lecom-modeler 0.42.0 → 0.43.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 +15 -15
- package/lib/index.js +15 -15
- package/lib/style.min.css +1 -1
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var Wp=Object.defineProperty,Xp=Object.defineProperties;var Up=Object.getOwnPropertyDescriptors;var zn=Object.getOwnPropertySymbols;var la=Object.prototype.hasOwnProperty,ca=Object.prototype.propertyIsEnumerable;var aa=(e,t,o)=>t in e?Wp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,_=(e,t)=>{for(var o in t||(t={}))la.call(t,o)&&aa(e,o,t[o]);if(zn)for(var o of zn(t))ca.call(t,o)&&aa(e,o,t[o]);return e},w=(e,t)=>Xp(e,Up(t));var mt=(e,t)=>{var o={};for(var n in e)la.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&zn)for(var n of zn(e))t.indexOf(n)<0&&ca.call(e,n)&&(o[n]=e[n]);return o};var Oi=e=>{if(typeof document=="undefined")return;let t=document.cookie.match(new RegExp(`(?:^|; )${e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")}=([^;]*)`));return t?decodeURIComponent(t[1]):void 0};import{initializeI18n as $p,Translations as Kp}from"@produto-lecom/lecom-ui";var da={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 ua={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 pa={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 fa={pt_BR:pa,en_US:da,es_ES:ua};var ma,ga,qp=(ga=(ma=Oi("LecomUserLanguage"))!=null?ma:Oi("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?ga:Kp.PT_BR;$p({lng:qp,resources:fa});var Ce=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(Ce||{});var Yn=(i=>(i.ACTIVITY="activity",i.ROUTING="routing",i.GATEWAY="gateway",i.SUB_PROCESS="sub_process",i.SERVICE_TASK="service_task",i))(Yn||{}),Vi=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Vi||{}),Hi=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Hi||{}),Gi=(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))(Gi||{});import{Bot as lf,RotateCcw as cf,ScrollText as df,SquarePlus as uf}from"lucide-react";import{jsx as Fn,jsxs as Zp}from"react/jsx-runtime";var Wn=({size:e=24,className:t})=>Zp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:[Fn("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),Fn("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),Fn("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),Fn("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as ha}from"react/jsx-runtime";var To=({size:e=24,className:t})=>ha("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:ha("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as Qo,jsxs as Jp}from"react/jsx-runtime";var vo=({size:e=24,className:t})=>Jp("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:[Qo("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"}),Qo("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Qo("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),Qo("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Qo("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Bi,jsxs as Qp}from"react/jsx-runtime";var No=({size:e=24,className:t})=>Qp("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:[Bi("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"}),Bi("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Bi("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as zi,jsxs as jp}from"react/jsx-runtime";var wo=({size:e=24,className:t})=>jp("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:[zi("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"}),zi("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),zi("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Yi,jsxs as ef}from"react/jsx-runtime";var ya=({size:e=24,className:t})=>Yi("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:ef("g",{children:[Yi("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"}),Yi("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as tf}from"clsx";import{twMerge as of}from"tailwind-merge";function G(...e){return of(tf(e))}var Vt=(e=0,t=0)=>e<t?t:e,Xn=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as xa,jsxs as nf}from"react/jsx-runtime";var Ea=({size:e=24,className:t})=>nf("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:[xa("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"}),xa("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Fi}from"react/jsx-runtime";var _a=({size:e=24,className:t})=>Fi("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:Fi("g",{children:Fi("path",{d:"M4.85372 6.17472L5.31292 5.71552L5.31993 5.70863C6.88908 4.1924 8.98352 3.34122 11.1655 3.33301L11.1668 3.33301C11.167 3.33301 11.1673 3.33301 11.1675 3.33301C12.7165 3.33314 14.2308 3.79255 15.5188 4.65317C16.807 5.5139 17.811 6.7373 18.4039 8.16866C18.9968 9.60001 19.1519 11.175 18.8497 12.6945C18.5986 13.9567 18.0414 15.1334 17.232 16.1236L16.9457 16.4738L17.2655 16.7936L20.6617 20.1899L20.6617 20.1899C20.7919 20.3201 20.7919 20.5311 20.6617 20.6612L20.6616 20.6613C20.5316 20.7915 20.3205 20.7915 20.1903 20.6613L16.7941 17.265L16.4743 16.9452L16.1241 17.2315C15.1339 18.0409 13.9571 18.5981 12.695 18.8492C11.1755 19.1514 9.6005 18.9963 8.16915 18.4034C6.73778 17.8105 5.51439 16.8065 4.65365 15.5183C3.79291 14.2301 3.3335 12.7156 3.3335 11.1663C3.3335 10.9822 3.48273 10.833 3.66683 10.833C3.85093 10.833 4.00016 10.9822 4.00016 11.1663C4.00016 12.5838 4.42048 13.9694 5.20796 15.148C5.99545 16.3265 7.11474 17.245 8.42426 17.7874C9.73378 18.3299 11.1748 18.4719 12.565 18.1953C13.9552 17.9188 15.2321 17.2362 16.2344 16.234L16.2345 16.234C17.2367 15.2316 17.9193 13.9547 18.1958 12.5645C18.4724 11.1743 18.3304 9.7333 17.7879 8.42378C17.2455 7.11426 16.327 5.99497 15.1484 5.20748L14.8707 5.62322L15.1484 5.20748C13.9703 4.42031 12.5854 4.00001 11.1685 3.99968L11.1664 3.99969C9.15876 4.00767 7.23176 4.7903 5.78712 6.18424L5.78706 6.18418L5.78075 6.1905L5.32512 6.64613L4.47156 7.49968H5.67867H7.8335C8.01759 7.49968 8.16683 7.64892 8.16683 7.83302C8.16683 8.01711 8.01759 8.16635 7.8335 8.16635H3.66683C3.48274 8.16635 3.3335 8.01711 3.3335 7.83302V3.66635C3.3335 3.48225 3.48274 3.33302 3.66683 3.33302C3.85092 3.33302 4.00016 3.48225 4.00016 3.66635V5.82117V7.02827L4.85372 6.17472Z"})})});import{jsx as ba}from"react/jsx-runtime";var Un=({size:e=24,className:t})=>ba("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:ba("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as Ta}from"react/jsx-runtime";var jo=({size:e=24,className:t})=>Ta("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:Ta("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as Wi,jsxs as rf}from"react/jsx-runtime";var va=({size:e=24,className:t})=>rf("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:[Wi("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"}),Wi("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"}),Wi("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as en,jsxs as sf}from"react/jsx-runtime";var Na=({size:e=24,className:t})=>sf("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:[en("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"}),en("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"}),en("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"}),en("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),en("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as $n,jsxs as af}from"react/jsx-runtime";var tn=({size:e=24,className:t})=>af("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:[$n("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"}),$n("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),$n("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),$n("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var se=(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))(se||{}),Qe=(n=>(n.SCRIPT="SCRIPT",n.SUBPROCESS="SUBPROCESS",n.SERVICE_TASK="SERVICE_TASK",n))(Qe||{}),Kn={SCRIPT:{icon:df},SUBPROCESS:{icon:uf},SERVICE_TASK:{icon:lf}},gt=(t=>(t.LOOP="LOOP",t))(gt||{}),qn={LOOP:{icon:cf}},rt=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(rt||{}),Xi={EXCLUSIVE:{icon:No},PARALLEL:{icon:wo},COMPLEX:{icon:vo}};import{useTranslation as Ib}from"@produto-lecom/lecom-ui";import{ReactFlowProvider as Ab}from"@xyflow/react";import{createContext as Cb,useContext as Sb,useEffect as Mb,useId as Pb,useMemo as Yp,useRef as Lb,useState as Tt}from"react";import{Background as ob,MiniMap as nb,ReactFlow as rb,SelectionMode as ib,useKeyPress as sb}from"@xyflow/react";import{forwardRef as ab,useImperativeHandle as lb,useRef as Hp}from"react";import{useTranslation as Wx}from"@produto-lecom/lecom-ui";import{useEdgesState as Xx,useNodesState as Ux,useReactFlow as $x,useStoreApi as Kx}from"@xyflow/react";import{useCallback as Dt,useEffect as qx}from"react";var Zn={MIN_WIDTH:36,MIN_HEIGHT:36},Jn={MIN_WIDTH:36,MIN_HEIGHT:36},Io={MIN_WIDTH:56,MIN_HEIGHT:56},Ht={MIN_WIDTH:176,MIN_HEIGHT:96},wa={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},re={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},Ao={MIN_WIDTH:176,MIN_HEIGHT:64},pf={MIN_WIDTH:128,MIN_HEIGHT:64},de={START_EVENT:Zn,END_EVENT:Jn,GATEWAY:Io,TASK:Ht,LANE:re,ANNOTATION:Ao,UNSUPPORTED:pf};import{Position as on}from"@xyflow/react";function Ia(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 Aa(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?on.Left:a>=i+n-1?on.Right:l<=s+1?on.Top:l>=s+r-1?on.Bottom:on.Top}function Co(e,t){let o=Ia(e,t),n=Ia(t,e),r=Aa(e,o),i=Aa(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function Qn(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"}}import{orderBy as ff}from"lodash";var jn=e=>e.some(t=>t.type==="position"&&t.dragging),Ca=e=>new Map(e.map(t=>[t.id,t])),Sa=(e,t)=>e.map(o=>{var n;return(n=t.get(o.id))!=null?n:o}),it=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}},nn=e=>ff(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),Ma=(e,t)=>{let{x:o,y:n}=it(e),{x:r,y:i}=it(t);return{x:o-r,y:n-i}};var no=({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)),mf=(e,t)=>{let{x:o,y:n}=it(e),{x:r,y:i}=it(t),s=o-r,a=n-i;return Math.sqrt(s*s+a*a)},gf=(e,t)=>{let{x:o,y:n,w:r,h:i}=it(e),{x:s,y:a,w:l,h:c}=it(t),d=o+r/2,u=n+i/2;return d>=s&&d<=s+l&&u>=a&&u<=a+c},rn=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&gf(e,r)){let i=mf(e,r);i<n&&(n=i,o=r)}return o},Pa=(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 La=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}},ka=({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 Ui=(e,t)=>{let o=t.find(s=>s.id===e);if(!o||o.type!=="LANE"||o.parentId)return!1;let n=it(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=it(s);return a.x<r&&a.x+a.w>n.x&&a.y<i&&a.y+a.h>n.y})};var hf=50,ro=(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+hf-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})})})},Te=15,io=e=>[...e].sort((t,o)=>t.position.y-o.position.y),yf=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)},xf=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)},$i=(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=yf(C),L=xf(C);if(((h=(g=C.position)==null?void 0:g.y)!=null?h:0)<Te&&(o.set(C.id,w(_({},C),{position:w(_({},C.position),{y:Te})})),L=Te+((y=(m=C.measured)==null?void 0:m.height)!=null?y:0)),((b=(v=C.position)==null?void 0:v.x)!=null?b:0)<re.HEADER_WIDTH+Te){let k=(I=o.get(C.id))!=null?I:C;o.set(C.id,w(_({},k),{position:w(_({},k.position),{x:re.HEADER_WIDTH+Te})})),M=re.HEADER_WIDTH+Te+((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,re.MIN_WIDTH),l=Math.max(r,re.MIN_HEIGHT);i+Te>a&&(a=i+Te),s+Te>l&&(l=s+Te);let c=w(_({},e),{width:a,height:l,measured:w(_({},e.measured),{width:a,height:l})});return o.set(e.id,c),c},Ra=(e,t,o)=>{var s,a;let n=io(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=$i(l,c,t);t.set(d.id,w(_({},d),{position:{x:re.HEADER_WIDTH,y:i}})),i+=(a=d.height)!=null?a:0}},Da=(e,t)=>{var x,E,g,h;let o=[];for(let m of t.values())m.parentId===e.id&&o.push(m);let n=io(o),r=((E=(x=e.measured)==null?void 0:x.width)!=null?E:0)-re.HEADER_WIDTH,i=Pa(e.id,o)||re.MIN_WIDTH,s=o.reduce((m,y)=>{var v;return m+((v=y.height)!=null?v:re.MIN_HEIGHT)},0),a=Math.max(r,i),l=s,c=r>i,d=c?a:a+re.HEADER_WIDTH,u=c?a-re.HEADER_WIDTH:a,p=0;for(let m=0;m<n.length;m++){let y=n[m],v=Math.max(re.MIN_HEIGHT,(g=y.height)!=null?g:re.MIN_HEIGHT),b=w(_({},y),{width:u,height:v,measured:w(_({},y.measured),{width:u,height:v}),position:{x:re.HEADER_WIDTH,y:p}});if(m===o.length-1){let I=Math.max(re.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})}))},Oa=(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=io(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(re.MIN_HEIGHT,r-p)),m&&i&&(b=Math.max(re.MIN_HEIGHT,o-p)),f=f.map(N=>{if(N.id===g.id){let C=i?t-re.HEADER_WIDTH:t;return w(_({},N),{width:C,height:b,measured:w(_({},N.measured),{width:C,height:b}),position:{x:re.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+re.HEADER_WIDTH;return w(_({},g),{width:h,height:i?o:p,measured:{width:h,height:i?o:p}})}return g}),f};var Ki=(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<Te&&(e.position.y=Te),e.position.x<re.HEADER_WIDTH+Te&&(e.position.x=re.HEADER_WIDTH+Te);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+Te>n&&(t.width=i+Te,t.measured.width=i+Te),s+Te>r&&(t.height=s+Te,t.measured.height=s+Te),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};import{useCallback as _f}from"react";import{create as bf}from"zustand";import{useStoreApi as Ef}from"@xyflow/react";var ht=()=>{let e=Ef();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 Xn(),!0}}};var Va=()=>{let{selectElements:e}=ht();return _f(()=>{let o=so.getState().pathEdgeIds;e(o)},[e])},so=bf((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})}}));import{useNodesInitialized as Og,useReactFlow as Vg,useStore as Hg}from"@xyflow/react";import{useCallback as _n,useEffect as Gg,useRef as Bg,useState as Pc}from"react";import{shallow as zg}from"zustand/shallow";var Tf={value:()=>{}};function Ga(){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 er(o)}function er(e){this._=e}function vf(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}})}er.prototype=Ga.prototype={constructor:er,on:function(e,t){var o=this._,n=vf(e+"",o),r,i=-1,s=n.length;if(arguments.length<2){for(;++i<s;)if((r=(e=n[i]).type)&&(r=Nf(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]=Ha(o[r],e.name,t);else if(t==null)for(r in o)o[r]=Ha(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 er(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 Nf(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function Ha(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=Tf,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var qi=Ga;var tr="http://www.w3.org/1999/xhtml",Zi={svg:"http://www.w3.org/2000/svg",xhtml:tr,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function At(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),Zi.hasOwnProperty(t)?{space:Zi[t],local:e}:e}function wf(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===tr&&t.documentElement.namespaceURI===tr?t.createElement(e):t.createElementNS(o,e)}}function If(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function or(e){var t=At(e);return(t.local?If:wf)(t)}function Af(){}function ao(e){return e==null?Af:function(){return this.querySelector(e)}}function Ba(e){typeof e!="function"&&(e=ao(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 Pe(n,this._parents)}function Ji(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Cf(){return[]}function sn(e){return e==null?Cf:function(){return this.querySelectorAll(e)}}function Sf(e){return function(){return Ji(e.apply(this,arguments))}}function za(e){typeof e=="function"?e=Sf(e):e=sn(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 Pe(n,r)}function an(e){return function(){return this.matches(e)}}function nr(e){return function(t){return t.matches(e)}}var Mf=Array.prototype.find;function Pf(e){return function(){return Mf.call(this.children,e)}}function Lf(){return this.firstElementChild}function Ya(e){return this.select(e==null?Lf:Pf(typeof e=="function"?e:nr(e)))}var kf=Array.prototype.filter;function Rf(){return Array.from(this.children)}function Df(e){return function(){return kf.call(this.children,e)}}function Fa(e){return this.selectAll(e==null?Rf:Df(typeof e=="function"?e:nr(e)))}function Wa(e){typeof e!="function"&&(e=an(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 Pe(n,this._parents)}function rr(e){return new Array(e.length)}function Xa(){return new Pe(this._enter||this._groups.map(rr),this._parents)}function ln(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}ln.prototype={constructor:ln,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 Ua(e){return function(){return e}}function Of(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 ln(e,i[s]);for(;s<l;++s)(a=t[s])&&(r[s]=a)}function Vf(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 ln(e,i[a]);for(a=0;a<d;++a)(l=t[a])&&c.get(p[a])===l&&(r[a]=l)}function Hf(e){return e.__data__}function $a(e,t){if(!arguments.length)return Array.from(this,Hf);var o=t?Vf:Of,n=this._parents,r=this._groups;typeof e!="function"&&(e=Ua(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=Gf(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 Pe(s,n),s._enter=a,s._exit=l,s}function Gf(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Ka(){return new Pe(this._exit||this._groups.map(rr),this._parents)}function qa(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 Za(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 Pe(a,this._parents)}function Ja(){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 Qa(e){e||(e=Bf);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 Pe(r,this._parents).order()}function Bf(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function ja(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function el(){return Array.from(this)}function tl(){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 nl(){return!this.node()}function rl(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 zf(e){return function(){this.removeAttribute(e)}}function Yf(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Ff(e,t){return function(){this.setAttribute(e,t)}}function Wf(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Xf(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function Uf(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 il(e,t){var o=At(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?Yf:zf:typeof t=="function"?o.local?Uf:Xf:o.local?Wf:Ff)(o,t))}function ir(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function $f(e){return function(){this.style.removeProperty(e)}}function Kf(e,t,o){return function(){this.style.setProperty(e,t,o)}}function qf(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function sl(e,t,o){return arguments.length>1?this.each((t==null?$f:typeof t=="function"?qf:Kf)(e,t,o==null?"":o)):Gt(this.node(),e)}function Gt(e,t){return e.style.getPropertyValue(t)||ir(e).getComputedStyle(e,null).getPropertyValue(t)}function Zf(e){return function(){delete this[e]}}function Jf(e,t){return function(){this[e]=t}}function Qf(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function al(e,t){return arguments.length>1?this.each((t==null?Zf:typeof t=="function"?Qf:Jf)(e,t)):this.node()[e]}function ll(e){return e.trim().split(/^|\s+/)}function Qi(e){return e.classList||new cl(e)}function cl(e){this._node=e,this._names=ll(e.getAttribute("class")||"")}cl.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 dl(e,t){for(var o=Qi(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function ul(e,t){for(var o=Qi(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function jf(e){return function(){dl(this,e)}}function em(e){return function(){ul(this,e)}}function tm(e,t){return function(){(t.apply(this,arguments)?dl:ul)(this,e)}}function pl(e,t){var o=ll(e+"");if(arguments.length<2){for(var n=Qi(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?tm:t?jf:em)(o,t))}function om(){this.textContent=""}function nm(e){return function(){this.textContent=e}}function rm(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function fl(e){return arguments.length?this.each(e==null?om:(typeof e=="function"?rm:nm)(e)):this.node().textContent}function im(){this.innerHTML=""}function sm(e){return function(){this.innerHTML=e}}function am(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function ml(e){return arguments.length?this.each(e==null?im:(typeof e=="function"?am:sm)(e)):this.node().innerHTML}function lm(){this.nextSibling&&this.parentNode.appendChild(this)}function gl(){return this.each(lm)}function cm(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function hl(){return this.each(cm)}function yl(e){var t=typeof e=="function"?e:or(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function dm(){return null}function xl(e,t){var o=typeof e=="function"?e:or(e),n=t==null?dm:typeof t=="function"?t:ao(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function um(){var e=this.parentNode;e&&e.removeChild(this)}function El(){return this.each(um)}function pm(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function fm(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function _l(e){return this.select(e?fm:pm)}function bl(e){return arguments.length?this.property("__data__",e):this.node().__data__}function mm(e){return function(t){e.call(this,t,this.__data__)}}function gm(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 hm(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 ym(e,t,o){return function(){var n=this.__on,r,i=mm(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 Tl(e,t,o){var n=gm(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?ym:hm,r=0;r<i;++r)this.each(a(n[r],t,o));return this}function vl(e,t,o){var n=ir(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 xm(e,t){return function(){return vl(this,e,t)}}function Em(e,t){return function(){return vl(this,e,t.apply(this,arguments))}}function Nl(e,t){return this.each((typeof t=="function"?Em:xm)(e,t))}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,s;r<i;++r)(s=n[r])&&(yield s)}var _m=[null];function Pe(e,t){this._groups=e,this._parents=t}function Il(){return new Pe([[document.documentElement]],_m)}function bm(){return this}Pe.prototype=Il.prototype={constructor:Pe,select:Ba,selectAll:za,selectChild:Ya,selectChildren:Fa,filter:Wa,data:$a,enter:Xa,exit:Ka,join:qa,merge:Za,selection:bm,order:Ja,sort:Qa,call:ja,nodes:el,node:tl,size:ol,empty:nl,each:rl,attr:il,style:sl,property:al,classed:pl,text:fl,html:ml,raise:gl,lower:hl,append:yl,insert:xl,remove:El,clone:_l,datum:bl,on:Tl,dispatch:Nl,[Symbol.iterator]:wl};var Ct=Il;function sr(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function ji(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function un(){}var cn=.7,cr=1/cn,So="\\s*([+-]?\\d+)\\s*",dn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",yt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Tm=/^#([0-9a-f]{3,8})$/,vm=new RegExp(`^rgb\\(${So},${So},${So}\\)$`),Nm=new RegExp(`^rgb\\(${yt},${yt},${yt}\\)$`),wm=new RegExp(`^rgba\\(${So},${So},${So},${dn}\\)$`),Im=new RegExp(`^rgba\\(${yt},${yt},${yt},${dn}\\)$`),Am=new RegExp(`^hsl\\(${dn},${yt},${yt}\\)$`),Cm=new RegExp(`^hsla\\(${dn},${yt},${yt},${dn}\\)$`),Al={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};sr(un,Bt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Cl,formatHex:Cl,formatHex8:Sm,formatHsl:Mm,formatRgb:Sl,toString:Sl});function Cl(){return this.rgb().formatHex()}function Sm(){return this.rgb().formatHex8()}function Mm(){return Dl(this).formatHsl()}function Sl(){return this.rgb().formatRgb()}function Bt(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=Tm.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?Ml(t):o===3?new Ke(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?ar(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?ar(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=vm.exec(e))?new Ke(t[1],t[2],t[3],1):(t=Nm.exec(e))?new Ke(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=wm.exec(e))?ar(t[1],t[2],t[3],t[4]):(t=Im.exec(e))?ar(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Am.exec(e))?kl(t[1],t[2]/100,t[3]/100,1):(t=Cm.exec(e))?kl(t[1],t[2]/100,t[3]/100,t[4]):Al.hasOwnProperty(e)?Ml(Al[e]):e==="transparent"?new Ke(NaN,NaN,NaN,0):null}function Ml(e){return new Ke(e>>16&255,e>>8&255,e&255,1)}function ar(e,t,o,n){return n<=0&&(e=t=o=NaN),new Ke(e,t,o,n)}function Pm(e){return e instanceof un||(e=Bt(e)),e?(e=e.rgb(),new Ke(e.r,e.g,e.b,e.opacity)):new Ke}function Mo(e,t,o,n){return arguments.length===1?Pm(e):new Ke(e,t,o,n==null?1:n)}function Ke(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}sr(Ke,Mo,ji(un,{brighter(e){return e=e==null?cr:Math.pow(cr,e),new Ke(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?cn:Math.pow(cn,e),new Ke(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ke(co(this.r),co(this.g),co(this.b),dr(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:Pl,formatHex:Pl,formatHex8:Lm,formatRgb:Ll,toString:Ll}));function Pl(){return`#${lo(this.r)}${lo(this.g)}${lo(this.b)}`}function Lm(){return`#${lo(this.r)}${lo(this.g)}${lo(this.b)}${lo((isNaN(this.opacity)?1:this.opacity)*255)}`}function Ll(){let e=dr(this.opacity);return`${e===1?"rgb(":"rgba("}${co(this.r)}, ${co(this.g)}, ${co(this.b)}${e===1?")":`, ${e})`}`}function dr(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function co(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function lo(e){return e=co(e),(e<16?"0":"")+e.toString(16)}function kl(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new ut(e,t,o,n)}function Dl(e){if(e instanceof ut)return new ut(e.h,e.s,e.l,e.opacity);if(e instanceof un||(e=Bt(e)),!e)return new ut;if(e instanceof ut)return e;e=e.rgb();var t=e.r/255,o=e.g/255,n=e.b/255,r=Math.min(t,o,n),i=Math.max(t,o,n),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 ut(s,a,l,e.opacity)}function Ol(e,t,o,n){return arguments.length===1?Dl(e):new ut(e,t,o,n==null?1:n)}function ut(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}sr(ut,Ol,ji(un,{brighter(e){return e=e==null?cr:Math.pow(cr,e),new ut(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?cn:Math.pow(cn,e),new ut(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,o=this.l,n=o+(o<.5?o:1-o)*t,r=2*o-n;return new Ke(es(e>=240?e-240:e+120,r,n),es(e,r,n),es(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new ut(Rl(this.h),lr(this.s),lr(this.l),dr(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=dr(this.opacity);return`${e===1?"hsl(":"hsla("}${Rl(this.h)}, ${lr(this.s)*100}%, ${lr(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Rl(e){return e=(e||0)%360,e<0?e+360:e}function lr(e){return Math.max(0,Math.min(1,e||0))}function es(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 ts(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 Vl(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 ts((o-n/t)*t,s,r,i,a)}}function Hl(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 ts((o-n/t)*t,r,i,s,a)}}var os=e=>()=>e;function km(e,t){return function(o){return e+o*t}}function Rm(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 Gl(e){return(e=+e)==1?ur:function(t,o){return o-t?Rm(t,o,e):os(isNaN(t)?o:t)}}function ur(e,t){var o=t-e;return o?km(e,o):os(isNaN(e)?t:e)}var pr=function e(t){var o=Gl(t);function n(r,i){var s=o((r=Mo(r)).r,(i=Mo(i)).r),a=o(r.g,i.g),l=o(r.b,i.b),c=ur(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 Bl(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=Mo(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 Dm=Bl(Vl),Om=Bl(Hl);function st(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var rs=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ns=new RegExp(rs.source,"g");function Vm(e){return function(){return e}}function Hm(e){return function(t){return e(t)+""}}function is(e,t){var o=rs.lastIndex=ns.lastIndex=0,n,r,i,s=-1,a=[],l=[];for(e=e+"",t=t+"";(n=rs.exec(e))&&(r=ns.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:st(n,r)})),o=ns.lastIndex;return o<t.length&&(i=t.slice(o),a[s]?a[s]+=i:a[++s]=i),a.length<2?l[0]?Hm(l[0].x):Vm(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 zl=180/Math.PI,fr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ss(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)*zl,skewX:Math.atan(l)*zl,scaleX:s,scaleY:a}}var mr;function Yl(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?fr:ss(t.a,t.b,t.c,t.d,t.e,t.f)}function Fl(e){return e==null?fr:(mr||(mr=document.createElementNS("http://www.w3.org/2000/svg","g")),mr.setAttribute("transform",e),(e=mr.transform.baseVal.consolidate())?(e=e.matrix,ss(e.a,e.b,e.c,e.d,e.e,e.f)):fr)}function Wl(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:st(c,u)},{i:E-2,x:st(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:st(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:st(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:st(c,u)},{i:E-2,x:st(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 as=Wl(Yl,"px, ","px)","deg)"),ls=Wl(Fl,", ",")",")");var Po=0,fn=0,pn=0,Ul=1e3,gr,mn,hr=0,uo=0,yr=0,gn=typeof performance=="object"&&performance.now?performance:Date,$l=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function yn(){return uo||($l(Gm),uo=gn.now()+yr)}function Gm(){uo=0}function hn(){this._call=this._time=this._next=null}hn.prototype=xr.prototype={constructor:hn,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?yn():+o)+(t==null?0:+t),!this._next&&mn!==this&&(mn?mn._next=this:gr=this,mn=this),this._call=e,this._time=o,cs()},stop:function(){this._call&&(this._call=null,this._time=1/0,cs())}};function xr(e,t,o){var n=new hn;return n.restart(e,t,o),n}function Kl(){yn(),++Po;for(var e=gr,t;e;)(t=uo-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Po}function Xl(){uo=(hr=gn.now())+yr,Po=fn=0;try{Kl()}finally{Po=0,zm(),uo=0}}function Bm(){var e=gn.now(),t=e-hr;t>Ul&&(yr-=t,hr=e)}function zm(){for(var e,t=gr,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:gr=o);mn=e,cs(n)}function cs(e){if(!Po){fn&&(fn=clearTimeout(fn));var t=e-uo;t>24?(e<1/0&&(fn=setTimeout(Xl,e-gn.now()-yr)),pn&&(pn=clearInterval(pn))):(pn||(hr=gn.now(),pn=setInterval(Bm,Ul)),Po=1,$l(Xl))}}function Er(e,t,o){var n=new hn;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var Ym=qi("start","end","cancel","interrupt"),Fm=[],Jl=0,ql=1,br=2,_r=3,Zl=4,Tr=5,xn=6;function zt(e,t,o,n,r,i){var s=e.__transition;if(!s)e.__transition={};else if(o in s)return;Wm(e,o,{name:t,index:n,group:r,on:Ym,tween:Fm,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Jl})}function En(e,t){var o=Le(e,t);if(o.state>Jl)throw new Error("too late; already scheduled");return o}function Ve(e,t){var o=Le(e,t);if(o.state>_r)throw new Error("too late; already running");return o}function Le(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function Wm(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=xr(i,0,o.time);function i(c){o.state=ql,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!==ql)return l();for(d in n)if(f=n[d],f.name===o.name){if(f.state===_r)return Er(s);f.state===Zl?(f.state=xn,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete n[d]):+d<t&&(f.state=xn,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete n[d])}if(Er(function(){o.state===_r&&(o.state=Zl,o.timer.restart(a,o.delay,o.time),a(c))}),o.state=br,o.on.call("start",e,e.__data__,o.index,o.group),o.state===br){for(o.state=_r,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=Tr,1),u=-1,p=r.length;++u<p;)r[u].call(e,d);o.state===Tr&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=xn,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function ds(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>br&&n.state<Tr,n.state=xn,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[s]}i&&delete e.__transition}}function Ql(e){return this.each(function(){ds(this,e)})}function Xm(e,t){var o,n;return function(){var r=Ve(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 Um(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=Ve(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 jl(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=Le(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?Xm:Um)(o,e,t))}function Lo(e,t,o){var n=e._id;return e.each(function(){var r=Ve(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return Le(r,n).value[t]}}function vr(e,t){var o;return(typeof t=="number"?st:t instanceof Bt?pr:(o=Bt(t))?(t=o,pr):is)(e,t)}function $m(e){return function(){this.removeAttribute(e)}}function Km(e){return function(){this.removeAttributeNS(e.space,e.local)}}function qm(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 Zm(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 Jm(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 Qm(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 ec(e,t){var o=At(e),n=o==="transform"?ls:vr;return this.attrTween(e,typeof t=="function"?(o.local?Qm:Jm)(o,n,Lo(this,"attr."+e,t)):t==null?(o.local?Km:$m)(o):(o.local?Zm:qm)(o,n,t))}function jm(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function eg(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function tg(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&eg(e,i)),o}return r._value=t,r}function og(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&jm(e,i)),o}return r._value=t,r}function tc(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=At(e);return this.tween(o,(n.local?tg:og)(n,t))}function ng(e,t){return function(){En(this,e).delay=+t.apply(this,arguments)}}function rg(e,t){return t=+t,function(){En(this,e).delay=t}}function oc(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?ng:rg)(t,e)):Le(this.node(),t).delay}function ig(e,t){return function(){Ve(this,e).duration=+t.apply(this,arguments)}}function sg(e,t){return t=+t,function(){Ve(this,e).duration=t}}function nc(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?ig:sg)(t,e)):Le(this.node(),t).duration}function ag(e,t){if(typeof t!="function")throw new Error;return function(){Ve(this,e).ease=t}}function rc(e){var t=this._id;return arguments.length?this.each(ag(t,e)):Le(this.node(),t).ease}function lg(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;Ve(this,e).ease=o}}function ic(e){if(typeof e!="function")throw new Error;return this.each(lg(this._id,e))}function sc(e){typeof e!="function"&&(e=an(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 Xe(n,this._parents,this._name,this._id)}function ac(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 Xe(s,this._parents,this._name,this._id)}function cg(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 dg(e,t,o){var n,r,i=cg(t)?En:Ve;return function(){var s=i(this,e),a=s.on;a!==n&&(r=(n=a).copy()).on(t,o),s.on=r}}function lc(e,t){var o=this._id;return arguments.length<2?Le(this.node(),o).on.on(e):this.each(dg(o,e,t))}function ug(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function cc(){return this.on("end.remove",ug(this._id))}function dc(e){var t=this._name,o=this._id;typeof e!="function"&&(e=ao(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,zt(c[p],t,o,p,c,Le(d,o)));return new Xe(i,this._parents,t,o)}function uc(e){var t=this._name,o=this._id;typeof e!="function"&&(e=sn(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=Le(d,o),E=0,g=p.length;E<g;++E)(f=p[E])&&zt(f,t,o,E,p,x);i.push(p),s.push(d)}return new Xe(i,s,t,o)}var pg=Ct.prototype.constructor;function pc(){return new pg(this._groups,this._parents)}function fg(e,t){var o,n,r;return function(){var i=Gt(this,e),s=(this.style.removeProperty(e),Gt(this,e));return i===s?null:i===o&&s===n?r:r=t(o=i,n=s)}}function fc(e){return function(){this.style.removeProperty(e)}}function mg(e,t,o){var n,r=o+"",i;return function(){var s=Gt(this,e);return s===r?null:s===n?i:i=t(n=s,o)}}function gg(e,t,o){var n,r,i;return function(){var s=Gt(this,e),a=o(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),Gt(this,e))),s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a))}}function hg(e,t){var o,n,r,i="style."+t,s="end."+i,a;return function(){var l=Ve(this,e),c=l.on,d=l.value[i]==null?a||(a=fc(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(s,r=d),l.on=n}}function mc(e,t,o){var n=(e+="")=="transform"?as:vr;return t==null?this.styleTween(e,fg(e,n)).on("end.style."+e,fc(e)):typeof t=="function"?this.styleTween(e,gg(e,n,Lo(this,"style."+e,t))).each(hg(this._id,e)):this.styleTween(e,mg(e,n,t),o).on("end.style."+e,null)}function yg(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function xg(e,t,o){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&yg(e,s,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,xg(e,t,o==null?"":o))}function Eg(e){return function(){this.textContent=e}}function _g(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function hc(e){return this.tween("text",typeof e=="function"?_g(Lo(this,"text",e)):Eg(e==null?"":e+""))}function bg(e){return function(t){this.textContent=e.call(this,t)}}function Tg(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&bg(r)),t}return n._value=e,n}function yc(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,Tg(e))}function xc(){for(var e=this._name,t=this._id,o=Nr(),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=Le(l,t);zt(l,e,o,c,s,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Xe(n,this._parents,e,o)}function Ec(){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=Ve(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 vg=0;function Xe(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function _c(e){return Ct().transition(e)}function Nr(){return++vg}var St=Ct.prototype;Xe.prototype=_c.prototype={constructor:Xe,select:dc,selectAll:uc,selectChild:St.selectChild,selectChildren:St.selectChildren,filter:sc,merge:ac,selection:pc,transition:xc,call:St.call,nodes:St.nodes,node:St.node,size:St.size,empty:St.empty,each:St.each,on:lc,attr:ec,attrTween:tc,style:mc,styleTween:gc,text:hc,textTween:yc,remove:cc,tween:jl,delay:oc,duration:nc,ease:rc,easeVarying:ic,end:Ec,[Symbol.iterator]:St[Symbol.iterator]};function wr(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Ng={time:null,delay:0,duration:250,ease:wr};function wg(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 bc(e){var t,o;e instanceof Xe?(t=e._id,e=e._name):(t=Nr(),(o=Ng).time=yn(),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])&&zt(l,e,t,c,s,o||wg(l,t));return new Xe(n,this._parents,e,t)}Ct.prototype.interrupt=Ql;Ct.prototype.transition=bc;function Yt(e,t,o){this.k=e,this.x=t,this.y=o}Yt.prototype={constructor:Yt,scale:function(e){return e===1?this:new Yt(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Yt(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 Ir=new Yt(1,0,0);Ar.prototype=Yt.prototype;function Ar(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Ir;return e.__zoom}var Ag=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var Tc;(function(e){e.Strict="strict",e.Loose="loose"})(Tc||(Tc={}));var vc;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(vc||(vc={}));var Nc;(function(e){e.Partial="partial",e.Full="full"})(Nc||(Nc={}));var wc;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(wc||(wc={}));var Ic;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ic||(Ic={}));var qe;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(qe||(qe={}));var NI={[qe.Left]:qe.Right,[qe.Right]:qe.Left,[qe.Top]:qe.Bottom,[qe.Bottom]:qe.Top};var Cg=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var Sg=(e,t=[0,0])=>{var a;let{width:o,height:n}=Mg(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 Cr=(e,t=[0,0])=>{var r,i,s,a,l,c,d,u;let{x:o,y:n}=Cg(e)?e.internals.positionAbsolute:Sg(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 Mg(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 wI={[qe.Left]:{x:-1,y:0},[qe.Right]:{x:1,y:0},[qe.Top]:{x:0,y:-1},[qe.Bottom]:{x:0,y:1}};var Pg={nodeOrigin:[0,0],nodeExtent:Ag,elevateNodesOnSelect:!0,defaults:{}},II=w(_({},Pg),{checkEquality:!0});var Ac;(function(e){e.Line="line",e.Handle="handle"})(Ac||(Ac={}));var Lg={width:0,height:0,x:0,y:0},AI=w(_({},Lg),{pointerX:0,pointerY:0,aspectRatio:1});var kg=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function Rg(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 Dg(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 Sr=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)||!kg(f.nodeBox,r))continue;let x=Math.abs(f.position-o);if(x>Mr)continue;let g=Rg(f.nodeBox,n)>0?0:Dg(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 Cc(e,t=po,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=Cr(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 Sc(e,t,o,n,r=Object.keys(po)){let i=[];for(let a of r){let l=po[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 Mc(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)<=Mr&&(r=l,s=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=Mr&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:s}}var Mr=10,po={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}};import{jsx as $g}from"react/jsx-runtime";var Yg=new Sr;function Fg(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(po);return{bounds:{x:r,y:i,x2:s,y2:a},excludedNodeIds:l,anchors:n?["top","left"]:c}}function Wg(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 Xg(e,t,o,n){return e.length>0?Fg(e,o,n,!!t):t?Wg(t,o,n):null}function Lc(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 Ug(e,t,o,n,r,i){r&&(e.forEach(s=>{s.position&&(s.position.x-=o)}),Lc(t,e,"width",o)),i&&(e.forEach(s=>{s.position&&(s.position.y-=n)}),Lc(t,e,"height",n))}function Pr(){let[e,t]=Pc(void 0),[o,n]=Pc(void 0),{width:r,height:i}=Hg(g=>({width:g.width,height:g.height}),zg),s=Og(),a=Bg(Yg),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=Vg(),u=_n(()=>{t(void 0),n(void 0)},[]),p=_n(g=>{let h=g!=null?g:d();u();let m=Cc(h,po,c);a.current.initialize(m)},[c,u,d]),f=_n(()=>{setTimeout(()=>{p()},100)},[p]);Gg(()=>{s&&p(d())},[s,p,d]);let x=_n((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=Xg(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}=Sc(a.current,M,b.bounds,b.excludedNodeIds,b.anchors),{deltaX:O,deltaY:V,snappedX:F,snappedY:j}=Mc(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)),Ug(y,v,O,V,F,j)},[l,c,r,i,t,n,u]),E=_n(()=>$g(kc,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:p,forceRebuildIndex:f,updateHelperLines:x,helperLineHorizontal:e,helperLineVertical:o,HelperLines:E}}import{reconnectEdge as j0,useReactFlow as ex}from"@xyflow/react";import{useCallback as yo,useRef as tx}from"react";var Mt=e=>new Map(e.map(t=>[t.id,t])),bn=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),Rc=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),us=e=>e.some(t=>t.type==="START_EVENT"),ko=(e,t)=>e==="START_EVENT"?!us(t):!0,Dc=(e,t,o,n,r)=>{let i=Mt(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:bn(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Oc=(e,t,o,n,r)=>{let i=Mt(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:Rc(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Lr=(e,t,o,n,r)=>{var c;let i=Mt(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:bn(e,n,r).filter(d=>{let u=i.get(d.target);return(u==null?void 0:u.type)!=="ANNOTATION"}).length>=2},Vc=(e,t,o)=>{var s,a,l,c;let n=Mt(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"},kr=(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"},Hc=(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"},Tn=(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"},Rr=(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"},fo=(e,t,o,n)=>{let r=Mt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:Rc(e,o,n).some(a=>{let l=r.get(a.source);return(l==null?void 0:l.type)==="START_EVENT"})},vn=(e,t,o,n)=>{let r=Mt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:bn(e,o,n).some(a=>{let l=r.get(a.target);return(l==null?void 0:l.type)==="END_EVENT"})},Gc=(e,t,o,n,r)=>{let i=Mt(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"?vn(t,o,n,r):(a==null?void 0:a.type)==="END_EVENT"&&(s==null?void 0:s.type)==="TASK"?fo(e,o,n,r):!1},Dr=(e,t,o)=>bn(e,t,o).length>0,Or=(e,t,o,n,r)=>{let i=Mt(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:bn(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var Bc=(e,t,o,n,r)=>{var a,l;let i=Mt(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 Kg=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!Bc(e.sourceNodeId,e.targetNodeId,e.edges,e.nodes,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!Dc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!Oc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!Lr(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!Or(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:Vc(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"&&Hc(e.targetNodeId,e.nodes)),reason:"start_event_to_subprocess_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&Tn(e.targetNodeId,e.nodes)),reason:"start_event_to_service_task_not_allowed"}),e=>({isValid:!(Tn(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:!(kr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(Rr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(fo(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!Gc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(vn(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(Dr(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"})],ps=e=>{for(let t of Kg){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var qg=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:Lr(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:us(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:kr(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Rr(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Tn(e.sourceNodeId,e.nodes),reason:"service_task_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:fo(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:vn(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Dr(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Or(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],zc=e=>{let t=qg.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}};import{BaseEdge as Ih,EdgeLabelRenderer as Ah,getStraightPath as Ch,useInternalNode as Fc,useViewport as Sh}from"@xyflow/react";import{useCallback as Zg}from"react";import{useStore as Jg}from"@xyflow/react";function xt(){return Jg(Zg(e=>e.nodes.filter(o=>o.selected).length+e.edges.filter(o=>o.selected).length>=2,[]))}import{Button as jg,Tooltip as eh,TooltipContent as th,TooltipTrigger as oh,useTranslation as nh}from"@produto-lecom/lecom-ui";import{Settings as rh}from"lucide-react";import{getIncomers as Vr,getOutgoers as Hr,useReactFlow as Qg}from"@xyflow/react";var Gr=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=Qg(),{selectElements:r}=ht(),i=g=>{let h=o(),m=n(),y=Vr(g,h,m),v=Hr(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=Vr(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(Hr(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=Vr(I,h,m);if(M.length)for(let L of M)v(L,T,N+1);T.pop()}let b=Vr(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=Hr(I,h,m);if(M.length)for(let L of M)v(L,T,N+1);T.pop()}let b=Hr(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}};import{jsx as Br,jsxs as sh}from"react/jsx-runtime";var ih={node:"editor.toolbar.configure_node",edge:"editor.toolbar.configure_edge",gateway:"editor.toolbar.configure_gateway"},Ft=({elementId:e,elementType:t="node"})=>{let{t:o}=nh(),{onConfigureElement:n}=J(),{getConfigureElement:r}=Gr();return sh(eh,{children:[Br(oh,{asChild:!0,children:Br(jg,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let s=r(e);s&&(n==null||n(s))},children:Br(rh,{size:16})})}),Br(th,{color:"black",children:o(ih[t])})]})};import{Button as lh,Tooltip as ch,TooltipContent as dh,TooltipTrigger as uh,useTranslation as ph}from"@produto-lecom/lecom-ui";import{useReactFlow as fh}from"@xyflow/react";import{TrashIcon as mh}from"lucide-react";import{useNotificationToast as ah}from"@produto-lecom/lecom-ui";function De(){let{toast:e}=Nn(),{toast:t}=ah();return{toast:e||t}}import{jsx as zr,jsxs as gh}from"react/jsx-runtime";var Yr=({elementId:e,elementType:t="node"})=>{let{t:o}=ph(),{toast:n}=De(),{deleteElements:r,getNodes:i}=fh();return gh(ch,{children:[zr(uh,{asChild:!0,children:zr(lh,{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:zr(mh,{size:16})})}),zr(dh,{color:"black",children:o("editor.toolbar.delete")})]})};import{Button as hh,Tooltip as yh,TooltipContent as xh,TooltipTrigger as Eh,useTranslation as _h}from"@produto-lecom/lecom-ui";import{MoveUpRightIcon as bh}from"lucide-react";import{useCallback as Th}from"react";import{jsx as Fr,jsxs as vh}from"react/jsx-runtime";var Ro=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=_h(),r=Th(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 vh(yh,{children:[Fr(Eh,{asChild:!0,children:Fr(hh,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:Fr(bh,{size:16})})}),Fr(xh,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};import{jsx as wn}from"react/jsx-runtime";var Do=i=>{var s=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=s,r=mt(s,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:a}=J(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d,isToEndEvent:u}=Qn(o,n),p=!l&&!c&&!d&&!u,f=[{component:wn(Yr,{elementId:e,elementType:"edge"})}],x=()=>a==="view"?p?[{component:wn(Ft,{elementId:e,elementType:"edge"})}]:[]:p?[{component:wn(Ft,{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 wn("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)=>wn("div",{children:h.component},m))}))};import{useViewport as Nh}from"@xyflow/react";import{useMemo as wh}from"react";import{jsx as Yc}from"react/jsx-runtime";var Et=12,Oo=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:s}=Nh(),a=1/s,l=wh(()=>t===n?{bottom:`${Et}px`,transform:"translateX(-50%)"}:e===o?{left:`${Et}px`,transform:r?"translateY(-100%)":"translateY(-50%)"}:n>t&&o>e?{left:`${Et}px`,bottom:`${Et}px`}:n>t&&o<e?{right:`${Et}px`,bottom:`${Et}px`}:t>n&&o>e?{right:`${Et}px`,bottom:`${Et}px`}:{left:`${Et}px`,bottom:`${Et}px`},[e,t,o,n,r]);return Yc("div",{style:{transform:`scale(${a})`},children:Yc("div",{className:"absolute pointer-events-auto",style:_({},l),children:i})})};import{jsx as Vo,jsxs as Wc}from"react/jsx-runtime";var Ho={type:"ANNOTATION_EDGE",reconnectable:!0},Xc=({id:e,source:t,target:o,selected:n,data:r})=>{let{isReadOnly:i,edgeHighlight:s}=J(),a=xt(),{zoom:l}=Sh(),c=Fc(t),d=Fc(o);if(!c||!d)return null;let{sx:u,sy:p,tx:f,ty:x}=Co(c,d),[E,g,h]=Ch({sourceX:u,sourceY:p,targetX:f,targetY:x}),m=s&&(n||(c==null?void 0:c.selected)||(d==null?void 0:d.selected));return Wc("g",{className:G("group bpmn-edge",{"is-highlighted":m}),children:[Vo("path",{d:E,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/l),style:{pointerEvents:"stroke",cursor:"pointer"}}),Wc("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:[Vo(Ih,{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)})}),Vo(Ah,{children:Vo("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&&Vo(Oo,{sx:u,sy:p,tx:f,ty:x,children:Vo(Do,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})})})]})]})};import Uh,{useState as td,useCallback as Qr,useMemo as jr,useEffect as $h,useRef as gs}from"react";import{BaseEdge as Kh,EdgeLabelRenderer as qh,MarkerType as od,useInternalNode as nd,useReactFlow as Zh,useStore as rd,useViewport as Jh,Position as Yo}from"@xyflow/react";import{useCallback as Mh,useEffect as fs,useRef as Uc,useState as Ph}from"react";import{jsx as Kc}from"react/jsx-runtime";var ms=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,$c=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Escape","Shift"],Ge=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:s,onBlur:a,onInput:l,onInvalidFirstCharacter:c,skipFirstCharValidation:d})=>{let u=Uc(null),p=Uc(null),[f,x]=Ph(!1);fs(()=>()=>{p.current&&clearTimeout(p.current)},[]),fs(()=>{x(i!=null?i:!1)},[i]),fs(()=>{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=Mh(()=>{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&&!ms.test(b.key)&&!$c.includes(b.key)&&!L){b.preventDefault(),E();return}T&&!M&&($c.includes(b.key)||k||O||V||F||b.preventDefault())},m=b=>{b.preventDefault();let I=b.clipboardData.getData("text/plain").replace(/\r\n/g,`
|
|
1
|
+
var Xp=Object.defineProperty,Up=Object.defineProperties;var $p=Object.getOwnPropertyDescriptors;var zn=Object.getOwnPropertySymbols;var la=Object.prototype.hasOwnProperty,ca=Object.prototype.propertyIsEnumerable;var aa=(e,t,o)=>t in e?Xp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,b=(e,t)=>{for(var o in t||(t={}))la.call(t,o)&&aa(e,o,t[o]);if(zn)for(var o of zn(t))ca.call(t,o)&&aa(e,o,t[o]);return e},w=(e,t)=>Up(e,$p(t));var mt=(e,t)=>{var o={};for(var n in e)la.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&zn)for(var n of zn(e))t.indexOf(n)<0&&ca.call(e,n)&&(o[n]=e[n]);return o};var Oi=e=>{if(typeof document=="undefined")return;let t=document.cookie.match(new RegExp(`(?:^|; )${e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")}=([^;]*)`));return t?decodeURIComponent(t[1]):void 0};import{initializeI18n as Kp,Translations as qp}from"@produto-lecom/lecom-ui";var da={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:"One or more gateways do not have the correct number of outputs",events_nested:"Connecting events directly is not allowed",event_to_condition:"Connecting an event directly to a gateway is not allowed",script_in_final_activity:"Final activity cannot be a script type",subprocess_not_configured:"The subprocess reference is not properly configured in one or more activities",cannot_validate_subprocess_reference:"Could not validate the subprocess reference in one or more activities",start_event_not_found:"A start event is required",end_event_not_found:"At least one end event is required",service_task_without_rejection_routing:"Automated activity (RPA) without rejection routing configured",service_task_without_automation:"Automated activity (RPA) without a configured robot",service_task_connector_inactive:"Automated activity (RPA) linked to an inactive connector",service_task_integration_suspended:"Automated activity (RPA) linked to a suspended integration",service_task_automation_status_unavailable:"Could not verify the automation (RPA) status",service_task_initial_or_final:"Automated activity (RPA) cannot be an initial, final or concentrator step",service_task_in_loop:"Automated activity (RPA) cannot be in a loop"}},bpmn:{start_event:{variant:{default:"Start event"}},end_event:{variant:{default:"End event"}},annotation:{variant:{default:"Annotation"}},gateway:{menu:{title:"Change gateway type"},variant:{default:"Gateway",exclusive:"Exclusive gateway",parallel:"Parallel gateway",complex:"Complex gateway"}},task:{menu:{title:"Change task type"},variant:{default:"Task",script:"Script task",subprocess:"Subprocess",service_task:"RPA"},attribute:{loop:"Task with loop"},label:{prefix:"Activity"},feedback:{label_empty:{prefix:"Activity name was automatically set to"},label_already_exists:{prefix:"The name",middle:"already exists. The name was changed to"},invalid_first_character:"Activity name must start with a letter or number"}},lane:{variant:{default:"Pool / Lane"}},unsupported:{variant:{default:"Unsupported element"}}},adapter:{governance:{error:{DEFAULT:"Error importing diagram",NO_FILE:"No file selected",EMPTY_FILE:"Empty file",INVALID_FILE:"Invalid file",CONTAIN_NO_CELLS:"No cells found to be imported",ALREADY_INITIALIZED:"Importing from the Governance platform is only allowed in diagrams without elements. To import, delete the current diagram"},success:{default:"The diagram was imported from the Governance platform successfully and without any incompatibility detected.",incompatible_cells:"The diagram was imported from the Governance platform with incompatibilities. To know more details, click on the button below."},report:{columns:{type:"Type",value:"Value",status:"Status"},status:{imported:"Imported",adapted:"Adapted",unsupported:"Unsupported"}},action:{download:"Download report"}}}}};var ua={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:"Una o m\xE1s compuertas no tienen el n\xFAmero correcto de salidas",events_nested:"No se permite conectar eventos directamente",event_to_condition:"No se permite conectar un evento directamente a una compuerta",script_in_final_activity:"La actividad final no puede ser de tipo script",subprocess_not_configured:"La referencia al subproceso no est\xE1 configurada correctamente en una o m\xE1s actividades",cannot_validate_subprocess_reference:"No fue posible validar la referencia al subproceso en una o m\xE1s actividades",start_event_not_found:"Es necesario tener un evento de inicio",end_event_not_found:"Es necesario tener al menos un evento final",service_task_without_rejection_routing:"Actividad autom\xE1tica (RPA) sin enrutamiento de rechazo configurado",service_task_without_automation:"Actividad autom\xE1tica (RPA) sin robot configurado",service_task_connector_inactive:"Actividad autom\xE1tica (RPA) vinculada a un conector inactivo",service_task_integration_suspended:"Actividad autom\xE1tica (RPA) vinculada a una integraci\xF3n suspendida",service_task_automation_status_unavailable:"No se pudo verificar el estado de la automatizaci\xF3n (RPA)",service_task_initial_or_final:"La actividad autom\xE1tica (RPA) no puede ser etapa inicial, final o concentradora",service_task_in_loop:"La actividad autom\xE1tica (RPA) no puede estar en un bucle"}},bpmn:{start_event:{variant:{default:"Evento de inicio"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anotaci\xF3n"}},gateway:{menu:{title:"Cambiar tipo de compuerta"},variant:{default:"Compuerta",exclusive:"Compuerta exclusiva",parallel:"Compuerta paralela",complex:"Compuerta compleja"}},task:{menu:{title:"Cambiar tipo de tarea"},variant:{default:"Tarea",script:"Tarea de script",subprocess:"Subproceso",service_task:"RPA"},attribute:{loop:"Tarea con bucle"},label:{prefix:"Actividad"},feedback:{label_empty:{prefix:"El nombre de la actividad se estableci\xF3 autom\xE1ticamente como"},label_already_exists:{prefix:"El nombre",middle:"ya existe. El nombre fue cambiado a"},invalid_first_character:"El nombre de la actividad debe comenzar con una letra o n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento no soportado"}}},adapter:{governance:{error:{DEFAULT:"Error al importar diagrama",NO_FILE:"No se ha seleccionado ning\xFAn archivo",EMPTY_FILE:"Archivo vac\xEDo",INVALID_FILE:"Archivo inv\xE1lido",CONTAIN_NO_CELLS:"No se encontraron c\xE9lulas para importar",ALREADY_INITIALIZED:"La importaci\xF3n de la plataforma Governance solo se permite en diagramas sin elementos. Para importar, elimine el diagrama actual"},success:{default:"El diagrama se ha importado de la plataforma Governance correctamente y sin ninguna incompatibilidad detectada.",incompatible_cells:"El diagrama se ha importado de la plataforma Governance con incompatibilidades. Para saber m\xE1s detalles, haz click en el bot\xF3n de abajo."},report:{columns:{type:"Tipo",value:"Valor",status:"Estado"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"No soportado"}},action:{download:"Descargar informe"}}}}};var pa={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 validado com sucesso!",message:"Nenhum erro encontrado."},errors:{title:"O diagrama cont\xE9m erros",subtitle:"Veja abaixo o que precisa ser corrigido:",task_label_length:"O nome da atividade excede o limite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"N\xE3o \xE9 permitido ter mais de um evento de in\xEDcio",task_flows_limit_exceeds:"O n\xFAmero de conex\xF5es de sa\xEDda ultrapassa o limite de dois",duplicate_task_name:"H\xE1 v\xE1rias atividades com o mesmo nome",flows_on_end_tasks_not_allowed:"Atividades conectadas a eventos finais n\xE3o podem ter outras conex\xF5es",conditions_flows_limit_exceeds:"Gateway exclusivo com excesso de conex\xF5es de sa\xEDda (m\xE1ximo de dois)",task_label_empty:"O nome de uma ou mais atividades n\xE3o foi preenchido",activity_name_invalid:"O nome da atividade n\xE3o \xE9 v\xE1lido",final_activity_has_loop:"Atividades finais n\xE3o podem ter loops",nested_gateway:"N\xE3o \xE9 permitido conectar gateways",concurrent_initial_and_final_event:"Uma mesma atividade n\xE3o pode ter eventos iniciais e finais",gateway_flow_to_event:"N\xE3o \xE9 permitido conectar um gateway a um evento de sa\xEDda",gateway_missing_output_streams:"Um ou mais gateways n\xE3o possuem o n\xFAmero correto de sa\xEDdas",events_nested:"N\xE3o \xE9 permitido conectar eventos",event_to_condition:"N\xE3o \xE9 permitido conectar um evento diretamente em um gateway",script_in_final_activity:"Atividade final n\xE3o pode ser do tipo script",subprocess_not_configured:"A refer\xEAncia ao subprocesso n\xE3o est\xE1 configurada corretamente em uma ou mais atividades",cannot_validate_subprocess_reference:"N\xE3o foi poss\xEDvel validar a refer\xEAncia ao subprocesso em uma ou mais atividades",start_event_not_found:"\xC9 necess\xE1rio ter um evento inicial",end_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento final",service_task_without_rejection_routing:"Atividade autom\xE1tica (RPA) sem roteamento de rejei\xE7\xE3o configurado",service_task_without_automation:"Atividade autom\xE1tica (RPA) sem rob\xF4 configurado",service_task_connector_inactive:"Atividade autom\xE1tica (RPA) vinculada a um conector inativo",service_task_integration_suspended:"Atividade autom\xE1tica (RPA) vinculada a uma integra\xE7\xE3o suspensa",service_task_automation_status_unavailable:"N\xE3o foi poss\xEDvel verificar o status da automa\xE7\xE3o (RPA)",service_task_initial_or_final:"Atividade autom\xE1tica (RPA) n\xE3o pode ser etapa inicial, final ou concentradora",service_task_in_loop:"Atividade autom\xE1tica (RPA) n\xE3o pode estar em loop"}},bpmn:{start_event:{variant:{default:"Evento inicial"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anota\xE7\xE3o"}},gateway:{menu:{title:"Alterar tipo de gateway"},variant:{default:"Gateway",exclusive:"Gateway exclusivo",parallel:"Gateway paralelo",complex:"Gateway complexo"}},task:{menu:{title:"Alterar tipo de atividade"},variant:{default:"Atividade",script:"Atividade de script",subprocess:"Subprocesso",service_task:"RPA"},attribute:{loop:"Atividade com loop"},label:{prefix:"Atividade"},feedback:{label_empty:{prefix:"O nome da atividade foi definido automaticamente como"},label_already_exists:{prefix:"O nome",middle:"j\xE1 existe. O nome foi alterado para"},invalid_first_character:"O nome da atividade deve come\xE7ar com uma letra ou n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento n\xE3o suportado"}}},adapter:{governance:{error:{DEFAULT:"Erro ao importar diagrama",NO_FILE:"Nenhum arquivo selecionado",EMPTY_FILE:"Arquivo vazio",INVALID_FILE:"Arquivo inv\xE1lido",CONTAIN_NO_CELLS:"N\xE3o foram encontradas c\xE9lulas para serem importadas",ALREADY_INITIALIZED:"A importa\xE7\xE3o da plataforma Governance s\xF3 \xE9 permitida em diagramas sem elementos. Para importar, apague o diagrama atual"},success:{default:"O diagrama foi importado da plataforma Governance com sucesso e sem nenhuma incompatibilidade detectada.",incompatible_cells:"O diagrama foi importado da plataforma Governance com incompatibilidades. Para saber mais detalhes, clique no bot\xE3o abaixo."},report:{columns:{type:"Tipo do elemento",value:"Valor",status:"Status"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"N\xE3o suportado"}},action:{download:"Baixar relat\xF3rio"}}}}};var fa={pt_BR:pa,en_US:da,es_ES:ua};var ma,ga,Zp=(ga=(ma=Oi("LecomUserLanguage"))!=null?ma:Oi("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?ga:qp.PT_BR;Kp({lng:Zp,resources:fa});var Ce=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(Ce||{});var Yn=(i=>(i.ACTIVITY="activity",i.ROUTING="routing",i.GATEWAY="gateway",i.SUB_PROCESS="sub_process",i.SERVICE_TASK="service_task",i))(Yn||{}),Vi=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Vi||{}),Hi=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Hi||{}),Gi=(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))(Gi||{});import{Bot as cf,RotateCcw as df,ScrollText as uf,SquarePlus as pf}from"lucide-react";import{jsx as Fn,jsxs as Jp}from"react/jsx-runtime";var Wn=({size:e=24,className:t})=>Jp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:[Fn("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),Fn("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),Fn("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),Fn("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as ha}from"react/jsx-runtime";var To=({size:e=24,className:t})=>ha("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:ha("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as Qo,jsxs as Qp}from"react/jsx-runtime";var vo=({size:e=24,className:t})=>Qp("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:[Qo("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"}),Qo("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Qo("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),Qo("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Qo("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Bi,jsxs as jp}from"react/jsx-runtime";var No=({size:e=24,className:t})=>jp("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:[Bi("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"}),Bi("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Bi("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as zi,jsxs as ef}from"react/jsx-runtime";var wo=({size:e=24,className:t})=>ef("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:[zi("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"}),zi("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),zi("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Yi,jsxs as tf}from"react/jsx-runtime";var ya=({size:e=24,className:t})=>Yi("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:tf("g",{children:[Yi("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"}),Yi("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as of}from"clsx";import{twMerge as nf}from"tailwind-merge";function H(...e){return nf(of(e))}var Vt=(e=0,t=0)=>e<t?t:e,Xn=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as xa,jsxs as rf}from"react/jsx-runtime";var Ea=({size:e=24,className:t})=>rf("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:[xa("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"}),xa("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Fi}from"react/jsx-runtime";var _a=({size:e=24,className:t})=>Fi("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:Fi("g",{children:Fi("path",{d:"M4.85372 6.17472L5.31292 5.71552L5.31993 5.70863C6.88908 4.1924 8.98352 3.34122 11.1655 3.33301L11.1668 3.33301C11.167 3.33301 11.1673 3.33301 11.1675 3.33301C12.7165 3.33314 14.2308 3.79255 15.5188 4.65317C16.807 5.5139 17.811 6.7373 18.4039 8.16866C18.9968 9.60001 19.1519 11.175 18.8497 12.6945C18.5986 13.9567 18.0414 15.1334 17.232 16.1236L16.9457 16.4738L17.2655 16.7936L20.6617 20.1899L20.6617 20.1899C20.7919 20.3201 20.7919 20.5311 20.6617 20.6612L20.6616 20.6613C20.5316 20.7915 20.3205 20.7915 20.1903 20.6613L16.7941 17.265L16.4743 16.9452L16.1241 17.2315C15.1339 18.0409 13.9571 18.5981 12.695 18.8492C11.1755 19.1514 9.6005 18.9963 8.16915 18.4034C6.73778 17.8105 5.51439 16.8065 4.65365 15.5183C3.79291 14.2301 3.3335 12.7156 3.3335 11.1663C3.3335 10.9822 3.48273 10.833 3.66683 10.833C3.85093 10.833 4.00016 10.9822 4.00016 11.1663C4.00016 12.5838 4.42048 13.9694 5.20796 15.148C5.99545 16.3265 7.11474 17.245 8.42426 17.7874C9.73378 18.3299 11.1748 18.4719 12.565 18.1953C13.9552 17.9188 15.2321 17.2362 16.2344 16.234L16.2345 16.234C17.2367 15.2316 17.9193 13.9547 18.1958 12.5645C18.4724 11.1743 18.3304 9.7333 17.7879 8.42378C17.2455 7.11426 16.327 5.99497 15.1484 5.20748L14.8707 5.62322L15.1484 5.20748C13.9703 4.42031 12.5854 4.00001 11.1685 3.99968L11.1664 3.99969C9.15876 4.00767 7.23176 4.7903 5.78712 6.18424L5.78706 6.18418L5.78075 6.1905L5.32512 6.64613L4.47156 7.49968H5.67867H7.8335C8.01759 7.49968 8.16683 7.64892 8.16683 7.83302C8.16683 8.01711 8.01759 8.16635 7.8335 8.16635H3.66683C3.48274 8.16635 3.3335 8.01711 3.3335 7.83302V3.66635C3.3335 3.48225 3.48274 3.33302 3.66683 3.33302C3.85092 3.33302 4.00016 3.48225 4.00016 3.66635V5.82117V7.02827L4.85372 6.17472Z"})})});import{jsx as ba}from"react/jsx-runtime";var Un=({size:e=24,className:t})=>ba("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:ba("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as Ta}from"react/jsx-runtime";var jo=({size:e=24,className:t})=>Ta("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:Ta("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as Wi,jsxs as sf}from"react/jsx-runtime";var va=({size:e=24,className:t})=>sf("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:[Wi("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"}),Wi("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"}),Wi("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as en,jsxs as af}from"react/jsx-runtime";var Na=({size:e=24,className:t})=>af("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:[en("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"}),en("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"}),en("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"}),en("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),en("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as $n,jsxs as lf}from"react/jsx-runtime";var tn=({size:e=24,className:t})=>lf("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:[$n("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"}),$n("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),$n("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),$n("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var se=(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))(se||{}),Qe=(n=>(n.SCRIPT="SCRIPT",n.SUBPROCESS="SUBPROCESS",n.SERVICE_TASK="SERVICE_TASK",n))(Qe||{}),Kn={SCRIPT:{icon:uf},SUBPROCESS:{icon:pf},SERVICE_TASK:{icon:cf}},gt=(t=>(t.LOOP="LOOP",t))(gt||{}),qn={LOOP:{icon:df}},rt=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(rt||{}),Xi={EXCLUSIVE:{icon:No},PARALLEL:{icon:wo},COMPLEX:{icon:vo}};import{useTranslation as Ab}from"@produto-lecom/lecom-ui";import{ReactFlowProvider as Cb}from"@xyflow/react";import{createContext as Sb,useContext as Mb,useEffect as Pb,useId as Lb,useMemo as Fp,useRef as kb,useState as Tt}from"react";import{Background as nb,MiniMap as rb,ReactFlow as ib,SelectionMode as sb,useKeyPress as ab}from"@xyflow/react";import{forwardRef as lb,useImperativeHandle as cb,useRef as Gp}from"react";import{useTranslation as Xx}from"@produto-lecom/lecom-ui";import{useEdgesState as Ux,useNodesState as $x,useReactFlow as Kx,useStoreApi as qx}from"@xyflow/react";import{useCallback as Dt,useEffect as Zx}from"react";var Zn={MIN_WIDTH:36,MIN_HEIGHT:36},Jn={MIN_WIDTH:36,MIN_HEIGHT:36},Io={MIN_WIDTH:56,MIN_HEIGHT:56},Ht={MIN_WIDTH:176,MIN_HEIGHT:96},wa={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},re={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},Ao={MIN_WIDTH:176,MIN_HEIGHT:64},ff={MIN_WIDTH:128,MIN_HEIGHT:64},de={START_EVENT:Zn,END_EVENT:Jn,GATEWAY:Io,TASK:Ht,LANE:re,ANNOTATION:Ao,UNSUPPORTED:ff};import{Position as on}from"@xyflow/react";function Ia(e,t){var x,T,_,I;let{width:o=0,height:n=0}=e.measured||{width:0,height:0},r=e.internals.positionAbsolute,i=t.internals.positionAbsolute,s=o/2,a=n/2,l=r.x+s,c=r.y+a,d=i.x+((T=(x=t==null?void 0:t.measured)==null?void 0:x.width)!=null?T:0)/2,u=i.y+((I=(_=t==null?void 0:t.measured)==null?void 0:_.height)!=null?I:0)/2,p=(d-l)/(2*s)-(u-c)/(2*a),f=(d-l)/(2*s)+(u-c)/(2*a),h=1/(Math.abs(p)+Math.abs(f)||1),E=h*p,m=h*f,y=s*(E+m)+l,g=a*(-E+m)+c;return{x:y,y:g}}function Aa(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?on.Left:a>=i+n-1?on.Right:l<=s+1?on.Top:l>=s+r-1?on.Bottom:on.Top}function Co(e,t){let o=Ia(e,t),n=Ia(t,e),r=Aa(e,o),i=Aa(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function Qn(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"}}import{orderBy as mf}from"lodash";var jn=e=>e.some(t=>t.type==="position"&&t.dragging),Ca=e=>new Map(e.map(t=>[t.id,t])),Sa=(e,t)=>e.map(o=>{var n;return(n=t.get(o.id))!=null?n:o}),it=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}},nn=e=>mf(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),Ma=(e,t)=>{let{x:o,y:n}=it(e),{x:r,y:i}=it(t);return{x:o-r,y:n-i}};var no=({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)),gf=(e,t)=>{let{x:o,y:n}=it(e),{x:r,y:i}=it(t),s=o-r,a=n-i;return Math.sqrt(s*s+a*a)},hf=(e,t)=>{let{x:o,y:n,w:r,h:i}=it(e),{x:s,y:a,w:l,h:c}=it(t),d=o+r/2,u=n+i/2;return d>=s&&d<=s+l&&u>=a&&u<=a+c},rn=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&hf(e,r)){let i=gf(e,r);i<n&&(n=i,o=r)}return o},Pa=(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 La=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}},ka=({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 Ui=(e,t)=>{let o=t.find(s=>s.id===e);if(!o||o.type!=="LANE"||o.parentId)return!1;let n=it(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=it(s);return a.x<r&&a.x+a.w>n.x&&a.y<i&&a.y+a.h>n.y})};var yf=50,ro=(e,t)=>{var p,f,h,E,m,y,g,x,T,_,I,v,N,S,M,L;let o=t.find(k=>k.id===e);if(!o)return t;let n=(f=(p=o.position)==null?void 0:p.x)!=null?f:0,r=(E=(h=o.position)==null?void 0:h.y)!=null?E:0,i=(y=(m=o.measured)==null?void 0:m.width)!=null?y:0,s=(x=(g=o.measured)==null?void 0:g.height)!=null?x:0,a=r+s,l=n+i,c=new Set,d=1/0;for(let k of t){if(k.id===e||k.parentId)continue;let O=(_=(T=k.position)==null?void 0:T.y)!=null?_:0,G=(v=(I=k.position)==null?void 0:I.x)!=null?v:0,F=(S=(N=k.measured)==null?void 0:N.width)!=null?S:0,Q=(L=(M=k.measured)==null?void 0:M.height)!=null?L:0;G<l&&G+F>n&&O<a&&O+Q>r&&(c.add(k.id),d=Math.min(d,O))}if(c.size===0)return t;let u=a+yf-d;return t.map(k=>{var G,F,Q;if(!c.has(k.id))return k;let O=(F=(G=k.position)==null?void 0:G.y)!=null?F:0;return w(b({},k),{position:w(b({},(Q=k.position)!=null?Q:{x:0,y:0}),{y:O+u})})})},Te=15,io=e=>[...e].sort((t,o)=>t.position.y-o.position.y),xf=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)},Ef=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)},$i=(e,t,o)=>{var d,u,p,f,h,E,m,y,g,x,T,_,I,v,N;if(t.length===0)return e;let n=(p=(u=e.width)!=null?u:(d=e.measured)==null?void 0:d.width)!=null?p:0,r=(E=(h=e.height)!=null?h:(f=e.measured)==null?void 0:f.height)!=null?E:0,i=0,s=0;for(let S of t){let M=xf(S),L=Ef(S);if(((y=(m=S.position)==null?void 0:m.y)!=null?y:0)<Te&&(o.set(S.id,w(b({},S),{position:w(b({},S.position),{y:Te})})),L=Te+((x=(g=S.measured)==null?void 0:g.height)!=null?x:0)),((_=(T=S.position)==null?void 0:T.x)!=null?_:0)<re.HEADER_WIDTH+Te){let k=(I=o.get(S.id))!=null?I:S;o.set(S.id,w(b({},k),{position:w(b({},k.position),{x:re.HEADER_WIDTH+Te})})),M=re.HEADER_WIDTH+Te+((N=(v=S.measured)==null?void 0:v.width)!=null?N:0)}i=Math.max(i,M),s=Math.max(s,L)}let a=Math.max(n,re.MIN_WIDTH),l=Math.max(r,re.MIN_HEIGHT);i+Te>a&&(a=i+Te),s+Te>l&&(l=s+Te);let c=w(b({},e),{width:a,height:l,measured:w(b({},e.measured),{width:a,height:l})});return o.set(e.id,c),c},Ra=(e,t,o)=>{var s,a;let n=io(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=$i(l,c,t);t.set(d.id,w(b({},d),{position:{x:re.HEADER_WIDTH,y:i}})),i+=(a=d.height)!=null?a:0}},Da=(e,t)=>{var h,E,m,y;let o=[];for(let g of t.values())g.parentId===e.id&&o.push(g);let n=io(o),r=((E=(h=e.measured)==null?void 0:h.width)!=null?E:0)-re.HEADER_WIDTH,i=Pa(e.id,o)||re.MIN_WIDTH,s=o.reduce((g,x)=>{var T;return g+((T=x.height)!=null?T:re.MIN_HEIGHT)},0),a=Math.max(r,i),l=s,c=r>i,d=c?a:a+re.HEADER_WIDTH,u=c?a-re.HEADER_WIDTH:a,p=0;for(let g=0;g<n.length;g++){let x=n[g],T=Math.max(re.MIN_HEIGHT,(m=x.height)!=null?m:re.MIN_HEIGHT),_=w(b({},x),{width:u,height:T,measured:w(b({},x.measured),{width:u,height:T}),position:{x:re.HEADER_WIDTH,y:p}});if(g===o.length-1){let I=Math.max(re.MIN_HEIGHT,l-p);_=w(b({},_),{height:I,measured:w(b({},x.measured),{width:u,height:I})})}t.set(x.id,_),p+=(y=_.height)!=null?y:0}let f=Math.max(l,p);t.set(e.id,w(b({},e),{width:d,height:f,measured:w(b({},e.measured),{width:d,height:f})}))},Oa=(e,t,o,n,r)=>{var h,E;let i=!e.parentId,s=i?e.id:e.parentId,a=n.filter(m=>m.type==="LANE"&&m.parentId===s);if(!a.length)return n;let l=io(a),c=l.findIndex(m=>m.id===e.id),d=(E=(h=e.position)==null?void 0:h.y)!=null?E:0,u=!i&&r!==void 0&&c>0&&Math.abs(r-d)>.5,p=0,f=[...n];return l.forEach((m,y)=>{var I,v;let g=y===l.length-1,x=m.id===e.id,_=(v=(I=m.measured)==null?void 0:I.height)!=null?v:0;x?_=o:u&&y===c-1&&(_=Math.max(re.MIN_HEIGHT,r-p)),g&&i&&(_=Math.max(re.MIN_HEIGHT,o-p)),f=f.map(N=>{if(N.id===m.id){let S=i?t-re.HEADER_WIDTH:t;return w(b({},N),{width:S,height:_,measured:w(b({},N.measured),{width:S,height:_}),position:{x:re.HEADER_WIDTH,y:p}})}return N}),x&&u?p=r+o:p+=_}),f=f.map(m=>{if(m.id===s){let y=i?t:t+re.HEADER_WIDTH;return w(b({},m),{width:y,height:i?o:p,measured:{width:y,height:i?o:p}})}return m}),f};var Ki=(e,t,o)=>{var a,l,c,d,u,p,f,h;if(e.type==="LANE")return o;let n=(l=(a=t.measured)==null?void 0:a.width)!=null?l:0,r=(d=(c=t.measured)==null?void 0:c.height)!=null?d:0;e.position.y<Te&&(e.position.y=Te),e.position.x<re.HEADER_WIDTH+Te&&(e.position.x=re.HEADER_WIDTH+Te);let i=e.position.x+((p=(u=e.measured)==null?void 0:u.width)!=null?p:0),s=e.position.y+((h=(f=e.measured)==null?void 0:f.height)!=null?h:0);return i+Te>n&&(t.width=i+Te,t.measured.width=i+Te),s+Te>r&&(t.height=s+Te,t.measured.height=s+Te),o=o.map(E=>E.id===t.id?w(b({},E),{height:t.height,width:t.width,measured:t.measured}):E.id===e.id?w(b({},E),{position:e.position}):E),o};import{useCallback as bf}from"react";import{create as Tf}from"zustand";import{useStoreApi as _f}from"@xyflow/react";var ht=()=>{let e=_f();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 Xn(),!0}}};var Va=()=>{let{selectElements:e}=ht();return bf(()=>{let o=so.getState().pathEdgeIds;e(o)},[e])},so=Tf((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=b({},n.statusByNodeId),i=b({},n.statusData),s=!1;return o.forEach(a=>{let l=`${a.diagramId}-${a.activityId}`;r[a.diagramId]!==a.status&&(r[a.diagramId]=a.status,i[l]=a,s=!0)}),s?{statusByNodeId:r,statusData:i}:n})},getTaskStatus:o=>t().statusByNodeId[o]||null,clearTaskStatuses:()=>e({statusByNodeId:{},statusData:{},pathEdgeIds:[]}),setPathEdges:o=>{e({pathEdgeIds:o})},getPathEdgeIds:()=>t().pathEdgeIds,clearPathEdges:()=>{e({pathEdgeIds:[]})},calculateFlowPath:(o,n)=>{if(!o.length||!n.length)return;t().clearPathEdges();let r=n.filter(d=>t().statusByNodeId[d]);if(r.length<=1)return;let i=[],s={};o.forEach(d=>{s[d.source]||(s[d.source]=[]),s[d.source].push({targetId:d.target,edgeId:d.id})});let a=r[0],l=r[r.length-1];o.forEach(d=>{d.target===a&&i.push(d.id)}),o.forEach(d=>{d.source===l&&i.push(d.id)});let c=(d,u)=>{let p=[],f=new Set;for(p.push({node:d,path:[]}),f.add(d);p.length>0;){let{node:h,path:E}=p.shift();if(h===u)return E;let m=s[h]||[];for(let{targetId:y,edgeId:g}of m)f.has(y)||(f.add(y),p.push({node:y,path:[...E,g]}))}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})}}));import{useNodesInitialized as Vg,useReactFlow as Hg,useStore as Gg}from"@xyflow/react";import{useCallback as _n,useEffect as Bg,useRef as zg,useState as Pc}from"react";import{shallow as Yg}from"zustand/shallow";var vf={value:()=>{}};function Ga(){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 er(o)}function er(e){this._=e}function Nf(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}})}er.prototype=Ga.prototype={constructor:er,on:function(e,t){var o=this._,n=Nf(e+"",o),r,i=-1,s=n.length;if(arguments.length<2){for(;++i<s;)if((r=(e=n[i]).type)&&(r=wf(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]=Ha(o[r],e.name,t);else if(t==null)for(r in o)o[r]=Ha(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 er(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 wf(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function Ha(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=vf,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var qi=Ga;var tr="http://www.w3.org/1999/xhtml",Zi={svg:"http://www.w3.org/2000/svg",xhtml:tr,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function At(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),Zi.hasOwnProperty(t)?{space:Zi[t],local:e}:e}function If(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===tr&&t.documentElement.namespaceURI===tr?t.createElement(e):t.createElementNS(o,e)}}function Af(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function or(e){var t=At(e);return(t.local?Af:If)(t)}function Cf(){}function ao(e){return e==null?Cf:function(){return this.querySelector(e)}}function Ba(e){typeof e!="function"&&(e=ao(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 Pe(n,this._parents)}function Ji(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Sf(){return[]}function sn(e){return e==null?Sf:function(){return this.querySelectorAll(e)}}function Mf(e){return function(){return Ji(e.apply(this,arguments))}}function za(e){typeof e=="function"?e=Mf(e):e=sn(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 Pe(n,r)}function an(e){return function(){return this.matches(e)}}function nr(e){return function(t){return t.matches(e)}}var Pf=Array.prototype.find;function Lf(e){return function(){return Pf.call(this.children,e)}}function kf(){return this.firstElementChild}function Ya(e){return this.select(e==null?kf:Lf(typeof e=="function"?e:nr(e)))}var Rf=Array.prototype.filter;function Df(){return Array.from(this.children)}function Of(e){return function(){return Rf.call(this.children,e)}}function Fa(e){return this.selectAll(e==null?Df:Of(typeof e=="function"?e:nr(e)))}function Wa(e){typeof e!="function"&&(e=an(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 Pe(n,this._parents)}function rr(e){return new Array(e.length)}function Xa(){return new Pe(this._enter||this._groups.map(rr),this._parents)}function ln(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}ln.prototype={constructor:ln,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 Ua(e){return function(){return e}}function Vf(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 ln(e,i[s]);for(;s<l;++s)(a=t[s])&&(r[s]=a)}function Hf(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 ln(e,i[a]);for(a=0;a<d;++a)(l=t[a])&&c.get(p[a])===l&&(r[a]=l)}function Gf(e){return e.__data__}function $a(e,t){if(!arguments.length)return Array.from(this,Gf);var o=t?Hf:Vf,n=this._parents,r=this._groups;typeof e!="function"&&(e=Ua(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=Bf(e.call(d,d&&d.__data__,c,n)),h=f.length,E=a[c]=new Array(h),m=s[c]=new Array(h),y=l[c]=new Array(p);o(d,u,E,m,y,f,t);for(var g=0,x=0,T,_;g<h;++g)if(T=E[g]){for(g>=x&&(x=g+1);!(_=m[x])&&++x<h;);T._next=_||null}}return s=new Pe(s,n),s._enter=a,s._exit=l,s}function Bf(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Ka(){return new Pe(this._exit||this._groups.map(rr),this._parents)}function qa(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 Za(e){for(var t=e.selection?e.selection():e,o=this._groups,n=t._groups,r=o.length,i=n.length,s=Math.min(r,i),a=new Array(r),l=0;l<s;++l)for(var c=o[l],d=n[l],u=c.length,p=a[l]=new Array(u),f,h=0;h<u;++h)(f=c[h]||d[h])&&(p[h]=f);for(;l<r;++l)a[l]=o[l];return new Pe(a,this._parents)}function Ja(){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 Qa(e){e||(e=zf);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 Pe(r,this._parents).order()}function zf(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function ja(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function el(){return Array.from(this)}function tl(){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 nl(){return!this.node()}function rl(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 Yf(e){return function(){this.removeAttribute(e)}}function Ff(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Wf(e,t){return function(){this.setAttribute(e,t)}}function Xf(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Uf(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function $f(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 il(e,t){var o=At(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?Ff:Yf:typeof t=="function"?o.local?$f:Uf:o.local?Xf:Wf)(o,t))}function ir(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Kf(e){return function(){this.style.removeProperty(e)}}function qf(e,t,o){return function(){this.style.setProperty(e,t,o)}}function Zf(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function sl(e,t,o){return arguments.length>1?this.each((t==null?Kf:typeof t=="function"?Zf:qf)(e,t,o==null?"":o)):Gt(this.node(),e)}function Gt(e,t){return e.style.getPropertyValue(t)||ir(e).getComputedStyle(e,null).getPropertyValue(t)}function Jf(e){return function(){delete this[e]}}function Qf(e,t){return function(){this[e]=t}}function jf(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function al(e,t){return arguments.length>1?this.each((t==null?Jf:typeof t=="function"?jf:Qf)(e,t)):this.node()[e]}function ll(e){return e.trim().split(/^|\s+/)}function Qi(e){return e.classList||new cl(e)}function cl(e){this._node=e,this._names=ll(e.getAttribute("class")||"")}cl.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 dl(e,t){for(var o=Qi(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function ul(e,t){for(var o=Qi(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function em(e){return function(){dl(this,e)}}function tm(e){return function(){ul(this,e)}}function om(e,t){return function(){(t.apply(this,arguments)?dl:ul)(this,e)}}function pl(e,t){var o=ll(e+"");if(arguments.length<2){for(var n=Qi(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?om:t?em:tm)(o,t))}function nm(){this.textContent=""}function rm(e){return function(){this.textContent=e}}function im(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function fl(e){return arguments.length?this.each(e==null?nm:(typeof e=="function"?im:rm)(e)):this.node().textContent}function sm(){this.innerHTML=""}function am(e){return function(){this.innerHTML=e}}function lm(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function ml(e){return arguments.length?this.each(e==null?sm:(typeof e=="function"?lm:am)(e)):this.node().innerHTML}function cm(){this.nextSibling&&this.parentNode.appendChild(this)}function gl(){return this.each(cm)}function dm(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function hl(){return this.each(dm)}function yl(e){var t=typeof e=="function"?e:or(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function um(){return null}function xl(e,t){var o=typeof e=="function"?e:or(e),n=t==null?um:typeof t=="function"?t:ao(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function pm(){var e=this.parentNode;e&&e.removeChild(this)}function El(){return this.each(pm)}function fm(){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 _l(e){return this.select(e?mm:fm)}function bl(e){return arguments.length?this.property("__data__",e):this.node().__data__}function gm(e){return function(t){e.call(this,t,this.__data__)}}function hm(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 ym(e){return function(){var t=this.__on;if(t){for(var o=0,n=-1,r=t.length,i;o<r;++o)i=t[o],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++n]=i;++n?t.length=n:delete this.__on}}}function xm(e,t,o){return function(){var n=this.__on,r,i=gm(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 Tl(e,t,o){var n=hm(e+""),r,i=n.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,c=a.length,d;l<c;++l)for(r=0,d=a[l];r<i;++r)if((s=n[r]).type===d.type&&s.name===d.name)return d.value}return}for(a=t?xm:ym,r=0;r<i;++r)this.each(a(n[r],t,o));return this}function vl(e,t,o){var n=ir(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 Em(e,t){return function(){return vl(this,e,t)}}function _m(e,t){return function(){return vl(this,e,t.apply(this,arguments))}}function Nl(e,t){return this.each((typeof t=="function"?_m:Em)(e,t))}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,s;r<i;++r)(s=n[r])&&(yield s)}var bm=[null];function Pe(e,t){this._groups=e,this._parents=t}function Il(){return new Pe([[document.documentElement]],bm)}function Tm(){return this}Pe.prototype=Il.prototype={constructor:Pe,select:Ba,selectAll:za,selectChild:Ya,selectChildren:Fa,filter:Wa,data:$a,enter:Xa,exit:Ka,join:qa,merge:Za,selection:Tm,order:Ja,sort:Qa,call:ja,nodes:el,node:tl,size:ol,empty:nl,each:rl,attr:il,style:sl,property:al,classed:pl,text:fl,html:ml,raise:gl,lower:hl,append:yl,insert:xl,remove:El,clone:_l,datum:bl,on:Tl,dispatch:Nl,[Symbol.iterator]:wl};var Ct=Il;function sr(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function ji(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function un(){}var cn=.7,cr=1/cn,So="\\s*([+-]?\\d+)\\s*",dn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",yt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",vm=/^#([0-9a-f]{3,8})$/,Nm=new RegExp(`^rgb\\(${So},${So},${So}\\)$`),wm=new RegExp(`^rgb\\(${yt},${yt},${yt}\\)$`),Im=new RegExp(`^rgba\\(${So},${So},${So},${dn}\\)$`),Am=new RegExp(`^rgba\\(${yt},${yt},${yt},${dn}\\)$`),Cm=new RegExp(`^hsl\\(${dn},${yt},${yt}\\)$`),Sm=new RegExp(`^hsla\\(${dn},${yt},${yt},${dn}\\)$`),Al={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};sr(un,Bt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Cl,formatHex:Cl,formatHex8:Mm,formatHsl:Pm,formatRgb:Sl,toString:Sl});function Cl(){return this.rgb().formatHex()}function Mm(){return this.rgb().formatHex8()}function Pm(){return Dl(this).formatHsl()}function Sl(){return this.rgb().formatRgb()}function Bt(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=vm.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?Ml(t):o===3?new Ke(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?ar(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?ar(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=Nm.exec(e))?new Ke(t[1],t[2],t[3],1):(t=wm.exec(e))?new Ke(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Im.exec(e))?ar(t[1],t[2],t[3],t[4]):(t=Am.exec(e))?ar(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Cm.exec(e))?kl(t[1],t[2]/100,t[3]/100,1):(t=Sm.exec(e))?kl(t[1],t[2]/100,t[3]/100,t[4]):Al.hasOwnProperty(e)?Ml(Al[e]):e==="transparent"?new Ke(NaN,NaN,NaN,0):null}function Ml(e){return new Ke(e>>16&255,e>>8&255,e&255,1)}function ar(e,t,o,n){return n<=0&&(e=t=o=NaN),new Ke(e,t,o,n)}function Lm(e){return e instanceof un||(e=Bt(e)),e?(e=e.rgb(),new Ke(e.r,e.g,e.b,e.opacity)):new Ke}function Mo(e,t,o,n){return arguments.length===1?Lm(e):new Ke(e,t,o,n==null?1:n)}function Ke(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}sr(Ke,Mo,ji(un,{brighter(e){return e=e==null?cr:Math.pow(cr,e),new Ke(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?cn:Math.pow(cn,e),new Ke(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ke(co(this.r),co(this.g),co(this.b),dr(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:Pl,formatHex:Pl,formatHex8:km,formatRgb:Ll,toString:Ll}));function Pl(){return`#${lo(this.r)}${lo(this.g)}${lo(this.b)}`}function km(){return`#${lo(this.r)}${lo(this.g)}${lo(this.b)}${lo((isNaN(this.opacity)?1:this.opacity)*255)}`}function Ll(){let e=dr(this.opacity);return`${e===1?"rgb(":"rgba("}${co(this.r)}, ${co(this.g)}, ${co(this.b)}${e===1?")":`, ${e})`}`}function dr(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function co(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function lo(e){return e=co(e),(e<16?"0":"")+e.toString(16)}function kl(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new ut(e,t,o,n)}function Dl(e){if(e instanceof ut)return new ut(e.h,e.s,e.l,e.opacity);if(e instanceof un||(e=Bt(e)),!e)return new ut;if(e instanceof ut)return e;e=e.rgb();var t=e.r/255,o=e.g/255,n=e.b/255,r=Math.min(t,o,n),i=Math.max(t,o,n),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 ut(s,a,l,e.opacity)}function Ol(e,t,o,n){return arguments.length===1?Dl(e):new ut(e,t,o,n==null?1:n)}function ut(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}sr(ut,Ol,ji(un,{brighter(e){return e=e==null?cr:Math.pow(cr,e),new ut(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?cn:Math.pow(cn,e),new ut(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,o=this.l,n=o+(o<.5?o:1-o)*t,r=2*o-n;return new Ke(es(e>=240?e-240:e+120,r,n),es(e,r,n),es(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new ut(Rl(this.h),lr(this.s),lr(this.l),dr(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=dr(this.opacity);return`${e===1?"hsl(":"hsla("}${Rl(this.h)}, ${lr(this.s)*100}%, ${lr(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Rl(e){return e=(e||0)%360,e<0?e+360:e}function lr(e){return Math.max(0,Math.min(1,e||0))}function es(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 ts(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 Vl(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 ts((o-n/t)*t,s,r,i,a)}}function Hl(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 ts((o-n/t)*t,r,i,s,a)}}var os=e=>()=>e;function Rm(e,t){return function(o){return e+o*t}}function Dm(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 Gl(e){return(e=+e)==1?ur:function(t,o){return o-t?Dm(t,o,e):os(isNaN(t)?o:t)}}function ur(e,t){var o=t-e;return o?Rm(e,o):os(isNaN(e)?t:e)}var pr=function e(t){var o=Gl(t);function n(r,i){var s=o((r=Mo(r)).r,(i=Mo(i)).r),a=o(r.g,i.g),l=o(r.b,i.b),c=ur(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 Bl(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=Mo(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 Om=Bl(Vl),Vm=Bl(Hl);function st(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var rs=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ns=new RegExp(rs.source,"g");function Hm(e){return function(){return e}}function Gm(e){return function(t){return e(t)+""}}function is(e,t){var o=rs.lastIndex=ns.lastIndex=0,n,r,i,s=-1,a=[],l=[];for(e=e+"",t=t+"";(n=rs.exec(e))&&(r=ns.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:st(n,r)})),o=ns.lastIndex;return o<t.length&&(i=t.slice(o),a[s]?a[s]+=i:a[++s]=i),a.length<2?l[0]?Gm(l[0].x):Hm(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 zl=180/Math.PI,fr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ss(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)*zl,skewX:Math.atan(l)*zl,scaleX:s,scaleY:a}}var mr;function Yl(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?fr:ss(t.a,t.b,t.c,t.d,t.e,t.f)}function Fl(e){return e==null?fr:(mr||(mr=document.createElementNS("http://www.w3.org/2000/svg","g")),mr.setAttribute("transform",e),(e=mr.transform.baseVal.consolidate())?(e=e.matrix,ss(e.a,e.b,e.c,e.d,e.e,e.f)):fr)}function Wl(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,p,f,h){if(c!==u||d!==p){var E=f.push("translate(",null,t,null,o);h.push({i:E-4,x:st(c,u)},{i:E-2,x:st(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:st(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:st(c,d)}):d&&u.push(r(u)+"skewX("+d+n)}function l(c,d,u,p,f,h){if(c!==u||d!==p){var E=f.push(r(f)+"scale(",null,",",null,")");h.push({i:E-4,x:st(c,u)},{i:E-2,x:st(d,p)})}else(u!==1||p!==1)&&f.push(r(f)+"scale("+u+","+p+")")}return function(c,d){var u=[],p=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,u,p),s(c.rotate,d.rotate,u,p),a(c.skewX,d.skewX,u,p),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,p),c=d=null,function(f){for(var h=-1,E=p.length,m;++h<E;)u[(m=p[h]).i]=m.x(f);return u.join("")}}}var as=Wl(Yl,"px, ","px)","deg)"),ls=Wl(Fl,", ",")",")");var Po=0,fn=0,pn=0,Ul=1e3,gr,mn,hr=0,uo=0,yr=0,gn=typeof performance=="object"&&performance.now?performance:Date,$l=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function yn(){return uo||($l(Bm),uo=gn.now()+yr)}function Bm(){uo=0}function hn(){this._call=this._time=this._next=null}hn.prototype=xr.prototype={constructor:hn,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?yn():+o)+(t==null?0:+t),!this._next&&mn!==this&&(mn?mn._next=this:gr=this,mn=this),this._call=e,this._time=o,cs()},stop:function(){this._call&&(this._call=null,this._time=1/0,cs())}};function xr(e,t,o){var n=new hn;return n.restart(e,t,o),n}function Kl(){yn(),++Po;for(var e=gr,t;e;)(t=uo-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Po}function Xl(){uo=(hr=gn.now())+yr,Po=fn=0;try{Kl()}finally{Po=0,Ym(),uo=0}}function zm(){var e=gn.now(),t=e-hr;t>Ul&&(yr-=t,hr=e)}function Ym(){for(var e,t=gr,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:gr=o);mn=e,cs(n)}function cs(e){if(!Po){fn&&(fn=clearTimeout(fn));var t=e-uo;t>24?(e<1/0&&(fn=setTimeout(Xl,e-gn.now()-yr)),pn&&(pn=clearInterval(pn))):(pn||(hr=gn.now(),pn=setInterval(zm,Ul)),Po=1,$l(Xl))}}function Er(e,t,o){var n=new hn;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var Fm=qi("start","end","cancel","interrupt"),Wm=[],Jl=0,ql=1,br=2,_r=3,Zl=4,Tr=5,xn=6;function zt(e,t,o,n,r,i){var s=e.__transition;if(!s)e.__transition={};else if(o in s)return;Xm(e,o,{name:t,index:n,group:r,on:Fm,tween:Wm,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Jl})}function En(e,t){var o=Le(e,t);if(o.state>Jl)throw new Error("too late; already scheduled");return o}function Ve(e,t){var o=Le(e,t);if(o.state>_r)throw new Error("too late; already running");return o}function Le(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function Xm(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=xr(i,0,o.time);function i(c){o.state=ql,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!==ql)return l();for(d in n)if(f=n[d],f.name===o.name){if(f.state===_r)return Er(s);f.state===Zl?(f.state=xn,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete n[d]):+d<t&&(f.state=xn,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete n[d])}if(Er(function(){o.state===_r&&(o.state=Zl,o.timer.restart(a,o.delay,o.time),a(c))}),o.state=br,o.on.call("start",e,e.__data__,o.index,o.group),o.state===br){for(o.state=_r,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=Tr,1),u=-1,p=r.length;++u<p;)r[u].call(e,d);o.state===Tr&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=xn,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function ds(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>br&&n.state<Tr,n.state=xn,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[s]}i&&delete e.__transition}}function Ql(e){return this.each(function(){ds(this,e)})}function Um(e,t){var o,n;return function(){var r=Ve(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 $m(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=Ve(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 jl(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=Le(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?Um:$m)(o,e,t))}function Lo(e,t,o){var n=e._id;return e.each(function(){var r=Ve(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return Le(r,n).value[t]}}function vr(e,t){var o;return(typeof t=="number"?st:t instanceof Bt?pr:(o=Bt(t))?(t=o,pr):is)(e,t)}function Km(e){return function(){this.removeAttribute(e)}}function qm(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Zm(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 Jm(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 Qm(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 jm(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 ec(e,t){var o=At(e),n=o==="transform"?ls:vr;return this.attrTween(e,typeof t=="function"?(o.local?jm:Qm)(o,n,Lo(this,"attr."+e,t)):t==null?(o.local?qm:Km)(o):(o.local?Jm:Zm)(o,n,t))}function eg(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function tg(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function og(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&tg(e,i)),o}return r._value=t,r}function ng(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&eg(e,i)),o}return r._value=t,r}function tc(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=At(e);return this.tween(o,(n.local?og:ng)(n,t))}function rg(e,t){return function(){En(this,e).delay=+t.apply(this,arguments)}}function ig(e,t){return t=+t,function(){En(this,e).delay=t}}function oc(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?rg:ig)(t,e)):Le(this.node(),t).delay}function sg(e,t){return function(){Ve(this,e).duration=+t.apply(this,arguments)}}function ag(e,t){return t=+t,function(){Ve(this,e).duration=t}}function nc(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?sg:ag)(t,e)):Le(this.node(),t).duration}function lg(e,t){if(typeof t!="function")throw new Error;return function(){Ve(this,e).ease=t}}function rc(e){var t=this._id;return arguments.length?this.each(lg(t,e)):Le(this.node(),t).ease}function cg(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;Ve(this,e).ease=o}}function ic(e){if(typeof e!="function")throw new Error;return this.each(cg(this._id,e))}function sc(e){typeof e!="function"&&(e=an(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 Xe(n,this._parents,this._name,this._id)}function ac(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 Xe(s,this._parents,this._name,this._id)}function dg(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 ug(e,t,o){var n,r,i=dg(t)?En:Ve;return function(){var s=i(this,e),a=s.on;a!==n&&(r=(n=a).copy()).on(t,o),s.on=r}}function lc(e,t){var o=this._id;return arguments.length<2?Le(this.node(),o).on.on(e):this.each(ug(o,e,t))}function pg(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function cc(){return this.on("end.remove",pg(this._id))}function dc(e){var t=this._name,o=this._id;typeof e!="function"&&(e=ao(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,zt(c[p],t,o,p,c,Le(d,o)));return new Xe(i,this._parents,t,o)}function uc(e){var t=this._name,o=this._id;typeof e!="function"&&(e=sn(e));for(var n=this._groups,r=n.length,i=[],s=[],a=0;a<r;++a)for(var l=n[a],c=l.length,d,u=0;u<c;++u)if(d=l[u]){for(var p=e.call(d,d.__data__,u,l),f,h=Le(d,o),E=0,m=p.length;E<m;++E)(f=p[E])&&zt(f,t,o,E,p,h);i.push(p),s.push(d)}return new Xe(i,s,t,o)}var fg=Ct.prototype.constructor;function pc(){return new fg(this._groups,this._parents)}function mg(e,t){var o,n,r;return function(){var i=Gt(this,e),s=(this.style.removeProperty(e),Gt(this,e));return i===s?null:i===o&&s===n?r:r=t(o=i,n=s)}}function fc(e){return function(){this.style.removeProperty(e)}}function gg(e,t,o){var n,r=o+"",i;return function(){var s=Gt(this,e);return s===r?null:s===n?i:i=t(n=s,o)}}function hg(e,t,o){var n,r,i;return function(){var s=Gt(this,e),a=o(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),Gt(this,e))),s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a))}}function yg(e,t){var o,n,r,i="style."+t,s="end."+i,a;return function(){var l=Ve(this,e),c=l.on,d=l.value[i]==null?a||(a=fc(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(s,r=d),l.on=n}}function mc(e,t,o){var n=(e+="")=="transform"?as:vr;return t==null?this.styleTween(e,mg(e,n)).on("end.style."+e,fc(e)):typeof t=="function"?this.styleTween(e,hg(e,n,Lo(this,"style."+e,t))).each(yg(this._id,e)):this.styleTween(e,gg(e,n,t),o).on("end.style."+e,null)}function xg(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function Eg(e,t,o){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&xg(e,s,o)),n}return i._value=t,i}function 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,Eg(e,t,o==null?"":o))}function _g(e){return function(){this.textContent=e}}function bg(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function hc(e){return this.tween("text",typeof e=="function"?bg(Lo(this,"text",e)):_g(e==null?"":e+""))}function Tg(e){return function(t){this.textContent=e.call(this,t)}}function vg(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&Tg(r)),t}return n._value=e,n}function yc(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,vg(e))}function xc(){for(var e=this._name,t=this._id,o=Nr(),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=Le(l,t);zt(l,e,o,c,s,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Xe(n,this._parents,e,o)}function Ec(){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=Ve(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 Ng=0;function Xe(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function _c(e){return Ct().transition(e)}function Nr(){return++Ng}var St=Ct.prototype;Xe.prototype=_c.prototype={constructor:Xe,select:dc,selectAll:uc,selectChild:St.selectChild,selectChildren:St.selectChildren,filter:sc,merge:ac,selection:pc,transition:xc,call:St.call,nodes:St.nodes,node:St.node,size:St.size,empty:St.empty,each:St.each,on:lc,attr:ec,attrTween:tc,style:mc,styleTween:gc,text:hc,textTween:yc,remove:cc,tween:jl,delay:oc,duration:nc,ease:rc,easeVarying:ic,end:Ec,[Symbol.iterator]:St[Symbol.iterator]};function wr(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var wg={time:null,delay:0,duration:250,ease:wr};function Ig(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 bc(e){var t,o;e instanceof Xe?(t=e._id,e=e._name):(t=Nr(),(o=wg).time=yn(),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])&&zt(l,e,t,c,s,o||Ig(l,t));return new Xe(n,this._parents,e,t)}Ct.prototype.interrupt=Ql;Ct.prototype.transition=bc;function Yt(e,t,o){this.k=e,this.x=t,this.y=o}Yt.prototype={constructor:Yt,scale:function(e){return e===1?this:new Yt(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Yt(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 Ir=new Yt(1,0,0);Ar.prototype=Yt.prototype;function Ar(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Ir;return e.__zoom}var Cg=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var Tc;(function(e){e.Strict="strict",e.Loose="loose"})(Tc||(Tc={}));var vc;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(vc||(vc={}));var Nc;(function(e){e.Partial="partial",e.Full="full"})(Nc||(Nc={}));var wc;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(wc||(wc={}));var Ic;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ic||(Ic={}));var qe;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(qe||(qe={}));var wI={[qe.Left]:qe.Right,[qe.Right]:qe.Left,[qe.Top]:qe.Bottom,[qe.Bottom]:qe.Top};var Sg=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var Mg=(e,t=[0,0])=>{var a;let{width:o,height:n}=Pg(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 Cr=(e,t=[0,0])=>{var r,i,s,a,l,c,d,u;let{x:o,y:n}=Sg(e)?e.internals.positionAbsolute:Mg(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 Pg(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 II={[qe.Left]:{x:-1,y:0},[qe.Right]:{x:1,y:0},[qe.Top]:{x:0,y:-1},[qe.Bottom]:{x:0,y:1}};var Lg={nodeOrigin:[0,0],nodeExtent:Cg,elevateNodesOnSelect:!0,defaults:{}},AI=w(b({},Lg),{checkEquality:!0});var Ac;(function(e){e.Line="line",e.Handle="handle"})(Ac||(Ac={}));var kg={width:0,height:0,x:0,y:0},CI=w(b({},kg),{pointerX:0,pointerY:0,aspectRatio:1});var Rg=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function Dg(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 Og(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 Sr=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)||!Rg(f.nodeBox,r))continue;let h=Math.abs(f.position-o);if(h>Mr)continue;let m=Dg(f.nodeBox,n)>0?0:Og(f.nodeBox,n);c.push({line:f,lineDist:h,nodeDist:m})}let d=.5,u=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;c.sort((f,h)=>{if(u){if(f.line===u&&h.line!==u)return-1;if(h.line===u&&f.line!==u)return 1}return Math.abs(f.lineDist-h.lineDist)<=d?f.nodeDist-h.nodeDist:f.lineDist-h.lineDist});let p=c.length>0?c[0].line:void 0;return p&&(t==="horizontal"?this.lastHorizontalLine=p:this.lastVerticalLine=p),p}};function Cc(e,t=po,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=Cr(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 Sc(e,t,o,n,r=Object.keys(po)){let i=[];for(let a of r){let l=po[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 Mc(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)<=Mr&&(r=l,s=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=Mr&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:s}}var Mr=10,po={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}};import{jsx as Kg}from"react/jsx-runtime";var Fg=new Sr;function Wg(e,t,o,n){var d,u,p,f,h,E;let r=1/0,i=1/0,s=-1/0,a=-1/0,l=new Set;for(let m of e){let y=t.find(N=>N.id===m.id);if(!y)continue;l.add(y.id);let g=o(y.id);if(!g)continue;let x=g.parentId?o(g.parentId):void 0,T=m.position.x+((d=x==null?void 0:x.internals.positionAbsolute.x)!=null?d:0),_=m.position.y+((u=x==null?void 0:x.internals.positionAbsolute.y)!=null?u:0),I=(f=(p=y.measured)==null?void 0:p.width)!=null?f:0,v=(E=(h=y.measured)==null?void 0:h.height)!=null?E:0;r=Math.min(r,T),i=Math.min(i,_),s=Math.max(s,T+I),a=Math.max(a,_+v)}if(r===1/0)return null;let c=Object.keys(po);return{bounds:{x:r,y:i,x2:s,y2:a},excludedNodeIds:l,anchors:n?["top","left"]:c}}function Xg(e,t,o){var c,d,u,p,f,h,E,m;let n=t.find(y=>y.id===e.id);if(!n)return null;let r=o(n.id);if(!r)return null;let i=r.internals.positionAbsolute.x,s=r.internals.positionAbsolute.y,a=(p=(u=(c=e.dimensions)==null?void 0:c.width)!=null?u:(d=n.measured)==null?void 0:d.width)!=null?p:0,l=(m=(E=(f=e.dimensions)==null?void 0:f.height)!=null?E:(h=n.measured)==null?void 0:h.height)!=null?m:0;return{bounds:{x:i,y:s,x2:i+a,y2:s+l},excludedNodeIds:new Set([n.id]),anchors:["right","bottom"]}}function Ug(e,t,o,n){return e.length>0?Wg(e,o,n,!!t):t?Xg(t,o,n):null}function Lc(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 $g(e,t,o,n,r,i){r&&(e.forEach(s=>{s.position&&(s.position.x-=o)}),Lc(t,e,"width",o)),i&&(e.forEach(s=>{s.position&&(s.position.y-=n)}),Lc(t,e,"height",n))}function Pr(){let[e,t]=Pc(void 0),[o,n]=Pc(void 0),{width:r,height:i}=Gg(m=>({width:m.width,height:m.height}),Yg),s=Vg(),a=zg(Fg),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=Hg(),u=_n(()=>{t(void 0),n(void 0)},[]),p=_n(m=>{let y=m!=null?m:d();u();let g=Cc(y,po,c);a.current.initialize(g)},[c,u,d]),f=_n(()=>{setTimeout(()=>{p()},100)},[p]);Bg(()=>{s&&p(d())},[s,p,d]);let h=_n((m,y)=>{if(!a.current||m.length===0)return;let g=m.filter(A=>A.type==="dimensions");if(g.length>1)return;u();let x=m.filter(A=>A.type==="position"&&!!A.position),T=g[0];if(x.length===0&&!T)return;let _=Ug(x,T,y,c);if(!_)return;let{x:I,y:v}=l({x:0,y:0}),{x:N,y:S}=l({x:r,y:i}),M={x:I,y:v,x2:N,y2:S},{horizontal:L,vertical:k}=Sc(a.current,M,_.bounds,_.excludedNodeIds,_.anchors),{deltaX:O,deltaY:G,snappedX:F,snappedY:Q}=Mc(_.bounds,L,k);if(!F&&!Q)return;let $=x.some(A=>A.dragging),K=!!(T!=null&&T.resizing);($||K)&&(F&&n(k==null?void 0:k.line),Q&&t(L==null?void 0:L.line)),$g(x,T,O,G,F,Q)},[l,c,r,i,t,n,u]),E=_n(()=>Kg(kc,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:p,forceRebuildIndex:f,updateHelperLines:h,helperLineHorizontal:e,helperLineVertical:o,HelperLines:E}}import{reconnectEdge as ex,useReactFlow as tx}from"@xyflow/react";import{useCallback as yo,useRef as ox}from"react";var Mt=e=>new Map(e.map(t=>[t.id,t])),bn=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),Rc=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),us=e=>e.some(t=>t.type==="START_EVENT"),ko=(e,t)=>e==="START_EVENT"?!us(t):!0,Dc=(e,t,o,n,r)=>{let i=Mt(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:bn(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Oc=(e,t,o,n,r)=>{let i=Mt(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:Rc(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Lr=(e,t,o,n,r)=>{var c;let i=Mt(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:bn(e,n,r).filter(d=>{let u=i.get(d.target);return(u==null?void 0:u.type)!=="ANNOTATION"}).length>=2},Vc=(e,t,o)=>{var s,a,l,c;let n=Mt(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"},kr=(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"},Hc=(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"},Tn=(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"},Rr=(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"},fo=(e,t,o,n)=>{let r=Mt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:Rc(e,o,n).some(a=>{let l=r.get(a.source);return(l==null?void 0:l.type)==="START_EVENT"})},vn=(e,t,o,n)=>{let r=Mt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:bn(e,o,n).some(a=>{let l=r.get(a.target);return(l==null?void 0:l.type)==="END_EVENT"})},Gc=(e,t,o,n,r)=>{let i=Mt(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"?vn(t,o,n,r):(a==null?void 0:a.type)==="END_EVENT"&&(s==null?void 0:s.type)==="TASK"?fo(e,o,n,r):!1},Dr=(e,t,o)=>bn(e,t,o).length>0,Or=(e,t,o,n,r)=>{let i=Mt(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:bn(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var Bc=(e,t,o,n,r)=>{var a,l;let i=Mt(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 qg=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!Bc(e.sourceNodeId,e.targetNodeId,e.edges,e.nodes,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!Dc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!Oc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!Lr(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!Or(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:Vc(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"&&Hc(e.targetNodeId,e.nodes)),reason:"start_event_to_subprocess_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&Tn(e.targetNodeId,e.nodes)),reason:"start_event_to_service_task_not_allowed"}),e=>({isValid:!(Tn(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:!(kr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(Rr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(fo(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!Gc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(vn(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(Dr(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"})],ps=e=>{for(let t of qg){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var Zg=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:Lr(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:us(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:kr(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Rr(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Tn(e.sourceNodeId,e.nodes),reason:"service_task_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:fo(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:vn(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Dr(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Or(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],zc=e=>{let t=Zg.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}};import{BaseEdge as Ah,EdgeLabelRenderer as Ch,getStraightPath as Sh,useInternalNode as Fc,useViewport as Mh}from"@xyflow/react";import{useCallback as Jg}from"react";import{useStore as Qg}from"@xyflow/react";function xt(){return Qg(Jg(e=>e.nodes.filter(o=>o.selected).length+e.edges.filter(o=>o.selected).length>=2,[]))}import{Button as eh,Tooltip as th,TooltipContent as oh,TooltipTrigger as nh,useTranslation as rh}from"@produto-lecom/lecom-ui";import{Settings as ih}from"lucide-react";import{getIncomers as Vr,getOutgoers as Hr,useReactFlow as jg}from"@xyflow/react";var Gr=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=jg(),{selectElements:r}=ht(),i=m=>{let y=o(),g=n(),x=Vr(m,y,g),T=Hr(m,y,g),_=x.some(v=>v.type==="START_EVENT"),I=T.some(v=>v.type==="END_EVENT");return _?"start":I?"end":"between"},s=(m,y,g)=>{var _,I,v,N,S;if(!m)return;let x={type:m.type,variant:(_=m.data)==null?void 0:_.variant,attribute:(I=m.data)==null?void 0:I.attribute},T={id:m.id,position:i(m),label:(v=m.data)==null?void 0:v.label,node:x};return m.type==="TASK"&&((N=m.data)==null?void 0:N.variant)==="SUBPROCESS"?w(b({},T),{type:"sub_process"}):m.type==="TASK"&&((S=m.data)==null?void 0:S.variant)==="SERVICE_TASK"?w(b({},T),{type:"service_task"}):m.type==="GATEWAY"?w(b({},T),{type:"gateway",variant:a(m,y,g)}):w(b({},T),{type:"activity"})},a=(m,y,g)=>{if(m.type!=="GATEWAY")return;let x=Vr(m,y,g),T=!1,_=!1;if(x.forEach(I=>{var v,N;I.type==="TASK"&&(((v=I.data)==null?void 0:v.variant)==="SCRIPT"&&(T=!0),((N=I.data)==null?void 0:N.attribute)==="LOOP"&&(_=!0))}),T&&_)return"script_loop";if(T)return"script";if(_)return"loop"},l=(m,y,g)=>{var v,N,S,M,L;let x=e(m.source),T=e(m.target);if(!x||!T)return"simple";if(Hr(x,y,g).some(k=>k.type==="END_EVENT"))return"final";if(x.type==="GATEWAY")switch((v=x.data)==null?void 0:v.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(x.type==="TASK"){let k=(N=x.data)==null?void 0:N.variant,O=(S=x.data)==null?void 0:S.attribute;if(k==="SUBPROCESS")return"from_sub_process";if(k==="SERVICE_TASK")return"from_service_task";if(T.type==="TASK"&&((M=T.data)==null?void 0:M.variant)==="SUBPROCESS")return"to_sub_process";if(T.type==="TASK"&&((L=T.data)==null?void 0:L.variant)==="SERVICE_TASK")return"to_service_task";let G=k==="SCRIPT",F=O==="LOOP";return G&&F?"script_loop":G?"script":F?"loop":"simple"}return"simple"},c=(m,y,g)=>{let x=[];function T(I,v,N=0){let S=s(I,y,g);if(S.depth=N,v.push(S),I.type==="TASK"){x.push([...v]),v.pop();return}let M=Vr(I,y,g);if(M.length)for(let L of M)T(L,v,N+1);v.pop()}let _=Vr(m,y,g);for(let I of _)T(I,[]);return x},d=(m,y,g)=>{let x=[];function T(I,v,N=0){let S=s(I,y,g);if(S.depth=N,v.push(S),I.type==="TASK"){x.push([...v]),v.pop();return}let M=Hr(I,y,g);if(M.length)for(let L of M)T(L,v,N+1);v.pop()}let _=Hr(m,y,g);for(let I of _)T(I,[]);return x},u=(m,y,g)=>(g=g.filter(T=>T.source===m.id),g.map(T=>{var v;let _=e(T.target),I;return _&&(I=s(_,y,g)),{id:T.id,type:"routing",variant:l(T,y,g),label:(v=T.data)==null?void 0:v.label,target:I}})),p=m=>{let y=e(m);if(!y)return;let g=o(),x=n(),T=s(y,g,x);return T.sources=c(y,g,x),T.targets=d(y,g,x),T.edgeTargets=u(y,g,x),y.type==="GATEWAY"&&(T.variant=a(y,g,x)),T},f=m=>{let y=t(m);if(!y)return;let g=o(),x=n(),T=l(y,g,x),I={id:y.id,type:"routing",variant:T,gatewayVariant:void 0},v=e(y.source);if(v){let S=s(v,g,x);I.source=S;let M=a(v,g,x);if(I.gatewayVariant=M,v.type==="TASK")I.sources=[[S]];else{let L=c(v,g,x);I.sources=L.length?L:[[S]]}}let N=e(y.target);if(N){let S=s(N,g,x);if(I.target=S,N.type==="TASK")I.targets=[[S]];else{let M=d(N,g,x);I.targets=M.length?M:[[S]]}}return I},h=m=>{let y=e(m);if(y)return p(y.id);let g=t(m);if(g)return f(g.id)};return{configureElement:m=>{let y=h(m);if(y)return r([m]),y},getConfigureElement:h,getNodeConfigure:p,getEdgeConfigure:f}};import{jsx as Br,jsxs as ah}from"react/jsx-runtime";var sh={node:"editor.toolbar.configure_node",edge:"editor.toolbar.configure_edge",gateway:"editor.toolbar.configure_gateway"},Ft=({elementId:e,elementType:t="node"})=>{let{t:o}=rh(),{onConfigureElement:n}=J(),{getConfigureElement:r}=Gr();return ah(th,{children:[Br(nh,{asChild:!0,children:Br(eh,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let s=r(e);s&&(n==null||n(s))},children:Br(ih,{size:16})})}),Br(oh,{color:"black",children:o(sh[t])})]})};import{Button as ch,Tooltip as dh,TooltipContent as uh,TooltipTrigger as ph,useTranslation as fh}from"@produto-lecom/lecom-ui";import{useReactFlow as mh}from"@xyflow/react";import{TrashIcon as gh}from"lucide-react";import{useNotificationToast as lh}from"@produto-lecom/lecom-ui";function De(){let{toast:e}=Nn(),{toast:t}=lh();return{toast:e||t}}import{jsx as zr,jsxs as hh}from"react/jsx-runtime";var Yr=({elementId:e,elementType:t="node"})=>{let{t:o}=fh(),{toast:n}=De(),{deleteElements:r,getNodes:i}=mh();return hh(dh,{children:[zr(ph,{asChild:!0,children:zr(ch,{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:zr(gh,{size:16})})}),zr(uh,{color:"black",children:o("editor.toolbar.delete")})]})};import{Button as yh,Tooltip as xh,TooltipContent as Eh,TooltipTrigger as _h,useTranslation as bh}from"@produto-lecom/lecom-ui";import{MoveUpRightIcon as Th}from"lucide-react";import{useCallback as vh}from"react";import{jsx as Fr,jsxs as Nh}from"react/jsx-runtime";var Ro=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=bh(),r=vh(i=>{i.stopPropagation();let s=document.querySelectorAll(`.react-flow__handle.source[data-nodeid="${e}"]`);if(s.length===0)return;let a=Array.from(s).reduce((p,f)=>{let h=p.getBoundingClientRect(),E=f.getBoundingClientRect(),m=Math.hypot(i.clientX-(h.left+h.width/2),i.clientY-(h.top+h.height/2));return Math.hypot(i.clientX-(E.left+E.width/2),i.clientY-(E.top+E.height/2))<m?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 Nh(xh,{children:[Fr(_h,{asChild:!0,children:Fr(yh,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:Fr(Th,{size:16})})}),Fr(Eh,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};import{jsx as wn}from"react/jsx-runtime";var Do=i=>{var s=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=s,r=mt(s,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:a}=J(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d,isToEndEvent:u}=Qn(o,n),p=!l&&!c&&!d&&!u,f=[{component:wn(Yr,{elementId:e,elementType:"edge"})}],h=()=>a==="view"?p?[{component:wn(Ft,{elementId:e,elementType:"edge"})}]:[]:p?[{component:wn(Ft,{elementId:e,elementType:"edge"})},...f]:f,m=(y=>{switch(y){case"SEQUENCE_EDGE":return h();case"MESSAGE_EDGE":return a==="view"?[]:[...f];case"ANNOTATION_EDGE":return a==="view"?[]:[...f];default:return[]}})(t);if(!(m.length===0||a==="readonly"))return wn("div",w(b({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:m.map((y,g)=>wn("div",{children:y.component},g))}))};import{useViewport as wh}from"@xyflow/react";import{useMemo as Ih}from"react";import{jsx as Yc}from"react/jsx-runtime";var Et=12,Oo=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:s}=wh(),a=1/s,l=Ih(()=>t===n?{bottom:`${Et}px`,transform:"translateX(-50%)"}:e===o?{left:`${Et}px`,transform:r?"translateY(-100%)":"translateY(-50%)"}:n>t&&o>e?{left:`${Et}px`,bottom:`${Et}px`}:n>t&&o<e?{right:`${Et}px`,bottom:`${Et}px`}:t>n&&o>e?{right:`${Et}px`,bottom:`${Et}px`}:{left:`${Et}px`,bottom:`${Et}px`},[e,t,o,n,r]);return Yc("div",{style:{transform:`scale(${a})`},children:Yc("div",{className:"absolute pointer-events-auto",style:b({},l),children:i})})};import{jsx as Vo,jsxs as Wc}from"react/jsx-runtime";var Ho={type:"ANNOTATION_EDGE",reconnectable:!0},Xc=({id:e,source:t,target:o,selected:n,data:r})=>{let{isReadOnly:i,edgeHighlight:s}=J(),a=xt(),{zoom:l}=Mh(),c=Fc(t),d=Fc(o);if(!c||!d)return null;let{sx:u,sy:p,tx:f,ty:h}=Co(c,d),[E,m,y]=Sh({sourceX:u,sourceY:p,targetX:f,targetY:h}),g=s&&(n||(c==null?void 0:c.selected)||(d==null?void 0:d.selected));return Wc("g",{className:H("group bpmn-edge",{"is-highlighted":g}),children:[Vo("path",{d:E,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/l),style:{pointerEvents:"stroke",cursor:"pointer"}}),Wc("g",{className:H("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!i,"text-blue-500 group-hover:text-blue-600":g}),children:[Vo(Ah,{id:e,path:E,interactionWidth:0,strokeDasharray:4,className:H("stroke-2 stroke-current transition-[stroke] duration-75 group-hover:stroke-[2.5px]",{"stroke-red-500 hover:stroke-red-600":r==null?void 0:r.hasError,"stroke-blue-500 hover:stroke-blue-600 stroke-[3px]":g&&!(r!=null&&r.hasError)})}),Vo(Ch,{children:Vo("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${m}px, ${y}px)`},children:n&&!a&&Vo(Oo,{sx:u,sy:p,tx:f,ty:h,children:Vo(Do,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})})})]})]})};import $h,{useState as td,useCallback as Qr,useMemo as jr,useEffect as Kh,useRef as gs}from"react";import{BaseEdge as qh,EdgeLabelRenderer as Zh,MarkerType as od,useInternalNode as nd,useReactFlow as Jh,useStore as rd,useViewport as Qh,Position as Yo}from"@xyflow/react";import{useCallback as Ph,useEffect as fs,useRef as Uc,useState as Lh}from"react";import{jsx as Kc}from"react/jsx-runtime";var ms=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,$c=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Escape","Shift"],Ge=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:s,onBlur:a,onInput:l,onInvalidFirstCharacter:c,skipFirstCharValidation:d})=>{let u=Uc(null),p=Uc(null),[f,h]=Lh(!1);fs(()=>()=>{p.current&&clearTimeout(p.current)},[]),fs(()=>{h(i!=null?i:!1)},[i]),fs(()=>{if(f&&u.current){u.current.focus();let _=document.createRange();_.selectNodeContents(u.current);let I=window.getSelection();I&&(I.removeAllRanges(),I.addRange(_))}},[f]);let E=Ph(()=>{p.current||(c==null||c(),p.current=setTimeout(()=>{p.current=null},500))},[c]),m=_=>{_.stopPropagation(),f||h(!0)},y=_=>{let I=_.currentTarget.innerText.replace(/\n$/,""),v=t&&I.length>=t,N=window.getSelection(),S=(N==null?void 0:N.toString())||"",M=S.length>0,L=(_.ctrlKey||_.metaKey)&&!_.altKey,k=L&&_.key==="a",O=L&&_.key==="c",G=L&&_.key==="x",F=L&&_.key==="v",Q=I.length===0||M&&S.length===I.length;if(!d&&Q&&!ms.test(_.key)&&!$c.includes(_.key)&&!L){_.preventDefault(),E();return}v&&!M&&($c.includes(_.key)||k||O||G||F||_.preventDefault())},g=_=>{_.preventDefault();let I=_.clipboardData.getData("text/plain").replace(/\r\n/g,`
|
|
2
2
|
`).replace(/\r/g,`
|
|
3
|
-
`),
|
|
3
|
+
`),v=_.currentTarget.innerText.replace(/\n$/,""),N=window.getSelection();if(!N||N.rangeCount===0)return;let S=N.toString(),M=v.length-S.length,L=t?Math.max(0,t-M):1/0;if(L<=0&&S.length===0)return;let k=I;if(k.length>L&&(k=k.substring(0,L)),!k&&S.length===0)return;let O=N.getRangeAt(0),G=O.startOffset===0&&(O.startContainer===_.currentTarget||O.startContainer.parentNode===_.currentTarget);if(!d&&G&&k.length>0&&!ms.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(_.currentTarget.innerText.replace(/\n$/,""))},x=_=>{let I=_.currentTarget,v=I.innerText.replace(/\n$/,"");if(!d&&v.length>0&&!ms.test(v[0])){let N=v.slice(1);if(I.innerText=N,N.length>0&&I.firstChild){let S=document.createRange(),M=window.getSelection();S.setStart(I.firstChild,0),S.collapse(!0),M==null||M.removeAllRanges(),M==null||M.addRange(S)}E(),l==null||l(N);return}l==null||l(v)},T=_=>{h(!1);let I=_.currentTarget.innerText.replace(/\r\n/g,`
|
|
4
4
|
`).replace(/\r/g,`
|
|
5
|
-
`).trim();t&&I.length>t&&(I=I.substring(0,t)),b.currentTarget.innerText=I,a==null||a(),I!==e&&(s==null||s(I))};return Kc("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:Kc("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})})};import{Position as EC}from"@xyflow/react";var pe=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,Go=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),Wr=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),Lh=(e,t,o)=>{let n=o.x-t.x,r=o.y-t.y,i=n*n+r*r;if(i===0)return Go(e,t);let s=Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*r)/i));return Go(e,{x:t.x+s*n,y:t.y+s*r})},qc=(e,t)=>{let o=1/0;for(let n=0;n<t.length-1;n++)o=Math.min(o,Lh(e,t[n],t[n+1]));return o};import{Position as Xr}from"@xyflow/react";var Wt={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15,MAX_LABEL_DISTANCE:80};var{TOLERANCE:ce}=Wt;function kh(e,t,o){return pe(e,t,"x",ce)&&pe(t,o,"x",ce)&&pe(e,o,"x",ce)}function Rh(e,t,o){return pe(e,t,"y",ce)&&pe(t,o,"y",ce)&&pe(e,o,"y",ce)}function Dh(e,t,o){if(!kh(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 Oh(e,t,o){if(!Rh(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 Vh(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 Zc(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];pe(n,r,"x",ce)&&pe(r,i,"x",ce)||pe(n,r,"y",ce)&&pe(r,i,"y",ce)||t.push(r)}return t.push(e[e.length-1]),t}function Ur(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 Hh(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(Dh(r,i,s)||Oh(r,i,s)){t.splice(n,1),o=!0;break}}}return t}function Jc(e){let t=Ur(Zc([...e]));return t=Hh(t),Ur(Zc(t))}function $r(e){switch(e){case Xr.Left:return{x:-1,y:0};case Xr.Right:return{x:1,y:0};case Xr.Top:return{x:0,y:-1};case Xr.Bottom:return{x:0,y:1};default:return{x:0,y:0}}}function Qc(e,t,o,n){let r=Wt.OFFSET,i=Wt.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*Wt.OFFSET&&(r=s/2,i=s/2)}else{let s=(o.y-e.y)*t.y;s>0&&s<2*Wt.OFFSET&&(r=s/2,i=s/2)}return{sourceOffset:r,targetOffset:i}}function Gh(e,t,o,n,r,i,s=0){let a=$r(r),l=$r(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}=Qc(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=Vh(h,a,m,l),v=[f,h,...y,m,x],b=Jc(v);if(b.length===2&&Kr(f,x)>ce){let I=pe(f,h,"x",ce)&&pe(h,m,"x",ce)&&pe(m,x,"x",ce),T=pe(f,h,"y",ce)&&pe(h,m,"y",ce)&&pe(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 Ur([f,h,m,x])}}return b}function qr(e,t,o,n,r,i,s,a=0){if(!(s!=null&&s.length))return Gh(e,t,o,n,r,i,a);let l=$r(r),c=$r(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}=Qc(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=Jc(M);if(L.length===2&&Kr(x,E)>ce){let k=pe(x,m,"x",ce)&&pe(m,y,"x",ce)&&pe(y,E,"x",ce),O=pe(x,m,"y",ce)&&pe(m,y,"y",ce)&&pe(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 Ur([x,m,y,E])}}return L}var Kr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Bh(e,t,o){return pe(e,t,"x",ce)&&pe(t,o,"x",ce)||pe(e,t,"y",ce)&&pe(t,o,"y",ce)}function zh(e,t,o,n){if(Bh(e,t,o))return`L${t.x} ${t.y}`;let r=Kr(e,t),i=Kr(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 jc=(e,t=5)=>e.length<2?"":e.reduce((o,n,r)=>{let i="";return r>0&&r<e.length-1?i=zh(e[r-1],n,e[r+1],t):i=`${r===0?"M":"L"}${n.x} ${n.y}`,o+=i,o},"");import{useCallback as Bo,useEffect as Zr,useRef as In,useState as zo}from"react";import{useReactFlow as Yh,useStore as Fh}from"@xyflow/react";var Wh=50,ed=.1,Xh=.6,Jr=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:s,getNodes:a,getEdge:l,screenToFlowPosition:c}=Yh(),{setIsDragging:d,setReconnectingEdgeId:u}=J(),p=Fh(P=>P.isValidConnection),[f,x]=zo(null),[E,g]=zo(null),[h,m]=zo(null),[y,v]=zo(null),[b,I]=zo(null),[T,N]=zo(!1),C=In(null),M=In(null),L=In(null),k=In(t),O=In(o);Zr(()=>{k.current=t,O.current=o},[t,o]),Zr(()=>{C.current=f},[f]),Zr(()=>{M.current=b},[b]);let V=Bo(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=Bo(P=>{var D,H,z,X,Z,W;let R=a(),S=null,B=Wh,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 ue=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)),Ee=Math.sqrt(ue*ue+ae*ae);Ee<B&&(B=Ee,S=U.id)}return S},[a,V,e]),j=Bo((P,R)=>{var ue,ae,Ee,_e,He,q;let S=s(P);if(!S)return null;let B=V(P),Y=(Ee=(ae=(ue=S.measured)==null?void 0:ue.width)!=null?ae:S.width)!=null?Ee:0,D=(q=(He=(_e=S.measured)==null?void 0:_e.height)!=null?He: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((ie,[oe,le])=>le<ie[1]?[oe,le]:ie,["right",W.right])[0],Q=L.current;if(Q&&Q!==U){let ie=W[U],oe=W[Q],le=Math.abs(oe-ie),xe=Math.min(Math.abs(oe),Math.abs(ie));le<xe*Xh&&(U=Q)}let ee=U,te,me;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)<ed&&(oe=.5),me=oe,te={x:ee==="right"?B.x+Y:B.x,y:B.y+me*D}}else{let oe=(Math.max(B.x,Math.min(B.x+Y,R.x))-B.x)/(Y||1);Math.abs(oe-.5)<ed&&(oe=.5),me=oe,te={x:B.x+me*Y,y:ee==="bottom"?B.y+D:B.y}}return{side:ee,snapPosition:te,offset:me}},[s,V]),$=Bo(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=Bo(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(me=>me.map(ue=>{var ae,Ee;return ue.id===e?w(_({},ue),{source:te.source,target:te.target,sourceHandle:te.sourceHandle,targetHandle:te.targetHandle,data:w(_({},ue.data),{points:void 0,sourceOffset:R==="source"?Q:(ae=ue.data)==null?void 0:ae.sourceOffset,targetOffset:R==="target"?Q:(Ee=ue.data)==null?void 0:Ee.targetOffset})}):ue}))}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=_t.get(n);Y==null||Y.clearReconnectingEdge()},[e,F,j,l,i,n,$,p,c,d,u]),A=Bo((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=_t.get(n);S==null||S.setReconnectingEdge(e),document.addEventListener("mousemove",$),document.addEventListener("mouseup",K)},[r,e,n,$,K,u,i]);return Zr(()=>()=>{if(C.current){document.removeEventListener("mousemove",$),document.removeEventListener("mouseup",K),u(null);let P=_t.get(n);P==null||P.clearReconnectingEdge()}},[n,$,K,u]),{reconnectingHandle:f,cursorPosition:E,hoveredNodeId:h,reconnectingSide:y,reconnectingOffset:b,isValidReconnection:T,handleReconnectStart:A}};import{Fragment as sd,jsx as ke,jsxs as Xt}from"react/jsx-runtime";var at={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:od.ArrowClosed},markerEnd:{type:od.Arrow},data:{label:""}},{MOVE_THRESHOLD:ei,MIN_SEGMENT_LENGTH:Qh,PARALLEL_OFFSET:id,MAX_LABEL_DISTANCE:jh}=Wt;function ey(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)*id}let s=i.findIndex(l=>l.id===e),a=(i.length-1)/2;return(s-a)*id}var hs=Uh.memo(({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:s,sourceHandleId:a,targetHandleId:l})=>{var U,Q,ee,te,me,ue,ae,Ee,_e,He;let{zoom:c}=Jh(),{updateEdgeData:d}=Zh(),{isReadOnly:u,mode:p,instanceId:f,edgeHighlight:x}=J(),E=xt(),g=rd(Qr(q=>q.edges,[])),h=rd(Qr(q=>{var ie,oe;return((ie=q.nodeLookup.get(t))==null?void 0:ie.type)==="GATEWAY"||((oe=q.nodeLookup.get(o))==null?void 0:oe.type)==="GATEWAY"},[t,o])),m=jr(()=>ey(e,t,o,g,h),[e,t,o,g,h]),[y,v]=td(!1),[b,I]=td(null),T=gs(null),N=gs(n==null?void 0:n.labelOffset),C=gs(null),M=p!=="edit",{reconnectingHandle:L,cursorPosition:k,hoveredNodeId:O,reconnectingSide:V,isValidReconnection:F,handleReconnectStart:j}=Jr({edgeId:e,source:t,target:o,instanceId:f,isReadOnly:M}),$=nd(t),K=nd(o),{sx:A,sy:P,tx:R,ty:S,sourcePos:B,targetPos:Y}=jr(()=>{var ft,fe;let q=$&&K?Co($,K):{sx:0,sy:0,tx:0,ty:0,sourcePos:Yo.Right,targetPos:Yo.Left},ie=a?i:q.sourcePos,oe=l?s:q.targetPos,le=(ge,he,Ne)=>{var Ot,wt,It,ra,ia,sa;let{x:be,y:Me}=ge.internals.positionAbsolute,Ae=(It=(wt=(Ot=ge.measured)==null?void 0:Ot.width)!=null?wt:ge.width)!=null?It:0,We=(sa=(ia=(ra=ge.measured)==null?void 0:ra.height)!=null?ia:ge.height)!=null?sa:0;switch(he){case Yo.Top:return{x:be+Ae*Ne,y:Me};case Yo.Bottom:return{x:be+Ae*Ne,y:Me+We};case Yo.Left:return{x:be,y:Me+We*Ne};case Yo.Right:return{x:be+Ae,y:Me+We*Ne};default:return{x:be+Ae/2,y:Me+We/2}}},xe=(ft=n==null?void 0:n.sourceOffset)!=null?ft:.5,Se=(fe=n==null?void 0:n.targetOffset)!=null?fe:.5,Ie=$?le($,ie,xe).x:q.sx,Fe=$?le($,ie,xe).y:q.sy,vt=K?le(K,oe,Se).x:q.tx,Nt=K?le(K,oe,Se).y:q.ty;return L==="source"&&k?(Ie=k.x,Fe=k.y,V&&(ie=V)):L==="target"&&k&&(vt=k.x,Nt=k.y,V&&(oe=V)),{sx:Ie,sy:Fe,tx:vt,ty:Nt,sourcePos:ie,targetPos:oe}},[$,K,a,l,i,s,L,k,V,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);$h(()=>{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)>ei||Math.abs(P-q.sy)>ei||Math.abs(R-q.tx)>ei||Math.abs(S-q.ty)>ei||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=jr(()=>qr(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=jr(()=>{if(D.length<2)return Wr({x:A,y:P},{x:R,y:S});let q=0;for(let le=0;le<D.length-1;le++)q+=Go(D[le],D[le+1]);let ie=q/2,oe=0;for(let le=0;le<D.length-1;le++){let xe=Go(D[le],D[le+1]);if(oe+xe>=ie){let Se=(ie-oe)/xe,Ie=D[le],Fe=D[le+1];return{x:Ie.x+(Fe.x-Ie.x)*Se,y:Ie.y+(Fe.y-Ie.y)*Se}}oe+=xe}return Wr({x:A,y:P},{x:R,y:S})},[D,A,P,R,S]),z=Qr((q,ie)=>{if(p!=="edit"||ie.button!==0)return;ie.stopPropagation(),ie.preventDefault();let oe=D[q],le=D[q+1],xe=pe(oe,le,"y"),Se=xe?oe.y:oe.x,Ie=[...D],Fe=Ie.length,vt=q,Nt=q+1;I(q);let ft=ge=>{let he=Se+(xe?ge.clientY-ie.clientY:ge.clientX-ie.clientX)/c;T.current=xe?{x:(oe.x+le.x)/2,y:he}:{x:he,y:(oe.y+le.y)/2};let Ne=[];for(let be=1;be<Fe-1;be++){let Me=Ie[be];be===vt||be===Nt?xe?Ne.push({x:Me.x,y:he}):Ne.push({x:he,y:Me.y}):Ne.push(_({},Me))}d(e,w(_({},n),{points:Ne}))},fe=()=>{I(null),T.current=null,document.removeEventListener("mousemove",ft),document.removeEventListener("mouseup",fe)};document.addEventListener("mousemove",ft),document.addEventListener("mouseup",fe)},[p,D,c,n,e,d]),X=Qr(q=>{var ft,fe,ge,he,Ne;if(y||M||q.button!==0||!((ft=n==null?void 0:n.label)!=null&&ft.trim()))return;q.stopPropagation(),q.preventDefault();let ie=q.clientX,oe=q.clientY,le=(ge=(fe=n==null?void 0:n.labelOffset)==null?void 0:fe.x)!=null?ge:0,xe=(Ne=(he=n==null?void 0:n.labelOffset)==null?void 0:he.y)!=null?Ne:0,Se=[...D],Ie={x:H.x,y:H.y},Fe=!1,vt=be=>{let Me=(be.clientX-ie)/c,Ae=(be.clientY-oe)/c;if(!Fe&&Math.abs(Me)<3&&Math.abs(Ae)<3)return;Fe=!0;let We={x:le+Me,y:xe+Ae};N.current=We,d(e,w(_({},n),{labelOffset:We}))},Nt=()=>{document.removeEventListener("mousemove",vt),document.removeEventListener("mouseup",Nt);let be=N.current;if(!be)return;let Me={x:Ie.x+be.x,y:Ie.y+be.y};qc(Me,Se)>jh&&(N.current=void 0,d(e,w(_({},n),{labelOffset:void 0})))};document.addEventListener("mousemove",vt),document.addEventListener("mouseup",Nt)},[y,M,c,n,e,d,D,H]);if(!$||!K)return null;let Z=jc(D),W=x&&(r||$.selected||K.selected);return Xt(sd,{children:[Xt("g",{className:G("group bpmn-arrow-edge",{"is-highlighted":W}),onDoubleClick:()=>!M&&v(!0),children:[ke("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}),Xt("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:[ke(Kh,{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&&ke("g",{children:D.slice(0,-1).map((q,ie)=>{let oe=D[ie+1];if(ie===0||ie===D.length-2||Go(q,oe)<Qh)return null;let le=pe(q,oe,"y"),xe=b===ie,Se=xe&&T.current?T.current:Wr(q,oe);return Xt("g",{children:[ke("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:Ie=>z(ie,Ie)}),ke("circle",{cx:Se.x,cy:Se.y,r:4/c,fill:xe?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),ke("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"})]},ie)})})]})]}),Xt(qh,{children:[ke("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&&ke(Oo,{sx:A,sy:P,tx:R,ty:S,hasLabel:!!((ee=n==null?void 0:n.label)!=null&&ee.trim()),children:ke(Do,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:$,targetNode:K})})}),(y||((te=n==null?void 0:n.label)==null?void 0:te.trim()))&&ke("div",{className:G("absolute nodrag nopan",!y&&!M&&((me=n==null?void 0:n.label)!=null&&me.trim())?"z-[10001] pointer-events-auto":"z-[3000] pointer-events-none"),style:{transform:`translate(-50%, -50%) translate(${H.x+((ae=(ue=n==null?void 0:n.labelOffset)==null?void 0:ue.x)!=null?ae:0)}px, ${H.y+((_e=(Ee=n==null?void 0:n.labelOffset)==null?void 0:Ee.y)!=null?_e:0)}px)`,cursor:!y&&!M&&((He=n==null?void 0:n.label)!=null&&He.trim())?"move":void 0},onMouseDown:!y&&!M?X:void 0,onDoubleClick:q=>{M||(q.stopPropagation(),v(!0))},children:ke(Ge,{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&&Xt(sd,{children:[ke("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${D[0].x}px, ${D[0].y}px)`},children:Xt("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[ke("circle",{cx:6/c,cy:6/c,r:4/c,fill:L==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),ke("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"}),ke("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)})]})}),ke("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:Xt("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[ke("circle",{cx:6/c,cy:6/c,r:4/c,fill:L==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),ke("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"}),ke("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)})]})})]})]})]})});hs.displayName="SequenceEdge";import{Position as Pt}from"@xyflow/react";var ty={right:Pt.Right,left:Pt.Left,top:Pt.Top,bottom:Pt.Bottom},ti=e=>{var t;return(t=ty[e!=null?e:""])!=null?t:Pt.Right},ys=(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(ti(t)){case Pt.Right:return{x:n+i,y:r+s*o};case Pt.Left:return{x:n,y:r+s*o};case Pt.Top:return{x:n+i*o,y:r};case Pt.Bottom:return{x:n+i*o,y:r+s};default:return{x:n+i/2,y:r+s/2}}},ad=(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};import{useCallback as Tu,useEffect as Z0}from"react";import{useDebouncedCallback as J0}from"use-debounce";import{useReactFlow as q0}from"@xyflow/react";import{useCallback as bu}from"react";var An=(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))(An||{});var Cn=1,ld=e=>`<mxGraphModel>
|
|
5
|
+
`).trim();t&&I.length>t&&(I=I.substring(0,t)),_.currentTarget.innerText=I,a==null||a(),I!==e&&(s==null||s(I))};return Kc("div",{className:H("flex-1 p-2 self-stretch flex items-center justify-center border border-transparent overflow-hidden text-ellipsis body-medium-400 text-center rounded-sm",{"border border-dashed border-grey-400 bg-white shadow-md":f,"bg-white":e.length>0},n),style:o,onDoubleClick:m,children:Kc("div",{ref:u,className:H("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":f}),contentEditable:f,suppressContentEditableWarning:!0,onKeyDown:y,onPaste:g,onInput:x,onBlur:T,children:e})})};import{Position as _C}from"@xyflow/react";var pe=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,Go=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),Wr=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),kh=(e,t,o)=>{let n=o.x-t.x,r=o.y-t.y,i=n*n+r*r;if(i===0)return Go(e,t);let s=Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*r)/i));return Go(e,{x:t.x+s*n,y:t.y+s*r})},qc=(e,t)=>{let o=1/0;for(let n=0;n<t.length-1;n++)o=Math.min(o,kh(e,t[n],t[n+1]));return o};import{Position as Xr}from"@xyflow/react";var Wt={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15,MAX_LABEL_DISTANCE:80};var{TOLERANCE:ce}=Wt;function Rh(e,t,o){return pe(e,t,"x",ce)&&pe(t,o,"x",ce)&&pe(e,o,"x",ce)}function Dh(e,t,o){return pe(e,t,"y",ce)&&pe(t,o,"y",ce)&&pe(e,o,"y",ce)}function Oh(e,t,o){if(!Rh(e,t,o))return!1;let n=t.y-e.y,r=o.y-t.y;return Math.abs(n)<ce||Math.abs(r)<ce?!1:n*r<0}function Vh(e,t,o){if(!Dh(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 Hh(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 Zc(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];pe(n,r,"x",ce)&&pe(r,i,"x",ce)||pe(n,r,"y",ce)&&pe(r,i,"y",ce)||t.push(r)}return t.push(e[e.length-1]),t}function Ur(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 Gh(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(Oh(r,i,s)||Vh(r,i,s)){t.splice(n,1),o=!0;break}}}return t}function Jc(e){let t=Ur(Zc([...e]));return t=Gh(t),Ur(Zc(t))}function $r(e){switch(e){case Xr.Left:return{x:-1,y:0};case Xr.Right:return{x:1,y:0};case Xr.Top:return{x:0,y:-1};case Xr.Bottom:return{x:0,y:1};default:return{x:0,y:0}}}function Qc(e,t,o,n){let r=Wt.OFFSET,i=Wt.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*Wt.OFFSET&&(r=s/2,i=s/2)}else{let s=(o.y-e.y)*t.y;s>0&&s<2*Wt.OFFSET&&(r=s/2,i=s/2)}return{sourceOffset:r,targetOffset:i}}function Bh(e,t,o,n,r,i,s=0){let a=$r(r),l=$r(i),c=a.x===0?s:0,d=a.y===0?s:0,u=l.x===0?s:0,p=l.y===0?s:0,f={x:e+c,y:t+d},h={x:o+u,y:n+p},{sourceOffset:E,targetOffset:m}=Qc(f,a,h,l),y={x:f.x+a.x*E,y:f.y+a.y*E},g={x:h.x+l.x*m,y:h.y+l.y*m},x=Hh(y,a,g,l),T=[f,y,...x,g,h],_=Jc(T);if(_.length===2&&Kr(f,h)>ce){let I=pe(f,y,"x",ce)&&pe(y,g,"x",ce)&&pe(g,h,"x",ce),v=pe(f,y,"y",ce)&&pe(y,g,"y",ce)&&pe(g,h,"y",ce);if(I||v){let N=v&&(g.x-y.x)*a.x<0,S=I&&(g.y-y.y)*a.y<0;if(!N&&!S)return Ur([f,y,g,h])}}return _}function qr(e,t,o,n,r,i,s,a=0){if(!(s!=null&&s.length))return Bh(e,t,o,n,r,i,a);let l=$r(r),c=$r(i),d=l.x===0?a:0,u=l.y===0?a:0,p=c.x===0?a:0,f=c.y===0?a:0,h={x:e+d,y:t+u},E={x:o+p,y:n+f},{sourceOffset:m,targetOffset:y}=Qc(h,l,E,c),g={x:h.x+l.x*m,y:h.y+l.y*m},x={x:E.x+c.x*y,y:E.y+c.y*y},T=[...s],_=T[0],I=l.y===0;I&&Math.abs(h.y-_.y)>ce?T.unshift({x:_.x,y:h.y}):!I&&Math.abs(h.x-_.x)>ce&&T.unshift({x:h.x,y:_.y});let v=T[T.length-1],N=c.y===0,S=[];(Math.abs(v.x-x.x)>ce||Math.abs(v.y-x.y)>ce)&&(N?S.push({x:x.x,y:v.y}):S.push({x:v.x,y:x.y})),S.push(x);let M=[h,...T,...S,E],L=Jc(M);if(L.length===2&&Kr(h,E)>ce){let k=pe(h,g,"x",ce)&&pe(g,x,"x",ce)&&pe(x,E,"x",ce),O=pe(h,g,"y",ce)&&pe(g,x,"y",ce)&&pe(x,E,"y",ce);if(k||O){let G=O&&(x.x-g.x)*l.x<0,F=k&&(x.y-g.y)*l.y<0;if(!G&&!F)return Ur([h,g,x,E])}}return L}var Kr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function zh(e,t,o){return pe(e,t,"x",ce)&&pe(t,o,"x",ce)||pe(e,t,"y",ce)&&pe(t,o,"y",ce)}function Yh(e,t,o,n){if(zh(e,t,o))return`L${t.x} ${t.y}`;let r=Kr(e,t),i=Kr(t,o),s=Math.min(r/2,i/2,n);if(s<1)return`L${t.x} ${t.y}`;let a=e.x-t.x,l=e.y-t.y,c=o.x-t.x,d=o.y-t.y,u={x:a/r,y:l/r},p={x:c/i,y:d/i},f={x:t.x+u.x*s,y:t.y+u.y*s},h={x:t.x+p.x*s,y:t.y+p.y*s},E=-u.x,m=-u.y,y=p.x,g=p.y,T=E*g-m*y>0?1:0;return`L${f.x} ${f.y}A${s} ${s} 0 0 ${T} ${h.x} ${h.y}`}var jc=(e,t=5)=>e.length<2?"":e.reduce((o,n,r)=>{let i="";return r>0&&r<e.length-1?i=Yh(e[r-1],n,e[r+1],t):i=`${r===0?"M":"L"}${n.x} ${n.y}`,o+=i,o},"");import{useCallback as Bo,useEffect as Zr,useRef as In,useState as zo}from"react";import{useReactFlow as Fh,useStore as Wh}from"@xyflow/react";var Xh=50,ed=.1,Uh=.6,Jr=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:s,getNodes:a,getEdge:l,screenToFlowPosition:c}=Fh(),{setIsDragging:d,setReconnectingEdgeId:u}=J(),p=Wh(P=>P.isValidConnection),[f,h]=zo(null),[E,m]=zo(null),[y,g]=zo(null),[x,T]=zo(null),[_,I]=zo(null),[v,N]=zo(!1),S=In(null),M=In(null),L=In(null),k=In(t),O=In(o);Zr(()=>{k.current=t,O.current=o},[t,o]),Zr(()=>{S.current=f},[f]),Zr(()=>{M.current=_},[_]);let G=Bo(P=>{let R=a(),C=R.find(V=>V.id===P);if(!C)return{x:0,y:0};let B=C.position.x,Y=C.position.y,D=C.parentId;for(;D;){let V=R.find(z=>z.id===D);if(!V)break;B+=V.position.x,Y+=V.position.y,D=V.parentId}return{x:B,y:Y}},[a]),F=Bo(P=>{var D,V,z,X,Z,W;let R=a(),C=null,B=Xh,Y=R.filter(U=>U.type!=="LANE"&&U.type!=="ANNOTATION");for(let U of Y){if(U.id===e)continue;let j=G(U.id),ee=(z=(V=(D=U.measured)==null?void 0:D.width)!=null?V: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>=j.x&&P.x<=j.x+ee&&P.y>=j.y&&P.y<=j.y+te)return U.id;let ue=Math.max(j.x-P.x,0,P.x-(j.x+ee)),ae=Math.max(j.y-P.y,0,P.y-(j.y+te)),Ee=Math.sqrt(ue*ue+ae*ae);Ee<B&&(B=Ee,C=U.id)}return C},[a,G,e]),Q=Bo((P,R)=>{var ue,ae,Ee,_e,He,q;let C=s(P);if(!C)return null;let B=G(P),Y=(Ee=(ae=(ue=C.measured)==null?void 0:ue.width)!=null?ae:C.width)!=null?Ee:0,D=(q=(He=(_e=C.measured)==null?void 0:_e.height)!=null?He:C.height)!=null?q:0,V=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:V,left:z,bottom:X,top:Z},U=Object.entries(W).reduce((ie,[oe,le])=>le<ie[1]?[oe,le]:ie,["right",W.right])[0],j=L.current;if(j&&j!==U){let ie=W[U],oe=W[j],le=Math.abs(oe-ie),xe=Math.min(Math.abs(oe),Math.abs(ie));le<xe*Uh&&(U=j)}let ee=U,te,me;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)<ed&&(oe=.5),me=oe,te={x:ee==="right"?B.x+Y:B.x,y:B.y+me*D}}else{let oe=(Math.max(B.x,Math.min(B.x+Y,R.x))-B.x)/(Y||1);Math.abs(oe-.5)<ed&&(oe=.5),me=oe,te={x:B.x+me*Y,y:ee==="bottom"?B.y+D:B.y}}return{side:ee,snapPosition:te,offset:me}},[s,G]),$=Bo(P=>{var z,X,Z;let R=S.current;if(!R)return;let C=c({x:P.clientX,y:P.clientY}),B=F(C);g(B);let Y=C,D=null,V=null;if(B){let W=Q(B,C);W&&(D=W.side,Y=W.snapPosition,V=W.offset,L.current=D);let U=l(e),j={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(j))!=null?Z:!0;N(ee)}else L.current=null,N(!1);T(D),I(V),m(Y)},[F,Q,l,e,c,p]),K=Bo(P=>{var D,V,z,X,Z;let R=S.current;if(!R)return;let C=c({x:P.clientX,y:P.clientY}),B=F(C);if(B){let W=Q(B,C),U=(D=W==null?void 0:W.side)!=null?D:null,j=(V=W==null?void 0:W.offset)!=null?V:.5,ee=l(e),te={source:R==="source"?B:k.current,target:R==="target"?B:O.current,sourceHandle:R==="source"?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(me=>me.map(ue=>{var ae,Ee;return ue.id===e?w(b({},ue),{source:te.source,target:te.target,sourceHandle:te.sourceHandle,targetHandle:te.targetHandle,data:w(b({},ue.data),{points:void 0,sourceOffset:R==="source"?j:(ae=ue.data)==null?void 0:ae.sourceOffset,targetOffset:R==="target"?j:(Ee=ue.data)==null?void 0:Ee.targetOffset})}):ue}))}h(null),m(null),g(null),T(null),I(null),d(!1),N(!1),u(null),L.current=null,document.removeEventListener("mouseup",K),document.removeEventListener("mousemove",$);let Y=_t.get(n);Y==null||Y.clearReconnectingEdge()},[e,F,Q,l,i,n,$,p,c,d,u]),A=Bo((P,R)=>{if(r||R.button!==0)return;R.stopPropagation(),R.preventDefault(),i(B=>B.map(Y=>Y.id===e?w(b({},Y),{data:w(b({},Y.data),{points:void 0})}):Y)),h(P),u(e);let C=_t.get(n);C==null||C.setReconnectingEdge(e),document.addEventListener("mousemove",$),document.addEventListener("mouseup",K)},[r,e,n,$,K,u,i]);return Zr(()=>()=>{if(S.current){document.removeEventListener("mousemove",$),document.removeEventListener("mouseup",K),u(null);let P=_t.get(n);P==null||P.clearReconnectingEdge()}},[n,$,K,u]),{reconnectingHandle:f,cursorPosition:E,hoveredNodeId:y,reconnectingSide:x,reconnectingOffset:_,isValidReconnection:v,handleReconnectStart:A}};import{Fragment as sd,jsx as ke,jsxs as Xt}from"react/jsx-runtime";var at={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:od.ArrowClosed},markerEnd:{type:od.Arrow},data:{label:""}},{MOVE_THRESHOLD:ei,MIN_SEGMENT_LENGTH:jh,PARALLEL_OFFSET:id,MAX_LABEL_DISTANCE:ey}=Wt;function ty(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)*id}let s=i.findIndex(l=>l.id===e),a=(i.length-1)/2;return(s-a)*id}var hs=$h.memo(({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:s,sourceHandleId:a,targetHandleId:l})=>{var U,j,ee,te,me,ue,ae,Ee,_e,He;let{zoom:c}=Qh(),{updateEdgeData:d}=Jh(),{isReadOnly:u,mode:p,instanceId:f,edgeHighlight:h}=J(),E=xt(),m=rd(Qr(q=>q.edges,[])),y=rd(Qr(q=>{var ie,oe;return((ie=q.nodeLookup.get(t))==null?void 0:ie.type)==="GATEWAY"||((oe=q.nodeLookup.get(o))==null?void 0:oe.type)==="GATEWAY"},[t,o])),g=jr(()=>ty(e,t,o,m,y),[e,t,o,m,y]),[x,T]=td(!1),[_,I]=td(null),v=gs(null),N=gs(n==null?void 0:n.labelOffset),S=gs(null),M=p!=="edit",{reconnectingHandle:L,cursorPosition:k,hoveredNodeId:O,reconnectingSide:G,isValidReconnection:F,handleReconnectStart:Q}=Jr({edgeId:e,source:t,target:o,instanceId:f,isReadOnly:M}),$=nd(t),K=nd(o),{sx:A,sy:P,tx:R,ty:C,sourcePos:B,targetPos:Y}=jr(()=>{var ft,fe;let q=$&&K?Co($,K):{sx:0,sy:0,tx:0,ty:0,sourcePos:Yo.Right,targetPos:Yo.Left},ie=a?i:q.sourcePos,oe=l?s:q.targetPos,le=(ge,he,Ne)=>{var Ot,wt,It,ra,ia,sa;let{x:be,y:Me}=ge.internals.positionAbsolute,Ae=(It=(wt=(Ot=ge.measured)==null?void 0:Ot.width)!=null?wt:ge.width)!=null?It:0,We=(sa=(ia=(ra=ge.measured)==null?void 0:ra.height)!=null?ia:ge.height)!=null?sa:0;switch(he){case Yo.Top:return{x:be+Ae*Ne,y:Me};case Yo.Bottom:return{x:be+Ae*Ne,y:Me+We};case Yo.Left:return{x:be,y:Me+We*Ne};case Yo.Right:return{x:be+Ae,y:Me+We*Ne};default:return{x:be+Ae/2,y:Me+We/2}}},xe=(ft=n==null?void 0:n.sourceOffset)!=null?ft:.5,Se=(fe=n==null?void 0:n.targetOffset)!=null?fe:.5,Ie=$?le($,ie,xe).x:q.sx,Fe=$?le($,ie,xe).y:q.sy,vt=K?le(K,oe,Se).x:q.tx,Nt=K?le(K,oe,Se).y:q.ty;return L==="source"&&k?(Ie=k.x,Fe=k.y,G&&(ie=G)):L==="target"&&k&&(vt=k.x,Nt=k.y,G&&(oe=G)),{sx:Ie,sy:Fe,tx:vt,ty:Nt,sourcePos:ie,targetPos:oe}},[$,K,a,l,i,s,L,k,G,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);Kh(()=>{var oe;if(!S.current){S.current={sx:A,sy:P,tx:R,ty:C,sourcePos:B,targetPos:Y};return}let q=S.current;if(Math.abs(A-q.sx)>ei||Math.abs(P-q.sy)>ei||Math.abs(R-q.tx)>ei||Math.abs(C-q.ty)>ei||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,b(b({},n),le))}S.current={sx:A,sy:P,tx:R,ty:C,sourcePos:B,targetPos:Y}},[A,P,R,C,B,Y,n,e,d,L]);let D=jr(()=>qr(A,P,R,C,B,Y,n==null?void 0:n.points,g),[A,P,R,C,B,Y,n==null?void 0:n.points,g]),V=jr(()=>{if(D.length<2)return Wr({x:A,y:P},{x:R,y:C});let q=0;for(let le=0;le<D.length-1;le++)q+=Go(D[le],D[le+1]);let ie=q/2,oe=0;for(let le=0;le<D.length-1;le++){let xe=Go(D[le],D[le+1]);if(oe+xe>=ie){let Se=(ie-oe)/xe,Ie=D[le],Fe=D[le+1];return{x:Ie.x+(Fe.x-Ie.x)*Se,y:Ie.y+(Fe.y-Ie.y)*Se}}oe+=xe}return Wr({x:A,y:P},{x:R,y:C})},[D,A,P,R,C]),z=Qr((q,ie)=>{if(p!=="edit"||ie.button!==0)return;ie.stopPropagation(),ie.preventDefault();let oe=D[q],le=D[q+1],xe=pe(oe,le,"y"),Se=xe?oe.y:oe.x,Ie=[...D],Fe=Ie.length,vt=q,Nt=q+1;I(q);let ft=ge=>{let he=Se+(xe?ge.clientY-ie.clientY:ge.clientX-ie.clientX)/c;v.current=xe?{x:(oe.x+le.x)/2,y:he}:{x:he,y:(oe.y+le.y)/2};let Ne=[];for(let be=1;be<Fe-1;be++){let Me=Ie[be];be===vt||be===Nt?xe?Ne.push({x:Me.x,y:he}):Ne.push({x:he,y:Me.y}):Ne.push(b({},Me))}d(e,w(b({},n),{points:Ne}))},fe=()=>{I(null),v.current=null,document.removeEventListener("mousemove",ft),document.removeEventListener("mouseup",fe)};document.addEventListener("mousemove",ft),document.addEventListener("mouseup",fe)},[p,D,c,n,e,d]),X=Qr(q=>{var ft,fe,ge,he,Ne;if(x||M||q.button!==0||!((ft=n==null?void 0:n.label)!=null&&ft.trim()))return;q.stopPropagation(),q.preventDefault();let ie=q.clientX,oe=q.clientY,le=(ge=(fe=n==null?void 0:n.labelOffset)==null?void 0:fe.x)!=null?ge:0,xe=(Ne=(he=n==null?void 0:n.labelOffset)==null?void 0:he.y)!=null?Ne:0,Se=[...D],Ie={x:V.x,y:V.y},Fe=!1,vt=be=>{let Me=(be.clientX-ie)/c,Ae=(be.clientY-oe)/c;if(!Fe&&Math.abs(Me)<3&&Math.abs(Ae)<3)return;Fe=!0;let We={x:le+Me,y:xe+Ae};N.current=We,d(e,w(b({},n),{labelOffset:We}))},Nt=()=>{document.removeEventListener("mousemove",vt),document.removeEventListener("mouseup",Nt);let be=N.current;if(!be)return;let Me={x:Ie.x+be.x,y:Ie.y+be.y};qc(Me,Se)>ey&&(N.current=void 0,d(e,w(b({},n),{labelOffset:void 0})))};document.addEventListener("mousemove",vt),document.addEventListener("mouseup",Nt)},[x,M,c,n,e,d,D,V]);if(!$||!K)return null;let Z=jc(D),W=h&&(r||$.selected||K.selected);return Xt(sd,{children:[Xt("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":W}),onDoubleClick:()=>!M&&T(!0),children:[ke("path",{d:Z,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),className:H({"nopan nodrag":!x&&!M&&!!((U=n==null?void 0:n.label)!=null&&U.trim())}),style:{pointerEvents:"stroke",cursor:!x&&!M&&((j=n==null?void 0:n.label)!=null&&j.trim())?"move":"pointer"},onMouseDown:X}),Xt("g",{className:H("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!u,"text-blue-500 group-hover:text-blue-600":W}),children:[ke(qh,{id:e,path:Z,interactionWidth:0,markerEnd:`url(#${W?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:H("stroke-2 stroke-current transition-[stroke] duration-75",{"group-hover:stroke-[2.5px]":!u,"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||L&&O&&!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&&ke("g",{children:D.slice(0,-1).map((q,ie)=>{let oe=D[ie+1];if(ie===0||ie===D.length-2||Go(q,oe)<jh)return null;let le=pe(q,oe,"y"),xe=_===ie,Se=xe&&v.current?v.current:Wr(q,oe);return Xt("g",{children:[ke("line",{x1:q.x,y1:q.y,x2:oe.x,y2:oe.y,stroke:"transparent",strokeWidth:20/c,className:H("cursor-pointer",{"cursor-ns-resize":le,"cursor-ew-resize":!le}),onMouseDown:Ie=>z(ie,Ie)}),ke("circle",{cx:Se.x,cy:Se.y,r:4/c,fill:xe?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),ke("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"})]},ie)})})]})]}),Xt(Zh,{children:[ke("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${V.x}px, ${V.y}px)`},children:r&&!E&&ke(Oo,{sx:A,sy:P,tx:R,ty:C,hasLabel:!!((ee=n==null?void 0:n.label)!=null&&ee.trim()),children:ke(Do,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:$,targetNode:K})})}),(x||((te=n==null?void 0:n.label)==null?void 0:te.trim()))&&ke("div",{className:H("absolute nodrag nopan",!x&&!M&&((me=n==null?void 0:n.label)!=null&&me.trim())?"z-[10001] pointer-events-auto":"z-[3000] pointer-events-none"),style:{transform:`translate(-50%, -50%) translate(${V.x+((ae=(ue=n==null?void 0:n.labelOffset)==null?void 0:ue.x)!=null?ae:0)}px, ${V.y+((_e=(Ee=n==null?void 0:n.labelOffset)==null?void 0:Ee.y)!=null?_e:0)}px)`,cursor:!x&&!M&&((He=n==null?void 0:n.label)!=null&&He.trim())?"move":void 0},onMouseDown:!x&&!M?X:void 0,onDoubleClick:q=>{M||(q.stopPropagation(),T(!0))},children:ke(Ge,{value:n==null?void 0:n.label,className:H("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":x,"pointer-events-none":!x}),isEditing:x,onBlur:()=>T(!1),onChange:q=>d(e,{label:q.trim()})})}),r&&!E&&!M&&Xt(sd,{children:[ke("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${D[0].x}px, ${D[0].y}px)`},children:Xt("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[ke("circle",{cx:6/c,cy:6/c,r:4/c,fill:L==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),ke("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"}),ke("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!L||L!=="source","cursor-not-allowed":L==="source"&&O&&!F,"cursor-grabbing":L==="source"&&(!O||F)}),onMouseDown:q=>Q("source",q.nativeEvent)})]})}),ke("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:Xt("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[ke("circle",{cx:6/c,cy:6/c,r:4/c,fill:L==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),ke("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"}),ke("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!L||L!=="target","cursor-not-allowed":L==="target"&&O&&!F,"cursor-grabbing":L==="target"&&(!O||F)}),onMouseDown:q=>Q("target",q.nativeEvent)})]})})]})]})]})});hs.displayName="SequenceEdge";import{Position as Pt}from"@xyflow/react";var oy={right:Pt.Right,left:Pt.Left,top:Pt.Top,bottom:Pt.Bottom},ti=e=>{var t;return(t=oy[e!=null?e:""])!=null?t:Pt.Right},ys=(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(ti(t)){case Pt.Right:return{x:n+i,y:r+s*o};case Pt.Left:return{x:n,y:r+s*o};case Pt.Top:return{x:n+i*o,y:r};case Pt.Bottom:return{x:n+i*o,y:r+s};default:return{x:n+i/2,y:r+s/2}}},ad=(e,t,o)=>{var d,u;let{position:{x:n,y:r},measured:i}=e,s=(d=i.width)!=null?d:0,a=(u=i.height)!=null?u:0;return[{id:"left",x:n,y:r+a/2},{id:"right",x:n+s,y:r+a/2},{id:"top",x:n+s/2,y:r},{id:"bottom",x:n+s/2,y:r+a}].reduce((p,f)=>{let h=Math.hypot(t-p.x,o-p.y);return Math.hypot(t-f.x,o-f.y)<h?f:p}).id};import{useCallback as Tu,useEffect as J0}from"react";import{useDebouncedCallback as Q0}from"use-debounce";import{useReactFlow as Z0}from"@xyflow/react";import{useCallback as bu}from"react";var An=(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))(An||{});var Cn=1,ld=e=>`<mxGraphModel>
|
|
6
6
|
<root version="1.1">
|
|
7
7
|
<mxCell id="0" />
|
|
8
8
|
<mxCell id="1" parent="0" />
|
|
@@ -35,17 +35,17 @@ var Wp=Object.defineProperty,Xp=Object.defineProperties;var Up=Object.getOwnProp
|
|
|
35
35
|
<mxGeometry as="geometry" relative="1" />
|
|
36
36
|
</mxCell>
|
|
37
37
|
</root>
|
|
38
|
-
</mxGraphModel>`,cd=(e,t)=>{if(!e.length&&!t.length)return Cn;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};import{xml2json as
|
|
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(Vt(Number(s),t),l),u=Math.max(Vt(Number(a),o),c);return{width:d,height:u,measured:{width:d,height:u}}},Wo=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},sy=e=>{let{mxGeometry:t}=e,o=Wo(e),n=Fo(t,de.START_EVENT.MIN_WIDTH,de.START_EVENT.MIN_HEIGHT);return w(_(_({},o),n),{type:"START_EVENT"})},ay=e=>{let{mxGeometry:t}=e,o=Wo(e),n=Fo(t,de.END_EVENT.MIN_WIDTH,de.END_EVENT.MIN_HEIGHT);return w(_(_({},o),n),{type:"END_EVENT"})},ni=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=Wo(e),a=Fo(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=pd[d];u&&(r.data.attribute=u)}let c=fd[o.style];return c&&(r.data.variant=c),w(_(_({},r),a),{type:"TASK"})},xs=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=Wo(e),i=Fo(o,de.GATEWAY.MIN_WIDTH,de.GATEWAY.MIN_HEIGHT);return r.data.variant=md[n],w(_(_({},r),i),{type:"GATEWAY"})},ly=e=>{let{mxGeometry:t}=e,o=Wo(e),i=Fo(t,de.ANNOTATION.MIN_WIDTH,de.ANNOTATION.MIN_HEIGHT,o.data.label,32,24);return w(_(_({},o),i),{type:"ANNOTATION"})},cy=e=>{let{mxGeometry:t}=e,o=Wo(e),n=Fo(t,de.LANE.MIN_WIDTH,de.LANE.MIN_HEIGHT);return w(_(_({},o),n),{type:"LANE"})},yd={task:ni,"task-script":ni,"subprocess-collapsed":ni,"service-task":ni,"start-event":sy,"end-event-terminate":ay,"gateway-parallel":xs,"gateway-exclusive":xs,"gateway-complex":xs,annotation:ly,lane:cy},dy=e=>{if(e&&Array.isArray(e))return e.map(t=>({x:Number(t._attributes.x),y:Number(t._attributes.y)}))},xd=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=dy(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=""')?_(_({},Ho),y):_(_({},at),y)},Ed=(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}},Xo=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}}}},uy=e=>{let{variant:t}=e.data,o=Xo(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:gd[t]||"task"})})},py=e=>{let t=Xo(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"start-event"})})},fy=e=>{let t=Xo(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"end-event-terminate"})})},my=e=>{let{variant:t}=e.data,o=Xo(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:hd[t]})})},gy=e=>{let t=Xo(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"lane"})})},hy=e=>{let t=Xo(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"annotation"})})},_d={TASK:uy,START_EVENT:py,END_EVENT:fy,GATEWAY:my,ANNOTATION:hy,LANE:gy},bd=(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 yy=e=>{let t=Object.values(An),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=yd[s],l=a==null?void 0:a(i,n);if(!l){console.warn(`Node ${s} not supported`);continue}r.push(l)}return r},xy=(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=xd(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},Ey=(e,t)=>{let o=[];return e.forEach(n=>{var s,a;let r=(a=(s=_d)[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=bd(n,t);o.push(l)}}),o},_y=(e,t)=>{let o=[];return e.forEach(n=>{let r=Ed(n,t);o.push(r)}),o},by=(e=[],t=[],o)=>{let n=Ey(e,o),r=_y(t,e);return{mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}}},Td=(e=[],t=[],o)=>{let n=by(e,t,o);return ud(JSON.stringify(n),{compact:!0,spaces:0})},vd=async e=>{var s,a,l,c,d;let t=await oi(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)||Cn),r=yy(o),i=xy(o,r);return{lastElementId:n,edges:i,nodes:r}};import{useReactFlow as X0,useStoreApi as U0}from"@xyflow/react";import{useCallback as $0}from"react";import{Position as $t,useConnection as i0,useReactFlow as s0}from"@xyflow/react";import{useCallback as Ts}from"react";import{Handle as Nd,useReactFlow as Ty}from"@xyflow/react";import{jsx as wd}from"react/jsx-runtime";var ne=i=>{var s=i,{type:e,position:t,className:o,nodeType:n}=s,r=mt(s,["type","position","className","nodeType"]);let a=n==="TASK";return wd(Nd,_({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))},Ue=a=>{var l=a,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,s=mt(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=Ty(),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 wd(Nd,_({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))};import{useRef as Cd}from"react";import{NodeResizeControl as Sd,ResizeControlVariant as Ny,useReactFlow as wy,useStoreApi as Iy}from"@xyflow/react";import{useStoreApi as vy}from"@xyflow/react";var ri=()=>{let e=vy();return{getInternalNodes:()=>{let{nodeLookup:o}=e.getState();return Array.from(o.values())}}};import Id from"@dagrejs/dagre";var ii=(e=[],t=[],o="LR")=>{let n=new Id.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)),Id.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}},Ut=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId);if(t.length===0)return e;let o=Ca(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){Ra(s,o,r),Da(n,o);continue}$i(n,i,o)}return Sa(e,o)};var Ad=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)};import{Fragment as Sy,jsxs as My}from"react/jsx-runtime";import{createElement as Md}from"react";var Ay=["top","right","bottom","left"],Cy=["top-left","top-middle","top-right","right-middle","bottom-left","left-middle","bottom-right","bottom-middle"],lt=r=>{var i=r,{nodeId:e,isVisible:t,offset:o=8}=i,n=mt(i,["nodeId","isVisible","offset"]);let{getInternalNode:s,setNodes:a}=wy(),{getInternalNodes:l}=ri(),c=xt(),d=Iy(),u=Cd(0),p=Cd([]),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=io(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-re.HEADER_WIDTH:m,B=R;T&&P&&(B=Math.max(re.MIN_HEIGHT,y-k)),V&&$===O-1&&(B=Math.max(re.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:re.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+re.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=Ut(b),a(b);return}b=Oa(v,m,y,b,h),b=Ut(b),b=ro((I=v.parentId)!=null?I:v.id,b),a(b)};if(!(!c&&t))return null;let g={"--resize-offset":`${o}px`};return My(Sy,{children:[Ay.map(h=>Md(Sd,w(_({},n),{key:h,nodeId:e,position:h,variant:Ny.Line,className:"border-blue-400/90 border-dashed",style:g,onResize:(m,y)=>f(y),onResizeEnd:(m,y)=>x(y)}))),Cy.map(h=>Md(Sd,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)})))]})};import{NodeToolbar as Ky,useReactFlow as qy,useStore as Dd}from"@xyflow/react";import{Button as Zy,Tooltip as Jy,TooltipContent as Qy,TooltipTrigger as jy,useTranslation as e0}from"@produto-lecom/lecom-ui";import t0,{useCallback as Mn,useEffect as o0,useRef as si,useState as n0}from"react";import{create as Py}from"zustand";var Uo=Py(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{useEffect as Ly,useState as ky}from"react";var Pd=(e,t=!1)=>{let[o,n]=ky({width:0,height:0});return Ly(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};import{Position as Sn,useReactFlow as Ry}from"@xyflow/react";import{useMemo as Dy}from"react";var Oy=120,Vy=12,Ld=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=Ry(),{instanceId:i}=J();return Dy(()=>{var f,x;if(!t)return{position:Sn.Right,align:"start"};let s=n(e);if(!s)return{position:Sn.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:Sn.Right,align:"start"};let u=(o==null?void 0:o.width)||Oy;return{position:l+c+u+Vy>d?Sn.Left:Sn.Right}},[i,e,t,o,n,r])};import{Bot as Od}from"lucide-react";import{useNodesData as Hy,useReactFlow as Gy}from"@xyflow/react";import{Button as kd,DropdownMenu as By,DropdownMenuContent as zy,DropdownMenuGroup as Yy,DropdownMenuItem as Fy,DropdownMenuLabel as Wy,DropdownMenuTrigger as Xy,Tooltip as Es,TooltipContent as _s,TooltipTrigger as bs,useTranslation as Uy}from"@produto-lecom/lecom-ui";import{WrenchIcon as $y}from"lucide-react";import{jsx as Be,jsxs as go}from"react/jsx-runtime";var Rd=({nodeId:e})=>{let{t}=Uy(),{updateNodeData:o,getEdges:n,getNode:r}=Gy(),i=Hy(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 go(By,{children:[go(Es,{children:[Be(bs,{asChild:!0,children:Be(Xy,{asChild:!0,children:Be(kd,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:Be($y,{})})})}),Be(_s,{color:"black",children:t("bpmn.task.menu.title")})]}),go(zy,{align:"start",className:"w-60 bg-white text-grey-600",children:[go(Wy,{className:"flex items-center gap-1",children:[Be("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),Be("div",{className:"flex items-center gap-1",children:Object.entries(qn).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 go(Es,{children:[Be(bs,{asChild:!0,children:Be(kd,{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:Be(f.icon,{className:"stroke-inherit"})})}),g&&Be(_s,{color:"black",children:g})]},p)})})]}),Be(Yy,{children:go(Es,{children:[Be(bs,{asChild:!0,children:Be("div",{className:G({"cursor-not-allowed":a}),children:go(Fy,{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:[Be(Kn.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),a&&Be(_s,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};import{jsx as Re,jsxs as Vd}from"react/jsx-runtime";var Lt={START_EVENT:{type:"START_EVENT",icon:jo,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:To,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:jo,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:Wn,label:"bpmn.annotation.variant.default"}},r0={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:No,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:wo,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:vo,label:"bpmn.gateway.variant.complex"}},$e=t0.memo(({nodeId:e,nodeType:t,nodeVariant:o,isChild:n})=>{let r=si(null),i=si(null),{t:s}=e0(),{setDraggableNode:a}=Uo(),{getEdges:l,getNodes:c,setNodes:d}=qy(),{setIsDragging:u,mode:p,isConnecting:f,isDragging:x}=J(),E=xt(),g=Dd(Mn(z=>{var X,Z;return(Z=(X=z.nodeLookup.get(e))==null?void 0:X.selected)!=null?Z:!1},[e])),h=Dd(Mn(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}=Pd(r,m),{position:v}=Ld(e,m,y),[b,I]=n0(void 0),T=o==="SUBPROCESS",N=o==="SERVICE_TASK",C=si(null),M=si(!1),L=Mn(()=>{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]);o0(()=>{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=Mn((z,X)=>{M.current=!0,u(!1),a({type:X.type,variant:X.variant,attribute:X.attribute,icon:X.icon}),X.icon&&I(Re(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=Mn(()=>{L()},[L]);if(!m)return null;let V=c(),F=l(),j=[{component:Re(Yr,{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:Re(Ro,{nodeId:e,disabled:!z,tooltipMessage:z?void 0:s("editor.toolbar.start_event_limit_reached")})},Lt.TASK,Lt.ANNOTATION,...j]},K=()=>p==="view"?[{component:Re(Ft,{elementId:e})}]:[{component:Re(Ft,{elementId:e})},...T||N?[]:[{component:Re(Rd,{nodeId:e})}],{component:Re(Ro,{nodeId:e})},Lt.TASK,{type:"TASK",variant:"SUBPROCESS",icon:tn,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:Od,label:"bpmn.task.variant.service_task"},Lt.ANNOTATION,...Object.values(r0),...fo(e,V,F)?[]:[Lt.END_EVENT],...j],A=()=>p==="view"?[{component:Re(Ft,{elementId:e,elementType:"gateway"})}]:[{component:Re(Ft,{elementId:e,elementType:"gateway"})},{component:Re(Ro,{nodeId:e})},Lt.TASK,{type:"TASK",variant:"SUBPROCESS",icon:tn,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:Od,label:"bpmn.task.variant.service_task"},Lt.ANNOTATION,...j],P=()=>p==="view"?[]:[Lt.ANNOTATION,...j],R=()=>p==="view"?[]:[...n?[]:[{component:Re(Ro,{nodeId:e})}],Lt.ANNOTATION,...j],S=()=>p==="view"?[]:[{component:Re(Ro,{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 Vd(Ky,{position:v,align:"start",className:H?"-top-[4.5rem]":"-top-8",isVisible:m,children:[Re("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 Re("div",{children:z.component},X);let Z={sourceNodeType:t,targetNodeType:z.type,sourceNodeId:e,nodes:V,edges:F},W=zc(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 Vd(Jy,{children:[Re(jy,{asChild:!0,children:Re(Zy,{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&&Re(z.icon,{size:16})})}),Re(Qy,{color:"black",children:Q})]},X)})}),Re("div",{ref:i,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:b})]})});$e.displayName="NodeToolbar";import{Fragment as Hd,jsx as pt,jsxs as vs}from"react/jsx-runtime";var Gd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r,setNodes:i}=s0(),{inProgress:s,fromNode:a}=i0(),{mode:l,isReadOnly:c}=J(),d=s&&(a==null?void 0:a.id)!==e,u=Ts(x=>{let y=x.split(`
|
|
40
|
-
`),v=y.reduce((N,C)=>Math.max(N,C.length),0),b=y.length,I=Math.max(Ao.MIN_WIDTH,v*7+32),T=Math.max(Ao.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=Ts(x=>{r(e,{label:x}),u(x)},[e,r,u]),f=Ts(x=>{u(x)},[u]);return vs("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:[pt(Ge,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:p,onInput:f,skipFirstCharValidation:!0}),pt($e,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&pt(lt,{nodeId:e,minWidth:Ao.MIN_WIDTH,minHeight:Ao.MIN_HEIGHT,isVisible:!n&&o}),!s&&vs(Hd,{children:[pt(ne,{type:"source",position:$t.Left,id:"left"}),pt(ne,{type:"source",position:$t.Right,id:"right"}),pt(ne,{type:"source",position:$t.Top,id:"top"}),pt(ne,{type:"source",position:$t.Bottom,id:"bottom"})]}),(!s||d)&&vs(Hd,{children:[pt(ne,{type:"target",position:$t.Left,id:"left",className:G({"annotation-handle":d})}),pt(ne,{type:"target",position:$t.Right,id:"right",className:G({"annotation-handle":d})}),pt(ne,{type:"target",position:$t.Top,id:"top",className:G({"annotation-handle":d})}),pt(ne,{type:"target",position:$t.Bottom,id:"bottom",className:G({"annotation-handle":d})})]})]})};import{Position as Kt,useConnection as a0,useReactFlow as l0}from"@xyflow/react";import{useState as c0}from"react";import{Fragment as Bd,jsx as je,jsxs as Ns}from"react/jsx-runtime";var zd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=l0(),{inProgress:i,fromNode:s}=a0(),{mode:a,isReadOnly:l,reconnectingEdgeId:c}=J(),[d,u]=c0(!1),p=i&&(s==null?void 0:s.id)!==e||!!c,f=g=>{r(e,{label:g})},x=()=>{u(!0)},E=()=>{u(!1)};return Ns("div",{className:"relative",onDoubleClick:x,children:[je(To,{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})}),je("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:je(Ge,{value:t.label,isEditing:d,onBlur:E,onChange:f})}),je($e,{nodeId:e,nodeType:"END_EVENT"}),a==="edit"&&je(lt,{nodeId:e,isVisible:!n&&o,minWidth:Jn.MIN_WIDTH,minHeight:Jn.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||p)&&Ns(Bd,{children:[je(ne,{type:"target",position:Kt.Left,id:"left",className:G({"event-handle":p})}),je(ne,{type:"target",position:Kt.Right,id:"right",className:G({"event-handle":p})}),je(ne,{type:"target",position:Kt.Top,id:"top",className:G({"event-handle":p})}),je(ne,{type:"target",position:Kt.Bottom,id:"bottom",className:G({"event-handle":p})})]}),!i&&Ns(Bd,{children:[je(ne,{type:"source",position:Kt.Left,id:"left"}),je(ne,{type:"source",position:Kt.Right,id:"right"}),je(ne,{type:"source",position:Kt.Top,id:"top"}),je(ne,{type:"source",position:Kt.Bottom,id:"bottom"})]})]})};import{Position as qt,useConnection as d0,useReactFlow as u0}from"@xyflow/react";import{memo as p0,useCallback as f0,useState as m0}from"react";import{Fragment as Yd,jsx as et,jsxs as ws}from"react/jsx-runtime";var Is=p0(({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let s=Xi[t.variant].icon,{updateNodeData:a}=u0(),{inProgress:l,fromNode:c}=d0(),{mode:d,isReadOnly:u,reconnectingEdgeId:p}=J(),[f,x]=m0(!1),E=l&&(c==null?void 0:c.id)!==e||!!p,g=f0(y=>{a(e,{label:y})},[e,a]),h=()=>{x(!0)},m=()=>{x(!1)};return ws("div",{className:"relative",style:{width:o!=null?o:Io.MIN_WIDTH,height:n!=null?n:Io.MIN_HEIGHT},onDoubleClick:h,children:[et(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})}),et("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:et(Ge,{value:t.label,isEditing:f,onBlur:m,onChange:g})}),et($e,{nodeId:e,nodeType:"GATEWAY",nodeVariant:t.variant}),d==="edit"&&et(lt,{nodeId:e,isVisible:!i&&r,minWidth:Io.MIN_WIDTH,minHeight:Io.MIN_HEIGHT,offset:2,keepAspectRatio:!0}),(!l||E)&&ws(Yd,{children:[et(ne,{type:"target",position:qt.Left,id:"left",className:G({"gateway-handle":E})}),et(ne,{type:"target",position:qt.Right,id:"right",className:G({"gateway-handle":E})}),et(ne,{type:"target",position:qt.Top,id:"top",className:G({"gateway-handle":E})}),et(ne,{type:"target",position:qt.Bottom,id:"bottom",className:G({"gateway-handle":E})})]}),!l&&ws(Yd,{children:[et(Ue,{type:"source",position:qt.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),et(Ue,{type:"source",position:qt.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),et(Ue,{type:"source",position:qt.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),et(Ue,{type:"source",position:qt.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})});Is.displayName="Gateway";import{useNodesData as JP,useReactFlow as QP}from"@xyflow/react";import{Button as eL,DropdownMenu as tL,DropdownMenuContent as oL,DropdownMenuGroup as nL,DropdownMenuItem as rL,DropdownMenuLabel as iL,DropdownMenuTrigger as sL,Tooltip as aL,TooltipContent as lL,TooltipTrigger as cL,useTranslation as dL}from"@produto-lecom/lecom-ui";import{WrenchIcon as pL}from"lucide-react";import{jsx as hL,jsxs as yL}from"react/jsx-runtime";import{Position as Zt,useConnection as g0,useReactFlow as h0}from"@xyflow/react";import{useState as y0}from"react";import{Fragment as Fd,jsx as tt,jsxs as As}from"react/jsx-runtime";var Wd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=h0(),{inProgress:i,fromNode:s}=g0(),{mode:a,isReadOnly:l,reconnectingEdgeId:c}=J(),[d,u]=y0(!1),p=i&&(s==null?void 0:s.id)!==e||!!c,f=g=>{r(e,{label:g})},x=()=>{u(!0)},E=()=>{u(!1)};return As("div",{className:"relative",onDoubleClick:x,children:[tt(Un,{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})}),tt("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:tt(Ge,{value:t.label,isEditing:d,onBlur:E,onChange:f})}),tt($e,{nodeId:e,nodeType:"START_EVENT"}),a==="edit"&&tt(lt,{nodeId:e,isVisible:!n&&o,minWidth:Zn.MIN_WIDTH,minHeight:Zn.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||p)&&As(Fd,{children:[tt(ne,{type:"target",position:Zt.Left,id:"left",className:G({"event-handle":p})}),tt(ne,{type:"target",position:Zt.Right,id:"right",className:G({"event-handle":p})}),tt(ne,{type:"target",position:Zt.Top,id:"top",className:G({"event-handle":p})}),tt(ne,{type:"target",position:Zt.Bottom,id:"bottom",className:G({"event-handle":p})})]}),!i&&As(Fd,{children:[tt(Ue,{type:"source",position:Zt.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),tt(Ue,{type:"source",position:Zt.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),tt(Ue,{type:"source",position:Zt.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),tt(Ue,{type:"source",position:Zt.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};import{useTranslation as _0}from"@produto-lecom/lecom-ui";import{Position as Jt,useConnection as b0,useReactFlow as T0}from"@xyflow/react";import{memo as v0,useCallback as li}from"react";var Pn=60,ai=(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<=Pn?i:i.substring(0,Pn).trim()},$o=(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>Pn&&(n=n.substring(0,Pn).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=Pn-l.length,u=`${r.substring(0,c).trim()}${l}`;if(!o.has(u))return u;i++}return n};import{jsx as Xd,jsxs as x0}from"react/jsx-runtime";var Ud=e=>x0("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[Xd("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),Xd("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as $d}from"react/jsx-runtime";var Kd=e=>$d("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:$d("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"})}));import{jsx as qd,jsxs as E0}from"react/jsx-runtime";var Zd=e=>E0("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[qd("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),qd("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{Fragment as ci,jsx as ve,jsxs as Ln}from"react/jsx-runtime";var N0={APROVADO:Ud,EM_ANDAMENTO:Kd,REJEITADO:Zd},Cs={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)]"},w0={APROVADO:"bg-green-50",EM_ANDAMENTO:"bg-turquoise-50",REJEITADO:"bg-red-50"},Ss=v0(({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let{t:s}=_0(),{toast:a}=De(),{updateNodeData:l,getNodes:c,setNodes:d}=T0(),{inProgress:u,fromNode:p}=b0(),{mode:f,isReadOnly:x,onSubprocessValidationClick:E,reconnectingEdgeId:g}=J(),{getTaskStatus:h}=so(),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=li(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(Ht.MIN_WIDTH,Y*7+64),z=Math.max(Ht.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=li(K=>{let A=K.trim(),P=t.label||"";if(A===P)return;let R=A,S=c();if(!(A&&A!=="")){R=ai(S,s("bpmn.task.label.prefix")),l(e,{label:R}),N(R),a({variant:"warning",content:Ln(ci,{children:[s("bpmn.task.feedback.label_empty.prefix")," ",ve("strong",{children:R})]})});return}let Y=$o(R,S);Y===P||(l(e,{label:Y}),N(Y),Y!==R&&a({variant:"warning",content:Ln(ci,{children:[s("bpmn.task.feedback.label_already_exists.prefix")," ",ve("strong",{children:A})," ",s("bpmn.task.feedback.label_already_exists.middle")," ",ve("strong",{children:Y})]})}))},[t.label,c,e,s,l,N,a]),M=li(K=>{N(K)},[N]),L=li(()=>{a({variant:"error",content:s("bpmn.task.feedback.invalid_first_character")})},[s,a]),k=y?N0[y]:null,O=t.variant?Kn[t.variant].icon:null,V=t.attribute?qn[t.attribute].icon:null,F=()=>t.hasError?Cs.error:y?Cs[y]:x?Cs.default:"",j=()=>{var K;return r&&(K=w0[y])!=null?K:""},$=()=>{E==null||E({id:e,type:"sub_process",label:t.label})};return Ln("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:Ht.MIN_WIDTH,height:n!=null?n:Ht.MIN_HEIGHT},children:[ve("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:ve(Ge,{value:t.label,maxLength:60,className:G(j(),{"py-10 px-8":I||T}),onChange:C,onInput:M,onInvalidFirstCharacter:L})}),O&&ve("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:ve(O,{size:b?20:16,className:G(t.hasError?"text-red-500":"text-grey-500",v&&"cursor-pointer"),onClick:v?$:void 0})}),V&&ve("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:ve("div",{className:G("flex items-center w-16 p-1",v||b?"justify-between":"justify-center"),children:ve(V,{size:16,className:G(t.hasError?"text-red-500":"text-grey-500")})})}),k&&ve("div",{className:"absolute top-0 right-0 flex items-center p-1",children:ve(k,{})}),ve($e,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),f==="edit"&&ve(lt,{nodeId:e,isVisible:!i&&r,minWidth:Ht.MIN_WIDTH,minHeight:Ht.MIN_HEIGHT}),(!u||m)&&Ln(ci,{children:[ve(ne,{type:"target",position:Jt.Left,id:"left",className:G({"task-handle":m})}),ve(ne,{type:"target",position:Jt.Right,id:"right",className:G({"task-handle":m})}),ve(ne,{type:"target",position:Jt.Top,id:"top",className:G({"task-handle":m})}),ve(ne,{type:"target",position:Jt.Bottom,id:"bottom",className:G({"task-handle":m})})]}),!u&&Ln(ci,{children:[ve(Ue,{type:"source",position:Jt.Left,id:"left",nodeId:e,nodeType:"TASK"}),ve(Ue,{type:"source",position:Jt.Right,id:"right",nodeId:e,nodeType:"TASK"}),ve(Ue,{type:"source",position:Jt.Top,id:"top",nodeId:e,nodeType:"TASK"}),ve(Ue,{type:"source",position:Jt.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})});Ss.displayName="Task";import{Position as Jd}from"@xyflow/react";import{Fragment as I0,jsx as di,jsxs as A0}from"react/jsx-runtime";var Qd=({id:e,data:t})=>A0(I0,{children:[di("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}),di($e,{nodeId:e,nodeType:"UNSUPPORTED"}),di(ne,{type:"source",position:Jd.Right}),di(ne,{type:"target",position:Jd.Left})]});import{BaseEdge as C0,EdgeLabelRenderer as S0,getSmoothStepPath as M0,MarkerType as P0,useInternalNode as jd,useReactFlow as L0,useViewport as k0,Position as Ko}from"@xyflow/react";import{useState as R0,useMemo as D0}from"react";import{Fragment as O0,jsx as ot,jsxs as ho}from"react/jsx-runtime";var ok={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:P0.Arrow},data:{label:""}},eu=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:s,sourceHandleId:a,targetHandleId:l})=>{var B;let{zoom:c}=k0(),{updateEdgeData:d}=L0(),{mode:u,instanceId:p}=J(),f=xt(),x=u!=="edit",[E,g]=R0(!1),{reconnectingHandle:h,cursorPosition:m,hoveredNodeId:y,reconnectingSide:v,isValidReconnection:b,handleReconnectStart:I}=Jr({edgeId:e,source:t,target:o,instanceId:p,isReadOnly:x}),T=jd(t),N=jd(o),{sx:C,sy:M,tx:L,ty:k,sourcePos:O,targetPos:V}=D0(()=>{var te,me;if(!T||!N)return{sx:0,sy:0,tx:0,ty:0,sourcePos:Ko.Left,targetPos:Ko.Right};let Y=Co(T,N),D=a?i:Y.sourcePos,H=l?s:Y.targetPos,z=(ue,ae,Ee)=>{var oe,le,xe,Se,Ie,Fe;let{x:_e,y:He}=ue.internals.positionAbsolute,q=(xe=(le=(oe=ue.measured)==null?void 0:oe.width)!=null?le:ue.width)!=null?xe:0,ie=(Fe=(Ie=(Se=ue.measured)==null?void 0:Se.height)!=null?Ie:ue.height)!=null?Fe:0;switch(ae){case Ko.Top:return{x:_e+q*Ee,y:He};case Ko.Bottom:return{x:_e+q*Ee,y:He+ie};case Ko.Left:return{x:_e,y:He+ie*Ee};case Ko.Right:return{x:_e+q,y:He+ie*Ee};default:return{x:_e+q/2,y:He+ie/2}}},X=(te=n==null?void 0:n.sourceOffset)!=null?te:.5,Z=(me=n==null?void 0:n.targetOffset)!=null?me:.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,$]=M0({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 ho("g",{className:G("group bpmn-arrow-edge",{"is-highlighted":K}),onDoubleClick:()=>!x&&g(!0),children:[ot("path",{d:F,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),ho("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:[ot(C0,{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})}),ho(S0,{children:[ho("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&&ot(Oo,{sx:C,sy:M,tx:L,ty:k,hasLabel:!!((B=n==null?void 0:n.label)!=null&&B.trim()),children:ot(Do,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),P&&ot(Ge,{value:n==null?void 0:n.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:E,onBlur:R,onChange:S})]}),r&&!f&&!x&&ho(O0,{children:[ot("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${C}px, ${M}px)`},children:ho("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[ot("circle",{cx:6/c,cy:6/c,r:4/c,fill:h==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),ot("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"}),ot("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)})]})}),ot("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${L}px, ${k}px)`},children:ho("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[ot("circle",{cx:6/c,cy:6/c,r:4/c,fill:h==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),ot("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"}),ot("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)})]})})]})]})]})]})};import{getStraightPath as V0,Position as ui}from"@xyflow/react";import{jsx as tu,jsxs as H0}from"react/jsx-runtime";var ou=({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:ui.Left},{x:n+s,y:r+a/2,pos:ui.Right},{x:n+s/2,y:r,pos:ui.Top},{x:n+s/2,y:r+a,pos:ui.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]=V0({sourceX:c.x,sourceY:c.y,targetX:e,targetY:t});return H0("g",{className:"group",children:[tu("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d}),tu("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})};import{Position as Qt,useConnection as G0,useReactFlow as B0}from"@xyflow/react";import{orderBy as z0}from"lodash";import{memo as Y0,useMemo as nu,useState as F0}from"react";import{Fragment as Ms,jsx as Ze,jsxs as pi}from"react/jsx-runtime";var Ps=Y0(({id:e,data:t,selected:o,dragging:n,parentId:r})=>{var T;let{updateNodeData:i,getNodes:s}=B0(),{mode:a,isReadOnly:l}=J(),{inProgress:c,fromNode:d}=G0(),u=c&&(d==null?void 0:d.id)!==e,[p,f]=F0(!1),x=s(),E=!r,g=!E&&((T=x.find(N=>N.id===r))==null?void 0:T.selected),h=nu(()=>z0([...x.filter(N=>N.parentId===e&&N.type==="LANE")],"position.y","asc"),[x,e]),m=E?wa.MIN_WIDTH:re.MIN_WIDTH,y=nu(()=>{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)+re.MIN_HEIGHT}return re.MIN_HEIGHT},[E,h]),v=N=>{i(e,{label:N})},b=()=>{f(!0)},I=()=>{f(!1)};return pi(Ms,{children:[pi("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:[Ze("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:Ze("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:Ze(Ge,{value:t.label,className:"w-full h-full self-auto",contentClassName:G({"whitespace-nowrap":p}),isEditing:p,onBlur:I,onChange:v})})}),Ze("div",{className:"flex-1"})]}),Ze($e,{nodeId:e,nodeType:"LANE",isChild:!E}),a==="edit"&&Ze(lt,{nodeId:e,isVisible:!n&&o,minWidth:m,minHeight:y,offset:10}),!c&&pi(Ms,{children:[Ze(ne,{type:"source",position:Qt.Left,id:"left"}),Ze(ne,{type:"source",position:Qt.Right,id:"right"}),Ze(ne,{type:"source",position:Qt.Top,id:"top"}),Ze(ne,{type:"source",position:Qt.Bottom,id:"bottom"})]}),(!c||u)&&pi(Ms,{children:[Ze(ne,{type:"target",position:Qt.Left,id:"left",className:G({"annotation-handle":u})}),Ze(ne,{type:"target",position:Qt.Right,id:"right",className:G({"annotation-handle":u})}),Ze(ne,{type:"target",position:Qt.Top,id:"top",className:G({"annotation-handle":u})}),Ze(ne,{type:"target",position:Qt.Bottom,id:"bottom",className:G({"annotation-handle":u})})]})]})});Ps.displayName="Lane";var ru={START_EVENT:Wd,END_EVENT:zd,TASK:Ss,GATEWAY:Is,ANNOTATION:Gd,LANE:Ps,UNSUPPORTED:Qd},iu={SEQUENCE_EDGE:hs,MESSAGE_EDGE:eu,ANNOTATION_EDGE:Xc},su="#fafafa",au="#bebebe",lu=1,cu=10,du="bottom-left",Ls=.05,uu=5,pu=150,fu=100,mu=Ls,gu=1,hu={x:0,y:0,zoom:.75},yu=1,xu=2,W0={[yu]:4,[xu]:2},kn=[yu,xu],Eu=[0,1,2],_u={hideAttribution:!0},ks=kn.reduce((e,t)=>e|W0[t],0);var jt=()=>{let{setViewport:e}=X0(),t=U0();return{fitToNodes:$0(n=>{let{width:r,height:i}=t.getState();if(i<=0||r<=0)return;let s=La(n);if(!s)return;let a=ka({bounds:s,canvasHeight:i,canvasWidth:r,minZoom:mu,maxZoom:gu,offsetX:pu,offsetY:fu});e(a)},[t,e])}};import{useReactFlow as K0}from"@xyflow/react";var ct=()=>{let{getEdges:e,getNodes:t}=K0(),{lastElementId:o}=J(),n=()=>{let i=t(),s=e(),a=cd(i,s);return Math.max(a,o)};return{getLastId:n,getNextId:()=>n()+1}};var eo=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n}=q0(),{getLastId:r}=ct(),{fitToNodes:i}=jt(),{setLastElementId:s}=J(),a=bu(async(c="")=>{let{nodes:d,edges:u,lastElementId:p}=await vd(c);i(d),o(d),n(u),s(p)},[o,n,s,i]),l=bu(()=>{let c=e(),d=t(),u=r();return Td(c,d,u)},[e,t,r]);return{importFromMxGraph:a,exportToMxGraph:l}};var Q0=500,fi=()=>{let{isInitialized:e,onElementChanges:t}=J(),{exportToMxGraph:o}=eo(),n=J0(()=>{if(!e)return;let s=o();t==null||t(s)},Q0);Z0(()=>()=>{n.isPending()&&n.flush()},[n]);let r=Tu(s=>{s.every(c=>c.type==="select")||s.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=Tu(s=>{s.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var vu=({setEdges:e,saveHistory:t})=>{let{getNode:o,getEdges:n,getNodes:r,getInternalNode:i}=ex(),{emitElementChanges:s}=fi(),a=tx(null),{getNextId:l}=ct(),c=yo(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 ps(y).isValid},[o,n,r]),d=yo(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=ad(m,I,T),C=(b==null?void 0:b.type)==="ANNOTATION"||(m==null?void 0:m.type)==="ANNOTATION",M=C?Ho:at,L;if(!C&&b&&g.targetHandle){let V=ti(N),F=ti(g.targetHandle),{x:j,y:$}=ys(m,N),{x:K,y:A}=ys(b,g.targetHandle),R=qr(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?{}:at.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=yo((g,h)=>{a.current=h.id},[]),p=yo(()=>{a.current=null},[]),f=yo((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(!ps(v).isValid){a.current=null;return}let I=j0(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=yo(g=>{a.current=g},[]),E=yo(()=>{a.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:f,onReconnectStart:u,onReconnectEnd:p,setReconnectingEdge:x,clearReconnectingEdge:E}};import{useTranslation as ox}from"@produto-lecom/lecom-ui";import{useReactFlow as nx}from"@xyflow/react";import{useCallback as qo,useRef as Rs,useState as rx}from"react";var Rn=(e=[])=>e.filter(t=>t.type==="START_EVENT"),xo=(e=[])=>e.filter(t=>t.type==="END_EVENT"),to=(e=[])=>e.filter(t=>t.type==="TASK")||[],Nu=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"});var mi=(e=[])=>e.filter(t=>t.type==="GATEWAY"),wu=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),nt=(e,t=[])=>t.filter(o=>o.source===e),Dn=(e,t=[])=>t.filter(o=>o.target===e),Iu=(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"},Au=(e,t)=>{let o=nt(e,t.edges||[]);for(let n of o){let r=(t.nodes||[]).find(i=>i.id===n.target);if(r&&r.type==="END_EVENT")return!0}return!1},Cu=e=>e?/[^\s]/.test(e.trim()):!1,ye=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:[]}},kt=(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)}},Su=(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 On=[{id:"start_event_not_found",validate:e=>{let t=Rn(e.nodes);return ye({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=xo(e.nodes);return ye({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Rn(e.nodes),o=t.length===1;if(t.length===0)return ye({isValid:!0});if(!o)return ye({isValid:!1,nodeIds:t.map(i=>i.id)});let n=nt(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(s=>s.id),...n.map(s=>s.target)];return ye({isValid:!1,nodeIds:[...new Set(i)]})}return ye({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=to(e.nodes),o=kt(t,n=>nt(n.id,e.edges).length<=2);return ye({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=to(e.nodes),o=kt(t,n=>!!n.label&&n.label.trim()!=="");return ye({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=to(e.nodes),n=kt(o,r=>!r.label||r.label.length<=60);return ye({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=to(e.nodes),o=new Map;for(let r of t){if(!r.label)continue;let i=r.label.trim();i&&(o.has(i)||o.set(i,[]),o.get(i).push(r))}let n=[];for(let[,r]of o.entries())r.length>1&&r.forEach(i=>n.push(i.id));return ye({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{var r,i,s,a;let t=mi(e.nodes),o=[],n=[];for(let l of t){let c=nt(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 ye({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Rn(e.nodes),...xo(e.nodes)],o=[],n=[];for(let r of t){let i=nt(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 ye({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=xo(e.nodes),o=[],n=[];for(let r of t){let i=Dn(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=nt(a.id,e.edges);l.length>1&&(o.push(a.id),l.forEach(c=>n.push(c.id)))}}}return ye({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=wu(e.nodes),o=kt(t,r=>nt(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>nt(r,e.edges).map(i=>i.id));return ye({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=to(e.nodes),o=kt(t,n=>!n.label||Cu(n.label));return ye({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 ye({isValid:!0});let t=xo(e.nodes)[0];if(!t)return ye({isValid:!0});let o=Dn(t.id,e.edges);if(!o.length)return ye({isValid:!0});let r=to(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=kt(r,l=>!Iu(l.id,e));return ye({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=to(e.nodes),o=xo(e.nodes)[0];if(!o)return ye({isValid:!0});let n=t.filter(l=>{let c=Dn(l.id,e.edges),d=nt(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=Dn(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 ye(a)}},{id:"gateway_flow_to_event",validate:e=>{let t=mi(e.nodes),o=[],n=[];for(let r of t){let i=nt(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 ye({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=mi(e.nodes),o=kt(t,n=>nt(n.id,e.edges).length>=1);return ye({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Rn(e.nodes),...xo(e.nodes)],o=[],n=[];for(let r of t){let i=nt(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 ye({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=Nu(e.nodes),o=kt(t,n=>!Au(n.id,e));return ye({isValid:o.isValid,nodeIds:o.invalidIds})}}];var Mu=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of On){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}},Pu=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}}};import{jsx as gi,jsxs as ix}from"react/jsx-runtime";var Lu=()=>{let{t:e}=ox(),{toast:t}=De(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=nx(),{validateCustomDiagram:s}=J(),[a,l]=rx(!1),c=Rs(!1),d=Rs(!1),u=Rs(!1),p=qo(async m=>{let y=Su(m.nodes,m.edges),v=Mu(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 Pu(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=qo((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:ix("div",{className:"flex flex-col gap-1",children:[!m.isValid&&gi("span",{className:"body-small-500",children:e("validation.errors.subtitle")}),gi("ul",{className:"list-disc list-inside max-h-40 overflow-y-auto",children:m.isValid?gi("li",{children:e("validation.success.message")}):m.errors.map(V=>gi("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=On.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=On.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=qo(()=>{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=qo(()=>{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=qo(()=>d.current,[]),h=qo(()=>c.current,[]);return{validateDiagram:p,handleValidationComplete:f,clearValidation:x,dismissValidationPanel:E,isAutoValidationEnabled:a,getIsClearingValidation:g,getIsValidating:h}};import{useReactFlow as sx}from"@xyflow/react";import{useTranslation as ax}from"@produto-lecom/lecom-ui";import{useEffect as lx}from"react";var cx=15,ku="bpmn:selection",dx=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},Ru=e=>{if(!dx(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},Du=({offset:e=cx,saveHistory:t})=>{let{t:o}=ax(),{getNodes:n,setNodes:r,getEdges:i,setEdges:s}=sx(),{getNextId:a}=ct(),{mode:l,containerRef:c}=J();lx(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let u=f=>{var b,I;if(!Ru(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(ku,v),(I=f.clipboardData)==null||I.setData("text/plain",`BPMN Selection: ${h.length} nodes`)},p=f=>{var L,k;if(!Ru(f)||!d.contains(document.activeElement))return;let E=(L=f.clipboardData)==null?void 0:L.getData(ku);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=>ko(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=$o($||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])};import{useTranslation as ux}from"@produto-lecom/lecom-ui";import{useReactFlow as px}from"@xyflow/react";import{useRef as fx,useState as mx}from"react";var gx=50,Ou=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let{draggableNode:r,setDraggableNode:i}=Uo(),{t:s}=ux(),{getInternalNode:a,getNodes:l,getEdges:c,screenToFlowPosition:d}=px(),{getNextId:u}=ct(),{setIsDragging:p}=J(),{getInternalNodes:f}=ri(),{rebuildIndex:x,forceRebuildIndex:E}=Pr(),[g,h]=mx(null),m=fx(""),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=rn(A,H);if(!z){v();return}if(no({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=rn(A,B);if(!Y){v();return}if(no({parentId:Y.id,nodes:e,includeTypes:["LANE"]})){v();return}v(Y.id)},I=A=>{let P=a(A.id),R=A.type==="LANE"&&no({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=it(S),Y=B.y+B.h;R=Math.max(R,Y)}return R+gx},M=(A,P)=>{if(!Ui(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=Ki(A,P,S),S=Ut(S),S=ro(B,S),T(S);if(A.type==="LANE"){if(no({parentId:P.id,nodes:S,excludeTypes:["LANE"]})){let te=Cr(P),me=50,ue=50;return S.map(ae=>{var Ee,_e;return ae.id===A.id?w(_({},ae),{position:{x:(Ee=g==null?void 0:g.x)!=null?Ee:te.x+me,y:(_e=g==null?void 0:g.y)!=null?_e:te.y2+ue}}):ae})}let Q=S.filter(te=>te.parentId===P.id).reduce((te,me)=>{var ue,ae;return te+((ae=(ue=me.measured)==null?void 0:ue.height)!=null?ae:0)},0),ee={x:re.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=Ut(S),S=M(B,S),S}if(no({parentId:P.id,nodes:S,includeTypes:["LANE"]})){let W;if(A.parentId){let U=a(A.parentId),{x:Q,y:ee}=it(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=ro(B,S),S}let H=Ma(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=Ki(z,P,S),S=Ut(S),S=ro(B,S),S},F=A=>{if(A.preventDefault(),!(r!=null&&r.type))return;if(!ko(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"?ai(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=rn(D,X),W=[...H.map(te=>w(_({},te),{selected:!1})),Y];Z&&(W=V(Y,Z,W)),W=nn(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},me=r.type==="ANNOTATION"?_(_({},te),Ho):_(_({},te),at);ee=Q.concat(me),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=rn(z,Z);if(W){if(X&&no({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)Ui(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=ro(z,S)}S=nn(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,me,ue;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=re.MIN_HEIGHT;else if(S){let ae=(W=(Z=A.measured)==null?void 0:Z.height)!=null?W:re.MIN_HEIGHT;D=((Q=(U=R.measured)==null?void 0:U.height)!=null?Q:re.MIN_HEIGHT)-ae,D=Math.max(re.MIN_HEIGHT,D)}else D=B.length>0?B.reduce((ae,Ee)=>{var _e,He;return ae+((He=(_e=Ee.measured)==null?void 0:_e.height)!=null?He:0)},0)+Te:Math.max(re.MIN_HEIGHT,(te=(ee=R.measured)==null?void 0:ee.height)!=null?te:0);let{x:H,y:z}=it(R),X={x:H+((me=A.position.x)!=null?me:0),y:z+((ue=A.position.y)!=null?ue: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=Ut(P),P};return{onDragOver:L,onDragLeave:k,onDrop:F,onNodeDrag:O,onNodeDragStart:$,onNodeDragStop:j}};import{useReactFlow as hx}from"@xyflow/react";import{useTranslation as yx}from"@produto-lecom/lecom-ui";import{useEffect as xx}from"react";var Ex=30,_x=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},bx=e=>!_x(e.target),Vu=({offset:e=Ex,saveHistory:t})=>{let{t:o}=yx(),{getNodes:n,setNodes:r,getEdges:i,setEdges:s}=hx(),{getNextId:a}=ct(),{mode:l,containerRef:c}=J();xx(()=>{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"&&bx(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=>ko(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=$o(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])};import{useEffect as Tx,useRef as Hu}from"react";import{useReactFlow as vx}from"@xyflow/react";var Nx=20,wx=50,Vn={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},Ix=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},Gu=e=>{let{getNodes:t}=vx(),{mode:o,isMoveTool:n}=J(),r=Hu(0),i=Hu(new Map);Tx(()=>{let s=a=>{if(o!=="edit"||!n||Ix(a.target)||!Object.values(Vn).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?wx:Nx,E=0,g=0;switch(a.key){case Vn.UP:g=-x;break;case Vn.DOWN:g=x;break;case Vn.LEFT:E=-x;break;case Vn.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])};import{useReactFlow as Cx}from"@xyflow/react";var zu={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY","gateway-parallel":"GATEWAY","gateway-complex":"GATEWAY"},Yu={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Bu=(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}},Ax=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=Bu(i[0],o),a=Bu(i[1],o);s&&a&&n.push({sourceId:s.step,targetId:a.step,label:s.edgeLabel||a.edgeLabel||""})}),{components:o,connections:n}},Fu=e=>{let{components:t,connections:o}=Ax(e);return{nodes:t,edges:o}};var Sx=7,Mx=48,Px=340,Lx=(e,t)=>{let o=Mx+e.length*Sx;return Math.min(Px,Math.max(t,o))},hi=()=>{let{setNodes:e,setEdges:t}=Cx(),{fitToNodes:o}=jt(),{getNextId:n}=ct();return{importFromLia:i=>{let s=typeof i=="string"?i:i.diagramXml||"",{nodes:a,edges:l}=Fu(s),c=[],d=new Map,u=!1,p=n();for(let[m,y]of Object.entries(a)){let v=String(p++),b=zu[y.type],I=Yu[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(_({},at),{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(_({},at),{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:Lx(String((v=(y=m.data)==null?void 0:y.label)!=null?v:""),de.TASK.MIN_WIDTH)}):m}),{nodes:E}=ii(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)}}};import{useCallback as kx,useEffect as Rx}from"react";var Dx={origin:"*",debug:!1};function yi(e,t=Dx){let{origin:o,debug:n}=t,r=kx((i,s)=>{let a={event:i,data:s};window.parent.postMessage(a,o||"*")},[o]);return Rx(()=>{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}}import{useNodesInitialized as Vx}from"@xyflow/react";import{useEffect as Ds,useRef as Hx}from"react";var Wu=()=>{let e=Vx(),{initialDiagram:t,isNewDiagram:o,isInitialized:n,setIsInitialized:r,onElementChanges:i}=J(),{importFromMxGraph:s,exportToMxGraph:a}=eo(),{sendMessage:l}=yi(),c=Hx(!1);Ds(()=>{t&&s(t)},[t,s]),Ds(()=>{if(!n||!o||c.current)return;c.current=!0;let d=a();i==null||i(d)},[n,o,t,a,i]),Ds(()=>{if(!e)return;(async()=>{await Xn(),r(!0),l("INIT_MODELER",t)})()},[e,t,r,l])};import{useReactFlow as Gx}from"@xyflow/react";import{useCallback as Xu}from"react";function Uu(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=so(),{getEdges:n}=Gx(),r=Xu(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=Xu(()=>{t()},[t]);return{handleTasksStatus:r,handleClearTaskStatus:i}}import{useReactFlow as Bx}from"@xyflow/react";import{useCallback as Rt,useState as zx,useEffect as $u}from"react";import{useDebouncedCallback as Yx}from"use-debounce";var Fx=500,Ku=100,qu=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=Bx(),{mode:i,containerRef:s}=J(),[a,l]=zx({history:[],currentStep:0}),{history:c,currentStep:d}=a,u=d>0,p=d<c.length-1,f=Rt((T,N)=>{n(T[N].nodes),r(T[N].edges)},[n,r]),x=Rt(()=>{if(d>0){let T=d-1;l(N=>w(_({},N),{currentStep:T})),f(c,T)}},[d,c,f]),E=Rt(()=>{if(d<c.length-1){let T=d+1;l(N=>w(_({},N),{currentStep:T})),f(c,T)}},[c,d,f]),g=Rt(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>Ku?k.slice(k.length-Ku):k;return{history:O,currentStep:O.length-1}})},[]),h=Rt((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:nn(C),edges:M}},[]),m=Rt(()=>h(t(),o()),[t,o,h]),y=Yx(()=>{let T=m();g(T)},Fx),v=Rt((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")||jn(T)||y()},[e,y,c.length,m,g,h]);$u(()=>{if(e&&c.length===0){let T=m();l({history:[T],currentStep:0})}},[e,c.length,m]);let b=Rt(T=>{l({history:T||[],currentStep:0})},[]),I=Rt(()=>{l({history:[],currentStep:0})},[]);return $u(()=>{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 Zu=()=>{let{t:e}=Wx(),[t,o,n]=Ux([]),[r,i,s]=Xx([]),{getNodes:a,getNode:l}=$x(),{toast:c}=De(),d=Kx(),{instanceId:u,isInitialized:p,setIsConnecting:f,onElementClick:x}=J(),{updateHelperLines:E,HelperLines:g}=Pr(),{undo:h,redo:m,canUndo:y,canRedo:v,saveHistory:b}=qu(p),{onNodeDrag:I,onDrop:T,onDragOver:N,onDragLeave:C,onNodeDragStop:M,onNodeDragStart:L}=Ou({nodes:t,setNodes:o,setEdges:i,saveHistory:b}),{isValidConnection:k,onConnect:O,onReconnect:V,onReconnectStart:F,onReconnectEnd:j,setReconnectingEdge:$,clearReconnectingEdge:K}=vu({setEdges:i,saveHistory:b}),{handleValidationComplete:A,clearValidation:P,dismissValidationPanel:R,validateDiagram:S,getIsValidating:B,getIsClearingValidation:Y}=Lu(),{importFromLia:D}=hi(),{handleTasksStatus:H,handleClearTaskStatus:z}=Uu(),{clearPathEdges:X}=so(),{emitElementChanges:Z,handleNodeChanges:W,handleEdgeChanges:U}=fi(),Q=Va();Du({saveHistory:b}),Vu({saveHistory:b}),Wu();let ee=Dt(()=>{o([]),i([]),X(),setTimeout(Q,0)},[o,i,X,Q]),{selectElements:te,clearSelection:me}=ht(),{importFromMxGraph:ue,exportToMxGraph:ae}=eo(),{configureElement:Ee,getConfigureElement:_e}=Gr(),He=Dt(fe=>{fe!=null&&fe.id&&te([fe.id])},[te]),{sendMessage:q}=yi({LIA_CREATE_DIAGRAM:D,CLEAR_DIAGRAM:ee,TASKS_STATUS:H,CLEAR_TASKS_STATUS:z,EXTERNAL_TASK_SELECT:He}),ie=Dt(()=>t.length+r.length,[t,r]);qx(()=>(_t.set(u,{importFromMxGraph:ue,exportToMxGraph:ae,selectElements:te,clearSelection:me,configureElement:Ee,getConfigureElement:_e,getElementsCount:ie,setReconnectingEdge:$,clearReconnectingEdge:K}),()=>{_t.delete(u)}),[u,ue,ae,te,me,Ee,_e,ie,$,K]);let oe=Dt((fe,ge)=>{if(ge.type!=="TASK"&&ge.type!=="GATEWAY")return;let he=_e(ge.id);he&&(x==null||x(he)),ge.type==="TASK"&&q("SELECT_TASK",{id:ge.id})},[_e,x,q]),le=Dt((fe,ge)=>{if(ge.type!=="SEQUENCE_EDGE")return;let he=l(ge.source),Ne=l(ge.target),{isFromStartEvent:be,isGatewayToGateway:Me,isActiviyToAndGateway:Ae,isToEndEvent:We}=Qn(he,Ne);if(!(!be&&!Me&&!Ae&&!We))return;let wt=_e(ge.id);wt&&(x==null||x(wt))},[_e,l,x]),xe=Dt(fe=>{E(fe,t),n(fe),!jn(fe)&&(b(fe),Y()||R(),B()||W(fe))},[t,b,Y,R,E,W,B]),Se=Dt(fe=>{s(fe),b(fe),Y()||R(),B()||U(fe)},[s,b,Y,R,U,B]);Gu(xe);let Ie=Dt(async({nodes:fe})=>fe.some(he=>he.type==="LANE"&&t.some(Ne=>Ne.parentId===he.id))?(c({variant:"error",title:e("validation.errors.title"),content:e("editor.toolbar.delete_pool_lane_error")}),!1):!0,[t,e,c]),Fe=()=>{b("forceSave"),Z(),R()},vt=()=>{f(!0)},Nt=()=>{f(!1),R()},ft=Dt(fe=>{let ge=new Set(fe.filter(he=>he.type==="LANE"&&!!he.parentId).map(he=>he.parentId));ge.size!==0&&setTimeout(()=>{var be,Me;let he=a(),Ne=new Map(he.map(Ae=>[Ae.id,Ae]));for(let Ae of ge){let We=io(he.filter(It=>It.type==="LANE"&&It.parentId===Ae));if(We.length===0)continue;let Ot=0;for(let It of We)Ne.set(It.id,w(_({},It),{position:{x:re.HEADER_WIDTH,y:Ot}})),Ot+=(Me=(be=It.measured)==null?void 0:be.height)!=null?Me:0;let wt=Ne.get(Ae);wt&&Ne.set(Ae,w(_({},wt),{height:Ot,measured:w(_({},wt.measured),{height:Ot})}))}o(he.map(Ae=>{var We;return(We=Ne.get(Ae.id))!=null?We:Ae}))},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:Fe,onConnectStart:vt,onConnectEnd:Nt,onSelectionEnd:()=>setTimeout(()=>d.setState({nodesSelectionActive:!1}),0),onNodesChange:xe,onEdgesChange:Se,onBeforeDelete:Ie,onNodesDelete:ft},ui:{handleCloseValidationPanel:P},controls:{undo:h,redo:m,canUndo:y,canRedo:v},components:{HelperLines:g},actions:{saveHistory:b,selectElements:te,clearSelection:me,exportToMxGraph:ae,validateDiagram:S,handleValidationComplete:A,setReconnectingEdge:$,clearReconnectingEdge:K}}};import{useCallback as Zx}from"react";import{useStore as Jx}from"@xyflow/react";function xi(){return Jx(Zx(e=>e.nodes.length+e.edges.length>0,[]))}import{useReactFlow as Qx}from"@xyflow/react";import{useCallback as jx,useEffect as eE,useRef as tE,useState as oE}from"react";var nE=".react-flow__node, .react-flow__edge, .react-flow__node-toolbar";function Ju(e,t,o){let[n,r]=oE(!1),i=tE(null),{getViewport:s,setViewport:a}=Qx(),l=jx(()=>{i.current=null,r(!1)},[]);return eE(()=>{let c=e.current;if(!c)return;let d=f=>{if(!kn.some(E=>E===f.button)||t.current||o.current||(r(!0),!(f.target instanceof Element))||!f.target.closest(nE))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&ks)===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&ks)===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}import{jsx as Qu}from"react/jsx-runtime";var Ei=({id:e,className:t})=>Qu("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:Qu("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as _i,jsxs as rE}from"react/jsx-runtime";var ju=()=>_i("svg",{style:{position:"absolute",top:0,left:0},children:rE("defs",{children:[_i(Ei,{id:"sequence-edge-marker",className:"text-grey-500"}),_i(Ei,{id:"sequence-edge-marker-hovered",className:"text-grey-800"}),_i(Ei,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{Tooltip as cb,TooltipContent as db,TooltipTrigger as ub,useTranslation as pb}from"@produto-lecom/lecom-ui";import{useKeyPress as Ap,useReactFlow as C_}from"@xyflow/react";import{Button as Ai,Tooltip as Ci,TooltipContent as Si,TooltipTrigger as Mi,useTranslation as S_}from"@produto-lecom/lecom-ui";import{HandIcon as M_,ListCheckIcon as P_,Loader2Icon as L_,MapIcon as k_,MousePointerIcon as R_}from"lucide-react";import D_,{useCallback as Ks,useEffect as Cp,useState as O_}from"react";import{Tooltip as NE,TooltipContent as wE,TooltipTrigger as IE,useTranslation as AE}from"@produto-lecom/lecom-ui";var Hn=(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))(Hn||{});import{Button as hE,useTranslation as yE}from"@produto-lecom/lecom-ui";import{useReactFlow as xE}from"@xyflow/react";var bi=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 ep({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);Ti(i,`${o}.csv`)}var Ti=(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
|
|
38
|
+
</mxGraphModel>`,cd=(e,t)=>{if(!e.length&&!t.length)return Cn;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};import{xml2json as ny,json2xml as ry}from"xml-js";var dd={compact:!0,spaces:4},iy=e=>e.replace(/\n/g,"
");function oi(e,t=dd){if(e)return JSON.parse(ny(e,t))}function ud(e,t=dd){return e?ry(e,w(b({},t),{attributeValueFn:iy})):""}var pd={"attribute-loop":"LOOP"},fd={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS","service-task":"SERVICE_TASK"},md={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},gd={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed",SERVICE_TASK:"service-task"},hd={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var Fo=(e,t,o,n,r,i)=>{let s=e._attributes.width||0,a=e._attributes.height||0,l=0,c=0;if(n&&r!==void 0&&i!==void 0){let h=n.split(`
|
|
39
|
+
`),E=h.length;l=h.reduce((y,g)=>Math.max(y,g.length),0)*7+r,c=E*20+i}let d=Math.max(Vt(Number(s),t),l),u=Math.max(Vt(Number(a),o),c);return{width:d,height:u,measured:{width:d,height:u}}},Wo=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},ay=e=>{let{mxGeometry:t}=e,o=Wo(e),n=Fo(t,de.START_EVENT.MIN_WIDTH,de.START_EVENT.MIN_HEIGHT);return w(b(b({},o),n),{type:"START_EVENT"})},ly=e=>{let{mxGeometry:t}=e,o=Wo(e),n=Fo(t,de.END_EVENT.MIN_WIDTH,de.END_EVENT.MIN_HEIGHT);return w(b(b({},o),n),{type:"END_EVENT"})},ni=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=Wo(e),a=Fo(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=pd[d];u&&(r.data.attribute=u)}let c=fd[o.style];return c&&(r.data.variant=c),w(b(b({},r),a),{type:"TASK"})},xs=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=Wo(e),i=Fo(o,de.GATEWAY.MIN_WIDTH,de.GATEWAY.MIN_HEIGHT);return r.data.variant=md[n],w(b(b({},r),i),{type:"GATEWAY"})},cy=e=>{let{mxGeometry:t}=e,o=Wo(e),i=Fo(t,de.ANNOTATION.MIN_WIDTH,de.ANNOTATION.MIN_HEIGHT,o.data.label,32,24);return w(b(b({},o),i),{type:"ANNOTATION"})},dy=e=>{let{mxGeometry:t}=e,o=Wo(e),n=Fo(t,de.LANE.MIN_WIDTH,de.LANE.MIN_HEIGHT);return w(b(b({},o),n),{type:"LANE"})},yd={task:ni,"task-script":ni,"subprocess-collapsed":ni,"service-task":ni,"start-event":ay,"end-event-terminate":ly,"gateway-parallel":xs,"gateway-exclusive":xs,"gateway-complex":xs,annotation:cy,lane:dy},uy=e=>{if(e&&Array.isArray(e))return e.map(t=>({x:Number(t._attributes.x),y:Number(t._attributes.y)}))},xd=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,source:r,target:i,value:s,style:a,sourceHandle:l,targetHandle:c,sourceOffset:d,targetOffset:u,labelOffsetX:p,labelOffsetY:f}=t,h=uy(o==null?void 0:o.Array),E=d!==void 0?Number(d):void 0,m=u!==void 0?Number(u):void 0,y=p!==void 0?Number(p):void 0,g=f!==void 0?Number(f):void 0,x=w(b(b({id:n,source:r,target:i},l?{sourceHandle:l}:{}),c?{targetHandle:c}:{}),{data:b(b(b(b({label:s||""},h&&h.length>0?{points:h}:{}),E!==void 0?{sourceOffset:E}:{}),m!==void 0?{targetOffset:m}:{}),y!==void 0&&g!==void 0?{labelOffset:{x:y,y:g}}:{})});return a.includes("association")&&a.includes('endArrow=""')?b(b({},Ho),x):b(b({},at),x)},Ed=(e,t)=>{var f,h;let{id:o,type:n,source:r,target:i,sourceHandle:s,targetHandle:a,data:l}=e,c=t==null?void 0:t.find(E=>E.id===r),d="";n==="ANNOTATION_EDGE"&&(d='association;endArrow=""');let u={_attributes:{as:"geometry",relative:"1"}};return l!=null&&l.points&&Array.isArray(l.points)&&l.points.length>0&&(u.Array=l.points.map(E=>({_attributes:{as:"mxPoint",x:E.x,y:E.y}}))),{_attributes:{id:o,parent:(c==null?void 0:c.parentId)||"1",edge:"1",style:d,source:r,target:i,value:(l==null?void 0:l.label)||"",sourceHandle:s!=null?s:void 0,targetHandle:a!=null?a:void 0,sourceOffset:(l==null?void 0:l.sourceOffset)!==void 0?String(l.sourceOffset):void 0,targetOffset:(l==null?void 0:l.targetOffset)!==void 0?String(l.targetOffset):void 0,labelOffsetX:((f=l==null?void 0:l.labelOffset)==null?void 0:f.x)!==void 0?String(l.labelOffset.x):void 0,labelOffsetY:((h=l==null?void 0:l.labelOffset)==null?void 0:h.y)!==void 0?String(l.labelOffset.y):void 0},mxGeometry:u}},Xo=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}}}},py=e=>{let{variant:t}=e.data,o=Xo(e);return w(b({},o),{_attributes:w(b({},o._attributes),{style:gd[t]||"task"})})},fy=e=>{let t=Xo(e);return w(b({},t),{_attributes:w(b({},t._attributes),{style:"start-event"})})},my=e=>{let t=Xo(e);return w(b({},t),{_attributes:w(b({},t._attributes),{style:"end-event-terminate"})})},gy=e=>{let{variant:t}=e.data,o=Xo(e);return w(b({},o),{_attributes:w(b({},o._attributes),{style:hd[t]})})},hy=e=>{let t=Xo(e);return w(b({},t),{_attributes:w(b({},t._attributes),{style:"lane"})})},yy=e=>{let t=Xo(e);return w(b({},t),{_attributes:w(b({},t._attributes),{style:"annotation"})})},_d={TASK:py,START_EVENT:fy,END_EVENT:my,GATEWAY:gy,ANNOTATION:yy,LANE:hy},bd=(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 xy=e=>{let t=Object.values(An),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=yd[s],l=a==null?void 0:a(i,n);if(!l){console.warn(`Node ${s} not supported`);continue}r.push(l)}return r},Ey=(e,t)=>{let o=e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}),n=[];for(let r of o){let i=xd(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},_y=(e,t)=>{let o=[];return e.forEach(n=>{var s,a;let r=(a=(s=_d)[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=bd(n,t);o.push(l)}}),o},by=(e,t)=>{let o=[];return e.forEach(n=>{let r=Ed(n,t);o.push(r)}),o},Ty=(e=[],t=[],o)=>{let n=_y(e,o),r=by(t,e);return{mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}}},Td=(e=[],t=[],o)=>{let n=Ty(e,t,o);return ud(JSON.stringify(n),{compact:!0,spaces:0})},vd=async e=>{var s,a,l,c,d;let t=await oi(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)||Cn),r=xy(o),i=Ey(o,r);return{lastElementId:n,edges:i,nodes:r}};import{useReactFlow as U0,useStoreApi as $0}from"@xyflow/react";import{useCallback as K0}from"react";import{Position as $t,useConnection as s0,useReactFlow as a0}from"@xyflow/react";import{useCallback as Ts}from"react";import{Handle as Nd,useReactFlow as vy}from"@xyflow/react";import{jsx as wd}from"react/jsx-runtime";var ne=i=>{var s=i,{type:e,position:t,className:o,nodeType:n}=s,r=mt(s,["type","position","className","nodeType"]);let a=n==="TASK";return wd(Nd,b({type:e,position:t,className:H("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":a,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":!a},o)},r))},Ue=a=>{var l=a,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,s=mt(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=vy(),p=(()=>{if(n!=="source")return!1;let f=c();if(t==="TASK")return f.filter(E=>E.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return f.filter(E=>E.source===e).length>=2;if(t==="START_EVENT"){let h=d();return f.filter(m=>{if(m.source!==e)return!1;let y=h.find(g=>g.id===m.target);return(y==null?void 0:y.type)!=="ANNOTATION"}).length>=1}return!1})();return wd(Nd,b({type:n,position:r,className:H("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":p,"hover:border-grey-500":!p},i),style:{pointerEvents:p?"none":"auto"}},s))};import{useRef as Cd}from"react";import{NodeResizeControl as Sd,ResizeControlVariant as wy,useReactFlow as Iy,useStoreApi as Ay}from"@xyflow/react";import{useStoreApi as Ny}from"@xyflow/react";var ri=()=>{let e=Ny();return{getInternalNodes:()=>{let{nodeLookup:o}=e.getState();return Array.from(o.values())}}};import Id from"@dagrejs/dagre";var ii=(e=[],t=[],o="LR")=>{let n=new Id.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)),Id.layout(n),{nodes:e.map(i=>{let s=n.node(i.id);return w(b({},i),{position:{x:s.x-i.width/2,y:s.y-i.height/2}})}),edges:t}},Ut=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId);if(t.length===0)return e;let o=Ca(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){Ra(s,o,r),Da(n,o);continue}$i(n,i,o)}return Sa(e,o)};var Ad=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)};import{Fragment as My,jsxs as Py}from"react/jsx-runtime";import{createElement as Md}from"react";var Cy=["top","right","bottom","left"],Sy=["top-left","top-middle","top-right","right-middle","bottom-left","left-middle","bottom-right","bottom-middle"],lt=r=>{var i=r,{nodeId:e,isVisible:t,offset:o=8}=i,n=mt(i,["nodeId","isVisible","offset"]);let{getInternalNode:s,setNodes:a}=Iy(),{getInternalNodes:l}=ri(),c=xt(),d=Ay(),u=Cd(0),p=Cd([]),f=({y,width:g,height:x})=>{cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{var F,Q;if(!e)return;let{nodeLookup:T,onNodesChange:_}=d.getState(),I=T.get(e);if(!I||I.type!=="LANE")return;let v=!I.parentId,N=v?I.id:I.parentId;if(!N)return;let S=Array.from(T.values()).filter($=>$.type==="LANE"&&$.parentId===N);if(!S.length)return;p.current.length===0&&(p.current=io(S).map($=>$.id));let M=p.current.map($=>S.find(K=>K.id===$)).filter(Boolean),L=[],k=0,O=M.findIndex($=>$.id===I.id),G=!v&&O>0&&Math.abs(y-I.position.y)>.5;for(let $=0;$<M.length;$++){let K=M[$],A=K.id===I.id,P=$===M.length-1;if(A){k=G?y+x:k+x;continue}let R=(Q=(F=K.measured)==null?void 0:F.height)!=null?Q:0,C=v?g-re.HEADER_WIDTH:g,B=R;v&&P&&(B=Math.max(re.MIN_HEIGHT,x-k)),G&&$===O-1&&(B=Math.max(re.MIN_HEIGHT,y-k)),L.push({id:K.id,type:"dimensions",dimensions:{width:C,height:B},setAttributes:!0}),L.push({id:K.id,type:"position",position:{x:re.HEADER_WIDTH,y:k}}),k+=B}v?L.push({id:N,type:"dimensions",dimensions:{width:g,height:x},setAttributes:!0}):L.push({id:N,type:"dimensions",dimensions:{width:g+re.HEADER_WIDTH,height:k},setAttributes:!0}),_==null||_(L)})},h=({y,width:g,height:x})=>{var I;if(cancelAnimationFrame(u.current),p.current=[],!e)return;let T=s(e);if(!T||T.type!=="LANE"&&!T.parentId)return;let _=[...l()];if(T.type!=="LANE"){_=_.map(v=>v.id===e?w(b({},v),{width:g,height:x,measured:{width:g,height:x}}):v),_=Ut(_),a(_);return}_=Oa(T,g,x,_,y),_=Ut(_),_=ro((I=T.parentId)!=null?I:T.id,_),a(_)};if(!(!c&&t))return null;let m={"--resize-offset":`${o}px`};return Py(My,{children:[Cy.map(y=>Md(Sd,w(b({},n),{key:y,nodeId:e,position:y,variant:wy.Line,className:"border-blue-400/90 border-dashed",style:m,onResize:(g,x)=>f(x),onResizeEnd:(g,x)=>h(x)}))),Sy.map(y=>Md(Sd,w(b({},n),{key:y,nodeId:e,position:y,className:"size-1.5 bg-blue-400 relative before:content-[''] before:absolute before:w-5 before:h-5 before:left-1/2 before:top-1/2 before:-translate-x-1/2 before:-translate-y-1/2 before:cursor-[inherit]",style:m,onResize:(g,x)=>f(x),onResizeEnd:(g,x)=>h(x)})))]})};import{NodeToolbar as qy,useReactFlow as Zy,useStore as Dd}from"@xyflow/react";import{Button as Jy,Tooltip as Qy,TooltipContent as jy,TooltipTrigger as e0,useTranslation as t0}from"@produto-lecom/lecom-ui";import o0,{useCallback as Mn,useEffect as n0,useRef as si,useState as r0}from"react";import{create as Ly}from"zustand";var Uo=Ly(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{useEffect as ky,useState as Ry}from"react";var Pd=(e,t=!1)=>{let[o,n]=Ry({width:0,height:0});return ky(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};import{Position as Sn,useReactFlow as Dy}from"@xyflow/react";import{useMemo as Oy}from"react";var Vy=120,Hy=12,Ld=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=Dy(),{instanceId:i}=J();return Oy(()=>{var f,h;if(!t)return{position:Sn.Right,align:"start"};let s=n(e);if(!s)return{position:Sn.Right,align:"start"};let a=r(),l=s.position.x*a.zoom+a.x,c=(((f=s.measured)==null?void 0:f.width)||s.width||100)*a.zoom,d=(h=document.getElementById(`modeler-${i}`))==null?void 0:h.clientWidth;if(!d)return{position:Sn.Right,align:"start"};let u=(o==null?void 0:o.width)||Vy;return{position:l+c+u+Hy>d?Sn.Left:Sn.Right}},[i,e,t,o,n,r])};import{Bot as Od}from"lucide-react";import{useNodesData as Gy,useReactFlow as By}from"@xyflow/react";import{Button as kd,DropdownMenu as zy,DropdownMenuContent as Yy,DropdownMenuGroup as Fy,DropdownMenuItem as Wy,DropdownMenuLabel as Xy,DropdownMenuTrigger as Uy,Tooltip as Es,TooltipContent as _s,TooltipTrigger as bs,useTranslation as $y}from"@produto-lecom/lecom-ui";import{WrenchIcon as Ky}from"lucide-react";import{jsx as Be,jsxs as go}from"react/jsx-runtime";var Rd=({nodeId:e})=>{let{t}=$y(),{updateNodeData:o,getEdges:n,getNode:r}=By(),i=Gy(e),a=n().filter(h=>h.source===e).some(h=>{let E=r(h.target);return(E==null?void 0:E.type)==="END_EVENT"}),l=(i==null?void 0:i.data.variant)==="SUBPROCESS",c=(i==null?void 0:i.data.variant)==="SERVICE_TASK",d=p=>{o(e,{variant:(i==null?void 0:i.data.variant)===p?"":p})},u=p=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===p?"":p})};return go(zy,{children:[go(Es,{children:[Be(bs,{asChild:!0,children:Be(Uy,{asChild:!0,children:Be(kd,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:Be(Ky,{})})})}),Be(_s,{color:"black",children:t("bpmn.task.menu.title")})]}),go(Yy,{align:"start",className:"w-60 bg-white text-grey-600",children:[go(Xy,{className:"flex items-center gap-1",children:[Be("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),Be("div",{className:"flex items-center gap-1",children:Object.entries(qn).map(([p,f])=>{let h=p==="LOOP"&&(a||l||c),m=(()=>{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 go(Es,{children:[Be(bs,{asChild:!0,children:Be(kd,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:h,className:H({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===p,"opacity-50 cursor-not-allowed":h}),onClick:h?void 0:()=>u(p),children:Be(f.icon,{className:"stroke-inherit"})})}),m&&Be(_s,{color:"black",children:m})]},p)})})]}),Be(Fy,{children:go(Es,{children:[Be(bs,{asChild:!0,children:Be("div",{className:H({"cursor-not-allowed":a}),children:go(Wy,{className:H({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":a}),disabled:a,onClick:()=>d("SCRIPT"),children:[Be(Kn.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),a&&Be(_s,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};import{jsx as Re,jsxs as Vd}from"react/jsx-runtime";var Lt={START_EVENT:{type:"START_EVENT",icon:jo,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:To,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:jo,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:Wn,label:"bpmn.annotation.variant.default"}},i0={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:No,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:wo,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:vo,label:"bpmn.gateway.variant.complex"}},$e=o0.memo(({nodeId:e,nodeType:t,nodeVariant:o,isChild:n})=>{let r=si(null),i=si(null),{t:s}=t0(),{setDraggableNode:a}=Uo(),{getEdges:l,getNodes:c,setNodes:d}=Zy(),{setIsDragging:u,mode:p,isConnecting:f,isDragging:h}=J(),E=xt(),m=Dd(Mn(z=>{var X,Z;return(Z=(X=z.nodeLookup.get(e))==null?void 0:X.selected)!=null?Z:!1},[e])),y=Dd(Mn(z=>{var X,Z;return(Z=(X=z.nodeLookup.get(e))==null?void 0:X.dragging)!=null?Z:!1},[e])),g=m&&!y&&!f&&!h&&!E,{dimensions:x}=Pd(r,g),{position:T}=Ld(e,g,x),[_,I]=r0(void 0),v=o==="SUBPROCESS",N=o==="SERVICE_TASK",S=si(null),M=si(!1),L=Mn(()=>{S.current!==null&&(clearTimeout(S.current),S.current=null),M.current=!1,u(!1),a(null),I(void 0),d(z=>z.map(X=>w(b({},X),{className:void 0})))},[u,a,d]);n0(()=>{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=Mn((z,X)=>{M.current=!0,u(!1),a({type:X.type,variant:X.variant,attribute:X.attribute,icon:X.icon}),X.icon&&I(Re(X.icon,{})),z.dataTransfer.effectAllowed="move",z.dataTransfer.setData("sourceId",e),i.current&&z.dataTransfer.setDragImage(i.current,10,10),S.current=setTimeout(()=>{S.current=null,u(!0)},100)},[e,a,u]),O=Mn(()=>{L()},[L]);if(!g)return null;let G=c(),F=l(),Q=[{component:Re(Yr,{elementId:e})}],$=()=>{if(p==="view")return[];let z=!F.some(X=>{var Z;return X.source===e&&((Z=G.find(W=>W.id===X.target))==null?void 0:Z.type)!=="ANNOTATION"});return[{component:Re(Ro,{nodeId:e,disabled:!z,tooltipMessage:z?void 0:s("editor.toolbar.start_event_limit_reached")})},Lt.TASK,Lt.ANNOTATION,...Q]},K=()=>p==="view"?[{component:Re(Ft,{elementId:e})}]:[{component:Re(Ft,{elementId:e})},...v||N?[]:[{component:Re(Rd,{nodeId:e})}],{component:Re(Ro,{nodeId:e})},Lt.TASK,{type:"TASK",variant:"SUBPROCESS",icon:tn,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:Od,label:"bpmn.task.variant.service_task"},Lt.ANNOTATION,...Object.values(i0),...fo(e,G,F)?[]:[Lt.END_EVENT],...Q],A=()=>p==="view"?[{component:Re(Ft,{elementId:e,elementType:"gateway"})}]:[{component:Re(Ft,{elementId:e,elementType:"gateway"})},{component:Re(Ro,{nodeId:e})},Lt.TASK,{type:"TASK",variant:"SUBPROCESS",icon:tn,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:Od,label:"bpmn.task.variant.service_task"},Lt.ANNOTATION,...Q],P=()=>p==="view"?[]:[Lt.ANNOTATION,...Q],R=()=>p==="view"?[]:[...n?[]:[{component:Re(Ro,{nodeId:e})}],Lt.ANNOTATION,...Q],C=()=>p==="view"?[]:[{component:Re(Ro,{nodeId:e})},...Q],B=()=>p==="view"?[]:[...Q],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 C();case"UNSUPPORTED":return B();default:return[]}})(t),V=D.length>6;if(!(D.length===0||p==="readonly"))return Vd(qy,{position:T,align:"start",className:V?"-top-[4.5rem]":"-top-8",isVisible:g,children:[Re("div",{ref:r,className:`${V?"grid grid-cols-6":"flex"} gap-1 px-2 py-2 bg-white rounded-sm shadow-md`,children:D.map((z,X)=>{if(z.component)return Re("div",{children:z.component},X);let Z={sourceNodeType:t,targetNodeType:z.type,sourceNodeId:e,nodes:G,edges:F},W=zc(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")},j=W.shouldDisable&&W.reason?U[W.reason]||s(z.label):s(z.label)||"";return Vd(Qy,{children:[Re(e0,{asChild:!0,children:Re(Jy,{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&&Re(z.icon,{size:16})})}),Re(jy,{color:"black",children:j})]},X)})}),Re("div",{ref:i,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:_})]})});$e.displayName="NodeToolbar";import{Fragment as Hd,jsx as pt,jsxs as vs}from"react/jsx-runtime";var Gd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r,setNodes:i}=a0(),{inProgress:s,fromNode:a}=s0(),{mode:l,isReadOnly:c}=J(),d=s&&(a==null?void 0:a.id)!==e,u=Ts(h=>{let x=h.split(`
|
|
40
|
+
`),T=x.reduce((N,S)=>Math.max(N,S.length),0),_=x.length,I=Math.max(Ao.MIN_WIDTH,T*7+32),v=Math.max(Ao.MIN_HEIGHT,_*20+24);i(N=>N.map(S=>S.id===e?w(b({},S),{width:I,height:v,style:w(b({},S.style),{width:I,height:v})}):S))},[e,i]),p=Ts(h=>{r(e,{label:h}),u(h)},[e,r,u]),f=Ts(h=>{u(h)},[u]);return vs("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:[pt(Ge,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:p,onInput:f,skipFirstCharValidation:!0}),pt($e,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&pt(lt,{nodeId:e,minWidth:Ao.MIN_WIDTH,minHeight:Ao.MIN_HEIGHT,isVisible:!n&&o}),!s&&vs(Hd,{children:[pt(ne,{type:"source",position:$t.Left,id:"left"}),pt(ne,{type:"source",position:$t.Right,id:"right"}),pt(ne,{type:"source",position:$t.Top,id:"top"}),pt(ne,{type:"source",position:$t.Bottom,id:"bottom"})]}),(!s||d)&&vs(Hd,{children:[pt(ne,{type:"target",position:$t.Left,id:"left",className:H({"annotation-handle":d})}),pt(ne,{type:"target",position:$t.Right,id:"right",className:H({"annotation-handle":d})}),pt(ne,{type:"target",position:$t.Top,id:"top",className:H({"annotation-handle":d})}),pt(ne,{type:"target",position:$t.Bottom,id:"bottom",className:H({"annotation-handle":d})})]})]})};import{Position as Kt,useConnection as l0,useReactFlow as c0}from"@xyflow/react";import{useState as d0}from"react";import{Fragment as Bd,jsx as je,jsxs as Ns}from"react/jsx-runtime";var zd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=c0(),{inProgress:i,fromNode:s}=l0(),{mode:a,isReadOnly:l,reconnectingEdgeId:c}=J(),[d,u]=d0(!1),p=i&&(s==null?void 0:s.id)!==e||!!c,f=m=>{r(e,{label:m})},h=()=>{u(!0)},E=()=>{u(!1)};return Ns("div",{className:"relative",onDoubleClick:h,children:[je(To,{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})}),je("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:je(Ge,{value:t.label,isEditing:d,onBlur:E,onChange:f})}),je($e,{nodeId:e,nodeType:"END_EVENT"}),a==="edit"&&je(lt,{nodeId:e,isVisible:!n&&o,minWidth:Jn.MIN_WIDTH,minHeight:Jn.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||p)&&Ns(Bd,{children:[je(ne,{type:"target",position:Kt.Left,id:"left",className:H({"event-handle":p})}),je(ne,{type:"target",position:Kt.Right,id:"right",className:H({"event-handle":p})}),je(ne,{type:"target",position:Kt.Top,id:"top",className:H({"event-handle":p})}),je(ne,{type:"target",position:Kt.Bottom,id:"bottom",className:H({"event-handle":p})})]}),!i&&Ns(Bd,{children:[je(ne,{type:"source",position:Kt.Left,id:"left"}),je(ne,{type:"source",position:Kt.Right,id:"right"}),je(ne,{type:"source",position:Kt.Top,id:"top"}),je(ne,{type:"source",position:Kt.Bottom,id:"bottom"})]})]})};import{Position as qt,useConnection as u0,useReactFlow as p0}from"@xyflow/react";import{memo as f0,useCallback as m0,useState as g0}from"react";import{Fragment as Yd,jsx as et,jsxs as ws}from"react/jsx-runtime";var Is=f0(({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let s=Xi[t.variant].icon,{updateNodeData:a}=p0(),{inProgress:l,fromNode:c}=u0(),{mode:d,isReadOnly:u,reconnectingEdgeId:p}=J(),[f,h]=g0(!1),E=l&&(c==null?void 0:c.id)!==e||!!p,m=m0(x=>{a(e,{label:x})},[e,a]),y=()=>{h(!0)},g=()=>{h(!1)};return ws("div",{className:"relative",style:{width:o!=null?o:Io.MIN_WIDTH,height:n!=null?n:Io.MIN_HEIGHT},onDoubleClick:y,children:[et(s,{className:H("w-full h-full min-w-14 min-h-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"pointer-events-none":u,"stroke-blue-500 hover:stroke-blue-600":r&&!u,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),et("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:et(Ge,{value:t.label,isEditing:f,onBlur:g,onChange:m})}),et($e,{nodeId:e,nodeType:"GATEWAY",nodeVariant:t.variant}),d==="edit"&&et(lt,{nodeId:e,isVisible:!i&&r,minWidth:Io.MIN_WIDTH,minHeight:Io.MIN_HEIGHT,offset:2,keepAspectRatio:!0}),(!l||E)&&ws(Yd,{children:[et(ne,{type:"target",position:qt.Left,id:"left",className:H({"gateway-handle":E})}),et(ne,{type:"target",position:qt.Right,id:"right",className:H({"gateway-handle":E})}),et(ne,{type:"target",position:qt.Top,id:"top",className:H({"gateway-handle":E})}),et(ne,{type:"target",position:qt.Bottom,id:"bottom",className:H({"gateway-handle":E})})]}),!l&&ws(Yd,{children:[et(Ue,{type:"source",position:qt.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),et(Ue,{type:"source",position:qt.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),et(Ue,{type:"source",position:qt.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),et(Ue,{type:"source",position:qt.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})});Is.displayName="Gateway";import{useNodesData as QP,useReactFlow as jP}from"@xyflow/react";import{Button as tL,DropdownMenu as oL,DropdownMenuContent as nL,DropdownMenuGroup as rL,DropdownMenuItem as iL,DropdownMenuLabel as sL,DropdownMenuTrigger as aL,Tooltip as lL,TooltipContent as cL,TooltipTrigger as dL,useTranslation as uL}from"@produto-lecom/lecom-ui";import{WrenchIcon as fL}from"lucide-react";import{jsx as yL,jsxs as xL}from"react/jsx-runtime";import{Position as Zt,useConnection as h0,useReactFlow as y0}from"@xyflow/react";import{useState as x0}from"react";import{Fragment as Fd,jsx as tt,jsxs as As}from"react/jsx-runtime";var Wd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=y0(),{inProgress:i,fromNode:s}=h0(),{mode:a,isReadOnly:l,reconnectingEdgeId:c}=J(),[d,u]=x0(!1),p=i&&(s==null?void 0:s.id)!==e||!!c,f=m=>{r(e,{label:m})},h=()=>{u(!0)},E=()=>{u(!1)};return As("div",{className:"relative",onDoubleClick:h,children:[tt(Un,{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})}),tt("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:tt(Ge,{value:t.label,isEditing:d,onBlur:E,onChange:f})}),tt($e,{nodeId:e,nodeType:"START_EVENT"}),a==="edit"&&tt(lt,{nodeId:e,isVisible:!n&&o,minWidth:Zn.MIN_WIDTH,minHeight:Zn.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||p)&&As(Fd,{children:[tt(ne,{type:"target",position:Zt.Left,id:"left",className:H({"event-handle":p})}),tt(ne,{type:"target",position:Zt.Right,id:"right",className:H({"event-handle":p})}),tt(ne,{type:"target",position:Zt.Top,id:"top",className:H({"event-handle":p})}),tt(ne,{type:"target",position:Zt.Bottom,id:"bottom",className:H({"event-handle":p})})]}),!i&&As(Fd,{children:[tt(Ue,{type:"source",position:Zt.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),tt(Ue,{type:"source",position:Zt.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),tt(Ue,{type:"source",position:Zt.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),tt(Ue,{type:"source",position:Zt.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};import{useTranslation as b0}from"@produto-lecom/lecom-ui";import{Position as Jt,useConnection as T0,useReactFlow as v0}from"@xyflow/react";import{memo as N0,useCallback as li}from"react";var Pn=60,ai=(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<=Pn?i:i.substring(0,Pn).trim()},$o=(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>Pn&&(n=n.substring(0,Pn).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=Pn-l.length,u=`${r.substring(0,c).trim()}${l}`;if(!o.has(u))return u;i++}return n};import{jsx as Xd,jsxs as E0}from"react/jsx-runtime";var Ud=e=>E0("svg",w(b({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[Xd("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),Xd("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as $d}from"react/jsx-runtime";var Kd=e=>$d("svg",w(b({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:$d("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"})}));import{jsx as qd,jsxs as _0}from"react/jsx-runtime";var Zd=e=>_0("svg",w(b({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[qd("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),qd("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{Fragment as ci,jsx as ve,jsxs as Ln}from"react/jsx-runtime";var w0={APROVADO:Ud,EM_ANDAMENTO:Kd,REJEITADO:Zd},Cs={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)]"},I0={APROVADO:"bg-green-50",EM_ANDAMENTO:"bg-turquoise-50",REJEITADO:"bg-red-50"},Ss=N0(({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let{t:s}=b0(),{toast:a}=De(),{updateNodeData:l,getNodes:c,setNodes:d}=v0(),{inProgress:u,fromNode:p}=T0(),{mode:f,isReadOnly:h,onSubprocessValidationClick:E,reconnectingEdgeId:m}=J(),{getTaskStatus:y}=so(),g=u&&(p==null?void 0:p.id)!==e||!!m,x=y(e),T=t.variant==="SUBPROCESS",_=t.variant==="SERVICE_TASK",I=!!t.variant&&!T&&!_||!!x,v=!!t.attribute||T||_,N=li(K=>{let C=I||v?80:40,B=K.split(`
|
|
41
|
+
`),Y=B.reduce((X,Z)=>Math.max(X,Z.length),0),D=B.length,V=Math.max(Ht.MIN_WIDTH,Y*7+64),z=Math.max(Ht.MIN_HEIGHT,D*24+C);d(X=>X.map(Z=>Z.id===e?w(b({},Z),{width:V,height:z,style:w(b({},Z.style),{width:V,height:z})}):Z))},[e,d,I,v]),S=li(K=>{let A=K.trim(),P=t.label||"";if(A===P)return;let R=A,C=c();if(!(A&&A!=="")){R=ai(C,s("bpmn.task.label.prefix")),l(e,{label:R}),N(R),a({variant:"warning",content:Ln(ci,{children:[s("bpmn.task.feedback.label_empty.prefix")," ",ve("strong",{children:R})]})});return}let Y=$o(R,C);Y===P||(l(e,{label:Y}),N(Y),Y!==R&&a({variant:"warning",content:Ln(ci,{children:[s("bpmn.task.feedback.label_already_exists.prefix")," ",ve("strong",{children:A})," ",s("bpmn.task.feedback.label_already_exists.middle")," ",ve("strong",{children:Y})]})}))},[t.label,c,e,s,l,N,a]),M=li(K=>{N(K)},[N]),L=li(()=>{a({variant:"error",content:s("bpmn.task.feedback.invalid_first_character")})},[s,a]),k=x?w0[x]:null,O=t.variant?Kn[t.variant].icon:null,G=t.attribute?qn[t.attribute].icon:null,F=()=>t.hasError?Cs.error:x?Cs[x]:h?Cs.default:"",Q=()=>{var K;return r&&(K=I0[x])!=null?K:""},$=()=>{E==null||E({id:e,type:"sub_process",label:t.label})};return Ln("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",F(),{"cursor-pointer":h,"border-blue-500 hover:border-blue-600 shadow-md":r&&!h&&!x,"border-red-500 hover:border-red-600 shadow-[0_0_5px_rgba(255,0,0,0.5)]":t.hasError}),style:{width:o!=null?o:Ht.MIN_WIDTH,height:n!=null?n:Ht.MIN_HEIGHT},children:[ve("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:ve(Ge,{value:t.label,maxLength:60,className:H(Q(),{"py-10 px-8":I||v}),onChange:S,onInput:M,onInvalidFirstCharacter:L})}),O&&ve("div",{className:H("absolute flex items-center p-1",T||_?"bottom-0 left-1/2 -translate-x-1/2":"top-0 left-0"),children:ve(O,{size:_?20:16,className:H(t.hasError?"text-red-500":"text-grey-500",T&&"cursor-pointer"),onClick:T?$:void 0})}),G&&ve("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:ve("div",{className:H("flex items-center w-16 p-1",T||_?"justify-between":"justify-center"),children:ve(G,{size:16,className:H(t.hasError?"text-red-500":"text-grey-500")})})}),k&&ve("div",{className:"absolute top-0 right-0 flex items-center p-1",children:ve(k,{})}),ve($e,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),f==="edit"&&ve(lt,{nodeId:e,isVisible:!i&&r,minWidth:Ht.MIN_WIDTH,minHeight:Ht.MIN_HEIGHT}),(!u||g)&&Ln(ci,{children:[ve(ne,{type:"target",position:Jt.Left,id:"left",className:H({"task-handle":g})}),ve(ne,{type:"target",position:Jt.Right,id:"right",className:H({"task-handle":g})}),ve(ne,{type:"target",position:Jt.Top,id:"top",className:H({"task-handle":g})}),ve(ne,{type:"target",position:Jt.Bottom,id:"bottom",className:H({"task-handle":g})})]}),!u&&Ln(ci,{children:[ve(Ue,{type:"source",position:Jt.Left,id:"left",nodeId:e,nodeType:"TASK"}),ve(Ue,{type:"source",position:Jt.Right,id:"right",nodeId:e,nodeType:"TASK"}),ve(Ue,{type:"source",position:Jt.Top,id:"top",nodeId:e,nodeType:"TASK"}),ve(Ue,{type:"source",position:Jt.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})});Ss.displayName="Task";import{Position as Jd}from"@xyflow/react";import{Fragment as A0,jsx as di,jsxs as C0}from"react/jsx-runtime";var Qd=({id:e,data:t})=>C0(A0,{children:[di("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}),di($e,{nodeId:e,nodeType:"UNSUPPORTED"}),di(ne,{type:"source",position:Jd.Right}),di(ne,{type:"target",position:Jd.Left})]});import{BaseEdge as S0,EdgeLabelRenderer as M0,getSmoothStepPath as P0,MarkerType as L0,useInternalNode as jd,useReactFlow as k0,useViewport as R0,Position as Ko}from"@xyflow/react";import{useState as D0,useMemo as O0}from"react";import{Fragment as V0,jsx as ot,jsxs as ho}from"react/jsx-runtime";var nk={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:L0.Arrow},data:{label:""}},eu=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:s,sourceHandleId:a,targetHandleId:l})=>{var B;let{zoom:c}=R0(),{updateEdgeData:d}=k0(),{mode:u,instanceId:p}=J(),f=xt(),h=u!=="edit",[E,m]=D0(!1),{reconnectingHandle:y,cursorPosition:g,hoveredNodeId:x,reconnectingSide:T,isValidReconnection:_,handleReconnectStart:I}=Jr({edgeId:e,source:t,target:o,instanceId:p,isReadOnly:h}),v=jd(t),N=jd(o),{sx:S,sy:M,tx:L,ty:k,sourcePos:O,targetPos:G}=O0(()=>{var te,me;if(!v||!N)return{sx:0,sy:0,tx:0,ty:0,sourcePos:Ko.Left,targetPos:Ko.Right};let Y=Co(v,N),D=a?i:Y.sourcePos,V=l?s:Y.targetPos,z=(ue,ae,Ee)=>{var oe,le,xe,Se,Ie,Fe;let{x:_e,y:He}=ue.internals.positionAbsolute,q=(xe=(le=(oe=ue.measured)==null?void 0:oe.width)!=null?le:ue.width)!=null?xe:0,ie=(Fe=(Ie=(Se=ue.measured)==null?void 0:Se.height)!=null?Ie:ue.height)!=null?Fe:0;switch(ae){case Ko.Top:return{x:_e+q*Ee,y:He};case Ko.Bottom:return{x:_e+q*Ee,y:He+ie};case Ko.Left:return{x:_e,y:He+ie*Ee};case Ko.Right:return{x:_e+q,y:He+ie*Ee};default:return{x:_e+q/2,y:He+ie/2}}},X=(te=n==null?void 0:n.sourceOffset)!=null?te:.5,Z=(me=n==null?void 0:n.targetOffset)!=null?me:.5,W=v?z(v,D,X).x:Y.sx,U=v?z(v,D,X).y:Y.sy,j=N?z(N,V,Z).x:Y.tx,ee=N?z(N,V,Z).y:Y.ty;return y==="source"&&g?(W=g.x,U=g.y,T&&(D=T)):y==="target"&&g&&(j=g.x,ee=g.y,T&&(V=T)),{sx:W,sy:U,tx:j,ty:ee,sourcePos:D,targetPos:V}},[v,N,a,l,i,s,y,g,T,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!v||!N)return null;let[F,Q,$]=P0({sourceX:S,sourceY:M,targetX:L,targetY:k,sourcePosition:O,targetPosition:G}),K=r||(v==null?void 0:v.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=()=>{m(!1)},C=Y=>{d(e,{label:Y.trim()})};return ho("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":K}),onDoubleClick:()=>!h&&m(!0),children:[ot("path",{d:F,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),ho("g",{className:H("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":K}),children:[ot(S0,{id:e,path:F,interactionWidth:0,markerEnd:`url(#${A})`,strokeDasharray:4,className:H("stroke-2 stroke-current transition-[stroke] duration-75 group-hover:stroke-[2.5px]",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||y&&x&&!_,"stroke-green-500":y&&x&&_,"stroke-blue-500 hover:stroke-blue-600 stroke-[3px]":K&&!(n!=null&&n.hasError)&&!y})}),ho(M0,{children:[ho("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${Q}px, ${$}px)`},children:[r&&!f&&ot(Oo,{sx:S,sy:M,tx:L,ty:k,hasLabel:!!((B=n==null?void 0:n.label)!=null&&B.trim()),children:ot(Do,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),P&&ot(Ge,{value:n==null?void 0:n.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:E,onBlur:R,onChange:C})]}),r&&!f&&!h&&ho(V0,{children:[ot("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${S}px, ${M}px)`},children:ho("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[ot("circle",{cx:6/c,cy:6/c,r:4/c,fill:y==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),ot("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:y==="source"?.6:.3,className:"pointer-events-none"}),ot("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!y||y!=="source","cursor-not-allowed":y==="source"&&x&&!_,"cursor-grabbing":y==="source"&&(!x||_)}),onMouseDown:Y=>I("source",Y.nativeEvent)})]})}),ot("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${L}px, ${k}px)`},children:ho("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[ot("circle",{cx:6/c,cy:6/c,r:4/c,fill:y==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),ot("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:y==="target"?.6:.3,className:"pointer-events-none"}),ot("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!y||y!=="target","cursor-not-allowed":y==="target"&&x&&!_,"cursor-grabbing":y==="target"&&(!x||_)}),onMouseDown:Y=>I("target",Y.nativeEvent)})]})})]})]})]})]})};import{getStraightPath as H0,Position as ui}from"@xyflow/react";import{jsx as tu,jsxs as G0}from"react/jsx-runtime";var ou=({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:ui.Left},{x:n+s,y:r+a/2,pos:ui.Right},{x:n+s/2,y:r,pos:ui.Top},{x:n+s/2,y:r+a,pos:ui.Bottom}].reduce((f,h)=>{let E=Math.hypot(e-f.x,t-f.y);return Math.hypot(e-h.x,t-h.y)<E?h:f}),[d]=H0({sourceX:c.x,sourceY:c.y,targetX:e,targetY:t});return G0("g",{className:"group",children:[tu("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d}),tu("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})};import{Position as Qt,useConnection as B0,useReactFlow as z0}from"@xyflow/react";import{orderBy as Y0}from"lodash";import{memo as F0,useMemo as nu,useState as W0}from"react";import{Fragment as Ms,jsx as Ze,jsxs as pi}from"react/jsx-runtime";var Ps=F0(({id:e,data:t,selected:o,dragging:n,parentId:r})=>{var v;let{updateNodeData:i,getNodes:s}=z0(),{mode:a,isReadOnly:l}=J(),{inProgress:c,fromNode:d}=B0(),u=c&&(d==null?void 0:d.id)!==e,[p,f]=W0(!1),h=s(),E=!r,m=!E&&((v=h.find(N=>N.id===r))==null?void 0:v.selected),y=nu(()=>Y0([...h.filter(N=>N.parentId===e&&N.type==="LANE")],"position.y","asc"),[h,e]),g=E?wa.MIN_WIDTH:re.MIN_WIDTH,x=nu(()=>{if(E&&y.length>1){let N=[...y];return N.pop(),N.reduce((M,L)=>{var k,O;return M+((O=(k=L.measured)==null?void 0:k.height)!=null?O:0)},0)+re.MIN_HEIGHT}return re.MIN_HEIGHT},[E,y]),T=N=>{i(e,{label:N})},_=()=>{f(!0)},I=()=>{f(!1)};return pi(Ms,{children:[pi("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||m)&&!l}),children:[Ze("div",{className:H("flex align-items justify-center w-10 border-r-2 border-grey-400",{"border-blue-500":(o||m)&&!l}),onDoubleClick:_,children:Ze("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:Ze(Ge,{value:t.label,className:"w-full h-full self-auto",contentClassName:H({"whitespace-nowrap":p}),isEditing:p,onBlur:I,onChange:T})})}),Ze("div",{className:"flex-1"})]}),Ze($e,{nodeId:e,nodeType:"LANE",isChild:!E}),a==="edit"&&Ze(lt,{nodeId:e,isVisible:!n&&o,minWidth:g,minHeight:x,offset:10}),!c&&pi(Ms,{children:[Ze(ne,{type:"source",position:Qt.Left,id:"left"}),Ze(ne,{type:"source",position:Qt.Right,id:"right"}),Ze(ne,{type:"source",position:Qt.Top,id:"top"}),Ze(ne,{type:"source",position:Qt.Bottom,id:"bottom"})]}),(!c||u)&&pi(Ms,{children:[Ze(ne,{type:"target",position:Qt.Left,id:"left",className:H({"annotation-handle":u})}),Ze(ne,{type:"target",position:Qt.Right,id:"right",className:H({"annotation-handle":u})}),Ze(ne,{type:"target",position:Qt.Top,id:"top",className:H({"annotation-handle":u})}),Ze(ne,{type:"target",position:Qt.Bottom,id:"bottom",className:H({"annotation-handle":u})})]})]})});Ps.displayName="Lane";var ru={START_EVENT:Wd,END_EVENT:zd,TASK:Ss,GATEWAY:Is,ANNOTATION:Gd,LANE:Ps,UNSUPPORTED:Qd},iu={SEQUENCE_EDGE:hs,MESSAGE_EDGE:eu,ANNOTATION_EDGE:Xc},su="#fafafa",au="#bebebe",lu=1,cu=10,du="bottom-left",Ls=.05,uu=5,pu=150,fu=100,mu=Ls,gu=1,hu={x:0,y:0,zoom:.75},yu=1,xu=2,X0={[yu]:4,[xu]:2},kn=[yu,xu],Eu=[0,1,2],_u={hideAttribution:!0},ks=kn.reduce((e,t)=>e|X0[t],0);var jt=()=>{let{setViewport:e}=U0(),t=$0();return{fitToNodes:K0(n=>{let{width:r,height:i}=t.getState();if(i<=0||r<=0)return;let s=La(n);if(!s)return;let a=ka({bounds:s,canvasHeight:i,canvasWidth:r,minZoom:mu,maxZoom:gu,offsetX:pu,offsetY:fu});e(a)},[t,e])}};import{useReactFlow as q0}from"@xyflow/react";var ct=()=>{let{getEdges:e,getNodes:t}=q0(),{lastElementId:o}=J(),n=()=>{let i=t(),s=e(),a=cd(i,s);return Math.max(a,o)};return{getLastId:n,getNextId:()=>n()+1}};var eo=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n}=Z0(),{getLastId:r}=ct(),{fitToNodes:i}=jt(),{setLastElementId:s}=J(),a=bu(async(c="")=>{let{nodes:d,edges:u,lastElementId:p}=await vd(c);i(d),o(d),n(u),s(p)},[o,n,s,i]),l=bu(()=>{let c=e(),d=t(),u=r();return Td(c,d,u)},[e,t,r]);return{importFromMxGraph:a,exportToMxGraph:l}};var j0=500,fi=()=>{let{isInitialized:e,onElementChanges:t}=J(),{exportToMxGraph:o}=eo(),n=Q0(()=>{if(!e)return;let s=o();t==null||t(s)},j0);J0(()=>()=>{n.isPending()&&n.flush()},[n]);let r=Tu(s=>{s.every(c=>c.type==="select")||s.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=Tu(s=>{s.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var vu=({setEdges:e,saveHistory:t})=>{let{getNode:o,getEdges:n,getNodes:r,getInternalNode:i}=tx(),{emitElementChanges:s}=fi(),a=ox(null),{getNextId:l}=ct(),c=yo(m=>{var _;let y=o(m.source),g=o(m.target);if(!y||!g)return!1;let x={sourceNodeId:y.id,targetNodeId:g.id,sourceNodeType:y.type,targetNodeType:g.type,nodes:r(),edges:n(),reconnectingEdgeId:(_=a.current)!=null?_:void 0};return ps(x).isValid},[o,n,r]),d=yo(m=>{var x,T;let y=l(),g=i(m.source);if(g){let _=i(m.target),I=_?_.internals.positionAbsolute.x+((x=_.measured.width)!=null?x:0)/2:0,v=_?_.internals.positionAbsolute.y+((T=_.measured.height)!=null?T:0)/2:0,N=ad(g,I,v),S=(_==null?void 0:_.type)==="ANNOTATION"||(g==null?void 0:g.type)==="ANNOTATION",M=S?Ho:at,L;if(!S&&_&&m.targetHandle){let G=ti(N),F=ti(m.targetHandle),{x:Q,y:$}=ys(g,N),{x:K,y:A}=ys(_,m.targetHandle),R=qr(Q,$,K,A,G,F).slice(1,-1);R.length>0&&(L=R)}let k=w(b(b({},m),M),{id:String(y),sourceHandle:N,data:b(b({},S?{}:at.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=yo((m,y)=>{a.current=y.id},[]),p=yo(()=>{a.current=null},[]),f=yo((m,y)=>{let g=o(y.source),x=o(y.target);if(!g||!x){a.current=null;return}let T={sourceNodeId:g.id,targetNodeId:x.id,sourceNodeType:g.type,targetNodeType:x.type,nodes:r(),edges:n(),reconnectingEdgeId:m.id};if(!ps(T).isValid){a.current=null;return}let I=ex(m,y,n()).map(v=>v.id===m.id?w(b({},v),{data:w(b({},v.data),{points:void 0})}):v);e(I),t("forceSave",{nodes:r(),edges:I}),a.current=null,s()},[o,r,n,e,s,t]),h=yo(m=>{a.current=m},[]),E=yo(()=>{a.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:f,onReconnectStart:u,onReconnectEnd:p,setReconnectingEdge:h,clearReconnectingEdge:E}};import{Typography as Lu,useTranslation as nx}from"@produto-lecom/lecom-ui";import{useReactFlow as rx}from"@xyflow/react";import{useCallback as qo,useRef as Rs,useState as ix}from"react";var Rn=(e=[])=>e.filter(t=>t.type==="START_EVENT"),xo=(e=[])=>e.filter(t=>t.type==="END_EVENT"),to=(e=[])=>e.filter(t=>t.type==="TASK")||[],Nu=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"});var mi=(e=[])=>e.filter(t=>t.type==="GATEWAY"),wu=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),nt=(e,t=[])=>t.filter(o=>o.source===e),Dn=(e,t=[])=>t.filter(o=>o.target===e),Iu=(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"},Au=(e,t)=>{let o=nt(e,t.edges||[]);for(let n of o){let r=(t.nodes||[]).find(i=>i.id===n.target);if(r&&r.type==="END_EVENT")return!0}return!1},Cu=e=>e?/[^\s]/.test(e.trim()):!1,ye=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:[]}},kt=(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)}},Su=(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 On=[{id:"start_event_not_found",validate:e=>{let t=Rn(e.nodes);return ye({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=xo(e.nodes);return ye({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Rn(e.nodes),o=t.length===1;if(t.length===0)return ye({isValid:!0});if(!o)return ye({isValid:!1,nodeIds:t.map(i=>i.id)});let n=nt(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(s=>s.id),...n.map(s=>s.target)];return ye({isValid:!1,nodeIds:[...new Set(i)]})}return ye({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=to(e.nodes),o=kt(t,n=>nt(n.id,e.edges).length<=2);return ye({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=to(e.nodes),o=kt(t,n=>!!n.label&&n.label.trim()!=="");return ye({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=to(e.nodes),n=kt(o,r=>!r.label||r.label.length<=60);return ye({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=to(e.nodes),o=new Map;for(let r of t){if(!r.label)continue;let i=r.label.trim();i&&(o.has(i)||o.set(i,[]),o.get(i).push(r))}let n=[];for(let[,r]of o.entries())r.length>1&&r.forEach(i=>n.push(i.id));return ye({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{var r,i,s,a;let t=mi(e.nodes),o=[],n=[];for(let l of t){let c=nt(l.id,e.edges);for(let d of c){let u=e.nodes.find(h=>h.id===d.target);if((u==null?void 0:u.type)!=="GATEWAY")continue;let p=((r=l.properties)==null?void 0:r.variant)==="EXCLUSIVE"&&((i=u==null?void 0:u.properties)==null?void 0:i.variant)==="PARALLEL",f=((s=l.properties)==null?void 0:s.variant)==="COMPLEX"&&((a=u==null?void 0:u.properties)==null?void 0:a.variant)==="PARALLEL";!p&&!f&&(o.push(l.id,u.id),n.push(d.id))}}return ye({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Rn(e.nodes),...xo(e.nodes)],o=[],n=[];for(let r of t){let i=nt(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 ye({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=xo(e.nodes),o=[],n=[];for(let r of t){let i=Dn(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=nt(a.id,e.edges);l.length>1&&(o.push(a.id),l.forEach(c=>n.push(c.id)))}}}return ye({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=wu(e.nodes),o=kt(t,r=>nt(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>nt(r,e.edges).map(i=>i.id));return ye({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=to(e.nodes),o=kt(t,n=>!n.label||Cu(n.label));return ye({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 ye({isValid:!0});let t=xo(e.nodes)[0];if(!t)return ye({isValid:!0});let o=Dn(t.id,e.edges);if(!o.length)return ye({isValid:!0});let r=to(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=kt(r,l=>!Iu(l.id,e));return ye({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=to(e.nodes),o=xo(e.nodes)[0];if(!o)return ye({isValid:!0});let n=t.filter(l=>{let c=Dn(l.id,e.edges),d=nt(l.id,e.edges),u=c.some(f=>{var h;return((h=e.nodes.find(E=>E.id===f.source))==null?void 0:h.type)==="START_EVENT"}),p=d.some(f=>{var h;return((h=e.nodes.find(E=>E.id===f.target))==null?void 0:h.type)==="END_EVENT"});return u&&p}),r=Dn(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 ye(a)}},{id:"gateway_flow_to_event",validate:e=>{let t=mi(e.nodes),o=[],n=[];for(let r of t){let i=nt(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 ye({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=mi(e.nodes),o=kt(t,n=>nt(n.id,e.edges).length>=1);return ye({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Rn(e.nodes),...xo(e.nodes)],o=[],n=[];for(let r of t){let i=nt(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 ye({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=Nu(e.nodes),o=kt(t,n=>!Au(n.id,e));return ye({isValid:o.isValid,nodeIds:o.invalidIds})}}];var Mu=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of On){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}},Pu=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}}};import{jsx as gi,jsxs as sx}from"react/jsx-runtime";var ku=()=>{let{t:e}=nx(),{toast:t}=De(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=rx(),{validateCustomDiagram:s}=J(),[a,l]=ix(!1),c=Rs(!1),d=Rs(!1),u=Rs(!1),p=qo(async g=>{let x=Su(g.nodes,g.edges),T=Mu(x),_=g.nodes.filter(({type:v,data:N})=>v==="TASK"&&((N==null?void 0:N.variant)==="SUBPROCESS"||(N==null?void 0:N.variant)==="SERVICE_TASK"));if(s&&_.length>0){let v=await Pu(s,_);T={isValid:T.isValid&&v.isValid,errors:[...T.errors,...v.errors]}}let I=T.errors.map(v=>w(b({},v),{message:e(`validation.errors.${v.id}`)}));return a||l(!0),{isValid:T.isValid,errors:I}},[a,e,s]),f=qo((g,x=!0)=>{if(x&&g){let G=g.isValid?e("validation.success.title"):e("validation.errors.title"),F=g.isValid?e("validation.success.message"):e("validation.errors.subtitle");t({variant:g.isValid?"success":"error",duration:5e3,title:G,content:sx("div",{className:"flex flex-col gap-2",children:[gi(Lu,{variant:"body-medium-400",textColor:"text-grey-950",children:F}),!g.isValid&&gi("ul",{className:"list-disc list-inside max-h-[600px] overflow-y-auto",children:g.errors.map(Q=>gi("li",{children:gi(Lu,{variant:"body-medium-400",textColor:"text-grey-950",children:Q.message})},Q.id))})]})})}if(!g)return;c.current=!0,d.current=!0,u.current=!0;let T=[],_=[];g.errors.forEach(G=>{G.nodeIds&&G.nodeIds.length>0&&G.nodeIds.forEach(F=>T.push(F)),G.edgeIds&&G.edgeIds.length>0&&G.edgeIds.forEach(F=>_.push(F))});let I=[...new Set(T)],v=r(),N=i(),S=new Set(I),M=new Set;g.errors.forEach(G=>{var $,K;let F=On.find(A=>A.id===G.id);(F==null?void 0:F.highlightRelatedEdges)!==!1&&(($=G.edgeIds)==null||$.forEach(A=>M.add(A)),(K=G.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;v.forEach(G=>{G.type==="START_EVENT"?L.add(G.id):G.type==="END_EVENT"&&k.add(G.id)}),N.forEach(G=>{L.has(G.source)&&O.add(G.target),k.has(G.target)&&O.add(G.source)}),O.forEach(G=>{var F,Q;if(S.has(G)){let $=(F=g.errors.find(A=>{var P;return(P=A.nodeIds)==null?void 0:P.includes(G)}))==null?void 0:F.id;((Q=On.find(A=>A.id===$))==null?void 0:Q.highlightRelatedEdges)!==!1&&N.forEach(A=>{A.source===G&&k.has(A.target)&&(S.add(A.target),M.add(A.id)),A.target===G&&L.has(A.source)&&(S.add(A.source),M.add(A.id))})}}),o(G=>G.map(F=>w(b({},F),{data:w(b({},F.data),{hasError:S.has(F.id)})}))),n(G=>G.map(F=>w(b({},F),{data:w(b({},F.data),{hasError:M.has(F.id)})}))),setTimeout(()=>{d.current=!1,c.current=!1},0)},[e,i,r,n,o,t]),h=qo(()=>{l(!1),u.current=!1,o(g=>g.map(x=>w(b({},x),{data:w(b({},x.data),{hasError:!1})}))),n(g=>g.map(x=>w(b({},x),{data:w(b({},x.data),{hasError:!1})})))},[n,o]),E=qo(()=>{u.current&&(d.current=!0,u.current=!1,o(g=>g.map(x=>w(b({},x),{data:w(b({},x.data),{hasError:!1})}))),n(g=>g.map(x=>w(b({},x),{data:w(b({},x.data),{hasError:!1})}))),setTimeout(()=>{d.current=!1},0))},[n,o]),m=qo(()=>d.current,[]),y=qo(()=>c.current,[]);return{validateDiagram:p,handleValidationComplete:f,clearValidation:h,dismissValidationPanel:E,isAutoValidationEnabled:a,getIsClearingValidation:m,getIsValidating:y}};import{useReactFlow as ax}from"@xyflow/react";import{useTranslation as lx}from"@produto-lecom/lecom-ui";import{useEffect as cx}from"react";var dx=15,Ru="bpmn:selection",ux=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},Du=e=>{if(!ux(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},Ou=({offset:e=dx,saveHistory:t})=>{let{t:o}=lx(),{getNodes:n,setNodes:r,getEdges:i,setEdges:s}=ax(),{getNextId:a}=ct(),{mode:l,containerRef:c}=J();cx(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let u=f=>{var _,I;if(!Du(f)||!d.contains(document.activeElement))return;let E=n(),m=i(),y=E.filter(v=>v.selected);if(!y.length)return;f.preventDefault(),f.stopPropagation();let g=m.filter(v=>y.some(N=>N.id===v.source)&&y.some(N=>N.id===v.target)),T=JSON.stringify({nodes:y,edges:g});(_=f.clipboardData)==null||_.setData(Ru,T),(I=f.clipboardData)==null||I.setData("text/plain",`BPMN Selection: ${y.length} nodes`)},p=f=>{var L,k;if(!Du(f)||!d.contains(document.activeElement))return;let E=(L=f.clipboardData)==null?void 0:L.getData(Ru);if(!E)return;f.preventDefault(),f.stopPropagation();let m;try{m=JSON.parse(E)}catch(O){return}if(!((k=m.nodes)!=null&&k.length))return;let y=new Map,g=n(),x=[],T=m.nodes.filter(O=>ko(O.type,g));if(T.length===0)return;let _=a(),I=T.map(O=>{var Q;let G=String(_++);y.set(O.id,G);let F=w(b({},O),{id:G,selected:!0,position:{x:O.position.x+e,y:O.position.y+e}});if(O.type==="TASK"){let $=(Q=O.data)==null?void 0:Q.label,K=$o($||o("bpmn.task.label.prefix"),[...g,...x]);F.data=w(b({},O.data),{label:K})}return x.push(F),F}),v=m.edges.map(O=>w(b({},O),{id:String(_++),selected:!0,source:y.get(O.source)||O.source,target:y.get(O.target)||O.target})),N=[...g.map(O=>w(b({},O),{selected:!1})),...I],M=[...i().map(O=>w(b({},O),{selected:!1})),...v];r(N),s(M),t("forceSave",{nodes:N,edges:M})};return d.addEventListener("copy",u,!0),d.addEventListener("paste",p,!0),()=>{d.removeEventListener("copy",u,!0),d.removeEventListener("paste",p,!0)}},[n,r,i,s,a,e,o,t,l,c])};import{useTranslation as px}from"@produto-lecom/lecom-ui";import{useReactFlow as fx}from"@xyflow/react";import{useRef as mx,useState as gx}from"react";var hx=50,Vu=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let{draggableNode:r,setDraggableNode:i}=Uo(),{t:s}=px(),{getInternalNode:a,getNodes:l,getEdges:c,screenToFlowPosition:d}=fx(),{getNextId:u}=ct(),{setIsDragging:p}=J(),{getInternalNodes:f}=ri(),{rebuildIndex:h,forceRebuildIndex:E}=Pr(),[m,y]=gx(null),g=mx(""),x=(A,P,R)=>{var D;if(A.parentId!==P)return null;let C=R.filter(V=>V.id!==A.id&&V.parentId===P&&V.type==="LANE").sort((V,z)=>V.position.y-z.position.y);if(C.length===0)return null;let B=(D=R.find(V=>V.id===A.id))!=null?D:A,Y=C.find(V=>B.position.y<V.position.y);return Y?{draggedLaneId:A.id,beforeLaneId:Y.id}:{draggedLaneId:A.id,afterLaneId:C[C.length-1].id}},T=(A,P=!1,R)=>{let C=P?"node-drop-target-error":"node-drop-target",B=P?"node-drop-target-lane-error":"node-drop-target-lane";t(Y=>{var X,Z,W,U;let D=(X=R==null?void 0:R(Y))!=null?X:null,V=[A!=null?A:"",P?"error":"valid",(Z=D==null?void 0:D.draggedLaneId)!=null?Z:"",(W=D==null?void 0:D.beforeLaneId)!=null?W:"",(U=D==null?void 0:D.afterLaneId)!=null?U:""].join(":"),z=j=>{let ee=[];return j.id===A&&ee.push(C),A!==void 0&&j.parentId===A&&j.type==="LANE"&&j.id!==(D==null?void 0:D.draggedLaneId)&&ee.push(B),j.id===(D==null?void 0:D.draggedLaneId)&&ee.push("lane-reorder-dragging"),j.id===(D==null?void 0:D.beforeLaneId)&&ee.push("lane-reorder-before"),j.id===(D==null?void 0:D.afterLaneId)&&ee.push("lane-reorder-after"),ee.join(" ")||void 0};return g.current===V?Y:(g.current=V,Y.map(j=>{let ee=z(j);return j.className===ee?j:w(b({},j),{className:ee})}))})},_=(A,P)=>{let R=f();if(A.type==="LANE"){if(P){T();return}let V=R.filter(Z=>Z.id!==A.id&&Z.type==="LANE"&&!Z.parentId),z=rn(A,V);if(!z){T();return}if(no({parentId:z.id,nodes:e,excludeTypes:["LANE"]})){T(z.id,!0);return}T(z.id,!1,Z=>x(A,z.id,Z));return}let B=R.filter(V=>V.id!==A.id&&V.type==="LANE"),Y=rn(A,B);if(!Y){T();return}if(no({parentId:Y.id,nodes:e,includeTypes:["LANE"]})){T();return}T(Y.id)},I=A=>{let P=a(A.id),R=A.type==="LANE"&&no({parentId:A.id,nodes:e,includeTypes:["LANE"]});_(P,R)},v=A=>(g.current="",A.map(P=>w(b({},P),{className:void 0}))),N=A=>A.some(R=>R.dragging)?A.map(R=>R.dragging?w(b({},R),{dragging:!1}):R):A,S=(A,P)=>{let R=0;for(let C of P){if(C.id===A||C.parentId||C.type==="LANE")continue;let B=it(C),Y=B.y+B.h;R=Math.max(R,Y)}return R+hx},M=(A,P)=>{if(!Ui(A,P))return P;let R=S(A,P);return P.map(C=>C.id===A?w(b({},C),{position:w(b({},C.position),{y:R})}):C)},L=A=>{if(A.preventDefault(),A.dataTransfer.dropEffect="move",!(r!=null&&r.type))return;let P=d({x:A.clientX,y:A.clientY}),R={id:"__sidebar_drag__",type:r.type,position:P,measured:{width:1,height:1},internals:{positionAbsolute:P}};_(R,!1)},k=A=>{let P=A.relatedTarget;(!P||!A.currentTarget.contains(P))&&T()},O=(A,P)=>{A.preventDefault(),I(P)},G=(A,P,R)=>{var X,Z;let C=[...R],B=P.parentId?P.parentId:P.id;if(A.parentId===P.id)return C=Ki(A,P,C),C=Ut(C),C=ro(B,C),v(C);if(A.type==="LANE"){if(no({parentId:P.id,nodes:C,excludeTypes:["LANE"]})){let te=Cr(P),me=50,ue=50;return C.map(ae=>{var Ee,_e;return ae.id===A.id?w(b({},ae),{position:{x:(Ee=m==null?void 0:m.x)!=null?Ee:te.x+me,y:(_e=m==null?void 0:m.y)!=null?_e:te.y2+ue}}):ae})}let j=C.filter(te=>te.parentId===P.id).reduce((te,me)=>{var ue,ae;return te+((ae=(ue=me.measured)==null?void 0:ue.height)!=null?ae:0)},0),ee={x:re.HEADER_WIDTH,y:j};return C=C.map(te=>te.id===A.id?w(b({},te),{parentId:P.id,position:ee,className:void 0}):w(b({},te),{className:void 0})),C=Ut(C),C=M(B,C),C}if(no({parentId:P.id,nodes:C,includeTypes:["LANE"]})){let W;if(A.parentId){let U=a(A.parentId),{x:j,y:ee}=it(U);W={x:j+((X=A.position.x)!=null?X:0),y:ee+((Z=A.position.y)!=null?Z:0)}}return C=C.map(U=>U.id===A.id?w(b({},U),{position:W!=null?W:U.position,parentId:void 0,className:void 0}):w(b({},U),{className:void 0})),C=ro(B,C),C}let V=Ma(A,P);C=C.map(W=>W.id===A.id?w(b({},W),{parentId:P.id,position:V,className:void 0}):w(b({},W),{className:void 0}));let z=C.find(W=>W.id===A.id);return C=Ki(z,P,C),C=Ut(C),C=ro(B,C),C},F=A=>{if(A.preventDefault(),!(r!=null&&r.type))return;if(!ko(r.type,l())){p(!1),i(null);return}let P=d({x:A.clientX,y:A.clientY}),R={width:de[r.type].MIN_WIDTH,height:de[r.type].MIN_HEIGHT},C=u(),B={id:String(C),type:r.type,position:P,measured:R,data:{label:r.type==="TASK"?ai(e,s("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},Y=w(b({},B),{internals:{positionAbsolute:P}}),D=w(b({},Y),{measured:{width:1,height:1}}),V=f(),z=r.type==="LANE",X=V.filter(te=>z?te.type==="LANE"&&!te.parentId:te.type==="LANE"),Z=rn(D,X),W=[...V.map(te=>w(b({},te),{selected:!1})),Y];Z&&(W=G(Y,Z,W)),W=nn(W),z&&!Z&&(W=M(Y.id,W)),W=v(W),t(W),E();let U=A.dataTransfer.getData("sourceId"),j=c(),ee=j;if(U){let te={id:String(C+1),source:U,target:B.id},me=r.type==="ANNOTATION"?b(b({},te),Ho):b(b({},te),at);ee=j.concat(me),o(ee)}n("forceSave",{nodes:W,edges:ee}),p(!1),i(null)},Q=async(A,P,R)=>{let C=[...f()],B=new Set;R.forEach(V=>{let z=a(V.id),X=V.type==="LANE",Z=C.filter(U=>U.id!==V.id&&(X?U.type==="LANE"&&!U.parentId:U.type==="LANE")),W=rn(z,Z);if(W){if(X&&no({parentId:V.id,nodes:C,includeTypes:["LANE"]})){V.parentId&&(C=K(V,C),B.add(V.id));return}C=G(z,W,C);return}V.parentId&&(C=K(V,C),V.type==="LANE"&&B.add(V.id))}),C=N(C);let Y=R.filter(V=>V.type==="LANE"&&!V.parentId).map(V=>V.id);for(let V of Y)Ui(V,C)&&m&&(C=C.map(z=>z.id===V?w(b({},z),{position:b({},m)}):z));for(let V of B)C=M(V,C);if(R.some(V=>V.type!=="LANE"&&!V.parentId)){let V=C.filter(z=>z.type==="LANE"&&!z.parentId).map(z=>z.id);for(let z of V)C=ro(z,C)}C=nn(C),C=v(C),t(C),h(C),y(null)},$=(A,P)=>{y({x:P.position.x,y:P.position.y})},K=(A,P)=>{var Z,W,U,j,ee,te,me,ue;let R=a(A.parentId);if(!R)return P;let C=A.type==="LANE",B=P.filter(ae=>ae.parentId===R.id&&ae.id!==A.id),Y=B.filter(ae=>ae.type==="LANE"),D;if(C&&Y.length===0)D=re.MIN_HEIGHT;else if(C){let ae=(W=(Z=A.measured)==null?void 0:Z.height)!=null?W:re.MIN_HEIGHT;D=((j=(U=R.measured)==null?void 0:U.height)!=null?j:re.MIN_HEIGHT)-ae,D=Math.max(re.MIN_HEIGHT,D)}else D=B.length>0?B.reduce((ae,Ee)=>{var _e,He;return ae+((He=(_e=Ee.measured)==null?void 0:_e.height)!=null?He:0)},0)+Te:Math.max(re.MIN_HEIGHT,(te=(ee=R.measured)==null?void 0:ee.height)!=null?te:0);let{x:V,y:z}=it(R),X={x:V+((me=A.position.x)!=null?me:0),y:z+((ue=A.position.y)!=null?ue:0)};return P=P.map(ae=>ae.id===A.id?w(b({},ae),{position:X,parentId:void 0}):ae.id===R.id?w(b({},ae),{height:D,measured:w(b({},ae.measured),{height:D})}):ae),P=Ut(P),P};return{onDragOver:L,onDragLeave:k,onDrop:F,onNodeDrag:O,onNodeDragStart:$,onNodeDragStop:Q}};import{useReactFlow as yx}from"@xyflow/react";import{useTranslation as xx}from"@produto-lecom/lecom-ui";import{useEffect as Ex}from"react";var _x=30,bx=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},Tx=e=>!bx(e.target),Hu=({offset:e=_x,saveHistory:t})=>{let{t:o}=xx(),{getNodes:n,setNodes:r,getEdges:i,setEdges:s}=yx(),{getNextId:a}=ct(),{mode:l,containerRef:c}=J();Ex(()=>{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"&&Tx(p)){p.preventDefault(),p.stopPropagation();let h=n(),E=i(),m=h.filter(M=>M.selected);if(!m.length)return;let y=new Map,g=[],x=m.filter(M=>ko(M.type,h));if(x.length===0)return;let T=E.filter(M=>x.some(L=>L.id===M.source)&&x.some(L=>L.id===M.target)),_=a(),I=x.map(M=>{var O;let L=String(_++);y.set(M.id,L);let k=w(b({},M),{id:L,selected:!0,position:{x:M.position.x+e,y:M.position.y+e}});if(M.type==="TASK"){let G=(O=M.data)==null?void 0:O.label,F=$o(G||o("bpmn.task.label.prefix"),[...h,...g]);k.data=w(b({},M.data),{label:F})}return g.push(k),k}),v=T.map(M=>w(b({},M),{id:String(_++),selected:!0,source:y.get(M.source)||M.source,target:y.get(M.target)||M.target})),N=[...h.map(M=>w(b({},M),{selected:!1})),...I],S=[...E.map(M=>w(b({},M),{selected:!1})),...v];r(N),s(S),t("forceSave",{nodes:N,edges:S})}};return d.addEventListener("keydown",u,!0),()=>{d.removeEventListener("keydown",u,!0)}},[n,r,i,s,a,e,o,t,l,c])};import{useEffect as vx,useRef as Gu}from"react";import{useReactFlow as Nx}from"@xyflow/react";var wx=20,Ix=50,Vn={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},Ax=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},Bu=e=>{let{getNodes:t}=Nx(),{mode:o,isMoveTool:n}=J(),r=Gu(0),i=Gu(new Map);vx(()=>{let s=a=>{if(o!=="edit"||!n||Ax(a.target)||!Object.values(Vn).includes(a.key))return;let u=t().filter(g=>g.selected);if(u.length===0){i.current.clear();return}a.preventDefault();let p=Date.now(),f=p-r.current<500;r.current=p;let h=a.shiftKey?Ix:wx,E=0,m=0;switch(a.key){case Vn.UP:m=-h;break;case Vn.DOWN:m=h;break;case Vn.LEFT:E=-h;break;case Vn.RIGHT:E=h;break}let y=u.map(g=>{let x=i.current.get(g.id);(!f||!x)&&(x={x:g.position.x,y:g.position.y});let T={x:x.x+E,y:x.y+m};return i.current.set(g.id,T),{id:g.id,dragging:!1,type:"position",position:T}});e&&e(y)};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t,e,o,n])};import{useReactFlow as Sx}from"@xyflow/react";var Yu={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY","gateway-parallel":"GATEWAY","gateway-complex":"GATEWAY"},Fu={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},zu=(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}},Cx=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=zu(i[0],o),a=zu(i[1],o);s&&a&&n.push({sourceId:s.step,targetId:a.step,label:s.edgeLabel||a.edgeLabel||""})}),{components:o,connections:n}},Wu=e=>{let{components:t,connections:o}=Cx(e);return{nodes:t,edges:o}};var Mx=7,Px=48,Lx=340,kx=(e,t)=>{let o=Px+e.length*Mx;return Math.min(Lx,Math.max(t,o))},hi=()=>{let{setNodes:e,setEdges:t}=Sx(),{fitToNodes:o}=jt(),{getNextId:n}=ct();return{importFromLia:i=>{let s=typeof i=="string"?i:i.diagramXml||"",{nodes:a,edges:l}=Wu(s),c=[],d=new Map,u=!1,p=n();for(let[g,x]of Object.entries(a)){let T=String(p++),_=Yu[x.type],I=Fu[x.type];_==="START_EVENT"&&(u=!0),d.set(g,T);let v=de[_].MIN_WIDTH,N=de[_].MIN_HEIGHT;c.push({id:T,type:_,data:{label:x.label||"",variant:I,attribute:""},position:{x:0,y:0},width:v,height:N,measured:{width:v,height:N}})}let f=[];for(let g of l){let x=w(b({},at),{id:String(p++),source:d.get(g.sourceId)||g.sourceId,target:d.get(g.targetId)||g.targetId});f.push(x)}if(!u&&c.length>0){let g=String(p++),x={id:g,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:de.START_EVENT.MIN_WIDTH,height:de.START_EVENT.MIN_HEIGHT,measured:{width:de.START_EVENT.MIN_WIDTH,height:de.START_EVENT.MIN_HEIGHT}};c.unshift(x);let T=c[1];if(T){let _=w(b({},at),{id:String(p++),source:g,target:T.id});f.unshift(_)}}let h=c.map(g=>{var x,T;return g.type==="TASK"?w(b({},g),{width:kx(String((T=(x=g.data)==null?void 0:x.label)!=null?T:""),de.TASK.MIN_WIDTH)}):g}),{nodes:E}=ii(h,f),m=new Map(E.map(g=>[g.id,g.position])),y=c.map(g=>{var x;return w(b({},g),{position:(x=m.get(g.id))!=null?x:g.position})});e(y),t(f),o(y)}}};import{useCallback as Rx,useEffect as Dx}from"react";var Ox={origin:"*",debug:!1};function yi(e,t=Ox){let{origin:o,debug:n}=t,r=Rx((i,s)=>{let a={event:i,data:s};window.parent.postMessage(a,o||"*")},[o]);return Dx(()=>{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}}import{useNodesInitialized as Hx}from"@xyflow/react";import{useEffect as Ds,useRef as Gx}from"react";var Xu=()=>{let e=Hx(),{initialDiagram:t,isNewDiagram:o,isInitialized:n,setIsInitialized:r,onElementChanges:i}=J(),{importFromMxGraph:s,exportToMxGraph:a}=eo(),{sendMessage:l}=yi(),c=Gx(!1);Ds(()=>{t&&s(t)},[t,s]),Ds(()=>{if(!n||!o||c.current)return;c.current=!0;let d=a();i==null||i(d)},[n,o,t,a,i]),Ds(()=>{if(!e)return;(async()=>{await Xn(),r(!0),l("INIT_MODELER",t)})()},[e,t,r,l])};import{useReactFlow as Bx}from"@xyflow/react";import{useCallback as Uu}from"react";function $u(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=so(),{getEdges:n}=Bx(),r=Uu(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=Uu(()=>{t()},[t]);return{handleTasksStatus:r,handleClearTaskStatus:i}}import{useReactFlow as zx}from"@xyflow/react";import{useCallback as Rt,useState as Yx,useEffect as Ku}from"react";import{useDebouncedCallback as Fx}from"use-debounce";var Wx=500,qu=100,Zu=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=zx(),{mode:i,containerRef:s}=J(),[a,l]=Yx({history:[],currentStep:0}),{history:c,currentStep:d}=a,u=d>0,p=d<c.length-1,f=Rt((v,N)=>{n(v[N].nodes),r(v[N].edges)},[n,r]),h=Rt(()=>{if(d>0){let v=d-1;l(N=>w(b({},N),{currentStep:v})),f(c,v)}},[d,c,f]),E=Rt(()=>{if(d<c.length-1){let v=d+1;l(N=>w(b({},N),{currentStep:v})),f(c,v)}},[c,d,f]),m=Rt(v=>{l(N=>{let S=N.history[N.currentStep];if(S&&JSON.stringify(S)===JSON.stringify(v))return N;let k=[...N.history.slice(0,N.currentStep+1),v],O=k.length>qu?k.slice(k.length-qu):k;return{history:O,currentStep:O.length-1}})},[]),y=Rt((v,N)=>{let S=v.map(L=>w(b({},L),{selected:!1,className:"",data:w(b({},L.data),{hasError:!1})})),M=N.map(L=>w(b({},L),{data:w(b({},L.data),{hasError:!1})}));return{nodes:nn(S),edges:M}},[]),g=Rt(()=>y(t(),o()),[t,o,y]),x=Fx(()=>{let v=g();m(v)},Wx),T=Rt((v,N)=>{if(!e)return;if(c.length===0){let M=g();l({history:[M],currentStep:0})}if(v==="forceSave"){if(N){m(y(N.nodes,N.edges));return}x();return}v.some(M=>M.type==="select")||jn(v)||x()},[e,x,c.length,g,m,y]);Ku(()=>{if(e&&c.length===0){let v=g();l({history:[v],currentStep:0})}},[e,c.length,g]);let _=Rt(v=>{l({history:v||[],currentStep:0})},[]),I=Rt(()=>{l({history:[],currentStep:0})},[]);return Ku(()=>{if(i!=="edit")return;let v=s.current;if(!v)return;let N=S=>{if(!v.contains(document.activeElement)||!(S.ctrlKey||S.metaKey))return;let k=S.key.toLowerCase();if(S.shiftKey&&k==="z"){S.preventDefault(),E();return}k==="z"&&(S.preventDefault(),h())};return v.addEventListener("keydown",N),()=>{v.removeEventListener("keydown",N)}},[h,E,i,s]),{history:c,undo:h,redo:E,canUndo:u,canRedo:p,saveHistory:T,resetHistory:_,clearHistory:I}};var Ju=()=>{let{t:e}=Xx(),[t,o,n]=$x([]),[r,i,s]=Ux([]),{getNodes:a,getNode:l}=Kx(),{toast:c}=De(),d=qx(),{instanceId:u,isInitialized:p,setIsConnecting:f,onElementClick:h}=J(),{updateHelperLines:E,HelperLines:m}=Pr(),{undo:y,redo:g,canUndo:x,canRedo:T,saveHistory:_}=Zu(p),{onNodeDrag:I,onDrop:v,onDragOver:N,onDragLeave:S,onNodeDragStop:M,onNodeDragStart:L}=Vu({nodes:t,setNodes:o,setEdges:i,saveHistory:_}),{isValidConnection:k,onConnect:O,onReconnect:G,onReconnectStart:F,onReconnectEnd:Q,setReconnectingEdge:$,clearReconnectingEdge:K}=vu({setEdges:i,saveHistory:_}),{handleValidationComplete:A,clearValidation:P,dismissValidationPanel:R,validateDiagram:C,getIsValidating:B,getIsClearingValidation:Y}=ku(),{importFromLia:D}=hi(),{handleTasksStatus:V,handleClearTaskStatus:z}=$u(),{clearPathEdges:X}=so(),{emitElementChanges:Z,handleNodeChanges:W,handleEdgeChanges:U}=fi(),j=Va();Ou({saveHistory:_}),Hu({saveHistory:_}),Xu();let ee=Dt(()=>{o([]),i([]),X(),setTimeout(j,0)},[o,i,X,j]),{selectElements:te,clearSelection:me}=ht(),{importFromMxGraph:ue,exportToMxGraph:ae}=eo(),{configureElement:Ee,getConfigureElement:_e}=Gr(),He=Dt(fe=>{fe!=null&&fe.id&&te([fe.id])},[te]),{sendMessage:q}=yi({LIA_CREATE_DIAGRAM:D,CLEAR_DIAGRAM:ee,TASKS_STATUS:V,CLEAR_TASKS_STATUS:z,EXTERNAL_TASK_SELECT:He}),ie=Dt(()=>t.length+r.length,[t,r]);Zx(()=>(_t.set(u,{importFromMxGraph:ue,exportToMxGraph:ae,selectElements:te,clearSelection:me,configureElement:Ee,getConfigureElement:_e,getElementsCount:ie,setReconnectingEdge:$,clearReconnectingEdge:K}),()=>{_t.delete(u)}),[u,ue,ae,te,me,Ee,_e,ie,$,K]);let oe=Dt((fe,ge)=>{if(ge.type!=="TASK"&&ge.type!=="GATEWAY")return;let he=_e(ge.id);he&&(h==null||h(he)),ge.type==="TASK"&&q("SELECT_TASK",{id:ge.id})},[_e,h,q]),le=Dt((fe,ge)=>{if(ge.type!=="SEQUENCE_EDGE")return;let he=l(ge.source),Ne=l(ge.target),{isFromStartEvent:be,isGatewayToGateway:Me,isActiviyToAndGateway:Ae,isToEndEvent:We}=Qn(he,Ne);if(!(!be&&!Me&&!Ae&&!We))return;let wt=_e(ge.id);wt&&(h==null||h(wt))},[_e,l,h]),xe=Dt(fe=>{E(fe,t),n(fe),!jn(fe)&&(_(fe),Y()||R(),B()||W(fe))},[t,_,Y,R,E,W,B,n]),Se=Dt(fe=>{s(fe),_(fe),Y()||R(),B()||U(fe)},[s,_,Y,R,U,B]);Bu(xe);let Ie=Dt(async({nodes:fe})=>fe.some(he=>he.type==="LANE"&&t.some(Ne=>Ne.parentId===he.id))?(c({variant:"error",title:e("validation.errors.title"),content:e("editor.toolbar.delete_pool_lane_error")}),!1):!0,[t,e,c]),Fe=()=>{_("forceSave"),Z(),R()},vt=()=>{f(!0)},Nt=()=>{f(!1),R()},ft=Dt(fe=>{let ge=new Set(fe.filter(he=>he.type==="LANE"&&!!he.parentId).map(he=>he.parentId));ge.size!==0&&setTimeout(()=>{var be,Me;let he=a(),Ne=new Map(he.map(Ae=>[Ae.id,Ae]));for(let Ae of ge){let We=io(he.filter(It=>It.type==="LANE"&&It.parentId===Ae));if(We.length===0)continue;let Ot=0;for(let It of We)Ne.set(It.id,w(b({},It),{position:{x:re.HEADER_WIDTH,y:Ot}})),Ot+=(Me=(be=It.measured)==null?void 0:be.height)!=null?Me:0;let wt=Ne.get(Ae);wt&&Ne.set(Ae,w(b({},wt),{height:Ot,measured:w(b({},wt.measured),{height:Ot})}))}o(he.map(Ae=>{var We;return(We=Ne.get(Ae.id))!=null?We:Ae}))},0)},[a,o]);return{nodes:t,setNodes:o,edges:r,setEdges:i,events:{isValidConnection:k,onConnect:O,onReconnect:G,onReconnectStart:F,onReconnectEnd:Q,onDrop:v,onDragOver:N,onDragLeave:S,onNodeDrag:I,onNodeDragStop:M,onNodeDragStart:L,onNodeClick:oe,onEdgeClick:le,onDropCapture:Fe,onConnectStart:vt,onConnectEnd:Nt,onSelectionEnd:()=>setTimeout(()=>d.setState({nodesSelectionActive:!1}),0),onNodesChange:xe,onEdgesChange:Se,onBeforeDelete:Ie,onNodesDelete:ft},ui:{handleCloseValidationPanel:P},controls:{undo:y,redo:g,canUndo:x,canRedo:T},components:{HelperLines:m},actions:{saveHistory:_,selectElements:te,clearSelection:me,exportToMxGraph:ae,validateDiagram:C,handleValidationComplete:A,setReconnectingEdge:$,clearReconnectingEdge:K}}};import{useCallback as Jx}from"react";import{useStore as Qx}from"@xyflow/react";function xi(){return Qx(Jx(e=>e.nodes.length+e.edges.length>0,[]))}import{useReactFlow as jx}from"@xyflow/react";import{useCallback as eE,useEffect as tE,useRef as oE,useState as nE}from"react";var rE=".react-flow__node, .react-flow__edge, .react-flow__node-toolbar";function Qu(e,t,o){let[n,r]=nE(!1),i=oE(null),{getViewport:s,setViewport:a}=jx(),l=eE(()=>{i.current=null,r(!1)},[]);return tE(()=>{let c=e.current;if(!c)return;let d=f=>{if(!kn.some(E=>E===f.button)||t.current||o.current||(r(!0),!(f.target instanceof Element))||!f.target.closest(rE))return;f.preventDefault(),f.stopPropagation();let h=s();i.current={pointerX:f.clientX,pointerY:f.clientY,viewportX:h.x,viewportY:h.y,zoom:h.zoom}},u=f=>{let h=i.current;if(h){if((f.buttons&ks)===0){l();return}a({x:h.viewportX+(f.clientX-h.pointerX),y:h.viewportY+(f.clientY-h.pointerY),zoom:h.zoom})}},p=f=>{(f.buttons&ks)===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}import{jsx as ju}from"react/jsx-runtime";var Ei=({id:e,className:t})=>ju("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:ju("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as _i,jsxs as iE}from"react/jsx-runtime";var ep=()=>_i("svg",{style:{position:"absolute",top:0,left:0},children:iE("defs",{children:[_i(Ei,{id:"sequence-edge-marker",className:"text-grey-500"}),_i(Ei,{id:"sequence-edge-marker-hovered",className:"text-grey-800"}),_i(Ei,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{Tooltip as db,TooltipContent as ub,TooltipTrigger as pb,useTranslation as fb}from"@produto-lecom/lecom-ui";import{useKeyPress as Cp,useReactFlow as S_}from"@xyflow/react";import{Button as Ai,Tooltip as Ci,TooltipContent as Si,TooltipTrigger as Mi,useTranslation as M_}from"@produto-lecom/lecom-ui";import{HandIcon as P_,ListCheckIcon as L_,Loader2Icon as k_,MapIcon as R_,MousePointerIcon as D_}from"lucide-react";import O_,{useCallback as Ks,useEffect as Sp,useState as V_}from"react";import{Tooltip as wE,TooltipContent as IE,TooltipTrigger as AE,useTranslation as CE}from"@produto-lecom/lecom-ui";var Hn=(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))(Hn||{});import{Button as yE,useTranslation as xE}from"@produto-lecom/lecom-ui";import{useReactFlow as EE}from"@xyflow/react";var bi=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 tp({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);Ti(i,`${o}.csv`)}var Ti=(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 op(e){return e==null?void 0:e.replaceAll("
"," ")}var SO={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},np={script:"SCRIPT",subprocess:"SUBPROCESS"},rp={"marker-loop":"LOOP"},ip={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL",inclusive:"EXCLUSIVE"};var Eo=({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}}},aE=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:Eo({cell:e,type:"START_EVENT"}),status:n,originalType:o}},lE=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:Eo({cell:e,type:"END_EVENT"}),status:n,originalType:o}},cE=(e,t)=>{let{id:o,subType:n,style:r}=e==null?void 0:e._attributes,i=np[n],s=t.get(o)||"",a=rp[s]||"",l=a==="LOOP",c="imported";return!["script","none"].includes(n)&&!l&&(c="adapted"),e.mxGeometry._attributes.width=Vt(e.mxGeometry._attributes.width||0,de.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=Vt(e.mxGeometry._attributes.height||0,de.TASK.MIN_HEIGHT),{node:Eo({cell:e,type:"TASK",variant:i,attribute:a}),status:c,originalType:r}},dE=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=ip[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:Eo({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},uE=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:Eo({cell:e,type:"LANE"}),status:"imported",originalType:t}},pE=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=Vt(e.mxGeometry._attributes.width||0,de.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=Vt(e.mxGeometry._attributes.height||0,de.ANNOTATION.MIN_HEIGHT),{node:Eo({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},sp=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:Eo({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},ap=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return w(b({},at),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},lp={TASK:cE,GATEWAY:dE,START_EVENT:aE,END_EVENT:lE,LANE:uE,ANNOTATION:pE};var fE=e=>{let t=new Map,o=Object.values(Hn),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=lp[l]||sp,{node:d,status:u,originalType:p}=c(a,r);s.push(d),i.push({originalType:p,type:d.type,variant:d.data.variant,value:op(d.data.label),status:u})}return{nodes:s,governanceIdToNodeIdMap:t,summary:i}},mE=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>ap(r,t)),gE=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=fE(t.root.mxCell),i=mE(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},hE=async e=>{let t=await bi(e),o=oi(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}},cp=async e=>{try{let t=await hE(e),{nodes:o,edges:n,summary:r}=gE(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};import{jsx as _E}from"react/jsx-runtime";var dp=()=>{let{t:e}=xE(),{toast:t}=De(),{setNodes:o,setEdges:n}=EE(),{fitToNodes:r}=jt(),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:_E(yE,{size:"small",variant:"ghost",onClick:()=>tp({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 cp(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}`)})}}}};import{Button as bE}from"@produto-lecom/lecom-ui";import{useRef as TE}from"react";import{Fragment as vE,jsx as up,jsxs as NE}from"react/jsx-runtime";var pp=a=>{var l=a,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,s=mt(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=TE(null),d=p=>{let f=p.target.files;f!=null&&f.length&&i(f),c.current&&(c.current.value="")};return NE(vE,{children:[up(bE,w(b({disabled:n,onClick:p=>{var f;(f=c.current)==null||f.click(),r==null||r(p)}},s),{children:e})),up("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};import{jsx as vi,jsxs as SE}from"react/jsx-runtime";var fp=({disabled:e=!1})=>{let{t}=CE(),{toast:o}=De(),{importFromGovernance:n}=dp(),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 SE(wE,{children:[vi(AE,{asChild:!0,children:vi(pp,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:vi(ya,{})})}),vi(IE,{color:"black",children:t(e?"adapter.governance.error.ALREADY_INITIALIZED":"editor.controls.actions.import_governance")})]})};import{jsx as ME}from"react/jsx-runtime";var Os=({shortcut:e})=>ME("span",{className:"min-h-7.5 inline-flex justify-center items-center py-0.5 px-1.5 bg-grey-100 border border-grey-300 font-mono text-gray-800 shadow-lg rounded-md text-grey-900",children:e});import{Button as YE,DropdownMenu as FE,DropdownMenuContent as WE,DropdownMenuItem as Bs,DropdownMenuTrigger as XE,Tooltip as Ni,TooltipContent as wi,TooltipTrigger as Ii,useTranslation as UE}from"@produto-lecom/lecom-ui";import{FileCodeIcon as $E,FileImageIcon as KE,FolderOutputIcon as qE,PrinterIcon as ZE}from"lucide-react";import{useState as JE}from"react";import{useTranslation as LE}from"@produto-lecom/lecom-ui";import{useReactFlow as kE}from"@xyflow/react";import{toPng as gp,toSvg as RE}from"html-to-image";import{useState as DE}from"react";import{getNodesBounds as PE}from"@xyflow/react";var mp=(e,t=0)=>{let o=PE(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 OE=3,Vs="diagram",Hs=50,VE=e=>e instanceof Element&&e.closest("[data-export-hidden]")!==null,Gs=e=>!VE(e),HE=96,GE=25.4,BE="sequence-edge-marker",hp=e=>e*GE/HE,zE=e=>{let t=document.getElementById(BE);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},yp=()=>{let{t:e}=LE(),{toast:t}=De(),{getEdges:o,getNodes:n}=kE(),{clearSelection:r}=ht(),[i,s]=DE({png:!1,html:!1,print:!1}),a=()=>{let{x:p,y:f,width:h,height:E}=mp(n(),Hs),m=Hs-p,y=Hs-f;return{width:h,height:E,style:{width:`${h}px`,height:`${E}px`,transform:`translate(${m}px, ${y}px)`,transformOrigin:"top left"}}},l=async(p,f)=>{s(h=>w(b({},h),{[f]:!0})),await r();try{let h=n(),E=o();if(h.length===0&&E.length===0){t({content:e("editor.controls.actions.export.feedback.empty"),variant:"warning"});return}let m=Ad();if(!m)throw new Error("Flow element not found");let y=a(),g=zE(m);try{return await p(m,y)}finally{g==null||g.remove()}}catch(h){console.error("Diagram export failed",h),t({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{s(h=>w(b({},h),{[f]:!1}))}};return{exportAsPng:async(p=Vs)=>{await l(async(f,h)=>{let E=await gp(f,w(b({},h),{backgroundColor:"#fcfcfc",skipFonts:!0,filter:Gs}));Ti(E,`${p}.png`)},"png")},exportAsHtml:async(p=Vs)=>{await l(async(f,h)=>{let E=await RE(f,w(b({},h),{backgroundColor:"#fcfcfc",skipFonts:!0,filter:Gs})),m=`
|
|
44
44
|
<!DOCTYPE html>
|
|
45
45
|
<html>
|
|
46
46
|
<head>
|
|
47
47
|
<meta charset="utf-8" />
|
|
48
|
-
<title>${
|
|
48
|
+
<title>${p}</title>
|
|
49
49
|
<style>
|
|
50
50
|
html, body {
|
|
51
51
|
margin: 0;
|
|
@@ -65,11 +65,11 @@ var Wp=Object.defineProperty,Xp=Object.defineProperties;var Up=Object.getOwnProp
|
|
|
65
65
|
</style>
|
|
66
66
|
</head>
|
|
67
67
|
<body>
|
|
68
|
-
<img src="${
|
|
68
|
+
<img src="${E}" alt="${p}" />
|
|
69
69
|
</body>
|
|
70
|
-
</html>`,
|
|
70
|
+
</html>`,y=new Blob([m],{type:"text/html"}),g=URL.createObjectURL(y);Ti(g,`${p}.html`),window.setTimeout(()=>URL.revokeObjectURL(g),1e4)},"html")},printDiagram:async(p=Vs)=>{await l(async(f,h)=>{var N;let E=await gp(f,w(b({},h),{backgroundColor:"#fcfcfc",pixelRatio:OE,skipFonts:!0,filter:Gs})),m=document.createElement("iframe");m.style.position="fixed",m.style.right="0",m.style.bottom="0",m.style.width="0",m.style.height="0",m.style.border="0",document.body.appendChild(m);let y=(N=m.contentWindow)==null?void 0:N.document;if(!y)throw document.body.removeChild(m),new Error("Unable to access print iframe document");let g=hp(h.width).toFixed(2),x=hp(h.height).toFixed(2),T=y.createElement("style");T.textContent=`
|
|
71
71
|
@page {
|
|
72
|
-
size: ${
|
|
72
|
+
size: ${g}mm ${x}mm;
|
|
73
73
|
margin: 0;
|
|
74
74
|
}
|
|
75
75
|
html, body {
|
|
@@ -83,11 +83,11 @@ var Wp=Object.defineProperty,Xp=Object.defineProperties;var Up=Object.getOwnProp
|
|
|
83
83
|
height: 100%;
|
|
84
84
|
object-fit: contain;
|
|
85
85
|
}
|
|
86
|
-
`,
|
|
86
|
+
`,y.head.appendChild(T),y.title=p;let _=y.createElement("img");_.alt="Diagram",y.body.appendChild(_),await new Promise((S,M)=>{let L=!1,k=O=>{L||(L=!0,O?M(O):S())};_.onload=()=>k(),_.onerror=()=>k(new Error("Failed to load print image")),_.src=E,_.complete&&_.naturalWidth>0&&k()});let I=m.contentWindow;if(!I)throw document.body.removeChild(m),new Error("Unable to access print iframe window");let v=()=>{m.parentNode&&document.body.removeChild(m)};I.addEventListener("afterprint",v,{once:!0}),window.setTimeout(v,6e4),I.focus(),I.print()},"print")},isPrintingPng:i.png,isPrintingHtml:i.html,isPrinting:i.print}};import{jsx as Oe,jsxs as Zo}from"react/jsx-runtime";function xp(){let{t:e}=UE(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:s}=yp(),[a,l]=JE(!1);return Zo(FE,{modal:!1,open:a,onOpenChange:l,children:[Oe(XE,{asChild:!0,children:Oe("div",{children:Zo(Ni,{children:[Oe(Ii,{asChild:!0,children:Oe(YE,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:Oe(qE,{})})}),!a&&Oe(wi,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),Zo(WE,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[Zo(Ni,{children:[Oe(Ii,{asChild:!0,children:Oe(Bs,{className:"p-1.5",disabled:i,onClick:()=>t(),children:Oe(KE,{})})}),Oe(wi,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),Zo(Ni,{children:[Oe(Ii,{asChild:!0,children:Oe(Bs,{className:"p-1.5",disabled:s,onClick:()=>o(),children:Oe($E,{})})}),Oe(wi,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),Zo(Ni,{children:[Oe(Ii,{asChild:!0,children:Oe(Bs,{className:"p-1.5",disabled:r,onClick:()=>n(),children:Oe(ZE,{})})}),Oe(wi,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Button as a_,DropdownMenu as l_,DropdownMenuContent as c_,DropdownMenuItem as vp,DropdownMenuTrigger as d_,Tooltip as Ys,TooltipContent as Fs,TooltipTrigger as Ws,useTranslation as u_}from"@produto-lecom/lecom-ui";import{CircleIcon as p_,ClipboardPasteIcon as f_,FileCodeIcon as m_}from"lucide-react";import{useRef as g_,useState as Np}from"react";import{useState as _p}from"react";import{Button as bp,Dialog as QE,DialogContent as jE,DialogDescription as e_,DialogFooter as t_,DialogHeader as o_,DialogTitle as n_,Textarea as r_,useTranslation as i_}from"@produto-lecom/lecom-ui";var Ep=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()};import{jsx as _o,jsxs as zs}from"react/jsx-runtime";var s_=`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>`,bp=({open:e,onOpenChange:t})=>{let{t:o}=r_(),{importFromLia:n}=hi(),[r,i]=Ep(""),[s,a]=Ep(null),l=d=>{d||(i(""),a(null)),t(d)},c=()=>{let d=xp(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 _o(JE,{open:e,onOpenChange:l,children:zs(QE,{className:"w-[90vw] max-w-4xl",children:[zs(t_,{children:[_o(o_,{children:o("editor.modals.mermaid_import.title")}),_o(jE,{children:o("editor.modals.mermaid_import.description")})]}),_o(n_,{value:r,onChange:d=>{i(d.target.value),s&&a(null)},placeholder:i_,rows:16,className:"max-h-[60vh] min-h-[360px] resize-y font-mono"}),s&&_o("p",{className:"text-sm text-red-500",children:s}),zs(e_,{children:[_o(_p,{variant:"ghost",color:"grey",onClick:()=>l(!1),children:o("editor.modals.mermaid_import.cancel")}),_o(_p,{variant:"filled",color:"blue",onClick:c,children:o("editor.modals.mermaid_import.generate")})]})]})})};import{Fragment as h_,jsx as ze,jsxs as Jo}from"react/jsx-runtime";var g_=".xml,text/xml,application/xml";function Np(){let{t:e}=d_(),{importFromMxGraph:t}=eo(),{toast:o}=De(),[n,r]=vp(!1),[i,s]=vp(!1),a=m_(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 bi(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 Jo(h_,{children:[Jo(a_,{modal:!1,open:n,onOpenChange:r,children:[ze(c_,{asChild:!0,children:ze("div",{children:Jo(Ys,{children:[ze(Ws,{asChild:!0,children:ze(s_,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:ze(p_,{})})}),!n&&ze(Fs,{color:"black",children:e("editor.controls.actions.import.title")})]})})}),Jo(l_,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[Jo(Ys,{children:[ze(Ws,{asChild:!0,children:ze(Tp,{className:"p-1.5",onClick:()=>{var c;return(c=a.current)==null?void 0:c.click()},children:ze(f_,{})})}),ze(Fs,{side:"right",color:"black",children:e("editor.controls.actions.import.xml")})]}),Jo(Ys,{children:[ze(Ws,{asChild:!0,children:ze(Tp,{className:"p-1.5",onClick:()=>s(!0),children:ze(u_,{})})}),ze(Fs,{side:"right",color:"black",children:e("editor.controls.actions.import.mermaid")})]})]})]}),ze("input",{ref:a,type:"file",className:"sr-only",accept:g_,onChange:l}),ze(bp,{open:i,onOpenChange:s})]})}import{useCallback as y_,useState as x_}from"react";import{Button as E_,DropdownMenu as __,DropdownMenuContent as b_,DropdownMenuItem as wp,DropdownMenuTrigger as T_,Tooltip as Xs,TooltipContent as Us,TooltipTrigger as $s,useTranslation as v_}from"@produto-lecom/lecom-ui";import{useReactFlow as N_}from"@xyflow/react";import{AlignHorizontalJustifyStartIcon as w_,AlignVerticalJustifyStartIcon as I_,NetworkIcon as A_}from"lucide-react";import{jsx as Je,jsxs as Gn}from"react/jsx-runtime";function Ip(){let{t:e}=v_(),{getNodes:t,getEdges:o,setNodes:n}=N_(),{fitToNodes:r}=jt(),{toast:i}=De(),[s,a]=x_(!1),l=y_(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}=ii(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 Gn(__,{modal:!1,open:s,onOpenChange:a,children:[Je(T_,{asChild:!0,children:Je("div",{children:Gn(Xs,{children:[Je($s,{asChild:!0,children:Je(E_,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:Je(A_,{})})}),!s&&Je(Us,{color:"black",children:e("editor.controls.actions.organize.title")})]})})}),Gn(b_,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[Gn(Xs,{children:[Je($s,{asChild:!0,children:Je(wp,{className:"p-1.5",onClick:()=>l("TB"),children:Je(I_,{})})}),Je(Us,{side:"right",color:"black",children:e("editor.controls.actions.organize.vertical")})]}),Gn(Xs,{children:[Je($s,{asChild:!0,children:Je(wp,{className:"p-1.5",onClick:()=>l("LR"),children:Je(w_,{})})}),Je(Us,{side:"right",color:"black",children:e("editor.controls.actions.organize.horizontal")})]})]})]})}import{Fragment as qs,jsx as we,jsxs as bt}from"react/jsx-runtime";var Zs=D_.memo(({hasContent:e,validateDiagram:t,handleValidationComplete:o})=>{let{t:n}=S_(),{clearSelection:r}=ht(),{mode:i,containerRef:s,featureFlags:a,isMinimapOpen:l,setIsMinimapOpen:c,isMoveTool:d,isHandTool:u,setIsMoveTool:p,setIsHandTool:f}=J(),{getNodes:x,getEdges:E}=C_(),g=Ap(["v","V"],{target:s==null?void 0:s.current}),h=Ap(["h","H"],{target:s==null?void 0:s.current}),m=Ks(()=>{r(),f(!0),p(!1)},[r,f,p]),y=Ks(()=>{p(!0),f(!1)},[p,f]),[v,b]=O_(!1),I=Ks(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 Cp(()=>{g&&!d&&i==="edit"&&y()},[g,y,d,i]),Cp(()=>{h&&!u&&i==="edit"&&m()},[h,m,u,i]),bt("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[i==="edit"&&bt(qs,{children:[bt(Ci,{children:[we(Mi,{asChild:!0,children:we(Ai,{size:"small",variant:"ghost",color:"grey",className:G(d&&"bg-grey-400"),iconButton:!0,onClick:y,children:we(R_,{})})}),bt(Si,{color:"black",className:"flex items-center gap-2",children:[n("editor.controls.actions.move_tool"),we(Os,{shortcut:"V"})]})]}),bt(Ci,{children:[we(Mi,{asChild:!0,children:we(Ai,{size:"small",variant:"ghost",color:"grey",className:G(u&&"bg-grey-400"),iconButton:!0,onClick:m,children:we(M_,{})})}),bt(Si,{color:"black",className:"flex items-center gap-2",children:[n("editor.controls.actions.hand_tool")," ",we(Os,{shortcut:"H"})]})]})]}),we(yp,{}),i==="edit"&&bt(qs,{children:[(a==null?void 0:a.importDiagramMermaidEnabled)&&bt(qs,{children:[we(Np,{}),we(Ip,{})]}),bt(Ci,{children:[we(Mi,{asChild:!0,children:we(Ai,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:v,onClick:I,children:v?we(L_,{className:"animate-spin"}):we(P_,{})})}),we(Si,{color:"black",children:n(v?"editor.controls.actions.check_loading":"editor.controls.actions.check")})]}),we(pp,{disabled:e})]}),bt(Ci,{children:[we(Mi,{asChild:!0,children:we(Ai,{size:"small",variant:"ghost",color:"grey",className:G(l&&"bg-grey-400"),iconButton:!0,onClick:()=>c(!l),children:we(k_,{})})}),we(Si,{color:"black",children:n(l?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})});Zs.displayName="ActionsControl";import V_ from"react";import{Button as Sp,Tooltip as Mp,TooltipContent as Pp,TooltipTrigger as Lp,useTranslation as H_}from"@produto-lecom/lecom-ui";import{RedoIcon as G_,UndoIcon as B_}from"lucide-react";import{jsx as oo,jsxs as Js}from"react/jsx-runtime";var Qs=V_.memo(({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=H_();return Js("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Js(Mp,{children:[oo(Lp,{asChild:!0,children:oo(Sp,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:oo(B_,{})})}),oo(Pp,{color:"black",children:r("editor.controls.history.undo")})]}),Js(Mp,{children:[oo(Lp,{asChild:!0,children:oo(Sp,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:oo(G_,{})})}),oo(Pp,{color:"black",children:r("editor.controls.history.redo")})]})]})});Qs.displayName="HistoryControl";import{useReactFlow as z_}from"@xyflow/react";import{Button as Pi,Tooltip as Li,TooltipContent as ki,TooltipTrigger as Ri,useTranslation as Y_}from"@produto-lecom/lecom-ui";import{ScanIcon as F_,ZoomIn as W_,ZoomOut as X_}from"lucide-react";import{jsx as Ye,jsxs as Bn}from"react/jsx-runtime";var kp=()=>{let{t:e}=Y_(),t=!xi(),{zoomIn:o,zoomOut:n,zoomTo:r,fitView:i}=z_();return Bn("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Bn(Li,{children:[Ye(Ri,{asChild:!0,children:Ye(Pi,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>i(),children:Ye(F_,{})})}),Ye(ki,{color:"black",children:e("editor.controls.zoom.fit")})]}),Bn(Li,{children:[Ye(Ri,{asChild:!0,children:Ye(Pi,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>n(),children:Ye(X_,{})})}),Ye(ki,{color:"black",children:e("editor.controls.zoom.out")})]}),Bn(Li,{children:[Ye(Ri,{asChild:!0,children:Ye(Pi,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>r(1),children:Ye(_a,{})})}),Ye(ki,{color:"black",children:e("editor.controls.zoom.reset")})]}),Bn(Li,{children:[Ye(Ri,{asChild:!0,children:Ye(Pi,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>o(),children:Ye(W_,{})})}),Ye(ki,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{ViewportPortal as U_}from"@xyflow/react";import{jsx as js,jsxs as Rp}from"react/jsx-runtime";var Dp=()=>Rp(U_,{children:[Rp("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:[js("line",{x1:"0",y1:"10",x2:"20",y2:"10",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"}),js("line",{x1:"10",y1:"0",x2:"10",y2:"20",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"})]}),js("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"})]});import{useStore as $_}from"@xyflow/react";import{Button as K_,Tooltip as q_,TooltipContent as Z_,TooltipTrigger as J_,useTranslation as Q_}from"@produto-lecom/lecom-ui";import{useRef as j_,useState as eb}from"react";import{Bot as tb}from"lucide-react";import{jsx as bo,jsxs as Op}from"react/jsx-runtime";var Vp=()=>{let e=j_(null),{t}=Q_(),{setDraggableNode:o}=Uo(),n=$_(c=>c.nodes.some(d=>d.type==="START_EVENT")),{setIsDragging:r}=J(),[i,s]=eb(void 0),a=[{type:"START_EVENT",icon:Un,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:To,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:jo,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:tn,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SERVICE_TASK",icon:tb,label:t("bpmn.task.variant.service_task")},{type:"TASK",variant:"SCRIPT",icon:Na,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:va,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:No,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:wo,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:vo,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:Ea,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:Wn,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),s(bo(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return Op("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[bo("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 Op(q_,{children:[bo(J_,{asChild:!0,children:bo(K_,{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:bo(c.icon,{})},d)}),bo(Z_,{color:"black",side:"right",children:p})]},d)})}),bo("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{jsx as dt,jsxs as Di}from"react/jsx-runtime";var ea=e=>e.preventDefault(),ta=ab((e,t)=>{let{instanceId:o,containerRef:n,mode:r,isMinimapOpen:i,isMoveTool:s,isHandTool:a}=J(),l=sb("Space",{target:n==null?void 0:n.current}),c=Hp(a),d=Hp(l),{nodes:u,edges:p,actions:f,events:x,components:E,controls:g}=Zu(),{t:h}=pb(),m=xi();c.current=a,d.current=l;let y=Ju(n,c,d);lb(t,()=>({selectElements:f.selectElements,clearSelection:f.clearSelection}));let v=a||l||r!=="edit",b=v?Eu:kn,I=a||l||y,T=s&&!l&&!y,N=r==="edit"&&T,C=!v&&!y,M=r==="view"||T;return Di("div",{ref:n,className:"w-full h-full outline-none",tabIndex:0,children:[r==="edit"&&dt(Vp,{}),dt(ju,{}),Di(rb,w(_({},x),{id:`modeler-${o}`,className:G(r.toLowerCase(),{"is-hand-tool":I,"is-pan-tool-active":I}),edges:p,nodes:u,nodeTypes:ru,edgeTypes:iu,onlyRenderVisibleElements:!0,minZoom:Ls,maxZoom:uu,panOnDrag:b,panOnScroll:!0,selectionOnDrag:C,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:M,nodesConnectable:N,nodesDraggable:N,connectionLineComponent:ou,selectionMode:ib.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:N?"Delete":null,selectionKeyCode:null,defaultViewport:hu,connectOnClick:!1,connectionRadius:50,onPaneContextMenu:ea,onNodeContextMenu:ea,onEdgeContextMenu:ea,proOptions:_u,children:[dt(ob,{gap:cu,size:lu,color:au,bgColor:su}),dt(Dp,{}),i&&Di(cb,{children:[dt(ub,{asChild:!0,children:dt("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:dt(nb,{pannable:!0,zoomable:!0,position:du,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),dt(db,{color:"black",children:h("editor.controls.actions.minimap.label")})]}),Di("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&dt(Qs,_({},g)),r!=="readonly"&&dt(Zs,{hasContent:m,validateDiagram:f.validateDiagram,handleValidationComplete:f.handleValidationComplete}),dt(kp,{})]}),dt(E.HelperLines,{})]}))]})});ta.displayName="Editor";import{useStore as fb}from"@xyflow/react";import{useEffect as mb,useRef as Gp}from"react";import{jsx as hb}from"react/jsx-runtime";var gb=e=>({width:e.width,height:e.height,transform:e.transform}),oa="rgba(51, 103, 217, 0.4)",kc=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=fb(gb),i=Gp(null),s=Gp(1);return mb(()=>{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=oa,t&&(l.beginPath(),l.strokeStyle=t.color||oa,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||oa,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]),hb("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as yb,Notification as xb,TooltipProvider as Eb}from"@produto-lecom/lecom-ui";import{createContext as _b,useContext as bb,useEffect as Tb,useState as vb}from"react";import{jsx as Bp,jsxs as wb}from"react/jsx-runtime";var _t=new Map,zp=_b(null),Nn=()=>{let e=bb(zp);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},Nb=({locale:e,defaultMode:t="view",featureFlags:o,toast:n,children:r})=>{let[i,s]=vb(e||"pt_BR");Tb(()=>{e&&(s(e),yb.changeLanguage(e))},[e]);let a=E=>{let g=_t.size;if(g===0)throw new Error("No modeler instances found");if(g===1||!E){let[m]=_t.values();return m}let h=_t.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 Bp(zp.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:wb(Eb,{children:[!n&&Bp(xb,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),r]})})};import{jsx as na}from"react/jsx-runtime";var Fp=Cb(null),J=()=>{let e=Sb(Fp);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},kb=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,edgeHighlight:r=!0,validateCustomDiagram:i,onElementChanges:s,onConfigureElement:a,onElementClick:l,onSubprocessValidationClick:c})=>{let d=Lb(null),{t:u}=Ib(),{defaultMode:p,featureFlags:f}=Nn(),x=Pb(),[E]=Tt(o||x),[g,h]=Tt(n||p||"edit"),[m,y]=Tt(Cn),[v,b]=Tt(!1),[I,T]=Tt(!0),[N,C]=Tt(!1),[M,L]=Tt(!1),[k,O]=Tt(!1),[V,F]=Tt(!1),[j,$]=Tt(null);Mb(()=>{n&&h(n)},[n]);let K=!t,A=Yp(()=>t||ld(u),[t,u]),P=Yp(()=>({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 na(Ab,{children:na(Fp.Provider,{value:P,children:na(ta,{ref:e})})})};export{Ce as EditorMode,Vi as ElementPosition,Yn as ElementType,Hi as GatewayElementVariant,rt as GatewayVariant,kb as Modeler,Nb as ModelerProvider,gt as NodeAttribute,se as NodeType,Qe as NodeVariant,Gi as RoutingVariant,Nn as useModeler};
|
|
93
|
+
E --> F<end>`,Tp=({open:e,onOpenChange:t})=>{let{t:o}=i_(),{importFromLia:n}=hi(),[r,i]=_p(""),[s,a]=_p(null),l=d=>{d||(i(""),a(null)),t(d)},c=()=>{let d=Ep(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 _o(QE,{open:e,onOpenChange:l,children:zs(jE,{className:"w-[90vw] max-w-4xl",children:[zs(o_,{children:[_o(n_,{children:o("editor.modals.mermaid_import.title")}),_o(e_,{children:o("editor.modals.mermaid_import.description")})]}),_o(r_,{value:r,onChange:d=>{i(d.target.value),s&&a(null)},placeholder:s_,rows:16,className:"max-h-[60vh] min-h-[360px] resize-y font-mono"}),s&&_o("p",{className:"text-sm text-red-500",children:s}),zs(t_,{children:[_o(bp,{variant:"ghost",color:"grey",onClick:()=>l(!1),children:o("editor.modals.mermaid_import.cancel")}),_o(bp,{variant:"filled",color:"blue",onClick:c,children:o("editor.modals.mermaid_import.generate")})]})]})})};import{Fragment as y_,jsx as ze,jsxs as Jo}from"react/jsx-runtime";var h_=".xml,text/xml,application/xml";function wp(){let{t:e}=u_(),{importFromMxGraph:t}=eo(),{toast:o}=De(),[n,r]=Np(!1),[i,s]=Np(!1),a=g_(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 bi(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 Jo(y_,{children:[Jo(l_,{modal:!1,open:n,onOpenChange:r,children:[ze(d_,{asChild:!0,children:ze("div",{children:Jo(Ys,{children:[ze(Ws,{asChild:!0,children:ze(a_,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:ze(f_,{})})}),!n&&ze(Fs,{color:"black",children:e("editor.controls.actions.import.title")})]})})}),Jo(c_,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[Jo(Ys,{children:[ze(Ws,{asChild:!0,children:ze(vp,{className:"p-1.5",onClick:()=>{var c;return(c=a.current)==null?void 0:c.click()},children:ze(m_,{})})}),ze(Fs,{side:"right",color:"black",children:e("editor.controls.actions.import.xml")})]}),Jo(Ys,{children:[ze(Ws,{asChild:!0,children:ze(vp,{className:"p-1.5",onClick:()=>s(!0),children:ze(p_,{})})}),ze(Fs,{side:"right",color:"black",children:e("editor.controls.actions.import.mermaid")})]})]})]}),ze("input",{ref:a,type:"file",className:"sr-only",accept:h_,onChange:l}),ze(Tp,{open:i,onOpenChange:s})]})}import{useCallback as x_,useState as E_}from"react";import{Button as __,DropdownMenu as b_,DropdownMenuContent as T_,DropdownMenuItem as Ip,DropdownMenuTrigger as v_,Tooltip as Xs,TooltipContent as Us,TooltipTrigger as $s,useTranslation as N_}from"@produto-lecom/lecom-ui";import{useReactFlow as w_}from"@xyflow/react";import{AlignHorizontalJustifyStartIcon as I_,AlignVerticalJustifyStartIcon as A_,NetworkIcon as C_}from"lucide-react";import{jsx as Je,jsxs as Gn}from"react/jsx-runtime";function Ap(){let{t:e}=N_(),{getNodes:t,getEdges:o,setNodes:n}=w_(),{fitToNodes:r}=jt(),{toast:i}=De(),[s,a]=E_(!1),l=x_(c=>{let d=t();if(d.length===0)return;if(d.some(m=>m.parentId)){i({content:e("editor.controls.actions.organize.feedback.pool_lane"),variant:"warning"});return}let p=d.map(m=>{var y,g,x,T;return w(b({},m),{width:(g=m.width)!=null?g:(y=m.measured)==null?void 0:y.width,height:(T=m.height)!=null?T:(x=m.measured)==null?void 0:x.height})}),{nodes:f}=ii(p,o(),c),h=new Map(f.map(m=>[m.id,m.position])),E=d.map(m=>{var y;return w(b({},m),{position:(y=h.get(m.id))!=null?y:m.position})});n(E),r(E)},[t,o,n,r,i,e]);return Gn(b_,{modal:!1,open:s,onOpenChange:a,children:[Je(v_,{asChild:!0,children:Je("div",{children:Gn(Xs,{children:[Je($s,{asChild:!0,children:Je(__,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:Je(C_,{})})}),!s&&Je(Us,{color:"black",children:e("editor.controls.actions.organize.title")})]})})}),Gn(T_,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[Gn(Xs,{children:[Je($s,{asChild:!0,children:Je(Ip,{className:"p-1.5",onClick:()=>l("TB"),children:Je(A_,{})})}),Je(Us,{side:"right",color:"black",children:e("editor.controls.actions.organize.vertical")})]}),Gn(Xs,{children:[Je($s,{asChild:!0,children:Je(Ip,{className:"p-1.5",onClick:()=>l("LR"),children:Je(I_,{})})}),Je(Us,{side:"right",color:"black",children:e("editor.controls.actions.organize.horizontal")})]})]})]})}import{Fragment as qs,jsx as we,jsxs as bt}from"react/jsx-runtime";var Zs=O_.memo(({hasContent:e,validateDiagram:t,handleValidationComplete:o})=>{let{t:n}=M_(),{clearSelection:r}=ht(),{mode:i,containerRef:s,featureFlags:a,isMinimapOpen:l,setIsMinimapOpen:c,isMoveTool:d,isHandTool:u,setIsMoveTool:p,setIsHandTool:f}=J(),{getNodes:h,getEdges:E}=S_(),m=Cp(["v","V"],{target:s==null?void 0:s.current}),y=Cp(["h","H"],{target:s==null?void 0:s.current}),g=Ks(()=>{r(),f(!0),p(!1)},[r,f,p]),x=Ks(()=>{p(!0),f(!1)},[p,f]),[T,_]=V_(!1),I=Ks(async()=>{_(!0);try{let v=h(),N=E(),S=await t({nodes:v,edges:N});o(S)}finally{_(!1)}},[h,E,t,o]);return Sp(()=>{m&&!d&&i==="edit"&&x()},[m,x,d,i]),Sp(()=>{y&&!u&&i==="edit"&&g()},[y,g,u,i]),bt("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[i==="edit"&&bt(qs,{children:[bt(Ci,{children:[we(Mi,{asChild:!0,children:we(Ai,{size:"small",variant:"ghost",color:"grey",className:H(d&&"bg-grey-400"),iconButton:!0,onClick:x,children:we(D_,{})})}),bt(Si,{color:"black",className:"flex items-center gap-2",children:[n("editor.controls.actions.move_tool"),we(Os,{shortcut:"V"})]})]}),bt(Ci,{children:[we(Mi,{asChild:!0,children:we(Ai,{size:"small",variant:"ghost",color:"grey",className:H(u&&"bg-grey-400"),iconButton:!0,onClick:g,children:we(P_,{})})}),bt(Si,{color:"black",className:"flex items-center gap-2",children:[n("editor.controls.actions.hand_tool")," ",we(Os,{shortcut:"H"})]})]})]}),we(xp,{}),i==="edit"&&bt(qs,{children:[(a==null?void 0:a.importDiagramMermaidEnabled)&&bt(qs,{children:[we(wp,{}),we(Ap,{})]}),bt(Ci,{children:[we(Mi,{asChild:!0,children:we(Ai,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:T,onClick:I,children:T?we(k_,{className:"animate-spin"}):we(L_,{})})}),we(Si,{color:"black",children:n(T?"editor.controls.actions.check_loading":"editor.controls.actions.check")})]}),we(fp,{disabled:e})]}),bt(Ci,{children:[we(Mi,{asChild:!0,children:we(Ai,{size:"small",variant:"ghost",color:"grey",className:H(l&&"bg-grey-400"),iconButton:!0,onClick:()=>c(!l),children:we(R_,{})})}),we(Si,{color:"black",children:n(l?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})});Zs.displayName="ActionsControl";import H_ from"react";import{Button as Mp,Tooltip as Pp,TooltipContent as Lp,TooltipTrigger as kp,useTranslation as G_}from"@produto-lecom/lecom-ui";import{RedoIcon as B_,UndoIcon as z_}from"lucide-react";import{jsx as oo,jsxs as Js}from"react/jsx-runtime";var Qs=H_.memo(({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=G_();return Js("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Js(Pp,{children:[oo(kp,{asChild:!0,children:oo(Mp,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:oo(z_,{})})}),oo(Lp,{color:"black",children:r("editor.controls.history.undo")})]}),Js(Pp,{children:[oo(kp,{asChild:!0,children:oo(Mp,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:oo(B_,{})})}),oo(Lp,{color:"black",children:r("editor.controls.history.redo")})]})]})});Qs.displayName="HistoryControl";import{useReactFlow as Y_}from"@xyflow/react";import{Button as Pi,Tooltip as Li,TooltipContent as ki,TooltipTrigger as Ri,useTranslation as F_}from"@produto-lecom/lecom-ui";import{ScanIcon as W_,ZoomIn as X_,ZoomOut as U_}from"lucide-react";import{jsx as Ye,jsxs as Bn}from"react/jsx-runtime";var Rp=()=>{let{t:e}=F_(),t=!xi(),{zoomIn:o,zoomOut:n,zoomTo:r,fitView:i}=Y_();return Bn("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Bn(Li,{children:[Ye(Ri,{asChild:!0,children:Ye(Pi,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>i(),children:Ye(W_,{})})}),Ye(ki,{color:"black",children:e("editor.controls.zoom.fit")})]}),Bn(Li,{children:[Ye(Ri,{asChild:!0,children:Ye(Pi,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>n(),children:Ye(U_,{})})}),Ye(ki,{color:"black",children:e("editor.controls.zoom.out")})]}),Bn(Li,{children:[Ye(Ri,{asChild:!0,children:Ye(Pi,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>r(1),children:Ye(_a,{})})}),Ye(ki,{color:"black",children:e("editor.controls.zoom.reset")})]}),Bn(Li,{children:[Ye(Ri,{asChild:!0,children:Ye(Pi,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>o(),children:Ye(X_,{})})}),Ye(ki,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{ViewportPortal as $_}from"@xyflow/react";import{jsx as js,jsxs as Dp}from"react/jsx-runtime";var Op=()=>Dp($_,{children:[Dp("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:[js("line",{x1:"0",y1:"10",x2:"20",y2:"10",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"}),js("line",{x1:"10",y1:"0",x2:"10",y2:"20",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"})]}),js("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"})]});import{useStore as K_}from"@xyflow/react";import{Button as q_,Tooltip as Z_,TooltipContent as J_,TooltipTrigger as Q_,useTranslation as j_}from"@produto-lecom/lecom-ui";import{useRef as eb,useState as tb}from"react";import{Bot as ob}from"lucide-react";import{jsx as bo,jsxs as Vp}from"react/jsx-runtime";var Hp=()=>{let e=eb(null),{t}=j_(),{setDraggableNode:o}=Uo(),n=K_(c=>c.nodes.some(d=>d.type==="START_EVENT")),{setIsDragging:r}=J(),[i,s]=tb(void 0),a=[{type:"START_EVENT",icon:Un,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:To,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:jo,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:tn,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SERVICE_TASK",icon:ob,label:t("bpmn.task.variant.service_task")},{type:"TASK",variant:"SCRIPT",icon:Na,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:va,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:No,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:wo,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:vo,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:Ea,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:Wn,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),s(bo(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return Vp("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[bo("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 Vp(Z_,{children:[bo(Q_,{asChild:!0,children:bo(q_,{className:H("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":u}),size:"small",variant:"ghost",color:"grey",draggable:!u,disabled:u,iconButton:!0,onDragStart:u?void 0:f=>l(f,c),children:bo(c.icon,{})},d)}),bo(J_,{color:"black",side:"right",children:p})]},d)})}),bo("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{jsx as dt,jsxs as Di}from"react/jsx-runtime";var ea=e=>e.preventDefault(),ta=lb((e,t)=>{let{instanceId:o,containerRef:n,mode:r,isMinimapOpen:i,isMoveTool:s,isHandTool:a}=J(),l=ab("Space",{target:n==null?void 0:n.current}),c=Gp(a),d=Gp(l),{nodes:u,edges:p,actions:f,events:h,components:E,controls:m}=Ju(),{t:y}=fb(),g=xi();c.current=a,d.current=l;let x=Qu(n,c,d);cb(t,()=>({selectElements:f.selectElements,clearSelection:f.clearSelection}));let T=a||l||r!=="edit",_=T?Eu:kn,I=a||l||x,v=s&&!l&&!x,N=r==="edit"&&v,S=!T&&!x,M=r==="view"||v;return Di("div",{ref:n,className:"w-full h-full outline-none",tabIndex:0,children:[r==="edit"&&dt(Hp,{}),dt(ep,{}),Di(ib,w(b({},h),{id:`modeler-${o}`,className:H(r.toLowerCase(),{"is-hand-tool":I,"is-pan-tool-active":I}),edges:p,nodes:u,nodeTypes:ru,edgeTypes:iu,onlyRenderVisibleElements:!0,minZoom:Ls,maxZoom:uu,panOnDrag:_,panOnScroll:!0,selectionOnDrag:S,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:M,nodesConnectable:N,nodesDraggable:N,connectionLineComponent:ou,selectionMode:sb.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:N?"Delete":null,selectionKeyCode:null,defaultViewport:hu,connectOnClick:!1,connectionRadius:50,onPaneContextMenu:ea,onNodeContextMenu:ea,onEdgeContextMenu:ea,proOptions:_u,children:[dt(nb,{gap:cu,size:lu,color:au,bgColor:su}),dt(Op,{}),i&&Di(db,{children:[dt(pb,{asChild:!0,children:dt("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:dt(rb,{pannable:!0,zoomable:!0,position:du,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),dt(ub,{color:"black",children:y("editor.controls.actions.minimap.label")})]}),Di("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&dt(Qs,b({},m)),r!=="readonly"&&dt(Zs,{hasContent:g,validateDiagram:f.validateDiagram,handleValidationComplete:f.handleValidationComplete}),dt(Rp,{})]}),dt(E.HelperLines,{})]}))]})});ta.displayName="Editor";import{useStore as mb}from"@xyflow/react";import{useEffect as gb,useRef as Bp}from"react";import{jsx as yb}from"react/jsx-runtime";var hb=e=>({width:e.width,height:e.height,transform:e.transform}),oa="rgba(51, 103, 217, 0.4)",kc=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=mb(hb),i=Bp(null),s=Bp(1);return gb(()=>{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=oa,t&&(l.beginPath(),l.strokeStyle=t.color||oa,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||oa,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]),yb("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as xb,Notification as Eb,TooltipProvider as _b}from"@produto-lecom/lecom-ui";import{createContext as bb,useContext as Tb,useEffect as vb,useState as Nb}from"react";import{jsx as zp,jsxs as Ib}from"react/jsx-runtime";var _t=new Map,Yp=bb(null),Nn=()=>{let e=Tb(Yp);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},wb=({locale:e,defaultMode:t="view",featureFlags:o,toast:n,children:r})=>{let[i,s]=Nb(e||"pt_BR");vb(()=>{e&&(s(e),xb.changeLanguage(e))},[e]);let a=E=>{let m=_t.size;if(m===0)throw new Error("No modeler instances found");if(m===1||!E){let[g]=_t.values();return g}let y=_t.get(E);if(!y)throw new Error(`Modeler instance with ID "${E}" not found`);return y},l=(E,m)=>{let y=a(m);return y==null?void 0:y.selectElements(E)},c=async E=>{let m=a(E);return m==null?void 0:m.clearSelection()},d=(E,m)=>{let y=a(m);return y==null?void 0:y.configureElement(E)},u=(E,m)=>{let y=a(m);return y==null?void 0:y.getConfigureElement(E)},p=async(E,m)=>{let y=a(m);await(y==null?void 0:y.importFromMxGraph(E))},f=E=>{let m=a(E);return m==null?void 0:m.exportToMxGraph()},h=E=>{let m=a(E);return(m==null?void 0:m.getElementsCount())||0};return zp(Yp.Provider,{value:{defaultMode:t,locale:i,featureFlags:o,selectElements:l,clearSelection:c,configureElement:d,getConfigureElement:u,importDiagram:p,exportDiagram:f,getElementsCount:h,toast:n},children:Ib(_b,{children:[!n&&zp(Eb,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),r]})})};import{jsx as na}from"react/jsx-runtime";var Wp=Sb(null),J=()=>{let e=Mb(Wp);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},Rb=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,edgeHighlight:r=!0,validateCustomDiagram:i,onElementChanges:s,onConfigureElement:a,onElementClick:l,onSubprocessValidationClick:c})=>{let d=kb(null),{t:u}=Ab(),{defaultMode:p,featureFlags:f}=Nn(),h=Lb(),[E]=Tt(o||h),[m,y]=Tt(n||p||"edit"),[g,x]=Tt(Cn),[T,_]=Tt(!1),[I,v]=Tt(!0),[N,S]=Tt(!1),[M,L]=Tt(!1),[k,O]=Tt(!1),[G,F]=Tt(!1),[Q,$]=Tt(null);Pb(()=>{n&&y(n)},[n]);let K=!t,A=Fp(()=>t||ld(u),[t,u]),P=Fp(()=>({instanceId:E,containerRef:d,initialDiagram:A,mode:m,featureFlags:f,edgeHighlight:r,isEdit:m==="edit",isView:m==="view",isReadOnly:m==="readonly",isNewDiagram:K,lastElementId:g,isInitialized:T,isMinimapOpen:M,isMoveTool:I,isHandTool:N,isDragging:k,isConnecting:G,setLastElementId:x,setIsInitialized:_,reconnectingEdgeId:Q,setIsMinimapOpen:L,setIsMoveTool:v,setIsHandTool:S,setIsDragging:O,setIsConnecting:F,setReconnectingEdgeId:$,validateCustomDiagram:i,onElementChanges:s,onConfigureElement:a,onElementClick:l,onSubprocessValidationClick:c}),[E,d,A,m,f,r,K,g,T,M,I,N,k,G,Q,i,s,a,l,c]);return na(Cb,{children:na(Wp.Provider,{value:P,children:na(ta,{ref:e})})})};export{Ce as EditorMode,Vi as ElementPosition,Yn as ElementType,Hi as GatewayElementVariant,rt as GatewayVariant,Rb as Modeler,wb as ModelerProvider,gt as NodeAttribute,se as NodeType,Qe as NodeVariant,Gi as RoutingVariant,Nn as useModeler};
|