lecom-modeler 0.47.0 → 0.47.2
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 +11 -11
- package/lib/index.js +11 -11
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var gm=Object.create;var Yn=Object.defineProperty,hm=Object.defineProperties,ym=Object.getOwnPropertyDescriptor,xm=Object.getOwnPropertyDescriptors,Em=Object.getOwnPropertyNames,Fr=Object.getOwnPropertySymbols,_m=Object.getPrototypeOf,As=Object.prototype.hasOwnProperty,Fa=Object.prototype.propertyIsEnumerable;var za=(e,t,o)=>t in e?Yn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,T=(e,t)=>{for(var o in t||(t={}))As.call(t,o)&&za(e,o,t[o]);if(Fr)for(var o of Fr(t))Fa.call(t,o)&&za(e,o,t[o]);return e},I=(e,t)=>hm(e,xm(t));var bt=(e,t)=>{var o={};for(var n in e)As.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Fr)for(var n of Fr(e))t.indexOf(n)<0&&Fa.call(e,n)&&(o[n]=e[n]);return o};var bm=(e,t)=>{for(var o in t)Yn(e,o,{get:t[o],enumerable:!0})},Ya=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Em(t))!As.call(e,r)&&r!==o&&Yn(e,r,{get:()=>t[r],enumerable:!(n=ym(t,r))||n.enumerable});return e};var Wn=(e,t,o)=>(o=e!=null?gm(_m(e)):{},Ya(t||!e||!e.__esModule?Yn(o,"default",{value:e,enumerable:!0}):o,e)),Tm=e=>Ya(Yn({},"__esModule",{value:!0}),e);var Ix={};bm(Ix,{EditorMode:()=>xe,ElementPosition:()=>Wr,ElementType:()=>Xn,GatewayElementVariant:()=>Xr,GatewayVariant:()=>qe,Modeler:()=>cm,ModelerProvider:()=>im,NodeAttribute:()=>pt,NodeType:()=>Q,NodeVariant:()=>Xe,RoutingVariant:()=>Ur,useModeler:()=>Cn});module.exports=Tm(Ix);var Cs=e=>{if(typeof document=="undefined")return;let t=document.cookie.match(new RegExp(`(?:^|; )${e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")}=([^;]*)`));return t?decodeURIComponent(t[1]):void 0};var Yr=require("@produto-lecom/lecom-ui");var Wa={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Delete",deleting:"Deleting...",configure_node:"Configure activity",configure_edge:"Configure routing",configure_gateway:"Configure routing",initial_task:"Initial Activity",gateway_limit_reached:"Exclusive gateway cannot have more than 2 outgoing connections",task_limit_reached:"Task cannot have more than 2 outgoing connections",start_event_limit_reached:"Start event can only connect to a single element",gateway_to_gateway_not_allowed:"Gateways cannot connect directly to other gateways",start_event_already_exists:"A start event already exists. Delete the current event to add another",script_to_end_not_allowed:"Script activities cannot connect directly to the end event",loop_to_end_not_allowed:"Loop activities cannot connect directly to the end event",initial_activity_to_end_not_allowed:"Initial activity cannot connect directly to the end event",final_activity_cannot_connect:"Final activity cannot connect to other elements",activity_has_outgoing_connections:"Activity with outgoing connections cannot connect to end event",end_event_cannot_connect_to_initial_activity:"End event cannot connect to an initial activity",initial_activity_cannot_connect_to_start_event:"Initial activity cannot connect to start event",concurrent_initial_and_final_activity:"An activity cannot be connected to both start and end events",start_event_to_service_task_not_allowed:"Start event cannot connect to an automatic activity",service_task_to_end_not_allowed:"Automatic activities cannot connect to the end event",duplicate_connection_not_allowed:"A connection already exists between these elements",connect_node:"Connect element",connecting:"Connecting...",delete_pool_lane_error:"Cannot delete the pool or lane while there are elements inside it.",delete_elements_blocked:"One or more activities cannot be deleted because there are in-progress processes in the Workspace linked to them.",delete_elements_error:"An error occurred. Please try again later."},controls:{zoom:{fit:"Fit zoom",in:"Zoom in",out:"Zoom out",reset:"Reset zoom"},actions:{move_tool:"Select elements",hand_tool:"Navigate the diagram",check:"Check diagram",check_loading:"Validating diagram...",export:{title:"Export diagram",print:"Print",html:"Export as HTML",png:"Export as PNG",feedback:{empty:"Cannot export an empty diagram",error:"Error exporting diagram"}},import_governance:"Import diagram from Governance platform",import_mermaid:"Import Mermaid",import:{title:"Import",xml:"XML",mermaid:"Mermaid",governance:"Governance",feedback:{error:"Could not import the file. Check its content."}},organize:{title:"Align diagram",vertical:"Vertical (top-down)",horizontal:"Horizontal (left-right)",feedback:{pool_lane:"Diagrams with pools or lanes cannot be arranged automatically."}},minimap:{label:"Minimap",open:"Open minimap",close:"Hide minimap"}},history:{undo:"Undo",redo:"Redo"}},modals:{mermaid_import:{title:"Import diagram from Mermaid",description:"Paste the Mermaid text (in the format supported by the modeler) to generate the diagram.",generate:"Generate",cancel:"Cancel",error_empty:"Paste the diagram text before generating.",error_parse:"Could not generate the diagram. Check the pasted text."},import_confirm:{title:"Replace the current diagram?",content:"Importing will replace the entire current diagram. Continue?",confirm:"Import",loading:"Importing...",cancel:"Cancel"},delete_elements:{title:"Delete elements",callout:"When deleting, the activity and routing settings will be deleted.",content:"Are you sure you want to delete?",confirm:"Delete",cancel:"Cancel"}},task_menu:{loop_not_allowed_when_connected_to_end:"Cannot create loop on activity connected to end event",script_not_allowed_when_connected_to_end:"Cannot transform to Script activity connected to end event",loop_not_allowed_when_subprocess:"Cannot create loop on subprocess",loop_not_allowed_when_service_task:"Cannot create loop on automatic activity",loop:"Activity with loop"}},validation:{success:{title:"Validation Successful",message:"The diagram was validated successfully with no errors."},errors:{title:"The diagram contains errors",subtitle:"Please review the following:",task_label_length:"Task name exceeds the maximum character limit",multiple_start_event_not_allowed:"Multiple start events are not allowed",task_flows_limit_exceeds:"The number of output connections exceeds the limit of two",duplicate_task_name:"There are multiple activities with the same name",flows_on_end_tasks_not_allowed:"Activities connected to end events cannot have other connections",conditions_flows_limit_exceeds:"Exclusive gateway has too many output connections (maximum of two)",task_label_empty:"One or more activities have no name",activity_name_invalid:"Activity name is invalid",final_activity_has_loop:"Final activities cannot have loops",nested_gateway:"Connecting gateways directly is not allowed",concurrent_initial_and_final_event:"The same activity cannot have both initial and final events",gateway_flow_to_event:"Connecting a gateway to an output event is not allowed",gateway_missing_output_streams:"One or more gateways do not have the correct number of outputs",events_nested:"Connecting events directly is not allowed",event_to_condition:"Connecting an event directly to a gateway is not allowed",script_in_final_activity:"Final activity cannot be a script type",subprocess_not_configured:"The subprocess reference is not properly configured in one or more activities",cannot_validate_subprocess_reference:"Could not validate the subprocess reference in one or more activities",start_event_not_found:"A start event is required",end_event_not_found:"At least one end event is required",service_task_without_rejection_routing:"Automated activity (RPA) without rejection routing configured",service_task_without_automation:"Automated activity (RPA) without a configured robot",service_task_connector_inactive:"Automated activity (RPA) linked to an inactive connector",service_task_integration_suspended:"Automated activity (RPA) linked to a suspended integration",service_task_automation_status_unavailable:"Could not verify the automation (RPA) status",service_task_initial_or_final:"Automated activity (RPA) cannot be an initial, final or concentrator step",service_task_in_loop:"Automated activity (RPA) cannot be in a loop"}},bpmn:{start_event:{variant:{default:"Start event"}},end_event:{variant:{default:"End event"}},annotation:{variant:{default:"Annotation"}},gateway:{menu:{title:"Change gateway type"},variant:{default:"Gateway",exclusive:"Exclusive gateway",parallel:"Parallel gateway",complex:"Complex gateway"}},task:{menu:{title:"Change task type"},variant:{default:"Task",script:"Script task",subprocess:"Subprocess",service_task:"RPA"},attribute:{loop:"Task with loop"},label:{prefix:"Activity"},feedback:{label_empty:{prefix:"Activity name was automatically set to"},label_already_exists:{prefix:"The name",middle:"already exists. The name was changed to"},invalid_first_character:"Activity name must start with a letter or number"}},lane:{variant:{default:"Pool / Lane"}},unsupported:{variant:{default:"Unsupported element"}}},adapter:{governance:{error:{DEFAULT:"Error importing diagram",NO_FILE:"No file selected",EMPTY_FILE:"Empty file",INVALID_FILE:"Invalid file",CONTAIN_NO_CELLS:"No cells found to be imported",ALREADY_INITIALIZED:"Importing from the Governance platform is only allowed in diagrams without elements. To import, delete the current diagram"},success:{default:"The diagram was imported from the Governance platform successfully and without any incompatibility detected.",incompatible_cells:"The diagram was imported from the Governance platform with incompatibilities. To know more details, click on the button below."},report:{columns:{type:"Type",value:"Value",status:"Status"},status:{imported:"Imported",adapted:"Adapted",unsupported:"Unsupported"}},action:{download:"Download report"}}}}};var Xa={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",deleting:"Eliminando...",configure_node:"Configurar actividad",configure_edge:"Configurar enrutamiento",configure_gateway:"Configurar enrutamiento",initial_task:"Actividad Inicial",gateway_limit_reached:"Compuerta exclusiva no puede tener m\xE1s de 2 conexiones de salida",task_limit_reached:"Actividad no puede tener m\xE1s de 2 conexiones de salida",start_event_limit_reached:"Evento inicial solo puede conectarse a un \xFAnico elemento",gateway_to_gateway_not_allowed:"Las compuertas no pueden conectarse directamente con otras compuertas",start_event_already_exists:"Ya existe un evento de inicio. Elimine el evento actual para agregar otro",script_to_end_not_allowed:"Las actividades Script no pueden conectarse directamente al evento final",loop_to_end_not_allowed:"Las actividades Loop no pueden conectarse directamente al evento final",initial_activity_to_end_not_allowed:"Actividad inicial no puede conectarse directamente al evento final",final_activity_cannot_connect:"Actividad final no puede conectarse a otros elementos",activity_has_outgoing_connections:"Actividad con conexiones de salida no puede conectarse al evento final",end_event_cannot_connect_to_initial_activity:"El evento final no puede conectarse a una actividad inicial",initial_activity_cannot_connect_to_start_event:"Actividad inicial no puede conectarse a evento de inicio",concurrent_initial_and_final_activity:"Una actividad no puede estar conectada al evento inicial y final al mismo tiempo",start_event_to_service_task_not_allowed:"El evento inicial no puede conectarse a una actividad autom\xE1tica",service_task_to_end_not_allowed:"Las actividades autom\xE1ticas no pueden conectarse al evento final",duplicate_connection_not_allowed:"Ya existe una conexi\xF3n entre estos elementos",connect_node:"Conectar elemento",connecting:"Conectando...",delete_pool_lane_error:"No se puede eliminar la piscina o carril mientras haya elementos dentro.",delete_elements_blocked:"No se pueden eliminar una o m\xE1s actividades porque existen procesos en curso en el Workspace vinculados a ellas.",delete_elements_error:"Ocurri\xF3 un error. Int\xE9ntelo de nuevo m\xE1s tarde."},controls:{zoom:{fit:"Ajustar zoom",in:"Acercar",out:"Alejar",reset:"Restablecer zoom"},actions:{move_tool:"Seleccionar elementos",hand_tool:"Navegar por el diagrama",check:"Validar diagrama",check_loading:"Validando diagrama...",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"No es posible exportar un diagrama vac\xEDo",error:"Error al exportar diagrama"}},import_governance:"Importar diagrama de la plataforma Governance",import_mermaid:"Importar Mermaid",import:{title:"Importar",xml:"XML",mermaid:"Mermaid",governance:"Governance",feedback:{error:"No fue posible importar el archivo. Verifique el contenido."}},organize:{title:"Alinear diagrama",vertical:"Vertical (de arriba hacia abajo)",horizontal:"Horizontal (de izquierda a derecha)",feedback:{pool_lane:"No es posible ordenar autom\xE1ticamente diagramas con piscinas o carriles."}},minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Deshacer",redo:"Rehacer"}},modals:{mermaid_import:{title:"Importar diagrama a partir de Mermaid",description:"Pegue el texto Mermaid (en el formato compatible con el modelador) para generar el diagrama.",generate:"Generar",cancel:"Cancelar",error_empty:"Pegue el texto del diagrama antes de generar.",error_parse:"No fue posible generar el diagrama. Verifique el texto pegado."},import_confirm:{title:"\xBFReemplazar el diagrama actual?",content:"Importar reemplazar\xE1 todo el diagrama actual. \xBFDesea continuar?",confirm:"Importar",loading:"Importando...",cancel:"Cancelar"},delete_elements:{title:"Eliminar elementos",callout:"Al eliminar, las configuraciones de actividades y enrutamiento ser\xE1n eliminadas.",content:"\xBFEst\xE1s seguro de querer eliminar?",confirm:"Eliminar",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"No se puede crear bucle en actividad conectada al evento final",script_not_allowed_when_connected_to_end:"No se puede transformar a Script actividad conectada al evento final",loop_not_allowed_when_subprocess:"No se puede crear bucle en subproceso",loop_not_allowed_when_service_task:"No se puede crear bucle en actividad autom\xE1tica",loop:"Actividad con loop"}},validation:{success:{title:"Validaci\xF3n exitosa",message:"El diagrama ha sido validado correctamente sin errores."},errors:{title:"El diagrama contiene errores",subtitle:"Revise lo siguiente:",task_label_length:"El nombre de la actividad excede el l\xEDmite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"No se permite tener m\xE1s de un evento de inicio",task_flows_limit_exceeds:"El n\xFAmero de conexiones de salida supera el l\xEDmite de dos",duplicate_task_name:"Hay varias actividades con el mismo nombre",flows_on_end_tasks_not_allowed:"Las actividades conectadas a eventos finales no pueden tener otras conexiones",conditions_flows_limit_exceeds:"Compuerta exclusiva con exceso de conexiones de salida (m\xE1ximo de dos)",task_label_empty:"El nombre de una o m\xE1s actividades no ha sido completado",activity_name_invalid:"El nombre de la actividad no es v\xE1lido",final_activity_has_loop:"Las actividades finales no pueden tener bucles",nested_gateway:"No se permite conectar compuertas directamente",concurrent_initial_and_final_event:"Una misma actividad no puede tener eventos iniciales y finales",gateway_flow_to_event:"No se permite conectar una compuerta a un evento de salida",gateway_missing_output_streams:"Una o m\xE1s compuertas no tienen el n\xFAmero correcto de salidas",events_nested:"No se permite conectar eventos directamente",event_to_condition:"No se permite conectar un evento directamente a una compuerta",script_in_final_activity:"La actividad final no puede ser de tipo script",subprocess_not_configured:"La referencia al subproceso no est\xE1 configurada correctamente en una o m\xE1s actividades",cannot_validate_subprocess_reference:"No fue posible validar la referencia al subproceso en una o m\xE1s actividades",start_event_not_found:"Es necesario tener un evento de inicio",end_event_not_found:"Es necesario tener al menos un evento final",service_task_without_rejection_routing:"Actividad autom\xE1tica (RPA) sin enrutamiento de rechazo configurado",service_task_without_automation:"Actividad autom\xE1tica (RPA) sin robot configurado",service_task_connector_inactive:"Actividad autom\xE1tica (RPA) vinculada a un conector inactivo",service_task_integration_suspended:"Actividad autom\xE1tica (RPA) vinculada a una integraci\xF3n suspendida",service_task_automation_status_unavailable:"No se pudo verificar el estado de la automatizaci\xF3n (RPA)",service_task_initial_or_final:"La actividad autom\xE1tica (RPA) no puede ser etapa inicial, final o concentradora",service_task_in_loop:"La actividad autom\xE1tica (RPA) no puede estar en un bucle"}},bpmn:{start_event:{variant:{default:"Evento de inicio"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anotaci\xF3n"}},gateway:{menu:{title:"Cambiar tipo de compuerta"},variant:{default:"Compuerta",exclusive:"Compuerta exclusiva",parallel:"Compuerta paralela",complex:"Compuerta compleja"}},task:{menu:{title:"Cambiar tipo de tarea"},variant:{default:"Tarea",script:"Tarea de script",subprocess:"Subproceso",service_task:"RPA"},attribute:{loop:"Tarea con bucle"},label:{prefix:"Actividad"},feedback:{label_empty:{prefix:"El nombre de la actividad se estableci\xF3 autom\xE1ticamente como"},label_already_exists:{prefix:"El nombre",middle:"ya existe. El nombre fue cambiado a"},invalid_first_character:"El nombre de la actividad debe comenzar con una letra o n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento no soportado"}}},adapter:{governance:{error:{DEFAULT:"Error al importar diagrama",NO_FILE:"No se ha seleccionado ning\xFAn archivo",EMPTY_FILE:"Archivo vac\xEDo",INVALID_FILE:"Archivo inv\xE1lido",CONTAIN_NO_CELLS:"No se encontraron c\xE9lulas para importar",ALREADY_INITIALIZED:"La importaci\xF3n de la plataforma Governance solo se permite en diagramas sin elementos. Para importar, elimine el diagrama actual"},success:{default:"El diagrama se ha importado de la plataforma Governance correctamente y sin ninguna incompatibilidad detectada.",incompatible_cells:"El diagrama se ha importado de la plataforma Governance con incompatibilidades. Para saber m\xE1s detalles, haz click en el bot\xF3n de abajo."},report:{columns:{type:"Tipo",value:"Valor",status:"Estado"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"No soportado"}},action:{download:"Descargar informe"}}}}};var Ua={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Excluir",deleting:"Excluindo...",configure_node:"Configurar atividade",configure_edge:"Configurar roteamento",configure_gateway:"Configurar roteamento",initial_task:"Atividade Inicial",gateway_limit_reached:"Gateway exclusivo n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",task_limit_reached:"Atividade n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",start_event_limit_reached:"Evento inicial s\xF3 pode se conectar a um \xFAnico elemento",gateway_to_gateway_not_allowed:"Gateways n\xE3o podem se conectar diretamente com outros gateways",start_event_already_exists:"J\xE1 existe um evento de in\xEDcio. Exclua o evento atual para adicionar outro",script_to_end_not_allowed:"Atividades Script n\xE3o podem se conectar diretamente ao evento final",loop_to_end_not_allowed:"Atividades Loop n\xE3o podem se conectar diretamente ao evento final",initial_activity_to_end_not_allowed:"Atividade inicial n\xE3o pode se conectar diretamente ao evento final",final_activity_cannot_connect:"Atividade final n\xE3o pode se conectar a outros elementos",activity_has_outgoing_connections:"Atividade com conex\xF5es de sa\xEDda n\xE3o pode se conectar a um evento final",end_event_cannot_connect_to_initial_activity:"O evento final n\xE3o pode ser conectado a uma atividade inicial",initial_activity_cannot_connect_to_start_event:"Atividade inicial n\xE3o pode se conectar a evento de in\xEDcio",concurrent_initial_and_final_activity:"Uma atividade n\xE3o pode estar conectada ao evento inicial e final ao mesmo tempo",duplicate_connection_not_allowed:"J\xE1 existe uma conex\xE3o entre esses elementos",start_event_to_subprocess_not_allowed:"Evento inicial n\xE3o pode se conectar a um subprocesso",start_event_to_service_task_not_allowed:"Evento inicial n\xE3o pode se conectar a uma atividade autom\xE1tica",service_task_to_end_not_allowed:"Atividades autom\xE1ticas n\xE3o podem se conectar ao evento final",connect_node:"Conectar elemento",connecting:"Conectando...",delete_pool_lane_error:"N\xE3o \xE9 poss\xEDvel excluir a piscina ou raia enquanto houver elementos dentro dela.",delete_elements_blocked:"Uma ou mais atividades n\xE3o podem ser exclu\xEDdas porque existem processos em andamento no Workspace vinculados a elas.",delete_elements_error:"Ocorreu um erro. Tente novamente mais tarde."},controls:{zoom:{fit:"Ajustar o zoom",in:"Aumentar o zoom",out:"Diminuir o zoom",reset:"Resetar o zoom"},actions:{move_tool:"Selecionar elementos",hand_tool:"Navegar pelo diagrama",check:"Validar diagrama",check_loading:"Validando diagrama...",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"N\xE3o \xE9 poss\xEDvel exportar um diagrama vazio",error:"Erro ao exportar o diagrama"}},import_governance:"Importar diagrama da plataforma Governance",import_mermaid:"Importar Mermaid",import:{title:"Importar",xml:"XML",mermaid:"Mermaid",governance:"Governance",feedback:{error:"N\xE3o foi poss\xEDvel importar o arquivo. Verifique o conte\xFAdo."}},organize:{title:"Alinhar diagrama",vertical:"Vertical (de cima para baixo)",horizontal:"Horizontal (da esquerda para a direita)",feedback:{pool_lane:"N\xE3o \xE9 poss\xEDvel ordenar automaticamente diagramas com piscinas ou raias."}},minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Desfazer",redo:"Refazer"}},modals:{mermaid_import:{title:"Importar diagrama a partir de Mermaid",description:"Cole o texto Mermaid (no formato suportado pelo modelador) para gerar o diagrama.",generate:"Gerar",cancel:"Cancelar",error_empty:"Cole o texto do diagrama antes de gerar.",error_parse:"N\xE3o foi poss\xEDvel gerar o diagrama. Verifique o texto colado."},import_confirm:{title:"Substituir o diagrama atual?",content:"Importar vai substituir todo o diagrama atual. Deseja continuar?",confirm:"Importar",loading:"Importando...",cancel:"Cancelar"},delete_elements:{title:"Excluir elementos",callout:"Ao excluir, as configura\xE7\xF5es de atividades e roteamento ser\xE3o exclu\xEDdas.",content:"Deseja realmente excluir?",confirm:"Excluir",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel criar loop em atividade conectada ao evento final",script_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel transformar em Script atividade conectada ao evento final",loop_not_allowed_when_subprocess:"N\xE3o \xE9 poss\xEDvel criar loop em subprocesso",loop_not_allowed_when_service_task:"N\xE3o \xE9 poss\xEDvel criar loop em atividade autom\xE1tica",loop:"Atividade com loop"}},validation:{success:{title:"Diagrama validado com sucesso!",message:"Nenhum erro encontrado."},errors:{title:"O diagrama cont\xE9m erros",subtitle:"Veja abaixo o que precisa ser corrigido:",task_label_length:"O nome da atividade excede o limite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"N\xE3o \xE9 permitido ter mais de um evento de in\xEDcio",task_flows_limit_exceeds:"O n\xFAmero de conex\xF5es de sa\xEDda ultrapassa o limite de dois",duplicate_task_name:"H\xE1 v\xE1rias atividades com o mesmo nome",flows_on_end_tasks_not_allowed:"Atividades conectadas a eventos finais n\xE3o podem ter outras conex\xF5es",conditions_flows_limit_exceeds:"Gateway exclusivo com excesso de conex\xF5es de sa\xEDda (m\xE1ximo de dois)",task_label_empty:"O nome de uma ou mais atividades n\xE3o foi preenchido",activity_name_invalid:"O nome da atividade n\xE3o \xE9 v\xE1lido",final_activity_has_loop:"Atividades finais n\xE3o podem ter loops",nested_gateway:"N\xE3o \xE9 permitido conectar gateways",concurrent_initial_and_final_event:"Uma mesma atividade n\xE3o pode ter eventos iniciais e finais",gateway_flow_to_event:"N\xE3o \xE9 permitido conectar um gateway a um evento de sa\xEDda",gateway_missing_output_streams:"Um ou mais gateways n\xE3o possuem o n\xFAmero correto de sa\xEDdas",events_nested:"N\xE3o \xE9 permitido conectar eventos",event_to_condition:"N\xE3o \xE9 permitido conectar um evento diretamente em um gateway",script_in_final_activity:"Atividade final n\xE3o pode ser do tipo script",subprocess_not_configured:"A refer\xEAncia ao subprocesso n\xE3o est\xE1 configurada corretamente em uma ou mais atividades",cannot_validate_subprocess_reference:"N\xE3o foi poss\xEDvel validar a refer\xEAncia ao subprocesso em uma ou mais atividades",start_event_not_found:"\xC9 necess\xE1rio ter um evento inicial",end_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento final",service_task_without_rejection_routing:"Atividade autom\xE1tica (RPA) sem roteamento de rejei\xE7\xE3o configurado",service_task_without_automation:"Atividade autom\xE1tica (RPA) sem rob\xF4 configurado",service_task_connector_inactive:"Atividade autom\xE1tica (RPA) vinculada a um conector inativo",service_task_integration_suspended:"Atividade autom\xE1tica (RPA) vinculada a uma integra\xE7\xE3o suspensa",service_task_automation_status_unavailable:"N\xE3o foi poss\xEDvel verificar o status da automa\xE7\xE3o (RPA)",service_task_initial_or_final:"Atividade autom\xE1tica (RPA) n\xE3o pode ser etapa inicial, final ou concentradora",service_task_in_loop:"Atividade autom\xE1tica (RPA) n\xE3o pode estar em loop"}},bpmn:{start_event:{variant:{default:"Evento inicial"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anota\xE7\xE3o"}},gateway:{menu:{title:"Alterar tipo de gateway"},variant:{default:"Gateway",exclusive:"Gateway exclusivo",parallel:"Gateway paralelo",complex:"Gateway complexo"}},task:{menu:{title:"Alterar tipo de atividade"},variant:{default:"Atividade",script:"Atividade de script",subprocess:"Subprocesso",service_task:"RPA"},attribute:{loop:"Atividade com loop"},label:{prefix:"Atividade"},feedback:{label_empty:{prefix:"O nome da atividade foi definido automaticamente como"},label_already_exists:{prefix:"O nome",middle:"j\xE1 existe. O nome foi alterado para"},invalid_first_character:"O nome da atividade deve come\xE7ar com uma letra ou n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento n\xE3o suportado"}}},adapter:{governance:{error:{DEFAULT:"Erro ao importar diagrama",NO_FILE:"Nenhum arquivo selecionado",EMPTY_FILE:"Arquivo vazio",INVALID_FILE:"Arquivo inv\xE1lido",CONTAIN_NO_CELLS:"N\xE3o foram encontradas c\xE9lulas para serem importadas",ALREADY_INITIALIZED:"A importa\xE7\xE3o da plataforma Governance s\xF3 \xE9 permitida em diagramas sem elementos. Para importar, apague o diagrama atual"},success:{default:"O diagrama foi importado da plataforma Governance com sucesso e sem nenhuma incompatibilidade detectada.",incompatible_cells:"O diagrama foi importado da plataforma Governance com incompatibilidades. Para saber mais detalhes, clique no bot\xE3o abaixo."},report:{columns:{type:"Tipo do elemento",value:"Valor",status:"Status"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"N\xE3o suportado"}},action:{download:"Baixar relat\xF3rio"}}}}};var $a={pt_BR:Ua,en_US:Wa,es_ES:Xa};var Ka,qa,vm=(qa=(Ka=Cs("LecomUserLanguage"))!=null?Ka:Cs("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?qa:Yr.Translations.PT_BR;(0,Yr.initializeI18n)({lng:vm,resources:$a});var xe=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(xe||{});var Xn=(i=>(i.ACTIVITY="activity",i.ROUTING="routing",i.GATEWAY="gateway",i.SUB_PROCESS="sub_process",i.SERVICE_TASK="service_task",i))(Xn||{}),Wr=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Wr||{}),Xr=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Xr||{}),Ur=(u=>(u.SIMPLE="simple",u.LOOP="loop",u.SCRIPT="script",u.SCRIPT_LOOP="script_loop",u.COMPLEX="complex",u.EXCLUSIVE="exclusive",u.PARALLEL="parallel",u.FINAL="final",u.TO_SUB_PROCESS="to_sub_process",u.FROM_SUB_PROCESS="from_sub_process",u.FROM_SERVICE_TASK="from_service_task",u))(Ur||{});var oo=require("lucide-react");var To=require("react/jsx-runtime"),$r=({size:e=24,className:t})=>(0,To.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:[(0,To.jsx)("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),(0,To.jsx)("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),(0,To.jsx)("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),(0,To.jsx)("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});var Ss=require("react/jsx-runtime"),nn=({size:e=24,className:t})=>(0,Ss.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#ff6565",stroke:"#ec1616",strokeWidth:3,className:t,children:(0,Ss.jsx)("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});var jt=require("react/jsx-runtime"),rn=({size:e=24,className:t})=>(0,jt.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[(0,jt.jsx)("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,jt.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,jt.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,jt.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,jt.jsx)("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var sn=require("react/jsx-runtime"),an=({size:e=24,className:t})=>(0,sn.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[(0,sn.jsx)("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,sn.jsx)("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,sn.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var ln=require("react/jsx-runtime"),cn=({size:e=24,className:t})=>(0,ln.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[(0,ln.jsx)("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ln.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ln.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});var dn=require("react/jsx-runtime"),Za=({size:e=24,className:t})=>(0,dn.jsx)("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:(0,dn.jsxs)("g",{children:[(0,dn.jsx)("path",{d:"M8.6543 11.4141V15.2148C8.51302 15.4017 8.29199 15.6068 7.99121 15.8301C7.69499 16.0488 7.30078 16.238 6.80859 16.3975C6.31641 16.557 5.70345 16.6367 4.96973 16.6367C4.34538 16.6367 3.77344 16.5319 3.25391 16.3223C2.73438 16.1081 2.28548 15.7959 1.90723 15.3857C1.53353 14.9756 1.24414 14.4766 1.03906 13.8887C0.833984 13.2962 0.731445 12.6217 0.731445 11.8652V11.1748C0.731445 10.4229 0.82487 9.75293 1.01172 9.16504C1.20312 8.57259 1.47656 8.07129 1.83203 7.66113C2.1875 7.25098 2.61589 6.94108 3.11719 6.73145C3.62305 6.51725 4.19499 6.41016 4.83301 6.41016C5.64876 6.41016 6.32324 6.54688 6.85645 6.82031C7.39421 7.08919 7.80892 7.46289 8.10059 7.94141C8.39225 8.41992 8.57682 8.9668 8.6543 9.58203H6.97266C6.91797 9.23568 6.81087 8.92578 6.65137 8.65234C6.49642 8.37891 6.27311 8.16471 5.98145 8.00977C5.69434 7.85026 5.32064 7.77051 4.86035 7.77051C4.46387 7.77051 4.11523 7.8457 3.81445 7.99609C3.51367 8.14648 3.26302 8.36751 3.0625 8.65918C2.86654 8.95085 2.71842 9.30632 2.61816 9.72559C2.5179 10.1449 2.46777 10.6234 2.46777 11.1611V11.8652C2.46777 12.4121 2.52474 12.8975 2.63867 13.3213C2.75716 13.7451 2.92578 14.1029 3.14453 14.3945C3.36784 14.6862 3.639 14.9072 3.95801 15.0576C4.27702 15.2035 4.63704 15.2764 5.03809 15.2764C5.43001 15.2764 5.7513 15.2445 6.00195 15.1807C6.2526 15.1123 6.45085 15.0326 6.59668 14.9414C6.74707 14.8457 6.86328 14.7546 6.94531 14.668V12.6924H4.87402V11.4141H8.6543ZM17.0912 11.25V11.7969C17.0912 12.5488 16.9932 13.2233 16.7973 13.8203C16.6013 14.4173 16.321 14.9255 15.9564 15.3447C15.5964 15.764 15.1635 16.0853 14.6576 16.3086C14.1518 16.5273 13.5912 16.6367 12.976 16.6367C12.3653 16.6367 11.807 16.5273 11.3012 16.3086C10.7999 16.0853 10.3646 15.764 9.99551 15.3447C9.62637 14.9255 9.33926 14.4173 9.13418 13.8203C8.93366 13.2233 8.8334 12.5488 8.8334 11.7969V11.25C8.8334 10.498 8.93366 9.82585 9.13418 9.2334C9.3347 8.63639 9.61725 8.12826 9.98184 7.70898C10.351 7.28516 10.7862 6.96387 11.2875 6.74512C11.7934 6.52181 12.3516 6.41016 12.9623 6.41016C13.5775 6.41016 14.1381 6.52181 14.6439 6.74512C15.1498 6.96387 15.585 7.28516 15.9496 7.70898C16.3142 8.12826 16.5945 8.63639 16.7904 9.2334C16.991 9.82585 17.0912 10.498 17.0912 11.25ZM15.3754 11.7969V11.2363C15.3754 10.6803 15.3207 10.1904 15.2113 9.7666C15.1065 9.33822 14.9493 8.98047 14.7396 8.69336C14.5346 8.40169 14.2816 8.18294 13.9809 8.03711C13.6801 7.88672 13.3406 7.81152 12.9623 7.81152C12.584 7.81152 12.2468 7.88672 11.9506 8.03711C11.6544 8.18294 11.4014 8.40169 11.1918 8.69336C10.9867 8.98047 10.8295 9.33822 10.7201 9.7666C10.6107 10.1904 10.5561 10.6803 10.5561 11.2363V11.7969C10.5561 12.3529 10.6107 12.8451 10.7201 13.2734C10.8295 13.7018 10.989 14.0641 11.1986 14.3604C11.4128 14.652 11.668 14.873 11.9643 15.0234C12.2605 15.1693 12.5977 15.2422 12.976 15.2422C13.3588 15.2422 13.6983 15.1693 13.9945 15.0234C14.2908 14.873 14.5414 14.652 14.7465 14.3604C14.9516 14.0641 15.1065 13.7018 15.2113 13.2734C15.3207 12.8451 15.3754 12.3529 15.3754 11.7969ZM20.6678 14.6816L23.2859 6.54688H25.1795L21.6111 16.5H20.3328L20.6678 14.6816ZM18.2479 6.54688L20.8455 14.6816L21.201 16.5H19.9158L16.3611 6.54688H18.2479Z"}),(0,dn.jsx)("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});var Ja=require("clsx"),Qa=require("tailwind-merge");function F(...e){return(0,Qa.twMerge)((0,Ja.clsx)(e))}var eo=(e=0,t=0)=>e<t?t:e,Kr=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});var Un=require("react/jsx-runtime"),ja=({size:e=24,className:t})=>(0,Un.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:F("stroke-2",t),children:[(0,Un.jsx)("path",{d:"M19 3H5C3.89543 3 3 3.89543 3 5V19C3 20.1046 3.89543 21 5 21H19C20.1046 21 21 20.1046 21 19V5C21 3.89543 20.1046 3 19 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Un.jsx)("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});var qr=require("react/jsx-runtime"),el=({size:e=24,className:t})=>(0,qr.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:(0,qr.jsx)("g",{children:(0,qr.jsx)("path",{d:"M4.85372 6.17472L5.31292 5.71552L5.31993 5.70863C6.88908 4.1924 8.98352 3.34122 11.1655 3.33301L11.1668 3.33301C11.167 3.33301 11.1673 3.33301 11.1675 3.33301C12.7165 3.33314 14.2308 3.79255 15.5188 4.65317C16.807 5.5139 17.811 6.7373 18.4039 8.16866C18.9968 9.60001 19.1519 11.175 18.8497 12.6945C18.5986 13.9567 18.0414 15.1334 17.232 16.1236L16.9457 16.4738L17.2655 16.7936L20.6617 20.1899L20.6617 20.1899C20.7919 20.3201 20.7919 20.5311 20.6617 20.6612L20.6616 20.6613C20.5316 20.7915 20.3205 20.7915 20.1903 20.6613L16.7941 17.265L16.4743 16.9452L16.1241 17.2315C15.1339 18.0409 13.9571 18.5981 12.695 18.8492C11.1755 19.1514 9.6005 18.9963 8.16915 18.4034C6.73778 17.8105 5.51439 16.8065 4.65365 15.5183C3.79291 14.2301 3.3335 12.7156 3.3335 11.1663C3.3335 10.9822 3.48273 10.833 3.66683 10.833C3.85093 10.833 4.00016 10.9822 4.00016 11.1663C4.00016 12.5838 4.42048 13.9694 5.20796 15.148C5.99545 16.3265 7.11474 17.245 8.42426 17.7874C9.73378 18.3299 11.1748 18.4719 12.565 18.1953C13.9552 17.9188 15.2321 17.2362 16.2344 16.234L16.2345 16.234C17.2367 15.2316 17.9193 13.9547 18.1958 12.5645C18.4724 11.1743 18.3304 9.7333 17.7879 8.42378C17.2455 7.11426 16.327 5.99497 15.1484 5.20748L14.8707 5.62322L15.1484 5.20748C13.9703 4.42031 12.5854 4.00001 11.1685 3.99968L11.1664 3.99969C9.15876 4.00767 7.23176 4.7903 5.78712 6.18424L5.78706 6.18418L5.78075 6.1905L5.32512 6.64613L4.47156 7.49968H5.67867H7.8335C8.01759 7.49968 8.16683 7.64892 8.16683 7.83302C8.16683 8.01711 8.01759 8.16635 7.8335 8.16635H3.66683C3.48274 8.16635 3.3335 8.01711 3.3335 7.83302V3.66635C3.3335 3.48225 3.48274 3.33302 3.66683 3.33302C3.85092 3.33302 4.00016 3.48225 4.00016 3.66635V5.82117V7.02827L4.85372 6.17472Z"})})});var Ms=require("react/jsx-runtime"),Zr=({size:e=24,className:t})=>(0,Ms.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#5fd9b0",stroke:"#1cad86",strokeWidth:"2",className:t,children:(0,Ms.jsx)("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});var Ps=require("react/jsx-runtime"),$n=({size:e=24,className:t})=>(0,Ps.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",className:F("stroke-2",t),children:(0,Ps.jsx)("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"})});var un=require("react/jsx-runtime"),tl=({size:e=24,className:t})=>(0,un.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[(0,un.jsx)("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,un.jsx)("path",{d:"M7.5 12C7.5 12.89 7.76392 13.76 8.25839 14.5001C8.75285 15.2401 9.45566 15.8169 10.2779 16.1575C11.1002 16.4981 12.005 16.5872 12.8779 16.4135C13.7508 16.2399 14.5526 15.8113 15.182 15.182C15.8113 14.5526 16.2399 13.7508 16.4135 12.8779C16.5872 12.005 16.4981 11.1002 16.1575 10.2779C15.8169 9.45566 15.2401 8.75285 14.5001 8.25839C13.76 7.76392 12.89 7.5 12 7.5C10.742 7.50473 9.53448 7.99561 8.63 8.87L7.5 10",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,un.jsx)("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});var to=require("react/jsx-runtime"),ol=({size:e=24,className:t})=>(0,to.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[(0,to.jsx)("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,to.jsx)("path",{d:"M15.5 14.5V8.5C15.5 8.23478 15.3946 7.98043 15.2071 7.79289C15.0196 7.60536 14.7652 7.5 14.5 7.5H8",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,to.jsx)("path",{d:"M10 16.5H16C16.2652 16.5 16.5196 16.3946 16.7071 16.2071C16.8946 16.0196 17 15.7652 17 15.5V15C17 14.8674 16.9473 14.7402 16.8536 14.6464C16.7598 14.5527 16.6326 14.5 16.5 14.5H11.5C11.3674 14.5 11.2402 14.5527 11.1464 14.6464C11.0527 14.7402 11 14.8674 11 15V15.5C11 15.7652 10.8946 16.0196 10.7071 16.2071C10.5196 16.3946 10.2652 16.5 10 16.5ZM10 16.5C9.73478 16.5 9.48043 16.3946 9.29289 16.2071C9.10536 16.0196 9 15.7652 9 15.5V8.5C9 8.23478 8.89464 7.98043 8.70711 7.79289C8.51957 7.60536 8.26522 7.5 8 7.5C7.73478 7.5 7.48043 7.60536 7.29289 7.79289C7.10536 7.98043 7 8.23478 7 8.5V9.5C7 9.63261 7.05268 9.75979 7.14645 9.85355C7.24021 9.94732 7.36739 10 7.5 10H9",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,to.jsx)("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,to.jsx)("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var vo=require("react/jsx-runtime"),Kn=({size:e=24,className:t})=>(0,vo.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[(0,vo.jsx)("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,vo.jsx)("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),(0,vo.jsx)("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,vo.jsx)("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var Q=(s=>(s.START_EVENT="START_EVENT",s.END_EVENT="END_EVENT",s.TASK="TASK",s.LANE="LANE",s.GATEWAY="GATEWAY",s.ANNOTATION="ANNOTATION",s.UNSUPPORTED="UNSUPPORTED",s))(Q||{}),Xe=(n=>(n.SCRIPT="SCRIPT",n.SUBPROCESS="SUBPROCESS",n.SERVICE_TASK="SERVICE_TASK",n))(Xe||{}),Jr={SCRIPT:{icon:oo.ScrollText},SUBPROCESS:{icon:oo.SquarePlus},SERVICE_TASK:{icon:oo.Bot}},pt=(t=>(t.LOOP="LOOP",t))(pt||{}),Qr={LOOP:{icon:oo.RotateCcw}},qe=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(qe||{}),Ls={EXCLUSIVE:{icon:an},PARALLEL:{icon:cn},COMPLEX:{icon:rn}};var sm=require("@produto-lecom/lecom-ui"),am=require("@xyflow/react"),ue=require("react");var Vt=require("@xyflow/react"),on=require("react");var go=require("@xyflow/react"),Dt=require("react");var pn=require("@xyflow/react");var Nm={START_EVENT:"ellipse",END_EVENT:"ellipse",TASK:"rectangle",GATEWAY:"rectangle",LANE:"rectangle",ANNOTATION:"rectangle",UNSUPPORTED:"rectangle"};function Ht(e){var o,n,r,i,a,s,l;return{bounds:{x:e.internals.positionAbsolute.x,y:e.internals.positionAbsolute.y,width:(r=(n=(o=e.measured)==null?void 0:o.width)!=null?n:e.width)!=null?r:0,height:(s=(a=(i=e.measured)==null?void 0:i.height)!=null?a:e.height)!=null?s:0},perimeter:(l=Nm[e.type])!=null?l:"rectangle"}}function jr(e,t){let o=e==null?void 0:e.controlPoint;return o?I(T({},e),{controlPoint:{x:o.x+t,y:o.y+t}}):e}function nl(e,t){var y,v,_,N;let{width:o=0,height:n=0}=e.measured||{width:0,height:0},r=e.internals.positionAbsolute,i=t.internals.positionAbsolute,a=o/2,s=n/2,l=r.x+a,c=r.y+s,d=i.x+((v=(y=t==null?void 0:t.measured)==null?void 0:y.width)!=null?v:0)/2,u=i.y+((N=(_=t==null?void 0:t.measured)==null?void 0:_.height)!=null?N:0)/2,p=(d-l)/(2*a)-(u-c)/(2*s),f=(d-l)/(2*a)+(u-c)/(2*s),x=1/(Math.abs(p)+Math.abs(f)||1),E=x*p,m=x*f,h=a*(E+m)+l,g=s*(-E+m)+c;return{x:h,y:g}}function rl(e,t){var c,d,u,p;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(p=(u=e.measured)==null?void 0:u.height)!=null?p:0,i=Math.round(o.x),a=Math.round(o.y),s=Math.round(t.x),l=Math.round(t.y);return s<=i+1?pn.Position.Left:s>=i+n-1?pn.Position.Right:l<=a+1?pn.Position.Top:l>=a+r-1?pn.Position.Bottom:pn.Position.Top}function ei(e,t){let o=nl(e,t),n=nl(t,e),r=rl(e,o),i=rl(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function ti(e,t){return{isFromStartEvent:(e==null?void 0:e.type)==="START_EVENT",isGatewayToGateway:(e==null?void 0:e.type)==="GATEWAY"&&(t==null?void 0:t.type)==="GATEWAY",isActiviyToAndGateway:(e==null?void 0:e.type)==="TASK"&&(t==null?void 0:t.type)==="GATEWAY",isToEndEvent:(t==null?void 0:t.type)==="END_EVENT"}}var il=require("lodash");var oi=e=>e.some(t=>t.type==="position"&&t.dragging),sl=e=>new Map(e.map(t=>[t.id,t])),No=(e,t)=>{let o=e?t.find(a=>a.id===e):void 0;if(!o)return{x:0,y:0};let{x:n,y:r}=o.position,i=o.parentId;for(;i;){let a=t.find(s=>s.id===i);if(!a)break;n+=a.position.x,r+=a.position.y,i=a.parentId}return{x:n,y:r}},al=(e,t)=>e.map(o=>{var n;return(n=t.get(o.id))!=null?n:o}),ot=e=>{var t,o,n,r,i,a,s,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(r=(n=e.internals)==null?void 0:n.positionAbsolute.y)!=null?r:0,w:(a=(i=e.measured)==null?void 0:i.width)!=null?a:0,h:(l=(s=e.measured)==null?void 0:s.height)!=null?l:0}},wo=e=>(0,il.orderBy)(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),ll=(e,t)=>{let{x:o,y:n}=ot(e),{x:r,y:i}=ot(t);return{x:o-r,y:n-i}};var Io=({parentId:e,nodes:t,includeTypes:o=[...Object.values(Q)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),wm=(e,t)=>{let{x:o,y:n}=ot(e),{x:r,y:i}=ot(t),a=o-r,s=n-i;return Math.sqrt(a*a+s*s)},Im=(e,t)=>{let{x:o,y:n,w:r,h:i}=ot(e),{x:a,y:s,w:l,h:c}=ot(t),d=o+r/2,u=n+i/2;return d>=a&&d<=a+l&&u>=s&&u<=s+c},fn=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&Im(e,r)){let i=wm(e,r);i<n&&(n=i,o=r)}return o},cl=(e,t)=>t.filter(o=>o.parentId===e).reduce((o,n)=>{var r,i;return Math.max(o,(i=(r=n.measured)==null?void 0:r.width)!=null?i:0)},0);var dl=e=>{let t=e.filter(a=>!a.parentId);if(t.length===0)return null;let o=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of t){let{position:s,width:l,height:c}=a,d=s.x+(l||0),u=s.y+(c||0);s.x<o&&(o=s.x),s.y<n&&(n=s.y),d>r&&(r=d),u>i&&(i=u)}return{x:o,y:n,w:r-o,h:i-n}},ul=({bounds:e,canvasWidth:t,canvasHeight:o,minZoom:n=.5,maxZoom:r=5,offsetX:i=0,offsetY:a=0})=>{let s=t-i*2,l=o-a*2,c=Math.min(s/e.w,l/e.h),d=Math.min(1,c),u=Math.min(Math.max(d,n),r);return{x:-e.x*u+i,y:-e.y*u+a,zoom:u}};var Ds=(e,t)=>{let o=t.find(a=>a.id===e);if(!o||o.type!=="LANE"||o.parentId)return!1;let n=ot(o),r=n.x+n.w,i=n.y+n.h;return t.some(a=>{if(a.id===e||a.parentId||a.type==="LANE")return!1;let s=ot(a);return s.x<r&&s.x+s.w>n.x&&s.y<i&&s.y+s.h>n.y})};var fl=require("react"),ml=require("zustand");var pl=require("@xyflow/react"),Tt=()=>{let e=(0,pl.useStoreApi)();return{selectElements:n=>{let{edges:r,nodes:i,triggerEdgeChanges:a,triggerNodeChanges:s}=e.getState(),l=i.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]),c=r.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]);return s(l),a(c),!0},clearSelection:async()=>{let{unselectNodesAndEdges:n}=e.getState();return n(),await Kr(),!0}}};var gl=()=>{let{selectElements:e}=Tt();return(0,fl.useCallback)(()=>{let o=Ao.getState().pathEdgeIds;e(o)},[e])},Ao=(0,ml.create)((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=T({},n.statusByNodeId),i=T({},n.statusData),a=!1;return o.forEach(s=>{let l=`${s.diagramId}-${s.activityId}`;r[s.diagramId]!==s.status&&(r[s.diagramId]=s.status,i[l]=s,a=!0)}),a?{statusByNodeId:r,statusData:i}:n})},getTaskStatus:o=>t().statusByNodeId[o]||null,clearTaskStatuses:()=>e({statusByNodeId:{},statusData:{},pathEdgeIds:[]}),setPathEdges:o=>{e({pathEdgeIds:o})},getPathEdgeIds:()=>t().pathEdgeIds,clearPathEdges:()=>{e({pathEdgeIds:[]})},calculateFlowPath:(o,n)=>{if(!o.length||!n.length)return;t().clearPathEdges();let r=n.filter(d=>t().statusByNodeId[d]);if(r.length<=1)return;let i=[],a={};o.forEach(d=>{a[d.source]||(a[d.source]=[]),a[d.source].push({targetId:d.target,edgeId:d.id})});let s=r[0],l=r[r.length-1];o.forEach(d=>{d.target===s&&i.push(d.id)}),o.forEach(d=>{d.source===l&&i.push(d.id)});let c=(d,u)=>{let p=[],f=new Set;for(p.push({node:d,path:[]}),f.add(d);p.length>0;){let{node:x,path:E}=p.shift();if(x===u)return E;let m=a[x]||[];for(let{targetId:h,edgeId:g}of m)f.has(h)||(f.add(h),p.push({node:h,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})}}));var xn=require("@xyflow/react"),Ze=require("react"),dd=require("zustand/shallow");var Am={value:()=>{}};function yl(){for(var e=0,t=arguments.length,o={},n;e<t;++e){if(!(n=arguments[e]+"")||n in o||/[\s.]/.test(n))throw new Error("illegal type: "+n);o[n]=[]}return new ni(o)}function ni(e){this._=e}function Cm(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}})}ni.prototype=yl.prototype={constructor:ni,on:function(e,t){var o=this._,n=Cm(e+"",o),r,i=-1,a=n.length;if(arguments.length<2){for(;++i<a;)if((r=(e=n[i]).type)&&(r=Sm(o[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<a;)if(r=(e=n[i]).type)o[r]=hl(o[r],e.name,t);else if(t==null)for(r in o)o[r]=hl(o[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var o in t)e[o]=t[o].slice();return new ni(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 Sm(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function hl(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=Am,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var ks=yl;var ri="http://www.w3.org/1999/xhtml",Rs={svg:"http://www.w3.org/2000/svg",xhtml:ri,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Gt(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),Rs.hasOwnProperty(t)?{space:Rs[t],local:e}:e}function Mm(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===ri&&t.documentElement.namespaceURI===ri?t.createElement(e):t.createElementNS(o,e)}}function Pm(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function ii(e){var t=Gt(e);return(t.local?Pm:Mm)(t)}function Lm(){}function Co(e){return e==null?Lm:function(){return this.querySelector(e)}}function xl(e){typeof e!="function"&&(e=Co(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=new Array(a),l,c,d=0;d<a;++d)(l=i[d])&&(c=e.call(l,l.__data__,d,i))&&("__data__"in l&&(c.__data__=l.__data__),s[d]=c);return new Me(n,this._parents)}function Os(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Dm(){return[]}function qn(e){return e==null?Dm:function(){return this.querySelectorAll(e)}}function km(e){return function(){return Os(e.apply(this,arguments))}}function El(e){typeof e=="function"?e=km(e):e=qn(e);for(var t=this._groups,o=t.length,n=[],r=[],i=0;i<o;++i)for(var a=t[i],s=a.length,l,c=0;c<s;++c)(l=a[c])&&(n.push(e.call(l,l.__data__,c,a)),r.push(l));return new Me(n,r)}function Zn(e){return function(){return this.matches(e)}}function si(e){return function(t){return t.matches(e)}}var Rm=Array.prototype.find;function Om(e){return function(){return Rm.call(this.children,e)}}function Vm(){return this.firstElementChild}function _l(e){return this.select(e==null?Vm:Om(typeof e=="function"?e:si(e)))}var Hm=Array.prototype.filter;function Gm(){return Array.from(this.children)}function Bm(e){return function(){return Hm.call(this.children,e)}}function bl(e){return this.selectAll(e==null?Gm:Bm(typeof e=="function"?e:si(e)))}function Tl(e){typeof e!="function"&&(e=Zn(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=[],l,c=0;c<a;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&s.push(l);return new Me(n,this._parents)}function ai(e){return new Array(e.length)}function vl(){return new Me(this._enter||this._groups.map(ai),this._parents)}function Jn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Jn.prototype={constructor:Jn,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Nl(e){return function(){return e}}function zm(e,t,o,n,r,i){for(var a=0,s,l=t.length,c=i.length;a<c;++a)(s=t[a])?(s.__data__=i[a],n[a]=s):o[a]=new Jn(e,i[a]);for(;a<l;++a)(s=t[a])&&(r[a]=s)}function Fm(e,t,o,n,r,i,a){var s,l,c=new Map,d=t.length,u=i.length,p=new Array(d),f;for(s=0;s<d;++s)(l=t[s])&&(p[s]=f=a.call(l,l.__data__,s,t)+"",c.has(f)?r[s]=l:c.set(f,l));for(s=0;s<u;++s)f=a.call(e,i[s],s,i)+"",(l=c.get(f))?(n[s]=l,l.__data__=i[s],c.delete(f)):o[s]=new Jn(e,i[s]);for(s=0;s<d;++s)(l=t[s])&&c.get(p[s])===l&&(r[s]=l)}function Ym(e){return e.__data__}function wl(e,t){if(!arguments.length)return Array.from(this,Ym);var o=t?Fm:zm,n=this._parents,r=this._groups;typeof e!="function"&&(e=Nl(e));for(var i=r.length,a=new Array(i),s=new Array(i),l=new Array(i),c=0;c<i;++c){var d=n[c],u=r[c],p=u.length,f=Wm(e.call(d,d&&d.__data__,c,n)),x=f.length,E=s[c]=new Array(x),m=a[c]=new Array(x),h=l[c]=new Array(p);o(d,u,E,m,h,f,t);for(var g=0,y=0,v,_;g<x;++g)if(v=E[g]){for(g>=y&&(y=g+1);!(_=m[y])&&++y<x;);v._next=_||null}}return a=new Me(a,n),a._enter=s,a._exit=l,a}function Wm(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Il(){return new Me(this._exit||this._groups.map(ai),this._parents)}function Al(e,t,o){var n=this.enter(),r=this,i=this.exit();return typeof e=="function"?(n=e(n),n&&(n=n.selection())):n=n.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),o==null?i.remove():o(i),n&&r?n.merge(r).order():r}function Cl(e){for(var t=e.selection?e.selection():e,o=this._groups,n=t._groups,r=o.length,i=n.length,a=Math.min(r,i),s=new Array(r),l=0;l<a;++l)for(var c=o[l],d=n[l],u=c.length,p=s[l]=new Array(u),f,x=0;x<u;++x)(f=c[x]||d[x])&&(p[x]=f);for(;l<r;++l)s[l]=o[l];return new Me(s,this._parents)}function Sl(){for(var e=this._groups,t=-1,o=e.length;++t<o;)for(var n=e[t],r=n.length-1,i=n[r],a;--r>=0;)(a=n[r])&&(i&&a.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(a,i),i=a);return this}function Ml(e){e||(e=Xm);function t(u,p){return u&&p?e(u.__data__,p.__data__):!u-!p}for(var o=this._groups,n=o.length,r=new Array(n),i=0;i<n;++i){for(var a=o[i],s=a.length,l=r[i]=new Array(s),c,d=0;d<s;++d)(c=a[d])&&(l[d]=c);l.sort(t)}return new Me(r,this._parents).order()}function Xm(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Pl(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Ll(){return Array.from(this)}function Dl(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length;r<i;++r){var a=n[r];if(a)return a}return null}function kl(){let e=0;for(let t of this)++e;return e}function Rl(){return!this.node()}function Ol(e){for(var t=this._groups,o=0,n=t.length;o<n;++o)for(var r=t[o],i=0,a=r.length,s;i<a;++i)(s=r[i])&&e.call(s,s.__data__,i,r);return this}function Um(e){return function(){this.removeAttribute(e)}}function $m(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Km(e,t){return function(){this.setAttribute(e,t)}}function qm(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Zm(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function Jm(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,o)}}function Vl(e,t){var o=Gt(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?$m:Um:typeof t=="function"?o.local?Jm:Zm:o.local?qm:Km)(o,t))}function li(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Qm(e){return function(){this.style.removeProperty(e)}}function jm(e,t,o){return function(){this.style.setProperty(e,t,o)}}function eg(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function Hl(e,t,o){return arguments.length>1?this.each((t==null?Qm:typeof t=="function"?eg:jm)(e,t,o==null?"":o)):no(this.node(),e)}function no(e,t){return e.style.getPropertyValue(t)||li(e).getComputedStyle(e,null).getPropertyValue(t)}function tg(e){return function(){delete this[e]}}function og(e,t){return function(){this[e]=t}}function ng(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function Gl(e,t){return arguments.length>1?this.each((t==null?tg:typeof t=="function"?ng:og)(e,t)):this.node()[e]}function Bl(e){return e.trim().split(/^|\s+/)}function Vs(e){return e.classList||new zl(e)}function zl(e){this._node=e,this._names=Bl(e.getAttribute("class")||"")}zl.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Fl(e,t){for(var o=Vs(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function Yl(e,t){for(var o=Vs(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function rg(e){return function(){Fl(this,e)}}function ig(e){return function(){Yl(this,e)}}function sg(e,t){return function(){(t.apply(this,arguments)?Fl:Yl)(this,e)}}function Wl(e,t){var o=Bl(e+"");if(arguments.length<2){for(var n=Vs(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?sg:t?rg:ig)(o,t))}function ag(){this.textContent=""}function lg(e){return function(){this.textContent=e}}function cg(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function Xl(e){return arguments.length?this.each(e==null?ag:(typeof e=="function"?cg:lg)(e)):this.node().textContent}function dg(){this.innerHTML=""}function ug(e){return function(){this.innerHTML=e}}function pg(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function Ul(e){return arguments.length?this.each(e==null?dg:(typeof e=="function"?pg:ug)(e)):this.node().innerHTML}function fg(){this.nextSibling&&this.parentNode.appendChild(this)}function $l(){return this.each(fg)}function mg(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Kl(){return this.each(mg)}function ql(e){var t=typeof e=="function"?e:ii(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function gg(){return null}function Zl(e,t){var o=typeof e=="function"?e:ii(e),n=t==null?gg:typeof t=="function"?t:Co(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function hg(){var e=this.parentNode;e&&e.removeChild(this)}function Jl(){return this.each(hg)}function yg(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function xg(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Ql(e){return this.select(e?xg:yg)}function jl(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Eg(e){return function(t){e.call(this,t,this.__data__)}}function _g(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 bg(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 Tg(e,t,o){return function(){var n=this.__on,r,i=Eg(t);if(n){for(var a=0,s=n.length;a<s;++a)if((r=n[a]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=o),r.value=t;return}}this.addEventListener(e.type,i,o),r={type:e.type,name:e.name,value:t,listener:i,options:o},n?n.push(r):this.__on=[r]}}function ec(e,t,o){var n=_g(e+""),r,i=n.length,a;if(arguments.length<2){var s=this.node().__on;if(s){for(var l=0,c=s.length,d;l<c;++l)for(r=0,d=s[l];r<i;++r)if((a=n[r]).type===d.type&&a.name===d.name)return d.value}return}for(s=t?Tg:bg,r=0;r<i;++r)this.each(s(n[r],t,o));return this}function tc(e,t,o){var n=li(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 vg(e,t){return function(){return tc(this,e,t)}}function Ng(e,t){return function(){return tc(this,e,t.apply(this,arguments))}}function oc(e,t){return this.each((typeof t=="function"?Ng:vg)(e,t))}function*nc(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length,a;r<i;++r)(a=n[r])&&(yield a)}var wg=[null];function Me(e,t){this._groups=e,this._parents=t}function rc(){return new Me([[document.documentElement]],wg)}function Ig(){return this}Me.prototype=rc.prototype={constructor:Me,select:xl,selectAll:El,selectChild:_l,selectChildren:bl,filter:Tl,data:wl,enter:vl,exit:Il,join:Al,merge:Cl,selection:Ig,order:Sl,sort:Ml,call:Pl,nodes:Ll,node:Dl,size:kl,empty:Rl,each:Ol,attr:Vl,style:Hl,property:Gl,classed:Wl,text:Xl,html:Ul,raise:$l,lower:Kl,append:ql,insert:Zl,remove:Jl,clone:Ql,datum:jl,on:ec,dispatch:oc,[Symbol.iterator]:nc};var Bt=rc;function ci(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function Hs(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function er(){}var Qn=.7,pi=1/Qn,mn="\\s*([+-]?\\d+)\\s*",jn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",vt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Ag=/^#([0-9a-f]{3,8})$/,Cg=new RegExp(`^rgb\\(${mn},${mn},${mn}\\)$`),Sg=new RegExp(`^rgb\\(${vt},${vt},${vt}\\)$`),Mg=new RegExp(`^rgba\\(${mn},${mn},${mn},${jn}\\)$`),Pg=new RegExp(`^rgba\\(${vt},${vt},${vt},${jn}\\)$`),Lg=new RegExp(`^hsl\\(${jn},${vt},${vt}\\)$`),Dg=new RegExp(`^hsla\\(${jn},${vt},${vt},${jn}\\)$`),ic={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};ci(er,ro,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:sc,formatHex:sc,formatHex8:kg,formatHsl:Rg,formatRgb:ac,toString:ac});function sc(){return this.rgb().formatHex()}function kg(){return this.rgb().formatHex8()}function Rg(){return fc(this).formatHsl()}function ac(){return this.rgb().formatRgb()}function ro(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=Ag.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?lc(t):o===3?new Ue(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?di(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?di(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=Cg.exec(e))?new Ue(t[1],t[2],t[3],1):(t=Sg.exec(e))?new Ue(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Mg.exec(e))?di(t[1],t[2],t[3],t[4]):(t=Pg.exec(e))?di(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Lg.exec(e))?uc(t[1],t[2]/100,t[3]/100,1):(t=Dg.exec(e))?uc(t[1],t[2]/100,t[3]/100,t[4]):ic.hasOwnProperty(e)?lc(ic[e]):e==="transparent"?new Ue(NaN,NaN,NaN,0):null}function lc(e){return new Ue(e>>16&255,e>>8&255,e&255,1)}function di(e,t,o,n){return n<=0&&(e=t=o=NaN),new Ue(e,t,o,n)}function Og(e){return e instanceof er||(e=ro(e)),e?(e=e.rgb(),new Ue(e.r,e.g,e.b,e.opacity)):new Ue}function gn(e,t,o,n){return arguments.length===1?Og(e):new Ue(e,t,o,n==null?1:n)}function Ue(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}ci(Ue,gn,Hs(er,{brighter(e){return e=e==null?pi:Math.pow(pi,e),new Ue(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Qn:Math.pow(Qn,e),new Ue(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ue(Mo(this.r),Mo(this.g),Mo(this.b),fi(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:cc,formatHex:cc,formatHex8:Vg,formatRgb:dc,toString:dc}));function cc(){return`#${So(this.r)}${So(this.g)}${So(this.b)}`}function Vg(){return`#${So(this.r)}${So(this.g)}${So(this.b)}${So((isNaN(this.opacity)?1:this.opacity)*255)}`}function dc(){let e=fi(this.opacity);return`${e===1?"rgb(":"rgba("}${Mo(this.r)}, ${Mo(this.g)}, ${Mo(this.b)}${e===1?")":`, ${e})`}`}function fi(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Mo(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function So(e){return e=Mo(e),(e<16?"0":"")+e.toString(16)}function uc(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new ft(e,t,o,n)}function fc(e){if(e instanceof ft)return new ft(e.h,e.s,e.l,e.opacity);if(e instanceof er||(e=ro(e)),!e)return new ft;if(e instanceof ft)return e;e=e.rgb();var t=e.r/255,o=e.g/255,n=e.b/255,r=Math.min(t,o,n),i=Math.max(t,o,n),a=NaN,s=i-r,l=(i+r)/2;return s?(t===i?a=(o-n)/s+(o<n)*6:o===i?a=(n-t)/s+2:a=(t-o)/s+4,s/=l<.5?i+r:2-i-r,a*=60):s=l>0&&l<1?0:a,new ft(a,s,l,e.opacity)}function mc(e,t,o,n){return arguments.length===1?fc(e):new ft(e,t,o,n==null?1:n)}function ft(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}ci(ft,mc,Hs(er,{brighter(e){return e=e==null?pi:Math.pow(pi,e),new ft(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Qn:Math.pow(Qn,e),new ft(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,o=this.l,n=o+(o<.5?o:1-o)*t,r=2*o-n;return new Ue(Gs(e>=240?e-240:e+120,r,n),Gs(e,r,n),Gs(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new ft(pc(this.h),ui(this.s),ui(this.l),fi(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=fi(this.opacity);return`${e===1?"hsl(":"hsla("}${pc(this.h)}, ${ui(this.s)*100}%, ${ui(this.l)*100}%${e===1?")":`, ${e})`}`}}));function pc(e){return e=(e||0)%360,e<0?e+360:e}function ui(e){return Math.max(0,Math.min(1,e||0))}function Gs(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 Bs(e,t,o,n,r){var i=e*e,a=i*e;return((1-3*e+3*i-a)*t+(4-6*i+3*a)*o+(1+3*e+3*i-3*a)*n+a*r)/6}function gc(e){var t=e.length-1;return function(o){var n=o<=0?o=0:o>=1?(o=1,t-1):Math.floor(o*t),r=e[n],i=e[n+1],a=n>0?e[n-1]:2*r-i,s=n<t-1?e[n+2]:2*i-r;return Bs((o-n/t)*t,a,r,i,s)}}function hc(e){var t=e.length;return function(o){var n=Math.floor(((o%=1)<0?++o:o)*t),r=e[(n+t-1)%t],i=e[n%t],a=e[(n+1)%t],s=e[(n+2)%t];return Bs((o-n/t)*t,r,i,a,s)}}var zs=e=>()=>e;function Hg(e,t){return function(o){return e+o*t}}function Gg(e,t,o){return e=Math.pow(e,o),t=Math.pow(t,o)-e,o=1/o,function(n){return Math.pow(e+n*t,o)}}function yc(e){return(e=+e)==1?mi:function(t,o){return o-t?Gg(t,o,e):zs(isNaN(t)?o:t)}}function mi(e,t){var o=t-e;return o?Hg(e,o):zs(isNaN(e)?t:e)}var gi=(function e(t){var o=yc(t);function n(r,i){var a=o((r=gn(r)).r,(i=gn(i)).r),s=o(r.g,i.g),l=o(r.b,i.b),c=mi(r.opacity,i.opacity);return function(d){return r.r=a(d),r.g=s(d),r.b=l(d),r.opacity=c(d),r+""}}return n.gamma=e,n})(1);function xc(e){return function(t){var o=t.length,n=new Array(o),r=new Array(o),i=new Array(o),a,s;for(a=0;a<o;++a)s=gn(t[a]),n[a]=s.r||0,r[a]=s.g||0,i[a]=s.b||0;return n=e(n),r=e(r),i=e(i),s.opacity=1,function(l){return s.r=n(l),s.g=r(l),s.b=i(l),s+""}}}var Bg=xc(gc),zg=xc(hc);function nt(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var Ys=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Fs=new RegExp(Ys.source,"g");function Fg(e){return function(){return e}}function Yg(e){return function(t){return e(t)+""}}function Ws(e,t){var o=Ys.lastIndex=Fs.lastIndex=0,n,r,i,a=-1,s=[],l=[];for(e=e+"",t=t+"";(n=Ys.exec(e))&&(r=Fs.exec(t));)(i=r.index)>o&&(i=t.slice(o,i),s[a]?s[a]+=i:s[++a]=i),(n=n[0])===(r=r[0])?s[a]?s[a]+=r:s[++a]=r:(s[++a]=null,l.push({i:a,x:nt(n,r)})),o=Fs.lastIndex;return o<t.length&&(i=t.slice(o),s[a]?s[a]+=i:s[++a]=i),s.length<2?l[0]?Yg(l[0].x):Fg(t):(t=l.length,function(c){for(var d=0,u;d<t;++d)s[(u=l[d]).i]=u.x(c);return s.join("")})}var Ec=180/Math.PI,hi={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Xs(e,t,o,n,r,i){var a,s,l;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(l=e*o+t*n)&&(o-=e*l,n-=t*l),(s=Math.sqrt(o*o+n*n))&&(o/=s,n/=s,l/=s),e*n<t*o&&(e=-e,t=-t,l=-l,a=-a),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*Ec,skewX:Math.atan(l)*Ec,scaleX:a,scaleY:s}}var yi;function _c(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?hi:Xs(t.a,t.b,t.c,t.d,t.e,t.f)}function bc(e){return e==null?hi:(yi||(yi=document.createElementNS("http://www.w3.org/2000/svg","g")),yi.setAttribute("transform",e),(e=yi.transform.baseVal.consolidate())?(e=e.matrix,Xs(e.a,e.b,e.c,e.d,e.e,e.f)):hi)}function Tc(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:nt(c,u)},{i:E-2,x:nt(d,p)})}else(u||p)&&f.push("translate("+u+t+p+o)}function a(c,d,u,p){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),p.push({i:u.push(r(u)+"rotate(",null,n)-2,x:nt(c,d)})):d&&u.push(r(u)+"rotate("+d+n)}function s(c,d,u,p){c!==d?p.push({i:u.push(r(u)+"skewX(",null,n)-2,x:nt(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:nt(c,u)},{i:E-2,x:nt(d,p)})}else(u!==1||p!==1)&&f.push(r(f)+"scale("+u+","+p+")")}return function(c,d){var u=[],p=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,u,p),a(c.rotate,d.rotate,u,p),s(c.skewX,d.skewX,u,p),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,p),c=d=null,function(f){for(var x=-1,E=p.length,m;++x<E;)u[(m=p[x]).i]=m.x(f);return u.join("")}}}var Us=Tc(_c,"px, ","px)","deg)"),$s=Tc(bc,", ",")",")");var hn=0,or=0,tr=0,Nc=1e3,xi,nr,Ei=0,Po=0,_i=0,rr=typeof performance=="object"&&performance.now?performance:Date,wc=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function sr(){return Po||(wc(Wg),Po=rr.now()+_i)}function Wg(){Po=0}function ir(){this._call=this._time=this._next=null}ir.prototype=bi.prototype={constructor:ir,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?sr():+o)+(t==null?0:+t),!this._next&&nr!==this&&(nr?nr._next=this:xi=this,nr=this),this._call=e,this._time=o,Ks()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ks())}};function bi(e,t,o){var n=new ir;return n.restart(e,t,o),n}function Ic(){sr(),++hn;for(var e=xi,t;e;)(t=Po-e._time)>=0&&e._call.call(void 0,t),e=e._next;--hn}function vc(){Po=(Ei=rr.now())+_i,hn=or=0;try{Ic()}finally{hn=0,Ug(),Po=0}}function Xg(){var e=rr.now(),t=e-Ei;t>Nc&&(_i-=t,Ei=e)}function Ug(){for(var e,t=xi,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:xi=o);nr=e,Ks(n)}function Ks(e){if(!hn){or&&(or=clearTimeout(or));var t=e-Po;t>24?(e<1/0&&(or=setTimeout(vc,e-rr.now()-_i)),tr&&(tr=clearInterval(tr))):(tr||(Ei=rr.now(),tr=setInterval(Xg,Nc)),hn=1,wc(vc))}}function Ti(e,t,o){var n=new ir;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var $g=ks("start","end","cancel","interrupt"),Kg=[],Sc=0,Ac=1,Ni=2,vi=3,Cc=4,wi=5,ar=6;function io(e,t,o,n,r,i){var a=e.__transition;if(!a)e.__transition={};else if(o in a)return;qg(e,o,{name:t,index:n,group:r,on:$g,tween:Kg,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Sc})}function lr(e,t){var o=Pe(e,t);if(o.state>Sc)throw new Error("too late; already scheduled");return o}function He(e,t){var o=Pe(e,t);if(o.state>vi)throw new Error("too late; already running");return o}function Pe(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function qg(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=bi(i,0,o.time);function i(c){o.state=Ac,o.timer.restart(a,o.delay,o.time),o.delay<=c&&a(c-o.delay)}function a(c){var d,u,p,f;if(o.state!==Ac)return l();for(d in n)if(f=n[d],f.name===o.name){if(f.state===vi)return Ti(a);f.state===Cc?(f.state=ar,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete n[d]):+d<t&&(f.state=ar,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete n[d])}if(Ti(function(){o.state===vi&&(o.state=Cc,o.timer.restart(s,o.delay,o.time),s(c))}),o.state=Ni,o.on.call("start",e,e.__data__,o.index,o.group),o.state===Ni){for(o.state=vi,r=new Array(p=o.tween.length),d=0,u=-1;d<p;++d)(f=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++u]=f);r.length=u+1}}function s(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=wi,1),u=-1,p=r.length;++u<p;)r[u].call(e,d);o.state===wi&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=ar,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function qs(e,t){var o=e.__transition,n,r,i=!0,a;if(o){t=t==null?null:t+"";for(a in o){if((n=o[a]).name!==t){i=!1;continue}r=n.state>Ni&&n.state<wi,n.state=ar,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[a]}i&&delete e.__transition}}function Mc(e){return this.each(function(){qs(this,e)})}function Zg(e,t){var o,n;return function(){var r=He(this,e),i=r.tween;if(i!==o){n=o=i;for(var a=0,s=n.length;a<s;++a)if(n[a].name===t){n=n.slice(),n.splice(a,1);break}}r.tween=n}}function Jg(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=He(this,e),a=i.tween;if(a!==n){r=(n=a).slice();for(var s={name:t,value:o},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=s;break}l===c&&r.push(s)}i.tween=r}}function Pc(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=Pe(this.node(),o).tween,r=0,i=n.length,a;r<i;++r)if((a=n[r]).name===e)return a.value;return null}return this.each((t==null?Zg:Jg)(o,e,t))}function yn(e,t,o){var n=e._id;return e.each(function(){var r=He(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return Pe(r,n).value[t]}}function Ii(e,t){var o;return(typeof t=="number"?nt:t instanceof ro?gi:(o=ro(t))?(t=o,gi):Ws)(e,t)}function Qg(e){return function(){this.removeAttribute(e)}}function jg(e){return function(){this.removeAttributeNS(e.space,e.local)}}function eh(e,t,o){var n,r=o+"",i;return function(){var a=this.getAttribute(e);return a===r?null:a===n?i:i=t(n=a,o)}}function th(e,t,o){var n,r=o+"",i;return function(){var a=this.getAttributeNS(e.space,e.local);return a===r?null:a===n?i:i=t(n=a,o)}}function oh(e,t,o){var n,r,i;return function(){var a,s=o(this),l;return s==null?void this.removeAttribute(e):(a=this.getAttribute(e),l=s+"",a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s)))}}function nh(e,t,o){var n,r,i;return function(){var a,s=o(this),l;return s==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),l=s+"",a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s)))}}function Lc(e,t){var o=Gt(e),n=o==="transform"?$s:Ii;return this.attrTween(e,typeof t=="function"?(o.local?nh:oh)(o,n,yn(this,"attr."+e,t)):t==null?(o.local?jg:Qg)(o):(o.local?th:eh)(o,n,t))}function rh(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function ih(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function sh(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&ih(e,i)),o}return r._value=t,r}function ah(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&rh(e,i)),o}return r._value=t,r}function Dc(e,t){var o="attr."+e;if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;var n=Gt(e);return this.tween(o,(n.local?sh:ah)(n,t))}function lh(e,t){return function(){lr(this,e).delay=+t.apply(this,arguments)}}function ch(e,t){return t=+t,function(){lr(this,e).delay=t}}function kc(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?lh:ch)(t,e)):Pe(this.node(),t).delay}function dh(e,t){return function(){He(this,e).duration=+t.apply(this,arguments)}}function uh(e,t){return t=+t,function(){He(this,e).duration=t}}function Rc(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?dh:uh)(t,e)):Pe(this.node(),t).duration}function ph(e,t){if(typeof t!="function")throw new Error;return function(){He(this,e).ease=t}}function Oc(e){var t=this._id;return arguments.length?this.each(ph(t,e)):Pe(this.node(),t).ease}function fh(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;He(this,e).ease=o}}function Vc(e){if(typeof e!="function")throw new Error;return this.each(fh(this._id,e))}function Hc(e){typeof e!="function"&&(e=Zn(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=[],l,c=0;c<a;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&s.push(l);return new Fe(n,this._parents,this._name,this._id)}function Gc(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,o=e._groups,n=t.length,r=o.length,i=Math.min(n,r),a=new Array(n),s=0;s<i;++s)for(var l=t[s],c=o[s],d=l.length,u=a[s]=new Array(d),p,f=0;f<d;++f)(p=l[f]||c[f])&&(u[f]=p);for(;s<n;++s)a[s]=t[s];return new Fe(a,this._parents,this._name,this._id)}function mh(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 gh(e,t,o){var n,r,i=mh(t)?lr:He;return function(){var a=i(this,e),s=a.on;s!==n&&(r=(n=s).copy()).on(t,o),a.on=r}}function Bc(e,t){var o=this._id;return arguments.length<2?Pe(this.node(),o).on.on(e):this.each(gh(o,e,t))}function hh(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function zc(){return this.on("end.remove",hh(this._id))}function Fc(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Co(e));for(var n=this._groups,r=n.length,i=new Array(r),a=0;a<r;++a)for(var s=n[a],l=s.length,c=i[a]=new Array(l),d,u,p=0;p<l;++p)(d=s[p])&&(u=e.call(d,d.__data__,p,s))&&("__data__"in d&&(u.__data__=d.__data__),c[p]=u,io(c[p],t,o,p,c,Pe(d,o)));return new Fe(i,this._parents,t,o)}function Yc(e){var t=this._name,o=this._id;typeof e!="function"&&(e=qn(e));for(var n=this._groups,r=n.length,i=[],a=[],s=0;s<r;++s)for(var l=n[s],c=l.length,d,u=0;u<c;++u)if(d=l[u]){for(var p=e.call(d,d.__data__,u,l),f,x=Pe(d,o),E=0,m=p.length;E<m;++E)(f=p[E])&&io(f,t,o,E,p,x);i.push(p),a.push(d)}return new Fe(i,a,t,o)}var yh=Bt.prototype.constructor;function Wc(){return new yh(this._groups,this._parents)}function xh(e,t){var o,n,r;return function(){var i=no(this,e),a=(this.style.removeProperty(e),no(this,e));return i===a?null:i===o&&a===n?r:r=t(o=i,n=a)}}function Xc(e){return function(){this.style.removeProperty(e)}}function Eh(e,t,o){var n,r=o+"",i;return function(){var a=no(this,e);return a===r?null:a===n?i:i=t(n=a,o)}}function _h(e,t,o){var n,r,i;return function(){var a=no(this,e),s=o(this),l=s+"";return s==null&&(l=s=(this.style.removeProperty(e),no(this,e))),a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s))}}function bh(e,t){var o,n,r,i="style."+t,a="end."+i,s;return function(){var l=He(this,e),c=l.on,d=l.value[i]==null?s||(s=Xc(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(a,r=d),l.on=n}}function Uc(e,t,o){var n=(e+="")=="transform"?Us:Ii;return t==null?this.styleTween(e,xh(e,n)).on("end.style."+e,Xc(e)):typeof t=="function"?this.styleTween(e,_h(e,n,yn(this,"style."+e,t))).each(bh(this._id,e)):this.styleTween(e,Eh(e,n,t),o).on("end.style."+e,null)}function Th(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function vh(e,t,o){var n,r;function i(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&Th(e,a,o)),n}return i._value=t,i}function $c(e,t,o){var n="style."+(e+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;return this.tween(n,vh(e,t,o==null?"":o))}function Nh(e){return function(){this.textContent=e}}function wh(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function Kc(e){return this.tween("text",typeof e=="function"?wh(yn(this,"text",e)):Nh(e==null?"":e+""))}function Ih(e){return function(t){this.textContent=e.call(this,t)}}function Ah(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&Ih(r)),t}return n._value=e,n}function qc(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,Ah(e))}function Zc(){for(var e=this._name,t=this._id,o=Ai(),n=this._groups,r=n.length,i=0;i<r;++i)for(var a=n[i],s=a.length,l,c=0;c<s;++c)if(l=a[c]){var d=Pe(l,t);io(l,e,o,c,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Fe(n,this._parents,e,o)}function Jc(){var e,t,o=this,n=o._id,r=o.size();return new Promise(function(i,a){var s={value:a},l={value:function(){--r===0&&i()}};o.each(function(){var c=He(this,n),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(l)),c.on=t}),r===0&&i()})}var Ch=0;function Fe(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function Qc(e){return Bt().transition(e)}function Ai(){return++Ch}var zt=Bt.prototype;Fe.prototype=Qc.prototype={constructor:Fe,select:Fc,selectAll:Yc,selectChild:zt.selectChild,selectChildren:zt.selectChildren,filter:Hc,merge:Gc,selection:Wc,transition:Zc,call:zt.call,nodes:zt.nodes,node:zt.node,size:zt.size,empty:zt.empty,each:zt.each,on:Bc,attr:Lc,attrTween:Dc,style:Uc,styleTween:$c,text:Kc,textTween:qc,remove:zc,tween:Pc,delay:kc,duration:Rc,ease:Oc,easeVarying:Vc,end:Jc,[Symbol.iterator]:zt[Symbol.iterator]};function Ci(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Sh={time:null,delay:0,duration:250,ease:Ci};function Mh(e,t){for(var o;!(o=e.__transition)||!(o=o[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return o}function jc(e){var t,o;e instanceof Fe?(t=e._id,e=e._name):(t=Ai(),(o=Sh).time=sr(),e=e==null?null:e+"");for(var n=this._groups,r=n.length,i=0;i<r;++i)for(var a=n[i],s=a.length,l,c=0;c<s;++c)(l=a[c])&&io(l,e,t,c,a,o||Mh(l,t));return new Fe(n,this._parents,e,t)}Bt.prototype.interrupt=Mc;Bt.prototype.transition=jc;function so(e,t,o){this.k=e,this.x=t,this.y=o}so.prototype={constructor:so,scale:function(e){return e===1?this:new so(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new so(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 Si=new so(1,0,0);Mi.prototype=so.prototype;function Mi(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Si;return e.__zoom}var Lh=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var ed;(function(e){e.Strict="strict",e.Loose="loose"})(ed||(ed={}));var td;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(td||(td={}));var od;(function(e){e.Partial="partial",e.Full="full"})(od||(od={}));var nd;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(nd||(nd={}));var rd;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(rd||(rd={}));var $e;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})($e||($e={}));var UT={[$e.Left]:$e.Right,[$e.Right]:$e.Left,[$e.Top]:$e.Bottom,[$e.Bottom]:$e.Top};var Dh=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var kh=(e,t=[0,0])=>{var s;let{width:o,height:n}=Rh(e),r=(s=e.origin)!=null?s:t,i=o*r[0],a=n*r[1];return{x:e.position.x-i,y:e.position.y-a}};var Pi=(e,t=[0,0])=>{var r,i,a,s,l,c,d,u;let{x:o,y:n}=Dh(e)?e.internals.positionAbsolute:kh(e,t);return{x:o,y:n,x2:o+((s=(a=(i=(r=e.measured)==null?void 0:r.width)!=null?i:e.width)!=null?a:e.initialWidth)!=null?s:0),y2:n+((u=(d=(c=(l=e.measured)==null?void 0:l.height)!=null?c:e.height)!=null?d:e.initialHeight)!=null?u:0)}};function Rh(e){var t,o,n,r,i,a,s,l;return{width:(r=(n=(o=(t=e.measured)==null?void 0:t.width)!=null?o:e.width)!=null?n:e.initialWidth)!=null?r:0,height:(l=(s=(a=(i=e.measured)==null?void 0:i.height)!=null?a:e.height)!=null?s:e.initialHeight)!=null?l:0}}var $T={[$e.Left]:{x:-1,y:0},[$e.Right]:{x:1,y:0},[$e.Top]:{x:0,y:-1},[$e.Bottom]:{x:0,y:1}};var Oh={nodeOrigin:[0,0],nodeExtent:Lh,elevateNodesOnSelect:!0,defaults:{}},KT=I(T({},Oh),{checkEquality:!0});var id;(function(e){e.Line="line",e.Handle="handle"})(id||(id={}));var Vh={width:0,height:0,x:0,y:0},qT=I(T({},Vh),{pointerX:0,pointerY:0,aspectRatio:1});var Hh=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function Gh(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 Bh(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 Li=class{constructor(){this.xLines=[];this.yLines=[]}initialize(t){this.xLines=t.filter(o=>o.orientation==="vertical"),this.yLines=t.filter(o=>o.orientation==="horizontal"),this.xLines.sort((o,n)=>o.position-n.position),this.yLines.sort((o,n)=>o.position-n.position),this.lastHorizontalLine=void 0,this.lastVerticalLine=void 0}search(t,o,n,r,i){let a=t==="horizontal"?this.yLines:this.xLines,[s,l]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],c=[];for(let f of a){if(f.position<s)continue;if(f.position>l)break;if(i.has(f.node.id)||f.node.parentId&&i.has(f.node.parentId)||!Hh(f.nodeBox,r))continue;let x=Math.abs(f.position-o);if(x>Di)continue;let m=Gh(f.nodeBox,n)>0?0:Bh(f.nodeBox,n);c.push({line:f,lineDist:x,nodeDist:m})}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 sd(e,t=Lo,o){let n=[];return e==null||e.forEach(r=>{let i=o(r.id);if(!i)throw new Error(`Node with id ${r.id} not found in internal nodes.`);let a=Pi(i);Object.entries(t).forEach(([s,l])=>{var c;n.push({position:l.resolve(r,a),color:(c=r.style)==null?void 0:c.backgroundColor,orientation:l.orientation,anchorName:s,nodeBox:a,node:r})})}),n}function ad(e,t,o,n,r=Object.keys(Lo)){let i=[];for(let s of r){let l=Lo[s],c=l.resolve(null,o),d=e.search(l.orientation,c,o,t,n);d&&i.push({sourcePosition:c,anchorName:s,anchor:l,line:d})}let a={horizontal:void 0,vertical:void 0};for(let s of i){let l=a[s.anchor.orientation],c=Math.abs(s.sourcePosition-s.line.position);(!l||c<Math.abs(l.sourcePosition-l.line.position))&&(a[s.anchor.orientation]=s)}return a}function ld(e,t,o){let n=0,r=0,i=!1,a=!1;if(t){let l=t.anchor.resolve(null,e)-t.line.position;Math.abs(l)<=Di&&(r=l,a=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=Di&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:a}}var Di=10,Lo={top:{orientation:"horizontal",resolve:(e,t)=>t.y},bottom:{orientation:"horizontal",resolve:(e,t)=>t.y2},left:{orientation:"vertical",resolve:(e,t)=>t.x},right:{orientation:"vertical",resolve:(e,t)=>t.x2},centerX:{orientation:"vertical",resolve:(e,t)=>(t.x+t.x2)/2},centerY:{orientation:"horizontal",resolve:(e,t)=>(t.y+t.y2)/2}};var ud=require("react/jsx-runtime"),zh=new Li;function Fh(e,t,o,n){var d,u,p,f,x,E;let r=1/0,i=1/0,a=-1/0,s=-1/0,l=new Set;for(let m of e){let h=t.find(w=>w.id===m.id);if(!h)continue;l.add(h.id);let g=o(h.id);if(!g)continue;let y=g.parentId?o(g.parentId):void 0,v=m.position.x+((d=y==null?void 0:y.internals.positionAbsolute.x)!=null?d:0),_=m.position.y+((u=y==null?void 0:y.internals.positionAbsolute.y)!=null?u:0),N=(f=(p=h.measured)==null?void 0:p.width)!=null?f:0,b=(E=(x=h.measured)==null?void 0:x.height)!=null?E:0;r=Math.min(r,v),i=Math.min(i,_),a=Math.max(a,v+N),s=Math.max(s,_+b)}if(r===1/0)return null;let c=Object.keys(Lo);return{bounds:{x:r,y:i,x2:a,y2:s},excludedNodeIds:l,anchors:n?["top","left"]:c}}function Yh(e,t,o){var c,d,u,p,f,x,E,m;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,a=r.internals.positionAbsolute.y,s=(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:(x=n.measured)==null?void 0:x.height)!=null?m:0;return{bounds:{x:i,y:a,x2:i+s,y2:a+l},excludedNodeIds:new Set([n.id]),anchors:["right","bottom"]}}function Wh(e,t,o,n){return e.length>0?Fh(e,o,n,!!t):t?Yh(t,o,n):null}function cd(e,t,o,n){var r;e!=null&&e.dimensions&&(e.id===((r=t[0])==null?void 0:r.id)?e.dimensions[o]+=n:t.length||(e.dimensions[o]-=n))}function Xh(e,t,o,n,r,i){r&&(e.forEach(a=>{a.position&&(a.position.x-=o)}),cd(t,e,"width",o)),i&&(e.forEach(a=>{a.position&&(a.position.y-=n)}),cd(t,e,"height",n))}function ki(){let[e,t]=(0,Ze.useState)(void 0),[o,n]=(0,Ze.useState)(void 0),{width:r,height:i}=(0,xn.useStore)(m=>({width:m.width,height:m.height}),dd.shallow),a=(0,xn.useNodesInitialized)(),s=(0,Ze.useRef)(zh),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=(0,xn.useReactFlow)(),u=(0,Ze.useCallback)(()=>{t(void 0),n(void 0)},[]),p=(0,Ze.useCallback)(m=>{let h=m!=null?m:d();u();let g=sd(h,Lo,c);s.current.initialize(g)},[c,u,d]),f=(0,Ze.useCallback)(()=>{setTimeout(()=>{p()},100)},[p]);(0,Ze.useEffect)(()=>{a&&p(d())},[a,p,d]);let x=(0,Ze.useCallback)((m,h)=>{if(!s.current||m.length===0)return;let g=m.filter(C=>C.type==="dimensions");if(g.length>1)return;u();let y=m.filter(C=>C.type==="position"&&!!C.position),v=g[0];if(y.length===0&&!v)return;let _=Wh(y,v,h,c);if(!_)return;let{x:N,y:b}=l({x:0,y:0}),{x:w,y:S}=l({x:r,y:i}),M={x:N,y:b,x2:w,y2:S},{horizontal:L,vertical:D}=ad(s.current,M,_.bounds,_.excludedNodeIds,_.anchors),{deltaX:O,deltaY:R,snappedX:V,snappedY:G}=ld(_.bounds,L,D);if(!V&&!G)return;let B=y.some(C=>C.dragging),A=!!(v!=null&&v.resizing);(B||A)&&(V&&n(D==null?void 0:D.line),G&&t(L==null?void 0:L.line)),Xh(y,v,O,R,V,G)},[l,c,r,i,t,n,u]),E=(0,Ze.useCallback)(()=>(0,ud.jsx)(pd,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:p,forceRebuildIndex:f,updateHelperLines:x,helperLineHorizontal:e,helperLineVertical:o,HelperLines:E}}var us=require("@xyflow/react"),Lt=require("react");var Ft=e=>new Map(e.map(t=>[t.id,t])),cr=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),fd=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),Zs=e=>e.some(t=>t.type==="START_EVENT"),En=(e,t)=>e==="START_EVENT"?!Zs(t):!0,md=(e,t,o,n,r)=>{let i=Ft(o),a=i.get(e);if(!a||a.type!=="START_EVENT")return!1;let s=i.get(t);return(s==null?void 0:s.type)==="ANNOTATION"?!1:cr(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},gd=(e,t,o,n,r)=>{let i=Ft(o),a=i.get(t);if(!a||a.type!=="END_EVENT")return!1;let s=i.get(e);return(s==null?void 0:s.type)==="ANNOTATION"?!1:fd(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Ri=(e,t,o,n,r)=>{var c;let i=Ft(o),a=i.get(e);if(!a||a.type!=="GATEWAY"||((c=a.data)==null?void 0:c.variant)!=="EXCLUSIVE")return!1;let s=t?i.get(t):null;return(s==null?void 0:s.type)==="ANNOTATION"?!1:cr(e,n,r).filter(d=>{let u=i.get(d.target);return(u==null?void 0:u.type)!=="ANNOTATION"}).length>=2},hd=(e,t,o)=>{var a,s,l,c;let n=Ft(o),r=n.get(e),i=n.get(t);return(r==null?void 0:r.type)!=="GATEWAY"||(i==null?void 0:i.type)!=="GATEWAY"||((a=r==null?void 0:r.data)==null?void 0:a.variant)==="EXCLUSIVE"&&((s=i==null?void 0:i.data)==null?void 0:s.variant)==="PARALLEL"||((l=r==null?void 0:r.data)==null?void 0:l.variant)==="COMPLEX"&&((c=i==null?void 0:i.data)==null?void 0:c.variant)==="PARALLEL"},Oi=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SCRIPT"},yd=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SUBPROCESS"},dr=(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"},Vi=(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"},Do=(e,t,o,n)=>{let r=Ft(t),i=r.get(e);return!i||i.type!=="TASK"?!1:fd(e,o,n).some(s=>{let l=r.get(s.source);return(l==null?void 0:l.type)==="START_EVENT"})},ur=(e,t,o,n)=>{let r=Ft(t),i=r.get(e);return!i||i.type!=="TASK"?!1:cr(e,o,n).some(s=>{let l=r.get(s.target);return(l==null?void 0:l.type)==="END_EVENT"})},xd=(e,t,o,n,r)=>{let i=Ft(o),a=i.get(e),s=i.get(t);return(a==null?void 0:a.type)==="START_EVENT"&&(s==null?void 0:s.type)==="TASK"?ur(t,o,n,r):(s==null?void 0:s.type)==="END_EVENT"&&(a==null?void 0:a.type)==="TASK"?Do(e,o,n,r):!1},Hi=(e,t,o)=>cr(e,t,o).length>0,Gi=(e,t,o,n,r)=>{let i=Ft(o),a=i.get(e);if(!a||a.type!=="TASK")return!1;let s=t?i.get(t):null;return(s==null?void 0:s.type)==="ANNOTATION"?!1:cr(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var Ed=(e,t,o,n,r)=>{var s,l;let i=Ft(n),a=((s=i.get(e))==null?void 0:s.type)==="ANNOTATION"||((l=i.get(t))==null?void 0:l.type)==="ANNOTATION";return o.some(c=>r&&c.id===r?!1:!!(c.source===e&&c.target===t||a&&c.source===t&&c.target===e))};var Uh=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!Ed(e.sourceNodeId,e.targetNodeId,e.edges,e.nodes,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!md(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!gd(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!Ri(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!Gi(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:hd(e.sourceNodeId,e.targetNodeId,e.nodes),reason:"gateway_to_gateway_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&e.targetNodeType==="END_EVENT"),reason:"start_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&yd(e.targetNodeId,e.nodes)),reason:"start_event_to_subprocess_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&dr(e.targetNodeId,e.nodes)),reason:"start_event_to_service_task_not_allowed"}),e=>({isValid:!(dr(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:!(Oi(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(Vi(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(Do(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!xd(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(ur(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(Hi(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"})],Js=e=>{for(let t of Uh){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var $h=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:Ri(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:Zs(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Oi(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Vi(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:dr(e.sourceNodeId,e.nodes),reason:"service_task_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Do(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:ur(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Hi(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Gi(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],_d=e=>{let t=$h.filter(o=>{let n=!o.sourceTypes||o.sourceTypes.includes(e.sourceNodeType),r=!o.targetTypes||o.targetTypes.includes(e.targetNodeType);return n&&r});for(let o of t){let n=o.validate(e);if(n.shouldDisable)return n}return{shouldDisable:!1}};var rt={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:"arrowclosed"},markerEnd:{type:"arrow"},data:{label:""}},_n={type:"ANNOTATION_EDGE",reconnectable:!0,data:{label:""}};var wr=require("react"),hp=require("use-debounce");var gp=require("@xyflow/react"),Nr=require("react");var pr=(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))(pr||{});var ea=Wn(require("@dagrejs/dagre"),1);var Bi={MIN_WIDTH:36,DEFAULT_WIDTH:36,MIN_HEIGHT:36,DEFAULT_HEIGHT:36},zi={MIN_WIDTH:36,DEFAULT_WIDTH:36,MIN_HEIGHT:36,DEFAULT_HEIGHT:36},bn={MIN_WIDTH:40,DEFAULT_WIDTH:56,MIN_HEIGHT:40,DEFAULT_HEIGHT:56},Yt={MIN_WIDTH:60,DEFAULT_WIDTH:176,MIN_HEIGHT:60,DEFAULT_HEIGHT:96},bd={HEADER_WIDTH:40,MIN_WIDTH:150,DEFAULT_WIDTH:840,MIN_HEIGHT:150,DEFAULT_HEIGHT:256},J={HEADER_WIDTH:40,MIN_WIDTH:150,DEFAULT_WIDTH:800,MIN_HEIGHT:150,DEFAULT_HEIGHT:256},ko={MIN_WIDTH:40,DEFAULT_WIDTH:176,MIN_HEIGHT:40,DEFAULT_HEIGHT:64},Kh={MIN_WIDTH:126,DEFAULT_WIDTH:128,MIN_HEIGHT:60,DEFAULT_HEIGHT:64},te={START_EVENT:Bi,END_EVENT:zi,GATEWAY:bn,TASK:Yt,LANE:J,ANNOTATION:ko,UNSUPPORTED:Kh};var qh=50,Ro=(e,t)=>{var p,f,x,E,m,h,g,y,v,_,N,b,w,S,M,L;let o=t.find(D=>D.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=(m=o.measured)==null?void 0:m.width)!=null?h:0,a=(y=(g=o.measured)==null?void 0:g.height)!=null?y:0,s=r+a,l=n+i,c=new Set,d=1/0;for(let D of t){if(D.id===e||D.parentId)continue;let O=(_=(v=D.position)==null?void 0:v.y)!=null?_:0,R=(b=(N=D.position)==null?void 0:N.x)!=null?b:0,V=(S=(w=D.measured)==null?void 0:w.width)!=null?S:0,G=(L=(M=D.measured)==null?void 0:M.height)!=null?L:0;R<l&&R+V>n&&O<s&&O+G>r&&(c.add(D.id),d=Math.min(d,O))}if(c.size===0)return t;let u=s+qh-d;return t.map(D=>{var R,V,G;if(!c.has(D.id))return D;let O=(V=(R=D.position)==null?void 0:R.y)!=null?V:0;return I(T({},D),{position:I(T({},(G=D.position)!=null?G:{x:0,y:0}),{y:O+u})})})},Te=15,Oo=e=>[...e].sort((t,o)=>t.position.y-o.position.y),Zh=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)},Jh=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)},Qs=(e,t,o)=>{var d,u,p,f,x,E,m,h,g,y,v,_,N,b,w,S,M,L,D,O,R;if(t.length===0){let V=I(T({},e),{width:(p=(u=e.width)!=null?u:(d=e.measured)==null?void 0:d.width)!=null?p:J.MIN_WIDTH,height:(E=(x=e.height)!=null?x:(f=e.measured)==null?void 0:f.height)!=null?E:J.MIN_HEIGHT});return o.set(e.id,V),V}let n=(g=(h=e.width)!=null?h:(m=e.measured)==null?void 0:m.width)!=null?g:0,r=(_=(v=e.height)!=null?v:(y=e.measured)==null?void 0:y.height)!=null?_:0,i=0,a=0;for(let V of t){let G=Zh(V),B=Jh(V);if(((b=(N=V.position)==null?void 0:N.y)!=null?b:0)<Te&&(o.set(V.id,I(T({},V),{position:I(T({},V.position),{y:Te})})),B=Te+((S=(w=V.measured)==null?void 0:w.height)!=null?S:0)),((L=(M=V.position)==null?void 0:M.x)!=null?L:0)<J.HEADER_WIDTH+Te){let A=(D=o.get(V.id))!=null?D:V;o.set(V.id,I(T({},A),{position:I(T({},A.position),{x:J.HEADER_WIDTH+Te})})),G=J.HEADER_WIDTH+Te+((R=(O=V.measured)==null?void 0:O.width)!=null?R:0)}i=Math.max(i,G),a=Math.max(a,B)}let s=Math.max(n,J.MIN_WIDTH),l=Math.max(r,J.MIN_HEIGHT);i+Te>s&&(s=i+Te),a+Te>l&&(l=a+Te);let c=I(T({},e),{width:s,height:l,measured:I(T({},e.measured),{width:s,height:l})});return o.set(e.id,c),c},Td=(e,t,o)=>{var a,s,l,c;let n=Oo(e),r=new Map;for(let d of o)d.parentId&&(r.has(d.parentId)||r.set(d.parentId,[]),r.get(d.parentId).push(d));let i=0;for(let d of n){let u=(a=r.get(d.id))!=null?a:[],p=Qs(d,u,t);t.set(p.id,I(T({},p),{position:{x:J.HEADER_WIDTH,y:i}})),i+=(c=(l=p.height)!=null?l:(s=p.measured)==null?void 0:s.height)!=null?c:0}},vd=(e,t)=>{var x,E,m,h,g,y;let o=[];for(let v of t.values())v.parentId===e.id&&o.push(v);let n=Oo(o),r=((E=(x=e.measured)==null?void 0:x.width)!=null?E:0)-J.HEADER_WIDTH,i=cl(e.id,o)||J.MIN_WIDTH,a=o.reduce((v,_)=>{var N,b,w;return v+((w=(b=_.height)!=null?b:(N=_.measured)==null?void 0:N.height)!=null?w:J.MIN_HEIGHT)},0),s=Math.max(r,i),l=a,c=r>i,d=c?s:s+J.HEADER_WIDTH,u=c?s-J.HEADER_WIDTH:s,p=0;for(let v=0;v<n.length;v++){let _=n[v],N=Math.max(J.MIN_HEIGHT,(g=(h=_.height)!=null?h:(m=_.measured)==null?void 0:m.height)!=null?g:J.MIN_HEIGHT),b=I(T({},_),{width:u,height:N,measured:I(T({},_.measured),{width:u,height:N}),position:{x:J.HEADER_WIDTH,y:p}});if(v===o.length-1){let w=Math.max(J.MIN_HEIGHT,l-p);b=I(T({},b),{height:w,measured:I(T({},_.measured),{width:u,height:w})})}t.set(_.id,b),p+=(y=b.height)!=null?y:0}let f=Math.max(l,p);t.set(e.id,I(T({},e),{width:d,height:f,measured:I(T({},e.measured),{width:d,height:f})}))},Nd=(e,t,o,n,r)=>{var x,E;let i=!e.parentId,a=i?e.id:e.parentId,s=n.filter(m=>m.type==="LANE"&&m.parentId===a);if(!s.length)return n;let l=Oo(s),c=l.findIndex(m=>m.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((m,h)=>{var N,b;let g=h===l.length-1,y=m.id===e.id,_=(b=(N=m.measured)==null?void 0:N.height)!=null?b:0;y?_=o:u&&h===c-1&&(_=Math.max(J.MIN_HEIGHT,r-p)),g&&i&&(_=Math.max(J.MIN_HEIGHT,o-p)),f=f.map(w=>{if(w.id===m.id){let S=i?t-J.HEADER_WIDTH:t;return I(T({},w),{width:S,height:_,measured:I(T({},w.measured),{width:S,height:_}),position:{x:J.HEADER_WIDTH,y:p}})}return w}),y&&u?p=r+o:p+=_}),f=f.map(m=>{if(m.id===a){let h=i?t:t+J.HEADER_WIDTH;return I(T({},m),{width:h,height:i?o:p,measured:{width:h,height:i?o:p}})}return m}),f};var js=(e,t,o)=>{var s,l,c,d,u,p,f,x;if(e.type==="LANE")return o;let n=(l=(s=t.measured)==null?void 0:s.width)!=null?l:0,r=(d=(c=t.measured)==null?void 0:c.height)!=null?d:0;e.position.y<Te&&(e.position.y=Te),e.position.x<J.HEADER_WIDTH+Te&&(e.position.x=J.HEADER_WIDTH+Te);let i=e.position.x+((p=(u=e.measured)==null?void 0:u.width)!=null?p:0),a=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),a+Te>r&&(t.height=a+Te,t.measured.height=a+Te),o=o.map(E=>E.id===t.id?I(T({},E),{height:t.height,width:t.width,measured:t.measured}):E.id===e.id?I(T({},E),{position:e.position}):E),o},wd=e=>{var i,a;let t=e.filter(s=>s.type==="LANE");if(t.length===0)return e;let o=new Map(e.map(s=>[s.id,No(s.id,e)])),n=s=>{var p,f,x,E,m,h,g;let{x:l,y:c}=(p=o.get(s.id))!=null?p:{x:0,y:0},d=(E=(x=(f=s.measured)==null?void 0:f.width)!=null?x:s.width)!=null?E:0,u=(g=(h=(m=s.measured)==null?void 0:m.height)!=null?h:s.height)!=null?g:0;return{x1:l,y1:c,x2:l+d,y2:c+u,w:d,h:u}},r=new Map;for(let s of e){if(s.type==="LANE")continue;let{x1:l,y1:c,w:d,h:u}=n(s),p=l+d/2,f=c+u/2,x=t.filter(g=>{let{x1:y,x2:v,y1:_,y2:N}=n(g);return p>=y&&p<=v&&f>=_&&f<=N});if(x.length===0)continue;let E=x.reduce((g,y)=>{if(!g)return y;let v=!!g.parentId,_=!!y.parentId;if(_&&!v)return y;if(!_&&v)return g;let{x1:N,y1:b,w,h:S}=n(g),{x1:M,y1:L,w:D,h:O}=n(y),R=Math.hypot(N+w/2-p,b+S/2-f);return Math.hypot(M+D/2-p,L+O/2-f)<R?y:g},null);if(!E||s.parentId===E.id)continue;let m=(i=o.get(s.id))!=null?i:{x:0,y:0},h=(a=o.get(E.id))!=null?a:{x:0,y:0};r.set(s.id,{parentId:E.id,position:{x:m.x-h.x,y:m.y-h.y}})}return r.size===0?e:e.map(s=>{let l=r.get(s.id);return l?I(T({},s),{parentId:l.parentId,position:l.position}):s})};var Fi=(e=[],t=[],o="LR")=>{let n=new ea.default.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:i,width:a,height:s})=>n.setNode(i,{width:a,height:s})),t.forEach(i=>n.setEdge(i.source,i.target)),ea.default.layout(n),{nodes:e.map(i=>{let a=n.node(i.id);return I(T({},i),{position:{x:a.x-i.width/2,y:a.y-i.height/2}})}),edges:t}},Wt=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId);if(t.length===0)return e;let o=sl(e);for(let n of t){let r=[...o.values()],i=r.filter(s=>s.parentId===n.id);if(i.length===0)continue;let a=i.filter(s=>s.type==="LANE");if(a.length>0){Td(a,o,r),vd(n,o);continue}Qs(n,i,o)}return al(e,o)},Id=Wt,Ad=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)};var fr=1,Cd=e=>`<mxGraphModel>
|
|
1
|
+
"use strict";var gm=Object.create;var Wn=Object.defineProperty,hm=Object.defineProperties,ym=Object.getOwnPropertyDescriptor,xm=Object.getOwnPropertyDescriptors,Em=Object.getOwnPropertyNames,Fr=Object.getOwnPropertySymbols,_m=Object.getPrototypeOf,As=Object.prototype.hasOwnProperty,Fa=Object.prototype.propertyIsEnumerable;var za=(e,t,o)=>t in e?Wn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,T=(e,t)=>{for(var o in t||(t={}))As.call(t,o)&&za(e,o,t[o]);if(Fr)for(var o of Fr(t))Fa.call(t,o)&&za(e,o,t[o]);return e},I=(e,t)=>hm(e,xm(t));var bt=(e,t)=>{var o={};for(var n in e)As.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Fr)for(var n of Fr(e))t.indexOf(n)<0&&Fa.call(e,n)&&(o[n]=e[n]);return o};var bm=(e,t)=>{for(var o in t)Wn(e,o,{get:t[o],enumerable:!0})},Ya=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Em(t))!As.call(e,r)&&r!==o&&Wn(e,r,{get:()=>t[r],enumerable:!(n=ym(t,r))||n.enumerable});return e};var Xn=(e,t,o)=>(o=e!=null?gm(_m(e)):{},Ya(t||!e||!e.__esModule?Wn(o,"default",{value:e,enumerable:!0}):o,e)),Tm=e=>Ya(Wn({},"__esModule",{value:!0}),e);var Ax={};bm(Ax,{EditorMode:()=>xe,ElementPosition:()=>Wr,ElementType:()=>Un,GatewayElementVariant:()=>Xr,GatewayVariant:()=>qe,Modeler:()=>cm,ModelerProvider:()=>im,NodeAttribute:()=>pt,NodeType:()=>Q,NodeVariant:()=>Xe,RoutingVariant:()=>Ur,useModeler:()=>Sn});module.exports=Tm(Ax);var Cs=e=>{if(typeof document=="undefined")return;let t=document.cookie.match(new RegExp(`(?:^|; )${e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")}=([^;]*)`));return t?decodeURIComponent(t[1]):void 0};var Yr=require("@produto-lecom/lecom-ui");var Wa={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Delete",deleting:"Deleting...",configure_node:"Configure activity",configure_edge:"Configure routing",configure_gateway:"Configure routing",initial_task:"Initial Activity",gateway_limit_reached:"Exclusive gateway cannot have more than 2 outgoing connections",task_limit_reached:"Task cannot have more than 2 outgoing connections",start_event_limit_reached:"Start event can only connect to a single element",gateway_to_gateway_not_allowed:"Gateways cannot connect directly to other gateways",start_event_already_exists:"A start event already exists. Delete the current event to add another",script_to_end_not_allowed:"Script activities cannot connect directly to the end event",loop_to_end_not_allowed:"Loop activities cannot connect directly to the end event",initial_activity_to_end_not_allowed:"Initial activity cannot connect directly to the end event",final_activity_cannot_connect:"Final activity cannot connect to other elements",activity_has_outgoing_connections:"Activity with outgoing connections cannot connect to end event",end_event_cannot_connect_to_initial_activity:"End event cannot connect to an initial activity",initial_activity_cannot_connect_to_start_event:"Initial activity cannot connect to start event",concurrent_initial_and_final_activity:"An activity cannot be connected to both start and end events",start_event_to_service_task_not_allowed:"Start event cannot connect to an automatic activity",service_task_to_end_not_allowed:"Automatic activities cannot connect to the end event",duplicate_connection_not_allowed:"A connection already exists between these elements",connect_node:"Connect element",connecting:"Connecting...",delete_pool_lane_error:"Cannot delete the pool or lane while there are elements inside it.",delete_elements_blocked:"One or more activities cannot be deleted because there are in-progress processes in the Workspace linked to them.",delete_elements_error:"An error occurred. Please try again later."},controls:{zoom:{fit:"Fit zoom",in:"Zoom in",out:"Zoom out",reset:"Reset zoom"},actions:{move_tool:"Select elements",hand_tool:"Navigate the diagram",check:"Check diagram",check_loading:"Validating diagram...",export:{title:"Export diagram",print:"Print",html:"Export as HTML",png:"Export as PNG",feedback:{empty:"Cannot export an empty diagram",error:"Error exporting diagram"}},import_governance:"Import diagram from Governance platform",import_mermaid:"Import Mermaid",import:{title:"Import",xml:"XML",mermaid:"Mermaid",governance:"Governance",feedback:{error:"Could not import the file. Check its content."}},organize:{title:"Align diagram",vertical:"Vertical (top-down)",horizontal:"Horizontal (left-right)",feedback:{pool_lane:"Diagrams with pools or lanes cannot be arranged automatically."}},minimap:{label:"Minimap",open:"Open minimap",close:"Hide minimap"}},history:{undo:"Undo",redo:"Redo"}},modals:{mermaid_import:{title:"Import diagram from Mermaid",description:"Paste the Mermaid text (in the format supported by the modeler) to generate the diagram.",generate:"Generate",cancel:"Cancel",error_empty:"Paste the diagram text before generating.",error_parse:"Could not generate the diagram. Check the pasted text."},import_confirm:{title:"Replace the current diagram?",content:"Importing will replace the entire current diagram. Continue?",confirm:"Import",loading:"Importing...",cancel:"Cancel"},delete_elements:{title:"Delete elements",callout:"When deleting, the activity and routing settings will be deleted.",content:"Are you sure you want to delete?",confirm:"Delete",cancel:"Cancel"}},task_menu:{loop_not_allowed_when_connected_to_end:"Cannot create loop on activity connected to end event",script_not_allowed_when_connected_to_end:"Cannot transform to Script activity connected to end event",loop_not_allowed_when_subprocess:"Cannot create loop on subprocess",loop_not_allowed_when_service_task:"Cannot create loop on automatic activity",loop:"Activity with loop"}},validation:{success:{title:"Validation Successful",message:"The diagram was validated successfully with no errors."},errors:{title:"The diagram contains errors",subtitle:"Please review the following:",task_label_length:"Task name exceeds the maximum character limit",multiple_start_event_not_allowed:"Multiple start events are not allowed",task_flows_limit_exceeds:"The number of output connections exceeds the limit of two",duplicate_task_name:"There are multiple activities with the same name",flows_on_end_tasks_not_allowed:"Activities connected to end events cannot have other connections",conditions_flows_limit_exceeds:"Exclusive gateway has too many output connections (maximum of two)",task_label_empty:"One or more activities have no name",activity_name_invalid:"Activity name is invalid",final_activity_has_loop:"Final activities cannot have loops",nested_gateway:"Connecting gateways directly is not allowed",concurrent_initial_and_final_event:"The same activity cannot have both initial and final events",gateway_flow_to_event:"Connecting a gateway to an output event is not allowed",gateway_missing_output_streams:"One or more gateways do not have the correct number of outputs",events_nested:"Connecting events directly is not allowed",event_to_condition:"Connecting an event directly to a gateway is not allowed",script_in_final_activity:"Final activity cannot be a script type",subprocess_not_configured:"The subprocess reference is not properly configured in one or more activities",cannot_validate_subprocess_reference:"Could not validate the subprocess reference in one or more activities",start_event_not_found:"A start event is required",end_event_not_found:"At least one end event is required",service_task_without_rejection_routing:"Automated activity (RPA) without rejection routing configured",service_task_without_automation:"Automated activity (RPA) without a configured robot",service_task_connector_inactive:"Automated activity (RPA) linked to an inactive connector",service_task_integration_suspended:"Automated activity (RPA) linked to a suspended integration",service_task_automation_status_unavailable:"Could not verify the automation (RPA) status",service_task_initial_or_final:"Automated activity (RPA) cannot be an initial, final or concentrator step",service_task_in_loop:"Automated activity (RPA) cannot be in a loop"}},bpmn:{start_event:{variant:{default:"Start event"}},end_event:{variant:{default:"End event"}},annotation:{variant:{default:"Annotation"}},gateway:{menu:{title:"Change gateway type"},variant:{default:"Gateway",exclusive:"Exclusive gateway",parallel:"Parallel gateway",complex:"Complex gateway"}},task:{menu:{title:"Change task type"},variant:{default:"Task",script:"Script task",subprocess:"Subprocess",service_task:"RPA"},attribute:{loop:"Task with loop"},label:{prefix:"Activity"},feedback:{label_empty:{prefix:"Activity name was automatically set to"},label_already_exists:{prefix:"The name",middle:"already exists. The name was changed to"},invalid_first_character:"Activity name must start with a letter or number"}},lane:{variant:{default:"Pool / Lane"}},unsupported:{variant:{default:"Unsupported element"}}},adapter:{governance:{error:{DEFAULT:"Error importing diagram",NO_FILE:"No file selected",EMPTY_FILE:"Empty file",INVALID_FILE:"Invalid file",CONTAIN_NO_CELLS:"No cells found to be imported",ALREADY_INITIALIZED:"Importing from the Governance platform is only allowed in diagrams without elements. To import, delete the current diagram"},success:{default:"The diagram was imported from the Governance platform successfully and without any incompatibility detected.",incompatible_cells:"The diagram was imported from the Governance platform with incompatibilities. To know more details, click on the button below."},report:{columns:{type:"Type",value:"Value",status:"Status"},status:{imported:"Imported",adapted:"Adapted",unsupported:"Unsupported"}},action:{download:"Download report"}}}}};var Xa={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",deleting:"Eliminando...",configure_node:"Configurar actividad",configure_edge:"Configurar enrutamiento",configure_gateway:"Configurar enrutamiento",initial_task:"Actividad Inicial",gateway_limit_reached:"Compuerta exclusiva no puede tener m\xE1s de 2 conexiones de salida",task_limit_reached:"Actividad no puede tener m\xE1s de 2 conexiones de salida",start_event_limit_reached:"Evento inicial solo puede conectarse a un \xFAnico elemento",gateway_to_gateway_not_allowed:"Las compuertas no pueden conectarse directamente con otras compuertas",start_event_already_exists:"Ya existe un evento de inicio. Elimine el evento actual para agregar otro",script_to_end_not_allowed:"Las actividades Script no pueden conectarse directamente al evento final",loop_to_end_not_allowed:"Las actividades Loop no pueden conectarse directamente al evento final",initial_activity_to_end_not_allowed:"Actividad inicial no puede conectarse directamente al evento final",final_activity_cannot_connect:"Actividad final no puede conectarse a otros elementos",activity_has_outgoing_connections:"Actividad con conexiones de salida no puede conectarse al evento final",end_event_cannot_connect_to_initial_activity:"El evento final no puede conectarse a una actividad inicial",initial_activity_cannot_connect_to_start_event:"Actividad inicial no puede conectarse a evento de inicio",concurrent_initial_and_final_activity:"Una actividad no puede estar conectada al evento inicial y final al mismo tiempo",start_event_to_service_task_not_allowed:"El evento inicial no puede conectarse a una actividad autom\xE1tica",service_task_to_end_not_allowed:"Las actividades autom\xE1ticas no pueden conectarse al evento final",duplicate_connection_not_allowed:"Ya existe una conexi\xF3n entre estos elementos",connect_node:"Conectar elemento",connecting:"Conectando...",delete_pool_lane_error:"No se puede eliminar la piscina o carril mientras haya elementos dentro.",delete_elements_blocked:"No se pueden eliminar una o m\xE1s actividades porque existen procesos en curso en el Workspace vinculados a ellas.",delete_elements_error:"Ocurri\xF3 un error. Int\xE9ntelo de nuevo m\xE1s tarde."},controls:{zoom:{fit:"Ajustar zoom",in:"Acercar",out:"Alejar",reset:"Restablecer zoom"},actions:{move_tool:"Seleccionar elementos",hand_tool:"Navegar por el diagrama",check:"Validar diagrama",check_loading:"Validando diagrama...",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"No es posible exportar un diagrama vac\xEDo",error:"Error al exportar diagrama"}},import_governance:"Importar diagrama de la plataforma Governance",import_mermaid:"Importar Mermaid",import:{title:"Importar",xml:"XML",mermaid:"Mermaid",governance:"Governance",feedback:{error:"No fue posible importar el archivo. Verifique el contenido."}},organize:{title:"Alinear diagrama",vertical:"Vertical (de arriba hacia abajo)",horizontal:"Horizontal (de izquierda a derecha)",feedback:{pool_lane:"No es posible ordenar autom\xE1ticamente diagramas con piscinas o carriles."}},minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Deshacer",redo:"Rehacer"}},modals:{mermaid_import:{title:"Importar diagrama a partir de Mermaid",description:"Pegue el texto Mermaid (en el formato compatible con el modelador) para generar el diagrama.",generate:"Generar",cancel:"Cancelar",error_empty:"Pegue el texto del diagrama antes de generar.",error_parse:"No fue posible generar el diagrama. Verifique el texto pegado."},import_confirm:{title:"\xBFReemplazar el diagrama actual?",content:"Importar reemplazar\xE1 todo el diagrama actual. \xBFDesea continuar?",confirm:"Importar",loading:"Importando...",cancel:"Cancelar"},delete_elements:{title:"Eliminar elementos",callout:"Al eliminar, las configuraciones de actividades y enrutamiento ser\xE1n eliminadas.",content:"\xBFEst\xE1s seguro de querer eliminar?",confirm:"Eliminar",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"No se puede crear bucle en actividad conectada al evento final",script_not_allowed_when_connected_to_end:"No se puede transformar a Script actividad conectada al evento final",loop_not_allowed_when_subprocess:"No se puede crear bucle en subproceso",loop_not_allowed_when_service_task:"No se puede crear bucle en actividad autom\xE1tica",loop:"Actividad con loop"}},validation:{success:{title:"Validaci\xF3n exitosa",message:"El diagrama ha sido validado correctamente sin errores."},errors:{title:"El diagrama contiene errores",subtitle:"Revise lo siguiente:",task_label_length:"El nombre de la actividad excede el l\xEDmite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"No se permite tener m\xE1s de un evento de inicio",task_flows_limit_exceeds:"El n\xFAmero de conexiones de salida supera el l\xEDmite de dos",duplicate_task_name:"Hay varias actividades con el mismo nombre",flows_on_end_tasks_not_allowed:"Las actividades conectadas a eventos finales no pueden tener otras conexiones",conditions_flows_limit_exceeds:"Compuerta exclusiva con exceso de conexiones de salida (m\xE1ximo de dos)",task_label_empty:"El nombre de una o m\xE1s actividades no ha sido completado",activity_name_invalid:"El nombre de la actividad no es v\xE1lido",final_activity_has_loop:"Las actividades finales no pueden tener bucles",nested_gateway:"No se permite conectar compuertas directamente",concurrent_initial_and_final_event:"Una misma actividad no puede tener eventos iniciales y finales",gateway_flow_to_event:"No se permite conectar una compuerta a un evento de salida",gateway_missing_output_streams:"Una o m\xE1s compuertas no tienen el n\xFAmero correcto de salidas",events_nested:"No se permite conectar eventos directamente",event_to_condition:"No se permite conectar un evento directamente a una compuerta",script_in_final_activity:"La actividad final no puede ser de tipo script",subprocess_not_configured:"La referencia al subproceso no est\xE1 configurada correctamente en una o m\xE1s actividades",cannot_validate_subprocess_reference:"No fue posible validar la referencia al subproceso en una o m\xE1s actividades",start_event_not_found:"Es necesario tener un evento de inicio",end_event_not_found:"Es necesario tener al menos un evento final",service_task_without_rejection_routing:"Actividad autom\xE1tica (RPA) sin enrutamiento de rechazo configurado",service_task_without_automation:"Actividad autom\xE1tica (RPA) sin robot configurado",service_task_connector_inactive:"Actividad autom\xE1tica (RPA) vinculada a un conector inactivo",service_task_integration_suspended:"Actividad autom\xE1tica (RPA) vinculada a una integraci\xF3n suspendida",service_task_automation_status_unavailable:"No se pudo verificar el estado de la automatizaci\xF3n (RPA)",service_task_initial_or_final:"La actividad autom\xE1tica (RPA) no puede ser etapa inicial, final o concentradora",service_task_in_loop:"La actividad autom\xE1tica (RPA) no puede estar en un bucle"}},bpmn:{start_event:{variant:{default:"Evento de inicio"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anotaci\xF3n"}},gateway:{menu:{title:"Cambiar tipo de compuerta"},variant:{default:"Compuerta",exclusive:"Compuerta exclusiva",parallel:"Compuerta paralela",complex:"Compuerta compleja"}},task:{menu:{title:"Cambiar tipo de tarea"},variant:{default:"Tarea",script:"Tarea de script",subprocess:"Subproceso",service_task:"RPA"},attribute:{loop:"Tarea con bucle"},label:{prefix:"Actividad"},feedback:{label_empty:{prefix:"El nombre de la actividad se estableci\xF3 autom\xE1ticamente como"},label_already_exists:{prefix:"El nombre",middle:"ya existe. El nombre fue cambiado a"},invalid_first_character:"El nombre de la actividad debe comenzar con una letra o n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento no soportado"}}},adapter:{governance:{error:{DEFAULT:"Error al importar diagrama",NO_FILE:"No se ha seleccionado ning\xFAn archivo",EMPTY_FILE:"Archivo vac\xEDo",INVALID_FILE:"Archivo inv\xE1lido",CONTAIN_NO_CELLS:"No se encontraron c\xE9lulas para importar",ALREADY_INITIALIZED:"La importaci\xF3n de la plataforma Governance solo se permite en diagramas sin elementos. Para importar, elimine el diagrama actual"},success:{default:"El diagrama se ha importado de la plataforma Governance correctamente y sin ninguna incompatibilidad detectada.",incompatible_cells:"El diagrama se ha importado de la plataforma Governance con incompatibilidades. Para saber m\xE1s detalles, haz click en el bot\xF3n de abajo."},report:{columns:{type:"Tipo",value:"Valor",status:"Estado"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"No soportado"}},action:{download:"Descargar informe"}}}}};var Ua={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Excluir",deleting:"Excluindo...",configure_node:"Configurar atividade",configure_edge:"Configurar roteamento",configure_gateway:"Configurar roteamento",initial_task:"Atividade Inicial",gateway_limit_reached:"Gateway exclusivo n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",task_limit_reached:"Atividade n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",start_event_limit_reached:"Evento inicial s\xF3 pode se conectar a um \xFAnico elemento",gateway_to_gateway_not_allowed:"Gateways n\xE3o podem se conectar diretamente com outros gateways",start_event_already_exists:"J\xE1 existe um evento de in\xEDcio. Exclua o evento atual para adicionar outro",script_to_end_not_allowed:"Atividades Script n\xE3o podem se conectar diretamente ao evento final",loop_to_end_not_allowed:"Atividades Loop n\xE3o podem se conectar diretamente ao evento final",initial_activity_to_end_not_allowed:"Atividade inicial n\xE3o pode se conectar diretamente ao evento final",final_activity_cannot_connect:"Atividade final n\xE3o pode se conectar a outros elementos",activity_has_outgoing_connections:"Atividade com conex\xF5es de sa\xEDda n\xE3o pode se conectar a um evento final",end_event_cannot_connect_to_initial_activity:"O evento final n\xE3o pode ser conectado a uma atividade inicial",initial_activity_cannot_connect_to_start_event:"Atividade inicial n\xE3o pode se conectar a evento de in\xEDcio",concurrent_initial_and_final_activity:"Uma atividade n\xE3o pode estar conectada ao evento inicial e final ao mesmo tempo",duplicate_connection_not_allowed:"J\xE1 existe uma conex\xE3o entre esses elementos",start_event_to_subprocess_not_allowed:"Evento inicial n\xE3o pode se conectar a um subprocesso",start_event_to_service_task_not_allowed:"Evento inicial n\xE3o pode se conectar a uma atividade autom\xE1tica",service_task_to_end_not_allowed:"Atividades autom\xE1ticas n\xE3o podem se conectar ao evento final",connect_node:"Conectar elemento",connecting:"Conectando...",delete_pool_lane_error:"N\xE3o \xE9 poss\xEDvel excluir a piscina ou raia enquanto houver elementos dentro dela.",delete_elements_blocked:"Uma ou mais atividades n\xE3o podem ser exclu\xEDdas porque existem processos em andamento no Workspace vinculados a elas.",delete_elements_error:"Ocorreu um erro. Tente novamente mais tarde."},controls:{zoom:{fit:"Ajustar o zoom",in:"Aumentar o zoom",out:"Diminuir o zoom",reset:"Resetar o zoom"},actions:{move_tool:"Selecionar elementos",hand_tool:"Navegar pelo diagrama",check:"Validar diagrama",check_loading:"Validando diagrama...",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"N\xE3o \xE9 poss\xEDvel exportar um diagrama vazio",error:"Erro ao exportar o diagrama"}},import_governance:"Importar diagrama da plataforma Governance",import_mermaid:"Importar Mermaid",import:{title:"Importar",xml:"XML",mermaid:"Mermaid",governance:"Governance",feedback:{error:"N\xE3o foi poss\xEDvel importar o arquivo. Verifique o conte\xFAdo."}},organize:{title:"Alinhar diagrama",vertical:"Vertical (de cima para baixo)",horizontal:"Horizontal (da esquerda para a direita)",feedback:{pool_lane:"N\xE3o \xE9 poss\xEDvel ordenar automaticamente diagramas com piscinas ou raias."}},minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Desfazer",redo:"Refazer"}},modals:{mermaid_import:{title:"Importar diagrama a partir de Mermaid",description:"Cole o texto Mermaid (no formato suportado pelo modelador) para gerar o diagrama.",generate:"Gerar",cancel:"Cancelar",error_empty:"Cole o texto do diagrama antes de gerar.",error_parse:"N\xE3o foi poss\xEDvel gerar o diagrama. Verifique o texto colado."},import_confirm:{title:"Substituir o diagrama atual?",content:"Importar vai substituir todo o diagrama atual. Deseja continuar?",confirm:"Importar",loading:"Importando...",cancel:"Cancelar"},delete_elements:{title:"Excluir elementos",callout:"Ao excluir, as configura\xE7\xF5es de atividades e roteamento ser\xE3o exclu\xEDdas.",content:"Deseja realmente excluir?",confirm:"Excluir",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel criar loop em atividade conectada ao evento final",script_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel transformar em Script atividade conectada ao evento final",loop_not_allowed_when_subprocess:"N\xE3o \xE9 poss\xEDvel criar loop em subprocesso",loop_not_allowed_when_service_task:"N\xE3o \xE9 poss\xEDvel criar loop em atividade autom\xE1tica",loop:"Atividade com loop"}},validation:{success:{title:"Diagrama validado com sucesso!",message:"Nenhum erro encontrado."},errors:{title:"O diagrama cont\xE9m erros",subtitle:"Veja abaixo o que precisa ser corrigido:",task_label_length:"O nome da atividade excede o limite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"N\xE3o \xE9 permitido ter mais de um evento de in\xEDcio",task_flows_limit_exceeds:"O n\xFAmero de conex\xF5es de sa\xEDda ultrapassa o limite de dois",duplicate_task_name:"H\xE1 v\xE1rias atividades com o mesmo nome",flows_on_end_tasks_not_allowed:"Atividades conectadas a eventos finais n\xE3o podem ter outras conex\xF5es",conditions_flows_limit_exceeds:"Gateway exclusivo com excesso de conex\xF5es de sa\xEDda (m\xE1ximo de dois)",task_label_empty:"O nome de uma ou mais atividades n\xE3o foi preenchido",activity_name_invalid:"O nome da atividade n\xE3o \xE9 v\xE1lido",final_activity_has_loop:"Atividades finais n\xE3o podem ter loops",nested_gateway:"N\xE3o \xE9 permitido conectar gateways",concurrent_initial_and_final_event:"Uma mesma atividade n\xE3o pode ter eventos iniciais e finais",gateway_flow_to_event:"N\xE3o \xE9 permitido conectar um gateway a um evento de sa\xEDda",gateway_missing_output_streams:"Um ou mais gateways n\xE3o possuem o n\xFAmero correto de sa\xEDdas",events_nested:"N\xE3o \xE9 permitido conectar eventos",event_to_condition:"N\xE3o \xE9 permitido conectar um evento diretamente em um gateway",script_in_final_activity:"Atividade final n\xE3o pode ser do tipo script",subprocess_not_configured:"A refer\xEAncia ao subprocesso n\xE3o est\xE1 configurada corretamente em uma ou mais atividades",cannot_validate_subprocess_reference:"N\xE3o foi poss\xEDvel validar a refer\xEAncia ao subprocesso em uma ou mais atividades",start_event_not_found:"\xC9 necess\xE1rio ter um evento inicial",end_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento final",service_task_without_rejection_routing:"Atividade autom\xE1tica (RPA) sem roteamento de rejei\xE7\xE3o configurado",service_task_without_automation:"Atividade autom\xE1tica (RPA) sem rob\xF4 configurado",service_task_connector_inactive:"Atividade autom\xE1tica (RPA) vinculada a um conector inativo",service_task_integration_suspended:"Atividade autom\xE1tica (RPA) vinculada a uma integra\xE7\xE3o suspensa",service_task_automation_status_unavailable:"N\xE3o foi poss\xEDvel verificar o status da automa\xE7\xE3o (RPA)",service_task_initial_or_final:"Atividade autom\xE1tica (RPA) n\xE3o pode ser etapa inicial, final ou concentradora",service_task_in_loop:"Atividade autom\xE1tica (RPA) n\xE3o pode estar em loop"}},bpmn:{start_event:{variant:{default:"Evento inicial"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anota\xE7\xE3o"}},gateway:{menu:{title:"Alterar tipo de gateway"},variant:{default:"Gateway",exclusive:"Gateway exclusivo",parallel:"Gateway paralelo",complex:"Gateway complexo"}},task:{menu:{title:"Alterar tipo de atividade"},variant:{default:"Atividade",script:"Atividade de script",subprocess:"Subprocesso",service_task:"RPA"},attribute:{loop:"Atividade com loop"},label:{prefix:"Atividade"},feedback:{label_empty:{prefix:"O nome da atividade foi definido automaticamente como"},label_already_exists:{prefix:"O nome",middle:"j\xE1 existe. O nome foi alterado para"},invalid_first_character:"O nome da atividade deve come\xE7ar com uma letra ou n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento n\xE3o suportado"}}},adapter:{governance:{error:{DEFAULT:"Erro ao importar diagrama",NO_FILE:"Nenhum arquivo selecionado",EMPTY_FILE:"Arquivo vazio",INVALID_FILE:"Arquivo inv\xE1lido",CONTAIN_NO_CELLS:"N\xE3o foram encontradas c\xE9lulas para serem importadas",ALREADY_INITIALIZED:"A importa\xE7\xE3o da plataforma Governance s\xF3 \xE9 permitida em diagramas sem elementos. Para importar, apague o diagrama atual"},success:{default:"O diagrama foi importado da plataforma Governance com sucesso e sem nenhuma incompatibilidade detectada.",incompatible_cells:"O diagrama foi importado da plataforma Governance com incompatibilidades. Para saber mais detalhes, clique no bot\xE3o abaixo."},report:{columns:{type:"Tipo do elemento",value:"Valor",status:"Status"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"N\xE3o suportado"}},action:{download:"Baixar relat\xF3rio"}}}}};var $a={pt_BR:Ua,en_US:Wa,es_ES:Xa};var Ka,qa,vm=(qa=(Ka=Cs("LecomUserLanguage"))!=null?Ka:Cs("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?qa:Yr.Translations.PT_BR;(0,Yr.initializeI18n)({lng:vm,resources:$a});var xe=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(xe||{});var Un=(i=>(i.ACTIVITY="activity",i.ROUTING="routing",i.GATEWAY="gateway",i.SUB_PROCESS="sub_process",i.SERVICE_TASK="service_task",i))(Un||{}),Wr=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Wr||{}),Xr=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Xr||{}),Ur=(u=>(u.SIMPLE="simple",u.LOOP="loop",u.SCRIPT="script",u.SCRIPT_LOOP="script_loop",u.COMPLEX="complex",u.EXCLUSIVE="exclusive",u.PARALLEL="parallel",u.FINAL="final",u.TO_SUB_PROCESS="to_sub_process",u.FROM_SUB_PROCESS="from_sub_process",u.FROM_SERVICE_TASK="from_service_task",u))(Ur||{});var oo=require("lucide-react");var To=require("react/jsx-runtime"),$r=({size:e=24,className:t})=>(0,To.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:[(0,To.jsx)("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),(0,To.jsx)("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),(0,To.jsx)("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),(0,To.jsx)("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});var Ss=require("react/jsx-runtime"),nn=({size:e=24,className:t})=>(0,Ss.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#ff6565",stroke:"#ec1616",strokeWidth:3,className:t,children:(0,Ss.jsx)("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});var jt=require("react/jsx-runtime"),rn=({size:e=24,className:t})=>(0,jt.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[(0,jt.jsx)("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,jt.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,jt.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,jt.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,jt.jsx)("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var sn=require("react/jsx-runtime"),an=({size:e=24,className:t})=>(0,sn.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[(0,sn.jsx)("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,sn.jsx)("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,sn.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var ln=require("react/jsx-runtime"),cn=({size:e=24,className:t})=>(0,ln.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[(0,ln.jsx)("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ln.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ln.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});var dn=require("react/jsx-runtime"),Za=({size:e=24,className:t})=>(0,dn.jsx)("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:(0,dn.jsxs)("g",{children:[(0,dn.jsx)("path",{d:"M8.6543 11.4141V15.2148C8.51302 15.4017 8.29199 15.6068 7.99121 15.8301C7.69499 16.0488 7.30078 16.238 6.80859 16.3975C6.31641 16.557 5.70345 16.6367 4.96973 16.6367C4.34538 16.6367 3.77344 16.5319 3.25391 16.3223C2.73438 16.1081 2.28548 15.7959 1.90723 15.3857C1.53353 14.9756 1.24414 14.4766 1.03906 13.8887C0.833984 13.2962 0.731445 12.6217 0.731445 11.8652V11.1748C0.731445 10.4229 0.82487 9.75293 1.01172 9.16504C1.20312 8.57259 1.47656 8.07129 1.83203 7.66113C2.1875 7.25098 2.61589 6.94108 3.11719 6.73145C3.62305 6.51725 4.19499 6.41016 4.83301 6.41016C5.64876 6.41016 6.32324 6.54688 6.85645 6.82031C7.39421 7.08919 7.80892 7.46289 8.10059 7.94141C8.39225 8.41992 8.57682 8.9668 8.6543 9.58203H6.97266C6.91797 9.23568 6.81087 8.92578 6.65137 8.65234C6.49642 8.37891 6.27311 8.16471 5.98145 8.00977C5.69434 7.85026 5.32064 7.77051 4.86035 7.77051C4.46387 7.77051 4.11523 7.8457 3.81445 7.99609C3.51367 8.14648 3.26302 8.36751 3.0625 8.65918C2.86654 8.95085 2.71842 9.30632 2.61816 9.72559C2.5179 10.1449 2.46777 10.6234 2.46777 11.1611V11.8652C2.46777 12.4121 2.52474 12.8975 2.63867 13.3213C2.75716 13.7451 2.92578 14.1029 3.14453 14.3945C3.36784 14.6862 3.639 14.9072 3.95801 15.0576C4.27702 15.2035 4.63704 15.2764 5.03809 15.2764C5.43001 15.2764 5.7513 15.2445 6.00195 15.1807C6.2526 15.1123 6.45085 15.0326 6.59668 14.9414C6.74707 14.8457 6.86328 14.7546 6.94531 14.668V12.6924H4.87402V11.4141H8.6543ZM17.0912 11.25V11.7969C17.0912 12.5488 16.9932 13.2233 16.7973 13.8203C16.6013 14.4173 16.321 14.9255 15.9564 15.3447C15.5964 15.764 15.1635 16.0853 14.6576 16.3086C14.1518 16.5273 13.5912 16.6367 12.976 16.6367C12.3653 16.6367 11.807 16.5273 11.3012 16.3086C10.7999 16.0853 10.3646 15.764 9.99551 15.3447C9.62637 14.9255 9.33926 14.4173 9.13418 13.8203C8.93366 13.2233 8.8334 12.5488 8.8334 11.7969V11.25C8.8334 10.498 8.93366 9.82585 9.13418 9.2334C9.3347 8.63639 9.61725 8.12826 9.98184 7.70898C10.351 7.28516 10.7862 6.96387 11.2875 6.74512C11.7934 6.52181 12.3516 6.41016 12.9623 6.41016C13.5775 6.41016 14.1381 6.52181 14.6439 6.74512C15.1498 6.96387 15.585 7.28516 15.9496 7.70898C16.3142 8.12826 16.5945 8.63639 16.7904 9.2334C16.991 9.82585 17.0912 10.498 17.0912 11.25ZM15.3754 11.7969V11.2363C15.3754 10.6803 15.3207 10.1904 15.2113 9.7666C15.1065 9.33822 14.9493 8.98047 14.7396 8.69336C14.5346 8.40169 14.2816 8.18294 13.9809 8.03711C13.6801 7.88672 13.3406 7.81152 12.9623 7.81152C12.584 7.81152 12.2468 7.88672 11.9506 8.03711C11.6544 8.18294 11.4014 8.40169 11.1918 8.69336C10.9867 8.98047 10.8295 9.33822 10.7201 9.7666C10.6107 10.1904 10.5561 10.6803 10.5561 11.2363V11.7969C10.5561 12.3529 10.6107 12.8451 10.7201 13.2734C10.8295 13.7018 10.989 14.0641 11.1986 14.3604C11.4128 14.652 11.668 14.873 11.9643 15.0234C12.2605 15.1693 12.5977 15.2422 12.976 15.2422C13.3588 15.2422 13.6983 15.1693 13.9945 15.0234C14.2908 14.873 14.5414 14.652 14.7465 14.3604C14.9516 14.0641 15.1065 13.7018 15.2113 13.2734C15.3207 12.8451 15.3754 12.3529 15.3754 11.7969ZM20.6678 14.6816L23.2859 6.54688H25.1795L21.6111 16.5H20.3328L20.6678 14.6816ZM18.2479 6.54688L20.8455 14.6816L21.201 16.5H19.9158L16.3611 6.54688H18.2479Z"}),(0,dn.jsx)("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});var Ja=require("clsx"),Qa=require("tailwind-merge");function F(...e){return(0,Qa.twMerge)((0,Ja.clsx)(e))}var eo=(e=0,t=0)=>e<t?t:e,Kr=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});var $n=require("react/jsx-runtime"),ja=({size:e=24,className:t})=>(0,$n.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:F("stroke-2",t),children:[(0,$n.jsx)("path",{d:"M19 3H5C3.89543 3 3 3.89543 3 5V19C3 20.1046 3.89543 21 5 21H19C20.1046 21 21 20.1046 21 19V5C21 3.89543 20.1046 3 19 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,$n.jsx)("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});var qr=require("react/jsx-runtime"),el=({size:e=24,className:t})=>(0,qr.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:(0,qr.jsx)("g",{children:(0,qr.jsx)("path",{d:"M4.85372 6.17472L5.31292 5.71552L5.31993 5.70863C6.88908 4.1924 8.98352 3.34122 11.1655 3.33301L11.1668 3.33301C11.167 3.33301 11.1673 3.33301 11.1675 3.33301C12.7165 3.33314 14.2308 3.79255 15.5188 4.65317C16.807 5.5139 17.811 6.7373 18.4039 8.16866C18.9968 9.60001 19.1519 11.175 18.8497 12.6945C18.5986 13.9567 18.0414 15.1334 17.232 16.1236L16.9457 16.4738L17.2655 16.7936L20.6617 20.1899L20.6617 20.1899C20.7919 20.3201 20.7919 20.5311 20.6617 20.6612L20.6616 20.6613C20.5316 20.7915 20.3205 20.7915 20.1903 20.6613L16.7941 17.265L16.4743 16.9452L16.1241 17.2315C15.1339 18.0409 13.9571 18.5981 12.695 18.8492C11.1755 19.1514 9.6005 18.9963 8.16915 18.4034C6.73778 17.8105 5.51439 16.8065 4.65365 15.5183C3.79291 14.2301 3.3335 12.7156 3.3335 11.1663C3.3335 10.9822 3.48273 10.833 3.66683 10.833C3.85093 10.833 4.00016 10.9822 4.00016 11.1663C4.00016 12.5838 4.42048 13.9694 5.20796 15.148C5.99545 16.3265 7.11474 17.245 8.42426 17.7874C9.73378 18.3299 11.1748 18.4719 12.565 18.1953C13.9552 17.9188 15.2321 17.2362 16.2344 16.234L16.2345 16.234C17.2367 15.2316 17.9193 13.9547 18.1958 12.5645C18.4724 11.1743 18.3304 9.7333 17.7879 8.42378C17.2455 7.11426 16.327 5.99497 15.1484 5.20748L14.8707 5.62322L15.1484 5.20748C13.9703 4.42031 12.5854 4.00001 11.1685 3.99968L11.1664 3.99969C9.15876 4.00767 7.23176 4.7903 5.78712 6.18424L5.78706 6.18418L5.78075 6.1905L5.32512 6.64613L4.47156 7.49968H5.67867H7.8335C8.01759 7.49968 8.16683 7.64892 8.16683 7.83302C8.16683 8.01711 8.01759 8.16635 7.8335 8.16635H3.66683C3.48274 8.16635 3.3335 8.01711 3.3335 7.83302V3.66635C3.3335 3.48225 3.48274 3.33302 3.66683 3.33302C3.85092 3.33302 4.00016 3.48225 4.00016 3.66635V5.82117V7.02827L4.85372 6.17472Z"})})});var Ms=require("react/jsx-runtime"),Zr=({size:e=24,className:t})=>(0,Ms.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#5fd9b0",stroke:"#1cad86",strokeWidth:"2",className:t,children:(0,Ms.jsx)("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});var Ps=require("react/jsx-runtime"),Kn=({size:e=24,className:t})=>(0,Ps.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",className:F("stroke-2",t),children:(0,Ps.jsx)("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"})});var un=require("react/jsx-runtime"),tl=({size:e=24,className:t})=>(0,un.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[(0,un.jsx)("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,un.jsx)("path",{d:"M7.5 12C7.5 12.89 7.76392 13.76 8.25839 14.5001C8.75285 15.2401 9.45566 15.8169 10.2779 16.1575C11.1002 16.4981 12.005 16.5872 12.8779 16.4135C13.7508 16.2399 14.5526 15.8113 15.182 15.182C15.8113 14.5526 16.2399 13.7508 16.4135 12.8779C16.5872 12.005 16.4981 11.1002 16.1575 10.2779C15.8169 9.45566 15.2401 8.75285 14.5001 8.25839C13.76 7.76392 12.89 7.5 12 7.5C10.742 7.50473 9.53448 7.99561 8.63 8.87L7.5 10",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,un.jsx)("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});var to=require("react/jsx-runtime"),ol=({size:e=24,className:t})=>(0,to.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[(0,to.jsx)("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,to.jsx)("path",{d:"M15.5 14.5V8.5C15.5 8.23478 15.3946 7.98043 15.2071 7.79289C15.0196 7.60536 14.7652 7.5 14.5 7.5H8",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,to.jsx)("path",{d:"M10 16.5H16C16.2652 16.5 16.5196 16.3946 16.7071 16.2071C16.8946 16.0196 17 15.7652 17 15.5V15C17 14.8674 16.9473 14.7402 16.8536 14.6464C16.7598 14.5527 16.6326 14.5 16.5 14.5H11.5C11.3674 14.5 11.2402 14.5527 11.1464 14.6464C11.0527 14.7402 11 14.8674 11 15V15.5C11 15.7652 10.8946 16.0196 10.7071 16.2071C10.5196 16.3946 10.2652 16.5 10 16.5ZM10 16.5C9.73478 16.5 9.48043 16.3946 9.29289 16.2071C9.10536 16.0196 9 15.7652 9 15.5V8.5C9 8.23478 8.89464 7.98043 8.70711 7.79289C8.51957 7.60536 8.26522 7.5 8 7.5C7.73478 7.5 7.48043 7.60536 7.29289 7.79289C7.10536 7.98043 7 8.23478 7 8.5V9.5C7 9.63261 7.05268 9.75979 7.14645 9.85355C7.24021 9.94732 7.36739 10 7.5 10H9",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,to.jsx)("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,to.jsx)("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var vo=require("react/jsx-runtime"),qn=({size:e=24,className:t})=>(0,vo.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[(0,vo.jsx)("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,vo.jsx)("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),(0,vo.jsx)("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,vo.jsx)("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var Q=(s=>(s.START_EVENT="START_EVENT",s.END_EVENT="END_EVENT",s.TASK="TASK",s.LANE="LANE",s.GATEWAY="GATEWAY",s.ANNOTATION="ANNOTATION",s.UNSUPPORTED="UNSUPPORTED",s))(Q||{}),Xe=(n=>(n.SCRIPT="SCRIPT",n.SUBPROCESS="SUBPROCESS",n.SERVICE_TASK="SERVICE_TASK",n))(Xe||{}),Jr={SCRIPT:{icon:oo.ScrollText},SUBPROCESS:{icon:oo.SquarePlus},SERVICE_TASK:{icon:oo.Bot}},pt=(t=>(t.LOOP="LOOP",t))(pt||{}),Qr={LOOP:{icon:oo.RotateCcw}},qe=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(qe||{}),Ls={EXCLUSIVE:{icon:an},PARALLEL:{icon:cn},COMPLEX:{icon:rn}};var sm=require("@produto-lecom/lecom-ui"),am=require("@xyflow/react"),le=require("react");var Vt=require("@xyflow/react"),on=require("react");var go=require("@xyflow/react"),Dt=require("react");var pn=require("@xyflow/react");var Nm={START_EVENT:"ellipse",END_EVENT:"ellipse",TASK:"rectangle",GATEWAY:"rectangle",LANE:"rectangle",ANNOTATION:"rectangle",UNSUPPORTED:"rectangle"};function Ht(e){var o,n,r,i,a,s,l;return{bounds:{x:e.internals.positionAbsolute.x,y:e.internals.positionAbsolute.y,width:(r=(n=(o=e.measured)==null?void 0:o.width)!=null?n:e.width)!=null?r:0,height:(s=(a=(i=e.measured)==null?void 0:i.height)!=null?a:e.height)!=null?s:0},perimeter:(l=Nm[e.type])!=null?l:"rectangle"}}function jr(e,t){let o=e==null?void 0:e.controlPoint;return o?I(T({},e),{controlPoint:{x:o.x+t,y:o.y+t}}):e}function nl(e,t){var y,v,_,N;let{width:o=0,height:n=0}=e.measured||{width:0,height:0},r=e.internals.positionAbsolute,i=t.internals.positionAbsolute,a=o/2,s=n/2,l=r.x+a,c=r.y+s,d=i.x+((v=(y=t==null?void 0:t.measured)==null?void 0:y.width)!=null?v:0)/2,u=i.y+((N=(_=t==null?void 0:t.measured)==null?void 0:_.height)!=null?N:0)/2,p=(d-l)/(2*a)-(u-c)/(2*s),f=(d-l)/(2*a)+(u-c)/(2*s),x=1/(Math.abs(p)+Math.abs(f)||1),E=x*p,m=x*f,h=a*(E+m)+l,g=s*(-E+m)+c;return{x:h,y:g}}function rl(e,t){var c,d,u,p;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(p=(u=e.measured)==null?void 0:u.height)!=null?p:0,i=Math.round(o.x),a=Math.round(o.y),s=Math.round(t.x),l=Math.round(t.y);return s<=i+1?pn.Position.Left:s>=i+n-1?pn.Position.Right:l<=a+1?pn.Position.Top:l>=a+r-1?pn.Position.Bottom:pn.Position.Top}function ei(e,t){let o=nl(e,t),n=nl(t,e),r=rl(e,o),i=rl(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function ti(e,t){return{isFromStartEvent:(e==null?void 0:e.type)==="START_EVENT",isGatewayToGateway:(e==null?void 0:e.type)==="GATEWAY"&&(t==null?void 0:t.type)==="GATEWAY",isActiviyToAndGateway:(e==null?void 0:e.type)==="TASK"&&(t==null?void 0:t.type)==="GATEWAY",isToEndEvent:(t==null?void 0:t.type)==="END_EVENT"}}var il=require("lodash");var oi=e=>e.some(t=>t.type==="position"&&t.dragging),sl=e=>new Map(e.map(t=>[t.id,t])),No=(e,t)=>{let o=e?t.find(a=>a.id===e):void 0;if(!o)return{x:0,y:0};let{x:n,y:r}=o.position,i=o.parentId;for(;i;){let a=t.find(s=>s.id===i);if(!a)break;n+=a.position.x,r+=a.position.y,i=a.parentId}return{x:n,y:r}},al=(e,t)=>e.map(o=>{var n;return(n=t.get(o.id))!=null?n:o}),ot=e=>{var t,o,n,r,i,a,s,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(r=(n=e.internals)==null?void 0:n.positionAbsolute.y)!=null?r:0,w:(a=(i=e.measured)==null?void 0:i.width)!=null?a:0,h:(l=(s=e.measured)==null?void 0:s.height)!=null?l:0}},wo=e=>(0,il.orderBy)(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),ll=(e,t)=>{let{x:o,y:n}=ot(e),{x:r,y:i}=ot(t);return{x:o-r,y:n-i}};var Io=({parentId:e,nodes:t,includeTypes:o=[...Object.values(Q)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),wm=(e,t)=>{let{x:o,y:n}=ot(e),{x:r,y:i}=ot(t),a=o-r,s=n-i;return Math.sqrt(a*a+s*s)},Im=(e,t)=>{let{x:o,y:n,w:r,h:i}=ot(e),{x:a,y:s,w:l,h:c}=ot(t),d=o+r/2,u=n+i/2;return d>=a&&d<=a+l&&u>=s&&u<=s+c},fn=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&Im(e,r)){let i=wm(e,r);i<n&&(n=i,o=r)}return o},cl=(e,t)=>t.filter(o=>o.parentId===e).reduce((o,n)=>{var r,i;return Math.max(o,(i=(r=n.measured)==null?void 0:r.width)!=null?i:0)},0);var dl=e=>{let t=e.filter(a=>!a.parentId);if(t.length===0)return null;let o=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of t){let{position:s,width:l,height:c}=a,d=s.x+(l||0),u=s.y+(c||0);s.x<o&&(o=s.x),s.y<n&&(n=s.y),d>r&&(r=d),u>i&&(i=u)}return{x:o,y:n,w:r-o,h:i-n}},ul=({bounds:e,canvasWidth:t,canvasHeight:o,minZoom:n=.5,maxZoom:r=5,offsetX:i=0,offsetY:a=0})=>{let s=t-i*2,l=o-a*2,c=Math.min(s/e.w,l/e.h),d=Math.min(1,c),u=Math.min(Math.max(d,n),r);return{x:-e.x*u+i,y:-e.y*u+a,zoom:u}};var Ds=(e,t)=>{let o=t.find(a=>a.id===e);if(!o||o.type!=="LANE"||o.parentId)return!1;let n=ot(o),r=n.x+n.w,i=n.y+n.h;return t.some(a=>{if(a.id===e||a.parentId||a.type==="LANE")return!1;let s=ot(a);return s.x<r&&s.x+s.w>n.x&&s.y<i&&s.y+s.h>n.y})};var fl=require("react"),ml=require("zustand");var pl=require("@xyflow/react"),Tt=()=>{let e=(0,pl.useStoreApi)();return{selectElements:n=>{let{edges:r,nodes:i,triggerEdgeChanges:a,triggerNodeChanges:s}=e.getState(),l=i.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]),c=r.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]);return s(l),a(c),!0},clearSelection:async()=>{let{unselectNodesAndEdges:n}=e.getState();return n(),await Kr(),!0}}};var gl=()=>{let{selectElements:e}=Tt();return(0,fl.useCallback)(()=>{let o=Ao.getState().pathEdgeIds;e(o)},[e])},Ao=(0,ml.create)((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=T({},n.statusByNodeId),i=T({},n.statusData),a=!1;return o.forEach(s=>{let l=`${s.diagramId}-${s.activityId}`;r[s.diagramId]!==s.status&&(r[s.diagramId]=s.status,i[l]=s,a=!0)}),a?{statusByNodeId:r,statusData:i}:n})},getTaskStatus:o=>t().statusByNodeId[o]||null,clearTaskStatuses:()=>e({statusByNodeId:{},statusData:{},pathEdgeIds:[]}),setPathEdges:o=>{e({pathEdgeIds:o})},getPathEdgeIds:()=>t().pathEdgeIds,clearPathEdges:()=>{e({pathEdgeIds:[]})},calculateFlowPath:(o,n)=>{if(!o.length||!n.length)return;t().clearPathEdges();let r=n.filter(d=>t().statusByNodeId[d]);if(r.length<=1)return;let i=[],a={};o.forEach(d=>{a[d.source]||(a[d.source]=[]),a[d.source].push({targetId:d.target,edgeId:d.id})});let s=r[0],l=r[r.length-1];o.forEach(d=>{d.target===s&&i.push(d.id)}),o.forEach(d=>{d.source===l&&i.push(d.id)});let c=(d,u)=>{let p=[],f=new Set;for(p.push({node:d,path:[]}),f.add(d);p.length>0;){let{node:x,path:E}=p.shift();if(x===u)return E;let m=a[x]||[];for(let{targetId:h,edgeId:g}of m)f.has(h)||(f.add(h),p.push({node:h,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})}}));var xn=require("@xyflow/react"),Ze=require("react"),dd=require("zustand/shallow");var Am={value:()=>{}};function yl(){for(var e=0,t=arguments.length,o={},n;e<t;++e){if(!(n=arguments[e]+"")||n in o||/[\s.]/.test(n))throw new Error("illegal type: "+n);o[n]=[]}return new ni(o)}function ni(e){this._=e}function Cm(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}})}ni.prototype=yl.prototype={constructor:ni,on:function(e,t){var o=this._,n=Cm(e+"",o),r,i=-1,a=n.length;if(arguments.length<2){for(;++i<a;)if((r=(e=n[i]).type)&&(r=Sm(o[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<a;)if(r=(e=n[i]).type)o[r]=hl(o[r],e.name,t);else if(t==null)for(r in o)o[r]=hl(o[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var o in t)e[o]=t[o].slice();return new ni(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 Sm(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function hl(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=Am,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var ks=yl;var ri="http://www.w3.org/1999/xhtml",Rs={svg:"http://www.w3.org/2000/svg",xhtml:ri,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Gt(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),Rs.hasOwnProperty(t)?{space:Rs[t],local:e}:e}function Mm(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===ri&&t.documentElement.namespaceURI===ri?t.createElement(e):t.createElementNS(o,e)}}function Pm(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function ii(e){var t=Gt(e);return(t.local?Pm:Mm)(t)}function Lm(){}function Co(e){return e==null?Lm:function(){return this.querySelector(e)}}function xl(e){typeof e!="function"&&(e=Co(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=new Array(a),l,c,d=0;d<a;++d)(l=i[d])&&(c=e.call(l,l.__data__,d,i))&&("__data__"in l&&(c.__data__=l.__data__),s[d]=c);return new Me(n,this._parents)}function Os(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Dm(){return[]}function Zn(e){return e==null?Dm:function(){return this.querySelectorAll(e)}}function km(e){return function(){return Os(e.apply(this,arguments))}}function El(e){typeof e=="function"?e=km(e):e=Zn(e);for(var t=this._groups,o=t.length,n=[],r=[],i=0;i<o;++i)for(var a=t[i],s=a.length,l,c=0;c<s;++c)(l=a[c])&&(n.push(e.call(l,l.__data__,c,a)),r.push(l));return new Me(n,r)}function Jn(e){return function(){return this.matches(e)}}function si(e){return function(t){return t.matches(e)}}var Rm=Array.prototype.find;function Om(e){return function(){return Rm.call(this.children,e)}}function Vm(){return this.firstElementChild}function _l(e){return this.select(e==null?Vm:Om(typeof e=="function"?e:si(e)))}var Hm=Array.prototype.filter;function Gm(){return Array.from(this.children)}function Bm(e){return function(){return Hm.call(this.children,e)}}function bl(e){return this.selectAll(e==null?Gm:Bm(typeof e=="function"?e:si(e)))}function Tl(e){typeof e!="function"&&(e=Jn(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=[],l,c=0;c<a;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&s.push(l);return new Me(n,this._parents)}function ai(e){return new Array(e.length)}function vl(){return new Me(this._enter||this._groups.map(ai),this._parents)}function Qn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Qn.prototype={constructor:Qn,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Nl(e){return function(){return e}}function zm(e,t,o,n,r,i){for(var a=0,s,l=t.length,c=i.length;a<c;++a)(s=t[a])?(s.__data__=i[a],n[a]=s):o[a]=new Qn(e,i[a]);for(;a<l;++a)(s=t[a])&&(r[a]=s)}function Fm(e,t,o,n,r,i,a){var s,l,c=new Map,d=t.length,u=i.length,p=new Array(d),f;for(s=0;s<d;++s)(l=t[s])&&(p[s]=f=a.call(l,l.__data__,s,t)+"",c.has(f)?r[s]=l:c.set(f,l));for(s=0;s<u;++s)f=a.call(e,i[s],s,i)+"",(l=c.get(f))?(n[s]=l,l.__data__=i[s],c.delete(f)):o[s]=new Qn(e,i[s]);for(s=0;s<d;++s)(l=t[s])&&c.get(p[s])===l&&(r[s]=l)}function Ym(e){return e.__data__}function wl(e,t){if(!arguments.length)return Array.from(this,Ym);var o=t?Fm:zm,n=this._parents,r=this._groups;typeof e!="function"&&(e=Nl(e));for(var i=r.length,a=new Array(i),s=new Array(i),l=new Array(i),c=0;c<i;++c){var d=n[c],u=r[c],p=u.length,f=Wm(e.call(d,d&&d.__data__,c,n)),x=f.length,E=s[c]=new Array(x),m=a[c]=new Array(x),h=l[c]=new Array(p);o(d,u,E,m,h,f,t);for(var g=0,y=0,v,_;g<x;++g)if(v=E[g]){for(g>=y&&(y=g+1);!(_=m[y])&&++y<x;);v._next=_||null}}return a=new Me(a,n),a._enter=s,a._exit=l,a}function Wm(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Il(){return new Me(this._exit||this._groups.map(ai),this._parents)}function Al(e,t,o){var n=this.enter(),r=this,i=this.exit();return typeof e=="function"?(n=e(n),n&&(n=n.selection())):n=n.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),o==null?i.remove():o(i),n&&r?n.merge(r).order():r}function Cl(e){for(var t=e.selection?e.selection():e,o=this._groups,n=t._groups,r=o.length,i=n.length,a=Math.min(r,i),s=new Array(r),l=0;l<a;++l)for(var c=o[l],d=n[l],u=c.length,p=s[l]=new Array(u),f,x=0;x<u;++x)(f=c[x]||d[x])&&(p[x]=f);for(;l<r;++l)s[l]=o[l];return new Me(s,this._parents)}function Sl(){for(var e=this._groups,t=-1,o=e.length;++t<o;)for(var n=e[t],r=n.length-1,i=n[r],a;--r>=0;)(a=n[r])&&(i&&a.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(a,i),i=a);return this}function Ml(e){e||(e=Xm);function t(u,p){return u&&p?e(u.__data__,p.__data__):!u-!p}for(var o=this._groups,n=o.length,r=new Array(n),i=0;i<n;++i){for(var a=o[i],s=a.length,l=r[i]=new Array(s),c,d=0;d<s;++d)(c=a[d])&&(l[d]=c);l.sort(t)}return new Me(r,this._parents).order()}function Xm(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Pl(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Ll(){return Array.from(this)}function Dl(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length;r<i;++r){var a=n[r];if(a)return a}return null}function kl(){let e=0;for(let t of this)++e;return e}function Rl(){return!this.node()}function Ol(e){for(var t=this._groups,o=0,n=t.length;o<n;++o)for(var r=t[o],i=0,a=r.length,s;i<a;++i)(s=r[i])&&e.call(s,s.__data__,i,r);return this}function Um(e){return function(){this.removeAttribute(e)}}function $m(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Km(e,t){return function(){this.setAttribute(e,t)}}function qm(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Zm(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function Jm(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,o)}}function Vl(e,t){var o=Gt(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?$m:Um:typeof t=="function"?o.local?Jm:Zm:o.local?qm:Km)(o,t))}function li(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Qm(e){return function(){this.style.removeProperty(e)}}function jm(e,t,o){return function(){this.style.setProperty(e,t,o)}}function eg(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function Hl(e,t,o){return arguments.length>1?this.each((t==null?Qm:typeof t=="function"?eg:jm)(e,t,o==null?"":o)):no(this.node(),e)}function no(e,t){return e.style.getPropertyValue(t)||li(e).getComputedStyle(e,null).getPropertyValue(t)}function tg(e){return function(){delete this[e]}}function og(e,t){return function(){this[e]=t}}function ng(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function Gl(e,t){return arguments.length>1?this.each((t==null?tg:typeof t=="function"?ng:og)(e,t)):this.node()[e]}function Bl(e){return e.trim().split(/^|\s+/)}function Vs(e){return e.classList||new zl(e)}function zl(e){this._node=e,this._names=Bl(e.getAttribute("class")||"")}zl.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Fl(e,t){for(var o=Vs(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function Yl(e,t){for(var o=Vs(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function rg(e){return function(){Fl(this,e)}}function ig(e){return function(){Yl(this,e)}}function sg(e,t){return function(){(t.apply(this,arguments)?Fl:Yl)(this,e)}}function Wl(e,t){var o=Bl(e+"");if(arguments.length<2){for(var n=Vs(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?sg:t?rg:ig)(o,t))}function ag(){this.textContent=""}function lg(e){return function(){this.textContent=e}}function cg(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function Xl(e){return arguments.length?this.each(e==null?ag:(typeof e=="function"?cg:lg)(e)):this.node().textContent}function dg(){this.innerHTML=""}function ug(e){return function(){this.innerHTML=e}}function pg(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function Ul(e){return arguments.length?this.each(e==null?dg:(typeof e=="function"?pg:ug)(e)):this.node().innerHTML}function fg(){this.nextSibling&&this.parentNode.appendChild(this)}function $l(){return this.each(fg)}function mg(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Kl(){return this.each(mg)}function ql(e){var t=typeof e=="function"?e:ii(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function gg(){return null}function Zl(e,t){var o=typeof e=="function"?e:ii(e),n=t==null?gg:typeof t=="function"?t:Co(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function hg(){var e=this.parentNode;e&&e.removeChild(this)}function Jl(){return this.each(hg)}function yg(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function xg(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Ql(e){return this.select(e?xg:yg)}function jl(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Eg(e){return function(t){e.call(this,t,this.__data__)}}function _g(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 bg(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 Tg(e,t,o){return function(){var n=this.__on,r,i=Eg(t);if(n){for(var a=0,s=n.length;a<s;++a)if((r=n[a]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=o),r.value=t;return}}this.addEventListener(e.type,i,o),r={type:e.type,name:e.name,value:t,listener:i,options:o},n?n.push(r):this.__on=[r]}}function ec(e,t,o){var n=_g(e+""),r,i=n.length,a;if(arguments.length<2){var s=this.node().__on;if(s){for(var l=0,c=s.length,d;l<c;++l)for(r=0,d=s[l];r<i;++r)if((a=n[r]).type===d.type&&a.name===d.name)return d.value}return}for(s=t?Tg:bg,r=0;r<i;++r)this.each(s(n[r],t,o));return this}function tc(e,t,o){var n=li(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 vg(e,t){return function(){return tc(this,e,t)}}function Ng(e,t){return function(){return tc(this,e,t.apply(this,arguments))}}function oc(e,t){return this.each((typeof t=="function"?Ng:vg)(e,t))}function*nc(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length,a;r<i;++r)(a=n[r])&&(yield a)}var wg=[null];function Me(e,t){this._groups=e,this._parents=t}function rc(){return new Me([[document.documentElement]],wg)}function Ig(){return this}Me.prototype=rc.prototype={constructor:Me,select:xl,selectAll:El,selectChild:_l,selectChildren:bl,filter:Tl,data:wl,enter:vl,exit:Il,join:Al,merge:Cl,selection:Ig,order:Sl,sort:Ml,call:Pl,nodes:Ll,node:Dl,size:kl,empty:Rl,each:Ol,attr:Vl,style:Hl,property:Gl,classed:Wl,text:Xl,html:Ul,raise:$l,lower:Kl,append:ql,insert:Zl,remove:Jl,clone:Ql,datum:jl,on:ec,dispatch:oc,[Symbol.iterator]:nc};var Bt=rc;function ci(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function Hs(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function tr(){}var jn=.7,pi=1/jn,mn="\\s*([+-]?\\d+)\\s*",er="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",vt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Ag=/^#([0-9a-f]{3,8})$/,Cg=new RegExp(`^rgb\\(${mn},${mn},${mn}\\)$`),Sg=new RegExp(`^rgb\\(${vt},${vt},${vt}\\)$`),Mg=new RegExp(`^rgba\\(${mn},${mn},${mn},${er}\\)$`),Pg=new RegExp(`^rgba\\(${vt},${vt},${vt},${er}\\)$`),Lg=new RegExp(`^hsl\\(${er},${vt},${vt}\\)$`),Dg=new RegExp(`^hsla\\(${er},${vt},${vt},${er}\\)$`),ic={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};ci(tr,ro,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:sc,formatHex:sc,formatHex8:kg,formatHsl:Rg,formatRgb:ac,toString:ac});function sc(){return this.rgb().formatHex()}function kg(){return this.rgb().formatHex8()}function Rg(){return fc(this).formatHsl()}function ac(){return this.rgb().formatRgb()}function ro(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=Ag.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?lc(t):o===3?new Ue(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?di(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?di(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=Cg.exec(e))?new Ue(t[1],t[2],t[3],1):(t=Sg.exec(e))?new Ue(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Mg.exec(e))?di(t[1],t[2],t[3],t[4]):(t=Pg.exec(e))?di(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Lg.exec(e))?uc(t[1],t[2]/100,t[3]/100,1):(t=Dg.exec(e))?uc(t[1],t[2]/100,t[3]/100,t[4]):ic.hasOwnProperty(e)?lc(ic[e]):e==="transparent"?new Ue(NaN,NaN,NaN,0):null}function lc(e){return new Ue(e>>16&255,e>>8&255,e&255,1)}function di(e,t,o,n){return n<=0&&(e=t=o=NaN),new Ue(e,t,o,n)}function Og(e){return e instanceof tr||(e=ro(e)),e?(e=e.rgb(),new Ue(e.r,e.g,e.b,e.opacity)):new Ue}function gn(e,t,o,n){return arguments.length===1?Og(e):new Ue(e,t,o,n==null?1:n)}function Ue(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}ci(Ue,gn,Hs(tr,{brighter(e){return e=e==null?pi:Math.pow(pi,e),new Ue(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?jn:Math.pow(jn,e),new Ue(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ue(Mo(this.r),Mo(this.g),Mo(this.b),fi(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:cc,formatHex:cc,formatHex8:Vg,formatRgb:dc,toString:dc}));function cc(){return`#${So(this.r)}${So(this.g)}${So(this.b)}`}function Vg(){return`#${So(this.r)}${So(this.g)}${So(this.b)}${So((isNaN(this.opacity)?1:this.opacity)*255)}`}function dc(){let e=fi(this.opacity);return`${e===1?"rgb(":"rgba("}${Mo(this.r)}, ${Mo(this.g)}, ${Mo(this.b)}${e===1?")":`, ${e})`}`}function fi(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Mo(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function So(e){return e=Mo(e),(e<16?"0":"")+e.toString(16)}function uc(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new ft(e,t,o,n)}function fc(e){if(e instanceof ft)return new ft(e.h,e.s,e.l,e.opacity);if(e instanceof tr||(e=ro(e)),!e)return new ft;if(e instanceof ft)return e;e=e.rgb();var t=e.r/255,o=e.g/255,n=e.b/255,r=Math.min(t,o,n),i=Math.max(t,o,n),a=NaN,s=i-r,l=(i+r)/2;return s?(t===i?a=(o-n)/s+(o<n)*6:o===i?a=(n-t)/s+2:a=(t-o)/s+4,s/=l<.5?i+r:2-i-r,a*=60):s=l>0&&l<1?0:a,new ft(a,s,l,e.opacity)}function mc(e,t,o,n){return arguments.length===1?fc(e):new ft(e,t,o,n==null?1:n)}function ft(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}ci(ft,mc,Hs(tr,{brighter(e){return e=e==null?pi:Math.pow(pi,e),new ft(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?jn:Math.pow(jn,e),new ft(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,o=this.l,n=o+(o<.5?o:1-o)*t,r=2*o-n;return new Ue(Gs(e>=240?e-240:e+120,r,n),Gs(e,r,n),Gs(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new ft(pc(this.h),ui(this.s),ui(this.l),fi(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=fi(this.opacity);return`${e===1?"hsl(":"hsla("}${pc(this.h)}, ${ui(this.s)*100}%, ${ui(this.l)*100}%${e===1?")":`, ${e})`}`}}));function pc(e){return e=(e||0)%360,e<0?e+360:e}function ui(e){return Math.max(0,Math.min(1,e||0))}function Gs(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 Bs(e,t,o,n,r){var i=e*e,a=i*e;return((1-3*e+3*i-a)*t+(4-6*i+3*a)*o+(1+3*e+3*i-3*a)*n+a*r)/6}function gc(e){var t=e.length-1;return function(o){var n=o<=0?o=0:o>=1?(o=1,t-1):Math.floor(o*t),r=e[n],i=e[n+1],a=n>0?e[n-1]:2*r-i,s=n<t-1?e[n+2]:2*i-r;return Bs((o-n/t)*t,a,r,i,s)}}function hc(e){var t=e.length;return function(o){var n=Math.floor(((o%=1)<0?++o:o)*t),r=e[(n+t-1)%t],i=e[n%t],a=e[(n+1)%t],s=e[(n+2)%t];return Bs((o-n/t)*t,r,i,a,s)}}var zs=e=>()=>e;function Hg(e,t){return function(o){return e+o*t}}function Gg(e,t,o){return e=Math.pow(e,o),t=Math.pow(t,o)-e,o=1/o,function(n){return Math.pow(e+n*t,o)}}function yc(e){return(e=+e)==1?mi:function(t,o){return o-t?Gg(t,o,e):zs(isNaN(t)?o:t)}}function mi(e,t){var o=t-e;return o?Hg(e,o):zs(isNaN(e)?t:e)}var gi=(function e(t){var o=yc(t);function n(r,i){var a=o((r=gn(r)).r,(i=gn(i)).r),s=o(r.g,i.g),l=o(r.b,i.b),c=mi(r.opacity,i.opacity);return function(d){return r.r=a(d),r.g=s(d),r.b=l(d),r.opacity=c(d),r+""}}return n.gamma=e,n})(1);function xc(e){return function(t){var o=t.length,n=new Array(o),r=new Array(o),i=new Array(o),a,s;for(a=0;a<o;++a)s=gn(t[a]),n[a]=s.r||0,r[a]=s.g||0,i[a]=s.b||0;return n=e(n),r=e(r),i=e(i),s.opacity=1,function(l){return s.r=n(l),s.g=r(l),s.b=i(l),s+""}}}var Bg=xc(gc),zg=xc(hc);function nt(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var Ys=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Fs=new RegExp(Ys.source,"g");function Fg(e){return function(){return e}}function Yg(e){return function(t){return e(t)+""}}function Ws(e,t){var o=Ys.lastIndex=Fs.lastIndex=0,n,r,i,a=-1,s=[],l=[];for(e=e+"",t=t+"";(n=Ys.exec(e))&&(r=Fs.exec(t));)(i=r.index)>o&&(i=t.slice(o,i),s[a]?s[a]+=i:s[++a]=i),(n=n[0])===(r=r[0])?s[a]?s[a]+=r:s[++a]=r:(s[++a]=null,l.push({i:a,x:nt(n,r)})),o=Fs.lastIndex;return o<t.length&&(i=t.slice(o),s[a]?s[a]+=i:s[++a]=i),s.length<2?l[0]?Yg(l[0].x):Fg(t):(t=l.length,function(c){for(var d=0,u;d<t;++d)s[(u=l[d]).i]=u.x(c);return s.join("")})}var Ec=180/Math.PI,hi={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Xs(e,t,o,n,r,i){var a,s,l;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(l=e*o+t*n)&&(o-=e*l,n-=t*l),(s=Math.sqrt(o*o+n*n))&&(o/=s,n/=s,l/=s),e*n<t*o&&(e=-e,t=-t,l=-l,a=-a),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*Ec,skewX:Math.atan(l)*Ec,scaleX:a,scaleY:s}}var yi;function _c(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?hi:Xs(t.a,t.b,t.c,t.d,t.e,t.f)}function bc(e){return e==null?hi:(yi||(yi=document.createElementNS("http://www.w3.org/2000/svg","g")),yi.setAttribute("transform",e),(e=yi.transform.baseVal.consolidate())?(e=e.matrix,Xs(e.a,e.b,e.c,e.d,e.e,e.f)):hi)}function Tc(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:nt(c,u)},{i:E-2,x:nt(d,p)})}else(u||p)&&f.push("translate("+u+t+p+o)}function a(c,d,u,p){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),p.push({i:u.push(r(u)+"rotate(",null,n)-2,x:nt(c,d)})):d&&u.push(r(u)+"rotate("+d+n)}function s(c,d,u,p){c!==d?p.push({i:u.push(r(u)+"skewX(",null,n)-2,x:nt(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:nt(c,u)},{i:E-2,x:nt(d,p)})}else(u!==1||p!==1)&&f.push(r(f)+"scale("+u+","+p+")")}return function(c,d){var u=[],p=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,u,p),a(c.rotate,d.rotate,u,p),s(c.skewX,d.skewX,u,p),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,p),c=d=null,function(f){for(var x=-1,E=p.length,m;++x<E;)u[(m=p[x]).i]=m.x(f);return u.join("")}}}var Us=Tc(_c,"px, ","px)","deg)"),$s=Tc(bc,", ",")",")");var hn=0,nr=0,or=0,Nc=1e3,xi,rr,Ei=0,Po=0,_i=0,ir=typeof performance=="object"&&performance.now?performance:Date,wc=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ar(){return Po||(wc(Wg),Po=ir.now()+_i)}function Wg(){Po=0}function sr(){this._call=this._time=this._next=null}sr.prototype=bi.prototype={constructor:sr,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?ar():+o)+(t==null?0:+t),!this._next&&rr!==this&&(rr?rr._next=this:xi=this,rr=this),this._call=e,this._time=o,Ks()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ks())}};function bi(e,t,o){var n=new sr;return n.restart(e,t,o),n}function Ic(){ar(),++hn;for(var e=xi,t;e;)(t=Po-e._time)>=0&&e._call.call(void 0,t),e=e._next;--hn}function vc(){Po=(Ei=ir.now())+_i,hn=nr=0;try{Ic()}finally{hn=0,Ug(),Po=0}}function Xg(){var e=ir.now(),t=e-Ei;t>Nc&&(_i-=t,Ei=e)}function Ug(){for(var e,t=xi,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:xi=o);rr=e,Ks(n)}function Ks(e){if(!hn){nr&&(nr=clearTimeout(nr));var t=e-Po;t>24?(e<1/0&&(nr=setTimeout(vc,e-ir.now()-_i)),or&&(or=clearInterval(or))):(or||(Ei=ir.now(),or=setInterval(Xg,Nc)),hn=1,wc(vc))}}function Ti(e,t,o){var n=new sr;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var $g=ks("start","end","cancel","interrupt"),Kg=[],Sc=0,Ac=1,Ni=2,vi=3,Cc=4,wi=5,lr=6;function io(e,t,o,n,r,i){var a=e.__transition;if(!a)e.__transition={};else if(o in a)return;qg(e,o,{name:t,index:n,group:r,on:$g,tween:Kg,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Sc})}function cr(e,t){var o=Pe(e,t);if(o.state>Sc)throw new Error("too late; already scheduled");return o}function He(e,t){var o=Pe(e,t);if(o.state>vi)throw new Error("too late; already running");return o}function Pe(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function qg(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=bi(i,0,o.time);function i(c){o.state=Ac,o.timer.restart(a,o.delay,o.time),o.delay<=c&&a(c-o.delay)}function a(c){var d,u,p,f;if(o.state!==Ac)return l();for(d in n)if(f=n[d],f.name===o.name){if(f.state===vi)return Ti(a);f.state===Cc?(f.state=lr,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete n[d]):+d<t&&(f.state=lr,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete n[d])}if(Ti(function(){o.state===vi&&(o.state=Cc,o.timer.restart(s,o.delay,o.time),s(c))}),o.state=Ni,o.on.call("start",e,e.__data__,o.index,o.group),o.state===Ni){for(o.state=vi,r=new Array(p=o.tween.length),d=0,u=-1;d<p;++d)(f=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++u]=f);r.length=u+1}}function s(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=wi,1),u=-1,p=r.length;++u<p;)r[u].call(e,d);o.state===wi&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=lr,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function qs(e,t){var o=e.__transition,n,r,i=!0,a;if(o){t=t==null?null:t+"";for(a in o){if((n=o[a]).name!==t){i=!1;continue}r=n.state>Ni&&n.state<wi,n.state=lr,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[a]}i&&delete e.__transition}}function Mc(e){return this.each(function(){qs(this,e)})}function Zg(e,t){var o,n;return function(){var r=He(this,e),i=r.tween;if(i!==o){n=o=i;for(var a=0,s=n.length;a<s;++a)if(n[a].name===t){n=n.slice(),n.splice(a,1);break}}r.tween=n}}function Jg(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=He(this,e),a=i.tween;if(a!==n){r=(n=a).slice();for(var s={name:t,value:o},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=s;break}l===c&&r.push(s)}i.tween=r}}function Pc(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=Pe(this.node(),o).tween,r=0,i=n.length,a;r<i;++r)if((a=n[r]).name===e)return a.value;return null}return this.each((t==null?Zg:Jg)(o,e,t))}function yn(e,t,o){var n=e._id;return e.each(function(){var r=He(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return Pe(r,n).value[t]}}function Ii(e,t){var o;return(typeof t=="number"?nt:t instanceof ro?gi:(o=ro(t))?(t=o,gi):Ws)(e,t)}function Qg(e){return function(){this.removeAttribute(e)}}function jg(e){return function(){this.removeAttributeNS(e.space,e.local)}}function eh(e,t,o){var n,r=o+"",i;return function(){var a=this.getAttribute(e);return a===r?null:a===n?i:i=t(n=a,o)}}function th(e,t,o){var n,r=o+"",i;return function(){var a=this.getAttributeNS(e.space,e.local);return a===r?null:a===n?i:i=t(n=a,o)}}function oh(e,t,o){var n,r,i;return function(){var a,s=o(this),l;return s==null?void this.removeAttribute(e):(a=this.getAttribute(e),l=s+"",a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s)))}}function nh(e,t,o){var n,r,i;return function(){var a,s=o(this),l;return s==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),l=s+"",a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s)))}}function Lc(e,t){var o=Gt(e),n=o==="transform"?$s:Ii;return this.attrTween(e,typeof t=="function"?(o.local?nh:oh)(o,n,yn(this,"attr."+e,t)):t==null?(o.local?jg:Qg)(o):(o.local?th:eh)(o,n,t))}function rh(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function ih(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function sh(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&ih(e,i)),o}return r._value=t,r}function ah(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&rh(e,i)),o}return r._value=t,r}function Dc(e,t){var o="attr."+e;if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;var n=Gt(e);return this.tween(o,(n.local?sh:ah)(n,t))}function lh(e,t){return function(){cr(this,e).delay=+t.apply(this,arguments)}}function ch(e,t){return t=+t,function(){cr(this,e).delay=t}}function kc(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?lh:ch)(t,e)):Pe(this.node(),t).delay}function dh(e,t){return function(){He(this,e).duration=+t.apply(this,arguments)}}function uh(e,t){return t=+t,function(){He(this,e).duration=t}}function Rc(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?dh:uh)(t,e)):Pe(this.node(),t).duration}function ph(e,t){if(typeof t!="function")throw new Error;return function(){He(this,e).ease=t}}function Oc(e){var t=this._id;return arguments.length?this.each(ph(t,e)):Pe(this.node(),t).ease}function fh(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;He(this,e).ease=o}}function Vc(e){if(typeof e!="function")throw new Error;return this.each(fh(this._id,e))}function Hc(e){typeof e!="function"&&(e=Jn(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=[],l,c=0;c<a;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&s.push(l);return new Fe(n,this._parents,this._name,this._id)}function Gc(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,o=e._groups,n=t.length,r=o.length,i=Math.min(n,r),a=new Array(n),s=0;s<i;++s)for(var l=t[s],c=o[s],d=l.length,u=a[s]=new Array(d),p,f=0;f<d;++f)(p=l[f]||c[f])&&(u[f]=p);for(;s<n;++s)a[s]=t[s];return new Fe(a,this._parents,this._name,this._id)}function mh(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 gh(e,t,o){var n,r,i=mh(t)?cr:He;return function(){var a=i(this,e),s=a.on;s!==n&&(r=(n=s).copy()).on(t,o),a.on=r}}function Bc(e,t){var o=this._id;return arguments.length<2?Pe(this.node(),o).on.on(e):this.each(gh(o,e,t))}function hh(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function zc(){return this.on("end.remove",hh(this._id))}function Fc(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Co(e));for(var n=this._groups,r=n.length,i=new Array(r),a=0;a<r;++a)for(var s=n[a],l=s.length,c=i[a]=new Array(l),d,u,p=0;p<l;++p)(d=s[p])&&(u=e.call(d,d.__data__,p,s))&&("__data__"in d&&(u.__data__=d.__data__),c[p]=u,io(c[p],t,o,p,c,Pe(d,o)));return new Fe(i,this._parents,t,o)}function Yc(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Zn(e));for(var n=this._groups,r=n.length,i=[],a=[],s=0;s<r;++s)for(var l=n[s],c=l.length,d,u=0;u<c;++u)if(d=l[u]){for(var p=e.call(d,d.__data__,u,l),f,x=Pe(d,o),E=0,m=p.length;E<m;++E)(f=p[E])&&io(f,t,o,E,p,x);i.push(p),a.push(d)}return new Fe(i,a,t,o)}var yh=Bt.prototype.constructor;function Wc(){return new yh(this._groups,this._parents)}function xh(e,t){var o,n,r;return function(){var i=no(this,e),a=(this.style.removeProperty(e),no(this,e));return i===a?null:i===o&&a===n?r:r=t(o=i,n=a)}}function Xc(e){return function(){this.style.removeProperty(e)}}function Eh(e,t,o){var n,r=o+"",i;return function(){var a=no(this,e);return a===r?null:a===n?i:i=t(n=a,o)}}function _h(e,t,o){var n,r,i;return function(){var a=no(this,e),s=o(this),l=s+"";return s==null&&(l=s=(this.style.removeProperty(e),no(this,e))),a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s))}}function bh(e,t){var o,n,r,i="style."+t,a="end."+i,s;return function(){var l=He(this,e),c=l.on,d=l.value[i]==null?s||(s=Xc(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(a,r=d),l.on=n}}function Uc(e,t,o){var n=(e+="")=="transform"?Us:Ii;return t==null?this.styleTween(e,xh(e,n)).on("end.style."+e,Xc(e)):typeof t=="function"?this.styleTween(e,_h(e,n,yn(this,"style."+e,t))).each(bh(this._id,e)):this.styleTween(e,Eh(e,n,t),o).on("end.style."+e,null)}function Th(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function vh(e,t,o){var n,r;function i(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&Th(e,a,o)),n}return i._value=t,i}function $c(e,t,o){var n="style."+(e+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;return this.tween(n,vh(e,t,o==null?"":o))}function Nh(e){return function(){this.textContent=e}}function wh(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function Kc(e){return this.tween("text",typeof e=="function"?wh(yn(this,"text",e)):Nh(e==null?"":e+""))}function Ih(e){return function(t){this.textContent=e.call(this,t)}}function Ah(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&Ih(r)),t}return n._value=e,n}function qc(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,Ah(e))}function Zc(){for(var e=this._name,t=this._id,o=Ai(),n=this._groups,r=n.length,i=0;i<r;++i)for(var a=n[i],s=a.length,l,c=0;c<s;++c)if(l=a[c]){var d=Pe(l,t);io(l,e,o,c,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Fe(n,this._parents,e,o)}function Jc(){var e,t,o=this,n=o._id,r=o.size();return new Promise(function(i,a){var s={value:a},l={value:function(){--r===0&&i()}};o.each(function(){var c=He(this,n),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(l)),c.on=t}),r===0&&i()})}var Ch=0;function Fe(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function Qc(e){return Bt().transition(e)}function Ai(){return++Ch}var zt=Bt.prototype;Fe.prototype=Qc.prototype={constructor:Fe,select:Fc,selectAll:Yc,selectChild:zt.selectChild,selectChildren:zt.selectChildren,filter:Hc,merge:Gc,selection:Wc,transition:Zc,call:zt.call,nodes:zt.nodes,node:zt.node,size:zt.size,empty:zt.empty,each:zt.each,on:Bc,attr:Lc,attrTween:Dc,style:Uc,styleTween:$c,text:Kc,textTween:qc,remove:zc,tween:Pc,delay:kc,duration:Rc,ease:Oc,easeVarying:Vc,end:Jc,[Symbol.iterator]:zt[Symbol.iterator]};function Ci(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Sh={time:null,delay:0,duration:250,ease:Ci};function Mh(e,t){for(var o;!(o=e.__transition)||!(o=o[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return o}function jc(e){var t,o;e instanceof Fe?(t=e._id,e=e._name):(t=Ai(),(o=Sh).time=ar(),e=e==null?null:e+"");for(var n=this._groups,r=n.length,i=0;i<r;++i)for(var a=n[i],s=a.length,l,c=0;c<s;++c)(l=a[c])&&io(l,e,t,c,a,o||Mh(l,t));return new Fe(n,this._parents,e,t)}Bt.prototype.interrupt=Mc;Bt.prototype.transition=jc;function so(e,t,o){this.k=e,this.x=t,this.y=o}so.prototype={constructor:so,scale:function(e){return e===1?this:new so(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new so(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 Si=new so(1,0,0);Mi.prototype=so.prototype;function Mi(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Si;return e.__zoom}var Lh=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var ed;(function(e){e.Strict="strict",e.Loose="loose"})(ed||(ed={}));var td;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(td||(td={}));var od;(function(e){e.Partial="partial",e.Full="full"})(od||(od={}));var nd;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(nd||(nd={}));var rd;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(rd||(rd={}));var $e;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})($e||($e={}));var $T={[$e.Left]:$e.Right,[$e.Right]:$e.Left,[$e.Top]:$e.Bottom,[$e.Bottom]:$e.Top};var Dh=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var kh=(e,t=[0,0])=>{var s;let{width:o,height:n}=Rh(e),r=(s=e.origin)!=null?s:t,i=o*r[0],a=n*r[1];return{x:e.position.x-i,y:e.position.y-a}};var Pi=(e,t=[0,0])=>{var r,i,a,s,l,c,d,u;let{x:o,y:n}=Dh(e)?e.internals.positionAbsolute:kh(e,t);return{x:o,y:n,x2:o+((s=(a=(i=(r=e.measured)==null?void 0:r.width)!=null?i:e.width)!=null?a:e.initialWidth)!=null?s:0),y2:n+((u=(d=(c=(l=e.measured)==null?void 0:l.height)!=null?c:e.height)!=null?d:e.initialHeight)!=null?u:0)}};function Rh(e){var t,o,n,r,i,a,s,l;return{width:(r=(n=(o=(t=e.measured)==null?void 0:t.width)!=null?o:e.width)!=null?n:e.initialWidth)!=null?r:0,height:(l=(s=(a=(i=e.measured)==null?void 0:i.height)!=null?a:e.height)!=null?s:e.initialHeight)!=null?l:0}}var KT={[$e.Left]:{x:-1,y:0},[$e.Right]:{x:1,y:0},[$e.Top]:{x:0,y:-1},[$e.Bottom]:{x:0,y:1}};var Oh={nodeOrigin:[0,0],nodeExtent:Lh,elevateNodesOnSelect:!0,defaults:{}},qT=I(T({},Oh),{checkEquality:!0});var id;(function(e){e.Line="line",e.Handle="handle"})(id||(id={}));var Vh={width:0,height:0,x:0,y:0},ZT=I(T({},Vh),{pointerX:0,pointerY:0,aspectRatio:1});var Hh=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function Gh(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 Bh(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 Li=class{constructor(){this.xLines=[];this.yLines=[]}initialize(t){this.xLines=t.filter(o=>o.orientation==="vertical"),this.yLines=t.filter(o=>o.orientation==="horizontal"),this.xLines.sort((o,n)=>o.position-n.position),this.yLines.sort((o,n)=>o.position-n.position),this.lastHorizontalLine=void 0,this.lastVerticalLine=void 0}search(t,o,n,r,i){let a=t==="horizontal"?this.yLines:this.xLines,[s,l]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],c=[];for(let f of a){if(f.position<s)continue;if(f.position>l)break;if(i.has(f.node.id)||f.node.parentId&&i.has(f.node.parentId)||!Hh(f.nodeBox,r))continue;let x=Math.abs(f.position-o);if(x>Di)continue;let m=Gh(f.nodeBox,n)>0?0:Bh(f.nodeBox,n);c.push({line:f,lineDist:x,nodeDist:m})}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 sd(e,t=Lo,o){let n=[];return e==null||e.forEach(r=>{let i=o(r.id);if(!i)throw new Error(`Node with id ${r.id} not found in internal nodes.`);let a=Pi(i);Object.entries(t).forEach(([s,l])=>{var c;n.push({position:l.resolve(r,a),color:(c=r.style)==null?void 0:c.backgroundColor,orientation:l.orientation,anchorName:s,nodeBox:a,node:r})})}),n}function ad(e,t,o,n,r=Object.keys(Lo)){let i=[];for(let s of r){let l=Lo[s],c=l.resolve(null,o),d=e.search(l.orientation,c,o,t,n);d&&i.push({sourcePosition:c,anchorName:s,anchor:l,line:d})}let a={horizontal:void 0,vertical:void 0};for(let s of i){let l=a[s.anchor.orientation],c=Math.abs(s.sourcePosition-s.line.position);(!l||c<Math.abs(l.sourcePosition-l.line.position))&&(a[s.anchor.orientation]=s)}return a}function ld(e,t,o){let n=0,r=0,i=!1,a=!1;if(t){let l=t.anchor.resolve(null,e)-t.line.position;Math.abs(l)<=Di&&(r=l,a=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=Di&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:a}}var Di=10,Lo={top:{orientation:"horizontal",resolve:(e,t)=>t.y},bottom:{orientation:"horizontal",resolve:(e,t)=>t.y2},left:{orientation:"vertical",resolve:(e,t)=>t.x},right:{orientation:"vertical",resolve:(e,t)=>t.x2},centerX:{orientation:"vertical",resolve:(e,t)=>(t.x+t.x2)/2},centerY:{orientation:"horizontal",resolve:(e,t)=>(t.y+t.y2)/2}};var ud=require("react/jsx-runtime"),zh=new Li;function Fh(e,t,o,n){var d,u,p,f,x,E;let r=1/0,i=1/0,a=-1/0,s=-1/0,l=new Set;for(let m of e){let h=t.find(w=>w.id===m.id);if(!h)continue;l.add(h.id);let g=o(h.id);if(!g)continue;let y=g.parentId?o(g.parentId):void 0,v=m.position.x+((d=y==null?void 0:y.internals.positionAbsolute.x)!=null?d:0),_=m.position.y+((u=y==null?void 0:y.internals.positionAbsolute.y)!=null?u:0),N=(f=(p=h.measured)==null?void 0:p.width)!=null?f:0,b=(E=(x=h.measured)==null?void 0:x.height)!=null?E:0;r=Math.min(r,v),i=Math.min(i,_),a=Math.max(a,v+N),s=Math.max(s,_+b)}if(r===1/0)return null;let c=Object.keys(Lo);return{bounds:{x:r,y:i,x2:a,y2:s},excludedNodeIds:l,anchors:n?["top","left"]:c}}function Yh(e,t,o){var c,d,u,p,f,x,E,m;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,a=r.internals.positionAbsolute.y,s=(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:(x=n.measured)==null?void 0:x.height)!=null?m:0;return{bounds:{x:i,y:a,x2:i+s,y2:a+l},excludedNodeIds:new Set([n.id]),anchors:["right","bottom"]}}function Wh(e,t,o,n){return e.length>0?Fh(e,o,n,!!t):t?Yh(t,o,n):null}function cd(e,t,o,n){var r;e!=null&&e.dimensions&&(e.id===((r=t[0])==null?void 0:r.id)?e.dimensions[o]+=n:t.length||(e.dimensions[o]-=n))}function Xh(e,t,o,n,r,i){r&&(e.forEach(a=>{a.position&&(a.position.x-=o)}),cd(t,e,"width",o)),i&&(e.forEach(a=>{a.position&&(a.position.y-=n)}),cd(t,e,"height",n))}function ki(){let[e,t]=(0,Ze.useState)(void 0),[o,n]=(0,Ze.useState)(void 0),{width:r,height:i}=(0,xn.useStore)(m=>({width:m.width,height:m.height}),dd.shallow),a=(0,xn.useNodesInitialized)(),s=(0,Ze.useRef)(zh),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=(0,xn.useReactFlow)(),u=(0,Ze.useCallback)(()=>{t(void 0),n(void 0)},[]),p=(0,Ze.useCallback)(m=>{let h=m!=null?m:d();u();let g=sd(h,Lo,c);s.current.initialize(g)},[c,u,d]),f=(0,Ze.useCallback)(()=>{setTimeout(()=>{p()},100)},[p]);(0,Ze.useEffect)(()=>{a&&p(d())},[a,p,d]);let x=(0,Ze.useCallback)((m,h)=>{if(!s.current||m.length===0)return;let g=m.filter(C=>C.type==="dimensions");if(g.length>1)return;u();let y=m.filter(C=>C.type==="position"&&!!C.position),v=g[0];if(y.length===0&&!v)return;let _=Wh(y,v,h,c);if(!_)return;let{x:N,y:b}=l({x:0,y:0}),{x:w,y:S}=l({x:r,y:i}),M={x:N,y:b,x2:w,y2:S},{horizontal:L,vertical:D}=ad(s.current,M,_.bounds,_.excludedNodeIds,_.anchors),{deltaX:O,deltaY:R,snappedX:V,snappedY:G}=ld(_.bounds,L,D);if(!V&&!G)return;let B=y.some(C=>C.dragging),A=!!(v!=null&&v.resizing);(B||A)&&(V&&n(D==null?void 0:D.line),G&&t(L==null?void 0:L.line)),Xh(y,v,O,R,V,G)},[l,c,r,i,t,n,u]),E=(0,Ze.useCallback)(()=>(0,ud.jsx)(pd,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:p,forceRebuildIndex:f,updateHelperLines:x,helperLineHorizontal:e,helperLineVertical:o,HelperLines:E}}var us=require("@xyflow/react"),Lt=require("react");var Ft=e=>new Map(e.map(t=>[t.id,t])),dr=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),fd=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),Zs=e=>e.some(t=>t.type==="START_EVENT"),En=(e,t)=>e==="START_EVENT"?!Zs(t):!0,md=(e,t,o,n,r)=>{let i=Ft(o),a=i.get(e);if(!a||a.type!=="START_EVENT")return!1;let s=i.get(t);return(s==null?void 0:s.type)==="ANNOTATION"?!1:dr(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},gd=(e,t,o,n,r)=>{let i=Ft(o),a=i.get(t);if(!a||a.type!=="END_EVENT")return!1;let s=i.get(e);return(s==null?void 0:s.type)==="ANNOTATION"?!1:fd(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Ri=(e,t,o,n,r)=>{var c;let i=Ft(o),a=i.get(e);if(!a||a.type!=="GATEWAY"||((c=a.data)==null?void 0:c.variant)!=="EXCLUSIVE")return!1;let s=t?i.get(t):null;return(s==null?void 0:s.type)==="ANNOTATION"?!1:dr(e,n,r).filter(d=>{let u=i.get(d.target);return(u==null?void 0:u.type)!=="ANNOTATION"}).length>=2},hd=(e,t,o)=>{var a,s,l,c;let n=Ft(o),r=n.get(e),i=n.get(t);return(r==null?void 0:r.type)!=="GATEWAY"||(i==null?void 0:i.type)!=="GATEWAY"||((a=r==null?void 0:r.data)==null?void 0:a.variant)==="EXCLUSIVE"&&((s=i==null?void 0:i.data)==null?void 0:s.variant)==="PARALLEL"||((l=r==null?void 0:r.data)==null?void 0:l.variant)==="COMPLEX"&&((c=i==null?void 0:i.data)==null?void 0:c.variant)==="PARALLEL"},Oi=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SCRIPT"},yd=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SUBPROCESS"},ur=(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"},Vi=(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"},Do=(e,t,o,n)=>{let r=Ft(t),i=r.get(e);return!i||i.type!=="TASK"?!1:fd(e,o,n).some(s=>{let l=r.get(s.source);return(l==null?void 0:l.type)==="START_EVENT"})},pr=(e,t,o,n)=>{let r=Ft(t),i=r.get(e);return!i||i.type!=="TASK"?!1:dr(e,o,n).some(s=>{let l=r.get(s.target);return(l==null?void 0:l.type)==="END_EVENT"})},xd=(e,t,o,n,r)=>{let i=Ft(o),a=i.get(e),s=i.get(t);return(a==null?void 0:a.type)==="START_EVENT"&&(s==null?void 0:s.type)==="TASK"?pr(t,o,n,r):(s==null?void 0:s.type)==="END_EVENT"&&(a==null?void 0:a.type)==="TASK"?Do(e,o,n,r):!1},Hi=(e,t,o)=>dr(e,t,o).length>0,Gi=(e,t,o,n,r)=>{let i=Ft(o),a=i.get(e);if(!a||a.type!=="TASK")return!1;let s=t?i.get(t):null;return(s==null?void 0:s.type)==="ANNOTATION"?!1:dr(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var Ed=(e,t,o,n,r)=>{var s,l;let i=Ft(n),a=((s=i.get(e))==null?void 0:s.type)==="ANNOTATION"||((l=i.get(t))==null?void 0:l.type)==="ANNOTATION";return o.some(c=>r&&c.id===r?!1:!!(c.source===e&&c.target===t||a&&c.source===t&&c.target===e))};var Uh=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!Ed(e.sourceNodeId,e.targetNodeId,e.edges,e.nodes,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!md(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!gd(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!Ri(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!Gi(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:hd(e.sourceNodeId,e.targetNodeId,e.nodes),reason:"gateway_to_gateway_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&e.targetNodeType==="END_EVENT"),reason:"start_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&yd(e.targetNodeId,e.nodes)),reason:"start_event_to_subprocess_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&ur(e.targetNodeId,e.nodes)),reason:"start_event_to_service_task_not_allowed"}),e=>({isValid:!(ur(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:!(Oi(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(Vi(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(Do(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!xd(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(pr(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(Hi(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"})],Js=e=>{for(let t of Uh){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var $h=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:Ri(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:Zs(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Oi(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Vi(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:ur(e.sourceNodeId,e.nodes),reason:"service_task_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Do(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:pr(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Hi(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Gi(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],_d=e=>{let t=$h.filter(o=>{let n=!o.sourceTypes||o.sourceTypes.includes(e.sourceNodeType),r=!o.targetTypes||o.targetTypes.includes(e.targetNodeType);return n&&r});for(let o of t){let n=o.validate(e);if(n.shouldDisable)return n}return{shouldDisable:!1}};var rt={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:"arrowclosed"},markerEnd:{type:"arrow"},data:{label:""}},_n={type:"ANNOTATION_EDGE",reconnectable:!0,data:{label:""}};var wr=require("react"),hp=require("use-debounce");var gp=require("@xyflow/react"),Nr=require("react");var fr=(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))(fr||{});var ea=Xn(require("@dagrejs/dagre"),1);var Bi={MIN_WIDTH:36,DEFAULT_WIDTH:36,MIN_HEIGHT:36,DEFAULT_HEIGHT:36},zi={MIN_WIDTH:36,DEFAULT_WIDTH:36,MIN_HEIGHT:36,DEFAULT_HEIGHT:36},bn={MIN_WIDTH:40,DEFAULT_WIDTH:56,MIN_HEIGHT:40,DEFAULT_HEIGHT:56},Yt={MIN_WIDTH:60,DEFAULT_WIDTH:176,MIN_HEIGHT:60,DEFAULT_HEIGHT:96},bd={HEADER_WIDTH:40,MIN_WIDTH:150,DEFAULT_WIDTH:840,MIN_HEIGHT:150,DEFAULT_HEIGHT:256},J={HEADER_WIDTH:40,MIN_WIDTH:150,DEFAULT_WIDTH:800,MIN_HEIGHT:150,DEFAULT_HEIGHT:256},ko={MIN_WIDTH:40,DEFAULT_WIDTH:176,MIN_HEIGHT:40,DEFAULT_HEIGHT:64},Kh={MIN_WIDTH:126,DEFAULT_WIDTH:128,MIN_HEIGHT:60,DEFAULT_HEIGHT:64},te={START_EVENT:Bi,END_EVENT:zi,GATEWAY:bn,TASK:Yt,LANE:J,ANNOTATION:ko,UNSUPPORTED:Kh};var qh=50,Ro=(e,t)=>{var p,f,x,E,m,h,g,y,v,_,N,b,w,S,M,L;let o=t.find(D=>D.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=(m=o.measured)==null?void 0:m.width)!=null?h:0,a=(y=(g=o.measured)==null?void 0:g.height)!=null?y:0,s=r+a,l=n+i,c=new Set,d=1/0;for(let D of t){if(D.id===e||D.parentId)continue;let O=(_=(v=D.position)==null?void 0:v.y)!=null?_:0,R=(b=(N=D.position)==null?void 0:N.x)!=null?b:0,V=(S=(w=D.measured)==null?void 0:w.width)!=null?S:0,G=(L=(M=D.measured)==null?void 0:M.height)!=null?L:0;R<l&&R+V>n&&O<s&&O+G>r&&(c.add(D.id),d=Math.min(d,O))}if(c.size===0)return t;let u=s+qh-d;return t.map(D=>{var R,V,G;if(!c.has(D.id))return D;let O=(V=(R=D.position)==null?void 0:R.y)!=null?V:0;return I(T({},D),{position:I(T({},(G=D.position)!=null?G:{x:0,y:0}),{y:O+u})})})},Te=15,Oo=e=>[...e].sort((t,o)=>t.position.y-o.position.y),Zh=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)},Jh=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)},Qs=(e,t,o)=>{var d,u,p,f,x,E,m,h,g,y,v,_,N,b,w,S,M,L,D,O,R;if(t.length===0){let V=I(T({},e),{width:(p=(u=e.width)!=null?u:(d=e.measured)==null?void 0:d.width)!=null?p:J.MIN_WIDTH,height:(E=(x=e.height)!=null?x:(f=e.measured)==null?void 0:f.height)!=null?E:J.MIN_HEIGHT});return o.set(e.id,V),V}let n=(g=(h=e.width)!=null?h:(m=e.measured)==null?void 0:m.width)!=null?g:0,r=(_=(v=e.height)!=null?v:(y=e.measured)==null?void 0:y.height)!=null?_:0,i=0,a=0;for(let V of t){let G=Zh(V),B=Jh(V);if(((b=(N=V.position)==null?void 0:N.y)!=null?b:0)<Te&&(o.set(V.id,I(T({},V),{position:I(T({},V.position),{y:Te})})),B=Te+((S=(w=V.measured)==null?void 0:w.height)!=null?S:0)),((L=(M=V.position)==null?void 0:M.x)!=null?L:0)<J.HEADER_WIDTH+Te){let A=(D=o.get(V.id))!=null?D:V;o.set(V.id,I(T({},A),{position:I(T({},A.position),{x:J.HEADER_WIDTH+Te})})),G=J.HEADER_WIDTH+Te+((R=(O=V.measured)==null?void 0:O.width)!=null?R:0)}i=Math.max(i,G),a=Math.max(a,B)}let s=Math.max(n,J.MIN_WIDTH),l=Math.max(r,J.MIN_HEIGHT);i+Te>s&&(s=i+Te),a+Te>l&&(l=a+Te);let c=I(T({},e),{width:s,height:l,measured:I(T({},e.measured),{width:s,height:l})});return o.set(e.id,c),c},Td=(e,t,o)=>{var a,s,l,c;let n=Oo(e),r=new Map;for(let d of o)d.parentId&&(r.has(d.parentId)||r.set(d.parentId,[]),r.get(d.parentId).push(d));let i=0;for(let d of n){let u=(a=r.get(d.id))!=null?a:[],p=Qs(d,u,t);t.set(p.id,I(T({},p),{position:{x:J.HEADER_WIDTH,y:i}})),i+=(c=(l=p.height)!=null?l:(s=p.measured)==null?void 0:s.height)!=null?c:0}},vd=(e,t)=>{var x,E,m,h,g,y;let o=[];for(let v of t.values())v.parentId===e.id&&o.push(v);let n=Oo(o),r=((E=(x=e.measured)==null?void 0:x.width)!=null?E:0)-J.HEADER_WIDTH,i=cl(e.id,o)||J.MIN_WIDTH,a=o.reduce((v,_)=>{var N,b,w;return v+((w=(b=_.height)!=null?b:(N=_.measured)==null?void 0:N.height)!=null?w:J.MIN_HEIGHT)},0),s=Math.max(r,i),l=a,c=r>i,d=c?s:s+J.HEADER_WIDTH,u=c?s-J.HEADER_WIDTH:s,p=0;for(let v=0;v<n.length;v++){let _=n[v],N=Math.max(J.MIN_HEIGHT,(g=(h=_.height)!=null?h:(m=_.measured)==null?void 0:m.height)!=null?g:J.MIN_HEIGHT),b=I(T({},_),{width:u,height:N,measured:I(T({},_.measured),{width:u,height:N}),position:{x:J.HEADER_WIDTH,y:p}});if(v===o.length-1){let w=Math.max(J.MIN_HEIGHT,l-p);b=I(T({},b),{height:w,measured:I(T({},_.measured),{width:u,height:w})})}t.set(_.id,b),p+=(y=b.height)!=null?y:0}let f=Math.max(l,p);t.set(e.id,I(T({},e),{width:d,height:f,measured:I(T({},e.measured),{width:d,height:f})}))},Nd=(e,t,o,n,r)=>{var x,E;let i=!e.parentId,a=i?e.id:e.parentId,s=n.filter(m=>m.type==="LANE"&&m.parentId===a);if(!s.length)return n;let l=Oo(s),c=l.findIndex(m=>m.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((m,h)=>{var N,b;let g=h===l.length-1,y=m.id===e.id,_=(b=(N=m.measured)==null?void 0:N.height)!=null?b:0;y?_=o:u&&h===c-1&&(_=Math.max(J.MIN_HEIGHT,r-p)),g&&i&&(_=Math.max(J.MIN_HEIGHT,o-p)),f=f.map(w=>{if(w.id===m.id){let S=i?t-J.HEADER_WIDTH:t;return I(T({},w),{width:S,height:_,measured:I(T({},w.measured),{width:S,height:_}),position:{x:J.HEADER_WIDTH,y:p}})}return w}),y&&u?p=r+o:p+=_}),f=f.map(m=>{if(m.id===a){let h=i?t:t+J.HEADER_WIDTH;return I(T({},m),{width:h,height:i?o:p,measured:{width:h,height:i?o:p}})}return m}),f};var js=(e,t,o)=>{var s,l,c,d,u,p,f,x;if(e.type==="LANE")return o;let n=(l=(s=t.measured)==null?void 0:s.width)!=null?l:0,r=(d=(c=t.measured)==null?void 0:c.height)!=null?d:0;e.position.y<Te&&(e.position.y=Te),e.position.x<J.HEADER_WIDTH+Te&&(e.position.x=J.HEADER_WIDTH+Te);let i=e.position.x+((p=(u=e.measured)==null?void 0:u.width)!=null?p:0),a=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),a+Te>r&&(t.height=a+Te,t.measured.height=a+Te),o=o.map(E=>E.id===t.id?I(T({},E),{height:t.height,width:t.width,measured:t.measured}):E.id===e.id?I(T({},E),{position:e.position}):E),o},wd=e=>{var i,a;let t=e.filter(s=>s.type==="LANE");if(t.length===0)return e;let o=new Map(e.map(s=>[s.id,No(s.id,e)])),n=s=>{var p,f,x,E,m,h,g;let{x:l,y:c}=(p=o.get(s.id))!=null?p:{x:0,y:0},d=(E=(x=(f=s.measured)==null?void 0:f.width)!=null?x:s.width)!=null?E:0,u=(g=(h=(m=s.measured)==null?void 0:m.height)!=null?h:s.height)!=null?g:0;return{x1:l,y1:c,x2:l+d,y2:c+u,w:d,h:u}},r=new Map;for(let s of e){if(s.type==="LANE")continue;let{x1:l,y1:c,w:d,h:u}=n(s),p=l+d/2,f=c+u/2,x=t.filter(g=>{let{x1:y,x2:v,y1:_,y2:N}=n(g);return p>=y&&p<=v&&f>=_&&f<=N});if(x.length===0)continue;let E=x.reduce((g,y)=>{if(!g)return y;let v=!!g.parentId,_=!!y.parentId;if(_&&!v)return y;if(!_&&v)return g;let{x1:N,y1:b,w,h:S}=n(g),{x1:M,y1:L,w:D,h:O}=n(y),R=Math.hypot(N+w/2-p,b+S/2-f);return Math.hypot(M+D/2-p,L+O/2-f)<R?y:g},null);if(!E||s.parentId===E.id)continue;let m=(i=o.get(s.id))!=null?i:{x:0,y:0},h=(a=o.get(E.id))!=null?a:{x:0,y:0};r.set(s.id,{parentId:E.id,position:{x:m.x-h.x,y:m.y-h.y}})}return r.size===0?e:e.map(s=>{let l=r.get(s.id);return l?I(T({},s),{parentId:l.parentId,position:l.position}):s})};var Fi=(e=[],t=[],o="LR")=>{let n=new ea.default.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:i,width:a,height:s})=>n.setNode(i,{width:a,height:s})),t.forEach(i=>n.setEdge(i.source,i.target)),ea.default.layout(n),{nodes:e.map(i=>{let a=n.node(i.id);return I(T({},i),{position:{x:a.x-i.width/2,y:a.y-i.height/2}})}),edges:t}},Wt=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId);if(t.length===0)return e;let o=sl(e);for(let n of t){let r=[...o.values()],i=r.filter(s=>s.parentId===n.id);if(i.length===0)continue;let a=i.filter(s=>s.type==="LANE");if(a.length>0){Td(a,o,r),vd(n,o);continue}Qs(n,i,o)}return al(e,o)},Id=Wt,Ad=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)};var mr=1,Cd=e=>`<mxGraphModel>
|
|
2
2
|
<root version="1.1">
|
|
3
3
|
<mxCell id="0" />
|
|
4
4
|
<mxCell id="1" parent="0" />
|
|
@@ -31,16 +31,16 @@
|
|
|
31
31
|
<mxGeometry as="geometry" relative="1" />
|
|
32
32
|
</mxCell>
|
|
33
33
|
</root>
|
|
34
|
-
</mxGraphModel>`,Sd=(e,t)=>{if(!e.length&&!t.length)return
|
|
35
|
-
`),E=x.length;l=x.reduce((h,g)=>Math.max(h,g.length),0)*7+r,c=E*20+i}let d=Math.max(eo(Number(a),t),l),u=Math.max(eo(Number(s),o),c);return{width:d,height:u,measured:{width:d,height:u}}},vn=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,parent:r,value:i}=t,a={x:Number(o._attributes.x||0),y:Number(o._attributes.y||0)},s={id:n,position:a,className:void 0,data:{label:i||""}},l=r==="1"?void 0:r;return l&&(s.parentId=l),s},ey=e=>{let{mxGeometry:t}=e,o=vn(e),n=Tn(t,te.START_EVENT.MIN_WIDTH,te.START_EVENT.MIN_HEIGHT);return I(T(T({},o),n),{type:"START_EVENT"})},ty=e=>{let{mxGeometry:t}=e,o=vn(e),n=Tn(t,te.END_EVENT.MIN_WIDTH,te.END_EVENT.MIN_HEIGHT);return I(T(T({},o),n),{type:"END_EVENT"})},Xi=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=vn(e),s=Tn(n,te.TASK.MIN_WIDTH,te.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=Dd[d];u&&(r.data.attribute=u)}let c=kd[o.style];return c&&(r.data.variant=c),I(T(T({},r),s),{type:"TASK"})},oa=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=vn(e),i=Tn(o,te.GATEWAY.MIN_WIDTH,te.GATEWAY.MIN_HEIGHT);return r.data.variant=Rd[n],I(T(T({},r),i),{type:"GATEWAY"})},oy=e=>{let{mxGeometry:t}=e,o=vn(e),i=Tn(t,te.ANNOTATION.MIN_WIDTH,te.ANNOTATION.MIN_HEIGHT,o.data.label,32,24);return I(T(T({},o),i),{type:"ANNOTATION"})},ny=e=>{let{mxGeometry:t}=e,o=vn(e),n=Tn(t,te.LANE.MIN_WIDTH,te.LANE.MIN_HEIGHT);return I(T(T({},o),n),{type:"LANE"})},Hd={task:Xi,"task-script":Xi,"subprocess-collapsed":Xi,"service-task":Xi,"start-event":ey,"end-event-terminate":ty,"gateway-parallel":oa,"gateway-exclusive":oa,"gateway-complex":oa,annotation:oy,lane:ny},Gd=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,{id:r,source:i,target:a,value:s,style:l,parent:c,labelOffsetX:d,labelOffsetY:u}=o,p=Ld(n==null?void 0:n.Array),f;if(p!=null&&p.points.length){let[h]=p.points;if(p.space==="parent"){let g=No(c==="1"?void 0:c,t!=null?t:[]);f={x:h.x+g.x,y:h.y+g.y}}else f=h}let x=d!==void 0?Number(d):void 0,E=u!==void 0?Number(u):void 0,m={id:r,source:i,target:a,data:T(T({label:s||""},f?{controlPoint:f}:{}),x!==void 0&&E!==void 0?{labelOffset:{x,y:E}}:{})};return l.includes("association")&&l.includes('endArrow=""')?T(T({},_n),m):T(T({},rt),m)},Bd=(e,t)=>{let{id:o,type:n,source:r,target:i,data:a}=e,s=t==null?void 0:t.find(E=>E.id===r),l=t==null?void 0:t.find(E=>E.id===i),c="";n==="ANNOTATION_EDGE"&&(c='association;endArrow=""');let d=s!=null&&s.parentId&&s.parentId===(l==null?void 0:l.parentId)?s.parentId:"1",u={_attributes:{as:"geometry",relative:"1"}},p=a==null?void 0:a.controlPoint;if(p){let E=No(d==="1"?void 0:d,t!=null?t:[]);u.Array={_attributes:{as:"points"},mxPoint:[{_attributes:{x:p.x-E.x,y:p.y-E.y}}]}}let f=a==null?void 0:a.labelOffset;return{_attributes:{id:o,parent:d,edge:"1",style:c,source:r,target:i,value:(a==null?void 0:a.label)||"",labelOffsetX:f?String(f.x):void 0,labelOffsetY:f?String(f.y):void 0},mxGeometry:u}},Nn=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}}}},ry=e=>{let{variant:t}=e.data,o=Nn(e);return I(T({},o),{_attributes:I(T({},o._attributes),{style:Od[t]||"task"})})},iy=e=>{let t=Nn(e);return I(T({},t),{_attributes:I(T({},t._attributes),{style:"start-event"})})},sy=e=>{let t=Nn(e);return I(T({},t),{_attributes:I(T({},t._attributes),{style:"end-event-terminate"})})},ay=e=>{let{variant:t}=e.data,o=Nn(e);return I(T({},o),{_attributes:I(T({},o._attributes),{style:Vd[t]})})},ly=e=>{let t=Nn(e);return I(T({},t),{_attributes:I(T({},t._attributes),{style:"lane"})})},cy=e=>{let t=Nn(e);return I(T({},t),{_attributes:I(T({},t._attributes),{style:"annotation"})})},zd={TASK:ry,START_EVENT:iy,END_EVENT:sy,GATEWAY:ay,ANNOTATION:cy,LANE:ly},Fd=(e,t)=>{var a,s;let r=((a=e.measured)==null?void 0:a.width)||0,i=((s=e.measured)==null?void 0:s.height)||0;return{_attributes:{id:`${t+1}`,parent:e.id,style:"attribute-loop",connectable:"0"},mxGeometry:{_attributes:{as:"geometry",x:r/2-22/2,y:i-22,width:22,height:22}}}};var dy=e=>{let t=Object.values(
|
|
34
|
+
</mxGraphModel>`,Sd=(e,t)=>{if(!e.length&&!t.length)return mr;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var Yi=require("xml-js");var Md={compact:!0,spaces:4},Qh=e=>e.replace(/\n/g,"
");function Wi(e,t=Md){if(e)return JSON.parse((0,Yi.xml2json)(e,t))}function Pd(e,t=Md){return e?(0,Yi.json2xml)(e,I(T({},t),{attributeValueFn:Qh})):""}var ta=e=>({x:Number(e._attributes.x),y:Number(e._attributes.y)}),Ld=e=>{var t;if(e){if(!Array.isArray(e)&&"mxPoint"in e&&e.mxPoint)return{points:(Array.isArray(e.mxPoint)?e.mxPoint:[e.mxPoint]).map(ta),space:"parent"};if(Array.isArray(e))return{points:e.map(ta),space:"absolute"};if("_attributes"in e&&((t=e._attributes)==null?void 0:t.as)==="mxPoint")return{points:[ta(e)],space:"absolute"}}};var Dd={"attribute-loop":"LOOP"},kd={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS","service-task":"SERVICE_TASK"},Rd={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Od={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed",SERVICE_TASK:"service-task"},Vd={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var Tn=(e,t,o,n,r,i)=>{let a=e._attributes.width||0,s=e._attributes.height||0,l=0,c=0;if(n&&r!==void 0&&i!==void 0){let x=n.split(`
|
|
35
|
+
`),E=x.length;l=x.reduce((h,g)=>Math.max(h,g.length),0)*7+r,c=E*20+i}let d=Math.max(eo(Number(a),t),l),u=Math.max(eo(Number(s),o),c);return{width:d,height:u,measured:{width:d,height:u}}},vn=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,parent:r,value:i}=t,a={x:Number(o._attributes.x||0),y:Number(o._attributes.y||0)},s={id:n,position:a,className:void 0,data:{label:i||""}},l=r==="1"?void 0:r;return l&&(s.parentId=l),s},ey=e=>{let{mxGeometry:t}=e,o=vn(e),n=Tn(t,te.START_EVENT.MIN_WIDTH,te.START_EVENT.MIN_HEIGHT);return I(T(T({},o),n),{type:"START_EVENT"})},ty=e=>{let{mxGeometry:t}=e,o=vn(e),n=Tn(t,te.END_EVENT.MIN_WIDTH,te.END_EVENT.MIN_HEIGHT);return I(T(T({},o),n),{type:"END_EVENT"})},Xi=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=vn(e),s=Tn(n,te.TASK.MIN_WIDTH,te.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=Dd[d];u&&(r.data.attribute=u)}let c=kd[o.style];return c&&(r.data.variant=c),I(T(T({},r),s),{type:"TASK"})},oa=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=vn(e),i=Tn(o,te.GATEWAY.MIN_WIDTH,te.GATEWAY.MIN_HEIGHT);return r.data.variant=Rd[n],I(T(T({},r),i),{type:"GATEWAY"})},oy=e=>{let{mxGeometry:t}=e,o=vn(e),i=Tn(t,te.ANNOTATION.MIN_WIDTH,te.ANNOTATION.MIN_HEIGHT,o.data.label,32,24);return I(T(T({},o),i),{type:"ANNOTATION"})},ny=e=>{let{mxGeometry:t}=e,o=vn(e),n=Tn(t,te.LANE.MIN_WIDTH,te.LANE.MIN_HEIGHT);return I(T(T({},o),n),{type:"LANE"})},Hd={task:Xi,"task-script":Xi,"subprocess-collapsed":Xi,"service-task":Xi,"start-event":ey,"end-event-terminate":ty,"gateway-parallel":oa,"gateway-exclusive":oa,"gateway-complex":oa,annotation:oy,lane:ny},Gd=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,{id:r,source:i,target:a,value:s,style:l,parent:c,labelOffsetX:d,labelOffsetY:u}=o,p=Ld(n==null?void 0:n.Array),f;if(p!=null&&p.points.length){let[h]=p.points;if(p.space==="parent"){let g=No(c==="1"?void 0:c,t!=null?t:[]);f={x:h.x+g.x,y:h.y+g.y}}else f=h}let x=d!==void 0?Number(d):void 0,E=u!==void 0?Number(u):void 0,m={id:r,source:i,target:a,data:T(T({label:s||""},f?{controlPoint:f}:{}),x!==void 0&&E!==void 0?{labelOffset:{x,y:E}}:{})};return l.includes("association")&&l.includes('endArrow=""')?T(T({},_n),m):T(T({},rt),m)},Bd=(e,t)=>{let{id:o,type:n,source:r,target:i,data:a}=e,s=t==null?void 0:t.find(E=>E.id===r),l=t==null?void 0:t.find(E=>E.id===i),c="";n==="ANNOTATION_EDGE"&&(c='association;endArrow=""');let d=s!=null&&s.parentId&&s.parentId===(l==null?void 0:l.parentId)?s.parentId:"1",u={_attributes:{as:"geometry",relative:"1"}},p=a==null?void 0:a.controlPoint;if(p){let E=No(d==="1"?void 0:d,t!=null?t:[]);u.Array={_attributes:{as:"points"},mxPoint:[{_attributes:{x:p.x-E.x,y:p.y-E.y}}]}}let f=a==null?void 0:a.labelOffset;return{_attributes:{id:o,parent:d,edge:"1",style:c,source:r,target:i,value:(a==null?void 0:a.label)||"",labelOffsetX:f?String(f.x):void 0,labelOffsetY:f?String(f.y):void 0},mxGeometry:u}},Nn=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}}}},ry=e=>{let{variant:t}=e.data,o=Nn(e);return I(T({},o),{_attributes:I(T({},o._attributes),{style:Od[t]||"task"})})},iy=e=>{let t=Nn(e);return I(T({},t),{_attributes:I(T({},t._attributes),{style:"start-event"})})},sy=e=>{let t=Nn(e);return I(T({},t),{_attributes:I(T({},t._attributes),{style:"end-event-terminate"})})},ay=e=>{let{variant:t}=e.data,o=Nn(e);return I(T({},o),{_attributes:I(T({},o._attributes),{style:Vd[t]})})},ly=e=>{let t=Nn(e);return I(T({},t),{_attributes:I(T({},t._attributes),{style:"lane"})})},cy=e=>{let t=Nn(e);return I(T({},t),{_attributes:I(T({},t._attributes),{style:"annotation"})})},zd={TASK:ry,START_EVENT:iy,END_EVENT:sy,GATEWAY:ay,ANNOTATION:cy,LANE:ly},Fd=(e,t)=>{var a,s;let r=((a=e.measured)==null?void 0:a.width)||0,i=((s=e.measured)==null?void 0:s.height)||0;return{_attributes:{id:`${t+1}`,parent:e.id,style:"attribute-loop",connectable:"0"},mxGeometry:{_attributes:{as:"geometry",x:r/2-22/2,y:i-22,width:22,height:22}}}};var dy=e=>{let t=Object.values(fr),o=e.filter(i=>{var s;let a=(s=i._attributes)==null?void 0:s.style;return t.includes(a)}),n=e.filter(i=>{var s;let a=(s=i._attributes)==null?void 0:s.style;return["attribute-loop"].includes(a)}),r=[];for(let i of o){let{style:a}=i._attributes,s=Hd[a],l=s==null?void 0:s(i,n);if(!l){console.warn(`Node ${a} not supported`);continue}r.push(l)}return r},uy=(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=Gd(r,t),a=t.find(c=>c.id===i.source),s=t.find(c=>c.id===i.target);((a==null?void 0:a.type)==="LANE"||(s==null?void 0:s.type)==="LANE")&&i.type!=="ANNOTATION_EDGE"||n.push(i)}return n},py=(e,t)=>{let o=[];return e.forEach(n=>{var a,s;let r=(s=(a=zd)[n.type])==null?void 0:s.call(a,n);if(!r){console.warn(`Node ${n.type} not supported`);return}if(o.push(r),n.type==="TASK"&&n.data.attribute==="LOOP"){let l=Fd(n,t);o.push(l)}}),o},fy=(e,t)=>{let o=[];return e.forEach(n=>{let r=Bd(n,t);o.push(r)}),o},my=(e=[],t=[],o)=>{let n=py(e,o),r=fy(t,e);return{mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}}},wn=(e=[],t=[],o)=>{let n=my(e,t,o);return Pd(JSON.stringify(n),{compact:!0,spaces:0})},Yd=async e=>{var a,s,l,c,d;let t=await Wi(e),o=((s=(a=t==null?void 0:t.mxGraphModel)==null?void 0:a.root)==null?void 0:s.mxCell)||[],n=Number(((d=(c=(l=t==null?void 0:t.mxGraphModel)==null?void 0:l.root)==null?void 0:c._attributes)==null?void 0:d.lastId)||mr),r=dy(o);r=wd(r),r=Id(r),r=wo(r);let i=uy(o,r);return{lastElementId:n,nodes:r,edges:i}};var cs=require("@xyflow/react"),fp=require("react");var hu=require("@xyflow/react"),ji=require("react");var mt=require("react");var ra=require("react/jsx-runtime"),na=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,Wd=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Escape","Shift"],Re=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:a,onBlur:s,onInput:l,onInvalidFirstCharacter:c,skipFirstCharValidation:d})=>{let u=(0,mt.useRef)(null),p=(0,mt.useRef)(null),[f,x]=(0,mt.useState)(!1);(0,mt.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]),(0,mt.useEffect)(()=>{x(i!=null?i:!1)},[i]),(0,mt.useEffect)(()=>{if(f&&u.current){u.current.focus();let _=document.createRange();_.selectNodeContents(u.current);let N=window.getSelection();N&&(N.removeAllRanges(),N.addRange(_))}},[f]);let E=(0,mt.useCallback)(()=>{p.current||(c==null||c(),p.current=setTimeout(()=>{p.current=null},500))},[c]),m=_=>{_.stopPropagation(),f||x(!0)},h=_=>{let N=_.currentTarget.innerText.replace(/\n$/,""),b=t&&N.length>=t,w=window.getSelection(),S=(w==null?void 0:w.toString())||"",M=S.length>0,L=(_.ctrlKey||_.metaKey)&&!_.altKey,D=L&&_.key==="a",O=L&&_.key==="c",R=L&&_.key==="x",V=L&&_.key==="v",G=N.length===0||M&&S.length===N.length;if(!d&&G&&!na.test(_.key)&&!Wd.includes(_.key)&&!L){_.preventDefault(),E();return}b&&!M&&(Wd.includes(_.key)||D||O||R||V||_.preventDefault())},g=_=>{_.preventDefault();let N=_.clipboardData.getData("text/plain").replace(/\r\n/g,`
|
|
36
36
|
`).replace(/\r/g,`
|
|
37
37
|
`),b=_.currentTarget.innerText.replace(/\n$/,""),w=window.getSelection();if(!w||w.rangeCount===0)return;let S=w.toString(),M=b.length-S.length,L=t?Math.max(0,t-M):1/0;if(L<=0&&S.length===0)return;let D=N;if(D.length>L&&(D=D.substring(0,L)),!D&&S.length===0)return;let O=w.getRangeAt(0),R=O.startOffset===0&&(O.startContainer===_.currentTarget||O.startContainer.parentNode===_.currentTarget);if(!d&&R&&D.length>0&&!na.test(D[0])){E();return}O.deleteContents();let V=document.createTextNode(D);O.insertNode(V),O.setStartAfter(V),O.collapse(!0),w.removeAllRanges(),w.addRange(O),l==null||l(_.currentTarget.innerText.replace(/\n$/,""))},y=_=>{let N=_.currentTarget,b=N.innerText.replace(/\n$/,"");if(!d&&b.length>0&&!na.test(b[0])){let w=b.slice(1);if(N.innerText=w,w.length>0&&N.firstChild){let S=document.createRange(),M=window.getSelection();S.setStart(N.firstChild,0),S.collapse(!0),M==null||M.removeAllRanges(),M==null||M.addRange(S)}E(),l==null||l(w);return}l==null||l(b)},v=_=>{x(!1);let N=_.currentTarget.innerText.replace(/\r\n/g,`
|
|
38
38
|
`).replace(/\r/g,`
|
|
39
|
-
`).trim();t&&N.length>t&&(N=N.substring(0,t)),_.currentTarget.innerText=N,s==null||s(),N!==e&&(a==null||a(N))};return(0,ra.jsx)("div",{className:F("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:(0,ra.jsx)("div",{ref:u,className:F("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":f}),contentEditable:f,suppressContentEditableWarning:!0,onKeyDown:h,onPaste:g,onInput:y,onBlur:v,children:e})})};var Vo=require("@xyflow/react");var gr=require("@xyflow/react"),Jd=require("react");function ia(e,t,o){return e.x<=t&&e.x+e.width>=t&&e.y<=o&&e.y+e.height>=o}function sa(e){return e.x+e.width/2}function aa(e){return e.y+e.height/2}function Ui(e){return{x:e.x,y:e.y,width:0,height:0}}function wn(e,t,o,n){!ia(t,n.x,n.y)&&!ia(o,n.x,n.y)&&e.push(n)}function Xd(e,t,o,n,r){let i=[],a=o?Ui(o):e,s=n?Ui(n):t,l=Math.max(a.x,s.x),c=Math.min(a.x+a.width,s.x+s.width),d=r?r.x:Math.round(c+(l-c)/2),u=aa(a),p=aa(s);if(r&&(r.y>=a.y&&r.y<=a.y+a.height&&(u=r.y),r.y>=s.y&&r.y<=s.y+s.height&&(p=r.y)),wn(i,s,a,{x:d,y:u}),wn(i,s,a,{x:d,y:p}),i.length===0)if(r)wn(i,s,a,{x:d,y:r.y});else{let f=Math.max(a.y,s.y),x=Math.min(a.y+a.height,s.y+s.height);i.push({x:d,y:f+(x-f)/2})}return i}function Ud(e,t,o,n,r){let i=[],a=o?Ui(o):e,s=n?Ui(n):t,l=Math.max(a.y,s.y),c=Math.min(a.y+a.height,s.y+s.height),d=sa(a);r&&r.x>=a.x&&r.x<=a.x+a.width&&(d=r.x);let u=r?r.y:Math.round(c+(l-c)/2);if(wn(i,s,a,{x:d,y:u}),r&&r.x>=s.x&&r.x<=s.x+s.width?d=r.x:d=sa(s),wn(i,s,a,{x:d,y:u}),i.length===0)if(r)wn(i,s,a,{x:r.x,y:u});else{let p=Math.max(a.x,s.x),f=Math.min(a.x+a.width,s.x+s.width);i.push({x:p+(f-p)/2,y:u})}return i}function la(e,t,o,n,r){let i=!1,a=!1;if(r){let s=Math.min(e.x,t.x),l=Math.max(e.x+e.width,t.x+t.width),c=Math.min(e.y,t.y),d=Math.max(e.y+e.height,t.y+t.height);i=r.y<c||r.y>d,a=r.x<s||r.x>l}else{let s=Math.max(e.x,t.x),l=Math.min(e.x+e.width,t.x+t.width);if(i=s===l,!i){let c=Math.max(e.y,t.y),d=Math.min(e.y+e.height,t.y+t.height);a=c===d}}return!a&&i?{waypoints:Ud(e,t,o,n,r),direction:"top-to-bottom"}:{waypoints:Xd(e,t,o,n,r),direction:"side-to-side"}}function gy(e,t,o){return t.x>=o.x&&t.x<=o.x+o.width?e.x=t.x:t.y>=o.y&&t.y<=o.y+o.height&&(e.y=t.y),t.x<o.x?e.x=o.x:t.x>o.x+o.width&&(e.x=o.x+o.width),t.y<o.y?e.y=o.y:t.y>o.y+o.height&&(e.y=o.y+o.height),e}function $d(e,t,o,n=0){let r=n?{x:e.x-n,y:e.y-n,width:e.width+2*n,height:e.height+2*n}:e,i=r.x+r.width/2,a=r.y+r.height/2,s=t.x-i,l=t.y-a,c=Math.atan2(l,s),d={x:0,y:0},u=Math.PI,f=Math.PI/2-c,x=Math.atan2(r.height,r.width);return c<-u+x||c>u-x?(d.x=r.x,d.y=a-r.width*Math.tan(c)/2):c<-x?(d.y=r.y,d.x=i-r.height*Math.tan(f)/2):c<x?(d.x=r.x+r.width,d.y=a+r.width*Math.tan(c)/2):(d.y=r.y+r.height,d.x=i+r.height*Math.tan(f)/2),o?gy(d,t,r):d}function hy(e,t,o,n,r,i){let a=e-o,s=t-n;if(i>=s&&i<=t+n){let l=i-t,c=Math.sqrt(o*o*(1-l*l/(n*n)))||0;return r<=a&&(c=-c),{x:e+c,y:i}}if(r>=a&&r<=e+o){let l=r-e,c=Math.sqrt(n*n*(1-l*l/(o*o)))||0;return i<=s&&(c=-c),{x:r,y:t+c}}}function Kd(e,t,o,n=0){let r=e.x-n,i=e.y-n,a=e.width+2*n,s=e.height+2*n,l=a/2,c=s/2,d=r+l,u=i+c,p=t.x,f=t.y,x=Math.trunc(p-d),E=Math.trunc(f-u);if(x===0&&E!==0)return{x:d,y:u+c*E/Math.abs(E)};if(x===0&&E===0)return{x:p,y:f};if(o){let D=hy(d,u,l,c,p,f);if(D)return D}let m=E/x,h=u-m*d,g=l*l*m*m+c*c,y=-2*d*g,v=l*l*m*m*d*d+c*c*d*d-l*l*c*c,_=Math.sqrt(y*y-4*g*v),N=(-y+_)/(2*g),b=(-y-_)/(2*g),w=m*N+h,S=m*b+h,M=Math.sqrt(Math.pow(N-p,2)+Math.pow(w-f,2)),L=Math.sqrt(Math.pow(b-p,2)+Math.pow(S-f,2));return M<L?{x:N,y:w}:{x:b,y:S}}function ca(e){return e==="ellipse"?Kd:$d}function Zd(e){let{x:t,y:o,width:n,height:r}=e.bounds;return{x:t+n/2,y:o+r/2}}function yy(e,t,o){let n=null;if(e.length>=2){let r=e.length;n=e[o?Math.min(1,r-1):Math.max(0,r-2)]}return n!=null||(n=Zd(t)),n}function qd(e,t,o,n){let r=yy(e,o,n);return t.bounds.width<=0&&t.bounds.height<=0?Zd(t):ca(t.perimeter)(t.bounds,r,!0,0)}function Xt(e){var p;let{source:t,target:o,controlPoint:n=null,fixedSourcePoint:r=null,fixedTargetPoint:i=null}=e,a=r,s=i,{waypoints:l,direction:c}=la(t.bounds,o.bounds,a,s,n),d=[a,...l,s];d.at(-1)==null&&(d[d.length-1]=qd(d,o,t,!1)),(p=d[0])!=null||(d[0]=qd(d,t,o,!0));let u=d;return{points:u,sourcePoint:u[0],targetPoint:u.at(-1),waypoints:l,direction:c}}function da(e,t){let o=Xt({source:e,target:t});return xy(o.targetPoint,t.bounds)}function xy(e,t){if(Math.abs(e.x-t.x)<=1)return"left";if(Math.abs(e.x-(t.x+t.width))<=1)return"right";if(Math.abs(e.y-t.y)<=1)return"top";if(Math.abs(e.y-(t.y+t.height))<=1)return"bottom";let n=t.x+t.width/2,r=t.y+t.height/2,i=Math.abs(e.x-n),a=Math.abs(e.y-r);return i>=a?e.x<n?"left":"right":e.y<r?"top":"bottom"}function Qd(e){var i;let{inProgress:t,fromNode:o}=(0,gr.useConnection)(),n=(0,gr.useInternalNode)(e),r=(0,gr.useInternalNode)((i=o==null?void 0:o.id)!=null?i:"");return(0,Jd.useMemo)(()=>!t||!r||r.id===e||!n?null:da(Ht(r),Ht(n)),[t,r,e,n])}var hr=require("@xyflow/react");var ua=require("react/jsx-runtime"),In=i=>{var a=i,{type:e,position:t,className:o,nodeType:n}=a,r=bt(a,["type","position","className","nodeType"]);let s=n==="TASK";return(0,ua.jsx)(hr.Handle,T({type:e,position:t,className:F("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":s,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":!s},o)},r))},jd=s=>{var l=s,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,a=bt(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=(0,hr.useReactFlow)(),p=(()=>{if(n!=="source")return!1;let f=c();if(t==="TASK")return f.filter(E=>E.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return f.filter(E=>E.source===e).length>=2;if(t==="START_EVENT"){let x=d();return f.filter(m=>{if(m.source!==e)return!1;let h=x.find(g=>g.id===m.target);return(h==null?void 0:h.type)!=="ANNOTATION"}).length>=1}return!1})();return(0,ua.jsx)(hr.Handle,T({type:n,position:r,className:F("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"}},a))};var lo=require("react/jsx-runtime"),eu=[{position:Vo.Position.Left,side:"left"},{position:Vo.Position.Right,side:"right"},{position:Vo.Position.Top,side:"top"},{position:Vo.Position.Bottom,side:"bottom"}],it=({nodeId:e,nodeType:t,gatewayVariant:o,targetHandleClassName:n,conditionalSource:r=!1})=>{let{inProgress:i,fromNode:a,toNode:s,isValid:l}=(0,Vo.useConnection)(),{reconnectingEdgeId:c}=Y(),d=Qd(e),u=i&&(a==null?void 0:a.id)!==e||!!c,p=!i||u,f=!!s&&s.id===e;return(0,lo.jsxs)(lo.Fragment,{children:[p&&eu.map(({position:x,side:E})=>{let m=u&&(d===null||E===d);return(0,lo.jsx)(In,{type:"target",position:x,id:E,className:F(m&&n,m&&f&&(l?"valid":"connectingto"))},`target-${E}`)}),!i&&eu.map(({position:x,side:E})=>r?(0,lo.jsx)(jd,{type:"source",position:x,id:E,nodeId:e,nodeType:t,gatewayVariant:o},`source-${E}`):(0,lo.jsx)(In,{type:"source",position:x,id:E},`source-${E}`))]})};var pa=require("react"),Ut=require("@xyflow/react");var tu=require("react"),ou=require("@xyflow/react");function Nt(){return(0,ou.useStore)((0,tu.useCallback)(e=>e.nodes.filter(o=>o.selected).length+e.edges.filter(o=>o.selected).length>=2,[]))}var nu=require("@xyflow/react"),$i=()=>{let e=(0,nu.useStoreApi)();return{getInternalNodes:()=>{let{nodeLookup:o}=e.getState();return Array.from(o.values())}}};var Ki=require("react/jsx-runtime"),fa=require("react"),Ey=["top","right","bottom","left"],_y=["top-left","top-middle","top-right","right-middle","bottom-left","left-middle","bottom-right","bottom-middle"],st=r=>{var i=r,{nodeId:e,isVisible:t,offset:o=8}=i,n=bt(i,["nodeId","isVisible","offset"]);let{getInternalNode:a,setNodes:s}=(0,Ut.useReactFlow)(),{getInternalNodes:l}=$i(),c=Nt(),d=(0,Ut.useStoreApi)(),u=(0,pa.useRef)(0),p=(0,pa.useRef)([]),f=({y:h,width:g,height:y})=>{cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{var V,G;if(!e)return;let{nodeLookup:v,onNodesChange:_}=d.getState(),N=v.get(e);if(!N||N.type!=="LANE")return;let b=!N.parentId,w=b?N.id:N.parentId;if(!w)return;let S=Array.from(v.values()).filter(B=>B.type==="LANE"&&B.parentId===w);if(!S.length)return;p.current.length===0&&(p.current=Oo(S).map(B=>B.id));let M=p.current.map(B=>S.find(A=>A.id===B)).filter(Boolean),L=[],D=0,O=M.findIndex(B=>B.id===N.id),R=!b&&O>0&&Math.abs(h-N.position.y)>.5;for(let B=0;B<M.length;B++){let A=M[B],C=A.id===N.id,k=B===M.length-1;if(C){D=R?h+y:D+y;continue}let P=(G=(V=A.measured)==null?void 0:V.height)!=null?G:0,K=b?g-J.HEADER_WIDTH:g,Z=P;b&&k&&(Z=Math.max(J.MIN_HEIGHT,y-D)),R&&B===O-1&&(Z=Math.max(J.MIN_HEIGHT,h-D)),L.push({id:A.id,type:"dimensions",dimensions:{width:K,height:Z},setAttributes:!0}),L.push({id:A.id,type:"position",position:{x:J.HEADER_WIDTH,y:D}}),D+=Z}b?L.push({id:w,type:"dimensions",dimensions:{width:g,height:y},setAttributes:!0}):L.push({id:w,type:"dimensions",dimensions:{width:g+J.HEADER_WIDTH,height:D},setAttributes:!0}),_==null||_(L)})},x=({y:h,width:g,height:y})=>{var N;if(cancelAnimationFrame(u.current),p.current=[],!e)return;let v=a(e);if(!v||v.type!=="LANE"&&!v.parentId)return;let _=[...l()];if(v.type!=="LANE"){_=_.map(b=>b.id===e?I(T({},b),{width:g,height:y,measured:{width:g,height:y}}):b),_=Wt(_),s(_);return}_=Nd(v,g,y,_,h),_=Wt(_),_=Ro((N=v.parentId)!=null?N:v.id,_),s(_)};if(!(!c&&t))return null;let m={"--resize-offset":`${o}px`};return(0,Ki.jsxs)(Ki.Fragment,{children:[Ey.map(h=>(0,fa.createElement)(Ut.NodeResizeControl,I(T({},n),{key:h,nodeId:e,position:h,variant:Ut.ResizeControlVariant.Line,className:"border-blue-400/90 border-dashed",style:m,onResize:(g,y)=>f(y),onResizeEnd:(g,y)=>x(y)}))),_y.map(h=>(0,fa.createElement)(Ut.NodeResizeControl,I(T({},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:m,onResize:(g,y)=>f(y),onResizeEnd:(g,y)=>x(y)})))]})};var zo=require("@xyflow/react"),Ct=require("@produto-lecom/lecom-ui"),Ge=Wn(require("react"),1);var ru=require("zustand"),An=(0,ru.create)(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));var qi=require("react"),iu=(e,t=!1)=>{let[o,n]=(0,qi.useState)({width:0,height:0});return(0,qi.useEffect)(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};var co=require("@xyflow/react"),su=require("react"),by=120,Ty=12,au=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=(0,co.useReactFlow)(),{instanceId:i}=Y();return(0,su.useMemo)(()=>{var f,x;if(!t)return{position:co.Position.Right,align:"start"};let a=n(e);if(!a)return{position:co.Position.Right,align:"start"};let s=r(),l=a.position.x*s.zoom+s.x,c=(((f=a.measured)==null?void 0:f.width)||a.width||100)*s.zoom,d=(x=document.getElementById(`modeler-${i}`))==null?void 0:x.clientWidth;if(!d)return{position:co.Position.Right,align:"start"};let u=(o==null?void 0:o.width)||by;return{position:l+c+u+Ty>d?co.Position.Left:co.Position.Right}},[i,e,t,o,n,r])};var ma=require("lucide-react");var Zi=require("@xyflow/react"),ie=require("@produto-lecom/lecom-ui"),lu=require("lucide-react");var me=require("react/jsx-runtime"),cu=({nodeId:e})=>{let{t}=(0,ie.useTranslation)(),{updateNodeData:o,getEdges:n,getNode:r}=(0,Zi.useReactFlow)(),i=(0,Zi.useNodesData)(e),s=n().filter(x=>x.source===e).some(x=>{let E=r(x.target);return(E==null?void 0:E.type)==="END_EVENT"}),l=(i==null?void 0:i.data.variant)==="SUBPROCESS",c=(i==null?void 0:i.data.variant)==="SERVICE_TASK",d=p=>{o(e,{variant:(i==null?void 0:i.data.variant)===p?"":p})},u=p=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===p?"":p})};return(0,me.jsxs)(ie.DropdownMenu,{children:[(0,me.jsxs)(ie.Tooltip,{children:[(0,me.jsx)(ie.TooltipTrigger,{asChild:!0,children:(0,me.jsx)(ie.DropdownMenuTrigger,{asChild:!0,children:(0,me.jsx)(ie.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:(0,me.jsx)(lu.WrenchIcon,{})})})}),(0,me.jsx)(ie.TooltipContent,{color:"black",children:t("bpmn.task.menu.title")})]}),(0,me.jsxs)(ie.DropdownMenuContent,{align:"start",className:"w-60 bg-white text-grey-600",children:[(0,me.jsxs)(ie.DropdownMenuLabel,{className:"flex items-center gap-1",children:[(0,me.jsx)("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),(0,me.jsx)("div",{className:"flex items-center gap-1",children:Object.entries(Qr).map(([p,f])=>{let x=p==="LOOP"&&(s||l||c),m=(()=>{if(p==="LOOP"&&s)return t("editor.task_menu.loop_not_allowed_when_connected_to_end");if(p==="LOOP"&&l)return t("editor.task_menu.loop_not_allowed_when_subprocess");if(p==="LOOP"&&c)return t("editor.task_menu.loop_not_allowed_when_service_task");if(p==="LOOP")return t("editor.task_menu.loop")})();return(0,me.jsxs)(ie.Tooltip,{children:[(0,me.jsx)(ie.TooltipTrigger,{asChild:!0,children:(0,me.jsx)(ie.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:x,className:F({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===p,"opacity-50 cursor-not-allowed":x}),onClick:x?void 0:()=>u(p),children:(0,me.jsx)(f.icon,{className:"stroke-inherit"})})}),m&&(0,me.jsx)(ie.TooltipContent,{color:"black",children:m})]},p)})})]}),(0,me.jsx)(ie.DropdownMenuGroup,{children:(0,me.jsxs)(ie.Tooltip,{children:[(0,me.jsx)(ie.TooltipTrigger,{asChild:!0,children:(0,me.jsx)("div",{className:F({"cursor-not-allowed":s}),children:(0,me.jsxs)(ie.DropdownMenuItem,{className:F({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":s}),disabled:s,onClick:()=>d("SCRIPT"),children:[(0,me.jsx)(Jr.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),s&&(0,me.jsx)(ie.TooltipContent,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};var wt=require("@produto-lecom/lecom-ui"),du=require("lucide-react");var at=require("@xyflow/react");var Ji=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=(0,at.useReactFlow)(),{selectElements:r}=Tt(),i=m=>{let h=o(),g=n(),y=(0,at.getIncomers)(m,h,g),v=(0,at.getOutgoers)(m,h,g),_=y.some(b=>b.type==="START_EVENT"),N=v.some(b=>b.type==="END_EVENT");return _?"start":N?"end":"between"},a=(m,h,g)=>{var _,N,b,w,S;if(!m)return;let y={type:m.type,variant:(_=m.data)==null?void 0:_.variant,attribute:(N=m.data)==null?void 0:N.attribute},v={id:m.id,position:i(m),label:(b=m.data)==null?void 0:b.label,node:y};return m.type==="TASK"&&((w=m.data)==null?void 0:w.variant)==="SUBPROCESS"?I(T({},v),{type:"sub_process"}):m.type==="TASK"&&((S=m.data)==null?void 0:S.variant)==="SERVICE_TASK"?I(T({},v),{type:"service_task"}):m.type==="GATEWAY"?I(T({},v),{type:"gateway",variant:s(m,h,g)}):I(T({},v),{type:"activity"})},s=(m,h,g)=>{if(m.type!=="GATEWAY")return;let y=(0,at.getIncomers)(m,h,g),v=!1,_=!1;if(y.forEach(N=>{var b,w;N.type==="TASK"&&(((b=N.data)==null?void 0:b.variant)==="SCRIPT"&&(v=!0),((w=N.data)==null?void 0:w.attribute)==="LOOP"&&(_=!0))}),v&&_)return"script_loop";if(v)return"script";if(_)return"loop"},l=(m,h,g)=>{var b,w,S,M;let y=e(m.source),v=e(m.target);if(!y||!v)return"simple";if((0,at.getOutgoers)(y,h,g).some(L=>L.type==="END_EVENT"))return"final";if(y.type==="GATEWAY")switch((b=y.data)==null?void 0:b.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(y.type==="TASK"){let L=(w=y.data)==null?void 0:w.variant,D=(S=y.data)==null?void 0:S.attribute;if(L==="SUBPROCESS")return"from_sub_process";if(v.type==="TASK"&&((M=v.data)==null?void 0:M.variant)==="SUBPROCESS")return"to_sub_process";if(L==="SERVICE_TASK")return"from_service_task";let O=L==="SCRIPT",R=D==="LOOP";return O&&R?"script_loop":O?"script":R?"loop":"simple"}return"simple"},c=(m,h,g)=>{let y=[];function v(N,b,w=0){let S=a(N,h,g);if(S.depth=w,b.push(S),N.type==="TASK"){y.push([...b]),b.pop();return}let M=(0,at.getIncomers)(N,h,g);if(M.length)for(let L of M)v(L,b,w+1);b.pop()}let _=(0,at.getIncomers)(m,h,g);for(let N of _)v(N,[]);return y},d=(m,h,g)=>{let y=[];function v(N,b,w=0){let S=a(N,h,g);if(S.depth=w,b.push(S),N.type==="TASK"){y.push([...b]),b.pop();return}let M=(0,at.getOutgoers)(N,h,g);if(M.length)for(let L of M)v(L,b,w+1);b.pop()}let _=(0,at.getOutgoers)(m,h,g);for(let N of _)v(N,[]);return y},u=(m,h,g)=>(g=g.filter(v=>v.source===m.id),g.map(v=>{var b;let _=e(v.target),N;return _&&(N=a(_,h,g)),{id:v.id,type:"routing",variant:l(v,h,g),label:(b=v.data)==null?void 0:b.label,target:N}})),p=m=>{let h=e(m);if(!h)return;let g=o(),y=n(),v=a(h,g,y);return v.sources=c(h,g,y),v.targets=d(h,g,y),v.edgeTargets=u(h,g,y),h.type==="GATEWAY"&&(v.variant=s(h,g,y)),v},f=m=>{let h=t(m);if(!h)return;let g=o(),y=n(),v=l(h,g,y),N={id:h.id,type:"routing",variant:v,gatewayVariant:void 0},b=e(h.source);if(b){let S=a(b,g,y);N.source=S;let M=s(b,g,y);if(N.gatewayVariant=M,b.type==="TASK")N.sources=[[S]];else{let L=c(b,g,y);N.sources=L.length?L:[[S]]}}let w=e(h.target);if(w){let S=a(w,g,y);if(N.target=S,w.type==="TASK")N.targets=[[S]];else{let M=d(w,g,y);N.targets=M.length?M:[[S]]}}return N},x=m=>{let h=e(m);if(h)return p(h.id);let g=t(m);if(g)return f(g.id)};return{configureElement:m=>{let h=x(m);if(h)return r([m]),h},getConfigureElement:x,getNodeConfigure:p,getEdgeConfigure:f}};var Ho=require("react/jsx-runtime"),vy={node:"editor.toolbar.configure_node",edge:"editor.toolbar.configure_edge",gateway:"editor.toolbar.configure_gateway"},uo=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,wt.useTranslation)(),{onConfigureElement:n}=Y(),{getConfigureElement:r}=Ji();return(0,Ho.jsxs)(wt.Tooltip,{children:[(0,Ho.jsx)(wt.TooltipTrigger,{asChild:!0,children:(0,Ho.jsx)(wt.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let a=r(e);a&&(n==null||n(a))},children:(0,Ho.jsx)(du.Settings,{size:16})})}),(0,Ho.jsx)(wt.TooltipContent,{color:"black",children:o(vy[t])})]})};var It=require("@produto-lecom/lecom-ui"),pu=require("@xyflow/react"),fu=require("lucide-react");var uu=require("@produto-lecom/lecom-ui");function Oe(){let{toast:e}=Cn(),{toast:t}=(0,uu.useNotificationToast)();return{toast:e||t}}var Go=require("react/jsx-runtime"),Qi=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,It.useTranslation)(),{toast:n}=Oe(),{deleteElements:r,getNodes:i}=(0,pu.useReactFlow)(),{isRemovingElements:a}=Y();return(0,Go.jsxs)(It.Tooltip,{children:[(0,Go.jsx)(It.TooltipTrigger,{asChild:!0,children:(0,Go.jsx)(It.Button,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{if(!a)if(t==="node"){let l=i(),c=l.find(d=>d.id===e);if((c==null?void 0:c.type)==="LANE"&&l.some(u=>u.parentId===e)){n({variant:"error",title:o("validation.errors.title"),content:o("editor.toolbar.delete_pool_lane_error")});return}r({nodes:[{id:e}]})}else r({edges:[{id:e}]})},disabled:a,children:(0,Go.jsx)(fu.TrashIcon,{size:16})})}),(0,Go.jsx)(It.TooltipContent,{color:"black",children:o(a?"editor.toolbar.deleting":"editor.toolbar.delete")})]})};var At=require("@produto-lecom/lecom-ui"),mu=require("lucide-react"),gu=require("react"),Bo=require("react/jsx-runtime"),Sn=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=(0,At.useTranslation)(),r=(0,gu.useCallback)(i=>{i.stopPropagation();let a=document.querySelectorAll(`.react-flow__handle.source[data-nodeid="${e}"]`);if(a.length===0)return;let s=Array.from(a).reduce((p,f)=>{let x=p.getBoundingClientRect(),E=f.getBoundingClientRect(),m=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))<m?f:p}),l=s.getBoundingClientRect(),c=l.left+l.width/2,d=l.top+l.height/2,u=new MouseEvent("mousedown",{clientX:c,clientY:d,bubbles:!0,cancelable:!0});s.dispatchEvent(u)},[e]);return(0,Bo.jsxs)(At.Tooltip,{children:[(0,Bo.jsx)(At.TooltipTrigger,{asChild:!0,children:(0,Bo.jsx)(At.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:(0,Bo.jsx)(mu.MoveUpRightIcon,{size:16})})}),(0,Bo.jsx)(At.TooltipContent,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};var Ee=require("react/jsx-runtime"),$t={START_EVENT:{type:"START_EVENT",icon:$n,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:nn,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:$n,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:$r,label:"bpmn.annotation.variant.default"}},Ny={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:an,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:cn,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:rn,label:"bpmn.gateway.variant.complex"}},Ye=Ge.default.memo(({nodeId:e,nodeType:t,nodeVariant:o,isChild:n})=>{let r=(0,Ge.useRef)(null),i=(0,Ge.useRef)(null),{t:a}=(0,Ct.useTranslation)(),{setDraggableNode:s}=An(),{getEdges:l,getNodes:c,setNodes:d}=(0,zo.useReactFlow)(),{setIsDragging:u,mode:p,isConnecting:f,isDragging:x}=Y(),E=Nt(),m=(0,zo.useStore)((0,Ge.useCallback)(z=>{var U,$;return($=(U=z.nodeLookup.get(e))==null?void 0:U.selected)!=null?$:!1},[e])),h=(0,zo.useStore)((0,Ge.useCallback)(z=>{var U,$;return($=(U=z.nodeLookup.get(e))==null?void 0:U.dragging)!=null?$:!1},[e])),g=m&&!h&&!f&&!x&&!E,{dimensions:y}=iu(r,g),{position:v}=au(e,g,y),[_,N]=(0,Ge.useState)(void 0),b=o==="SUBPROCESS",w=o==="SERVICE_TASK",S=(0,Ge.useRef)(null),M=(0,Ge.useRef)(!1),L=(0,Ge.useCallback)(()=>{S.current!==null&&(clearTimeout(S.current),S.current=null),M.current=!1,u(!1),s(null),N(void 0),d(z=>z.map(U=>I(T({},U),{className:void 0})))},[u,s,d]);(0,Ge.useEffect)(()=>{let z=U=>{M.current&&U.buttons===0&&L()};return document.addEventListener("dragend",L),document.addEventListener("mousemove",z),()=>{document.removeEventListener("dragend",L),document.removeEventListener("mousemove",z)}},[L]);let D=(0,Ge.useCallback)((z,U)=>{M.current=!0,u(!1),s({type:U.type,variant:U.variant,attribute:U.attribute,icon:U.icon}),U.icon&&N((0,Ee.jsx)(U.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,s,u]),O=(0,Ge.useCallback)(()=>{L()},[L]);if(!g)return null;let R=c(),V=l(),G=[{component:(0,Ee.jsx)(Qi,{elementId:e})}],B=()=>{if(p==="view")return[];let z=!V.some(U=>{var $;return U.source===e&&(($=R.find(X=>X.id===U.target))==null?void 0:$.type)!=="ANNOTATION"});return[{component:(0,Ee.jsx)(Sn,{nodeId:e,disabled:!z,tooltipMessage:z?void 0:a("editor.toolbar.start_event_limit_reached")})},$t.TASK,$t.ANNOTATION,...G]},A=()=>p==="view"?[{component:(0,Ee.jsx)(uo,{elementId:e})}]:[{component:(0,Ee.jsx)(uo,{elementId:e})},...b||w?[]:[{component:(0,Ee.jsx)(cu,{nodeId:e})}],{component:(0,Ee.jsx)(Sn,{nodeId:e})},$t.TASK,{type:"TASK",variant:"SUBPROCESS",icon:Kn,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:ma.Bot,label:"bpmn.task.variant.service_task"},$t.ANNOTATION,...Object.values(Ny),...Do(e,R,V)?[]:[$t.END_EVENT],...G],C=()=>p==="view"?[{component:(0,Ee.jsx)(uo,{elementId:e,elementType:"gateway"})}]:[{component:(0,Ee.jsx)(uo,{elementId:e,elementType:"gateway"})},{component:(0,Ee.jsx)(Sn,{nodeId:e})},$t.TASK,{type:"TASK",variant:"SUBPROCESS",icon:Kn,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:ma.Bot,label:"bpmn.task.variant.service_task"},$t.ANNOTATION,...G],k=()=>p==="view"?[]:[$t.ANNOTATION,...G],P=()=>p==="view"?[]:[...n?[]:[{component:(0,Ee.jsx)(Sn,{nodeId:e})}],$t.ANNOTATION,...G],K=()=>p==="view"?[]:[{component:(0,Ee.jsx)(Sn,{nodeId:e})},...G],Z=()=>p==="view"?[]:[...G],H=(z=>{switch(z){case"START_EVENT":return B();case"TASK":return A();case"GATEWAY":return C();case"END_EVENT":return k();case"LANE":return P();case"ANNOTATION":return K();case"UNSUPPORTED":return Z();default:return[]}})(t),q=H.length>6;if(!(H.length===0||p==="readonly"))return(0,Ee.jsxs)(zo.NodeToolbar,{position:v,align:"start",className:q?"-top-[4.5rem]":"-top-8",isVisible:g,children:[(0,Ee.jsx)("div",{ref:r,className:`${q?"grid grid-cols-6":"flex"} gap-1 px-2 py-2 bg-white rounded-sm shadow-md`,children:H.map((z,U)=>{if(z.component)return(0,Ee.jsx)("div",{children:z.component},U);let $={sourceNodeType:t,targetNodeType:z.type,sourceNodeId:e,nodes:R,edges:V},X=_d($),ne={gateway_limit_reached:a("editor.toolbar.gateway_limit_reached"),start_event_limit_reached:a("editor.toolbar.start_event_limit_reached"),start_event_already_exists:a("editor.toolbar.start_event_already_exists"),script_to_end_not_allowed:a("editor.toolbar.script_to_end_not_allowed"),loop_to_end_not_allowed:a("editor.toolbar.loop_to_end_not_allowed"),initial_activity_to_end_not_allowed:a("editor.toolbar.initial_activity_to_end_not_allowed"),final_activity_cannot_connect:a("editor.toolbar.final_activity_cannot_connect"),activity_has_outgoing_connections:a("editor.toolbar.activity_has_outgoing_connections"),task_limit_reached:a("editor.toolbar.task_limit_reached"),start_event_to_service_task_not_allowed:a("editor.toolbar.start_event_to_service_task_not_allowed"),service_task_to_end_not_allowed:a("editor.toolbar.service_task_to_end_not_allowed")},le=X.shouldDisable&&X.reason?ne[X.reason]||a(z.label):a(z.label)||"";return(0,Ee.jsxs)(Ct.Tooltip,{children:[(0,Ee.jsx)(Ct.TooltipTrigger,{asChild:!0,children:(0,Ee.jsx)(Ct.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!X.shouldDisable,disabled:X.shouldDisable,className:X.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:X.shouldDisable?void 0:oe=>D(oe,z),onDragEnd:X.shouldDisable?void 0:O,children:z.icon&&(0,Ee.jsx)(z.icon,{size:16})})}),(0,Ee.jsx)(Ct.TooltipContent,{color:"black",children:le})]},U)})}),(0,Ee.jsx)("div",{ref:i,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:_})]})});Ye.displayName="NodeToolbar";var Fo=require("react/jsx-runtime"),yu=({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let{updateNodeData:a,setNodes:s}=(0,hu.useReactFlow)(),{mode:l,isReadOnly:c}=Y(),d=(0,ji.useCallback)(f=>{let g=f.split(`
|
|
40
|
-
`),y=g.reduce((b,w)=>Math.max(b,w.length),0),v=g.length,_=Math.max(ko.MIN_WIDTH,y*7+32),N=Math.max(ko.MIN_HEIGHT,v*20+24);s(b=>b.map(w=>{var S;if(w.id===e){let M=Math.max((S=w.height)!=null?S:ko.MIN_HEIGHT,N);return I(T({},w),{width:_,height:M,style:I(T({},w.style),{width:_,height:M})})}return w}))},[e,s]),u=(0,ji.useCallback)(f=>{a(e,{label:f}),d(f)},[e,a,d]),p=(0,ji.useCallback)(f=>{d(f)},[d]);return(0,Fo.jsxs)("div",{className:F("relative w-full h-full 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":r&&!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}),style:{width:o,height:n},children:[(0,Fo.jsx)(Re,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:u,onInput:p,skipFirstCharValidation:!0}),(0,Fo.jsx)(Ye,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&(0,Fo.jsx)(st,{nodeId:e,minWidth:ko.MIN_WIDTH,minHeight:ko.MIN_HEIGHT,isVisible:!i&&r}),(0,Fo.jsx)(it,{nodeId:e,nodeType:"ANNOTATION",targetHandleClassName:"annotation-handle"})]})};var xu=require("@xyflow/react"),Eu=require("react");var Kt=require("react/jsx-runtime"),_u=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=(0,xu.useReactFlow)(),{mode:i,isReadOnly:a}=Y(),[s,l]=(0,Eu.useState)(!1),c=p=>{r(e,{label:p})},d=()=>{l(!0)},u=()=>{l(!1)};return(0,Kt.jsxs)("div",{className:"relative",onDoubleClick:d,children:[(0,Kt.jsx)(nn,{className:F("w-full h-full hover:stroke-[#d33b3b] transition-colors duration-75",{"pointer-events-none":a,"stroke-blue-500 hover:stroke-blue-600":o&&!a,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),(0,Kt.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,Kt.jsx)(Re,{value:t.label,isEditing:s,onBlur:u,onChange:c})}),(0,Kt.jsx)(Ye,{nodeId:e,nodeType:"END_EVENT"}),i==="edit"&&(0,Kt.jsx)(st,{nodeId:e,isVisible:!n&&o,minWidth:zi.MIN_WIDTH,minHeight:zi.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(0,Kt.jsx)(it,{nodeId:e,nodeType:"END_EVENT",targetHandleClassName:"event-handle"})]})};var bu=require("@xyflow/react"),
|
|
41
|
-
`),k=C.reduce((W,H)=>Math.max(W,H.length),0),P=C.length,K=Math.max(Yt.MIN_WIDTH,k*7+64),Z=Math.max(Yt.MIN_HEIGHT,P*24+A);d(W=>W.map(H=>{var q;if(H.id===e){let z=Math.max((q=H.height)!=null?q:Yt.MIN_HEIGHT,Z);return I(T({},H),{width:K,height:z,style:I(T({},H.style),{width:K,height:z})})}return H}))},[e,d,g,y]),_=(0,Yo.useCallback)(R=>{let V=R.trim(),G=t.label||"";if(V===G)return;let B=V,A=c();if(!(V&&V!=="")){B=es(A,a("bpmn.task.label.prefix")),l(e,{label:B}),v(B),s({variant:"warning",content:(0,_e.jsxs)(_e.Fragment,{children:[a("bpmn.task.feedback.label_empty.prefix")," ",(0,_e.jsx)("strong",{children:B})]})});return}let k=Pn(B,A);k===G||(l(e,{label:k}),v(k),k!==B&&s({variant:"warning",content:(0,_e.jsxs)(_e.Fragment,{children:[a("bpmn.task.feedback.label_already_exists.prefix")," ",(0,_e.jsx)("strong",{children:V})," ",a("bpmn.task.feedback.label_already_exists.middle")," ",(0,_e.jsx)("strong",{children:k})]})}))},[t.label,c,e,a,l,v,s]),N=(0,Yo.useCallback)(R=>{v(R)},[v]),b=(0,Yo.useCallback)(()=>{s({variant:"error",content:a("bpmn.task.feedback.invalid_first_character")})},[a,s]),w=E?Iy[E]:null,S=t.variant?Jr[t.variant].icon:null,M=t.attribute?Qr[t.attribute].icon:null,L=()=>t.hasError?ya.error:E?ya[E]:p?ya.default:"",D=()=>{var R;return r&&(R=Ay[E])!=null?R:""},O=()=>{f==null||f({id:e,type:"sub_process",label:t.label})};return(0,_e.jsxs)("div",{className:F("relative w-full h-full 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",L(),{"cursor-pointer":p,"border-blue-500 hover:border-blue-600 shadow-md":r&&!p&&!E,"border-red-500 hover:border-red-600 shadow-[0_0_5px_rgba(255,0,0,0.5)]":t.hasError}),style:{width:o!=null?o:Yt.MIN_WIDTH,height:n!=null?n:Yt.MIN_HEIGHT},children:[(0,_e.jsx)("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:(0,_e.jsx)(Re,{value:t.label,maxLength:60,className:F("bg-white/10",D(),{"py-10 px-8":g||y}),onChange:_,onInput:N,onInvalidFirstCharacter:b})}),S&&(0,_e.jsx)("div",{className:F("absolute flex items-center p-1",m||h?"bottom-0 left-1/2 -translate-x-1/2":"top-0 left-0"),children:(0,_e.jsx)(S,{size:h?20:16,className:F(t.hasError?"text-red-500":"text-grey-500",m&&"cursor-pointer"),onClick:m?O:void 0})}),M&&(0,_e.jsx)("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:(0,_e.jsx)("div",{className:F("flex items-center w-16 p-1",m||h?"justify-between":"justify-center"),children:(0,_e.jsx)(M,{size:16,className:F(t.hasError?"text-red-500":"text-grey-500")})})}),w&&(0,_e.jsx)("div",{className:"absolute top-0 right-0 flex items-center p-1",children:(0,_e.jsx)(w,{})}),(0,_e.jsx)(Ye,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),u==="edit"&&(0,_e.jsx)(st,{nodeId:e,isVisible:!i&&r,minWidth:Yt.MIN_WIDTH,minHeight:Yt.MIN_HEIGHT}),(0,_e.jsx)(it,{nodeId:e,nodeType:"TASK",targetHandleClassName:"task-handle",conditionalSource:!0})]})});xa.displayName="Task";var Lu=require("@xyflow/react"),Du=require("lodash"),Wo=require("react");var Je=require("react/jsx-runtime"),Ea=(0,Wo.memo)(({id:e,data:t,selected:o,dragging:n,parentId:r,width:i,height:a})=>{var N;let{updateNodeData:s,getNodes:l}=(0,Lu.useReactFlow)(),{mode:c,isReadOnly:d}=Y(),[u,p]=(0,Wo.useState)(!1),f=l(),x=!r,E=!x&&((N=f.find(b=>b.id===r))==null?void 0:N.selected),m=(0,Wo.useMemo)(()=>(0,Du.orderBy)(f.filter(b=>b.parentId===e&&b.type==="LANE"),"position.y","asc"),[f,e]),h=x?bd.MIN_WIDTH:J.MIN_WIDTH,g=(0,Wo.useMemo)(()=>{if(x&&m.length>1){let b=[...m];return b.pop(),b.reduce((S,M)=>{var L,D;return S+((D=(L=M.measured)==null?void 0:L.height)!=null?D:0)},0)+J.MIN_HEIGHT}return J.MIN_HEIGHT},[x,m]),y=b=>{s(e,{label:b})},v=()=>{p(!0)},_=()=>{p(!1)};return(0,Je.jsxs)(Je.Fragment,{children:[(0,Je.jsxs)("div",{className:F("flex h-full w-full hover:shadow-md outline outline-2 outline-grey-400",{"pointer-events-none":d,"outline-offset-0 outline-blue-500 shadow-sm":(o||E)&&!d}),style:{width:i!=null?i:J.MIN_WIDTH,height:a!=null?a:J.MIN_HEIGHT},children:[(0,Je.jsx)("div",{className:F("flex align-items justify-center w-10 border-r-2 border-grey-400 bg-white",{"border-blue-500":(o||E)&&!d}),onDoubleClick:v,children:(0,Je.jsx)("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:(0,Je.jsx)(Re,{value:t.label,className:"w-full h-full self-auto",contentClassName:F({"whitespace-nowrap":u}),isEditing:u,onBlur:_,onChange:y})})}),(0,Je.jsx)("div",{className:F("flex-1",{"bg-white":!r||n})})]}),(0,Je.jsx)(Ye,{nodeId:e,nodeType:"LANE",isChild:!x}),c==="edit"&&(0,Je.jsx)(st,{nodeId:e,isVisible:!n&&o,minWidth:h,minHeight:g,offset:10}),(0,Je.jsx)(it,{nodeId:e,nodeType:"LANE",targetHandleClassName:"annotation-handle"})]})});Ea.displayName="Lane";var _a=require("@xyflow/react");var Jt=require("react/jsx-runtime"),ku=({id:e,data:t})=>(0,Jt.jsxs)(Jt.Fragment,{children:[(0,Jt.jsx)("div",{className:"relative w-full h-full flex items-center justify-center bg-white border-2 border-red-400 rounded-sm overflow-hidden",children:t.label}),(0,Jt.jsx)(Ye,{nodeId:e,nodeType:"UNSUPPORTED"}),(0,Jt.jsx)(In,{type:"source",position:_a.Position.Right}),(0,Jt.jsx)(In,{type:"target",position:_a.Position.Left})]});var On=require("@xyflow/react"),Vn=Wn(require("react"),1);var ve=require("react"),ts=require("@xyflow/react");var Cy=50,Ru=.1,Sy=.6,os=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:a,getNodes:s,screenToFlowPosition:l}=(0,ts.useReactFlow)(),{setIsDragging:c,setReconnectingEdgeId:d}=Y(),u=(0,ts.useStore)(G=>G.isValidConnection),[p,f]=(0,ve.useState)(null),[x,E]=(0,ve.useState)(null),[m,h]=(0,ve.useState)(null),[g,y]=(0,ve.useState)(null),[v,_]=(0,ve.useState)(!1),N=(0,ve.useRef)(null),b=(0,ve.useRef)(null),w=(0,ve.useRef)(t),S=(0,ve.useRef)(o);(0,ve.useEffect)(()=>{w.current=t,S.current=o},[t,o]),(0,ve.useEffect)(()=>{N.current=p},[p]);let M=(0,ve.useCallback)(G=>No(G,s()),[s]),L=(0,ve.useCallback)(G=>{var P,K,Z,W,H,q;let B=s(),A=null,C=Cy,k=B.filter(z=>z.type!=="LANE"&&z.type!=="ANNOTATION");for(let z of k){if(z.id===e)continue;let U=M(z.id),$=(Z=(K=(P=z.measured)==null?void 0:P.width)!=null?K:z.width)!=null?Z:0,X=(q=(H=(W=z.measured)==null?void 0:W.height)!=null?H:z.height)!=null?q:0;if(G.x>=U.x&&G.x<=U.x+$&&G.y>=U.y&&G.y<=U.y+X)return z.id;let le=Math.max(U.x-G.x,0,G.x-(U.x+$)),oe=Math.max(U.y-G.y,0,G.y-(U.y+X)),re=Math.sqrt(le*le+oe*oe);re<C&&(C=re,A=z.id)}return A},[s,M,e]),D=(0,ve.useCallback)((G,B)=>{var le,oe,re,Ae,ae,Se;let A=a(G);if(!A)return null;let C=M(G),k=(re=(oe=(le=A.measured)==null?void 0:le.width)!=null?oe:A.width)!=null?re:0,P=(Se=(ae=(Ae=A.measured)==null?void 0:Ae.height)!=null?ae:A.height)!=null?Se:0,K=Math.abs(C.x+k-B.x),Z=Math.abs(B.x-C.x),W=Math.abs(C.y+P-B.y),H=Math.abs(B.y-C.y),q={right:K,left:Z,bottom:W,top:H},z=Object.entries(q).reduce((j,[ce,ke])=>ke<j[1]?[ce,ke]:j,["right",q.right])[0],U=b.current;if(U&&U!==z){let j=q[z],ce=q[U],ke=Math.abs(ce-j),ut=Math.min(Math.abs(ce),Math.abs(j));ke<ut*Sy&&(z=U)}let $=z,X,ne;if($==="right"||$==="left"){let ce=(Math.max(C.y,Math.min(C.y+P,B.y))-C.y)/(P||1);Math.abs(ce-.5)<Ru&&(ce=.5),ne=ce,X={x:$==="right"?C.x+k:C.x,y:C.y+ne*P}}else{let ce=(Math.max(C.x,Math.min(C.x+k,B.x))-C.x)/(k||1);Math.abs(ce-.5)<Ru&&(ce=.5),ne=ce,X={x:C.x+ne*k,y:$==="bottom"?C.y+P:C.y}}return{side:$,snapPosition:X,offset:ne}},[a,M]),O=(0,ve.useCallback)(G=>{var K;let B=N.current;if(!B)return;let A=l({x:G.clientX,y:G.clientY}),C=L(A);h(C);let k=A,P=null;if(C){let Z=D(C,A);Z&&(P=Z.side,k=Z.snapPosition,b.current=P);let W={source:B==="source"?C:w.current,target:B==="target"?C:S.current,sourceHandle:null,targetHandle:null},H=(K=u==null?void 0:u(W))!=null?K:!0;_(H)}else b.current=null,_(!1);y(P),E(k)},[L,D,l,u]),R=(0,ve.useCallback)(G=>{var P;let B=N.current;if(!B)return;let A=l({x:G.clientX,y:G.clientY}),C=L(A);if(C){let K={source:B==="source"?C:w.current,target:B==="target"?C:S.current,sourceHandle:null,targetHandle:null};((P=u==null?void 0:u(K))==null||P)&&i(Z=>Z.map(W=>W.id===e?I(T({},W),{source:K.source,target:K.target,sourceHandle:void 0,targetHandle:void 0,data:I(T({},W.data),{controlPoint:void 0})}):W))}f(null),E(null),h(null),y(null),c(!1),_(!1),d(null),b.current=null,document.removeEventListener("mouseup",R),document.removeEventListener("mousemove",O);let k=St.get(n);k==null||k.clearReconnectingEdge()},[e,L,i,n,O,u,l,c,d]),V=(0,ve.useCallback)((G,B)=>{if(r||B.button!==0)return;B.stopPropagation(),B.preventDefault(),f(G),d(e);let A=St.get(n);A==null||A.setReconnectingEdge(e),document.addEventListener("mousemove",O),document.addEventListener("mouseup",R)},[r,e,n,O,R,d]);return(0,ve.useEffect)(()=>()=>{if(N.current){document.removeEventListener("mousemove",O),document.removeEventListener("mouseup",R),d(null);let G=St.get(n);G==null||G.clearReconnectingEdge()}},[n,O,R,d]),{reconnectingHandle:p,cursorPosition:x,hoveredNodeId:m,reconnectingSide:g,isValidReconnection:v,handleReconnectStart:V}};var Hu=require("@xyflow/react"),is=require("react");var po={TOLERANCE:1,MAX_LABEL_DISTANCE:80,BEND_HANDLE_HIT_RADIUS:24};var My=require("@xyflow/react");var _r=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,ns=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),ba=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),Py=(e,t,o)=>{let n=o.x-t.x,r=o.y-t.y,i=n*n+r*r;if(i===0)return ns(e,t);let a=Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*r)/i));return ns(e,{x:t.x+a*n,y:t.y+a*r})},rs=(e,t)=>{let o=1/0;for(let n=0;n<t.length-1;n++)o=Math.min(o,Py(e,t[n],t[n+1]));return o},Ou=e=>{let t=0;for(let r=0;r<e.length-1;r++)t+=ns(e[r],e[r+1]);let o=t/2,n=0;for(let r=0;r<e.length-1;r++){let i=ns(e[r],e[r+1]);if(n+i>=o){let a=i===0?0:(o-n)/i,s=e[r],l=e[r+1];return{x:s.x+(l.x-s.x)*a,y:s.y+(l.y-s.y)*a}}n+=i}return ba(e[0],e.at(-1))};var{MAX_LABEL_DISTANCE:Ly}=po,Vu=3;function Gu({edgeId:e,isEditing:t,isViewOrReadOnly:o,zoom:n,label:r,labelOffset:i,pathPoints:a,pathCenter:s}){let{updateEdgeData:l}=(0,Hu.useReactFlow)(),c=(0,is.useRef)(i);return(0,is.useCallback)(d=>{var v,_;if(t||o||d.button!==0||!(r!=null&&r.trim()))return;d.stopPropagation(),d.preventDefault();let u=d.clientX,p=d.clientY,f=(v=i==null?void 0:i.x)!=null?v:0,x=(_=i==null?void 0:i.y)!=null?_:0,E=[...a],m={x:s.x,y:s.y},h=!1,g=N=>{let b=(N.clientX-u)/n,w=(N.clientY-p)/n;if(!h&&Math.abs(b)<Vu&&Math.abs(w)<Vu)return;h=!0;let S={x:f+b,y:x+w};c.current=S,l(e,{labelOffset:S})},y=()=>{document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",y);let N=c.current;if(!N)return;let b={x:m.x+N.x,y:m.y+N.y};rs(b,E)>Ly&&(c.current=void 0,l(e,{labelOffset:void 0}))};document.addEventListener("mousemove",g),document.addEventListener("mouseup",y)},[t,o,n,r,i,e,l,a,s])}var br=require("@xyflow/react"),Xo=require("react");var{TOLERANCE:ss}=po,Bu=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Dy(e,t,o){return _r(e,t,"x",ss)&&_r(t,o,"x",ss)||_r(e,t,"y",ss)&&_r(t,o,"y",ss)}function ky(e,t,o,n){if(Dy(e,t,o))return`L${t.x} ${t.y}`;let r=Bu(e,t),i=Bu(t,o),a=Math.min(r/2,i/2,n);if(a<1)return`L${t.x} ${t.y}`;let s=e.x-t.x,l=e.y-t.y,c=o.x-t.x,d=o.y-t.y,u={x:s/r,y:l/r},p={x:c/i,y:d/i},f={x:t.x+u.x*a,y:t.y+u.y*a},x={x:t.x+p.x*a,y:t.y+p.y*a},E=-u.x,m=-u.y,h=p.x,g=p.y,v=E*g-m*h>0?1:0;return`L${f.x} ${f.y}A${a} ${a} 0 0 ${v} ${x.x} ${x.y}`}var as=(e,t=5)=>e.length<2?"":e.reduce((o,n,r)=>{let i="";return r>0&&r<e.length-1?i=ky(e[r-1],n,e[r+1],t):i=`${r===0?"M":"L"}${n.x} ${n.y}`,o+=i,o},"");var zu=({id:e,source:t,target:o,controlPoint:n,fixedSourcePoint:r,fixedTargetPoint:i})=>{let a=(0,br.useInternalNode)(t),s=(0,br.useInternalNode)(o),{updateEdgeData:l,screenToFlowPosition:c}=(0,br.useReactFlow)(),{mode:d}=Y(),[u,p]=(0,Xo.useState)(!1),f=(0,Xo.useCallback)(E=>{if(d!=="edit"||E.button!==0)return;E.stopPropagation(),E.preventDefault(),p(!0);let m=g=>{let y=c({x:g.clientX,y:g.clientY});l(e,{controlPoint:{x:Math.round(y.x),y:Math.round(y.y)}})},h=()=>{p(!1),document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",h)};document.addEventListener("mousemove",m),document.addEventListener("mouseup",h)},[d,c,e,l]),x=(0,Xo.useMemo)(()=>{if(!a||!s)return null;let E=Xt({source:Ht(a),target:Ht(s),controlPoint:n,fixedSourcePoint:r,fixedTargetPoint:i}),{points:m}=E,h=m[1],g=m.at(-2);return{sourceNode:a,targetNode:s,points:m,svgPath:as(m),sourcePoint:E.sourcePoint,targetPoint:E.targetPoint,direction:E.direction,bendPoint:ba(h,g),pathCenter:Ou(m)}},[a,s,n,r,i]);return(0,Xo.useMemo)(()=>x?I(T({},x),{isDraggingBend:u,onBendDragStart:f}):null,[x,u,f])};var Ln=require("react/jsx-runtime"),{BEND_HANDLE_HIT_RADIUS:Ry}=po,Fu=({bendPoint:e,zoom:t,isDragging:o,onMouseDown:n})=>(0,Ln.jsxs)("g",{className:"pointer-events-auto cursor-move",onMouseDown:n,children:[(0,Ln.jsx)("circle",{cx:e.x,cy:e.y,r:Ry/t,fill:"transparent"}),(0,Ln.jsx)("circle",{cx:e.x,cy:e.y,r:4/t,fill:o?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/t,className:"pointer-events-none"}),(0,Ln.jsx)("circle",{cx:e.x,cy:e.y,r:6/t,fill:"none",stroke:"#3b82f6",strokeWidth:1/t,opacity:o?.6:.3,className:"pointer-events-none"})]});var Dn=require("react/jsx-runtime"),kn=i=>{var a=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=a,r=bt(a,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:s}=Y(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d,isToEndEvent:u}=ti(o,n),p=!l&&!c&&!d&&!u,f=[{component:(0,Dn.jsx)(Qi,{elementId:e,elementType:"edge"})}],x=()=>s==="view"?p?[{component:(0,Dn.jsx)(uo,{elementId:e,elementType:"edge"})}]:[]:p?[{component:(0,Dn.jsx)(uo,{elementId:e,elementType:"edge"})},...f]:f,m=(h=>{switch(h){case"SEQUENCE_EDGE":return x();case"MESSAGE_EDGE":return s==="view"?[]:[...f];case"ANNOTATION_EDGE":return s==="view"?[]:[...f];default:return[]}})(t);if(!(m.length===0||s==="readonly"))return(0,Dn.jsx)("div",I(T({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:m.map((h,g)=>(0,Dn.jsx)("div",{children:h.component},g))}))};var Yu=require("@xyflow/react"),Wu=require("react");var Ta=require("react/jsx-runtime"),Mt=12,Rn=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:a}=(0,Yu.useViewport)(),s=1/a,l=(0,Wu.useMemo)(()=>t===n?{bottom:`${Mt}px`,transform:"translateX(-50%)"}:e===o?{left:`${Mt}px`,transform:r?"translateY(-100%)":"translateY(-50%)"}:n>t&&o>e?{left:`${Mt}px`,bottom:`${Mt}px`}:n>t&&o<e?{right:`${Mt}px`,bottom:`${Mt}px`}:t>n&&o>e?{right:`${Mt}px`,bottom:`${Mt}px`}:{left:`${Mt}px`,bottom:`${Mt}px`},[e,t,o,n,r]);return(0,Ta.jsx)("div",{style:{transform:`scale(${s})`},children:(0,Ta.jsx)("div",{className:"absolute pointer-events-auto",style:T({},l),children:i})})};var Uo=require("react/jsx-runtime"),va=({x:e,y:t,zoom:o,handleType:n,reconnectingHandle:r,hoveredNodeId:i,isValidReconnection:a,onMouseDown:s})=>{let l=r===n,c=l?i&&!a?"cursor-not-allowed":"cursor-grabbing":"cursor-move";return(0,Uo.jsx)("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${e}px, ${t}px)`},children:(0,Uo.jsxs)("svg",{width:12/o,height:12/o,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,Uo.jsx)("circle",{cx:6/o,cy:6/o,r:4/o,fill:l?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/o,className:"pointer-events-none"}),(0,Uo.jsx)("circle",{cx:6/o,cy:6/o,r:6/o,fill:"none",stroke:"#3b82f6",strokeWidth:1/o,opacity:l?.6:.3,className:"pointer-events-none"}),(0,Uo.jsx)("circle",{cx:6/o,cy:6/o,r:8/o,fill:"transparent",className:F("pointer-events-auto",c),onMouseDown:s})]})})};var Xu=require("@xyflow/react");var Na=require("react/jsx-runtime"),Uu=({edgeId:e,label:t,labelOffset:o,pathCenter:n,isEditing:r,isViewOrReadOnly:i,onSetEditing:a,onLabelDragStart:s})=>{var d,u;let{updateEdgeData:l}=(0,Xu.useReactFlow)(),c=!r&&!i&&!!(t!=null&&t.trim());return!r&&!(t!=null&&t.trim())?null:(0,Na.jsx)("div",{className:F("absolute nodrag nopan",c?"z-[10001] pointer-events-auto":"z-[3000] pointer-events-none"),style:{transform:`translate(-50%, -50%) translate(${n.x+((d=o==null?void 0:o.x)!=null?d:0)}px, ${n.y+((u=o==null?void 0:o.y)!=null?u:0)}px)`,cursor:c?"move":void 0},onMouseDown:c?s:void 0,onDoubleClick:p=>{i||(p.stopPropagation(),a(!0))},children:(0,Na.jsx)(Re,{value:t,className:F("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":r,"pointer-events-none":!r}),isEditing:r,onBlur:()=>a(!1),onChange:p=>l(e,{label:p.trim()})})})};var Le=require("react/jsx-runtime"),Oy={x:0,y:0};function Vy(e,t,o,n,r){return F("stroke-2 stroke-current transition-[stroke] duration-75",{"group-hover:stroke-[2.5px]":!e,"stroke-red-500 hover:stroke-red-600":o||n,"stroke-green-500":r,"stroke-blue-500 hover:stroke-blue-600 stroke-[3px]":t&&!o})}var wa=Vn.default.memo(({id:e,source:t,target:o,data:n,selected:r})=>{var A,C;let{zoom:i}=(0,On.useViewport)(),{isReadOnly:a,mode:s,instanceId:l,edgeHighlight:c}=Y(),d=Nt(),[u,p]=(0,Vn.useState)(!1),f=s!=="edit",{reconnectingHandle:x,cursorPosition:E,hoveredNodeId:m,isValidReconnection:h,handleReconnectStart:g}=os({edgeId:e,source:t,target:o,instanceId:l,isReadOnly:f}),y=zu({id:e,source:t,target:o,controlPoint:n==null?void 0:n.controlPoint,fixedSourcePoint:x==="source"?E:void 0,fixedTargetPoint:x==="target"?E:void 0}),v=(0,Vn.useMemo)(()=>{var k;return(k=y==null?void 0:y.points)!=null?k:[]},[y]),_=(A=y==null?void 0:y.pathCenter)!=null?A:Oy,N=Gu({edgeId:e,isEditing:u,isViewOrReadOnly:f,zoom:i,label:n==null?void 0:n.label,labelOffset:n==null?void 0:n.labelOffset,pathPoints:v,pathCenter:_});if(!y)return null;let{sourceNode:b,targetNode:w,svgPath:S,sourcePoint:M,targetPoint:L}=y,D=c&&(r||b.selected||w.selected),O=r&&!d&&!f,R=!!((C=n==null?void 0:n.label)!=null&&C.trim()),V=!u&&!f&&R,G=!!x&&!!m&&!h,B=!!x&&!!m&&h;return(0,Le.jsxs)(Le.Fragment,{children:[(0,Le.jsxs)("g",{className:F("group bpmn-arrow-edge",{"is-highlighted":D}),onDoubleClick:()=>!f&&p(!0),children:[(0,Le.jsx)("path",{d:S,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/i),className:F({"nopan nodrag":V}),style:{pointerEvents:"stroke",cursor:V?"move":"pointer"},onMouseDown:N}),(0,Le.jsxs)("g",{className:F("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!a,"text-blue-500 group-hover:text-blue-600":D}),children:[(0,Le.jsx)(On.BaseEdge,{id:e,path:S,interactionWidth:0,markerEnd:`url(#${D?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:Vy(a,!!D,n==null?void 0:n.hasError,G,B)}),O&&!x&&(0,Le.jsx)(Fu,{bendPoint:y.bendPoint,zoom:i,isDragging:y.isDraggingBend,onMouseDown:y.onBendDragStart})]})]}),(0,Le.jsxs)(On.EdgeLabelRenderer,{children:[(0,Le.jsx)("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${_.x}px, ${_.y}px)`},children:r&&!d&&(0,Le.jsx)(Rn,{sx:M.x,sy:M.y,tx:L.x,ty:L.y,hasLabel:R,children:(0,Le.jsx)(kn,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:b,targetNode:w})})}),(0,Le.jsx)(Uu,{edgeId:e,label:n==null?void 0:n.label,labelOffset:n==null?void 0:n.labelOffset,pathCenter:_,isEditing:u,isViewOrReadOnly:f,onSetEditing:p,onLabelDragStart:N}),O&&(0,Le.jsxs)(Le.Fragment,{children:[(0,Le.jsx)(va,{x:M.x,y:M.y,zoom:i,handleType:"source",reconnectingHandle:x,hoveredNodeId:m,isValidReconnection:h,onMouseDown:k=>g("source",k.nativeEvent)}),(0,Le.jsx)(va,{x:L.x,y:L.y,zoom:i,handleType:"target",reconnectingHandle:x,hoveredNodeId:m,isValidReconnection:h,onMouseDown:k=>g("target",k.nativeEvent)})]})]})]})});wa.displayName="SequenceEdge";var Ne=require("@xyflow/react"),ls=require("react");var ye=require("react/jsx-runtime"),PC={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:Ne.MarkerType.Arrow},data:{label:""}},$u=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var Z;let{zoom:c}=(0,Ne.useViewport)(),{updateEdgeData:d}=(0,Ne.useReactFlow)(),{mode:u,instanceId:p}=Y(),f=Nt(),x=u!=="edit",[E,m]=(0,ls.useState)(!1),{reconnectingHandle:h,cursorPosition:g,hoveredNodeId:y,reconnectingSide:v,isValidReconnection:_,handleReconnectStart:N}=os({edgeId:e,source:t,target:o,instanceId:p,isReadOnly:x}),b=(0,Ne.useInternalNode)(t),w=(0,Ne.useInternalNode)(o),{sx:S,sy:M,tx:L,ty:D,sourcePos:O,targetPos:R}=(0,ls.useMemo)(()=>{var re,Ae;if(!b||!w)return{sx:0,sy:0,tx:0,ty:0,sourcePos:Ne.Position.Left,targetPos:Ne.Position.Right};let W=ei(b,w),H=s?i:W.sourcePos,q=l?a:W.targetPos,z=(ae,Se,j)=>{var Vr,Hr,Gr,Br,ws,Is;let{x:ce,y:ke}=ae.internals.positionAbsolute,ut=(Gr=(Hr=(Vr=ae.measured)==null?void 0:Vr.width)!=null?Hr:ae.width)!=null?Gr:0,bo=(Is=(ws=(Br=ae.measured)==null?void 0:Br.height)!=null?ws:ae.height)!=null?Is:0;switch(Se){case Ne.Position.Top:return{x:ce+ut*j,y:ke};case Ne.Position.Bottom:return{x:ce+ut*j,y:ke+bo};case Ne.Position.Left:return{x:ce,y:ke+bo*j};case Ne.Position.Right:return{x:ce+ut,y:ke+bo*j};default:return{x:ce+ut/2,y:ke+bo/2}}},U=(re=n==null?void 0:n.sourceOffset)!=null?re:.5,$=(Ae=n==null?void 0:n.targetOffset)!=null?Ae:.5,X=b?z(b,H,U).x:W.sx,ne=b?z(b,H,U).y:W.sy,le=w?z(w,q,$).x:W.tx,oe=w?z(w,q,$).y:W.ty;return h==="source"&&g?(X=g.x,ne=g.y,v&&(H=v)):h==="target"&&g&&(le=g.x,oe=g.y,v&&(q=v)),{sx:X,sy:ne,tx:le,ty:oe,sourcePos:H,targetPos:q}},[b,w,s,l,i,a,h,g,v,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!b||!w)return null;let[V,G,B]=(0,Ne.getSmoothStepPath)({sourceX:S,sourceY:M,targetX:L,targetY:D,sourcePosition:O,targetPosition:R}),A=r||(b==null?void 0:b.selected)||(w==null?void 0:w.selected),C=A?"sequence-edge-marker-highlighted":"sequence-edge-marker",k=E||(n==null?void 0:n.label.trim().length)>0,P=()=>{m(!1)},K=W=>{d(e,{label:W.trim()})};return(0,ye.jsxs)("g",{className:F("group bpmn-arrow-edge",{"is-highlighted":A}),onDoubleClick:()=>!x&&m(!0),children:[(0,ye.jsx)("path",{d:V,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),(0,ye.jsxs)("g",{className:F("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":A}),children:[(0,ye.jsx)(Ne.BaseEdge,{id:e,path:V,interactionWidth:0,markerEnd:`url(#${C})`,strokeDasharray:4,className:F("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&&!_,"stroke-green-500":h&&y&&_,"stroke-blue-500 hover:stroke-blue-600 stroke-[3px]":A&&!(n!=null&&n.hasError)&&!h})}),(0,ye.jsxs)(Ne.EdgeLabelRenderer,{children:[(0,ye.jsxs)("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${G}px, ${B}px)`},children:[r&&!f&&(0,ye.jsx)(Rn,{sx:S,sy:M,tx:L,ty:D,hasLabel:!!((Z=n==null?void 0:n.label)!=null&&Z.trim()),children:(0,ye.jsx)(kn,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),k&&(0,ye.jsx)(Re,{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:P,onChange:K})]}),r&&!f&&!x&&(0,ye.jsxs)(ye.Fragment,{children:[(0,ye.jsx)("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${S}px, ${M}px)`},children:(0,ye.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,ye.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:h==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ye.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:h==="source"?.6:.3,className:"pointer-events-none"}),(0,ye.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:F("pointer-events-auto",{"cursor-move":!h||h!=="source","cursor-not-allowed":h==="source"&&y&&!_,"cursor-grabbing":h==="source"&&(!y||_)}),onMouseDown:W=>N("source",W.nativeEvent)})]})}),(0,ye.jsx)("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${L}px, ${D}px)`},children:(0,ye.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,ye.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:h==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ye.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:h==="target"?.6:.3,className:"pointer-events-none"}),(0,ye.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:F("pointer-events-auto",{"cursor-move":!h||h!=="target","cursor-not-allowed":h==="target"&&y&&!_,"cursor-grabbing":h==="target"&&(!y||_)}),onMouseDown:W=>N("target",W.nativeEvent)})]})})]})]})]})]})};var Qe=require("@xyflow/react"),ht=require("react");var lt=require("react/jsx-runtime"),{MAX_LABEL_DISTANCE:Hy}=po,Ku=({id:e,source:t,target:o,selected:n,data:r})=>{var D,O,R,V,G,B,A,C,k,P;let{isReadOnly:i,edgeHighlight:a,mode:s}=Y(),l=Nt(),{zoom:c}=(0,Qe.useViewport)(),{updateEdgeData:d}=(0,Qe.useReactFlow)(),[u,p]=(0,ht.useState)(!1),f=(0,ht.useRef)(r==null?void 0:r.labelOffset),x=s!=="edit",E=(0,Qe.useInternalNode)(t),m=(0,Qe.useInternalNode)(o),{sx:h,sy:g,tx:y,ty:v}=(0,ht.useMemo)(()=>E&&m?ei(E,m):{sx:0,sy:0,tx:0,ty:0},[E,m]),[_,N,b]=(0,ht.useMemo)(()=>(0,Qe.getStraightPath)({sourceX:h,sourceY:g,targetX:y,targetY:v}),[h,g,y,v]),w=(0,ht.useMemo)(()=>[{x:h,y:g},{x:y,y:v}],[h,g,y,v]),S=(0,ht.useMemo)(()=>({x:N,y:b}),[N,b]),M=(0,ht.useCallback)(K=>{var le,oe,re,Ae,ae;if(u||x||K.button!==0||!((le=r==null?void 0:r.label)!=null&&le.trim()))return;K.stopPropagation(),K.preventDefault();let Z=K.clientX,W=K.clientY,H=(re=(oe=r==null?void 0:r.labelOffset)==null?void 0:oe.x)!=null?re:0,q=(ae=(Ae=r==null?void 0:r.labelOffset)==null?void 0:Ae.y)!=null?ae:0,z=[...w],U={x:S.x,y:S.y},$=!1,X=Se=>{let j=(Se.clientX-Z)/c,ce=(Se.clientY-W)/c;if(!$&&Math.abs(j)<3&&Math.abs(ce)<3)return;$=!0;let ke={x:H+j,y:q+ce};f.current=ke,d(e,{labelOffset:ke})},ne=()=>{document.removeEventListener("mousemove",X),document.removeEventListener("mouseup",ne);let Se=f.current;if(!Se)return;let j={x:U.x+Se.x,y:U.y+Se.y};rs(j,z)>Hy&&(f.current=void 0,d(e,{labelOffset:void 0}))};document.addEventListener("mousemove",X),document.addEventListener("mouseup",ne)},[u,x,c,r,e,d,w,S]);if(!E||!m)return null;let L=a&&(n||(E==null?void 0:E.selected)||(m==null?void 0:m.selected));return(0,lt.jsxs)("g",{className:F("group bpmn-edge",{"is-highlighted":L}),onDoubleClick:()=>!x&&p(!0),children:[(0,lt.jsx)("path",{d:_,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),className:F({"nopan nodrag":!u&&!x&&!!((D=r==null?void 0:r.label)!=null&&D.trim())}),style:{pointerEvents:"stroke",cursor:!u&&!x&&((O=r==null?void 0:r.label)!=null&&O.trim())?"move":"pointer"},onMouseDown:M}),(0,lt.jsxs)("g",{className:F("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!i,"text-blue-500 group-hover:text-blue-600":L}),children:[(0,lt.jsx)(Qe.BaseEdge,{id:e,path:_,interactionWidth:0,strokeDasharray:4,className:F("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]":L&&!(r!=null&&r.hasError)})}),(0,lt.jsxs)(Qe.EdgeLabelRenderer,{children:[(0,lt.jsx)("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${N}px, ${b}px)`},children:n&&!l&&(0,lt.jsx)(Rn,{sx:h,sy:g,tx:y,ty:v,children:(0,lt.jsx)(kn,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})}),(u||((R=r==null?void 0:r.label)==null?void 0:R.trim()))&&(0,lt.jsx)("div",{className:F("absolute nodrag nopan",!u&&!x&&((V=r==null?void 0:r.label)!=null&&V.trim())?"z-[10001] pointer-events-auto":"z-[3000] pointer-events-none"),style:{transform:`translate(-50%, -50%) translate(${S.x+((B=(G=r==null?void 0:r.labelOffset)==null?void 0:G.x)!=null?B:0)}px, ${S.y+((C=(A=r==null?void 0:r.labelOffset)==null?void 0:A.y)!=null?C:0)}px)`,cursor:!u&&!x&&((k=r==null?void 0:r.label)!=null&&k.trim())?"move":void 0},onMouseDown:!u&&!x?M:void 0,onDoubleClick:K=>{x||(K.stopPropagation(),p(!0))},children:(0,lt.jsx)(Re,{value:(P=r==null?void 0:r.label)!=null?P:"",className:F("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":u,"pointer-events-none":!u}),isEditing:u,onBlur:()=>p(!1),onChange:K=>d(e,{label:K.trim()})})})]})]})]})};var Tr=require("@xyflow/react");var yt=require("react/jsx-runtime"),qu=({toX:e,toY:t,fromNode:o})=>{let{getNodes:n,getInternalNode:r}=(0,Tr.useReactFlow)();if(!o)return null;let i=Ht(o),a=n().map(u=>r(u.id)).filter(u=>u!=null).find(u=>{var m,h,g,y;let{x:p,y:f}=u.internals.positionAbsolute,x=(h=(m=u.measured)==null?void 0:m.width)!=null?h:0,E=(y=(g=u.measured)==null?void 0:g.height)!=null?y:0;return e>=p&&e<=p+x&&t>=f&&t<=f+E});if(!a){let u=Xt({source:i,target:{bounds:{x:e,y:t,width:0,height:0},perimeter:"rectangle"}}),[p]=(0,Tr.getStraightPath)({sourceX:u.sourcePoint.x,sourceY:u.sourcePoint.y,targetX:e,targetY:t});return(0,yt.jsxs)("g",{className:"group",children:[(0,yt.jsx)("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d:p}),(0,yt.jsx)("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})}let s=Ht(a);if(o.type==="ANNOTATION"||a.type==="ANNOTATION"){let u=Xt({source:i,target:s}),[p]=(0,Tr.getStraightPath)({sourceX:u.sourcePoint.x,sourceY:u.sourcePoint.y,targetX:u.targetPoint.x,targetY:u.targetPoint.y});return(0,yt.jsxs)("g",{className:"group",children:[(0,yt.jsx)("path",{fill:"none",strokeDasharray:4,className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d:p}),(0,yt.jsx)("circle",{cx:u.targetPoint.x,cy:u.targetPoint.y,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})}let c=Xt({source:i,target:s}),d=as(c.points);return(0,yt.jsxs)("g",{className:"group",children:[(0,yt.jsx)("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d}),(0,yt.jsx)("circle",{cx:c.targetPoint.x,cy:c.targetPoint.y,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})};var Zu={START_EVENT:Iu,END_EVENT:_u,TASK:xa,GATEWAY:ga,ANNOTATION:yu,LANE:Ea,UNSUPPORTED:ku},Ju={SEQUENCE_EDGE:wa,MESSAGE_EDGE:$u,ANNOTATION_EDGE:Ku},Qu="#fafafa",ju="#bebebe",ep=1,tp=10,op="bottom-left",Ia=.05,np=5,rp=150,ip=100,sp=Ia,ap=1,lp={x:0,y:0,zoom:.75},cp=1,dp=2,Gy={[cp]:4,[dp]:2},vr=[cp,dp],up=[0,1,2],pp={hideAttribution:!0},Aa=vr.reduce((e,t)=>e|Gy[t],0);var fo=()=>{let{setViewport:e}=(0,cs.useReactFlow)(),t=(0,cs.useStoreApi)();return{fitToNodes:(0,fp.useCallback)(n=>{let{width:r,height:i}=t.getState();if(i<=0||r<=0)return;let a=dl(n);if(!a)return;let s=ul({bounds:a,canvasHeight:i,canvasWidth:r,minZoom:sp,maxZoom:ap,offsetX:rp,offsetY:ip});e(s)},[t,e])}};var mp=require("@xyflow/react");var ct=()=>{let{getEdges:e,getNodes:t}=(0,mp.useReactFlow)(),{lastElementId:o}=Y(),n=()=>{let i=t(),a=e(),s=Sd(i,a);return Math.max(s,o)};return{getLastId:n,getNextId:()=>n()+1}};var Pt=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n}=(0,gp.useReactFlow)(),{getLastId:r}=ct(),{fitToNodes:i}=fo(),{setLastElementId:a,onElementChanges:s}=Y(),l=(0,Nr.useCallback)(async(p="")=>{let{nodes:f,edges:x,lastElementId:E}=await Yd(p);i(f),o(f),n(x),a(E)},[o,n,a,i]),c=(0,Nr.useCallback)(()=>{let p=e(),f=t(),x=r();return mr(p,f,x)},[e,t,r]),d=(0,Nr.useCallback)(()=>mr([],[],r()),[r]),u=(0,Nr.useCallback)(async p=>{await(s==null?void 0:s(p))},[s]);return{importFromMxGraph:l,exportToMxGraph:c,buildEmptyDiagram:d,publishNow:u}};var By=500,ds=()=>{let{isInitialized:e,isImporting:t,onElementChanges:o}=Y(),{exportToMxGraph:n}=Pt(),r=(0,hp.useDebouncedCallback)(()=>{if(!e||t)return;let s=n();o==null||o(s)},By);(0,wr.useEffect)(()=>()=>{r.isPending()&&r.flush()},[r]);let i=(0,wr.useCallback)(s=>{s.every(d=>d.type==="select")||s.some(d=>d.type==="position"&&d.dragging)||r()},[r]),a=(0,wr.useCallback)(s=>{s.some(c=>c.type==="select")||r()},[r]);return{emitElementChanges:r,handleNodeChanges:i,handleEdgeChanges:a}};var yp=({setEdges:e,saveHistory:t})=>{let{getNode:o,getEdges:n,getNodes:r,getInternalNode:i}=(0,us.useReactFlow)(),{emitElementChanges:a}=ds(),s=(0,Lt.useRef)(null),{getNextId:l}=ct(),c=(0,Lt.useCallback)(m=>{var _;let h=o(m.source),g=o(m.target);if(!h||!g)return!1;let y={sourceNodeId:h.id,targetNodeId:g.id,sourceNodeType:h.type,targetNodeType:g.type,nodes:r(),edges:n(),reconnectingEdgeId:(_=s.current)!=null?_:void 0};return Js(y).isValid},[o,n,r]),d=(0,Lt.useCallback)(m=>{let h=l(),g=i(m.source);if(g){let y=i(m.target),v=(y==null?void 0:y.type)==="ANNOTATION"||(g==null?void 0:g.type)==="ANNOTATION",_=v?_n:rt,N=I(T(T({},m),_),{id:String(h),sourceHandle:void 0,targetHandle:void 0,data:T({},v?{}:rt.data)}),b=n().concat(N);e(b),t("forceSave",{nodes:r(),edges:b}),a()}},[l,e,a,i,n,r,t]),u=(0,Lt.useCallback)((m,h)=>{s.current=h.id},[]),p=(0,Lt.useCallback)(()=>{s.current=null},[]),f=(0,Lt.useCallback)((m,h)=>{let g=o(h.source),y=o(h.target);if(!g||!y){s.current=null;return}let v={sourceNodeId:g.id,targetNodeId:y.id,sourceNodeType:g.type,targetNodeType:y.type,nodes:r(),edges:n(),reconnectingEdgeId:m.id};if(!Js(v).isValid){s.current=null;return}let N=(0,us.reconnectEdge)(m,h,n()).map(b=>b.id===m.id?I(T({},b),{data:I(T({},b.data),{controlPoint:void 0})}):b);e(N),t("forceSave",{nodes:r(),edges:N}),s.current=null,a()},[o,r,n,e,a,t]),x=(0,Lt.useCallback)(m=>{s.current=m},[]),E=(0,Lt.useCallback)(()=>{s.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:f,onReconnectStart:u,onReconnectEnd:p,setReconnectingEdge:x,clearReconnectingEdge:E}};var Sr=require("@produto-lecom/lecom-ui"),Ip=require("@xyflow/react"),et=require("react");var Ir=(e=[])=>e.filter(t=>t.type==="START_EVENT"),$o=(e=[])=>e.filter(t=>t.type==="END_EVENT"),mo=(e=[])=>e.filter(t=>t.type==="TASK")||[],xp=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"});var ps=(e=[])=>e.filter(t=>t.type==="GATEWAY"),Ep=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),je=(e,t=[])=>t.filter(o=>o.source===e),Ar=(e,t=[])=>t.filter(o=>o.target===e),_p=(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"},bp=(e,t)=>{let o=je(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},Tp=e=>e?/[^\s]/.test(e.trim()):!1,pe=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:[]}},Qt=(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)}},zy=(e,t)=>{let o=new Set(e.filter(n=>n.type==="ANNOTATION").map(n=>n.id));return t.filter(n=>!o.has(n.source)&&!o.has(n.target))},vp=(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:zy(e,t).map(o=>({id:o.id,source:o.source,target:o.target,type:o.type||"default"}))});var Cr=[{id:"start_event_not_found",validate:e=>{let t=Ir(e.nodes);return pe({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=$o(e.nodes);return pe({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Ir(e.nodes),o=t.length===1;if(t.length===0)return pe({isValid:!0});if(!o)return pe({isValid:!1,nodeIds:t.map(i=>i.id)});let n=je(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(a=>a.id),...n.map(a=>a.target)];return pe({isValid:!1,nodeIds:[...new Set(i)]})}return pe({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=mo(e.nodes),o=Qt(t,n=>je(n.id,e.edges).length<=2);return pe({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=mo(e.nodes),o=Qt(t,n=>!!n.label&&n.label.trim()!=="");return pe({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=mo(e.nodes),n=Qt(o,r=>!r.label||r.label.length<=60);return pe({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=mo(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 pe({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{var r,i,a,s;let t=ps(e.nodes),o=[],n=[];for(let l of t){let c=je(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=((a=l.properties)==null?void 0:a.variant)==="COMPLEX"&&((s=u==null?void 0:u.properties)==null?void 0:s.variant)==="PARALLEL";!p&&!f&&(o.push(l.id,u.id),n.push(d.id))}}return pe({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Ir(e.nodes),...$o(e.nodes)],o=[],n=[];for(let r of t){let i=je(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&(s.type==="START_EVENT"||s.type==="END_EVENT")&&(o.push(r.id,s.id),n.push(a.id))}}return pe({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=$o(e.nodes),o=[],n=[];for(let r of t){let i=Ar(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.source);if(s&&s.type==="TASK"){let l=je(s.id,e.edges);l.length>1&&(o.push(s.id),l.forEach(c=>n.push(c.id)))}}}return pe({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=Ep(e.nodes),o=Qt(t,r=>je(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>je(r,e.edges).map(i=>i.id));return pe({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=mo(e.nodes),o=Qt(t,n=>!n.label||Tp(n.label));return pe({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var a,s;if(!((a=e==null?void 0:e.nodes)!=null&&a.length)||!((s=e==null?void 0:e.edges)!=null&&s.length))return pe({isValid:!0});let t=$o(e.nodes)[0];if(!t)return pe({isValid:!0});let o=Ar(t.id,e.edges);if(!o.length)return pe({isValid:!0});let r=mo(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=Qt(r,l=>!_p(l.id,e));return pe({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=mo(e.nodes),o=$o(e.nodes)[0];if(!o)return pe({isValid:!0});let n=t.filter(l=>{let c=Ar(l.id,e.edges),d=je(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=Ar(o.id,e.edges),i=r.length>1,a=r.map(l=>l.source),s={isValid:n.length===0&&!i,nodeIds:[...n.map(l=>l.id),...i?a:[]]};return pe(s)}},{id:"gateway_flow_to_event",validate:e=>{let t=ps(e.nodes),o=[],n=[];for(let r of t){let i=je(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="END_EVENT"&&(o.push(r.id,s.id),n.push(a.id))}}return pe({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=ps(e.nodes),o=Qt(t,n=>je(n.id,e.edges).length>=1);return pe({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Ir(e.nodes),...$o(e.nodes)],o=[],n=[];for(let r of t){let i=je(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="GATEWAY"&&(o.push(r.id,s.id),n.push(a.id))}}return pe({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=xp(e.nodes),o=Qt(t,n=>!bp(n.id,e));return pe({isValid:o.isValid,nodeIds:o.invalidIds})}}];var Np=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of Cr){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}},wp=async(e,t)=>{var n;let o=[];try{let r=await e(),i=(n=r==null?void 0:r.filter(a=>a.area==="DIAGRAM"))!=null?n:[];return i.length===0?{isValid:!0,errors:[]}:(i.forEach(a=>{var l,c;let s=(c=(l=a==null?void 0:a.detail)==null?void 0:l.phases)==null?void 0:c.map(d=>d.diagramCellId);o.push({id:a.code,message:a.code,nodeIds:s,edgeIds:[]})}),{isValid:!1,errors:o})}catch(r){let i=[],a=(s,l)=>{let c=t.filter(d=>{var u;return((u=d.data)==null?void 0:u.variant)===s}).map(d=>d.id);c.length>0&&i.push({id:l,message:l,nodeIds:c,edgeIds:[]})};return a("SUBPROCESS","cannot_validate_subprocess_reference"),a("SERVICE_TASK","service_task_automation_status_unavailable"),{isValid:!1,errors:i}}};var Ko=require("react/jsx-runtime"),Ap=()=>{let{t:e}=(0,Sr.useTranslation)(),{toast:t}=Oe(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=(0,Ip.useReactFlow)(),{validateCustomDiagram:a}=Y(),[s,l]=(0,et.useState)(!1),c=(0,et.useRef)(!1),d=(0,et.useRef)(!1),u=(0,et.useRef)(!1),p=(0,et.useCallback)(async g=>{let y=vp(g.nodes,g.edges),v=Np(y),_=g.nodes.filter(({type:b,data:w})=>b==="TASK"&&((w==null?void 0:w.variant)==="SUBPROCESS"||(w==null?void 0:w.variant)==="SERVICE_TASK"));if(a&&_.length>0){let b=await wp(a,_);v={isValid:v.isValid&&b.isValid,errors:[...v.errors,...b.errors]}}let N=v.errors.map(b=>I(T({},b),{message:e(`validation.errors.${b.id}`)}));return s||l(!0),{isValid:v.isValid,errors:N}},[s,e,a]),f=(0,et.useCallback)((g,y=!0)=>{if(y&&g){let R=g.isValid?e("validation.success.title"):e("validation.errors.title"),V=g.isValid?e("validation.success.message"):e("validation.errors.subtitle");t({variant:g.isValid?"success":"error",duration:5e3,title:R,content:(0,Ko.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,Ko.jsx)(Sr.Typography,{variant:"body-medium-400",textColor:"text-grey-950",children:V}),!g.isValid&&(0,Ko.jsx)("ul",{className:"list-disc list-inside max-h-[600px] overflow-y-auto",children:g.errors.map(G=>(0,Ko.jsx)("li",{children:(0,Ko.jsx)(Sr.Typography,{variant:"body-medium-400",textColor:"text-grey-950",children:G.message})},G.id))})]})})}if(!g)return;c.current=!0,d.current=!0,u.current=!0;let v=[],_=[];g.errors.forEach(R=>{R.nodeIds&&R.nodeIds.length>0&&R.nodeIds.forEach(V=>v.push(V)),R.edgeIds&&R.edgeIds.length>0&&R.edgeIds.forEach(V=>_.push(V))});let N=[...new Set(v)],b=r(),w=i(),S=new Set(N),M=new Set;g.errors.forEach(R=>{var B,A;let V=Cr.find(C=>C.id===R.id);(V==null?void 0:V.highlightRelatedEdges)!==!1&&((B=R.edgeIds)==null||B.forEach(C=>M.add(C)),(A=R.nodeIds)==null||A.forEach(C=>{w.forEach(k=>{(k.source===C||k.target===C)&&M.add(k.id)})}))});let L=new Set,D=new Set,O=new Set;b.forEach(R=>{R.type==="START_EVENT"?L.add(R.id):R.type==="END_EVENT"&&D.add(R.id)}),w.forEach(R=>{L.has(R.source)&&O.add(R.target),D.has(R.target)&&O.add(R.source)}),O.forEach(R=>{var V,G;if(S.has(R)){let B=(V=g.errors.find(C=>{var k;return(k=C.nodeIds)==null?void 0:k.includes(R)}))==null?void 0:V.id;((G=Cr.find(C=>C.id===B))==null?void 0:G.highlightRelatedEdges)!==!1&&w.forEach(C=>{C.source===R&&D.has(C.target)&&(S.add(C.target),M.add(C.id)),C.target===R&&L.has(C.source)&&(S.add(C.source),M.add(C.id))})}}),o(R=>R.map(V=>I(T({},V),{data:I(T({},V.data),{hasError:S.has(V.id)})}))),n(R=>R.map(V=>I(T({},V),{data:I(T({},V.data),{hasError:M.has(V.id)})}))),setTimeout(()=>{d.current=!1,c.current=!1},0)},[e,i,r,n,o,t]),x=(0,et.useCallback)(()=>{l(!1),u.current=!1,o(g=>g.map(y=>I(T({},y),{data:I(T({},y.data),{hasError:!1})}))),n(g=>g.map(y=>I(T({},y),{data:I(T({},y.data),{hasError:!1})})))},[n,o]),E=(0,et.useCallback)(()=>{u.current&&(d.current=!0,u.current=!1,o(g=>g.map(y=>I(T({},y),{data:I(T({},y.data),{hasError:!1})}))),n(g=>g.map(y=>I(T({},y),{data:I(T({},y.data),{hasError:!1})}))),setTimeout(()=>{d.current=!1},0))},[n,o]),m=(0,et.useCallback)(()=>d.current,[]),h=(0,et.useCallback)(()=>c.current,[]);return{validateDiagram:p,handleValidationComplete:f,clearValidation:x,dismissValidationPanel:E,isAutoValidationEnabled:s,getIsClearingValidation:m,getIsValidating:h}};var Mp=require("@produto-lecom/lecom-ui"),Pp=require("@xyflow/react"),Lp=require("react");var Fy=15,Cp="bpmn:selection",Yy=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},Sp=e=>{if(!Yy(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},Dp=({offset:e=Fy,saveHistory:t})=>{let{t:o}=(0,Mp.useTranslation)(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=(0,Pp.useReactFlow)(),{getNextId:s}=ct(),{mode:l,containerRef:c}=Y();(0,Lp.useEffect)(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let u=f=>{var _,N;if(!Sp(f)||!d.contains(document.activeElement))return;let E=n(),m=i(),h=E.filter(b=>b.selected);if(!h.length)return;f.preventDefault(),f.stopPropagation();let g=m.filter(b=>h.some(w=>w.id===b.source)&&h.some(w=>w.id===b.target)),v=JSON.stringify({nodes:h,edges:g});(_=f.clipboardData)==null||_.setData(Cp,v),(N=f.clipboardData)==null||N.setData("text/plain",`BPMN Selection: ${h.length} nodes`)},p=f=>{var L,D;if(!Sp(f)||!d.contains(document.activeElement))return;let E=(L=f.clipboardData)==null?void 0:L.getData(Cp);if(!E)return;f.preventDefault(),f.stopPropagation();let m;try{m=JSON.parse(E)}catch(O){return}if(!((D=m.nodes)!=null&&D.length))return;let h=new Map,g=n(),y=[],v=m.nodes.filter(O=>En(O.type,g));if(v.length===0)return;let _=s(),N=v.map(O=>{var G;let R=String(_++);h.set(O.id,R);let V=I(T({},O),{id:R,selected:!0,position:{x:O.position.x+e,y:O.position.y+e}});if(O.type==="TASK"){let B=(G=O.data)==null?void 0:G.label,A=Pn(B||o("bpmn.task.label.prefix"),[...g,...y]);V.data=I(T({},O.data),{label:A})}return y.push(V),V}),b=m.edges.map(O=>I(T({},O),{id:String(_++),selected:!0,source:h.get(O.source)||O.source,target:h.get(O.target)||O.target,data:jr(O.data,e)})),w=[...g.map(O=>I(T({},O),{selected:!1})),...N],M=[...i().map(O=>I(T({},O),{selected:!1})),...b];r(w),a(M),t("forceSave",{nodes:w,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,a,s,e,o,t,l,c])};var kp=require("@produto-lecom/lecom-ui"),Rp=require("@xyflow/react"),qo=require("react");var Op=({nodes:e,setNodes:t})=>{let{t:o}=(0,kp.useTranslation)(),{toast:n}=Oe(),{getNodes:r}=(0,Rp.useReactFlow)(),{setIsRemovingElements:i,validateDeleteElements:a}=Y(),s=(0,qo.useRef)(!1),l=(0,qo.useCallback)(async p=>{try{let{activitiesWithInstances:f}=await a(p);if(f.length)return s.current=!1,i(!1),n({variant:"warning",content:o("editor.toolbar.delete_elements_blocked")}),!1}catch(f){return s.current=!1,i(!1),n({variant:"error",content:o("editor.toolbar.delete_elements_error")}),!1}return!0},[o,n,a,i]),c=(0,qo.useCallback)(async({nodes:p})=>{if(s.current)return!1;if(s.current=!0,i(!0),p.some(E=>E.type==="LANE"&&e.some(m=>m.parentId===E.id)))return s.current=!1,i(!1),n({variant:"error",title:o("validation.errors.title"),content:o("editor.toolbar.delete_pool_lane_error")}),!1;let x=p.filter(E=>E.type==="TASK");if(a&&x.length>0){let E=x.map(m=>m.id);return l(E)}return!0},[e,o,n,a,l,i]),d=(0,qo.useCallback)(p=>{s.current=!1,i(!1);let f=new Set(p.filter(x=>x.type==="LANE"&&!!x.parentId).map(x=>x.parentId));f.size!==0&&setTimeout(()=>{var m,h;let x=r(),E=new Map(x.map(g=>[g.id,g]));for(let g of f){let y=Oo(x.filter(N=>N.type==="LANE"&&N.parentId===g));if(y.length===0)continue;let v=0;for(let N of y)E.set(N.id,I(T({},N),{position:{x:J.HEADER_WIDTH,y:v}})),v+=(h=(m=N.measured)==null?void 0:m.height)!=null?h:0;let _=E.get(g);_&&E.set(g,I(T({},_),{height:v,measured:I(T({},_.measured),{height:v})}))}t(x.map(g=>{var y;return(y=E.get(g.id))!=null?y:g}))},0)},[r,t,i]),u=(0,qo.useCallback)(()=>{s.current=!1,i(!1)},[i]);return{onBeforeDelete:c,onNodesDelete:d,onEdgesDelete:u}};var Vp=require("@produto-lecom/lecom-ui"),Hp=require("@xyflow/react");var Gp=require("react");var Wy=50,Bp=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let{draggableNode:r,setDraggableNode:i}=An(),{t:a}=(0,Vp.useTranslation)(),{getInternalNode:s,getNodes:l,getEdges:c,screenToFlowPosition:d}=(0,Hp.useReactFlow)(),{getNextId:u}=ct(),{setIsDragging:p}=Y(),{getInternalNodes:f}=$i(),{rebuildIndex:x,forceRebuildIndex:E}=ki(),[m,h]=(0,Gp.useState)(null),g=(A,C,k)=>{var W;if(A.parentId!==C)return null;let P=k.filter(H=>H.id!==A.id&&H.parentId===C&&H.type==="LANE").sort((H,q)=>H.position.y-q.position.y);if(P.length===0)return null;let K=(W=k.find(H=>H.id===A.id))!=null?W:A,Z=P.find(H=>K.position.y<H.position.y);return Z?{draggedLaneId:A.id,beforeLaneId:Z.id}:{draggedLaneId:A.id,afterLaneId:P[P.length-1].id}},y=(A,C=!1,k)=>{let P=C?"node-drop-target-error":"node-drop-target",K=C?"node-drop-target-lane-error":"node-drop-target-lane";t(Z=>{var U;let W=(U=k==null?void 0:k(Z))!=null?U:null,H=$=>{let X=[];return $.id===A&&X.push(P),A!==void 0&&$.parentId===A&&$.type==="LANE"&&$.id!==(W==null?void 0:W.draggedLaneId)&&X.push(K),$.id===(W==null?void 0:W.draggedLaneId)&&X.push("lane-reorder-dragging"),$.id===(W==null?void 0:W.beforeLaneId)&&X.push("lane-reorder-before"),$.id===(W==null?void 0:W.afterLaneId)&&X.push("lane-reorder-after"),X.join(" ")||void 0},q=!1,z=Z.map($=>{let X=H($);return $.className===X?$:(q=!0,I(T({},$),{className:X}))});return q?z:Z})},v=(A,C)=>{let k=f();if(A.type==="LANE"){if(C){let U=k.filter(X=>X.id!==A.id&&X.parentId!==A.id&&X.type==="LANE"),$=fn(A,U);$?y($.id,!0):y();return}let H=k.filter(U=>U.id!==A.id&&U.type==="LANE"&&!U.parentId),q=fn(A,H);if(!q){y();return}if(Io({parentId:q.id,nodes:e,excludeTypes:["LANE"]})){y(q.id,!0);return}y(q.id,!1,U=>g(A,q.id,U));return}let K=k.filter(H=>H.id!==A.id&&H.type==="LANE"),Z=fn(A,K);if(!Z){y();return}if(Io({parentId:Z.id,nodes:e,includeTypes:["LANE"]})){y(Z.id,!0);return}y(Z.id)},_=A=>{let C=s(A.id),k=A.type==="LANE"&&Io({parentId:A.id,nodes:e,includeTypes:["LANE"]});v(C,k)},N=A=>A.map(C=>I(T({},C),{className:void 0})),b=A=>A.some(k=>k.dragging)?A.map(k=>k.dragging?I(T({},k),{dragging:!1}):k):A,w=(A,C)=>{let k=0;for(let P of C){if(P.id===A||P.parentId||P.type==="LANE")continue;let K=ot(P),Z=K.y+K.h;k=Math.max(k,Z)}return k+Wy},S=(A,C)=>{if(!Ds(A,C))return C;let k=w(A,C);return C.map(P=>P.id===A?I(T({},P),{position:I(T({},P.position),{y:k})}):P)},M=A=>{if(A.preventDefault(),A.dataTransfer.dropEffect="move",!(r!=null&&r.type))return;let C=d({x:A.clientX,y:A.clientY}),k={id:"__sidebar_drag__",type:r.type,position:C,measured:{width:1,height:1},internals:{positionAbsolute:C}};v(k,!1)},L=A=>{let C=A.relatedTarget;(!C||!A.currentTarget.contains(C))&&y()},D=(A,C)=>{A.preventDefault(),_(C)},O=(A,C,k)=>{var z,U;let P=[...k],K=C.parentId?C.parentId:C.id;if(A.parentId===C.id)return P=js(A,C,P),P=Wt(P),P=Ro(K,P),N(P);if(A.type==="LANE"){if(Io({parentId:C.id,nodes:P,excludeTypes:["LANE"]})){let oe=Pi(C),re=50,Ae=50;return P.map(ae=>{var Se,j;return ae.id===A.id?I(T({},ae),{position:{x:(Se=m==null?void 0:m.x)!=null?Se:oe.x+re,y:(j=m==null?void 0:m.y)!=null?j:oe.y2+Ae}}):ae})}let ne=P.filter(oe=>oe.parentId===C.id).reduce((oe,re)=>{var Ae,ae;return oe+((ae=(Ae=re.measured)==null?void 0:Ae.height)!=null?ae:0)},0),le={x:J.HEADER_WIDTH,y:ne};return P=P.map(oe=>oe.id===A.id?I(T({},oe),{parentId:C.id,position:le,className:void 0}):I(T({},oe),{className:void 0})),P=Wt(P),P=S(K,P),P}if(Io({parentId:C.id,nodes:P,includeTypes:["LANE"]})){let $;if(A.parentId){let X=s(A.parentId),{x:ne,y:le}=ot(X);$={x:ne+((z=A.position.x)!=null?z:0),y:le+((U=A.position.y)!=null?U:0)}}return P=P.map(X=>X.id===A.id?I(T({},X),{position:$!=null?$:X.position,parentId:void 0,className:void 0}):I(T({},X),{className:void 0})),P=Ro(K,P),P}let H=ll(A,C);P=P.map($=>$.id===A.id?I(T({},$),{parentId:C.id,position:H,className:void 0}):I(T({},$),{className:void 0}));let q=P.find($=>$.id===A.id);return P=js(q,C,P),P=Wt(P),P=Ro(K,P),P},R=A=>{if(A.preventDefault(),!(r!=null&&r.type))return;if(!En(r.type,l())){p(!1),i(null);return}let C=d({x:A.clientX,y:A.clientY}),k=te[r.type],P={width:k.DEFAULT_WIDTH,height:k.DEFAULT_HEIGHT},K=u(),Z={id:String(K),type:r.type,position:C,width:k.DEFAULT_WIDTH,height:k.DEFAULT_HEIGHT,measured:P,data:{label:r.type==="TASK"?es(e,a("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},W=I(T({},Z),{internals:{positionAbsolute:C}}),H=I(T({},W),{measured:{width:1,height:1}}),q=f(),z=r.type==="LANE",U=q.filter(re=>z?re.type==="LANE"&&!re.parentId:re.type==="LANE"),$=fn(H,U),X=[...q.map(re=>I(T({},re),{selected:!1})),W];$&&(X=O(W,$,X)),X=wo(X),z&&!$&&(X=S(W.id,X)),X=N(X),t(X),E();let ne=A.dataTransfer.getData("sourceId"),le=c(),oe=le;if(ne){let re={id:String(K+1),source:ne,target:Z.id},Ae=r.type==="ANNOTATION"?T(T({},re),_n):T(T({},re),rt);oe=le.concat(Ae),o(oe)}n("forceSave",{nodes:X,edges:oe}),p(!1),i(null)},V=async(A,C,k)=>{let P=[...f()],K=new Set;k.forEach(H=>{let q=s(H.id),z=H.type==="LANE",U=P.filter(X=>X.id!==H.id&&(z?X.type==="LANE"&&!X.parentId:X.type==="LANE")),$=fn(q,U);if($){if(z&&Io({parentId:H.id,nodes:P,includeTypes:["LANE"]})){H.parentId&&(P=B(H,P),K.add(H.id));return}P=O(q,$,P);return}H.parentId&&(P=B(H,P),H.type==="LANE"&&K.add(H.id))}),P=b(P);let Z=k.filter(H=>H.type==="LANE"&&!H.parentId).map(H=>H.id);for(let H of Z)Ds(H,P)&&m&&(P=P.map(q=>q.id===H?I(T({},q),{position:T({},m)}):q));for(let H of K)P=S(H,P);if(k.some(H=>H.type!=="LANE"&&!H.parentId)){let H=P.filter(q=>q.type==="LANE"&&!q.parentId).map(q=>q.id);for(let q of H)P=Ro(q,P)}P=wo(P),P=N(P),t(P),x(P),h(null)},G=(A,C)=>{h({x:C.position.x,y:C.position.y})},B=(A,C)=>{var U,$,X,ne,le,oe,re,Ae,ae,Se;let k=s(A.parentId);if(!k)return C;let P=A.type==="LANE",K=C.filter(j=>j.parentId===k.id&&j.id!==A.id),Z=K.filter(j=>j.type==="LANE"),W;if(P&&Z.length===0)W=($=(U=k.measured)==null?void 0:U.height)!=null?$:J.DEFAULT_HEIGHT;else if(P){let j=(ne=(X=A.measured)==null?void 0:X.height)!=null?ne:J.MIN_HEIGHT;W=((oe=(le=k.measured)==null?void 0:le.height)!=null?oe:J.MIN_HEIGHT)-j,W=Math.max(J.MIN_HEIGHT,W)}else W=K.length>0?K.reduce((j,ce)=>{var ke,ut;return j+((ut=(ke=ce.measured)==null?void 0:ke.height)!=null?ut:0)},0)+Te:Math.max(J.MIN_HEIGHT,(Ae=(re=k.measured)==null?void 0:re.height)!=null?Ae:0);let{x:H,y:q}=ot(k),z={x:H+((ae=A.position.x)!=null?ae:0),y:q+((Se=A.position.y)!=null?Se:0)};return C=C.map(j=>j.id===A.id?I(T({},j),{position:z,parentId:void 0}):j.id===k.id?I(T({},j),{height:W,measured:I(T({},j.measured),{height:W})}):j),C=Wt(C),C};return{onDragOver:M,onDragLeave:L,onDrop:R,onNodeDrag:D,onNodeDragStart:G,onNodeDragStop:V}};var zp=require("@produto-lecom/lecom-ui"),Fp=require("@xyflow/react"),Yp=require("react");var Xy=30,Uy=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",i=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||i},$y=e=>!Uy(e.target),Wp=({offset:e=Xy,saveHistory:t})=>{let{t:o}=(0,zp.useTranslation)(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=(0,Fp.useReactFlow)(),{getNextId:s}=ct(),{mode:l,containerRef:c}=Y();(0,Yp.useEffect)(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let u=p=>{if(d.contains(document.activeElement)&&p.ctrlKey&&p.key.toLowerCase()==="d"&&$y(p)){p.preventDefault(),p.stopPropagation();let x=n(),E=i(),m=x.filter(M=>M.selected);if(!m.length)return;let h=new Map,g=[],y=m.filter(M=>En(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)),_=s(),N=y.map(M=>{var O;let L=String(_++);h.set(M.id,L);let D=I(T({},M),{id:L,selected:!0,position:{x:M.position.x+e,y:M.position.y+e}});if(M.type==="TASK"){let R=(O=M.data)==null?void 0:O.label,V=Pn(R||o("bpmn.task.label.prefix"),[...x,...g]);D.data=I(T({},M.data),{label:V})}return g.push(D),D}),b=v.map(M=>I(T({},M),{id:String(_++),selected:!0,source:h.get(M.source)||M.source,target:h.get(M.target)||M.target,data:jr(M.data,e)})),w=[...x.map(M=>I(T({},M),{selected:!1})),...N],S=[...E.map(M=>I(T({},M),{selected:!1})),...b];r(w),a(S),t("forceSave",{nodes:w,edges:S})}};return d.addEventListener("keydown",u,!0),()=>{d.removeEventListener("keydown",u,!0)}},[n,r,i,a,s,e,o,t,l,c])};var Pr=require("react"),Xp=require("@xyflow/react");var Ky=20,qy=50,Mr={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},Zy=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},Up=e=>{let{getNodes:t}=(0,Xp.useReactFlow)(),{mode:o,isMoveTool:n}=Y(),r=(0,Pr.useRef)(0),i=(0,Pr.useRef)(new Map);(0,Pr.useEffect)(()=>{let a=s=>{if(o!=="edit"||!n||Zy(s.target)||!Object.values(Mr).includes(s.key))return;let u=t().filter(g=>g.selected);if(u.length===0){i.current.clear();return}s.preventDefault();let p=Date.now(),f=p-r.current<500;r.current=p;let x=s.shiftKey?qy:Ky,E=0,m=0;switch(s.key){case Mr.UP:m=-x;break;case Mr.DOWN:m=x;break;case Mr.LEFT:E=-x;break;case Mr.RIGHT:E=x;break}let h=u.map(g=>{let y=i.current.get(g.id);(!f||!y)&&(y={x:g.position.x,y:g.position.y});let v={x:y.x+E,y:y.y+m};return i.current.set(g.id,v),{id:g.id,dragging:!1,type:"position",position:v}});e&&e(h)};return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[t,e,o,n])};var Jp=require("@xyflow/react");var Kp={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY","gateway-parallel":"GATEWAY","gateway-complex":"GATEWAY"},qp={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},$p=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],n=e.match(/(\[.*?\])/)||[],r=e.match(/(\{.*?\})/)||[],i=e.match(/(--.*|\|.*?\|)/i)||[],a="",s="",l="";if(o.length){switch(o[1]){case"<start>":a="start-event";break;case"<end>":a="end-event";break}e=e.replace(o[1],"")}return n.length&&(a="task",s=n[1].replace(/\[|\]/g,""),e=e.replace(n[1],"")),r.length&&(s=r[1].replace(/\{|\}/g,""),s.charAt(0)==="+"?(a="gateway-parallel",s=s.slice(1)):s.charAt(0)==="*"?(a="gateway-complex",s=s.slice(1)):a="gateway-exclusive",e=e.replace(r[1],"")),a||(a="task",s=e),i.length&&(l=i[1].replace(/(\||--)/g,""),e=e.replace(i[1],"")),e=e.trim(),t[e]||(t[e]={type:a,label:s}),{step:e,type:a,label:s,edgeLabel:l}},Jy=e=>{e=e||"";let t=e.trim().split(`
|
|
42
|
-
`),o={},n=[];return t.forEach(r=>{r=r||"";let i=r.trim().split("-->");if(i.length!==2){console.warn("Invalid number of steps");return}let a=$p(i[0],o),s=$p(i[1],o);a&&s&&n.push({sourceId:a.step,targetId:s.step,label:a.edgeLabel||s.edgeLabel||""})}),{components:o,connections:n}},Zp=e=>{let{components:t,connections:o}=Jy(e);return{nodes:t,edges:o}};var Qy=7,jy=48,ex=340,tx=(e,t)=>{let o=jy+e.length*Qy;return Math.min(ex,Math.max(t,o))},fs=()=>{let{setNodes:e,setEdges:t}=(0,Jp.useReactFlow)(),{fitToNodes:o}=fo(),{getNextId:n}=ct();return{importFromLia:i=>{let a=typeof i=="string"?i:i.diagramXml||"",{nodes:s,edges:l}=Zp(a),c=[],d=new Map,u=!1,p=n();for(let[g,y]of Object.entries(s)){let v=String(p++),_=Kp[y.type],N=qp[y.type];_==="START_EVENT"&&(u=!0),d.set(g,v);let b=te[_].MIN_WIDTH,w=te[_].MIN_HEIGHT;c.push({id:v,type:_,data:{label:y.label||"",variant:N,attribute:""},position:{x:0,y:0},width:b,height:w,measured:{width:b,height:w}})}let f=[];for(let g of l){let y=I(T({},rt),{id:String(p++),source:d.get(g.sourceId)||g.sourceId,target:d.get(g.targetId)||g.targetId});f.push(y)}if(!u&&c.length>0){let g=String(p++),y={id:g,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:te.START_EVENT.MIN_WIDTH,height:te.START_EVENT.MIN_HEIGHT,measured:{width:te.START_EVENT.MIN_WIDTH,height:te.START_EVENT.MIN_HEIGHT}};c.unshift(y);let v=c[1];if(v){let _=I(T({},rt),{id:String(p++),source:g,target:v.id});f.unshift(_)}}let x=c.map(g=>{var y,v;return g.type==="TASK"?I(T({},g),{width:tx(String((v=(y=g.data)==null?void 0:y.label)!=null?v:""),te.TASK.MIN_WIDTH)}):g}),{nodes:E}=Fi(x,f),m=new Map(E.map(g=>[g.id,g.position])),h=c.map(g=>{var y;return I(T({},g),{position:(y=m.get(g.id))!=null?y:g.position})});return e(h),t(f),o(h),mr(h,f,p-1)}}};var ms=require("react"),ox={origin:"*",debug:!1};function gs(e,t=ox){let{origin:o,debug:n}=t,r=(0,ms.useCallback)((i,a)=>{let s={event:i,data:a};window.parent.postMessage(s,o||"*")},[o]);return(0,ms.useEffect)(()=>{if(!e)return;let i=a=>{let s=a.data;if(!(s!=null&&s.event)||(s==null?void 0:s.data)===void 0)return;let{event:l,data:c}=s,d;if(Array.isArray(c)){let[,u]=c;d=u.data}else d=c;n&&(console.debug("[postMessage] received:",s),console.debug("[postMessage] eventData:",d)),l&&e[l]&&e[l](d)};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[e,n]),{sendMessage:r}}var Qp=require("@xyflow/react"),Hn=require("react");var jp=()=>{let e=(0,Qp.useNodesInitialized)(),{initialDiagram:t,isNewDiagram:o,isInitialized:n,setIsInitialized:r,onElementChanges:i}=Y(),{importFromMxGraph:a,exportToMxGraph:s}=Pt(),{sendMessage:l}=gs(),c=(0,Hn.useRef)(!1);(0,Hn.useEffect)(()=>{t&&a(t)},[t,a]),(0,Hn.useEffect)(()=>{if(!n||!o||c.current)return;c.current=!0;let d=s();i==null||i(d)},[n,o,t,s,i]),(0,Hn.useEffect)(()=>{if(!e)return;(async()=>{await Kr(),r(!0),l("INIT_MODELER",t)})()},[e,t,r,l])};var ef=require("@xyflow/react"),Ca=require("react");function tf(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=Ao(),{getEdges:n}=(0,ef.useReactFlow)(),r=(0,Ca.useCallback)(a=>{if(!(a!=null&&a.activities))return;e(a.activities);let s=a.activities.map(c=>c.diagramId),l=n();o(l,s)},[e,o,n]),i=(0,Ca.useCallback)(()=>{t()},[t]);return{handleTasksStatus:r,handleClearTaskStatus:i}}var nf=require("@xyflow/react"),We=require("react"),rf=require("use-debounce");var rx=500,of=100,sf=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=(0,nf.useReactFlow)(),{mode:i,containerRef:a}=Y(),[s,l]=(0,We.useState)({history:[],currentStep:0}),{history:c,currentStep:d}=s,u=d>0,p=d<c.length-1,f=(0,We.useCallback)((b,w)=>{n(b[w].nodes),r(b[w].edges)},[n,r]),x=(0,We.useCallback)(()=>{if(d>0){let b=d-1;l(w=>I(T({},w),{currentStep:b})),f(c,b)}},[d,c,f]),E=(0,We.useCallback)(()=>{if(d<c.length-1){let b=d+1;l(w=>I(T({},w),{currentStep:b})),f(c,b)}},[c,d,f]),m=(0,We.useCallback)(b=>{l(w=>{let S=w.history[w.currentStep];if(S&&JSON.stringify(S)===JSON.stringify(b))return w;let D=[...w.history.slice(0,w.currentStep+1),b],O=D.length>of?D.slice(D.length-of):D;return{history:O,currentStep:O.length-1}})},[]),h=(0,We.useCallback)((b,w)=>{let S=b.map(L=>I(T({},L),{selected:!1,className:"",data:I(T({},L.data),{hasError:!1})})),M=w.map(L=>I(T({},L),{data:I(T({},L.data),{hasError:!1})}));return{nodes:wo(S),edges:M}},[]),g=(0,We.useCallback)(()=>h(t(),o()),[t,o,h]),y=(0,rf.useDebouncedCallback)(()=>{let b=g();m(b)},rx),v=(0,We.useCallback)((b,w)=>{if(!e)return;if(c.length===0){let M=g();l({history:[M],currentStep:0})}if(b==="forceSave"){if(w){m(h(w.nodes,w.edges));return}y();return}b.some(M=>M.type==="select")||oi(b)||y()},[e,y,c.length,g,m,h]);(0,We.useEffect)(()=>{if(e&&c.length===0){let b=g();l({history:[b],currentStep:0})}},[e,c.length,g]);let _=(0,We.useCallback)(b=>{l({history:b||[],currentStep:0})},[]),N=(0,We.useCallback)(()=>{l({history:[],currentStep:0})},[]);return(0,We.useEffect)(()=>{if(i!=="edit")return;let b=a.current;if(!b)return;let w=S=>{if(!b.contains(document.activeElement)||!(S.ctrlKey||S.metaKey))return;let D=S.key.toLowerCase();if(S.shiftKey&&D==="z"){S.preventDefault(),E();return}D==="z"&&(S.preventDefault(),x())};return b.addEventListener("keydown",w),()=>{b.removeEventListener("keydown",w)}},[x,E,i,a]),{history:c,undo:x,redo:E,canUndo:u,canRedo:p,saveHistory:v,resetHistory:_,clearHistory:N}};var af=()=>{let[e,t,o]=(0,go.useNodesState)([]),[n,r,i]=(0,go.useEdgesState)([]),{getNode:a}=(0,go.useReactFlow)(),s=(0,go.useStoreApi)(),{instanceId:l,isInitialized:c,setIsConnecting:d,onElementClick:u}=Y(),{updateHelperLines:p,HelperLines:f}=ki(),{undo:x,redo:E,canUndo:m,canRedo:h,saveHistory:g}=sf(c),{onNodeDrag:y,onDrop:v,onDragOver:_,onDragLeave:N,onNodeDragStop:b,onNodeDragStart:w}=Bp({nodes:e,setNodes:t,setEdges:r,saveHistory:g}),{isValidConnection:S,onConnect:M,onReconnect:L,onReconnectStart:D,onReconnectEnd:O,setReconnectingEdge:R,clearReconnectingEdge:V}=yp({setEdges:r,saveHistory:g}),{handleValidationComplete:G,clearValidation:B,dismissValidationPanel:A,validateDiagram:C,getIsValidating:k,getIsClearingValidation:P}=Ap(),{importFromLia:K}=fs(),{handleTasksStatus:Z,handleClearTaskStatus:W}=tf(),{clearPathEdges:H}=Ao(),{emitElementChanges:q,handleNodeChanges:z,handleEdgeChanges:U}=ds(),$=gl();Dp({saveHistory:g}),Wp({saveHistory:g}),jp();let X=(0,Dt.useCallback)(()=>{t([]),r([]),H(),setTimeout($,0)},[t,r,H,$]),{selectElements:ne,clearSelection:le}=Tt(),{importFromMxGraph:oe,exportToMxGraph:re}=Pt(),{configureElement:Ae,getConfigureElement:ae}=Ji(),Se=(0,Dt.useCallback)(ze=>{ze!=null&&ze.id&&ne([ze.id])},[ne]),{sendMessage:j}=gs({LIA_CREATE_DIAGRAM:K,CLEAR_DIAGRAM:X,TASKS_STATUS:Z,CLEAR_TASKS_STATUS:W,EXTERNAL_TASK_SELECT:Se}),ce=(0,Dt.useCallback)(()=>e.length+n.length,[e,n]);(0,Dt.useEffect)(()=>(St.set(l,{importFromMxGraph:oe,exportToMxGraph:re,selectElements:ne,clearSelection:le,configureElement:Ae,getConfigureElement:ae,getElementsCount:ce,setReconnectingEdge:R,clearReconnectingEdge:V}),()=>{St.delete(l)}),[l,oe,re,ne,le,Ae,ae,ce,R,V]);let ke=(0,Dt.useCallback)((ze,_t)=>{if(_t.type!=="TASK"&&_t.type!=="GATEWAY")return;let zr=ae(_t.id);zr&&(u==null||u(zr)),_t.type==="TASK"&&j("SELECT_TASK",{id:_t.id})},[ae,u,j]),ut=(0,Dt.useCallback)((ze,_t)=>{if(_t.type!=="SEQUENCE_EDGE")return;let zr=a(_t.source),dm=a(_t.target),{isFromStartEvent:um,isGatewayToGateway:pm,isActiviyToAndGateway:fm,isToEndEvent:mm}=ti(zr,dm);if(!(!um&&!pm&&!fm&&!mm))return;let Ba=ae(_t.id);Ba&&(u==null||u(Ba))},[ae,a,u]),bo=(0,Dt.useCallback)(ze=>{p(ze,e),o(ze),!oi(ze)&&(g(ze),P()||A(),k()||z(ze))},[e,g,P,A,p,z,k,o]),Vr=(0,Dt.useCallback)(ze=>{i(ze),g(ze),P()||A(),k()||U(ze)},[i,g,P,A,U,k]);Up(bo);let{onBeforeDelete:Hr,onNodesDelete:Gr,onEdgesDelete:Br}=Op({nodes:e,setNodes:t});return{nodes:e,setNodes:t,edges:n,setEdges:r,events:{isValidConnection:S,onConnect:M,onReconnect:L,onReconnectStart:D,onReconnectEnd:O,onDrop:v,onDragOver:_,onDragLeave:N,onNodeDrag:y,onNodeDragStop:b,onNodeDragStart:w,onNodeClick:ke,onEdgeClick:ut,onDropCapture:()=>{g("forceSave"),q(),A()},onConnectStart:()=>{d(!0)},onConnectEnd:()=>{d(!1),A()},onSelectionEnd:()=>setTimeout(()=>s.setState({nodesSelectionActive:!1}),0),onNodesChange:bo,onEdgesChange:Vr,onBeforeDelete:Hr,onNodesDelete:Gr,onEdgesDelete:Br},ui:{handleCloseValidationPanel:B},controls:{undo:x,redo:E,canUndo:m,canRedo:h},components:{HelperLines:f},actions:{saveHistory:g,selectElements:ne,clearSelection:le,exportToMxGraph:re,validateDiagram:C,handleValidationComplete:G,setReconnectingEdge:R,clearReconnectingEdge:V}}};var lf=require("react"),cf=require("@xyflow/react");function hs(){return(0,cf.useStore)((0,lf.useCallback)(e=>e.nodes.length+e.edges.length>0,[]))}var df=require("@xyflow/react"),ho=require("react");var ix=".react-flow__node, .react-flow__edge, .react-flow__node-toolbar";function uf(e,t,o){let[n,r]=(0,ho.useState)(!1),i=(0,ho.useRef)(null),{getViewport:a,setViewport:s}=(0,df.useReactFlow)(),l=(0,ho.useCallback)(()=>{i.current=null,r(!1)},[]);return(0,ho.useEffect)(()=>{let c=e.current;if(!c)return;let d=f=>{if(!vr.some(E=>E===f.button)||t.current||o.current||(r(!0),!(f.target instanceof Element))||!f.target.closest(ix))return;f.preventDefault(),f.stopPropagation();let x=a();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&Aa)===0){l();return}s({x:x.viewportX+(f.clientX-x.pointerX),y:x.viewportY+(f.clientY-x.pointerY),zoom:x.zoom})}},p=f=>{(f.buttons&Aa)===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,a,s,l]),n}var Sa=require("react/jsx-runtime"),ys=({id:e,className:t})=>(0,Sa.jsx)("marker",{id:e,className:F("react-flow__arrowhead",t),viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"7",markerHeight:"7",orient:"auto",markerUnits:"userSpaceOnUse",fill:"currentColor",stroke:"currentColor",children:(0,Sa.jsx)("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});var Zo=require("react/jsx-runtime"),pf=()=>(0,Zo.jsx)("svg",{style:{position:"absolute",top:0,left:0},children:(0,Zo.jsxs)("defs",{children:[(0,Zo.jsx)(ys,{id:"sequence-edge-marker",className:"text-grey-500"}),(0,Zo.jsx)(ys,{id:"sequence-edge-marker-hovered",className:"text-grey-800"}),(0,Zo.jsx)(ys,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});var Eo=require("@produto-lecom/lecom-ui");var kr=require("@xyflow/react"),we=require("@produto-lecom/lecom-ui"),Rt=require("lucide-react"),xt=Wn(require("react"),1);var yo=require("@produto-lecom/lecom-ui");var Lr=(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))(Lr||{});var _s=require("@produto-lecom/lecom-ui"),Tf=require("@xyflow/react");var xs=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 ff({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let r="data:text/csv;charset=utf-8,"+[e,...t].map(a=>a.join(",")).join(`
|
|
43
|
-
`),i=encodeURI(r);Es(i,`${o}.csv`)}var Es=(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 mf(e){return e==null?void 0:e.replaceAll("
"," ")}var
|
|
39
|
+
`).trim();t&&N.length>t&&(N=N.substring(0,t)),_.currentTarget.innerText=N,s==null||s(),N!==e&&(a==null||a(N))};return(0,ra.jsx)("div",{className:F("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:(0,ra.jsx)("div",{ref:u,className:F("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":f}),contentEditable:f,suppressContentEditableWarning:!0,onKeyDown:h,onPaste:g,onInput:y,onBlur:v,children:e})})};var Vo=require("@xyflow/react");var gr=require("@xyflow/react"),Jd=require("react");function ia(e,t,o){return e.x<=t&&e.x+e.width>=t&&e.y<=o&&e.y+e.height>=o}function sa(e){return e.x+e.width/2}function aa(e){return e.y+e.height/2}function Ui(e){return{x:e.x,y:e.y,width:0,height:0}}function In(e,t,o,n){!ia(t,n.x,n.y)&&!ia(o,n.x,n.y)&&e.push(n)}function Xd(e,t,o,n,r){let i=[],a=o?Ui(o):e,s=n?Ui(n):t,l=Math.max(a.x,s.x),c=Math.min(a.x+a.width,s.x+s.width),d=r?r.x:Math.round(c+(l-c)/2),u=aa(a),p=aa(s);if(r&&(r.y>=a.y&&r.y<=a.y+a.height&&(u=r.y),r.y>=s.y&&r.y<=s.y+s.height&&(p=r.y)),In(i,s,a,{x:d,y:u}),In(i,s,a,{x:d,y:p}),i.length===0)if(r)In(i,s,a,{x:d,y:r.y});else{let f=Math.max(a.y,s.y),x=Math.min(a.y+a.height,s.y+s.height);i.push({x:d,y:f+(x-f)/2})}return i}function Ud(e,t,o,n,r){let i=[],a=o?Ui(o):e,s=n?Ui(n):t,l=Math.max(a.y,s.y),c=Math.min(a.y+a.height,s.y+s.height),d=sa(a);r&&r.x>=a.x&&r.x<=a.x+a.width&&(d=r.x);let u=r?r.y:Math.round(c+(l-c)/2);if(In(i,s,a,{x:d,y:u}),r&&r.x>=s.x&&r.x<=s.x+s.width?d=r.x:d=sa(s),In(i,s,a,{x:d,y:u}),i.length===0)if(r)In(i,s,a,{x:r.x,y:u});else{let p=Math.max(a.x,s.x),f=Math.min(a.x+a.width,s.x+s.width);i.push({x:p+(f-p)/2,y:u})}return i}function la(e,t,o,n,r){let i=!1,a=!1;if(r){let s=Math.min(e.x,t.x),l=Math.max(e.x+e.width,t.x+t.width),c=Math.min(e.y,t.y),d=Math.max(e.y+e.height,t.y+t.height);i=r.y<c||r.y>d,a=r.x<s||r.x>l}else{let s=Math.max(e.x,t.x),l=Math.min(e.x+e.width,t.x+t.width);if(i=s===l,!i){let c=Math.max(e.y,t.y),d=Math.min(e.y+e.height,t.y+t.height);a=c===d}}return!a&&i?{waypoints:Ud(e,t,o,n,r),direction:"top-to-bottom"}:{waypoints:Xd(e,t,o,n,r),direction:"side-to-side"}}function gy(e,t,o){return t.x>=o.x&&t.x<=o.x+o.width?e.x=t.x:t.y>=o.y&&t.y<=o.y+o.height&&(e.y=t.y),t.x<o.x?e.x=o.x:t.x>o.x+o.width&&(e.x=o.x+o.width),t.y<o.y?e.y=o.y:t.y>o.y+o.height&&(e.y=o.y+o.height),e}function $d(e,t,o,n=0){let r=n?{x:e.x-n,y:e.y-n,width:e.width+2*n,height:e.height+2*n}:e,i=r.x+r.width/2,a=r.y+r.height/2,s=t.x-i,l=t.y-a,c=Math.atan2(l,s),d={x:0,y:0},u=Math.PI,f=Math.PI/2-c,x=Math.atan2(r.height,r.width);return c<-u+x||c>u-x?(d.x=r.x,d.y=a-r.width*Math.tan(c)/2):c<-x?(d.y=r.y,d.x=i-r.height*Math.tan(f)/2):c<x?(d.x=r.x+r.width,d.y=a+r.width*Math.tan(c)/2):(d.y=r.y+r.height,d.x=i+r.height*Math.tan(f)/2),o?gy(d,t,r):d}function hy(e,t,o,n,r,i){let a=e-o,s=t-n;if(i>=s&&i<=t+n){let l=i-t,c=Math.sqrt(o*o*(1-l*l/(n*n)))||0;return r<=a&&(c=-c),{x:e+c,y:i}}if(r>=a&&r<=e+o){let l=r-e,c=Math.sqrt(n*n*(1-l*l/(o*o)))||0;return i<=s&&(c=-c),{x:r,y:t+c}}}function Kd(e,t,o,n=0){let r=e.x-n,i=e.y-n,a=e.width+2*n,s=e.height+2*n,l=a/2,c=s/2,d=r+l,u=i+c,p=t.x,f=t.y,x=Math.trunc(p-d),E=Math.trunc(f-u);if(x===0&&E!==0)return{x:d,y:u+c*E/Math.abs(E)};if(x===0&&E===0)return{x:p,y:f};if(o){let D=hy(d,u,l,c,p,f);if(D)return D}let m=E/x,h=u-m*d,g=l*l*m*m+c*c,y=-2*d*g,v=l*l*m*m*d*d+c*c*d*d-l*l*c*c,_=Math.sqrt(y*y-4*g*v),N=(-y+_)/(2*g),b=(-y-_)/(2*g),w=m*N+h,S=m*b+h,M=Math.sqrt(Math.pow(N-p,2)+Math.pow(w-f,2)),L=Math.sqrt(Math.pow(b-p,2)+Math.pow(S-f,2));return M<L?{x:N,y:w}:{x:b,y:S}}function ca(e){return e==="ellipse"?Kd:$d}function Zd(e){let{x:t,y:o,width:n,height:r}=e.bounds;return{x:t+n/2,y:o+r/2}}function yy(e,t,o){let n=null;if(e.length>=2){let r=e.length;n=e[o?Math.min(1,r-1):Math.max(0,r-2)]}return n!=null||(n=Zd(t)),n}function qd(e,t,o,n){let r=yy(e,o,n);return t.bounds.width<=0&&t.bounds.height<=0?Zd(t):ca(t.perimeter)(t.bounds,r,!0,0)}function Xt(e){var p;let{source:t,target:o,controlPoint:n=null,fixedSourcePoint:r=null,fixedTargetPoint:i=null}=e,a=r,s=i,{waypoints:l,direction:c}=la(t.bounds,o.bounds,a,s,n),d=[a,...l,s];d.at(-1)==null&&(d[d.length-1]=qd(d,o,t,!1)),(p=d[0])!=null||(d[0]=qd(d,t,o,!0));let u=d;return{points:u,sourcePoint:u[0],targetPoint:u.at(-1),waypoints:l,direction:c}}function da(e,t){let o=Xt({source:e,target:t});return xy(o.targetPoint,t.bounds)}function xy(e,t){if(Math.abs(e.x-t.x)<=1)return"left";if(Math.abs(e.x-(t.x+t.width))<=1)return"right";if(Math.abs(e.y-t.y)<=1)return"top";if(Math.abs(e.y-(t.y+t.height))<=1)return"bottom";let n=t.x+t.width/2,r=t.y+t.height/2,i=Math.abs(e.x-n),a=Math.abs(e.y-r);return i>=a?e.x<n?"left":"right":e.y<r?"top":"bottom"}function Qd(e){var i;let{inProgress:t,fromNode:o}=(0,gr.useConnection)(),n=(0,gr.useInternalNode)(e),r=(0,gr.useInternalNode)((i=o==null?void 0:o.id)!=null?i:"");return(0,Jd.useMemo)(()=>!t||!r||r.id===e||!n?null:da(Ht(r),Ht(n)),[t,r,e,n])}var hr=require("@xyflow/react");var ua=require("react/jsx-runtime"),An=i=>{var a=i,{type:e,position:t,className:o,nodeType:n}=a,r=bt(a,["type","position","className","nodeType"]);let s=n==="TASK";return(0,ua.jsx)(hr.Handle,T({type:e,position:t,className:F("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":s,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":!s},o)},r))},jd=s=>{var l=s,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,a=bt(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=(0,hr.useReactFlow)(),p=(()=>{if(n!=="source")return!1;let f=c();if(t==="TASK")return f.filter(E=>E.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return f.filter(E=>E.source===e).length>=2;if(t==="START_EVENT"){let x=d();return f.filter(m=>{if(m.source!==e)return!1;let h=x.find(g=>g.id===m.target);return(h==null?void 0:h.type)!=="ANNOTATION"}).length>=1}return!1})();return(0,ua.jsx)(hr.Handle,T({type:n,position:r,className:F("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"}},a))};var lo=require("react/jsx-runtime"),eu=[{position:Vo.Position.Left,side:"left"},{position:Vo.Position.Right,side:"right"},{position:Vo.Position.Top,side:"top"},{position:Vo.Position.Bottom,side:"bottom"}],it=({nodeId:e,nodeType:t,gatewayVariant:o,targetHandleClassName:n,conditionalSource:r=!1})=>{let{inProgress:i,fromNode:a,toNode:s,isValid:l}=(0,Vo.useConnection)(),{reconnectingEdgeId:c}=Y(),d=Qd(e),u=i&&(a==null?void 0:a.id)!==e||!!c,p=!i||u,f=!!s&&s.id===e;return(0,lo.jsxs)(lo.Fragment,{children:[p&&eu.map(({position:x,side:E})=>{let m=u&&(d===null||E===d);return(0,lo.jsx)(An,{type:"target",position:x,id:E,className:F(m&&n,m&&f&&(l?"valid":"connectingto"))},`target-${E}`)}),!i&&eu.map(({position:x,side:E})=>r?(0,lo.jsx)(jd,{type:"source",position:x,id:E,nodeId:e,nodeType:t,gatewayVariant:o},`source-${E}`):(0,lo.jsx)(An,{type:"source",position:x,id:E},`source-${E}`))]})};var pa=require("react"),Ut=require("@xyflow/react");var tu=require("react"),ou=require("@xyflow/react");function Nt(){return(0,ou.useStore)((0,tu.useCallback)(e=>e.nodes.filter(o=>o.selected).length+e.edges.filter(o=>o.selected).length>=2,[]))}var nu=require("@xyflow/react"),$i=()=>{let e=(0,nu.useStoreApi)();return{getInternalNodes:()=>{let{nodeLookup:o}=e.getState();return Array.from(o.values())}}};var Ki=require("react/jsx-runtime"),fa=require("react"),Ey=["top","right","bottom","left"],_y=["top-left","top-middle","top-right","right-middle","bottom-left","left-middle","bottom-right","bottom-middle"],st=r=>{var i=r,{nodeId:e,isVisible:t,offset:o=8}=i,n=bt(i,["nodeId","isVisible","offset"]);let{getInternalNode:a,setNodes:s}=(0,Ut.useReactFlow)(),{getInternalNodes:l}=$i(),c=Nt(),d=(0,Ut.useStoreApi)(),u=(0,pa.useRef)(0),p=(0,pa.useRef)([]),f=({y:h,width:g,height:y})=>{cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{var V,G;if(!e)return;let{nodeLookup:v,onNodesChange:_}=d.getState(),N=v.get(e);if(!N||N.type!=="LANE")return;let b=!N.parentId,w=b?N.id:N.parentId;if(!w)return;let S=Array.from(v.values()).filter(B=>B.type==="LANE"&&B.parentId===w);if(!S.length)return;p.current.length===0&&(p.current=Oo(S).map(B=>B.id));let M=p.current.map(B=>S.find(A=>A.id===B)).filter(Boolean),L=[],D=0,O=M.findIndex(B=>B.id===N.id),R=!b&&O>0&&Math.abs(h-N.position.y)>.5;for(let B=0;B<M.length;B++){let A=M[B],C=A.id===N.id,k=B===M.length-1;if(C){D=R?h+y:D+y;continue}let P=(G=(V=A.measured)==null?void 0:V.height)!=null?G:0,K=b?g-J.HEADER_WIDTH:g,Z=P;b&&k&&(Z=Math.max(J.MIN_HEIGHT,y-D)),R&&B===O-1&&(Z=Math.max(J.MIN_HEIGHT,h-D)),L.push({id:A.id,type:"dimensions",dimensions:{width:K,height:Z},setAttributes:!0}),L.push({id:A.id,type:"position",position:{x:J.HEADER_WIDTH,y:D}}),D+=Z}b?L.push({id:w,type:"dimensions",dimensions:{width:g,height:y},setAttributes:!0}):L.push({id:w,type:"dimensions",dimensions:{width:g+J.HEADER_WIDTH,height:D},setAttributes:!0}),_==null||_(L)})},x=({y:h,width:g,height:y})=>{var N;if(cancelAnimationFrame(u.current),p.current=[],!e)return;let v=a(e);if(!v||v.type!=="LANE"&&!v.parentId)return;let _=[...l()];if(v.type!=="LANE"){_=_.map(b=>b.id===e?I(T({},b),{width:g,height:y,measured:{width:g,height:y}}):b),_=Wt(_),s(_);return}_=Nd(v,g,y,_,h),_=Wt(_),_=Ro((N=v.parentId)!=null?N:v.id,_),s(_)};if(!(!c&&t))return null;let m={"--resize-offset":`${o}px`};return(0,Ki.jsxs)(Ki.Fragment,{children:[Ey.map(h=>(0,fa.createElement)(Ut.NodeResizeControl,I(T({},n),{key:h,nodeId:e,position:h,variant:Ut.ResizeControlVariant.Line,className:"border-blue-400/90 border-dashed",style:m,onResize:(g,y)=>f(y),onResizeEnd:(g,y)=>x(y)}))),_y.map(h=>(0,fa.createElement)(Ut.NodeResizeControl,I(T({},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:m,onResize:(g,y)=>f(y),onResizeEnd:(g,y)=>x(y)})))]})};var zo=require("@xyflow/react"),Ct=require("@produto-lecom/lecom-ui"),Ge=Xn(require("react"),1);var ru=require("zustand"),Cn=(0,ru.create)(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));var qi=require("react"),iu=(e,t=!1)=>{let[o,n]=(0,qi.useState)({width:0,height:0});return(0,qi.useEffect)(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};var co=require("@xyflow/react"),su=require("react"),by=120,Ty=12,au=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=(0,co.useReactFlow)(),{instanceId:i}=Y();return(0,su.useMemo)(()=>{var f,x;if(!t)return{position:co.Position.Right,align:"start"};let a=n(e);if(!a)return{position:co.Position.Right,align:"start"};let s=r(),l=a.position.x*s.zoom+s.x,c=(((f=a.measured)==null?void 0:f.width)||a.width||100)*s.zoom,d=(x=document.getElementById(`modeler-${i}`))==null?void 0:x.clientWidth;if(!d)return{position:co.Position.Right,align:"start"};let u=(o==null?void 0:o.width)||by;return{position:l+c+u+Ty>d?co.Position.Left:co.Position.Right}},[i,e,t,o,n,r])};var ma=require("lucide-react");var Zi=require("@xyflow/react"),ie=require("@produto-lecom/lecom-ui"),lu=require("lucide-react");var me=require("react/jsx-runtime"),cu=({nodeId:e})=>{let{t}=(0,ie.useTranslation)(),{updateNodeData:o,getEdges:n,getNode:r}=(0,Zi.useReactFlow)(),i=(0,Zi.useNodesData)(e),s=n().filter(x=>x.source===e).some(x=>{let E=r(x.target);return(E==null?void 0:E.type)==="END_EVENT"}),l=(i==null?void 0:i.data.variant)==="SUBPROCESS",c=(i==null?void 0:i.data.variant)==="SERVICE_TASK",d=p=>{o(e,{variant:(i==null?void 0:i.data.variant)===p?"":p})},u=p=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===p?"":p})};return(0,me.jsxs)(ie.DropdownMenu,{children:[(0,me.jsxs)(ie.Tooltip,{children:[(0,me.jsx)(ie.TooltipTrigger,{asChild:!0,children:(0,me.jsx)(ie.DropdownMenuTrigger,{asChild:!0,children:(0,me.jsx)(ie.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:(0,me.jsx)(lu.WrenchIcon,{})})})}),(0,me.jsx)(ie.TooltipContent,{color:"black",children:t("bpmn.task.menu.title")})]}),(0,me.jsxs)(ie.DropdownMenuContent,{align:"start",className:"w-60 bg-white text-grey-600",children:[(0,me.jsxs)(ie.DropdownMenuLabel,{className:"flex items-center gap-1",children:[(0,me.jsx)("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),(0,me.jsx)("div",{className:"flex items-center gap-1",children:Object.entries(Qr).map(([p,f])=>{let x=p==="LOOP"&&(s||l||c),m=(()=>{if(p==="LOOP"&&s)return t("editor.task_menu.loop_not_allowed_when_connected_to_end");if(p==="LOOP"&&l)return t("editor.task_menu.loop_not_allowed_when_subprocess");if(p==="LOOP"&&c)return t("editor.task_menu.loop_not_allowed_when_service_task");if(p==="LOOP")return t("editor.task_menu.loop")})();return(0,me.jsxs)(ie.Tooltip,{children:[(0,me.jsx)(ie.TooltipTrigger,{asChild:!0,children:(0,me.jsx)(ie.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:x,className:F({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===p,"opacity-50 cursor-not-allowed":x}),onClick:x?void 0:()=>u(p),children:(0,me.jsx)(f.icon,{className:"stroke-inherit"})})}),m&&(0,me.jsx)(ie.TooltipContent,{color:"black",children:m})]},p)})})]}),(0,me.jsx)(ie.DropdownMenuGroup,{children:(0,me.jsxs)(ie.Tooltip,{children:[(0,me.jsx)(ie.TooltipTrigger,{asChild:!0,children:(0,me.jsx)("div",{className:F({"cursor-not-allowed":s}),children:(0,me.jsxs)(ie.DropdownMenuItem,{className:F({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":s}),disabled:s,onClick:()=>d("SCRIPT"),children:[(0,me.jsx)(Jr.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),s&&(0,me.jsx)(ie.TooltipContent,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};var wt=require("@produto-lecom/lecom-ui"),du=require("lucide-react");var at=require("@xyflow/react");var Ji=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=(0,at.useReactFlow)(),{selectElements:r}=Tt(),i=m=>{let h=o(),g=n(),y=(0,at.getIncomers)(m,h,g),v=(0,at.getOutgoers)(m,h,g),_=y.some(b=>b.type==="START_EVENT"),N=v.some(b=>b.type==="END_EVENT");return _?"start":N?"end":"between"},a=(m,h,g)=>{var _,N,b,w,S;if(!m)return;let y={type:m.type,variant:(_=m.data)==null?void 0:_.variant,attribute:(N=m.data)==null?void 0:N.attribute},v={id:m.id,position:i(m),label:(b=m.data)==null?void 0:b.label,node:y};return m.type==="TASK"&&((w=m.data)==null?void 0:w.variant)==="SUBPROCESS"?I(T({},v),{type:"sub_process"}):m.type==="TASK"&&((S=m.data)==null?void 0:S.variant)==="SERVICE_TASK"?I(T({},v),{type:"service_task"}):m.type==="GATEWAY"?I(T({},v),{type:"gateway",variant:s(m,h,g)}):I(T({},v),{type:"activity"})},s=(m,h,g)=>{if(m.type!=="GATEWAY")return;let y=(0,at.getIncomers)(m,h,g),v=!1,_=!1;if(y.forEach(N=>{var b,w;N.type==="TASK"&&(((b=N.data)==null?void 0:b.variant)==="SCRIPT"&&(v=!0),((w=N.data)==null?void 0:w.attribute)==="LOOP"&&(_=!0))}),v&&_)return"script_loop";if(v)return"script";if(_)return"loop"},l=(m,h,g)=>{var b,w,S,M;let y=e(m.source),v=e(m.target);if(!y||!v)return"simple";if((0,at.getOutgoers)(y,h,g).some(L=>L.type==="END_EVENT"))return"final";if(y.type==="GATEWAY")switch((b=y.data)==null?void 0:b.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(y.type==="TASK"){let L=(w=y.data)==null?void 0:w.variant,D=(S=y.data)==null?void 0:S.attribute;if(L==="SUBPROCESS")return"from_sub_process";if(v.type==="TASK"&&((M=v.data)==null?void 0:M.variant)==="SUBPROCESS")return"to_sub_process";if(L==="SERVICE_TASK")return"from_service_task";let O=L==="SCRIPT",R=D==="LOOP";return O&&R?"script_loop":O?"script":R?"loop":"simple"}return"simple"},c=(m,h,g)=>{let y=[];function v(N,b,w=0){let S=a(N,h,g);if(S.depth=w,b.push(S),N.type==="TASK"){y.push([...b]),b.pop();return}let M=(0,at.getIncomers)(N,h,g);if(M.length)for(let L of M)v(L,b,w+1);b.pop()}let _=(0,at.getIncomers)(m,h,g);for(let N of _)v(N,[]);return y},d=(m,h,g)=>{let y=[];function v(N,b,w=0){let S=a(N,h,g);if(S.depth=w,b.push(S),N.type==="TASK"){y.push([...b]),b.pop();return}let M=(0,at.getOutgoers)(N,h,g);if(M.length)for(let L of M)v(L,b,w+1);b.pop()}let _=(0,at.getOutgoers)(m,h,g);for(let N of _)v(N,[]);return y},u=(m,h,g)=>(g=g.filter(v=>v.source===m.id),g.map(v=>{var b;let _=e(v.target),N;return _&&(N=a(_,h,g)),{id:v.id,type:"routing",variant:l(v,h,g),label:(b=v.data)==null?void 0:b.label,target:N}})),p=m=>{let h=e(m);if(!h)return;let g=o(),y=n(),v=a(h,g,y);return v.sources=c(h,g,y),v.targets=d(h,g,y),v.edgeTargets=u(h,g,y),h.type==="GATEWAY"&&(v.variant=s(h,g,y)),v},f=m=>{let h=t(m);if(!h)return;let g=o(),y=n(),v=l(h,g,y),N={id:h.id,type:"routing",variant:v,gatewayVariant:void 0},b=e(h.source);if(b){let S=a(b,g,y);N.source=S;let M=s(b,g,y);if(N.gatewayVariant=M,b.type==="TASK")N.sources=[[S]];else{let L=c(b,g,y);N.sources=L.length?L:[[S]]}}let w=e(h.target);if(w){let S=a(w,g,y);if(N.target=S,w.type==="TASK")N.targets=[[S]];else{let M=d(w,g,y);N.targets=M.length?M:[[S]]}}return N},x=m=>{let h=e(m);if(h)return p(h.id);let g=t(m);if(g)return f(g.id)};return{configureElement:m=>{let h=x(m);if(h)return r([m]),h},getConfigureElement:x,getNodeConfigure:p,getEdgeConfigure:f}};var Ho=require("react/jsx-runtime"),vy={node:"editor.toolbar.configure_node",edge:"editor.toolbar.configure_edge",gateway:"editor.toolbar.configure_gateway"},uo=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,wt.useTranslation)(),{onConfigureElement:n}=Y(),{getConfigureElement:r}=Ji();return(0,Ho.jsxs)(wt.Tooltip,{children:[(0,Ho.jsx)(wt.TooltipTrigger,{asChild:!0,children:(0,Ho.jsx)(wt.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let a=r(e);a&&(n==null||n(a))},children:(0,Ho.jsx)(du.Settings,{size:16})})}),(0,Ho.jsx)(wt.TooltipContent,{color:"black",children:o(vy[t])})]})};var It=require("@produto-lecom/lecom-ui"),pu=require("@xyflow/react"),fu=require("lucide-react");var uu=require("@produto-lecom/lecom-ui");function Oe(){let{toast:e}=Sn(),{toast:t}=(0,uu.useNotificationToast)();return{toast:e||t}}var Go=require("react/jsx-runtime"),Qi=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,It.useTranslation)(),{toast:n}=Oe(),{deleteElements:r,getNodes:i}=(0,pu.useReactFlow)(),{isRemovingElements:a}=Y();return(0,Go.jsxs)(It.Tooltip,{children:[(0,Go.jsx)(It.TooltipTrigger,{asChild:!0,children:(0,Go.jsx)(It.Button,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{if(!a)if(t==="node"){let l=i(),c=l.find(d=>d.id===e);if((c==null?void 0:c.type)==="LANE"&&l.some(u=>u.parentId===e)){n({variant:"error",title:o("validation.errors.title"),content:o("editor.toolbar.delete_pool_lane_error")});return}r({nodes:[{id:e}]})}else r({edges:[{id:e}]})},disabled:a,children:(0,Go.jsx)(fu.TrashIcon,{size:16})})}),(0,Go.jsx)(It.TooltipContent,{color:"black",children:o(a?"editor.toolbar.deleting":"editor.toolbar.delete")})]})};var At=require("@produto-lecom/lecom-ui"),mu=require("lucide-react"),gu=require("react"),Bo=require("react/jsx-runtime"),Mn=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=(0,At.useTranslation)(),r=(0,gu.useCallback)(i=>{i.stopPropagation();let a=document.querySelectorAll(`.react-flow__handle.source[data-nodeid="${e}"]`);if(a.length===0)return;let s=Array.from(a).reduce((p,f)=>{let x=p.getBoundingClientRect(),E=f.getBoundingClientRect(),m=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))<m?f:p}),l=s.getBoundingClientRect(),c=l.left+l.width/2,d=l.top+l.height/2,u=new MouseEvent("mousedown",{clientX:c,clientY:d,bubbles:!0,cancelable:!0});s.dispatchEvent(u)},[e]);return(0,Bo.jsxs)(At.Tooltip,{children:[(0,Bo.jsx)(At.TooltipTrigger,{asChild:!0,children:(0,Bo.jsx)(At.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:(0,Bo.jsx)(mu.MoveUpRightIcon,{size:16})})}),(0,Bo.jsx)(At.TooltipContent,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};var Ee=require("react/jsx-runtime"),$t={START_EVENT:{type:"START_EVENT",icon:Kn,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:nn,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:Kn,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:$r,label:"bpmn.annotation.variant.default"}},Ny={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:an,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:cn,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:rn,label:"bpmn.gateway.variant.complex"}},Ye=Ge.default.memo(({nodeId:e,nodeType:t,nodeVariant:o,isChild:n})=>{let r=(0,Ge.useRef)(null),i=(0,Ge.useRef)(null),{t:a}=(0,Ct.useTranslation)(),{setDraggableNode:s}=Cn(),{getEdges:l,getNodes:c,setNodes:d}=(0,zo.useReactFlow)(),{setIsDragging:u,mode:p,isConnecting:f,isDragging:x}=Y(),E=Nt(),m=(0,zo.useStore)((0,Ge.useCallback)(z=>{var W,X;return(X=(W=z.nodeLookup.get(e))==null?void 0:W.selected)!=null?X:!1},[e])),h=(0,zo.useStore)((0,Ge.useCallback)(z=>{var W,X;return(X=(W=z.nodeLookup.get(e))==null?void 0:W.dragging)!=null?X:!1},[e])),g=m&&!h&&!f&&!x&&!E,{dimensions:y}=iu(r,g),{position:v}=au(e,g,y),[_,N]=(0,Ge.useState)(void 0),b=o==="SUBPROCESS",w=o==="SERVICE_TASK",S=(0,Ge.useRef)(null),M=(0,Ge.useRef)(!1),L=(0,Ge.useCallback)(()=>{S.current!==null&&(clearTimeout(S.current),S.current=null),M.current=!1,u(!1),s(null),N(void 0),d(z=>z.map(W=>I(T({},W),{className:void 0})))},[u,s,d]);(0,Ge.useEffect)(()=>{let z=W=>{M.current&&W.buttons===0&&L()};return document.addEventListener("dragend",L),document.addEventListener("mousemove",z),()=>{document.removeEventListener("dragend",L),document.removeEventListener("mousemove",z)}},[L]);let D=(0,Ge.useCallback)((z,W)=>{M.current=!0,u(!1),s({type:W.type,variant:W.variant,attribute:W.attribute,icon:W.icon}),W.icon&&N((0,Ee.jsx)(W.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,s,u]),O=(0,Ge.useCallback)(()=>{L()},[L]);if(!g)return null;let R=c(),V=l(),G=[{component:(0,Ee.jsx)(Qi,{elementId:e})}],B=()=>{if(p==="view")return[];let z=!V.some(W=>{var X;return W.source===e&&((X=R.find($=>$.id===W.target))==null?void 0:X.type)!=="ANNOTATION"});return[{component:(0,Ee.jsx)(Mn,{nodeId:e,disabled:!z,tooltipMessage:z?void 0:a("editor.toolbar.start_event_limit_reached")})},$t.TASK,$t.ANNOTATION,...G]},A=()=>p==="view"?[{component:(0,Ee.jsx)(uo,{elementId:e})}]:[{component:(0,Ee.jsx)(uo,{elementId:e})},...b||w?[]:[{component:(0,Ee.jsx)(cu,{nodeId:e})}],{component:(0,Ee.jsx)(Mn,{nodeId:e})},$t.TASK,{type:"TASK",variant:"SUBPROCESS",icon:qn,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:ma.Bot,label:"bpmn.task.variant.service_task"},$t.ANNOTATION,...Object.values(Ny),...Do(e,R,V)?[]:[$t.END_EVENT],...G],C=()=>p==="view"?[{component:(0,Ee.jsx)(uo,{elementId:e,elementType:"gateway"})}]:[{component:(0,Ee.jsx)(uo,{elementId:e,elementType:"gateway"})},{component:(0,Ee.jsx)(Mn,{nodeId:e})},$t.TASK,{type:"TASK",variant:"SUBPROCESS",icon:qn,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:ma.Bot,label:"bpmn.task.variant.service_task"},$t.ANNOTATION,...G],k=()=>p==="view"?[]:[$t.ANNOTATION,...G],P=()=>p==="view"?[]:[...n?[]:[{component:(0,Ee.jsx)(Mn,{nodeId:e})}],$t.ANNOTATION,...G],K=()=>p==="view"?[]:[{component:(0,Ee.jsx)(Mn,{nodeId:e})},...G],Z=()=>p==="view"?[]:[...G],H=(z=>{switch(z){case"START_EVENT":return B();case"TASK":return A();case"GATEWAY":return C();case"END_EVENT":return k();case"LANE":return P();case"ANNOTATION":return K();case"UNSUPPORTED":return Z();default:return[]}})(t),q=H.length>6;if(!(H.length===0||p==="readonly"))return(0,Ee.jsxs)(zo.NodeToolbar,{position:v,align:"start",className:q?"-top-[4.5rem]":"-top-8",isVisible:g,children:[(0,Ee.jsx)("div",{ref:r,className:`${q?"grid grid-cols-6":"flex"} gap-1 px-2 py-2 bg-white rounded-sm shadow-md`,children:H.map((z,W)=>{if(z.component)return(0,Ee.jsx)("div",{children:z.component},W);let X={sourceNodeType:t,targetNodeType:z.type,sourceNodeId:e,nodes:R,edges:V},$=_d(X),ne={gateway_limit_reached:a("editor.toolbar.gateway_limit_reached"),start_event_limit_reached:a("editor.toolbar.start_event_limit_reached"),start_event_already_exists:a("editor.toolbar.start_event_already_exists"),script_to_end_not_allowed:a("editor.toolbar.script_to_end_not_allowed"),loop_to_end_not_allowed:a("editor.toolbar.loop_to_end_not_allowed"),initial_activity_to_end_not_allowed:a("editor.toolbar.initial_activity_to_end_not_allowed"),final_activity_cannot_connect:a("editor.toolbar.final_activity_cannot_connect"),activity_has_outgoing_connections:a("editor.toolbar.activity_has_outgoing_connections"),task_limit_reached:a("editor.toolbar.task_limit_reached"),start_event_to_service_task_not_allowed:a("editor.toolbar.start_event_to_service_task_not_allowed"),service_task_to_end_not_allowed:a("editor.toolbar.service_task_to_end_not_allowed")},ce=$.shouldDisable&&$.reason?ne[$.reason]||a(z.label):a(z.label)||"";return(0,Ee.jsxs)(Ct.Tooltip,{children:[(0,Ee.jsx)(Ct.TooltipTrigger,{asChild:!0,children:(0,Ee.jsx)(Ct.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!$.shouldDisable,disabled:$.shouldDisable,className:$.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:$.shouldDisable?void 0:oe=>D(oe,z),onDragEnd:$.shouldDisable?void 0:O,children:z.icon&&(0,Ee.jsx)(z.icon,{size:16})})}),(0,Ee.jsx)(Ct.TooltipContent,{color:"black",children:ce})]},W)})}),(0,Ee.jsx)("div",{ref:i,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:_})]})});Ye.displayName="NodeToolbar";var Fo=require("react/jsx-runtime"),yu=({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let{updateNodeData:a,setNodes:s}=(0,hu.useReactFlow)(),{mode:l,isReadOnly:c}=Y(),d=(0,ji.useCallback)(f=>{let g=f.split(`
|
|
40
|
+
`),y=g.reduce((b,w)=>Math.max(b,w.length),0),v=g.length,_=Math.max(ko.MIN_WIDTH,y*7+32),N=Math.max(ko.MIN_HEIGHT,v*20+24);s(b=>b.map(w=>{var S;if(w.id===e){let M=Math.max((S=w.height)!=null?S:ko.MIN_HEIGHT,N);return I(T({},w),{width:_,height:M,style:I(T({},w.style),{width:_,height:M})})}return w}))},[e,s]),u=(0,ji.useCallback)(f=>{a(e,{label:f}),d(f)},[e,a,d]),p=(0,ji.useCallback)(f=>{d(f)},[d]);return(0,Fo.jsxs)("div",{className:F("relative w-full h-full 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":r&&!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}),style:{width:o,height:n},children:[(0,Fo.jsx)(Re,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:u,onInput:p,skipFirstCharValidation:!0}),(0,Fo.jsx)(Ye,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&(0,Fo.jsx)(st,{nodeId:e,minWidth:ko.MIN_WIDTH,minHeight:ko.MIN_HEIGHT,isVisible:!i&&r}),(0,Fo.jsx)(it,{nodeId:e,nodeType:"ANNOTATION",targetHandleClassName:"annotation-handle"})]})};var xu=require("@xyflow/react"),Eu=require("react");var Kt=require("react/jsx-runtime"),_u=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=(0,xu.useReactFlow)(),{mode:i,isReadOnly:a}=Y(),[s,l]=(0,Eu.useState)(!1),c=p=>{r(e,{label:p})},d=()=>{l(!0)},u=()=>{l(!1)};return(0,Kt.jsxs)("div",{className:"relative",onDoubleClick:d,children:[(0,Kt.jsx)(nn,{className:F("w-full h-full hover:stroke-[#d33b3b] transition-colors duration-75",{"pointer-events-none":a,"stroke-blue-500 hover:stroke-blue-600":o&&!a,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),(0,Kt.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,Kt.jsx)(Re,{value:t.label,isEditing:s,onBlur:u,onChange:c})}),(0,Kt.jsx)(Ye,{nodeId:e,nodeType:"END_EVENT"}),i==="edit"&&(0,Kt.jsx)(st,{nodeId:e,isVisible:!n&&o,minWidth:zi.MIN_WIDTH,minHeight:zi.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(0,Kt.jsx)(it,{nodeId:e,nodeType:"END_EVENT",targetHandleClassName:"event-handle"})]})};var bu=require("@xyflow/react"),Pn=require("react");var qt=require("react/jsx-runtime"),ga=(0,Pn.memo)(({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let a=Ls[t.variant].icon,{updateNodeData:s}=(0,bu.useReactFlow)(),{mode:l,isReadOnly:c}=Y(),[d,u]=(0,Pn.useState)(!1),p=(0,Pn.useCallback)(E=>{s(e,{label:E})},[e,s]),f=()=>{u(!0)},x=()=>{u(!1)};return(0,qt.jsxs)("div",{className:"relative",style:{width:o!=null?o:bn.MIN_WIDTH,height:n!=null?n:bn.MIN_HEIGHT},onDoubleClick:f,children:[(0,qt.jsx)(a,{className:F("w-full h-full stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"pointer-events-none":c,"stroke-blue-500 hover:stroke-blue-600":r&&!c,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),(0,qt.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,qt.jsx)(Re,{value:t.label,isEditing:d,onBlur:x,onChange:p})}),(0,qt.jsx)(Ye,{nodeId:e,nodeType:"GATEWAY",nodeVariant:t.variant}),l==="edit"&&(0,qt.jsx)(st,{nodeId:e,isVisible:!i&&r,minWidth:bn.MIN_WIDTH,minHeight:bn.MIN_HEIGHT,offset:2,keepAspectRatio:!0}),(0,qt.jsx)(it,{nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant,targetHandleClassName:"gateway-handle",conditionalSource:!0})]})});ga.displayName="Gateway";var Tu=require("@xyflow/react"),gt=require("@produto-lecom/lecom-ui"),wy=require("lucide-react");var vu=require("react/jsx-runtime");var Nu=require("@xyflow/react"),wu=require("react");var Zt=require("react/jsx-runtime"),Iu=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=(0,Nu.useReactFlow)(),{mode:i,isReadOnly:a}=Y(),[s,l]=(0,wu.useState)(!1),c=p=>{r(e,{label:p})},d=()=>{l(!0)},u=()=>{l(!1)};return(0,Zt.jsxs)("div",{className:"relative",onDoubleClick:d,children:[(0,Zt.jsx)(Zr,{className:F("w-full h-full hover:stroke-[#54890b] transition-colors duration-75",{"pointer-events-none":a,"stroke-blue-500 hover:stroke-blue-600":o&&!a,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),(0,Zt.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,Zt.jsx)(Re,{value:t.label,isEditing:s,onBlur:u,onChange:c})}),(0,Zt.jsx)(Ye,{nodeId:e,nodeType:"START_EVENT"}),i==="edit"&&(0,Zt.jsx)(st,{nodeId:e,isVisible:!n&&o,minWidth:Bi.MIN_WIDTH,minHeight:Bi.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(0,Zt.jsx)(it,{nodeId:e,nodeType:"START_EVENT",targetHandleClassName:"event-handle",conditionalSource:!0})]})};var Mu=require("@produto-lecom/lecom-ui"),Pu=require("@xyflow/react"),Yo=require("react");var yr=60,es=(e,t)=>{var a;let o=[],n=`${t} `;for(let s of e){if(!(s.type==="TASK"))continue;let c=(a=s.data)==null?void 0:a.label;if(c&&c.startsWith(n)){let d=c.substring(n.length);/^\d{1,15}$/.test(d)&&o.push(parseInt(d,10))}}let r=o.length>0?Math.max(...o)+1:1,i=`${t} ${r}`;return i.length<=yr?i:i.substring(0,yr).trim()},Ln=(e,t)=>{var s;let o=new Set;for(let l of t)l.type==="TASK"&&((s=l.data)!=null&&s.label)&&o.add(l.data.label);let n=e;if(n.length>yr&&(n=n.substring(0,yr).trim()),!o.has(n))return n;let r=n.replace(/\s+\(\d+\)$/,""),i=2,a=o.size+2;for(;i<=a;){let l=` (${i})`,c=yr-l.length,u=`${r.substring(0,c).trim()}${l}`;if(!o.has(u))return u;i++}return n};var xr=require("react/jsx-runtime"),Au=e=>(0,xr.jsxs)("svg",I(T({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[(0,xr.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),(0,xr.jsx)("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));var ha=require("react/jsx-runtime"),Cu=e=>(0,ha.jsx)("svg",I(T({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:(0,ha.jsx)("path",{d:"M12 2C8.13 2 5 5.13 5 9C5 14.25 12 22 12 22C12 22 19 14.25 19 9C19 5.13 15.87 2 12 2ZM12 11.5C10.62 11.5 9.5 10.38 9.5 9C9.5 7.62 10.62 6.5 12 6.5C13.38 6.5 14.5 7.62 14.5 9C14.5 10.38 13.38 11.5 12 11.5Z",fill:"#38bdf8"})}));var Er=require("react/jsx-runtime"),Su=e=>(0,Er.jsxs)("svg",I(T({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[(0,Er.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),(0,Er.jsx)("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));var _e=require("react/jsx-runtime"),Iy={APROVADO:Au,EM_ANDAMENTO:Cu,REJEITADO:Su},ya={APROVADO:"border-green-500 hover:border-green-500 border-[3px] border-solid",EM_ANDAMENTO:"border-turquoise-400 hover:border-turquoise-400 border-[3px] border-solid",REJEITADO:"border-red-500 hover:border-red-500 border-[3px] border-solid",default:"border-grey-400 border-2 border-solid",error:"border-red-500 border-[3px] shadow-[0_0_5px_rgba(255,0,0,0.5)]"},Ay={APROVADO:"bg-green-50",EM_ANDAMENTO:"bg-turquoise-50",REJEITADO:"bg-red-50"},xa=(0,Yo.memo)(({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let{t:a}=(0,Mu.useTranslation)(),{toast:s}=Oe(),{updateNodeData:l,getNodes:c,setNodes:d}=(0,Pu.useReactFlow)(),{mode:u,isReadOnly:p,onSubprocessValidationClick:f}=Y(),{getTaskStatus:x}=Ao(),E=x(e),m=t.variant==="SUBPROCESS",h=t.variant==="SERVICE_TASK",g=!!t.variant&&!m&&!h||!!E,y=!!t.attribute||m||h,v=(0,Yo.useCallback)(R=>{let A=g||y?80:40,C=R.split(`
|
|
41
|
+
`),k=C.reduce((U,H)=>Math.max(U,H.length),0),P=C.length,K=Math.max(Yt.MIN_WIDTH,k*7+64),Z=Math.max(Yt.MIN_HEIGHT,P*24+A);d(U=>U.map(H=>{var q;if(H.id===e){let z=Math.max((q=H.height)!=null?q:Yt.MIN_HEIGHT,Z);return I(T({},H),{width:K,height:z,style:I(T({},H.style),{width:K,height:z})})}return H}))},[e,d,g,y]),_=(0,Yo.useCallback)(R=>{let V=R.trim(),G=t.label||"";if(V===G)return;let B=V,A=c();if(!(V&&V!=="")){B=es(A,a("bpmn.task.label.prefix")),l(e,{label:B}),v(B),s({variant:"warning",content:(0,_e.jsxs)(_e.Fragment,{children:[a("bpmn.task.feedback.label_empty.prefix")," ",(0,_e.jsx)("strong",{children:B})]})});return}let k=Ln(B,A);k===G||(l(e,{label:k}),v(k),k!==B&&s({variant:"warning",content:(0,_e.jsxs)(_e.Fragment,{children:[a("bpmn.task.feedback.label_already_exists.prefix")," ",(0,_e.jsx)("strong",{children:V})," ",a("bpmn.task.feedback.label_already_exists.middle")," ",(0,_e.jsx)("strong",{children:k})]})}))},[t.label,c,e,a,l,v,s]),N=(0,Yo.useCallback)(R=>{v(R)},[v]),b=(0,Yo.useCallback)(()=>{s({variant:"error",content:a("bpmn.task.feedback.invalid_first_character")})},[a,s]),w=E?Iy[E]:null,S=t.variant?Jr[t.variant].icon:null,M=t.attribute?Qr[t.attribute].icon:null,L=()=>t.hasError?ya.error:E?ya[E]:p?ya.default:"",D=()=>{var R;return r&&(R=Ay[E])!=null?R:""},O=()=>{f==null||f({id:e,type:"sub_process",label:t.label})};return(0,_e.jsxs)("div",{className:F("relative w-full h-full 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",L(),{"cursor-pointer":p,"border-blue-500 hover:border-blue-600 shadow-md":r&&!p&&!E,"border-red-500 hover:border-red-600 shadow-[0_0_5px_rgba(255,0,0,0.5)]":t.hasError}),style:{width:o!=null?o:Yt.MIN_WIDTH,height:n!=null?n:Yt.MIN_HEIGHT},children:[(0,_e.jsx)("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:(0,_e.jsx)(Re,{value:t.label,maxLength:60,className:F("bg-white/10",D(),{"py-10 px-8":g||y}),onChange:_,onInput:N,onInvalidFirstCharacter:b})}),S&&(0,_e.jsx)("div",{className:F("absolute flex items-center p-1",m||h?"bottom-0 left-1/2 -translate-x-1/2":"top-0 left-0"),children:(0,_e.jsx)(S,{size:h?20:16,className:F(t.hasError?"text-red-500":"text-grey-500",m&&"cursor-pointer"),onClick:m?O:void 0})}),M&&(0,_e.jsx)("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:(0,_e.jsx)("div",{className:F("flex items-center w-16 p-1",m||h?"justify-between":"justify-center"),children:(0,_e.jsx)(M,{size:16,className:F(t.hasError?"text-red-500":"text-grey-500")})})}),w&&(0,_e.jsx)("div",{className:"absolute top-0 right-0 flex items-center p-1",children:(0,_e.jsx)(w,{})}),(0,_e.jsx)(Ye,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),u==="edit"&&(0,_e.jsx)(st,{nodeId:e,isVisible:!i&&r,minWidth:Yt.MIN_WIDTH,minHeight:Yt.MIN_HEIGHT}),(0,_e.jsx)(it,{nodeId:e,nodeType:"TASK",targetHandleClassName:"task-handle",conditionalSource:!0})]})});xa.displayName="Task";var Lu=require("@xyflow/react"),Du=require("lodash"),Wo=require("react");var Je=require("react/jsx-runtime"),Ea=(0,Wo.memo)(({id:e,data:t,selected:o,dragging:n,parentId:r,width:i,height:a})=>{var N;let{updateNodeData:s,getNodes:l}=(0,Lu.useReactFlow)(),{mode:c,isReadOnly:d}=Y(),[u,p]=(0,Wo.useState)(!1),f=l(),x=!r,E=!x&&((N=f.find(b=>b.id===r))==null?void 0:N.selected),m=(0,Wo.useMemo)(()=>(0,Du.orderBy)(f.filter(b=>b.parentId===e&&b.type==="LANE"),"position.y","asc"),[f,e]),h=x?bd.MIN_WIDTH:J.MIN_WIDTH,g=(0,Wo.useMemo)(()=>{if(x&&m.length>1){let b=[...m];return b.pop(),b.reduce((S,M)=>{var L,D;return S+((D=(L=M.measured)==null?void 0:L.height)!=null?D:0)},0)+J.MIN_HEIGHT}return J.MIN_HEIGHT},[x,m]),y=b=>{s(e,{label:b})},v=()=>{p(!0)},_=()=>{p(!1)};return(0,Je.jsxs)(Je.Fragment,{children:[(0,Je.jsxs)("div",{className:F("flex h-full w-full hover:shadow-md outline outline-2 outline-grey-400",{"pointer-events-none":d,"outline-offset-0 outline-blue-500 shadow-sm":(o||E)&&!d}),style:{width:i!=null?i:J.MIN_WIDTH,height:a!=null?a:J.MIN_HEIGHT},children:[(0,Je.jsx)("div",{className:F("flex align-items justify-center w-10 border-r-2 border-grey-400 bg-white",{"border-blue-500":(o||E)&&!d}),onDoubleClick:v,children:(0,Je.jsx)("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:(0,Je.jsx)(Re,{value:t.label,className:"w-full h-full self-auto",contentClassName:F({"whitespace-nowrap":u}),isEditing:u,onBlur:_,onChange:y})})}),(0,Je.jsx)("div",{className:F("flex-1",{"bg-white":!r||n})})]}),(0,Je.jsx)(Ye,{nodeId:e,nodeType:"LANE",isChild:!x}),c==="edit"&&(0,Je.jsx)(st,{nodeId:e,isVisible:!n&&o,minWidth:h,minHeight:g,offset:10}),(0,Je.jsx)(it,{nodeId:e,nodeType:"LANE",targetHandleClassName:"annotation-handle"})]})});Ea.displayName="Lane";var _a=require("@xyflow/react");var Jt=require("react/jsx-runtime"),ku=({id:e,data:t})=>(0,Jt.jsxs)(Jt.Fragment,{children:[(0,Jt.jsx)("div",{className:"relative w-full h-full flex items-center justify-center bg-white border-2 border-red-400 rounded-sm overflow-hidden",children:t.label}),(0,Jt.jsx)(Ye,{nodeId:e,nodeType:"UNSUPPORTED"}),(0,Jt.jsx)(An,{type:"source",position:_a.Position.Right}),(0,Jt.jsx)(An,{type:"target",position:_a.Position.Left})]});var Vn=require("@xyflow/react"),Hn=Xn(require("react"),1);var ve=require("react"),ts=require("@xyflow/react");var Cy=50,Ru=.1,Sy=.6,os=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:a,getNodes:s,screenToFlowPosition:l}=(0,ts.useReactFlow)(),{setIsDragging:c,setReconnectingEdgeId:d}=Y(),u=(0,ts.useStore)(G=>G.isValidConnection),[p,f]=(0,ve.useState)(null),[x,E]=(0,ve.useState)(null),[m,h]=(0,ve.useState)(null),[g,y]=(0,ve.useState)(null),[v,_]=(0,ve.useState)(!1),N=(0,ve.useRef)(null),b=(0,ve.useRef)(null),w=(0,ve.useRef)(t),S=(0,ve.useRef)(o);(0,ve.useEffect)(()=>{w.current=t,S.current=o},[t,o]),(0,ve.useEffect)(()=>{N.current=p},[p]);let M=(0,ve.useCallback)(G=>No(G,s()),[s]),L=(0,ve.useCallback)(G=>{var P,K,Z,U,H,q;let B=s(),A=null,C=Cy,k=B.filter(z=>z.type!=="LANE"&&z.type!=="ANNOTATION");for(let z of k){if(z.id===e)continue;let W=M(z.id),X=(Z=(K=(P=z.measured)==null?void 0:P.width)!=null?K:z.width)!=null?Z:0,$=(q=(H=(U=z.measured)==null?void 0:U.height)!=null?H:z.height)!=null?q:0;if(G.x>=W.x&&G.x<=W.x+X&&G.y>=W.y&&G.y<=W.y+$)return z.id;let ce=Math.max(W.x-G.x,0,G.x-(W.x+X)),oe=Math.max(W.y-G.y,0,G.y-(W.y+$)),re=Math.sqrt(ce*ce+oe*oe);re<C&&(C=re,A=z.id)}return A},[s,M,e]),D=(0,ve.useCallback)((G,B)=>{var ce,oe,re,Ae,ae,Se;let A=a(G);if(!A)return null;let C=M(G),k=(re=(oe=(ce=A.measured)==null?void 0:ce.width)!=null?oe:A.width)!=null?re:0,P=(Se=(ae=(Ae=A.measured)==null?void 0:Ae.height)!=null?ae:A.height)!=null?Se:0,K=Math.abs(C.x+k-B.x),Z=Math.abs(B.x-C.x),U=Math.abs(C.y+P-B.y),H=Math.abs(B.y-C.y),q={right:K,left:Z,bottom:U,top:H},z=Object.entries(q).reduce((j,[de,ke])=>ke<j[1]?[de,ke]:j,["right",q.right])[0],W=b.current;if(W&&W!==z){let j=q[z],de=q[W],ke=Math.abs(de-j),ut=Math.min(Math.abs(de),Math.abs(j));ke<ut*Sy&&(z=W)}let X=z,$,ne;if(X==="right"||X==="left"){let de=(Math.max(C.y,Math.min(C.y+P,B.y))-C.y)/(P||1);Math.abs(de-.5)<Ru&&(de=.5),ne=de,$={x:X==="right"?C.x+k:C.x,y:C.y+ne*P}}else{let de=(Math.max(C.x,Math.min(C.x+k,B.x))-C.x)/(k||1);Math.abs(de-.5)<Ru&&(de=.5),ne=de,$={x:C.x+ne*k,y:X==="bottom"?C.y+P:C.y}}return{side:X,snapPosition:$,offset:ne}},[a,M]),O=(0,ve.useCallback)(G=>{var K;let B=N.current;if(!B)return;let A=l({x:G.clientX,y:G.clientY}),C=L(A);h(C);let k=A,P=null;if(C){let Z=D(C,A);Z&&(P=Z.side,k=Z.snapPosition,b.current=P);let U={source:B==="source"?C:w.current,target:B==="target"?C:S.current,sourceHandle:null,targetHandle:null},H=(K=u==null?void 0:u(U))!=null?K:!0;_(H)}else b.current=null,_(!1);y(P),E(k)},[L,D,l,u]),R=(0,ve.useCallback)(G=>{var P;let B=N.current;if(!B)return;let A=l({x:G.clientX,y:G.clientY}),C=L(A);if(C){let K={source:B==="source"?C:w.current,target:B==="target"?C:S.current,sourceHandle:null,targetHandle:null};((P=u==null?void 0:u(K))==null||P)&&i(Z=>Z.map(U=>U.id===e?I(T({},U),{source:K.source,target:K.target,sourceHandle:void 0,targetHandle:void 0,data:I(T({},U.data),{controlPoint:void 0})}):U))}f(null),E(null),h(null),y(null),c(!1),_(!1),d(null),b.current=null,document.removeEventListener("mouseup",R),document.removeEventListener("mousemove",O);let k=St.get(n);k==null||k.clearReconnectingEdge()},[e,L,i,n,O,u,l,c,d]),V=(0,ve.useCallback)((G,B)=>{if(r||B.button!==0)return;B.stopPropagation(),B.preventDefault(),f(G),d(e);let A=St.get(n);A==null||A.setReconnectingEdge(e),document.addEventListener("mousemove",O),document.addEventListener("mouseup",R)},[r,e,n,O,R,d]);return(0,ve.useEffect)(()=>()=>{if(N.current){document.removeEventListener("mousemove",O),document.removeEventListener("mouseup",R),d(null);let G=St.get(n);G==null||G.clearReconnectingEdge()}},[n,O,R,d]),{reconnectingHandle:p,cursorPosition:x,hoveredNodeId:m,reconnectingSide:g,isValidReconnection:v,handleReconnectStart:V}};var Hu=require("@xyflow/react"),is=require("react");var po={TOLERANCE:1,MAX_LABEL_DISTANCE:80,BEND_HANDLE_HIT_RADIUS:24};var My=require("@xyflow/react");var _r=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,ns=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),ba=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),Py=(e,t,o)=>{let n=o.x-t.x,r=o.y-t.y,i=n*n+r*r;if(i===0)return ns(e,t);let a=Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*r)/i));return ns(e,{x:t.x+a*n,y:t.y+a*r})},rs=(e,t)=>{let o=1/0;for(let n=0;n<t.length-1;n++)o=Math.min(o,Py(e,t[n],t[n+1]));return o},Ou=e=>{let t=0;for(let r=0;r<e.length-1;r++)t+=ns(e[r],e[r+1]);let o=t/2,n=0;for(let r=0;r<e.length-1;r++){let i=ns(e[r],e[r+1]);if(n+i>=o){let a=i===0?0:(o-n)/i,s=e[r],l=e[r+1];return{x:s.x+(l.x-s.x)*a,y:s.y+(l.y-s.y)*a}}n+=i}return ba(e[0],e.at(-1))};var{MAX_LABEL_DISTANCE:Ly}=po,Vu=3;function Gu({edgeId:e,isEditing:t,isViewOrReadOnly:o,zoom:n,label:r,labelOffset:i,pathPoints:a,pathCenter:s}){let{updateEdgeData:l}=(0,Hu.useReactFlow)(),c=(0,is.useRef)(i);return(0,is.useCallback)(d=>{var v,_;if(t||o||d.button!==0||!(r!=null&&r.trim()))return;d.stopPropagation(),d.preventDefault();let u=d.clientX,p=d.clientY,f=(v=i==null?void 0:i.x)!=null?v:0,x=(_=i==null?void 0:i.y)!=null?_:0,E=[...a],m={x:s.x,y:s.y},h=!1,g=N=>{let b=(N.clientX-u)/n,w=(N.clientY-p)/n;if(!h&&Math.abs(b)<Vu&&Math.abs(w)<Vu)return;h=!0;let S={x:f+b,y:x+w};c.current=S,l(e,{labelOffset:S})},y=()=>{document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",y);let N=c.current;if(!N)return;let b={x:m.x+N.x,y:m.y+N.y};rs(b,E)>Ly&&(c.current=void 0,l(e,{labelOffset:void 0}))};document.addEventListener("mousemove",g),document.addEventListener("mouseup",y)},[t,o,n,r,i,e,l,a,s])}var br=require("@xyflow/react"),Xo=require("react");var{TOLERANCE:ss}=po,Bu=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Dy(e,t,o){return _r(e,t,"x",ss)&&_r(t,o,"x",ss)||_r(e,t,"y",ss)&&_r(t,o,"y",ss)}function ky(e,t,o,n){if(Dy(e,t,o))return`L${t.x} ${t.y}`;let r=Bu(e,t),i=Bu(t,o),a=Math.min(r/2,i/2,n);if(a<1)return`L${t.x} ${t.y}`;let s=e.x-t.x,l=e.y-t.y,c=o.x-t.x,d=o.y-t.y,u={x:s/r,y:l/r},p={x:c/i,y:d/i},f={x:t.x+u.x*a,y:t.y+u.y*a},x={x:t.x+p.x*a,y:t.y+p.y*a},E=-u.x,m=-u.y,h=p.x,g=p.y,v=E*g-m*h>0?1:0;return`L${f.x} ${f.y}A${a} ${a} 0 0 ${v} ${x.x} ${x.y}`}var as=(e,t=5)=>e.length<2?"":e.reduce((o,n,r)=>{let i="";return r>0&&r<e.length-1?i=ky(e[r-1],n,e[r+1],t):i=`${r===0?"M":"L"}${n.x} ${n.y}`,o+=i,o},"");var zu=({id:e,source:t,target:o,controlPoint:n,fixedSourcePoint:r,fixedTargetPoint:i})=>{let a=(0,br.useInternalNode)(t),s=(0,br.useInternalNode)(o),{updateEdgeData:l,screenToFlowPosition:c}=(0,br.useReactFlow)(),{mode:d}=Y(),[u,p]=(0,Xo.useState)(!1),f=(0,Xo.useCallback)(E=>{if(d!=="edit"||E.button!==0)return;E.stopPropagation(),E.preventDefault(),p(!0);let m=g=>{let y=c({x:g.clientX,y:g.clientY});l(e,{controlPoint:{x:Math.round(y.x),y:Math.round(y.y)}})},h=()=>{p(!1),document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",h)};document.addEventListener("mousemove",m),document.addEventListener("mouseup",h)},[d,c,e,l]),x=(0,Xo.useMemo)(()=>{if(!a||!s)return null;let E=Xt({source:Ht(a),target:Ht(s),controlPoint:n,fixedSourcePoint:r,fixedTargetPoint:i}),{points:m}=E,h=m[1],g=m.at(-2);return{sourceNode:a,targetNode:s,points:m,svgPath:as(m),sourcePoint:E.sourcePoint,targetPoint:E.targetPoint,direction:E.direction,bendPoint:ba(h,g),pathCenter:Ou(m)}},[a,s,n,r,i]);return(0,Xo.useMemo)(()=>x?I(T({},x),{isDraggingBend:u,onBendDragStart:f}):null,[x,u,f])};var Dn=require("react/jsx-runtime"),{BEND_HANDLE_HIT_RADIUS:Ry}=po,Fu=({bendPoint:e,zoom:t,isDragging:o,onMouseDown:n})=>(0,Dn.jsxs)("g",{className:"pointer-events-auto cursor-move",onMouseDown:n,children:[(0,Dn.jsx)("circle",{cx:e.x,cy:e.y,r:Ry/t,fill:"transparent"}),(0,Dn.jsx)("circle",{cx:e.x,cy:e.y,r:4/t,fill:o?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/t,className:"pointer-events-none"}),(0,Dn.jsx)("circle",{cx:e.x,cy:e.y,r:6/t,fill:"none",stroke:"#3b82f6",strokeWidth:1/t,opacity:o?.6:.3,className:"pointer-events-none"})]});var kn=require("react/jsx-runtime"),Rn=i=>{var a=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=a,r=bt(a,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:s}=Y(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d,isToEndEvent:u}=ti(o,n),p=!l&&!c&&!d&&!u,f=[{component:(0,kn.jsx)(Qi,{elementId:e,elementType:"edge"})}],x=()=>s==="view"?p?[{component:(0,kn.jsx)(uo,{elementId:e,elementType:"edge"})}]:[]:p?[{component:(0,kn.jsx)(uo,{elementId:e,elementType:"edge"})},...f]:f,m=(h=>{switch(h){case"SEQUENCE_EDGE":return x();case"MESSAGE_EDGE":return s==="view"?[]:[...f];case"ANNOTATION_EDGE":return s==="view"?[]:[...f];default:return[]}})(t);if(!(m.length===0||s==="readonly"))return(0,kn.jsx)("div",I(T({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:m.map((h,g)=>(0,kn.jsx)("div",{children:h.component},g))}))};var Yu=require("@xyflow/react"),Wu=require("react");var Ta=require("react/jsx-runtime"),Mt=12,On=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:a}=(0,Yu.useViewport)(),s=1/a,l=(0,Wu.useMemo)(()=>t===n?{bottom:`${Mt}px`,transform:"translateX(-50%)"}:e===o?{left:`${Mt}px`,transform:r?"translateY(-100%)":"translateY(-50%)"}:n>t&&o>e?{left:`${Mt}px`,bottom:`${Mt}px`}:n>t&&o<e?{right:`${Mt}px`,bottom:`${Mt}px`}:t>n&&o>e?{right:`${Mt}px`,bottom:`${Mt}px`}:{left:`${Mt}px`,bottom:`${Mt}px`},[e,t,o,n,r]);return(0,Ta.jsx)("div",{style:{transform:`scale(${s})`},children:(0,Ta.jsx)("div",{className:"absolute pointer-events-auto",style:T({},l),children:i})})};var Uo=require("react/jsx-runtime"),va=({x:e,y:t,zoom:o,handleType:n,reconnectingHandle:r,hoveredNodeId:i,isValidReconnection:a,onMouseDown:s})=>{let l=r===n,c=l?i&&!a?"cursor-not-allowed":"cursor-grabbing":"cursor-move";return(0,Uo.jsx)("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${e}px, ${t}px)`},children:(0,Uo.jsxs)("svg",{width:12/o,height:12/o,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,Uo.jsx)("circle",{cx:6/o,cy:6/o,r:4/o,fill:l?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/o,className:"pointer-events-none"}),(0,Uo.jsx)("circle",{cx:6/o,cy:6/o,r:6/o,fill:"none",stroke:"#3b82f6",strokeWidth:1/o,opacity:l?.6:.3,className:"pointer-events-none"}),(0,Uo.jsx)("circle",{cx:6/o,cy:6/o,r:8/o,fill:"transparent",className:F("pointer-events-auto",c),onMouseDown:s})]})})};var Xu=require("@xyflow/react");var Na=require("react/jsx-runtime"),Uu=({edgeId:e,label:t,labelOffset:o,pathCenter:n,isEditing:r,isViewOrReadOnly:i,onSetEditing:a,onLabelDragStart:s})=>{var d,u;let{updateEdgeData:l}=(0,Xu.useReactFlow)(),c=!r&&!i&&!!(t!=null&&t.trim());return!r&&!(t!=null&&t.trim())?null:(0,Na.jsx)("div",{className:F("absolute nodrag nopan",c?"z-[10001] pointer-events-auto":"z-[3000] pointer-events-none"),style:{transform:`translate(-50%, -50%) translate(${n.x+((d=o==null?void 0:o.x)!=null?d:0)}px, ${n.y+((u=o==null?void 0:o.y)!=null?u:0)}px)`,cursor:c?"move":void 0},onMouseDown:c?s:void 0,onDoubleClick:p=>{i||(p.stopPropagation(),a(!0))},children:(0,Na.jsx)(Re,{value:t,className:F("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":r,"pointer-events-none":!r}),isEditing:r,onBlur:()=>a(!1),onChange:p=>l(e,{label:p.trim()})})})};var Le=require("react/jsx-runtime"),Oy={x:0,y:0};function Vy(e,t,o,n,r){return F("stroke-2 stroke-current transition-[stroke] duration-75",{"group-hover:stroke-[2.5px]":!e,"stroke-red-500 hover:stroke-red-600":o||n,"stroke-green-500":r,"stroke-blue-500 hover:stroke-blue-600 stroke-[3px]":t&&!o})}var wa=Hn.default.memo(({id:e,source:t,target:o,data:n,selected:r})=>{var A,C;let{zoom:i}=(0,Vn.useViewport)(),{isReadOnly:a,mode:s,instanceId:l,edgeHighlight:c}=Y(),d=Nt(),[u,p]=(0,Hn.useState)(!1),f=s!=="edit",{reconnectingHandle:x,cursorPosition:E,hoveredNodeId:m,isValidReconnection:h,handleReconnectStart:g}=os({edgeId:e,source:t,target:o,instanceId:l,isReadOnly:f}),y=zu({id:e,source:t,target:o,controlPoint:n==null?void 0:n.controlPoint,fixedSourcePoint:x==="source"?E:void 0,fixedTargetPoint:x==="target"?E:void 0}),v=(0,Hn.useMemo)(()=>{var k;return(k=y==null?void 0:y.points)!=null?k:[]},[y]),_=(A=y==null?void 0:y.pathCenter)!=null?A:Oy,N=Gu({edgeId:e,isEditing:u,isViewOrReadOnly:f,zoom:i,label:n==null?void 0:n.label,labelOffset:n==null?void 0:n.labelOffset,pathPoints:v,pathCenter:_});if(!y)return null;let{sourceNode:b,targetNode:w,svgPath:S,sourcePoint:M,targetPoint:L}=y,D=c&&(r||b.selected||w.selected),O=r&&!d&&!f,R=!!((C=n==null?void 0:n.label)!=null&&C.trim()),V=!u&&!f&&R,G=!!x&&!!m&&!h,B=!!x&&!!m&&h;return(0,Le.jsxs)(Le.Fragment,{children:[(0,Le.jsxs)("g",{className:F("group bpmn-arrow-edge",{"is-highlighted":D}),onDoubleClick:()=>!f&&p(!0),children:[(0,Le.jsx)("path",{d:S,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/i),className:F({"nopan nodrag":V}),style:{pointerEvents:"stroke",cursor:V?"move":"pointer"},onMouseDown:N}),(0,Le.jsxs)("g",{className:F("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!a,"text-blue-500 group-hover:text-blue-600":D}),children:[(0,Le.jsx)(Vn.BaseEdge,{id:e,path:S,interactionWidth:0,markerEnd:`url(#${D?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:Vy(a,!!D,n==null?void 0:n.hasError,G,B)}),O&&!x&&(0,Le.jsx)(Fu,{bendPoint:y.bendPoint,zoom:i,isDragging:y.isDraggingBend,onMouseDown:y.onBendDragStart})]})]}),(0,Le.jsxs)(Vn.EdgeLabelRenderer,{children:[(0,Le.jsx)("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${_.x}px, ${_.y}px)`},children:r&&!d&&(0,Le.jsx)(On,{sx:M.x,sy:M.y,tx:L.x,ty:L.y,hasLabel:R,children:(0,Le.jsx)(Rn,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:b,targetNode:w})})}),(0,Le.jsx)(Uu,{edgeId:e,label:n==null?void 0:n.label,labelOffset:n==null?void 0:n.labelOffset,pathCenter:_,isEditing:u,isViewOrReadOnly:f,onSetEditing:p,onLabelDragStart:N}),O&&(0,Le.jsxs)(Le.Fragment,{children:[(0,Le.jsx)(va,{x:M.x,y:M.y,zoom:i,handleType:"source",reconnectingHandle:x,hoveredNodeId:m,isValidReconnection:h,onMouseDown:k=>g("source",k.nativeEvent)}),(0,Le.jsx)(va,{x:L.x,y:L.y,zoom:i,handleType:"target",reconnectingHandle:x,hoveredNodeId:m,isValidReconnection:h,onMouseDown:k=>g("target",k.nativeEvent)})]})]})]})});wa.displayName="SequenceEdge";var Ne=require("@xyflow/react"),ls=require("react");var ye=require("react/jsx-runtime"),LC={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:Ne.MarkerType.Arrow},data:{label:""}},$u=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var Z;let{zoom:c}=(0,Ne.useViewport)(),{updateEdgeData:d}=(0,Ne.useReactFlow)(),{mode:u,instanceId:p}=Y(),f=Nt(),x=u!=="edit",[E,m]=(0,ls.useState)(!1),{reconnectingHandle:h,cursorPosition:g,hoveredNodeId:y,reconnectingSide:v,isValidReconnection:_,handleReconnectStart:N}=os({edgeId:e,source:t,target:o,instanceId:p,isReadOnly:x}),b=(0,Ne.useInternalNode)(t),w=(0,Ne.useInternalNode)(o),{sx:S,sy:M,tx:L,ty:D,sourcePos:O,targetPos:R}=(0,ls.useMemo)(()=>{var re,Ae;if(!b||!w)return{sx:0,sy:0,tx:0,ty:0,sourcePos:Ne.Position.Left,targetPos:Ne.Position.Right};let U=ei(b,w),H=s?i:U.sourcePos,q=l?a:U.targetPos,z=(ae,Se,j)=>{var Vr,Hr,Gr,Br,ws,Is;let{x:de,y:ke}=ae.internals.positionAbsolute,ut=(Gr=(Hr=(Vr=ae.measured)==null?void 0:Vr.width)!=null?Hr:ae.width)!=null?Gr:0,bo=(Is=(ws=(Br=ae.measured)==null?void 0:Br.height)!=null?ws:ae.height)!=null?Is:0;switch(Se){case Ne.Position.Top:return{x:de+ut*j,y:ke};case Ne.Position.Bottom:return{x:de+ut*j,y:ke+bo};case Ne.Position.Left:return{x:de,y:ke+bo*j};case Ne.Position.Right:return{x:de+ut,y:ke+bo*j};default:return{x:de+ut/2,y:ke+bo/2}}},W=(re=n==null?void 0:n.sourceOffset)!=null?re:.5,X=(Ae=n==null?void 0:n.targetOffset)!=null?Ae:.5,$=b?z(b,H,W).x:U.sx,ne=b?z(b,H,W).y:U.sy,ce=w?z(w,q,X).x:U.tx,oe=w?z(w,q,X).y:U.ty;return h==="source"&&g?($=g.x,ne=g.y,v&&(H=v)):h==="target"&&g&&(ce=g.x,oe=g.y,v&&(q=v)),{sx:$,sy:ne,tx:ce,ty:oe,sourcePos:H,targetPos:q}},[b,w,s,l,i,a,h,g,v,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!b||!w)return null;let[V,G,B]=(0,Ne.getSmoothStepPath)({sourceX:S,sourceY:M,targetX:L,targetY:D,sourcePosition:O,targetPosition:R}),A=r||(b==null?void 0:b.selected)||(w==null?void 0:w.selected),C=A?"sequence-edge-marker-highlighted":"sequence-edge-marker",k=E||(n==null?void 0:n.label.trim().length)>0,P=()=>{m(!1)},K=U=>{d(e,{label:U.trim()})};return(0,ye.jsxs)("g",{className:F("group bpmn-arrow-edge",{"is-highlighted":A}),onDoubleClick:()=>!x&&m(!0),children:[(0,ye.jsx)("path",{d:V,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),(0,ye.jsxs)("g",{className:F("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":A}),children:[(0,ye.jsx)(Ne.BaseEdge,{id:e,path:V,interactionWidth:0,markerEnd:`url(#${C})`,strokeDasharray:4,className:F("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&&!_,"stroke-green-500":h&&y&&_,"stroke-blue-500 hover:stroke-blue-600 stroke-[3px]":A&&!(n!=null&&n.hasError)&&!h})}),(0,ye.jsxs)(Ne.EdgeLabelRenderer,{children:[(0,ye.jsxs)("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${G}px, ${B}px)`},children:[r&&!f&&(0,ye.jsx)(On,{sx:S,sy:M,tx:L,ty:D,hasLabel:!!((Z=n==null?void 0:n.label)!=null&&Z.trim()),children:(0,ye.jsx)(Rn,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),k&&(0,ye.jsx)(Re,{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:P,onChange:K})]}),r&&!f&&!x&&(0,ye.jsxs)(ye.Fragment,{children:[(0,ye.jsx)("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${S}px, ${M}px)`},children:(0,ye.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,ye.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:h==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ye.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:h==="source"?.6:.3,className:"pointer-events-none"}),(0,ye.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:F("pointer-events-auto",{"cursor-move":!h||h!=="source","cursor-not-allowed":h==="source"&&y&&!_,"cursor-grabbing":h==="source"&&(!y||_)}),onMouseDown:U=>N("source",U.nativeEvent)})]})}),(0,ye.jsx)("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${L}px, ${D}px)`},children:(0,ye.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,ye.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:h==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ye.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:h==="target"?.6:.3,className:"pointer-events-none"}),(0,ye.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:F("pointer-events-auto",{"cursor-move":!h||h!=="target","cursor-not-allowed":h==="target"&&y&&!_,"cursor-grabbing":h==="target"&&(!y||_)}),onMouseDown:U=>N("target",U.nativeEvent)})]})})]})]})]})]})};var Qe=require("@xyflow/react"),ht=require("react");var lt=require("react/jsx-runtime"),{MAX_LABEL_DISTANCE:Hy}=po,Ku=({id:e,source:t,target:o,selected:n,data:r})=>{var D,O,R,V,G,B,A,C,k,P;let{isReadOnly:i,edgeHighlight:a,mode:s}=Y(),l=Nt(),{zoom:c}=(0,Qe.useViewport)(),{updateEdgeData:d}=(0,Qe.useReactFlow)(),[u,p]=(0,ht.useState)(!1),f=(0,ht.useRef)(r==null?void 0:r.labelOffset),x=s!=="edit",E=(0,Qe.useInternalNode)(t),m=(0,Qe.useInternalNode)(o),{sx:h,sy:g,tx:y,ty:v}=(0,ht.useMemo)(()=>E&&m?ei(E,m):{sx:0,sy:0,tx:0,ty:0},[E,m]),[_,N,b]=(0,ht.useMemo)(()=>(0,Qe.getStraightPath)({sourceX:h,sourceY:g,targetX:y,targetY:v}),[h,g,y,v]),w=(0,ht.useMemo)(()=>[{x:h,y:g},{x:y,y:v}],[h,g,y,v]),S=(0,ht.useMemo)(()=>({x:N,y:b}),[N,b]),M=(0,ht.useCallback)(K=>{var ce,oe,re,Ae,ae;if(u||x||K.button!==0||!((ce=r==null?void 0:r.label)!=null&&ce.trim()))return;K.stopPropagation(),K.preventDefault();let Z=K.clientX,U=K.clientY,H=(re=(oe=r==null?void 0:r.labelOffset)==null?void 0:oe.x)!=null?re:0,q=(ae=(Ae=r==null?void 0:r.labelOffset)==null?void 0:Ae.y)!=null?ae:0,z=[...w],W={x:S.x,y:S.y},X=!1,$=Se=>{let j=(Se.clientX-Z)/c,de=(Se.clientY-U)/c;if(!X&&Math.abs(j)<3&&Math.abs(de)<3)return;X=!0;let ke={x:H+j,y:q+de};f.current=ke,d(e,{labelOffset:ke})},ne=()=>{document.removeEventListener("mousemove",$),document.removeEventListener("mouseup",ne);let Se=f.current;if(!Se)return;let j={x:W.x+Se.x,y:W.y+Se.y};rs(j,z)>Hy&&(f.current=void 0,d(e,{labelOffset:void 0}))};document.addEventListener("mousemove",$),document.addEventListener("mouseup",ne)},[u,x,c,r,e,d,w,S]);if(!E||!m)return null;let L=a&&(n||(E==null?void 0:E.selected)||(m==null?void 0:m.selected));return(0,lt.jsxs)("g",{className:F("group bpmn-edge",{"is-highlighted":L}),onDoubleClick:()=>!x&&p(!0),children:[(0,lt.jsx)("path",{d:_,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),className:F({"nopan nodrag":!u&&!x&&!!((D=r==null?void 0:r.label)!=null&&D.trim())}),style:{pointerEvents:"stroke",cursor:!u&&!x&&((O=r==null?void 0:r.label)!=null&&O.trim())?"move":"pointer"},onMouseDown:M}),(0,lt.jsxs)("g",{className:F("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!i,"text-blue-500 group-hover:text-blue-600":L}),children:[(0,lt.jsx)(Qe.BaseEdge,{id:e,path:_,interactionWidth:0,strokeDasharray:4,className:F("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]":L&&!(r!=null&&r.hasError)})}),(0,lt.jsxs)(Qe.EdgeLabelRenderer,{children:[(0,lt.jsx)("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${N}px, ${b}px)`},children:n&&!l&&(0,lt.jsx)(On,{sx:h,sy:g,tx:y,ty:v,children:(0,lt.jsx)(Rn,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})}),(u||((R=r==null?void 0:r.label)==null?void 0:R.trim()))&&(0,lt.jsx)("div",{className:F("absolute nodrag nopan",!u&&!x&&((V=r==null?void 0:r.label)!=null&&V.trim())?"z-[10001] pointer-events-auto":"z-[3000] pointer-events-none"),style:{transform:`translate(-50%, -50%) translate(${S.x+((B=(G=r==null?void 0:r.labelOffset)==null?void 0:G.x)!=null?B:0)}px, ${S.y+((C=(A=r==null?void 0:r.labelOffset)==null?void 0:A.y)!=null?C:0)}px)`,cursor:!u&&!x&&((k=r==null?void 0:r.label)!=null&&k.trim())?"move":void 0},onMouseDown:!u&&!x?M:void 0,onDoubleClick:K=>{x||(K.stopPropagation(),p(!0))},children:(0,lt.jsx)(Re,{value:(P=r==null?void 0:r.label)!=null?P:"",className:F("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":u,"pointer-events-none":!u}),isEditing:u,onBlur:()=>p(!1),onChange:K=>d(e,{label:K.trim()})})})]})]})]})};var Tr=require("@xyflow/react");var yt=require("react/jsx-runtime"),qu=({toX:e,toY:t,fromNode:o})=>{let{getNodes:n,getInternalNode:r}=(0,Tr.useReactFlow)();if(!o)return null;let i=Ht(o),a=n().map(u=>r(u.id)).filter(u=>u!=null).find(u=>{var m,h,g,y;let{x:p,y:f}=u.internals.positionAbsolute,x=(h=(m=u.measured)==null?void 0:m.width)!=null?h:0,E=(y=(g=u.measured)==null?void 0:g.height)!=null?y:0;return e>=p&&e<=p+x&&t>=f&&t<=f+E});if(!a){let u=Xt({source:i,target:{bounds:{x:e,y:t,width:0,height:0},perimeter:"rectangle"}}),[p]=(0,Tr.getStraightPath)({sourceX:u.sourcePoint.x,sourceY:u.sourcePoint.y,targetX:e,targetY:t});return(0,yt.jsxs)("g",{className:"group",children:[(0,yt.jsx)("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d:p}),(0,yt.jsx)("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})}let s=Ht(a);if(o.type==="ANNOTATION"||a.type==="ANNOTATION"){let u=Xt({source:i,target:s}),[p]=(0,Tr.getStraightPath)({sourceX:u.sourcePoint.x,sourceY:u.sourcePoint.y,targetX:u.targetPoint.x,targetY:u.targetPoint.y});return(0,yt.jsxs)("g",{className:"group",children:[(0,yt.jsx)("path",{fill:"none",strokeDasharray:4,className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d:p}),(0,yt.jsx)("circle",{cx:u.targetPoint.x,cy:u.targetPoint.y,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})}let c=Xt({source:i,target:s}),d=as(c.points);return(0,yt.jsxs)("g",{className:"group",children:[(0,yt.jsx)("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d}),(0,yt.jsx)("circle",{cx:c.targetPoint.x,cy:c.targetPoint.y,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})};var Zu={START_EVENT:Iu,END_EVENT:_u,TASK:xa,GATEWAY:ga,ANNOTATION:yu,LANE:Ea,UNSUPPORTED:ku},Ju={SEQUENCE_EDGE:wa,MESSAGE_EDGE:$u,ANNOTATION_EDGE:Ku},Qu="#fafafa",ju="#bebebe",ep=1,tp=10,op="bottom-left",Ia=.05,np=5,rp=150,ip=100,sp=Ia,ap=1,lp={x:0,y:0,zoom:.75},cp=1,dp=2,Gy={[cp]:4,[dp]:2},vr=[cp,dp],up=[0,1,2],pp={hideAttribution:!0},Aa=vr.reduce((e,t)=>e|Gy[t],0);var fo=()=>{let{setViewport:e}=(0,cs.useReactFlow)(),t=(0,cs.useStoreApi)();return{fitToNodes:(0,fp.useCallback)(n=>{let{width:r,height:i}=t.getState();if(i<=0||r<=0)return;let a=dl(n);if(!a)return;let s=ul({bounds:a,canvasHeight:i,canvasWidth:r,minZoom:sp,maxZoom:ap,offsetX:rp,offsetY:ip});e(s)},[t,e])}};var mp=require("@xyflow/react");var ct=()=>{let{getEdges:e,getNodes:t}=(0,mp.useReactFlow)(),{lastElementId:o}=Y(),n=()=>{let i=t(),a=e(),s=Sd(i,a);return Math.max(s,o)};return{getLastId:n,getNextId:()=>n()+1}};var By=3e4,Pt=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n}=(0,gp.useReactFlow)(),{getLastId:r}=ct(),{fitToNodes:i}=fo(),{setLastElementId:a,onElementChanges:s}=Y(),l=(0,Nr.useCallback)(async(p="")=>{let{nodes:f,edges:x,lastElementId:E}=await Yd(p);return i(f),o(f),n(x),a(E),wn(f,x,E)},[o,n,a,i]),c=(0,Nr.useCallback)(()=>{let p=e(),f=t(),x=r();return wn(p,f,x)},[e,t,r]),d=(0,Nr.useCallback)(()=>wn([],[],r()),[r]),u=(0,Nr.useCallback)(async p=>{let f=s==null?void 0:s(p);if(!(f instanceof Promise))return;let x,E=new Promise((m,h)=>{x=setTimeout(()=>h(new Error("Tempo limite ao publicar o diagrama")),By)});try{await Promise.race([f,E])}finally{clearTimeout(x)}},[s]);return{importFromMxGraph:l,exportToMxGraph:c,buildEmptyDiagram:d,publishNow:u}};var zy=500,ds=()=>{let{isInitialized:e,isImporting:t,onElementChanges:o}=Y(),{exportToMxGraph:n}=Pt(),r=(0,hp.useDebouncedCallback)(()=>{if(!e||t)return;let s=n();o==null||o(s)},zy);(0,wr.useEffect)(()=>()=>{r.isPending()&&r.flush()},[r]);let i=(0,wr.useCallback)(s=>{s.every(d=>d.type==="select")||s.some(d=>d.type==="position"&&d.dragging)||r()},[r]),a=(0,wr.useCallback)(s=>{s.some(c=>c.type==="select")||r()},[r]);return{emitElementChanges:r,handleNodeChanges:i,handleEdgeChanges:a}};var yp=({setEdges:e,saveHistory:t})=>{let{getNode:o,getEdges:n,getNodes:r,getInternalNode:i}=(0,us.useReactFlow)(),{emitElementChanges:a}=ds(),s=(0,Lt.useRef)(null),{getNextId:l}=ct(),c=(0,Lt.useCallback)(m=>{var _;let h=o(m.source),g=o(m.target);if(!h||!g)return!1;let y={sourceNodeId:h.id,targetNodeId:g.id,sourceNodeType:h.type,targetNodeType:g.type,nodes:r(),edges:n(),reconnectingEdgeId:(_=s.current)!=null?_:void 0};return Js(y).isValid},[o,n,r]),d=(0,Lt.useCallback)(m=>{let h=l(),g=i(m.source);if(g){let y=i(m.target),v=(y==null?void 0:y.type)==="ANNOTATION"||(g==null?void 0:g.type)==="ANNOTATION",_=v?_n:rt,N=I(T(T({},m),_),{id:String(h),sourceHandle:void 0,targetHandle:void 0,data:T({},v?{}:rt.data)}),b=n().concat(N);e(b),t("forceSave",{nodes:r(),edges:b}),a()}},[l,e,a,i,n,r,t]),u=(0,Lt.useCallback)((m,h)=>{s.current=h.id},[]),p=(0,Lt.useCallback)(()=>{s.current=null},[]),f=(0,Lt.useCallback)((m,h)=>{let g=o(h.source),y=o(h.target);if(!g||!y){s.current=null;return}let v={sourceNodeId:g.id,targetNodeId:y.id,sourceNodeType:g.type,targetNodeType:y.type,nodes:r(),edges:n(),reconnectingEdgeId:m.id};if(!Js(v).isValid){s.current=null;return}let N=(0,us.reconnectEdge)(m,h,n()).map(b=>b.id===m.id?I(T({},b),{data:I(T({},b.data),{controlPoint:void 0})}):b);e(N),t("forceSave",{nodes:r(),edges:N}),s.current=null,a()},[o,r,n,e,a,t]),x=(0,Lt.useCallback)(m=>{s.current=m},[]),E=(0,Lt.useCallback)(()=>{s.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:f,onReconnectStart:u,onReconnectEnd:p,setReconnectingEdge:x,clearReconnectingEdge:E}};var Sr=require("@produto-lecom/lecom-ui"),Ip=require("@xyflow/react"),et=require("react");var Ir=(e=[])=>e.filter(t=>t.type==="START_EVENT"),$o=(e=[])=>e.filter(t=>t.type==="END_EVENT"),mo=(e=[])=>e.filter(t=>t.type==="TASK")||[],xp=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"});var ps=(e=[])=>e.filter(t=>t.type==="GATEWAY"),Ep=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),je=(e,t=[])=>t.filter(o=>o.source===e),Ar=(e,t=[])=>t.filter(o=>o.target===e),_p=(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"},bp=(e,t)=>{let o=je(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},Tp=e=>e?/[^\s]/.test(e.trim()):!1,pe=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:[]}},Qt=(e=[],t)=>{if(!e||e.length===0)return{isValid:!0,invalidIds:[]};let o=e.filter(n=>!t(n));return{isValid:o.length===0,invalidIds:o.map(n=>n.id)}},Fy=(e,t)=>{let o=new Set(e.filter(n=>n.type==="ANNOTATION").map(n=>n.id));return t.filter(n=>!o.has(n.source)&&!o.has(n.target))},vp=(e=[],t=[])=>({nodes:e.map(o=>{var n;return{id:o.id,type:o.type||"",label:typeof((n=o.data)==null?void 0:n.label)=="string"?o.data.label:void 0,properties:o.data}}),edges:Fy(e,t).map(o=>({id:o.id,source:o.source,target:o.target,type:o.type||"default"}))});var Cr=[{id:"start_event_not_found",validate:e=>{let t=Ir(e.nodes);return pe({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=$o(e.nodes);return pe({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Ir(e.nodes),o=t.length===1;if(t.length===0)return pe({isValid:!0});if(!o)return pe({isValid:!1,nodeIds:t.map(i=>i.id)});let n=je(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(a=>a.id),...n.map(a=>a.target)];return pe({isValid:!1,nodeIds:[...new Set(i)]})}return pe({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=mo(e.nodes),o=Qt(t,n=>je(n.id,e.edges).length<=2);return pe({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=mo(e.nodes),o=Qt(t,n=>!!n.label&&n.label.trim()!=="");return pe({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=mo(e.nodes),n=Qt(o,r=>!r.label||r.label.length<=60);return pe({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=mo(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 pe({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{var r,i,a,s;let t=ps(e.nodes),o=[],n=[];for(let l of t){let c=je(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=((a=l.properties)==null?void 0:a.variant)==="COMPLEX"&&((s=u==null?void 0:u.properties)==null?void 0:s.variant)==="PARALLEL";!p&&!f&&(o.push(l.id,u.id),n.push(d.id))}}return pe({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Ir(e.nodes),...$o(e.nodes)],o=[],n=[];for(let r of t){let i=je(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&(s.type==="START_EVENT"||s.type==="END_EVENT")&&(o.push(r.id,s.id),n.push(a.id))}}return pe({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=$o(e.nodes),o=[],n=[];for(let r of t){let i=Ar(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.source);if(s&&s.type==="TASK"){let l=je(s.id,e.edges);l.length>1&&(o.push(s.id),l.forEach(c=>n.push(c.id)))}}}return pe({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=Ep(e.nodes),o=Qt(t,r=>je(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>je(r,e.edges).map(i=>i.id));return pe({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=mo(e.nodes),o=Qt(t,n=>!n.label||Tp(n.label));return pe({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var a,s;if(!((a=e==null?void 0:e.nodes)!=null&&a.length)||!((s=e==null?void 0:e.edges)!=null&&s.length))return pe({isValid:!0});let t=$o(e.nodes)[0];if(!t)return pe({isValid:!0});let o=Ar(t.id,e.edges);if(!o.length)return pe({isValid:!0});let r=mo(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=Qt(r,l=>!_p(l.id,e));return pe({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=mo(e.nodes),o=$o(e.nodes)[0];if(!o)return pe({isValid:!0});let n=t.filter(l=>{let c=Ar(l.id,e.edges),d=je(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=Ar(o.id,e.edges),i=r.length>1,a=r.map(l=>l.source),s={isValid:n.length===0&&!i,nodeIds:[...n.map(l=>l.id),...i?a:[]]};return pe(s)}},{id:"gateway_flow_to_event",validate:e=>{let t=ps(e.nodes),o=[],n=[];for(let r of t){let i=je(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="END_EVENT"&&(o.push(r.id,s.id),n.push(a.id))}}return pe({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=ps(e.nodes),o=Qt(t,n=>je(n.id,e.edges).length>=1);return pe({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Ir(e.nodes),...$o(e.nodes)],o=[],n=[];for(let r of t){let i=je(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="GATEWAY"&&(o.push(r.id,s.id),n.push(a.id))}}return pe({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=xp(e.nodes),o=Qt(t,n=>!bp(n.id,e));return pe({isValid:o.isValid,nodeIds:o.invalidIds})}}];var Np=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of Cr){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}},wp=async(e,t)=>{var n;let o=[];try{let r=await e(),i=(n=r==null?void 0:r.filter(a=>a.area==="DIAGRAM"))!=null?n:[];return i.length===0?{isValid:!0,errors:[]}:(i.forEach(a=>{var l,c;let s=(c=(l=a==null?void 0:a.detail)==null?void 0:l.phases)==null?void 0:c.map(d=>d.diagramCellId);o.push({id:a.code,message:a.code,nodeIds:s,edgeIds:[]})}),{isValid:!1,errors:o})}catch(r){let i=[],a=(s,l)=>{let c=t.filter(d=>{var u;return((u=d.data)==null?void 0:u.variant)===s}).map(d=>d.id);c.length>0&&i.push({id:l,message:l,nodeIds:c,edgeIds:[]})};return a("SUBPROCESS","cannot_validate_subprocess_reference"),a("SERVICE_TASK","service_task_automation_status_unavailable"),{isValid:!1,errors:i}}};var Ko=require("react/jsx-runtime"),Ap=()=>{let{t:e}=(0,Sr.useTranslation)(),{toast:t}=Oe(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=(0,Ip.useReactFlow)(),{validateCustomDiagram:a}=Y(),[s,l]=(0,et.useState)(!1),c=(0,et.useRef)(!1),d=(0,et.useRef)(!1),u=(0,et.useRef)(!1),p=(0,et.useCallback)(async g=>{let y=vp(g.nodes,g.edges),v=Np(y),_=g.nodes.filter(({type:b,data:w})=>b==="TASK"&&((w==null?void 0:w.variant)==="SUBPROCESS"||(w==null?void 0:w.variant)==="SERVICE_TASK"));if(a&&_.length>0){let b=await wp(a,_);v={isValid:v.isValid&&b.isValid,errors:[...v.errors,...b.errors]}}let N=v.errors.map(b=>I(T({},b),{message:e(`validation.errors.${b.id}`)}));return s||l(!0),{isValid:v.isValid,errors:N}},[s,e,a]),f=(0,et.useCallback)((g,y=!0)=>{if(y&&g){let R=g.isValid?e("validation.success.title"):e("validation.errors.title"),V=g.isValid?e("validation.success.message"):e("validation.errors.subtitle");t({variant:g.isValid?"success":"error",duration:5e3,title:R,content:(0,Ko.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,Ko.jsx)(Sr.Typography,{variant:"body-medium-400",textColor:"text-grey-950",children:V}),!g.isValid&&(0,Ko.jsx)("ul",{className:"list-disc list-inside max-h-[600px] overflow-y-auto",children:g.errors.map(G=>(0,Ko.jsx)("li",{children:(0,Ko.jsx)(Sr.Typography,{variant:"body-medium-400",textColor:"text-grey-950",children:G.message})},G.id))})]})})}if(!g)return;c.current=!0,d.current=!0,u.current=!0;let v=[],_=[];g.errors.forEach(R=>{R.nodeIds&&R.nodeIds.length>0&&R.nodeIds.forEach(V=>v.push(V)),R.edgeIds&&R.edgeIds.length>0&&R.edgeIds.forEach(V=>_.push(V))});let N=[...new Set(v)],b=r(),w=i(),S=new Set(N),M=new Set;g.errors.forEach(R=>{var B,A;let V=Cr.find(C=>C.id===R.id);(V==null?void 0:V.highlightRelatedEdges)!==!1&&((B=R.edgeIds)==null||B.forEach(C=>M.add(C)),(A=R.nodeIds)==null||A.forEach(C=>{w.forEach(k=>{(k.source===C||k.target===C)&&M.add(k.id)})}))});let L=new Set,D=new Set,O=new Set;b.forEach(R=>{R.type==="START_EVENT"?L.add(R.id):R.type==="END_EVENT"&&D.add(R.id)}),w.forEach(R=>{L.has(R.source)&&O.add(R.target),D.has(R.target)&&O.add(R.source)}),O.forEach(R=>{var V,G;if(S.has(R)){let B=(V=g.errors.find(C=>{var k;return(k=C.nodeIds)==null?void 0:k.includes(R)}))==null?void 0:V.id;((G=Cr.find(C=>C.id===B))==null?void 0:G.highlightRelatedEdges)!==!1&&w.forEach(C=>{C.source===R&&D.has(C.target)&&(S.add(C.target),M.add(C.id)),C.target===R&&L.has(C.source)&&(S.add(C.source),M.add(C.id))})}}),o(R=>R.map(V=>I(T({},V),{data:I(T({},V.data),{hasError:S.has(V.id)})}))),n(R=>R.map(V=>I(T({},V),{data:I(T({},V.data),{hasError:M.has(V.id)})}))),setTimeout(()=>{d.current=!1,c.current=!1},0)},[e,i,r,n,o,t]),x=(0,et.useCallback)(()=>{l(!1),u.current=!1,o(g=>g.map(y=>I(T({},y),{data:I(T({},y.data),{hasError:!1})}))),n(g=>g.map(y=>I(T({},y),{data:I(T({},y.data),{hasError:!1})})))},[n,o]),E=(0,et.useCallback)(()=>{u.current&&(d.current=!0,u.current=!1,o(g=>g.map(y=>I(T({},y),{data:I(T({},y.data),{hasError:!1})}))),n(g=>g.map(y=>I(T({},y),{data:I(T({},y.data),{hasError:!1})}))),setTimeout(()=>{d.current=!1},0))},[n,o]),m=(0,et.useCallback)(()=>d.current,[]),h=(0,et.useCallback)(()=>c.current,[]);return{validateDiagram:p,handleValidationComplete:f,clearValidation:x,dismissValidationPanel:E,isAutoValidationEnabled:s,getIsClearingValidation:m,getIsValidating:h}};var Mp=require("@produto-lecom/lecom-ui"),Pp=require("@xyflow/react"),Lp=require("react");var Yy=15,Cp="bpmn:selection",Wy=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},Sp=e=>{if(!Wy(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},Dp=({offset:e=Yy,saveHistory:t})=>{let{t:o}=(0,Mp.useTranslation)(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=(0,Pp.useReactFlow)(),{getNextId:s}=ct(),{mode:l,containerRef:c}=Y();(0,Lp.useEffect)(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let u=f=>{var _,N;if(!Sp(f)||!d.contains(document.activeElement))return;let E=n(),m=i(),h=E.filter(b=>b.selected);if(!h.length)return;f.preventDefault(),f.stopPropagation();let g=m.filter(b=>h.some(w=>w.id===b.source)&&h.some(w=>w.id===b.target)),v=JSON.stringify({nodes:h,edges:g});(_=f.clipboardData)==null||_.setData(Cp,v),(N=f.clipboardData)==null||N.setData("text/plain",`BPMN Selection: ${h.length} nodes`)},p=f=>{var L,D;if(!Sp(f)||!d.contains(document.activeElement))return;let E=(L=f.clipboardData)==null?void 0:L.getData(Cp);if(!E)return;f.preventDefault(),f.stopPropagation();let m;try{m=JSON.parse(E)}catch(O){return}if(!((D=m.nodes)!=null&&D.length))return;let h=new Map,g=n(),y=[],v=m.nodes.filter(O=>En(O.type,g));if(v.length===0)return;let _=s(),N=v.map(O=>{var G;let R=String(_++);h.set(O.id,R);let V=I(T({},O),{id:R,selected:!0,position:{x:O.position.x+e,y:O.position.y+e}});if(O.type==="TASK"){let B=(G=O.data)==null?void 0:G.label,A=Ln(B||o("bpmn.task.label.prefix"),[...g,...y]);V.data=I(T({},O.data),{label:A})}return y.push(V),V}),b=m.edges.map(O=>I(T({},O),{id:String(_++),selected:!0,source:h.get(O.source)||O.source,target:h.get(O.target)||O.target,data:jr(O.data,e)})),w=[...g.map(O=>I(T({},O),{selected:!1})),...N],M=[...i().map(O=>I(T({},O),{selected:!1})),...b];r(w),a(M),t("forceSave",{nodes:w,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,a,s,e,o,t,l,c])};var kp=require("@produto-lecom/lecom-ui"),Rp=require("@xyflow/react"),qo=require("react");var Op=({nodes:e,setNodes:t})=>{let{t:o}=(0,kp.useTranslation)(),{toast:n}=Oe(),{getNodes:r}=(0,Rp.useReactFlow)(),{setIsRemovingElements:i,validateDeleteElements:a}=Y(),s=(0,qo.useRef)(!1),l=(0,qo.useCallback)(async p=>{try{let{activitiesWithInstances:f}=await a(p);if(f.length)return s.current=!1,i(!1),n({variant:"warning",content:o("editor.toolbar.delete_elements_blocked")}),!1}catch(f){return s.current=!1,i(!1),n({variant:"error",content:o("editor.toolbar.delete_elements_error")}),!1}return!0},[o,n,a,i]),c=(0,qo.useCallback)(async({nodes:p})=>{if(s.current)return!1;if(s.current=!0,i(!0),p.some(E=>E.type==="LANE"&&e.some(m=>m.parentId===E.id)))return s.current=!1,i(!1),n({variant:"error",title:o("validation.errors.title"),content:o("editor.toolbar.delete_pool_lane_error")}),!1;let x=p.filter(E=>E.type==="TASK");if(a&&x.length>0){let E=x.map(m=>m.id);return l(E)}return!0},[e,o,n,a,l,i]),d=(0,qo.useCallback)(p=>{s.current=!1,i(!1);let f=new Set(p.filter(x=>x.type==="LANE"&&!!x.parentId).map(x=>x.parentId));f.size!==0&&setTimeout(()=>{var m,h;let x=r(),E=new Map(x.map(g=>[g.id,g]));for(let g of f){let y=Oo(x.filter(N=>N.type==="LANE"&&N.parentId===g));if(y.length===0)continue;let v=0;for(let N of y)E.set(N.id,I(T({},N),{position:{x:J.HEADER_WIDTH,y:v}})),v+=(h=(m=N.measured)==null?void 0:m.height)!=null?h:0;let _=E.get(g);_&&E.set(g,I(T({},_),{height:v,measured:I(T({},_.measured),{height:v})}))}t(x.map(g=>{var y;return(y=E.get(g.id))!=null?y:g}))},0)},[r,t,i]),u=(0,qo.useCallback)(()=>{s.current=!1,i(!1)},[i]);return{onBeforeDelete:c,onNodesDelete:d,onEdgesDelete:u}};var Vp=require("@produto-lecom/lecom-ui"),Hp=require("@xyflow/react");var Gp=require("react");var Xy=50,Bp=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let{draggableNode:r,setDraggableNode:i}=Cn(),{t:a}=(0,Vp.useTranslation)(),{getInternalNode:s,getNodes:l,getEdges:c,screenToFlowPosition:d}=(0,Hp.useReactFlow)(),{getNextId:u}=ct(),{setIsDragging:p}=Y(),{getInternalNodes:f}=$i(),{rebuildIndex:x,forceRebuildIndex:E}=ki(),[m,h]=(0,Gp.useState)(null),g=(A,C,k)=>{var U;if(A.parentId!==C)return null;let P=k.filter(H=>H.id!==A.id&&H.parentId===C&&H.type==="LANE").sort((H,q)=>H.position.y-q.position.y);if(P.length===0)return null;let K=(U=k.find(H=>H.id===A.id))!=null?U:A,Z=P.find(H=>K.position.y<H.position.y);return Z?{draggedLaneId:A.id,beforeLaneId:Z.id}:{draggedLaneId:A.id,afterLaneId:P[P.length-1].id}},y=(A,C=!1,k)=>{let P=C?"node-drop-target-error":"node-drop-target",K=C?"node-drop-target-lane-error":"node-drop-target-lane";t(Z=>{var W;let U=(W=k==null?void 0:k(Z))!=null?W:null,H=X=>{let $=[];return X.id===A&&$.push(P),A!==void 0&&X.parentId===A&&X.type==="LANE"&&X.id!==(U==null?void 0:U.draggedLaneId)&&$.push(K),X.id===(U==null?void 0:U.draggedLaneId)&&$.push("lane-reorder-dragging"),X.id===(U==null?void 0:U.beforeLaneId)&&$.push("lane-reorder-before"),X.id===(U==null?void 0:U.afterLaneId)&&$.push("lane-reorder-after"),$.join(" ")||void 0},q=!1,z=Z.map(X=>{let $=H(X);return X.className===$?X:(q=!0,I(T({},X),{className:$}))});return q?z:Z})},v=(A,C)=>{let k=f();if(A.type==="LANE"){if(C){let W=k.filter($=>$.id!==A.id&&$.parentId!==A.id&&$.type==="LANE"),X=fn(A,W);X?y(X.id,!0):y();return}let H=k.filter(W=>W.id!==A.id&&W.type==="LANE"&&!W.parentId),q=fn(A,H);if(!q){y();return}if(Io({parentId:q.id,nodes:e,excludeTypes:["LANE"]})){y(q.id,!0);return}y(q.id,!1,W=>g(A,q.id,W));return}let K=k.filter(H=>H.id!==A.id&&H.type==="LANE"),Z=fn(A,K);if(!Z){y();return}if(Io({parentId:Z.id,nodes:e,includeTypes:["LANE"]})){y(Z.id,!0);return}y(Z.id)},_=A=>{let C=s(A.id),k=A.type==="LANE"&&Io({parentId:A.id,nodes:e,includeTypes:["LANE"]});v(C,k)},N=A=>A.map(C=>I(T({},C),{className:void 0})),b=A=>A.some(k=>k.dragging)?A.map(k=>k.dragging?I(T({},k),{dragging:!1}):k):A,w=(A,C)=>{let k=0;for(let P of C){if(P.id===A||P.parentId||P.type==="LANE")continue;let K=ot(P),Z=K.y+K.h;k=Math.max(k,Z)}return k+Xy},S=(A,C)=>{if(!Ds(A,C))return C;let k=w(A,C);return C.map(P=>P.id===A?I(T({},P),{position:I(T({},P.position),{y:k})}):P)},M=A=>{if(A.preventDefault(),A.dataTransfer.dropEffect="move",!(r!=null&&r.type))return;let C=d({x:A.clientX,y:A.clientY}),k={id:"__sidebar_drag__",type:r.type,position:C,measured:{width:1,height:1},internals:{positionAbsolute:C}};v(k,!1)},L=A=>{let C=A.relatedTarget;(!C||!A.currentTarget.contains(C))&&y()},D=(A,C)=>{A.preventDefault(),_(C)},O=(A,C,k)=>{var z,W;let P=[...k],K=C.parentId?C.parentId:C.id;if(A.parentId===C.id)return P=js(A,C,P),P=Wt(P),P=Ro(K,P),N(P);if(A.type==="LANE"){if(Io({parentId:C.id,nodes:P,excludeTypes:["LANE"]})){let oe=Pi(C),re=50,Ae=50;return P.map(ae=>{var Se,j;return ae.id===A.id?I(T({},ae),{position:{x:(Se=m==null?void 0:m.x)!=null?Se:oe.x+re,y:(j=m==null?void 0:m.y)!=null?j:oe.y2+Ae}}):ae})}let ne=P.filter(oe=>oe.parentId===C.id).reduce((oe,re)=>{var Ae,ae;return oe+((ae=(Ae=re.measured)==null?void 0:Ae.height)!=null?ae:0)},0),ce={x:J.HEADER_WIDTH,y:ne};return P=P.map(oe=>oe.id===A.id?I(T({},oe),{parentId:C.id,position:ce,className:void 0}):I(T({},oe),{className:void 0})),P=Wt(P),P=S(K,P),P}if(Io({parentId:C.id,nodes:P,includeTypes:["LANE"]})){let X;if(A.parentId){let $=s(A.parentId),{x:ne,y:ce}=ot($);X={x:ne+((z=A.position.x)!=null?z:0),y:ce+((W=A.position.y)!=null?W:0)}}return P=P.map($=>$.id===A.id?I(T({},$),{position:X!=null?X:$.position,parentId:void 0,className:void 0}):I(T({},$),{className:void 0})),P=Ro(K,P),P}let H=ll(A,C);P=P.map(X=>X.id===A.id?I(T({},X),{parentId:C.id,position:H,className:void 0}):I(T({},X),{className:void 0}));let q=P.find(X=>X.id===A.id);return P=js(q,C,P),P=Wt(P),P=Ro(K,P),P},R=A=>{if(A.preventDefault(),!(r!=null&&r.type))return;if(!En(r.type,l())){p(!1),i(null);return}let C=d({x:A.clientX,y:A.clientY}),k=te[r.type],P={width:k.DEFAULT_WIDTH,height:k.DEFAULT_HEIGHT},K=u(),Z={id:String(K),type:r.type,position:C,width:k.DEFAULT_WIDTH,height:k.DEFAULT_HEIGHT,measured:P,data:{label:r.type==="TASK"?es(e,a("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},U=I(T({},Z),{internals:{positionAbsolute:C}}),H=I(T({},U),{measured:{width:1,height:1}}),q=f(),z=r.type==="LANE",W=q.filter(re=>z?re.type==="LANE"&&!re.parentId:re.type==="LANE"),X=fn(H,W),$=[...q.map(re=>I(T({},re),{selected:!1})),U];X&&($=O(U,X,$)),$=wo($),z&&!X&&($=S(U.id,$)),$=N($),t($),E();let ne=A.dataTransfer.getData("sourceId"),ce=c(),oe=ce;if(ne){let re={id:String(K+1),source:ne,target:Z.id},Ae=r.type==="ANNOTATION"?T(T({},re),_n):T(T({},re),rt);oe=ce.concat(Ae),o(oe)}n("forceSave",{nodes:$,edges:oe}),p(!1),i(null)},V=async(A,C,k)=>{let P=[...f()],K=new Set;k.forEach(H=>{let q=s(H.id),z=H.type==="LANE",W=P.filter($=>$.id!==H.id&&(z?$.type==="LANE"&&!$.parentId:$.type==="LANE")),X=fn(q,W);if(X){if(z&&Io({parentId:H.id,nodes:P,includeTypes:["LANE"]})){H.parentId&&(P=B(H,P),K.add(H.id));return}P=O(q,X,P);return}H.parentId&&(P=B(H,P),H.type==="LANE"&&K.add(H.id))}),P=b(P);let Z=k.filter(H=>H.type==="LANE"&&!H.parentId).map(H=>H.id);for(let H of Z)Ds(H,P)&&m&&(P=P.map(q=>q.id===H?I(T({},q),{position:T({},m)}):q));for(let H of K)P=S(H,P);if(k.some(H=>H.type!=="LANE"&&!H.parentId)){let H=P.filter(q=>q.type==="LANE"&&!q.parentId).map(q=>q.id);for(let q of H)P=Ro(q,P)}P=wo(P),P=N(P),t(P),x(P),h(null)},G=(A,C)=>{h({x:C.position.x,y:C.position.y})},B=(A,C)=>{var W,X,$,ne,ce,oe,re,Ae,ae,Se;let k=s(A.parentId);if(!k)return C;let P=A.type==="LANE",K=C.filter(j=>j.parentId===k.id&&j.id!==A.id),Z=K.filter(j=>j.type==="LANE"),U;if(P&&Z.length===0)U=(X=(W=k.measured)==null?void 0:W.height)!=null?X:J.DEFAULT_HEIGHT;else if(P){let j=(ne=($=A.measured)==null?void 0:$.height)!=null?ne:J.MIN_HEIGHT;U=((oe=(ce=k.measured)==null?void 0:ce.height)!=null?oe:J.MIN_HEIGHT)-j,U=Math.max(J.MIN_HEIGHT,U)}else U=K.length>0?K.reduce((j,de)=>{var ke,ut;return j+((ut=(ke=de.measured)==null?void 0:ke.height)!=null?ut:0)},0)+Te:Math.max(J.MIN_HEIGHT,(Ae=(re=k.measured)==null?void 0:re.height)!=null?Ae:0);let{x:H,y:q}=ot(k),z={x:H+((ae=A.position.x)!=null?ae:0),y:q+((Se=A.position.y)!=null?Se:0)};return C=C.map(j=>j.id===A.id?I(T({},j),{position:z,parentId:void 0}):j.id===k.id?I(T({},j),{height:U,measured:I(T({},j.measured),{height:U})}):j),C=Wt(C),C};return{onDragOver:M,onDragLeave:L,onDrop:R,onNodeDrag:D,onNodeDragStart:G,onNodeDragStop:V}};var zp=require("@produto-lecom/lecom-ui"),Fp=require("@xyflow/react"),Yp=require("react");var Uy=30,$y=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},Ky=e=>!$y(e.target),Wp=({offset:e=Uy,saveHistory:t})=>{let{t:o}=(0,zp.useTranslation)(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=(0,Fp.useReactFlow)(),{getNextId:s}=ct(),{mode:l,containerRef:c}=Y();(0,Yp.useEffect)(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let u=p=>{if(d.contains(document.activeElement)&&p.ctrlKey&&p.key.toLowerCase()==="d"&&Ky(p)){p.preventDefault(),p.stopPropagation();let x=n(),E=i(),m=x.filter(M=>M.selected);if(!m.length)return;let h=new Map,g=[],y=m.filter(M=>En(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)),_=s(),N=y.map(M=>{var O;let L=String(_++);h.set(M.id,L);let D=I(T({},M),{id:L,selected:!0,position:{x:M.position.x+e,y:M.position.y+e}});if(M.type==="TASK"){let R=(O=M.data)==null?void 0:O.label,V=Ln(R||o("bpmn.task.label.prefix"),[...x,...g]);D.data=I(T({},M.data),{label:V})}return g.push(D),D}),b=v.map(M=>I(T({},M),{id:String(_++),selected:!0,source:h.get(M.source)||M.source,target:h.get(M.target)||M.target,data:jr(M.data,e)})),w=[...x.map(M=>I(T({},M),{selected:!1})),...N],S=[...E.map(M=>I(T({},M),{selected:!1})),...b];r(w),a(S),t("forceSave",{nodes:w,edges:S})}};return d.addEventListener("keydown",u,!0),()=>{d.removeEventListener("keydown",u,!0)}},[n,r,i,a,s,e,o,t,l,c])};var Pr=require("react"),Xp=require("@xyflow/react");var qy=20,Zy=50,Mr={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},Jy=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},Up=e=>{let{getNodes:t}=(0,Xp.useReactFlow)(),{mode:o,isMoveTool:n}=Y(),r=(0,Pr.useRef)(0),i=(0,Pr.useRef)(new Map);(0,Pr.useEffect)(()=>{let a=s=>{if(o!=="edit"||!n||Jy(s.target)||!Object.values(Mr).includes(s.key))return;let u=t().filter(g=>g.selected);if(u.length===0){i.current.clear();return}s.preventDefault();let p=Date.now(),f=p-r.current<500;r.current=p;let x=s.shiftKey?Zy:qy,E=0,m=0;switch(s.key){case Mr.UP:m=-x;break;case Mr.DOWN:m=x;break;case Mr.LEFT:E=-x;break;case Mr.RIGHT:E=x;break}let h=u.map(g=>{let y=i.current.get(g.id);(!f||!y)&&(y={x:g.position.x,y:g.position.y});let v={x:y.x+E,y:y.y+m};return i.current.set(g.id,v),{id:g.id,dragging:!1,type:"position",position:v}});e&&e(h)};return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[t,e,o,n])};var Jp=require("@xyflow/react");var Kp={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY","gateway-parallel":"GATEWAY","gateway-complex":"GATEWAY"},qp={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},$p=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],n=e.match(/(\[.*?\])/)||[],r=e.match(/(\{.*?\})/)||[],i=e.match(/(--.*|\|.*?\|)/i)||[],a="",s="",l="";if(o.length){switch(o[1]){case"<start>":a="start-event";break;case"<end>":a="end-event";break}e=e.replace(o[1],"")}return n.length&&(a="task",s=n[1].replace(/\[|\]/g,""),e=e.replace(n[1],"")),r.length&&(s=r[1].replace(/\{|\}/g,""),s.charAt(0)==="+"?(a="gateway-parallel",s=s.slice(1)):s.charAt(0)==="*"?(a="gateway-complex",s=s.slice(1)):a="gateway-exclusive",e=e.replace(r[1],"")),a||(a="task",s=e),i.length&&(l=i[1].replace(/(\||--)/g,""),e=e.replace(i[1],"")),e=e.trim(),t[e]||(t[e]={type:a,label:s}),{step:e,type:a,label:s,edgeLabel:l}},Qy=e=>{e=e||"";let t=e.trim().split(`
|
|
42
|
+
`),o={},n=[];return t.forEach(r=>{r=r||"";let i=r.trim().split("-->");if(i.length!==2){console.warn("Invalid number of steps");return}let a=$p(i[0],o),s=$p(i[1],o);a&&s&&n.push({sourceId:a.step,targetId:s.step,label:a.edgeLabel||s.edgeLabel||""})}),{components:o,connections:n}},Zp=e=>{let{components:t,connections:o}=Qy(e);return{nodes:t,edges:o}};var jy=7,ex=48,tx=340,ox=(e,t)=>{let o=ex+e.length*jy;return Math.min(tx,Math.max(t,o))},fs=()=>{let{setNodes:e,setEdges:t}=(0,Jp.useReactFlow)(),{fitToNodes:o}=fo(),{getNextId:n}=ct();return{importFromLia:i=>{let a=typeof i=="string"?i:i.diagramXml||"",{nodes:s,edges:l}=Zp(a),c=[],d=new Map,u=!1,p=n();for(let[g,y]of Object.entries(s)){let v=String(p++),_=Kp[y.type],N=qp[y.type];_==="START_EVENT"&&(u=!0),d.set(g,v);let b=te[_].MIN_WIDTH,w=te[_].MIN_HEIGHT;c.push({id:v,type:_,data:{label:y.label||"",variant:N,attribute:""},position:{x:0,y:0},width:b,height:w,measured:{width:b,height:w}})}let f=[];for(let g of l){let y=I(T({},rt),{id:String(p++),source:d.get(g.sourceId)||g.sourceId,target:d.get(g.targetId)||g.targetId});f.push(y)}if(!u&&c.length>0){let g=String(p++),y={id:g,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:te.START_EVENT.MIN_WIDTH,height:te.START_EVENT.MIN_HEIGHT,measured:{width:te.START_EVENT.MIN_WIDTH,height:te.START_EVENT.MIN_HEIGHT}};c.unshift(y);let v=c[1];if(v){let _=I(T({},rt),{id:String(p++),source:g,target:v.id});f.unshift(_)}}let x=c.map(g=>{var y,v;return g.type==="TASK"?I(T({},g),{width:ox(String((v=(y=g.data)==null?void 0:y.label)!=null?v:""),te.TASK.MIN_WIDTH)}):g}),{nodes:E}=Fi(x,f),m=new Map(E.map(g=>[g.id,g.position])),h=c.map(g=>{var y;return I(T({},g),{position:(y=m.get(g.id))!=null?y:g.position})});return e(h),t(f),o(h),wn(h,f,p-1)}}};var ms=require("react"),nx={origin:"*",debug:!1};function gs(e,t=nx){let{origin:o,debug:n}=t,r=(0,ms.useCallback)((i,a)=>{let s={event:i,data:a};window.parent.postMessage(s,o||"*")},[o]);return(0,ms.useEffect)(()=>{if(!e)return;let i=a=>{let s=a.data;if(!(s!=null&&s.event)||(s==null?void 0:s.data)===void 0)return;let{event:l,data:c}=s,d;if(Array.isArray(c)){let[,u]=c;d=u.data}else d=c;n&&(console.debug("[postMessage] received:",s),console.debug("[postMessage] eventData:",d)),l&&e[l]&&e[l](d)};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[e,n]),{sendMessage:r}}var Qp=require("@xyflow/react"),Gn=require("react");var jp=()=>{let e=(0,Qp.useNodesInitialized)(),{initialDiagram:t,isNewDiagram:o,isInitialized:n,setIsInitialized:r,onElementChanges:i}=Y(),{importFromMxGraph:a,exportToMxGraph:s}=Pt(),{sendMessage:l}=gs(),c=(0,Gn.useRef)(!1);(0,Gn.useEffect)(()=>{t&&a(t)},[t,a]),(0,Gn.useEffect)(()=>{if(!n||!o||c.current)return;c.current=!0;let d=s();i==null||i(d)},[n,o,t,s,i]),(0,Gn.useEffect)(()=>{if(!e)return;(async()=>{await Kr(),r(!0),l("INIT_MODELER",t)})()},[e,t,r,l])};var ef=require("@xyflow/react"),Ca=require("react");function tf(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=Ao(),{getEdges:n}=(0,ef.useReactFlow)(),r=(0,Ca.useCallback)(a=>{if(!(a!=null&&a.activities))return;e(a.activities);let s=a.activities.map(c=>c.diagramId),l=n();o(l,s)},[e,o,n]),i=(0,Ca.useCallback)(()=>{t()},[t]);return{handleTasksStatus:r,handleClearTaskStatus:i}}var nf=require("@xyflow/react"),We=require("react"),rf=require("use-debounce");var ix=500,of=100,sf=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=(0,nf.useReactFlow)(),{mode:i,containerRef:a}=Y(),[s,l]=(0,We.useState)({history:[],currentStep:0}),{history:c,currentStep:d}=s,u=d>0,p=d<c.length-1,f=(0,We.useCallback)((b,w)=>{n(b[w].nodes),r(b[w].edges)},[n,r]),x=(0,We.useCallback)(()=>{if(d>0){let b=d-1;l(w=>I(T({},w),{currentStep:b})),f(c,b)}},[d,c,f]),E=(0,We.useCallback)(()=>{if(d<c.length-1){let b=d+1;l(w=>I(T({},w),{currentStep:b})),f(c,b)}},[c,d,f]),m=(0,We.useCallback)(b=>{l(w=>{let S=w.history[w.currentStep];if(S&&JSON.stringify(S)===JSON.stringify(b))return w;let D=[...w.history.slice(0,w.currentStep+1),b],O=D.length>of?D.slice(D.length-of):D;return{history:O,currentStep:O.length-1}})},[]),h=(0,We.useCallback)((b,w)=>{let S=b.map(L=>I(T({},L),{selected:!1,className:"",data:I(T({},L.data),{hasError:!1})})),M=w.map(L=>I(T({},L),{data:I(T({},L.data),{hasError:!1})}));return{nodes:wo(S),edges:M}},[]),g=(0,We.useCallback)(()=>h(t(),o()),[t,o,h]),y=(0,rf.useDebouncedCallback)(()=>{let b=g();m(b)},ix),v=(0,We.useCallback)((b,w)=>{if(!e)return;if(c.length===0){let M=g();l({history:[M],currentStep:0})}if(b==="forceSave"){if(w){m(h(w.nodes,w.edges));return}y();return}b.some(M=>M.type==="select")||oi(b)||y()},[e,y,c.length,g,m,h]);(0,We.useEffect)(()=>{if(e&&c.length===0){let b=g();l({history:[b],currentStep:0})}},[e,c.length,g]);let _=(0,We.useCallback)(b=>{l({history:b||[],currentStep:0})},[]),N=(0,We.useCallback)(()=>{l({history:[],currentStep:0})},[]);return(0,We.useEffect)(()=>{if(i!=="edit")return;let b=a.current;if(!b)return;let w=S=>{if(!b.contains(document.activeElement)||!(S.ctrlKey||S.metaKey))return;let D=S.key.toLowerCase();if(S.shiftKey&&D==="z"){S.preventDefault(),E();return}D==="z"&&(S.preventDefault(),x())};return b.addEventListener("keydown",w),()=>{b.removeEventListener("keydown",w)}},[x,E,i,a]),{history:c,undo:x,redo:E,canUndo:u,canRedo:p,saveHistory:v,resetHistory:_,clearHistory:N}};var af=()=>{let[e,t,o]=(0,go.useNodesState)([]),[n,r,i]=(0,go.useEdgesState)([]),{getNode:a}=(0,go.useReactFlow)(),s=(0,go.useStoreApi)(),{instanceId:l,isInitialized:c,setIsConnecting:d,onElementClick:u}=Y(),{updateHelperLines:p,HelperLines:f}=ki(),{undo:x,redo:E,canUndo:m,canRedo:h,saveHistory:g}=sf(c),{onNodeDrag:y,onDrop:v,onDragOver:_,onDragLeave:N,onNodeDragStop:b,onNodeDragStart:w}=Bp({nodes:e,setNodes:t,setEdges:r,saveHistory:g}),{isValidConnection:S,onConnect:M,onReconnect:L,onReconnectStart:D,onReconnectEnd:O,setReconnectingEdge:R,clearReconnectingEdge:V}=yp({setEdges:r,saveHistory:g}),{handleValidationComplete:G,clearValidation:B,dismissValidationPanel:A,validateDiagram:C,getIsValidating:k,getIsClearingValidation:P}=Ap(),{importFromLia:K}=fs(),{handleTasksStatus:Z,handleClearTaskStatus:U}=tf(),{clearPathEdges:H}=Ao(),{emitElementChanges:q,handleNodeChanges:z,handleEdgeChanges:W}=ds(),X=gl();Dp({saveHistory:g}),Wp({saveHistory:g}),jp();let $=(0,Dt.useCallback)(()=>{t([]),r([]),H(),setTimeout(X,0)},[t,r,H,X]),{selectElements:ne,clearSelection:ce}=Tt(),{importFromMxGraph:oe,exportToMxGraph:re}=Pt(),{configureElement:Ae,getConfigureElement:ae}=Ji(),Se=(0,Dt.useCallback)(ze=>{ze!=null&&ze.id&&ne([ze.id])},[ne]),{sendMessage:j}=gs({LIA_CREATE_DIAGRAM:K,CLEAR_DIAGRAM:$,TASKS_STATUS:Z,CLEAR_TASKS_STATUS:U,EXTERNAL_TASK_SELECT:Se}),de=(0,Dt.useCallback)(()=>e.length+n.length,[e,n]);(0,Dt.useEffect)(()=>(St.set(l,{importFromMxGraph:oe,exportToMxGraph:re,selectElements:ne,clearSelection:ce,configureElement:Ae,getConfigureElement:ae,getElementsCount:de,setReconnectingEdge:R,clearReconnectingEdge:V}),()=>{St.delete(l)}),[l,oe,re,ne,ce,Ae,ae,de,R,V]);let ke=(0,Dt.useCallback)((ze,_t)=>{if(_t.type!=="TASK"&&_t.type!=="GATEWAY")return;let zr=ae(_t.id);zr&&(u==null||u(zr)),_t.type==="TASK"&&j("SELECT_TASK",{id:_t.id})},[ae,u,j]),ut=(0,Dt.useCallback)((ze,_t)=>{if(_t.type!=="SEQUENCE_EDGE")return;let zr=a(_t.source),dm=a(_t.target),{isFromStartEvent:um,isGatewayToGateway:pm,isActiviyToAndGateway:fm,isToEndEvent:mm}=ti(zr,dm);if(!(!um&&!pm&&!fm&&!mm))return;let Ba=ae(_t.id);Ba&&(u==null||u(Ba))},[ae,a,u]),bo=(0,Dt.useCallback)(ze=>{p(ze,e),o(ze),!oi(ze)&&(g(ze),P()||A(),k()||z(ze))},[e,g,P,A,p,z,k,o]),Vr=(0,Dt.useCallback)(ze=>{i(ze),g(ze),P()||A(),k()||W(ze)},[i,g,P,A,W,k]);Up(bo);let{onBeforeDelete:Hr,onNodesDelete:Gr,onEdgesDelete:Br}=Op({nodes:e,setNodes:t});return{nodes:e,setNodes:t,edges:n,setEdges:r,events:{isValidConnection:S,onConnect:M,onReconnect:L,onReconnectStart:D,onReconnectEnd:O,onDrop:v,onDragOver:_,onDragLeave:N,onNodeDrag:y,onNodeDragStop:b,onNodeDragStart:w,onNodeClick:ke,onEdgeClick:ut,onDropCapture:()=>{g("forceSave"),q(),A()},onConnectStart:()=>{d(!0)},onConnectEnd:()=>{d(!1),A()},onSelectionEnd:()=>setTimeout(()=>s.setState({nodesSelectionActive:!1}),0),onNodesChange:bo,onEdgesChange:Vr,onBeforeDelete:Hr,onNodesDelete:Gr,onEdgesDelete:Br},ui:{handleCloseValidationPanel:B},controls:{undo:x,redo:E,canUndo:m,canRedo:h},components:{HelperLines:f},actions:{saveHistory:g,selectElements:ne,clearSelection:ce,exportToMxGraph:re,validateDiagram:C,handleValidationComplete:G,setReconnectingEdge:R,clearReconnectingEdge:V}}};var lf=require("react"),cf=require("@xyflow/react");function hs(){return(0,cf.useStore)((0,lf.useCallback)(e=>e.nodes.length+e.edges.length>0,[]))}var df=require("@xyflow/react"),ho=require("react");var sx=".react-flow__node, .react-flow__edge, .react-flow__node-toolbar";function uf(e,t,o){let[n,r]=(0,ho.useState)(!1),i=(0,ho.useRef)(null),{getViewport:a,setViewport:s}=(0,df.useReactFlow)(),l=(0,ho.useCallback)(()=>{i.current=null,r(!1)},[]);return(0,ho.useEffect)(()=>{let c=e.current;if(!c)return;let d=f=>{if(!vr.some(E=>E===f.button)||t.current||o.current||(r(!0),!(f.target instanceof Element))||!f.target.closest(sx))return;f.preventDefault(),f.stopPropagation();let x=a();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&Aa)===0){l();return}s({x:x.viewportX+(f.clientX-x.pointerX),y:x.viewportY+(f.clientY-x.pointerY),zoom:x.zoom})}},p=f=>{(f.buttons&Aa)===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,a,s,l]),n}var Sa=require("react/jsx-runtime"),ys=({id:e,className:t})=>(0,Sa.jsx)("marker",{id:e,className:F("react-flow__arrowhead",t),viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"7",markerHeight:"7",orient:"auto",markerUnits:"userSpaceOnUse",fill:"currentColor",stroke:"currentColor",children:(0,Sa.jsx)("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});var Zo=require("react/jsx-runtime"),pf=()=>(0,Zo.jsx)("svg",{style:{position:"absolute",top:0,left:0},children:(0,Zo.jsxs)("defs",{children:[(0,Zo.jsx)(ys,{id:"sequence-edge-marker",className:"text-grey-500"}),(0,Zo.jsx)(ys,{id:"sequence-edge-marker-hovered",className:"text-grey-800"}),(0,Zo.jsx)(ys,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});var Eo=require("@produto-lecom/lecom-ui");var kr=require("@xyflow/react"),we=require("@produto-lecom/lecom-ui"),Rt=require("lucide-react"),xt=Xn(require("react"),1);var yo=require("@produto-lecom/lecom-ui");var Lr=(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))(Lr||{});var _s=require("@produto-lecom/lecom-ui"),Tf=require("@xyflow/react");var xs=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 ff({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let r="data:text/csv;charset=utf-8,"+[e,...t].map(a=>a.join(",")).join(`
|
|
43
|
+
`),i=encodeURI(r);Es(i,`${o}.csv`)}var Es=(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 mf(e){return e==null?void 0:e.replaceAll("
"," ")}var fL={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},gf={script:"SCRIPT",subprocess:"SUBPROCESS"},hf={"marker-loop":"LOOP"},yf={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL",inclusive:"EXCLUSIVE"};var Jo=({cell:e,type:t,variant:o="",attribute:n=""})=>{let{_attributes:r,mxGeometry:i}=e,{value:a,parent:s}=r,l=Number(i._attributes.width),c=Number(i._attributes.height),d=s==="1"?void 0:s;return{id:r.id,parentId:d,type:t,data:{label:a||"",variant:o,attribute:n},position:{x:Number(i._attributes.x)||0,y:Number(i._attributes.y)||0},width:l,height:c,measured:{width:l,height:c}}},lx=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=te.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=te.START_EVENT.MIN_HEIGHT,{node:Jo({cell:e,type:"START_EVENT"}),status:n,originalType:o}},cx=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=te.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=te.END_EVENT.MIN_HEIGHT,{node:Jo({cell:e,type:"END_EVENT"}),status:n,originalType:o}},dx=(e,t)=>{let{id:o,subType:n,style:r}=e==null?void 0:e._attributes,i=gf[n],a=t.get(o)||"",s=hf[a]||"",l=s==="LOOP",c="imported";return!["script","none"].includes(n)&&!l&&(c="adapted"),e.mxGeometry._attributes.width=eo(e.mxGeometry._attributes.width||0,te.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=eo(e.mxGeometry._attributes.height||0,te.TASK.MIN_HEIGHT),{node:Jo({cell:e,type:"TASK",variant:i,attribute:s}),status:c,originalType:r}},ux=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=yf[o],r=["none","inclusive","event-based"],i="imported";return r.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=te.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=te.GATEWAY.MIN_HEIGHT,{node:Jo({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},px=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:Jo({cell:e,type:"LANE"}),status:"imported",originalType:t}},fx=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=eo(e.mxGeometry._attributes.width||0,te.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=eo(e.mxGeometry._attributes.height||0,te.ANNOTATION.MIN_HEIGHT),{node:Jo({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},xf=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=te.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=te.UNSUPPORTED.MIN_HEIGHT,{node:Jo({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},Ef=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return I(T({},rt),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},_f={TASK:dx,GATEWAY:ux,START_EVENT:lx,END_EVENT:cx,LANE:px,ANNOTATION:fx};var mx=e=>{let t=new Map,o=Object.values(Lr),n=[],r=new Map;e.forEach(s=>{var c;let l=(c=s._attributes)==null?void 0:c.type;if(l==="MARKER"){r.set(s._attributes.parent,s._attributes.style);return}if(o.includes(l)){n.push(s);return}});let i=[],a=[];for(let s of n){let{type:l}=s._attributes,c=_f[l]||xf,{node:d,status:u,originalType:p}=c(s,r);a.push(d),i.push({originalType:p,type:d.type,variant:d.data.variant,value:mf(d.data.label),status:u})}return{nodes:a,governanceIdToNodeIdMap:t,summary:i}},gx=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>Ef(r,t)),hx=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=mx(t.root.mxCell),i=gx(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},yx=async e=>{let t=await xs(e),o=Wi(t);if(!o)throw new Error("EMPTY_FILE");let{metadata:n,mxGraphModel:r}=o.modeler||{},i=(n==null?void 0:n.app)&&(n==null?void 0:n.diagramType)&&(n==null?void 0:n.version),a=r==null?void 0:r.root;if(!i||!a)throw new Error("INVALID_FILE");if(!Object.keys(r.root.mxCell||{}).length)throw new Error("CONTAIN_NO_CELLS");return{metadata:n,mxGraphModel:r}},bf=async e=>{try{let t=await yx(e),{nodes:o,edges:n,summary:r}=hx(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};var Nf=require("react/jsx-runtime"),vf=()=>{let{t:e}=(0,_s.useTranslation)(),{toast:t}=Oe(),{setNodes:o,setEdges:n}=(0,Tf.useReactFlow)(),{fitToNodes:r}=fo(),i=s=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],c=s.map(d=>[d.originalType,d.value,e(`adapter.governance.report.status.${d.status.toLowerCase()}`)]);t({variant:"warning",content:e("adapter.governance.success.incompatible_cells"),duration:1e3*60*1,action:(0,Nf.jsx)(_s.Button,{size:"small",variant:"ghost",onClick:()=>ff({columns:l,rows:c,fileName:"governance-imported-cells"}),children:e("adapter.governance.action.download")})})};return{importFromGovernance:async s=>{try{let{nodes:l,edges:c,summary:d}=await bf(s);if(o(p=>p.concat(l)),n(p=>p.concat(c)),r(l),d.some(p=>p.status==="unsupported")){i(d);return}t({variant:"success",content:e("adapter.governance.success.default")})}catch(l){let c=l instanceof Error?l.message:"DEFAULT";t({variant:"error",content:e(`adapter.governance.error.${c}`)})}}}};var wf=require("@produto-lecom/lecom-ui"),If=require("react");var Qo=require("react/jsx-runtime"),Af=s=>{var l=s,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,a=bt(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=(0,If.useRef)(null),d=p=>{let f=p.target.files;f!=null&&f.length&&i(f),c.current&&(c.current.value="")};return(0,Qo.jsxs)(Qo.Fragment,{children:[(0,Qo.jsx)(wf.Button,I(T({disabled:n,onClick:p=>{var f;(f=c.current)==null||f.click(),r==null||r(p)}},a),{children:e})),(0,Qo.jsx)("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};var jo=require("react/jsx-runtime"),Cf=({disabled:e=!1})=>{let{t}=(0,yo.useTranslation)(),{toast:o}=Oe(),{importFromGovernance:n}=vf(),r=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},i=a=>{let s=a[0];if(!s){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}n(s)};return(0,jo.jsxs)(yo.Tooltip,{children:[(0,jo.jsx)(yo.TooltipTrigger,{asChild:!0,children:(0,jo.jsx)(Af,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:(0,jo.jsx)(Za,{})})}),(0,jo.jsx)(yo.TooltipContent,{color:"black",children:t(e?"adapter.governance.error.ALREADY_INITIALIZED":"editor.controls.actions.import_governance")})]})};var Sf=require("react/jsx-runtime"),Ma=({shortcut:e})=>(0,Sf.jsx)("span",{className:"min-h-7.5 inline-flex justify-center items-center py-0.5 px-1.5 bg-grey-100 border border-grey-300 font-mono text-gray-800 shadow-lg rounded-md text-grey-900",children:e});var se=require("@produto-lecom/lecom-ui"),xo=require("lucide-react"),Vf=require("react");var Df=require("@produto-lecom/lecom-ui"),kf=require("@xyflow/react"),Dr=require("html-to-image"),Rf=require("react");var Mf=require("@xyflow/react"),Pf=(e,t=0)=>{let o=(0,Mf.getNodesBounds)(e),n=document.querySelectorAll(".react-flow__edge-path"),r=o.x,i=o.y,a=o.x+o.width,s=o.y+o.height;return n.forEach(l=>{let c=l.getBBox();r=Math.min(r,c.x),i=Math.min(i,c.y),a=Math.max(a,c.x+c.width),s=Math.max(s,c.y+c.height)}),{x:r,y:i,width:a-r+t*2,height:s-i+t*2}};var xx=3,Pa="diagram",La=50,Ex=e=>e instanceof Element&&e.closest("[data-export-hidden]")!==null,Da=e=>!Ex(e),_x=96,bx=25.4,Tx="sequence-edge-marker",Lf=e=>e*bx/_x,vx=e=>{let t=document.getElementById(Tx);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},Of=()=>{let{t:e}=(0,Df.useTranslation)(),{toast:t}=Oe(),{getEdges:o,getNodes:n}=(0,kf.useReactFlow)(),{clearSelection:r}=Tt(),{setIsExporting:i}=Y(),[a,s]=(0,Rf.useState)({png:!1,html:!1,print:!1}),l=()=>{let{x:f,y:x,width:E,height:m}=Pf(n(),La),h=La-f,g=La-x;return{width:E,height:m,style:{width:`${E}px`,height:`${m}px`,transform:`translate(${h}px, ${g}px)`,transformOrigin:"top left"}}},c=async(f,x)=>{s(E=>I(T({},E),{[x]:!0})),i(!0),await r();try{let E=n(),m=o();if(E.length===0&&m.length===0){t({content:e("editor.controls.actions.export.feedback.empty"),variant:"warning"});return}let h=Ad();if(!h)throw new Error("Flow element not found");let g=l(),y=vx(h);try{return await f(h,g)}finally{y==null||y.remove()}}catch(E){console.error("Diagram export failed",E),t({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{i(!1),s(E=>I(T({},E),{[x]:!1}))}};return{exportAsPng:async(f=Pa)=>{await c(async(x,E)=>{let m=await(0,Dr.toPng)(x,I(T({},E),{backgroundColor:"#fcfcfc",skipFonts:!0,filter:Da}));Es(m,`${f}.png`)},"png")},exportAsHtml:async(f=Pa)=>{await c(async(x,E)=>{let m=await(0,Dr.toSvg)(x,I(T({},E),{backgroundColor:"#fcfcfc",skipFonts:!0,filter:Da})),h=`
|
|
44
44
|
<!DOCTYPE html>
|
|
45
45
|
<html>
|
|
46
46
|
<head>
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
<body>
|
|
68
68
|
<img src="${m}" alt="${f}" />
|
|
69
69
|
</body>
|
|
70
|
-
</html>`,g=new Blob([h],{type:"text/html"}),y=URL.createObjectURL(g);Es(y,`${f}.html`),window.setTimeout(()=>URL.revokeObjectURL(y),1e4)},"html")},printDiagram:async(f=Pa)=>{await c(async(x,E)=>{var S;let m=await(0,Dr.toPng)(x,I(T({},E),{backgroundColor:"#fcfcfc",pixelRatio:
|
|
70
|
+
</html>`,g=new Blob([h],{type:"text/html"}),y=URL.createObjectURL(g);Es(y,`${f}.html`),window.setTimeout(()=>URL.revokeObjectURL(y),1e4)},"html")},printDiagram:async(f=Pa)=>{await c(async(x,E)=>{var S;let m=await(0,Dr.toPng)(x,I(T({},E),{backgroundColor:"#fcfcfc",pixelRatio:xx,skipFonts:!0,filter:Da})),h=document.createElement("iframe");h.style.position="fixed",h.style.right="0",h.style.bottom="0",h.style.width="0",h.style.height="0",h.style.border="0",document.body.appendChild(h);let g=(S=h.contentWindow)==null?void 0:S.document;if(!g)throw document.body.removeChild(h),new Error("Unable to access print iframe document");let y=Lf(E.width).toFixed(2),v=Lf(E.height).toFixed(2),_=g.createElement("style");_.textContent=`
|
|
71
71
|
@page {
|
|
72
72
|
size: ${y}mm ${v}mm;
|
|
73
73
|
margin: 0;
|
|
@@ -83,11 +83,11 @@
|
|
|
83
83
|
height: 100%;
|
|
84
84
|
object-fit: contain;
|
|
85
85
|
}
|
|
86
|
-
`,g.head.appendChild(_),g.title=f;let N=g.createElement("img");N.alt="Diagram",g.body.appendChild(N),await new Promise((M,L)=>{let D=!1,O=R=>{D||(D=!0,R?L(R):M())};N.onload=()=>O(),N.onerror=()=>O(new Error("Failed to load print image")),N.src=m,N.complete&&N.naturalWidth>0&&O()});let b=h.contentWindow;if(!b)throw document.body.removeChild(h),new Error("Unable to access print iframe window");let w=()=>{h.parentNode&&document.body.removeChild(h)};b.addEventListener("afterprint",w,{once:!0}),window.setTimeout(w,6e4),b.focus(),b.print()},"print")},isPrintingPng:a.png,isPrintingHtml:a.html,isPrinting:a.print}};var fe=require("react/jsx-runtime");function Hf(){let{t:e}=(0,se.useTranslation)(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:a}=Of(),[s,l]=(0,Vf.useState)(!1);return(0,fe.jsxs)(se.DropdownMenu,{modal:!1,open:s,onOpenChange:l,children:[(0,fe.jsx)(se.DropdownMenuTrigger,{asChild:!0,children:(0,fe.jsx)("div",{children:(0,fe.jsxs)(se.Tooltip,{children:[(0,fe.jsx)(se.TooltipTrigger,{asChild:!0,children:(0,fe.jsx)(se.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:(0,fe.jsx)(xo.FolderOutputIcon,{})})}),!s&&(0,fe.jsx)(se.TooltipContent,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),(0,fe.jsxs)(se.DropdownMenuContent,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[(0,fe.jsxs)(se.Tooltip,{children:[(0,fe.jsx)(se.TooltipTrigger,{asChild:!0,children:(0,fe.jsx)(se.DropdownMenuItem,{className:"p-1.5",disabled:i,onClick:()=>t(),children:(0,fe.jsx)(xo.FileImageIcon,{})})}),(0,fe.jsx)(se.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),(0,fe.jsxs)(se.Tooltip,{children:[(0,fe.jsx)(se.TooltipTrigger,{asChild:!0,children:(0,fe.jsx)(se.DropdownMenuItem,{className:"p-1.5",disabled:a,onClick:()=>o(),children:(0,fe.jsx)(xo.FileCodeIcon,{})})}),(0,fe.jsx)(se.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),(0,fe.jsxs)(se.Tooltip,{children:[(0,fe.jsx)(se.TooltipTrigger,{asChild:!0,children:(0,fe.jsx)(se.DropdownMenuItem,{className:"p-1.5",disabled:r,onClick:()=>n(),children:(0,fe.jsx)(xo.PrinterIcon,{})})}),(0,fe.jsx)(se.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}var ge=require("@produto-lecom/lecom-ui"),Wf=require("@xyflow/react"),
|
|
86
|
+
`,g.head.appendChild(_),g.title=f;let N=g.createElement("img");N.alt="Diagram",g.body.appendChild(N),await new Promise((M,L)=>{let D=!1,O=R=>{D||(D=!0,R?L(R):M())};N.onload=()=>O(),N.onerror=()=>O(new Error("Failed to load print image")),N.src=m,N.complete&&N.naturalWidth>0&&O()});let b=h.contentWindow;if(!b)throw document.body.removeChild(h),new Error("Unable to access print iframe window");let w=()=>{h.parentNode&&document.body.removeChild(h)};b.addEventListener("afterprint",w,{once:!0}),window.setTimeout(w,6e4),b.focus(),b.print()},"print")},isPrintingPng:a.png,isPrintingHtml:a.html,isPrinting:a.print}};var fe=require("react/jsx-runtime");function Hf(){let{t:e}=(0,se.useTranslation)(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:a}=Of(),[s,l]=(0,Vf.useState)(!1);return(0,fe.jsxs)(se.DropdownMenu,{modal:!1,open:s,onOpenChange:l,children:[(0,fe.jsx)(se.DropdownMenuTrigger,{asChild:!0,children:(0,fe.jsx)("div",{children:(0,fe.jsxs)(se.Tooltip,{children:[(0,fe.jsx)(se.TooltipTrigger,{asChild:!0,children:(0,fe.jsx)(se.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:(0,fe.jsx)(xo.FolderOutputIcon,{})})}),!s&&(0,fe.jsx)(se.TooltipContent,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),(0,fe.jsxs)(se.DropdownMenuContent,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[(0,fe.jsxs)(se.Tooltip,{children:[(0,fe.jsx)(se.TooltipTrigger,{asChild:!0,children:(0,fe.jsx)(se.DropdownMenuItem,{className:"p-1.5",disabled:i,onClick:()=>t(),children:(0,fe.jsx)(xo.FileImageIcon,{})})}),(0,fe.jsx)(se.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),(0,fe.jsxs)(se.Tooltip,{children:[(0,fe.jsx)(se.TooltipTrigger,{asChild:!0,children:(0,fe.jsx)(se.DropdownMenuItem,{className:"p-1.5",disabled:a,onClick:()=>o(),children:(0,fe.jsx)(xo.FileCodeIcon,{})})}),(0,fe.jsx)(se.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),(0,fe.jsxs)(se.Tooltip,{children:[(0,fe.jsx)(se.TooltipTrigger,{asChild:!0,children:(0,fe.jsx)(se.DropdownMenuItem,{className:"p-1.5",disabled:r,onClick:()=>n(),children:(0,fe.jsx)(xo.PrinterIcon,{})})}),(0,fe.jsx)(se.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}var ge=require("@produto-lecom/lecom-ui"),Wf=require("@xyflow/react"),Bn=require("lucide-react"),en=require("react");var Gf=require("react");var Bf=()=>{let{exportToMxGraph:e,importFromMxGraph:t,buildEmptyDiagram:o,publishNow:n}=Pt(),{setIsImporting:r}=Y();return{runImport:(0,Gf.useCallback)(async a=>{let s=e();r(!0);try{await n(o());let l=await a();await n(l)}catch(l){try{await t(s),await n(s)}catch(c){console.error("Falha ao restaurar o diagrama anterior apos erro no import:",c)}throw l}finally{r(!1)}},[e,t,o,n,r])}};var Be=require("@produto-lecom/lecom-ui"),kt=require("react/jsx-runtime"),zf=({open:e,loading:t,onConfirm:o,onCancel:n})=>{let{t:r}=(0,Be.useTranslation)();return(0,kt.jsx)(Be.Dialog,{open:e,onOpenChange:i=>!i&&!t&&n(),children:(0,kt.jsxs)(Be.DialogContent,{className:"max-w-md",children:[(0,kt.jsxs)(Be.DialogHeader,{children:[(0,kt.jsx)(Be.DialogTitle,{children:r("editor.modals.import_confirm.title")}),(0,kt.jsx)(Be.DialogDescription,{children:r("editor.modals.import_confirm.content")})]}),(0,kt.jsxs)(Be.DialogFooter,{children:[(0,kt.jsx)(Be.Button,{variant:"ghost",color:"grey",onClick:n,disabled:t,children:r("editor.modals.import_confirm.cancel")}),(0,kt.jsx)(Be.Button,{variant:"filled",color:"blue",onClick:o,disabled:t,children:r(t?"editor.modals.import_confirm.loading":"editor.modals.import_confirm.confirm")})]})]})})};var ka=require("react"),De=require("@produto-lecom/lecom-ui");var Ff=e=>{if(!e)return"";let t=e.trim();return t=t.replace(/```[a-zA-Z]*\s*/g,"").replace(/```/g,""),t=t.replace(/^\s*(graph|flowchart)\s+[A-Za-z]{1,2}\s*\r?\n/i,""),t.trim()};var dt=require("react/jsx-runtime"),Nx=`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>`,Yf=({open:e,onOpenChange:t,onSubmit:o})=>{let{t:n}=(0,De.useTranslation)(),[r,i]=(0,ka.useState)(""),[a,s]=(0,ka.useState)(null),l=d=>{d||(i(""),s(null)),t(d)},c=()=>{let d=Ff(r);if(!d){s(n("editor.modals.mermaid_import.error_empty"));return}o(d),l(!1)};return(0,dt.jsx)(De.Dialog,{open:e,onOpenChange:l,children:(0,dt.jsxs)(De.DialogContent,{className:"w-[90vw] max-w-4xl",children:[(0,dt.jsxs)(De.DialogHeader,{children:[(0,dt.jsx)(De.DialogTitle,{children:n("editor.modals.mermaid_import.title")}),(0,dt.jsx)(De.DialogDescription,{children:n("editor.modals.mermaid_import.description")})]}),(0,dt.jsx)(De.Textarea,{value:r,onChange:d=>{i(d.target.value),a&&s(null)},placeholder:vx,rows:16,className:"max-h-[60vh] min-h-[360px] resize-y font-mono"}),a&&(0,dt.jsx)("p",{className:"text-sm text-red-500",children:a}),(0,dt.jsxs)(De.DialogFooter,{children:[(0,dt.jsx)(De.Button,{variant:"ghost",color:"grey",onClick:()=>l(!1),children:n("editor.modals.mermaid_import.cancel")}),(0,dt.jsx)(De.Button,{variant:"filled",color:"blue",onClick:c,children:n("editor.modals.mermaid_import.generate")})]})]})})};var de=require("react/jsx-runtime"),Nx=".xml,text/xml,application/xml";function Xf(){let{t:e}=(0,ge.useTranslation)(),{getNodes:t}=(0,Wf.useReactFlow)(),{importFromMxGraph:o}=Pt(),{importFromLia:n}=fs(),{runImport:r}=Bf(),{isImporting:i}=Y(),{toast:a}=Oe(),[s,l]=(0,en.useState)(!1),[c,d]=(0,en.useState)(!1),[u,p]=(0,en.useState)(!1),f=(0,en.useRef)(null),x=(0,en.useRef)(null),E=async _=>{try{await r(_)}catch(N){console.error("Falha ao importar o diagrama:",N),a({variant:"error",content:e("editor.controls.actions.import.feedback.error")})}},m=_=>{if(t().length===0){E(_);return}x.current=_,p(!0)},h=async()=>{let _=x.current;_&&(await E(_),x.current=null,p(!1))},g=()=>{x.current=null,p(!1)},y=async _=>{var w;let N=(w=_.target.files)==null?void 0:w[0];if(_.target.value="",!N)return;let b;try{b=await xs(N)}catch(S){console.error("Falha ao ler o arquivo XML:",S),a({variant:"error",content:e("editor.controls.actions.import.feedback.error")});return}m(async()=>(await o(b),b))},v=_=>{m(()=>n(_))};return(0,de.jsxs)(de.Fragment,{children:[(0,de.jsxs)(ge.DropdownMenu,{modal:!1,open:s,onOpenChange:l,children:[(0,de.jsx)(ge.DropdownMenuTrigger,{asChild:!0,children:(0,de.jsx)("div",{children:(0,de.jsxs)(ge.Tooltip,{children:[(0,de.jsx)(ge.TooltipTrigger,{asChild:!0,children:(0,de.jsx)(ge.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:i,children:(0,de.jsx)(Gn.ClipboardPasteIcon,{})})}),!s&&(0,de.jsx)(ge.TooltipContent,{color:"black",children:e("editor.controls.actions.import.title")})]})})}),(0,de.jsxs)(ge.DropdownMenuContent,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[(0,de.jsxs)(ge.Tooltip,{children:[(0,de.jsx)(ge.TooltipTrigger,{asChild:!0,children:(0,de.jsx)(ge.DropdownMenuItem,{className:"p-1.5",onClick:()=>{var _;return(_=f.current)==null?void 0:_.click()},children:(0,de.jsx)(Gn.FileCodeIcon,{})})}),(0,de.jsx)(ge.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.import.xml")})]}),(0,de.jsxs)(ge.Tooltip,{children:[(0,de.jsx)(ge.TooltipTrigger,{asChild:!0,children:(0,de.jsx)(ge.DropdownMenuItem,{className:"p-1.5",onClick:()=>d(!0),children:(0,de.jsx)(Gn.CircleIcon,{})})}),(0,de.jsx)(ge.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.import.mermaid")})]})]})]}),(0,de.jsx)("input",{ref:f,type:"file",className:"sr-only",accept:Nx,onChange:y}),(0,de.jsx)(Yf,{open:c,onOpenChange:d,onSubmit:v}),(0,de.jsx)(zf,{open:u,loading:i,onConfirm:h,onCancel:g})]})}var bs=require("react"),he=require("@produto-lecom/lecom-ui"),Uf=require("@xyflow/react"),Bn=require("lucide-react");var Ce=require("react/jsx-runtime");function $f(){let{t:e}=(0,he.useTranslation)(),{getNodes:t,getEdges:o,setNodes:n}=(0,Uf.useReactFlow)(),{fitToNodes:r}=fo(),{toast:i}=Oe(),[a,s]=(0,bs.useState)(!1),l=(0,bs.useCallback)(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 h,g,y,v;return I(T({},m),{width:(g=m.width)!=null?g:(h=m.measured)==null?void 0:h.width,height:(v=m.height)!=null?v:(y=m.measured)==null?void 0:y.height})}),{nodes:f}=Fi(p,o(),c),x=new Map(f.map(m=>[m.id,m.position])),E=d.map(m=>{var h;return I(T({},m),{position:(h=x.get(m.id))!=null?h:m.position})});n(E),r(E)},[t,o,n,r,i,e]);return(0,Ce.jsxs)(he.DropdownMenu,{modal:!1,open:a,onOpenChange:s,children:[(0,Ce.jsx)(he.DropdownMenuTrigger,{asChild:!0,children:(0,Ce.jsx)("div",{children:(0,Ce.jsxs)(he.Tooltip,{children:[(0,Ce.jsx)(he.TooltipTrigger,{asChild:!0,children:(0,Ce.jsx)(he.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:(0,Ce.jsx)(Bn.NetworkIcon,{})})}),!a&&(0,Ce.jsx)(he.TooltipContent,{color:"black",children:e("editor.controls.actions.organize.title")})]})})}),(0,Ce.jsxs)(he.DropdownMenuContent,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[(0,Ce.jsxs)(he.Tooltip,{children:[(0,Ce.jsx)(he.TooltipTrigger,{asChild:!0,children:(0,Ce.jsx)(he.DropdownMenuItem,{className:"p-1.5",onClick:()=>l("TB"),children:(0,Ce.jsx)(Bn.AlignVerticalJustifyStartIcon,{})})}),(0,Ce.jsx)(he.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.organize.vertical")})]}),(0,Ce.jsxs)(he.Tooltip,{children:[(0,Ce.jsx)(he.TooltipTrigger,{asChild:!0,children:(0,Ce.jsx)(he.DropdownMenuItem,{className:"p-1.5",onClick:()=>l("LR"),children:(0,Ce.jsx)(Bn.AlignHorizontalJustifyStartIcon,{})})}),(0,Ce.jsx)(he.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.organize.horizontal")})]})]})]})}var ee=require("react/jsx-runtime"),Ra=xt.default.memo(({hasContent:e,validateDiagram:t,handleValidationComplete:o})=>{let{t:n}=(0,we.useTranslation)(),{clearSelection:r}=Tt(),{mode:i,containerRef:a,featureFlags:s,isMinimapOpen:l,setIsMinimapOpen:c,isMoveTool:d,isHandTool:u,setIsMoveTool:p,setIsHandTool:f}=Y(),{getNodes:x,getEdges:E}=(0,kr.useReactFlow)(),m=(0,kr.useKeyPress)(["v","V"],{target:a==null?void 0:a.current}),h=(0,kr.useKeyPress)(["h","H"],{target:a==null?void 0:a.current}),g=(0,xt.useCallback)(()=>{r(),f(!0),p(!1)},[r,f,p]),y=(0,xt.useCallback)(()=>{p(!0),f(!1)},[p,f]),[v,_]=(0,xt.useState)(!1),N=(0,xt.useCallback)(async()=>{_(!0);try{let b=x(),w=E(),S=await t({nodes:b,edges:w});o(S)}finally{_(!1)}},[x,E,t,o]);return(0,xt.useEffect)(()=>{m&&!d&&i==="edit"&&y()},[m,y,d,i]),(0,xt.useEffect)(()=>{h&&!u&&i==="edit"&&g()},[h,g,u,i]),(0,ee.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[i==="edit"&&(0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsxs)(we.Tooltip,{children:[(0,ee.jsx)(we.TooltipTrigger,{asChild:!0,children:(0,ee.jsx)(we.Button,{size:"small",variant:"ghost",color:"grey",className:F(d&&"bg-grey-400"),iconButton:!0,onClick:y,children:(0,ee.jsx)(Rt.MousePointerIcon,{})})}),(0,ee.jsxs)(we.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[n("editor.controls.actions.move_tool"),(0,ee.jsx)(Ma,{shortcut:"V"})]})]}),(0,ee.jsxs)(we.Tooltip,{children:[(0,ee.jsx)(we.TooltipTrigger,{asChild:!0,children:(0,ee.jsx)(we.Button,{size:"small",variant:"ghost",color:"grey",className:F(u&&"bg-grey-400"),iconButton:!0,onClick:g,children:(0,ee.jsx)(Rt.HandIcon,{})})}),(0,ee.jsxs)(we.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[n("editor.controls.actions.hand_tool")," ",(0,ee.jsx)(Ma,{shortcut:"H"})]})]})]}),(0,ee.jsx)(Hf,{}),i==="edit"&&(0,ee.jsxs)(ee.Fragment,{children:[(s==null?void 0:s.importDiagramMermaidEnabled)&&(0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsx)(Xf,{}),(0,ee.jsx)($f,{})]}),(0,ee.jsxs)(we.Tooltip,{children:[(0,ee.jsx)(we.TooltipTrigger,{asChild:!0,children:(0,ee.jsx)(we.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:v,onClick:N,children:v?(0,ee.jsx)(Rt.Loader2Icon,{className:"animate-spin"}):(0,ee.jsx)(Rt.ListCheckIcon,{})})}),(0,ee.jsx)(we.TooltipContent,{color:"black",children:n(v?"editor.controls.actions.check_loading":"editor.controls.actions.check")})]}),(0,ee.jsx)(Cf,{disabled:e})]}),(0,ee.jsxs)(we.Tooltip,{children:[(0,ee.jsx)(we.TooltipTrigger,{asChild:!0,children:(0,ee.jsx)(we.Button,{size:"small",variant:"ghost",color:"grey",className:F(l&&"bg-grey-400"),iconButton:!0,onClick:()=>c(!l),children:(0,ee.jsx)(Rt.MapIcon,{})})}),(0,ee.jsx)(we.TooltipContent,{color:"black",children:n(l?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})});Ra.displayName="ActionsControl";var Kf=Wn(require("react"),1),Ke=require("@produto-lecom/lecom-ui"),Ts=require("lucide-react"),tt=require("react/jsx-runtime"),Oa=Kf.default.memo(({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=(0,Ke.useTranslation)();return(0,tt.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,tt.jsxs)(Ke.Tooltip,{children:[(0,tt.jsx)(Ke.TooltipTrigger,{asChild:!0,children:(0,tt.jsx)(Ke.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:(0,tt.jsx)(Ts.UndoIcon,{})})}),(0,tt.jsx)(Ke.TooltipContent,{color:"black",children:r("editor.controls.history.undo")})]}),(0,tt.jsxs)(Ke.Tooltip,{children:[(0,tt.jsx)(Ke.TooltipTrigger,{asChild:!0,children:(0,tt.jsx)(Ke.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:(0,tt.jsx)(Ts.RedoIcon,{})})}),(0,tt.jsx)(Ke.TooltipContent,{color:"black",children:r("editor.controls.history.redo")})]})]})});Oa.displayName="HistoryControl";var qf=require("@xyflow/react"),Ie=require("@produto-lecom/lecom-ui"),zn=require("lucide-react");var be=require("react/jsx-runtime"),Zf=()=>{let{t:e}=(0,Ie.useTranslation)(),t=!hs(),{zoomIn:o,zoomOut:n,zoomTo:r,fitView:i}=(0,qf.useReactFlow)();return(0,be.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,be.jsxs)(Ie.Tooltip,{children:[(0,be.jsx)(Ie.TooltipTrigger,{asChild:!0,children:(0,be.jsx)(Ie.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>i(),children:(0,be.jsx)(zn.ScanIcon,{})})}),(0,be.jsx)(Ie.TooltipContent,{color:"black",children:e("editor.controls.zoom.fit")})]}),(0,be.jsxs)(Ie.Tooltip,{children:[(0,be.jsx)(Ie.TooltipTrigger,{asChild:!0,children:(0,be.jsx)(Ie.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>n(),children:(0,be.jsx)(zn.ZoomOut,{})})}),(0,be.jsx)(Ie.TooltipContent,{color:"black",children:e("editor.controls.zoom.out")})]}),(0,be.jsxs)(Ie.Tooltip,{children:[(0,be.jsx)(Ie.TooltipTrigger,{asChild:!0,children:(0,be.jsx)(Ie.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>r(1),children:(0,be.jsx)(el,{})})}),(0,be.jsx)(Ie.TooltipContent,{color:"black",children:e("editor.controls.zoom.reset")})]}),(0,be.jsxs)(Ie.Tooltip,{children:[(0,be.jsx)(Ie.TooltipTrigger,{asChild:!0,children:(0,be.jsx)(Ie.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>o(),children:(0,be.jsx)(zn.ZoomIn,{})})}),(0,be.jsx)(Ie.TooltipContent,{color:"black",children:e("editor.controls.zoom.in")})]})]})};var Jf=require("@xyflow/react"),tn=require("react/jsx-runtime"),Qf=()=>(0,tn.jsxs)(Jf.ViewportPortal,{children:[(0,tn.jsxs)("svg",{"data-export-hidden":!0,width:"20",height:"20",viewBox:"0 0 20 20",className:"text-grey-400 -translate-x-1/2 -translate-y-1/2 pointer-events-none",children:[(0,tn.jsx)("line",{x1:"0",y1:"10",x2:"20",y2:"10",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"}),(0,tn.jsx)("line",{x1:"10",y1:"0",x2:"10",y2:"20",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"})]}),(0,tn.jsx)("div",{"data-export-hidden":!0,className:"absolute top-1 left-1 text-xs font-medium text-grey-400 bg-white/70 px-1 rounded-sm pointer-events-none",children:"0,0"})]});var jf=require("@xyflow/react"),Ot=require("@produto-lecom/lecom-ui"),vs=require("react");var em=require("lucide-react");var Et=require("react/jsx-runtime"),tm=()=>{let e=(0,vs.useRef)(null),{t}=(0,Ot.useTranslation)(),{setDraggableNode:o}=An(),n=(0,jf.useStore)(c=>c.nodes.some(d=>d.type==="START_EVENT")),{setIsDragging:r}=Y(),[i,a]=(0,vs.useState)(void 0),s=[{type:"START_EVENT",icon:Zr,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:nn,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:$n,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:Kn,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SERVICE_TASK",icon:em.Bot,label:t("bpmn.task.variant.service_task")},{type:"TASK",variant:"SCRIPT",icon:ol,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:tl,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:an,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:cn,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:rn,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:ja,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:$r,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),a((0,Et.jsx)(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return(0,Et.jsxs)("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[(0,Et.jsx)("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:s.map((c,d)=>{let u=c.type==="START_EVENT"&&n,p=u?t("editor.toolbar.start_event_already_exists"):c.label;return(0,Et.jsxs)(Ot.Tooltip,{children:[(0,Et.jsx)(Ot.TooltipTrigger,{asChild:!0,children:(0,Et.jsx)(Ot.Button,{className:F("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":u}),size:"small",variant:"ghost",color:"grey",draggable:!u,disabled:u,iconButton:!0,onDragStart:u?void 0:f=>l(f,c),children:(0,Et.jsx)(c.icon,{})},d)}),(0,Et.jsx)(Ot.TooltipContent,{color:"black",side:"right",children:p})]},d)})}),(0,Et.jsx)("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};var Ve=require("react/jsx-runtime"),Va=e=>e.preventDefault(),Ha=(0,on.forwardRef)((e,t)=>{let{instanceId:o,containerRef:n,mode:r,isMinimapOpen:i,isMoveTool:a,isHandTool:s,isExporting:l}=Y(),c=(0,Vt.useKeyPress)("Space",{target:n==null?void 0:n.current}),d=(0,on.useRef)(s),u=(0,on.useRef)(c),{nodes:p,edges:f,actions:x,events:E,components:m,controls:h}=af(),{t:g}=(0,Eo.useTranslation)(),y=hs();d.current=s,u.current=c;let v=uf(n,d,u);(0,on.useImperativeHandle)(t,()=>({selectElements:x.selectElements,clearSelection:x.clearSelection}));let _=s||c||r!=="edit",N=_?up:vr,b=s||c||v,w=a&&!c&&!v,S=r==="edit"&&w,M=!_&&!v,L=r==="view"||w;return(0,Ve.jsxs)("div",{ref:n,className:"w-full h-full outline-none",tabIndex:0,children:[r==="edit"&&(0,Ve.jsx)(tm,{}),(0,Ve.jsx)(pf,{}),(0,Ve.jsxs)(Vt.ReactFlow,I(T({},E),{id:`modeler-${o}`,className:F(r.toLowerCase(),{"is-hand-tool":b,"is-pan-tool-active":b}),edges:f,nodes:p,nodeTypes:Zu,edgeTypes:Ju,onlyRenderVisibleElements:!l,minZoom:Ia,maxZoom:np,panOnDrag:N,panOnScroll:!0,selectionOnDrag:M,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:L,nodesConnectable:S,nodesDraggable:S,connectionLineComponent:qu,selectionMode:Vt.SelectionMode.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:S?"Delete":null,selectionKeyCode:null,defaultViewport:lp,connectOnClick:!1,connectionRadius:50,onPaneContextMenu:Va,onNodeContextMenu:Va,onEdgeContextMenu:Va,proOptions:pp,children:[(0,Ve.jsx)(Vt.Background,{gap:tp,size:ep,color:ju,bgColor:Qu}),(0,Ve.jsx)(Qf,{}),i&&(0,Ve.jsxs)(Eo.Tooltip,{children:[(0,Ve.jsx)(Eo.TooltipTrigger,{asChild:!0,children:(0,Ve.jsx)("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:(0,Ve.jsx)(Vt.MiniMap,{pannable:!0,zoomable:!0,position:op,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),(0,Ve.jsx)(Eo.TooltipContent,{color:"black",children:g("editor.controls.actions.minimap.label")})]}),(0,Ve.jsxs)("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&(0,Ve.jsx)(Oa,T({},h)),r!=="readonly"&&(0,Ve.jsx)(Ra,{hasContent:y,validateDiagram:x.validateDiagram,handleValidationComplete:x.handleValidationComplete}),(0,Ve.jsx)(Zf,{})]}),(0,Ve.jsx)(m.HelperLines,{})]}))]})});Ha.displayName="Editor";var om=require("@xyflow/react"),Rr=require("react"),nm=require("react/jsx-runtime"),wx=e=>({width:e.width,height:e.height,transform:e.transform}),Ga="rgba(51, 103, 217, 0.4)",pd=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=(0,om.useStore)(wx),i=(0,Rr.useRef)(null),a=(0,Rr.useRef)(1);return(0,Rr.useEffect)(()=>{let s=i.current,l=s==null?void 0:s.getContext("2d");if(!l||!s)return;let c=Math.min(window.devicePixelRatio||1,2),d=Math.ceil(o*c),u=Math.ceil(n*c);(s.width!==d||s.height!==u)&&(s.width=d,s.height=u,a.current=c),l.setTransform(a.current,0,0,a.current,0,0),l.clearRect(0,0,o,n),l.strokeStyle=Ga,t&&(l.beginPath(),l.strokeStyle=t.color||Ga,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||Ga,l.moveTo(0,e.position*r[2]+r[1]),l.lineTo(o,e.position*r[2]+r[1]),l.stroke())},[o,n,r,e,t]),(0,nm.jsx)("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};var Fn=require("@produto-lecom/lecom-ui"),_o=require("react");var Or=require("react/jsx-runtime"),St=new Map,rm=(0,_o.createContext)(null),Cn=()=>{let e=(0,_o.useContext)(rm);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},im=({locale:e,defaultMode:t="view",featureFlags:o,toast:n,children:r})=>{let[i,a]=(0,_o.useState)(e||"pt_BR");(0,_o.useEffect)(()=>{e&&(a(e),Fn.i18n.changeLanguage(e))},[e]);let s=E=>{let m=St.size;if(m===0)throw new Error("No modeler instances found");if(m===1||!E){let[g]=St.values();return g}let h=St.get(E);if(!h)throw new Error(`Modeler instance with ID "${E}" not found`);return h},l=(E,m)=>{let h=s(m);return h==null?void 0:h.selectElements(E)},c=async E=>{let m=s(E);return m==null?void 0:m.clearSelection()},d=(E,m)=>{let h=s(m);return h==null?void 0:h.configureElement(E)},u=(E,m)=>{let h=s(m);return h==null?void 0:h.getConfigureElement(E)},p=async(E,m)=>{let h=s(m);await(h==null?void 0:h.importFromMxGraph(E))},f=E=>{let m=s(E);return m==null?void 0:m.exportToMxGraph()},x=E=>{let m=s(E);return(m==null?void 0:m.getElementsCount())||0};return(0,Or.jsx)(rm.Provider,{value:{defaultMode:t,locale:i,featureFlags:o,selectElements:l,clearSelection:c,configureElement:d,getConfigureElement:u,importDiagram:p,exportDiagram:f,getElementsCount:x,toast:n},children:(0,Or.jsxs)(Fn.TooltipProvider,{children:[!n&&(0,Or.jsx)(Fn.Notification,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),r]})})};var Ns=require("react/jsx-runtime"),lm=(0,ue.createContext)(null),Y=()=>{let e=(0,ue.useContext)(lm);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},cm=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,edgeHighlight:r=!0,validateCustomDiagram:i,validateDeleteElements:a,onElementChanges:s,onConfigureElement:l,onElementClick:c,onSubprocessValidationClick:d})=>{let u=(0,ue.useRef)(null),{t:p}=(0,sm.useTranslation)(),{defaultMode:f,featureFlags:x}=Cn(),E=(0,ue.useId)(),[m]=(0,ue.useState)(o||E),[h,g]=(0,ue.useState)(n||f||"edit"),[y,v]=(0,ue.useState)(fr),[_,N]=(0,ue.useState)(!1),[b,w]=(0,ue.useState)(!0),[S,M]=(0,ue.useState)(!1),[L,D]=(0,ue.useState)(!1),[O,R]=(0,ue.useState)(!1),[V,G]=(0,ue.useState)(!1),[B,A]=(0,ue.useState)(!1),[C,k]=(0,ue.useState)(!1),[P,K]=(0,ue.useState)(!1),[Z,W]=(0,ue.useState)(null);(0,ue.useEffect)(()=>{n&&g(n)},[n]);let H=!t,q=(0,ue.useMemo)(()=>t||Cd(p),[t,p]),z=(0,ue.useMemo)(()=>({instanceId:m,containerRef:u,initialDiagram:q,mode:h,featureFlags:x,edgeHighlight:r,isEdit:h==="edit",isView:h==="view",isReadOnly:h==="readonly",isNewDiagram:H,lastElementId:y,isInitialized:_,isMinimapOpen:L,isMoveTool:b,isHandTool:S,isDragging:O,isConnecting:V,isRemovingElements:B,isExporting:C,isImporting:P,setIsImporting:K,setLastElementId:v,setIsInitialized:N,reconnectingEdgeId:Z,setIsMinimapOpen:D,setIsMoveTool:w,setIsHandTool:M,setIsDragging:R,setIsConnecting:G,setIsRemovingElements:A,setIsExporting:k,setReconnectingEdgeId:W,validateCustomDiagram:i,validateDeleteElements:a,onElementChanges:s,onConfigureElement:l,onElementClick:c,onSubprocessValidationClick:d}),[m,u,q,h,x,r,H,y,_,L,b,S,O,V,B,C,P,Z,i,a,s,l,c,d]);return(0,Ns.jsx)(am.ReactFlowProvider,{children:(0,Ns.jsx)(lm.Provider,{value:z,children:(0,Ns.jsx)(Ha,{ref:e})})})};0&&(module.exports={EditorMode,ElementPosition,ElementType,GatewayElementVariant,GatewayVariant,Modeler,ModelerProvider,NodeAttribute,NodeType,NodeVariant,RoutingVariant,useModeler});
|
|
93
|
+
E --> F<end>`,Yf=({open:e,onOpenChange:t,onSubmit:o})=>{let{t:n}=(0,De.useTranslation)(),[r,i]=(0,ka.useState)(""),[a,s]=(0,ka.useState)(null),l=d=>{d||(i(""),s(null)),t(d)},c=()=>{let d=Ff(r);if(!d){s(n("editor.modals.mermaid_import.error_empty"));return}o(d),l(!1)};return(0,dt.jsx)(De.Dialog,{open:e,onOpenChange:l,children:(0,dt.jsxs)(De.DialogContent,{className:"w-[90vw] max-w-4xl",children:[(0,dt.jsxs)(De.DialogHeader,{children:[(0,dt.jsx)(De.DialogTitle,{children:n("editor.modals.mermaid_import.title")}),(0,dt.jsx)(De.DialogDescription,{children:n("editor.modals.mermaid_import.description")})]}),(0,dt.jsx)(De.Textarea,{value:r,onChange:d=>{i(d.target.value),a&&s(null)},placeholder:Nx,rows:16,className:"max-h-[60vh] min-h-[360px] resize-y font-mono"}),a&&(0,dt.jsx)("p",{className:"text-sm text-red-500",children:a}),(0,dt.jsxs)(De.DialogFooter,{children:[(0,dt.jsx)(De.Button,{variant:"ghost",color:"grey",onClick:()=>l(!1),children:n("editor.modals.mermaid_import.cancel")}),(0,dt.jsx)(De.Button,{variant:"filled",color:"blue",onClick:c,children:n("editor.modals.mermaid_import.generate")})]})]})})};var ue=require("react/jsx-runtime"),wx=".xml,text/xml,application/xml";function Xf(){let{t:e}=(0,ge.useTranslation)(),{getNodes:t}=(0,Wf.useReactFlow)(),{importFromMxGraph:o}=Pt(),{importFromLia:n}=fs(),{runImport:r}=Bf(),{isImporting:i}=Y(),{toast:a}=Oe(),[s,l]=(0,en.useState)(!1),[c,d]=(0,en.useState)(!1),[u,p]=(0,en.useState)(!1),f=(0,en.useRef)(null),x=(0,en.useRef)(null),E=async _=>{try{await r(_)}catch(N){console.error("Falha ao importar o diagrama:",N),a({variant:"error",content:e("editor.controls.actions.import.feedback.error")})}},m=_=>{if(t().length===0){E(_);return}x.current=_,p(!0)},h=async()=>{let _=x.current;_&&(await E(_),x.current=null,p(!1))},g=()=>{x.current=null,p(!1)},y=async _=>{var w;let N=(w=_.target.files)==null?void 0:w[0];if(_.target.value="",!N)return;let b;try{b=await xs(N)}catch(S){console.error("Falha ao ler o arquivo XML:",S),a({variant:"error",content:e("editor.controls.actions.import.feedback.error")});return}m(()=>o(b))},v=_=>{m(()=>n(_))};return(0,ue.jsxs)(ue.Fragment,{children:[(0,ue.jsxs)(ge.DropdownMenu,{modal:!1,open:s,onOpenChange:l,children:[(0,ue.jsx)(ge.DropdownMenuTrigger,{asChild:!0,children:(0,ue.jsx)("div",{children:(0,ue.jsxs)(ge.Tooltip,{children:[(0,ue.jsx)(ge.TooltipTrigger,{asChild:!0,children:(0,ue.jsx)(ge.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:i,children:(0,ue.jsx)(Bn.ClipboardPasteIcon,{})})}),!s&&(0,ue.jsx)(ge.TooltipContent,{color:"black",children:e("editor.controls.actions.import.title")})]})})}),(0,ue.jsxs)(ge.DropdownMenuContent,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[(0,ue.jsxs)(ge.Tooltip,{children:[(0,ue.jsx)(ge.TooltipTrigger,{asChild:!0,children:(0,ue.jsx)(ge.DropdownMenuItem,{className:"p-1.5",onClick:()=>{var _;return(_=f.current)==null?void 0:_.click()},children:(0,ue.jsx)(Bn.FileCodeIcon,{})})}),(0,ue.jsx)(ge.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.import.xml")})]}),(0,ue.jsxs)(ge.Tooltip,{children:[(0,ue.jsx)(ge.TooltipTrigger,{asChild:!0,children:(0,ue.jsx)(ge.DropdownMenuItem,{className:"p-1.5",onClick:()=>d(!0),children:(0,ue.jsx)(Bn.CircleIcon,{})})}),(0,ue.jsx)(ge.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.import.mermaid")})]})]})]}),(0,ue.jsx)("input",{ref:f,type:"file",className:"sr-only",accept:wx,onChange:y}),(0,ue.jsx)(Yf,{open:c,onOpenChange:d,onSubmit:v}),(0,ue.jsx)(zf,{open:u,loading:i,onConfirm:h,onCancel:g})]})}var bs=require("react"),he=require("@produto-lecom/lecom-ui"),Uf=require("@xyflow/react"),zn=require("lucide-react");var Ce=require("react/jsx-runtime");function $f(){let{t:e}=(0,he.useTranslation)(),{getNodes:t,getEdges:o,setNodes:n}=(0,Uf.useReactFlow)(),{fitToNodes:r}=fo(),{toast:i}=Oe(),[a,s]=(0,bs.useState)(!1),l=(0,bs.useCallback)(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 h,g,y,v;return I(T({},m),{width:(g=m.width)!=null?g:(h=m.measured)==null?void 0:h.width,height:(v=m.height)!=null?v:(y=m.measured)==null?void 0:y.height})}),{nodes:f}=Fi(p,o(),c),x=new Map(f.map(m=>[m.id,m.position])),E=d.map(m=>{var h;return I(T({},m),{position:(h=x.get(m.id))!=null?h:m.position})});n(E),r(E)},[t,o,n,r,i,e]);return(0,Ce.jsxs)(he.DropdownMenu,{modal:!1,open:a,onOpenChange:s,children:[(0,Ce.jsx)(he.DropdownMenuTrigger,{asChild:!0,children:(0,Ce.jsx)("div",{children:(0,Ce.jsxs)(he.Tooltip,{children:[(0,Ce.jsx)(he.TooltipTrigger,{asChild:!0,children:(0,Ce.jsx)(he.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:(0,Ce.jsx)(zn.NetworkIcon,{})})}),!a&&(0,Ce.jsx)(he.TooltipContent,{color:"black",children:e("editor.controls.actions.organize.title")})]})})}),(0,Ce.jsxs)(he.DropdownMenuContent,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[(0,Ce.jsxs)(he.Tooltip,{children:[(0,Ce.jsx)(he.TooltipTrigger,{asChild:!0,children:(0,Ce.jsx)(he.DropdownMenuItem,{className:"p-1.5",onClick:()=>l("TB"),children:(0,Ce.jsx)(zn.AlignVerticalJustifyStartIcon,{})})}),(0,Ce.jsx)(he.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.organize.vertical")})]}),(0,Ce.jsxs)(he.Tooltip,{children:[(0,Ce.jsx)(he.TooltipTrigger,{asChild:!0,children:(0,Ce.jsx)(he.DropdownMenuItem,{className:"p-1.5",onClick:()=>l("LR"),children:(0,Ce.jsx)(zn.AlignHorizontalJustifyStartIcon,{})})}),(0,Ce.jsx)(he.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.organize.horizontal")})]})]})]})}var ee=require("react/jsx-runtime"),Ra=xt.default.memo(({hasContent:e,validateDiagram:t,handleValidationComplete:o})=>{let{t:n}=(0,we.useTranslation)(),{clearSelection:r}=Tt(),{mode:i,containerRef:a,featureFlags:s,isMinimapOpen:l,setIsMinimapOpen:c,isMoveTool:d,isHandTool:u,setIsMoveTool:p,setIsHandTool:f}=Y(),{getNodes:x,getEdges:E}=(0,kr.useReactFlow)(),m=(0,kr.useKeyPress)(["v","V"],{target:a==null?void 0:a.current}),h=(0,kr.useKeyPress)(["h","H"],{target:a==null?void 0:a.current}),g=(0,xt.useCallback)(()=>{r(),f(!0),p(!1)},[r,f,p]),y=(0,xt.useCallback)(()=>{p(!0),f(!1)},[p,f]),[v,_]=(0,xt.useState)(!1),N=(0,xt.useCallback)(async()=>{_(!0);try{let b=x(),w=E(),S=await t({nodes:b,edges:w});o(S)}finally{_(!1)}},[x,E,t,o]);return(0,xt.useEffect)(()=>{m&&!d&&i==="edit"&&y()},[m,y,d,i]),(0,xt.useEffect)(()=>{h&&!u&&i==="edit"&&g()},[h,g,u,i]),(0,ee.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[i==="edit"&&(0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsxs)(we.Tooltip,{children:[(0,ee.jsx)(we.TooltipTrigger,{asChild:!0,children:(0,ee.jsx)(we.Button,{size:"small",variant:"ghost",color:"grey",className:F(d&&"bg-grey-400"),iconButton:!0,onClick:y,children:(0,ee.jsx)(Rt.MousePointerIcon,{})})}),(0,ee.jsxs)(we.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[n("editor.controls.actions.move_tool"),(0,ee.jsx)(Ma,{shortcut:"V"})]})]}),(0,ee.jsxs)(we.Tooltip,{children:[(0,ee.jsx)(we.TooltipTrigger,{asChild:!0,children:(0,ee.jsx)(we.Button,{size:"small",variant:"ghost",color:"grey",className:F(u&&"bg-grey-400"),iconButton:!0,onClick:g,children:(0,ee.jsx)(Rt.HandIcon,{})})}),(0,ee.jsxs)(we.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[n("editor.controls.actions.hand_tool")," ",(0,ee.jsx)(Ma,{shortcut:"H"})]})]})]}),(0,ee.jsx)(Hf,{}),i==="edit"&&(0,ee.jsxs)(ee.Fragment,{children:[(s==null?void 0:s.importDiagramMermaidEnabled)&&(0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsx)(Xf,{}),(0,ee.jsx)($f,{})]}),(0,ee.jsxs)(we.Tooltip,{children:[(0,ee.jsx)(we.TooltipTrigger,{asChild:!0,children:(0,ee.jsx)(we.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:v,onClick:N,children:v?(0,ee.jsx)(Rt.Loader2Icon,{className:"animate-spin"}):(0,ee.jsx)(Rt.ListCheckIcon,{})})}),(0,ee.jsx)(we.TooltipContent,{color:"black",children:n(v?"editor.controls.actions.check_loading":"editor.controls.actions.check")})]}),(0,ee.jsx)(Cf,{disabled:e})]}),(0,ee.jsxs)(we.Tooltip,{children:[(0,ee.jsx)(we.TooltipTrigger,{asChild:!0,children:(0,ee.jsx)(we.Button,{size:"small",variant:"ghost",color:"grey",className:F(l&&"bg-grey-400"),iconButton:!0,onClick:()=>c(!l),children:(0,ee.jsx)(Rt.MapIcon,{})})}),(0,ee.jsx)(we.TooltipContent,{color:"black",children:n(l?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})});Ra.displayName="ActionsControl";var Kf=Xn(require("react"),1),Ke=require("@produto-lecom/lecom-ui"),Ts=require("lucide-react"),tt=require("react/jsx-runtime"),Oa=Kf.default.memo(({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=(0,Ke.useTranslation)();return(0,tt.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,tt.jsxs)(Ke.Tooltip,{children:[(0,tt.jsx)(Ke.TooltipTrigger,{asChild:!0,children:(0,tt.jsx)(Ke.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:(0,tt.jsx)(Ts.UndoIcon,{})})}),(0,tt.jsx)(Ke.TooltipContent,{color:"black",children:r("editor.controls.history.undo")})]}),(0,tt.jsxs)(Ke.Tooltip,{children:[(0,tt.jsx)(Ke.TooltipTrigger,{asChild:!0,children:(0,tt.jsx)(Ke.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:(0,tt.jsx)(Ts.RedoIcon,{})})}),(0,tt.jsx)(Ke.TooltipContent,{color:"black",children:r("editor.controls.history.redo")})]})]})});Oa.displayName="HistoryControl";var qf=require("@xyflow/react"),Ie=require("@produto-lecom/lecom-ui"),Fn=require("lucide-react");var be=require("react/jsx-runtime"),Zf=()=>{let{t:e}=(0,Ie.useTranslation)(),t=!hs(),{zoomIn:o,zoomOut:n,zoomTo:r,fitView:i}=(0,qf.useReactFlow)();return(0,be.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,be.jsxs)(Ie.Tooltip,{children:[(0,be.jsx)(Ie.TooltipTrigger,{asChild:!0,children:(0,be.jsx)(Ie.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>i(),children:(0,be.jsx)(Fn.ScanIcon,{})})}),(0,be.jsx)(Ie.TooltipContent,{color:"black",children:e("editor.controls.zoom.fit")})]}),(0,be.jsxs)(Ie.Tooltip,{children:[(0,be.jsx)(Ie.TooltipTrigger,{asChild:!0,children:(0,be.jsx)(Ie.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>n(),children:(0,be.jsx)(Fn.ZoomOut,{})})}),(0,be.jsx)(Ie.TooltipContent,{color:"black",children:e("editor.controls.zoom.out")})]}),(0,be.jsxs)(Ie.Tooltip,{children:[(0,be.jsx)(Ie.TooltipTrigger,{asChild:!0,children:(0,be.jsx)(Ie.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>r(1),children:(0,be.jsx)(el,{})})}),(0,be.jsx)(Ie.TooltipContent,{color:"black",children:e("editor.controls.zoom.reset")})]}),(0,be.jsxs)(Ie.Tooltip,{children:[(0,be.jsx)(Ie.TooltipTrigger,{asChild:!0,children:(0,be.jsx)(Ie.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>o(),children:(0,be.jsx)(Fn.ZoomIn,{})})}),(0,be.jsx)(Ie.TooltipContent,{color:"black",children:e("editor.controls.zoom.in")})]})]})};var Jf=require("@xyflow/react"),tn=require("react/jsx-runtime"),Qf=()=>(0,tn.jsxs)(Jf.ViewportPortal,{children:[(0,tn.jsxs)("svg",{"data-export-hidden":!0,width:"20",height:"20",viewBox:"0 0 20 20",className:"text-grey-400 -translate-x-1/2 -translate-y-1/2 pointer-events-none",children:[(0,tn.jsx)("line",{x1:"0",y1:"10",x2:"20",y2:"10",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"}),(0,tn.jsx)("line",{x1:"10",y1:"0",x2:"10",y2:"20",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"})]}),(0,tn.jsx)("div",{"data-export-hidden":!0,className:"absolute top-1 left-1 text-xs font-medium text-grey-400 bg-white/70 px-1 rounded-sm pointer-events-none",children:"0,0"})]});var jf=require("@xyflow/react"),Ot=require("@produto-lecom/lecom-ui"),vs=require("react");var em=require("lucide-react");var Et=require("react/jsx-runtime"),tm=()=>{let e=(0,vs.useRef)(null),{t}=(0,Ot.useTranslation)(),{setDraggableNode:o}=Cn(),n=(0,jf.useStore)(c=>c.nodes.some(d=>d.type==="START_EVENT")),{setIsDragging:r}=Y(),[i,a]=(0,vs.useState)(void 0),s=[{type:"START_EVENT",icon:Zr,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:nn,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:Kn,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:qn,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SERVICE_TASK",icon:em.Bot,label:t("bpmn.task.variant.service_task")},{type:"TASK",variant:"SCRIPT",icon:ol,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:tl,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:an,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:cn,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:rn,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:ja,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:$r,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),a((0,Et.jsx)(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return(0,Et.jsxs)("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[(0,Et.jsx)("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:s.map((c,d)=>{let u=c.type==="START_EVENT"&&n,p=u?t("editor.toolbar.start_event_already_exists"):c.label;return(0,Et.jsxs)(Ot.Tooltip,{children:[(0,Et.jsx)(Ot.TooltipTrigger,{asChild:!0,children:(0,Et.jsx)(Ot.Button,{className:F("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":u}),size:"small",variant:"ghost",color:"grey",draggable:!u,disabled:u,iconButton:!0,onDragStart:u?void 0:f=>l(f,c),children:(0,Et.jsx)(c.icon,{})},d)}),(0,Et.jsx)(Ot.TooltipContent,{color:"black",side:"right",children:p})]},d)})}),(0,Et.jsx)("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};var Ve=require("react/jsx-runtime"),Va=e=>e.preventDefault(),Ha=(0,on.forwardRef)((e,t)=>{let{instanceId:o,containerRef:n,mode:r,isMinimapOpen:i,isMoveTool:a,isHandTool:s,isExporting:l}=Y(),c=(0,Vt.useKeyPress)("Space",{target:n==null?void 0:n.current}),d=(0,on.useRef)(s),u=(0,on.useRef)(c),{nodes:p,edges:f,actions:x,events:E,components:m,controls:h}=af(),{t:g}=(0,Eo.useTranslation)(),y=hs();d.current=s,u.current=c;let v=uf(n,d,u);(0,on.useImperativeHandle)(t,()=>({selectElements:x.selectElements,clearSelection:x.clearSelection}));let _=s||c||r!=="edit",N=_?up:vr,b=s||c||v,w=a&&!c&&!v,S=r==="edit"&&w,M=!_&&!v,L=r==="view"||w;return(0,Ve.jsxs)("div",{ref:n,className:"w-full h-full outline-none",tabIndex:0,children:[r==="edit"&&(0,Ve.jsx)(tm,{}),(0,Ve.jsx)(pf,{}),(0,Ve.jsxs)(Vt.ReactFlow,I(T({},E),{id:`modeler-${o}`,className:F(r.toLowerCase(),{"is-hand-tool":b,"is-pan-tool-active":b}),edges:f,nodes:p,nodeTypes:Zu,edgeTypes:Ju,onlyRenderVisibleElements:!l,minZoom:Ia,maxZoom:np,panOnDrag:N,panOnScroll:!0,selectionOnDrag:M,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:L,nodesConnectable:S,nodesDraggable:S,connectionLineComponent:qu,selectionMode:Vt.SelectionMode.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:S?"Delete":null,selectionKeyCode:null,defaultViewport:lp,connectOnClick:!1,connectionRadius:50,onPaneContextMenu:Va,onNodeContextMenu:Va,onEdgeContextMenu:Va,proOptions:pp,children:[(0,Ve.jsx)(Vt.Background,{gap:tp,size:ep,color:ju,bgColor:Qu}),(0,Ve.jsx)(Qf,{}),i&&(0,Ve.jsxs)(Eo.Tooltip,{children:[(0,Ve.jsx)(Eo.TooltipTrigger,{asChild:!0,children:(0,Ve.jsx)("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:(0,Ve.jsx)(Vt.MiniMap,{pannable:!0,zoomable:!0,position:op,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),(0,Ve.jsx)(Eo.TooltipContent,{color:"black",children:g("editor.controls.actions.minimap.label")})]}),(0,Ve.jsxs)("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&(0,Ve.jsx)(Oa,T({},h)),r!=="readonly"&&(0,Ve.jsx)(Ra,{hasContent:y,validateDiagram:x.validateDiagram,handleValidationComplete:x.handleValidationComplete}),(0,Ve.jsx)(Zf,{})]}),(0,Ve.jsx)(m.HelperLines,{})]}))]})});Ha.displayName="Editor";var om=require("@xyflow/react"),Rr=require("react"),nm=require("react/jsx-runtime"),Ix=e=>({width:e.width,height:e.height,transform:e.transform}),Ga="rgba(51, 103, 217, 0.4)",pd=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=(0,om.useStore)(Ix),i=(0,Rr.useRef)(null),a=(0,Rr.useRef)(1);return(0,Rr.useEffect)(()=>{let s=i.current,l=s==null?void 0:s.getContext("2d");if(!l||!s)return;let c=Math.min(window.devicePixelRatio||1,2),d=Math.ceil(o*c),u=Math.ceil(n*c);(s.width!==d||s.height!==u)&&(s.width=d,s.height=u,a.current=c),l.setTransform(a.current,0,0,a.current,0,0),l.clearRect(0,0,o,n),l.strokeStyle=Ga,t&&(l.beginPath(),l.strokeStyle=t.color||Ga,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||Ga,l.moveTo(0,e.position*r[2]+r[1]),l.lineTo(o,e.position*r[2]+r[1]),l.stroke())},[o,n,r,e,t]),(0,nm.jsx)("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};var Yn=require("@produto-lecom/lecom-ui"),_o=require("react");var Or=require("react/jsx-runtime"),St=new Map,rm=(0,_o.createContext)(null),Sn=()=>{let e=(0,_o.useContext)(rm);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},im=({locale:e,defaultMode:t="view",featureFlags:o,toast:n,children:r})=>{let[i,a]=(0,_o.useState)(e||"pt_BR");(0,_o.useEffect)(()=>{e&&(a(e),Yn.i18n.changeLanguage(e))},[e]);let s=E=>{let m=St.size;if(m===0)throw new Error("No modeler instances found");if(m===1||!E){let[g]=St.values();return g}let h=St.get(E);if(!h)throw new Error(`Modeler instance with ID "${E}" not found`);return h},l=(E,m)=>{let h=s(m);return h==null?void 0:h.selectElements(E)},c=async E=>{let m=s(E);return m==null?void 0:m.clearSelection()},d=(E,m)=>{let h=s(m);return h==null?void 0:h.configureElement(E)},u=(E,m)=>{let h=s(m);return h==null?void 0:h.getConfigureElement(E)},p=async(E,m)=>{let h=s(m);await(h==null?void 0:h.importFromMxGraph(E))},f=E=>{let m=s(E);return m==null?void 0:m.exportToMxGraph()},x=E=>{let m=s(E);return(m==null?void 0:m.getElementsCount())||0};return(0,Or.jsx)(rm.Provider,{value:{defaultMode:t,locale:i,featureFlags:o,selectElements:l,clearSelection:c,configureElement:d,getConfigureElement:u,importDiagram:p,exportDiagram:f,getElementsCount:x,toast:n},children:(0,Or.jsxs)(Yn.TooltipProvider,{children:[!n&&(0,Or.jsx)(Yn.Notification,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),r]})})};var Ns=require("react/jsx-runtime"),lm=(0,le.createContext)(null),Y=()=>{let e=(0,le.useContext)(lm);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},cm=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,edgeHighlight:r=!0,validateCustomDiagram:i,validateDeleteElements:a,onElementChanges:s,onConfigureElement:l,onElementClick:c,onSubprocessValidationClick:d})=>{let u=(0,le.useRef)(null),{t:p}=(0,sm.useTranslation)(),{defaultMode:f,featureFlags:x}=Sn(),E=(0,le.useId)(),[m]=(0,le.useState)(o||E),[h,g]=(0,le.useState)(n||f||"edit"),[y,v]=(0,le.useState)(mr),[_,N]=(0,le.useState)(!1),[b,w]=(0,le.useState)(!0),[S,M]=(0,le.useState)(!1),[L,D]=(0,le.useState)(!1),[O,R]=(0,le.useState)(!1),[V,G]=(0,le.useState)(!1),[B,A]=(0,le.useState)(!1),[C,k]=(0,le.useState)(!1),[P,K]=(0,le.useState)(!1),[Z,U]=(0,le.useState)(null);(0,le.useEffect)(()=>{n&&g(n)},[n]),(0,le.useEffect)(()=>{if(!P)return;let W=X=>{X.preventDefault()};return window.addEventListener("beforeunload",W),()=>window.removeEventListener("beforeunload",W)},[P]);let H=!t,q=(0,le.useMemo)(()=>t||Cd(p),[t,p]),z=(0,le.useMemo)(()=>({instanceId:m,containerRef:u,initialDiagram:q,mode:h,featureFlags:x,edgeHighlight:r,isEdit:h==="edit",isView:h==="view",isReadOnly:h==="readonly",isNewDiagram:H,lastElementId:y,isInitialized:_,isMinimapOpen:L,isMoveTool:b,isHandTool:S,isDragging:O,isConnecting:V,isRemovingElements:B,isExporting:C,isImporting:P,setIsImporting:K,setLastElementId:v,setIsInitialized:N,reconnectingEdgeId:Z,setIsMinimapOpen:D,setIsMoveTool:w,setIsHandTool:M,setIsDragging:R,setIsConnecting:G,setIsRemovingElements:A,setIsExporting:k,setReconnectingEdgeId:U,validateCustomDiagram:i,validateDeleteElements:a,onElementChanges:s,onConfigureElement:l,onElementClick:c,onSubprocessValidationClick:d}),[m,u,q,h,x,r,H,y,_,L,b,S,O,V,B,C,P,Z,i,a,s,l,c,d]);return(0,Ns.jsx)(am.ReactFlowProvider,{children:(0,Ns.jsx)(lm.Provider,{value:z,children:(0,Ns.jsx)(Ha,{ref:e})})})};0&&(module.exports={EditorMode,ElementPosition,ElementType,GatewayElementVariant,GatewayVariant,Modeler,ModelerProvider,NodeAttribute,NodeType,NodeVariant,RoutingVariant,useModeler});
|