lecom-modeler 0.40.0 → 0.41.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 vf=Object.create;var jn=Object.defineProperty,Nf=Object.defineProperties,wf=Object.getOwnPropertyDescriptor,If=Object.getOwnPropertyDescriptors,Af=Object.getOwnPropertyNames,Xr=Object.getOwnPropertySymbols,Cf=Object.getPrototypeOf,Ss=Object.prototype.hasOwnProperty,Ma=Object.prototype.propertyIsEnumerable;var Sa=(e,t,o)=>t in e?jn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,_=(e,t)=>{for(var o in t||(t={}))Ss.call(t,o)&&Sa(e,o,t[o]);if(Xr)for(var o of Xr(t))Ma.call(t,o)&&Sa(e,o,t[o]);return e},w=(e,t)=>Nf(e,If(t));var qt=(e,t)=>{var o={};for(var n in e)Ss.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Xr)for(var n of Xr(e))t.indexOf(n)<0&&Ma.call(e,n)&&(o[n]=e[n]);return o};var Sf=(e,t)=>{for(var o in t)jn(e,o,{get:t[o],enumerable:!0})},Pa=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Af(t))!Ss.call(e,r)&&r!==o&&jn(e,r,{get:()=>t[r],enumerable:!(n=wf(t,r))||n.enumerable});return e};var Mf=(e,t,o)=>(o=e!=null?vf(Cf(e)):{},Pa(t||!e||!e.__esModule?jn(o,"default",{value:e,enumerable:!0}):o,e)),Pf=e=>Pa(jn({},"__esModule",{value:!0}),e);var Oy={};Sf(Oy,{EditorMode:()=>Xe,ElementPosition:()=>$r,ElementType:()=>er,GatewayElementVariant:()=>Kr,GatewayVariant:()=>Pt,Modeler:()=>Tf,ModelerProvider:()=>xf,NodeAttribute:()=>Gt,NodeType:()=>se,NodeVariant:()=>dt,RoutingVariant:()=>qr,useModeler:()=>On});module.exports=Pf(Oy);var Ms=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 Ur=require("@produto-lecom/lecom-ui");var La={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Delete",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."},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:"The gateway does not have the correct number of outputs",events_nested:"Connecting events directly is not allowed",event_to_condition:"Connecting an event directly to a gateway is not allowed",script_in_final_activity:"Final activity cannot be a script type",subprocess_not_configured:"The subprocess reference is not properly configured",cannot_validate_subprocess_reference:"Could not validate whether the subprocess reference is configured",start_event_not_found:"At least one 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:"It is not possible to import the diagram from the Governance platform, since the diagram has already been initialized"},success:{default:"The diagram was imported from the Governance platform successfully and without any incompatibility detected.",incompatible_cells:"The diagram was imported from the Governance platform with incompatibilities. To know more details, click on the button below."},report:{columns:{type:"Type",value:"Value",status:"Status"},status:{imported:"Imported",adapted:"Adapted",unsupported:"Unsupported"}},action:{download:"Download report"}}}}};var ka={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",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."},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:"La compuerta no tiene el n\xFAmero correcto de salidas",events_nested:"No se permite conectar eventos directamente",event_to_condition:"No se permite conectar un evento directamente a una compuerta",script_in_final_activity:"La actividad final no puede ser de tipo script",subprocess_not_configured:"La referencia al subproceso no est\xE1 configurada correctamente",cannot_validate_subprocess_reference:"No fue posible validar si la referencia al subproceso est\xE1 configurada",start_event_not_found:"Es necesario tener al menos un evento de inicio",end_event_not_found:"Es necesario tener al menos un evento final",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:"No es posible importar el diagrama de la plataforma Governance, ya que el diagrama ya ha sido iniciado"},success:{default:"El diagrama se ha importado de la plataforma Governance correctamente y sin ninguna incompatibilidad detectada.",incompatible_cells:"El diagrama se ha importado de la plataforma Governance con incompatibilidades. Para saber m\xE1s detalles, haz click en el bot\xF3n de abajo."},report:{columns:{type:"Tipo",value:"Valor",status:"Estado"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"No soportado"}},action:{download:"Descargar informe"}}}}};var Ra={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Excluir",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."},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 v\xE1lidado com sucesso!",message:"Nenhum erro encontrado."},errors:{title:"O diagrama cont\xE9m erros",subtitle:"Veja abaixo o que precisa ser corrigido:",task_label_length:"O nome da atividade excede o limite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"N\xE3o \xE9 permitido ter mais de um evento de in\xEDcio",task_flows_limit_exceeds:"O n\xFAmero de conex\xF5es de sa\xEDda ultrapassa o limite de dois",duplicate_task_name:"H\xE1 v\xE1rias atividades com o mesmo nome",flows_on_end_tasks_not_allowed:"Atividades conectadas a eventos finais n\xE3o podem ter outras conex\xF5es",conditions_flows_limit_exceeds:"Gateway exclusivo com excesso de conex\xF5es de sa\xEDda (m\xE1ximo de dois)",task_label_empty:"O nome de uma ou mais atividades n\xE3o foi preenchido",activity_name_invalid:"O nome da atividade n\xE3o \xE9 v\xE1lido",final_activity_has_loop:"Atividades finais n\xE3o podem ter loops",nested_gateway:"N\xE3o \xE9 permitido conectar gateways",concurrent_initial_and_final_event:"Uma mesma atividade n\xE3o pode ter eventos iniciais e finais",gateway_flow_to_event:"N\xE3o \xE9 permitido conectar um gateway a um evento de sa\xEDda",gateway_missing_output_streams:"O gateway n\xE3o possui o n\xFAmero correto de sa\xEDdas",events_nested:"N\xE3o \xE9 permitido conectar eventos",event_to_condition:"N\xE3o \xE9 permitido conectar um evento diretamente em um gateway",script_in_final_activity:"Atividade final n\xE3o pode ser do tipo script",subprocess_not_configured:"A refer\xEAncia ao subprocesso n\xE3o est\xE1 configurada corretamente",cannot_validate_subprocess_reference:"N\xE3o foi poss\xEDvel validar se a refer\xEAncia ao subprocesso est\xE1 configurada",start_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento inicial",end_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento final",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:"N\xE3o \xE9 poss\xEDvel importar o diagrama da plataforma Governance, pois o diagrama j\xE1 foi iniciado"},success:{default:"O diagrama foi importado da plataforma Governance com sucesso e sem nenhuma incompatibilidade detectada.",incompatible_cells:"O diagrama foi importado da plataforma Governance com incompatibilidades. Para saber mais detalhes, clique no bot\xE3o abaixo."},report:{columns:{type:"Tipo do elemento",value:"Valor",status:"Status"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"N\xE3o suportado"}},action:{download:"Baixar relat\xF3rio"}}}}};var Da={pt_BR:Ra,en_US:La,es_ES:ka};var Oa,Va,Lf=(Va=(Oa=Ms("LecomUserLanguage"))!=null?Oa:Ms("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?Va:Ur.Translations.PT_BR;(0,Ur.initializeI18n)({lng:Lf,resources:Da});var Xe=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(Xe||{});var er=(i=>(i.ACTIVITY="activity",i.ROUTING="routing",i.GATEWAY="gateway",i.SUB_PROCESS="sub_process",i.SERVICE_TASK="service_task",i))(er||{}),$r=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))($r||{}),Kr=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Kr||{}),qr=(f=>(f.SIMPLE="simple",f.LOOP="loop",f.SCRIPT="script",f.SCRIPT_LOOP="script_loop",f.COMPLEX="complex",f.EXCLUSIVE="exclusive",f.PARALLEL="parallel",f.FINAL="final",f.TO_SUB_PROCESS="to_sub_process",f.FROM_SUB_PROCESS="from_sub_process",f.TO_SERVICE_TASK="to_service_task",f.FROM_SERVICE_TASK="from_service_task",f))(qr||{});var Co=require("lucide-react");var $o=require("react/jsx-runtime"),Zr=({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:"currentColor",className:t,children:[(0,$o.jsx)("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),(0,$o.jsx)("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),(0,$o.jsx)("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),(0,$o.jsx)("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});var Ps=require("react/jsx-runtime"),En=({size:e=24,className:t})=>(0,Ps.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,Ps.jsx)("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});var wo=require("react/jsx-runtime"),_n=({size:e=24,className:t})=>(0,wo.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,wo.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,wo.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,wo.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,wo.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,wo.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"),Ha=({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 Ga=require("clsx"),Ba=require("tailwind-merge");function H(...e){return(0,Ba.twMerge)((0,Ga.clsx)(e))}var Io=(e=0,t=0)=>e<t?t:e,Jr=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});var tr=require("react/jsx-runtime"),za=({size:e=24,className:t})=>(0,tr.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,tr.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,tr.jsx)("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});var Qr=require("react/jsx-runtime"),Ya=({size:e=24,className:t})=>(0,Qr.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:(0,Qr.jsx)("g",{children:(0,Qr.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 Ls=require("react/jsx-runtime"),jr=({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:"#5fd9b0",stroke:"#1cad86",strokeWidth:"2",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 ks=require("react/jsx-runtime"),or=({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:"white",stroke:"currentColor",className:H("stroke-2",t),children:(0,ks.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"),Fa=({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 Ao=require("react/jsx-runtime"),Wa=({size:e=24,className:t})=>(0,Ao.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[(0,Ao.jsx)("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Ao.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,Ao.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,Ao.jsx)("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Ao.jsx)("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var Ko=require("react/jsx-runtime"),nr=({size:e=24,className:t})=>(0,Ko.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[(0,Ko.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,Ko.jsx)("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),(0,Ko.jsx)("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Ko.jsx)("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var se=(s=>(s.START_EVENT="START_EVENT",s.END_EVENT="END_EVENT",s.TASK="TASK",s.LANE="LANE",s.GATEWAY="GATEWAY",s.ANNOTATION="ANNOTATION",s.UNSUPPORTED="UNSUPPORTED",s))(se||{}),dt=(n=>(n.SCRIPT="SCRIPT",n.SUBPROCESS="SUBPROCESS",n.SERVICE_TASK="SERVICE_TASK",n))(dt||{}),ei={SCRIPT:{icon:Co.ScrollText},SUBPROCESS:{icon:Co.SquarePlus},SERVICE_TASK:{icon:Co.Bot}},Gt=(t=>(t.LOOP="LOOP",t))(Gt||{}),ti={LOOP:{icon:Co.RotateCcw}},Pt=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(Pt||{}),Rs={EXCLUSIVE:{icon:Tn},PARALLEL:{icon:Nn},COMPLEX:{icon:_n}};var Ef=require("@produto-lecom/lecom-ui"),_f=require("@xyflow/react"),De=require("react");var co=require("@xyflow/react"),xn=require("react");var Ip=require("@produto-lecom/lecom-ui"),so=require("@xyflow/react"),At=require("react");var oi={MIN_WIDTH:36,MIN_HEIGHT:36},ni={MIN_WIDTH:36,MIN_HEIGHT:36},An={MIN_WIDTH:56,MIN_HEIGHT:56},So={MIN_WIDTH:176,MIN_HEIGHT:96},Xa={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},ae={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},Cn={MIN_WIDTH:176,MIN_HEIGHT:64},kf={MIN_WIDTH:128,MIN_HEIGHT:64},ue={START_EVENT:oi,END_EVENT:ni,GATEWAY:An,TASK:So,LANE:ae,ANNOTATION:Cn,UNSUPPORTED:kf};var Sn=require("@xyflow/react");function Ua(e,t){var x,T,b,N;let{width:o=0,height:n=0}=e.measured||{width:0,height:0},r=e.internals.positionAbsolute,i=t.internals.positionAbsolute,a=o/2,s=n/2,l=r.x+a,c=r.y+s,d=i.x+((T=(x=t==null?void 0:t.measured)==null?void 0:x.width)!=null?T:0)/2,p=i.y+((N=(b=t==null?void 0:t.measured)==null?void 0:b.height)!=null?N:0)/2,f=(d-l)/(2*a)-(p-c)/(2*s),m=(d-l)/(2*a)+(p-c)/(2*s),y=1/(Math.abs(f)+Math.abs(m)||1),E=y*f,u=y*m,g=a*(E+u)+l,h=s*(-E+u)+c;return{x:g,y:h}}function $a(e,t){var c,d,p,f;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(f=(p=e.measured)==null?void 0:p.height)!=null?f:0,i=Math.round(o.x),a=Math.round(o.y),s=Math.round(t.x),l=Math.round(t.y);return s<=i+1?Sn.Position.Left:s>=i+n-1?Sn.Position.Right:l<=a+1?Sn.Position.Top:l>=a+r-1?Sn.Position.Bottom:Sn.Position.Top}function Mn(e,t){let o=Ua(e,t),n=Ua(t,e),r=$a(e,o),i=$a(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 Ka=require("lodash");var qa=e=>new Map(e.map(t=>[t.id,t])),Za=(e,t)=>e.map(o=>{var n;return(n=t.get(o.id))!=null?n:o}),Lt=e=>{var t,o,n,r,i,a,s,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(r=(n=e.internals)==null?void 0:n.positionAbsolute.y)!=null?r:0,w:(a=(i=e.measured)==null?void 0:i.width)!=null?a:0,h:(l=(s=e.measured)==null?void 0:s.height)!=null?l:0}},rr=e=>(0,Ka.orderBy)(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),Ja=(e,t)=>{let{x:o,y:n}=Lt(e),{x:r,y:i}=Lt(t);return{x:o-r,y:n-i}};var qo=({parentId:e,nodes:t,includeTypes:o=[...Object.values(se)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),Rf=(e,t)=>{let{x:o,y:n}=Lt(e),{x:r,y:i}=Lt(t),a=o-r,s=n-i;return Math.sqrt(a*a+s*s)},Df=(e,t)=>{let{x:o,y:n,w:r,h:i}=Lt(e),{x:a,y:s,w:l,h:c}=Lt(t),d=o+r/2,p=n+i/2;return d>=a&&d<=a+l&&p>=s&&p<=s+c},ir=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&Df(e,r)){let i=Rf(e,r);i<n&&(n=i,o=r)}return o},Qa=(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 ja=e=>{let t=e.filter(a=>!a.parentId);if(t.length===0)return null;let o=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of t){let{position:s,width:l,height:c}=a,d=s.x+(l||0),p=s.y+(c||0);s.x<o&&(o=s.x),s.y<n&&(n=s.y),d>r&&(r=d),p>i&&(i=p)}return{x:o,y:n,w:r-o,h:i-n}},el=({bounds:e,canvasWidth:t,canvasHeight:o,minZoom:n=.5,maxZoom:r=5,offsetX:i=0,offsetY:a=0})=>{let s=t-i*2,l=o-a*2,c=Math.min(s/e.w,l/e.h),d=Math.min(1,c),p=Math.min(Math.max(d,n),r);return{x:-e.x*p+i,y:-e.y*p+a,zoom:p}};var Ds=(e,t)=>{let o=t.find(a=>a.id===e);if(!o||o.type!=="LANE"||o.parentId)return!1;let n=Lt(o),r=n.x+n.w,i=n.y+n.h;return t.some(a=>{if(a.id===e||a.parentId||a.type==="LANE")return!1;let s=Lt(a);return s.x<r&&s.x+s.w>n.x&&s.y<i&&s.y+s.h>n.y})};var Of=50,Zo=(e,t)=>{var f,m,y,E,u,g,h,x,T,b,N,v,I,C,P,R;let o=t.find(S=>S.id===e);if(!o)return t;let n=(m=(f=o.position)==null?void 0:f.x)!=null?m:0,r=(E=(y=o.position)==null?void 0:y.y)!=null?E:0,i=(g=(u=o.measured)==null?void 0:u.width)!=null?g:0,a=(x=(h=o.measured)==null?void 0:h.height)!=null?x:0,s=r+a,l=n+i,c=new Set,d=1/0;for(let S of t){if(S.id===e||S.parentId)continue;let L=(b=(T=S.position)==null?void 0:T.y)!=null?b:0,K=(v=(N=S.position)==null?void 0:N.x)!=null?v:0,j=(C=(I=S.measured)==null?void 0:I.width)!=null?C:0,Q=(R=(P=S.measured)==null?void 0:P.height)!=null?R:0;K<l&&K+j>n&&L<s&&L+Q>r&&(c.add(S.id),d=Math.min(d,L))}if(c.size===0)return t;let p=s+Of-d;return t.map(S=>{var K,j,Q;if(!c.has(S.id))return S;let L=(j=(K=S.position)==null?void 0:K.y)!=null?j:0;return w(_({},S),{position:w(_({},(Q=S.position)!=null?Q:{x:0,y:0}),{y:L+p})})})},ze=15,Jo=e=>[...e].sort((t,o)=>t.position.y-o.position.y),Vf=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)},Hf=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)},Os=(e,t,o)=>{var d,p,f,m,y,E,u,g,h,x,T,b,N,v,I;if(t.length===0)return e;let n=(f=(p=e.width)!=null?p:(d=e.measured)==null?void 0:d.width)!=null?f:0,r=(E=(y=e.height)!=null?y:(m=e.measured)==null?void 0:m.height)!=null?E:0,i=0,a=0;for(let C of t){let P=Vf(C),R=Hf(C);if(((g=(u=C.position)==null?void 0:u.y)!=null?g:0)<ze&&(o.set(C.id,w(_({},C),{position:w(_({},C.position),{y:ze})})),R=ze+((x=(h=C.measured)==null?void 0:h.height)!=null?x:0)),((b=(T=C.position)==null?void 0:T.x)!=null?b:0)<ae.HEADER_WIDTH+ze){let S=(N=o.get(C.id))!=null?N:C;o.set(C.id,w(_({},S),{position:w(_({},S.position),{x:ae.HEADER_WIDTH+ze})})),P=ae.HEADER_WIDTH+ze+((I=(v=C.measured)==null?void 0:v.width)!=null?I:0)}i=Math.max(i,P),a=Math.max(a,R)}let s=Math.max(n,ae.MIN_WIDTH),l=Math.max(r,ae.MIN_HEIGHT);i+ze>s&&(s=i+ze),a+ze>l&&(l=a+ze);let c=w(_({},e),{width:s,height:l,measured:w(_({},e.measured),{width:s,height:l})});return o.set(e.id,c),c},tl=(e,t,o)=>{var a,s;let n=Jo(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=(a=r.get(l.id))!=null?a:[],d=Os(l,c,t);t.set(d.id,w(_({},d),{position:{x:ae.HEADER_WIDTH,y:i}})),i+=(s=d.height)!=null?s:0}},ol=(e,t)=>{var y,E,u,g;let o=[];for(let h of t.values())h.parentId===e.id&&o.push(h);let n=Jo(o),r=((E=(y=e.measured)==null?void 0:y.width)!=null?E:0)-ae.HEADER_WIDTH,i=Qa(e.id,o)||ae.MIN_WIDTH,a=o.reduce((h,x)=>{var T;return h+((T=x.height)!=null?T:ae.MIN_HEIGHT)},0),s=Math.max(r,i),l=a,c=r>i,d=c?s:s+ae.HEADER_WIDTH,p=c?s-ae.HEADER_WIDTH:s,f=0;for(let h=0;h<n.length;h++){let x=n[h],T=Math.max(ae.MIN_HEIGHT,(u=x.height)!=null?u:ae.MIN_HEIGHT),b=w(_({},x),{width:p,height:T,measured:w(_({},x.measured),{width:p,height:T}),position:{x:ae.HEADER_WIDTH,y:f}});if(h===o.length-1){let N=Math.max(ae.MIN_HEIGHT,l-f);b=w(_({},b),{height:N,measured:w(_({},x.measured),{width:p,height:N})})}t.set(x.id,b),f+=(g=b.height)!=null?g:0}let m=Math.max(l,f);t.set(e.id,w(_({},e),{width:d,height:m,measured:w(_({},e.measured),{width:d,height:m})}))},nl=(e,t,o,n,r)=>{var y,E;let i=!e.parentId,a=i?e.id:e.parentId,s=n.filter(u=>u.type==="LANE"&&u.parentId===a);if(!s.length)return n;let l=Jo(s),c=l.findIndex(u=>u.id===e.id),d=(E=(y=e.position)==null?void 0:y.y)!=null?E:0,p=!i&&r!==void 0&&c>0&&Math.abs(r-d)>.5,f=0,m=[...n];return l.forEach((u,g)=>{var N,v;let h=g===l.length-1,x=u.id===e.id,b=(v=(N=u.measured)==null?void 0:N.height)!=null?v:0;x?b=o:p&&g===c-1&&(b=Math.max(ae.MIN_HEIGHT,r-f)),h&&i&&(b=Math.max(ae.MIN_HEIGHT,o-f)),m=m.map(I=>{if(I.id===u.id){let C=i?t-ae.HEADER_WIDTH:t;return w(_({},I),{width:C,height:b,measured:w(_({},I.measured),{width:C,height:b}),position:{x:ae.HEADER_WIDTH,y:f}})}return I}),x&&p?f=r+o:f+=b}),m=m.map(u=>{if(u.id===a){let g=i?t:t+ae.HEADER_WIDTH;return w(_({},u),{width:g,height:i?o:f,measured:{width:g,height:i?o:f}})}return u}),m};var Vs=(e,t,o)=>{var s,l,c,d,p,f,m,y;if(e.type==="LANE")return o;let n=(l=(s=t.measured)==null?void 0:s.width)!=null?l:0,r=(d=(c=t.measured)==null?void 0:c.height)!=null?d:0;e.position.y<ze&&(e.position.y=ze),e.position.x<ae.HEADER_WIDTH+ze&&(e.position.x=ae.HEADER_WIDTH+ze);let i=e.position.x+((f=(p=e.measured)==null?void 0:p.width)!=null?f:0),a=e.position.y+((y=(m=e.measured)==null?void 0:m.height)!=null?y:0);return i+ze>n&&(t.width=i+ze,t.measured.width=i+ze),a+ze>r&&(t.height=a+ze,t.measured.height=a+ze),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 il=require("react"),sl=require("zustand");var rl=require("@xyflow/react"),Zt=()=>{let e=(0,rl.useStoreApi)();return{selectElements:n=>{let{edges:r,nodes:i,triggerEdgeChanges:a,triggerNodeChanges:s}=e.getState(),l=i.reduce((d,p)=>[...d,{id:p.id,type:"select",selected:n.includes(p.id)}],[]),c=r.reduce((d,p)=>[...d,{id:p.id,type:"select",selected:n.includes(p.id)}],[]);return s(l),a(c),!0},clearSelection:async()=>{let{unselectNodesAndEdges:n}=e.getState();return n(),await Jr(),!0}}};var al=()=>{let{selectElements:e}=Zt();return(0,il.useCallback)(()=>{let o=Qo.getState().pathEdgeIds;e(o)},[e])},Qo=(0,sl.create)((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=_({},n.statusByNodeId),i=_({},n.statusData),a=!1;return o.forEach(s=>{let l=`${s.diagramId}-${s.activityId}`;r[s.diagramId]!==s.status&&(r[s.diagramId]=s.status,i[l]=s,a=!0)}),a?{statusByNodeId:r,statusData:i}:n})},getTaskStatus:o=>t().statusByNodeId[o]||null,clearTaskStatuses:()=>e({statusByNodeId:{},statusData:{},pathEdgeIds:[]}),setPathEdges:o=>{e({pathEdgeIds:o})},getPathEdgeIds:()=>t().pathEdgeIds,clearPathEdges:()=>{e({pathEdgeIds:[]})},calculateFlowPath:(o,n)=>{if(!o.length||!n.length)return;t().clearPathEdges();let r=n.filter(d=>t().statusByNodeId[d]);if(r.length<=1)return;let i=[],a={};o.forEach(d=>{a[d.source]||(a[d.source]=[]),a[d.source].push({targetId:d.target,edgeId:d.id})});let s=r[0],l=r[r.length-1];o.forEach(d=>{d.target===s&&i.push(d.id)}),o.forEach(d=>{d.source===l&&i.push(d.id)});let c=(d,p)=>{let f=[],m=new Set;for(f.push({node:d,path:[]}),m.add(d);f.length>0;){let{node:y,path:E}=f.shift();if(y===p)return E;let u=a[y]||[];for(let{targetId:g,edgeId:h}of u)m.has(g)||(m.add(g),f.push({node:g,path:[...E,h]}))}return[]};for(let d=0;d<r.length-1;d++){let p=r[d],f=r[d+1],m=c(p,f);m.length>0&&i.push(...m)}i.length>0&&e({pathEdgeIds:i})}}));var Dn=require("@xyflow/react"),yt=require("react"),td=require("zustand/shallow");var Gf={value:()=>{}};function cl(){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 ii(o)}function ii(e){this._=e}function Bf(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}})}ii.prototype=cl.prototype={constructor:ii,on:function(e,t){var o=this._,n=Bf(e+"",o),r,i=-1,a=n.length;if(arguments.length<2){for(;++i<a;)if((r=(e=n[i]).type)&&(r=zf(o[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<a;)if(r=(e=n[i]).type)o[r]=ll(o[r],e.name,t);else if(t==null)for(r in o)o[r]=ll(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 ii(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 zf(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function ll(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=Gf,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var Hs=cl;var si="http://www.w3.org/1999/xhtml",Gs={svg:"http://www.w3.org/2000/svg",xhtml:si,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function mo(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),Gs.hasOwnProperty(t)?{space:Gs[t],local:e}:e}function Yf(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===si&&t.documentElement.namespaceURI===si?t.createElement(e):t.createElementNS(o,e)}}function Ff(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function ai(e){var t=mo(e);return(t.local?Ff:Yf)(t)}function Wf(){}function jo(e){return e==null?Wf:function(){return this.querySelector(e)}}function dl(e){typeof e!="function"&&(e=jo(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=new Array(a),l,c,d=0;d<a;++d)(l=i[d])&&(c=e.call(l,l.__data__,d,i))&&("__data__"in l&&(c.__data__=l.__data__),s[d]=c);return new Ze(n,this._parents)}function Bs(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Xf(){return[]}function sr(e){return e==null?Xf:function(){return this.querySelectorAll(e)}}function Uf(e){return function(){return Bs(e.apply(this,arguments))}}function ul(e){typeof e=="function"?e=Uf(e):e=sr(e);for(var t=this._groups,o=t.length,n=[],r=[],i=0;i<o;++i)for(var a=t[i],s=a.length,l,c=0;c<s;++c)(l=a[c])&&(n.push(e.call(l,l.__data__,c,a)),r.push(l));return new Ze(n,r)}function ar(e){return function(){return this.matches(e)}}function li(e){return function(t){return t.matches(e)}}var $f=Array.prototype.find;function Kf(e){return function(){return $f.call(this.children,e)}}function qf(){return this.firstElementChild}function pl(e){return this.select(e==null?qf:Kf(typeof e=="function"?e:li(e)))}var Zf=Array.prototype.filter;function Jf(){return Array.from(this.children)}function Qf(e){return function(){return Zf.call(this.children,e)}}function fl(e){return this.selectAll(e==null?Jf:Qf(typeof e=="function"?e:li(e)))}function ml(e){typeof e!="function"&&(e=ar(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=[],l,c=0;c<a;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&s.push(l);return new Ze(n,this._parents)}function ci(e){return new Array(e.length)}function gl(){return new Ze(this._enter||this._groups.map(ci),this._parents)}function lr(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}lr.prototype={constructor:lr,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 hl(e){return function(){return e}}function jf(e,t,o,n,r,i){for(var a=0,s,l=t.length,c=i.length;a<c;++a)(s=t[a])?(s.__data__=i[a],n[a]=s):o[a]=new lr(e,i[a]);for(;a<l;++a)(s=t[a])&&(r[a]=s)}function em(e,t,o,n,r,i,a){var s,l,c=new Map,d=t.length,p=i.length,f=new Array(d),m;for(s=0;s<d;++s)(l=t[s])&&(f[s]=m=a.call(l,l.__data__,s,t)+"",c.has(m)?r[s]=l:c.set(m,l));for(s=0;s<p;++s)m=a.call(e,i[s],s,i)+"",(l=c.get(m))?(n[s]=l,l.__data__=i[s],c.delete(m)):o[s]=new lr(e,i[s]);for(s=0;s<d;++s)(l=t[s])&&c.get(f[s])===l&&(r[s]=l)}function tm(e){return e.__data__}function yl(e,t){if(!arguments.length)return Array.from(this,tm);var o=t?em:jf,n=this._parents,r=this._groups;typeof e!="function"&&(e=hl(e));for(var i=r.length,a=new Array(i),s=new Array(i),l=new Array(i),c=0;c<i;++c){var d=n[c],p=r[c],f=p.length,m=om(e.call(d,d&&d.__data__,c,n)),y=m.length,E=s[c]=new Array(y),u=a[c]=new Array(y),g=l[c]=new Array(f);o(d,p,E,u,g,m,t);for(var h=0,x=0,T,b;h<y;++h)if(T=E[h]){for(h>=x&&(x=h+1);!(b=u[x])&&++x<y;);T._next=b||null}}return a=new Ze(a,n),a._enter=s,a._exit=l,a}function om(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function xl(){return new Ze(this._exit||this._groups.map(ci),this._parents)}function El(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 _l(e){for(var t=e.selection?e.selection():e,o=this._groups,n=t._groups,r=o.length,i=n.length,a=Math.min(r,i),s=new Array(r),l=0;l<a;++l)for(var c=o[l],d=n[l],p=c.length,f=s[l]=new Array(p),m,y=0;y<p;++y)(m=c[y]||d[y])&&(f[y]=m);for(;l<r;++l)s[l]=o[l];return new Ze(s,this._parents)}function bl(){for(var e=this._groups,t=-1,o=e.length;++t<o;)for(var n=e[t],r=n.length-1,i=n[r],a;--r>=0;)(a=n[r])&&(i&&a.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(a,i),i=a);return this}function Tl(e){e||(e=nm);function t(p,f){return p&&f?e(p.__data__,f.__data__):!p-!f}for(var o=this._groups,n=o.length,r=new Array(n),i=0;i<n;++i){for(var a=o[i],s=a.length,l=r[i]=new Array(s),c,d=0;d<s;++d)(c=a[d])&&(l[d]=c);l.sort(t)}return new Ze(r,this._parents).order()}function nm(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function vl(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Nl(){return Array.from(this)}function wl(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length;r<i;++r){var a=n[r];if(a)return a}return null}function Il(){let e=0;for(let t of this)++e;return e}function Al(){return!this.node()}function Cl(e){for(var t=this._groups,o=0,n=t.length;o<n;++o)for(var r=t[o],i=0,a=r.length,s;i<a;++i)(s=r[i])&&e.call(s,s.__data__,i,r);return this}function rm(e){return function(){this.removeAttribute(e)}}function im(e){return function(){this.removeAttributeNS(e.space,e.local)}}function sm(e,t){return function(){this.setAttribute(e,t)}}function am(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function lm(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function cm(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 Sl(e,t){var o=mo(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?im:rm:typeof t=="function"?o.local?cm:lm:o.local?am:sm)(o,t))}function di(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function dm(e){return function(){this.style.removeProperty(e)}}function um(e,t,o){return function(){this.style.setProperty(e,t,o)}}function pm(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function Ml(e,t,o){return arguments.length>1?this.each((t==null?dm:typeof t=="function"?pm:um)(e,t,o==null?"":o)):Mo(this.node(),e)}function Mo(e,t){return e.style.getPropertyValue(t)||di(e).getComputedStyle(e,null).getPropertyValue(t)}function fm(e){return function(){delete this[e]}}function mm(e,t){return function(){this[e]=t}}function gm(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function Pl(e,t){return arguments.length>1?this.each((t==null?fm:typeof t=="function"?gm:mm)(e,t)):this.node()[e]}function Ll(e){return e.trim().split(/^|\s+/)}function zs(e){return e.classList||new kl(e)}function kl(e){this._node=e,this._names=Ll(e.getAttribute("class")||"")}kl.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 Rl(e,t){for(var o=zs(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function Dl(e,t){for(var o=zs(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function hm(e){return function(){Rl(this,e)}}function ym(e){return function(){Dl(this,e)}}function xm(e,t){return function(){(t.apply(this,arguments)?Rl:Dl)(this,e)}}function Ol(e,t){var o=Ll(e+"");if(arguments.length<2){for(var n=zs(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?xm:t?hm:ym)(o,t))}function Em(){this.textContent=""}function _m(e){return function(){this.textContent=e}}function bm(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function Vl(e){return arguments.length?this.each(e==null?Em:(typeof e=="function"?bm:_m)(e)):this.node().textContent}function Tm(){this.innerHTML=""}function vm(e){return function(){this.innerHTML=e}}function Nm(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function Hl(e){return arguments.length?this.each(e==null?Tm:(typeof e=="function"?Nm:vm)(e)):this.node().innerHTML}function wm(){this.nextSibling&&this.parentNode.appendChild(this)}function Gl(){return this.each(wm)}function Im(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Bl(){return this.each(Im)}function zl(e){var t=typeof e=="function"?e:ai(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Am(){return null}function Yl(e,t){var o=typeof e=="function"?e:ai(e),n=t==null?Am:typeof t=="function"?t:jo(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function Cm(){var e=this.parentNode;e&&e.removeChild(this)}function Fl(){return this.each(Cm)}function Sm(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Mm(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Wl(e){return this.select(e?Mm:Sm)}function Xl(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Pm(e){return function(t){e.call(this,t,this.__data__)}}function Lm(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 km(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 Rm(e,t,o){return function(){var n=this.__on,r,i=Pm(t);if(n){for(var a=0,s=n.length;a<s;++a)if((r=n[a]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=o),r.value=t;return}}this.addEventListener(e.type,i,o),r={type:e.type,name:e.name,value:t,listener:i,options:o},n?n.push(r):this.__on=[r]}}function Ul(e,t,o){var n=Lm(e+""),r,i=n.length,a;if(arguments.length<2){var s=this.node().__on;if(s){for(var l=0,c=s.length,d;l<c;++l)for(r=0,d=s[l];r<i;++r)if((a=n[r]).type===d.type&&a.name===d.name)return d.value}return}for(s=t?Rm:km,r=0;r<i;++r)this.each(s(n[r],t,o));return this}function $l(e,t,o){var n=di(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 Dm(e,t){return function(){return $l(this,e,t)}}function Om(e,t){return function(){return $l(this,e,t.apply(this,arguments))}}function Kl(e,t){return this.each((typeof t=="function"?Om:Dm)(e,t))}function*ql(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length,a;r<i;++r)(a=n[r])&&(yield a)}var Vm=[null];function Ze(e,t){this._groups=e,this._parents=t}function Zl(){return new Ze([[document.documentElement]],Vm)}function Hm(){return this}Ze.prototype=Zl.prototype={constructor:Ze,select:dl,selectAll:ul,selectChild:pl,selectChildren:fl,filter:ml,data:yl,enter:gl,exit:xl,join:El,merge:_l,selection:Hm,order:bl,sort:Tl,call:vl,nodes:Nl,node:wl,size:Il,empty:Al,each:Cl,attr:Sl,style:Ml,property:Pl,classed:Ol,text:Vl,html:Hl,raise:Gl,lower:Bl,append:zl,insert:Yl,remove:Fl,clone:Wl,datum:Xl,on:Ul,dispatch:Kl,[Symbol.iterator]:ql};var go=Zl;function ui(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function Ys(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function ur(){}var cr=.7,mi=1/cr,Pn="\\s*([+-]?\\d+)\\s*",dr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Jt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Gm=/^#([0-9a-f]{3,8})$/,Bm=new RegExp(`^rgb\\(${Pn},${Pn},${Pn}\\)$`),zm=new RegExp(`^rgb\\(${Jt},${Jt},${Jt}\\)$`),Ym=new RegExp(`^rgba\\(${Pn},${Pn},${Pn},${dr}\\)$`),Fm=new RegExp(`^rgba\\(${Jt},${Jt},${Jt},${dr}\\)$`),Wm=new RegExp(`^hsl\\(${dr},${Jt},${Jt}\\)$`),Xm=new RegExp(`^hsla\\(${dr},${Jt},${Jt},${dr}\\)$`),Jl={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};ui(ur,Po,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Ql,formatHex:Ql,formatHex8:Um,formatHsl:$m,formatRgb:jl,toString:jl});function Ql(){return this.rgb().formatHex()}function Um(){return this.rgb().formatHex8()}function $m(){return ic(this).formatHsl()}function jl(){return this.rgb().formatRgb()}function Po(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=Gm.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?ec(t):o===3?new ut(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?pi(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?pi(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=Bm.exec(e))?new ut(t[1],t[2],t[3],1):(t=zm.exec(e))?new ut(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Ym.exec(e))?pi(t[1],t[2],t[3],t[4]):(t=Fm.exec(e))?pi(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Wm.exec(e))?nc(t[1],t[2]/100,t[3]/100,1):(t=Xm.exec(e))?nc(t[1],t[2]/100,t[3]/100,t[4]):Jl.hasOwnProperty(e)?ec(Jl[e]):e==="transparent"?new ut(NaN,NaN,NaN,0):null}function ec(e){return new ut(e>>16&255,e>>8&255,e&255,1)}function pi(e,t,o,n){return n<=0&&(e=t=o=NaN),new ut(e,t,o,n)}function Km(e){return e instanceof ur||(e=Po(e)),e?(e=e.rgb(),new ut(e.r,e.g,e.b,e.opacity)):new ut}function Ln(e,t,o,n){return arguments.length===1?Km(e):new ut(e,t,o,n==null?1:n)}function ut(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}ui(ut,Ln,Ys(ur,{brighter(e){return e=e==null?mi:Math.pow(mi,e),new ut(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?cr:Math.pow(cr,e),new ut(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ut(tn(this.r),tn(this.g),tn(this.b),gi(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:tc,formatHex:tc,formatHex8:qm,formatRgb:oc,toString:oc}));function tc(){return`#${en(this.r)}${en(this.g)}${en(this.b)}`}function qm(){return`#${en(this.r)}${en(this.g)}${en(this.b)}${en((isNaN(this.opacity)?1:this.opacity)*255)}`}function oc(){let e=gi(this.opacity);return`${e===1?"rgb(":"rgba("}${tn(this.r)}, ${tn(this.g)}, ${tn(this.b)}${e===1?")":`, ${e})`}`}function gi(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function tn(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function en(e){return e=tn(e),(e<16?"0":"")+e.toString(16)}function nc(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new Bt(e,t,o,n)}function ic(e){if(e instanceof Bt)return new Bt(e.h,e.s,e.l,e.opacity);if(e instanceof ur||(e=Po(e)),!e)return new Bt;if(e instanceof Bt)return e;e=e.rgb();var t=e.r/255,o=e.g/255,n=e.b/255,r=Math.min(t,o,n),i=Math.max(t,o,n),a=NaN,s=i-r,l=(i+r)/2;return s?(t===i?a=(o-n)/s+(o<n)*6:o===i?a=(n-t)/s+2:a=(t-o)/s+4,s/=l<.5?i+r:2-i-r,a*=60):s=l>0&&l<1?0:a,new Bt(a,s,l,e.opacity)}function sc(e,t,o,n){return arguments.length===1?ic(e):new Bt(e,t,o,n==null?1:n)}function Bt(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}ui(Bt,sc,Ys(ur,{brighter(e){return e=e==null?mi:Math.pow(mi,e),new Bt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?cr:Math.pow(cr,e),new Bt(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 ut(Fs(e>=240?e-240:e+120,r,n),Fs(e,r,n),Fs(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new Bt(rc(this.h),fi(this.s),fi(this.l),gi(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=gi(this.opacity);return`${e===1?"hsl(":"hsla("}${rc(this.h)}, ${fi(this.s)*100}%, ${fi(this.l)*100}%${e===1?")":`, ${e})`}`}}));function rc(e){return e=(e||0)%360,e<0?e+360:e}function fi(e){return Math.max(0,Math.min(1,e||0))}function Fs(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 Ws(e,t,o,n,r){var i=e*e,a=i*e;return((1-3*e+3*i-a)*t+(4-6*i+3*a)*o+(1+3*e+3*i-3*a)*n+a*r)/6}function ac(e){var t=e.length-1;return function(o){var n=o<=0?o=0:o>=1?(o=1,t-1):Math.floor(o*t),r=e[n],i=e[n+1],a=n>0?e[n-1]:2*r-i,s=n<t-1?e[n+2]:2*i-r;return Ws((o-n/t)*t,a,r,i,s)}}function lc(e){var t=e.length;return function(o){var n=Math.floor(((o%=1)<0?++o:o)*t),r=e[(n+t-1)%t],i=e[n%t],a=e[(n+1)%t],s=e[(n+2)%t];return Ws((o-n/t)*t,r,i,a,s)}}var Xs=e=>()=>e;function Zm(e,t){return function(o){return e+o*t}}function Jm(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 cc(e){return(e=+e)==1?hi:function(t,o){return o-t?Jm(t,o,e):Xs(isNaN(t)?o:t)}}function hi(e,t){var o=t-e;return o?Zm(e,o):Xs(isNaN(e)?t:e)}var yi=function e(t){var o=cc(t);function n(r,i){var a=o((r=Ln(r)).r,(i=Ln(i)).r),s=o(r.g,i.g),l=o(r.b,i.b),c=hi(r.opacity,i.opacity);return function(d){return r.r=a(d),r.g=s(d),r.b=l(d),r.opacity=c(d),r+""}}return n.gamma=e,n}(1);function dc(e){return function(t){var o=t.length,n=new Array(o),r=new Array(o),i=new Array(o),a,s;for(a=0;a<o;++a)s=Ln(t[a]),n[a]=s.r||0,r[a]=s.g||0,i[a]=s.b||0;return n=e(n),r=e(r),i=e(i),s.opacity=1,function(l){return s.r=n(l),s.g=r(l),s.b=i(l),s+""}}}var Qm=dc(ac),jm=dc(lc);function kt(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var $s=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Us=new RegExp($s.source,"g");function eg(e){return function(){return e}}function tg(e){return function(t){return e(t)+""}}function Ks(e,t){var o=$s.lastIndex=Us.lastIndex=0,n,r,i,a=-1,s=[],l=[];for(e=e+"",t=t+"";(n=$s.exec(e))&&(r=Us.exec(t));)(i=r.index)>o&&(i=t.slice(o,i),s[a]?s[a]+=i:s[++a]=i),(n=n[0])===(r=r[0])?s[a]?s[a]+=r:s[++a]=r:(s[++a]=null,l.push({i:a,x:kt(n,r)})),o=Us.lastIndex;return o<t.length&&(i=t.slice(o),s[a]?s[a]+=i:s[++a]=i),s.length<2?l[0]?tg(l[0].x):eg(t):(t=l.length,function(c){for(var d=0,p;d<t;++d)s[(p=l[d]).i]=p.x(c);return s.join("")})}var uc=180/Math.PI,xi={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function qs(e,t,o,n,r,i){var a,s,l;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(l=e*o+t*n)&&(o-=e*l,n-=t*l),(s=Math.sqrt(o*o+n*n))&&(o/=s,n/=s,l/=s),e*n<t*o&&(e=-e,t=-t,l=-l,a=-a),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*uc,skewX:Math.atan(l)*uc,scaleX:a,scaleY:s}}var Ei;function pc(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?xi:qs(t.a,t.b,t.c,t.d,t.e,t.f)}function fc(e){return e==null?xi:(Ei||(Ei=document.createElementNS("http://www.w3.org/2000/svg","g")),Ei.setAttribute("transform",e),(e=Ei.transform.baseVal.consolidate())?(e=e.matrix,qs(e.a,e.b,e.c,e.d,e.e,e.f)):xi)}function mc(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,p,f,m,y){if(c!==p||d!==f){var E=m.push("translate(",null,t,null,o);y.push({i:E-4,x:kt(c,p)},{i:E-2,x:kt(d,f)})}else(p||f)&&m.push("translate("+p+t+f+o)}function a(c,d,p,f){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),f.push({i:p.push(r(p)+"rotate(",null,n)-2,x:kt(c,d)})):d&&p.push(r(p)+"rotate("+d+n)}function s(c,d,p,f){c!==d?f.push({i:p.push(r(p)+"skewX(",null,n)-2,x:kt(c,d)}):d&&p.push(r(p)+"skewX("+d+n)}function l(c,d,p,f,m,y){if(c!==p||d!==f){var E=m.push(r(m)+"scale(",null,",",null,")");y.push({i:E-4,x:kt(c,p)},{i:E-2,x:kt(d,f)})}else(p!==1||f!==1)&&m.push(r(m)+"scale("+p+","+f+")")}return function(c,d){var p=[],f=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,p,f),a(c.rotate,d.rotate,p,f),s(c.skewX,d.skewX,p,f),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,p,f),c=d=null,function(m){for(var y=-1,E=f.length,u;++y<E;)p[(u=f[y]).i]=u.x(m);return p.join("")}}}var Zs=mc(pc,"px, ","px)","deg)"),Js=mc(fc,", ",")",")");var kn=0,fr=0,pr=0,hc=1e3,_i,mr,bi=0,on=0,Ti=0,gr=typeof performance=="object"&&performance.now?performance:Date,yc=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function yr(){return on||(yc(og),on=gr.now()+Ti)}function og(){on=0}function hr(){this._call=this._time=this._next=null}hr.prototype=vi.prototype={constructor:hr,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?yr():+o)+(t==null?0:+t),!this._next&&mr!==this&&(mr?mr._next=this:_i=this,mr=this),this._call=e,this._time=o,Qs()},stop:function(){this._call&&(this._call=null,this._time=1/0,Qs())}};function vi(e,t,o){var n=new hr;return n.restart(e,t,o),n}function xc(){yr(),++kn;for(var e=_i,t;e;)(t=on-e._time)>=0&&e._call.call(void 0,t),e=e._next;--kn}function gc(){on=(bi=gr.now())+Ti,kn=fr=0;try{xc()}finally{kn=0,rg(),on=0}}function ng(){var e=gr.now(),t=e-bi;t>hc&&(Ti-=t,bi=e)}function rg(){for(var e,t=_i,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:_i=o);mr=e,Qs(n)}function Qs(e){if(!kn){fr&&(fr=clearTimeout(fr));var t=e-on;t>24?(e<1/0&&(fr=setTimeout(gc,e-gr.now()-Ti)),pr&&(pr=clearInterval(pr))):(pr||(bi=gr.now(),pr=setInterval(ng,hc)),kn=1,yc(gc))}}function Ni(e,t,o){var n=new hr;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var ig=Hs("start","end","cancel","interrupt"),sg=[],bc=0,Ec=1,Ii=2,wi=3,_c=4,Ai=5,xr=6;function Lo(e,t,o,n,r,i){var a=e.__transition;if(!a)e.__transition={};else if(o in a)return;ag(e,o,{name:t,index:n,group:r,on:ig,tween:sg,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:bc})}function Er(e,t){var o=Je(e,t);if(o.state>bc)throw new Error("too late; already scheduled");return o}function nt(e,t){var o=Je(e,t);if(o.state>wi)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 ag(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=vi(i,0,o.time);function i(c){o.state=Ec,o.timer.restart(a,o.delay,o.time),o.delay<=c&&a(c-o.delay)}function a(c){var d,p,f,m;if(o.state!==Ec)return l();for(d in n)if(m=n[d],m.name===o.name){if(m.state===wi)return Ni(a);m.state===_c?(m.state=xr,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete n[d]):+d<t&&(m.state=xr,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete n[d])}if(Ni(function(){o.state===wi&&(o.state=_c,o.timer.restart(s,o.delay,o.time),s(c))}),o.state=Ii,o.on.call("start",e,e.__data__,o.index,o.group),o.state===Ii){for(o.state=wi,r=new Array(f=o.tween.length),d=0,p=-1;d<f;++d)(m=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++p]=m);r.length=p+1}}function s(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=Ai,1),p=-1,f=r.length;++p<f;)r[p].call(e,d);o.state===Ai&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=xr,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function js(e,t){var o=e.__transition,n,r,i=!0,a;if(o){t=t==null?null:t+"";for(a in o){if((n=o[a]).name!==t){i=!1;continue}r=n.state>Ii&&n.state<Ai,n.state=xr,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[a]}i&&delete e.__transition}}function Tc(e){return this.each(function(){js(this,e)})}function lg(e,t){var o,n;return function(){var r=nt(this,e),i=r.tween;if(i!==o){n=o=i;for(var a=0,s=n.length;a<s;++a)if(n[a].name===t){n=n.slice(),n.splice(a,1);break}}r.tween=n}}function cg(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=nt(this,e),a=i.tween;if(a!==n){r=(n=a).slice();for(var s={name:t,value:o},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=s;break}l===c&&r.push(s)}i.tween=r}}function vc(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=Je(this.node(),o).tween,r=0,i=n.length,a;r<i;++r)if((a=n[r]).name===e)return a.value;return null}return this.each((t==null?lg:cg)(o,e,t))}function Rn(e,t,o){var n=e._id;return e.each(function(){var r=nt(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return Je(r,n).value[t]}}function Ci(e,t){var o;return(typeof t=="number"?kt:t instanceof Po?yi:(o=Po(t))?(t=o,yi):Ks)(e,t)}function dg(e){return function(){this.removeAttribute(e)}}function ug(e){return function(){this.removeAttributeNS(e.space,e.local)}}function pg(e,t,o){var n,r=o+"",i;return function(){var a=this.getAttribute(e);return a===r?null:a===n?i:i=t(n=a,o)}}function fg(e,t,o){var n,r=o+"",i;return function(){var a=this.getAttributeNS(e.space,e.local);return a===r?null:a===n?i:i=t(n=a,o)}}function mg(e,t,o){var n,r,i;return function(){var a,s=o(this),l;return s==null?void this.removeAttribute(e):(a=this.getAttribute(e),l=s+"",a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s)))}}function gg(e,t,o){var n,r,i;return function(){var a,s=o(this),l;return s==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),l=s+"",a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s)))}}function Nc(e,t){var o=mo(e),n=o==="transform"?Js:Ci;return this.attrTween(e,typeof t=="function"?(o.local?gg:mg)(o,n,Rn(this,"attr."+e,t)):t==null?(o.local?ug:dg)(o):(o.local?fg:pg)(o,n,t))}function hg(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function yg(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function xg(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&yg(e,i)),o}return r._value=t,r}function Eg(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&hg(e,i)),o}return r._value=t,r}function wc(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=mo(e);return this.tween(o,(n.local?xg:Eg)(n,t))}function _g(e,t){return function(){Er(this,e).delay=+t.apply(this,arguments)}}function bg(e,t){return t=+t,function(){Er(this,e).delay=t}}function Ic(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?_g:bg)(t,e)):Je(this.node(),t).delay}function Tg(e,t){return function(){nt(this,e).duration=+t.apply(this,arguments)}}function vg(e,t){return t=+t,function(){nt(this,e).duration=t}}function Ac(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Tg:vg)(t,e)):Je(this.node(),t).duration}function Ng(e,t){if(typeof t!="function")throw new Error;return function(){nt(this,e).ease=t}}function Cc(e){var t=this._id;return arguments.length?this.each(Ng(t,e)):Je(this.node(),t).ease}function wg(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;nt(this,e).ease=o}}function Sc(e){if(typeof e!="function")throw new Error;return this.each(wg(this._id,e))}function Mc(e){typeof e!="function"&&(e=ar(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=[],l,c=0;c<a;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&s.push(l);return new st(n,this._parents,this._name,this._id)}function Pc(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,o=e._groups,n=t.length,r=o.length,i=Math.min(n,r),a=new Array(n),s=0;s<i;++s)for(var l=t[s],c=o[s],d=l.length,p=a[s]=new Array(d),f,m=0;m<d;++m)(f=l[m]||c[m])&&(p[m]=f);for(;s<n;++s)a[s]=t[s];return new st(a,this._parents,this._name,this._id)}function Ig(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 Ag(e,t,o){var n,r,i=Ig(t)?Er:nt;return function(){var a=i(this,e),s=a.on;s!==n&&(r=(n=s).copy()).on(t,o),a.on=r}}function Lc(e,t){var o=this._id;return arguments.length<2?Je(this.node(),o).on.on(e):this.each(Ag(o,e,t))}function Cg(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function kc(){return this.on("end.remove",Cg(this._id))}function Rc(e){var t=this._name,o=this._id;typeof e!="function"&&(e=jo(e));for(var n=this._groups,r=n.length,i=new Array(r),a=0;a<r;++a)for(var s=n[a],l=s.length,c=i[a]=new Array(l),d,p,f=0;f<l;++f)(d=s[f])&&(p=e.call(d,d.__data__,f,s))&&("__data__"in d&&(p.__data__=d.__data__),c[f]=p,Lo(c[f],t,o,f,c,Je(d,o)));return new st(i,this._parents,t,o)}function Dc(e){var t=this._name,o=this._id;typeof e!="function"&&(e=sr(e));for(var n=this._groups,r=n.length,i=[],a=[],s=0;s<r;++s)for(var l=n[s],c=l.length,d,p=0;p<c;++p)if(d=l[p]){for(var f=e.call(d,d.__data__,p,l),m,y=Je(d,o),E=0,u=f.length;E<u;++E)(m=f[E])&&Lo(m,t,o,E,f,y);i.push(f),a.push(d)}return new st(i,a,t,o)}var Sg=go.prototype.constructor;function Oc(){return new Sg(this._groups,this._parents)}function Mg(e,t){var o,n,r;return function(){var i=Mo(this,e),a=(this.style.removeProperty(e),Mo(this,e));return i===a?null:i===o&&a===n?r:r=t(o=i,n=a)}}function Vc(e){return function(){this.style.removeProperty(e)}}function Pg(e,t,o){var n,r=o+"",i;return function(){var a=Mo(this,e);return a===r?null:a===n?i:i=t(n=a,o)}}function Lg(e,t,o){var n,r,i;return function(){var a=Mo(this,e),s=o(this),l=s+"";return s==null&&(l=s=(this.style.removeProperty(e),Mo(this,e))),a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s))}}function kg(e,t){var o,n,r,i="style."+t,a="end."+i,s;return function(){var l=nt(this,e),c=l.on,d=l.value[i]==null?s||(s=Vc(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(a,r=d),l.on=n}}function Hc(e,t,o){var n=(e+="")=="transform"?Zs:Ci;return t==null?this.styleTween(e,Mg(e,n)).on("end.style."+e,Vc(e)):typeof t=="function"?this.styleTween(e,Lg(e,n,Rn(this,"style."+e,t))).each(kg(this._id,e)):this.styleTween(e,Pg(e,n,t),o).on("end.style."+e,null)}function Rg(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function Dg(e,t,o){var n,r;function i(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&Rg(e,a,o)),n}return i._value=t,i}function Gc(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,Dg(e,t,o==null?"":o))}function Og(e){return function(){this.textContent=e}}function Vg(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function Bc(e){return this.tween("text",typeof e=="function"?Vg(Rn(this,"text",e)):Og(e==null?"":e+""))}function Hg(e){return function(t){this.textContent=e.call(this,t)}}function Gg(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&Hg(r)),t}return n._value=e,n}function zc(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,Gg(e))}function Yc(){for(var e=this._name,t=this._id,o=Si(),n=this._groups,r=n.length,i=0;i<r;++i)for(var a=n[i],s=a.length,l,c=0;c<s;++c)if(l=a[c]){var d=Je(l,t);Lo(l,e,o,c,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new st(n,this._parents,e,o)}function Fc(){var e,t,o=this,n=o._id,r=o.size();return new Promise(function(i,a){var s={value:a},l={value:function(){--r===0&&i()}};o.each(function(){var c=nt(this,n),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(l)),c.on=t}),r===0&&i()})}var Bg=0;function st(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function Wc(e){return go().transition(e)}function Si(){return++Bg}var ho=go.prototype;st.prototype=Wc.prototype={constructor:st,select:Rc,selectAll:Dc,selectChild:ho.selectChild,selectChildren:ho.selectChildren,filter:Mc,merge:Pc,selection:Oc,transition:Yc,call:ho.call,nodes:ho.nodes,node:ho.node,size:ho.size,empty:ho.empty,each:ho.each,on:Lc,attr:Nc,attrTween:wc,style:Hc,styleTween:Gc,text:Bc,textTween:zc,remove:kc,tween:vc,delay:Ic,duration:Ac,ease:Cc,easeVarying:Sc,end:Fc,[Symbol.iterator]:ho[Symbol.iterator]};function Mi(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var zg={time:null,delay:0,duration:250,ease:Mi};function Yg(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 Xc(e){var t,o;e instanceof st?(t=e._id,e=e._name):(t=Si(),(o=zg).time=yr(),e=e==null?null:e+"");for(var n=this._groups,r=n.length,i=0;i<r;++i)for(var a=n[i],s=a.length,l,c=0;c<s;++c)(l=a[c])&&Lo(l,e,t,c,a,o||Yg(l,t));return new st(n,this._parents,e,t)}go.prototype.interrupt=Tc;go.prototype.transition=Xc;function ko(e,t,o){this.k=e,this.x=t,this.y=o}ko.prototype={constructor:ko,scale:function(e){return e===1?this:new ko(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ko(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 Pi=new ko(1,0,0);Li.prototype=ko.prototype;function Li(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Pi;return e.__zoom}var Wg=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var Uc;(function(e){e.Strict="strict",e.Loose="loose"})(Uc||(Uc={}));var $c;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})($c||($c={}));var Kc;(function(e){e.Partial="partial",e.Full="full"})(Kc||(Kc={}));var qc;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(qc||(qc={}));var Zc;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Zc||(Zc={}));var pt;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(pt||(pt={}));var iT={[pt.Left]:pt.Right,[pt.Right]:pt.Left,[pt.Top]:pt.Bottom,[pt.Bottom]:pt.Top};var Xg=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var Ug=(e,t=[0,0])=>{var s;let{width:o,height:n}=$g(e),r=(s=e.origin)!=null?s:t,i=o*r[0],a=n*r[1];return{x:e.position.x-i,y:e.position.y-a}};var ki=(e,t=[0,0])=>{var r,i,a,s,l,c,d,p;let{x:o,y:n}=Xg(e)?e.internals.positionAbsolute:Ug(e,t);return{x:o,y:n,x2:o+((s=(a=(i=(r=e.measured)==null?void 0:r.width)!=null?i:e.width)!=null?a:e.initialWidth)!=null?s:0),y2:n+((p=(d=(c=(l=e.measured)==null?void 0:l.height)!=null?c:e.height)!=null?d:e.initialHeight)!=null?p:0)}};function $g(e){var t,o,n,r,i,a,s,l;return{width:(r=(n=(o=(t=e.measured)==null?void 0:t.width)!=null?o:e.width)!=null?n:e.initialWidth)!=null?r:0,height:(l=(s=(a=(i=e.measured)==null?void 0:i.height)!=null?a:e.height)!=null?s:e.initialHeight)!=null?l:0}}var sT={[pt.Left]:{x:-1,y:0},[pt.Right]:{x:1,y:0},[pt.Top]:{x:0,y:-1},[pt.Bottom]:{x:0,y:1}};var Kg={nodeOrigin:[0,0],nodeExtent:Wg,elevateNodesOnSelect:!0,defaults:{}},aT=w(_({},Kg),{checkEquality:!0});var Jc;(function(e){e.Line="line",e.Handle="handle"})(Jc||(Jc={}));var qg={width:0,height:0,x:0,y:0},lT=w(_({},qg),{pointerX:0,pointerY:0,aspectRatio:1});var Zg=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function Jg(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 Qg(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 Ri=class{constructor(){this.xLines=[];this.yLines=[]}initialize(t){this.xLines=t.filter(o=>o.orientation==="vertical"),this.yLines=t.filter(o=>o.orientation==="horizontal"),this.xLines.sort((o,n)=>o.position-n.position),this.yLines.sort((o,n)=>o.position-n.position),this.lastHorizontalLine=void 0,this.lastVerticalLine=void 0}search(t,o,n,r,i){let a=t==="horizontal"?this.yLines:this.xLines,[s,l]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],c=[];for(let m of a){if(m.position<s)continue;if(m.position>l)break;if(i.has(m.node.id)||m.node.parentId&&i.has(m.node.parentId)||!Zg(m.nodeBox,r))continue;let y=Math.abs(m.position-o);if(y>Di)continue;let u=Jg(m.nodeBox,n)>0?0:Qg(m.nodeBox,n);c.push({line:m,lineDist:y,nodeDist:u})}let d=.5,p=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;c.sort((m,y)=>{if(p){if(m.line===p&&y.line!==p)return-1;if(y.line===p&&m.line!==p)return 1}return Math.abs(m.lineDist-y.lineDist)<=d?m.nodeDist-y.nodeDist:m.lineDist-y.lineDist});let f=c.length>0?c[0].line:void 0;return f&&(t==="horizontal"?this.lastHorizontalLine=f:this.lastVerticalLine=f),f}};function Qc(e,t=nn,o){let n=[];return e==null||e.forEach(r=>{let i=o(r.id);if(!i)throw new Error(`Node with id ${r.id} not found in internal nodes.`);let a=ki(i);Object.entries(t).forEach(([s,l])=>{var c;n.push({position:l.resolve(r,a),color:(c=r.style)==null?void 0:c.backgroundColor,orientation:l.orientation,anchorName:s,nodeBox:a,node:r})})}),n}function jc(e,t,o,n,r=Object.keys(nn)){let i=[];for(let s of r){let l=nn[s],c=l.resolve(null,o),d=e.search(l.orientation,c,o,t,n);d&&i.push({sourcePosition:c,anchorName:s,anchor:l,line:d})}let a={horizontal:void 0,vertical:void 0};for(let s of i){let l=a[s.anchor.orientation],c=Math.abs(s.sourcePosition-s.line.position);(!l||c<Math.abs(l.sourcePosition-l.line.position))&&(a[s.anchor.orientation]=s)}return a}function ed(e,t,o){let n=0,r=0,i=!1,a=!1;if(t){let l=t.anchor.resolve(null,e)-t.line.position;Math.abs(l)<=Di&&(r=l,a=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=Di&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:a}}var Di=10,nn={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 od=require("react/jsx-runtime"),jg=new Ri;function Oi(){let[e,t]=(0,yt.useState)(void 0),[o,n]=(0,yt.useState)(void 0),{width:r,height:i}=(0,Dn.useStore)(u=>({width:u.width,height:u.height}),td.shallow),a=(0,Dn.useNodesInitialized)(),s=(0,yt.useRef)(jg),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=(0,Dn.useReactFlow)(),p=(0,yt.useCallback)(()=>{t(void 0),n(void 0)},[]),f=(0,yt.useCallback)(u=>{let g=u!=null?u:d();p();let h=Qc(g,nn,c);s.current.initialize(h)},[c,p,d]),m=(0,yt.useCallback)(()=>{setTimeout(()=>{f()},100)},[f]);(0,yt.useEffect)(()=>{a&&f(d())},[a,f,d]);let y=(0,yt.useCallback)((u,g)=>{var G,k,O,Y,F,U,X,$,te,ie;if(!s.current||u.length===0||u.filter(W=>W.type==="dimensions").length>1)return u;p();let x=u.filter(W=>W.type==="position"&&!!W.position),T=u.find(W=>W.type==="dimensions");if(x.length===0&&!T)return u;let b=Object.keys(nn),N=new Set,v=1/0,I=1/0,C=-1/0,P=-1/0;if(x.length>0)x.forEach(W=>{var de,re,ee,xe,Se,Ve;let oe=g.find(ot=>ot.id===W.id);if(!oe)return;N.add(oe.id);let le=c(oe.id);if(!le)return;let Z=le.parentId?c(le.parentId):void 0,ve=W.position.x+((de=Z==null?void 0:Z.internals.positionAbsolute.x)!=null?de:0),ye=W.position.y+((re=Z==null?void 0:Z.internals.positionAbsolute.y)!=null?re:0),Ce=(xe=(ee=oe.measured)==null?void 0:ee.width)!=null?xe:0,J=(Ve=(Se=oe.measured)==null?void 0:Se.height)!=null?Ve:0;v=Math.min(v,ve),I=Math.min(I,ye),C=Math.max(C,ve+Ce),P=Math.max(P,ye+J)}),T&&(b=["top","left"]);else if(T){let W=g.find(Ce=>Ce.id===T.id);if(!W)return u;N.add(W.id);let oe=c(W.id);if(!oe)return u;let le=oe.internals.positionAbsolute.x,Z=oe.internals.positionAbsolute.y,ve=(Y=(O=(G=T.dimensions)==null?void 0:G.width)!=null?O:(k=W.measured)==null?void 0:k.width)!=null?Y:0,ye=($=(X=(F=T.dimensions)==null?void 0:F.height)!=null?X:(U=W.measured)==null?void 0:U.height)!=null?$:0;v=le,I=Z,C=le+ve,P=Z+ye,b=["right","bottom"]}if(v===1/0)return u;let R={x:v,y:I,x2:C,y2:P},{x:S,y:L}=l({x:0,y:0}),{x:K,y:j}=l({x:r,y:i}),Q={x:S,y:L,x2:K,y2:j},{horizontal:z,vertical:M}=jc(s.current,Q,R,N,b),{deltaX:V,deltaY:D,snappedX:A,snappedY:B}=ed(R,z,M);if(A||B){let W=x.some(le=>le.dragging),oe=!!(T!=null&&T.resizing);(W||oe)&&(A&&n(M==null?void 0:M.line),B&&t(z==null?void 0:z.line)),A&&(x.forEach(le=>{le.position&&(le.position.x-=V)}),(T==null?void 0:T.id)===((te=x[0])==null?void 0:te.id)?T.dimensions&&(T.dimensions.width+=V):T&&!x.length&&T.dimensions&&(T.dimensions.width-=V)),B&&(x.forEach(le=>{le.position&&(le.position.y-=D)}),(T==null?void 0:T.id)===((ie=x[0])==null?void 0:ie.id)?T.dimensions&&(T.dimensions.height+=D):T&&!x.length&&T.dimensions&&(T.dimensions.height-=D))}return u},[l,c,r,i,t,n,p]),E=(0,yt.useCallback)(()=>(0,od.jsx)(nd,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:f,forceRebuildIndex:m,updateHelperLines:y,helperLineHorizontal:e,helperLineVertical:o,HelperLines:E}}var ms=require("@xyflow/react"),io=require("react");var yo=e=>new Map(e.map(t=>[t.id,t])),_r=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),rd=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),ea=e=>e.some(t=>t.type==="START_EVENT"),Ro=(e,t)=>e==="START_EVENT"?!ea(t):!0,id=(e,t,o,n,r)=>{let i=yo(o),a=i.get(e);if(!a||a.type!=="START_EVENT")return!1;let s=i.get(t);return(s==null?void 0:s.type)==="ANNOTATION"?!1:_r(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},sd=(e,t,o,n,r)=>{let i=yo(o),a=i.get(t);if(!a||a.type!=="END_EVENT")return!1;let s=i.get(e);return(s==null?void 0:s.type)==="ANNOTATION"?!1:rd(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Vi=(e,t,o,n,r)=>{var c;let i=yo(o),a=i.get(e);if(!a||a.type!=="GATEWAY"||((c=a.data)==null?void 0:c.variant)!=="EXCLUSIVE")return!1;let s=t?i.get(t):null;return(s==null?void 0:s.type)==="ANNOTATION"?!1:_r(e,n,r).filter(d=>{let p=i.get(d.target);return(p==null?void 0:p.type)!=="ANNOTATION"}).length>=2},ad=(e,t,o)=>{var a,s,l,c;let n=yo(o),r=n.get(e),i=n.get(t);return(r==null?void 0:r.type)!=="GATEWAY"||(i==null?void 0:i.type)!=="GATEWAY"||((a=r==null?void 0:r.data)==null?void 0:a.variant)==="EXCLUSIVE"&&((s=i==null?void 0:i.data)==null?void 0:s.variant)==="PARALLEL"||((l=r==null?void 0:r.data)==null?void 0:l.variant)==="COMPLEX"&&((c=i==null?void 0:i.data)==null?void 0:c.variant)==="PARALLEL"},Hi=(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"},ld=(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"},br=(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"},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.attribute)==="LOOP"},rn=(e,t,o,n)=>{let r=yo(t),i=r.get(e);return!i||i.type!=="TASK"?!1:rd(e,o,n).some(s=>{let l=r.get(s.source);return(l==null?void 0:l.type)==="START_EVENT"})},Tr=(e,t,o,n)=>{let r=yo(t),i=r.get(e);return!i||i.type!=="TASK"?!1:_r(e,o,n).some(s=>{let l=r.get(s.target);return(l==null?void 0:l.type)==="END_EVENT"})},cd=(e,t,o,n,r)=>{let i=yo(o),a=i.get(e),s=i.get(t);return(a==null?void 0:a.type)==="START_EVENT"&&(s==null?void 0:s.type)==="TASK"?Tr(t,o,n,r):(s==null?void 0:s.type)==="END_EVENT"&&(a==null?void 0:a.type)==="TASK"?rn(e,o,n,r):!1},Bi=(e,t,o)=>_r(e,t,o).length>0,zi=(e,t,o,n,r)=>{let i=yo(o),a=i.get(e);if(!a||a.type!=="TASK")return!1;let s=t?i.get(t):null;return(s==null?void 0:s.type)==="ANNOTATION"?!1:_r(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var dd=(e,t,o,n,r)=>{var s,l;let i=yo(n),a=((s=i.get(e))==null?void 0:s.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||a&&c.source===t&&c.target===e))};var eh=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!dd(e.sourceNodeId,e.targetNodeId,e.edges,e.nodes,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!id(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!sd(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!Vi(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!zi(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:ad(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"&&ld(e.targetNodeId,e.nodes)),reason:"start_event_to_subprocess_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&br(e.targetNodeId,e.nodes)),reason:"start_event_to_service_task_not_allowed"}),e=>({isValid:!(br(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:!(Hi(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(Gi(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(rn(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!cd(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(Tr(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(Bi(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"})],ta=e=>{for(let t of eh){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var th=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:Vi(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:ea(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Hi(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Gi(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:br(e.sourceNodeId,e.nodes),reason:"service_task_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:rn(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Tr(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Bi(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:zi(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],ud=e=>{let t=th.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 zt=require("@xyflow/react");var Qt=require("@produto-lecom/lecom-ui"),pd=require("lucide-react");var Rt=require("@xyflow/react");var Yi=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=(0,Rt.useReactFlow)(),{selectElements:r}=Zt(),i=u=>{let g=o(),h=n(),x=(0,Rt.getIncomers)(u,g,h),T=(0,Rt.getOutgoers)(u,g,h),b=x.some(v=>v.type==="START_EVENT"),N=T.some(v=>v.type==="END_EVENT");return b?"start":N?"end":"between"},a=(u,g,h)=>{var b,N,v,I,C;if(!u)return;let x={type:u.type,variant:(b=u.data)==null?void 0:b.variant,attribute:(N=u.data)==null?void 0:N.attribute},T={id:u.id,position:i(u),label:(v=u.data)==null?void 0:v.label,node:x};return u.type==="TASK"&&((I=u.data)==null?void 0:I.variant)==="SUBPROCESS"?w(_({},T),{type:"sub_process"}):u.type==="TASK"&&((C=u.data)==null?void 0:C.variant)==="SERVICE_TASK"?w(_({},T),{type:"service_task"}):u.type==="GATEWAY"?w(_({},T),{type:"gateway",variant:s(u,g,h)}):w(_({},T),{type:"activity"})},s=(u,g,h)=>{if(u.type!=="GATEWAY")return;let x=(0,Rt.getIncomers)(u,g,h),T=!1,b=!1;if(x.forEach(N=>{var v,I;N.type==="TASK"&&(((v=N.data)==null?void 0:v.variant)==="SCRIPT"&&(T=!0),((I=N.data)==null?void 0:I.attribute)==="LOOP"&&(b=!0))}),T&&b)return"script_loop";if(T)return"script";if(b)return"loop"},l=(u,g,h)=>{var v,I,C,P,R;let x=e(u.source),T=e(u.target);if(!x||!T)return"simple";if((0,Rt.getOutgoers)(x,g,h).some(S=>S.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 S=(I=x.data)==null?void 0:I.variant,L=(C=x.data)==null?void 0:C.attribute;if(S==="SUBPROCESS")return"from_sub_process";if(S==="SERVICE_TASK")return"from_service_task";if(T.type==="TASK"&&((P=T.data)==null?void 0:P.variant)==="SUBPROCESS")return"to_sub_process";if(T.type==="TASK"&&((R=T.data)==null?void 0:R.variant)==="SERVICE_TASK")return"to_service_task";let K=S==="SCRIPT",j=L==="LOOP";return K&&j?"script_loop":K?"script":j?"loop":"simple"}return"simple"},c=(u,g,h)=>{let x=[];function T(N,v,I=0){let C=a(N,g,h);if(C.depth=I,v.push(C),N.type==="TASK"){x.push([...v]),v.pop();return}let P=(0,Rt.getIncomers)(N,g,h);if(P.length)for(let R of P)T(R,v,I+1);v.pop()}let b=(0,Rt.getIncomers)(u,g,h);for(let N of b)T(N,[]);return x},d=(u,g,h)=>{let x=[];function T(N,v,I=0){let C=a(N,g,h);if(C.depth=I,v.push(C),N.type==="TASK"){x.push([...v]),v.pop();return}let P=(0,Rt.getOutgoers)(N,g,h);if(P.length)for(let R of P)T(R,v,I+1);v.pop()}let b=(0,Rt.getOutgoers)(u,g,h);for(let N of b)T(N,[]);return x},p=(u,g,h)=>(h=h.filter(T=>T.source===u.id),h.map(T=>{var v;let b=e(T.target),N;return b&&(N=a(b,g,h)),{id:T.id,type:"routing",variant:l(T,g,h),label:(v=T.data)==null?void 0:v.label,target:N}})),f=u=>{let g=e(u);if(!g)return;let h=o(),x=n(),T=a(g,h,x);return T.sources=c(g,h,x),T.targets=d(g,h,x),T.edgeTargets=p(g,h,x),g.type==="GATEWAY"&&(T.variant=s(g,h,x)),T},m=u=>{let g=t(u);if(!g)return;let h=o(),x=n(),T=l(g,h,x),N={id:g.id,type:"routing",variant:T,gatewayVariant:void 0},v=e(g.source);if(v){let C=a(v,h,x);N.source=C;let P=s(v,h,x);if(N.gatewayVariant=P,v.type==="TASK")N.sources=[[C]];else{let R=c(v,h,x);N.sources=R.length?R:[[C]]}}let I=e(g.target);if(I){let C=a(I,h,x);if(N.target=C,I.type==="TASK")N.targets=[[C]];else{let P=d(I,h,x);N.targets=P.length?P:[[C]]}}return N},y=u=>{let g=e(u);if(g)return f(g.id);let h=t(u);if(h)return m(h.id)};return{configureElement:u=>{let g=y(u);if(g)return r([u]),g},getConfigureElement:y,getNodeConfigure:f,getEdgeConfigure:m}};var sn=require("react/jsx-runtime"),oh={node:"editor.toolbar.configure_node",edge:"editor.toolbar.configure_edge",gateway:"editor.toolbar.configure_gateway"},Do=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,Qt.useTranslation)(),{onConfigureElement:n}=q(),{getConfigureElement:r}=Yi();return(0,sn.jsxs)(Qt.Tooltip,{children:[(0,sn.jsx)(Qt.TooltipTrigger,{asChild:!0,children:(0,sn.jsx)(Qt.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let a=r(e);a&&(n==null||n(a))},children:(0,sn.jsx)(pd.Settings,{size:16})})}),(0,sn.jsx)(Qt.TooltipContent,{color:"black",children:o(oh[t])})]})};var jt=require("@produto-lecom/lecom-ui"),md=require("@xyflow/react"),gd=require("lucide-react");var fd=require("@produto-lecom/lecom-ui");function et(){let{toast:e}=On(),{toast:t}=(0,fd.useNotificationToast)();return{toast:e||t}}var an=require("react/jsx-runtime"),Fi=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,jt.useTranslation)(),{toast:n}=et(),{deleteElements:r,getNodes:i}=(0,md.useReactFlow)();return(0,an.jsxs)(jt.Tooltip,{children:[(0,an.jsx)(jt.TooltipTrigger,{asChild:!0,children:(0,an.jsx)(jt.Button,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{if(t==="node"){let s=i(),l=s.find(c=>c.id===e);if((l==null?void 0:l.type)==="LANE"&&s.some(d=>d.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}]})},children:(0,an.jsx)(gd.TrashIcon,{size:16})})}),(0,an.jsx)(jt.TooltipContent,{color:"black",children:o("editor.toolbar.delete")})]})};var eo=require("@produto-lecom/lecom-ui"),hd=require("lucide-react"),yd=require("react"),ln=require("react/jsx-runtime"),Vn=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=(0,eo.useTranslation)(),r=(0,yd.useCallback)(i=>{i.stopPropagation();let a=document.querySelectorAll(`.react-flow__handle.source[data-nodeid="${e}"]`);if(a.length===0)return;let s=Array.from(a).reduce((f,m)=>{let y=f.getBoundingClientRect(),E=m.getBoundingClientRect(),u=Math.hypot(i.clientX-(y.left+y.width/2),i.clientY-(y.top+y.height/2));return Math.hypot(i.clientX-(E.left+E.width/2),i.clientY-(E.top+E.height/2))<u?m:f}),l=s.getBoundingClientRect(),c=l.left+l.width/2,d=l.top+l.height/2,p=new MouseEvent("mousedown",{clientX:c,clientY:d,bubbles:!0,cancelable:!0});s.dispatchEvent(p)},[e]);return(0,ln.jsxs)(eo.Tooltip,{children:[(0,ln.jsx)(eo.TooltipTrigger,{asChild:!0,children:(0,ln.jsx)(eo.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,ln.jsx)(hd.MoveUpRightIcon,{size:16})})}),(0,ln.jsx)(eo.TooltipContent,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};var Hn=require("react/jsx-runtime"),Gn=i=>{var a=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=a,r=qt(a,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:s}=q(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d,isToEndEvent:p}=ri(o,n),f=!l&&!c&&!d&&!p,m=[{component:(0,Hn.jsx)(Fi,{elementId:e,elementType:"edge"})}],y=()=>s==="view"?f?[{component:(0,Hn.jsx)(Do,{elementId:e,elementType:"edge"})}]:[]:f?[{component:(0,Hn.jsx)(Do,{elementId:e,elementType:"edge"})},...m]:m,u=(g=>{switch(g){case"SEQUENCE_EDGE":return y();case"MESSAGE_EDGE":return s==="view"?[]:[...m];case"ANNOTATION_EDGE":return s==="view"?[]:[...m];default:return[]}})(t);if(!(u.length===0||s==="readonly"))return(0,Hn.jsx)("div",w(_({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:u.map((g,h)=>(0,Hn.jsx)("div",{children:g.component},h))}))};var xd=require("@xyflow/react"),Ed=require("react");var oa=require("react/jsx-runtime"),to=12,Bn=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:a}=(0,xd.useViewport)(),s=1/a,l=(0,Ed.useMemo)(()=>t===n?{bottom:`${to}px`,transform:"translateX(-50%)"}:e===o?{left:`${to}px`,transform:r?"translateY(-100%)":"translateY(-50%)"}:n>t&&o>e?{left:`${to}px`,bottom:`${to}px`}:n>t&&o<e?{right:`${to}px`,bottom:`${to}px`}:t>n&&o>e?{right:`${to}px`,bottom:`${to}px`}:{left:`${to}px`,bottom:`${to}px`},[e,t,o,n,r]);return(0,oa.jsx)("div",{style:{transform:`scale(${s})`},children:(0,oa.jsx)("div",{className:"absolute pointer-events-auto",style:_({},l),children:i})})};var xt=require("react/jsx-runtime"),zn={type:"ANNOTATION_EDGE",reconnectable:!0},_d=({id:e,source:t,target:o,selected:n,data:r})=>{let{isMultipleSelection:i,isReadOnly:a,edgeHighlight:s}=q(),{zoom:l}=(0,zt.useViewport)(),c=(0,zt.useInternalNode)(t),d=(0,zt.useInternalNode)(o);if(!c||!d)return null;let{sx:p,sy:f,tx:m,ty:y}=Mn(c,d),[E,u,g]=(0,zt.getStraightPath)({sourceX:p,sourceY:f,targetX:m,targetY:y}),h=s&&(n||(c==null?void 0:c.selected)||(d==null?void 0:d.selected));return(0,xt.jsx)(xt.Fragment,{children:(0,xt.jsxs)("g",{className:H("group bpmn-edge",{"is-highlighted":h}),children:[(0,xt.jsx)("path",{d:E,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/l),style:{pointerEvents:"stroke",cursor:"pointer"}}),(0,xt.jsxs)("g",{className:H("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!a,"text-blue-500 group-hover:text-blue-600":h}),children:[(0,xt.jsx)(zt.BaseEdge,{id:e,path:E,interactionWidth:0,strokeDasharray:4,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":r==null?void 0:r.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":h&&!(r!=null&&r.hasError)})}),(0,xt.jsx)(zt.EdgeLabelRenderer,{children:(0,xt.jsx)("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${u}px, ${g}px)`},children:n&&!i&&(0,xt.jsx)(Bn,{sx:p,sy:f,tx:m,ty:y,children:(0,xt.jsx)(Gn,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})})})]})]})})};var it=require("react"),Pe=require("@xyflow/react");var Yt=require("react");var ra=require("react/jsx-runtime"),na=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,bd=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Escape","Shift"],rt=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:a,onBlur:s,onInput:l,onInvalidFirstCharacter:c,skipFirstCharValidation:d})=>{let p=(0,Yt.useRef)(null),f=(0,Yt.useRef)(null),[m,y]=(0,Yt.useState)(!1);(0,Yt.useEffect)(()=>()=>{f.current&&clearTimeout(f.current)},[]),(0,Yt.useEffect)(()=>{y(i!=null?i:!1)},[i]),(0,Yt.useEffect)(()=>{if(m&&p.current){p.current.focus();let b=document.createRange();b.selectNodeContents(p.current);let N=window.getSelection();N&&(N.removeAllRanges(),N.addRange(b))}},[m]);let E=(0,Yt.useCallback)(()=>{f.current||(c==null||c(),f.current=setTimeout(()=>{f.current=null},500))},[c]),u=b=>{b.stopPropagation(),m||y(!0)},g=b=>{let N=b.currentTarget.innerText.replace(/\n$/,""),v=t&&N.length>=t,I=window.getSelection(),C=(I==null?void 0:I.toString())||"",P=C.length>0,R=(b.ctrlKey||b.metaKey)&&!b.altKey,S=R&&b.key==="a",L=R&&b.key==="c",K=R&&b.key==="x",j=R&&b.key==="v",Q=N.length===0||P&&C.length===N.length;if(!d&&Q&&!na.test(b.key)&&!bd.includes(b.key)&&!R){b.preventDefault(),E();return}v&&!P&&(bd.includes(b.key)||S||L||K||j||b.preventDefault())},h=b=>{b.preventDefault();let N=b.clipboardData.getData("text/plain").replace(/\r\n/g,`
1
+ "use strict";var Of=Object.create;var or=Object.defineProperty,Vf=Object.defineProperties,Hf=Object.getOwnPropertyDescriptor,Gf=Object.getOwnPropertyDescriptors,Bf=Object.getOwnPropertyNames,$r=Object.getOwnPropertySymbols,zf=Object.getPrototypeOf,Ms=Object.prototype.hasOwnProperty,Ba=Object.prototype.propertyIsEnumerable;var Ga=(e,t,o)=>t in e?or(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)&&Ga(e,o,t[o]);if($r)for(var o of $r(t))Ba.call(t,o)&&Ga(e,o,t[o]);return e},w=(e,t)=>Vf(e,Gf(t));var $t=(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&&Ba.call(e,n)&&(o[n]=e[n]);return o};var Yf=(e,t)=>{for(var o in t)or(e,o,{get:t[o],enumerable:!0})},za=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Bf(t))!Ms.call(e,r)&&r!==o&&or(e,r,{get:()=>t[r],enumerable:!(n=Hf(t,r))||n.enumerable});return e};var nr=(e,t,o)=>(o=e!=null?Of(zf(e)):{},za(t||!e||!e.__esModule?or(o,"default",{value:e,enumerable:!0}):o,e)),Ff=e=>za(or({},"__esModule",{value:!0}),e);var Ky={};Yf(Ky,{EditorMode:()=>We,ElementPosition:()=>qr,ElementType:()=>rr,GatewayElementVariant:()=>Zr,GatewayVariant:()=>_t,Modeler:()=>Df,ModelerProvider:()=>Pf,NodeAttribute:()=>Gt,NodeType:()=>re,NodeVariant:()=>ht,RoutingVariant:()=>Jr,useModeler:()=>Gn});module.exports=Ff(Ky);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 Ya={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Delete",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."},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:"The gateway does not have the correct number of outputs",events_nested:"Connecting events directly is not allowed",event_to_condition:"Connecting an event directly to a gateway is not allowed",script_in_final_activity:"Final activity cannot be a script type",subprocess_not_configured:"The subprocess reference is not properly configured",cannot_validate_subprocess_reference:"Could not validate whether the subprocess reference is configured",start_event_not_found:"At least one 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 Fa={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",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."},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:"La compuerta no tiene el n\xFAmero correcto de salidas",events_nested:"No se permite conectar eventos directamente",event_to_condition:"No se permite conectar un evento directamente a una compuerta",script_in_final_activity:"La actividad final no puede ser de tipo script",subprocess_not_configured:"La referencia al subproceso no est\xE1 configurada correctamente",cannot_validate_subprocess_reference:"No fue posible validar si la referencia al subproceso est\xE1 configurada",start_event_not_found:"Es necesario tener al menos un evento de inicio",end_event_not_found:"Es necesario tener al menos un evento final",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 Wa={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Excluir",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."},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 v\xE1lidado com sucesso!",message:"Nenhum erro encontrado."},errors:{title:"O diagrama cont\xE9m erros",subtitle:"Veja abaixo o que precisa ser corrigido:",task_label_length:"O nome da atividade excede o limite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"N\xE3o \xE9 permitido ter mais de um evento de in\xEDcio",task_flows_limit_exceeds:"O n\xFAmero de conex\xF5es de sa\xEDda ultrapassa o limite de dois",duplicate_task_name:"H\xE1 v\xE1rias atividades com o mesmo nome",flows_on_end_tasks_not_allowed:"Atividades conectadas a eventos finais n\xE3o podem ter outras conex\xF5es",conditions_flows_limit_exceeds:"Gateway exclusivo com excesso de conex\xF5es de sa\xEDda (m\xE1ximo de dois)",task_label_empty:"O nome de uma ou mais atividades n\xE3o foi preenchido",activity_name_invalid:"O nome da atividade n\xE3o \xE9 v\xE1lido",final_activity_has_loop:"Atividades finais n\xE3o podem ter loops",nested_gateway:"N\xE3o \xE9 permitido conectar gateways",concurrent_initial_and_final_event:"Uma mesma atividade n\xE3o pode ter eventos iniciais e finais",gateway_flow_to_event:"N\xE3o \xE9 permitido conectar um gateway a um evento de sa\xEDda",gateway_missing_output_streams:"O gateway n\xE3o possui o n\xFAmero correto de sa\xEDdas",events_nested:"N\xE3o \xE9 permitido conectar eventos",event_to_condition:"N\xE3o \xE9 permitido conectar um evento diretamente em um gateway",script_in_final_activity:"Atividade final n\xE3o pode ser do tipo script",subprocess_not_configured:"A refer\xEAncia ao subprocesso n\xE3o est\xE1 configurada corretamente",cannot_validate_subprocess_reference:"N\xE3o foi poss\xEDvel validar se a refer\xEAncia ao subprocesso est\xE1 configurada",start_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento inicial",end_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento final",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 Xa={pt_BR:Wa,en_US:Ya,es_ES:Fa};var Ua,$a,Wf=($a=(Ua=Ps("LecomUserLanguage"))!=null?Ua:Ps("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?$a:Kr.Translations.PT_BR;(0,Kr.initializeI18n)({lng:Wf,resources:Xa});var We=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(We||{});var rr=(i=>(i.ACTIVITY="activity",i.ROUTING="routing",i.GATEWAY="gateway",i.SUB_PROCESS="sub_process",i.SERVICE_TASK="service_task",i))(rr||{}),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 Ao=require("lucide-react");var Uo=require("react/jsx-runtime"),Qr=({size:e=24,className:t})=>(0,Uo.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:[(0,Uo.jsx)("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),(0,Uo.jsx)("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),(0,Uo.jsx)("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),(0,Uo.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"),bn=({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 No=require("react/jsx-runtime"),Tn=({size:e=24,className:t})=>(0,No.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,No.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,No.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,No.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,No.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,No.jsx)("path",{d:"M14.8281 9.17188L9.17127 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:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,vn.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var wn=require("react/jsx-runtime"),In=({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:"currentColor",strokeWidth:2,className:t,children:[(0,wn.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,wn.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,wn.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});var An=require("react/jsx-runtime"),Ka=({size:e=24,className:t})=>(0,An.jsx)("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:(0,An.jsxs)("g",{children:[(0,An.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,An.jsx)("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});var qa=require("clsx"),Za=require("tailwind-merge");function G(...e){return(0,Za.twMerge)((0,qa.clsx)(e))}var wo=(e=0,t=0)=>e<t?t:e,jr=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});var ir=require("react/jsx-runtime"),Ja=({size:e=24,className:t})=>(0,ir.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,ir.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,ir.jsx)("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});var ei=require("react/jsx-runtime"),Qa=({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"),sr=({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 Cn=require("react/jsx-runtime"),ja=({size:e=24,className:t})=>(0,Cn.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,Cn.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,Cn.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,Cn.jsx)("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});var Io=require("react/jsx-runtime"),el=({size:e=24,className:t})=>(0,Io.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[(0,Io.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,Io.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,Io.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,Io.jsx)("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Io.jsx)("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var $o=require("react/jsx-runtime"),ar=({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:"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,$o.jsx)("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),(0,$o.jsx)("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,$o.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||{}),ht=(n=>(n.SCRIPT="SCRIPT",n.SUBPROCESS="SUBPROCESS",n.SERVICE_TASK="SERVICE_TASK",n))(ht||{}),oi={SCRIPT:{icon:Ao.ScrollText},SUBPROCESS:{icon:Ao.SquarePlus},SERVICE_TASK:{icon:Ao.Bot}},Gt=(t=>(t.LOOP="LOOP",t))(Gt||{}),ni={LOOP:{icon:Ao.RotateCcw}},_t=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(_t||{}),Ds={EXCLUSIVE:{icon:Nn},PARALLEL:{icon:In},COMPLEX:{icon:Tn}};var Lf=require("@produto-lecom/lecom-ui"),kf=require("@xyflow/react"),De=require("react");var lo=require("@xyflow/react"),_n=require("react");var Dp=require("@produto-lecom/lecom-ui"),Bo=require("@xyflow/react"),Vt=require("react");var ri={MIN_WIDTH:36,MIN_HEIGHT:36},ii={MIN_WIDTH:36,MIN_HEIGHT:36},Sn={MIN_WIDTH:56,MIN_HEIGHT:56},Co={MIN_WIDTH:176,MIN_HEIGHT:96},tl={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},ie={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},Mn={MIN_WIDTH:176,MIN_HEIGHT:64},Xf={MIN_WIDTH:128,MIN_HEIGHT:64},de={START_EVENT:ri,END_EVENT:ii,GATEWAY:Sn,TASK:Co,LANE:ie,ANNOTATION:Mn,UNSUPPORTED:Xf};var Pn=require("@xyflow/react");function ol(e,t){var y,v,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+((v=(y=t==null?void 0:t.measured)==null?void 0:y.width)!=null?v: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),x=1/(Math.abs(p)+Math.abs(f)||1),E=x*p,g=x*f,h=s*(E+g)+l,m=a*(-E+g)+c;return{x:h,y:m}}function nl(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?Pn.Position.Left:a>=i+n-1?Pn.Position.Right:l<=s+1?Pn.Position.Top:l>=s+r-1?Pn.Position.Bottom:Pn.Position.Top}function Ln(e,t){let o=ol(e,t),n=ol(t,e),r=nl(e,o),i=nl(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function si(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 rl=require("lodash");var ai=e=>e.some(t=>t.type==="position"&&t.dragging),il=e=>new Map(e.map(t=>[t.id,t])),sl=(e,t)=>e.map(o=>{var n;return(n=t.get(o.id))!=null?n:o}),Pt=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}},lr=e=>(0,rl.orderBy)(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),al=(e,t)=>{let{x:o,y:n}=Pt(e),{x:r,y:i}=Pt(t);return{x:o-r,y:n-i}};var Ko=({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)),Uf=(e,t)=>{let{x:o,y:n}=Pt(e),{x:r,y:i}=Pt(t),s=o-r,a=n-i;return Math.sqrt(s*s+a*a)},$f=(e,t)=>{let{x:o,y:n,w:r,h:i}=Pt(e),{x:s,y:a,w:l,h:c}=Pt(t),d=o+r/2,u=n+i/2;return d>=s&&d<=s+l&&u>=a&&u<=a+c},cr=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&$f(e,r)){let i=Uf(e,r);i<n&&(n=i,o=r)}return o},ll=(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 cl=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}},dl=({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=Pt(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=Pt(s);return a.x<r&&a.x+a.w>n.x&&a.y<i&&a.y+a.h>n.y})};var Kf=50,qo=(e,t)=>{var p,f,x,E,g,h,m,y,v,b,I,T,N,C,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=(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=(m=o.measured)==null?void 0:m.height)!=null?y: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=(v=k.position)==null?void 0:v.y)!=null?b:0,V=(T=(I=k.position)==null?void 0:I.x)!=null?T:0,F=(C=(N=k.measured)==null?void 0:N.width)!=null?C:0,j=(L=(M=k.measured)==null?void 0:M.height)!=null?L:0;V<l&&V+F>n&&O<a&&O+j>r&&(c.add(k.id),d=Math.min(d,O))}if(c.size===0)return t;let u=a+Kf-d;return t.map(k=>{var V,F,j;if(!c.has(k.id))return k;let O=(F=(V=k.position)==null?void 0:V.y)!=null?F:0;return w(_({},k),{position:w(_({},(j=k.position)!=null?j:{x:0,y:0}),{y:O+u})})})},Ge=15,Zo=e=>[...e].sort((t,o)=>t.position.y-o.position.y),qf=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)},Zf=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)},Vs=(e,t,o)=>{var d,u,p,f,x,E,g,h,m,y,v,b,I,T,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:(f=e.measured)==null?void 0:f.height)!=null?E:0,i=0,s=0;for(let C of t){let M=qf(C),L=Zf(C);if(((h=(g=C.position)==null?void 0:g.y)!=null?h:0)<Ge&&(o.set(C.id,w(_({},C),{position:w(_({},C.position),{y:Ge})})),L=Ge+((y=(m=C.measured)==null?void 0:m.height)!=null?y:0)),((b=(v=C.position)==null?void 0:v.x)!=null?b:0)<ie.HEADER_WIDTH+Ge){let k=(I=o.get(C.id))!=null?I:C;o.set(C.id,w(_({},k),{position:w(_({},k.position),{x:ie.HEADER_WIDTH+Ge})})),M=ie.HEADER_WIDTH+Ge+((N=(T=C.measured)==null?void 0:T.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+Ge>a&&(a=i+Ge),s+Ge>l&&(l=s+Ge);let c=w(_({},e),{width:a,height:l,measured:w(_({},e.measured),{width:a,height:l})});return o.set(e.id,c),c},ul=(e,t,o)=>{var s,a;let n=Zo(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=Vs(l,c,t);t.set(d.id,w(_({},d),{position:{x:ie.HEADER_WIDTH,y:i}})),i+=(a=d.height)!=null?a:0}},pl=(e,t)=>{var x,E,g,h;let o=[];for(let m of t.values())m.parentId===e.id&&o.push(m);let n=Zo(o),r=((E=(x=e.measured)==null?void 0:x.width)!=null?E:0)-ie.HEADER_WIDTH,i=ll(e.id,o)||ie.MIN_WIDTH,s=o.reduce((m,y)=>{var v;return m+((v=y.height)!=null?v: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 y=n[m],v=Math.max(ie.MIN_HEIGHT,(g=y.height)!=null?g:ie.MIN_HEIGHT),b=w(_({},y),{width:u,height:v,measured:w(_({},y.measured),{width:u,height:v}),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(_({},y.measured),{width:u,height:I})})}t.set(y.id,b),p+=(h=b.height)!=null?h: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})}))},fl=(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=Zo(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,f=[...n];return l.forEach((g,h)=>{var I,T;let m=h===l.length-1,y=g.id===e.id,b=(T=(I=g.measured)==null?void 0:I.height)!=null?T:0;y?b=o:u&&h===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 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}),f=f.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}),f};var Hs=(e,t,o)=>{var a,l,c,d,u,p,f,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<Ge&&(e.position.y=Ge),e.position.x<ie.HEADER_WIDTH+Ge&&(e.position.x=ie.HEADER_WIDTH+Ge);let i=e.position.x+((p=(u=e.measured)==null?void 0:u.width)!=null?p:0),s=e.position.y+((x=(f=e.measured)==null?void 0:f.height)!=null?x:0);return i+Ge>n&&(t.width=i+Ge,t.measured.width=i+Ge),s+Ge>r&&(t.height=s+Ge,t.measured.height=s+Ge),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 gl=require("react"),hl=require("zustand");var ml=require("@xyflow/react"),Kt=()=>{let e=(0,ml.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 yl=()=>{let{selectElements:e}=Kt();return(0,gl.useCallback)(()=>{let o=Jo.getState().pathEdgeIds;e(o)},[e])},Jo=(0,hl.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:x,path:E}=p.shift();if(x===u)return E;let g=s[x]||[];for(let{targetId:h,edgeId:m}of g)f.has(h)||(f.add(h),p.push({node:h,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 Vn=require("@xyflow/react"),bt=require("react"),pd=require("zustand/shallow");var Jf={value:()=>{}};function El(){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 li(o)}function li(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}})}li.prototype=El.prototype={constructor:li,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]=xl(o[r],e.name,t);else if(t==null)for(r in o)o[r]=xl(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 li(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 xl(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 Gs=El;var ci="http://www.w3.org/1999/xhtml",Bs={svg:"http://www.w3.org/2000/svg",xhtml:ci,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function mo(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),Bs.hasOwnProperty(t)?{space:Bs[t],local:e}:e}function em(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===ci&&t.documentElement.namespaceURI===ci?t.createElement(e):t.createElementNS(o,e)}}function tm(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function di(e){var t=mo(e);return(t.local?tm:em)(t)}function om(){}function Qo(e){return e==null?om:function(){return this.querySelector(e)}}function _l(e){typeof e!="function"&&(e=Qo(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 et(n,this._parents)}function zs(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function nm(){return[]}function dr(e){return e==null?nm:function(){return this.querySelectorAll(e)}}function rm(e){return function(){return zs(e.apply(this,arguments))}}function bl(e){typeof e=="function"?e=rm(e):e=dr(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 et(n,r)}function ur(e){return function(){return this.matches(e)}}function ui(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 Tl(e){return this.select(e==null?am:sm(typeof e=="function"?e:ui(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 vl(e){return this.selectAll(e==null?cm:dm(typeof e=="function"?e:ui(e)))}function Nl(e){typeof e!="function"&&(e=ur(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 et(n,this._parents)}function pi(e){return new Array(e.length)}function wl(){return new et(this._enter||this._groups.map(pi),this._parents)}function pr(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}pr.prototype={constructor:pr,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 Il(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 pr(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),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 pr(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 Al(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=Il(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=mm(e.call(d,d&&d.__data__,c,n)),x=f.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,f,t);for(var m=0,y=0,v,b;m<x;++m)if(v=E[m]){for(m>=y&&(y=m+1);!(b=g[y])&&++y<x;);v._next=b||null}}return s=new et(s,n),s._enter=a,s._exit=l,s}function mm(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Cl(){return new et(this._exit||this._groups.map(pi),this._parents)}function Sl(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 Ml(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,x=0;x<u;++x)(f=c[x]||d[x])&&(p[x]=f);for(;l<r;++l)a[l]=o[l];return new et(a,this._parents)}function Pl(){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 Ll(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 et(r,this._parents).order()}function gm(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function kl(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Rl(){return Array.from(this)}function Dl(){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 Ol(){let e=0;for(let t of this)++e;return e}function Vl(){return!this.node()}function Hl(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 Gl(e,t){var o=mo(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 fi(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 Bl(e,t,o){return arguments.length>1?this.each((t==null?Tm:typeof t=="function"?Nm:vm)(e,t,o==null?"":o)):So(this.node(),e)}function So(e,t){return e.style.getPropertyValue(t)||fi(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 zl(e,t){return arguments.length>1?this.each((t==null?wm:typeof t=="function"?Am:Im)(e,t)):this.node()[e]}function Yl(e){return e.trim().split(/^|\s+/)}function Ys(e){return e.classList||new Fl(e)}function Fl(e){this._node=e,this._names=Yl(e.getAttribute("class")||"")}Fl.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 Wl(e,t){for(var o=Ys(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function Xl(e,t){for(var o=Ys(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function Cm(e){return function(){Wl(this,e)}}function Sm(e){return function(){Xl(this,e)}}function Mm(e,t){return function(){(t.apply(this,arguments)?Wl:Xl)(this,e)}}function Ul(e,t){var o=Yl(e+"");if(arguments.length<2){for(var n=Ys(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 $l(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 Kl(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 ql(){return this.each(Vm)}function Hm(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Zl(){return this.each(Hm)}function Jl(e){var t=typeof e=="function"?e:di(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Gm(){return null}function Ql(e,t){var o=typeof e=="function"?e:di(e),n=t==null?Gm:typeof t=="function"?t:Qo(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 ec(e){return this.select(e?Ym:zm)}function tc(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 oc(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 nc(e,t,o){var n=fi(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 nc(this,e,t)}}function Km(e,t){return function(){return nc(this,e,t.apply(this,arguments))}}function rc(e,t){return this.each((typeof t=="function"?Km:$m)(e,t))}function*ic(){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 et(e,t){this._groups=e,this._parents=t}function sc(){return new et([[document.documentElement]],qm)}function Zm(){return this}et.prototype=sc.prototype={constructor:et,select:_l,selectAll:bl,selectChild:Tl,selectChildren:vl,filter:Nl,data:Al,enter:wl,exit:Cl,join:Sl,merge:Ml,selection:Zm,order:Pl,sort:Ll,call:kl,nodes:Rl,node:Dl,size:Ol,empty:Vl,each:Hl,attr:Gl,style:Bl,property:zl,classed:Ul,text:$l,html:Kl,raise:ql,lower:Zl,append:Jl,insert:Ql,remove:jl,clone:ec,datum:tc,on:oc,dispatch:rc,[Symbol.iterator]:ic};var go=sc;function mi(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function Fs(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function gr(){}var fr=.7,yi=1/fr,kn="\\s*([+-]?\\d+)\\s*",mr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",qt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Jm=/^#([0-9a-f]{3,8})$/,Qm=new RegExp(`^rgb\\(${kn},${kn},${kn}\\)$`),jm=new RegExp(`^rgb\\(${qt},${qt},${qt}\\)$`),eg=new RegExp(`^rgba\\(${kn},${kn},${kn},${mr}\\)$`),tg=new RegExp(`^rgba\\(${qt},${qt},${qt},${mr}\\)$`),og=new RegExp(`^hsl\\(${mr},${qt},${qt}\\)$`),ng=new RegExp(`^hsla\\(${mr},${qt},${qt},${mr}\\)$`),ac={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};mi(gr,Mo,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:lc,formatHex:lc,formatHex8:rg,formatHsl:ig,formatRgb:cc,toString:cc});function lc(){return this.rgb().formatHex()}function rg(){return this.rgb().formatHex8()}function ig(){return gc(this).formatHsl()}function cc(){return this.rgb().formatRgb()}function Mo(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=Jm.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?dc(t):o===3?new yt(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?gi(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?gi(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 yt(t[1],t[2],t[3],1):(t=jm.exec(e))?new yt(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=eg.exec(e))?gi(t[1],t[2],t[3],t[4]):(t=tg.exec(e))?gi(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=og.exec(e))?fc(t[1],t[2]/100,t[3]/100,1):(t=ng.exec(e))?fc(t[1],t[2]/100,t[3]/100,t[4]):ac.hasOwnProperty(e)?dc(ac[e]):e==="transparent"?new yt(NaN,NaN,NaN,0):null}function dc(e){return new yt(e>>16&255,e>>8&255,e&255,1)}function gi(e,t,o,n){return n<=0&&(e=t=o=NaN),new yt(e,t,o,n)}function sg(e){return e instanceof gr||(e=Mo(e)),e?(e=e.rgb(),new yt(e.r,e.g,e.b,e.opacity)):new yt}function Rn(e,t,o,n){return arguments.length===1?sg(e):new yt(e,t,o,n==null?1:n)}function yt(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}mi(yt,Rn,Fs(gr,{brighter(e){return e=e==null?yi:Math.pow(yi,e),new yt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?fr:Math.pow(fr,e),new yt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new yt(en(this.r),en(this.g),en(this.b),xi(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:uc,formatHex:uc,formatHex8:ag,formatRgb:pc,toString:pc}));function uc(){return`#${jo(this.r)}${jo(this.g)}${jo(this.b)}`}function ag(){return`#${jo(this.r)}${jo(this.g)}${jo(this.b)}${jo((isNaN(this.opacity)?1:this.opacity)*255)}`}function pc(){let e=xi(this.opacity);return`${e===1?"rgb(":"rgba("}${en(this.r)}, ${en(this.g)}, ${en(this.b)}${e===1?")":`, ${e})`}`}function xi(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function en(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function jo(e){return e=en(e),(e<16?"0":"")+e.toString(16)}function fc(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new Bt(e,t,o,n)}function gc(e){if(e instanceof Bt)return new Bt(e.h,e.s,e.l,e.opacity);if(e instanceof gr||(e=Mo(e)),!e)return new Bt;if(e instanceof Bt)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 Bt(s,a,l,e.opacity)}function hc(e,t,o,n){return arguments.length===1?gc(e):new Bt(e,t,o,n==null?1:n)}function Bt(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}mi(Bt,hc,Fs(gr,{brighter(e){return e=e==null?yi:Math.pow(yi,e),new Bt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?fr:Math.pow(fr,e),new Bt(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 yt(Ws(e>=240?e-240:e+120,r,n),Ws(e,r,n),Ws(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new Bt(mc(this.h),hi(this.s),hi(this.l),xi(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=xi(this.opacity);return`${e===1?"hsl(":"hsla("}${mc(this.h)}, ${hi(this.s)*100}%, ${hi(this.l)*100}%${e===1?")":`, ${e})`}`}}));function mc(e){return e=(e||0)%360,e<0?e+360:e}function hi(e){return Math.max(0,Math.min(1,e||0))}function Ws(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 Xs(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 yc(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 Xs((o-n/t)*t,s,r,i,a)}}function xc(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 Xs((o-n/t)*t,r,i,s,a)}}var Us=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 Ec(e){return(e=+e)==1?Ei:function(t,o){return o-t?cg(t,o,e):Us(isNaN(t)?o:t)}}function Ei(e,t){var o=t-e;return o?lg(e,o):Us(isNaN(e)?t:e)}var _i=function e(t){var o=Ec(t);function n(r,i){var s=o((r=Rn(r)).r,(i=Rn(i)).r),a=o(r.g,i.g),l=o(r.b,i.b),c=Ei(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 _c(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=Rn(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=_c(yc),ug=_c(xc);function Lt(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var Ks=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,$s=new RegExp(Ks.source,"g");function pg(e){return function(){return e}}function fg(e){return function(t){return e(t)+""}}function qs(e,t){var o=Ks.lastIndex=$s.lastIndex=0,n,r,i,s=-1,a=[],l=[];for(e=e+"",t=t+"";(n=Ks.exec(e))&&(r=$s.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:Lt(n,r)})),o=$s.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 bc=180/Math.PI,bi={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Zs(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)*bc,skewX:Math.atan(l)*bc,scaleX:s,scaleY:a}}var Ti;function Tc(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?bi:Zs(t.a,t.b,t.c,t.d,t.e,t.f)}function vc(e){return e==null?bi:(Ti||(Ti=document.createElementNS("http://www.w3.org/2000/svg","g")),Ti.setAttribute("transform",e),(e=Ti.transform.baseVal.consolidate())?(e=e.matrix,Zs(e.a,e.b,e.c,e.d,e.e,e.f)):bi)}function Nc(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,p,f,x){if(c!==u||d!==p){var E=f.push("translate(",null,t,null,o);x.push({i:E-4,x:Lt(c,u)},{i:E-2,x:Lt(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:Lt(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:Lt(c,d)}):d&&u.push(r(u)+"skewX("+d+n)}function l(c,d,u,p,f,x){if(c!==u||d!==p){var E=f.push(r(f)+"scale(",null,",",null,")");x.push({i:E-4,x:Lt(c,u)},{i:E-2,x:Lt(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 x=-1,E=p.length,g;++x<E;)u[(g=p[x]).i]=g.x(f);return u.join("")}}}var Js=Nc(Tc,"px, ","px)","deg)"),Qs=Nc(vc,", ",")",")");var Dn=0,yr=0,hr=0,Ic=1e3,vi,xr,Ni=0,tn=0,wi=0,Er=typeof performance=="object"&&performance.now?performance:Date,Ac=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function br(){return tn||(Ac(mg),tn=Er.now()+wi)}function mg(){tn=0}function _r(){this._call=this._time=this._next=null}_r.prototype=Ii.prototype={constructor:_r,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?br():+o)+(t==null?0:+t),!this._next&&xr!==this&&(xr?xr._next=this:vi=this,xr=this),this._call=e,this._time=o,js()},stop:function(){this._call&&(this._call=null,this._time=1/0,js())}};function Ii(e,t,o){var n=new _r;return n.restart(e,t,o),n}function Cc(){br(),++Dn;for(var e=vi,t;e;)(t=tn-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Dn}function wc(){tn=(Ni=Er.now())+wi,Dn=yr=0;try{Cc()}finally{Dn=0,hg(),tn=0}}function gg(){var e=Er.now(),t=e-Ni;t>Ic&&(wi-=t,Ni=e)}function hg(){for(var e,t=vi,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:vi=o);xr=e,js(n)}function js(e){if(!Dn){yr&&(yr=clearTimeout(yr));var t=e-tn;t>24?(e<1/0&&(yr=setTimeout(wc,e-Er.now()-wi)),hr&&(hr=clearInterval(hr))):(hr||(Ni=Er.now(),hr=setInterval(gg,Ic)),Dn=1,Ac(wc))}}function Ai(e,t,o){var n=new _r;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var yg=Gs("start","end","cancel","interrupt"),xg=[],Pc=0,Sc=1,Si=2,Ci=3,Mc=4,Mi=5,Tr=6;function Po(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:Pc})}function vr(e,t){var o=tt(e,t);if(o.state>Pc)throw new Error("too late; already scheduled");return o}function st(e,t){var o=tt(e,t);if(o.state>Ci)throw new Error("too late; already running");return o}function tt(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=Ii(i,0,o.time);function i(c){o.state=Sc,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!==Sc)return l();for(d in n)if(f=n[d],f.name===o.name){if(f.state===Ci)return Ai(s);f.state===Mc?(f.state=Tr,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete n[d]):+d<t&&(f.state=Tr,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete n[d])}if(Ai(function(){o.state===Ci&&(o.state=Mc,o.timer.restart(a,o.delay,o.time),a(c))}),o.state=Si,o.on.call("start",e,e.__data__,o.index,o.group),o.state===Si){for(o.state=Ci,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=Mi,1),u=-1,p=r.length;++u<p;)r[u].call(e,d);o.state===Mi&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=Tr,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function ea(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>Si&&n.state<Mi,n.state=Tr,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[s]}i&&delete e.__transition}}function Lc(e){return this.each(function(){ea(this,e)})}function _g(e,t){var o,n;return function(){var r=st(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=st(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 kc(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=tt(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 On(e,t,o){var n=e._id;return e.each(function(){var r=st(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return tt(r,n).value[t]}}function Pi(e,t){var o;return(typeof t=="number"?Lt:t instanceof Mo?_i:(o=Mo(t))?(t=o,_i):qs)(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 Rc(e,t){var o=mo(e),n=o==="transform"?Qs:Pi;return this.attrTween(e,typeof t=="function"?(o.local?Ag:Ig)(o,n,On(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 Dc(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=mo(e);return this.tween(o,(n.local?Mg:Pg)(n,t))}function Lg(e,t){return function(){vr(this,e).delay=+t.apply(this,arguments)}}function kg(e,t){return t=+t,function(){vr(this,e).delay=t}}function Oc(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Lg:kg)(t,e)):tt(this.node(),t).delay}function Rg(e,t){return function(){st(this,e).duration=+t.apply(this,arguments)}}function Dg(e,t){return t=+t,function(){st(this,e).duration=t}}function Vc(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Rg:Dg)(t,e)):tt(this.node(),t).duration}function Og(e,t){if(typeof t!="function")throw new Error;return function(){st(this,e).ease=t}}function Hc(e){var t=this._id;return arguments.length?this.each(Og(t,e)):tt(this.node(),t).ease}function Vg(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;st(this,e).ease=o}}function Gc(e){if(typeof e!="function")throw new Error;return this.each(Vg(this._id,e))}function Bc(e){typeof e!="function"&&(e=ur(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 pt(n,this._parents,this._name,this._id)}function zc(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 pt(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)?vr:st;return function(){var s=i(this,e),a=s.on;a!==n&&(r=(n=a).copy()).on(t,o),s.on=r}}function Yc(e,t){var o=this._id;return arguments.length<2?tt(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 Fc(){return this.on("end.remove",Bg(this._id))}function Wc(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Qo(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,Po(c[p],t,o,p,c,tt(d,o)));return new pt(i,this._parents,t,o)}function Xc(e){var t=this._name,o=this._id;typeof e!="function"&&(e=dr(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,x=tt(d,o),E=0,g=p.length;E<g;++E)(f=p[E])&&Po(f,t,o,E,p,x);i.push(p),s.push(d)}return new pt(i,s,t,o)}var zg=go.prototype.constructor;function Uc(){return new zg(this._groups,this._parents)}function Yg(e,t){var o,n,r;return function(){var i=So(this,e),s=(this.style.removeProperty(e),So(this,e));return i===s?null:i===o&&s===n?r:r=t(o=i,n=s)}}function $c(e){return function(){this.style.removeProperty(e)}}function Fg(e,t,o){var n,r=o+"",i;return function(){var s=So(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=So(this,e),a=o(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),So(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=st(this,e),c=l.on,d=l.value[i]==null?a||(a=$c(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(s,r=d),l.on=n}}function Kc(e,t,o){var n=(e+="")=="transform"?Js:Pi;return t==null?this.styleTween(e,Yg(e,n)).on("end.style."+e,$c(e)):typeof t=="function"?this.styleTween(e,Wg(e,n,On(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 qc(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 Zc(e){return this.tween("text",typeof e=="function"?qg(On(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 Jc(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 Qc(){for(var e=this._name,t=this._id,o=Li(),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=tt(l,t);Po(l,e,o,c,s,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new pt(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=st(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 pt(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function ed(e){return go().transition(e)}function Li(){return++Qg}var ho=go.prototype;pt.prototype=ed.prototype={constructor:pt,select:Wc,selectAll:Xc,selectChild:ho.selectChild,selectChildren:ho.selectChildren,filter:Bc,merge:zc,selection:Uc,transition:Qc,call:ho.call,nodes:ho.nodes,node:ho.node,size:ho.size,empty:ho.empty,each:ho.each,on:Yc,attr:Rc,attrTween:Dc,style:Kc,styleTween:qc,text:Zc,textTween:Jc,remove:Fc,tween:kc,delay:Oc,duration:Vc,ease:Hc,easeVarying:Gc,end:jc,[Symbol.iterator]:ho[Symbol.iterator]};function ki(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var jg={time:null,delay:0,duration:250,ease:ki};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 td(e){var t,o;e instanceof pt?(t=e._id,e=e._name):(t=Li(),(o=jg).time=br(),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])&&Po(l,e,t,c,s,o||eh(l,t));return new pt(n,this._parents,e,t)}go.prototype.interrupt=Lc;go.prototype.transition=td;function Lo(e,t,o){this.k=e,this.x=t,this.y=o}Lo.prototype={constructor:Lo,scale:function(e){return e===1?this:new Lo(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Lo(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 Ri=new Lo(1,0,0);Di.prototype=Lo.prototype;function Di(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Ri;return e.__zoom}var oh=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var od;(function(e){e.Strict="strict",e.Loose="loose"})(od||(od={}));var nd;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(nd||(nd={}));var rd;(function(e){e.Partial="partial",e.Full="full"})(rd||(rd={}));var id;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(id||(id={}));var sd;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(sd||(sd={}));var xt;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(xt||(xt={}));var yT={[xt.Left]:xt.Right,[xt.Right]:xt.Left,[xt.Top]:xt.Bottom,[xt.Bottom]:xt.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 Oi=(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 xT={[xt.Left]:{x:-1,y:0},[xt.Right]:{x:1,y:0},[xt.Top]:{x:0,y:-1},[xt.Bottom]:{x:0,y:1}};var sh={nodeOrigin:[0,0],nodeExtent:oh,elevateNodesOnSelect:!0,defaults:{}},ET=w(_({},sh),{checkEquality:!0});var ad;(function(e){e.Line="line",e.Handle="handle"})(ad||(ad={}));var ah={width:0,height:0,x:0,y:0},_T=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 Vi=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)||!lh(f.nodeBox,r))continue;let x=Math.abs(f.position-o);if(x>Hi)continue;let g=ch(f.nodeBox,n)>0?0:dh(f.nodeBox,n);c.push({line:f,lineDist:x,nodeDist:g})}let d=.5,u=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;c.sort((f,x)=>{if(u){if(f.line===u&&x.line!==u)return-1;if(x.line===u&&f.line!==u)return 1}return Math.abs(f.lineDist-x.lineDist)<=d?f.nodeDist-x.nodeDist:f.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 ld(e,t=on,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=Oi(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 cd(e,t,o,n,r=Object.keys(on)){let i=[];for(let a of r){let l=on[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 dd(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)<=Hi&&(r=l,s=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=Hi&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:s}}var Hi=10,on={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 fd=require("react/jsx-runtime"),uh=new Vi;function ph(e,t,o,n){var d,u,p,f,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 m=o(h.id);if(!m)continue;let y=m.parentId?o(m.parentId):void 0,v=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=(f=(p=h.measured)==null?void 0:p.width)!=null?f:0,T=(E=(x=h.measured)==null?void 0:x.height)!=null?E:0;r=Math.min(r,v),i=Math.min(i,b),s=Math.max(s,v+I),a=Math.max(a,b+T)}if(r===1/0)return null;let c=Object.keys(on);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,f,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=(f=e.dimensions)==null?void 0:f.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 ud(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)}),ud(t,e,"width",o)),i&&(e.forEach(s=>{s.position&&(s.position.y-=n)}),ud(t,e,"height",n))}function Gi(){let[e,t]=(0,bt.useState)(void 0),[o,n]=(0,bt.useState)(void 0),{width:r,height:i}=(0,Vn.useStore)(g=>({width:g.width,height:g.height}),pd.shallow),s=(0,Vn.useNodesInitialized)(),a=(0,bt.useRef)(uh),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=(0,Vn.useReactFlow)(),u=(0,bt.useCallback)(()=>{t(void 0),n(void 0)},[]),p=(0,bt.useCallback)(g=>{let h=g!=null?g:d();u();let m=ld(h,on,c);a.current.initialize(m)},[c,u,d]),f=(0,bt.useCallback)(()=>{setTimeout(()=>{p()},100)},[p]);(0,bt.useEffect)(()=>{s&&p(d())},[s,p,d]);let x=(0,bt.useCallback)((g,h)=>{if(!a.current||g.length===0)return;let m=g.filter(A=>A.type==="dimensions");if(m.length>1)return;u();let y=g.filter(A=>A.type==="position"&&!!A.position),v=m[0];if(y.length===0&&!v)return;let b=mh(y,v,h,c);if(!b)return;let{x:I,y:T}=l({x:0,y:0}),{x:N,y:C}=l({x:r,y:i}),M={x:I,y:T,x2:N,y2:C},{horizontal:L,vertical:k}=cd(a.current,M,b.bounds,b.excludedNodeIds,b.anchors),{deltaX:O,deltaY:V,snappedX:F,snappedY:j}=dd(b.bounds,L,k);if(!F&&!j)return;let $=y.some(A=>A.dragging),K=!!(v!=null&&v.resizing);($||K)&&(F&&n(k==null?void 0:k.line),j&&t(L==null?void 0:L.line)),gh(y,v,O,V,F,j)},[l,c,r,i,t,n,u]),E=(0,bt.useCallback)(()=>(0,fd.jsx)(md,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:p,forceRebuildIndex:f,updateHelperLines:x,helperLineHorizontal:e,helperLineVertical:o,HelperLines:E}}var gs=require("@xyflow/react"),io=require("react");var yo=e=>new Map(e.map(t=>[t.id,t])),Nr=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),gd=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),ta=e=>e.some(t=>t.type==="START_EVENT"),Hn=(e,t)=>e==="START_EVENT"?!ta(t):!0,hd=(e,t,o,n,r)=>{let i=yo(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:Nr(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},yd=(e,t,o,n,r)=>{let i=yo(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:gd(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Bi=(e,t,o,n,r)=>{var c;let i=yo(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:Nr(e,n,r).filter(d=>{let u=i.get(d.target);return(u==null?void 0:u.type)!=="ANNOTATION"}).length>=2},xd=(e,t,o)=>{var s,a,l,c;let n=yo(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"},zi=(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"},Ed=(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"},wr=(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"},Yi=(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"},nn=(e,t,o,n)=>{let r=yo(t),i=r.get(e);return!i||i.type!=="TASK"?!1:gd(e,o,n).some(a=>{let l=r.get(a.source);return(l==null?void 0:l.type)==="START_EVENT"})},Ir=(e,t,o,n)=>{let r=yo(t),i=r.get(e);return!i||i.type!=="TASK"?!1:Nr(e,o,n).some(a=>{let l=r.get(a.target);return(l==null?void 0:l.type)==="END_EVENT"})},_d=(e,t,o,n,r)=>{let i=yo(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"?Ir(t,o,n,r):(a==null?void 0:a.type)==="END_EVENT"&&(s==null?void 0:s.type)==="TASK"?nn(e,o,n,r):!1},Fi=(e,t,o)=>Nr(e,t,o).length>0,Wi=(e,t,o,n,r)=>{let i=yo(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:Nr(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var bd=(e,t,o,n,r)=>{var a,l;let i=yo(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:!bd(e.sourceNodeId,e.targetNodeId,e.edges,e.nodes,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!hd(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!yd(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!Bi(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!Wi(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:xd(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"&&Ed(e.targetNodeId,e.nodes)),reason:"start_event_to_subprocess_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&wr(e.targetNodeId,e.nodes)),reason:"start_event_to_service_task_not_allowed"}),e=>({isValid:!(wr(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:!(zi(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(Yi(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(nn(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!_d(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(Ir(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(Fi(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"})],oa=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:Bi(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:ta(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:zi(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Yi(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:wr(e.sourceNodeId,e.nodes),reason:"service_task_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:nn(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Ir(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Fi(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Wi(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],Td=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 zt=require("@xyflow/react");var vd=require("react"),Nd=require("@xyflow/react");function Zt(){return(0,Nd.useStore)((0,vd.useCallback)(e=>e.nodes.filter(o=>o.selected).length+e.edges.filter(o=>o.selected).length>=2,[]))}var Jt=require("@produto-lecom/lecom-ui"),wd=require("lucide-react");var kt=require("@xyflow/react");var Xi=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=(0,kt.useReactFlow)(),{selectElements:r}=Kt(),i=g=>{let h=o(),m=n(),y=(0,kt.getIncomers)(g,h,m),v=(0,kt.getOutgoers)(g,h,m),b=y.some(T=>T.type==="START_EVENT"),I=v.some(T=>T.type==="END_EVENT");return b?"start":I?"end":"between"},s=(g,h,m)=>{var b,I,T,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},v={id:g.id,position:i(g),label:(T=g.data)==null?void 0:T.label,node:y};return g.type==="TASK"&&((N=g.data)==null?void 0:N.variant)==="SUBPROCESS"?w(_({},v),{type:"sub_process"}):g.type==="TASK"&&((C=g.data)==null?void 0:C.variant)==="SERVICE_TASK"?w(_({},v),{type:"service_task"}):g.type==="GATEWAY"?w(_({},v),{type:"gateway",variant:a(g,h,m)}):w(_({},v),{type:"activity"})},a=(g,h,m)=>{if(g.type!=="GATEWAY")return;let y=(0,kt.getIncomers)(g,h,m),v=!1,b=!1;if(y.forEach(I=>{var T,N;I.type==="TASK"&&(((T=I.data)==null?void 0:T.variant)==="SCRIPT"&&(v=!0),((N=I.data)==null?void 0:N.attribute)==="LOOP"&&(b=!0))}),v&&b)return"script_loop";if(v)return"script";if(b)return"loop"},l=(g,h,m)=>{var T,N,C,M,L;let y=e(g.source),v=e(g.target);if(!y||!v)return"simple";if((0,kt.getOutgoers)(y,h,m).some(k=>k.type==="END_EVENT"))return"final";if(y.type==="GATEWAY")switch((T=y.data)==null?void 0:T.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(y.type==="TASK"){let k=(N=y.data)==null?void 0:N.variant,O=(C=y.data)==null?void 0:C.attribute;if(k==="SUBPROCESS")return"from_sub_process";if(k==="SERVICE_TASK")return"from_service_task";if(v.type==="TASK"&&((M=v.data)==null?void 0:M.variant)==="SUBPROCESS")return"to_sub_process";if(v.type==="TASK"&&((L=v.data)==null?void 0:L.variant)==="SERVICE_TASK")return"to_service_task";let V=k==="SCRIPT",F=O==="LOOP";return V&&F?"script_loop":V?"script":F?"loop":"simple"}return"simple"},c=(g,h,m)=>{let y=[];function v(I,T,N=0){let C=s(I,h,m);if(C.depth=N,T.push(C),I.type==="TASK"){y.push([...T]),T.pop();return}let M=(0,kt.getIncomers)(I,h,m);if(M.length)for(let L of M)v(L,T,N+1);T.pop()}let b=(0,kt.getIncomers)(g,h,m);for(let I of b)v(I,[]);return y},d=(g,h,m)=>{let y=[];function v(I,T,N=0){let C=s(I,h,m);if(C.depth=N,T.push(C),I.type==="TASK"){y.push([...T]),T.pop();return}let M=(0,kt.getOutgoers)(I,h,m);if(M.length)for(let L of M)v(L,T,N+1);T.pop()}let b=(0,kt.getOutgoers)(g,h,m);for(let I of b)v(I,[]);return y},u=(g,h,m)=>(m=m.filter(v=>v.source===g.id),m.map(v=>{var T;let b=e(v.target),I;return b&&(I=s(b,h,m)),{id:v.id,type:"routing",variant:l(v,h,m),label:(T=v.data)==null?void 0:T.label,target:I}})),p=g=>{let h=e(g);if(!h)return;let m=o(),y=n(),v=s(h,m,y);return v.sources=c(h,m,y),v.targets=d(h,m,y),v.edgeTargets=u(h,m,y),h.type==="GATEWAY"&&(v.variant=a(h,m,y)),v},f=g=>{let h=t(g);if(!h)return;let m=o(),y=n(),v=l(h,m,y),I={id:h.id,type:"routing",variant:v,gatewayVariant:void 0},T=e(h.source);if(T){let C=s(T,m,y);I.source=C;let M=a(T,m,y);if(I.gatewayVariant=M,T.type==="TASK")I.sources=[[C]];else{let L=c(T,m,y);I.sources=L.length?L:[[C]]}}let N=e(h.target);if(N){let C=s(N,m,y);if(I.target=C,N.type==="TASK")I.targets=[[C]];else{let M=d(N,m,y);I.targets=M.length?M:[[C]]}}return I},x=g=>{let h=e(g);if(h)return p(h.id);let m=t(g);if(m)return f(m.id)};return{configureElement:g=>{let h=x(g);if(h)return r([g]),h},getConfigureElement:x,getNodeConfigure:p,getEdgeConfigure:f}};var rn=require("react/jsx-runtime"),xh={node:"editor.toolbar.configure_node",edge:"editor.toolbar.configure_edge",gateway:"editor.toolbar.configure_gateway"},ko=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,Jt.useTranslation)(),{onConfigureElement:n}=J(),{getConfigureElement:r}=Xi();return(0,rn.jsxs)(Jt.Tooltip,{children:[(0,rn.jsx)(Jt.TooltipTrigger,{asChild:!0,children:(0,rn.jsx)(Jt.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let s=r(e);s&&(n==null||n(s))},children:(0,rn.jsx)(wd.Settings,{size:16})})}),(0,rn.jsx)(Jt.TooltipContent,{color:"black",children:o(xh[t])})]})};var Qt=require("@produto-lecom/lecom-ui"),Ad=require("@xyflow/react"),Cd=require("lucide-react");var Id=require("@produto-lecom/lecom-ui");function rt(){let{toast:e}=Gn(),{toast:t}=(0,Id.useNotificationToast)();return{toast:e||t}}var sn=require("react/jsx-runtime"),Ui=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,Qt.useTranslation)(),{toast:n}=rt(),{deleteElements:r,getNodes:i}=(0,Ad.useReactFlow)();return(0,sn.jsxs)(Qt.Tooltip,{children:[(0,sn.jsx)(Qt.TooltipTrigger,{asChild:!0,children:(0,sn.jsx)(Qt.Button,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{if(t==="node"){let a=i(),l=a.find(c=>c.id===e);if((l==null?void 0:l.type)==="LANE"&&a.some(d=>d.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}]})},children:(0,sn.jsx)(Cd.TrashIcon,{size:16})})}),(0,sn.jsx)(Qt.TooltipContent,{color:"black",children:o("editor.toolbar.delete")})]})};var jt=require("@produto-lecom/lecom-ui"),Sd=require("lucide-react"),Md=require("react"),an=require("react/jsx-runtime"),Bn=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=(0,jt.useTranslation)(),r=(0,Md.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 x=p.getBoundingClientRect(),E=f.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?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,an.jsxs)(jt.Tooltip,{children:[(0,an.jsx)(jt.TooltipTrigger,{asChild:!0,children:(0,an.jsx)(jt.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,an.jsx)(Sd.MoveUpRightIcon,{size:16})})}),(0,an.jsx)(jt.TooltipContent,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};var zn=require("react/jsx-runtime"),Yn=i=>{var s=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=s,r=$t(s,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:a}=J(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d,isToEndEvent:u}=si(o,n),p=!l&&!c&&!d&&!u,f=[{component:(0,zn.jsx)(Ui,{elementId:e,elementType:"edge"})}],x=()=>a==="view"?p?[{component:(0,zn.jsx)(ko,{elementId:e,elementType:"edge"})}]:[]:p?[{component:(0,zn.jsx)(ko,{elementId:e,elementType:"edge"})},...f]:f,g=(h=>{switch(h){case"SEQUENCE_EDGE":return x();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,zn.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,m)=>(0,zn.jsx)("div",{children:h.component},m))}))};var Pd=require("@xyflow/react"),Ld=require("react");var na=require("react/jsx-runtime"),eo=12,Fn=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:s}=(0,Pd.useViewport)(),a=1/s,l=(0,Ld.useMemo)(()=>t===n?{bottom:`${eo}px`,transform:"translateX(-50%)"}:e===o?{left:`${eo}px`,transform:r?"translateY(-100%)":"translateY(-50%)"}:n>t&&o>e?{left:`${eo}px`,bottom:`${eo}px`}:n>t&&o<e?{right:`${eo}px`,bottom:`${eo}px`}:t>n&&o>e?{right:`${eo}px`,bottom:`${eo}px`}:{left:`${eo}px`,bottom:`${eo}px`},[e,t,o,n,r]);return(0,na.jsx)("div",{style:{transform:`scale(${a})`},children:(0,na.jsx)("div",{className:"absolute pointer-events-auto",style:_({},l),children:i})})};var to=require("react/jsx-runtime"),Wn={type:"ANNOTATION_EDGE",reconnectable:!0},kd=({id:e,source:t,target:o,selected:n,data:r})=>{let{isReadOnly:i,edgeHighlight:s}=J(),a=Zt(),{zoom:l}=(0,zt.useViewport)(),c=(0,zt.useInternalNode)(t),d=(0,zt.useInternalNode)(o);if(!c||!d)return null;let{sx:u,sy:p,tx:f,ty:x}=Ln(c,d),[E,g,h]=(0,zt.getStraightPath)({sourceX:u,sourceY:p,targetX:f,targetY:x}),m=s&&(n||(c==null?void 0:c.selected)||(d==null?void 0:d.selected));return(0,to.jsxs)("g",{className:G("group bpmn-edge",{"is-highlighted":m}),children:[(0,to.jsx)("path",{d:E,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/l),style:{pointerEvents:"stroke",cursor:"pointer"}}),(0,to.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":m}),children:[(0,to.jsx)(zt.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]":m&&!(r!=null&&r.hasError)})}),(0,to.jsx)(zt.EdgeLabelRenderer,{children:(0,to.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,to.jsx)(Fn,{sx:u,sy:p,tx:f,ty:x,children:(0,to.jsx)(Yn,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})})})]})]})};var Xe=nr(require("react"),1),Le=require("@xyflow/react");var Yt=require("react");var ia=require("react/jsx-runtime"),ra=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,Rd=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Escape","Shift"],ct=({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,Yt.useRef)(null),p=(0,Yt.useRef)(null),[f,x]=(0,Yt.useState)(!1);(0,Yt.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]),(0,Yt.useEffect)(()=>{x(i!=null?i:!1)},[i]),(0,Yt.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,Yt.useCallback)(()=>{p.current||(c==null||c(),p.current=setTimeout(()=>{p.current=null},500))},[c]),g=b=>{b.stopPropagation(),f||x(!0)},h=b=>{let I=b.currentTarget.innerText.replace(/\n$/,""),T=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,k=L&&b.key==="a",O=L&&b.key==="c",V=L&&b.key==="x",F=L&&b.key==="v",j=I.length===0||M&&C.length===I.length;if(!d&&j&&!ra.test(b.key)&&!Rd.includes(b.key)&&!L){b.preventDefault(),E();return}T&&!M&&(Rd.includes(b.key)||k||O||V||F||b.preventDefault())},m=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$/,""),I=window.getSelection();if(!I||I.rangeCount===0)return;let C=I.toString(),P=v.length-C.length,R=t?Math.max(0,t-P):1/0;if(R<=0&&C.length===0)return;let S=N;if(S.length>R&&(S=S.substring(0,R)),!S&&C.length===0)return;let L=I.getRangeAt(0),K=L.startOffset===0&&(L.startContainer===b.currentTarget||L.startContainer.parentNode===b.currentTarget);if(!d&&K&&S.length>0&&!na.test(S[0])){E();return}L.deleteContents();let j=document.createTextNode(S);L.insertNode(j),L.setStartAfter(j),L.collapse(!0),I.removeAllRanges(),I.addRange(L),l==null||l(b.currentTarget.innerText.replace(/\n$/,""))},x=b=>{let N=b.currentTarget,v=N.innerText.replace(/\n$/,"");if(!d&&v.length>0&&!na.test(v[0])){let I=v.slice(1);if(N.innerText=I,I.length>0&&N.firstChild){let C=document.createRange(),P=window.getSelection();C.setStart(N.firstChild,0),C.collapse(!0),P==null||P.removeAllRanges(),P==null||P.addRange(C)}E(),l==null||l(I);return}l==null||l(v)},T=b=>{y(!1);let N=b.currentTarget.innerText.replace(/\r\n/g,`
3
+ `),T=b.currentTarget.innerText.replace(/\n$/,""),N=window.getSelection();if(!N||N.rangeCount===0)return;let C=N.toString(),M=T.length-C.length,L=t?Math.max(0,t-M):1/0;if(L<=0&&C.length===0)return;let k=I;if(k.length>L&&(k=k.substring(0,L)),!k&&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&&k.length>0&&!ra.test(k[0])){E();return}O.deleteContents();let F=document.createTextNode(k);O.insertNode(F),O.setStartAfter(F),O.collapse(!0),N.removeAllRanges(),N.addRange(O),l==null||l(b.currentTarget.innerText.replace(/\n$/,""))},y=b=>{let I=b.currentTarget,T=I.innerText.replace(/\n$/,"");if(!d&&T.length>0&&!ra.test(T[0])){let N=T.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(T)},v=b=>{x(!1);let I=b.currentTarget.innerText.replace(/\r\n/g,`
4
4
  `).replace(/\r/g,`
5
- `).trim();t&&N.length>t&&(N=N.substring(0,t)),b.currentTarget.innerText=N,s==null||s(),N!==e&&(a==null||a(N))};return(0,ra.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":m,"bg-white":e.length>0},n),style:o,onDoubleClick:u,children:(0,ra.jsx)("div",{ref:p,className:H("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":m}),contentEditable:m,suppressContentEditableWarning:!0,onKeyDown:g,onPaste:h,onInput:x,onBlur:T,children:e})})};var nh=require("@xyflow/react");var _e=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,Yn=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),Wi=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),rh=(e,t,o)=>{let n=o.x-t.x,r=o.y-t.y,i=n*n+r*r;if(i===0)return Yn(e,t);let a=Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*r)/i));return Yn(e,{x:t.x+a*n,y:t.y+a*r})},Td=(e,t)=>{let o=1/0;for(let n=0;n<t.length-1;n++)o=Math.min(o,rh(e,t[n],t[n+1]));return o};var vr=require("@xyflow/react");var Oo={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15,MAX_LABEL_DISTANCE:80};var{TOLERANCE:ce}=Oo;function ih(e,t,o){return _e(e,t,"x",ce)&&_e(t,o,"x",ce)&&_e(e,o,"x",ce)}function sh(e,t,o){return _e(e,t,"y",ce)&&_e(t,o,"y",ce)&&_e(e,o,"y",ce)}function ah(e,t,o){if(!ih(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 lh(e,t,o){if(!sh(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 ch(e,t,o,n){let r=t.x!==0,i=t.x===-n.x&&t.y===-n.y,a=t.x===n.x&&t.y===n.y,s=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)<s?Math.max(e.y,o.y)+s: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)<s?Math.max(e.x,o.x)+s:l;return[{x:c,y:e.y},{x:c,y:o.y}]}}else if(a)if(r)if((o.x-e.x)*t.x>0&&Math.abs(e.y-o.y)<s){let l=Math.max(e.y,o.y)+s,c=o.x+t.x*(s/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)<s){let l=Math.max(e.x,o.x)+s,c=o.y+t.y*(s/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,p=n.x!==0?(l-o.x)*n.x:(c-o.y)*n.y;return d>=0&&p>=0?[{x:l,y:c}]:r?[{x:e.x,y:o.y}]:[{x:o.x,y:e.y}]}}function vd(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];_e(n,r,"x",ce)&&_e(r,i,"x",ce)||_e(n,r,"y",ce)&&_e(r,i,"y",ce)||t.push(r)}return t.push(e[e.length-1]),t}function Xi(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 dh(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],a=t[n+1];if(ah(r,i,a)||lh(r,i,a)){t.splice(n,1),o=!0;break}}}return t}function Nd(e){let t=Xi(vd([...e]));return t=dh(t),Xi(vd(t))}function Ui(e){switch(e){case vr.Position.Left:return{x:-1,y:0};case vr.Position.Right:return{x:1,y:0};case vr.Position.Top:return{x:0,y:-1};case vr.Position.Bottom:return{x:0,y:1};default:return{x:0,y:0}}}function wd(e,t,o,n){let r=Oo.OFFSET,i=Oo.OFFSET;if(t.x===-n.x&&t.y===-n.y)if(t.x!==0){let a=(o.x-e.x)*t.x;a>0&&a<2*Oo.OFFSET&&(r=a/2,i=a/2)}else{let a=(o.y-e.y)*t.y;a>0&&a<2*Oo.OFFSET&&(r=a/2,i=a/2)}return{sourceOffset:r,targetOffset:i}}function uh(e,t,o,n,r,i,a=0){let s=Ui(r),l=Ui(i),c=s.x===0?a:0,d=s.y===0?a:0,p=l.x===0?a:0,f=l.y===0?a:0,m={x:e+c,y:t+d},y={x:o+p,y:n+f},{sourceOffset:E,targetOffset:u}=wd(m,s,y,l),g={x:m.x+s.x*E,y:m.y+s.y*E},h={x:y.x+l.x*u,y:y.y+l.y*u},x=ch(g,s,h,l),T=[m,g,...x,h,y],b=Nd(T);if(b.length===2&&$i(m,y)>ce){let N=_e(m,g,"x",ce)&&_e(g,h,"x",ce)&&_e(h,y,"x",ce),v=_e(m,g,"y",ce)&&_e(g,h,"y",ce)&&_e(h,y,"y",ce);if(N||v){let I=v&&(h.x-g.x)*s.x<0,C=N&&(h.y-g.y)*s.y<0;if(!I&&!C)return Xi([m,g,h,y])}}return b}function Ki(e,t,o,n,r,i,a,s=0){if(!(a!=null&&a.length))return uh(e,t,o,n,r,i,s);let l=Ui(r),c=Ui(i),d=l.x===0?s:0,p=l.y===0?s:0,f=c.x===0?s:0,m=c.y===0?s:0,y={x:e+d,y:t+p},E={x:o+f,y:n+m},{sourceOffset:u,targetOffset:g}=wd(y,l,E,c),h={x:y.x+l.x*u,y:y.y+l.y*u},x={x:E.x+c.x*g,y:E.y+c.y*g},T=[...a],b=T[0],N=l.y===0;N&&Math.abs(y.y-b.y)>ce?T.unshift({x:b.x,y:y.y}):!N&&Math.abs(y.x-b.x)>ce&&T.unshift({x:y.x,y:b.y});let v=T[T.length-1],I=c.y===0,C=[];(Math.abs(v.x-x.x)>ce||Math.abs(v.y-x.y)>ce)&&(I?C.push({x:x.x,y:v.y}):C.push({x:v.x,y:x.y})),C.push(x);let P=[y,...T,...C,E],R=Nd(P);if(R.length===2&&$i(y,E)>ce){let S=_e(y,h,"x",ce)&&_e(h,x,"x",ce)&&_e(x,E,"x",ce),L=_e(y,h,"y",ce)&&_e(h,x,"y",ce)&&_e(x,E,"y",ce);if(S||L){let K=L&&(x.x-h.x)*l.x<0,j=S&&(x.y-h.y)*l.y<0;if(!K&&!j)return Xi([y,h,x,E])}}return R}var $i=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function ph(e,t,o){return _e(e,t,"x",ce)&&_e(t,o,"x",ce)||_e(e,t,"y",ce)&&_e(t,o,"y",ce)}function fh(e,t,o,n){if(ph(e,t,o))return`L${t.x} ${t.y}`;let r=$i(e,t),i=$i(t,o),a=Math.min(r/2,i/2,n);if(a<1)return`L${t.x} ${t.y}`;let s=e.x-t.x,l=e.y-t.y,c=o.x-t.x,d=o.y-t.y,p={x:s/r,y:l/r},f={x:c/i,y:d/i},m={x:t.x+p.x*a,y:t.y+p.y*a},y={x:t.x+f.x*a,y:t.y+f.y*a},E=-p.x,u=-p.y,g=f.x,h=f.y,T=E*h-u*g>0?1:0;return`L${m.x} ${m.y}A${a} ${a} 0 0 ${T} ${y.x} ${y.y}`}var Id=(e,t=5)=>e.length<2?"":e.reduce((o,n,r)=>{let i="";return r>0&&r<e.length-1?i=fh(e[r-1],n,e[r+1],t):i=`${r===0?"M":"L"}${n.x} ${n.y}`,o+=i,o},"");var Me=require("react"),qi=require("@xyflow/react");var mh=50,Ad=.1,gh=.6,Zi=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:a,getNodes:s,getEdge:l,screenToFlowPosition:c}=(0,qi.useReactFlow)(),{setIsDragging:d,setReconnectingEdgeId:p}=q(),f=(0,qi.useStore)(D=>D.isValidConnection),[m,y]=(0,Me.useState)(null),[E,u]=(0,Me.useState)(null),[g,h]=(0,Me.useState)(null),[x,T]=(0,Me.useState)(null),[b,N]=(0,Me.useState)(null),[v,I]=(0,Me.useState)(!1),C=(0,Me.useRef)(null),P=(0,Me.useRef)(null),R=(0,Me.useRef)(null),S=(0,Me.useRef)(t),L=(0,Me.useRef)(o);(0,Me.useEffect)(()=>{S.current=t,L.current=o},[t,o]),(0,Me.useEffect)(()=>{C.current=m},[m]),(0,Me.useEffect)(()=>{P.current=b},[b]);let K=(0,Me.useCallback)(D=>{let A=s(),B=A.find(Y=>Y.id===D);if(!B)return{x:0,y:0};let G=B.position.x,k=B.position.y,O=B.parentId;for(;O;){let Y=A.find(F=>F.id===O);if(!Y)break;G+=Y.position.x,k+=Y.position.y,O=Y.parentId}return{x:G,y:k}},[s]),j=(0,Me.useCallback)(D=>{var O,Y,F,U,X,$;let A=s(),B=null,G=mh,k=A.filter(te=>te.type!=="LANE"&&te.type!=="ANNOTATION");for(let te of k){if(te.id===e)continue;let ie=K(te.id),W=(F=(Y=(O=te.measured)==null?void 0:O.width)!=null?Y:te.width)!=null?F:0,oe=($=(X=(U=te.measured)==null?void 0:U.height)!=null?X:te.height)!=null?$:0;if(D.x>=ie.x&&D.x<=ie.x+W&&D.y>=ie.y&&D.y<=ie.y+oe)return te.id;let Z=Math.max(ie.x-D.x,0,D.x-(ie.x+W)),ve=Math.max(ie.y-D.y,0,D.y-(ie.y+oe)),ye=Math.sqrt(Z*Z+ve*ve);ye<G&&(G=ye,B=te.id)}return B},[s,K,e]),Q=(0,Me.useCallback)((D,A)=>{var Z,ve,ye,Ce,J,de;let B=a(D);if(!B)return null;let G=K(D),k=(ye=(ve=(Z=B.measured)==null?void 0:Z.width)!=null?ve:B.width)!=null?ye:0,O=(de=(J=(Ce=B.measured)==null?void 0:Ce.height)!=null?J:B.height)!=null?de:0,Y=Math.abs(G.x+k-A.x),F=Math.abs(A.x-G.x),U=Math.abs(G.y+O-A.y),X=Math.abs(A.y-G.y),$={right:Y,left:F,bottom:U,top:X},te=Object.entries($).reduce((re,[ee,xe])=>xe<re[1]?[ee,xe]:re,["right",$.right])[0],ie=R.current;if(ie&&ie!==te){let re=$[te],ee=$[ie],xe=Math.abs(ee-re),Se=Math.min(Math.abs(ee),Math.abs(re));xe<Se*gh&&(te=ie)}let W=te,oe,le;if(W==="right"||W==="left"){let ee=(Math.max(G.y,Math.min(G.y+O,A.y))-G.y)/(O||1);Math.abs(ee-.5)<Ad&&(ee=.5),le=ee,oe={x:W==="right"?G.x+k:G.x,y:G.y+le*O}}else{let ee=(Math.max(G.x,Math.min(G.x+k,A.x))-G.x)/(k||1);Math.abs(ee-.5)<Ad&&(ee=.5),le=ee,oe={x:G.x+le*k,y:W==="bottom"?G.y+O:G.y}}return{side:W,snapPosition:oe,offset:le}},[a,K]),z=(0,Me.useCallback)(D=>{var F,U,X;let A=C.current;if(!A)return;let B=c({x:D.clientX,y:D.clientY}),G=j(B);h(G);let k=B,O=null,Y=null;if(G){let $=Q(G,B);$&&(O=$.side,k=$.snapPosition,Y=$.offset,R.current=O);let te=l(e),ie={source:A==="source"?G:S.current,target:A==="target"?G:L.current,sourceHandle:A==="source"?O:(F=te==null?void 0:te.sourceHandle)!=null?F:null,targetHandle:A==="target"?O:(U=te==null?void 0:te.targetHandle)!=null?U:null},W=(X=f==null?void 0:f(ie))!=null?X:!0;I(W)}else R.current=null,I(!1);T(O),N(Y),u(k)},[j,Q,l,e,c,f]),M=(0,Me.useCallback)(D=>{var O,Y,F,U,X;let A=C.current;if(!A)return;let B=c({x:D.clientX,y:D.clientY}),G=j(B);if(G){let $=Q(G,B),te=(O=$==null?void 0:$.side)!=null?O:null,ie=(Y=$==null?void 0:$.offset)!=null?Y:.5,W=l(e),oe={source:A==="source"?G:S.current,target:A==="target"?G:L.current,sourceHandle:A==="source"?te:(F=W==null?void 0:W.sourceHandle)!=null?F:null,targetHandle:A==="target"?te:(U=W==null?void 0:W.targetHandle)!=null?U:null};((X=f==null?void 0:f(oe))==null||X)&&i(le=>le.map(Z=>{var ve,ye;return Z.id===e?w(_({},Z),{source:oe.source,target:oe.target,sourceHandle:oe.sourceHandle,targetHandle:oe.targetHandle,data:w(_({},Z.data),{points:void 0,sourceOffset:A==="source"?ie:(ve=Z.data)==null?void 0:ve.sourceOffset,targetOffset:A==="target"?ie:(ye=Z.data)==null?void 0:ye.targetOffset})}):Z}))}y(null),u(null),h(null),T(null),N(null),d(!1),I(!1),p(null),R.current=null,document.removeEventListener("mouseup",M),document.removeEventListener("mousemove",z);let k=oo.get(n);k==null||k.clearReconnectingEdge()},[e,j,Q,l,i,n,z,f,c,d,p]),V=(0,Me.useCallback)((D,A)=>{if(r||A.button!==0)return;A.stopPropagation(),A.preventDefault(),i(G=>G.map(k=>k.id===e?w(_({},k),{data:w(_({},k.data),{points:void 0})}):k)),y(D),p(e);let B=oo.get(n);B==null||B.setReconnectingEdge(e),document.addEventListener("mousemove",z),document.addEventListener("mouseup",M)},[r,e,n,z,M,p,i]);return(0,Me.useEffect)(()=>()=>{if(C.current){document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",M),p(null);let D=oo.get(n);D==null||D.clearReconnectingEdge()}},[n,z,M,p]),{reconnectingHandle:m,cursorPosition:E,hoveredNodeId:g,reconnectingSide:x,reconnectingOffset:b,isValidReconnection:v,handleReconnectStart:V}};var ge=require("react/jsx-runtime"),Dt={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:Pe.MarkerType.ArrowClosed},markerEnd:{type:Pe.MarkerType.Arrow},data:{label:""}},{MOVE_THRESHOLD:Ji,MIN_SEGMENT_LENGTH:hh,PARALLEL_OFFSET:Cd,MAX_LABEL_DISTANCE:yh}=Oo;function xh(e,t,o,n,r){let i=r.find(d=>d.id===t),a=r.find(d=>d.id===o);if((i==null?void 0:i.type)==="GATEWAY"||(a==null?void 0:a.type)==="GATEWAY")return 0;let s=n.filter(d=>d.source===t&&d.target===o||d.source===o&&d.target===t);if(s.length<=1){let d=n.filter(m=>m.source===t);if(d.length<=1)return 0;let p=d.findIndex(m=>m.id===e);if(p<=0)return 0;let f=(d.length-1)/2;return(p-f)*Cd}let l=s.findIndex(d=>d.id===e),c=(s.length-1)/2;return(l-c)*Cd}var Sd=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var $,te,ie,W,oe,le,Z,ve,ye,Ce;let{zoom:c}=(0,Pe.useViewport)(),{updateEdgeData:d}=(0,Pe.useReactFlow)(),p=(0,Pe.useEdges)(),f=(0,Pe.useNodes)(),{isMultipleSelection:m,isReadOnly:y,mode:E,instanceId:u,edgeHighlight:g}=q(),[h,x]=(0,it.useState)(!1),[T,b]=(0,it.useState)(null),N=(0,it.useRef)(null),v=(0,it.useRef)(n==null?void 0:n.labelOffset),I=(0,it.useRef)(null),C=E!=="edit",{reconnectingHandle:P,cursorPosition:R,hoveredNodeId:S,reconnectingSide:L,isValidReconnection:K,handleReconnectStart:j}=Zi({edgeId:e,source:t,target:o,instanceId:u,isReadOnly:C}),Q=(0,Pe.useInternalNode)(t),z=(0,Pe.useInternalNode)(o),{sx:M,sy:V,tx:D,ty:A,sourcePos:B,targetPos:G}=(0,it.useMemo)(()=>{var Ut,$t;let J=Q&&z?Mn(Q,z):{sx:0,sy:0,tx:0,ty:0,sourcePos:Pe.Position.Right,targetPos:Pe.Position.Left},de=s?i:J.sourcePos,re=l?a:J.targetPos,ee=(gt,Ee,he)=>{var ct,Kt,No,po,fo,Ca;let{x:fe,y:He}=gt.internals.positionAbsolute,ht=(No=(Kt=(ct=gt.measured)==null?void 0:ct.width)!=null?Kt:gt.width)!=null?No:0,Mt=(Ca=(fo=(po=gt.measured)==null?void 0:po.height)!=null?fo:gt.height)!=null?Ca:0;switch(Ee){case Pe.Position.Top:return{x:fe+ht*he,y:He};case Pe.Position.Bottom:return{x:fe+ht*he,y:He+Mt};case Pe.Position.Left:return{x:fe,y:He+Mt*he};case Pe.Position.Right:return{x:fe+ht,y:He+Mt*he};default:return{x:fe+ht/2,y:He+Mt/2}}},xe=(Ut=n==null?void 0:n.sourceOffset)!=null?Ut:.5,Se=($t=n==null?void 0:n.targetOffset)!=null?$t:.5,Ve=Q?ee(Q,de,xe).x:J.sx,ot=Q?ee(Q,de,xe).y:J.sy,St=z?ee(z,re,Se).x:J.tx,uo=z?ee(z,re,Se).y:J.ty;return P==="source"&&R?(Ve=R.x,ot=R.y,L&&(de=L)):P==="target"&&R&&(St=R.x,uo=R.y,L&&(re=L)),{sx:Ve,sy:ot,tx:St,ty:uo,sourcePos:de,targetPos:re}},[Q,z,s,l,i,a,P,R,L,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);(0,it.useEffect)(()=>{var re;if(!I.current){I.current={sx:M,sy:V,tx:D,ty:A,sourcePos:B,targetPos:G};return}let J=I.current;if(Math.abs(M-J.sx)>Ji||Math.abs(V-J.sy)>Ji||Math.abs(D-J.tx)>Ji||Math.abs(A-J.ty)>Ji||J.sourcePos!==B||J.targetPos!==G){let ee={};(re=n==null?void 0:n.points)!=null&&re.length&&(ee.points=void 0),n!=null&&n.labelOffset&&(ee.labelOffset=void 0),Object.keys(ee).length>0&&d(e,_(_({},n),ee))}I.current={sx:M,sy:V,tx:D,ty:A,sourcePos:B,targetPos:G}},[M,V,D,A,B,G,n,e,d,P]);let k=(0,it.useMemo)(()=>{let J=xh(e,t,o,p,f);return Ki(M,V,D,A,B,G,n==null?void 0:n.points,J)},[M,V,D,A,B,G,n==null?void 0:n.points,p,f,e,t,o]),O=(0,it.useMemo)(()=>{if(k.length<2)return Wi({x:M,y:V},{x:D,y:A});let J=0;for(let ee=0;ee<k.length-1;ee++)J+=Yn(k[ee],k[ee+1]);let de=J/2,re=0;for(let ee=0;ee<k.length-1;ee++){let xe=Yn(k[ee],k[ee+1]);if(re+xe>=de){let Se=(de-re)/xe,Ve=k[ee],ot=k[ee+1];return{x:Ve.x+(ot.x-Ve.x)*Se,y:Ve.y+(ot.y-Ve.y)*Se}}re+=xe}return Wi({x:M,y:V},{x:D,y:A})},[k,M,V,D,A]),Y=(0,it.useCallback)((J,de)=>{if(E!=="edit"||de.button!==0)return;de.stopPropagation(),de.preventDefault();let re=k[J],ee=k[J+1],xe=_e(re,ee,"y"),Se=xe?re.y:re.x,Ve=[...k],ot=Ve.length,St=J,uo=J+1;b(J);let Ut=gt=>{let Ee=Se+(xe?gt.clientY-de.clientY:gt.clientX-de.clientX)/c;N.current=xe?{x:(re.x+ee.x)/2,y:Ee}:{x:Ee,y:(re.y+ee.y)/2};let he=[];for(let fe=1;fe<ot-1;fe++){let He=Ve[fe];fe===St||fe===uo?xe?he.push({x:He.x,y:Ee}):he.push({x:Ee,y:He.y}):he.push(_({},He))}d(e,w(_({},n),{points:he}))},$t=()=>{b(null),N.current=null,document.removeEventListener("mousemove",Ut),document.removeEventListener("mouseup",$t)};document.addEventListener("mousemove",Ut),document.addEventListener("mouseup",$t)},[E,k,c,n,e,d]),F=(0,it.useCallback)(J=>{var Ut,$t,gt,Ee,he;if(h||C||J.button!==0||!((Ut=n==null?void 0:n.label)!=null&&Ut.trim()))return;J.stopPropagation(),J.preventDefault();let de=J.clientX,re=J.clientY,ee=(gt=($t=n==null?void 0:n.labelOffset)==null?void 0:$t.x)!=null?gt:0,xe=(he=(Ee=n==null?void 0:n.labelOffset)==null?void 0:Ee.y)!=null?he:0,Se=[...k],Ve={x:O.x,y:O.y},ot=!1,St=fe=>{let He=(fe.clientX-de)/c,ht=(fe.clientY-re)/c;if(!ot&&Math.abs(He)<3&&Math.abs(ht)<3)return;ot=!0;let Mt={x:ee+He,y:xe+ht};v.current=Mt,d(e,w(_({},n),{labelOffset:Mt}))},uo=()=>{document.removeEventListener("mousemove",St),document.removeEventListener("mouseup",uo);let fe=v.current;if(!fe)return;let He={x:Ve.x+fe.x,y:Ve.y+fe.y};Td(He,Se)>yh&&(v.current=void 0,d(e,w(_({},n),{labelOffset:void 0})))};document.addEventListener("mousemove",St),document.addEventListener("mouseup",uo)},[h,C,c,n,e,d,k,O]);if(!Q||!z)return null;let U=Id(k),X=g&&(r||Q.selected||z.selected);return(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsxs)("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":X}),onDoubleClick:()=>!C&&x(!0),children:[(0,ge.jsx)("path",{d:U,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),className:H({"nopan nodrag":!h&&!C&&!!(($=n==null?void 0:n.label)!=null&&$.trim())}),style:{pointerEvents:"stroke",cursor:!h&&!C&&((te=n==null?void 0:n.label)!=null&&te.trim())?"move":"pointer"},onMouseDown:F}),(0,ge.jsxs)("g",{className:H("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!y,"text-blue-500 group-hover:text-blue-600":X}),children:[(0,ge.jsx)(Pe.BaseEdge,{id:e,path:U,interactionWidth:0,markerEnd:`url(#${X?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75",{"group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]":!y,"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||P&&S&&!K,"stroke-green-500":P&&S&&K,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":X&&!(n!=null&&n.hasError)&&!P})}),r&&!m&&!C&&(0,ge.jsx)("g",{children:k.slice(0,-1).map((J,de)=>{let re=k[de+1];if(de===0||de===k.length-2||Yn(J,re)<hh)return null;let ee=_e(J,re,"y"),xe=T===de,Se=xe&&N.current?N.current:Wi(J,re);return(0,ge.jsxs)("g",{children:[(0,ge.jsx)("line",{x1:J.x,y1:J.y,x2:re.x,y2:re.y,stroke:"transparent",strokeWidth:20/c,className:H("cursor-pointer",{"cursor-ns-resize":ee,"cursor-ew-resize":!ee}),onMouseDown:Ve=>Y(de,Ve)}),(0,ge.jsx)("circle",{cx:Se.x,cy:Se.y,r:4/c,fill:xe?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ge.jsx)("circle",{cx:Se.x,cy:Se.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:xe?.6:.3,className:"pointer-events-none"})]},de)})})]})]}),(0,ge.jsxs)(Pe.EdgeLabelRenderer,{children:[(0,ge.jsx)("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${O.x}px, ${O.y}px)`},children:r&&!m&&(0,ge.jsx)(Bn,{sx:M,sy:V,tx:D,ty:A,hasLabel:!!((ie=n==null?void 0:n.label)!=null&&ie.trim()),children:(0,ge.jsx)(Gn,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:Q,targetNode:z})})}),(h||((W=n==null?void 0:n.label)==null?void 0:W.trim()))&&(0,ge.jsx)("div",{className:H("absolute nodrag nopan",!h&&!C&&((oe=n==null?void 0:n.label)!=null&&oe.trim())?"z-[10001] pointer-events-auto":"z-[3000] pointer-events-none"),style:{transform:`translate(-50%, -50%) translate(${O.x+((Z=(le=n==null?void 0:n.labelOffset)==null?void 0:le.x)!=null?Z:0)}px, ${O.y+((ye=(ve=n==null?void 0:n.labelOffset)==null?void 0:ve.y)!=null?ye:0)}px)`,cursor:!h&&!C&&((Ce=n==null?void 0:n.label)!=null&&Ce.trim())?"move":void 0},onMouseDown:!h&&!C?F:void 0,onDoubleClick:J=>{C||(J.stopPropagation(),x(!0))},children:(0,ge.jsx)(rt,{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":h,"pointer-events-none":!h}),isEditing:h,onBlur:()=>x(!1),onChange:J=>d(e,{label:J.trim()})})}),r&&!m&&!C&&(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsx)("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${k[0].x}px, ${k[0].y}px)`},children:(0,ge.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:P==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:P==="source"?.6:.3,className:"pointer-events-none"}),(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!P||P!=="source","cursor-not-allowed":P==="source"&&S&&!K,"cursor-grabbing":P==="source"&&(!S||K)}),onMouseDown:J=>j("source",J.nativeEvent)})]})}),(0,ge.jsx)("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${k[k.length-1].x}px, ${k[k.length-1].y}px)`},children:(0,ge.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:P==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:P==="target"?.6:.3,className:"pointer-events-none"}),(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!P||P!=="target","cursor-not-allowed":P==="target"&&S&&!K,"cursor-grabbing":P==="target"&&(!S||K)}),onMouseDown:J=>j("target",J.nativeEvent)})]})})]})]})]})};var no=require("@xyflow/react"),Eh={right:no.Position.Right,left:no.Position.Left,top:no.Position.Top,bottom:no.Position.Bottom},Qi=e=>{var t;return(t=Eh[e!=null?e:""])!=null?t:no.Position.Right},ia=(e,t,o=.5)=>{var l,c,d,p;let{x:n,y:r}=e.internals.positionAbsolute,i=(c=(l=e.measured)==null?void 0:l.width)!=null?c:0,a=(p=(d=e.measured)==null?void 0:d.height)!=null?p:0;switch(Qi(t)){case no.Position.Right:return{x:n+i,y:r+a*o};case no.Position.Left:return{x:n,y:r+a*o};case no.Position.Top:return{x:n+i*o,y:r};case no.Position.Bottom:return{x:n+i*o,y:r+a};default:return{x:n+i/2,y:r+a/2}}},Md=(e,t,o)=>{var d,p;let{position:{x:n,y:r},measured:i}=e,a=(d=i.width)!=null?d:0,s=(p=i.height)!=null?p:0;return[{id:"left",x:n,y:r+s/2},{id:"right",x:n+a,y:r+s/2},{id:"top",x:n+a/2,y:r},{id:"bottom",x:n+a/2,y:r+s}].reduce((f,m)=>{let y=Math.hypot(t-f.x,o-f.y);return Math.hypot(t-m.x,o-m.y)<y?m:f}).id};var Hu=require("use-debounce");var Vu=require("@xyflow/react"),xa=require("react");var Nr=(p=>(p.START_EVENT="start-event",p.END_EVENT_TERMINATE="end-event-terminate",p.TASK="task",p.TASK_SCRIPT="task-script",p.SUBPROCESS="subprocess-collapsed",p.GATEWAY_EXCLUSIVE="gateway-exclusive",p.GATEWAY_PARALLEL="gateway-parallel",p.GATEWAY_COMPLEX="gateway-complex",p.SERVICE_TASK="service-task",p.ANNOTATION="annotation",p.LANE="lane",p))(Nr||{});var wr=1,Pd=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,ia.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":f,"bg-white":e.length>0},n),style:o,onDoubleClick:g,children:(0,ia.jsx)("div",{ref:u,className:G("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":f}),contentEditable:f,suppressContentEditableWarning:!0,onKeyDown:h,onPaste:m,onInput:y,onBlur:v,children:e})})};var Eh=require("@xyflow/react");var ge=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,Xn=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),$i=(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 Xn(e,t);let s=Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*r)/i));return Xn(e,{x:t.x+s*n,y:t.y+s*r})},Dd=(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 Ar=require("@xyflow/react");var Ro={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15,MAX_LABEL_DISTANCE:80};var{TOLERANCE:ce}=Ro;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 Od(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 Ki(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 Vd(e){let t=Ki(Od([...e]));return t=Ih(t),Ki(Od(t))}function qi(e){switch(e){case Ar.Position.Left:return{x:-1,y:0};case Ar.Position.Right:return{x:1,y:0};case Ar.Position.Top:return{x:0,y:-1};case Ar.Position.Bottom:return{x:0,y:1};default:return{x:0,y:0}}}function Hd(e,t,o,n){let r=Ro.OFFSET,i=Ro.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*Ro.OFFSET&&(r=s/2,i=s/2)}else{let s=(o.y-e.y)*t.y;s>0&&s<2*Ro.OFFSET&&(r=s/2,i=s/2)}return{sourceOffset:r,targetOffset:i}}function Ah(e,t,o,n,r,i,s=0){let a=qi(r),l=qi(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},x={x:o+u,y:n+p},{sourceOffset:E,targetOffset:g}=Hd(f,a,x,l),h={x:f.x+a.x*E,y:f.y+a.y*E},m={x:x.x+l.x*g,y:x.y+l.y*g},y=wh(h,a,m,l),v=[f,h,...y,m,x],b=Vd(v);if(b.length===2&&Zi(f,x)>ce){let I=ge(f,h,"x",ce)&&ge(h,m,"x",ce)&&ge(m,x,"x",ce),T=ge(f,h,"y",ce)&&ge(h,m,"y",ce)&&ge(m,x,"y",ce);if(I||T){let N=T&&(m.x-h.x)*a.x<0,C=I&&(m.y-h.y)*a.y<0;if(!N&&!C)return Ki([f,h,m,x])}}return b}function Ji(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=qi(r),c=qi(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,x={x:e+d,y:t+u},E={x:o+p,y:n+f},{sourceOffset:g,targetOffset:h}=Hd(x,l,E,c),m={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},v=[...s],b=v[0],I=l.y===0;I&&Math.abs(x.y-b.y)>ce?v.unshift({x:b.x,y:x.y}):!I&&Math.abs(x.x-b.x)>ce&&v.unshift({x:x.x,y:b.y});let T=v[v.length-1],N=c.y===0,C=[];(Math.abs(T.x-y.x)>ce||Math.abs(T.y-y.y)>ce)&&(N?C.push({x:y.x,y:T.y}):C.push({x:T.x,y:y.y})),C.push(y);let M=[x,...v,...C,E],L=Vd(M);if(L.length===2&&Zi(x,E)>ce){let k=ge(x,m,"x",ce)&&ge(m,y,"x",ce)&&ge(y,E,"x",ce),O=ge(x,m,"y",ce)&&ge(m,y,"y",ce)&&ge(y,E,"y",ce);if(k||O){let V=O&&(y.x-m.x)*l.x<0,F=k&&(y.y-m.y)*l.y<0;if(!V&&!F)return Ki([x,m,y,E])}}return L}var Zi=(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=Zi(e,t),i=Zi(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},x={x:t.x+p.x*s,y:t.y+p.y*s},E=-u.x,g=-u.y,h=p.x,m=p.y,v=E*m-g*h>0?1:0;return`L${f.x} ${f.y}A${s} ${s} 0 0 ${v} ${x.x} ${x.y}`}var Gd=(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 Ie=require("react"),Qi=require("@xyflow/react");var Mh=50,Bd=.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,Qi.useReactFlow)(),{setIsDragging:d,setReconnectingEdgeId:u}=J(),p=(0,Qi.useStore)(P=>P.isValidConnection),[f,x]=(0,Ie.useState)(null),[E,g]=(0,Ie.useState)(null),[h,m]=(0,Ie.useState)(null),[y,v]=(0,Ie.useState)(null),[b,I]=(0,Ie.useState)(null),[T,N]=(0,Ie.useState)(!1),C=(0,Ie.useRef)(null),M=(0,Ie.useRef)(null),L=(0,Ie.useRef)(null),k=(0,Ie.useRef)(t),O=(0,Ie.useRef)(o);(0,Ie.useEffect)(()=>{k.current=t,O.current=o},[t,o]),(0,Ie.useEffect)(()=>{C.current=f},[f]),(0,Ie.useEffect)(()=>{M.current=b},[b]);let V=(0,Ie.useCallback)(P=>{let R=a(),S=R.find(H=>H.id===P);if(!S)return{x:0,y:0};let B=S.position.x,Y=S.position.y,D=S.parentId;for(;D;){let H=R.find(z=>z.id===D);if(!H)break;B+=H.position.x,Y+=H.position.y,D=H.parentId}return{x:B,y:Y}},[a]),F=(0,Ie.useCallback)(P=>{var D,H,z,X,Z,W;let R=a(),S=null,B=Mh,Y=R.filter(U=>U.type!=="LANE"&&U.type!=="ANNOTATION");for(let U of Y){if(U.id===e)continue;let Q=V(U.id),ee=(z=(H=(D=U.measured)==null?void 0:D.width)!=null?H:U.width)!=null?z:0,te=(W=(Z=(X=U.measured)==null?void 0:X.height)!=null?Z:U.height)!=null?W:0;if(P.x>=Q.x&&P.x<=Q.x+ee&&P.y>=Q.y&&P.y<=Q.y+te)return U.id;let fe=Math.max(Q.x-P.x,0,P.x-(Q.x+ee)),ae=Math.max(Q.y-P.y,0,P.y-(Q.y+te)),Me=Math.sqrt(fe*fe+ae*ae);Me<B&&(B=Me,S=U.id)}return S},[a,V,e]),j=(0,Ie.useCallback)((P,R)=>{var fe,ae,Me,Pe,lt,q;let S=s(P);if(!S)return null;let B=V(P),Y=(Me=(ae=(fe=S.measured)==null?void 0:fe.width)!=null?ae:S.width)!=null?Me:0,D=(q=(lt=(Pe=S.measured)==null?void 0:Pe.height)!=null?lt:S.height)!=null?q:0,H=Math.abs(B.x+Y-R.x),z=Math.abs(R.x-B.x),X=Math.abs(B.y+D-R.y),Z=Math.abs(R.y-B.y),W={right:H,left:z,bottom:X,top:Z},U=Object.entries(W).reduce((se,[oe,le])=>le<se[1]?[oe,le]:se,["right",W.right])[0],Q=L.current;if(Q&&Q!==U){let se=W[U],oe=W[Q],le=Math.abs(oe-se),we=Math.min(Math.abs(oe),Math.abs(se));le<we*Ph&&(U=Q)}let ee=U,te,Ee;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)<Bd&&(oe=.5),Ee=oe,te={x:ee==="right"?B.x+Y:B.x,y:B.y+Ee*D}}else{let oe=(Math.max(B.x,Math.min(B.x+Y,R.x))-B.x)/(Y||1);Math.abs(oe-.5)<Bd&&(oe=.5),Ee=oe,te={x:B.x+Ee*Y,y:ee==="bottom"?B.y+D:B.y}}return{side:ee,snapPosition:te,offset:Ee}},[s,V]),$=(0,Ie.useCallback)(P=>{var z,X,Z;let R=C.current;if(!R)return;let S=c({x:P.clientX,y:P.clientY}),B=F(S);m(B);let Y=S,D=null,H=null;if(B){let W=j(B,S);W&&(D=W.side,Y=W.snapPosition,H=W.offset,L.current=D);let U=l(e),Q={source:R==="source"?B:k.current,target:R==="target"?B:O.current,sourceHandle:R==="source"?D:(z=U==null?void 0:U.sourceHandle)!=null?z:null,targetHandle:R==="target"?D:(X=U==null?void 0:U.targetHandle)!=null?X:null},ee=(Z=p==null?void 0:p(Q))!=null?Z:!0;N(ee)}else L.current=null,N(!1);v(D),I(H),g(Y)},[F,j,l,e,c,p]),K=(0,Ie.useCallback)(P=>{var D,H,z,X,Z;let R=C.current;if(!R)return;let S=c({x:P.clientX,y:P.clientY}),B=F(S);if(B){let W=j(B,S),U=(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:R==="source"?B:k.current,target:R==="target"?B:O.current,sourceHandle:R==="source"?U:(z=ee==null?void 0:ee.sourceHandle)!=null?z:null,targetHandle:R==="target"?U:(X=ee==null?void 0:ee.targetHandle)!=null?X:null};((Z=p==null?void 0:p(te))==null||Z)&&i(Ee=>Ee.map(fe=>{var ae,Me;return fe.id===e?w(_({},fe),{source:te.source,target:te.target,sourceHandle:te.sourceHandle,targetHandle:te.targetHandle,data:w(_({},fe.data),{points:void 0,sourceOffset:R==="source"?Q:(ae=fe.data)==null?void 0:ae.sourceOffset,targetOffset:R==="target"?Q:(Me=fe.data)==null?void 0:Me.targetOffset})}):fe}))}x(null),g(null),m(null),v(null),I(null),d(!1),N(!1),u(null),L.current=null,document.removeEventListener("mouseup",K),document.removeEventListener("mousemove",$);let Y=oo.get(n);Y==null||Y.clearReconnectingEdge()},[e,F,j,l,i,n,$,p,c,d,u]),A=(0,Ie.useCallback)((P,R)=>{if(r||R.button!==0)return;R.stopPropagation(),R.preventDefault(),i(B=>B.map(Y=>Y.id===e?w(_({},Y),{data:w(_({},Y.data),{points:void 0})}):Y)),x(P),u(e);let S=oo.get(n);S==null||S.setReconnectingEdge(e),document.addEventListener("mousemove",$),document.addEventListener("mouseup",K)},[r,e,n,$,K,u,i]);return(0,Ie.useEffect)(()=>()=>{if(C.current){document.removeEventListener("mousemove",$),document.removeEventListener("mouseup",K),u(null);let P=oo.get(n);P==null||P.clearReconnectingEdge()}},[n,$,K,u]),{reconnectingHandle:f,cursorPosition:E,hoveredNodeId:h,reconnectingSide:y,reconnectingOffset:b,isValidReconnection:T,handleReconnectStart:A}};var me=require("react/jsx-runtime"),Rt={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:Le.MarkerType.ArrowClosed},markerEnd:{type:Le.MarkerType.Arrow},data:{label:""}},{MOVE_THRESHOLD:es,MIN_SEGMENT_LENGTH:Lh,PARALLEL_OFFSET:zd,MAX_LABEL_DISTANCE:kh}=Ro;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)*zd}let s=i.findIndex(l=>l.id===e),a=(i.length-1)/2;return(s-a)*zd}var sa=Xe.default.memo(({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:s,sourceHandleId:a,targetHandleId:l})=>{var U,Q,ee,te,Ee,fe,ae,Me,Pe,lt;let{zoom:c}=(0,Le.useViewport)(),{updateEdgeData:d}=(0,Le.useReactFlow)(),{isReadOnly:u,mode:p,instanceId:f,edgeHighlight:x}=J(),E=Zt(),g=(0,Le.useStore)((0,Xe.useCallback)(q=>q.edges,[])),h=(0,Le.useStore)((0,Xe.useCallback)(q=>{var se,oe;return((se=q.nodeLookup.get(t))==null?void 0:se.type)==="GATEWAY"||((oe=q.nodeLookup.get(o))==null?void 0:oe.type)==="GATEWAY"},[t,o])),m=(0,Xe.useMemo)(()=>Rh(e,t,o,g,h),[e,t,o,g,h]),[y,v]=(0,Xe.useState)(!1),[b,I]=(0,Xe.useState)(null),T=(0,Xe.useRef)(null),N=(0,Xe.useRef)(n==null?void 0:n.labelOffset),C=(0,Xe.useRef)(null),M=p!=="edit",{reconnectingHandle:L,cursorPosition:k,hoveredNodeId:O,reconnectingSide:V,isValidReconnection:F,handleReconnectStart:j}=ji({edgeId:e,source:t,target:o,instanceId:f,isReadOnly:M}),$=(0,Le.useInternalNode)(t),K=(0,Le.useInternalNode)(o),{sx:A,sy:P,tx:R,ty:S,sourcePos:B,targetPos:Y}=(0,Xe.useMemo)(()=>{var Ut,he;let q=$&&K?Ln($,K):{sx:0,sy:0,tx:0,ty:0,sourcePos:Le.Position.Right,targetPos:Le.Position.Left},se=a?i:q.sourcePos,oe=l?s:q.targetPos,le=(_e,be,Fe)=>{var vo,po,fo,Oa,Va,Ha;let{x:Oe,y:je}=_e.internals.positionAbsolute,Je=(fo=(po=(vo=_e.measured)==null?void 0:vo.width)!=null?po:_e.width)!=null?fo:0,ut=(Ha=(Va=(Oa=_e.measured)==null?void 0:Oa.height)!=null?Va:_e.height)!=null?Ha:0;switch(be){case Le.Position.Top:return{x:Oe+Je*Fe,y:je};case Le.Position.Bottom:return{x:Oe+Je*Fe,y:je+ut};case Le.Position.Left:return{x:Oe,y:je+ut*Fe};case Le.Position.Right:return{x:Oe+Je,y:je+ut*Fe};default:return{x:Oe+Je/2,y:je+ut/2}}},we=(Ut=n==null?void 0:n.sourceOffset)!=null?Ut:.5,Qe=(he=n==null?void 0:n.targetOffset)!=null?he:.5,Ze=$?le($,se,we).x:q.sx,dt=$?le($,se,we).y:q.sy,co=K?le(K,oe,Qe).x:q.tx,uo=K?le(K,oe,Qe).y:q.ty;return L==="source"&&k?(Ze=k.x,dt=k.y,V&&(se=V)):L==="target"&&k&&(co=k.x,uo=k.y,V&&(oe=V)),{sx:Ze,sy:dt,tx:co,ty:uo,sourcePos:se,targetPos:oe}},[$,K,a,l,i,s,L,k,V,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);(0,Xe.useEffect)(()=>{var oe;if(!C.current){C.current={sx:A,sy:P,tx:R,ty:S,sourcePos:B,targetPos:Y};return}let q=C.current;if(Math.abs(A-q.sx)>es||Math.abs(P-q.sy)>es||Math.abs(R-q.tx)>es||Math.abs(S-q.ty)>es||q.sourcePos!==B||q.targetPos!==Y){let le={};(oe=n==null?void 0:n.points)!=null&&oe.length&&(le.points=void 0),n!=null&&n.labelOffset&&(le.labelOffset=void 0),Object.keys(le).length>0&&d(e,_(_({},n),le))}C.current={sx:A,sy:P,tx:R,ty:S,sourcePos:B,targetPos:Y}},[A,P,R,S,B,Y,n,e,d,L]);let D=(0,Xe.useMemo)(()=>Ji(A,P,R,S,B,Y,n==null?void 0:n.points,m),[A,P,R,S,B,Y,n==null?void 0:n.points,m]),H=(0,Xe.useMemo)(()=>{if(D.length<2)return $i({x:A,y:P},{x:R,y:S});let q=0;for(let le=0;le<D.length-1;le++)q+=Xn(D[le],D[le+1]);let se=q/2,oe=0;for(let le=0;le<D.length-1;le++){let we=Xn(D[le],D[le+1]);if(oe+we>=se){let Qe=(se-oe)/we,Ze=D[le],dt=D[le+1];return{x:Ze.x+(dt.x-Ze.x)*Qe,y:Ze.y+(dt.y-Ze.y)*Qe}}oe+=we}return $i({x:A,y:P},{x:R,y:S})},[D,A,P,R,S]),z=(0,Xe.useCallback)((q,se)=>{if(p!=="edit"||se.button!==0)return;se.stopPropagation(),se.preventDefault();let oe=D[q],le=D[q+1],we=ge(oe,le,"y"),Qe=we?oe.y:oe.x,Ze=[...D],dt=Ze.length,co=q,uo=q+1;I(q);let Ut=_e=>{let be=Qe+(we?_e.clientY-se.clientY:_e.clientX-se.clientX)/c;T.current=we?{x:(oe.x+le.x)/2,y:be}:{x:be,y:(oe.y+le.y)/2};let Fe=[];for(let Oe=1;Oe<dt-1;Oe++){let je=Ze[Oe];Oe===co||Oe===uo?we?Fe.push({x:je.x,y:be}):Fe.push({x:be,y:je.y}):Fe.push(_({},je))}d(e,w(_({},n),{points:Fe}))},he=()=>{I(null),T.current=null,document.removeEventListener("mousemove",Ut),document.removeEventListener("mouseup",he)};document.addEventListener("mousemove",Ut),document.addEventListener("mouseup",he)},[p,D,c,n,e,d]),X=(0,Xe.useCallback)(q=>{var Ut,he,_e,be,Fe;if(y||M||q.button!==0||!((Ut=n==null?void 0:n.label)!=null&&Ut.trim()))return;q.stopPropagation(),q.preventDefault();let se=q.clientX,oe=q.clientY,le=(_e=(he=n==null?void 0:n.labelOffset)==null?void 0:he.x)!=null?_e:0,we=(Fe=(be=n==null?void 0:n.labelOffset)==null?void 0:be.y)!=null?Fe:0,Qe=[...D],Ze={x:H.x,y:H.y},dt=!1,co=Oe=>{let je=(Oe.clientX-se)/c,Je=(Oe.clientY-oe)/c;if(!dt&&Math.abs(je)<3&&Math.abs(Je)<3)return;dt=!0;let ut={x:le+je,y:we+Je};N.current=ut,d(e,w(_({},n),{labelOffset:ut}))},uo=()=>{document.removeEventListener("mousemove",co),document.removeEventListener("mouseup",uo);let Oe=N.current;if(!Oe)return;let je={x:Ze.x+Oe.x,y:Ze.y+Oe.y};Dd(je,Qe)>kh&&(N.current=void 0,d(e,w(_({},n),{labelOffset:void 0})))};document.addEventListener("mousemove",co),document.addEventListener("mouseup",uo)},[y,M,c,n,e,d,D,H]);if(!$||!K)return null;let Z=Gd(D),W=x&&(r||$.selected||K.selected);return(0,me.jsxs)(me.Fragment,{children:[(0,me.jsxs)("g",{className:G("group bpmn-arrow-edge",{"is-highlighted":W}),onDoubleClick:()=>!M&&v(!0),children:[(0,me.jsx)("path",{d:Z,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),className:G({"nopan nodrag":!y&&!M&&!!((U=n==null?void 0:n.label)!=null&&U.trim())}),style:{pointerEvents:"stroke",cursor:!y&&!M&&((Q=n==null?void 0:n.label)!=null&&Q.trim())?"move":"pointer"},onMouseDown:X}),(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)(Le.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&&!F,"stroke-green-500":L&&O&&F,"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((q,se)=>{let oe=D[se+1];if(se===0||se===D.length-2||Xn(q,oe)<Lh)return null;let le=ge(q,oe,"y"),we=b===se,Qe=we&&T.current?T.current:$i(q,oe);return(0,me.jsxs)("g",{children:[(0,me.jsx)("line",{x1:q.x,y1:q.y,x2:oe.x,y2:oe.y,stroke:"transparent",strokeWidth:20/c,className:G("cursor-pointer",{"cursor-ns-resize":le,"cursor-ew-resize":!le}),onMouseDown:Ze=>z(se,Ze)}),(0,me.jsx)("circle",{cx:Qe.x,cy:Qe.y,r:4/c,fill:we?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,me.jsx)("circle",{cx:Qe.x,cy:Qe.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:we?.6:.3,className:"pointer-events-none"})]},se)})})]})]}),(0,me.jsxs)(Le.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)(Fn,{sx:A,sy:P,tx:R,ty:S,hasLabel:!!((ee=n==null?void 0:n.label)!=null&&ee.trim()),children:(0,me.jsx)(Yn,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:$,targetNode:K})})}),(y||((te=n==null?void 0:n.label)==null?void 0:te.trim()))&&(0,me.jsx)("div",{className:G("absolute nodrag nopan",!y&&!M&&((Ee=n==null?void 0:n.label)!=null&&Ee.trim())?"z-[10001] pointer-events-auto":"z-[3000] pointer-events-none"),style:{transform:`translate(-50%, -50%) translate(${H.x+((ae=(fe=n==null?void 0:n.labelOffset)==null?void 0:fe.x)!=null?ae:0)}px, ${H.y+((Pe=(Me=n==null?void 0:n.labelOffset)==null?void 0:Me.y)!=null?Pe:0)}px)`,cursor:!y&&!M&&((lt=n==null?void 0:n.label)!=null&&lt.trim())?"move":void 0},onMouseDown:!y&&!M?X:void 0,onDoubleClick:q=>{M||(q.stopPropagation(),v(!0))},children:(0,me.jsx)(ct,{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:()=>v(!1),onChange:q=>d(e,{label:q.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&&!F,"cursor-grabbing":L==="source"&&(!O||F)}),onMouseDown:q=>j("source",q.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&&!F,"cursor-grabbing":L==="target"&&(!O||F)}),onMouseDown:q=>j("target",q.nativeEvent)})]})})]})]})]})});sa.displayName="SequenceEdge";var no=require("@xyflow/react"),Dh={right:no.Position.Right,left:no.Position.Left,top:no.Position.Top,bottom:no.Position.Bottom},ts=e=>{var t;return(t=Dh[e!=null?e:""])!=null?t:no.Position.Right},aa=(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(ts(t)){case no.Position.Right:return{x:n+i,y:r+s*o};case no.Position.Left:return{x:n,y:r+s*o};case no.Position.Top:return{x:n+i*o,y:r};case no.Position.Bottom:return{x:n+i*o,y:r+s};default:return{x:n+i/2,y:r+s/2}}},Yd=(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 x=Math.hypot(t-p.x,o-p.y);return Math.hypot(t-f.x,o-f.y)<x?f:p}).id};var Ku=require("use-debounce");var $u=require("@xyflow/react"),Ta=require("react");var Cr=(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))(Cr||{});var Sr=1,Fd=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>`,Ld=(e,t)=>{if(!e.length&&!t.length)return wr;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var ji=require("xml-js");var kd={compact:!0,spaces:4},_h=e=>e.replace(/\n/g,"&#xA;");function es(e,t=kd){if(e)return JSON.parse((0,ji.xml2json)(e,t))}function Rd(e,t=kd){return e?(0,ji.json2xml)(e,w(_({},t),{attributeValueFn:_h})):""}var Dd={"attribute-loop":"LOOP"},Od={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS","service-task":"SERVICE_TASK"},Vd={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Hd={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed",SERVICE_TASK:"service-task"},Gd={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var Fn=(e,t,o,n,r,i)=>{let a=e._attributes.width||0,s=e._attributes.height||0,l=0,c=0;if(n&&r!==void 0&&i!==void 0){let y=n.split(`
39
- `),E=y.length;l=y.reduce((g,h)=>Math.max(g,h.length),0)*7+r,c=E*20+i}let d=Math.max(Io(Number(a),t),l),p=Math.max(Io(Number(s),o),c);return{width:d,height:p,measured:{width:d,height:p}}},Wn=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,parent:r,value:i}=t,a={x:Number(o._attributes.x||0),y:Number(o._attributes.y||0)},s={id:n,position:a,data:{label:i||""}},l=r==="1"?void 0:r;return l&&(s.parentId=l),s},Th=e=>{let{mxGeometry:t}=e,o=Wn(e),n=Fn(t,ue.START_EVENT.MIN_WIDTH,ue.START_EVENT.MIN_HEIGHT);return w(_(_({},o),n),{type:"START_EVENT"})},vh=e=>{let{mxGeometry:t}=e,o=Wn(e),n=Fn(t,ue.END_EVENT.MIN_WIDTH,ue.END_EVENT.MIN_HEIGHT);return w(_(_({},o),n),{type:"END_EVENT"})},ts=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=Wn(e),s=Fn(n,ue.TASK.MIN_WIDTH,ue.TASK.MIN_HEIGHT,r.data.label,48,24),l=t==null?void 0:t.find(d=>{let{parent:p}=d._attributes;return p===e._attributes.id});if(l){let{style:d}=l._attributes,p=Dd[d];p&&(r.data.attribute=p)}let c=Od[o.style];return c&&(r.data.variant=c),w(_(_({},r),s),{type:"TASK"})},sa=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=Wn(e),i=Fn(o,ue.GATEWAY.MIN_WIDTH,ue.GATEWAY.MIN_HEIGHT);return r.data.variant=Vd[n],w(_(_({},r),i),{type:"GATEWAY"})},Nh=e=>{let{mxGeometry:t}=e,o=Wn(e),i=Fn(t,ue.ANNOTATION.MIN_WIDTH,ue.ANNOTATION.MIN_HEIGHT,o.data.label,32,24);return w(_(_({},o),i),{type:"ANNOTATION"})},wh=e=>{let{mxGeometry:t}=e,o=Wn(e),n=Fn(t,ue.LANE.MIN_WIDTH,ue.LANE.MIN_HEIGHT);return w(_(_({},o),n),{type:"LANE"})},Bd={task:ts,"task-script":ts,"subprocess-collapsed":ts,"service-task":ts,"start-event":Th,"end-event-terminate":vh,"gateway-parallel":sa,"gateway-exclusive":sa,"gateway-complex":sa,annotation:Nh,lane:wh},Ih=e=>{if(e&&Array.isArray(e))return e.map(t=>({x:Number(t._attributes.x),y:Number(t._attributes.y)}))},zd=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,source:r,target:i,value:a,style:s,sourceHandle:l,targetHandle:c,sourceOffset:d,targetOffset:p,labelOffsetX:f,labelOffsetY:m}=t,y=Ih(o==null?void 0:o.Array),E=d!==void 0?Number(d):void 0,u=p!==void 0?Number(p):void 0,g=f!==void 0?Number(f):void 0,h=m!==void 0?Number(m):void 0,x=w(_(_({id:n,source:r,target:i},l?{sourceHandle:l}:{}),c?{targetHandle:c}:{}),{data:_(_(_(_({label:a||""},y&&y.length>0?{points:y}:{}),E!==void 0?{sourceOffset:E}:{}),u!==void 0?{targetOffset:u}:{}),g!==void 0&&h!==void 0?{labelOffset:{x:g,y:h}}:{})});return s.includes("association")&&s.includes('endArrow=""')?_(_({},zn),x):_(_({},Dt),x)},Yd=(e,t)=>{var m,y;let{id:o,type:n,source:r,target:i,sourceHandle:a,targetHandle:s,data:l}=e,c=t==null?void 0:t.find(E=>E.id===r),d="";n==="ANNOTATION_EDGE"&&(d='association;endArrow=""');let p={_attributes:{as:"geometry",relative:"1"}};return l!=null&&l.points&&Array.isArray(l.points)&&l.points.length>0&&(p.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:a!=null?a:void 0,targetHandle:s!=null?s: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:((y=l==null?void 0:l.labelOffset)==null?void 0:y.y)!==void 0?String(l.labelOffset.y):void 0},mxGeometry:p}},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}}}},Ah=e=>{let{variant:t}=e.data,o=Xn(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:Hd[t]||"task"})})},Ch=e=>{let t=Xn(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"start-event"})})},Sh=e=>{let t=Xn(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"end-event-terminate"})})},Mh=e=>{let{variant:t}=e.data,o=Xn(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:Gd[t]})})},Ph=e=>{let t=Xn(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"lane"})})},Lh=e=>{let t=Xn(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"annotation"})})},Fd={TASK:Ah,START_EVENT:Ch,END_EVENT:Sh,GATEWAY:Mh,ANNOTATION:Lh,LANE:Ph},Wd=(e,t)=>{var a,s;let r=((a=e.measured)==null?void 0:a.width)||0,i=((s=e.measured)==null?void 0:s.height)||0;return{_attributes:{id:`${t+1}`,parent:e.id,style:"attribute-loop",connectable:"0"},mxGeometry:{_attributes:{as:"geometry",x:r/2-22/2,y:i-22,width:22,height:22}}}};var kh=e=>{let t=Object.values(Nr),o=e.filter(i=>{var s;let a=(s=i._attributes)==null?void 0:s.style;return t.includes(a)}),n=e.filter(i=>{var s;let a=(s=i._attributes)==null?void 0:s.style;return["attribute-loop"].includes(a)}),r=[];for(let i of o){let{style:a}=i._attributes,s=Bd[a],l=s==null?void 0:s(i,n);if(!l){console.warn(`Node ${a} not supported`);continue}r.push(l)}return r},Rh=(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=zd(r),a=t.find(c=>c.id===i.source),s=t.find(c=>c.id===i.target);((a==null?void 0:a.type)==="LANE"||(s==null?void 0:s.type)==="LANE")&&i.type!=="ANNOTATION_EDGE"||n.push(i)}return n},Dh=(e,t)=>{let o=[];return e.forEach(n=>{var a,s;let r=(s=(a=Fd)[n.type])==null?void 0:s.call(a,n);if(!r){console.warn(`Node ${n.type} not supported`);return}if(o.push(r),n.type==="TASK"&&n.data.attribute==="LOOP"){let l=Wd(n,t);o.push(l)}}),o},Oh=(e,t)=>{let o=[];return e.forEach(n=>{let r=Yd(n,t);o.push(r)}),o},Vh=(e=[],t=[],o)=>{let n=Dh(e,o),r=Oh(t,e);return{mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}}},Xd=(e=[],t=[],o)=>{let n=Vh(e,t,o);return Rd(JSON.stringify(n),{compact:!0,spaces:0})},Ud=async e=>{var a,s,l,c,d;let t=await es(e),o=((s=(a=t==null?void 0:t.mxGraphModel)==null?void 0:a.root)==null?void 0:s.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)||wr),r=kh(o),i=Rh(o,r);return{lastElementId:n,edges:i,nodes:r}};var ps=require("@xyflow/react"),Du=require("react");var _t=require("@xyflow/react"),ls=require("react");var Ir=require("@xyflow/react");var aa=require("react/jsx-runtime"),ne=i=>{var a=i,{type:e,position:t,className:o,nodeType:n}=a,r=qt(a,["type","position","className","nodeType"]);let s=n==="TASK";return(0,aa.jsx)(Ir.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":s,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":!s},o)},r))},at=s=>{var l=s,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,a=qt(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=(0,Ir.useReactFlow)(),f=(()=>{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 y=d();return m.filter(u=>{if(u.source!==e)return!1;let g=y.find(h=>h.id===u.target);return(g==null?void 0:g.type)!=="ANNOTATION"}).length>=1}return!1})();return(0,aa.jsx)(Ir.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":f,"hover:border-grey-500":!f},i),style:{pointerEvents:f?"none":"auto"}},a))};var da=require("react"),xo=require("@xyflow/react");var $d=require("@xyflow/react"),os=()=>{let e=(0,$d.useStoreApi)();return{getInternalNodes:()=>{let{nodeLookup:o}=e.getState();return Array.from(o.values())}}};var la=Mf(require("@dagrejs/dagre"),1),Ar=require("@xyflow/react");var ns=(e=[],t=[],o="LR")=>{let n=new la.default.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:i,width:a,height:s})=>n.setNode(i,{width:a,height:s})),t.forEach(i=>n.setEdge(i.source,i.target)),la.default.layout(n),{nodes:e.map(i=>{let a=n.node(i.id);return w(_({},i),{position:{x:a.x-i.width/2,y:a.y-i.height/2}})}),edges:t}},Vo=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId);if(t.length===0)return e;let o=qa(e);for(let n of t){let r=[...o.values()],i=r.filter(s=>s.parentId===n.id);if(i.length===0)continue;let a=i.filter(s=>s.type==="LANE");if(a.length>0){tl(a,o,r),ol(n,o);continue}Os(n,i,o)}return Za(e,o)};var qd=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)};var Hh=500;var Gh=e=>e.type==="LANE"&&!e.parentId,Bh=(e,t)=>{let o=e.x+e.width,n=e.y+e.height,r=t.x+t.width,i=t.y+t.height;return e.x<=t.x&&e.y<=t.y&&o>=r&&n>=i},zh=(e,t)=>{let o=e.x+e.width,n=e.y+e.height,r=t.x+t.width,i=t.y+t.height,a=Math.max(e.x-r,t.x-o,0),s=Math.max(e.y-i,t.y-n,0);return Math.hypot(a,s)},Yh=e=>{let t=new Set;for(let o of e)t.add(o.source),t.add(o.target);return t},Kd=(e,t,o)=>{if(e.type!=="ANNOTATION"||o.has(e.id))return!1;let n=(0,Ar.getNodesBounds)([e]);return zh(t,n)>Hh},ca=(e,t=[])=>{var E;let o=e.filter(Gh);if(o.length===0)return e;let n=new Map;for(let u of e){if(!u.parentId)continue;let g=(E=n.get(u.parentId))!=null?E:[];g.push(u.id),n.set(u.parentId,g)}let r=new Set,i=o.map(u=>u.id);for(;i.length>0;){let u=i.pop();if(!u||r.has(u))continue;r.add(u);let g=n.get(u);if(g)for(let h of g)r.has(h)||i.push(h)}let a=e.filter(u=>r.has(u.id));if(a.length===0)return e;let s=Yh(t),l=a.filter(u=>u.type!=="ANNOTATION"),c=(0,Ar.getNodesBounds)(l.length>0?l:a),d=a.filter(u=>!Kd(u,c,s)),p=(0,Ar.getNodesBounds)(d),y=e.filter(u=>!r.has(u.id)).filter(u=>{let g=(0,Ar.getNodesBounds)([u]);return!Bh(p,g)}).filter(u=>!Kd(u,p,s));return[...d,...y]};var rs=require("react/jsx-runtime"),ua=require("react"),Fh=["top","right","bottom","left"],Wh=["top-left","top-middle","top-right","right-middle","bottom-left","left-middle","bottom-right","bottom-middle"],Ot=r=>{var i=r,{nodeId:e,isVisible:t,offset:o=8}=i,n=qt(i,["nodeId","isVisible","offset"]);let{getInternalNode:a,setNodes:s}=(0,xo.useReactFlow)(),{getInternalNodes:l}=os(),{isMultipleSelection:c}=q(),d=(0,xo.useStoreApi)(),p=(0,da.useRef)(0),f=(0,da.useRef)([]),m=({y:g,width:h,height:x})=>{cancelAnimationFrame(p.current),p.current=requestAnimationFrame(()=>{var j,Q;if(!e)return;let{nodeLookup:T,onNodesChange:b}=d.getState(),N=T.get(e);if(!N||N.type!=="LANE")return;let v=!N.parentId,I=v?N.id:N.parentId;if(!I)return;let C=Array.from(T.values()).filter(z=>z.type==="LANE"&&z.parentId===I);if(!C.length)return;f.current.length===0&&(f.current=Jo(C).map(z=>z.id));let P=f.current.map(z=>C.find(M=>M.id===z)).filter(Boolean),R=[],S=0,L=P.findIndex(z=>z.id===N.id),K=!v&&L>0&&Math.abs(g-N.position.y)>.5;for(let z=0;z<P.length;z++){let M=P[z],V=M.id===N.id,D=z===P.length-1;if(V){S=K?g+x:S+x;continue}let A=(Q=(j=M.measured)==null?void 0:j.height)!=null?Q:0,B=v?h-ae.HEADER_WIDTH:h,G=A;v&&D&&(G=Math.max(ae.MIN_HEIGHT,x-S)),K&&z===L-1&&(G=Math.max(ae.MIN_HEIGHT,g-S)),R.push({id:M.id,type:"dimensions",dimensions:{width:B,height:G},setAttributes:!0}),R.push({id:M.id,type:"position",position:{x:ae.HEADER_WIDTH,y:S}}),S+=G}v?R.push({id:I,type:"dimensions",dimensions:{width:h,height:x},setAttributes:!0}):R.push({id:I,type:"dimensions",dimensions:{width:h+ae.HEADER_WIDTH,height:S},setAttributes:!0}),b==null||b(R)})},y=({y:g,width:h,height:x})=>{var N;if(cancelAnimationFrame(p.current),f.current=[],!e)return;let T=a(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:h,height:x,measured:{width:h,height:x}}):v),b=Vo(b),s(b);return}b=nl(T,h,x,b,g),b=Vo(b),b=Zo((N=T.parentId)!=null?N:T.id,b),s(b)};if(!(!c&&t))return null;let u={"--resize-offset":`${o}px`};return(0,rs.jsxs)(rs.Fragment,{children:[Fh.map(g=>(0,ua.createElement)(xo.NodeResizeControl,w(_({},n),{key:g,nodeId:e,position:g,variant:xo.ResizeControlVariant.Line,className:"border-blue-400/90 border-dashed",style:u,onResize:(h,x)=>m(x),onResizeEnd:(h,x)=>y(x)}))),Wh.map(g=>(0,ua.createElement)(xo.NodeResizeControl,w(_({},n),{key:g,nodeId:e,position:g,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:u,onResize:(h,x)=>m(x),onResizeEnd:(h,x)=>y(x)})))]})};var as=require("@xyflow/react"),ro=require("@produto-lecom/lecom-ui"),Et=require("react");var Zd=require("zustand"),Un=(0,Zd.create)(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));var is=require("react"),Jd=(e,t=!1)=>{let[o,n]=(0,is.useState)({width:0,height:0});return(0,is.useEffect)(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};var Ho=require("@xyflow/react"),Qd=require("react"),Xh=120,Uh=12,jd=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=(0,Ho.useReactFlow)(),{instanceId:i}=q();return(0,Qd.useMemo)(()=>{var m,y;if(!t)return{position:Ho.Position.Right,align:"start"};let a=n(e);if(!a)return{position:Ho.Position.Right,align:"start"};let s=r(),l=a.position.x*s.zoom+s.x,c=(((m=a.measured)==null?void 0:m.width)||a.width||100)*s.zoom,d=(y=document.getElementById(`modeler-${i}`))==null?void 0:y.clientWidth;if(!d)return{position:Ho.Position.Right,align:"start"};let p=(o==null?void 0:o.width)||Xh;return{position:l+c+p+Uh>d?Ho.Position.Left:Ho.Position.Right}},[i,e,t,o,n,r])};var pa=require("lucide-react");var ss=require("@xyflow/react"),be=require("@produto-lecom/lecom-ui"),eu=require("lucide-react");var Le=require("react/jsx-runtime"),tu=({nodeId:e})=>{let{t}=(0,be.useTranslation)(),{updateNodeData:o,getEdges:n,getNode:r}=(0,ss.useReactFlow)(),i=(0,ss.useNodesData)(e),s=n().filter(y=>y.source===e).some(y=>{let E=r(y.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=f=>{o(e,{variant:(i==null?void 0:i.data.variant)===f?"":f})},p=f=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===f?"":f})};return(0,Le.jsxs)(be.DropdownMenu,{children:[(0,Le.jsxs)(be.Tooltip,{children:[(0,Le.jsx)(be.TooltipTrigger,{asChild:!0,children:(0,Le.jsx)(be.DropdownMenuTrigger,{asChild:!0,children:(0,Le.jsx)(be.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:(0,Le.jsx)(eu.WrenchIcon,{})})})}),(0,Le.jsx)(be.TooltipContent,{color:"black",children:t("bpmn.task.menu.title")})]}),(0,Le.jsxs)(be.DropdownMenuContent,{align:"start",className:"w-60 bg-white text-grey-600",children:[(0,Le.jsxs)(be.DropdownMenuLabel,{className:"flex items-center gap-1",children:[(0,Le.jsx)("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),(0,Le.jsx)("div",{className:"flex items-center gap-1",children:Object.entries(ti).map(([f,m])=>{let y=f==="LOOP"&&(s||l||c),u=(()=>{if(f==="LOOP"&&s)return t("editor.task_menu.loop_not_allowed_when_connected_to_end");if(f==="LOOP"&&l)return t("editor.task_menu.loop_not_allowed_when_subprocess");if(f==="LOOP"&&c)return t("editor.task_menu.loop_not_allowed_when_service_task");if(f==="LOOP")return t("editor.task_menu.loop")})();return(0,Le.jsxs)(be.Tooltip,{children:[(0,Le.jsx)(be.TooltipTrigger,{asChild:!0,children:(0,Le.jsx)(be.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:y,className:H({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===f,"opacity-50 cursor-not-allowed":y}),onClick:y?void 0:()=>p(f),children:(0,Le.jsx)(m.icon,{className:"stroke-inherit"})})}),u&&(0,Le.jsx)(be.TooltipContent,{color:"black",children:u})]},f)})})]}),(0,Le.jsx)(be.DropdownMenuGroup,{children:(0,Le.jsxs)(be.Tooltip,{children:[(0,Le.jsx)(be.TooltipTrigger,{asChild:!0,children:(0,Le.jsx)("div",{className:H({"cursor-not-allowed":s}),children:(0,Le.jsxs)(be.DropdownMenuItem,{className:H({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":s}),disabled:s,onClick:()=>d("SCRIPT"),children:[(0,Le.jsx)(ei.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),s&&(0,Le.jsx)(be.TooltipContent,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};var Ge=require("react/jsx-runtime"),Eo={START_EVENT:{type:"START_EVENT",icon:or,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:En,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:or,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:Zr,label:"bpmn.annotation.variant.default"}},$h={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"}},ft=({nodeId:e,nodeType:t,nodeVariant:o,isChild:n})=>{let r=(0,Et.useRef)(null),i=(0,Et.useRef)(null),{t:a}=(0,ro.useTranslation)(),{setDraggableNode:s}=Un(),{getEdges:l,getNodes:c,getNode:d,setNodes:p}=(0,as.useReactFlow)(),{setIsDragging:f,mode:m,isConnecting:y,isDragging:E,isMultipleSelection:u}=q(),g=d(e),h=!!(g!=null&&g.selected)&&!g.dragging&&!y&&!E&&!u,{dimensions:x}=Jd(r,h),{position:T}=jd(e,h,x),[b,N]=(0,Et.useState)(void 0),v=c(),I=l(),C=o==="SUBPROCESS",P=o==="SERVICE_TASK",R=(0,Et.useRef)(null),S=(0,Et.useRef)(!1),L=(0,Et.useCallback)(()=>{R.current!==null&&(clearTimeout(R.current),R.current=null),S.current=!1,f(!1),s(null),N(void 0),p(F=>F.map(U=>w(_({},U),{className:void 0})))},[f,s,p]);(0,Et.useEffect)(()=>{let F=U=>{S.current&&U.buttons===0&&L()};return document.addEventListener("dragend",L),document.addEventListener("mousemove",F),()=>{document.removeEventListener("dragend",L),document.removeEventListener("mousemove",F)}},[L]);let K=(0,Et.useCallback)((F,U)=>{S.current=!0,f(!1),s({type:U.type,variant:U.variant,attribute:U.attribute,icon:U.icon}),U.icon&&N((0,Ge.jsx)(U.icon,{})),F.dataTransfer.effectAllowed="move",F.dataTransfer.setData("sourceId",e),i.current&&F.dataTransfer.setDragImage(i.current,10,10),R.current=setTimeout(()=>{R.current=null,f(!0)},100)},[e,s,f]),j=(0,Et.useCallback)(()=>{L()},[L]),Q=[{component:(0,Ge.jsx)(Fi,{elementId:e})}],z=()=>{if(m==="view")return[];let F=!I.some(U=>{var X;return U.source===e&&((X=v.find($=>$.id===U.target))==null?void 0:X.type)!=="ANNOTATION"});return[{component:(0,Ge.jsx)(Vn,{nodeId:e,disabled:!F,tooltipMessage:F?void 0:a("editor.toolbar.start_event_limit_reached")})},Eo.TASK,Eo.ANNOTATION,...Q]},M=()=>m==="view"?[{component:(0,Ge.jsx)(Do,{elementId:e})}]:[{component:(0,Ge.jsx)(Do,{elementId:e})},...C||P?[]:[{component:(0,Ge.jsx)(tu,{nodeId:e})}],{component:(0,Ge.jsx)(Vn,{nodeId:e})},Eo.TASK,{type:"TASK",variant:"SUBPROCESS",icon:nr,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:pa.Bot,label:"bpmn.task.variant.service_task"},Eo.ANNOTATION,...Object.values($h),...rn(e,v,I)?[]:[Eo.END_EVENT],...Q],V=()=>m==="view"?[{component:(0,Ge.jsx)(Do,{elementId:e,elementType:"gateway"})}]:[{component:(0,Ge.jsx)(Do,{elementId:e,elementType:"gateway"})},{component:(0,Ge.jsx)(Vn,{nodeId:e})},Eo.TASK,{type:"TASK",variant:"SUBPROCESS",icon:nr,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:pa.Bot,label:"bpmn.task.variant.service_task"},Eo.ANNOTATION,...Q],D=()=>m==="view"?[]:[Eo.ANNOTATION,...Q],A=()=>m==="view"?[]:[...n?[]:[{component:(0,Ge.jsx)(Vn,{nodeId:e})}],Eo.ANNOTATION,...Q],B=()=>m==="view"?[]:[{component:(0,Ge.jsx)(Vn,{nodeId:e})},...Q],G=()=>m==="view"?[]:[...Q],O=(F=>{switch(F){case"START_EVENT":return z();case"TASK":return M();case"GATEWAY":return V();case"END_EVENT":return D();case"LANE":return A();case"ANNOTATION":return B();case"UNSUPPORTED":return G();default:return[]}})(t),Y=O.length>6;if(!(O.length===0||m==="readonly"))return(0,Ge.jsxs)(as.NodeToolbar,{position:T,align:"start",className:Y?"-top-[4.5rem]":"-top-8",isVisible:h,children:[(0,Ge.jsx)("div",{ref:r,className:`${Y?"grid grid-cols-6":"flex"} gap-1 px-2 py-2 bg-white rounded-sm shadow-md`,children:O.map((F,U)=>{if(F.component)return(0,Ge.jsx)("div",{children:F.component},U);let X={sourceNodeType:t,targetNodeType:F.type,sourceNodeId:e,nodes:v,edges:I},$=ud(X),te={gateway_limit_reached:a("editor.toolbar.gateway_limit_reached"),start_event_limit_reached:a("editor.toolbar.start_event_limit_reached"),start_event_already_exists:a("editor.toolbar.start_event_already_exists"),script_to_end_not_allowed:a("editor.toolbar.script_to_end_not_allowed"),loop_to_end_not_allowed:a("editor.toolbar.loop_to_end_not_allowed"),initial_activity_to_end_not_allowed:a("editor.toolbar.initial_activity_to_end_not_allowed"),final_activity_cannot_connect:a("editor.toolbar.final_activity_cannot_connect"),activity_has_outgoing_connections:a("editor.toolbar.activity_has_outgoing_connections"),task_limit_reached:a("editor.toolbar.task_limit_reached"),start_event_to_service_task_not_allowed:a("editor.toolbar.start_event_to_service_task_not_allowed"),service_task_to_end_not_allowed:a("editor.toolbar.service_task_to_end_not_allowed")},ie=$.shouldDisable&&$.reason?te[$.reason]||a(F.label):a(F.label)||"";return(0,Ge.jsxs)(ro.Tooltip,{children:[(0,Ge.jsx)(ro.TooltipTrigger,{asChild:!0,children:(0,Ge.jsx)(ro.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!$.shouldDisable,disabled:$.shouldDisable,className:$.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:$.shouldDisable?void 0:W=>K(W,F),onDragEnd:$.shouldDisable?void 0:j,children:F.icon&&(0,Ge.jsx)(F.icon,{size:16})})}),(0,Ge.jsx)(ro.TooltipContent,{color:"black",children:ie})]},U)})}),(0,Ge.jsx)("div",{ref:i,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:b})]})};var Qe=require("react/jsx-runtime"),ou=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r,setNodes:i}=(0,_t.useReactFlow)(),{inProgress:a,fromNode:s}=(0,_t.useConnection)(),{mode:l,isReadOnly:c}=q(),d=a&&(s==null?void 0:s.id)!==e,p=(0,ls.useCallback)(y=>{let x=y.split(`
40
- `),T=x.reduce((I,C)=>Math.max(I,C.length),0),b=x.length,N=Math.max(Cn.MIN_WIDTH,T*7+32),v=Math.max(Cn.MIN_HEIGHT,b*20+24);i(I=>I.map(C=>C.id===e?w(_({},C),{width:N,height:v,style:w(_({},C.style),{width:N,height:v})}):C))},[e,i]),f=(0,ls.useCallback)(y=>{r(e,{label:y}),p(y)},[e,r,p]),m=(0,ls.useCallback)(y=>{p(y)},[p]);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)(rt,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:f,onInput:m,skipFirstCharValidation:!0}),(0,Qe.jsx)(ft,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&(0,Qe.jsx)(Ot,{nodeId:e,minWidth:Cn.MIN_WIDTH,minHeight:Cn.MIN_HEIGHT,isVisible:!n&&o}),!a&&(0,Qe.jsxs)(Qe.Fragment,{children:[(0,Qe.jsx)(ne,{type:"source",position:_t.Position.Left,id:"left"}),(0,Qe.jsx)(ne,{type:"source",position:_t.Position.Right,id:"right"}),(0,Qe.jsx)(ne,{type:"source",position:_t.Position.Top,id:"top"}),(0,Qe.jsx)(ne,{type:"source",position:_t.Position.Bottom,id:"bottom"})]}),(!a||d)&&(0,Qe.jsxs)(Qe.Fragment,{children:[(0,Qe.jsx)(ne,{type:"target",position:_t.Position.Left,id:"left",className:H({"annotation-handle":d})}),(0,Qe.jsx)(ne,{type:"target",position:_t.Position.Right,id:"right",className:H({"annotation-handle":d})}),(0,Qe.jsx)(ne,{type:"target",position:_t.Position.Top,id:"top",className:H({"annotation-handle":d})}),(0,Qe.jsx)(ne,{type:"target",position:_t.Position.Bottom,id:"bottom",className:H({"annotation-handle":d})})]})]})};var bt=require("@xyflow/react"),nu=require("react");var Ue=require("react/jsx-runtime"),ru=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=(0,bt.useReactFlow)(),{inProgress:i,fromNode:a}=(0,bt.useConnection)(),{mode:s,isReadOnly:l,reconnectingEdgeId:c}=q(),[d,p]=(0,nu.useState)(!1),f=i&&(a==null?void 0:a.id)!==e||!!c,m=u=>{r(e,{label:u})},y=()=>{p(!0)},E=()=>{p(!1)};return(0,Ue.jsxs)("div",{className:"relative",onDoubleClick:y,children:[(0,Ue.jsx)(En,{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,Ue.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,Ue.jsx)(rt,{value:t.label,isEditing:d,onBlur:E,onChange:m})}),(0,Ue.jsx)(ft,{nodeId:e,nodeType:"END_EVENT"}),s==="edit"&&(0,Ue.jsx)(Ot,{nodeId:e,isVisible:!n&&o,minWidth:ni.MIN_WIDTH,minHeight:ni.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||f)&&(0,Ue.jsxs)(Ue.Fragment,{children:[(0,Ue.jsx)(ne,{type:"target",position:bt.Position.Left,id:"left",className:H({"event-handle":f})}),(0,Ue.jsx)(ne,{type:"target",position:bt.Position.Right,id:"right",className:H({"event-handle":f})}),(0,Ue.jsx)(ne,{type:"target",position:bt.Position.Top,id:"top",className:H({"event-handle":f})}),(0,Ue.jsx)(ne,{type:"target",position:bt.Position.Bottom,id:"bottom",className:H({"event-handle":f})})]}),!i&&(0,Ue.jsxs)(Ue.Fragment,{children:[(0,Ue.jsx)(ne,{type:"source",position:bt.Position.Left,id:"left"}),(0,Ue.jsx)(ne,{type:"source",position:bt.Position.Right,id:"right"}),(0,Ue.jsx)(ne,{type:"source",position:bt.Position.Top,id:"top"}),(0,Ue.jsx)(ne,{type:"source",position:bt.Position.Bottom,id:"bottom"})]})]})};var Tt=require("@xyflow/react"),cs=require("react");var $e=require("react/jsx-runtime"),iu=({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let a=Rs[t.variant].icon,{updateNodeData:s}=(0,Tt.useReactFlow)(),{inProgress:l,fromNode:c}=(0,Tt.useConnection)(),{mode:d,isReadOnly:p,reconnectingEdgeId:f}=q(),[m,y]=(0,cs.useState)(!1),E=l&&(c==null?void 0:c.id)!==e||!!f,u=(0,cs.useCallback)(x=>{s(e,{label:x})},[e,s]),g=()=>{y(!0)},h=()=>{y(!1)};return(0,$e.jsxs)("div",{className:"relative",style:{width:o!=null?o:An.MIN_WIDTH,height:n!=null?n:An.MIN_HEIGHT},onDoubleClick:g,children:[(0,$e.jsx)(a,{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":p,"stroke-blue-500 hover:stroke-blue-600":r&&!p,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),(0,$e.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,$e.jsx)(rt,{value:t.label,isEditing:m,onBlur:h,onChange:u})}),(0,$e.jsx)(ft,{nodeId:e,nodeType:"GATEWAY",nodeVariant:t.variant}),d==="edit"&&(0,$e.jsx)(Ot,{nodeId:e,isVisible:!i&&r,minWidth:An.MIN_WIDTH,minHeight:An.MIN_HEIGHT,offset:2,keepAspectRatio:!0}),(!l||E)&&(0,$e.jsxs)($e.Fragment,{children:[(0,$e.jsx)(ne,{type:"target",position:Tt.Position.Left,id:"left",className:H({"gateway-handle":E})}),(0,$e.jsx)(ne,{type:"target",position:Tt.Position.Right,id:"right",className:H({"gateway-handle":E})}),(0,$e.jsx)(ne,{type:"target",position:Tt.Position.Top,id:"top",className:H({"gateway-handle":E})}),(0,$e.jsx)(ne,{type:"target",position:Tt.Position.Bottom,id:"bottom",className:H({"gateway-handle":E})})]}),!l&&(0,$e.jsxs)($e.Fragment,{children:[(0,$e.jsx)(at,{type:"source",position:Tt.Position.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,$e.jsx)(at,{type:"source",position:Tt.Position.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,$e.jsx)(at,{type:"source",position:Tt.Position.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,$e.jsx)(at,{type:"source",position:Tt.Position.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})};var su=require("@xyflow/react"),Ft=require("@produto-lecom/lecom-ui"),Kh=require("lucide-react");var au=require("react/jsx-runtime");var vt=require("@xyflow/react"),lu=require("react");var Ke=require("react/jsx-runtime"),cu=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=(0,vt.useReactFlow)(),{inProgress:i,fromNode:a}=(0,vt.useConnection)(),{mode:s,isReadOnly:l,reconnectingEdgeId:c}=q(),[d,p]=(0,lu.useState)(!1),f=i&&(a==null?void 0:a.id)!==e||!!c,m=u=>{r(e,{label:u})},y=()=>{p(!0)},E=()=>{p(!1)};return(0,Ke.jsxs)("div",{className:"relative",onDoubleClick:y,children:[(0,Ke.jsx)(jr,{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,Ke.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,Ke.jsx)(rt,{value:t.label,isEditing:d,onBlur:E,onChange:m})}),(0,Ke.jsx)(ft,{nodeId:e,nodeType:"START_EVENT"}),s==="edit"&&(0,Ke.jsx)(Ot,{nodeId:e,isVisible:!n&&o,minWidth:oi.MIN_WIDTH,minHeight:oi.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||f)&&(0,Ke.jsxs)(Ke.Fragment,{children:[(0,Ke.jsx)(ne,{type:"target",position:vt.Position.Left,id:"left",className:H({"event-handle":f})}),(0,Ke.jsx)(ne,{type:"target",position:vt.Position.Right,id:"right",className:H({"event-handle":f})}),(0,Ke.jsx)(ne,{type:"target",position:vt.Position.Top,id:"top",className:H({"event-handle":f})}),(0,Ke.jsx)(ne,{type:"target",position:vt.Position.Bottom,id:"bottom",className:H({"event-handle":f})})]}),!i&&(0,Ke.jsxs)(Ke.Fragment,{children:[(0,Ke.jsx)(at,{type:"source",position:vt.Position.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),(0,Ke.jsx)(at,{type:"source",position:vt.Position.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),(0,Ke.jsx)(at,{type:"source",position:vt.Position.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),(0,Ke.jsx)(at,{type:"source",position:vt.Position.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};var fu=require("@produto-lecom/lecom-ui"),Nt=require("@xyflow/react"),Pr=require("react");var Cr=60,ds=(e,t)=>{var a;let o=[],n=`${t} `;for(let s of e){if(!(s.type==="TASK"))continue;let c=(a=s.data)==null?void 0:a.label;if(c&&c.startsWith(n)){let d=c.substring(n.length);/^\d{1,15}$/.test(d)&&o.push(parseInt(d,10))}}let r=o.length>0?Math.max(...o)+1:1,i=`${t} ${r}`;return i.length<=Cr?i:i.substring(0,Cr).trim()},$n=(e,t)=>{var s;let o=new Set;for(let l of t)l.type==="TASK"&&((s=l.data)!=null&&s.label)&&o.add(l.data.label);let n=e;if(n.length>Cr&&(n=n.substring(0,Cr).trim()),!o.has(n))return n;let r=n.replace(/\s+\(\d+\)$/,""),i=2,a=o.size+2;for(;i<=a;){let l=` (${i})`,c=Cr-l.length,p=`${r.substring(0,c).trim()}${l}`;if(!o.has(p))return p;i++}return n};var Sr=require("react/jsx-runtime"),du=e=>(0,Sr.jsxs)("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[(0,Sr.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),(0,Sr.jsx)("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));var fa=require("react/jsx-runtime"),uu=e=>(0,fa.jsx)("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:(0,fa.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 Mr=require("react/jsx-runtime"),pu=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:"#EF4444"}),(0,Mr.jsx)("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));var me=require("react/jsx-runtime"),qh={APROVADO:du,EM_ANDAMENTO:uu,REJEITADO:pu},ma={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)]"},Zh={APROVADO:"bg-green-50",EM_ANDAMENTO:"bg-turquoise-50",REJEITADO:"bg-red-50"},mu=({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let{t:a}=(0,fu.useTranslation)(),{toast:s}=et(),{updateNodeData:l,getNodes:c,setNodes:d}=(0,Nt.useReactFlow)(),{inProgress:p,fromNode:f}=(0,Nt.useConnection)(),{mode:m,isReadOnly:y,onSubprocessValidationClick:E,reconnectingEdgeId:u}=q(),{getTaskStatus:g}=Qo(),h=p&&(f==null?void 0:f.id)!==e||!!u,x=g(e),T=t.variant==="SUBPROCESS",b=t.variant==="SERVICE_TASK",N=!!t.variant&&!T&&!b||!!x,v=!!t.attribute||T||b,I=(0,Pr.useCallback)(M=>{let B=N||v?80:40,G=M.split(`
41
- `),k=G.reduce((U,X)=>Math.max(U,X.length),0),O=G.length,Y=Math.max(So.MIN_WIDTH,k*7+64),F=Math.max(So.MIN_HEIGHT,O*24+B);d(U=>U.map(X=>X.id===e?w(_({},X),{width:Y,height:F,style:w(_({},X.style),{width:Y,height:F})}):X))},[e,d,N,v]),C=(0,Pr.useCallback)(M=>{let V=M.trim(),D=t.label||"";if(V===D)return;let A=V,B=c();if(!(V&&V!=="")){A=ds(B,a("bpmn.task.label.prefix")),l(e,{label:A}),I(A),s({variant:"warning",content:(0,me.jsxs)(me.Fragment,{children:[a("bpmn.task.feedback.label_empty.prefix")," ",(0,me.jsx)("strong",{children:A})]})});return}let k=$n(A,B);k===D||(l(e,{label:k}),I(k),k!==A&&s({variant:"warning",content:(0,me.jsxs)(me.Fragment,{children:[a("bpmn.task.feedback.label_already_exists.prefix")," ",(0,me.jsx)("strong",{children:V})," ",a("bpmn.task.feedback.label_already_exists.middle")," ",(0,me.jsx)("strong",{children:k})]})}))},[t.label,c,e,a,l,I,s]),P=(0,Pr.useCallback)(M=>{I(M)},[I]),R=(0,Pr.useCallback)(()=>{s({variant:"error",content:a("bpmn.task.feedback.invalid_first_character")})},[a,s]),S=x?qh[x]:null,L=t.variant?ei[t.variant].icon:null,K=t.attribute?ti[t.attribute].icon:null,j=()=>t.hasError?ma.error:x?ma[x]:y?ma.default:"",Q=()=>{var M;return r&&(M=Zh[x])!=null?M:""},z=()=>{E==null||E({id:e,type:"sub_process",label:t.label})};return(0,me.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",j(),{"cursor-pointer":y,"border-blue-500 hover:border-blue-600 shadow-md":r&&!y&&!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:So.MIN_WIDTH,height:n!=null?n:So.MIN_HEIGHT},children:[(0,me.jsx)("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:(0,me.jsx)(rt,{value:t.label,maxLength:60,className:H(Q(),{"py-10 px-8":N||v}),onChange:C,onInput:P,onInvalidFirstCharacter:R})}),L&&(0,me.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,me.jsx)(L,{size:b?20:16,className:H(t.hasError?"text-red-500":"text-grey-500",T&&"cursor-pointer"),onClick:T?z:void 0})}),K&&(0,me.jsx)("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:(0,me.jsx)("div",{className:H("flex items-center w-16 p-1",T||b?"justify-between":"justify-center"),children:(0,me.jsx)(K,{size:16,className:H(t.hasError?"text-red-500":"text-grey-500")})})}),S&&(0,me.jsx)("div",{className:"absolute top-0 right-0 flex items-center p-1",children:(0,me.jsx)(S,{})}),(0,me.jsx)(ft,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),m==="edit"&&(0,me.jsx)(Ot,{nodeId:e,isVisible:!i&&r,minWidth:So.MIN_WIDTH,minHeight:So.MIN_HEIGHT}),(!p||h)&&(0,me.jsxs)(me.Fragment,{children:[(0,me.jsx)(ne,{type:"target",position:Nt.Position.Left,id:"left",className:H({"task-handle":h})}),(0,me.jsx)(ne,{type:"target",position:Nt.Position.Right,id:"right",className:H({"task-handle":h})}),(0,me.jsx)(ne,{type:"target",position:Nt.Position.Top,id:"top",className:H({"task-handle":h})}),(0,me.jsx)(ne,{type:"target",position:Nt.Position.Bottom,id:"bottom",className:H({"task-handle":h})})]}),!p&&(0,me.jsxs)(me.Fragment,{children:[(0,me.jsx)(at,{type:"source",position:Nt.Position.Left,id:"left",nodeId:e,nodeType:"TASK"}),(0,me.jsx)(at,{type:"source",position:Nt.Position.Right,id:"right",nodeId:e,nodeType:"TASK"}),(0,me.jsx)(at,{type:"source",position:Nt.Position.Top,id:"top",nodeId:e,nodeType:"TASK"}),(0,me.jsx)(at,{type:"source",position:Nt.Position.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})};var ga=require("@xyflow/react");var _o=require("react/jsx-runtime"),gu=({id:e,data:t})=>(0,_o.jsxs)(_o.Fragment,{children:[(0,_o.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,_o.jsx)(ft,{nodeId:e,nodeType:"UNSUPPORTED"}),(0,_o.jsx)(ne,{type:"source",position:ga.Position.Right}),(0,_o.jsx)(ne,{type:"target",position:ga.Position.Left})]});var Ye=require("@xyflow/react"),us=require("react");var Ne=require("react/jsx-runtime"),YI={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:Ye.MarkerType.Arrow},data:{label:""}},hu=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var G;let{zoom:c}=(0,Ye.useViewport)(),{updateEdgeData:d}=(0,Ye.useReactFlow)(),{isMultipleSelection:p,mode:f,instanceId:m}=q(),y=f!=="edit",[E,u]=(0,us.useState)(!1),{reconnectingHandle:g,cursorPosition:h,hoveredNodeId:x,reconnectingSide:T,isValidReconnection:b,handleReconnectStart:N}=Zi({edgeId:e,source:t,target:o,instanceId:m,isReadOnly:y}),v=(0,Ye.useInternalNode)(t),I=(0,Ye.useInternalNode)(o),{sx:C,sy:P,tx:R,ty:S,sourcePos:L,targetPos:K}=(0,us.useMemo)(()=>{var oe,le;if(!v||!I)return{sx:0,sy:0,tx:0,ty:0,sourcePos:Ye.Position.Left,targetPos:Ye.Position.Right};let k=Mn(v,I),O=s?i:k.sourcePos,Y=l?a:k.targetPos,F=(Z,ve,ye)=>{var ee,xe,Se,Ve,ot,St;let{x:Ce,y:J}=Z.internals.positionAbsolute,de=(Se=(xe=(ee=Z.measured)==null?void 0:ee.width)!=null?xe:Z.width)!=null?Se:0,re=(St=(ot=(Ve=Z.measured)==null?void 0:Ve.height)!=null?ot:Z.height)!=null?St:0;switch(ve){case Ye.Position.Top:return{x:Ce+de*ye,y:J};case Ye.Position.Bottom:return{x:Ce+de*ye,y:J+re};case Ye.Position.Left:return{x:Ce,y:J+re*ye};case Ye.Position.Right:return{x:Ce+de,y:J+re*ye};default:return{x:Ce+de/2,y:J+re/2}}},U=(oe=n==null?void 0:n.sourceOffset)!=null?oe:.5,X=(le=n==null?void 0:n.targetOffset)!=null?le:.5,$=v?F(v,O,U).x:k.sx,te=v?F(v,O,U).y:k.sy,ie=I?F(I,Y,X).x:k.tx,W=I?F(I,Y,X).y:k.ty;return g==="source"&&h?($=h.x,te=h.y,T&&(O=T)):g==="target"&&h&&(ie=h.x,W=h.y,T&&(Y=T)),{sx:$,sy:te,tx:ie,ty:W,sourcePos:O,targetPos:Y}},[v,I,s,l,i,a,g,h,T,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!v||!I)return null;let[j,Q,z]=(0,Ye.getSmoothStepPath)({sourceX:C,sourceY:P,targetX:R,targetY:S,sourcePosition:L,targetPosition:K}),M=r||(v==null?void 0:v.selected)||(I==null?void 0:I.selected),V=M?"sequence-edge-marker-highlighted":"sequence-edge-marker",D=E||(n==null?void 0:n.label.trim().length)>0,A=()=>{u(!1)},B=k=>{d(e,{label:k.trim()})};return(0,Ne.jsx)(Ne.Fragment,{children:(0,Ne.jsxs)("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":M}),onDoubleClick:()=>!y&&u(!0),children:[(0,Ne.jsx)("path",{d:j,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),(0,Ne.jsxs)("g",{className:H("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":M}),children:[(0,Ne.jsx)(Ye.BaseEdge,{id:e,path:j,interactionWidth:0,markerEnd:`url(#${V})`,strokeDasharray:4,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||g&&x&&!b,"stroke-green-500":g&&x&&b,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":M&&!(n!=null&&n.hasError)&&!g})}),(0,Ne.jsxs)(Ye.EdgeLabelRenderer,{children:[(0,Ne.jsxs)("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${Q}px, ${z}px)`},children:[r&&!p&&(0,Ne.jsx)(Bn,{sx:C,sy:P,tx:R,ty:S,hasLabel:!!((G=n==null?void 0:n.label)!=null&&G.trim()),children:(0,Ne.jsx)(Gn,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),D&&(0,Ne.jsx)(rt,{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:A,onChange:B})]}),r&&!p&&!y&&(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${C}px, ${P}px)`},children:(0,Ne.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:g==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:g==="source"?.6:.3,className:"pointer-events-none"}),(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!g||g!=="source","cursor-not-allowed":g==="source"&&x&&!b,"cursor-grabbing":g==="source"&&(!x||b)}),onMouseDown:k=>N("source",k.nativeEvent)})]})}),(0,Ne.jsx)("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${R}px, ${S}px)`},children:(0,Ne.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:g==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:g==="target"?.6:.3,className:"pointer-events-none"}),(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!g||g!=="target","cursor-not-allowed":g==="target"&&x&&!b,"cursor-grabbing":g==="target"&&(!x||b)}),onMouseDown:k=>N("target",k.nativeEvent)})]})})]})]})]})]})})};var dn=require("@xyflow/react"),Lr=require("react/jsx-runtime"),yu=({toX:e,toY:t,fromNode:o})=>{var p,f;if(!o)return null;let{internals:{positionAbsolute:{x:n,y:r}},measured:i}=o,a=(p=i.width)!=null?p:0,s=(f=i.height)!=null?f:0,c=[{x:n,y:r+s/2,pos:dn.Position.Left},{x:n+a,y:r+s/2,pos:dn.Position.Right},{x:n+a/2,y:r,pos:dn.Position.Top},{x:n+a/2,y:r+s,pos:dn.Position.Bottom}].reduce((m,y)=>{let E=Math.hypot(e-m.x,t-m.y);return Math.hypot(e-y.x,t-y.y)<E?y:m}),[d]=(0,dn.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 wt=require("@xyflow/react"),xu=require("lodash"),kr=require("react");var Oe=require("react/jsx-runtime"),Eu=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{var v;let{updateNodeData:i,getNodes:a}=(0,wt.useReactFlow)(),{mode:s,isReadOnly:l}=q(),{inProgress:c,fromNode:d}=(0,wt.useConnection)(),p=c&&(d==null?void 0:d.id)!==e,[f,m]=(0,kr.useState)(!1),y=a(),E=!r,u=!E&&((v=y.find(I=>I.id===r))==null?void 0:v.selected),g=(0,kr.useMemo)(()=>(0,xu.orderBy)([...y.filter(I=>I.parentId===e&&I.type==="LANE")],"position.y","asc"),[y,e]),h=E?Xa.MIN_WIDTH:ae.MIN_WIDTH,x=(0,kr.useMemo)(()=>{if(E&&g.length>1){let I=[...g];return I.pop(),I.reduce((P,R)=>{var S,L;return P+((L=(S=R.measured)==null?void 0:S.height)!=null?L:0)},0)+ae.MIN_HEIGHT}return ae.MIN_HEIGHT},[E,g]),T=I=>{i(e,{label:I})},b=()=>{m(!0)},N=()=>{m(!1)};return(0,Oe.jsxs)(Oe.Fragment,{children:[(0,Oe.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||u)&&!l}),children:[(0,Oe.jsx)("div",{className:H("flex align-items justify-center w-10 border-r-2 border-grey-400",{"border-blue-500":(o||u)&&!l}),onDoubleClick:b,children:(0,Oe.jsx)("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:(0,Oe.jsx)(rt,{value:t.label,className:"w-full h-full self-auto",contentClassName:H({"whitespace-nowrap":f}),isEditing:f,onBlur:N,onChange:T})})}),(0,Oe.jsx)("div",{className:"flex-1"})]}),(0,Oe.jsx)(ft,{nodeId:e,nodeType:"LANE",isChild:!E}),s==="edit"&&(0,Oe.jsx)(Ot,{nodeId:e,isVisible:!n&&o,minWidth:h,minHeight:x,offset:10}),!c&&(0,Oe.jsxs)(Oe.Fragment,{children:[(0,Oe.jsx)(ne,{type:"source",position:wt.Position.Left,id:"left"}),(0,Oe.jsx)(ne,{type:"source",position:wt.Position.Right,id:"right"}),(0,Oe.jsx)(ne,{type:"source",position:wt.Position.Top,id:"top"}),(0,Oe.jsx)(ne,{type:"source",position:wt.Position.Bottom,id:"bottom"})]}),(!c||p)&&(0,Oe.jsxs)(Oe.Fragment,{children:[(0,Oe.jsx)(ne,{type:"target",position:wt.Position.Left,id:"left",className:H({"annotation-handle":p})}),(0,Oe.jsx)(ne,{type:"target",position:wt.Position.Right,id:"right",className:H({"annotation-handle":p})}),(0,Oe.jsx)(ne,{type:"target",position:wt.Position.Top,id:"top",className:H({"annotation-handle":p})}),(0,Oe.jsx)(ne,{type:"target",position:wt.Position.Bottom,id:"bottom",className:H({"annotation-handle":p})})]})]})};var _u={START_EVENT:cu,END_EVENT:ru,TASK:mu,GATEWAY:iu,ANNOTATION:ou,LANE:Eu,UNSUPPORTED:gu},bu={SEQUENCE_EDGE:Sd,MESSAGE_EDGE:hu,ANNOTATION_EDGE:_d},Tu="#fafafa",vu="#bebebe",Nu=1,wu=10,Iu="bottom-left",ha=.05,Au=5,Cu=150,Su=100,Mu=ha,Pu=1,Lu={x:0,y:0,zoom:.75},ku=1,Ru=2,Jh={[ku]:4,[Ru]:2},Rr=[ku,Ru],ya=Rr.reduce((e,t)=>e|Jh[t],0);var Go=()=>{let{setViewport:e}=(0,ps.useReactFlow)(),t=(0,ps.useStoreApi)();return{fitToNodes:(0,Du.useCallback)(n=>{let{width:r,height:i}=t.getState();if(i<=0||r<=0)return;let a=ja(n);if(!a)return;let s=el({bounds:a,canvasHeight:i,canvasWidth:r,minZoom:Mu,maxZoom:Pu,offsetX:Cu,offsetY:Su});e(s)},[t,e])}};var Ou=require("@xyflow/react");var Vt=()=>{let{getEdges:e,getNodes:t}=(0,Ou.useReactFlow)(),{lastElementId:o}=q(),n=()=>{let i=t(),a=e(),s=Ld(i,a);return Math.max(s,o)};return{getLastId:n,getNextId:()=>n()+1}};var Bo=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n}=(0,Vu.useReactFlow)(),{getLastId:r}=Vt(),{fitToNodes:i}=Go(),{setLastElementId:a}=q(),s=(0,xa.useCallback)(async(c="")=>{let{nodes:d,edges:p,lastElementId:f}=await Ud(c);i(d),o(d),n(p),a(f)},[o,n,a,i]),l=(0,xa.useCallback)(()=>{let c=e(),d=t(),p=r();return Xd(c,d,p)},[e,t,r]);return{importFromMxGraph:s,exportToMxGraph:l}};var Ea=require("react"),Qh=500,fs=()=>{let{isInitialized:e,onElementChanges:t}=q(),{exportToMxGraph:o}=Bo(),n=(0,Hu.useDebouncedCallback)(()=>{if(!e)return;let a=o();t==null||t(a)},Qh),r=(0,Ea.useCallback)(a=>{a.every(c=>c.type==="select")||a.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=(0,Ea.useCallback)(a=>{a.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var Gu=({setEdges:e,saveHistory:t})=>{let{getNode:o,getEdges:n,getNodes:r,getInternalNode:i}=(0,ms.useReactFlow)(),{emitElementChanges:a}=fs(),s=(0,io.useRef)(null),{getNextId:l}=Vt(),c=(0,io.useCallback)(u=>{var b;let g=o(u.source),h=o(u.target);if(!g||!h)return!1;let x={sourceNodeId:g.id,targetNodeId:h.id,sourceNodeType:g.type,targetNodeType:h.type,nodes:r(),edges:n(),reconnectingEdgeId:(b=s.current)!=null?b:void 0};return ta(x).isValid},[o,n,r]),d=(0,io.useCallback)(u=>{var x,T;let g=l(),h=i(u.source);if(h){let b=i(u.target),N=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,I=Md(h,N,v),C=(b==null?void 0:b.type)==="ANNOTATION"||(h==null?void 0:h.type)==="ANNOTATION",P=C?zn:Dt,R;if(!C&&b&&u.targetHandle){let K=Qi(I),j=Qi(u.targetHandle),{x:Q,y:z}=ia(h,I),{x:M,y:V}=ia(b,u.targetHandle),A=Ki(Q,z,M,V,K,j).slice(1,-1);A.length>0&&(R=A)}let S=w(_(_({},u),P),{id:String(g),sourceHandle:I,data:_(_({},C?{}:Dt.data),R?{points:R}:{})}),L=n().concat(S);e(L),t("forceSave",{nodes:r(),edges:L}),a()}},[l,e,a,i,n,r,t]),p=(0,io.useCallback)((u,g)=>{s.current=g.id},[]),f=(0,io.useCallback)(()=>{s.current=null},[]),m=(0,io.useCallback)((u,g)=>{let h=o(g.source),x=o(g.target);if(!h||!x){s.current=null;return}let T={sourceNodeId:h.id,targetNodeId:x.id,sourceNodeType:h.type,targetNodeType:x.type,nodes:r(),edges:n(),reconnectingEdgeId:u.id};if(!ta(T).isValid){s.current=null;return}let N=(0,ms.reconnectEdge)(u,g,n()).map(v=>v.id===u.id?w(_({},v),{data:w(_({},v.data),{points:void 0})}):v);e(N),t("forceSave",{nodes:r(),edges:N}),s.current=null,a()},[o,r,n,e,a,t]),y=(0,io.useCallback)(u=>{s.current=u},[]),E=(0,io.useCallback)(()=>{s.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:m,onReconnectStart:p,onReconnectEnd:f,setReconnectingEdge:y,clearReconnectingEdge:E}};var Ku=require("@produto-lecom/lecom-ui"),qu=require("@xyflow/react"),Wt=require("react");var Dr=(e=[])=>e.filter(t=>t.type==="START_EVENT"),un=(e=[])=>e.filter(t=>t.type==="END_EVENT"),zo=(e=[])=>e.filter(t=>t.type==="TASK")||[],Bu=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"});var gs=(e=[])=>e.filter(t=>t.type==="GATEWAY"),zu=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),It=(e,t=[])=>t.filter(o=>o.source===e),Or=(e,t=[])=>t.filter(o=>o.target===e),Yu=(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"},Fu=(e,t)=>{let o=It(e,t.edges||[]);for(let n of o){let r=(t.nodes||[]).find(i=>i.id===n.target);if(r&&r.type==="END_EVENT")return!0}return!1},Wu=e=>e?/[^\s]/.test(e.trim()):!1,we=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:[]}},bo=(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)}},Xu=(e=[],t=[])=>({nodes:e.map(o=>{var n;return{id:o.id,type:o.type||"",label:typeof((n=o.data)==null?void 0:n.label)=="string"?o.data.label:void 0,properties:o.data}}),edges:t.map(o=>({id:o.id,source:o.source,target:o.target,type:o.type||"default"}))});var Vr=[{id:"start_event_not_found",validate:e=>{let t=Dr(e.nodes);return we({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=un(e.nodes);return we({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 we({isValid:!0});if(!o)return we({isValid:!1,nodeIds:t.map(i=>i.id)});let n=It(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(a=>a.id),...n.map(a=>a.target)];return we({isValid:!1,nodeIds:[...new Set(i)]})}return we({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=zo(e.nodes),o=bo(t,n=>It(n.id,e.edges).length<=2);return we({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=zo(e.nodes),o=bo(t,n=>!!n.label&&n.label.trim()!=="");return we({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=zo(e.nodes),n=bo(o,r=>!r.label||r.label.length<=60);return we({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=zo(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 we({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=gs(e.nodes),o=[],n=[];for(let r of t){let i=It(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="GATEWAY"&&(o.push(r.id,s.id),n.push(a.id))}}return we({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Dr(e.nodes),...un(e.nodes)],o=[],n=[];for(let r of t){let i=It(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&(s.type==="START_EVENT"||s.type==="END_EVENT")&&(o.push(r.id,s.id),n.push(a.id))}}return we({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=un(e.nodes),o=[],n=[];for(let r of t){let i=Or(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.source);if(s&&s.type==="TASK"){let l=It(s.id,e.edges);l.length>1&&(o.push(s.id),l.forEach(c=>n.push(c.id)))}}}return we({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=zu(e.nodes),o=bo(t,r=>It(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>It(r,e.edges).map(i=>i.id));return we({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=zo(e.nodes),o=bo(t,n=>!n.label||Wu(n.label));return we({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var a,s;if(!((a=e==null?void 0:e.nodes)!=null&&a.length)||!((s=e==null?void 0:e.edges)!=null&&s.length))return we({isValid:!0});let t=un(e.nodes)[0];if(!t)return we({isValid:!0});let o=Or(t.id,e.edges);if(!o.length)return we({isValid:!0});let r=zo(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=bo(r,l=>!Yu(l.id,e));return we({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=zo(e.nodes),o=un(e.nodes)[0];if(!o)return we({isValid:!0});let n=t.filter(l=>{let c=Or(l.id,e.edges),d=It(l.id,e.edges),p=c.some(m=>{var y;return((y=e.nodes.find(E=>E.id===m.source))==null?void 0:y.type)==="START_EVENT"}),f=d.some(m=>{var y;return((y=e.nodes.find(E=>E.id===m.target))==null?void 0:y.type)==="END_EVENT"});return p&&f}),r=Or(o.id,e.edges),i=r.length>1,a=r.map(l=>l.source),s={isValid:n.length===0&&!i,nodeIds:[...n.map(l=>l.id),...i?a:[]]};return we(s)}},{id:"gateway_flow_to_event",validate:e=>{let t=gs(e.nodes),o=[],n=[];for(let r of t){let i=It(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="END_EVENT"&&(o.push(r.id,s.id),n.push(a.id))}}return we({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=gs(e.nodes),o=bo(t,n=>It(n.id,e.edges).length>=1);return we({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Dr(e.nodes),...un(e.nodes)],o=[],n=[];for(let r of t){let i=It(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="GATEWAY"&&(o.push(r.id,s.id),n.push(a.id))}}return we({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=Bu(e.nodes),o=bo(t,n=>!Fu(n.id,e));return we({isValid:o.isValid,nodeIds:o.invalidIds})}}];var Uu=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}},$u=async(e,t)=>{var n;let o=[];try{let r=await e(),i=(n=r==null?void 0:r.filter(a=>a.area==="DIAGRAM"))!=null?n:[];return i.length===0?{isValid:!0,errors:[]}:(i.forEach(a=>{var l,c;let s=(c=(l=a==null?void 0:a.detail)==null?void 0:l.phases)==null?void 0:c.map(d=>d.diagramCellId);o.push({id:a.code,message:a.code,nodeIds:s,edgeIds:[]})}),{isValid:!1,errors:o})}catch(r){let i=[],a=(s,l)=>{let c=t.filter(d=>{var p;return((p=d.data)==null?void 0:p.variant)===s}).map(d=>d.id);c.length>0&&i.push({id:l,message:l,nodeIds:c,edgeIds:[]})};return a("SUBPROCESS","cannot_validate_subprocess_reference"),a("SERVICE_TASK","service_task_automation_status_unavailable"),{isValid:!1,errors:i}}};var pn=require("react/jsx-runtime"),Zu=()=>{let{t:e}=(0,Ku.useTranslation)(),{toast:t}=et(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=(0,qu.useReactFlow)(),{validateCustomDiagram:a}=q(),[s,l]=(0,Wt.useState)(!1),c=(0,Wt.useRef)(!1),d=(0,Wt.useRef)(!1),p=(0,Wt.useCallback)(async u=>{let g=Xu(u.nodes,u.edges),h=Uu(g),x=u.nodes.filter(({type:b,data:N})=>b==="TASK"&&((N==null?void 0:N.variant)==="SUBPROCESS"||(N==null?void 0:N.variant)==="SERVICE_TASK"));if(a&&x.length>0){let b=await $u(a,x);h={isValid:h.isValid&&b.isValid,errors:[...h.errors,...b.errors]}}let T=h.errors.map(b=>w(_({},b),{message:e(`validation.errors.${b.id}`)}));return s||l(!0),{isValid:h.isValid,errors:T}},[s,e,a]),f=(0,Wt.useCallback)((u,g=!0)=>{if(g&&u&&t({variant:u.isValid?"success":"error",duration:5e3,title:u.isValid?e("validation.success.title"):e("validation.errors.title"),content:(0,pn.jsxs)("div",{className:"flex flex-col gap-1",children:[!u.isValid&&(0,pn.jsx)("span",{className:"body-small-500",children:e("validation.errors.subtitle")}),(0,pn.jsx)("ul",{className:"list-disc list-inside max-h-40 overflow-y-auto",children:u.isValid?(0,pn.jsx)("li",{children:e("validation.success.message")}):u.errors.map(S=>(0,pn.jsx)("li",{className:"text-xs",children:S.message},S.id))})]})}),!u)return;c.current=!0,d.current=!0;let h=[],x=[];u.errors.forEach(S=>{S.nodeIds&&S.nodeIds.length>0&&S.nodeIds.forEach(L=>h.push(L)),S.edgeIds&&S.edgeIds.length>0&&S.edgeIds.forEach(L=>x.push(L))});let T=[...new Set(h)];o(S=>S.map(L=>w(_({},L),{data:w(_({},L.data),{hasError:!1})}))),n(S=>S.map(L=>w(_({},L),{data:w(_({},L.data),{hasError:!1})})));let b=r(),N=i(),v=new Set(T),I=new Set;u.errors.forEach(S=>{var j,Q;let L=Vr.find(z=>z.id===S.id);(L==null?void 0:L.highlightRelatedEdges)!==!1&&((j=S.edgeIds)==null||j.forEach(z=>I.add(z)),(Q=S.nodeIds)==null||Q.forEach(z=>{N.forEach(M=>{(M.source===z||M.target===z)&&I.add(M.id)})}))});let C=new Set,P=new Set,R=new Set;b.forEach(S=>{S.type==="START_EVENT"?C.add(S.id):S.type==="END_EVENT"&&P.add(S.id)}),N.forEach(S=>{C.has(S.source)&&R.add(S.target),P.has(S.target)&&R.add(S.source)}),R.forEach(S=>{var L,K;if(v.has(S)){let j=(L=u.errors.find(z=>{var M;return(M=z.nodeIds)==null?void 0:M.includes(S)}))==null?void 0:L.id;((K=Vr.find(z=>z.id===j))==null?void 0:K.highlightRelatedEdges)!==!1&&N.forEach(z=>{z.source===S&&P.has(z.target)&&(v.add(z.target),I.add(z.id)),z.target===S&&C.has(z.source)&&(v.add(z.source),I.add(z.id))})}}),v.size>0&&o(S=>S.map(L=>w(_({},L),{data:w(_({},L.data),{hasError:v.has(L.id)})}))),I.size>0&&n(S=>S.map(L=>w(_({},L),{data:w(_({},L.data),{hasError:I.has(L.id)})}))),setTimeout(()=>{c.current=!1},0)},[e,i,r,n,o,t]),m=(0,Wt.useCallback)(()=>{l(!1),d.current=!1,o(u=>u.map(g=>w(_({},g),{data:w(_({},g.data),{hasError:!1})}))),n(u=>u.map(g=>w(_({},g),{data:w(_({},g.data),{hasError:!1})})))},[n,o]),y=(0,Wt.useCallback)(()=>{d.current&&(c.current=!0,d.current=!1,o(u=>u.map(g=>w(_({},g),{data:w(_({},g.data),{hasError:!1})}))),n(u=>u.map(g=>w(_({},g),{data:w(_({},g.data),{hasError:!1})}))),setTimeout(()=>{c.current=!1},0))},[n,o]),E=(0,Wt.useCallback)(()=>c.current,[]);return{validateDiagram:p,handleValidationComplete:f,clearValidation:m,dismissValidationPanel:y,isAutoValidationEnabled:s,getIsClearingValidation:E}};var ju=require("@xyflow/react"),ep=require("@produto-lecom/lecom-ui"),tp=require("react");var jh=15,Ju="bpmn:selection",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},Qu=e=>{if(!ey(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},op=({offset:e=jh,saveHistory:t})=>{let{t:o}=(0,ep.useTranslation)(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=(0,ju.useReactFlow)(),{getNextId:s}=Vt(),{mode:l,containerRef:c}=q();(0,tp.useEffect)(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let p=m=>{var b,N;if(!Qu(m)||!d.contains(document.activeElement))return;let E=n(),u=i(),g=E.filter(v=>v.selected);if(!g.length)return;m.preventDefault(),m.stopPropagation();let h=u.filter(v=>g.some(I=>I.id===v.source)&&g.some(I=>I.id===v.target)),T=JSON.stringify({nodes:g,edges:h});(b=m.clipboardData)==null||b.setData(Ju,T),(N=m.clipboardData)==null||N.setData("text/plain",`BPMN Selection: ${g.length} nodes`)},f=m=>{var R,S;if(!Qu(m)||!d.contains(document.activeElement))return;let E=(R=m.clipboardData)==null?void 0:R.getData(Ju);if(!E)return;m.preventDefault(),m.stopPropagation();let u;try{u=JSON.parse(E)}catch(L){return}if(!((S=u.nodes)!=null&&S.length))return;let g=new Map,h=n(),x=[],T=u.nodes.filter(L=>Ro(L.type,h));if(T.length===0)return;let b=s(),N=T.map(L=>{var Q;let K=String(b++);g.set(L.id,K);let j=w(_({},L),{id:K,selected:!0,position:{x:L.position.x+e,y:L.position.y+e}});if(L.type==="TASK"){let z=(Q=L.data)==null?void 0:Q.label,M=$n(z||o("bpmn.task.label.prefix"),[...h,...x]);j.data=w(_({},L.data),{label:M})}return x.push(j),j}),v=u.edges.map(L=>w(_({},L),{id:String(b++),selected:!0,source:g.get(L.source)||L.source,target:g.get(L.target)||L.target})),I=[...h.map(L=>w(_({},L),{selected:!1})),...N],P=[...i().map(L=>w(_({},L),{selected:!1})),...v];r(I),a(P),t("forceSave",{nodes:I,edges:P})};return d.addEventListener("copy",p,!0),d.addEventListener("paste",f,!0),()=>{d.removeEventListener("copy",p,!0),d.removeEventListener("paste",f,!0)}},[n,r,i,a,s,e,o,t,l,c])};var np=require("@produto-lecom/lecom-ui"),rp=require("@xyflow/react");var ip=require("react");var ty=50,sp=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let{draggableNode:r,setDraggableNode:i}=Un(),{t:a}=(0,np.useTranslation)(),{getInternalNode:s,getNodes:l,getEdges:c,screenToFlowPosition:d}=(0,rp.useReactFlow)(),{getNextId:p}=Vt(),{setIsDragging:f}=q(),{getInternalNodes:m}=os(),{rebuildIndex:y,forceRebuildIndex:E}=Oi(),[u,g]=(0,ip.useState)(null),h=(M,V,D)=>{var k;if(M.parentId!==V)return null;let A=D.filter(O=>O.id!==M.id&&O.parentId===V&&O.type==="LANE").sort((O,Y)=>O.position.y-Y.position.y);if(A.length===0)return null;let B=(k=D.find(O=>O.id===M.id))!=null?k:M,G=A.find(O=>B.position.y<O.position.y);return G?{draggedLaneId:M.id,beforeLaneId:G.id}:{draggedLaneId:M.id,afterLaneId:A[A.length-1].id}},x=(M,V=!1,D)=>{let A=V?"node-drop-target-error":"node-drop-target",B=V?"node-drop-target-lane-error":"node-drop-target-lane";t(G=>{var O;let k=(O=D==null?void 0:D(G))!=null?O:null;return G.map(Y=>{let F=[];return Y.id===M&&F.push(A),M!==void 0&&Y.parentId===M&&Y.type==="LANE"&&Y.id!==(k==null?void 0:k.draggedLaneId)&&F.push(B),Y.id===(k==null?void 0:k.draggedLaneId)&&F.push("lane-reorder-dragging"),Y.id===(k==null?void 0:k.beforeLaneId)&&F.push("lane-reorder-before"),Y.id===(k==null?void 0:k.afterLaneId)&&F.push("lane-reorder-after"),w(_({},Y),{className:F.join(" ")})})})},T=(M,V)=>{let D=m();if(M.type==="LANE"){if(V){x();return}let O=D.filter(U=>U.id!==M.id&&U.type==="LANE"&&!U.parentId),Y=ir(M,O);if(!Y){x();return}if(qo({parentId:Y.id,nodes:e,excludeTypes:["LANE"]})){x(Y.id,!0);return}x(Y.id,!1,U=>h(M,Y.id,U));return}let B=D.filter(O=>O.id!==M.id&&O.type==="LANE"),G=ir(M,B);if(!G){x();return}if(qo({parentId:G.id,nodes:e,includeTypes:["LANE"]})){x();return}x(G.id)},b=M=>{let V=s(M.id),D=M.type==="LANE"&&qo({parentId:M.id,nodes:e,includeTypes:["LANE"]});T(V,D)},N=M=>M.map(V=>w(_({},V),{className:void 0})),v=M=>M.some(D=>D.dragging)?M.map(D=>D.dragging?w(_({},D),{dragging:!1}):D):M,I=(M,V)=>{let D=0;for(let A of V){if(A.id===M||A.parentId||A.type==="LANE")continue;let B=Lt(A),G=B.y+B.h;D=Math.max(D,G)}return D+ty},C=(M,V)=>{if(!Ds(M,V))return V;let D=I(M,V);return V.map(A=>A.id===M?w(_({},A),{position:w(_({},A.position),{y:D})}):A)},P=M=>{if(M.preventDefault(),M.dataTransfer.dropEffect="move",!(r!=null&&r.type))return;let V=d({x:M.clientX,y:M.clientY}),D={id:"__sidebar_drag__",type:r.type,position:V,measured:{width:1,height:1},internals:{positionAbsolute:V}};T(D,!1)},R=M=>{let V=M.relatedTarget;(!V||!M.currentTarget.contains(V))&&x()},S=(M,V)=>{M.preventDefault(),b(V)},L=(M,V,D)=>{var F,U;let A=[...D],B=V.parentId?V.parentId:V.id;if(M.parentId===V.id)return A=Vs(M,V,A),A=Vo(A),A=Zo(B,A),N(A);if(M.type==="LANE"){if(qo({parentId:V.id,nodes:A,excludeTypes:["LANE"]})){let W=ki(V),oe=50,le=50;return A.map(Z=>{var ve,ye;return Z.id===M.id?w(_({},Z),{position:{x:(ve=u==null?void 0:u.x)!=null?ve:W.x+oe,y:(ye=u==null?void 0:u.y)!=null?ye:W.y2+le}}):Z})}let te=A.filter(W=>W.parentId===V.id).reduce((W,oe)=>{var le,Z;return W+((Z=(le=oe.measured)==null?void 0:le.height)!=null?Z:0)},0),ie={x:ae.HEADER_WIDTH,y:te};return A=A.map(W=>W.id===M.id?w(_({},W),{parentId:V.id,position:ie,className:void 0}):w(_({},W),{className:void 0})),A=Vo(A),A=C(B,A),A}if(qo({parentId:V.id,nodes:A,includeTypes:["LANE"]})){let X;if(M.parentId){let $=s(M.parentId),{x:te,y:ie}=Lt($);X={x:te+((F=M.position.x)!=null?F:0),y:ie+((U=M.position.y)!=null?U:0)}}return A=A.map($=>$.id===M.id?w(_({},$),{position:X!=null?X:$.position,parentId:void 0,className:void 0}):w(_({},$),{className:void 0})),A=Zo(B,A),A}let O=Ja(M,V);A=A.map(X=>X.id===M.id?w(_({},X),{parentId:V.id,position:O,className:void 0}):w(_({},X),{className:void 0}));let Y=A.find(X=>X.id===M.id);return A=Vs(Y,V,A),A=Vo(A),A=Zo(B,A),A},K=M=>{if(M.preventDefault(),!(r!=null&&r.type))return;if(!Ro(r.type,l())){f(!1),i(null);return}let V=d({x:M.clientX,y:M.clientY}),D={width:ue[r.type].MIN_WIDTH,height:ue[r.type].MIN_HEIGHT},A=p(),B={id:String(A),type:r.type,position:V,measured:D,data:{label:r.type==="TASK"?ds(e,a("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},G=w(_({},B),{internals:{positionAbsolute:V}}),k=w(_({},G),{measured:{width:1,height:1}}),O=m(),Y=r.type==="LANE",F=O.filter(W=>Y?W.type==="LANE"&&!W.parentId:W.type==="LANE"),U=ir(k,F),X=[...O.map(W=>w(_({},W),{selected:!1})),G];U&&(X=L(G,U,X)),X=rr(X),Y&&!U&&(X=C(G.id,X)),X=N(X),t(X),E();let $=M.dataTransfer.getData("sourceId"),te=c(),ie=te;if($){let W={id:String(A+1),source:$,target:B.id},oe=r.type==="ANNOTATION"?_(_({},W),zn):_(_({},W),Dt);ie=te.concat(oe),o(ie)}n("forceSave",{nodes:X,edges:ie}),f(!1),i(null)},j=async(M,V,D)=>{let A=[...m()],B=new Set;D.forEach(O=>{let Y=s(O.id),F=O.type==="LANE",U=A.filter($=>$.id!==O.id&&(F?$.type==="LANE"&&!$.parentId:$.type==="LANE")),X=ir(Y,U);if(X){if(F&&qo({parentId:O.id,nodes:A,includeTypes:["LANE"]})){O.parentId&&(A=z(O,A),B.add(O.id));return}A=L(Y,X,A);return}O.parentId&&(A=z(O,A),O.type==="LANE"&&B.add(O.id))}),A=v(A);let G=D.filter(O=>O.type==="LANE"&&!O.parentId).map(O=>O.id);for(let O of G)Ds(O,A)&&u&&(A=A.map(Y=>Y.id===O?w(_({},Y),{position:_({},u)}):Y));for(let O of B)A=C(O,A);if(D.some(O=>O.type!=="LANE"&&!O.parentId)){let O=A.filter(Y=>Y.type==="LANE"&&!Y.parentId).map(Y=>Y.id);for(let Y of O)A=Zo(Y,A)}A=rr(A),A=N(A),t(A),y(A),g(null)},Q=(M,V)=>{g({x:V.position.x,y:V.position.y})},z=(M,V)=>{var U,X,$,te,ie,W,oe,le;let D=s(M.parentId);if(!D)return V;let A=M.type==="LANE",B=V.filter(Z=>Z.parentId===D.id&&Z.id!==M.id),G=B.filter(Z=>Z.type==="LANE"),k;if(A&&G.length===0)k=ae.MIN_HEIGHT;else if(A){let Z=(X=(U=M.measured)==null?void 0:U.height)!=null?X:ae.MIN_HEIGHT;k=((te=($=D.measured)==null?void 0:$.height)!=null?te:ae.MIN_HEIGHT)-Z,k=Math.max(ae.MIN_HEIGHT,k)}else k=B.length>0?B.reduce((Z,ve)=>{var ye,Ce;return Z+((Ce=(ye=ve.measured)==null?void 0:ye.height)!=null?Ce:0)},0)+ze:Math.max(ae.MIN_HEIGHT,(W=(ie=D.measured)==null?void 0:ie.height)!=null?W:0);let{x:O,y:Y}=Lt(D),F={x:O+((oe=M.position.x)!=null?oe:0),y:Y+((le=M.position.y)!=null?le:0)};return V=V.map(Z=>Z.id===M.id?w(_({},Z),{position:F,parentId:void 0}):Z.id===D.id?w(_({},Z),{height:k,measured:w(_({},Z.measured),{height:k})}):Z),V=Vo(V),V};return{onDragOver:P,onDragLeave:R,onDrop:K,onNodeDrag:S,onNodeDragStart:Q,onNodeDragStop:j}};var ap=require("@xyflow/react"),lp=require("@produto-lecom/lecom-ui"),cp=require("react");var oy=30,ny=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},ry=e=>!ny(e.target),dp=({offset:e=oy,saveHistory:t})=>{let{t:o}=(0,lp.useTranslation)(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=(0,ap.useReactFlow)(),{getNextId:s}=Vt(),{mode:l,containerRef:c}=q();(0,cp.useEffect)(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let p=f=>{if(d.contains(document.activeElement)&&f.ctrlKey&&f.key.toLowerCase()==="d"&&ry(f)){f.preventDefault(),f.stopPropagation();let y=n(),E=i(),u=y.filter(P=>P.selected);if(!u.length)return;let g=new Map,h=[],x=u.filter(P=>Ro(P.type,y));if(x.length===0)return;let T=E.filter(P=>x.some(R=>R.id===P.source)&&x.some(R=>R.id===P.target)),b=s(),N=x.map(P=>{var L;let R=String(b++);g.set(P.id,R);let S=w(_({},P),{id:R,selected:!0,position:{x:P.position.x+e,y:P.position.y+e}});if(P.type==="TASK"){let K=(L=P.data)==null?void 0:L.label,j=$n(K||o("bpmn.task.label.prefix"),[...y,...h]);S.data=w(_({},P.data),{label:j})}return h.push(S),S}),v=T.map(P=>w(_({},P),{id:String(b++),selected:!0,source:g.get(P.source)||P.source,target:g.get(P.target)||P.target})),I=[...y.map(P=>w(_({},P),{selected:!1})),...N],C=[...E.map(P=>w(_({},P),{selected:!1})),...v];r(I),a(C),t("forceSave",{nodes:I,edges:C})}};return d.addEventListener("keydown",p,!0),()=>{d.removeEventListener("keydown",p,!0)}},[n,r,i,a,s,e,o,t,l,c])};var Gr=require("react"),up=require("@xyflow/react");var iy=20,sy=50,Hr={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},ay=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},pp=e=>{let{getNodes:t}=(0,up.useReactFlow)(),{mode:o,isMoveTool:n}=q(),r=(0,Gr.useRef)(0),i=(0,Gr.useRef)(new Map);(0,Gr.useEffect)(()=>{let a=s=>{if(o!=="edit"||!n||ay(s.target)||!Object.values(Hr).includes(s.key))return;let p=t().filter(h=>h.selected);if(p.length===0){i.current.clear();return}s.preventDefault();let f=Date.now(),m=f-r.current<500;r.current=f;let y=s.shiftKey?sy:iy,E=0,u=0;switch(s.key){case Hr.UP:u=-y;break;case Hr.DOWN:u=y;break;case Hr.LEFT:E=-y;break;case Hr.RIGHT:E=y;break}let g=p.map(h=>{let x=i.current.get(h.id);(!m||!x)&&(x={x:h.position.x,y:h.position.y});let T={x:x.x+E,y:x.y+u};return i.current.set(h.id,T),{id:h.id,dragging:!0,type:"position",position:T}});e&&e(g)};return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[t,e,o,n])};var yp=require("@xyflow/react");var mp={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY","gateway-parallel":"GATEWAY","gateway-complex":"GATEWAY"},gp={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},fp=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],n=e.match(/(\[.*?\])/)||[],r=e.match(/(\{.*?\})/)||[],i=e.match(/(--.*|\|.*?\|)/i)||[],a="",s="",l="";if(o.length){switch(o[1]){case"<start>":a="start-event";break;case"<end>":a="end-event";break}e=e.replace(o[1],"")}return n.length&&(a="task",s=n[1].replace(/\[|\]/g,""),e=e.replace(n[1],"")),r.length&&(s=r[1].replace(/\{|\}/g,""),s.charAt(0)==="+"?(a="gateway-parallel",s=s.slice(1)):s.charAt(0)==="*"?(a="gateway-complex",s=s.slice(1)):a="gateway-exclusive",e=e.replace(r[1],"")),a||(a="task",s=e),i.length&&(l=i[1].replace(/(\||--)/g,""),e=e.replace(i[1],"")),e=e.trim(),t[e]||(t[e]={type:a,label:s}),{step:e,type:a,label:s,edgeLabel:l}},ly=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 a=fp(i[0],o),s=fp(i[1],o);a&&s&&n.push({sourceId:a.step,targetId:s.step,label:a.edgeLabel||s.edgeLabel||""})}),{components:o,connections:n}},hp=e=>{let{components:t,connections:o}=ly(e);return{nodes:t,edges:o}};var cy=7,dy=48,uy=340,py=(e,t)=>{let o=dy+e.length*cy;return Math.min(uy,Math.max(t,o))},hs=()=>{let{setNodes:e,setEdges:t}=(0,yp.useReactFlow)(),{fitToNodes:o}=Go(),{getNextId:n}=Vt();return{importFromLia:i=>{let a=typeof i=="string"?i:i.diagramXml||"",{nodes:s,edges:l}=hp(a),c=[],d=new Map,p=!1,f=n();for(let[h,x]of Object.entries(s)){let T=String(f++),b=mp[x.type],N=gp[x.type];b==="START_EVENT"&&(p=!0),d.set(h,T);let v=ue[b].MIN_WIDTH,I=ue[b].MIN_HEIGHT;c.push({id:T,type:b,data:{label:x.label||"",variant:N,attribute:""},position:{x:0,y:0},width:v,height:I,measured:{width:v,height:I}})}let m=[];for(let h of l){let x=w(_({},Dt),{id:String(f++),source:d.get(h.sourceId)||h.sourceId,target:d.get(h.targetId)||h.targetId});m.push(x)}if(!p&&c.length>0){let h=String(f++),x={id:h,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:ue.START_EVENT.MIN_WIDTH,height:ue.START_EVENT.MIN_HEIGHT,measured:{width:ue.START_EVENT.MIN_WIDTH,height:ue.START_EVENT.MIN_HEIGHT}};c.unshift(x);let T=c[1];if(T){let b=w(_({},Dt),{id:String(f++),source:h,target:T.id});m.unshift(b)}}let y=c.map(h=>{var x,T;return h.type==="TASK"?w(_({},h),{width:py(String((T=(x=h.data)==null?void 0:x.label)!=null?T:""),ue.TASK.MIN_WIDTH)}):h}),{nodes:E}=ns(y,m),u=new Map(E.map(h=>[h.id,h.position])),g=c.map(h=>{var x;return w(_({},h),{position:(x=u.get(h.id))!=null?x:h.position})});e(g),t(m),o(g)}}};var ys=require("react"),fy={origin:"*",debug:!1};function xs(e,t=fy){let{origin:o,debug:n}=t,r=(0,ys.useCallback)((i,a)=>{let s={event:i,data:a};window.parent.postMessage(s,o||"*")},[o]);return(0,ys.useEffect)(()=>{if(!e)return;let i=a=>{let s=a.data;if(!(s!=null&&s.event)||(s==null?void 0:s.data)===void 0)return;let{event:l,data:c}=s,d;if(Array.isArray(c)){let[,p]=c;d=p.data}else d=c;n&&(console.debug("[postMessage] received:",s),console.debug("[postMessage] eventData:",d)),l&&e[l]&&e[l](d)};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[e,n]),{sendMessage:r}}var xp=require("@xyflow/react"),To=require("react");var Ep=()=>{let e=(0,xp.useNodesInitialized)(),{initialDiagram:t,isNewDiagram:o,setIsInitialized:n,onElementChanges:r}=q(),{importFromMxGraph:i,exportToMxGraph:a}=Bo(),{sendMessage:s}=xs(),l=(0,To.useRef)(t),c=(0,To.useRef)(r),d=(0,To.useRef)(a);(0,To.useEffect)(()=>{c.current=r},[r]),(0,To.useEffect)(()=>{d.current=a},[a]),(0,To.useEffect)(()=>{t&&(i(t),l.current=t)},[t,i]),(0,To.useEffect)(()=>{if(!e)return;(async()=>{var f;if(await Jr(),n(!0),s("INIT_MODELER",l.current),!o){let m=d.current();(f=c.current)==null||f.call(c,m)}})()},[e,o,n,s])};var _p=require("@xyflow/react"),_a=require("react");function bp(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=Qo(),{getEdges:n}=(0,_p.useReactFlow)(),r=(0,_a.useCallback)(a=>{if(!(a!=null&&a.activities))return;e(a.activities);let s=a.activities.map(c=>c.diagramId),l=n();o(l,s)},[e,o,n]),i=(0,_a.useCallback)(()=>{t()},[t]);return{handleTasksStatus:r,handleClearTaskStatus:i}}var vp=require("@xyflow/react"),lt=require("react"),Np=require("use-debounce");var gy=500,Tp=100,wp=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=(0,vp.useReactFlow)(),{mode:i,containerRef:a}=q(),[s,l]=(0,lt.useState)({history:[],currentStep:0}),{history:c,currentStep:d}=s,p=d>0,f=d<c.length-1,m=(0,lt.useCallback)((v,I)=>{n(v[I].nodes),r(v[I].edges)},[n,r]),y=(0,lt.useCallback)(()=>{if(d>0){let v=d-1;l(I=>w(_({},I),{currentStep:v})),m(c,v)}},[d,c,m]),E=(0,lt.useCallback)(()=>{if(d<c.length-1){let v=d+1;l(I=>w(_({},I),{currentStep:v})),m(c,v)}},[c,d,m]),u=(0,lt.useCallback)(v=>{l(I=>{let C=I.history[I.currentStep];if(C&&JSON.stringify(C)===JSON.stringify(v))return I;let S=[...I.history.slice(0,I.currentStep+1),v],L=S.length>Tp?S.slice(S.length-Tp):S;return{history:L,currentStep:L.length-1}})},[]),g=(0,lt.useCallback)((v,I)=>{let C=v.map(R=>w(_({},R),{selected:!1,className:"",data:w(_({},R.data),{hasError:!1})})),P=I.map(R=>w(_({},R),{data:w(_({},R.data),{hasError:!1})}));return{nodes:rr(C),edges:P}},[]),h=(0,lt.useCallback)(()=>g(t(),o()),[t,o,g]),x=(0,Np.useDebouncedCallback)(()=>{let v=h();u(v)},gy),T=(0,lt.useCallback)((v,I)=>{if(!e)return;if(c.length===0){let R=h();l({history:[R],currentStep:0})}if(v==="forceSave"){if(I){u(g(I.nodes,I.edges));return}x();return}v.some(R=>R.type==="select")||v.some(R=>R.type==="position"&&R.dragging)||x()},[e,x,c.length,h,u,g]);(0,lt.useEffect)(()=>{if(e&&c.length===0){let v=h();l({history:[v],currentStep:0})}},[e,c.length,h]);let b=(0,lt.useCallback)(v=>{l({history:v||[],currentStep:0})},[]),N=(0,lt.useCallback)(()=>{l({history:[],currentStep:0})},[]);return(0,lt.useEffect)(()=>{if(i!=="edit")return;let v=a.current;if(!v)return;let I=C=>{if(!v.contains(document.activeElement)||!(C.ctrlKey||C.metaKey))return;let S=C.key.toLowerCase();if(C.shiftKey&&S==="z"){C.preventDefault(),E();return}S==="z"&&(C.preventDefault(),y())};return v.addEventListener("keydown",I),()=>{v.removeEventListener("keydown",I)}},[y,E,i,a]),{history:c,undo:y,redo:E,canUndo:p,canRedo:f,saveHistory:T,resetHistory:b,clearHistory:N}};var Ap=()=>{let{t:e}=(0,Ip.useTranslation)(),[t,o,n]=(0,so.useNodesState)([]),[r,i,a]=(0,so.useEdgesState)([]),{getNodes:s,getNode:l}=(0,so.useReactFlow)(),{toast:c}=et(),d=(0,so.useStoreApi)(),{instanceId:p,isInitialized:f,setIsConnecting:m,setIsMultipleSelection:y,onElementClick:E}=q(),{updateHelperLines:u,HelperLines:g}=Oi(),{undo:h,redo:x,canUndo:T,canRedo:b,saveHistory:N}=wp(f),{onNodeDrag:v,onDrop:I,onDragOver:C,onDragLeave:P,onNodeDragStop:R,onNodeDragStart:S}=sp({nodes:t,setNodes:o,setEdges:i,saveHistory:N}),{isValidConnection:L,onConnect:K,onReconnect:j,onReconnectStart:Q,onReconnectEnd:z,setReconnectingEdge:M,clearReconnectingEdge:V}=Gu({setEdges:i,saveHistory:N}),{handleValidationComplete:D,clearValidation:A,dismissValidationPanel:B,validateDiagram:G,getIsClearingValidation:k}=Zu(),{importFromLia:O}=hs(),{handleTasksStatus:Y,handleClearTaskStatus:F}=bp(),{clearPathEdges:U}=Qo(),{emitElementChanges:X,handleNodeChanges:$,handleEdgeChanges:te}=fs(),ie=al();op({saveHistory:N}),dp({saveHistory:N}),Ep();let W=(0,At.useCallback)(()=>{o([]),i([]),U(),setTimeout(ie,0)},[o,i,U,ie]),{selectElements:oe,clearSelection:le}=Zt(),{importFromMxGraph:Z,exportToMxGraph:ve}=Bo(),{configureElement:ye,getConfigureElement:Ce}=Yi(),J=(0,At.useCallback)(Ee=>{Ee!=null&&Ee.id&&oe([Ee.id])},[oe]),{sendMessage:de}=xs({LIA_CREATE_DIAGRAM:O,CLEAR_DIAGRAM:W,TASKS_STATUS:Y,CLEAR_TASKS_STATUS:F,EXTERNAL_TASK_SELECT:J}),re=(0,At.useCallback)(()=>t.length+r.length,[t,r]);(0,At.useEffect)(()=>(oo.set(p,{importFromMxGraph:Z,exportToMxGraph:ve,selectElements:oe,clearSelection:le,configureElement:ye,getConfigureElement:Ce,getElementsCount:re,setReconnectingEdge:M,clearReconnectingEdge:V}),()=>{oo.delete(p)}),[p,Z,ve,oe,le,ye,Ce,re,M,V]);let ee=(0,At.useCallback)((Ee,he)=>{if(he.type!=="TASK"&&he.type!=="GATEWAY")return;let fe=Ce(he.id);fe&&(E==null||E(fe)),he.type==="TASK"&&de("SELECT_TASK",{id:he.id})},[Ce,E,de]),xe=(0,At.useCallback)((Ee,he)=>{if(he.type!=="SEQUENCE_EDGE")return;let fe=l(he.source),He=l(he.target),{isFromStartEvent:ht,isGatewayToGateway:Mt,isActiviyToAndGateway:ct,isToEndEvent:Kt}=ri(fe,He);if(!(!ht&&!Mt&&!ct&&!Kt))return;let po=Ce(he.id);po&&(E==null||E(po))},[Ce,l,E]),Se=(0,At.useCallback)(Ee=>{let he=u(Ee,t);n(he),N(Ee),k()||B(),$(Ee)},[t,n,N,k,B,u,$]),Ve=(0,At.useCallback)(Ee=>{a(Ee),N(Ee),k()||B(),te(Ee)},[a,N,k,B,te]);pp(Se);let ot=(0,At.useCallback)(({nodes:Ee,edges:he})=>{y(Ee.length+he.length>=2)},[y]);(0,so.useOnSelectionChange)({onChange:ot});let St=(0,At.useCallback)(async({nodes:Ee})=>Ee.some(fe=>fe.type==="LANE"&&t.some(He=>He.parentId===fe.id))?(c({variant:"error",title:e("validation.errors.title"),content:e("editor.toolbar.delete_pool_lane_error")}),!1):!0,[t,e,c]),uo=()=>{N("forceSave"),X(),B()},Ut=()=>{m(!0)},$t=()=>{m(!1),B()},gt=(0,At.useCallback)(Ee=>{let he=new Set(Ee.filter(fe=>fe.type==="LANE"&&!!fe.parentId).map(fe=>fe.parentId));he.size!==0&&setTimeout(()=>{var ht,Mt;let fe=s(),He=new Map(fe.map(ct=>[ct.id,ct]));for(let ct of he){let Kt=Jo(fe.filter(fo=>fo.type==="LANE"&&fo.parentId===ct));if(Kt.length===0)continue;let No=0;for(let fo of Kt)He.set(fo.id,w(_({},fo),{position:{x:ae.HEADER_WIDTH,y:No}})),No+=(Mt=(ht=fo.measured)==null?void 0:ht.height)!=null?Mt:0;let po=He.get(ct);po&&He.set(ct,w(_({},po),{height:No,measured:w(_({},po.measured),{height:No})}))}o(fe.map(ct=>{var Kt;return(Kt=He.get(ct.id))!=null?Kt:ct}))},0)},[s,o]);return{nodes:t,setNodes:o,edges:r,setEdges:i,events:{isValidConnection:L,onConnect:K,onReconnect:j,onReconnectStart:Q,onReconnectEnd:z,onDrop:I,onDragOver:C,onDragLeave:P,onNodeDrag:v,onNodeDragStop:R,onNodeDragStart:S,onNodeClick:ee,onEdgeClick:xe,onDropCapture:uo,onConnectStart:Ut,onConnectEnd:$t,onSelectionEnd:()=>setTimeout(()=>d.setState({nodesSelectionActive:!1}),0),onNodesChange:Se,onEdgesChange:Ve,onBeforeDelete:St,onNodesDelete:gt},ui:{handleCloseValidationPanel:A},controls:{undo:h,redo:x,canUndo:T,canRedo:b},components:{HelperLines:g},actions:{saveHistory:N,selectElements:oe,clearSelection:le,exportToMxGraph:ve,validateDiagram:G,handleValidationComplete:D,setReconnectingEdge:M,clearReconnectingEdge:V}}};var Cp=require("@xyflow/react"),Yo=require("react");var hy=".react-flow__node, .react-flow__edge, .react-flow__node-toolbar";function Sp(e,t,o){let[n,r]=(0,Yo.useState)(!1),i=(0,Yo.useRef)(null),{getViewport:a,setViewport:s}=(0,Cp.useReactFlow)(),l=(0,Yo.useCallback)(()=>{i.current=null,r(!1)},[]);return(0,Yo.useEffect)(()=>{let c=e.current;if(!c)return;let d=m=>{if(!Rr.some(E=>E===m.button)||t.current||o.current||(r(!0),!(m.target instanceof Element))||!m.target.closest(hy))return;m.preventDefault(),m.stopPropagation();let y=a();i.current={pointerX:m.clientX,pointerY:m.clientY,viewportX:y.x,viewportY:y.y,zoom:y.zoom}},p=m=>{let y=i.current;if(y){if((m.buttons&ya)===0){l();return}s({x:y.viewportX+(m.clientX-y.pointerX),y:y.viewportY+(m.clientY-y.pointerY),zoom:y.zoom})}},f=m=>{(m.buttons&ya)===0&&l()};return c.addEventListener("pointerdown",d,!0),window.addEventListener("pointermove",p),window.addEventListener("pointerup",f),window.addEventListener("pointercancel",l),window.addEventListener("blur",l),()=>{c.removeEventListener("pointerdown",d,!0),window.removeEventListener("pointermove",p),window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",l),window.removeEventListener("blur",l)}},[e,t,o,a,s,l]),n}var ba=require("react/jsx-runtime"),Es=({id:e,className:t})=>(0,ba.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,ba.jsx)("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});var fn=require("react/jsx-runtime"),Mp=()=>(0,fn.jsx)("svg",{style:{position:"absolute",top:0,left:0},children:(0,fn.jsxs)("defs",{children:[(0,fn.jsx)(Es,{id:"sequence-edge-marker",className:"text-grey-500"}),(0,fn.jsx)(Es,{id:"sequence-edge-marker-hovered",className:"text-grey-800"}),(0,fn.jsx)(Es,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});var Xo=require("@produto-lecom/lecom-ui");var Fr=require("@xyflow/react"),Fe=require("@produto-lecom/lecom-ui"),ao=require("lucide-react"),vo=require("react");var Fo=require("@produto-lecom/lecom-ui");var Br=(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))(Br||{});var Ts=require("@produto-lecom/lecom-ui"),Bp=require("@xyflow/react");var _s=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 Pp({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let r="data:text/csv;charset=utf-8,"+[e,...t].map(a=>a.join(",")).join(`
43
- `),i=encodeURI(r);bs(i,`${o}.csv`)}var bs=(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 Lp(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"},kp={script:"SCRIPT",subprocess:"SUBPROCESS"},Rp={"marker-loop":"LOOP"},Dp={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:a,parent:s}=r,l=Number(i._attributes.width),c=Number(i._attributes.height),d=s==="1"?void 0:s;return{id:r.id,parentId:d,type:t,data:{label:a||"",variant:o,attribute:n},position:{x:Number(i._attributes.x)||0,y:Number(i._attributes.y)||0},width:l,height:c,measured:{width:l,height:c}}},xy=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=ue.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=ue.START_EVENT.MIN_HEIGHT,{node:mn({cell:e,type:"START_EVENT"}),status:n,originalType:o}},Ey=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=ue.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=ue.END_EVENT.MIN_HEIGHT,{node:mn({cell:e,type:"END_EVENT"}),status:n,originalType:o}},_y=(e,t)=>{let{id:o,subType:n,style:r}=e==null?void 0:e._attributes,i=kp[n],a=t.get(o)||"",s=Rp[a]||"",l=s==="LOOP",c="imported";return!["script","none"].includes(n)&&!l&&(c="adapted"),e.mxGeometry._attributes.width=Io(e.mxGeometry._attributes.width||0,ue.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=Io(e.mxGeometry._attributes.height||0,ue.TASK.MIN_HEIGHT),{node:mn({cell:e,type:"TASK",variant:i,attribute:s}),status:c,originalType:r}},by=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=Dp[o],r=["none","inclusive","event-based"],i="imported";return r.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=ue.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=ue.GATEWAY.MIN_HEIGHT,{node:mn({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},Ty=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:mn({cell:e,type:"LANE"}),status:"imported",originalType:t}},vy=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=Io(e.mxGeometry._attributes.width||0,ue.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=Io(e.mxGeometry._attributes.height||0,ue.ANNOTATION.MIN_HEIGHT),{node:mn({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},Op=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=ue.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=ue.UNSUPPORTED.MIN_HEIGHT,{node:mn({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},Vp=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return w(_({},Dt),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},Hp={TASK:_y,GATEWAY:by,START_EVENT:xy,END_EVENT:Ey,LANE:Ty,ANNOTATION:vy};var Ny=e=>{let t=new Map,o=Object.values(Br),n=[],r=new Map;e.forEach(s=>{var c;let l=(c=s._attributes)==null?void 0:c.type;if(l==="MARKER"){r.set(s._attributes.parent,s._attributes.style);return}if(o.includes(l)){n.push(s);return}});let i=[],a=[];for(let s of n){let{type:l}=s._attributes,c=Hp[l]||Op,{node:d,status:p,originalType:f}=c(s,r);a.push(d),i.push({originalType:f,type:d.type,variant:d.data.variant,value:Lp(d.data.label),status:p})}return{nodes:a,governanceIdToNodeIdMap:t,summary:i}},wy=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>Vp(r,t)),Iy=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=Ny(t.root.mxCell),i=wy(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},Ay=async e=>{let t=await _s(e),o=es(t);if(!o)throw new Error("EMPTY_FILE");let{metadata:n,mxGraphModel:r}=o.modeler||{},i=(n==null?void 0:n.app)&&(n==null?void 0:n.diagramType)&&(n==null?void 0:n.version),a=r==null?void 0:r.root;if(!i||!a)throw new Error("INVALID_FILE");if(!Object.keys(r.root.mxCell||{}).length)throw new Error("CONTAIN_NO_CELLS");return{metadata:n,mxGraphModel:r}},Gp=async e=>{try{let t=await Ay(e),{nodes:o,edges:n,summary:r}=Iy(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};var Yp=require("react/jsx-runtime"),zp=()=>{let{t:e}=(0,Ts.useTranslation)(),{toast:t}=et(),{setNodes:o,setEdges:n}=(0,Bp.useReactFlow)(),{fitToNodes:r}=Go(),i=s=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],c=s.map(d=>[d.originalType,d.value,e(`adapter.governance.report.status.${d.status.toLowerCase()}`)]);t({variant:"warning",content:e("adapter.governance.success.incompatible_cells"),duration:1e3*60*1,action:(0,Yp.jsx)(Ts.Button,{size:"small",variant:"ghost",onClick:()=>Pp({columns:l,rows:c,fileName:"governance-imported-cells"}),children:e("adapter.governance.action.download")})})};return{importFromGovernance:async s=>{try{let{nodes:l,edges:c,summary:d}=await Gp(s);if(o(f=>f.concat(l)),n(f=>f.concat(c)),r(l),d.some(f=>f.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 Fp=require("@produto-lecom/lecom-ui"),Wp=require("react");var gn=require("react/jsx-runtime"),Xp=s=>{var l=s,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,a=qt(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=(0,Wp.useRef)(null),d=f=>{let m=f.target.files;m!=null&&m.length&&i(m),c.current&&(c.current.value="")};return(0,gn.jsxs)(gn.Fragment,{children:[(0,gn.jsx)(Fp.Button,w(_({disabled:n,onClick:f=>{var m;(m=c.current)==null||m.click(),r==null||r(f)}},a),{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"),Up=({disabled:e=!1})=>{let{t}=(0,Fo.useTranslation)(),{toast:o}=et(),{importFromGovernance:n}=zp(),r=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},i=a=>{let s=a[0];if(!s){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}n(s)};return(0,hn.jsxs)(Fo.Tooltip,{children:[(0,hn.jsx)(Fo.TooltipTrigger,{asChild:!0,children:(0,hn.jsx)(Xp,{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)(Ha,{})})}),(0,hn.jsx)(Fo.TooltipContent,{color:"black",children:t("editor.controls.actions.import_governance")})]})};var $p=require("react/jsx-runtime"),Ta=({shortcut:e})=>(0,$p.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 Te=require("@produto-lecom/lecom-ui"),Wo=require("lucide-react"),jp=require("react");var qp=require("@produto-lecom/lecom-ui"),Zp=require("@xyflow/react"),zr=require("html-to-image"),Jp=require("react");var Cy=3,va="diagram",vs=50,Sy=96,My=25.4,Py="sequence-edge-marker",Kp=e=>e*My/Sy,Ly=e=>{let t=document.getElementById(Py);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},Qp=()=>{let{t:e}=(0,qp.useTranslation)(),{toast:t}=et(),{getEdges:o,getNodes:n,getNodesBounds:r}=(0,Zp.useReactFlow)(),{clearSelection:i}=Zt(),[a,s]=(0,Jp.useState)({png:!1,html:!1,print:!1}),l=()=>{let m=ca(n(),o()),y=r(m),E=y.width+vs*2,u=y.height+vs*2,g=vs-y.x,h=vs-y.y;return{width:E,height:u,style:{width:`${E}px`,height:`${u}px`,transform:`translate(${g}px, ${h}px)`,transformOrigin:"top left"}}},c=async(m,y)=>{s(E=>w(_({},E),{[y]:!0})),await i();try{if(ca(n(),o()).length===0){t({content:e("editor.controls.actions.export.feedback.empty"),variant:"warning"});return}let u=qd();if(!u)throw new Error("Flow element not found");let g=l(),h=Ly(u);try{return await m(u,g)}finally{h==null||h.remove()}}catch(E){console.error("Diagram export failed",E),t({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{s(E=>w(_({},E),{[y]:!1}))}};return{exportAsPng:async(m=va)=>{await c(async(y,E)=>{let u=await(0,zr.toPng)(y,w(_({},E),{backgroundColor:"#fcfcfc",skipFonts:!0}));bs(u,`${m}.png`)},"png")},exportAsHtml:async(m=va)=>{await c(async(y,E)=>{let u=await(0,zr.toSvg)(y,w(_({},E),{backgroundColor:"#fcfcfc",skipFonts:!0})),g=`
38
+ </mxGraphModel>`,Wd=(e,t)=>{if(!e.length&&!t.length)return Sr;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var os=require("xml-js");var Xd={compact:!0,spaces:4},Oh=e=>e.replace(/\n/g,"&#xA;");function ns(e,t=Xd){if(e)return JSON.parse((0,os.xml2json)(e,t))}function Ud(e,t=Xd){return e?(0,os.json2xml)(e,w(_({},t),{attributeValueFn:Oh})):""}var $d={"attribute-loop":"LOOP"},Kd={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS","service-task":"SERVICE_TASK"},qd={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Zd={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed",SERVICE_TASK:"service-task"},Jd={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var Un=(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,m)=>Math.max(h,m.length),0)*7+r,c=E*20+i}let d=Math.max(wo(Number(s),t),l),u=Math.max(wo(Number(a),o),c);return{width:d,height:u,measured:{width:d,height:u}}},$n=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=$n(e),n=Un(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=$n(e),n=Un(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=$n(e),a=Un(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=$d[d];u&&(r.data.attribute=u)}let c=Kd[o.style];return c&&(r.data.variant=c),w(_(_({},r),a),{type:"TASK"})},la=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=$n(e),i=Un(o,de.GATEWAY.MIN_WIDTH,de.GATEWAY.MIN_HEIGHT);return r.data.variant=qd[n],w(_(_({},r),i),{type:"GATEWAY"})},Bh=e=>{let{mxGeometry:t}=e,o=$n(e),i=Un(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=$n(e),n=Un(t,de.LANE.MIN_WIDTH,de.LANE.MIN_HEIGHT);return w(_(_({},o),n),{type:"LANE"})},Qd={task:rs,"task-script":rs,"subprocess-collapsed":rs,"service-task":rs,"start-event":Hh,"end-event-terminate":Gh,"gateway-parallel":la,"gateway-exclusive":la,"gateway-complex":la,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)}))},jd=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,x=Yh(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,m=f!==void 0?Number(f):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&&m!==void 0?{labelOffset:{x:h,y:m}}:{})});return a.includes("association")&&a.includes('endArrow=""')?_(_({},Wn),y):_(_({},Rt),y)},eu=(e,t)=>{var f,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:((f=l==null?void 0:l.labelOffset)==null?void 0:f.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}},Kn=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=Kn(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:Zd[t]||"task"})})},Wh=e=>{let t=Kn(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"start-event"})})},Xh=e=>{let t=Kn(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"end-event-terminate"})})},Uh=e=>{let{variant:t}=e.data,o=Kn(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:Jd[t]})})},$h=e=>{let t=Kn(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"lane"})})},Kh=e=>{let t=Kn(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"annotation"})})},tu={TASK:Fh,START_EVENT:Wh,END_EVENT:Xh,GATEWAY:Uh,ANNOTATION:Kh,LANE:$h},ou=(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(Cr),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=Qd[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=jd(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=tu)[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=ou(n,t);o.push(l)}}),o},Qh=(e,t)=>{let o=[];return e.forEach(n=>{let r=eu(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]}}}},nu=(e=[],t=[],o)=>{let n=jh(e,t,o);return Ud(JSON.stringify(n),{compact:!0,spaces:0})},ru=async e=>{var s,a,l,c,d;let t=await ns(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)||Sr),r=qh(o),i=Zh(o,r);return{lastElementId:n,edges:i,nodes:r}};var fs=require("@xyflow/react"),Xu=require("react");var Tt=require("@xyflow/react"),ds=require("react");var Mr=require("@xyflow/react");var ca=require("react/jsx-runtime"),ne=i=>{var s=i,{type:e,position:t,className:o,nodeType:n}=s,r=$t(s,["type","position","className","nodeType"]);let a=n==="TASK";return(0,ca.jsx)(Mr.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))},ft=a=>{var l=a,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,s=$t(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=(0,Mr.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 x=d();return f.filter(g=>{if(g.source!==e)return!1;let h=x.find(m=>m.id===g.target);return(h==null?void 0:h.type)!=="ANNOTATION"}).length>=1}return!1})();return(0,ca.jsx)(Mr.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"),xo=require("@xyflow/react");var iu=require("@xyflow/react"),is=()=>{let e=(0,iu.useStoreApi)();return{getInternalNodes:()=>{let{nodeLookup:o}=e.getState();return Array.from(o.values())}}};var da=nr(require("@dagrejs/dagre"),1);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}},Do=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId);if(t.length===0)return e;let o=il(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){ul(s,o,r),pl(n,o);continue}Vs(n,i,o)}return sl(e,o)};var su=()=>{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"),ey=["top","right","bottom","left"],ty=["top-left","top-middle","top-right","right-middle","bottom-left","left-middle","bottom-right","bottom-middle"],Dt=r=>{var i=r,{nodeId:e,isVisible:t,offset:o=8}=i,n=$t(i,["nodeId","isVisible","offset"]);let{getInternalNode:s,setNodes:a}=(0,xo.useReactFlow)(),{getInternalNodes:l}=is(),c=Zt(),d=(0,xo.useStoreApi)(),u=(0,ua.useRef)(0),p=(0,ua.useRef)([]),f=({y:h,width:m,height:y})=>{cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{var F,j;if(!e)return;let{nodeLookup:v,onNodesChange:b}=d.getState(),I=v.get(e);if(!I||I.type!=="LANE")return;let T=!I.parentId,N=T?I.id:I.parentId;if(!N)return;let C=Array.from(v.values()).filter($=>$.type==="LANE"&&$.parentId===N);if(!C.length)return;p.current.length===0&&(p.current=Zo(C).map($=>$.id));let M=p.current.map($=>C.find(K=>K.id===$)).filter(Boolean),L=[],k=0,O=M.findIndex($=>$.id===I.id),V=!T&&O>0&&Math.abs(h-I.position.y)>.5;for(let $=0;$<M.length;$++){let K=M[$],A=K.id===I.id,P=$===M.length-1;if(A){k=V?h+y:k+y;continue}let R=(j=(F=K.measured)==null?void 0:F.height)!=null?j:0,S=T?m-ie.HEADER_WIDTH:m,B=R;T&&P&&(B=Math.max(ie.MIN_HEIGHT,y-k)),V&&$===O-1&&(B=Math.max(ie.MIN_HEIGHT,h-k)),L.push({id:K.id,type:"dimensions",dimensions:{width:S,height:B},setAttributes:!0}),L.push({id:K.id,type:"position",position:{x:ie.HEADER_WIDTH,y:k}}),k+=B}T?L.push({id:N,type:"dimensions",dimensions:{width:m,height:y},setAttributes:!0}):L.push({id:N,type:"dimensions",dimensions:{width:m+ie.HEADER_WIDTH,height:k},setAttributes:!0}),b==null||b(L)})},x=({y:h,width:m,height:y})=>{var I;if(cancelAnimationFrame(u.current),p.current=[],!e)return;let v=s(e);if(!v||v.type!=="LANE"&&!v.parentId)return;let b=[...l()];if(v.type!=="LANE"){b=b.map(T=>T.id===e?w(_({},T),{width:m,height:y,measured:{width:m,height:y}}):T),b=Do(b),a(b);return}b=fl(v,m,y,b,h),b=Do(b),b=qo((I=v.parentId)!=null?I:v.id,b),a(b)};if(!(!c&&t))return null;let g={"--resize-offset":`${o}px`};return(0,as.jsxs)(as.Fragment,{children:[ey.map(h=>(0,pa.createElement)(xo.NodeResizeControl,w(_({},n),{key:h,nodeId:e,position:h,variant:xo.ResizeControlVariant.Line,className:"border-blue-400/90 border-dashed",style:g,onResize:(m,y)=>f(y),onResizeEnd:(m,y)=>x(y)}))),ty.map(h=>(0,pa.createElement)(xo.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:(m,y)=>f(y),onResizeEnd:(m,y)=>x(y)})))]})};var cn=require("@xyflow/react"),ro=require("@produto-lecom/lecom-ui"),at=nr(require("react"),1);var au=require("zustand"),qn=(0,au.create)(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));var ls=require("react"),lu=(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 Oo=require("@xyflow/react"),cu=require("react"),oy=120,ny=12,du=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=(0,Oo.useReactFlow)(),{instanceId:i}=J();return(0,cu.useMemo)(()=>{var f,x;if(!t)return{position:Oo.Position.Right,align:"start"};let s=n(e);if(!s)return{position:Oo.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=(x=document.getElementById(`modeler-${i}`))==null?void 0:x.clientWidth;if(!d)return{position:Oo.Position.Right,align:"start"};let u=(o==null?void 0:o.width)||oy;return{position:l+c+u+ny>d?Oo.Position.Left:Oo.Position.Right}},[i,e,t,o,n,r])};var fa=require("lucide-react");var cs=require("@xyflow/react"),ye=require("@produto-lecom/lecom-ui"),uu=require("lucide-react");var Ae=require("react/jsx-runtime"),pu=({nodeId:e})=>{let{t}=(0,ye.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,Ae.jsxs)(ye.DropdownMenu,{children:[(0,Ae.jsxs)(ye.Tooltip,{children:[(0,Ae.jsx)(ye.TooltipTrigger,{asChild:!0,children:(0,Ae.jsx)(ye.DropdownMenuTrigger,{asChild:!0,children:(0,Ae.jsx)(ye.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:(0,Ae.jsx)(uu.WrenchIcon,{})})})}),(0,Ae.jsx)(ye.TooltipContent,{color:"black",children:t("bpmn.task.menu.title")})]}),(0,Ae.jsxs)(ye.DropdownMenuContent,{align:"start",className:"w-60 bg-white text-grey-600",children:[(0,Ae.jsxs)(ye.DropdownMenuLabel,{className:"flex items-center gap-1",children:[(0,Ae.jsx)("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),(0,Ae.jsx)("div",{className:"flex items-center gap-1",children:Object.entries(ni).map(([p,f])=>{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,Ae.jsxs)(ye.Tooltip,{children:[(0,Ae.jsx)(ye.TooltipTrigger,{asChild:!0,children:(0,Ae.jsx)(ye.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,Ae.jsx)(f.icon,{className:"stroke-inherit"})})}),g&&(0,Ae.jsx)(ye.TooltipContent,{color:"black",children:g})]},p)})})]}),(0,Ae.jsx)(ye.DropdownMenuGroup,{children:(0,Ae.jsxs)(ye.Tooltip,{children:[(0,Ae.jsx)(ye.TooltipTrigger,{asChild:!0,children:(0,Ae.jsx)("div",{className:G({"cursor-not-allowed":a}),children:(0,Ae.jsxs)(ye.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,Ae.jsx)(oi.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),a&&(0,Ae.jsx)(ye.TooltipContent,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};var Ve=require("react/jsx-runtime"),Eo={START_EVENT:{type:"START_EVENT",icon:sr,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:bn,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:sr,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:Qr,label:"bpmn.annotation.variant.default"}},ry={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:Nn,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:In,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:Tn,label:"bpmn.gateway.variant.complex"}},mt=at.default.memo(({nodeId:e,nodeType:t,nodeVariant:o,isChild:n})=>{let r=(0,at.useRef)(null),i=(0,at.useRef)(null),{t:s}=(0,ro.useTranslation)(),{setDraggableNode:a}=qn(),{getEdges:l,getNodes:c,setNodes:d}=(0,cn.useReactFlow)(),{setIsDragging:u,mode:p,isConnecting:f,isDragging:x}=J(),E=Zt(),g=(0,cn.useStore)((0,at.useCallback)(z=>{var X,Z;return(Z=(X=z.nodeLookup.get(e))==null?void 0:X.selected)!=null?Z:!1},[e])),h=(0,cn.useStore)((0,at.useCallback)(z=>{var X,Z;return(Z=(X=z.nodeLookup.get(e))==null?void 0:X.dragging)!=null?Z:!1},[e])),m=g&&!h&&!f&&!x&&!E,{dimensions:y}=lu(r,m),{position:v}=du(e,m,y),[b,I]=(0,at.useState)(void 0),T=o==="SUBPROCESS",N=o==="SERVICE_TASK",C=(0,at.useRef)(null),M=(0,at.useRef)(!1),L=(0,at.useCallback)(()=>{C.current!==null&&(clearTimeout(C.current),C.current=null),M.current=!1,u(!1),a(null),I(void 0),d(z=>z.map(X=>w(_({},X),{className:void 0})))},[u,a,d]);(0,at.useEffect)(()=>{let z=X=>{M.current&&X.buttons===0&&L()};return document.addEventListener("dragend",L),document.addEventListener("mousemove",z),()=>{document.removeEventListener("dragend",L),document.removeEventListener("mousemove",z)}},[L]);let k=(0,at.useCallback)((z,X)=>{M.current=!0,u(!1),a({type:X.type,variant:X.variant,attribute:X.attribute,icon:X.icon}),X.icon&&I((0,Ve.jsx)(X.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,at.useCallback)(()=>{L()},[L]);if(!m)return null;let V=c(),F=l(),j=[{component:(0,Ve.jsx)(Ui,{elementId:e})}],$=()=>{if(p==="view")return[];let z=!F.some(X=>{var Z;return X.source===e&&((Z=V.find(W=>W.id===X.target))==null?void 0:Z.type)!=="ANNOTATION"});return[{component:(0,Ve.jsx)(Bn,{nodeId:e,disabled:!z,tooltipMessage:z?void 0:s("editor.toolbar.start_event_limit_reached")})},Eo.TASK,Eo.ANNOTATION,...j]},K=()=>p==="view"?[{component:(0,Ve.jsx)(ko,{elementId:e})}]:[{component:(0,Ve.jsx)(ko,{elementId:e})},...T||N?[]:[{component:(0,Ve.jsx)(pu,{nodeId:e})}],{component:(0,Ve.jsx)(Bn,{nodeId:e})},Eo.TASK,{type:"TASK",variant:"SUBPROCESS",icon:ar,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:fa.Bot,label:"bpmn.task.variant.service_task"},Eo.ANNOTATION,...Object.values(ry),...nn(e,V,F)?[]:[Eo.END_EVENT],...j],A=()=>p==="view"?[{component:(0,Ve.jsx)(ko,{elementId:e,elementType:"gateway"})}]:[{component:(0,Ve.jsx)(ko,{elementId:e,elementType:"gateway"})},{component:(0,Ve.jsx)(Bn,{nodeId:e})},Eo.TASK,{type:"TASK",variant:"SUBPROCESS",icon:ar,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:fa.Bot,label:"bpmn.task.variant.service_task"},Eo.ANNOTATION,...j],P=()=>p==="view"?[]:[Eo.ANNOTATION,...j],R=()=>p==="view"?[]:[...n?[]:[{component:(0,Ve.jsx)(Bn,{nodeId:e})}],Eo.ANNOTATION,...j],S=()=>p==="view"?[]:[{component:(0,Ve.jsx)(Bn,{nodeId:e})},...j],B=()=>p==="view"?[]:[...j],D=(z=>{switch(z){case"START_EVENT":return $();case"TASK":return K();case"GATEWAY":return A();case"END_EVENT":return P();case"LANE":return R();case"ANNOTATION":return S();case"UNSUPPORTED":return B();default:return[]}})(t),H=D.length>6;if(!(D.length===0||p==="readonly"))return(0,Ve.jsxs)(cn.NodeToolbar,{position:v,align:"start",className:H?"-top-[4.5rem]":"-top-8",isVisible:m,children:[(0,Ve.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,X)=>{if(z.component)return(0,Ve.jsx)("div",{children:z.component},X);let Z={sourceNodeType:t,targetNodeType:z.type,sourceNodeId:e,nodes:V,edges:F},W=Td(Z),U={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?U[W.reason]||s(z.label):s(z.label)||"";return(0,Ve.jsxs)(ro.Tooltip,{children:[(0,Ve.jsx)(ro.TooltipTrigger,{asChild:!0,children:(0,Ve.jsx)(ro.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,Ve.jsx)(z.icon,{size:16})})}),(0,Ve.jsx)(ro.TooltipContent,{color:"black",children:Q})]},X)})}),(0,Ve.jsx)("div",{ref:i,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:b})]})});mt.displayName="NodeToolbar";var ot=require("react/jsx-runtime"),fu=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r,setNodes:i}=(0,Tt.useReactFlow)(),{inProgress:s,fromNode:a}=(0,Tt.useConnection)(),{mode:l,isReadOnly:c}=J(),d=s&&(a==null?void 0:a.id)!==e,u=(0,ds.useCallback)(x=>{let y=x.split(`
40
+ `),v=y.reduce((N,C)=>Math.max(N,C.length),0),b=y.length,I=Math.max(Mn.MIN_WIDTH,v*7+32),T=Math.max(Mn.MIN_HEIGHT,b*20+24);i(N=>N.map(C=>C.id===e?w(_({},C),{width:I,height:T,style:w(_({},C.style),{width:I,height:T})}):C))},[e,i]),p=(0,ds.useCallback)(x=>{r(e,{label:x}),u(x)},[e,r,u]),f=(0,ds.useCallback)(x=>{u(x)},[u]);return(0,ot.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,ot.jsx)(ct,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:p,onInput:f,skipFirstCharValidation:!0}),(0,ot.jsx)(mt,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&(0,ot.jsx)(Dt,{nodeId:e,minWidth:Mn.MIN_WIDTH,minHeight:Mn.MIN_HEIGHT,isVisible:!n&&o}),!s&&(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsx)(ne,{type:"source",position:Tt.Position.Left,id:"left"}),(0,ot.jsx)(ne,{type:"source",position:Tt.Position.Right,id:"right"}),(0,ot.jsx)(ne,{type:"source",position:Tt.Position.Top,id:"top"}),(0,ot.jsx)(ne,{type:"source",position:Tt.Position.Bottom,id:"bottom"})]}),(!s||d)&&(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsx)(ne,{type:"target",position:Tt.Position.Left,id:"left",className:G({"annotation-handle":d})}),(0,ot.jsx)(ne,{type:"target",position:Tt.Position.Right,id:"right",className:G({"annotation-handle":d})}),(0,ot.jsx)(ne,{type:"target",position:Tt.Position.Top,id:"top",className:G({"annotation-handle":d})}),(0,ot.jsx)(ne,{type:"target",position:Tt.Position.Bottom,id:"bottom",className:G({"annotation-handle":d})})]})]})};var vt=require("@xyflow/react"),mu=require("react");var Ue=require("react/jsx-runtime"),gu=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=(0,vt.useReactFlow)(),{inProgress:i,fromNode:s}=(0,vt.useConnection)(),{mode:a,isReadOnly:l,reconnectingEdgeId:c}=J(),[d,u]=(0,mu.useState)(!1),p=i&&(s==null?void 0:s.id)!==e||!!c,f=g=>{r(e,{label:g})},x=()=>{u(!0)},E=()=>{u(!1)};return(0,Ue.jsxs)("div",{className:"relative",onDoubleClick:x,children:[(0,Ue.jsx)(bn,{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,Ue.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,Ue.jsx)(ct,{value:t.label,isEditing:d,onBlur:E,onChange:f})}),(0,Ue.jsx)(mt,{nodeId:e,nodeType:"END_EVENT"}),a==="edit"&&(0,Ue.jsx)(Dt,{nodeId:e,isVisible:!n&&o,minWidth:ii.MIN_WIDTH,minHeight:ii.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||p)&&(0,Ue.jsxs)(Ue.Fragment,{children:[(0,Ue.jsx)(ne,{type:"target",position:vt.Position.Left,id:"left",className:G({"event-handle":p})}),(0,Ue.jsx)(ne,{type:"target",position:vt.Position.Right,id:"right",className:G({"event-handle":p})}),(0,Ue.jsx)(ne,{type:"target",position:vt.Position.Top,id:"top",className:G({"event-handle":p})}),(0,Ue.jsx)(ne,{type:"target",position:vt.Position.Bottom,id:"bottom",className:G({"event-handle":p})})]}),!i&&(0,Ue.jsxs)(Ue.Fragment,{children:[(0,Ue.jsx)(ne,{type:"source",position:vt.Position.Left,id:"left"}),(0,Ue.jsx)(ne,{type:"source",position:vt.Position.Right,id:"right"}),(0,Ue.jsx)(ne,{type:"source",position:vt.Position.Top,id:"top"}),(0,Ue.jsx)(ne,{type:"source",position:vt.Position.Bottom,id:"bottom"})]})]})};var Nt=require("@xyflow/react"),Zn=require("react");var $e=require("react/jsx-runtime"),ma=(0,Zn.memo)(({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let s=Ds[t.variant].icon,{updateNodeData:a}=(0,Nt.useReactFlow)(),{inProgress:l,fromNode:c}=(0,Nt.useConnection)(),{mode:d,isReadOnly:u,reconnectingEdgeId:p}=J(),[f,x]=(0,Zn.useState)(!1),E=l&&(c==null?void 0:c.id)!==e||!!p,g=(0,Zn.useCallback)(y=>{a(e,{label:y})},[e,a]),h=()=>{x(!0)},m=()=>{x(!1)};return(0,$e.jsxs)("div",{className:"relative",style:{width:o!=null?o:Sn.MIN_WIDTH,height:n!=null?n:Sn.MIN_HEIGHT},onDoubleClick:h,children:[(0,$e.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,$e.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,$e.jsx)(ct,{value:t.label,isEditing:f,onBlur:m,onChange:g})}),(0,$e.jsx)(mt,{nodeId:e,nodeType:"GATEWAY",nodeVariant:t.variant}),d==="edit"&&(0,$e.jsx)(Dt,{nodeId:e,isVisible:!i&&r,minWidth:Sn.MIN_WIDTH,minHeight:Sn.MIN_HEIGHT,offset:2,keepAspectRatio:!0}),(!l||E)&&(0,$e.jsxs)($e.Fragment,{children:[(0,$e.jsx)(ne,{type:"target",position:Nt.Position.Left,id:"left",className:G({"gateway-handle":E})}),(0,$e.jsx)(ne,{type:"target",position:Nt.Position.Right,id:"right",className:G({"gateway-handle":E})}),(0,$e.jsx)(ne,{type:"target",position:Nt.Position.Top,id:"top",className:G({"gateway-handle":E})}),(0,$e.jsx)(ne,{type:"target",position:Nt.Position.Bottom,id:"bottom",className:G({"gateway-handle":E})})]}),!l&&(0,$e.jsxs)($e.Fragment,{children:[(0,$e.jsx)(ft,{type:"source",position:Nt.Position.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,$e.jsx)(ft,{type:"source",position:Nt.Position.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,$e.jsx)(ft,{type:"source",position:Nt.Position.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,$e.jsx)(ft,{type:"source",position:Nt.Position.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})});ma.displayName="Gateway";var hu=require("@xyflow/react"),Ft=require("@produto-lecom/lecom-ui"),iy=require("lucide-react");var yu=require("react/jsx-runtime");var wt=require("@xyflow/react"),xu=require("react");var Ke=require("react/jsx-runtime"),Eu=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=(0,wt.useReactFlow)(),{inProgress:i,fromNode:s}=(0,wt.useConnection)(),{mode:a,isReadOnly:l,reconnectingEdgeId:c}=J(),[d,u]=(0,xu.useState)(!1),p=i&&(s==null?void 0:s.id)!==e||!!c,f=g=>{r(e,{label:g})},x=()=>{u(!0)},E=()=>{u(!1)};return(0,Ke.jsxs)("div",{className:"relative",onDoubleClick:x,children:[(0,Ke.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,Ke.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,Ke.jsx)(ct,{value:t.label,isEditing:d,onBlur:E,onChange:f})}),(0,Ke.jsx)(mt,{nodeId:e,nodeType:"START_EVENT"}),a==="edit"&&(0,Ke.jsx)(Dt,{nodeId:e,isVisible:!n&&o,minWidth:ri.MIN_WIDTH,minHeight:ri.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||p)&&(0,Ke.jsxs)(Ke.Fragment,{children:[(0,Ke.jsx)(ne,{type:"target",position:wt.Position.Left,id:"left",className:G({"event-handle":p})}),(0,Ke.jsx)(ne,{type:"target",position:wt.Position.Right,id:"right",className:G({"event-handle":p})}),(0,Ke.jsx)(ne,{type:"target",position:wt.Position.Top,id:"top",className:G({"event-handle":p})}),(0,Ke.jsx)(ne,{type:"target",position:wt.Position.Bottom,id:"bottom",className:G({"event-handle":p})})]}),!i&&(0,Ke.jsxs)(Ke.Fragment,{children:[(0,Ke.jsx)(ft,{type:"source",position:wt.Position.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),(0,Ke.jsx)(ft,{type:"source",position:wt.Position.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),(0,Ke.jsx)(ft,{type:"source",position:wt.Position.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),(0,Ke.jsx)(ft,{type:"source",position:wt.Position.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};var vu=require("@produto-lecom/lecom-ui"),It=require("@xyflow/react"),dn=require("react");var Pr=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<=Pr?i:i.substring(0,Pr).trim()},Jn=(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>Pr&&(n=n.substring(0,Pr).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=Pr-l.length,u=`${r.substring(0,c).trim()}${l}`;if(!o.has(u))return u;i++}return n};var Lr=require("react/jsx-runtime"),_u=e=>(0,Lr.jsxs)("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[(0,Lr.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),(0,Lr.jsx)("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));var ga=require("react/jsx-runtime"),bu=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 kr=require("react/jsx-runtime"),Tu=e=>(0,kr.jsxs)("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[(0,kr.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),(0,kr.jsx)("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));var pe=require("react/jsx-runtime"),sy={APROVADO:_u,EM_ANDAMENTO:bu,REJEITADO:Tu},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)]"},ay={APROVADO:"bg-green-50",EM_ANDAMENTO:"bg-turquoise-50",REJEITADO:"bg-red-50"},ya=(0,dn.memo)(({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let{t:s}=(0,vu.useTranslation)(),{toast:a}=rt(),{updateNodeData:l,getNodes:c,setNodes:d}=(0,It.useReactFlow)(),{inProgress:u,fromNode:p}=(0,It.useConnection)(),{mode:f,isReadOnly:x,onSubprocessValidationClick:E,reconnectingEdgeId:g}=J(),{getTaskStatus:h}=Jo(),m=u&&(p==null?void 0:p.id)!==e||!!g,y=h(e),v=t.variant==="SUBPROCESS",b=t.variant==="SERVICE_TASK",I=!!t.variant&&!v&&!b||!!y,T=!!t.attribute||v||b,N=(0,dn.useCallback)(K=>{let S=I||T?80:40,B=K.split(`
41
+ `),Y=B.reduce((X,Z)=>Math.max(X,Z.length),0),D=B.length,H=Math.max(Co.MIN_WIDTH,Y*7+64),z=Math.max(Co.MIN_HEIGHT,D*24+S);d(X=>X.map(Z=>Z.id===e?w(_({},Z),{width:H,height:z,style:w(_({},Z.style),{width:H,height:z})}):Z))},[e,d,I,T]),C=(0,dn.useCallback)(K=>{let A=K.trim(),P=t.label||"";if(A===P)return;let R=A,S=c();if(!(A&&A!=="")){R=us(S,s("bpmn.task.label.prefix")),l(e,{label:R}),N(R),a({variant:"warning",content:(0,pe.jsxs)(pe.Fragment,{children:[s("bpmn.task.feedback.label_empty.prefix")," ",(0,pe.jsx)("strong",{children:R})]})});return}let Y=Jn(R,S);Y===P||(l(e,{label:Y}),N(Y),Y!==R&&a({variant:"warning",content:(0,pe.jsxs)(pe.Fragment,{children:[s("bpmn.task.feedback.label_already_exists.prefix")," ",(0,pe.jsx)("strong",{children:A})," ",s("bpmn.task.feedback.label_already_exists.middle")," ",(0,pe.jsx)("strong",{children:Y})]})}))},[t.label,c,e,s,l,N,a]),M=(0,dn.useCallback)(K=>{N(K)},[N]),L=(0,dn.useCallback)(()=>{a({variant:"error",content:s("bpmn.task.feedback.invalid_first_character")})},[s,a]),k=y?sy[y]:null,O=t.variant?oi[t.variant].icon:null,V=t.attribute?ni[t.attribute].icon:null,F=()=>t.hasError?ha.error:y?ha[y]:x?ha.default:"",j=()=>{var K;return r&&(K=ay[y])!=null?K:""},$=()=>{E==null||E({id:e,type:"sub_process",label:t.label})};return(0,pe.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",F(),{"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:Co.MIN_WIDTH,height:n!=null?n:Co.MIN_HEIGHT},children:[(0,pe.jsx)("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:(0,pe.jsx)(ct,{value:t.label,maxLength:60,className:G(j(),{"py-10 px-8":I||T}),onChange:C,onInput:M,onInvalidFirstCharacter:L})}),O&&(0,pe.jsx)("div",{className:G("absolute flex items-center p-1",v||b?"bottom-0 left-1/2 -translate-x-1/2":"top-0 left-0"),children:(0,pe.jsx)(O,{size:b?20:16,className:G(t.hasError?"text-red-500":"text-grey-500",v&&"cursor-pointer"),onClick:v?$:void 0})}),V&&(0,pe.jsx)("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:(0,pe.jsx)("div",{className:G("flex items-center w-16 p-1",v||b?"justify-between":"justify-center"),children:(0,pe.jsx)(V,{size:16,className:G(t.hasError?"text-red-500":"text-grey-500")})})}),k&&(0,pe.jsx)("div",{className:"absolute top-0 right-0 flex items-center p-1",children:(0,pe.jsx)(k,{})}),(0,pe.jsx)(mt,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),f==="edit"&&(0,pe.jsx)(Dt,{nodeId:e,isVisible:!i&&r,minWidth:Co.MIN_WIDTH,minHeight:Co.MIN_HEIGHT}),(!u||m)&&(0,pe.jsxs)(pe.Fragment,{children:[(0,pe.jsx)(ne,{type:"target",position:It.Position.Left,id:"left",className:G({"task-handle":m})}),(0,pe.jsx)(ne,{type:"target",position:It.Position.Right,id:"right",className:G({"task-handle":m})}),(0,pe.jsx)(ne,{type:"target",position:It.Position.Top,id:"top",className:G({"task-handle":m})}),(0,pe.jsx)(ne,{type:"target",position:It.Position.Bottom,id:"bottom",className:G({"task-handle":m})})]}),!u&&(0,pe.jsxs)(pe.Fragment,{children:[(0,pe.jsx)(ft,{type:"source",position:It.Position.Left,id:"left",nodeId:e,nodeType:"TASK"}),(0,pe.jsx)(ft,{type:"source",position:It.Position.Right,id:"right",nodeId:e,nodeType:"TASK"}),(0,pe.jsx)(ft,{type:"source",position:It.Position.Top,id:"top",nodeId:e,nodeType:"TASK"}),(0,pe.jsx)(ft,{type:"source",position:It.Position.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})});ya.displayName="Task";var xa=require("@xyflow/react");var _o=require("react/jsx-runtime"),Nu=({id:e,data:t})=>(0,_o.jsxs)(_o.Fragment,{children:[(0,_o.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,_o.jsx)(mt,{nodeId:e,nodeType:"UNSUPPORTED"}),(0,_o.jsx)(ne,{type:"source",position:xa.Position.Right}),(0,_o.jsx)(ne,{type:"target",position:xa.Position.Left})]});var Be=require("@xyflow/react"),ps=require("react");var ke=require("react/jsx-runtime"),oA={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:Be.MarkerType.Arrow},data:{label:""}},wu=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:s,sourceHandleId:a,targetHandleId:l})=>{var B;let{zoom:c}=(0,Be.useViewport)(),{updateEdgeData:d}=(0,Be.useReactFlow)(),{mode:u,instanceId:p}=J(),f=Zt(),x=u!=="edit",[E,g]=(0,ps.useState)(!1),{reconnectingHandle:h,cursorPosition:m,hoveredNodeId:y,reconnectingSide:v,isValidReconnection:b,handleReconnectStart:I}=ji({edgeId:e,source:t,target:o,instanceId:p,isReadOnly:x}),T=(0,Be.useInternalNode)(t),N=(0,Be.useInternalNode)(o),{sx:C,sy:M,tx:L,ty:k,sourcePos:O,targetPos:V}=(0,ps.useMemo)(()=>{var te,Ee;if(!T||!N)return{sx:0,sy:0,tx:0,ty:0,sourcePos:Be.Position.Left,targetPos:Be.Position.Right};let Y=Ln(T,N),D=a?i:Y.sourcePos,H=l?s:Y.targetPos,z=(fe,ae,Me)=>{var oe,le,we,Qe,Ze,dt;let{x:Pe,y:lt}=fe.internals.positionAbsolute,q=(we=(le=(oe=fe.measured)==null?void 0:oe.width)!=null?le:fe.width)!=null?we:0,se=(dt=(Ze=(Qe=fe.measured)==null?void 0:Qe.height)!=null?Ze:fe.height)!=null?dt:0;switch(ae){case Be.Position.Top:return{x:Pe+q*Me,y:lt};case Be.Position.Bottom:return{x:Pe+q*Me,y:lt+se};case Be.Position.Left:return{x:Pe,y:lt+se*Me};case Be.Position.Right:return{x:Pe+q,y:lt+se*Me};default:return{x:Pe+q/2,y:lt+se/2}}},X=(te=n==null?void 0:n.sourceOffset)!=null?te:.5,Z=(Ee=n==null?void 0:n.targetOffset)!=null?Ee:.5,W=T?z(T,D,X).x:Y.sx,U=T?z(T,D,X).y:Y.sy,Q=N?z(N,H,Z).x:Y.tx,ee=N?z(N,H,Z).y:Y.ty;return h==="source"&&m?(W=m.x,U=m.y,v&&(D=v)):h==="target"&&m&&(Q=m.x,ee=m.y,v&&(H=v)),{sx:W,sy:U,tx:Q,ty:ee,sourcePos:D,targetPos:H}},[T,N,a,l,i,s,h,m,v,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!T||!N)return null;let[F,j,$]=(0,Be.getSmoothStepPath)({sourceX:C,sourceY:M,targetX:L,targetY:k,sourcePosition:O,targetPosition:V}),K=r||(T==null?void 0:T.selected)||(N==null?void 0:N.selected),A=K?"sequence-edge-marker-highlighted":"sequence-edge-marker",P=E||(n==null?void 0:n.label.trim().length)>0,R=()=>{g(!1)},S=Y=>{d(e,{label:Y.trim()})};return(0,ke.jsxs)("g",{className:G("group bpmn-arrow-edge",{"is-highlighted":K}),onDoubleClick:()=>!x&&g(!0),children:[(0,ke.jsx)("path",{d:F,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),(0,ke.jsxs)("g",{className:G("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":K}),children:[(0,ke.jsx)(Be.BaseEdge,{id:e,path:F,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]":K&&!(n!=null&&n.hasError)&&!h})}),(0,ke.jsxs)(Be.EdgeLabelRenderer,{children:[(0,ke.jsxs)("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${j}px, ${$}px)`},children:[r&&!f&&(0,ke.jsx)(Fn,{sx:C,sy:M,tx:L,ty:k,hasLabel:!!((B=n==null?void 0:n.label)!=null&&B.trim()),children:(0,ke.jsx)(Yn,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),P&&(0,ke.jsx)(ct,{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:S})]}),r&&!f&&!x&&(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsx)("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${C}px, ${M}px)`},children:(0,ke.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,ke.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,ke.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,ke.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:Y=>I("source",Y.nativeEvent)})]})}),(0,ke.jsx)("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${L}px, ${k}px)`},children:(0,ke.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,ke.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,ke.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,ke.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:Y=>I("target",Y.nativeEvent)})]})})]})]})]})]})};var un=require("@xyflow/react"),Rr=require("react/jsx-runtime"),Iu=({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:un.Position.Left},{x:n+s,y:r+a/2,pos:un.Position.Right},{x:n+s/2,y:r,pos:un.Position.Top},{x:n+s/2,y:r+a,pos:un.Position.Bottom}].reduce((f,x)=>{let E=Math.hypot(e-f.x,t-f.y);return Math.hypot(e-x.x,t-x.y)<E?x:f}),[d]=(0,un.getStraightPath)({sourceX:c.x,sourceY:c.y,targetX:e,targetY:t});return(0,Rr.jsxs)("g",{className:"group",children:[(0,Rr.jsx)("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d}),(0,Rr.jsx)("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})};var At=require("@xyflow/react"),Au=require("lodash"),pn=require("react");var Re=require("react/jsx-runtime"),Ea=(0,pn.memo)(({id:e,data:t,selected:o,dragging:n,parentId:r})=>{var T;let{updateNodeData:i,getNodes:s}=(0,At.useReactFlow)(),{mode:a,isReadOnly:l}=J(),{inProgress:c,fromNode:d}=(0,At.useConnection)(),u=c&&(d==null?void 0:d.id)!==e,[p,f]=(0,pn.useState)(!1),x=s(),E=!r,g=!E&&((T=x.find(N=>N.id===r))==null?void 0:T.selected),h=(0,pn.useMemo)(()=>(0,Au.orderBy)([...x.filter(N=>N.parentId===e&&N.type==="LANE")],"position.y","asc"),[x,e]),m=E?tl.MIN_WIDTH:ie.MIN_WIDTH,y=(0,pn.useMemo)(()=>{if(E&&h.length>1){let N=[...h];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,h]),v=N=>{i(e,{label:N})},b=()=>{f(!0)},I=()=>{f(!1)};return(0,Re.jsxs)(Re.Fragment,{children:[(0,Re.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,Re.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,Re.jsx)("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:(0,Re.jsx)(ct,{value:t.label,className:"w-full h-full self-auto",contentClassName:G({"whitespace-nowrap":p}),isEditing:p,onBlur:I,onChange:v})})}),(0,Re.jsx)("div",{className:"flex-1"})]}),(0,Re.jsx)(mt,{nodeId:e,nodeType:"LANE",isChild:!E}),a==="edit"&&(0,Re.jsx)(Dt,{nodeId:e,isVisible:!n&&o,minWidth:m,minHeight:y,offset:10}),!c&&(0,Re.jsxs)(Re.Fragment,{children:[(0,Re.jsx)(ne,{type:"source",position:At.Position.Left,id:"left"}),(0,Re.jsx)(ne,{type:"source",position:At.Position.Right,id:"right"}),(0,Re.jsx)(ne,{type:"source",position:At.Position.Top,id:"top"}),(0,Re.jsx)(ne,{type:"source",position:At.Position.Bottom,id:"bottom"})]}),(!c||u)&&(0,Re.jsxs)(Re.Fragment,{children:[(0,Re.jsx)(ne,{type:"target",position:At.Position.Left,id:"left",className:G({"annotation-handle":u})}),(0,Re.jsx)(ne,{type:"target",position:At.Position.Right,id:"right",className:G({"annotation-handle":u})}),(0,Re.jsx)(ne,{type:"target",position:At.Position.Top,id:"top",className:G({"annotation-handle":u})}),(0,Re.jsx)(ne,{type:"target",position:At.Position.Bottom,id:"bottom",className:G({"annotation-handle":u})})]})]})});Ea.displayName="Lane";var Cu={START_EVENT:Eu,END_EVENT:gu,TASK:ya,GATEWAY:ma,ANNOTATION:fu,LANE:Ea,UNSUPPORTED:Nu},Su={SEQUENCE_EDGE:sa,MESSAGE_EDGE:wu,ANNOTATION_EDGE:kd},Mu="#fafafa",Pu="#bebebe",Lu=1,ku=10,Ru="bottom-left",_a=.05,Du=5,Ou=150,Vu=100,Hu=_a,Gu=1,Bu={x:0,y:0,zoom:.75},zu=1,Yu=2,ly={[zu]:4,[Yu]:2},Dr=[zu,Yu],Fu=[0,1,2],Wu={hideAttribution:!0},ba=Dr.reduce((e,t)=>e|ly[t],0);var Vo=()=>{let{setViewport:e}=(0,fs.useReactFlow)(),t=(0,fs.useStoreApi)();return{fitToNodes:(0,Xu.useCallback)(n=>{let{width:r,height:i}=t.getState();if(i<=0||r<=0)return;let s=cl(n);if(!s)return;let a=dl({bounds:s,canvasHeight:i,canvasWidth:r,minZoom:Hu,maxZoom:Gu,offsetX:Ou,offsetY:Vu});e(a)},[t,e])}};var Uu=require("@xyflow/react");var Ot=()=>{let{getEdges:e,getNodes:t}=(0,Uu.useReactFlow)(),{lastElementId:o}=J(),n=()=>{let i=t(),s=e(),a=Wd(i,s);return Math.max(a,o)};return{getLastId:n,getNextId:()=>n()+1}};var Ho=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n}=(0,$u.useReactFlow)(),{getLastId:r}=Ot(),{fitToNodes:i}=Vo(),{setLastElementId:s}=J(),a=(0,Ta.useCallback)(async(c="")=>{let{nodes:d,edges:u,lastElementId:p}=await ru(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 nu(c,d,u)},[e,t,r]);return{importFromMxGraph:a,exportToMxGraph:l}};var va=require("react"),cy=500,ms=()=>{let{isInitialized:e,onElementChanges:t}=J(),{exportToMxGraph:o}=Ho(),n=(0,Ku.useDebouncedCallback)(()=>{if(!e)return;let s=o();t==null||t(s)},cy),r=(0,va.useCallback)(s=>{s.every(c=>c.type==="select")||s.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=(0,va.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,io.useRef)(null),{getNextId:l}=Ot(),c=(0,io.useCallback)(g=>{var b;let h=o(g.source),m=o(g.target);if(!h||!m)return!1;let y={sourceNodeId:h.id,targetNodeId:m.id,sourceNodeType:h.type,targetNodeType:m.type,nodes:r(),edges:n(),reconnectingEdgeId:(b=a.current)!=null?b:void 0};return oa(y).isValid},[o,n,r]),d=(0,io.useCallback)(g=>{var y,v;let h=l(),m=i(g.source);if(m){let b=i(g.target),I=b?b.internals.positionAbsolute.x+((y=b.measured.width)!=null?y:0)/2:0,T=b?b.internals.positionAbsolute.y+((v=b.measured.height)!=null?v:0)/2:0,N=Yd(m,I,T),C=(b==null?void 0:b.type)==="ANNOTATION"||(m==null?void 0:m.type)==="ANNOTATION",M=C?Wn:Rt,L;if(!C&&b&&g.targetHandle){let V=ts(N),F=ts(g.targetHandle),{x:j,y:$}=aa(m,N),{x:K,y:A}=aa(b,g.targetHandle),R=Ji(j,$,K,A,V,F).slice(1,-1);R.length>0&&(L=R)}let k=w(_(_({},g),M),{id:String(h),sourceHandle:N,data:_(_({},C?{}:Rt.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,io.useCallback)((g,h)=>{a.current=h.id},[]),p=(0,io.useCallback)(()=>{a.current=null},[]),f=(0,io.useCallback)((g,h)=>{let m=o(h.source),y=o(h.target);if(!m||!y){a.current=null;return}let v={sourceNodeId:m.id,targetNodeId:y.id,sourceNodeType:m.type,targetNodeType:y.type,nodes:r(),edges:n(),reconnectingEdgeId:g.id};if(!oa(v).isValid){a.current=null;return}let I=(0,gs.reconnectEdge)(g,h,n()).map(T=>T.id===g.id?w(_({},T),{data:w(_({},T.data),{points:void 0})}):T);e(I),t("forceSave",{nodes:r(),edges:I}),a.current=null,s()},[o,r,n,e,s,t]),x=(0,io.useCallback)(g=>{a.current=g},[]),E=(0,io.useCallback)(()=>{a.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:f,onReconnectStart:u,onReconnectEnd:p,setReconnectingEdge:x,clearReconnectingEdge:E}};var rp=require("@produto-lecom/lecom-ui"),ip=require("@xyflow/react"),St=require("react");var Or=(e=[])=>e.filter(t=>t.type==="START_EVENT"),fn=(e=[])=>e.filter(t=>t.type==="END_EVENT"),Go=(e=[])=>e.filter(t=>t.type==="TASK")||[],Zu=(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"}),Ct=(e,t=[])=>t.filter(o=>o.source===e),Vr=(e,t=[])=>t.filter(o=>o.target===e),Qu=(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"},ju=(e,t)=>{let o=Ct(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},ep=e=>e?/[^\s]/.test(e.trim()):!1,Te=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:[]}},bo=(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)}},tp=(e=[],t=[])=>({nodes:e.map(o=>{var n;return{id:o.id,type:o.type||"",label:typeof((n=o.data)==null?void 0:n.label)=="string"?o.data.label:void 0,properties:o.data}}),edges:t.map(o=>({id:o.id,source:o.source,target:o.target,type:o.type||"default"}))});var Hr=[{id:"start_event_not_found",validate:e=>{let t=Or(e.nodes);return Te({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=fn(e.nodes);return Te({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Or(e.nodes),o=t.length===1;if(t.length===0)return Te({isValid:!0});if(!o)return Te({isValid:!1,nodeIds:t.map(i=>i.id)});let n=Ct(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(s=>s.id),...n.map(s=>s.target)];return Te({isValid:!1,nodeIds:[...new Set(i)]})}return Te({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=Go(e.nodes),o=bo(t,n=>Ct(n.id,e.edges).length<=2);return Te({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=Go(e.nodes),o=bo(t,n=>!!n.label&&n.label.trim()!=="");return Te({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=Go(e.nodes),n=bo(o,r=>!r.label||r.label.length<=60);return Te({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=Go(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 Te({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=Ct(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",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 Te({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Or(e.nodes),...fn(e.nodes)],o=[],n=[];for(let r of t){let i=Ct(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 Te({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=fn(e.nodes),o=[],n=[];for(let r of t){let i=Vr(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=Ct(a.id,e.edges);l.length>1&&(o.push(a.id),l.forEach(c=>n.push(c.id)))}}}return Te({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=Ju(e.nodes),o=bo(t,r=>Ct(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>Ct(r,e.edges).map(i=>i.id));return Te({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=Go(e.nodes),o=bo(t,n=>!n.label||ep(n.label));return Te({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 Te({isValid:!0});let t=fn(e.nodes)[0];if(!t)return Te({isValid:!0});let o=Vr(t.id,e.edges);if(!o.length)return Te({isValid:!0});let r=Go(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=bo(r,l=>!Qu(l.id,e));return Te({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=Go(e.nodes),o=fn(e.nodes)[0];if(!o)return Te({isValid:!0});let n=t.filter(l=>{let c=Vr(l.id,e.edges),d=Ct(l.id,e.edges),u=c.some(f=>{var x;return((x=e.nodes.find(E=>E.id===f.source))==null?void 0:x.type)==="START_EVENT"}),p=d.some(f=>{var x;return((x=e.nodes.find(E=>E.id===f.target))==null?void 0:x.type)==="END_EVENT"});return u&&p}),r=Vr(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 Te(a)}},{id:"gateway_flow_to_event",validate:e=>{let t=hs(e.nodes),o=[],n=[];for(let r of t){let i=Ct(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 Te({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=bo(t,n=>Ct(n.id,e.edges).length>=1);return Te({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Or(e.nodes),...fn(e.nodes)],o=[],n=[];for(let r of t){let i=Ct(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 Te({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=Zu(e.nodes),o=bo(t,n=>!ju(n.id,e));return Te({isValid:o.isValid,nodeIds:o.invalidIds})}}];var op=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of Hr){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}},np=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 mn=require("react/jsx-runtime"),sp=()=>{let{t:e}=(0,rp.useTranslation)(),{toast:t}=rt(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=(0,ip.useReactFlow)(),{validateCustomDiagram:s}=J(),[a,l]=(0,St.useState)(!1),c=(0,St.useRef)(!1),d=(0,St.useRef)(!1),u=(0,St.useRef)(!1),p=(0,St.useCallback)(async m=>{let y=tp(m.nodes,m.edges),v=op(y),b=m.nodes.filter(({type:T,data:N})=>T==="TASK"&&((N==null?void 0:N.variant)==="SUBPROCESS"||(N==null?void 0:N.variant)==="SERVICE_TASK"));if(s&&b.length>0){let T=await np(s,b);v={isValid:v.isValid&&T.isValid,errors:[...v.errors,...T.errors]}}let I=v.errors.map(T=>w(_({},T),{message:e(`validation.errors.${T.id}`)}));return a||l(!0),{isValid:v.isValid,errors:I}},[a,e,s]),f=(0,St.useCallback)((m,y=!0)=>{if(y&&m&&t({variant:m.isValid?"success":"error",duration:5e3,title:m.isValid?e("validation.success.title"):e("validation.errors.title"),content:(0,mn.jsxs)("div",{className:"flex flex-col gap-1",children:[!m.isValid&&(0,mn.jsx)("span",{className:"body-small-500",children:e("validation.errors.subtitle")}),(0,mn.jsx)("ul",{className:"list-disc list-inside max-h-40 overflow-y-auto",children:m.isValid?(0,mn.jsx)("li",{children:e("validation.success.message")}):m.errors.map(V=>(0,mn.jsx)("li",{className:"text-xs",children:V.message},V.id))})]})}),!m)return;c.current=!0,d.current=!0,u.current=!0;let v=[],b=[];m.errors.forEach(V=>{V.nodeIds&&V.nodeIds.length>0&&V.nodeIds.forEach(F=>v.push(F)),V.edgeIds&&V.edgeIds.length>0&&V.edgeIds.forEach(F=>b.push(F))});let I=[...new Set(v)],T=r(),N=i(),C=new Set(I),M=new Set;m.errors.forEach(V=>{var $,K;let F=Hr.find(A=>A.id===V.id);(F==null?void 0:F.highlightRelatedEdges)!==!1&&(($=V.edgeIds)==null||$.forEach(A=>M.add(A)),(K=V.nodeIds)==null||K.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;T.forEach(V=>{V.type==="START_EVENT"?L.add(V.id):V.type==="END_EVENT"&&k.add(V.id)}),N.forEach(V=>{L.has(V.source)&&O.add(V.target),k.has(V.target)&&O.add(V.source)}),O.forEach(V=>{var F,j;if(C.has(V)){let $=(F=m.errors.find(A=>{var P;return(P=A.nodeIds)==null?void 0:P.includes(V)}))==null?void 0:F.id;((j=Hr.find(A=>A.id===$))==null?void 0:j.highlightRelatedEdges)!==!1&&N.forEach(A=>{A.source===V&&k.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(F=>w(_({},F),{data:w(_({},F.data),{hasError:C.has(F.id)})}))),n(V=>V.map(F=>w(_({},F),{data:w(_({},F.data),{hasError:M.has(F.id)})}))),setTimeout(()=>{d.current=!1,c.current=!1},0)},[e,i,r,n,o,t]),x=(0,St.useCallback)(()=>{l(!1),u.current=!1,o(m=>m.map(y=>w(_({},y),{data:w(_({},y.data),{hasError:!1})}))),n(m=>m.map(y=>w(_({},y),{data:w(_({},y.data),{hasError:!1})})))},[n,o]),E=(0,St.useCallback)(()=>{u.current&&(d.current=!0,u.current=!1,o(m=>m.map(y=>w(_({},y),{data:w(_({},y.data),{hasError:!1})}))),n(m=>m.map(y=>w(_({},y),{data:w(_({},y.data),{hasError:!1})}))),setTimeout(()=>{d.current=!1},0))},[n,o]),g=(0,St.useCallback)(()=>d.current,[]),h=(0,St.useCallback)(()=>c.current,[]);return{validateDiagram:p,handleValidationComplete:f,clearValidation:x,dismissValidationPanel:E,isAutoValidationEnabled:a,getIsClearingValidation:g,getIsValidating:h}};var cp=require("@xyflow/react"),dp=require("@produto-lecom/lecom-ui"),up=require("react");var dy=15,ap="bpmn:selection",uy=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},lp=e=>{if(!uy(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},pp=({offset:e=dy,saveHistory:t})=>{let{t:o}=(0,dp.useTranslation)(),{getNodes:n,setNodes:r,getEdges:i,setEdges:s}=(0,cp.useReactFlow)(),{getNextId:a}=Ot(),{mode:l,containerRef:c}=J();(0,up.useEffect)(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let u=f=>{var b,I;if(!lp(f)||!d.contains(document.activeElement))return;let E=n(),g=i(),h=E.filter(T=>T.selected);if(!h.length)return;f.preventDefault(),f.stopPropagation();let m=g.filter(T=>h.some(N=>N.id===T.source)&&h.some(N=>N.id===T.target)),v=JSON.stringify({nodes:h,edges:m});(b=f.clipboardData)==null||b.setData(ap,v),(I=f.clipboardData)==null||I.setData("text/plain",`BPMN Selection: ${h.length} nodes`)},p=f=>{var L,k;if(!lp(f)||!d.contains(document.activeElement))return;let E=(L=f.clipboardData)==null?void 0:L.getData(ap);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 h=new Map,m=n(),y=[],v=g.nodes.filter(O=>Hn(O.type,m));if(v.length===0)return;let b=a(),I=v.map(O=>{var j;let V=String(b++);h.set(O.id,V);let F=w(_({},O),{id:V,selected:!0,position:{x:O.position.x+e,y:O.position.y+e}});if(O.type==="TASK"){let $=(j=O.data)==null?void 0:j.label,K=Jn($||o("bpmn.task.label.prefix"),[...m,...y]);F.data=w(_({},O.data),{label:K})}return y.push(F),F}),T=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=[...m.map(O=>w(_({},O),{selected:!1})),...I],M=[...i().map(O=>w(_({},O),{selected:!1})),...T];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 fp=require("@produto-lecom/lecom-ui"),mp=require("@xyflow/react");var ys=require("react");var py=50,gp=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let{draggableNode:r,setDraggableNode:i}=qn(),{t:s}=(0,fp.useTranslation)(),{getInternalNode:a,getNodes:l,getEdges:c,screenToFlowPosition:d}=(0,mp.useReactFlow)(),{getNextId:u}=Ot(),{setIsDragging:p}=J(),{getInternalNodes:f}=is(),{rebuildIndex:x,forceRebuildIndex:E}=Gi(),[g,h]=(0,ys.useState)(null),m=(0,ys.useRef)(""),y=(A,P,R)=>{var D;if(A.parentId!==P)return null;let S=R.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=R.find(H=>H.id===A.id))!=null?D:A,Y=S.find(H=>B.position.y<H.position.y);return Y?{draggedLaneId:A.id,beforeLaneId:Y.id}:{draggedLaneId:A.id,afterLaneId:S[S.length-1].id}},v=(A,P=!1,R)=>{let S=P?"node-drop-target-error":"node-drop-target",B=P?"node-drop-target-lane-error":"node-drop-target-lane";t(Y=>{var X,Z,W,U;let D=(X=R==null?void 0:R(Y))!=null?X: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:"",(U=D==null?void 0:D.afterLaneId)!=null?U:""].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 m.current===H?Y:(m.current=H,Y.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){v();return}let H=R.filter(Z=>Z.id!==A.id&&Z.type==="LANE"&&!Z.parentId),z=cr(A,H);if(!z){v();return}if(Ko({parentId:z.id,nodes:e,excludeTypes:["LANE"]})){v(z.id,!0);return}v(z.id,!1,Z=>y(A,z.id,Z));return}let B=R.filter(H=>H.id!==A.id&&H.type==="LANE"),Y=cr(A,B);if(!Y){v();return}if(Ko({parentId:Y.id,nodes:e,includeTypes:["LANE"]})){v();return}v(Y.id)},I=A=>{let P=a(A.id),R=A.type==="LANE"&&Ko({parentId:A.id,nodes:e,includeTypes:["LANE"]});b(P,R)},T=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,C=(A,P)=>{let R=0;for(let S of P){if(S.id===A||S.parentId||S.type==="LANE")continue;let B=Pt(S),Y=B.y+B.h;R=Math.max(R,Y)}return R+py},M=(A,P)=>{if(!Os(A,P))return P;let R=C(A,P);return P.map(S=>S.id===A?w(_({},S),{position:w(_({},S.position),{y:R})}):S)},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))&&v()},O=(A,P)=>{A.preventDefault(),I(P)},V=(A,P,R)=>{var X,Z;let S=[...R],B=P.parentId?P.parentId:P.id;if(A.parentId===P.id)return S=Hs(A,P,S),S=Do(S),S=qo(B,S),T(S);if(A.type==="LANE"){if(Ko({parentId:P.id,nodes:S,excludeTypes:["LANE"]})){let te=Oi(P),Ee=50,fe=50;return S.map(ae=>{var Me,Pe;return ae.id===A.id?w(_({},ae),{position:{x:(Me=g==null?void 0:g.x)!=null?Me:te.x+Ee,y:(Pe=g==null?void 0:g.y)!=null?Pe:te.y2+fe}}):ae})}let Q=S.filter(te=>te.parentId===P.id).reduce((te,Ee)=>{var fe,ae;return te+((ae=(fe=Ee.measured)==null?void 0:fe.height)!=null?ae: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=Do(S),S=M(B,S),S}if(Ko({parentId:P.id,nodes:S,includeTypes:["LANE"]})){let W;if(A.parentId){let U=a(A.parentId),{x:Q,y:ee}=Pt(U);W={x:Q+((X=A.position.x)!=null?X:0),y:ee+((Z=A.position.y)!=null?Z:0)}}return S=S.map(U=>U.id===A.id?w(_({},U),{position:W!=null?W:U.position,parentId:void 0,className:void 0}):w(_({},U),{className:void 0})),S=qo(B,S),S}let H=al(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=Hs(z,P,S),S=Do(S),S=qo(B,S),S},F=A=>{if(A.preventDefault(),!(r!=null&&r.type))return;if(!Hn(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},S=u(),B={id:String(S),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},Y=w(_({},B),{internals:{positionAbsolute:P}}),D=w(_({},Y),{measured:{width:1,height:1}}),H=f(),z=r.type==="LANE",X=H.filter(te=>z?te.type==="LANE"&&!te.parentId:te.type==="LANE"),Z=cr(D,X),W=[...H.map(te=>w(_({},te),{selected:!1})),Y];Z&&(W=V(Y,Z,W)),W=lr(W),z&&!Z&&(W=M(Y.id,W)),W=T(W),t(W),E();let U=A.dataTransfer.getData("sourceId"),Q=c(),ee=Q;if(U){let te={id:String(S+1),source:U,target:B.id},Ee=r.type==="ANNOTATION"?_(_({},te),Wn):_(_({},te),Rt);ee=Q.concat(Ee),o(ee)}n("forceSave",{nodes:W,edges:ee}),p(!1),i(null)},j=async(A,P,R)=>{let S=[...f()],B=new Set;R.forEach(H=>{let z=a(H.id),X=H.type==="LANE",Z=S.filter(U=>U.id!==H.id&&(X?U.type==="LANE"&&!U.parentId:U.type==="LANE")),W=cr(z,Z);if(W){if(X&&Ko({parentId:H.id,nodes:S,includeTypes:["LANE"]})){H.parentId&&(S=K(H,S),B.add(H.id));return}S=V(z,W,S);return}H.parentId&&(S=K(H,S),H.type==="LANE"&&B.add(H.id))}),S=N(S);let Y=R.filter(H=>H.type==="LANE"&&!H.parentId).map(H=>H.id);for(let H of Y)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(R.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=qo(z,S)}S=lr(S),S=T(S),t(S),x(S),h(null)},$=(A,P)=>{h({x:P.position.x,y:P.position.y})},K=(A,P)=>{var Z,W,U,Q,ee,te,Ee,fe;let R=a(A.parentId);if(!R)return P;let S=A.type==="LANE",B=P.filter(ae=>ae.parentId===R.id&&ae.id!==A.id),Y=B.filter(ae=>ae.type==="LANE"),D;if(S&&Y.length===0)D=ie.MIN_HEIGHT;else if(S){let ae=(W=(Z=A.measured)==null?void 0:Z.height)!=null?W:ie.MIN_HEIGHT;D=((Q=(U=R.measured)==null?void 0:U.height)!=null?Q:ie.MIN_HEIGHT)-ae,D=Math.max(ie.MIN_HEIGHT,D)}else D=B.length>0?B.reduce((ae,Me)=>{var Pe,lt;return ae+((lt=(Pe=Me.measured)==null?void 0:Pe.height)!=null?lt:0)},0)+Ge:Math.max(ie.MIN_HEIGHT,(te=(ee=R.measured)==null?void 0:ee.height)!=null?te:0);let{x:H,y:z}=Pt(R),X={x:H+((Ee=A.position.x)!=null?Ee:0),y:z+((fe=A.position.y)!=null?fe:0)};return P=P.map(ae=>ae.id===A.id?w(_({},ae),{position:X,parentId:void 0}):ae.id===R.id?w(_({},ae),{height:D,measured:w(_({},ae.measured),{height:D})}):ae),P=Do(P),P};return{onDragOver:L,onDragLeave:k,onDrop:F,onNodeDrag:O,onNodeDragStart:$,onNodeDragStop:j}};var hp=require("@xyflow/react"),yp=require("@produto-lecom/lecom-ui"),xp=require("react");var fy=30,my=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},gy=e=>!my(e.target),Ep=({offset:e=fy,saveHistory:t})=>{let{t:o}=(0,yp.useTranslation)(),{getNodes:n,setNodes:r,getEdges:i,setEdges:s}=(0,hp.useReactFlow)(),{getNextId:a}=Ot(),{mode:l,containerRef:c}=J();(0,xp.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"&&gy(p)){p.preventDefault(),p.stopPropagation();let x=n(),E=i(),g=x.filter(M=>M.selected);if(!g.length)return;let h=new Map,m=[],y=g.filter(M=>Hn(M.type,x));if(y.length===0)return;let v=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 k=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,F=Jn(V||o("bpmn.task.label.prefix"),[...x,...m]);k.data=w(_({},M.data),{label:F})}return m.push(k),k}),T=v.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})),...T];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"),_p=require("@xyflow/react");var hy=20,yy=50,Gr={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},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},bp=e=>{let{getNodes:t}=(0,_p.useReactFlow)(),{mode:o,isMoveTool:n}=J(),r=(0,Br.useRef)(0),i=(0,Br.useRef)(new Map);(0,Br.useEffect)(()=>{let s=a=>{if(o!=="edit"||!n||xy(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 x=a.shiftKey?yy:hy,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(m=>{let y=i.current.get(m.id);(!f||!y)&&(y={x:m.position.x,y:m.position.y});let v={x:y.x+E,y:y.y+g};return i.current.set(m.id,v),{id:m.id,dragging:!1,type:"position",position:v}});e&&e(h)};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t,e,o,n])};var Ip=require("@xyflow/react");var vp={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY","gateway-parallel":"GATEWAY","gateway-complex":"GATEWAY"},Np={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Tp=(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}},Ey=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=Tp(i[0],o),a=Tp(i[1],o);s&&a&&n.push({sourceId:s.step,targetId:a.step,label:s.edgeLabel||a.edgeLabel||""})}),{components:o,connections:n}},wp=e=>{let{components:t,connections:o}=Ey(e);return{nodes:t,edges:o}};var _y=7,by=48,Ty=340,vy=(e,t)=>{let o=by+e.length*_y;return Math.min(Ty,Math.max(t,o))},xs=()=>{let{setNodes:e,setEdges:t}=(0,Ip.useReactFlow)(),{fitToNodes:o}=Vo(),{getNextId:n}=Ot();return{importFromLia:i=>{let s=typeof i=="string"?i:i.diagramXml||"",{nodes:a,edges:l}=wp(s),c=[],d=new Map,u=!1,p=n();for(let[m,y]of Object.entries(a)){let v=String(p++),b=vp[y.type],I=Np[y.type];b==="START_EVENT"&&(u=!0),d.set(m,v);let T=de[b].MIN_WIDTH,N=de[b].MIN_HEIGHT;c.push({id:v,type:b,data:{label:y.label||"",variant:I,attribute:""},position:{x:0,y:0},width:T,height:N,measured:{width:T,height:N}})}let f=[];for(let m of l){let y=w(_({},Rt),{id:String(p++),source:d.get(m.sourceId)||m.sourceId,target:d.get(m.targetId)||m.targetId});f.push(y)}if(!u&&c.length>0){let m=String(p++),y={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(y);let v=c[1];if(v){let b=w(_({},Rt),{id:String(p++),source:m,target:v.id});f.unshift(b)}}let x=c.map(m=>{var y,v;return m.type==="TASK"?w(_({},m),{width:vy(String((v=(y=m.data)==null?void 0:y.label)!=null?v:""),de.TASK.MIN_WIDTH)}):m}),{nodes:E}=ss(x,f),g=new Map(E.map(m=>[m.id,m.position])),h=c.map(m=>{var y;return w(_({},m),{position:(y=g.get(m.id))!=null?y:m.position})});e(h),t(f),o(h)}}};var Es=require("react"),Ny={origin:"*",debug:!1};function _s(e,t=Ny){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 Ap=require("@xyflow/react"),To=require("react");var Cp=()=>{let e=(0,Ap.useNodesInitialized)(),{initialDiagram:t,isNewDiagram:o,setIsInitialized:n,onElementChanges:r}=J(),{importFromMxGraph:i,exportToMxGraph:s}=Ho(),{sendMessage:a}=_s(),l=(0,To.useRef)(t),c=(0,To.useRef)(r),d=(0,To.useRef)(s);(0,To.useEffect)(()=>{c.current=r},[r]),(0,To.useEffect)(()=>{d.current=s},[s]),(0,To.useEffect)(()=>{t&&(i(t),l.current=t)},[t,i]),(0,To.useEffect)(()=>{if(!e)return;(async()=>{var p;if(await jr(),n(!0),a("INIT_MODELER",l.current),!o){let f=d.current();(p=c.current)==null||p.call(c,f)}})()},[e,o,n,a])};var Sp=require("@xyflow/react"),Na=require("react");function Mp(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=Jo(),{getEdges:n}=(0,Sp.useReactFlow)(),r=(0,Na.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,Na.useCallback)(()=>{t()},[t]);return{handleTasksStatus:r,handleClearTaskStatus:i}}var Lp=require("@xyflow/react"),gt=require("react"),kp=require("use-debounce");var Iy=500,Pp=100,Rp=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=(0,Lp.useReactFlow)(),{mode:i,containerRef:s}=J(),[a,l]=(0,gt.useState)({history:[],currentStep:0}),{history:c,currentStep:d}=a,u=d>0,p=d<c.length-1,f=(0,gt.useCallback)((T,N)=>{n(T[N].nodes),r(T[N].edges)},[n,r]),x=(0,gt.useCallback)(()=>{if(d>0){let T=d-1;l(N=>w(_({},N),{currentStep:T})),f(c,T)}},[d,c,f]),E=(0,gt.useCallback)(()=>{if(d<c.length-1){let T=d+1;l(N=>w(_({},N),{currentStep:T})),f(c,T)}},[c,d,f]),g=(0,gt.useCallback)(T=>{l(N=>{let C=N.history[N.currentStep];if(C&&JSON.stringify(C)===JSON.stringify(T))return N;let k=[...N.history.slice(0,N.currentStep+1),T],O=k.length>Pp?k.slice(k.length-Pp):k;return{history:O,currentStep:O.length-1}})},[]),h=(0,gt.useCallback)((T,N)=>{let C=T.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:lr(C),edges:M}},[]),m=(0,gt.useCallback)(()=>h(t(),o()),[t,o,h]),y=(0,kp.useDebouncedCallback)(()=>{let T=m();g(T)},Iy),v=(0,gt.useCallback)((T,N)=>{if(!e)return;if(c.length===0){let M=m();l({history:[M],currentStep:0})}if(T==="forceSave"){if(N){g(h(N.nodes,N.edges));return}y();return}T.some(M=>M.type==="select")||ai(T)||y()},[e,y,c.length,m,g,h]);(0,gt.useEffect)(()=>{if(e&&c.length===0){let T=m();l({history:[T],currentStep:0})}},[e,c.length,m]);let b=(0,gt.useCallback)(T=>{l({history:T||[],currentStep:0})},[]),I=(0,gt.useCallback)(()=>{l({history:[],currentStep:0})},[]);return(0,gt.useEffect)(()=>{if(i!=="edit")return;let T=s.current;if(!T)return;let N=C=>{if(!T.contains(document.activeElement)||!(C.ctrlKey||C.metaKey))return;let k=C.key.toLowerCase();if(C.shiftKey&&k==="z"){C.preventDefault(),E();return}k==="z"&&(C.preventDefault(),x())};return T.addEventListener("keydown",N),()=>{T.removeEventListener("keydown",N)}},[x,E,i,s]),{history:c,undo:x,redo:E,canUndo:u,canRedo:p,saveHistory:v,resetHistory:b,clearHistory:I}};var Op=()=>{let{t:e}=(0,Dp.useTranslation)(),[t,o,n]=(0,Bo.useNodesState)([]),[r,i,s]=(0,Bo.useEdgesState)([]),{getNodes:a,getNode:l}=(0,Bo.useReactFlow)(),{toast:c}=rt(),d=(0,Bo.useStoreApi)(),{instanceId:u,isInitialized:p,setIsConnecting:f,onElementClick:x}=J(),{updateHelperLines:E,HelperLines:g}=Gi(),{undo:h,redo:m,canUndo:y,canRedo:v,saveHistory:b}=Rp(p),{onNodeDrag:I,onDrop:T,onDragOver:N,onDragLeave:C,onNodeDragStop:M,onNodeDragStart:L}=gp({nodes:t,setNodes:o,setEdges:i,saveHistory:b}),{isValidConnection:k,onConnect:O,onReconnect:V,onReconnectStart:F,onReconnectEnd:j,setReconnectingEdge:$,clearReconnectingEdge:K}=qu({setEdges:i,saveHistory:b}),{handleValidationComplete:A,clearValidation:P,dismissValidationPanel:R,validateDiagram:S,getIsValidating:B,getIsClearingValidation:Y}=sp(),{importFromLia:D}=xs(),{handleTasksStatus:H,handleClearTaskStatus:z}=Mp(),{clearPathEdges:X}=Jo(),{emitElementChanges:Z,handleNodeChanges:W,handleEdgeChanges:U}=ms(),Q=yl();pp({saveHistory:b}),Ep({saveHistory:b}),Cp();let ee=(0,Vt.useCallback)(()=>{o([]),i([]),X(),setTimeout(Q,0)},[o,i,X,Q]),{selectElements:te,clearSelection:Ee}=Kt(),{importFromMxGraph:fe,exportToMxGraph:ae}=Ho(),{configureElement:Me,getConfigureElement:Pe}=Xi(),lt=(0,Vt.useCallback)(he=>{he!=null&&he.id&&te([he.id])},[te]),{sendMessage:q}=_s({LIA_CREATE_DIAGRAM:D,CLEAR_DIAGRAM:ee,TASKS_STATUS:H,CLEAR_TASKS_STATUS:z,EXTERNAL_TASK_SELECT:lt}),se=(0,Vt.useCallback)(()=>t.length+r.length,[t,r]);(0,Vt.useEffect)(()=>(oo.set(u,{importFromMxGraph:fe,exportToMxGraph:ae,selectElements:te,clearSelection:Ee,configureElement:Me,getConfigureElement:Pe,getElementsCount:se,setReconnectingEdge:$,clearReconnectingEdge:K}),()=>{oo.delete(u)}),[u,fe,ae,te,Ee,Me,Pe,se,$,K]);let oe=(0,Vt.useCallback)((he,_e)=>{if(_e.type!=="TASK"&&_e.type!=="GATEWAY")return;let be=Pe(_e.id);be&&(x==null||x(be)),_e.type==="TASK"&&q("SELECT_TASK",{id:_e.id})},[Pe,x,q]),le=(0,Vt.useCallback)((he,_e)=>{if(_e.type!=="SEQUENCE_EDGE")return;let be=l(_e.source),Fe=l(_e.target),{isFromStartEvent:Oe,isGatewayToGateway:je,isActiviyToAndGateway:Je,isToEndEvent:ut}=si(be,Fe);if(!(!Oe&&!je&&!Je&&!ut))return;let po=Pe(_e.id);po&&(x==null||x(po))},[Pe,l,x]),we=(0,Vt.useCallback)(he=>{E(he,t),n(he),!ai(he)&&(b(he),Y()||R(),B()||W(he))},[t,b,Y,R,E,W,B]),Qe=(0,Vt.useCallback)(he=>{s(he),b(he),Y()||R(),B()||U(he)},[s,b,Y,R,U,B]);bp(we);let Ze=(0,Vt.useCallback)(async({nodes:he})=>he.some(be=>be.type==="LANE"&&t.some(Fe=>Fe.parentId===be.id))?(c({variant:"error",title:e("validation.errors.title"),content:e("editor.toolbar.delete_pool_lane_error")}),!1):!0,[t,e,c]),dt=()=>{b("forceSave"),Z(),R()},co=()=>{f(!0)},uo=()=>{f(!1),R()},Ut=(0,Vt.useCallback)(he=>{let _e=new Set(he.filter(be=>be.type==="LANE"&&!!be.parentId).map(be=>be.parentId));_e.size!==0&&setTimeout(()=>{var Oe,je;let be=a(),Fe=new Map(be.map(Je=>[Je.id,Je]));for(let Je of _e){let ut=Zo(be.filter(fo=>fo.type==="LANE"&&fo.parentId===Je));if(ut.length===0)continue;let vo=0;for(let fo of ut)Fe.set(fo.id,w(_({},fo),{position:{x:ie.HEADER_WIDTH,y:vo}})),vo+=(je=(Oe=fo.measured)==null?void 0:Oe.height)!=null?je:0;let po=Fe.get(Je);po&&Fe.set(Je,w(_({},po),{height:vo,measured:w(_({},po.measured),{height:vo})}))}o(be.map(Je=>{var ut;return(ut=Fe.get(Je.id))!=null?ut:Je}))},0)},[a,o]);return{nodes:t,setNodes:o,edges:r,setEdges:i,events:{isValidConnection:k,onConnect:O,onReconnect:V,onReconnectStart:F,onReconnectEnd:j,onDrop:T,onDragOver:N,onDragLeave:C,onNodeDrag:I,onNodeDragStop:M,onNodeDragStart:L,onNodeClick:oe,onEdgeClick:le,onDropCapture:dt,onConnectStart:co,onConnectEnd:uo,onSelectionEnd:()=>setTimeout(()=>d.setState({nodesSelectionActive:!1}),0),onNodesChange:we,onEdgesChange:Qe,onBeforeDelete:Ze,onNodesDelete:Ut},ui:{handleCloseValidationPanel:P},controls:{undo:h,redo:m,canUndo:y,canRedo:v},components:{HelperLines:g},actions:{saveHistory:b,selectElements:te,clearSelection:Ee,exportToMxGraph:ae,validateDiagram:S,handleValidationComplete:A,setReconnectingEdge:$,clearReconnectingEdge:K}}};var Vp=require("react"),Hp=require("@xyflow/react");function bs(){return(0,Hp.useStore)((0,Vp.useCallback)(e=>e.nodes.length+e.edges.length>0,[]))}var Gp=require("@xyflow/react"),zo=require("react");var Ay=".react-flow__node, .react-flow__edge, .react-flow__node-toolbar";function Bp(e,t,o){let[n,r]=(0,zo.useState)(!1),i=(0,zo.useRef)(null),{getViewport:s,setViewport:a}=(0,Gp.useReactFlow)(),l=(0,zo.useCallback)(()=>{i.current=null,r(!1)},[]);return(0,zo.useEffect)(()=>{let c=e.current;if(!c)return;let d=f=>{if(!Dr.some(E=>E===f.button)||t.current||o.current||(r(!0),!(f.target instanceof Element))||!f.target.closest(Ay))return;f.preventDefault(),f.stopPropagation();let x=s();i.current={pointerX:f.clientX,pointerY:f.clientY,viewportX:x.x,viewportY:x.y,zoom:x.zoom}},u=f=>{let x=i.current;if(x){if((f.buttons&ba)===0){l();return}a({x:x.viewportX+(f.clientX-x.pointerX),y:x.viewportY+(f.clientY-x.pointerY),zoom:x.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 wa=require("react/jsx-runtime"),Ts=({id:e,className:t})=>(0,wa.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,wa.jsx)("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});var gn=require("react/jsx-runtime"),zp=()=>(0,gn.jsx)("svg",{style:{position:"absolute",top:0,left:0},children:(0,gn.jsxs)("defs",{children:[(0,gn.jsx)(Ts,{id:"sequence-edge-marker",className:"text-grey-500"}),(0,gn.jsx)(Ts,{id:"sequence-edge-marker-hovered",className:"text-grey-800"}),(0,gn.jsx)(Ts,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});var Wo=require("@produto-lecom/lecom-ui");var Wr=require("@xyflow/react"),ze=require("@produto-lecom/lecom-ui"),so=require("lucide-react"),Wt=nr(require("react"),1);var Yo=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"),Jp=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 Yp({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 Fp(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}var kM={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},Wp={script:"SCRIPT",subprocess:"SUBPROCESS"},Xp={"marker-loop":"LOOP"},Up={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL",inclusive:"EXCLUSIVE"};var hn=({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}}},Sy=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:hn({cell:e,type:"START_EVENT"}),status:n,originalType:o}},My=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:hn({cell:e,type:"END_EVENT"}),status:n,originalType:o}},Py=(e,t)=>{let{id:o,subType:n,style:r}=e==null?void 0:e._attributes,i=Wp[n],s=t.get(o)||"",a=Xp[s]||"",l=a==="LOOP",c="imported";return!["script","none"].includes(n)&&!l&&(c="adapted"),e.mxGeometry._attributes.width=wo(e.mxGeometry._attributes.width||0,de.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=wo(e.mxGeometry._attributes.height||0,de.TASK.MIN_HEIGHT),{node:hn({cell:e,type:"TASK",variant:i,attribute:a}),status:c,originalType:r}},Ly=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=Up[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:hn({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},ky=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:hn({cell:e,type:"LANE"}),status:"imported",originalType:t}},Ry=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=wo(e.mxGeometry._attributes.width||0,de.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=wo(e.mxGeometry._attributes.height||0,de.ANNOTATION.MIN_HEIGHT),{node:hn({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},$p=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:hn({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},Kp=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return w(_({},Rt),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},qp={TASK:Py,GATEWAY:Ly,START_EVENT:Sy,END_EVENT:My,LANE:ky,ANNOTATION:Ry};var Dy=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]||$p,{node:d,status:u,originalType:p}=c(a,r);s.push(d),i.push({originalType:p,type:d.type,variant:d.data.variant,value:Fp(d.data.label),status:u})}return{nodes:s,governanceIdToNodeIdMap:t,summary:i}},Oy=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>Kp(r,t)),Vy=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=Dy(t.root.mxCell),i=Oy(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},Hy=async e=>{let t=await vs(e),o=ns(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}},Zp=async e=>{try{let t=await Hy(e),{nodes:o,edges:n,summary:r}=Vy(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};var jp=require("react/jsx-runtime"),Qp=()=>{let{t:e}=(0,ws.useTranslation)(),{toast:t}=rt(),{setNodes:o,setEdges:n}=(0,Jp.useReactFlow)(),{fitToNodes:r}=Vo(),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,jp.jsx)(ws.Button,{size:"small",variant:"ghost",onClick:()=>Yp({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 Zp(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 ef=require("@produto-lecom/lecom-ui"),tf=require("react");var yn=require("react/jsx-runtime"),of=a=>{var l=a,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,s=$t(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=(0,tf.useRef)(null),d=p=>{let f=p.target.files;f!=null&&f.length&&i(f),c.current&&(c.current.value="")};return(0,yn.jsxs)(yn.Fragment,{children:[(0,yn.jsx)(ef.Button,w(_({disabled:n,onClick:p=>{var f;(f=c.current)==null||f.click(),r==null||r(p)}},s),{children:e})),(0,yn.jsx)("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};var xn=require("react/jsx-runtime"),nf=({disabled:e=!1})=>{let{t}=(0,Yo.useTranslation)(),{toast:o}=rt(),{importFromGovernance:n}=Qp(),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,xn.jsxs)(Yo.Tooltip,{children:[(0,xn.jsx)(Yo.TooltipTrigger,{asChild:!0,children:(0,xn.jsx)(of,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:(0,xn.jsx)(Ka,{})})}),(0,xn.jsx)(Yo.TooltipContent,{color:"black",children:t(e?"adapter.governance.error.ALREADY_INITIALIZED":"editor.controls.actions.import_governance")})]})};var rf=require("react/jsx-runtime"),Ia=({shortcut:e})=>(0,rf.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 xe=require("@produto-lecom/lecom-ui"),Fo=require("lucide-react"),ff=require("react");var cf=require("@produto-lecom/lecom-ui"),df=require("@xyflow/react"),Yr=require("html-to-image"),uf=require("react");var sf=require("@xyflow/react"),af=(e,t=0)=>{let o=(0,sf.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 Gy=3,Aa="diagram",Ca=50,By=e=>e instanceof Element&&e.closest("[data-export-hidden]")!==null,Sa=e=>!By(e),zy=96,Yy=25.4,Fy="sequence-edge-marker",lf=e=>e*Yy/zy,Wy=e=>{let t=document.getElementById(Fy);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},pf=()=>{let{t:e}=(0,cf.useTranslation)(),{toast:t}=rt(),{getEdges:o,getNodes:n,getNodesBounds:r}=(0,df.useReactFlow)(),{clearSelection:i}=Kt(),[s,a]=(0,uf.useState)({png:!1,html:!1,print:!1}),l=()=>{let{x:f,y:x,width:E,height:g}=af(n(),Ca),h=Ca-f,m=Ca-x;return{width:E,height:g,style:{width:`${E}px`,height:`${g}px`,transform:`translate(${h}px, ${m}px)`,transformOrigin:"top left"}}},c=async(f,x)=>{a(E=>w(_({},E),{[x]:!0})),await i();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=su();if(!h)throw new Error("Flow element not found");let m=l(),y=Wy(h);try{return await f(h,m)}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{a(E=>w(_({},E),{[x]:!1}))}};return{exportAsPng:async(f=Aa)=>{await c(async(x,E)=>{let g=await(0,Yr.toPng)(x,w(_({},E),{backgroundColor:"#fcfcfc",skipFonts:!0,filter:Sa}));Ns(g,`${f}.png`)},"png")},exportAsHtml:async(f=Aa)=>{await c(async(x,E)=>{let g=await(0,Yr.toSvg)(x,w(_({},E),{backgroundColor:"#fcfcfc",skipFonts:!0,filter:Sa})),h=`
44
44
  <!DOCTYPE html>
45
45
  <html>
46
46
  <head>
47
47
  <meta charset="utf-8" />
48
- <title>${m}</title>
48
+ <title>${f}</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="${u}" alt="${m}" />
68
+ <img src="${g}" alt="${f}" />
69
69
  </body>
70
- </html>`,h=new Blob([g],{type:"text/html"}),x=URL.createObjectURL(h);bs(x,`${m}.html`),window.setTimeout(()=>URL.revokeObjectURL(x),1e4)},"html")},printDiagram:async(m=va)=>{await c(async(y,E)=>{var C;let u=await(0,zr.toPng)(y,w(_({},E),{backgroundColor:"#fcfcfc",pixelRatio:Cy,skipFonts:!0})),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 h=(C=g.contentWindow)==null?void 0:C.document;if(!h)throw document.body.removeChild(g),new Error("Unable to access print iframe document");let x=Kp(E.width).toFixed(2),T=Kp(E.height).toFixed(2),b=h.createElement("style");b.textContent=`
70
+ </html>`,m=new Blob([h],{type:"text/html"}),y=URL.createObjectURL(m);Ns(y,`${f}.html`),window.setTimeout(()=>URL.revokeObjectURL(y),1e4)},"html")},printDiagram:async(f=Aa)=>{await c(async(x,E)=>{var C;let g=await(0,Yr.toPng)(x,w(_({},E),{backgroundColor:"#fcfcfc",pixelRatio:Gy,skipFonts:!0,filter:Sa})),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 m=(C=h.contentWindow)==null?void 0:C.document;if(!m)throw document.body.removeChild(h),new Error("Unable to access print iframe document");let y=lf(E.width).toFixed(2),v=lf(E.height).toFixed(2),b=m.createElement("style");b.textContent=`
71
71
  @page {
72
- size: ${x}mm ${T}mm;
72
+ size: ${y}mm ${v}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
- `,h.head.appendChild(b),h.title=m;let N=h.createElement("img");N.alt="Diagram",h.body.appendChild(N),await new Promise((P,R)=>{let S=!1,L=K=>{S||(S=!0,K?R(K):P())};N.onload=()=>L(),N.onerror=()=>L(new Error("Failed to load print image")),N.src=u,N.complete&&N.naturalWidth>0&&L()});let v=g.contentWindow;if(!v)throw document.body.removeChild(g),new Error("Unable to access print iframe window");let I=()=>{g.parentNode&&document.body.removeChild(g)};v.addEventListener("afterprint",I,{once:!0}),window.setTimeout(I,6e4),v.focus(),v.print()},"print")},isPrintingPng:a.png,isPrintingHtml:a.html,isPrinting:a.print}};var Ie=require("react/jsx-runtime");function ef(){let{t:e}=(0,Te.useTranslation)(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:a}=Qp(),[s,l]=(0,jp.useState)(!1);return(0,Ie.jsxs)(Te.DropdownMenu,{modal:!1,open:s,onOpenChange:l,children:[(0,Ie.jsx)(Te.DropdownMenuTrigger,{asChild:!0,children:(0,Ie.jsx)("div",{children:(0,Ie.jsxs)(Te.Tooltip,{children:[(0,Ie.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,Ie.jsx)(Te.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:(0,Ie.jsx)(Wo.FolderOutputIcon,{})})}),!s&&(0,Ie.jsx)(Te.TooltipContent,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),(0,Ie.jsxs)(Te.DropdownMenuContent,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[(0,Ie.jsxs)(Te.Tooltip,{children:[(0,Ie.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,Ie.jsx)(Te.DropdownMenuItem,{className:"p-1.5",disabled:i,onClick:()=>t(),children:(0,Ie.jsx)(Wo.FileImageIcon,{})})}),(0,Ie.jsx)(Te.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),(0,Ie.jsxs)(Te.Tooltip,{children:[(0,Ie.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,Ie.jsx)(Te.DropdownMenuItem,{className:"p-1.5",disabled:a,onClick:()=>o(),children:(0,Ie.jsx)(Wo.FileCodeIcon,{})})}),(0,Ie.jsx)(Te.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),(0,Ie.jsxs)(Te.Tooltip,{children:[(0,Ie.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,Ie.jsx)(Te.DropdownMenuItem,{className:"p-1.5",disabled:r,onClick:()=>n(),children:(0,Ie.jsx)(Wo.PrinterIcon,{})})}),(0,Ie.jsx)(Te.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}var ke=require("@produto-lecom/lecom-ui"),Kn=require("lucide-react"),Yr=require("react");var Na=require("react"),je=require("@produto-lecom/lecom-ui");var tf=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 Ht=require("react/jsx-runtime"),ky=`Um passo (A --> B) por linha, com um ID antes de cada n\xF3. Ex.:
86
+ `,m.head.appendChild(b),m.title=f;let I=m.createElement("img");I.alt="Diagram",m.body.appendChild(I),await new Promise((M,L)=>{let k=!1,O=V=>{k||(k=!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 T=h.contentWindow;if(!T)throw document.body.removeChild(h),new Error("Unable to access print iframe window");let N=()=>{h.parentNode&&document.body.removeChild(h)};T.addEventListener("afterprint",N,{once:!0}),window.setTimeout(N,6e4),T.focus(),T.print()},"print")},isPrintingPng:s.png,isPrintingHtml:s.html,isPrinting:s.print}};var ve=require("react/jsx-runtime");function mf(){let{t:e}=(0,xe.useTranslation)(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:s}=pf(),[a,l]=(0,ff.useState)(!1);return(0,ve.jsxs)(xe.DropdownMenu,{modal:!1,open:a,onOpenChange:l,children:[(0,ve.jsx)(xe.DropdownMenuTrigger,{asChild:!0,children:(0,ve.jsx)("div",{children:(0,ve.jsxs)(xe.Tooltip,{children:[(0,ve.jsx)(xe.TooltipTrigger,{asChild:!0,children:(0,ve.jsx)(xe.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:(0,ve.jsx)(Fo.FolderOutputIcon,{})})}),!a&&(0,ve.jsx)(xe.TooltipContent,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),(0,ve.jsxs)(xe.DropdownMenuContent,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[(0,ve.jsxs)(xe.Tooltip,{children:[(0,ve.jsx)(xe.TooltipTrigger,{asChild:!0,children:(0,ve.jsx)(xe.DropdownMenuItem,{className:"p-1.5",disabled:i,onClick:()=>t(),children:(0,ve.jsx)(Fo.FileImageIcon,{})})}),(0,ve.jsx)(xe.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),(0,ve.jsxs)(xe.Tooltip,{children:[(0,ve.jsx)(xe.TooltipTrigger,{asChild:!0,children:(0,ve.jsx)(xe.DropdownMenuItem,{className:"p-1.5",disabled:s,onClick:()=>o(),children:(0,ve.jsx)(Fo.FileCodeIcon,{})})}),(0,ve.jsx)(xe.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),(0,ve.jsxs)(xe.Tooltip,{children:[(0,ve.jsx)(xe.TooltipTrigger,{asChild:!0,children:(0,ve.jsx)(xe.DropdownMenuItem,{className:"p-1.5",disabled:r,onClick:()=>n(),children:(0,ve.jsx)(Fo.PrinterIcon,{})})}),(0,ve.jsx)(xe.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}var Ce=require("@produto-lecom/lecom-ui"),Qn=require("lucide-react"),Fr=require("react");var Ma=require("react"),nt=require("@produto-lecom/lecom-ui");var gf=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 Ht=require("react/jsx-runtime"),Xy=`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>`,of=({open:e,onOpenChange:t})=>{let{t:o}=(0,je.useTranslation)(),{importFromLia:n}=hs(),[r,i]=(0,Na.useState)(""),[a,s]=(0,Na.useState)(null),l=d=>{d||(i(""),s(null)),t(d)},c=()=>{let d=tf(r);if(!d){s(o("editor.modals.mermaid_import.error_empty"));return}try{n(d),l(!1)}catch(p){console.error("Falha ao gerar o diagrama a partir de Mermaid:",p),s(o("editor.modals.mermaid_import.error_parse"))}};return(0,Ht.jsx)(je.Dialog,{open:e,onOpenChange:l,children:(0,Ht.jsxs)(je.DialogContent,{className:"w-[90vw] max-w-4xl",children:[(0,Ht.jsxs)(je.DialogHeader,{children:[(0,Ht.jsx)(je.DialogTitle,{children:o("editor.modals.mermaid_import.title")}),(0,Ht.jsx)(je.DialogDescription,{children:o("editor.modals.mermaid_import.description")})]}),(0,Ht.jsx)(je.Textarea,{value:r,onChange:d=>{i(d.target.value),a&&s(null)},placeholder:ky,rows:16,className:"max-h-[60vh] min-h-[360px] resize-y font-mono"}),a&&(0,Ht.jsx)("p",{className:"text-sm text-red-500",children:a}),(0,Ht.jsxs)(je.DialogFooter,{children:[(0,Ht.jsx)(je.Button,{variant:"ghost",color:"grey",onClick:()=>l(!1),children:o("editor.modals.mermaid_import.cancel")}),(0,Ht.jsx)(je.Button,{variant:"filled",color:"blue",onClick:c,children:o("editor.modals.mermaid_import.generate")})]})]})})};var Ae=require("react/jsx-runtime"),Ry=".xml,text/xml,application/xml";function nf(){let{t:e}=(0,ke.useTranslation)(),{importFromMxGraph:t}=Bo(),{toast:o}=et(),[n,r]=(0,Yr.useState)(!1),[i,a]=(0,Yr.useState)(!1),s=(0,Yr.useRef)(null),l=async c=>{var p;let d=(p=c.target.files)==null?void 0:p[0];if(c.target.value="",!!d)try{let f=await _s(d);await t(f)}catch(f){console.error("Falha ao importar o XML:",f),o({variant:"error",content:e("editor.controls.actions.import.feedback.error")})}};return(0,Ae.jsxs)(Ae.Fragment,{children:[(0,Ae.jsxs)(ke.DropdownMenu,{modal:!1,open:n,onOpenChange:r,children:[(0,Ae.jsx)(ke.DropdownMenuTrigger,{asChild:!0,children:(0,Ae.jsx)("div",{children:(0,Ae.jsxs)(ke.Tooltip,{children:[(0,Ae.jsx)(ke.TooltipTrigger,{asChild:!0,children:(0,Ae.jsx)(ke.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:(0,Ae.jsx)(Kn.ClipboardPasteIcon,{})})}),!n&&(0,Ae.jsx)(ke.TooltipContent,{color:"black",children:e("editor.controls.actions.import.title")})]})})}),(0,Ae.jsxs)(ke.DropdownMenuContent,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[(0,Ae.jsxs)(ke.Tooltip,{children:[(0,Ae.jsx)(ke.TooltipTrigger,{asChild:!0,children:(0,Ae.jsx)(ke.DropdownMenuItem,{className:"p-1.5",onClick:()=>{var c;return(c=s.current)==null?void 0:c.click()},children:(0,Ae.jsx)(Kn.FileCodeIcon,{})})}),(0,Ae.jsx)(ke.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.import.xml")})]}),(0,Ae.jsxs)(ke.Tooltip,{children:[(0,Ae.jsx)(ke.TooltipTrigger,{asChild:!0,children:(0,Ae.jsx)(ke.DropdownMenuItem,{className:"p-1.5",onClick:()=>a(!0),children:(0,Ae.jsx)(Kn.CircleIcon,{})})}),(0,Ae.jsx)(ke.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.import.mermaid")})]})]})]}),(0,Ae.jsx)("input",{ref:s,type:"file",className:"sr-only",accept:Ry,onChange:l}),(0,Ae.jsx)(of,{open:i,onOpenChange:a})]})}var Ns=require("react"),Re=require("@produto-lecom/lecom-ui"),rf=require("@xyflow/react"),qn=require("lucide-react");var qe=require("react/jsx-runtime");function sf(){let{t:e}=(0,Re.useTranslation)(),{getNodes:t,getEdges:o,setNodes:n}=(0,rf.useReactFlow)(),{fitToNodes:r}=Go(),{toast:i}=et(),[a,s]=(0,Ns.useState)(!1),l=(0,Ns.useCallback)(c=>{let d=t();if(d.length===0)return;if(d.some(u=>u.parentId)){i({content:e("editor.controls.actions.organize.feedback.pool_lane"),variant:"warning"});return}let f=d.map(u=>{var g,h,x,T;return w(_({},u),{width:(h=u.width)!=null?h:(g=u.measured)==null?void 0:g.width,height:(T=u.height)!=null?T:(x=u.measured)==null?void 0:x.height})}),{nodes:m}=ns(f,o(),c),y=new Map(m.map(u=>[u.id,u.position])),E=d.map(u=>{var g;return w(_({},u),{position:(g=y.get(u.id))!=null?g:u.position})});n(E),r(E)},[t,o,n,r,i,e]);return(0,qe.jsxs)(Re.DropdownMenu,{modal:!1,open:a,onOpenChange:s,children:[(0,qe.jsx)(Re.DropdownMenuTrigger,{asChild:!0,children:(0,qe.jsx)("div",{children:(0,qe.jsxs)(Re.Tooltip,{children:[(0,qe.jsx)(Re.TooltipTrigger,{asChild:!0,children:(0,qe.jsx)(Re.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:(0,qe.jsx)(qn.NetworkIcon,{})})}),!a&&(0,qe.jsx)(Re.TooltipContent,{color:"black",children:e("editor.controls.actions.organize.title")})]})})}),(0,qe.jsxs)(Re.DropdownMenuContent,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[(0,qe.jsxs)(Re.Tooltip,{children:[(0,qe.jsx)(Re.TooltipTrigger,{asChild:!0,children:(0,qe.jsx)(Re.DropdownMenuItem,{className:"p-1.5",onClick:()=>l("TB"),children:(0,qe.jsx)(qn.AlignVerticalJustifyStartIcon,{})})}),(0,qe.jsx)(Re.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.organize.vertical")})]}),(0,qe.jsxs)(Re.Tooltip,{children:[(0,qe.jsx)(Re.TooltipTrigger,{asChild:!0,children:(0,qe.jsx)(Re.DropdownMenuItem,{className:"p-1.5",onClick:()=>l("LR"),children:(0,qe.jsx)(qn.AlignHorizontalJustifyStartIcon,{})})}),(0,qe.jsx)(Re.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.organize.horizontal")})]})]})]})}var pe=require("react/jsx-runtime"),af=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=(0,Fe.useTranslation)(),{clearSelection:i}=Zt(),{mode:a,containerRef:s,featureFlags:l,isMinimapOpen:c,setIsMinimapOpen:d,isMoveTool:p,isHandTool:f,setIsMoveTool:m,setIsHandTool:y}=q(),{getNodes:E,getEdges:u}=(0,Fr.useReactFlow)(),g=(0,Fr.useKeyPress)(["v","V"],{target:s==null?void 0:s.current}),h=(0,Fr.useKeyPress)(["h","H"],{target:s==null?void 0:s.current}),x=(0,vo.useCallback)(()=>{i(),y(!0),m(!1)},[i,y,m]),T=(0,vo.useCallback)(()=>{m(!0),y(!1)},[m,y]),[b,N]=(0,vo.useState)(!1),v=(0,vo.useCallback)(async()=>{N(!0);try{let I=E(),C=u(),P=await o({nodes:I,edges:C});n(P)}finally{N(!1)}},[E,u,o,n]);return(0,vo.useEffect)(()=>{g&&!p&&a==="edit"&&T()},[g,T,p,a]),(0,vo.useEffect)(()=>{h&&!f&&a==="edit"&&x()},[h,x,f,a]),(0,pe.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[a==="edit"&&(0,pe.jsxs)(pe.Fragment,{children:[(0,pe.jsxs)(Fe.Tooltip,{children:[(0,pe.jsx)(Fe.TooltipTrigger,{asChild:!0,children:(0,pe.jsx)(Fe.Button,{size:"small",variant:"ghost",color:"grey",className:H(p&&"bg-grey-400"),iconButton:!0,onClick:T,children:(0,pe.jsx)(ao.MousePointerIcon,{})})}),(0,pe.jsxs)(Fe.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),(0,pe.jsx)(Ta,{shortcut:"V"})]})]}),(0,pe.jsxs)(Fe.Tooltip,{children:[(0,pe.jsx)(Fe.TooltipTrigger,{asChild:!0,children:(0,pe.jsx)(Fe.Button,{size:"small",variant:"ghost",color:"grey",className:H(f&&"bg-grey-400"),iconButton:!0,onClick:x,children:(0,pe.jsx)(ao.HandIcon,{})})}),(0,pe.jsxs)(Fe.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",(0,pe.jsx)(Ta,{shortcut:"H"})]})]})]}),(0,pe.jsx)(ef,{}),a==="edit"&&(0,pe.jsxs)(pe.Fragment,{children:[(l==null?void 0:l.importDiagramMermaidEnabled)&&(0,pe.jsxs)(pe.Fragment,{children:[(0,pe.jsx)(nf,{}),(0,pe.jsx)(sf,{})]}),(0,pe.jsxs)(Fe.Tooltip,{children:[(0,pe.jsx)(Fe.TooltipTrigger,{asChild:!0,children:(0,pe.jsx)(Fe.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:b,onClick:v,children:b?(0,pe.jsx)(ao.Loader2Icon,{className:"animate-spin"}):(0,pe.jsx)(ao.ListCheckIcon,{})})}),(0,pe.jsx)(Fe.TooltipContent,{color:"black",children:r(b?"editor.controls.actions.check_loading":"editor.controls.actions.check")})]}),(0,pe.jsx)(Up,{disabled:e.length>0||t.length>0})]}),(0,pe.jsxs)(Fe.Tooltip,{children:[(0,pe.jsx)(Fe.TooltipTrigger,{asChild:!0,children:(0,pe.jsx)(Fe.Button,{size:"small",variant:"ghost",color:"grey",className:H(c&&"bg-grey-400"),iconButton:!0,onClick:()=>d(!c),children:(0,pe.jsx)(ao.MapIcon,{})})}),(0,pe.jsx)(Fe.TooltipContent,{color:"black",children:r(c?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};var mt=require("@produto-lecom/lecom-ui"),ws=require("lucide-react"),Ct=require("react/jsx-runtime"),lf=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=(0,mt.useTranslation)();return(0,Ct.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,Ct.jsxs)(mt.Tooltip,{children:[(0,Ct.jsx)(mt.TooltipTrigger,{asChild:!0,children:(0,Ct.jsx)(mt.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:(0,Ct.jsx)(ws.UndoIcon,{})})}),(0,Ct.jsx)(mt.TooltipContent,{color:"black",children:r("editor.controls.history.undo")})]}),(0,Ct.jsxs)(mt.Tooltip,{children:[(0,Ct.jsx)(mt.TooltipTrigger,{asChild:!0,children:(0,Ct.jsx)(mt.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:(0,Ct.jsx)(ws.RedoIcon,{})})}),(0,Ct.jsx)(mt.TooltipContent,{color:"black",children:r("editor.controls.history.redo")})]})]})};var Zn=require("@xyflow/react"),We=require("@produto-lecom/lecom-ui"),Jn=require("lucide-react");var Be=require("react/jsx-runtime"),cf=()=>{let{t:e}=(0,We.useTranslation)(),t=(0,Zn.useNodes)(),o=(0,Zn.useEdges)(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:a}=(0,Zn.useReactFlow)(),s=t.length===0&&o.length===0;return(0,Be.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,Be.jsxs)(We.Tooltip,{children:[(0,Be.jsx)(We.TooltipTrigger,{asChild:!0,children:(0,Be.jsx)(We.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>a(),children:(0,Be.jsx)(Jn.ScanIcon,{})})}),(0,Be.jsx)(We.TooltipContent,{color:"black",children:e("editor.controls.zoom.fit")})]}),(0,Be.jsxs)(We.Tooltip,{children:[(0,Be.jsx)(We.TooltipTrigger,{asChild:!0,children:(0,Be.jsx)(We.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>r(),children:(0,Be.jsx)(Jn.ZoomOut,{})})}),(0,Be.jsx)(We.TooltipContent,{color:"black",children:e("editor.controls.zoom.out")})]}),(0,Be.jsxs)(We.Tooltip,{children:[(0,Be.jsx)(We.TooltipTrigger,{asChild:!0,children:(0,Be.jsx)(We.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>i(1),children:(0,Be.jsx)(Ya,{})})}),(0,Be.jsx)(We.TooltipContent,{color:"black",children:e("editor.controls.zoom.reset")})]}),(0,Be.jsxs)(We.Tooltip,{children:[(0,Be.jsx)(We.TooltipTrigger,{asChild:!0,children:(0,Be.jsx)(We.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>n(),children:(0,Be.jsx)(Jn.ZoomIn,{})})}),(0,Be.jsx)(We.TooltipContent,{color:"black",children:e("editor.controls.zoom.in")})]})]})};var df=require("@xyflow/react"),yn=require("react/jsx-runtime"),uf=()=>(0,yn.jsxs)(df.ViewportPortal,{children:[(0,yn.jsxs)("svg",{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",{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 pf=require("@xyflow/react"),lo=require("@produto-lecom/lecom-ui"),Is=require("react");var ff=require("lucide-react");var Xt=require("react/jsx-runtime"),mf=()=>{let e=(0,Is.useRef)(null),{t}=(0,lo.useTranslation)(),{setDraggableNode:o}=Un(),n=(0,pf.useNodes)(),{setIsDragging:r}=q(),[i,a]=(0,Is.useState)(void 0),s=[{type:"START_EVENT",icon:jr,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:En,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:or,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:nr,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SERVICE_TASK",icon:ff.Bot,label:t("bpmn.task.variant.service_task")},{type:"TASK",variant:"SCRIPT",icon:Wa,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:Fa,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:za,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:Zr,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),a((0,Xt.jsx)(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return(0,Xt.jsxs)("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[(0,Xt.jsx)("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:s.map((c,d)=>{let p=!Ro(c.type,n),f=p?t("editor.toolbar.start_event_already_exists"):c.label;return(0,Xt.jsxs)(lo.Tooltip,{children:[(0,Xt.jsx)(lo.TooltipTrigger,{asChild:!0,children:(0,Xt.jsx)(lo.Button,{className:H("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":p}),size:"small",variant:"ghost",color:"grey",draggable:!p,disabled:p,iconButton:!0,onDragStart:p?void 0:m=>l(m,c),children:(0,Xt.jsx)(c.icon,{})},d)}),(0,Xt.jsx)(lo.TooltipContent,{color:"black",side:"right",children:f})]},d)})}),(0,Xt.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"),wa=e=>e.preventDefault(),Ia=(0,xn.forwardRef)((e,t)=>{let{instanceId:o,containerRef:n,mode:r,isMinimapOpen:i,isMoveTool:a,isHandTool:s}=q(),l=(0,co.useKeyPress)("Space",{target:n==null?void 0:n.current}),c=(0,xn.useRef)(s),d=(0,xn.useRef)(l),{nodes:p,edges:f,actions:m,events:y,components:E,controls:u}=Ap(),{t:g}=(0,Xo.useTranslation)();c.current=s,d.current=l;let h=Sp(n,c,d);(0,xn.useImperativeHandle)(t,()=>({selectElements:m.selectElements,clearSelection:m.clearSelection}));let x=s||l||r!=="edit",T=x?[0,1,2]:Rr,b=s||l||h,N=a&&!l&&!h,v=r==="edit"&&N,I=!x&&!h,C=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)(mf,{}),(0,tt.jsx)(Mp,{}),(0,tt.jsxs)(co.ReactFlow,w(_({},y),{id:`modeler-${o}`,className:H(r.toLowerCase(),{"is-hand-tool":b,"is-pan-tool-active":b}),edges:f,nodes:p,nodeTypes:_u,edgeTypes:bu,minZoom:ha,maxZoom:Au,panOnDrag:T,panOnScroll:!0,selectionOnDrag:I,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:C,nodesConnectable:v,nodesDraggable:v,connectionLineComponent:yu,selectionMode:co.SelectionMode.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:v?"Delete":null,selectionKeyCode:null,defaultViewport:Lu,connectOnClick:!1,connectionRadius:50,onPaneContextMenu:wa,onNodeContextMenu:wa,onEdgeContextMenu:wa,proOptions:{hideAttribution:!0},children:[(0,tt.jsx)(co.Background,{gap:wu,size:Nu,color:vu,bgColor:Tu}),(0,tt.jsx)(uf,{}),i&&(0,tt.jsxs)(Xo.Tooltip,{children:[(0,tt.jsx)(Xo.TooltipTrigger,{asChild:!0,children:(0,tt.jsx)("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:(0,tt.jsx)(co.MiniMap,{pannable:!0,zoomable:!0,position:Iu,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),(0,tt.jsx)(Xo.TooltipContent,{color:"black",children:g("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)(lf,_({},u)),r!=="readonly"&&(0,tt.jsx)(af,{nodes:p,edges:f,validateDiagram:m.validateDiagram,handleValidationComplete:m.handleValidationComplete}),(0,tt.jsx)(cf,{})]}),(0,tt.jsx)(E.HelperLines,{})]}))]})});Ia.displayName="Editor";var gf=require("@xyflow/react"),As=require("react"),hf=require("react/jsx-runtime"),Dy=e=>({width:e.width,height:e.height,transform:e.transform}),Aa="rgba(51, 103, 217, 0.4)",nd=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=(0,gf.useStore)(Dy),i=(0,As.useRef)(null);return(0,As.useEffect)(()=>{let a=i.current,s=a==null?void 0:a.getContext("2d");if(!s||!a)return;let l=window.devicePixelRatio;a.width=o*l,a.height=n*l,s.clearRect(0,0,o,n),s.scale(l,l),s.strokeStyle=Aa,t&&(s.beginPath(),s.strokeStyle=t.color||Aa,s.moveTo(t.position*r[2]+r[0],0),s.lineTo(t.position*r[2]+r[0],n),s.stroke()),e&&(s.beginPath(),s.strokeStyle=e.color||Aa,s.moveTo(0,e.position*r[2]+r[1]),s.lineTo(o,e.position*r[2]+r[1]),s.stroke())},[o,n,r,e,t]),(0,hf.jsx)("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};var Qn=require("@produto-lecom/lecom-ui"),Uo=require("react");var Wr=require("react/jsx-runtime"),oo=new Map,yf=(0,Uo.createContext)(null),On=()=>{let e=(0,Uo.useContext)(yf);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},xf=({locale:e,defaultMode:t="view",featureFlags:o,toast:n,children:r})=>{let[i,a]=(0,Uo.useState)(e||"pt_BR");(0,Uo.useEffect)(()=>{e&&(a(e),Qn.i18n.changeLanguage(e))},[e]);let s=E=>{let u=oo.size;if(u===0)throw new Error("No modeler instances found");if(u===1||!E){let[h]=oo.values();return h}let g=oo.get(E);if(!g)throw new Error(`Modeler instance with ID "${E}" not found`);return g},l=(E,u)=>{let g=s(u);return g==null?void 0:g.selectElements(E)},c=async E=>{let u=s(E);return u==null?void 0:u.clearSelection()},d=(E,u)=>{let g=s(u);return g==null?void 0:g.configureElement(E)},p=(E,u)=>{let g=s(u);return g==null?void 0:g.getConfigureElement(E)},f=async(E,u)=>{let g=s(u);await(g==null?void 0:g.importFromMxGraph(E))},m=E=>{let u=s(E);return u==null?void 0:u.exportToMxGraph()},y=E=>{let u=s(E);return(u==null?void 0:u.getElementsCount())||0};return(0,Wr.jsx)(yf.Provider,{value:{defaultMode:t,locale:i,featureFlags:o,selectElements:l,clearSelection:c,configureElement:d,getConfigureElement:p,importDiagram:f,exportDiagram:m,getElementsCount:y,toast:n},children:(0,Wr.jsxs)(Qn.TooltipProvider,{children:[!n&&(0,Wr.jsx)(Qn.Notification,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),r]})})};var Cs=require("react/jsx-runtime"),bf=(0,De.createContext)(null),q=()=>{let e=(0,De.useContext)(bf);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},Tf=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,edgeHighlight:r=!0,validateCustomDiagram:i,onElementChanges:a,onConfigureElement:s,onElementClick:l,onSubprocessValidationClick:c})=>{let d=(0,De.useRef)(null),{t:p}=(0,Ef.useTranslation)(),{defaultMode:f,featureFlags:m}=On(),y=(0,De.useId)(),[E]=(0,De.useState)(o||y),[u,g]=(0,De.useState)(n||f||"edit"),[h,x]=(0,De.useState)(wr),[T,b]=(0,De.useState)(!1),[N,v]=(0,De.useState)(!0),[I,C]=(0,De.useState)(!1),[P,R]=(0,De.useState)(!1),[S,L]=(0,De.useState)(!1),[K,j]=(0,De.useState)(!1),[Q,z]=(0,De.useState)(!1),[M,V]=(0,De.useState)(null);(0,De.useEffect)(()=>{n&&g(n)},[n]);let D=!!t,A=(0,De.useMemo)(()=>t||Pd(p),[t,p]),B=(0,De.useMemo)(()=>({instanceId:E,containerRef:d,initialDiagram:A,mode:u,featureFlags:m,edgeHighlight:r,isEdit:u==="edit",isView:u==="view",isReadOnly:u==="readonly",isNewDiagram:D,lastElementId:h,isInitialized:T,isMinimapOpen:P,isMoveTool:N,isHandTool:I,isDragging:S,isMultipleSelection:Q,isConnecting:K,setLastElementId:x,setIsInitialized:b,reconnectingEdgeId:M,setIsMinimapOpen:R,setIsMoveTool:v,setIsHandTool:C,setIsDragging:L,setIsConnecting:j,setIsMultipleSelection:z,setReconnectingEdgeId:V,validateCustomDiagram:i,onElementChanges:a,onConfigureElement:s,onElementClick:l,onSubprocessValidationClick:c}),[E,d,A,u,m,r,D,h,T,P,N,I,S,Q,K,M,i,a,s,l,c]);return(0,Cs.jsx)(_f.ReactFlowProvider,{children:(0,Cs.jsx)(bf.Provider,{value:B,children:(0,Cs.jsx)(Ia,{ref:e})})})};0&&(module.exports={EditorMode,ElementPosition,ElementType,GatewayElementVariant,GatewayVariant,Modeler,ModelerProvider,NodeAttribute,NodeType,NodeVariant,RoutingVariant,useModeler});
93
+ E --> F<end>`,hf=({open:e,onOpenChange:t})=>{let{t:o}=(0,nt.useTranslation)(),{importFromLia:n}=xs(),[r,i]=(0,Ma.useState)(""),[s,a]=(0,Ma.useState)(null),l=d=>{d||(i(""),a(null)),t(d)},c=()=>{let d=gf(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,Ht.jsx)(nt.Dialog,{open:e,onOpenChange:l,children:(0,Ht.jsxs)(nt.DialogContent,{className:"w-[90vw] max-w-4xl",children:[(0,Ht.jsxs)(nt.DialogHeader,{children:[(0,Ht.jsx)(nt.DialogTitle,{children:o("editor.modals.mermaid_import.title")}),(0,Ht.jsx)(nt.DialogDescription,{children:o("editor.modals.mermaid_import.description")})]}),(0,Ht.jsx)(nt.Textarea,{value:r,onChange:d=>{i(d.target.value),s&&a(null)},placeholder:Xy,rows:16,className:"max-h-[60vh] min-h-[360px] resize-y font-mono"}),s&&(0,Ht.jsx)("p",{className:"text-sm text-red-500",children:s}),(0,Ht.jsxs)(nt.DialogFooter,{children:[(0,Ht.jsx)(nt.Button,{variant:"ghost",color:"grey",onClick:()=>l(!1),children:o("editor.modals.mermaid_import.cancel")}),(0,Ht.jsx)(nt.Button,{variant:"filled",color:"blue",onClick:c,children:o("editor.modals.mermaid_import.generate")})]})]})})};var Ne=require("react/jsx-runtime"),Uy=".xml,text/xml,application/xml";function yf(){let{t:e}=(0,Ce.useTranslation)(),{importFromMxGraph:t}=Ho(),{toast:o}=rt(),[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,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(Ce.DropdownMenu,{modal:!1,open:n,onOpenChange:r,children:[(0,Ne.jsx)(Ce.DropdownMenuTrigger,{asChild:!0,children:(0,Ne.jsx)("div",{children:(0,Ne.jsxs)(Ce.Tooltip,{children:[(0,Ne.jsx)(Ce.TooltipTrigger,{asChild:!0,children:(0,Ne.jsx)(Ce.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:(0,Ne.jsx)(Qn.ClipboardPasteIcon,{})})}),!n&&(0,Ne.jsx)(Ce.TooltipContent,{color:"black",children:e("editor.controls.actions.import.title")})]})})}),(0,Ne.jsxs)(Ce.DropdownMenuContent,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[(0,Ne.jsxs)(Ce.Tooltip,{children:[(0,Ne.jsx)(Ce.TooltipTrigger,{asChild:!0,children:(0,Ne.jsx)(Ce.DropdownMenuItem,{className:"p-1.5",onClick:()=>{var c;return(c=a.current)==null?void 0:c.click()},children:(0,Ne.jsx)(Qn.FileCodeIcon,{})})}),(0,Ne.jsx)(Ce.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.import.xml")})]}),(0,Ne.jsxs)(Ce.Tooltip,{children:[(0,Ne.jsx)(Ce.TooltipTrigger,{asChild:!0,children:(0,Ne.jsx)(Ce.DropdownMenuItem,{className:"p-1.5",onClick:()=>s(!0),children:(0,Ne.jsx)(Qn.CircleIcon,{})})}),(0,Ne.jsx)(Ce.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.import.mermaid")})]})]})]}),(0,Ne.jsx)("input",{ref:a,type:"file",className:"sr-only",accept:Uy,onChange:l}),(0,Ne.jsx)(hf,{open:i,onOpenChange:s})]})}var Is=require("react"),Se=require("@produto-lecom/lecom-ui"),xf=require("@xyflow/react"),jn=require("lucide-react");var qe=require("react/jsx-runtime");function Ef(){let{t:e}=(0,Se.useTranslation)(),{getNodes:t,getEdges:o,setNodes:n}=(0,xf.useReactFlow)(),{fitToNodes:r}=Vo(),{toast:i}=rt(),[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,m,y,v;return w(_({},g),{width:(m=g.width)!=null?m:(h=g.measured)==null?void 0:h.width,height:(v=g.height)!=null?v:(y=g.measured)==null?void 0:y.height})}),{nodes:f}=ss(p,o(),c),x=new Map(f.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,qe.jsxs)(Se.DropdownMenu,{modal:!1,open:s,onOpenChange:a,children:[(0,qe.jsx)(Se.DropdownMenuTrigger,{asChild:!0,children:(0,qe.jsx)("div",{children:(0,qe.jsxs)(Se.Tooltip,{children:[(0,qe.jsx)(Se.TooltipTrigger,{asChild:!0,children:(0,qe.jsx)(Se.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:(0,qe.jsx)(jn.NetworkIcon,{})})}),!s&&(0,qe.jsx)(Se.TooltipContent,{color:"black",children:e("editor.controls.actions.organize.title")})]})})}),(0,qe.jsxs)(Se.DropdownMenuContent,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[(0,qe.jsxs)(Se.Tooltip,{children:[(0,qe.jsx)(Se.TooltipTrigger,{asChild:!0,children:(0,qe.jsx)(Se.DropdownMenuItem,{className:"p-1.5",onClick:()=>l("TB"),children:(0,qe.jsx)(jn.AlignVerticalJustifyStartIcon,{})})}),(0,qe.jsx)(Se.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.organize.vertical")})]}),(0,qe.jsxs)(Se.Tooltip,{children:[(0,qe.jsx)(Se.TooltipTrigger,{asChild:!0,children:(0,qe.jsx)(Se.DropdownMenuItem,{className:"p-1.5",onClick:()=>l("LR"),children:(0,qe.jsx)(jn.AlignHorizontalJustifyStartIcon,{})})}),(0,qe.jsx)(Se.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.organize.horizontal")})]})]})]})}var ue=require("react/jsx-runtime"),Pa=Wt.default.memo(({hasContent:e,validateDiagram:t,handleValidationComplete:o})=>{let{t:n}=(0,ze.useTranslation)(),{clearSelection:r}=Kt(),{mode:i,containerRef:s,featureFlags:a,isMinimapOpen:l,setIsMinimapOpen:c,isMoveTool:d,isHandTool:u,setIsMoveTool:p,setIsHandTool:f}=J(),{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}),m=(0,Wt.useCallback)(()=>{r(),f(!0),p(!1)},[r,f,p]),y=(0,Wt.useCallback)(()=>{p(!0),f(!1)},[p,f]),[v,b]=(0,Wt.useState)(!1),I=(0,Wt.useCallback)(async()=>{b(!0);try{let T=x(),N=E(),C=await t({nodes:T,edges:N});o(C)}finally{b(!1)}},[x,E,t,o]);return(0,Wt.useEffect)(()=>{g&&!d&&i==="edit"&&y()},[g,y,d,i]),(0,Wt.useEffect)(()=>{h&&!u&&i==="edit"&&m()},[h,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)(ze.Tooltip,{children:[(0,ue.jsx)(ze.TooltipTrigger,{asChild:!0,children:(0,ue.jsx)(ze.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)(ze.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[n("editor.controls.actions.move_tool"),(0,ue.jsx)(Ia,{shortcut:"V"})]})]}),(0,ue.jsxs)(ze.Tooltip,{children:[(0,ue.jsx)(ze.TooltipTrigger,{asChild:!0,children:(0,ue.jsx)(ze.Button,{size:"small",variant:"ghost",color:"grey",className:G(u&&"bg-grey-400"),iconButton:!0,onClick:m,children:(0,ue.jsx)(so.HandIcon,{})})}),(0,ue.jsxs)(ze.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[n("editor.controls.actions.hand_tool")," ",(0,ue.jsx)(Ia,{shortcut:"H"})]})]})]}),(0,ue.jsx)(mf,{}),i==="edit"&&(0,ue.jsxs)(ue.Fragment,{children:[(a==null?void 0:a.importDiagramMermaidEnabled)&&(0,ue.jsxs)(ue.Fragment,{children:[(0,ue.jsx)(yf,{}),(0,ue.jsx)(Ef,{})]}),(0,ue.jsxs)(ze.Tooltip,{children:[(0,ue.jsx)(ze.TooltipTrigger,{asChild:!0,children:(0,ue.jsx)(ze.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:v,onClick:I,children:v?(0,ue.jsx)(so.Loader2Icon,{className:"animate-spin"}):(0,ue.jsx)(so.ListCheckIcon,{})})}),(0,ue.jsx)(ze.TooltipContent,{color:"black",children:n(v?"editor.controls.actions.check_loading":"editor.controls.actions.check")})]}),(0,ue.jsx)(nf,{disabled:e})]}),(0,ue.jsxs)(ze.Tooltip,{children:[(0,ue.jsx)(ze.TooltipTrigger,{asChild:!0,children:(0,ue.jsx)(ze.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)(ze.TooltipContent,{color:"black",children:n(l?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})});Pa.displayName="ActionsControl";var _f=nr(require("react"),1),Et=require("@produto-lecom/lecom-ui"),As=require("lucide-react"),Mt=require("react/jsx-runtime"),La=_f.default.memo(({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=(0,Et.useTranslation)();return(0,Mt.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,Mt.jsxs)(Et.Tooltip,{children:[(0,Mt.jsx)(Et.TooltipTrigger,{asChild:!0,children:(0,Mt.jsx)(Et.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:(0,Mt.jsx)(As.UndoIcon,{})})}),(0,Mt.jsx)(Et.TooltipContent,{color:"black",children:r("editor.controls.history.undo")})]}),(0,Mt.jsxs)(Et.Tooltip,{children:[(0,Mt.jsx)(Et.TooltipTrigger,{asChild:!0,children:(0,Mt.jsx)(Et.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:(0,Mt.jsx)(As.RedoIcon,{})})}),(0,Mt.jsx)(Et.TooltipContent,{color:"black",children:r("editor.controls.history.redo")})]})]})});La.displayName="HistoryControl";var bf=require("@xyflow/react"),Ye=require("@produto-lecom/lecom-ui"),er=require("lucide-react");var He=require("react/jsx-runtime"),Tf=()=>{let{t:e}=(0,Ye.useTranslation)(),t=!bs(),{zoomIn:o,zoomOut:n,zoomTo:r,fitView:i}=(0,bf.useReactFlow)();return(0,He.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,He.jsxs)(Ye.Tooltip,{children:[(0,He.jsx)(Ye.TooltipTrigger,{asChild:!0,children:(0,He.jsx)(Ye.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>i(),children:(0,He.jsx)(er.ScanIcon,{})})}),(0,He.jsx)(Ye.TooltipContent,{color:"black",children:e("editor.controls.zoom.fit")})]}),(0,He.jsxs)(Ye.Tooltip,{children:[(0,He.jsx)(Ye.TooltipTrigger,{asChild:!0,children:(0,He.jsx)(Ye.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>n(),children:(0,He.jsx)(er.ZoomOut,{})})}),(0,He.jsx)(Ye.TooltipContent,{color:"black",children:e("editor.controls.zoom.out")})]}),(0,He.jsxs)(Ye.Tooltip,{children:[(0,He.jsx)(Ye.TooltipTrigger,{asChild:!0,children:(0,He.jsx)(Ye.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>r(1),children:(0,He.jsx)(Qa,{})})}),(0,He.jsx)(Ye.TooltipContent,{color:"black",children:e("editor.controls.zoom.reset")})]}),(0,He.jsxs)(Ye.Tooltip,{children:[(0,He.jsx)(Ye.TooltipTrigger,{asChild:!0,children:(0,He.jsx)(Ye.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>o(),children:(0,He.jsx)(er.ZoomIn,{})})}),(0,He.jsx)(Ye.TooltipContent,{color:"black",children:e("editor.controls.zoom.in")})]})]})};var vf=require("@xyflow/react"),En=require("react/jsx-runtime"),Nf=()=>(0,En.jsxs)(vf.ViewportPortal,{children:[(0,En.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,En.jsx)("line",{x1:"0",y1:"10",x2:"20",y2:"10",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"}),(0,En.jsx)("line",{x1:"10",y1:"0",x2:"10",y2:"20",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"})]}),(0,En.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 wf=require("@xyflow/react"),ao=require("@produto-lecom/lecom-ui"),Cs=require("react");var If=require("lucide-react");var Xt=require("react/jsx-runtime"),Af=()=>{let e=(0,Cs.useRef)(null),{t}=(0,ao.useTranslation)(),{setDraggableNode:o}=qn(),n=(0,wf.useStore)(c=>c.nodes.some(d=>d.type==="START_EVENT")),{setIsDragging:r}=J(),[i,s]=(0,Cs.useState)(void 0),a=[{type:"START_EVENT",icon:ti,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:bn,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:sr,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:ar,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SERVICE_TASK",icon:If.Bot,label:t("bpmn.task.variant.service_task")},{type:"TASK",variant:"SCRIPT",icon:el,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:ja,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:Nn,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:In,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:Tn,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,Xt.jsx)(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return(0,Xt.jsxs)("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[(0,Xt.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,Xt.jsxs)(ao.Tooltip,{children:[(0,Xt.jsx)(ao.TooltipTrigger,{asChild:!0,children:(0,Xt.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:f=>l(f,c),children:(0,Xt.jsx)(c.icon,{})},d)}),(0,Xt.jsx)(ao.TooltipContent,{color:"black",side:"right",children:p})]},d)})}),(0,Xt.jsx)("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};var it=require("react/jsx-runtime"),ka=e=>e.preventDefault(),Ra=(0,_n.forwardRef)((e,t)=>{let{instanceId:o,containerRef:n,mode:r,isMinimapOpen:i,isMoveTool:s,isHandTool:a}=J(),l=(0,lo.useKeyPress)("Space",{target:n==null?void 0:n.current}),c=(0,_n.useRef)(a),d=(0,_n.useRef)(l),{nodes:u,edges:p,actions:f,events:x,components:E,controls:g}=Op(),{t:h}=(0,Wo.useTranslation)(),m=bs();c.current=a,d.current=l;let y=Bp(n,c,d);(0,_n.useImperativeHandle)(t,()=>({selectElements:f.selectElements,clearSelection:f.clearSelection}));let v=a||l||r!=="edit",b=v?Fu:Dr,I=a||l||y,T=s&&!l&&!y,N=r==="edit"&&T,C=!v&&!y,M=r==="view"||T;return(0,it.jsxs)("div",{ref:n,className:"w-full h-full outline-none",tabIndex:0,children:[r==="edit"&&(0,it.jsx)(Af,{}),(0,it.jsx)(zp,{}),(0,it.jsxs)(lo.ReactFlow,w(_({},x),{id:`modeler-${o}`,className:G(r.toLowerCase(),{"is-hand-tool":I,"is-pan-tool-active":I}),edges:p,nodes:u,nodeTypes:Cu,edgeTypes:Su,onlyRenderVisibleElements:!0,minZoom:_a,maxZoom:Du,panOnDrag:b,panOnScroll:!0,selectionOnDrag:C,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:M,nodesConnectable:N,nodesDraggable:N,connectionLineComponent:Iu,selectionMode:lo.SelectionMode.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:N?"Delete":null,selectionKeyCode:null,defaultViewport:Bu,connectOnClick:!1,connectionRadius:50,onPaneContextMenu:ka,onNodeContextMenu:ka,onEdgeContextMenu:ka,proOptions:Wu,children:[(0,it.jsx)(lo.Background,{gap:ku,size:Lu,color:Pu,bgColor:Mu}),(0,it.jsx)(Nf,{}),i&&(0,it.jsxs)(Wo.Tooltip,{children:[(0,it.jsx)(Wo.TooltipTrigger,{asChild:!0,children:(0,it.jsx)("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:(0,it.jsx)(lo.MiniMap,{pannable:!0,zoomable:!0,position:Ru,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),(0,it.jsx)(Wo.TooltipContent,{color:"black",children:h("editor.controls.actions.minimap.label")})]}),(0,it.jsxs)("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&(0,it.jsx)(La,_({},g)),r!=="readonly"&&(0,it.jsx)(Pa,{hasContent:m,validateDiagram:f.validateDiagram,handleValidationComplete:f.handleValidationComplete}),(0,it.jsx)(Tf,{})]}),(0,it.jsx)(E.HelperLines,{})]}))]})});Ra.displayName="Editor";var Cf=require("@xyflow/react"),Xr=require("react"),Sf=require("react/jsx-runtime"),$y=e=>({width:e.width,height:e.height,transform:e.transform}),Da="rgba(51, 103, 217, 0.4)",md=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=(0,Cf.useStore)($y),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=Da,t&&(l.beginPath(),l.strokeStyle=t.color||Da,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||Da,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,Sf.jsx)("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};var tr=require("@produto-lecom/lecom-ui"),Xo=require("react");var Ur=require("react/jsx-runtime"),oo=new Map,Mf=(0,Xo.createContext)(null),Gn=()=>{let e=(0,Xo.useContext)(Mf);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},Pf=({locale:e,defaultMode:t="view",featureFlags:o,toast:n,children:r})=>{let[i,s]=(0,Xo.useState)(e||"pt_BR");(0,Xo.useEffect)(()=>{e&&(s(e),tr.i18n.changeLanguage(e))},[e]);let a=E=>{let g=oo.size;if(g===0)throw new Error("No modeler instances found");if(g===1||!E){let[m]=oo.values();return m}let h=oo.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))},f=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)(Mf.Provider,{value:{defaultMode:t,locale:i,featureFlags:o,selectElements:l,clearSelection:c,configureElement:d,getConfigureElement:u,importDiagram:p,exportDiagram:f,getElementsCount:x,toast:n},children:(0,Ur.jsxs)(tr.TooltipProvider,{children:[!n&&(0,Ur.jsx)(tr.Notification,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),r]})})};var Ss=require("react/jsx-runtime"),Rf=(0,De.createContext)(null),J=()=>{let e=(0,De.useContext)(Rf);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},Df=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,edgeHighlight:r=!0,validateCustomDiagram:i,onElementChanges:s,onConfigureElement:a,onElementClick:l,onSubprocessValidationClick:c})=>{let d=(0,De.useRef)(null),{t:u}=(0,Lf.useTranslation)(),{defaultMode:p,featureFlags:f}=Gn(),x=(0,De.useId)(),[E]=(0,De.useState)(o||x),[g,h]=(0,De.useState)(n||p||"edit"),[m,y]=(0,De.useState)(Sr),[v,b]=(0,De.useState)(!1),[I,T]=(0,De.useState)(!0),[N,C]=(0,De.useState)(!1),[M,L]=(0,De.useState)(!1),[k,O]=(0,De.useState)(!1),[V,F]=(0,De.useState)(!1),[j,$]=(0,De.useState)(null);(0,De.useEffect)(()=>{n&&h(n)},[n]);let K=!!t,A=(0,De.useMemo)(()=>t||Fd(u),[t,u]),P=(0,De.useMemo)(()=>({instanceId:E,containerRef:d,initialDiagram:A,mode:g,featureFlags:f,edgeHighlight:r,isEdit:g==="edit",isView:g==="view",isReadOnly:g==="readonly",isNewDiagram:K,lastElementId:m,isInitialized:v,isMinimapOpen:M,isMoveTool:I,isHandTool:N,isDragging:k,isConnecting:V,setLastElementId:y,setIsInitialized:b,reconnectingEdgeId:j,setIsMinimapOpen:L,setIsMoveTool:T,setIsHandTool:C,setIsDragging:O,setIsConnecting:F,setReconnectingEdgeId:$,validateCustomDiagram:i,onElementChanges:s,onConfigureElement:a,onElementClick:l,onSubprocessValidationClick:c}),[E,d,A,g,f,r,K,m,v,M,I,N,k,V,j,i,s,a,l,c]);return(0,Ss.jsx)(kf.ReactFlowProvider,{children:(0,Ss.jsx)(Rf.Provider,{value:P,children:(0,Ss.jsx)(Ra,{ref:e})})})};0&&(module.exports={EditorMode,ElementPosition,ElementType,GatewayElementVariant,GatewayVariant,Modeler,ModelerProvider,NodeAttribute,NodeType,NodeVariant,RoutingVariant,useModeler});