lecom-modeler 0.39.0 → 0.39.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/lib/index.cjs +12 -12
  2. package/lib/index.js +12 -12
  3. package/package.json +1 -1
package/lib/index.cjs CHANGED
@@ -1,8 +1,8 @@
1
- "use strict";var xf=Object.create;var qn=Object.defineProperty,Ef=Object.defineProperties,_f=Object.getOwnPropertyDescriptor,bf=Object.getOwnPropertyDescriptors,Tf=Object.getOwnPropertyNames,Br=Object.getOwnPropertySymbols,vf=Object.getPrototypeOf,Ts=Object.prototype.hasOwnProperty,va=Object.prototype.propertyIsEnumerable;var Ta=(e,t,o)=>t in e?qn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,_=(e,t)=>{for(var o in t||(t={}))Ts.call(t,o)&&Ta(e,o,t[o]);if(Br)for(var o of Br(t))va.call(t,o)&&Ta(e,o,t[o]);return e},w=(e,t)=>Ef(e,bf(t));var Ut=(e,t)=>{var o={};for(var n in e)Ts.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Br)for(var n of Br(e))t.indexOf(n)<0&&va.call(e,n)&&(o[n]=e[n]);return o};var Nf=(e,t)=>{for(var o in t)qn(e,o,{get:t[o],enumerable:!0})},Na=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Tf(t))!Ts.call(e,r)&&r!==o&&qn(e,r,{get:()=>t[r],enumerable:!(n=_f(t,r))||n.enumerable});return e};var wf=(e,t,o)=>(o=e!=null?xf(vf(e)):{},Na(t||!e||!e.__esModule?qn(o,"default",{value:e,enumerable:!0}):o,e)),Af=e=>Na(qn({},"__esModule",{value:!0}),e);var Ay={};Nf(Ay,{EditorMode:()=>Ye,ElementPosition:()=>Yr,ElementType:()=>Zn,GatewayElementVariant:()=>Fr,GatewayVariant:()=>It,Modeler:()=>yf,ModelerProvider:()=>ff,NodeAttribute:()=>Dt,NodeType:()=>se,NodeVariant:()=>it,RoutingVariant:()=>Wr,useModeler:()=>Ln});module.exports=Af(Ay);var vs=e=>{if(typeof document=="undefined")return;let t=document.cookie.match(new RegExp(`(?:^|; )${e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")}=([^;]*)`));return t?decodeURIComponent(t[1]):void 0};var zr=require("@produto-lecom/lecom-ui");var wa={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",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 Aa={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",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 Ia={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",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 Ca={pt_BR:Ia,en_US:wa,es_ES:Aa};var Sa,Ma,If=(Ma=(Sa=vs("LecomUserLanguage"))!=null?Sa:vs("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?Ma:zr.Translations.PT_BR;(0,zr.initializeI18n)({lng:If,resources:Ca});var Ye=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(Ye||{});var Zn=(i=>(i.ACTIVITY="activity",i.ROUTING="routing",i.GATEWAY="gateway",i.SUB_PROCESS="sub_process",i.SERVICE_TASK="service_task",i))(Zn||{}),Yr=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Yr||{}),Fr=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Fr||{}),Wr=(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))(Wr||{});var wo=require("lucide-react");var Fo=require("react/jsx-runtime"),Xr=({size:e=24,className:t})=>(0,Fo.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:[(0,Fo.jsx)("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),(0,Fo.jsx)("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),(0,Fo.jsx)("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),(0,Fo.jsx)("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});var Ns=require("react/jsx-runtime"),gn=({size:e=24,className:t})=>(0,Ns.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#ff6565",stroke:"#ec1616",strokeWidth:3,className:t,children:(0,Ns.jsx)("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});var To=require("react/jsx-runtime"),hn=({size:e=24,className:t})=>(0,To.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[(0,To.jsx)("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,To.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,To.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,To.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,To.jsx)("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var yn=require("react/jsx-runtime"),xn=({size:e=24,className:t})=>(0,yn.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[(0,yn.jsx)("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,yn.jsx)("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,yn.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var En=require("react/jsx-runtime"),_n=({size:e=24,className:t})=>(0,En.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[(0,En.jsx)("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,En.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,En.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});var bn=require("react/jsx-runtime"),Pa=({size:e=24,className:t})=>(0,bn.jsx)("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:(0,bn.jsxs)("g",{children:[(0,bn.jsx)("path",{d:"M8.6543 11.4141V15.2148C8.51302 15.4017 8.29199 15.6068 7.99121 15.8301C7.69499 16.0488 7.30078 16.238 6.80859 16.3975C6.31641 16.557 5.70345 16.6367 4.96973 16.6367C4.34538 16.6367 3.77344 16.5319 3.25391 16.3223C2.73438 16.1081 2.28548 15.7959 1.90723 15.3857C1.53353 14.9756 1.24414 14.4766 1.03906 13.8887C0.833984 13.2962 0.731445 12.6217 0.731445 11.8652V11.1748C0.731445 10.4229 0.82487 9.75293 1.01172 9.16504C1.20312 8.57259 1.47656 8.07129 1.83203 7.66113C2.1875 7.25098 2.61589 6.94108 3.11719 6.73145C3.62305 6.51725 4.19499 6.41016 4.83301 6.41016C5.64876 6.41016 6.32324 6.54688 6.85645 6.82031C7.39421 7.08919 7.80892 7.46289 8.10059 7.94141C8.39225 8.41992 8.57682 8.9668 8.6543 9.58203H6.97266C6.91797 9.23568 6.81087 8.92578 6.65137 8.65234C6.49642 8.37891 6.27311 8.16471 5.98145 8.00977C5.69434 7.85026 5.32064 7.77051 4.86035 7.77051C4.46387 7.77051 4.11523 7.8457 3.81445 7.99609C3.51367 8.14648 3.26302 8.36751 3.0625 8.65918C2.86654 8.95085 2.71842 9.30632 2.61816 9.72559C2.5179 10.1449 2.46777 10.6234 2.46777 11.1611V11.8652C2.46777 12.4121 2.52474 12.8975 2.63867 13.3213C2.75716 13.7451 2.92578 14.1029 3.14453 14.3945C3.36784 14.6862 3.639 14.9072 3.95801 15.0576C4.27702 15.2035 4.63704 15.2764 5.03809 15.2764C5.43001 15.2764 5.7513 15.2445 6.00195 15.1807C6.2526 15.1123 6.45085 15.0326 6.59668 14.9414C6.74707 14.8457 6.86328 14.7546 6.94531 14.668V12.6924H4.87402V11.4141H8.6543ZM17.0912 11.25V11.7969C17.0912 12.5488 16.9932 13.2233 16.7973 13.8203C16.6013 14.4173 16.321 14.9255 15.9564 15.3447C15.5964 15.764 15.1635 16.0853 14.6576 16.3086C14.1518 16.5273 13.5912 16.6367 12.976 16.6367C12.3653 16.6367 11.807 16.5273 11.3012 16.3086C10.7999 16.0853 10.3646 15.764 9.99551 15.3447C9.62637 14.9255 9.33926 14.4173 9.13418 13.8203C8.93366 13.2233 8.8334 12.5488 8.8334 11.7969V11.25C8.8334 10.498 8.93366 9.82585 9.13418 9.2334C9.3347 8.63639 9.61725 8.12826 9.98184 7.70898C10.351 7.28516 10.7862 6.96387 11.2875 6.74512C11.7934 6.52181 12.3516 6.41016 12.9623 6.41016C13.5775 6.41016 14.1381 6.52181 14.6439 6.74512C15.1498 6.96387 15.585 7.28516 15.9496 7.70898C16.3142 8.12826 16.5945 8.63639 16.7904 9.2334C16.991 9.82585 17.0912 10.498 17.0912 11.25ZM15.3754 11.7969V11.2363C15.3754 10.6803 15.3207 10.1904 15.2113 9.7666C15.1065 9.33822 14.9493 8.98047 14.7396 8.69336C14.5346 8.40169 14.2816 8.18294 13.9809 8.03711C13.6801 7.88672 13.3406 7.81152 12.9623 7.81152C12.584 7.81152 12.2468 7.88672 11.9506 8.03711C11.6544 8.18294 11.4014 8.40169 11.1918 8.69336C10.9867 8.98047 10.8295 9.33822 10.7201 9.7666C10.6107 10.1904 10.5561 10.6803 10.5561 11.2363V11.7969C10.5561 12.3529 10.6107 12.8451 10.7201 13.2734C10.8295 13.7018 10.989 14.0641 11.1986 14.3604C11.4128 14.652 11.668 14.873 11.9643 15.0234C12.2605 15.1693 12.5977 15.2422 12.976 15.2422C13.3588 15.2422 13.6983 15.1693 13.9945 15.0234C14.2908 14.873 14.5414 14.652 14.7465 14.3604C14.9516 14.0641 15.1065 13.7018 15.2113 13.2734C15.3207 12.8451 15.3754 12.3529 15.3754 11.7969ZM20.6678 14.6816L23.2859 6.54688H25.1795L21.6111 16.5H20.3328L20.6678 14.6816ZM18.2479 6.54688L20.8455 14.6816L21.201 16.5H19.9158L16.3611 6.54688H18.2479Z"}),(0,bn.jsx)("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});var La=require("clsx"),ka=require("tailwind-merge");function H(...e){return(0,ka.twMerge)((0,La.clsx)(e))}var vo=(e=0,t=0)=>e<t?t:e,Ur=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});var Jn=require("react/jsx-runtime"),Ra=({size:e=24,className:t})=>(0,Jn.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:H("stroke-2",t),children:[(0,Jn.jsx)("path",{d:"M19 3H5C3.89543 3 3 3.89543 3 5V19C3 20.1046 3.89543 21 5 21H19C20.1046 21 21 20.1046 21 19V5C21 3.89543 20.1046 3 19 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Jn.jsx)("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});var $r=require("react/jsx-runtime"),Da=({size:e=24,className:t})=>(0,$r.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:(0,$r.jsx)("g",{children:(0,$r.jsx)("path",{d:"M4.85372 6.17472L5.31292 5.71552L5.31993 5.70863C6.88908 4.1924 8.98352 3.34122 11.1655 3.33301L11.1668 3.33301C11.167 3.33301 11.1673 3.33301 11.1675 3.33301C12.7165 3.33314 14.2308 3.79255 15.5188 4.65317C16.807 5.5139 17.811 6.7373 18.4039 8.16866C18.9968 9.60001 19.1519 11.175 18.8497 12.6945C18.5986 13.9567 18.0414 15.1334 17.232 16.1236L16.9457 16.4738L17.2655 16.7936L20.6617 20.1899L20.6617 20.1899C20.7919 20.3201 20.7919 20.5311 20.6617 20.6612L20.6616 20.6613C20.5316 20.7915 20.3205 20.7915 20.1903 20.6613L16.7941 17.265L16.4743 16.9452L16.1241 17.2315C15.1339 18.0409 13.9571 18.5981 12.695 18.8492C11.1755 19.1514 9.6005 18.9963 8.16915 18.4034C6.73778 17.8105 5.51439 16.8065 4.65365 15.5183C3.79291 14.2301 3.3335 12.7156 3.3335 11.1663C3.3335 10.9822 3.48273 10.833 3.66683 10.833C3.85093 10.833 4.00016 10.9822 4.00016 11.1663C4.00016 12.5838 4.42048 13.9694 5.20796 15.148C5.99545 16.3265 7.11474 17.245 8.42426 17.7874C9.73378 18.3299 11.1748 18.4719 12.565 18.1953C13.9552 17.9188 15.2321 17.2362 16.2344 16.234L16.2345 16.234C17.2367 15.2316 17.9193 13.9547 18.1958 12.5645C18.4724 11.1743 18.3304 9.7333 17.7879 8.42378C17.2455 7.11426 16.327 5.99497 15.1484 5.20748L14.8707 5.62322L15.1484 5.20748C13.9703 4.42031 12.5854 4.00001 11.1685 3.99968L11.1664 3.99969C9.15876 4.00767 7.23176 4.7903 5.78712 6.18424L5.78706 6.18418L5.78075 6.1905L5.32512 6.64613L4.47156 7.49968H5.67867H7.8335C8.01759 7.49968 8.16683 7.64892 8.16683 7.83302C8.16683 8.01711 8.01759 8.16635 7.8335 8.16635H3.66683C3.48274 8.16635 3.3335 8.01711 3.3335 7.83302V3.66635C3.3335 3.48225 3.48274 3.33302 3.66683 3.33302C3.85092 3.33302 4.00016 3.48225 4.00016 3.66635V5.82117V7.02827L4.85372 6.17472Z"})})});var ws=require("react/jsx-runtime"),Kr=({size:e=24,className:t})=>(0,ws.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#5fd9b0",stroke:"#1cad86",strokeWidth:"2",className:t,children:(0,ws.jsx)("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});var As=require("react/jsx-runtime"),Qn=({size:e=24,className:t})=>(0,As.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",className:H("stroke-2",t),children:(0,As.jsx)("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"})});var Tn=require("react/jsx-runtime"),Oa=({size:e=24,className:t})=>(0,Tn.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[(0,Tn.jsx)("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Tn.jsx)("path",{d:"M7.5 12C7.5 12.89 7.76392 13.76 8.25839 14.5001C8.75285 15.2401 9.45566 15.8169 10.2779 16.1575C11.1002 16.4981 12.005 16.5872 12.8779 16.4135C13.7508 16.2399 14.5526 15.8113 15.182 15.182C15.8113 14.5526 16.2399 13.7508 16.4135 12.8779C16.5872 12.005 16.4981 11.1002 16.1575 10.2779C15.8169 9.45566 15.2401 8.75285 14.5001 8.25839C13.76 7.76392 12.89 7.5 12 7.5C10.742 7.50473 9.53448 7.99561 8.63 8.87L7.5 10",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Tn.jsx)("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});var No=require("react/jsx-runtime"),Va=({size:e=24,className:t})=>(0,No.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[(0,No.jsx)("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,No.jsx)("path",{d:"M15.5 14.5V8.5C15.5 8.23478 15.3946 7.98043 15.2071 7.79289C15.0196 7.60536 14.7652 7.5 14.5 7.5H8",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,No.jsx)("path",{d:"M10 16.5H16C16.2652 16.5 16.5196 16.3946 16.7071 16.2071C16.8946 16.0196 17 15.7652 17 15.5V15C17 14.8674 16.9473 14.7402 16.8536 14.6464C16.7598 14.5527 16.6326 14.5 16.5 14.5H11.5C11.3674 14.5 11.2402 14.5527 11.1464 14.6464C11.0527 14.7402 11 14.8674 11 15V15.5C11 15.7652 10.8946 16.0196 10.7071 16.2071C10.5196 16.3946 10.2652 16.5 10 16.5ZM10 16.5C9.73478 16.5 9.48043 16.3946 9.29289 16.2071C9.10536 16.0196 9 15.7652 9 15.5V8.5C9 8.23478 8.89464 7.98043 8.70711 7.79289C8.51957 7.60536 8.26522 7.5 8 7.5C7.73478 7.5 7.48043 7.60536 7.29289 7.79289C7.10536 7.98043 7 8.23478 7 8.5V9.5C7 9.63261 7.05268 9.75979 7.14645 9.85355C7.24021 9.94732 7.36739 10 7.5 10H9",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,No.jsx)("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,No.jsx)("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var Wo=require("react/jsx-runtime"),jn=({size:e=24,className:t})=>(0,Wo.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[(0,Wo.jsx)("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Wo.jsx)("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),(0,Wo.jsx)("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Wo.jsx)("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var se=(s=>(s.START_EVENT="START_EVENT",s.END_EVENT="END_EVENT",s.TASK="TASK",s.LANE="LANE",s.GATEWAY="GATEWAY",s.ANNOTATION="ANNOTATION",s.UNSUPPORTED="UNSUPPORTED",s))(se||{}),it=(n=>(n.SCRIPT="SCRIPT",n.SUBPROCESS="SUBPROCESS",n.SERVICE_TASK="SERVICE_TASK",n))(it||{}),qr={SCRIPT:{icon:wo.ScrollText},SUBPROCESS:{icon:wo.SquarePlus},SERVICE_TASK:{icon:wo.Bot}},Dt=(t=>(t.LOOP="LOOP",t))(Dt||{}),Zr={LOOP:{icon:wo.RotateCcw}},It=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(It||{}),Is={EXCLUSIVE:{icon:xn},PARALLEL:{icon:_n},COMPLEX:{icon:hn}};var mf=require("@produto-lecom/lecom-ui"),gf=require("@xyflow/react"),Le=require("react");var so=require("@xyflow/react"),mn=require("react");var _p=require("@produto-lecom/lecom-ui"),oo=require("@xyflow/react"),vt=require("react");var Jr={MIN_WIDTH:36,MIN_HEIGHT:36},Qr={MIN_WIDTH:36,MIN_HEIGHT:36},vn={MIN_WIDTH:56,MIN_HEIGHT:56},Ao={MIN_WIDTH:176,MIN_HEIGHT:96},Ha={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},ae={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},Nn={MIN_WIDTH:176,MIN_HEIGHT:64},Cf={MIN_WIDTH:128,MIN_HEIGHT:64},ue={START_EVENT:Jr,END_EVENT:Qr,GATEWAY:vn,TASK:Ao,LANE:ae,ANNOTATION:Nn,UNSUPPORTED:Cf};var wn=require("@xyflow/react");function Ga(e,t){var x,N,b,T;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+((N=(x=t==null?void 0:t.measured)==null?void 0:x.width)!=null?N:0)/2,u=i.y+((T=(b=t==null?void 0:t.measured)==null?void 0:b.height)!=null?T:0)/2,f=(d-l)/(2*a)-(u-c)/(2*s),m=(d-l)/(2*a)+(u-c)/(2*s),y=1/(Math.abs(f)+Math.abs(m)||1),E=y*f,p=y*m,g=a*(E+p)+l,h=s*(-E+p)+c;return{x:g,y:h}}function Ba(e,t){var c,d,u,f;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(f=(u=e.measured)==null?void 0:u.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?wn.Position.Left:s>=i+n-1?wn.Position.Right:l<=a+1?wn.Position.Top:l>=a+r-1?wn.Position.Bottom:wn.Position.Top}function An(e,t){let o=Ga(e,t),n=Ga(t,e),r=Ba(e,o),i=Ba(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function jr(e,t){return{isFromStartEvent:(e==null?void 0:e.type)==="START_EVENT",isGatewayToGateway:(e==null?void 0:e.type)==="GATEWAY"&&(t==null?void 0:t.type)==="GATEWAY",isActiviyToAndGateway:(e==null?void 0:e.type)==="TASK"&&(t==null?void 0:t.type)==="GATEWAY",isToEndEvent:(t==null?void 0:t.type)==="END_EVENT"}}var za=require("lodash");var Ya=e=>new Map(e.map(t=>[t.id,t])),Fa=(e,t)=>e.map(o=>{var n;return(n=t.get(o.id))!=null?n:o}),Ct=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}},er=e=>(0,za.orderBy)(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),Wa=(e,t)=>{let{x:o,y:n}=Ct(e),{x:r,y:i}=Ct(t);return{x:o-r,y:n-i}};var Xo=({parentId:e,nodes:t,includeTypes:o=[...Object.values(se)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),Sf=(e,t)=>{let{x:o,y:n}=Ct(e),{x:r,y:i}=Ct(t),a=o-r,s=n-i;return Math.sqrt(a*a+s*s)},Mf=(e,t)=>{let{x:o,y:n,w:r,h:i}=Ct(e),{x:a,y:s,w:l,h:c}=Ct(t),d=o+r/2,u=n+i/2;return d>=a&&d<=a+l&&u>=s&&u<=s+c},tr=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&Mf(e,r)){let i=Sf(e,r);i<n&&(n=i,o=r)}return o},Xa=(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 Ua=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}},$a=({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 Cs=(e,t)=>{let o=t.find(a=>a.id===e);if(!o||o.type!=="LANE"||o.parentId)return!1;let n=Ct(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=Ct(a);return s.x<r&&s.x+s.w>n.x&&s.y<i&&s.y+s.h>n.y})};var Pf=50,Uo=(e,t)=>{var f,m,y,E,p,g,h,x,N,b,T,v,A,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=(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=(N=S.position)==null?void 0:N.y)!=null?b:0,K=(v=(T=S.position)==null?void 0:T.x)!=null?v: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+Pf-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})})})},He=15,$o=e=>[...e].sort((t,o)=>t.position.y-o.position.y),Lf=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)},kf=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)},Ss=(e,t,o)=>{var d,u,f,m,y,E,p,g,h,x,N,b,T,v,A;if(t.length===0)return e;let n=(f=(u=e.width)!=null?u:(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=Lf(C),R=kf(C);if(((g=(p=C.position)==null?void 0:p.y)!=null?g:0)<He&&(o.set(C.id,w(_({},C),{position:w(_({},C.position),{y:He})})),R=He+((x=(h=C.measured)==null?void 0:h.height)!=null?x:0)),((b=(N=C.position)==null?void 0:N.x)!=null?b:0)<ae.HEADER_WIDTH+He){let S=(T=o.get(C.id))!=null?T:C;o.set(C.id,w(_({},S),{position:w(_({},S.position),{x:ae.HEADER_WIDTH+He})})),P=ae.HEADER_WIDTH+He+((A=(v=C.measured)==null?void 0:v.width)!=null?A:0)}i=Math.max(i,P),a=Math.max(a,R)}let s=Math.max(n,ae.MIN_WIDTH),l=Math.max(r,ae.MIN_HEIGHT);i+He>s&&(s=i+He),a+He>l&&(l=a+He);let c=w(_({},e),{width:s,height:l,measured:w(_({},e.measured),{width:s,height:l})});return o.set(e.id,c),c},Ka=(e,t,o)=>{var a,s;let n=$o(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=Ss(l,c,t);t.set(d.id,w(_({},d),{position:{x:ae.HEADER_WIDTH,y:i}})),i+=(s=d.height)!=null?s:0}},qa=(e,t)=>{var y,E,p,g;let o=[];for(let h of t.values())h.parentId===e.id&&o.push(h);let n=$o(o),r=((E=(y=e.measured)==null?void 0:y.width)!=null?E:0)-ae.HEADER_WIDTH,i=Xa(e.id,o)||ae.MIN_WIDTH,a=o.reduce((h,x)=>{var N;return h+((N=x.height)!=null?N:ae.MIN_HEIGHT)},0),s=Math.max(r,i),l=a,c=r>i,d=c?s:s+ae.HEADER_WIDTH,u=c?s-ae.HEADER_WIDTH:s,f=0;for(let h=0;h<n.length;h++){let x=n[h],N=Math.max(ae.MIN_HEIGHT,(p=x.height)!=null?p:ae.MIN_HEIGHT),b=w(_({},x),{width:u,height:N,measured:w(_({},x.measured),{width:u,height:N}),position:{x:ae.HEADER_WIDTH,y:f}});if(h===o.length-1){let T=Math.max(ae.MIN_HEIGHT,l-f);b=w(_({},b),{height:T,measured:w(_({},x.measured),{width:u,height:T})})}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})}))},Za=(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=$o(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,f=0,m=[...n];return l.forEach((p,g)=>{var T,v;let h=g===l.length-1,x=p.id===e.id,b=(v=(T=p.measured)==null?void 0:T.height)!=null?v:0;x?b=o:u&&g===c-1&&(b=Math.max(ae.MIN_HEIGHT,r-f)),h&&i&&(b=Math.max(ae.MIN_HEIGHT,o-f)),m=m.map(A=>{if(A.id===p.id){let C=i?t-ae.HEADER_WIDTH:t;return w(_({},A),{width:C,height:b,measured:w(_({},A.measured),{width:C,height:b}),position:{x:ae.HEADER_WIDTH,y:f}})}return A}),x&&u?f=r+o:f+=b}),m=m.map(p=>{if(p.id===a){let g=i?t:t+ae.HEADER_WIDTH;return w(_({},p),{width:g,height:i?o:f,measured:{width:g,height:i?o:f}})}return p}),m};var Ms=(e,t,o)=>{var s,l,c,d,u,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<He&&(e.position.y=He),e.position.x<ae.HEADER_WIDTH+He&&(e.position.x=ae.HEADER_WIDTH+He);let i=e.position.x+((f=(u=e.measured)==null?void 0:u.width)!=null?f:0),a=e.position.y+((y=(m=e.measured)==null?void 0:m.height)!=null?y:0);return i+He>n&&(t.width=i+He,t.measured.width=i+He),a+He>r&&(t.height=a+He,t.measured.height=a+He),o=o.map(E=>E.id===t.id?w(_({},E),{height:t.height,width:t.width,measured:t.measured}):E.id===e.id?w(_({},E),{position:e.position}):E),o};var Ja=require("zustand"),Qa=require("@xyflow/react"),ja=require("react");var ei=()=>{let{setEdges:e}=(0,Qa.useReactFlow)();return(0,ja.useCallback)(()=>{let o=Ko.getState().pathEdgeIds;e(n=>n.map(r=>w(_({},r),{selected:o.includes(r.id)})))},[e])},Ko=(0,Ja.create)((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=_({},n.statusByNodeId),i=_({},n.statusData),a=!1;return o.forEach(s=>{let l=`${s.diagramId}-${s.activityId}`;r[s.diagramId]!==s.status&&(r[s.diagramId]=s.status,i[l]=s,a=!0)}),a?{statusByNodeId:r,statusData:i}:n})},getTaskStatus:o=>t().statusByNodeId[o]||null,clearTaskStatuses:()=>e({statusByNodeId:{},statusData:{},pathEdgeIds:[]}),setPathEdges:o=>{e({pathEdgeIds:o})},getPathEdgeIds:()=>t().pathEdgeIds,clearPathEdges:()=>{e({pathEdgeIds:[]})},calculateFlowPath:(o,n)=>{if(!o.length||!n.length)return;t().clearPathEdges();let r=n.filter(d=>t().statusByNodeId[d]);if(r.length<=1)return;let i=[],a={};o.forEach(d=>{a[d.source]||(a[d.source]=[]),a[d.source].push({targetId:d.target,edgeId:d.id})});let s=r[0],l=r[r.length-1];o.forEach(d=>{d.target===s&&i.push(d.id)}),o.forEach(d=>{d.source===l&&i.push(d.id)});let c=(d,u)=>{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===u)return E;let p=a[y]||[];for(let{targetId:g,edgeId:h}of p)m.has(g)||(m.add(g),f.push({node:g,path:[...E,h]}))}return[]};for(let d=0;d<r.length-1;d++){let u=r[d],f=r[d+1],m=c(u,f);m.length>0&&i.push(...m)}i.length>0&&e({pathEdgeIds:i})}}));var Pn=require("@xyflow/react"),ft=require("react"),$c=require("zustand/shallow");var Rf={value:()=>{}};function tl(){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 ti(o)}function ti(e){this._=e}function Df(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}})}ti.prototype=tl.prototype={constructor:ti,on:function(e,t){var o=this._,n=Df(e+"",o),r,i=-1,a=n.length;if(arguments.length<2){for(;++i<a;)if((r=(e=n[i]).type)&&(r=Of(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]=el(o[r],e.name,t);else if(t==null)for(r in o)o[r]=el(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 ti(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 Of(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function el(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=Rf,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var Ps=tl;var oi="http://www.w3.org/1999/xhtml",Ls={svg:"http://www.w3.org/2000/svg",xhtml:oi,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function uo(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),Ls.hasOwnProperty(t)?{space:Ls[t],local:e}:e}function Vf(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===oi&&t.documentElement.namespaceURI===oi?t.createElement(e):t.createElementNS(o,e)}}function Hf(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function ni(e){var t=uo(e);return(t.local?Hf:Vf)(t)}function Gf(){}function qo(e){return e==null?Gf:function(){return this.querySelector(e)}}function ol(e){typeof e!="function"&&(e=qo(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],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 Ue(n,this._parents)}function ks(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Bf(){return[]}function or(e){return e==null?Bf:function(){return this.querySelectorAll(e)}}function zf(e){return function(){return ks(e.apply(this,arguments))}}function nl(e){typeof e=="function"?e=zf(e):e=or(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 Ue(n,r)}function nr(e){return function(){return this.matches(e)}}function ri(e){return function(t){return t.matches(e)}}var Yf=Array.prototype.find;function Ff(e){return function(){return Yf.call(this.children,e)}}function Wf(){return this.firstElementChild}function rl(e){return this.select(e==null?Wf:Ff(typeof e=="function"?e:ri(e)))}var Xf=Array.prototype.filter;function Uf(){return Array.from(this.children)}function $f(e){return function(){return Xf.call(this.children,e)}}function il(e){return this.selectAll(e==null?Uf:$f(typeof e=="function"?e:ri(e)))}function sl(e){typeof e!="function"&&(e=nr(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 Ue(n,this._parents)}function ii(e){return new Array(e.length)}function al(){return new Ue(this._enter||this._groups.map(ii),this._parents)}function rr(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}rr.prototype={constructor:rr,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 ll(e){return function(){return e}}function Kf(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 rr(e,i[a]);for(;a<l;++a)(s=t[a])&&(r[a]=s)}function qf(e,t,o,n,r,i,a){var s,l,c=new Map,d=t.length,u=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<u;++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 rr(e,i[s]);for(s=0;s<d;++s)(l=t[s])&&c.get(f[s])===l&&(r[s]=l)}function Zf(e){return e.__data__}function cl(e,t){if(!arguments.length)return Array.from(this,Zf);var o=t?qf:Kf,n=this._parents,r=this._groups;typeof e!="function"&&(e=ll(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],f=u.length,m=Jf(e.call(d,d&&d.__data__,c,n)),y=m.length,E=s[c]=new Array(y),p=a[c]=new Array(y),g=l[c]=new Array(f);o(d,u,E,p,g,m,t);for(var h=0,x=0,N,b;h<y;++h)if(N=E[h]){for(h>=x&&(x=h+1);!(b=p[x])&&++x<y;);N._next=b||null}}return a=new Ue(a,n),a._enter=s,a._exit=l,a}function Jf(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function dl(){return new Ue(this._exit||this._groups.map(ii),this._parents)}function ul(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 pl(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,f=s[l]=new Array(u),m,y=0;y<u;++y)(m=c[y]||d[y])&&(f[y]=m);for(;l<r;++l)s[l]=o[l];return new Ue(s,this._parents)}function fl(){for(var e=this._groups,t=-1,o=e.length;++t<o;)for(var n=e[t],r=n.length-1,i=n[r],a;--r>=0;)(a=n[r])&&(i&&a.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(a,i),i=a);return this}function ml(e){e||(e=Qf);function t(u,f){return u&&f?e(u.__data__,f.__data__):!u-!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 Ue(r,this._parents).order()}function Qf(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function gl(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function hl(){return Array.from(this)}function yl(){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 xl(){let e=0;for(let t of this)++e;return e}function El(){return!this.node()}function _l(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 jf(e){return function(){this.removeAttribute(e)}}function em(e){return function(){this.removeAttributeNS(e.space,e.local)}}function tm(e,t){return function(){this.setAttribute(e,t)}}function om(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function nm(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function rm(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 bl(e,t){var o=uo(e);if(arguments.length<2){var n=this.node();return o.local?n.getAttributeNS(o.space,o.local):n.getAttribute(o)}return this.each((t==null?o.local?em:jf:typeof t=="function"?o.local?rm:nm:o.local?om:tm)(o,t))}function si(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function im(e){return function(){this.style.removeProperty(e)}}function sm(e,t,o){return function(){this.style.setProperty(e,t,o)}}function am(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function Tl(e,t,o){return arguments.length>1?this.each((t==null?im:typeof t=="function"?am:sm)(e,t,o==null?"":o)):Io(this.node(),e)}function Io(e,t){return e.style.getPropertyValue(t)||si(e).getComputedStyle(e,null).getPropertyValue(t)}function lm(e){return function(){delete this[e]}}function cm(e,t){return function(){this[e]=t}}function dm(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function vl(e,t){return arguments.length>1?this.each((t==null?lm:typeof t=="function"?dm:cm)(e,t)):this.node()[e]}function Nl(e){return e.trim().split(/^|\s+/)}function Rs(e){return e.classList||new wl(e)}function wl(e){this._node=e,this._names=Nl(e.getAttribute("class")||"")}wl.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 Al(e,t){for(var o=Rs(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function Il(e,t){for(var o=Rs(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function um(e){return function(){Al(this,e)}}function pm(e){return function(){Il(this,e)}}function fm(e,t){return function(){(t.apply(this,arguments)?Al:Il)(this,e)}}function Cl(e,t){var o=Nl(e+"");if(arguments.length<2){for(var n=Rs(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?fm:t?um:pm)(o,t))}function mm(){this.textContent=""}function gm(e){return function(){this.textContent=e}}function hm(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function Sl(e){return arguments.length?this.each(e==null?mm:(typeof e=="function"?hm:gm)(e)):this.node().textContent}function ym(){this.innerHTML=""}function xm(e){return function(){this.innerHTML=e}}function Em(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function Ml(e){return arguments.length?this.each(e==null?ym:(typeof e=="function"?Em:xm)(e)):this.node().innerHTML}function _m(){this.nextSibling&&this.parentNode.appendChild(this)}function Pl(){return this.each(_m)}function bm(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ll(){return this.each(bm)}function kl(e){var t=typeof e=="function"?e:ni(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Tm(){return null}function Rl(e,t){var o=typeof e=="function"?e:ni(e),n=t==null?Tm:typeof t=="function"?t:qo(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function vm(){var e=this.parentNode;e&&e.removeChild(this)}function Dl(){return this.each(vm)}function Nm(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function wm(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Ol(e){return this.select(e?wm:Nm)}function Vl(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Am(e){return function(t){e.call(this,t,this.__data__)}}function Im(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 Sm(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 Hl(e,t,o){var n=Im(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?Sm:Cm,r=0;r<i;++r)this.each(s(n[r],t,o));return this}function Gl(e,t,o){var n=si(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 Mm(e,t){return function(){return Gl(this,e,t)}}function Pm(e,t){return function(){return Gl(this,e,t.apply(this,arguments))}}function Bl(e,t){return this.each((typeof t=="function"?Pm:Mm)(e,t))}function*zl(){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 Ue(e,t){this._groups=e,this._parents=t}function Yl(){return new Ue([[document.documentElement]],Lm)}function km(){return this}Ue.prototype=Yl.prototype={constructor:Ue,select:ol,selectAll:nl,selectChild:rl,selectChildren:il,filter:sl,data:cl,enter:al,exit:dl,join:ul,merge:pl,selection:km,order:fl,sort:ml,call:gl,nodes:hl,node:yl,size:xl,empty:El,each:_l,attr:bl,style:Tl,property:vl,classed:Cl,text:Sl,html:Ml,raise:Pl,lower:Ll,append:kl,insert:Rl,remove:Dl,clone:Ol,datum:Vl,on:Hl,dispatch:Bl,[Symbol.iterator]:zl};var po=Yl;function ai(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function Ds(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function ar(){}var ir=.7,di=1/ir,In="\\s*([+-]?\\d+)\\s*",sr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",$t="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Rm=/^#([0-9a-f]{3,8})$/,Dm=new RegExp(`^rgb\\(${In},${In},${In}\\)$`),Om=new RegExp(`^rgb\\(${$t},${$t},${$t}\\)$`),Vm=new RegExp(`^rgba\\(${In},${In},${In},${sr}\\)$`),Hm=new RegExp(`^rgba\\(${$t},${$t},${$t},${sr}\\)$`),Gm=new RegExp(`^hsl\\(${sr},${$t},${$t}\\)$`),Bm=new RegExp(`^hsla\\(${sr},${$t},${$t},${sr}\\)$`),Fl={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};ai(ar,Co,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Wl,formatHex:Wl,formatHex8:zm,formatHsl:Ym,formatRgb:Xl,toString:Xl});function Wl(){return this.rgb().formatHex()}function zm(){return this.rgb().formatHex8()}function Ym(){return Jl(this).formatHsl()}function Xl(){return this.rgb().formatRgb()}function Co(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=Rm.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?Ul(t):o===3?new st(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?li(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?li(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=Dm.exec(e))?new st(t[1],t[2],t[3],1):(t=Om.exec(e))?new st(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Vm.exec(e))?li(t[1],t[2],t[3],t[4]):(t=Hm.exec(e))?li(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Gm.exec(e))?ql(t[1],t[2]/100,t[3]/100,1):(t=Bm.exec(e))?ql(t[1],t[2]/100,t[3]/100,t[4]):Fl.hasOwnProperty(e)?Ul(Fl[e]):e==="transparent"?new st(NaN,NaN,NaN,0):null}function Ul(e){return new st(e>>16&255,e>>8&255,e&255,1)}function li(e,t,o,n){return n<=0&&(e=t=o=NaN),new st(e,t,o,n)}function Fm(e){return e instanceof ar||(e=Co(e)),e?(e=e.rgb(),new st(e.r,e.g,e.b,e.opacity)):new st}function Cn(e,t,o,n){return arguments.length===1?Fm(e):new st(e,t,o,n==null?1:n)}function st(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}ai(st,Cn,Ds(ar,{brighter(e){return e=e==null?di:Math.pow(di,e),new st(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?ir:Math.pow(ir,e),new st(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new st(Jo(this.r),Jo(this.g),Jo(this.b),ui(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:$l,formatHex:$l,formatHex8:Wm,formatRgb:Kl,toString:Kl}));function $l(){return`#${Zo(this.r)}${Zo(this.g)}${Zo(this.b)}`}function Wm(){return`#${Zo(this.r)}${Zo(this.g)}${Zo(this.b)}${Zo((isNaN(this.opacity)?1:this.opacity)*255)}`}function Kl(){let e=ui(this.opacity);return`${e===1?"rgb(":"rgba("}${Jo(this.r)}, ${Jo(this.g)}, ${Jo(this.b)}${e===1?")":`, ${e})`}`}function ui(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Jo(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Zo(e){return e=Jo(e),(e<16?"0":"")+e.toString(16)}function ql(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new Ot(e,t,o,n)}function Jl(e){if(e instanceof Ot)return new Ot(e.h,e.s,e.l,e.opacity);if(e instanceof ar||(e=Co(e)),!e)return new Ot;if(e instanceof Ot)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 Ot(a,s,l,e.opacity)}function Ql(e,t,o,n){return arguments.length===1?Jl(e):new Ot(e,t,o,n==null?1:n)}function Ot(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}ai(Ot,Ql,Ds(ar,{brighter(e){return e=e==null?di:Math.pow(di,e),new Ot(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?ir:Math.pow(ir,e),new Ot(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 st(Os(e>=240?e-240:e+120,r,n),Os(e,r,n),Os(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new Ot(Zl(this.h),ci(this.s),ci(this.l),ui(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=ui(this.opacity);return`${e===1?"hsl(":"hsla("}${Zl(this.h)}, ${ci(this.s)*100}%, ${ci(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Zl(e){return e=(e||0)%360,e<0?e+360:e}function ci(e){return Math.max(0,Math.min(1,e||0))}function Os(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 Vs(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 jl(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 Vs((o-n/t)*t,a,r,i,s)}}function ec(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 Vs((o-n/t)*t,r,i,a,s)}}var Hs=e=>()=>e;function Xm(e,t){return function(o){return e+o*t}}function Um(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 tc(e){return(e=+e)==1?pi:function(t,o){return o-t?Um(t,o,e):Hs(isNaN(t)?o:t)}}function pi(e,t){var o=t-e;return o?Xm(e,o):Hs(isNaN(e)?t:e)}var fi=function e(t){var o=tc(t);function n(r,i){var a=o((r=Cn(r)).r,(i=Cn(i)).r),s=o(r.g,i.g),l=o(r.b,i.b),c=pi(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 oc(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=Cn(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 $m=oc(jl),Km=oc(ec);function St(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var Bs=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Gs=new RegExp(Bs.source,"g");function qm(e){return function(){return e}}function Zm(e){return function(t){return e(t)+""}}function zs(e,t){var o=Bs.lastIndex=Gs.lastIndex=0,n,r,i,a=-1,s=[],l=[];for(e=e+"",t=t+"";(n=Bs.exec(e))&&(r=Gs.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:St(n,r)})),o=Gs.lastIndex;return o<t.length&&(i=t.slice(o),s[a]?s[a]+=i:s[++a]=i),s.length<2?l[0]?Zm(l[0].x):qm(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 nc=180/Math.PI,mi={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ys(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)*nc,skewX:Math.atan(l)*nc,scaleX:a,scaleY:s}}var gi;function rc(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?mi:Ys(t.a,t.b,t.c,t.d,t.e,t.f)}function ic(e){return e==null?mi:(gi||(gi=document.createElementNS("http://www.w3.org/2000/svg","g")),gi.setAttribute("transform",e),(e=gi.transform.baseVal.consolidate())?(e=e.matrix,Ys(e.a,e.b,e.c,e.d,e.e,e.f)):mi)}function sc(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,f,m,y){if(c!==u||d!==f){var E=m.push("translate(",null,t,null,o);y.push({i:E-4,x:St(c,u)},{i:E-2,x:St(d,f)})}else(u||f)&&m.push("translate("+u+t+f+o)}function a(c,d,u,f){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),f.push({i:u.push(r(u)+"rotate(",null,n)-2,x:St(c,d)})):d&&u.push(r(u)+"rotate("+d+n)}function s(c,d,u,f){c!==d?f.push({i:u.push(r(u)+"skewX(",null,n)-2,x:St(c,d)}):d&&u.push(r(u)+"skewX("+d+n)}function l(c,d,u,f,m,y){if(c!==u||d!==f){var E=m.push(r(m)+"scale(",null,",",null,")");y.push({i:E-4,x:St(c,u)},{i:E-2,x:St(d,f)})}else(u!==1||f!==1)&&m.push(r(m)+"scale("+u+","+f+")")}return function(c,d){var u=[],f=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,u,f),a(c.rotate,d.rotate,u,f),s(c.skewX,d.skewX,u,f),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,f),c=d=null,function(m){for(var y=-1,E=f.length,p;++y<E;)u[(p=f[y]).i]=p.x(m);return u.join("")}}}var Fs=sc(rc,"px, ","px)","deg)"),Ws=sc(ic,", ",")",")");var Sn=0,cr=0,lr=0,lc=1e3,hi,dr,yi=0,Qo=0,xi=0,ur=typeof performance=="object"&&performance.now?performance:Date,cc=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function fr(){return Qo||(cc(Jm),Qo=ur.now()+xi)}function Jm(){Qo=0}function pr(){this._call=this._time=this._next=null}pr.prototype=Ei.prototype={constructor:pr,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?fr():+o)+(t==null?0:+t),!this._next&&dr!==this&&(dr?dr._next=this:hi=this,dr=this),this._call=e,this._time=o,Xs()},stop:function(){this._call&&(this._call=null,this._time=1/0,Xs())}};function Ei(e,t,o){var n=new pr;return n.restart(e,t,o),n}function dc(){fr(),++Sn;for(var e=hi,t;e;)(t=Qo-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Sn}function ac(){Qo=(yi=ur.now())+xi,Sn=cr=0;try{dc()}finally{Sn=0,jm(),Qo=0}}function Qm(){var e=ur.now(),t=e-yi;t>lc&&(xi-=t,yi=e)}function jm(){for(var e,t=hi,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:hi=o);dr=e,Xs(n)}function Xs(e){if(!Sn){cr&&(cr=clearTimeout(cr));var t=e-Qo;t>24?(e<1/0&&(cr=setTimeout(ac,e-ur.now()-xi)),lr&&(lr=clearInterval(lr))):(lr||(yi=ur.now(),lr=setInterval(Qm,lc)),Sn=1,cc(ac))}}function _i(e,t,o){var n=new pr;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var eg=Ps("start","end","cancel","interrupt"),tg=[],fc=0,uc=1,Ti=2,bi=3,pc=4,vi=5,mr=6;function So(e,t,o,n,r,i){var a=e.__transition;if(!a)e.__transition={};else if(o in a)return;og(e,o,{name:t,index:n,group:r,on:eg,tween:tg,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:fc})}function gr(e,t){var o=$e(e,t);if(o.state>fc)throw new Error("too late; already scheduled");return o}function Qe(e,t){var o=$e(e,t);if(o.state>bi)throw new Error("too late; already running");return o}function $e(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function og(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=Ei(i,0,o.time);function i(c){o.state=uc,o.timer.restart(a,o.delay,o.time),o.delay<=c&&a(c-o.delay)}function a(c){var d,u,f,m;if(o.state!==uc)return l();for(d in n)if(m=n[d],m.name===o.name){if(m.state===bi)return _i(a);m.state===pc?(m.state=mr,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete n[d]):+d<t&&(m.state=mr,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete n[d])}if(_i(function(){o.state===bi&&(o.state=pc,o.timer.restart(s,o.delay,o.time),s(c))}),o.state=Ti,o.on.call("start",e,e.__data__,o.index,o.group),o.state===Ti){for(o.state=bi,r=new Array(f=o.tween.length),d=0,u=-1;d<f;++d)(m=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++u]=m);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=vi,1),u=-1,f=r.length;++u<f;)r[u].call(e,d);o.state===vi&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=mr,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function Us(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>Ti&&n.state<vi,n.state=mr,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[a]}i&&delete e.__transition}}function mc(e){return this.each(function(){Us(this,e)})}function ng(e,t){var o,n;return function(){var r=Qe(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 rg(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=Qe(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 gc(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=$e(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?ng:rg)(o,e,t))}function Mn(e,t,o){var n=e._id;return e.each(function(){var r=Qe(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return $e(r,n).value[t]}}function Ni(e,t){var o;return(typeof t=="number"?St:t instanceof Co?fi:(o=Co(t))?(t=o,fi):zs)(e,t)}function ig(e){return function(){this.removeAttribute(e)}}function sg(e){return function(){this.removeAttributeNS(e.space,e.local)}}function ag(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 lg(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 cg(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 dg(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 hc(e,t){var o=uo(e),n=o==="transform"?Ws:Ni;return this.attrTween(e,typeof t=="function"?(o.local?dg:cg)(o,n,Mn(this,"attr."+e,t)):t==null?(o.local?sg:ig)(o):(o.local?lg:ag)(o,n,t))}function ug(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function pg(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function fg(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&pg(e,i)),o}return r._value=t,r}function mg(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&ug(e,i)),o}return r._value=t,r}function yc(e,t){var o="attr."+e;if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;var n=uo(e);return this.tween(o,(n.local?fg:mg)(n,t))}function gg(e,t){return function(){gr(this,e).delay=+t.apply(this,arguments)}}function hg(e,t){return t=+t,function(){gr(this,e).delay=t}}function xc(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?gg:hg)(t,e)):$e(this.node(),t).delay}function yg(e,t){return function(){Qe(this,e).duration=+t.apply(this,arguments)}}function xg(e,t){return t=+t,function(){Qe(this,e).duration=t}}function Ec(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?yg:xg)(t,e)):$e(this.node(),t).duration}function Eg(e,t){if(typeof t!="function")throw new Error;return function(){Qe(this,e).ease=t}}function _c(e){var t=this._id;return arguments.length?this.each(Eg(t,e)):$e(this.node(),t).ease}function _g(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;Qe(this,e).ease=o}}function bc(e){if(typeof e!="function")throw new Error;return this.each(_g(this._id,e))}function Tc(e){typeof e!="function"&&(e=nr(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 tt(n,this._parents,this._name,this._id)}function vc(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),f,m=0;m<d;++m)(f=l[m]||c[m])&&(u[m]=f);for(;s<n;++s)a[s]=t[s];return new tt(a,this._parents,this._name,this._id)}function bg(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 Tg(e,t,o){var n,r,i=bg(t)?gr:Qe;return function(){var a=i(this,e),s=a.on;s!==n&&(r=(n=s).copy()).on(t,o),a.on=r}}function Nc(e,t){var o=this._id;return arguments.length<2?$e(this.node(),o).on.on(e):this.each(Tg(o,e,t))}function vg(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function wc(){return this.on("end.remove",vg(this._id))}function Ac(e){var t=this._name,o=this._id;typeof e!="function"&&(e=qo(e));for(var n=this._groups,r=n.length,i=new Array(r),a=0;a<r;++a)for(var s=n[a],l=s.length,c=i[a]=new Array(l),d,u,f=0;f<l;++f)(d=s[f])&&(u=e.call(d,d.__data__,f,s))&&("__data__"in d&&(u.__data__=d.__data__),c[f]=u,So(c[f],t,o,f,c,$e(d,o)));return new tt(i,this._parents,t,o)}function Ic(e){var t=this._name,o=this._id;typeof e!="function"&&(e=or(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 f=e.call(d,d.__data__,u,l),m,y=$e(d,o),E=0,p=f.length;E<p;++E)(m=f[E])&&So(m,t,o,E,f,y);i.push(f),a.push(d)}return new tt(i,a,t,o)}var Ng=po.prototype.constructor;function Cc(){return new Ng(this._groups,this._parents)}function wg(e,t){var o,n,r;return function(){var i=Io(this,e),a=(this.style.removeProperty(e),Io(this,e));return i===a?null:i===o&&a===n?r:r=t(o=i,n=a)}}function Sc(e){return function(){this.style.removeProperty(e)}}function Ag(e,t,o){var n,r=o+"",i;return function(){var a=Io(this,e);return a===r?null:a===n?i:i=t(n=a,o)}}function Ig(e,t,o){var n,r,i;return function(){var a=Io(this,e),s=o(this),l=s+"";return s==null&&(l=s=(this.style.removeProperty(e),Io(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=Qe(this,e),c=l.on,d=l.value[i]==null?s||(s=Sc(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(a,r=d),l.on=n}}function Mc(e,t,o){var n=(e+="")=="transform"?Fs:Ni;return t==null?this.styleTween(e,wg(e,n)).on("end.style."+e,Sc(e)):typeof t=="function"?this.styleTween(e,Ig(e,n,Mn(this,"style."+e,t))).each(Cg(this._id,e)):this.styleTween(e,Ag(e,n,t),o).on("end.style."+e,null)}function Sg(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function Mg(e,t,o){var n,r;function i(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&Sg(e,a,o)),n}return i._value=t,i}function Pc(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,Mg(e,t,o==null?"":o))}function Pg(e){return function(){this.textContent=e}}function Lg(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function Lc(e){return this.tween("text",typeof e=="function"?Lg(Mn(this,"text",e)):Pg(e==null?"":e+""))}function kg(e){return function(t){this.textContent=e.call(this,t)}}function Rg(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&kg(r)),t}return n._value=e,n}function kc(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,Rg(e))}function Rc(){for(var e=this._name,t=this._id,o=wi(),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=$e(l,t);So(l,e,o,c,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new tt(n,this._parents,e,o)}function Dc(){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=Qe(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 Dg=0;function tt(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function Oc(e){return po().transition(e)}function wi(){return++Dg}var fo=po.prototype;tt.prototype=Oc.prototype={constructor:tt,select:Ac,selectAll:Ic,selectChild:fo.selectChild,selectChildren:fo.selectChildren,filter:Tc,merge:vc,selection:Cc,transition:Rc,call:fo.call,nodes:fo.nodes,node:fo.node,size:fo.size,empty:fo.empty,each:fo.each,on:Nc,attr:hc,attrTween:yc,style:Mc,styleTween:Pc,text:Lc,textTween:kc,remove:wc,tween:gc,delay:xc,duration:Ec,ease:_c,easeVarying:bc,end:Dc,[Symbol.iterator]:fo[Symbol.iterator]};function Ai(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Og={time:null,delay:0,duration:250,ease:Ai};function Vg(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 Vc(e){var t,o;e instanceof tt?(t=e._id,e=e._name):(t=wi(),(o=Og).time=fr(),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])&&So(l,e,t,c,a,o||Vg(l,t));return new tt(n,this._parents,e,t)}po.prototype.interrupt=mc;po.prototype.transition=Vc;function Mo(e,t,o){this.k=e,this.x=t,this.y=o}Mo.prototype={constructor:Mo,scale:function(e){return e===1?this:new Mo(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Mo(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 Ii=new Mo(1,0,0);Ci.prototype=Mo.prototype;function Ci(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Ii;return e.__zoom}var Gg=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var Hc;(function(e){e.Strict="strict",e.Loose="loose"})(Hc||(Hc={}));var Gc;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Gc||(Gc={}));var Bc;(function(e){e.Partial="partial",e.Full="full"})(Bc||(Bc={}));var zc;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(zc||(zc={}));var Yc;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Yc||(Yc={}));var at;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(at||(at={}));var X1={[at.Left]:at.Right,[at.Right]:at.Left,[at.Top]:at.Bottom,[at.Bottom]:at.Top};var Bg=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var zg=(e,t=[0,0])=>{var s;let{width:o,height:n}=Yg(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 Si=(e,t=[0,0])=>{var r,i,a,s,l,c,d,u;let{x:o,y:n}=Bg(e)?e.internals.positionAbsolute:zg(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 Yg(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 U1={[at.Left]:{x:-1,y:0},[at.Right]:{x:1,y:0},[at.Top]:{x:0,y:-1},[at.Bottom]:{x:0,y:1}};var Fg={nodeOrigin:[0,0],nodeExtent:Gg,elevateNodesOnSelect:!0,defaults:{}},$1=w(_({},Fg),{checkEquality:!0});var Fc;(function(e){e.Line="line",e.Handle="handle"})(Fc||(Fc={}));var Wg={width:0,height:0,x:0,y:0},K1=w(_({},Wg),{pointerX:0,pointerY:0,aspectRatio:1});var Xg=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function Ug(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 $g(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 Mi=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)||!Xg(m.nodeBox,r))continue;let y=Math.abs(m.position-o);if(y>Pi)continue;let p=Ug(m.nodeBox,n)>0?0:$g(m.nodeBox,n);c.push({line:m,lineDist:y,nodeDist:p})}let d=.5,u=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;c.sort((m,y)=>{if(u){if(m.line===u&&y.line!==u)return-1;if(y.line===u&&m.line!==u)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 Wc(e,t=jo,o){let n=[];return e==null||e.forEach(r=>{let i=o(r.id);if(!i)throw new Error(`Node with id ${r.id} not found in internal nodes.`);let a=Si(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 Xc(e,t,o,n,r=Object.keys(jo)){let i=[];for(let s of r){let l=jo[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 Uc(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)<=Pi&&(r=l,a=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=Pi&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:a}}var Pi=10,jo={top:{orientation:"horizontal",resolve:(e,t)=>t.y},bottom:{orientation:"horizontal",resolve:(e,t)=>t.y2},left:{orientation:"vertical",resolve:(e,t)=>t.x},right:{orientation:"vertical",resolve:(e,t)=>t.x2},centerX:{orientation:"vertical",resolve:(e,t)=>(t.x+t.x2)/2},centerY:{orientation:"horizontal",resolve:(e,t)=>(t.y+t.y2)/2}};var Kc=require("react/jsx-runtime"),Kg=new Mi;function Li(){let[e,t]=(0,ft.useState)(void 0),[o,n]=(0,ft.useState)(void 0),{width:r,height:i}=(0,Pn.useStore)(p=>({width:p.width,height:p.height}),$c.shallow),a=(0,Pn.useNodesInitialized)(),s=(0,ft.useRef)(Kg),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=(0,Pn.useReactFlow)(),u=(0,ft.useCallback)(()=>{t(void 0),n(void 0)},[]),f=(0,ft.useCallback)(p=>{let g=p!=null?p:d();u();let h=Wc(g,jo,c);s.current.initialize(h)},[c,u,d]),m=(0,ft.useCallback)(()=>{setTimeout(()=>{f()},100)},[f]);(0,ft.useEffect)(()=>{a&&f(d())},[a,f,d]);let y=(0,ft.useCallback)((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),N=p.find(W=>W.type==="dimensions");if(x.length===0&&!N)return p;let b=Object.keys(jo),T=new Set,v=1/0,A=1/0,C=-1/0,P=-1/0;if(x.length>0)x.forEach(W=>{var de,re,ee,xe,Ce,Re;let oe=g.find(Je=>Je.id===W.id);if(!oe)return;T.add(oe.id);let le=c(oe.id);if(!le)return;let Z=le.parentId?c(le.parentId):void 0,ve=W.position.x+((de=Z==null?void 0:Z.internals.positionAbsolute.x)!=null?de:0),ye=W.position.y+((re=Z==null?void 0:Z.internals.positionAbsolute.y)!=null?re:0),Ie=(xe=(ee=oe.measured)==null?void 0:ee.width)!=null?xe:0,J=(Re=(Ce=oe.measured)==null?void 0:Ce.height)!=null?Re:0;v=Math.min(v,ve),A=Math.min(A,ye),C=Math.max(C,ve+Ie),P=Math.max(P,ye+J)}),N&&(b=["top","left"]);else if(N){let W=g.find(Ie=>Ie.id===N.id);if(!W)return p;T.add(W.id);let oe=c(W.id);if(!oe)return p;let le=oe.internals.positionAbsolute.x,Z=oe.internals.positionAbsolute.y,ve=(Y=(O=(G=N.dimensions)==null?void 0:G.width)!=null?O:(k=W.measured)==null?void 0:k.width)!=null?Y:0,ye=($=(X=(F=N.dimensions)==null?void 0:F.height)!=null?X:(U=W.measured)==null?void 0:U.height)!=null?$:0;v=le,A=Z,C=le+ve,P=Z+ye,b=["right","bottom"]}if(v===1/0)return p;let R={x:v,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}=Xc(s.current,Q,R,T,b),{deltaX:V,deltaY:D,snappedX:I,snappedY:B}=Uc(R,z,M);if(I||B){let W=x.some(le=>le.dragging),oe=!!(N!=null&&N.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)}),(N==null?void 0:N.id)===((te=x[0])==null?void 0:te.id)?N.dimensions&&(N.dimensions.width+=V):N&&!x.length&&N.dimensions&&(N.dimensions.width-=V)),B&&(x.forEach(le=>{le.position&&(le.position.y-=D)}),(N==null?void 0:N.id)===((ie=x[0])==null?void 0:ie.id)?N.dimensions&&(N.dimensions.height+=D):N&&!x.length&&N.dimensions&&(N.dimensions.height-=D))}return p},[l,c,r,i,t,n,u]),E=(0,ft.useCallback)(()=>(0,Kc.jsx)(qc,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:f,forceRebuildIndex:m,updateHelperLines:y,helperLineHorizontal:e,helperLineVertical:o,HelperLines:E}}var cs=require("@xyflow/react"),to=require("react");var mo=e=>new Map(e.map(t=>[t.id,t])),hr=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),Zc=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),$s=e=>e.some(t=>t.type==="START_EVENT"),Po=(e,t)=>e==="START_EVENT"?!$s(t):!0,Jc=(e,t,o,n,r)=>{let i=mo(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:hr(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Qc=(e,t,o,n,r)=>{let i=mo(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:Zc(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},ki=(e,t,o,n,r)=>{var c;let i=mo(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:hr(e,n,r).filter(d=>{let u=i.get(d.target);return(u==null?void 0:u.type)!=="ANNOTATION"}).length>=2},jc=(e,t,o)=>{var a,s,l,c;let n=mo(o),r=n.get(e),i=n.get(t);return(r==null?void 0:r.type)!=="GATEWAY"||(i==null?void 0:i.type)!=="GATEWAY"||((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"},Ri=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SCRIPT"},ed=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SUBPROCESS"},yr=(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"},Di=(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"},en=(e,t,o,n)=>{let r=mo(t),i=r.get(e);return!i||i.type!=="TASK"?!1:Zc(e,o,n).some(s=>{let l=r.get(s.source);return(l==null?void 0:l.type)==="START_EVENT"})},xr=(e,t,o,n)=>{let r=mo(t),i=r.get(e);return!i||i.type!=="TASK"?!1:hr(e,o,n).some(s=>{let l=r.get(s.target);return(l==null?void 0:l.type)==="END_EVENT"})},td=(e,t,o,n,r)=>{let i=mo(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"?xr(t,o,n,r):(s==null?void 0:s.type)==="END_EVENT"&&(a==null?void 0:a.type)==="TASK"?en(e,o,n,r):!1},Oi=(e,t,o)=>hr(e,t,o).length>0,Vi=(e,t,o,n,r)=>{let i=mo(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:hr(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var od=(e,t,o,n,r)=>{var s,l;let i=mo(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 qg=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!od(e.sourceNodeId,e.targetNodeId,e.edges,e.nodes,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!Jc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!Qc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!ki(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!Vi(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:jc(e.sourceNodeId,e.targetNodeId,e.nodes),reason:"gateway_to_gateway_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&e.targetNodeType==="END_EVENT"),reason:"start_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&ed(e.targetNodeId,e.nodes)),reason:"start_event_to_subprocess_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&yr(e.targetNodeId,e.nodes)),reason:"start_event_to_service_task_not_allowed"}),e=>({isValid:!(yr(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:!(Ri(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(Di(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(en(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!td(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(xr(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(Oi(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"})],Ks=e=>{for(let t of qg){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var Zg=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:ki(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:$s(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Ri(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Di(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:yr(e.sourceNodeId,e.nodes),reason:"service_task_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:en(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:xr(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Oi(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Vi(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],nd=e=>{let t=Zg.filter(o=>{let n=!o.sourceTypes||o.sourceTypes.includes(e.sourceNodeType),r=!o.targetTypes||o.targetTypes.includes(e.targetNodeType);return n&&r});for(let o of t){let n=o.validate(e);if(n.shouldDisable)return n}return{shouldDisable:!1}};var Vt=require("@xyflow/react");var Kt=require("@produto-lecom/lecom-ui"),id=require("lucide-react");var Mt=require("@xyflow/react");var rd=require("@xyflow/react"),Lo=()=>{let e=(0,rd.useStoreApi)();return{selectElements:n=>{let{edges:r,nodes:i,triggerEdgeChanges:a,triggerNodeChanges:s}=e.getState(),l=i.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]),c=r.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]);return s(l),a(c),!0},clearSelection:async()=>{let{unselectNodesAndEdges:n}=e.getState();return n(),await Ur(),!0}}};var Hi=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=(0,Mt.useReactFlow)(),{selectElements:r}=Lo(),i=p=>{let g=o(),h=n(),x=(0,Mt.getIncomers)(p,g,h),N=(0,Mt.getOutgoers)(p,g,h),b=x.some(v=>v.type==="START_EVENT"),T=N.some(v=>v.type==="END_EVENT");return b?"start":T?"end":"between"},a=(p,g,h)=>{var b,T,v,A,C;if(!p)return;let x={type:p.type,variant:(b=p.data)==null?void 0:b.variant,attribute:(T=p.data)==null?void 0:T.attribute},N={id:p.id,position:i(p),label:(v=p.data)==null?void 0:v.label,node:x};return p.type==="TASK"&&((A=p.data)==null?void 0:A.variant)==="SUBPROCESS"?w(_({},N),{type:"sub_process"}):p.type==="TASK"&&((C=p.data)==null?void 0:C.variant)==="SERVICE_TASK"?w(_({},N),{type:"service_task"}):p.type==="GATEWAY"?w(_({},N),{type:"gateway",variant:s(p,g,h)}):w(_({},N),{type:"activity"})},s=(p,g,h)=>{if(p.type!=="GATEWAY")return;let x=(0,Mt.getIncomers)(p,g,h),N=!1,b=!1;if(x.forEach(T=>{var v,A;T.type==="TASK"&&(((v=T.data)==null?void 0:v.variant)==="SCRIPT"&&(N=!0),((A=T.data)==null?void 0:A.attribute)==="LOOP"&&(b=!0))}),N&&b)return"script_loop";if(N)return"script";if(b)return"loop"},l=(p,g,h)=>{var v,A,C,P,R;let x=e(p.source),N=e(p.target);if(!x||!N)return"simple";if((0,Mt.getOutgoers)(x,g,h).some(S=>S.type==="END_EVENT"))return"final";if(x.type==="GATEWAY")switch((v=x.data)==null?void 0:v.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(x.type==="TASK"){let S=(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(N.type==="TASK"&&((P=N.data)==null?void 0:P.variant)==="SUBPROCESS")return"to_sub_process";if(N.type==="TASK"&&((R=N.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 N(T,v,A=0){let C=a(T,g,h);if(C.depth=A,v.push(C),T.type==="TASK"){x.push([...v]),v.pop();return}let P=(0,Mt.getIncomers)(T,g,h);if(P.length)for(let R of P)N(R,v,A+1);v.pop()}let b=(0,Mt.getIncomers)(p,g,h);for(let T of b)N(T,[]);return x},d=(p,g,h)=>{let x=[];function N(T,v,A=0){let C=a(T,g,h);if(C.depth=A,v.push(C),T.type==="TASK"){x.push([...v]),v.pop();return}let P=(0,Mt.getOutgoers)(T,g,h);if(P.length)for(let R of P)N(R,v,A+1);v.pop()}let b=(0,Mt.getOutgoers)(p,g,h);for(let T of b)N(T,[]);return x},u=(p,g,h)=>(h=h.filter(N=>N.source===p.id),h.map(N=>{var v;let b=e(N.target),T;return b&&(T=a(b,g,h)),{id:N.id,type:"routing",variant:l(N,g,h),label:(v=N.data)==null?void 0:v.label,target:T}})),f=p=>{let g=e(p);if(!g)return;let h=o(),x=n(),N=a(g,h,x);return N.sources=c(g,h,x),N.targets=d(g,h,x),N.edgeTargets=u(g,h,x),g.type==="GATEWAY"&&(N.variant=s(g,h,x)),N},m=p=>{let g=t(p);if(!g)return;let h=o(),x=n(),N=l(g,h,x),T={id:g.id,type:"routing",variant:N,gatewayVariant:void 0},v=e(g.source);if(v){let C=a(v,h,x);T.source=C;let P=s(v,h,x);if(T.gatewayVariant=P,v.type==="TASK")T.sources=[[C]];else{let R=c(v,h,x);T.sources=R.length?R:[[C]]}}let A=e(g.target);if(A){let C=a(A,h,x);if(T.target=C,A.type==="TASK")T.targets=[[C]];else{let P=d(A,h,x);T.targets=P.length?P:[[C]]}}return T},y=p=>{let g=e(p);if(g)return f(g.id);let h=t(p);if(h)return m(h.id)};return{configureElement:p=>{let g=y(p);if(g)return r([p]),g},getConfigureElement:y,getNodeConfigure:f,getEdgeConfigure:m}};var tn=require("react/jsx-runtime"),Jg={node:"editor.toolbar.configure_node",edge:"editor.toolbar.configure_edge",gateway:"editor.toolbar.configure_gateway"},ko=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,Kt.useTranslation)(),{onConfigureElement:n}=q(),{getConfigureElement:r}=Hi();return(0,tn.jsxs)(Kt.Tooltip,{children:[(0,tn.jsx)(Kt.TooltipTrigger,{asChild:!0,children:(0,tn.jsx)(Kt.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let a=r(e);a&&(n==null||n(a))},children:(0,tn.jsx)(id.Settings,{size:16})})}),(0,tn.jsx)(Kt.TooltipContent,{color:"black",children:o(Jg[t])})]})};var qt=require("@produto-lecom/lecom-ui"),ad=require("@xyflow/react"),ld=require("lucide-react");var sd=require("@produto-lecom/lecom-ui");function lt(){let{toast:e}=Ln(),{toast:t}=(0,sd.useNotificationToast)();return{toast:e||t}}var on=require("react/jsx-runtime"),Gi=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,qt.useTranslation)(),{toast:n}=lt(),{deleteElements:r,getNodes:i}=(0,ad.useReactFlow)();return(0,on.jsxs)(qt.Tooltip,{children:[(0,on.jsx)(qt.TooltipTrigger,{asChild:!0,children:(0,on.jsx)(qt.Button,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{if(t==="node"){let s=i(),l=s.find(c=>c.id===e);if((l==null?void 0:l.type)==="LANE"&&s.some(d=>d.parentId===e)){n({variant:"error",title:o("validation.errors.title"),content:o("editor.toolbar.delete_pool_lane_error")});return}r({nodes:[{id:e}]})}else r({edges:[{id:e}]})},children:(0,on.jsx)(ld.TrashIcon,{size:16})})}),(0,on.jsx)(qt.TooltipContent,{color:"black",children:o("editor.toolbar.delete")})]})};var Zt=require("@produto-lecom/lecom-ui"),cd=require("lucide-react"),dd=require("react"),nn=require("react/jsx-runtime"),kn=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=(0,Zt.useTranslation)(),r=(0,dd.useCallback)(i=>{i.stopPropagation();let a=document.querySelectorAll(`.react-flow__handle.source[data-nodeid="${e}"]`);if(a.length===0)return;let s=Array.from(a).reduce((f,m)=>{let y=f.getBoundingClientRect(),E=m.getBoundingClientRect(),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?m:f}),l=s.getBoundingClientRect(),c=l.left+l.width/2,d=l.top+l.height/2,u=new MouseEvent("mousedown",{clientX:c,clientY:d,bubbles:!0,cancelable:!0});s.dispatchEvent(u)},[e]);return(0,nn.jsxs)(Zt.Tooltip,{children:[(0,nn.jsx)(Zt.TooltipTrigger,{asChild:!0,children:(0,nn.jsx)(Zt.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:(0,nn.jsx)(cd.MoveUpRightIcon,{size:16})})}),(0,nn.jsx)(Zt.TooltipContent,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};var Rn=require("react/jsx-runtime"),Dn=i=>{var a=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=a,r=Ut(a,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:s}=q(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d,isToEndEvent:u}=jr(o,n),f=!l&&!c&&!d&&!u,m=[{component:(0,Rn.jsx)(Gi,{elementId:e,elementType:"edge"})}],y=()=>s==="view"?f?[{component:(0,Rn.jsx)(ko,{elementId:e,elementType:"edge"})}]:[]:f?[{component:(0,Rn.jsx)(ko,{elementId:e,elementType:"edge"})},...m]:m,p=(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(!(p.length===0||s==="readonly"))return(0,Rn.jsx)("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)=>(0,Rn.jsx)("div",{children:g.component},h))}))};var ud=require("@xyflow/react"),pd=require("react");var qs=require("react/jsx-runtime"),Jt=12,On=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:a}=(0,ud.useViewport)(),s=1/a,l=(0,pd.useMemo)(()=>t===n?{bottom:`${Jt}px`,transform:"translateX(-50%)"}:e===o?{left:`${Jt}px`,transform:r?"translateY(-100%)":"translateY(-50%)"}:n>t&&o>e?{left:`${Jt}px`,bottom:`${Jt}px`}:n>t&&o<e?{right:`${Jt}px`,bottom:`${Jt}px`}:t>n&&o>e?{right:`${Jt}px`,bottom:`${Jt}px`}:{left:`${Jt}px`,bottom:`${Jt}px`},[e,t,o,n,r]);return(0,qs.jsx)("div",{style:{transform:`scale(${s})`},children:(0,qs.jsx)("div",{className:"absolute pointer-events-auto",style:_({},l),children:i})})};var mt=require("react/jsx-runtime"),Vn={type:"ANNOTATION_EDGE",reconnectable:!0},fd=({id:e,source:t,target:o,selected:n,data:r})=>{let{isMultipleSelection:i,isReadOnly:a,edgeHighlight:s}=q(),{zoom:l}=(0,Vt.useViewport)(),c=(0,Vt.useInternalNode)(t),d=(0,Vt.useInternalNode)(o);if(!c||!d)return null;let{sx:u,sy:f,tx:m,ty:y}=An(c,d),[E,p,g]=(0,Vt.getStraightPath)({sourceX:u,sourceY:f,targetX:m,targetY:y}),h=s&&(n||(c==null?void 0:c.selected)||(d==null?void 0:d.selected));return(0,mt.jsx)(mt.Fragment,{children:(0,mt.jsxs)("g",{className:H("group bpmn-edge",{"is-highlighted":h}),children:[(0,mt.jsx)("path",{d:E,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/l),style:{pointerEvents:"stroke",cursor:"pointer"}}),(0,mt.jsxs)("g",{className:H("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!a,"text-blue-500 group-hover:text-blue-600":h}),children:[(0,mt.jsx)(Vt.BaseEdge,{id:e,path:E,interactionWidth:0,strokeDasharray:4,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":r==null?void 0:r.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":h&&!(r!=null&&r.hasError)})}),(0,mt.jsx)(Vt.EdgeLabelRenderer,{children:(0,mt.jsx)("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&&(0,mt.jsx)(On,{sx:u,sy:f,tx:m,ty:y,children:(0,mt.jsx)(Dn,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})})})]})]})})};var et=require("react"),Me=require("@xyflow/react");var Ht=require("react");var Js=require("react/jsx-runtime"),Zs=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,md=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Escape","Shift"],je=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:a,onBlur:s,onInput:l,onInvalidFirstCharacter:c,skipFirstCharValidation:d})=>{let u=(0,Ht.useRef)(null),f=(0,Ht.useRef)(null),[m,y]=(0,Ht.useState)(!1);(0,Ht.useEffect)(()=>()=>{f.current&&clearTimeout(f.current)},[]),(0,Ht.useEffect)(()=>{y(i!=null?i:!1)},[i]),(0,Ht.useEffect)(()=>{if(m&&u.current){u.current.focus();let b=document.createRange();b.selectNodeContents(u.current);let T=window.getSelection();T&&(T.removeAllRanges(),T.addRange(b))}},[m]);let E=(0,Ht.useCallback)(()=>{f.current||(c==null||c(),f.current=setTimeout(()=>{f.current=null},500))},[c]),p=b=>{b.stopPropagation(),m||y(!0)},g=b=>{let T=b.currentTarget.innerText.replace(/\n$/,""),v=t&&T.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=T.length===0||P&&C.length===T.length;if(!d&&Q&&!Zs.test(b.key)&&!md.includes(b.key)&&!R){b.preventDefault(),E();return}v&&!P&&(md.includes(b.key)||S||L||K||j||b.preventDefault())},h=b=>{b.preventDefault();let T=b.clipboardData.getData("text/plain").replace(/\r\n/g,`
1
+ "use strict";var yf=Object.create;var qn=Object.defineProperty,xf=Object.defineProperties,Ef=Object.getOwnPropertyDescriptor,_f=Object.getOwnPropertyDescriptors,bf=Object.getOwnPropertyNames,Br=Object.getOwnPropertySymbols,Tf=Object.getPrototypeOf,bs=Object.prototype.hasOwnProperty,Ta=Object.prototype.propertyIsEnumerable;var ba=(e,t,o)=>t in e?qn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,_=(e,t)=>{for(var o in t||(t={}))bs.call(t,o)&&ba(e,o,t[o]);if(Br)for(var o of Br(t))Ta.call(t,o)&&ba(e,o,t[o]);return e},w=(e,t)=>xf(e,_f(t));var Ut=(e,t)=>{var o={};for(var n in e)bs.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Br)for(var n of Br(e))t.indexOf(n)<0&&Ta.call(e,n)&&(o[n]=e[n]);return o};var vf=(e,t)=>{for(var o in t)qn(e,o,{get:t[o],enumerable:!0})},va=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of bf(t))!bs.call(e,r)&&r!==o&&qn(e,r,{get:()=>t[r],enumerable:!(n=Ef(t,r))||n.enumerable});return e};var Nf=(e,t,o)=>(o=e!=null?yf(Tf(e)):{},va(t||!e||!e.__esModule?qn(o,"default",{value:e,enumerable:!0}):o,e)),wf=e=>va(qn({},"__esModule",{value:!0}),e);var wy={};vf(wy,{EditorMode:()=>Ye,ElementPosition:()=>Yr,ElementType:()=>Zn,GatewayElementVariant:()=>Fr,GatewayVariant:()=>It,Modeler:()=>hf,ModelerProvider:()=>pf,NodeAttribute:()=>Dt,NodeType:()=>se,NodeVariant:()=>it,RoutingVariant:()=>Wr,useModeler:()=>Ln});module.exports=wf(wy);var Ts=e=>{if(typeof document=="undefined")return;let t=document.cookie.match(new RegExp(`(?:^|; )${e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")}=([^;]*)`));return t?decodeURIComponent(t[1]):void 0};var zr=require("@produto-lecom/lecom-ui");var Na={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",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 wa={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",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 Aa={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",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 Ia={pt_BR:Aa,en_US:Na,es_ES:wa};var Ca,Sa,Af=(Sa=(Ca=Ts("LecomUserLanguage"))!=null?Ca:Ts("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?Sa:zr.Translations.PT_BR;(0,zr.initializeI18n)({lng:Af,resources:Ia});var Ye=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(Ye||{});var Zn=(i=>(i.ACTIVITY="activity",i.ROUTING="routing",i.GATEWAY="gateway",i.SUB_PROCESS="sub_process",i.SERVICE_TASK="service_task",i))(Zn||{}),Yr=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Yr||{}),Fr=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Fr||{}),Wr=(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))(Wr||{});var Ao=require("lucide-react");var Fo=require("react/jsx-runtime"),Xr=({size:e=24,className:t})=>(0,Fo.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:[(0,Fo.jsx)("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),(0,Fo.jsx)("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),(0,Fo.jsx)("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),(0,Fo.jsx)("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});var vs=require("react/jsx-runtime"),gn=({size:e=24,className:t})=>(0,vs.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#ff6565",stroke:"#ec1616",strokeWidth:3,className:t,children:(0,vs.jsx)("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});var vo=require("react/jsx-runtime"),hn=({size:e=24,className:t})=>(0,vo.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[(0,vo.jsx)("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,vo.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,vo.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,vo.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,vo.jsx)("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var yn=require("react/jsx-runtime"),xn=({size:e=24,className:t})=>(0,yn.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[(0,yn.jsx)("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,yn.jsx)("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,yn.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var En=require("react/jsx-runtime"),_n=({size:e=24,className:t})=>(0,En.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[(0,En.jsx)("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,En.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,En.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});var bn=require("react/jsx-runtime"),Ma=({size:e=24,className:t})=>(0,bn.jsx)("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:(0,bn.jsxs)("g",{children:[(0,bn.jsx)("path",{d:"M8.6543 11.4141V15.2148C8.51302 15.4017 8.29199 15.6068 7.99121 15.8301C7.69499 16.0488 7.30078 16.238 6.80859 16.3975C6.31641 16.557 5.70345 16.6367 4.96973 16.6367C4.34538 16.6367 3.77344 16.5319 3.25391 16.3223C2.73438 16.1081 2.28548 15.7959 1.90723 15.3857C1.53353 14.9756 1.24414 14.4766 1.03906 13.8887C0.833984 13.2962 0.731445 12.6217 0.731445 11.8652V11.1748C0.731445 10.4229 0.82487 9.75293 1.01172 9.16504C1.20312 8.57259 1.47656 8.07129 1.83203 7.66113C2.1875 7.25098 2.61589 6.94108 3.11719 6.73145C3.62305 6.51725 4.19499 6.41016 4.83301 6.41016C5.64876 6.41016 6.32324 6.54688 6.85645 6.82031C7.39421 7.08919 7.80892 7.46289 8.10059 7.94141C8.39225 8.41992 8.57682 8.9668 8.6543 9.58203H6.97266C6.91797 9.23568 6.81087 8.92578 6.65137 8.65234C6.49642 8.37891 6.27311 8.16471 5.98145 8.00977C5.69434 7.85026 5.32064 7.77051 4.86035 7.77051C4.46387 7.77051 4.11523 7.8457 3.81445 7.99609C3.51367 8.14648 3.26302 8.36751 3.0625 8.65918C2.86654 8.95085 2.71842 9.30632 2.61816 9.72559C2.5179 10.1449 2.46777 10.6234 2.46777 11.1611V11.8652C2.46777 12.4121 2.52474 12.8975 2.63867 13.3213C2.75716 13.7451 2.92578 14.1029 3.14453 14.3945C3.36784 14.6862 3.639 14.9072 3.95801 15.0576C4.27702 15.2035 4.63704 15.2764 5.03809 15.2764C5.43001 15.2764 5.7513 15.2445 6.00195 15.1807C6.2526 15.1123 6.45085 15.0326 6.59668 14.9414C6.74707 14.8457 6.86328 14.7546 6.94531 14.668V12.6924H4.87402V11.4141H8.6543ZM17.0912 11.25V11.7969C17.0912 12.5488 16.9932 13.2233 16.7973 13.8203C16.6013 14.4173 16.321 14.9255 15.9564 15.3447C15.5964 15.764 15.1635 16.0853 14.6576 16.3086C14.1518 16.5273 13.5912 16.6367 12.976 16.6367C12.3653 16.6367 11.807 16.5273 11.3012 16.3086C10.7999 16.0853 10.3646 15.764 9.99551 15.3447C9.62637 14.9255 9.33926 14.4173 9.13418 13.8203C8.93366 13.2233 8.8334 12.5488 8.8334 11.7969V11.25C8.8334 10.498 8.93366 9.82585 9.13418 9.2334C9.3347 8.63639 9.61725 8.12826 9.98184 7.70898C10.351 7.28516 10.7862 6.96387 11.2875 6.74512C11.7934 6.52181 12.3516 6.41016 12.9623 6.41016C13.5775 6.41016 14.1381 6.52181 14.6439 6.74512C15.1498 6.96387 15.585 7.28516 15.9496 7.70898C16.3142 8.12826 16.5945 8.63639 16.7904 9.2334C16.991 9.82585 17.0912 10.498 17.0912 11.25ZM15.3754 11.7969V11.2363C15.3754 10.6803 15.3207 10.1904 15.2113 9.7666C15.1065 9.33822 14.9493 8.98047 14.7396 8.69336C14.5346 8.40169 14.2816 8.18294 13.9809 8.03711C13.6801 7.88672 13.3406 7.81152 12.9623 7.81152C12.584 7.81152 12.2468 7.88672 11.9506 8.03711C11.6544 8.18294 11.4014 8.40169 11.1918 8.69336C10.9867 8.98047 10.8295 9.33822 10.7201 9.7666C10.6107 10.1904 10.5561 10.6803 10.5561 11.2363V11.7969C10.5561 12.3529 10.6107 12.8451 10.7201 13.2734C10.8295 13.7018 10.989 14.0641 11.1986 14.3604C11.4128 14.652 11.668 14.873 11.9643 15.0234C12.2605 15.1693 12.5977 15.2422 12.976 15.2422C13.3588 15.2422 13.6983 15.1693 13.9945 15.0234C14.2908 14.873 14.5414 14.652 14.7465 14.3604C14.9516 14.0641 15.1065 13.7018 15.2113 13.2734C15.3207 12.8451 15.3754 12.3529 15.3754 11.7969ZM20.6678 14.6816L23.2859 6.54688H25.1795L21.6111 16.5H20.3328L20.6678 14.6816ZM18.2479 6.54688L20.8455 14.6816L21.201 16.5H19.9158L16.3611 6.54688H18.2479Z"}),(0,bn.jsx)("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});var Pa=require("clsx"),La=require("tailwind-merge");function H(...e){return(0,La.twMerge)((0,Pa.clsx)(e))}var No=(e=0,t=0)=>e<t?t:e,Ur=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});var Jn=require("react/jsx-runtime"),ka=({size:e=24,className:t})=>(0,Jn.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:H("stroke-2",t),children:[(0,Jn.jsx)("path",{d:"M19 3H5C3.89543 3 3 3.89543 3 5V19C3 20.1046 3.89543 21 5 21H19C20.1046 21 21 20.1046 21 19V5C21 3.89543 20.1046 3 19 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Jn.jsx)("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});var $r=require("react/jsx-runtime"),Ra=({size:e=24,className:t})=>(0,$r.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:(0,$r.jsx)("g",{children:(0,$r.jsx)("path",{d:"M4.85372 6.17472L5.31292 5.71552L5.31993 5.70863C6.88908 4.1924 8.98352 3.34122 11.1655 3.33301L11.1668 3.33301C11.167 3.33301 11.1673 3.33301 11.1675 3.33301C12.7165 3.33314 14.2308 3.79255 15.5188 4.65317C16.807 5.5139 17.811 6.7373 18.4039 8.16866C18.9968 9.60001 19.1519 11.175 18.8497 12.6945C18.5986 13.9567 18.0414 15.1334 17.232 16.1236L16.9457 16.4738L17.2655 16.7936L20.6617 20.1899L20.6617 20.1899C20.7919 20.3201 20.7919 20.5311 20.6617 20.6612L20.6616 20.6613C20.5316 20.7915 20.3205 20.7915 20.1903 20.6613L16.7941 17.265L16.4743 16.9452L16.1241 17.2315C15.1339 18.0409 13.9571 18.5981 12.695 18.8492C11.1755 19.1514 9.6005 18.9963 8.16915 18.4034C6.73778 17.8105 5.51439 16.8065 4.65365 15.5183C3.79291 14.2301 3.3335 12.7156 3.3335 11.1663C3.3335 10.9822 3.48273 10.833 3.66683 10.833C3.85093 10.833 4.00016 10.9822 4.00016 11.1663C4.00016 12.5838 4.42048 13.9694 5.20796 15.148C5.99545 16.3265 7.11474 17.245 8.42426 17.7874C9.73378 18.3299 11.1748 18.4719 12.565 18.1953C13.9552 17.9188 15.2321 17.2362 16.2344 16.234L16.2345 16.234C17.2367 15.2316 17.9193 13.9547 18.1958 12.5645C18.4724 11.1743 18.3304 9.7333 17.7879 8.42378C17.2455 7.11426 16.327 5.99497 15.1484 5.20748L14.8707 5.62322L15.1484 5.20748C13.9703 4.42031 12.5854 4.00001 11.1685 3.99968L11.1664 3.99969C9.15876 4.00767 7.23176 4.7903 5.78712 6.18424L5.78706 6.18418L5.78075 6.1905L5.32512 6.64613L4.47156 7.49968H5.67867H7.8335C8.01759 7.49968 8.16683 7.64892 8.16683 7.83302C8.16683 8.01711 8.01759 8.16635 7.8335 8.16635H3.66683C3.48274 8.16635 3.3335 8.01711 3.3335 7.83302V3.66635C3.3335 3.48225 3.48274 3.33302 3.66683 3.33302C3.85092 3.33302 4.00016 3.48225 4.00016 3.66635V5.82117V7.02827L4.85372 6.17472Z"})})});var Ns=require("react/jsx-runtime"),Kr=({size:e=24,className:t})=>(0,Ns.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#5fd9b0",stroke:"#1cad86",strokeWidth:"2",className:t,children:(0,Ns.jsx)("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});var ws=require("react/jsx-runtime"),Qn=({size:e=24,className:t})=>(0,ws.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",className:H("stroke-2",t),children:(0,ws.jsx)("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"})});var Tn=require("react/jsx-runtime"),Da=({size:e=24,className:t})=>(0,Tn.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[(0,Tn.jsx)("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Tn.jsx)("path",{d:"M7.5 12C7.5 12.89 7.76392 13.76 8.25839 14.5001C8.75285 15.2401 9.45566 15.8169 10.2779 16.1575C11.1002 16.4981 12.005 16.5872 12.8779 16.4135C13.7508 16.2399 14.5526 15.8113 15.182 15.182C15.8113 14.5526 16.2399 13.7508 16.4135 12.8779C16.5872 12.005 16.4981 11.1002 16.1575 10.2779C15.8169 9.45566 15.2401 8.75285 14.5001 8.25839C13.76 7.76392 12.89 7.5 12 7.5C10.742 7.50473 9.53448 7.99561 8.63 8.87L7.5 10",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Tn.jsx)("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});var wo=require("react/jsx-runtime"),Oa=({size:e=24,className:t})=>(0,wo.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[(0,wo.jsx)("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,wo.jsx)("path",{d:"M15.5 14.5V8.5C15.5 8.23478 15.3946 7.98043 15.2071 7.79289C15.0196 7.60536 14.7652 7.5 14.5 7.5H8",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,wo.jsx)("path",{d:"M10 16.5H16C16.2652 16.5 16.5196 16.3946 16.7071 16.2071C16.8946 16.0196 17 15.7652 17 15.5V15C17 14.8674 16.9473 14.7402 16.8536 14.6464C16.7598 14.5527 16.6326 14.5 16.5 14.5H11.5C11.3674 14.5 11.2402 14.5527 11.1464 14.6464C11.0527 14.7402 11 14.8674 11 15V15.5C11 15.7652 10.8946 16.0196 10.7071 16.2071C10.5196 16.3946 10.2652 16.5 10 16.5ZM10 16.5C9.73478 16.5 9.48043 16.3946 9.29289 16.2071C9.10536 16.0196 9 15.7652 9 15.5V8.5C9 8.23478 8.89464 7.98043 8.70711 7.79289C8.51957 7.60536 8.26522 7.5 8 7.5C7.73478 7.5 7.48043 7.60536 7.29289 7.79289C7.10536 7.98043 7 8.23478 7 8.5V9.5C7 9.63261 7.05268 9.75979 7.14645 9.85355C7.24021 9.94732 7.36739 10 7.5 10H9",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,wo.jsx)("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,wo.jsx)("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var Wo=require("react/jsx-runtime"),jn=({size:e=24,className:t})=>(0,Wo.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[(0,Wo.jsx)("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Wo.jsx)("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),(0,Wo.jsx)("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Wo.jsx)("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var se=(s=>(s.START_EVENT="START_EVENT",s.END_EVENT="END_EVENT",s.TASK="TASK",s.LANE="LANE",s.GATEWAY="GATEWAY",s.ANNOTATION="ANNOTATION",s.UNSUPPORTED="UNSUPPORTED",s))(se||{}),it=(n=>(n.SCRIPT="SCRIPT",n.SUBPROCESS="SUBPROCESS",n.SERVICE_TASK="SERVICE_TASK",n))(it||{}),qr={SCRIPT:{icon:Ao.ScrollText},SUBPROCESS:{icon:Ao.SquarePlus},SERVICE_TASK:{icon:Ao.Bot}},Dt=(t=>(t.LOOP="LOOP",t))(Dt||{}),Zr={LOOP:{icon:Ao.RotateCcw}},It=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(It||{}),As={EXCLUSIVE:{icon:xn},PARALLEL:{icon:_n},COMPLEX:{icon:hn}};var ff=require("@produto-lecom/lecom-ui"),mf=require("@xyflow/react"),Le=require("react");var ao=require("@xyflow/react"),mn=require("react");var Ep=require("@produto-lecom/lecom-ui"),no=require("@xyflow/react"),vt=require("react");var Jr={MIN_WIDTH:36,MIN_HEIGHT:36},Qr={MIN_WIDTH:36,MIN_HEIGHT:36},vn={MIN_WIDTH:56,MIN_HEIGHT:56},Io={MIN_WIDTH:176,MIN_HEIGHT:96},Va={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},ae={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},Nn={MIN_WIDTH:176,MIN_HEIGHT:64},If={MIN_WIDTH:128,MIN_HEIGHT:64},ue={START_EVENT:Jr,END_EVENT:Qr,GATEWAY:vn,TASK:Io,LANE:ae,ANNOTATION:Nn,UNSUPPORTED:If};var wn=require("@xyflow/react");function Ha(e,t){var x,N,b,T;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+((N=(x=t==null?void 0:t.measured)==null?void 0:x.width)!=null?N:0)/2,u=i.y+((T=(b=t==null?void 0:t.measured)==null?void 0:b.height)!=null?T:0)/2,f=(d-l)/(2*a)-(u-c)/(2*s),m=(d-l)/(2*a)+(u-c)/(2*s),y=1/(Math.abs(f)+Math.abs(m)||1),E=y*f,p=y*m,g=a*(E+p)+l,h=s*(-E+p)+c;return{x:g,y:h}}function Ga(e,t){var c,d,u,f;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(f=(u=e.measured)==null?void 0:u.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?wn.Position.Left:s>=i+n-1?wn.Position.Right:l<=a+1?wn.Position.Top:l>=a+r-1?wn.Position.Bottom:wn.Position.Top}function An(e,t){let o=Ha(e,t),n=Ha(t,e),r=Ga(e,o),i=Ga(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function jr(e,t){return{isFromStartEvent:(e==null?void 0:e.type)==="START_EVENT",isGatewayToGateway:(e==null?void 0:e.type)==="GATEWAY"&&(t==null?void 0:t.type)==="GATEWAY",isActiviyToAndGateway:(e==null?void 0:e.type)==="TASK"&&(t==null?void 0:t.type)==="GATEWAY",isToEndEvent:(t==null?void 0:t.type)==="END_EVENT"}}var Ba=require("lodash");var za=e=>new Map(e.map(t=>[t.id,t])),Ya=(e,t)=>e.map(o=>{var n;return(n=t.get(o.id))!=null?n:o}),Ct=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}},er=e=>(0,Ba.orderBy)(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),Fa=(e,t)=>{let{x:o,y:n}=Ct(e),{x:r,y:i}=Ct(t);return{x:o-r,y:n-i}};var Xo=({parentId:e,nodes:t,includeTypes:o=[...Object.values(se)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),Cf=(e,t)=>{let{x:o,y:n}=Ct(e),{x:r,y:i}=Ct(t),a=o-r,s=n-i;return Math.sqrt(a*a+s*s)},Sf=(e,t)=>{let{x:o,y:n,w:r,h:i}=Ct(e),{x:a,y:s,w:l,h:c}=Ct(t),d=o+r/2,u=n+i/2;return d>=a&&d<=a+l&&u>=s&&u<=s+c},tr=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&Sf(e,r)){let i=Cf(e,r);i<n&&(n=i,o=r)}return o},Wa=(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 Xa=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}},Ua=({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 Is=(e,t)=>{let o=t.find(a=>a.id===e);if(!o||o.type!=="LANE"||o.parentId)return!1;let n=Ct(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=Ct(a);return s.x<r&&s.x+s.w>n.x&&s.y<i&&s.y+s.h>n.y})};var Mf=50,Uo=(e,t)=>{var f,m,y,E,p,g,h,x,N,b,T,v,A,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=(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=(N=S.position)==null?void 0:N.y)!=null?b:0,K=(v=(T=S.position)==null?void 0:T.x)!=null?v: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+Mf-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})})})},He=15,$o=e=>[...e].sort((t,o)=>t.position.y-o.position.y),Pf=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)},Lf=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)},Cs=(e,t,o)=>{var d,u,f,m,y,E,p,g,h,x,N,b,T,v,A;if(t.length===0)return e;let n=(f=(u=e.width)!=null?u:(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=Pf(C),R=Lf(C);if(((g=(p=C.position)==null?void 0:p.y)!=null?g:0)<He&&(o.set(C.id,w(_({},C),{position:w(_({},C.position),{y:He})})),R=He+((x=(h=C.measured)==null?void 0:h.height)!=null?x:0)),((b=(N=C.position)==null?void 0:N.x)!=null?b:0)<ae.HEADER_WIDTH+He){let S=(T=o.get(C.id))!=null?T:C;o.set(C.id,w(_({},S),{position:w(_({},S.position),{x:ae.HEADER_WIDTH+He})})),P=ae.HEADER_WIDTH+He+((A=(v=C.measured)==null?void 0:v.width)!=null?A:0)}i=Math.max(i,P),a=Math.max(a,R)}let s=Math.max(n,ae.MIN_WIDTH),l=Math.max(r,ae.MIN_HEIGHT);i+He>s&&(s=i+He),a+He>l&&(l=a+He);let c=w(_({},e),{width:s,height:l,measured:w(_({},e.measured),{width:s,height:l})});return o.set(e.id,c),c},$a=(e,t,o)=>{var a,s;let n=$o(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=Cs(l,c,t);t.set(d.id,w(_({},d),{position:{x:ae.HEADER_WIDTH,y:i}})),i+=(s=d.height)!=null?s:0}},Ka=(e,t)=>{var y,E,p,g;let o=[];for(let h of t.values())h.parentId===e.id&&o.push(h);let n=$o(o),r=((E=(y=e.measured)==null?void 0:y.width)!=null?E:0)-ae.HEADER_WIDTH,i=Wa(e.id,o)||ae.MIN_WIDTH,a=o.reduce((h,x)=>{var N;return h+((N=x.height)!=null?N:ae.MIN_HEIGHT)},0),s=Math.max(r,i),l=a,c=r>i,d=c?s:s+ae.HEADER_WIDTH,u=c?s-ae.HEADER_WIDTH:s,f=0;for(let h=0;h<n.length;h++){let x=n[h],N=Math.max(ae.MIN_HEIGHT,(p=x.height)!=null?p:ae.MIN_HEIGHT),b=w(_({},x),{width:u,height:N,measured:w(_({},x.measured),{width:u,height:N}),position:{x:ae.HEADER_WIDTH,y:f}});if(h===o.length-1){let T=Math.max(ae.MIN_HEIGHT,l-f);b=w(_({},b),{height:T,measured:w(_({},x.measured),{width:u,height:T})})}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})}))},qa=(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=$o(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,f=0,m=[...n];return l.forEach((p,g)=>{var T,v;let h=g===l.length-1,x=p.id===e.id,b=(v=(T=p.measured)==null?void 0:T.height)!=null?v:0;x?b=o:u&&g===c-1&&(b=Math.max(ae.MIN_HEIGHT,r-f)),h&&i&&(b=Math.max(ae.MIN_HEIGHT,o-f)),m=m.map(A=>{if(A.id===p.id){let C=i?t-ae.HEADER_WIDTH:t;return w(_({},A),{width:C,height:b,measured:w(_({},A.measured),{width:C,height:b}),position:{x:ae.HEADER_WIDTH,y:f}})}return A}),x&&u?f=r+o:f+=b}),m=m.map(p=>{if(p.id===a){let g=i?t:t+ae.HEADER_WIDTH;return w(_({},p),{width:g,height:i?o:f,measured:{width:g,height:i?o:f}})}return p}),m};var Ss=(e,t,o)=>{var s,l,c,d,u,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<He&&(e.position.y=He),e.position.x<ae.HEADER_WIDTH+He&&(e.position.x=ae.HEADER_WIDTH+He);let i=e.position.x+((f=(u=e.measured)==null?void 0:u.width)!=null?f:0),a=e.position.y+((y=(m=e.measured)==null?void 0:m.height)!=null?y:0);return i+He>n&&(t.width=i+He,t.measured.width=i+He),a+He>r&&(t.height=a+He,t.measured.height=a+He),o=o.map(E=>E.id===t.id?w(_({},E),{height:t.height,width:t.width,measured:t.measured}):E.id===e.id?w(_({},E),{position:e.position}):E),o};var Ja=require("react"),Qa=require("zustand");var Za=require("@xyflow/react"),$t=()=>{let e=(0,Za.useStoreApi)();return{selectElements:n=>{let{edges:r,nodes:i,triggerEdgeChanges:a,triggerNodeChanges:s}=e.getState(),l=i.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]),c=r.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]);return s(l),a(c),!0},clearSelection:async()=>{let{unselectNodesAndEdges:n}=e.getState();return n(),await Ur(),!0}}};var ja=()=>{let{selectElements:e}=$t();return(0,Ja.useCallback)(()=>{let o=Ko.getState().pathEdgeIds;e(o)},[e])},Ko=(0,Qa.create)((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=_({},n.statusByNodeId),i=_({},n.statusData),a=!1;return o.forEach(s=>{let l=`${s.diagramId}-${s.activityId}`;r[s.diagramId]!==s.status&&(r[s.diagramId]=s.status,i[l]=s,a=!0)}),a?{statusByNodeId:r,statusData:i}:n})},getTaskStatus:o=>t().statusByNodeId[o]||null,clearTaskStatuses:()=>e({statusByNodeId:{},statusData:{},pathEdgeIds:[]}),setPathEdges:o=>{e({pathEdgeIds:o})},getPathEdgeIds:()=>t().pathEdgeIds,clearPathEdges:()=>{e({pathEdgeIds:[]})},calculateFlowPath:(o,n)=>{if(!o.length||!n.length)return;t().clearPathEdges();let r=n.filter(d=>t().statusByNodeId[d]);if(r.length<=1)return;let i=[],a={};o.forEach(d=>{a[d.source]||(a[d.source]=[]),a[d.source].push({targetId:d.target,edgeId:d.id})});let s=r[0],l=r[r.length-1];o.forEach(d=>{d.target===s&&i.push(d.id)}),o.forEach(d=>{d.source===l&&i.push(d.id)});let c=(d,u)=>{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===u)return E;let p=a[y]||[];for(let{targetId:g,edgeId:h}of p)m.has(g)||(m.add(g),f.push({node:g,path:[...E,h]}))}return[]};for(let d=0;d<r.length-1;d++){let u=r[d],f=r[d+1],m=c(u,f);m.length>0&&i.push(...m)}i.length>0&&e({pathEdgeIds:i})}}));var Pn=require("@xyflow/react"),ft=require("react"),$c=require("zustand/shallow");var kf={value:()=>{}};function tl(){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 ei(o)}function ei(e){this._=e}function Rf(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}})}ei.prototype=tl.prototype={constructor:ei,on:function(e,t){var o=this._,n=Rf(e+"",o),r,i=-1,a=n.length;if(arguments.length<2){for(;++i<a;)if((r=(e=n[i]).type)&&(r=Df(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]=el(o[r],e.name,t);else if(t==null)for(r in o)o[r]=el(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 ei(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 Df(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function el(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=kf,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var Ms=tl;var ti="http://www.w3.org/1999/xhtml",Ps={svg:"http://www.w3.org/2000/svg",xhtml:ti,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function po(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),Ps.hasOwnProperty(t)?{space:Ps[t],local:e}:e}function Of(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===ti&&t.documentElement.namespaceURI===ti?t.createElement(e):t.createElementNS(o,e)}}function Vf(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function oi(e){var t=po(e);return(t.local?Vf:Of)(t)}function Hf(){}function qo(e){return e==null?Hf:function(){return this.querySelector(e)}}function ol(e){typeof e!="function"&&(e=qo(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],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 Ue(n,this._parents)}function Ls(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Gf(){return[]}function or(e){return e==null?Gf:function(){return this.querySelectorAll(e)}}function Bf(e){return function(){return Ls(e.apply(this,arguments))}}function nl(e){typeof e=="function"?e=Bf(e):e=or(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 Ue(n,r)}function nr(e){return function(){return this.matches(e)}}function ni(e){return function(t){return t.matches(e)}}var zf=Array.prototype.find;function Yf(e){return function(){return zf.call(this.children,e)}}function Ff(){return this.firstElementChild}function rl(e){return this.select(e==null?Ff:Yf(typeof e=="function"?e:ni(e)))}var Wf=Array.prototype.filter;function Xf(){return Array.from(this.children)}function Uf(e){return function(){return Wf.call(this.children,e)}}function il(e){return this.selectAll(e==null?Xf:Uf(typeof e=="function"?e:ni(e)))}function sl(e){typeof e!="function"&&(e=nr(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 Ue(n,this._parents)}function ri(e){return new Array(e.length)}function al(){return new Ue(this._enter||this._groups.map(ri),this._parents)}function rr(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}rr.prototype={constructor:rr,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 ll(e){return function(){return e}}function $f(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 rr(e,i[a]);for(;a<l;++a)(s=t[a])&&(r[a]=s)}function Kf(e,t,o,n,r,i,a){var s,l,c=new Map,d=t.length,u=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<u;++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 rr(e,i[s]);for(s=0;s<d;++s)(l=t[s])&&c.get(f[s])===l&&(r[s]=l)}function qf(e){return e.__data__}function cl(e,t){if(!arguments.length)return Array.from(this,qf);var o=t?Kf:$f,n=this._parents,r=this._groups;typeof e!="function"&&(e=ll(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],f=u.length,m=Zf(e.call(d,d&&d.__data__,c,n)),y=m.length,E=s[c]=new Array(y),p=a[c]=new Array(y),g=l[c]=new Array(f);o(d,u,E,p,g,m,t);for(var h=0,x=0,N,b;h<y;++h)if(N=E[h]){for(h>=x&&(x=h+1);!(b=p[x])&&++x<y;);N._next=b||null}}return a=new Ue(a,n),a._enter=s,a._exit=l,a}function Zf(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function dl(){return new Ue(this._exit||this._groups.map(ri),this._parents)}function ul(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 pl(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,f=s[l]=new Array(u),m,y=0;y<u;++y)(m=c[y]||d[y])&&(f[y]=m);for(;l<r;++l)s[l]=o[l];return new Ue(s,this._parents)}function fl(){for(var e=this._groups,t=-1,o=e.length;++t<o;)for(var n=e[t],r=n.length-1,i=n[r],a;--r>=0;)(a=n[r])&&(i&&a.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(a,i),i=a);return this}function ml(e){e||(e=Jf);function t(u,f){return u&&f?e(u.__data__,f.__data__):!u-!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 Ue(r,this._parents).order()}function Jf(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function gl(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function hl(){return Array.from(this)}function yl(){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 xl(){let e=0;for(let t of this)++e;return e}function El(){return!this.node()}function _l(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 Qf(e){return function(){this.removeAttribute(e)}}function jf(e){return function(){this.removeAttributeNS(e.space,e.local)}}function em(e,t){return function(){this.setAttribute(e,t)}}function tm(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function om(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function nm(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 bl(e,t){var o=po(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?jf:Qf:typeof t=="function"?o.local?nm:om:o.local?tm:em)(o,t))}function ii(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function rm(e){return function(){this.style.removeProperty(e)}}function im(e,t,o){return function(){this.style.setProperty(e,t,o)}}function sm(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function Tl(e,t,o){return arguments.length>1?this.each((t==null?rm:typeof t=="function"?sm:im)(e,t,o==null?"":o)):Co(this.node(),e)}function Co(e,t){return e.style.getPropertyValue(t)||ii(e).getComputedStyle(e,null).getPropertyValue(t)}function am(e){return function(){delete this[e]}}function lm(e,t){return function(){this[e]=t}}function cm(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function vl(e,t){return arguments.length>1?this.each((t==null?am:typeof t=="function"?cm:lm)(e,t)):this.node()[e]}function Nl(e){return e.trim().split(/^|\s+/)}function ks(e){return e.classList||new wl(e)}function wl(e){this._node=e,this._names=Nl(e.getAttribute("class")||"")}wl.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 Al(e,t){for(var o=ks(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function Il(e,t){for(var o=ks(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function dm(e){return function(){Al(this,e)}}function um(e){return function(){Il(this,e)}}function pm(e,t){return function(){(t.apply(this,arguments)?Al:Il)(this,e)}}function Cl(e,t){var o=Nl(e+"");if(arguments.length<2){for(var n=ks(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?pm:t?dm:um)(o,t))}function fm(){this.textContent=""}function mm(e){return function(){this.textContent=e}}function gm(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function Sl(e){return arguments.length?this.each(e==null?fm:(typeof e=="function"?gm:mm)(e)):this.node().textContent}function hm(){this.innerHTML=""}function ym(e){return function(){this.innerHTML=e}}function xm(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function Ml(e){return arguments.length?this.each(e==null?hm:(typeof e=="function"?xm:ym)(e)):this.node().innerHTML}function Em(){this.nextSibling&&this.parentNode.appendChild(this)}function Pl(){return this.each(Em)}function _m(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ll(){return this.each(_m)}function kl(e){var t=typeof e=="function"?e:oi(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function bm(){return null}function Rl(e,t){var o=typeof e=="function"?e:oi(e),n=t==null?bm:typeof t=="function"?t:qo(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function Tm(){var e=this.parentNode;e&&e.removeChild(this)}function Dl(){return this.each(Tm)}function vm(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Nm(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Ol(e){return this.select(e?Nm:vm)}function Vl(e){return arguments.length?this.property("__data__",e):this.node().__data__}function wm(e){return function(t){e.call(this,t,this.__data__)}}function Am(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 Im(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 Cm(e,t,o){return function(){var n=this.__on,r,i=wm(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 Hl(e,t,o){var n=Am(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?Cm:Im,r=0;r<i;++r)this.each(s(n[r],t,o));return this}function Gl(e,t,o){var n=ii(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 Gl(this,e,t)}}function Mm(e,t){return function(){return Gl(this,e,t.apply(this,arguments))}}function Bl(e,t){return this.each((typeof t=="function"?Mm:Sm)(e,t))}function*zl(){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 Pm=[null];function Ue(e,t){this._groups=e,this._parents=t}function Yl(){return new Ue([[document.documentElement]],Pm)}function Lm(){return this}Ue.prototype=Yl.prototype={constructor:Ue,select:ol,selectAll:nl,selectChild:rl,selectChildren:il,filter:sl,data:cl,enter:al,exit:dl,join:ul,merge:pl,selection:Lm,order:fl,sort:ml,call:gl,nodes:hl,node:yl,size:xl,empty:El,each:_l,attr:bl,style:Tl,property:vl,classed:Cl,text:Sl,html:Ml,raise:Pl,lower:Ll,append:kl,insert:Rl,remove:Dl,clone:Ol,datum:Vl,on:Hl,dispatch:Bl,[Symbol.iterator]:zl};var fo=Yl;function si(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function Rs(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function ar(){}var ir=.7,ci=1/ir,In="\\s*([+-]?\\d+)\\s*",sr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Kt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",km=/^#([0-9a-f]{3,8})$/,Rm=new RegExp(`^rgb\\(${In},${In},${In}\\)$`),Dm=new RegExp(`^rgb\\(${Kt},${Kt},${Kt}\\)$`),Om=new RegExp(`^rgba\\(${In},${In},${In},${sr}\\)$`),Vm=new RegExp(`^rgba\\(${Kt},${Kt},${Kt},${sr}\\)$`),Hm=new RegExp(`^hsl\\(${sr},${Kt},${Kt}\\)$`),Gm=new RegExp(`^hsla\\(${sr},${Kt},${Kt},${sr}\\)$`),Fl={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};si(ar,So,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Wl,formatHex:Wl,formatHex8:Bm,formatHsl:zm,formatRgb:Xl,toString:Xl});function Wl(){return this.rgb().formatHex()}function Bm(){return this.rgb().formatHex8()}function zm(){return Jl(this).formatHsl()}function Xl(){return this.rgb().formatRgb()}function So(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=km.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?Ul(t):o===3?new st(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?ai(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?ai(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=Rm.exec(e))?new st(t[1],t[2],t[3],1):(t=Dm.exec(e))?new st(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Om.exec(e))?ai(t[1],t[2],t[3],t[4]):(t=Vm.exec(e))?ai(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Hm.exec(e))?ql(t[1],t[2]/100,t[3]/100,1):(t=Gm.exec(e))?ql(t[1],t[2]/100,t[3]/100,t[4]):Fl.hasOwnProperty(e)?Ul(Fl[e]):e==="transparent"?new st(NaN,NaN,NaN,0):null}function Ul(e){return new st(e>>16&255,e>>8&255,e&255,1)}function ai(e,t,o,n){return n<=0&&(e=t=o=NaN),new st(e,t,o,n)}function Ym(e){return e instanceof ar||(e=So(e)),e?(e=e.rgb(),new st(e.r,e.g,e.b,e.opacity)):new st}function Cn(e,t,o,n){return arguments.length===1?Ym(e):new st(e,t,o,n==null?1:n)}function st(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}si(st,Cn,Rs(ar,{brighter(e){return e=e==null?ci:Math.pow(ci,e),new st(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?ir:Math.pow(ir,e),new st(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new st(Jo(this.r),Jo(this.g),Jo(this.b),di(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:$l,formatHex:$l,formatHex8:Fm,formatRgb:Kl,toString:Kl}));function $l(){return`#${Zo(this.r)}${Zo(this.g)}${Zo(this.b)}`}function Fm(){return`#${Zo(this.r)}${Zo(this.g)}${Zo(this.b)}${Zo((isNaN(this.opacity)?1:this.opacity)*255)}`}function Kl(){let e=di(this.opacity);return`${e===1?"rgb(":"rgba("}${Jo(this.r)}, ${Jo(this.g)}, ${Jo(this.b)}${e===1?")":`, ${e})`}`}function di(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Jo(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Zo(e){return e=Jo(e),(e<16?"0":"")+e.toString(16)}function ql(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new Ot(e,t,o,n)}function Jl(e){if(e instanceof Ot)return new Ot(e.h,e.s,e.l,e.opacity);if(e instanceof ar||(e=So(e)),!e)return new Ot;if(e instanceof Ot)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 Ot(a,s,l,e.opacity)}function Ql(e,t,o,n){return arguments.length===1?Jl(e):new Ot(e,t,o,n==null?1:n)}function Ot(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}si(Ot,Ql,Rs(ar,{brighter(e){return e=e==null?ci:Math.pow(ci,e),new Ot(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?ir:Math.pow(ir,e),new Ot(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 st(Ds(e>=240?e-240:e+120,r,n),Ds(e,r,n),Ds(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new Ot(Zl(this.h),li(this.s),li(this.l),di(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=di(this.opacity);return`${e===1?"hsl(":"hsla("}${Zl(this.h)}, ${li(this.s)*100}%, ${li(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Zl(e){return e=(e||0)%360,e<0?e+360:e}function li(e){return Math.max(0,Math.min(1,e||0))}function Ds(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 Os(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 jl(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 Os((o-n/t)*t,a,r,i,s)}}function ec(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 Os((o-n/t)*t,r,i,a,s)}}var Vs=e=>()=>e;function Wm(e,t){return function(o){return e+o*t}}function Xm(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 tc(e){return(e=+e)==1?ui:function(t,o){return o-t?Xm(t,o,e):Vs(isNaN(t)?o:t)}}function ui(e,t){var o=t-e;return o?Wm(e,o):Vs(isNaN(e)?t:e)}var pi=function e(t){var o=tc(t);function n(r,i){var a=o((r=Cn(r)).r,(i=Cn(i)).r),s=o(r.g,i.g),l=o(r.b,i.b),c=ui(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 oc(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=Cn(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 Um=oc(jl),$m=oc(ec);function St(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var Gs=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Hs=new RegExp(Gs.source,"g");function Km(e){return function(){return e}}function qm(e){return function(t){return e(t)+""}}function Bs(e,t){var o=Gs.lastIndex=Hs.lastIndex=0,n,r,i,a=-1,s=[],l=[];for(e=e+"",t=t+"";(n=Gs.exec(e))&&(r=Hs.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:St(n,r)})),o=Hs.lastIndex;return o<t.length&&(i=t.slice(o),s[a]?s[a]+=i:s[++a]=i),s.length<2?l[0]?qm(l[0].x):Km(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 nc=180/Math.PI,fi={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function zs(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)*nc,skewX:Math.atan(l)*nc,scaleX:a,scaleY:s}}var mi;function rc(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?fi:zs(t.a,t.b,t.c,t.d,t.e,t.f)}function ic(e){return e==null?fi:(mi||(mi=document.createElementNS("http://www.w3.org/2000/svg","g")),mi.setAttribute("transform",e),(e=mi.transform.baseVal.consolidate())?(e=e.matrix,zs(e.a,e.b,e.c,e.d,e.e,e.f)):fi)}function sc(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,f,m,y){if(c!==u||d!==f){var E=m.push("translate(",null,t,null,o);y.push({i:E-4,x:St(c,u)},{i:E-2,x:St(d,f)})}else(u||f)&&m.push("translate("+u+t+f+o)}function a(c,d,u,f){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),f.push({i:u.push(r(u)+"rotate(",null,n)-2,x:St(c,d)})):d&&u.push(r(u)+"rotate("+d+n)}function s(c,d,u,f){c!==d?f.push({i:u.push(r(u)+"skewX(",null,n)-2,x:St(c,d)}):d&&u.push(r(u)+"skewX("+d+n)}function l(c,d,u,f,m,y){if(c!==u||d!==f){var E=m.push(r(m)+"scale(",null,",",null,")");y.push({i:E-4,x:St(c,u)},{i:E-2,x:St(d,f)})}else(u!==1||f!==1)&&m.push(r(m)+"scale("+u+","+f+")")}return function(c,d){var u=[],f=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,u,f),a(c.rotate,d.rotate,u,f),s(c.skewX,d.skewX,u,f),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,f),c=d=null,function(m){for(var y=-1,E=f.length,p;++y<E;)u[(p=f[y]).i]=p.x(m);return u.join("")}}}var Ys=sc(rc,"px, ","px)","deg)"),Fs=sc(ic,", ",")",")");var Sn=0,cr=0,lr=0,lc=1e3,gi,dr,hi=0,Qo=0,yi=0,ur=typeof performance=="object"&&performance.now?performance:Date,cc=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function fr(){return Qo||(cc(Zm),Qo=ur.now()+yi)}function Zm(){Qo=0}function pr(){this._call=this._time=this._next=null}pr.prototype=xi.prototype={constructor:pr,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?fr():+o)+(t==null?0:+t),!this._next&&dr!==this&&(dr?dr._next=this:gi=this,dr=this),this._call=e,this._time=o,Ws()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ws())}};function xi(e,t,o){var n=new pr;return n.restart(e,t,o),n}function dc(){fr(),++Sn;for(var e=gi,t;e;)(t=Qo-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Sn}function ac(){Qo=(hi=ur.now())+yi,Sn=cr=0;try{dc()}finally{Sn=0,Qm(),Qo=0}}function Jm(){var e=ur.now(),t=e-hi;t>lc&&(yi-=t,hi=e)}function Qm(){for(var e,t=gi,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:gi=o);dr=e,Ws(n)}function Ws(e){if(!Sn){cr&&(cr=clearTimeout(cr));var t=e-Qo;t>24?(e<1/0&&(cr=setTimeout(ac,e-ur.now()-yi)),lr&&(lr=clearInterval(lr))):(lr||(hi=ur.now(),lr=setInterval(Jm,lc)),Sn=1,cc(ac))}}function Ei(e,t,o){var n=new pr;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var jm=Ms("start","end","cancel","interrupt"),eg=[],fc=0,uc=1,bi=2,_i=3,pc=4,Ti=5,mr=6;function Mo(e,t,o,n,r,i){var a=e.__transition;if(!a)e.__transition={};else if(o in a)return;tg(e,o,{name:t,index:n,group:r,on:jm,tween:eg,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:fc})}function gr(e,t){var o=$e(e,t);if(o.state>fc)throw new Error("too late; already scheduled");return o}function Qe(e,t){var o=$e(e,t);if(o.state>_i)throw new Error("too late; already running");return o}function $e(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function tg(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=xi(i,0,o.time);function i(c){o.state=uc,o.timer.restart(a,o.delay,o.time),o.delay<=c&&a(c-o.delay)}function a(c){var d,u,f,m;if(o.state!==uc)return l();for(d in n)if(m=n[d],m.name===o.name){if(m.state===_i)return Ei(a);m.state===pc?(m.state=mr,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete n[d]):+d<t&&(m.state=mr,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete n[d])}if(Ei(function(){o.state===_i&&(o.state=pc,o.timer.restart(s,o.delay,o.time),s(c))}),o.state=bi,o.on.call("start",e,e.__data__,o.index,o.group),o.state===bi){for(o.state=_i,r=new Array(f=o.tween.length),d=0,u=-1;d<f;++d)(m=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++u]=m);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=Ti,1),u=-1,f=r.length;++u<f;)r[u].call(e,d);o.state===Ti&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=mr,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function Xs(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>bi&&n.state<Ti,n.state=mr,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[a]}i&&delete e.__transition}}function mc(e){return this.each(function(){Xs(this,e)})}function og(e,t){var o,n;return function(){var r=Qe(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 ng(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=Qe(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 gc(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=$e(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?og:ng)(o,e,t))}function Mn(e,t,o){var n=e._id;return e.each(function(){var r=Qe(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return $e(r,n).value[t]}}function vi(e,t){var o;return(typeof t=="number"?St:t instanceof So?pi:(o=So(t))?(t=o,pi):Bs)(e,t)}function rg(e){return function(){this.removeAttribute(e)}}function ig(e){return function(){this.removeAttributeNS(e.space,e.local)}}function sg(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 ag(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 lg(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 cg(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 hc(e,t){var o=po(e),n=o==="transform"?Fs:vi;return this.attrTween(e,typeof t=="function"?(o.local?cg:lg)(o,n,Mn(this,"attr."+e,t)):t==null?(o.local?ig:rg)(o):(o.local?ag:sg)(o,n,t))}function dg(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function ug(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function pg(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&ug(e,i)),o}return r._value=t,r}function fg(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&dg(e,i)),o}return r._value=t,r}function yc(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=po(e);return this.tween(o,(n.local?pg:fg)(n,t))}function mg(e,t){return function(){gr(this,e).delay=+t.apply(this,arguments)}}function gg(e,t){return t=+t,function(){gr(this,e).delay=t}}function xc(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?mg:gg)(t,e)):$e(this.node(),t).delay}function hg(e,t){return function(){Qe(this,e).duration=+t.apply(this,arguments)}}function yg(e,t){return t=+t,function(){Qe(this,e).duration=t}}function Ec(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?hg:yg)(t,e)):$e(this.node(),t).duration}function xg(e,t){if(typeof t!="function")throw new Error;return function(){Qe(this,e).ease=t}}function _c(e){var t=this._id;return arguments.length?this.each(xg(t,e)):$e(this.node(),t).ease}function Eg(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;Qe(this,e).ease=o}}function bc(e){if(typeof e!="function")throw new Error;return this.each(Eg(this._id,e))}function Tc(e){typeof e!="function"&&(e=nr(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 tt(n,this._parents,this._name,this._id)}function vc(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),f,m=0;m<d;++m)(f=l[m]||c[m])&&(u[m]=f);for(;s<n;++s)a[s]=t[s];return new tt(a,this._parents,this._name,this._id)}function _g(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 bg(e,t,o){var n,r,i=_g(t)?gr:Qe;return function(){var a=i(this,e),s=a.on;s!==n&&(r=(n=s).copy()).on(t,o),a.on=r}}function Nc(e,t){var o=this._id;return arguments.length<2?$e(this.node(),o).on.on(e):this.each(bg(o,e,t))}function Tg(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function wc(){return this.on("end.remove",Tg(this._id))}function Ac(e){var t=this._name,o=this._id;typeof e!="function"&&(e=qo(e));for(var n=this._groups,r=n.length,i=new Array(r),a=0;a<r;++a)for(var s=n[a],l=s.length,c=i[a]=new Array(l),d,u,f=0;f<l;++f)(d=s[f])&&(u=e.call(d,d.__data__,f,s))&&("__data__"in d&&(u.__data__=d.__data__),c[f]=u,Mo(c[f],t,o,f,c,$e(d,o)));return new tt(i,this._parents,t,o)}function Ic(e){var t=this._name,o=this._id;typeof e!="function"&&(e=or(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 f=e.call(d,d.__data__,u,l),m,y=$e(d,o),E=0,p=f.length;E<p;++E)(m=f[E])&&Mo(m,t,o,E,f,y);i.push(f),a.push(d)}return new tt(i,a,t,o)}var vg=fo.prototype.constructor;function Cc(){return new vg(this._groups,this._parents)}function Ng(e,t){var o,n,r;return function(){var i=Co(this,e),a=(this.style.removeProperty(e),Co(this,e));return i===a?null:i===o&&a===n?r:r=t(o=i,n=a)}}function Sc(e){return function(){this.style.removeProperty(e)}}function wg(e,t,o){var n,r=o+"",i;return function(){var a=Co(this,e);return a===r?null:a===n?i:i=t(n=a,o)}}function Ag(e,t,o){var n,r,i;return function(){var a=Co(this,e),s=o(this),l=s+"";return s==null&&(l=s=(this.style.removeProperty(e),Co(this,e))),a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s))}}function Ig(e,t){var o,n,r,i="style."+t,a="end."+i,s;return function(){var l=Qe(this,e),c=l.on,d=l.value[i]==null?s||(s=Sc(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(a,r=d),l.on=n}}function Mc(e,t,o){var n=(e+="")=="transform"?Ys:vi;return t==null?this.styleTween(e,Ng(e,n)).on("end.style."+e,Sc(e)):typeof t=="function"?this.styleTween(e,Ag(e,n,Mn(this,"style."+e,t))).each(Ig(this._id,e)):this.styleTween(e,wg(e,n,t),o).on("end.style."+e,null)}function Cg(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)&&Cg(e,a,o)),n}return i._value=t,i}function Pc(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 Mg(e){return function(){this.textContent=e}}function Pg(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function Lc(e){return this.tween("text",typeof e=="function"?Pg(Mn(this,"text",e)):Mg(e==null?"":e+""))}function Lg(e){return function(t){this.textContent=e.call(this,t)}}function kg(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&Lg(r)),t}return n._value=e,n}function kc(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,kg(e))}function Rc(){for(var e=this._name,t=this._id,o=Ni(),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=$e(l,t);Mo(l,e,o,c,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new tt(n,this._parents,e,o)}function Dc(){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=Qe(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 Rg=0;function tt(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function Oc(e){return fo().transition(e)}function Ni(){return++Rg}var mo=fo.prototype;tt.prototype=Oc.prototype={constructor:tt,select:Ac,selectAll:Ic,selectChild:mo.selectChild,selectChildren:mo.selectChildren,filter:Tc,merge:vc,selection:Cc,transition:Rc,call:mo.call,nodes:mo.nodes,node:mo.node,size:mo.size,empty:mo.empty,each:mo.each,on:Nc,attr:hc,attrTween:yc,style:Mc,styleTween:Pc,text:Lc,textTween:kc,remove:wc,tween:gc,delay:xc,duration:Ec,ease:_c,easeVarying:bc,end:Dc,[Symbol.iterator]:mo[Symbol.iterator]};function wi(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Dg={time:null,delay:0,duration:250,ease:wi};function Og(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 Vc(e){var t,o;e instanceof tt?(t=e._id,e=e._name):(t=Ni(),(o=Dg).time=fr(),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])&&Mo(l,e,t,c,a,o||Og(l,t));return new tt(n,this._parents,e,t)}fo.prototype.interrupt=mc;fo.prototype.transition=Vc;function Po(e,t,o){this.k=e,this.x=t,this.y=o}Po.prototype={constructor:Po,scale:function(e){return e===1?this:new Po(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Po(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 Ai=new Po(1,0,0);Ii.prototype=Po.prototype;function Ii(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Ai;return e.__zoom}var Hg=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var Hc;(function(e){e.Strict="strict",e.Loose="loose"})(Hc||(Hc={}));var Gc;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Gc||(Gc={}));var Bc;(function(e){e.Partial="partial",e.Full="full"})(Bc||(Bc={}));var zc;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(zc||(zc={}));var Yc;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Yc||(Yc={}));var at;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(at||(at={}));var K1={[at.Left]:at.Right,[at.Right]:at.Left,[at.Top]:at.Bottom,[at.Bottom]:at.Top};var Gg=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var Bg=(e,t=[0,0])=>{var s;let{width:o,height:n}=zg(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 Ci=(e,t=[0,0])=>{var r,i,a,s,l,c,d,u;let{x:o,y:n}=Gg(e)?e.internals.positionAbsolute:Bg(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 zg(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 q1={[at.Left]:{x:-1,y:0},[at.Right]:{x:1,y:0},[at.Top]:{x:0,y:-1},[at.Bottom]:{x:0,y:1}};var Yg={nodeOrigin:[0,0],nodeExtent:Hg,elevateNodesOnSelect:!0,defaults:{}},Z1=w(_({},Yg),{checkEquality:!0});var Fc;(function(e){e.Line="line",e.Handle="handle"})(Fc||(Fc={}));var Fg={width:0,height:0,x:0,y:0},J1=w(_({},Fg),{pointerX:0,pointerY:0,aspectRatio:1});var Wg=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function Xg(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 Ug(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 Si=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)||!Wg(m.nodeBox,r))continue;let y=Math.abs(m.position-o);if(y>Mi)continue;let p=Xg(m.nodeBox,n)>0?0:Ug(m.nodeBox,n);c.push({line:m,lineDist:y,nodeDist:p})}let d=.5,u=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;c.sort((m,y)=>{if(u){if(m.line===u&&y.line!==u)return-1;if(y.line===u&&m.line!==u)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 Wc(e,t=jo,o){let n=[];return e==null||e.forEach(r=>{let i=o(r.id);if(!i)throw new Error(`Node with id ${r.id} not found in internal nodes.`);let a=Ci(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 Xc(e,t,o,n,r=Object.keys(jo)){let i=[];for(let s of r){let l=jo[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 Uc(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)<=Mi&&(r=l,a=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=Mi&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:a}}var Mi=10,jo={top:{orientation:"horizontal",resolve:(e,t)=>t.y},bottom:{orientation:"horizontal",resolve:(e,t)=>t.y2},left:{orientation:"vertical",resolve:(e,t)=>t.x},right:{orientation:"vertical",resolve:(e,t)=>t.x2},centerX:{orientation:"vertical",resolve:(e,t)=>(t.x+t.x2)/2},centerY:{orientation:"horizontal",resolve:(e,t)=>(t.y+t.y2)/2}};var Kc=require("react/jsx-runtime"),$g=new Si;function Pi(){let[e,t]=(0,ft.useState)(void 0),[o,n]=(0,ft.useState)(void 0),{width:r,height:i}=(0,Pn.useStore)(p=>({width:p.width,height:p.height}),$c.shallow),a=(0,Pn.useNodesInitialized)(),s=(0,ft.useRef)($g),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=(0,Pn.useReactFlow)(),u=(0,ft.useCallback)(()=>{t(void 0),n(void 0)},[]),f=(0,ft.useCallback)(p=>{let g=p!=null?p:d();u();let h=Wc(g,jo,c);s.current.initialize(h)},[c,u,d]),m=(0,ft.useCallback)(()=>{setTimeout(()=>{f()},100)},[f]);(0,ft.useEffect)(()=>{a&&f(d())},[a,f,d]);let y=(0,ft.useCallback)((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),N=p.find(W=>W.type==="dimensions");if(x.length===0&&!N)return p;let b=Object.keys(jo),T=new Set,v=1/0,A=1/0,C=-1/0,P=-1/0;if(x.length>0)x.forEach(W=>{var de,re,ee,xe,Ce,Re;let oe=g.find(Je=>Je.id===W.id);if(!oe)return;T.add(oe.id);let le=c(oe.id);if(!le)return;let Z=le.parentId?c(le.parentId):void 0,ve=W.position.x+((de=Z==null?void 0:Z.internals.positionAbsolute.x)!=null?de:0),ye=W.position.y+((re=Z==null?void 0:Z.internals.positionAbsolute.y)!=null?re:0),Ie=(xe=(ee=oe.measured)==null?void 0:ee.width)!=null?xe:0,J=(Re=(Ce=oe.measured)==null?void 0:Ce.height)!=null?Re:0;v=Math.min(v,ve),A=Math.min(A,ye),C=Math.max(C,ve+Ie),P=Math.max(P,ye+J)}),N&&(b=["top","left"]);else if(N){let W=g.find(Ie=>Ie.id===N.id);if(!W)return p;T.add(W.id);let oe=c(W.id);if(!oe)return p;let le=oe.internals.positionAbsolute.x,Z=oe.internals.positionAbsolute.y,ve=(Y=(O=(G=N.dimensions)==null?void 0:G.width)!=null?O:(k=W.measured)==null?void 0:k.width)!=null?Y:0,ye=($=(X=(F=N.dimensions)==null?void 0:F.height)!=null?X:(U=W.measured)==null?void 0:U.height)!=null?$:0;v=le,A=Z,C=le+ve,P=Z+ye,b=["right","bottom"]}if(v===1/0)return p;let R={x:v,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}=Xc(s.current,Q,R,T,b),{deltaX:V,deltaY:D,snappedX:I,snappedY:B}=Uc(R,z,M);if(I||B){let W=x.some(le=>le.dragging),oe=!!(N!=null&&N.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)}),(N==null?void 0:N.id)===((te=x[0])==null?void 0:te.id)?N.dimensions&&(N.dimensions.width+=V):N&&!x.length&&N.dimensions&&(N.dimensions.width-=V)),B&&(x.forEach(le=>{le.position&&(le.position.y-=D)}),(N==null?void 0:N.id)===((ie=x[0])==null?void 0:ie.id)?N.dimensions&&(N.dimensions.height+=D):N&&!x.length&&N.dimensions&&(N.dimensions.height-=D))}return p},[l,c,r,i,t,n,u]),E=(0,ft.useCallback)(()=>(0,Kc.jsx)(qc,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:f,forceRebuildIndex:m,updateHelperLines:y,helperLineHorizontal:e,helperLineVertical:o,HelperLines:E}}var ls=require("@xyflow/react"),oo=require("react");var go=e=>new Map(e.map(t=>[t.id,t])),hr=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),Zc=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),Us=e=>e.some(t=>t.type==="START_EVENT"),Lo=(e,t)=>e==="START_EVENT"?!Us(t):!0,Jc=(e,t,o,n,r)=>{let i=go(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:hr(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Qc=(e,t,o,n,r)=>{let i=go(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:Zc(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Li=(e,t,o,n,r)=>{var c;let i=go(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:hr(e,n,r).filter(d=>{let u=i.get(d.target);return(u==null?void 0:u.type)!=="ANNOTATION"}).length>=2},jc=(e,t,o)=>{var a,s,l,c;let n=go(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"},ki=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SCRIPT"},ed=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SUBPROCESS"},yr=(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"},Ri=(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"},en=(e,t,o,n)=>{let r=go(t),i=r.get(e);return!i||i.type!=="TASK"?!1:Zc(e,o,n).some(s=>{let l=r.get(s.source);return(l==null?void 0:l.type)==="START_EVENT"})},xr=(e,t,o,n)=>{let r=go(t),i=r.get(e);return!i||i.type!=="TASK"?!1:hr(e,o,n).some(s=>{let l=r.get(s.target);return(l==null?void 0:l.type)==="END_EVENT"})},td=(e,t,o,n,r)=>{let i=go(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"?xr(t,o,n,r):(s==null?void 0:s.type)==="END_EVENT"&&(a==null?void 0:a.type)==="TASK"?en(e,o,n,r):!1},Di=(e,t,o)=>hr(e,t,o).length>0,Oi=(e,t,o,n,r)=>{let i=go(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:hr(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var od=(e,t,o,n,r)=>{var s,l;let i=go(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 Kg=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!od(e.sourceNodeId,e.targetNodeId,e.edges,e.nodes,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!Jc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!Qc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!Li(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!Oi(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:jc(e.sourceNodeId,e.targetNodeId,e.nodes),reason:"gateway_to_gateway_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&e.targetNodeType==="END_EVENT"),reason:"start_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&ed(e.targetNodeId,e.nodes)),reason:"start_event_to_subprocess_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&yr(e.targetNodeId,e.nodes)),reason:"start_event_to_service_task_not_allowed"}),e=>({isValid:!(yr(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:!(ki(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(Ri(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(en(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!td(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(xr(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(Di(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"})],$s=e=>{for(let t of Kg){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var qg=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:Li(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"gateway_limit_reached"})},{sourceTypes:["START_EVENT"],validate:e=>({shouldDisable:e.edges.some(o=>{if(o.source!==e.sourceNodeId)return!1;let n=e.nodes.find(r=>r.id===o.target);return(n==null?void 0:n.type)!=="ANNOTATION"})&&e.targetNodeType!=="ANNOTATION",reason:"start_event_limit_reached"})},{targetTypes:["START_EVENT"],validate:e=>({shouldDisable:Us(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:ki(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Ri(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:yr(e.sourceNodeId,e.nodes),reason:"service_task_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:en(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:xr(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Di(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Oi(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],nd=e=>{let t=qg.filter(o=>{let n=!o.sourceTypes||o.sourceTypes.includes(e.sourceNodeType),r=!o.targetTypes||o.targetTypes.includes(e.targetNodeType);return n&&r});for(let o of t){let n=o.validate(e);if(n.shouldDisable)return n}return{shouldDisable:!1}};var Vt=require("@xyflow/react");var qt=require("@produto-lecom/lecom-ui"),rd=require("lucide-react");var Mt=require("@xyflow/react");var Vi=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=(0,Mt.useReactFlow)(),{selectElements:r}=$t(),i=p=>{let g=o(),h=n(),x=(0,Mt.getIncomers)(p,g,h),N=(0,Mt.getOutgoers)(p,g,h),b=x.some(v=>v.type==="START_EVENT"),T=N.some(v=>v.type==="END_EVENT");return b?"start":T?"end":"between"},a=(p,g,h)=>{var b,T,v,A,C;if(!p)return;let x={type:p.type,variant:(b=p.data)==null?void 0:b.variant,attribute:(T=p.data)==null?void 0:T.attribute},N={id:p.id,position:i(p),label:(v=p.data)==null?void 0:v.label,node:x};return p.type==="TASK"&&((A=p.data)==null?void 0:A.variant)==="SUBPROCESS"?w(_({},N),{type:"sub_process"}):p.type==="TASK"&&((C=p.data)==null?void 0:C.variant)==="SERVICE_TASK"?w(_({},N),{type:"service_task"}):p.type==="GATEWAY"?w(_({},N),{type:"gateway",variant:s(p,g,h)}):w(_({},N),{type:"activity"})},s=(p,g,h)=>{if(p.type!=="GATEWAY")return;let x=(0,Mt.getIncomers)(p,g,h),N=!1,b=!1;if(x.forEach(T=>{var v,A;T.type==="TASK"&&(((v=T.data)==null?void 0:v.variant)==="SCRIPT"&&(N=!0),((A=T.data)==null?void 0:A.attribute)==="LOOP"&&(b=!0))}),N&&b)return"script_loop";if(N)return"script";if(b)return"loop"},l=(p,g,h)=>{var v,A,C,P,R;let x=e(p.source),N=e(p.target);if(!x||!N)return"simple";if((0,Mt.getOutgoers)(x,g,h).some(S=>S.type==="END_EVENT"))return"final";if(x.type==="GATEWAY")switch((v=x.data)==null?void 0:v.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(x.type==="TASK"){let S=(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(N.type==="TASK"&&((P=N.data)==null?void 0:P.variant)==="SUBPROCESS")return"to_sub_process";if(N.type==="TASK"&&((R=N.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 N(T,v,A=0){let C=a(T,g,h);if(C.depth=A,v.push(C),T.type==="TASK"){x.push([...v]),v.pop();return}let P=(0,Mt.getIncomers)(T,g,h);if(P.length)for(let R of P)N(R,v,A+1);v.pop()}let b=(0,Mt.getIncomers)(p,g,h);for(let T of b)N(T,[]);return x},d=(p,g,h)=>{let x=[];function N(T,v,A=0){let C=a(T,g,h);if(C.depth=A,v.push(C),T.type==="TASK"){x.push([...v]),v.pop();return}let P=(0,Mt.getOutgoers)(T,g,h);if(P.length)for(let R of P)N(R,v,A+1);v.pop()}let b=(0,Mt.getOutgoers)(p,g,h);for(let T of b)N(T,[]);return x},u=(p,g,h)=>(h=h.filter(N=>N.source===p.id),h.map(N=>{var v;let b=e(N.target),T;return b&&(T=a(b,g,h)),{id:N.id,type:"routing",variant:l(N,g,h),label:(v=N.data)==null?void 0:v.label,target:T}})),f=p=>{let g=e(p);if(!g)return;let h=o(),x=n(),N=a(g,h,x);return N.sources=c(g,h,x),N.targets=d(g,h,x),N.edgeTargets=u(g,h,x),g.type==="GATEWAY"&&(N.variant=s(g,h,x)),N},m=p=>{let g=t(p);if(!g)return;let h=o(),x=n(),N=l(g,h,x),T={id:g.id,type:"routing",variant:N,gatewayVariant:void 0},v=e(g.source);if(v){let C=a(v,h,x);T.source=C;let P=s(v,h,x);if(T.gatewayVariant=P,v.type==="TASK")T.sources=[[C]];else{let R=c(v,h,x);T.sources=R.length?R:[[C]]}}let A=e(g.target);if(A){let C=a(A,h,x);if(T.target=C,A.type==="TASK")T.targets=[[C]];else{let P=d(A,h,x);T.targets=P.length?P:[[C]]}}return T},y=p=>{let g=e(p);if(g)return f(g.id);let h=t(p);if(h)return m(h.id)};return{configureElement:p=>{let g=y(p);if(g)return r([p]),g},getConfigureElement:y,getNodeConfigure:f,getEdgeConfigure:m}};var tn=require("react/jsx-runtime"),Zg={node:"editor.toolbar.configure_node",edge:"editor.toolbar.configure_edge",gateway:"editor.toolbar.configure_gateway"},ko=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,qt.useTranslation)(),{onConfigureElement:n}=q(),{getConfigureElement:r}=Vi();return(0,tn.jsxs)(qt.Tooltip,{children:[(0,tn.jsx)(qt.TooltipTrigger,{asChild:!0,children:(0,tn.jsx)(qt.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let a=r(e);a&&(n==null||n(a))},children:(0,tn.jsx)(rd.Settings,{size:16})})}),(0,tn.jsx)(qt.TooltipContent,{color:"black",children:o(Zg[t])})]})};var Zt=require("@produto-lecom/lecom-ui"),sd=require("@xyflow/react"),ad=require("lucide-react");var id=require("@produto-lecom/lecom-ui");function lt(){let{toast:e}=Ln(),{toast:t}=(0,id.useNotificationToast)();return{toast:e||t}}var on=require("react/jsx-runtime"),Hi=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,Zt.useTranslation)(),{toast:n}=lt(),{deleteElements:r,getNodes:i}=(0,sd.useReactFlow)();return(0,on.jsxs)(Zt.Tooltip,{children:[(0,on.jsx)(Zt.TooltipTrigger,{asChild:!0,children:(0,on.jsx)(Zt.Button,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{if(t==="node"){let s=i(),l=s.find(c=>c.id===e);if((l==null?void 0:l.type)==="LANE"&&s.some(d=>d.parentId===e)){n({variant:"error",title:o("validation.errors.title"),content:o("editor.toolbar.delete_pool_lane_error")});return}r({nodes:[{id:e}]})}else r({edges:[{id:e}]})},children:(0,on.jsx)(ad.TrashIcon,{size:16})})}),(0,on.jsx)(Zt.TooltipContent,{color:"black",children:o("editor.toolbar.delete")})]})};var Jt=require("@produto-lecom/lecom-ui"),ld=require("lucide-react"),cd=require("react"),nn=require("react/jsx-runtime"),kn=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=(0,Jt.useTranslation)(),r=(0,cd.useCallback)(i=>{i.stopPropagation();let a=document.querySelectorAll(`.react-flow__handle.source[data-nodeid="${e}"]`);if(a.length===0)return;let s=Array.from(a).reduce((f,m)=>{let y=f.getBoundingClientRect(),E=m.getBoundingClientRect(),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?m:f}),l=s.getBoundingClientRect(),c=l.left+l.width/2,d=l.top+l.height/2,u=new MouseEvent("mousedown",{clientX:c,clientY:d,bubbles:!0,cancelable:!0});s.dispatchEvent(u)},[e]);return(0,nn.jsxs)(Jt.Tooltip,{children:[(0,nn.jsx)(Jt.TooltipTrigger,{asChild:!0,children:(0,nn.jsx)(Jt.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:(0,nn.jsx)(ld.MoveUpRightIcon,{size:16})})}),(0,nn.jsx)(Jt.TooltipContent,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};var Rn=require("react/jsx-runtime"),Dn=i=>{var a=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=a,r=Ut(a,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:s}=q(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d,isToEndEvent:u}=jr(o,n),f=!l&&!c&&!d&&!u,m=[{component:(0,Rn.jsx)(Hi,{elementId:e,elementType:"edge"})}],y=()=>s==="view"?f?[{component:(0,Rn.jsx)(ko,{elementId:e,elementType:"edge"})}]:[]:f?[{component:(0,Rn.jsx)(ko,{elementId:e,elementType:"edge"})},...m]:m,p=(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(!(p.length===0||s==="readonly"))return(0,Rn.jsx)("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)=>(0,Rn.jsx)("div",{children:g.component},h))}))};var dd=require("@xyflow/react"),ud=require("react");var Ks=require("react/jsx-runtime"),Qt=12,On=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:a}=(0,dd.useViewport)(),s=1/a,l=(0,ud.useMemo)(()=>t===n?{bottom:`${Qt}px`,transform:"translateX(-50%)"}:e===o?{left:`${Qt}px`,transform:r?"translateY(-100%)":"translateY(-50%)"}:n>t&&o>e?{left:`${Qt}px`,bottom:`${Qt}px`}:n>t&&o<e?{right:`${Qt}px`,bottom:`${Qt}px`}:t>n&&o>e?{right:`${Qt}px`,bottom:`${Qt}px`}:{left:`${Qt}px`,bottom:`${Qt}px`},[e,t,o,n,r]);return(0,Ks.jsx)("div",{style:{transform:`scale(${s})`},children:(0,Ks.jsx)("div",{className:"absolute pointer-events-auto",style:_({},l),children:i})})};var mt=require("react/jsx-runtime"),Vn={type:"ANNOTATION_EDGE",reconnectable:!0},pd=({id:e,source:t,target:o,selected:n,data:r})=>{let{isMultipleSelection:i,isReadOnly:a,edgeHighlight:s}=q(),{zoom:l}=(0,Vt.useViewport)(),c=(0,Vt.useInternalNode)(t),d=(0,Vt.useInternalNode)(o);if(!c||!d)return null;let{sx:u,sy:f,tx:m,ty:y}=An(c,d),[E,p,g]=(0,Vt.getStraightPath)({sourceX:u,sourceY:f,targetX:m,targetY:y}),h=s&&(n||(c==null?void 0:c.selected)||(d==null?void 0:d.selected));return(0,mt.jsx)(mt.Fragment,{children:(0,mt.jsxs)("g",{className:H("group bpmn-edge",{"is-highlighted":h}),children:[(0,mt.jsx)("path",{d:E,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/l),style:{pointerEvents:"stroke",cursor:"pointer"}}),(0,mt.jsxs)("g",{className:H("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!a,"text-blue-500 group-hover:text-blue-600":h}),children:[(0,mt.jsx)(Vt.BaseEdge,{id:e,path:E,interactionWidth:0,strokeDasharray:4,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":r==null?void 0:r.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":h&&!(r!=null&&r.hasError)})}),(0,mt.jsx)(Vt.EdgeLabelRenderer,{children:(0,mt.jsx)("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&&(0,mt.jsx)(On,{sx:u,sy:f,tx:m,ty:y,children:(0,mt.jsx)(Dn,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})})})]})]})})};var et=require("react"),Me=require("@xyflow/react");var Ht=require("react");var Zs=require("react/jsx-runtime"),qs=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,fd=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Escape","Shift"],je=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:a,onBlur:s,onInput:l,onInvalidFirstCharacter:c,skipFirstCharValidation:d})=>{let u=(0,Ht.useRef)(null),f=(0,Ht.useRef)(null),[m,y]=(0,Ht.useState)(!1);(0,Ht.useEffect)(()=>()=>{f.current&&clearTimeout(f.current)},[]),(0,Ht.useEffect)(()=>{y(i!=null?i:!1)},[i]),(0,Ht.useEffect)(()=>{if(m&&u.current){u.current.focus();let b=document.createRange();b.selectNodeContents(u.current);let T=window.getSelection();T&&(T.removeAllRanges(),T.addRange(b))}},[m]);let E=(0,Ht.useCallback)(()=>{f.current||(c==null||c(),f.current=setTimeout(()=>{f.current=null},500))},[c]),p=b=>{b.stopPropagation(),m||y(!0)},g=b=>{let T=b.currentTarget.innerText.replace(/\n$/,""),v=t&&T.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=T.length===0||P&&C.length===T.length;if(!d&&Q&&!qs.test(b.key)&&!fd.includes(b.key)&&!R){b.preventDefault(),E();return}v&&!P&&(fd.includes(b.key)||S||L||K||j||b.preventDefault())},h=b=>{b.preventDefault();let T=b.clipboardData.getData("text/plain").replace(/\r\n/g,`
2
2
  `).replace(/\r/g,`
3
- `),v=b.currentTarget.innerText.replace(/\n$/,""),A=window.getSelection();if(!A||A.rangeCount===0)return;let C=A.toString(),P=v.length-C.length,R=t?Math.max(0,t-P):1/0;if(R<=0&&C.length===0)return;let S=T;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&&!Zs.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 T=b.currentTarget,v=T.innerText.replace(/\n$/,"");if(!d&&v.length>0&&!Zs.test(v[0])){let A=v.slice(1);if(T.innerText=A,A.length>0&&T.firstChild){let C=document.createRange(),P=window.getSelection();C.setStart(T.firstChild,0),C.collapse(!0),P==null||P.removeAllRanges(),P==null||P.addRange(C)}E(),l==null||l(A);return}l==null||l(v)},N=b=>{y(!1);let T=b.currentTarget.innerText.replace(/\r\n/g,`
3
+ `),v=b.currentTarget.innerText.replace(/\n$/,""),A=window.getSelection();if(!A||A.rangeCount===0)return;let C=A.toString(),P=v.length-C.length,R=t?Math.max(0,t-P):1/0;if(R<=0&&C.length===0)return;let S=T;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&&!qs.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 T=b.currentTarget,v=T.innerText.replace(/\n$/,"");if(!d&&v.length>0&&!qs.test(v[0])){let A=v.slice(1);if(T.innerText=A,A.length>0&&T.firstChild){let C=document.createRange(),P=window.getSelection();C.setStart(T.firstChild,0),C.collapse(!0),P==null||P.removeAllRanges(),P==null||P.addRange(C)}E(),l==null||l(A);return}l==null||l(v)},N=b=>{y(!1);let T=b.currentTarget.innerText.replace(/\r\n/g,`
4
4
  `).replace(/\r/g,`
5
- `).trim();t&&T.length>t&&(T=T.substring(0,t)),b.currentTarget.innerText=T,s==null||s(),T!==e&&(a==null||a(T))};return(0,Js.jsx)("div",{className:H("flex-1 p-2 self-stretch flex items-center justify-center border border-transparent overflow-hidden text-ellipsis body-medium-400 text-center rounded-sm",{"border border-dashed border-grey-400 bg-white shadow-md":m,"bg-white":e.length>0},n),style:o,onDoubleClick:p,children:(0,Js.jsx)("div",{ref:u,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:N,children:e})})};var Qg=require("@xyflow/react");var _e=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,Hn=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),Bi=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),jg=(e,t,o)=>{let n=o.x-t.x,r=o.y-t.y,i=n*n+r*r;if(i===0)return Hn(e,t);let a=Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*r)/i));return Hn(e,{x:t.x+a*n,y:t.y+a*r})},gd=(e,t)=>{let o=1/0;for(let n=0;n<t.length-1;n++)o=Math.min(o,jg(e,t[n],t[n+1]));return o};var Er=require("@xyflow/react");var Ro={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15,MAX_LABEL_DISTANCE:80};var{TOLERANCE:ce}=Ro;function eh(e,t,o){return _e(e,t,"x",ce)&&_e(t,o,"x",ce)&&_e(e,o,"x",ce)}function th(e,t,o){return _e(e,t,"y",ce)&&_e(t,o,"y",ce)&&_e(e,o,"y",ce)}function oh(e,t,o){if(!eh(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 rh(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 hd(e){if(e.length<=2)return e;let t=[e[0]];for(let o=1;o<e.length-1;o++){let n=t[t.length-1],r=e[o],i=e[o+1];_e(n,r,"x",ce)&&_e(r,i,"x",ce)||_e(n,r,"y",ce)&&_e(r,i,"y",ce)||t.push(r)}return t.push(e[e.length-1]),t}function zi(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(oh(r,i,a)||nh(r,i,a)){t.splice(n,1),o=!0;break}}}return t}function yd(e){let t=zi(hd([...e]));return t=ih(t),zi(hd(t))}function Yi(e){switch(e){case Er.Position.Left:return{x:-1,y:0};case Er.Position.Right:return{x:1,y:0};case Er.Position.Top:return{x:0,y:-1};case Er.Position.Bottom:return{x:0,y:1};default:return{x:0,y:0}}}function xd(e,t,o,n){let r=Ro.OFFSET,i=Ro.OFFSET;if(t.x===-n.x&&t.y===-n.y)if(t.x!==0){let a=(o.x-e.x)*t.x;a>0&&a<2*Ro.OFFSET&&(r=a/2,i=a/2)}else{let a=(o.y-e.y)*t.y;a>0&&a<2*Ro.OFFSET&&(r=a/2,i=a/2)}return{sourceOffset:r,targetOffset:i}}function sh(e,t,o,n,r,i,a=0){let s=Yi(r),l=Yi(i),c=s.x===0?a:0,d=s.y===0?a:0,u=l.x===0?a:0,f=l.y===0?a:0,m={x:e+c,y:t+d},y={x:o+u,y:n+f},{sourceOffset:E,targetOffset:p}=xd(m,s,y,l),g={x:m.x+s.x*E,y:m.y+s.y*E},h={x:y.x+l.x*p,y:y.y+l.y*p},x=rh(g,s,h,l),N=[m,g,...x,h,y],b=yd(N);if(b.length===2&&Fi(m,y)>ce){let T=_e(m,g,"x",ce)&&_e(g,h,"x",ce)&&_e(h,y,"x",ce),v=_e(m,g,"y",ce)&&_e(g,h,"y",ce)&&_e(h,y,"y",ce);if(T||v){let A=v&&(h.x-g.x)*s.x<0,C=T&&(h.y-g.y)*s.y<0;if(!A&&!C)return zi([m,g,h,y])}}return b}function Wi(e,t,o,n,r,i,a,s=0){if(!(a!=null&&a.length))return sh(e,t,o,n,r,i,s);let l=Yi(r),c=Yi(i),d=l.x===0?s:0,u=l.y===0?s:0,f=c.x===0?s:0,m=c.y===0?s:0,y={x:e+d,y:t+u},E={x:o+f,y:n+m},{sourceOffset:p,targetOffset:g}=xd(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},N=[...a],b=N[0],T=l.y===0;T&&Math.abs(y.y-b.y)>ce?N.unshift({x:b.x,y:y.y}):!T&&Math.abs(y.x-b.x)>ce&&N.unshift({x:y.x,y:b.y});let v=N[N.length-1],A=c.y===0,C=[];(Math.abs(v.x-x.x)>ce||Math.abs(v.y-x.y)>ce)&&(A?C.push({x:x.x,y:v.y}):C.push({x:v.x,y:x.y})),C.push(x);let P=[y,...N,...C,E],R=yd(P);if(R.length===2&&Fi(y,E)>ce){let S=_e(y,h,"x",ce)&&_e(h,x,"x",ce)&&_e(x,E,"x",ce),L=_e(y,h,"y",ce)&&_e(h,x,"y",ce)&&_e(x,E,"y",ce);if(S||L){let K=L&&(x.x-h.x)*l.x<0,j=S&&(x.y-h.y)*l.y<0;if(!K&&!j)return zi([y,h,x,E])}}return R}var Fi=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function ah(e,t,o){return _e(e,t,"x",ce)&&_e(t,o,"x",ce)||_e(e,t,"y",ce)&&_e(t,o,"y",ce)}function lh(e,t,o,n){if(ah(e,t,o))return`L${t.x} ${t.y}`;let r=Fi(e,t),i=Fi(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},f={x:c/i,y:d/i},m={x:t.x+u.x*a,y:t.y+u.y*a},y={x:t.x+f.x*a,y:t.y+f.y*a},E=-u.x,p=-u.y,g=f.x,h=f.y,N=E*h-p*g>0?1:0;return`L${m.x} ${m.y}A${a} ${a} 0 0 ${N} ${y.x} ${y.y}`}var Ed=(e,t=5)=>e.length<2?"":e.reduce((o,n,r)=>{let i="";return r>0&&r<e.length-1?i=lh(e[r-1],n,e[r+1],t):i=`${r===0?"M":"L"}${n.x} ${n.y}`,o+=i,o},"");var Se=require("react"),Xi=require("@xyflow/react");var ch=50,_d=.1,dh=.6,Ui=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:a,getNodes:s,getEdge:l,screenToFlowPosition:c}=(0,Xi.useReactFlow)(),{setIsDragging:d,setReconnectingEdgeId:u}=q(),f=(0,Xi.useStore)(D=>D.isValidConnection),[m,y]=(0,Se.useState)(null),[E,p]=(0,Se.useState)(null),[g,h]=(0,Se.useState)(null),[x,N]=(0,Se.useState)(null),[b,T]=(0,Se.useState)(null),[v,A]=(0,Se.useState)(!1),C=(0,Se.useRef)(null),P=(0,Se.useRef)(null),R=(0,Se.useRef)(null),S=(0,Se.useRef)(t),L=(0,Se.useRef)(o);(0,Se.useEffect)(()=>{S.current=t,L.current=o},[t,o]),(0,Se.useEffect)(()=>{C.current=m},[m]),(0,Se.useEffect)(()=>{P.current=b},[b]);let K=(0,Se.useCallback)(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=(0,Se.useCallback)(D=>{var O,Y,F,U,X,$;let I=s(),B=null,G=ch,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)),ve=Math.max(ie.y-D.y,0,D.y-(ie.y+oe)),ye=Math.sqrt(Z*Z+ve*ve);ye<G&&(G=ye,B=te.id)}return B},[s,K,e]),Q=(0,Se.useCallback)((D,I)=>{var Z,ve,ye,Ie,J,de;let B=a(D);if(!B)return null;let G=K(D),k=(ye=(ve=(Z=B.measured)==null?void 0:Z.width)!=null?ve:B.width)!=null?ye:0,O=(de=(J=(Ie=B.measured)==null?void 0:Ie.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,xe])=>xe<re[1]?[ee,xe]:re,["right",$.right])[0],ie=R.current;if(ie&&ie!==te){let re=$[te],ee=$[ie],xe=Math.abs(ee-re),Ce=Math.min(Math.abs(ee),Math.abs(re));xe<Ce*dh&&(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)<_d&&(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)<_d&&(ee=.5),le=ee,oe={x:G.x+le*k,y:W==="bottom"?G.y+O:G.y}}return{side:W,snapPosition:oe,offset:le}},[a,K]),z=(0,Se.useCallback)(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=f==null?void 0:f(ie))!=null?X:!0;A(W)}else R.current=null,A(!1);N(O),T(Y),p(k)},[j,Q,l,e,c,f]),M=(0,Se.useCallback)(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=f==null?void 0:f(oe))==null||X)&&i(le=>le.map(Z=>{var ve,ye;return Z.id===e?w(_({},Z),{source:oe.source,target:oe.target,sourceHandle:oe.sourceHandle,targetHandle:oe.targetHandle,data:w(_({},Z.data),{points:void 0,sourceOffset:I==="source"?ie:(ve=Z.data)==null?void 0:ve.sourceOffset,targetOffset:I==="target"?ie:(ye=Z.data)==null?void 0:ye.targetOffset})}):Z}))}y(null),p(null),h(null),N(null),T(null),d(!1),A(!1),u(null),R.current=null,document.removeEventListener("mouseup",M),document.removeEventListener("mousemove",z);let k=Qt.get(n);k==null||k.clearReconnectingEdge()},[e,j,Q,l,i,n,z,f,c,d,u]),V=(0,Se.useCallback)((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=Qt.get(n);B==null||B.setReconnectingEdge(e),document.addEventListener("mousemove",z),document.addEventListener("mouseup",M)},[r,e,n,z,M,u,i]);return(0,Se.useEffect)(()=>()=>{if(C.current){document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",M),u(null);let D=Qt.get(n);D==null||D.clearReconnectingEdge()}},[n,z,M,u]),{reconnectingHandle:m,cursorPosition:E,hoveredNodeId:g,reconnectingSide:x,reconnectingOffset:b,isValidReconnection:v,handleReconnectStart:V}};var ge=require("react/jsx-runtime"),Pt={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:Me.MarkerType.ArrowClosed},markerEnd:{type:Me.MarkerType.Arrow},data:{label:""}},{MOVE_THRESHOLD:$i,MIN_SEGMENT_LENGTH:uh,PARALLEL_OFFSET:bd,MAX_LABEL_DISTANCE:ph}=Ro;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 u=d.findIndex(m=>m.id===e);if(u<=0)return 0;let f=(d.length-1)/2;return(u-f)*bd}let l=s.findIndex(d=>d.id===e),c=(s.length-1)/2;return(l-c)*bd}var Td=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var $,te,ie,W,oe,le,Z,ve,ye,Ie;let{zoom:c}=(0,Me.useViewport)(),{updateEdgeData:d}=(0,Me.useReactFlow)(),u=(0,Me.useEdges)(),f=(0,Me.useNodes)(),{isMultipleSelection:m,isReadOnly:y,mode:E,instanceId:p,edgeHighlight:g}=q(),[h,x]=(0,et.useState)(!1),[N,b]=(0,et.useState)(null),T=(0,et.useRef)(null),v=(0,et.useRef)(n==null?void 0:n.labelOffset),A=(0,et.useRef)(null),C=E!=="edit",{reconnectingHandle:P,cursorPosition:R,hoveredNodeId:S,reconnectingSide:L,isValidReconnection:K,handleReconnectStart:j}=Ui({edgeId:e,source:t,target:o,instanceId:p,isReadOnly:C}),Q=(0,Me.useInternalNode)(t),z=(0,Me.useInternalNode)(o),{sx:M,sy:V,tx:D,ty:I,sourcePos:B,targetPos:G}=(0,et.useMemo)(()=>{var Ft,Wt;let J=Q&&z?An(Q,z):{sx:0,sy:0,tx:0,ty:0,sourcePos:Me.Position.Right,targetPos:Me.Position.Left},de=s?i:J.sourcePos,re=l?a:J.targetPos,ee=(ut,Ee,he)=>{var rt,Xt,bo,lo,co,ba;let{x:pe,y:De}=ut.internals.positionAbsolute,pt=(bo=(Xt=(rt=ut.measured)==null?void 0:rt.width)!=null?Xt:ut.width)!=null?bo:0,At=(ba=(co=(lo=ut.measured)==null?void 0:lo.height)!=null?co:ut.height)!=null?ba:0;switch(Ee){case Me.Position.Top:return{x:pe+pt*he,y:De};case Me.Position.Bottom:return{x:pe+pt*he,y:De+At};case Me.Position.Left:return{x:pe,y:De+At*he};case Me.Position.Right:return{x:pe+pt,y:De+At*he};default:return{x:pe+pt/2,y:De+At/2}}},xe=(Ft=n==null?void 0:n.sourceOffset)!=null?Ft:.5,Ce=(Wt=n==null?void 0:n.targetOffset)!=null?Wt:.5,Re=Q?ee(Q,de,xe).x:J.sx,Je=Q?ee(Q,de,xe).y:J.sy,wt=z?ee(z,re,Ce).x:J.tx,ao=z?ee(z,re,Ce).y:J.ty;return P==="source"&&R?(Re=R.x,Je=R.y,L&&(de=L)):P==="target"&&R&&(wt=R.x,ao=R.y,L&&(re=L)),{sx:Re,sy:Je,tx:wt,ty:ao,sourcePos:de,targetPos:re}},[Q,z,s,l,i,a,P,R,L,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);(0,et.useEffect)(()=>{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)>$i||Math.abs(V-J.sy)>$i||Math.abs(D-J.tx)>$i||Math.abs(I-J.ty)>$i||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=(0,et.useMemo)(()=>{let J=fh(e,t,o,u,f);return Wi(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,f,e,t,o]),O=(0,et.useMemo)(()=>{if(k.length<2)return Bi({x:M,y:V},{x:D,y:I});let J=0;for(let ee=0;ee<k.length-1;ee++)J+=Hn(k[ee],k[ee+1]);let de=J/2,re=0;for(let ee=0;ee<k.length-1;ee++){let xe=Hn(k[ee],k[ee+1]);if(re+xe>=de){let Ce=(de-re)/xe,Re=k[ee],Je=k[ee+1];return{x:Re.x+(Je.x-Re.x)*Ce,y:Re.y+(Je.y-Re.y)*Ce}}re+=xe}return Bi({x:M,y:V},{x:D,y:I})},[k,M,V,D,I]),Y=(0,et.useCallback)((J,de)=>{if(E!=="edit"||de.button!==0)return;de.stopPropagation(),de.preventDefault();let re=k[J],ee=k[J+1],xe=_e(re,ee,"y"),Ce=xe?re.y:re.x,Re=[...k],Je=Re.length,wt=J,ao=J+1;b(J);let Ft=ut=>{let Ee=Ce+(xe?ut.clientY-de.clientY:ut.clientX-de.clientX)/c;T.current=xe?{x:(re.x+ee.x)/2,y:Ee}:{x:Ee,y:(re.y+ee.y)/2};let he=[];for(let pe=1;pe<Je-1;pe++){let De=Re[pe];pe===wt||pe===ao?xe?he.push({x:De.x,y:Ee}):he.push({x:Ee,y:De.y}):he.push(_({},De))}d(e,w(_({},n),{points:he}))},Wt=()=>{b(null),T.current=null,document.removeEventListener("mousemove",Ft),document.removeEventListener("mouseup",Wt)};document.addEventListener("mousemove",Ft),document.addEventListener("mouseup",Wt)},[E,k,c,n,e,d]),F=(0,et.useCallback)(J=>{var Ft,Wt,ut,Ee,he;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=(ut=(Wt=n==null?void 0:n.labelOffset)==null?void 0:Wt.x)!=null?ut:0,xe=(he=(Ee=n==null?void 0:n.labelOffset)==null?void 0:Ee.y)!=null?he:0,Ce=[...k],Re={x:O.x,y:O.y},Je=!1,wt=pe=>{let De=(pe.clientX-de)/c,pt=(pe.clientY-re)/c;if(!Je&&Math.abs(De)<3&&Math.abs(pt)<3)return;Je=!0;let At={x:ee+De,y:xe+pt};v.current=At,d(e,w(_({},n),{labelOffset:At}))},ao=()=>{document.removeEventListener("mousemove",wt),document.removeEventListener("mouseup",ao);let pe=v.current;if(!pe)return;let De={x:Re.x+pe.x,y:Re.y+pe.y};gd(De,Ce)>ph&&(v.current=void 0,d(e,w(_({},n),{labelOffset:void 0})))};document.addEventListener("mousemove",wt),document.addEventListener("mouseup",ao)},[h,C,c,n,e,d,k,O]);if(!Q||!z)return null;let U=Ed(k),X=g&&(r||Q.selected||z.selected);return(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsxs)("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":X}),onDoubleClick:()=>!C&&x(!0),children:[(0,ge.jsx)("path",{d:U,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),className:H({"nopan nodrag":!h&&!C&&!!(($=n==null?void 0:n.label)!=null&&$.trim())}),style:{pointerEvents:"stroke",cursor:!h&&!C&&((te=n==null?void 0:n.label)!=null&&te.trim())?"move":"pointer"},onMouseDown:F}),(0,ge.jsxs)("g",{className:H("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!y,"text-blue-500 group-hover:text-blue-600":X}),children:[(0,ge.jsx)(Me.BaseEdge,{id:e,path:U,interactionWidth:0,markerEnd:`url(#${X?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75",{"group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]":!y,"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||P&&S&&!K,"stroke-green-500":P&&S&&K,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":X&&!(n!=null&&n.hasError)&&!P})}),r&&!m&&!C&&(0,ge.jsx)("g",{children:k.slice(0,-1).map((J,de)=>{let re=k[de+1];if(de===0||de===k.length-2||Hn(J,re)<uh)return null;let ee=_e(J,re,"y"),xe=N===de,Ce=xe&&T.current?T.current:Bi(J,re);return(0,ge.jsxs)("g",{children:[(0,ge.jsx)("line",{x1:J.x,y1:J.y,x2:re.x,y2:re.y,stroke:"transparent",strokeWidth:20/c,className:H("cursor-pointer",{"cursor-ns-resize":ee,"cursor-ew-resize":!ee}),onMouseDown:Re=>Y(de,Re)}),(0,ge.jsx)("circle",{cx:Ce.x,cy:Ce.y,r:4/c,fill:xe?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ge.jsx)("circle",{cx:Ce.x,cy:Ce.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:xe?.6:.3,className:"pointer-events-none"})]},de)})})]})]}),(0,ge.jsxs)(Me.EdgeLabelRenderer,{children:[(0,ge.jsx)("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${O.x}px, ${O.y}px)`},children:r&&!m&&(0,ge.jsx)(On,{sx:M,sy:V,tx:D,ty:I,hasLabel:!!((ie=n==null?void 0:n.label)!=null&&ie.trim()),children:(0,ge.jsx)(Dn,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:Q,targetNode:z})})}),(h||((W=n==null?void 0:n.label)==null?void 0:W.trim()))&&(0,ge.jsx)("div",{className:H("absolute nodrag nopan",!h&&!C&&((oe=n==null?void 0:n.label)!=null&&oe.trim())?"z-[10001] pointer-events-auto":"z-[3000] pointer-events-none"),style:{transform:`translate(-50%, -50%) translate(${O.x+((Z=(le=n==null?void 0:n.labelOffset)==null?void 0:le.x)!=null?Z:0)}px, ${O.y+((ye=(ve=n==null?void 0:n.labelOffset)==null?void 0:ve.y)!=null?ye:0)}px)`,cursor:!h&&!C&&((Ie=n==null?void 0:n.label)!=null&&Ie.trim())?"move":void 0},onMouseDown:!h&&!C?F:void 0,onDoubleClick:J=>{C||(J.stopPropagation(),x(!0))},children:(0,ge.jsx)(je,{value:n==null?void 0:n.label,className:H("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":h,"pointer-events-none":!h}),isEditing:h,onBlur:()=>x(!1),onChange:J=>d(e,{label:J.trim()})})}),r&&!m&&!C&&(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsx)("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${k[0].x}px, ${k[0].y}px)`},children:(0,ge.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:P==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:P==="source"?.6:.3,className:"pointer-events-none"}),(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!P||P!=="source","cursor-not-allowed":P==="source"&&S&&!K,"cursor-grabbing":P==="source"&&(!S||K)}),onMouseDown:J=>j("source",J.nativeEvent)})]})}),(0,ge.jsx)("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${k[k.length-1].x}px, ${k[k.length-1].y}px)`},children:(0,ge.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:P==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:P==="target"?.6:.3,className:"pointer-events-none"}),(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!P||P!=="target","cursor-not-allowed":P==="target"&&S&&!K,"cursor-grabbing":P==="target"&&(!S||K)}),onMouseDown:J=>j("target",J.nativeEvent)})]})})]})]})]})};var jt=require("@xyflow/react"),mh={right:jt.Position.Right,left:jt.Position.Left,top:jt.Position.Top,bottom:jt.Position.Bottom},Ki=e=>{var t;return(t=mh[e!=null?e:""])!=null?t:jt.Position.Right},Qs=(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(Ki(t)){case jt.Position.Right:return{x:n+i,y:r+a*o};case jt.Position.Left:return{x:n,y:r+a*o};case jt.Position.Top:return{x:n+i*o,y:r};case jt.Position.Bottom:return{x:n+i*o,y:r+a};default:return{x:n+i/2,y:r+a/2}}},vd=(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((f,m)=>{let y=Math.hypot(t-f.x,o-f.y);return Math.hypot(t-m.x,o-m.y)<y?m:f}).id};var Lu=require("use-debounce");var Pu=require("@xyflow/react"),ua=require("react");var _r=(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))(_r||{});var br=1,Nd=e=>`<mxGraphModel>
5
+ `).trim();t&&T.length>t&&(T=T.substring(0,t)),b.currentTarget.innerText=T,s==null||s(),T!==e&&(a==null||a(T))};return(0,Zs.jsx)("div",{className:H("flex-1 p-2 self-stretch flex items-center justify-center border border-transparent overflow-hidden text-ellipsis body-medium-400 text-center rounded-sm",{"border border-dashed border-grey-400 bg-white shadow-md":m,"bg-white":e.length>0},n),style:o,onDoubleClick:p,children:(0,Zs.jsx)("div",{ref:u,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:N,children:e})})};var Jg=require("@xyflow/react");var _e=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,Hn=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),Gi=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),Qg=(e,t,o)=>{let n=o.x-t.x,r=o.y-t.y,i=n*n+r*r;if(i===0)return Hn(e,t);let a=Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*r)/i));return Hn(e,{x:t.x+a*n,y:t.y+a*r})},md=(e,t)=>{let o=1/0;for(let n=0;n<t.length-1;n++)o=Math.min(o,Qg(e,t[n],t[n+1]));return o};var Er=require("@xyflow/react");var Ro={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15,MAX_LABEL_DISTANCE:80};var{TOLERANCE:ce}=Ro;function jg(e,t,o){return _e(e,t,"x",ce)&&_e(t,o,"x",ce)&&_e(e,o,"x",ce)}function eh(e,t,o){return _e(e,t,"y",ce)&&_e(t,o,"y",ce)&&_e(e,o,"y",ce)}function th(e,t,o){if(!jg(e,t,o))return!1;let n=t.y-e.y,r=o.y-t.y;return Math.abs(n)<ce||Math.abs(r)<ce?!1:n*r<0}function oh(e,t,o){if(!eh(e,t,o))return!1;let n=t.x-e.x,r=o.x-t.x;return Math.abs(n)<ce||Math.abs(r)<ce?!1:n*r<0}function nh(e,t,o,n){let r=t.x!==0,i=t.x===-n.x&&t.y===-n.y,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 gd(e){if(e.length<=2)return e;let t=[e[0]];for(let o=1;o<e.length-1;o++){let n=t[t.length-1],r=e[o],i=e[o+1];_e(n,r,"x",ce)&&_e(r,i,"x",ce)||_e(n,r,"y",ce)&&_e(r,i,"y",ce)||t.push(r)}return t.push(e[e.length-1]),t}function Bi(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 rh(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(th(r,i,a)||oh(r,i,a)){t.splice(n,1),o=!0;break}}}return t}function hd(e){let t=Bi(gd([...e]));return t=rh(t),Bi(gd(t))}function zi(e){switch(e){case Er.Position.Left:return{x:-1,y:0};case Er.Position.Right:return{x:1,y:0};case Er.Position.Top:return{x:0,y:-1};case Er.Position.Bottom:return{x:0,y:1};default:return{x:0,y:0}}}function yd(e,t,o,n){let r=Ro.OFFSET,i=Ro.OFFSET;if(t.x===-n.x&&t.y===-n.y)if(t.x!==0){let a=(o.x-e.x)*t.x;a>0&&a<2*Ro.OFFSET&&(r=a/2,i=a/2)}else{let a=(o.y-e.y)*t.y;a>0&&a<2*Ro.OFFSET&&(r=a/2,i=a/2)}return{sourceOffset:r,targetOffset:i}}function ih(e,t,o,n,r,i,a=0){let s=zi(r),l=zi(i),c=s.x===0?a:0,d=s.y===0?a:0,u=l.x===0?a:0,f=l.y===0?a:0,m={x:e+c,y:t+d},y={x:o+u,y:n+f},{sourceOffset:E,targetOffset:p}=yd(m,s,y,l),g={x:m.x+s.x*E,y:m.y+s.y*E},h={x:y.x+l.x*p,y:y.y+l.y*p},x=nh(g,s,h,l),N=[m,g,...x,h,y],b=hd(N);if(b.length===2&&Yi(m,y)>ce){let T=_e(m,g,"x",ce)&&_e(g,h,"x",ce)&&_e(h,y,"x",ce),v=_e(m,g,"y",ce)&&_e(g,h,"y",ce)&&_e(h,y,"y",ce);if(T||v){let A=v&&(h.x-g.x)*s.x<0,C=T&&(h.y-g.y)*s.y<0;if(!A&&!C)return Bi([m,g,h,y])}}return b}function Fi(e,t,o,n,r,i,a,s=0){if(!(a!=null&&a.length))return ih(e,t,o,n,r,i,s);let l=zi(r),c=zi(i),d=l.x===0?s:0,u=l.y===0?s:0,f=c.x===0?s:0,m=c.y===0?s:0,y={x:e+d,y:t+u},E={x:o+f,y:n+m},{sourceOffset:p,targetOffset:g}=yd(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},N=[...a],b=N[0],T=l.y===0;T&&Math.abs(y.y-b.y)>ce?N.unshift({x:b.x,y:y.y}):!T&&Math.abs(y.x-b.x)>ce&&N.unshift({x:y.x,y:b.y});let v=N[N.length-1],A=c.y===0,C=[];(Math.abs(v.x-x.x)>ce||Math.abs(v.y-x.y)>ce)&&(A?C.push({x:x.x,y:v.y}):C.push({x:v.x,y:x.y})),C.push(x);let P=[y,...N,...C,E],R=hd(P);if(R.length===2&&Yi(y,E)>ce){let S=_e(y,h,"x",ce)&&_e(h,x,"x",ce)&&_e(x,E,"x",ce),L=_e(y,h,"y",ce)&&_e(h,x,"y",ce)&&_e(x,E,"y",ce);if(S||L){let K=L&&(x.x-h.x)*l.x<0,j=S&&(x.y-h.y)*l.y<0;if(!K&&!j)return Bi([y,h,x,E])}}return R}var Yi=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function sh(e,t,o){return _e(e,t,"x",ce)&&_e(t,o,"x",ce)||_e(e,t,"y",ce)&&_e(t,o,"y",ce)}function ah(e,t,o,n){if(sh(e,t,o))return`L${t.x} ${t.y}`;let r=Yi(e,t),i=Yi(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},f={x:c/i,y:d/i},m={x:t.x+u.x*a,y:t.y+u.y*a},y={x:t.x+f.x*a,y:t.y+f.y*a},E=-u.x,p=-u.y,g=f.x,h=f.y,N=E*h-p*g>0?1:0;return`L${m.x} ${m.y}A${a} ${a} 0 0 ${N} ${y.x} ${y.y}`}var xd=(e,t=5)=>e.length<2?"":e.reduce((o,n,r)=>{let i="";return r>0&&r<e.length-1?i=ah(e[r-1],n,e[r+1],t):i=`${r===0?"M":"L"}${n.x} ${n.y}`,o+=i,o},"");var Se=require("react"),Wi=require("@xyflow/react");var lh=50,Ed=.1,ch=.6,Xi=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:a,getNodes:s,getEdge:l,screenToFlowPosition:c}=(0,Wi.useReactFlow)(),{setIsDragging:d,setReconnectingEdgeId:u}=q(),f=(0,Wi.useStore)(D=>D.isValidConnection),[m,y]=(0,Se.useState)(null),[E,p]=(0,Se.useState)(null),[g,h]=(0,Se.useState)(null),[x,N]=(0,Se.useState)(null),[b,T]=(0,Se.useState)(null),[v,A]=(0,Se.useState)(!1),C=(0,Se.useRef)(null),P=(0,Se.useRef)(null),R=(0,Se.useRef)(null),S=(0,Se.useRef)(t),L=(0,Se.useRef)(o);(0,Se.useEffect)(()=>{S.current=t,L.current=o},[t,o]),(0,Se.useEffect)(()=>{C.current=m},[m]),(0,Se.useEffect)(()=>{P.current=b},[b]);let K=(0,Se.useCallback)(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=(0,Se.useCallback)(D=>{var O,Y,F,U,X,$;let I=s(),B=null,G=lh,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)),ve=Math.max(ie.y-D.y,0,D.y-(ie.y+oe)),ye=Math.sqrt(Z*Z+ve*ve);ye<G&&(G=ye,B=te.id)}return B},[s,K,e]),Q=(0,Se.useCallback)((D,I)=>{var Z,ve,ye,Ie,J,de;let B=a(D);if(!B)return null;let G=K(D),k=(ye=(ve=(Z=B.measured)==null?void 0:Z.width)!=null?ve:B.width)!=null?ye:0,O=(de=(J=(Ie=B.measured)==null?void 0:Ie.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,xe])=>xe<re[1]?[ee,xe]:re,["right",$.right])[0],ie=R.current;if(ie&&ie!==te){let re=$[te],ee=$[ie],xe=Math.abs(ee-re),Ce=Math.min(Math.abs(ee),Math.abs(re));xe<Ce*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)<Ed&&(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)<Ed&&(ee=.5),le=ee,oe={x:G.x+le*k,y:W==="bottom"?G.y+O:G.y}}return{side:W,snapPosition:oe,offset:le}},[a,K]),z=(0,Se.useCallback)(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=f==null?void 0:f(ie))!=null?X:!0;A(W)}else R.current=null,A(!1);N(O),T(Y),p(k)},[j,Q,l,e,c,f]),M=(0,Se.useCallback)(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=f==null?void 0:f(oe))==null||X)&&i(le=>le.map(Z=>{var ve,ye;return Z.id===e?w(_({},Z),{source:oe.source,target:oe.target,sourceHandle:oe.sourceHandle,targetHandle:oe.targetHandle,data:w(_({},Z.data),{points:void 0,sourceOffset:I==="source"?ie:(ve=Z.data)==null?void 0:ve.sourceOffset,targetOffset:I==="target"?ie:(ye=Z.data)==null?void 0:ye.targetOffset})}):Z}))}y(null),p(null),h(null),N(null),T(null),d(!1),A(!1),u(null),R.current=null,document.removeEventListener("mouseup",M),document.removeEventListener("mousemove",z);let k=jt.get(n);k==null||k.clearReconnectingEdge()},[e,j,Q,l,i,n,z,f,c,d,u]),V=(0,Se.useCallback)((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=jt.get(n);B==null||B.setReconnectingEdge(e),document.addEventListener("mousemove",z),document.addEventListener("mouseup",M)},[r,e,n,z,M,u,i]);return(0,Se.useEffect)(()=>()=>{if(C.current){document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",M),u(null);let D=jt.get(n);D==null||D.clearReconnectingEdge()}},[n,z,M,u]),{reconnectingHandle:m,cursorPosition:E,hoveredNodeId:g,reconnectingSide:x,reconnectingOffset:b,isValidReconnection:v,handleReconnectStart:V}};var ge=require("react/jsx-runtime"),Pt={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:Me.MarkerType.ArrowClosed},markerEnd:{type:Me.MarkerType.Arrow},data:{label:""}},{MOVE_THRESHOLD:Ui,MIN_SEGMENT_LENGTH:dh,PARALLEL_OFFSET:_d,MAX_LABEL_DISTANCE:uh}=Ro;function ph(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 u=d.findIndex(m=>m.id===e);if(u<=0)return 0;let f=(d.length-1)/2;return(u-f)*_d}let l=s.findIndex(d=>d.id===e),c=(s.length-1)/2;return(l-c)*_d}var bd=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var $,te,ie,W,oe,le,Z,ve,ye,Ie;let{zoom:c}=(0,Me.useViewport)(),{updateEdgeData:d}=(0,Me.useReactFlow)(),u=(0,Me.useEdges)(),f=(0,Me.useNodes)(),{isMultipleSelection:m,isReadOnly:y,mode:E,instanceId:p,edgeHighlight:g}=q(),[h,x]=(0,et.useState)(!1),[N,b]=(0,et.useState)(null),T=(0,et.useRef)(null),v=(0,et.useRef)(n==null?void 0:n.labelOffset),A=(0,et.useRef)(null),C=E!=="edit",{reconnectingHandle:P,cursorPosition:R,hoveredNodeId:S,reconnectingSide:L,isValidReconnection:K,handleReconnectStart:j}=Xi({edgeId:e,source:t,target:o,instanceId:p,isReadOnly:C}),Q=(0,Me.useInternalNode)(t),z=(0,Me.useInternalNode)(o),{sx:M,sy:V,tx:D,ty:I,sourcePos:B,targetPos:G}=(0,et.useMemo)(()=>{var Ft,Wt;let J=Q&&z?An(Q,z):{sx:0,sy:0,tx:0,ty:0,sourcePos:Me.Position.Right,targetPos:Me.Position.Left},de=s?i:J.sourcePos,re=l?a:J.targetPos,ee=(ut,Ee,he)=>{var rt,Xt,To,co,uo,_a;let{x:pe,y:De}=ut.internals.positionAbsolute,pt=(To=(Xt=(rt=ut.measured)==null?void 0:rt.width)!=null?Xt:ut.width)!=null?To:0,At=(_a=(uo=(co=ut.measured)==null?void 0:co.height)!=null?uo:ut.height)!=null?_a:0;switch(Ee){case Me.Position.Top:return{x:pe+pt*he,y:De};case Me.Position.Bottom:return{x:pe+pt*he,y:De+At};case Me.Position.Left:return{x:pe,y:De+At*he};case Me.Position.Right:return{x:pe+pt,y:De+At*he};default:return{x:pe+pt/2,y:De+At/2}}},xe=(Ft=n==null?void 0:n.sourceOffset)!=null?Ft:.5,Ce=(Wt=n==null?void 0:n.targetOffset)!=null?Wt:.5,Re=Q?ee(Q,de,xe).x:J.sx,Je=Q?ee(Q,de,xe).y:J.sy,wt=z?ee(z,re,Ce).x:J.tx,lo=z?ee(z,re,Ce).y:J.ty;return P==="source"&&R?(Re=R.x,Je=R.y,L&&(de=L)):P==="target"&&R&&(wt=R.x,lo=R.y,L&&(re=L)),{sx:Re,sy:Je,tx:wt,ty:lo,sourcePos:de,targetPos:re}},[Q,z,s,l,i,a,P,R,L,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);(0,et.useEffect)(()=>{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)>Ui||Math.abs(V-J.sy)>Ui||Math.abs(D-J.tx)>Ui||Math.abs(I-J.ty)>Ui||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=(0,et.useMemo)(()=>{let J=ph(e,t,o,u,f);return Fi(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,f,e,t,o]),O=(0,et.useMemo)(()=>{if(k.length<2)return Gi({x:M,y:V},{x:D,y:I});let J=0;for(let ee=0;ee<k.length-1;ee++)J+=Hn(k[ee],k[ee+1]);let de=J/2,re=0;for(let ee=0;ee<k.length-1;ee++){let xe=Hn(k[ee],k[ee+1]);if(re+xe>=de){let Ce=(de-re)/xe,Re=k[ee],Je=k[ee+1];return{x:Re.x+(Je.x-Re.x)*Ce,y:Re.y+(Je.y-Re.y)*Ce}}re+=xe}return Gi({x:M,y:V},{x:D,y:I})},[k,M,V,D,I]),Y=(0,et.useCallback)((J,de)=>{if(E!=="edit"||de.button!==0)return;de.stopPropagation(),de.preventDefault();let re=k[J],ee=k[J+1],xe=_e(re,ee,"y"),Ce=xe?re.y:re.x,Re=[...k],Je=Re.length,wt=J,lo=J+1;b(J);let Ft=ut=>{let Ee=Ce+(xe?ut.clientY-de.clientY:ut.clientX-de.clientX)/c;T.current=xe?{x:(re.x+ee.x)/2,y:Ee}:{x:Ee,y:(re.y+ee.y)/2};let he=[];for(let pe=1;pe<Je-1;pe++){let De=Re[pe];pe===wt||pe===lo?xe?he.push({x:De.x,y:Ee}):he.push({x:Ee,y:De.y}):he.push(_({},De))}d(e,w(_({},n),{points:he}))},Wt=()=>{b(null),T.current=null,document.removeEventListener("mousemove",Ft),document.removeEventListener("mouseup",Wt)};document.addEventListener("mousemove",Ft),document.addEventListener("mouseup",Wt)},[E,k,c,n,e,d]),F=(0,et.useCallback)(J=>{var Ft,Wt,ut,Ee,he;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=(ut=(Wt=n==null?void 0:n.labelOffset)==null?void 0:Wt.x)!=null?ut:0,xe=(he=(Ee=n==null?void 0:n.labelOffset)==null?void 0:Ee.y)!=null?he:0,Ce=[...k],Re={x:O.x,y:O.y},Je=!1,wt=pe=>{let De=(pe.clientX-de)/c,pt=(pe.clientY-re)/c;if(!Je&&Math.abs(De)<3&&Math.abs(pt)<3)return;Je=!0;let At={x:ee+De,y:xe+pt};v.current=At,d(e,w(_({},n),{labelOffset:At}))},lo=()=>{document.removeEventListener("mousemove",wt),document.removeEventListener("mouseup",lo);let pe=v.current;if(!pe)return;let De={x:Re.x+pe.x,y:Re.y+pe.y};md(De,Ce)>uh&&(v.current=void 0,d(e,w(_({},n),{labelOffset:void 0})))};document.addEventListener("mousemove",wt),document.addEventListener("mouseup",lo)},[h,C,c,n,e,d,k,O]);if(!Q||!z)return null;let U=xd(k),X=g&&(r||Q.selected||z.selected);return(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsxs)("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":X}),onDoubleClick:()=>!C&&x(!0),children:[(0,ge.jsx)("path",{d:U,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),className:H({"nopan nodrag":!h&&!C&&!!(($=n==null?void 0:n.label)!=null&&$.trim())}),style:{pointerEvents:"stroke",cursor:!h&&!C&&((te=n==null?void 0:n.label)!=null&&te.trim())?"move":"pointer"},onMouseDown:F}),(0,ge.jsxs)("g",{className:H("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!y,"text-blue-500 group-hover:text-blue-600":X}),children:[(0,ge.jsx)(Me.BaseEdge,{id:e,path:U,interactionWidth:0,markerEnd:`url(#${X?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75",{"group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]":!y,"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||P&&S&&!K,"stroke-green-500":P&&S&&K,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":X&&!(n!=null&&n.hasError)&&!P})}),r&&!m&&!C&&(0,ge.jsx)("g",{children:k.slice(0,-1).map((J,de)=>{let re=k[de+1];if(de===0||de===k.length-2||Hn(J,re)<dh)return null;let ee=_e(J,re,"y"),xe=N===de,Ce=xe&&T.current?T.current:Gi(J,re);return(0,ge.jsxs)("g",{children:[(0,ge.jsx)("line",{x1:J.x,y1:J.y,x2:re.x,y2:re.y,stroke:"transparent",strokeWidth:20/c,className:H("cursor-pointer",{"cursor-ns-resize":ee,"cursor-ew-resize":!ee}),onMouseDown:Re=>Y(de,Re)}),(0,ge.jsx)("circle",{cx:Ce.x,cy:Ce.y,r:4/c,fill:xe?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ge.jsx)("circle",{cx:Ce.x,cy:Ce.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:xe?.6:.3,className:"pointer-events-none"})]},de)})})]})]}),(0,ge.jsxs)(Me.EdgeLabelRenderer,{children:[(0,ge.jsx)("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${O.x}px, ${O.y}px)`},children:r&&!m&&(0,ge.jsx)(On,{sx:M,sy:V,tx:D,ty:I,hasLabel:!!((ie=n==null?void 0:n.label)!=null&&ie.trim()),children:(0,ge.jsx)(Dn,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:Q,targetNode:z})})}),(h||((W=n==null?void 0:n.label)==null?void 0:W.trim()))&&(0,ge.jsx)("div",{className:H("absolute nodrag nopan",!h&&!C&&((oe=n==null?void 0:n.label)!=null&&oe.trim())?"z-[10001] pointer-events-auto":"z-[3000] pointer-events-none"),style:{transform:`translate(-50%, -50%) translate(${O.x+((Z=(le=n==null?void 0:n.labelOffset)==null?void 0:le.x)!=null?Z:0)}px, ${O.y+((ye=(ve=n==null?void 0:n.labelOffset)==null?void 0:ve.y)!=null?ye:0)}px)`,cursor:!h&&!C&&((Ie=n==null?void 0:n.label)!=null&&Ie.trim())?"move":void 0},onMouseDown:!h&&!C?F:void 0,onDoubleClick:J=>{C||(J.stopPropagation(),x(!0))},children:(0,ge.jsx)(je,{value:n==null?void 0:n.label,className:H("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":h,"pointer-events-none":!h}),isEditing:h,onBlur:()=>x(!1),onChange:J=>d(e,{label:J.trim()})})}),r&&!m&&!C&&(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsx)("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${k[0].x}px, ${k[0].y}px)`},children:(0,ge.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:P==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:P==="source"?.6:.3,className:"pointer-events-none"}),(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!P||P!=="source","cursor-not-allowed":P==="source"&&S&&!K,"cursor-grabbing":P==="source"&&(!S||K)}),onMouseDown:J=>j("source",J.nativeEvent)})]})}),(0,ge.jsx)("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${k[k.length-1].x}px, ${k[k.length-1].y}px)`},children:(0,ge.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:P==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:P==="target"?.6:.3,className:"pointer-events-none"}),(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!P||P!=="target","cursor-not-allowed":P==="target"&&S&&!K,"cursor-grabbing":P==="target"&&(!S||K)}),onMouseDown:J=>j("target",J.nativeEvent)})]})})]})]})]})};var eo=require("@xyflow/react"),fh={right:eo.Position.Right,left:eo.Position.Left,top:eo.Position.Top,bottom:eo.Position.Bottom},$i=e=>{var t;return(t=fh[e!=null?e:""])!=null?t:eo.Position.Right},Js=(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($i(t)){case eo.Position.Right:return{x:n+i,y:r+a*o};case eo.Position.Left:return{x:n,y:r+a*o};case eo.Position.Top:return{x:n+i*o,y:r};case eo.Position.Bottom:return{x:n+i*o,y:r+a};default:return{x:n+i/2,y:r+a/2}}},Td=(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((f,m)=>{let y=Math.hypot(t-f.x,o-f.y);return Math.hypot(t-m.x,o-m.y)<y?m:f}).id};var Pu=require("use-debounce");var Mu=require("@xyflow/react"),da=require("react");var _r=(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))(_r||{});var br=1,vd=e=>`<mxGraphModel>
6
6
  <root version="1.1">
7
7
  <mxCell id="0" />
8
8
  <mxCell id="1" parent="0" />
@@ -35,12 +35,12 @@
35
35
  <mxGeometry as="geometry" relative="1" />
36
36
  </mxCell>
37
37
  </root>
38
- </mxGraphModel>`,wd=(e,t)=>{if(!e.length&&!t.length)return br;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var qi=require("xml-js");var Ad={compact:!0,spaces:4},gh=e=>e.replace(/\n/g,"&#xA;");function Zi(e,t=Ad){if(e)return JSON.parse((0,qi.xml2json)(e,t))}function Id(e,t=Ad){return e?(0,qi.json2xml)(e,w(_({},t),{attributeValueFn:gh})):""}var Cd={"attribute-loop":"LOOP"},Sd={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS","service-task":"SERVICE_TASK"},Md={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Pd={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed",SERVICE_TASK:"service-task"},Ld={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var Gn=(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(vo(Number(a),t),l),u=Math.max(vo(Number(s),o),c);return{width:d,height:u,measured:{width:d,height:u}}},Bn=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},yh=e=>{let{mxGeometry:t}=e,o=Bn(e),n=Gn(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=Bn(e),n=Gn(t,ue.END_EVENT.MIN_WIDTH,ue.END_EVENT.MIN_HEIGHT);return w(_(_({},o),n),{type:"END_EVENT"})},Ji=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=Bn(e),s=Gn(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=Cd[d];u&&(r.data.attribute=u)}let c=Sd[o.style];return c&&(r.data.variant=c),w(_(_({},r),s),{type:"TASK"})},js=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=Bn(e),i=Gn(o,ue.GATEWAY.MIN_WIDTH,ue.GATEWAY.MIN_HEIGHT);return r.data.variant=Md[n],w(_(_({},r),i),{type:"GATEWAY"})},Eh=e=>{let{mxGeometry:t}=e,o=Bn(e),i=Gn(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=Bn(e),n=Gn(t,ue.LANE.MIN_WIDTH,ue.LANE.MIN_HEIGHT);return w(_(_({},o),n),{type:"LANE"})},kd={task:Ji,"task-script":Ji,"subprocess-collapsed":Ji,"service-task":Ji,"start-event":yh,"end-event-terminate":xh,"gateway-parallel":js,"gateway-exclusive":js,"gateway-complex":js,annotation:Eh,lane:_h},bh=e=>{if(e&&Array.isArray(e))return e.map(t=>({x:Number(t._attributes.x),y:Number(t._attributes.y)}))},Rd=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:f,labelOffsetY:m}=t,y=bh(o==null?void 0:o.Array),E=d!==void 0?Number(d):void 0,p=u!==void 0?Number(u):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}:{}),p!==void 0?{targetOffset:p}:{}),g!==void 0&&h!==void 0?{labelOffset:{x:g,y:h}}:{})});return s.includes("association")&&s.includes('endArrow=""')?_(_({},Vn),x):_(_({},Pt),x)},Dd=(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 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:((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:u}},zn=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}}}},Th=e=>{let{variant:t}=e.data,o=zn(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:Pd[t]||"task"})})},vh=e=>{let t=zn(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"start-event"})})},Nh=e=>{let t=zn(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"end-event-terminate"})})},wh=e=>{let{variant:t}=e.data,o=zn(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:Ld[t]})})},Ah=e=>{let t=zn(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"lane"})})},Ih=e=>{let t=zn(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"annotation"})})},Od={TASK:Th,START_EVENT:vh,END_EVENT:Nh,GATEWAY:wh,ANNOTATION:Ih,LANE:Ah},Vd=(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 Ch=e=>{let t=Object.values(_r),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=kd[a],l=s==null?void 0:s(i,n);if(!l){console.warn(`Node ${a} not supported`);continue}r.push(l)}return r},Sh=(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=Rd(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},Mh=(e,t)=>{let o=[];return e.forEach(n=>{var a,s;let r=(s=(a=Od)[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=Vd(n,t);o.push(l)}}),o},Ph=(e,t)=>{let o=[];return e.forEach(n=>{let r=Dd(n,t);o.push(r)}),o},Lh=(e=[],t=[],o)=>{let n=Mh(e,o),r=Ph(t,e);return{mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}}},Hd=(e=[],t=[],o)=>{let n=Lh(e,t,o);return Id(JSON.stringify(n),{compact:!0,spaces:0})},Gd=async e=>{var a,s,l,c,d;let t=await Zi(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)||br),r=Ch(o),i=Sh(o,r);return{lastElementId:n,edges:i,nodes:r}};var as=require("@xyflow/react"),Su=require("react");var ht=require("@xyflow/react"),ns=require("react");var Tr=require("@xyflow/react");var ea=require("react/jsx-runtime"),ne=i=>{var a=i,{type:e,position:t,className:o,nodeType:n}=a,r=Ut(a,["type","position","className","nodeType"]);let s=n==="TASK";return(0,ea.jsx)(Tr.Handle,_({type:e,position:t,className:H("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":s,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":!s},o)},r))},ot=s=>{var l=s,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,a=Ut(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=(0,Tr.useReactFlow)(),f=(()=>{if(n!=="source")return!1;let m=c();if(t==="TASK")return m.filter(E=>E.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return m.filter(E=>E.source===e).length>=2;if(t==="START_EVENT"){let y=d();return m.filter(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(0,ea.jsx)(Tr.Handle,_({type:n,position:r,className:H("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":f,"hover:border-grey-500":!f},i),style:{pointerEvents:f?"none":"auto"}},a))};var na=require("react"),go=require("@xyflow/react");var Bd=require("@xyflow/react"),Qi=()=>{let e=(0,Bd.useStoreApi)();return{getInternalNodes:()=>{let{nodeLookup:o}=e.getState();return Array.from(o.values())}}};var ta=wf(require("@dagrejs/dagre"),1),vr=require("@xyflow/react");var Yd=(e=[],t=[],o="LR")=>{let n=new ta.default.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:i,width:a,height:s})=>n.setNode(i,{width:a,height:s})),t.forEach(i=>n.setEdge(i.source,i.target)),ta.default.layout(n),{nodes:e.map(i=>{let a=n.node(i.id);return w(_({},i),{position:{x:a.x-i.width/2,y:a.y-i.height/2}})}),edges:t}},Do=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId);if(t.length===0)return e;let o=Ya(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){Ka(a,o,r),qa(n,o);continue}Ss(n,i,o)}return Fa(e,o)};var Fd=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)};var kh=500;var Rh=e=>e.type==="LANE"&&!e.parentId,Dh=(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},Oh=(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)},Vh=e=>{let t=new Set;for(let o of e)t.add(o.source),t.add(o.target);return t},zd=(e,t,o)=>{if(e.type!=="ANNOTATION"||o.has(e.id))return!1;let n=(0,vr.getNodesBounds)([e]);return Oh(t,n)>kh},oa=(e,t=[])=>{var E;let o=e.filter(Rh);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=Vh(t),l=a.filter(p=>p.type!=="ANNOTATION"),c=(0,vr.getNodesBounds)(l.length>0?l:a),d=a.filter(p=>!zd(p,c,s)),u=(0,vr.getNodesBounds)(d),y=e.filter(p=>!r.has(p.id)).filter(p=>{let g=(0,vr.getNodesBounds)([p]);return!Dh(u,g)}).filter(p=>!zd(p,u,s));return[...d,...y]};var ji=require("react/jsx-runtime"),ra=require("react"),Hh=["top","right","bottom","left"],Gh=["top-left","top-middle","top-right","right-middle","bottom-left","left-middle","bottom-right","bottom-middle"],Lt=r=>{var i=r,{nodeId:e,isVisible:t,offset:o=8}=i,n=Ut(i,["nodeId","isVisible","offset"]);let{getInternalNode:a,setNodes:s}=(0,go.useReactFlow)(),{getInternalNodes:l}=Qi(),{isMultipleSelection:c}=q(),d=(0,go.useStoreApi)(),u=(0,na.useRef)(0),f=(0,na.useRef)([]),m=({y:g,width:h,height:x})=>{cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{var j,Q;if(!e)return;let{nodeLookup:N,onNodesChange:b}=d.getState(),T=N.get(e);if(!T||T.type!=="LANE")return;let v=!T.parentId,A=v?T.id:T.parentId;if(!A)return;let C=Array.from(N.values()).filter(z=>z.type==="LANE"&&z.parentId===A);if(!C.length)return;f.current.length===0&&(f.current=$o(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===T.id),K=!v&&L>0&&Math.abs(g-T.position.y)>.5;for(let z=0;z<P.length;z++){let M=P[z],V=M.id===T.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=v?h-ae.HEADER_WIDTH:h,G=I;v&&D&&(G=Math.max(ae.MIN_HEIGHT,x-S)),K&&z===L-1&&(G=Math.max(ae.MIN_HEIGHT,g-S)),R.push({id:M.id,type:"dimensions",dimensions:{width:B,height:G},setAttributes:!0}),R.push({id:M.id,type:"position",position:{x:ae.HEADER_WIDTH,y:S}}),S+=G}v?R.push({id:A,type:"dimensions",dimensions:{width:h,height:x},setAttributes:!0}):R.push({id:A,type:"dimensions",dimensions:{width:h+ae.HEADER_WIDTH,height:S},setAttributes:!0}),b==null||b(R)})},y=({y:g,width:h,height:x})=>{var T;if(cancelAnimationFrame(u.current),f.current=[],!e)return;let N=a(e);if(!N||N.type!=="LANE"&&!N.parentId)return;let b=[...l()];if(N.type!=="LANE"){b=b.map(v=>v.id===e?w(_({},v),{width:h,height:x,measured:{width:h,height:x}}):v),b=Do(b),s(b);return}b=Za(N,h,x,b,g),b=Do(b),b=Uo((T=N.parentId)!=null?T:N.id,b),s(b)};if(!(!c&&t))return null;let p={"--resize-offset":`${o}px`};return(0,ji.jsxs)(ji.Fragment,{children:[Hh.map(g=>(0,ra.createElement)(go.NodeResizeControl,w(_({},n),{key:g,nodeId:e,position:g,variant:go.ResizeControlVariant.Line,className:"border-blue-400/90 border-dashed",style:p,onResize:(h,x)=>m(x),onResizeEnd:(h,x)=>y(x)}))),Gh.map(g=>(0,ra.createElement)(go.NodeResizeControl,w(_({},n),{key:g,nodeId:e,position:g,className:"size-1.5 bg-blue-400 relative before:content-[''] before:absolute before:w-5 before:h-5 before:left-1/2 before:top-1/2 before:-translate-x-1/2 before:-translate-y-1/2 before:cursor-[inherit]",style:p,onResize:(h,x)=>m(x),onResizeEnd:(h,x)=>y(x)})))]})};var os=require("@xyflow/react"),eo=require("@produto-lecom/lecom-ui"),gt=require("react");var Wd=require("zustand"),Yn=(0,Wd.create)(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));var es=require("react"),Xd=(e,t=!1)=>{let[o,n]=(0,es.useState)({width:0,height:0});return(0,es.useEffect)(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};var Oo=require("@xyflow/react"),Ud=require("react"),Bh=120,zh=12,$d=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=(0,Oo.useReactFlow)(),{instanceId:i}=q();return(0,Ud.useMemo)(()=>{var m,y;if(!t)return{position:Oo.Position.Right,align:"start"};let a=n(e);if(!a)return{position:Oo.Position.Right,align:"start"};let s=r(),l=a.position.x*s.zoom+s.x,c=(((m=a.measured)==null?void 0:m.width)||a.width||100)*s.zoom,d=(y=document.getElementById(`modeler-${i}`))==null?void 0:y.clientWidth;if(!d)return{position:Oo.Position.Right,align:"start"};let u=(o==null?void 0:o.width)||Bh;return{position:l+c+u+zh>d?Oo.Position.Left:Oo.Position.Right}},[i,e,t,o,n,r])};var ia=require("lucide-react");var ts=require("@xyflow/react"),be=require("@produto-lecom/lecom-ui"),Kd=require("lucide-react");var Pe=require("react/jsx-runtime"),qd=({nodeId:e})=>{let{t}=(0,be.useTranslation)(),{updateNodeData:o,getEdges:n,getNode:r}=(0,ts.useReactFlow)(),i=(0,ts.useNodesData)(e),s=n().filter(y=>y.source===e).some(y=>{let E=r(y.target);return(E==null?void 0:E.type)==="END_EVENT"}),l=(i==null?void 0:i.data.variant)==="SUBPROCESS",c=(i==null?void 0:i.data.variant)==="SERVICE_TASK",d=f=>{o(e,{variant:(i==null?void 0:i.data.variant)===f?"":f})},u=f=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===f?"":f})};return(0,Pe.jsxs)(be.DropdownMenu,{children:[(0,Pe.jsxs)(be.Tooltip,{children:[(0,Pe.jsx)(be.TooltipTrigger,{asChild:!0,children:(0,Pe.jsx)(be.DropdownMenuTrigger,{asChild:!0,children:(0,Pe.jsx)(be.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:(0,Pe.jsx)(Kd.WrenchIcon,{})})})}),(0,Pe.jsx)(be.TooltipContent,{color:"black",children:t("bpmn.task.menu.title")})]}),(0,Pe.jsxs)(be.DropdownMenuContent,{align:"start",className:"w-60 bg-white text-grey-600",children:[(0,Pe.jsxs)(be.DropdownMenuLabel,{className:"flex items-center gap-1",children:[(0,Pe.jsx)("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),(0,Pe.jsx)("div",{className:"flex items-center gap-1",children:Object.entries(Zr).map(([f,m])=>{let y=f==="LOOP"&&(s||l||c),p=(()=>{if(f==="LOOP"&&s)return t("editor.task_menu.loop_not_allowed_when_connected_to_end");if(f==="LOOP"&&l)return t("editor.task_menu.loop_not_allowed_when_subprocess");if(f==="LOOP"&&c)return t("editor.task_menu.loop_not_allowed_when_service_task");if(f==="LOOP")return t("editor.task_menu.loop")})();return(0,Pe.jsxs)(be.Tooltip,{children:[(0,Pe.jsx)(be.TooltipTrigger,{asChild:!0,children:(0,Pe.jsx)(be.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:y,className:H({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===f,"opacity-50 cursor-not-allowed":y}),onClick:y?void 0:()=>u(f),children:(0,Pe.jsx)(m.icon,{className:"stroke-inherit"})})}),p&&(0,Pe.jsx)(be.TooltipContent,{color:"black",children:p})]},f)})})]}),(0,Pe.jsx)(be.DropdownMenuGroup,{children:(0,Pe.jsxs)(be.Tooltip,{children:[(0,Pe.jsx)(be.TooltipTrigger,{asChild:!0,children:(0,Pe.jsx)("div",{className:H({"cursor-not-allowed":s}),children:(0,Pe.jsxs)(be.DropdownMenuItem,{className:H({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":s}),disabled:s,onClick:()=>d("SCRIPT"),children:[(0,Pe.jsx)(qr.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),s&&(0,Pe.jsx)(be.TooltipContent,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};var Oe=require("react/jsx-runtime"),ho={START_EVENT:{type:"START_EVENT",icon:Qn,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:gn,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:Qn,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:Xr,label:"bpmn.annotation.variant.default"}},Yh={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:xn,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:_n,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:hn,label:"bpmn.gateway.variant.complex"}},ct=({nodeId:e,nodeType:t,nodeVariant:o,isChild:n})=>{let r=(0,gt.useRef)(null),i=(0,gt.useRef)(null),{t:a}=(0,eo.useTranslation)(),{setDraggableNode:s}=Yn(),{getEdges:l,getNodes:c,getNode:d,setNodes:u}=(0,os.useReactFlow)(),{setIsDragging:f,mode:m,isConnecting:y,isDragging:E,isMultipleSelection:p}=q(),g=d(e),h=!!(g!=null&&g.selected)&&!g.dragging&&!y&&!E&&!p,{dimensions:x}=Xd(r,h),{position:N}=$d(e,h,x),[b,T]=(0,gt.useState)(void 0),v=c(),A=l(),C=o==="SUBPROCESS",P=o==="SERVICE_TASK",R=(0,gt.useRef)(null),S=(0,gt.useRef)(!1),L=(0,gt.useCallback)(()=>{R.current!==null&&(clearTimeout(R.current),R.current=null),S.current=!1,f(!1),s(null),T(void 0),u(F=>F.map(U=>w(_({},U),{className:void 0})))},[f,s,u]);(0,gt.useEffect)(()=>{let F=U=>{S.current&&U.buttons===0&&L()};return document.addEventListener("dragend",L),document.addEventListener("mousemove",F),()=>{document.removeEventListener("dragend",L),document.removeEventListener("mousemove",F)}},[L]);let K=(0,gt.useCallback)((F,U)=>{S.current=!0,f(!1),s({type:U.type,variant:U.variant,attribute:U.attribute,icon:U.icon}),U.icon&&T((0,Oe.jsx)(U.icon,{})),F.dataTransfer.effectAllowed="move",F.dataTransfer.setData("sourceId",e),i.current&&F.dataTransfer.setDragImage(i.current,10,10),R.current=setTimeout(()=>{R.current=null,f(!0)},100)},[e,s,f]),j=(0,gt.useCallback)(()=>{L()},[L]),Q=[{component:(0,Oe.jsx)(Gi,{elementId:e})}],z=()=>{if(m==="view")return[];let F=!A.some(U=>{var X;return U.source===e&&((X=v.find($=>$.id===U.target))==null?void 0:X.type)!=="ANNOTATION"});return[{component:(0,Oe.jsx)(kn,{nodeId:e,disabled:!F,tooltipMessage:F?void 0:a("editor.toolbar.start_event_limit_reached")})},ho.TASK,ho.ANNOTATION,...Q]},M=()=>m==="view"?[{component:(0,Oe.jsx)(ko,{elementId:e})}]:[{component:(0,Oe.jsx)(ko,{elementId:e})},...C||P?[]:[{component:(0,Oe.jsx)(qd,{nodeId:e})}],{component:(0,Oe.jsx)(kn,{nodeId:e})},ho.TASK,{type:"TASK",variant:"SUBPROCESS",icon:jn,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:ia.Bot,label:"bpmn.task.variant.service_task"},ho.ANNOTATION,...Object.values(Yh),...en(e,v,A)?[]:[ho.END_EVENT],...Q],V=()=>m==="view"?[{component:(0,Oe.jsx)(ko,{elementId:e,elementType:"gateway"})}]:[{component:(0,Oe.jsx)(ko,{elementId:e,elementType:"gateway"})},{component:(0,Oe.jsx)(kn,{nodeId:e})},ho.TASK,{type:"TASK",variant:"SUBPROCESS",icon:jn,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:ia.Bot,label:"bpmn.task.variant.service_task"},ho.ANNOTATION,...Q],D=()=>m==="view"?[]:[ho.ANNOTATION,...Q],I=()=>m==="view"?[]:[...n?[]:[{component:(0,Oe.jsx)(kn,{nodeId:e})}],ho.ANNOTATION,...Q],B=()=>m==="view"?[]:[{component:(0,Oe.jsx)(kn,{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 I();case"ANNOTATION":return B();case"UNSUPPORTED":return G();default:return[]}})(t),Y=O.length>6;if(!(O.length===0||m==="readonly"))return(0,Oe.jsxs)(os.NodeToolbar,{position:N,align:"start",className:Y?"-top-[4.5rem]":"-top-8",isVisible:h,children:[(0,Oe.jsx)("div",{ref:r,className:`${Y?"grid grid-cols-6":"flex"} gap-1 px-2 py-2 bg-white rounded-sm shadow-md`,children:O.map((F,U)=>{if(F.component)return(0,Oe.jsx)("div",{children:F.component},U);let X={sourceNodeType:t,targetNodeType:F.type,sourceNodeId:e,nodes:v,edges:A},$=nd(X),te={gateway_limit_reached:a("editor.toolbar.gateway_limit_reached"),start_event_limit_reached:a("editor.toolbar.start_event_limit_reached"),start_event_already_exists:a("editor.toolbar.start_event_already_exists"),script_to_end_not_allowed:a("editor.toolbar.script_to_end_not_allowed"),loop_to_end_not_allowed:a("editor.toolbar.loop_to_end_not_allowed"),initial_activity_to_end_not_allowed:a("editor.toolbar.initial_activity_to_end_not_allowed"),final_activity_cannot_connect:a("editor.toolbar.final_activity_cannot_connect"),activity_has_outgoing_connections:a("editor.toolbar.activity_has_outgoing_connections"),task_limit_reached:a("editor.toolbar.task_limit_reached"),start_event_to_service_task_not_allowed:a("editor.toolbar.start_event_to_service_task_not_allowed"),service_task_to_end_not_allowed:a("editor.toolbar.service_task_to_end_not_allowed")},ie=$.shouldDisable&&$.reason?te[$.reason]||a(F.label):a(F.label)||"";return(0,Oe.jsxs)(eo.Tooltip,{children:[(0,Oe.jsx)(eo.TooltipTrigger,{asChild:!0,children:(0,Oe.jsx)(eo.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!$.shouldDisable,disabled:$.shouldDisable,className:$.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:$.shouldDisable?void 0:W=>K(W,F),onDragEnd:$.shouldDisable?void 0:j,children:F.icon&&(0,Oe.jsx)(F.icon,{size:16})})}),(0,Oe.jsx)(eo.TooltipContent,{color:"black",children:ie})]},U)})}),(0,Oe.jsx)("div",{ref:i,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:b})]})};var Ke=require("react/jsx-runtime"),Zd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r,setNodes:i}=(0,ht.useReactFlow)(),{inProgress:a,fromNode:s}=(0,ht.useConnection)(),{mode:l,isReadOnly:c}=q(),d=a&&(s==null?void 0:s.id)!==e,u=(0,ns.useCallback)(y=>{let x=y.split(`
40
- `),N=x.reduce((A,C)=>Math.max(A,C.length),0),b=x.length,T=Math.max(Nn.MIN_WIDTH,N*7+32),v=Math.max(Nn.MIN_HEIGHT,b*20+24);i(A=>A.map(C=>C.id===e?w(_({},C),{width:T,height:v,style:w(_({},C.style),{width:T,height:v})}):C))},[e,i]),f=(0,ns.useCallback)(y=>{r(e,{label:y}),u(y)},[e,r,u]),m=(0,ns.useCallback)(y=>{u(y)},[u]);return(0,Ke.jsxs)("div",{className:H("relative w-full h-full min-w-44 min-h-16 flex text-grey-400 hover:text-grey-500 bg-white rounded-sm border-l-2 border-current before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-current after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-current hover:shadow-md transition-colors duration-75",{"pointer-events-none":c,"text-blue-500 hover:text-blue-600 shadow-md":o&&!c,"border-red-500 border-l-[3px] shadow-[0_0_5px_rgba(255,0,0,0.5)] before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-red-500 after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-red-500":t.hasError}),children:[(0,Ke.jsx)(je,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:f,onInput:m,skipFirstCharValidation:!0}),(0,Ke.jsx)(ct,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&(0,Ke.jsx)(Lt,{nodeId:e,minWidth:Nn.MIN_WIDTH,minHeight:Nn.MIN_HEIGHT,isVisible:!n&&o}),!a&&(0,Ke.jsxs)(Ke.Fragment,{children:[(0,Ke.jsx)(ne,{type:"source",position:ht.Position.Left,id:"left"}),(0,Ke.jsx)(ne,{type:"source",position:ht.Position.Right,id:"right"}),(0,Ke.jsx)(ne,{type:"source",position:ht.Position.Top,id:"top"}),(0,Ke.jsx)(ne,{type:"source",position:ht.Position.Bottom,id:"bottom"})]}),(!a||d)&&(0,Ke.jsxs)(Ke.Fragment,{children:[(0,Ke.jsx)(ne,{type:"target",position:ht.Position.Left,id:"left",className:H({"annotation-handle":d})}),(0,Ke.jsx)(ne,{type:"target",position:ht.Position.Right,id:"right",className:H({"annotation-handle":d})}),(0,Ke.jsx)(ne,{type:"target",position:ht.Position.Top,id:"top",className:H({"annotation-handle":d})}),(0,Ke.jsx)(ne,{type:"target",position:ht.Position.Bottom,id:"bottom",className:H({"annotation-handle":d})})]})]})};var yt=require("@xyflow/react"),Jd=require("react");var Fe=require("react/jsx-runtime"),Qd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=(0,yt.useReactFlow)(),{inProgress:i,fromNode:a}=(0,yt.useConnection)(),{mode:s,isReadOnly:l,reconnectingEdgeId:c}=q(),[d,u]=(0,Jd.useState)(!1),f=i&&(a==null?void 0:a.id)!==e||!!c,m=p=>{r(e,{label:p})},y=()=>{u(!0)},E=()=>{u(!1)};return(0,Fe.jsxs)("div",{className:"relative",onDoubleClick:y,children:[(0,Fe.jsx)(gn,{className:H("w-full h-full min-w-9 min-h-9 hover:stroke-[#d33b3b] transition-colors duration-75",{"pointer-events-none":l,"stroke-blue-500 hover:stroke-blue-600":o&&!l,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),(0,Fe.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,Fe.jsx)(je,{value:t.label,isEditing:d,onBlur:E,onChange:m})}),(0,Fe.jsx)(ct,{nodeId:e,nodeType:"END_EVENT"}),s==="edit"&&(0,Fe.jsx)(Lt,{nodeId:e,isVisible:!n&&o,minWidth:Qr.MIN_WIDTH,minHeight:Qr.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||f)&&(0,Fe.jsxs)(Fe.Fragment,{children:[(0,Fe.jsx)(ne,{type:"target",position:yt.Position.Left,id:"left",className:H({"event-handle":f})}),(0,Fe.jsx)(ne,{type:"target",position:yt.Position.Right,id:"right",className:H({"event-handle":f})}),(0,Fe.jsx)(ne,{type:"target",position:yt.Position.Top,id:"top",className:H({"event-handle":f})}),(0,Fe.jsx)(ne,{type:"target",position:yt.Position.Bottom,id:"bottom",className:H({"event-handle":f})})]}),!i&&(0,Fe.jsxs)(Fe.Fragment,{children:[(0,Fe.jsx)(ne,{type:"source",position:yt.Position.Left,id:"left"}),(0,Fe.jsx)(ne,{type:"source",position:yt.Position.Right,id:"right"}),(0,Fe.jsx)(ne,{type:"source",position:yt.Position.Top,id:"top"}),(0,Fe.jsx)(ne,{type:"source",position:yt.Position.Bottom,id:"bottom"})]})]})};var xt=require("@xyflow/react"),rs=require("react");var We=require("react/jsx-runtime"),jd=({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let a=Is[t.variant].icon,{updateNodeData:s}=(0,xt.useReactFlow)(),{inProgress:l,fromNode:c}=(0,xt.useConnection)(),{mode:d,isReadOnly:u,reconnectingEdgeId:f}=q(),[m,y]=(0,rs.useState)(!1),E=l&&(c==null?void 0:c.id)!==e||!!f,p=(0,rs.useCallback)(x=>{s(e,{label:x})},[e,s]),g=()=>{y(!0)},h=()=>{y(!1)};return(0,We.jsxs)("div",{className:"relative",style:{width:o!=null?o:vn.MIN_WIDTH,height:n!=null?n:vn.MIN_HEIGHT},onDoubleClick:g,children:[(0,We.jsx)(a,{className:H("w-full h-full min-w-14 min-h-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"pointer-events-none":u,"stroke-blue-500 hover:stroke-blue-600":r&&!u,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),(0,We.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,We.jsx)(je,{value:t.label,isEditing:m,onBlur:h,onChange:p})}),(0,We.jsx)(ct,{nodeId:e,nodeType:"GATEWAY",nodeVariant:t.variant}),d==="edit"&&(0,We.jsx)(Lt,{nodeId:e,isVisible:!i&&r,minWidth:vn.MIN_WIDTH,minHeight:vn.MIN_HEIGHT,offset:2,keepAspectRatio:!0}),(!l||E)&&(0,We.jsxs)(We.Fragment,{children:[(0,We.jsx)(ne,{type:"target",position:xt.Position.Left,id:"left",className:H({"gateway-handle":E})}),(0,We.jsx)(ne,{type:"target",position:xt.Position.Right,id:"right",className:H({"gateway-handle":E})}),(0,We.jsx)(ne,{type:"target",position:xt.Position.Top,id:"top",className:H({"gateway-handle":E})}),(0,We.jsx)(ne,{type:"target",position:xt.Position.Bottom,id:"bottom",className:H({"gateway-handle":E})})]}),!l&&(0,We.jsxs)(We.Fragment,{children:[(0,We.jsx)(ot,{type:"source",position:xt.Position.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,We.jsx)(ot,{type:"source",position:xt.Position.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,We.jsx)(ot,{type:"source",position:xt.Position.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,We.jsx)(ot,{type:"source",position:xt.Position.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})};var eu=require("@xyflow/react"),Gt=require("@produto-lecom/lecom-ui"),Fh=require("lucide-react");var tu=require("react/jsx-runtime");var Et=require("@xyflow/react"),ou=require("react");var Xe=require("react/jsx-runtime"),nu=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=(0,Et.useReactFlow)(),{inProgress:i,fromNode:a}=(0,Et.useConnection)(),{mode:s,isReadOnly:l,reconnectingEdgeId:c}=q(),[d,u]=(0,ou.useState)(!1),f=i&&(a==null?void 0:a.id)!==e||!!c,m=p=>{r(e,{label:p})},y=()=>{u(!0)},E=()=>{u(!1)};return(0,Xe.jsxs)("div",{className:"relative",onDoubleClick:y,children:[(0,Xe.jsx)(Kr,{className:H("w-full h-full min-w-9 min-h-9 hover:stroke-[#54890b] transition-colors duration-75",{"pointer-events-none":l,"stroke-blue-500 hover:stroke-blue-600":o&&!l,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),(0,Xe.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,Xe.jsx)(je,{value:t.label,isEditing:d,onBlur:E,onChange:m})}),(0,Xe.jsx)(ct,{nodeId:e,nodeType:"START_EVENT"}),s==="edit"&&(0,Xe.jsx)(Lt,{nodeId:e,isVisible:!n&&o,minWidth:Jr.MIN_WIDTH,minHeight:Jr.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||f)&&(0,Xe.jsxs)(Xe.Fragment,{children:[(0,Xe.jsx)(ne,{type:"target",position:Et.Position.Left,id:"left",className:H({"event-handle":f})}),(0,Xe.jsx)(ne,{type:"target",position:Et.Position.Right,id:"right",className:H({"event-handle":f})}),(0,Xe.jsx)(ne,{type:"target",position:Et.Position.Top,id:"top",className:H({"event-handle":f})}),(0,Xe.jsx)(ne,{type:"target",position:Et.Position.Bottom,id:"bottom",className:H({"event-handle":f})})]}),!i&&(0,Xe.jsxs)(Xe.Fragment,{children:[(0,Xe.jsx)(ot,{type:"source",position:Et.Position.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),(0,Xe.jsx)(ot,{type:"source",position:Et.Position.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),(0,Xe.jsx)(ot,{type:"source",position:Et.Position.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),(0,Xe.jsx)(ot,{type:"source",position:Et.Position.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};var au=require("@produto-lecom/lecom-ui"),_t=require("@xyflow/react"),Ir=require("react");var Nr=60,is=(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<=Nr?i:i.substring(0,Nr).trim()},Fn=(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>Nr&&(n=n.substring(0,Nr).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=Nr-l.length,u=`${r.substring(0,c).trim()}${l}`;if(!o.has(u))return u;i++}return n};var wr=require("react/jsx-runtime"),ru=e=>(0,wr.jsxs)("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[(0,wr.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),(0,wr.jsx)("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));var sa=require("react/jsx-runtime"),iu=e=>(0,sa.jsx)("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:(0,sa.jsx)("path",{d:"M12 2C8.13 2 5 5.13 5 9C5 14.25 12 22 12 22C12 22 19 14.25 19 9C19 5.13 15.87 2 12 2ZM12 11.5C10.62 11.5 9.5 10.38 9.5 9C9.5 7.62 10.62 6.5 12 6.5C13.38 6.5 14.5 7.62 14.5 9C14.5 10.38 13.38 11.5 12 11.5Z",fill:"#38bdf8"})}));var Ar=require("react/jsx-runtime"),su=e=>(0,Ar.jsxs)("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[(0,Ar.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),(0,Ar.jsx)("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));var fe=require("react/jsx-runtime"),Wh={APROVADO:ru,EM_ANDAMENTO:iu,REJEITADO:su},aa={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)]"},Xh={APROVADO:"bg-green-50",EM_ANDAMENTO:"bg-turquoise-50",REJEITADO:"bg-red-50"},lu=({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let{t:a}=(0,au.useTranslation)(),{toast:s}=lt(),{updateNodeData:l,getNodes:c,setNodes:d}=(0,_t.useReactFlow)(),{inProgress:u,fromNode:f}=(0,_t.useConnection)(),{mode:m,isReadOnly:y,onSubprocessValidationClick:E,reconnectingEdgeId:p}=q(),{getTaskStatus:g}=Ko(),h=u&&(f==null?void 0:f.id)!==e||!!p,x=g(e),N=t.variant==="SUBPROCESS",b=t.variant==="SERVICE_TASK",T=!!t.variant&&!N&&!b||!!x,v=!!t.attribute||N||b,A=(0,Ir.useCallback)(M=>{let B=T||v?80:40,G=M.split(`
41
- `),k=G.reduce((U,X)=>Math.max(U,X.length),0),O=G.length,Y=Math.max(Ao.MIN_WIDTH,k*7+64),F=Math.max(Ao.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,T,v]),C=(0,Ir.useCallback)(M=>{let V=M.trim(),D=t.label||"";if(V===D)return;let I=V,B=c();if(!(V&&V!=="")){I=is(B,a("bpmn.task.label.prefix")),l(e,{label:I}),A(I),s({variant:"warning",content:(0,fe.jsxs)(fe.Fragment,{children:[a("bpmn.task.feedback.label_empty.prefix")," ",(0,fe.jsx)("strong",{children:I})]})});return}let k=Fn(I,B);k===D||(l(e,{label:k}),A(k),k!==I&&s({variant:"warning",content:(0,fe.jsxs)(fe.Fragment,{children:[a("bpmn.task.feedback.label_already_exists.prefix")," ",(0,fe.jsx)("strong",{children:V})," ",a("bpmn.task.feedback.label_already_exists.middle")," ",(0,fe.jsx)("strong",{children:k})]})}))},[t.label,c,e,a,l,A,s]),P=(0,Ir.useCallback)(M=>{A(M)},[A]),R=(0,Ir.useCallback)(()=>{s({variant:"error",content:a("bpmn.task.feedback.invalid_first_character")})},[a,s]),S=x?Wh[x]:null,L=t.variant?qr[t.variant].icon:null,K=t.attribute?Zr[t.attribute].icon:null,j=()=>t.hasError?aa.error:x?aa[x]:y?aa.default:"",Q=()=>{var M;return r&&(M=Xh[x])!=null?M:""},z=()=>{E==null||E({id:e,type:"sub_process",label:t.label})};return(0,fe.jsxs)("div",{className:H("relative w-full h-full min-w-44 min-h-24 flex flex-col items-stretch justify-stretch bg-white border-2 border-grey-400 hover:border-grey-500 rounded-md hover:shadow-md transition-colors duration-75",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:Ao.MIN_WIDTH,height:n!=null?n:Ao.MIN_HEIGHT},children:[(0,fe.jsx)("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:(0,fe.jsx)(je,{value:t.label,maxLength:60,className:H(Q(),{"py-10 px-8":T||v}),onChange:C,onInput:P,onInvalidFirstCharacter:R})}),L&&(0,fe.jsx)("div",{className:H("absolute flex items-center p-1",N||b?"bottom-0 left-1/2 -translate-x-1/2":"top-0 left-0"),children:(0,fe.jsx)(L,{size:b?20:16,className:H(t.hasError?"text-red-500":"text-grey-500",N&&"cursor-pointer"),onClick:N?z:void 0})}),K&&(0,fe.jsx)("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:(0,fe.jsx)("div",{className:H("flex items-center w-16 p-1",N||b?"justify-between":"justify-center"),children:(0,fe.jsx)(K,{size:16,className:H(t.hasError?"text-red-500":"text-grey-500")})})}),S&&(0,fe.jsx)("div",{className:"absolute top-0 right-0 flex items-center p-1",children:(0,fe.jsx)(S,{})}),(0,fe.jsx)(ct,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),m==="edit"&&(0,fe.jsx)(Lt,{nodeId:e,isVisible:!i&&r,minWidth:Ao.MIN_WIDTH,minHeight:Ao.MIN_HEIGHT}),(!u||h)&&(0,fe.jsxs)(fe.Fragment,{children:[(0,fe.jsx)(ne,{type:"target",position:_t.Position.Left,id:"left",className:H({"task-handle":h})}),(0,fe.jsx)(ne,{type:"target",position:_t.Position.Right,id:"right",className:H({"task-handle":h})}),(0,fe.jsx)(ne,{type:"target",position:_t.Position.Top,id:"top",className:H({"task-handle":h})}),(0,fe.jsx)(ne,{type:"target",position:_t.Position.Bottom,id:"bottom",className:H({"task-handle":h})})]}),!u&&(0,fe.jsxs)(fe.Fragment,{children:[(0,fe.jsx)(ot,{type:"source",position:_t.Position.Left,id:"left",nodeId:e,nodeType:"TASK"}),(0,fe.jsx)(ot,{type:"source",position:_t.Position.Right,id:"right",nodeId:e,nodeType:"TASK"}),(0,fe.jsx)(ot,{type:"source",position:_t.Position.Top,id:"top",nodeId:e,nodeType:"TASK"}),(0,fe.jsx)(ot,{type:"source",position:_t.Position.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})};var la=require("@xyflow/react");var yo=require("react/jsx-runtime"),cu=({id:e,data:t})=>(0,yo.jsxs)(yo.Fragment,{children:[(0,yo.jsx)("div",{className:"relative w-full h-full min-w-32 min-h-16 flex items-center justify-center bg-white border-2 border-red-400 rounded-sm overflow-hidden",children:t.label}),(0,yo.jsx)(ct,{nodeId:e,nodeType:"UNSUPPORTED"}),(0,yo.jsx)(ne,{type:"source",position:la.Position.Right}),(0,yo.jsx)(ne,{type:"target",position:la.Position.Left})]});var Ge=require("@xyflow/react"),ss=require("react");var Ne=require("react/jsx-runtime"),LA={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:Ge.MarkerType.Arrow},data:{label:""}},du=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var G;let{zoom:c}=(0,Ge.useViewport)(),{updateEdgeData:d}=(0,Ge.useReactFlow)(),{isMultipleSelection:u,mode:f,instanceId:m}=q(),y=f!=="edit",[E,p]=(0,ss.useState)(!1),{reconnectingHandle:g,cursorPosition:h,hoveredNodeId:x,reconnectingSide:N,isValidReconnection:b,handleReconnectStart:T}=Ui({edgeId:e,source:t,target:o,instanceId:m,isReadOnly:y}),v=(0,Ge.useInternalNode)(t),A=(0,Ge.useInternalNode)(o),{sx:C,sy:P,tx:R,ty:S,sourcePos:L,targetPos:K}=(0,ss.useMemo)(()=>{var oe,le;if(!v||!A)return{sx:0,sy:0,tx:0,ty:0,sourcePos:Ge.Position.Left,targetPos:Ge.Position.Right};let k=An(v,A),O=s?i:k.sourcePos,Y=l?a:k.targetPos,F=(Z,ve,ye)=>{var ee,xe,Ce,Re,Je,wt;let{x:Ie,y:J}=Z.internals.positionAbsolute,de=(Ce=(xe=(ee=Z.measured)==null?void 0:ee.width)!=null?xe:Z.width)!=null?Ce:0,re=(wt=(Je=(Re=Z.measured)==null?void 0:Re.height)!=null?Je:Z.height)!=null?wt:0;switch(ve){case Ge.Position.Top:return{x:Ie+de*ye,y:J};case Ge.Position.Bottom:return{x:Ie+de*ye,y:J+re};case Ge.Position.Left:return{x:Ie,y:J+re*ye};case Ge.Position.Right:return{x:Ie+de,y:J+re*ye};default:return{x:Ie+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=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,N&&(O=N)):g==="target"&&h&&(ie=h.x,W=h.y,N&&(Y=N)),{sx:$,sy:te,tx:ie,ty:W,sourcePos:O,targetPos:Y}},[v,A,s,l,i,a,g,h,N,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!v||!A)return null;let[j,Q,z]=(0,Ge.getSmoothStepPath)({sourceX:C,sourceY:P,targetX:R,targetY:S,sourcePosition:L,targetPosition:K}),M=r||(v==null?void 0:v.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(0,Ne.jsx)(Ne.Fragment,{children:(0,Ne.jsxs)("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":M}),onDoubleClick:()=>!y&&p(!0),children:[(0,Ne.jsx)("path",{d:j,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),(0,Ne.jsxs)("g",{className:H("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":M}),children:[(0,Ne.jsx)(Ge.BaseEdge,{id:e,path:j,interactionWidth:0,markerEnd:`url(#${V})`,strokeDasharray:4,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||g&&x&&!b,"stroke-green-500":g&&x&&b,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":M&&!(n!=null&&n.hasError)&&!g})}),(0,Ne.jsxs)(Ge.EdgeLabelRenderer,{children:[(0,Ne.jsxs)("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${Q}px, ${z}px)`},children:[r&&!u&&(0,Ne.jsx)(On,{sx:C,sy:P,tx:R,ty:S,hasLabel:!!((G=n==null?void 0:n.label)!=null&&G.trim()),children:(0,Ne.jsx)(Dn,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),D&&(0,Ne.jsx)(je,{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&&(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${C}px, ${P}px)`},children:(0,Ne.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:g==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:g==="source"?.6:.3,className:"pointer-events-none"}),(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!g||g!=="source","cursor-not-allowed":g==="source"&&x&&!b,"cursor-grabbing":g==="source"&&(!x||b)}),onMouseDown:k=>T("source",k.nativeEvent)})]})}),(0,Ne.jsx)("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${R}px, ${S}px)`},children:(0,Ne.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:g==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:g==="target"?.6:.3,className:"pointer-events-none"}),(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!g||g!=="target","cursor-not-allowed":g==="target"&&x&&!b,"cursor-grabbing":g==="target"&&(!x||b)}),onMouseDown:k=>T("target",k.nativeEvent)})]})})]})]})]})]})})};var sn=require("@xyflow/react"),Cr=require("react/jsx-runtime"),uu=({toX:e,toY:t,fromNode:o})=>{var u,f;if(!o)return null;let{internals:{positionAbsolute:{x:n,y:r}},measured:i}=o,a=(u=i.width)!=null?u:0,s=(f=i.height)!=null?f:0,c=[{x:n,y:r+s/2,pos:sn.Position.Left},{x:n+a,y:r+s/2,pos:sn.Position.Right},{x:n+a/2,y:r,pos:sn.Position.Top},{x:n+a/2,y:r+s,pos:sn.Position.Bottom}].reduce((m,y)=>{let E=Math.hypot(e-m.x,t-m.y);return Math.hypot(e-y.x,t-y.y)<E?y:m}),[d]=(0,sn.getStraightPath)({sourceX:c.x,sourceY:c.y,targetX:e,targetY:t});return(0,Cr.jsxs)("g",{className:"group",children:[(0,Cr.jsx)("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d}),(0,Cr.jsx)("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})};var bt=require("@xyflow/react"),pu=require("lodash"),Sr=require("react");var ke=require("react/jsx-runtime"),fu=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{var v;let{updateNodeData:i,getNodes:a}=(0,bt.useReactFlow)(),{mode:s,isReadOnly:l}=q(),{inProgress:c,fromNode:d}=(0,bt.useConnection)(),u=c&&(d==null?void 0:d.id)!==e,[f,m]=(0,Sr.useState)(!1),y=a(),E=!r,p=!E&&((v=y.find(A=>A.id===r))==null?void 0:v.selected),g=(0,Sr.useMemo)(()=>(0,pu.orderBy)([...y.filter(A=>A.parentId===e&&A.type==="LANE")],"position.y","asc"),[y,e]),h=E?Ha.MIN_WIDTH:ae.MIN_WIDTH,x=(0,Sr.useMemo)(()=>{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)+ae.MIN_HEIGHT}return ae.MIN_HEIGHT},[E,g]),N=A=>{i(e,{label:A})},b=()=>{m(!0)},T=()=>{m(!1)};return(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsxs)("div",{className:H("flex h-full min-h-64 w-full min-w-[50rem] hover:shadow-md bg-white outline outline-2 outline-grey-400",{"pointer-events-none":l,"outline-offset-0 outline-blue-500 shadow-sm":(o||p)&&!l}),children:[(0,ke.jsx)("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:(0,ke.jsx)("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:(0,ke.jsx)(je,{value:t.label,className:"w-full h-full self-auto",contentClassName:H({"whitespace-nowrap":f}),isEditing:f,onBlur:T,onChange:N})})}),(0,ke.jsx)("div",{className:"flex-1"})]}),(0,ke.jsx)(ct,{nodeId:e,nodeType:"LANE",isChild:!E}),s==="edit"&&(0,ke.jsx)(Lt,{nodeId:e,isVisible:!n&&o,minWidth:h,minHeight:x,offset:10}),!c&&(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsx)(ne,{type:"source",position:bt.Position.Left,id:"left"}),(0,ke.jsx)(ne,{type:"source",position:bt.Position.Right,id:"right"}),(0,ke.jsx)(ne,{type:"source",position:bt.Position.Top,id:"top"}),(0,ke.jsx)(ne,{type:"source",position:bt.Position.Bottom,id:"bottom"})]}),(!c||u)&&(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsx)(ne,{type:"target",position:bt.Position.Left,id:"left",className:H({"annotation-handle":u})}),(0,ke.jsx)(ne,{type:"target",position:bt.Position.Right,id:"right",className:H({"annotation-handle":u})}),(0,ke.jsx)(ne,{type:"target",position:bt.Position.Top,id:"top",className:H({"annotation-handle":u})}),(0,ke.jsx)(ne,{type:"target",position:bt.Position.Bottom,id:"bottom",className:H({"annotation-handle":u})})]})]})};var mu={START_EVENT:nu,END_EVENT:Qd,TASK:lu,GATEWAY:jd,ANNOTATION:Zd,LANE:fu,UNSUPPORTED:cu},gu={SEQUENCE_EDGE:Td,MESSAGE_EDGE:du,ANNOTATION_EDGE:fd},hu="#fafafa",yu="#bebebe",xu=1,Eu=10,_u="bottom-left",ca=.05,bu=5,Tu=150,vu=100,Nu=ca,wu=1,Au={x:0,y:0,zoom:.75},Iu=1,Cu=2,Uh={[Iu]:4,[Cu]:2},Mr=[Iu,Cu],da=Mr.reduce((e,t)=>e|Uh[t],0);var Wn=()=>{let{setViewport:e}=(0,as.useReactFlow)(),t=(0,as.useStoreApi)();return{fitToNodes:(0,Su.useCallback)(n=>{let{width:r,height:i}=t.getState();if(i<=0||r<=0)return;let a=Ua(n);if(!a)return;let s=$a({bounds:a,canvasHeight:i,canvasWidth:r,minZoom:Nu,maxZoom:wu,offsetX:Tu,offsetY:vu});e(s)},[t,e])}};var Mu=require("@xyflow/react");var kt=()=>{let{getEdges:e,getNodes:t}=(0,Mu.useReactFlow)(),{lastElementId:o}=q(),n=()=>{let i=t(),a=e(),s=wd(i,a);return Math.max(s,o)};return{getLastId:n,getNextId:()=>n()+1}};var Xn=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n}=(0,Pu.useReactFlow)(),{getLastId:r}=kt(),{fitToNodes:i}=Wn(),{setLastElementId:a}=q(),s=(0,ua.useCallback)(async(c="")=>{let{nodes:d,edges:u,lastElementId:f}=await Gd(c);i(d),o(d),n(u),a(f)},[o,n,a,i]),l=(0,ua.useCallback)(()=>{let c=e(),d=t(),u=r();return Hd(c,d,u)},[e,t,r]);return{importFromMxGraph:s,exportToMxGraph:l}};var pa=require("react"),$h=500,ls=()=>{let{isInitialized:e,onElementChanges:t}=q(),{exportToMxGraph:o}=Xn(),n=(0,Lu.useDebouncedCallback)(()=>{if(!e)return;let a=o();t==null||t(a)},$h),r=(0,pa.useCallback)(a=>{a.every(c=>c.type==="select")||a.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=(0,pa.useCallback)(a=>{a.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var ku=({setEdges:e,saveHistory:t})=>{let{getNode:o,getEdges:n,getNodes:r,getInternalNode:i}=(0,cs.useReactFlow)(),{emitElementChanges:a}=ls(),s=(0,to.useRef)(null),{getNextId:l}=kt(),c=(0,to.useCallback)(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 Ks(x).isValid},[o,n,r]),d=(0,to.useCallback)(p=>{var x,N;let g=l(),h=i(p.source);if(h){let b=i(p.target),T=b?b.internals.positionAbsolute.x+((x=b.measured.width)!=null?x:0)/2:0,v=b?b.internals.positionAbsolute.y+((N=b.measured.height)!=null?N:0)/2:0,A=vd(h,T,v),C=(b==null?void 0:b.type)==="ANNOTATION"||(h==null?void 0:h.type)==="ANNOTATION",P=C?Vn:Pt,R;if(!C&&b&&p.targetHandle){let K=Ki(A),j=Ki(p.targetHandle),{x:Q,y:z}=Qs(h,A),{x:M,y:V}=Qs(b,p.targetHandle),I=Wi(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?{}:Pt.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=(0,to.useCallback)((p,g)=>{s.current=g.id},[]),f=(0,to.useCallback)(()=>{s.current=null},[]),m=(0,to.useCallback)((p,g)=>{let h=o(g.source),x=o(g.target);if(!h||!x){s.current=null;return}let N={sourceNodeId:h.id,targetNodeId:x.id,sourceNodeType:h.type,targetNodeType:x.type,nodes:r(),edges:n(),reconnectingEdgeId:p.id};if(!Ks(N).isValid){s.current=null;return}let T=(0,cs.reconnectEdge)(p,g,n()).map(v=>v.id===p.id?w(_({},v),{data:w(_({},v.data),{points:void 0})}):v);e(T),t("forceSave",{nodes:r(),edges:T}),s.current=null,a()},[o,r,n,e,a,t]),y=(0,to.useCallback)(p=>{s.current=p},[]),E=(0,to.useCallback)(()=>{s.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:m,onReconnectStart:u,onReconnectEnd:f,setReconnectingEdge:y,clearReconnectingEdge:E}};var Yu=require("@produto-lecom/lecom-ui"),Fu=require("@xyflow/react"),Bt=require("react");var Pr=(e=[])=>e.filter(t=>t.type==="START_EVENT"),an=(e=[])=>e.filter(t=>t.type==="END_EVENT"),Vo=(e=[])=>e.filter(t=>t.type==="TASK")||[],Ru=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"});var ds=(e=[])=>e.filter(t=>t.type==="GATEWAY"),Du=(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),Lr=(e,t=[])=>t.filter(o=>o.target===e),Ou=(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"},Vu=(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},Hu=e=>e?/[^\s]/.test(e.trim()):!1,we=e=>{let{isValid:t,nodeIds:o,edgeIds:n}=e;return{isValid:t,nodeIds:!t&&o&&o.length>0?o:[],edgeIds:!t&&n&&n.length>0?n:[]}},xo=(e=[],t)=>{if(!e||e.length===0)return{isValid:!0,invalidIds:[]};let o=e.filter(n=>!t(n));return{isValid:o.length===0,invalidIds:o.map(n=>n.id)}},Gu=(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 kr=[{id:"start_event_not_found",validate:e=>{let t=Pr(e.nodes);return we({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=an(e.nodes);return we({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Pr(e.nodes),o=t.length===1;if(t.length===0)return we({isValid:!0});if(!o)return we({isValid:!1,nodeIds:t.map(i=>i.id)});let n=Tt(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(a=>a.id),...n.map(a=>a.target)];return we({isValid:!1,nodeIds:[...new Set(i)]})}return we({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=Vo(e.nodes),o=xo(t,n=>Tt(n.id,e.edges).length<=2);return we({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=Vo(e.nodes),o=xo(t,n=>!!n.label&&n.label.trim()!=="");return we({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=Vo(e.nodes),n=xo(o,r=>!r.label||r.label.length<=60);return we({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=Vo(e.nodes),o=new Map;for(let r of t){if(!r.label)continue;let i=r.label.trim();i&&(o.has(i)||o.set(i,[]),o.get(i).push(r))}let n=[];for(let[,r]of o.entries())r.length>1&&r.forEach(i=>n.push(i.id));return we({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=ds(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 we({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Pr(e.nodes),...an(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 we({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=an(e.nodes),o=[],n=[];for(let r of t){let i=Lr(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 we({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=Du(e.nodes),o=xo(t,r=>Tt(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>Tt(r,e.edges).map(i=>i.id));return we({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=Vo(e.nodes),o=xo(t,n=>!n.label||Hu(n.label));return we({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var a,s;if(!((a=e==null?void 0:e.nodes)!=null&&a.length)||!((s=e==null?void 0:e.edges)!=null&&s.length))return we({isValid:!0});let t=an(e.nodes)[0];if(!t)return we({isValid:!0});let o=Lr(t.id,e.edges);if(!o.length)return we({isValid:!0});let r=Vo(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=xo(r,l=>!Ou(l.id,e));return we({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=Vo(e.nodes),o=an(e.nodes)[0];if(!o)return we({isValid:!0});let n=t.filter(l=>{let c=Lr(l.id,e.edges),d=Tt(l.id,e.edges),u=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 u&&f}),r=Lr(o.id,e.edges),i=r.length>1,a=r.map(l=>l.source),s={isValid:n.length===0&&!i,nodeIds:[...n.map(l=>l.id),...i?a:[]]};return we(s)}},{id:"gateway_flow_to_event",validate:e=>{let t=ds(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 we({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=ds(e.nodes),o=xo(t,n=>Tt(n.id,e.edges).length>=1);return we({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Pr(e.nodes),...an(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 we({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=Ru(e.nodes),o=xo(t,n=>!Vu(n.id,e));return we({isValid:o.isValid,nodeIds:o.invalidIds})}}];var Bu=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of kr){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}},zu=async(e,t)=>{var n;let o=[];try{let r=await e(),i=(n=r==null?void 0:r.filter(a=>a.area==="DIAGRAM"))!=null?n:[];return i.length===0?{isValid:!0,errors:[]}:(i.forEach(a=>{var l,c;let s=(c=(l=a==null?void 0:a.detail)==null?void 0:l.phases)==null?void 0:c.map(d=>d.diagramCellId);o.push({id:a.code,message:a.code,nodeIds:s,edgeIds:[]})}),{isValid:!1,errors:o})}catch(r){let i=[],a=(s,l)=>{let c=t.filter(d=>{var u;return((u=d.data)==null?void 0:u.variant)===s}).map(d=>d.id);c.length>0&&i.push({id:l,message:l,nodeIds:c,edgeIds:[]})};return a("SUBPROCESS","cannot_validate_subprocess_reference"),a("SERVICE_TASK","service_task_automation_status_unavailable"),{isValid:!1,errors:i}}};var ln=require("react/jsx-runtime"),Wu=()=>{let{t:e}=(0,Yu.useTranslation)(),{toast:t}=lt(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=(0,Fu.useReactFlow)(),{validateCustomDiagram:a}=q(),[s,l]=(0,Bt.useState)(!1),c=(0,Bt.useRef)(!1),d=(0,Bt.useRef)(!1),u=(0,Bt.useCallback)(async p=>{let g=Gu(p.nodes,p.edges),h=Bu(g),x=p.nodes.filter(({type:b,data:T})=>b==="TASK"&&((T==null?void 0:T.variant)==="SUBPROCESS"||(T==null?void 0:T.variant)==="SERVICE_TASK"));if(a&&x.length>0){let b=await zu(a,x);h={isValid:h.isValid&&b.isValid,errors:[...h.errors,...b.errors]}}let N=h.errors.map(b=>w(_({},b),{message:e(`validation.errors.${b.id}`)}));return s||l(!0),{isValid:h.isValid,errors:N}},[s,e,a]),f=(0,Bt.useCallback)((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:(0,ln.jsxs)("div",{className:"flex flex-col gap-1",children:[!p.isValid&&(0,ln.jsx)("span",{className:"body-small-500",children:e("validation.errors.subtitle")}),(0,ln.jsx)("ul",{className:"list-disc list-inside max-h-40 overflow-y-auto",children:p.isValid?(0,ln.jsx)("li",{children:e("validation.success.message")}):p.errors.map(S=>(0,ln.jsx)("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 N=[...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(),T=i(),v=new Set(N),A=new Set;p.errors.forEach(S=>{var j,Q;let L=kr.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=>{T.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)}),T.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=p.errors.find(z=>{var M;return(M=z.nodeIds)==null?void 0:M.includes(S)}))==null?void 0:L.id;((K=kr.find(z=>z.id===j))==null?void 0:K.highlightRelatedEdges)!==!1&&T.forEach(z=>{z.source===S&&P.has(z.target)&&(v.add(z.target),A.add(z.id)),z.target===S&&C.has(z.source)&&(v.add(z.source),A.add(z.id))})}}),v.size>0&&o(S=>S.map(L=>w(_({},L),{data:w(_({},L.data),{hasError:v.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]),m=(0,Bt.useCallback)(()=>{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=(0,Bt.useCallback)(()=>{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=(0,Bt.useCallback)(()=>c.current,[]);return{validateDiagram:u,handleValidationComplete:f,clearValidation:m,dismissValidationPanel:y,isAutoValidationEnabled:s,getIsClearingValidation:E}};var $u=require("@xyflow/react"),Ku=require("@produto-lecom/lecom-ui"),qu=require("react");var Kh=15,Xu="bpmn:selection",qh=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},Uu=e=>{if(!qh(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},Zu=({offset:e=Kh,saveHistory:t})=>{let{t:o}=(0,Ku.useTranslation)(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=(0,$u.useReactFlow)(),{getNextId:s}=kt(),{mode:l,containerRef:c}=q();(0,qu.useEffect)(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let u=m=>{var b,T;if(!Uu(m)||!d.contains(document.activeElement))return;let E=n(),p=i(),g=E.filter(v=>v.selected);if(!g.length)return;m.preventDefault(),m.stopPropagation();let h=p.filter(v=>g.some(A=>A.id===v.source)&&g.some(A=>A.id===v.target)),N=JSON.stringify({nodes:g,edges:h});(b=m.clipboardData)==null||b.setData(Xu,N),(T=m.clipboardData)==null||T.setData("text/plain",`BPMN Selection: ${g.length} nodes`)},f=m=>{var R,S;if(!Uu(m)||!d.contains(document.activeElement))return;let E=(R=m.clipboardData)==null?void 0:R.getData(Xu);if(!E)return;m.preventDefault(),m.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=[],N=p.nodes.filter(L=>Po(L.type,h));if(N.length===0)return;let b=s(),T=N.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=Fn(z||o("bpmn.task.label.prefix"),[...h,...x]);j.data=w(_({},L.data),{label:M})}return x.push(j),j}),v=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})),...T],P=[...i().map(L=>w(_({},L),{selected:!1})),...v];r(A),a(P),t("forceSave",{nodes:A,edges:P})};return d.addEventListener("copy",u,!0),d.addEventListener("paste",f,!0),()=>{d.removeEventListener("copy",u,!0),d.removeEventListener("paste",f,!0)}},[n,r,i,a,s,e,o,t,l,c])};var Ju=require("@produto-lecom/lecom-ui"),Qu=require("@xyflow/react");var ju=require("react");var Zh=50,ep=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let{draggableNode:r,setDraggableNode:i}=Yn(),{t:a}=(0,Ju.useTranslation)(),{getInternalNode:s,getNodes:l,getEdges:c,screenToFlowPosition:d}=(0,Qu.useReactFlow)(),{getNextId:u}=kt(),{setIsDragging:f}=q(),{getInternalNodes:m}=Qi(),{rebuildIndex:y,forceRebuildIndex:E}=Li(),[p,g]=(0,ju.useState)(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(" ")})})})},N=(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=tr(M,O);if(!Y){x();return}if(Xo({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=tr(M,B);if(!G){x();return}if(Xo({parentId:G.id,nodes:e,includeTypes:["LANE"]})){x();return}x(G.id)},b=M=>{let V=s(M.id),D=M.type==="LANE"&&Xo({parentId:M.id,nodes:e,includeTypes:["LANE"]});N(V,D)},T=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,A=(M,V)=>{let D=0;for(let I of V){if(I.id===M||I.parentId||I.type==="LANE")continue;let B=Ct(I),G=B.y+B.h;D=Math.max(D,G)}return D+Zh},C=(M,V)=>{if(!Cs(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}};N(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=Ms(M,V,I),I=Do(I),I=Uo(B,I),T(I);if(M.type==="LANE"){if(Xo({parentId:V.id,nodes:I,excludeTypes:["LANE"]})){let W=Si(V),oe=50,le=50;return I.map(Z=>{var ve,ye;return Z.id===M.id?w(_({},Z),{position:{x:(ve=p==null?void 0:p.x)!=null?ve:W.x+oe,y:(ye=p==null?void 0:p.y)!=null?ye: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:ae.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=Do(I),I=C(B,I),I}if(Xo({parentId:V.id,nodes:I,includeTypes:["LANE"]})){let X;if(M.parentId){let $=s(M.parentId),{x:te,y:ie}=Ct($);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=Uo(B,I),I}let O=Wa(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=Ms(Y,V,I),I=Do(I),I=Uo(B,I),I},K=M=>{if(M.preventDefault(),!(r!=null&&r.type))return;if(!Po(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},I=u(),B={id:String(I),type:r.type,position:V,measured:D,data:{label:r.type==="TASK"?is(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=tr(k,F),X=[...O.map(W=>w(_({},W),{selected:!1})),G];U&&(X=L(G,U,X)),X=er(X),Y&&!U&&(X=C(G.id,X)),X=T(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),Vn):_(_({},W),Pt);ie=te.concat(oe),o(ie)}n("forceSave",{nodes:X,edges:ie}),f(!1),i(null)},j=async(M,V,D)=>{let I=[...m()],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=tr(Y,U);if(X){if(F&&Xo({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=v(I);let G=D.filter(O=>O.type==="LANE"&&!O.parentId).map(O=>O.id);for(let O of G)Cs(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=Uo(Y,I)}I=er(I),I=T(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=ae.MIN_HEIGHT;else if(I){let Z=(X=(U=M.measured)==null?void 0:U.height)!=null?X:ae.MIN_HEIGHT;k=((te=($=D.measured)==null?void 0:$.height)!=null?te:ae.MIN_HEIGHT)-Z,k=Math.max(ae.MIN_HEIGHT,k)}else k=B.length>0?B.reduce((Z,ve)=>{var ye,Ie;return Z+((Ie=(ye=ve.measured)==null?void 0:ye.height)!=null?Ie:0)},0)+He:Math.max(ae.MIN_HEIGHT,(W=(ie=D.measured)==null?void 0:ie.height)!=null?W:0);let{x:O,y:Y}=Ct(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=Do(V),V};return{onDragOver:P,onDragLeave:R,onDrop:K,onNodeDrag:S,onNodeDragStart:Q,onNodeDragStop:j}};var tp=require("@xyflow/react"),op=require("@produto-lecom/lecom-ui"),np=require("react");var Jh=30,Qh=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},jh=e=>!Qh(e.target),rp=({offset:e=Jh,saveHistory:t})=>{let{t:o}=(0,op.useTranslation)(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=(0,tp.useReactFlow)(),{getNextId:s}=kt(),{mode:l,containerRef:c}=q();(0,np.useEffect)(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let u=f=>{if(d.contains(document.activeElement)&&f.ctrlKey&&f.key.toLowerCase()==="d"&&jh(f)){f.preventDefault(),f.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=>Po(P.type,y));if(x.length===0)return;let N=E.filter(P=>x.some(R=>R.id===P.source)&&x.some(R=>R.id===P.target)),b=s(),T=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=Fn(K||o("bpmn.task.label.prefix"),[...y,...h]);S.data=w(_({},P.data),{label:j})}return h.push(S),S}),v=N.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})),...T],C=[...E.map(P=>w(_({},P),{selected:!1})),...v];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])};var Dr=require("react"),ip=require("@xyflow/react");var ey=20,ty=50,Rr={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},oy=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",i=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||i},sp=e=>{let{getNodes:t}=(0,ip.useReactFlow)(),{mode:o,isMoveTool:n}=q(),r=(0,Dr.useRef)(0),i=(0,Dr.useRef)(new Map);(0,Dr.useEffect)(()=>{let a=s=>{if(o!=="edit"||!n||oy(s.target)||!Object.values(Rr).includes(s.key))return;let u=t().filter(h=>h.selected);if(u.length===0){i.current.clear();return}s.preventDefault();let f=Date.now(),m=f-r.current<500;r.current=f;let y=s.shiftKey?ty:ey,E=0,p=0;switch(s.key){case Rr.UP:p=-y;break;case Rr.DOWN:p=y;break;case Rr.LEFT:E=-y;break;case Rr.RIGHT:E=y;break}let g=u.map(h=>{let x=i.current.get(h.id);(!m||!x)&&(x={x:h.position.x,y:h.position.y});let N={x:x.x+E,y:x.y+p};return i.current.set(h.id,N),{id:h.id,dragging:!0,type:"position",position:N}});e&&e(g)};return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[t,e,o,n])};var up=require("@xyflow/react");var lp={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY","gateway-parallel":"GATEWAY","gateway-complex":"GATEWAY"},cp={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},ap=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],n=e.match(/(\[.*?\])/)||[],r=e.match(/(\{.*?\})/)||[],i=e.match(/(--.*|\|.*?\|)/i)||[],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}},ny=e=>{e=e||"";let t=e.trim().split(`
42
- `),o={},n=[];return t.forEach(r=>{r=r||"";let i=r.trim().split("-->");if(i.length!==2){console.warn("Invalid number of steps");return}let a=ap(i[0],o),s=ap(i[1],o);a&&s&&n.push({sourceId:a.step,targetId:s.step,label:a.edgeLabel||s.edgeLabel||""})}),{components:o,connections:n}},dp=e=>{let{components:t,connections:o}=ny(e);return{nodes:t,edges:o}};var us=()=>{let{setNodes:e,setEdges:t}=(0,up.useReactFlow)(),{fitToNodes:o}=Wn(),{getNextId:n}=kt();return{importFromLia:i=>{let a=typeof i=="string"?i:i.diagramXml||"",{nodes:s,edges:l}=dp(a),c=[],d=new Map,u=!1,f=n();for(let[p,g]of Object.entries(s)){let h=String(f++),x=lp[g.type],N=cp[g.type];x==="START_EVENT"&&(u=!0),d.set(p,h);let b=ue[x].MIN_WIDTH,T=ue[x].MIN_HEIGHT;c.push({id:h,type:x,data:{label:g.label||"",variant:N,attribute:""},position:{x:0,y:0},width:b,height:T,measured:{width:b,height:T}})}let m=[];for(let p of l){let g=w(_({},Pt),{id:String(f++),source:d.get(p.sourceId)||p.sourceId,target:d.get(p.targetId)||p.targetId});m.push(g)}if(!u&&c.length>0){let p=String(f++),g={id:p,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(g);let h=c[1];if(h){let x=w(_({},Pt),{id:String(f++),source:p,target:h.id});m.unshift(x)}}let{nodes:y,edges:E}=Yd(c,m);e(y),t(E),o(y)}}};var ps=require("react"),ry={origin:"*",debug:!1};function fs(e,t=ry){let{origin:o,debug:n}=t,r=(0,ps.useCallback)((i,a)=>{let s={event:i,data:a};window.parent.postMessage(s,o||"*")},[o]);return(0,ps.useEffect)(()=>{if(!e)return;let i=a=>{let s=a.data;if(!(s!=null&&s.event)||(s==null?void 0:s.data)===void 0)return;let{event:l,data:c}=s,d;if(Array.isArray(c)){let[,u]=c;d=u.data}else d=c;n&&(console.debug("[postMessage] received:",s),console.debug("[postMessage] eventData:",d)),l&&e[l]&&e[l](d)};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[e,n]),{sendMessage:r}}var pp=require("@xyflow/react"),Eo=require("react");var fp=()=>{let e=(0,pp.useNodesInitialized)(),{initialDiagram:t,isNewDiagram:o,setIsInitialized:n,onElementChanges:r}=q(),{importFromMxGraph:i,exportToMxGraph:a}=Xn(),{sendMessage:s}=fs(),l=(0,Eo.useRef)(t),c=(0,Eo.useRef)(r),d=(0,Eo.useRef)(a);(0,Eo.useEffect)(()=>{c.current=r},[r]),(0,Eo.useEffect)(()=>{d.current=a},[a]),(0,Eo.useEffect)(()=>{t&&(i(t),l.current=t)},[t,i]),(0,Eo.useEffect)(()=>{if(!e)return;(async()=>{var f;if(await Ur(),n(!0),s("INIT_MODELER",l.current),!o){let m=d.current();(f=c.current)==null||f.call(c,m)}})()},[e,o,n,s])};var fa=require("react"),mp=require("@xyflow/react");function gp(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=Ko(),{getEdges:n}=(0,mp.useReactFlow)(),r=ei(),i=(0,fa.useCallback)(s=>{if(!(s!=null&&s.activities))return;e(s.activities);let l=s.activities.map(d=>d.diagramId),c=n();o(c,l),setTimeout(()=>{r()},0)},[e,o,n,r]),a=(0,fa.useCallback)(()=>{t(),setTimeout(()=>{r()},0)},[t,r]);return{handleTasksStatus:i,handleClearTaskStatus:a}}var yp=require("@xyflow/react"),nt=require("react"),xp=require("use-debounce");var sy=500,hp=100,Ep=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=(0,yp.useReactFlow)(),{mode:i,containerRef:a}=q(),[s,l]=(0,nt.useState)({history:[],currentStep:0}),{history:c,currentStep:d}=s,u=d>0,f=d<c.length-1,m=(0,nt.useCallback)((v,A)=>{n(v[A].nodes),r(v[A].edges)},[n,r]),y=(0,nt.useCallback)(()=>{if(d>0){let v=d-1;l(A=>w(_({},A),{currentStep:v})),m(c,v)}},[d,c,m]),E=(0,nt.useCallback)(()=>{if(d<c.length-1){let v=d+1;l(A=>w(_({},A),{currentStep:v})),m(c,v)}},[c,d,m]),p=(0,nt.useCallback)(v=>{l(A=>{let C=A.history[A.currentStep];if(C&&JSON.stringify(C)===JSON.stringify(v))return A;let S=[...A.history.slice(0,A.currentStep+1),v],L=S.length>hp?S.slice(S.length-hp):S;return{history:L,currentStep:L.length-1}})},[]),g=(0,nt.useCallback)((v,A)=>{let C=v.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:er(C),edges:P}},[]),h=(0,nt.useCallback)(()=>g(t(),o()),[t,o,g]),x=(0,xp.useDebouncedCallback)(()=>{let v=h();p(v)},sy),N=(0,nt.useCallback)((v,A)=>{if(!e)return;if(c.length===0){let R=h();l({history:[R],currentStep:0})}if(v==="forceSave"){if(A){p(g(A.nodes,A.edges));return}x();return}v.some(R=>R.type==="select")||v.some(R=>R.type==="position"&&R.dragging)||x()},[e,x,c.length,h,p,g]);(0,nt.useEffect)(()=>{if(e&&c.length===0){let v=h();l({history:[v],currentStep:0})}},[e,c.length,h]);let b=(0,nt.useCallback)(v=>{l({history:v||[],currentStep:0})},[]),T=(0,nt.useCallback)(()=>{l({history:[],currentStep:0})},[]);return(0,nt.useEffect)(()=>{if(i!=="edit")return;let v=a.current;if(!v)return;let A=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",A),()=>{v.removeEventListener("keydown",A)}},[y,E,i,a]),{history:c,undo:y,redo:E,canUndo:u,canRedo:f,saveHistory:N,resetHistory:b,clearHistory:T}};var bp=()=>{let{t:e}=(0,_p.useTranslation)(),[t,o,n]=(0,oo.useNodesState)([]),[r,i,a]=(0,oo.useEdgesState)([]),{getNodes:s,getNode:l}=(0,oo.useReactFlow)(),{toast:c}=lt(),d=(0,oo.useStoreApi)(),{instanceId:u,isInitialized:f,setIsConnecting:m,setIsMultipleSelection:y,onElementClick:E}=q(),{updateHelperLines:p,HelperLines:g}=Li(),{undo:h,redo:x,canUndo:N,canRedo:b,saveHistory:T}=Ep(f),{onNodeDrag:v,onDrop:A,onDragOver:C,onDragLeave:P,onNodeDragStop:R,onNodeDragStart:S}=ep({nodes:t,setNodes:o,setEdges:i,saveHistory:T}),{isValidConnection:L,onConnect:K,onReconnect:j,onReconnectStart:Q,onReconnectEnd:z,setReconnectingEdge:M,clearReconnectingEdge:V}=ku({setEdges:i,saveHistory:T}),{handleValidationComplete:D,clearValidation:I,dismissValidationPanel:B,validateDiagram:G,getIsClearingValidation:k}=Wu(),{importFromLia:O}=us(),{handleTasksStatus:Y,handleClearTaskStatus:F}=gp(),{clearPathEdges:U}=Ko(),{emitElementChanges:X,handleNodeChanges:$,handleEdgeChanges:te}=ls(),ie=ei();Zu({saveHistory:T}),rp({saveHistory:T}),fp();let W=(0,vt.useCallback)(()=>{o([]),i([]),U(),setTimeout(ie,0)},[o,i,U,ie]),{selectElements:oe,clearSelection:le}=Lo(),{importFromMxGraph:Z,exportToMxGraph:ve}=Xn(),{configureElement:ye,getConfigureElement:Ie}=Hi(),J=(0,vt.useCallback)(Ee=>{Ee!=null&&Ee.id&&oe([Ee.id])},[oe]),{sendMessage:de}=fs({LIA_CREATE_DIAGRAM:O,CLEAR_DIAGRAM:W,TASKS_STATUS:Y,CLEAR_TASKS_STATUS:F,EXTERNAL_TASK_SELECT:J}),re=(0,vt.useCallback)(()=>t.length+r.length,[t,r]);(0,vt.useEffect)(()=>(Qt.set(u,{importFromMxGraph:Z,exportToMxGraph:ve,selectElements:oe,clearSelection:le,configureElement:ye,getConfigureElement:Ie,getElementsCount:re,setReconnectingEdge:M,clearReconnectingEdge:V}),()=>{Qt.delete(u)}),[u,Z,ve,oe,le,ye,Ie,re,M,V]);let ee=(0,vt.useCallback)((Ee,he)=>{if(he.type!=="TASK"&&he.type!=="GATEWAY")return;let pe=Ie(he.id);pe&&(E==null||E(pe)),he.type==="TASK"&&de("SELECT_TASK",{id:he.id})},[Ie,E,de]),xe=(0,vt.useCallback)((Ee,he)=>{if(he.type!=="SEQUENCE_EDGE")return;let pe=l(he.source),De=l(he.target),{isFromStartEvent:pt,isGatewayToGateway:At,isActiviyToAndGateway:rt,isToEndEvent:Xt}=jr(pe,De);if(!(!pt&&!At&&!rt&&!Xt))return;let lo=Ie(he.id);lo&&(E==null||E(lo))},[Ie,l,E]),Ce=(0,vt.useCallback)(Ee=>{let he=p(Ee,t);n(he),T(Ee),k()||B(),$(Ee)},[t,n,T,k,B,p,$]),Re=(0,vt.useCallback)(Ee=>{a(Ee),T(Ee),k()||B(),te(Ee)},[a,T,k,B,te]);sp(Ce);let Je=(0,vt.useCallback)(({nodes:Ee,edges:he})=>{y(Ee.length+he.length>=2)},[y]);(0,oo.useOnSelectionChange)({onChange:Je});let wt=(0,vt.useCallback)(async({nodes:Ee})=>Ee.some(pe=>pe.type==="LANE"&&t.some(De=>De.parentId===pe.id))?(c({variant:"error",title:e("validation.errors.title"),content:e("editor.toolbar.delete_pool_lane_error")}),!1):!0,[t,e,c]),ao=()=>{T("forceSave"),X(),B()},Ft=()=>{m(!0)},Wt=()=>{m(!1),B()},ut=(0,vt.useCallback)(Ee=>{let he=new Set(Ee.filter(pe=>pe.type==="LANE"&&!!pe.parentId).map(pe=>pe.parentId));he.size!==0&&setTimeout(()=>{var pt,At;let pe=s(),De=new Map(pe.map(rt=>[rt.id,rt]));for(let rt of he){let Xt=$o(pe.filter(co=>co.type==="LANE"&&co.parentId===rt));if(Xt.length===0)continue;let bo=0;for(let co of Xt)De.set(co.id,w(_({},co),{position:{x:ae.HEADER_WIDTH,y:bo}})),bo+=(At=(pt=co.measured)==null?void 0:pt.height)!=null?At:0;let lo=De.get(rt);lo&&De.set(rt,w(_({},lo),{height:bo,measured:w(_({},lo.measured),{height:bo})}))}o(pe.map(rt=>{var Xt;return(Xt=De.get(rt.id))!=null?Xt:rt}))},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:v,onNodeDragStop:R,onNodeDragStart:S,onNodeClick:ee,onEdgeClick:xe,onDropCapture:ao,onConnectStart:Ft,onConnectEnd:Wt,onSelectionEnd:()=>setTimeout(()=>d.setState({nodesSelectionActive:!1}),0),onNodesChange:Ce,onEdgesChange:Re,onBeforeDelete:wt,onNodesDelete:ut},ui:{handleCloseValidationPanel:I},controls:{undo:h,redo:x,canUndo:N,canRedo:b},components:{HelperLines:g},actions:{saveHistory:T,selectElements:oe,clearSelection:le,exportToMxGraph:ve,validateDiagram:G,handleValidationComplete:D,setReconnectingEdge:M,clearReconnectingEdge:V}}};var Tp=require("@xyflow/react"),Ho=require("react");var ay=".react-flow__node, .react-flow__edge, .react-flow__node-toolbar";function vp(e,t,o){let[n,r]=(0,Ho.useState)(!1),i=(0,Ho.useRef)(null),{getViewport:a,setViewport:s}=(0,Tp.useReactFlow)(),l=(0,Ho.useCallback)(()=>{i.current=null,r(!1)},[]);return(0,Ho.useEffect)(()=>{let c=e.current;if(!c)return;let d=m=>{if(!Mr.some(E=>E===m.button)||t.current||o.current||(r(!0),!(m.target instanceof Element))||!m.target.closest(ay))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}},u=m=>{let y=i.current;if(y){if((m.buttons&da)===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&da)===0&&l()};return c.addEventListener("pointerdown",d,!0),window.addEventListener("pointermove",u),window.addEventListener("pointerup",f),window.addEventListener("pointercancel",l),window.addEventListener("blur",l),()=>{c.removeEventListener("pointerdown",d,!0),window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",l),window.removeEventListener("blur",l)}},[e,t,o,a,s,l]),n}var ma=require("react/jsx-runtime"),ms=({id:e,className:t})=>(0,ma.jsx)("marker",{id:e,className:H("react-flow__arrowhead",t),viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"7",markerHeight:"7",orient:"auto",markerUnits:"userSpaceOnUse",fill:"currentColor",stroke:"currentColor",children:(0,ma.jsx)("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});var cn=require("react/jsx-runtime"),Np=()=>(0,cn.jsx)("svg",{style:{position:"absolute",top:0,left:0},children:(0,cn.jsxs)("defs",{children:[(0,cn.jsx)(ms,{id:"sequence-edge-marker",className:"text-grey-500"}),(0,cn.jsx)(ms,{id:"sequence-edge-marker-hovered",className:"text-grey-800"}),(0,cn.jsx)(ms,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});var zo=require("@produto-lecom/lecom-ui");var Hr=require("@xyflow/react"),Be=require("@produto-lecom/lecom-ui"),ro=require("lucide-react"),_o=require("react");var Go=require("@produto-lecom/lecom-ui");var Or=(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))(Or||{});var hs=require("@produto-lecom/lecom-ui"),Dp=require("@xyflow/react");var wp=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 Ap({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);gs(i,`${o}.csv`)}var gs=(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 Ip(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}var aM={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},Cp={script:"SCRIPT",subprocess:"SUBPROCESS"},Sp={"marker-loop":"LOOP"},Mp={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL",inclusive:"EXCLUSIVE"};var dn=({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}}},cy=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:dn({cell:e,type:"START_EVENT"}),status:n,originalType:o}},dy=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=ue.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=ue.END_EVENT.MIN_HEIGHT,{node:dn({cell:e,type:"END_EVENT"}),status:n,originalType:o}},uy=(e,t)=>{let{id:o,subType:n,style:r}=e==null?void 0:e._attributes,i=Cp[n],a=t.get(o)||"",s=Sp[a]||"",l=s==="LOOP",c="imported";return!["script","none"].includes(n)&&!l&&(c="adapted"),e.mxGeometry._attributes.width=vo(e.mxGeometry._attributes.width||0,ue.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=vo(e.mxGeometry._attributes.height||0,ue.TASK.MIN_HEIGHT),{node:dn({cell:e,type:"TASK",variant:i,attribute:s}),status:c,originalType:r}},py=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=Mp[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:dn({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},fy=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:dn({cell:e,type:"LANE"}),status:"imported",originalType:t}},my=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=vo(e.mxGeometry._attributes.width||0,ue.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=vo(e.mxGeometry._attributes.height||0,ue.ANNOTATION.MIN_HEIGHT),{node:dn({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},Pp=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:dn({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},Lp=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return w(_({},Pt),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},kp={TASK:uy,GATEWAY:py,START_EVENT:cy,END_EVENT:dy,LANE:fy,ANNOTATION:my};var gy=e=>{let t=new Map,o=Object.values(Or),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=kp[l]||Pp,{node:d,status:u,originalType:f}=c(s,r);a.push(d),i.push({originalType:f,type:d.type,variant:d.data.variant,value:Ip(d.data.label),status:u})}return{nodes:a,governanceIdToNodeIdMap:t,summary:i}},hy=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>Lp(r,t)),yy=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=gy(t.root.mxCell),i=hy(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},xy=async e=>{let t=await wp(e),o=Zi(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}},Rp=async e=>{try{let t=await xy(e),{nodes:o,edges:n,summary:r}=yy(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};var Vp=require("react/jsx-runtime"),Op=()=>{let{t:e}=(0,hs.useTranslation)(),{toast:t}=lt(),{setNodes:o,setEdges:n}=(0,Dp.useReactFlow)(),{fitToNodes:r}=Wn(),i=s=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],c=s.map(d=>[d.originalType,d.value,e(`adapter.governance.report.status.${d.status.toLowerCase()}`)]);t({variant:"warning",content:e("adapter.governance.success.incompatible_cells"),duration:1e3*60*1,action:(0,Vp.jsx)(hs.Button,{size:"small",variant:"ghost",onClick:()=>Ap({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 Rp(s);if(o(f=>f.concat(l)),n(f=>f.concat(c)),r(l),d.some(f=>f.status==="unsupported")){i(d);return}t({variant:"success",content:e("adapter.governance.success.default")})}catch(l){let c=l instanceof Error?l.message:"DEFAULT";t({variant:"error",content:e(`adapter.governance.error.${c}`)})}}}};var Hp=require("@produto-lecom/lecom-ui"),Gp=require("react");var un=require("react/jsx-runtime"),Bp=s=>{var l=s,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,a=Ut(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=(0,Gp.useRef)(null),d=f=>{let m=f.target.files;m!=null&&m.length&&i(m),c.current&&(c.current.value="")};return(0,un.jsxs)(un.Fragment,{children:[(0,un.jsx)(Hp.Button,w(_({disabled:n,onClick:f=>{var m;(m=c.current)==null||m.click(),r==null||r(f)}},a),{children:e})),(0,un.jsx)("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};var pn=require("react/jsx-runtime"),zp=({disabled:e=!1})=>{let{t}=(0,Go.useTranslation)(),{toast:o}=lt(),{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(0,pn.jsxs)(Go.Tooltip,{children:[(0,pn.jsx)(Go.TooltipTrigger,{asChild:!0,children:(0,pn.jsx)(Bp,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:(0,pn.jsx)(Pa,{})})}),(0,pn.jsx)(Go.TooltipContent,{color:"black",children:t("editor.controls.actions.import_governance")})]})};var Yp=require("react/jsx-runtime"),ga=({shortcut:e})=>(0,Yp.jsx)("span",{className:"min-h-7.5 inline-flex justify-center items-center py-0.5 px-1.5 bg-grey-100 border border-grey-300 font-mono text-gray-800 shadow-lg rounded-md text-grey-900",children:e});var Te=require("@produto-lecom/lecom-ui"),Bo=require("lucide-react"),Kp=require("react");var Wp=require("@produto-lecom/lecom-ui"),Xp=require("@xyflow/react"),Vr=require("html-to-image"),Up=require("react");var Ey=3,ha="diagram",ys=50,_y=96,by=25.4,Ty="sequence-edge-marker",Fp=e=>e*by/_y,vy=e=>{let t=document.getElementById(Ty);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},$p=()=>{let{t:e}=(0,Wp.useTranslation)(),{toast:t}=lt(),{getEdges:o,getNodes:n,getNodesBounds:r}=(0,Xp.useReactFlow)(),{clearSelection:i}=Lo(),[a,s]=(0,Up.useState)({png:!1,html:!1,print:!1}),l=()=>{let m=oa(n(),o()),y=r(m),E=y.width+ys*2,p=y.height+ys*2,g=ys-y.x,h=ys-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(m,y)=>{s(E=>w(_({},E),{[y]:!0})),await i();try{if(oa(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=vy(p);try{return await m(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(m=ha)=>{await c(async(y,E)=>{let p=await(0,Vr.toPng)(y,w(_({},E),{backgroundColor:"#fcfcfc",skipFonts:!0}));gs(p,`${m}.png`)},"png")},exportAsHtml:async(m=ha)=>{await c(async(y,E)=>{let p=await(0,Vr.toSvg)(y,w(_({},E),{backgroundColor:"#fcfcfc",skipFonts:!0})),g=`
38
+ </mxGraphModel>`,Nd=(e,t)=>{if(!e.length&&!t.length)return br;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var Ki=require("xml-js");var wd={compact:!0,spaces:4},mh=e=>e.replace(/\n/g,"&#xA;");function qi(e,t=wd){if(e)return JSON.parse((0,Ki.xml2json)(e,t))}function Ad(e,t=wd){return e?(0,Ki.json2xml)(e,w(_({},t),{attributeValueFn:mh})):""}var Id={"attribute-loop":"LOOP"},Cd={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS","service-task":"SERVICE_TASK"},Sd={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Md={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed",SERVICE_TASK:"service-task"},Pd={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var Gn=(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(No(Number(a),t),l),u=Math.max(No(Number(s),o),c);return{width:d,height:u,measured:{width:d,height:u}}},Bn=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},hh=e=>{let{mxGeometry:t}=e,o=Bn(e),n=Gn(t,ue.START_EVENT.MIN_WIDTH,ue.START_EVENT.MIN_HEIGHT);return w(_(_({},o),n),{type:"START_EVENT"})},yh=e=>{let{mxGeometry:t}=e,o=Bn(e),n=Gn(t,ue.END_EVENT.MIN_WIDTH,ue.END_EVENT.MIN_HEIGHT);return w(_(_({},o),n),{type:"END_EVENT"})},Zi=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=Bn(e),s=Gn(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=Id[d];u&&(r.data.attribute=u)}let c=Cd[o.style];return c&&(r.data.variant=c),w(_(_({},r),s),{type:"TASK"})},Qs=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=Bn(e),i=Gn(o,ue.GATEWAY.MIN_WIDTH,ue.GATEWAY.MIN_HEIGHT);return r.data.variant=Sd[n],w(_(_({},r),i),{type:"GATEWAY"})},xh=e=>{let{mxGeometry:t}=e,o=Bn(e),i=Gn(t,ue.ANNOTATION.MIN_WIDTH,ue.ANNOTATION.MIN_HEIGHT,o.data.label,32,24);return w(_(_({},o),i),{type:"ANNOTATION"})},Eh=e=>{let{mxGeometry:t}=e,o=Bn(e),n=Gn(t,ue.LANE.MIN_WIDTH,ue.LANE.MIN_HEIGHT);return w(_(_({},o),n),{type:"LANE"})},Ld={task:Zi,"task-script":Zi,"subprocess-collapsed":Zi,"service-task":Zi,"start-event":hh,"end-event-terminate":yh,"gateway-parallel":Qs,"gateway-exclusive":Qs,"gateway-complex":Qs,annotation:xh,lane:Eh},_h=e=>{if(e&&Array.isArray(e))return e.map(t=>({x:Number(t._attributes.x),y:Number(t._attributes.y)}))},kd=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:f,labelOffsetY:m}=t,y=_h(o==null?void 0:o.Array),E=d!==void 0?Number(d):void 0,p=u!==void 0?Number(u):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}:{}),p!==void 0?{targetOffset:p}:{}),g!==void 0&&h!==void 0?{labelOffset:{x:g,y:h}}:{})});return s.includes("association")&&s.includes('endArrow=""')?_(_({},Vn),x):_(_({},Pt),x)},Rd=(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 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:((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:u}},zn=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}}}},bh=e=>{let{variant:t}=e.data,o=zn(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:Md[t]||"task"})})},Th=e=>{let t=zn(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"start-event"})})},vh=e=>{let t=zn(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"end-event-terminate"})})},Nh=e=>{let{variant:t}=e.data,o=zn(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:Pd[t]})})},wh=e=>{let t=zn(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"lane"})})},Ah=e=>{let t=zn(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"annotation"})})},Dd={TASK:bh,START_EVENT:Th,END_EVENT:vh,GATEWAY:Nh,ANNOTATION:Ah,LANE:wh},Od=(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 Ih=e=>{let t=Object.values(_r),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=Ld[a],l=s==null?void 0:s(i,n);if(!l){console.warn(`Node ${a} not supported`);continue}r.push(l)}return r},Ch=(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=kd(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},Sh=(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=Od(n,t);o.push(l)}}),o},Mh=(e,t)=>{let o=[];return e.forEach(n=>{let r=Rd(n,t);o.push(r)}),o},Ph=(e=[],t=[],o)=>{let n=Sh(e,o),r=Mh(t,e);return{mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}}},Vd=(e=[],t=[],o)=>{let n=Ph(e,t,o);return Ad(JSON.stringify(n),{compact:!0,spaces:0})},Hd=async e=>{var a,s,l,c,d;let t=await qi(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)||br),r=Ih(o),i=Ch(o,r);return{lastElementId:n,edges:i,nodes:r}};var ss=require("@xyflow/react"),Cu=require("react");var ht=require("@xyflow/react"),os=require("react");var Tr=require("@xyflow/react");var js=require("react/jsx-runtime"),ne=i=>{var a=i,{type:e,position:t,className:o,nodeType:n}=a,r=Ut(a,["type","position","className","nodeType"]);let s=n==="TASK";return(0,js.jsx)(Tr.Handle,_({type:e,position:t,className:H("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":s,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":!s},o)},r))},ot=s=>{var l=s,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,a=Ut(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=(0,Tr.useReactFlow)(),f=(()=>{if(n!=="source")return!1;let m=c();if(t==="TASK")return m.filter(E=>E.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return m.filter(E=>E.source===e).length>=2;if(t==="START_EVENT"){let y=d();return m.filter(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(0,js.jsx)(Tr.Handle,_({type:n,position:r,className:H("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":f,"hover:border-grey-500":!f},i),style:{pointerEvents:f?"none":"auto"}},a))};var oa=require("react"),ho=require("@xyflow/react");var Gd=require("@xyflow/react"),Ji=()=>{let e=(0,Gd.useStoreApi)();return{getInternalNodes:()=>{let{nodeLookup:o}=e.getState();return Array.from(o.values())}}};var ea=Nf(require("@dagrejs/dagre"),1),vr=require("@xyflow/react");var zd=(e=[],t=[],o="LR")=>{let n=new ea.default.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:i,width:a,height:s})=>n.setNode(i,{width:a,height:s})),t.forEach(i=>n.setEdge(i.source,i.target)),ea.default.layout(n),{nodes:e.map(i=>{let a=n.node(i.id);return w(_({},i),{position:{x:a.x-i.width/2,y:a.y-i.height/2}})}),edges:t}},Do=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId);if(t.length===0)return e;let o=za(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){$a(a,o,r),Ka(n,o);continue}Cs(n,i,o)}return Ya(e,o)};var Yd=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)};var Lh=500;var kh=e=>e.type==="LANE"&&!e.parentId,Rh=(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},Dh=(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)},Oh=e=>{let t=new Set;for(let o of e)t.add(o.source),t.add(o.target);return t},Bd=(e,t,o)=>{if(e.type!=="ANNOTATION"||o.has(e.id))return!1;let n=(0,vr.getNodesBounds)([e]);return Dh(t,n)>Lh},ta=(e,t=[])=>{var E;let o=e.filter(kh);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=Oh(t),l=a.filter(p=>p.type!=="ANNOTATION"),c=(0,vr.getNodesBounds)(l.length>0?l:a),d=a.filter(p=>!Bd(p,c,s)),u=(0,vr.getNodesBounds)(d),y=e.filter(p=>!r.has(p.id)).filter(p=>{let g=(0,vr.getNodesBounds)([p]);return!Rh(u,g)}).filter(p=>!Bd(p,u,s));return[...d,...y]};var Qi=require("react/jsx-runtime"),na=require("react"),Vh=["top","right","bottom","left"],Hh=["top-left","top-middle","top-right","right-middle","bottom-left","left-middle","bottom-right","bottom-middle"],Lt=r=>{var i=r,{nodeId:e,isVisible:t,offset:o=8}=i,n=Ut(i,["nodeId","isVisible","offset"]);let{getInternalNode:a,setNodes:s}=(0,ho.useReactFlow)(),{getInternalNodes:l}=Ji(),{isMultipleSelection:c}=q(),d=(0,ho.useStoreApi)(),u=(0,oa.useRef)(0),f=(0,oa.useRef)([]),m=({y:g,width:h,height:x})=>{cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{var j,Q;if(!e)return;let{nodeLookup:N,onNodesChange:b}=d.getState(),T=N.get(e);if(!T||T.type!=="LANE")return;let v=!T.parentId,A=v?T.id:T.parentId;if(!A)return;let C=Array.from(N.values()).filter(z=>z.type==="LANE"&&z.parentId===A);if(!C.length)return;f.current.length===0&&(f.current=$o(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===T.id),K=!v&&L>0&&Math.abs(g-T.position.y)>.5;for(let z=0;z<P.length;z++){let M=P[z],V=M.id===T.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=v?h-ae.HEADER_WIDTH:h,G=I;v&&D&&(G=Math.max(ae.MIN_HEIGHT,x-S)),K&&z===L-1&&(G=Math.max(ae.MIN_HEIGHT,g-S)),R.push({id:M.id,type:"dimensions",dimensions:{width:B,height:G},setAttributes:!0}),R.push({id:M.id,type:"position",position:{x:ae.HEADER_WIDTH,y:S}}),S+=G}v?R.push({id:A,type:"dimensions",dimensions:{width:h,height:x},setAttributes:!0}):R.push({id:A,type:"dimensions",dimensions:{width:h+ae.HEADER_WIDTH,height:S},setAttributes:!0}),b==null||b(R)})},y=({y:g,width:h,height:x})=>{var T;if(cancelAnimationFrame(u.current),f.current=[],!e)return;let N=a(e);if(!N||N.type!=="LANE"&&!N.parentId)return;let b=[...l()];if(N.type!=="LANE"){b=b.map(v=>v.id===e?w(_({},v),{width:h,height:x,measured:{width:h,height:x}}):v),b=Do(b),s(b);return}b=qa(N,h,x,b,g),b=Do(b),b=Uo((T=N.parentId)!=null?T:N.id,b),s(b)};if(!(!c&&t))return null;let p={"--resize-offset":`${o}px`};return(0,Qi.jsxs)(Qi.Fragment,{children:[Vh.map(g=>(0,na.createElement)(ho.NodeResizeControl,w(_({},n),{key:g,nodeId:e,position:g,variant:ho.ResizeControlVariant.Line,className:"border-blue-400/90 border-dashed",style:p,onResize:(h,x)=>m(x),onResizeEnd:(h,x)=>y(x)}))),Hh.map(g=>(0,na.createElement)(ho.NodeResizeControl,w(_({},n),{key:g,nodeId:e,position:g,className:"size-1.5 bg-blue-400 relative before:content-[''] before:absolute before:w-5 before:h-5 before:left-1/2 before:top-1/2 before:-translate-x-1/2 before:-translate-y-1/2 before:cursor-[inherit]",style:p,onResize:(h,x)=>m(x),onResizeEnd:(h,x)=>y(x)})))]})};var ts=require("@xyflow/react"),to=require("@produto-lecom/lecom-ui"),gt=require("react");var Fd=require("zustand"),Yn=(0,Fd.create)(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));var ji=require("react"),Wd=(e,t=!1)=>{let[o,n]=(0,ji.useState)({width:0,height:0});return(0,ji.useEffect)(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};var Oo=require("@xyflow/react"),Xd=require("react"),Gh=120,Bh=12,Ud=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=(0,Oo.useReactFlow)(),{instanceId:i}=q();return(0,Xd.useMemo)(()=>{var m,y;if(!t)return{position:Oo.Position.Right,align:"start"};let a=n(e);if(!a)return{position:Oo.Position.Right,align:"start"};let s=r(),l=a.position.x*s.zoom+s.x,c=(((m=a.measured)==null?void 0:m.width)||a.width||100)*s.zoom,d=(y=document.getElementById(`modeler-${i}`))==null?void 0:y.clientWidth;if(!d)return{position:Oo.Position.Right,align:"start"};let u=(o==null?void 0:o.width)||Gh;return{position:l+c+u+Bh>d?Oo.Position.Left:Oo.Position.Right}},[i,e,t,o,n,r])};var ra=require("lucide-react");var es=require("@xyflow/react"),be=require("@produto-lecom/lecom-ui"),$d=require("lucide-react");var Pe=require("react/jsx-runtime"),Kd=({nodeId:e})=>{let{t}=(0,be.useTranslation)(),{updateNodeData:o,getEdges:n,getNode:r}=(0,es.useReactFlow)(),i=(0,es.useNodesData)(e),s=n().filter(y=>y.source===e).some(y=>{let E=r(y.target);return(E==null?void 0:E.type)==="END_EVENT"}),l=(i==null?void 0:i.data.variant)==="SUBPROCESS",c=(i==null?void 0:i.data.variant)==="SERVICE_TASK",d=f=>{o(e,{variant:(i==null?void 0:i.data.variant)===f?"":f})},u=f=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===f?"":f})};return(0,Pe.jsxs)(be.DropdownMenu,{children:[(0,Pe.jsxs)(be.Tooltip,{children:[(0,Pe.jsx)(be.TooltipTrigger,{asChild:!0,children:(0,Pe.jsx)(be.DropdownMenuTrigger,{asChild:!0,children:(0,Pe.jsx)(be.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:(0,Pe.jsx)($d.WrenchIcon,{})})})}),(0,Pe.jsx)(be.TooltipContent,{color:"black",children:t("bpmn.task.menu.title")})]}),(0,Pe.jsxs)(be.DropdownMenuContent,{align:"start",className:"w-60 bg-white text-grey-600",children:[(0,Pe.jsxs)(be.DropdownMenuLabel,{className:"flex items-center gap-1",children:[(0,Pe.jsx)("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),(0,Pe.jsx)("div",{className:"flex items-center gap-1",children:Object.entries(Zr).map(([f,m])=>{let y=f==="LOOP"&&(s||l||c),p=(()=>{if(f==="LOOP"&&s)return t("editor.task_menu.loop_not_allowed_when_connected_to_end");if(f==="LOOP"&&l)return t("editor.task_menu.loop_not_allowed_when_subprocess");if(f==="LOOP"&&c)return t("editor.task_menu.loop_not_allowed_when_service_task");if(f==="LOOP")return t("editor.task_menu.loop")})();return(0,Pe.jsxs)(be.Tooltip,{children:[(0,Pe.jsx)(be.TooltipTrigger,{asChild:!0,children:(0,Pe.jsx)(be.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:y,className:H({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===f,"opacity-50 cursor-not-allowed":y}),onClick:y?void 0:()=>u(f),children:(0,Pe.jsx)(m.icon,{className:"stroke-inherit"})})}),p&&(0,Pe.jsx)(be.TooltipContent,{color:"black",children:p})]},f)})})]}),(0,Pe.jsx)(be.DropdownMenuGroup,{children:(0,Pe.jsxs)(be.Tooltip,{children:[(0,Pe.jsx)(be.TooltipTrigger,{asChild:!0,children:(0,Pe.jsx)("div",{className:H({"cursor-not-allowed":s}),children:(0,Pe.jsxs)(be.DropdownMenuItem,{className:H({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":s}),disabled:s,onClick:()=>d("SCRIPT"),children:[(0,Pe.jsx)(qr.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),s&&(0,Pe.jsx)(be.TooltipContent,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};var Oe=require("react/jsx-runtime"),yo={START_EVENT:{type:"START_EVENT",icon:Qn,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:gn,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:Qn,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:Xr,label:"bpmn.annotation.variant.default"}},zh={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:xn,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:_n,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:hn,label:"bpmn.gateway.variant.complex"}},ct=({nodeId:e,nodeType:t,nodeVariant:o,isChild:n})=>{let r=(0,gt.useRef)(null),i=(0,gt.useRef)(null),{t:a}=(0,to.useTranslation)(),{setDraggableNode:s}=Yn(),{getEdges:l,getNodes:c,getNode:d,setNodes:u}=(0,ts.useReactFlow)(),{setIsDragging:f,mode:m,isConnecting:y,isDragging:E,isMultipleSelection:p}=q(),g=d(e),h=!!(g!=null&&g.selected)&&!g.dragging&&!y&&!E&&!p,{dimensions:x}=Wd(r,h),{position:N}=Ud(e,h,x),[b,T]=(0,gt.useState)(void 0),v=c(),A=l(),C=o==="SUBPROCESS",P=o==="SERVICE_TASK",R=(0,gt.useRef)(null),S=(0,gt.useRef)(!1),L=(0,gt.useCallback)(()=>{R.current!==null&&(clearTimeout(R.current),R.current=null),S.current=!1,f(!1),s(null),T(void 0),u(F=>F.map(U=>w(_({},U),{className:void 0})))},[f,s,u]);(0,gt.useEffect)(()=>{let F=U=>{S.current&&U.buttons===0&&L()};return document.addEventListener("dragend",L),document.addEventListener("mousemove",F),()=>{document.removeEventListener("dragend",L),document.removeEventListener("mousemove",F)}},[L]);let K=(0,gt.useCallback)((F,U)=>{S.current=!0,f(!1),s({type:U.type,variant:U.variant,attribute:U.attribute,icon:U.icon}),U.icon&&T((0,Oe.jsx)(U.icon,{})),F.dataTransfer.effectAllowed="move",F.dataTransfer.setData("sourceId",e),i.current&&F.dataTransfer.setDragImage(i.current,10,10),R.current=setTimeout(()=>{R.current=null,f(!0)},100)},[e,s,f]),j=(0,gt.useCallback)(()=>{L()},[L]),Q=[{component:(0,Oe.jsx)(Hi,{elementId:e})}],z=()=>{if(m==="view")return[];let F=!A.some(U=>{var X;return U.source===e&&((X=v.find($=>$.id===U.target))==null?void 0:X.type)!=="ANNOTATION"});return[{component:(0,Oe.jsx)(kn,{nodeId:e,disabled:!F,tooltipMessage:F?void 0:a("editor.toolbar.start_event_limit_reached")})},yo.TASK,yo.ANNOTATION,...Q]},M=()=>m==="view"?[{component:(0,Oe.jsx)(ko,{elementId:e})}]:[{component:(0,Oe.jsx)(ko,{elementId:e})},...C||P?[]:[{component:(0,Oe.jsx)(Kd,{nodeId:e})}],{component:(0,Oe.jsx)(kn,{nodeId:e})},yo.TASK,{type:"TASK",variant:"SUBPROCESS",icon:jn,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:ra.Bot,label:"bpmn.task.variant.service_task"},yo.ANNOTATION,...Object.values(zh),...en(e,v,A)?[]:[yo.END_EVENT],...Q],V=()=>m==="view"?[{component:(0,Oe.jsx)(ko,{elementId:e,elementType:"gateway"})}]:[{component:(0,Oe.jsx)(ko,{elementId:e,elementType:"gateway"})},{component:(0,Oe.jsx)(kn,{nodeId:e})},yo.TASK,{type:"TASK",variant:"SUBPROCESS",icon:jn,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:ra.Bot,label:"bpmn.task.variant.service_task"},yo.ANNOTATION,...Q],D=()=>m==="view"?[]:[yo.ANNOTATION,...Q],I=()=>m==="view"?[]:[...n?[]:[{component:(0,Oe.jsx)(kn,{nodeId:e})}],yo.ANNOTATION,...Q],B=()=>m==="view"?[]:[{component:(0,Oe.jsx)(kn,{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 I();case"ANNOTATION":return B();case"UNSUPPORTED":return G();default:return[]}})(t),Y=O.length>6;if(!(O.length===0||m==="readonly"))return(0,Oe.jsxs)(ts.NodeToolbar,{position:N,align:"start",className:Y?"-top-[4.5rem]":"-top-8",isVisible:h,children:[(0,Oe.jsx)("div",{ref:r,className:`${Y?"grid grid-cols-6":"flex"} gap-1 px-2 py-2 bg-white rounded-sm shadow-md`,children:O.map((F,U)=>{if(F.component)return(0,Oe.jsx)("div",{children:F.component},U);let X={sourceNodeType:t,targetNodeType:F.type,sourceNodeId:e,nodes:v,edges:A},$=nd(X),te={gateway_limit_reached:a("editor.toolbar.gateway_limit_reached"),start_event_limit_reached:a("editor.toolbar.start_event_limit_reached"),start_event_already_exists:a("editor.toolbar.start_event_already_exists"),script_to_end_not_allowed:a("editor.toolbar.script_to_end_not_allowed"),loop_to_end_not_allowed:a("editor.toolbar.loop_to_end_not_allowed"),initial_activity_to_end_not_allowed:a("editor.toolbar.initial_activity_to_end_not_allowed"),final_activity_cannot_connect:a("editor.toolbar.final_activity_cannot_connect"),activity_has_outgoing_connections:a("editor.toolbar.activity_has_outgoing_connections"),task_limit_reached:a("editor.toolbar.task_limit_reached"),start_event_to_service_task_not_allowed:a("editor.toolbar.start_event_to_service_task_not_allowed"),service_task_to_end_not_allowed:a("editor.toolbar.service_task_to_end_not_allowed")},ie=$.shouldDisable&&$.reason?te[$.reason]||a(F.label):a(F.label)||"";return(0,Oe.jsxs)(to.Tooltip,{children:[(0,Oe.jsx)(to.TooltipTrigger,{asChild:!0,children:(0,Oe.jsx)(to.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!$.shouldDisable,disabled:$.shouldDisable,className:$.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:$.shouldDisable?void 0:W=>K(W,F),onDragEnd:$.shouldDisable?void 0:j,children:F.icon&&(0,Oe.jsx)(F.icon,{size:16})})}),(0,Oe.jsx)(to.TooltipContent,{color:"black",children:ie})]},U)})}),(0,Oe.jsx)("div",{ref:i,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:b})]})};var Ke=require("react/jsx-runtime"),qd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r,setNodes:i}=(0,ht.useReactFlow)(),{inProgress:a,fromNode:s}=(0,ht.useConnection)(),{mode:l,isReadOnly:c}=q(),d=a&&(s==null?void 0:s.id)!==e,u=(0,os.useCallback)(y=>{let x=y.split(`
40
+ `),N=x.reduce((A,C)=>Math.max(A,C.length),0),b=x.length,T=Math.max(Nn.MIN_WIDTH,N*7+32),v=Math.max(Nn.MIN_HEIGHT,b*20+24);i(A=>A.map(C=>C.id===e?w(_({},C),{width:T,height:v,style:w(_({},C.style),{width:T,height:v})}):C))},[e,i]),f=(0,os.useCallback)(y=>{r(e,{label:y}),u(y)},[e,r,u]),m=(0,os.useCallback)(y=>{u(y)},[u]);return(0,Ke.jsxs)("div",{className:H("relative w-full h-full min-w-44 min-h-16 flex text-grey-400 hover:text-grey-500 bg-white rounded-sm border-l-2 border-current before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-current after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-current hover:shadow-md transition-colors duration-75",{"pointer-events-none":c,"text-blue-500 hover:text-blue-600 shadow-md":o&&!c,"border-red-500 border-l-[3px] shadow-[0_0_5px_rgba(255,0,0,0.5)] before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-red-500 after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-red-500":t.hasError}),children:[(0,Ke.jsx)(je,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:f,onInput:m,skipFirstCharValidation:!0}),(0,Ke.jsx)(ct,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&(0,Ke.jsx)(Lt,{nodeId:e,minWidth:Nn.MIN_WIDTH,minHeight:Nn.MIN_HEIGHT,isVisible:!n&&o}),!a&&(0,Ke.jsxs)(Ke.Fragment,{children:[(0,Ke.jsx)(ne,{type:"source",position:ht.Position.Left,id:"left"}),(0,Ke.jsx)(ne,{type:"source",position:ht.Position.Right,id:"right"}),(0,Ke.jsx)(ne,{type:"source",position:ht.Position.Top,id:"top"}),(0,Ke.jsx)(ne,{type:"source",position:ht.Position.Bottom,id:"bottom"})]}),(!a||d)&&(0,Ke.jsxs)(Ke.Fragment,{children:[(0,Ke.jsx)(ne,{type:"target",position:ht.Position.Left,id:"left",className:H({"annotation-handle":d})}),(0,Ke.jsx)(ne,{type:"target",position:ht.Position.Right,id:"right",className:H({"annotation-handle":d})}),(0,Ke.jsx)(ne,{type:"target",position:ht.Position.Top,id:"top",className:H({"annotation-handle":d})}),(0,Ke.jsx)(ne,{type:"target",position:ht.Position.Bottom,id:"bottom",className:H({"annotation-handle":d})})]})]})};var yt=require("@xyflow/react"),Zd=require("react");var Fe=require("react/jsx-runtime"),Jd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=(0,yt.useReactFlow)(),{inProgress:i,fromNode:a}=(0,yt.useConnection)(),{mode:s,isReadOnly:l,reconnectingEdgeId:c}=q(),[d,u]=(0,Zd.useState)(!1),f=i&&(a==null?void 0:a.id)!==e||!!c,m=p=>{r(e,{label:p})},y=()=>{u(!0)},E=()=>{u(!1)};return(0,Fe.jsxs)("div",{className:"relative",onDoubleClick:y,children:[(0,Fe.jsx)(gn,{className:H("w-full h-full min-w-9 min-h-9 hover:stroke-[#d33b3b] transition-colors duration-75",{"pointer-events-none":l,"stroke-blue-500 hover:stroke-blue-600":o&&!l,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),(0,Fe.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,Fe.jsx)(je,{value:t.label,isEditing:d,onBlur:E,onChange:m})}),(0,Fe.jsx)(ct,{nodeId:e,nodeType:"END_EVENT"}),s==="edit"&&(0,Fe.jsx)(Lt,{nodeId:e,isVisible:!n&&o,minWidth:Qr.MIN_WIDTH,minHeight:Qr.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||f)&&(0,Fe.jsxs)(Fe.Fragment,{children:[(0,Fe.jsx)(ne,{type:"target",position:yt.Position.Left,id:"left",className:H({"event-handle":f})}),(0,Fe.jsx)(ne,{type:"target",position:yt.Position.Right,id:"right",className:H({"event-handle":f})}),(0,Fe.jsx)(ne,{type:"target",position:yt.Position.Top,id:"top",className:H({"event-handle":f})}),(0,Fe.jsx)(ne,{type:"target",position:yt.Position.Bottom,id:"bottom",className:H({"event-handle":f})})]}),!i&&(0,Fe.jsxs)(Fe.Fragment,{children:[(0,Fe.jsx)(ne,{type:"source",position:yt.Position.Left,id:"left"}),(0,Fe.jsx)(ne,{type:"source",position:yt.Position.Right,id:"right"}),(0,Fe.jsx)(ne,{type:"source",position:yt.Position.Top,id:"top"}),(0,Fe.jsx)(ne,{type:"source",position:yt.Position.Bottom,id:"bottom"})]})]})};var xt=require("@xyflow/react"),ns=require("react");var We=require("react/jsx-runtime"),Qd=({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let a=As[t.variant].icon,{updateNodeData:s}=(0,xt.useReactFlow)(),{inProgress:l,fromNode:c}=(0,xt.useConnection)(),{mode:d,isReadOnly:u,reconnectingEdgeId:f}=q(),[m,y]=(0,ns.useState)(!1),E=l&&(c==null?void 0:c.id)!==e||!!f,p=(0,ns.useCallback)(x=>{s(e,{label:x})},[e,s]),g=()=>{y(!0)},h=()=>{y(!1)};return(0,We.jsxs)("div",{className:"relative",style:{width:o!=null?o:vn.MIN_WIDTH,height:n!=null?n:vn.MIN_HEIGHT},onDoubleClick:g,children:[(0,We.jsx)(a,{className:H("w-full h-full min-w-14 min-h-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"pointer-events-none":u,"stroke-blue-500 hover:stroke-blue-600":r&&!u,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),(0,We.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,We.jsx)(je,{value:t.label,isEditing:m,onBlur:h,onChange:p})}),(0,We.jsx)(ct,{nodeId:e,nodeType:"GATEWAY",nodeVariant:t.variant}),d==="edit"&&(0,We.jsx)(Lt,{nodeId:e,isVisible:!i&&r,minWidth:vn.MIN_WIDTH,minHeight:vn.MIN_HEIGHT,offset:2,keepAspectRatio:!0}),(!l||E)&&(0,We.jsxs)(We.Fragment,{children:[(0,We.jsx)(ne,{type:"target",position:xt.Position.Left,id:"left",className:H({"gateway-handle":E})}),(0,We.jsx)(ne,{type:"target",position:xt.Position.Right,id:"right",className:H({"gateway-handle":E})}),(0,We.jsx)(ne,{type:"target",position:xt.Position.Top,id:"top",className:H({"gateway-handle":E})}),(0,We.jsx)(ne,{type:"target",position:xt.Position.Bottom,id:"bottom",className:H({"gateway-handle":E})})]}),!l&&(0,We.jsxs)(We.Fragment,{children:[(0,We.jsx)(ot,{type:"source",position:xt.Position.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,We.jsx)(ot,{type:"source",position:xt.Position.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,We.jsx)(ot,{type:"source",position:xt.Position.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,We.jsx)(ot,{type:"source",position:xt.Position.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})};var jd=require("@xyflow/react"),Gt=require("@produto-lecom/lecom-ui"),Yh=require("lucide-react");var eu=require("react/jsx-runtime");var Et=require("@xyflow/react"),tu=require("react");var Xe=require("react/jsx-runtime"),ou=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=(0,Et.useReactFlow)(),{inProgress:i,fromNode:a}=(0,Et.useConnection)(),{mode:s,isReadOnly:l,reconnectingEdgeId:c}=q(),[d,u]=(0,tu.useState)(!1),f=i&&(a==null?void 0:a.id)!==e||!!c,m=p=>{r(e,{label:p})},y=()=>{u(!0)},E=()=>{u(!1)};return(0,Xe.jsxs)("div",{className:"relative",onDoubleClick:y,children:[(0,Xe.jsx)(Kr,{className:H("w-full h-full min-w-9 min-h-9 hover:stroke-[#54890b] transition-colors duration-75",{"pointer-events-none":l,"stroke-blue-500 hover:stroke-blue-600":o&&!l,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),(0,Xe.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,Xe.jsx)(je,{value:t.label,isEditing:d,onBlur:E,onChange:m})}),(0,Xe.jsx)(ct,{nodeId:e,nodeType:"START_EVENT"}),s==="edit"&&(0,Xe.jsx)(Lt,{nodeId:e,isVisible:!n&&o,minWidth:Jr.MIN_WIDTH,minHeight:Jr.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||f)&&(0,Xe.jsxs)(Xe.Fragment,{children:[(0,Xe.jsx)(ne,{type:"target",position:Et.Position.Left,id:"left",className:H({"event-handle":f})}),(0,Xe.jsx)(ne,{type:"target",position:Et.Position.Right,id:"right",className:H({"event-handle":f})}),(0,Xe.jsx)(ne,{type:"target",position:Et.Position.Top,id:"top",className:H({"event-handle":f})}),(0,Xe.jsx)(ne,{type:"target",position:Et.Position.Bottom,id:"bottom",className:H({"event-handle":f})})]}),!i&&(0,Xe.jsxs)(Xe.Fragment,{children:[(0,Xe.jsx)(ot,{type:"source",position:Et.Position.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),(0,Xe.jsx)(ot,{type:"source",position:Et.Position.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),(0,Xe.jsx)(ot,{type:"source",position:Et.Position.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),(0,Xe.jsx)(ot,{type:"source",position:Et.Position.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};var su=require("@produto-lecom/lecom-ui"),_t=require("@xyflow/react"),Ir=require("react");var Nr=60,rs=(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<=Nr?i:i.substring(0,Nr).trim()},Fn=(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>Nr&&(n=n.substring(0,Nr).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=Nr-l.length,u=`${r.substring(0,c).trim()}${l}`;if(!o.has(u))return u;i++}return n};var wr=require("react/jsx-runtime"),nu=e=>(0,wr.jsxs)("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[(0,wr.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),(0,wr.jsx)("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));var ia=require("react/jsx-runtime"),ru=e=>(0,ia.jsx)("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:(0,ia.jsx)("path",{d:"M12 2C8.13 2 5 5.13 5 9C5 14.25 12 22 12 22C12 22 19 14.25 19 9C19 5.13 15.87 2 12 2ZM12 11.5C10.62 11.5 9.5 10.38 9.5 9C9.5 7.62 10.62 6.5 12 6.5C13.38 6.5 14.5 7.62 14.5 9C14.5 10.38 13.38 11.5 12 11.5Z",fill:"#38bdf8"})}));var Ar=require("react/jsx-runtime"),iu=e=>(0,Ar.jsxs)("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[(0,Ar.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),(0,Ar.jsx)("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));var fe=require("react/jsx-runtime"),Fh={APROVADO:nu,EM_ANDAMENTO:ru,REJEITADO:iu},sa={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)]"},Wh={APROVADO:"bg-green-50",EM_ANDAMENTO:"bg-turquoise-50",REJEITADO:"bg-red-50"},au=({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let{t:a}=(0,su.useTranslation)(),{toast:s}=lt(),{updateNodeData:l,getNodes:c,setNodes:d}=(0,_t.useReactFlow)(),{inProgress:u,fromNode:f}=(0,_t.useConnection)(),{mode:m,isReadOnly:y,onSubprocessValidationClick:E,reconnectingEdgeId:p}=q(),{getTaskStatus:g}=Ko(),h=u&&(f==null?void 0:f.id)!==e||!!p,x=g(e),N=t.variant==="SUBPROCESS",b=t.variant==="SERVICE_TASK",T=!!t.variant&&!N&&!b||!!x,v=!!t.attribute||N||b,A=(0,Ir.useCallback)(M=>{let B=T||v?80:40,G=M.split(`
41
+ `),k=G.reduce((U,X)=>Math.max(U,X.length),0),O=G.length,Y=Math.max(Io.MIN_WIDTH,k*7+64),F=Math.max(Io.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,T,v]),C=(0,Ir.useCallback)(M=>{let V=M.trim(),D=t.label||"";if(V===D)return;let I=V,B=c();if(!(V&&V!=="")){I=rs(B,a("bpmn.task.label.prefix")),l(e,{label:I}),A(I),s({variant:"warning",content:(0,fe.jsxs)(fe.Fragment,{children:[a("bpmn.task.feedback.label_empty.prefix")," ",(0,fe.jsx)("strong",{children:I})]})});return}let k=Fn(I,B);k===D||(l(e,{label:k}),A(k),k!==I&&s({variant:"warning",content:(0,fe.jsxs)(fe.Fragment,{children:[a("bpmn.task.feedback.label_already_exists.prefix")," ",(0,fe.jsx)("strong",{children:V})," ",a("bpmn.task.feedback.label_already_exists.middle")," ",(0,fe.jsx)("strong",{children:k})]})}))},[t.label,c,e,a,l,A,s]),P=(0,Ir.useCallback)(M=>{A(M)},[A]),R=(0,Ir.useCallback)(()=>{s({variant:"error",content:a("bpmn.task.feedback.invalid_first_character")})},[a,s]),S=x?Fh[x]:null,L=t.variant?qr[t.variant].icon:null,K=t.attribute?Zr[t.attribute].icon:null,j=()=>t.hasError?sa.error:x?sa[x]:y?sa.default:"",Q=()=>{var M;return r&&(M=Wh[x])!=null?M:""},z=()=>{E==null||E({id:e,type:"sub_process",label:t.label})};return(0,fe.jsxs)("div",{className:H("relative w-full h-full min-w-44 min-h-24 flex flex-col items-stretch justify-stretch bg-white border-2 border-grey-400 hover:border-grey-500 rounded-md hover:shadow-md transition-colors duration-75",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:Io.MIN_WIDTH,height:n!=null?n:Io.MIN_HEIGHT},children:[(0,fe.jsx)("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:(0,fe.jsx)(je,{value:t.label,maxLength:60,className:H(Q(),{"py-10 px-8":T||v}),onChange:C,onInput:P,onInvalidFirstCharacter:R})}),L&&(0,fe.jsx)("div",{className:H("absolute flex items-center p-1",N||b?"bottom-0 left-1/2 -translate-x-1/2":"top-0 left-0"),children:(0,fe.jsx)(L,{size:b?20:16,className:H(t.hasError?"text-red-500":"text-grey-500",N&&"cursor-pointer"),onClick:N?z:void 0})}),K&&(0,fe.jsx)("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:(0,fe.jsx)("div",{className:H("flex items-center w-16 p-1",N||b?"justify-between":"justify-center"),children:(0,fe.jsx)(K,{size:16,className:H(t.hasError?"text-red-500":"text-grey-500")})})}),S&&(0,fe.jsx)("div",{className:"absolute top-0 right-0 flex items-center p-1",children:(0,fe.jsx)(S,{})}),(0,fe.jsx)(ct,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),m==="edit"&&(0,fe.jsx)(Lt,{nodeId:e,isVisible:!i&&r,minWidth:Io.MIN_WIDTH,minHeight:Io.MIN_HEIGHT}),(!u||h)&&(0,fe.jsxs)(fe.Fragment,{children:[(0,fe.jsx)(ne,{type:"target",position:_t.Position.Left,id:"left",className:H({"task-handle":h})}),(0,fe.jsx)(ne,{type:"target",position:_t.Position.Right,id:"right",className:H({"task-handle":h})}),(0,fe.jsx)(ne,{type:"target",position:_t.Position.Top,id:"top",className:H({"task-handle":h})}),(0,fe.jsx)(ne,{type:"target",position:_t.Position.Bottom,id:"bottom",className:H({"task-handle":h})})]}),!u&&(0,fe.jsxs)(fe.Fragment,{children:[(0,fe.jsx)(ot,{type:"source",position:_t.Position.Left,id:"left",nodeId:e,nodeType:"TASK"}),(0,fe.jsx)(ot,{type:"source",position:_t.Position.Right,id:"right",nodeId:e,nodeType:"TASK"}),(0,fe.jsx)(ot,{type:"source",position:_t.Position.Top,id:"top",nodeId:e,nodeType:"TASK"}),(0,fe.jsx)(ot,{type:"source",position:_t.Position.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})};var aa=require("@xyflow/react");var xo=require("react/jsx-runtime"),lu=({id:e,data:t})=>(0,xo.jsxs)(xo.Fragment,{children:[(0,xo.jsx)("div",{className:"relative w-full h-full min-w-32 min-h-16 flex items-center justify-center bg-white border-2 border-red-400 rounded-sm overflow-hidden",children:t.label}),(0,xo.jsx)(ct,{nodeId:e,nodeType:"UNSUPPORTED"}),(0,xo.jsx)(ne,{type:"source",position:aa.Position.Right}),(0,xo.jsx)(ne,{type:"target",position:aa.Position.Left})]});var Ge=require("@xyflow/react"),is=require("react");var Ne=require("react/jsx-runtime"),PA={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:Ge.MarkerType.Arrow},data:{label:""}},cu=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var G;let{zoom:c}=(0,Ge.useViewport)(),{updateEdgeData:d}=(0,Ge.useReactFlow)(),{isMultipleSelection:u,mode:f,instanceId:m}=q(),y=f!=="edit",[E,p]=(0,is.useState)(!1),{reconnectingHandle:g,cursorPosition:h,hoveredNodeId:x,reconnectingSide:N,isValidReconnection:b,handleReconnectStart:T}=Xi({edgeId:e,source:t,target:o,instanceId:m,isReadOnly:y}),v=(0,Ge.useInternalNode)(t),A=(0,Ge.useInternalNode)(o),{sx:C,sy:P,tx:R,ty:S,sourcePos:L,targetPos:K}=(0,is.useMemo)(()=>{var oe,le;if(!v||!A)return{sx:0,sy:0,tx:0,ty:0,sourcePos:Ge.Position.Left,targetPos:Ge.Position.Right};let k=An(v,A),O=s?i:k.sourcePos,Y=l?a:k.targetPos,F=(Z,ve,ye)=>{var ee,xe,Ce,Re,Je,wt;let{x:Ie,y:J}=Z.internals.positionAbsolute,de=(Ce=(xe=(ee=Z.measured)==null?void 0:ee.width)!=null?xe:Z.width)!=null?Ce:0,re=(wt=(Je=(Re=Z.measured)==null?void 0:Re.height)!=null?Je:Z.height)!=null?wt:0;switch(ve){case Ge.Position.Top:return{x:Ie+de*ye,y:J};case Ge.Position.Bottom:return{x:Ie+de*ye,y:J+re};case Ge.Position.Left:return{x:Ie,y:J+re*ye};case Ge.Position.Right:return{x:Ie+de,y:J+re*ye};default:return{x:Ie+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=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,N&&(O=N)):g==="target"&&h&&(ie=h.x,W=h.y,N&&(Y=N)),{sx:$,sy:te,tx:ie,ty:W,sourcePos:O,targetPos:Y}},[v,A,s,l,i,a,g,h,N,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!v||!A)return null;let[j,Q,z]=(0,Ge.getSmoothStepPath)({sourceX:C,sourceY:P,targetX:R,targetY:S,sourcePosition:L,targetPosition:K}),M=r||(v==null?void 0:v.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(0,Ne.jsx)(Ne.Fragment,{children:(0,Ne.jsxs)("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":M}),onDoubleClick:()=>!y&&p(!0),children:[(0,Ne.jsx)("path",{d:j,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),(0,Ne.jsxs)("g",{className:H("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":M}),children:[(0,Ne.jsx)(Ge.BaseEdge,{id:e,path:j,interactionWidth:0,markerEnd:`url(#${V})`,strokeDasharray:4,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||g&&x&&!b,"stroke-green-500":g&&x&&b,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":M&&!(n!=null&&n.hasError)&&!g})}),(0,Ne.jsxs)(Ge.EdgeLabelRenderer,{children:[(0,Ne.jsxs)("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${Q}px, ${z}px)`},children:[r&&!u&&(0,Ne.jsx)(On,{sx:C,sy:P,tx:R,ty:S,hasLabel:!!((G=n==null?void 0:n.label)!=null&&G.trim()),children:(0,Ne.jsx)(Dn,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),D&&(0,Ne.jsx)(je,{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&&(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${C}px, ${P}px)`},children:(0,Ne.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:g==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:g==="source"?.6:.3,className:"pointer-events-none"}),(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!g||g!=="source","cursor-not-allowed":g==="source"&&x&&!b,"cursor-grabbing":g==="source"&&(!x||b)}),onMouseDown:k=>T("source",k.nativeEvent)})]})}),(0,Ne.jsx)("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${R}px, ${S}px)`},children:(0,Ne.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:g==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:g==="target"?.6:.3,className:"pointer-events-none"}),(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!g||g!=="target","cursor-not-allowed":g==="target"&&x&&!b,"cursor-grabbing":g==="target"&&(!x||b)}),onMouseDown:k=>T("target",k.nativeEvent)})]})})]})]})]})]})})};var sn=require("@xyflow/react"),Cr=require("react/jsx-runtime"),du=({toX:e,toY:t,fromNode:o})=>{var u,f;if(!o)return null;let{internals:{positionAbsolute:{x:n,y:r}},measured:i}=o,a=(u=i.width)!=null?u:0,s=(f=i.height)!=null?f:0,c=[{x:n,y:r+s/2,pos:sn.Position.Left},{x:n+a,y:r+s/2,pos:sn.Position.Right},{x:n+a/2,y:r,pos:sn.Position.Top},{x:n+a/2,y:r+s,pos:sn.Position.Bottom}].reduce((m,y)=>{let E=Math.hypot(e-m.x,t-m.y);return Math.hypot(e-y.x,t-y.y)<E?y:m}),[d]=(0,sn.getStraightPath)({sourceX:c.x,sourceY:c.y,targetX:e,targetY:t});return(0,Cr.jsxs)("g",{className:"group",children:[(0,Cr.jsx)("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d}),(0,Cr.jsx)("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})};var bt=require("@xyflow/react"),uu=require("lodash"),Sr=require("react");var ke=require("react/jsx-runtime"),pu=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{var v;let{updateNodeData:i,getNodes:a}=(0,bt.useReactFlow)(),{mode:s,isReadOnly:l}=q(),{inProgress:c,fromNode:d}=(0,bt.useConnection)(),u=c&&(d==null?void 0:d.id)!==e,[f,m]=(0,Sr.useState)(!1),y=a(),E=!r,p=!E&&((v=y.find(A=>A.id===r))==null?void 0:v.selected),g=(0,Sr.useMemo)(()=>(0,uu.orderBy)([...y.filter(A=>A.parentId===e&&A.type==="LANE")],"position.y","asc"),[y,e]),h=E?Va.MIN_WIDTH:ae.MIN_WIDTH,x=(0,Sr.useMemo)(()=>{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)+ae.MIN_HEIGHT}return ae.MIN_HEIGHT},[E,g]),N=A=>{i(e,{label:A})},b=()=>{m(!0)},T=()=>{m(!1)};return(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsxs)("div",{className:H("flex h-full min-h-64 w-full min-w-[50rem] hover:shadow-md bg-white outline outline-2 outline-grey-400",{"pointer-events-none":l,"outline-offset-0 outline-blue-500 shadow-sm":(o||p)&&!l}),children:[(0,ke.jsx)("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:(0,ke.jsx)("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:(0,ke.jsx)(je,{value:t.label,className:"w-full h-full self-auto",contentClassName:H({"whitespace-nowrap":f}),isEditing:f,onBlur:T,onChange:N})})}),(0,ke.jsx)("div",{className:"flex-1"})]}),(0,ke.jsx)(ct,{nodeId:e,nodeType:"LANE",isChild:!E}),s==="edit"&&(0,ke.jsx)(Lt,{nodeId:e,isVisible:!n&&o,minWidth:h,minHeight:x,offset:10}),!c&&(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsx)(ne,{type:"source",position:bt.Position.Left,id:"left"}),(0,ke.jsx)(ne,{type:"source",position:bt.Position.Right,id:"right"}),(0,ke.jsx)(ne,{type:"source",position:bt.Position.Top,id:"top"}),(0,ke.jsx)(ne,{type:"source",position:bt.Position.Bottom,id:"bottom"})]}),(!c||u)&&(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsx)(ne,{type:"target",position:bt.Position.Left,id:"left",className:H({"annotation-handle":u})}),(0,ke.jsx)(ne,{type:"target",position:bt.Position.Right,id:"right",className:H({"annotation-handle":u})}),(0,ke.jsx)(ne,{type:"target",position:bt.Position.Top,id:"top",className:H({"annotation-handle":u})}),(0,ke.jsx)(ne,{type:"target",position:bt.Position.Bottom,id:"bottom",className:H({"annotation-handle":u})})]})]})};var fu={START_EVENT:ou,END_EVENT:Jd,TASK:au,GATEWAY:Qd,ANNOTATION:qd,LANE:pu,UNSUPPORTED:lu},mu={SEQUENCE_EDGE:bd,MESSAGE_EDGE:cu,ANNOTATION_EDGE:pd},gu="#fafafa",hu="#bebebe",yu=1,xu=10,Eu="bottom-left",la=.05,_u=5,bu=150,Tu=100,vu=la,Nu=1,wu={x:0,y:0,zoom:.75},Au=1,Iu=2,Xh={[Au]:4,[Iu]:2},Mr=[Au,Iu],ca=Mr.reduce((e,t)=>e|Xh[t],0);var Wn=()=>{let{setViewport:e}=(0,ss.useReactFlow)(),t=(0,ss.useStoreApi)();return{fitToNodes:(0,Cu.useCallback)(n=>{let{width:r,height:i}=t.getState();if(i<=0||r<=0)return;let a=Xa(n);if(!a)return;let s=Ua({bounds:a,canvasHeight:i,canvasWidth:r,minZoom:vu,maxZoom:Nu,offsetX:bu,offsetY:Tu});e(s)},[t,e])}};var Su=require("@xyflow/react");var kt=()=>{let{getEdges:e,getNodes:t}=(0,Su.useReactFlow)(),{lastElementId:o}=q(),n=()=>{let i=t(),a=e(),s=Nd(i,a);return Math.max(s,o)};return{getLastId:n,getNextId:()=>n()+1}};var Xn=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n}=(0,Mu.useReactFlow)(),{getLastId:r}=kt(),{fitToNodes:i}=Wn(),{setLastElementId:a}=q(),s=(0,da.useCallback)(async(c="")=>{let{nodes:d,edges:u,lastElementId:f}=await Hd(c);i(d),o(d),n(u),a(f)},[o,n,a,i]),l=(0,da.useCallback)(()=>{let c=e(),d=t(),u=r();return Vd(c,d,u)},[e,t,r]);return{importFromMxGraph:s,exportToMxGraph:l}};var ua=require("react"),Uh=500,as=()=>{let{isInitialized:e,onElementChanges:t}=q(),{exportToMxGraph:o}=Xn(),n=(0,Pu.useDebouncedCallback)(()=>{if(!e)return;let a=o();t==null||t(a)},Uh),r=(0,ua.useCallback)(a=>{a.every(c=>c.type==="select")||a.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=(0,ua.useCallback)(a=>{a.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var Lu=({setEdges:e,saveHistory:t})=>{let{getNode:o,getEdges:n,getNodes:r,getInternalNode:i}=(0,ls.useReactFlow)(),{emitElementChanges:a}=as(),s=(0,oo.useRef)(null),{getNextId:l}=kt(),c=(0,oo.useCallback)(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 $s(x).isValid},[o,n,r]),d=(0,oo.useCallback)(p=>{var x,N;let g=l(),h=i(p.source);if(h){let b=i(p.target),T=b?b.internals.positionAbsolute.x+((x=b.measured.width)!=null?x:0)/2:0,v=b?b.internals.positionAbsolute.y+((N=b.measured.height)!=null?N:0)/2:0,A=Td(h,T,v),C=(b==null?void 0:b.type)==="ANNOTATION"||(h==null?void 0:h.type)==="ANNOTATION",P=C?Vn:Pt,R;if(!C&&b&&p.targetHandle){let K=$i(A),j=$i(p.targetHandle),{x:Q,y:z}=Js(h,A),{x:M,y:V}=Js(b,p.targetHandle),I=Fi(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?{}:Pt.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=(0,oo.useCallback)((p,g)=>{s.current=g.id},[]),f=(0,oo.useCallback)(()=>{s.current=null},[]),m=(0,oo.useCallback)((p,g)=>{let h=o(g.source),x=o(g.target);if(!h||!x){s.current=null;return}let N={sourceNodeId:h.id,targetNodeId:x.id,sourceNodeType:h.type,targetNodeType:x.type,nodes:r(),edges:n(),reconnectingEdgeId:p.id};if(!$s(N).isValid){s.current=null;return}let T=(0,ls.reconnectEdge)(p,g,n()).map(v=>v.id===p.id?w(_({},v),{data:w(_({},v.data),{points:void 0})}):v);e(T),t("forceSave",{nodes:r(),edges:T}),s.current=null,a()},[o,r,n,e,a,t]),y=(0,oo.useCallback)(p=>{s.current=p},[]),E=(0,oo.useCallback)(()=>{s.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:m,onReconnectStart:u,onReconnectEnd:f,setReconnectingEdge:y,clearReconnectingEdge:E}};var zu=require("@produto-lecom/lecom-ui"),Yu=require("@xyflow/react"),Bt=require("react");var Pr=(e=[])=>e.filter(t=>t.type==="START_EVENT"),an=(e=[])=>e.filter(t=>t.type==="END_EVENT"),Vo=(e=[])=>e.filter(t=>t.type==="TASK")||[],ku=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"});var cs=(e=[])=>e.filter(t=>t.type==="GATEWAY"),Ru=(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),Lr=(e,t=[])=>t.filter(o=>o.target===e),Du=(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"},Ou=(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},Vu=e=>e?/[^\s]/.test(e.trim()):!1,we=e=>{let{isValid:t,nodeIds:o,edgeIds:n}=e;return{isValid:t,nodeIds:!t&&o&&o.length>0?o:[],edgeIds:!t&&n&&n.length>0?n:[]}},Eo=(e=[],t)=>{if(!e||e.length===0)return{isValid:!0,invalidIds:[]};let o=e.filter(n=>!t(n));return{isValid:o.length===0,invalidIds:o.map(n=>n.id)}},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 kr=[{id:"start_event_not_found",validate:e=>{let t=Pr(e.nodes);return we({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=an(e.nodes);return we({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Pr(e.nodes),o=t.length===1;if(t.length===0)return we({isValid:!0});if(!o)return we({isValid:!1,nodeIds:t.map(i=>i.id)});let n=Tt(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(a=>a.id),...n.map(a=>a.target)];return we({isValid:!1,nodeIds:[...new Set(i)]})}return we({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=Vo(e.nodes),o=Eo(t,n=>Tt(n.id,e.edges).length<=2);return we({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=Vo(e.nodes),o=Eo(t,n=>!!n.label&&n.label.trim()!=="");return we({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=Vo(e.nodes),n=Eo(o,r=>!r.label||r.label.length<=60);return we({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=Vo(e.nodes),o=new Map;for(let r of t){if(!r.label)continue;let i=r.label.trim();i&&(o.has(i)||o.set(i,[]),o.get(i).push(r))}let n=[];for(let[,r]of o.entries())r.length>1&&r.forEach(i=>n.push(i.id));return we({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=cs(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 we({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Pr(e.nodes),...an(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 we({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=an(e.nodes),o=[],n=[];for(let r of t){let i=Lr(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 we({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=Ru(e.nodes),o=Eo(t,r=>Tt(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>Tt(r,e.edges).map(i=>i.id));return we({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=Vo(e.nodes),o=Eo(t,n=>!n.label||Vu(n.label));return we({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var a,s;if(!((a=e==null?void 0:e.nodes)!=null&&a.length)||!((s=e==null?void 0:e.edges)!=null&&s.length))return we({isValid:!0});let t=an(e.nodes)[0];if(!t)return we({isValid:!0});let o=Lr(t.id,e.edges);if(!o.length)return we({isValid:!0});let r=Vo(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=Eo(r,l=>!Du(l.id,e));return we({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=Vo(e.nodes),o=an(e.nodes)[0];if(!o)return we({isValid:!0});let n=t.filter(l=>{let c=Lr(l.id,e.edges),d=Tt(l.id,e.edges),u=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 u&&f}),r=Lr(o.id,e.edges),i=r.length>1,a=r.map(l=>l.source),s={isValid:n.length===0&&!i,nodeIds:[...n.map(l=>l.id),...i?a:[]]};return we(s)}},{id:"gateway_flow_to_event",validate:e=>{let t=cs(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 we({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=cs(e.nodes),o=Eo(t,n=>Tt(n.id,e.edges).length>=1);return we({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Pr(e.nodes),...an(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 we({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=ku(e.nodes),o=Eo(t,n=>!Ou(n.id,e));return we({isValid:o.isValid,nodeIds:o.invalidIds})}}];var Gu=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of kr){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}},Bu=async(e,t)=>{var n;let o=[];try{let r=await e(),i=(n=r==null?void 0:r.filter(a=>a.area==="DIAGRAM"))!=null?n:[];return i.length===0?{isValid:!0,errors:[]}:(i.forEach(a=>{var l,c;let s=(c=(l=a==null?void 0:a.detail)==null?void 0:l.phases)==null?void 0:c.map(d=>d.diagramCellId);o.push({id:a.code,message:a.code,nodeIds:s,edgeIds:[]})}),{isValid:!1,errors:o})}catch(r){let i=[],a=(s,l)=>{let c=t.filter(d=>{var u;return((u=d.data)==null?void 0:u.variant)===s}).map(d=>d.id);c.length>0&&i.push({id:l,message:l,nodeIds:c,edgeIds:[]})};return a("SUBPROCESS","cannot_validate_subprocess_reference"),a("SERVICE_TASK","service_task_automation_status_unavailable"),{isValid:!1,errors:i}}};var ln=require("react/jsx-runtime"),Fu=()=>{let{t:e}=(0,zu.useTranslation)(),{toast:t}=lt(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=(0,Yu.useReactFlow)(),{validateCustomDiagram:a}=q(),[s,l]=(0,Bt.useState)(!1),c=(0,Bt.useRef)(!1),d=(0,Bt.useRef)(!1),u=(0,Bt.useCallback)(async p=>{let g=Hu(p.nodes,p.edges),h=Gu(g),x=p.nodes.filter(({type:b,data:T})=>b==="TASK"&&((T==null?void 0:T.variant)==="SUBPROCESS"||(T==null?void 0:T.variant)==="SERVICE_TASK"));if(a&&x.length>0){let b=await Bu(a,x);h={isValid:h.isValid&&b.isValid,errors:[...h.errors,...b.errors]}}let N=h.errors.map(b=>w(_({},b),{message:e(`validation.errors.${b.id}`)}));return s||l(!0),{isValid:h.isValid,errors:N}},[s,e,a]),f=(0,Bt.useCallback)((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:(0,ln.jsxs)("div",{className:"flex flex-col gap-1",children:[!p.isValid&&(0,ln.jsx)("span",{className:"body-small-500",children:e("validation.errors.subtitle")}),(0,ln.jsx)("ul",{className:"list-disc list-inside max-h-40 overflow-y-auto",children:p.isValid?(0,ln.jsx)("li",{children:e("validation.success.message")}):p.errors.map(S=>(0,ln.jsx)("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 N=[...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(),T=i(),v=new Set(N),A=new Set;p.errors.forEach(S=>{var j,Q;let L=kr.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=>{T.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)}),T.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=p.errors.find(z=>{var M;return(M=z.nodeIds)==null?void 0:M.includes(S)}))==null?void 0:L.id;((K=kr.find(z=>z.id===j))==null?void 0:K.highlightRelatedEdges)!==!1&&T.forEach(z=>{z.source===S&&P.has(z.target)&&(v.add(z.target),A.add(z.id)),z.target===S&&C.has(z.source)&&(v.add(z.source),A.add(z.id))})}}),v.size>0&&o(S=>S.map(L=>w(_({},L),{data:w(_({},L.data),{hasError:v.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]),m=(0,Bt.useCallback)(()=>{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=(0,Bt.useCallback)(()=>{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=(0,Bt.useCallback)(()=>c.current,[]);return{validateDiagram:u,handleValidationComplete:f,clearValidation:m,dismissValidationPanel:y,isAutoValidationEnabled:s,getIsClearingValidation:E}};var Uu=require("@xyflow/react"),$u=require("@produto-lecom/lecom-ui"),Ku=require("react");var $h=15,Wu="bpmn:selection",Kh=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},Xu=e=>{if(!Kh(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},qu=({offset:e=$h,saveHistory:t})=>{let{t:o}=(0,$u.useTranslation)(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=(0,Uu.useReactFlow)(),{getNextId:s}=kt(),{mode:l,containerRef:c}=q();(0,Ku.useEffect)(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let u=m=>{var b,T;if(!Xu(m)||!d.contains(document.activeElement))return;let E=n(),p=i(),g=E.filter(v=>v.selected);if(!g.length)return;m.preventDefault(),m.stopPropagation();let h=p.filter(v=>g.some(A=>A.id===v.source)&&g.some(A=>A.id===v.target)),N=JSON.stringify({nodes:g,edges:h});(b=m.clipboardData)==null||b.setData(Wu,N),(T=m.clipboardData)==null||T.setData("text/plain",`BPMN Selection: ${g.length} nodes`)},f=m=>{var R,S;if(!Xu(m)||!d.contains(document.activeElement))return;let E=(R=m.clipboardData)==null?void 0:R.getData(Wu);if(!E)return;m.preventDefault(),m.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=[],N=p.nodes.filter(L=>Lo(L.type,h));if(N.length===0)return;let b=s(),T=N.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=Fn(z||o("bpmn.task.label.prefix"),[...h,...x]);j.data=w(_({},L.data),{label:M})}return x.push(j),j}),v=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})),...T],P=[...i().map(L=>w(_({},L),{selected:!1})),...v];r(A),a(P),t("forceSave",{nodes:A,edges:P})};return d.addEventListener("copy",u,!0),d.addEventListener("paste",f,!0),()=>{d.removeEventListener("copy",u,!0),d.removeEventListener("paste",f,!0)}},[n,r,i,a,s,e,o,t,l,c])};var Zu=require("@produto-lecom/lecom-ui"),Ju=require("@xyflow/react");var Qu=require("react");var qh=50,ju=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let{draggableNode:r,setDraggableNode:i}=Yn(),{t:a}=(0,Zu.useTranslation)(),{getInternalNode:s,getNodes:l,getEdges:c,screenToFlowPosition:d}=(0,Ju.useReactFlow)(),{getNextId:u}=kt(),{setIsDragging:f}=q(),{getInternalNodes:m}=Ji(),{rebuildIndex:y,forceRebuildIndex:E}=Pi(),[p,g]=(0,Qu.useState)(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(" ")})})})},N=(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=tr(M,O);if(!Y){x();return}if(Xo({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=tr(M,B);if(!G){x();return}if(Xo({parentId:G.id,nodes:e,includeTypes:["LANE"]})){x();return}x(G.id)},b=M=>{let V=s(M.id),D=M.type==="LANE"&&Xo({parentId:M.id,nodes:e,includeTypes:["LANE"]});N(V,D)},T=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,A=(M,V)=>{let D=0;for(let I of V){if(I.id===M||I.parentId||I.type==="LANE")continue;let B=Ct(I),G=B.y+B.h;D=Math.max(D,G)}return D+qh},C=(M,V)=>{if(!Is(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}};N(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=Ss(M,V,I),I=Do(I),I=Uo(B,I),T(I);if(M.type==="LANE"){if(Xo({parentId:V.id,nodes:I,excludeTypes:["LANE"]})){let W=Ci(V),oe=50,le=50;return I.map(Z=>{var ve,ye;return Z.id===M.id?w(_({},Z),{position:{x:(ve=p==null?void 0:p.x)!=null?ve:W.x+oe,y:(ye=p==null?void 0:p.y)!=null?ye: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:ae.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=Do(I),I=C(B,I),I}if(Xo({parentId:V.id,nodes:I,includeTypes:["LANE"]})){let X;if(M.parentId){let $=s(M.parentId),{x:te,y:ie}=Ct($);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=Uo(B,I),I}let O=Fa(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=Ss(Y,V,I),I=Do(I),I=Uo(B,I),I},K=M=>{if(M.preventDefault(),!(r!=null&&r.type))return;if(!Lo(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},I=u(),B={id:String(I),type:r.type,position:V,measured:D,data:{label:r.type==="TASK"?rs(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=tr(k,F),X=[...O.map(W=>w(_({},W),{selected:!1})),G];U&&(X=L(G,U,X)),X=er(X),Y&&!U&&(X=C(G.id,X)),X=T(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),Vn):_(_({},W),Pt);ie=te.concat(oe),o(ie)}n("forceSave",{nodes:X,edges:ie}),f(!1),i(null)},j=async(M,V,D)=>{let I=[...m()],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=tr(Y,U);if(X){if(F&&Xo({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=v(I);let G=D.filter(O=>O.type==="LANE"&&!O.parentId).map(O=>O.id);for(let O of G)Is(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=Uo(Y,I)}I=er(I),I=T(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=ae.MIN_HEIGHT;else if(I){let Z=(X=(U=M.measured)==null?void 0:U.height)!=null?X:ae.MIN_HEIGHT;k=((te=($=D.measured)==null?void 0:$.height)!=null?te:ae.MIN_HEIGHT)-Z,k=Math.max(ae.MIN_HEIGHT,k)}else k=B.length>0?B.reduce((Z,ve)=>{var ye,Ie;return Z+((Ie=(ye=ve.measured)==null?void 0:ye.height)!=null?Ie:0)},0)+He:Math.max(ae.MIN_HEIGHT,(W=(ie=D.measured)==null?void 0:ie.height)!=null?W:0);let{x:O,y:Y}=Ct(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=Do(V),V};return{onDragOver:P,onDragLeave:R,onDrop:K,onNodeDrag:S,onNodeDragStart:Q,onNodeDragStop:j}};var ep=require("@xyflow/react"),tp=require("@produto-lecom/lecom-ui"),op=require("react");var Zh=30,Jh=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},Qh=e=>!Jh(e.target),np=({offset:e=Zh,saveHistory:t})=>{let{t:o}=(0,tp.useTranslation)(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=(0,ep.useReactFlow)(),{getNextId:s}=kt(),{mode:l,containerRef:c}=q();(0,op.useEffect)(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let u=f=>{if(d.contains(document.activeElement)&&f.ctrlKey&&f.key.toLowerCase()==="d"&&Qh(f)){f.preventDefault(),f.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=>Lo(P.type,y));if(x.length===0)return;let N=E.filter(P=>x.some(R=>R.id===P.source)&&x.some(R=>R.id===P.target)),b=s(),T=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=Fn(K||o("bpmn.task.label.prefix"),[...y,...h]);S.data=w(_({},P.data),{label:j})}return h.push(S),S}),v=N.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})),...T],C=[...E.map(P=>w(_({},P),{selected:!1})),...v];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])};var Dr=require("react"),rp=require("@xyflow/react");var jh=20,ey=50,Rr={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},ty=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",i=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||i},ip=e=>{let{getNodes:t}=(0,rp.useReactFlow)(),{mode:o,isMoveTool:n}=q(),r=(0,Dr.useRef)(0),i=(0,Dr.useRef)(new Map);(0,Dr.useEffect)(()=>{let a=s=>{if(o!=="edit"||!n||ty(s.target)||!Object.values(Rr).includes(s.key))return;let u=t().filter(h=>h.selected);if(u.length===0){i.current.clear();return}s.preventDefault();let f=Date.now(),m=f-r.current<500;r.current=f;let y=s.shiftKey?ey:jh,E=0,p=0;switch(s.key){case Rr.UP:p=-y;break;case Rr.DOWN:p=y;break;case Rr.LEFT:E=-y;break;case Rr.RIGHT:E=y;break}let g=u.map(h=>{let x=i.current.get(h.id);(!m||!x)&&(x={x:h.position.x,y:h.position.y});let N={x:x.x+E,y:x.y+p};return i.current.set(h.id,N),{id:h.id,dragging:!0,type:"position",position:N}});e&&e(g)};return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[t,e,o,n])};var dp=require("@xyflow/react");var ap={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY","gateway-parallel":"GATEWAY","gateway-complex":"GATEWAY"},lp={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},sp=(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}},oy=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=sp(i[0],o),s=sp(i[1],o);a&&s&&n.push({sourceId:a.step,targetId:s.step,label:a.edgeLabel||s.edgeLabel||""})}),{components:o,connections:n}},cp=e=>{let{components:t,connections:o}=oy(e);return{nodes:t,edges:o}};var ds=()=>{let{setNodes:e,setEdges:t}=(0,dp.useReactFlow)(),{fitToNodes:o}=Wn(),{getNextId:n}=kt();return{importFromLia:i=>{let a=typeof i=="string"?i:i.diagramXml||"",{nodes:s,edges:l}=cp(a),c=[],d=new Map,u=!1,f=n();for(let[p,g]of Object.entries(s)){let h=String(f++),x=ap[g.type],N=lp[g.type];x==="START_EVENT"&&(u=!0),d.set(p,h);let b=ue[x].MIN_WIDTH,T=ue[x].MIN_HEIGHT;c.push({id:h,type:x,data:{label:g.label||"",variant:N,attribute:""},position:{x:0,y:0},width:b,height:T,measured:{width:b,height:T}})}let m=[];for(let p of l){let g=w(_({},Pt),{id:String(f++),source:d.get(p.sourceId)||p.sourceId,target:d.get(p.targetId)||p.targetId});m.push(g)}if(!u&&c.length>0){let p=String(f++),g={id:p,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(g);let h=c[1];if(h){let x=w(_({},Pt),{id:String(f++),source:p,target:h.id});m.unshift(x)}}let{nodes:y,edges:E}=zd(c,m);e(y),t(E),o(y)}}};var us=require("react"),ny={origin:"*",debug:!1};function ps(e,t=ny){let{origin:o,debug:n}=t,r=(0,us.useCallback)((i,a)=>{let s={event:i,data:a};window.parent.postMessage(s,o||"*")},[o]);return(0,us.useEffect)(()=>{if(!e)return;let i=a=>{let s=a.data;if(!(s!=null&&s.event)||(s==null?void 0:s.data)===void 0)return;let{event:l,data:c}=s,d;if(Array.isArray(c)){let[,u]=c;d=u.data}else d=c;n&&(console.debug("[postMessage] received:",s),console.debug("[postMessage] eventData:",d)),l&&e[l]&&e[l](d)};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[e,n]),{sendMessage:r}}var up=require("@xyflow/react"),_o=require("react");var pp=()=>{let e=(0,up.useNodesInitialized)(),{initialDiagram:t,isNewDiagram:o,setIsInitialized:n,onElementChanges:r}=q(),{importFromMxGraph:i,exportToMxGraph:a}=Xn(),{sendMessage:s}=ps(),l=(0,_o.useRef)(t),c=(0,_o.useRef)(r),d=(0,_o.useRef)(a);(0,_o.useEffect)(()=>{c.current=r},[r]),(0,_o.useEffect)(()=>{d.current=a},[a]),(0,_o.useEffect)(()=>{t&&(i(t),l.current=t)},[t,i]),(0,_o.useEffect)(()=>{if(!e)return;(async()=>{var f;if(await Ur(),n(!0),s("INIT_MODELER",l.current),!o){let m=d.current();(f=c.current)==null||f.call(c,m)}})()},[e,o,n,s])};var fp=require("@xyflow/react"),pa=require("react");function mp(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=Ko(),{getEdges:n}=(0,fp.useReactFlow)(),r=(0,pa.useCallback)(a=>{if(!(a!=null&&a.activities))return;e(a.activities);let s=a.activities.map(c=>c.diagramId),l=n();o(l,s)},[e,o,n]),i=(0,pa.useCallback)(()=>{t()},[t]);return{handleTasksStatus:r,handleClearTaskStatus:i}}var hp=require("@xyflow/react"),nt=require("react"),yp=require("use-debounce");var iy=500,gp=100,xp=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=(0,hp.useReactFlow)(),{mode:i,containerRef:a}=q(),[s,l]=(0,nt.useState)({history:[],currentStep:0}),{history:c,currentStep:d}=s,u=d>0,f=d<c.length-1,m=(0,nt.useCallback)((v,A)=>{n(v[A].nodes),r(v[A].edges)},[n,r]),y=(0,nt.useCallback)(()=>{if(d>0){let v=d-1;l(A=>w(_({},A),{currentStep:v})),m(c,v)}},[d,c,m]),E=(0,nt.useCallback)(()=>{if(d<c.length-1){let v=d+1;l(A=>w(_({},A),{currentStep:v})),m(c,v)}},[c,d,m]),p=(0,nt.useCallback)(v=>{l(A=>{let C=A.history[A.currentStep];if(C&&JSON.stringify(C)===JSON.stringify(v))return A;let S=[...A.history.slice(0,A.currentStep+1),v],L=S.length>gp?S.slice(S.length-gp):S;return{history:L,currentStep:L.length-1}})},[]),g=(0,nt.useCallback)((v,A)=>{let C=v.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:er(C),edges:P}},[]),h=(0,nt.useCallback)(()=>g(t(),o()),[t,o,g]),x=(0,yp.useDebouncedCallback)(()=>{let v=h();p(v)},iy),N=(0,nt.useCallback)((v,A)=>{if(!e)return;if(c.length===0){let R=h();l({history:[R],currentStep:0})}if(v==="forceSave"){if(A){p(g(A.nodes,A.edges));return}x();return}v.some(R=>R.type==="select")||v.some(R=>R.type==="position"&&R.dragging)||x()},[e,x,c.length,h,p,g]);(0,nt.useEffect)(()=>{if(e&&c.length===0){let v=h();l({history:[v],currentStep:0})}},[e,c.length,h]);let b=(0,nt.useCallback)(v=>{l({history:v||[],currentStep:0})},[]),T=(0,nt.useCallback)(()=>{l({history:[],currentStep:0})},[]);return(0,nt.useEffect)(()=>{if(i!=="edit")return;let v=a.current;if(!v)return;let A=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",A),()=>{v.removeEventListener("keydown",A)}},[y,E,i,a]),{history:c,undo:y,redo:E,canUndo:u,canRedo:f,saveHistory:N,resetHistory:b,clearHistory:T}};var _p=()=>{let{t:e}=(0,Ep.useTranslation)(),[t,o,n]=(0,no.useNodesState)([]),[r,i,a]=(0,no.useEdgesState)([]),{getNodes:s,getNode:l}=(0,no.useReactFlow)(),{toast:c}=lt(),d=(0,no.useStoreApi)(),{instanceId:u,isInitialized:f,setIsConnecting:m,setIsMultipleSelection:y,onElementClick:E}=q(),{updateHelperLines:p,HelperLines:g}=Pi(),{undo:h,redo:x,canUndo:N,canRedo:b,saveHistory:T}=xp(f),{onNodeDrag:v,onDrop:A,onDragOver:C,onDragLeave:P,onNodeDragStop:R,onNodeDragStart:S}=ju({nodes:t,setNodes:o,setEdges:i,saveHistory:T}),{isValidConnection:L,onConnect:K,onReconnect:j,onReconnectStart:Q,onReconnectEnd:z,setReconnectingEdge:M,clearReconnectingEdge:V}=Lu({setEdges:i,saveHistory:T}),{handleValidationComplete:D,clearValidation:I,dismissValidationPanel:B,validateDiagram:G,getIsClearingValidation:k}=Fu(),{importFromLia:O}=ds(),{handleTasksStatus:Y,handleClearTaskStatus:F}=mp(),{clearPathEdges:U}=Ko(),{emitElementChanges:X,handleNodeChanges:$,handleEdgeChanges:te}=as(),ie=ja();qu({saveHistory:T}),np({saveHistory:T}),pp();let W=(0,vt.useCallback)(()=>{o([]),i([]),U(),setTimeout(ie,0)},[o,i,U,ie]),{selectElements:oe,clearSelection:le}=$t(),{importFromMxGraph:Z,exportToMxGraph:ve}=Xn(),{configureElement:ye,getConfigureElement:Ie}=Vi(),J=(0,vt.useCallback)(Ee=>{Ee!=null&&Ee.id&&oe([Ee.id])},[oe]),{sendMessage:de}=ps({LIA_CREATE_DIAGRAM:O,CLEAR_DIAGRAM:W,TASKS_STATUS:Y,CLEAR_TASKS_STATUS:F,EXTERNAL_TASK_SELECT:J}),re=(0,vt.useCallback)(()=>t.length+r.length,[t,r]);(0,vt.useEffect)(()=>(jt.set(u,{importFromMxGraph:Z,exportToMxGraph:ve,selectElements:oe,clearSelection:le,configureElement:ye,getConfigureElement:Ie,getElementsCount:re,setReconnectingEdge:M,clearReconnectingEdge:V}),()=>{jt.delete(u)}),[u,Z,ve,oe,le,ye,Ie,re,M,V]);let ee=(0,vt.useCallback)((Ee,he)=>{if(he.type!=="TASK"&&he.type!=="GATEWAY")return;let pe=Ie(he.id);pe&&(E==null||E(pe)),he.type==="TASK"&&de("SELECT_TASK",{id:he.id})},[Ie,E,de]),xe=(0,vt.useCallback)((Ee,he)=>{if(he.type!=="SEQUENCE_EDGE")return;let pe=l(he.source),De=l(he.target),{isFromStartEvent:pt,isGatewayToGateway:At,isActiviyToAndGateway:rt,isToEndEvent:Xt}=jr(pe,De);if(!(!pt&&!At&&!rt&&!Xt))return;let co=Ie(he.id);co&&(E==null||E(co))},[Ie,l,E]),Ce=(0,vt.useCallback)(Ee=>{let he=p(Ee,t);n(he),T(Ee),k()||B(),$(Ee)},[t,n,T,k,B,p,$]),Re=(0,vt.useCallback)(Ee=>{a(Ee),T(Ee),k()||B(),te(Ee)},[a,T,k,B,te]);ip(Ce);let Je=(0,vt.useCallback)(({nodes:Ee,edges:he})=>{y(Ee.length+he.length>=2)},[y]);(0,no.useOnSelectionChange)({onChange:Je});let wt=(0,vt.useCallback)(async({nodes:Ee})=>Ee.some(pe=>pe.type==="LANE"&&t.some(De=>De.parentId===pe.id))?(c({variant:"error",title:e("validation.errors.title"),content:e("editor.toolbar.delete_pool_lane_error")}),!1):!0,[t,e,c]),lo=()=>{T("forceSave"),X(),B()},Ft=()=>{m(!0)},Wt=()=>{m(!1),B()},ut=(0,vt.useCallback)(Ee=>{let he=new Set(Ee.filter(pe=>pe.type==="LANE"&&!!pe.parentId).map(pe=>pe.parentId));he.size!==0&&setTimeout(()=>{var pt,At;let pe=s(),De=new Map(pe.map(rt=>[rt.id,rt]));for(let rt of he){let Xt=$o(pe.filter(uo=>uo.type==="LANE"&&uo.parentId===rt));if(Xt.length===0)continue;let To=0;for(let uo of Xt)De.set(uo.id,w(_({},uo),{position:{x:ae.HEADER_WIDTH,y:To}})),To+=(At=(pt=uo.measured)==null?void 0:pt.height)!=null?At:0;let co=De.get(rt);co&&De.set(rt,w(_({},co),{height:To,measured:w(_({},co.measured),{height:To})}))}o(pe.map(rt=>{var Xt;return(Xt=De.get(rt.id))!=null?Xt:rt}))},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:v,onNodeDragStop:R,onNodeDragStart:S,onNodeClick:ee,onEdgeClick:xe,onDropCapture:lo,onConnectStart:Ft,onConnectEnd:Wt,onSelectionEnd:()=>setTimeout(()=>d.setState({nodesSelectionActive:!1}),0),onNodesChange:Ce,onEdgesChange:Re,onBeforeDelete:wt,onNodesDelete:ut},ui:{handleCloseValidationPanel:I},controls:{undo:h,redo:x,canUndo:N,canRedo:b},components:{HelperLines:g},actions:{saveHistory:T,selectElements:oe,clearSelection:le,exportToMxGraph:ve,validateDiagram:G,handleValidationComplete:D,setReconnectingEdge:M,clearReconnectingEdge:V}}};var bp=require("@xyflow/react"),Ho=require("react");var sy=".react-flow__node, .react-flow__edge, .react-flow__node-toolbar";function Tp(e,t,o){let[n,r]=(0,Ho.useState)(!1),i=(0,Ho.useRef)(null),{getViewport:a,setViewport:s}=(0,bp.useReactFlow)(),l=(0,Ho.useCallback)(()=>{i.current=null,r(!1)},[]);return(0,Ho.useEffect)(()=>{let c=e.current;if(!c)return;let d=m=>{if(!Mr.some(E=>E===m.button)||t.current||o.current||(r(!0),!(m.target instanceof Element))||!m.target.closest(sy))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}},u=m=>{let y=i.current;if(y){if((m.buttons&ca)===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&ca)===0&&l()};return c.addEventListener("pointerdown",d,!0),window.addEventListener("pointermove",u),window.addEventListener("pointerup",f),window.addEventListener("pointercancel",l),window.addEventListener("blur",l),()=>{c.removeEventListener("pointerdown",d,!0),window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",l),window.removeEventListener("blur",l)}},[e,t,o,a,s,l]),n}var fa=require("react/jsx-runtime"),fs=({id:e,className:t})=>(0,fa.jsx)("marker",{id:e,className:H("react-flow__arrowhead",t),viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"7",markerHeight:"7",orient:"auto",markerUnits:"userSpaceOnUse",fill:"currentColor",stroke:"currentColor",children:(0,fa.jsx)("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});var cn=require("react/jsx-runtime"),vp=()=>(0,cn.jsx)("svg",{style:{position:"absolute",top:0,left:0},children:(0,cn.jsxs)("defs",{children:[(0,cn.jsx)(fs,{id:"sequence-edge-marker",className:"text-grey-500"}),(0,cn.jsx)(fs,{id:"sequence-edge-marker-hovered",className:"text-grey-800"}),(0,cn.jsx)(fs,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});var zo=require("@produto-lecom/lecom-ui");var Hr=require("@xyflow/react"),Be=require("@produto-lecom/lecom-ui"),io=require("lucide-react"),bo=require("react");var Go=require("@produto-lecom/lecom-ui");var Or=(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))(Or||{});var gs=require("@produto-lecom/lecom-ui"),Rp=require("@xyflow/react");var Np=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 wp({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);ms(i,`${o}.csv`)}var ms=(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 Ap(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}var sM={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},Ip={script:"SCRIPT",subprocess:"SUBPROCESS"},Cp={"marker-loop":"LOOP"},Sp={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL",inclusive:"EXCLUSIVE"};var dn=({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}}},ly=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:dn({cell:e,type:"START_EVENT"}),status:n,originalType:o}},cy=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:dn({cell:e,type:"END_EVENT"}),status:n,originalType:o}},dy=(e,t)=>{let{id:o,subType:n,style:r}=e==null?void 0:e._attributes,i=Ip[n],a=t.get(o)||"",s=Cp[a]||"",l=s==="LOOP",c="imported";return!["script","none"].includes(n)&&!l&&(c="adapted"),e.mxGeometry._attributes.width=No(e.mxGeometry._attributes.width||0,ue.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=No(e.mxGeometry._attributes.height||0,ue.TASK.MIN_HEIGHT),{node:dn({cell:e,type:"TASK",variant:i,attribute:s}),status:c,originalType:r}},uy=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=Sp[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:dn({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},py=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:dn({cell:e,type:"LANE"}),status:"imported",originalType:t}},fy=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=No(e.mxGeometry._attributes.width||0,ue.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=No(e.mxGeometry._attributes.height||0,ue.ANNOTATION.MIN_HEIGHT),{node:dn({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},Mp=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:dn({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},Pp=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return w(_({},Pt),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},Lp={TASK:dy,GATEWAY:uy,START_EVENT:ly,END_EVENT:cy,LANE:py,ANNOTATION:fy};var my=e=>{let t=new Map,o=Object.values(Or),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=Lp[l]||Mp,{node:d,status:u,originalType:f}=c(s,r);a.push(d),i.push({originalType:f,type:d.type,variant:d.data.variant,value:Ap(d.data.label),status:u})}return{nodes:a,governanceIdToNodeIdMap:t,summary:i}},gy=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>Pp(r,t)),hy=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=my(t.root.mxCell),i=gy(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},yy=async e=>{let t=await Np(e),o=qi(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}},kp=async e=>{try{let t=await yy(e),{nodes:o,edges:n,summary:r}=hy(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};var Op=require("react/jsx-runtime"),Dp=()=>{let{t:e}=(0,gs.useTranslation)(),{toast:t}=lt(),{setNodes:o,setEdges:n}=(0,Rp.useReactFlow)(),{fitToNodes:r}=Wn(),i=s=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],c=s.map(d=>[d.originalType,d.value,e(`adapter.governance.report.status.${d.status.toLowerCase()}`)]);t({variant:"warning",content:e("adapter.governance.success.incompatible_cells"),duration:1e3*60*1,action:(0,Op.jsx)(gs.Button,{size:"small",variant:"ghost",onClick:()=>wp({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 kp(s);if(o(f=>f.concat(l)),n(f=>f.concat(c)),r(l),d.some(f=>f.status==="unsupported")){i(d);return}t({variant:"success",content:e("adapter.governance.success.default")})}catch(l){let c=l instanceof Error?l.message:"DEFAULT";t({variant:"error",content:e(`adapter.governance.error.${c}`)})}}}};var Vp=require("@produto-lecom/lecom-ui"),Hp=require("react");var un=require("react/jsx-runtime"),Gp=s=>{var l=s,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,a=Ut(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=(0,Hp.useRef)(null),d=f=>{let m=f.target.files;m!=null&&m.length&&i(m),c.current&&(c.current.value="")};return(0,un.jsxs)(un.Fragment,{children:[(0,un.jsx)(Vp.Button,w(_({disabled:n,onClick:f=>{var m;(m=c.current)==null||m.click(),r==null||r(f)}},a),{children:e})),(0,un.jsx)("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};var pn=require("react/jsx-runtime"),Bp=({disabled:e=!1})=>{let{t}=(0,Go.useTranslation)(),{toast:o}=lt(),{importFromGovernance:n}=Dp(),r=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},i=a=>{let s=a[0];if(!s){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}n(s)};return(0,pn.jsxs)(Go.Tooltip,{children:[(0,pn.jsx)(Go.TooltipTrigger,{asChild:!0,children:(0,pn.jsx)(Gp,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:(0,pn.jsx)(Ma,{})})}),(0,pn.jsx)(Go.TooltipContent,{color:"black",children:t("editor.controls.actions.import_governance")})]})};var zp=require("react/jsx-runtime"),ma=({shortcut:e})=>(0,zp.jsx)("span",{className:"min-h-7.5 inline-flex justify-center items-center py-0.5 px-1.5 bg-grey-100 border border-grey-300 font-mono text-gray-800 shadow-lg rounded-md text-grey-900",children:e});var Te=require("@produto-lecom/lecom-ui"),Bo=require("lucide-react"),$p=require("react");var Fp=require("@produto-lecom/lecom-ui"),Wp=require("@xyflow/react"),Vr=require("html-to-image"),Xp=require("react");var xy=3,ga="diagram",hs=50,Ey=96,_y=25.4,by="sequence-edge-marker",Yp=e=>e*_y/Ey,Ty=e=>{let t=document.getElementById(by);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},Up=()=>{let{t:e}=(0,Fp.useTranslation)(),{toast:t}=lt(),{getEdges:o,getNodes:n,getNodesBounds:r}=(0,Wp.useReactFlow)(),{clearSelection:i}=$t(),[a,s]=(0,Xp.useState)({png:!1,html:!1,print:!1}),l=()=>{let m=ta(n(),o()),y=r(m),E=y.width+hs*2,p=y.height+hs*2,g=hs-y.x,h=hs-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(m,y)=>{s(E=>w(_({},E),{[y]:!0})),await i();try{if(ta(n(),o()).length===0){t({content:e("editor.controls.actions.export.feedback.empty"),variant:"warning"});return}let p=Yd();if(!p)throw new Error("Flow element not found");let g=l(),h=Ty(p);try{return await m(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(m=ga)=>{await c(async(y,E)=>{let p=await(0,Vr.toPng)(y,w(_({},E),{backgroundColor:"#fcfcfc",skipFonts:!0}));ms(p,`${m}.png`)},"png")},exportAsHtml:async(m=ga)=>{await c(async(y,E)=>{let p=await(0,Vr.toSvg)(y,w(_({},E),{backgroundColor:"#fcfcfc",skipFonts:!0})),g=`
44
44
  <!DOCTYPE html>
45
45
  <html>
46
46
  <head>
@@ -67,7 +67,7 @@
67
67
  <body>
68
68
  <img src="${p}" alt="${m}" />
69
69
  </body>
70
- </html>`,h=new Blob([g],{type:"text/html"}),x=URL.createObjectURL(h);gs(x,`${m}.html`),window.setTimeout(()=>URL.revokeObjectURL(x),1e4)},"html")},printDiagram:async(m=ha)=>{await c(async(y,E)=>{var C;let p=await(0,Vr.toPng)(y,w(_({},E),{backgroundColor:"#fcfcfc",pixelRatio:Ey,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=Fp(E.width).toFixed(2),N=Fp(E.height).toFixed(2),b=h.createElement("style");b.textContent=`
70
+ </html>`,h=new Blob([g],{type:"text/html"}),x=URL.createObjectURL(h);ms(x,`${m}.html`),window.setTimeout(()=>URL.revokeObjectURL(x),1e4)},"html")},printDiagram:async(m=ga)=>{await c(async(y,E)=>{var C;let p=await(0,Vr.toPng)(y,w(_({},E),{backgroundColor:"#fcfcfc",pixelRatio:xy,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=Yp(E.width).toFixed(2),N=Yp(E.height).toFixed(2),b=h.createElement("style");b.textContent=`
71
71
  @page {
72
72
  size: ${x}mm ${N}mm;
73
73
  margin: 0;
@@ -83,11 +83,11 @@
83
83
  height: 100%;
84
84
  object-fit: contain;
85
85
  }
86
- `,h.head.appendChild(b),h.title=m;let T=h.createElement("img");T.alt="Diagram",h.body.appendChild(T),await new Promise((P,R)=>{let S=!1,L=K=>{S||(S=!0,K?R(K):P())};T.onload=()=>L(),T.onerror=()=>L(new Error("Failed to load print image")),T.src=p,T.complete&&T.naturalWidth>0&&L()});let v=g.contentWindow;if(!v)throw document.body.removeChild(g),new Error("Unable to access print iframe window");let A=()=>{g.parentNode&&document.body.removeChild(g)};v.addEventListener("afterprint",A,{once:!0}),window.setTimeout(A,6e4),v.focus(),v.print()},"print")},isPrintingPng:a.png,isPrintingHtml:a.html,isPrinting:a.print}};var Ae=require("react/jsx-runtime");function qp(){let{t:e}=(0,Te.useTranslation)(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:a}=$p(),[s,l]=(0,Kp.useState)(!1);return(0,Ae.jsxs)(Te.DropdownMenu,{modal:!1,open:s,onOpenChange:l,children:[(0,Ae.jsx)(Te.DropdownMenuTrigger,{asChild:!0,children:(0,Ae.jsx)("div",{children:(0,Ae.jsxs)(Te.Tooltip,{children:[(0,Ae.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,Ae.jsx)(Te.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:(0,Ae.jsx)(Bo.FolderOutputIcon,{})})}),!s&&(0,Ae.jsx)(Te.TooltipContent,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),(0,Ae.jsxs)(Te.DropdownMenuContent,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[(0,Ae.jsxs)(Te.Tooltip,{children:[(0,Ae.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,Ae.jsx)(Te.DropdownMenuItem,{className:"p-1.5",disabled:i,onClick:()=>t(),children:(0,Ae.jsx)(Bo.FileImageIcon,{})})}),(0,Ae.jsx)(Te.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),(0,Ae.jsxs)(Te.Tooltip,{children:[(0,Ae.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,Ae.jsx)(Te.DropdownMenuItem,{className:"p-1.5",disabled:a,onClick:()=>o(),children:(0,Ae.jsx)(Bo.FileCodeIcon,{})})}),(0,Ae.jsx)(Te.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),(0,Ae.jsxs)(Te.Tooltip,{children:[(0,Ae.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,Ae.jsx)(Te.DropdownMenuItem,{className:"p-1.5",disabled:r,onClick:()=>n(),children:(0,Ae.jsx)(Bo.PrinterIcon,{})})}),(0,Ae.jsx)(Te.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}var Qp=require("react"),no=require("@produto-lecom/lecom-ui"),jp=require("lucide-react");var ya=require("react"),qe=require("@produto-lecom/lecom-ui");var Zp=e=>{if(!e)return"";let t=e.trim();return t=t.replace(/```[a-zA-Z]*\s*/g,"").replace(/```/g,""),t=t.replace(/^\s*(graph|flowchart)\s+[A-Za-z]{1,2}\s*\r?\n/i,""),t.trim()};var Rt=require("react/jsx-runtime"),Ny=`Um passo (A --> B) por linha, com um ID antes de cada n\xF3. Ex.:
86
+ `,h.head.appendChild(b),h.title=m;let T=h.createElement("img");T.alt="Diagram",h.body.appendChild(T),await new Promise((P,R)=>{let S=!1,L=K=>{S||(S=!0,K?R(K):P())};T.onload=()=>L(),T.onerror=()=>L(new Error("Failed to load print image")),T.src=p,T.complete&&T.naturalWidth>0&&L()});let v=g.contentWindow;if(!v)throw document.body.removeChild(g),new Error("Unable to access print iframe window");let A=()=>{g.parentNode&&document.body.removeChild(g)};v.addEventListener("afterprint",A,{once:!0}),window.setTimeout(A,6e4),v.focus(),v.print()},"print")},isPrintingPng:a.png,isPrintingHtml:a.html,isPrinting:a.print}};var Ae=require("react/jsx-runtime");function Kp(){let{t:e}=(0,Te.useTranslation)(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:a}=Up(),[s,l]=(0,$p.useState)(!1);return(0,Ae.jsxs)(Te.DropdownMenu,{modal:!1,open:s,onOpenChange:l,children:[(0,Ae.jsx)(Te.DropdownMenuTrigger,{asChild:!0,children:(0,Ae.jsx)("div",{children:(0,Ae.jsxs)(Te.Tooltip,{children:[(0,Ae.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,Ae.jsx)(Te.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:(0,Ae.jsx)(Bo.FolderOutputIcon,{})})}),!s&&(0,Ae.jsx)(Te.TooltipContent,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),(0,Ae.jsxs)(Te.DropdownMenuContent,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[(0,Ae.jsxs)(Te.Tooltip,{children:[(0,Ae.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,Ae.jsx)(Te.DropdownMenuItem,{className:"p-1.5",disabled:i,onClick:()=>t(),children:(0,Ae.jsx)(Bo.FileImageIcon,{})})}),(0,Ae.jsx)(Te.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),(0,Ae.jsxs)(Te.Tooltip,{children:[(0,Ae.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,Ae.jsx)(Te.DropdownMenuItem,{className:"p-1.5",disabled:a,onClick:()=>o(),children:(0,Ae.jsx)(Bo.FileCodeIcon,{})})}),(0,Ae.jsx)(Te.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),(0,Ae.jsxs)(Te.Tooltip,{children:[(0,Ae.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,Ae.jsx)(Te.DropdownMenuItem,{className:"p-1.5",disabled:r,onClick:()=>n(),children:(0,Ae.jsx)(Bo.PrinterIcon,{})})}),(0,Ae.jsx)(Te.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}var Jp=require("react"),ro=require("@produto-lecom/lecom-ui"),Qp=require("lucide-react");var ha=require("react"),qe=require("@produto-lecom/lecom-ui");var qp=e=>{if(!e)return"";let t=e.trim();return t=t.replace(/```[a-zA-Z]*\s*/g,"").replace(/```/g,""),t=t.replace(/^\s*(graph|flowchart)\s+[A-Za-z]{1,2}\s*\r?\n/i,""),t.trim()};var Rt=require("react/jsx-runtime"),vy=`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>`,Jp=({open:e,onOpenChange:t})=>{let{t:o}=(0,qe.useTranslation)(),{importFromLia:n}=us(),[r,i]=(0,ya.useState)(""),[a,s]=(0,ya.useState)(null),l=d=>{d||(i(""),s(null)),t(d)},c=()=>{let d=Zp(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(0,Rt.jsx)(qe.Dialog,{open:e,onOpenChange:l,children:(0,Rt.jsxs)(qe.DialogContent,{className:"w-[90vw] max-w-4xl",children:[(0,Rt.jsxs)(qe.DialogHeader,{children:[(0,Rt.jsx)(qe.DialogTitle,{children:o("editor.modals.mermaid_import.title")}),(0,Rt.jsx)(qe.DialogDescription,{children:o("editor.modals.mermaid_import.description")})]}),(0,Rt.jsx)(qe.Textarea,{value:r,onChange:d=>{i(d.target.value),a&&s(null)},placeholder:Ny,rows:16,className:"max-h-[60vh] min-h-[360px] resize-y font-mono"}),a&&(0,Rt.jsx)("p",{className:"text-sm text-red-500",children:a}),(0,Rt.jsxs)(qe.DialogFooter,{children:[(0,Rt.jsx)(qe.Button,{variant:"ghost",color:"grey",onClick:()=>l(!1),children:o("editor.modals.mermaid_import.cancel")}),(0,Rt.jsx)(qe.Button,{variant:"filled",color:"blue",onClick:c,children:o("editor.modals.mermaid_import.generate")})]})]})})};var zt=require("react/jsx-runtime"),ef=()=>{let{t:e}=(0,no.useTranslation)(),[t,o]=(0,Qp.useState)(!1);return(0,zt.jsxs)(zt.Fragment,{children:[(0,zt.jsxs)(no.Tooltip,{children:[(0,zt.jsx)(no.TooltipTrigger,{asChild:!0,children:(0,zt.jsx)(no.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>o(!0),children:(0,zt.jsx)(jp.WorkflowIcon,{})})}),(0,zt.jsx)(no.TooltipContent,{color:"black",children:e("editor.controls.actions.import_mermaid")})]}),(0,zt.jsx)(Jp,{open:t,onOpenChange:o})]})};var me=require("react/jsx-runtime"),tf=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=(0,Be.useTranslation)(),{clearSelection:i}=Lo(),{mode:a,containerRef:s,featureFlags:l,isMinimapOpen:c,setIsMinimapOpen:d,isMoveTool:u,isHandTool:f,setIsMoveTool:m,setIsHandTool:y}=q(),{getNodes:E,getEdges:p}=(0,Hr.useReactFlow)(),g=(0,Hr.useKeyPress)(["v","V"],{target:s==null?void 0:s.current}),h=(0,Hr.useKeyPress)(["h","H"],{target:s==null?void 0:s.current}),x=(0,_o.useCallback)(()=>{i(),y(!0),m(!1)},[i,y,m]),N=(0,_o.useCallback)(()=>{m(!0),y(!1)},[m,y]),[b,T]=(0,_o.useState)(!1),v=(0,_o.useCallback)(async()=>{T(!0);try{let A=E(),C=p(),P=await o({nodes:A,edges:C});n(P)}finally{T(!1)}},[E,p,o,n]);return(0,_o.useEffect)(()=>{g&&!u&&a==="edit"&&N()},[g,N,u,a]),(0,_o.useEffect)(()=>{h&&!f&&a==="edit"&&x()},[h,x,f,a]),(0,me.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[a==="edit"&&(0,me.jsxs)(me.Fragment,{children:[(0,me.jsxs)(Be.Tooltip,{children:[(0,me.jsx)(Be.TooltipTrigger,{asChild:!0,children:(0,me.jsx)(Be.Button,{size:"small",variant:"ghost",color:"grey",className:H(u&&"bg-grey-400"),iconButton:!0,onClick:N,children:(0,me.jsx)(ro.MousePointerIcon,{})})}),(0,me.jsxs)(Be.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),(0,me.jsx)(ga,{shortcut:"V"})]})]}),(0,me.jsxs)(Be.Tooltip,{children:[(0,me.jsx)(Be.TooltipTrigger,{asChild:!0,children:(0,me.jsx)(Be.Button,{size:"small",variant:"ghost",color:"grey",className:H(f&&"bg-grey-400"),iconButton:!0,onClick:x,children:(0,me.jsx)(ro.HandIcon,{})})}),(0,me.jsxs)(Be.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",(0,me.jsx)(ga,{shortcut:"H"})]})]})]}),(0,me.jsx)(qp,{}),a==="edit"&&(0,me.jsxs)(me.Fragment,{children:[(l==null?void 0:l.importDiagramMermaidEnabled)&&(0,me.jsx)(ef,{}),(0,me.jsxs)(Be.Tooltip,{children:[(0,me.jsx)(Be.TooltipTrigger,{asChild:!0,children:(0,me.jsx)(Be.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:b,onClick:v,children:b?(0,me.jsx)(ro.Loader2Icon,{className:"animate-spin"}):(0,me.jsx)(ro.ListCheckIcon,{})})}),(0,me.jsx)(Be.TooltipContent,{color:"black",children:r(b?"editor.controls.actions.check_loading":"editor.controls.actions.check")})]}),(0,me.jsx)(zp,{disabled:e.length>0||t.length>0})]}),(0,me.jsxs)(Be.Tooltip,{children:[(0,me.jsx)(Be.TooltipTrigger,{asChild:!0,children:(0,me.jsx)(Be.Button,{size:"small",variant:"ghost",color:"grey",className:H(c&&"bg-grey-400"),iconButton:!0,onClick:()=>d(!c),children:(0,me.jsx)(ro.MapIcon,{})})}),(0,me.jsx)(Be.TooltipContent,{color:"black",children:r(c?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};var dt=require("@produto-lecom/lecom-ui"),xs=require("lucide-react"),Nt=require("react/jsx-runtime"),of=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=(0,dt.useTranslation)();return(0,Nt.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,Nt.jsxs)(dt.Tooltip,{children:[(0,Nt.jsx)(dt.TooltipTrigger,{asChild:!0,children:(0,Nt.jsx)(dt.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:(0,Nt.jsx)(xs.UndoIcon,{})})}),(0,Nt.jsx)(dt.TooltipContent,{color:"black",children:r("editor.controls.history.undo")})]}),(0,Nt.jsxs)(dt.Tooltip,{children:[(0,Nt.jsx)(dt.TooltipTrigger,{asChild:!0,children:(0,Nt.jsx)(dt.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:(0,Nt.jsx)(xs.RedoIcon,{})})}),(0,Nt.jsx)(dt.TooltipContent,{color:"black",children:r("editor.controls.history.redo")})]})]})};var Un=require("@xyflow/react"),ze=require("@produto-lecom/lecom-ui"),$n=require("lucide-react");var Ve=require("react/jsx-runtime"),nf=()=>{let{t:e}=(0,ze.useTranslation)(),t=(0,Un.useNodes)(),o=(0,Un.useEdges)(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:a}=(0,Un.useReactFlow)(),s=t.length===0&&o.length===0;return(0,Ve.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,Ve.jsxs)(ze.Tooltip,{children:[(0,Ve.jsx)(ze.TooltipTrigger,{asChild:!0,children:(0,Ve.jsx)(ze.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>a(),children:(0,Ve.jsx)($n.ScanIcon,{})})}),(0,Ve.jsx)(ze.TooltipContent,{color:"black",children:e("editor.controls.zoom.fit")})]}),(0,Ve.jsxs)(ze.Tooltip,{children:[(0,Ve.jsx)(ze.TooltipTrigger,{asChild:!0,children:(0,Ve.jsx)(ze.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>r(),children:(0,Ve.jsx)($n.ZoomOut,{})})}),(0,Ve.jsx)(ze.TooltipContent,{color:"black",children:e("editor.controls.zoom.out")})]}),(0,Ve.jsxs)(ze.Tooltip,{children:[(0,Ve.jsx)(ze.TooltipTrigger,{asChild:!0,children:(0,Ve.jsx)(ze.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>i(1),children:(0,Ve.jsx)(Da,{})})}),(0,Ve.jsx)(ze.TooltipContent,{color:"black",children:e("editor.controls.zoom.reset")})]}),(0,Ve.jsxs)(ze.Tooltip,{children:[(0,Ve.jsx)(ze.TooltipTrigger,{asChild:!0,children:(0,Ve.jsx)(ze.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>n(),children:(0,Ve.jsx)($n.ZoomIn,{})})}),(0,Ve.jsx)(ze.TooltipContent,{color:"black",children:e("editor.controls.zoom.in")})]})]})};var rf=require("@xyflow/react"),fn=require("react/jsx-runtime"),sf=()=>(0,fn.jsxs)(rf.ViewportPortal,{children:[(0,fn.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 20 20",className:"text-grey-400 -translate-x-1/2 -translate-y-1/2 pointer-events-none",children:[(0,fn.jsx)("line",{x1:"0",y1:"10",x2:"20",y2:"10",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"}),(0,fn.jsx)("line",{x1:"10",y1:"0",x2:"10",y2:"20",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"})]}),(0,fn.jsx)("div",{className:"absolute top-1 left-1 text-xs font-medium text-grey-400 bg-white/70 px-1 rounded-sm pointer-events-none",children:"0,0"})]});var af=require("@xyflow/react"),io=require("@produto-lecom/lecom-ui"),Es=require("react");var lf=require("lucide-react");var Yt=require("react/jsx-runtime"),cf=()=>{let e=(0,Es.useRef)(null),{t}=(0,io.useTranslation)(),{setDraggableNode:o}=Yn(),n=(0,af.useNodes)(),{setIsDragging:r}=q(),[i,a]=(0,Es.useState)(void 0),s=[{type:"START_EVENT",icon:Kr,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:gn,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:Qn,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:jn,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SERVICE_TASK",icon:lf.Bot,label:t("bpmn.task.variant.service_task")},{type:"TASK",variant:"SCRIPT",icon:Va,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:Oa,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:xn,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:_n,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:hn,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:Ra,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:Xr,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),a((0,Yt.jsx)(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return(0,Yt.jsxs)("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[(0,Yt.jsx)("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:s.map((c,d)=>{let u=!Po(c.type,n),f=u?t("editor.toolbar.start_event_already_exists"):c.label;return(0,Yt.jsxs)(io.Tooltip,{children:[(0,Yt.jsx)(io.TooltipTrigger,{asChild:!0,children:(0,Yt.jsx)(io.Button,{className:H("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":u}),size:"small",variant:"ghost",color:"grey",draggable:!u,disabled:u,iconButton:!0,onDragStart:u?void 0:m=>l(m,c),children:(0,Yt.jsx)(c.icon,{})},d)}),(0,Yt.jsx)(io.TooltipContent,{color:"black",side:"right",children:f})]},d)})}),(0,Yt.jsx)("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};var Ze=require("react/jsx-runtime"),xa=e=>e.preventDefault(),Ea=(0,mn.forwardRef)((e,t)=>{let{instanceId:o,containerRef:n,mode:r,isMinimapOpen:i,isMoveTool:a,isHandTool:s}=q(),l=(0,so.useKeyPress)("Space",{target:n==null?void 0:n.current}),c=(0,mn.useRef)(s),d=(0,mn.useRef)(l),{nodes:u,edges:f,actions:m,events:y,components:E,controls:p}=bp(),{t:g}=(0,zo.useTranslation)();c.current=s,d.current=l;let h=vp(n,c,d);(0,mn.useImperativeHandle)(t,()=>({selectElements:m.selectElements,clearSelection:m.clearSelection}));let x=s||l||r!=="edit",N=x?[0,1,2]:Mr,b=s||l||h,T=a&&!l&&!h,v=r==="edit"&&T,A=!x&&!h,C=r==="view"||T;return(0,Ze.jsxs)("div",{ref:n,className:"w-full h-full outline-none",tabIndex:0,children:[r==="edit"&&(0,Ze.jsx)(cf,{}),(0,Ze.jsx)(Np,{}),(0,Ze.jsxs)(so.ReactFlow,w(_({},y),{id:`modeler-${o}`,className:H(r.toLowerCase(),{"is-hand-tool":b,"is-pan-tool-active":b}),edges:f,nodes:u,nodeTypes:mu,edgeTypes:gu,minZoom:ca,maxZoom:bu,panOnDrag:N,panOnScroll:!0,selectionOnDrag:A,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:C,nodesConnectable:v,nodesDraggable:v,connectionLineComponent:uu,selectionMode:so.SelectionMode.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:v?"Delete":null,selectionKeyCode:null,defaultViewport:Au,connectOnClick:!1,connectionRadius:50,onPaneContextMenu:xa,onNodeContextMenu:xa,onEdgeContextMenu:xa,proOptions:{hideAttribution:!0},children:[(0,Ze.jsx)(so.Background,{gap:Eu,size:xu,color:yu,bgColor:hu}),(0,Ze.jsx)(sf,{}),i&&(0,Ze.jsxs)(zo.Tooltip,{children:[(0,Ze.jsx)(zo.TooltipTrigger,{asChild:!0,children:(0,Ze.jsx)("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:(0,Ze.jsx)(so.MiniMap,{pannable:!0,zoomable:!0,position:_u,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),(0,Ze.jsx)(zo.TooltipContent,{color:"black",children:g("editor.controls.actions.minimap.label")})]}),(0,Ze.jsxs)("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&(0,Ze.jsx)(of,_({},p)),r!=="readonly"&&(0,Ze.jsx)(tf,{nodes:u,edges:f,validateDiagram:m.validateDiagram,handleValidationComplete:m.handleValidationComplete}),(0,Ze.jsx)(nf,{})]}),(0,Ze.jsx)(E.HelperLines,{})]}))]})});Ea.displayName="Editor";var df=require("@xyflow/react"),_s=require("react"),uf=require("react/jsx-runtime"),wy=e=>({width:e.width,height:e.height,transform:e.transform}),_a="rgba(51, 103, 217, 0.4)",qc=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=(0,df.useStore)(wy),i=(0,_s.useRef)(null);return(0,_s.useEffect)(()=>{let a=i.current,s=a==null?void 0:a.getContext("2d");if(!s||!a)return;let l=window.devicePixelRatio;a.width=o*l,a.height=n*l,s.clearRect(0,0,o,n),s.scale(l,l),s.strokeStyle=_a,t&&(s.beginPath(),s.strokeStyle=t.color||_a,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||_a,s.moveTo(0,e.position*r[2]+r[1]),s.lineTo(o,e.position*r[2]+r[1]),s.stroke())},[o,n,r,e,t]),(0,uf.jsx)("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};var Kn=require("@produto-lecom/lecom-ui"),Yo=require("react");var Gr=require("react/jsx-runtime"),Qt=new Map,pf=(0,Yo.createContext)(null),Ln=()=>{let e=(0,Yo.useContext)(pf);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},ff=({locale:e,defaultMode:t="view",featureFlags:o,toast:n,children:r})=>{let[i,a]=(0,Yo.useState)(e||"pt_BR");(0,Yo.useEffect)(()=>{e&&(a(e),Kn.i18n.changeLanguage(e))},[e]);let s=E=>{let p=Qt.size;if(p===0)throw new Error("No modeler instances found");if(p===1||!E){let[h]=Qt.values();return h}let g=Qt.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)},f=async(E,p)=>{let g=s(p);await(g==null?void 0:g.importFromMxGraph(E))},m=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(0,Gr.jsx)(pf.Provider,{value:{defaultMode:t,locale:i,featureFlags:o,selectElements:l,clearSelection:c,configureElement:d,getConfigureElement:u,importDiagram:f,exportDiagram:m,getElementsCount:y,toast:n},children:(0,Gr.jsxs)(Kn.TooltipProvider,{children:[!n&&(0,Gr.jsx)(Kn.Notification,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),r]})})};var bs=require("react/jsx-runtime"),hf=(0,Le.createContext)(null),q=()=>{let e=(0,Le.useContext)(hf);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},yf=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,edgeHighlight:r=!0,validateCustomDiagram:i,onElementChanges:a,onConfigureElement:s,onElementClick:l,onSubprocessValidationClick:c})=>{let d=(0,Le.useRef)(null),{t:u}=(0,mf.useTranslation)(),{defaultMode:f,featureFlags:m}=Ln(),y=(0,Le.useId)(),[E]=(0,Le.useState)(o||y),[p,g]=(0,Le.useState)(n||f||"edit"),[h,x]=(0,Le.useState)(br),[N,b]=(0,Le.useState)(!1),[T,v]=(0,Le.useState)(!0),[A,C]=(0,Le.useState)(!1),[P,R]=(0,Le.useState)(!1),[S,L]=(0,Le.useState)(!1),[K,j]=(0,Le.useState)(!1),[Q,z]=(0,Le.useState)(!1),[M,V]=(0,Le.useState)(null);(0,Le.useEffect)(()=>{n&&g(n)},[n]);let D=!!t,I=(0,Le.useMemo)(()=>t||Nd(u),[t,u]),B=(0,Le.useMemo)(()=>({instanceId:E,containerRef:d,initialDiagram:I,mode:p,featureFlags:m,edgeHighlight:r,isEdit:p==="edit",isView:p==="view",isReadOnly:p==="readonly",isNewDiagram:D,lastElementId:h,isInitialized:N,isMinimapOpen:P,isMoveTool:T,isHandTool:A,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,I,p,m,r,D,h,N,P,T,A,S,Q,K,M,i,a,s,l,c]);return(0,bs.jsx)(gf.ReactFlowProvider,{children:(0,bs.jsx)(hf.Provider,{value:B,children:(0,bs.jsx)(Ea,{ref:e})})})};0&&(module.exports={EditorMode,ElementPosition,ElementType,GatewayElementVariant,GatewayVariant,Modeler,ModelerProvider,NodeAttribute,NodeType,NodeVariant,RoutingVariant,useModeler});
93
+ E --> F<end>`,Zp=({open:e,onOpenChange:t})=>{let{t:o}=(0,qe.useTranslation)(),{importFromLia:n}=ds(),[r,i]=(0,ha.useState)(""),[a,s]=(0,ha.useState)(null),l=d=>{d||(i(""),s(null)),t(d)},c=()=>{let d=qp(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(0,Rt.jsx)(qe.Dialog,{open:e,onOpenChange:l,children:(0,Rt.jsxs)(qe.DialogContent,{className:"w-[90vw] max-w-4xl",children:[(0,Rt.jsxs)(qe.DialogHeader,{children:[(0,Rt.jsx)(qe.DialogTitle,{children:o("editor.modals.mermaid_import.title")}),(0,Rt.jsx)(qe.DialogDescription,{children:o("editor.modals.mermaid_import.description")})]}),(0,Rt.jsx)(qe.Textarea,{value:r,onChange:d=>{i(d.target.value),a&&s(null)},placeholder:vy,rows:16,className:"max-h-[60vh] min-h-[360px] resize-y font-mono"}),a&&(0,Rt.jsx)("p",{className:"text-sm text-red-500",children:a}),(0,Rt.jsxs)(qe.DialogFooter,{children:[(0,Rt.jsx)(qe.Button,{variant:"ghost",color:"grey",onClick:()=>l(!1),children:o("editor.modals.mermaid_import.cancel")}),(0,Rt.jsx)(qe.Button,{variant:"filled",color:"blue",onClick:c,children:o("editor.modals.mermaid_import.generate")})]})]})})};var zt=require("react/jsx-runtime"),jp=()=>{let{t:e}=(0,ro.useTranslation)(),[t,o]=(0,Jp.useState)(!1);return(0,zt.jsxs)(zt.Fragment,{children:[(0,zt.jsxs)(ro.Tooltip,{children:[(0,zt.jsx)(ro.TooltipTrigger,{asChild:!0,children:(0,zt.jsx)(ro.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>o(!0),children:(0,zt.jsx)(Qp.WorkflowIcon,{})})}),(0,zt.jsx)(ro.TooltipContent,{color:"black",children:e("editor.controls.actions.import_mermaid")})]}),(0,zt.jsx)(Zp,{open:t,onOpenChange:o})]})};var me=require("react/jsx-runtime"),ef=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=(0,Be.useTranslation)(),{clearSelection:i}=$t(),{mode:a,containerRef:s,featureFlags:l,isMinimapOpen:c,setIsMinimapOpen:d,isMoveTool:u,isHandTool:f,setIsMoveTool:m,setIsHandTool:y}=q(),{getNodes:E,getEdges:p}=(0,Hr.useReactFlow)(),g=(0,Hr.useKeyPress)(["v","V"],{target:s==null?void 0:s.current}),h=(0,Hr.useKeyPress)(["h","H"],{target:s==null?void 0:s.current}),x=(0,bo.useCallback)(()=>{i(),y(!0),m(!1)},[i,y,m]),N=(0,bo.useCallback)(()=>{m(!0),y(!1)},[m,y]),[b,T]=(0,bo.useState)(!1),v=(0,bo.useCallback)(async()=>{T(!0);try{let A=E(),C=p(),P=await o({nodes:A,edges:C});n(P)}finally{T(!1)}},[E,p,o,n]);return(0,bo.useEffect)(()=>{g&&!u&&a==="edit"&&N()},[g,N,u,a]),(0,bo.useEffect)(()=>{h&&!f&&a==="edit"&&x()},[h,x,f,a]),(0,me.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[a==="edit"&&(0,me.jsxs)(me.Fragment,{children:[(0,me.jsxs)(Be.Tooltip,{children:[(0,me.jsx)(Be.TooltipTrigger,{asChild:!0,children:(0,me.jsx)(Be.Button,{size:"small",variant:"ghost",color:"grey",className:H(u&&"bg-grey-400"),iconButton:!0,onClick:N,children:(0,me.jsx)(io.MousePointerIcon,{})})}),(0,me.jsxs)(Be.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),(0,me.jsx)(ma,{shortcut:"V"})]})]}),(0,me.jsxs)(Be.Tooltip,{children:[(0,me.jsx)(Be.TooltipTrigger,{asChild:!0,children:(0,me.jsx)(Be.Button,{size:"small",variant:"ghost",color:"grey",className:H(f&&"bg-grey-400"),iconButton:!0,onClick:x,children:(0,me.jsx)(io.HandIcon,{})})}),(0,me.jsxs)(Be.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",(0,me.jsx)(ma,{shortcut:"H"})]})]})]}),(0,me.jsx)(Kp,{}),a==="edit"&&(0,me.jsxs)(me.Fragment,{children:[(l==null?void 0:l.importDiagramMermaidEnabled)&&(0,me.jsx)(jp,{}),(0,me.jsxs)(Be.Tooltip,{children:[(0,me.jsx)(Be.TooltipTrigger,{asChild:!0,children:(0,me.jsx)(Be.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:b,onClick:v,children:b?(0,me.jsx)(io.Loader2Icon,{className:"animate-spin"}):(0,me.jsx)(io.ListCheckIcon,{})})}),(0,me.jsx)(Be.TooltipContent,{color:"black",children:r(b?"editor.controls.actions.check_loading":"editor.controls.actions.check")})]}),(0,me.jsx)(Bp,{disabled:e.length>0||t.length>0})]}),(0,me.jsxs)(Be.Tooltip,{children:[(0,me.jsx)(Be.TooltipTrigger,{asChild:!0,children:(0,me.jsx)(Be.Button,{size:"small",variant:"ghost",color:"grey",className:H(c&&"bg-grey-400"),iconButton:!0,onClick:()=>d(!c),children:(0,me.jsx)(io.MapIcon,{})})}),(0,me.jsx)(Be.TooltipContent,{color:"black",children:r(c?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};var dt=require("@produto-lecom/lecom-ui"),ys=require("lucide-react"),Nt=require("react/jsx-runtime"),tf=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=(0,dt.useTranslation)();return(0,Nt.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,Nt.jsxs)(dt.Tooltip,{children:[(0,Nt.jsx)(dt.TooltipTrigger,{asChild:!0,children:(0,Nt.jsx)(dt.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:(0,Nt.jsx)(ys.UndoIcon,{})})}),(0,Nt.jsx)(dt.TooltipContent,{color:"black",children:r("editor.controls.history.undo")})]}),(0,Nt.jsxs)(dt.Tooltip,{children:[(0,Nt.jsx)(dt.TooltipTrigger,{asChild:!0,children:(0,Nt.jsx)(dt.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:(0,Nt.jsx)(ys.RedoIcon,{})})}),(0,Nt.jsx)(dt.TooltipContent,{color:"black",children:r("editor.controls.history.redo")})]})]})};var Un=require("@xyflow/react"),ze=require("@produto-lecom/lecom-ui"),$n=require("lucide-react");var Ve=require("react/jsx-runtime"),of=()=>{let{t:e}=(0,ze.useTranslation)(),t=(0,Un.useNodes)(),o=(0,Un.useEdges)(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:a}=(0,Un.useReactFlow)(),s=t.length===0&&o.length===0;return(0,Ve.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,Ve.jsxs)(ze.Tooltip,{children:[(0,Ve.jsx)(ze.TooltipTrigger,{asChild:!0,children:(0,Ve.jsx)(ze.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>a(),children:(0,Ve.jsx)($n.ScanIcon,{})})}),(0,Ve.jsx)(ze.TooltipContent,{color:"black",children:e("editor.controls.zoom.fit")})]}),(0,Ve.jsxs)(ze.Tooltip,{children:[(0,Ve.jsx)(ze.TooltipTrigger,{asChild:!0,children:(0,Ve.jsx)(ze.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>r(),children:(0,Ve.jsx)($n.ZoomOut,{})})}),(0,Ve.jsx)(ze.TooltipContent,{color:"black",children:e("editor.controls.zoom.out")})]}),(0,Ve.jsxs)(ze.Tooltip,{children:[(0,Ve.jsx)(ze.TooltipTrigger,{asChild:!0,children:(0,Ve.jsx)(ze.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>i(1),children:(0,Ve.jsx)(Ra,{})})}),(0,Ve.jsx)(ze.TooltipContent,{color:"black",children:e("editor.controls.zoom.reset")})]}),(0,Ve.jsxs)(ze.Tooltip,{children:[(0,Ve.jsx)(ze.TooltipTrigger,{asChild:!0,children:(0,Ve.jsx)(ze.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>n(),children:(0,Ve.jsx)($n.ZoomIn,{})})}),(0,Ve.jsx)(ze.TooltipContent,{color:"black",children:e("editor.controls.zoom.in")})]})]})};var nf=require("@xyflow/react"),fn=require("react/jsx-runtime"),rf=()=>(0,fn.jsxs)(nf.ViewportPortal,{children:[(0,fn.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 20 20",className:"text-grey-400 -translate-x-1/2 -translate-y-1/2 pointer-events-none",children:[(0,fn.jsx)("line",{x1:"0",y1:"10",x2:"20",y2:"10",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"}),(0,fn.jsx)("line",{x1:"10",y1:"0",x2:"10",y2:"20",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"})]}),(0,fn.jsx)("div",{className:"absolute top-1 left-1 text-xs font-medium text-grey-400 bg-white/70 px-1 rounded-sm pointer-events-none",children:"0,0"})]});var sf=require("@xyflow/react"),so=require("@produto-lecom/lecom-ui"),xs=require("react");var af=require("lucide-react");var Yt=require("react/jsx-runtime"),lf=()=>{let e=(0,xs.useRef)(null),{t}=(0,so.useTranslation)(),{setDraggableNode:o}=Yn(),n=(0,sf.useNodes)(),{setIsDragging:r}=q(),[i,a]=(0,xs.useState)(void 0),s=[{type:"START_EVENT",icon:Kr,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:gn,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:Qn,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:jn,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SERVICE_TASK",icon:af.Bot,label:t("bpmn.task.variant.service_task")},{type:"TASK",variant:"SCRIPT",icon:Oa,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:Da,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:xn,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:_n,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:hn,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:ka,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:Xr,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),a((0,Yt.jsx)(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return(0,Yt.jsxs)("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[(0,Yt.jsx)("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:s.map((c,d)=>{let u=!Lo(c.type,n),f=u?t("editor.toolbar.start_event_already_exists"):c.label;return(0,Yt.jsxs)(so.Tooltip,{children:[(0,Yt.jsx)(so.TooltipTrigger,{asChild:!0,children:(0,Yt.jsx)(so.Button,{className:H("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":u}),size:"small",variant:"ghost",color:"grey",draggable:!u,disabled:u,iconButton:!0,onDragStart:u?void 0:m=>l(m,c),children:(0,Yt.jsx)(c.icon,{})},d)}),(0,Yt.jsx)(so.TooltipContent,{color:"black",side:"right",children:f})]},d)})}),(0,Yt.jsx)("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};var Ze=require("react/jsx-runtime"),ya=e=>e.preventDefault(),xa=(0,mn.forwardRef)((e,t)=>{let{instanceId:o,containerRef:n,mode:r,isMinimapOpen:i,isMoveTool:a,isHandTool:s}=q(),l=(0,ao.useKeyPress)("Space",{target:n==null?void 0:n.current}),c=(0,mn.useRef)(s),d=(0,mn.useRef)(l),{nodes:u,edges:f,actions:m,events:y,components:E,controls:p}=_p(),{t:g}=(0,zo.useTranslation)();c.current=s,d.current=l;let h=Tp(n,c,d);(0,mn.useImperativeHandle)(t,()=>({selectElements:m.selectElements,clearSelection:m.clearSelection}));let x=s||l||r!=="edit",N=x?[0,1,2]:Mr,b=s||l||h,T=a&&!l&&!h,v=r==="edit"&&T,A=!x&&!h,C=r==="view"||T;return(0,Ze.jsxs)("div",{ref:n,className:"w-full h-full outline-none",tabIndex:0,children:[r==="edit"&&(0,Ze.jsx)(lf,{}),(0,Ze.jsx)(vp,{}),(0,Ze.jsxs)(ao.ReactFlow,w(_({},y),{id:`modeler-${o}`,className:H(r.toLowerCase(),{"is-hand-tool":b,"is-pan-tool-active":b}),edges:f,nodes:u,nodeTypes:fu,edgeTypes:mu,minZoom:la,maxZoom:_u,panOnDrag:N,panOnScroll:!0,selectionOnDrag:A,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:C,nodesConnectable:v,nodesDraggable:v,connectionLineComponent:du,selectionMode:ao.SelectionMode.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:v?"Delete":null,selectionKeyCode:null,defaultViewport:wu,connectOnClick:!1,connectionRadius:50,onPaneContextMenu:ya,onNodeContextMenu:ya,onEdgeContextMenu:ya,proOptions:{hideAttribution:!0},children:[(0,Ze.jsx)(ao.Background,{gap:xu,size:yu,color:hu,bgColor:gu}),(0,Ze.jsx)(rf,{}),i&&(0,Ze.jsxs)(zo.Tooltip,{children:[(0,Ze.jsx)(zo.TooltipTrigger,{asChild:!0,children:(0,Ze.jsx)("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:(0,Ze.jsx)(ao.MiniMap,{pannable:!0,zoomable:!0,position:Eu,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),(0,Ze.jsx)(zo.TooltipContent,{color:"black",children:g("editor.controls.actions.minimap.label")})]}),(0,Ze.jsxs)("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&(0,Ze.jsx)(tf,_({},p)),r!=="readonly"&&(0,Ze.jsx)(ef,{nodes:u,edges:f,validateDiagram:m.validateDiagram,handleValidationComplete:m.handleValidationComplete}),(0,Ze.jsx)(of,{})]}),(0,Ze.jsx)(E.HelperLines,{})]}))]})});xa.displayName="Editor";var cf=require("@xyflow/react"),Es=require("react"),df=require("react/jsx-runtime"),Ny=e=>({width:e.width,height:e.height,transform:e.transform}),Ea="rgba(51, 103, 217, 0.4)",qc=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=(0,cf.useStore)(Ny),i=(0,Es.useRef)(null);return(0,Es.useEffect)(()=>{let a=i.current,s=a==null?void 0:a.getContext("2d");if(!s||!a)return;let l=window.devicePixelRatio;a.width=o*l,a.height=n*l,s.clearRect(0,0,o,n),s.scale(l,l),s.strokeStyle=Ea,t&&(s.beginPath(),s.strokeStyle=t.color||Ea,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||Ea,s.moveTo(0,e.position*r[2]+r[1]),s.lineTo(o,e.position*r[2]+r[1]),s.stroke())},[o,n,r,e,t]),(0,df.jsx)("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};var Kn=require("@produto-lecom/lecom-ui"),Yo=require("react");var Gr=require("react/jsx-runtime"),jt=new Map,uf=(0,Yo.createContext)(null),Ln=()=>{let e=(0,Yo.useContext)(uf);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},pf=({locale:e,defaultMode:t="view",featureFlags:o,toast:n,children:r})=>{let[i,a]=(0,Yo.useState)(e||"pt_BR");(0,Yo.useEffect)(()=>{e&&(a(e),Kn.i18n.changeLanguage(e))},[e]);let s=E=>{let p=jt.size;if(p===0)throw new Error("No modeler instances found");if(p===1||!E){let[h]=jt.values();return h}let g=jt.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)},f=async(E,p)=>{let g=s(p);await(g==null?void 0:g.importFromMxGraph(E))},m=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(0,Gr.jsx)(uf.Provider,{value:{defaultMode:t,locale:i,featureFlags:o,selectElements:l,clearSelection:c,configureElement:d,getConfigureElement:u,importDiagram:f,exportDiagram:m,getElementsCount:y,toast:n},children:(0,Gr.jsxs)(Kn.TooltipProvider,{children:[!n&&(0,Gr.jsx)(Kn.Notification,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),r]})})};var _s=require("react/jsx-runtime"),gf=(0,Le.createContext)(null),q=()=>{let e=(0,Le.useContext)(gf);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},hf=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,edgeHighlight:r=!0,validateCustomDiagram:i,onElementChanges:a,onConfigureElement:s,onElementClick:l,onSubprocessValidationClick:c})=>{let d=(0,Le.useRef)(null),{t:u}=(0,ff.useTranslation)(),{defaultMode:f,featureFlags:m}=Ln(),y=(0,Le.useId)(),[E]=(0,Le.useState)(o||y),[p,g]=(0,Le.useState)(n||f||"edit"),[h,x]=(0,Le.useState)(br),[N,b]=(0,Le.useState)(!1),[T,v]=(0,Le.useState)(!0),[A,C]=(0,Le.useState)(!1),[P,R]=(0,Le.useState)(!1),[S,L]=(0,Le.useState)(!1),[K,j]=(0,Le.useState)(!1),[Q,z]=(0,Le.useState)(!1),[M,V]=(0,Le.useState)(null);(0,Le.useEffect)(()=>{n&&g(n)},[n]);let D=!!t,I=(0,Le.useMemo)(()=>t||vd(u),[t,u]),B=(0,Le.useMemo)(()=>({instanceId:E,containerRef:d,initialDiagram:I,mode:p,featureFlags:m,edgeHighlight:r,isEdit:p==="edit",isView:p==="view",isReadOnly:p==="readonly",isNewDiagram:D,lastElementId:h,isInitialized:N,isMinimapOpen:P,isMoveTool:T,isHandTool:A,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,I,p,m,r,D,h,N,P,T,A,S,Q,K,M,i,a,s,l,c]);return(0,_s.jsx)(mf.ReactFlowProvider,{children:(0,_s.jsx)(gf.Provider,{value:B,children:(0,_s.jsx)(xa,{ref:e})})})};0&&(module.exports={EditorMode,ElementPosition,ElementType,GatewayElementVariant,GatewayVariant,Modeler,ModelerProvider,NodeAttribute,NodeType,NodeVariant,RoutingVariant,useModeler});