lecom-modeler 0.39.3 → 0.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/lib/index.cjs +15 -15
  2. package/lib/index.js +15 -15
  3. package/package.json +2 -2
package/lib/index.js CHANGED
@@ -1,8 +1,8 @@
1
- var Lp=Object.defineProperty,kp=Object.defineProperties;var Rp=Object.getOwnPropertyDescriptors;var Gn=Object.getOwnPropertySymbols;var $s=Object.prototype.hasOwnProperty,Ks=Object.prototype.propertyIsEnumerable;var Us=(e,t,o)=>t in e?Lp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,_=(e,t)=>{for(var o in t||(t={}))$s.call(t,o)&&Us(e,o,t[o]);if(Gn)for(var o of Gn(t))Ks.call(t,o)&&Us(e,o,t[o]);return e},w=(e,t)=>kp(e,Rp(t));var ht=(e,t)=>{var o={};for(var n in e)$s.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Gn)for(var n of Gn(e))t.indexOf(n)<0&&Ks.call(e,n)&&(o[n]=e[n]);return o};var Li=e=>{if(typeof document=="undefined")return;let t=document.cookie.match(new RegExp(`(?:^|; )${e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")}=([^;]*)`));return t?decodeURIComponent(t[1]):void 0};import{initializeI18n as Dp,Translations as Op}from"@produto-lecom/lecom-ui";var qs={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Delete",configure_node:"Configure activity",configure_edge:"Configure routing",configure_gateway:"Configure routing",initial_task:"Initial Activity",gateway_limit_reached:"Exclusive gateway cannot have more than 2 outgoing connections",task_limit_reached:"Task cannot have more than 2 outgoing connections",start_event_limit_reached:"Start event can only connect to a single element",gateway_to_gateway_not_allowed:"Gateways cannot connect directly to other gateways",start_event_already_exists:"A start event already exists. Delete the current event to add another",script_to_end_not_allowed:"Script activities cannot connect directly to the end event",loop_to_end_not_allowed:"Loop activities cannot connect directly to the end event",initial_activity_to_end_not_allowed:"Initial activity cannot connect directly to the end event",final_activity_cannot_connect:"Final activity cannot connect to other elements",activity_has_outgoing_connections:"Activity with outgoing connections cannot connect to end event",end_event_cannot_connect_to_initial_activity:"End event cannot connect to an initial activity",initial_activity_cannot_connect_to_start_event:"Initial activity cannot connect to start event",concurrent_initial_and_final_activity:"An activity cannot be connected to both start and end events",start_event_to_service_task_not_allowed:"Start event cannot connect to an automatic activity",service_task_to_end_not_allowed:"Automatic activities cannot connect to the end event",duplicate_connection_not_allowed:"A connection already exists between these elements",connect_node:"Connect element",connecting:"Connecting...",delete_pool_lane_error:"Cannot delete the pool or lane while there are elements inside it."},controls:{zoom:{fit:"Fit zoom",in:"Zoom in",out:"Zoom out",reset:"Reset zoom"},actions:{move_tool:"Select elements",hand_tool:"Navigate the diagram",check:"Check diagram",check_loading:"Validating diagram...",export:{title:"Export diagram",print:"Print",html:"Export as HTML",png:"Export as PNG",feedback:{empty:"Cannot export an empty diagram",error:"Error exporting diagram"}},import_governance:"Import diagram from Governance platform",import_mermaid:"Import Mermaid",organize:{title:"Arrange diagram",vertical:"Vertical (top-down)",horizontal:"Horizontal (left-right)"},minimap:{label:"Minimap",open:"Open minimap",close:"Hide minimap"}},history:{undo:"Undo",redo:"Redo"}},modals:{mermaid_import:{title:"Import diagram from Mermaid",description:"Paste the Mermaid text (in the format supported by the modeler) to generate the diagram.",generate:"Generate",cancel:"Cancel",error_empty:"Paste the diagram text before generating.",error_parse:"Could not generate the diagram. Check the pasted text."},delete_elements:{title:"Delete elements",callout:"When deleting, the activity and routing settings will be deleted.",content:"Are you sure you want to delete?",confirm:"Delete",cancel:"Cancel"}},task_menu:{loop_not_allowed_when_connected_to_end:"Cannot create loop on activity connected to end event",script_not_allowed_when_connected_to_end:"Cannot transform to Script activity connected to end event",loop_not_allowed_when_subprocess:"Cannot create loop on subprocess",loop_not_allowed_when_service_task:"Cannot create loop on automatic activity",loop:"Activity with loop"}},validation:{success:{title:"Validation Successful",message:"The diagram was validated successfully with no errors."},errors:{title:"The diagram contains errors",subtitle:"Please review the following:",task_label_length:"Task name exceeds the maximum character limit",multiple_start_event_not_allowed:"Multiple start events are not allowed",task_flows_limit_exceeds:"The number of output connections exceeds the limit of two",duplicate_task_name:"There are multiple activities with the same name",flows_on_end_tasks_not_allowed:"Activities connected to end events cannot have other connections",conditions_flows_limit_exceeds:"Exclusive gateway has too many output connections (maximum of two)",task_label_empty:"One or more activities have no name",activity_name_invalid:"Activity name is invalid",final_activity_has_loop:"Final activities cannot have loops",nested_gateway:"Connecting gateways directly is not allowed",concurrent_initial_and_final_event:"The same activity cannot have both initial and final events",gateway_flow_to_event:"Connecting a gateway to an output event is not allowed",gateway_missing_output_streams:"The gateway does not have the correct number of outputs",events_nested:"Connecting events directly is not allowed",event_to_condition:"Connecting an event directly to a gateway is not allowed",script_in_final_activity:"Final activity cannot be a script type",subprocess_not_configured:"The subprocess reference is not properly configured",cannot_validate_subprocess_reference:"Could not validate whether the subprocess reference is configured",start_event_not_found:"At least one start event is required",end_event_not_found:"At least one end event is required",service_task_without_rejection_routing:"Automated activity (RPA) without rejection routing configured",service_task_without_automation:"Automated activity (RPA) without a configured robot",service_task_connector_inactive:"Automated activity (RPA) linked to an inactive connector",service_task_integration_suspended:"Automated activity (RPA) linked to a suspended integration",service_task_automation_status_unavailable:"Could not verify the automation (RPA) status",service_task_initial_or_final:"Automated activity (RPA) cannot be an initial, final or concentrator step",service_task_in_loop:"Automated activity (RPA) cannot be in a loop"}},bpmn:{start_event:{variant:{default:"Start event"}},end_event:{variant:{default:"End event"}},annotation:{variant:{default:"Annotation"}},gateway:{menu:{title:"Change gateway type"},variant:{default:"Gateway",exclusive:"Exclusive gateway",parallel:"Parallel gateway",complex:"Complex gateway"}},task:{menu:{title:"Change task type"},variant:{default:"Task",script:"Script task",subprocess:"Subprocess",service_task:"RPA"},attribute:{loop:"Task with loop"},label:{prefix:"Activity"},feedback:{label_empty:{prefix:"Activity name was automatically set to"},label_already_exists:{prefix:"The name",middle:"already exists. The name was changed to"},invalid_first_character:"Activity name must start with a letter or number"}},lane:{variant:{default:"Pool / Lane"}},unsupported:{variant:{default:"Unsupported element"}}},adapter:{governance:{error:{DEFAULT:"Error importing diagram",NO_FILE:"No file selected",EMPTY_FILE:"Empty file",INVALID_FILE:"Invalid file",CONTAIN_NO_CELLS:"No cells found to be imported",ALREADY_INITIALIZED:"It is not possible to import the diagram from the Governance platform, since the diagram has already been initialized"},success:{default:"The diagram was imported from the Governance platform successfully and without any incompatibility detected.",incompatible_cells:"The diagram was imported from the Governance platform with incompatibilities. To know more details, click on the button below."},report:{columns:{type:"Type",value:"Value",status:"Status"},status:{imported:"Imported",adapted:"Adapted",unsupported:"Unsupported"}},action:{download:"Download report"}}}}};var Zs={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",configure_node:"Configurar actividad",configure_edge:"Configurar enrutamiento",configure_gateway:"Configurar enrutamiento",initial_task:"Actividad Inicial",gateway_limit_reached:"Compuerta exclusiva no puede tener m\xE1s de 2 conexiones de salida",task_limit_reached:"Actividad no puede tener m\xE1s de 2 conexiones de salida",start_event_limit_reached:"Evento inicial solo puede conectarse a un \xFAnico elemento",gateway_to_gateway_not_allowed:"Las compuertas no pueden conectarse directamente con otras compuertas",start_event_already_exists:"Ya existe un evento de inicio. Elimine el evento actual para agregar otro",script_to_end_not_allowed:"Las actividades Script no pueden conectarse directamente al evento final",loop_to_end_not_allowed:"Las actividades Loop no pueden conectarse directamente al evento final",initial_activity_to_end_not_allowed:"Actividad inicial no puede conectarse directamente al evento final",final_activity_cannot_connect:"Actividad final no puede conectarse a otros elementos",activity_has_outgoing_connections:"Actividad con conexiones de salida no puede conectarse al evento final",end_event_cannot_connect_to_initial_activity:"El evento final no puede conectarse a una actividad inicial",initial_activity_cannot_connect_to_start_event:"Actividad inicial no puede conectarse a evento de inicio",concurrent_initial_and_final_activity:"Una actividad no puede estar conectada al evento inicial y final al mismo tiempo",start_event_to_service_task_not_allowed:"El evento inicial no puede conectarse a una actividad autom\xE1tica",service_task_to_end_not_allowed:"Las actividades autom\xE1ticas no pueden conectarse al evento final",duplicate_connection_not_allowed:"Ya existe una conexi\xF3n entre estos elementos",connect_node:"Conectar elemento",connecting:"Conectando...",delete_pool_lane_error:"No se puede eliminar la piscina o carril mientras haya elementos dentro."},controls:{zoom:{fit:"Ajustar zoom",in:"Acercar",out:"Alejar",reset:"Restablecer zoom"},actions:{move_tool:"Seleccionar elementos",hand_tool:"Navegar por el diagrama",check:"Validar diagrama",check_loading:"Validando diagrama...",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"No es posible exportar un diagrama vac\xEDo",error:"Error al exportar diagrama"}},import_governance:"Importar diagrama de la plataforma Governance",import_mermaid:"Importar Mermaid",organize:{title:"Ordenar diagrama",vertical:"Vertical (de arriba hacia abajo)",horizontal:"Horizontal (de izquierda a derecha)"},minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Deshacer",redo:"Rehacer"}},modals:{mermaid_import:{title:"Importar diagrama a partir de Mermaid",description:"Pegue el texto Mermaid (en el formato compatible con el modelador) para generar el diagrama.",generate:"Generar",cancel:"Cancelar",error_empty:"Pegue el texto del diagrama antes de generar.",error_parse:"No fue posible generar el diagrama. Verifique el texto pegado."},delete_elements:{title:"Eliminar elementos",callout:"Al eliminar, las configuraciones de actividades y enrutamiento ser\xE1n eliminadas.",content:"\xBFEst\xE1s seguro de querer eliminar?",confirm:"Eliminar",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"No se puede crear bucle en actividad conectada al evento final",script_not_allowed_when_connected_to_end:"No se puede transformar a Script actividad conectada al evento final",loop_not_allowed_when_subprocess:"No se puede crear bucle en subproceso",loop_not_allowed_when_service_task:"No se puede crear bucle en actividad autom\xE1tica",loop:"Actividad con loop"}},validation:{success:{title:"Validaci\xF3n exitosa",message:"El diagrama ha sido validado correctamente sin errores."},errors:{title:"El diagrama contiene errores",subtitle:"Revise lo siguiente:",task_label_length:"El nombre de la actividad excede el l\xEDmite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"No se permite tener m\xE1s de un evento de inicio",task_flows_limit_exceeds:"El n\xFAmero de conexiones de salida supera el l\xEDmite de dos",duplicate_task_name:"Hay varias actividades con el mismo nombre",flows_on_end_tasks_not_allowed:"Las actividades conectadas a eventos finales no pueden tener otras conexiones",conditions_flows_limit_exceeds:"Compuerta exclusiva con exceso de conexiones de salida (m\xE1ximo de dos)",task_label_empty:"El nombre de una o m\xE1s actividades no ha sido completado",activity_name_invalid:"El nombre de la actividad no es v\xE1lido",final_activity_has_loop:"Las actividades finales no pueden tener bucles",nested_gateway:"No se permite conectar compuertas directamente",concurrent_initial_and_final_event:"Una misma actividad no puede tener eventos iniciales y finales",gateway_flow_to_event:"No se permite conectar una compuerta a un evento de salida",gateway_missing_output_streams:"La compuerta no tiene el n\xFAmero correcto de salidas",events_nested:"No se permite conectar eventos directamente",event_to_condition:"No se permite conectar un evento directamente a una compuerta",script_in_final_activity:"La actividad final no puede ser de tipo script",subprocess_not_configured:"La referencia al subproceso no est\xE1 configurada correctamente",cannot_validate_subprocess_reference:"No fue posible validar si la referencia al subproceso est\xE1 configurada",start_event_not_found:"Es necesario tener al menos un evento de inicio",end_event_not_found:"Es necesario tener al menos un evento final",service_task_without_rejection_routing:"Actividad autom\xE1tica (RPA) sin enrutamiento de rechazo configurado",service_task_without_automation:"Actividad autom\xE1tica (RPA) sin robot configurado",service_task_connector_inactive:"Actividad autom\xE1tica (RPA) vinculada a un conector inactivo",service_task_integration_suspended:"Actividad autom\xE1tica (RPA) vinculada a una integraci\xF3n suspendida",service_task_automation_status_unavailable:"No se pudo verificar el estado de la automatizaci\xF3n (RPA)",service_task_initial_or_final:"La actividad autom\xE1tica (RPA) no puede ser etapa inicial, final o concentradora",service_task_in_loop:"La actividad autom\xE1tica (RPA) no puede estar en un bucle"}},bpmn:{start_event:{variant:{default:"Evento de inicio"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anotaci\xF3n"}},gateway:{menu:{title:"Cambiar tipo de compuerta"},variant:{default:"Compuerta",exclusive:"Compuerta exclusiva",parallel:"Compuerta paralela",complex:"Compuerta compleja"}},task:{menu:{title:"Cambiar tipo de tarea"},variant:{default:"Tarea",script:"Tarea de script",subprocess:"Subproceso",service_task:"RPA"},attribute:{loop:"Tarea con bucle"},label:{prefix:"Actividad"},feedback:{label_empty:{prefix:"El nombre de la actividad se estableci\xF3 autom\xE1ticamente como"},label_already_exists:{prefix:"El nombre",middle:"ya existe. El nombre fue cambiado a"},invalid_first_character:"El nombre de la actividad debe comenzar con una letra o n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento no soportado"}}},adapter:{governance:{error:{DEFAULT:"Error al importar diagrama",NO_FILE:"No se ha seleccionado ning\xFAn archivo",EMPTY_FILE:"Archivo vac\xEDo",INVALID_FILE:"Archivo inv\xE1lido",CONTAIN_NO_CELLS:"No se encontraron c\xE9lulas para importar",ALREADY_INITIALIZED:"No es posible importar el diagrama de la plataforma Governance, ya que el diagrama ya ha sido iniciado"},success:{default:"El diagrama se ha importado de la plataforma Governance correctamente y sin ninguna incompatibilidad detectada.",incompatible_cells:"El diagrama se ha importado de la plataforma Governance con incompatibilidades. Para saber m\xE1s detalles, haz click en el bot\xF3n de abajo."},report:{columns:{type:"Tipo",value:"Valor",status:"Estado"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"No soportado"}},action:{download:"Descargar informe"}}}}};var Js={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Excluir",configure_node:"Configurar atividade",configure_edge:"Configurar roteamento",configure_gateway:"Configurar roteamento",initial_task:"Atividade Inicial",gateway_limit_reached:"Gateway exclusivo n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",task_limit_reached:"Atividade n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",start_event_limit_reached:"Evento inicial s\xF3 pode se conectar a um \xFAnico elemento",gateway_to_gateway_not_allowed:"Gateways n\xE3o podem se conectar diretamente com outros gateways",start_event_already_exists:"J\xE1 existe um evento de in\xEDcio. Exclua o evento atual para adicionar outro",script_to_end_not_allowed:"Atividades Script n\xE3o podem se conectar diretamente ao evento final",loop_to_end_not_allowed:"Atividades Loop n\xE3o podem se conectar diretamente ao evento final",initial_activity_to_end_not_allowed:"Atividade inicial n\xE3o pode se conectar diretamente ao evento final",final_activity_cannot_connect:"Atividade final n\xE3o pode se conectar a outros elementos",activity_has_outgoing_connections:"Atividade com conex\xF5es de sa\xEDda n\xE3o pode se conectar a um evento final",end_event_cannot_connect_to_initial_activity:"O evento final n\xE3o pode ser conectado a uma atividade inicial",initial_activity_cannot_connect_to_start_event:"Atividade inicial n\xE3o pode se conectar a evento de in\xEDcio",concurrent_initial_and_final_activity:"Uma atividade n\xE3o pode estar conectada ao evento inicial e final ao mesmo tempo",duplicate_connection_not_allowed:"J\xE1 existe uma conex\xE3o entre esses elementos",start_event_to_subprocess_not_allowed:"Evento inicial n\xE3o pode se conectar a um subprocesso",start_event_to_service_task_not_allowed:"Evento inicial n\xE3o pode se conectar a uma atividade autom\xE1tica",service_task_to_end_not_allowed:"Atividades autom\xE1ticas n\xE3o podem se conectar ao evento final",connect_node:"Conectar elemento",connecting:"Conectando...",delete_pool_lane_error:"N\xE3o \xE9 poss\xEDvel excluir a piscina ou raia enquanto houver elementos dentro dela."},controls:{zoom:{fit:"Ajustar o zoom",in:"Aumentar o zoom",out:"Diminuir o zoom",reset:"Resetar o zoom"},actions:{move_tool:"Selecionar elementos",hand_tool:"Navegar pelo diagrama",check:"Validar diagrama",check_loading:"Validando diagrama...",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"N\xE3o \xE9 poss\xEDvel exportar um diagrama vazio",error:"Erro ao exportar o diagrama"}},import_governance:"Importar diagrama da plataforma Governance",import_mermaid:"Importar Mermaid",organize:{title:"Ordenar diagrama",vertical:"Vertical (de cima para baixo)",horizontal:"Horizontal (da esquerda para a direita)"},minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Desfazer",redo:"Refazer"}},modals:{mermaid_import:{title:"Importar diagrama a partir de Mermaid",description:"Cole o texto Mermaid (no formato suportado pelo modelador) para gerar o diagrama.",generate:"Gerar",cancel:"Cancelar",error_empty:"Cole o texto do diagrama antes de gerar.",error_parse:"N\xE3o foi poss\xEDvel gerar o diagrama. Verifique o texto colado."},delete_elements:{title:"Excluir elementos",callout:"Ao excluir, as configura\xE7\xF5es de atividades e roteamento ser\xE3o exclu\xEDdas.",content:"Deseja realmente excluir?",confirm:"Excluir",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel criar loop em atividade conectada ao evento final",script_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel transformar em Script atividade conectada ao evento final",loop_not_allowed_when_subprocess:"N\xE3o \xE9 poss\xEDvel criar loop em subprocesso",loop_not_allowed_when_service_task:"N\xE3o \xE9 poss\xEDvel criar loop em atividade autom\xE1tica",loop:"Atividade com loop"}},validation:{success:{title:"Diagrama v\xE1lidado com sucesso!",message:"Nenhum erro encontrado."},errors:{title:"O diagrama cont\xE9m erros",subtitle:"Veja abaixo o que precisa ser corrigido:",task_label_length:"O nome da atividade excede o limite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"N\xE3o \xE9 permitido ter mais de um evento de in\xEDcio",task_flows_limit_exceeds:"O n\xFAmero de conex\xF5es de sa\xEDda ultrapassa o limite de dois",duplicate_task_name:"H\xE1 v\xE1rias atividades com o mesmo nome",flows_on_end_tasks_not_allowed:"Atividades conectadas a eventos finais n\xE3o podem ter outras conex\xF5es",conditions_flows_limit_exceeds:"Gateway exclusivo com excesso de conex\xF5es de sa\xEDda (m\xE1ximo de dois)",task_label_empty:"O nome de uma ou mais atividades n\xE3o foi preenchido",activity_name_invalid:"O nome da atividade n\xE3o \xE9 v\xE1lido",final_activity_has_loop:"Atividades finais n\xE3o podem ter loops",nested_gateway:"N\xE3o \xE9 permitido conectar gateways",concurrent_initial_and_final_event:"Uma mesma atividade n\xE3o pode ter eventos iniciais e finais",gateway_flow_to_event:"N\xE3o \xE9 permitido conectar um gateway a um evento de sa\xEDda",gateway_missing_output_streams:"O gateway n\xE3o possui o n\xFAmero correto de sa\xEDdas",events_nested:"N\xE3o \xE9 permitido conectar eventos",event_to_condition:"N\xE3o \xE9 permitido conectar um evento diretamente em um gateway",script_in_final_activity:"Atividade final n\xE3o pode ser do tipo script",subprocess_not_configured:"A refer\xEAncia ao subprocesso n\xE3o est\xE1 configurada corretamente",cannot_validate_subprocess_reference:"N\xE3o foi poss\xEDvel validar se a refer\xEAncia ao subprocesso est\xE1 configurada",start_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento inicial",end_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento final",service_task_without_rejection_routing:"Atividade autom\xE1tica (RPA) sem roteamento de rejei\xE7\xE3o configurado",service_task_without_automation:"Atividade autom\xE1tica (RPA) sem rob\xF4 configurado",service_task_connector_inactive:"Atividade autom\xE1tica (RPA) vinculada a um conector inativo",service_task_integration_suspended:"Atividade autom\xE1tica (RPA) vinculada a uma integra\xE7\xE3o suspensa",service_task_automation_status_unavailable:"N\xE3o foi poss\xEDvel verificar o status da automa\xE7\xE3o (RPA)",service_task_initial_or_final:"Atividade autom\xE1tica (RPA) n\xE3o pode ser etapa inicial, final ou concentradora",service_task_in_loop:"Atividade autom\xE1tica (RPA) n\xE3o pode estar em loop"}},bpmn:{start_event:{variant:{default:"Evento inicial"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anota\xE7\xE3o"}},gateway:{menu:{title:"Alterar tipo de gateway"},variant:{default:"Gateway",exclusive:"Gateway exclusivo",parallel:"Gateway paralelo",complex:"Gateway complexo"}},task:{menu:{title:"Alterar tipo de atividade"},variant:{default:"Atividade",script:"Atividade de script",subprocess:"Subprocesso",service_task:"RPA"},attribute:{loop:"Atividade com loop"},label:{prefix:"Atividade"},feedback:{label_empty:{prefix:"O nome da atividade foi definido automaticamente como"},label_already_exists:{prefix:"O nome",middle:"j\xE1 existe. O nome foi alterado para"},invalid_first_character:"O nome da atividade deve come\xE7ar com uma letra ou n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento n\xE3o suportado"}}},adapter:{governance:{error:{DEFAULT:"Erro ao importar diagrama",NO_FILE:"Nenhum arquivo selecionado",EMPTY_FILE:"Arquivo vazio",INVALID_FILE:"Arquivo inv\xE1lido",CONTAIN_NO_CELLS:"N\xE3o foram encontradas c\xE9lulas para serem importadas",ALREADY_INITIALIZED:"N\xE3o \xE9 poss\xEDvel importar o diagrama da plataforma Governance, pois o diagrama j\xE1 foi iniciado"},success:{default:"O diagrama foi importado da plataforma Governance com sucesso e sem nenhuma incompatibilidade detectada.",incompatible_cells:"O diagrama foi importado da plataforma Governance com incompatibilidades. Para saber mais detalhes, clique no bot\xE3o abaixo."},report:{columns:{type:"Tipo do elemento",value:"Valor",status:"Status"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"N\xE3o suportado"}},action:{download:"Baixar relat\xF3rio"}}}}};var Qs={pt_BR:Js,en_US:qs,es_ES:Zs};var js,ea,Vp=(ea=(js=Li("LecomUserLanguage"))!=null?js:Li("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?ea:Op.PT_BR;Dp({lng:Vp,resources:Qs});var Ie=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(Ie||{});var Bn=(i=>(i.ACTIVITY="activity",i.ROUTING="routing",i.GATEWAY="gateway",i.SUB_PROCESS="sub_process",i.SERVICE_TASK="service_task",i))(Bn||{}),ki=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(ki||{}),Ri=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Ri||{}),Di=(m=>(m.SIMPLE="simple",m.LOOP="loop",m.SCRIPT="script",m.SCRIPT_LOOP="script_loop",m.COMPLEX="complex",m.EXCLUSIVE="exclusive",m.PARALLEL="parallel",m.FINAL="final",m.TO_SUB_PROCESS="to_sub_process",m.FROM_SUB_PROCESS="from_sub_process",m.TO_SERVICE_TASK="to_service_task",m.FROM_SERVICE_TASK="from_service_task",m))(Di||{});import{Bot as qp,RotateCcw as Zp,ScrollText as Jp,SquarePlus as Qp}from"lucide-react";import{jsx as zn,jsxs as Hp}from"react/jsx-runtime";var Yn=({size:e=24,className:t})=>Hp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:[zn("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),zn("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),zn("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),zn("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as ta}from"react/jsx-runtime";var To=({size:e=24,className:t})=>ta("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:ta("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as qo,jsxs as Gp}from"react/jsx-runtime";var vo=({size:e=24,className:t})=>Gp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[qo("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),qo("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),qo("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),qo("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),qo("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Oi,jsxs as Bp}from"react/jsx-runtime";var No=({size:e=24,className:t})=>Bp("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:[Oi("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"}),Oi("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Oi("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Vi,jsxs as zp}from"react/jsx-runtime";var wo=({size:e=24,className:t})=>zp("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:[Vi("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"}),Vi("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Vi("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Hi,jsxs as Yp}from"react/jsx-runtime";var oa=({size:e=24,className:t})=>Hi("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:Yp("g",{children:[Hi("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"}),Hi("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as Fp}from"clsx";import{twMerge as Wp}from"tailwind-merge";function H(...e){return Wp(Fp(e))}var Ot=(e=0,t=0)=>e<t?t:e,Fn=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as na,jsxs as Xp}from"react/jsx-runtime";var ra=({size:e=24,className:t})=>Xp("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:H("stroke-2",t),children:[na("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"}),na("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Gi}from"react/jsx-runtime";var ia=({size:e=24,className:t})=>Gi("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:Gi("g",{children:Gi("path",{d:"M4.85372 6.17472L5.31292 5.71552L5.31993 5.70863C6.88908 4.1924 8.98352 3.34122 11.1655 3.33301L11.1668 3.33301C11.167 3.33301 11.1673 3.33301 11.1675 3.33301C12.7165 3.33314 14.2308 3.79255 15.5188 4.65317C16.807 5.5139 17.811 6.7373 18.4039 8.16866C18.9968 9.60001 19.1519 11.175 18.8497 12.6945C18.5986 13.9567 18.0414 15.1334 17.232 16.1236L16.9457 16.4738L17.2655 16.7936L20.6617 20.1899L20.6617 20.1899C20.7919 20.3201 20.7919 20.5311 20.6617 20.6612L20.6616 20.6613C20.5316 20.7915 20.3205 20.7915 20.1903 20.6613L16.7941 17.265L16.4743 16.9452L16.1241 17.2315C15.1339 18.0409 13.9571 18.5981 12.695 18.8492C11.1755 19.1514 9.6005 18.9963 8.16915 18.4034C6.73778 17.8105 5.51439 16.8065 4.65365 15.5183C3.79291 14.2301 3.3335 12.7156 3.3335 11.1663C3.3335 10.9822 3.48273 10.833 3.66683 10.833C3.85093 10.833 4.00016 10.9822 4.00016 11.1663C4.00016 12.5838 4.42048 13.9694 5.20796 15.148C5.99545 16.3265 7.11474 17.245 8.42426 17.7874C9.73378 18.3299 11.1748 18.4719 12.565 18.1953C13.9552 17.9188 15.2321 17.2362 16.2344 16.234L16.2345 16.234C17.2367 15.2316 17.9193 13.9547 18.1958 12.5645C18.4724 11.1743 18.3304 9.7333 17.7879 8.42378C17.2455 7.11426 16.327 5.99497 15.1484 5.20748L14.8707 5.62322L15.1484 5.20748C13.9703 4.42031 12.5854 4.00001 11.1685 3.99968L11.1664 3.99969C9.15876 4.00767 7.23176 4.7903 5.78712 6.18424L5.78706 6.18418L5.78075 6.1905L5.32512 6.64613L4.47156 7.49968H5.67867H7.8335C8.01759 7.49968 8.16683 7.64892 8.16683 7.83302C8.16683 8.01711 8.01759 8.16635 7.8335 8.16635H3.66683C3.48274 8.16635 3.3335 8.01711 3.3335 7.83302V3.66635C3.3335 3.48225 3.48274 3.33302 3.66683 3.33302C3.85092 3.33302 4.00016 3.48225 4.00016 3.66635V5.82117V7.02827L4.85372 6.17472Z"})})});import{jsx as sa}from"react/jsx-runtime";var Wn=({size:e=24,className:t})=>sa("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:sa("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as aa}from"react/jsx-runtime";var Zo=({size:e=24,className:t})=>aa("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",className:H("stroke-2",t),children:aa("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as Bi,jsxs as Up}from"react/jsx-runtime";var la=({size:e=24,className:t})=>Up("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:[Bi("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"}),Bi("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"}),Bi("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Jo,jsxs as $p}from"react/jsx-runtime";var ca=({size:e=24,className:t})=>$p("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:[Jo("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"}),Jo("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"}),Jo("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"}),Jo("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Jo("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Xn,jsxs as Kp}from"react/jsx-runtime";var Qo=({size:e=24,className:t})=>Kp("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:[Xn("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"}),Xn("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),Xn("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Xn("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var ae=(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))(ae||{}),Ze=(n=>(n.SCRIPT="SCRIPT",n.SUBPROCESS="SUBPROCESS",n.SERVICE_TASK="SERVICE_TASK",n))(Ze||{}),Un={SCRIPT:{icon:Jp},SUBPROCESS:{icon:Qp},SERVICE_TASK:{icon:qp}},yt=(t=>(t.LOOP="LOOP",t))(yt||{}),$n={LOOP:{icon:Zp}},ct=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(ct||{}),zi={EXCLUSIVE:{icon:No},PARALLEL:{icon:wo},COMPLEX:{icon:vo}};import{useTranslation as ob}from"@produto-lecom/lecom-ui";import{ReactFlowProvider as nb}from"@xyflow/react";import{createContext as rb,useContext as ib,useEffect as sb,useId as ab,useMemo as Mp,useRef as lb,useState as pt}from"react";import{Background as P_,MiniMap as L_,ReactFlow as k_,SelectionMode as R_,useKeyPress as D_}from"@xyflow/react";import{forwardRef as O_,useImperativeHandle as V_,useRef as Ip}from"react";import{useTranslation as wx}from"@produto-lecom/lecom-ui";import{useEdgesState as Ax,useNodesState as Ix,useOnSelectionChange as Cx,useReactFlow as Sx,useStoreApi as Mx}from"@xyflow/react";import{useCallback as Tt,useEffect as Px}from"react";var Kn={MIN_WIDTH:36,MIN_HEIGHT:36},qn={MIN_WIDTH:36,MIN_HEIGHT:36},Ao={MIN_WIDTH:56,MIN_HEIGHT:56},Vt={MIN_WIDTH:176,MIN_HEIGHT:96},da={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},se={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},Io={MIN_WIDTH:176,MIN_HEIGHT:64},jp={MIN_WIDTH:128,MIN_HEIGHT:64},ue={START_EVENT:Kn,END_EVENT:qn,GATEWAY:Ao,TASK:Vt,LANE:se,ANNOTATION:Io,UNSUPPORTED:jp};import{Position as jo}from"@xyflow/react";function ua(e,t){var x,v,b,N;let{width:o=0,height:n=0}=e.measured||{width:0,height:0},r=e.internals.positionAbsolute,i=t.internals.positionAbsolute,a=o/2,s=n/2,l=r.x+a,c=r.y+s,d=i.x+((v=(x=t==null?void 0:t.measured)==null?void 0:x.width)!=null?v:0)/2,u=i.y+((N=(b=t==null?void 0:t.measured)==null?void 0:b.height)!=null?N:0)/2,m=(d-l)/(2*a)-(u-c)/(2*s),f=(d-l)/(2*a)+(u-c)/(2*s),y=1/(Math.abs(m)+Math.abs(f)||1),E=y*m,p=y*f,g=a*(E+p)+l,h=s*(-E+p)+c;return{x:g,y:h}}function pa(e,t){var c,d,u,m;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(m=(u=e.measured)==null?void 0:u.height)!=null?m: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?jo.Left:s>=i+n-1?jo.Right:l<=a+1?jo.Top:l>=a+r-1?jo.Bottom:jo.Top}function Co(e,t){let o=ua(e,t),n=ua(t,e),r=pa(e,o),i=pa(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function Zn(e,t){return{isFromStartEvent:(e==null?void 0:e.type)==="START_EVENT",isGatewayToGateway:(e==null?void 0:e.type)==="GATEWAY"&&(t==null?void 0:t.type)==="GATEWAY",isActiviyToAndGateway:(e==null?void 0:e.type)==="TASK"&&(t==null?void 0:t.type)==="GATEWAY",isToEndEvent:(t==null?void 0:t.type)==="END_EVENT"}}import{orderBy as ef}from"lodash";var fa=e=>new Map(e.map(t=>[t.id,t])),ma=(e,t)=>e.map(o=>{var n;return(n=t.get(o.id))!=null?n:o}),nt=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}},en=e=>ef(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),ga=(e,t)=>{let{x:o,y:n}=nt(e),{x:r,y:i}=nt(t);return{x:o-r,y:n-i}};var oo=({parentId:e,nodes:t,includeTypes:o=[...Object.values(ae)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),tf=(e,t)=>{let{x:o,y:n}=nt(e),{x:r,y:i}=nt(t),a=o-r,s=n-i;return Math.sqrt(a*a+s*s)},of=(e,t)=>{let{x:o,y:n,w:r,h:i}=nt(e),{x:a,y:s,w:l,h:c}=nt(t),d=o+r/2,u=n+i/2;return d>=a&&d<=a+l&&u>=s&&u<=s+c},tn=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&of(e,r)){let i=tf(e,r);i<n&&(n=i,o=r)}return o},ha=(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 ya=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}},xa=({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 Yi=(e,t)=>{let o=t.find(a=>a.id===e);if(!o||o.type!=="LANE"||o.parentId)return!1;let n=nt(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=nt(a);return s.x<r&&s.x+s.w>n.x&&s.y<i&&s.y+s.h>n.y})};var nf=50,no=(e,t)=>{var m,f,y,E,p,g,h,x,v,b,N,T,A,C,P,R;let o=t.find(S=>S.id===e);if(!o)return t;let n=(f=(m=o.position)==null?void 0:m.x)!=null?f:0,r=(E=(y=o.position)==null?void 0:y.y)!=null?E:0,i=(g=(p=o.measured)==null?void 0:p.width)!=null?g:0,a=(x=(h=o.measured)==null?void 0:h.height)!=null?x:0,s=r+a,l=n+i,c=new Set,d=1/0;for(let S of t){if(S.id===e||S.parentId)continue;let L=(b=(v=S.position)==null?void 0:v.y)!=null?b:0,K=(T=(N=S.position)==null?void 0:N.x)!=null?T:0,j=(C=(A=S.measured)==null?void 0:A.width)!=null?C:0,Q=(R=(P=S.measured)==null?void 0:P.height)!=null?R:0;K<l&&K+j>n&&L<s&&L+Q>r&&(c.add(S.id),d=Math.min(d,L))}if(c.size===0)return t;let u=s+nf-d;return t.map(S=>{var K,j,Q;if(!c.has(S.id))return S;let L=(j=(K=S.position)==null?void 0:K.y)!=null?j:0;return w(_({},S),{position:w(_({},(Q=S.position)!=null?Q:{x:0,y:0}),{y:L+u})})})},Ne=15,ro=e=>[...e].sort((t,o)=>t.position.y-o.position.y),rf=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)},sf=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)},Fi=(e,t,o)=>{var d,u,m,f,y,E,p,g,h,x,v,b,N,T,A;if(t.length===0)return e;let n=(m=(u=e.width)!=null?u:(d=e.measured)==null?void 0:d.width)!=null?m:0,r=(E=(y=e.height)!=null?y:(f=e.measured)==null?void 0:f.height)!=null?E:0,i=0,a=0;for(let C of t){let P=rf(C),R=sf(C);if(((g=(p=C.position)==null?void 0:p.y)!=null?g:0)<Ne&&(o.set(C.id,w(_({},C),{position:w(_({},C.position),{y:Ne})})),R=Ne+((x=(h=C.measured)==null?void 0:h.height)!=null?x:0)),((b=(v=C.position)==null?void 0:v.x)!=null?b:0)<se.HEADER_WIDTH+Ne){let S=(N=o.get(C.id))!=null?N:C;o.set(C.id,w(_({},S),{position:w(_({},S.position),{x:se.HEADER_WIDTH+Ne})})),P=se.HEADER_WIDTH+Ne+((A=(T=C.measured)==null?void 0:T.width)!=null?A:0)}i=Math.max(i,P),a=Math.max(a,R)}let s=Math.max(n,se.MIN_WIDTH),l=Math.max(r,se.MIN_HEIGHT);i+Ne>s&&(s=i+Ne),a+Ne>l&&(l=a+Ne);let c=w(_({},e),{width:s,height:l,measured:w(_({},e.measured),{width:s,height:l})});return o.set(e.id,c),c},Ea=(e,t,o)=>{var a,s;let n=ro(e),r=new Map;for(let l of o)l.parentId&&(r.has(l.parentId)||r.set(l.parentId,[]),r.get(l.parentId).push(l));let i=0;for(let l of n){let c=(a=r.get(l.id))!=null?a:[],d=Fi(l,c,t);t.set(d.id,w(_({},d),{position:{x:se.HEADER_WIDTH,y:i}})),i+=(s=d.height)!=null?s:0}},_a=(e,t)=>{var y,E,p,g;let o=[];for(let h of t.values())h.parentId===e.id&&o.push(h);let n=ro(o),r=((E=(y=e.measured)==null?void 0:y.width)!=null?E:0)-se.HEADER_WIDTH,i=ha(e.id,o)||se.MIN_WIDTH,a=o.reduce((h,x)=>{var v;return h+((v=x.height)!=null?v:se.MIN_HEIGHT)},0),s=Math.max(r,i),l=a,c=r>i,d=c?s:s+se.HEADER_WIDTH,u=c?s-se.HEADER_WIDTH:s,m=0;for(let h=0;h<n.length;h++){let x=n[h],v=Math.max(se.MIN_HEIGHT,(p=x.height)!=null?p:se.MIN_HEIGHT),b=w(_({},x),{width:u,height:v,measured:w(_({},x.measured),{width:u,height:v}),position:{x:se.HEADER_WIDTH,y:m}});if(h===o.length-1){let N=Math.max(se.MIN_HEIGHT,l-m);b=w(_({},b),{height:N,measured:w(_({},x.measured),{width:u,height:N})})}t.set(x.id,b),m+=(g=b.height)!=null?g:0}let f=Math.max(l,m);t.set(e.id,w(_({},e),{width:d,height:f,measured:w(_({},e.measured),{width:d,height:f})}))},ba=(e,t,o,n,r)=>{var y,E;let i=!e.parentId,a=i?e.id:e.parentId,s=n.filter(p=>p.type==="LANE"&&p.parentId===a);if(!s.length)return n;let l=ro(s),c=l.findIndex(p=>p.id===e.id),d=(E=(y=e.position)==null?void 0:y.y)!=null?E:0,u=!i&&r!==void 0&&c>0&&Math.abs(r-d)>.5,m=0,f=[...n];return l.forEach((p,g)=>{var N,T;let h=g===l.length-1,x=p.id===e.id,b=(T=(N=p.measured)==null?void 0:N.height)!=null?T:0;x?b=o:u&&g===c-1&&(b=Math.max(se.MIN_HEIGHT,r-m)),h&&i&&(b=Math.max(se.MIN_HEIGHT,o-m)),f=f.map(A=>{if(A.id===p.id){let C=i?t-se.HEADER_WIDTH:t;return w(_({},A),{width:C,height:b,measured:w(_({},A.measured),{width:C,height:b}),position:{x:se.HEADER_WIDTH,y:m}})}return A}),x&&u?m=r+o:m+=b}),f=f.map(p=>{if(p.id===a){let g=i?t:t+se.HEADER_WIDTH;return w(_({},p),{width:g,height:i?o:m,measured:{width:g,height:i?o:m}})}return p}),f};var Wi=(e,t,o)=>{var s,l,c,d,u,m,f,y;if(e.type==="LANE")return o;let n=(l=(s=t.measured)==null?void 0:s.width)!=null?l:0,r=(d=(c=t.measured)==null?void 0:c.height)!=null?d:0;e.position.y<Ne&&(e.position.y=Ne),e.position.x<se.HEADER_WIDTH+Ne&&(e.position.x=se.HEADER_WIDTH+Ne);let i=e.position.x+((m=(u=e.measured)==null?void 0:u.width)!=null?m:0),a=e.position.y+((y=(f=e.measured)==null?void 0:f.height)!=null?y:0);return i+Ne>n&&(t.width=i+Ne,t.measured.width=i+Ne),a+Ne>r&&(t.height=a+Ne,t.measured.height=a+Ne),o=o.map(E=>E.id===t.id?w(_({},E),{height:t.height,width:t.width,measured:t.measured}):E.id===e.id?w(_({},E),{position:e.position}):E),o};import{useCallback as lf}from"react";import{create as cf}from"zustand";import{useStoreApi as af}from"@xyflow/react";var xt=()=>{let e=af();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 Fn(),!0}}};var Ta=()=>{let{selectElements:e}=xt();return lf(()=>{let o=io.getState().pathEdgeIds;e(o)},[e])},io=cf((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=_({},n.statusByNodeId),i=_({},n.statusData),a=!1;return o.forEach(s=>{let l=`${s.diagramId}-${s.activityId}`;r[s.diagramId]!==s.status&&(r[s.diagramId]=s.status,i[l]=s,a=!0)}),a?{statusByNodeId:r,statusData:i}:n})},getTaskStatus:o=>t().statusByNodeId[o]||null,clearTaskStatuses:()=>e({statusByNodeId:{},statusData:{},pathEdgeIds:[]}),setPathEdges:o=>{e({pathEdgeIds:o})},getPathEdgeIds:()=>t().pathEdgeIds,clearPathEdges:()=>{e({pathEdgeIds:[]})},calculateFlowPath:(o,n)=>{if(!o.length||!n.length)return;t().clearPathEdges();let r=n.filter(d=>t().statusByNodeId[d]);if(r.length<=1)return;let i=[],a={};o.forEach(d=>{a[d.source]||(a[d.source]=[]),a[d.source].push({targetId:d.target,edgeId:d.id})});let s=r[0],l=r[r.length-1];o.forEach(d=>{d.target===s&&i.push(d.id)}),o.forEach(d=>{d.source===l&&i.push(d.id)});let c=(d,u)=>{let m=[],f=new Set;for(m.push({node:d,path:[]}),f.add(d);m.length>0;){let{node:y,path:E}=m.shift();if(y===u)return E;let p=a[y]||[];for(let{targetId:g,edgeId:h}of p)f.has(g)||(f.add(g),m.push({node:g,path:[...E,h]}))}return[]};for(let d=0;d<r.length-1;d++){let u=r[d],m=r[d+1],f=c(u,m);f.length>0&&i.push(...f)}i.length>0&&e({pathEdgeIds:i})}}));import{useNodesInitialized as Ng,useReactFlow as wg,useStore as Ag}from"@xyflow/react";import{useCallback as yn,useEffect as Ig,useRef as Cg,useState as hc}from"react";import{shallow as Sg}from"zustand/shallow";var df={value:()=>{}};function Na(){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 Jn(o)}function Jn(e){this._=e}function uf(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}})}Jn.prototype=Na.prototype={constructor:Jn,on:function(e,t){var o=this._,n=uf(e+"",o),r,i=-1,a=n.length;if(arguments.length<2){for(;++i<a;)if((r=(e=n[i]).type)&&(r=pf(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]=va(o[r],e.name,t);else if(t==null)for(r in o)o[r]=va(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 Jn(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 pf(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function va(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=df,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var Xi=Na;var Qn="http://www.w3.org/1999/xhtml",Ui={svg:"http://www.w3.org/2000/svg",xhtml:Qn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function It(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),Ui.hasOwnProperty(t)?{space:Ui[t],local:e}:e}function ff(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===Qn&&t.documentElement.namespaceURI===Qn?t.createElement(e):t.createElementNS(o,e)}}function mf(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function jn(e){var t=It(e);return(t.local?mf:ff)(t)}function gf(){}function so(e){return e==null?gf:function(){return this.querySelector(e)}}function wa(e){typeof e!="function"&&(e=so(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 Ce(n,this._parents)}function $i(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function hf(){return[]}function on(e){return e==null?hf:function(){return this.querySelectorAll(e)}}function yf(e){return function(){return $i(e.apply(this,arguments))}}function Aa(e){typeof e=="function"?e=yf(e):e=on(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 Ce(n,r)}function nn(e){return function(){return this.matches(e)}}function er(e){return function(t){return t.matches(e)}}var xf=Array.prototype.find;function Ef(e){return function(){return xf.call(this.children,e)}}function _f(){return this.firstElementChild}function Ia(e){return this.select(e==null?_f:Ef(typeof e=="function"?e:er(e)))}var bf=Array.prototype.filter;function Tf(){return Array.from(this.children)}function vf(e){return function(){return bf.call(this.children,e)}}function Ca(e){return this.selectAll(e==null?Tf:vf(typeof e=="function"?e:er(e)))}function Sa(e){typeof e!="function"&&(e=nn(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 Ce(n,this._parents)}function tr(e){return new Array(e.length)}function Ma(){return new Ce(this._enter||this._groups.map(tr),this._parents)}function rn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}rn.prototype={constructor:rn,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 Pa(e){return function(){return e}}function Nf(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 rn(e,i[a]);for(;a<l;++a)(s=t[a])&&(r[a]=s)}function wf(e,t,o,n,r,i,a){var s,l,c=new Map,d=t.length,u=i.length,m=new Array(d),f;for(s=0;s<d;++s)(l=t[s])&&(m[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 rn(e,i[s]);for(s=0;s<d;++s)(l=t[s])&&c.get(m[s])===l&&(r[s]=l)}function Af(e){return e.__data__}function La(e,t){if(!arguments.length)return Array.from(this,Af);var o=t?wf:Nf,n=this._parents,r=this._groups;typeof e!="function"&&(e=Pa(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],m=u.length,f=If(e.call(d,d&&d.__data__,c,n)),y=f.length,E=s[c]=new Array(y),p=a[c]=new Array(y),g=l[c]=new Array(m);o(d,u,E,p,g,f,t);for(var h=0,x=0,v,b;h<y;++h)if(v=E[h]){for(h>=x&&(x=h+1);!(b=p[x])&&++x<y;);v._next=b||null}}return a=new Ce(a,n),a._enter=s,a._exit=l,a}function If(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function ka(){return new Ce(this._exit||this._groups.map(tr),this._parents)}function Ra(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 Da(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,m=s[l]=new Array(u),f,y=0;y<u;++y)(f=c[y]||d[y])&&(m[y]=f);for(;l<r;++l)s[l]=o[l];return new Ce(s,this._parents)}function Oa(){for(var e=this._groups,t=-1,o=e.length;++t<o;)for(var n=e[t],r=n.length-1,i=n[r],a;--r>=0;)(a=n[r])&&(i&&a.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(a,i),i=a);return this}function Va(e){e||(e=Cf);function t(u,m){return u&&m?e(u.__data__,m.__data__):!u-!m}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 Ce(r,this._parents).order()}function Cf(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Ha(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Ga(){return Array.from(this)}function Ba(){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 za(){let e=0;for(let t of this)++e;return e}function Ya(){return!this.node()}function Fa(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 Sf(e){return function(){this.removeAttribute(e)}}function Mf(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Pf(e,t){return function(){this.setAttribute(e,t)}}function Lf(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function kf(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function Rf(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 Wa(e,t){var o=It(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?Mf:Sf:typeof t=="function"?o.local?Rf:kf:o.local?Lf:Pf)(o,t))}function or(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Df(e){return function(){this.style.removeProperty(e)}}function Of(e,t,o){return function(){this.style.setProperty(e,t,o)}}function Vf(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function Xa(e,t,o){return arguments.length>1?this.each((t==null?Df:typeof t=="function"?Vf:Of)(e,t,o==null?"":o)):Ht(this.node(),e)}function Ht(e,t){return e.style.getPropertyValue(t)||or(e).getComputedStyle(e,null).getPropertyValue(t)}function Hf(e){return function(){delete this[e]}}function Gf(e,t){return function(){this[e]=t}}function Bf(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function Ua(e,t){return arguments.length>1?this.each((t==null?Hf:typeof t=="function"?Bf:Gf)(e,t)):this.node()[e]}function $a(e){return e.trim().split(/^|\s+/)}function Ki(e){return e.classList||new Ka(e)}function Ka(e){this._node=e,this._names=$a(e.getAttribute("class")||"")}Ka.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 qa(e,t){for(var o=Ki(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function Za(e,t){for(var o=Ki(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function zf(e){return function(){qa(this,e)}}function Yf(e){return function(){Za(this,e)}}function Ff(e,t){return function(){(t.apply(this,arguments)?qa:Za)(this,e)}}function Ja(e,t){var o=$a(e+"");if(arguments.length<2){for(var n=Ki(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?Ff:t?zf:Yf)(o,t))}function Wf(){this.textContent=""}function Xf(e){return function(){this.textContent=e}}function Uf(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function Qa(e){return arguments.length?this.each(e==null?Wf:(typeof e=="function"?Uf:Xf)(e)):this.node().textContent}function $f(){this.innerHTML=""}function Kf(e){return function(){this.innerHTML=e}}function qf(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function ja(e){return arguments.length?this.each(e==null?$f:(typeof e=="function"?qf:Kf)(e)):this.node().innerHTML}function Zf(){this.nextSibling&&this.parentNode.appendChild(this)}function el(){return this.each(Zf)}function Jf(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function tl(){return this.each(Jf)}function ol(e){var t=typeof e=="function"?e:jn(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Qf(){return null}function nl(e,t){var o=typeof e=="function"?e:jn(e),n=t==null?Qf:typeof t=="function"?t:so(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function jf(){var e=this.parentNode;e&&e.removeChild(this)}function rl(){return this.each(jf)}function em(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function tm(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function il(e){return this.select(e?tm:em)}function sl(e){return arguments.length?this.property("__data__",e):this.node().__data__}function om(e){return function(t){e.call(this,t,this.__data__)}}function nm(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 rm(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 im(e,t,o){return function(){var n=this.__on,r,i=om(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 al(e,t,o){var n=nm(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?im:rm,r=0;r<i;++r)this.each(s(n[r],t,o));return this}function ll(e,t,o){var n=or(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 sm(e,t){return function(){return ll(this,e,t)}}function am(e,t){return function(){return ll(this,e,t.apply(this,arguments))}}function cl(e,t){return this.each((typeof t=="function"?am:sm)(e,t))}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,a;r<i;++r)(a=n[r])&&(yield a)}var lm=[null];function Ce(e,t){this._groups=e,this._parents=t}function ul(){return new Ce([[document.documentElement]],lm)}function cm(){return this}Ce.prototype=ul.prototype={constructor:Ce,select:wa,selectAll:Aa,selectChild:Ia,selectChildren:Ca,filter:Sa,data:La,enter:Ma,exit:ka,join:Ra,merge:Da,selection:cm,order:Oa,sort:Va,call:Ha,nodes:Ga,node:Ba,size:za,empty:Ya,each:Fa,attr:Wa,style:Xa,property:Ua,classed:Ja,text:Qa,html:ja,raise:el,lower:tl,append:ol,insert:nl,remove:rl,clone:il,datum:sl,on:al,dispatch:cl,[Symbol.iterator]:dl};var Ct=ul;function nr(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function qi(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function ln(){}var sn=.7,sr=1/sn,So="\\s*([+-]?\\d+)\\s*",an="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Et="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",dm=/^#([0-9a-f]{3,8})$/,um=new RegExp(`^rgb\\(${So},${So},${So}\\)$`),pm=new RegExp(`^rgb\\(${Et},${Et},${Et}\\)$`),fm=new RegExp(`^rgba\\(${So},${So},${So},${an}\\)$`),mm=new RegExp(`^rgba\\(${Et},${Et},${Et},${an}\\)$`),gm=new RegExp(`^hsl\\(${an},${Et},${Et}\\)$`),hm=new RegExp(`^hsla\\(${an},${Et},${Et},${an}\\)$`),pl={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};nr(ln,Gt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:fl,formatHex:fl,formatHex8:ym,formatHsl:xm,formatRgb:ml,toString:ml});function fl(){return this.rgb().formatHex()}function ym(){return this.rgb().formatHex8()}function xm(){return _l(this).formatHsl()}function ml(){return this.rgb().formatRgb()}function Gt(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=dm.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?gl(t):o===3?new ze(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?rr(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?rr(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=um.exec(e))?new ze(t[1],t[2],t[3],1):(t=pm.exec(e))?new ze(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=fm.exec(e))?rr(t[1],t[2],t[3],t[4]):(t=mm.exec(e))?rr(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=gm.exec(e))?xl(t[1],t[2]/100,t[3]/100,1):(t=hm.exec(e))?xl(t[1],t[2]/100,t[3]/100,t[4]):pl.hasOwnProperty(e)?gl(pl[e]):e==="transparent"?new ze(NaN,NaN,NaN,0):null}function gl(e){return new ze(e>>16&255,e>>8&255,e&255,1)}function rr(e,t,o,n){return n<=0&&(e=t=o=NaN),new ze(e,t,o,n)}function Em(e){return e instanceof ln||(e=Gt(e)),e?(e=e.rgb(),new ze(e.r,e.g,e.b,e.opacity)):new ze}function Mo(e,t,o,n){return arguments.length===1?Em(e):new ze(e,t,o,n==null?1:n)}function ze(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}nr(ze,Mo,qi(ln,{brighter(e){return e=e==null?sr:Math.pow(sr,e),new ze(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?sn:Math.pow(sn,e),new ze(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ze(lo(this.r),lo(this.g),lo(this.b),ar(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:hl,formatHex:hl,formatHex8:_m,formatRgb:yl,toString:yl}));function hl(){return`#${ao(this.r)}${ao(this.g)}${ao(this.b)}`}function _m(){return`#${ao(this.r)}${ao(this.g)}${ao(this.b)}${ao((isNaN(this.opacity)?1:this.opacity)*255)}`}function yl(){let e=ar(this.opacity);return`${e===1?"rgb(":"rgba("}${lo(this.r)}, ${lo(this.g)}, ${lo(this.b)}${e===1?")":`, ${e})`}`}function ar(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function lo(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ao(e){return e=lo(e),(e<16?"0":"")+e.toString(16)}function xl(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new dt(e,t,o,n)}function _l(e){if(e instanceof dt)return new dt(e.h,e.s,e.l,e.opacity);if(e instanceof ln||(e=Gt(e)),!e)return new dt;if(e instanceof dt)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 dt(a,s,l,e.opacity)}function bl(e,t,o,n){return arguments.length===1?_l(e):new dt(e,t,o,n==null?1:n)}function dt(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}nr(dt,bl,qi(ln,{brighter(e){return e=e==null?sr:Math.pow(sr,e),new dt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?sn:Math.pow(sn,e),new dt(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 ze(Zi(e>=240?e-240:e+120,r,n),Zi(e,r,n),Zi(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new dt(El(this.h),ir(this.s),ir(this.l),ar(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=ar(this.opacity);return`${e===1?"hsl(":"hsla("}${El(this.h)}, ${ir(this.s)*100}%, ${ir(this.l)*100}%${e===1?")":`, ${e})`}`}}));function El(e){return e=(e||0)%360,e<0?e+360:e}function ir(e){return Math.max(0,Math.min(1,e||0))}function Zi(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 Ji(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 Tl(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 Ji((o-n/t)*t,a,r,i,s)}}function vl(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 Ji((o-n/t)*t,r,i,a,s)}}var Qi=e=>()=>e;function bm(e,t){return function(o){return e+o*t}}function Tm(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 Nl(e){return(e=+e)==1?lr:function(t,o){return o-t?Tm(t,o,e):Qi(isNaN(t)?o:t)}}function lr(e,t){var o=t-e;return o?bm(e,o):Qi(isNaN(e)?t:e)}var cr=function e(t){var o=Nl(t);function n(r,i){var a=o((r=Mo(r)).r,(i=Mo(i)).r),s=o(r.g,i.g),l=o(r.b,i.b),c=lr(r.opacity,i.opacity);return function(d){return r.r=a(d),r.g=s(d),r.b=l(d),r.opacity=c(d),r+""}}return n.gamma=e,n}(1);function wl(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=Mo(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 vm=wl(Tl),Nm=wl(vl);function rt(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var es=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ji=new RegExp(es.source,"g");function wm(e){return function(){return e}}function Am(e){return function(t){return e(t)+""}}function ts(e,t){var o=es.lastIndex=ji.lastIndex=0,n,r,i,a=-1,s=[],l=[];for(e=e+"",t=t+"";(n=es.exec(e))&&(r=ji.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:rt(n,r)})),o=ji.lastIndex;return o<t.length&&(i=t.slice(o),s[a]?s[a]+=i:s[++a]=i),s.length<2?l[0]?Am(l[0].x):wm(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 Al=180/Math.PI,dr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function os(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)*Al,skewX:Math.atan(l)*Al,scaleX:a,scaleY:s}}var ur;function Il(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?dr:os(t.a,t.b,t.c,t.d,t.e,t.f)}function Cl(e){return e==null?dr:(ur||(ur=document.createElementNS("http://www.w3.org/2000/svg","g")),ur.setAttribute("transform",e),(e=ur.transform.baseVal.consolidate())?(e=e.matrix,os(e.a,e.b,e.c,e.d,e.e,e.f)):dr)}function Sl(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,m,f,y){if(c!==u||d!==m){var E=f.push("translate(",null,t,null,o);y.push({i:E-4,x:rt(c,u)},{i:E-2,x:rt(d,m)})}else(u||m)&&f.push("translate("+u+t+m+o)}function a(c,d,u,m){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),m.push({i:u.push(r(u)+"rotate(",null,n)-2,x:rt(c,d)})):d&&u.push(r(u)+"rotate("+d+n)}function s(c,d,u,m){c!==d?m.push({i:u.push(r(u)+"skewX(",null,n)-2,x:rt(c,d)}):d&&u.push(r(u)+"skewX("+d+n)}function l(c,d,u,m,f,y){if(c!==u||d!==m){var E=f.push(r(f)+"scale(",null,",",null,")");y.push({i:E-4,x:rt(c,u)},{i:E-2,x:rt(d,m)})}else(u!==1||m!==1)&&f.push(r(f)+"scale("+u+","+m+")")}return function(c,d){var u=[],m=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,u,m),a(c.rotate,d.rotate,u,m),s(c.skewX,d.skewX,u,m),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,m),c=d=null,function(f){for(var y=-1,E=m.length,p;++y<E;)u[(p=m[y]).i]=p.x(f);return u.join("")}}}var ns=Sl(Il,"px, ","px)","deg)"),rs=Sl(Cl,", ",")",")");var Po=0,dn=0,cn=0,Pl=1e3,pr,un,fr=0,co=0,mr=0,pn=typeof performance=="object"&&performance.now?performance:Date,Ll=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function mn(){return co||(Ll(Im),co=pn.now()+mr)}function Im(){co=0}function fn(){this._call=this._time=this._next=null}fn.prototype=gr.prototype={constructor:fn,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?mn():+o)+(t==null?0:+t),!this._next&&un!==this&&(un?un._next=this:pr=this,un=this),this._call=e,this._time=o,is()},stop:function(){this._call&&(this._call=null,this._time=1/0,is())}};function gr(e,t,o){var n=new fn;return n.restart(e,t,o),n}function kl(){mn(),++Po;for(var e=pr,t;e;)(t=co-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Po}function Ml(){co=(fr=pn.now())+mr,Po=dn=0;try{kl()}finally{Po=0,Sm(),co=0}}function Cm(){var e=pn.now(),t=e-fr;t>Pl&&(mr-=t,fr=e)}function Sm(){for(var e,t=pr,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:pr=o);un=e,is(n)}function is(e){if(!Po){dn&&(dn=clearTimeout(dn));var t=e-co;t>24?(e<1/0&&(dn=setTimeout(Ml,e-pn.now()-mr)),cn&&(cn=clearInterval(cn))):(cn||(fr=pn.now(),cn=setInterval(Cm,Pl)),Po=1,Ll(Ml))}}function hr(e,t,o){var n=new fn;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var Mm=Xi("start","end","cancel","interrupt"),Pm=[],Ol=0,Rl=1,xr=2,yr=3,Dl=4,Er=5,gn=6;function Bt(e,t,o,n,r,i){var a=e.__transition;if(!a)e.__transition={};else if(o in a)return;Lm(e,o,{name:t,index:n,group:r,on:Mm,tween:Pm,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Ol})}function hn(e,t){var o=Se(e,t);if(o.state>Ol)throw new Error("too late; already scheduled");return o}function Re(e,t){var o=Se(e,t);if(o.state>yr)throw new Error("too late; already running");return o}function Se(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function Lm(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=gr(i,0,o.time);function i(c){o.state=Rl,o.timer.restart(a,o.delay,o.time),o.delay<=c&&a(c-o.delay)}function a(c){var d,u,m,f;if(o.state!==Rl)return l();for(d in n)if(f=n[d],f.name===o.name){if(f.state===yr)return hr(a);f.state===Dl?(f.state=gn,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete n[d]):+d<t&&(f.state=gn,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete n[d])}if(hr(function(){o.state===yr&&(o.state=Dl,o.timer.restart(s,o.delay,o.time),s(c))}),o.state=xr,o.on.call("start",e,e.__data__,o.index,o.group),o.state===xr){for(o.state=yr,r=new Array(m=o.tween.length),d=0,u=-1;d<m;++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=Er,1),u=-1,m=r.length;++u<m;)r[u].call(e,d);o.state===Er&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=gn,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function ss(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>xr&&n.state<Er,n.state=gn,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[a]}i&&delete e.__transition}}function Vl(e){return this.each(function(){ss(this,e)})}function km(e,t){var o,n;return function(){var r=Re(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 Rm(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=Re(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 Hl(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=Se(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?km:Rm)(o,e,t))}function Lo(e,t,o){var n=e._id;return e.each(function(){var r=Re(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return Se(r,n).value[t]}}function _r(e,t){var o;return(typeof t=="number"?rt:t instanceof Gt?cr:(o=Gt(t))?(t=o,cr):ts)(e,t)}function Dm(e){return function(){this.removeAttribute(e)}}function Om(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Vm(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 Hm(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 Gm(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 Bm(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 Gl(e,t){var o=It(e),n=o==="transform"?rs:_r;return this.attrTween(e,typeof t=="function"?(o.local?Bm:Gm)(o,n,Lo(this,"attr."+e,t)):t==null?(o.local?Om:Dm)(o):(o.local?Hm:Vm)(o,n,t))}function zm(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function Ym(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function Fm(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Ym(e,i)),o}return r._value=t,r}function Wm(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&zm(e,i)),o}return r._value=t,r}function Bl(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=It(e);return this.tween(o,(n.local?Fm:Wm)(n,t))}function Xm(e,t){return function(){hn(this,e).delay=+t.apply(this,arguments)}}function Um(e,t){return t=+t,function(){hn(this,e).delay=t}}function zl(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Xm:Um)(t,e)):Se(this.node(),t).delay}function $m(e,t){return function(){Re(this,e).duration=+t.apply(this,arguments)}}function Km(e,t){return t=+t,function(){Re(this,e).duration=t}}function Yl(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?$m:Km)(t,e)):Se(this.node(),t).duration}function qm(e,t){if(typeof t!="function")throw new Error;return function(){Re(this,e).ease=t}}function Fl(e){var t=this._id;return arguments.length?this.each(qm(t,e)):Se(this.node(),t).ease}function Zm(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;Re(this,e).ease=o}}function Wl(e){if(typeof e!="function")throw new Error;return this.each(Zm(this._id,e))}function Xl(e){typeof e!="function"&&(e=nn(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 He(n,this._parents,this._name,this._id)}function Ul(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),m,f=0;f<d;++f)(m=l[f]||c[f])&&(u[f]=m);for(;s<n;++s)a[s]=t[s];return new He(a,this._parents,this._name,this._id)}function Jm(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 Qm(e,t,o){var n,r,i=Jm(t)?hn:Re;return function(){var a=i(this,e),s=a.on;s!==n&&(r=(n=s).copy()).on(t,o),a.on=r}}function $l(e,t){var o=this._id;return arguments.length<2?Se(this.node(),o).on.on(e):this.each(Qm(o,e,t))}function jm(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function Kl(){return this.on("end.remove",jm(this._id))}function ql(e){var t=this._name,o=this._id;typeof e!="function"&&(e=so(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,m=0;m<l;++m)(d=s[m])&&(u=e.call(d,d.__data__,m,s))&&("__data__"in d&&(u.__data__=d.__data__),c[m]=u,Bt(c[m],t,o,m,c,Se(d,o)));return new He(i,this._parents,t,o)}function Zl(e){var t=this._name,o=this._id;typeof e!="function"&&(e=on(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 m=e.call(d,d.__data__,u,l),f,y=Se(d,o),E=0,p=m.length;E<p;++E)(f=m[E])&&Bt(f,t,o,E,m,y);i.push(m),a.push(d)}return new He(i,a,t,o)}var eg=Ct.prototype.constructor;function Jl(){return new eg(this._groups,this._parents)}function tg(e,t){var o,n,r;return function(){var i=Ht(this,e),a=(this.style.removeProperty(e),Ht(this,e));return i===a?null:i===o&&a===n?r:r=t(o=i,n=a)}}function Ql(e){return function(){this.style.removeProperty(e)}}function og(e,t,o){var n,r=o+"",i;return function(){var a=Ht(this,e);return a===r?null:a===n?i:i=t(n=a,o)}}function ng(e,t,o){var n,r,i;return function(){var a=Ht(this,e),s=o(this),l=s+"";return s==null&&(l=s=(this.style.removeProperty(e),Ht(this,e))),a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s))}}function rg(e,t){var o,n,r,i="style."+t,a="end."+i,s;return function(){var l=Re(this,e),c=l.on,d=l.value[i]==null?s||(s=Ql(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(a,r=d),l.on=n}}function jl(e,t,o){var n=(e+="")=="transform"?ns:_r;return t==null?this.styleTween(e,tg(e,n)).on("end.style."+e,Ql(e)):typeof t=="function"?this.styleTween(e,ng(e,n,Lo(this,"style."+e,t))).each(rg(this._id,e)):this.styleTween(e,og(e,n,t),o).on("end.style."+e,null)}function ig(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function sg(e,t,o){var n,r;function i(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&ig(e,a,o)),n}return i._value=t,i}function ec(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,sg(e,t,o==null?"":o))}function ag(e){return function(){this.textContent=e}}function lg(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function tc(e){return this.tween("text",typeof e=="function"?lg(Lo(this,"text",e)):ag(e==null?"":e+""))}function cg(e){return function(t){this.textContent=e.call(this,t)}}function dg(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&cg(r)),t}return n._value=e,n}function oc(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,dg(e))}function nc(){for(var e=this._name,t=this._id,o=br(),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=Se(l,t);Bt(l,e,o,c,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new He(n,this._parents,e,o)}function rc(){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=Re(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 ug=0;function He(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function ic(e){return Ct().transition(e)}function br(){return++ug}var St=Ct.prototype;He.prototype=ic.prototype={constructor:He,select:ql,selectAll:Zl,selectChild:St.selectChild,selectChildren:St.selectChildren,filter:Xl,merge:Ul,selection:Jl,transition:nc,call:St.call,nodes:St.nodes,node:St.node,size:St.size,empty:St.empty,each:St.each,on:$l,attr:Gl,attrTween:Bl,style:jl,styleTween:ec,text:tc,textTween:oc,remove:Kl,tween:Hl,delay:zl,duration:Yl,ease:Fl,easeVarying:Wl,end:rc,[Symbol.iterator]:St[Symbol.iterator]};function Tr(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var pg={time:null,delay:0,duration:250,ease:Tr};function fg(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 sc(e){var t,o;e instanceof He?(t=e._id,e=e._name):(t=br(),(o=pg).time=mn(),e=e==null?null:e+"");for(var n=this._groups,r=n.length,i=0;i<r;++i)for(var a=n[i],s=a.length,l,c=0;c<s;++c)(l=a[c])&&Bt(l,e,t,c,a,o||fg(l,t));return new He(n,this._parents,e,t)}Ct.prototype.interrupt=Vl;Ct.prototype.transition=sc;function zt(e,t,o){this.k=e,this.x=t,this.y=o}zt.prototype={constructor:zt,scale:function(e){return e===1?this:new zt(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new zt(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 vr=new zt(1,0,0);Nr.prototype=zt.prototype;function Nr(e){for(;!e.__zoom;)if(!(e=e.parentNode))return vr;return e.__zoom}var gg=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var ac;(function(e){e.Strict="strict",e.Loose="loose"})(ac||(ac={}));var lc;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(lc||(lc={}));var cc;(function(e){e.Partial="partial",e.Full="full"})(cc||(cc={}));var dc;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(dc||(dc={}));var uc;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(uc||(uc={}));var Ye;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ye||(Ye={}));var eA={[Ye.Left]:Ye.Right,[Ye.Right]:Ye.Left,[Ye.Top]:Ye.Bottom,[Ye.Bottom]:Ye.Top};var hg=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var yg=(e,t=[0,0])=>{var s;let{width:o,height:n}=xg(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 wr=(e,t=[0,0])=>{var r,i,a,s,l,c,d,u;let{x:o,y:n}=hg(e)?e.internals.positionAbsolute:yg(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 xg(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 tA={[Ye.Left]:{x:-1,y:0},[Ye.Right]:{x:1,y:0},[Ye.Top]:{x:0,y:-1},[Ye.Bottom]:{x:0,y:1}};var Eg={nodeOrigin:[0,0],nodeExtent:gg,elevateNodesOnSelect:!0,defaults:{}},oA=w(_({},Eg),{checkEquality:!0});var pc;(function(e){e.Line="line",e.Handle="handle"})(pc||(pc={}));var _g={width:0,height:0,x:0,y:0},nA=w(_({},_g),{pointerX:0,pointerY:0,aspectRatio:1});var bg=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function Tg(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 vg(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 Ar=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)||!bg(f.nodeBox,r))continue;let y=Math.abs(f.position-o);if(y>Ir)continue;let p=Tg(f.nodeBox,n)>0?0:vg(f.nodeBox,n);c.push({line:f,lineDist:y,nodeDist:p})}let d=.5,u=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;c.sort((f,y)=>{if(u){if(f.line===u&&y.line!==u)return-1;if(y.line===u&&f.line!==u)return 1}return Math.abs(f.lineDist-y.lineDist)<=d?f.nodeDist-y.nodeDist:f.lineDist-y.lineDist});let m=c.length>0?c[0].line:void 0;return m&&(t==="horizontal"?this.lastHorizontalLine=m:this.lastVerticalLine=m),m}};function fc(e,t=uo,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=wr(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 mc(e,t,o,n,r=Object.keys(uo)){let i=[];for(let s of r){let l=uo[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 gc(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)<=Ir&&(r=l,a=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=Ir&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:a}}var Ir=10,uo={top:{orientation:"horizontal",resolve:(e,t)=>t.y},bottom:{orientation:"horizontal",resolve:(e,t)=>t.y2},left:{orientation:"vertical",resolve:(e,t)=>t.x},right:{orientation:"vertical",resolve:(e,t)=>t.x2},centerX:{orientation:"vertical",resolve:(e,t)=>(t.x+t.x2)/2},centerY:{orientation:"horizontal",resolve:(e,t)=>(t.y+t.y2)/2}};import{jsx as Pg}from"react/jsx-runtime";var Mg=new Ar;function Cr(){let[e,t]=hc(void 0),[o,n]=hc(void 0),{width:r,height:i}=Ag(p=>({width:p.width,height:p.height}),Sg),a=Ng(),s=Cg(Mg),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=wg(),u=yn(()=>{t(void 0),n(void 0)},[]),m=yn(p=>{let g=p!=null?p:d();u();let h=fc(g,uo,c);s.current.initialize(h)},[c,u,d]),f=yn(()=>{setTimeout(()=>{m()},100)},[m]);Ig(()=>{a&&m(d())},[a,m,d]);let y=yn((p,g)=>{var G,k,O,Y,F,U,X,$,te,ie;if(!s.current||p.length===0||p.filter(W=>W.type==="dimensions").length>1)return p;u();let x=p.filter(W=>W.type==="position"&&!!W.position),v=p.find(W=>W.type==="dimensions");if(x.length===0&&!v)return p;let b=Object.keys(uo),N=new Set,T=1/0,A=1/0,C=-1/0,P=-1/0;if(x.length>0)x.forEach(W=>{var de,re,ee,ge,be,Te;let oe=g.find(ke=>ke.id===W.id);if(!oe)return;N.add(oe.id);let le=c(oe.id);if(!le)return;let Z=le.parentId?c(le.parentId):void 0,xe=W.position.x+((de=Z==null?void 0:Z.internals.positionAbsolute.x)!=null?de:0),me=W.position.y+((re=Z==null?void 0:Z.internals.positionAbsolute.y)!=null?re:0),_e=(ge=(ee=oe.measured)==null?void 0:ee.width)!=null?ge:0,J=(Te=(be=oe.measured)==null?void 0:be.height)!=null?Te:0;T=Math.min(T,xe),A=Math.min(A,me),C=Math.max(C,xe+_e),P=Math.max(P,me+J)}),v&&(b=["top","left"]);else if(v){let W=g.find(_e=>_e.id===v.id);if(!W)return p;N.add(W.id);let oe=c(W.id);if(!oe)return p;let le=oe.internals.positionAbsolute.x,Z=oe.internals.positionAbsolute.y,xe=(Y=(O=(G=v.dimensions)==null?void 0:G.width)!=null?O:(k=W.measured)==null?void 0:k.width)!=null?Y:0,me=($=(X=(F=v.dimensions)==null?void 0:F.height)!=null?X:(U=W.measured)==null?void 0:U.height)!=null?$:0;T=le,A=Z,C=le+xe,P=Z+me,b=["right","bottom"]}if(T===1/0)return p;let R={x:T,y:A,x2:C,y2:P},{x:S,y:L}=l({x:0,y:0}),{x:K,y:j}=l({x:r,y:i}),Q={x:S,y:L,x2:K,y2:j},{horizontal:z,vertical:M}=mc(s.current,Q,R,N,b),{deltaX:V,deltaY:D,snappedX:I,snappedY:B}=gc(R,z,M);if(I||B){let W=x.some(le=>le.dragging),oe=!!(v!=null&&v.resizing);(W||oe)&&(I&&n(M==null?void 0:M.line),B&&t(z==null?void 0:z.line)),I&&(x.forEach(le=>{le.position&&(le.position.x-=V)}),(v==null?void 0:v.id)===((te=x[0])==null?void 0:te.id)?v.dimensions&&(v.dimensions.width+=V):v&&!x.length&&v.dimensions&&(v.dimensions.width-=V)),B&&(x.forEach(le=>{le.position&&(le.position.y-=D)}),(v==null?void 0:v.id)===((ie=x[0])==null?void 0:ie.id)?v.dimensions&&(v.dimensions.height+=D):v&&!x.length&&v.dimensions&&(v.dimensions.height-=D))}return p},[l,c,r,i,t,n,u]),E=yn(()=>Pg(yc,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:m,forceRebuildIndex:f,updateHelperLines:y,helperLineHorizontal:e,helperLineVertical:o,HelperLines:E}}import{reconnectEdge as O0,useReactFlow as V0}from"@xyflow/react";import{useCallback as yo,useRef as H0}from"react";var Mt=e=>new Map(e.map(t=>[t.id,t])),xn=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),xc=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),as=e=>e.some(t=>t.type==="START_EVENT"),Yt=(e,t)=>e==="START_EVENT"?!as(t):!0,Ec=(e,t,o,n,r)=>{let i=Mt(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:xn(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},_c=(e,t,o,n,r)=>{let i=Mt(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:xc(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Sr=(e,t,o,n,r)=>{var c;let i=Mt(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:xn(e,n,r).filter(d=>{let u=i.get(d.target);return(u==null?void 0:u.type)!=="ANNOTATION"}).length>=2},bc=(e,t,o)=>{var a,s,l,c;let n=Mt(o),r=n.get(e),i=n.get(t);return(r==null?void 0:r.type)!=="GATEWAY"||(i==null?void 0:i.type)!=="GATEWAY"||((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"},Mr=(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"},Tc=(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"},En=(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"},Pr=(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"},po=(e,t,o,n)=>{let r=Mt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:xc(e,o,n).some(s=>{let l=r.get(s.source);return(l==null?void 0:l.type)==="START_EVENT"})},_n=(e,t,o,n)=>{let r=Mt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:xn(e,o,n).some(s=>{let l=r.get(s.target);return(l==null?void 0:l.type)==="END_EVENT"})},vc=(e,t,o,n,r)=>{let i=Mt(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"?_n(t,o,n,r):(s==null?void 0:s.type)==="END_EVENT"&&(a==null?void 0:a.type)==="TASK"?po(e,o,n,r):!1},Lr=(e,t,o)=>xn(e,t,o).length>0,kr=(e,t,o,n,r)=>{let i=Mt(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:xn(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var Nc=(e,t,o,n,r)=>{var s,l;let i=Mt(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 Lg=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!Nc(e.sourceNodeId,e.targetNodeId,e.edges,e.nodes,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!Ec(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!_c(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!Sr(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!kr(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:bc(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"&&Tc(e.targetNodeId,e.nodes)),reason:"start_event_to_subprocess_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&En(e.targetNodeId,e.nodes)),reason:"start_event_to_service_task_not_allowed"}),e=>({isValid:!(En(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:!(Mr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(Pr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(po(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!vc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(_n(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(Lr(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"})],ls=e=>{for(let t of Lg){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var kg=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:Sr(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:as(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Mr(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Pr(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:En(e.sourceNodeId,e.nodes),reason:"service_task_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:po(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:_n(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Lr(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:kr(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],wc=e=>{let t=kg.filter(o=>{let n=!o.sourceTypes||o.sourceTypes.includes(e.sourceNodeType),r=!o.targetTypes||o.targetTypes.includes(e.targetNodeType);return n&&r});for(let o of t){let n=o.validate(e);if(n.shouldDisable)return n}return{shouldDisable:!1}};import{BaseEdge as lh,EdgeLabelRenderer as ch,getStraightPath as dh,useInternalNode as Ic,useViewport as uh}from"@xyflow/react";import{Button as Dg,Tooltip as Og,TooltipContent as Vg,TooltipTrigger as Hg,useTranslation as Gg}from"@produto-lecom/lecom-ui";import{Settings as Bg}from"lucide-react";import{getIncomers as Rr,getOutgoers as Dr,useReactFlow as Rg}from"@xyflow/react";var Or=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=Rg(),{selectElements:r}=xt(),i=p=>{let g=o(),h=n(),x=Rr(p,g,h),v=Dr(p,g,h),b=x.some(T=>T.type==="START_EVENT"),N=v.some(T=>T.type==="END_EVENT");return b?"start":N?"end":"between"},a=(p,g,h)=>{var b,N,T,A,C;if(!p)return;let x={type:p.type,variant:(b=p.data)==null?void 0:b.variant,attribute:(N=p.data)==null?void 0:N.attribute},v={id:p.id,position:i(p),label:(T=p.data)==null?void 0:T.label,node:x};return p.type==="TASK"&&((A=p.data)==null?void 0:A.variant)==="SUBPROCESS"?w(_({},v),{type:"sub_process"}):p.type==="TASK"&&((C=p.data)==null?void 0:C.variant)==="SERVICE_TASK"?w(_({},v),{type:"service_task"}):p.type==="GATEWAY"?w(_({},v),{type:"gateway",variant:s(p,g,h)}):w(_({},v),{type:"activity"})},s=(p,g,h)=>{if(p.type!=="GATEWAY")return;let x=Rr(p,g,h),v=!1,b=!1;if(x.forEach(N=>{var T,A;N.type==="TASK"&&(((T=N.data)==null?void 0:T.variant)==="SCRIPT"&&(v=!0),((A=N.data)==null?void 0:A.attribute)==="LOOP"&&(b=!0))}),v&&b)return"script_loop";if(v)return"script";if(b)return"loop"},l=(p,g,h)=>{var T,A,C,P,R;let x=e(p.source),v=e(p.target);if(!x||!v)return"simple";if(Dr(x,g,h).some(S=>S.type==="END_EVENT"))return"final";if(x.type==="GATEWAY")switch((T=x.data)==null?void 0:T.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(x.type==="TASK"){let S=(A=x.data)==null?void 0:A.variant,L=(C=x.data)==null?void 0:C.attribute;if(S==="SUBPROCESS")return"from_sub_process";if(S==="SERVICE_TASK")return"from_service_task";if(v.type==="TASK"&&((P=v.data)==null?void 0:P.variant)==="SUBPROCESS")return"to_sub_process";if(v.type==="TASK"&&((R=v.data)==null?void 0:R.variant)==="SERVICE_TASK")return"to_service_task";let K=S==="SCRIPT",j=L==="LOOP";return K&&j?"script_loop":K?"script":j?"loop":"simple"}return"simple"},c=(p,g,h)=>{let x=[];function v(N,T,A=0){let C=a(N,g,h);if(C.depth=A,T.push(C),N.type==="TASK"){x.push([...T]),T.pop();return}let P=Rr(N,g,h);if(P.length)for(let R of P)v(R,T,A+1);T.pop()}let b=Rr(p,g,h);for(let N of b)v(N,[]);return x},d=(p,g,h)=>{let x=[];function v(N,T,A=0){let C=a(N,g,h);if(C.depth=A,T.push(C),N.type==="TASK"){x.push([...T]),T.pop();return}let P=Dr(N,g,h);if(P.length)for(let R of P)v(R,T,A+1);T.pop()}let b=Dr(p,g,h);for(let N of b)v(N,[]);return x},u=(p,g,h)=>(h=h.filter(v=>v.source===p.id),h.map(v=>{var T;let b=e(v.target),N;return b&&(N=a(b,g,h)),{id:v.id,type:"routing",variant:l(v,g,h),label:(T=v.data)==null?void 0:T.label,target:N}})),m=p=>{let g=e(p);if(!g)return;let h=o(),x=n(),v=a(g,h,x);return v.sources=c(g,h,x),v.targets=d(g,h,x),v.edgeTargets=u(g,h,x),g.type==="GATEWAY"&&(v.variant=s(g,h,x)),v},f=p=>{let g=t(p);if(!g)return;let h=o(),x=n(),v=l(g,h,x),N={id:g.id,type:"routing",variant:v,gatewayVariant:void 0},T=e(g.source);if(T){let C=a(T,h,x);N.source=C;let P=s(T,h,x);if(N.gatewayVariant=P,T.type==="TASK")N.sources=[[C]];else{let R=c(T,h,x);N.sources=R.length?R:[[C]]}}let A=e(g.target);if(A){let C=a(A,h,x);if(N.target=C,A.type==="TASK")N.targets=[[C]];else{let P=d(A,h,x);N.targets=P.length?P:[[C]]}}return N},y=p=>{let g=e(p);if(g)return m(g.id);let h=t(p);if(h)return f(h.id)};return{configureElement:p=>{let g=y(p);if(g)return r([p]),g},getConfigureElement:y,getNodeConfigure:m,getEdgeConfigure:f}};import{jsx as Vr,jsxs as Yg}from"react/jsx-runtime";var zg={node:"editor.toolbar.configure_node",edge:"editor.toolbar.configure_edge",gateway:"editor.toolbar.configure_gateway"},Ft=({elementId:e,elementType:t="node"})=>{let{t:o}=Gg(),{onConfigureElement:n}=q(),{getConfigureElement:r}=Or();return Yg(Og,{children:[Vr(Hg,{asChild:!0,children:Vr(Dg,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let a=r(e);a&&(n==null||n(a))},children:Vr(Bg,{size:16})})}),Vr(Vg,{color:"black",children:o(zg[t])})]})};import{Button as Wg,Tooltip as Xg,TooltipContent as Ug,TooltipTrigger as $g,useTranslation as Kg}from"@produto-lecom/lecom-ui";import{useReactFlow as qg}from"@xyflow/react";import{TrashIcon as Zg}from"lucide-react";import{useNotificationToast as Fg}from"@produto-lecom/lecom-ui";function Fe(){let{toast:e}=bn(),{toast:t}=Fg();return{toast:e||t}}import{jsx as Hr,jsxs as Jg}from"react/jsx-runtime";var Gr=({elementId:e,elementType:t="node"})=>{let{t:o}=Kg(),{toast:n}=Fe(),{deleteElements:r,getNodes:i}=qg();return Jg(Xg,{children:[Hr($g,{asChild:!0,children:Hr(Wg,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{if(t==="node"){let s=i(),l=s.find(c=>c.id===e);if((l==null?void 0:l.type)==="LANE"&&s.some(d=>d.parentId===e)){n({variant:"error",title:o("validation.errors.title"),content:o("editor.toolbar.delete_pool_lane_error")});return}r({nodes:[{id:e}]})}else r({edges:[{id:e}]})},children:Hr(Zg,{size:16})})}),Hr(Ug,{color:"black",children:o("editor.toolbar.delete")})]})};import{Button as Qg,Tooltip as jg,TooltipContent as eh,TooltipTrigger as th,useTranslation as oh}from"@produto-lecom/lecom-ui";import{MoveUpRightIcon as nh}from"lucide-react";import{useCallback as rh}from"react";import{jsx as Br,jsxs as ih}from"react/jsx-runtime";var ko=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=oh(),r=rh(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((m,f)=>{let y=m.getBoundingClientRect(),E=f.getBoundingClientRect(),p=Math.hypot(i.clientX-(y.left+y.width/2),i.clientY-(y.top+y.height/2));return Math.hypot(i.clientX-(E.left+E.width/2),i.clientY-(E.top+E.height/2))<p?f:m}),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 ih(jg,{children:[Br(th,{asChild:!0,children:Br(Qg,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:Br(nh,{size:16})})}),Br(eh,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};import{jsx as Tn}from"react/jsx-runtime";var Ro=i=>{var a=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=a,r=ht(a,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:s}=q(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d,isToEndEvent:u}=Zn(o,n),m=!l&&!c&&!d&&!u,f=[{component:Tn(Gr,{elementId:e,elementType:"edge"})}],y=()=>s==="view"?m?[{component:Tn(Ft,{elementId:e,elementType:"edge"})}]:[]:m?[{component:Tn(Ft,{elementId:e,elementType:"edge"})},...f]:f,p=(g=>{switch(g){case"SEQUENCE_EDGE":return y();case"MESSAGE_EDGE":return s==="view"?[]:[...f];case"ANNOTATION_EDGE":return s==="view"?[]:[...f];default:return[]}})(t);if(!(p.length===0||s==="readonly"))return Tn("div",w(_({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:p.map((g,h)=>Tn("div",{children:g.component},h))}))};import{useViewport as sh}from"@xyflow/react";import{useMemo as ah}from"react";import{jsx as Ac}from"react/jsx-runtime";var _t=12,Do=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:a}=sh(),s=1/a,l=ah(()=>t===n?{bottom:`${_t}px`,transform:"translateX(-50%)"}:e===o?{left:`${_t}px`,transform:r?"translateY(-100%)":"translateY(-50%)"}:n>t&&o>e?{left:`${_t}px`,bottom:`${_t}px`}:n>t&&o<e?{right:`${_t}px`,bottom:`${_t}px`}:t>n&&o>e?{right:`${_t}px`,bottom:`${_t}px`}:{left:`${_t}px`,bottom:`${_t}px`},[e,t,o,n,r]);return Ac("div",{style:{transform:`scale(${s})`},children:Ac("div",{className:"absolute pointer-events-auto",style:_({},l),children:i})})};import{Fragment as ph,jsx as mo,jsxs as Cc}from"react/jsx-runtime";var Oo={type:"ANNOTATION_EDGE",reconnectable:!0},Sc=({id:e,source:t,target:o,selected:n,data:r})=>{let{isMultipleSelection:i,isReadOnly:a,edgeHighlight:s}=q(),{zoom:l}=uh(),c=Ic(t),d=Ic(o);if(!c||!d)return null;let{sx:u,sy:m,tx:f,ty:y}=Co(c,d),[E,p,g]=dh({sourceX:u,sourceY:m,targetX:f,targetY:y}),h=s&&(n||(c==null?void 0:c.selected)||(d==null?void 0:d.selected));return mo(ph,{children:Cc("g",{className:H("group bpmn-edge",{"is-highlighted":h}),children:[mo("path",{d:E,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/l),style:{pointerEvents:"stroke",cursor:"pointer"}}),Cc("g",{className:H("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!a,"text-blue-500 group-hover:text-blue-600":h}),children:[mo(lh,{id:e,path:E,interactionWidth:0,strokeDasharray:4,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":r==null?void 0:r.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":h&&!(r!=null&&r.hasError)})}),mo(ch,{children:mo("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${p}px, ${g}px)`},children:n&&!i&&mo(Do,{sx:u,sy:m,tx:f,ty:y,children:mo(Ro,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})})})]})]})})};import{useState as Gc,useCallback as Bc,useMemo as us,useEffect as Sh,useRef as ps}from"react";import{BaseEdge as Mh,EdgeLabelRenderer as Ph,MarkerType as zc,useInternalNode as Yc,useReactFlow as Lh,useViewport as kh,useEdges as Rh,useNodes as Dh,Position as Bo}from"@xyflow/react";import{useCallback as fh,useEffect as cs,useRef as Mc,useState as mh}from"react";import{jsx as Lc}from"react/jsx-runtime";var ds=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,Pc=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Escape","Shift"],De=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:a,onBlur:s,onInput:l,onInvalidFirstCharacter:c,skipFirstCharValidation:d})=>{let u=Mc(null),m=Mc(null),[f,y]=mh(!1);cs(()=>()=>{m.current&&clearTimeout(m.current)},[]),cs(()=>{y(i!=null?i:!1)},[i]),cs(()=>{if(f&&u.current){u.current.focus();let b=document.createRange();b.selectNodeContents(u.current);let N=window.getSelection();N&&(N.removeAllRanges(),N.addRange(b))}},[f]);let E=fh(()=>{m.current||(c==null||c(),m.current=setTimeout(()=>{m.current=null},500))},[c]),p=b=>{b.stopPropagation(),f||y(!0)},g=b=>{let N=b.currentTarget.innerText.replace(/\n$/,""),T=t&&N.length>=t,A=window.getSelection(),C=(A==null?void 0:A.toString())||"",P=C.length>0,R=(b.ctrlKey||b.metaKey)&&!b.altKey,S=R&&b.key==="a",L=R&&b.key==="c",K=R&&b.key==="x",j=R&&b.key==="v",Q=N.length===0||P&&C.length===N.length;if(!d&&Q&&!ds.test(b.key)&&!Pc.includes(b.key)&&!R){b.preventDefault(),E();return}T&&!P&&(Pc.includes(b.key)||S||L||K||j||b.preventDefault())},h=b=>{b.preventDefault();let N=b.clipboardData.getData("text/plain").replace(/\r\n/g,`
1
+ var Vp=Object.defineProperty,Hp=Object.defineProperties;var Gp=Object.getOwnPropertyDescriptors;var Bn=Object.getOwnPropertySymbols;var Qs=Object.prototype.hasOwnProperty,js=Object.prototype.propertyIsEnumerable;var Js=(e,t,o)=>t in e?Vp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,_=(e,t)=>{for(var o in t||(t={}))Qs.call(t,o)&&Js(e,o,t[o]);if(Bn)for(var o of Bn(t))js.call(t,o)&&Js(e,o,t[o]);return e},w=(e,t)=>Hp(e,Gp(t));var yt=(e,t)=>{var o={};for(var n in e)Qs.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Bn)for(var n of Bn(e))t.indexOf(n)<0&&js.call(e,n)&&(o[n]=e[n]);return o};var Ri=e=>{if(typeof document=="undefined")return;let t=document.cookie.match(new RegExp(`(?:^|; )${e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")}=([^;]*)`));return t?decodeURIComponent(t[1]):void 0};import{initializeI18n as Bp,Translations as zp}from"@produto-lecom/lecom-ui";var ea={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Delete",configure_node:"Configure activity",configure_edge:"Configure routing",configure_gateway:"Configure routing",initial_task:"Initial Activity",gateway_limit_reached:"Exclusive gateway cannot have more than 2 outgoing connections",task_limit_reached:"Task cannot have more than 2 outgoing connections",start_event_limit_reached:"Start event can only connect to a single element",gateway_to_gateway_not_allowed:"Gateways cannot connect directly to other gateways",start_event_already_exists:"A start event already exists. Delete the current event to add another",script_to_end_not_allowed:"Script activities cannot connect directly to the end event",loop_to_end_not_allowed:"Loop activities cannot connect directly to the end event",initial_activity_to_end_not_allowed:"Initial activity cannot connect directly to the end event",final_activity_cannot_connect:"Final activity cannot connect to other elements",activity_has_outgoing_connections:"Activity with outgoing connections cannot connect to end event",end_event_cannot_connect_to_initial_activity:"End event cannot connect to an initial activity",initial_activity_cannot_connect_to_start_event:"Initial activity cannot connect to start event",concurrent_initial_and_final_activity:"An activity cannot be connected to both start and end events",start_event_to_service_task_not_allowed:"Start event cannot connect to an automatic activity",service_task_to_end_not_allowed:"Automatic activities cannot connect to the end event",duplicate_connection_not_allowed:"A connection already exists between these elements",connect_node:"Connect element",connecting:"Connecting...",delete_pool_lane_error:"Cannot delete the pool or lane while there are elements inside it."},controls:{zoom:{fit:"Fit zoom",in:"Zoom in",out:"Zoom out",reset:"Reset zoom"},actions:{move_tool:"Select elements",hand_tool:"Navigate the diagram",check:"Check diagram",check_loading:"Validating diagram...",export:{title:"Export diagram",print:"Print",html:"Export as HTML",png:"Export as PNG",feedback:{empty:"Cannot export an empty diagram",error:"Error exporting diagram"}},import_governance:"Import diagram from Governance platform",import_mermaid:"Import Mermaid",import:{title:"Import",xml:"XML",mermaid:"Mermaid",governance:"Governance",feedback:{error:"Could not import the file. Check its content."}},organize:{title:"Align diagram",vertical:"Vertical (top-down)",horizontal:"Horizontal (left-right)",feedback:{pool_lane:"Diagrams with pools or lanes cannot be arranged automatically."}},minimap:{label:"Minimap",open:"Open minimap",close:"Hide minimap"}},history:{undo:"Undo",redo:"Redo"}},modals:{mermaid_import:{title:"Import diagram from Mermaid",description:"Paste the Mermaid text (in the format supported by the modeler) to generate the diagram.",generate:"Generate",cancel:"Cancel",error_empty:"Paste the diagram text before generating.",error_parse:"Could not generate the diagram. Check the pasted text."},delete_elements:{title:"Delete elements",callout:"When deleting, the activity and routing settings will be deleted.",content:"Are you sure you want to delete?",confirm:"Delete",cancel:"Cancel"}},task_menu:{loop_not_allowed_when_connected_to_end:"Cannot create loop on activity connected to end event",script_not_allowed_when_connected_to_end:"Cannot transform to Script activity connected to end event",loop_not_allowed_when_subprocess:"Cannot create loop on subprocess",loop_not_allowed_when_service_task:"Cannot create loop on automatic activity",loop:"Activity with loop"}},validation:{success:{title:"Validation Successful",message:"The diagram was validated successfully with no errors."},errors:{title:"The diagram contains errors",subtitle:"Please review the following:",task_label_length:"Task name exceeds the maximum character limit",multiple_start_event_not_allowed:"Multiple start events are not allowed",task_flows_limit_exceeds:"The number of output connections exceeds the limit of two",duplicate_task_name:"There are multiple activities with the same name",flows_on_end_tasks_not_allowed:"Activities connected to end events cannot have other connections",conditions_flows_limit_exceeds:"Exclusive gateway has too many output connections (maximum of two)",task_label_empty:"One or more activities have no name",activity_name_invalid:"Activity name is invalid",final_activity_has_loop:"Final activities cannot have loops",nested_gateway:"Connecting gateways directly is not allowed",concurrent_initial_and_final_event:"The same activity cannot have both initial and final events",gateway_flow_to_event:"Connecting a gateway to an output event is not allowed",gateway_missing_output_streams:"The gateway does not have the correct number of outputs",events_nested:"Connecting events directly is not allowed",event_to_condition:"Connecting an event directly to a gateway is not allowed",script_in_final_activity:"Final activity cannot be a script type",subprocess_not_configured:"The subprocess reference is not properly configured",cannot_validate_subprocess_reference:"Could not validate whether the subprocess reference is configured",start_event_not_found:"At least one start event is required",end_event_not_found:"At least one end event is required",service_task_without_rejection_routing:"Automated activity (RPA) without rejection routing configured",service_task_without_automation:"Automated activity (RPA) without a configured robot",service_task_connector_inactive:"Automated activity (RPA) linked to an inactive connector",service_task_integration_suspended:"Automated activity (RPA) linked to a suspended integration",service_task_automation_status_unavailable:"Could not verify the automation (RPA) status",service_task_initial_or_final:"Automated activity (RPA) cannot be an initial, final or concentrator step",service_task_in_loop:"Automated activity (RPA) cannot be in a loop"}},bpmn:{start_event:{variant:{default:"Start event"}},end_event:{variant:{default:"End event"}},annotation:{variant:{default:"Annotation"}},gateway:{menu:{title:"Change gateway type"},variant:{default:"Gateway",exclusive:"Exclusive gateway",parallel:"Parallel gateway",complex:"Complex gateway"}},task:{menu:{title:"Change task type"},variant:{default:"Task",script:"Script task",subprocess:"Subprocess",service_task:"RPA"},attribute:{loop:"Task with loop"},label:{prefix:"Activity"},feedback:{label_empty:{prefix:"Activity name was automatically set to"},label_already_exists:{prefix:"The name",middle:"already exists. The name was changed to"},invalid_first_character:"Activity name must start with a letter or number"}},lane:{variant:{default:"Pool / Lane"}},unsupported:{variant:{default:"Unsupported element"}}},adapter:{governance:{error:{DEFAULT:"Error importing diagram",NO_FILE:"No file selected",EMPTY_FILE:"Empty file",INVALID_FILE:"Invalid file",CONTAIN_NO_CELLS:"No cells found to be imported",ALREADY_INITIALIZED:"It is not possible to import the diagram from the Governance platform, since the diagram has already been initialized"},success:{default:"The diagram was imported from the Governance platform successfully and without any incompatibility detected.",incompatible_cells:"The diagram was imported from the Governance platform with incompatibilities. To know more details, click on the button below."},report:{columns:{type:"Type",value:"Value",status:"Status"},status:{imported:"Imported",adapted:"Adapted",unsupported:"Unsupported"}},action:{download:"Download report"}}}}};var ta={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",configure_node:"Configurar actividad",configure_edge:"Configurar enrutamiento",configure_gateway:"Configurar enrutamiento",initial_task:"Actividad Inicial",gateway_limit_reached:"Compuerta exclusiva no puede tener m\xE1s de 2 conexiones de salida",task_limit_reached:"Actividad no puede tener m\xE1s de 2 conexiones de salida",start_event_limit_reached:"Evento inicial solo puede conectarse a un \xFAnico elemento",gateway_to_gateway_not_allowed:"Las compuertas no pueden conectarse directamente con otras compuertas",start_event_already_exists:"Ya existe un evento de inicio. Elimine el evento actual para agregar otro",script_to_end_not_allowed:"Las actividades Script no pueden conectarse directamente al evento final",loop_to_end_not_allowed:"Las actividades Loop no pueden conectarse directamente al evento final",initial_activity_to_end_not_allowed:"Actividad inicial no puede conectarse directamente al evento final",final_activity_cannot_connect:"Actividad final no puede conectarse a otros elementos",activity_has_outgoing_connections:"Actividad con conexiones de salida no puede conectarse al evento final",end_event_cannot_connect_to_initial_activity:"El evento final no puede conectarse a una actividad inicial",initial_activity_cannot_connect_to_start_event:"Actividad inicial no puede conectarse a evento de inicio",concurrent_initial_and_final_activity:"Una actividad no puede estar conectada al evento inicial y final al mismo tiempo",start_event_to_service_task_not_allowed:"El evento inicial no puede conectarse a una actividad autom\xE1tica",service_task_to_end_not_allowed:"Las actividades autom\xE1ticas no pueden conectarse al evento final",duplicate_connection_not_allowed:"Ya existe una conexi\xF3n entre estos elementos",connect_node:"Conectar elemento",connecting:"Conectando...",delete_pool_lane_error:"No se puede eliminar la piscina o carril mientras haya elementos dentro."},controls:{zoom:{fit:"Ajustar zoom",in:"Acercar",out:"Alejar",reset:"Restablecer zoom"},actions:{move_tool:"Seleccionar elementos",hand_tool:"Navegar por el diagrama",check:"Validar diagrama",check_loading:"Validando diagrama...",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"No es posible exportar un diagrama vac\xEDo",error:"Error al exportar diagrama"}},import_governance:"Importar diagrama de la plataforma Governance",import_mermaid:"Importar Mermaid",import:{title:"Importar",xml:"XML",mermaid:"Mermaid",governance:"Governance",feedback:{error:"No fue posible importar el archivo. Verifique el contenido."}},organize:{title:"Alinear diagrama",vertical:"Vertical (de arriba hacia abajo)",horizontal:"Horizontal (de izquierda a derecha)",feedback:{pool_lane:"No es posible ordenar autom\xE1ticamente diagramas con piscinas o carriles."}},minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Deshacer",redo:"Rehacer"}},modals:{mermaid_import:{title:"Importar diagrama a partir de Mermaid",description:"Pegue el texto Mermaid (en el formato compatible con el modelador) para generar el diagrama.",generate:"Generar",cancel:"Cancelar",error_empty:"Pegue el texto del diagrama antes de generar.",error_parse:"No fue posible generar el diagrama. Verifique el texto pegado."},delete_elements:{title:"Eliminar elementos",callout:"Al eliminar, las configuraciones de actividades y enrutamiento ser\xE1n eliminadas.",content:"\xBFEst\xE1s seguro de querer eliminar?",confirm:"Eliminar",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"No se puede crear bucle en actividad conectada al evento final",script_not_allowed_when_connected_to_end:"No se puede transformar a Script actividad conectada al evento final",loop_not_allowed_when_subprocess:"No se puede crear bucle en subproceso",loop_not_allowed_when_service_task:"No se puede crear bucle en actividad autom\xE1tica",loop:"Actividad con loop"}},validation:{success:{title:"Validaci\xF3n exitosa",message:"El diagrama ha sido validado correctamente sin errores."},errors:{title:"El diagrama contiene errores",subtitle:"Revise lo siguiente:",task_label_length:"El nombre de la actividad excede el l\xEDmite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"No se permite tener m\xE1s de un evento de inicio",task_flows_limit_exceeds:"El n\xFAmero de conexiones de salida supera el l\xEDmite de dos",duplicate_task_name:"Hay varias actividades con el mismo nombre",flows_on_end_tasks_not_allowed:"Las actividades conectadas a eventos finales no pueden tener otras conexiones",conditions_flows_limit_exceeds:"Compuerta exclusiva con exceso de conexiones de salida (m\xE1ximo de dos)",task_label_empty:"El nombre de una o m\xE1s actividades no ha sido completado",activity_name_invalid:"El nombre de la actividad no es v\xE1lido",final_activity_has_loop:"Las actividades finales no pueden tener bucles",nested_gateway:"No se permite conectar compuertas directamente",concurrent_initial_and_final_event:"Una misma actividad no puede tener eventos iniciales y finales",gateway_flow_to_event:"No se permite conectar una compuerta a un evento de salida",gateway_missing_output_streams:"La compuerta no tiene el n\xFAmero correcto de salidas",events_nested:"No se permite conectar eventos directamente",event_to_condition:"No se permite conectar un evento directamente a una compuerta",script_in_final_activity:"La actividad final no puede ser de tipo script",subprocess_not_configured:"La referencia al subproceso no est\xE1 configurada correctamente",cannot_validate_subprocess_reference:"No fue posible validar si la referencia al subproceso est\xE1 configurada",start_event_not_found:"Es necesario tener al menos un evento de inicio",end_event_not_found:"Es necesario tener al menos un evento final",service_task_without_rejection_routing:"Actividad autom\xE1tica (RPA) sin enrutamiento de rechazo configurado",service_task_without_automation:"Actividad autom\xE1tica (RPA) sin robot configurado",service_task_connector_inactive:"Actividad autom\xE1tica (RPA) vinculada a un conector inactivo",service_task_integration_suspended:"Actividad autom\xE1tica (RPA) vinculada a una integraci\xF3n suspendida",service_task_automation_status_unavailable:"No se pudo verificar el estado de la automatizaci\xF3n (RPA)",service_task_initial_or_final:"La actividad autom\xE1tica (RPA) no puede ser etapa inicial, final o concentradora",service_task_in_loop:"La actividad autom\xE1tica (RPA) no puede estar en un bucle"}},bpmn:{start_event:{variant:{default:"Evento de inicio"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anotaci\xF3n"}},gateway:{menu:{title:"Cambiar tipo de compuerta"},variant:{default:"Compuerta",exclusive:"Compuerta exclusiva",parallel:"Compuerta paralela",complex:"Compuerta compleja"}},task:{menu:{title:"Cambiar tipo de tarea"},variant:{default:"Tarea",script:"Tarea de script",subprocess:"Subproceso",service_task:"RPA"},attribute:{loop:"Tarea con bucle"},label:{prefix:"Actividad"},feedback:{label_empty:{prefix:"El nombre de la actividad se estableci\xF3 autom\xE1ticamente como"},label_already_exists:{prefix:"El nombre",middle:"ya existe. El nombre fue cambiado a"},invalid_first_character:"El nombre de la actividad debe comenzar con una letra o n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento no soportado"}}},adapter:{governance:{error:{DEFAULT:"Error al importar diagrama",NO_FILE:"No se ha seleccionado ning\xFAn archivo",EMPTY_FILE:"Archivo vac\xEDo",INVALID_FILE:"Archivo inv\xE1lido",CONTAIN_NO_CELLS:"No se encontraron c\xE9lulas para importar",ALREADY_INITIALIZED:"No es posible importar el diagrama de la plataforma Governance, ya que el diagrama ya ha sido iniciado"},success:{default:"El diagrama se ha importado de la plataforma Governance correctamente y sin ninguna incompatibilidad detectada.",incompatible_cells:"El diagrama se ha importado de la plataforma Governance con incompatibilidades. Para saber m\xE1s detalles, haz click en el bot\xF3n de abajo."},report:{columns:{type:"Tipo",value:"Valor",status:"Estado"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"No soportado"}},action:{download:"Descargar informe"}}}}};var oa={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Excluir",configure_node:"Configurar atividade",configure_edge:"Configurar roteamento",configure_gateway:"Configurar roteamento",initial_task:"Atividade Inicial",gateway_limit_reached:"Gateway exclusivo n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",task_limit_reached:"Atividade n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",start_event_limit_reached:"Evento inicial s\xF3 pode se conectar a um \xFAnico elemento",gateway_to_gateway_not_allowed:"Gateways n\xE3o podem se conectar diretamente com outros gateways",start_event_already_exists:"J\xE1 existe um evento de in\xEDcio. Exclua o evento atual para adicionar outro",script_to_end_not_allowed:"Atividades Script n\xE3o podem se conectar diretamente ao evento final",loop_to_end_not_allowed:"Atividades Loop n\xE3o podem se conectar diretamente ao evento final",initial_activity_to_end_not_allowed:"Atividade inicial n\xE3o pode se conectar diretamente ao evento final",final_activity_cannot_connect:"Atividade final n\xE3o pode se conectar a outros elementos",activity_has_outgoing_connections:"Atividade com conex\xF5es de sa\xEDda n\xE3o pode se conectar a um evento final",end_event_cannot_connect_to_initial_activity:"O evento final n\xE3o pode ser conectado a uma atividade inicial",initial_activity_cannot_connect_to_start_event:"Atividade inicial n\xE3o pode se conectar a evento de in\xEDcio",concurrent_initial_and_final_activity:"Uma atividade n\xE3o pode estar conectada ao evento inicial e final ao mesmo tempo",duplicate_connection_not_allowed:"J\xE1 existe uma conex\xE3o entre esses elementos",start_event_to_subprocess_not_allowed:"Evento inicial n\xE3o pode se conectar a um subprocesso",start_event_to_service_task_not_allowed:"Evento inicial n\xE3o pode se conectar a uma atividade autom\xE1tica",service_task_to_end_not_allowed:"Atividades autom\xE1ticas n\xE3o podem se conectar ao evento final",connect_node:"Conectar elemento",connecting:"Conectando...",delete_pool_lane_error:"N\xE3o \xE9 poss\xEDvel excluir a piscina ou raia enquanto houver elementos dentro dela."},controls:{zoom:{fit:"Ajustar o zoom",in:"Aumentar o zoom",out:"Diminuir o zoom",reset:"Resetar o zoom"},actions:{move_tool:"Selecionar elementos",hand_tool:"Navegar pelo diagrama",check:"Validar diagrama",check_loading:"Validando diagrama...",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"N\xE3o \xE9 poss\xEDvel exportar um diagrama vazio",error:"Erro ao exportar o diagrama"}},import_governance:"Importar diagrama da plataforma Governance",import_mermaid:"Importar Mermaid",import:{title:"Importar",xml:"XML",mermaid:"Mermaid",governance:"Governance",feedback:{error:"N\xE3o foi poss\xEDvel importar o arquivo. Verifique o conte\xFAdo."}},organize:{title:"Alinhar diagrama",vertical:"Vertical (de cima para baixo)",horizontal:"Horizontal (da esquerda para a direita)",feedback:{pool_lane:"N\xE3o \xE9 poss\xEDvel ordenar automaticamente diagramas com piscinas ou raias."}},minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Desfazer",redo:"Refazer"}},modals:{mermaid_import:{title:"Importar diagrama a partir de Mermaid",description:"Cole o texto Mermaid (no formato suportado pelo modelador) para gerar o diagrama.",generate:"Gerar",cancel:"Cancelar",error_empty:"Cole o texto do diagrama antes de gerar.",error_parse:"N\xE3o foi poss\xEDvel gerar o diagrama. Verifique o texto colado."},delete_elements:{title:"Excluir elementos",callout:"Ao excluir, as configura\xE7\xF5es de atividades e roteamento ser\xE3o exclu\xEDdas.",content:"Deseja realmente excluir?",confirm:"Excluir",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel criar loop em atividade conectada ao evento final",script_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel transformar em Script atividade conectada ao evento final",loop_not_allowed_when_subprocess:"N\xE3o \xE9 poss\xEDvel criar loop em subprocesso",loop_not_allowed_when_service_task:"N\xE3o \xE9 poss\xEDvel criar loop em atividade autom\xE1tica",loop:"Atividade com loop"}},validation:{success:{title:"Diagrama v\xE1lidado com sucesso!",message:"Nenhum erro encontrado."},errors:{title:"O diagrama cont\xE9m erros",subtitle:"Veja abaixo o que precisa ser corrigido:",task_label_length:"O nome da atividade excede o limite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"N\xE3o \xE9 permitido ter mais de um evento de in\xEDcio",task_flows_limit_exceeds:"O n\xFAmero de conex\xF5es de sa\xEDda ultrapassa o limite de dois",duplicate_task_name:"H\xE1 v\xE1rias atividades com o mesmo nome",flows_on_end_tasks_not_allowed:"Atividades conectadas a eventos finais n\xE3o podem ter outras conex\xF5es",conditions_flows_limit_exceeds:"Gateway exclusivo com excesso de conex\xF5es de sa\xEDda (m\xE1ximo de dois)",task_label_empty:"O nome de uma ou mais atividades n\xE3o foi preenchido",activity_name_invalid:"O nome da atividade n\xE3o \xE9 v\xE1lido",final_activity_has_loop:"Atividades finais n\xE3o podem ter loops",nested_gateway:"N\xE3o \xE9 permitido conectar gateways",concurrent_initial_and_final_event:"Uma mesma atividade n\xE3o pode ter eventos iniciais e finais",gateway_flow_to_event:"N\xE3o \xE9 permitido conectar um gateway a um evento de sa\xEDda",gateway_missing_output_streams:"O gateway n\xE3o possui o n\xFAmero correto de sa\xEDdas",events_nested:"N\xE3o \xE9 permitido conectar eventos",event_to_condition:"N\xE3o \xE9 permitido conectar um evento diretamente em um gateway",script_in_final_activity:"Atividade final n\xE3o pode ser do tipo script",subprocess_not_configured:"A refer\xEAncia ao subprocesso n\xE3o est\xE1 configurada corretamente",cannot_validate_subprocess_reference:"N\xE3o foi poss\xEDvel validar se a refer\xEAncia ao subprocesso est\xE1 configurada",start_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento inicial",end_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento final",service_task_without_rejection_routing:"Atividade autom\xE1tica (RPA) sem roteamento de rejei\xE7\xE3o configurado",service_task_without_automation:"Atividade autom\xE1tica (RPA) sem rob\xF4 configurado",service_task_connector_inactive:"Atividade autom\xE1tica (RPA) vinculada a um conector inativo",service_task_integration_suspended:"Atividade autom\xE1tica (RPA) vinculada a uma integra\xE7\xE3o suspensa",service_task_automation_status_unavailable:"N\xE3o foi poss\xEDvel verificar o status da automa\xE7\xE3o (RPA)",service_task_initial_or_final:"Atividade autom\xE1tica (RPA) n\xE3o pode ser etapa inicial, final ou concentradora",service_task_in_loop:"Atividade autom\xE1tica (RPA) n\xE3o pode estar em loop"}},bpmn:{start_event:{variant:{default:"Evento inicial"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anota\xE7\xE3o"}},gateway:{menu:{title:"Alterar tipo de gateway"},variant:{default:"Gateway",exclusive:"Gateway exclusivo",parallel:"Gateway paralelo",complex:"Gateway complexo"}},task:{menu:{title:"Alterar tipo de atividade"},variant:{default:"Atividade",script:"Atividade de script",subprocess:"Subprocesso",service_task:"RPA"},attribute:{loop:"Atividade com loop"},label:{prefix:"Atividade"},feedback:{label_empty:{prefix:"O nome da atividade foi definido automaticamente como"},label_already_exists:{prefix:"O nome",middle:"j\xE1 existe. O nome foi alterado para"},invalid_first_character:"O nome da atividade deve come\xE7ar com uma letra ou n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento n\xE3o suportado"}}},adapter:{governance:{error:{DEFAULT:"Erro ao importar diagrama",NO_FILE:"Nenhum arquivo selecionado",EMPTY_FILE:"Arquivo vazio",INVALID_FILE:"Arquivo inv\xE1lido",CONTAIN_NO_CELLS:"N\xE3o foram encontradas c\xE9lulas para serem importadas",ALREADY_INITIALIZED:"N\xE3o \xE9 poss\xEDvel importar o diagrama da plataforma Governance, pois o diagrama j\xE1 foi iniciado"},success:{default:"O diagrama foi importado da plataforma Governance com sucesso e sem nenhuma incompatibilidade detectada.",incompatible_cells:"O diagrama foi importado da plataforma Governance com incompatibilidades. Para saber mais detalhes, clique no bot\xE3o abaixo."},report:{columns:{type:"Tipo do elemento",value:"Valor",status:"Status"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"N\xE3o suportado"}},action:{download:"Baixar relat\xF3rio"}}}}};var na={pt_BR:oa,en_US:ea,es_ES:ta};var ra,ia,Yp=(ia=(ra=Ri("LecomUserLanguage"))!=null?ra:Ri("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?ia:zp.PT_BR;Bp({lng:Yp,resources:na});var Ae=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(Ae||{});var zn=(i=>(i.ACTIVITY="activity",i.ROUTING="routing",i.GATEWAY="gateway",i.SUB_PROCESS="sub_process",i.SERVICE_TASK="service_task",i))(zn||{}),Di=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Di||{}),Oi=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Oi||{}),Vi=(f=>(f.SIMPLE="simple",f.LOOP="loop",f.SCRIPT="script",f.SCRIPT_LOOP="script_loop",f.COMPLEX="complex",f.EXCLUSIVE="exclusive",f.PARALLEL="parallel",f.FINAL="final",f.TO_SUB_PROCESS="to_sub_process",f.FROM_SUB_PROCESS="from_sub_process",f.TO_SERVICE_TASK="to_service_task",f.FROM_SERVICE_TASK="from_service_task",f))(Vi||{});import{Bot as ef,RotateCcw as tf,ScrollText as of,SquarePlus as nf}from"lucide-react";import{jsx as Yn,jsxs as Fp}from"react/jsx-runtime";var Fn=({size:e=24,className:t})=>Fp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:[Yn("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),Yn("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),Yn("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),Yn("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as sa}from"react/jsx-runtime";var No=({size:e=24,className:t})=>sa("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:sa("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as Jo,jsxs as Wp}from"react/jsx-runtime";var wo=({size:e=24,className:t})=>Wp("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:[Jo("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"}),Jo("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Jo("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),Jo("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Jo("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Hi,jsxs as Xp}from"react/jsx-runtime";var Io=({size:e=24,className:t})=>Xp("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:[Hi("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"}),Hi("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Hi("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Gi,jsxs as Up}from"react/jsx-runtime";var Ao=({size:e=24,className:t})=>Up("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:[Gi("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"}),Gi("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Gi("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Bi,jsxs as $p}from"react/jsx-runtime";var aa=({size:e=24,className:t})=>Bi("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:$p("g",{children:[Bi("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"}),Bi("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as Kp}from"clsx";import{twMerge as qp}from"tailwind-merge";function H(...e){return qp(Kp(e))}var Vt=(e=0,t=0)=>e<t?t:e,Wn=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as la,jsxs as Zp}from"react/jsx-runtime";var ca=({size:e=24,className:t})=>Zp("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:H("stroke-2",t),children:[la("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"}),la("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as zi}from"react/jsx-runtime";var da=({size:e=24,className:t})=>zi("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:zi("g",{children:zi("path",{d:"M4.85372 6.17472L5.31292 5.71552L5.31993 5.70863C6.88908 4.1924 8.98352 3.34122 11.1655 3.33301L11.1668 3.33301C11.167 3.33301 11.1673 3.33301 11.1675 3.33301C12.7165 3.33314 14.2308 3.79255 15.5188 4.65317C16.807 5.5139 17.811 6.7373 18.4039 8.16866C18.9968 9.60001 19.1519 11.175 18.8497 12.6945C18.5986 13.9567 18.0414 15.1334 17.232 16.1236L16.9457 16.4738L17.2655 16.7936L20.6617 20.1899L20.6617 20.1899C20.7919 20.3201 20.7919 20.5311 20.6617 20.6612L20.6616 20.6613C20.5316 20.7915 20.3205 20.7915 20.1903 20.6613L16.7941 17.265L16.4743 16.9452L16.1241 17.2315C15.1339 18.0409 13.9571 18.5981 12.695 18.8492C11.1755 19.1514 9.6005 18.9963 8.16915 18.4034C6.73778 17.8105 5.51439 16.8065 4.65365 15.5183C3.79291 14.2301 3.3335 12.7156 3.3335 11.1663C3.3335 10.9822 3.48273 10.833 3.66683 10.833C3.85093 10.833 4.00016 10.9822 4.00016 11.1663C4.00016 12.5838 4.42048 13.9694 5.20796 15.148C5.99545 16.3265 7.11474 17.245 8.42426 17.7874C9.73378 18.3299 11.1748 18.4719 12.565 18.1953C13.9552 17.9188 15.2321 17.2362 16.2344 16.234L16.2345 16.234C17.2367 15.2316 17.9193 13.9547 18.1958 12.5645C18.4724 11.1743 18.3304 9.7333 17.7879 8.42378C17.2455 7.11426 16.327 5.99497 15.1484 5.20748L14.8707 5.62322L15.1484 5.20748C13.9703 4.42031 12.5854 4.00001 11.1685 3.99968L11.1664 3.99969C9.15876 4.00767 7.23176 4.7903 5.78712 6.18424L5.78706 6.18418L5.78075 6.1905L5.32512 6.64613L4.47156 7.49968H5.67867H7.8335C8.01759 7.49968 8.16683 7.64892 8.16683 7.83302C8.16683 8.01711 8.01759 8.16635 7.8335 8.16635H3.66683C3.48274 8.16635 3.3335 8.01711 3.3335 7.83302V3.66635C3.3335 3.48225 3.48274 3.33302 3.66683 3.33302C3.85092 3.33302 4.00016 3.48225 4.00016 3.66635V5.82117V7.02827L4.85372 6.17472Z"})})});import{jsx as ua}from"react/jsx-runtime";var Xn=({size:e=24,className:t})=>ua("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:ua("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as pa}from"react/jsx-runtime";var Qo=({size:e=24,className:t})=>pa("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",className:H("stroke-2",t),children:pa("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as Yi,jsxs as Jp}from"react/jsx-runtime";var fa=({size:e=24,className:t})=>Jp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[Yi("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"}),Yi("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"}),Yi("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as jo,jsxs as Qp}from"react/jsx-runtime";var ma=({size:e=24,className:t})=>Qp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[jo("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"}),jo("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"}),jo("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"}),jo("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),jo("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Un,jsxs as jp}from"react/jsx-runtime";var en=({size:e=24,className:t})=>jp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[Un("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"}),Un("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),Un("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Un("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var ae=(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))(ae||{}),Je=(n=>(n.SCRIPT="SCRIPT",n.SUBPROCESS="SUBPROCESS",n.SERVICE_TASK="SERVICE_TASK",n))(Je||{}),$n={SCRIPT:{icon:of},SUBPROCESS:{icon:nf},SERVICE_TASK:{icon:ef}},xt=(t=>(t.LOOP="LOOP",t))(xt||{}),Kn={LOOP:{icon:tf}},dt=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(dt||{}),Fi={EXCLUSIVE:{icon:Io},PARALLEL:{icon:Ao},COMPLEX:{icon:wo}};import{useTranslation as db}from"@produto-lecom/lecom-ui";import{ReactFlowProvider as ub}from"@xyflow/react";import{createContext as pb,useContext as fb,useEffect as mb,useId as gb,useMemo as Dp,useRef as hb,useState as ft}from"react";import{Background as G_,MiniMap as B_,ReactFlow as z_,SelectionMode as Y_,useKeyPress as F_}from"@xyflow/react";import{forwardRef as W_,useImperativeHandle as X_,useRef as Lp}from"react";import{useTranslation as Mx}from"@produto-lecom/lecom-ui";import{useEdgesState as Px,useNodesState as Lx,useOnSelectionChange as kx,useReactFlow as Rx,useStoreApi as Dx}from"@xyflow/react";import{useCallback as vt,useEffect as Ox}from"react";var qn={MIN_WIDTH:36,MIN_HEIGHT:36},Zn={MIN_WIDTH:36,MIN_HEIGHT:36},Co={MIN_WIDTH:56,MIN_HEIGHT:56},Ht={MIN_WIDTH:176,MIN_HEIGHT:96},ga={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},se={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},So={MIN_WIDTH:176,MIN_HEIGHT:64},rf={MIN_WIDTH:128,MIN_HEIGHT:64},ue={START_EVENT:qn,END_EVENT:Zn,GATEWAY:Co,TASK:Ht,LANE:se,ANNOTATION:So,UNSUPPORTED:rf};import{Position as tn}from"@xyflow/react";function ha(e,t){var x,T,b,N;let{width:o=0,height:n=0}=e.measured||{width:0,height:0},r=e.internals.positionAbsolute,i=t.internals.positionAbsolute,a=o/2,s=n/2,l=r.x+a,c=r.y+s,d=i.x+((T=(x=t==null?void 0:t.measured)==null?void 0:x.width)!=null?T:0)/2,p=i.y+((N=(b=t==null?void 0:t.measured)==null?void 0:b.height)!=null?N:0)/2,f=(d-l)/(2*a)-(p-c)/(2*s),m=(d-l)/(2*a)+(p-c)/(2*s),y=1/(Math.abs(f)+Math.abs(m)||1),E=y*f,u=y*m,g=a*(E+u)+l,h=s*(-E+u)+c;return{x:g,y:h}}function ya(e,t){var c,d,p,f;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(f=(p=e.measured)==null?void 0:p.height)!=null?f:0,i=Math.round(o.x),a=Math.round(o.y),s=Math.round(t.x),l=Math.round(t.y);return s<=i+1?tn.Left:s>=i+n-1?tn.Right:l<=a+1?tn.Top:l>=a+r-1?tn.Bottom:tn.Top}function Mo(e,t){let o=ha(e,t),n=ha(t,e),r=ya(e,o),i=ya(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function Jn(e,t){return{isFromStartEvent:(e==null?void 0:e.type)==="START_EVENT",isGatewayToGateway:(e==null?void 0:e.type)==="GATEWAY"&&(t==null?void 0:t.type)==="GATEWAY",isActiviyToAndGateway:(e==null?void 0:e.type)==="TASK"&&(t==null?void 0:t.type)==="GATEWAY",isToEndEvent:(t==null?void 0:t.type)==="END_EVENT"}}import{orderBy as sf}from"lodash";var xa=e=>new Map(e.map(t=>[t.id,t])),Ea=(e,t)=>e.map(o=>{var n;return(n=t.get(o.id))!=null?n:o}),rt=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}},on=e=>sf(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),_a=(e,t)=>{let{x:o,y:n}=rt(e),{x:r,y:i}=rt(t);return{x:o-r,y:n-i}};var ro=({parentId:e,nodes:t,includeTypes:o=[...Object.values(ae)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),af=(e,t)=>{let{x:o,y:n}=rt(e),{x:r,y:i}=rt(t),a=o-r,s=n-i;return Math.sqrt(a*a+s*s)},lf=(e,t)=>{let{x:o,y:n,w:r,h:i}=rt(e),{x:a,y:s,w:l,h:c}=rt(t),d=o+r/2,p=n+i/2;return d>=a&&d<=a+l&&p>=s&&p<=s+c},nn=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&lf(e,r)){let i=af(e,r);i<n&&(n=i,o=r)}return o},ba=(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 Ta=e=>{let t=e.filter(a=>!a.parentId);if(t.length===0)return null;let o=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of t){let{position:s,width:l,height:c}=a,d=s.x+(l||0),p=s.y+(c||0);s.x<o&&(o=s.x),s.y<n&&(n=s.y),d>r&&(r=d),p>i&&(i=p)}return{x:o,y:n,w:r-o,h:i-n}},va=({bounds:e,canvasWidth:t,canvasHeight:o,minZoom:n=.5,maxZoom:r=5,offsetX:i=0,offsetY:a=0})=>{let s=t-i*2,l=o-a*2,c=Math.min(s/e.w,l/e.h),d=Math.min(1,c),p=Math.min(Math.max(d,n),r);return{x:-e.x*p+i,y:-e.y*p+a,zoom:p}};var Wi=(e,t)=>{let o=t.find(a=>a.id===e);if(!o||o.type!=="LANE"||o.parentId)return!1;let n=rt(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=rt(a);return s.x<r&&s.x+s.w>n.x&&s.y<i&&s.y+s.h>n.y})};var cf=50,io=(e,t)=>{var f,m,y,E,u,g,h,x,T,b,N,v,I,C,P,R;let o=t.find(S=>S.id===e);if(!o)return t;let n=(m=(f=o.position)==null?void 0:f.x)!=null?m:0,r=(E=(y=o.position)==null?void 0:y.y)!=null?E:0,i=(g=(u=o.measured)==null?void 0:u.width)!=null?g:0,a=(x=(h=o.measured)==null?void 0:h.height)!=null?x:0,s=r+a,l=n+i,c=new Set,d=1/0;for(let S of t){if(S.id===e||S.parentId)continue;let L=(b=(T=S.position)==null?void 0:T.y)!=null?b:0,K=(v=(N=S.position)==null?void 0:N.x)!=null?v:0,j=(C=(I=S.measured)==null?void 0:I.width)!=null?C:0,Q=(R=(P=S.measured)==null?void 0:P.height)!=null?R:0;K<l&&K+j>n&&L<s&&L+Q>r&&(c.add(S.id),d=Math.min(d,L))}if(c.size===0)return t;let p=s+cf-d;return t.map(S=>{var K,j,Q;if(!c.has(S.id))return S;let L=(j=(K=S.position)==null?void 0:K.y)!=null?j:0;return w(_({},S),{position:w(_({},(Q=S.position)!=null?Q:{x:0,y:0}),{y:L+p})})})},Ne=15,so=e=>[...e].sort((t,o)=>t.position.y-o.position.y),df=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)},uf=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)},Xi=(e,t,o)=>{var d,p,f,m,y,E,u,g,h,x,T,b,N,v,I;if(t.length===0)return e;let n=(f=(p=e.width)!=null?p:(d=e.measured)==null?void 0:d.width)!=null?f:0,r=(E=(y=e.height)!=null?y:(m=e.measured)==null?void 0:m.height)!=null?E:0,i=0,a=0;for(let C of t){let P=df(C),R=uf(C);if(((g=(u=C.position)==null?void 0:u.y)!=null?g:0)<Ne&&(o.set(C.id,w(_({},C),{position:w(_({},C.position),{y:Ne})})),R=Ne+((x=(h=C.measured)==null?void 0:h.height)!=null?x:0)),((b=(T=C.position)==null?void 0:T.x)!=null?b:0)<se.HEADER_WIDTH+Ne){let S=(N=o.get(C.id))!=null?N:C;o.set(C.id,w(_({},S),{position:w(_({},S.position),{x:se.HEADER_WIDTH+Ne})})),P=se.HEADER_WIDTH+Ne+((I=(v=C.measured)==null?void 0:v.width)!=null?I:0)}i=Math.max(i,P),a=Math.max(a,R)}let s=Math.max(n,se.MIN_WIDTH),l=Math.max(r,se.MIN_HEIGHT);i+Ne>s&&(s=i+Ne),a+Ne>l&&(l=a+Ne);let c=w(_({},e),{width:s,height:l,measured:w(_({},e.measured),{width:s,height:l})});return o.set(e.id,c),c},Na=(e,t,o)=>{var a,s;let n=so(e),r=new Map;for(let l of o)l.parentId&&(r.has(l.parentId)||r.set(l.parentId,[]),r.get(l.parentId).push(l));let i=0;for(let l of n){let c=(a=r.get(l.id))!=null?a:[],d=Xi(l,c,t);t.set(d.id,w(_({},d),{position:{x:se.HEADER_WIDTH,y:i}})),i+=(s=d.height)!=null?s:0}},wa=(e,t)=>{var y,E,u,g;let o=[];for(let h of t.values())h.parentId===e.id&&o.push(h);let n=so(o),r=((E=(y=e.measured)==null?void 0:y.width)!=null?E:0)-se.HEADER_WIDTH,i=ba(e.id,o)||se.MIN_WIDTH,a=o.reduce((h,x)=>{var T;return h+((T=x.height)!=null?T:se.MIN_HEIGHT)},0),s=Math.max(r,i),l=a,c=r>i,d=c?s:s+se.HEADER_WIDTH,p=c?s-se.HEADER_WIDTH:s,f=0;for(let h=0;h<n.length;h++){let x=n[h],T=Math.max(se.MIN_HEIGHT,(u=x.height)!=null?u:se.MIN_HEIGHT),b=w(_({},x),{width:p,height:T,measured:w(_({},x.measured),{width:p,height:T}),position:{x:se.HEADER_WIDTH,y:f}});if(h===o.length-1){let N=Math.max(se.MIN_HEIGHT,l-f);b=w(_({},b),{height:N,measured:w(_({},x.measured),{width:p,height:N})})}t.set(x.id,b),f+=(g=b.height)!=null?g:0}let m=Math.max(l,f);t.set(e.id,w(_({},e),{width:d,height:m,measured:w(_({},e.measured),{width:d,height:m})}))},Ia=(e,t,o,n,r)=>{var y,E;let i=!e.parentId,a=i?e.id:e.parentId,s=n.filter(u=>u.type==="LANE"&&u.parentId===a);if(!s.length)return n;let l=so(s),c=l.findIndex(u=>u.id===e.id),d=(E=(y=e.position)==null?void 0:y.y)!=null?E:0,p=!i&&r!==void 0&&c>0&&Math.abs(r-d)>.5,f=0,m=[...n];return l.forEach((u,g)=>{var N,v;let h=g===l.length-1,x=u.id===e.id,b=(v=(N=u.measured)==null?void 0:N.height)!=null?v:0;x?b=o:p&&g===c-1&&(b=Math.max(se.MIN_HEIGHT,r-f)),h&&i&&(b=Math.max(se.MIN_HEIGHT,o-f)),m=m.map(I=>{if(I.id===u.id){let C=i?t-se.HEADER_WIDTH:t;return w(_({},I),{width:C,height:b,measured:w(_({},I.measured),{width:C,height:b}),position:{x:se.HEADER_WIDTH,y:f}})}return I}),x&&p?f=r+o:f+=b}),m=m.map(u=>{if(u.id===a){let g=i?t:t+se.HEADER_WIDTH;return w(_({},u),{width:g,height:i?o:f,measured:{width:g,height:i?o:f}})}return u}),m};var Ui=(e,t,o)=>{var s,l,c,d,p,f,m,y;if(e.type==="LANE")return o;let n=(l=(s=t.measured)==null?void 0:s.width)!=null?l:0,r=(d=(c=t.measured)==null?void 0:c.height)!=null?d:0;e.position.y<Ne&&(e.position.y=Ne),e.position.x<se.HEADER_WIDTH+Ne&&(e.position.x=se.HEADER_WIDTH+Ne);let i=e.position.x+((f=(p=e.measured)==null?void 0:p.width)!=null?f:0),a=e.position.y+((y=(m=e.measured)==null?void 0:m.height)!=null?y:0);return i+Ne>n&&(t.width=i+Ne,t.measured.width=i+Ne),a+Ne>r&&(t.height=a+Ne,t.measured.height=a+Ne),o=o.map(E=>E.id===t.id?w(_({},E),{height:t.height,width:t.width,measured:t.measured}):E.id===e.id?w(_({},E),{position:e.position}):E),o};import{useCallback as ff}from"react";import{create as mf}from"zustand";import{useStoreApi as pf}from"@xyflow/react";var Et=()=>{let e=pf();return{selectElements:n=>{let{edges:r,nodes:i,triggerEdgeChanges:a,triggerNodeChanges:s}=e.getState(),l=i.reduce((d,p)=>[...d,{id:p.id,type:"select",selected:n.includes(p.id)}],[]),c=r.reduce((d,p)=>[...d,{id:p.id,type:"select",selected:n.includes(p.id)}],[]);return s(l),a(c),!0},clearSelection:async()=>{let{unselectNodesAndEdges:n}=e.getState();return n(),await Wn(),!0}}};var Aa=()=>{let{selectElements:e}=Et();return ff(()=>{let o=ao.getState().pathEdgeIds;e(o)},[e])},ao=mf((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=_({},n.statusByNodeId),i=_({},n.statusData),a=!1;return o.forEach(s=>{let l=`${s.diagramId}-${s.activityId}`;r[s.diagramId]!==s.status&&(r[s.diagramId]=s.status,i[l]=s,a=!0)}),a?{statusByNodeId:r,statusData:i}:n})},getTaskStatus:o=>t().statusByNodeId[o]||null,clearTaskStatuses:()=>e({statusByNodeId:{},statusData:{},pathEdgeIds:[]}),setPathEdges:o=>{e({pathEdgeIds:o})},getPathEdgeIds:()=>t().pathEdgeIds,clearPathEdges:()=>{e({pathEdgeIds:[]})},calculateFlowPath:(o,n)=>{if(!o.length||!n.length)return;t().clearPathEdges();let r=n.filter(d=>t().statusByNodeId[d]);if(r.length<=1)return;let i=[],a={};o.forEach(d=>{a[d.source]||(a[d.source]=[]),a[d.source].push({targetId:d.target,edgeId:d.id})});let s=r[0],l=r[r.length-1];o.forEach(d=>{d.target===s&&i.push(d.id)}),o.forEach(d=>{d.source===l&&i.push(d.id)});let c=(d,p)=>{let f=[],m=new Set;for(f.push({node:d,path:[]}),m.add(d);f.length>0;){let{node:y,path:E}=f.shift();if(y===p)return E;let u=a[y]||[];for(let{targetId:g,edgeId:h}of u)m.has(g)||(m.add(g),f.push({node:g,path:[...E,h]}))}return[]};for(let d=0;d<r.length-1;d++){let p=r[d],f=r[d+1],m=c(p,f);m.length>0&&i.push(...m)}i.length>0&&e({pathEdgeIds:i})}}));import{useNodesInitialized as Sg,useReactFlow as Mg,useStore as Pg}from"@xyflow/react";import{useCallback as En,useEffect as Lg,useRef as kg,useState as bc}from"react";import{shallow as Rg}from"zustand/shallow";var gf={value:()=>{}};function Sa(){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 Qn(o)}function Qn(e){this._=e}function hf(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}})}Qn.prototype=Sa.prototype={constructor:Qn,on:function(e,t){var o=this._,n=hf(e+"",o),r,i=-1,a=n.length;if(arguments.length<2){for(;++i<a;)if((r=(e=n[i]).type)&&(r=yf(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]=Ca(o[r],e.name,t);else if(t==null)for(r in o)o[r]=Ca(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 Qn(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 yf(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function Ca(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=gf,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var $i=Sa;var jn="http://www.w3.org/1999/xhtml",Ki={svg:"http://www.w3.org/2000/svg",xhtml:jn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Ct(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),Ki.hasOwnProperty(t)?{space:Ki[t],local:e}:e}function xf(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===jn&&t.documentElement.namespaceURI===jn?t.createElement(e):t.createElementNS(o,e)}}function Ef(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function er(e){var t=Ct(e);return(t.local?Ef:xf)(t)}function _f(){}function lo(e){return e==null?_f:function(){return this.querySelector(e)}}function Ma(e){typeof e!="function"&&(e=lo(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=new Array(a),l,c,d=0;d<a;++d)(l=i[d])&&(c=e.call(l,l.__data__,d,i))&&("__data__"in l&&(c.__data__=l.__data__),s[d]=c);return new Ce(n,this._parents)}function qi(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function bf(){return[]}function rn(e){return e==null?bf:function(){return this.querySelectorAll(e)}}function Tf(e){return function(){return qi(e.apply(this,arguments))}}function Pa(e){typeof e=="function"?e=Tf(e):e=rn(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 Ce(n,r)}function sn(e){return function(){return this.matches(e)}}function tr(e){return function(t){return t.matches(e)}}var vf=Array.prototype.find;function Nf(e){return function(){return vf.call(this.children,e)}}function wf(){return this.firstElementChild}function La(e){return this.select(e==null?wf:Nf(typeof e=="function"?e:tr(e)))}var If=Array.prototype.filter;function Af(){return Array.from(this.children)}function Cf(e){return function(){return If.call(this.children,e)}}function ka(e){return this.selectAll(e==null?Af:Cf(typeof e=="function"?e:tr(e)))}function Ra(e){typeof e!="function"&&(e=sn(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 Ce(n,this._parents)}function or(e){return new Array(e.length)}function Da(){return new Ce(this._enter||this._groups.map(or),this._parents)}function an(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}an.prototype={constructor:an,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 Oa(e){return function(){return e}}function Sf(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 an(e,i[a]);for(;a<l;++a)(s=t[a])&&(r[a]=s)}function Mf(e,t,o,n,r,i,a){var s,l,c=new Map,d=t.length,p=i.length,f=new Array(d),m;for(s=0;s<d;++s)(l=t[s])&&(f[s]=m=a.call(l,l.__data__,s,t)+"",c.has(m)?r[s]=l:c.set(m,l));for(s=0;s<p;++s)m=a.call(e,i[s],s,i)+"",(l=c.get(m))?(n[s]=l,l.__data__=i[s],c.delete(m)):o[s]=new an(e,i[s]);for(s=0;s<d;++s)(l=t[s])&&c.get(f[s])===l&&(r[s]=l)}function Pf(e){return e.__data__}function Va(e,t){if(!arguments.length)return Array.from(this,Pf);var o=t?Mf:Sf,n=this._parents,r=this._groups;typeof e!="function"&&(e=Oa(e));for(var i=r.length,a=new Array(i),s=new Array(i),l=new Array(i),c=0;c<i;++c){var d=n[c],p=r[c],f=p.length,m=Lf(e.call(d,d&&d.__data__,c,n)),y=m.length,E=s[c]=new Array(y),u=a[c]=new Array(y),g=l[c]=new Array(f);o(d,p,E,u,g,m,t);for(var h=0,x=0,T,b;h<y;++h)if(T=E[h]){for(h>=x&&(x=h+1);!(b=u[x])&&++x<y;);T._next=b||null}}return a=new Ce(a,n),a._enter=s,a._exit=l,a}function Lf(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Ha(){return new Ce(this._exit||this._groups.map(or),this._parents)}function Ga(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 Ba(e){for(var t=e.selection?e.selection():e,o=this._groups,n=t._groups,r=o.length,i=n.length,a=Math.min(r,i),s=new Array(r),l=0;l<a;++l)for(var c=o[l],d=n[l],p=c.length,f=s[l]=new Array(p),m,y=0;y<p;++y)(m=c[y]||d[y])&&(f[y]=m);for(;l<r;++l)s[l]=o[l];return new Ce(s,this._parents)}function za(){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 Ya(e){e||(e=kf);function t(p,f){return p&&f?e(p.__data__,f.__data__):!p-!f}for(var o=this._groups,n=o.length,r=new Array(n),i=0;i<n;++i){for(var a=o[i],s=a.length,l=r[i]=new Array(s),c,d=0;d<s;++d)(c=a[d])&&(l[d]=c);l.sort(t)}return new Ce(r,this._parents).order()}function kf(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Fa(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Wa(){return Array.from(this)}function Xa(){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 Ua(){let e=0;for(let t of this)++e;return e}function $a(){return!this.node()}function Ka(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 Rf(e){return function(){this.removeAttribute(e)}}function Df(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Of(e,t){return function(){this.setAttribute(e,t)}}function Vf(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Hf(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function Gf(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 qa(e,t){var o=Ct(e);if(arguments.length<2){var n=this.node();return o.local?n.getAttributeNS(o.space,o.local):n.getAttribute(o)}return this.each((t==null?o.local?Df:Rf:typeof t=="function"?o.local?Gf:Hf:o.local?Vf:Of)(o,t))}function nr(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Bf(e){return function(){this.style.removeProperty(e)}}function zf(e,t,o){return function(){this.style.setProperty(e,t,o)}}function Yf(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function Za(e,t,o){return arguments.length>1?this.each((t==null?Bf:typeof t=="function"?Yf:zf)(e,t,o==null?"":o)):Gt(this.node(),e)}function Gt(e,t){return e.style.getPropertyValue(t)||nr(e).getComputedStyle(e,null).getPropertyValue(t)}function Ff(e){return function(){delete this[e]}}function Wf(e,t){return function(){this[e]=t}}function Xf(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function Ja(e,t){return arguments.length>1?this.each((t==null?Ff:typeof t=="function"?Xf:Wf)(e,t)):this.node()[e]}function Qa(e){return e.trim().split(/^|\s+/)}function Zi(e){return e.classList||new ja(e)}function ja(e){this._node=e,this._names=Qa(e.getAttribute("class")||"")}ja.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 el(e,t){for(var o=Zi(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function tl(e,t){for(var o=Zi(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function Uf(e){return function(){el(this,e)}}function $f(e){return function(){tl(this,e)}}function Kf(e,t){return function(){(t.apply(this,arguments)?el:tl)(this,e)}}function ol(e,t){var o=Qa(e+"");if(arguments.length<2){for(var n=Zi(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?Kf:t?Uf:$f)(o,t))}function qf(){this.textContent=""}function Zf(e){return function(){this.textContent=e}}function Jf(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function nl(e){return arguments.length?this.each(e==null?qf:(typeof e=="function"?Jf:Zf)(e)):this.node().textContent}function Qf(){this.innerHTML=""}function jf(e){return function(){this.innerHTML=e}}function em(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function rl(e){return arguments.length?this.each(e==null?Qf:(typeof e=="function"?em:jf)(e)):this.node().innerHTML}function tm(){this.nextSibling&&this.parentNode.appendChild(this)}function il(){return this.each(tm)}function om(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function sl(){return this.each(om)}function al(e){var t=typeof e=="function"?e:er(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function nm(){return null}function ll(e,t){var o=typeof e=="function"?e:er(e),n=t==null?nm:typeof t=="function"?t:lo(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function rm(){var e=this.parentNode;e&&e.removeChild(this)}function cl(){return this.each(rm)}function im(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function sm(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function dl(e){return this.select(e?sm:im)}function ul(e){return arguments.length?this.property("__data__",e):this.node().__data__}function am(e){return function(t){e.call(this,t,this.__data__)}}function lm(e){return e.trim().split(/^|\s+/).map(function(t){var o="",n=t.indexOf(".");return n>=0&&(o=t.slice(n+1),t=t.slice(0,n)),{type:t,name:o}})}function cm(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 dm(e,t,o){return function(){var n=this.__on,r,i=am(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 pl(e,t,o){var n=lm(e+""),r,i=n.length,a;if(arguments.length<2){var s=this.node().__on;if(s){for(var l=0,c=s.length,d;l<c;++l)for(r=0,d=s[l];r<i;++r)if((a=n[r]).type===d.type&&a.name===d.name)return d.value}return}for(s=t?dm:cm,r=0;r<i;++r)this.each(s(n[r],t,o));return this}function fl(e,t,o){var n=nr(e),r=n.CustomEvent;typeof r=="function"?r=new r(t,o):(r=n.document.createEvent("Event"),o?(r.initEvent(t,o.bubbles,o.cancelable),r.detail=o.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function um(e,t){return function(){return fl(this,e,t)}}function pm(e,t){return function(){return fl(this,e,t.apply(this,arguments))}}function ml(e,t){return this.each((typeof t=="function"?pm:um)(e,t))}function*gl(){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 fm=[null];function Ce(e,t){this._groups=e,this._parents=t}function hl(){return new Ce([[document.documentElement]],fm)}function mm(){return this}Ce.prototype=hl.prototype={constructor:Ce,select:Ma,selectAll:Pa,selectChild:La,selectChildren:ka,filter:Ra,data:Va,enter:Da,exit:Ha,join:Ga,merge:Ba,selection:mm,order:za,sort:Ya,call:Fa,nodes:Wa,node:Xa,size:Ua,empty:$a,each:Ka,attr:qa,style:Za,property:Ja,classed:ol,text:nl,html:rl,raise:il,lower:sl,append:al,insert:ll,remove:cl,clone:dl,datum:ul,on:pl,dispatch:ml,[Symbol.iterator]:gl};var St=hl;function rr(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function Ji(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function dn(){}var ln=.7,ar=1/ln,Po="\\s*([+-]?\\d+)\\s*",cn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",_t="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",gm=/^#([0-9a-f]{3,8})$/,hm=new RegExp(`^rgb\\(${Po},${Po},${Po}\\)$`),ym=new RegExp(`^rgb\\(${_t},${_t},${_t}\\)$`),xm=new RegExp(`^rgba\\(${Po},${Po},${Po},${cn}\\)$`),Em=new RegExp(`^rgba\\(${_t},${_t},${_t},${cn}\\)$`),_m=new RegExp(`^hsl\\(${cn},${_t},${_t}\\)$`),bm=new RegExp(`^hsla\\(${cn},${_t},${_t},${cn}\\)$`),yl={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};rr(dn,Bt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:xl,formatHex:xl,formatHex8:Tm,formatHsl:vm,formatRgb:El,toString:El});function xl(){return this.rgb().formatHex()}function Tm(){return this.rgb().formatHex8()}function vm(){return wl(this).formatHsl()}function El(){return this.rgb().formatRgb()}function Bt(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=gm.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?_l(t):o===3?new Fe(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?ir(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?ir(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=hm.exec(e))?new Fe(t[1],t[2],t[3],1):(t=ym.exec(e))?new Fe(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=xm.exec(e))?ir(t[1],t[2],t[3],t[4]):(t=Em.exec(e))?ir(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=_m.exec(e))?vl(t[1],t[2]/100,t[3]/100,1):(t=bm.exec(e))?vl(t[1],t[2]/100,t[3]/100,t[4]):yl.hasOwnProperty(e)?_l(yl[e]):e==="transparent"?new Fe(NaN,NaN,NaN,0):null}function _l(e){return new Fe(e>>16&255,e>>8&255,e&255,1)}function ir(e,t,o,n){return n<=0&&(e=t=o=NaN),new Fe(e,t,o,n)}function Nm(e){return e instanceof dn||(e=Bt(e)),e?(e=e.rgb(),new Fe(e.r,e.g,e.b,e.opacity)):new Fe}function Lo(e,t,o,n){return arguments.length===1?Nm(e):new Fe(e,t,o,n==null?1:n)}function Fe(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}rr(Fe,Lo,Ji(dn,{brighter(e){return e=e==null?ar:Math.pow(ar,e),new Fe(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?ln:Math.pow(ln,e),new Fe(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Fe(uo(this.r),uo(this.g),uo(this.b),lr(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:bl,formatHex:bl,formatHex8:wm,formatRgb:Tl,toString:Tl}));function bl(){return`#${co(this.r)}${co(this.g)}${co(this.b)}`}function wm(){return`#${co(this.r)}${co(this.g)}${co(this.b)}${co((isNaN(this.opacity)?1:this.opacity)*255)}`}function Tl(){let e=lr(this.opacity);return`${e===1?"rgb(":"rgba("}${uo(this.r)}, ${uo(this.g)}, ${uo(this.b)}${e===1?")":`, ${e})`}`}function lr(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function uo(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function co(e){return e=uo(e),(e<16?"0":"")+e.toString(16)}function vl(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new ut(e,t,o,n)}function wl(e){if(e instanceof ut)return new ut(e.h,e.s,e.l,e.opacity);if(e instanceof dn||(e=Bt(e)),!e)return new ut;if(e instanceof ut)return e;e=e.rgb();var t=e.r/255,o=e.g/255,n=e.b/255,r=Math.min(t,o,n),i=Math.max(t,o,n),a=NaN,s=i-r,l=(i+r)/2;return s?(t===i?a=(o-n)/s+(o<n)*6:o===i?a=(n-t)/s+2:a=(t-o)/s+4,s/=l<.5?i+r:2-i-r,a*=60):s=l>0&&l<1?0:a,new ut(a,s,l,e.opacity)}function Il(e,t,o,n){return arguments.length===1?wl(e):new ut(e,t,o,n==null?1:n)}function ut(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}rr(ut,Il,Ji(dn,{brighter(e){return e=e==null?ar:Math.pow(ar,e),new ut(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?ln:Math.pow(ln,e),new ut(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,o=this.l,n=o+(o<.5?o:1-o)*t,r=2*o-n;return new Fe(Qi(e>=240?e-240:e+120,r,n),Qi(e,r,n),Qi(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new ut(Nl(this.h),sr(this.s),sr(this.l),lr(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=lr(this.opacity);return`${e===1?"hsl(":"hsla("}${Nl(this.h)}, ${sr(this.s)*100}%, ${sr(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Nl(e){return e=(e||0)%360,e<0?e+360:e}function sr(e){return Math.max(0,Math.min(1,e||0))}function Qi(e,t,o){return(e<60?t+(o-t)*e/60:e<180?o:e<240?t+(o-t)*(240-e)/60:t)*255}function ji(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 Al(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 ji((o-n/t)*t,a,r,i,s)}}function Cl(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 ji((o-n/t)*t,r,i,a,s)}}var es=e=>()=>e;function Im(e,t){return function(o){return e+o*t}}function Am(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 Sl(e){return(e=+e)==1?cr:function(t,o){return o-t?Am(t,o,e):es(isNaN(t)?o:t)}}function cr(e,t){var o=t-e;return o?Im(e,o):es(isNaN(e)?t:e)}var dr=function e(t){var o=Sl(t);function n(r,i){var a=o((r=Lo(r)).r,(i=Lo(i)).r),s=o(r.g,i.g),l=o(r.b,i.b),c=cr(r.opacity,i.opacity);return function(d){return r.r=a(d),r.g=s(d),r.b=l(d),r.opacity=c(d),r+""}}return n.gamma=e,n}(1);function Ml(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=Lo(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 Cm=Ml(Al),Sm=Ml(Cl);function it(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var os=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ts=new RegExp(os.source,"g");function Mm(e){return function(){return e}}function Pm(e){return function(t){return e(t)+""}}function ns(e,t){var o=os.lastIndex=ts.lastIndex=0,n,r,i,a=-1,s=[],l=[];for(e=e+"",t=t+"";(n=os.exec(e))&&(r=ts.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:it(n,r)})),o=ts.lastIndex;return o<t.length&&(i=t.slice(o),s[a]?s[a]+=i:s[++a]=i),s.length<2?l[0]?Pm(l[0].x):Mm(t):(t=l.length,function(c){for(var d=0,p;d<t;++d)s[(p=l[d]).i]=p.x(c);return s.join("")})}var Pl=180/Math.PI,ur={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function rs(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)*Pl,skewX:Math.atan(l)*Pl,scaleX:a,scaleY:s}}var pr;function Ll(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?ur:rs(t.a,t.b,t.c,t.d,t.e,t.f)}function kl(e){return e==null?ur:(pr||(pr=document.createElementNS("http://www.w3.org/2000/svg","g")),pr.setAttribute("transform",e),(e=pr.transform.baseVal.consolidate())?(e=e.matrix,rs(e.a,e.b,e.c,e.d,e.e,e.f)):ur)}function Rl(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,p,f,m,y){if(c!==p||d!==f){var E=m.push("translate(",null,t,null,o);y.push({i:E-4,x:it(c,p)},{i:E-2,x:it(d,f)})}else(p||f)&&m.push("translate("+p+t+f+o)}function a(c,d,p,f){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),f.push({i:p.push(r(p)+"rotate(",null,n)-2,x:it(c,d)})):d&&p.push(r(p)+"rotate("+d+n)}function s(c,d,p,f){c!==d?f.push({i:p.push(r(p)+"skewX(",null,n)-2,x:it(c,d)}):d&&p.push(r(p)+"skewX("+d+n)}function l(c,d,p,f,m,y){if(c!==p||d!==f){var E=m.push(r(m)+"scale(",null,",",null,")");y.push({i:E-4,x:it(c,p)},{i:E-2,x:it(d,f)})}else(p!==1||f!==1)&&m.push(r(m)+"scale("+p+","+f+")")}return function(c,d){var p=[],f=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,p,f),a(c.rotate,d.rotate,p,f),s(c.skewX,d.skewX,p,f),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,p,f),c=d=null,function(m){for(var y=-1,E=f.length,u;++y<E;)p[(u=f[y]).i]=u.x(m);return p.join("")}}}var is=Rl(Ll,"px, ","px)","deg)"),ss=Rl(kl,", ",")",")");var ko=0,pn=0,un=0,Ol=1e3,fr,fn,mr=0,po=0,gr=0,mn=typeof performance=="object"&&performance.now?performance:Date,Vl=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function hn(){return po||(Vl(Lm),po=mn.now()+gr)}function Lm(){po=0}function gn(){this._call=this._time=this._next=null}gn.prototype=hr.prototype={constructor:gn,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?hn():+o)+(t==null?0:+t),!this._next&&fn!==this&&(fn?fn._next=this:fr=this,fn=this),this._call=e,this._time=o,as()},stop:function(){this._call&&(this._call=null,this._time=1/0,as())}};function hr(e,t,o){var n=new gn;return n.restart(e,t,o),n}function Hl(){hn(),++ko;for(var e=fr,t;e;)(t=po-e._time)>=0&&e._call.call(void 0,t),e=e._next;--ko}function Dl(){po=(mr=mn.now())+gr,ko=pn=0;try{Hl()}finally{ko=0,Rm(),po=0}}function km(){var e=mn.now(),t=e-mr;t>Ol&&(gr-=t,mr=e)}function Rm(){for(var e,t=fr,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:fr=o);fn=e,as(n)}function as(e){if(!ko){pn&&(pn=clearTimeout(pn));var t=e-po;t>24?(e<1/0&&(pn=setTimeout(Dl,e-mn.now()-gr)),un&&(un=clearInterval(un))):(un||(mr=mn.now(),un=setInterval(km,Ol)),ko=1,Vl(Dl))}}function yr(e,t,o){var n=new gn;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var Dm=$i("start","end","cancel","interrupt"),Om=[],zl=0,Gl=1,Er=2,xr=3,Bl=4,_r=5,yn=6;function zt(e,t,o,n,r,i){var a=e.__transition;if(!a)e.__transition={};else if(o in a)return;Vm(e,o,{name:t,index:n,group:r,on:Dm,tween:Om,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:zl})}function xn(e,t){var o=Se(e,t);if(o.state>zl)throw new Error("too late; already scheduled");return o}function De(e,t){var o=Se(e,t);if(o.state>xr)throw new Error("too late; already running");return o}function Se(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function Vm(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=hr(i,0,o.time);function i(c){o.state=Gl,o.timer.restart(a,o.delay,o.time),o.delay<=c&&a(c-o.delay)}function a(c){var d,p,f,m;if(o.state!==Gl)return l();for(d in n)if(m=n[d],m.name===o.name){if(m.state===xr)return yr(a);m.state===Bl?(m.state=yn,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete n[d]):+d<t&&(m.state=yn,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete n[d])}if(yr(function(){o.state===xr&&(o.state=Bl,o.timer.restart(s,o.delay,o.time),s(c))}),o.state=Er,o.on.call("start",e,e.__data__,o.index,o.group),o.state===Er){for(o.state=xr,r=new Array(f=o.tween.length),d=0,p=-1;d<f;++d)(m=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++p]=m);r.length=p+1}}function s(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=_r,1),p=-1,f=r.length;++p<f;)r[p].call(e,d);o.state===_r&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=yn,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function ls(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>Er&&n.state<_r,n.state=yn,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[a]}i&&delete e.__transition}}function Yl(e){return this.each(function(){ls(this,e)})}function Hm(e,t){var o,n;return function(){var r=De(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 Gm(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=De(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 Fl(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=Se(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?Hm:Gm)(o,e,t))}function Ro(e,t,o){var n=e._id;return e.each(function(){var r=De(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return Se(r,n).value[t]}}function br(e,t){var o;return(typeof t=="number"?it:t instanceof Bt?dr:(o=Bt(t))?(t=o,dr):ns)(e,t)}function Bm(e){return function(){this.removeAttribute(e)}}function zm(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Ym(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 Fm(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 Wm(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 Xm(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 Wl(e,t){var o=Ct(e),n=o==="transform"?ss:br;return this.attrTween(e,typeof t=="function"?(o.local?Xm:Wm)(o,n,Ro(this,"attr."+e,t)):t==null?(o.local?zm:Bm)(o):(o.local?Fm:Ym)(o,n,t))}function Um(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function $m(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function Km(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&$m(e,i)),o}return r._value=t,r}function qm(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Um(e,i)),o}return r._value=t,r}function Xl(e,t){var o="attr."+e;if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;var n=Ct(e);return this.tween(o,(n.local?Km:qm)(n,t))}function Zm(e,t){return function(){xn(this,e).delay=+t.apply(this,arguments)}}function Jm(e,t){return t=+t,function(){xn(this,e).delay=t}}function Ul(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Zm:Jm)(t,e)):Se(this.node(),t).delay}function Qm(e,t){return function(){De(this,e).duration=+t.apply(this,arguments)}}function jm(e,t){return t=+t,function(){De(this,e).duration=t}}function $l(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Qm:jm)(t,e)):Se(this.node(),t).duration}function eg(e,t){if(typeof t!="function")throw new Error;return function(){De(this,e).ease=t}}function Kl(e){var t=this._id;return arguments.length?this.each(eg(t,e)):Se(this.node(),t).ease}function tg(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;De(this,e).ease=o}}function ql(e){if(typeof e!="function")throw new Error;return this.each(tg(this._id,e))}function Zl(e){typeof e!="function"&&(e=sn(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=[],l,c=0;c<a;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&s.push(l);return new Be(n,this._parents,this._name,this._id)}function Jl(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,o=e._groups,n=t.length,r=o.length,i=Math.min(n,r),a=new Array(n),s=0;s<i;++s)for(var l=t[s],c=o[s],d=l.length,p=a[s]=new Array(d),f,m=0;m<d;++m)(f=l[m]||c[m])&&(p[m]=f);for(;s<n;++s)a[s]=t[s];return new Be(a,this._parents,this._name,this._id)}function og(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 ng(e,t,o){var n,r,i=og(t)?xn:De;return function(){var a=i(this,e),s=a.on;s!==n&&(r=(n=s).copy()).on(t,o),a.on=r}}function Ql(e,t){var o=this._id;return arguments.length<2?Se(this.node(),o).on.on(e):this.each(ng(o,e,t))}function rg(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function jl(){return this.on("end.remove",rg(this._id))}function ec(e){var t=this._name,o=this._id;typeof e!="function"&&(e=lo(e));for(var n=this._groups,r=n.length,i=new Array(r),a=0;a<r;++a)for(var s=n[a],l=s.length,c=i[a]=new Array(l),d,p,f=0;f<l;++f)(d=s[f])&&(p=e.call(d,d.__data__,f,s))&&("__data__"in d&&(p.__data__=d.__data__),c[f]=p,zt(c[f],t,o,f,c,Se(d,o)));return new Be(i,this._parents,t,o)}function tc(e){var t=this._name,o=this._id;typeof e!="function"&&(e=rn(e));for(var n=this._groups,r=n.length,i=[],a=[],s=0;s<r;++s)for(var l=n[s],c=l.length,d,p=0;p<c;++p)if(d=l[p]){for(var f=e.call(d,d.__data__,p,l),m,y=Se(d,o),E=0,u=f.length;E<u;++E)(m=f[E])&&zt(m,t,o,E,f,y);i.push(f),a.push(d)}return new Be(i,a,t,o)}var ig=St.prototype.constructor;function oc(){return new ig(this._groups,this._parents)}function sg(e,t){var o,n,r;return function(){var i=Gt(this,e),a=(this.style.removeProperty(e),Gt(this,e));return i===a?null:i===o&&a===n?r:r=t(o=i,n=a)}}function nc(e){return function(){this.style.removeProperty(e)}}function ag(e,t,o){var n,r=o+"",i;return function(){var a=Gt(this,e);return a===r?null:a===n?i:i=t(n=a,o)}}function lg(e,t,o){var n,r,i;return function(){var a=Gt(this,e),s=o(this),l=s+"";return s==null&&(l=s=(this.style.removeProperty(e),Gt(this,e))),a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s))}}function cg(e,t){var o,n,r,i="style."+t,a="end."+i,s;return function(){var l=De(this,e),c=l.on,d=l.value[i]==null?s||(s=nc(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(a,r=d),l.on=n}}function rc(e,t,o){var n=(e+="")=="transform"?is:br;return t==null?this.styleTween(e,sg(e,n)).on("end.style."+e,nc(e)):typeof t=="function"?this.styleTween(e,lg(e,n,Ro(this,"style."+e,t))).each(cg(this._id,e)):this.styleTween(e,ag(e,n,t),o).on("end.style."+e,null)}function dg(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function ug(e,t,o){var n,r;function i(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&dg(e,a,o)),n}return i._value=t,i}function ic(e,t,o){var n="style."+(e+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;return this.tween(n,ug(e,t,o==null?"":o))}function pg(e){return function(){this.textContent=e}}function fg(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function sc(e){return this.tween("text",typeof e=="function"?fg(Ro(this,"text",e)):pg(e==null?"":e+""))}function mg(e){return function(t){this.textContent=e.call(this,t)}}function gg(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&mg(r)),t}return n._value=e,n}function ac(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,gg(e))}function lc(){for(var e=this._name,t=this._id,o=Tr(),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=Se(l,t);zt(l,e,o,c,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Be(n,this._parents,e,o)}function cc(){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=De(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 hg=0;function Be(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function dc(e){return St().transition(e)}function Tr(){return++hg}var Mt=St.prototype;Be.prototype=dc.prototype={constructor:Be,select:ec,selectAll:tc,selectChild:Mt.selectChild,selectChildren:Mt.selectChildren,filter:Zl,merge:Jl,selection:oc,transition:lc,call:Mt.call,nodes:Mt.nodes,node:Mt.node,size:Mt.size,empty:Mt.empty,each:Mt.each,on:Ql,attr:Wl,attrTween:Xl,style:rc,styleTween:ic,text:sc,textTween:ac,remove:jl,tween:Fl,delay:Ul,duration:$l,ease:Kl,easeVarying:ql,end:cc,[Symbol.iterator]:Mt[Symbol.iterator]};function vr(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var yg={time:null,delay:0,duration:250,ease:vr};function xg(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 uc(e){var t,o;e instanceof Be?(t=e._id,e=e._name):(t=Tr(),(o=yg).time=hn(),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])&&zt(l,e,t,c,a,o||xg(l,t));return new Be(n,this._parents,e,t)}St.prototype.interrupt=Yl;St.prototype.transition=uc;function Yt(e,t,o){this.k=e,this.x=t,this.y=o}Yt.prototype={constructor:Yt,scale:function(e){return e===1?this:new Yt(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Yt(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Nr=new Yt(1,0,0);wr.prototype=Yt.prototype;function wr(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Nr;return e.__zoom}var _g=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var pc;(function(e){e.Strict="strict",e.Loose="loose"})(pc||(pc={}));var fc;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(fc||(fc={}));var mc;(function(e){e.Partial="partial",e.Full="full"})(mc||(mc={}));var gc;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(gc||(gc={}));var hc;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(hc||(hc={}));var We;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(We||(We={}));var lI={[We.Left]:We.Right,[We.Right]:We.Left,[We.Top]:We.Bottom,[We.Bottom]:We.Top};var bg=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var Tg=(e,t=[0,0])=>{var s;let{width:o,height:n}=vg(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 Ir=(e,t=[0,0])=>{var r,i,a,s,l,c,d,p;let{x:o,y:n}=bg(e)?e.internals.positionAbsolute:Tg(e,t);return{x:o,y:n,x2:o+((s=(a=(i=(r=e.measured)==null?void 0:r.width)!=null?i:e.width)!=null?a:e.initialWidth)!=null?s:0),y2:n+((p=(d=(c=(l=e.measured)==null?void 0:l.height)!=null?c:e.height)!=null?d:e.initialHeight)!=null?p:0)}};function vg(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 cI={[We.Left]:{x:-1,y:0},[We.Right]:{x:1,y:0},[We.Top]:{x:0,y:-1},[We.Bottom]:{x:0,y:1}};var Ng={nodeOrigin:[0,0],nodeExtent:_g,elevateNodesOnSelect:!0,defaults:{}},dI=w(_({},Ng),{checkEquality:!0});var yc;(function(e){e.Line="line",e.Handle="handle"})(yc||(yc={}));var wg={width:0,height:0,x:0,y:0},uI=w(_({},wg),{pointerX:0,pointerY:0,aspectRatio:1});var Ig=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function Ag(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 Cg(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 Ar=class{constructor(){this.xLines=[];this.yLines=[]}initialize(t){this.xLines=t.filter(o=>o.orientation==="vertical"),this.yLines=t.filter(o=>o.orientation==="horizontal"),this.xLines.sort((o,n)=>o.position-n.position),this.yLines.sort((o,n)=>o.position-n.position),this.lastHorizontalLine=void 0,this.lastVerticalLine=void 0}search(t,o,n,r,i){let a=t==="horizontal"?this.yLines:this.xLines,[s,l]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],c=[];for(let m of a){if(m.position<s)continue;if(m.position>l)break;if(i.has(m.node.id)||m.node.parentId&&i.has(m.node.parentId)||!Ig(m.nodeBox,r))continue;let y=Math.abs(m.position-o);if(y>Cr)continue;let u=Ag(m.nodeBox,n)>0?0:Cg(m.nodeBox,n);c.push({line:m,lineDist:y,nodeDist:u})}let d=.5,p=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;c.sort((m,y)=>{if(p){if(m.line===p&&y.line!==p)return-1;if(y.line===p&&m.line!==p)return 1}return Math.abs(m.lineDist-y.lineDist)<=d?m.nodeDist-y.nodeDist:m.lineDist-y.lineDist});let f=c.length>0?c[0].line:void 0;return f&&(t==="horizontal"?this.lastHorizontalLine=f:this.lastVerticalLine=f),f}};function xc(e,t=fo,o){let n=[];return e==null||e.forEach(r=>{let i=o(r.id);if(!i)throw new Error(`Node with id ${r.id} not found in internal nodes.`);let a=Ir(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 Ec(e,t,o,n,r=Object.keys(fo)){let i=[];for(let s of r){let l=fo[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 _c(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)<=Cr&&(r=l,a=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=Cr&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:a}}var Cr=10,fo={top:{orientation:"horizontal",resolve:(e,t)=>t.y},bottom:{orientation:"horizontal",resolve:(e,t)=>t.y2},left:{orientation:"vertical",resolve:(e,t)=>t.x},right:{orientation:"vertical",resolve:(e,t)=>t.x2},centerX:{orientation:"vertical",resolve:(e,t)=>(t.x+t.x2)/2},centerY:{orientation:"horizontal",resolve:(e,t)=>(t.y+t.y2)/2}};import{jsx as Og}from"react/jsx-runtime";var Dg=new Ar;function Sr(){let[e,t]=bc(void 0),[o,n]=bc(void 0),{width:r,height:i}=Pg(u=>({width:u.width,height:u.height}),Rg),a=Sg(),s=kg(Dg),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=Mg(),p=En(()=>{t(void 0),n(void 0)},[]),f=En(u=>{let g=u!=null?u:d();p();let h=xc(g,fo,c);s.current.initialize(h)},[c,p,d]),m=En(()=>{setTimeout(()=>{f()},100)},[f]);Lg(()=>{a&&f(d())},[a,f,d]);let y=En((u,g)=>{var G,k,O,Y,F,U,X,$,te,ie;if(!s.current||u.length===0||u.filter(W=>W.type==="dimensions").length>1)return u;p();let x=u.filter(W=>W.type==="position"&&!!W.position),T=u.find(W=>W.type==="dimensions");if(x.length===0&&!T)return u;let b=Object.keys(fo),N=new Set,v=1/0,I=1/0,C=-1/0,P=-1/0;if(x.length>0)x.forEach(W=>{var de,re,ee,ge,be,Te;let oe=g.find(Re=>Re.id===W.id);if(!oe)return;N.add(oe.id);let le=c(oe.id);if(!le)return;let Z=le.parentId?c(le.parentId):void 0,xe=W.position.x+((de=Z==null?void 0:Z.internals.positionAbsolute.x)!=null?de:0),me=W.position.y+((re=Z==null?void 0:Z.internals.positionAbsolute.y)!=null?re:0),_e=(ge=(ee=oe.measured)==null?void 0:ee.width)!=null?ge:0,J=(Te=(be=oe.measured)==null?void 0:be.height)!=null?Te:0;v=Math.min(v,xe),I=Math.min(I,me),C=Math.max(C,xe+_e),P=Math.max(P,me+J)}),T&&(b=["top","left"]);else if(T){let W=g.find(_e=>_e.id===T.id);if(!W)return u;N.add(W.id);let oe=c(W.id);if(!oe)return u;let le=oe.internals.positionAbsolute.x,Z=oe.internals.positionAbsolute.y,xe=(Y=(O=(G=T.dimensions)==null?void 0:G.width)!=null?O:(k=W.measured)==null?void 0:k.width)!=null?Y:0,me=($=(X=(F=T.dimensions)==null?void 0:F.height)!=null?X:(U=W.measured)==null?void 0:U.height)!=null?$:0;v=le,I=Z,C=le+xe,P=Z+me,b=["right","bottom"]}if(v===1/0)return u;let R={x:v,y:I,x2:C,y2:P},{x:S,y:L}=l({x:0,y:0}),{x:K,y:j}=l({x:r,y:i}),Q={x:S,y:L,x2:K,y2:j},{horizontal:z,vertical:M}=Ec(s.current,Q,R,N,b),{deltaX:V,deltaY:D,snappedX:A,snappedY:B}=_c(R,z,M);if(A||B){let W=x.some(le=>le.dragging),oe=!!(T!=null&&T.resizing);(W||oe)&&(A&&n(M==null?void 0:M.line),B&&t(z==null?void 0:z.line)),A&&(x.forEach(le=>{le.position&&(le.position.x-=V)}),(T==null?void 0:T.id)===((te=x[0])==null?void 0:te.id)?T.dimensions&&(T.dimensions.width+=V):T&&!x.length&&T.dimensions&&(T.dimensions.width-=V)),B&&(x.forEach(le=>{le.position&&(le.position.y-=D)}),(T==null?void 0:T.id)===((ie=x[0])==null?void 0:ie.id)?T.dimensions&&(T.dimensions.height+=D):T&&!x.length&&T.dimensions&&(T.dimensions.height-=D))}return u},[l,c,r,i,t,n,p]),E=En(()=>Og(Tc,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:f,forceRebuildIndex:m,updateHelperLines:y,helperLineHorizontal:e,helperLineVertical:o,HelperLines:E}}import{reconnectEdge as z0,useReactFlow as Y0}from"@xyflow/react";import{useCallback as Eo,useRef as F0}from"react";var Pt=e=>new Map(e.map(t=>[t.id,t])),_n=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),vc=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),cs=e=>e.some(t=>t.type==="START_EVENT"),Ft=(e,t)=>e==="START_EVENT"?!cs(t):!0,Nc=(e,t,o,n,r)=>{let i=Pt(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:_n(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},wc=(e,t,o,n,r)=>{let i=Pt(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:vc(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Mr=(e,t,o,n,r)=>{var c;let i=Pt(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:_n(e,n,r).filter(d=>{let p=i.get(d.target);return(p==null?void 0:p.type)!=="ANNOTATION"}).length>=2},Ic=(e,t,o)=>{var a,s,l,c;let n=Pt(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"},Pr=(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"},Ac=(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"},bn=(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"},Lr=(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"},mo=(e,t,o,n)=>{let r=Pt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:vc(e,o,n).some(s=>{let l=r.get(s.source);return(l==null?void 0:l.type)==="START_EVENT"})},Tn=(e,t,o,n)=>{let r=Pt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:_n(e,o,n).some(s=>{let l=r.get(s.target);return(l==null?void 0:l.type)==="END_EVENT"})},Cc=(e,t,o,n,r)=>{let i=Pt(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"?Tn(t,o,n,r):(s==null?void 0:s.type)==="END_EVENT"&&(a==null?void 0:a.type)==="TASK"?mo(e,o,n,r):!1},kr=(e,t,o)=>_n(e,t,o).length>0,Rr=(e,t,o,n,r)=>{let i=Pt(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:_n(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var Sc=(e,t,o,n,r)=>{var s,l;let i=Pt(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 Vg=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!Sc(e.sourceNodeId,e.targetNodeId,e.edges,e.nodes,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!Nc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!wc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!Mr(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!Rr(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:Ic(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"&&Ac(e.targetNodeId,e.nodes)),reason:"start_event_to_subprocess_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&bn(e.targetNodeId,e.nodes)),reason:"start_event_to_service_task_not_allowed"}),e=>({isValid:!(bn(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:!(Pr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(Lr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(mo(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!Cc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(Tn(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(kr(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"})],ds=e=>{for(let t of Vg){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var Hg=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:Mr(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:cs(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Pr(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Lr(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:bn(e.sourceNodeId,e.nodes),reason:"service_task_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:mo(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Tn(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:kr(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Rr(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],Mc=e=>{let t=Hg.filter(o=>{let n=!o.sourceTypes||o.sourceTypes.includes(e.sourceNodeType),r=!o.targetTypes||o.targetTypes.includes(e.targetNodeType);return n&&r});for(let o of t){let n=o.validate(e);if(n.shouldDisable)return n}return{shouldDisable:!1}};import{BaseEdge as fh,EdgeLabelRenderer as mh,getStraightPath as gh,useInternalNode as Lc,useViewport as hh}from"@xyflow/react";import{Button as Bg,Tooltip as zg,TooltipContent as Yg,TooltipTrigger as Fg,useTranslation as Wg}from"@produto-lecom/lecom-ui";import{Settings as Xg}from"lucide-react";import{getIncomers as Dr,getOutgoers as Or,useReactFlow as Gg}from"@xyflow/react";var Vr=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=Gg(),{selectElements:r}=Et(),i=u=>{let g=o(),h=n(),x=Dr(u,g,h),T=Or(u,g,h),b=x.some(v=>v.type==="START_EVENT"),N=T.some(v=>v.type==="END_EVENT");return b?"start":N?"end":"between"},a=(u,g,h)=>{var b,N,v,I,C;if(!u)return;let x={type:u.type,variant:(b=u.data)==null?void 0:b.variant,attribute:(N=u.data)==null?void 0:N.attribute},T={id:u.id,position:i(u),label:(v=u.data)==null?void 0:v.label,node:x};return u.type==="TASK"&&((I=u.data)==null?void 0:I.variant)==="SUBPROCESS"?w(_({},T),{type:"sub_process"}):u.type==="TASK"&&((C=u.data)==null?void 0:C.variant)==="SERVICE_TASK"?w(_({},T),{type:"service_task"}):u.type==="GATEWAY"?w(_({},T),{type:"gateway",variant:s(u,g,h)}):w(_({},T),{type:"activity"})},s=(u,g,h)=>{if(u.type!=="GATEWAY")return;let x=Dr(u,g,h),T=!1,b=!1;if(x.forEach(N=>{var v,I;N.type==="TASK"&&(((v=N.data)==null?void 0:v.variant)==="SCRIPT"&&(T=!0),((I=N.data)==null?void 0:I.attribute)==="LOOP"&&(b=!0))}),T&&b)return"script_loop";if(T)return"script";if(b)return"loop"},l=(u,g,h)=>{var v,I,C,P,R;let x=e(u.source),T=e(u.target);if(!x||!T)return"simple";if(Or(x,g,h).some(S=>S.type==="END_EVENT"))return"final";if(x.type==="GATEWAY")switch((v=x.data)==null?void 0:v.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(x.type==="TASK"){let S=(I=x.data)==null?void 0:I.variant,L=(C=x.data)==null?void 0:C.attribute;if(S==="SUBPROCESS")return"from_sub_process";if(S==="SERVICE_TASK")return"from_service_task";if(T.type==="TASK"&&((P=T.data)==null?void 0:P.variant)==="SUBPROCESS")return"to_sub_process";if(T.type==="TASK"&&((R=T.data)==null?void 0:R.variant)==="SERVICE_TASK")return"to_service_task";let K=S==="SCRIPT",j=L==="LOOP";return K&&j?"script_loop":K?"script":j?"loop":"simple"}return"simple"},c=(u,g,h)=>{let x=[];function T(N,v,I=0){let C=a(N,g,h);if(C.depth=I,v.push(C),N.type==="TASK"){x.push([...v]),v.pop();return}let P=Dr(N,g,h);if(P.length)for(let R of P)T(R,v,I+1);v.pop()}let b=Dr(u,g,h);for(let N of b)T(N,[]);return x},d=(u,g,h)=>{let x=[];function T(N,v,I=0){let C=a(N,g,h);if(C.depth=I,v.push(C),N.type==="TASK"){x.push([...v]),v.pop();return}let P=Or(N,g,h);if(P.length)for(let R of P)T(R,v,I+1);v.pop()}let b=Or(u,g,h);for(let N of b)T(N,[]);return x},p=(u,g,h)=>(h=h.filter(T=>T.source===u.id),h.map(T=>{var v;let b=e(T.target),N;return b&&(N=a(b,g,h)),{id:T.id,type:"routing",variant:l(T,g,h),label:(v=T.data)==null?void 0:v.label,target:N}})),f=u=>{let g=e(u);if(!g)return;let h=o(),x=n(),T=a(g,h,x);return T.sources=c(g,h,x),T.targets=d(g,h,x),T.edgeTargets=p(g,h,x),g.type==="GATEWAY"&&(T.variant=s(g,h,x)),T},m=u=>{let g=t(u);if(!g)return;let h=o(),x=n(),T=l(g,h,x),N={id:g.id,type:"routing",variant:T,gatewayVariant:void 0},v=e(g.source);if(v){let C=a(v,h,x);N.source=C;let P=s(v,h,x);if(N.gatewayVariant=P,v.type==="TASK")N.sources=[[C]];else{let R=c(v,h,x);N.sources=R.length?R:[[C]]}}let I=e(g.target);if(I){let C=a(I,h,x);if(N.target=C,I.type==="TASK")N.targets=[[C]];else{let P=d(I,h,x);N.targets=P.length?P:[[C]]}}return N},y=u=>{let g=e(u);if(g)return f(g.id);let h=t(u);if(h)return m(h.id)};return{configureElement:u=>{let g=y(u);if(g)return r([u]),g},getConfigureElement:y,getNodeConfigure:f,getEdgeConfigure:m}};import{jsx as Hr,jsxs as $g}from"react/jsx-runtime";var Ug={node:"editor.toolbar.configure_node",edge:"editor.toolbar.configure_edge",gateway:"editor.toolbar.configure_gateway"},Wt=({elementId:e,elementType:t="node"})=>{let{t:o}=Wg(),{onConfigureElement:n}=q(),{getConfigureElement:r}=Vr();return $g(zg,{children:[Hr(Fg,{asChild:!0,children:Hr(Bg,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let a=r(e);a&&(n==null||n(a))},children:Hr(Xg,{size:16})})}),Hr(Yg,{color:"black",children:o(Ug[t])})]})};import{Button as qg,Tooltip as Zg,TooltipContent as Jg,TooltipTrigger as Qg,useTranslation as jg}from"@produto-lecom/lecom-ui";import{useReactFlow as eh}from"@xyflow/react";import{TrashIcon as th}from"lucide-react";import{useNotificationToast as Kg}from"@produto-lecom/lecom-ui";function Le(){let{toast:e}=vn(),{toast:t}=Kg();return{toast:e||t}}import{jsx as Gr,jsxs as oh}from"react/jsx-runtime";var Br=({elementId:e,elementType:t="node"})=>{let{t:o}=jg(),{toast:n}=Le(),{deleteElements:r,getNodes:i}=eh();return oh(Zg,{children:[Gr(Qg,{asChild:!0,children:Gr(qg,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{if(t==="node"){let s=i(),l=s.find(c=>c.id===e);if((l==null?void 0:l.type)==="LANE"&&s.some(d=>d.parentId===e)){n({variant:"error",title:o("validation.errors.title"),content:o("editor.toolbar.delete_pool_lane_error")});return}r({nodes:[{id:e}]})}else r({edges:[{id:e}]})},children:Gr(th,{size:16})})}),Gr(Jg,{color:"black",children:o("editor.toolbar.delete")})]})};import{Button as nh,Tooltip as rh,TooltipContent as ih,TooltipTrigger as sh,useTranslation as ah}from"@produto-lecom/lecom-ui";import{MoveUpRightIcon as lh}from"lucide-react";import{useCallback as ch}from"react";import{jsx as zr,jsxs as dh}from"react/jsx-runtime";var Do=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=ah(),r=ch(i=>{i.stopPropagation();let a=document.querySelectorAll(`.react-flow__handle.source[data-nodeid="${e}"]`);if(a.length===0)return;let s=Array.from(a).reduce((f,m)=>{let y=f.getBoundingClientRect(),E=m.getBoundingClientRect(),u=Math.hypot(i.clientX-(y.left+y.width/2),i.clientY-(y.top+y.height/2));return Math.hypot(i.clientX-(E.left+E.width/2),i.clientY-(E.top+E.height/2))<u?m:f}),l=s.getBoundingClientRect(),c=l.left+l.width/2,d=l.top+l.height/2,p=new MouseEvent("mousedown",{clientX:c,clientY:d,bubbles:!0,cancelable:!0});s.dispatchEvent(p)},[e]);return dh(rh,{children:[zr(sh,{asChild:!0,children:zr(nh,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:zr(lh,{size:16})})}),zr(ih,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};import{jsx as Nn}from"react/jsx-runtime";var Oo=i=>{var a=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=a,r=yt(a,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:s}=q(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d,isToEndEvent:p}=Jn(o,n),f=!l&&!c&&!d&&!p,m=[{component:Nn(Br,{elementId:e,elementType:"edge"})}],y=()=>s==="view"?f?[{component:Nn(Wt,{elementId:e,elementType:"edge"})}]:[]:f?[{component:Nn(Wt,{elementId:e,elementType:"edge"})},...m]:m,u=(g=>{switch(g){case"SEQUENCE_EDGE":return y();case"MESSAGE_EDGE":return s==="view"?[]:[...m];case"ANNOTATION_EDGE":return s==="view"?[]:[...m];default:return[]}})(t);if(!(u.length===0||s==="readonly"))return Nn("div",w(_({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:u.map((g,h)=>Nn("div",{children:g.component},h))}))};import{useViewport as uh}from"@xyflow/react";import{useMemo as ph}from"react";import{jsx as Pc}from"react/jsx-runtime";var bt=12,Vo=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:a}=uh(),s=1/a,l=ph(()=>t===n?{bottom:`${bt}px`,transform:"translateX(-50%)"}:e===o?{left:`${bt}px`,transform:r?"translateY(-100%)":"translateY(-50%)"}:n>t&&o>e?{left:`${bt}px`,bottom:`${bt}px`}:n>t&&o<e?{right:`${bt}px`,bottom:`${bt}px`}:t>n&&o>e?{right:`${bt}px`,bottom:`${bt}px`}:{left:`${bt}px`,bottom:`${bt}px`},[e,t,o,n,r]);return Pc("div",{style:{transform:`scale(${s})`},children:Pc("div",{className:"absolute pointer-events-auto",style:_({},l),children:i})})};import{Fragment as yh,jsx as ho,jsxs as kc}from"react/jsx-runtime";var Ho={type:"ANNOTATION_EDGE",reconnectable:!0},Rc=({id:e,source:t,target:o,selected:n,data:r})=>{let{isMultipleSelection:i,isReadOnly:a,edgeHighlight:s}=q(),{zoom:l}=hh(),c=Lc(t),d=Lc(o);if(!c||!d)return null;let{sx:p,sy:f,tx:m,ty:y}=Mo(c,d),[E,u,g]=gh({sourceX:p,sourceY:f,targetX:m,targetY:y}),h=s&&(n||(c==null?void 0:c.selected)||(d==null?void 0:d.selected));return ho(yh,{children:kc("g",{className:H("group bpmn-edge",{"is-highlighted":h}),children:[ho("path",{d:E,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/l),style:{pointerEvents:"stroke",cursor:"pointer"}}),kc("g",{className:H("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!a,"text-blue-500 group-hover:text-blue-600":h}),children:[ho(fh,{id:e,path:E,interactionWidth:0,strokeDasharray:4,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":r==null?void 0:r.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":h&&!(r!=null&&r.hasError)})}),ho(mh,{children:ho("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${u}px, ${g}px)`},children:n&&!i&&ho(Vo,{sx:p,sy:f,tx:m,ty:y,children:ho(Oo,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})})})]})]})})};import{useState as Wc,useCallback as Xc,useMemo as fs,useEffect as Rh,useRef as ms}from"react";import{BaseEdge as Dh,EdgeLabelRenderer as Oh,MarkerType as Uc,useInternalNode as $c,useReactFlow as Vh,useViewport as Hh,useEdges as Gh,useNodes as Bh,Position as Yo}from"@xyflow/react";import{useCallback as xh,useEffect as us,useRef as Dc,useState as Eh}from"react";import{jsx as Vc}from"react/jsx-runtime";var ps=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,Oc=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Escape","Shift"],Oe=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:a,onBlur:s,onInput:l,onInvalidFirstCharacter:c,skipFirstCharValidation:d})=>{let p=Dc(null),f=Dc(null),[m,y]=Eh(!1);us(()=>()=>{f.current&&clearTimeout(f.current)},[]),us(()=>{y(i!=null?i:!1)},[i]),us(()=>{if(m&&p.current){p.current.focus();let b=document.createRange();b.selectNodeContents(p.current);let N=window.getSelection();N&&(N.removeAllRanges(),N.addRange(b))}},[m]);let E=xh(()=>{f.current||(c==null||c(),f.current=setTimeout(()=>{f.current=null},500))},[c]),u=b=>{b.stopPropagation(),m||y(!0)},g=b=>{let N=b.currentTarget.innerText.replace(/\n$/,""),v=t&&N.length>=t,I=window.getSelection(),C=(I==null?void 0:I.toString())||"",P=C.length>0,R=(b.ctrlKey||b.metaKey)&&!b.altKey,S=R&&b.key==="a",L=R&&b.key==="c",K=R&&b.key==="x",j=R&&b.key==="v",Q=N.length===0||P&&C.length===N.length;if(!d&&Q&&!ps.test(b.key)&&!Oc.includes(b.key)&&!R){b.preventDefault(),E();return}v&&!P&&(Oc.includes(b.key)||S||L||K||j||b.preventDefault())},h=b=>{b.preventDefault();let N=b.clipboardData.getData("text/plain").replace(/\r\n/g,`
2
2
  `).replace(/\r/g,`
3
- `),T=b.currentTarget.innerText.replace(/\n$/,""),A=window.getSelection();if(!A||A.rangeCount===0)return;let C=A.toString(),P=T.length-C.length,R=t?Math.max(0,t-P):1/0;if(R<=0&&C.length===0)return;let S=N;if(S.length>R&&(S=S.substring(0,R)),!S&&C.length===0)return;let L=A.getRangeAt(0),K=L.startOffset===0&&(L.startContainer===b.currentTarget||L.startContainer.parentNode===b.currentTarget);if(!d&&K&&S.length>0&&!ds.test(S[0])){E();return}L.deleteContents();let j=document.createTextNode(S);L.insertNode(j),L.setStartAfter(j),L.collapse(!0),A.removeAllRanges(),A.addRange(L),l==null||l(b.currentTarget.innerText.replace(/\n$/,""))},x=b=>{let N=b.currentTarget,T=N.innerText.replace(/\n$/,"");if(!d&&T.length>0&&!ds.test(T[0])){let A=T.slice(1);if(N.innerText=A,A.length>0&&N.firstChild){let C=document.createRange(),P=window.getSelection();C.setStart(N.firstChild,0),C.collapse(!0),P==null||P.removeAllRanges(),P==null||P.addRange(C)}E(),l==null||l(A);return}l==null||l(T)},v=b=>{y(!1);let N=b.currentTarget.innerText.replace(/\r\n/g,`
3
+ `),v=b.currentTarget.innerText.replace(/\n$/,""),I=window.getSelection();if(!I||I.rangeCount===0)return;let C=I.toString(),P=v.length-C.length,R=t?Math.max(0,t-P):1/0;if(R<=0&&C.length===0)return;let S=N;if(S.length>R&&(S=S.substring(0,R)),!S&&C.length===0)return;let L=I.getRangeAt(0),K=L.startOffset===0&&(L.startContainer===b.currentTarget||L.startContainer.parentNode===b.currentTarget);if(!d&&K&&S.length>0&&!ps.test(S[0])){E();return}L.deleteContents();let j=document.createTextNode(S);L.insertNode(j),L.setStartAfter(j),L.collapse(!0),I.removeAllRanges(),I.addRange(L),l==null||l(b.currentTarget.innerText.replace(/\n$/,""))},x=b=>{let N=b.currentTarget,v=N.innerText.replace(/\n$/,"");if(!d&&v.length>0&&!ps.test(v[0])){let I=v.slice(1);if(N.innerText=I,I.length>0&&N.firstChild){let C=document.createRange(),P=window.getSelection();C.setStart(N.firstChild,0),C.collapse(!0),P==null||P.removeAllRanges(),P==null||P.addRange(C)}E(),l==null||l(I);return}l==null||l(v)},T=b=>{y(!1);let N=b.currentTarget.innerText.replace(/\r\n/g,`
4
4
  `).replace(/\r/g,`
5
- `).trim();t&&N.length>t&&(N=N.substring(0,t)),b.currentTarget.innerText=N,s==null||s(),N!==e&&(a==null||a(N))};return Lc("div",{className:H("flex-1 p-2 self-stretch flex items-center justify-center border border-transparent overflow-hidden text-ellipsis body-medium-400 text-center rounded-sm",{"border border-dashed border-grey-400 bg-white shadow-md":f,"bg-white":e.length>0},n),style:o,onDoubleClick:p,children:Lc("div",{ref:u,className:H("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":f}),contentEditable:f,suppressContentEditableWarning:!0,onKeyDown:g,onPaste:h,onInput:x,onBlur:v,children:e})})};import{Position as XI}from"@xyflow/react";var ye=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,Vo=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),zr=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),gh=(e,t,o)=>{let n=o.x-t.x,r=o.y-t.y,i=n*n+r*r;if(i===0)return Vo(e,t);let a=Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*r)/i));return Vo(e,{x:t.x+a*n,y:t.y+a*r})},kc=(e,t)=>{let o=1/0;for(let n=0;n<t.length-1;n++)o=Math.min(o,gh(e,t[n],t[n+1]));return o};import{Position as Yr}from"@xyflow/react";var Wt={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15,MAX_LABEL_DISTANCE:80};var{TOLERANCE:ce}=Wt;function hh(e,t,o){return ye(e,t,"x",ce)&&ye(t,o,"x",ce)&&ye(e,o,"x",ce)}function yh(e,t,o){return ye(e,t,"y",ce)&&ye(t,o,"y",ce)&&ye(e,o,"y",ce)}function xh(e,t,o){if(!hh(e,t,o))return!1;let n=t.y-e.y,r=o.y-t.y;return Math.abs(n)<ce||Math.abs(r)<ce?!1:n*r<0}function Eh(e,t,o){if(!yh(e,t,o))return!1;let n=t.x-e.x,r=o.x-t.x;return Math.abs(n)<ce||Math.abs(r)<ce?!1:n*r<0}function _h(e,t,o,n){let r=t.x!==0,i=t.x===-n.x&&t.y===-n.y,a=t.x===n.x&&t.y===n.y,s=120;if(i)if(r){if((o.x-e.x)*t.x>=0)return[{x:(e.x+o.x)/2,y:e.y},{x:(e.x+o.x)/2,y:o.y}];{let l=(e.y+o.y)/2,c=Math.abs(e.y-o.y)<s?Math.max(e.y,o.y)+s:l;return[{x:e.x,y:c},{x:o.x,y:c}]}}else{if((o.y-e.y)*t.y>=0)return[{x:e.x,y:(e.y+o.y)/2},{x:o.x,y:(e.y+o.y)/2}];{let l=(e.x+o.x)/2,c=Math.abs(e.x-o.x)<s?Math.max(e.x,o.x)+s:l;return[{x:c,y:e.y},{x:c,y:o.y}]}}else if(a)if(r)if((o.x-e.x)*t.x>0&&Math.abs(e.y-o.y)<s){let l=Math.max(e.y,o.y)+s,c=o.x+t.x*(s/2);return[{x:e.x,y:l},{x:c,y:l},{x:c,y:o.y}]}else{let l=t.x>0?Math.max(e.x,o.x):Math.min(e.x,o.x);return[{x:l,y:e.y},{x:l,y:o.y}]}else if((o.y-e.y)*t.y>0&&Math.abs(e.x-o.x)<s){let l=Math.max(e.x,o.x)+s,c=o.y+t.y*(s/2);return[{x:l,y:e.y},{x:l,y:c},{x:o.x,y:c}]}else{let l=t.y>0?Math.max(e.y,o.y):Math.min(e.y,o.y);return[{x:e.x,y:l},{x:o.x,y:l}]}else{let l=t.x!==0?o.x:e.x,c=t.y!==0?o.y:e.y,d=t.x!==0?(l-e.x)*t.x:(c-e.y)*t.y,u=n.x!==0?(l-o.x)*n.x:(c-o.y)*n.y;return d>=0&&u>=0?[{x:l,y:c}]:r?[{x:e.x,y:o.y}]:[{x:o.x,y:e.y}]}}function Rc(e){if(e.length<=2)return e;let t=[e[0]];for(let o=1;o<e.length-1;o++){let n=t[t.length-1],r=e[o],i=e[o+1];ye(n,r,"x",ce)&&ye(r,i,"x",ce)||ye(n,r,"y",ce)&&ye(r,i,"y",ce)||t.push(r)}return t.push(e[e.length-1]),t}function Fr(e){let t=[];for(let o of e){let n=t[t.length-1];(!n||Math.abs(n.x-o.x)>=ce||Math.abs(n.y-o.y)>=ce)&&t.push(o)}return t}function bh(e){let t=[...e],o=!0;for(;o;){o=!1;for(let n=1;n<t.length-1;n++){let r=t[n-1],i=t[n],a=t[n+1];if(xh(r,i,a)||Eh(r,i,a)){t.splice(n,1),o=!0;break}}}return t}function Dc(e){let t=Fr(Rc([...e]));return t=bh(t),Fr(Rc(t))}function Wr(e){switch(e){case Yr.Left:return{x:-1,y:0};case Yr.Right:return{x:1,y:0};case Yr.Top:return{x:0,y:-1};case Yr.Bottom:return{x:0,y:1};default:return{x:0,y:0}}}function Oc(e,t,o,n){let r=Wt.OFFSET,i=Wt.OFFSET;if(t.x===-n.x&&t.y===-n.y)if(t.x!==0){let a=(o.x-e.x)*t.x;a>0&&a<2*Wt.OFFSET&&(r=a/2,i=a/2)}else{let a=(o.y-e.y)*t.y;a>0&&a<2*Wt.OFFSET&&(r=a/2,i=a/2)}return{sourceOffset:r,targetOffset:i}}function Th(e,t,o,n,r,i,a=0){let s=Wr(r),l=Wr(i),c=s.x===0?a:0,d=s.y===0?a:0,u=l.x===0?a:0,m=l.y===0?a:0,f={x:e+c,y:t+d},y={x:o+u,y:n+m},{sourceOffset:E,targetOffset:p}=Oc(f,s,y,l),g={x:f.x+s.x*E,y:f.y+s.y*E},h={x:y.x+l.x*p,y:y.y+l.y*p},x=_h(g,s,h,l),v=[f,g,...x,h,y],b=Dc(v);if(b.length===2&&Xr(f,y)>ce){let N=ye(f,g,"x",ce)&&ye(g,h,"x",ce)&&ye(h,y,"x",ce),T=ye(f,g,"y",ce)&&ye(g,h,"y",ce)&&ye(h,y,"y",ce);if(N||T){let A=T&&(h.x-g.x)*s.x<0,C=N&&(h.y-g.y)*s.y<0;if(!A&&!C)return Fr([f,g,h,y])}}return b}function Ur(e,t,o,n,r,i,a,s=0){if(!(a!=null&&a.length))return Th(e,t,o,n,r,i,s);let l=Wr(r),c=Wr(i),d=l.x===0?s:0,u=l.y===0?s:0,m=c.x===0?s:0,f=c.y===0?s:0,y={x:e+d,y:t+u},E={x:o+m,y:n+f},{sourceOffset:p,targetOffset:g}=Oc(y,l,E,c),h={x:y.x+l.x*p,y:y.y+l.y*p},x={x:E.x+c.x*g,y:E.y+c.y*g},v=[...a],b=v[0],N=l.y===0;N&&Math.abs(y.y-b.y)>ce?v.unshift({x:b.x,y:y.y}):!N&&Math.abs(y.x-b.x)>ce&&v.unshift({x:y.x,y:b.y});let T=v[v.length-1],A=c.y===0,C=[];(Math.abs(T.x-x.x)>ce||Math.abs(T.y-x.y)>ce)&&(A?C.push({x:x.x,y:T.y}):C.push({x:T.x,y:x.y})),C.push(x);let P=[y,...v,...C,E],R=Dc(P);if(R.length===2&&Xr(y,E)>ce){let S=ye(y,h,"x",ce)&&ye(h,x,"x",ce)&&ye(x,E,"x",ce),L=ye(y,h,"y",ce)&&ye(h,x,"y",ce)&&ye(x,E,"y",ce);if(S||L){let K=L&&(x.x-h.x)*l.x<0,j=S&&(x.y-h.y)*l.y<0;if(!K&&!j)return Fr([y,h,x,E])}}return R}var Xr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function vh(e,t,o){return ye(e,t,"x",ce)&&ye(t,o,"x",ce)||ye(e,t,"y",ce)&&ye(t,o,"y",ce)}function Nh(e,t,o,n){if(vh(e,t,o))return`L${t.x} ${t.y}`;let r=Xr(e,t),i=Xr(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},m={x:c/i,y:d/i},f={x:t.x+u.x*a,y:t.y+u.y*a},y={x:t.x+m.x*a,y:t.y+m.y*a},E=-u.x,p=-u.y,g=m.x,h=m.y,v=E*h-p*g>0?1:0;return`L${f.x} ${f.y}A${a} ${a} 0 0 ${v} ${y.x} ${y.y}`}var Vc=(e,t=5)=>e.length<2?"":e.reduce((o,n,r)=>{let i="";return r>0&&r<e.length-1?i=Nh(e[r-1],n,e[r+1],t):i=`${r===0?"M":"L"}${n.x} ${n.y}`,o+=i,o},"");import{useCallback as Ho,useEffect as $r,useRef as vn,useState as Go}from"react";import{useReactFlow as wh,useStore as Ah}from"@xyflow/react";var Ih=50,Hc=.1,Ch=.6,Kr=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:a,getNodes:s,getEdge:l,screenToFlowPosition:c}=wh(),{setIsDragging:d,setReconnectingEdgeId:u}=q(),m=Ah(D=>D.isValidConnection),[f,y]=Go(null),[E,p]=Go(null),[g,h]=Go(null),[x,v]=Go(null),[b,N]=Go(null),[T,A]=Go(!1),C=vn(null),P=vn(null),R=vn(null),S=vn(t),L=vn(o);$r(()=>{S.current=t,L.current=o},[t,o]),$r(()=>{C.current=f},[f]),$r(()=>{P.current=b},[b]);let K=Ho(D=>{let I=s(),B=I.find(Y=>Y.id===D);if(!B)return{x:0,y:0};let G=B.position.x,k=B.position.y,O=B.parentId;for(;O;){let Y=I.find(F=>F.id===O);if(!Y)break;G+=Y.position.x,k+=Y.position.y,O=Y.parentId}return{x:G,y:k}},[s]),j=Ho(D=>{var O,Y,F,U,X,$;let I=s(),B=null,G=Ih,k=I.filter(te=>te.type!=="LANE"&&te.type!=="ANNOTATION");for(let te of k){if(te.id===e)continue;let ie=K(te.id),W=(F=(Y=(O=te.measured)==null?void 0:O.width)!=null?Y:te.width)!=null?F:0,oe=($=(X=(U=te.measured)==null?void 0:U.height)!=null?X:te.height)!=null?$:0;if(D.x>=ie.x&&D.x<=ie.x+W&&D.y>=ie.y&&D.y<=ie.y+oe)return te.id;let Z=Math.max(ie.x-D.x,0,D.x-(ie.x+W)),xe=Math.max(ie.y-D.y,0,D.y-(ie.y+oe)),me=Math.sqrt(Z*Z+xe*xe);me<G&&(G=me,B=te.id)}return B},[s,K,e]),Q=Ho((D,I)=>{var Z,xe,me,_e,J,de;let B=a(D);if(!B)return null;let G=K(D),k=(me=(xe=(Z=B.measured)==null?void 0:Z.width)!=null?xe:B.width)!=null?me:0,O=(de=(J=(_e=B.measured)==null?void 0:_e.height)!=null?J:B.height)!=null?de:0,Y=Math.abs(G.x+k-I.x),F=Math.abs(I.x-G.x),U=Math.abs(G.y+O-I.y),X=Math.abs(I.y-G.y),$={right:Y,left:F,bottom:U,top:X},te=Object.entries($).reduce((re,[ee,ge])=>ge<re[1]?[ee,ge]:re,["right",$.right])[0],ie=R.current;if(ie&&ie!==te){let re=$[te],ee=$[ie],ge=Math.abs(ee-re),be=Math.min(Math.abs(ee),Math.abs(re));ge<be*Ch&&(te=ie)}let W=te,oe,le;if(W==="right"||W==="left"){let ee=(Math.max(G.y,Math.min(G.y+O,I.y))-G.y)/(O||1);Math.abs(ee-.5)<Hc&&(ee=.5),le=ee,oe={x:W==="right"?G.x+k:G.x,y:G.y+le*O}}else{let ee=(Math.max(G.x,Math.min(G.x+k,I.x))-G.x)/(k||1);Math.abs(ee-.5)<Hc&&(ee=.5),le=ee,oe={x:G.x+le*k,y:W==="bottom"?G.y+O:G.y}}return{side:W,snapPosition:oe,offset:le}},[a,K]),z=Ho(D=>{var F,U,X;let I=C.current;if(!I)return;let B=c({x:D.clientX,y:D.clientY}),G=j(B);h(G);let k=B,O=null,Y=null;if(G){let $=Q(G,B);$&&(O=$.side,k=$.snapPosition,Y=$.offset,R.current=O);let te=l(e),ie={source:I==="source"?G:S.current,target:I==="target"?G:L.current,sourceHandle:I==="source"?O:(F=te==null?void 0:te.sourceHandle)!=null?F:null,targetHandle:I==="target"?O:(U=te==null?void 0:te.targetHandle)!=null?U:null},W=(X=m==null?void 0:m(ie))!=null?X:!0;A(W)}else R.current=null,A(!1);v(O),N(Y),p(k)},[j,Q,l,e,c,m]),M=Ho(D=>{var O,Y,F,U,X;let I=C.current;if(!I)return;let B=c({x:D.clientX,y:D.clientY}),G=j(B);if(G){let $=Q(G,B),te=(O=$==null?void 0:$.side)!=null?O:null,ie=(Y=$==null?void 0:$.offset)!=null?Y:.5,W=l(e),oe={source:I==="source"?G:S.current,target:I==="target"?G:L.current,sourceHandle:I==="source"?te:(F=W==null?void 0:W.sourceHandle)!=null?F:null,targetHandle:I==="target"?te:(U=W==null?void 0:W.targetHandle)!=null?U:null};((X=m==null?void 0:m(oe))==null||X)&&i(le=>le.map(Z=>{var xe,me;return Z.id===e?w(_({},Z),{source:oe.source,target:oe.target,sourceHandle:oe.sourceHandle,targetHandle:oe.targetHandle,data:w(_({},Z.data),{points:void 0,sourceOffset:I==="source"?ie:(xe=Z.data)==null?void 0:xe.sourceOffset,targetOffset:I==="target"?ie:(me=Z.data)==null?void 0:me.targetOffset})}):Z}))}y(null),p(null),h(null),v(null),N(null),d(!1),A(!1),u(null),R.current=null,document.removeEventListener("mouseup",M),document.removeEventListener("mousemove",z);let k=bt.get(n);k==null||k.clearReconnectingEdge()},[e,j,Q,l,i,n,z,m,c,d,u]),V=Ho((D,I)=>{if(r||I.button!==0)return;I.stopPropagation(),I.preventDefault(),i(G=>G.map(k=>k.id===e?w(_({},k),{data:w(_({},k.data),{points:void 0})}):k)),y(D),u(e);let B=bt.get(n);B==null||B.setReconnectingEdge(e),document.addEventListener("mousemove",z),document.addEventListener("mouseup",M)},[r,e,n,z,M,u,i]);return $r(()=>()=>{if(C.current){document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",M),u(null);let D=bt.get(n);D==null||D.clearReconnectingEdge()}},[n,z,M,u]),{reconnectingHandle:f,cursorPosition:E,hoveredNodeId:g,reconnectingSide:x,reconnectingOffset:b,isValidReconnection:T,handleReconnectStart:V}};import{Fragment as Wc,jsx as Me,jsxs as Xt}from"react/jsx-runtime";var it={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:zc.ArrowClosed},markerEnd:{type:zc.Arrow},data:{label:""}},{MOVE_THRESHOLD:qr,MIN_SEGMENT_LENGTH:Oh,PARALLEL_OFFSET:Fc,MAX_LABEL_DISTANCE:Vh}=Wt;function Hh(e,t,o,n,r){let i=r.find(d=>d.id===t),a=r.find(d=>d.id===o);if((i==null?void 0:i.type)==="GATEWAY"||(a==null?void 0:a.type)==="GATEWAY")return 0;let s=n.filter(d=>d.source===t&&d.target===o||d.source===o&&d.target===t);if(s.length<=1){let d=n.filter(f=>f.source===t);if(d.length<=1)return 0;let u=d.findIndex(f=>f.id===e);if(u<=0)return 0;let m=(d.length-1)/2;return(u-m)*Fc}let l=s.findIndex(d=>d.id===e),c=(s.length-1)/2;return(l-c)*Fc}var Xc=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var $,te,ie,W,oe,le,Z,xe,me,_e;let{zoom:c}=kh(),{updateEdgeData:d}=Lh(),u=Rh(),m=Dh(),{isMultipleSelection:f,isReadOnly:y,mode:E,instanceId:p,edgeHighlight:g}=q(),[h,x]=Gc(!1),[v,b]=Gc(null),N=ps(null),T=ps(n==null?void 0:n.labelOffset),A=ps(null),C=E!=="edit",{reconnectingHandle:P,cursorPosition:R,hoveredNodeId:S,reconnectingSide:L,isValidReconnection:K,handleReconnectStart:j}=Kr({edgeId:e,source:t,target:o,instanceId:p,isReadOnly:C}),Q=Yc(t),z=Yc(o),{sx:M,sy:V,tx:D,ty:I,sourcePos:B,targetPos:G}=us(()=>{var ft,mt;let J=Q&&z?Co(Q,z):{sx:0,sy:0,tx:0,ty:0,sourcePos:Bo.Right,targetPos:Bo.Left},de=s?i:J.sourcePos,re=l?a:J.targetPos,ee=(Ke,he,fe)=>{var Be,gt,Dt,wt,At,Xs;let{x:pe,y:ve}=Ke.internals.positionAbsolute,qe=(Dt=(gt=(Be=Ke.measured)==null?void 0:Be.width)!=null?gt:Ke.width)!=null?Dt:0,ot=(Xs=(At=(wt=Ke.measured)==null?void 0:wt.height)!=null?At:Ke.height)!=null?Xs:0;switch(he){case Bo.Top:return{x:pe+qe*fe,y:ve};case Bo.Bottom:return{x:pe+qe*fe,y:ve+ot};case Bo.Left:return{x:pe,y:ve+ot*fe};case Bo.Right:return{x:pe+qe,y:ve+ot*fe};default:return{x:pe+qe/2,y:ve+ot/2}}},ge=(ft=n==null?void 0:n.sourceOffset)!=null?ft:.5,be=(mt=n==null?void 0:n.targetOffset)!=null?mt:.5,Te=Q?ee(Q,de,ge).x:J.sx,ke=Q?ee(Q,de,ge).y:J.sy,tt=z?ee(z,re,be).x:J.tx,Nt=z?ee(z,re,be).y:J.ty;return P==="source"&&R?(Te=R.x,ke=R.y,L&&(de=L)):P==="target"&&R&&(tt=R.x,Nt=R.y,L&&(re=L)),{sx:Te,sy:ke,tx:tt,ty:Nt,sourcePos:de,targetPos:re}},[Q,z,s,l,i,a,P,R,L,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);Sh(()=>{var re;if(!A.current){A.current={sx:M,sy:V,tx:D,ty:I,sourcePos:B,targetPos:G};return}let J=A.current;if(Math.abs(M-J.sx)>qr||Math.abs(V-J.sy)>qr||Math.abs(D-J.tx)>qr||Math.abs(I-J.ty)>qr||J.sourcePos!==B||J.targetPos!==G){let ee={};(re=n==null?void 0:n.points)!=null&&re.length&&(ee.points=void 0),n!=null&&n.labelOffset&&(ee.labelOffset=void 0),Object.keys(ee).length>0&&d(e,_(_({},n),ee))}A.current={sx:M,sy:V,tx:D,ty:I,sourcePos:B,targetPos:G}},[M,V,D,I,B,G,n,e,d,P]);let k=us(()=>{let J=Hh(e,t,o,u,m);return Ur(M,V,D,I,B,G,n==null?void 0:n.points,J)},[M,V,D,I,B,G,n==null?void 0:n.points,u,m,e,t,o]),O=us(()=>{if(k.length<2)return zr({x:M,y:V},{x:D,y:I});let J=0;for(let ee=0;ee<k.length-1;ee++)J+=Vo(k[ee],k[ee+1]);let de=J/2,re=0;for(let ee=0;ee<k.length-1;ee++){let ge=Vo(k[ee],k[ee+1]);if(re+ge>=de){let be=(de-re)/ge,Te=k[ee],ke=k[ee+1];return{x:Te.x+(ke.x-Te.x)*be,y:Te.y+(ke.y-Te.y)*be}}re+=ge}return zr({x:M,y:V},{x:D,y:I})},[k,M,V,D,I]),Y=Bc((J,de)=>{if(E!=="edit"||de.button!==0)return;de.stopPropagation(),de.preventDefault();let re=k[J],ee=k[J+1],ge=ye(re,ee,"y"),be=ge?re.y:re.x,Te=[...k],ke=Te.length,tt=J,Nt=J+1;b(J);let ft=Ke=>{let he=be+(ge?Ke.clientY-de.clientY:Ke.clientX-de.clientX)/c;N.current=ge?{x:(re.x+ee.x)/2,y:he}:{x:he,y:(re.y+ee.y)/2};let fe=[];for(let pe=1;pe<ke-1;pe++){let ve=Te[pe];pe===tt||pe===Nt?ge?fe.push({x:ve.x,y:he}):fe.push({x:he,y:ve.y}):fe.push(_({},ve))}d(e,w(_({},n),{points:fe}))},mt=()=>{b(null),N.current=null,document.removeEventListener("mousemove",ft),document.removeEventListener("mouseup",mt)};document.addEventListener("mousemove",ft),document.addEventListener("mouseup",mt)},[E,k,c,n,e,d]),F=Bc(J=>{var ft,mt,Ke,he,fe;if(h||C||J.button!==0||!((ft=n==null?void 0:n.label)!=null&&ft.trim()))return;J.stopPropagation(),J.preventDefault();let de=J.clientX,re=J.clientY,ee=(Ke=(mt=n==null?void 0:n.labelOffset)==null?void 0:mt.x)!=null?Ke:0,ge=(fe=(he=n==null?void 0:n.labelOffset)==null?void 0:he.y)!=null?fe:0,be=[...k],Te={x:O.x,y:O.y},ke=!1,tt=pe=>{let ve=(pe.clientX-de)/c,qe=(pe.clientY-re)/c;if(!ke&&Math.abs(ve)<3&&Math.abs(qe)<3)return;ke=!0;let ot={x:ee+ve,y:ge+qe};T.current=ot,d(e,w(_({},n),{labelOffset:ot}))},Nt=()=>{document.removeEventListener("mousemove",tt),document.removeEventListener("mouseup",Nt);let pe=T.current;if(!pe)return;let ve={x:Te.x+pe.x,y:Te.y+pe.y};kc(ve,be)>Vh&&(T.current=void 0,d(e,w(_({},n),{labelOffset:void 0})))};document.addEventListener("mousemove",tt),document.addEventListener("mouseup",Nt)},[h,C,c,n,e,d,k,O]);if(!Q||!z)return null;let U=Vc(k),X=g&&(r||Q.selected||z.selected);return Xt(Wc,{children:[Xt("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":X}),onDoubleClick:()=>!C&&x(!0),children:[Me("path",{d:U,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),className:H({"nopan nodrag":!h&&!C&&!!(($=n==null?void 0:n.label)!=null&&$.trim())}),style:{pointerEvents:"stroke",cursor:!h&&!C&&((te=n==null?void 0:n.label)!=null&&te.trim())?"move":"pointer"},onMouseDown:F}),Xt("g",{className:H("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!y,"text-blue-500 group-hover:text-blue-600":X}),children:[Me(Mh,{id:e,path:U,interactionWidth:0,markerEnd:`url(#${X?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75",{"group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]":!y,"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||P&&S&&!K,"stroke-green-500":P&&S&&K,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":X&&!(n!=null&&n.hasError)&&!P})}),r&&!f&&!C&&Me("g",{children:k.slice(0,-1).map((J,de)=>{let re=k[de+1];if(de===0||de===k.length-2||Vo(J,re)<Oh)return null;let ee=ye(J,re,"y"),ge=v===de,be=ge&&N.current?N.current:zr(J,re);return Xt("g",{children:[Me("line",{x1:J.x,y1:J.y,x2:re.x,y2:re.y,stroke:"transparent",strokeWidth:20/c,className:H("cursor-pointer",{"cursor-ns-resize":ee,"cursor-ew-resize":!ee}),onMouseDown:Te=>Y(de,Te)}),Me("circle",{cx:be.x,cy:be.y,r:4/c,fill:ge?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Me("circle",{cx:be.x,cy:be.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:ge?.6:.3,className:"pointer-events-none"})]},de)})})]})]}),Xt(Ph,{children:[Me("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${O.x}px, ${O.y}px)`},children:r&&!f&&Me(Do,{sx:M,sy:V,tx:D,ty:I,hasLabel:!!((ie=n==null?void 0:n.label)!=null&&ie.trim()),children:Me(Ro,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:Q,targetNode:z})})}),(h||((W=n==null?void 0:n.label)==null?void 0:W.trim()))&&Me("div",{className:H("absolute nodrag nopan",!h&&!C&&((oe=n==null?void 0:n.label)!=null&&oe.trim())?"z-[10001] pointer-events-auto":"z-[3000] pointer-events-none"),style:{transform:`translate(-50%, -50%) translate(${O.x+((Z=(le=n==null?void 0:n.labelOffset)==null?void 0:le.x)!=null?Z:0)}px, ${O.y+((me=(xe=n==null?void 0:n.labelOffset)==null?void 0:xe.y)!=null?me:0)}px)`,cursor:!h&&!C&&((_e=n==null?void 0:n.label)!=null&&_e.trim())?"move":void 0},onMouseDown:!h&&!C?F:void 0,onDoubleClick:J=>{C||(J.stopPropagation(),x(!0))},children:Me(De,{value:n==null?void 0:n.label,className:H("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":h,"pointer-events-none":!h}),isEditing:h,onBlur:()=>x(!1),onChange:J=>d(e,{label:J.trim()})})}),r&&!f&&!C&&Xt(Wc,{children:[Me("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${k[0].x}px, ${k[0].y}px)`},children:Xt("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Me("circle",{cx:6/c,cy:6/c,r:4/c,fill:P==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Me("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:P==="source"?.6:.3,className:"pointer-events-none"}),Me("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!P||P!=="source","cursor-not-allowed":P==="source"&&S&&!K,"cursor-grabbing":P==="source"&&(!S||K)}),onMouseDown:J=>j("source",J.nativeEvent)})]})}),Me("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${k[k.length-1].x}px, ${k[k.length-1].y}px)`},children:Xt("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Me("circle",{cx:6/c,cy:6/c,r:4/c,fill:P==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Me("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:P==="target"?.6:.3,className:"pointer-events-none"}),Me("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!P||P!=="target","cursor-not-allowed":P==="target"&&S&&!K,"cursor-grabbing":P==="target"&&(!S||K)}),onMouseDown:J=>j("target",J.nativeEvent)})]})})]})]})]})};import{Position as Pt}from"@xyflow/react";var Gh={right:Pt.Right,left:Pt.Left,top:Pt.Top,bottom:Pt.Bottom},Zr=e=>{var t;return(t=Gh[e!=null?e:""])!=null?t:Pt.Right},fs=(e,t,o=.5)=>{var l,c,d,u;let{x:n,y:r}=e.internals.positionAbsolute,i=(c=(l=e.measured)==null?void 0:l.width)!=null?c:0,a=(u=(d=e.measured)==null?void 0:d.height)!=null?u:0;switch(Zr(t)){case Pt.Right:return{x:n+i,y:r+a*o};case Pt.Left:return{x:n,y:r+a*o};case Pt.Top:return{x:n+i*o,y:r};case Pt.Bottom:return{x:n+i*o,y:r+a};default:return{x:n+i/2,y:r+a/2}}},Uc=(e,t,o)=>{var d,u;let{position:{x:n,y:r},measured:i}=e,a=(d=i.width)!=null?d:0,s=(u=i.height)!=null?u:0;return[{id:"left",x:n,y:r+s/2},{id:"right",x:n+a,y:r+s/2},{id:"top",x:n+a/2,y:r},{id:"bottom",x:n+a/2,y:r+s}].reduce((m,f)=>{let y=Math.hypot(t-m.x,o-m.y);return Math.hypot(t-f.x,o-f.y)<y?f:m}).id};import{useDebouncedCallback as R0}from"use-debounce";import{useReactFlow as k0}from"@xyflow/react";import{useCallback as lu}from"react";var Nn=(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))(Nn||{});var wn=1,$c=e=>`<mxGraphModel>
5
+ `).trim();t&&N.length>t&&(N=N.substring(0,t)),b.currentTarget.innerText=N,s==null||s(),N!==e&&(a==null||a(N))};return Vc("div",{className:H("flex-1 p-2 self-stretch flex items-center justify-center border border-transparent overflow-hidden text-ellipsis body-medium-400 text-center rounded-sm",{"border border-dashed border-grey-400 bg-white shadow-md":m,"bg-white":e.length>0},n),style:o,onDoubleClick:u,children:Vc("div",{ref:p,className:H("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":m}),contentEditable:m,suppressContentEditableWarning:!0,onKeyDown:g,onPaste:h,onInput:x,onBlur:T,children:e})})};import{Position as jA}from"@xyflow/react";var ye=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,Go=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),Yr=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),_h=(e,t,o)=>{let n=o.x-t.x,r=o.y-t.y,i=n*n+r*r;if(i===0)return Go(e,t);let a=Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*r)/i));return Go(e,{x:t.x+a*n,y:t.y+a*r})},Hc=(e,t)=>{let o=1/0;for(let n=0;n<t.length-1;n++)o=Math.min(o,_h(e,t[n],t[n+1]));return o};import{Position as Fr}from"@xyflow/react";var Xt={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15,MAX_LABEL_DISTANCE:80};var{TOLERANCE:ce}=Xt;function bh(e,t,o){return ye(e,t,"x",ce)&&ye(t,o,"x",ce)&&ye(e,o,"x",ce)}function Th(e,t,o){return ye(e,t,"y",ce)&&ye(t,o,"y",ce)&&ye(e,o,"y",ce)}function vh(e,t,o){if(!bh(e,t,o))return!1;let n=t.y-e.y,r=o.y-t.y;return Math.abs(n)<ce||Math.abs(r)<ce?!1:n*r<0}function Nh(e,t,o){if(!Th(e,t,o))return!1;let n=t.x-e.x,r=o.x-t.x;return Math.abs(n)<ce||Math.abs(r)<ce?!1:n*r<0}function wh(e,t,o,n){let r=t.x!==0,i=t.x===-n.x&&t.y===-n.y,a=t.x===n.x&&t.y===n.y,s=120;if(i)if(r){if((o.x-e.x)*t.x>=0)return[{x:(e.x+o.x)/2,y:e.y},{x:(e.x+o.x)/2,y:o.y}];{let l=(e.y+o.y)/2,c=Math.abs(e.y-o.y)<s?Math.max(e.y,o.y)+s:l;return[{x:e.x,y:c},{x:o.x,y:c}]}}else{if((o.y-e.y)*t.y>=0)return[{x:e.x,y:(e.y+o.y)/2},{x:o.x,y:(e.y+o.y)/2}];{let l=(e.x+o.x)/2,c=Math.abs(e.x-o.x)<s?Math.max(e.x,o.x)+s:l;return[{x:c,y:e.y},{x:c,y:o.y}]}}else if(a)if(r)if((o.x-e.x)*t.x>0&&Math.abs(e.y-o.y)<s){let l=Math.max(e.y,o.y)+s,c=o.x+t.x*(s/2);return[{x:e.x,y:l},{x:c,y:l},{x:c,y:o.y}]}else{let l=t.x>0?Math.max(e.x,o.x):Math.min(e.x,o.x);return[{x:l,y:e.y},{x:l,y:o.y}]}else if((o.y-e.y)*t.y>0&&Math.abs(e.x-o.x)<s){let l=Math.max(e.x,o.x)+s,c=o.y+t.y*(s/2);return[{x:l,y:e.y},{x:l,y:c},{x:o.x,y:c}]}else{let l=t.y>0?Math.max(e.y,o.y):Math.min(e.y,o.y);return[{x:e.x,y:l},{x:o.x,y:l}]}else{let l=t.x!==0?o.x:e.x,c=t.y!==0?o.y:e.y,d=t.x!==0?(l-e.x)*t.x:(c-e.y)*t.y,p=n.x!==0?(l-o.x)*n.x:(c-o.y)*n.y;return d>=0&&p>=0?[{x:l,y:c}]:r?[{x:e.x,y:o.y}]:[{x:o.x,y:e.y}]}}function Gc(e){if(e.length<=2)return e;let t=[e[0]];for(let o=1;o<e.length-1;o++){let n=t[t.length-1],r=e[o],i=e[o+1];ye(n,r,"x",ce)&&ye(r,i,"x",ce)||ye(n,r,"y",ce)&&ye(r,i,"y",ce)||t.push(r)}return t.push(e[e.length-1]),t}function Wr(e){let t=[];for(let o of e){let n=t[t.length-1];(!n||Math.abs(n.x-o.x)>=ce||Math.abs(n.y-o.y)>=ce)&&t.push(o)}return t}function Ih(e){let t=[...e],o=!0;for(;o;){o=!1;for(let n=1;n<t.length-1;n++){let r=t[n-1],i=t[n],a=t[n+1];if(vh(r,i,a)||Nh(r,i,a)){t.splice(n,1),o=!0;break}}}return t}function Bc(e){let t=Wr(Gc([...e]));return t=Ih(t),Wr(Gc(t))}function Xr(e){switch(e){case Fr.Left:return{x:-1,y:0};case Fr.Right:return{x:1,y:0};case Fr.Top:return{x:0,y:-1};case Fr.Bottom:return{x:0,y:1};default:return{x:0,y:0}}}function zc(e,t,o,n){let r=Xt.OFFSET,i=Xt.OFFSET;if(t.x===-n.x&&t.y===-n.y)if(t.x!==0){let a=(o.x-e.x)*t.x;a>0&&a<2*Xt.OFFSET&&(r=a/2,i=a/2)}else{let a=(o.y-e.y)*t.y;a>0&&a<2*Xt.OFFSET&&(r=a/2,i=a/2)}return{sourceOffset:r,targetOffset:i}}function Ah(e,t,o,n,r,i,a=0){let s=Xr(r),l=Xr(i),c=s.x===0?a:0,d=s.y===0?a:0,p=l.x===0?a:0,f=l.y===0?a:0,m={x:e+c,y:t+d},y={x:o+p,y:n+f},{sourceOffset:E,targetOffset:u}=zc(m,s,y,l),g={x:m.x+s.x*E,y:m.y+s.y*E},h={x:y.x+l.x*u,y:y.y+l.y*u},x=wh(g,s,h,l),T=[m,g,...x,h,y],b=Bc(T);if(b.length===2&&Ur(m,y)>ce){let N=ye(m,g,"x",ce)&&ye(g,h,"x",ce)&&ye(h,y,"x",ce),v=ye(m,g,"y",ce)&&ye(g,h,"y",ce)&&ye(h,y,"y",ce);if(N||v){let I=v&&(h.x-g.x)*s.x<0,C=N&&(h.y-g.y)*s.y<0;if(!I&&!C)return Wr([m,g,h,y])}}return b}function $r(e,t,o,n,r,i,a,s=0){if(!(a!=null&&a.length))return Ah(e,t,o,n,r,i,s);let l=Xr(r),c=Xr(i),d=l.x===0?s:0,p=l.y===0?s:0,f=c.x===0?s:0,m=c.y===0?s:0,y={x:e+d,y:t+p},E={x:o+f,y:n+m},{sourceOffset:u,targetOffset:g}=zc(y,l,E,c),h={x:y.x+l.x*u,y:y.y+l.y*u},x={x:E.x+c.x*g,y:E.y+c.y*g},T=[...a],b=T[0],N=l.y===0;N&&Math.abs(y.y-b.y)>ce?T.unshift({x:b.x,y:y.y}):!N&&Math.abs(y.x-b.x)>ce&&T.unshift({x:y.x,y:b.y});let v=T[T.length-1],I=c.y===0,C=[];(Math.abs(v.x-x.x)>ce||Math.abs(v.y-x.y)>ce)&&(I?C.push({x:x.x,y:v.y}):C.push({x:v.x,y:x.y})),C.push(x);let P=[y,...T,...C,E],R=Bc(P);if(R.length===2&&Ur(y,E)>ce){let S=ye(y,h,"x",ce)&&ye(h,x,"x",ce)&&ye(x,E,"x",ce),L=ye(y,h,"y",ce)&&ye(h,x,"y",ce)&&ye(x,E,"y",ce);if(S||L){let K=L&&(x.x-h.x)*l.x<0,j=S&&(x.y-h.y)*l.y<0;if(!K&&!j)return Wr([y,h,x,E])}}return R}var Ur=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Ch(e,t,o){return ye(e,t,"x",ce)&&ye(t,o,"x",ce)||ye(e,t,"y",ce)&&ye(t,o,"y",ce)}function Sh(e,t,o,n){if(Ch(e,t,o))return`L${t.x} ${t.y}`;let r=Ur(e,t),i=Ur(t,o),a=Math.min(r/2,i/2,n);if(a<1)return`L${t.x} ${t.y}`;let s=e.x-t.x,l=e.y-t.y,c=o.x-t.x,d=o.y-t.y,p={x:s/r,y:l/r},f={x:c/i,y:d/i},m={x:t.x+p.x*a,y:t.y+p.y*a},y={x:t.x+f.x*a,y:t.y+f.y*a},E=-p.x,u=-p.y,g=f.x,h=f.y,T=E*h-u*g>0?1:0;return`L${m.x} ${m.y}A${a} ${a} 0 0 ${T} ${y.x} ${y.y}`}var Yc=(e,t=5)=>e.length<2?"":e.reduce((o,n,r)=>{let i="";return r>0&&r<e.length-1?i=Sh(e[r-1],n,e[r+1],t):i=`${r===0?"M":"L"}${n.x} ${n.y}`,o+=i,o},"");import{useCallback as Bo,useEffect as Kr,useRef as wn,useState as zo}from"react";import{useReactFlow as Mh,useStore as Ph}from"@xyflow/react";var Lh=50,Fc=.1,kh=.6,qr=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:a,getNodes:s,getEdge:l,screenToFlowPosition:c}=Mh(),{setIsDragging:d,setReconnectingEdgeId:p}=q(),f=Ph(D=>D.isValidConnection),[m,y]=zo(null),[E,u]=zo(null),[g,h]=zo(null),[x,T]=zo(null),[b,N]=zo(null),[v,I]=zo(!1),C=wn(null),P=wn(null),R=wn(null),S=wn(t),L=wn(o);Kr(()=>{S.current=t,L.current=o},[t,o]),Kr(()=>{C.current=m},[m]),Kr(()=>{P.current=b},[b]);let K=Bo(D=>{let A=s(),B=A.find(Y=>Y.id===D);if(!B)return{x:0,y:0};let G=B.position.x,k=B.position.y,O=B.parentId;for(;O;){let Y=A.find(F=>F.id===O);if(!Y)break;G+=Y.position.x,k+=Y.position.y,O=Y.parentId}return{x:G,y:k}},[s]),j=Bo(D=>{var O,Y,F,U,X,$;let A=s(),B=null,G=Lh,k=A.filter(te=>te.type!=="LANE"&&te.type!=="ANNOTATION");for(let te of k){if(te.id===e)continue;let ie=K(te.id),W=(F=(Y=(O=te.measured)==null?void 0:O.width)!=null?Y:te.width)!=null?F:0,oe=($=(X=(U=te.measured)==null?void 0:U.height)!=null?X:te.height)!=null?$:0;if(D.x>=ie.x&&D.x<=ie.x+W&&D.y>=ie.y&&D.y<=ie.y+oe)return te.id;let Z=Math.max(ie.x-D.x,0,D.x-(ie.x+W)),xe=Math.max(ie.y-D.y,0,D.y-(ie.y+oe)),me=Math.sqrt(Z*Z+xe*xe);me<G&&(G=me,B=te.id)}return B},[s,K,e]),Q=Bo((D,A)=>{var Z,xe,me,_e,J,de;let B=a(D);if(!B)return null;let G=K(D),k=(me=(xe=(Z=B.measured)==null?void 0:Z.width)!=null?xe:B.width)!=null?me:0,O=(de=(J=(_e=B.measured)==null?void 0:_e.height)!=null?J:B.height)!=null?de:0,Y=Math.abs(G.x+k-A.x),F=Math.abs(A.x-G.x),U=Math.abs(G.y+O-A.y),X=Math.abs(A.y-G.y),$={right:Y,left:F,bottom:U,top:X},te=Object.entries($).reduce((re,[ee,ge])=>ge<re[1]?[ee,ge]:re,["right",$.right])[0],ie=R.current;if(ie&&ie!==te){let re=$[te],ee=$[ie],ge=Math.abs(ee-re),be=Math.min(Math.abs(ee),Math.abs(re));ge<be*kh&&(te=ie)}let W=te,oe,le;if(W==="right"||W==="left"){let ee=(Math.max(G.y,Math.min(G.y+O,A.y))-G.y)/(O||1);Math.abs(ee-.5)<Fc&&(ee=.5),le=ee,oe={x:W==="right"?G.x+k:G.x,y:G.y+le*O}}else{let ee=(Math.max(G.x,Math.min(G.x+k,A.x))-G.x)/(k||1);Math.abs(ee-.5)<Fc&&(ee=.5),le=ee,oe={x:G.x+le*k,y:W==="bottom"?G.y+O:G.y}}return{side:W,snapPosition:oe,offset:le}},[a,K]),z=Bo(D=>{var F,U,X;let A=C.current;if(!A)return;let B=c({x:D.clientX,y:D.clientY}),G=j(B);h(G);let k=B,O=null,Y=null;if(G){let $=Q(G,B);$&&(O=$.side,k=$.snapPosition,Y=$.offset,R.current=O);let te=l(e),ie={source:A==="source"?G:S.current,target:A==="target"?G:L.current,sourceHandle:A==="source"?O:(F=te==null?void 0:te.sourceHandle)!=null?F:null,targetHandle:A==="target"?O:(U=te==null?void 0:te.targetHandle)!=null?U:null},W=(X=f==null?void 0:f(ie))!=null?X:!0;I(W)}else R.current=null,I(!1);T(O),N(Y),u(k)},[j,Q,l,e,c,f]),M=Bo(D=>{var O,Y,F,U,X;let A=C.current;if(!A)return;let B=c({x:D.clientX,y:D.clientY}),G=j(B);if(G){let $=Q(G,B),te=(O=$==null?void 0:$.side)!=null?O:null,ie=(Y=$==null?void 0:$.offset)!=null?Y:.5,W=l(e),oe={source:A==="source"?G:S.current,target:A==="target"?G:L.current,sourceHandle:A==="source"?te:(F=W==null?void 0:W.sourceHandle)!=null?F:null,targetHandle:A==="target"?te:(U=W==null?void 0:W.targetHandle)!=null?U:null};((X=f==null?void 0:f(oe))==null||X)&&i(le=>le.map(Z=>{var xe,me;return Z.id===e?w(_({},Z),{source:oe.source,target:oe.target,sourceHandle:oe.sourceHandle,targetHandle:oe.targetHandle,data:w(_({},Z.data),{points:void 0,sourceOffset:A==="source"?ie:(xe=Z.data)==null?void 0:xe.sourceOffset,targetOffset:A==="target"?ie:(me=Z.data)==null?void 0:me.targetOffset})}):Z}))}y(null),u(null),h(null),T(null),N(null),d(!1),I(!1),p(null),R.current=null,document.removeEventListener("mouseup",M),document.removeEventListener("mousemove",z);let k=Tt.get(n);k==null||k.clearReconnectingEdge()},[e,j,Q,l,i,n,z,f,c,d,p]),V=Bo((D,A)=>{if(r||A.button!==0)return;A.stopPropagation(),A.preventDefault(),i(G=>G.map(k=>k.id===e?w(_({},k),{data:w(_({},k.data),{points:void 0})}):k)),y(D),p(e);let B=Tt.get(n);B==null||B.setReconnectingEdge(e),document.addEventListener("mousemove",z),document.addEventListener("mouseup",M)},[r,e,n,z,M,p,i]);return Kr(()=>()=>{if(C.current){document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",M),p(null);let D=Tt.get(n);D==null||D.clearReconnectingEdge()}},[n,z,M,p]),{reconnectingHandle:m,cursorPosition:E,hoveredNodeId:g,reconnectingSide:x,reconnectingOffset:b,isValidReconnection:v,handleReconnectStart:V}};import{Fragment as qc,jsx as Me,jsxs as Ut}from"react/jsx-runtime";var st={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:Uc.ArrowClosed},markerEnd:{type:Uc.Arrow},data:{label:""}},{MOVE_THRESHOLD:Zr,MIN_SEGMENT_LENGTH:zh,PARALLEL_OFFSET:Kc,MAX_LABEL_DISTANCE:Yh}=Xt;function Fh(e,t,o,n,r){let i=r.find(d=>d.id===t),a=r.find(d=>d.id===o);if((i==null?void 0:i.type)==="GATEWAY"||(a==null?void 0:a.type)==="GATEWAY")return 0;let s=n.filter(d=>d.source===t&&d.target===o||d.source===o&&d.target===t);if(s.length<=1){let d=n.filter(m=>m.source===t);if(d.length<=1)return 0;let p=d.findIndex(m=>m.id===e);if(p<=0)return 0;let f=(d.length-1)/2;return(p-f)*Kc}let l=s.findIndex(d=>d.id===e),c=(s.length-1)/2;return(l-c)*Kc}var Zc=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var $,te,ie,W,oe,le,Z,xe,me,_e;let{zoom:c}=Hh(),{updateEdgeData:d}=Vh(),p=Gh(),f=Bh(),{isMultipleSelection:m,isReadOnly:y,mode:E,instanceId:u,edgeHighlight:g}=q(),[h,x]=Wc(!1),[T,b]=Wc(null),N=ms(null),v=ms(n==null?void 0:n.labelOffset),I=ms(null),C=E!=="edit",{reconnectingHandle:P,cursorPosition:R,hoveredNodeId:S,reconnectingSide:L,isValidReconnection:K,handleReconnectStart:j}=qr({edgeId:e,source:t,target:o,instanceId:u,isReadOnly:C}),Q=$c(t),z=$c(o),{sx:M,sy:V,tx:D,ty:A,sourcePos:B,targetPos:G}=fs(()=>{var mt,gt;let J=Q&&z?Mo(Q,z):{sx:0,sy:0,tx:0,ty:0,sourcePos:Yo.Right,targetPos:Yo.Left},de=s?i:J.sourcePos,re=l?a:J.targetPos,ee=(qe,he,fe)=>{var Ye,ht,Ot,It,At,Zs;let{x:pe,y:ve}=qe.internals.positionAbsolute,Ze=(Ot=(ht=(Ye=qe.measured)==null?void 0:Ye.width)!=null?ht:qe.width)!=null?Ot:0,nt=(Zs=(At=(It=qe.measured)==null?void 0:It.height)!=null?At:qe.height)!=null?Zs:0;switch(he){case Yo.Top:return{x:pe+Ze*fe,y:ve};case Yo.Bottom:return{x:pe+Ze*fe,y:ve+nt};case Yo.Left:return{x:pe,y:ve+nt*fe};case Yo.Right:return{x:pe+Ze,y:ve+nt*fe};default:return{x:pe+Ze/2,y:ve+nt/2}}},ge=(mt=n==null?void 0:n.sourceOffset)!=null?mt:.5,be=(gt=n==null?void 0:n.targetOffset)!=null?gt:.5,Te=Q?ee(Q,de,ge).x:J.sx,Re=Q?ee(Q,de,ge).y:J.sy,ot=z?ee(z,re,be).x:J.tx,wt=z?ee(z,re,be).y:J.ty;return P==="source"&&R?(Te=R.x,Re=R.y,L&&(de=L)):P==="target"&&R&&(ot=R.x,wt=R.y,L&&(re=L)),{sx:Te,sy:Re,tx:ot,ty:wt,sourcePos:de,targetPos:re}},[Q,z,s,l,i,a,P,R,L,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);Rh(()=>{var re;if(!I.current){I.current={sx:M,sy:V,tx:D,ty:A,sourcePos:B,targetPos:G};return}let J=I.current;if(Math.abs(M-J.sx)>Zr||Math.abs(V-J.sy)>Zr||Math.abs(D-J.tx)>Zr||Math.abs(A-J.ty)>Zr||J.sourcePos!==B||J.targetPos!==G){let ee={};(re=n==null?void 0:n.points)!=null&&re.length&&(ee.points=void 0),n!=null&&n.labelOffset&&(ee.labelOffset=void 0),Object.keys(ee).length>0&&d(e,_(_({},n),ee))}I.current={sx:M,sy:V,tx:D,ty:A,sourcePos:B,targetPos:G}},[M,V,D,A,B,G,n,e,d,P]);let k=fs(()=>{let J=Fh(e,t,o,p,f);return $r(M,V,D,A,B,G,n==null?void 0:n.points,J)},[M,V,D,A,B,G,n==null?void 0:n.points,p,f,e,t,o]),O=fs(()=>{if(k.length<2)return Yr({x:M,y:V},{x:D,y:A});let J=0;for(let ee=0;ee<k.length-1;ee++)J+=Go(k[ee],k[ee+1]);let de=J/2,re=0;for(let ee=0;ee<k.length-1;ee++){let ge=Go(k[ee],k[ee+1]);if(re+ge>=de){let be=(de-re)/ge,Te=k[ee],Re=k[ee+1];return{x:Te.x+(Re.x-Te.x)*be,y:Te.y+(Re.y-Te.y)*be}}re+=ge}return Yr({x:M,y:V},{x:D,y:A})},[k,M,V,D,A]),Y=Xc((J,de)=>{if(E!=="edit"||de.button!==0)return;de.stopPropagation(),de.preventDefault();let re=k[J],ee=k[J+1],ge=ye(re,ee,"y"),be=ge?re.y:re.x,Te=[...k],Re=Te.length,ot=J,wt=J+1;b(J);let mt=qe=>{let he=be+(ge?qe.clientY-de.clientY:qe.clientX-de.clientX)/c;N.current=ge?{x:(re.x+ee.x)/2,y:he}:{x:he,y:(re.y+ee.y)/2};let fe=[];for(let pe=1;pe<Re-1;pe++){let ve=Te[pe];pe===ot||pe===wt?ge?fe.push({x:ve.x,y:he}):fe.push({x:he,y:ve.y}):fe.push(_({},ve))}d(e,w(_({},n),{points:fe}))},gt=()=>{b(null),N.current=null,document.removeEventListener("mousemove",mt),document.removeEventListener("mouseup",gt)};document.addEventListener("mousemove",mt),document.addEventListener("mouseup",gt)},[E,k,c,n,e,d]),F=Xc(J=>{var mt,gt,qe,he,fe;if(h||C||J.button!==0||!((mt=n==null?void 0:n.label)!=null&&mt.trim()))return;J.stopPropagation(),J.preventDefault();let de=J.clientX,re=J.clientY,ee=(qe=(gt=n==null?void 0:n.labelOffset)==null?void 0:gt.x)!=null?qe:0,ge=(fe=(he=n==null?void 0:n.labelOffset)==null?void 0:he.y)!=null?fe:0,be=[...k],Te={x:O.x,y:O.y},Re=!1,ot=pe=>{let ve=(pe.clientX-de)/c,Ze=(pe.clientY-re)/c;if(!Re&&Math.abs(ve)<3&&Math.abs(Ze)<3)return;Re=!0;let nt={x:ee+ve,y:ge+Ze};v.current=nt,d(e,w(_({},n),{labelOffset:nt}))},wt=()=>{document.removeEventListener("mousemove",ot),document.removeEventListener("mouseup",wt);let pe=v.current;if(!pe)return;let ve={x:Te.x+pe.x,y:Te.y+pe.y};Hc(ve,be)>Yh&&(v.current=void 0,d(e,w(_({},n),{labelOffset:void 0})))};document.addEventListener("mousemove",ot),document.addEventListener("mouseup",wt)},[h,C,c,n,e,d,k,O]);if(!Q||!z)return null;let U=Yc(k),X=g&&(r||Q.selected||z.selected);return Ut(qc,{children:[Ut("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":X}),onDoubleClick:()=>!C&&x(!0),children:[Me("path",{d:U,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),className:H({"nopan nodrag":!h&&!C&&!!(($=n==null?void 0:n.label)!=null&&$.trim())}),style:{pointerEvents:"stroke",cursor:!h&&!C&&((te=n==null?void 0:n.label)!=null&&te.trim())?"move":"pointer"},onMouseDown:F}),Ut("g",{className:H("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!y,"text-blue-500 group-hover:text-blue-600":X}),children:[Me(Dh,{id:e,path:U,interactionWidth:0,markerEnd:`url(#${X?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75",{"group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]":!y,"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||P&&S&&!K,"stroke-green-500":P&&S&&K,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":X&&!(n!=null&&n.hasError)&&!P})}),r&&!m&&!C&&Me("g",{children:k.slice(0,-1).map((J,de)=>{let re=k[de+1];if(de===0||de===k.length-2||Go(J,re)<zh)return null;let ee=ye(J,re,"y"),ge=T===de,be=ge&&N.current?N.current:Yr(J,re);return Ut("g",{children:[Me("line",{x1:J.x,y1:J.y,x2:re.x,y2:re.y,stroke:"transparent",strokeWidth:20/c,className:H("cursor-pointer",{"cursor-ns-resize":ee,"cursor-ew-resize":!ee}),onMouseDown:Te=>Y(de,Te)}),Me("circle",{cx:be.x,cy:be.y,r:4/c,fill:ge?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Me("circle",{cx:be.x,cy:be.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:ge?.6:.3,className:"pointer-events-none"})]},de)})})]})]}),Ut(Oh,{children:[Me("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${O.x}px, ${O.y}px)`},children:r&&!m&&Me(Vo,{sx:M,sy:V,tx:D,ty:A,hasLabel:!!((ie=n==null?void 0:n.label)!=null&&ie.trim()),children:Me(Oo,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:Q,targetNode:z})})}),(h||((W=n==null?void 0:n.label)==null?void 0:W.trim()))&&Me("div",{className:H("absolute nodrag nopan",!h&&!C&&((oe=n==null?void 0:n.label)!=null&&oe.trim())?"z-[10001] pointer-events-auto":"z-[3000] pointer-events-none"),style:{transform:`translate(-50%, -50%) translate(${O.x+((Z=(le=n==null?void 0:n.labelOffset)==null?void 0:le.x)!=null?Z:0)}px, ${O.y+((me=(xe=n==null?void 0:n.labelOffset)==null?void 0:xe.y)!=null?me:0)}px)`,cursor:!h&&!C&&((_e=n==null?void 0:n.label)!=null&&_e.trim())?"move":void 0},onMouseDown:!h&&!C?F:void 0,onDoubleClick:J=>{C||(J.stopPropagation(),x(!0))},children:Me(Oe,{value:n==null?void 0:n.label,className:H("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":h,"pointer-events-none":!h}),isEditing:h,onBlur:()=>x(!1),onChange:J=>d(e,{label:J.trim()})})}),r&&!m&&!C&&Ut(qc,{children:[Me("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${k[0].x}px, ${k[0].y}px)`},children:Ut("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Me("circle",{cx:6/c,cy:6/c,r:4/c,fill:P==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Me("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:P==="source"?.6:.3,className:"pointer-events-none"}),Me("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!P||P!=="source","cursor-not-allowed":P==="source"&&S&&!K,"cursor-grabbing":P==="source"&&(!S||K)}),onMouseDown:J=>j("source",J.nativeEvent)})]})}),Me("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${k[k.length-1].x}px, ${k[k.length-1].y}px)`},children:Ut("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Me("circle",{cx:6/c,cy:6/c,r:4/c,fill:P==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Me("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:P==="target"?.6:.3,className:"pointer-events-none"}),Me("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!P||P!=="target","cursor-not-allowed":P==="target"&&S&&!K,"cursor-grabbing":P==="target"&&(!S||K)}),onMouseDown:J=>j("target",J.nativeEvent)})]})})]})]})]})};import{Position as Lt}from"@xyflow/react";var Wh={right:Lt.Right,left:Lt.Left,top:Lt.Top,bottom:Lt.Bottom},Jr=e=>{var t;return(t=Wh[e!=null?e:""])!=null?t:Lt.Right},gs=(e,t,o=.5)=>{var l,c,d,p;let{x:n,y:r}=e.internals.positionAbsolute,i=(c=(l=e.measured)==null?void 0:l.width)!=null?c:0,a=(p=(d=e.measured)==null?void 0:d.height)!=null?p:0;switch(Jr(t)){case Lt.Right:return{x:n+i,y:r+a*o};case Lt.Left:return{x:n,y:r+a*o};case Lt.Top:return{x:n+i*o,y:r};case Lt.Bottom:return{x:n+i*o,y:r+a};default:return{x:n+i/2,y:r+a/2}}},Jc=(e,t,o)=>{var d,p;let{position:{x:n,y:r},measured:i}=e,a=(d=i.width)!=null?d:0,s=(p=i.height)!=null?p:0;return[{id:"left",x:n,y:r+s/2},{id:"right",x:n+a,y:r+s/2},{id:"top",x:n+a/2,y:r},{id:"bottom",x:n+a/2,y:r+s}].reduce((f,m)=>{let y=Math.hypot(t-f.x,o-f.y);return Math.hypot(t-m.x,o-m.y)<y?m:f}).id};import{useDebouncedCallback as G0}from"use-debounce";import{useReactFlow as H0}from"@xyflow/react";import{useCallback as fu}from"react";var In=(p=>(p.START_EVENT="start-event",p.END_EVENT_TERMINATE="end-event-terminate",p.TASK="task",p.TASK_SCRIPT="task-script",p.SUBPROCESS="subprocess-collapsed",p.GATEWAY_EXCLUSIVE="gateway-exclusive",p.GATEWAY_PARALLEL="gateway-parallel",p.GATEWAY_COMPLEX="gateway-complex",p.SERVICE_TASK="service-task",p.ANNOTATION="annotation",p.LANE="lane",p))(In||{});var An=1,Qc=e=>`<mxGraphModel>
6
6
  <root version="1.1">
7
7
  <mxCell id="0" />
8
8
  <mxCell id="1" parent="0" />
@@ -35,17 +35,17 @@ var Lp=Object.defineProperty,kp=Object.defineProperties;var Rp=Object.getOwnProp
35
35
  <mxGeometry as="geometry" relative="1" />
36
36
  </mxCell>
37
37
  </root>
38
- </mxGraphModel>`,Kc=(e,t)=>{if(!e.length&&!t.length)return wn;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};import{xml2json as Bh,json2xml as zh}from"xml-js";var qc={compact:!0,spaces:4},Yh=e=>e.replace(/\n/g,"&#xA;");function Jr(e,t=qc){if(e)return JSON.parse(Bh(e,t))}function Zc(e,t=qc){return e?zh(e,w(_({},t),{attributeValueFn:Yh})):""}var Jc={"attribute-loop":"LOOP"},Qc={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS","service-task":"SERVICE_TASK"},jc={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},ed={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed",SERVICE_TASK:"service-task"},td={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var zo=(e,t,o,n,r,i)=>{let a=e._attributes.width||0,s=e._attributes.height||0,l=0,c=0;if(n&&r!==void 0&&i!==void 0){let y=n.split(`
39
- `),E=y.length;l=y.reduce((g,h)=>Math.max(g,h.length),0)*7+r,c=E*20+i}let d=Math.max(Ot(Number(a),t),l),u=Math.max(Ot(Number(s),o),c);return{width:d,height:u,measured:{width:d,height:u}}},Yo=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,parent:r,value:i}=t,a={x:Number(o._attributes.x||0),y:Number(o._attributes.y||0)},s={id:n,position:a,data:{label:i||""}},l=r==="1"?void 0:r;return l&&(s.parentId=l),s},Wh=e=>{let{mxGeometry:t}=e,o=Yo(e),n=zo(t,ue.START_EVENT.MIN_WIDTH,ue.START_EVENT.MIN_HEIGHT);return w(_(_({},o),n),{type:"START_EVENT"})},Xh=e=>{let{mxGeometry:t}=e,o=Yo(e),n=zo(t,ue.END_EVENT.MIN_WIDTH,ue.END_EVENT.MIN_HEIGHT);return w(_(_({},o),n),{type:"END_EVENT"})},Qr=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=Yo(e),s=zo(n,ue.TASK.MIN_WIDTH,ue.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=Jc[d];u&&(r.data.attribute=u)}let c=Qc[o.style];return c&&(r.data.variant=c),w(_(_({},r),s),{type:"TASK"})},ms=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=Yo(e),i=zo(o,ue.GATEWAY.MIN_WIDTH,ue.GATEWAY.MIN_HEIGHT);return r.data.variant=jc[n],w(_(_({},r),i),{type:"GATEWAY"})},Uh=e=>{let{mxGeometry:t}=e,o=Yo(e),i=zo(t,ue.ANNOTATION.MIN_WIDTH,ue.ANNOTATION.MIN_HEIGHT,o.data.label,32,24);return w(_(_({},o),i),{type:"ANNOTATION"})},$h=e=>{let{mxGeometry:t}=e,o=Yo(e),n=zo(t,ue.LANE.MIN_WIDTH,ue.LANE.MIN_HEIGHT);return w(_(_({},o),n),{type:"LANE"})},od={task:Qr,"task-script":Qr,"subprocess-collapsed":Qr,"service-task":Qr,"start-event":Wh,"end-event-terminate":Xh,"gateway-parallel":ms,"gateway-exclusive":ms,"gateway-complex":ms,annotation:Uh,lane:$h},Kh=e=>{if(e&&Array.isArray(e))return e.map(t=>({x:Number(t._attributes.x),y:Number(t._attributes.y)}))},nd=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,source:r,target:i,value:a,style:s,sourceHandle:l,targetHandle:c,sourceOffset:d,targetOffset:u,labelOffsetX:m,labelOffsetY:f}=t,y=Kh(o==null?void 0:o.Array),E=d!==void 0?Number(d):void 0,p=u!==void 0?Number(u):void 0,g=m!==void 0?Number(m):void 0,h=f!==void 0?Number(f):void 0,x=w(_(_({id:n,source:r,target:i},l?{sourceHandle:l}:{}),c?{targetHandle:c}:{}),{data:_(_(_(_({label:a||""},y&&y.length>0?{points:y}:{}),E!==void 0?{sourceOffset:E}:{}),p!==void 0?{targetOffset:p}:{}),g!==void 0&&h!==void 0?{labelOffset:{x:g,y:h}}:{})});return s.includes("association")&&s.includes('endArrow=""')?_(_({},Oo),x):_(_({},it),x)},rd=(e,t)=>{var f,y;let{id:o,type:n,source:r,target:i,sourceHandle:a,targetHandle:s,data:l}=e,c=t==null?void 0:t.find(E=>E.id===r),d="";n==="ANNOTATION_EDGE"&&(d='association;endArrow=""');let u={_attributes:{as:"geometry",relative:"1"}};return l!=null&&l.points&&Array.isArray(l.points)&&l.points.length>0&&(u.Array=l.points.map(E=>({_attributes:{as:"mxPoint",x:E.x,y:E.y}}))),{_attributes:{id:o,parent:(c==null?void 0:c.parentId)||"1",edge:"1",style:d,source:r,target:i,value:(l==null?void 0:l.label)||"",sourceHandle:a!=null?a:void 0,targetHandle:s!=null?s:void 0,sourceOffset:(l==null?void 0:l.sourceOffset)!==void 0?String(l.sourceOffset):void 0,targetOffset:(l==null?void 0:l.targetOffset)!==void 0?String(l.targetOffset):void 0,labelOffsetX:((f=l==null?void 0:l.labelOffset)==null?void 0:f.x)!==void 0?String(l.labelOffset.x):void 0,labelOffsetY:((y=l==null?void 0:l.labelOffset)==null?void 0:y.y)!==void 0?String(l.labelOffset.y):void 0},mxGeometry:u}},Fo=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}}}},qh=e=>{let{variant:t}=e.data,o=Fo(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:ed[t]||"task"})})},Zh=e=>{let t=Fo(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"start-event"})})},Jh=e=>{let t=Fo(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"end-event-terminate"})})},Qh=e=>{let{variant:t}=e.data,o=Fo(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:td[t]})})},jh=e=>{let t=Fo(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"lane"})})},ey=e=>{let t=Fo(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"annotation"})})},id={TASK:qh,START_EVENT:Zh,END_EVENT:Jh,GATEWAY:Qh,ANNOTATION:ey,LANE:jh},sd=(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 ty=e=>{let t=Object.values(Nn),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=od[a],l=s==null?void 0:s(i,n);if(!l){console.warn(`Node ${a} not supported`);continue}r.push(l)}return r},oy=(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=nd(r),a=t.find(c=>c.id===i.source),s=t.find(c=>c.id===i.target);((a==null?void 0:a.type)==="LANE"||(s==null?void 0:s.type)==="LANE")&&i.type!=="ANNOTATION_EDGE"||n.push(i)}return n},ny=(e,t)=>{let o=[];return e.forEach(n=>{var a,s;let r=(s=(a=id)[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=sd(n,t);o.push(l)}}),o},ry=(e,t)=>{let o=[];return e.forEach(n=>{let r=rd(n,t);o.push(r)}),o},iy=(e=[],t=[],o)=>{let n=ny(e,o),r=ry(t,e);return{mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}}},ad=(e=[],t=[],o)=>{let n=iy(e,t,o);return Zc(JSON.stringify(n),{compact:!0,spaces:0})},ld=async e=>{var a,s,l,c,d;let t=await Jr(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)||wn),r=ty(o),i=oy(o,r);return{lastElementId:n,edges:i,nodes:r}};import{useReactFlow as S0,useStoreApi as M0}from"@xyflow/react";import{useCallback as P0}from"react";import{Position as $t,useConnection as $y,useReactFlow as Ky}from"@xyflow/react";import{useCallback as _s}from"react";import{Handle as cd,useReactFlow as sy}from"@xyflow/react";import{jsx as dd}from"react/jsx-runtime";var ne=i=>{var a=i,{type:e,position:t,className:o,nodeType:n}=a,r=ht(a,["type","position","className","nodeType"]);let s=n==="TASK";return dd(cd,_({type:e,position:t,className:H("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":s,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":!s},o)},r))},Ge=s=>{var l=s,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,a=ht(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=sy(),m=(()=>{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 y=d();return f.filter(p=>{if(p.source!==e)return!1;let g=y.find(h=>h.id===p.target);return(g==null?void 0:g.type)!=="ANNOTATION"}).length>=1}return!1})();return dd(cd,_({type:n,position:r,className:H("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":m,"hover:border-grey-500":!m},i),style:{pointerEvents:m?"none":"auto"}},a))};import{useRef as md}from"react";import{NodeResizeControl as gd,ResizeControlVariant as fy,useReactFlow as my,useStoreApi as gy}from"@xyflow/react";import{useStoreApi as ay}from"@xyflow/react";var jr=()=>{let e=ay();return{getInternalNodes:()=>{let{nodeLookup:o}=e.getState();return Array.from(o.values())}}};import ud from"@dagrejs/dagre";import{getNodesBounds as ei}from"@xyflow/react";var ti=(e=[],t=[],o="LR")=>{let n=new ud.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)),ud.layout(n),{nodes:e.map(i=>{let a=n.node(i.id);return w(_({},i),{position:{x:a.x-i.width/2,y:a.y-i.height/2}})}),edges:t}},Ut=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId);if(t.length===0)return e;let o=fa(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){Ea(a,o,r),_a(n,o);continue}Fi(n,i,o)}return ma(e,o)};var fd=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)};var ly=500;var cy=e=>e.type==="LANE"&&!e.parentId,dy=(e,t)=>{let o=e.x+e.width,n=e.y+e.height,r=t.x+t.width,i=t.y+t.height;return e.x<=t.x&&e.y<=t.y&&o>=r&&n>=i},uy=(e,t)=>{let o=e.x+e.width,n=e.y+e.height,r=t.x+t.width,i=t.y+t.height,a=Math.max(e.x-r,t.x-o,0),s=Math.max(e.y-i,t.y-n,0);return Math.hypot(a,s)},py=e=>{let t=new Set;for(let o of e)t.add(o.source),t.add(o.target);return t},pd=(e,t,o)=>{if(e.type!=="ANNOTATION"||o.has(e.id))return!1;let n=ei([e]);return uy(t,n)>ly},gs=(e,t=[])=>{var E;let o=e.filter(cy);if(o.length===0)return e;let n=new Map;for(let p of e){if(!p.parentId)continue;let g=(E=n.get(p.parentId))!=null?E:[];g.push(p.id),n.set(p.parentId,g)}let r=new Set,i=o.map(p=>p.id);for(;i.length>0;){let p=i.pop();if(!p||r.has(p))continue;r.add(p);let g=n.get(p);if(g)for(let h of g)r.has(h)||i.push(h)}let a=e.filter(p=>r.has(p.id));if(a.length===0)return e;let s=py(t),l=a.filter(p=>p.type!=="ANNOTATION"),c=ei(l.length>0?l:a),d=a.filter(p=>!pd(p,c,s)),u=ei(d),y=e.filter(p=>!r.has(p.id)).filter(p=>{let g=ei([p]);return!dy(u,g)}).filter(p=>!pd(p,u,s));return[...d,...y]};import{Fragment as xy,jsxs as Ey}from"react/jsx-runtime";import{createElement as hd}from"react";var hy=["top","right","bottom","left"],yy=["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=ht(i,["nodeId","isVisible","offset"]);let{getInternalNode:a,setNodes:s}=my(),{getInternalNodes:l}=jr(),{isMultipleSelection:c}=q(),d=gy(),u=md(0),m=md([]),f=({y:g,width:h,height:x})=>{cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{var j,Q;if(!e)return;let{nodeLookup:v,onNodesChange:b}=d.getState(),N=v.get(e);if(!N||N.type!=="LANE")return;let T=!N.parentId,A=T?N.id:N.parentId;if(!A)return;let C=Array.from(v.values()).filter(z=>z.type==="LANE"&&z.parentId===A);if(!C.length)return;m.current.length===0&&(m.current=ro(C).map(z=>z.id));let P=m.current.map(z=>C.find(M=>M.id===z)).filter(Boolean),R=[],S=0,L=P.findIndex(z=>z.id===N.id),K=!T&&L>0&&Math.abs(g-N.position.y)>.5;for(let z=0;z<P.length;z++){let M=P[z],V=M.id===N.id,D=z===P.length-1;if(V){S=K?g+x:S+x;continue}let I=(Q=(j=M.measured)==null?void 0:j.height)!=null?Q:0,B=T?h-se.HEADER_WIDTH:h,G=I;T&&D&&(G=Math.max(se.MIN_HEIGHT,x-S)),K&&z===L-1&&(G=Math.max(se.MIN_HEIGHT,g-S)),R.push({id:M.id,type:"dimensions",dimensions:{width:B,height:G},setAttributes:!0}),R.push({id:M.id,type:"position",position:{x:se.HEADER_WIDTH,y:S}}),S+=G}T?R.push({id:A,type:"dimensions",dimensions:{width:h,height:x},setAttributes:!0}):R.push({id:A,type:"dimensions",dimensions:{width:h+se.HEADER_WIDTH,height:S},setAttributes:!0}),b==null||b(R)})},y=({y:g,width:h,height:x})=>{var N;if(cancelAnimationFrame(u.current),m.current=[],!e)return;let v=a(e);if(!v||v.type!=="LANE"&&!v.parentId)return;let b=[...l()];if(v.type!=="LANE"){b=b.map(T=>T.id===e?w(_({},T),{width:h,height:x,measured:{width:h,height:x}}):T),b=Ut(b),s(b);return}b=ba(v,h,x,b,g),b=Ut(b),b=no((N=v.parentId)!=null?N:v.id,b),s(b)};if(!(!c&&t))return null;let p={"--resize-offset":`${o}px`};return Ey(xy,{children:[hy.map(g=>hd(gd,w(_({},n),{key:g,nodeId:e,position:g,variant:fy.Line,className:"border-blue-400/90 border-dashed",style:p,onResize:(h,x)=>f(x),onResizeEnd:(h,x)=>y(x)}))),yy.map(g=>hd(gd,w(_({},n),{key:g,nodeId:e,position:g,className:"size-1.5 bg-blue-400 relative before:content-[''] before:absolute before:w-5 before:h-5 before:left-1/2 before:top-1/2 before:-translate-x-1/2 before:-translate-y-1/2 before:cursor-[inherit]",style:p,onResize:(h,x)=>f(x),onResizeEnd:(h,x)=>y(x)})))]})};import{NodeToolbar as Vy,useReactFlow as Hy}from"@xyflow/react";import{Button as Gy,Tooltip as By,TooltipContent as zy,TooltipTrigger as Yy,useTranslation as Fy}from"@produto-lecom/lecom-ui";import{useCallback as Es,useEffect as Wy,useRef as oi,useState as Xy}from"react";import{create as _y}from"zustand";var Wo=_y(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{useEffect as by,useState as Ty}from"react";var yd=(e,t=!1)=>{let[o,n]=Ty({width:0,height:0});return by(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};import{Position as An,useReactFlow as vy}from"@xyflow/react";import{useMemo as Ny}from"react";var wy=120,Ay=12,xd=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=vy(),{instanceId:i}=q();return Ny(()=>{var f,y;if(!t)return{position:An.Right,align:"start"};let a=n(e);if(!a)return{position:An.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=(y=document.getElementById(`modeler-${i}`))==null?void 0:y.clientWidth;if(!d)return{position:An.Right,align:"start"};let u=(o==null?void 0:o.width)||wy;return{position:l+c+u+Ay>d?An.Left:An.Right}},[i,e,t,o,n,r])};import{Bot as bd}from"lucide-react";import{useNodesData as Iy,useReactFlow as Cy}from"@xyflow/react";import{Button as Ed,DropdownMenu as Sy,DropdownMenuContent as My,DropdownMenuGroup as Py,DropdownMenuItem as Ly,DropdownMenuLabel as ky,DropdownMenuTrigger as Ry,Tooltip as hs,TooltipContent as ys,TooltipTrigger as xs,useTranslation as Dy}from"@produto-lecom/lecom-ui";import{WrenchIcon as Oy}from"lucide-react";import{jsx as Oe,jsxs as go}from"react/jsx-runtime";var _d=({nodeId:e})=>{let{t}=Dy(),{updateNodeData:o,getEdges:n,getNode:r}=Cy(),i=Iy(e),s=n().filter(y=>y.source===e).some(y=>{let E=r(y.target);return(E==null?void 0:E.type)==="END_EVENT"}),l=(i==null?void 0:i.data.variant)==="SUBPROCESS",c=(i==null?void 0:i.data.variant)==="SERVICE_TASK",d=m=>{o(e,{variant:(i==null?void 0:i.data.variant)===m?"":m})},u=m=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===m?"":m})};return go(Sy,{children:[go(hs,{children:[Oe(xs,{asChild:!0,children:Oe(Ry,{asChild:!0,children:Oe(Ed,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:Oe(Oy,{})})})}),Oe(ys,{color:"black",children:t("bpmn.task.menu.title")})]}),go(My,{align:"start",className:"w-60 bg-white text-grey-600",children:[go(ky,{className:"flex items-center gap-1",children:[Oe("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),Oe("div",{className:"flex items-center gap-1",children:Object.entries($n).map(([m,f])=>{let y=m==="LOOP"&&(s||l||c),p=(()=>{if(m==="LOOP"&&s)return t("editor.task_menu.loop_not_allowed_when_connected_to_end");if(m==="LOOP"&&l)return t("editor.task_menu.loop_not_allowed_when_subprocess");if(m==="LOOP"&&c)return t("editor.task_menu.loop_not_allowed_when_service_task");if(m==="LOOP")return t("editor.task_menu.loop")})();return go(hs,{children:[Oe(xs,{asChild:!0,children:Oe(Ed,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:y,className:H({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===m,"opacity-50 cursor-not-allowed":y}),onClick:y?void 0:()=>u(m),children:Oe(f.icon,{className:"stroke-inherit"})})}),p&&Oe(ys,{color:"black",children:p})]},m)})})]}),Oe(Py,{children:go(hs,{children:[Oe(xs,{asChild:!0,children:Oe("div",{className:H({"cursor-not-allowed":s}),children:go(Ly,{className:H({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":s}),disabled:s,onClick:()=>d("SCRIPT"),children:[Oe(Un.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),s&&Oe(ys,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};import{jsx as Pe,jsxs as Td}from"react/jsx-runtime";var Lt={START_EVENT:{type:"START_EVENT",icon:Zo,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:To,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:Zo,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:Yn,label:"bpmn.annotation.variant.default"}},Uy={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:No,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:wo,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:vo,label:"bpmn.gateway.variant.complex"}},We=({nodeId:e,nodeType:t,nodeVariant:o,isChild:n})=>{let r=oi(null),i=oi(null),{t:a}=Fy(),{setDraggableNode:s}=Wo(),{getEdges:l,getNodes:c,getNode:d,setNodes:u}=Hy(),{setIsDragging:m,mode:f,isConnecting:y,isDragging:E,isMultipleSelection:p}=q(),g=d(e),h=!!(g!=null&&g.selected)&&!g.dragging&&!y&&!E&&!p,{dimensions:x}=yd(r,h),{position:v}=xd(e,h,x),[b,N]=Xy(void 0),T=c(),A=l(),C=o==="SUBPROCESS",P=o==="SERVICE_TASK",R=oi(null),S=oi(!1),L=Es(()=>{R.current!==null&&(clearTimeout(R.current),R.current=null),S.current=!1,m(!1),s(null),N(void 0),u(F=>F.map(U=>w(_({},U),{className:void 0})))},[m,s,u]);Wy(()=>{let F=U=>{S.current&&U.buttons===0&&L()};return document.addEventListener("dragend",L),document.addEventListener("mousemove",F),()=>{document.removeEventListener("dragend",L),document.removeEventListener("mousemove",F)}},[L]);let K=Es((F,U)=>{S.current=!0,m(!1),s({type:U.type,variant:U.variant,attribute:U.attribute,icon:U.icon}),U.icon&&N(Pe(U.icon,{})),F.dataTransfer.effectAllowed="move",F.dataTransfer.setData("sourceId",e),i.current&&F.dataTransfer.setDragImage(i.current,10,10),R.current=setTimeout(()=>{R.current=null,m(!0)},100)},[e,s,m]),j=Es(()=>{L()},[L]),Q=[{component:Pe(Gr,{elementId:e})}],z=()=>{if(f==="view")return[];let F=!A.some(U=>{var X;return U.source===e&&((X=T.find($=>$.id===U.target))==null?void 0:X.type)!=="ANNOTATION"});return[{component:Pe(ko,{nodeId:e,disabled:!F,tooltipMessage:F?void 0:a("editor.toolbar.start_event_limit_reached")})},Lt.TASK,Lt.ANNOTATION,...Q]},M=()=>f==="view"?[{component:Pe(Ft,{elementId:e})}]:[{component:Pe(Ft,{elementId:e})},...C||P?[]:[{component:Pe(_d,{nodeId:e})}],{component:Pe(ko,{nodeId:e})},Lt.TASK,{type:"TASK",variant:"SUBPROCESS",icon:Qo,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:bd,label:"bpmn.task.variant.service_task"},Lt.ANNOTATION,...Object.values(Uy),...po(e,T,A)?[]:[Lt.END_EVENT],...Q],V=()=>f==="view"?[{component:Pe(Ft,{elementId:e,elementType:"gateway"})}]:[{component:Pe(Ft,{elementId:e,elementType:"gateway"})},{component:Pe(ko,{nodeId:e})},Lt.TASK,{type:"TASK",variant:"SUBPROCESS",icon:Qo,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:bd,label:"bpmn.task.variant.service_task"},Lt.ANNOTATION,...Q],D=()=>f==="view"?[]:[Lt.ANNOTATION,...Q],I=()=>f==="view"?[]:[...n?[]:[{component:Pe(ko,{nodeId:e})}],Lt.ANNOTATION,...Q],B=()=>f==="view"?[]:[{component:Pe(ko,{nodeId:e})},...Q],G=()=>f==="view"?[]:[...Q],O=(F=>{switch(F){case"START_EVENT":return z();case"TASK":return M();case"GATEWAY":return V();case"END_EVENT":return D();case"LANE":return I();case"ANNOTATION":return B();case"UNSUPPORTED":return G();default:return[]}})(t),Y=O.length>6;if(!(O.length===0||f==="readonly"))return Td(Vy,{position:v,align:"start",className:Y?"-top-[4.5rem]":"-top-8",isVisible:h,children:[Pe("div",{ref:r,className:`${Y?"grid grid-cols-6":"flex"} gap-1 px-2 py-2 bg-white rounded-sm shadow-md`,children:O.map((F,U)=>{if(F.component)return Pe("div",{children:F.component},U);let X={sourceNodeType:t,targetNodeType:F.type,sourceNodeId:e,nodes:T,edges:A},$=wc(X),te={gateway_limit_reached:a("editor.toolbar.gateway_limit_reached"),start_event_limit_reached:a("editor.toolbar.start_event_limit_reached"),start_event_already_exists:a("editor.toolbar.start_event_already_exists"),script_to_end_not_allowed:a("editor.toolbar.script_to_end_not_allowed"),loop_to_end_not_allowed:a("editor.toolbar.loop_to_end_not_allowed"),initial_activity_to_end_not_allowed:a("editor.toolbar.initial_activity_to_end_not_allowed"),final_activity_cannot_connect:a("editor.toolbar.final_activity_cannot_connect"),activity_has_outgoing_connections:a("editor.toolbar.activity_has_outgoing_connections"),task_limit_reached:a("editor.toolbar.task_limit_reached"),start_event_to_service_task_not_allowed:a("editor.toolbar.start_event_to_service_task_not_allowed"),service_task_to_end_not_allowed:a("editor.toolbar.service_task_to_end_not_allowed")},ie=$.shouldDisable&&$.reason?te[$.reason]||a(F.label):a(F.label)||"";return Td(By,{children:[Pe(Yy,{asChild:!0,children:Pe(Gy,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!$.shouldDisable,disabled:$.shouldDisable,className:$.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:$.shouldDisable?void 0:W=>K(W,F),onDragEnd:$.shouldDisable?void 0:j,children:F.icon&&Pe(F.icon,{size:16})})}),Pe(zy,{color:"black",children:ie})]},U)})}),Pe("div",{ref:i,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:b})]})};import{Fragment as vd,jsx as ut,jsxs as bs}from"react/jsx-runtime";var Nd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r,setNodes:i}=Ky(),{inProgress:a,fromNode:s}=$y(),{mode:l,isReadOnly:c}=q(),d=a&&(s==null?void 0:s.id)!==e,u=_s(y=>{let x=y.split(`
40
- `),v=x.reduce((A,C)=>Math.max(A,C.length),0),b=x.length,N=Math.max(Io.MIN_WIDTH,v*7+32),T=Math.max(Io.MIN_HEIGHT,b*20+24);i(A=>A.map(C=>C.id===e?w(_({},C),{width:N,height:T,style:w(_({},C.style),{width:N,height:T})}):C))},[e,i]),m=_s(y=>{r(e,{label:y}),u(y)},[e,r,u]),f=_s(y=>{u(y)},[u]);return bs("div",{className:H("relative w-full h-full min-w-44 min-h-16 flex text-grey-400 hover:text-grey-500 bg-white rounded-sm border-l-2 border-current before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-current after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-current hover:shadow-md transition-colors duration-75",{"pointer-events-none":c,"text-blue-500 hover:text-blue-600 shadow-md":o&&!c,"border-red-500 border-l-[3px] shadow-[0_0_5px_rgba(255,0,0,0.5)] before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-red-500 after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-red-500":t.hasError}),children:[ut(De,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:m,onInput:f,skipFirstCharValidation:!0}),ut(We,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&ut(st,{nodeId:e,minWidth:Io.MIN_WIDTH,minHeight:Io.MIN_HEIGHT,isVisible:!n&&o}),!a&&bs(vd,{children:[ut(ne,{type:"source",position:$t.Left,id:"left"}),ut(ne,{type:"source",position:$t.Right,id:"right"}),ut(ne,{type:"source",position:$t.Top,id:"top"}),ut(ne,{type:"source",position:$t.Bottom,id:"bottom"})]}),(!a||d)&&bs(vd,{children:[ut(ne,{type:"target",position:$t.Left,id:"left",className:H({"annotation-handle":d})}),ut(ne,{type:"target",position:$t.Right,id:"right",className:H({"annotation-handle":d})}),ut(ne,{type:"target",position:$t.Top,id:"top",className:H({"annotation-handle":d})}),ut(ne,{type:"target",position:$t.Bottom,id:"bottom",className:H({"annotation-handle":d})})]})]})};import{Position as Kt,useConnection as qy,useReactFlow as Zy}from"@xyflow/react";import{useState as Jy}from"react";import{Fragment as wd,jsx as Je,jsxs as Ts}from"react/jsx-runtime";var Ad=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=Zy(),{inProgress:i,fromNode:a}=qy(),{mode:s,isReadOnly:l,reconnectingEdgeId:c}=q(),[d,u]=Jy(!1),m=i&&(a==null?void 0:a.id)!==e||!!c,f=p=>{r(e,{label:p})},y=()=>{u(!0)},E=()=>{u(!1)};return Ts("div",{className:"relative",onDoubleClick:y,children:[Je(To,{className:H("w-full h-full min-w-9 min-h-9 hover:stroke-[#d33b3b] transition-colors duration-75",{"pointer-events-none":l,"stroke-blue-500 hover:stroke-blue-600":o&&!l,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),Je("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Je(De,{value:t.label,isEditing:d,onBlur:E,onChange:f})}),Je(We,{nodeId:e,nodeType:"END_EVENT"}),s==="edit"&&Je(st,{nodeId:e,isVisible:!n&&o,minWidth:qn.MIN_WIDTH,minHeight:qn.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||m)&&Ts(wd,{children:[Je(ne,{type:"target",position:Kt.Left,id:"left",className:H({"event-handle":m})}),Je(ne,{type:"target",position:Kt.Right,id:"right",className:H({"event-handle":m})}),Je(ne,{type:"target",position:Kt.Top,id:"top",className:H({"event-handle":m})}),Je(ne,{type:"target",position:Kt.Bottom,id:"bottom",className:H({"event-handle":m})})]}),!i&&Ts(wd,{children:[Je(ne,{type:"source",position:Kt.Left,id:"left"}),Je(ne,{type:"source",position:Kt.Right,id:"right"}),Je(ne,{type:"source",position:Kt.Top,id:"top"}),Je(ne,{type:"source",position:Kt.Bottom,id:"bottom"})]})]})};import{Position as qt,useConnection as Qy,useReactFlow as jy}from"@xyflow/react";import{useCallback as e0,useState as t0}from"react";import{Fragment as Id,jsx as Qe,jsxs as vs}from"react/jsx-runtime";var Cd=({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let a=zi[t.variant].icon,{updateNodeData:s}=jy(),{inProgress:l,fromNode:c}=Qy(),{mode:d,isReadOnly:u,reconnectingEdgeId:m}=q(),[f,y]=t0(!1),E=l&&(c==null?void 0:c.id)!==e||!!m,p=e0(x=>{s(e,{label:x})},[e,s]),g=()=>{y(!0)},h=()=>{y(!1)};return vs("div",{className:"relative",style:{width:o!=null?o:Ao.MIN_WIDTH,height:n!=null?n:Ao.MIN_HEIGHT},onDoubleClick:g,children:[Qe(a,{className:H("w-full h-full min-w-14 min-h-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"pointer-events-none":u,"stroke-blue-500 hover:stroke-blue-600":r&&!u,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),Qe("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Qe(De,{value:t.label,isEditing:f,onBlur:h,onChange:p})}),Qe(We,{nodeId:e,nodeType:"GATEWAY",nodeVariant:t.variant}),d==="edit"&&Qe(st,{nodeId:e,isVisible:!i&&r,minWidth:Ao.MIN_WIDTH,minHeight:Ao.MIN_HEIGHT,offset:2,keepAspectRatio:!0}),(!l||E)&&vs(Id,{children:[Qe(ne,{type:"target",position:qt.Left,id:"left",className:H({"gateway-handle":E})}),Qe(ne,{type:"target",position:qt.Right,id:"right",className:H({"gateway-handle":E})}),Qe(ne,{type:"target",position:qt.Top,id:"top",className:H({"gateway-handle":E})}),Qe(ne,{type:"target",position:qt.Bottom,id:"bottom",className:H({"gateway-handle":E})})]}),!l&&vs(Id,{children:[Qe(Ge,{type:"source",position:qt.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Qe(Ge,{type:"source",position:qt.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Qe(Ge,{type:"source",position:qt.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Qe(Ge,{type:"source",position:qt.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})};import{useNodesData as wP,useReactFlow as AP}from"@xyflow/react";import{Button as CP,DropdownMenu as SP,DropdownMenuContent as MP,DropdownMenuGroup as PP,DropdownMenuItem as LP,DropdownMenuLabel as kP,DropdownMenuTrigger as RP,Tooltip as DP,TooltipContent as OP,TooltipTrigger as VP,useTranslation as HP}from"@produto-lecom/lecom-ui";import{WrenchIcon as BP}from"lucide-react";import{jsx as WP,jsxs as XP}from"react/jsx-runtime";import{Position as Zt,useConnection as o0,useReactFlow as n0}from"@xyflow/react";import{useState as r0}from"react";import{Fragment as Sd,jsx as je,jsxs as Ns}from"react/jsx-runtime";var Md=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=n0(),{inProgress:i,fromNode:a}=o0(),{mode:s,isReadOnly:l,reconnectingEdgeId:c}=q(),[d,u]=r0(!1),m=i&&(a==null?void 0:a.id)!==e||!!c,f=p=>{r(e,{label:p})},y=()=>{u(!0)},E=()=>{u(!1)};return Ns("div",{className:"relative",onDoubleClick:y,children:[je(Wn,{className:H("w-full h-full min-w-9 min-h-9 hover:stroke-[#54890b] transition-colors duration-75",{"pointer-events-none":l,"stroke-blue-500 hover:stroke-blue-600":o&&!l,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),je("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:je(De,{value:t.label,isEditing:d,onBlur:E,onChange:f})}),je(We,{nodeId:e,nodeType:"START_EVENT"}),s==="edit"&&je(st,{nodeId:e,isVisible:!n&&o,minWidth:Kn.MIN_WIDTH,minHeight:Kn.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||m)&&Ns(Sd,{children:[je(ne,{type:"target",position:Zt.Left,id:"left",className:H({"event-handle":m})}),je(ne,{type:"target",position:Zt.Right,id:"right",className:H({"event-handle":m})}),je(ne,{type:"target",position:Zt.Top,id:"top",className:H({"event-handle":m})}),je(ne,{type:"target",position:Zt.Bottom,id:"bottom",className:H({"event-handle":m})})]}),!i&&Ns(Sd,{children:[je(Ge,{type:"source",position:Zt.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),je(Ge,{type:"source",position:Zt.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),je(Ge,{type:"source",position:Zt.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),je(Ge,{type:"source",position:Zt.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};import{useTranslation as a0}from"@produto-lecom/lecom-ui";import{Position as Jt,useConnection as l0,useReactFlow as c0}from"@xyflow/react";import{useCallback as ri}from"react";var In=60,ni=(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<=In?i:i.substring(0,In).trim()},Xo=(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>In&&(n=n.substring(0,In).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=In-l.length,u=`${r.substring(0,c).trim()}${l}`;if(!o.has(u))return u;i++}return n};import{jsx as Pd,jsxs as i0}from"react/jsx-runtime";var Ld=e=>i0("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[Pd("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),Pd("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as kd}from"react/jsx-runtime";var Rd=e=>kd("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:kd("path",{d:"M12 2C8.13 2 5 5.13 5 9C5 14.25 12 22 12 22C12 22 19 14.25 19 9C19 5.13 15.87 2 12 2ZM12 11.5C10.62 11.5 9.5 10.38 9.5 9C9.5 7.62 10.62 6.5 12 6.5C13.38 6.5 14.5 7.62 14.5 9C14.5 10.38 13.38 11.5 12 11.5Z",fill:"#38bdf8"})}));import{jsx as Dd,jsxs as s0}from"react/jsx-runtime";var Od=e=>s0("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[Dd("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),Dd("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{Fragment as ii,jsx as we,jsxs as Cn}from"react/jsx-runtime";var d0={APROVADO:Ld,EM_ANDAMENTO:Rd,REJEITADO:Od},ws={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)]"},u0={APROVADO:"bg-green-50",EM_ANDAMENTO:"bg-turquoise-50",REJEITADO:"bg-red-50"},Vd=({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let{t:a}=a0(),{toast:s}=Fe(),{updateNodeData:l,getNodes:c,setNodes:d}=c0(),{inProgress:u,fromNode:m}=l0(),{mode:f,isReadOnly:y,onSubprocessValidationClick:E,reconnectingEdgeId:p}=q(),{getTaskStatus:g}=io(),h=u&&(m==null?void 0:m.id)!==e||!!p,x=g(e),v=t.variant==="SUBPROCESS",b=t.variant==="SERVICE_TASK",N=!!t.variant&&!v&&!b||!!x,T=!!t.attribute||v||b,A=ri(M=>{let B=N||T?80:40,G=M.split(`
41
- `),k=G.reduce((U,X)=>Math.max(U,X.length),0),O=G.length,Y=Math.max(Vt.MIN_WIDTH,k*7+64),F=Math.max(Vt.MIN_HEIGHT,O*24+B);d(U=>U.map(X=>X.id===e?w(_({},X),{width:Y,height:F,style:w(_({},X.style),{width:Y,height:F})}):X))},[e,d,N,T]),C=ri(M=>{let V=M.trim(),D=t.label||"";if(V===D)return;let I=V,B=c();if(!(V&&V!=="")){I=ni(B,a("bpmn.task.label.prefix")),l(e,{label:I}),A(I),s({variant:"warning",content:Cn(ii,{children:[a("bpmn.task.feedback.label_empty.prefix")," ",we("strong",{children:I})]})});return}let k=Xo(I,B);k===D||(l(e,{label:k}),A(k),k!==I&&s({variant:"warning",content:Cn(ii,{children:[a("bpmn.task.feedback.label_already_exists.prefix")," ",we("strong",{children:V})," ",a("bpmn.task.feedback.label_already_exists.middle")," ",we("strong",{children:k})]})}))},[t.label,c,e,a,l,A,s]),P=ri(M=>{A(M)},[A]),R=ri(()=>{s({variant:"error",content:a("bpmn.task.feedback.invalid_first_character")})},[a,s]),S=x?d0[x]:null,L=t.variant?Un[t.variant].icon:null,K=t.attribute?$n[t.attribute].icon:null,j=()=>t.hasError?ws.error:x?ws[x]:y?ws.default:"",Q=()=>{var M;return r&&(M=u0[x])!=null?M:""},z=()=>{E==null||E({id:e,type:"sub_process",label:t.label})};return Cn("div",{className:H("relative w-full h-full min-w-44 min-h-24 flex flex-col items-stretch justify-stretch bg-white border-2 border-grey-400 hover:border-grey-500 rounded-md hover:shadow-md transition-colors duration-75",j(),{"cursor-pointer":y,"border-blue-500 hover:border-blue-600 shadow-md":r&&!y&&!x,"border-red-500 hover:border-red-600 shadow-[0_0_5px_rgba(255,0,0,0.5)]":t.hasError}),style:{width:o!=null?o:Vt.MIN_WIDTH,height:n!=null?n:Vt.MIN_HEIGHT},children:[we("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:we(De,{value:t.label,maxLength:60,className:H(Q(),{"py-10 px-8":N||T}),onChange:C,onInput:P,onInvalidFirstCharacter:R})}),L&&we("div",{className:H("absolute flex items-center p-1",v||b?"bottom-0 left-1/2 -translate-x-1/2":"top-0 left-0"),children:we(L,{size:b?20:16,className:H(t.hasError?"text-red-500":"text-grey-500",v&&"cursor-pointer"),onClick:v?z:void 0})}),K&&we("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:we("div",{className:H("flex items-center w-16 p-1",v||b?"justify-between":"justify-center"),children:we(K,{size:16,className:H(t.hasError?"text-red-500":"text-grey-500")})})}),S&&we("div",{className:"absolute top-0 right-0 flex items-center p-1",children:we(S,{})}),we(We,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),f==="edit"&&we(st,{nodeId:e,isVisible:!i&&r,minWidth:Vt.MIN_WIDTH,minHeight:Vt.MIN_HEIGHT}),(!u||h)&&Cn(ii,{children:[we(ne,{type:"target",position:Jt.Left,id:"left",className:H({"task-handle":h})}),we(ne,{type:"target",position:Jt.Right,id:"right",className:H({"task-handle":h})}),we(ne,{type:"target",position:Jt.Top,id:"top",className:H({"task-handle":h})}),we(ne,{type:"target",position:Jt.Bottom,id:"bottom",className:H({"task-handle":h})})]}),!u&&Cn(ii,{children:[we(Ge,{type:"source",position:Jt.Left,id:"left",nodeId:e,nodeType:"TASK"}),we(Ge,{type:"source",position:Jt.Right,id:"right",nodeId:e,nodeType:"TASK"}),we(Ge,{type:"source",position:Jt.Top,id:"top",nodeId:e,nodeType:"TASK"}),we(Ge,{type:"source",position:Jt.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})};import{Position as Hd}from"@xyflow/react";import{Fragment as p0,jsx as si,jsxs as f0}from"react/jsx-runtime";var Gd=({id:e,data:t})=>f0(p0,{children:[si("div",{className:"relative w-full h-full min-w-32 min-h-16 flex items-center justify-center bg-white border-2 border-red-400 rounded-sm overflow-hidden",children:t.label}),si(We,{nodeId:e,nodeType:"UNSUPPORTED"}),si(ne,{type:"source",position:Hd.Right}),si(ne,{type:"target",position:Hd.Left})]});import{BaseEdge as m0,EdgeLabelRenderer as g0,getSmoothStepPath as h0,MarkerType as y0,useInternalNode as Bd,useReactFlow as x0,useViewport as E0,Position as Uo}from"@xyflow/react";import{useState as _0,useMemo as b0}from"react";import{Fragment as zd,jsx as Xe,jsxs as ho}from"react/jsx-runtime";var SL={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:y0.Arrow},data:{label:""}},Yd=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var G;let{zoom:c}=E0(),{updateEdgeData:d}=x0(),{isMultipleSelection:u,mode:m,instanceId:f}=q(),y=m!=="edit",[E,p]=_0(!1),{reconnectingHandle:g,cursorPosition:h,hoveredNodeId:x,reconnectingSide:v,isValidReconnection:b,handleReconnectStart:N}=Kr({edgeId:e,source:t,target:o,instanceId:f,isReadOnly:y}),T=Bd(t),A=Bd(o),{sx:C,sy:P,tx:R,ty:S,sourcePos:L,targetPos:K}=b0(()=>{var oe,le;if(!T||!A)return{sx:0,sy:0,tx:0,ty:0,sourcePos:Uo.Left,targetPos:Uo.Right};let k=Co(T,A),O=s?i:k.sourcePos,Y=l?a:k.targetPos,F=(Z,xe,me)=>{var ee,ge,be,Te,ke,tt;let{x:_e,y:J}=Z.internals.positionAbsolute,de=(be=(ge=(ee=Z.measured)==null?void 0:ee.width)!=null?ge:Z.width)!=null?be:0,re=(tt=(ke=(Te=Z.measured)==null?void 0:Te.height)!=null?ke:Z.height)!=null?tt:0;switch(xe){case Uo.Top:return{x:_e+de*me,y:J};case Uo.Bottom:return{x:_e+de*me,y:J+re};case Uo.Left:return{x:_e,y:J+re*me};case Uo.Right:return{x:_e+de,y:J+re*me};default:return{x:_e+de/2,y:J+re/2}}},U=(oe=n==null?void 0:n.sourceOffset)!=null?oe:.5,X=(le=n==null?void 0:n.targetOffset)!=null?le:.5,$=T?F(T,O,U).x:k.sx,te=T?F(T,O,U).y:k.sy,ie=A?F(A,Y,X).x:k.tx,W=A?F(A,Y,X).y:k.ty;return g==="source"&&h?($=h.x,te=h.y,v&&(O=v)):g==="target"&&h&&(ie=h.x,W=h.y,v&&(Y=v)),{sx:$,sy:te,tx:ie,ty:W,sourcePos:O,targetPos:Y}},[T,A,s,l,i,a,g,h,v,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!T||!A)return null;let[j,Q,z]=h0({sourceX:C,sourceY:P,targetX:R,targetY:S,sourcePosition:L,targetPosition:K}),M=r||(T==null?void 0:T.selected)||(A==null?void 0:A.selected),V=M?"sequence-edge-marker-highlighted":"sequence-edge-marker",D=E||(n==null?void 0:n.label.trim().length)>0,I=()=>{p(!1)},B=k=>{d(e,{label:k.trim()})};return Xe(zd,{children:ho("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":M}),onDoubleClick:()=>!y&&p(!0),children:[Xe("path",{d:j,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),ho("g",{className:H("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":M}),children:[Xe(m0,{id:e,path:j,interactionWidth:0,markerEnd:`url(#${V})`,strokeDasharray:4,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||g&&x&&!b,"stroke-green-500":g&&x&&b,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":M&&!(n!=null&&n.hasError)&&!g})}),ho(g0,{children:[ho("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${Q}px, ${z}px)`},children:[r&&!u&&Xe(Do,{sx:C,sy:P,tx:R,ty:S,hasLabel:!!((G=n==null?void 0:n.label)!=null&&G.trim()),children:Xe(Ro,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),D&&Xe(De,{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:I,onChange:B})]}),r&&!u&&!y&&ho(zd,{children:[Xe("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${C}px, ${P}px)`},children:ho("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Xe("circle",{cx:6/c,cy:6/c,r:4/c,fill:g==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Xe("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:g==="source"?.6:.3,className:"pointer-events-none"}),Xe("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!g||g!=="source","cursor-not-allowed":g==="source"&&x&&!b,"cursor-grabbing":g==="source"&&(!x||b)}),onMouseDown:k=>N("source",k.nativeEvent)})]})}),Xe("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${R}px, ${S}px)`},children:ho("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Xe("circle",{cx:6/c,cy:6/c,r:4/c,fill:g==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Xe("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:g==="target"?.6:.3,className:"pointer-events-none"}),Xe("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!g||g!=="target","cursor-not-allowed":g==="target"&&x&&!b,"cursor-grabbing":g==="target"&&(!x||b)}),onMouseDown:k=>N("target",k.nativeEvent)})]})})]})]})]})]})})};import{getStraightPath as T0,Position as ai}from"@xyflow/react";import{jsx as Fd,jsxs as v0}from"react/jsx-runtime";var Wd=({toX:e,toY:t,fromNode:o})=>{var u,m;if(!o)return null;let{internals:{positionAbsolute:{x:n,y:r}},measured:i}=o,a=(u=i.width)!=null?u:0,s=(m=i.height)!=null?m:0,c=[{x:n,y:r+s/2,pos:ai.Left},{x:n+a,y:r+s/2,pos:ai.Right},{x:n+a/2,y:r,pos:ai.Top},{x:n+a/2,y:r+s,pos:ai.Bottom}].reduce((f,y)=>{let E=Math.hypot(e-f.x,t-f.y);return Math.hypot(e-y.x,t-y.y)<E?y:f}),[d]=T0({sourceX:c.x,sourceY:c.y,targetX:e,targetY:t});return v0("g",{className:"group",children:[Fd("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d}),Fd("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})};import{Position as Qt,useConnection as N0,useReactFlow as w0}from"@xyflow/react";import{orderBy as A0}from"lodash";import{useMemo as Xd,useState as I0}from"react";import{Fragment as As,jsx as Ue,jsxs as li}from"react/jsx-runtime";var Ud=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{var T;let{updateNodeData:i,getNodes:a}=w0(),{mode:s,isReadOnly:l}=q(),{inProgress:c,fromNode:d}=N0(),u=c&&(d==null?void 0:d.id)!==e,[m,f]=I0(!1),y=a(),E=!r,p=!E&&((T=y.find(A=>A.id===r))==null?void 0:T.selected),g=Xd(()=>A0([...y.filter(A=>A.parentId===e&&A.type==="LANE")],"position.y","asc"),[y,e]),h=E?da.MIN_WIDTH:se.MIN_WIDTH,x=Xd(()=>{if(E&&g.length>1){let A=[...g];return A.pop(),A.reduce((P,R)=>{var S,L;return P+((L=(S=R.measured)==null?void 0:S.height)!=null?L:0)},0)+se.MIN_HEIGHT}return se.MIN_HEIGHT},[E,g]),v=A=>{i(e,{label:A})},b=()=>{f(!0)},N=()=>{f(!1)};return li(As,{children:[li("div",{className:H("flex h-full min-h-64 w-full min-w-[50rem] hover:shadow-md bg-white outline outline-2 outline-grey-400",{"pointer-events-none":l,"outline-offset-0 outline-blue-500 shadow-sm":(o||p)&&!l}),children:[Ue("div",{className:H("flex align-items justify-center w-10 border-r-2 border-grey-400",{"border-blue-500":(o||p)&&!l}),onDoubleClick:b,children:Ue("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:Ue(De,{value:t.label,className:"w-full h-full self-auto",contentClassName:H({"whitespace-nowrap":m}),isEditing:m,onBlur:N,onChange:v})})}),Ue("div",{className:"flex-1"})]}),Ue(We,{nodeId:e,nodeType:"LANE",isChild:!E}),s==="edit"&&Ue(st,{nodeId:e,isVisible:!n&&o,minWidth:h,minHeight:x,offset:10}),!c&&li(As,{children:[Ue(ne,{type:"source",position:Qt.Left,id:"left"}),Ue(ne,{type:"source",position:Qt.Right,id:"right"}),Ue(ne,{type:"source",position:Qt.Top,id:"top"}),Ue(ne,{type:"source",position:Qt.Bottom,id:"bottom"})]}),(!c||u)&&li(As,{children:[Ue(ne,{type:"target",position:Qt.Left,id:"left",className:H({"annotation-handle":u})}),Ue(ne,{type:"target",position:Qt.Right,id:"right",className:H({"annotation-handle":u})}),Ue(ne,{type:"target",position:Qt.Top,id:"top",className:H({"annotation-handle":u})}),Ue(ne,{type:"target",position:Qt.Bottom,id:"bottom",className:H({"annotation-handle":u})})]})]})};var $d={START_EVENT:Md,END_EVENT:Ad,TASK:Vd,GATEWAY:Cd,ANNOTATION:Nd,LANE:Ud,UNSUPPORTED:Gd},Kd={SEQUENCE_EDGE:Xc,MESSAGE_EDGE:Yd,ANNOTATION_EDGE:Sc},qd="#fafafa",Zd="#bebebe",Jd=1,Qd=10,jd="bottom-left",Is=.05,eu=5,tu=150,ou=100,nu=Is,ru=1,iu={x:0,y:0,zoom:.75},su=1,au=2,C0={[su]:4,[au]:2},Sn=[su,au],Cs=Sn.reduce((e,t)=>e|C0[t],0);var jt=()=>{let{setViewport:e}=S0(),t=M0();return{fitToNodes:P0(n=>{let{width:r,height:i}=t.getState();if(i<=0||r<=0)return;let a=ya(n);if(!a)return;let s=xa({bounds:a,canvasHeight:i,canvasWidth:r,minZoom:nu,maxZoom:ru,offsetX:tu,offsetY:ou});e(s)},[t,e])}};import{useReactFlow as L0}from"@xyflow/react";var at=()=>{let{getEdges:e,getNodes:t}=L0(),{lastElementId:o}=q(),n=()=>{let i=t(),a=e(),s=Kc(i,a);return Math.max(s,o)};return{getLastId:n,getNextId:()=>n()+1}};var $o=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n}=k0(),{getLastId:r}=at(),{fitToNodes:i}=jt(),{setLastElementId:a}=q(),s=lu(async(c="")=>{let{nodes:d,edges:u,lastElementId:m}=await ld(c);i(d),o(d),n(u),a(m)},[o,n,a,i]),l=lu(()=>{let c=e(),d=t(),u=r();return ad(c,d,u)},[e,t,r]);return{importFromMxGraph:s,exportToMxGraph:l}};import{useCallback as cu}from"react";var D0=500,ci=()=>{let{isInitialized:e,onElementChanges:t}=q(),{exportToMxGraph:o}=$o(),n=R0(()=>{if(!e)return;let a=o();t==null||t(a)},D0),r=cu(a=>{a.every(c=>c.type==="select")||a.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=cu(a=>{a.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var du=({setEdges:e,saveHistory:t})=>{let{getNode:o,getEdges:n,getNodes:r,getInternalNode:i}=V0(),{emitElementChanges:a}=ci(),s=H0(null),{getNextId:l}=at(),c=yo(p=>{var b;let g=o(p.source),h=o(p.target);if(!g||!h)return!1;let x={sourceNodeId:g.id,targetNodeId:h.id,sourceNodeType:g.type,targetNodeType:h.type,nodes:r(),edges:n(),reconnectingEdgeId:(b=s.current)!=null?b:void 0};return ls(x).isValid},[o,n,r]),d=yo(p=>{var x,v;let g=l(),h=i(p.source);if(h){let b=i(p.target),N=b?b.internals.positionAbsolute.x+((x=b.measured.width)!=null?x:0)/2:0,T=b?b.internals.positionAbsolute.y+((v=b.measured.height)!=null?v:0)/2:0,A=Uc(h,N,T),C=(b==null?void 0:b.type)==="ANNOTATION"||(h==null?void 0:h.type)==="ANNOTATION",P=C?Oo:it,R;if(!C&&b&&p.targetHandle){let K=Zr(A),j=Zr(p.targetHandle),{x:Q,y:z}=fs(h,A),{x:M,y:V}=fs(b,p.targetHandle),I=Ur(Q,z,M,V,K,j).slice(1,-1);I.length>0&&(R=I)}let S=w(_(_({},p),P),{id:String(g),sourceHandle:A,data:_(_({},C?{}:it.data),R?{points:R}:{})}),L=n().concat(S);e(L),t("forceSave",{nodes:r(),edges:L}),a()}},[l,e,a,i,n,r,t]),u=yo((p,g)=>{s.current=g.id},[]),m=yo(()=>{s.current=null},[]),f=yo((p,g)=>{let h=o(g.source),x=o(g.target);if(!h||!x){s.current=null;return}let v={sourceNodeId:h.id,targetNodeId:x.id,sourceNodeType:h.type,targetNodeType:x.type,nodes:r(),edges:n(),reconnectingEdgeId:p.id};if(!ls(v).isValid){s.current=null;return}let N=O0(p,g,n()).map(T=>T.id===p.id?w(_({},T),{data:w(_({},T.data),{points:void 0})}):T);e(N),t("forceSave",{nodes:r(),edges:N}),s.current=null,a()},[o,r,n,e,a,t]),y=yo(p=>{s.current=p},[]),E=yo(()=>{s.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:f,onReconnectStart:u,onReconnectEnd:m,setReconnectingEdge:y,clearReconnectingEdge:E}};import{useTranslation as G0}from"@produto-lecom/lecom-ui";import{useReactFlow as B0}from"@xyflow/react";import{useCallback as kn,useRef as Eu,useState as z0}from"react";var Mn=(e=[])=>e.filter(t=>t.type==="START_EVENT"),xo=(e=[])=>e.filter(t=>t.type==="END_EVENT"),eo=(e=[])=>e.filter(t=>t.type==="TASK")||[],uu=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"});var di=(e=[])=>e.filter(t=>t.type==="GATEWAY"),pu=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),et=(e,t=[])=>t.filter(o=>o.source===e),Pn=(e,t=[])=>t.filter(o=>o.target===e),fu=(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"},mu=(e,t)=>{let o=et(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},gu=e=>e?/[^\s]/.test(e.trim()):!1,Ee=e=>{let{isValid:t,nodeIds:o,edgeIds:n}=e;return{isValid:t,nodeIds:!t&&o&&o.length>0?o:[],edgeIds:!t&&n&&n.length>0?n:[]}},kt=(e=[],t)=>{if(!e||e.length===0)return{isValid:!0,invalidIds:[]};let o=e.filter(n=>!t(n));return{isValid:o.length===0,invalidIds:o.map(n=>n.id)}},hu=(e=[],t=[])=>({nodes:e.map(o=>{var n;return{id:o.id,type:o.type||"",label:typeof((n=o.data)==null?void 0:n.label)=="string"?o.data.label:void 0,properties:o.data}}),edges:t.map(o=>({id:o.id,source:o.source,target:o.target,type:o.type||"default"}))});var Ln=[{id:"start_event_not_found",validate:e=>{let t=Mn(e.nodes);return Ee({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=xo(e.nodes);return Ee({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Mn(e.nodes),o=t.length===1;if(t.length===0)return Ee({isValid:!0});if(!o)return Ee({isValid:!1,nodeIds:t.map(i=>i.id)});let n=et(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(a=>a.id),...n.map(a=>a.target)];return Ee({isValid:!1,nodeIds:[...new Set(i)]})}return Ee({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=eo(e.nodes),o=kt(t,n=>et(n.id,e.edges).length<=2);return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=eo(e.nodes),o=kt(t,n=>!!n.label&&n.label.trim()!=="");return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=eo(e.nodes),n=kt(o,r=>!r.label||r.label.length<=60);return Ee({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=eo(e.nodes),o=new Map;for(let r of t){if(!r.label)continue;let i=r.label.trim();i&&(o.has(i)||o.set(i,[]),o.get(i).push(r))}let n=[];for(let[,r]of o.entries())r.length>1&&r.forEach(i=>n.push(i.id));return Ee({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=di(e.nodes),o=[],n=[];for(let r of t){let i=et(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 Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Mn(e.nodes),...xo(e.nodes)],o=[],n=[];for(let r of t){let i=et(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 Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=xo(e.nodes),o=[],n=[];for(let r of t){let i=Pn(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=et(s.id,e.edges);l.length>1&&(o.push(s.id),l.forEach(c=>n.push(c.id)))}}}return Ee({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=pu(e.nodes),o=kt(t,r=>et(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>et(r,e.edges).map(i=>i.id));return Ee({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=eo(e.nodes),o=kt(t,n=>!n.label||gu(n.label));return Ee({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 Ee({isValid:!0});let t=xo(e.nodes)[0];if(!t)return Ee({isValid:!0});let o=Pn(t.id,e.edges);if(!o.length)return Ee({isValid:!0});let r=eo(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=kt(r,l=>!fu(l.id,e));return Ee({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=eo(e.nodes),o=xo(e.nodes)[0];if(!o)return Ee({isValid:!0});let n=t.filter(l=>{let c=Pn(l.id,e.edges),d=et(l.id,e.edges),u=c.some(f=>{var y;return((y=e.nodes.find(E=>E.id===f.source))==null?void 0:y.type)==="START_EVENT"}),m=d.some(f=>{var y;return((y=e.nodes.find(E=>E.id===f.target))==null?void 0:y.type)==="END_EVENT"});return u&&m}),r=Pn(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 Ee(s)}},{id:"gateway_flow_to_event",validate:e=>{let t=di(e.nodes),o=[],n=[];for(let r of t){let i=et(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 Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=di(e.nodes),o=kt(t,n=>et(n.id,e.edges).length>=1);return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Mn(e.nodes),...xo(e.nodes)],o=[],n=[];for(let r of t){let i=et(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 Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=uu(e.nodes),o=kt(t,n=>!mu(n.id,e));return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}}];var yu=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of Ln){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}},xu=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}}};import{jsx as ui,jsxs as Y0}from"react/jsx-runtime";var _u=()=>{let{t:e}=G0(),{toast:t}=Fe(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=B0(),{validateCustomDiagram:a}=q(),[s,l]=z0(!1),c=Eu(!1),d=Eu(!1),u=kn(async p=>{let g=hu(p.nodes,p.edges),h=yu(g),x=p.nodes.filter(({type:b,data:N})=>b==="TASK"&&((N==null?void 0:N.variant)==="SUBPROCESS"||(N==null?void 0:N.variant)==="SERVICE_TASK"));if(a&&x.length>0){let b=await xu(a,x);h={isValid:h.isValid&&b.isValid,errors:[...h.errors,...b.errors]}}let v=h.errors.map(b=>w(_({},b),{message:e(`validation.errors.${b.id}`)}));return s||l(!0),{isValid:h.isValid,errors:v}},[s,e,a]),m=kn((p,g=!0)=>{if(g&&p&&t({variant:p.isValid?"success":"error",duration:5e3,title:p.isValid?e("validation.success.title"):e("validation.errors.title"),content:Y0("div",{className:"flex flex-col gap-1",children:[!p.isValid&&ui("span",{className:"body-small-500",children:e("validation.errors.subtitle")}),ui("ul",{className:"list-disc list-inside max-h-40 overflow-y-auto",children:p.isValid?ui("li",{children:e("validation.success.message")}):p.errors.map(S=>ui("li",{className:"text-xs",children:S.message},S.id))})]})}),!p)return;c.current=!0,d.current=!0;let h=[],x=[];p.errors.forEach(S=>{S.nodeIds&&S.nodeIds.length>0&&S.nodeIds.forEach(L=>h.push(L)),S.edgeIds&&S.edgeIds.length>0&&S.edgeIds.forEach(L=>x.push(L))});let v=[...new Set(h)];o(S=>S.map(L=>w(_({},L),{data:w(_({},L.data),{hasError:!1})}))),n(S=>S.map(L=>w(_({},L),{data:w(_({},L.data),{hasError:!1})})));let b=r(),N=i(),T=new Set(v),A=new Set;p.errors.forEach(S=>{var j,Q;let L=Ln.find(z=>z.id===S.id);(L==null?void 0:L.highlightRelatedEdges)!==!1&&((j=S.edgeIds)==null||j.forEach(z=>A.add(z)),(Q=S.nodeIds)==null||Q.forEach(z=>{N.forEach(M=>{(M.source===z||M.target===z)&&A.add(M.id)})}))});let C=new Set,P=new Set,R=new Set;b.forEach(S=>{S.type==="START_EVENT"?C.add(S.id):S.type==="END_EVENT"&&P.add(S.id)}),N.forEach(S=>{C.has(S.source)&&R.add(S.target),P.has(S.target)&&R.add(S.source)}),R.forEach(S=>{var L,K;if(T.has(S)){let j=(L=p.errors.find(z=>{var M;return(M=z.nodeIds)==null?void 0:M.includes(S)}))==null?void 0:L.id;((K=Ln.find(z=>z.id===j))==null?void 0:K.highlightRelatedEdges)!==!1&&N.forEach(z=>{z.source===S&&P.has(z.target)&&(T.add(z.target),A.add(z.id)),z.target===S&&C.has(z.source)&&(T.add(z.source),A.add(z.id))})}}),T.size>0&&o(S=>S.map(L=>w(_({},L),{data:w(_({},L.data),{hasError:T.has(L.id)})}))),A.size>0&&n(S=>S.map(L=>w(_({},L),{data:w(_({},L.data),{hasError:A.has(L.id)})}))),setTimeout(()=>{c.current=!1},0)},[e,i,r,n,o,t]),f=kn(()=>{l(!1),d.current=!1,o(p=>p.map(g=>w(_({},g),{data:w(_({},g.data),{hasError:!1})}))),n(p=>p.map(g=>w(_({},g),{data:w(_({},g.data),{hasError:!1})})))},[n,o]),y=kn(()=>{d.current&&(c.current=!0,d.current=!1,o(p=>p.map(g=>w(_({},g),{data:w(_({},g.data),{hasError:!1})}))),n(p=>p.map(g=>w(_({},g),{data:w(_({},g.data),{hasError:!1})}))),setTimeout(()=>{c.current=!1},0))},[n,o]),E=kn(()=>c.current,[]);return{validateDiagram:u,handleValidationComplete:m,clearValidation:f,dismissValidationPanel:y,isAutoValidationEnabled:s,getIsClearingValidation:E}};import{useReactFlow as F0}from"@xyflow/react";import{useTranslation as W0}from"@produto-lecom/lecom-ui";import{useEffect as X0}from"react";var U0=15,bu="bpmn:selection",$0=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},Tu=e=>{if(!$0(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},vu=({offset:e=U0,saveHistory:t})=>{let{t:o}=W0(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=F0(),{getNextId:s}=at(),{mode:l,containerRef:c}=q();X0(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let u=f=>{var b,N;if(!Tu(f)||!d.contains(document.activeElement))return;let E=n(),p=i(),g=E.filter(T=>T.selected);if(!g.length)return;f.preventDefault(),f.stopPropagation();let h=p.filter(T=>g.some(A=>A.id===T.source)&&g.some(A=>A.id===T.target)),v=JSON.stringify({nodes:g,edges:h});(b=f.clipboardData)==null||b.setData(bu,v),(N=f.clipboardData)==null||N.setData("text/plain",`BPMN Selection: ${g.length} nodes`)},m=f=>{var R,S;if(!Tu(f)||!d.contains(document.activeElement))return;let E=(R=f.clipboardData)==null?void 0:R.getData(bu);if(!E)return;f.preventDefault(),f.stopPropagation();let p;try{p=JSON.parse(E)}catch(L){return}if(!((S=p.nodes)!=null&&S.length))return;let g=new Map,h=n(),x=[],v=p.nodes.filter(L=>Yt(L.type,h));if(v.length===0)return;let b=s(),N=v.map(L=>{var Q;let K=String(b++);g.set(L.id,K);let j=w(_({},L),{id:K,selected:!0,position:{x:L.position.x+e,y:L.position.y+e}});if(L.type==="TASK"){let z=(Q=L.data)==null?void 0:Q.label,M=Xo(z||o("bpmn.task.label.prefix"),[...h,...x]);j.data=w(_({},L.data),{label:M})}return x.push(j),j}),T=p.edges.map(L=>w(_({},L),{id:String(b++),selected:!0,source:g.get(L.source)||L.source,target:g.get(L.target)||L.target})),A=[...h.map(L=>w(_({},L),{selected:!1})),...N],P=[...i().map(L=>w(_({},L),{selected:!1})),...T];r(A),a(P),t("forceSave",{nodes:A,edges:P})};return d.addEventListener("copy",u,!0),d.addEventListener("paste",m,!0),()=>{d.removeEventListener("copy",u,!0),d.removeEventListener("paste",m,!0)}},[n,r,i,a,s,e,o,t,l,c])};import{useTranslation as K0}from"@produto-lecom/lecom-ui";import{useReactFlow as q0}from"@xyflow/react";import{useState as Z0}from"react";var J0=50,Nu=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let{draggableNode:r,setDraggableNode:i}=Wo(),{t:a}=K0(),{getInternalNode:s,getNodes:l,getEdges:c,screenToFlowPosition:d}=q0(),{getNextId:u}=at(),{setIsDragging:m}=q(),{getInternalNodes:f}=jr(),{rebuildIndex:y,forceRebuildIndex:E}=Cr(),[p,g]=Z0(null),h=(M,V,D)=>{var k;if(M.parentId!==V)return null;let I=D.filter(O=>O.id!==M.id&&O.parentId===V&&O.type==="LANE").sort((O,Y)=>O.position.y-Y.position.y);if(I.length===0)return null;let B=(k=D.find(O=>O.id===M.id))!=null?k:M,G=I.find(O=>B.position.y<O.position.y);return G?{draggedLaneId:M.id,beforeLaneId:G.id}:{draggedLaneId:M.id,afterLaneId:I[I.length-1].id}},x=(M,V=!1,D)=>{let I=V?"node-drop-target-error":"node-drop-target",B=V?"node-drop-target-lane-error":"node-drop-target-lane";t(G=>{var O;let k=(O=D==null?void 0:D(G))!=null?O:null;return G.map(Y=>{let F=[];return Y.id===M&&F.push(I),M!==void 0&&Y.parentId===M&&Y.type==="LANE"&&Y.id!==(k==null?void 0:k.draggedLaneId)&&F.push(B),Y.id===(k==null?void 0:k.draggedLaneId)&&F.push("lane-reorder-dragging"),Y.id===(k==null?void 0:k.beforeLaneId)&&F.push("lane-reorder-before"),Y.id===(k==null?void 0:k.afterLaneId)&&F.push("lane-reorder-after"),w(_({},Y),{className:F.join(" ")})})})},v=(M,V)=>{let D=f();if(M.type==="LANE"){if(V){x();return}let O=D.filter(U=>U.id!==M.id&&U.type==="LANE"&&!U.parentId),Y=tn(M,O);if(!Y){x();return}if(oo({parentId:Y.id,nodes:e,excludeTypes:["LANE"]})){x(Y.id,!0);return}x(Y.id,!1,U=>h(M,Y.id,U));return}let B=D.filter(O=>O.id!==M.id&&O.type==="LANE"),G=tn(M,B);if(!G){x();return}if(oo({parentId:G.id,nodes:e,includeTypes:["LANE"]})){x();return}x(G.id)},b=M=>{let V=s(M.id),D=M.type==="LANE"&&oo({parentId:M.id,nodes:e,includeTypes:["LANE"]});v(V,D)},N=M=>M.map(V=>w(_({},V),{className:void 0})),T=M=>M.some(D=>D.dragging)?M.map(D=>D.dragging?w(_({},D),{dragging:!1}):D):M,A=(M,V)=>{let D=0;for(let I of V){if(I.id===M||I.parentId||I.type==="LANE")continue;let B=nt(I),G=B.y+B.h;D=Math.max(D,G)}return D+J0},C=(M,V)=>{if(!Yi(M,V))return V;let D=A(M,V);return V.map(I=>I.id===M?w(_({},I),{position:w(_({},I.position),{y:D})}):I)},P=M=>{if(M.preventDefault(),M.dataTransfer.dropEffect="move",!(r!=null&&r.type))return;let V=d({x:M.clientX,y:M.clientY}),D={id:"__sidebar_drag__",type:r.type,position:V,measured:{width:1,height:1},internals:{positionAbsolute:V}};v(D,!1)},R=M=>{let V=M.relatedTarget;(!V||!M.currentTarget.contains(V))&&x()},S=(M,V)=>{M.preventDefault(),b(V)},L=(M,V,D)=>{var F,U;let I=[...D],B=V.parentId?V.parentId:V.id;if(M.parentId===V.id)return I=Wi(M,V,I),I=Ut(I),I=no(B,I),N(I);if(M.type==="LANE"){if(oo({parentId:V.id,nodes:I,excludeTypes:["LANE"]})){let W=wr(V),oe=50,le=50;return I.map(Z=>{var xe,me;return Z.id===M.id?w(_({},Z),{position:{x:(xe=p==null?void 0:p.x)!=null?xe:W.x+oe,y:(me=p==null?void 0:p.y)!=null?me:W.y2+le}}):Z})}let te=I.filter(W=>W.parentId===V.id).reduce((W,oe)=>{var le,Z;return W+((Z=(le=oe.measured)==null?void 0:le.height)!=null?Z:0)},0),ie={x:se.HEADER_WIDTH,y:te};return I=I.map(W=>W.id===M.id?w(_({},W),{parentId:V.id,position:ie,className:void 0}):w(_({},W),{className:void 0})),I=Ut(I),I=C(B,I),I}if(oo({parentId:V.id,nodes:I,includeTypes:["LANE"]})){let X;if(M.parentId){let $=s(M.parentId),{x:te,y:ie}=nt($);X={x:te+((F=M.position.x)!=null?F:0),y:ie+((U=M.position.y)!=null?U:0)}}return I=I.map($=>$.id===M.id?w(_({},$),{position:X!=null?X:$.position,parentId:void 0,className:void 0}):w(_({},$),{className:void 0})),I=no(B,I),I}let O=ga(M,V);I=I.map(X=>X.id===M.id?w(_({},X),{parentId:V.id,position:O,className:void 0}):w(_({},X),{className:void 0}));let Y=I.find(X=>X.id===M.id);return I=Wi(Y,V,I),I=Ut(I),I=no(B,I),I},K=M=>{if(M.preventDefault(),!(r!=null&&r.type))return;if(!Yt(r.type,l())){m(!1),i(null);return}let V=d({x:M.clientX,y:M.clientY}),D={width:ue[r.type].MIN_WIDTH,height:ue[r.type].MIN_HEIGHT},I=u(),B={id:String(I),type:r.type,position:V,measured:D,data:{label:r.type==="TASK"?ni(e,a("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},G=w(_({},B),{internals:{positionAbsolute:V}}),k=w(_({},G),{measured:{width:1,height:1}}),O=f(),Y=r.type==="LANE",F=O.filter(W=>Y?W.type==="LANE"&&!W.parentId:W.type==="LANE"),U=tn(k,F),X=[...O.map(W=>w(_({},W),{selected:!1})),G];U&&(X=L(G,U,X)),X=en(X),Y&&!U&&(X=C(G.id,X)),X=N(X),t(X),E();let $=M.dataTransfer.getData("sourceId"),te=c(),ie=te;if($){let W={id:String(I+1),source:$,target:B.id},oe=r.type==="ANNOTATION"?_(_({},W),Oo):_(_({},W),it);ie=te.concat(oe),o(ie)}n("forceSave",{nodes:X,edges:ie}),m(!1),i(null)},j=async(M,V,D)=>{let I=[...f()],B=new Set;D.forEach(O=>{let Y=s(O.id),F=O.type==="LANE",U=I.filter($=>$.id!==O.id&&(F?$.type==="LANE"&&!$.parentId:$.type==="LANE")),X=tn(Y,U);if(X){if(F&&oo({parentId:O.id,nodes:I,includeTypes:["LANE"]})){O.parentId&&(I=z(O,I),B.add(O.id));return}I=L(Y,X,I);return}O.parentId&&(I=z(O,I),O.type==="LANE"&&B.add(O.id))}),I=T(I);let G=D.filter(O=>O.type==="LANE"&&!O.parentId).map(O=>O.id);for(let O of G)Yi(O,I)&&p&&(I=I.map(Y=>Y.id===O?w(_({},Y),{position:_({},p)}):Y));for(let O of B)I=C(O,I);if(D.some(O=>O.type!=="LANE"&&!O.parentId)){let O=I.filter(Y=>Y.type==="LANE"&&!Y.parentId).map(Y=>Y.id);for(let Y of O)I=no(Y,I)}I=en(I),I=N(I),t(I),y(I),g(null)},Q=(M,V)=>{g({x:V.position.x,y:V.position.y})},z=(M,V)=>{var U,X,$,te,ie,W,oe,le;let D=s(M.parentId);if(!D)return V;let I=M.type==="LANE",B=V.filter(Z=>Z.parentId===D.id&&Z.id!==M.id),G=B.filter(Z=>Z.type==="LANE"),k;if(I&&G.length===0)k=se.MIN_HEIGHT;else if(I){let Z=(X=(U=M.measured)==null?void 0:U.height)!=null?X:se.MIN_HEIGHT;k=((te=($=D.measured)==null?void 0:$.height)!=null?te:se.MIN_HEIGHT)-Z,k=Math.max(se.MIN_HEIGHT,k)}else k=B.length>0?B.reduce((Z,xe)=>{var me,_e;return Z+((_e=(me=xe.measured)==null?void 0:me.height)!=null?_e:0)},0)+Ne:Math.max(se.MIN_HEIGHT,(W=(ie=D.measured)==null?void 0:ie.height)!=null?W:0);let{x:O,y:Y}=nt(D),F={x:O+((oe=M.position.x)!=null?oe:0),y:Y+((le=M.position.y)!=null?le:0)};return V=V.map(Z=>Z.id===M.id?w(_({},Z),{position:F,parentId:void 0}):Z.id===D.id?w(_({},Z),{height:k,measured:w(_({},Z.measured),{height:k})}):Z),V=Ut(V),V};return{onDragOver:P,onDragLeave:R,onDrop:K,onNodeDrag:S,onNodeDragStart:Q,onNodeDragStop:j}};import{useReactFlow as Q0}from"@xyflow/react";import{useTranslation as j0}from"@produto-lecom/lecom-ui";import{useEffect as ex}from"react";var tx=30,ox=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},nx=e=>!ox(e.target),wu=({offset:e=tx,saveHistory:t})=>{let{t:o}=j0(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=Q0(),{getNextId:s}=at(),{mode:l,containerRef:c}=q();ex(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let u=m=>{if(d.contains(document.activeElement)&&m.ctrlKey&&m.key.toLowerCase()==="d"&&nx(m)){m.preventDefault(),m.stopPropagation();let y=n(),E=i(),p=y.filter(P=>P.selected);if(!p.length)return;let g=new Map,h=[],x=p.filter(P=>Yt(P.type,y));if(x.length===0)return;let v=E.filter(P=>x.some(R=>R.id===P.source)&&x.some(R=>R.id===P.target)),b=s(),N=x.map(P=>{var L;let R=String(b++);g.set(P.id,R);let S=w(_({},P),{id:R,selected:!0,position:{x:P.position.x+e,y:P.position.y+e}});if(P.type==="TASK"){let K=(L=P.data)==null?void 0:L.label,j=Xo(K||o("bpmn.task.label.prefix"),[...y,...h]);S.data=w(_({},P.data),{label:j})}return h.push(S),S}),T=v.map(P=>w(_({},P),{id:String(b++),selected:!0,source:g.get(P.source)||P.source,target:g.get(P.target)||P.target})),A=[...y.map(P=>w(_({},P),{selected:!1})),...N],C=[...E.map(P=>w(_({},P),{selected:!1})),...T];r(A),a(C),t("forceSave",{nodes:A,edges:C})}};return d.addEventListener("keydown",u,!0),()=>{d.removeEventListener("keydown",u,!0)}},[n,r,i,a,s,e,o,t,l,c])};import{useEffect as rx,useRef as Au}from"react";import{useReactFlow as ix}from"@xyflow/react";var sx=20,ax=50,Rn={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},lx=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},Iu=e=>{let{getNodes:t}=ix(),{mode:o,isMoveTool:n}=q(),r=Au(0),i=Au(new Map);rx(()=>{let a=s=>{if(o!=="edit"||!n||lx(s.target)||!Object.values(Rn).includes(s.key))return;let u=t().filter(h=>h.selected);if(u.length===0){i.current.clear();return}s.preventDefault();let m=Date.now(),f=m-r.current<500;r.current=m;let y=s.shiftKey?ax:sx,E=0,p=0;switch(s.key){case Rn.UP:p=-y;break;case Rn.DOWN:p=y;break;case Rn.LEFT:E=-y;break;case Rn.RIGHT:E=y;break}let g=u.map(h=>{let x=i.current.get(h.id);(!f||!x)&&(x={x:h.position.x,y:h.position.y});let v={x:x.x+E,y:x.y+p};return i.current.set(h.id,v),{id:h.id,dragging:!0,type:"position",position:v}});e&&e(g)};return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[t,e,o,n])};import{useReactFlow as dx}from"@xyflow/react";var Su={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY","gateway-parallel":"GATEWAY","gateway-complex":"GATEWAY"},Mu={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Cu=(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}},cx=e=>{e=e||"";let t=e.trim().split(`
42
- `),o={},n=[];return t.forEach(r=>{r=r||"";let i=r.trim().split("-->");if(i.length!==2){console.warn("Invalid number of steps");return}let a=Cu(i[0],o),s=Cu(i[1],o);a&&s&&n.push({sourceId:a.step,targetId:s.step,label:a.edgeLabel||s.edgeLabel||""})}),{components:o,connections:n}},Pu=e=>{let{components:t,connections:o}=cx(e);return{nodes:t,edges:o}};var ux=7,px=48,fx=340,mx=(e,t)=>{let o=px+e.length*ux;return Math.min(fx,Math.max(t,o))},pi=()=>{let{setNodes:e,setEdges:t}=dx(),{fitToNodes:o}=jt(),{getNextId:n}=at();return{importFromLia:i=>{let a=typeof i=="string"?i:i.diagramXml||"",{nodes:s,edges:l}=Pu(a),c=[],d=new Map,u=!1,m=n();for(let[h,x]of Object.entries(s)){let v=String(m++),b=Su[x.type],N=Mu[x.type];b==="START_EVENT"&&(u=!0),d.set(h,v);let T=ue[b].MIN_WIDTH,A=ue[b].MIN_HEIGHT;c.push({id:v,type:b,data:{label:x.label||"",variant:N,attribute:""},position:{x:0,y:0},width:T,height:A,measured:{width:T,height:A}})}let f=[];for(let h of l){let x=w(_({},it),{id:String(m++),source:d.get(h.sourceId)||h.sourceId,target:d.get(h.targetId)||h.targetId});f.push(x)}if(!u&&c.length>0){let h=String(m++),x={id:h,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:ue.START_EVENT.MIN_WIDTH,height:ue.START_EVENT.MIN_HEIGHT,measured:{width:ue.START_EVENT.MIN_WIDTH,height:ue.START_EVENT.MIN_HEIGHT}};c.unshift(x);let v=c[1];if(v){let b=w(_({},it),{id:String(m++),source:h,target:v.id});f.unshift(b)}}let y=c.map(h=>{var x,v;return h.type==="TASK"?w(_({},h),{width:mx(String((v=(x=h.data)==null?void 0:x.label)!=null?v:""),ue.TASK.MIN_WIDTH)}):h}),{nodes:E}=ti(y,f),p=new Map(E.map(h=>[h.id,h.position])),g=c.map(h=>{var x;return w(_({},h),{position:(x=p.get(h.id))!=null?x:h.position})});e(g),t(f),o(g)}}};import{useCallback as gx,useEffect as hx}from"react";var yx={origin:"*",debug:!1};function fi(e,t=yx){let{origin:o,debug:n}=t,r=gx((i,a)=>{let s={event:i,data:a};window.parent.postMessage(s,o||"*")},[o]);return hx(()=>{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}}import{useNodesInitialized as Ex}from"@xyflow/react";import{useEffect as mi,useRef as Ss}from"react";var Lu=()=>{let e=Ex(),{initialDiagram:t,isNewDiagram:o,setIsInitialized:n,onElementChanges:r}=q(),{importFromMxGraph:i,exportToMxGraph:a}=$o(),{sendMessage:s}=fi(),l=Ss(t),c=Ss(r),d=Ss(a);mi(()=>{c.current=r},[r]),mi(()=>{d.current=a},[a]),mi(()=>{t&&(i(t),l.current=t)},[t,i]),mi(()=>{if(!e)return;(async()=>{var m;if(await Fn(),n(!0),s("INIT_MODELER",l.current),!o){let f=d.current();(m=c.current)==null||m.call(c,f)}})()},[e,o,n,s])};import{useReactFlow as _x}from"@xyflow/react";import{useCallback as ku}from"react";function Ru(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=io(),{getEdges:n}=_x(),r=ku(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=ku(()=>{t()},[t]);return{handleTasksStatus:r,handleClearTaskStatus:i}}import{useReactFlow as bx}from"@xyflow/react";import{useCallback as Rt,useState as Tx,useEffect as Du}from"react";import{useDebouncedCallback as vx}from"use-debounce";var Nx=500,Ou=100,Vu=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=bx(),{mode:i,containerRef:a}=q(),[s,l]=Tx({history:[],currentStep:0}),{history:c,currentStep:d}=s,u=d>0,m=d<c.length-1,f=Rt((T,A)=>{n(T[A].nodes),r(T[A].edges)},[n,r]),y=Rt(()=>{if(d>0){let T=d-1;l(A=>w(_({},A),{currentStep:T})),f(c,T)}},[d,c,f]),E=Rt(()=>{if(d<c.length-1){let T=d+1;l(A=>w(_({},A),{currentStep:T})),f(c,T)}},[c,d,f]),p=Rt(T=>{l(A=>{let C=A.history[A.currentStep];if(C&&JSON.stringify(C)===JSON.stringify(T))return A;let S=[...A.history.slice(0,A.currentStep+1),T],L=S.length>Ou?S.slice(S.length-Ou):S;return{history:L,currentStep:L.length-1}})},[]),g=Rt((T,A)=>{let C=T.map(R=>w(_({},R),{selected:!1,className:"",data:w(_({},R.data),{hasError:!1})})),P=A.map(R=>w(_({},R),{data:w(_({},R.data),{hasError:!1})}));return{nodes:en(C),edges:P}},[]),h=Rt(()=>g(t(),o()),[t,o,g]),x=vx(()=>{let T=h();p(T)},Nx),v=Rt((T,A)=>{if(!e)return;if(c.length===0){let R=h();l({history:[R],currentStep:0})}if(T==="forceSave"){if(A){p(g(A.nodes,A.edges));return}x();return}T.some(R=>R.type==="select")||T.some(R=>R.type==="position"&&R.dragging)||x()},[e,x,c.length,h,p,g]);Du(()=>{if(e&&c.length===0){let T=h();l({history:[T],currentStep:0})}},[e,c.length,h]);let b=Rt(T=>{l({history:T||[],currentStep:0})},[]),N=Rt(()=>{l({history:[],currentStep:0})},[]);return Du(()=>{if(i!=="edit")return;let T=a.current;if(!T)return;let A=C=>{if(!T.contains(document.activeElement)||!(C.ctrlKey||C.metaKey))return;let S=C.key.toLowerCase();if(C.shiftKey&&S==="z"){C.preventDefault(),E();return}S==="z"&&(C.preventDefault(),y())};return T.addEventListener("keydown",A),()=>{T.removeEventListener("keydown",A)}},[y,E,i,a]),{history:c,undo:y,redo:E,canUndo:u,canRedo:m,saveHistory:v,resetHistory:b,clearHistory:N}};var Hu=()=>{let{t:e}=wx(),[t,o,n]=Ix([]),[r,i,a]=Ax([]),{getNodes:s,getNode:l}=Sx(),{toast:c}=Fe(),d=Mx(),{instanceId:u,isInitialized:m,setIsConnecting:f,setIsMultipleSelection:y,onElementClick:E}=q(),{updateHelperLines:p,HelperLines:g}=Cr(),{undo:h,redo:x,canUndo:v,canRedo:b,saveHistory:N}=Vu(m),{onNodeDrag:T,onDrop:A,onDragOver:C,onDragLeave:P,onNodeDragStop:R,onNodeDragStart:S}=Nu({nodes:t,setNodes:o,setEdges:i,saveHistory:N}),{isValidConnection:L,onConnect:K,onReconnect:j,onReconnectStart:Q,onReconnectEnd:z,setReconnectingEdge:M,clearReconnectingEdge:V}=du({setEdges:i,saveHistory:N}),{handleValidationComplete:D,clearValidation:I,dismissValidationPanel:B,validateDiagram:G,getIsClearingValidation:k}=_u(),{importFromLia:O}=pi(),{handleTasksStatus:Y,handleClearTaskStatus:F}=Ru(),{clearPathEdges:U}=io(),{emitElementChanges:X,handleNodeChanges:$,handleEdgeChanges:te}=ci(),ie=Ta();vu({saveHistory:N}),wu({saveHistory:N}),Lu();let W=Tt(()=>{o([]),i([]),U(),setTimeout(ie,0)},[o,i,U,ie]),{selectElements:oe,clearSelection:le}=xt(),{importFromMxGraph:Z,exportToMxGraph:xe}=$o(),{configureElement:me,getConfigureElement:_e}=Or(),J=Tt(he=>{he!=null&&he.id&&oe([he.id])},[oe]),{sendMessage:de}=fi({LIA_CREATE_DIAGRAM:O,CLEAR_DIAGRAM:W,TASKS_STATUS:Y,CLEAR_TASKS_STATUS:F,EXTERNAL_TASK_SELECT:J}),re=Tt(()=>t.length+r.length,[t,r]);Px(()=>(bt.set(u,{importFromMxGraph:Z,exportToMxGraph:xe,selectElements:oe,clearSelection:le,configureElement:me,getConfigureElement:_e,getElementsCount:re,setReconnectingEdge:M,clearReconnectingEdge:V}),()=>{bt.delete(u)}),[u,Z,xe,oe,le,me,_e,re,M,V]);let ee=Tt((he,fe)=>{if(fe.type!=="TASK"&&fe.type!=="GATEWAY")return;let pe=_e(fe.id);pe&&(E==null||E(pe)),fe.type==="TASK"&&de("SELECT_TASK",{id:fe.id})},[_e,E,de]),ge=Tt((he,fe)=>{if(fe.type!=="SEQUENCE_EDGE")return;let pe=l(fe.source),ve=l(fe.target),{isFromStartEvent:qe,isGatewayToGateway:ot,isActiviyToAndGateway:Be,isToEndEvent:gt}=Zn(pe,ve);if(!(!qe&&!ot&&!Be&&!gt))return;let wt=_e(fe.id);wt&&(E==null||E(wt))},[_e,l,E]),be=Tt(he=>{let fe=p(he,t);n(fe),N(he),k()||B(),$(he)},[t,n,N,k,B,p,$]),Te=Tt(he=>{a(he),N(he),k()||B(),te(he)},[a,N,k,B,te]);Iu(be);let ke=Tt(({nodes:he,edges:fe})=>{y(he.length+fe.length>=2)},[y]);Cx({onChange:ke});let tt=Tt(async({nodes:he})=>he.some(pe=>pe.type==="LANE"&&t.some(ve=>ve.parentId===pe.id))?(c({variant:"error",title:e("validation.errors.title"),content:e("editor.toolbar.delete_pool_lane_error")}),!1):!0,[t,e,c]),Nt=()=>{N("forceSave"),X(),B()},ft=()=>{f(!0)},mt=()=>{f(!1),B()},Ke=Tt(he=>{let fe=new Set(he.filter(pe=>pe.type==="LANE"&&!!pe.parentId).map(pe=>pe.parentId));fe.size!==0&&setTimeout(()=>{var qe,ot;let pe=s(),ve=new Map(pe.map(Be=>[Be.id,Be]));for(let Be of fe){let gt=ro(pe.filter(At=>At.type==="LANE"&&At.parentId===Be));if(gt.length===0)continue;let Dt=0;for(let At of gt)ve.set(At.id,w(_({},At),{position:{x:se.HEADER_WIDTH,y:Dt}})),Dt+=(ot=(qe=At.measured)==null?void 0:qe.height)!=null?ot:0;let wt=ve.get(Be);wt&&ve.set(Be,w(_({},wt),{height:Dt,measured:w(_({},wt.measured),{height:Dt})}))}o(pe.map(Be=>{var gt;return(gt=ve.get(Be.id))!=null?gt:Be}))},0)},[s,o]);return{nodes:t,setNodes:o,edges:r,setEdges:i,events:{isValidConnection:L,onConnect:K,onReconnect:j,onReconnectStart:Q,onReconnectEnd:z,onDrop:A,onDragOver:C,onDragLeave:P,onNodeDrag:T,onNodeDragStop:R,onNodeDragStart:S,onNodeClick:ee,onEdgeClick:ge,onDropCapture:Nt,onConnectStart:ft,onConnectEnd:mt,onSelectionEnd:()=>setTimeout(()=>d.setState({nodesSelectionActive:!1}),0),onNodesChange:be,onEdgesChange:Te,onBeforeDelete:tt,onNodesDelete:Ke},ui:{handleCloseValidationPanel:I},controls:{undo:h,redo:x,canUndo:v,canRedo:b},components:{HelperLines:g},actions:{saveHistory:N,selectElements:oe,clearSelection:le,exportToMxGraph:xe,validateDiagram:G,handleValidationComplete:D,setReconnectingEdge:M,clearReconnectingEdge:V}}};import{useReactFlow as Lx}from"@xyflow/react";import{useCallback as kx,useEffect as Rx,useRef as Dx,useState as Ox}from"react";var Vx=".react-flow__node, .react-flow__edge, .react-flow__node-toolbar";function Gu(e,t,o){let[n,r]=Ox(!1),i=Dx(null),{getViewport:a,setViewport:s}=Lx(),l=kx(()=>{i.current=null,r(!1)},[]);return Rx(()=>{let c=e.current;if(!c)return;let d=f=>{if(!Sn.some(E=>E===f.button)||t.current||o.current||(r(!0),!(f.target instanceof Element))||!f.target.closest(Vx))return;f.preventDefault(),f.stopPropagation();let y=a();i.current={pointerX:f.clientX,pointerY:f.clientY,viewportX:y.x,viewportY:y.y,zoom:y.zoom}},u=f=>{let y=i.current;if(y){if((f.buttons&Cs)===0){l();return}s({x:y.viewportX+(f.clientX-y.pointerX),y:y.viewportY+(f.clientY-y.pointerY),zoom:y.zoom})}},m=f=>{(f.buttons&Cs)===0&&l()};return c.addEventListener("pointerdown",d,!0),window.addEventListener("pointermove",u),window.addEventListener("pointerup",m),window.addEventListener("pointercancel",l),window.addEventListener("blur",l),()=>{c.removeEventListener("pointerdown",d,!0),window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",m),window.removeEventListener("pointercancel",l),window.removeEventListener("blur",l)}},[e,t,o,a,s,l]),n}import{jsx as Bu}from"react/jsx-runtime";var gi=({id:e,className:t})=>Bu("marker",{id:e,className:H("react-flow__arrowhead",t),viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"7",markerHeight:"7",orient:"auto",markerUnits:"userSpaceOnUse",fill:"currentColor",stroke:"currentColor",children:Bu("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as hi,jsxs as Hx}from"react/jsx-runtime";var zu=()=>hi("svg",{style:{position:"absolute",top:0,left:0},children:Hx("defs",{children:[hi(gi,{id:"sequence-edge-marker",className:"text-grey-500"}),hi(gi,{id:"sequence-edge-marker-hovered",className:"text-grey-800"}),hi(gi,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{Tooltip as H_,TooltipContent as G_,TooltipTrigger as B_,useTranslation as z_}from"@produto-lecom/lecom-ui";import{useKeyPress as mp,useReactFlow as n_}from"@xyflow/react";import{Button as vi,Tooltip as Ni,TooltipContent as wi,TooltipTrigger as Ai,useTranslation as r_}from"@produto-lecom/lecom-ui";import{HandIcon as i_,ListCheckIcon as s_,Loader2Icon as a_,MapIcon as l_,MousePointerIcon as c_}from"lucide-react";import{useCallback as Vs,useEffect as gp,useState as d_}from"react";import{Tooltip as rE,TooltipContent as iE,TooltipTrigger as sE,useTranslation as aE}from"@produto-lecom/lecom-ui";var Dn=(x=>(x.START_EVENT="START_EVENT",x.END_EVENT="END_EVENT",x.TASK="TASK",x.SUBPROCESS="SUBPROCESS",x.GATEWAY="GATEWAY",x.LANE="LANE",x.ANNOTATION="ANNOTATION",x.CONNECTION="CONNECTION",x.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",x.ACTIVITY="ACTIVITY",x.PROCESS_INTERFACE="PROCESS_INTERFACE",x.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",x.VARIANT_ACTIVITY="VARIANT_ACTIVITY",x.AUTO_ACTIVITY="AUTO_ACTIVITY",x.DATA_STORE="DATA_STORE",x.DATA_OBJECT="DATA_OBJECT",x.DATA_OUTPUT="DATA_OUTPUT",x.DATA_INPUT="DATA_INPUT",x.MARKER="MARKER",x))(Dn||{});import{Button as Zx,useTranslation as Jx}from"@produto-lecom/lecom-ui";import{useReactFlow as Qx}from"@xyflow/react";var Yu=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 Fu({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);yi(i,`${o}.csv`)}var yi=(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 Wu(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}var JD={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},Xu={script:"SCRIPT",subprocess:"SUBPROCESS"},Uu={"marker-loop":"LOOP"},$u={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL",inclusive:"EXCLUSIVE"};var Eo=({cell:e,type:t,variant:o="",attribute:n=""})=>{let{_attributes:r,mxGeometry:i}=e,{value: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}}},Bx=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=ue.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=ue.START_EVENT.MIN_HEIGHT,{node:Eo({cell:e,type:"START_EVENT"}),status:n,originalType:o}},zx=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=ue.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=ue.END_EVENT.MIN_HEIGHT,{node:Eo({cell:e,type:"END_EVENT"}),status:n,originalType:o}},Yx=(e,t)=>{let{id:o,subType:n,style:r}=e==null?void 0:e._attributes,i=Xu[n],a=t.get(o)||"",s=Uu[a]||"",l=s==="LOOP",c="imported";return!["script","none"].includes(n)&&!l&&(c="adapted"),e.mxGeometry._attributes.width=Ot(e.mxGeometry._attributes.width||0,ue.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=Ot(e.mxGeometry._attributes.height||0,ue.TASK.MIN_HEIGHT),{node:Eo({cell:e,type:"TASK",variant:i,attribute:s}),status:c,originalType:r}},Fx=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=$u[o],r=["none","inclusive","event-based"],i="imported";return r.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=ue.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=ue.GATEWAY.MIN_HEIGHT,{node:Eo({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},Wx=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:Eo({cell:e,type:"LANE"}),status:"imported",originalType:t}},Xx=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=Ot(e.mxGeometry._attributes.width||0,ue.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=Ot(e.mxGeometry._attributes.height||0,ue.ANNOTATION.MIN_HEIGHT),{node:Eo({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},Ku=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=ue.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=ue.UNSUPPORTED.MIN_HEIGHT,{node:Eo({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},qu=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return w(_({},it),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},Zu={TASK:Yx,GATEWAY:Fx,START_EVENT:Bx,END_EVENT:zx,LANE:Wx,ANNOTATION:Xx};var Ux=e=>{let t=new Map,o=Object.values(Dn),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=Zu[l]||Ku,{node:d,status:u,originalType:m}=c(s,r);a.push(d),i.push({originalType:m,type:d.type,variant:d.data.variant,value:Wu(d.data.label),status:u})}return{nodes:a,governanceIdToNodeIdMap:t,summary:i}},$x=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>qu(r,t)),Kx=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=Ux(t.root.mxCell),i=$x(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},qx=async e=>{let t=await Yu(e),o=Jr(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}},Ju=async e=>{try{let t=await qx(e),{nodes:o,edges:n,summary:r}=Kx(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};import{jsx as jx}from"react/jsx-runtime";var Qu=()=>{let{t:e}=Jx(),{toast:t}=Fe(),{setNodes:o,setEdges:n}=Qx(),{fitToNodes:r}=jt(),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:jx(Zx,{size:"small",variant:"ghost",onClick:()=>Fu({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 Ju(s);if(o(m=>m.concat(l)),n(m=>m.concat(c)),r(l),d.some(m=>m.status==="unsupported")){i(d);return}t({variant:"success",content:e("adapter.governance.success.default")})}catch(l){let c=l instanceof Error?l.message:"DEFAULT";t({variant:"error",content:e(`adapter.governance.error.${c}`)})}}}};import{Button as eE}from"@produto-lecom/lecom-ui";import{useRef as tE}from"react";import{Fragment as oE,jsx as ju,jsxs as nE}from"react/jsx-runtime";var ep=s=>{var l=s,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,a=ht(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=tE(null),d=m=>{let f=m.target.files;f!=null&&f.length&&i(f),c.current&&(c.current.value="")};return nE(oE,{children:[ju(eE,w(_({disabled:n,onClick:m=>{var f;(f=c.current)==null||f.click(),r==null||r(m)}},a),{children:e})),ju("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};import{jsx as xi,jsxs as lE}from"react/jsx-runtime";var tp=({disabled:e=!1})=>{let{t}=aE(),{toast:o}=Fe(),{importFromGovernance:n}=Qu(),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 lE(rE,{children:[xi(sE,{asChild:!0,children:xi(ep,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:xi(oa,{})})}),xi(iE,{color:"black",children:t("editor.controls.actions.import_governance")})]})};import{jsx as cE}from"react/jsx-runtime";var Ms=({shortcut:e})=>cE("span",{className:"min-h-7.5 inline-flex justify-center items-center py-0.5 px-1.5 bg-grey-100 border border-grey-300 font-mono text-gray-800 shadow-lg rounded-md text-grey-900",children:e});import{Button as EE,DropdownMenu as _E,DropdownMenuContent as bE,DropdownMenuItem as Ls,DropdownMenuTrigger as TE,Tooltip as _i,TooltipContent as bi,TooltipTrigger as Ti,useTranslation as vE}from"@produto-lecom/lecom-ui";import{FileCodeIcon as NE,FileImageIcon as wE,FolderOutputIcon as AE,PrinterIcon as IE}from"lucide-react";import{useState as CE}from"react";import{useTranslation as dE}from"@produto-lecom/lecom-ui";import{useReactFlow as uE}from"@xyflow/react";import{toPng as op,toSvg as pE}from"html-to-image";import{useState as fE}from"react";var mE=3,Ps="diagram",Ei=50,gE=96,hE=25.4,yE="sequence-edge-marker",np=e=>e*hE/gE,xE=e=>{let t=document.getElementById(yE);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},rp=()=>{let{t:e}=dE(),{toast:t}=Fe(),{getEdges:o,getNodes:n,getNodesBounds:r}=uE(),{clearSelection:i}=xt(),[a,s]=fE({png:!1,html:!1,print:!1}),l=()=>{let f=gs(n(),o()),y=r(f),E=y.width+Ei*2,p=y.height+Ei*2,g=Ei-y.x,h=Ei-y.y;return{width:E,height:p,style:{width:`${E}px`,height:`${p}px`,transform:`translate(${g}px, ${h}px)`,transformOrigin:"top left"}}},c=async(f,y)=>{s(E=>w(_({},E),{[y]:!0})),await i();try{if(gs(n(),o()).length===0){t({content:e("editor.controls.actions.export.feedback.empty"),variant:"warning"});return}let p=fd();if(!p)throw new Error("Flow element not found");let g=l(),h=xE(p);try{return await f(p,g)}finally{h==null||h.remove()}}catch(E){console.error("Diagram export failed",E),t({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{s(E=>w(_({},E),{[y]:!1}))}};return{exportAsPng:async(f=Ps)=>{await c(async(y,E)=>{let p=await op(y,w(_({},E),{backgroundColor:"#fcfcfc",skipFonts:!0}));yi(p,`${f}.png`)},"png")},exportAsHtml:async(f=Ps)=>{await c(async(y,E)=>{let p=await pE(y,w(_({},E),{backgroundColor:"#fcfcfc",skipFonts:!0})),g=`
38
+ </mxGraphModel>`,jc=(e,t)=>{if(!e.length&&!t.length)return An;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};import{xml2json as Xh,json2xml as Uh}from"xml-js";var ed={compact:!0,spaces:4},$h=e=>e.replace(/\n/g,"&#xA;");function Qr(e,t=ed){if(e)return JSON.parse(Xh(e,t))}function td(e,t=ed){return e?Uh(e,w(_({},t),{attributeValueFn:$h})):""}var od={"attribute-loop":"LOOP"},nd={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS","service-task":"SERVICE_TASK"},rd={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},id={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed",SERVICE_TASK:"service-task"},sd={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var Fo=(e,t,o,n,r,i)=>{let a=e._attributes.width||0,s=e._attributes.height||0,l=0,c=0;if(n&&r!==void 0&&i!==void 0){let y=n.split(`
39
+ `),E=y.length;l=y.reduce((g,h)=>Math.max(g,h.length),0)*7+r,c=E*20+i}let d=Math.max(Vt(Number(a),t),l),p=Math.max(Vt(Number(s),o),c);return{width:d,height:p,measured:{width:d,height:p}}},Wo=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,parent:r,value:i}=t,a={x:Number(o._attributes.x||0),y:Number(o._attributes.y||0)},s={id:n,position:a,data:{label:i||""}},l=r==="1"?void 0:r;return l&&(s.parentId=l),s},qh=e=>{let{mxGeometry:t}=e,o=Wo(e),n=Fo(t,ue.START_EVENT.MIN_WIDTH,ue.START_EVENT.MIN_HEIGHT);return w(_(_({},o),n),{type:"START_EVENT"})},Zh=e=>{let{mxGeometry:t}=e,o=Wo(e),n=Fo(t,ue.END_EVENT.MIN_WIDTH,ue.END_EVENT.MIN_HEIGHT);return w(_(_({},o),n),{type:"END_EVENT"})},jr=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=Wo(e),s=Fo(n,ue.TASK.MIN_WIDTH,ue.TASK.MIN_HEIGHT,r.data.label,48,24),l=t==null?void 0:t.find(d=>{let{parent:p}=d._attributes;return p===e._attributes.id});if(l){let{style:d}=l._attributes,p=od[d];p&&(r.data.attribute=p)}let c=nd[o.style];return c&&(r.data.variant=c),w(_(_({},r),s),{type:"TASK"})},hs=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=Wo(e),i=Fo(o,ue.GATEWAY.MIN_WIDTH,ue.GATEWAY.MIN_HEIGHT);return r.data.variant=rd[n],w(_(_({},r),i),{type:"GATEWAY"})},Jh=e=>{let{mxGeometry:t}=e,o=Wo(e),i=Fo(t,ue.ANNOTATION.MIN_WIDTH,ue.ANNOTATION.MIN_HEIGHT,o.data.label,32,24);return w(_(_({},o),i),{type:"ANNOTATION"})},Qh=e=>{let{mxGeometry:t}=e,o=Wo(e),n=Fo(t,ue.LANE.MIN_WIDTH,ue.LANE.MIN_HEIGHT);return w(_(_({},o),n),{type:"LANE"})},ad={task:jr,"task-script":jr,"subprocess-collapsed":jr,"service-task":jr,"start-event":qh,"end-event-terminate":Zh,"gateway-parallel":hs,"gateway-exclusive":hs,"gateway-complex":hs,annotation:Jh,lane:Qh},jh=e=>{if(e&&Array.isArray(e))return e.map(t=>({x:Number(t._attributes.x),y:Number(t._attributes.y)}))},ld=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,source:r,target:i,value:a,style:s,sourceHandle:l,targetHandle:c,sourceOffset:d,targetOffset:p,labelOffsetX:f,labelOffsetY:m}=t,y=jh(o==null?void 0:o.Array),E=d!==void 0?Number(d):void 0,u=p!==void 0?Number(p):void 0,g=f!==void 0?Number(f):void 0,h=m!==void 0?Number(m):void 0,x=w(_(_({id:n,source:r,target:i},l?{sourceHandle:l}:{}),c?{targetHandle:c}:{}),{data:_(_(_(_({label:a||""},y&&y.length>0?{points:y}:{}),E!==void 0?{sourceOffset:E}:{}),u!==void 0?{targetOffset:u}:{}),g!==void 0&&h!==void 0?{labelOffset:{x:g,y:h}}:{})});return s.includes("association")&&s.includes('endArrow=""')?_(_({},Ho),x):_(_({},st),x)},cd=(e,t)=>{var m,y;let{id:o,type:n,source:r,target:i,sourceHandle:a,targetHandle:s,data:l}=e,c=t==null?void 0:t.find(E=>E.id===r),d="";n==="ANNOTATION_EDGE"&&(d='association;endArrow=""');let p={_attributes:{as:"geometry",relative:"1"}};return l!=null&&l.points&&Array.isArray(l.points)&&l.points.length>0&&(p.Array=l.points.map(E=>({_attributes:{as:"mxPoint",x:E.x,y:E.y}}))),{_attributes:{id:o,parent:(c==null?void 0:c.parentId)||"1",edge:"1",style:d,source:r,target:i,value:(l==null?void 0:l.label)||"",sourceHandle:a!=null?a:void 0,targetHandle:s!=null?s:void 0,sourceOffset:(l==null?void 0:l.sourceOffset)!==void 0?String(l.sourceOffset):void 0,targetOffset:(l==null?void 0:l.targetOffset)!==void 0?String(l.targetOffset):void 0,labelOffsetX:((m=l==null?void 0:l.labelOffset)==null?void 0:m.x)!==void 0?String(l.labelOffset.x):void 0,labelOffsetY:((y=l==null?void 0:l.labelOffset)==null?void 0:y.y)!==void 0?String(l.labelOffset.y):void 0},mxGeometry:p}},Xo=e=>{let{id:t,parentId:o,position:n,measured:r,data:i}=e;return{_attributes:{id:t,parent:o||"1",value:i.label,vertex:"1"},mxGeometry:{_attributes:{as:"geometry",width:(r==null?void 0:r.width)||0,height:(r==null?void 0:r.height)||0,x:n.x||0,y:n.y||0}}}},ey=e=>{let{variant:t}=e.data,o=Xo(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:id[t]||"task"})})},ty=e=>{let t=Xo(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"start-event"})})},oy=e=>{let t=Xo(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"end-event-terminate"})})},ny=e=>{let{variant:t}=e.data,o=Xo(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:sd[t]})})},ry=e=>{let t=Xo(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"lane"})})},iy=e=>{let t=Xo(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"annotation"})})},dd={TASK:ey,START_EVENT:ty,END_EVENT:oy,GATEWAY:ny,ANNOTATION:iy,LANE:ry},ud=(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 sy=e=>{let t=Object.values(In),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=ad[a],l=s==null?void 0:s(i,n);if(!l){console.warn(`Node ${a} not supported`);continue}r.push(l)}return r},ay=(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=ld(r),a=t.find(c=>c.id===i.source),s=t.find(c=>c.id===i.target);((a==null?void 0:a.type)==="LANE"||(s==null?void 0:s.type)==="LANE")&&i.type!=="ANNOTATION_EDGE"||n.push(i)}return n},ly=(e,t)=>{let o=[];return e.forEach(n=>{var a,s;let r=(s=(a=dd)[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=ud(n,t);o.push(l)}}),o},cy=(e,t)=>{let o=[];return e.forEach(n=>{let r=cd(n,t);o.push(r)}),o},dy=(e=[],t=[],o)=>{let n=ly(e,o),r=cy(t,e);return{mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}}},pd=(e=[],t=[],o)=>{let n=dy(e,t,o);return td(JSON.stringify(n),{compact:!0,spaces:0})},fd=async e=>{var a,s,l,c,d;let t=await Qr(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)||An),r=sy(o),i=ay(o,r);return{lastElementId:n,edges:i,nodes:r}};import{useReactFlow as R0,useStoreApi as D0}from"@xyflow/react";import{useCallback as O0}from"react";import{Position as Kt,useConnection as Qy,useReactFlow as jy}from"@xyflow/react";import{useCallback as Ts}from"react";import{Handle as md,useReactFlow as uy}from"@xyflow/react";import{jsx as gd}from"react/jsx-runtime";var ne=i=>{var a=i,{type:e,position:t,className:o,nodeType:n}=a,r=yt(a,["type","position","className","nodeType"]);let s=n==="TASK";return gd(md,_({type:e,position:t,className:H("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":s,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":!s},o)},r))},ze=s=>{var l=s,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,a=yt(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=uy(),f=(()=>{if(n!=="source")return!1;let m=c();if(t==="TASK")return m.filter(E=>E.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return m.filter(E=>E.source===e).length>=2;if(t==="START_EVENT"){let y=d();return m.filter(u=>{if(u.source!==e)return!1;let g=y.find(h=>h.id===u.target);return(g==null?void 0:g.type)!=="ANNOTATION"}).length>=1}return!1})();return gd(md,_({type:n,position:r,className:H("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":f,"hover:border-grey-500":!f},i),style:{pointerEvents:f?"none":"auto"}},a))};import{useRef as Ed}from"react";import{NodeResizeControl as _d,ResizeControlVariant as xy,useReactFlow as Ey,useStoreApi as _y}from"@xyflow/react";import{useStoreApi as py}from"@xyflow/react";var ei=()=>{let e=py();return{getInternalNodes:()=>{let{nodeLookup:o}=e.getState();return Array.from(o.values())}}};import hd from"@dagrejs/dagre";import{getNodesBounds as ti}from"@xyflow/react";var oi=(e=[],t=[],o="LR")=>{let n=new hd.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)),hd.layout(n),{nodes:e.map(i=>{let a=n.node(i.id);return w(_({},i),{position:{x:a.x-i.width/2,y:a.y-i.height/2}})}),edges:t}},$t=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId);if(t.length===0)return e;let o=xa(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){Na(a,o,r),wa(n,o);continue}Xi(n,i,o)}return Ea(e,o)};var xd=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)};var fy=500;var my=e=>e.type==="LANE"&&!e.parentId,gy=(e,t)=>{let o=e.x+e.width,n=e.y+e.height,r=t.x+t.width,i=t.y+t.height;return e.x<=t.x&&e.y<=t.y&&o>=r&&n>=i},hy=(e,t)=>{let o=e.x+e.width,n=e.y+e.height,r=t.x+t.width,i=t.y+t.height,a=Math.max(e.x-r,t.x-o,0),s=Math.max(e.y-i,t.y-n,0);return Math.hypot(a,s)},yy=e=>{let t=new Set;for(let o of e)t.add(o.source),t.add(o.target);return t},yd=(e,t,o)=>{if(e.type!=="ANNOTATION"||o.has(e.id))return!1;let n=ti([e]);return hy(t,n)>fy},ys=(e,t=[])=>{var E;let o=e.filter(my);if(o.length===0)return e;let n=new Map;for(let u of e){if(!u.parentId)continue;let g=(E=n.get(u.parentId))!=null?E:[];g.push(u.id),n.set(u.parentId,g)}let r=new Set,i=o.map(u=>u.id);for(;i.length>0;){let u=i.pop();if(!u||r.has(u))continue;r.add(u);let g=n.get(u);if(g)for(let h of g)r.has(h)||i.push(h)}let a=e.filter(u=>r.has(u.id));if(a.length===0)return e;let s=yy(t),l=a.filter(u=>u.type!=="ANNOTATION"),c=ti(l.length>0?l:a),d=a.filter(u=>!yd(u,c,s)),p=ti(d),y=e.filter(u=>!r.has(u.id)).filter(u=>{let g=ti([u]);return!gy(p,g)}).filter(u=>!yd(u,p,s));return[...d,...y]};import{Fragment as vy,jsxs as Ny}from"react/jsx-runtime";import{createElement as bd}from"react";var by=["top","right","bottom","left"],Ty=["top-left","top-middle","top-right","right-middle","bottom-left","left-middle","bottom-right","bottom-middle"],at=r=>{var i=r,{nodeId:e,isVisible:t,offset:o=8}=i,n=yt(i,["nodeId","isVisible","offset"]);let{getInternalNode:a,setNodes:s}=Ey(),{getInternalNodes:l}=ei(),{isMultipleSelection:c}=q(),d=_y(),p=Ed(0),f=Ed([]),m=({y:g,width:h,height:x})=>{cancelAnimationFrame(p.current),p.current=requestAnimationFrame(()=>{var j,Q;if(!e)return;let{nodeLookup:T,onNodesChange:b}=d.getState(),N=T.get(e);if(!N||N.type!=="LANE")return;let v=!N.parentId,I=v?N.id:N.parentId;if(!I)return;let C=Array.from(T.values()).filter(z=>z.type==="LANE"&&z.parentId===I);if(!C.length)return;f.current.length===0&&(f.current=so(C).map(z=>z.id));let P=f.current.map(z=>C.find(M=>M.id===z)).filter(Boolean),R=[],S=0,L=P.findIndex(z=>z.id===N.id),K=!v&&L>0&&Math.abs(g-N.position.y)>.5;for(let z=0;z<P.length;z++){let M=P[z],V=M.id===N.id,D=z===P.length-1;if(V){S=K?g+x:S+x;continue}let A=(Q=(j=M.measured)==null?void 0:j.height)!=null?Q:0,B=v?h-se.HEADER_WIDTH:h,G=A;v&&D&&(G=Math.max(se.MIN_HEIGHT,x-S)),K&&z===L-1&&(G=Math.max(se.MIN_HEIGHT,g-S)),R.push({id:M.id,type:"dimensions",dimensions:{width:B,height:G},setAttributes:!0}),R.push({id:M.id,type:"position",position:{x:se.HEADER_WIDTH,y:S}}),S+=G}v?R.push({id:I,type:"dimensions",dimensions:{width:h,height:x},setAttributes:!0}):R.push({id:I,type:"dimensions",dimensions:{width:h+se.HEADER_WIDTH,height:S},setAttributes:!0}),b==null||b(R)})},y=({y:g,width:h,height:x})=>{var N;if(cancelAnimationFrame(p.current),f.current=[],!e)return;let T=a(e);if(!T||T.type!=="LANE"&&!T.parentId)return;let b=[...l()];if(T.type!=="LANE"){b=b.map(v=>v.id===e?w(_({},v),{width:h,height:x,measured:{width:h,height:x}}):v),b=$t(b),s(b);return}b=Ia(T,h,x,b,g),b=$t(b),b=io((N=T.parentId)!=null?N:T.id,b),s(b)};if(!(!c&&t))return null;let u={"--resize-offset":`${o}px`};return Ny(vy,{children:[by.map(g=>bd(_d,w(_({},n),{key:g,nodeId:e,position:g,variant:xy.Line,className:"border-blue-400/90 border-dashed",style:u,onResize:(h,x)=>m(x),onResizeEnd:(h,x)=>y(x)}))),Ty.map(g=>bd(_d,w(_({},n),{key:g,nodeId:e,position:g,className:"size-1.5 bg-blue-400 relative before:content-[''] before:absolute before:w-5 before:h-5 before:left-1/2 before:top-1/2 before:-translate-x-1/2 before:-translate-y-1/2 before:cursor-[inherit]",style:u,onResize:(h,x)=>m(x),onResizeEnd:(h,x)=>y(x)})))]})};import{NodeToolbar as Yy,useReactFlow as Fy}from"@xyflow/react";import{Button as Wy,Tooltip as Xy,TooltipContent as Uy,TooltipTrigger as $y,useTranslation as Ky}from"@produto-lecom/lecom-ui";import{useCallback as bs,useEffect as qy,useRef as ni,useState as Zy}from"react";import{create as wy}from"zustand";var Uo=wy(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{useEffect as Iy,useState as Ay}from"react";var Td=(e,t=!1)=>{let[o,n]=Ay({width:0,height:0});return Iy(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};import{Position as Cn,useReactFlow as Cy}from"@xyflow/react";import{useMemo as Sy}from"react";var My=120,Py=12,vd=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=Cy(),{instanceId:i}=q();return Sy(()=>{var m,y;if(!t)return{position:Cn.Right,align:"start"};let a=n(e);if(!a)return{position:Cn.Right,align:"start"};let s=r(),l=a.position.x*s.zoom+s.x,c=(((m=a.measured)==null?void 0:m.width)||a.width||100)*s.zoom,d=(y=document.getElementById(`modeler-${i}`))==null?void 0:y.clientWidth;if(!d)return{position:Cn.Right,align:"start"};let p=(o==null?void 0:o.width)||My;return{position:l+c+p+Py>d?Cn.Left:Cn.Right}},[i,e,t,o,n,r])};import{Bot as Id}from"lucide-react";import{useNodesData as Ly,useReactFlow as ky}from"@xyflow/react";import{Button as Nd,DropdownMenu as Ry,DropdownMenuContent as Dy,DropdownMenuGroup as Oy,DropdownMenuItem as Vy,DropdownMenuLabel as Hy,DropdownMenuTrigger as Gy,Tooltip as xs,TooltipContent as Es,TooltipTrigger as _s,useTranslation as By}from"@produto-lecom/lecom-ui";import{WrenchIcon as zy}from"lucide-react";import{jsx as Ve,jsxs as yo}from"react/jsx-runtime";var wd=({nodeId:e})=>{let{t}=By(),{updateNodeData:o,getEdges:n,getNode:r}=ky(),i=Ly(e),s=n().filter(y=>y.source===e).some(y=>{let E=r(y.target);return(E==null?void 0:E.type)==="END_EVENT"}),l=(i==null?void 0:i.data.variant)==="SUBPROCESS",c=(i==null?void 0:i.data.variant)==="SERVICE_TASK",d=f=>{o(e,{variant:(i==null?void 0:i.data.variant)===f?"":f})},p=f=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===f?"":f})};return yo(Ry,{children:[yo(xs,{children:[Ve(_s,{asChild:!0,children:Ve(Gy,{asChild:!0,children:Ve(Nd,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:Ve(zy,{})})})}),Ve(Es,{color:"black",children:t("bpmn.task.menu.title")})]}),yo(Dy,{align:"start",className:"w-60 bg-white text-grey-600",children:[yo(Hy,{className:"flex items-center gap-1",children:[Ve("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),Ve("div",{className:"flex items-center gap-1",children:Object.entries(Kn).map(([f,m])=>{let y=f==="LOOP"&&(s||l||c),u=(()=>{if(f==="LOOP"&&s)return t("editor.task_menu.loop_not_allowed_when_connected_to_end");if(f==="LOOP"&&l)return t("editor.task_menu.loop_not_allowed_when_subprocess");if(f==="LOOP"&&c)return t("editor.task_menu.loop_not_allowed_when_service_task");if(f==="LOOP")return t("editor.task_menu.loop")})();return yo(xs,{children:[Ve(_s,{asChild:!0,children:Ve(Nd,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:y,className:H({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===f,"opacity-50 cursor-not-allowed":y}),onClick:y?void 0:()=>p(f),children:Ve(m.icon,{className:"stroke-inherit"})})}),u&&Ve(Es,{color:"black",children:u})]},f)})})]}),Ve(Oy,{children:yo(xs,{children:[Ve(_s,{asChild:!0,children:Ve("div",{className:H({"cursor-not-allowed":s}),children:yo(Vy,{className:H({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":s}),disabled:s,onClick:()=>d("SCRIPT"),children:[Ve($n.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),s&&Ve(Es,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};import{jsx as Pe,jsxs as Ad}from"react/jsx-runtime";var kt={START_EVENT:{type:"START_EVENT",icon:Qo,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:No,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:Qo,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:Fn,label:"bpmn.annotation.variant.default"}},Jy={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:Io,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:Ao,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:wo,label:"bpmn.gateway.variant.complex"}},Xe=({nodeId:e,nodeType:t,nodeVariant:o,isChild:n})=>{let r=ni(null),i=ni(null),{t:a}=Ky(),{setDraggableNode:s}=Uo(),{getEdges:l,getNodes:c,getNode:d,setNodes:p}=Fy(),{setIsDragging:f,mode:m,isConnecting:y,isDragging:E,isMultipleSelection:u}=q(),g=d(e),h=!!(g!=null&&g.selected)&&!g.dragging&&!y&&!E&&!u,{dimensions:x}=Td(r,h),{position:T}=vd(e,h,x),[b,N]=Zy(void 0),v=c(),I=l(),C=o==="SUBPROCESS",P=o==="SERVICE_TASK",R=ni(null),S=ni(!1),L=bs(()=>{R.current!==null&&(clearTimeout(R.current),R.current=null),S.current=!1,f(!1),s(null),N(void 0),p(F=>F.map(U=>w(_({},U),{className:void 0})))},[f,s,p]);qy(()=>{let F=U=>{S.current&&U.buttons===0&&L()};return document.addEventListener("dragend",L),document.addEventListener("mousemove",F),()=>{document.removeEventListener("dragend",L),document.removeEventListener("mousemove",F)}},[L]);let K=bs((F,U)=>{S.current=!0,f(!1),s({type:U.type,variant:U.variant,attribute:U.attribute,icon:U.icon}),U.icon&&N(Pe(U.icon,{})),F.dataTransfer.effectAllowed="move",F.dataTransfer.setData("sourceId",e),i.current&&F.dataTransfer.setDragImage(i.current,10,10),R.current=setTimeout(()=>{R.current=null,f(!0)},100)},[e,s,f]),j=bs(()=>{L()},[L]),Q=[{component:Pe(Br,{elementId:e})}],z=()=>{if(m==="view")return[];let F=!I.some(U=>{var X;return U.source===e&&((X=v.find($=>$.id===U.target))==null?void 0:X.type)!=="ANNOTATION"});return[{component:Pe(Do,{nodeId:e,disabled:!F,tooltipMessage:F?void 0:a("editor.toolbar.start_event_limit_reached")})},kt.TASK,kt.ANNOTATION,...Q]},M=()=>m==="view"?[{component:Pe(Wt,{elementId:e})}]:[{component:Pe(Wt,{elementId:e})},...C||P?[]:[{component:Pe(wd,{nodeId:e})}],{component:Pe(Do,{nodeId:e})},kt.TASK,{type:"TASK",variant:"SUBPROCESS",icon:en,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:Id,label:"bpmn.task.variant.service_task"},kt.ANNOTATION,...Object.values(Jy),...mo(e,v,I)?[]:[kt.END_EVENT],...Q],V=()=>m==="view"?[{component:Pe(Wt,{elementId:e,elementType:"gateway"})}]:[{component:Pe(Wt,{elementId:e,elementType:"gateway"})},{component:Pe(Do,{nodeId:e})},kt.TASK,{type:"TASK",variant:"SUBPROCESS",icon:en,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:Id,label:"bpmn.task.variant.service_task"},kt.ANNOTATION,...Q],D=()=>m==="view"?[]:[kt.ANNOTATION,...Q],A=()=>m==="view"?[]:[...n?[]:[{component:Pe(Do,{nodeId:e})}],kt.ANNOTATION,...Q],B=()=>m==="view"?[]:[{component:Pe(Do,{nodeId:e})},...Q],G=()=>m==="view"?[]:[...Q],O=(F=>{switch(F){case"START_EVENT":return z();case"TASK":return M();case"GATEWAY":return V();case"END_EVENT":return D();case"LANE":return A();case"ANNOTATION":return B();case"UNSUPPORTED":return G();default:return[]}})(t),Y=O.length>6;if(!(O.length===0||m==="readonly"))return Ad(Yy,{position:T,align:"start",className:Y?"-top-[4.5rem]":"-top-8",isVisible:h,children:[Pe("div",{ref:r,className:`${Y?"grid grid-cols-6":"flex"} gap-1 px-2 py-2 bg-white rounded-sm shadow-md`,children:O.map((F,U)=>{if(F.component)return Pe("div",{children:F.component},U);let X={sourceNodeType:t,targetNodeType:F.type,sourceNodeId:e,nodes:v,edges:I},$=Mc(X),te={gateway_limit_reached:a("editor.toolbar.gateway_limit_reached"),start_event_limit_reached:a("editor.toolbar.start_event_limit_reached"),start_event_already_exists:a("editor.toolbar.start_event_already_exists"),script_to_end_not_allowed:a("editor.toolbar.script_to_end_not_allowed"),loop_to_end_not_allowed:a("editor.toolbar.loop_to_end_not_allowed"),initial_activity_to_end_not_allowed:a("editor.toolbar.initial_activity_to_end_not_allowed"),final_activity_cannot_connect:a("editor.toolbar.final_activity_cannot_connect"),activity_has_outgoing_connections:a("editor.toolbar.activity_has_outgoing_connections"),task_limit_reached:a("editor.toolbar.task_limit_reached"),start_event_to_service_task_not_allowed:a("editor.toolbar.start_event_to_service_task_not_allowed"),service_task_to_end_not_allowed:a("editor.toolbar.service_task_to_end_not_allowed")},ie=$.shouldDisable&&$.reason?te[$.reason]||a(F.label):a(F.label)||"";return Ad(Xy,{children:[Pe($y,{asChild:!0,children:Pe(Wy,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!$.shouldDisable,disabled:$.shouldDisable,className:$.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:$.shouldDisable?void 0:W=>K(W,F),onDragEnd:$.shouldDisable?void 0:j,children:F.icon&&Pe(F.icon,{size:16})})}),Pe(Uy,{color:"black",children:ie})]},U)})}),Pe("div",{ref:i,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:b})]})};import{Fragment as Cd,jsx as pt,jsxs as vs}from"react/jsx-runtime";var Sd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r,setNodes:i}=jy(),{inProgress:a,fromNode:s}=Qy(),{mode:l,isReadOnly:c}=q(),d=a&&(s==null?void 0:s.id)!==e,p=Ts(y=>{let x=y.split(`
40
+ `),T=x.reduce((I,C)=>Math.max(I,C.length),0),b=x.length,N=Math.max(So.MIN_WIDTH,T*7+32),v=Math.max(So.MIN_HEIGHT,b*20+24);i(I=>I.map(C=>C.id===e?w(_({},C),{width:N,height:v,style:w(_({},C.style),{width:N,height:v})}):C))},[e,i]),f=Ts(y=>{r(e,{label:y}),p(y)},[e,r,p]),m=Ts(y=>{p(y)},[p]);return vs("div",{className:H("relative w-full h-full min-w-44 min-h-16 flex text-grey-400 hover:text-grey-500 bg-white rounded-sm border-l-2 border-current before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-current after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-current hover:shadow-md transition-colors duration-75",{"pointer-events-none":c,"text-blue-500 hover:text-blue-600 shadow-md":o&&!c,"border-red-500 border-l-[3px] shadow-[0_0_5px_rgba(255,0,0,0.5)] before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-red-500 after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-red-500":t.hasError}),children:[pt(Oe,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:f,onInput:m,skipFirstCharValidation:!0}),pt(Xe,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&pt(at,{nodeId:e,minWidth:So.MIN_WIDTH,minHeight:So.MIN_HEIGHT,isVisible:!n&&o}),!a&&vs(Cd,{children:[pt(ne,{type:"source",position:Kt.Left,id:"left"}),pt(ne,{type:"source",position:Kt.Right,id:"right"}),pt(ne,{type:"source",position:Kt.Top,id:"top"}),pt(ne,{type:"source",position:Kt.Bottom,id:"bottom"})]}),(!a||d)&&vs(Cd,{children:[pt(ne,{type:"target",position:Kt.Left,id:"left",className:H({"annotation-handle":d})}),pt(ne,{type:"target",position:Kt.Right,id:"right",className:H({"annotation-handle":d})}),pt(ne,{type:"target",position:Kt.Top,id:"top",className:H({"annotation-handle":d})}),pt(ne,{type:"target",position:Kt.Bottom,id:"bottom",className:H({"annotation-handle":d})})]})]})};import{Position as qt,useConnection as e0,useReactFlow as t0}from"@xyflow/react";import{useState as o0}from"react";import{Fragment as Md,jsx as Qe,jsxs as Ns}from"react/jsx-runtime";var Pd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=t0(),{inProgress:i,fromNode:a}=e0(),{mode:s,isReadOnly:l,reconnectingEdgeId:c}=q(),[d,p]=o0(!1),f=i&&(a==null?void 0:a.id)!==e||!!c,m=u=>{r(e,{label:u})},y=()=>{p(!0)},E=()=>{p(!1)};return Ns("div",{className:"relative",onDoubleClick:y,children:[Qe(No,{className:H("w-full h-full min-w-9 min-h-9 hover:stroke-[#d33b3b] transition-colors duration-75",{"pointer-events-none":l,"stroke-blue-500 hover:stroke-blue-600":o&&!l,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),Qe("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Qe(Oe,{value:t.label,isEditing:d,onBlur:E,onChange:m})}),Qe(Xe,{nodeId:e,nodeType:"END_EVENT"}),s==="edit"&&Qe(at,{nodeId:e,isVisible:!n&&o,minWidth:Zn.MIN_WIDTH,minHeight:Zn.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||f)&&Ns(Md,{children:[Qe(ne,{type:"target",position:qt.Left,id:"left",className:H({"event-handle":f})}),Qe(ne,{type:"target",position:qt.Right,id:"right",className:H({"event-handle":f})}),Qe(ne,{type:"target",position:qt.Top,id:"top",className:H({"event-handle":f})}),Qe(ne,{type:"target",position:qt.Bottom,id:"bottom",className:H({"event-handle":f})})]}),!i&&Ns(Md,{children:[Qe(ne,{type:"source",position:qt.Left,id:"left"}),Qe(ne,{type:"source",position:qt.Right,id:"right"}),Qe(ne,{type:"source",position:qt.Top,id:"top"}),Qe(ne,{type:"source",position:qt.Bottom,id:"bottom"})]})]})};import{Position as Zt,useConnection as n0,useReactFlow as r0}from"@xyflow/react";import{useCallback as i0,useState as s0}from"react";import{Fragment as Ld,jsx as je,jsxs as ws}from"react/jsx-runtime";var kd=({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let a=Fi[t.variant].icon,{updateNodeData:s}=r0(),{inProgress:l,fromNode:c}=n0(),{mode:d,isReadOnly:p,reconnectingEdgeId:f}=q(),[m,y]=s0(!1),E=l&&(c==null?void 0:c.id)!==e||!!f,u=i0(x=>{s(e,{label:x})},[e,s]),g=()=>{y(!0)},h=()=>{y(!1)};return ws("div",{className:"relative",style:{width:o!=null?o:Co.MIN_WIDTH,height:n!=null?n:Co.MIN_HEIGHT},onDoubleClick:g,children:[je(a,{className:H("w-full h-full min-w-14 min-h-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"pointer-events-none":p,"stroke-blue-500 hover:stroke-blue-600":r&&!p,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),je("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:je(Oe,{value:t.label,isEditing:m,onBlur:h,onChange:u})}),je(Xe,{nodeId:e,nodeType:"GATEWAY",nodeVariant:t.variant}),d==="edit"&&je(at,{nodeId:e,isVisible:!i&&r,minWidth:Co.MIN_WIDTH,minHeight:Co.MIN_HEIGHT,offset:2,keepAspectRatio:!0}),(!l||E)&&ws(Ld,{children:[je(ne,{type:"target",position:Zt.Left,id:"left",className:H({"gateway-handle":E})}),je(ne,{type:"target",position:Zt.Right,id:"right",className:H({"gateway-handle":E})}),je(ne,{type:"target",position:Zt.Top,id:"top",className:H({"gateway-handle":E})}),je(ne,{type:"target",position:Zt.Bottom,id:"bottom",className:H({"gateway-handle":E})})]}),!l&&ws(Ld,{children:[je(ze,{type:"source",position:Zt.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),je(ze,{type:"source",position:Zt.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),je(ze,{type:"source",position:Zt.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),je(ze,{type:"source",position:Zt.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})};import{useNodesData as kP,useReactFlow as RP}from"@xyflow/react";import{Button as OP,DropdownMenu as VP,DropdownMenuContent as HP,DropdownMenuGroup as GP,DropdownMenuItem as BP,DropdownMenuLabel as zP,DropdownMenuTrigger as YP,Tooltip as FP,TooltipContent as WP,TooltipTrigger as XP,useTranslation as UP}from"@produto-lecom/lecom-ui";import{WrenchIcon as KP}from"lucide-react";import{jsx as QP,jsxs as jP}from"react/jsx-runtime";import{Position as Jt,useConnection as a0,useReactFlow as l0}from"@xyflow/react";import{useState as c0}from"react";import{Fragment as Rd,jsx as et,jsxs as Is}from"react/jsx-runtime";var Dd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=l0(),{inProgress:i,fromNode:a}=a0(),{mode:s,isReadOnly:l,reconnectingEdgeId:c}=q(),[d,p]=c0(!1),f=i&&(a==null?void 0:a.id)!==e||!!c,m=u=>{r(e,{label:u})},y=()=>{p(!0)},E=()=>{p(!1)};return Is("div",{className:"relative",onDoubleClick:y,children:[et(Xn,{className:H("w-full h-full min-w-9 min-h-9 hover:stroke-[#54890b] transition-colors duration-75",{"pointer-events-none":l,"stroke-blue-500 hover:stroke-blue-600":o&&!l,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),et("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:et(Oe,{value:t.label,isEditing:d,onBlur:E,onChange:m})}),et(Xe,{nodeId:e,nodeType:"START_EVENT"}),s==="edit"&&et(at,{nodeId:e,isVisible:!n&&o,minWidth:qn.MIN_WIDTH,minHeight:qn.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||f)&&Is(Rd,{children:[et(ne,{type:"target",position:Jt.Left,id:"left",className:H({"event-handle":f})}),et(ne,{type:"target",position:Jt.Right,id:"right",className:H({"event-handle":f})}),et(ne,{type:"target",position:Jt.Top,id:"top",className:H({"event-handle":f})}),et(ne,{type:"target",position:Jt.Bottom,id:"bottom",className:H({"event-handle":f})})]}),!i&&Is(Rd,{children:[et(ze,{type:"source",position:Jt.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),et(ze,{type:"source",position:Jt.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),et(ze,{type:"source",position:Jt.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),et(ze,{type:"source",position:Jt.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};import{useTranslation as p0}from"@produto-lecom/lecom-ui";import{Position as Qt,useConnection as f0,useReactFlow as m0}from"@xyflow/react";import{useCallback as ii}from"react";var Sn=60,ri=(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<=Sn?i:i.substring(0,Sn).trim()},$o=(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>Sn&&(n=n.substring(0,Sn).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=Sn-l.length,p=`${r.substring(0,c).trim()}${l}`;if(!o.has(p))return p;i++}return n};import{jsx as Od,jsxs as d0}from"react/jsx-runtime";var Vd=e=>d0("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[Od("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),Od("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as Hd}from"react/jsx-runtime";var Gd=e=>Hd("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:Hd("path",{d:"M12 2C8.13 2 5 5.13 5 9C5 14.25 12 22 12 22C12 22 19 14.25 19 9C19 5.13 15.87 2 12 2ZM12 11.5C10.62 11.5 9.5 10.38 9.5 9C9.5 7.62 10.62 6.5 12 6.5C13.38 6.5 14.5 7.62 14.5 9C14.5 10.38 13.38 11.5 12 11.5Z",fill:"#38bdf8"})}));import{jsx as Bd,jsxs as u0}from"react/jsx-runtime";var zd=e=>u0("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[Bd("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),Bd("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{Fragment as si,jsx as we,jsxs as Mn}from"react/jsx-runtime";var g0={APROVADO:Vd,EM_ANDAMENTO:Gd,REJEITADO:zd},As={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)]"},h0={APROVADO:"bg-green-50",EM_ANDAMENTO:"bg-turquoise-50",REJEITADO:"bg-red-50"},Yd=({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let{t:a}=p0(),{toast:s}=Le(),{updateNodeData:l,getNodes:c,setNodes:d}=m0(),{inProgress:p,fromNode:f}=f0(),{mode:m,isReadOnly:y,onSubprocessValidationClick:E,reconnectingEdgeId:u}=q(),{getTaskStatus:g}=ao(),h=p&&(f==null?void 0:f.id)!==e||!!u,x=g(e),T=t.variant==="SUBPROCESS",b=t.variant==="SERVICE_TASK",N=!!t.variant&&!T&&!b||!!x,v=!!t.attribute||T||b,I=ii(M=>{let B=N||v?80:40,G=M.split(`
41
+ `),k=G.reduce((U,X)=>Math.max(U,X.length),0),O=G.length,Y=Math.max(Ht.MIN_WIDTH,k*7+64),F=Math.max(Ht.MIN_HEIGHT,O*24+B);d(U=>U.map(X=>X.id===e?w(_({},X),{width:Y,height:F,style:w(_({},X.style),{width:Y,height:F})}):X))},[e,d,N,v]),C=ii(M=>{let V=M.trim(),D=t.label||"";if(V===D)return;let A=V,B=c();if(!(V&&V!=="")){A=ri(B,a("bpmn.task.label.prefix")),l(e,{label:A}),I(A),s({variant:"warning",content:Mn(si,{children:[a("bpmn.task.feedback.label_empty.prefix")," ",we("strong",{children:A})]})});return}let k=$o(A,B);k===D||(l(e,{label:k}),I(k),k!==A&&s({variant:"warning",content:Mn(si,{children:[a("bpmn.task.feedback.label_already_exists.prefix")," ",we("strong",{children:V})," ",a("bpmn.task.feedback.label_already_exists.middle")," ",we("strong",{children:k})]})}))},[t.label,c,e,a,l,I,s]),P=ii(M=>{I(M)},[I]),R=ii(()=>{s({variant:"error",content:a("bpmn.task.feedback.invalid_first_character")})},[a,s]),S=x?g0[x]:null,L=t.variant?$n[t.variant].icon:null,K=t.attribute?Kn[t.attribute].icon:null,j=()=>t.hasError?As.error:x?As[x]:y?As.default:"",Q=()=>{var M;return r&&(M=h0[x])!=null?M:""},z=()=>{E==null||E({id:e,type:"sub_process",label:t.label})};return Mn("div",{className:H("relative w-full h-full min-w-44 min-h-24 flex flex-col items-stretch justify-stretch bg-white border-2 border-grey-400 hover:border-grey-500 rounded-md hover:shadow-md transition-colors duration-75",j(),{"cursor-pointer":y,"border-blue-500 hover:border-blue-600 shadow-md":r&&!y&&!x,"border-red-500 hover:border-red-600 shadow-[0_0_5px_rgba(255,0,0,0.5)]":t.hasError}),style:{width:o!=null?o:Ht.MIN_WIDTH,height:n!=null?n:Ht.MIN_HEIGHT},children:[we("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:we(Oe,{value:t.label,maxLength:60,className:H(Q(),{"py-10 px-8":N||v}),onChange:C,onInput:P,onInvalidFirstCharacter:R})}),L&&we("div",{className:H("absolute flex items-center p-1",T||b?"bottom-0 left-1/2 -translate-x-1/2":"top-0 left-0"),children:we(L,{size:b?20:16,className:H(t.hasError?"text-red-500":"text-grey-500",T&&"cursor-pointer"),onClick:T?z:void 0})}),K&&we("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:we("div",{className:H("flex items-center w-16 p-1",T||b?"justify-between":"justify-center"),children:we(K,{size:16,className:H(t.hasError?"text-red-500":"text-grey-500")})})}),S&&we("div",{className:"absolute top-0 right-0 flex items-center p-1",children:we(S,{})}),we(Xe,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),m==="edit"&&we(at,{nodeId:e,isVisible:!i&&r,minWidth:Ht.MIN_WIDTH,minHeight:Ht.MIN_HEIGHT}),(!p||h)&&Mn(si,{children:[we(ne,{type:"target",position:Qt.Left,id:"left",className:H({"task-handle":h})}),we(ne,{type:"target",position:Qt.Right,id:"right",className:H({"task-handle":h})}),we(ne,{type:"target",position:Qt.Top,id:"top",className:H({"task-handle":h})}),we(ne,{type:"target",position:Qt.Bottom,id:"bottom",className:H({"task-handle":h})})]}),!p&&Mn(si,{children:[we(ze,{type:"source",position:Qt.Left,id:"left",nodeId:e,nodeType:"TASK"}),we(ze,{type:"source",position:Qt.Right,id:"right",nodeId:e,nodeType:"TASK"}),we(ze,{type:"source",position:Qt.Top,id:"top",nodeId:e,nodeType:"TASK"}),we(ze,{type:"source",position:Qt.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})};import{Position as Fd}from"@xyflow/react";import{Fragment as y0,jsx as ai,jsxs as x0}from"react/jsx-runtime";var Wd=({id:e,data:t})=>x0(y0,{children:[ai("div",{className:"relative w-full h-full min-w-32 min-h-16 flex items-center justify-center bg-white border-2 border-red-400 rounded-sm overflow-hidden",children:t.label}),ai(Xe,{nodeId:e,nodeType:"UNSUPPORTED"}),ai(ne,{type:"source",position:Fd.Right}),ai(ne,{type:"target",position:Fd.Left})]});import{BaseEdge as E0,EdgeLabelRenderer as _0,getSmoothStepPath as b0,MarkerType as T0,useInternalNode as Xd,useReactFlow as v0,useViewport as N0,Position as Ko}from"@xyflow/react";import{useState as w0,useMemo as I0}from"react";import{Fragment as Ud,jsx as Ue,jsxs as xo}from"react/jsx-runtime";var VL={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:T0.Arrow},data:{label:""}},$d=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var G;let{zoom:c}=N0(),{updateEdgeData:d}=v0(),{isMultipleSelection:p,mode:f,instanceId:m}=q(),y=f!=="edit",[E,u]=w0(!1),{reconnectingHandle:g,cursorPosition:h,hoveredNodeId:x,reconnectingSide:T,isValidReconnection:b,handleReconnectStart:N}=qr({edgeId:e,source:t,target:o,instanceId:m,isReadOnly:y}),v=Xd(t),I=Xd(o),{sx:C,sy:P,tx:R,ty:S,sourcePos:L,targetPos:K}=I0(()=>{var oe,le;if(!v||!I)return{sx:0,sy:0,tx:0,ty:0,sourcePos:Ko.Left,targetPos:Ko.Right};let k=Mo(v,I),O=s?i:k.sourcePos,Y=l?a:k.targetPos,F=(Z,xe,me)=>{var ee,ge,be,Te,Re,ot;let{x:_e,y:J}=Z.internals.positionAbsolute,de=(be=(ge=(ee=Z.measured)==null?void 0:ee.width)!=null?ge:Z.width)!=null?be:0,re=(ot=(Re=(Te=Z.measured)==null?void 0:Te.height)!=null?Re:Z.height)!=null?ot:0;switch(xe){case Ko.Top:return{x:_e+de*me,y:J};case Ko.Bottom:return{x:_e+de*me,y:J+re};case Ko.Left:return{x:_e,y:J+re*me};case Ko.Right:return{x:_e+de,y:J+re*me};default:return{x:_e+de/2,y:J+re/2}}},U=(oe=n==null?void 0:n.sourceOffset)!=null?oe:.5,X=(le=n==null?void 0:n.targetOffset)!=null?le:.5,$=v?F(v,O,U).x:k.sx,te=v?F(v,O,U).y:k.sy,ie=I?F(I,Y,X).x:k.tx,W=I?F(I,Y,X).y:k.ty;return g==="source"&&h?($=h.x,te=h.y,T&&(O=T)):g==="target"&&h&&(ie=h.x,W=h.y,T&&(Y=T)),{sx:$,sy:te,tx:ie,ty:W,sourcePos:O,targetPos:Y}},[v,I,s,l,i,a,g,h,T,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!v||!I)return null;let[j,Q,z]=b0({sourceX:C,sourceY:P,targetX:R,targetY:S,sourcePosition:L,targetPosition:K}),M=r||(v==null?void 0:v.selected)||(I==null?void 0:I.selected),V=M?"sequence-edge-marker-highlighted":"sequence-edge-marker",D=E||(n==null?void 0:n.label.trim().length)>0,A=()=>{u(!1)},B=k=>{d(e,{label:k.trim()})};return Ue(Ud,{children:xo("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":M}),onDoubleClick:()=>!y&&u(!0),children:[Ue("path",{d:j,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),xo("g",{className:H("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":M}),children:[Ue(E0,{id:e,path:j,interactionWidth:0,markerEnd:`url(#${V})`,strokeDasharray:4,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||g&&x&&!b,"stroke-green-500":g&&x&&b,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":M&&!(n!=null&&n.hasError)&&!g})}),xo(_0,{children:[xo("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${Q}px, ${z}px)`},children:[r&&!p&&Ue(Vo,{sx:C,sy:P,tx:R,ty:S,hasLabel:!!((G=n==null?void 0:n.label)!=null&&G.trim()),children:Ue(Oo,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),D&&Ue(Oe,{value:n==null?void 0:n.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:E,onBlur:A,onChange:B})]}),r&&!p&&!y&&xo(Ud,{children:[Ue("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${C}px, ${P}px)`},children:xo("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Ue("circle",{cx:6/c,cy:6/c,r:4/c,fill:g==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ue("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:g==="source"?.6:.3,className:"pointer-events-none"}),Ue("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!g||g!=="source","cursor-not-allowed":g==="source"&&x&&!b,"cursor-grabbing":g==="source"&&(!x||b)}),onMouseDown:k=>N("source",k.nativeEvent)})]})}),Ue("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${R}px, ${S}px)`},children:xo("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Ue("circle",{cx:6/c,cy:6/c,r:4/c,fill:g==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ue("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:g==="target"?.6:.3,className:"pointer-events-none"}),Ue("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!g||g!=="target","cursor-not-allowed":g==="target"&&x&&!b,"cursor-grabbing":g==="target"&&(!x||b)}),onMouseDown:k=>N("target",k.nativeEvent)})]})})]})]})]})]})})};import{getStraightPath as A0,Position as li}from"@xyflow/react";import{jsx as Kd,jsxs as C0}from"react/jsx-runtime";var qd=({toX:e,toY:t,fromNode:o})=>{var p,f;if(!o)return null;let{internals:{positionAbsolute:{x:n,y:r}},measured:i}=o,a=(p=i.width)!=null?p:0,s=(f=i.height)!=null?f:0,c=[{x:n,y:r+s/2,pos:li.Left},{x:n+a,y:r+s/2,pos:li.Right},{x:n+a/2,y:r,pos:li.Top},{x:n+a/2,y:r+s,pos:li.Bottom}].reduce((m,y)=>{let E=Math.hypot(e-m.x,t-m.y);return Math.hypot(e-y.x,t-y.y)<E?y:m}),[d]=A0({sourceX:c.x,sourceY:c.y,targetX:e,targetY:t});return C0("g",{className:"group",children:[Kd("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d}),Kd("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})};import{Position as jt,useConnection as S0,useReactFlow as M0}from"@xyflow/react";import{orderBy as P0}from"lodash";import{useMemo as Zd,useState as L0}from"react";import{Fragment as Cs,jsx as $e,jsxs as ci}from"react/jsx-runtime";var Jd=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{var v;let{updateNodeData:i,getNodes:a}=M0(),{mode:s,isReadOnly:l}=q(),{inProgress:c,fromNode:d}=S0(),p=c&&(d==null?void 0:d.id)!==e,[f,m]=L0(!1),y=a(),E=!r,u=!E&&((v=y.find(I=>I.id===r))==null?void 0:v.selected),g=Zd(()=>P0([...y.filter(I=>I.parentId===e&&I.type==="LANE")],"position.y","asc"),[y,e]),h=E?ga.MIN_WIDTH:se.MIN_WIDTH,x=Zd(()=>{if(E&&g.length>1){let I=[...g];return I.pop(),I.reduce((P,R)=>{var S,L;return P+((L=(S=R.measured)==null?void 0:S.height)!=null?L:0)},0)+se.MIN_HEIGHT}return se.MIN_HEIGHT},[E,g]),T=I=>{i(e,{label:I})},b=()=>{m(!0)},N=()=>{m(!1)};return ci(Cs,{children:[ci("div",{className:H("flex h-full min-h-64 w-full min-w-[50rem] hover:shadow-md bg-white outline outline-2 outline-grey-400",{"pointer-events-none":l,"outline-offset-0 outline-blue-500 shadow-sm":(o||u)&&!l}),children:[$e("div",{className:H("flex align-items justify-center w-10 border-r-2 border-grey-400",{"border-blue-500":(o||u)&&!l}),onDoubleClick:b,children:$e("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:$e(Oe,{value:t.label,className:"w-full h-full self-auto",contentClassName:H({"whitespace-nowrap":f}),isEditing:f,onBlur:N,onChange:T})})}),$e("div",{className:"flex-1"})]}),$e(Xe,{nodeId:e,nodeType:"LANE",isChild:!E}),s==="edit"&&$e(at,{nodeId:e,isVisible:!n&&o,minWidth:h,minHeight:x,offset:10}),!c&&ci(Cs,{children:[$e(ne,{type:"source",position:jt.Left,id:"left"}),$e(ne,{type:"source",position:jt.Right,id:"right"}),$e(ne,{type:"source",position:jt.Top,id:"top"}),$e(ne,{type:"source",position:jt.Bottom,id:"bottom"})]}),(!c||p)&&ci(Cs,{children:[$e(ne,{type:"target",position:jt.Left,id:"left",className:H({"annotation-handle":p})}),$e(ne,{type:"target",position:jt.Right,id:"right",className:H({"annotation-handle":p})}),$e(ne,{type:"target",position:jt.Top,id:"top",className:H({"annotation-handle":p})}),$e(ne,{type:"target",position:jt.Bottom,id:"bottom",className:H({"annotation-handle":p})})]})]})};var Qd={START_EVENT:Dd,END_EVENT:Pd,TASK:Yd,GATEWAY:kd,ANNOTATION:Sd,LANE:Jd,UNSUPPORTED:Wd},jd={SEQUENCE_EDGE:Zc,MESSAGE_EDGE:$d,ANNOTATION_EDGE:Rc},eu="#fafafa",tu="#bebebe",ou=1,nu=10,ru="bottom-left",Ss=.05,iu=5,su=150,au=100,lu=Ss,cu=1,du={x:0,y:0,zoom:.75},uu=1,pu=2,k0={[uu]:4,[pu]:2},Pn=[uu,pu],Ms=Pn.reduce((e,t)=>e|k0[t],0);var eo=()=>{let{setViewport:e}=R0(),t=D0();return{fitToNodes:O0(n=>{let{width:r,height:i}=t.getState();if(i<=0||r<=0)return;let a=Ta(n);if(!a)return;let s=va({bounds:a,canvasHeight:i,canvasWidth:r,minZoom:lu,maxZoom:cu,offsetX:su,offsetY:au});e(s)},[t,e])}};import{useReactFlow as V0}from"@xyflow/react";var lt=()=>{let{getEdges:e,getNodes:t}=V0(),{lastElementId:o}=q(),n=()=>{let i=t(),a=e(),s=jc(i,a);return Math.max(s,o)};return{getLastId:n,getNextId:()=>n()+1}};var to=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n}=H0(),{getLastId:r}=lt(),{fitToNodes:i}=eo(),{setLastElementId:a}=q(),s=fu(async(c="")=>{let{nodes:d,edges:p,lastElementId:f}=await fd(c);i(d),o(d),n(p),a(f)},[o,n,a,i]),l=fu(()=>{let c=e(),d=t(),p=r();return pd(c,d,p)},[e,t,r]);return{importFromMxGraph:s,exportToMxGraph:l}};import{useCallback as mu}from"react";var B0=500,di=()=>{let{isInitialized:e,onElementChanges:t}=q(),{exportToMxGraph:o}=to(),n=G0(()=>{if(!e)return;let a=o();t==null||t(a)},B0),r=mu(a=>{a.every(c=>c.type==="select")||a.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=mu(a=>{a.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var gu=({setEdges:e,saveHistory:t})=>{let{getNode:o,getEdges:n,getNodes:r,getInternalNode:i}=Y0(),{emitElementChanges:a}=di(),s=F0(null),{getNextId:l}=lt(),c=Eo(u=>{var b;let g=o(u.source),h=o(u.target);if(!g||!h)return!1;let x={sourceNodeId:g.id,targetNodeId:h.id,sourceNodeType:g.type,targetNodeType:h.type,nodes:r(),edges:n(),reconnectingEdgeId:(b=s.current)!=null?b:void 0};return ds(x).isValid},[o,n,r]),d=Eo(u=>{var x,T;let g=l(),h=i(u.source);if(h){let b=i(u.target),N=b?b.internals.positionAbsolute.x+((x=b.measured.width)!=null?x:0)/2:0,v=b?b.internals.positionAbsolute.y+((T=b.measured.height)!=null?T:0)/2:0,I=Jc(h,N,v),C=(b==null?void 0:b.type)==="ANNOTATION"||(h==null?void 0:h.type)==="ANNOTATION",P=C?Ho:st,R;if(!C&&b&&u.targetHandle){let K=Jr(I),j=Jr(u.targetHandle),{x:Q,y:z}=gs(h,I),{x:M,y:V}=gs(b,u.targetHandle),A=$r(Q,z,M,V,K,j).slice(1,-1);A.length>0&&(R=A)}let S=w(_(_({},u),P),{id:String(g),sourceHandle:I,data:_(_({},C?{}:st.data),R?{points:R}:{})}),L=n().concat(S);e(L),t("forceSave",{nodes:r(),edges:L}),a()}},[l,e,a,i,n,r,t]),p=Eo((u,g)=>{s.current=g.id},[]),f=Eo(()=>{s.current=null},[]),m=Eo((u,g)=>{let h=o(g.source),x=o(g.target);if(!h||!x){s.current=null;return}let T={sourceNodeId:h.id,targetNodeId:x.id,sourceNodeType:h.type,targetNodeType:x.type,nodes:r(),edges:n(),reconnectingEdgeId:u.id};if(!ds(T).isValid){s.current=null;return}let N=z0(u,g,n()).map(v=>v.id===u.id?w(_({},v),{data:w(_({},v.data),{points:void 0})}):v);e(N),t("forceSave",{nodes:r(),edges:N}),s.current=null,a()},[o,r,n,e,a,t]),y=Eo(u=>{s.current=u},[]),E=Eo(()=>{s.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:m,onReconnectStart:p,onReconnectEnd:f,setReconnectingEdge:y,clearReconnectingEdge:E}};import{useTranslation as W0}from"@produto-lecom/lecom-ui";import{useReactFlow as X0}from"@xyflow/react";import{useCallback as Dn,useRef as Nu,useState as U0}from"react";var Ln=(e=[])=>e.filter(t=>t.type==="START_EVENT"),_o=(e=[])=>e.filter(t=>t.type==="END_EVENT"),oo=(e=[])=>e.filter(t=>t.type==="TASK")||[],hu=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"});var ui=(e=[])=>e.filter(t=>t.type==="GATEWAY"),yu=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),tt=(e,t=[])=>t.filter(o=>o.source===e),kn=(e,t=[])=>t.filter(o=>o.target===e),xu=(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"},Eu=(e,t)=>{let o=tt(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},_u=e=>e?/[^\s]/.test(e.trim()):!1,Ee=e=>{let{isValid:t,nodeIds:o,edgeIds:n}=e;return{isValid:t,nodeIds:!t&&o&&o.length>0?o:[],edgeIds:!t&&n&&n.length>0?n:[]}},Rt=(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)}},bu=(e=[],t=[])=>({nodes:e.map(o=>{var n;return{id:o.id,type:o.type||"",label:typeof((n=o.data)==null?void 0:n.label)=="string"?o.data.label:void 0,properties:o.data}}),edges:t.map(o=>({id:o.id,source:o.source,target:o.target,type:o.type||"default"}))});var Rn=[{id:"start_event_not_found",validate:e=>{let t=Ln(e.nodes);return Ee({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=_o(e.nodes);return Ee({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Ln(e.nodes),o=t.length===1;if(t.length===0)return Ee({isValid:!0});if(!o)return Ee({isValid:!1,nodeIds:t.map(i=>i.id)});let n=tt(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(a=>a.id),...n.map(a=>a.target)];return Ee({isValid:!1,nodeIds:[...new Set(i)]})}return Ee({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=oo(e.nodes),o=Rt(t,n=>tt(n.id,e.edges).length<=2);return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=oo(e.nodes),o=Rt(t,n=>!!n.label&&n.label.trim()!=="");return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=oo(e.nodes),n=Rt(o,r=>!r.label||r.label.length<=60);return Ee({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=oo(e.nodes),o=new Map;for(let r of t){if(!r.label)continue;let i=r.label.trim();i&&(o.has(i)||o.set(i,[]),o.get(i).push(r))}let n=[];for(let[,r]of o.entries())r.length>1&&r.forEach(i=>n.push(i.id));return Ee({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=ui(e.nodes),o=[],n=[];for(let r of t){let i=tt(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 Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Ln(e.nodes),..._o(e.nodes)],o=[],n=[];for(let r of t){let i=tt(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 Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=_o(e.nodes),o=[],n=[];for(let r of t){let i=kn(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=tt(s.id,e.edges);l.length>1&&(o.push(s.id),l.forEach(c=>n.push(c.id)))}}}return Ee({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=yu(e.nodes),o=Rt(t,r=>tt(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>tt(r,e.edges).map(i=>i.id));return Ee({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=oo(e.nodes),o=Rt(t,n=>!n.label||_u(n.label));return Ee({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 Ee({isValid:!0});let t=_o(e.nodes)[0];if(!t)return Ee({isValid:!0});let o=kn(t.id,e.edges);if(!o.length)return Ee({isValid:!0});let r=oo(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=Rt(r,l=>!xu(l.id,e));return Ee({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=oo(e.nodes),o=_o(e.nodes)[0];if(!o)return Ee({isValid:!0});let n=t.filter(l=>{let c=kn(l.id,e.edges),d=tt(l.id,e.edges),p=c.some(m=>{var y;return((y=e.nodes.find(E=>E.id===m.source))==null?void 0:y.type)==="START_EVENT"}),f=d.some(m=>{var y;return((y=e.nodes.find(E=>E.id===m.target))==null?void 0:y.type)==="END_EVENT"});return p&&f}),r=kn(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 Ee(s)}},{id:"gateway_flow_to_event",validate:e=>{let t=ui(e.nodes),o=[],n=[];for(let r of t){let i=tt(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 Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=ui(e.nodes),o=Rt(t,n=>tt(n.id,e.edges).length>=1);return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Ln(e.nodes),..._o(e.nodes)],o=[],n=[];for(let r of t){let i=tt(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 Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=hu(e.nodes),o=Rt(t,n=>!Eu(n.id,e));return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}}];var Tu=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of Rn){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}},vu=async(e,t)=>{var n;let o=[];try{let r=await e(),i=(n=r==null?void 0:r.filter(a=>a.area==="DIAGRAM"))!=null?n:[];return i.length===0?{isValid:!0,errors:[]}:(i.forEach(a=>{var l,c;let s=(c=(l=a==null?void 0:a.detail)==null?void 0:l.phases)==null?void 0:c.map(d=>d.diagramCellId);o.push({id:a.code,message:a.code,nodeIds:s,edgeIds:[]})}),{isValid:!1,errors:o})}catch(r){let i=[],a=(s,l)=>{let c=t.filter(d=>{var p;return((p=d.data)==null?void 0:p.variant)===s}).map(d=>d.id);c.length>0&&i.push({id:l,message:l,nodeIds:c,edgeIds:[]})};return a("SUBPROCESS","cannot_validate_subprocess_reference"),a("SERVICE_TASK","service_task_automation_status_unavailable"),{isValid:!1,errors:i}}};import{jsx as pi,jsxs as $0}from"react/jsx-runtime";var wu=()=>{let{t:e}=W0(),{toast:t}=Le(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=X0(),{validateCustomDiagram:a}=q(),[s,l]=U0(!1),c=Nu(!1),d=Nu(!1),p=Dn(async u=>{let g=bu(u.nodes,u.edges),h=Tu(g),x=u.nodes.filter(({type:b,data:N})=>b==="TASK"&&((N==null?void 0:N.variant)==="SUBPROCESS"||(N==null?void 0:N.variant)==="SERVICE_TASK"));if(a&&x.length>0){let b=await vu(a,x);h={isValid:h.isValid&&b.isValid,errors:[...h.errors,...b.errors]}}let T=h.errors.map(b=>w(_({},b),{message:e(`validation.errors.${b.id}`)}));return s||l(!0),{isValid:h.isValid,errors:T}},[s,e,a]),f=Dn((u,g=!0)=>{if(g&&u&&t({variant:u.isValid?"success":"error",duration:5e3,title:u.isValid?e("validation.success.title"):e("validation.errors.title"),content:$0("div",{className:"flex flex-col gap-1",children:[!u.isValid&&pi("span",{className:"body-small-500",children:e("validation.errors.subtitle")}),pi("ul",{className:"list-disc list-inside max-h-40 overflow-y-auto",children:u.isValid?pi("li",{children:e("validation.success.message")}):u.errors.map(S=>pi("li",{className:"text-xs",children:S.message},S.id))})]})}),!u)return;c.current=!0,d.current=!0;let h=[],x=[];u.errors.forEach(S=>{S.nodeIds&&S.nodeIds.length>0&&S.nodeIds.forEach(L=>h.push(L)),S.edgeIds&&S.edgeIds.length>0&&S.edgeIds.forEach(L=>x.push(L))});let T=[...new Set(h)];o(S=>S.map(L=>w(_({},L),{data:w(_({},L.data),{hasError:!1})}))),n(S=>S.map(L=>w(_({},L),{data:w(_({},L.data),{hasError:!1})})));let b=r(),N=i(),v=new Set(T),I=new Set;u.errors.forEach(S=>{var j,Q;let L=Rn.find(z=>z.id===S.id);(L==null?void 0:L.highlightRelatedEdges)!==!1&&((j=S.edgeIds)==null||j.forEach(z=>I.add(z)),(Q=S.nodeIds)==null||Q.forEach(z=>{N.forEach(M=>{(M.source===z||M.target===z)&&I.add(M.id)})}))});let C=new Set,P=new Set,R=new Set;b.forEach(S=>{S.type==="START_EVENT"?C.add(S.id):S.type==="END_EVENT"&&P.add(S.id)}),N.forEach(S=>{C.has(S.source)&&R.add(S.target),P.has(S.target)&&R.add(S.source)}),R.forEach(S=>{var L,K;if(v.has(S)){let j=(L=u.errors.find(z=>{var M;return(M=z.nodeIds)==null?void 0:M.includes(S)}))==null?void 0:L.id;((K=Rn.find(z=>z.id===j))==null?void 0:K.highlightRelatedEdges)!==!1&&N.forEach(z=>{z.source===S&&P.has(z.target)&&(v.add(z.target),I.add(z.id)),z.target===S&&C.has(z.source)&&(v.add(z.source),I.add(z.id))})}}),v.size>0&&o(S=>S.map(L=>w(_({},L),{data:w(_({},L.data),{hasError:v.has(L.id)})}))),I.size>0&&n(S=>S.map(L=>w(_({},L),{data:w(_({},L.data),{hasError:I.has(L.id)})}))),setTimeout(()=>{c.current=!1},0)},[e,i,r,n,o,t]),m=Dn(()=>{l(!1),d.current=!1,o(u=>u.map(g=>w(_({},g),{data:w(_({},g.data),{hasError:!1})}))),n(u=>u.map(g=>w(_({},g),{data:w(_({},g.data),{hasError:!1})})))},[n,o]),y=Dn(()=>{d.current&&(c.current=!0,d.current=!1,o(u=>u.map(g=>w(_({},g),{data:w(_({},g.data),{hasError:!1})}))),n(u=>u.map(g=>w(_({},g),{data:w(_({},g.data),{hasError:!1})}))),setTimeout(()=>{c.current=!1},0))},[n,o]),E=Dn(()=>c.current,[]);return{validateDiagram:p,handleValidationComplete:f,clearValidation:m,dismissValidationPanel:y,isAutoValidationEnabled:s,getIsClearingValidation:E}};import{useReactFlow as K0}from"@xyflow/react";import{useTranslation as q0}from"@produto-lecom/lecom-ui";import{useEffect as Z0}from"react";var J0=15,Iu="bpmn:selection",Q0=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},Au=e=>{if(!Q0(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},Cu=({offset:e=J0,saveHistory:t})=>{let{t:o}=q0(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=K0(),{getNextId:s}=lt(),{mode:l,containerRef:c}=q();Z0(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let p=m=>{var b,N;if(!Au(m)||!d.contains(document.activeElement))return;let E=n(),u=i(),g=E.filter(v=>v.selected);if(!g.length)return;m.preventDefault(),m.stopPropagation();let h=u.filter(v=>g.some(I=>I.id===v.source)&&g.some(I=>I.id===v.target)),T=JSON.stringify({nodes:g,edges:h});(b=m.clipboardData)==null||b.setData(Iu,T),(N=m.clipboardData)==null||N.setData("text/plain",`BPMN Selection: ${g.length} nodes`)},f=m=>{var R,S;if(!Au(m)||!d.contains(document.activeElement))return;let E=(R=m.clipboardData)==null?void 0:R.getData(Iu);if(!E)return;m.preventDefault(),m.stopPropagation();let u;try{u=JSON.parse(E)}catch(L){return}if(!((S=u.nodes)!=null&&S.length))return;let g=new Map,h=n(),x=[],T=u.nodes.filter(L=>Ft(L.type,h));if(T.length===0)return;let b=s(),N=T.map(L=>{var Q;let K=String(b++);g.set(L.id,K);let j=w(_({},L),{id:K,selected:!0,position:{x:L.position.x+e,y:L.position.y+e}});if(L.type==="TASK"){let z=(Q=L.data)==null?void 0:Q.label,M=$o(z||o("bpmn.task.label.prefix"),[...h,...x]);j.data=w(_({},L.data),{label:M})}return x.push(j),j}),v=u.edges.map(L=>w(_({},L),{id:String(b++),selected:!0,source:g.get(L.source)||L.source,target:g.get(L.target)||L.target})),I=[...h.map(L=>w(_({},L),{selected:!1})),...N],P=[...i().map(L=>w(_({},L),{selected:!1})),...v];r(I),a(P),t("forceSave",{nodes:I,edges:P})};return d.addEventListener("copy",p,!0),d.addEventListener("paste",f,!0),()=>{d.removeEventListener("copy",p,!0),d.removeEventListener("paste",f,!0)}},[n,r,i,a,s,e,o,t,l,c])};import{useTranslation as j0}from"@produto-lecom/lecom-ui";import{useReactFlow as ex}from"@xyflow/react";import{useState as tx}from"react";var ox=50,Su=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let{draggableNode:r,setDraggableNode:i}=Uo(),{t:a}=j0(),{getInternalNode:s,getNodes:l,getEdges:c,screenToFlowPosition:d}=ex(),{getNextId:p}=lt(),{setIsDragging:f}=q(),{getInternalNodes:m}=ei(),{rebuildIndex:y,forceRebuildIndex:E}=Sr(),[u,g]=tx(null),h=(M,V,D)=>{var k;if(M.parentId!==V)return null;let A=D.filter(O=>O.id!==M.id&&O.parentId===V&&O.type==="LANE").sort((O,Y)=>O.position.y-Y.position.y);if(A.length===0)return null;let B=(k=D.find(O=>O.id===M.id))!=null?k:M,G=A.find(O=>B.position.y<O.position.y);return G?{draggedLaneId:M.id,beforeLaneId:G.id}:{draggedLaneId:M.id,afterLaneId:A[A.length-1].id}},x=(M,V=!1,D)=>{let A=V?"node-drop-target-error":"node-drop-target",B=V?"node-drop-target-lane-error":"node-drop-target-lane";t(G=>{var O;let k=(O=D==null?void 0:D(G))!=null?O:null;return G.map(Y=>{let F=[];return Y.id===M&&F.push(A),M!==void 0&&Y.parentId===M&&Y.type==="LANE"&&Y.id!==(k==null?void 0:k.draggedLaneId)&&F.push(B),Y.id===(k==null?void 0:k.draggedLaneId)&&F.push("lane-reorder-dragging"),Y.id===(k==null?void 0:k.beforeLaneId)&&F.push("lane-reorder-before"),Y.id===(k==null?void 0:k.afterLaneId)&&F.push("lane-reorder-after"),w(_({},Y),{className:F.join(" ")})})})},T=(M,V)=>{let D=m();if(M.type==="LANE"){if(V){x();return}let O=D.filter(U=>U.id!==M.id&&U.type==="LANE"&&!U.parentId),Y=nn(M,O);if(!Y){x();return}if(ro({parentId:Y.id,nodes:e,excludeTypes:["LANE"]})){x(Y.id,!0);return}x(Y.id,!1,U=>h(M,Y.id,U));return}let B=D.filter(O=>O.id!==M.id&&O.type==="LANE"),G=nn(M,B);if(!G){x();return}if(ro({parentId:G.id,nodes:e,includeTypes:["LANE"]})){x();return}x(G.id)},b=M=>{let V=s(M.id),D=M.type==="LANE"&&ro({parentId:M.id,nodes:e,includeTypes:["LANE"]});T(V,D)},N=M=>M.map(V=>w(_({},V),{className:void 0})),v=M=>M.some(D=>D.dragging)?M.map(D=>D.dragging?w(_({},D),{dragging:!1}):D):M,I=(M,V)=>{let D=0;for(let A of V){if(A.id===M||A.parentId||A.type==="LANE")continue;let B=rt(A),G=B.y+B.h;D=Math.max(D,G)}return D+ox},C=(M,V)=>{if(!Wi(M,V))return V;let D=I(M,V);return V.map(A=>A.id===M?w(_({},A),{position:w(_({},A.position),{y:D})}):A)},P=M=>{if(M.preventDefault(),M.dataTransfer.dropEffect="move",!(r!=null&&r.type))return;let V=d({x:M.clientX,y:M.clientY}),D={id:"__sidebar_drag__",type:r.type,position:V,measured:{width:1,height:1},internals:{positionAbsolute:V}};T(D,!1)},R=M=>{let V=M.relatedTarget;(!V||!M.currentTarget.contains(V))&&x()},S=(M,V)=>{M.preventDefault(),b(V)},L=(M,V,D)=>{var F,U;let A=[...D],B=V.parentId?V.parentId:V.id;if(M.parentId===V.id)return A=Ui(M,V,A),A=$t(A),A=io(B,A),N(A);if(M.type==="LANE"){if(ro({parentId:V.id,nodes:A,excludeTypes:["LANE"]})){let W=Ir(V),oe=50,le=50;return A.map(Z=>{var xe,me;return Z.id===M.id?w(_({},Z),{position:{x:(xe=u==null?void 0:u.x)!=null?xe:W.x+oe,y:(me=u==null?void 0:u.y)!=null?me:W.y2+le}}):Z})}let te=A.filter(W=>W.parentId===V.id).reduce((W,oe)=>{var le,Z;return W+((Z=(le=oe.measured)==null?void 0:le.height)!=null?Z:0)},0),ie={x:se.HEADER_WIDTH,y:te};return A=A.map(W=>W.id===M.id?w(_({},W),{parentId:V.id,position:ie,className:void 0}):w(_({},W),{className:void 0})),A=$t(A),A=C(B,A),A}if(ro({parentId:V.id,nodes:A,includeTypes:["LANE"]})){let X;if(M.parentId){let $=s(M.parentId),{x:te,y:ie}=rt($);X={x:te+((F=M.position.x)!=null?F:0),y:ie+((U=M.position.y)!=null?U:0)}}return A=A.map($=>$.id===M.id?w(_({},$),{position:X!=null?X:$.position,parentId:void 0,className:void 0}):w(_({},$),{className:void 0})),A=io(B,A),A}let O=_a(M,V);A=A.map(X=>X.id===M.id?w(_({},X),{parentId:V.id,position:O,className:void 0}):w(_({},X),{className:void 0}));let Y=A.find(X=>X.id===M.id);return A=Ui(Y,V,A),A=$t(A),A=io(B,A),A},K=M=>{if(M.preventDefault(),!(r!=null&&r.type))return;if(!Ft(r.type,l())){f(!1),i(null);return}let V=d({x:M.clientX,y:M.clientY}),D={width:ue[r.type].MIN_WIDTH,height:ue[r.type].MIN_HEIGHT},A=p(),B={id:String(A),type:r.type,position:V,measured:D,data:{label:r.type==="TASK"?ri(e,a("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},G=w(_({},B),{internals:{positionAbsolute:V}}),k=w(_({},G),{measured:{width:1,height:1}}),O=m(),Y=r.type==="LANE",F=O.filter(W=>Y?W.type==="LANE"&&!W.parentId:W.type==="LANE"),U=nn(k,F),X=[...O.map(W=>w(_({},W),{selected:!1})),G];U&&(X=L(G,U,X)),X=on(X),Y&&!U&&(X=C(G.id,X)),X=N(X),t(X),E();let $=M.dataTransfer.getData("sourceId"),te=c(),ie=te;if($){let W={id:String(A+1),source:$,target:B.id},oe=r.type==="ANNOTATION"?_(_({},W),Ho):_(_({},W),st);ie=te.concat(oe),o(ie)}n("forceSave",{nodes:X,edges:ie}),f(!1),i(null)},j=async(M,V,D)=>{let A=[...m()],B=new Set;D.forEach(O=>{let Y=s(O.id),F=O.type==="LANE",U=A.filter($=>$.id!==O.id&&(F?$.type==="LANE"&&!$.parentId:$.type==="LANE")),X=nn(Y,U);if(X){if(F&&ro({parentId:O.id,nodes:A,includeTypes:["LANE"]})){O.parentId&&(A=z(O,A),B.add(O.id));return}A=L(Y,X,A);return}O.parentId&&(A=z(O,A),O.type==="LANE"&&B.add(O.id))}),A=v(A);let G=D.filter(O=>O.type==="LANE"&&!O.parentId).map(O=>O.id);for(let O of G)Wi(O,A)&&u&&(A=A.map(Y=>Y.id===O?w(_({},Y),{position:_({},u)}):Y));for(let O of B)A=C(O,A);if(D.some(O=>O.type!=="LANE"&&!O.parentId)){let O=A.filter(Y=>Y.type==="LANE"&&!Y.parentId).map(Y=>Y.id);for(let Y of O)A=io(Y,A)}A=on(A),A=N(A),t(A),y(A),g(null)},Q=(M,V)=>{g({x:V.position.x,y:V.position.y})},z=(M,V)=>{var U,X,$,te,ie,W,oe,le;let D=s(M.parentId);if(!D)return V;let A=M.type==="LANE",B=V.filter(Z=>Z.parentId===D.id&&Z.id!==M.id),G=B.filter(Z=>Z.type==="LANE"),k;if(A&&G.length===0)k=se.MIN_HEIGHT;else if(A){let Z=(X=(U=M.measured)==null?void 0:U.height)!=null?X:se.MIN_HEIGHT;k=((te=($=D.measured)==null?void 0:$.height)!=null?te:se.MIN_HEIGHT)-Z,k=Math.max(se.MIN_HEIGHT,k)}else k=B.length>0?B.reduce((Z,xe)=>{var me,_e;return Z+((_e=(me=xe.measured)==null?void 0:me.height)!=null?_e:0)},0)+Ne:Math.max(se.MIN_HEIGHT,(W=(ie=D.measured)==null?void 0:ie.height)!=null?W:0);let{x:O,y:Y}=rt(D),F={x:O+((oe=M.position.x)!=null?oe:0),y:Y+((le=M.position.y)!=null?le:0)};return V=V.map(Z=>Z.id===M.id?w(_({},Z),{position:F,parentId:void 0}):Z.id===D.id?w(_({},Z),{height:k,measured:w(_({},Z.measured),{height:k})}):Z),V=$t(V),V};return{onDragOver:P,onDragLeave:R,onDrop:K,onNodeDrag:S,onNodeDragStart:Q,onNodeDragStop:j}};import{useReactFlow as nx}from"@xyflow/react";import{useTranslation as rx}from"@produto-lecom/lecom-ui";import{useEffect as ix}from"react";var sx=30,ax=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",i=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||i},lx=e=>!ax(e.target),Mu=({offset:e=sx,saveHistory:t})=>{let{t:o}=rx(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=nx(),{getNextId:s}=lt(),{mode:l,containerRef:c}=q();ix(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let p=f=>{if(d.contains(document.activeElement)&&f.ctrlKey&&f.key.toLowerCase()==="d"&&lx(f)){f.preventDefault(),f.stopPropagation();let y=n(),E=i(),u=y.filter(P=>P.selected);if(!u.length)return;let g=new Map,h=[],x=u.filter(P=>Ft(P.type,y));if(x.length===0)return;let T=E.filter(P=>x.some(R=>R.id===P.source)&&x.some(R=>R.id===P.target)),b=s(),N=x.map(P=>{var L;let R=String(b++);g.set(P.id,R);let S=w(_({},P),{id:R,selected:!0,position:{x:P.position.x+e,y:P.position.y+e}});if(P.type==="TASK"){let K=(L=P.data)==null?void 0:L.label,j=$o(K||o("bpmn.task.label.prefix"),[...y,...h]);S.data=w(_({},P.data),{label:j})}return h.push(S),S}),v=T.map(P=>w(_({},P),{id:String(b++),selected:!0,source:g.get(P.source)||P.source,target:g.get(P.target)||P.target})),I=[...y.map(P=>w(_({},P),{selected:!1})),...N],C=[...E.map(P=>w(_({},P),{selected:!1})),...v];r(I),a(C),t("forceSave",{nodes:I,edges:C})}};return d.addEventListener("keydown",p,!0),()=>{d.removeEventListener("keydown",p,!0)}},[n,r,i,a,s,e,o,t,l,c])};import{useEffect as cx,useRef as Pu}from"react";import{useReactFlow as dx}from"@xyflow/react";var ux=20,px=50,On={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},fx=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},Lu=e=>{let{getNodes:t}=dx(),{mode:o,isMoveTool:n}=q(),r=Pu(0),i=Pu(new Map);cx(()=>{let a=s=>{if(o!=="edit"||!n||fx(s.target)||!Object.values(On).includes(s.key))return;let p=t().filter(h=>h.selected);if(p.length===0){i.current.clear();return}s.preventDefault();let f=Date.now(),m=f-r.current<500;r.current=f;let y=s.shiftKey?px:ux,E=0,u=0;switch(s.key){case On.UP:u=-y;break;case On.DOWN:u=y;break;case On.LEFT:E=-y;break;case On.RIGHT:E=y;break}let g=p.map(h=>{let x=i.current.get(h.id);(!m||!x)&&(x={x:h.position.x,y:h.position.y});let T={x:x.x+E,y:x.y+u};return i.current.set(h.id,T),{id:h.id,dragging:!0,type:"position",position:T}});e&&e(g)};return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[t,e,o,n])};import{useReactFlow as gx}from"@xyflow/react";var Ru={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY","gateway-parallel":"GATEWAY","gateway-complex":"GATEWAY"},Du={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},ku=(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}},mx=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=ku(i[0],o),s=ku(i[1],o);a&&s&&n.push({sourceId:a.step,targetId:s.step,label:a.edgeLabel||s.edgeLabel||""})}),{components:o,connections:n}},Ou=e=>{let{components:t,connections:o}=mx(e);return{nodes:t,edges:o}};var hx=7,yx=48,xx=340,Ex=(e,t)=>{let o=yx+e.length*hx;return Math.min(xx,Math.max(t,o))},fi=()=>{let{setNodes:e,setEdges:t}=gx(),{fitToNodes:o}=eo(),{getNextId:n}=lt();return{importFromLia:i=>{let a=typeof i=="string"?i:i.diagramXml||"",{nodes:s,edges:l}=Ou(a),c=[],d=new Map,p=!1,f=n();for(let[h,x]of Object.entries(s)){let T=String(f++),b=Ru[x.type],N=Du[x.type];b==="START_EVENT"&&(p=!0),d.set(h,T);let v=ue[b].MIN_WIDTH,I=ue[b].MIN_HEIGHT;c.push({id:T,type:b,data:{label:x.label||"",variant:N,attribute:""},position:{x:0,y:0},width:v,height:I,measured:{width:v,height:I}})}let m=[];for(let h of l){let x=w(_({},st),{id:String(f++),source:d.get(h.sourceId)||h.sourceId,target:d.get(h.targetId)||h.targetId});m.push(x)}if(!p&&c.length>0){let h=String(f++),x={id:h,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:ue.START_EVENT.MIN_WIDTH,height:ue.START_EVENT.MIN_HEIGHT,measured:{width:ue.START_EVENT.MIN_WIDTH,height:ue.START_EVENT.MIN_HEIGHT}};c.unshift(x);let T=c[1];if(T){let b=w(_({},st),{id:String(f++),source:h,target:T.id});m.unshift(b)}}let y=c.map(h=>{var x,T;return h.type==="TASK"?w(_({},h),{width:Ex(String((T=(x=h.data)==null?void 0:x.label)!=null?T:""),ue.TASK.MIN_WIDTH)}):h}),{nodes:E}=oi(y,m),u=new Map(E.map(h=>[h.id,h.position])),g=c.map(h=>{var x;return w(_({},h),{position:(x=u.get(h.id))!=null?x:h.position})});e(g),t(m),o(g)}}};import{useCallback as _x,useEffect as bx}from"react";var Tx={origin:"*",debug:!1};function mi(e,t=Tx){let{origin:o,debug:n}=t,r=_x((i,a)=>{let s={event:i,data:a};window.parent.postMessage(s,o||"*")},[o]);return bx(()=>{if(!e)return;let i=a=>{let s=a.data;if(!(s!=null&&s.event)||(s==null?void 0:s.data)===void 0)return;let{event:l,data:c}=s,d;if(Array.isArray(c)){let[,p]=c;d=p.data}else d=c;n&&(console.debug("[postMessage] received:",s),console.debug("[postMessage] eventData:",d)),l&&e[l]&&e[l](d)};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[e,n]),{sendMessage:r}}import{useNodesInitialized as Nx}from"@xyflow/react";import{useEffect as gi,useRef as Ps}from"react";var Vu=()=>{let e=Nx(),{initialDiagram:t,isNewDiagram:o,setIsInitialized:n,onElementChanges:r}=q(),{importFromMxGraph:i,exportToMxGraph:a}=to(),{sendMessage:s}=mi(),l=Ps(t),c=Ps(r),d=Ps(a);gi(()=>{c.current=r},[r]),gi(()=>{d.current=a},[a]),gi(()=>{t&&(i(t),l.current=t)},[t,i]),gi(()=>{if(!e)return;(async()=>{var f;if(await Wn(),n(!0),s("INIT_MODELER",l.current),!o){let m=d.current();(f=c.current)==null||f.call(c,m)}})()},[e,o,n,s])};import{useReactFlow as wx}from"@xyflow/react";import{useCallback as Hu}from"react";function Gu(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=ao(),{getEdges:n}=wx(),r=Hu(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=Hu(()=>{t()},[t]);return{handleTasksStatus:r,handleClearTaskStatus:i}}import{useReactFlow as Ix}from"@xyflow/react";import{useCallback as Dt,useState as Ax,useEffect as Bu}from"react";import{useDebouncedCallback as Cx}from"use-debounce";var Sx=500,zu=100,Yu=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=Ix(),{mode:i,containerRef:a}=q(),[s,l]=Ax({history:[],currentStep:0}),{history:c,currentStep:d}=s,p=d>0,f=d<c.length-1,m=Dt((v,I)=>{n(v[I].nodes),r(v[I].edges)},[n,r]),y=Dt(()=>{if(d>0){let v=d-1;l(I=>w(_({},I),{currentStep:v})),m(c,v)}},[d,c,m]),E=Dt(()=>{if(d<c.length-1){let v=d+1;l(I=>w(_({},I),{currentStep:v})),m(c,v)}},[c,d,m]),u=Dt(v=>{l(I=>{let C=I.history[I.currentStep];if(C&&JSON.stringify(C)===JSON.stringify(v))return I;let S=[...I.history.slice(0,I.currentStep+1),v],L=S.length>zu?S.slice(S.length-zu):S;return{history:L,currentStep:L.length-1}})},[]),g=Dt((v,I)=>{let C=v.map(R=>w(_({},R),{selected:!1,className:"",data:w(_({},R.data),{hasError:!1})})),P=I.map(R=>w(_({},R),{data:w(_({},R.data),{hasError:!1})}));return{nodes:on(C),edges:P}},[]),h=Dt(()=>g(t(),o()),[t,o,g]),x=Cx(()=>{let v=h();u(v)},Sx),T=Dt((v,I)=>{if(!e)return;if(c.length===0){let R=h();l({history:[R],currentStep:0})}if(v==="forceSave"){if(I){u(g(I.nodes,I.edges));return}x();return}v.some(R=>R.type==="select")||v.some(R=>R.type==="position"&&R.dragging)||x()},[e,x,c.length,h,u,g]);Bu(()=>{if(e&&c.length===0){let v=h();l({history:[v],currentStep:0})}},[e,c.length,h]);let b=Dt(v=>{l({history:v||[],currentStep:0})},[]),N=Dt(()=>{l({history:[],currentStep:0})},[]);return Bu(()=>{if(i!=="edit")return;let v=a.current;if(!v)return;let I=C=>{if(!v.contains(document.activeElement)||!(C.ctrlKey||C.metaKey))return;let S=C.key.toLowerCase();if(C.shiftKey&&S==="z"){C.preventDefault(),E();return}S==="z"&&(C.preventDefault(),y())};return v.addEventListener("keydown",I),()=>{v.removeEventListener("keydown",I)}},[y,E,i,a]),{history:c,undo:y,redo:E,canUndo:p,canRedo:f,saveHistory:T,resetHistory:b,clearHistory:N}};var Fu=()=>{let{t:e}=Mx(),[t,o,n]=Lx([]),[r,i,a]=Px([]),{getNodes:s,getNode:l}=Rx(),{toast:c}=Le(),d=Dx(),{instanceId:p,isInitialized:f,setIsConnecting:m,setIsMultipleSelection:y,onElementClick:E}=q(),{updateHelperLines:u,HelperLines:g}=Sr(),{undo:h,redo:x,canUndo:T,canRedo:b,saveHistory:N}=Yu(f),{onNodeDrag:v,onDrop:I,onDragOver:C,onDragLeave:P,onNodeDragStop:R,onNodeDragStart:S}=Su({nodes:t,setNodes:o,setEdges:i,saveHistory:N}),{isValidConnection:L,onConnect:K,onReconnect:j,onReconnectStart:Q,onReconnectEnd:z,setReconnectingEdge:M,clearReconnectingEdge:V}=gu({setEdges:i,saveHistory:N}),{handleValidationComplete:D,clearValidation:A,dismissValidationPanel:B,validateDiagram:G,getIsClearingValidation:k}=wu(),{importFromLia:O}=fi(),{handleTasksStatus:Y,handleClearTaskStatus:F}=Gu(),{clearPathEdges:U}=ao(),{emitElementChanges:X,handleNodeChanges:$,handleEdgeChanges:te}=di(),ie=Aa();Cu({saveHistory:N}),Mu({saveHistory:N}),Vu();let W=vt(()=>{o([]),i([]),U(),setTimeout(ie,0)},[o,i,U,ie]),{selectElements:oe,clearSelection:le}=Et(),{importFromMxGraph:Z,exportToMxGraph:xe}=to(),{configureElement:me,getConfigureElement:_e}=Vr(),J=vt(he=>{he!=null&&he.id&&oe([he.id])},[oe]),{sendMessage:de}=mi({LIA_CREATE_DIAGRAM:O,CLEAR_DIAGRAM:W,TASKS_STATUS:Y,CLEAR_TASKS_STATUS:F,EXTERNAL_TASK_SELECT:J}),re=vt(()=>t.length+r.length,[t,r]);Ox(()=>(Tt.set(p,{importFromMxGraph:Z,exportToMxGraph:xe,selectElements:oe,clearSelection:le,configureElement:me,getConfigureElement:_e,getElementsCount:re,setReconnectingEdge:M,clearReconnectingEdge:V}),()=>{Tt.delete(p)}),[p,Z,xe,oe,le,me,_e,re,M,V]);let ee=vt((he,fe)=>{if(fe.type!=="TASK"&&fe.type!=="GATEWAY")return;let pe=_e(fe.id);pe&&(E==null||E(pe)),fe.type==="TASK"&&de("SELECT_TASK",{id:fe.id})},[_e,E,de]),ge=vt((he,fe)=>{if(fe.type!=="SEQUENCE_EDGE")return;let pe=l(fe.source),ve=l(fe.target),{isFromStartEvent:Ze,isGatewayToGateway:nt,isActiviyToAndGateway:Ye,isToEndEvent:ht}=Jn(pe,ve);if(!(!Ze&&!nt&&!Ye&&!ht))return;let It=_e(fe.id);It&&(E==null||E(It))},[_e,l,E]),be=vt(he=>{let fe=u(he,t);n(fe),N(he),k()||B(),$(he)},[t,n,N,k,B,u,$]),Te=vt(he=>{a(he),N(he),k()||B(),te(he)},[a,N,k,B,te]);Lu(be);let Re=vt(({nodes:he,edges:fe})=>{y(he.length+fe.length>=2)},[y]);kx({onChange:Re});let ot=vt(async({nodes:he})=>he.some(pe=>pe.type==="LANE"&&t.some(ve=>ve.parentId===pe.id))?(c({variant:"error",title:e("validation.errors.title"),content:e("editor.toolbar.delete_pool_lane_error")}),!1):!0,[t,e,c]),wt=()=>{N("forceSave"),X(),B()},mt=()=>{m(!0)},gt=()=>{m(!1),B()},qe=vt(he=>{let fe=new Set(he.filter(pe=>pe.type==="LANE"&&!!pe.parentId).map(pe=>pe.parentId));fe.size!==0&&setTimeout(()=>{var Ze,nt;let pe=s(),ve=new Map(pe.map(Ye=>[Ye.id,Ye]));for(let Ye of fe){let ht=so(pe.filter(At=>At.type==="LANE"&&At.parentId===Ye));if(ht.length===0)continue;let Ot=0;for(let At of ht)ve.set(At.id,w(_({},At),{position:{x:se.HEADER_WIDTH,y:Ot}})),Ot+=(nt=(Ze=At.measured)==null?void 0:Ze.height)!=null?nt:0;let It=ve.get(Ye);It&&ve.set(Ye,w(_({},It),{height:Ot,measured:w(_({},It.measured),{height:Ot})}))}o(pe.map(Ye=>{var ht;return(ht=ve.get(Ye.id))!=null?ht:Ye}))},0)},[s,o]);return{nodes:t,setNodes:o,edges:r,setEdges:i,events:{isValidConnection:L,onConnect:K,onReconnect:j,onReconnectStart:Q,onReconnectEnd:z,onDrop:I,onDragOver:C,onDragLeave:P,onNodeDrag:v,onNodeDragStop:R,onNodeDragStart:S,onNodeClick:ee,onEdgeClick:ge,onDropCapture:wt,onConnectStart:mt,onConnectEnd:gt,onSelectionEnd:()=>setTimeout(()=>d.setState({nodesSelectionActive:!1}),0),onNodesChange:be,onEdgesChange:Te,onBeforeDelete:ot,onNodesDelete:qe},ui:{handleCloseValidationPanel:A},controls:{undo:h,redo:x,canUndo:T,canRedo:b},components:{HelperLines:g},actions:{saveHistory:N,selectElements:oe,clearSelection:le,exportToMxGraph:xe,validateDiagram:G,handleValidationComplete:D,setReconnectingEdge:M,clearReconnectingEdge:V}}};import{useReactFlow as Vx}from"@xyflow/react";import{useCallback as Hx,useEffect as Gx,useRef as Bx,useState as zx}from"react";var Yx=".react-flow__node, .react-flow__edge, .react-flow__node-toolbar";function Wu(e,t,o){let[n,r]=zx(!1),i=Bx(null),{getViewport:a,setViewport:s}=Vx(),l=Hx(()=>{i.current=null,r(!1)},[]);return Gx(()=>{let c=e.current;if(!c)return;let d=m=>{if(!Pn.some(E=>E===m.button)||t.current||o.current||(r(!0),!(m.target instanceof Element))||!m.target.closest(Yx))return;m.preventDefault(),m.stopPropagation();let y=a();i.current={pointerX:m.clientX,pointerY:m.clientY,viewportX:y.x,viewportY:y.y,zoom:y.zoom}},p=m=>{let y=i.current;if(y){if((m.buttons&Ms)===0){l();return}s({x:y.viewportX+(m.clientX-y.pointerX),y:y.viewportY+(m.clientY-y.pointerY),zoom:y.zoom})}},f=m=>{(m.buttons&Ms)===0&&l()};return c.addEventListener("pointerdown",d,!0),window.addEventListener("pointermove",p),window.addEventListener("pointerup",f),window.addEventListener("pointercancel",l),window.addEventListener("blur",l),()=>{c.removeEventListener("pointerdown",d,!0),window.removeEventListener("pointermove",p),window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",l),window.removeEventListener("blur",l)}},[e,t,o,a,s,l]),n}import{jsx as Xu}from"react/jsx-runtime";var hi=({id:e,className:t})=>Xu("marker",{id:e,className:H("react-flow__arrowhead",t),viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"7",markerHeight:"7",orient:"auto",markerUnits:"userSpaceOnUse",fill:"currentColor",stroke:"currentColor",children:Xu("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as yi,jsxs as Fx}from"react/jsx-runtime";var Uu=()=>yi("svg",{style:{position:"absolute",top:0,left:0},children:Fx("defs",{children:[yi(hi,{id:"sequence-edge-marker",className:"text-grey-500"}),yi(hi,{id:"sequence-edge-marker-hovered",className:"text-grey-800"}),yi(hi,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{Tooltip as U_,TooltipContent as $_,TooltipTrigger as K_,useTranslation as q_}from"@produto-lecom/lecom-ui";import{useKeyPress as Ep,useReactFlow as u_}from"@xyflow/react";import{Button as wi,Tooltip as Ii,TooltipContent as Ai,TooltipTrigger as Ci,useTranslation as p_}from"@produto-lecom/lecom-ui";import{HandIcon as f_,ListCheckIcon as m_,Loader2Icon as g_,MapIcon as h_,MousePointerIcon as y_}from"lucide-react";import{useCallback as Ys,useEffect as _p,useState as x_}from"react";import{Tooltip as cE,TooltipContent as dE,TooltipTrigger as uE,useTranslation as pE}from"@produto-lecom/lecom-ui";var Vn=(x=>(x.START_EVENT="START_EVENT",x.END_EVENT="END_EVENT",x.TASK="TASK",x.SUBPROCESS="SUBPROCESS",x.GATEWAY="GATEWAY",x.LANE="LANE",x.ANNOTATION="ANNOTATION",x.CONNECTION="CONNECTION",x.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",x.ACTIVITY="ACTIVITY",x.PROCESS_INTERFACE="PROCESS_INTERFACE",x.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",x.VARIANT_ACTIVITY="VARIANT_ACTIVITY",x.AUTO_ACTIVITY="AUTO_ACTIVITY",x.DATA_STORE="DATA_STORE",x.DATA_OBJECT="DATA_OBJECT",x.DATA_OUTPUT="DATA_OUTPUT",x.DATA_INPUT="DATA_INPUT",x.MARKER="MARKER",x))(Vn||{});import{Button as tE,useTranslation as oE}from"@produto-lecom/lecom-ui";import{useReactFlow as nE}from"@xyflow/react";var xi=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 $u({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);Ei(i,`${o}.csv`)}var Ei=(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 Ku(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}var iO={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},qu={script:"SCRIPT",subprocess:"SUBPROCESS"},Zu={"marker-loop":"LOOP"},Ju={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL",inclusive:"EXCLUSIVE"};var bo=({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}}},Xx=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=ue.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=ue.START_EVENT.MIN_HEIGHT,{node:bo({cell:e,type:"START_EVENT"}),status:n,originalType:o}},Ux=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=ue.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=ue.END_EVENT.MIN_HEIGHT,{node:bo({cell:e,type:"END_EVENT"}),status:n,originalType:o}},$x=(e,t)=>{let{id:o,subType:n,style:r}=e==null?void 0:e._attributes,i=qu[n],a=t.get(o)||"",s=Zu[a]||"",l=s==="LOOP",c="imported";return!["script","none"].includes(n)&&!l&&(c="adapted"),e.mxGeometry._attributes.width=Vt(e.mxGeometry._attributes.width||0,ue.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=Vt(e.mxGeometry._attributes.height||0,ue.TASK.MIN_HEIGHT),{node:bo({cell:e,type:"TASK",variant:i,attribute:s}),status:c,originalType:r}},Kx=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=Ju[o],r=["none","inclusive","event-based"],i="imported";return r.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=ue.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=ue.GATEWAY.MIN_HEIGHT,{node:bo({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},qx=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:bo({cell:e,type:"LANE"}),status:"imported",originalType:t}},Zx=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=Vt(e.mxGeometry._attributes.width||0,ue.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=Vt(e.mxGeometry._attributes.height||0,ue.ANNOTATION.MIN_HEIGHT),{node:bo({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},Qu=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=ue.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=ue.UNSUPPORTED.MIN_HEIGHT,{node:bo({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},ju=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return w(_({},st),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},ep={TASK:$x,GATEWAY:Kx,START_EVENT:Xx,END_EVENT:Ux,LANE:qx,ANNOTATION:Zx};var Jx=e=>{let t=new Map,o=Object.values(Vn),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=ep[l]||Qu,{node:d,status:p,originalType:f}=c(s,r);a.push(d),i.push({originalType:f,type:d.type,variant:d.data.variant,value:Ku(d.data.label),status:p})}return{nodes:a,governanceIdToNodeIdMap:t,summary:i}},Qx=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>ju(r,t)),jx=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=Jx(t.root.mxCell),i=Qx(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},eE=async e=>{let t=await xi(e),o=Qr(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}},tp=async e=>{try{let t=await eE(e),{nodes:o,edges:n,summary:r}=jx(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};import{jsx as rE}from"react/jsx-runtime";var op=()=>{let{t:e}=oE(),{toast:t}=Le(),{setNodes:o,setEdges:n}=nE(),{fitToNodes:r}=eo(),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:rE(tE,{size:"small",variant:"ghost",onClick:()=>$u({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 tp(s);if(o(f=>f.concat(l)),n(f=>f.concat(c)),r(l),d.some(f=>f.status==="unsupported")){i(d);return}t({variant:"success",content:e("adapter.governance.success.default")})}catch(l){let c=l instanceof Error?l.message:"DEFAULT";t({variant:"error",content:e(`adapter.governance.error.${c}`)})}}}};import{Button as iE}from"@produto-lecom/lecom-ui";import{useRef as sE}from"react";import{Fragment as aE,jsx as np,jsxs as lE}from"react/jsx-runtime";var rp=s=>{var l=s,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,a=yt(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=sE(null),d=f=>{let m=f.target.files;m!=null&&m.length&&i(m),c.current&&(c.current.value="")};return lE(aE,{children:[np(iE,w(_({disabled:n,onClick:f=>{var m;(m=c.current)==null||m.click(),r==null||r(f)}},a),{children:e})),np("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};import{jsx as _i,jsxs as fE}from"react/jsx-runtime";var ip=({disabled:e=!1})=>{let{t}=pE(),{toast:o}=Le(),{importFromGovernance:n}=op(),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 fE(cE,{children:[_i(uE,{asChild:!0,children:_i(rp,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:_i(aa,{})})}),_i(dE,{color:"black",children:t("editor.controls.actions.import_governance")})]})};import{jsx as mE}from"react/jsx-runtime";var Ls=({shortcut:e})=>mE("span",{className:"min-h-7.5 inline-flex justify-center items-center py-0.5 px-1.5 bg-grey-100 border border-grey-300 font-mono text-gray-800 shadow-lg rounded-md text-grey-900",children:e});import{Button as NE,DropdownMenu as wE,DropdownMenuContent as IE,DropdownMenuItem as Rs,DropdownMenuTrigger as AE,Tooltip as Ti,TooltipContent as vi,TooltipTrigger as Ni,useTranslation as CE}from"@produto-lecom/lecom-ui";import{FileCodeIcon as SE,FileImageIcon as ME,FolderOutputIcon as PE,PrinterIcon as LE}from"lucide-react";import{useState as kE}from"react";import{useTranslation as gE}from"@produto-lecom/lecom-ui";import{useReactFlow as hE}from"@xyflow/react";import{toPng as sp,toSvg as yE}from"html-to-image";import{useState as xE}from"react";var EE=3,ks="diagram",bi=50,_E=96,bE=25.4,TE="sequence-edge-marker",ap=e=>e*bE/_E,vE=e=>{let t=document.getElementById(TE);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},lp=()=>{let{t:e}=gE(),{toast:t}=Le(),{getEdges:o,getNodes:n,getNodesBounds:r}=hE(),{clearSelection:i}=Et(),[a,s]=xE({png:!1,html:!1,print:!1}),l=()=>{let m=ys(n(),o()),y=r(m),E=y.width+bi*2,u=y.height+bi*2,g=bi-y.x,h=bi-y.y;return{width:E,height:u,style:{width:`${E}px`,height:`${u}px`,transform:`translate(${g}px, ${h}px)`,transformOrigin:"top left"}}},c=async(m,y)=>{s(E=>w(_({},E),{[y]:!0})),await i();try{if(ys(n(),o()).length===0){t({content:e("editor.controls.actions.export.feedback.empty"),variant:"warning"});return}let u=xd();if(!u)throw new Error("Flow element not found");let g=l(),h=vE(u);try{return await m(u,g)}finally{h==null||h.remove()}}catch(E){console.error("Diagram export failed",E),t({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{s(E=>w(_({},E),{[y]:!1}))}};return{exportAsPng:async(m=ks)=>{await c(async(y,E)=>{let u=await sp(y,w(_({},E),{backgroundColor:"#fcfcfc",skipFonts:!0}));Ei(u,`${m}.png`)},"png")},exportAsHtml:async(m=ks)=>{await c(async(y,E)=>{let u=await yE(y,w(_({},E),{backgroundColor:"#fcfcfc",skipFonts:!0})),g=`
44
44
  <!DOCTYPE html>
45
45
  <html>
46
46
  <head>
47
47
  <meta charset="utf-8" />
48
- <title>${f}</title>
48
+ <title>${m}</title>
49
49
  <style>
50
50
  html, body {
51
51
  margin: 0;
@@ -65,11 +65,11 @@ var Lp=Object.defineProperty,kp=Object.defineProperties;var Rp=Object.getOwnProp
65
65
  </style>
66
66
  </head>
67
67
  <body>
68
- <img src="${p}" alt="${f}" />
68
+ <img src="${u}" alt="${m}" />
69
69
  </body>
70
- </html>`,h=new Blob([g],{type:"text/html"}),x=URL.createObjectURL(h);yi(x,`${f}.html`),window.setTimeout(()=>URL.revokeObjectURL(x),1e4)},"html")},printDiagram:async(f=Ps)=>{await c(async(y,E)=>{var C;let p=await op(y,w(_({},E),{backgroundColor:"#fcfcfc",pixelRatio:mE,skipFonts:!0})),g=document.createElement("iframe");g.style.position="fixed",g.style.right="0",g.style.bottom="0",g.style.width="0",g.style.height="0",g.style.border="0",document.body.appendChild(g);let h=(C=g.contentWindow)==null?void 0:C.document;if(!h)throw document.body.removeChild(g),new Error("Unable to access print iframe document");let x=np(E.width).toFixed(2),v=np(E.height).toFixed(2),b=h.createElement("style");b.textContent=`
70
+ </html>`,h=new Blob([g],{type:"text/html"}),x=URL.createObjectURL(h);Ei(x,`${m}.html`),window.setTimeout(()=>URL.revokeObjectURL(x),1e4)},"html")},printDiagram:async(m=ks)=>{await c(async(y,E)=>{var C;let u=await sp(y,w(_({},E),{backgroundColor:"#fcfcfc",pixelRatio:EE,skipFonts:!0})),g=document.createElement("iframe");g.style.position="fixed",g.style.right="0",g.style.bottom="0",g.style.width="0",g.style.height="0",g.style.border="0",document.body.appendChild(g);let h=(C=g.contentWindow)==null?void 0:C.document;if(!h)throw document.body.removeChild(g),new Error("Unable to access print iframe document");let x=ap(E.width).toFixed(2),T=ap(E.height).toFixed(2),b=h.createElement("style");b.textContent=`
71
71
  @page {
72
- size: ${x}mm ${v}mm;
72
+ size: ${x}mm ${T}mm;
73
73
  margin: 0;
74
74
  }
75
75
  html, body {
@@ -83,11 +83,11 @@ var Lp=Object.defineProperty,kp=Object.defineProperties;var Rp=Object.getOwnProp
83
83
  height: 100%;
84
84
  object-fit: contain;
85
85
  }
86
- `,h.head.appendChild(b),h.title=f;let N=h.createElement("img");N.alt="Diagram",h.body.appendChild(N),await new Promise((P,R)=>{let S=!1,L=K=>{S||(S=!0,K?R(K):P())};N.onload=()=>L(),N.onerror=()=>L(new Error("Failed to load print image")),N.src=p,N.complete&&N.naturalWidth>0&&L()});let T=g.contentWindow;if(!T)throw document.body.removeChild(g),new Error("Unable to access print iframe window");let A=()=>{g.parentNode&&document.body.removeChild(g)};T.addEventListener("afterprint",A,{once:!0}),window.setTimeout(A,6e4),T.focus(),T.print()},"print")},isPrintingPng:a.png,isPrintingHtml:a.html,isPrinting:a.print}};import{jsx as Le,jsxs as Ko}from"react/jsx-runtime";function ip(){let{t:e}=vE(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:a}=rp(),[s,l]=CE(!1);return Ko(_E,{modal:!1,open:s,onOpenChange:l,children:[Le(TE,{asChild:!0,children:Le("div",{children:Ko(_i,{children:[Le(Ti,{asChild:!0,children:Le(EE,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:Le(AE,{})})}),!s&&Le(bi,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),Ko(bE,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[Ko(_i,{children:[Le(Ti,{asChild:!0,children:Le(Ls,{className:"p-1.5",disabled:i,onClick:()=>t(),children:Le(wE,{})})}),Le(bi,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),Ko(_i,{children:[Le(Ti,{asChild:!0,children:Le(Ls,{className:"p-1.5",disabled:a,onClick:()=>o(),children:Le(NE,{})})}),Le(bi,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),Ko(_i,{children:[Le(Ti,{asChild:!0,children:Le(Ls,{className:"p-1.5",disabled:r,onClick:()=>n(),children:Le(IE,{})})}),Le(bi,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{useState as HE}from"react";import{Button as GE,Tooltip as BE,TooltipContent as zE,TooltipTrigger as YE,useTranslation as FE}from"@produto-lecom/lecom-ui";import{ClipboardPasteIcon as WE}from"lucide-react";import{useState as ap}from"react";import{Button as lp,Dialog as SE,DialogContent as ME,DialogDescription as PE,DialogFooter as LE,DialogHeader as kE,DialogTitle as RE,Textarea as DE,useTranslation as OE}from"@produto-lecom/lecom-ui";var sp=e=>{if(!e)return"";let t=e.trim();return t=t.replace(/```[a-zA-Z]*\s*/g,"").replace(/```/g,""),t=t.replace(/^\s*(graph|flowchart)\s+[A-Za-z]{1,2}\s*\r?\n/i,""),t.trim()};import{jsx as _o,jsxs as ks}from"react/jsx-runtime";var VE=`Um passo (A --> B) por linha, com um ID antes de cada n\xF3. Ex.:
86
+ `,h.head.appendChild(b),h.title=m;let N=h.createElement("img");N.alt="Diagram",h.body.appendChild(N),await new Promise((P,R)=>{let S=!1,L=K=>{S||(S=!0,K?R(K):P())};N.onload=()=>L(),N.onerror=()=>L(new Error("Failed to load print image")),N.src=u,N.complete&&N.naturalWidth>0&&L()});let v=g.contentWindow;if(!v)throw document.body.removeChild(g),new Error("Unable to access print iframe window");let I=()=>{g.parentNode&&document.body.removeChild(g)};v.addEventListener("afterprint",I,{once:!0}),window.setTimeout(I,6e4),v.focus(),v.print()},"print")},isPrintingPng:a.png,isPrintingHtml:a.html,isPrinting:a.print}};import{jsx as ke,jsxs as qo}from"react/jsx-runtime";function cp(){let{t:e}=CE(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:a}=lp(),[s,l]=kE(!1);return qo(wE,{modal:!1,open:s,onOpenChange:l,children:[ke(AE,{asChild:!0,children:ke("div",{children:qo(Ti,{children:[ke(Ni,{asChild:!0,children:ke(NE,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:ke(PE,{})})}),!s&&ke(vi,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),qo(IE,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[qo(Ti,{children:[ke(Ni,{asChild:!0,children:ke(Rs,{className:"p-1.5",disabled:i,onClick:()=>t(),children:ke(ME,{})})}),ke(vi,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),qo(Ti,{children:[ke(Ni,{asChild:!0,children:ke(Rs,{className:"p-1.5",disabled:a,onClick:()=>o(),children:ke(SE,{})})}),ke(vi,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),qo(Ti,{children:[ke(Ni,{asChild:!0,children:ke(Rs,{className:"p-1.5",disabled:r,onClick:()=>n(),children:ke(LE,{})})}),ke(vi,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Button as FE,DropdownMenu as WE,DropdownMenuContent as XE,DropdownMenuItem as mp,DropdownMenuTrigger as UE,Tooltip as Os,TooltipContent as Vs,TooltipTrigger as Hs,useTranslation as $E}from"@produto-lecom/lecom-ui";import{CircleIcon as KE,ClipboardPasteIcon as qE,FileCodeIcon as ZE}from"lucide-react";import{useRef as JE,useState as gp}from"react";import{useState as up}from"react";import{Button as pp,Dialog as RE,DialogContent as DE,DialogDescription as OE,DialogFooter as VE,DialogHeader as HE,DialogTitle as GE,Textarea as BE,useTranslation as zE}from"@produto-lecom/lecom-ui";var dp=e=>{if(!e)return"";let t=e.trim();return t=t.replace(/```[a-zA-Z]*\s*/g,"").replace(/```/g,""),t=t.replace(/^\s*(graph|flowchart)\s+[A-Za-z]{1,2}\s*\r?\n/i,""),t.trim()};import{jsx as To,jsxs as Ds}from"react/jsx-runtime";var YE=`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>`,cp=({open:e,onOpenChange:t})=>{let{t:o}=OE(),{importFromLia:n}=pi(),[r,i]=ap(""),[a,s]=ap(null),l=d=>{d||(i(""),s(null)),t(d)},c=()=>{let d=sp(r);if(!d){s(o("editor.modals.mermaid_import.error_empty"));return}try{n(d),l(!1)}catch(u){console.error("Falha ao gerar o diagrama a partir de Mermaid:",u),s(o("editor.modals.mermaid_import.error_parse"))}};return _o(SE,{open:e,onOpenChange:l,children:ks(ME,{className:"w-[90vw] max-w-4xl",children:[ks(kE,{children:[_o(RE,{children:o("editor.modals.mermaid_import.title")}),_o(PE,{children:o("editor.modals.mermaid_import.description")})]}),_o(DE,{value:r,onChange:d=>{i(d.target.value),a&&s(null)},placeholder:VE,rows:16,className:"max-h-[60vh] min-h-[360px] resize-y font-mono"}),a&&_o("p",{className:"text-sm text-red-500",children:a}),ks(LE,{children:[_o(lp,{variant:"ghost",color:"grey",onClick:()=>l(!1),children:o("editor.modals.mermaid_import.cancel")}),_o(lp,{variant:"filled",color:"blue",onClick:c,children:o("editor.modals.mermaid_import.generate")})]})]})})};import{Fragment as XE,jsx as On,jsxs as dp}from"react/jsx-runtime";var up=()=>{let{t:e}=FE(),[t,o]=HE(!1);return dp(XE,{children:[dp(BE,{children:[On(YE,{asChild:!0,children:On(GE,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>o(!0),children:On(WE,{})})}),On(zE,{color:"black",children:e("editor.controls.actions.import_mermaid")})]}),On(cp,{open:t,onOpenChange:o})]})};import{useCallback as UE,useState as $E}from"react";import{Button as KE,DropdownMenu as qE,DropdownMenuContent as ZE,DropdownMenuItem as pp,DropdownMenuTrigger as JE,Tooltip as Rs,TooltipContent as Ds,TooltipTrigger as Os,useTranslation as QE}from"@produto-lecom/lecom-ui";import{useReactFlow as jE}from"@xyflow/react";import{AlignHorizontalJustifyStartIcon as e_,AlignVerticalJustifyStartIcon as t_,NetworkIcon as o_}from"lucide-react";import{jsx as $e,jsxs as Vn}from"react/jsx-runtime";function fp(){let{t:e}=QE(),{getNodes:t,getEdges:o,setNodes:n}=jE(),{fitToNodes:r}=jt(),[i,a]=$E(!1),s=UE(l=>{let c=t();if(c.length===0)return;let d=c.map(y=>{var E,p,g,h;return w(_({},y),{width:(p=y.width)!=null?p:(E=y.measured)==null?void 0:E.width,height:(h=y.height)!=null?h:(g=y.measured)==null?void 0:g.height})}),{nodes:u}=ti(d,o(),l),m=new Map(u.map(y=>[y.id,y.position])),f=c.map(y=>{var E;return w(_({},y),{position:(E=m.get(y.id))!=null?E:y.position})});n(f),r(f)},[t,o,n,r]);return Vn(qE,{modal:!1,open:i,onOpenChange:a,children:[$e(JE,{asChild:!0,children:$e("div",{children:Vn(Rs,{children:[$e(Os,{asChild:!0,children:$e(KE,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:$e(o_,{})})}),!i&&$e(Ds,{color:"black",children:e("editor.controls.actions.organize.title")})]})})}),Vn(ZE,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[Vn(Rs,{children:[$e(Os,{asChild:!0,children:$e(pp,{className:"p-1.5",onClick:()=>s("TB"),children:$e(t_,{})})}),$e(Ds,{side:"right",color:"black",children:e("editor.controls.actions.organize.vertical")})]}),Vn(Rs,{children:[$e(Os,{asChild:!0,children:$e(pp,{className:"p-1.5",onClick:()=>s("LR"),children:$e(e_,{})})}),$e(Ds,{side:"right",color:"black",children:e("editor.controls.actions.organize.horizontal")})]})]})]})}import{Fragment as Hs,jsx as Ae,jsxs as vt}from"react/jsx-runtime";var hp=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=r_(),{clearSelection:i}=xt(),{mode:a,containerRef:s,featureFlags:l,isMinimapOpen:c,setIsMinimapOpen:d,isMoveTool:u,isHandTool:m,setIsMoveTool:f,setIsHandTool:y}=q(),{getNodes:E,getEdges:p}=n_(),g=mp(["v","V"],{target:s==null?void 0:s.current}),h=mp(["h","H"],{target:s==null?void 0:s.current}),x=Vs(()=>{i(),y(!0),f(!1)},[i,y,f]),v=Vs(()=>{f(!0),y(!1)},[f,y]),[b,N]=d_(!1),T=Vs(async()=>{N(!0);try{let A=E(),C=p(),P=await o({nodes:A,edges:C});n(P)}finally{N(!1)}},[E,p,o,n]);return gp(()=>{g&&!u&&a==="edit"&&v()},[g,v,u,a]),gp(()=>{h&&!m&&a==="edit"&&x()},[h,x,m,a]),vt("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[a==="edit"&&vt(Hs,{children:[vt(Ni,{children:[Ae(Ai,{asChild:!0,children:Ae(vi,{size:"small",variant:"ghost",color:"grey",className:H(u&&"bg-grey-400"),iconButton:!0,onClick:v,children:Ae(c_,{})})}),vt(wi,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),Ae(Ms,{shortcut:"V"})]})]}),vt(Ni,{children:[Ae(Ai,{asChild:!0,children:Ae(vi,{size:"small",variant:"ghost",color:"grey",className:H(m&&"bg-grey-400"),iconButton:!0,onClick:x,children:Ae(i_,{})})}),vt(wi,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",Ae(Ms,{shortcut:"H"})]})]})]}),Ae(ip,{}),a==="edit"&&vt(Hs,{children:[(l==null?void 0:l.importDiagramMermaidEnabled)&&vt(Hs,{children:[Ae(up,{}),Ae(fp,{})]}),vt(Ni,{children:[Ae(Ai,{asChild:!0,children:Ae(vi,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:b,onClick:T,children:b?Ae(a_,{className:"animate-spin"}):Ae(s_,{})})}),Ae(wi,{color:"black",children:r(b?"editor.controls.actions.check_loading":"editor.controls.actions.check")})]}),Ae(tp,{disabled:e.length>0||t.length>0})]}),vt(Ni,{children:[Ae(Ai,{asChild:!0,children:Ae(vi,{size:"small",variant:"ghost",color:"grey",className:H(c&&"bg-grey-400"),iconButton:!0,onClick:()=>d(!c),children:Ae(l_,{})})}),Ae(wi,{color:"black",children:r(c?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as yp,Tooltip as xp,TooltipContent as Ep,TooltipTrigger as _p,useTranslation as u_}from"@produto-lecom/lecom-ui";import{RedoIcon as p_,UndoIcon as f_}from"lucide-react";import{jsx as to,jsxs as Gs}from"react/jsx-runtime";var bp=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=u_();return Gs("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Gs(xp,{children:[to(_p,{asChild:!0,children:to(yp,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:to(f_,{})})}),to(Ep,{color:"black",children:r("editor.controls.history.undo")})]}),Gs(xp,{children:[to(_p,{asChild:!0,children:to(yp,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:to(p_,{})})}),to(Ep,{color:"black",children:r("editor.controls.history.redo")})]})]})};import{useEdges as m_,useNodes as g_,useReactFlow as h_}from"@xyflow/react";import{Button as Ii,Tooltip as Ci,TooltipContent as Si,TooltipTrigger as Mi,useTranslation as y_}from"@produto-lecom/lecom-ui";import{ScanIcon as x_,ZoomIn as E_,ZoomOut as __}from"lucide-react";import{jsx as Ve,jsxs as Hn}from"react/jsx-runtime";var Tp=()=>{let{t:e}=y_(),t=g_(),o=m_(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:a}=h_(),s=t.length===0&&o.length===0;return Hn("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Hn(Ci,{children:[Ve(Mi,{asChild:!0,children:Ve(Ii,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>a(),children:Ve(x_,{})})}),Ve(Si,{color:"black",children:e("editor.controls.zoom.fit")})]}),Hn(Ci,{children:[Ve(Mi,{asChild:!0,children:Ve(Ii,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>r(),children:Ve(__,{})})}),Ve(Si,{color:"black",children:e("editor.controls.zoom.out")})]}),Hn(Ci,{children:[Ve(Mi,{asChild:!0,children:Ve(Ii,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>i(1),children:Ve(ia,{})})}),Ve(Si,{color:"black",children:e("editor.controls.zoom.reset")})]}),Hn(Ci,{children:[Ve(Mi,{asChild:!0,children:Ve(Ii,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>n(),children:Ve(E_,{})})}),Ve(Si,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{ViewportPortal as b_}from"@xyflow/react";import{jsx as Bs,jsxs as vp}from"react/jsx-runtime";var Np=()=>vp(b_,{children:[vp("svg",{width:"20",height:"20",viewBox:"0 0 20 20",className:"text-grey-400 -translate-x-1/2 -translate-y-1/2 pointer-events-none",children:[Bs("line",{x1:"0",y1:"10",x2:"20",y2:"10",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"}),Bs("line",{x1:"10",y1:"0",x2:"10",y2:"20",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"})]}),Bs("div",{className:"absolute top-1 left-1 text-xs font-medium text-grey-400 bg-white/70 px-1 rounded-sm pointer-events-none",children:"0,0"})]});import{useNodes as T_}from"@xyflow/react";import{Button as v_,Tooltip as N_,TooltipContent as w_,TooltipTrigger as A_,useTranslation as I_}from"@produto-lecom/lecom-ui";import{useRef as C_,useState as S_}from"react";import{Bot as M_}from"lucide-react";import{jsx as bo,jsxs as wp}from"react/jsx-runtime";var Ap=()=>{let e=C_(null),{t}=I_(),{setDraggableNode:o}=Wo(),n=T_(),{setIsDragging:r}=q(),[i,a]=S_(void 0),s=[{type:"START_EVENT",icon:Wn,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:To,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:Zo,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:Qo,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SERVICE_TASK",icon:M_,label:t("bpmn.task.variant.service_task")},{type:"TASK",variant:"SCRIPT",icon:ca,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:la,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:No,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:wo,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:vo,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:ra,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:Yn,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),a(bo(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return wp("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[bo("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:s.map((c,d)=>{let u=!Yt(c.type,n),m=u?t("editor.toolbar.start_event_already_exists"):c.label;return wp(N_,{children:[bo(A_,{asChild:!0,children:bo(v_,{className:H("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":u}),size:"small",variant:"ghost",color:"grey",draggable:!u,disabled:u,iconButton:!0,onDragStart:u?void 0:f=>l(f,c),children:bo(c.icon,{})},d)}),bo(w_,{color:"black",side:"right",children:m})]},d)})}),bo("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{jsx as lt,jsxs as Pi}from"react/jsx-runtime";var zs=e=>e.preventDefault(),Ys=O_((e,t)=>{let{instanceId:o,containerRef:n,mode:r,isMinimapOpen:i,isMoveTool:a,isHandTool:s}=q(),l=D_("Space",{target:n==null?void 0:n.current}),c=Ip(s),d=Ip(l),{nodes:u,edges:m,actions:f,events:y,components:E,controls:p}=Hu(),{t:g}=z_();c.current=s,d.current=l;let h=Gu(n,c,d);V_(t,()=>({selectElements:f.selectElements,clearSelection:f.clearSelection}));let x=s||l||r!=="edit",v=x?[0,1,2]:Sn,b=s||l||h,N=a&&!l&&!h,T=r==="edit"&&N,A=!x&&!h,C=r==="view"||N;return Pi("div",{ref:n,className:"w-full h-full outline-none",tabIndex:0,children:[r==="edit"&&lt(Ap,{}),lt(zu,{}),Pi(k_,w(_({},y),{id:`modeler-${o}`,className:H(r.toLowerCase(),{"is-hand-tool":b,"is-pan-tool-active":b}),edges:m,nodes:u,nodeTypes:$d,edgeTypes:Kd,minZoom:Is,maxZoom:eu,panOnDrag:v,panOnScroll:!0,selectionOnDrag:A,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:C,nodesConnectable:T,nodesDraggable:T,connectionLineComponent:Wd,selectionMode:R_.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:T?"Delete":null,selectionKeyCode:null,defaultViewport:iu,connectOnClick:!1,connectionRadius:50,onPaneContextMenu:zs,onNodeContextMenu:zs,onEdgeContextMenu:zs,proOptions:{hideAttribution:!0},children:[lt(P_,{gap:Qd,size:Jd,color:Zd,bgColor:qd}),lt(Np,{}),i&&Pi(H_,{children:[lt(B_,{asChild:!0,children:lt("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:lt(L_,{pannable:!0,zoomable:!0,position:jd,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),lt(G_,{color:"black",children:g("editor.controls.actions.minimap.label")})]}),Pi("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&lt(bp,_({},p)),r!=="readonly"&&lt(hp,{nodes:u,edges:m,validateDiagram:f.validateDiagram,handleValidationComplete:f.handleValidationComplete}),lt(Tp,{})]}),lt(E.HelperLines,{})]}))]})});Ys.displayName="Editor";import{useStore as Y_}from"@xyflow/react";import{useEffect as F_,useRef as W_}from"react";import{jsx as U_}from"react/jsx-runtime";var X_=e=>({width:e.width,height:e.height,transform:e.transform}),Fs="rgba(51, 103, 217, 0.4)",yc=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=Y_(X_),i=W_(null);return F_(()=>{let a=i.current,s=a==null?void 0:a.getContext("2d");if(!s||!a)return;let l=window.devicePixelRatio;a.width=o*l,a.height=n*l,s.clearRect(0,0,o,n),s.scale(l,l),s.strokeStyle=Fs,t&&(s.beginPath(),s.strokeStyle=t.color||Fs,s.moveTo(t.position*r[2]+r[0],0),s.lineTo(t.position*r[2]+r[0],n),s.stroke()),e&&(s.beginPath(),s.strokeStyle=e.color||Fs,s.moveTo(0,e.position*r[2]+r[1]),s.lineTo(o,e.position*r[2]+r[1]),s.stroke())},[o,n,r,e,t]),U_("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as $_,Notification as K_,TooltipProvider as q_}from"@produto-lecom/lecom-ui";import{createContext as Z_,useContext as J_,useEffect as Q_,useState as j_}from"react";import{jsx as Cp,jsxs as tb}from"react/jsx-runtime";var bt=new Map,Sp=Z_(null),bn=()=>{let e=J_(Sp);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},eb=({locale:e,defaultMode:t="view",featureFlags:o,toast:n,children:r})=>{let[i,a]=j_(e||"pt_BR");Q_(()=>{e&&(a(e),$_.changeLanguage(e))},[e]);let s=E=>{let p=bt.size;if(p===0)throw new Error("No modeler instances found");if(p===1||!E){let[h]=bt.values();return h}let g=bt.get(E);if(!g)throw new Error(`Modeler instance with ID "${E}" not found`);return g},l=(E,p)=>{let g=s(p);return g==null?void 0:g.selectElements(E)},c=async E=>{let p=s(E);return p==null?void 0:p.clearSelection()},d=(E,p)=>{let g=s(p);return g==null?void 0:g.configureElement(E)},u=(E,p)=>{let g=s(p);return g==null?void 0:g.getConfigureElement(E)},m=async(E,p)=>{let g=s(p);await(g==null?void 0:g.importFromMxGraph(E))},f=E=>{let p=s(E);return p==null?void 0:p.exportToMxGraph()},y=E=>{let p=s(E);return(p==null?void 0:p.getElementsCount())||0};return Cp(Sp.Provider,{value:{defaultMode:t,locale:i,featureFlags:o,selectElements:l,clearSelection:c,configureElement:d,getConfigureElement:u,importDiagram:m,exportDiagram:f,getElementsCount:y,toast:n},children:tb(q_,{children:[!n&&Cp(K_,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),r]})})};import{jsx as Ws}from"react/jsx-runtime";var Pp=rb(null),q=()=>{let e=ib(Pp);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},cb=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,edgeHighlight:r=!0,validateCustomDiagram:i,onElementChanges:a,onConfigureElement:s,onElementClick:l,onSubprocessValidationClick:c})=>{let d=lb(null),{t:u}=ob(),{defaultMode:m,featureFlags:f}=bn(),y=ab(),[E]=pt(o||y),[p,g]=pt(n||m||"edit"),[h,x]=pt(wn),[v,b]=pt(!1),[N,T]=pt(!0),[A,C]=pt(!1),[P,R]=pt(!1),[S,L]=pt(!1),[K,j]=pt(!1),[Q,z]=pt(!1),[M,V]=pt(null);sb(()=>{n&&g(n)},[n]);let D=!!t,I=Mp(()=>t||$c(u),[t,u]),B=Mp(()=>({instanceId:E,containerRef:d,initialDiagram:I,mode:p,featureFlags:f,edgeHighlight:r,isEdit:p==="edit",isView:p==="view",isReadOnly:p==="readonly",isNewDiagram:D,lastElementId:h,isInitialized:v,isMinimapOpen:P,isMoveTool:N,isHandTool:A,isDragging:S,isMultipleSelection:Q,isConnecting:K,setLastElementId:x,setIsInitialized:b,reconnectingEdgeId:M,setIsMinimapOpen:R,setIsMoveTool:T,setIsHandTool:C,setIsDragging:L,setIsConnecting:j,setIsMultipleSelection:z,setReconnectingEdgeId:V,validateCustomDiagram:i,onElementChanges:a,onConfigureElement:s,onElementClick:l,onSubprocessValidationClick:c}),[E,d,I,p,f,r,D,h,v,P,N,A,S,Q,K,M,i,a,s,l,c]);return Ws(nb,{children:Ws(Pp.Provider,{value:B,children:Ws(Ys,{ref:e})})})};export{Ie as EditorMode,ki as ElementPosition,Bn as ElementType,Ri as GatewayElementVariant,ct as GatewayVariant,cb as Modeler,eb as ModelerProvider,yt as NodeAttribute,ae as NodeType,Ze as NodeVariant,Di as RoutingVariant,bn as useModeler};
93
+ E --> F<end>`,fp=({open:e,onOpenChange:t})=>{let{t:o}=zE(),{importFromLia:n}=fi(),[r,i]=up(""),[a,s]=up(null),l=d=>{d||(i(""),s(null)),t(d)},c=()=>{let d=dp(r);if(!d){s(o("editor.modals.mermaid_import.error_empty"));return}try{n(d),l(!1)}catch(p){console.error("Falha ao gerar o diagrama a partir de Mermaid:",p),s(o("editor.modals.mermaid_import.error_parse"))}};return To(RE,{open:e,onOpenChange:l,children:Ds(DE,{className:"w-[90vw] max-w-4xl",children:[Ds(HE,{children:[To(GE,{children:o("editor.modals.mermaid_import.title")}),To(OE,{children:o("editor.modals.mermaid_import.description")})]}),To(BE,{value:r,onChange:d=>{i(d.target.value),a&&s(null)},placeholder:YE,rows:16,className:"max-h-[60vh] min-h-[360px] resize-y font-mono"}),a&&To("p",{className:"text-sm text-red-500",children:a}),Ds(VE,{children:[To(pp,{variant:"ghost",color:"grey",onClick:()=>l(!1),children:o("editor.modals.mermaid_import.cancel")}),To(pp,{variant:"filled",color:"blue",onClick:c,children:o("editor.modals.mermaid_import.generate")})]})]})})};import{Fragment as jE,jsx as He,jsxs as Zo}from"react/jsx-runtime";var QE=".xml,text/xml,application/xml";function hp(){let{t:e}=$E(),{importFromMxGraph:t}=to(),{toast:o}=Le(),[n,r]=gp(!1),[i,a]=gp(!1),s=JE(null),l=async c=>{var p;let d=(p=c.target.files)==null?void 0:p[0];if(c.target.value="",!!d)try{let f=await xi(d);await t(f)}catch(f){console.error("Falha ao importar o XML:",f),o({variant:"error",content:e("editor.controls.actions.import.feedback.error")})}};return Zo(jE,{children:[Zo(WE,{modal:!1,open:n,onOpenChange:r,children:[He(UE,{asChild:!0,children:He("div",{children:Zo(Os,{children:[He(Hs,{asChild:!0,children:He(FE,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:He(qE,{})})}),!n&&He(Vs,{color:"black",children:e("editor.controls.actions.import.title")})]})})}),Zo(XE,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[Zo(Os,{children:[He(Hs,{asChild:!0,children:He(mp,{className:"p-1.5",onClick:()=>{var c;return(c=s.current)==null?void 0:c.click()},children:He(ZE,{})})}),He(Vs,{side:"right",color:"black",children:e("editor.controls.actions.import.xml")})]}),Zo(Os,{children:[He(Hs,{asChild:!0,children:He(mp,{className:"p-1.5",onClick:()=>a(!0),children:He(KE,{})})}),He(Vs,{side:"right",color:"black",children:e("editor.controls.actions.import.mermaid")})]})]})]}),He("input",{ref:s,type:"file",className:"sr-only",accept:QE,onChange:l}),He(fp,{open:i,onOpenChange:a})]})}import{useCallback as e_,useState as t_}from"react";import{Button as o_,DropdownMenu as n_,DropdownMenuContent as r_,DropdownMenuItem as yp,DropdownMenuTrigger as i_,Tooltip as Gs,TooltipContent as Bs,TooltipTrigger as zs,useTranslation as s_}from"@produto-lecom/lecom-ui";import{useReactFlow as a_}from"@xyflow/react";import{AlignHorizontalJustifyStartIcon as l_,AlignVerticalJustifyStartIcon as c_,NetworkIcon as d_}from"lucide-react";import{jsx as Ke,jsxs as Hn}from"react/jsx-runtime";function xp(){let{t:e}=s_(),{getNodes:t,getEdges:o,setNodes:n}=a_(),{fitToNodes:r}=eo(),{toast:i}=Le(),[a,s]=t_(!1),l=e_(c=>{let d=t();if(d.length===0)return;if(d.some(u=>u.parentId)){i({content:e("editor.controls.actions.organize.feedback.pool_lane"),variant:"warning"});return}let f=d.map(u=>{var g,h,x,T;return w(_({},u),{width:(h=u.width)!=null?h:(g=u.measured)==null?void 0:g.width,height:(T=u.height)!=null?T:(x=u.measured)==null?void 0:x.height})}),{nodes:m}=oi(f,o(),c),y=new Map(m.map(u=>[u.id,u.position])),E=d.map(u=>{var g;return w(_({},u),{position:(g=y.get(u.id))!=null?g:u.position})});n(E),r(E)},[t,o,n,r,i,e]);return Hn(n_,{modal:!1,open:a,onOpenChange:s,children:[Ke(i_,{asChild:!0,children:Ke("div",{children:Hn(Gs,{children:[Ke(zs,{asChild:!0,children:Ke(o_,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:Ke(d_,{})})}),!a&&Ke(Bs,{color:"black",children:e("editor.controls.actions.organize.title")})]})})}),Hn(r_,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[Hn(Gs,{children:[Ke(zs,{asChild:!0,children:Ke(yp,{className:"p-1.5",onClick:()=>l("TB"),children:Ke(c_,{})})}),Ke(Bs,{side:"right",color:"black",children:e("editor.controls.actions.organize.vertical")})]}),Hn(Gs,{children:[Ke(zs,{asChild:!0,children:Ke(yp,{className:"p-1.5",onClick:()=>l("LR"),children:Ke(l_,{})})}),Ke(Bs,{side:"right",color:"black",children:e("editor.controls.actions.organize.horizontal")})]})]})]})}import{Fragment as Fs,jsx as Ie,jsxs as Nt}from"react/jsx-runtime";var bp=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=p_(),{clearSelection:i}=Et(),{mode:a,containerRef:s,featureFlags:l,isMinimapOpen:c,setIsMinimapOpen:d,isMoveTool:p,isHandTool:f,setIsMoveTool:m,setIsHandTool:y}=q(),{getNodes:E,getEdges:u}=u_(),g=Ep(["v","V"],{target:s==null?void 0:s.current}),h=Ep(["h","H"],{target:s==null?void 0:s.current}),x=Ys(()=>{i(),y(!0),m(!1)},[i,y,m]),T=Ys(()=>{m(!0),y(!1)},[m,y]),[b,N]=x_(!1),v=Ys(async()=>{N(!0);try{let I=E(),C=u(),P=await o({nodes:I,edges:C});n(P)}finally{N(!1)}},[E,u,o,n]);return _p(()=>{g&&!p&&a==="edit"&&T()},[g,T,p,a]),_p(()=>{h&&!f&&a==="edit"&&x()},[h,x,f,a]),Nt("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[a==="edit"&&Nt(Fs,{children:[Nt(Ii,{children:[Ie(Ci,{asChild:!0,children:Ie(wi,{size:"small",variant:"ghost",color:"grey",className:H(p&&"bg-grey-400"),iconButton:!0,onClick:T,children:Ie(y_,{})})}),Nt(Ai,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),Ie(Ls,{shortcut:"V"})]})]}),Nt(Ii,{children:[Ie(Ci,{asChild:!0,children:Ie(wi,{size:"small",variant:"ghost",color:"grey",className:H(f&&"bg-grey-400"),iconButton:!0,onClick:x,children:Ie(f_,{})})}),Nt(Ai,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",Ie(Ls,{shortcut:"H"})]})]})]}),Ie(cp,{}),a==="edit"&&Nt(Fs,{children:[(l==null?void 0:l.importDiagramMermaidEnabled)&&Nt(Fs,{children:[Ie(hp,{}),Ie(xp,{})]}),Nt(Ii,{children:[Ie(Ci,{asChild:!0,children:Ie(wi,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:b,onClick:v,children:b?Ie(g_,{className:"animate-spin"}):Ie(m_,{})})}),Ie(Ai,{color:"black",children:r(b?"editor.controls.actions.check_loading":"editor.controls.actions.check")})]}),Ie(ip,{disabled:e.length>0||t.length>0})]}),Nt(Ii,{children:[Ie(Ci,{asChild:!0,children:Ie(wi,{size:"small",variant:"ghost",color:"grey",className:H(c&&"bg-grey-400"),iconButton:!0,onClick:()=>d(!c),children:Ie(h_,{})})}),Ie(Ai,{color:"black",children:r(c?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as Tp,Tooltip as vp,TooltipContent as Np,TooltipTrigger as wp,useTranslation as E_}from"@produto-lecom/lecom-ui";import{RedoIcon as __,UndoIcon as b_}from"lucide-react";import{jsx as no,jsxs as Ws}from"react/jsx-runtime";var Ip=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=E_();return Ws("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Ws(vp,{children:[no(wp,{asChild:!0,children:no(Tp,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:no(b_,{})})}),no(Np,{color:"black",children:r("editor.controls.history.undo")})]}),Ws(vp,{children:[no(wp,{asChild:!0,children:no(Tp,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:no(__,{})})}),no(Np,{color:"black",children:r("editor.controls.history.redo")})]})]})};import{useEdges as T_,useNodes as v_,useReactFlow as N_}from"@xyflow/react";import{Button as Si,Tooltip as Mi,TooltipContent as Pi,TooltipTrigger as Li,useTranslation as w_}from"@produto-lecom/lecom-ui";import{ScanIcon as I_,ZoomIn as A_,ZoomOut as C_}from"lucide-react";import{jsx as Ge,jsxs as Gn}from"react/jsx-runtime";var Ap=()=>{let{t:e}=w_(),t=v_(),o=T_(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:a}=N_(),s=t.length===0&&o.length===0;return Gn("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Gn(Mi,{children:[Ge(Li,{asChild:!0,children:Ge(Si,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>a(),children:Ge(I_,{})})}),Ge(Pi,{color:"black",children:e("editor.controls.zoom.fit")})]}),Gn(Mi,{children:[Ge(Li,{asChild:!0,children:Ge(Si,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>r(),children:Ge(C_,{})})}),Ge(Pi,{color:"black",children:e("editor.controls.zoom.out")})]}),Gn(Mi,{children:[Ge(Li,{asChild:!0,children:Ge(Si,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>i(1),children:Ge(da,{})})}),Ge(Pi,{color:"black",children:e("editor.controls.zoom.reset")})]}),Gn(Mi,{children:[Ge(Li,{asChild:!0,children:Ge(Si,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>n(),children:Ge(A_,{})})}),Ge(Pi,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{ViewportPortal as S_}from"@xyflow/react";import{jsx as Xs,jsxs as Cp}from"react/jsx-runtime";var Sp=()=>Cp(S_,{children:[Cp("svg",{width:"20",height:"20",viewBox:"0 0 20 20",className:"text-grey-400 -translate-x-1/2 -translate-y-1/2 pointer-events-none",children:[Xs("line",{x1:"0",y1:"10",x2:"20",y2:"10",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"}),Xs("line",{x1:"10",y1:"0",x2:"10",y2:"20",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"})]}),Xs("div",{className:"absolute top-1 left-1 text-xs font-medium text-grey-400 bg-white/70 px-1 rounded-sm pointer-events-none",children:"0,0"})]});import{useNodes as M_}from"@xyflow/react";import{Button as P_,Tooltip as L_,TooltipContent as k_,TooltipTrigger as R_,useTranslation as D_}from"@produto-lecom/lecom-ui";import{useRef as O_,useState as V_}from"react";import{Bot as H_}from"lucide-react";import{jsx as vo,jsxs as Mp}from"react/jsx-runtime";var Pp=()=>{let e=O_(null),{t}=D_(),{setDraggableNode:o}=Uo(),n=M_(),{setIsDragging:r}=q(),[i,a]=V_(void 0),s=[{type:"START_EVENT",icon:Xn,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:No,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:Qo,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:en,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SERVICE_TASK",icon:H_,label:t("bpmn.task.variant.service_task")},{type:"TASK",variant:"SCRIPT",icon:ma,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:fa,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:Io,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:Ao,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:wo,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:ca,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:Fn,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),a(vo(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return Mp("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[vo("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:s.map((c,d)=>{let p=!Ft(c.type,n),f=p?t("editor.toolbar.start_event_already_exists"):c.label;return Mp(L_,{children:[vo(R_,{asChild:!0,children:vo(P_,{className:H("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":p}),size:"small",variant:"ghost",color:"grey",draggable:!p,disabled:p,iconButton:!0,onDragStart:p?void 0:m=>l(m,c),children:vo(c.icon,{})},d)}),vo(k_,{color:"black",side:"right",children:f})]},d)})}),vo("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{jsx as ct,jsxs as ki}from"react/jsx-runtime";var Us=e=>e.preventDefault(),$s=W_((e,t)=>{let{instanceId:o,containerRef:n,mode:r,isMinimapOpen:i,isMoveTool:a,isHandTool:s}=q(),l=F_("Space",{target:n==null?void 0:n.current}),c=Lp(s),d=Lp(l),{nodes:p,edges:f,actions:m,events:y,components:E,controls:u}=Fu(),{t:g}=q_();c.current=s,d.current=l;let h=Wu(n,c,d);X_(t,()=>({selectElements:m.selectElements,clearSelection:m.clearSelection}));let x=s||l||r!=="edit",T=x?[0,1,2]:Pn,b=s||l||h,N=a&&!l&&!h,v=r==="edit"&&N,I=!x&&!h,C=r==="view"||N;return ki("div",{ref:n,className:"w-full h-full outline-none",tabIndex:0,children:[r==="edit"&&ct(Pp,{}),ct(Uu,{}),ki(z_,w(_({},y),{id:`modeler-${o}`,className:H(r.toLowerCase(),{"is-hand-tool":b,"is-pan-tool-active":b}),edges:f,nodes:p,nodeTypes:Qd,edgeTypes:jd,minZoom:Ss,maxZoom:iu,panOnDrag:T,panOnScroll:!0,selectionOnDrag:I,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:C,nodesConnectable:v,nodesDraggable:v,connectionLineComponent:qd,selectionMode:Y_.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:v?"Delete":null,selectionKeyCode:null,defaultViewport:du,connectOnClick:!1,connectionRadius:50,onPaneContextMenu:Us,onNodeContextMenu:Us,onEdgeContextMenu:Us,proOptions:{hideAttribution:!0},children:[ct(G_,{gap:nu,size:ou,color:tu,bgColor:eu}),ct(Sp,{}),i&&ki(U_,{children:[ct(K_,{asChild:!0,children:ct("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:ct(B_,{pannable:!0,zoomable:!0,position:ru,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),ct($_,{color:"black",children:g("editor.controls.actions.minimap.label")})]}),ki("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&ct(Ip,_({},u)),r!=="readonly"&&ct(bp,{nodes:p,edges:f,validateDiagram:m.validateDiagram,handleValidationComplete:m.handleValidationComplete}),ct(Ap,{})]}),ct(E.HelperLines,{})]}))]})});$s.displayName="Editor";import{useStore as Z_}from"@xyflow/react";import{useEffect as J_,useRef as Q_}from"react";import{jsx as eb}from"react/jsx-runtime";var j_=e=>({width:e.width,height:e.height,transform:e.transform}),Ks="rgba(51, 103, 217, 0.4)",Tc=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=Z_(j_),i=Q_(null);return J_(()=>{let a=i.current,s=a==null?void 0:a.getContext("2d");if(!s||!a)return;let l=window.devicePixelRatio;a.width=o*l,a.height=n*l,s.clearRect(0,0,o,n),s.scale(l,l),s.strokeStyle=Ks,t&&(s.beginPath(),s.strokeStyle=t.color||Ks,s.moveTo(t.position*r[2]+r[0],0),s.lineTo(t.position*r[2]+r[0],n),s.stroke()),e&&(s.beginPath(),s.strokeStyle=e.color||Ks,s.moveTo(0,e.position*r[2]+r[1]),s.lineTo(o,e.position*r[2]+r[1]),s.stroke())},[o,n,r,e,t]),eb("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as tb,Notification as ob,TooltipProvider as nb}from"@produto-lecom/lecom-ui";import{createContext as rb,useContext as ib,useEffect as sb,useState as ab}from"react";import{jsx as kp,jsxs as cb}from"react/jsx-runtime";var Tt=new Map,Rp=rb(null),vn=()=>{let e=ib(Rp);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},lb=({locale:e,defaultMode:t="view",featureFlags:o,toast:n,children:r})=>{let[i,a]=ab(e||"pt_BR");sb(()=>{e&&(a(e),tb.changeLanguage(e))},[e]);let s=E=>{let u=Tt.size;if(u===0)throw new Error("No modeler instances found");if(u===1||!E){let[h]=Tt.values();return h}let g=Tt.get(E);if(!g)throw new Error(`Modeler instance with ID "${E}" not found`);return g},l=(E,u)=>{let g=s(u);return g==null?void 0:g.selectElements(E)},c=async E=>{let u=s(E);return u==null?void 0:u.clearSelection()},d=(E,u)=>{let g=s(u);return g==null?void 0:g.configureElement(E)},p=(E,u)=>{let g=s(u);return g==null?void 0:g.getConfigureElement(E)},f=async(E,u)=>{let g=s(u);await(g==null?void 0:g.importFromMxGraph(E))},m=E=>{let u=s(E);return u==null?void 0:u.exportToMxGraph()},y=E=>{let u=s(E);return(u==null?void 0:u.getElementsCount())||0};return kp(Rp.Provider,{value:{defaultMode:t,locale:i,featureFlags:o,selectElements:l,clearSelection:c,configureElement:d,getConfigureElement:p,importDiagram:f,exportDiagram:m,getElementsCount:y,toast:n},children:cb(nb,{children:[!n&&kp(ob,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),r]})})};import{jsx as qs}from"react/jsx-runtime";var Op=pb(null),q=()=>{let e=fb(Op);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},yb=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,edgeHighlight:r=!0,validateCustomDiagram:i,onElementChanges:a,onConfigureElement:s,onElementClick:l,onSubprocessValidationClick:c})=>{let d=hb(null),{t:p}=db(),{defaultMode:f,featureFlags:m}=vn(),y=gb(),[E]=ft(o||y),[u,g]=ft(n||f||"edit"),[h,x]=ft(An),[T,b]=ft(!1),[N,v]=ft(!0),[I,C]=ft(!1),[P,R]=ft(!1),[S,L]=ft(!1),[K,j]=ft(!1),[Q,z]=ft(!1),[M,V]=ft(null);mb(()=>{n&&g(n)},[n]);let D=!!t,A=Dp(()=>t||Qc(p),[t,p]),B=Dp(()=>({instanceId:E,containerRef:d,initialDiagram:A,mode:u,featureFlags:m,edgeHighlight:r,isEdit:u==="edit",isView:u==="view",isReadOnly:u==="readonly",isNewDiagram:D,lastElementId:h,isInitialized:T,isMinimapOpen:P,isMoveTool:N,isHandTool:I,isDragging:S,isMultipleSelection:Q,isConnecting:K,setLastElementId:x,setIsInitialized:b,reconnectingEdgeId:M,setIsMinimapOpen:R,setIsMoveTool:v,setIsHandTool:C,setIsDragging:L,setIsConnecting:j,setIsMultipleSelection:z,setReconnectingEdgeId:V,validateCustomDiagram:i,onElementChanges:a,onConfigureElement:s,onElementClick:l,onSubprocessValidationClick:c}),[E,d,A,u,m,r,D,h,T,P,N,I,S,Q,K,M,i,a,s,l,c]);return qs(ub,{children:qs(Op.Provider,{value:B,children:qs($s,{ref:e})})})};export{Ae as EditorMode,Di as ElementPosition,zn as ElementType,Oi as GatewayElementVariant,dt as GatewayVariant,yb as Modeler,lb as ModelerProvider,xt as NodeAttribute,ae as NodeType,Je as NodeVariant,Vi as RoutingVariant,vn as useModeler};