lecom-modeler 0.38.0 → 0.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.cjs +18 -11
- package/lib/index.d.cts +6 -1
- package/lib/index.d.ts +6 -1
- package/lib/index.js +18 -11
- package/lib/style.min.css +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var hp=Object.defineProperty,yp=Object.defineProperties;var xp=Object.getOwnPropertyDescriptors;var Dn=Object.getOwnPropertySymbols;var Vs=Object.prototype.hasOwnProperty,Hs=Object.prototype.propertyIsEnumerable;var Os=(e,t,o)=>t in e?hp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,_=(e,t)=>{for(var o in t||(t={}))Vs.call(t,o)&&Os(e,o,t[o]);if(Dn)for(var o of Dn(t))Hs.call(t,o)&&Os(e,o,t[o]);return e},w=(e,t)=>yp(e,xp(t));var gt=(e,t)=>{var o={};for(var n in e)Vs.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Dn)for(var n of Dn(e))t.indexOf(n)<0&&Hs.call(e,n)&&(o[n]=e[n]);return o};var Ai=e=>{if(typeof document=="undefined")return;let t=document.cookie.match(new RegExp(`(?:^|; )${e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")}=([^;]*)`));return t?decodeURIComponent(t[1]):void 0};import{initializeI18n as Ep,Translations as _p}from"@produto-lecom/lecom-ui";var Gs={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",minimap:{label:"Minimap",open:"Open minimap",close:"Hide minimap"}},history:{undo:"Undo",redo:"Redo"}},modals:{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 Bs={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",minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Deshacer",redo:"Rehacer"}},modals:{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 zs={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",minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Desfazer",redo:"Refazer"}},modals:{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 Ys={pt_BR:zs,en_US:Gs,es_ES:Bs};var Ws,Fs,bp=(Fs=(Ws=Ai("LecomUserLanguage"))!=null?Ws:Ai("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?Fs:_p.PT_BR;Ep({lng:bp,resources:Ys});var Ie=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(Ie||{});var On=(i=>(i.ACTIVITY="activity",i.ROUTING="routing",i.GATEWAY="gateway",i.SUB_PROCESS="sub_process",i.SERVICE_TASK="service_task",i))(On||{}),Si=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Si||{}),Ci=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Ci||{}),Mi=(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))(Mi||{});import{Bot as kp,RotateCcw as Rp,ScrollText as Dp,SquarePlus as Op}from"lucide-react";import{jsx as Vn,jsxs as Tp}from"react/jsx-runtime";var Hn=({size:e=24,className:t})=>Tp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:[Vn("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),Vn("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),Vn("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),Vn("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as Xs}from"react/jsx-runtime";var Eo=({size:e=24,className:t})=>Xs("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:Xs("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as $o,jsxs as vp}from"react/jsx-runtime";var _o=({size:e=24,className:t})=>vp("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:[$o("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"}),$o("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),$o("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),$o("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),$o("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Pi,jsxs as Np}from"react/jsx-runtime";var bo=({size:e=24,className:t})=>Np("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:[Pi("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"}),Pi("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Pi("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Li,jsxs as wp}from"react/jsx-runtime";var To=({size:e=24,className:t})=>wp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[Li("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"}),Li("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Li("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as ki,jsxs as Ip}from"react/jsx-runtime";var Us=({size:e=24,className:t})=>ki("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:Ip("g",{children:[ki("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"}),ki("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as Ap}from"clsx";import{twMerge as Sp}from"tailwind-merge";function H(...e){return Sp(Ap(e))}var Rt=(e=0,t=0)=>e<t?t:e,Gn=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as $s,jsxs as Cp}from"react/jsx-runtime";var Ks=({size:e=24,className:t})=>Cp("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:[$s("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"}),$s("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Ri}from"react/jsx-runtime";var qs=({size:e=24,className:t})=>Ri("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:Ri("g",{children:Ri("path",{d:"M4.85372 6.17472L5.31292 5.71552L5.31993 5.70863C6.88908 4.1924 8.98352 3.34122 11.1655 3.33301L11.1668 3.33301C11.167 3.33301 11.1673 3.33301 11.1675 3.33301C12.7165 3.33314 14.2308 3.79255 15.5188 4.65317C16.807 5.5139 17.811 6.7373 18.4039 8.16866C18.9968 9.60001 19.1519 11.175 18.8497 12.6945C18.5986 13.9567 18.0414 15.1334 17.232 16.1236L16.9457 16.4738L17.2655 16.7936L20.6617 20.1899L20.6617 20.1899C20.7919 20.3201 20.7919 20.5311 20.6617 20.6612L20.6616 20.6613C20.5316 20.7915 20.3205 20.7915 20.1903 20.6613L16.7941 17.265L16.4743 16.9452L16.1241 17.2315C15.1339 18.0409 13.9571 18.5981 12.695 18.8492C11.1755 19.1514 9.6005 18.9963 8.16915 18.4034C6.73778 17.8105 5.51439 16.8065 4.65365 15.5183C3.79291 14.2301 3.3335 12.7156 3.3335 11.1663C3.3335 10.9822 3.48273 10.833 3.66683 10.833C3.85093 10.833 4.00016 10.9822 4.00016 11.1663C4.00016 12.5838 4.42048 13.9694 5.20796 15.148C5.99545 16.3265 7.11474 17.245 8.42426 17.7874C9.73378 18.3299 11.1748 18.4719 12.565 18.1953C13.9552 17.9188 15.2321 17.2362 16.2344 16.234L16.2345 16.234C17.2367 15.2316 17.9193 13.9547 18.1958 12.5645C18.4724 11.1743 18.3304 9.7333 17.7879 8.42378C17.2455 7.11426 16.327 5.99497 15.1484 5.20748L14.8707 5.62322L15.1484 5.20748C13.9703 4.42031 12.5854 4.00001 11.1685 3.99968L11.1664 3.99969C9.15876 4.00767 7.23176 4.7903 5.78712 6.18424L5.78706 6.18418L5.78075 6.1905L5.32512 6.64613L4.47156 7.49968H5.67867H7.8335C8.01759 7.49968 8.16683 7.64892 8.16683 7.83302C8.16683 8.01711 8.01759 8.16635 7.8335 8.16635H3.66683C3.48274 8.16635 3.3335 8.01711 3.3335 7.83302V3.66635C3.3335 3.48225 3.48274 3.33302 3.66683 3.33302C3.85092 3.33302 4.00016 3.48225 4.00016 3.66635V5.82117V7.02827L4.85372 6.17472Z"})})});import{jsx as Zs}from"react/jsx-runtime";var Bn=({size:e=24,className:t})=>Zs("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:Zs("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as Js}from"react/jsx-runtime";var Ko=({size:e=24,className:t})=>Js("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:Js("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as Di,jsxs as Mp}from"react/jsx-runtime";var Qs=({size:e=24,className:t})=>Mp("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:[Di("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"}),Di("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"}),Di("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as qo,jsxs as Pp}from"react/jsx-runtime";var js=({size:e=24,className:t})=>Pp("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:[qo("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"}),qo("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"}),qo("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"}),qo("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),qo("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as zn,jsxs as Lp}from"react/jsx-runtime";var Zo=({size:e=24,className:t})=>Lp("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:[zn("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"}),zn("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),zn("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),zn("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var ae=(a=>(a.START_EVENT="START_EVENT",a.END_EVENT="END_EVENT",a.TASK="TASK",a.LANE="LANE",a.GATEWAY="GATEWAY",a.ANNOTATION="ANNOTATION",a.UNSUPPORTED="UNSUPPORTED",a))(ae||{}),qe=(n=>(n.SCRIPT="SCRIPT",n.SUBPROCESS="SUBPROCESS",n.SERVICE_TASK="SERVICE_TASK",n))(qe||{}),Yn={SCRIPT:{icon:Dp},SUBPROCESS:{icon:Op},SERVICE_TASK:{icon:kp}},ht=(t=>(t.LOOP="LOOP",t))(ht||{}),Wn={LOOP:{icon:Rp}},lt=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(lt||{}),Oi={EXCLUSIVE:{icon:bo},PARALLEL:{icon:To},COMPLEX:{icon:_o}};import{useTranslation as c_}from"@produto-lecom/lecom-ui";import{ReactFlowProvider as d_}from"@xyflow/react";import{createContext as u_,useContext as p_,useEffect as f_,useId as m_,useMemo as mp,useRef as g_,useState as ut}from"react";import{Background as HE,MiniMap as GE,ReactFlow as BE,SelectionMode as zE,useKeyPress as YE}from"@xyflow/react";import{forwardRef as WE,useImperativeHandle as FE,useRef as up}from"react";import{useTranslation as sx}from"@produto-lecom/lecom-ui";import{useEdgesState as ax,useNodesState as lx,useOnSelectionChange as cx,useReactFlow as dx,useStoreApi as ux}from"@xyflow/react";import{useCallback as _t,useEffect as px}from"react";var Fn={MIN_WIDTH:36,MIN_HEIGHT:36},Xn={MIN_WIDTH:36,MIN_HEIGHT:36},vo={MIN_WIDTH:56,MIN_HEIGHT:56},Dt={MIN_WIDTH:176,MIN_HEIGHT:96},ea={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},se={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},No={MIN_WIDTH:176,MIN_HEIGHT:64},Vp={MIN_WIDTH:128,MIN_HEIGHT:64},ue={START_EVENT:Fn,END_EVENT:Xn,GATEWAY:vo,TASK:Dt,LANE:se,ANNOTATION:No,UNSUPPORTED:Vp};import{Position as Jo}from"@xyflow/react";function ta(e,t){var x,N,b,v;let{width:o=0,height:n=0}=e.measured||{width:0,height:0},r=e.internals.positionAbsolute,i=t.internals.positionAbsolute,s=o/2,a=n/2,l=r.x+s,c=r.y+a,d=i.x+((N=(x=t==null?void 0:t.measured)==null?void 0:x.width)!=null?N:0)/2,u=i.y+((v=(b=t==null?void 0:t.measured)==null?void 0:b.height)!=null?v:0)/2,f=(d-l)/(2*s)-(u-c)/(2*a),m=(d-l)/(2*s)+(u-c)/(2*a),h=1/(Math.abs(f)+Math.abs(m)||1),E=h*f,p=h*m,g=s*(E+p)+l,y=a*(-E+p)+c;return{x:g,y}}function oa(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),s=Math.round(o.y),a=Math.round(t.x),l=Math.round(t.y);return a<=i+1?Jo.Left:a>=i+n-1?Jo.Right:l<=s+1?Jo.Top:l>=s+r-1?Jo.Bottom:Jo.Top}function wo(e,t){let o=ta(e,t),n=ta(t,e),r=oa(e,o),i=oa(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function Un(e,t){return{isFromStartEvent:(e==null?void 0:e.type)==="START_EVENT",isGatewayToGateway:(e==null?void 0:e.type)==="GATEWAY"&&(t==null?void 0:t.type)==="GATEWAY",isActiviyToAndGateway:(e==null?void 0:e.type)==="TASK"&&(t==null?void 0:t.type)==="GATEWAY",isToEndEvent:(t==null?void 0:t.type)==="END_EVENT"}}import{orderBy as Hp}from"lodash";var na=e=>new Map(e.map(t=>[t.id,t])),ra=(e,t)=>e.map(o=>{var n;return(n=t.get(o.id))!=null?n:o}),ot=e=>{var t,o,n,r,i,s,a,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(r=(n=e.internals)==null?void 0:n.positionAbsolute.y)!=null?r:0,w:(s=(i=e.measured)==null?void 0:i.width)!=null?s:0,h:(l=(a=e.measured)==null?void 0:a.height)!=null?l:0}},Qo=e=>Hp(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),ia=(e,t)=>{let{x:o,y:n}=ot(e),{x:r,y:i}=ot(t);return{x:o-r,y:n-i}};var eo=({parentId:e,nodes:t,includeTypes:o=[...Object.values(ae)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),Gp=(e,t)=>{let{x:o,y:n}=ot(e),{x:r,y:i}=ot(t),s=o-r,a=n-i;return Math.sqrt(s*s+a*a)},Bp=(e,t)=>{let{x:o,y:n,w:r,h:i}=ot(e),{x:s,y:a,w:l,h:c}=ot(t),d=o+r/2,u=n+i/2;return d>=s&&d<=s+l&&u>=a&&u<=a+c},jo=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&Bp(e,r)){let i=Gp(e,r);i<n&&(n=i,o=r)}return o},sa=(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 aa=e=>{let t=e.filter(s=>!s.parentId);if(t.length===0)return null;let o=1/0,n=1/0,r=-1/0,i=-1/0;for(let s of t){let{position:a,width:l,height:c}=s,d=a.x+(l||0),u=a.y+(c||0);a.x<o&&(o=a.x),a.y<n&&(n=a.y),d>r&&(r=d),u>i&&(i=u)}return{x:o,y:n,w:r-o,h:i-n}},la=({bounds:e,canvasWidth:t,canvasHeight:o,minZoom:n=.5,maxZoom:r=5,offsetX:i=0,offsetY:s=0})=>{let a=t-i*2,l=o-s*2,c=Math.min(a/e.w,l/e.h),d=Math.min(1,c),u=Math.min(Math.max(d,n),r);return{x:-e.x*u+i,y:-e.y*u+s,zoom:u}};var Vi=(e,t)=>{let o=t.find(s=>s.id===e);if(!o||o.type!=="LANE"||o.parentId)return!1;let n=ot(o),r=n.x+n.w,i=n.y+n.h;return t.some(s=>{if(s.id===e||s.parentId||s.type==="LANE")return!1;let a=ot(s);return a.x<r&&a.x+a.w>n.x&&a.y<i&&a.y+a.h>n.y})};var zp=50,to=(e,t)=>{var f,m,h,E,p,g,y,x,N,b,v,T,I,S,P,R;let o=t.find(C=>C.id===e);if(!o)return t;let n=(m=(f=o.position)==null?void 0:f.x)!=null?m:0,r=(E=(h=o.position)==null?void 0:h.y)!=null?E:0,i=(g=(p=o.measured)==null?void 0:p.width)!=null?g:0,s=(x=(y=o.measured)==null?void 0:y.height)!=null?x:0,a=r+s,l=n+i,c=new Set,d=1/0;for(let C of t){if(C.id===e||C.parentId)continue;let L=(b=(N=C.position)==null?void 0:N.y)!=null?b:0,K=(T=(v=C.position)==null?void 0:v.x)!=null?T:0,Q=(S=(I=C.measured)==null?void 0:I.width)!=null?S:0,j=(R=(P=C.measured)==null?void 0:P.height)!=null?R:0;K<l&&K+Q>n&&L<a&&L+j>r&&(c.add(C.id),d=Math.min(d,L))}if(c.size===0)return t;let u=a+zp-d;return t.map(C=>{var K,Q,j;if(!c.has(C.id))return C;let L=(Q=(K=C.position)==null?void 0:K.y)!=null?Q:0;return w(_({},C),{position:w(_({},(j=C.position)!=null?j:{x:0,y:0}),{y:L+u})})})},Ne=15,oo=e=>[...e].sort((t,o)=>t.position.y-o.position.y),Yp=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)},Wp=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)},Hi=(e,t,o)=>{var d,u,f,m,h,E,p,g,y,x,N,b,v,T,I;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=(h=e.height)!=null?h:(m=e.measured)==null?void 0:m.height)!=null?E:0,i=0,s=0;for(let S of t){let P=Yp(S),R=Wp(S);if(((g=(p=S.position)==null?void 0:p.y)!=null?g:0)<Ne&&(o.set(S.id,w(_({},S),{position:w(_({},S.position),{y:Ne})})),R=Ne+((x=(y=S.measured)==null?void 0:y.height)!=null?x:0)),((b=(N=S.position)==null?void 0:N.x)!=null?b:0)<se.HEADER_WIDTH+Ne){let C=(v=o.get(S.id))!=null?v:S;o.set(S.id,w(_({},C),{position:w(_({},C.position),{x:se.HEADER_WIDTH+Ne})})),P=se.HEADER_WIDTH+Ne+((I=(T=S.measured)==null?void 0:T.width)!=null?I:0)}i=Math.max(i,P),s=Math.max(s,R)}let a=Math.max(n,se.MIN_WIDTH),l=Math.max(r,se.MIN_HEIGHT);i+Ne>a&&(a=i+Ne),s+Ne>l&&(l=s+Ne);let c=w(_({},e),{width:a,height:l,measured:w(_({},e.measured),{width:a,height:l})});return o.set(e.id,c),c},ca=(e,t,o)=>{var s,a;let n=oo(e),r=new Map;for(let l of o)l.parentId&&(r.has(l.parentId)||r.set(l.parentId,[]),r.get(l.parentId).push(l));let i=0;for(let l of n){let c=(s=r.get(l.id))!=null?s:[],d=Hi(l,c,t);t.set(d.id,w(_({},d),{position:{x:se.HEADER_WIDTH,y:i}})),i+=(a=d.height)!=null?a:0}},da=(e,t)=>{var h,E,p,g;let o=[];for(let y of t.values())y.parentId===e.id&&o.push(y);let n=oo(o),r=((E=(h=e.measured)==null?void 0:h.width)!=null?E:0)-se.HEADER_WIDTH,i=sa(e.id,o)||se.MIN_WIDTH,s=o.reduce((y,x)=>{var N;return y+((N=x.height)!=null?N:se.MIN_HEIGHT)},0),a=Math.max(r,i),l=s,c=r>i,d=c?a:a+se.HEADER_WIDTH,u=c?a-se.HEADER_WIDTH:a,f=0;for(let y=0;y<n.length;y++){let x=n[y],N=Math.max(se.MIN_HEIGHT,(p=x.height)!=null?p:se.MIN_HEIGHT),b=w(_({},x),{width:u,height:N,measured:w(_({},x.measured),{width:u,height:N}),position:{x:se.HEADER_WIDTH,y:f}});if(y===o.length-1){let v=Math.max(se.MIN_HEIGHT,l-f);b=w(_({},b),{height:v,measured:w(_({},x.measured),{width:u,height:v})})}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})}))},ua=(e,t,o,n,r)=>{var h,E;let i=!e.parentId,s=i?e.id:e.parentId,a=n.filter(p=>p.type==="LANE"&&p.parentId===s);if(!a.length)return n;let l=oo(a),c=l.findIndex(p=>p.id===e.id),d=(E=(h=e.position)==null?void 0:h.y)!=null?E:0,u=!i&&r!==void 0&&c>0&&Math.abs(r-d)>.5,f=0,m=[...n];return l.forEach((p,g)=>{var v,T;let y=g===l.length-1,x=p.id===e.id,b=(T=(v=p.measured)==null?void 0:v.height)!=null?T:0;x?b=o:u&&g===c-1&&(b=Math.max(se.MIN_HEIGHT,r-f)),y&&i&&(b=Math.max(se.MIN_HEIGHT,o-f)),m=m.map(I=>{if(I.id===p.id){let S=i?t-se.HEADER_WIDTH:t;return w(_({},I),{width:S,height:b,measured:w(_({},I.measured),{width:S,height:b}),position:{x:se.HEADER_WIDTH,y:f}})}return I}),x&&u?f=r+o:f+=b}),m=m.map(p=>{if(p.id===s){let g=i?t:t+se.HEADER_WIDTH;return w(_({},p),{width:g,height:i?o:f,measured:{width:g,height:i?o:f}})}return p}),m};var Gi=(e,t,o)=>{var a,l,c,d,u,f,m,h;if(e.type==="LANE")return o;let n=(l=(a=t.measured)==null?void 0:a.width)!=null?l:0,r=(d=(c=t.measured)==null?void 0:c.height)!=null?d:0;e.position.y<Ne&&(e.position.y=Ne),e.position.x<se.HEADER_WIDTH+Ne&&(e.position.x=se.HEADER_WIDTH+Ne);let i=e.position.x+((f=(u=e.measured)==null?void 0:u.width)!=null?f:0),s=e.position.y+((h=(m=e.measured)==null?void 0:m.height)!=null?h:0);return i+Ne>n&&(t.width=i+Ne,t.measured.width=i+Ne),s+Ne>r&&(t.height=s+Ne,t.measured.height=s+Ne),o=o.map(E=>E.id===t.id?w(_({},E),{height:t.height,width:t.width,measured:t.measured}):E.id===e.id?w(_({},E),{position:e.position}):E),o};import{create as Fp}from"zustand";import{useReactFlow as Xp}from"@xyflow/react";import{useCallback as Up}from"react";var $n=()=>{let{setEdges:e}=Xp();return Up(()=>{let o=no.getState().pathEdgeIds;e(n=>n.map(r=>w(_({},r),{selected:o.includes(r.id)})))},[e])},no=Fp((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=_({},n.statusByNodeId),i=_({},n.statusData),s=!1;return o.forEach(a=>{let l=`${a.diagramId}-${a.activityId}`;r[a.diagramId]!==a.status&&(r[a.diagramId]=a.status,i[l]=a,s=!0)}),s?{statusByNodeId:r,statusData:i}:n})},getTaskStatus:o=>t().statusByNodeId[o]||null,clearTaskStatuses:()=>e({statusByNodeId:{},statusData:{},pathEdgeIds:[]}),setPathEdges:o=>{e({pathEdgeIds:o})},getPathEdgeIds:()=>t().pathEdgeIds,clearPathEdges:()=>{e({pathEdgeIds:[]})},calculateFlowPath:(o,n)=>{if(!o.length||!n.length)return;t().clearPathEdges();let r=n.filter(d=>t().statusByNodeId[d]);if(r.length<=1)return;let i=[],s={};o.forEach(d=>{s[d.source]||(s[d.source]=[]),s[d.source].push({targetId:d.target,edgeId:d.id})});let a=r[0],l=r[r.length-1];o.forEach(d=>{d.target===a&&i.push(d.id)}),o.forEach(d=>{d.source===l&&i.push(d.id)});let c=(d,u)=>{let f=[],m=new Set;for(f.push({node:d,path:[]}),m.add(d);f.length>0;){let{node:h,path:E}=f.shift();if(h===u)return E;let p=s[h]||[];for(let{targetId:g,edgeId:y}of p)m.has(g)||(m.add(g),f.push({node:g,path:[...E,y]}))}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})}}));import{useNodesInitialized as lg,useReactFlow as cg,useStore as dg}from"@xyflow/react";import{useCallback as gn,useEffect as ug,useRef as pg,useState as ic}from"react";import{shallow as fg}from"zustand/shallow";var $p={value:()=>{}};function fa(){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 Kn(o)}function Kn(e){this._=e}function Kp(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}})}Kn.prototype=fa.prototype={constructor:Kn,on:function(e,t){var o=this._,n=Kp(e+"",o),r,i=-1,s=n.length;if(arguments.length<2){for(;++i<s;)if((r=(e=n[i]).type)&&(r=qp(o[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(r=(e=n[i]).type)o[r]=pa(o[r],e.name,t);else if(t==null)for(r in o)o[r]=pa(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 Kn(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 qp(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function pa(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=$p,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var Bi=fa;var qn="http://www.w3.org/1999/xhtml",zi={svg:"http://www.w3.org/2000/svg",xhtml:qn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Nt(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),zi.hasOwnProperty(t)?{space:zi[t],local:e}:e}function Zp(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===qn&&t.documentElement.namespaceURI===qn?t.createElement(e):t.createElementNS(o,e)}}function Jp(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Zn(e){var t=Nt(e);return(t.local?Jp:Zp)(t)}function Qp(){}function ro(e){return e==null?Qp:function(){return this.querySelector(e)}}function ma(e){typeof e!="function"&&(e=ro(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=new Array(s),l,c,d=0;d<s;++d)(l=i[d])&&(c=e.call(l,l.__data__,d,i))&&("__data__"in l&&(c.__data__=l.__data__),a[d]=c);return new Ae(n,this._parents)}function Yi(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function jp(){return[]}function en(e){return e==null?jp:function(){return this.querySelectorAll(e)}}function ef(e){return function(){return Yi(e.apply(this,arguments))}}function ga(e){typeof e=="function"?e=ef(e):e=en(e);for(var t=this._groups,o=t.length,n=[],r=[],i=0;i<o;++i)for(var s=t[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&(n.push(e.call(l,l.__data__,c,s)),r.push(l));return new Ae(n,r)}function tn(e){return function(){return this.matches(e)}}function Jn(e){return function(t){return t.matches(e)}}var tf=Array.prototype.find;function of(e){return function(){return tf.call(this.children,e)}}function nf(){return this.firstElementChild}function ha(e){return this.select(e==null?nf:of(typeof e=="function"?e:Jn(e)))}var rf=Array.prototype.filter;function sf(){return Array.from(this.children)}function af(e){return function(){return rf.call(this.children,e)}}function ya(e){return this.selectAll(e==null?sf:af(typeof e=="function"?e:Jn(e)))}function xa(e){typeof e!="function"&&(e=tn(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new Ae(n,this._parents)}function Qn(e){return new Array(e.length)}function Ea(){return new Ae(this._enter||this._groups.map(Qn),this._parents)}function on(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}on.prototype={constructor:on,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 _a(e){return function(){return e}}function lf(e,t,o,n,r,i){for(var s=0,a,l=t.length,c=i.length;s<c;++s)(a=t[s])?(a.__data__=i[s],n[s]=a):o[s]=new on(e,i[s]);for(;s<l;++s)(a=t[s])&&(r[s]=a)}function cf(e,t,o,n,r,i,s){var a,l,c=new Map,d=t.length,u=i.length,f=new Array(d),m;for(a=0;a<d;++a)(l=t[a])&&(f[a]=m=s.call(l,l.__data__,a,t)+"",c.has(m)?r[a]=l:c.set(m,l));for(a=0;a<u;++a)m=s.call(e,i[a],a,i)+"",(l=c.get(m))?(n[a]=l,l.__data__=i[a],c.delete(m)):o[a]=new on(e,i[a]);for(a=0;a<d;++a)(l=t[a])&&c.get(f[a])===l&&(r[a]=l)}function df(e){return e.__data__}function ba(e,t){if(!arguments.length)return Array.from(this,df);var o=t?cf:lf,n=this._parents,r=this._groups;typeof e!="function"&&(e=_a(e));for(var i=r.length,s=new Array(i),a=new Array(i),l=new Array(i),c=0;c<i;++c){var d=n[c],u=r[c],f=u.length,m=uf(e.call(d,d&&d.__data__,c,n)),h=m.length,E=a[c]=new Array(h),p=s[c]=new Array(h),g=l[c]=new Array(f);o(d,u,E,p,g,m,t);for(var y=0,x=0,N,b;y<h;++y)if(N=E[y]){for(y>=x&&(x=y+1);!(b=p[x])&&++x<h;);N._next=b||null}}return s=new Ae(s,n),s._enter=a,s._exit=l,s}function uf(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Ta(){return new Ae(this._exit||this._groups.map(Qn),this._parents)}function va(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 Na(e){for(var t=e.selection?e.selection():e,o=this._groups,n=t._groups,r=o.length,i=n.length,s=Math.min(r,i),a=new Array(r),l=0;l<s;++l)for(var c=o[l],d=n[l],u=c.length,f=a[l]=new Array(u),m,h=0;h<u;++h)(m=c[h]||d[h])&&(f[h]=m);for(;l<r;++l)a[l]=o[l];return new Ae(a,this._parents)}function wa(){for(var e=this._groups,t=-1,o=e.length;++t<o;)for(var n=e[t],r=n.length-1,i=n[r],s;--r>=0;)(s=n[r])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function Ia(e){e||(e=pf);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 s=o[i],a=s.length,l=r[i]=new Array(a),c,d=0;d<a;++d)(c=s[d])&&(l[d]=c);l.sort(t)}return new Ae(r,this._parents).order()}function pf(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Aa(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Sa(){return Array.from(this)}function Ca(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length;r<i;++r){var s=n[r];if(s)return s}return null}function Ma(){let e=0;for(let t of this)++e;return e}function Pa(){return!this.node()}function La(e){for(var t=this._groups,o=0,n=t.length;o<n;++o)for(var r=t[o],i=0,s=r.length,a;i<s;++i)(a=r[i])&&e.call(a,a.__data__,i,r);return this}function ff(e){return function(){this.removeAttribute(e)}}function mf(e){return function(){this.removeAttributeNS(e.space,e.local)}}function gf(e,t){return function(){this.setAttribute(e,t)}}function hf(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function yf(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function xf(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 ka(e,t){var o=Nt(e);if(arguments.length<2){var n=this.node();return o.local?n.getAttributeNS(o.space,o.local):n.getAttribute(o)}return this.each((t==null?o.local?mf:ff:typeof t=="function"?o.local?xf:yf:o.local?hf:gf)(o,t))}function jn(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Ef(e){return function(){this.style.removeProperty(e)}}function _f(e,t,o){return function(){this.style.setProperty(e,t,o)}}function bf(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function Ra(e,t,o){return arguments.length>1?this.each((t==null?Ef:typeof t=="function"?bf:_f)(e,t,o==null?"":o)):Ot(this.node(),e)}function Ot(e,t){return e.style.getPropertyValue(t)||jn(e).getComputedStyle(e,null).getPropertyValue(t)}function Tf(e){return function(){delete this[e]}}function vf(e,t){return function(){this[e]=t}}function Nf(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function Da(e,t){return arguments.length>1?this.each((t==null?Tf:typeof t=="function"?Nf:vf)(e,t)):this.node()[e]}function Oa(e){return e.trim().split(/^|\s+/)}function Wi(e){return e.classList||new Va(e)}function Va(e){this._node=e,this._names=Oa(e.getAttribute("class")||"")}Va.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 Ha(e,t){for(var o=Wi(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function Ga(e,t){for(var o=Wi(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function wf(e){return function(){Ha(this,e)}}function If(e){return function(){Ga(this,e)}}function Af(e,t){return function(){(t.apply(this,arguments)?Ha:Ga)(this,e)}}function Ba(e,t){var o=Oa(e+"");if(arguments.length<2){for(var n=Wi(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?Af:t?wf:If)(o,t))}function Sf(){this.textContent=""}function Cf(e){return function(){this.textContent=e}}function Mf(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function za(e){return arguments.length?this.each(e==null?Sf:(typeof e=="function"?Mf:Cf)(e)):this.node().textContent}function Pf(){this.innerHTML=""}function Lf(e){return function(){this.innerHTML=e}}function kf(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function Ya(e){return arguments.length?this.each(e==null?Pf:(typeof e=="function"?kf:Lf)(e)):this.node().innerHTML}function Rf(){this.nextSibling&&this.parentNode.appendChild(this)}function Wa(){return this.each(Rf)}function Df(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Fa(){return this.each(Df)}function Xa(e){var t=typeof e=="function"?e:Zn(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Of(){return null}function Ua(e,t){var o=typeof e=="function"?e:Zn(e),n=t==null?Of:typeof t=="function"?t:ro(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function Vf(){var e=this.parentNode;e&&e.removeChild(this)}function $a(){return this.each(Vf)}function Hf(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Gf(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Ka(e){return this.select(e?Gf:Hf)}function qa(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Bf(e){return function(t){e.call(this,t,this.__data__)}}function zf(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 Yf(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 Wf(e,t,o){return function(){var n=this.__on,r,i=Bf(t);if(n){for(var s=0,a=n.length;s<a;++s)if((r=n[s]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=o),r.value=t;return}}this.addEventListener(e.type,i,o),r={type:e.type,name:e.name,value:t,listener:i,options:o},n?n.push(r):this.__on=[r]}}function Za(e,t,o){var n=zf(e+""),r,i=n.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,c=a.length,d;l<c;++l)for(r=0,d=a[l];r<i;++r)if((s=n[r]).type===d.type&&s.name===d.name)return d.value}return}for(a=t?Wf:Yf,r=0;r<i;++r)this.each(a(n[r],t,o));return this}function Ja(e,t,o){var n=jn(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 Ff(e,t){return function(){return Ja(this,e,t)}}function Xf(e,t){return function(){return Ja(this,e,t.apply(this,arguments))}}function Qa(e,t){return this.each((typeof t=="function"?Xf:Ff)(e,t))}function*ja(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length,s;r<i;++r)(s=n[r])&&(yield s)}var Uf=[null];function Ae(e,t){this._groups=e,this._parents=t}function el(){return new Ae([[document.documentElement]],Uf)}function $f(){return this}Ae.prototype=el.prototype={constructor:Ae,select:ma,selectAll:ga,selectChild:ha,selectChildren:ya,filter:xa,data:ba,enter:Ea,exit:Ta,join:va,merge:Na,selection:$f,order:wa,sort:Ia,call:Aa,nodes:Sa,node:Ca,size:Ma,empty:Pa,each:La,attr:ka,style:Ra,property:Da,classed:Ba,text:za,html:Ya,raise:Wa,lower:Fa,append:Xa,insert:Ua,remove:$a,clone:Ka,datum:qa,on:Za,dispatch:Qa,[Symbol.iterator]:ja};var wt=el;function er(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function Fi(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function sn(){}var nn=.7,nr=1/nn,Io="\\s*([+-]?\\d+)\\s*",rn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",yt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Kf=/^#([0-9a-f]{3,8})$/,qf=new RegExp(`^rgb\\(${Io},${Io},${Io}\\)$`),Zf=new RegExp(`^rgb\\(${yt},${yt},${yt}\\)$`),Jf=new RegExp(`^rgba\\(${Io},${Io},${Io},${rn}\\)$`),Qf=new RegExp(`^rgba\\(${yt},${yt},${yt},${rn}\\)$`),jf=new RegExp(`^hsl\\(${rn},${yt},${yt}\\)$`),em=new RegExp(`^hsla\\(${rn},${yt},${yt},${rn}\\)$`),tl={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};er(sn,Vt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:ol,formatHex:ol,formatHex8:tm,formatHsl:om,formatRgb:nl,toString:nl});function ol(){return this.rgb().formatHex()}function tm(){return this.rgb().formatHex8()}function om(){return cl(this).formatHsl()}function nl(){return this.rgb().formatRgb()}function Vt(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=Kf.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?rl(t):o===3?new ze(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?tr(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?tr(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=qf.exec(e))?new ze(t[1],t[2],t[3],1):(t=Zf.exec(e))?new ze(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Jf.exec(e))?tr(t[1],t[2],t[3],t[4]):(t=Qf.exec(e))?tr(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=jf.exec(e))?al(t[1],t[2]/100,t[3]/100,1):(t=em.exec(e))?al(t[1],t[2]/100,t[3]/100,t[4]):tl.hasOwnProperty(e)?rl(tl[e]):e==="transparent"?new ze(NaN,NaN,NaN,0):null}function rl(e){return new ze(e>>16&255,e>>8&255,e&255,1)}function tr(e,t,o,n){return n<=0&&(e=t=o=NaN),new ze(e,t,o,n)}function nm(e){return e instanceof sn||(e=Vt(e)),e?(e=e.rgb(),new ze(e.r,e.g,e.b,e.opacity)):new ze}function Ao(e,t,o,n){return arguments.length===1?nm(e):new ze(e,t,o,n==null?1:n)}function ze(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}er(ze,Ao,Fi(sn,{brighter(e){return e=e==null?nr:Math.pow(nr,e),new ze(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?nn:Math.pow(nn,e),new ze(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ze(so(this.r),so(this.g),so(this.b),rr(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:il,formatHex:il,formatHex8:rm,formatRgb:sl,toString:sl}));function il(){return`#${io(this.r)}${io(this.g)}${io(this.b)}`}function rm(){return`#${io(this.r)}${io(this.g)}${io(this.b)}${io((isNaN(this.opacity)?1:this.opacity)*255)}`}function sl(){let e=rr(this.opacity);return`${e===1?"rgb(":"rgba("}${so(this.r)}, ${so(this.g)}, ${so(this.b)}${e===1?")":`, ${e})`}`}function rr(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function so(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function io(e){return e=so(e),(e<16?"0":"")+e.toString(16)}function al(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new ct(e,t,o,n)}function cl(e){if(e instanceof ct)return new ct(e.h,e.s,e.l,e.opacity);if(e instanceof sn||(e=Vt(e)),!e)return new ct;if(e instanceof ct)return e;e=e.rgb();var t=e.r/255,o=e.g/255,n=e.b/255,r=Math.min(t,o,n),i=Math.max(t,o,n),s=NaN,a=i-r,l=(i+r)/2;return a?(t===i?s=(o-n)/a+(o<n)*6:o===i?s=(n-t)/a+2:s=(t-o)/a+4,a/=l<.5?i+r:2-i-r,s*=60):a=l>0&&l<1?0:s,new ct(s,a,l,e.opacity)}function dl(e,t,o,n){return arguments.length===1?cl(e):new ct(e,t,o,n==null?1:n)}function ct(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}er(ct,dl,Fi(sn,{brighter(e){return e=e==null?nr:Math.pow(nr,e),new ct(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?nn:Math.pow(nn,e),new ct(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,o=this.l,n=o+(o<.5?o:1-o)*t,r=2*o-n;return new ze(Xi(e>=240?e-240:e+120,r,n),Xi(e,r,n),Xi(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new ct(ll(this.h),or(this.s),or(this.l),rr(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=rr(this.opacity);return`${e===1?"hsl(":"hsla("}${ll(this.h)}, ${or(this.s)*100}%, ${or(this.l)*100}%${e===1?")":`, ${e})`}`}}));function ll(e){return e=(e||0)%360,e<0?e+360:e}function or(e){return Math.max(0,Math.min(1,e||0))}function Xi(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 Ui(e,t,o,n,r){var i=e*e,s=i*e;return((1-3*e+3*i-s)*t+(4-6*i+3*s)*o+(1+3*e+3*i-3*s)*n+s*r)/6}function ul(e){var t=e.length-1;return function(o){var n=o<=0?o=0:o>=1?(o=1,t-1):Math.floor(o*t),r=e[n],i=e[n+1],s=n>0?e[n-1]:2*r-i,a=n<t-1?e[n+2]:2*i-r;return Ui((o-n/t)*t,s,r,i,a)}}function pl(e){var t=e.length;return function(o){var n=Math.floor(((o%=1)<0?++o:o)*t),r=e[(n+t-1)%t],i=e[n%t],s=e[(n+1)%t],a=e[(n+2)%t];return Ui((o-n/t)*t,r,i,s,a)}}var $i=e=>()=>e;function im(e,t){return function(o){return e+o*t}}function sm(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 fl(e){return(e=+e)==1?ir:function(t,o){return o-t?sm(t,o,e):$i(isNaN(t)?o:t)}}function ir(e,t){var o=t-e;return o?im(e,o):$i(isNaN(e)?t:e)}var sr=function e(t){var o=fl(t);function n(r,i){var s=o((r=Ao(r)).r,(i=Ao(i)).r),a=o(r.g,i.g),l=o(r.b,i.b),c=ir(r.opacity,i.opacity);return function(d){return r.r=s(d),r.g=a(d),r.b=l(d),r.opacity=c(d),r+""}}return n.gamma=e,n}(1);function ml(e){return function(t){var o=t.length,n=new Array(o),r=new Array(o),i=new Array(o),s,a;for(s=0;s<o;++s)a=Ao(t[s]),n[s]=a.r||0,r[s]=a.g||0,i[s]=a.b||0;return n=e(n),r=e(r),i=e(i),a.opacity=1,function(l){return a.r=n(l),a.g=r(l),a.b=i(l),a+""}}}var am=ml(ul),lm=ml(pl);function nt(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var qi=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ki=new RegExp(qi.source,"g");function cm(e){return function(){return e}}function dm(e){return function(t){return e(t)+""}}function Zi(e,t){var o=qi.lastIndex=Ki.lastIndex=0,n,r,i,s=-1,a=[],l=[];for(e=e+"",t=t+"";(n=qi.exec(e))&&(r=Ki.exec(t));)(i=r.index)>o&&(i=t.slice(o,i),a[s]?a[s]+=i:a[++s]=i),(n=n[0])===(r=r[0])?a[s]?a[s]+=r:a[++s]=r:(a[++s]=null,l.push({i:s,x:nt(n,r)})),o=Ki.lastIndex;return o<t.length&&(i=t.slice(o),a[s]?a[s]+=i:a[++s]=i),a.length<2?l[0]?dm(l[0].x):cm(t):(t=l.length,function(c){for(var d=0,u;d<t;++d)a[(u=l[d]).i]=u.x(c);return a.join("")})}var gl=180/Math.PI,ar={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ji(e,t,o,n,r,i){var s,a,l;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(l=e*o+t*n)&&(o-=e*l,n-=t*l),(a=Math.sqrt(o*o+n*n))&&(o/=a,n/=a,l/=a),e*n<t*o&&(e=-e,t=-t,l=-l,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*gl,skewX:Math.atan(l)*gl,scaleX:s,scaleY:a}}var lr;function hl(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?ar:Ji(t.a,t.b,t.c,t.d,t.e,t.f)}function yl(e){return e==null?ar:(lr||(lr=document.createElementNS("http://www.w3.org/2000/svg","g")),lr.setAttribute("transform",e),(e=lr.transform.baseVal.consolidate())?(e=e.matrix,Ji(e.a,e.b,e.c,e.d,e.e,e.f)):ar)}function xl(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,f,m,h){if(c!==u||d!==f){var E=m.push("translate(",null,t,null,o);h.push({i:E-4,x:nt(c,u)},{i:E-2,x:nt(d,f)})}else(u||f)&&m.push("translate("+u+t+f+o)}function s(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:nt(c,d)})):d&&u.push(r(u)+"rotate("+d+n)}function a(c,d,u,f){c!==d?f.push({i:u.push(r(u)+"skewX(",null,n)-2,x:nt(c,d)}):d&&u.push(r(u)+"skewX("+d+n)}function l(c,d,u,f,m,h){if(c!==u||d!==f){var E=m.push(r(m)+"scale(",null,",",null,")");h.push({i:E-4,x:nt(c,u)},{i:E-2,x:nt(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),s(c.rotate,d.rotate,u,f),a(c.skewX,d.skewX,u,f),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,f),c=d=null,function(m){for(var h=-1,E=f.length,p;++h<E;)u[(p=f[h]).i]=p.x(m);return u.join("")}}}var Qi=xl(hl,"px, ","px)","deg)"),ji=xl(yl,", ",")",")");var So=0,ln=0,an=0,_l=1e3,cr,cn,dr=0,ao=0,ur=0,dn=typeof performance=="object"&&performance.now?performance:Date,bl=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function pn(){return ao||(bl(um),ao=dn.now()+ur)}function um(){ao=0}function un(){this._call=this._time=this._next=null}un.prototype=pr.prototype={constructor:un,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?pn():+o)+(t==null?0:+t),!this._next&&cn!==this&&(cn?cn._next=this:cr=this,cn=this),this._call=e,this._time=o,es()},stop:function(){this._call&&(this._call=null,this._time=1/0,es())}};function pr(e,t,o){var n=new un;return n.restart(e,t,o),n}function Tl(){pn(),++So;for(var e=cr,t;e;)(t=ao-e._time)>=0&&e._call.call(void 0,t),e=e._next;--So}function El(){ao=(dr=dn.now())+ur,So=ln=0;try{Tl()}finally{So=0,fm(),ao=0}}function pm(){var e=dn.now(),t=e-dr;t>_l&&(ur-=t,dr=e)}function fm(){for(var e,t=cr,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:cr=o);cn=e,es(n)}function es(e){if(!So){ln&&(ln=clearTimeout(ln));var t=e-ao;t>24?(e<1/0&&(ln=setTimeout(El,e-dn.now()-ur)),an&&(an=clearInterval(an))):(an||(dr=dn.now(),an=setInterval(pm,_l)),So=1,bl(El))}}function fr(e,t,o){var n=new un;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var mm=Bi("start","end","cancel","interrupt"),gm=[],wl=0,vl=1,gr=2,mr=3,Nl=4,hr=5,fn=6;function Ht(e,t,o,n,r,i){var s=e.__transition;if(!s)e.__transition={};else if(o in s)return;hm(e,o,{name:t,index:n,group:r,on:mm,tween:gm,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:wl})}function mn(e,t){var o=Se(e,t);if(o.state>wl)throw new Error("too late; already scheduled");return o}function Re(e,t){var o=Se(e,t);if(o.state>mr)throw new Error("too late; already running");return o}function Se(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function hm(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=pr(i,0,o.time);function i(c){o.state=vl,o.timer.restart(s,o.delay,o.time),o.delay<=c&&s(c-o.delay)}function s(c){var d,u,f,m;if(o.state!==vl)return l();for(d in n)if(m=n[d],m.name===o.name){if(m.state===mr)return fr(s);m.state===Nl?(m.state=fn,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete n[d]):+d<t&&(m.state=fn,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete n[d])}if(fr(function(){o.state===mr&&(o.state=Nl,o.timer.restart(a,o.delay,o.time),a(c))}),o.state=gr,o.on.call("start",e,e.__data__,o.index,o.group),o.state===gr){for(o.state=mr,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 a(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=hr,1),u=-1,f=r.length;++u<f;)r[u].call(e,d);o.state===hr&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=fn,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function ts(e,t){var o=e.__transition,n,r,i=!0,s;if(o){t=t==null?null:t+"";for(s in o){if((n=o[s]).name!==t){i=!1;continue}r=n.state>gr&&n.state<hr,n.state=fn,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[s]}i&&delete e.__transition}}function Il(e){return this.each(function(){ts(this,e)})}function ym(e,t){var o,n;return function(){var r=Re(this,e),i=r.tween;if(i!==o){n=o=i;for(var s=0,a=n.length;s<a;++s)if(n[s].name===t){n=n.slice(),n.splice(s,1);break}}r.tween=n}}function xm(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=Re(this,e),s=i.tween;if(s!==n){r=(n=s).slice();for(var a={name:t,value:o},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=a;break}l===c&&r.push(a)}i.tween=r}}function Al(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=Se(this.node(),o).tween,r=0,i=n.length,s;r<i;++r)if((s=n[r]).name===e)return s.value;return null}return this.each((t==null?ym:xm)(o,e,t))}function Co(e,t,o){var n=e._id;return e.each(function(){var r=Re(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return Se(r,n).value[t]}}function yr(e,t){var o;return(typeof t=="number"?nt:t instanceof Vt?sr:(o=Vt(t))?(t=o,sr):Zi)(e,t)}function Em(e){return function(){this.removeAttribute(e)}}function _m(e){return function(){this.removeAttributeNS(e.space,e.local)}}function bm(e,t,o){var n,r=o+"",i;return function(){var s=this.getAttribute(e);return s===r?null:s===n?i:i=t(n=s,o)}}function Tm(e,t,o){var n,r=o+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===r?null:s===n?i:i=t(n=s,o)}}function vm(e,t,o){var n,r,i;return function(){var s,a=o(this),l;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),l=a+"",s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a)))}}function Nm(e,t,o){var n,r,i;return function(){var s,a=o(this),l;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),l=a+"",s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a)))}}function Sl(e,t){var o=Nt(e),n=o==="transform"?ji:yr;return this.attrTween(e,typeof t=="function"?(o.local?Nm:vm)(o,n,Co(this,"attr."+e,t)):t==null?(o.local?_m:Em)(o):(o.local?Tm:bm)(o,n,t))}function wm(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function Im(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function Am(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Im(e,i)),o}return r._value=t,r}function Sm(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&wm(e,i)),o}return r._value=t,r}function Cl(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=Nt(e);return this.tween(o,(n.local?Am:Sm)(n,t))}function Cm(e,t){return function(){mn(this,e).delay=+t.apply(this,arguments)}}function Mm(e,t){return t=+t,function(){mn(this,e).delay=t}}function Ml(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Cm:Mm)(t,e)):Se(this.node(),t).delay}function Pm(e,t){return function(){Re(this,e).duration=+t.apply(this,arguments)}}function Lm(e,t){return t=+t,function(){Re(this,e).duration=t}}function Pl(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Pm:Lm)(t,e)):Se(this.node(),t).duration}function km(e,t){if(typeof t!="function")throw new Error;return function(){Re(this,e).ease=t}}function Ll(e){var t=this._id;return arguments.length?this.each(km(t,e)):Se(this.node(),t).ease}function Rm(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;Re(this,e).ease=o}}function kl(e){if(typeof e!="function")throw new Error;return this.each(Rm(this._id,e))}function Rl(e){typeof e!="function"&&(e=tn(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new He(n,this._parents,this._name,this._id)}function Dl(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,o=e._groups,n=t.length,r=o.length,i=Math.min(n,r),s=new Array(n),a=0;a<i;++a)for(var l=t[a],c=o[a],d=l.length,u=s[a]=new Array(d),f,m=0;m<d;++m)(f=l[m]||c[m])&&(u[m]=f);for(;a<n;++a)s[a]=t[a];return new He(s,this._parents,this._name,this._id)}function Dm(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 Om(e,t,o){var n,r,i=Dm(t)?mn:Re;return function(){var s=i(this,e),a=s.on;a!==n&&(r=(n=a).copy()).on(t,o),s.on=r}}function Ol(e,t){var o=this._id;return arguments.length<2?Se(this.node(),o).on.on(e):this.each(Om(o,e,t))}function Vm(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function Vl(){return this.on("end.remove",Vm(this._id))}function Hl(e){var t=this._name,o=this._id;typeof e!="function"&&(e=ro(e));for(var n=this._groups,r=n.length,i=new Array(r),s=0;s<r;++s)for(var a=n[s],l=a.length,c=i[s]=new Array(l),d,u,f=0;f<l;++f)(d=a[f])&&(u=e.call(d,d.__data__,f,a))&&("__data__"in d&&(u.__data__=d.__data__),c[f]=u,Ht(c[f],t,o,f,c,Se(d,o)));return new He(i,this._parents,t,o)}function Gl(e){var t=this._name,o=this._id;typeof e!="function"&&(e=en(e));for(var n=this._groups,r=n.length,i=[],s=[],a=0;a<r;++a)for(var l=n[a],c=l.length,d,u=0;u<c;++u)if(d=l[u]){for(var f=e.call(d,d.__data__,u,l),m,h=Se(d,o),E=0,p=f.length;E<p;++E)(m=f[E])&&Ht(m,t,o,E,f,h);i.push(f),s.push(d)}return new He(i,s,t,o)}var Hm=wt.prototype.constructor;function Bl(){return new Hm(this._groups,this._parents)}function Gm(e,t){var o,n,r;return function(){var i=Ot(this,e),s=(this.style.removeProperty(e),Ot(this,e));return i===s?null:i===o&&s===n?r:r=t(o=i,n=s)}}function zl(e){return function(){this.style.removeProperty(e)}}function Bm(e,t,o){var n,r=o+"",i;return function(){var s=Ot(this,e);return s===r?null:s===n?i:i=t(n=s,o)}}function zm(e,t,o){var n,r,i;return function(){var s=Ot(this,e),a=o(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),Ot(this,e))),s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a))}}function Ym(e,t){var o,n,r,i="style."+t,s="end."+i,a;return function(){var l=Re(this,e),c=l.on,d=l.value[i]==null?a||(a=zl(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(s,r=d),l.on=n}}function Yl(e,t,o){var n=(e+="")=="transform"?Qi:yr;return t==null?this.styleTween(e,Gm(e,n)).on("end.style."+e,zl(e)):typeof t=="function"?this.styleTween(e,zm(e,n,Co(this,"style."+e,t))).each(Ym(this._id,e)):this.styleTween(e,Bm(e,n,t),o).on("end.style."+e,null)}function Wm(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function Fm(e,t,o){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&Wm(e,s,o)),n}return i._value=t,i}function Wl(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,Fm(e,t,o==null?"":o))}function Xm(e){return function(){this.textContent=e}}function Um(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function Fl(e){return this.tween("text",typeof e=="function"?Um(Co(this,"text",e)):Xm(e==null?"":e+""))}function $m(e){return function(t){this.textContent=e.call(this,t)}}function Km(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&$m(r)),t}return n._value=e,n}function Xl(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,Km(e))}function Ul(){for(var e=this._name,t=this._id,o=xr(),n=this._groups,r=n.length,i=0;i<r;++i)for(var s=n[i],a=s.length,l,c=0;c<a;++c)if(l=s[c]){var d=Se(l,t);Ht(l,e,o,c,s,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new He(n,this._parents,e,o)}function $l(){var e,t,o=this,n=o._id,r=o.size();return new Promise(function(i,s){var a={value:s},l={value:function(){--r===0&&i()}};o.each(function(){var c=Re(this,n),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(l)),c.on=t}),r===0&&i()})}var qm=0;function He(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function Kl(e){return wt().transition(e)}function xr(){return++qm}var It=wt.prototype;He.prototype=Kl.prototype={constructor:He,select:Hl,selectAll:Gl,selectChild:It.selectChild,selectChildren:It.selectChildren,filter:Rl,merge:Dl,selection:Bl,transition:Ul,call:It.call,nodes:It.nodes,node:It.node,size:It.size,empty:It.empty,each:It.each,on:Ol,attr:Sl,attrTween:Cl,style:Yl,styleTween:Wl,text:Fl,textTween:Xl,remove:Vl,tween:Al,delay:Ml,duration:Pl,ease:Ll,easeVarying:kl,end:$l,[Symbol.iterator]:It[Symbol.iterator]};function Er(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Zm={time:null,delay:0,duration:250,ease:Er};function Jm(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 ql(e){var t,o;e instanceof He?(t=e._id,e=e._name):(t=xr(),(o=Zm).time=pn(),e=e==null?null:e+"");for(var n=this._groups,r=n.length,i=0;i<r;++i)for(var s=n[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&Ht(l,e,t,c,s,o||Jm(l,t));return new He(n,this._parents,e,t)}wt.prototype.interrupt=Il;wt.prototype.transition=ql;function Gt(e,t,o){this.k=e,this.x=t,this.y=o}Gt.prototype={constructor:Gt,scale:function(e){return e===1?this:new Gt(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Gt(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 _r=new Gt(1,0,0);br.prototype=Gt.prototype;function br(e){for(;!e.__zoom;)if(!(e=e.parentNode))return _r;return e.__zoom}var jm=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var Zl;(function(e){e.Strict="strict",e.Loose="loose"})(Zl||(Zl={}));var Jl;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Jl||(Jl={}));var Ql;(function(e){e.Partial="partial",e.Full="full"})(Ql||(Ql={}));var jl;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(jl||(jl={}));var ec;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(ec||(ec={}));var Ye;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ye||(Ye={}));var n2={[Ye.Left]:Ye.Right,[Ye.Right]:Ye.Left,[Ye.Top]:Ye.Bottom,[Ye.Bottom]:Ye.Top};var eg=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var tg=(e,t=[0,0])=>{var a;let{width:o,height:n}=og(e),r=(a=e.origin)!=null?a:t,i=o*r[0],s=n*r[1];return{x:e.position.x-i,y:e.position.y-s}};var Tr=(e,t=[0,0])=>{var r,i,s,a,l,c,d,u;let{x:o,y:n}=eg(e)?e.internals.positionAbsolute:tg(e,t);return{x:o,y:n,x2:o+((a=(s=(i=(r=e.measured)==null?void 0:r.width)!=null?i:e.width)!=null?s:e.initialWidth)!=null?a:0),y2:n+((u=(d=(c=(l=e.measured)==null?void 0:l.height)!=null?c:e.height)!=null?d:e.initialHeight)!=null?u:0)}};function og(e){var t,o,n,r,i,s,a,l;return{width:(r=(n=(o=(t=e.measured)==null?void 0:t.width)!=null?o:e.width)!=null?n:e.initialWidth)!=null?r:0,height:(l=(a=(s=(i=e.measured)==null?void 0:i.height)!=null?s:e.height)!=null?a:e.initialHeight)!=null?l:0}}var r2={[Ye.Left]:{x:-1,y:0},[Ye.Right]:{x:1,y:0},[Ye.Top]:{x:0,y:-1},[Ye.Bottom]:{x:0,y:1}};var ng={nodeOrigin:[0,0],nodeExtent:jm,elevateNodesOnSelect:!0,defaults:{}},i2=w(_({},ng),{checkEquality:!0});var tc;(function(e){e.Line="line",e.Handle="handle"})(tc||(tc={}));var rg={width:0,height:0,x:0,y:0},s2=w(_({},rg),{pointerX:0,pointerY:0,aspectRatio:1});var ig=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function sg(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 ag(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 vr=class{constructor(){this.xLines=[];this.yLines=[]}initialize(t){this.xLines=t.filter(o=>o.orientation==="vertical"),this.yLines=t.filter(o=>o.orientation==="horizontal"),this.xLines.sort((o,n)=>o.position-n.position),this.yLines.sort((o,n)=>o.position-n.position),this.lastHorizontalLine=void 0,this.lastVerticalLine=void 0}search(t,o,n,r,i){let s=t==="horizontal"?this.yLines:this.xLines,[a,l]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],c=[];for(let m of s){if(m.position<a)continue;if(m.position>l)break;if(i.has(m.node.id)||m.node.parentId&&i.has(m.node.parentId)||!ig(m.nodeBox,r))continue;let h=Math.abs(m.position-o);if(h>Nr)continue;let p=sg(m.nodeBox,n)>0?0:ag(m.nodeBox,n);c.push({line:m,lineDist:h,nodeDist:p})}let d=.5,u=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;c.sort((m,h)=>{if(u){if(m.line===u&&h.line!==u)return-1;if(h.line===u&&m.line!==u)return 1}return Math.abs(m.lineDist-h.lineDist)<=d?m.nodeDist-h.nodeDist:m.lineDist-h.lineDist});let f=c.length>0?c[0].line:void 0;return f&&(t==="horizontal"?this.lastHorizontalLine=f:this.lastVerticalLine=f),f}};function oc(e,t=lo,o){let n=[];return e==null||e.forEach(r=>{let i=o(r.id);if(!i)throw new Error(`Node with id ${r.id} not found in internal nodes.`);let s=Tr(i);Object.entries(t).forEach(([a,l])=>{var c;n.push({position:l.resolve(r,s),color:(c=r.style)==null?void 0:c.backgroundColor,orientation:l.orientation,anchorName:a,nodeBox:s,node:r})})}),n}function nc(e,t,o,n,r=Object.keys(lo)){let i=[];for(let a of r){let l=lo[a],c=l.resolve(null,o),d=e.search(l.orientation,c,o,t,n);d&&i.push({sourcePosition:c,anchorName:a,anchor:l,line:d})}let s={horizontal:void 0,vertical:void 0};for(let a of i){let l=s[a.anchor.orientation],c=Math.abs(a.sourcePosition-a.line.position);(!l||c<Math.abs(l.sourcePosition-l.line.position))&&(s[a.anchor.orientation]=a)}return s}function rc(e,t,o){let n=0,r=0,i=!1,s=!1;if(t){let l=t.anchor.resolve(null,e)-t.line.position;Math.abs(l)<=Nr&&(r=l,s=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=Nr&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:s}}var Nr=10,lo={top:{orientation:"horizontal",resolve:(e,t)=>t.y},bottom:{orientation:"horizontal",resolve:(e,t)=>t.y2},left:{orientation:"vertical",resolve:(e,t)=>t.x},right:{orientation:"vertical",resolve:(e,t)=>t.x2},centerX:{orientation:"vertical",resolve:(e,t)=>(t.x+t.x2)/2},centerY:{orientation:"horizontal",resolve:(e,t)=>(t.y+t.y2)/2}};import{jsx as gg}from"react/jsx-runtime";var mg=new vr;function wr(){let[e,t]=ic(void 0),[o,n]=ic(void 0),{width:r,height:i}=dg(p=>({width:p.width,height:p.height}),fg),s=lg(),a=pg(mg),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=cg(),u=gn(()=>{t(void 0),n(void 0)},[]),f=gn(p=>{let g=p!=null?p:d();u();let y=oc(g,lo,c);a.current.initialize(y)},[c,u,d]),m=gn(()=>{setTimeout(()=>{f()},100)},[f]);ug(()=>{s&&f(d())},[s,f,d]);let h=gn((p,g)=>{var G,k,O,Y,W,U,X,$,te,ie;if(!a.current||p.length===0||p.filter(F=>F.type==="dimensions").length>1)return p;u();let x=p.filter(F=>F.type==="position"&&!!F.position),N=p.find(F=>F.type==="dimensions");if(x.length===0&&!N)return p;let b=Object.keys(lo),v=new Set,T=1/0,I=1/0,S=-1/0,P=-1/0;if(x.length>0)x.forEach(F=>{var de,re,ee,ge,be,Te;let oe=g.find(ke=>ke.id===F.id);if(!oe)return;v.add(oe.id);let le=c(oe.id);if(!le)return;let Z=le.parentId?c(le.parentId):void 0,xe=F.position.x+((de=Z==null?void 0:Z.internals.positionAbsolute.x)!=null?de:0),me=F.position.y+((re=Z==null?void 0:Z.internals.positionAbsolute.y)!=null?re:0),_e=(ge=(ee=oe.measured)==null?void 0:ee.width)!=null?ge:0,J=(Te=(be=oe.measured)==null?void 0:be.height)!=null?Te:0;T=Math.min(T,xe),I=Math.min(I,me),S=Math.max(S,xe+_e),P=Math.max(P,me+J)}),N&&(b=["top","left"]);else if(N){let F=g.find(_e=>_e.id===N.id);if(!F)return p;v.add(F.id);let oe=c(F.id);if(!oe)return p;let le=oe.internals.positionAbsolute.x,Z=oe.internals.positionAbsolute.y,xe=(Y=(O=(G=N.dimensions)==null?void 0:G.width)!=null?O:(k=F.measured)==null?void 0:k.width)!=null?Y:0,me=($=(X=(W=N.dimensions)==null?void 0:W.height)!=null?X:(U=F.measured)==null?void 0:U.height)!=null?$:0;T=le,I=Z,S=le+xe,P=Z+me,b=["right","bottom"]}if(T===1/0)return p;let R={x:T,y:I,x2:S,y2:P},{x:C,y:L}=l({x:0,y:0}),{x:K,y:Q}=l({x:r,y:i}),j={x:C,y:L,x2:K,y2:Q},{horizontal:z,vertical:M}=nc(a.current,j,R,v,b),{deltaX:V,deltaY:D,snappedX:A,snappedY:B}=rc(R,z,M);if(A||B){let F=x.some(le=>le.dragging),oe=!!(N!=null&&N.resizing);(F||oe)&&(A&&n(M==null?void 0:M.line),B&&t(z==null?void 0:z.line)),A&&(x.forEach(le=>{le.position&&(le.position.x-=V)}),(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=gn(()=>gg(sc,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:f,forceRebuildIndex:m,updateHelperLines:h,helperLineHorizontal:e,helperLineVertical:o,HelperLines:E}}import{reconnectEdge as b0,useReactFlow as T0}from"@xyflow/react";import{useCallback as go,useRef as v0}from"react";var At=e=>new Map(e.map(t=>[t.id,t])),hn=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),ac=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),os=e=>e.some(t=>t.type==="START_EVENT"),Bt=(e,t)=>e==="START_EVENT"?!os(t):!0,lc=(e,t,o,n,r)=>{let i=At(o),s=i.get(e);if(!s||s.type!=="START_EVENT")return!1;let a=i.get(t);return(a==null?void 0:a.type)==="ANNOTATION"?!1:hn(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},cc=(e,t,o,n,r)=>{let i=At(o),s=i.get(t);if(!s||s.type!=="END_EVENT")return!1;let a=i.get(e);return(a==null?void 0:a.type)==="ANNOTATION"?!1:ac(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Ir=(e,t,o,n,r)=>{var c;let i=At(o),s=i.get(e);if(!s||s.type!=="GATEWAY"||((c=s.data)==null?void 0:c.variant)!=="EXCLUSIVE")return!1;let a=t?i.get(t):null;return(a==null?void 0:a.type)==="ANNOTATION"?!1:hn(e,n,r).filter(d=>{let u=i.get(d.target);return(u==null?void 0:u.type)!=="ANNOTATION"}).length>=2},dc=(e,t,o)=>{var s,a,l,c;let n=At(o),r=n.get(e),i=n.get(t);return(r==null?void 0:r.type)!=="GATEWAY"||(i==null?void 0:i.type)!=="GATEWAY"||((s=r==null?void 0:r.data)==null?void 0:s.variant)==="EXCLUSIVE"&&((a=i==null?void 0:i.data)==null?void 0:a.variant)==="PARALLEL"||((l=r==null?void 0:r.data)==null?void 0:l.variant)==="COMPLEX"&&((c=i==null?void 0:i.data)==null?void 0:c.variant)==="PARALLEL"},Ar=(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"},uc=(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"},yn=(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"},Sr=(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"},co=(e,t,o,n)=>{let r=At(t),i=r.get(e);return!i||i.type!=="TASK"?!1:ac(e,o,n).some(a=>{let l=r.get(a.source);return(l==null?void 0:l.type)==="START_EVENT"})},xn=(e,t,o,n)=>{let r=At(t),i=r.get(e);return!i||i.type!=="TASK"?!1:hn(e,o,n).some(a=>{let l=r.get(a.target);return(l==null?void 0:l.type)==="END_EVENT"})},pc=(e,t,o,n,r)=>{let i=At(o),s=i.get(e),a=i.get(t);return(s==null?void 0:s.type)==="START_EVENT"&&(a==null?void 0:a.type)==="TASK"?xn(t,o,n,r):(a==null?void 0:a.type)==="END_EVENT"&&(s==null?void 0:s.type)==="TASK"?co(e,o,n,r):!1},Cr=(e,t,o)=>hn(e,t,o).length>0,Mr=(e,t,o,n,r)=>{let i=At(o),s=i.get(e);if(!s||s.type!=="TASK")return!1;let a=t?i.get(t):null;return(a==null?void 0:a.type)==="ANNOTATION"?!1:hn(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var fc=(e,t,o,n,r)=>{var a,l;let i=At(n),s=((a=i.get(e))==null?void 0:a.type)==="ANNOTATION"||((l=i.get(t))==null?void 0:l.type)==="ANNOTATION";return o.some(c=>r&&c.id===r?!1:!!(c.source===e&&c.target===t||s&&c.source===t&&c.target===e))};var hg=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!fc(e.sourceNodeId,e.targetNodeId,e.edges,e.nodes,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!lc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!cc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!Ir(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!Mr(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:dc(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"&&uc(e.targetNodeId,e.nodes)),reason:"start_event_to_subprocess_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&yn(e.targetNodeId,e.nodes)),reason:"start_event_to_service_task_not_allowed"}),e=>({isValid:!(yn(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:!(Ar(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(Sr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(co(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!pc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(xn(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(Cr(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"})],ns=e=>{for(let t of hg){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var yg=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:Ir(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:os(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Ar(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Sr(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:yn(e.sourceNodeId,e.nodes),reason:"service_task_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:co(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:xn(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Cr(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Mr(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],mc=e=>{let t=yg.filter(o=>{let n=!o.sourceTypes||o.sourceTypes.includes(e.sourceNodeType),r=!o.targetTypes||o.targetTypes.includes(e.targetNodeType);return n&&r});for(let o of t){let n=o.validate(e);if(n.shouldDisable)return n}return{shouldDisable:!1}};import{BaseEdge as $g,EdgeLabelRenderer as Kg,getStraightPath as qg,useInternalNode as hc,useViewport as Zg}from"@xyflow/react";import{Button as _g,Tooltip as bg,TooltipContent as Tg,TooltipTrigger as vg,useTranslation as Ng}from"@produto-lecom/lecom-ui";import{Settings as wg}from"lucide-react";import{getIncomers as Pr,getOutgoers as Lr,useReactFlow as Eg}from"@xyflow/react";import{useStoreApi as xg}from"@xyflow/react";var zt=()=>{let e=xg();return{selectElements:n=>{let{edges:r,nodes:i,triggerEdgeChanges:s,triggerNodeChanges:a}=e.getState(),l=i.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]),c=r.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]);return a(l),s(c),!0},clearSelection:async()=>{let{unselectNodesAndEdges:n}=e.getState();return n(),await Gn(),!0}}};var kr=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=Eg(),{selectElements:r}=zt(),i=p=>{let g=o(),y=n(),x=Pr(p,g,y),N=Lr(p,g,y),b=x.some(T=>T.type==="START_EVENT"),v=N.some(T=>T.type==="END_EVENT");return b?"start":v?"end":"between"},s=(p,g,y)=>{var b,v,T,I,S;if(!p)return;let x={type:p.type,variant:(b=p.data)==null?void 0:b.variant,attribute:(v=p.data)==null?void 0:v.attribute},N={id:p.id,position:i(p),label:(T=p.data)==null?void 0:T.label,node:x};return p.type==="TASK"&&((I=p.data)==null?void 0:I.variant)==="SUBPROCESS"?w(_({},N),{type:"sub_process"}):p.type==="TASK"&&((S=p.data)==null?void 0:S.variant)==="SERVICE_TASK"?w(_({},N),{type:"service_task"}):p.type==="GATEWAY"?w(_({},N),{type:"gateway",variant:a(p,g,y)}):w(_({},N),{type:"activity"})},a=(p,g,y)=>{if(p.type!=="GATEWAY")return;let x=Pr(p,g,y),N=!1,b=!1;if(x.forEach(v=>{var T,I;v.type==="TASK"&&(((T=v.data)==null?void 0:T.variant)==="SCRIPT"&&(N=!0),((I=v.data)==null?void 0:I.attribute)==="LOOP"&&(b=!0))}),N&&b)return"script_loop";if(N)return"script";if(b)return"loop"},l=(p,g,y)=>{var T,I,S,P,R;let x=e(p.source),N=e(p.target);if(!x||!N)return"simple";if(Lr(x,g,y).some(C=>C.type==="END_EVENT"))return"final";if(x.type==="GATEWAY")switch((T=x.data)==null?void 0:T.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(x.type==="TASK"){let C=(I=x.data)==null?void 0:I.variant,L=(S=x.data)==null?void 0:S.attribute;if(C==="SUBPROCESS")return"from_sub_process";if(C==="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=C==="SCRIPT",Q=L==="LOOP";return K&&Q?"script_loop":K?"script":Q?"loop":"simple"}return"simple"},c=(p,g,y)=>{let x=[];function N(v,T,I=0){let S=s(v,g,y);if(S.depth=I,T.push(S),v.type==="TASK"){x.push([...T]),T.pop();return}let P=Pr(v,g,y);if(P.length)for(let R of P)N(R,T,I+1);T.pop()}let b=Pr(p,g,y);for(let v of b)N(v,[]);return x},d=(p,g,y)=>{let x=[];function N(v,T,I=0){let S=s(v,g,y);if(S.depth=I,T.push(S),v.type==="TASK"){x.push([...T]),T.pop();return}let P=Lr(v,g,y);if(P.length)for(let R of P)N(R,T,I+1);T.pop()}let b=Lr(p,g,y);for(let v of b)N(v,[]);return x},u=(p,g,y)=>(y=y.filter(N=>N.source===p.id),y.map(N=>{var T;let b=e(N.target),v;return b&&(v=s(b,g,y)),{id:N.id,type:"routing",variant:l(N,g,y),label:(T=N.data)==null?void 0:T.label,target:v}})),f=p=>{let g=e(p);if(!g)return;let y=o(),x=n(),N=s(g,y,x);return N.sources=c(g,y,x),N.targets=d(g,y,x),N.edgeTargets=u(g,y,x),g.type==="GATEWAY"&&(N.variant=a(g,y,x)),N},m=p=>{let g=t(p);if(!g)return;let y=o(),x=n(),N=l(g,y,x),v={id:g.id,type:"routing",variant:N,gatewayVariant:void 0},T=e(g.source);if(T){let S=s(T,y,x);v.source=S;let P=a(T,y,x);if(v.gatewayVariant=P,T.type==="TASK")v.sources=[[S]];else{let R=c(T,y,x);v.sources=R.length?R:[[S]]}}let I=e(g.target);if(I){let S=s(I,y,x);if(v.target=S,I.type==="TASK")v.targets=[[S]];else{let P=d(I,y,x);v.targets=P.length?P:[[S]]}}return v},h=p=>{let g=e(p);if(g)return f(g.id);let y=t(p);if(y)return m(y.id)};return{configureElement:p=>{let g=h(p);if(g)return r([p]),g},getConfigureElement:h,getNodeConfigure:f,getEdgeConfigure:m}};import{jsx as Rr,jsxs as Ag}from"react/jsx-runtime";var Ig={node:"editor.toolbar.configure_node",edge:"editor.toolbar.configure_edge",gateway:"editor.toolbar.configure_gateway"},Yt=({elementId:e,elementType:t="node"})=>{let{t:o}=Ng(),{onConfigureElement:n}=q(),{getConfigureElement:r}=kr();return Ag(bg,{children:[Rr(vg,{asChild:!0,children:Rr(_g,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let s=r(e);s&&(n==null||n(s))},children:Rr(wg,{size:16})})}),Rr(Tg,{color:"black",children:o(Ig[t])})]})};import{Button as Cg,Tooltip as Mg,TooltipContent as Pg,TooltipTrigger as Lg,useTranslation as kg}from"@produto-lecom/lecom-ui";import{useReactFlow as Rg}from"@xyflow/react";import{TrashIcon as Dg}from"lucide-react";import{useNotificationToast as Sg}from"@produto-lecom/lecom-ui";function We(){let{toast:e}=En(),{toast:t}=Sg();return{toast:e||t}}import{jsx as Dr,jsxs as Og}from"react/jsx-runtime";var Or=({elementId:e,elementType:t="node"})=>{let{t:o}=kg(),{toast:n}=We(),{deleteElements:r,getNodes:i}=Rg();return Og(Mg,{children:[Dr(Lg,{asChild:!0,children:Dr(Cg,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{if(t==="node"){let a=i(),l=a.find(c=>c.id===e);if((l==null?void 0:l.type)==="LANE"&&a.some(d=>d.parentId===e)){n({variant:"error",title:o("validation.errors.title"),content:o("editor.toolbar.delete_pool_lane_error")});return}r({nodes:[{id:e}]})}else r({edges:[{id:e}]})},children:Dr(Dg,{size:16})})}),Dr(Pg,{color:"black",children:o("editor.toolbar.delete")})]})};import{Button as Vg,Tooltip as Hg,TooltipContent as Gg,TooltipTrigger as Bg,useTranslation as zg}from"@produto-lecom/lecom-ui";import{MoveUpRightIcon as Yg}from"lucide-react";import{useCallback as Wg}from"react";import{jsx as Vr,jsxs as Fg}from"react/jsx-runtime";var Mo=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=zg(),r=Wg(i=>{i.stopPropagation();let s=document.querySelectorAll(`.react-flow__handle.source[data-nodeid="${e}"]`);if(s.length===0)return;let a=Array.from(s).reduce((f,m)=>{let h=f.getBoundingClientRect(),E=m.getBoundingClientRect(),p=Math.hypot(i.clientX-(h.left+h.width/2),i.clientY-(h.top+h.height/2));return Math.hypot(i.clientX-(E.left+E.width/2),i.clientY-(E.top+E.height/2))<p?m:f}),l=a.getBoundingClientRect(),c=l.left+l.width/2,d=l.top+l.height/2,u=new MouseEvent("mousedown",{clientX:c,clientY:d,bubbles:!0,cancelable:!0});a.dispatchEvent(u)},[e]);return Fg(Hg,{children:[Vr(Bg,{asChild:!0,children:Vr(Vg,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:Vr(Yg,{size:16})})}),Vr(Gg,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};import{jsx as _n}from"react/jsx-runtime";var Po=i=>{var s=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=s,r=gt(s,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:a}=q(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d,isToEndEvent:u}=Un(o,n),f=!l&&!c&&!d&&!u,m=[{component:_n(Or,{elementId:e,elementType:"edge"})}],h=()=>a==="view"?f?[{component:_n(Yt,{elementId:e,elementType:"edge"})}]:[]:f?[{component:_n(Yt,{elementId:e,elementType:"edge"})},...m]:m,p=(g=>{switch(g){case"SEQUENCE_EDGE":return h();case"MESSAGE_EDGE":return a==="view"?[]:[...m];case"ANNOTATION_EDGE":return a==="view"?[]:[...m];default:return[]}})(t);if(!(p.length===0||a==="readonly"))return _n("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,y)=>_n("div",{children:g.component},y))}))};import{useViewport as Xg}from"@xyflow/react";import{useMemo as Ug}from"react";import{jsx as gc}from"react/jsx-runtime";var xt=12,Lo=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:s}=Xg(),a=1/s,l=Ug(()=>t===n?{bottom:`${xt}px`,transform:"translateX(-50%)"}:e===o?{left:`${xt}px`,transform:r?"translateY(-100%)":"translateY(-50%)"}:n>t&&o>e?{left:`${xt}px`,bottom:`${xt}px`}:n>t&&o<e?{right:`${xt}px`,bottom:`${xt}px`}:t>n&&o>e?{right:`${xt}px`,bottom:`${xt}px`}:{left:`${xt}px`,bottom:`${xt}px`},[e,t,o,n,r]);return gc("div",{style:{transform:`scale(${a})`},children:gc("div",{className:"absolute pointer-events-auto",style:_({},l),children:i})})};import{Fragment as Jg,jsx as po,jsxs as yc}from"react/jsx-runtime";var ko={type:"ANNOTATION_EDGE",reconnectable:!0},xc=({id:e,source:t,target:o,selected:n,data:r})=>{let{isMultipleSelection:i,isReadOnly:s,edgeHighlight:a}=q(),{zoom:l}=Zg(),c=hc(t),d=hc(o);if(!c||!d)return null;let{sx:u,sy:f,tx:m,ty:h}=wo(c,d),[E,p,g]=qg({sourceX:u,sourceY:f,targetX:m,targetY:h}),y=a&&(n||(c==null?void 0:c.selected)||(d==null?void 0:d.selected));return po(Jg,{children:yc("g",{className:H("group bpmn-edge",{"is-highlighted":y}),children:[po("path",{d:E,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/l),style:{pointerEvents:"stroke",cursor:"pointer"}}),yc("g",{className:H("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!s,"text-blue-500 group-hover:text-blue-600":y}),children:[po($g,{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)]":y&&!(r!=null&&r.hasError)})}),po(Kg,{children:po("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&&po(Lo,{sx:u,sy:f,tx:m,ty:h,children:po(Po,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})})})]})]})})};import{useState as Sc,useCallback as Cc,useMemo as ss,useEffect as mh,useRef as as}from"react";import{BaseEdge as gh,EdgeLabelRenderer as hh,MarkerType as Mc,useInternalNode as Pc,useReactFlow as yh,useViewport as xh,useEdges as Eh,useNodes as _h,Position as Vo}from"@xyflow/react";import{useCallback as Qg,useEffect as rs,useRef as Ec,useState as jg}from"react";import{jsx as bc}from"react/jsx-runtime";var is=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,_c=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Escape","Shift"],De=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:s,onBlur:a,onInput:l,onInvalidFirstCharacter:c,skipFirstCharValidation:d})=>{let u=Ec(null),f=Ec(null),[m,h]=jg(!1);rs(()=>()=>{f.current&&clearTimeout(f.current)},[]),rs(()=>{h(i!=null?i:!1)},[i]),rs(()=>{if(m&&u.current){u.current.focus();let b=document.createRange();b.selectNodeContents(u.current);let v=window.getSelection();v&&(v.removeAllRanges(),v.addRange(b))}},[m]);let E=Qg(()=>{f.current||(c==null||c(),f.current=setTimeout(()=>{f.current=null},500))},[c]),p=b=>{b.stopPropagation(),m||h(!0)},g=b=>{let v=b.currentTarget.innerText.replace(/\n$/,""),T=t&&v.length>=t,I=window.getSelection(),S=(I==null?void 0:I.toString())||"",P=S.length>0,R=(b.ctrlKey||b.metaKey)&&!b.altKey,C=R&&b.key==="a",L=R&&b.key==="c",K=R&&b.key==="x",Q=R&&b.key==="v",j=v.length===0||P&&S.length===v.length;if(!d&&j&&!is.test(b.key)&&!_c.includes(b.key)&&!R){b.preventDefault(),E();return}T&&!P&&(_c.includes(b.key)||C||L||K||Q||b.preventDefault())},y=b=>{b.preventDefault();let v=b.clipboardData.getData("text/plain").replace(/\r\n/g,`
|
|
1
|
+
var wp=Object.defineProperty,Ap=Object.defineProperties;var Ip=Object.getOwnPropertyDescriptors;var Vn=Object.getOwnPropertySymbols;var zs=Object.prototype.hasOwnProperty,Ys=Object.prototype.propertyIsEnumerable;var Bs=(e,t,o)=>t in e?wp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,_=(e,t)=>{for(var o in t||(t={}))zs.call(t,o)&&Bs(e,o,t[o]);if(Vn)for(var o of Vn(t))Ys.call(t,o)&&Bs(e,o,t[o]);return e},w=(e,t)=>Ap(e,Ip(t));var gt=(e,t)=>{var o={};for(var n in e)zs.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Vn)for(var n of Vn(e))t.indexOf(n)<0&&Ys.call(e,n)&&(o[n]=e[n]);return o};var Mi=e=>{if(typeof document=="undefined")return;let t=document.cookie.match(new RegExp(`(?:^|; )${e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")}=([^;]*)`));return t?decodeURIComponent(t[1]):void 0};import{initializeI18n as Cp,Translations as Sp}from"@produto-lecom/lecom-ui";var Fs={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 Ws={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 Xs={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 Us={pt_BR:Xs,en_US:Fs,es_ES:Ws};var $s,Ks,Mp=(Ks=($s=Mi("LecomUserLanguage"))!=null?$s:Mi("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?Ks:Sp.PT_BR;Cp({lng:Mp,resources:Us});var Ae=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(Ae||{});var Hn=(i=>(i.ACTIVITY="activity",i.ROUTING="routing",i.GATEWAY="gateway",i.SUB_PROCESS="sub_process",i.SERVICE_TASK="service_task",i))(Hn||{}),Pi=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Pi||{}),Li=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Li||{}),ki=(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))(ki||{});import{Bot as Yp,RotateCcw as Fp,ScrollText as Wp,SquarePlus as Xp}from"lucide-react";import{jsx as Gn,jsxs as Pp}from"react/jsx-runtime";var Bn=({size:e=24,className:t})=>Pp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:[Gn("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),Gn("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),Gn("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),Gn("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as qs}from"react/jsx-runtime";var _o=({size:e=24,className:t})=>qs("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:qs("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as Ko,jsxs as Lp}from"react/jsx-runtime";var bo=({size:e=24,className:t})=>Lp("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:[Ko("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"}),Ko("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Ko("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),Ko("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Ko("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Ri,jsxs as kp}from"react/jsx-runtime";var To=({size:e=24,className:t})=>kp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[Ri("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"}),Ri("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Ri("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Di,jsxs as Rp}from"react/jsx-runtime";var vo=({size:e=24,className:t})=>Rp("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:[Di("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"}),Di("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Di("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Oi,jsxs as Dp}from"react/jsx-runtime";var Zs=({size:e=24,className:t})=>Oi("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:Dp("g",{children:[Oi("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"}),Oi("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as Op}from"clsx";import{twMerge as Vp}from"tailwind-merge";function H(...e){return Vp(Op(e))}var Rt=(e=0,t=0)=>e<t?t:e,zn=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as Js,jsxs as Hp}from"react/jsx-runtime";var Qs=({size:e=24,className:t})=>Hp("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:[Js("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"}),Js("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Vi}from"react/jsx-runtime";var js=({size:e=24,className:t})=>Vi("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:Vi("g",{children:Vi("path",{d:"M4.85372 6.17472L5.31292 5.71552L5.31993 5.70863C6.88908 4.1924 8.98352 3.34122 11.1655 3.33301L11.1668 3.33301C11.167 3.33301 11.1673 3.33301 11.1675 3.33301C12.7165 3.33314 14.2308 3.79255 15.5188 4.65317C16.807 5.5139 17.811 6.7373 18.4039 8.16866C18.9968 9.60001 19.1519 11.175 18.8497 12.6945C18.5986 13.9567 18.0414 15.1334 17.232 16.1236L16.9457 16.4738L17.2655 16.7936L20.6617 20.1899L20.6617 20.1899C20.7919 20.3201 20.7919 20.5311 20.6617 20.6612L20.6616 20.6613C20.5316 20.7915 20.3205 20.7915 20.1903 20.6613L16.7941 17.265L16.4743 16.9452L16.1241 17.2315C15.1339 18.0409 13.9571 18.5981 12.695 18.8492C11.1755 19.1514 9.6005 18.9963 8.16915 18.4034C6.73778 17.8105 5.51439 16.8065 4.65365 15.5183C3.79291 14.2301 3.3335 12.7156 3.3335 11.1663C3.3335 10.9822 3.48273 10.833 3.66683 10.833C3.85093 10.833 4.00016 10.9822 4.00016 11.1663C4.00016 12.5838 4.42048 13.9694 5.20796 15.148C5.99545 16.3265 7.11474 17.245 8.42426 17.7874C9.73378 18.3299 11.1748 18.4719 12.565 18.1953C13.9552 17.9188 15.2321 17.2362 16.2344 16.234L16.2345 16.234C17.2367 15.2316 17.9193 13.9547 18.1958 12.5645C18.4724 11.1743 18.3304 9.7333 17.7879 8.42378C17.2455 7.11426 16.327 5.99497 15.1484 5.20748L14.8707 5.62322L15.1484 5.20748C13.9703 4.42031 12.5854 4.00001 11.1685 3.99968L11.1664 3.99969C9.15876 4.00767 7.23176 4.7903 5.78712 6.18424L5.78706 6.18418L5.78075 6.1905L5.32512 6.64613L4.47156 7.49968H5.67867H7.8335C8.01759 7.49968 8.16683 7.64892 8.16683 7.83302C8.16683 8.01711 8.01759 8.16635 7.8335 8.16635H3.66683C3.48274 8.16635 3.3335 8.01711 3.3335 7.83302V3.66635C3.3335 3.48225 3.48274 3.33302 3.66683 3.33302C3.85092 3.33302 4.00016 3.48225 4.00016 3.66635V5.82117V7.02827L4.85372 6.17472Z"})})});import{jsx as ea}from"react/jsx-runtime";var Yn=({size:e=24,className:t})=>ea("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:ea("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as ta}from"react/jsx-runtime";var qo=({size:e=24,className:t})=>ta("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",className:H("stroke-2",t),children:ta("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as Hi,jsxs as Gp}from"react/jsx-runtime";var oa=({size:e=24,className:t})=>Gp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[Hi("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"}),Hi("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"}),Hi("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Zo,jsxs as Bp}from"react/jsx-runtime";var na=({size:e=24,className:t})=>Bp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[Zo("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"}),Zo("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"}),Zo("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"}),Zo("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Zo("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Fn,jsxs as zp}from"react/jsx-runtime";var Jo=({size:e=24,className:t})=>zp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[Fn("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"}),Fn("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),Fn("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Fn("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var ae=(s=>(s.START_EVENT="START_EVENT",s.END_EVENT="END_EVENT",s.TASK="TASK",s.LANE="LANE",s.GATEWAY="GATEWAY",s.ANNOTATION="ANNOTATION",s.UNSUPPORTED="UNSUPPORTED",s))(ae||{}),qe=(n=>(n.SCRIPT="SCRIPT",n.SUBPROCESS="SUBPROCESS",n.SERVICE_TASK="SERVICE_TASK",n))(qe||{}),Wn={SCRIPT:{icon:Wp},SUBPROCESS:{icon:Xp},SERVICE_TASK:{icon:Yp}},ht=(t=>(t.LOOP="LOOP",t))(ht||{}),Xn={LOOP:{icon:Fp}},lt=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(lt||{}),Gi={EXCLUSIVE:{icon:To},PARALLEL:{icon:vo},COMPLEX:{icon:bo}};import{useTranslation as D_}from"@produto-lecom/lecom-ui";import{ReactFlowProvider as O_}from"@xyflow/react";import{createContext as V_,useContext as H_,useEffect as G_,useId as B_,useMemo as vp,useRef as z_,useState as ut}from"react";import{Background as d_,MiniMap as u_,ReactFlow as p_,SelectionMode as f_,useKeyPress as m_}from"@xyflow/react";import{forwardRef as g_,useImperativeHandle as h_,useRef as _p}from"react";import{useTranslation as gx}from"@produto-lecom/lecom-ui";import{useEdgesState as hx,useNodesState as yx,useOnSelectionChange as xx,useReactFlow as Ex,useStoreApi as _x}from"@xyflow/react";import{useCallback as _t,useEffect as bx}from"react";var Un={MIN_WIDTH:36,MIN_HEIGHT:36},$n={MIN_WIDTH:36,MIN_HEIGHT:36},No={MIN_WIDTH:56,MIN_HEIGHT:56},Dt={MIN_WIDTH:176,MIN_HEIGHT:96},ra={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},se={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},wo={MIN_WIDTH:176,MIN_HEIGHT:64},Up={MIN_WIDTH:128,MIN_HEIGHT:64},ue={START_EVENT:Un,END_EVENT:$n,GATEWAY:No,TASK:Dt,LANE:se,ANNOTATION:wo,UNSUPPORTED:Up};import{Position as Qo}from"@xyflow/react";function ia(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 sa(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?Qo.Left:s>=i+n-1?Qo.Right:l<=a+1?Qo.Top:l>=a+r-1?Qo.Bottom:Qo.Top}function Ao(e,t){let o=ia(e,t),n=ia(t,e),r=sa(e,o),i=sa(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function Kn(e,t){return{isFromStartEvent:(e==null?void 0:e.type)==="START_EVENT",isGatewayToGateway:(e==null?void 0:e.type)==="GATEWAY"&&(t==null?void 0:t.type)==="GATEWAY",isActiviyToAndGateway:(e==null?void 0:e.type)==="TASK"&&(t==null?void 0:t.type)==="GATEWAY",isToEndEvent:(t==null?void 0:t.type)==="END_EVENT"}}import{orderBy as $p}from"lodash";var aa=e=>new Map(e.map(t=>[t.id,t])),la=(e,t)=>e.map(o=>{var n;return(n=t.get(o.id))!=null?n:o}),ot=e=>{var t,o,n,r,i,a,s,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(r=(n=e.internals)==null?void 0:n.positionAbsolute.y)!=null?r:0,w:(a=(i=e.measured)==null?void 0:i.width)!=null?a:0,h:(l=(s=e.measured)==null?void 0:s.height)!=null?l:0}},jo=e=>$p(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),ca=(e,t)=>{let{x:o,y:n}=ot(e),{x:r,y:i}=ot(t);return{x:o-r,y:n-i}};var eo=({parentId:e,nodes:t,includeTypes:o=[...Object.values(ae)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),Kp=(e,t)=>{let{x:o,y:n}=ot(e),{x:r,y:i}=ot(t),a=o-r,s=n-i;return Math.sqrt(a*a+s*s)},qp=(e,t)=>{let{x:o,y:n,w:r,h:i}=ot(e),{x:a,y:s,w:l,h:c}=ot(t),d=o+r/2,u=n+i/2;return d>=a&&d<=a+l&&u>=s&&u<=s+c},en=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&qp(e,r)){let i=Kp(e,r);i<n&&(n=i,o=r)}return o},da=(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}},pa=({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 Bi=(e,t)=>{let o=t.find(a=>a.id===e);if(!o||o.type!=="LANE"||o.parentId)return!1;let n=ot(o),r=n.x+n.w,i=n.y+n.h;return t.some(a=>{if(a.id===e||a.parentId||a.type==="LANE")return!1;let s=ot(a);return s.x<r&&s.x+s.w>n.x&&s.y<i&&s.y+s.h>n.y})};var Zp=50,to=(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+Zp-d;return t.map(S=>{var K,j,Q;if(!c.has(S.id))return S;let L=(j=(K=S.position)==null?void 0:K.y)!=null?j:0;return w(_({},S),{position:w(_({},(Q=S.position)!=null?Q:{x:0,y:0}),{y:L+u})})})},Ne=15,oo=e=>[...e].sort((t,o)=>t.position.y-o.position.y),Jp=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)},Qp=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)},zi=(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=Jp(C),R=Qp(C);if(((g=(p=C.position)==null?void 0:p.y)!=null?g:0)<Ne&&(o.set(C.id,w(_({},C),{position:w(_({},C.position),{y:Ne})})),R=Ne+((x=(h=C.measured)==null?void 0:h.height)!=null?x:0)),((b=(N=C.position)==null?void 0:N.x)!=null?b:0)<se.HEADER_WIDTH+Ne){let S=(T=o.get(C.id))!=null?T:C;o.set(C.id,w(_({},S),{position:w(_({},S.position),{x:se.HEADER_WIDTH+Ne})})),P=se.HEADER_WIDTH+Ne+((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,se.MIN_WIDTH),l=Math.max(r,se.MIN_HEIGHT);i+Ne>s&&(s=i+Ne),a+Ne>l&&(l=a+Ne);let c=w(_({},e),{width:s,height:l,measured:w(_({},e.measured),{width:s,height:l})});return o.set(e.id,c),c},fa=(e,t,o)=>{var a,s;let n=oo(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=zi(l,c,t);t.set(d.id,w(_({},d),{position:{x:se.HEADER_WIDTH,y:i}})),i+=(s=d.height)!=null?s:0}},ma=(e,t)=>{var y,E,p,g;let o=[];for(let h of t.values())h.parentId===e.id&&o.push(h);let n=oo(o),r=((E=(y=e.measured)==null?void 0:y.width)!=null?E:0)-se.HEADER_WIDTH,i=da(e.id,o)||se.MIN_WIDTH,a=o.reduce((h,x)=>{var N;return h+((N=x.height)!=null?N:se.MIN_HEIGHT)},0),s=Math.max(r,i),l=a,c=r>i,d=c?s:s+se.HEADER_WIDTH,u=c?s-se.HEADER_WIDTH:s,f=0;for(let h=0;h<n.length;h++){let x=n[h],N=Math.max(se.MIN_HEIGHT,(p=x.height)!=null?p:se.MIN_HEIGHT),b=w(_({},x),{width:u,height:N,measured:w(_({},x.measured),{width:u,height:N}),position:{x:se.HEADER_WIDTH,y:f}});if(h===o.length-1){let T=Math.max(se.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})}))},ga=(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=oo(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(se.MIN_HEIGHT,r-f)),h&&i&&(b=Math.max(se.MIN_HEIGHT,o-f)),m=m.map(A=>{if(A.id===p.id){let C=i?t-se.HEADER_WIDTH:t;return w(_({},A),{width:C,height:b,measured:w(_({},A.measured),{width:C,height:b}),position:{x:se.HEADER_WIDTH,y:f}})}return A}),x&&u?f=r+o:f+=b}),m=m.map(p=>{if(p.id===a){let g=i?t:t+se.HEADER_WIDTH;return w(_({},p),{width:g,height:i?o:f,measured:{width:g,height:i?o:f}})}return p}),m};var Yi=(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<Ne&&(e.position.y=Ne),e.position.x<se.HEADER_WIDTH+Ne&&(e.position.x=se.HEADER_WIDTH+Ne);let i=e.position.x+((f=(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+Ne>n&&(t.width=i+Ne,t.measured.width=i+Ne),a+Ne>r&&(t.height=a+Ne,t.measured.height=a+Ne),o=o.map(E=>E.id===t.id?w(_({},E),{height:t.height,width:t.width,measured:t.measured}):E.id===e.id?w(_({},E),{position:e.position}):E),o};import{create as jp}from"zustand";import{useReactFlow as ef}from"@xyflow/react";import{useCallback as tf}from"react";var qn=()=>{let{setEdges:e}=ef();return tf(()=>{let o=no.getState().pathEdgeIds;e(n=>n.map(r=>w(_({},r),{selected:o.includes(r.id)})))},[e])},no=jp((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})}}));import{useNodesInitialized as yg,useReactFlow as xg,useStore as Eg}from"@xyflow/react";import{useCallback as hn,useEffect as _g,useRef as bg,useState as cc}from"react";import{shallow as Tg}from"zustand/shallow";var of={value:()=>{}};function ya(){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 Zn(o)}function Zn(e){this._=e}function nf(e,t){return e.trim().split(/^|\s+/).map(function(o){var n="",r=o.indexOf(".");if(r>=0&&(n=o.slice(r+1),o=o.slice(0,r)),o&&!t.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:n}})}Zn.prototype=ya.prototype={constructor:Zn,on:function(e,t){var o=this._,n=nf(e+"",o),r,i=-1,a=n.length;if(arguments.length<2){for(;++i<a;)if((r=(e=n[i]).type)&&(r=rf(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]=ha(o[r],e.name,t);else if(t==null)for(r in o)o[r]=ha(o[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var o in t)e[o]=t[o].slice();return new Zn(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 rf(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function ha(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=of,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var Fi=ya;var Jn="http://www.w3.org/1999/xhtml",Wi={svg:"http://www.w3.org/2000/svg",xhtml:Jn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Nt(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),Wi.hasOwnProperty(t)?{space:Wi[t],local:e}:e}function sf(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===Jn&&t.documentElement.namespaceURI===Jn?t.createElement(e):t.createElementNS(o,e)}}function af(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Qn(e){var t=Nt(e);return(t.local?af:sf)(t)}function lf(){}function ro(e){return e==null?lf:function(){return this.querySelector(e)}}function xa(e){typeof e!="function"&&(e=ro(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=new Array(a),l,c,d=0;d<a;++d)(l=i[d])&&(c=e.call(l,l.__data__,d,i))&&("__data__"in l&&(c.__data__=l.__data__),s[d]=c);return new Ce(n,this._parents)}function Xi(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function cf(){return[]}function tn(e){return e==null?cf:function(){return this.querySelectorAll(e)}}function df(e){return function(){return Xi(e.apply(this,arguments))}}function Ea(e){typeof e=="function"?e=df(e):e=tn(e);for(var t=this._groups,o=t.length,n=[],r=[],i=0;i<o;++i)for(var a=t[i],s=a.length,l,c=0;c<s;++c)(l=a[c])&&(n.push(e.call(l,l.__data__,c,a)),r.push(l));return new Ce(n,r)}function on(e){return function(){return this.matches(e)}}function jn(e){return function(t){return t.matches(e)}}var uf=Array.prototype.find;function pf(e){return function(){return uf.call(this.children,e)}}function ff(){return this.firstElementChild}function _a(e){return this.select(e==null?ff:pf(typeof e=="function"?e:jn(e)))}var mf=Array.prototype.filter;function gf(){return Array.from(this.children)}function hf(e){return function(){return mf.call(this.children,e)}}function ba(e){return this.selectAll(e==null?gf:hf(typeof e=="function"?e:jn(e)))}function Ta(e){typeof e!="function"&&(e=on(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=[],l,c=0;c<a;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&s.push(l);return new Ce(n,this._parents)}function er(e){return new Array(e.length)}function va(){return new Ce(this._enter||this._groups.map(er),this._parents)}function nn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}nn.prototype={constructor:nn,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 Na(e){return function(){return e}}function yf(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 nn(e,i[a]);for(;a<l;++a)(s=t[a])&&(r[a]=s)}function xf(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 nn(e,i[s]);for(s=0;s<d;++s)(l=t[s])&&c.get(f[s])===l&&(r[s]=l)}function Ef(e){return e.__data__}function wa(e,t){if(!arguments.length)return Array.from(this,Ef);var o=t?xf:yf,n=this._parents,r=this._groups;typeof e!="function"&&(e=Na(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=_f(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 Ce(a,n),a._enter=s,a._exit=l,a}function _f(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Aa(){return new Ce(this._exit||this._groups.map(er),this._parents)}function Ia(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 Ca(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 Ce(s,this._parents)}function Sa(){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 Ma(e){e||(e=bf);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 Ce(r,this._parents).order()}function bf(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Pa(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function La(){return Array.from(this)}function ka(){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 Ra(){let e=0;for(let t of this)++e;return e}function Da(){return!this.node()}function Oa(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 Tf(e){return function(){this.removeAttribute(e)}}function vf(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Nf(e,t){return function(){this.setAttribute(e,t)}}function wf(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Af(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function If(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 Va(e,t){var o=Nt(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?vf:Tf:typeof t=="function"?o.local?If:Af:o.local?wf:Nf)(o,t))}function tr(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Cf(e){return function(){this.style.removeProperty(e)}}function Sf(e,t,o){return function(){this.style.setProperty(e,t,o)}}function Mf(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function Ha(e,t,o){return arguments.length>1?this.each((t==null?Cf:typeof t=="function"?Mf:Sf)(e,t,o==null?"":o)):Ot(this.node(),e)}function Ot(e,t){return e.style.getPropertyValue(t)||tr(e).getComputedStyle(e,null).getPropertyValue(t)}function Pf(e){return function(){delete this[e]}}function Lf(e,t){return function(){this[e]=t}}function kf(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function Ga(e,t){return arguments.length>1?this.each((t==null?Pf:typeof t=="function"?kf:Lf)(e,t)):this.node()[e]}function Ba(e){return e.trim().split(/^|\s+/)}function Ui(e){return e.classList||new za(e)}function za(e){this._node=e,this._names=Ba(e.getAttribute("class")||"")}za.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 Ya(e,t){for(var o=Ui(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function Fa(e,t){for(var o=Ui(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function Rf(e){return function(){Ya(this,e)}}function Df(e){return function(){Fa(this,e)}}function Of(e,t){return function(){(t.apply(this,arguments)?Ya:Fa)(this,e)}}function Wa(e,t){var o=Ba(e+"");if(arguments.length<2){for(var n=Ui(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?Of:t?Rf:Df)(o,t))}function Vf(){this.textContent=""}function Hf(e){return function(){this.textContent=e}}function Gf(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function Xa(e){return arguments.length?this.each(e==null?Vf:(typeof e=="function"?Gf:Hf)(e)):this.node().textContent}function Bf(){this.innerHTML=""}function zf(e){return function(){this.innerHTML=e}}function Yf(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function Ua(e){return arguments.length?this.each(e==null?Bf:(typeof e=="function"?Yf:zf)(e)):this.node().innerHTML}function Ff(){this.nextSibling&&this.parentNode.appendChild(this)}function $a(){return this.each(Ff)}function Wf(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ka(){return this.each(Wf)}function qa(e){var t=typeof e=="function"?e:Qn(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Xf(){return null}function Za(e,t){var o=typeof e=="function"?e:Qn(e),n=t==null?Xf:typeof t=="function"?t:ro(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function Uf(){var e=this.parentNode;e&&e.removeChild(this)}function Ja(){return this.each(Uf)}function $f(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Kf(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Qa(e){return this.select(e?Kf:$f)}function ja(e){return arguments.length?this.property("__data__",e):this.node().__data__}function qf(e){return function(t){e.call(this,t,this.__data__)}}function Zf(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 Jf(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 Qf(e,t,o){return function(){var n=this.__on,r,i=qf(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 el(e,t,o){var n=Zf(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?Qf:Jf,r=0;r<i;++r)this.each(s(n[r],t,o));return this}function tl(e,t,o){var n=tr(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 jf(e,t){return function(){return tl(this,e,t)}}function em(e,t){return function(){return tl(this,e,t.apply(this,arguments))}}function ol(e,t){return this.each((typeof t=="function"?em:jf)(e,t))}function*nl(){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 tm=[null];function Ce(e,t){this._groups=e,this._parents=t}function rl(){return new Ce([[document.documentElement]],tm)}function om(){return this}Ce.prototype=rl.prototype={constructor:Ce,select:xa,selectAll:Ea,selectChild:_a,selectChildren:ba,filter:Ta,data:wa,enter:va,exit:Aa,join:Ia,merge:Ca,selection:om,order:Sa,sort:Ma,call:Pa,nodes:La,node:ka,size:Ra,empty:Da,each:Oa,attr:Va,style:Ha,property:Ga,classed:Wa,text:Xa,html:Ua,raise:$a,lower:Ka,append:qa,insert:Za,remove:Ja,clone:Qa,datum:ja,on:el,dispatch:ol,[Symbol.iterator]:nl};var wt=rl;function or(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function $i(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function an(){}var rn=.7,ir=1/rn,Io="\\s*([+-]?\\d+)\\s*",sn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",yt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",nm=/^#([0-9a-f]{3,8})$/,rm=new RegExp(`^rgb\\(${Io},${Io},${Io}\\)$`),im=new RegExp(`^rgb\\(${yt},${yt},${yt}\\)$`),sm=new RegExp(`^rgba\\(${Io},${Io},${Io},${sn}\\)$`),am=new RegExp(`^rgba\\(${yt},${yt},${yt},${sn}\\)$`),lm=new RegExp(`^hsl\\(${sn},${yt},${yt}\\)$`),cm=new RegExp(`^hsla\\(${sn},${yt},${yt},${sn}\\)$`),il={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};or(an,Vt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:sl,formatHex:sl,formatHex8:dm,formatHsl:um,formatRgb:al,toString:al});function sl(){return this.rgb().formatHex()}function dm(){return this.rgb().formatHex8()}function um(){return fl(this).formatHsl()}function al(){return this.rgb().formatRgb()}function Vt(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=nm.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?ll(t):o===3?new ze(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?nr(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?nr(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 ze(t[1],t[2],t[3],1):(t=im.exec(e))?new ze(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=sm.exec(e))?nr(t[1],t[2],t[3],t[4]):(t=am.exec(e))?nr(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=lm.exec(e))?ul(t[1],t[2]/100,t[3]/100,1):(t=cm.exec(e))?ul(t[1],t[2]/100,t[3]/100,t[4]):il.hasOwnProperty(e)?ll(il[e]):e==="transparent"?new ze(NaN,NaN,NaN,0):null}function ll(e){return new ze(e>>16&255,e>>8&255,e&255,1)}function nr(e,t,o,n){return n<=0&&(e=t=o=NaN),new ze(e,t,o,n)}function pm(e){return e instanceof an||(e=Vt(e)),e?(e=e.rgb(),new ze(e.r,e.g,e.b,e.opacity)):new ze}function Co(e,t,o,n){return arguments.length===1?pm(e):new ze(e,t,o,n==null?1:n)}function ze(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}or(ze,Co,$i(an,{brighter(e){return e=e==null?ir:Math.pow(ir,e),new ze(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?rn:Math.pow(rn,e),new ze(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ze(so(this.r),so(this.g),so(this.b),sr(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:cl,formatHex:cl,formatHex8:fm,formatRgb:dl,toString:dl}));function cl(){return`#${io(this.r)}${io(this.g)}${io(this.b)}`}function fm(){return`#${io(this.r)}${io(this.g)}${io(this.b)}${io((isNaN(this.opacity)?1:this.opacity)*255)}`}function dl(){let e=sr(this.opacity);return`${e===1?"rgb(":"rgba("}${so(this.r)}, ${so(this.g)}, ${so(this.b)}${e===1?")":`, ${e})`}`}function sr(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function so(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function io(e){return e=so(e),(e<16?"0":"")+e.toString(16)}function ul(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new ct(e,t,o,n)}function fl(e){if(e instanceof ct)return new ct(e.h,e.s,e.l,e.opacity);if(e instanceof an||(e=Vt(e)),!e)return new ct;if(e instanceof ct)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 ct(a,s,l,e.opacity)}function ml(e,t,o,n){return arguments.length===1?fl(e):new ct(e,t,o,n==null?1:n)}function ct(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}or(ct,ml,$i(an,{brighter(e){return e=e==null?ir:Math.pow(ir,e),new ct(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?rn:Math.pow(rn,e),new ct(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,o=this.l,n=o+(o<.5?o:1-o)*t,r=2*o-n;return new ze(Ki(e>=240?e-240:e+120,r,n),Ki(e,r,n),Ki(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new ct(pl(this.h),rr(this.s),rr(this.l),sr(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=sr(this.opacity);return`${e===1?"hsl(":"hsla("}${pl(this.h)}, ${rr(this.s)*100}%, ${rr(this.l)*100}%${e===1?")":`, ${e})`}`}}));function pl(e){return e=(e||0)%360,e<0?e+360:e}function rr(e){return Math.max(0,Math.min(1,e||0))}function Ki(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 qi(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 gl(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 qi((o-n/t)*t,a,r,i,s)}}function hl(e){var t=e.length;return function(o){var n=Math.floor(((o%=1)<0?++o:o)*t),r=e[(n+t-1)%t],i=e[n%t],a=e[(n+1)%t],s=e[(n+2)%t];return qi((o-n/t)*t,r,i,a,s)}}var Zi=e=>()=>e;function mm(e,t){return function(o){return e+o*t}}function gm(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 yl(e){return(e=+e)==1?ar:function(t,o){return o-t?gm(t,o,e):Zi(isNaN(t)?o:t)}}function ar(e,t){var o=t-e;return o?mm(e,o):Zi(isNaN(e)?t:e)}var lr=function e(t){var o=yl(t);function n(r,i){var a=o((r=Co(r)).r,(i=Co(i)).r),s=o(r.g,i.g),l=o(r.b,i.b),c=ar(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 xl(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=Co(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 hm=xl(gl),ym=xl(hl);function nt(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var Qi=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ji=new RegExp(Qi.source,"g");function xm(e){return function(){return e}}function Em(e){return function(t){return e(t)+""}}function ji(e,t){var o=Qi.lastIndex=Ji.lastIndex=0,n,r,i,a=-1,s=[],l=[];for(e=e+"",t=t+"";(n=Qi.exec(e))&&(r=Ji.exec(t));)(i=r.index)>o&&(i=t.slice(o,i),s[a]?s[a]+=i:s[++a]=i),(n=n[0])===(r=r[0])?s[a]?s[a]+=r:s[++a]=r:(s[++a]=null,l.push({i:a,x:nt(n,r)})),o=Ji.lastIndex;return o<t.length&&(i=t.slice(o),s[a]?s[a]+=i:s[++a]=i),s.length<2?l[0]?Em(l[0].x):xm(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 El=180/Math.PI,cr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function es(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)*El,skewX:Math.atan(l)*El,scaleX:a,scaleY:s}}var dr;function _l(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?cr:es(t.a,t.b,t.c,t.d,t.e,t.f)}function bl(e){return e==null?cr:(dr||(dr=document.createElementNS("http://www.w3.org/2000/svg","g")),dr.setAttribute("transform",e),(e=dr.transform.baseVal.consolidate())?(e=e.matrix,es(e.a,e.b,e.c,e.d,e.e,e.f)):cr)}function Tl(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:nt(c,u)},{i:E-2,x:nt(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:nt(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:nt(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:nt(c,u)},{i:E-2,x:nt(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 ts=Tl(_l,"px, ","px)","deg)"),os=Tl(bl,", ",")",")");var So=0,cn=0,ln=0,Nl=1e3,ur,dn,pr=0,ao=0,fr=0,un=typeof performance=="object"&&performance.now?performance:Date,wl=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function fn(){return ao||(wl(_m),ao=un.now()+fr)}function _m(){ao=0}function pn(){this._call=this._time=this._next=null}pn.prototype=mr.prototype={constructor:pn,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?fn():+o)+(t==null?0:+t),!this._next&&dn!==this&&(dn?dn._next=this:ur=this,dn=this),this._call=e,this._time=o,ns()},stop:function(){this._call&&(this._call=null,this._time=1/0,ns())}};function mr(e,t,o){var n=new pn;return n.restart(e,t,o),n}function Al(){fn(),++So;for(var e=ur,t;e;)(t=ao-e._time)>=0&&e._call.call(void 0,t),e=e._next;--So}function vl(){ao=(pr=un.now())+fr,So=cn=0;try{Al()}finally{So=0,Tm(),ao=0}}function bm(){var e=un.now(),t=e-pr;t>Nl&&(fr-=t,pr=e)}function Tm(){for(var e,t=ur,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:ur=o);dn=e,ns(n)}function ns(e){if(!So){cn&&(cn=clearTimeout(cn));var t=e-ao;t>24?(e<1/0&&(cn=setTimeout(vl,e-un.now()-fr)),ln&&(ln=clearInterval(ln))):(ln||(pr=un.now(),ln=setInterval(bm,Nl)),So=1,wl(vl))}}function gr(e,t,o){var n=new pn;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var vm=Fi("start","end","cancel","interrupt"),Nm=[],Sl=0,Il=1,yr=2,hr=3,Cl=4,xr=5,mn=6;function Ht(e,t,o,n,r,i){var a=e.__transition;if(!a)e.__transition={};else if(o in a)return;wm(e,o,{name:t,index:n,group:r,on:vm,tween:Nm,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Sl})}function gn(e,t){var o=Se(e,t);if(o.state>Sl)throw new Error("too late; already scheduled");return o}function Re(e,t){var o=Se(e,t);if(o.state>hr)throw new Error("too late; already running");return o}function Se(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function wm(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=mr(i,0,o.time);function i(c){o.state=Il,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!==Il)return l();for(d in n)if(m=n[d],m.name===o.name){if(m.state===hr)return gr(a);m.state===Cl?(m.state=mn,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete n[d]):+d<t&&(m.state=mn,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete n[d])}if(gr(function(){o.state===hr&&(o.state=Cl,o.timer.restart(s,o.delay,o.time),s(c))}),o.state=yr,o.on.call("start",e,e.__data__,o.index,o.group),o.state===yr){for(o.state=hr,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=xr,1),u=-1,f=r.length;++u<f;)r[u].call(e,d);o.state===xr&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=mn,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function rs(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>yr&&n.state<xr,n.state=mn,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[a]}i&&delete e.__transition}}function Ml(e){return this.each(function(){rs(this,e)})}function Am(e,t){var o,n;return function(){var r=Re(this,e),i=r.tween;if(i!==o){n=o=i;for(var a=0,s=n.length;a<s;++a)if(n[a].name===t){n=n.slice(),n.splice(a,1);break}}r.tween=n}}function Im(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=Re(this,e),a=i.tween;if(a!==n){r=(n=a).slice();for(var s={name:t,value:o},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=s;break}l===c&&r.push(s)}i.tween=r}}function Pl(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=Se(this.node(),o).tween,r=0,i=n.length,a;r<i;++r)if((a=n[r]).name===e)return a.value;return null}return this.each((t==null?Am:Im)(o,e,t))}function Mo(e,t,o){var n=e._id;return e.each(function(){var r=Re(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return Se(r,n).value[t]}}function Er(e,t){var o;return(typeof t=="number"?nt:t instanceof Vt?lr:(o=Vt(t))?(t=o,lr):ji)(e,t)}function Cm(e){return function(){this.removeAttribute(e)}}function Sm(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Mm(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 Pm(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 Lm(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 km(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 Ll(e,t){var o=Nt(e),n=o==="transform"?os:Er;return this.attrTween(e,typeof t=="function"?(o.local?km:Lm)(o,n,Mo(this,"attr."+e,t)):t==null?(o.local?Sm:Cm)(o):(o.local?Pm:Mm)(o,n,t))}function Rm(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function Dm(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function Om(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Dm(e,i)),o}return r._value=t,r}function Vm(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Rm(e,i)),o}return r._value=t,r}function kl(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=Nt(e);return this.tween(o,(n.local?Om:Vm)(n,t))}function Hm(e,t){return function(){gn(this,e).delay=+t.apply(this,arguments)}}function Gm(e,t){return t=+t,function(){gn(this,e).delay=t}}function Rl(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Hm:Gm)(t,e)):Se(this.node(),t).delay}function Bm(e,t){return function(){Re(this,e).duration=+t.apply(this,arguments)}}function zm(e,t){return t=+t,function(){Re(this,e).duration=t}}function Dl(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Bm:zm)(t,e)):Se(this.node(),t).duration}function Ym(e,t){if(typeof t!="function")throw new Error;return function(){Re(this,e).ease=t}}function Ol(e){var t=this._id;return arguments.length?this.each(Ym(t,e)):Se(this.node(),t).ease}function Fm(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;Re(this,e).ease=o}}function Vl(e){if(typeof e!="function")throw new Error;return this.each(Fm(this._id,e))}function Hl(e){typeof e!="function"&&(e=on(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=[],l,c=0;c<a;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&s.push(l);return new He(n,this._parents,this._name,this._id)}function Gl(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 He(a,this._parents,this._name,this._id)}function Wm(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 Xm(e,t,o){var n,r,i=Wm(t)?gn:Re;return function(){var a=i(this,e),s=a.on;s!==n&&(r=(n=s).copy()).on(t,o),a.on=r}}function Bl(e,t){var o=this._id;return arguments.length<2?Se(this.node(),o).on.on(e):this.each(Xm(o,e,t))}function Um(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function zl(){return this.on("end.remove",Um(this._id))}function Yl(e){var t=this._name,o=this._id;typeof e!="function"&&(e=ro(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,Ht(c[f],t,o,f,c,Se(d,o)));return new He(i,this._parents,t,o)}function Fl(e){var t=this._name,o=this._id;typeof e!="function"&&(e=tn(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=Se(d,o),E=0,p=f.length;E<p;++E)(m=f[E])&&Ht(m,t,o,E,f,y);i.push(f),a.push(d)}return new He(i,a,t,o)}var $m=wt.prototype.constructor;function Wl(){return new $m(this._groups,this._parents)}function Km(e,t){var o,n,r;return function(){var i=Ot(this,e),a=(this.style.removeProperty(e),Ot(this,e));return i===a?null:i===o&&a===n?r:r=t(o=i,n=a)}}function Xl(e){return function(){this.style.removeProperty(e)}}function qm(e,t,o){var n,r=o+"",i;return function(){var a=Ot(this,e);return a===r?null:a===n?i:i=t(n=a,o)}}function Zm(e,t,o){var n,r,i;return function(){var a=Ot(this,e),s=o(this),l=s+"";return s==null&&(l=s=(this.style.removeProperty(e),Ot(this,e))),a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s))}}function Jm(e,t){var o,n,r,i="style."+t,a="end."+i,s;return function(){var l=Re(this,e),c=l.on,d=l.value[i]==null?s||(s=Xl(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(a,r=d),l.on=n}}function Ul(e,t,o){var n=(e+="")=="transform"?ts:Er;return t==null?this.styleTween(e,Km(e,n)).on("end.style."+e,Xl(e)):typeof t=="function"?this.styleTween(e,Zm(e,n,Mo(this,"style."+e,t))).each(Jm(this._id,e)):this.styleTween(e,qm(e,n,t),o).on("end.style."+e,null)}function Qm(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function jm(e,t,o){var n,r;function i(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&Qm(e,a,o)),n}return i._value=t,i}function $l(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,jm(e,t,o==null?"":o))}function eg(e){return function(){this.textContent=e}}function tg(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function Kl(e){return this.tween("text",typeof e=="function"?tg(Mo(this,"text",e)):eg(e==null?"":e+""))}function og(e){return function(t){this.textContent=e.call(this,t)}}function ng(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&og(r)),t}return n._value=e,n}function ql(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,ng(e))}function Zl(){for(var e=this._name,t=this._id,o=_r(),n=this._groups,r=n.length,i=0;i<r;++i)for(var a=n[i],s=a.length,l,c=0;c<s;++c)if(l=a[c]){var d=Se(l,t);Ht(l,e,o,c,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new He(n,this._parents,e,o)}function Jl(){var e,t,o=this,n=o._id,r=o.size();return new Promise(function(i,a){var s={value:a},l={value:function(){--r===0&&i()}};o.each(function(){var c=Re(this,n),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(l)),c.on=t}),r===0&&i()})}var rg=0;function He(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function Ql(e){return wt().transition(e)}function _r(){return++rg}var At=wt.prototype;He.prototype=Ql.prototype={constructor:He,select:Yl,selectAll:Fl,selectChild:At.selectChild,selectChildren:At.selectChildren,filter:Hl,merge:Gl,selection:Wl,transition:Zl,call:At.call,nodes:At.nodes,node:At.node,size:At.size,empty:At.empty,each:At.each,on:Bl,attr:Ll,attrTween:kl,style:Ul,styleTween:$l,text:Kl,textTween:ql,remove:zl,tween:Pl,delay:Rl,duration:Dl,ease:Ol,easeVarying:Vl,end:Jl,[Symbol.iterator]:At[Symbol.iterator]};function br(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var ig={time:null,delay:0,duration:250,ease:br};function sg(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 jl(e){var t,o;e instanceof He?(t=e._id,e=e._name):(t=_r(),(o=ig).time=fn(),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])&&Ht(l,e,t,c,a,o||sg(l,t));return new He(n,this._parents,e,t)}wt.prototype.interrupt=Ml;wt.prototype.transition=jl;function Gt(e,t,o){this.k=e,this.x=t,this.y=o}Gt.prototype={constructor:Gt,scale:function(e){return e===1?this:new Gt(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Gt(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 Tr=new Gt(1,0,0);vr.prototype=Gt.prototype;function vr(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Tr;return e.__zoom}var lg=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var ec;(function(e){e.Strict="strict",e.Loose="loose"})(ec||(ec={}));var tc;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(tc||(tc={}));var oc;(function(e){e.Partial="partial",e.Full="full"})(oc||(oc={}));var nc;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(nc||(nc={}));var rc;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(rc||(rc={}));var Ye;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ye||(Ye={}));var S2={[Ye.Left]:Ye.Right,[Ye.Right]:Ye.Left,[Ye.Top]:Ye.Bottom,[Ye.Bottom]:Ye.Top};var cg=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var dg=(e,t=[0,0])=>{var s;let{width:o,height:n}=ug(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 Nr=(e,t=[0,0])=>{var r,i,a,s,l,c,d,u;let{x:o,y:n}=cg(e)?e.internals.positionAbsolute:dg(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 ug(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 M2={[Ye.Left]:{x:-1,y:0},[Ye.Right]:{x:1,y:0},[Ye.Top]:{x:0,y:-1},[Ye.Bottom]:{x:0,y:1}};var pg={nodeOrigin:[0,0],nodeExtent:lg,elevateNodesOnSelect:!0,defaults:{}},P2=w(_({},pg),{checkEquality:!0});var ic;(function(e){e.Line="line",e.Handle="handle"})(ic||(ic={}));var fg={width:0,height:0,x:0,y:0},L2=w(_({},fg),{pointerX:0,pointerY:0,aspectRatio:1});var mg=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function gg(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 hg(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 wr=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)||!mg(m.nodeBox,r))continue;let y=Math.abs(m.position-o);if(y>Ar)continue;let p=gg(m.nodeBox,n)>0?0:hg(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 sc(e,t=lo,o){let n=[];return e==null||e.forEach(r=>{let i=o(r.id);if(!i)throw new Error(`Node with id ${r.id} not found in internal nodes.`);let a=Nr(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 ac(e,t,o,n,r=Object.keys(lo)){let i=[];for(let s of r){let l=lo[s],c=l.resolve(null,o),d=e.search(l.orientation,c,o,t,n);d&&i.push({sourcePosition:c,anchorName:s,anchor:l,line:d})}let a={horizontal:void 0,vertical:void 0};for(let s of i){let l=a[s.anchor.orientation],c=Math.abs(s.sourcePosition-s.line.position);(!l||c<Math.abs(l.sourcePosition-l.line.position))&&(a[s.anchor.orientation]=s)}return a}function lc(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)<=Ar&&(r=l,a=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=Ar&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:a}}var Ar=10,lo={top:{orientation:"horizontal",resolve:(e,t)=>t.y},bottom:{orientation:"horizontal",resolve:(e,t)=>t.y2},left:{orientation:"vertical",resolve:(e,t)=>t.x},right:{orientation:"vertical",resolve:(e,t)=>t.x2},centerX:{orientation:"vertical",resolve:(e,t)=>(t.x+t.x2)/2},centerY:{orientation:"horizontal",resolve:(e,t)=>(t.y+t.y2)/2}};import{jsx as Ng}from"react/jsx-runtime";var vg=new wr;function Ir(){let[e,t]=cc(void 0),[o,n]=cc(void 0),{width:r,height:i}=Eg(p=>({width:p.width,height:p.height}),Tg),a=yg(),s=bg(vg),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=xg(),u=hn(()=>{t(void 0),n(void 0)},[]),f=hn(p=>{let g=p!=null?p:d();u();let h=sc(g,lo,c);s.current.initialize(h)},[c,u,d]),m=hn(()=>{setTimeout(()=>{f()},100)},[f]);_g(()=>{a&&f(d())},[a,f,d]);let y=hn((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(lo),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,ge,be,Te;let oe=g.find(ke=>ke.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,xe=W.position.x+((de=Z==null?void 0:Z.internals.positionAbsolute.x)!=null?de:0),me=W.position.y+((re=Z==null?void 0:Z.internals.positionAbsolute.y)!=null?re:0),_e=(ge=(ee=oe.measured)==null?void 0:ee.width)!=null?ge:0,J=(Te=(be=oe.measured)==null?void 0:be.height)!=null?Te:0;v=Math.min(v,xe),A=Math.min(A,me),C=Math.max(C,xe+_e),P=Math.max(P,me+J)}),N&&(b=["top","left"]);else if(N){let W=g.find(_e=>_e.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,xe=(Y=(O=(G=N.dimensions)==null?void 0:G.width)!=null?O:(k=W.measured)==null?void 0:k.width)!=null?Y:0,me=($=(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+xe,P=Z+me,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}=ac(s.current,Q,R,T,b),{deltaX:V,deltaY:D,snappedX:I,snappedY:B}=lc(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=hn(()=>Ng(dc,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:f,forceRebuildIndex:m,updateHelperLines:y,helperLineHorizontal:e,helperLineVertical:o,HelperLines:E}}import{reconnectEdge as M0,useReactFlow as P0}from"@xyflow/react";import{useCallback as go,useRef as L0}from"react";var It=e=>new Map(e.map(t=>[t.id,t])),yn=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),uc=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),is=e=>e.some(t=>t.type==="START_EVENT"),Bt=(e,t)=>e==="START_EVENT"?!is(t):!0,pc=(e,t,o,n,r)=>{let i=It(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:yn(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},fc=(e,t,o,n,r)=>{let i=It(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:uc(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Cr=(e,t,o,n,r)=>{var c;let i=It(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:yn(e,n,r).filter(d=>{let u=i.get(d.target);return(u==null?void 0:u.type)!=="ANNOTATION"}).length>=2},mc=(e,t,o)=>{var a,s,l,c;let n=It(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"},Sr=(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"},gc=(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"},xn=(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"},Mr=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.attribute)==="LOOP"},co=(e,t,o,n)=>{let r=It(t),i=r.get(e);return!i||i.type!=="TASK"?!1:uc(e,o,n).some(s=>{let l=r.get(s.source);return(l==null?void 0:l.type)==="START_EVENT"})},En=(e,t,o,n)=>{let r=It(t),i=r.get(e);return!i||i.type!=="TASK"?!1:yn(e,o,n).some(s=>{let l=r.get(s.target);return(l==null?void 0:l.type)==="END_EVENT"})},hc=(e,t,o,n,r)=>{let i=It(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"?En(t,o,n,r):(s==null?void 0:s.type)==="END_EVENT"&&(a==null?void 0:a.type)==="TASK"?co(e,o,n,r):!1},Pr=(e,t,o)=>yn(e,t,o).length>0,Lr=(e,t,o,n,r)=>{let i=It(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:yn(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var yc=(e,t,o,n,r)=>{var s,l;let i=It(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 wg=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!yc(e.sourceNodeId,e.targetNodeId,e.edges,e.nodes,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!pc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!fc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!Cr(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!Lr(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:mc(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"&&gc(e.targetNodeId,e.nodes)),reason:"start_event_to_subprocess_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&xn(e.targetNodeId,e.nodes)),reason:"start_event_to_service_task_not_allowed"}),e=>({isValid:!(xn(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:!(Sr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(Mr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(co(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!hc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(En(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(Pr(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"})],ss=e=>{for(let t of wg){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var Ag=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:Cr(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:is(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Sr(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Mr(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:xn(e.sourceNodeId,e.nodes),reason:"service_task_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:co(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:En(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Pr(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Lr(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],xc=e=>{let t=Ag.filter(o=>{let n=!o.sourceTypes||o.sourceTypes.includes(e.sourceNodeType),r=!o.targetTypes||o.targetTypes.includes(e.targetNodeType);return n&&r});for(let o of t){let n=o.validate(e);if(n.shouldDisable)return n}return{shouldDisable:!1}};import{BaseEdge as oh,EdgeLabelRenderer as nh,getStraightPath as rh,useInternalNode as _c,useViewport as ih}from"@xyflow/react";import{Button as Sg,Tooltip as Mg,TooltipContent as Pg,TooltipTrigger as Lg,useTranslation as kg}from"@produto-lecom/lecom-ui";import{Settings as Rg}from"lucide-react";import{getIncomers as kr,getOutgoers as Rr,useReactFlow as Cg}from"@xyflow/react";import{useStoreApi as Ig}from"@xyflow/react";var zt=()=>{let e=Ig();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 zn(),!0}}};var Dr=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=Cg(),{selectElements:r}=zt(),i=p=>{let g=o(),h=n(),x=kr(p,g,h),N=Rr(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=kr(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(Rr(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=kr(T,g,h);if(P.length)for(let R of P)N(R,v,A+1);v.pop()}let b=kr(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=Rr(T,g,h);if(P.length)for(let R of P)N(R,v,A+1);v.pop()}let b=Rr(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}};import{jsx as Or,jsxs as Og}from"react/jsx-runtime";var Dg={node:"editor.toolbar.configure_node",edge:"editor.toolbar.configure_edge",gateway:"editor.toolbar.configure_gateway"},Yt=({elementId:e,elementType:t="node"})=>{let{t:o}=kg(),{onConfigureElement:n}=q(),{getConfigureElement:r}=Dr();return Og(Mg,{children:[Or(Lg,{asChild:!0,children:Or(Sg,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let a=r(e);a&&(n==null||n(a))},children:Or(Rg,{size:16})})}),Or(Pg,{color:"black",children:o(Dg[t])})]})};import{Button as Hg,Tooltip as Gg,TooltipContent as Bg,TooltipTrigger as zg,useTranslation as Yg}from"@produto-lecom/lecom-ui";import{useReactFlow as Fg}from"@xyflow/react";import{TrashIcon as Wg}from"lucide-react";import{useNotificationToast as Vg}from"@produto-lecom/lecom-ui";function Fe(){let{toast:e}=_n(),{toast:t}=Vg();return{toast:e||t}}import{jsx as Vr,jsxs as Xg}from"react/jsx-runtime";var Hr=({elementId:e,elementType:t="node"})=>{let{t:o}=Yg(),{toast:n}=Fe(),{deleteElements:r,getNodes:i}=Fg();return Xg(Gg,{children:[Vr(zg,{asChild:!0,children:Vr(Hg,{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:Vr(Wg,{size:16})})}),Vr(Bg,{color:"black",children:o("editor.toolbar.delete")})]})};import{Button as Ug,Tooltip as $g,TooltipContent as Kg,TooltipTrigger as qg,useTranslation as Zg}from"@produto-lecom/lecom-ui";import{MoveUpRightIcon as Jg}from"lucide-react";import{useCallback as Qg}from"react";import{jsx as Gr,jsxs as jg}from"react/jsx-runtime";var Po=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=Zg(),r=Qg(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 jg($g,{children:[Gr(qg,{asChild:!0,children:Gr(Ug,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:Gr(Jg,{size:16})})}),Gr(Kg,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};import{jsx as bn}from"react/jsx-runtime";var Lo=i=>{var a=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=a,r=gt(a,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:s}=q(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d,isToEndEvent:u}=Kn(o,n),f=!l&&!c&&!d&&!u,m=[{component:bn(Hr,{elementId:e,elementType:"edge"})}],y=()=>s==="view"?f?[{component:bn(Yt,{elementId:e,elementType:"edge"})}]:[]:f?[{component:bn(Yt,{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 bn("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)=>bn("div",{children:g.component},h))}))};import{useViewport as eh}from"@xyflow/react";import{useMemo as th}from"react";import{jsx as Ec}from"react/jsx-runtime";var xt=12,ko=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:a}=eh(),s=1/a,l=th(()=>t===n?{bottom:`${xt}px`,transform:"translateX(-50%)"}:e===o?{left:`${xt}px`,transform:r?"translateY(-100%)":"translateY(-50%)"}:n>t&&o>e?{left:`${xt}px`,bottom:`${xt}px`}:n>t&&o<e?{right:`${xt}px`,bottom:`${xt}px`}:t>n&&o>e?{right:`${xt}px`,bottom:`${xt}px`}:{left:`${xt}px`,bottom:`${xt}px`},[e,t,o,n,r]);return Ec("div",{style:{transform:`scale(${s})`},children:Ec("div",{className:"absolute pointer-events-auto",style:_({},l),children:i})})};import{Fragment as sh,jsx as po,jsxs as bc}from"react/jsx-runtime";var Ro={type:"ANNOTATION_EDGE",reconnectable:!0},Tc=({id:e,source:t,target:o,selected:n,data:r})=>{let{isMultipleSelection:i,isReadOnly:a,edgeHighlight:s}=q(),{zoom:l}=ih(),c=_c(t),d=_c(o);if(!c||!d)return null;let{sx:u,sy:f,tx:m,ty:y}=Ao(c,d),[E,p,g]=rh({sourceX:u,sourceY:f,targetX:m,targetY:y}),h=s&&(n||(c==null?void 0:c.selected)||(d==null?void 0:d.selected));return po(sh,{children:bc("g",{className:H("group bpmn-edge",{"is-highlighted":h}),children:[po("path",{d:E,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/l),style:{pointerEvents:"stroke",cursor:"pointer"}}),bc("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:[po(oh,{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)})}),po(nh,{children:po("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&&po(ko,{sx:u,sy:f,tx:m,ty:y,children:po(Lo,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})})})]})]})})};import{useState as Lc,useCallback as kc,useMemo as cs,useEffect as vh,useRef as ds}from"react";import{BaseEdge as Nh,EdgeLabelRenderer as wh,MarkerType as Rc,useInternalNode as Dc,useReactFlow as Ah,useViewport as Ih,useEdges as Ch,useNodes as Sh,Position as Ho}from"@xyflow/react";import{useCallback as ah,useEffect as as,useRef as vc,useState as lh}from"react";import{jsx as wc}from"react/jsx-runtime";var ls=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,Nc=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Escape","Shift"],De=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:a,onBlur:s,onInput:l,onInvalidFirstCharacter:c,skipFirstCharValidation:d})=>{let u=vc(null),f=vc(null),[m,y]=lh(!1);as(()=>()=>{f.current&&clearTimeout(f.current)},[]),as(()=>{y(i!=null?i:!1)},[i]),as(()=>{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=ah(()=>{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&&!ls.test(b.key)&&!Nc.includes(b.key)&&!R){b.preventDefault(),E();return}v&&!P&&(Nc.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
|
-
`),
|
|
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&&!ls.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&&!ls.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&&v.length>t&&(v=v.substring(0,t)),b.currentTarget.innerText=v,a==null||a(),v!==e&&(s==null||s(v))};return bc("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:bc("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:y,onInput:x,onBlur:N,children:e})})};import{Position as jI}from"@xyflow/react";var ye=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,Ro=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),Hr=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),eh=(e,t,o)=>{let n=o.x-t.x,r=o.y-t.y,i=n*n+r*r;if(i===0)return Ro(e,t);let s=Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*r)/i));return Ro(e,{x:t.x+s*n,y:t.y+s*r})},Tc=(e,t)=>{let o=1/0;for(let n=0;n<t.length-1;n++)o=Math.min(o,eh(e,t[n],t[n+1]));return o};import{Position as Gr}from"@xyflow/react";var Wt={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15,MAX_LABEL_DISTANCE:80};var{TOLERANCE:ce}=Wt;function th(e,t,o){return ye(e,t,"x",ce)&&ye(t,o,"x",ce)&&ye(e,o,"x",ce)}function oh(e,t,o){return ye(e,t,"y",ce)&&ye(t,o,"y",ce)&&ye(e,o,"y",ce)}function nh(e,t,o){if(!th(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 rh(e,t,o){if(!oh(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 ih(e,t,o,n){let r=t.x!==0,i=t.x===-n.x&&t.y===-n.y,s=t.x===n.x&&t.y===n.y,a=120;if(i)if(r){if((o.x-e.x)*t.x>=0)return[{x:(e.x+o.x)/2,y:e.y},{x:(e.x+o.x)/2,y:o.y}];{let l=(e.y+o.y)/2,c=Math.abs(e.y-o.y)<a?Math.max(e.y,o.y)+a:l;return[{x:e.x,y:c},{x:o.x,y:c}]}}else{if((o.y-e.y)*t.y>=0)return[{x:e.x,y:(e.y+o.y)/2},{x:o.x,y:(e.y+o.y)/2}];{let l=(e.x+o.x)/2,c=Math.abs(e.x-o.x)<a?Math.max(e.x,o.x)+a:l;return[{x:c,y:e.y},{x:c,y:o.y}]}}else if(s)if(r)if((o.x-e.x)*t.x>0&&Math.abs(e.y-o.y)<a){let l=Math.max(e.y,o.y)+a,c=o.x+t.x*(a/2);return[{x:e.x,y:l},{x:c,y:l},{x:c,y:o.y}]}else{let l=t.x>0?Math.max(e.x,o.x):Math.min(e.x,o.x);return[{x:l,y:e.y},{x:l,y:o.y}]}else if((o.y-e.y)*t.y>0&&Math.abs(e.x-o.x)<a){let l=Math.max(e.x,o.x)+a,c=o.y+t.y*(a/2);return[{x:l,y:e.y},{x:l,y:c},{x:o.x,y:c}]}else{let l=t.y>0?Math.max(e.y,o.y):Math.min(e.y,o.y);return[{x:e.x,y:l},{x:o.x,y:l}]}else{let l=t.x!==0?o.x:e.x,c=t.y!==0?o.y:e.y,d=t.x!==0?(l-e.x)*t.x:(c-e.y)*t.y,u=n.x!==0?(l-o.x)*n.x:(c-o.y)*n.y;return d>=0&&u>=0?[{x:l,y:c}]:r?[{x:e.x,y:o.y}]:[{x:o.x,y:e.y}]}}function vc(e){if(e.length<=2)return e;let t=[e[0]];for(let o=1;o<e.length-1;o++){let n=t[t.length-1],r=e[o],i=e[o+1];ye(n,r,"x",ce)&&ye(r,i,"x",ce)||ye(n,r,"y",ce)&&ye(r,i,"y",ce)||t.push(r)}return t.push(e[e.length-1]),t}function Br(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 sh(e){let t=[...e],o=!0;for(;o;){o=!1;for(let n=1;n<t.length-1;n++){let r=t[n-1],i=t[n],s=t[n+1];if(nh(r,i,s)||rh(r,i,s)){t.splice(n,1),o=!0;break}}}return t}function Nc(e){let t=Br(vc([...e]));return t=sh(t),Br(vc(t))}function zr(e){switch(e){case Gr.Left:return{x:-1,y:0};case Gr.Right:return{x:1,y:0};case Gr.Top:return{x:0,y:-1};case Gr.Bottom:return{x:0,y:1};default:return{x:0,y:0}}}function wc(e,t,o,n){let r=Wt.OFFSET,i=Wt.OFFSET;if(t.x===-n.x&&t.y===-n.y)if(t.x!==0){let s=(o.x-e.x)*t.x;s>0&&s<2*Wt.OFFSET&&(r=s/2,i=s/2)}else{let s=(o.y-e.y)*t.y;s>0&&s<2*Wt.OFFSET&&(r=s/2,i=s/2)}return{sourceOffset:r,targetOffset:i}}function ah(e,t,o,n,r,i,s=0){let a=zr(r),l=zr(i),c=a.x===0?s:0,d=a.y===0?s:0,u=l.x===0?s:0,f=l.y===0?s:0,m={x:e+c,y:t+d},h={x:o+u,y:n+f},{sourceOffset:E,targetOffset:p}=wc(m,a,h,l),g={x:m.x+a.x*E,y:m.y+a.y*E},y={x:h.x+l.x*p,y:h.y+l.y*p},x=ih(g,a,y,l),N=[m,g,...x,y,h],b=Nc(N);if(b.length===2&&Yr(m,h)>ce){let v=ye(m,g,"x",ce)&&ye(g,y,"x",ce)&&ye(y,h,"x",ce),T=ye(m,g,"y",ce)&&ye(g,y,"y",ce)&&ye(y,h,"y",ce);if(v||T){let I=T&&(y.x-g.x)*a.x<0,S=v&&(y.y-g.y)*a.y<0;if(!I&&!S)return Br([m,g,y,h])}}return b}function Wr(e,t,o,n,r,i,s,a=0){if(!(s!=null&&s.length))return ah(e,t,o,n,r,i,a);let l=zr(r),c=zr(i),d=l.x===0?a:0,u=l.y===0?a:0,f=c.x===0?a:0,m=c.y===0?a:0,h={x:e+d,y:t+u},E={x:o+f,y:n+m},{sourceOffset:p,targetOffset:g}=wc(h,l,E,c),y={x:h.x+l.x*p,y:h.y+l.y*p},x={x:E.x+c.x*g,y:E.y+c.y*g},N=[...s],b=N[0],v=l.y===0;v&&Math.abs(h.y-b.y)>ce?N.unshift({x:b.x,y:h.y}):!v&&Math.abs(h.x-b.x)>ce&&N.unshift({x:h.x,y:b.y});let T=N[N.length-1],I=c.y===0,S=[];(Math.abs(T.x-x.x)>ce||Math.abs(T.y-x.y)>ce)&&(I?S.push({x:x.x,y:T.y}):S.push({x:T.x,y:x.y})),S.push(x);let P=[h,...N,...S,E],R=Nc(P);if(R.length===2&&Yr(h,E)>ce){let C=ye(h,y,"x",ce)&&ye(y,x,"x",ce)&&ye(x,E,"x",ce),L=ye(h,y,"y",ce)&&ye(y,x,"y",ce)&&ye(x,E,"y",ce);if(C||L){let K=L&&(x.x-y.x)*l.x<0,Q=C&&(x.y-y.y)*l.y<0;if(!K&&!Q)return Br([h,y,x,E])}}return R}var Yr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function lh(e,t,o){return ye(e,t,"x",ce)&&ye(t,o,"x",ce)||ye(e,t,"y",ce)&&ye(t,o,"y",ce)}function ch(e,t,o,n){if(lh(e,t,o))return`L${t.x} ${t.y}`;let r=Yr(e,t),i=Yr(t,o),s=Math.min(r/2,i/2,n);if(s<1)return`L${t.x} ${t.y}`;let a=e.x-t.x,l=e.y-t.y,c=o.x-t.x,d=o.y-t.y,u={x:a/r,y:l/r},f={x:c/i,y:d/i},m={x:t.x+u.x*s,y:t.y+u.y*s},h={x:t.x+f.x*s,y:t.y+f.y*s},E=-u.x,p=-u.y,g=f.x,y=f.y,N=E*y-p*g>0?1:0;return`L${m.x} ${m.y}A${s} ${s} 0 0 ${N} ${h.x} ${h.y}`}var Ic=(e,t=5)=>e.length<2?"":e.reduce((o,n,r)=>{let i="";return r>0&&r<e.length-1?i=ch(e[r-1],n,e[r+1],t):i=`${r===0?"M":"L"}${n.x} ${n.y}`,o+=i,o},"");import{useCallback as Do,useEffect as Fr,useRef as bn,useState as Oo}from"react";import{useReactFlow as dh,useStore as uh}from"@xyflow/react";var ph=50,Ac=.1,fh=.6,Xr=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:s,getNodes:a,getEdge:l,screenToFlowPosition:c}=dh(),{setIsDragging:d,setReconnectingEdgeId:u}=q(),f=uh(D=>D.isValidConnection),[m,h]=Oo(null),[E,p]=Oo(null),[g,y]=Oo(null),[x,N]=Oo(null),[b,v]=Oo(null),[T,I]=Oo(!1),S=bn(null),P=bn(null),R=bn(null),C=bn(t),L=bn(o);Fr(()=>{C.current=t,L.current=o},[t,o]),Fr(()=>{S.current=m},[m]),Fr(()=>{P.current=b},[b]);let K=Do(D=>{let A=a(),B=A.find(Y=>Y.id===D);if(!B)return{x:0,y:0};let G=B.position.x,k=B.position.y,O=B.parentId;for(;O;){let Y=A.find(W=>W.id===O);if(!Y)break;G+=Y.position.x,k+=Y.position.y,O=Y.parentId}return{x:G,y:k}},[a]),Q=Do(D=>{var O,Y,W,U,X,$;let A=a(),B=null,G=ph,k=A.filter(te=>te.type!=="LANE"&&te.type!=="ANNOTATION");for(let te of k){if(te.id===e)continue;let ie=K(te.id),F=(W=(Y=(O=te.measured)==null?void 0:O.width)!=null?Y:te.width)!=null?W: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+F&&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+F)),xe=Math.max(ie.y-D.y,0,D.y-(ie.y+oe)),me=Math.sqrt(Z*Z+xe*xe);me<G&&(G=me,B=te.id)}return B},[a,K,e]),j=Do((D,A)=>{var Z,xe,me,_e,J,de;let B=s(D);if(!B)return null;let G=K(D),k=(me=(xe=(Z=B.measured)==null?void 0:Z.width)!=null?xe:B.width)!=null?me:0,O=(de=(J=(_e=B.measured)==null?void 0:_e.height)!=null?J:B.height)!=null?de:0,Y=Math.abs(G.x+k-A.x),W=Math.abs(A.x-G.x),U=Math.abs(G.y+O-A.y),X=Math.abs(A.y-G.y),$={right:Y,left:W,bottom:U,top:X},te=Object.entries($).reduce((re,[ee,ge])=>ge<re[1]?[ee,ge]:re,["right",$.right])[0],ie=R.current;if(ie&&ie!==te){let re=$[te],ee=$[ie],ge=Math.abs(ee-re),be=Math.min(Math.abs(ee),Math.abs(re));ge<be*fh&&(te=ie)}let F=te,oe,le;if(F==="right"||F==="left"){let ee=(Math.max(G.y,Math.min(G.y+O,A.y))-G.y)/(O||1);Math.abs(ee-.5)<Ac&&(ee=.5),le=ee,oe={x:F==="right"?G.x+k:G.x,y:G.y+le*O}}else{let ee=(Math.max(G.x,Math.min(G.x+k,A.x))-G.x)/(k||1);Math.abs(ee-.5)<Ac&&(ee=.5),le=ee,oe={x:G.x+le*k,y:F==="bottom"?G.y+O:G.y}}return{side:F,snapPosition:oe,offset:le}},[s,K]),z=Do(D=>{var W,U,X;let A=S.current;if(!A)return;let B=c({x:D.clientX,y:D.clientY}),G=Q(B);y(G);let k=B,O=null,Y=null;if(G){let $=j(G,B);$&&(O=$.side,k=$.snapPosition,Y=$.offset,R.current=O);let te=l(e),ie={source:A==="source"?G:C.current,target:A==="target"?G:L.current,sourceHandle:A==="source"?O:(W=te==null?void 0:te.sourceHandle)!=null?W:null,targetHandle:A==="target"?O:(U=te==null?void 0:te.targetHandle)!=null?U:null},F=(X=f==null?void 0:f(ie))!=null?X:!0;I(F)}else R.current=null,I(!1);N(O),v(Y),p(k)},[Q,j,l,e,c,f]),M=Do(D=>{var O,Y,W,U,X;let A=S.current;if(!A)return;let B=c({x:D.clientX,y:D.clientY}),G=Q(B);if(G){let $=j(G,B),te=(O=$==null?void 0:$.side)!=null?O:null,ie=(Y=$==null?void 0:$.offset)!=null?Y:.5,F=l(e),oe={source:A==="source"?G:C.current,target:A==="target"?G:L.current,sourceHandle:A==="source"?te:(W=F==null?void 0:F.sourceHandle)!=null?W:null,targetHandle:A==="target"?te:(U=F==null?void 0:F.targetHandle)!=null?U:null};((X=f==null?void 0:f(oe))==null||X)&&i(le=>le.map(Z=>{var xe,me;return Z.id===e?w(_({},Z),{source:oe.source,target:oe.target,sourceHandle:oe.sourceHandle,targetHandle:oe.targetHandle,data:w(_({},Z.data),{points:void 0,sourceOffset:A==="source"?ie:(xe=Z.data)==null?void 0:xe.sourceOffset,targetOffset:A==="target"?ie:(me=Z.data)==null?void 0:me.targetOffset})}):Z}))}h(null),p(null),y(null),N(null),v(null),d(!1),I(!1),u(null),R.current=null,document.removeEventListener("mouseup",M),document.removeEventListener("mousemove",z);let k=Et.get(n);k==null||k.clearReconnectingEdge()},[e,Q,j,l,i,n,z,f,c,d,u]),V=Do((D,A)=>{if(r||A.button!==0)return;A.stopPropagation(),A.preventDefault(),i(G=>G.map(k=>k.id===e?w(_({},k),{data:w(_({},k.data),{points:void 0})}):k)),h(D),u(e);let B=Et.get(n);B==null||B.setReconnectingEdge(e),document.addEventListener("mousemove",z),document.addEventListener("mouseup",M)},[r,e,n,z,M,u,i]);return Fr(()=>()=>{if(S.current){document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",M),u(null);let D=Et.get(n);D==null||D.clearReconnectingEdge()}},[n,z,M,u]),{reconnectingHandle:m,cursorPosition:E,hoveredNodeId:g,reconnectingSide:x,reconnectingOffset:b,isValidReconnection:T,handleReconnectStart:V}};import{Fragment as kc,jsx as Ce,jsxs as Ft}from"react/jsx-runtime";var rt={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:Mc.ArrowClosed},markerEnd:{type:Mc.Arrow},data:{label:""}},{MOVE_THRESHOLD:Ur,MIN_SEGMENT_LENGTH:bh,PARALLEL_OFFSET:Lc,MAX_LABEL_DISTANCE:Th}=Wt;function vh(e,t,o,n,r){let i=r.find(d=>d.id===t),s=r.find(d=>d.id===o);if((i==null?void 0:i.type)==="GATEWAY"||(s==null?void 0:s.type)==="GATEWAY")return 0;let a=n.filter(d=>d.source===t&&d.target===o||d.source===o&&d.target===t);if(a.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)*Lc}let l=a.findIndex(d=>d.id===e),c=(a.length-1)/2;return(l-c)*Lc}var Rc=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:s,sourceHandleId:a,targetHandleId:l})=>{var $,te,ie,F,oe,le,Z,xe,me,_e;let{zoom:c}=xh(),{updateEdgeData:d}=yh(),u=Eh(),f=_h(),{isMultipleSelection:m,isReadOnly:h,mode:E,instanceId:p,edgeHighlight:g}=q(),[y,x]=Sc(!1),[N,b]=Sc(null),v=as(null),T=as(n==null?void 0:n.labelOffset),I=as(null),S=E!=="edit",{reconnectingHandle:P,cursorPosition:R,hoveredNodeId:C,reconnectingSide:L,isValidReconnection:K,handleReconnectStart:Q}=Xr({edgeId:e,source:t,target:o,instanceId:p,isReadOnly:S}),j=Pc(t),z=Pc(o),{sx:M,sy:V,tx:D,ty:A,sourcePos:B,targetPos:G}=ss(()=>{var pt,ft;let J=j&&z?wo(j,z):{sx:0,sy:0,tx:0,ty:0,sourcePos:Vo.Right,targetPos:Vo.Left},de=a?i:J.sourcePos,re=l?s:J.targetPos,ee=($e,he,fe)=>{var Be,mt,kt,Tt,vt,Ds;let{x:pe,y:ve}=$e.internals.positionAbsolute,Ke=(kt=(mt=(Be=$e.measured)==null?void 0:Be.width)!=null?mt:$e.width)!=null?kt:0,tt=(Ds=(vt=(Tt=$e.measured)==null?void 0:Tt.height)!=null?vt:$e.height)!=null?Ds:0;switch(he){case Vo.Top:return{x:pe+Ke*fe,y:ve};case Vo.Bottom:return{x:pe+Ke*fe,y:ve+tt};case Vo.Left:return{x:pe,y:ve+tt*fe};case Vo.Right:return{x:pe+Ke,y:ve+tt*fe};default:return{x:pe+Ke/2,y:ve+tt/2}}},ge=(pt=n==null?void 0:n.sourceOffset)!=null?pt:.5,be=(ft=n==null?void 0:n.targetOffset)!=null?ft:.5,Te=j?ee(j,de,ge).x:J.sx,ke=j?ee(j,de,ge).y:J.sy,et=z?ee(z,re,be).x:J.tx,bt=z?ee(z,re,be).y:J.ty;return P==="source"&&R?(Te=R.x,ke=R.y,L&&(de=L)):P==="target"&&R&&(et=R.x,bt=R.y,L&&(re=L)),{sx:Te,sy:ke,tx:et,ty:bt,sourcePos:de,targetPos:re}},[j,z,a,l,i,s,P,R,L,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);mh(()=>{var re;if(!I.current){I.current={sx:M,sy:V,tx:D,ty:A,sourcePos:B,targetPos:G};return}let J=I.current;if(Math.abs(M-J.sx)>Ur||Math.abs(V-J.sy)>Ur||Math.abs(D-J.tx)>Ur||Math.abs(A-J.ty)>Ur||J.sourcePos!==B||J.targetPos!==G){let ee={};(re=n==null?void 0:n.points)!=null&&re.length&&(ee.points=void 0),n!=null&&n.labelOffset&&(ee.labelOffset=void 0),Object.keys(ee).length>0&&d(e,_(_({},n),ee))}I.current={sx:M,sy:V,tx:D,ty:A,sourcePos:B,targetPos:G}},[M,V,D,A,B,G,n,e,d,P]);let k=ss(()=>{let J=vh(e,t,o,u,f);return Wr(M,V,D,A,B,G,n==null?void 0:n.points,J)},[M,V,D,A,B,G,n==null?void 0:n.points,u,f,e,t,o]),O=ss(()=>{if(k.length<2)return Hr({x:M,y:V},{x:D,y:A});let J=0;for(let ee=0;ee<k.length-1;ee++)J+=Ro(k[ee],k[ee+1]);let de=J/2,re=0;for(let ee=0;ee<k.length-1;ee++){let ge=Ro(k[ee],k[ee+1]);if(re+ge>=de){let be=(de-re)/ge,Te=k[ee],ke=k[ee+1];return{x:Te.x+(ke.x-Te.x)*be,y:Te.y+(ke.y-Te.y)*be}}re+=ge}return Hr({x:M,y:V},{x:D,y:A})},[k,M,V,D,A]),Y=Cc((J,de)=>{if(E!=="edit"||de.button!==0)return;de.stopPropagation(),de.preventDefault();let re=k[J],ee=k[J+1],ge=ye(re,ee,"y"),be=ge?re.y:re.x,Te=[...k],ke=Te.length,et=J,bt=J+1;b(J);let pt=$e=>{let he=be+(ge?$e.clientY-de.clientY:$e.clientX-de.clientX)/c;v.current=ge?{x:(re.x+ee.x)/2,y:he}:{x:he,y:(re.y+ee.y)/2};let fe=[];for(let pe=1;pe<ke-1;pe++){let ve=Te[pe];pe===et||pe===bt?ge?fe.push({x:ve.x,y:he}):fe.push({x:he,y:ve.y}):fe.push(_({},ve))}d(e,w(_({},n),{points:fe}))},ft=()=>{b(null),v.current=null,document.removeEventListener("mousemove",pt),document.removeEventListener("mouseup",ft)};document.addEventListener("mousemove",pt),document.addEventListener("mouseup",ft)},[E,k,c,n,e,d]),W=Cc(J=>{var pt,ft,$e,he,fe;if(y||S||J.button!==0||!((pt=n==null?void 0:n.label)!=null&&pt.trim()))return;J.stopPropagation(),J.preventDefault();let de=J.clientX,re=J.clientY,ee=($e=(ft=n==null?void 0:n.labelOffset)==null?void 0:ft.x)!=null?$e:0,ge=(fe=(he=n==null?void 0:n.labelOffset)==null?void 0:he.y)!=null?fe:0,be=[...k],Te={x:O.x,y:O.y},ke=!1,et=pe=>{let ve=(pe.clientX-de)/c,Ke=(pe.clientY-re)/c;if(!ke&&Math.abs(ve)<3&&Math.abs(Ke)<3)return;ke=!0;let tt={x:ee+ve,y:ge+Ke};T.current=tt,d(e,w(_({},n),{labelOffset:tt}))},bt=()=>{document.removeEventListener("mousemove",et),document.removeEventListener("mouseup",bt);let pe=T.current;if(!pe)return;let ve={x:Te.x+pe.x,y:Te.y+pe.y};Tc(ve,be)>Th&&(T.current=void 0,d(e,w(_({},n),{labelOffset:void 0})))};document.addEventListener("mousemove",et),document.addEventListener("mouseup",bt)},[y,S,c,n,e,d,k,O]);if(!j||!z)return null;let U=Ic(k),X=g&&(r||j.selected||z.selected);return Ft(kc,{children:[Ft("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":X}),onDoubleClick:()=>!S&&x(!0),children:[Ce("path",{d:U,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),className:H({"nopan nodrag":!y&&!S&&!!(($=n==null?void 0:n.label)!=null&&$.trim())}),style:{pointerEvents:"stroke",cursor:!y&&!S&&((te=n==null?void 0:n.label)!=null&&te.trim())?"move":"pointer"},onMouseDown:W}),Ft("g",{className:H("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!h,"text-blue-500 group-hover:text-blue-600":X}),children:[Ce(gh,{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)]":!h,"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||P&&C&&!K,"stroke-green-500":P&&C&&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&&!S&&Ce("g",{children:k.slice(0,-1).map((J,de)=>{let re=k[de+1];if(de===0||de===k.length-2||Ro(J,re)<bh)return null;let ee=ye(J,re,"y"),ge=N===de,be=ge&&v.current?v.current:Hr(J,re);return Ft("g",{children:[Ce("line",{x1:J.x,y1:J.y,x2:re.x,y2:re.y,stroke:"transparent",strokeWidth:20/c,className:H("cursor-pointer",{"cursor-ns-resize":ee,"cursor-ew-resize":!ee}),onMouseDown:Te=>Y(de,Te)}),Ce("circle",{cx:be.x,cy:be.y,r:4/c,fill:ge?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ce("circle",{cx:be.x,cy:be.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:ge?.6:.3,className:"pointer-events-none"})]},de)})})]})]}),Ft(hh,{children:[Ce("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&&Ce(Lo,{sx:M,sy:V,tx:D,ty:A,hasLabel:!!((ie=n==null?void 0:n.label)!=null&&ie.trim()),children:Ce(Po,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:j,targetNode:z})})}),(y||((F=n==null?void 0:n.label)==null?void 0:F.trim()))&&Ce("div",{className:H("absolute nodrag nopan",!y&&!S&&((oe=n==null?void 0:n.label)!=null&&oe.trim())?"z-[10001] pointer-events-auto":"z-[3000] pointer-events-none"),style:{transform:`translate(-50%, -50%) translate(${O.x+((Z=(le=n==null?void 0:n.labelOffset)==null?void 0:le.x)!=null?Z:0)}px, ${O.y+((me=(xe=n==null?void 0:n.labelOffset)==null?void 0:xe.y)!=null?me:0)}px)`,cursor:!y&&!S&&((_e=n==null?void 0:n.label)!=null&&_e.trim())?"move":void 0},onMouseDown:!y&&!S?W:void 0,onDoubleClick:J=>{S||(J.stopPropagation(),x(!0))},children:Ce(De,{value:n==null?void 0:n.label,className:H("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":y,"pointer-events-none":!y}),isEditing:y,onBlur:()=>x(!1),onChange:J=>d(e,{label:J.trim()})})}),r&&!m&&!S&&Ft(kc,{children:[Ce("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${k[0].x}px, ${k[0].y}px)`},children:Ft("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Ce("circle",{cx:6/c,cy:6/c,r:4/c,fill:P==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ce("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"}),Ce("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"&&C&&!K,"cursor-grabbing":P==="source"&&(!C||K)}),onMouseDown:J=>Q("source",J.nativeEvent)})]})}),Ce("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:Ft("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Ce("circle",{cx:6/c,cy:6/c,r:4/c,fill:P==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ce("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"}),Ce("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"&&C&&!K,"cursor-grabbing":P==="target"&&(!C||K)}),onMouseDown:J=>Q("target",J.nativeEvent)})]})})]})]})]})};import{Position as St}from"@xyflow/react";var Nh={right:St.Right,left:St.Left,top:St.Top,bottom:St.Bottom},$r=e=>{var t;return(t=Nh[e!=null?e:""])!=null?t:St.Right},ls=(e,t,o=.5)=>{var l,c,d,u;let{x:n,y:r}=e.internals.positionAbsolute,i=(c=(l=e.measured)==null?void 0:l.width)!=null?c:0,s=(u=(d=e.measured)==null?void 0:d.height)!=null?u:0;switch($r(t)){case St.Right:return{x:n+i,y:r+s*o};case St.Left:return{x:n,y:r+s*o};case St.Top:return{x:n+i*o,y:r};case St.Bottom:return{x:n+i*o,y:r+s};default:return{x:n+i/2,y:r+s/2}}},Dc=(e,t,o)=>{var d,u;let{position:{x:n,y:r},measured:i}=e,s=(d=i.width)!=null?d:0,a=(u=i.height)!=null?u:0;return[{id:"left",x:n,y:r+a/2},{id:"right",x:n+s,y:r+a/2},{id:"top",x:n+s/2,y:r},{id:"bottom",x:n+s/2,y:r+a}].reduce((f,m)=>{let h=Math.hypot(t-f.x,o-f.y);return Math.hypot(t-m.x,o-m.y)<h?m:f}).id};import{useDebouncedCallback as E0}from"use-debounce";import{useReactFlow as x0}from"@xyflow/react";import{useCallback as Qd}from"react";var Tn=(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))(Tn||{});var vn=1,Oc=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 wc("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:wc("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})})};import{Position as wI}from"@xyflow/react";var ye=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,Do=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),Br=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),ch=(e,t,o)=>{let n=o.x-t.x,r=o.y-t.y,i=n*n+r*r;if(i===0)return Do(e,t);let a=Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*r)/i));return Do(e,{x:t.x+a*n,y:t.y+a*r})},Ac=(e,t)=>{let o=1/0;for(let n=0;n<t.length-1;n++)o=Math.min(o,ch(e,t[n],t[n+1]));return o};import{Position as zr}from"@xyflow/react";var Ft={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15,MAX_LABEL_DISTANCE:80};var{TOLERANCE:ce}=Ft;function dh(e,t,o){return ye(e,t,"x",ce)&&ye(t,o,"x",ce)&&ye(e,o,"x",ce)}function uh(e,t,o){return ye(e,t,"y",ce)&&ye(t,o,"y",ce)&&ye(e,o,"y",ce)}function ph(e,t,o){if(!dh(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 fh(e,t,o){if(!uh(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 mh(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 Ic(e){if(e.length<=2)return e;let t=[e[0]];for(let o=1;o<e.length-1;o++){let n=t[t.length-1],r=e[o],i=e[o+1];ye(n,r,"x",ce)&&ye(r,i,"x",ce)||ye(n,r,"y",ce)&&ye(r,i,"y",ce)||t.push(r)}return t.push(e[e.length-1]),t}function Yr(e){let t=[];for(let o of e){let n=t[t.length-1];(!n||Math.abs(n.x-o.x)>=ce||Math.abs(n.y-o.y)>=ce)&&t.push(o)}return t}function gh(e){let t=[...e],o=!0;for(;o;){o=!1;for(let n=1;n<t.length-1;n++){let r=t[n-1],i=t[n],a=t[n+1];if(ph(r,i,a)||fh(r,i,a)){t.splice(n,1),o=!0;break}}}return t}function Cc(e){let t=Yr(Ic([...e]));return t=gh(t),Yr(Ic(t))}function Fr(e){switch(e){case zr.Left:return{x:-1,y:0};case zr.Right:return{x:1,y:0};case zr.Top:return{x:0,y:-1};case zr.Bottom:return{x:0,y:1};default:return{x:0,y:0}}}function Sc(e,t,o,n){let r=Ft.OFFSET,i=Ft.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*Ft.OFFSET&&(r=a/2,i=a/2)}else{let a=(o.y-e.y)*t.y;a>0&&a<2*Ft.OFFSET&&(r=a/2,i=a/2)}return{sourceOffset:r,targetOffset:i}}function hh(e,t,o,n,r,i,a=0){let s=Fr(r),l=Fr(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}=Sc(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=mh(g,s,h,l),N=[m,g,...x,h,y],b=Cc(N);if(b.length===2&&Wr(m,y)>ce){let T=ye(m,g,"x",ce)&&ye(g,h,"x",ce)&&ye(h,y,"x",ce),v=ye(m,g,"y",ce)&&ye(g,h,"y",ce)&&ye(h,y,"y",ce);if(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 Yr([m,g,h,y])}}return b}function Xr(e,t,o,n,r,i,a,s=0){if(!(a!=null&&a.length))return hh(e,t,o,n,r,i,s);let l=Fr(r),c=Fr(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}=Sc(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=Cc(P);if(R.length===2&&Wr(y,E)>ce){let S=ye(y,h,"x",ce)&&ye(h,x,"x",ce)&&ye(x,E,"x",ce),L=ye(y,h,"y",ce)&&ye(h,x,"y",ce)&&ye(x,E,"y",ce);if(S||L){let K=L&&(x.x-h.x)*l.x<0,j=S&&(x.y-h.y)*l.y<0;if(!K&&!j)return Yr([y,h,x,E])}}return R}var Wr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function yh(e,t,o){return ye(e,t,"x",ce)&&ye(t,o,"x",ce)||ye(e,t,"y",ce)&&ye(t,o,"y",ce)}function xh(e,t,o,n){if(yh(e,t,o))return`L${t.x} ${t.y}`;let r=Wr(e,t),i=Wr(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 Mc=(e,t=5)=>e.length<2?"":e.reduce((o,n,r)=>{let i="";return r>0&&r<e.length-1?i=xh(e[r-1],n,e[r+1],t):i=`${r===0?"M":"L"}${n.x} ${n.y}`,o+=i,o},"");import{useCallback as Oo,useEffect as Ur,useRef as Tn,useState as Vo}from"react";import{useReactFlow as Eh,useStore as _h}from"@xyflow/react";var bh=50,Pc=.1,Th=.6,$r=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:a,getNodes:s,getEdge:l,screenToFlowPosition:c}=Eh(),{setIsDragging:d,setReconnectingEdgeId:u}=q(),f=_h(D=>D.isValidConnection),[m,y]=Vo(null),[E,p]=Vo(null),[g,h]=Vo(null),[x,N]=Vo(null),[b,T]=Vo(null),[v,A]=Vo(!1),C=Tn(null),P=Tn(null),R=Tn(null),S=Tn(t),L=Tn(o);Ur(()=>{S.current=t,L.current=o},[t,o]),Ur(()=>{C.current=m},[m]),Ur(()=>{P.current=b},[b]);let K=Oo(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=Oo(D=>{var O,Y,F,U,X,$;let I=s(),B=null,G=bh,k=I.filter(te=>te.type!=="LANE"&&te.type!=="ANNOTATION");for(let te of k){if(te.id===e)continue;let ie=K(te.id),W=(F=(Y=(O=te.measured)==null?void 0:O.width)!=null?Y:te.width)!=null?F:0,oe=($=(X=(U=te.measured)==null?void 0:U.height)!=null?X:te.height)!=null?$:0;if(D.x>=ie.x&&D.x<=ie.x+W&&D.y>=ie.y&&D.y<=ie.y+oe)return te.id;let Z=Math.max(ie.x-D.x,0,D.x-(ie.x+W)),xe=Math.max(ie.y-D.y,0,D.y-(ie.y+oe)),me=Math.sqrt(Z*Z+xe*xe);me<G&&(G=me,B=te.id)}return B},[s,K,e]),Q=Oo((D,I)=>{var Z,xe,me,_e,J,de;let B=a(D);if(!B)return null;let G=K(D),k=(me=(xe=(Z=B.measured)==null?void 0:Z.width)!=null?xe:B.width)!=null?me:0,O=(de=(J=(_e=B.measured)==null?void 0:_e.height)!=null?J:B.height)!=null?de:0,Y=Math.abs(G.x+k-I.x),F=Math.abs(I.x-G.x),U=Math.abs(G.y+O-I.y),X=Math.abs(I.y-G.y),$={right:Y,left:F,bottom:U,top:X},te=Object.entries($).reduce((re,[ee,ge])=>ge<re[1]?[ee,ge]:re,["right",$.right])[0],ie=R.current;if(ie&&ie!==te){let re=$[te],ee=$[ie],ge=Math.abs(ee-re),be=Math.min(Math.abs(ee),Math.abs(re));ge<be*Th&&(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)<Pc&&(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)<Pc&&(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=Oo(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=Oo(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 xe,me;return Z.id===e?w(_({},Z),{source:oe.source,target:oe.target,sourceHandle:oe.sourceHandle,targetHandle:oe.targetHandle,data:w(_({},Z.data),{points:void 0,sourceOffset:I==="source"?ie:(xe=Z.data)==null?void 0:xe.sourceOffset,targetOffset:I==="target"?ie:(me=Z.data)==null?void 0:me.targetOffset})}):Z}))}y(null),p(null),h(null),N(null),T(null),d(!1),A(!1),u(null),R.current=null,document.removeEventListener("mouseup",M),document.removeEventListener("mousemove",z);let k=Et.get(n);k==null||k.clearReconnectingEdge()},[e,j,Q,l,i,n,z,f,c,d,u]),V=Oo((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=Et.get(n);B==null||B.setReconnectingEdge(e),document.addEventListener("mousemove",z),document.addEventListener("mouseup",M)},[r,e,n,z,M,u,i]);return Ur(()=>()=>{if(C.current){document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",M),u(null);let D=Et.get(n);D==null||D.clearReconnectingEdge()}},[n,z,M,u]),{reconnectingHandle:m,cursorPosition:E,hoveredNodeId:g,reconnectingSide:x,reconnectingOffset:b,isValidReconnection:v,handleReconnectStart:V}};import{Fragment as Vc,jsx as Me,jsxs as Wt}from"react/jsx-runtime";var rt={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:Rc.ArrowClosed},markerEnd:{type:Rc.Arrow},data:{label:""}},{MOVE_THRESHOLD:Kr,MIN_SEGMENT_LENGTH:Mh,PARALLEL_OFFSET:Oc,MAX_LABEL_DISTANCE:Ph}=Ft;function Lh(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)*Oc}let l=s.findIndex(d=>d.id===e),c=(s.length-1)/2;return(l-c)*Oc}var Hc=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var $,te,ie,W,oe,le,Z,xe,me,_e;let{zoom:c}=Ih(),{updateEdgeData:d}=Ah(),u=Ch(),f=Sh(),{isMultipleSelection:m,isReadOnly:y,mode:E,instanceId:p,edgeHighlight:g}=q(),[h,x]=Lc(!1),[N,b]=Lc(null),T=ds(null),v=ds(n==null?void 0:n.labelOffset),A=ds(null),C=E!=="edit",{reconnectingHandle:P,cursorPosition:R,hoveredNodeId:S,reconnectingSide:L,isValidReconnection:K,handleReconnectStart:j}=$r({edgeId:e,source:t,target:o,instanceId:p,isReadOnly:C}),Q=Dc(t),z=Dc(o),{sx:M,sy:V,tx:D,ty:I,sourcePos:B,targetPos:G}=cs(()=>{var pt,ft;let J=Q&&z?Ao(Q,z):{sx:0,sy:0,tx:0,ty:0,sourcePos:Ho.Right,targetPos:Ho.Left},de=s?i:J.sourcePos,re=l?a:J.targetPos,ee=($e,he,fe)=>{var Be,mt,kt,Tt,vt,Gs;let{x:pe,y:ve}=$e.internals.positionAbsolute,Ke=(kt=(mt=(Be=$e.measured)==null?void 0:Be.width)!=null?mt:$e.width)!=null?kt:0,tt=(Gs=(vt=(Tt=$e.measured)==null?void 0:Tt.height)!=null?vt:$e.height)!=null?Gs:0;switch(he){case Ho.Top:return{x:pe+Ke*fe,y:ve};case Ho.Bottom:return{x:pe+Ke*fe,y:ve+tt};case Ho.Left:return{x:pe,y:ve+tt*fe};case Ho.Right:return{x:pe+Ke,y:ve+tt*fe};default:return{x:pe+Ke/2,y:ve+tt/2}}},ge=(pt=n==null?void 0:n.sourceOffset)!=null?pt:.5,be=(ft=n==null?void 0:n.targetOffset)!=null?ft:.5,Te=Q?ee(Q,de,ge).x:J.sx,ke=Q?ee(Q,de,ge).y:J.sy,et=z?ee(z,re,be).x:J.tx,bt=z?ee(z,re,be).y:J.ty;return P==="source"&&R?(Te=R.x,ke=R.y,L&&(de=L)):P==="target"&&R&&(et=R.x,bt=R.y,L&&(re=L)),{sx:Te,sy:ke,tx:et,ty:bt,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]);vh(()=>{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)>Kr||Math.abs(V-J.sy)>Kr||Math.abs(D-J.tx)>Kr||Math.abs(I-J.ty)>Kr||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=cs(()=>{let J=Lh(e,t,o,u,f);return Xr(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=cs(()=>{if(k.length<2)return Br({x:M,y:V},{x:D,y:I});let J=0;for(let ee=0;ee<k.length-1;ee++)J+=Do(k[ee],k[ee+1]);let de=J/2,re=0;for(let ee=0;ee<k.length-1;ee++){let ge=Do(k[ee],k[ee+1]);if(re+ge>=de){let be=(de-re)/ge,Te=k[ee],ke=k[ee+1];return{x:Te.x+(ke.x-Te.x)*be,y:Te.y+(ke.y-Te.y)*be}}re+=ge}return Br({x:M,y:V},{x:D,y:I})},[k,M,V,D,I]),Y=kc((J,de)=>{if(E!=="edit"||de.button!==0)return;de.stopPropagation(),de.preventDefault();let re=k[J],ee=k[J+1],ge=ye(re,ee,"y"),be=ge?re.y:re.x,Te=[...k],ke=Te.length,et=J,bt=J+1;b(J);let pt=$e=>{let he=be+(ge?$e.clientY-de.clientY:$e.clientX-de.clientX)/c;T.current=ge?{x:(re.x+ee.x)/2,y:he}:{x:he,y:(re.y+ee.y)/2};let fe=[];for(let pe=1;pe<ke-1;pe++){let ve=Te[pe];pe===et||pe===bt?ge?fe.push({x:ve.x,y:he}):fe.push({x:he,y:ve.y}):fe.push(_({},ve))}d(e,w(_({},n),{points:fe}))},ft=()=>{b(null),T.current=null,document.removeEventListener("mousemove",pt),document.removeEventListener("mouseup",ft)};document.addEventListener("mousemove",pt),document.addEventListener("mouseup",ft)},[E,k,c,n,e,d]),F=kc(J=>{var pt,ft,$e,he,fe;if(h||C||J.button!==0||!((pt=n==null?void 0:n.label)!=null&&pt.trim()))return;J.stopPropagation(),J.preventDefault();let de=J.clientX,re=J.clientY,ee=($e=(ft=n==null?void 0:n.labelOffset)==null?void 0:ft.x)!=null?$e:0,ge=(fe=(he=n==null?void 0:n.labelOffset)==null?void 0:he.y)!=null?fe:0,be=[...k],Te={x:O.x,y:O.y},ke=!1,et=pe=>{let ve=(pe.clientX-de)/c,Ke=(pe.clientY-re)/c;if(!ke&&Math.abs(ve)<3&&Math.abs(Ke)<3)return;ke=!0;let tt={x:ee+ve,y:ge+Ke};v.current=tt,d(e,w(_({},n),{labelOffset:tt}))},bt=()=>{document.removeEventListener("mousemove",et),document.removeEventListener("mouseup",bt);let pe=v.current;if(!pe)return;let ve={x:Te.x+pe.x,y:Te.y+pe.y};Ac(ve,be)>Ph&&(v.current=void 0,d(e,w(_({},n),{labelOffset:void 0})))};document.addEventListener("mousemove",et),document.addEventListener("mouseup",bt)},[h,C,c,n,e,d,k,O]);if(!Q||!z)return null;let U=Mc(k),X=g&&(r||Q.selected||z.selected);return Wt(Vc,{children:[Wt("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":X}),onDoubleClick:()=>!C&&x(!0),children:[Me("path",{d:U,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),className:H({"nopan nodrag":!h&&!C&&!!(($=n==null?void 0:n.label)!=null&&$.trim())}),style:{pointerEvents:"stroke",cursor:!h&&!C&&((te=n==null?void 0:n.label)!=null&&te.trim())?"move":"pointer"},onMouseDown:F}),Wt("g",{className:H("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!y,"text-blue-500 group-hover:text-blue-600":X}),children:[Me(Nh,{id:e,path:U,interactionWidth:0,markerEnd:`url(#${X?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75",{"group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]":!y,"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||P&&S&&!K,"stroke-green-500":P&&S&&K,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":X&&!(n!=null&&n.hasError)&&!P})}),r&&!m&&!C&&Me("g",{children:k.slice(0,-1).map((J,de)=>{let re=k[de+1];if(de===0||de===k.length-2||Do(J,re)<Mh)return null;let ee=ye(J,re,"y"),ge=N===de,be=ge&&T.current?T.current:Br(J,re);return Wt("g",{children:[Me("line",{x1:J.x,y1:J.y,x2:re.x,y2:re.y,stroke:"transparent",strokeWidth:20/c,className:H("cursor-pointer",{"cursor-ns-resize":ee,"cursor-ew-resize":!ee}),onMouseDown:Te=>Y(de,Te)}),Me("circle",{cx:be.x,cy:be.y,r:4/c,fill:ge?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Me("circle",{cx:be.x,cy:be.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:ge?.6:.3,className:"pointer-events-none"})]},de)})})]})]}),Wt(wh,{children:[Me("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${O.x}px, ${O.y}px)`},children:r&&!m&&Me(ko,{sx:M,sy:V,tx:D,ty:I,hasLabel:!!((ie=n==null?void 0:n.label)!=null&&ie.trim()),children:Me(Lo,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:Q,targetNode:z})})}),(h||((W=n==null?void 0:n.label)==null?void 0:W.trim()))&&Me("div",{className:H("absolute nodrag nopan",!h&&!C&&((oe=n==null?void 0:n.label)!=null&&oe.trim())?"z-[10001] pointer-events-auto":"z-[3000] pointer-events-none"),style:{transform:`translate(-50%, -50%) translate(${O.x+((Z=(le=n==null?void 0:n.labelOffset)==null?void 0:le.x)!=null?Z:0)}px, ${O.y+((me=(xe=n==null?void 0:n.labelOffset)==null?void 0:xe.y)!=null?me:0)}px)`,cursor:!h&&!C&&((_e=n==null?void 0:n.label)!=null&&_e.trim())?"move":void 0},onMouseDown:!h&&!C?F:void 0,onDoubleClick:J=>{C||(J.stopPropagation(),x(!0))},children:Me(De,{value:n==null?void 0:n.label,className:H("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":h,"pointer-events-none":!h}),isEditing:h,onBlur:()=>x(!1),onChange:J=>d(e,{label:J.trim()})})}),r&&!m&&!C&&Wt(Vc,{children:[Me("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${k[0].x}px, ${k[0].y}px)`},children:Wt("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Me("circle",{cx:6/c,cy:6/c,r:4/c,fill:P==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Me("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:P==="source"?.6:.3,className:"pointer-events-none"}),Me("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!P||P!=="source","cursor-not-allowed":P==="source"&&S&&!K,"cursor-grabbing":P==="source"&&(!S||K)}),onMouseDown:J=>j("source",J.nativeEvent)})]})}),Me("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${k[k.length-1].x}px, ${k[k.length-1].y}px)`},children:Wt("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Me("circle",{cx:6/c,cy:6/c,r:4/c,fill:P==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Me("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:P==="target"?.6:.3,className:"pointer-events-none"}),Me("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!P||P!=="target","cursor-not-allowed":P==="target"&&S&&!K,"cursor-grabbing":P==="target"&&(!S||K)}),onMouseDown:J=>j("target",J.nativeEvent)})]})})]})]})]})};import{Position as Ct}from"@xyflow/react";var kh={right:Ct.Right,left:Ct.Left,top:Ct.Top,bottom:Ct.Bottom},qr=e=>{var t;return(t=kh[e!=null?e:""])!=null?t:Ct.Right},us=(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(qr(t)){case Ct.Right:return{x:n+i,y:r+a*o};case Ct.Left:return{x:n,y:r+a*o};case Ct.Top:return{x:n+i*o,y:r};case Ct.Bottom:return{x:n+i*o,y:r+a};default:return{x:n+i/2,y:r+a/2}}},Gc=(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};import{useDebouncedCallback as C0}from"use-debounce";import{useReactFlow as I0}from"@xyflow/react";import{useCallback as ou}from"react";var vn=(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))(vn||{});var Nn=1,Bc=e=>`<mxGraphModel>
|
|
6
6
|
<root version="1.1">
|
|
7
7
|
<mxCell id="0" />
|
|
8
8
|
<mxCell id="1" parent="0" />
|
|
@@ -35,12 +35,12 @@ var hp=Object.defineProperty,yp=Object.defineProperties;var xp=Object.getOwnProp
|
|
|
35
35
|
<mxGeometry as="geometry" relative="1" />
|
|
36
36
|
</mxCell>
|
|
37
37
|
</root>
|
|
38
|
-
</mxGraphModel>`,
|
|
39
|
-
`),E=h.length;l=h.reduce((g,y)=>Math.max(g,y.length),0)*7+r,c=E*20+i}let d=Math.max(Rt(Number(s),t),l),u=Math.max(Rt(Number(a),o),c);return{width:d,height:u,measured:{width:d,height:u}}},Go=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,parent:r,value:i}=t,s={x:Number(o._attributes.x||0),y:Number(o._attributes.y||0)},a={id:n,position:s,data:{label:i||""}},l=r==="1"?void 0:r;return l&&(a.parentId=l),a},Ch=e=>{let{mxGeometry:t}=e,o=Go(e),n=Ho(t,ue.START_EVENT.MIN_WIDTH,ue.START_EVENT.MIN_HEIGHT);return w(_(_({},o),n),{type:"START_EVENT"})},Mh=e=>{let{mxGeometry:t}=e,o=Go(e),n=Ho(t,ue.END_EVENT.MIN_WIDTH,ue.END_EVENT.MIN_HEIGHT);return w(_(_({},o),n),{type:"END_EVENT"})},qr=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=Go(e),a=Ho(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=Bc[d];u&&(r.data.attribute=u)}let c=zc[o.style];return c&&(r.data.variant=c),w(_(_({},r),a),{type:"TASK"})},cs=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=Go(e),i=Ho(o,ue.GATEWAY.MIN_WIDTH,ue.GATEWAY.MIN_HEIGHT);return r.data.variant=Yc[n],w(_(_({},r),i),{type:"GATEWAY"})},Ph=e=>{let{mxGeometry:t}=e,o=Go(e),i=Ho(t,ue.ANNOTATION.MIN_WIDTH,ue.ANNOTATION.MIN_HEIGHT,o.data.label,32,24);return w(_(_({},o),i),{type:"ANNOTATION"})},Lh=e=>{let{mxGeometry:t}=e,o=Go(e),n=Ho(t,ue.LANE.MIN_WIDTH,ue.LANE.MIN_HEIGHT);return w(_(_({},o),n),{type:"LANE"})},Xc={task:qr,"task-script":qr,"subprocess-collapsed":qr,"service-task":qr,"start-event":Ch,"end-event-terminate":Mh,"gateway-parallel":cs,"gateway-exclusive":cs,"gateway-complex":cs,annotation:Ph,lane:Lh},kh=e=>{if(e&&Array.isArray(e))return e.map(t=>({x:Number(t._attributes.x),y:Number(t._attributes.y)}))},Uc=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,source:r,target:i,value:s,style:a,sourceHandle:l,targetHandle:c,sourceOffset:d,targetOffset:u,labelOffsetX:f,labelOffsetY:m}=t,h=kh(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,y=m!==void 0?Number(m):void 0,x=w(_(_({id:n,source:r,target:i},l?{sourceHandle:l}:{}),c?{targetHandle:c}:{}),{data:_(_(_(_({label:s||""},h&&h.length>0?{points:h}:{}),E!==void 0?{sourceOffset:E}:{}),p!==void 0?{targetOffset:p}:{}),g!==void 0&&y!==void 0?{labelOffset:{x:g,y}}:{})});return a.includes("association")&&a.includes('endArrow=""')?_(_({},ko),x):_(_({},rt),x)},$c=(e,t)=>{var m,h;let{id:o,type:n,source:r,target:i,sourceHandle:s,targetHandle:a,data:l}=e,c=t==null?void 0:t.find(E=>E.id===r),d="";n==="ANNOTATION_EDGE"&&(d='association;endArrow=""');let u={_attributes:{as:"geometry",relative:"1"}};return l!=null&&l.points&&Array.isArray(l.points)&&l.points.length>0&&(u.Array=l.points.map(E=>({_attributes:{as:"mxPoint",x:E.x,y:E.y}}))),{_attributes:{id:o,parent:(c==null?void 0:c.parentId)||"1",edge:"1",style:d,source:r,target:i,value:(l==null?void 0:l.label)||"",sourceHandle:s!=null?s:void 0,targetHandle:a!=null?a:void 0,sourceOffset:(l==null?void 0:l.sourceOffset)!==void 0?String(l.sourceOffset):void 0,targetOffset:(l==null?void 0:l.targetOffset)!==void 0?String(l.targetOffset):void 0,labelOffsetX:((m=l==null?void 0:l.labelOffset)==null?void 0:m.x)!==void 0?String(l.labelOffset.x):void 0,labelOffsetY:((h=l==null?void 0:l.labelOffset)==null?void 0:h.y)!==void 0?String(l.labelOffset.y):void 0},mxGeometry:u}},Bo=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}}}},Rh=e=>{let{variant:t}=e.data,o=Bo(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:Wc[t]||"task"})})},Dh=e=>{let t=Bo(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"start-event"})})},Oh=e=>{let t=Bo(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"end-event-terminate"})})},Vh=e=>{let{variant:t}=e.data,o=Bo(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:Fc[t]})})},Hh=e=>{let t=Bo(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"lane"})})},Gh=e=>{let t=Bo(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"annotation"})})},Kc={TASK:Rh,START_EVENT:Dh,END_EVENT:Oh,GATEWAY:Vh,ANNOTATION:Gh,LANE:Hh},qc=(e,t)=>{var s,a;let r=((s=e.measured)==null?void 0:s.width)||0,i=((a=e.measured)==null?void 0:a.height)||0;return{_attributes:{id:`${t+1}`,parent:e.id,style:"attribute-loop",connectable:"0"},mxGeometry:{_attributes:{as:"geometry",x:r/2-22/2,y:i-22,width:22,height:22}}}};var Bh=e=>{let t=Object.values(Tn),o=e.filter(i=>{var a;let s=(a=i._attributes)==null?void 0:a.style;return t.includes(s)}),n=e.filter(i=>{var a;let s=(a=i._attributes)==null?void 0:a.style;return["attribute-loop"].includes(s)}),r=[];for(let i of o){let{style:s}=i._attributes,a=Xc[s],l=a==null?void 0:a(i,n);if(!l){console.warn(`Node ${s} not supported`);continue}r.push(l)}return r},zh=(e,t)=>{let o=e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}),n=[];for(let r of o){let i=Uc(r),s=t.find(c=>c.id===i.source),a=t.find(c=>c.id===i.target);((s==null?void 0:s.type)==="LANE"||(a==null?void 0:a.type)==="LANE")&&i.type!=="ANNOTATION_EDGE"||n.push(i)}return n},Yh=(e,t)=>{let o=[];return e.forEach(n=>{var s,a;let r=(a=(s=Kc)[n.type])==null?void 0:a.call(s,n);if(!r){console.warn(`Node ${n.type} not supported`);return}if(o.push(r),n.type==="TASK"&&n.data.attribute==="LOOP"){let l=qc(n,t);o.push(l)}}),o},Wh=(e,t)=>{let o=[];return e.forEach(n=>{let r=$c(n,t);o.push(r)}),o},Fh=(e=[],t=[],o)=>{let n=Yh(e,o),r=Wh(t,e);return{mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}}},Zc=(e=[],t=[],o)=>{let n=Fh(e,t,o);return Gc(JSON.stringify(n),{compact:!0,spaces:0})},Jc=async e=>{var s,a,l,c,d;let t=await Kr(e),o=((a=(s=t==null?void 0:t.mxGraphModel)==null?void 0:s.root)==null?void 0:a.mxCell)||[],n=Number(((d=(c=(l=t==null?void 0:t.mxGraphModel)==null?void 0:l.root)==null?void 0:c._attributes)==null?void 0:d.lastId)||vn),r=Bh(o),i=zh(o,r);return{lastElementId:n,edges:i,nodes:r}};import{useReactFlow as m0,useStoreApi as g0}from"@xyflow/react";import{useCallback as h0}from"react";import{Position as Ut,useConnection as Ly,useReactFlow as ky}from"@xyflow/react";import{useCallback as gs}from"react";import{Handle as Qc,useReactFlow as Xh}from"@xyflow/react";import{jsx as jc}from"react/jsx-runtime";var ne=i=>{var s=i,{type:e,position:t,className:o,nodeType:n}=s,r=gt(s,["type","position","className","nodeType"]);let a=n==="TASK";return jc(Qc,_({type:e,position:t,className:H("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":a,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":!a},o)},r))},Ge=a=>{var l=a,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,s=gt(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=Xh(),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 h=d();return m.filter(p=>{if(p.source!==e)return!1;let g=h.find(y=>y.id===p.target);return(g==null?void 0:g.type)!=="ANNOTATION"}).length>=1}return!1})();return jc(Qc,_({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"}},s))};import{useRef as rd}from"react";import{NodeResizeControl as id,ResizeControlVariant as Qh,useReactFlow as jh,useStoreApi as ey}from"@xyflow/react";import{useStoreApi as Uh}from"@xyflow/react";var Zr=()=>{let e=Uh();return{getInternalNodes:()=>{let{nodeLookup:o}=e.getState();return Array.from(o.values())}}};import ed from"@dagrejs/dagre";import{getNodesBounds as Jr}from"@xyflow/react";var od=(e=[],t=[],o="LR")=>{let n=new ed.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:i,width:s,height:a})=>n.setNode(i,{width:s,height:a})),t.forEach(i=>n.setEdge(i.source,i.target)),ed.layout(n),{nodes:e.map(i=>{let s=n.node(i.id);return w(_({},i),{position:{x:s.x-i.width/2,y:s.y-i.height/2}})}),edges:t}},Xt=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId);if(t.length===0)return e;let o=na(e);for(let n of t){let r=[...o.values()],i=r.filter(a=>a.parentId===n.id);if(i.length===0)continue;let s=i.filter(a=>a.type==="LANE");if(s.length>0){ca(s,o,r),da(n,o);continue}Hi(n,i,o)}return ra(e,o)};var nd=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)};var $h=500;var Kh=e=>e.type==="LANE"&&!e.parentId,qh=(e,t)=>{let o=e.x+e.width,n=e.y+e.height,r=t.x+t.width,i=t.y+t.height;return e.x<=t.x&&e.y<=t.y&&o>=r&&n>=i},Zh=(e,t)=>{let o=e.x+e.width,n=e.y+e.height,r=t.x+t.width,i=t.y+t.height,s=Math.max(e.x-r,t.x-o,0),a=Math.max(e.y-i,t.y-n,0);return Math.hypot(s,a)},Jh=e=>{let t=new Set;for(let o of e)t.add(o.source),t.add(o.target);return t},td=(e,t,o)=>{if(e.type!=="ANNOTATION"||o.has(e.id))return!1;let n=Jr([e]);return Zh(t,n)>$h},ds=(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 y of g)r.has(y)||i.push(y)}let s=e.filter(p=>r.has(p.id));if(s.length===0)return e;let a=Jh(t),l=s.filter(p=>p.type!=="ANNOTATION"),c=Jr(l.length>0?l:s),d=s.filter(p=>!td(p,c,a)),u=Jr(d),h=e.filter(p=>!r.has(p.id)).filter(p=>{let g=Jr([p]);return!qh(u,g)}).filter(p=>!td(p,u,a));return[...d,...h]};import{Fragment as ny,jsxs as ry}from"react/jsx-runtime";import{createElement as sd}from"react";var ty=["top","right","bottom","left"],oy=["top-left","top-middle","top-right","right-middle","bottom-left","left-middle","bottom-right","bottom-middle"],it=r=>{var i=r,{nodeId:e,isVisible:t,offset:o=8}=i,n=gt(i,["nodeId","isVisible","offset"]);let{getInternalNode:s,setNodes:a}=jh(),{getInternalNodes:l}=Zr(),{isMultipleSelection:c}=q(),d=ey(),u=rd(0),f=rd([]),m=({y:g,width:y,height:x})=>{cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{var Q,j;if(!e)return;let{nodeLookup:N,onNodesChange:b}=d.getState(),v=N.get(e);if(!v||v.type!=="LANE")return;let T=!v.parentId,I=T?v.id:v.parentId;if(!I)return;let S=Array.from(N.values()).filter(z=>z.type==="LANE"&&z.parentId===I);if(!S.length)return;f.current.length===0&&(f.current=oo(S).map(z=>z.id));let P=f.current.map(z=>S.find(M=>M.id===z)).filter(Boolean),R=[],C=0,L=P.findIndex(z=>z.id===v.id),K=!T&&L>0&&Math.abs(g-v.position.y)>.5;for(let z=0;z<P.length;z++){let M=P[z],V=M.id===v.id,D=z===P.length-1;if(V){C=K?g+x:C+x;continue}let A=(j=(Q=M.measured)==null?void 0:Q.height)!=null?j:0,B=T?y-se.HEADER_WIDTH:y,G=A;T&&D&&(G=Math.max(se.MIN_HEIGHT,x-C)),K&&z===L-1&&(G=Math.max(se.MIN_HEIGHT,g-C)),R.push({id:M.id,type:"dimensions",dimensions:{width:B,height:G},setAttributes:!0}),R.push({id:M.id,type:"position",position:{x:se.HEADER_WIDTH,y:C}}),C+=G}T?R.push({id:I,type:"dimensions",dimensions:{width:y,height:x},setAttributes:!0}):R.push({id:I,type:"dimensions",dimensions:{width:y+se.HEADER_WIDTH,height:C},setAttributes:!0}),b==null||b(R)})},h=({y:g,width:y,height:x})=>{var v;if(cancelAnimationFrame(u.current),f.current=[],!e)return;let N=s(e);if(!N||N.type!=="LANE"&&!N.parentId)return;let b=[...l()];if(N.type!=="LANE"){b=b.map(T=>T.id===e?w(_({},T),{width:y,height:x,measured:{width:y,height:x}}):T),b=Xt(b),a(b);return}b=ua(N,y,x,b,g),b=Xt(b),b=to((v=N.parentId)!=null?v:N.id,b),a(b)};if(!(!c&&t))return null;let p={"--resize-offset":`${o}px`};return ry(ny,{children:[ty.map(g=>sd(id,w(_({},n),{key:g,nodeId:e,position:g,variant:Qh.Line,className:"border-blue-400/90 border-dashed",style:p,onResize:(y,x)=>m(x),onResizeEnd:(y,x)=>h(x)}))),oy.map(g=>sd(id,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:(y,x)=>m(x),onResizeEnd:(y,x)=>h(x)})))]})};import{NodeToolbar as Ty,useReactFlow as vy}from"@xyflow/react";import{Button as Ny,Tooltip as wy,TooltipContent as Iy,TooltipTrigger as Ay,useTranslation as Sy}from"@produto-lecom/lecom-ui";import{useCallback as ms,useEffect as Cy,useRef as Qr,useState as My}from"react";import{create as iy}from"zustand";var zo=iy(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{useEffect as sy,useState as ay}from"react";var ad=(e,t=!1)=>{let[o,n]=ay({width:0,height:0});return sy(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};import{Position as Nn,useReactFlow as ly}from"@xyflow/react";import{useMemo as cy}from"react";var dy=120,uy=12,ld=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=ly(),{instanceId:i}=q();return cy(()=>{var m,h;if(!t)return{position:Nn.Right,align:"start"};let s=n(e);if(!s)return{position:Nn.Right,align:"start"};let a=r(),l=s.position.x*a.zoom+a.x,c=(((m=s.measured)==null?void 0:m.width)||s.width||100)*a.zoom,d=(h=document.getElementById(`modeler-${i}`))==null?void 0:h.clientWidth;if(!d)return{position:Nn.Right,align:"start"};let u=(o==null?void 0:o.width)||dy;return{position:l+c+u+uy>d?Nn.Left:Nn.Right}},[i,e,t,o,n,r])};import{Bot as ud}from"lucide-react";import{useNodesData as py,useReactFlow as fy}from"@xyflow/react";import{Button as cd,DropdownMenu as my,DropdownMenuContent as gy,DropdownMenuGroup as hy,DropdownMenuItem as yy,DropdownMenuLabel as xy,DropdownMenuTrigger as Ey,Tooltip as us,TooltipContent as ps,TooltipTrigger as fs,useTranslation as _y}from"@produto-lecom/lecom-ui";import{WrenchIcon as by}from"lucide-react";import{jsx as Oe,jsxs as fo}from"react/jsx-runtime";var dd=({nodeId:e})=>{let{t}=_y(),{updateNodeData:o,getEdges:n,getNode:r}=fy(),i=py(e),a=n().filter(h=>h.source===e).some(h=>{let E=r(h.target);return(E==null?void 0:E.type)==="END_EVENT"}),l=(i==null?void 0:i.data.variant)==="SUBPROCESS",c=(i==null?void 0:i.data.variant)==="SERVICE_TASK",d=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 fo(my,{children:[fo(us,{children:[Oe(fs,{asChild:!0,children:Oe(Ey,{asChild:!0,children:Oe(cd,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:Oe(by,{})})})}),Oe(ps,{color:"black",children:t("bpmn.task.menu.title")})]}),fo(gy,{align:"start",className:"w-60 bg-white text-grey-600",children:[fo(xy,{className:"flex items-center gap-1",children:[Oe("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),Oe("div",{className:"flex items-center gap-1",children:Object.entries(Wn).map(([f,m])=>{let h=f==="LOOP"&&(a||l||c),p=(()=>{if(f==="LOOP"&&a)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 fo(us,{children:[Oe(fs,{asChild:!0,children:Oe(cd,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:h,className:H({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===f,"opacity-50 cursor-not-allowed":h}),onClick:h?void 0:()=>u(f),children:Oe(m.icon,{className:"stroke-inherit"})})}),p&&Oe(ps,{color:"black",children:p})]},f)})})]}),Oe(hy,{children:fo(us,{children:[Oe(fs,{asChild:!0,children:Oe("div",{className:H({"cursor-not-allowed":a}),children:fo(yy,{className:H({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":a}),disabled:a,onClick:()=>d("SCRIPT"),children:[Oe(Yn.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),a&&Oe(ps,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};import{jsx as Me,jsxs as pd}from"react/jsx-runtime";var Ct={START_EVENT:{type:"START_EVENT",icon:Ko,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:Eo,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:Ko,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:Hn,label:"bpmn.annotation.variant.default"}},Py={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:bo,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:To,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:_o,label:"bpmn.gateway.variant.complex"}},Fe=({nodeId:e,nodeType:t,nodeVariant:o,isChild:n})=>{let r=Qr(null),i=Qr(null),{t:s}=Sy(),{setDraggableNode:a}=zo(),{getEdges:l,getNodes:c,getNode:d,setNodes:u}=vy(),{setIsDragging:f,mode:m,isConnecting:h,isDragging:E,isMultipleSelection:p}=q(),g=d(e),y=!!(g!=null&&g.selected)&&!g.dragging&&!h&&!E&&!p,{dimensions:x}=ad(r,y),{position:N}=ld(e,y,x),[b,v]=My(void 0),T=c(),I=l(),S=o==="SUBPROCESS",P=o==="SERVICE_TASK",R=Qr(null),C=Qr(!1),L=ms(()=>{R.current!==null&&(clearTimeout(R.current),R.current=null),C.current=!1,f(!1),a(null),v(void 0),u(W=>W.map(U=>w(_({},U),{className:void 0})))},[f,a,u]);Cy(()=>{let W=U=>{C.current&&U.buttons===0&&L()};return document.addEventListener("dragend",L),document.addEventListener("mousemove",W),()=>{document.removeEventListener("dragend",L),document.removeEventListener("mousemove",W)}},[L]);let K=ms((W,U)=>{C.current=!0,f(!1),a({type:U.type,variant:U.variant,attribute:U.attribute,icon:U.icon}),U.icon&&v(Me(U.icon,{})),W.dataTransfer.effectAllowed="move",W.dataTransfer.setData("sourceId",e),i.current&&W.dataTransfer.setDragImage(i.current,10,10),R.current=setTimeout(()=>{R.current=null,f(!0)},100)},[e,a,f]),Q=ms(()=>{L()},[L]),j=[{component:Me(Or,{elementId:e})}],z=()=>{if(m==="view")return[];let W=!I.some(U=>{var X;return U.source===e&&((X=T.find($=>$.id===U.target))==null?void 0:X.type)!=="ANNOTATION"});return[{component:Me(Mo,{nodeId:e,disabled:!W,tooltipMessage:W?void 0:s("editor.toolbar.start_event_limit_reached")})},Ct.TASK,Ct.ANNOTATION,...j]},M=()=>m==="view"?[{component:Me(Yt,{elementId:e})}]:[{component:Me(Yt,{elementId:e})},...S||P?[]:[{component:Me(dd,{nodeId:e})}],{component:Me(Mo,{nodeId:e})},Ct.TASK,{type:"TASK",variant:"SUBPROCESS",icon:Zo,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:ud,label:"bpmn.task.variant.service_task"},Ct.ANNOTATION,...Object.values(Py),...co(e,T,I)?[]:[Ct.END_EVENT],...j],V=()=>m==="view"?[{component:Me(Yt,{elementId:e,elementType:"gateway"})}]:[{component:Me(Yt,{elementId:e,elementType:"gateway"})},{component:Me(Mo,{nodeId:e})},Ct.TASK,{type:"TASK",variant:"SUBPROCESS",icon:Zo,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:ud,label:"bpmn.task.variant.service_task"},Ct.ANNOTATION,...j],D=()=>m==="view"?[]:[Ct.ANNOTATION,...j],A=()=>m==="view"?[]:[...n?[]:[{component:Me(Mo,{nodeId:e})}],Ct.ANNOTATION,...j],B=()=>m==="view"?[]:[{component:Me(Mo,{nodeId:e})},...j],G=()=>m==="view"?[]:[...j],O=(W=>{switch(W){case"START_EVENT":return z();case"TASK":return M();case"GATEWAY":return V();case"END_EVENT":return D();case"LANE":return A();case"ANNOTATION":return B();case"UNSUPPORTED":return G();default:return[]}})(t),Y=O.length>6;if(!(O.length===0||m==="readonly"))return pd(Ty,{position:N,align:"start",className:Y?"-top-[4.5rem]":"-top-8",isVisible:y,children:[Me("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((W,U)=>{if(W.component)return Me("div",{children:W.component},U);let X={sourceNodeType:t,targetNodeType:W.type,sourceNodeId:e,nodes:T,edges:I},$=mc(X),te={gateway_limit_reached:s("editor.toolbar.gateway_limit_reached"),start_event_limit_reached:s("editor.toolbar.start_event_limit_reached"),start_event_already_exists:s("editor.toolbar.start_event_already_exists"),script_to_end_not_allowed:s("editor.toolbar.script_to_end_not_allowed"),loop_to_end_not_allowed:s("editor.toolbar.loop_to_end_not_allowed"),initial_activity_to_end_not_allowed:s("editor.toolbar.initial_activity_to_end_not_allowed"),final_activity_cannot_connect:s("editor.toolbar.final_activity_cannot_connect"),activity_has_outgoing_connections:s("editor.toolbar.activity_has_outgoing_connections"),task_limit_reached:s("editor.toolbar.task_limit_reached"),start_event_to_service_task_not_allowed:s("editor.toolbar.start_event_to_service_task_not_allowed"),service_task_to_end_not_allowed:s("editor.toolbar.service_task_to_end_not_allowed")},ie=$.shouldDisable&&$.reason?te[$.reason]||s(W.label):s(W.label)||"";return pd(wy,{children:[Me(Ay,{asChild:!0,children:Me(Ny,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!$.shouldDisable,disabled:$.shouldDisable,className:$.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:$.shouldDisable?void 0:F=>K(F,W),onDragEnd:$.shouldDisable?void 0:Q,children:W.icon&&Me(W.icon,{size:16})})}),Me(Iy,{color:"black",children:ie})]},U)})}),Me("div",{ref:i,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:b})]})};import{Fragment as fd,jsx as dt,jsxs as hs}from"react/jsx-runtime";var md=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r,setNodes:i}=ky(),{inProgress:s,fromNode:a}=Ly(),{mode:l,isReadOnly:c}=q(),d=s&&(a==null?void 0:a.id)!==e,u=gs(h=>{let x=h.split(`
|
|
40
|
-
`),N=x.reduce((I,S)=>Math.max(I,S.length),0),b=x.length,v=Math.max(No.MIN_WIDTH,N*7+32),T=Math.max(No.MIN_HEIGHT,b*20+24);i(I=>I.map(S=>S.id===e?w(_({},S),{width:v,height:T,style:w(_({},S.style),{width:v,height:T})}):S))},[e,i]),f=gs(h=>{r(e,{label:h}),u(h)},[e,r,u]),m=gs(h=>{u(h)},[u]);return hs("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:[dt(De,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:f,onInput:m,skipFirstCharValidation:!0}),dt(Fe,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&dt(it,{nodeId:e,minWidth:No.MIN_WIDTH,minHeight:No.MIN_HEIGHT,isVisible:!n&&o}),!s&&hs(fd,{children:[dt(ne,{type:"source",position:Ut.Left,id:"left"}),dt(ne,{type:"source",position:Ut.Right,id:"right"}),dt(ne,{type:"source",position:Ut.Top,id:"top"}),dt(ne,{type:"source",position:Ut.Bottom,id:"bottom"})]}),(!s||d)&&hs(fd,{children:[dt(ne,{type:"target",position:Ut.Left,id:"left",className:H({"annotation-handle":d})}),dt(ne,{type:"target",position:Ut.Right,id:"right",className:H({"annotation-handle":d})}),dt(ne,{type:"target",position:Ut.Top,id:"top",className:H({"annotation-handle":d})}),dt(ne,{type:"target",position:Ut.Bottom,id:"bottom",className:H({"annotation-handle":d})})]})]})};import{Position as $t,useConnection as Ry,useReactFlow as Dy}from"@xyflow/react";import{useState as Oy}from"react";import{Fragment as gd,jsx as Ze,jsxs as ys}from"react/jsx-runtime";var hd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=Dy(),{inProgress:i,fromNode:s}=Ry(),{mode:a,isReadOnly:l,reconnectingEdgeId:c}=q(),[d,u]=Oy(!1),f=i&&(s==null?void 0:s.id)!==e||!!c,m=p=>{r(e,{label:p})},h=()=>{u(!0)},E=()=>{u(!1)};return ys("div",{className:"relative",onDoubleClick:h,children:[Ze(Eo,{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})}),Ze("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Ze(De,{value:t.label,isEditing:d,onBlur:E,onChange:m})}),Ze(Fe,{nodeId:e,nodeType:"END_EVENT"}),a==="edit"&&Ze(it,{nodeId:e,isVisible:!n&&o,minWidth:Xn.MIN_WIDTH,minHeight:Xn.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||f)&&ys(gd,{children:[Ze(ne,{type:"target",position:$t.Left,id:"left",className:H({"event-handle":f})}),Ze(ne,{type:"target",position:$t.Right,id:"right",className:H({"event-handle":f})}),Ze(ne,{type:"target",position:$t.Top,id:"top",className:H({"event-handle":f})}),Ze(ne,{type:"target",position:$t.Bottom,id:"bottom",className:H({"event-handle":f})})]}),!i&&ys(gd,{children:[Ze(ne,{type:"source",position:$t.Left,id:"left"}),Ze(ne,{type:"source",position:$t.Right,id:"right"}),Ze(ne,{type:"source",position:$t.Top,id:"top"}),Ze(ne,{type:"source",position:$t.Bottom,id:"bottom"})]})]})};import{Position as Kt,useConnection as Vy,useReactFlow as Hy}from"@xyflow/react";import{useCallback as Gy,useState as By}from"react";import{Fragment as yd,jsx as Je,jsxs as xs}from"react/jsx-runtime";var xd=({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let s=Oi[t.variant].icon,{updateNodeData:a}=Hy(),{inProgress:l,fromNode:c}=Vy(),{mode:d,isReadOnly:u,reconnectingEdgeId:f}=q(),[m,h]=By(!1),E=l&&(c==null?void 0:c.id)!==e||!!f,p=Gy(x=>{a(e,{label:x})},[e,a]),g=()=>{h(!0)},y=()=>{h(!1)};return xs("div",{className:"relative",style:{width:o!=null?o:vo.MIN_WIDTH,height:n!=null?n:vo.MIN_HEIGHT},onDoubleClick:g,children:[Je(s,{className:H("w-full h-full min-w-14 min-h-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"pointer-events-none":u,"stroke-blue-500 hover:stroke-blue-600":r&&!u,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),Je("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Je(De,{value:t.label,isEditing:m,onBlur:y,onChange:p})}),Je(Fe,{nodeId:e,nodeType:"GATEWAY",nodeVariant:t.variant}),d==="edit"&&Je(it,{nodeId:e,isVisible:!i&&r,minWidth:vo.MIN_WIDTH,minHeight:vo.MIN_HEIGHT,offset:2,keepAspectRatio:!0}),(!l||E)&&xs(yd,{children:[Je(ne,{type:"target",position:Kt.Left,id:"left",className:H({"gateway-handle":E})}),Je(ne,{type:"target",position:Kt.Right,id:"right",className:H({"gateway-handle":E})}),Je(ne,{type:"target",position:Kt.Top,id:"top",className:H({"gateway-handle":E})}),Je(ne,{type:"target",position:Kt.Bottom,id:"bottom",className:H({"gateway-handle":E})})]}),!l&&xs(yd,{children:[Je(Ge,{type:"source",position:Kt.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Je(Ge,{type:"source",position:Kt.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Je(Ge,{type:"source",position:Kt.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Je(Ge,{type:"source",position:Kt.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})};import{useNodesData as kM,useReactFlow as RM}from"@xyflow/react";import{Button as OM,DropdownMenu as VM,DropdownMenuContent as HM,DropdownMenuGroup as GM,DropdownMenuItem as BM,DropdownMenuLabel as zM,DropdownMenuTrigger as YM,Tooltip as WM,TooltipContent as FM,TooltipTrigger as XM,useTranslation as UM}from"@produto-lecom/lecom-ui";import{WrenchIcon as KM}from"lucide-react";import{jsx as QM,jsxs as jM}from"react/jsx-runtime";import{Position as qt,useConnection as zy,useReactFlow as Yy}from"@xyflow/react";import{useState as Wy}from"react";import{Fragment as Ed,jsx as Qe,jsxs as Es}from"react/jsx-runtime";var _d=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=Yy(),{inProgress:i,fromNode:s}=zy(),{mode:a,isReadOnly:l,reconnectingEdgeId:c}=q(),[d,u]=Wy(!1),f=i&&(s==null?void 0:s.id)!==e||!!c,m=p=>{r(e,{label:p})},h=()=>{u(!0)},E=()=>{u(!1)};return Es("div",{className:"relative",onDoubleClick:h,children:[Qe(Bn,{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})}),Qe("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Qe(De,{value:t.label,isEditing:d,onBlur:E,onChange:m})}),Qe(Fe,{nodeId:e,nodeType:"START_EVENT"}),a==="edit"&&Qe(it,{nodeId:e,isVisible:!n&&o,minWidth:Fn.MIN_WIDTH,minHeight:Fn.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||f)&&Es(Ed,{children:[Qe(ne,{type:"target",position:qt.Left,id:"left",className:H({"event-handle":f})}),Qe(ne,{type:"target",position:qt.Right,id:"right",className:H({"event-handle":f})}),Qe(ne,{type:"target",position:qt.Top,id:"top",className:H({"event-handle":f})}),Qe(ne,{type:"target",position:qt.Bottom,id:"bottom",className:H({"event-handle":f})})]}),!i&&Es(Ed,{children:[Qe(Ge,{type:"source",position:qt.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),Qe(Ge,{type:"source",position:qt.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),Qe(Ge,{type:"source",position:qt.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),Qe(Ge,{type:"source",position:qt.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};import{useTranslation as Uy}from"@produto-lecom/lecom-ui";import{Position as Zt,useConnection as $y,useReactFlow as Ky}from"@xyflow/react";import{useCallback as ei}from"react";var wn=60,jr=(e,t)=>{var s;let o=[],n=`${t} `;for(let a of e){if(!(a.type==="TASK"))continue;let c=(s=a.data)==null?void 0:s.label;if(c&&c.startsWith(n)){let d=c.substring(n.length);/^\d{1,15}$/.test(d)&&o.push(parseInt(d,10))}}let r=o.length>0?Math.max(...o)+1:1,i=`${t} ${r}`;return i.length<=wn?i:i.substring(0,wn).trim()},Yo=(e,t)=>{var a;let o=new Set;for(let l of t)l.type==="TASK"&&((a=l.data)!=null&&a.label)&&o.add(l.data.label);let n=e;if(n.length>wn&&(n=n.substring(0,wn).trim()),!o.has(n))return n;let r=n.replace(/\s+\(\d+\)$/,""),i=2,s=o.size+2;for(;i<=s;){let l=` (${i})`,c=wn-l.length,u=`${r.substring(0,c).trim()}${l}`;if(!o.has(u))return u;i++}return n};import{jsx as bd,jsxs as Fy}from"react/jsx-runtime";var Td=e=>Fy("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[bd("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),bd("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as vd}from"react/jsx-runtime";var Nd=e=>vd("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:vd("path",{d:"M12 2C8.13 2 5 5.13 5 9C5 14.25 12 22 12 22C12 22 19 14.25 19 9C19 5.13 15.87 2 12 2ZM12 11.5C10.62 11.5 9.5 10.38 9.5 9C9.5 7.62 10.62 6.5 12 6.5C13.38 6.5 14.5 7.62 14.5 9C14.5 10.38 13.38 11.5 12 11.5Z",fill:"#38bdf8"})}));import{jsx as wd,jsxs as Xy}from"react/jsx-runtime";var Id=e=>Xy("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[wd("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),wd("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{Fragment as ti,jsx as we,jsxs as In}from"react/jsx-runtime";var qy={APROVADO:Td,EM_ANDAMENTO:Nd,REJEITADO:Id},_s={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)]"},Zy={APROVADO:"bg-green-50",EM_ANDAMENTO:"bg-turquoise-50",REJEITADO:"bg-red-50"},Ad=({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let{t:s}=Uy(),{toast:a}=We(),{updateNodeData:l,getNodes:c,setNodes:d}=Ky(),{inProgress:u,fromNode:f}=$y(),{mode:m,isReadOnly:h,onSubprocessValidationClick:E,reconnectingEdgeId:p}=q(),{getTaskStatus:g}=no(),y=u&&(f==null?void 0:f.id)!==e||!!p,x=g(e),N=t.variant==="SUBPROCESS",b=t.variant==="SERVICE_TASK",v=!!t.variant&&!N&&!b||!!x,T=!!t.attribute||N||b,I=ei(M=>{let B=v||T?80:40,G=M.split(`
|
|
41
|
-
`),k=G.reduce((U,X)=>Math.max(U,X.length),0),O=G.length,Y=Math.max(Dt.MIN_WIDTH,k*7+64),W=Math.max(Dt.MIN_HEIGHT,O*24+B);d(U=>U.map(X=>X.id===e?w(_({},X),{width:Y,height:W,style:w(_({},X.style),{width:Y,height:W})}):X))},[e,d,v,T]),S=ei(M=>{let V=M.trim(),D=t.label||"";if(V===D)return;let A=V,B=c();if(!(V&&V!=="")){A=jr(B,s("bpmn.task.label.prefix")),l(e,{label:A}),I(A),a({variant:"warning",content:In(ti,{children:[s("bpmn.task.feedback.label_empty.prefix")," ",we("strong",{children:A})]})});return}let k=Yo(A,B);k===D||(l(e,{label:k}),I(k),k!==A&&a({variant:"warning",content:In(ti,{children:[s("bpmn.task.feedback.label_already_exists.prefix")," ",we("strong",{children:V})," ",s("bpmn.task.feedback.label_already_exists.middle")," ",we("strong",{children:k})]})}))},[t.label,c,e,s,l,I,a]),P=ei(M=>{I(M)},[I]),R=ei(()=>{a({variant:"error",content:s("bpmn.task.feedback.invalid_first_character")})},[s,a]),C=x?qy[x]:null,L=t.variant?Yn[t.variant].icon:null,K=t.attribute?Wn[t.attribute].icon:null,Q=()=>t.hasError?_s.error:x?_s[x]:h?_s.default:"",j=()=>{var M;return r&&(M=Zy[x])!=null?M:""},z=()=>{E==null||E({id:e,type:"sub_process",label:t.label})};return In("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",Q(),{"cursor-pointer":h,"border-blue-500 hover:border-blue-600 shadow-md":r&&!h&&!x,"border-red-500 hover:border-red-600 shadow-[0_0_5px_rgba(255,0,0,0.5)]":t.hasError}),style:{width:o!=null?o:Dt.MIN_WIDTH,height:n!=null?n:Dt.MIN_HEIGHT},children:[we("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:we(De,{value:t.label,maxLength:60,className:H(j(),{"py-10 px-8":v||T}),onChange:S,onInput:P,onInvalidFirstCharacter:R})}),L&&we("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:we(L,{size:b?20:16,className:H(t.hasError?"text-red-500":"text-grey-500",N&&"cursor-pointer"),onClick:N?z:void 0})}),K&&we("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:we("div",{className:H("flex items-center w-16 p-1",N||b?"justify-between":"justify-center"),children:we(K,{size:16,className:H(t.hasError?"text-red-500":"text-grey-500")})})}),C&&we("div",{className:"absolute top-0 right-0 flex items-center p-1",children:we(C,{})}),we(Fe,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),m==="edit"&&we(it,{nodeId:e,isVisible:!i&&r,minWidth:Dt.MIN_WIDTH,minHeight:Dt.MIN_HEIGHT}),(!u||y)&&In(ti,{children:[we(ne,{type:"target",position:Zt.Left,id:"left",className:H({"task-handle":y})}),we(ne,{type:"target",position:Zt.Right,id:"right",className:H({"task-handle":y})}),we(ne,{type:"target",position:Zt.Top,id:"top",className:H({"task-handle":y})}),we(ne,{type:"target",position:Zt.Bottom,id:"bottom",className:H({"task-handle":y})})]}),!u&&In(ti,{children:[we(Ge,{type:"source",position:Zt.Left,id:"left",nodeId:e,nodeType:"TASK"}),we(Ge,{type:"source",position:Zt.Right,id:"right",nodeId:e,nodeType:"TASK"}),we(Ge,{type:"source",position:Zt.Top,id:"top",nodeId:e,nodeType:"TASK"}),we(Ge,{type:"source",position:Zt.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})};import{Position as Sd}from"@xyflow/react";import{Fragment as Jy,jsx as oi,jsxs as Qy}from"react/jsx-runtime";var Cd=({id:e,data:t})=>Qy(Jy,{children:[oi("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}),oi(Fe,{nodeId:e,nodeType:"UNSUPPORTED"}),oi(ne,{type:"source",position:Sd.Right}),oi(ne,{type:"target",position:Sd.Left})]});import{BaseEdge as jy,EdgeLabelRenderer as e0,getSmoothStepPath as t0,MarkerType as o0,useInternalNode as Md,useReactFlow as n0,useViewport as r0,Position as Wo}from"@xyflow/react";import{useState as i0,useMemo as s0}from"react";import{Fragment as Pd,jsx as Xe,jsxs as mo}from"react/jsx-runtime";var V5={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:o0.Arrow},data:{label:""}},Ld=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:s,sourceHandleId:a,targetHandleId:l})=>{var G;let{zoom:c}=r0(),{updateEdgeData:d}=n0(),{isMultipleSelection:u,mode:f,instanceId:m}=q(),h=f!=="edit",[E,p]=i0(!1),{reconnectingHandle:g,cursorPosition:y,hoveredNodeId:x,reconnectingSide:N,isValidReconnection:b,handleReconnectStart:v}=Xr({edgeId:e,source:t,target:o,instanceId:m,isReadOnly:h}),T=Md(t),I=Md(o),{sx:S,sy:P,tx:R,ty:C,sourcePos:L,targetPos:K}=s0(()=>{var oe,le;if(!T||!I)return{sx:0,sy:0,tx:0,ty:0,sourcePos:Wo.Left,targetPos:Wo.Right};let k=wo(T,I),O=a?i:k.sourcePos,Y=l?s:k.targetPos,W=(Z,xe,me)=>{var ee,ge,be,Te,ke,et;let{x:_e,y:J}=Z.internals.positionAbsolute,de=(be=(ge=(ee=Z.measured)==null?void 0:ee.width)!=null?ge:Z.width)!=null?be:0,re=(et=(ke=(Te=Z.measured)==null?void 0:Te.height)!=null?ke:Z.height)!=null?et:0;switch(xe){case Wo.Top:return{x:_e+de*me,y:J};case Wo.Bottom:return{x:_e+de*me,y:J+re};case Wo.Left:return{x:_e,y:J+re*me};case Wo.Right:return{x:_e+de,y:J+re*me};default:return{x:_e+de/2,y:J+re/2}}},U=(oe=n==null?void 0:n.sourceOffset)!=null?oe:.5,X=(le=n==null?void 0:n.targetOffset)!=null?le:.5,$=T?W(T,O,U).x:k.sx,te=T?W(T,O,U).y:k.sy,ie=I?W(I,Y,X).x:k.tx,F=I?W(I,Y,X).y:k.ty;return g==="source"&&y?($=y.x,te=y.y,N&&(O=N)):g==="target"&&y&&(ie=y.x,F=y.y,N&&(Y=N)),{sx:$,sy:te,tx:ie,ty:F,sourcePos:O,targetPos:Y}},[T,I,a,l,i,s,g,y,N,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!T||!I)return null;let[Q,j,z]=t0({sourceX:S,sourceY:P,targetX:R,targetY:C,sourcePosition:L,targetPosition:K}),M=r||(T==null?void 0:T.selected)||(I==null?void 0:I.selected),V=M?"sequence-edge-marker-highlighted":"sequence-edge-marker",D=E||(n==null?void 0:n.label.trim().length)>0,A=()=>{p(!1)},B=k=>{d(e,{label:k.trim()})};return Xe(Pd,{children:mo("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":M}),onDoubleClick:()=>!h&&p(!0),children:[Xe("path",{d:Q,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),mo("g",{className:H("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":M}),children:[Xe(jy,{id:e,path:Q,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})}),mo(e0,{children:[mo("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${j}px, ${z}px)`},children:[r&&!u&&Xe(Lo,{sx:S,sy:P,tx:R,ty:C,hasLabel:!!((G=n==null?void 0:n.label)!=null&&G.trim()),children:Xe(Po,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),D&&Xe(De,{value:n==null?void 0:n.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:E,onBlur:A,onChange:B})]}),r&&!u&&!h&&mo(Pd,{children:[Xe("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${S}px, ${P}px)`},children:mo("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Xe("circle",{cx:6/c,cy:6/c,r:4/c,fill:g==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Xe("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:g==="source"?.6:.3,className:"pointer-events-none"}),Xe("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!g||g!=="source","cursor-not-allowed":g==="source"&&x&&!b,"cursor-grabbing":g==="source"&&(!x||b)}),onMouseDown:k=>v("source",k.nativeEvent)})]})}),Xe("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${R}px, ${C}px)`},children:mo("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Xe("circle",{cx:6/c,cy:6/c,r:4/c,fill:g==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Xe("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:g==="target"?.6:.3,className:"pointer-events-none"}),Xe("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!g||g!=="target","cursor-not-allowed":g==="target"&&x&&!b,"cursor-grabbing":g==="target"&&(!x||b)}),onMouseDown:k=>v("target",k.nativeEvent)})]})})]})]})]})]})})};import{getStraightPath as a0,Position as ni}from"@xyflow/react";import{jsx as kd,jsxs as l0}from"react/jsx-runtime";var Rd=({toX:e,toY:t,fromNode:o})=>{var u,f;if(!o)return null;let{internals:{positionAbsolute:{x:n,y:r}},measured:i}=o,s=(u=i.width)!=null?u:0,a=(f=i.height)!=null?f:0,c=[{x:n,y:r+a/2,pos:ni.Left},{x:n+s,y:r+a/2,pos:ni.Right},{x:n+s/2,y:r,pos:ni.Top},{x:n+s/2,y:r+a,pos:ni.Bottom}].reduce((m,h)=>{let E=Math.hypot(e-m.x,t-m.y);return Math.hypot(e-h.x,t-h.y)<E?h:m}),[d]=a0({sourceX:c.x,sourceY:c.y,targetX:e,targetY:t});return l0("g",{className:"group",children:[kd("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d}),kd("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})};import{Position as Jt,useConnection as c0,useReactFlow as d0}from"@xyflow/react";import{orderBy as u0}from"lodash";import{useMemo as Dd,useState as p0}from"react";import{Fragment as bs,jsx as Ue,jsxs as ri}from"react/jsx-runtime";var Od=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{var T;let{updateNodeData:i,getNodes:s}=d0(),{mode:a,isReadOnly:l}=q(),{inProgress:c,fromNode:d}=c0(),u=c&&(d==null?void 0:d.id)!==e,[f,m]=p0(!1),h=s(),E=!r,p=!E&&((T=h.find(I=>I.id===r))==null?void 0:T.selected),g=Dd(()=>u0([...h.filter(I=>I.parentId===e&&I.type==="LANE")],"position.y","asc"),[h,e]),y=E?ea.MIN_WIDTH:se.MIN_WIDTH,x=Dd(()=>{if(E&&g.length>1){let I=[...g];return I.pop(),I.reduce((P,R)=>{var C,L;return P+((L=(C=R.measured)==null?void 0:C.height)!=null?L:0)},0)+se.MIN_HEIGHT}return se.MIN_HEIGHT},[E,g]),N=I=>{i(e,{label:I})},b=()=>{m(!0)},v=()=>{m(!1)};return ri(bs,{children:[ri("div",{className:H("flex h-full min-h-64 w-full min-w-[50rem] hover:shadow-md bg-white outline outline-2 outline-grey-400",{"pointer-events-none":l,"outline-offset-0 outline-blue-500 shadow-sm":(o||p)&&!l}),children:[Ue("div",{className:H("flex align-items justify-center w-10 border-r-2 border-grey-400",{"border-blue-500":(o||p)&&!l}),onDoubleClick:b,children:Ue("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:Ue(De,{value:t.label,className:"w-full h-full self-auto",contentClassName:H({"whitespace-nowrap":f}),isEditing:f,onBlur:v,onChange:N})})}),Ue("div",{className:"flex-1"})]}),Ue(Fe,{nodeId:e,nodeType:"LANE",isChild:!E}),a==="edit"&&Ue(it,{nodeId:e,isVisible:!n&&o,minWidth:y,minHeight:x,offset:10}),!c&&ri(bs,{children:[Ue(ne,{type:"source",position:Jt.Left,id:"left"}),Ue(ne,{type:"source",position:Jt.Right,id:"right"}),Ue(ne,{type:"source",position:Jt.Top,id:"top"}),Ue(ne,{type:"source",position:Jt.Bottom,id:"bottom"})]}),(!c||u)&&ri(bs,{children:[Ue(ne,{type:"target",position:Jt.Left,id:"left",className:H({"annotation-handle":u})}),Ue(ne,{type:"target",position:Jt.Right,id:"right",className:H({"annotation-handle":u})}),Ue(ne,{type:"target",position:Jt.Top,id:"top",className:H({"annotation-handle":u})}),Ue(ne,{type:"target",position:Jt.Bottom,id:"bottom",className:H({"annotation-handle":u})})]})]})};var Vd={START_EVENT:_d,END_EVENT:hd,TASK:Ad,GATEWAY:xd,ANNOTATION:md,LANE:Od,UNSUPPORTED:Cd},Hd={SEQUENCE_EDGE:Rc,MESSAGE_EDGE:Ld,ANNOTATION_EDGE:xc},Gd="#fafafa",Bd="#bebebe",zd=1,Yd=10,Wd="bottom-left",Ts=.05,Fd=5,Xd=150,Ud=100,$d=Ts,Kd=1,qd={x:0,y:0,zoom:.75},Zd=1,Jd=2,f0={[Zd]:4,[Jd]:2},An=[Zd,Jd],vs=An.reduce((e,t)=>e|f0[t],0);var Fo=()=>{let{setViewport:e}=m0(),t=g0();return{fitToNodes:h0(n=>{let{width:r,height:i}=t.getState();if(i<=0||r<=0)return;let s=aa(n);if(!s)return;let a=la({bounds:s,canvasHeight:i,canvasWidth:r,minZoom:$d,maxZoom:Kd,offsetX:Xd,offsetY:Ud});e(a)},[t,e])}};import{useReactFlow as y0}from"@xyflow/react";var st=()=>{let{getEdges:e,getNodes:t}=y0(),{lastElementId:o}=q(),n=()=>{let i=t(),s=e(),a=Vc(i,s);return Math.max(a,o)};return{getLastId:n,getNextId:()=>n()+1}};var Xo=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n}=x0(),{getLastId:r}=st(),{fitToNodes:i}=Fo(),{setLastElementId:s}=q(),a=Qd(async(c="")=>{let{nodes:d,edges:u,lastElementId:f}=await Jc(c);i(d),o(d),n(u),s(f)},[o,n,s,i]),l=Qd(()=>{let c=e(),d=t(),u=r();return Zc(c,d,u)},[e,t,r]);return{importFromMxGraph:a,exportToMxGraph:l}};import{useCallback as jd}from"react";var _0=500,ii=()=>{let{isInitialized:e,onElementChanges:t}=q(),{exportToMxGraph:o}=Xo(),n=E0(()=>{if(!e)return;let s=o();t==null||t(s)},_0),r=jd(s=>{s.every(c=>c.type==="select")||s.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=jd(s=>{s.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var eu=({setEdges:e,saveHistory:t})=>{let{getNode:o,getEdges:n,getNodes:r,getInternalNode:i}=T0(),{emitElementChanges:s}=ii(),a=v0(null),{getNextId:l}=st(),c=go(p=>{var b;let g=o(p.source),y=o(p.target);if(!g||!y)return!1;let x={sourceNodeId:g.id,targetNodeId:y.id,sourceNodeType:g.type,targetNodeType:y.type,nodes:r(),edges:n(),reconnectingEdgeId:(b=a.current)!=null?b:void 0};return ns(x).isValid},[o,n,r]),d=go(p=>{var x,N;let g=l(),y=i(p.source);if(y){let b=i(p.target),v=b?b.internals.positionAbsolute.x+((x=b.measured.width)!=null?x:0)/2:0,T=b?b.internals.positionAbsolute.y+((N=b.measured.height)!=null?N:0)/2:0,I=Dc(y,v,T),S=(b==null?void 0:b.type)==="ANNOTATION"||(y==null?void 0:y.type)==="ANNOTATION",P=S?ko:rt,R;if(!S&&b&&p.targetHandle){let K=$r(I),Q=$r(p.targetHandle),{x:j,y:z}=ls(y,I),{x:M,y:V}=ls(b,p.targetHandle),A=Wr(j,z,M,V,K,Q).slice(1,-1);A.length>0&&(R=A)}let C=w(_(_({},p),P),{id:String(g),sourceHandle:I,data:_(_({},S?{}:rt.data),R?{points:R}:{})}),L=n().concat(C);e(L),t("forceSave",{nodes:r(),edges:L}),s()}},[l,e,s,i,n,r,t]),u=go((p,g)=>{a.current=g.id},[]),f=go(()=>{a.current=null},[]),m=go((p,g)=>{let y=o(g.source),x=o(g.target);if(!y||!x){a.current=null;return}let N={sourceNodeId:y.id,targetNodeId:x.id,sourceNodeType:y.type,targetNodeType:x.type,nodes:r(),edges:n(),reconnectingEdgeId:p.id};if(!ns(N).isValid){a.current=null;return}let v=b0(p,g,n()).map(T=>T.id===p.id?w(_({},T),{data:w(_({},T.data),{points:void 0})}):T);e(v),t("forceSave",{nodes:r(),edges:v}),a.current=null,s()},[o,r,n,e,s,t]),h=go(p=>{a.current=p},[]),E=go(()=>{a.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:m,onReconnectStart:u,onReconnectEnd:f,setReconnectingEdge:h,clearReconnectingEdge:E}};import{useTranslation as N0}from"@produto-lecom/lecom-ui";import{useReactFlow as w0}from"@xyflow/react";import{useCallback as Pn,useRef as cu,useState as I0}from"react";var Sn=(e=[])=>e.filter(t=>t.type==="START_EVENT"),ho=(e=[])=>e.filter(t=>t.type==="END_EVENT"),Qt=(e=[])=>e.filter(t=>t.type==="TASK")||[],tu=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"});var si=(e=[])=>e.filter(t=>t.type==="GATEWAY"),ou=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),je=(e,t=[])=>t.filter(o=>o.source===e),Cn=(e,t=[])=>t.filter(o=>o.target===e),nu=(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"},ru=(e,t)=>{let o=je(e,t.edges||[]);for(let n of o){let r=(t.nodes||[]).find(i=>i.id===n.target);if(r&&r.type==="END_EVENT")return!0}return!1},iu=e=>e?/[^\s]/.test(e.trim()):!1,Ee=e=>{let{isValid:t,nodeIds:o,edgeIds:n}=e;return{isValid:t,nodeIds:!t&&o&&o.length>0?o:[],edgeIds:!t&&n&&n.length>0?n:[]}},Mt=(e=[],t)=>{if(!e||e.length===0)return{isValid:!0,invalidIds:[]};let o=e.filter(n=>!t(n));return{isValid:o.length===0,invalidIds:o.map(n=>n.id)}},su=(e=[],t=[])=>({nodes:e.map(o=>{var n;return{id:o.id,type:o.type||"",label:typeof((n=o.data)==null?void 0:n.label)=="string"?o.data.label:void 0,properties:o.data}}),edges:t.map(o=>({id:o.id,source:o.source,target:o.target,type:o.type||"default"}))});var Mn=[{id:"start_event_not_found",validate:e=>{let t=Sn(e.nodes);return Ee({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=ho(e.nodes);return Ee({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Sn(e.nodes),o=t.length===1;if(t.length===0)return Ee({isValid:!0});if(!o)return Ee({isValid:!1,nodeIds:t.map(i=>i.id)});let n=je(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(s=>s.id),...n.map(s=>s.target)];return Ee({isValid:!1,nodeIds:[...new Set(i)]})}return Ee({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=Qt(e.nodes),o=Mt(t,n=>je(n.id,e.edges).length<=2);return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=Qt(e.nodes),o=Mt(t,n=>!!n.label&&n.label.trim()!=="");return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=Qt(e.nodes),n=Mt(o,r=>!r.label||r.label.length<=60);return Ee({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=Qt(e.nodes),o=new Map;for(let r of t){if(!r.label)continue;let i=r.label.trim();i&&(o.has(i)||o.set(i,[]),o.get(i).push(r))}let n=[];for(let[,r]of o.entries())r.length>1&&r.forEach(i=>n.push(i.id));return Ee({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=si(e.nodes),o=[],n=[];for(let r of t){let i=je(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&a.type==="GATEWAY"&&(o.push(r.id,a.id),n.push(s.id))}}return Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Sn(e.nodes),...ho(e.nodes)],o=[],n=[];for(let r of t){let i=je(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&(a.type==="START_EVENT"||a.type==="END_EVENT")&&(o.push(r.id,a.id),n.push(s.id))}}return Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=ho(e.nodes),o=[],n=[];for(let r of t){let i=Cn(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.source);if(a&&a.type==="TASK"){let l=je(a.id,e.edges);l.length>1&&(o.push(a.id),l.forEach(c=>n.push(c.id)))}}}return Ee({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=ou(e.nodes),o=Mt(t,r=>je(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>je(r,e.edges).map(i=>i.id));return Ee({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=Qt(e.nodes),o=Mt(t,n=>!n.label||iu(n.label));return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var s,a;if(!((s=e==null?void 0:e.nodes)!=null&&s.length)||!((a=e==null?void 0:e.edges)!=null&&a.length))return Ee({isValid:!0});let t=ho(e.nodes)[0];if(!t)return Ee({isValid:!0});let o=Cn(t.id,e.edges);if(!o.length)return Ee({isValid:!0});let r=Qt(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=Mt(r,l=>!nu(l.id,e));return Ee({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=Qt(e.nodes),o=ho(e.nodes)[0];if(!o)return Ee({isValid:!0});let n=t.filter(l=>{let c=Cn(l.id,e.edges),d=je(l.id,e.edges),u=c.some(m=>{var h;return((h=e.nodes.find(E=>E.id===m.source))==null?void 0:h.type)==="START_EVENT"}),f=d.some(m=>{var h;return((h=e.nodes.find(E=>E.id===m.target))==null?void 0:h.type)==="END_EVENT"});return u&&f}),r=Cn(o.id,e.edges),i=r.length>1,s=r.map(l=>l.source),a={isValid:n.length===0&&!i,nodeIds:[...n.map(l=>l.id),...i?s:[]]};return Ee(a)}},{id:"gateway_flow_to_event",validate:e=>{let t=si(e.nodes),o=[],n=[];for(let r of t){let i=je(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&a.type==="END_EVENT"&&(o.push(r.id,a.id),n.push(s.id))}}return Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=si(e.nodes),o=Mt(t,n=>je(n.id,e.edges).length>=1);return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Sn(e.nodes),...ho(e.nodes)],o=[],n=[];for(let r of t){let i=je(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&a.type==="GATEWAY"&&(o.push(r.id,a.id),n.push(s.id))}}return Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=tu(e.nodes),o=Mt(t,n=>!ru(n.id,e));return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}}];var au=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of Mn){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}},lu=async(e,t)=>{var n;let o=[];try{let r=await e(),i=(n=r==null?void 0:r.filter(s=>s.area==="DIAGRAM"))!=null?n:[];return i.length===0?{isValid:!0,errors:[]}:(i.forEach(s=>{var l,c;let a=(c=(l=s==null?void 0:s.detail)==null?void 0:l.phases)==null?void 0:c.map(d=>d.diagramCellId);o.push({id:s.code,message:s.code,nodeIds:a,edgeIds:[]})}),{isValid:!1,errors:o})}catch(r){let i=[],s=(a,l)=>{let c=t.filter(d=>{var u;return((u=d.data)==null?void 0:u.variant)===a}).map(d=>d.id);c.length>0&&i.push({id:l,message:l,nodeIds:c,edgeIds:[]})};return s("SUBPROCESS","cannot_validate_subprocess_reference"),s("SERVICE_TASK","service_task_automation_status_unavailable"),{isValid:!1,errors:i}}};import{jsx as ai,jsxs as A0}from"react/jsx-runtime";var du=()=>{let{t:e}=N0(),{toast:t}=We(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=w0(),{validateCustomDiagram:s}=q(),[a,l]=I0(!1),c=cu(!1),d=cu(!1),u=Pn(async p=>{let g=su(p.nodes,p.edges),y=au(g),x=p.nodes.filter(({type:b,data:v})=>b==="TASK"&&((v==null?void 0:v.variant)==="SUBPROCESS"||(v==null?void 0:v.variant)==="SERVICE_TASK"));if(s&&x.length>0){let b=await lu(s,x);y={isValid:y.isValid&&b.isValid,errors:[...y.errors,...b.errors]}}let N=y.errors.map(b=>w(_({},b),{message:e(`validation.errors.${b.id}`)}));return a||l(!0),{isValid:y.isValid,errors:N}},[a,e,s]),f=Pn((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:A0("div",{className:"flex flex-col gap-1",children:[!p.isValid&&ai("span",{className:"body-small-500",children:e("validation.errors.subtitle")}),ai("ul",{className:"list-disc list-inside max-h-40 overflow-y-auto",children:p.isValid?ai("li",{children:e("validation.success.message")}):p.errors.map(C=>ai("li",{className:"text-xs",children:C.message},C.id))})]})}),!p)return;c.current=!0,d.current=!0;let y=[],x=[];p.errors.forEach(C=>{C.nodeIds&&C.nodeIds.length>0&&C.nodeIds.forEach(L=>y.push(L)),C.edgeIds&&C.edgeIds.length>0&&C.edgeIds.forEach(L=>x.push(L))});let N=[...new Set(y)];o(C=>C.map(L=>w(_({},L),{data:w(_({},L.data),{hasError:!1})}))),n(C=>C.map(L=>w(_({},L),{data:w(_({},L.data),{hasError:!1})})));let b=r(),v=i(),T=new Set(N),I=new Set;p.errors.forEach(C=>{var Q,j;let L=Mn.find(z=>z.id===C.id);(L==null?void 0:L.highlightRelatedEdges)!==!1&&((Q=C.edgeIds)==null||Q.forEach(z=>I.add(z)),(j=C.nodeIds)==null||j.forEach(z=>{v.forEach(M=>{(M.source===z||M.target===z)&&I.add(M.id)})}))});let S=new Set,P=new Set,R=new Set;b.forEach(C=>{C.type==="START_EVENT"?S.add(C.id):C.type==="END_EVENT"&&P.add(C.id)}),v.forEach(C=>{S.has(C.source)&&R.add(C.target),P.has(C.target)&&R.add(C.source)}),R.forEach(C=>{var L,K;if(T.has(C)){let Q=(L=p.errors.find(z=>{var M;return(M=z.nodeIds)==null?void 0:M.includes(C)}))==null?void 0:L.id;((K=Mn.find(z=>z.id===Q))==null?void 0:K.highlightRelatedEdges)!==!1&&v.forEach(z=>{z.source===C&&P.has(z.target)&&(T.add(z.target),I.add(z.id)),z.target===C&&S.has(z.source)&&(T.add(z.source),I.add(z.id))})}}),T.size>0&&o(C=>C.map(L=>w(_({},L),{data:w(_({},L.data),{hasError:T.has(L.id)})}))),I.size>0&&n(C=>C.map(L=>w(_({},L),{data:w(_({},L.data),{hasError:I.has(L.id)})}))),setTimeout(()=>{c.current=!1},0)},[e,i,r,n,o,t]),m=Pn(()=>{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]),h=Pn(()=>{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=Pn(()=>c.current,[]);return{validateDiagram:u,handleValidationComplete:f,clearValidation:m,dismissValidationPanel:h,isAutoValidationEnabled:a,getIsClearingValidation:E}};import{useReactFlow as S0}from"@xyflow/react";import{useTranslation as C0}from"@produto-lecom/lecom-ui";import{useEffect as M0}from"react";var P0=15,uu="bpmn:selection",L0=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},pu=e=>{if(!L0(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},fu=({offset:e=P0,saveHistory:t})=>{let{t:o}=C0(),{getNodes:n,setNodes:r,getEdges:i,setEdges:s}=S0(),{getNextId:a}=st(),{mode:l,containerRef:c}=q();M0(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let u=m=>{var b,v;if(!pu(m)||!d.contains(document.activeElement))return;let E=n(),p=i(),g=E.filter(T=>T.selected);if(!g.length)return;m.preventDefault(),m.stopPropagation();let y=p.filter(T=>g.some(I=>I.id===T.source)&&g.some(I=>I.id===T.target)),N=JSON.stringify({nodes:g,edges:y});(b=m.clipboardData)==null||b.setData(uu,N),(v=m.clipboardData)==null||v.setData("text/plain",`BPMN Selection: ${g.length} nodes`)},f=m=>{var R,C;if(!pu(m)||!d.contains(document.activeElement))return;let E=(R=m.clipboardData)==null?void 0:R.getData(uu);if(!E)return;m.preventDefault(),m.stopPropagation();let p;try{p=JSON.parse(E)}catch(L){return}if(!((C=p.nodes)!=null&&C.length))return;let g=new Map,y=n(),x=[],N=p.nodes.filter(L=>Bt(L.type,y));if(N.length===0)return;let b=a(),v=N.map(L=>{var j;let K=String(b++);g.set(L.id,K);let Q=w(_({},L),{id:K,selected:!0,position:{x:L.position.x+e,y:L.position.y+e}});if(L.type==="TASK"){let z=(j=L.data)==null?void 0:j.label,M=Yo(z||o("bpmn.task.label.prefix"),[...y,...x]);Q.data=w(_({},L.data),{label:M})}return x.push(Q),Q}),T=p.edges.map(L=>w(_({},L),{id:String(b++),selected:!0,source:g.get(L.source)||L.source,target:g.get(L.target)||L.target})),I=[...y.map(L=>w(_({},L),{selected:!1})),...v],P=[...i().map(L=>w(_({},L),{selected:!1})),...T];r(I),s(P),t("forceSave",{nodes:I,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,s,a,e,o,t,l,c])};import{useTranslation as k0}from"@produto-lecom/lecom-ui";import{useReactFlow as R0}from"@xyflow/react";import{useState as D0}from"react";var O0=50,mu=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let{draggableNode:r,setDraggableNode:i}=zo(),{t:s}=k0(),{getInternalNode:a,getNodes:l,getEdges:c,screenToFlowPosition:d}=R0(),{getNextId:u}=st(),{setIsDragging:f}=q(),{getInternalNodes:m}=Zr(),{rebuildIndex:h,forceRebuildIndex:E}=wr(),[p,g]=D0(null),y=(M,V,D)=>{var k;if(M.parentId!==V)return null;let A=D.filter(O=>O.id!==M.id&&O.parentId===V&&O.type==="LANE").sort((O,Y)=>O.position.y-Y.position.y);if(A.length===0)return null;let B=(k=D.find(O=>O.id===M.id))!=null?k:M,G=A.find(O=>B.position.y<O.position.y);return G?{draggedLaneId:M.id,beforeLaneId:G.id}:{draggedLaneId:M.id,afterLaneId:A[A.length-1].id}},x=(M,V=!1,D)=>{let A=V?"node-drop-target-error":"node-drop-target",B=V?"node-drop-target-lane-error":"node-drop-target-lane";t(G=>{var O;let k=(O=D==null?void 0:D(G))!=null?O:null;return G.map(Y=>{let W=[];return Y.id===M&&W.push(A),M!==void 0&&Y.parentId===M&&Y.type==="LANE"&&Y.id!==(k==null?void 0:k.draggedLaneId)&&W.push(B),Y.id===(k==null?void 0:k.draggedLaneId)&&W.push("lane-reorder-dragging"),Y.id===(k==null?void 0:k.beforeLaneId)&&W.push("lane-reorder-before"),Y.id===(k==null?void 0:k.afterLaneId)&&W.push("lane-reorder-after"),w(_({},Y),{className:W.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=jo(M,O);if(!Y){x();return}if(eo({parentId:Y.id,nodes:e,excludeTypes:["LANE"]})){x(Y.id,!0);return}x(Y.id,!1,U=>y(M,Y.id,U));return}let B=D.filter(O=>O.id!==M.id&&O.type==="LANE"),G=jo(M,B);if(!G){x();return}if(eo({parentId:G.id,nodes:e,includeTypes:["LANE"]})){x();return}x(G.id)},b=M=>{let V=a(M.id),D=M.type==="LANE"&&eo({parentId:M.id,nodes:e,includeTypes:["LANE"]});N(V,D)},v=M=>M.map(V=>w(_({},V),{className:void 0})),T=M=>M.some(D=>D.dragging)?M.map(D=>D.dragging?w(_({},D),{dragging:!1}):D):M,I=(M,V)=>{let D=0;for(let A of V){if(A.id===M||A.parentId||A.type==="LANE")continue;let B=ot(A),G=B.y+B.h;D=Math.max(D,G)}return D+O0},S=(M,V)=>{if(!Vi(M,V))return V;let D=I(M,V);return V.map(A=>A.id===M?w(_({},A),{position:w(_({},A.position),{y:D})}):A)},P=M=>{if(M.preventDefault(),M.dataTransfer.dropEffect="move",!(r!=null&&r.type))return;let V=d({x:M.clientX,y:M.clientY}),D={id:"__sidebar_drag__",type:r.type,position:V,measured:{width:1,height:1},internals:{positionAbsolute:V}};N(D,!1)},R=M=>{let V=M.relatedTarget;(!V||!M.currentTarget.contains(V))&&x()},C=(M,V)=>{M.preventDefault(),b(V)},L=(M,V,D)=>{var W,U;let A=[...D],B=V.parentId?V.parentId:V.id;if(M.parentId===V.id)return A=Gi(M,V,A),A=Xt(A),A=to(B,A),v(A);if(M.type==="LANE"){if(eo({parentId:V.id,nodes:A,excludeTypes:["LANE"]})){let F=Tr(V),oe=50,le=50;return A.map(Z=>{var xe,me;return Z.id===M.id?w(_({},Z),{position:{x:(xe=p==null?void 0:p.x)!=null?xe:F.x+oe,y:(me=p==null?void 0:p.y)!=null?me:F.y2+le}}):Z})}let te=A.filter(F=>F.parentId===V.id).reduce((F,oe)=>{var le,Z;return F+((Z=(le=oe.measured)==null?void 0:le.height)!=null?Z:0)},0),ie={x:se.HEADER_WIDTH,y:te};return A=A.map(F=>F.id===M.id?w(_({},F),{parentId:V.id,position:ie,className:void 0}):w(_({},F),{className:void 0})),A=Xt(A),A=S(B,A),A}if(eo({parentId:V.id,nodes:A,includeTypes:["LANE"]})){let X;if(M.parentId){let $=a(M.parentId),{x:te,y:ie}=ot($);X={x:te+((W=M.position.x)!=null?W:0),y:ie+((U=M.position.y)!=null?U:0)}}return A=A.map($=>$.id===M.id?w(_({},$),{position:X!=null?X:$.position,parentId:void 0,className:void 0}):w(_({},$),{className:void 0})),A=to(B,A),A}let O=ia(M,V);A=A.map(X=>X.id===M.id?w(_({},X),{parentId:V.id,position:O,className:void 0}):w(_({},X),{className:void 0}));let Y=A.find(X=>X.id===M.id);return A=Gi(Y,V,A),A=Xt(A),A=to(B,A),A},K=M=>{if(M.preventDefault(),!(r!=null&&r.type))return;if(!Bt(r.type,l())){f(!1),i(null);return}let V=d({x:M.clientX,y:M.clientY}),D={width:ue[r.type].MIN_WIDTH,height:ue[r.type].MIN_HEIGHT},A=u(),B={id:String(A),type:r.type,position:V,measured:D,data:{label:r.type==="TASK"?jr(e,s("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",W=O.filter(F=>Y?F.type==="LANE"&&!F.parentId:F.type==="LANE"),U=jo(k,W),X=[...O.map(F=>w(_({},F),{selected:!1})),G];U&&(X=L(G,U,X)),X=Qo(X),Y&&!U&&(X=S(G.id,X)),X=v(X),t(X),E();let $=M.dataTransfer.getData("sourceId"),te=c(),ie=te;if($){let F={id:String(A+1),source:$,target:B.id},oe=r.type==="ANNOTATION"?_(_({},F),ko):_(_({},F),rt);ie=te.concat(oe),o(ie)}n("forceSave",{nodes:X,edges:ie}),f(!1),i(null)},Q=async(M,V,D)=>{let A=[...m()],B=new Set;D.forEach(O=>{let Y=a(O.id),W=O.type==="LANE",U=A.filter($=>$.id!==O.id&&(W?$.type==="LANE"&&!$.parentId:$.type==="LANE")),X=jo(Y,U);if(X){if(W&&eo({parentId:O.id,nodes:A,includeTypes:["LANE"]})){O.parentId&&(A=z(O,A),B.add(O.id));return}A=L(Y,X,A);return}O.parentId&&(A=z(O,A),O.type==="LANE"&&B.add(O.id))}),A=T(A);let G=D.filter(O=>O.type==="LANE"&&!O.parentId).map(O=>O.id);for(let O of G)Vi(O,A)&&p&&(A=A.map(Y=>Y.id===O?w(_({},Y),{position:_({},p)}):Y));for(let O of B)A=S(O,A);if(D.some(O=>O.type!=="LANE"&&!O.parentId)){let O=A.filter(Y=>Y.type==="LANE"&&!Y.parentId).map(Y=>Y.id);for(let Y of O)A=to(Y,A)}A=Qo(A),A=v(A),t(A),h(A),g(null)},j=(M,V)=>{g({x:V.position.x,y:V.position.y})},z=(M,V)=>{var U,X,$,te,ie,F,oe,le;let D=a(M.parentId);if(!D)return V;let A=M.type==="LANE",B=V.filter(Z=>Z.parentId===D.id&&Z.id!==M.id),G=B.filter(Z=>Z.type==="LANE"),k;if(A&&G.length===0)k=se.MIN_HEIGHT;else if(A){let Z=(X=(U=M.measured)==null?void 0:U.height)!=null?X:se.MIN_HEIGHT;k=((te=($=D.measured)==null?void 0:$.height)!=null?te:se.MIN_HEIGHT)-Z,k=Math.max(se.MIN_HEIGHT,k)}else k=B.length>0?B.reduce((Z,xe)=>{var me,_e;return Z+((_e=(me=xe.measured)==null?void 0:me.height)!=null?_e:0)},0)+Ne:Math.max(se.MIN_HEIGHT,(F=(ie=D.measured)==null?void 0:ie.height)!=null?F:0);let{x:O,y:Y}=ot(D),W={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:W,parentId:void 0}):Z.id===D.id?w(_({},Z),{height:k,measured:w(_({},Z.measured),{height:k})}):Z),V=Xt(V),V};return{onDragOver:P,onDragLeave:R,onDrop:K,onNodeDrag:C,onNodeDragStart:j,onNodeDragStop:Q}};import{useReactFlow as V0}from"@xyflow/react";import{useTranslation as H0}from"@produto-lecom/lecom-ui";import{useEffect as G0}from"react";var B0=30,z0=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},Y0=e=>!z0(e.target),gu=({offset:e=B0,saveHistory:t})=>{let{t:o}=H0(),{getNodes:n,setNodes:r,getEdges:i,setEdges:s}=V0(),{getNextId:a}=st(),{mode:l,containerRef:c}=q();G0(()=>{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"&&Y0(f)){f.preventDefault(),f.stopPropagation();let h=n(),E=i(),p=h.filter(P=>P.selected);if(!p.length)return;let g=new Map,y=[],x=p.filter(P=>Bt(P.type,h));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=a(),v=x.map(P=>{var L;let R=String(b++);g.set(P.id,R);let C=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,Q=Yo(K||o("bpmn.task.label.prefix"),[...h,...y]);C.data=w(_({},P.data),{label:Q})}return y.push(C),C}),T=N.map(P=>w(_({},P),{id:String(b++),selected:!0,source:g.get(P.source)||P.source,target:g.get(P.target)||P.target})),I=[...h.map(P=>w(_({},P),{selected:!1})),...v],S=[...E.map(P=>w(_({},P),{selected:!1})),...T];r(I),s(S),t("forceSave",{nodes:I,edges:S})}};return d.addEventListener("keydown",u,!0),()=>{d.removeEventListener("keydown",u,!0)}},[n,r,i,s,a,e,o,t,l,c])};import{useEffect as W0,useRef as hu}from"react";import{useReactFlow as F0}from"@xyflow/react";var X0=20,U0=50,Ln={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},$0=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",i=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||i},yu=e=>{let{getNodes:t}=F0(),{mode:o,isMoveTool:n}=q(),r=hu(0),i=hu(new Map);W0(()=>{let s=a=>{if(o!=="edit"||!n||$0(a.target)||!Object.values(Ln).includes(a.key))return;let u=t().filter(y=>y.selected);if(u.length===0){i.current.clear();return}a.preventDefault();let f=Date.now(),m=f-r.current<500;r.current=f;let h=a.shiftKey?U0:X0,E=0,p=0;switch(a.key){case Ln.UP:p=-h;break;case Ln.DOWN:p=h;break;case Ln.LEFT:E=-h;break;case Ln.RIGHT:E=h;break}let g=u.map(y=>{let x=i.current.get(y.id);(!m||!x)&&(x={x:y.position.x,y:y.position.y});let N={x:x.x+E,y:x.y+p};return i.current.set(y.id,N),{id:y.id,dragging:!0,type:"position",position:N}});e&&e(g)};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t,e,o,n])};import{useReactFlow as q0}from"@xyflow/react";var Eu={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},_u={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},xu=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],n=e.match(/(\[.*?\])/)||[],r=e.match(/(\{.*?\})/)||[],i=e.match(/(--.*|\|.*?\|)/i)||[],s="",a="",l="";if(o.length){switch(o[1]){case"<start>":s="start-event";break;case"<end>":s="end-event";break}e=e.replace(o[1],"")}return n.length&&(s="task",a=n[1].replace(/\[|\]/g,""),e=e.replace(n[1],"")),r.length&&(s="gateway-exclusive",a=r[1].replace(/\{|\}/g,""),e=e.replace(r[1],"")),s||(s="task",a=e),i.length&&(l=i[1].replace(/(\||--)/g,""),e=e.replace(i[1],"")),e=e.trim(),t[e]||(t[e]={type:s,label:a}),{step:e,type:s,label:a,edgeLabel:l}},K0=e=>{e=e||"";let t=e.trim().split(`
|
|
42
|
-
`),o={},n=[];return t.forEach(r=>{r=r||"";let i=r.trim().split("-->");if(i.length!==2){console.warn("Invalid number of steps");return}let s=xu(i[0],o),a=xu(i[1],o);s&&a&&n.push({sourceId:s.step,targetId:a.step,label:s.edgeLabel||a.edgeLabel||""})}),{components:o,connections:n}},bu=e=>{let{components:t,connections:o}=K0(e);return{nodes:t,edges:o}};var Tu=()=>{let{setNodes:e,setEdges:t}=q0(),{fitToNodes:o}=Fo(),{getNextId:n}=st();return{importFromLia:i=>{let s=typeof i=="string"?i:i.diagramXml||"",{nodes:a,edges:l}=bu(s),c=[],d=new Map,u=!1,f=n();for(let[p,g]of Object.entries(a)){let y=String(f++),x=Eu[g.type],N=_u[g.type];x==="START_EVENT"&&(u=!0),d.set(p,y);let b=ue[x].MIN_WIDTH,v=ue[x].MIN_HEIGHT;c.push({id:y,type:x,data:{label:g.label||"",variant:N,attribute:""},position:{x:0,y:0},width:b,height:v,measured:{width:b,height:v}})}let m=[];for(let p of l){let g=w(_({},rt),{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 y=c[1];if(y){let x=w(_({},rt),{id:String(f++),source:p,target:y.id});m.unshift(x)}}let{nodes:h,edges:E}=od(c,m);e(h),t(E),o(h)}}};import{useCallback as Z0,useEffect as J0}from"react";var Q0={origin:"*",debug:!1};function li(e,t=Q0){let{origin:o,debug:n}=t,r=Z0((i,s)=>{let a={event:i,data:s};window.parent.postMessage(a,o||"*")},[o]);return J0(()=>{if(!e)return;let i=s=>{let a=s.data;if(!(a!=null&&a.event)||(a==null?void 0:a.data)===void 0)return;let{event:l,data:c}=a,d;if(Array.isArray(c)){let[,u]=c;d=u.data}else d=c;n&&(console.debug("[postMessage] received:",a),console.debug("[postMessage] eventData:",d)),l&&e[l]&&e[l](d)};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[e,n]),{sendMessage:r}}import{useNodesInitialized as ex}from"@xyflow/react";import{useEffect as ci,useRef as Ns}from"react";var vu=()=>{let e=ex(),{initialDiagram:t,isNewDiagram:o,setIsInitialized:n,onElementChanges:r}=q(),{importFromMxGraph:i,exportToMxGraph:s}=Xo(),{sendMessage:a}=li(),l=Ns(t),c=Ns(r),d=Ns(s);ci(()=>{c.current=r},[r]),ci(()=>{d.current=s},[s]),ci(()=>{t&&(i(t),l.current=t)},[t,i]),ci(()=>{if(!e)return;(async()=>{var f;if(await Gn(),n(!0),a("INIT_MODELER",l.current),!o){let m=d.current();(f=c.current)==null||f.call(c,m)}})()},[e,o,n,a])};import{useCallback as Nu}from"react";import{useReactFlow as tx}from"@xyflow/react";function wu(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=no(),{getEdges:n}=tx(),r=$n(),i=Nu(a=>{if(!(a!=null&&a.activities))return;e(a.activities);let l=a.activities.map(d=>d.diagramId),c=n();o(c,l),setTimeout(()=>{r()},0)},[e,o,n,r]),s=Nu(()=>{t(),setTimeout(()=>{r()},0)},[t,r]);return{handleTasksStatus:i,handleClearTaskStatus:s}}import{useReactFlow as ox}from"@xyflow/react";import{useCallback as Pt,useState as nx,useEffect as Iu}from"react";import{useDebouncedCallback as rx}from"use-debounce";var ix=500,Au=100,Su=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=ox(),{mode:i,containerRef:s}=q(),[a,l]=nx({history:[],currentStep:0}),{history:c,currentStep:d}=a,u=d>0,f=d<c.length-1,m=Pt((T,I)=>{n(T[I].nodes),r(T[I].edges)},[n,r]),h=Pt(()=>{if(d>0){let T=d-1;l(I=>w(_({},I),{currentStep:T})),m(c,T)}},[d,c,m]),E=Pt(()=>{if(d<c.length-1){let T=d+1;l(I=>w(_({},I),{currentStep:T})),m(c,T)}},[c,d,m]),p=Pt(T=>{l(I=>{let S=I.history[I.currentStep];if(S&&JSON.stringify(S)===JSON.stringify(T))return I;let C=[...I.history.slice(0,I.currentStep+1),T],L=C.length>Au?C.slice(C.length-Au):C;return{history:L,currentStep:L.length-1}})},[]),g=Pt((T,I)=>{let S=T.map(R=>w(_({},R),{selected:!1,className:"",data:w(_({},R.data),{hasError:!1})})),P=I.map(R=>w(_({},R),{data:w(_({},R.data),{hasError:!1})}));return{nodes:Qo(S),edges:P}},[]),y=Pt(()=>g(t(),o()),[t,o,g]),x=rx(()=>{let T=y();p(T)},ix),N=Pt((T,I)=>{if(!e)return;if(c.length===0){let R=y();l({history:[R],currentStep:0})}if(T==="forceSave"){if(I){p(g(I.nodes,I.edges));return}x();return}T.some(R=>R.type==="select")||T.some(R=>R.type==="position"&&R.dragging)||x()},[e,x,c.length,y,p,g]);Iu(()=>{if(e&&c.length===0){let T=y();l({history:[T],currentStep:0})}},[e,c.length,y]);let b=Pt(T=>{l({history:T||[],currentStep:0})},[]),v=Pt(()=>{l({history:[],currentStep:0})},[]);return Iu(()=>{if(i!=="edit")return;let T=s.current;if(!T)return;let I=S=>{if(!T.contains(document.activeElement)||!(S.ctrlKey||S.metaKey))return;let C=S.key.toLowerCase();if(S.shiftKey&&C==="z"){S.preventDefault(),E();return}C==="z"&&(S.preventDefault(),h())};return T.addEventListener("keydown",I),()=>{T.removeEventListener("keydown",I)}},[h,E,i,s]),{history:c,undo:h,redo:E,canUndo:u,canRedo:f,saveHistory:N,resetHistory:b,clearHistory:v}};var Cu=()=>{let{t:e}=sx(),[t,o,n]=lx([]),[r,i,s]=ax([]),{getNodes:a,getNode:l}=dx(),{toast:c}=We(),d=ux(),{instanceId:u,isInitialized:f,setIsConnecting:m,setIsMultipleSelection:h,onElementClick:E}=q(),{updateHelperLines:p,HelperLines:g}=wr(),{undo:y,redo:x,canUndo:N,canRedo:b,saveHistory:v}=Su(f),{onNodeDrag:T,onDrop:I,onDragOver:S,onDragLeave:P,onNodeDragStop:R,onNodeDragStart:C}=mu({nodes:t,setNodes:o,setEdges:i,saveHistory:v}),{isValidConnection:L,onConnect:K,onReconnect:Q,onReconnectStart:j,onReconnectEnd:z,setReconnectingEdge:M,clearReconnectingEdge:V}=eu({setEdges:i,saveHistory:v}),{handleValidationComplete:D,clearValidation:A,dismissValidationPanel:B,validateDiagram:G,getIsClearingValidation:k}=du(),{importFromLia:O}=Tu(),{handleTasksStatus:Y,handleClearTaskStatus:W}=wu(),{clearPathEdges:U}=no(),{emitElementChanges:X,handleNodeChanges:$,handleEdgeChanges:te}=ii(),ie=$n();fu({saveHistory:v}),gu({saveHistory:v}),vu();let F=_t(()=>{o([]),i([]),U(),setTimeout(ie,0)},[o,i,U,ie]),{selectElements:oe,clearSelection:le}=zt(),{importFromMxGraph:Z,exportToMxGraph:xe}=Xo(),{configureElement:me,getConfigureElement:_e}=kr(),J=_t(he=>{he!=null&&he.id&&oe([he.id])},[oe]),{sendMessage:de}=li({LIA_CREATE_DIAGRAM:O,CLEAR_DIAGRAM:F,TASKS_STATUS:Y,CLEAR_TASKS_STATUS:W,EXTERNAL_TASK_SELECT:J}),re=_t(()=>t.length+r.length,[t,r]);px(()=>(Et.set(u,{importFromMxGraph:Z,exportToMxGraph:xe,selectElements:oe,clearSelection:le,configureElement:me,getConfigureElement:_e,getElementsCount:re,setReconnectingEdge:M,clearReconnectingEdge:V}),()=>{Et.delete(u)}),[u,Z,xe,oe,le,me,_e,re,M,V]);let ee=_t((he,fe)=>{if(fe.type!=="TASK"&&fe.type!=="GATEWAY")return;let pe=_e(fe.id);pe&&(E==null||E(pe)),fe.type==="TASK"&&de("SELECT_TASK",{id:fe.id})},[_e,E,de]),ge=_t((he,fe)=>{if(fe.type!=="SEQUENCE_EDGE")return;let pe=l(fe.source),ve=l(fe.target),{isFromStartEvent:Ke,isGatewayToGateway:tt,isActiviyToAndGateway:Be,isToEndEvent:mt}=Un(pe,ve);if(!(!Ke&&!tt&&!Be&&!mt))return;let Tt=_e(fe.id);Tt&&(E==null||E(Tt))},[_e,l,E]),be=_t(he=>{let fe=p(he,t);n(fe),v(he),k()||B(),$(he)},[t,n,v,k,B,p,$]),Te=_t(he=>{s(he),v(he),k()||B(),te(he)},[s,v,k,B,te]);yu(be);let ke=_t(({nodes:he,edges:fe})=>{h(he.length+fe.length>=2)},[h]);cx({onChange:ke});let et=_t(async({nodes:he})=>he.some(pe=>pe.type==="LANE"&&t.some(ve=>ve.parentId===pe.id))?(c({variant:"error",title:e("validation.errors.title"),content:e("editor.toolbar.delete_pool_lane_error")}),!1):!0,[t,e,c]),bt=()=>{v("forceSave"),X(),B()},pt=()=>{m(!0)},ft=()=>{m(!1),B()},$e=_t(he=>{let fe=new Set(he.filter(pe=>pe.type==="LANE"&&!!pe.parentId).map(pe=>pe.parentId));fe.size!==0&&setTimeout(()=>{var Ke,tt;let pe=a(),ve=new Map(pe.map(Be=>[Be.id,Be]));for(let Be of fe){let mt=oo(pe.filter(vt=>vt.type==="LANE"&&vt.parentId===Be));if(mt.length===0)continue;let kt=0;for(let vt of mt)ve.set(vt.id,w(_({},vt),{position:{x:se.HEADER_WIDTH,y:kt}})),kt+=(tt=(Ke=vt.measured)==null?void 0:Ke.height)!=null?tt:0;let Tt=ve.get(Be);Tt&&ve.set(Be,w(_({},Tt),{height:kt,measured:w(_({},Tt.measured),{height:kt})}))}o(pe.map(Be=>{var mt;return(mt=ve.get(Be.id))!=null?mt:Be}))},0)},[a,o]);return{nodes:t,setNodes:o,edges:r,setEdges:i,events:{isValidConnection:L,onConnect:K,onReconnect:Q,onReconnectStart:j,onReconnectEnd:z,onDrop:I,onDragOver:S,onDragLeave:P,onNodeDrag:T,onNodeDragStop:R,onNodeDragStart:C,onNodeClick:ee,onEdgeClick:ge,onDropCapture:bt,onConnectStart:pt,onConnectEnd:ft,onSelectionEnd:()=>setTimeout(()=>d.setState({nodesSelectionActive:!1}),0),onNodesChange:be,onEdgesChange:Te,onBeforeDelete:et,onNodesDelete:$e},ui:{handleCloseValidationPanel:A},controls:{undo:y,redo:x,canUndo:N,canRedo:b},components:{HelperLines:g},actions:{saveHistory:v,selectElements:oe,clearSelection:le,exportToMxGraph:xe,validateDiagram:G,handleValidationComplete:D,setReconnectingEdge:M,clearReconnectingEdge:V}}};import{useReactFlow as fx}from"@xyflow/react";import{useCallback as mx,useEffect as gx,useRef as hx,useState as yx}from"react";var xx=".react-flow__node, .react-flow__edge, .react-flow__node-toolbar";function Mu(e,t,o){let[n,r]=yx(!1),i=hx(null),{getViewport:s,setViewport:a}=fx(),l=mx(()=>{i.current=null,r(!1)},[]);return gx(()=>{let c=e.current;if(!c)return;let d=m=>{if(!An.some(E=>E===m.button)||t.current||o.current||(r(!0),!(m.target instanceof Element))||!m.target.closest(xx))return;m.preventDefault(),m.stopPropagation();let h=s();i.current={pointerX:m.clientX,pointerY:m.clientY,viewportX:h.x,viewportY:h.y,zoom:h.zoom}},u=m=>{let h=i.current;if(h){if((m.buttons&vs)===0){l();return}a({x:h.viewportX+(m.clientX-h.pointerX),y:h.viewportY+(m.clientY-h.pointerY),zoom:h.zoom})}},f=m=>{(m.buttons&vs)===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,s,a,l]),n}import{jsx as Pu}from"react/jsx-runtime";var di=({id:e,className:t})=>Pu("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:Pu("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as ui,jsxs as Ex}from"react/jsx-runtime";var Lu=()=>ui("svg",{style:{position:"absolute",top:0,left:0},children:Ex("defs",{children:[ui(di,{id:"sequence-edge-marker",className:"text-grey-500"}),ui(di,{id:"sequence-edge-marker-hovered",className:"text-grey-800"}),ui(di,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{Tooltip as XE,TooltipContent as UE,TooltipTrigger as $E,useTranslation as KE}from"@produto-lecom/lecom-ui";import{useKeyPress as Ju,useReactFlow as dE}from"@xyflow/react";import{Button as xi,Tooltip as Ei,TooltipContent as _i,TooltipTrigger as bi,useTranslation as uE}from"@produto-lecom/lecom-ui";import{HandIcon as pE,ListCheckIcon as fE,Loader2Icon as mE,MapIcon as gE,MousePointerIcon as hE}from"lucide-react";import{useCallback as Ss,useEffect as Qu,useState as yE}from"react";import{Tooltip as Gx,TooltipContent as Bx,TooltipTrigger as zx,useTranslation as Yx}from"@produto-lecom/lecom-ui";var kn=(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))(kn||{});import{Button as Px,useTranslation as Lx}from"@produto-lecom/lecom-ui";import{useReactFlow as kx}from"@xyflow/react";var ku=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 Ru({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let r="data:text/csv;charset=utf-8,"+[e,...t].map(s=>s.join(",")).join(`
|
|
43
|
-
`),i=encodeURI(r);
|
|
38
|
+
</mxGraphModel>`,zc=(e,t)=>{if(!e.length&&!t.length)return Nn;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};import{xml2json as Rh,json2xml as Dh}from"xml-js";var Yc={compact:!0,spaces:4},Oh=e=>e.replace(/\n/g,"
");function Zr(e,t=Yc){if(e)return JSON.parse(Rh(e,t))}function Fc(e,t=Yc){return e?Dh(e,w(_({},t),{attributeValueFn:Oh})):""}var Wc={"attribute-loop":"LOOP"},Xc={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS","service-task":"SERVICE_TASK"},Uc={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},$c={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed",SERVICE_TASK:"service-task"},Kc={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var Go=(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(Rt(Number(a),t),l),u=Math.max(Rt(Number(s),o),c);return{width:d,height:u,measured:{width:d,height:u}}},Bo=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=Bo(e),n=Go(t,ue.START_EVENT.MIN_WIDTH,ue.START_EVENT.MIN_HEIGHT);return w(_(_({},o),n),{type:"START_EVENT"})},Gh=e=>{let{mxGeometry:t}=e,o=Bo(e),n=Go(t,ue.END_EVENT.MIN_WIDTH,ue.END_EVENT.MIN_HEIGHT);return w(_(_({},o),n),{type:"END_EVENT"})},Jr=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=Bo(e),s=Go(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=Wc[d];u&&(r.data.attribute=u)}let c=Xc[o.style];return c&&(r.data.variant=c),w(_(_({},r),s),{type:"TASK"})},ps=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=Bo(e),i=Go(o,ue.GATEWAY.MIN_WIDTH,ue.GATEWAY.MIN_HEIGHT);return r.data.variant=Uc[n],w(_(_({},r),i),{type:"GATEWAY"})},Bh=e=>{let{mxGeometry:t}=e,o=Bo(e),i=Go(t,ue.ANNOTATION.MIN_WIDTH,ue.ANNOTATION.MIN_HEIGHT,o.data.label,32,24);return w(_(_({},o),i),{type:"ANNOTATION"})},zh=e=>{let{mxGeometry:t}=e,o=Bo(e),n=Go(t,ue.LANE.MIN_WIDTH,ue.LANE.MIN_HEIGHT);return w(_(_({},o),n),{type:"LANE"})},qc={task:Jr,"task-script":Jr,"subprocess-collapsed":Jr,"service-task":Jr,"start-event":Hh,"end-event-terminate":Gh,"gateway-parallel":ps,"gateway-exclusive":ps,"gateway-complex":ps,annotation:Bh,lane:zh},Yh=e=>{if(e&&Array.isArray(e))return e.map(t=>({x:Number(t._attributes.x),y:Number(t._attributes.y)}))},Zc=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=Yh(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=""')?_(_({},Ro),x):_(_({},rt),x)},Jc=(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}},zo=e=>{let{id:t,parentId:o,position:n,measured:r,data:i}=e;return{_attributes:{id:t,parent:o||"1",value:i.label,vertex:"1"},mxGeometry:{_attributes:{as:"geometry",width:(r==null?void 0:r.width)||0,height:(r==null?void 0:r.height)||0,x:n.x||0,y:n.y||0}}}},Fh=e=>{let{variant:t}=e.data,o=zo(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:$c[t]||"task"})})},Wh=e=>{let t=zo(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"start-event"})})},Xh=e=>{let t=zo(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"end-event-terminate"})})},Uh=e=>{let{variant:t}=e.data,o=zo(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:Kc[t]})})},$h=e=>{let t=zo(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"lane"})})},Kh=e=>{let t=zo(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"annotation"})})},Qc={TASK:Fh,START_EVENT:Wh,END_EVENT:Xh,GATEWAY:Uh,ANNOTATION:Kh,LANE:$h},jc=(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 qh=e=>{let t=Object.values(vn),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=qc[a],l=s==null?void 0:s(i,n);if(!l){console.warn(`Node ${a} not supported`);continue}r.push(l)}return r},Zh=(e,t)=>{let o=e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}),n=[];for(let r of o){let i=Zc(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},Jh=(e,t)=>{let o=[];return e.forEach(n=>{var a,s;let r=(s=(a=Qc)[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=jc(n,t);o.push(l)}}),o},Qh=(e,t)=>{let o=[];return e.forEach(n=>{let r=Jc(n,t);o.push(r)}),o},jh=(e=[],t=[],o)=>{let n=Jh(e,o),r=Qh(t,e);return{mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}}},ed=(e=[],t=[],o)=>{let n=jh(e,t,o);return Fc(JSON.stringify(n),{compact:!0,spaces:0})},td=async e=>{var a,s,l,c,d;let t=await Zr(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)||Nn),r=qh(o),i=Zh(o,r);return{lastElementId:n,edges:i,nodes:r}};import{useReactFlow as v0,useStoreApi as N0}from"@xyflow/react";import{useCallback as w0}from"react";import{Position as Ut,useConnection as zy,useReactFlow as Yy}from"@xyflow/react";import{useCallback as xs}from"react";import{Handle as od,useReactFlow as ey}from"@xyflow/react";import{jsx as nd}from"react/jsx-runtime";var ne=i=>{var a=i,{type:e,position:t,className:o,nodeType:n}=a,r=gt(a,["type","position","className","nodeType"]);let s=n==="TASK";return nd(od,_({type:e,position:t,className:H("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":s,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":!s},o)},r))},Ge=s=>{var l=s,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,a=gt(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=ey(),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 nd(od,_({type:n,position:r,className:H("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":f,"hover:border-grey-500":!f},i),style:{pointerEvents:f?"none":"auto"}},a))};import{useRef as ld}from"react";import{NodeResizeControl as cd,ResizeControlVariant as ay,useReactFlow as ly,useStoreApi as cy}from"@xyflow/react";import{useStoreApi as ty}from"@xyflow/react";var Qr=()=>{let e=ty();return{getInternalNodes:()=>{let{nodeLookup:o}=e.getState();return Array.from(o.values())}}};import rd from"@dagrejs/dagre";import{getNodesBounds as jr}from"@xyflow/react";var sd=(e=[],t=[],o="LR")=>{let n=new rd.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)),rd.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}},Xt=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId);if(t.length===0)return e;let o=aa(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){fa(a,o,r),ma(n,o);continue}zi(n,i,o)}return la(e,o)};var ad=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)};var oy=500;var ny=e=>e.type==="LANE"&&!e.parentId,ry=(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},iy=(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)},sy=e=>{let t=new Set;for(let o of e)t.add(o.source),t.add(o.target);return t},id=(e,t,o)=>{if(e.type!=="ANNOTATION"||o.has(e.id))return!1;let n=jr([e]);return iy(t,n)>oy},fs=(e,t=[])=>{var E;let o=e.filter(ny);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=sy(t),l=a.filter(p=>p.type!=="ANNOTATION"),c=jr(l.length>0?l:a),d=a.filter(p=>!id(p,c,s)),u=jr(d),y=e.filter(p=>!r.has(p.id)).filter(p=>{let g=jr([p]);return!ry(u,g)}).filter(p=>!id(p,u,s));return[...d,...y]};import{Fragment as py,jsxs as fy}from"react/jsx-runtime";import{createElement as dd}from"react";var dy=["top","right","bottom","left"],uy=["top-left","top-middle","top-right","right-middle","bottom-left","left-middle","bottom-right","bottom-middle"],it=r=>{var i=r,{nodeId:e,isVisible:t,offset:o=8}=i,n=gt(i,["nodeId","isVisible","offset"]);let{getInternalNode:a,setNodes:s}=ly(),{getInternalNodes:l}=Qr(),{isMultipleSelection:c}=q(),d=cy(),u=ld(0),f=ld([]),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=oo(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-se.HEADER_WIDTH:h,G=I;v&&D&&(G=Math.max(se.MIN_HEIGHT,x-S)),K&&z===L-1&&(G=Math.max(se.MIN_HEIGHT,g-S)),R.push({id:M.id,type:"dimensions",dimensions:{width:B,height:G},setAttributes:!0}),R.push({id:M.id,type:"position",position:{x:se.HEADER_WIDTH,y:S}}),S+=G}v?R.push({id:A,type:"dimensions",dimensions:{width:h,height:x},setAttributes:!0}):R.push({id:A,type:"dimensions",dimensions:{width:h+se.HEADER_WIDTH,height:S},setAttributes:!0}),b==null||b(R)})},y=({y:g,width:h,height:x})=>{var 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=Xt(b),s(b);return}b=ga(N,h,x,b,g),b=Xt(b),b=to((T=N.parentId)!=null?T:N.id,b),s(b)};if(!(!c&&t))return null;let p={"--resize-offset":`${o}px`};return fy(py,{children:[dy.map(g=>dd(cd,w(_({},n),{key:g,nodeId:e,position:g,variant:ay.Line,className:"border-blue-400/90 border-dashed",style:p,onResize:(h,x)=>m(x),onResizeEnd:(h,x)=>y(x)}))),uy.map(g=>dd(cd,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)})))]})};import{NodeToolbar as Py,useReactFlow as Ly}from"@xyflow/react";import{Button as ky,Tooltip as Ry,TooltipContent as Dy,TooltipTrigger as Oy,useTranslation as Vy}from"@produto-lecom/lecom-ui";import{useCallback as ys,useEffect as Hy,useRef as ei,useState as Gy}from"react";import{create as my}from"zustand";var Yo=my(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{useEffect as gy,useState as hy}from"react";var ud=(e,t=!1)=>{let[o,n]=hy({width:0,height:0});return gy(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};import{Position as wn,useReactFlow as yy}from"@xyflow/react";import{useMemo as xy}from"react";var Ey=120,_y=12,pd=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=yy(),{instanceId:i}=q();return xy(()=>{var m,y;if(!t)return{position:wn.Right,align:"start"};let a=n(e);if(!a)return{position:wn.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:wn.Right,align:"start"};let u=(o==null?void 0:o.width)||Ey;return{position:l+c+u+_y>d?wn.Left:wn.Right}},[i,e,t,o,n,r])};import{Bot as gd}from"lucide-react";import{useNodesData as by,useReactFlow as Ty}from"@xyflow/react";import{Button as fd,DropdownMenu as vy,DropdownMenuContent as Ny,DropdownMenuGroup as wy,DropdownMenuItem as Ay,DropdownMenuLabel as Iy,DropdownMenuTrigger as Cy,Tooltip as ms,TooltipContent as gs,TooltipTrigger as hs,useTranslation as Sy}from"@produto-lecom/lecom-ui";import{WrenchIcon as My}from"lucide-react";import{jsx as Oe,jsxs as fo}from"react/jsx-runtime";var md=({nodeId:e})=>{let{t}=Sy(),{updateNodeData:o,getEdges:n,getNode:r}=Ty(),i=by(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 fo(vy,{children:[fo(ms,{children:[Oe(hs,{asChild:!0,children:Oe(Cy,{asChild:!0,children:Oe(fd,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:Oe(My,{})})})}),Oe(gs,{color:"black",children:t("bpmn.task.menu.title")})]}),fo(Ny,{align:"start",className:"w-60 bg-white text-grey-600",children:[fo(Iy,{className:"flex items-center gap-1",children:[Oe("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),Oe("div",{className:"flex items-center gap-1",children:Object.entries(Xn).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 fo(ms,{children:[Oe(hs,{asChild:!0,children:Oe(fd,{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:Oe(m.icon,{className:"stroke-inherit"})})}),p&&Oe(gs,{color:"black",children:p})]},f)})})]}),Oe(wy,{children:fo(ms,{children:[Oe(hs,{asChild:!0,children:Oe("div",{className:H({"cursor-not-allowed":s}),children:fo(Ay,{className:H({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":s}),disabled:s,onClick:()=>d("SCRIPT"),children:[Oe(Wn.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),s&&Oe(gs,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};import{jsx as Pe,jsxs as hd}from"react/jsx-runtime";var St={START_EVENT:{type:"START_EVENT",icon:qo,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:_o,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:qo,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:Bn,label:"bpmn.annotation.variant.default"}},By={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:To,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:vo,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:bo,label:"bpmn.gateway.variant.complex"}},We=({nodeId:e,nodeType:t,nodeVariant:o,isChild:n})=>{let r=ei(null),i=ei(null),{t:a}=Vy(),{setDraggableNode:s}=Yo(),{getEdges:l,getNodes:c,getNode:d,setNodes:u}=Ly(),{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}=ud(r,h),{position:N}=pd(e,h,x),[b,T]=Gy(void 0),v=c(),A=l(),C=o==="SUBPROCESS",P=o==="SERVICE_TASK",R=ei(null),S=ei(!1),L=ys(()=>{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]);Hy(()=>{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=ys((F,U)=>{S.current=!0,f(!1),s({type:U.type,variant:U.variant,attribute:U.attribute,icon:U.icon}),U.icon&&T(Pe(U.icon,{})),F.dataTransfer.effectAllowed="move",F.dataTransfer.setData("sourceId",e),i.current&&F.dataTransfer.setDragImage(i.current,10,10),R.current=setTimeout(()=>{R.current=null,f(!0)},100)},[e,s,f]),j=ys(()=>{L()},[L]),Q=[{component:Pe(Hr,{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:Pe(Po,{nodeId:e,disabled:!F,tooltipMessage:F?void 0:a("editor.toolbar.start_event_limit_reached")})},St.TASK,St.ANNOTATION,...Q]},M=()=>m==="view"?[{component:Pe(Yt,{elementId:e})}]:[{component:Pe(Yt,{elementId:e})},...C||P?[]:[{component:Pe(md,{nodeId:e})}],{component:Pe(Po,{nodeId:e})},St.TASK,{type:"TASK",variant:"SUBPROCESS",icon:Jo,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:gd,label:"bpmn.task.variant.service_task"},St.ANNOTATION,...Object.values(By),...co(e,v,A)?[]:[St.END_EVENT],...Q],V=()=>m==="view"?[{component:Pe(Yt,{elementId:e,elementType:"gateway"})}]:[{component:Pe(Yt,{elementId:e,elementType:"gateway"})},{component:Pe(Po,{nodeId:e})},St.TASK,{type:"TASK",variant:"SUBPROCESS",icon:Jo,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:gd,label:"bpmn.task.variant.service_task"},St.ANNOTATION,...Q],D=()=>m==="view"?[]:[St.ANNOTATION,...Q],I=()=>m==="view"?[]:[...n?[]:[{component:Pe(Po,{nodeId:e})}],St.ANNOTATION,...Q],B=()=>m==="view"?[]:[{component:Pe(Po,{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 hd(Py,{position:N,align:"start",className:Y?"-top-[4.5rem]":"-top-8",isVisible:h,children:[Pe("div",{ref:r,className:`${Y?"grid grid-cols-6":"flex"} gap-1 px-2 py-2 bg-white rounded-sm shadow-md`,children:O.map((F,U)=>{if(F.component)return Pe("div",{children:F.component},U);let X={sourceNodeType:t,targetNodeType:F.type,sourceNodeId:e,nodes:v,edges:A},$=xc(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 hd(Ry,{children:[Pe(Oy,{asChild:!0,children:Pe(ky,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!$.shouldDisable,disabled:$.shouldDisable,className:$.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:$.shouldDisable?void 0:W=>K(W,F),onDragEnd:$.shouldDisable?void 0:j,children:F.icon&&Pe(F.icon,{size:16})})}),Pe(Dy,{color:"black",children:ie})]},U)})}),Pe("div",{ref:i,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:b})]})};import{Fragment as yd,jsx as dt,jsxs as Es}from"react/jsx-runtime";var xd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r,setNodes:i}=Yy(),{inProgress:a,fromNode:s}=zy(),{mode:l,isReadOnly:c}=q(),d=a&&(s==null?void 0:s.id)!==e,u=xs(y=>{let x=y.split(`
|
|
40
|
+
`),N=x.reduce((A,C)=>Math.max(A,C.length),0),b=x.length,T=Math.max(wo.MIN_WIDTH,N*7+32),v=Math.max(wo.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=xs(y=>{r(e,{label:y}),u(y)},[e,r,u]),m=xs(y=>{u(y)},[u]);return Es("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:[dt(De,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:f,onInput:m,skipFirstCharValidation:!0}),dt(We,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&dt(it,{nodeId:e,minWidth:wo.MIN_WIDTH,minHeight:wo.MIN_HEIGHT,isVisible:!n&&o}),!a&&Es(yd,{children:[dt(ne,{type:"source",position:Ut.Left,id:"left"}),dt(ne,{type:"source",position:Ut.Right,id:"right"}),dt(ne,{type:"source",position:Ut.Top,id:"top"}),dt(ne,{type:"source",position:Ut.Bottom,id:"bottom"})]}),(!a||d)&&Es(yd,{children:[dt(ne,{type:"target",position:Ut.Left,id:"left",className:H({"annotation-handle":d})}),dt(ne,{type:"target",position:Ut.Right,id:"right",className:H({"annotation-handle":d})}),dt(ne,{type:"target",position:Ut.Top,id:"top",className:H({"annotation-handle":d})}),dt(ne,{type:"target",position:Ut.Bottom,id:"bottom",className:H({"annotation-handle":d})})]})]})};import{Position as $t,useConnection as Fy,useReactFlow as Wy}from"@xyflow/react";import{useState as Xy}from"react";import{Fragment as Ed,jsx as Ze,jsxs as _s}from"react/jsx-runtime";var _d=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=Wy(),{inProgress:i,fromNode:a}=Fy(),{mode:s,isReadOnly:l,reconnectingEdgeId:c}=q(),[d,u]=Xy(!1),f=i&&(a==null?void 0:a.id)!==e||!!c,m=p=>{r(e,{label:p})},y=()=>{u(!0)},E=()=>{u(!1)};return _s("div",{className:"relative",onDoubleClick:y,children:[Ze(_o,{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})}),Ze("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Ze(De,{value:t.label,isEditing:d,onBlur:E,onChange:m})}),Ze(We,{nodeId:e,nodeType:"END_EVENT"}),s==="edit"&&Ze(it,{nodeId:e,isVisible:!n&&o,minWidth:$n.MIN_WIDTH,minHeight:$n.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||f)&&_s(Ed,{children:[Ze(ne,{type:"target",position:$t.Left,id:"left",className:H({"event-handle":f})}),Ze(ne,{type:"target",position:$t.Right,id:"right",className:H({"event-handle":f})}),Ze(ne,{type:"target",position:$t.Top,id:"top",className:H({"event-handle":f})}),Ze(ne,{type:"target",position:$t.Bottom,id:"bottom",className:H({"event-handle":f})})]}),!i&&_s(Ed,{children:[Ze(ne,{type:"source",position:$t.Left,id:"left"}),Ze(ne,{type:"source",position:$t.Right,id:"right"}),Ze(ne,{type:"source",position:$t.Top,id:"top"}),Ze(ne,{type:"source",position:$t.Bottom,id:"bottom"})]})]})};import{Position as Kt,useConnection as Uy,useReactFlow as $y}from"@xyflow/react";import{useCallback as Ky,useState as qy}from"react";import{Fragment as bd,jsx as Je,jsxs as bs}from"react/jsx-runtime";var Td=({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let a=Gi[t.variant].icon,{updateNodeData:s}=$y(),{inProgress:l,fromNode:c}=Uy(),{mode:d,isReadOnly:u,reconnectingEdgeId:f}=q(),[m,y]=qy(!1),E=l&&(c==null?void 0:c.id)!==e||!!f,p=Ky(x=>{s(e,{label:x})},[e,s]),g=()=>{y(!0)},h=()=>{y(!1)};return bs("div",{className:"relative",style:{width:o!=null?o:No.MIN_WIDTH,height:n!=null?n:No.MIN_HEIGHT},onDoubleClick:g,children:[Je(a,{className:H("w-full h-full min-w-14 min-h-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"pointer-events-none":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})}),Je("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Je(De,{value:t.label,isEditing:m,onBlur:h,onChange:p})}),Je(We,{nodeId:e,nodeType:"GATEWAY",nodeVariant:t.variant}),d==="edit"&&Je(it,{nodeId:e,isVisible:!i&&r,minWidth:No.MIN_WIDTH,minHeight:No.MIN_HEIGHT,offset:2,keepAspectRatio:!0}),(!l||E)&&bs(bd,{children:[Je(ne,{type:"target",position:Kt.Left,id:"left",className:H({"gateway-handle":E})}),Je(ne,{type:"target",position:Kt.Right,id:"right",className:H({"gateway-handle":E})}),Je(ne,{type:"target",position:Kt.Top,id:"top",className:H({"gateway-handle":E})}),Je(ne,{type:"target",position:Kt.Bottom,id:"bottom",className:H({"gateway-handle":E})})]}),!l&&bs(bd,{children:[Je(Ge,{type:"source",position:Kt.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Je(Ge,{type:"source",position:Kt.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Je(Ge,{type:"source",position:Kt.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Je(Ge,{type:"source",position:Kt.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})};import{useNodesData as iP,useReactFlow as sP}from"@xyflow/react";import{Button as lP,DropdownMenu as cP,DropdownMenuContent as dP,DropdownMenuGroup as uP,DropdownMenuItem as pP,DropdownMenuLabel as fP,DropdownMenuTrigger as mP,Tooltip as gP,TooltipContent as hP,TooltipTrigger as yP,useTranslation as xP}from"@produto-lecom/lecom-ui";import{WrenchIcon as _P}from"lucide-react";import{jsx as NP,jsxs as wP}from"react/jsx-runtime";import{Position as qt,useConnection as Zy,useReactFlow as Jy}from"@xyflow/react";import{useState as Qy}from"react";import{Fragment as vd,jsx as Qe,jsxs as Ts}from"react/jsx-runtime";var Nd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=Jy(),{inProgress:i,fromNode:a}=Zy(),{mode:s,isReadOnly:l,reconnectingEdgeId:c}=q(),[d,u]=Qy(!1),f=i&&(a==null?void 0:a.id)!==e||!!c,m=p=>{r(e,{label:p})},y=()=>{u(!0)},E=()=>{u(!1)};return Ts("div",{className:"relative",onDoubleClick:y,children:[Qe(Yn,{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})}),Qe("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Qe(De,{value:t.label,isEditing:d,onBlur:E,onChange:m})}),Qe(We,{nodeId:e,nodeType:"START_EVENT"}),s==="edit"&&Qe(it,{nodeId:e,isVisible:!n&&o,minWidth:Un.MIN_WIDTH,minHeight:Un.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||f)&&Ts(vd,{children:[Qe(ne,{type:"target",position:qt.Left,id:"left",className:H({"event-handle":f})}),Qe(ne,{type:"target",position:qt.Right,id:"right",className:H({"event-handle":f})}),Qe(ne,{type:"target",position:qt.Top,id:"top",className:H({"event-handle":f})}),Qe(ne,{type:"target",position:qt.Bottom,id:"bottom",className:H({"event-handle":f})})]}),!i&&Ts(vd,{children:[Qe(Ge,{type:"source",position:qt.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),Qe(Ge,{type:"source",position:qt.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),Qe(Ge,{type:"source",position:qt.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),Qe(Ge,{type:"source",position:qt.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};import{useTranslation as t0}from"@produto-lecom/lecom-ui";import{Position as Zt,useConnection as o0,useReactFlow as n0}from"@xyflow/react";import{useCallback as oi}from"react";var An=60,ti=(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<=An?i:i.substring(0,An).trim()},Fo=(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>An&&(n=n.substring(0,An).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=An-l.length,u=`${r.substring(0,c).trim()}${l}`;if(!o.has(u))return u;i++}return n};import{jsx as wd,jsxs as jy}from"react/jsx-runtime";var Ad=e=>jy("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[wd("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),wd("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as Id}from"react/jsx-runtime";var Cd=e=>Id("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:Id("path",{d:"M12 2C8.13 2 5 5.13 5 9C5 14.25 12 22 12 22C12 22 19 14.25 19 9C19 5.13 15.87 2 12 2ZM12 11.5C10.62 11.5 9.5 10.38 9.5 9C9.5 7.62 10.62 6.5 12 6.5C13.38 6.5 14.5 7.62 14.5 9C14.5 10.38 13.38 11.5 12 11.5Z",fill:"#38bdf8"})}));import{jsx as Sd,jsxs as e0}from"react/jsx-runtime";var Md=e=>e0("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[Sd("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),Sd("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{Fragment as ni,jsx as we,jsxs as In}from"react/jsx-runtime";var r0={APROVADO:Ad,EM_ANDAMENTO:Cd,REJEITADO:Md},vs={APROVADO:"border-green-500 hover:border-green-500 border-[3px] border-solid",EM_ANDAMENTO:"border-turquoise-400 hover:border-turquoise-400 border-[3px] border-solid",REJEITADO:"border-red-500 hover:border-red-500 border-[3px] border-solid",default:"border-grey-400 border-2 border-solid",error:"border-red-500 border-[3px] shadow-[0_0_5px_rgba(255,0,0,0.5)]"},i0={APROVADO:"bg-green-50",EM_ANDAMENTO:"bg-turquoise-50",REJEITADO:"bg-red-50"},Pd=({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let{t:a}=t0(),{toast:s}=Fe(),{updateNodeData:l,getNodes:c,setNodes:d}=n0(),{inProgress:u,fromNode:f}=o0(),{mode:m,isReadOnly:y,onSubprocessValidationClick:E,reconnectingEdgeId:p}=q(),{getTaskStatus:g}=no(),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=oi(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(Dt.MIN_WIDTH,k*7+64),F=Math.max(Dt.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=oi(M=>{let V=M.trim(),D=t.label||"";if(V===D)return;let I=V,B=c();if(!(V&&V!=="")){I=ti(B,a("bpmn.task.label.prefix")),l(e,{label:I}),A(I),s({variant:"warning",content:In(ni,{children:[a("bpmn.task.feedback.label_empty.prefix")," ",we("strong",{children:I})]})});return}let k=Fo(I,B);k===D||(l(e,{label:k}),A(k),k!==I&&s({variant:"warning",content:In(ni,{children:[a("bpmn.task.feedback.label_already_exists.prefix")," ",we("strong",{children:V})," ",a("bpmn.task.feedback.label_already_exists.middle")," ",we("strong",{children:k})]})}))},[t.label,c,e,a,l,A,s]),P=oi(M=>{A(M)},[A]),R=oi(()=>{s({variant:"error",content:a("bpmn.task.feedback.invalid_first_character")})},[a,s]),S=x?r0[x]:null,L=t.variant?Wn[t.variant].icon:null,K=t.attribute?Xn[t.attribute].icon:null,j=()=>t.hasError?vs.error:x?vs[x]:y?vs.default:"",Q=()=>{var M;return r&&(M=i0[x])!=null?M:""},z=()=>{E==null||E({id:e,type:"sub_process",label:t.label})};return In("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:Dt.MIN_WIDTH,height:n!=null?n:Dt.MIN_HEIGHT},children:[we("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:we(De,{value:t.label,maxLength:60,className:H(Q(),{"py-10 px-8":T||v}),onChange:C,onInput:P,onInvalidFirstCharacter:R})}),L&&we("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:we(L,{size:b?20:16,className:H(t.hasError?"text-red-500":"text-grey-500",N&&"cursor-pointer"),onClick:N?z:void 0})}),K&&we("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:we("div",{className:H("flex items-center w-16 p-1",N||b?"justify-between":"justify-center"),children:we(K,{size:16,className:H(t.hasError?"text-red-500":"text-grey-500")})})}),S&&we("div",{className:"absolute top-0 right-0 flex items-center p-1",children:we(S,{})}),we(We,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),m==="edit"&&we(it,{nodeId:e,isVisible:!i&&r,minWidth:Dt.MIN_WIDTH,minHeight:Dt.MIN_HEIGHT}),(!u||h)&&In(ni,{children:[we(ne,{type:"target",position:Zt.Left,id:"left",className:H({"task-handle":h})}),we(ne,{type:"target",position:Zt.Right,id:"right",className:H({"task-handle":h})}),we(ne,{type:"target",position:Zt.Top,id:"top",className:H({"task-handle":h})}),we(ne,{type:"target",position:Zt.Bottom,id:"bottom",className:H({"task-handle":h})})]}),!u&&In(ni,{children:[we(Ge,{type:"source",position:Zt.Left,id:"left",nodeId:e,nodeType:"TASK"}),we(Ge,{type:"source",position:Zt.Right,id:"right",nodeId:e,nodeType:"TASK"}),we(Ge,{type:"source",position:Zt.Top,id:"top",nodeId:e,nodeType:"TASK"}),we(Ge,{type:"source",position:Zt.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})};import{Position as Ld}from"@xyflow/react";import{Fragment as s0,jsx as ri,jsxs as a0}from"react/jsx-runtime";var kd=({id:e,data:t})=>a0(s0,{children:[ri("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}),ri(We,{nodeId:e,nodeType:"UNSUPPORTED"}),ri(ne,{type:"source",position:Ld.Right}),ri(ne,{type:"target",position:Ld.Left})]});import{BaseEdge as l0,EdgeLabelRenderer as c0,getSmoothStepPath as d0,MarkerType as u0,useInternalNode as Rd,useReactFlow as p0,useViewport as f0,Position as Wo}from"@xyflow/react";import{useState as m0,useMemo as g0}from"react";import{Fragment as Dd,jsx as Xe,jsxs as mo}from"react/jsx-runtime";var cL={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:u0.Arrow},data:{label:""}},Od=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var G;let{zoom:c}=f0(),{updateEdgeData:d}=p0(),{isMultipleSelection:u,mode:f,instanceId:m}=q(),y=f!=="edit",[E,p]=m0(!1),{reconnectingHandle:g,cursorPosition:h,hoveredNodeId:x,reconnectingSide:N,isValidReconnection:b,handleReconnectStart:T}=$r({edgeId:e,source:t,target:o,instanceId:m,isReadOnly:y}),v=Rd(t),A=Rd(o),{sx:C,sy:P,tx:R,ty:S,sourcePos:L,targetPos:K}=g0(()=>{var oe,le;if(!v||!A)return{sx:0,sy:0,tx:0,ty:0,sourcePos:Wo.Left,targetPos:Wo.Right};let k=Ao(v,A),O=s?i:k.sourcePos,Y=l?a:k.targetPos,F=(Z,xe,me)=>{var ee,ge,be,Te,ke,et;let{x:_e,y:J}=Z.internals.positionAbsolute,de=(be=(ge=(ee=Z.measured)==null?void 0:ee.width)!=null?ge:Z.width)!=null?be:0,re=(et=(ke=(Te=Z.measured)==null?void 0:Te.height)!=null?ke:Z.height)!=null?et:0;switch(xe){case Wo.Top:return{x:_e+de*me,y:J};case Wo.Bottom:return{x:_e+de*me,y:J+re};case Wo.Left:return{x:_e,y:J+re*me};case Wo.Right:return{x:_e+de,y:J+re*me};default:return{x:_e+de/2,y:J+re/2}}},U=(oe=n==null?void 0:n.sourceOffset)!=null?oe:.5,X=(le=n==null?void 0:n.targetOffset)!=null?le:.5,$=v?F(v,O,U).x:k.sx,te=v?F(v,O,U).y:k.sy,ie=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]=d0({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 Xe(Dd,{children:mo("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":M}),onDoubleClick:()=>!y&&p(!0),children:[Xe("path",{d:j,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),mo("g",{className:H("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":M}),children:[Xe(l0,{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})}),mo(c0,{children:[mo("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${Q}px, ${z}px)`},children:[r&&!u&&Xe(ko,{sx:C,sy:P,tx:R,ty:S,hasLabel:!!((G=n==null?void 0:n.label)!=null&&G.trim()),children:Xe(Lo,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),D&&Xe(De,{value:n==null?void 0:n.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:E,onBlur:I,onChange:B})]}),r&&!u&&!y&&mo(Dd,{children:[Xe("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${C}px, ${P}px)`},children:mo("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Xe("circle",{cx:6/c,cy:6/c,r:4/c,fill:g==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Xe("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:g==="source"?.6:.3,className:"pointer-events-none"}),Xe("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!g||g!=="source","cursor-not-allowed":g==="source"&&x&&!b,"cursor-grabbing":g==="source"&&(!x||b)}),onMouseDown:k=>T("source",k.nativeEvent)})]})}),Xe("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${R}px, ${S}px)`},children:mo("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Xe("circle",{cx:6/c,cy:6/c,r:4/c,fill:g==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Xe("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:g==="target"?.6:.3,className:"pointer-events-none"}),Xe("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!g||g!=="target","cursor-not-allowed":g==="target"&&x&&!b,"cursor-grabbing":g==="target"&&(!x||b)}),onMouseDown:k=>T("target",k.nativeEvent)})]})})]})]})]})]})})};import{getStraightPath as h0,Position as ii}from"@xyflow/react";import{jsx as Vd,jsxs as y0}from"react/jsx-runtime";var Hd=({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:ii.Left},{x:n+a,y:r+s/2,pos:ii.Right},{x:n+a/2,y:r,pos:ii.Top},{x:n+a/2,y:r+s,pos:ii.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]=h0({sourceX:c.x,sourceY:c.y,targetX:e,targetY:t});return y0("g",{className:"group",children:[Vd("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d}),Vd("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})};import{Position as Jt,useConnection as x0,useReactFlow as E0}from"@xyflow/react";import{orderBy as _0}from"lodash";import{useMemo as Gd,useState as b0}from"react";import{Fragment as Ns,jsx as Ue,jsxs as si}from"react/jsx-runtime";var Bd=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{var v;let{updateNodeData:i,getNodes:a}=E0(),{mode:s,isReadOnly:l}=q(),{inProgress:c,fromNode:d}=x0(),u=c&&(d==null?void 0:d.id)!==e,[f,m]=b0(!1),y=a(),E=!r,p=!E&&((v=y.find(A=>A.id===r))==null?void 0:v.selected),g=Gd(()=>_0([...y.filter(A=>A.parentId===e&&A.type==="LANE")],"position.y","asc"),[y,e]),h=E?ra.MIN_WIDTH:se.MIN_WIDTH,x=Gd(()=>{if(E&&g.length>1){let A=[...g];return A.pop(),A.reduce((P,R)=>{var S,L;return P+((L=(S=R.measured)==null?void 0:S.height)!=null?L:0)},0)+se.MIN_HEIGHT}return se.MIN_HEIGHT},[E,g]),N=A=>{i(e,{label:A})},b=()=>{m(!0)},T=()=>{m(!1)};return si(Ns,{children:[si("div",{className:H("flex h-full min-h-64 w-full min-w-[50rem] hover:shadow-md bg-white outline outline-2 outline-grey-400",{"pointer-events-none":l,"outline-offset-0 outline-blue-500 shadow-sm":(o||p)&&!l}),children:[Ue("div",{className:H("flex align-items justify-center w-10 border-r-2 border-grey-400",{"border-blue-500":(o||p)&&!l}),onDoubleClick:b,children:Ue("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:Ue(De,{value:t.label,className:"w-full h-full self-auto",contentClassName:H({"whitespace-nowrap":f}),isEditing:f,onBlur:T,onChange:N})})}),Ue("div",{className:"flex-1"})]}),Ue(We,{nodeId:e,nodeType:"LANE",isChild:!E}),s==="edit"&&Ue(it,{nodeId:e,isVisible:!n&&o,minWidth:h,minHeight:x,offset:10}),!c&&si(Ns,{children:[Ue(ne,{type:"source",position:Jt.Left,id:"left"}),Ue(ne,{type:"source",position:Jt.Right,id:"right"}),Ue(ne,{type:"source",position:Jt.Top,id:"top"}),Ue(ne,{type:"source",position:Jt.Bottom,id:"bottom"})]}),(!c||u)&&si(Ns,{children:[Ue(ne,{type:"target",position:Jt.Left,id:"left",className:H({"annotation-handle":u})}),Ue(ne,{type:"target",position:Jt.Right,id:"right",className:H({"annotation-handle":u})}),Ue(ne,{type:"target",position:Jt.Top,id:"top",className:H({"annotation-handle":u})}),Ue(ne,{type:"target",position:Jt.Bottom,id:"bottom",className:H({"annotation-handle":u})})]})]})};var zd={START_EVENT:Nd,END_EVENT:_d,TASK:Pd,GATEWAY:Td,ANNOTATION:xd,LANE:Bd,UNSUPPORTED:kd},Yd={SEQUENCE_EDGE:Hc,MESSAGE_EDGE:Od,ANNOTATION_EDGE:Tc},Fd="#fafafa",Wd="#bebebe",Xd=1,Ud=10,$d="bottom-left",ws=.05,Kd=5,qd=150,Zd=100,Jd=ws,Qd=1,jd={x:0,y:0,zoom:.75},eu=1,tu=2,T0={[eu]:4,[tu]:2},Cn=[eu,tu],As=Cn.reduce((e,t)=>e|T0[t],0);var Xo=()=>{let{setViewport:e}=v0(),t=N0();return{fitToNodes:w0(n=>{let{width:r,height:i}=t.getState();if(i<=0||r<=0)return;let a=ua(n);if(!a)return;let s=pa({bounds:a,canvasHeight:i,canvasWidth:r,minZoom:Jd,maxZoom:Qd,offsetX:qd,offsetY:Zd});e(s)},[t,e])}};import{useReactFlow as A0}from"@xyflow/react";var st=()=>{let{getEdges:e,getNodes:t}=A0(),{lastElementId:o}=q(),n=()=>{let i=t(),a=e(),s=zc(i,a);return Math.max(s,o)};return{getLastId:n,getNextId:()=>n()+1}};var Uo=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n}=I0(),{getLastId:r}=st(),{fitToNodes:i}=Xo(),{setLastElementId:a}=q(),s=ou(async(c="")=>{let{nodes:d,edges:u,lastElementId:f}=await td(c);i(d),o(d),n(u),a(f)},[o,n,a,i]),l=ou(()=>{let c=e(),d=t(),u=r();return ed(c,d,u)},[e,t,r]);return{importFromMxGraph:s,exportToMxGraph:l}};import{useCallback as nu}from"react";var S0=500,ai=()=>{let{isInitialized:e,onElementChanges:t}=q(),{exportToMxGraph:o}=Uo(),n=C0(()=>{if(!e)return;let a=o();t==null||t(a)},S0),r=nu(a=>{a.every(c=>c.type==="select")||a.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=nu(a=>{a.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var ru=({setEdges:e,saveHistory:t})=>{let{getNode:o,getEdges:n,getNodes:r,getInternalNode:i}=P0(),{emitElementChanges:a}=ai(),s=L0(null),{getNextId:l}=st(),c=go(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 ss(x).isValid},[o,n,r]),d=go(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=Gc(h,T,v),C=(b==null?void 0:b.type)==="ANNOTATION"||(h==null?void 0:h.type)==="ANNOTATION",P=C?Ro:rt,R;if(!C&&b&&p.targetHandle){let K=qr(A),j=qr(p.targetHandle),{x:Q,y:z}=us(h,A),{x:M,y:V}=us(b,p.targetHandle),I=Xr(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?{}:rt.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=go((p,g)=>{s.current=g.id},[]),f=go(()=>{s.current=null},[]),m=go((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(!ss(N).isValid){s.current=null;return}let T=M0(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=go(p=>{s.current=p},[]),E=go(()=>{s.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:m,onReconnectStart:u,onReconnectEnd:f,setReconnectingEdge:y,clearReconnectingEdge:E}};import{useTranslation as k0}from"@produto-lecom/lecom-ui";import{useReactFlow as R0}from"@xyflow/react";import{useCallback as Ln,useRef as fu,useState as D0}from"react";var Sn=(e=[])=>e.filter(t=>t.type==="START_EVENT"),ho=(e=[])=>e.filter(t=>t.type==="END_EVENT"),Qt=(e=[])=>e.filter(t=>t.type==="TASK")||[],iu=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"});var li=(e=[])=>e.filter(t=>t.type==="GATEWAY"),su=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),je=(e,t=[])=>t.filter(o=>o.source===e),Mn=(e,t=[])=>t.filter(o=>o.target===e),au=(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"},lu=(e,t)=>{let o=je(e,t.edges||[]);for(let n of o){let r=(t.nodes||[]).find(i=>i.id===n.target);if(r&&r.type==="END_EVENT")return!0}return!1},cu=e=>e?/[^\s]/.test(e.trim()):!1,Ee=e=>{let{isValid:t,nodeIds:o,edgeIds:n}=e;return{isValid:t,nodeIds:!t&&o&&o.length>0?o:[],edgeIds:!t&&n&&n.length>0?n:[]}},Mt=(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)}},du=(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 Pn=[{id:"start_event_not_found",validate:e=>{let t=Sn(e.nodes);return Ee({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=ho(e.nodes);return Ee({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Sn(e.nodes),o=t.length===1;if(t.length===0)return Ee({isValid:!0});if(!o)return Ee({isValid:!1,nodeIds:t.map(i=>i.id)});let n=je(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(a=>a.id),...n.map(a=>a.target)];return Ee({isValid:!1,nodeIds:[...new Set(i)]})}return Ee({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=Qt(e.nodes),o=Mt(t,n=>je(n.id,e.edges).length<=2);return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=Qt(e.nodes),o=Mt(t,n=>!!n.label&&n.label.trim()!=="");return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=Qt(e.nodes),n=Mt(o,r=>!r.label||r.label.length<=60);return Ee({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=Qt(e.nodes),o=new Map;for(let r of t){if(!r.label)continue;let i=r.label.trim();i&&(o.has(i)||o.set(i,[]),o.get(i).push(r))}let n=[];for(let[,r]of o.entries())r.length>1&&r.forEach(i=>n.push(i.id));return Ee({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=li(e.nodes),o=[],n=[];for(let r of t){let i=je(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="GATEWAY"&&(o.push(r.id,s.id),n.push(a.id))}}return Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Sn(e.nodes),...ho(e.nodes)],o=[],n=[];for(let r of t){let i=je(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&(s.type==="START_EVENT"||s.type==="END_EVENT")&&(o.push(r.id,s.id),n.push(a.id))}}return Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=ho(e.nodes),o=[],n=[];for(let r of t){let i=Mn(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.source);if(s&&s.type==="TASK"){let l=je(s.id,e.edges);l.length>1&&(o.push(s.id),l.forEach(c=>n.push(c.id)))}}}return Ee({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=su(e.nodes),o=Mt(t,r=>je(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>je(r,e.edges).map(i=>i.id));return Ee({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=Qt(e.nodes),o=Mt(t,n=>!n.label||cu(n.label));return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var a,s;if(!((a=e==null?void 0:e.nodes)!=null&&a.length)||!((s=e==null?void 0:e.edges)!=null&&s.length))return Ee({isValid:!0});let t=ho(e.nodes)[0];if(!t)return Ee({isValid:!0});let o=Mn(t.id,e.edges);if(!o.length)return Ee({isValid:!0});let r=Qt(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=Mt(r,l=>!au(l.id,e));return Ee({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=Qt(e.nodes),o=ho(e.nodes)[0];if(!o)return Ee({isValid:!0});let n=t.filter(l=>{let c=Mn(l.id,e.edges),d=je(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=Mn(o.id,e.edges),i=r.length>1,a=r.map(l=>l.source),s={isValid:n.length===0&&!i,nodeIds:[...n.map(l=>l.id),...i?a:[]]};return Ee(s)}},{id:"gateway_flow_to_event",validate:e=>{let t=li(e.nodes),o=[],n=[];for(let r of t){let i=je(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="END_EVENT"&&(o.push(r.id,s.id),n.push(a.id))}}return Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=li(e.nodes),o=Mt(t,n=>je(n.id,e.edges).length>=1);return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Sn(e.nodes),...ho(e.nodes)],o=[],n=[];for(let r of t){let i=je(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="GATEWAY"&&(o.push(r.id,s.id),n.push(a.id))}}return Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=iu(e.nodes),o=Mt(t,n=>!lu(n.id,e));return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}}];var uu=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of Pn){let r=n.validate(e);r.isValid||t.push({id:n.id,message:n.id,nodeIds:r.nodeIds||[],edgeIds:r.edgeIds||[]})}return{isValid:t.length===0,errors:t}},pu=async(e,t)=>{var n;let o=[];try{let r=await e(),i=(n=r==null?void 0:r.filter(a=>a.area==="DIAGRAM"))!=null?n:[];return i.length===0?{isValid:!0,errors:[]}:(i.forEach(a=>{var l,c;let s=(c=(l=a==null?void 0:a.detail)==null?void 0:l.phases)==null?void 0:c.map(d=>d.diagramCellId);o.push({id:a.code,message:a.code,nodeIds:s,edgeIds:[]})}),{isValid:!1,errors:o})}catch(r){let i=[],a=(s,l)=>{let c=t.filter(d=>{var u;return((u=d.data)==null?void 0:u.variant)===s}).map(d=>d.id);c.length>0&&i.push({id:l,message:l,nodeIds:c,edgeIds:[]})};return a("SUBPROCESS","cannot_validate_subprocess_reference"),a("SERVICE_TASK","service_task_automation_status_unavailable"),{isValid:!1,errors:i}}};import{jsx as ci,jsxs as O0}from"react/jsx-runtime";var mu=()=>{let{t:e}=k0(),{toast:t}=Fe(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=R0(),{validateCustomDiagram:a}=q(),[s,l]=D0(!1),c=fu(!1),d=fu(!1),u=Ln(async p=>{let g=du(p.nodes,p.edges),h=uu(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 pu(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=Ln((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:O0("div",{className:"flex flex-col gap-1",children:[!p.isValid&&ci("span",{className:"body-small-500",children:e("validation.errors.subtitle")}),ci("ul",{className:"list-disc list-inside max-h-40 overflow-y-auto",children:p.isValid?ci("li",{children:e("validation.success.message")}):p.errors.map(S=>ci("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=Pn.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=Pn.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=Ln(()=>{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=Ln(()=>{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=Ln(()=>c.current,[]);return{validateDiagram:u,handleValidationComplete:f,clearValidation:m,dismissValidationPanel:y,isAutoValidationEnabled:s,getIsClearingValidation:E}};import{useReactFlow as V0}from"@xyflow/react";import{useTranslation as H0}from"@produto-lecom/lecom-ui";import{useEffect as G0}from"react";var B0=15,gu="bpmn:selection",z0=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},hu=e=>{if(!z0(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},yu=({offset:e=B0,saveHistory:t})=>{let{t:o}=H0(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=V0(),{getNextId:s}=st(),{mode:l,containerRef:c}=q();G0(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let u=m=>{var b,T;if(!hu(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(gu,N),(T=m.clipboardData)==null||T.setData("text/plain",`BPMN Selection: ${g.length} nodes`)},f=m=>{var R,S;if(!hu(m)||!d.contains(document.activeElement))return;let E=(R=m.clipboardData)==null?void 0:R.getData(gu);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=>Bt(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=Fo(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])};import{useTranslation as Y0}from"@produto-lecom/lecom-ui";import{useReactFlow as F0}from"@xyflow/react";import{useState as W0}from"react";var X0=50,xu=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let{draggableNode:r,setDraggableNode:i}=Yo(),{t:a}=Y0(),{getInternalNode:s,getNodes:l,getEdges:c,screenToFlowPosition:d}=F0(),{getNextId:u}=st(),{setIsDragging:f}=q(),{getInternalNodes:m}=Qr(),{rebuildIndex:y,forceRebuildIndex:E}=Ir(),[p,g]=W0(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=en(M,O);if(!Y){x();return}if(eo({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=en(M,B);if(!G){x();return}if(eo({parentId:G.id,nodes:e,includeTypes:["LANE"]})){x();return}x(G.id)},b=M=>{let V=s(M.id),D=M.type==="LANE"&&eo({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=ot(I),G=B.y+B.h;D=Math.max(D,G)}return D+X0},C=(M,V)=>{if(!Bi(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=Yi(M,V,I),I=Xt(I),I=to(B,I),T(I);if(M.type==="LANE"){if(eo({parentId:V.id,nodes:I,excludeTypes:["LANE"]})){let W=Nr(V),oe=50,le=50;return I.map(Z=>{var xe,me;return Z.id===M.id?w(_({},Z),{position:{x:(xe=p==null?void 0:p.x)!=null?xe:W.x+oe,y:(me=p==null?void 0:p.y)!=null?me:W.y2+le}}):Z})}let te=I.filter(W=>W.parentId===V.id).reduce((W,oe)=>{var le,Z;return W+((Z=(le=oe.measured)==null?void 0:le.height)!=null?Z:0)},0),ie={x:se.HEADER_WIDTH,y:te};return I=I.map(W=>W.id===M.id?w(_({},W),{parentId:V.id,position:ie,className:void 0}):w(_({},W),{className:void 0})),I=Xt(I),I=C(B,I),I}if(eo({parentId:V.id,nodes:I,includeTypes:["LANE"]})){let X;if(M.parentId){let $=s(M.parentId),{x:te,y:ie}=ot($);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=to(B,I),I}let O=ca(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=Yi(Y,V,I),I=Xt(I),I=to(B,I),I},K=M=>{if(M.preventDefault(),!(r!=null&&r.type))return;if(!Bt(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"?ti(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=en(k,F),X=[...O.map(W=>w(_({},W),{selected:!1})),G];U&&(X=L(G,U,X)),X=jo(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),Ro):_(_({},W),rt);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=en(Y,U);if(X){if(F&&eo({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)Bi(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=to(Y,I)}I=jo(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=se.MIN_HEIGHT;else if(I){let Z=(X=(U=M.measured)==null?void 0:U.height)!=null?X:se.MIN_HEIGHT;k=((te=($=D.measured)==null?void 0:$.height)!=null?te:se.MIN_HEIGHT)-Z,k=Math.max(se.MIN_HEIGHT,k)}else k=B.length>0?B.reduce((Z,xe)=>{var me,_e;return Z+((_e=(me=xe.measured)==null?void 0:me.height)!=null?_e:0)},0)+Ne:Math.max(se.MIN_HEIGHT,(W=(ie=D.measured)==null?void 0:ie.height)!=null?W:0);let{x:O,y:Y}=ot(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=Xt(V),V};return{onDragOver:P,onDragLeave:R,onDrop:K,onNodeDrag:S,onNodeDragStart:Q,onNodeDragStop:j}};import{useReactFlow as U0}from"@xyflow/react";import{useTranslation as $0}from"@produto-lecom/lecom-ui";import{useEffect as K0}from"react";var q0=30,Z0=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},J0=e=>!Z0(e.target),Eu=({offset:e=q0,saveHistory:t})=>{let{t:o}=$0(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=U0(),{getNextId:s}=st(),{mode:l,containerRef:c}=q();K0(()=>{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"&&J0(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=>Bt(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=Fo(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])};import{useEffect as Q0,useRef as _u}from"react";import{useReactFlow as j0}from"@xyflow/react";var ex=20,tx=50,kn={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},ox=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",i=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||i},bu=e=>{let{getNodes:t}=j0(),{mode:o,isMoveTool:n}=q(),r=_u(0),i=_u(new Map);Q0(()=>{let a=s=>{if(o!=="edit"||!n||ox(s.target)||!Object.values(kn).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?tx:ex,E=0,p=0;switch(s.key){case kn.UP:p=-y;break;case kn.DOWN:p=y;break;case kn.LEFT:E=-y;break;case kn.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])};import{useReactFlow as rx}from"@xyflow/react";var vu={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY","gateway-parallel":"GATEWAY","gateway-complex":"GATEWAY"},Nu={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Tu=(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}},nx=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=Tu(i[0],o),s=Tu(i[1],o);a&&s&&n.push({sourceId:a.step,targetId:s.step,label:a.edgeLabel||s.edgeLabel||""})}),{components:o,connections:n}},wu=e=>{let{components:t,connections:o}=nx(e);return{nodes:t,edges:o}};var di=()=>{let{setNodes:e,setEdges:t}=rx(),{fitToNodes:o}=Xo(),{getNextId:n}=st();return{importFromLia:i=>{let a=typeof i=="string"?i:i.diagramXml||"",{nodes:s,edges:l}=wu(a),c=[],d=new Map,u=!1,f=n();for(let[p,g]of Object.entries(s)){let h=String(f++),x=vu[g.type],N=Nu[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(_({},rt),{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(_({},rt),{id:String(f++),source:p,target:h.id});m.unshift(x)}}let{nodes:y,edges:E}=sd(c,m);e(y),t(E),o(y)}}};import{useCallback as ix,useEffect as sx}from"react";var ax={origin:"*",debug:!1};function ui(e,t=ax){let{origin:o,debug:n}=t,r=ix((i,a)=>{let s={event:i,data:a};window.parent.postMessage(s,o||"*")},[o]);return sx(()=>{if(!e)return;let i=a=>{let s=a.data;if(!(s!=null&&s.event)||(s==null?void 0:s.data)===void 0)return;let{event:l,data:c}=s,d;if(Array.isArray(c)){let[,u]=c;d=u.data}else d=c;n&&(console.debug("[postMessage] received:",s),console.debug("[postMessage] eventData:",d)),l&&e[l]&&e[l](d)};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[e,n]),{sendMessage:r}}import{useNodesInitialized as cx}from"@xyflow/react";import{useEffect as pi,useRef as Is}from"react";var Au=()=>{let e=cx(),{initialDiagram:t,isNewDiagram:o,setIsInitialized:n,onElementChanges:r}=q(),{importFromMxGraph:i,exportToMxGraph:a}=Uo(),{sendMessage:s}=ui(),l=Is(t),c=Is(r),d=Is(a);pi(()=>{c.current=r},[r]),pi(()=>{d.current=a},[a]),pi(()=>{t&&(i(t),l.current=t)},[t,i]),pi(()=>{if(!e)return;(async()=>{var f;if(await zn(),n(!0),s("INIT_MODELER",l.current),!o){let m=d.current();(f=c.current)==null||f.call(c,m)}})()},[e,o,n,s])};import{useCallback as Iu}from"react";import{useReactFlow as dx}from"@xyflow/react";function Cu(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=no(),{getEdges:n}=dx(),r=qn(),i=Iu(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=Iu(()=>{t(),setTimeout(()=>{r()},0)},[t,r]);return{handleTasksStatus:i,handleClearTaskStatus:a}}import{useReactFlow as ux}from"@xyflow/react";import{useCallback as Pt,useState as px,useEffect as Su}from"react";import{useDebouncedCallback as fx}from"use-debounce";var mx=500,Mu=100,Pu=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=ux(),{mode:i,containerRef:a}=q(),[s,l]=px({history:[],currentStep:0}),{history:c,currentStep:d}=s,u=d>0,f=d<c.length-1,m=Pt((v,A)=>{n(v[A].nodes),r(v[A].edges)},[n,r]),y=Pt(()=>{if(d>0){let v=d-1;l(A=>w(_({},A),{currentStep:v})),m(c,v)}},[d,c,m]),E=Pt(()=>{if(d<c.length-1){let v=d+1;l(A=>w(_({},A),{currentStep:v})),m(c,v)}},[c,d,m]),p=Pt(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>Mu?S.slice(S.length-Mu):S;return{history:L,currentStep:L.length-1}})},[]),g=Pt((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:jo(C),edges:P}},[]),h=Pt(()=>g(t(),o()),[t,o,g]),x=fx(()=>{let v=h();p(v)},mx),N=Pt((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]);Su(()=>{if(e&&c.length===0){let v=h();l({history:[v],currentStep:0})}},[e,c.length,h]);let b=Pt(v=>{l({history:v||[],currentStep:0})},[]),T=Pt(()=>{l({history:[],currentStep:0})},[]);return Su(()=>{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 Lu=()=>{let{t:e}=gx(),[t,o,n]=yx([]),[r,i,a]=hx([]),{getNodes:s,getNode:l}=Ex(),{toast:c}=Fe(),d=_x(),{instanceId:u,isInitialized:f,setIsConnecting:m,setIsMultipleSelection:y,onElementClick:E}=q(),{updateHelperLines:p,HelperLines:g}=Ir(),{undo:h,redo:x,canUndo:N,canRedo:b,saveHistory:T}=Pu(f),{onNodeDrag:v,onDrop:A,onDragOver:C,onDragLeave:P,onNodeDragStop:R,onNodeDragStart:S}=xu({nodes:t,setNodes:o,setEdges:i,saveHistory:T}),{isValidConnection:L,onConnect:K,onReconnect:j,onReconnectStart:Q,onReconnectEnd:z,setReconnectingEdge:M,clearReconnectingEdge:V}=ru({setEdges:i,saveHistory:T}),{handleValidationComplete:D,clearValidation:I,dismissValidationPanel:B,validateDiagram:G,getIsClearingValidation:k}=mu(),{importFromLia:O}=di(),{handleTasksStatus:Y,handleClearTaskStatus:F}=Cu(),{clearPathEdges:U}=no(),{emitElementChanges:X,handleNodeChanges:$,handleEdgeChanges:te}=ai(),ie=qn();yu({saveHistory:T}),Eu({saveHistory:T}),Au();let W=_t(()=>{o([]),i([]),U(),setTimeout(ie,0)},[o,i,U,ie]),{selectElements:oe,clearSelection:le}=zt(),{importFromMxGraph:Z,exportToMxGraph:xe}=Uo(),{configureElement:me,getConfigureElement:_e}=Dr(),J=_t(he=>{he!=null&&he.id&&oe([he.id])},[oe]),{sendMessage:de}=ui({LIA_CREATE_DIAGRAM:O,CLEAR_DIAGRAM:W,TASKS_STATUS:Y,CLEAR_TASKS_STATUS:F,EXTERNAL_TASK_SELECT:J}),re=_t(()=>t.length+r.length,[t,r]);bx(()=>(Et.set(u,{importFromMxGraph:Z,exportToMxGraph:xe,selectElements:oe,clearSelection:le,configureElement:me,getConfigureElement:_e,getElementsCount:re,setReconnectingEdge:M,clearReconnectingEdge:V}),()=>{Et.delete(u)}),[u,Z,xe,oe,le,me,_e,re,M,V]);let ee=_t((he,fe)=>{if(fe.type!=="TASK"&&fe.type!=="GATEWAY")return;let pe=_e(fe.id);pe&&(E==null||E(pe)),fe.type==="TASK"&&de("SELECT_TASK",{id:fe.id})},[_e,E,de]),ge=_t((he,fe)=>{if(fe.type!=="SEQUENCE_EDGE")return;let pe=l(fe.source),ve=l(fe.target),{isFromStartEvent:Ke,isGatewayToGateway:tt,isActiviyToAndGateway:Be,isToEndEvent:mt}=Kn(pe,ve);if(!(!Ke&&!tt&&!Be&&!mt))return;let Tt=_e(fe.id);Tt&&(E==null||E(Tt))},[_e,l,E]),be=_t(he=>{let fe=p(he,t);n(fe),T(he),k()||B(),$(he)},[t,n,T,k,B,p,$]),Te=_t(he=>{a(he),T(he),k()||B(),te(he)},[a,T,k,B,te]);bu(be);let ke=_t(({nodes:he,edges:fe})=>{y(he.length+fe.length>=2)},[y]);xx({onChange:ke});let et=_t(async({nodes:he})=>he.some(pe=>pe.type==="LANE"&&t.some(ve=>ve.parentId===pe.id))?(c({variant:"error",title:e("validation.errors.title"),content:e("editor.toolbar.delete_pool_lane_error")}),!1):!0,[t,e,c]),bt=()=>{T("forceSave"),X(),B()},pt=()=>{m(!0)},ft=()=>{m(!1),B()},$e=_t(he=>{let fe=new Set(he.filter(pe=>pe.type==="LANE"&&!!pe.parentId).map(pe=>pe.parentId));fe.size!==0&&setTimeout(()=>{var Ke,tt;let pe=s(),ve=new Map(pe.map(Be=>[Be.id,Be]));for(let Be of fe){let mt=oo(pe.filter(vt=>vt.type==="LANE"&&vt.parentId===Be));if(mt.length===0)continue;let kt=0;for(let vt of mt)ve.set(vt.id,w(_({},vt),{position:{x:se.HEADER_WIDTH,y:kt}})),kt+=(tt=(Ke=vt.measured)==null?void 0:Ke.height)!=null?tt:0;let Tt=ve.get(Be);Tt&&ve.set(Be,w(_({},Tt),{height:kt,measured:w(_({},Tt.measured),{height:kt})}))}o(pe.map(Be=>{var mt;return(mt=ve.get(Be.id))!=null?mt:Be}))},0)},[s,o]);return{nodes:t,setNodes:o,edges:r,setEdges:i,events:{isValidConnection:L,onConnect:K,onReconnect:j,onReconnectStart:Q,onReconnectEnd:z,onDrop:A,onDragOver:C,onDragLeave:P,onNodeDrag:v,onNodeDragStop:R,onNodeDragStart:S,onNodeClick:ee,onEdgeClick:ge,onDropCapture:bt,onConnectStart:pt,onConnectEnd:ft,onSelectionEnd:()=>setTimeout(()=>d.setState({nodesSelectionActive:!1}),0),onNodesChange:be,onEdgesChange:Te,onBeforeDelete:et,onNodesDelete:$e},ui:{handleCloseValidationPanel:I},controls:{undo:h,redo:x,canUndo:N,canRedo:b},components:{HelperLines:g},actions:{saveHistory:T,selectElements:oe,clearSelection:le,exportToMxGraph:xe,validateDiagram:G,handleValidationComplete:D,setReconnectingEdge:M,clearReconnectingEdge:V}}};import{useReactFlow as Tx}from"@xyflow/react";import{useCallback as vx,useEffect as Nx,useRef as wx,useState as Ax}from"react";var Ix=".react-flow__node, .react-flow__edge, .react-flow__node-toolbar";function ku(e,t,o){let[n,r]=Ax(!1),i=wx(null),{getViewport:a,setViewport:s}=Tx(),l=vx(()=>{i.current=null,r(!1)},[]);return Nx(()=>{let c=e.current;if(!c)return;let d=m=>{if(!Cn.some(E=>E===m.button)||t.current||o.current||(r(!0),!(m.target instanceof Element))||!m.target.closest(Ix))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&As)===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&As)===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}import{jsx as Ru}from"react/jsx-runtime";var fi=({id:e,className:t})=>Ru("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:Ru("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as mi,jsxs as Cx}from"react/jsx-runtime";var Du=()=>mi("svg",{style:{position:"absolute",top:0,left:0},children:Cx("defs",{children:[mi(fi,{id:"sequence-edge-marker",className:"text-grey-500"}),mi(fi,{id:"sequence-edge-marker-hovered",className:"text-grey-800"}),mi(fi,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{Tooltip as y_,TooltipContent as x_,TooltipTrigger as E_,useTranslation as __}from"@produto-lecom/lecom-ui";import{useKeyPress as sp,useReactFlow as OE}from"@xyflow/react";import{Button as bi,Tooltip as Ti,TooltipContent as vi,TooltipTrigger as Ni,useTranslation as VE}from"@produto-lecom/lecom-ui";import{HandIcon as HE,ListCheckIcon as GE,Loader2Icon as BE,MapIcon as zE,MousePointerIcon as YE}from"lucide-react";import{useCallback as Ls,useEffect as ap,useState as FE}from"react";import{Tooltip as Kx,TooltipContent as qx,TooltipTrigger as Zx,useTranslation as Jx}from"@produto-lecom/lecom-ui";var Rn=(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))(Rn||{});import{Button as Bx,useTranslation as zx}from"@produto-lecom/lecom-ui";import{useReactFlow as Yx}from"@xyflow/react";var Ou=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 Vu({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);gi(i,`${o}.csv`)}var gi=(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 Hu(e){return e==null?void 0:e.replaceAll("
"," ")}var PD={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},Gu={script:"SCRIPT",subprocess:"SUBPROCESS"},Bu={"marker-loop":"LOOP"},zu={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL",inclusive:"EXCLUSIVE"};var yo=({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}}},Mx=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:yo({cell:e,type:"START_EVENT"}),status:n,originalType:o}},Px=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:yo({cell:e,type:"END_EVENT"}),status:n,originalType:o}},Lx=(e,t)=>{let{id:o,subType:n,style:r}=e==null?void 0:e._attributes,i=Gu[n],a=t.get(o)||"",s=Bu[a]||"",l=s==="LOOP",c="imported";return!["script","none"].includes(n)&&!l&&(c="adapted"),e.mxGeometry._attributes.width=Rt(e.mxGeometry._attributes.width||0,ue.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=Rt(e.mxGeometry._attributes.height||0,ue.TASK.MIN_HEIGHT),{node:yo({cell:e,type:"TASK",variant:i,attribute:s}),status:c,originalType:r}},kx=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=zu[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:yo({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},Rx=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:yo({cell:e,type:"LANE"}),status:"imported",originalType:t}},Dx=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=Rt(e.mxGeometry._attributes.width||0,ue.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=Rt(e.mxGeometry._attributes.height||0,ue.ANNOTATION.MIN_HEIGHT),{node:yo({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},Yu=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:yo({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},Fu=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return w(_({},rt),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},Wu={TASK:Lx,GATEWAY:kx,START_EVENT:Mx,END_EVENT:Px,LANE:Rx,ANNOTATION:Dx};var Ox=e=>{let t=new Map,o=Object.values(Rn),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=Wu[l]||Yu,{node:d,status:u,originalType:f}=c(s,r);a.push(d),i.push({originalType:f,type:d.type,variant:d.data.variant,value:Hu(d.data.label),status:u})}return{nodes:a,governanceIdToNodeIdMap:t,summary:i}},Vx=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>Fu(r,t)),Hx=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=Ox(t.root.mxCell),i=Vx(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},Gx=async e=>{let t=await Ou(e),o=Zr(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}},Xu=async e=>{try{let t=await Gx(e),{nodes:o,edges:n,summary:r}=Hx(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};import{jsx as Fx}from"react/jsx-runtime";var Uu=()=>{let{t:e}=zx(),{toast:t}=Fe(),{setNodes:o,setEdges:n}=Yx(),{fitToNodes:r}=Xo(),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:Fx(Bx,{size:"small",variant:"ghost",onClick:()=>Vu({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 Xu(s);if(o(f=>f.concat(l)),n(f=>f.concat(c)),r(l),d.some(f=>f.status==="unsupported")){i(d);return}t({variant:"success",content:e("adapter.governance.success.default")})}catch(l){let c=l instanceof Error?l.message:"DEFAULT";t({variant:"error",content:e(`adapter.governance.error.${c}`)})}}}};import{Button as Wx}from"@produto-lecom/lecom-ui";import{useRef as Xx}from"react";import{Fragment as Ux,jsx as $u,jsxs as $x}from"react/jsx-runtime";var Ku=s=>{var l=s,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,a=gt(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=Xx(null),d=f=>{let m=f.target.files;m!=null&&m.length&&i(m),c.current&&(c.current.value="")};return $x(Ux,{children:[$u(Wx,w(_({disabled:n,onClick:f=>{var m;(m=c.current)==null||m.click(),r==null||r(f)}},a),{children:e})),$u("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};import{jsx as hi,jsxs as Qx}from"react/jsx-runtime";var qu=({disabled:e=!1})=>{let{t}=Jx(),{toast:o}=Fe(),{importFromGovernance:n}=Uu(),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 Qx(Kx,{children:[hi(Zx,{asChild:!0,children:hi(Ku,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:hi(Zs,{})})}),hi(qx,{color:"black",children:t("editor.controls.actions.import_governance")})]})};import{jsx as jx}from"react/jsx-runtime";var Cs=({shortcut:e})=>jx("span",{className:"min-h-7.5 inline-flex justify-center items-center py-0.5 px-1.5 bg-grey-100 border border-grey-300 font-mono text-gray-800 shadow-lg rounded-md text-grey-900",children:e});import{Button as cE,DropdownMenu as dE,DropdownMenuContent as uE,DropdownMenuItem as Ms,DropdownMenuTrigger as pE,Tooltip as xi,TooltipContent as Ei,TooltipTrigger as _i,useTranslation as fE}from"@produto-lecom/lecom-ui";import{FileCodeIcon as mE,FileImageIcon as gE,FolderOutputIcon as hE,PrinterIcon as yE}from"lucide-react";import{useState as xE}from"react";import{useTranslation as eE}from"@produto-lecom/lecom-ui";import{useReactFlow as tE}from"@xyflow/react";import{toPng as Zu,toSvg as oE}from"html-to-image";import{useState as nE}from"react";var rE=3,Ss="diagram",yi=50,iE=96,sE=25.4,aE="sequence-edge-marker",Ju=e=>e*sE/iE,lE=e=>{let t=document.getElementById(aE);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},Qu=()=>{let{t:e}=eE(),{toast:t}=Fe(),{getEdges:o,getNodes:n,getNodesBounds:r}=tE(),{clearSelection:i}=zt(),[a,s]=nE({png:!1,html:!1,print:!1}),l=()=>{let m=fs(n(),o()),y=r(m),E=y.width+yi*2,p=y.height+yi*2,g=yi-y.x,h=yi-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(fs(n(),o()).length===0){t({content:e("editor.controls.actions.export.feedback.empty"),variant:"warning"});return}let p=ad();if(!p)throw new Error("Flow element not found");let g=l(),h=lE(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=Ss)=>{await c(async(y,E)=>{let p=await Zu(y,w(_({},E),{backgroundColor:"#fcfcfc",skipFonts:!0}));gi(p,`${m}.png`)},"png")},exportAsHtml:async(m=Ss)=>{await c(async(y,E)=>{let p=await oE(y,w(_({},E),{backgroundColor:"#fcfcfc",skipFonts:!0})),g=`
|
|
44
44
|
<!DOCTYPE html>
|
|
45
45
|
<html>
|
|
46
46
|
<head>
|
|
@@ -67,7 +67,7 @@ var hp=Object.defineProperty,yp=Object.defineProperties;var xp=Object.getOwnProp
|
|
|
67
67
|
<body>
|
|
68
68
|
<img src="${p}" alt="${m}" />
|
|
69
69
|
</body>
|
|
70
|
-
</html>`,
|
|
70
|
+
</html>`,h=new Blob([g],{type:"text/html"}),x=URL.createObjectURL(h);gi(x,`${m}.html`),window.setTimeout(()=>URL.revokeObjectURL(x),1e4)},"html")},printDiagram:async(m=Ss)=>{await c(async(y,E)=>{var C;let p=await Zu(y,w(_({},E),{backgroundColor:"#fcfcfc",pixelRatio:rE,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=Ju(E.width).toFixed(2),N=Ju(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,4 +83,11 @@ var hp=Object.defineProperty,yp=Object.defineProperties;var xp=Object.getOwnProp
|
|
|
83
83
|
height: 100%;
|
|
84
84
|
object-fit: contain;
|
|
85
85
|
}
|
|
86
|
-
`,y.head.appendChild(b),y.title=m;let v=y.createElement("img");v.alt="Diagram",y.body.appendChild(v),await new Promise((P,R)=>{let C=!1,L=K=>{C||(C=!0,K?R(K):P())};v.onload=()=>L(),v.onerror=()=>L(new Error("Failed to load print image")),v.src=p,v.complete&&v.naturalWidth>0&&L()});let T=g.contentWindow;if(!T)throw document.body.removeChild(g),new Error("Unable to access print iframe window");let I=()=>{g.parentNode&&document.body.removeChild(g)};T.addEventListener("afterprint",I,{once:!0}),window.setTimeout(I,6e4),T.focus(),T.print()},"print")},isPrintingPng:s.png,isPrintingHtml:s.html,isPrinting:s.print}};import{jsx as Le,jsxs as Uo}from"react/jsx-runtime";function Zu(){let{t:e}=rE(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:s}=qu(),[a,l]=cE(!1);return Uo(tE,{modal:!1,open:a,onOpenChange:l,children:[Le(nE,{asChild:!0,children:Le("div",{children:Uo(gi,{children:[Le(yi,{asChild:!0,children:Le(eE,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:Le(aE,{})})}),!a&&Le(hi,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),Uo(oE,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[Uo(gi,{children:[Le(yi,{asChild:!0,children:Le(As,{className:"p-1.5",disabled:i,onClick:()=>t(),children:Le(sE,{})})}),Le(hi,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),Uo(gi,{children:[Le(yi,{asChild:!0,children:Le(As,{className:"p-1.5",disabled:s,onClick:()=>o(),children:Le(iE,{})})}),Le(hi,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),Uo(gi,{children:[Le(yi,{asChild:!0,children:Le(As,{className:"p-1.5",disabled:r,onClick:()=>n(),children:Le(lE,{})})}),Le(hi,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as ju,jsx as Pe,jsxs as Lt}from"react/jsx-runtime";var ep=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=uE(),{clearSelection:i}=zt(),{mode:s,containerRef:a,isMinimapOpen:l,setIsMinimapOpen:c,isMoveTool:d,isHandTool:u,setIsMoveTool:f,setIsHandTool:m}=q(),{getNodes:h,getEdges:E}=dE(),p=Ju(["v","V"],{target:a==null?void 0:a.current}),g=Ju(["h","H"],{target:a==null?void 0:a.current}),y=Ss(()=>{i(),m(!0),f(!1)},[i,m,f]),x=Ss(()=>{f(!0),m(!1)},[f,m]),[N,b]=yE(!1),v=Ss(async()=>{b(!0);try{let T=h(),I=E(),S=await o({nodes:T,edges:I});n(S)}finally{b(!1)}},[h,E,o,n]);return Qu(()=>{p&&!d&&s==="edit"&&x()},[p,x,d,s]),Qu(()=>{g&&!u&&s==="edit"&&y()},[g,y,u,s]),Lt("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[s==="edit"&&Lt(ju,{children:[Lt(Ei,{children:[Pe(bi,{asChild:!0,children:Pe(xi,{size:"small",variant:"ghost",color:"grey",className:H(d&&"bg-grey-400"),iconButton:!0,onClick:x,children:Pe(hE,{})})}),Lt(_i,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),Pe(ws,{shortcut:"V"})]})]}),Lt(Ei,{children:[Pe(bi,{asChild:!0,children:Pe(xi,{size:"small",variant:"ghost",color:"grey",className:H(u&&"bg-grey-400"),iconButton:!0,onClick:y,children:Pe(pE,{})})}),Lt(_i,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",Pe(ws,{shortcut:"H"})]})]})]}),Pe(Zu,{}),s==="edit"&&Lt(ju,{children:[Lt(Ei,{children:[Pe(bi,{asChild:!0,children:Pe(xi,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:N,onClick:v,children:N?Pe(mE,{className:"animate-spin"}):Pe(fE,{})})}),Pe(_i,{color:"black",children:r(N?"editor.controls.actions.check_loading":"editor.controls.actions.check")})]}),Pe(Uu,{disabled:e.length>0||t.length>0})]}),Lt(Ei,{children:[Pe(bi,{asChild:!0,children:Pe(xi,{size:"small",variant:"ghost",color:"grey",className:H(l&&"bg-grey-400"),iconButton:!0,onClick:()=>c(!l),children:Pe(gE,{})})}),Pe(_i,{color:"black",children:r(l?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as tp,Tooltip as op,TooltipContent as np,TooltipTrigger as rp,useTranslation as xE}from"@produto-lecom/lecom-ui";import{RedoIcon as EE,UndoIcon as _E}from"lucide-react";import{jsx as jt,jsxs as Cs}from"react/jsx-runtime";var ip=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=xE();return Cs("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Cs(op,{children:[jt(rp,{asChild:!0,children:jt(tp,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:jt(_E,{})})}),jt(np,{color:"black",children:r("editor.controls.history.undo")})]}),Cs(op,{children:[jt(rp,{asChild:!0,children:jt(tp,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:jt(EE,{})})}),jt(np,{color:"black",children:r("editor.controls.history.redo")})]})]})};import{useEdges as bE,useNodes as TE,useReactFlow as vE}from"@xyflow/react";import{Button as Ti,Tooltip as vi,TooltipContent as Ni,TooltipTrigger as wi,useTranslation as NE}from"@produto-lecom/lecom-ui";import{ScanIcon as wE,ZoomIn as IE,ZoomOut as AE}from"lucide-react";import{jsx as Ve,jsxs as Rn}from"react/jsx-runtime";var sp=()=>{let{t:e}=NE(),t=TE(),o=bE(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:s}=vE(),a=t.length===0&&o.length===0;return Rn("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Rn(vi,{children:[Ve(wi,{asChild:!0,children:Ve(Ti,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>s(),children:Ve(wE,{})})}),Ve(Ni,{color:"black",children:e("editor.controls.zoom.fit")})]}),Rn(vi,{children:[Ve(wi,{asChild:!0,children:Ve(Ti,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>r(),children:Ve(AE,{})})}),Ve(Ni,{color:"black",children:e("editor.controls.zoom.out")})]}),Rn(vi,{children:[Ve(wi,{asChild:!0,children:Ve(Ti,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>i(1),children:Ve(qs,{})})}),Ve(Ni,{color:"black",children:e("editor.controls.zoom.reset")})]}),Rn(vi,{children:[Ve(wi,{asChild:!0,children:Ve(Ti,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>n(),children:Ve(IE,{})})}),Ve(Ni,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{ViewportPortal as SE}from"@xyflow/react";import{jsx as Ms,jsxs as ap}from"react/jsx-runtime";var lp=()=>ap(SE,{children:[ap("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:[Ms("line",{x1:"0",y1:"10",x2:"20",y2:"10",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"}),Ms("line",{x1:"10",y1:"0",x2:"10",y2:"20",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"})]}),Ms("div",{className:"absolute top-1 left-1 text-xs font-medium text-grey-400 bg-white/70 px-1 rounded-sm pointer-events-none",children:"0,0"})]});import{useNodes as CE}from"@xyflow/react";import{Button as ME,Tooltip as PE,TooltipContent as LE,TooltipTrigger as kE,useTranslation as RE}from"@produto-lecom/lecom-ui";import{useRef as DE,useState as OE}from"react";import{Bot as VE}from"lucide-react";import{jsx as xo,jsxs as cp}from"react/jsx-runtime";var dp=()=>{let e=DE(null),{t}=RE(),{setDraggableNode:o}=zo(),n=CE(),{setIsDragging:r}=q(),[i,s]=OE(void 0),a=[{type:"START_EVENT",icon:Bn,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:Eo,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:Ko,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:Zo,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SERVICE_TASK",icon:VE,label:t("bpmn.task.variant.service_task")},{type:"TASK",variant:"SCRIPT",icon:js,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:Qs,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:bo,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:To,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:_o,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:Ks,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:Hn,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),s(xo(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return cp("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[xo("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:a.map((c,d)=>{let u=!Bt(c.type,n),f=u?t("editor.toolbar.start_event_already_exists"):c.label;return cp(PE,{children:[xo(kE,{asChild:!0,children:xo(ME,{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:xo(c.icon,{})},d)}),xo(LE,{color:"black",side:"right",children:f})]},d)})}),xo("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{jsx as at,jsxs as Ii}from"react/jsx-runtime";var Ps=e=>e.preventDefault(),Ls=WE((e,t)=>{let{instanceId:o,containerRef:n,mode:r,isMinimapOpen:i,isMoveTool:s,isHandTool:a}=q(),l=YE("Space",{target:n==null?void 0:n.current}),c=up(a),d=up(l),{nodes:u,edges:f,actions:m,events:h,components:E,controls:p}=Cu(),{t:g}=KE();c.current=a,d.current=l;let y=Mu(n,c,d);FE(t,()=>({selectElements:m.selectElements,clearSelection:m.clearSelection}));let x=a||l||r!=="edit",N=x?[0,1,2]:An,b=a||l||y,v=s&&!l&&!y,T=r==="edit"&&v,I=!x&&!y,S=r==="view"||v;return Ii("div",{ref:n,className:"w-full h-full outline-none",tabIndex:0,children:[r==="edit"&&at(dp,{}),at(Lu,{}),Ii(BE,w(_({},h),{id:`modeler-${o}`,className:H(r.toLowerCase(),{"is-hand-tool":b,"is-pan-tool-active":b}),edges:f,nodes:u,nodeTypes:Vd,edgeTypes:Hd,minZoom:Ts,maxZoom:Fd,panOnDrag:N,panOnScroll:!0,selectionOnDrag:I,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:S,nodesConnectable:T,nodesDraggable:T,connectionLineComponent:Rd,selectionMode:zE.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:T?"Delete":null,selectionKeyCode:null,defaultViewport:qd,connectOnClick:!1,connectionRadius:50,onPaneContextMenu:Ps,onNodeContextMenu:Ps,onEdgeContextMenu:Ps,proOptions:{hideAttribution:!0},children:[at(HE,{gap:Yd,size:zd,color:Bd,bgColor:Gd}),at(lp,{}),i&&Ii(XE,{children:[at($E,{asChild:!0,children:at("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:at(GE,{pannable:!0,zoomable:!0,position:Wd,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),at(UE,{color:"black",children:g("editor.controls.actions.minimap.label")})]}),Ii("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&at(ip,_({},p)),r!=="readonly"&&at(ep,{nodes:u,edges:f,validateDiagram:m.validateDiagram,handleValidationComplete:m.handleValidationComplete}),at(sp,{})]}),at(E.HelperLines,{})]}))]})});Ls.displayName="Editor";import{useStore as qE}from"@xyflow/react";import{useEffect as ZE,useRef as JE}from"react";import{jsx as jE}from"react/jsx-runtime";var QE=e=>({width:e.width,height:e.height,transform:e.transform}),ks="rgba(51, 103, 217, 0.4)",sc=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=qE(QE),i=JE(null);return ZE(()=>{let s=i.current,a=s==null?void 0:s.getContext("2d");if(!a||!s)return;let l=window.devicePixelRatio;s.width=o*l,s.height=n*l,a.clearRect(0,0,o,n),a.scale(l,l),a.strokeStyle=ks,t&&(a.beginPath(),a.strokeStyle=t.color||ks,a.moveTo(t.position*r[2]+r[0],0),a.lineTo(t.position*r[2]+r[0],n),a.stroke()),e&&(a.beginPath(),a.strokeStyle=e.color||ks,a.moveTo(0,e.position*r[2]+r[1]),a.lineTo(o,e.position*r[2]+r[1]),a.stroke())},[o,n,r,e,t]),jE("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as e_,Notification as t_,TooltipProvider as o_}from"@produto-lecom/lecom-ui";import{createContext as n_,useContext as r_,useEffect as i_,useState as s_}from"react";import{jsx as pp,jsxs as l_}from"react/jsx-runtime";var Et=new Map,fp=n_(null),En=()=>{let e=r_(fp);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},a_=({locale:e,defaultMode:t="view",toast:o,children:n})=>{let[r,i]=s_(e||"pt_BR");i_(()=>{e&&(i(e),e_.changeLanguage(e))},[e]);let s=h=>{let E=Et.size;if(E===0)throw new Error("No modeler instances found");if(E===1||!h){let[g]=Et.values();return g}let p=Et.get(h);if(!p)throw new Error(`Modeler instance with ID "${h}" not found`);return p},a=(h,E)=>{let p=s(E);return p==null?void 0:p.selectElements(h)},l=async h=>{let E=s(h);return E==null?void 0:E.clearSelection()},c=(h,E)=>{let p=s(E);return p==null?void 0:p.configureElement(h)},d=(h,E)=>{let p=s(E);return p==null?void 0:p.getConfigureElement(h)},u=async(h,E)=>{let p=s(E);await(p==null?void 0:p.importFromMxGraph(h))},f=h=>{let E=s(h);return E==null?void 0:E.exportToMxGraph()},m=h=>{let E=s(h);return(E==null?void 0:E.getElementsCount())||0};return pp(fp.Provider,{value:{defaultMode:t,locale:r,selectElements:a,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:u,exportDiagram:f,getElementsCount:m,toast:o},children:l_(o_,{children:[!o&&pp(t_,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};import{jsx as Rs}from"react/jsx-runtime";var gp=u_(null),q=()=>{let e=p_(gp);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},h_=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,edgeHighlight:r=!0,validateCustomDiagram:i,onElementChanges:s,onConfigureElement:a,onElementClick:l,onSubprocessValidationClick:c})=>{let d=g_(null),{t:u}=c_(),{defaultMode:f}=En(),m=m_(),[h]=ut(o||m),[E,p]=ut(n||f||"edit"),[g,y]=ut(vn),[x,N]=ut(!1),[b,v]=ut(!0),[T,I]=ut(!1),[S,P]=ut(!1),[R,C]=ut(!1),[L,K]=ut(!1),[Q,j]=ut(!1),[z,M]=ut(null);f_(()=>{n&&p(n)},[n]);let V=!!t,D=mp(()=>t||Oc(u),[t,u]),A=mp(()=>({instanceId:h,containerRef:d,initialDiagram:D,mode:E,edgeHighlight:r,isEdit:E==="edit",isView:E==="view",isReadOnly:E==="readonly",isNewDiagram:V,lastElementId:g,isInitialized:x,isMinimapOpen:S,isMoveTool:b,isHandTool:T,isDragging:R,isMultipleSelection:Q,isConnecting:L,setLastElementId:y,setIsInitialized:N,reconnectingEdgeId:z,setIsMinimapOpen:P,setIsMoveTool:v,setIsHandTool:I,setIsDragging:C,setIsConnecting:K,setIsMultipleSelection:j,setReconnectingEdgeId:M,validateCustomDiagram:i,onElementChanges:s,onConfigureElement:a,onElementClick:l,onSubprocessValidationClick:c}),[h,d,D,E,r,V,g,x,S,b,T,R,Q,L,z,i,s,a,l,c]);return Rs(d_,{children:Rs(gp.Provider,{value:A,children:Rs(Ls,{ref:e})})})};export{Ie as EditorMode,Si as ElementPosition,On as ElementType,Ci as GatewayElementVariant,lt as GatewayVariant,h_ as Modeler,a_ as ModelerProvider,ht as NodeAttribute,ae as NodeType,qe as NodeVariant,Mi as RoutingVariant,En as useModeler};
|
|
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}};import{jsx as Le,jsxs as $o}from"react/jsx-runtime";function ju(){let{t:e}=fE(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:a}=Qu(),[s,l]=xE(!1);return $o(dE,{modal:!1,open:s,onOpenChange:l,children:[Le(pE,{asChild:!0,children:Le("div",{children:$o(xi,{children:[Le(_i,{asChild:!0,children:Le(cE,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:Le(hE,{})})}),!s&&Le(Ei,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),$o(uE,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[$o(xi,{children:[Le(_i,{asChild:!0,children:Le(Ms,{className:"p-1.5",disabled:i,onClick:()=>t(),children:Le(gE,{})})}),Le(Ei,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),$o(xi,{children:[Le(_i,{asChild:!0,children:Le(Ms,{className:"p-1.5",disabled:a,onClick:()=>o(),children:Le(mE,{})})}),Le(Ei,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),$o(xi,{children:[Le(_i,{asChild:!0,children:Le(Ms,{className:"p-1.5",disabled:r,onClick:()=>n(),children:Le(yE,{})})}),Le(Ei,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{useState as CE}from"react";import{Button as SE,Tooltip as ME,TooltipContent as PE,TooltipTrigger as LE,useTranslation as kE}from"@produto-lecom/lecom-ui";import{WorkflowIcon as RE}from"lucide-react";import{useState as tp}from"react";import{Button as op,Dialog as EE,DialogContent as _E,DialogDescription as bE,DialogFooter as TE,DialogHeader as vE,DialogTitle as NE,Textarea as wE,useTranslation as AE}from"@produto-lecom/lecom-ui";var ep=e=>{if(!e)return"";let t=e.trim();return t=t.replace(/```[a-zA-Z]*\s*/g,"").replace(/```/g,""),t=t.replace(/^\s*(graph|flowchart)\s+[A-Za-z]{1,2}\s*\r?\n/i,""),t.trim()};import{jsx as xo,jsxs as Ps}from"react/jsx-runtime";var IE=`Um passo (A --> B) por linha, com um ID antes de cada n\xF3. Ex.:
|
|
87
|
+
|
|
88
|
+
A<start> --> B[Analisar pedido]
|
|
89
|
+
B --> C{Aprovado?}
|
|
90
|
+
C -- Sim --> D[Liberar pedido]
|
|
91
|
+
C -- N\xE3o --> E[Recusar pedido]
|
|
92
|
+
D --> F<end>
|
|
93
|
+
E --> F<end>`,np=({open:e,onOpenChange:t})=>{let{t:o}=AE(),{importFromLia:n}=di(),[r,i]=tp(""),[a,s]=tp(null),l=d=>{d||(i(""),s(null)),t(d)},c=()=>{let d=ep(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 xo(EE,{open:e,onOpenChange:l,children:Ps(_E,{className:"w-[90vw] max-w-4xl",children:[Ps(vE,{children:[xo(NE,{children:o("editor.modals.mermaid_import.title")}),xo(bE,{children:o("editor.modals.mermaid_import.description")})]}),xo(wE,{value:r,onChange:d=>{i(d.target.value),a&&s(null)},placeholder:IE,rows:16,className:"max-h-[60vh] min-h-[360px] resize-y font-mono"}),a&&xo("p",{className:"text-sm text-red-500",children:a}),Ps(TE,{children:[xo(op,{variant:"ghost",color:"grey",onClick:()=>l(!1),children:o("editor.modals.mermaid_import.cancel")}),xo(op,{variant:"filled",color:"blue",onClick:c,children:o("editor.modals.mermaid_import.generate")})]})]})})};import{Fragment as DE,jsx as Dn,jsxs as rp}from"react/jsx-runtime";var ip=()=>{let{t:e}=kE(),[t,o]=CE(!1);return rp(DE,{children:[rp(ME,{children:[Dn(LE,{asChild:!0,children:Dn(SE,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>o(!0),children:Dn(RE,{})})}),Dn(PE,{color:"black",children:e("editor.controls.actions.import_mermaid")})]}),Dn(np,{open:t,onOpenChange:o})]})};import{Fragment as lp,jsx as Ie,jsxs as Lt}from"react/jsx-runtime";var cp=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=VE(),{clearSelection:i}=zt(),{mode:a,containerRef:s,featureFlags:l,isMinimapOpen:c,setIsMinimapOpen:d,isMoveTool:u,isHandTool:f,setIsMoveTool:m,setIsHandTool:y}=q(),{getNodes:E,getEdges:p}=OE(),g=sp(["v","V"],{target:s==null?void 0:s.current}),h=sp(["h","H"],{target:s==null?void 0:s.current}),x=Ls(()=>{i(),y(!0),m(!1)},[i,y,m]),N=Ls(()=>{m(!0),y(!1)},[m,y]),[b,T]=FE(!1),v=Ls(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 ap(()=>{g&&!u&&a==="edit"&&N()},[g,N,u,a]),ap(()=>{h&&!f&&a==="edit"&&x()},[h,x,f,a]),Lt("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[a==="edit"&&Lt(lp,{children:[Lt(Ti,{children:[Ie(Ni,{asChild:!0,children:Ie(bi,{size:"small",variant:"ghost",color:"grey",className:H(u&&"bg-grey-400"),iconButton:!0,onClick:N,children:Ie(YE,{})})}),Lt(vi,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),Ie(Cs,{shortcut:"V"})]})]}),Lt(Ti,{children:[Ie(Ni,{asChild:!0,children:Ie(bi,{size:"small",variant:"ghost",color:"grey",className:H(f&&"bg-grey-400"),iconButton:!0,onClick:x,children:Ie(HE,{})})}),Lt(vi,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",Ie(Cs,{shortcut:"H"})]})]})]}),Ie(ju,{}),a==="edit"&&Lt(lp,{children:[(l==null?void 0:l.importDiagramMermaidEnabled)&&Ie(ip,{}),Lt(Ti,{children:[Ie(Ni,{asChild:!0,children:Ie(bi,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:b,onClick:v,children:b?Ie(BE,{className:"animate-spin"}):Ie(GE,{})})}),Ie(vi,{color:"black",children:r(b?"editor.controls.actions.check_loading":"editor.controls.actions.check")})]}),Ie(qu,{disabled:e.length>0||t.length>0})]}),Lt(Ti,{children:[Ie(Ni,{asChild:!0,children:Ie(bi,{size:"small",variant:"ghost",color:"grey",className:H(c&&"bg-grey-400"),iconButton:!0,onClick:()=>d(!c),children:Ie(zE,{})})}),Ie(vi,{color:"black",children:r(c?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as dp,Tooltip as up,TooltipContent as pp,TooltipTrigger as fp,useTranslation as WE}from"@produto-lecom/lecom-ui";import{RedoIcon as XE,UndoIcon as UE}from"lucide-react";import{jsx as jt,jsxs as ks}from"react/jsx-runtime";var mp=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=WE();return ks("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[ks(up,{children:[jt(fp,{asChild:!0,children:jt(dp,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:jt(UE,{})})}),jt(pp,{color:"black",children:r("editor.controls.history.undo")})]}),ks(up,{children:[jt(fp,{asChild:!0,children:jt(dp,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:jt(XE,{})})}),jt(pp,{color:"black",children:r("editor.controls.history.redo")})]})]})};import{useEdges as $E,useNodes as KE,useReactFlow as qE}from"@xyflow/react";import{Button as wi,Tooltip as Ai,TooltipContent as Ii,TooltipTrigger as Ci,useTranslation as ZE}from"@produto-lecom/lecom-ui";import{ScanIcon as JE,ZoomIn as QE,ZoomOut as jE}from"lucide-react";import{jsx as Ve,jsxs as On}from"react/jsx-runtime";var gp=()=>{let{t:e}=ZE(),t=KE(),o=$E(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:a}=qE(),s=t.length===0&&o.length===0;return On("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[On(Ai,{children:[Ve(Ci,{asChild:!0,children:Ve(wi,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>a(),children:Ve(JE,{})})}),Ve(Ii,{color:"black",children:e("editor.controls.zoom.fit")})]}),On(Ai,{children:[Ve(Ci,{asChild:!0,children:Ve(wi,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>r(),children:Ve(jE,{})})}),Ve(Ii,{color:"black",children:e("editor.controls.zoom.out")})]}),On(Ai,{children:[Ve(Ci,{asChild:!0,children:Ve(wi,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>i(1),children:Ve(js,{})})}),Ve(Ii,{color:"black",children:e("editor.controls.zoom.reset")})]}),On(Ai,{children:[Ve(Ci,{asChild:!0,children:Ve(wi,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>n(),children:Ve(QE,{})})}),Ve(Ii,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{ViewportPortal as e_}from"@xyflow/react";import{jsx as Rs,jsxs as hp}from"react/jsx-runtime";var yp=()=>hp(e_,{children:[hp("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:[Rs("line",{x1:"0",y1:"10",x2:"20",y2:"10",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"}),Rs("line",{x1:"10",y1:"0",x2:"10",y2:"20",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"})]}),Rs("div",{className:"absolute top-1 left-1 text-xs font-medium text-grey-400 bg-white/70 px-1 rounded-sm pointer-events-none",children:"0,0"})]});import{useNodes as t_}from"@xyflow/react";import{Button as o_,Tooltip as n_,TooltipContent as r_,TooltipTrigger as i_,useTranslation as s_}from"@produto-lecom/lecom-ui";import{useRef as a_,useState as l_}from"react";import{Bot as c_}from"lucide-react";import{jsx as Eo,jsxs as xp}from"react/jsx-runtime";var Ep=()=>{let e=a_(null),{t}=s_(),{setDraggableNode:o}=Yo(),n=t_(),{setIsDragging:r}=q(),[i,a]=l_(void 0),s=[{type:"START_EVENT",icon:Yn,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:_o,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:qo,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:Jo,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SERVICE_TASK",icon:c_,label:t("bpmn.task.variant.service_task")},{type:"TASK",variant:"SCRIPT",icon:na,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:oa,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:To,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:vo,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:bo,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:Qs,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:Bn,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),a(Eo(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return xp("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[Eo("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:s.map((c,d)=>{let u=!Bt(c.type,n),f=u?t("editor.toolbar.start_event_already_exists"):c.label;return xp(n_,{children:[Eo(i_,{asChild:!0,children:Eo(o_,{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:Eo(c.icon,{})},d)}),Eo(r_,{color:"black",side:"right",children:f})]},d)})}),Eo("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{jsx as at,jsxs as Si}from"react/jsx-runtime";var Ds=e=>e.preventDefault(),Os=g_((e,t)=>{let{instanceId:o,containerRef:n,mode:r,isMinimapOpen:i,isMoveTool:a,isHandTool:s}=q(),l=m_("Space",{target:n==null?void 0:n.current}),c=_p(s),d=_p(l),{nodes:u,edges:f,actions:m,events:y,components:E,controls:p}=Lu(),{t:g}=__();c.current=s,d.current=l;let h=ku(n,c,d);h_(t,()=>({selectElements:m.selectElements,clearSelection:m.clearSelection}));let x=s||l||r!=="edit",N=x?[0,1,2]:Cn,b=s||l||h,T=a&&!l&&!h,v=r==="edit"&&T,A=!x&&!h,C=r==="view"||T;return Si("div",{ref:n,className:"w-full h-full outline-none",tabIndex:0,children:[r==="edit"&&at(Ep,{}),at(Du,{}),Si(p_,w(_({},y),{id:`modeler-${o}`,className:H(r.toLowerCase(),{"is-hand-tool":b,"is-pan-tool-active":b}),edges:f,nodes:u,nodeTypes:zd,edgeTypes:Yd,minZoom:ws,maxZoom:Kd,panOnDrag:N,panOnScroll:!0,selectionOnDrag:A,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:C,nodesConnectable:v,nodesDraggable:v,connectionLineComponent:Hd,selectionMode:f_.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:v?"Delete":null,selectionKeyCode:null,defaultViewport:jd,connectOnClick:!1,connectionRadius:50,onPaneContextMenu:Ds,onNodeContextMenu:Ds,onEdgeContextMenu:Ds,proOptions:{hideAttribution:!0},children:[at(d_,{gap:Ud,size:Xd,color:Wd,bgColor:Fd}),at(yp,{}),i&&Si(y_,{children:[at(E_,{asChild:!0,children:at("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:at(u_,{pannable:!0,zoomable:!0,position:$d,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),at(x_,{color:"black",children:g("editor.controls.actions.minimap.label")})]}),Si("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&at(mp,_({},p)),r!=="readonly"&&at(cp,{nodes:u,edges:f,validateDiagram:m.validateDiagram,handleValidationComplete:m.handleValidationComplete}),at(gp,{})]}),at(E.HelperLines,{})]}))]})});Os.displayName="Editor";import{useStore as b_}from"@xyflow/react";import{useEffect as T_,useRef as v_}from"react";import{jsx as w_}from"react/jsx-runtime";var N_=e=>({width:e.width,height:e.height,transform:e.transform}),Vs="rgba(51, 103, 217, 0.4)",dc=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=b_(N_),i=v_(null);return T_(()=>{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=Vs,t&&(s.beginPath(),s.strokeStyle=t.color||Vs,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||Vs,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]),w_("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as A_,Notification as I_,TooltipProvider as C_}from"@produto-lecom/lecom-ui";import{createContext as S_,useContext as M_,useEffect as P_,useState as L_}from"react";import{jsx as bp,jsxs as R_}from"react/jsx-runtime";var Et=new Map,Tp=S_(null),_n=()=>{let e=M_(Tp);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},k_=({locale:e,defaultMode:t="view",featureFlags:o,toast:n,children:r})=>{let[i,a]=L_(e||"pt_BR");P_(()=>{e&&(a(e),A_.changeLanguage(e))},[e]);let s=E=>{let p=Et.size;if(p===0)throw new Error("No modeler instances found");if(p===1||!E){let[h]=Et.values();return h}let g=Et.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 bp(Tp.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:R_(C_,{children:[!n&&bp(I_,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),r]})})};import{jsx as Hs}from"react/jsx-runtime";var Np=V_(null),q=()=>{let e=H_(Np);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},Y_=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,edgeHighlight:r=!0,validateCustomDiagram:i,onElementChanges:a,onConfigureElement:s,onElementClick:l,onSubprocessValidationClick:c})=>{let d=z_(null),{t:u}=D_(),{defaultMode:f,featureFlags:m}=_n(),y=B_(),[E]=ut(o||y),[p,g]=ut(n||f||"edit"),[h,x]=ut(Nn),[N,b]=ut(!1),[T,v]=ut(!0),[A,C]=ut(!1),[P,R]=ut(!1),[S,L]=ut(!1),[K,j]=ut(!1),[Q,z]=ut(!1),[M,V]=ut(null);G_(()=>{n&&g(n)},[n]);let D=!!t,I=vp(()=>t||Bc(u),[t,u]),B=vp(()=>({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 Hs(O_,{children:Hs(Np.Provider,{value:B,children:Hs(Os,{ref:e})})})};export{Ae as EditorMode,Pi as ElementPosition,Hn as ElementType,Li as GatewayElementVariant,lt as GatewayVariant,Y_ as Modeler,k_ as ModelerProvider,ht as NodeAttribute,ae as NodeType,qe as NodeVariant,ki as RoutingVariant,_n as useModeler};
|