lecom-modeler 0.34.0 → 0.36.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 +12 -12
- package/lib/index.js +12 -12
- package/lib/style.min.css +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var cp=Object.defineProperty,dp=Object.defineProperties;var up=Object.getOwnPropertyDescriptors;var On=Object.getOwnPropertySymbols;var Hs=Object.prototype.hasOwnProperty,Gs=Object.prototype.propertyIsEnumerable;var Vs=(e,t,o)=>t in e?cp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,b=(e,t)=>{for(var o in t||(t={}))Hs.call(t,o)&&Vs(e,o,t[o]);if(On)for(var o of On(t))Gs.call(t,o)&&Vs(e,o,t[o]);return e},w=(e,t)=>dp(e,up(t));var gt=(e,t)=>{var o={};for(var n in e)Hs.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&On)for(var n of On(e))t.indexOf(n)<0&&Gs.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 pp,Translations as fp}from"@produto-lecom/lecom-ui";var Bs={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",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:"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"}},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"},attribute:{loop:"Task with loop"},label:{prefix:"Activity"},feedback:{label_empty:{prefix:"Activity name was automatically set to"},label_already_exists:{prefix:"The name",middle:"already exists. The name was changed to"},invalid_first_character:"Activity name must start with a letter or number"}},lane:{variant:{default:"Pool / Lane"}},unsupported:{variant:{default:"Unsupported element"}}},adapter:{governance:{error:{DEFAULT:"Error importing diagram",NO_FILE:"No file selected",EMPTY_FILE:"Empty file",INVALID_FILE:"Invalid file",CONTAIN_NO_CELLS:"No cells found to be imported",ALREADY_INITIALIZED:"It is not possible to import the diagram from the Governance platform, since the diagram has already been initialized"},success:{default:"The diagram was imported from the Governance platform successfully and without any incompatibility detected.",incompatible_cells:"The diagram was imported from the Governance platform with incompatibilities. To know more details, click on the button below."},report:{columns:{type:"Type",value:"Value",status:"Status"},status:{imported:"Imported",adapted:"Adapted",unsupported:"Unsupported"}},action:{download:"Download report"}}}}};var zs={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",configure_node:"Configurar actividad",configure_edge:"Configurar enrutamiento",configure_gateway:"Configurar enrutamiento",initial_task:"Actividad Inicial",gateway_limit_reached:"Compuerta exclusiva no puede tener m\xE1s de 2 conexiones de salida",task_limit_reached:"Actividad no puede tener m\xE1s de 2 conexiones de salida",start_event_limit_reached:"Evento inicial solo puede conectarse a un \xFAnico elemento",gateway_to_gateway_not_allowed:"Las compuertas no pueden conectarse directamente con otras compuertas",start_event_already_exists:"Ya existe un evento de inicio. Elimine el evento actual para agregar otro",script_to_end_not_allowed:"Las actividades Script no pueden conectarse directamente al evento final",loop_to_end_not_allowed:"Las actividades Loop no pueden conectarse directamente al evento final",initial_activity_to_end_not_allowed:"Actividad inicial no puede conectarse directamente al evento final",final_activity_cannot_connect:"Actividad final no puede conectarse a otros elementos",activity_has_outgoing_connections:"Actividad con conexiones de salida no puede conectarse al evento final",end_event_cannot_connect_to_initial_activity:"El evento final no puede conectarse a una actividad inicial",initial_activity_cannot_connect_to_start_event:"Actividad inicial no puede conectarse a evento de inicio",concurrent_initial_and_final_activity:"Una actividad no puede estar conectada al evento inicial y final al mismo tiempo",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:"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"}},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"},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 Ys={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",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:"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"}},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"},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 Ws={pt_BR:Ys,en_US:Bs,es_ES:zs};var Fs,Xs,mp=(Xs=(Fs=Ai("LecomUserLanguage"))!=null?Fs:Ai("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?Xs:fp.PT_BR;pp({lng:mp,resources:Ws});var Ie=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(Ie||{});var Vn=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(Vn||{}),Ci=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Ci||{}),Si=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Si||{}),Mi=(d=>(d.SIMPLE="simple",d.LOOP="loop",d.SCRIPT="script",d.SCRIPT_LOOP="script_loop",d.COMPLEX="complex",d.EXCLUSIVE="exclusive",d.PARALLEL="parallel",d.FINAL="final",d.TO_SUB_PROCESS="to_sub_process",d.FROM_SUB_PROCESS="from_sub_process",d))(Mi||{});import{RotateCcw as Ip,ScrollText as Ap,SquarePlus as Cp}from"lucide-react";import{jsx as Hn,jsxs as gp}from"react/jsx-runtime";var Gn=({size:e=24,className:t})=>gp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:[Hn("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),Hn("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),Hn("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),Hn("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as Us}from"react/jsx-runtime";var bo=({size:e=24,className:t})=>Us("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:Us("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 Zo,jsxs as hp}from"react/jsx-runtime";var _o=({size:e=24,className:t})=>hp("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:[Zo("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"}),Zo("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Zo("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),Zo("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Zo("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Pi,jsxs as yp}from"react/jsx-runtime";var To=({size:e=24,className:t})=>yp("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 xp}from"react/jsx-runtime";var No=({size:e=24,className:t})=>xp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[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 Ri,jsxs as Ep}from"react/jsx-runtime";var $s=({size:e=24,className:t})=>Ri("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:Ep("g",{children:[Ri("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"}),Ri("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as bp}from"clsx";import{twMerge as _p}from"tailwind-merge";function G(...e){return _p(bp(e))}var Dt=(e=0,t=0)=>e<t?t:e,Bn=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as Ks,jsxs as Tp}from"react/jsx-runtime";var qs=({size:e=24,className:t})=>Tp("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:G("stroke-2",t),children:[Ks("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"}),Ks("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as ki}from"react/jsx-runtime";var Zs=({size:e=24,className:t})=>ki("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:ki("g",{children:ki("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 Js}from"react/jsx-runtime";var zn=({size:e=24,className:t})=>Js("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:Js("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 Qs}from"react/jsx-runtime";var Jo=({size:e=24,className:t})=>Qs("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",className:G("stroke-2",t),children:Qs("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 Np}from"react/jsx-runtime";var js=({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:"#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 vp}from"react/jsx-runtime";var ea=({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:"#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 Yn,jsxs as wp}from"react/jsx-runtime";var jo=({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:[Yn("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"}),Yn("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),Yn("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Yn("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||{}),tt=(o=>(o.SCRIPT="SCRIPT",o.SUBPROCESS="SUBPROCESS",o))(tt||{}),Wn={SCRIPT:{icon:Ap},SUBPROCESS:{icon:Cp}},ht=(t=>(t.LOOP="LOOP",t))(ht||{}),Fn={LOOP:{icon:Ip}},at=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(at||{}),Oi={EXCLUSIVE:{icon:To},PARALLEL:{icon:No},COMPLEX:{icon:_o}};import{useTranslation as QE}from"@produto-lecom/lecom-ui";import{ReactFlowProvider as jE}from"@xyflow/react";import{createContext as e1,useContext as t1,useEffect as o1,useId as n1,useMemo as r1,useState as ut}from"react";import{Background as AE,MiniMap as CE,ReactFlow as SE,SelectionMode as ME,useKeyPress as PE}from"@xyflow/react";import{forwardRef as LE,useImperativeHandle as RE,useRef as Ps}from"react";import{useTranslation as J0}from"@produto-lecom/lecom-ui";import{useEdgesState as Q0,useNodesState as j0,useOnSelectionChange as ex,useReactFlow as tx,useStoreApi as ox}from"@xyflow/react";import{useCallback as bt,useEffect as nx}from"react";var Xn={MIN_WIDTH:36,MIN_HEIGHT:36},Un={MIN_WIDTH:36,MIN_HEIGHT:36},vo={MIN_WIDTH:56,MIN_HEIGHT:56},Ot={MIN_WIDTH:176,MIN_HEIGHT:96},ta={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},Sp={MIN_WIDTH:128,MIN_HEIGHT:64},ue={START_EVENT:Xn,END_EVENT:Un,GATEWAY:vo,TASK:Ot,LANE:se,ANNOTATION:wo,UNSUPPORTED:Sp};import{Position as en}from"@xyflow/react";function oa(e,t){var E,v,N,T;let{width:o=0,height:n=0}=e.measured||{width:0,height:0},r=e.internals.positionAbsolute,i=t.internals.positionAbsolute,s=o/2,a=n/2,l=r.x+s,c=r.y+a,d=i.x+((v=(E=t==null?void 0:t.measured)==null?void 0:E.width)!=null?v:0)/2,u=i.y+((T=(N=t==null?void 0:t.measured)==null?void 0:N.height)!=null?T:0)/2,m=(d-l)/(2*s)-(u-c)/(2*a),p=(d-l)/(2*s)+(u-c)/(2*a),g=1/(Math.abs(m)+Math.abs(p)||1),x=g*m,f=g*p,h=s*(x+f)+l,y=a*(-x+f)+c;return{x:h,y}}function na(e,t){var c,d,u,m;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(m=(u=e.measured)==null?void 0:u.height)!=null?m:0,i=Math.round(o.x),s=Math.round(o.y),a=Math.round(t.x),l=Math.round(t.y);return a<=i+1?en.Left:a>=i+n-1?en.Right:l<=s+1?en.Top:l>=s+r-1?en.Bottom:en.Top}function Io(e,t){let o=oa(e,t),n=oa(t,e),r=na(e,o),i=na(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function $n(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 Mp}from"lodash";var ra=e=>new Map(e.map(t=>[t.id,t])),ia=(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}},eo=e=>Mp(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),sa=(e,t)=>{let{x:o,y:n}=ot(e),{x:r,y:i}=ot(t);return{x:o-r,y:n-i}};var to=({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)),Pp=(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)},Lp=(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},tn=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&Lp(e,r)){let i=Pp(e,r);i<n&&(n=i,o=r)}return o},aa=(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),la=(e,t)=>{let o=e.filter(c=>!c.parentId);if(o.length===0)return{nodes:e,edges:t};let n=o.filter(c=>c.type==="LANE"),r=n.length>0?n:o,i=Math.min(...r.map(c=>c.position.x||0)),s=Math.min(...r.map(c=>c.position.y||0)),a=e.map(c=>c.parentId?c:w(b({},c),{position:{x:c.position.x-i,y:c.position.y-s}})),l=t.map(c=>{let d=c.data;return d!=null&&d.points?w(b({},c),{data:w(b({},d),{points:d.points.map(u=>({x:u.x-i,y:u.y-s}))})}):c});return{nodes:a,edges:l}},ca=e=>{var l,c;let t=e.filter(d=>!d.parentId),o=t.filter(d=>d.type==="LANE"),n=o.length>0?o:t;if(n.length===0)return null;let r=1/0,i=1/0,s=-1/0,a=-1/0;for(let d of n){let u=d.position.x+((l=d.width)!=null?l:0),m=d.position.y+((c=d.height)!=null?c:0);d.position.x<r&&(r=d.position.x),d.position.y<i&&(i=d.position.y),u>s&&(s=u),m>a&&(a=m)}return{x:r,y:i,width:s-r,height:a-i}};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 Rp=50,oo=(e,t)=>{var m,p,g,x,f,h,y,E,v,N,T,_,A,M,C,O;let o=t.find(P=>P.id===e);if(!o)return t;let n=(p=(m=o.position)==null?void 0:m.x)!=null?p:0,r=(x=(g=o.position)==null?void 0:g.y)!=null?x:0,i=(h=(f=o.measured)==null?void 0:f.width)!=null?h:0,s=(E=(y=o.measured)==null?void 0:y.height)!=null?E:0,a=r+s,l=n+i,c=new Set,d=1/0;for(let P of t){if(P.id===e||P.parentId)continue;let H=(N=(v=P.position)==null?void 0:v.y)!=null?N:0,q=(_=(T=P.position)==null?void 0:T.x)!=null?_:0,Q=(M=(A=P.measured)==null?void 0:A.width)!=null?M:0,te=(O=(C=P.measured)==null?void 0:C.height)!=null?O:0;q<l&&q+Q>n&&H<a&&H+te>r&&(c.add(P.id),d=Math.min(d,H))}if(c.size===0)return t;let u=a+Rp-d;return t.map(P=>{var q,Q,te;if(!c.has(P.id))return P;let H=(Q=(q=P.position)==null?void 0:q.y)!=null?Q:0;return w(b({},P),{position:w(b({},(te=P.position)!=null?te:{x:0,y:0}),{y:H+u})})})},ve=15,no=e=>[...e].sort((t,o)=>t.position.y-o.position.y),kp=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)},Dp=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,m,p,g,x,f,h,y,E,v,N,T,_,A;if(t.length===0)return e;let n=(m=(u=e.width)!=null?u:(d=e.measured)==null?void 0:d.width)!=null?m:0,r=(x=(g=e.height)!=null?g:(p=e.measured)==null?void 0:p.height)!=null?x:0,i=0,s=0;for(let M of t){let C=kp(M),O=Dp(M);if(((h=(f=M.position)==null?void 0:f.y)!=null?h:0)<ve&&(o.set(M.id,w(b({},M),{position:w(b({},M.position),{y:ve})})),O=ve+((E=(y=M.measured)==null?void 0:y.height)!=null?E:0)),((N=(v=M.position)==null?void 0:v.x)!=null?N:0)<se.HEADER_WIDTH+ve){let P=(T=o.get(M.id))!=null?T:M;o.set(M.id,w(b({},P),{position:w(b({},P.position),{x:se.HEADER_WIDTH+ve})})),C=se.HEADER_WIDTH+ve+((A=(_=M.measured)==null?void 0:_.width)!=null?A:0)}i=Math.max(i,C),s=Math.max(s,O)}let a=Math.max(n,se.MIN_WIDTH),l=Math.max(r,se.MIN_HEIGHT);i+ve>a&&(a=i+ve),s+ve>l&&(l=s+ve);let c=w(b({},e),{width:a,height:l,measured:w(b({},e.measured),{width:a,height:l})});return o.set(e.id,c),c},da=(e,t,o)=>{var s,a;let n=no(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(b({},d),{position:{x:se.HEADER_WIDTH,y:i}})),i+=(a=d.height)!=null?a:0}},ua=(e,t)=>{var g,x,f,h;let o=[];for(let y of t.values())y.parentId===e.id&&o.push(y);let n=no(o),r=((x=(g=e.measured)==null?void 0:g.width)!=null?x:0)-se.HEADER_WIDTH,i=aa(e.id,o)||se.MIN_WIDTH,s=o.reduce((y,E)=>{var v;return y+((v=E.height)!=null?v: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,m=0;for(let y=0;y<n.length;y++){let E=n[y],v=Math.max(se.MIN_HEIGHT,(f=E.height)!=null?f:se.MIN_HEIGHT),N=w(b({},E),{width:u,height:v,measured:w(b({},E.measured),{width:u,height:v}),position:{x:se.HEADER_WIDTH,y:m}});if(y===o.length-1){let T=Math.max(se.MIN_HEIGHT,l-m);N=w(b({},N),{height:T,measured:w(b({},E.measured),{width:u,height:T})})}t.set(E.id,N),m+=(h=N.height)!=null?h:0}let p=Math.max(l,m);t.set(e.id,w(b({},e),{width:d,height:p,measured:w(b({},e.measured),{width:d,height:p})}))},pa=(e,t,o,n,r)=>{var g,x;let i=!e.parentId,s=i?e.id:e.parentId,a=n.filter(f=>f.type==="LANE"&&f.parentId===s);if(!a.length)return n;let l=no(a),c=l.findIndex(f=>f.id===e.id),d=(x=(g=e.position)==null?void 0:g.y)!=null?x:0,u=!i&&r!==void 0&&c>0&&Math.abs(r-d)>.5,m=0,p=[...n];return l.forEach((f,h)=>{var T,_;let y=h===l.length-1,E=f.id===e.id,N=(_=(T=f.measured)==null?void 0:T.height)!=null?_:0;E?N=o:u&&h===c-1&&(N=Math.max(se.MIN_HEIGHT,r-m)),y&&i&&(N=Math.max(se.MIN_HEIGHT,o-m)),p=p.map(A=>{if(A.id===f.id){let M=i?t-se.HEADER_WIDTH:t;return w(b({},A),{width:M,height:N,measured:w(b({},A.measured),{width:M,height:N}),position:{x:se.HEADER_WIDTH,y:m}})}return A}),E&&u?m=r+o:m+=N}),p=p.map(f=>{if(f.id===s){let h=i?t:t+se.HEADER_WIDTH;return w(b({},f),{width:h,height:i?o:m,measured:{width:h,height:i?o:m}})}return f}),p};var Gi=(e,t,o)=>{var a,l,c,d,u,m,p,g;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<ve&&(e.position.y=ve),e.position.x<se.HEADER_WIDTH+ve&&(e.position.x=se.HEADER_WIDTH+ve);let i=e.position.x+((m=(u=e.measured)==null?void 0:u.width)!=null?m:0),s=e.position.y+((g=(p=e.measured)==null?void 0:p.height)!=null?g:0);return i+ve>n&&(t.width=i+ve,t.measured.width=i+ve),s+ve>r&&(t.height=s+ve,t.measured.height=s+ve),o=o.map(x=>x.id===t.id?w(b({},x),{height:t.height,width:t.width,measured:t.measured}):x.id===e.id?w(b({},x),{position:e.position}):x),o};import{create as Op}from"zustand";import{useReactFlow as Vp}from"@xyflow/react";import{useCallback as Hp}from"react";var Kn=()=>{let{setEdges:e}=Vp();return Hp(()=>{let o=ro.getState().pathEdgeIds;e(n=>n.map(r=>w(b({},r),{selected:o.includes(r.id)})))},[e])},ro=Op((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=b({},n.statusByNodeId),i=b({},n.statusData),s=!1;return o.forEach(a=>{let l=`${a.diagramId}-${a.activityId}`;r[a.diagramId]!==a.status&&(r[a.diagramId]=a.status,i[l]=a,s=!0)}),s?{statusByNodeId:r,statusData:i}:n})},getTaskStatus:o=>t().statusByNodeId[o]||null,clearTaskStatuses:()=>e({statusByNodeId:{},statusData:{},pathEdgeIds:[]}),setPathEdges:o=>{e({pathEdgeIds:o})},getPathEdgeIds:()=>t().pathEdgeIds,clearPathEdges:()=>{e({pathEdgeIds:[]})},calculateFlowPath:(o,n)=>{if(!o.length||!n.length)return;t().clearPathEdges();let r=n.filter(d=>t().statusByNodeId[d]);if(r.length<=1)return;let i=[],s={};o.forEach(d=>{s[d.source]||(s[d.source]=[]),s[d.source].push({targetId:d.target,edgeId:d.id})});let a=r[0],l=r[r.length-1];o.forEach(d=>{d.target===a&&i.push(d.id)}),o.forEach(d=>{d.source===l&&i.push(d.id)});let c=(d,u)=>{let m=[],p=new Set;for(m.push({node:d,path:[]}),p.add(d);m.length>0;){let{node:g,path:x}=m.shift();if(g===u)return x;let f=s[g]||[];for(let{targetId:h,edgeId:y}of f)p.has(h)||(p.add(h),m.push({node:h,path:[...x,y]}))}return[]};for(let d=0;d<r.length-1;d++){let u=r[d],m=r[d+1],p=c(u,m);p.length>0&&i.push(...p)}i.length>0&&e({pathEdgeIds:i})}}));import{useNodesInitialized as eg,useReactFlow as tg,useStore as og}from"@xyflow/react";import{useCallback as yn,useEffect as ng,useRef as rg,useState as sc}from"react";import{shallow as ig}from"zustand/shallow";var Gp={value:()=>{}};function ma(){for(var e=0,t=arguments.length,o={},n;e<t;++e){if(!(n=arguments[e]+"")||n in o||/[\s.]/.test(n))throw new Error("illegal type: "+n);o[n]=[]}return new qn(o)}function qn(e){this._=e}function Bp(e,t){return e.trim().split(/^|\s+/).map(function(o){var n="",r=o.indexOf(".");if(r>=0&&(n=o.slice(r+1),o=o.slice(0,r)),o&&!t.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:n}})}qn.prototype=ma.prototype={constructor:qn,on:function(e,t){var o=this._,n=Bp(e+"",o),r,i=-1,s=n.length;if(arguments.length<2){for(;++i<s;)if((r=(e=n[i]).type)&&(r=zp(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]=fa(o[r],e.name,t);else if(t==null)for(r in o)o[r]=fa(o[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var o in t)e[o]=t[o].slice();return new qn(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var o=new Array(r),n=0,r,i;n<r;++n)o[n]=arguments[n+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],n=0,r=i.length;n<r;++n)i[n].value.apply(t,o)},apply:function(e,t,o){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var n=this._[e],r=0,i=n.length;r<i;++r)n[r].value.apply(t,o)}};function zp(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function fa(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=Gp,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var Bi=ma;var Zn="http://www.w3.org/1999/xhtml",zi={svg:"http://www.w3.org/2000/svg",xhtml:Zn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function vt(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 Yp(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===Zn&&t.documentElement.namespaceURI===Zn?t.createElement(e):t.createElementNS(o,e)}}function Wp(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Jn(e){var t=vt(e);return(t.local?Wp:Yp)(t)}function Fp(){}function io(e){return e==null?Fp:function(){return this.querySelector(e)}}function ga(e){typeof e!="function"&&(e=io(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 Xp(){return[]}function on(e){return e==null?Xp:function(){return this.querySelectorAll(e)}}function Up(e){return function(){return Yi(e.apply(this,arguments))}}function ha(e){typeof e=="function"?e=Up(e):e=on(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 nn(e){return function(){return this.matches(e)}}function Qn(e){return function(t){return t.matches(e)}}var $p=Array.prototype.find;function Kp(e){return function(){return $p.call(this.children,e)}}function qp(){return this.firstElementChild}function ya(e){return this.select(e==null?qp:Kp(typeof e=="function"?e:Qn(e)))}var Zp=Array.prototype.filter;function Jp(){return Array.from(this.children)}function Qp(e){return function(){return Zp.call(this.children,e)}}function xa(e){return this.selectAll(e==null?Jp:Qp(typeof e=="function"?e:Qn(e)))}function Ea(e){typeof e!="function"&&(e=nn(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],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 jn(e){return new Array(e.length)}function ba(){return new Ae(this._enter||this._groups.map(jn),this._parents)}function rn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}rn.prototype={constructor:rn,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function _a(e){return function(){return e}}function jp(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 rn(e,i[s]);for(;s<l;++s)(a=t[s])&&(r[s]=a)}function ef(e,t,o,n,r,i,s){var a,l,c=new Map,d=t.length,u=i.length,m=new Array(d),p;for(a=0;a<d;++a)(l=t[a])&&(m[a]=p=s.call(l,l.__data__,a,t)+"",c.has(p)?r[a]=l:c.set(p,l));for(a=0;a<u;++a)p=s.call(e,i[a],a,i)+"",(l=c.get(p))?(n[a]=l,l.__data__=i[a],c.delete(p)):o[a]=new rn(e,i[a]);for(a=0;a<d;++a)(l=t[a])&&c.get(m[a])===l&&(r[a]=l)}function tf(e){return e.__data__}function Ta(e,t){if(!arguments.length)return Array.from(this,tf);var o=t?ef:jp,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],m=u.length,p=of(e.call(d,d&&d.__data__,c,n)),g=p.length,x=a[c]=new Array(g),f=s[c]=new Array(g),h=l[c]=new Array(m);o(d,u,x,f,h,p,t);for(var y=0,E=0,v,N;y<g;++y)if(v=x[y]){for(y>=E&&(E=y+1);!(N=f[E])&&++E<g;);v._next=N||null}}return s=new Ae(s,n),s._enter=a,s._exit=l,s}function of(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Na(){return new Ae(this._exit||this._groups.map(jn),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 wa(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,m=a[l]=new Array(u),p,g=0;g<u;++g)(p=c[g]||d[g])&&(m[g]=p);for(;l<r;++l)a[l]=o[l];return new Ae(a,this._parents)}function Ia(){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 Aa(e){e||(e=nf);function t(u,m){return u&&m?e(u.__data__,m.__data__):!u-!m}for(var o=this._groups,n=o.length,r=new Array(n),i=0;i<n;++i){for(var 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 nf(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Ca(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Sa(){return Array.from(this)}function Ma(){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 Pa(){let e=0;for(let t of this)++e;return e}function La(){return!this.node()}function Ra(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 rf(e){return function(){this.removeAttribute(e)}}function sf(e){return function(){this.removeAttributeNS(e.space,e.local)}}function af(e,t){return function(){this.setAttribute(e,t)}}function lf(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function cf(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function df(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=vt(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?sf:rf:typeof t=="function"?o.local?df:cf:o.local?lf:af)(o,t))}function er(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function uf(e){return function(){this.style.removeProperty(e)}}function pf(e,t,o){return function(){this.style.setProperty(e,t,o)}}function ff(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function Da(e,t,o){return arguments.length>1?this.each((t==null?uf:typeof t=="function"?ff:pf)(e,t,o==null?"":o)):Vt(this.node(),e)}function Vt(e,t){return e.style.getPropertyValue(t)||er(e).getComputedStyle(e,null).getPropertyValue(t)}function mf(e){return function(){delete this[e]}}function gf(e,t){return function(){this[e]=t}}function hf(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function Oa(e,t){return arguments.length>1?this.each((t==null?mf:typeof t=="function"?hf:gf)(e,t)):this.node()[e]}function Va(e){return e.trim().split(/^|\s+/)}function Wi(e){return e.classList||new Ha(e)}function Ha(e){this._node=e,this._names=Va(e.getAttribute("class")||"")}Ha.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 Ga(e,t){for(var o=Wi(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function Ba(e,t){for(var o=Wi(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function yf(e){return function(){Ga(this,e)}}function xf(e){return function(){Ba(this,e)}}function Ef(e,t){return function(){(t.apply(this,arguments)?Ga:Ba)(this,e)}}function za(e,t){var o=Va(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"?Ef:t?yf:xf)(o,t))}function bf(){this.textContent=""}function _f(e){return function(){this.textContent=e}}function Tf(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function Ya(e){return arguments.length?this.each(e==null?bf:(typeof e=="function"?Tf:_f)(e)):this.node().textContent}function Nf(){this.innerHTML=""}function vf(e){return function(){this.innerHTML=e}}function wf(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function Wa(e){return arguments.length?this.each(e==null?Nf:(typeof e=="function"?wf:vf)(e)):this.node().innerHTML}function If(){this.nextSibling&&this.parentNode.appendChild(this)}function Fa(){return this.each(If)}function Af(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Xa(){return this.each(Af)}function Ua(e){var t=typeof e=="function"?e:Jn(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Cf(){return null}function $a(e,t){var o=typeof e=="function"?e:Jn(e),n=t==null?Cf:typeof t=="function"?t:io(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function Sf(){var e=this.parentNode;e&&e.removeChild(this)}function Ka(){return this.each(Sf)}function Mf(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Pf(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function qa(e){return this.select(e?Pf:Mf)}function Za(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Lf(e){return function(t){e.call(this,t,this.__data__)}}function Rf(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 kf(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 Df(e,t,o){return function(){var n=this.__on,r,i=Lf(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 Ja(e,t,o){var n=Rf(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?Df:kf,r=0;r<i;++r)this.each(a(n[r],t,o));return this}function Qa(e,t,o){var n=er(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 Of(e,t){return function(){return Qa(this,e,t)}}function Vf(e,t){return function(){return Qa(this,e,t.apply(this,arguments))}}function ja(e,t){return this.each((typeof t=="function"?Vf:Of)(e,t))}function*el(){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 Hf=[null];function Ae(e,t){this._groups=e,this._parents=t}function tl(){return new Ae([[document.documentElement]],Hf)}function Gf(){return this}Ae.prototype=tl.prototype={constructor:Ae,select:ga,selectAll:ha,selectChild:ya,selectChildren:xa,filter:Ea,data:Ta,enter:ba,exit:Na,join:va,merge:wa,selection:Gf,order:Ia,sort:Aa,call:Ca,nodes:Sa,node:Ma,size:Pa,empty:La,each:Ra,attr:ka,style:Da,property:Oa,classed:za,text:Ya,html:Wa,raise:Fa,lower:Xa,append:Ua,insert:$a,remove:Ka,clone:qa,datum:Za,on:Ja,dispatch:ja,[Symbol.iterator]:el};var wt=tl;function tr(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 ln(){}var sn=.7,rr=1/sn,Ao="\\s*([+-]?\\d+)\\s*",an="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",yt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Bf=/^#([0-9a-f]{3,8})$/,zf=new RegExp(`^rgb\\(${Ao},${Ao},${Ao}\\)$`),Yf=new RegExp(`^rgb\\(${yt},${yt},${yt}\\)$`),Wf=new RegExp(`^rgba\\(${Ao},${Ao},${Ao},${an}\\)$`),Ff=new RegExp(`^rgba\\(${yt},${yt},${yt},${an}\\)$`),Xf=new RegExp(`^hsl\\(${an},${yt},${yt}\\)$`),Uf=new RegExp(`^hsla\\(${an},${yt},${yt},${an}\\)$`),ol={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};tr(ln,Ht,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:nl,formatHex:nl,formatHex8:$f,formatHsl:Kf,formatRgb:rl,toString:rl});function nl(){return this.rgb().formatHex()}function $f(){return this.rgb().formatHex8()}function Kf(){return dl(this).formatHsl()}function rl(){return this.rgb().formatRgb()}function Ht(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=Bf.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?il(t):o===3?new ze(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?or(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?or(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=zf.exec(e))?new ze(t[1],t[2],t[3],1):(t=Yf.exec(e))?new ze(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Wf.exec(e))?or(t[1],t[2],t[3],t[4]):(t=Ff.exec(e))?or(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Xf.exec(e))?ll(t[1],t[2]/100,t[3]/100,1):(t=Uf.exec(e))?ll(t[1],t[2]/100,t[3]/100,t[4]):ol.hasOwnProperty(e)?il(ol[e]):e==="transparent"?new ze(NaN,NaN,NaN,0):null}function il(e){return new ze(e>>16&255,e>>8&255,e&255,1)}function or(e,t,o,n){return n<=0&&(e=t=o=NaN),new ze(e,t,o,n)}function qf(e){return e instanceof ln||(e=Ht(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?qf(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}tr(ze,Co,Fi(ln,{brighter(e){return e=e==null?rr:Math.pow(rr,e),new ze(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?sn:Math.pow(sn,e),new ze(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ze(ao(this.r),ao(this.g),ao(this.b),ir(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:sl,formatHex:sl,formatHex8:Zf,formatRgb:al,toString:al}));function sl(){return`#${so(this.r)}${so(this.g)}${so(this.b)}`}function Zf(){return`#${so(this.r)}${so(this.g)}${so(this.b)}${so((isNaN(this.opacity)?1:this.opacity)*255)}`}function al(){let e=ir(this.opacity);return`${e===1?"rgb(":"rgba("}${ao(this.r)}, ${ao(this.g)}, ${ao(this.b)}${e===1?")":`, ${e})`}`}function ir(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ao(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function so(e){return e=ao(e),(e<16?"0":"")+e.toString(16)}function ll(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new lt(e,t,o,n)}function dl(e){if(e instanceof lt)return new lt(e.h,e.s,e.l,e.opacity);if(e instanceof ln||(e=Ht(e)),!e)return new lt;if(e instanceof lt)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 lt(s,a,l,e.opacity)}function ul(e,t,o,n){return arguments.length===1?dl(e):new lt(e,t,o,n==null?1:n)}function lt(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}tr(lt,ul,Fi(ln,{brighter(e){return e=e==null?rr:Math.pow(rr,e),new lt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?sn:Math.pow(sn,e),new lt(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 lt(cl(this.h),nr(this.s),nr(this.l),ir(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=ir(this.opacity);return`${e===1?"hsl(":"hsla("}${cl(this.h)}, ${nr(this.s)*100}%, ${nr(this.l)*100}%${e===1?")":`, ${e})`}`}}));function cl(e){return e=(e||0)%360,e<0?e+360:e}function nr(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 pl(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 fl(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 Jf(e,t){return function(o){return e+o*t}}function Qf(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 ml(e){return(e=+e)==1?sr:function(t,o){return o-t?Qf(t,o,e):$i(isNaN(t)?o:t)}}function sr(e,t){var o=t-e;return o?Jf(e,o):$i(isNaN(e)?t:e)}var ar=function e(t){var o=ml(t);function n(r,i){var s=o((r=Co(r)).r,(i=Co(i)).r),a=o(r.g,i.g),l=o(r.b,i.b),c=sr(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 gl(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=Co(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 jf=gl(pl),em=gl(fl);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 tm(e){return function(){return e}}function om(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]?om(l[0].x):tm(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 hl=180/Math.PI,lr={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)*hl,skewX:Math.atan(l)*hl,scaleX:s,scaleY:a}}var cr;function yl(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?lr:Ji(t.a,t.b,t.c,t.d,t.e,t.f)}function xl(e){return e==null?lr:(cr||(cr=document.createElementNS("http://www.w3.org/2000/svg","g")),cr.setAttribute("transform",e),(e=cr.transform.baseVal.consolidate())?(e=e.matrix,Ji(e.a,e.b,e.c,e.d,e.e,e.f)):lr)}function El(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,m,p,g){if(c!==u||d!==m){var x=p.push("translate(",null,t,null,o);g.push({i:x-4,x:nt(c,u)},{i:x-2,x:nt(d,m)})}else(u||m)&&p.push("translate("+u+t+m+o)}function s(c,d,u,m){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),m.push({i:u.push(r(u)+"rotate(",null,n)-2,x:nt(c,d)})):d&&u.push(r(u)+"rotate("+d+n)}function a(c,d,u,m){c!==d?m.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,m,p,g){if(c!==u||d!==m){var x=p.push(r(p)+"scale(",null,",",null,")");g.push({i:x-4,x:nt(c,u)},{i:x-2,x:nt(d,m)})}else(u!==1||m!==1)&&p.push(r(p)+"scale("+u+","+m+")")}return function(c,d){var u=[],m=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,u,m),s(c.rotate,d.rotate,u,m),a(c.skewX,d.skewX,u,m),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,m),c=d=null,function(p){for(var g=-1,x=m.length,f;++g<x;)u[(f=m[g]).i]=f.x(p);return u.join("")}}}var Qi=El(yl,"px, ","px)","deg)"),ji=El(xl,", ",")",")");var So=0,dn=0,cn=0,_l=1e3,dr,un,ur=0,lo=0,pr=0,pn=typeof performance=="object"&&performance.now?performance:Date,Tl=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function mn(){return lo||(Tl(nm),lo=pn.now()+pr)}function nm(){lo=0}function fn(){this._call=this._time=this._next=null}fn.prototype=fr.prototype={constructor:fn,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?mn():+o)+(t==null?0:+t),!this._next&&un!==this&&(un?un._next=this:dr=this,un=this),this._call=e,this._time=o,es()},stop:function(){this._call&&(this._call=null,this._time=1/0,es())}};function fr(e,t,o){var n=new fn;return n.restart(e,t,o),n}function Nl(){mn(),++So;for(var e=dr,t;e;)(t=lo-e._time)>=0&&e._call.call(void 0,t),e=e._next;--So}function bl(){lo=(ur=pn.now())+pr,So=dn=0;try{Nl()}finally{So=0,im(),lo=0}}function rm(){var e=pn.now(),t=e-ur;t>_l&&(pr-=t,ur=e)}function im(){for(var e,t=dr,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:dr=o);un=e,es(n)}function es(e){if(!So){dn&&(dn=clearTimeout(dn));var t=e-lo;t>24?(e<1/0&&(dn=setTimeout(bl,e-pn.now()-pr)),cn&&(cn=clearInterval(cn))):(cn||(ur=pn.now(),cn=setInterval(rm,_l)),So=1,Tl(bl))}}function mr(e,t,o){var n=new fn;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var sm=Bi("start","end","cancel","interrupt"),am=[],Il=0,vl=1,hr=2,gr=3,wl=4,yr=5,gn=6;function Gt(e,t,o,n,r,i){var s=e.__transition;if(!s)e.__transition={};else if(o in s)return;lm(e,o,{name:t,index:n,group:r,on:sm,tween:am,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Il})}function hn(e,t){var o=Ce(e,t);if(o.state>Il)throw new Error("too late; already scheduled");return o}function ke(e,t){var o=Ce(e,t);if(o.state>gr)throw new Error("too late; already running");return o}function Ce(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function lm(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=fr(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,m,p;if(o.state!==vl)return l();for(d in n)if(p=n[d],p.name===o.name){if(p.state===gr)return mr(s);p.state===wl?(p.state=gn,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete n[d]):+d<t&&(p.state=gn,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete n[d])}if(mr(function(){o.state===gr&&(o.state=wl,o.timer.restart(a,o.delay,o.time),a(c))}),o.state=hr,o.on.call("start",e,e.__data__,o.index,o.group),o.state===hr){for(o.state=gr,r=new Array(m=o.tween.length),d=0,u=-1;d<m;++d)(p=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++u]=p);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=yr,1),u=-1,m=r.length;++u<m;)r[u].call(e,d);o.state===yr&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=gn,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function 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>hr&&n.state<yr,n.state=gn,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[s]}i&&delete e.__transition}}function Al(e){return this.each(function(){ts(this,e)})}function cm(e,t){var o,n;return function(){var r=ke(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 dm(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=ke(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 Cl(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=Ce(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?cm:dm)(o,e,t))}function Mo(e,t,o){var n=e._id;return e.each(function(){var r=ke(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return Ce(r,n).value[t]}}function xr(e,t){var o;return(typeof t=="number"?nt:t instanceof Ht?ar:(o=Ht(t))?(t=o,ar):Zi)(e,t)}function um(e){return function(){this.removeAttribute(e)}}function pm(e){return function(){this.removeAttributeNS(e.space,e.local)}}function fm(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 mm(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 gm(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 hm(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=vt(e),n=o==="transform"?ji:xr;return this.attrTween(e,typeof t=="function"?(o.local?hm:gm)(o,n,Mo(this,"attr."+e,t)):t==null?(o.local?pm:um)(o):(o.local?mm:fm)(o,n,t))}function ym(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function xm(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function Em(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&xm(e,i)),o}return r._value=t,r}function bm(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&ym(e,i)),o}return r._value=t,r}function Ml(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=vt(e);return this.tween(o,(n.local?Em:bm)(n,t))}function _m(e,t){return function(){hn(this,e).delay=+t.apply(this,arguments)}}function Tm(e,t){return t=+t,function(){hn(this,e).delay=t}}function Pl(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?_m:Tm)(t,e)):Ce(this.node(),t).delay}function Nm(e,t){return function(){ke(this,e).duration=+t.apply(this,arguments)}}function vm(e,t){return t=+t,function(){ke(this,e).duration=t}}function Ll(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Nm:vm)(t,e)):Ce(this.node(),t).duration}function wm(e,t){if(typeof t!="function")throw new Error;return function(){ke(this,e).ease=t}}function Rl(e){var t=this._id;return arguments.length?this.each(wm(t,e)):Ce(this.node(),t).ease}function Im(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;ke(this,e).ease=o}}function kl(e){if(typeof e!="function")throw new Error;return this.each(Im(this._id,e))}function Dl(e){typeof e!="function"&&(e=nn(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],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 Ol(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),m,p=0;p<d;++p)(m=l[p]||c[p])&&(u[p]=m);for(;a<n;++a)s[a]=t[a];return new He(s,this._parents,this._name,this._id)}function Am(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 Cm(e,t,o){var n,r,i=Am(t)?hn:ke;return function(){var s=i(this,e),a=s.on;a!==n&&(r=(n=a).copy()).on(t,o),s.on=r}}function Vl(e,t){var o=this._id;return arguments.length<2?Ce(this.node(),o).on.on(e):this.each(Cm(o,e,t))}function Sm(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function Hl(){return this.on("end.remove",Sm(this._id))}function Gl(e){var t=this._name,o=this._id;typeof e!="function"&&(e=io(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,m=0;m<l;++m)(d=a[m])&&(u=e.call(d,d.__data__,m,a))&&("__data__"in d&&(u.__data__=d.__data__),c[m]=u,Gt(c[m],t,o,m,c,Ce(d,o)));return new He(i,this._parents,t,o)}function Bl(e){var t=this._name,o=this._id;typeof e!="function"&&(e=on(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 m=e.call(d,d.__data__,u,l),p,g=Ce(d,o),x=0,f=m.length;x<f;++x)(p=m[x])&&Gt(p,t,o,x,m,g);i.push(m),s.push(d)}return new He(i,s,t,o)}var Mm=wt.prototype.constructor;function zl(){return new Mm(this._groups,this._parents)}function Pm(e,t){var o,n,r;return function(){var i=Vt(this,e),s=(this.style.removeProperty(e),Vt(this,e));return i===s?null:i===o&&s===n?r:r=t(o=i,n=s)}}function Yl(e){return function(){this.style.removeProperty(e)}}function Lm(e,t,o){var n,r=o+"",i;return function(){var s=Vt(this,e);return s===r?null:s===n?i:i=t(n=s,o)}}function Rm(e,t,o){var n,r,i;return function(){var s=Vt(this,e),a=o(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),Vt(this,e))),s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a))}}function km(e,t){var o,n,r,i="style."+t,s="end."+i,a;return function(){var l=ke(this,e),c=l.on,d=l.value[i]==null?a||(a=Yl(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(s,r=d),l.on=n}}function Wl(e,t,o){var n=(e+="")=="transform"?Qi:xr;return t==null?this.styleTween(e,Pm(e,n)).on("end.style."+e,Yl(e)):typeof t=="function"?this.styleTween(e,Rm(e,n,Mo(this,"style."+e,t))).each(km(this._id,e)):this.styleTween(e,Lm(e,n,t),o).on("end.style."+e,null)}function Dm(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function Om(e,t,o){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&Dm(e,s,o)),n}return i._value=t,i}function Fl(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,Om(e,t,o==null?"":o))}function Vm(e){return function(){this.textContent=e}}function Hm(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function Xl(e){return this.tween("text",typeof e=="function"?Hm(Mo(this,"text",e)):Vm(e==null?"":e+""))}function Gm(e){return function(t){this.textContent=e.call(this,t)}}function Bm(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&Gm(r)),t}return n._value=e,n}function Ul(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,Bm(e))}function $l(){for(var e=this._name,t=this._id,o=Er(),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=Ce(l,t);Gt(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 Kl(){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=ke(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 zm=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 Er(){return++zm}var It=wt.prototype;He.prototype=ql.prototype={constructor:He,select:Gl,selectAll:Bl,selectChild:It.selectChild,selectChildren:It.selectChildren,filter:Dl,merge:Ol,selection:zl,transition:$l,call:It.call,nodes:It.nodes,node:It.node,size:It.size,empty:It.empty,each:It.each,on:Vl,attr:Sl,attrTween:Ml,style:Wl,styleTween:Fl,text:Xl,textTween:Ul,remove:Hl,tween:Cl,delay:Pl,duration:Ll,ease:Rl,easeVarying:kl,end:Kl,[Symbol.iterator]:It[Symbol.iterator]};function br(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Ym={time:null,delay:0,duration:250,ease:br};function Wm(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 Zl(e){var t,o;e instanceof He?(t=e._id,e=e._name):(t=Er(),(o=Ym).time=mn(),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])&&Gt(l,e,t,c,s,o||Wm(l,t));return new He(n,this._parents,e,t)}wt.prototype.interrupt=Al;wt.prototype.transition=Zl;function Bt(e,t,o){this.k=e,this.x=t,this.y=o}Bt.prototype={constructor:Bt,scale:function(e){return e===1?this:new Bt(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Bt(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 Bt(1,0,0);Tr.prototype=Bt.prototype;function Tr(e){for(;!e.__zoom;)if(!(e=e.parentNode))return _r;return e.__zoom}var Xm=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var Jl;(function(e){e.Strict="strict",e.Loose="loose"})(Jl||(Jl={}));var Ql;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ql||(Ql={}));var jl;(function(e){e.Partial="partial",e.Full="full"})(jl||(jl={}));var ec;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ec||(ec={}));var tc;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(tc||(tc={}));var Ye;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ye||(Ye={}));var Uw={[Ye.Left]:Ye.Right,[Ye.Right]:Ye.Left,[Ye.Top]:Ye.Bottom,[Ye.Bottom]:Ye.Top};var Um=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var $m=(e,t=[0,0])=>{var a;let{width:o,height:n}=Km(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 Nr=(e,t=[0,0])=>{var r,i,s,a,l,c,d,u;let{x:o,y:n}=Um(e)?e.internals.positionAbsolute:$m(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 Km(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 $w={[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 qm={nodeOrigin:[0,0],nodeExtent:Xm,elevateNodesOnSelect:!0,defaults:{}},Kw=w(b({},qm),{checkEquality:!0});var oc;(function(e){e.Line="line",e.Handle="handle"})(oc||(oc={}));var Zm={width:0,height:0,x:0,y:0},qw=w(b({},Zm),{pointerX:0,pointerY:0,aspectRatio:1});var Jm=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function Qm(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 jm(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 p of s){if(p.position<a)continue;if(p.position>l)break;if(i.has(p.node.id)||p.node.parentId&&i.has(p.node.parentId)||!Jm(p.nodeBox,r))continue;let g=Math.abs(p.position-o);if(g>wr)continue;let f=Qm(p.nodeBox,n)>0?0:jm(p.nodeBox,n);c.push({line:p,lineDist:g,nodeDist:f})}let d=.5,u=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;c.sort((p,g)=>{if(u){if(p.line===u&&g.line!==u)return-1;if(g.line===u&&p.line!==u)return 1}return Math.abs(p.lineDist-g.lineDist)<=d?p.nodeDist-g.nodeDist:p.lineDist-g.lineDist});let m=c.length>0?c[0].line:void 0;return m&&(t==="horizontal"?this.lastHorizontalLine=m:this.lastVerticalLine=m),m}};function nc(e,t=co,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=Nr(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 rc(e,t,o,n,r=Object.keys(co)){let i=[];for(let a of r){let l=co[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 ic(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)<=wr&&(r=l,s=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=wr&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:s}}var wr=10,co={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 ag}from"react/jsx-runtime";var sg=new vr;function Ir(){let[e,t]=sc(void 0),[o,n]=sc(void 0),{width:r,height:i}=og(f=>({width:f.width,height:f.height}),ig),s=eg(),a=rg(sg),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=tg(),u=yn(()=>{t(void 0),n(void 0)},[]),m=yn(f=>{let h=f!=null?f:d();u();let y=nc(h,co,c);a.current.initialize(y)},[c,u,d]),p=yn(()=>{setTimeout(()=>{m()},100)},[m]);ng(()=>{s&&m(d())},[s,m,d]);let g=yn((f,h)=>{var B,L,k,D,F,Z,X,J,ee,ie;if(!a.current||f.length===0||f.filter(W=>W.type==="dimensions").length>1)return f;u();let E=f.filter(W=>W.type==="position"&&!!W.position),v=f.find(W=>W.type==="dimensions");if(E.length===0&&!v)return f;let N=Object.keys(co),T=new Set,_=1/0,A=1/0,M=-1/0,C=-1/0;if(E.length>0)E.forEach(W=>{var de,re,j,ge,_e,Te;let oe=h.find(Re=>Re.id===W.id);if(!oe)return;T.add(oe.id);let le=c(oe.id);if(!le)return;let $=le.parentId?c(le.parentId):void 0,xe=W.position.x+((de=$==null?void 0:$.internals.positionAbsolute.x)!=null?de:0),me=W.position.y+((re=$==null?void 0:$.internals.positionAbsolute.y)!=null?re:0),be=(ge=(j=oe.measured)==null?void 0:j.width)!=null?ge:0,K=(Te=(_e=oe.measured)==null?void 0:_e.height)!=null?Te:0;_=Math.min(_,xe),A=Math.min(A,me),M=Math.max(M,xe+be),C=Math.max(C,me+K)}),v&&(N=["top","left"]);else if(v){let W=h.find(be=>be.id===v.id);if(!W)return f;T.add(W.id);let oe=c(W.id);if(!oe)return f;let le=oe.internals.positionAbsolute.x,$=oe.internals.positionAbsolute.y,xe=(D=(k=(B=v.dimensions)==null?void 0:B.width)!=null?k:(L=W.measured)==null?void 0:L.width)!=null?D:0,me=(J=(X=(F=v.dimensions)==null?void 0:F.height)!=null?X:(Z=W.measured)==null?void 0:Z.height)!=null?J:0;_=le,A=$,M=le+xe,C=$+me,N=["right","bottom"]}if(_===1/0)return f;let O={x:_,y:A,x2:M,y2:C},{x:P,y:H}=l({x:0,y:0}),{x:q,y:Q}=l({x:r,y:i}),te={x:P,y:H,x2:q,y2:Q},{horizontal:z,vertical:S}=rc(a.current,te,O,T,N),{deltaX:V,deltaY:R,snappedX:I,snappedY:Y}=ic(O,z,S);if(I||Y){let W=E.some(le=>le.dragging),oe=!!(v!=null&&v.resizing);(W||oe)&&(I&&n(S==null?void 0:S.line),Y&&t(z==null?void 0:z.line)),I&&(E.forEach(le=>{le.position&&(le.position.x-=V)}),(v==null?void 0:v.id)===((ee=E[0])==null?void 0:ee.id)?v.dimensions&&(v.dimensions.width+=V):v&&!E.length&&v.dimensions&&(v.dimensions.width-=V)),Y&&(E.forEach(le=>{le.position&&(le.position.y-=R)}),(v==null?void 0:v.id)===((ie=E[0])==null?void 0:ie.id)?v.dimensions&&(v.dimensions.height+=R):v&&!E.length&&v.dimensions&&(v.dimensions.height-=R))}return f},[l,c,r,i,t,n,u]),x=yn(()=>ag(ac,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:m,forceRebuildIndex:p,updateHelperLines:g,helperLineHorizontal:e,helperLineVertical:o,HelperLines:x}}import{reconnectEdge as p0,useReactFlow as f0}from"@xyflow/react";import{useCallback as ho,useRef as m0}from"react";var At=e=>new Map(e.map(t=>[t.id,t])),xn=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),lc=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),os=e=>e.some(t=>t.type==="START_EVENT"),zt=(e,t)=>e==="START_EVENT"?!os(t):!0,cc=(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:xn(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},dc=(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:lc(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Ar=(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:xn(e,n,r).filter(d=>{let u=i.get(d.target);return(u==null?void 0:u.type)!=="ANNOTATION"}).length>=2},uc=(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"},Cr=(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"},pc=(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"},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"},uo=(e,t,o,n)=>{let r=At(t),i=r.get(e);return!i||i.type!=="TASK"?!1:lc(e,o,n).some(a=>{let l=r.get(a.source);return(l==null?void 0:l.type)==="START_EVENT"})},En=(e,t,o,n)=>{let r=At(t),i=r.get(e);return!i||i.type!=="TASK"?!1:xn(e,o,n).some(a=>{let l=r.get(a.target);return(l==null?void 0:l.type)==="END_EVENT"})},fc=(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"?En(t,o,n,r):(a==null?void 0:a.type)==="END_EVENT"&&(s==null?void 0:s.type)==="TASK"?uo(e,o,n,r):!1},Mr=(e,t,o)=>xn(e,t,o).length>0,Pr=(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:xn(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var mc=(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 lg=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!mc(e.sourceNodeId,e.targetNodeId,e.edges,e.nodes,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!cc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!dc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!Ar(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!Pr(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:uc(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"&&pc(e.targetNodeId,e.nodes)),reason:"start_event_to_subprocess_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:!(Cr(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:!(uo(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!fc(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:!(Mr(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 lg){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var cg=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:Ar(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:Cr(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:uo(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:Mr(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Pr(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],gc=e=>{let t=cg.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 Gg,EdgeLabelRenderer as Bg,getStraightPath as zg,useInternalNode as yc,useViewport as Yg}from"@xyflow/react";import{Button as pg,Tooltip as fg,TooltipContent as mg,TooltipTrigger as gg,useTranslation as hg}from"@produto-lecom/lecom-ui";import{Settings as yg}from"lucide-react";import{getIncomers as Lr,getOutgoers as Rr,useReactFlow as ug}from"@xyflow/react";import{useStoreApi as dg}from"@xyflow/react";var Yt=()=>{let e=dg();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 Bn(),!0}}};var kr=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=ug(),{selectElements:r}=Yt(),i=f=>{let h=o(),y=n(),E=Lr(f,h,y),v=Rr(f,h,y),N=E.some(_=>_.type==="START_EVENT"),T=v.some(_=>_.type==="END_EVENT");return N?"start":T?"end":"between"},s=(f,h,y)=>{var N,T,_,A;if(!f)return;let E={type:f.type,variant:(N=f.data)==null?void 0:N.variant,attribute:(T=f.data)==null?void 0:T.attribute},v={id:f.id,position:i(f),label:(_=f.data)==null?void 0:_.label,node:E};return f.type==="TASK"&&((A=f.data)==null?void 0:A.variant)==="SUBPROCESS"?w(b({},v),{type:"sub_process"}):f.type==="GATEWAY"?w(b({},v),{type:"gateway",variant:a(f,h,y)}):w(b({},v),{type:"activity"})},a=(f,h,y)=>{if(f.type!=="GATEWAY")return;let E=Lr(f,h,y),v=!1,N=!1;if(E.forEach(T=>{var _,A;T.type==="TASK"&&(((_=T.data)==null?void 0:_.variant)==="SCRIPT"&&(v=!0),((A=T.data)==null?void 0:A.attribute)==="LOOP"&&(N=!0))}),v&&N)return"script_loop";if(v)return"script";if(N)return"loop"},l=(f,h,y)=>{var _,A,M,C;let E=e(f.source),v=e(f.target);if(!E||!v)return"simple";if(Rr(E,h,y).some(O=>O.type==="END_EVENT"))return"final";if(E.type==="GATEWAY")switch((_=E.data)==null?void 0:_.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(E.type==="TASK"){let O=(A=E.data)==null?void 0:A.variant,P=(M=E.data)==null?void 0:M.attribute;if(O==="SUBPROCESS")return"from_sub_process";if(v.type==="TASK"&&((C=v.data)==null?void 0:C.variant)==="SUBPROCESS")return"to_sub_process";let H=O==="SCRIPT",q=P==="LOOP";return H&&q?"script_loop":H?"script":q?"loop":"simple"}return"simple"},c=(f,h,y)=>{let E=[];function v(T,_,A=0){let M=s(T,h,y);if(M.depth=A,_.push(M),T.type==="TASK"){E.push([..._]),_.pop();return}let C=Lr(T,h,y);if(C.length)for(let O of C)v(O,_,A+1);_.pop()}let N=Lr(f,h,y);for(let T of N)v(T,[]);return E},d=(f,h,y)=>{let E=[];function v(T,_,A=0){let M=s(T,h,y);if(M.depth=A,_.push(M),T.type==="TASK"){E.push([..._]),_.pop();return}let C=Rr(T,h,y);if(C.length)for(let O of C)v(O,_,A+1);_.pop()}let N=Rr(f,h,y);for(let T of N)v(T,[]);return E},u=(f,h,y)=>(y=y.filter(v=>v.source===f.id),y.map(v=>{var _;let N=e(v.target),T;return N&&(T=s(N,h,y)),{id:v.id,type:"routing",variant:l(v,h,y),label:(_=v.data)==null?void 0:_.label,target:T}})),m=f=>{let h=e(f);if(!h)return;let y=o(),E=n(),v=s(h,y,E);return v.sources=c(h,y,E),v.targets=d(h,y,E),v.edgeTargets=u(h,y,E),h.type==="GATEWAY"&&(v.variant=a(h,y,E)),v},p=f=>{let h=t(f);if(!h)return;let y=o(),E=n(),v=l(h,y,E),T={id:h.id,type:"routing",variant:v,gatewayVariant:void 0},_=e(h.source);if(_){let M=s(_,y,E);T.source=M;let C=a(_,y,E);if(T.gatewayVariant=C,_.type==="TASK")T.sources=[[M]];else{let O=c(_,y,E);T.sources=O.length?O:[[M]]}}let A=e(h.target);if(A){let M=s(A,y,E);if(T.target=M,A.type==="TASK")T.targets=[[M]];else{let C=d(A,y,E);T.targets=C.length?C:[[M]]}}return T},g=f=>{let h=e(f);if(h)return m(h.id);let y=t(f);if(y)return p(y.id)};return{configureElement:f=>{let h=g(f);if(h)return r([f]),h},getConfigureElement:g,getNodeConfigure:m,getEdgeConfigure:p}};import{jsx as Dr,jsxs as Eg}from"react/jsx-runtime";var xg={node:"editor.toolbar.configure_node",edge:"editor.toolbar.configure_edge",gateway:"editor.toolbar.configure_gateway"},Wt=({elementId:e,elementType:t="node"})=>{let{t:o}=hg(),{onConfigureElement:n}=U(),{getConfigureElement:r}=kr();return Eg(fg,{children:[Dr(gg,{asChild:!0,children:Dr(pg,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let s=r(e);s&&(n==null||n(s))},children:Dr(yg,{size:16})})}),Dr(mg,{color:"black",children:o(xg[t])})]})};import{Button as _g,Tooltip as Tg,TooltipContent as Ng,TooltipTrigger as vg,useTranslation as wg}from"@produto-lecom/lecom-ui";import{useReactFlow as Ig}from"@xyflow/react";import{TrashIcon as Ag}from"lucide-react";import{useNotificationToast as bg}from"@produto-lecom/lecom-ui";function We(){let{toast:e}=bn(),{toast:t}=bg();return{toast:e||t}}import{jsx as Or,jsxs as Cg}from"react/jsx-runtime";var Vr=({elementId:e,elementType:t="node"})=>{let{t:o}=wg(),{toast:n}=We(),{deleteElements:r,getNodes:i}=Ig();return Cg(Tg,{children:[Or(vg,{asChild:!0,children:Or(_g,{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:Or(Ag,{size:16})})}),Or(Ng,{color:"black",children:o("editor.toolbar.delete")})]})};import{Button as Sg,Tooltip as Mg,TooltipContent as Pg,TooltipTrigger as Lg,useTranslation as Rg}from"@produto-lecom/lecom-ui";import{MoveUpRightIcon as kg}from"lucide-react";import{useCallback as Dg}from"react";import{jsx as Hr,jsxs as Og}from"react/jsx-runtime";var Po=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=Rg(),r=Dg(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((m,p)=>{let g=m.getBoundingClientRect(),x=p.getBoundingClientRect(),f=Math.hypot(i.clientX-(g.left+g.width/2),i.clientY-(g.top+g.height/2));return Math.hypot(i.clientX-(x.left+x.width/2),i.clientY-(x.top+x.height/2))<f?p:m}),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 Og(Mg,{children:[Hr(Lg,{asChild:!0,children:Hr(Sg,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:Hr(kg,{size:16})})}),Hr(Pg,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};import{jsx as _n}from"react/jsx-runtime";var Lo=i=>{var s=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=s,r=gt(s,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:a}=U(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d,isToEndEvent:u}=$n(o,n),m=!l&&!c&&!d&&!u,p=[{component:_n(Vr,{elementId:e,elementType:"edge"})}],g=()=>a==="view"?m?[{component:_n(Wt,{elementId:e,elementType:"edge"})}]:[]:m?[{component:_n(Wt,{elementId:e,elementType:"edge"})},...p]:p,f=(h=>{switch(h){case"SEQUENCE_EDGE":return g();case"MESSAGE_EDGE":return a==="view"?[]:[...p];case"ANNOTATION_EDGE":return a==="view"?[]:[...p];default:return[]}})(t);if(!(f.length===0||a==="readonly"))return _n("div",w(b({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:f.map((h,y)=>_n("div",{children:h.component},y))}))};import{useViewport as Vg}from"@xyflow/react";import{useMemo as Hg}from"react";import{jsx as hc}from"react/jsx-runtime";var xt=12,Ro=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:s}=Vg(),a=1/s,l=Hg(()=>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 hc("div",{style:{transform:`scale(${a})`},children:hc("div",{className:"absolute pointer-events-auto",style:b({},l),children:i})})};import{Fragment as Wg,jsx as fo,jsxs as xc}from"react/jsx-runtime";var ko={type:"ANNOTATION_EDGE",reconnectable:!0},Ec=({id:e,source:t,target:o,selected:n,data:r})=>{let{isMultipleSelection:i,isReadOnly:s,edgeHighlight:a}=U(),{zoom:l}=Yg(),c=yc(t),d=yc(o);if(!c||!d)return null;let{sx:u,sy:m,tx:p,ty:g}=Io(c,d),[x,f,h]=zg({sourceX:u,sourceY:m,targetX:p,targetY:g}),y=a&&(n||(c==null?void 0:c.selected)||(d==null?void 0:d.selected));return fo(Wg,{children:xc("g",{className:G("group bpmn-edge",{"is-highlighted":y}),children:[fo("path",{d:x,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/l),style:{pointerEvents:"stroke",cursor:"pointer"}}),xc("g",{className:G("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!s,"text-blue-500 group-hover:text-blue-600":y}),children:[fo(Gg,{id:e,path:x,interactionWidth:0,strokeDasharray:4,className:G("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)})}),fo(Bg,{children:fo("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${f}px, ${h}px)`},children:n&&!i&&fo(Ro,{sx:u,sy:m,tx:p,ty:g,children:fo(Lo,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})})})]})]})})};import{useState as Sc,useCallback as Mc,useMemo as ss,useEffect as sh,useRef as as}from"react";import{BaseEdge as ah,EdgeLabelRenderer as lh,MarkerType as Pc,useInternalNode as Lc,useReactFlow as ch,useViewport as dh,useEdges as uh,useNodes as ph,Position as Ho}from"@xyflow/react";import{useCallback as Fg,useEffect as rs,useRef as bc,useState as Xg}from"react";import{jsx as Tc}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=bc(null),m=bc(null),[p,g]=Xg(!1);rs(()=>()=>{m.current&&clearTimeout(m.current)},[]),rs(()=>{g(i!=null?i:!1)},[i]),rs(()=>{if(p&&u.current){u.current.focus();let N=document.createRange();N.selectNodeContents(u.current);let T=window.getSelection();T&&(T.removeAllRanges(),T.addRange(N))}},[p]);let x=Fg(()=>{m.current||(c==null||c(),m.current=setTimeout(()=>{m.current=null},500))},[c]),f=N=>{N.stopPropagation(),p||g(!0)},h=N=>{let T=N.currentTarget.innerText.replace(/\n$/,""),_=t&&T.length>=t,A=window.getSelection(),M=(A==null?void 0:A.toString())||"",C=M.length>0,O=(N.ctrlKey||N.metaKey)&&!N.altKey,P=O&&N.key==="a",H=O&&N.key==="c",q=O&&N.key==="x",Q=O&&N.key==="v",te=T.length===0||C&&M.length===T.length;if(!d&&te&&!is.test(N.key)&&!_c.includes(N.key)&&!O){N.preventDefault(),x();return}_&&!C&&(_c.includes(N.key)||P||H||q||Q||N.preventDefault())},y=N=>{N.preventDefault();let T=N.clipboardData.getData("text/plain").replace(/\r\n/g,`
|
|
1
|
+
var dp=Object.defineProperty,up=Object.defineProperties;var pp=Object.getOwnPropertyDescriptors;var On=Object.getOwnPropertySymbols;var Vs=Object.prototype.hasOwnProperty,Hs=Object.prototype.propertyIsEnumerable;var Os=(e,t,o)=>t in e?dp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,b=(e,t)=>{for(var o in t||(t={}))Vs.call(t,o)&&Os(e,o,t[o]);if(On)for(var o of On(t))Hs.call(t,o)&&Os(e,o,t[o]);return e},v=(e,t)=>up(e,pp(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&&On)for(var n of On(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 fp,Translations as mp}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",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:"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"}},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"},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",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:"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"}},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"},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",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:"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"}},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"},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,gp=(Fs=(Ws=Ai("LecomUserLanguage"))!=null?Ws:Ai("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?Fs:mp.PT_BR;fp({lng:gp,resources:Ys});var Ie=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(Ie||{});var Vn=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(Vn||{}),Ci=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Ci||{}),Si=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Si||{}),Mi=(d=>(d.SIMPLE="simple",d.LOOP="loop",d.SCRIPT="script",d.SCRIPT_LOOP="script_loop",d.COMPLEX="complex",d.EXCLUSIVE="exclusive",d.PARALLEL="parallel",d.FINAL="final",d.TO_SUB_PROCESS="to_sub_process",d.FROM_SUB_PROCESS="from_sub_process",d))(Mi||{});import{RotateCcw as Ap,ScrollText as Cp,SquarePlus as Sp}from"lucide-react";import{jsx as Hn,jsxs as hp}from"react/jsx-runtime";var Gn=({size:e=24,className:t})=>hp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:[Hn("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),Hn("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),Hn("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),Hn("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 bo=({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 Zo,jsxs as yp}from"react/jsx-runtime";var _o=({size:e=24,className:t})=>yp("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:[Zo("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"}),Zo("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Zo("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),Zo("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Zo("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Pi,jsxs as xp}from"react/jsx-runtime";var To=({size:e=24,className:t})=>xp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[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 Ep}from"react/jsx-runtime";var No=({size:e=24,className:t})=>Ep("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 Ri,jsxs as bp}from"react/jsx-runtime";var Us=({size:e=24,className:t})=>Ri("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:bp("g",{children:[Ri("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"}),Ri("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as _p}from"clsx";import{twMerge as Tp}from"tailwind-merge";function G(...e){return Tp(_p(e))}var Dt=(e=0,t=0)=>e<t?t:e,Bn=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as $s,jsxs as Np}from"react/jsx-runtime";var Ks=({size:e=24,className:t})=>Np("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:G("stroke-2",t),children:[$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 ki}from"react/jsx-runtime";var qs=({size:e=24,className:t})=>ki("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:ki("g",{children:ki("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 zn=({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 Jo=({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:G("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 vp}from"react/jsx-runtime";var Qs=({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:"#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 wp}from"react/jsx-runtime";var js=({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:"#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 Yn,jsxs as Ip}from"react/jsx-runtime";var jo=({size:e=24,className:t})=>Ip("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:[Yn("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"}),Yn("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),Yn("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Yn("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||{}),tt=(o=>(o.SCRIPT="SCRIPT",o.SUBPROCESS="SUBPROCESS",o))(tt||{}),Wn={SCRIPT:{icon:Cp},SUBPROCESS:{icon:Sp}},ht=(t=>(t.LOOP="LOOP",t))(ht||{}),Fn={LOOP:{icon:Ap}},at=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(at||{}),Oi={EXCLUSIVE:{icon:To},PARALLEL:{icon:No},COMPLEX:{icon:_o}};import{useTranslation as jE}from"@produto-lecom/lecom-ui";import{ReactFlowProvider as e1}from"@xyflow/react";import{createContext as t1,useContext as o1,useEffect as n1,useId as r1,useMemo as lp,useRef as i1,useState as ut}from"react";import{Background as CE,MiniMap as SE,ReactFlow as ME,SelectionMode as PE,useKeyPress as LE}from"@xyflow/react";import{forwardRef as RE,useImperativeHandle as kE,useRef as ip}from"react";import{useTranslation as Q0}from"@produto-lecom/lecom-ui";import{useEdgesState as j0,useNodesState as ex,useOnSelectionChange as tx,useReactFlow as ox,useStoreApi as nx}from"@xyflow/react";import{useCallback as bt,useEffect as rx}from"react";var Xn={MIN_WIDTH:36,MIN_HEIGHT:36},Un={MIN_WIDTH:36,MIN_HEIGHT:36},vo={MIN_WIDTH:56,MIN_HEIGHT:56},Ot={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},wo={MIN_WIDTH:176,MIN_HEIGHT:64},Mp={MIN_WIDTH:128,MIN_HEIGHT:64},ue={START_EVENT:Xn,END_EVENT:Un,GATEWAY:vo,TASK:Ot,LANE:se,ANNOTATION:wo,UNSUPPORTED:Mp};import{Position as en}from"@xyflow/react";function ta(e,t){var x,w,_,N;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+((w=(x=t==null?void 0:t.measured)==null?void 0:x.width)!=null?w:0)/2,u=i.y+((N=(_=t==null?void 0:t.measured)==null?void 0:_.height)!=null?N:0)/2,m=(d-l)/(2*s)-(u-c)/(2*a),p=(d-l)/(2*s)+(u-c)/(2*a),h=1/(Math.abs(m)+Math.abs(p)||1),E=h*m,f=h*p,g=s*(E+f)+l,y=a*(-E+f)+c;return{x:g,y}}function oa(e,t){var c,d,u,m;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(m=(u=e.measured)==null?void 0:u.height)!=null?m:0,i=Math.round(o.x),s=Math.round(o.y),a=Math.round(t.x),l=Math.round(t.y);return a<=i+1?en.Left:a>=i+n-1?en.Right:l<=s+1?en.Top:l>=s+r-1?en.Bottom:en.Top}function Io(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 $n(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 Pp}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}},eo=e=>Pp(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 to=({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)),Lp=(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)},Rp=(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},tn=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&Rp(e,r)){let i=Lp(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),aa=(e,t)=>{let o=e.filter(c=>!c.parentId);if(o.length===0)return{nodes:e,edges:t};let n=o.filter(c=>c.type==="LANE"),r=n.length>0?n:o,i=Math.min(...r.map(c=>c.position.x||0)),s=Math.min(...r.map(c=>c.position.y||0)),a=e.map(c=>c.parentId?c:v(b({},c),{position:{x:c.position.x-i,y:c.position.y-s}})),l=t.map(c=>{let d=c.data;return d!=null&&d.points?v(b({},c),{data:v(b({},d),{points:d.points.map(u=>({x:u.x-i,y:u.y-s}))})}):c});return{nodes:a,edges:l}},la=e=>{var l,c;let t=e.filter(d=>!d.parentId),o=t.filter(d=>d.type==="LANE"),n=o.length>0?o:t;if(n.length===0)return null;let r=1/0,i=1/0,s=-1/0,a=-1/0;for(let d of n){let u=d.position.x+((l=d.width)!=null?l:0),m=d.position.y+((c=d.height)!=null?c:0);d.position.x<r&&(r=d.position.x),d.position.y<i&&(i=d.position.y),u>s&&(s=u),m>a&&(a=m)}return{x:r,y:i,width:s-r,height:a-i}};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 kp=50,oo=(e,t)=>{var m,p,h,E,f,g,y,x,w,_,N,T,I,C,P,R;let o=t.find(S=>S.id===e);if(!o)return t;let n=(p=(m=o.position)==null?void 0:m.x)!=null?p:0,r=(E=(h=o.position)==null?void 0:h.y)!=null?E:0,i=(g=(f=o.measured)==null?void 0:f.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 S of t){if(S.id===e||S.parentId)continue;let L=(_=(w=S.position)==null?void 0:w.y)!=null?_:0,$=(T=(N=S.position)==null?void 0:N.x)!=null?T:0,K=(C=(I=S.measured)==null?void 0:I.width)!=null?C:0,te=(R=(P=S.measured)==null?void 0:P.height)!=null?R:0;$<l&&$+K>n&&L<a&&L+te>r&&(c.add(S.id),d=Math.min(d,L))}if(c.size===0)return t;let u=a+kp-d;return t.map(S=>{var $,K,te;if(!c.has(S.id))return S;let L=(K=($=S.position)==null?void 0:$.y)!=null?K:0;return v(b({},S),{position:v(b({},(te=S.position)!=null?te:{x:0,y:0}),{y:L+u})})})},ve=15,no=e=>[...e].sort((t,o)=>t.position.y-o.position.y),Dp=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)},Op=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,m,p,h,E,f,g,y,x,w,_,N,T,I;if(t.length===0)return e;let n=(m=(u=e.width)!=null?u:(d=e.measured)==null?void 0:d.width)!=null?m:0,r=(E=(h=e.height)!=null?h:(p=e.measured)==null?void 0:p.height)!=null?E:0,i=0,s=0;for(let C of t){let P=Dp(C),R=Op(C);if(((g=(f=C.position)==null?void 0:f.y)!=null?g:0)<ve&&(o.set(C.id,v(b({},C),{position:v(b({},C.position),{y:ve})})),R=ve+((x=(y=C.measured)==null?void 0:y.height)!=null?x:0)),((_=(w=C.position)==null?void 0:w.x)!=null?_:0)<se.HEADER_WIDTH+ve){let S=(N=o.get(C.id))!=null?N:C;o.set(C.id,v(b({},S),{position:v(b({},S.position),{x:se.HEADER_WIDTH+ve})})),P=se.HEADER_WIDTH+ve+((I=(T=C.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+ve>a&&(a=i+ve),s+ve>l&&(l=s+ve);let c=v(b({},e),{width:a,height:l,measured:v(b({},e.measured),{width:a,height:l})});return o.set(e.id,c),c},ca=(e,t,o)=>{var s,a;let n=no(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,v(b({},d),{position:{x:se.HEADER_WIDTH,y:i}})),i+=(a=d.height)!=null?a:0}},da=(e,t)=>{var h,E,f,g;let o=[];for(let y of t.values())y.parentId===e.id&&o.push(y);let n=no(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 w;return y+((w=x.height)!=null?w: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,m=0;for(let y=0;y<n.length;y++){let x=n[y],w=Math.max(se.MIN_HEIGHT,(f=x.height)!=null?f:se.MIN_HEIGHT),_=v(b({},x),{width:u,height:w,measured:v(b({},x.measured),{width:u,height:w}),position:{x:se.HEADER_WIDTH,y:m}});if(y===o.length-1){let N=Math.max(se.MIN_HEIGHT,l-m);_=v(b({},_),{height:N,measured:v(b({},x.measured),{width:u,height:N})})}t.set(x.id,_),m+=(g=_.height)!=null?g:0}let p=Math.max(l,m);t.set(e.id,v(b({},e),{width:d,height:p,measured:v(b({},e.measured),{width:d,height:p})}))},ua=(e,t,o,n,r)=>{var h,E;let i=!e.parentId,s=i?e.id:e.parentId,a=n.filter(f=>f.type==="LANE"&&f.parentId===s);if(!a.length)return n;let l=no(a),c=l.findIndex(f=>f.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,m=0,p=[...n];return l.forEach((f,g)=>{var N,T;let y=g===l.length-1,x=f.id===e.id,_=(T=(N=f.measured)==null?void 0:N.height)!=null?T:0;x?_=o:u&&g===c-1&&(_=Math.max(se.MIN_HEIGHT,r-m)),y&&i&&(_=Math.max(se.MIN_HEIGHT,o-m)),p=p.map(I=>{if(I.id===f.id){let C=i?t-se.HEADER_WIDTH:t;return v(b({},I),{width:C,height:_,measured:v(b({},I.measured),{width:C,height:_}),position:{x:se.HEADER_WIDTH,y:m}})}return I}),x&&u?m=r+o:m+=_}),p=p.map(f=>{if(f.id===s){let g=i?t:t+se.HEADER_WIDTH;return v(b({},f),{width:g,height:i?o:m,measured:{width:g,height:i?o:m}})}return f}),p};var Gi=(e,t,o)=>{var a,l,c,d,u,m,p,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<ve&&(e.position.y=ve),e.position.x<se.HEADER_WIDTH+ve&&(e.position.x=se.HEADER_WIDTH+ve);let i=e.position.x+((m=(u=e.measured)==null?void 0:u.width)!=null?m:0),s=e.position.y+((h=(p=e.measured)==null?void 0:p.height)!=null?h:0);return i+ve>n&&(t.width=i+ve,t.measured.width=i+ve),s+ve>r&&(t.height=s+ve,t.measured.height=s+ve),o=o.map(E=>E.id===t.id?v(b({},E),{height:t.height,width:t.width,measured:t.measured}):E.id===e.id?v(b({},E),{position:e.position}):E),o};import{create as Vp}from"zustand";import{useReactFlow as Hp}from"@xyflow/react";import{useCallback as Gp}from"react";var Kn=()=>{let{setEdges:e}=Hp();return Gp(()=>{let o=ro.getState().pathEdgeIds;e(n=>n.map(r=>v(b({},r),{selected:o.includes(r.id)})))},[e])},ro=Vp((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=b({},n.statusByNodeId),i=b({},n.statusData),s=!1;return o.forEach(a=>{let l=`${a.diagramId}-${a.activityId}`;r[a.diagramId]!==a.status&&(r[a.diagramId]=a.status,i[l]=a,s=!0)}),s?{statusByNodeId:r,statusData:i}:n})},getTaskStatus:o=>t().statusByNodeId[o]||null,clearTaskStatuses:()=>e({statusByNodeId:{},statusData:{},pathEdgeIds:[]}),setPathEdges:o=>{e({pathEdgeIds:o})},getPathEdgeIds:()=>t().pathEdgeIds,clearPathEdges:()=>{e({pathEdgeIds:[]})},calculateFlowPath:(o,n)=>{if(!o.length||!n.length)return;t().clearPathEdges();let r=n.filter(d=>t().statusByNodeId[d]);if(r.length<=1)return;let i=[],s={};o.forEach(d=>{s[d.source]||(s[d.source]=[]),s[d.source].push({targetId:d.target,edgeId:d.id})});let a=r[0],l=r[r.length-1];o.forEach(d=>{d.target===a&&i.push(d.id)}),o.forEach(d=>{d.source===l&&i.push(d.id)});let c=(d,u)=>{let m=[],p=new Set;for(m.push({node:d,path:[]}),p.add(d);m.length>0;){let{node:h,path:E}=m.shift();if(h===u)return E;let f=s[h]||[];for(let{targetId:g,edgeId:y}of f)p.has(g)||(p.add(g),m.push({node:g,path:[...E,y]}))}return[]};for(let d=0;d<r.length-1;d++){let u=r[d],m=r[d+1],p=c(u,m);p.length>0&&i.push(...p)}i.length>0&&e({pathEdgeIds:i})}}));import{useNodesInitialized as tg,useReactFlow as og,useStore as ng}from"@xyflow/react";import{useCallback as yn,useEffect as rg,useRef as ig,useState as ic}from"react";import{shallow as sg}from"zustand/shallow";var Bp={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 qn(o)}function qn(e){this._=e}function zp(e,t){return e.trim().split(/^|\s+/).map(function(o){var n="",r=o.indexOf(".");if(r>=0&&(n=o.slice(r+1),o=o.slice(0,r)),o&&!t.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:n}})}qn.prototype=fa.prototype={constructor:qn,on:function(e,t){var o=this._,n=zp(e+"",o),r,i=-1,s=n.length;if(arguments.length<2){for(;++i<s;)if((r=(e=n[i]).type)&&(r=Yp(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 qn(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var o=new Array(r),n=0,r,i;n<r;++n)o[n]=arguments[n+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],n=0,r=i.length;n<r;++n)i[n].value.apply(t,o)},apply:function(e,t,o){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var n=this._[e],r=0,i=n.length;r<i;++r)n[r].value.apply(t,o)}};function Yp(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]=Bp,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 Zn="http://www.w3.org/1999/xhtml",zi={svg:"http://www.w3.org/2000/svg",xhtml:Zn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function vt(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 Wp(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===Zn&&t.documentElement.namespaceURI===Zn?t.createElement(e):t.createElementNS(o,e)}}function Fp(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Jn(e){var t=vt(e);return(t.local?Fp:Wp)(t)}function Xp(){}function io(e){return e==null?Xp:function(){return this.querySelector(e)}}function ma(e){typeof e!="function"&&(e=io(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 Up(){return[]}function on(e){return e==null?Up:function(){return this.querySelectorAll(e)}}function $p(e){return function(){return Yi(e.apply(this,arguments))}}function ga(e){typeof e=="function"?e=$p(e):e=on(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 nn(e){return function(){return this.matches(e)}}function Qn(e){return function(t){return t.matches(e)}}var Kp=Array.prototype.find;function qp(e){return function(){return Kp.call(this.children,e)}}function Zp(){return this.firstElementChild}function ha(e){return this.select(e==null?Zp:qp(typeof e=="function"?e:Qn(e)))}var Jp=Array.prototype.filter;function Qp(){return Array.from(this.children)}function jp(e){return function(){return Jp.call(this.children,e)}}function ya(e){return this.selectAll(e==null?Qp:jp(typeof e=="function"?e:Qn(e)))}function xa(e){typeof e!="function"&&(e=nn(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],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 jn(e){return new Array(e.length)}function Ea(){return new Ae(this._enter||this._groups.map(jn),this._parents)}function rn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}rn.prototype={constructor:rn,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function ba(e){return function(){return e}}function ef(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 rn(e,i[s]);for(;s<l;++s)(a=t[s])&&(r[s]=a)}function tf(e,t,o,n,r,i,s){var a,l,c=new Map,d=t.length,u=i.length,m=new Array(d),p;for(a=0;a<d;++a)(l=t[a])&&(m[a]=p=s.call(l,l.__data__,a,t)+"",c.has(p)?r[a]=l:c.set(p,l));for(a=0;a<u;++a)p=s.call(e,i[a],a,i)+"",(l=c.get(p))?(n[a]=l,l.__data__=i[a],c.delete(p)):o[a]=new rn(e,i[a]);for(a=0;a<d;++a)(l=t[a])&&c.get(m[a])===l&&(r[a]=l)}function of(e){return e.__data__}function _a(e,t){if(!arguments.length)return Array.from(this,of);var o=t?tf:ef,n=this._parents,r=this._groups;typeof e!="function"&&(e=ba(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],m=u.length,p=nf(e.call(d,d&&d.__data__,c,n)),h=p.length,E=a[c]=new Array(h),f=s[c]=new Array(h),g=l[c]=new Array(m);o(d,u,E,f,g,p,t);for(var y=0,x=0,w,_;y<h;++y)if(w=E[y]){for(y>=x&&(x=y+1);!(_=f[x])&&++x<h;);w._next=_||null}}return s=new Ae(s,n),s._enter=a,s._exit=l,s}function nf(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Ta(){return new Ae(this._exit||this._groups.map(jn),this._parents)}function Na(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 va(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,m=a[l]=new Array(u),p,h=0;h<u;++h)(p=c[h]||d[h])&&(m[h]=p);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=rf);function t(u,m){return u&&m?e(u.__data__,m.__data__):!u-!m}for(var o=this._groups,n=o.length,r=new Array(n),i=0;i<n;++i){for(var 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 rf(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 Ca(){return Array.from(this)}function Sa(){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 sf(e){return function(){this.removeAttribute(e)}}function af(e){return function(){this.removeAttributeNS(e.space,e.local)}}function lf(e,t){return function(){this.setAttribute(e,t)}}function cf(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function df(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function uf(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,o)}}function Ra(e,t){var o=vt(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?af:sf:typeof t=="function"?o.local?uf:df:o.local?cf:lf)(o,t))}function er(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function pf(e){return function(){this.style.removeProperty(e)}}function ff(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 ka(e,t,o){return arguments.length>1?this.each((t==null?pf:typeof t=="function"?mf:ff)(e,t,o==null?"":o)):Vt(this.node(),e)}function Vt(e,t){return e.style.getPropertyValue(t)||er(e).getComputedStyle(e,null).getPropertyValue(t)}function gf(e){return function(){delete this[e]}}function hf(e,t){return function(){this[e]=t}}function yf(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?gf:typeof t=="function"?yf:hf)(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 xf(e){return function(){Ha(this,e)}}function Ef(e){return function(){Ga(this,e)}}function bf(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"?bf:t?xf:Ef)(o,t))}function _f(){this.textContent=""}function Tf(e){return function(){this.textContent=e}}function Nf(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function za(e){return arguments.length?this.each(e==null?_f:(typeof e=="function"?Nf:Tf)(e)):this.node().textContent}function vf(){this.innerHTML=""}function wf(e){return function(){this.innerHTML=e}}function If(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function Ya(e){return arguments.length?this.each(e==null?vf:(typeof e=="function"?If:wf)(e)):this.node().innerHTML}function Af(){this.nextSibling&&this.parentNode.appendChild(this)}function Wa(){return this.each(Af)}function Cf(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Fa(){return this.each(Cf)}function Xa(e){var t=typeof e=="function"?e:Jn(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Sf(){return null}function Ua(e,t){var o=typeof e=="function"?e:Jn(e),n=t==null?Sf:typeof t=="function"?t:io(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function Mf(){var e=this.parentNode;e&&e.removeChild(this)}function $a(){return this.each(Mf)}function Pf(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Lf(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Ka(e){return this.select(e?Lf:Pf)}function qa(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Rf(e){return function(t){e.call(this,t,this.__data__)}}function kf(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 Df(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 Of(e,t,o){return function(){var n=this.__on,r,i=Rf(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=kf(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?Of:Df,r=0;r<i;++r)this.each(a(n[r],t,o));return this}function Ja(e,t,o){var n=er(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 Vf(e,t){return function(){return Ja(this,e,t)}}function Hf(e,t){return function(){return Ja(this,e,t.apply(this,arguments))}}function Qa(e,t){return this.each((typeof t=="function"?Hf:Vf)(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 Gf=[null];function Ae(e,t){this._groups=e,this._parents=t}function el(){return new Ae([[document.documentElement]],Gf)}function Bf(){return this}Ae.prototype=el.prototype={constructor:Ae,select:ma,selectAll:ga,selectChild:ha,selectChildren:ya,filter:xa,data:_a,enter:Ea,exit:Ta,join:Na,merge:va,selection:Bf,order:wa,sort:Ia,call:Aa,nodes:Ca,node:Sa,size:Ma,empty:Pa,each:La,attr:Ra,style:ka,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 tr(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 ln(){}var sn=.7,rr=1/sn,Ao="\\s*([+-]?\\d+)\\s*",an="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",yt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",zf=/^#([0-9a-f]{3,8})$/,Yf=new RegExp(`^rgb\\(${Ao},${Ao},${Ao}\\)$`),Wf=new RegExp(`^rgb\\(${yt},${yt},${yt}\\)$`),Ff=new RegExp(`^rgba\\(${Ao},${Ao},${Ao},${an}\\)$`),Xf=new RegExp(`^rgba\\(${yt},${yt},${yt},${an}\\)$`),Uf=new RegExp(`^hsl\\(${an},${yt},${yt}\\)$`),$f=new RegExp(`^hsla\\(${an},${yt},${yt},${an}\\)$`),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};tr(ln,Ht,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:ol,formatHex:ol,formatHex8:Kf,formatHsl:qf,formatRgb:nl,toString:nl});function ol(){return this.rgb().formatHex()}function Kf(){return this.rgb().formatHex8()}function qf(){return cl(this).formatHsl()}function nl(){return this.rgb().formatRgb()}function Ht(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=zf.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?or(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?or(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=Yf.exec(e))?new ze(t[1],t[2],t[3],1):(t=Wf.exec(e))?new ze(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Ff.exec(e))?or(t[1],t[2],t[3],t[4]):(t=Xf.exec(e))?or(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Uf.exec(e))?al(t[1],t[2]/100,t[3]/100,1):(t=$f.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 or(e,t,o,n){return n<=0&&(e=t=o=NaN),new ze(e,t,o,n)}function Zf(e){return e instanceof ln||(e=Ht(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?Zf(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}tr(ze,Co,Fi(ln,{brighter(e){return e=e==null?rr:Math.pow(rr,e),new ze(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?sn:Math.pow(sn,e),new ze(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ze(ao(this.r),ao(this.g),ao(this.b),ir(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:Jf,formatRgb:sl,toString:sl}));function il(){return`#${so(this.r)}${so(this.g)}${so(this.b)}`}function Jf(){return`#${so(this.r)}${so(this.g)}${so(this.b)}${so((isNaN(this.opacity)?1:this.opacity)*255)}`}function sl(){let e=ir(this.opacity);return`${e===1?"rgb(":"rgba("}${ao(this.r)}, ${ao(this.g)}, ${ao(this.b)}${e===1?")":`, ${e})`}`}function ir(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ao(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function so(e){return e=ao(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 lt(e,t,o,n)}function cl(e){if(e instanceof lt)return new lt(e.h,e.s,e.l,e.opacity);if(e instanceof ln||(e=Ht(e)),!e)return new lt;if(e instanceof lt)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 lt(s,a,l,e.opacity)}function dl(e,t,o,n){return arguments.length===1?cl(e):new lt(e,t,o,n==null?1:n)}function lt(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}tr(lt,dl,Fi(ln,{brighter(e){return e=e==null?rr:Math.pow(rr,e),new lt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?sn:Math.pow(sn,e),new lt(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 lt(ll(this.h),nr(this.s),nr(this.l),ir(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=ir(this.opacity);return`${e===1?"hsl(":"hsla("}${ll(this.h)}, ${nr(this.s)*100}%, ${nr(this.l)*100}%${e===1?")":`, ${e})`}`}}));function ll(e){return e=(e||0)%360,e<0?e+360:e}function nr(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 Qf(e,t){return function(o){return e+o*t}}function jf(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?sr:function(t,o){return o-t?jf(t,o,e):$i(isNaN(t)?o:t)}}function sr(e,t){var o=t-e;return o?Qf(e,o):$i(isNaN(e)?t:e)}var ar=function e(t){var o=fl(t);function n(r,i){var s=o((r=Co(r)).r,(i=Co(i)).r),a=o(r.g,i.g),l=o(r.b,i.b),c=sr(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=Co(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 em=ml(ul),tm=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 om(e){return function(){return e}}function nm(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]?nm(l[0].x):om(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,lr={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 cr;function hl(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?lr:Ji(t.a,t.b,t.c,t.d,t.e,t.f)}function yl(e){return e==null?lr:(cr||(cr=document.createElementNS("http://www.w3.org/2000/svg","g")),cr.setAttribute("transform",e),(e=cr.transform.baseVal.consolidate())?(e=e.matrix,Ji(e.a,e.b,e.c,e.d,e.e,e.f)):lr)}function xl(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,m,p,h){if(c!==u||d!==m){var E=p.push("translate(",null,t,null,o);h.push({i:E-4,x:nt(c,u)},{i:E-2,x:nt(d,m)})}else(u||m)&&p.push("translate("+u+t+m+o)}function s(c,d,u,m){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),m.push({i:u.push(r(u)+"rotate(",null,n)-2,x:nt(c,d)})):d&&u.push(r(u)+"rotate("+d+n)}function a(c,d,u,m){c!==d?m.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,m,p,h){if(c!==u||d!==m){var E=p.push(r(p)+"scale(",null,",",null,")");h.push({i:E-4,x:nt(c,u)},{i:E-2,x:nt(d,m)})}else(u!==1||m!==1)&&p.push(r(p)+"scale("+u+","+m+")")}return function(c,d){var u=[],m=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,u,m),s(c.rotate,d.rotate,u,m),a(c.skewX,d.skewX,u,m),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,m),c=d=null,function(p){for(var h=-1,E=m.length,f;++h<E;)u[(f=m[h]).i]=f.x(p);return u.join("")}}}var Qi=xl(hl,"px, ","px)","deg)"),ji=xl(yl,", ",")",")");var So=0,dn=0,cn=0,bl=1e3,dr,un,ur=0,lo=0,pr=0,pn=typeof performance=="object"&&performance.now?performance:Date,_l=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function mn(){return lo||(_l(rm),lo=pn.now()+pr)}function rm(){lo=0}function fn(){this._call=this._time=this._next=null}fn.prototype=fr.prototype={constructor:fn,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?mn():+o)+(t==null?0:+t),!this._next&&un!==this&&(un?un._next=this:dr=this,un=this),this._call=e,this._time=o,es()},stop:function(){this._call&&(this._call=null,this._time=1/0,es())}};function fr(e,t,o){var n=new fn;return n.restart(e,t,o),n}function Tl(){mn(),++So;for(var e=dr,t;e;)(t=lo-e._time)>=0&&e._call.call(void 0,t),e=e._next;--So}function El(){lo=(ur=pn.now())+pr,So=dn=0;try{Tl()}finally{So=0,sm(),lo=0}}function im(){var e=pn.now(),t=e-ur;t>bl&&(pr-=t,ur=e)}function sm(){for(var e,t=dr,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:dr=o);un=e,es(n)}function es(e){if(!So){dn&&(dn=clearTimeout(dn));var t=e-lo;t>24?(e<1/0&&(dn=setTimeout(El,e-pn.now()-pr)),cn&&(cn=clearInterval(cn))):(cn||(ur=pn.now(),cn=setInterval(im,bl)),So=1,_l(El))}}function mr(e,t,o){var n=new fn;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var am=Bi("start","end","cancel","interrupt"),lm=[],wl=0,Nl=1,hr=2,gr=3,vl=4,yr=5,gn=6;function Gt(e,t,o,n,r,i){var s=e.__transition;if(!s)e.__transition={};else if(o in s)return;cm(e,o,{name:t,index:n,group:r,on:am,tween:lm,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:wl})}function hn(e,t){var o=Ce(e,t);if(o.state>wl)throw new Error("too late; already scheduled");return o}function ke(e,t){var o=Ce(e,t);if(o.state>gr)throw new Error("too late; already running");return o}function Ce(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function cm(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=fr(i,0,o.time);function i(c){o.state=Nl,o.timer.restart(s,o.delay,o.time),o.delay<=c&&s(c-o.delay)}function s(c){var d,u,m,p;if(o.state!==Nl)return l();for(d in n)if(p=n[d],p.name===o.name){if(p.state===gr)return mr(s);p.state===vl?(p.state=gn,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete n[d]):+d<t&&(p.state=gn,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete n[d])}if(mr(function(){o.state===gr&&(o.state=vl,o.timer.restart(a,o.delay,o.time),a(c))}),o.state=hr,o.on.call("start",e,e.__data__,o.index,o.group),o.state===hr){for(o.state=gr,r=new Array(m=o.tween.length),d=0,u=-1;d<m;++d)(p=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++u]=p);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=yr,1),u=-1,m=r.length;++u<m;)r[u].call(e,d);o.state===yr&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=gn,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function 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>hr&&n.state<yr,n.state=gn,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 dm(e,t){var o,n;return function(){var r=ke(this,e),i=r.tween;if(i!==o){n=o=i;for(var s=0,a=n.length;s<a;++s)if(n[s].name===t){n=n.slice(),n.splice(s,1);break}}r.tween=n}}function um(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=ke(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=Ce(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?dm:um)(o,e,t))}function Mo(e,t,o){var n=e._id;return e.each(function(){var r=ke(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return Ce(r,n).value[t]}}function xr(e,t){var o;return(typeof t=="number"?nt:t instanceof Ht?ar:(o=Ht(t))?(t=o,ar):Zi)(e,t)}function pm(e){return function(){this.removeAttribute(e)}}function fm(e){return function(){this.removeAttributeNS(e.space,e.local)}}function mm(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 gm(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 hm(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 ym(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 Cl(e,t){var o=vt(e),n=o==="transform"?ji:xr;return this.attrTween(e,typeof t=="function"?(o.local?ym:hm)(o,n,Mo(this,"attr."+e,t)):t==null?(o.local?fm:pm)(o):(o.local?gm:mm)(o,n,t))}function xm(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function Em(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function bm(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Em(e,i)),o}return r._value=t,r}function _m(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&xm(e,i)),o}return r._value=t,r}function Sl(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=vt(e);return this.tween(o,(n.local?bm:_m)(n,t))}function Tm(e,t){return function(){hn(this,e).delay=+t.apply(this,arguments)}}function Nm(e,t){return t=+t,function(){hn(this,e).delay=t}}function Ml(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Tm:Nm)(t,e)):Ce(this.node(),t).delay}function vm(e,t){return function(){ke(this,e).duration=+t.apply(this,arguments)}}function wm(e,t){return t=+t,function(){ke(this,e).duration=t}}function Pl(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?vm:wm)(t,e)):Ce(this.node(),t).duration}function Im(e,t){if(typeof t!="function")throw new Error;return function(){ke(this,e).ease=t}}function Ll(e){var t=this._id;return arguments.length?this.each(Im(t,e)):Ce(this.node(),t).ease}function Am(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;ke(this,e).ease=o}}function Rl(e){if(typeof e!="function")throw new Error;return this.each(Am(this._id,e))}function kl(e){typeof e!="function"&&(e=nn(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],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),m,p=0;p<d;++p)(m=l[p]||c[p])&&(u[p]=m);for(;a<n;++a)s[a]=t[a];return new He(s,this._parents,this._name,this._id)}function Cm(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 Sm(e,t,o){var n,r,i=Cm(t)?hn:ke;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?Ce(this.node(),o).on.on(e):this.each(Sm(o,e,t))}function Mm(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",Mm(this._id))}function Hl(e){var t=this._name,o=this._id;typeof e!="function"&&(e=io(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,m=0;m<l;++m)(d=a[m])&&(u=e.call(d,d.__data__,m,a))&&("__data__"in d&&(u.__data__=d.__data__),c[m]=u,Gt(c[m],t,o,m,c,Ce(d,o)));return new He(i,this._parents,t,o)}function Gl(e){var t=this._name,o=this._id;typeof e!="function"&&(e=on(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 m=e.call(d,d.__data__,u,l),p,h=Ce(d,o),E=0,f=m.length;E<f;++E)(p=m[E])&&Gt(p,t,o,E,m,h);i.push(m),s.push(d)}return new He(i,s,t,o)}var Pm=wt.prototype.constructor;function Bl(){return new Pm(this._groups,this._parents)}function Lm(e,t){var o,n,r;return function(){var i=Vt(this,e),s=(this.style.removeProperty(e),Vt(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 Rm(e,t,o){var n,r=o+"",i;return function(){var s=Vt(this,e);return s===r?null:s===n?i:i=t(n=s,o)}}function km(e,t,o){var n,r,i;return function(){var s=Vt(this,e),a=o(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),Vt(this,e))),s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a))}}function Dm(e,t){var o,n,r,i="style."+t,s="end."+i,a;return function(){var l=ke(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:xr;return t==null?this.styleTween(e,Lm(e,n)).on("end.style."+e,zl(e)):typeof t=="function"?this.styleTween(e,km(e,n,Mo(this,"style."+e,t))).each(Dm(this._id,e)):this.styleTween(e,Rm(e,n,t),o).on("end.style."+e,null)}function Om(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function Vm(e,t,o){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&Om(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,Vm(e,t,o==null?"":o))}function Hm(e){return function(){this.textContent=e}}function Gm(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function Fl(e){return this.tween("text",typeof e=="function"?Gm(Mo(this,"text",e)):Hm(e==null?"":e+""))}function Bm(e){return function(t){this.textContent=e.call(this,t)}}function zm(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&Bm(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,zm(e))}function Ul(){for(var e=this._name,t=this._id,o=Er(),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=Ce(l,t);Gt(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=ke(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 Ym=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 Er(){return++Ym}var It=wt.prototype;He.prototype=Kl.prototype={constructor:He,select:Hl,selectAll:Gl,selectChild:It.selectChild,selectChildren:It.selectChildren,filter:kl,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:Cl,attrTween:Sl,style:Yl,styleTween:Wl,text:Fl,textTween:Xl,remove:Vl,tween:Al,delay:Ml,duration:Pl,ease:Ll,easeVarying:Rl,end:$l,[Symbol.iterator]:It[Symbol.iterator]};function br(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Wm={time:null,delay:0,duration:250,ease:br};function Fm(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=Er(),(o=Wm).time=mn(),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])&&Gt(l,e,t,c,s,o||Fm(l,t));return new He(n,this._parents,e,t)}wt.prototype.interrupt=Il;wt.prototype.transition=ql;function Bt(e,t,o){this.k=e,this.x=t,this.y=o}Bt.prototype={constructor:Bt,scale:function(e){return e===1?this:new Bt(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Bt(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 Bt(1,0,0);Tr.prototype=Bt.prototype;function Tr(e){for(;!e.__zoom;)if(!(e=e.parentNode))return _r;return e.__zoom}var Um=[[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 $w={[Ye.Left]:Ye.Right,[Ye.Right]:Ye.Left,[Ye.Top]:Ye.Bottom,[Ye.Bottom]:Ye.Top};var $m=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var Km=(e,t=[0,0])=>{var a;let{width:o,height:n}=qm(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 Nr=(e,t=[0,0])=>{var r,i,s,a,l,c,d,u;let{x:o,y:n}=$m(e)?e.internals.positionAbsolute:Km(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 qm(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 Kw={[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 Zm={nodeOrigin:[0,0],nodeExtent:Um,elevateNodesOnSelect:!0,defaults:{}},qw=v(b({},Zm),{checkEquality:!0});var tc;(function(e){e.Line="line",e.Handle="handle"})(tc||(tc={}));var Jm={width:0,height:0,x:0,y:0},Zw=v(b({},Jm),{pointerX:0,pointerY:0,aspectRatio:1});var Qm=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function jm(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 eg(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 p of s){if(p.position<a)continue;if(p.position>l)break;if(i.has(p.node.id)||p.node.parentId&&i.has(p.node.parentId)||!Qm(p.nodeBox,r))continue;let h=Math.abs(p.position-o);if(h>wr)continue;let f=jm(p.nodeBox,n)>0?0:eg(p.nodeBox,n);c.push({line:p,lineDist:h,nodeDist:f})}let d=.5,u=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;c.sort((p,h)=>{if(u){if(p.line===u&&h.line!==u)return-1;if(h.line===u&&p.line!==u)return 1}return Math.abs(p.lineDist-h.lineDist)<=d?p.nodeDist-h.nodeDist:p.lineDist-h.lineDist});let m=c.length>0?c[0].line:void 0;return m&&(t==="horizontal"?this.lastHorizontalLine=m:this.lastVerticalLine=m),m}};function oc(e,t=co,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=Nr(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(co)){let i=[];for(let a of r){let l=co[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)<=wr&&(r=l,s=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=wr&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:s}}var wr=10,co={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 lg}from"react/jsx-runtime";var ag=new vr;function Ir(){let[e,t]=ic(void 0),[o,n]=ic(void 0),{width:r,height:i}=ng(f=>({width:f.width,height:f.height}),sg),s=tg(),a=ig(ag),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=og(),u=yn(()=>{t(void 0),n(void 0)},[]),m=yn(f=>{let g=f!=null?f:d();u();let y=oc(g,co,c);a.current.initialize(y)},[c,u,d]),p=yn(()=>{setTimeout(()=>{m()},100)},[m]);rg(()=>{s&&m(d())},[s,m,d]);let h=yn((f,g)=>{var B,k,O,V,F,J,X,Q,ee,ie;if(!a.current||f.length===0||f.filter(W=>W.type==="dimensions").length>1)return f;u();let x=f.filter(W=>W.type==="position"&&!!W.position),w=f.find(W=>W.type==="dimensions");if(x.length===0&&!w)return f;let _=Object.keys(co),N=new Set,T=1/0,I=1/0,C=-1/0,P=-1/0;if(x.length>0)x.forEach(W=>{var de,re,j,ge,_e,Te;let oe=g.find(Re=>Re.id===W.id);if(!oe)return;N.add(oe.id);let le=c(oe.id);if(!le)return;let q=le.parentId?c(le.parentId):void 0,xe=W.position.x+((de=q==null?void 0:q.internals.positionAbsolute.x)!=null?de:0),me=W.position.y+((re=q==null?void 0:q.internals.positionAbsolute.y)!=null?re:0),be=(ge=(j=oe.measured)==null?void 0:j.width)!=null?ge:0,Z=(Te=(_e=oe.measured)==null?void 0:_e.height)!=null?Te:0;T=Math.min(T,xe),I=Math.min(I,me),C=Math.max(C,xe+be),P=Math.max(P,me+Z)}),w&&(_=["top","left"]);else if(w){let W=g.find(be=>be.id===w.id);if(!W)return f;N.add(W.id);let oe=c(W.id);if(!oe)return f;let le=oe.internals.positionAbsolute.x,q=oe.internals.positionAbsolute.y,xe=(V=(O=(B=w.dimensions)==null?void 0:B.width)!=null?O:(k=W.measured)==null?void 0:k.width)!=null?V:0,me=(Q=(X=(F=w.dimensions)==null?void 0:F.height)!=null?X:(J=W.measured)==null?void 0:J.height)!=null?Q:0;T=le,I=q,C=le+xe,P=q+me,_=["right","bottom"]}if(T===1/0)return f;let R={x:T,y:I,x2:C,y2:P},{x:S,y:L}=l({x:0,y:0}),{x:$,y:K}=l({x:r,y:i}),te={x:S,y:L,x2:$,y2:K},{horizontal:z,vertical:M}=nc(a.current,te,R,N,_),{deltaX:H,deltaY:D,snappedX:A,snappedY:Y}=rc(R,z,M);if(A||Y){let W=x.some(le=>le.dragging),oe=!!(w!=null&&w.resizing);(W||oe)&&(A&&n(M==null?void 0:M.line),Y&&t(z==null?void 0:z.line)),A&&(x.forEach(le=>{le.position&&(le.position.x-=H)}),(w==null?void 0:w.id)===((ee=x[0])==null?void 0:ee.id)?w.dimensions&&(w.dimensions.width+=H):w&&!x.length&&w.dimensions&&(w.dimensions.width-=H)),Y&&(x.forEach(le=>{le.position&&(le.position.y-=D)}),(w==null?void 0:w.id)===((ie=x[0])==null?void 0:ie.id)?w.dimensions&&(w.dimensions.height+=D):w&&!x.length&&w.dimensions&&(w.dimensions.height-=D))}return f},[l,c,r,i,t,n,u]),E=yn(()=>lg(sc,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:m,forceRebuildIndex:p,updateHelperLines:h,helperLineHorizontal:e,helperLineVertical:o,HelperLines:E}}import{reconnectEdge as f0,useReactFlow as m0}from"@xyflow/react";import{useCallback as ho,useRef as g0}from"react";var At=e=>new Map(e.map(t=>[t.id,t])),xn=(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"),zt=(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:xn(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},Ar=(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:xn(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"},Cr=(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"},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"},uo=(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"})},En=(e,t,o,n)=>{let r=At(t),i=r.get(e);return!i||i.type!=="TASK"?!1:xn(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"?En(t,o,n,r):(a==null?void 0:a.type)==="END_EVENT"&&(s==null?void 0:s.type)==="TASK"?uo(e,o,n,r):!1},Mr=(e,t,o)=>xn(e,t,o).length>0,Pr=(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:xn(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 cg=[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:!Ar(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!Pr(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==="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:!(Cr(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:!(uo(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:!(En(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(Mr(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 cg){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var dg=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:Ar(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:Cr(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:uo(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:Mr(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Pr(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],mc=e=>{let t=dg.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 Bg,EdgeLabelRenderer as zg,getStraightPath as Yg,useInternalNode as hc,useViewport as Wg}from"@xyflow/react";import{Button as fg,Tooltip as mg,TooltipContent as gg,TooltipTrigger as hg,useTranslation as yg}from"@produto-lecom/lecom-ui";import{Settings as xg}from"lucide-react";import{getIncomers as Lr,getOutgoers as Rr,useReactFlow as pg}from"@xyflow/react";import{useStoreApi as ug}from"@xyflow/react";var Yt=()=>{let e=ug();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 Bn(),!0}}};var kr=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=pg(),{selectElements:r}=Yt(),i=f=>{let g=o(),y=n(),x=Lr(f,g,y),w=Rr(f,g,y),_=x.some(T=>T.type==="START_EVENT"),N=w.some(T=>T.type==="END_EVENT");return _?"start":N?"end":"between"},s=(f,g,y)=>{var _,N,T,I;if(!f)return;let x={type:f.type,variant:(_=f.data)==null?void 0:_.variant,attribute:(N=f.data)==null?void 0:N.attribute},w={id:f.id,position:i(f),label:(T=f.data)==null?void 0:T.label,node:x};return f.type==="TASK"&&((I=f.data)==null?void 0:I.variant)==="SUBPROCESS"?v(b({},w),{type:"sub_process"}):f.type==="GATEWAY"?v(b({},w),{type:"gateway",variant:a(f,g,y)}):v(b({},w),{type:"activity"})},a=(f,g,y)=>{if(f.type!=="GATEWAY")return;let x=Lr(f,g,y),w=!1,_=!1;if(x.forEach(N=>{var T,I;N.type==="TASK"&&(((T=N.data)==null?void 0:T.variant)==="SCRIPT"&&(w=!0),((I=N.data)==null?void 0:I.attribute)==="LOOP"&&(_=!0))}),w&&_)return"script_loop";if(w)return"script";if(_)return"loop"},l=(f,g,y)=>{var T,I,C,P;let x=e(f.source),w=e(f.target);if(!x||!w)return"simple";if(Rr(x,g,y).some(R=>R.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 R=(I=x.data)==null?void 0:I.variant,S=(C=x.data)==null?void 0:C.attribute;if(R==="SUBPROCESS")return"from_sub_process";if(w.type==="TASK"&&((P=w.data)==null?void 0:P.variant)==="SUBPROCESS")return"to_sub_process";let L=R==="SCRIPT",$=S==="LOOP";return L&&$?"script_loop":L?"script":$?"loop":"simple"}return"simple"},c=(f,g,y)=>{let x=[];function w(N,T,I=0){let C=s(N,g,y);if(C.depth=I,T.push(C),N.type==="TASK"){x.push([...T]),T.pop();return}let P=Lr(N,g,y);if(P.length)for(let R of P)w(R,T,I+1);T.pop()}let _=Lr(f,g,y);for(let N of _)w(N,[]);return x},d=(f,g,y)=>{let x=[];function w(N,T,I=0){let C=s(N,g,y);if(C.depth=I,T.push(C),N.type==="TASK"){x.push([...T]),T.pop();return}let P=Rr(N,g,y);if(P.length)for(let R of P)w(R,T,I+1);T.pop()}let _=Rr(f,g,y);for(let N of _)w(N,[]);return x},u=(f,g,y)=>(y=y.filter(w=>w.source===f.id),y.map(w=>{var T;let _=e(w.target),N;return _&&(N=s(_,g,y)),{id:w.id,type:"routing",variant:l(w,g,y),label:(T=w.data)==null?void 0:T.label,target:N}})),m=f=>{let g=e(f);if(!g)return;let y=o(),x=n(),w=s(g,y,x);return w.sources=c(g,y,x),w.targets=d(g,y,x),w.edgeTargets=u(g,y,x),g.type==="GATEWAY"&&(w.variant=a(g,y,x)),w},p=f=>{let g=t(f);if(!g)return;let y=o(),x=n(),w=l(g,y,x),N={id:g.id,type:"routing",variant:w,gatewayVariant:void 0},T=e(g.source);if(T){let C=s(T,y,x);N.source=C;let P=a(T,y,x);if(N.gatewayVariant=P,T.type==="TASK")N.sources=[[C]];else{let R=c(T,y,x);N.sources=R.length?R:[[C]]}}let I=e(g.target);if(I){let C=s(I,y,x);if(N.target=C,I.type==="TASK")N.targets=[[C]];else{let P=d(I,y,x);N.targets=P.length?P:[[C]]}}return N},h=f=>{let g=e(f);if(g)return m(g.id);let y=t(f);if(y)return p(y.id)};return{configureElement:f=>{let g=h(f);if(g)return r([f]),g},getConfigureElement:h,getNodeConfigure:m,getEdgeConfigure:p}};import{jsx as Dr,jsxs as bg}from"react/jsx-runtime";var Eg={node:"editor.toolbar.configure_node",edge:"editor.toolbar.configure_edge",gateway:"editor.toolbar.configure_gateway"},Wt=({elementId:e,elementType:t="node"})=>{let{t:o}=yg(),{onConfigureElement:n}=U(),{getConfigureElement:r}=kr();return bg(mg,{children:[Dr(hg,{asChild:!0,children:Dr(fg,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let s=r(e);s&&(n==null||n(s))},children:Dr(xg,{size:16})})}),Dr(gg,{color:"black",children:o(Eg[t])})]})};import{Button as Tg,Tooltip as Ng,TooltipContent as vg,TooltipTrigger as wg,useTranslation as Ig}from"@produto-lecom/lecom-ui";import{useReactFlow as Ag}from"@xyflow/react";import{TrashIcon as Cg}from"lucide-react";import{useNotificationToast as _g}from"@produto-lecom/lecom-ui";function We(){let{toast:e}=bn(),{toast:t}=_g();return{toast:e||t}}import{jsx as Or,jsxs as Sg}from"react/jsx-runtime";var Vr=({elementId:e,elementType:t="node"})=>{let{t:o}=Ig(),{toast:n}=We(),{deleteElements:r,getNodes:i}=Ag();return Sg(Ng,{children:[Or(wg,{asChild:!0,children:Or(Tg,{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:Or(Cg,{size:16})})}),Or(vg,{color:"black",children:o("editor.toolbar.delete")})]})};import{Button as Mg,Tooltip as Pg,TooltipContent as Lg,TooltipTrigger as Rg,useTranslation as kg}from"@produto-lecom/lecom-ui";import{MoveUpRightIcon as Dg}from"lucide-react";import{useCallback as Og}from"react";import{jsx as Hr,jsxs as Vg}from"react/jsx-runtime";var Po=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=kg(),r=Og(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((m,p)=>{let h=m.getBoundingClientRect(),E=p.getBoundingClientRect(),f=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))<f?p:m}),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 Vg(Pg,{children:[Hr(Rg,{asChild:!0,children:Hr(Mg,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:Hr(Dg,{size:16})})}),Hr(Lg,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};import{jsx as _n}from"react/jsx-runtime";var Lo=i=>{var s=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=s,r=gt(s,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:a}=U(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d,isToEndEvent:u}=$n(o,n),m=!l&&!c&&!d&&!u,p=[{component:_n(Vr,{elementId:e,elementType:"edge"})}],h=()=>a==="view"?m?[{component:_n(Wt,{elementId:e,elementType:"edge"})}]:[]:m?[{component:_n(Wt,{elementId:e,elementType:"edge"})},...p]:p,f=(g=>{switch(g){case"SEQUENCE_EDGE":return h();case"MESSAGE_EDGE":return a==="view"?[]:[...p];case"ANNOTATION_EDGE":return a==="view"?[]:[...p];default:return[]}})(t);if(!(f.length===0||a==="readonly"))return _n("div",v(b({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:f.map((g,y)=>_n("div",{children:g.component},y))}))};import{useViewport as Hg}from"@xyflow/react";import{useMemo as Gg}from"react";import{jsx as gc}from"react/jsx-runtime";var xt=12,Ro=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:s}=Hg(),a=1/s,l=Gg(()=>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:b({},l),children:i})})};import{Fragment as Fg,jsx as fo,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}=U(),{zoom:l}=Wg(),c=hc(t),d=hc(o);if(!c||!d)return null;let{sx:u,sy:m,tx:p,ty:h}=Io(c,d),[E,f,g]=Yg({sourceX:u,sourceY:m,targetX:p,targetY:h}),y=a&&(n||(c==null?void 0:c.selected)||(d==null?void 0:d.selected));return fo(Fg,{children:yc("g",{className:G("group bpmn-edge",{"is-highlighted":y}),children:[fo("path",{d:E,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/l),style:{pointerEvents:"stroke",cursor:"pointer"}}),yc("g",{className:G("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!s,"text-blue-500 group-hover:text-blue-600":y}),children:[fo(Bg,{id:e,path:E,interactionWidth:0,strokeDasharray:4,className:G("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)})}),fo(zg,{children:fo("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${f}px, ${g}px)`},children:n&&!i&&fo(Ro,{sx:u,sy:m,tx:p,ty:h,children:fo(Lo,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})})})]})]})})};import{useState as Cc,useCallback as Sc,useMemo as ss,useEffect as ah,useRef as as}from"react";import{BaseEdge as lh,EdgeLabelRenderer as ch,MarkerType as Mc,useInternalNode as Pc,useReactFlow as dh,useViewport as uh,useEdges as ph,useNodes as fh,Position as Ho}from"@xyflow/react";import{useCallback as Xg,useEffect as rs,useRef as Ec,useState as Ug}from"react";import{jsx as _c}from"react/jsx-runtime";var is=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,bc=["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),m=Ec(null),[p,h]=Ug(!1);rs(()=>()=>{m.current&&clearTimeout(m.current)},[]),rs(()=>{h(i!=null?i:!1)},[i]),rs(()=>{if(p&&u.current){u.current.focus();let _=document.createRange();_.selectNodeContents(u.current);let N=window.getSelection();N&&(N.removeAllRanges(),N.addRange(_))}},[p]);let E=Xg(()=>{m.current||(c==null||c(),m.current=setTimeout(()=>{m.current=null},500))},[c]),f=_=>{_.stopPropagation(),p||h(!0)},g=_=>{let N=_.currentTarget.innerText.replace(/\n$/,""),T=t&&N.length>=t,I=window.getSelection(),C=(I==null?void 0:I.toString())||"",P=C.length>0,R=(_.ctrlKey||_.metaKey)&&!_.altKey,S=R&&_.key==="a",L=R&&_.key==="c",$=R&&_.key==="x",K=R&&_.key==="v",te=N.length===0||P&&C.length===N.length;if(!d&&te&&!is.test(_.key)&&!bc.includes(_.key)&&!R){_.preventDefault(),E();return}T&&!P&&(bc.includes(_.key)||S||L||$||K||_.preventDefault())},y=_=>{_.preventDefault();let N=_.clipboardData.getData("text/plain").replace(/\r\n/g,`
|
|
2
2
|
`).replace(/\r/g,`
|
|
3
|
-
`),_
|
|
3
|
+
`),T=_.currentTarget.innerText.replace(/\n$/,""),I=window.getSelection();if(!I||I.rangeCount===0)return;let C=I.toString(),P=T.length-C.length,R=t?Math.max(0,t-P):1/0;if(R<=0&&C.length===0)return;let S=N;if(S.length>R&&(S=S.substring(0,R)),!S&&C.length===0)return;let L=I.getRangeAt(0),$=L.startOffset===0&&(L.startContainer===_.currentTarget||L.startContainer.parentNode===_.currentTarget);if(!d&&$&&S.length>0&&!is.test(S[0])){E();return}L.deleteContents();let K=document.createTextNode(S);L.insertNode(K),L.setStartAfter(K),L.collapse(!0),I.removeAllRanges(),I.addRange(L),l==null||l(_.currentTarget.innerText.replace(/\n$/,""))},x=_=>{let N=_.currentTarget,T=N.innerText.replace(/\n$/,"");if(!d&&T.length>0&&!is.test(T[0])){let I=T.slice(1);if(N.innerText=I,I.length>0&&N.firstChild){let C=document.createRange(),P=window.getSelection();C.setStart(N.firstChild,0),C.collapse(!0),P==null||P.removeAllRanges(),P==null||P.addRange(C)}E(),l==null||l(I);return}l==null||l(T)},w=_=>{h(!1);let N=_.currentTarget.innerText.replace(/\r\n/g,`
|
|
4
4
|
`).replace(/\r/g,`
|
|
5
|
-
`).trim();t&&T.length>t&&(T=T.substring(0,t)),N.currentTarget.innerText=T,a==null||a(),T!==e&&(s==null||s(T))};return Tc("div",{className:G("flex-1 p-2 self-stretch flex items-center justify-center border border-transparent overflow-hidden text-ellipsis body-medium-400 text-center rounded-sm",{"border border-dashed border-grey-400 bg-white shadow-md":p,"bg-white":e.length>0},n),style:o,onDoubleClick:f,children:Tc("div",{ref:u,className:G("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":p}),contentEditable:p,suppressContentEditableWarning:!0,onKeyDown:h,onPaste:y,onInput:E,onBlur:v,children:e})})};import{Position as zI}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),Gr=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),Ug=(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 s=Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*r)/i));return Do(e,{x:t.x+s*n,y:t.y+s*r})},Nc=(e,t)=>{let o=1/0;for(let n=0;n<t.length-1;n++)o=Math.min(o,Ug(e,t[n],t[n+1]));return o};import{Position as Br}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 $g(e,t,o){return ye(e,t,"x",ce)&&ye(t,o,"x",ce)&&ye(e,o,"x",ce)}function Kg(e,t,o){return ye(e,t,"y",ce)&&ye(t,o,"y",ce)&&ye(e,o,"y",ce)}function qg(e,t,o){if(!$g(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 Zg(e,t,o){if(!Kg(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 Jg(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 zr(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 Qg(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(qg(r,i,s)||Zg(r,i,s)){t.splice(n,1),o=!0;break}}}return t}function wc(e){let t=zr(vc([...e]));return t=Qg(t),zr(vc(t))}function Yr(e){switch(e){case Br.Left:return{x:-1,y:0};case Br.Right:return{x:1,y:0};case Br.Top:return{x:0,y:-1};case Br.Bottom:return{x:0,y:1};default:return{x:0,y:0}}}function Ic(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 s=(o.x-e.x)*t.x;s>0&&s<2*Ft.OFFSET&&(r=s/2,i=s/2)}else{let s=(o.y-e.y)*t.y;s>0&&s<2*Ft.OFFSET&&(r=s/2,i=s/2)}return{sourceOffset:r,targetOffset:i}}function jg(e,t,o,n,r,i,s=0){let a=Yr(r),l=Yr(i),c=a.x===0?s:0,d=a.y===0?s:0,u=l.x===0?s:0,m=l.y===0?s:0,p={x:e+c,y:t+d},g={x:o+u,y:n+m},{sourceOffset:x,targetOffset:f}=Ic(p,a,g,l),h={x:p.x+a.x*x,y:p.y+a.y*x},y={x:g.x+l.x*f,y:g.y+l.y*f},E=Jg(h,a,y,l),v=[p,h,...E,y,g],N=wc(v);if(N.length===2&&Wr(p,g)>ce){let T=ye(p,h,"x",ce)&&ye(h,y,"x",ce)&&ye(y,g,"x",ce),_=ye(p,h,"y",ce)&&ye(h,y,"y",ce)&&ye(y,g,"y",ce);if(T||_){let A=_&&(y.x-h.x)*a.x<0,M=T&&(y.y-h.y)*a.y<0;if(!A&&!M)return zr([p,h,y,g])}}return N}function Fr(e,t,o,n,r,i,s,a=0){if(!(s!=null&&s.length))return jg(e,t,o,n,r,i,a);let l=Yr(r),c=Yr(i),d=l.x===0?a:0,u=l.y===0?a:0,m=c.x===0?a:0,p=c.y===0?a:0,g={x:e+d,y:t+u},x={x:o+m,y:n+p},{sourceOffset:f,targetOffset:h}=Ic(g,l,x,c),y={x:g.x+l.x*f,y:g.y+l.y*f},E={x:x.x+c.x*h,y:x.y+c.y*h},v=[...s],N=v[0],T=l.y===0;T&&Math.abs(g.y-N.y)>ce?v.unshift({x:N.x,y:g.y}):!T&&Math.abs(g.x-N.x)>ce&&v.unshift({x:g.x,y:N.y});let _=v[v.length-1],A=c.y===0,M=[];(Math.abs(_.x-E.x)>ce||Math.abs(_.y-E.y)>ce)&&(A?M.push({x:E.x,y:_.y}):M.push({x:_.x,y:E.y})),M.push(E);let C=[g,...v,...M,x],O=wc(C);if(O.length===2&&Wr(g,x)>ce){let P=ye(g,y,"x",ce)&&ye(y,E,"x",ce)&&ye(E,x,"x",ce),H=ye(g,y,"y",ce)&&ye(y,E,"y",ce)&&ye(E,x,"y",ce);if(P||H){let q=H&&(E.x-y.x)*l.x<0,Q=P&&(E.y-y.y)*l.y<0;if(!q&&!Q)return zr([g,y,E,x])}}return O}var Wr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function eh(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 th(e,t,o,n){if(eh(e,t,o))return`L${t.x} ${t.y}`;let r=Wr(e,t),i=Wr(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},m={x:c/i,y:d/i},p={x:t.x+u.x*s,y:t.y+u.y*s},g={x:t.x+m.x*s,y:t.y+m.y*s},x=-u.x,f=-u.y,h=m.x,y=m.y,v=x*y-f*h>0?1:0;return`L${p.x} ${p.y}A${s} ${s} 0 0 ${v} ${g.x} ${g.y}`}var Ac=(e,t=5)=>e.length<2?"":e.reduce((o,n,r)=>{let i="";return r>0&&r<e.length-1?i=th(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 Xr,useRef as Tn,useState as Vo}from"react";import{useReactFlow as oh,useStore as nh}from"@xyflow/react";var rh=50,Cc=.1,ih=.6,Ur=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:s,getNodes:a,getEdge:l,screenToFlowPosition:c}=oh(),{setIsDragging:d,setReconnectingEdgeId:u}=U(),m=nh(R=>R.isValidConnection),[p,g]=Vo(null),[x,f]=Vo(null),[h,y]=Vo(null),[E,v]=Vo(null),[N,T]=Vo(null),[_,A]=Vo(!1),M=Tn(null),C=Tn(null),O=Tn(null),P=Tn(t),H=Tn(o);Xr(()=>{P.current=t,H.current=o},[t,o]),Xr(()=>{M.current=p},[p]),Xr(()=>{C.current=N},[N]);let q=Oo(R=>{let I=a(),Y=I.find(D=>D.id===R);if(!Y)return{x:0,y:0};let B=Y.position.x,L=Y.position.y,k=Y.parentId;for(;k;){let D=I.find(F=>F.id===k);if(!D)break;B+=D.position.x,L+=D.position.y,k=D.parentId}return{x:B,y:L}},[a]),Q=Oo(R=>{var k,D,F,Z,X,J;let I=a(),Y=null,B=rh,L=I.filter(ee=>ee.type!=="LANE"&&ee.type!=="ANNOTATION");for(let ee of L){if(ee.id===e)continue;let ie=q(ee.id),W=(F=(D=(k=ee.measured)==null?void 0:k.width)!=null?D:ee.width)!=null?F:0,oe=(J=(X=(Z=ee.measured)==null?void 0:Z.height)!=null?X:ee.height)!=null?J:0;if(R.x>=ie.x&&R.x<=ie.x+W&&R.y>=ie.y&&R.y<=ie.y+oe)return ee.id;let $=Math.max(ie.x-R.x,0,R.x-(ie.x+W)),xe=Math.max(ie.y-R.y,0,R.y-(ie.y+oe)),me=Math.sqrt($*$+xe*xe);me<B&&(B=me,Y=ee.id)}return Y},[a,q,e]),te=Oo((R,I)=>{var $,xe,me,be,K,de;let Y=s(R);if(!Y)return null;let B=q(R),L=(me=(xe=($=Y.measured)==null?void 0:$.width)!=null?xe:Y.width)!=null?me:0,k=(de=(K=(be=Y.measured)==null?void 0:be.height)!=null?K:Y.height)!=null?de:0,D=Math.abs(B.x+L-I.x),F=Math.abs(I.x-B.x),Z=Math.abs(B.y+k-I.y),X=Math.abs(I.y-B.y),J={right:D,left:F,bottom:Z,top:X},ee=Object.entries(J).reduce((re,[j,ge])=>ge<re[1]?[j,ge]:re,["right",J.right])[0],ie=O.current;if(ie&&ie!==ee){let re=J[ee],j=J[ie],ge=Math.abs(j-re),_e=Math.min(Math.abs(j),Math.abs(re));ge<_e*ih&&(ee=ie)}let W=ee,oe,le;if(W==="right"||W==="left"){let j=(Math.max(B.y,Math.min(B.y+k,I.y))-B.y)/(k||1);Math.abs(j-.5)<Cc&&(j=.5),le=j,oe={x:W==="right"?B.x+L:B.x,y:B.y+le*k}}else{let j=(Math.max(B.x,Math.min(B.x+L,I.x))-B.x)/(L||1);Math.abs(j-.5)<Cc&&(j=.5),le=j,oe={x:B.x+le*L,y:W==="bottom"?B.y+k:B.y}}return{side:W,snapPosition:oe,offset:le}},[s,q]),z=Oo(R=>{var F,Z,X;let I=M.current;if(!I)return;let Y=c({x:R.clientX,y:R.clientY}),B=Q(Y);y(B);let L=Y,k=null,D=null;if(B){let J=te(B,Y);J&&(k=J.side,L=J.snapPosition,D=J.offset,O.current=k);let ee=l(e),ie={source:I==="source"?B:P.current,target:I==="target"?B:H.current,sourceHandle:I==="source"?k:(F=ee==null?void 0:ee.sourceHandle)!=null?F:null,targetHandle:I==="target"?k:(Z=ee==null?void 0:ee.targetHandle)!=null?Z:null},W=(X=m==null?void 0:m(ie))!=null?X:!0;A(W)}else O.current=null,A(!1);v(k),T(D),f(L)},[Q,te,l,e,c,m]),S=Oo(R=>{var k,D,F,Z,X;let I=M.current;if(!I)return;let Y=c({x:R.clientX,y:R.clientY}),B=Q(Y);if(B){let J=te(B,Y),ee=(k=J==null?void 0:J.side)!=null?k:null,ie=(D=J==null?void 0:J.offset)!=null?D:.5,W=l(e),oe={source:I==="source"?B:P.current,target:I==="target"?B:H.current,sourceHandle:I==="source"?ee:(F=W==null?void 0:W.sourceHandle)!=null?F:null,targetHandle:I==="target"?ee:(Z=W==null?void 0:W.targetHandle)!=null?Z:null};((X=m==null?void 0:m(oe))==null||X)&&i(le=>le.map($=>{var xe,me;return $.id===e?w(b({},$),{source:oe.source,target:oe.target,sourceHandle:oe.sourceHandle,targetHandle:oe.targetHandle,data:w(b({},$.data),{points:void 0,sourceOffset:I==="source"?ie:(xe=$.data)==null?void 0:xe.sourceOffset,targetOffset:I==="target"?ie:(me=$.data)==null?void 0:me.targetOffset})}):$}))}g(null),f(null),y(null),v(null),T(null),d(!1),A(!1),u(null),O.current=null,document.removeEventListener("mouseup",S),document.removeEventListener("mousemove",z);let L=Et.get(n);L==null||L.clearReconnectingEdge()},[e,Q,te,l,i,n,z,m,c,d,u]),V=Oo((R,I)=>{if(r||I.button!==0)return;I.stopPropagation(),I.preventDefault(),i(B=>B.map(L=>L.id===e?w(b({},L),{data:w(b({},L.data),{points:void 0})}):L)),g(R),u(e);let Y=Et.get(n);Y==null||Y.setReconnectingEdge(e),document.addEventListener("mousemove",z),document.addEventListener("mouseup",S)},[r,e,n,z,S,u,i]);return Xr(()=>()=>{if(M.current){document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",S),u(null);let R=Et.get(n);R==null||R.clearReconnectingEdge()}},[n,z,S,u]),{reconnectingHandle:p,cursorPosition:x,hoveredNodeId:h,reconnectingSide:E,reconnectingOffset:N,isValidReconnection:_,handleReconnectStart:V}};import{Fragment as kc,jsx as Se,jsxs as Xt}from"react/jsx-runtime";var rt={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:Pc.ArrowClosed},markerEnd:{type:Pc.Arrow},data:{label:""}},{MOVE_THRESHOLD:$r,MIN_SEGMENT_LENGTH:fh,PARALLEL_OFFSET:Rc,MAX_LABEL_DISTANCE:mh}=Ft;function gh(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(p=>p.source===t);if(d.length<=1)return 0;let u=d.findIndex(p=>p.id===e);if(u<=0)return 0;let m=(d.length-1)/2;return(u-m)*Rc}let l=a.findIndex(d=>d.id===e),c=(a.length-1)/2;return(l-c)*Rc}var Dc=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:s,sourceHandleId:a,targetHandleId:l})=>{var J,ee,ie,W,oe,le,$,xe,me,be;let{zoom:c}=dh(),{updateEdgeData:d}=ch(),u=uh(),m=ph(),{isMultipleSelection:p,isReadOnly:g,mode:x,instanceId:f,edgeHighlight:h}=U(),[y,E]=Sc(!1),[v,N]=Sc(null),T=as(null),_=as(n==null?void 0:n.labelOffset),A=as(null),M=x!=="edit",{reconnectingHandle:C,cursorPosition:O,hoveredNodeId:P,reconnectingSide:H,isValidReconnection:q,handleReconnectStart:Q}=Ur({edgeId:e,source:t,target:o,instanceId:f,isReadOnly:M}),te=Lc(t),z=Lc(o),{sx:S,sy:V,tx:R,ty:I,sourcePos:Y,targetPos:B}=ss(()=>{var pt,ft;let K=te&&z?Io(te,z):{sx:0,sy:0,tx:0,ty:0,sourcePos:Ho.Right,targetPos:Ho.Left},de=a?i:K.sourcePos,re=l?s:K.targetPos,j=($e,he,fe)=>{var Be,mt,kt,Tt,Nt,Os;let{x:pe,y:Ne}=$e.internals.positionAbsolute,Ke=(kt=(mt=(Be=$e.measured)==null?void 0:Be.width)!=null?mt:$e.width)!=null?kt:0,et=(Os=(Nt=(Tt=$e.measured)==null?void 0:Tt.height)!=null?Nt:$e.height)!=null?Os:0;switch(he){case Ho.Top:return{x:pe+Ke*fe,y:Ne};case Ho.Bottom:return{x:pe+Ke*fe,y:Ne+et};case Ho.Left:return{x:pe,y:Ne+et*fe};case Ho.Right:return{x:pe+Ke,y:Ne+et*fe};default:return{x:pe+Ke/2,y:Ne+et/2}}},ge=(pt=n==null?void 0:n.sourceOffset)!=null?pt:.5,_e=(ft=n==null?void 0:n.targetOffset)!=null?ft:.5,Te=te?j(te,de,ge).x:K.sx,Re=te?j(te,de,ge).y:K.sy,je=z?j(z,re,_e).x:K.tx,_t=z?j(z,re,_e).y:K.ty;return C==="source"&&O?(Te=O.x,Re=O.y,H&&(de=H)):C==="target"&&O&&(je=O.x,_t=O.y,H&&(re=H)),{sx:Te,sy:Re,tx:je,ty:_t,sourcePos:de,targetPos:re}},[te,z,a,l,i,s,C,O,H,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);sh(()=>{var re;if(!A.current){A.current={sx:S,sy:V,tx:R,ty:I,sourcePos:Y,targetPos:B};return}let K=A.current;if(Math.abs(S-K.sx)>$r||Math.abs(V-K.sy)>$r||Math.abs(R-K.tx)>$r||Math.abs(I-K.ty)>$r||K.sourcePos!==Y||K.targetPos!==B){let j={};(re=n==null?void 0:n.points)!=null&&re.length&&(j.points=void 0),n!=null&&n.labelOffset&&(j.labelOffset=void 0),Object.keys(j).length>0&&d(e,b(b({},n),j))}A.current={sx:S,sy:V,tx:R,ty:I,sourcePos:Y,targetPos:B}},[S,V,R,I,Y,B,n,e,d,C]);let L=ss(()=>{let K=gh(e,t,o,u,m);return Fr(S,V,R,I,Y,B,n==null?void 0:n.points,K)},[S,V,R,I,Y,B,n==null?void 0:n.points,u,m,e,t,o]),k=ss(()=>{if(L.length<2)return Gr({x:S,y:V},{x:R,y:I});let K=0;for(let j=0;j<L.length-1;j++)K+=Do(L[j],L[j+1]);let de=K/2,re=0;for(let j=0;j<L.length-1;j++){let ge=Do(L[j],L[j+1]);if(re+ge>=de){let _e=(de-re)/ge,Te=L[j],Re=L[j+1];return{x:Te.x+(Re.x-Te.x)*_e,y:Te.y+(Re.y-Te.y)*_e}}re+=ge}return Gr({x:S,y:V},{x:R,y:I})},[L,S,V,R,I]),D=Mc((K,de)=>{if(x!=="edit"||de.button!==0)return;de.stopPropagation(),de.preventDefault();let re=L[K],j=L[K+1],ge=ye(re,j,"y"),_e=ge?re.y:re.x,Te=[...L],Re=Te.length,je=K,_t=K+1;N(K);let pt=$e=>{let he=_e+(ge?$e.clientY-de.clientY:$e.clientX-de.clientX)/c;T.current=ge?{x:(re.x+j.x)/2,y:he}:{x:he,y:(re.y+j.y)/2};let fe=[];for(let pe=1;pe<Re-1;pe++){let Ne=Te[pe];pe===je||pe===_t?ge?fe.push({x:Ne.x,y:he}):fe.push({x:he,y:Ne.y}):fe.push(b({},Ne))}d(e,w(b({},n),{points:fe}))},ft=()=>{N(null),T.current=null,document.removeEventListener("mousemove",pt),document.removeEventListener("mouseup",ft)};document.addEventListener("mousemove",pt),document.addEventListener("mouseup",ft)},[x,L,c,n,e,d]),F=Mc(K=>{var pt,ft,$e,he,fe;if(y||M||K.button!==0||!((pt=n==null?void 0:n.label)!=null&&pt.trim()))return;K.stopPropagation(),K.preventDefault();let de=K.clientX,re=K.clientY,j=($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,_e=[...L],Te={x:k.x,y:k.y},Re=!1,je=pe=>{let Ne=(pe.clientX-de)/c,Ke=(pe.clientY-re)/c;if(!Re&&Math.abs(Ne)<3&&Math.abs(Ke)<3)return;Re=!0;let et={x:j+Ne,y:ge+Ke};_.current=et,d(e,w(b({},n),{labelOffset:et}))},_t=()=>{document.removeEventListener("mousemove",je),document.removeEventListener("mouseup",_t);let pe=_.current;if(!pe)return;let Ne={x:Te.x+pe.x,y:Te.y+pe.y};Nc(Ne,_e)>mh&&(_.current=void 0,d(e,w(b({},n),{labelOffset:void 0})))};document.addEventListener("mousemove",je),document.addEventListener("mouseup",_t)},[y,M,c,n,e,d,L,k]);if(!te||!z)return null;let Z=Ac(L),X=h&&(r||te.selected||z.selected);return Xt(kc,{children:[Xt("g",{className:G("group bpmn-arrow-edge",{"is-highlighted":X}),onDoubleClick:()=>!M&&E(!0),children:[Se("path",{d:Z,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),className:G({"nopan nodrag":!y&&!M&&!!((J=n==null?void 0:n.label)!=null&&J.trim())}),style:{pointerEvents:"stroke",cursor:!y&&!M&&((ee=n==null?void 0:n.label)!=null&&ee.trim())?"move":"pointer"},onMouseDown:F}),Xt("g",{className:G("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!g,"text-blue-500 group-hover:text-blue-600":X}),children:[Se(ah,{id:e,path:Z,interactionWidth:0,markerEnd:`url(#${X?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:G("stroke-2 stroke-current transition-[stroke,filter] duration-75",{"group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]":!g,"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||C&&P&&!q,"stroke-green-500":C&&P&&q,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":X&&!(n!=null&&n.hasError)&&!C})}),r&&!p&&!M&&Se("g",{children:L.slice(0,-1).map((K,de)=>{let re=L[de+1];if(de===0||de===L.length-2||Do(K,re)<fh)return null;let j=ye(K,re,"y"),ge=v===de,_e=ge&&T.current?T.current:Gr(K,re);return Xt("g",{children:[Se("line",{x1:K.x,y1:K.y,x2:re.x,y2:re.y,stroke:"transparent",strokeWidth:20/c,className:G("cursor-pointer",{"cursor-ns-resize":j,"cursor-ew-resize":!j}),onMouseDown:Te=>D(de,Te)}),Se("circle",{cx:_e.x,cy:_e.y,r:4/c,fill:ge?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Se("circle",{cx:_e.x,cy:_e.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:ge?.6:.3,className:"pointer-events-none"})]},de)})})]})]}),Xt(lh,{children:[Se("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${k.x}px, ${k.y}px)`},children:r&&!p&&Se(Ro,{sx:S,sy:V,tx:R,ty:I,hasLabel:!!((ie=n==null?void 0:n.label)!=null&&ie.trim()),children:Se(Lo,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:te,targetNode:z})})}),(y||((W=n==null?void 0:n.label)==null?void 0:W.trim()))&&Se("div",{className:G("absolute nodrag nopan",!y&&!M&&((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(${k.x+(($=(le=n==null?void 0:n.labelOffset)==null?void 0:le.x)!=null?$:0)}px, ${k.y+((me=(xe=n==null?void 0:n.labelOffset)==null?void 0:xe.y)!=null?me:0)}px)`,cursor:!y&&!M&&((be=n==null?void 0:n.label)!=null&&be.trim())?"move":void 0},onMouseDown:!y&&!M?F:void 0,onDoubleClick:K=>{M||(K.stopPropagation(),E(!0))},children:Se(De,{value:n==null?void 0:n.label,className:G("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":y,"pointer-events-none":!y}),isEditing:y,onBlur:()=>E(!1),onChange:K=>d(e,{label:K.trim()})})}),r&&!p&&!M&&Xt(kc,{children:[Se("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${L[0].x}px, ${L[0].y}px)`},children:Xt("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Se("circle",{cx:6/c,cy:6/c,r:4/c,fill:C==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Se("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:C==="source"?.6:.3,className:"pointer-events-none"}),Se("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:G("pointer-events-auto",{"cursor-move":!C||C!=="source","cursor-not-allowed":C==="source"&&P&&!q,"cursor-grabbing":C==="source"&&(!P||q)}),onMouseDown:K=>Q("source",K.nativeEvent)})]})}),Se("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${L[L.length-1].x}px, ${L[L.length-1].y}px)`},children:Xt("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Se("circle",{cx:6/c,cy:6/c,r:4/c,fill:C==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Se("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:C==="target"?.6:.3,className:"pointer-events-none"}),Se("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:G("pointer-events-auto",{"cursor-move":!C||C!=="target","cursor-not-allowed":C==="target"&&P&&!q,"cursor-grabbing":C==="target"&&(!P||q)}),onMouseDown:K=>Q("target",K.nativeEvent)})]})})]})]})]})};import{Position as Ct}from"@xyflow/react";var hh={right:Ct.Right,left:Ct.Left,top:Ct.Top,bottom:Ct.Bottom},Kr=e=>{var t;return(t=hh[e!=null?e:""])!=null?t:Ct.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(Kr(t)){case Ct.Right:return{x:n+i,y:r+s*o};case Ct.Left:return{x:n,y:r+s*o};case Ct.Top:return{x:n+i*o,y:r};case Ct.Bottom:return{x:n+i*o,y:r+s};default:return{x:n+i/2,y:r+s/2}}},Oc=(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((m,p)=>{let g=Math.hypot(t-m.x,o-m.y);return Math.hypot(t-p.x,o-p.y)<g?p:m}).id};import{useDebouncedCallback as d0}from"use-debounce";import{getViewportForBounds as a0,useReactFlow as l0,useStoreApi as c0}from"@xyflow/react";import{useCallback as qd}from"react";var Nn=(d=>(d.START_EVENT="start-event",d.END_EVENT_TERMINATE="end-event-terminate",d.TASK="task",d.TASK_SCRIPT="task-script",d.SUBPROCESS="subprocess-collapsed",d.GATEWAY_EXCLUSIVE="gateway-exclusive",d.GATEWAY_PARALLEL="gateway-parallel",d.GATEWAY_COMPLEX="gateway-complex",d.ANNOTATION="annotation",d.LANE="lane",d))(Nn||{});import{xml2json as yh,json2xml as xh}from"xml-js";var Vc={compact:!0,spaces:4},Eh=e=>e.replace(/\n/g,"
");function qr(e,t=Vc){if(e)return JSON.parse(yh(e,t))}function Hc(e,t=Vc){return e?xh(e,w(b({},t),{attributeValueFn:Eh})):""}var Gc={"attribute-loop":"LOOP"},Bc={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS"},zc={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Yc={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed"},Wc={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var Go=(e,t,o,n,r,i)=>{let s=e._attributes.width||0,a=e._attributes.height||0,l=0,c=0;if(n&&r!==void 0&&i!==void 0){let g=n.split(`
|
|
6
|
-
`),
|
|
5
|
+
`).trim();t&&N.length>t&&(N=N.substring(0,t)),_.currentTarget.innerText=N,a==null||a(),N!==e&&(s==null||s(N))};return _c("div",{className:G("flex-1 p-2 self-stretch flex items-center justify-center border border-transparent overflow-hidden text-ellipsis body-medium-400 text-center rounded-sm",{"border border-dashed border-grey-400 bg-white shadow-md":p,"bg-white":e.length>0},n),style:o,onDoubleClick:f,children:_c("div",{ref:u,className:G("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":p}),contentEditable:p,suppressContentEditableWarning:!0,onKeyDown:g,onPaste:y,onInput:x,onBlur:w,children:e})})};import{Position as YI}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),Gr=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),$g=(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 s=Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*r)/i));return Do(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,$g(e,t[n],t[n+1]));return o};import{Position as Br}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 Kg(e,t,o){return ye(e,t,"x",ce)&&ye(t,o,"x",ce)&&ye(e,o,"x",ce)}function qg(e,t,o){return ye(e,t,"y",ce)&&ye(t,o,"y",ce)&&ye(e,o,"y",ce)}function Zg(e,t,o){if(!Kg(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 Jg(e,t,o){if(!qg(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 Qg(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 Nc(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 zr(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 jg(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(Zg(r,i,s)||Jg(r,i,s)){t.splice(n,1),o=!0;break}}}return t}function vc(e){let t=zr(Nc([...e]));return t=jg(t),zr(Nc(t))}function Yr(e){switch(e){case Br.Left:return{x:-1,y:0};case Br.Right:return{x:1,y:0};case Br.Top:return{x:0,y:-1};case Br.Bottom:return{x:0,y:1};default:return{x:0,y:0}}}function wc(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 s=(o.x-e.x)*t.x;s>0&&s<2*Ft.OFFSET&&(r=s/2,i=s/2)}else{let s=(o.y-e.y)*t.y;s>0&&s<2*Ft.OFFSET&&(r=s/2,i=s/2)}return{sourceOffset:r,targetOffset:i}}function eh(e,t,o,n,r,i,s=0){let a=Yr(r),l=Yr(i),c=a.x===0?s:0,d=a.y===0?s:0,u=l.x===0?s:0,m=l.y===0?s:0,p={x:e+c,y:t+d},h={x:o+u,y:n+m},{sourceOffset:E,targetOffset:f}=wc(p,a,h,l),g={x:p.x+a.x*E,y:p.y+a.y*E},y={x:h.x+l.x*f,y:h.y+l.y*f},x=Qg(g,a,y,l),w=[p,g,...x,y,h],_=vc(w);if(_.length===2&&Wr(p,h)>ce){let N=ye(p,g,"x",ce)&&ye(g,y,"x",ce)&&ye(y,h,"x",ce),T=ye(p,g,"y",ce)&&ye(g,y,"y",ce)&&ye(y,h,"y",ce);if(N||T){let I=T&&(y.x-g.x)*a.x<0,C=N&&(y.y-g.y)*a.y<0;if(!I&&!C)return zr([p,g,y,h])}}return _}function Fr(e,t,o,n,r,i,s,a=0){if(!(s!=null&&s.length))return eh(e,t,o,n,r,i,a);let l=Yr(r),c=Yr(i),d=l.x===0?a:0,u=l.y===0?a:0,m=c.x===0?a:0,p=c.y===0?a:0,h={x:e+d,y:t+u},E={x:o+m,y:n+p},{sourceOffset:f,targetOffset:g}=wc(h,l,E,c),y={x:h.x+l.x*f,y:h.y+l.y*f},x={x:E.x+c.x*g,y:E.y+c.y*g},w=[...s],_=w[0],N=l.y===0;N&&Math.abs(h.y-_.y)>ce?w.unshift({x:_.x,y:h.y}):!N&&Math.abs(h.x-_.x)>ce&&w.unshift({x:h.x,y:_.y});let T=w[w.length-1],I=c.y===0,C=[];(Math.abs(T.x-x.x)>ce||Math.abs(T.y-x.y)>ce)&&(I?C.push({x:x.x,y:T.y}):C.push({x:T.x,y:x.y})),C.push(x);let P=[h,...w,...C,E],R=vc(P);if(R.length===2&&Wr(h,E)>ce){let S=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(S||L){let $=L&&(x.x-y.x)*l.x<0,K=S&&(x.y-y.y)*l.y<0;if(!$&&!K)return zr([h,y,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 th(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 oh(e,t,o,n){if(th(e,t,o))return`L${t.x} ${t.y}`;let r=Wr(e,t),i=Wr(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},m={x:c/i,y:d/i},p={x:t.x+u.x*s,y:t.y+u.y*s},h={x:t.x+m.x*s,y:t.y+m.y*s},E=-u.x,f=-u.y,g=m.x,y=m.y,w=E*y-f*g>0?1:0;return`L${p.x} ${p.y}A${s} ${s} 0 0 ${w} ${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=oh(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 Xr,useRef as Tn,useState as Vo}from"react";import{useReactFlow as nh,useStore as rh}from"@xyflow/react";var ih=50,Ac=.1,sh=.6,Ur=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:s,getNodes:a,getEdge:l,screenToFlowPosition:c}=nh(),{setIsDragging:d,setReconnectingEdgeId:u}=U(),m=rh(D=>D.isValidConnection),[p,h]=Vo(null),[E,f]=Vo(null),[g,y]=Vo(null),[x,w]=Vo(null),[_,N]=Vo(null),[T,I]=Vo(!1),C=Tn(null),P=Tn(null),R=Tn(null),S=Tn(t),L=Tn(o);Xr(()=>{S.current=t,L.current=o},[t,o]),Xr(()=>{C.current=p},[p]),Xr(()=>{P.current=_},[_]);let $=Oo(D=>{let A=a(),Y=A.find(V=>V.id===D);if(!Y)return{x:0,y:0};let B=Y.position.x,k=Y.position.y,O=Y.parentId;for(;O;){let V=A.find(F=>F.id===O);if(!V)break;B+=V.position.x,k+=V.position.y,O=V.parentId}return{x:B,y:k}},[a]),K=Oo(D=>{var O,V,F,J,X,Q;let A=a(),Y=null,B=ih,k=A.filter(ee=>ee.type!=="LANE"&&ee.type!=="ANNOTATION");for(let ee of k){if(ee.id===e)continue;let ie=$(ee.id),W=(F=(V=(O=ee.measured)==null?void 0:O.width)!=null?V:ee.width)!=null?F:0,oe=(Q=(X=(J=ee.measured)==null?void 0:J.height)!=null?X:ee.height)!=null?Q:0;if(D.x>=ie.x&&D.x<=ie.x+W&&D.y>=ie.y&&D.y<=ie.y+oe)return ee.id;let q=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(q*q+xe*xe);me<B&&(B=me,Y=ee.id)}return Y},[a,$,e]),te=Oo((D,A)=>{var q,xe,me,be,Z,de;let Y=s(D);if(!Y)return null;let B=$(D),k=(me=(xe=(q=Y.measured)==null?void 0:q.width)!=null?xe:Y.width)!=null?me:0,O=(de=(Z=(be=Y.measured)==null?void 0:be.height)!=null?Z:Y.height)!=null?de:0,V=Math.abs(B.x+k-A.x),F=Math.abs(A.x-B.x),J=Math.abs(B.y+O-A.y),X=Math.abs(A.y-B.y),Q={right:V,left:F,bottom:J,top:X},ee=Object.entries(Q).reduce((re,[j,ge])=>ge<re[1]?[j,ge]:re,["right",Q.right])[0],ie=R.current;if(ie&&ie!==ee){let re=Q[ee],j=Q[ie],ge=Math.abs(j-re),_e=Math.min(Math.abs(j),Math.abs(re));ge<_e*sh&&(ee=ie)}let W=ee,oe,le;if(W==="right"||W==="left"){let j=(Math.max(B.y,Math.min(B.y+O,A.y))-B.y)/(O||1);Math.abs(j-.5)<Ac&&(j=.5),le=j,oe={x:W==="right"?B.x+k:B.x,y:B.y+le*O}}else{let j=(Math.max(B.x,Math.min(B.x+k,A.x))-B.x)/(k||1);Math.abs(j-.5)<Ac&&(j=.5),le=j,oe={x:B.x+le*k,y:W==="bottom"?B.y+O:B.y}}return{side:W,snapPosition:oe,offset:le}},[s,$]),z=Oo(D=>{var F,J,X;let A=C.current;if(!A)return;let Y=c({x:D.clientX,y:D.clientY}),B=K(Y);y(B);let k=Y,O=null,V=null;if(B){let Q=te(B,Y);Q&&(O=Q.side,k=Q.snapPosition,V=Q.offset,R.current=O);let ee=l(e),ie={source:A==="source"?B:S.current,target:A==="target"?B:L.current,sourceHandle:A==="source"?O:(F=ee==null?void 0:ee.sourceHandle)!=null?F:null,targetHandle:A==="target"?O:(J=ee==null?void 0:ee.targetHandle)!=null?J:null},W=(X=m==null?void 0:m(ie))!=null?X:!0;I(W)}else R.current=null,I(!1);w(O),N(V),f(k)},[K,te,l,e,c,m]),M=Oo(D=>{var O,V,F,J,X;let A=C.current;if(!A)return;let Y=c({x:D.clientX,y:D.clientY}),B=K(Y);if(B){let Q=te(B,Y),ee=(O=Q==null?void 0:Q.side)!=null?O:null,ie=(V=Q==null?void 0:Q.offset)!=null?V:.5,W=l(e),oe={source:A==="source"?B:S.current,target:A==="target"?B:L.current,sourceHandle:A==="source"?ee:(F=W==null?void 0:W.sourceHandle)!=null?F:null,targetHandle:A==="target"?ee:(J=W==null?void 0:W.targetHandle)!=null?J:null};((X=m==null?void 0:m(oe))==null||X)&&i(le=>le.map(q=>{var xe,me;return q.id===e?v(b({},q),{source:oe.source,target:oe.target,sourceHandle:oe.sourceHandle,targetHandle:oe.targetHandle,data:v(b({},q.data),{points:void 0,sourceOffset:A==="source"?ie:(xe=q.data)==null?void 0:xe.sourceOffset,targetOffset:A==="target"?ie:(me=q.data)==null?void 0:me.targetOffset})}):q}))}h(null),f(null),y(null),w(null),N(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,K,te,l,i,n,z,m,c,d,u]),H=Oo((D,A)=>{if(r||A.button!==0)return;A.stopPropagation(),A.preventDefault(),i(B=>B.map(k=>k.id===e?v(b({},k),{data:v(b({},k.data),{points:void 0})}):k)),h(D),u(e);let Y=Et.get(n);Y==null||Y.setReconnectingEdge(e),document.addEventListener("mousemove",z),document.addEventListener("mouseup",M)},[r,e,n,z,M,u,i]);return Xr(()=>()=>{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:p,cursorPosition:E,hoveredNodeId:g,reconnectingSide:x,reconnectingOffset:_,isValidReconnection:T,handleReconnectStart:H}};import{Fragment as Rc,jsx as Se,jsxs as Xt}from"react/jsx-runtime";var rt={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:Mc.ArrowClosed},markerEnd:{type:Mc.Arrow},data:{label:""}},{MOVE_THRESHOLD:$r,MIN_SEGMENT_LENGTH:mh,PARALLEL_OFFSET:Lc,MAX_LABEL_DISTANCE:gh}=Ft;function hh(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(p=>p.source===t);if(d.length<=1)return 0;let u=d.findIndex(p=>p.id===e);if(u<=0)return 0;let m=(d.length-1)/2;return(u-m)*Lc}let l=a.findIndex(d=>d.id===e),c=(a.length-1)/2;return(l-c)*Lc}var kc=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:s,sourceHandleId:a,targetHandleId:l})=>{var Q,ee,ie,W,oe,le,q,xe,me,be;let{zoom:c}=uh(),{updateEdgeData:d}=dh(),u=ph(),m=fh(),{isMultipleSelection:p,isReadOnly:h,mode:E,instanceId:f,edgeHighlight:g}=U(),[y,x]=Cc(!1),[w,_]=Cc(null),N=as(null),T=as(n==null?void 0:n.labelOffset),I=as(null),C=E!=="edit",{reconnectingHandle:P,cursorPosition:R,hoveredNodeId:S,reconnectingSide:L,isValidReconnection:$,handleReconnectStart:K}=Ur({edgeId:e,source:t,target:o,instanceId:f,isReadOnly:C}),te=Pc(t),z=Pc(o),{sx:M,sy:H,tx:D,ty:A,sourcePos:Y,targetPos:B}=ss(()=>{var pt,ft;let Z=te&&z?Io(te,z):{sx:0,sy:0,tx:0,ty:0,sourcePos:Ho.Right,targetPos:Ho.Left},de=a?i:Z.sourcePos,re=l?s:Z.targetPos,j=($e,he,fe)=>{var Be,mt,kt,Tt,Nt,Ds;let{x:pe,y:Ne}=$e.internals.positionAbsolute,Ke=(kt=(mt=(Be=$e.measured)==null?void 0:Be.width)!=null?mt:$e.width)!=null?kt:0,et=(Ds=(Nt=(Tt=$e.measured)==null?void 0:Tt.height)!=null?Nt:$e.height)!=null?Ds:0;switch(he){case Ho.Top:return{x:pe+Ke*fe,y:Ne};case Ho.Bottom:return{x:pe+Ke*fe,y:Ne+et};case Ho.Left:return{x:pe,y:Ne+et*fe};case Ho.Right:return{x:pe+Ke,y:Ne+et*fe};default:return{x:pe+Ke/2,y:Ne+et/2}}},ge=(pt=n==null?void 0:n.sourceOffset)!=null?pt:.5,_e=(ft=n==null?void 0:n.targetOffset)!=null?ft:.5,Te=te?j(te,de,ge).x:Z.sx,Re=te?j(te,de,ge).y:Z.sy,je=z?j(z,re,_e).x:Z.tx,_t=z?j(z,re,_e).y:Z.ty;return P==="source"&&R?(Te=R.x,Re=R.y,L&&(de=L)):P==="target"&&R&&(je=R.x,_t=R.y,L&&(re=L)),{sx:Te,sy:Re,tx:je,ty:_t,sourcePos:de,targetPos:re}},[te,z,a,l,i,s,P,R,L,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);ah(()=>{var re;if(!I.current){I.current={sx:M,sy:H,tx:D,ty:A,sourcePos:Y,targetPos:B};return}let Z=I.current;if(Math.abs(M-Z.sx)>$r||Math.abs(H-Z.sy)>$r||Math.abs(D-Z.tx)>$r||Math.abs(A-Z.ty)>$r||Z.sourcePos!==Y||Z.targetPos!==B){let j={};(re=n==null?void 0:n.points)!=null&&re.length&&(j.points=void 0),n!=null&&n.labelOffset&&(j.labelOffset=void 0),Object.keys(j).length>0&&d(e,b(b({},n),j))}I.current={sx:M,sy:H,tx:D,ty:A,sourcePos:Y,targetPos:B}},[M,H,D,A,Y,B,n,e,d,P]);let k=ss(()=>{let Z=hh(e,t,o,u,m);return Fr(M,H,D,A,Y,B,n==null?void 0:n.points,Z)},[M,H,D,A,Y,B,n==null?void 0:n.points,u,m,e,t,o]),O=ss(()=>{if(k.length<2)return Gr({x:M,y:H},{x:D,y:A});let Z=0;for(let j=0;j<k.length-1;j++)Z+=Do(k[j],k[j+1]);let de=Z/2,re=0;for(let j=0;j<k.length-1;j++){let ge=Do(k[j],k[j+1]);if(re+ge>=de){let _e=(de-re)/ge,Te=k[j],Re=k[j+1];return{x:Te.x+(Re.x-Te.x)*_e,y:Te.y+(Re.y-Te.y)*_e}}re+=ge}return Gr({x:M,y:H},{x:D,y:A})},[k,M,H,D,A]),V=Sc((Z,de)=>{if(E!=="edit"||de.button!==0)return;de.stopPropagation(),de.preventDefault();let re=k[Z],j=k[Z+1],ge=ye(re,j,"y"),_e=ge?re.y:re.x,Te=[...k],Re=Te.length,je=Z,_t=Z+1;_(Z);let pt=$e=>{let he=_e+(ge?$e.clientY-de.clientY:$e.clientX-de.clientX)/c;N.current=ge?{x:(re.x+j.x)/2,y:he}:{x:he,y:(re.y+j.y)/2};let fe=[];for(let pe=1;pe<Re-1;pe++){let Ne=Te[pe];pe===je||pe===_t?ge?fe.push({x:Ne.x,y:he}):fe.push({x:he,y:Ne.y}):fe.push(b({},Ne))}d(e,v(b({},n),{points:fe}))},ft=()=>{_(null),N.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=Sc(Z=>{var pt,ft,$e,he,fe;if(y||C||Z.button!==0||!((pt=n==null?void 0:n.label)!=null&&pt.trim()))return;Z.stopPropagation(),Z.preventDefault();let de=Z.clientX,re=Z.clientY,j=($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,_e=[...k],Te={x:O.x,y:O.y},Re=!1,je=pe=>{let Ne=(pe.clientX-de)/c,Ke=(pe.clientY-re)/c;if(!Re&&Math.abs(Ne)<3&&Math.abs(Ke)<3)return;Re=!0;let et={x:j+Ne,y:ge+Ke};T.current=et,d(e,v(b({},n),{labelOffset:et}))},_t=()=>{document.removeEventListener("mousemove",je),document.removeEventListener("mouseup",_t);let pe=T.current;if(!pe)return;let Ne={x:Te.x+pe.x,y:Te.y+pe.y};Tc(Ne,_e)>gh&&(T.current=void 0,d(e,v(b({},n),{labelOffset:void 0})))};document.addEventListener("mousemove",je),document.addEventListener("mouseup",_t)},[y,C,c,n,e,d,k,O]);if(!te||!z)return null;let J=Ic(k),X=g&&(r||te.selected||z.selected);return Xt(Rc,{children:[Xt("g",{className:G("group bpmn-arrow-edge",{"is-highlighted":X}),onDoubleClick:()=>!C&&x(!0),children:[Se("path",{d:J,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),className:G({"nopan nodrag":!y&&!C&&!!((Q=n==null?void 0:n.label)!=null&&Q.trim())}),style:{pointerEvents:"stroke",cursor:!y&&!C&&((ee=n==null?void 0:n.label)!=null&&ee.trim())?"move":"pointer"},onMouseDown:F}),Xt("g",{className:G("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!h,"text-blue-500 group-hover:text-blue-600":X}),children:[Se(lh,{id:e,path:J,interactionWidth:0,markerEnd:`url(#${X?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:G("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&&S&&!$,"stroke-green-500":P&&S&&$,"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&&!p&&!C&&Se("g",{children:k.slice(0,-1).map((Z,de)=>{let re=k[de+1];if(de===0||de===k.length-2||Do(Z,re)<mh)return null;let j=ye(Z,re,"y"),ge=w===de,_e=ge&&N.current?N.current:Gr(Z,re);return Xt("g",{children:[Se("line",{x1:Z.x,y1:Z.y,x2:re.x,y2:re.y,stroke:"transparent",strokeWidth:20/c,className:G("cursor-pointer",{"cursor-ns-resize":j,"cursor-ew-resize":!j}),onMouseDown:Te=>V(de,Te)}),Se("circle",{cx:_e.x,cy:_e.y,r:4/c,fill:ge?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Se("circle",{cx:_e.x,cy:_e.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:ge?.6:.3,className:"pointer-events-none"})]},de)})})]})]}),Xt(ch,{children:[Se("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&&!p&&Se(Ro,{sx:M,sy:H,tx:D,ty:A,hasLabel:!!((ie=n==null?void 0:n.label)!=null&&ie.trim()),children:Se(Lo,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:te,targetNode:z})})}),(y||((W=n==null?void 0:n.label)==null?void 0:W.trim()))&&Se("div",{className:G("absolute nodrag nopan",!y&&!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+((q=(le=n==null?void 0:n.labelOffset)==null?void 0:le.x)!=null?q:0)}px, ${O.y+((me=(xe=n==null?void 0:n.labelOffset)==null?void 0:xe.y)!=null?me:0)}px)`,cursor:!y&&!C&&((be=n==null?void 0:n.label)!=null&&be.trim())?"move":void 0},onMouseDown:!y&&!C?F:void 0,onDoubleClick:Z=>{C||(Z.stopPropagation(),x(!0))},children:Se(De,{value:n==null?void 0:n.label,className:G("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":y,"pointer-events-none":!y}),isEditing:y,onBlur:()=>x(!1),onChange:Z=>d(e,{label:Z.trim()})})}),r&&!p&&!C&&Xt(Rc,{children:[Se("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${k[0].x}px, ${k[0].y}px)`},children:Xt("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Se("circle",{cx:6/c,cy:6/c,r:4/c,fill:P==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Se("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"}),Se("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:G("pointer-events-auto",{"cursor-move":!P||P!=="source","cursor-not-allowed":P==="source"&&S&&!$,"cursor-grabbing":P==="source"&&(!S||$)}),onMouseDown:Z=>K("source",Z.nativeEvent)})]})}),Se("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${k[k.length-1].x}px, ${k[k.length-1].y}px)`},children:Xt("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Se("circle",{cx:6/c,cy:6/c,r:4/c,fill:P==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Se("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"}),Se("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:G("pointer-events-auto",{"cursor-move":!P||P!=="target","cursor-not-allowed":P==="target"&&S&&!$,"cursor-grabbing":P==="target"&&(!S||$)}),onMouseDown:Z=>K("target",Z.nativeEvent)})]})})]})]})]})};import{Position as Ct}from"@xyflow/react";var yh={right:Ct.Right,left:Ct.Left,top:Ct.Top,bottom:Ct.Bottom},Kr=e=>{var t;return(t=yh[e!=null?e:""])!=null?t:Ct.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(Kr(t)){case Ct.Right:return{x:n+i,y:r+s*o};case Ct.Left:return{x:n,y:r+s*o};case Ct.Top:return{x:n+i*o,y:r};case Ct.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((m,p)=>{let h=Math.hypot(t-m.x,o-m.y);return Math.hypot(t-p.x,o-p.y)<h?p:m}).id};import{useDebouncedCallback as u0}from"use-debounce";import{getViewportForBounds as l0,useReactFlow as c0,useStoreApi as d0}from"@xyflow/react";import{useCallback as Kd}from"react";var Nn=(d=>(d.START_EVENT="start-event",d.END_EVENT_TERMINATE="end-event-terminate",d.TASK="task",d.TASK_SCRIPT="task-script",d.SUBPROCESS="subprocess-collapsed",d.GATEWAY_EXCLUSIVE="gateway-exclusive",d.GATEWAY_PARALLEL="gateway-parallel",d.GATEWAY_COMPLEX="gateway-complex",d.ANNOTATION="annotation",d.LANE="lane",d))(Nn||{});import{xml2json as xh,json2xml as Eh}from"xml-js";var Oc={compact:!0,spaces:4},bh=e=>e.replace(/\n/g,"
");function qr(e,t=Oc){if(e)return JSON.parse(xh(e,t))}function Vc(e,t=Oc){return e?Eh(e,v(b({},t),{attributeValueFn:bh})):""}var Hc={"attribute-loop":"LOOP"},Gc={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS"},Bc={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},zc={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed"},Yc={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var Go=(e,t,o,n,r,i)=>{let s=e._attributes.width||0,a=e._attributes.height||0,l=0,c=0;if(n&&r!==void 0&&i!==void 0){let h=n.split(`
|
|
6
|
+
`),E=h.length;l=h.reduce((g,y)=>Math.max(g,y.length),0)*7+r,c=E*20+i}let d=Math.max(Dt(Number(s),t),l),u=Math.max(Dt(Number(a),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,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},Th=e=>{let{mxGeometry:t}=e,o=Bo(e),n=Go(t,ue.START_EVENT.MIN_WIDTH,ue.START_EVENT.MIN_HEIGHT);return v(b(b({},o),n),{type:"START_EVENT"})},Nh=e=>{let{mxGeometry:t}=e,o=Bo(e),n=Go(t,ue.END_EVENT.MIN_WIDTH,ue.END_EVENT.MIN_HEIGHT);return v(b(b({},o),n),{type:"END_EVENT"})},cs=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=Bo(e),a=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=Hc[d];u&&(r.data.attribute=u)}let c=Gc[o.style];return c&&(r.data.variant=c),v(b(b({},r),a),{type:"TASK"})},ds=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=Bc[n],v(b(b({},r),i),{type:"GATEWAY"})},vh=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 v(b(b({},o),i),{type:"ANNOTATION"})},wh=e=>{let{mxGeometry:t}=e,o=Bo(e),n=Go(t,ue.LANE.MIN_WIDTH,ue.LANE.MIN_HEIGHT);return v(b(b({},o),n),{type:"LANE"})},Wc={task:cs,"task-script":cs,"subprocess-collapsed":cs,"start-event":Th,"end-event-terminate":Nh,"gateway-parallel":ds,"gateway-exclusive":ds,"gateway-complex":ds,annotation:vh,lane:wh},Ih=e=>{if(e&&Array.isArray(e))return e.map(t=>({x:Number(t._attributes.x),y:Number(t._attributes.y)}))},Fc=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:m,labelOffsetY:p}=t,h=Ih(o==null?void 0:o.Array),E=d!==void 0?Number(d):void 0,f=u!==void 0?Number(u):void 0,g=m!==void 0?Number(m):void 0,y=p!==void 0?Number(p):void 0,x=v(b(b({id:n,source:r,target:i},l?{sourceHandle:l}:{}),c?{targetHandle:c}:{}),{data:b(b(b(b({label:s||""},h&&h.length>0?{points:h}:{}),E!==void 0?{sourceOffset:E}:{}),f!==void 0?{targetOffset:f}:{}),g!==void 0&&y!==void 0?{labelOffset:{x:g,y}}:{})});return a.includes("association")&&a.includes('endArrow=""')?b(b({},ko),x):b(b({},rt),x)},Xc=(e,t)=>{var p,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:((p=l==null?void 0:l.labelOffset)==null?void 0:p.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}},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}}}},Ah=e=>{let{variant:t}=e.data,o=zo(e);return v(b({},o),{_attributes:v(b({},o._attributes),{style:zc[t]||"task"})})},Ch=e=>{let t=zo(e);return v(b({},t),{_attributes:v(b({},t._attributes),{style:"start-event"})})},Sh=e=>{let t=zo(e);return v(b({},t),{_attributes:v(b({},t._attributes),{style:"end-event-terminate"})})},Mh=e=>{let{variant:t}=e.data,o=zo(e);return v(b({},o),{_attributes:v(b({},o._attributes),{style:Yc[t]})})},Ph=e=>{let t=zo(e);return v(b({},t),{_attributes:v(b({},t._attributes),{style:"lane"})})},Lh=e=>{let t=zo(e);return v(b({},t),{_attributes:v(b({},t._attributes),{style:"annotation"})})},Uc={TASK:Ah,START_EVENT:Ch,END_EVENT:Sh,GATEWAY:Mh,ANNOTATION:Lh,LANE:Ph},$c=(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}}}};import Kc from"@dagrejs/dagre";import{getNodesBounds as Zr}from"@xyflow/react";var Zc=(e=[],t=[],o="LR")=>{let n=new Kc.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)),Kc.layout(n),{nodes:e.map(i=>{let s=n.node(i.id);return v(b({},i),{position:{x:s.x-i.width/2,y:s.y-i.height/2}})}),edges:t}},St=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)},Jc=St,Qc=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)};var Rh=500;var kh=e=>e.type==="LANE"&&!e.parentId,Dh=(e,t)=>{let o=e.x+e.width,n=e.y+e.height,r=t.x+t.width,i=t.y+t.height;return e.x<=t.x&&e.y<=t.y&&o>=r&&n>=i},Oh=(e,t)=>{let o=e.x+e.width,n=e.y+e.height,r=t.x+t.width,i=t.y+t.height,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)},Vh=e=>{let t=new Set;for(let o of e)t.add(o.source),t.add(o.target);return t},qc=(e,t,o)=>{if(e.type!=="ANNOTATION"||o.has(e.id))return!1;let n=Zr([e]);return Oh(t,n)>Rh},us=(e,t=[])=>{var E;let o=e.filter(kh);if(o.length===0)return e;let n=new Map;for(let f of e){if(!f.parentId)continue;let g=(E=n.get(f.parentId))!=null?E:[];g.push(f.id),n.set(f.parentId,g)}let r=new Set,i=o.map(f=>f.id);for(;i.length>0;){let f=i.pop();if(!f||r.has(f))continue;r.add(f);let g=n.get(f);if(g)for(let y of g)r.has(y)||i.push(y)}let s=e.filter(f=>r.has(f.id));if(s.length===0)return e;let a=Vh(t),l=s.filter(f=>f.type!=="ANNOTATION"),c=Zr(l.length>0?l:s),d=s.filter(f=>!qc(f,c,a)),u=Zr(d),h=e.filter(f=>!r.has(f.id)).filter(f=>{let g=Zr([f]);return!Dh(u,g)}).filter(f=>!qc(f,u,a));return[...d,...h]};var vn=1,jc=e=>`<mxGraphModel>
|
|
7
7
|
<root version="1.1">
|
|
8
8
|
<mxCell id="0" />
|
|
9
9
|
<mxCell id="1" parent="0" />
|
|
@@ -36,11 +36,11 @@ var cp=Object.defineProperty,dp=Object.defineProperties;var up=Object.getOwnProp
|
|
|
36
36
|
<mxGeometry as="geometry" relative="1" />
|
|
37
37
|
</mxCell>
|
|
38
38
|
</root>
|
|
39
|
-
</mxGraphModel>`,td=(e,t)=>{if(!e.length&&!t.length)return vn;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var Vh=e=>{let t=Object.values(Nn),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=Fc[s],l=a==null?void 0:a(i,n);if(!l){console.warn(`Node ${s} not supported`);continue}r.push(l)}return r},Hh=(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=Xc(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},Gh=(e,t)=>{let o=[];return e.forEach(n=>{var s,a;let r=(a=(s=$c)[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=Kc(n,t);o.push(l)}}),o},Bh=(e,t)=>{let o=[];return e.forEach(n=>{let r=Uc(n,t);o.push(r)}),o},zh=(e=[],t=[],o)=>{let n=Gh(e,o),r=Bh(t,e);return{mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}}},od=(e=[],t=[],o)=>{let n=zh(e,t,o);return Hc(JSON.stringify(n),{compact:!0,spaces:0})},nd=async e=>{var c,d,u,m,p;let t=await qr(e),o=((d=(c=t==null?void 0:t.mxGraphModel)==null?void 0:c.root)==null?void 0:d.mxCell)||[],n=Number(((p=(m=(u=t==null?void 0:t.mxGraphModel)==null?void 0:u.root)==null?void 0:m._attributes)==null?void 0:p.lastId)||vn),r=Vh(o),i=Hh(o,r),s=Qc(r),{nodes:a,edges:l}=la(s,i);return{lastElementId:n,edges:l,nodes:eo(a)}};import{Position as Ut,useConnection as vy,useReactFlow as wy}from"@xyflow/react";import{useCallback as hs}from"react";import{Handle as rd,useReactFlow as Yh}from"@xyflow/react";import{jsx as id}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 id(rd,b({type:e,position:t,className:G("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":a,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":!a},o)},r))},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}=Yh(),m=(()=>{if(n!=="source")return!1;let p=c();if(t==="TASK")return p.filter(x=>x.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return p.filter(x=>x.source===e).length>=2;if(t==="START_EVENT"){let g=d();return p.filter(f=>{if(f.source!==e)return!1;let h=g.find(y=>y.id===f.target);return(h==null?void 0:h.type)!=="ANNOTATION"}).length>=1}return!1})();return id(rd,b({type:n,position:r,className:G("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":m,"hover:border-grey-500":!m},i),style:{pointerEvents:m?"none":"auto"}},s))};import{useRef as sd}from"react";import{NodeResizeControl as ad,ResizeControlVariant as Fh,useReactFlow as Xh,useStoreApi as Uh}from"@xyflow/react";import{useStoreApi as Wh}from"@xyflow/react";var Jr=()=>{let e=Wh();return{getInternalNodes:()=>{let{nodeLookup:o}=e.getState();return Array.from(o.values())}}};import{Fragment as qh,jsxs as Zh}from"react/jsx-runtime";import{createElement as ld}from"react";var $h=["top","right","bottom","left"],Kh=["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}=Xh(),{getInternalNodes:l}=Jr(),{isMultipleSelection:c}=U(),d=Uh(),u=sd(0),m=sd([]),p=({y:h,width:y,height:E})=>{cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{var Q,te;if(!e)return;let{nodeLookup:v,onNodesChange:N}=d.getState(),T=v.get(e);if(!T||T.type!=="LANE")return;let _=!T.parentId,A=_?T.id:T.parentId;if(!A)return;let M=Array.from(v.values()).filter(z=>z.type==="LANE"&&z.parentId===A);if(!M.length)return;m.current.length===0&&(m.current=no(M).map(z=>z.id));let C=m.current.map(z=>M.find(S=>S.id===z)).filter(Boolean),O=[],P=0,H=C.findIndex(z=>z.id===T.id),q=!_&&H>0&&Math.abs(h-T.position.y)>.5;for(let z=0;z<C.length;z++){let S=C[z],V=S.id===T.id,R=z===C.length-1;if(V){P=q?h+E:P+E;continue}let I=(te=(Q=S.measured)==null?void 0:Q.height)!=null?te:0,Y=_?y-se.HEADER_WIDTH:y,B=I;_&&R&&(B=Math.max(se.MIN_HEIGHT,E-P)),q&&z===H-1&&(B=Math.max(se.MIN_HEIGHT,h-P)),O.push({id:S.id,type:"dimensions",dimensions:{width:Y,height:B},setAttributes:!0}),O.push({id:S.id,type:"position",position:{x:se.HEADER_WIDTH,y:P}}),P+=B}_?O.push({id:A,type:"dimensions",dimensions:{width:y,height:E},setAttributes:!0}):O.push({id:A,type:"dimensions",dimensions:{width:y+se.HEADER_WIDTH,height:P},setAttributes:!0}),N==null||N(O)})},g=({y:h,width:y,height:E})=>{var T;if(cancelAnimationFrame(u.current),m.current=[],!e)return;let v=s(e);if(!v||v.type!=="LANE"&&!v.parentId)return;let N=[...l()];if(v.type!=="LANE"){N=N.map(_=>_.id===e?w(b({},_),{width:y,height:E,measured:{width:y,height:E}}):_),N=St(N),a(N);return}N=pa(v,y,E,N,h),N=St(N),N=oo((T=v.parentId)!=null?T:v.id,N),a(N)};if(!(!c&&t))return null;let f={"--resize-offset":`${o}px`};return Zh(qh,{children:[$h.map(h=>ld(ad,w(b({},n),{key:h,nodeId:e,position:h,variant:Fh.Line,className:"border-blue-400/90 border-dashed",style:f,onResize:(y,E)=>p(E),onResizeEnd:(y,E)=>g(E)}))),Kh.map(h=>ld(ad,w(b({},n),{key:h,nodeId:e,position:h,className:"size-1.5 bg-blue-400 relative before:content-[''] before:absolute before:w-5 before:h-5 before:left-1/2 before:top-1/2 before:-translate-x-1/2 before:-translate-y-1/2 before:cursor-[inherit]",style:f,onResize:(y,E)=>p(E),onResizeEnd:(y,E)=>g(E)})))]})};import{NodeToolbar as my,useReactFlow as gy}from"@xyflow/react";import{Button as hy,Tooltip as yy,TooltipContent as xy,TooltipTrigger as Ey,useTranslation as by}from"@produto-lecom/lecom-ui";import{useCallback as gs,useEffect as _y,useRef as Qr,useState as Ty}from"react";import{create as Jh}from"zustand";var Yo=Jh(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{useEffect as Qh,useState as jh}from"react";var cd=(e,t=!1)=>{let[o,n]=jh({width:0,height:0});return Qh(()=>{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 ey}from"@xyflow/react";import{useMemo as ty}from"react";var oy=120,ny=12,dd=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=ey(),{instanceId:i}=U();return ty(()=>{var p,g;if(!t)return{position:wn.Right,align:"start"};let s=n(e);if(!s)return{position:wn.Right,align:"start"};let a=r(),l=s.position.x*a.zoom+a.x,c=(((p=s.measured)==null?void 0:p.width)||s.width||100)*a.zoom,d=(g=document.getElementById(`modeler-${i}`))==null?void 0:g.clientWidth;if(!d)return{position:wn.Right,align:"start"};let u=(o==null?void 0:o.width)||oy;return{position:l+c+u+ny>d?wn.Left:wn.Right}},[i,e,t,o,n,r])};import{useNodesData as ry,useReactFlow as iy}from"@xyflow/react";import{Button as ud,DropdownMenu as sy,DropdownMenuContent as ay,DropdownMenuGroup as ly,DropdownMenuItem as cy,DropdownMenuLabel as dy,DropdownMenuTrigger as uy,Tooltip as ps,TooltipContent as fs,TooltipTrigger as ms,useTranslation as py}from"@produto-lecom/lecom-ui";import{WrenchIcon as fy}from"lucide-react";import{jsx as Oe,jsxs as mo}from"react/jsx-runtime";var pd=({nodeId:e})=>{let{t}=py(),{updateNodeData:o,getEdges:n,getNode:r}=iy(),i=ry(e),a=n().filter(p=>p.source===e).some(p=>{let g=r(p.target);return(g==null?void 0:g.type)==="END_EVENT"}),l=(i==null?void 0:i.data.variant)==="SUBPROCESS",c=u=>{o(e,{variant:(i==null?void 0:i.data.variant)===u?"":u})},d=u=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===u?"":u})};return mo(sy,{children:[mo(ps,{children:[Oe(ms,{asChild:!0,children:Oe(uy,{asChild:!0,children:Oe(ud,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:Oe(fy,{})})})}),Oe(fs,{color:"black",children:t("bpmn.task.menu.title")})]}),mo(ay,{align:"start",className:"w-60 bg-white text-grey-600",children:[mo(dy,{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(Fn).map(([u,m])=>{let p=u==="LOOP"&&(a||l),x=(()=>{if(u==="LOOP"&&a)return t("editor.task_menu.loop_not_allowed_when_connected_to_end");if(u==="LOOP"&&l)return t("editor.task_menu.loop_not_allowed_when_subprocess");if(u==="LOOP")return t("editor.task_menu.loop")})();return mo(ps,{children:[Oe(ms,{asChild:!0,children:Oe(ud,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:p,className:G({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===u,"opacity-50 cursor-not-allowed":p}),onClick:p?void 0:()=>d(u),children:Oe(m.icon,{className:"stroke-inherit"})})}),x&&Oe(fs,{color:"black",children:x})]},u)})})]}),Oe(ly,{children:mo(ps,{children:[Oe(ms,{asChild:!0,children:Oe("div",{className:G({"cursor-not-allowed":a}),children:mo(cy,{className:G({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":a}),disabled:a,onClick:()=>c("SCRIPT"),children:[Oe(Wn.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),a&&Oe(fs,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};import{jsx as Me,jsxs as fd}from"react/jsx-runtime";var Mt={START_EVENT:{type:"START_EVENT",icon:Jo,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:bo,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:Jo,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:Gn,label:"bpmn.annotation.variant.default"}},Ny={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:To,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:No,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}=by(),{setDraggableNode:a}=Yo(),{getEdges:l,getNodes:c,getNode:d,setNodes:u}=gy(),{setIsDragging:m,mode:p,isConnecting:g,isDragging:x,isMultipleSelection:f}=U(),h=d(e),y=!!(h!=null&&h.selected)&&!h.dragging&&!g&&!x&&!f,{dimensions:E}=cd(r,y),{position:v}=dd(e,y,E),[N,T]=Ty(void 0),_=c(),A=l(),M=o==="SUBPROCESS",C=Qr(null),O=Qr(!1),P=gs(()=>{C.current!==null&&(clearTimeout(C.current),C.current=null),O.current=!1,m(!1),a(null),T(void 0),u(D=>D.map(F=>w(b({},F),{className:void 0})))},[m,a,u]);_y(()=>{let D=F=>{O.current&&F.buttons===0&&P()};return document.addEventListener("dragend",P),document.addEventListener("mousemove",D),()=>{document.removeEventListener("dragend",P),document.removeEventListener("mousemove",D)}},[P]);let H=gs((D,F)=>{O.current=!0,m(!1),a({type:F.type,variant:F.variant,attribute:F.attribute,icon:F.icon}),F.icon&&T(Me(F.icon,{})),D.dataTransfer.effectAllowed="move",D.dataTransfer.setData("sourceId",e),i.current&&D.dataTransfer.setDragImage(i.current,10,10),C.current=setTimeout(()=>{C.current=null,m(!0)},100)},[e,a,m]),q=gs(()=>{P()},[P]),Q=[{component:Me(Vr,{elementId:e})}],te=()=>{if(p==="view")return[];let D=!A.some(F=>{var Z;return F.source===e&&((Z=_.find(X=>X.id===F.target))==null?void 0:Z.type)!=="ANNOTATION"});return[{component:Me(Po,{nodeId:e,disabled:!D,tooltipMessage:D?void 0:s("editor.toolbar.start_event_limit_reached")})},Mt.TASK,Mt.ANNOTATION,...Q]},z=()=>p==="view"?[{component:Me(Wt,{elementId:e})}]:[{component:Me(Wt,{elementId:e})},...M?[]:[{component:Me(pd,{nodeId:e})}],{component:Me(Po,{nodeId:e})},Mt.TASK,{type:"TASK",variant:"SUBPROCESS",icon:jo,label:"bpmn.task.variant.subprocess"},Mt.ANNOTATION,...Object.values(Ny),...uo(e,_,A)?[]:[Mt.END_EVENT],...Q],S=()=>p==="view"?[{component:Me(Wt,{elementId:e,elementType:"gateway"})}]:[{component:Me(Wt,{elementId:e,elementType:"gateway"})},{component:Me(Po,{nodeId:e})},Mt.TASK,{type:"TASK",variant:"SUBPROCESS",icon:jo,label:"bpmn.task.variant.subprocess"},Mt.ANNOTATION,...Q],V=()=>p==="view"?[]:[Mt.ANNOTATION,...Q],R=()=>p==="view"?[]:[...n?[]:[{component:Me(Po,{nodeId:e})}],Mt.ANNOTATION,...Q],I=()=>p==="view"?[]:[{component:Me(Po,{nodeId:e})},...Q],Y=()=>p==="view"?[]:[...Q],L=(D=>{switch(D){case"START_EVENT":return te();case"TASK":return z();case"GATEWAY":return S();case"END_EVENT":return V();case"LANE":return R();case"ANNOTATION":return I();case"UNSUPPORTED":return Y();default:return[]}})(t),k=L.length>6;if(!(L.length===0||p==="readonly"))return fd(my,{position:v,align:"start",className:k?"-top-[4.5rem]":"-top-8",isVisible:y,children:[Me("div",{ref:r,className:`${k?"grid grid-cols-6":"flex"} gap-1 px-2 py-2 bg-white rounded-sm shadow-md`,children:L.map((D,F)=>{if(D.component)return Me("div",{children:D.component},F);let Z={sourceNodeType:t,targetNodeType:D.type,sourceNodeId:e,nodes:_,edges:A},X=gc(Z),J={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")},ee=X.shouldDisable&&X.reason?J[X.reason]||s(D.label):s(D.label)||"";return fd(yy,{children:[Me(Ey,{asChild:!0,children:Me(hy,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!X.shouldDisable,disabled:X.shouldDisable,className:X.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:X.shouldDisable?void 0:ie=>H(ie,D),onDragEnd:X.shouldDisable?void 0:q,children:D.icon&&Me(D.icon,{size:16})})}),Me(xy,{color:"black",children:ee})]},F)})}),Me("div",{ref:i,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:N})]})};import{Fragment as md,jsx as ct,jsxs as ys}from"react/jsx-runtime";var gd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r,setNodes:i}=wy(),{inProgress:s,fromNode:a}=vy(),{mode:l,isReadOnly:c}=U(),d=s&&(a==null?void 0:a.id)!==e,u=hs(g=>{let E=g.split(`
|
|
40
|
-
`),v=E.reduce((A,M)=>Math.max(A,M.length),0),N=E.length,T=Math.max(wo.MIN_WIDTH,v*7+32),_=Math.max(wo.MIN_HEIGHT,N*20+24);i(A=>A.map(M=>M.id===e?w(b({},M),{width:T,height:_,style:w(b({},M.style),{width:T,height:_})}):M))},[e,i]),m=hs(g=>{r(e,{label:g}),u(g)},[e,r,u]),p=hs(g=>{u(g)},[u]);return ys("div",{className:G("relative w-full h-full min-w-44 min-h-16 flex text-grey-400 hover:text-grey-500 bg-white rounded-sm border-l-2 border-current before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-current after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-current hover:shadow-md transition-colors duration-75",{"pointer-events-none":c,"text-blue-500 hover:text-blue-600 shadow-md":o&&!c,"border-red-500 border-l-[3px] shadow-[0_0_5px_rgba(255,0,0,0.5)] before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-red-500 after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-red-500":t.hasError}),children:[ct(De,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:m,onInput:p,skipFirstCharValidation:!0}),ct(Fe,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&ct(it,{nodeId:e,minWidth:wo.MIN_WIDTH,minHeight:wo.MIN_HEIGHT,isVisible:!n&&o}),!s&&ys(md,{children:[ct(ne,{type:"source",position:Ut.Left,id:"left"}),ct(ne,{type:"source",position:Ut.Right,id:"right"}),ct(ne,{type:"source",position:Ut.Top,id:"top"}),ct(ne,{type:"source",position:Ut.Bottom,id:"bottom"})]}),(!s||d)&&ys(md,{children:[ct(ne,{type:"target",position:Ut.Left,id:"left",className:G({"annotation-handle":d})}),ct(ne,{type:"target",position:Ut.Right,id:"right",className:G({"annotation-handle":d})}),ct(ne,{type:"target",position:Ut.Top,id:"top",className:G({"annotation-handle":d})}),ct(ne,{type:"target",position:Ut.Bottom,id:"bottom",className:G({"annotation-handle":d})})]})]})};import{Position as $t,useConnection as Iy,useReactFlow as Ay}from"@xyflow/react";import{useState as Cy}from"react";import{Fragment as hd,jsx as qe,jsxs as xs}from"react/jsx-runtime";var yd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=Ay(),{inProgress:i,fromNode:s}=Iy(),{mode:a,isReadOnly:l,reconnectingEdgeId:c}=U(),[d,u]=Cy(!1),m=i&&(s==null?void 0:s.id)!==e||!!c,p=f=>{r(e,{label:f})},g=()=>{u(!0)},x=()=>{u(!1)};return xs("div",{className:"relative",onDoubleClick:g,children:[qe(bo,{className:G("w-full h-full min-w-9 min-h-9 hover:stroke-[#d33b3b] transition-colors duration-75",{"pointer-events-none":l,"stroke-blue-500 hover:stroke-blue-600":o&&!l,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),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:x,onChange:p})}),qe(Fe,{nodeId:e,nodeType:"END_EVENT"}),a==="edit"&&qe(it,{nodeId:e,isVisible:!n&&o,minWidth:Un.MIN_WIDTH,minHeight:Un.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||m)&&xs(hd,{children:[qe(ne,{type:"target",position:$t.Left,id:"left",className:G({"event-handle":m})}),qe(ne,{type:"target",position:$t.Right,id:"right",className:G({"event-handle":m})}),qe(ne,{type:"target",position:$t.Top,id:"top",className:G({"event-handle":m})}),qe(ne,{type:"target",position:$t.Bottom,id:"bottom",className:G({"event-handle":m})})]}),!i&&xs(hd,{children:[qe(ne,{type:"source",position:$t.Left,id:"left"}),qe(ne,{type:"source",position:$t.Right,id:"right"}),qe(ne,{type:"source",position:$t.Top,id:"top"}),qe(ne,{type:"source",position:$t.Bottom,id:"bottom"})]})]})};import{Position as Kt,useConnection as Sy,useReactFlow as My}from"@xyflow/react";import{useCallback as Py,useState as Ly}from"react";import{Fragment as xd,jsx as Ze,jsxs as Es}from"react/jsx-runtime";var Ed=({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let s=Oi[t.variant].icon,{updateNodeData:a}=My(),{inProgress:l,fromNode:c}=Sy(),{mode:d,isReadOnly:u,reconnectingEdgeId:m}=U(),[p,g]=Ly(!1),x=l&&(c==null?void 0:c.id)!==e||!!m,f=Py(E=>{a(e,{label:E})},[e,a]),h=()=>{g(!0)},y=()=>{g(!1)};return Es("div",{className:"relative",style:{width:o!=null?o:vo.MIN_WIDTH,height:n!=null?n:vo.MIN_HEIGHT},onDoubleClick:h,children:[Ze(s,{className:G("w-full h-full min-w-14 min-h-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"pointer-events-none":u,"stroke-blue-500 hover:stroke-blue-600":r&&!u,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),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:p,onBlur:y,onChange:f})}),Ze(Fe,{nodeId:e,nodeType:"GATEWAY",nodeVariant:t.variant}),d==="edit"&&Ze(it,{nodeId:e,isVisible:!i&&r,minWidth:vo.MIN_WIDTH,minHeight:vo.MIN_HEIGHT,offset:2,keepAspectRatio:!0}),(!l||x)&&Es(xd,{children:[Ze(ne,{type:"target",position:Kt.Left,id:"left",className:G({"gateway-handle":x})}),Ze(ne,{type:"target",position:Kt.Right,id:"right",className:G({"gateway-handle":x})}),Ze(ne,{type:"target",position:Kt.Top,id:"top",className:G({"gateway-handle":x})}),Ze(ne,{type:"target",position:Kt.Bottom,id:"bottom",className:G({"gateway-handle":x})})]}),!l&&Es(xd,{children:[Ze(Ge,{type:"source",position:Kt.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Ze(Ge,{type:"source",position:Kt.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Ze(Ge,{type:"source",position:Kt.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Ze(Ge,{type:"source",position:Kt.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})};import{useNodesData as TM,useReactFlow as NM}from"@xyflow/react";import{Button as wM,DropdownMenu as IM,DropdownMenuContent as AM,DropdownMenuGroup as CM,DropdownMenuItem as SM,DropdownMenuLabel as MM,DropdownMenuTrigger as PM,Tooltip as LM,TooltipContent as RM,TooltipTrigger as kM,useTranslation as DM}from"@produto-lecom/lecom-ui";import{WrenchIcon as VM}from"lucide-react";import{jsx as zM,jsxs as YM}from"react/jsx-runtime";import{Position as qt,useConnection as Ry,useReactFlow as ky}from"@xyflow/react";import{useState as Dy}from"react";import{Fragment as bd,jsx as Je,jsxs as bs}from"react/jsx-runtime";var _d=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=ky(),{inProgress:i,fromNode:s}=Ry(),{mode:a,isReadOnly:l,reconnectingEdgeId:c}=U(),[d,u]=Dy(!1),m=i&&(s==null?void 0:s.id)!==e||!!c,p=f=>{r(e,{label:f})},g=()=>{u(!0)},x=()=>{u(!1)};return bs("div",{className:"relative",onDoubleClick:g,children:[Je(zn,{className:G("w-full h-full min-w-9 min-h-9 hover:stroke-[#54890b] transition-colors duration-75",{"pointer-events-none":l,"stroke-blue-500 hover:stroke-blue-600":o&&!l,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),Je("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Je(De,{value:t.label,isEditing:d,onBlur:x,onChange:p})}),Je(Fe,{nodeId:e,nodeType:"START_EVENT"}),a==="edit"&&Je(it,{nodeId:e,isVisible:!n&&o,minWidth:Xn.MIN_WIDTH,minHeight:Xn.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||m)&&bs(bd,{children:[Je(ne,{type:"target",position:qt.Left,id:"left",className:G({"event-handle":m})}),Je(ne,{type:"target",position:qt.Right,id:"right",className:G({"event-handle":m})}),Je(ne,{type:"target",position:qt.Top,id:"top",className:G({"event-handle":m})}),Je(ne,{type:"target",position:qt.Bottom,id:"bottom",className:G({"event-handle":m})})]}),!i&&bs(bd,{children:[Je(Ge,{type:"source",position:qt.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),Je(Ge,{type:"source",position:qt.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),Je(Ge,{type:"source",position:qt.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),Je(Ge,{type:"source",position:qt.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};import{useTranslation as Hy}from"@produto-lecom/lecom-ui";import{Position as Zt,useConnection as Gy,useReactFlow as By}from"@xyflow/react";import{useCallback as ei}from"react";var In=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<=In?i:i.substring(0,In).trim()},Wo=(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>In&&(n=n.substring(0,In).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=In-l.length,u=`${r.substring(0,c).trim()}${l}`;if(!o.has(u))return u;i++}return n};import{jsx as Td,jsxs as Oy}from"react/jsx-runtime";var Nd=e=>Oy("svg",w(b({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[Td("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),Td("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as vd}from"react/jsx-runtime";var wd=e=>vd("svg",w(b({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 Id,jsxs as Vy}from"react/jsx-runtime";var Ad=e=>Vy("svg",w(b({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[Id("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),Id("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{Fragment as ti,jsx as we,jsxs as An}from"react/jsx-runtime";var zy={APROVADO:Nd,EM_ANDAMENTO:wd,REJEITADO:Ad},_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)]"},Yy={APROVADO:"bg-green-50",EM_ANDAMENTO:"bg-turquoise-50",REJEITADO:"bg-red-50"},Cd=({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let{t:s}=Hy(),{toast:a}=We(),{updateNodeData:l,getNodes:c,setNodes:d}=By(),{inProgress:u,fromNode:m}=Gy(),{mode:p,isReadOnly:g,onSubprocessValidationClick:x,reconnectingEdgeId:f}=U(),{getTaskStatus:h}=ro(),y=u&&(m==null?void 0:m.id)!==e||!!f,E=h(e),v=t.variant==="SUBPROCESS",N=!!t.variant&&!v||!!E,T=!!t.attribute||v,_=ei(z=>{let I=N||T?80:40,Y=z.split(`
|
|
41
|
-
`),B=Y.reduce((F,Z)=>Math.max(F,Z.length),0),L=Y.length,k=Math.max(Ot.MIN_WIDTH,B*7+64),D=Math.max(Ot.MIN_HEIGHT,L*24+I);d(F=>F.map(Z=>Z.id===e?w(b({},Z),{width:k,height:D,style:w(b({},Z.style),{width:k,height:D})}):Z))},[e,d,N,T]),A=ei(z=>{let S=z.trim(),V=t.label||"";if(S===V)return;let R=S,I=c();if(!(S&&S!=="")){R=jr(I,s("bpmn.task.label.prefix")),l(e,{label:R}),_(R),a({variant:"warning",content:An(ti,{children:[s("bpmn.task.feedback.label_empty.prefix")," ",we("strong",{children:R})]})});return}let B=Wo(R,I);B===V||(l(e,{label:B}),_(B),B!==R&&a({variant:"warning",content:An(ti,{children:[s("bpmn.task.feedback.label_already_exists.prefix")," ",we("strong",{children:S})," ",s("bpmn.task.feedback.label_already_exists.middle")," ",we("strong",{children:B})]})}))},[t.label,c,e,s,l,_,a]),M=ei(z=>{_(z)},[_]),C=ei(()=>{a({variant:"error",content:s("bpmn.task.feedback.invalid_first_character")})},[s,a]),O=E?zy[E]:null,P=t.variant?Wn[t.variant].icon:null,H=t.attribute?Fn[t.attribute].icon:null,q=()=>t.hasError?_s.error:E?_s[E]:g?_s.default:"",Q=()=>{var z;return r&&(z=Yy[E])!=null?z:""},te=()=>{x==null||x({id:e,type:"sub_process",label:t.label})};return An("div",{className:G("relative w-full h-full min-w-44 min-h-24 flex flex-col items-stretch justify-stretch bg-white border-2 border-grey-400 hover:border-grey-500 rounded-md hover:shadow-md transition-colors duration-75",q(),{"cursor-pointer":g,"border-blue-500 hover:border-blue-600 shadow-md":r&&!g&&!E,"border-red-500 hover:border-red-600 shadow-[0_0_5px_rgba(255,0,0,0.5)]":t.hasError}),style:{width:o!=null?o:Ot.MIN_WIDTH,height:n!=null?n:Ot.MIN_HEIGHT},children:[we("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:we(De,{value:t.label,maxLength:60,className:G(Q(),{"py-10 px-8":N||T}),onChange:A,onInput:M,onInvalidFirstCharacter:C})}),P&&we("div",{className:G("absolute flex items-center p-1",v?"bottom-0 left-1/2 -translate-x-1/2":"top-0 left-0"),children:we(P,{size:16,className:G(t.hasError?"text-red-500":"text-grey-500",v&&"cursor-pointer"),onClick:v?te:void 0})}),H&&we("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:we("div",{className:G("flex items-center w-16 p-1",v?"justify-between":"justify-center"),children:we(H,{size:16,className:G(t.hasError?"text-red-500":"text-grey-500")})})}),O&&we("div",{className:"absolute top-0 right-0 flex items-center p-1",children:we(O,{})}),we(Fe,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),p==="edit"&&we(it,{nodeId:e,isVisible:!i&&r,minWidth:Ot.MIN_WIDTH,minHeight:Ot.MIN_HEIGHT}),(!u||y)&&An(ti,{children:[we(ne,{type:"target",position:Zt.Left,id:"left",className:G({"task-handle":y})}),we(ne,{type:"target",position:Zt.Right,id:"right",className:G({"task-handle":y})}),we(ne,{type:"target",position:Zt.Top,id:"top",className:G({"task-handle":y})}),we(ne,{type:"target",position:Zt.Bottom,id:"bottom",className:G({"task-handle":y})})]}),!u&&An(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 Wy,jsx as oi,jsxs as Fy}from"react/jsx-runtime";var Md=({id:e,data:t})=>Fy(Wy,{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 Xy,EdgeLabelRenderer as Uy,getSmoothStepPath as $y,MarkerType as Ky,useInternalNode as Pd,useReactFlow as qy,useViewport as Zy,Position as Fo}from"@xyflow/react";import{useState as Jy,useMemo as Qy}from"react";import{Fragment as Ld,jsx as Xe,jsxs as go}from"react/jsx-runtime";var I5={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:Ky.Arrow},data:{label:""}},Rd=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:s,sourceHandleId:a,targetHandleId:l})=>{var B;let{zoom:c}=Zy(),{updateEdgeData:d}=qy(),{isMultipleSelection:u,mode:m,instanceId:p}=U(),g=m!=="edit",[x,f]=Jy(!1),{reconnectingHandle:h,cursorPosition:y,hoveredNodeId:E,reconnectingSide:v,isValidReconnection:N,handleReconnectStart:T}=Ur({edgeId:e,source:t,target:o,instanceId:p,isReadOnly:g}),_=Pd(t),A=Pd(o),{sx:M,sy:C,tx:O,ty:P,sourcePos:H,targetPos:q}=Qy(()=>{var oe,le;if(!_||!A)return{sx:0,sy:0,tx:0,ty:0,sourcePos:Fo.Left,targetPos:Fo.Right};let L=Io(_,A),k=a?i:L.sourcePos,D=l?s:L.targetPos,F=($,xe,me)=>{var j,ge,_e,Te,Re,je;let{x:be,y:K}=$.internals.positionAbsolute,de=(_e=(ge=(j=$.measured)==null?void 0:j.width)!=null?ge:$.width)!=null?_e:0,re=(je=(Re=(Te=$.measured)==null?void 0:Te.height)!=null?Re:$.height)!=null?je:0;switch(xe){case Fo.Top:return{x:be+de*me,y:K};case Fo.Bottom:return{x:be+de*me,y:K+re};case Fo.Left:return{x:be,y:K+re*me};case Fo.Right:return{x:be+de,y:K+re*me};default:return{x:be+de/2,y:K+re/2}}},Z=(oe=n==null?void 0:n.sourceOffset)!=null?oe:.5,X=(le=n==null?void 0:n.targetOffset)!=null?le:.5,J=_?F(_,k,Z).x:L.sx,ee=_?F(_,k,Z).y:L.sy,ie=A?F(A,D,X).x:L.tx,W=A?F(A,D,X).y:L.ty;return h==="source"&&y?(J=y.x,ee=y.y,v&&(k=v)):h==="target"&&y&&(ie=y.x,W=y.y,v&&(D=v)),{sx:J,sy:ee,tx:ie,ty:W,sourcePos:k,targetPos:D}},[_,A,a,l,i,s,h,y,v,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!_||!A)return null;let[Q,te,z]=$y({sourceX:M,sourceY:C,targetX:O,targetY:P,sourcePosition:H,targetPosition:q}),S=r||(_==null?void 0:_.selected)||(A==null?void 0:A.selected),V=S?"sequence-edge-marker-highlighted":"sequence-edge-marker",R=x||(n==null?void 0:n.label.trim().length)>0,I=()=>{f(!1)},Y=L=>{d(e,{label:L.trim()})};return Xe(Ld,{children:go("g",{className:G("group bpmn-arrow-edge",{"is-highlighted":S}),onDoubleClick:()=>!g&&f(!0),children:[Xe("path",{d:Q,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),go("g",{className:G("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":S}),children:[Xe(Xy,{id:e,path:Q,interactionWidth:0,markerEnd:`url(#${V})`,strokeDasharray:4,className:G("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)||h&&E&&!N,"stroke-green-500":h&&E&&N,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":S&&!(n!=null&&n.hasError)&&!h})}),go(Uy,{children:[go("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${te}px, ${z}px)`},children:[r&&!u&&Xe(Ro,{sx:M,sy:C,tx:O,ty:P,hasLabel:!!((B=n==null?void 0:n.label)!=null&&B.trim()),children:Xe(Lo,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),R&&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:x,onBlur:I,onChange:Y})]}),r&&!u&&!g&&go(Ld,{children:[Xe("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${M}px, ${C}px)`},children:go("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:h==="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:h==="source"?.6:.3,className:"pointer-events-none"}),Xe("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:G("pointer-events-auto",{"cursor-move":!h||h!=="source","cursor-not-allowed":h==="source"&&E&&!N,"cursor-grabbing":h==="source"&&(!E||N)}),onMouseDown:L=>T("source",L.nativeEvent)})]})}),Xe("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${O}px, ${P}px)`},children:go("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:h==="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:h==="target"?.6:.3,className:"pointer-events-none"}),Xe("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:G("pointer-events-auto",{"cursor-move":!h||h!=="target","cursor-not-allowed":h==="target"&&E&&!N,"cursor-grabbing":h==="target"&&(!E||N)}),onMouseDown:L=>T("target",L.nativeEvent)})]})})]})]})]})]})})};import{getStraightPath as jy,Position as ni}from"@xyflow/react";import{jsx as kd,jsxs as e0}from"react/jsx-runtime";var Dd=({toX:e,toY:t,fromNode:o})=>{var u,m;if(!o)return null;let{internals:{positionAbsolute:{x:n,y:r}},measured:i}=o,s=(u=i.width)!=null?u:0,a=(m=i.height)!=null?m: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((p,g)=>{let x=Math.hypot(e-p.x,t-p.y);return Math.hypot(e-g.x,t-g.y)<x?g:p}),[d]=jy({sourceX:c.x,sourceY:c.y,targetX:e,targetY:t});return e0("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 t0,useReactFlow as o0}from"@xyflow/react";import{orderBy as n0}from"lodash";import{useMemo as Od,useState as r0}from"react";import{Fragment as Ts,jsx as Ue,jsxs as ri}from"react/jsx-runtime";var Vd=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{var _;let{updateNodeData:i,getNodes:s}=o0(),{mode:a,isReadOnly:l}=U(),{inProgress:c,fromNode:d}=t0(),u=c&&(d==null?void 0:d.id)!==e,[m,p]=r0(!1),g=s(),x=!r,f=!x&&((_=g.find(A=>A.id===r))==null?void 0:_.selected),h=Od(()=>n0([...g.filter(A=>A.parentId===e&&A.type==="LANE")],"position.y","asc"),[g,e]),y=x?ta.MIN_WIDTH:se.MIN_WIDTH,E=Od(()=>{if(x&&h.length>1){let A=[...h];return A.pop(),A.reduce((C,O)=>{var P,H;return C+((H=(P=O.measured)==null?void 0:P.height)!=null?H:0)},0)+se.MIN_HEIGHT}return se.MIN_HEIGHT},[x,h]),v=A=>{i(e,{label:A})},N=()=>{p(!0)},T=()=>{p(!1)};return ri(Ts,{children:[ri("div",{className:G("flex h-full min-h-64 w-full min-w-[50rem] hover:shadow-md bg-white outline outline-2 outline-grey-400",{"pointer-events-none":l,"outline-offset-0 outline-blue-500 shadow-sm":(o||f)&&!l}),children:[Ue("div",{className:G("flex align-items justify-center w-10 border-r-2 border-grey-400",{"border-blue-500":(o||f)&&!l}),onDoubleClick:N,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:G({"whitespace-nowrap":m}),isEditing:m,onBlur:T,onChange:v})})}),Ue("div",{className:"flex-1"})]}),Ue(Fe,{nodeId:e,nodeType:"LANE",isChild:!x}),a==="edit"&&Ue(it,{nodeId:e,isVisible:!n&&o,minWidth:y,minHeight:E,offset:10}),!c&&ri(Ts,{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(Ts,{children:[Ue(ne,{type:"target",position:Jt.Left,id:"left",className:G({"annotation-handle":u})}),Ue(ne,{type:"target",position:Jt.Right,id:"right",className:G({"annotation-handle":u})}),Ue(ne,{type:"target",position:Jt.Top,id:"top",className:G({"annotation-handle":u})}),Ue(ne,{type:"target",position:Jt.Bottom,id:"bottom",className:G({"annotation-handle":u})})]})]})};var Hd={START_EVENT:_d,END_EVENT:yd,TASK:Cd,GATEWAY:Ed,ANNOTATION:gd,LANE:Vd,UNSUPPORTED:Md},Gd={SEQUENCE_EDGE:Dc,MESSAGE_EDGE:Rd,ANNOTATION_EDGE:Ec},Bd="#fafafa",zd="#bebebe",Yd=1,Wd=10,Fd="bottom-left",Ns=.05,Xd=5,Xo=.5,Uo=Ns,$o=1,Ud={x:0,y:0,zoom:.75},$d=1,Kd=2,i0={[$d]:4,[Kd]:2},Cn=[$d,Kd],vs=Cn.reduce((e,t)=>e|i0[t],0);import{useReactFlow as s0}from"@xyflow/react";var st=()=>{let{getEdges:e,getNodes:t}=s0(),{lastElementId:o}=U(),n=()=>{let i=t(),s=e(),a=td(i,s);return Math.max(a,o)};return{getLastId:n,getNextId:()=>n()+1}};var Ko=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n,setViewport:r}=l0(),{getLastId:i}=st(),s=c0(),{setLastElementId:a}=U(),l=qd(async(d="")=>{let{nodes:u,edges:m,lastElementId:p}=await nd(d),{width:g,height:x}=s.getState();if(g>0&&x>0){let f=ca(u);f&&r(a0(f,g,x,Uo,$o,Xo))}o(u),n(m),a(p)},[o,n,a,s,r]),c=qd(()=>{let d=e(),u=t(),m=i();return od(d,u,m)},[e,t,i]);return{importFromMxGraph:l,exportToMxGraph:c}};import{useCallback as Zd}from"react";var u0=500,ii=()=>{let{isInitialized:e,onElementChanges:t}=U(),{exportToMxGraph:o}=Ko(),n=d0(()=>{if(!e)return;let s=o();t==null||t(s)},u0),r=Zd(s=>{s.every(c=>c.type==="select")||s.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=Zd(s=>{s.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var Jd=({setEdges:e,saveHistory:t})=>{let{getNode:o,getEdges:n,getNodes:r,getInternalNode:i}=f0(),{emitElementChanges:s}=ii(),a=m0(null),{getNextId:l}=st(),c=ho(f=>{var N;let h=o(f.source),y=o(f.target);if(!h||!y)return!1;let E={sourceNodeId:h.id,targetNodeId:y.id,sourceNodeType:h.type,targetNodeType:y.type,nodes:r(),edges:n(),reconnectingEdgeId:(N=a.current)!=null?N:void 0};return ns(E).isValid},[o,n,r]),d=ho(f=>{var E,v;let h=l(),y=i(f.source);if(y){let N=i(f.target),T=N?N.internals.positionAbsolute.x+((E=N.measured.width)!=null?E:0)/2:0,_=N?N.internals.positionAbsolute.y+((v=N.measured.height)!=null?v:0)/2:0,A=Oc(y,T,_),M=(N==null?void 0:N.type)==="ANNOTATION"||(y==null?void 0:y.type)==="ANNOTATION",C=M?ko:rt,O;if(!M&&N&&f.targetHandle){let q=Kr(A),Q=Kr(f.targetHandle),{x:te,y:z}=ls(y,A),{x:S,y:V}=ls(N,f.targetHandle),I=Fr(te,z,S,V,q,Q).slice(1,-1);I.length>0&&(O=I)}let P=w(b(b({},f),C),{id:String(h),sourceHandle:A,data:b(b({},M?{}:rt.data),O?{points:O}:{})}),H=n().concat(P);e(H),t("forceSave",{nodes:r(),edges:H}),s()}},[l,e,s,i,n,r,t]),u=ho((f,h)=>{a.current=h.id},[]),m=ho(()=>{a.current=null},[]),p=ho((f,h)=>{let y=o(h.source),E=o(h.target);if(!y||!E){a.current=null;return}let v={sourceNodeId:y.id,targetNodeId:E.id,sourceNodeType:y.type,targetNodeType:E.type,nodes:r(),edges:n(),reconnectingEdgeId:f.id};if(!ns(v).isValid){a.current=null;return}let T=p0(f,h,n()).map(_=>_.id===f.id?w(b({},_),{data:w(b({},_.data),{points:void 0})}):_);e(T),t("forceSave",{nodes:r(),edges:T}),a.current=null,s()},[o,r,n,e,s,t]),g=ho(f=>{a.current=f},[]),x=ho(()=>{a.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:p,onReconnectStart:u,onReconnectEnd:m,setReconnectingEdge:g,clearReconnectingEdge:x}};import{useTranslation as g0}from"@produto-lecom/lecom-ui";import{useReactFlow as h0}from"@xyflow/react";import{useCallback as Ln,useRef as su,useState as y0}from"react";var Sn=(e=[])=>e.filter(t=>t.type==="START_EVENT"),yo=(e=[])=>e.filter(t=>t.type==="END_EVENT"),Qt=(e=[])=>e.filter(t=>t.type==="TASK")||[],Qd=(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"),jd=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),Qe=(e,t=[])=>t.filter(o=>o.source===e),Mn=(e,t=[])=>t.filter(o=>o.target===e),eu=(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"},tu=(e,t)=>{let o=Qe(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},ou=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:[]}},Pt=(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)}},nu=(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=yo(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=Qe(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=Pt(t,n=>Qe(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=Pt(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=Pt(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=Qe(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),...yo(e.nodes)],o=[],n=[];for(let r of t){let i=Qe(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=yo(e.nodes),o=[],n=[];for(let r of t){let i=Mn(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=Qe(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=jd(e.nodes),o=Pt(t,r=>Qe(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>Qe(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=Pt(t,n=>!n.label||ou(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=yo(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=Pt(r,l=>!eu(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=yo(e.nodes)[0];if(!o)return Ee({isValid:!0});let n=t.filter(l=>{let c=Mn(l.id,e.edges),d=Qe(l.id,e.edges),u=c.some(p=>{var g;return((g=e.nodes.find(x=>x.id===p.source))==null?void 0:g.type)==="START_EVENT"}),m=d.some(p=>{var g;return((g=e.nodes.find(x=>x.id===p.target))==null?void 0:g.type)==="END_EVENT"});return u&&m}),r=Mn(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=Qe(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=Pt(t,n=>Qe(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),...yo(e.nodes)],o=[],n=[];for(let r of t){let i=Qe(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=Qd(e.nodes),o=Pt(t,n=>!tu(n.id,e));return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}}];var ru=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}},iu=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){return{isValid:!1,errors:[{id:"cannot_validate_subprocess_reference",message:"cannot_validate_subprocess_reference",nodeIds:t.map(i=>i.id)||[],edgeIds:[]}]}}};import{jsx as ai,jsxs as x0}from"react/jsx-runtime";var au=()=>{let{t:e}=g0(),{toast:t}=We(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=h0(),{validateCustomDiagram:s}=U(),[a,l]=y0(!1),c=su(!1),d=su(!1),u=Ln(async f=>{let h=nu(f.nodes,f.edges),y=ru(h),E=f.nodes.filter(({type:N,data:T})=>N==="TASK"&&(T==null?void 0:T.variant)==="SUBPROCESS");if(s&&E.length>0){let N=await iu(s,E);y={isValid:y.isValid&&N.isValid,errors:[...y.errors,...N.errors]}}let v=y.errors.map(N=>w(b({},N),{message:e(`validation.errors.${N.id}`)}));return a||l(!0),{isValid:y.isValid,errors:v}},[a,e,s]),m=Ln((f,h=!0)=>{if(h&&f&&t({variant:f.isValid?"success":"error",duration:5e3,title:f.isValid?e("validation.success.title"):e("validation.errors.title"),content:x0("div",{className:"flex flex-col gap-1",children:[!f.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:f.isValid?ai("li",{children:e("validation.success.message")}):f.errors.map(P=>ai("li",{className:"text-xs",children:P.message},P.id))})]})}),!f)return;c.current=!0,d.current=!0;let y=[],E=[];f.errors.forEach(P=>{P.nodeIds&&P.nodeIds.length>0&&P.nodeIds.forEach(H=>y.push(H)),P.edgeIds&&P.edgeIds.length>0&&P.edgeIds.forEach(H=>E.push(H))});let v=[...new Set(y)];o(P=>P.map(H=>w(b({},H),{data:w(b({},H.data),{hasError:!1})}))),n(P=>P.map(H=>w(b({},H),{data:w(b({},H.data),{hasError:!1})})));let N=r(),T=i(),_=new Set(v),A=new Set;f.errors.forEach(P=>{var Q,te;let H=Pn.find(z=>z.id===P.id);(H==null?void 0:H.highlightRelatedEdges)!==!1&&((Q=P.edgeIds)==null||Q.forEach(z=>A.add(z)),(te=P.nodeIds)==null||te.forEach(z=>{T.forEach(S=>{(S.source===z||S.target===z)&&A.add(S.id)})}))});let M=new Set,C=new Set,O=new Set;N.forEach(P=>{P.type==="START_EVENT"?M.add(P.id):P.type==="END_EVENT"&&C.add(P.id)}),T.forEach(P=>{M.has(P.source)&&O.add(P.target),C.has(P.target)&&O.add(P.source)}),O.forEach(P=>{var H,q;if(_.has(P)){let Q=(H=f.errors.find(z=>{var S;return(S=z.nodeIds)==null?void 0:S.includes(P)}))==null?void 0:H.id;((q=Pn.find(z=>z.id===Q))==null?void 0:q.highlightRelatedEdges)!==!1&&T.forEach(z=>{z.source===P&&C.has(z.target)&&(_.add(z.target),A.add(z.id)),z.target===P&&M.has(z.source)&&(_.add(z.source),A.add(z.id))})}}),_.size>0&&o(P=>P.map(H=>w(b({},H),{data:w(b({},H.data),{hasError:_.has(H.id)})}))),A.size>0&&n(P=>P.map(H=>w(b({},H),{data:w(b({},H.data),{hasError:A.has(H.id)})}))),setTimeout(()=>{c.current=!1},0)},[e,i,r,n,o,t]),p=Ln(()=>{l(!1),d.current=!1,o(f=>f.map(h=>w(b({},h),{data:w(b({},h.data),{hasError:!1})}))),n(f=>f.map(h=>w(b({},h),{data:w(b({},h.data),{hasError:!1})})))},[n,o]),g=Ln(()=>{d.current&&(c.current=!0,d.current=!1,o(f=>f.map(h=>w(b({},h),{data:w(b({},h.data),{hasError:!1})}))),n(f=>f.map(h=>w(b({},h),{data:w(b({},h.data),{hasError:!1})}))),setTimeout(()=>{c.current=!1},0))},[n,o]),x=Ln(()=>c.current,[]);return{validateDiagram:u,handleValidationComplete:m,clearValidation:p,dismissValidationPanel:g,isAutoValidationEnabled:a,getIsClearingValidation:x}};import{useReactFlow as E0}from"@xyflow/react";import{useTranslation as b0}from"@produto-lecom/lecom-ui";import{useEffect as _0}from"react";var T0=15,lu="bpmn:selection",N0=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},cu=e=>{if(!N0(e.target))return!0;let t=window.getSelection(),o=t&&t.toString().length>0;if(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement){let n=e.target;return n.selectionStart===n.selectionEnd&&!o}return!o},du=({offset:e=T0,saveHistory:t})=>{let{t:o}=b0(),{getNodes:n,setNodes:r,getEdges:i,setEdges:s}=E0(),{getNextId:a}=st(),{mode:l}=U();_0(()=>{if(l!=="edit")return;let c=u=>{var y,E;if(!cu(u))return;let m=n(),p=i(),g=m.filter(v=>v.selected);if(!g.length)return;u.preventDefault(),u.stopPropagation();let x=p.filter(v=>g.some(N=>N.id===v.source)&&g.some(N=>N.id===v.target)),h=JSON.stringify({nodes:g,edges:x});(y=u.clipboardData)==null||y.setData(lu,h),(E=u.clipboardData)==null||E.setData("text/plain",`BPMN Selection: ${g.length} nodes`)},d=u=>{var A,M;if(!cu(u))return;let m=(A=u.clipboardData)==null?void 0:A.getData(lu);if(!m)return;u.preventDefault(),u.stopPropagation();let p;try{p=JSON.parse(m)}catch(C){return}if(!((M=p.nodes)!=null&&M.length))return;let g=new Map,x=n(),f=[],h=p.nodes.filter(C=>zt(C.type,x));if(h.length===0)return;let y=a(),E=h.map(C=>{var H;let O=String(y++);g.set(C.id,O);let P=w(b({},C),{id:O,selected:!0,position:{x:C.position.x+e,y:C.position.y+e}});if(C.type==="TASK"){let q=(H=C.data)==null?void 0:H.label,Q=Wo(q||o("bpmn.task.label.prefix"),[...x,...f]);P.data=w(b({},C.data),{label:Q})}return f.push(P),P}),v=p.edges.map(C=>w(b({},C),{id:String(y++),selected:!0,source:g.get(C.source)||C.source,target:g.get(C.target)||C.target})),N=[...x.map(C=>w(b({},C),{selected:!1})),...E],_=[...i().map(C=>w(b({},C),{selected:!1})),...v];r(N),s(_),t("forceSave",{nodes:N,edges:_})};return document.addEventListener("copy",c,!0),document.addEventListener("paste",d,!0),()=>{document.removeEventListener("copy",c,!0),document.removeEventListener("paste",d,!0)}},[n,r,i,s,a,e,o,t,l])};import{useTranslation as v0}from"@produto-lecom/lecom-ui";import{useReactFlow as w0}from"@xyflow/react";import{useState as I0}from"react";var A0=50,uu=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let{draggableNode:r,setDraggableNode:i}=Yo(),{t:s}=v0(),{getInternalNode:a,getNodes:l,getEdges:c,screenToFlowPosition:d}=w0(),{getNextId:u}=st(),{setIsDragging:m}=U(),{getInternalNodes:p}=Jr(),{rebuildIndex:g,forceRebuildIndex:x}=Ir(),[f,h]=I0(null),y=(S,V,R)=>{var L;if(S.parentId!==V)return null;let I=R.filter(k=>k.id!==S.id&&k.parentId===V&&k.type==="LANE").sort((k,D)=>k.position.y-D.position.y);if(I.length===0)return null;let Y=(L=R.find(k=>k.id===S.id))!=null?L:S,B=I.find(k=>Y.position.y<k.position.y);return B?{draggedLaneId:S.id,beforeLaneId:B.id}:{draggedLaneId:S.id,afterLaneId:I[I.length-1].id}},E=(S,V=!1,R)=>{let I=V?"node-drop-target-error":"node-drop-target",Y=V?"node-drop-target-lane-error":"node-drop-target-lane";t(B=>{var k;let L=(k=R==null?void 0:R(B))!=null?k:null;return B.map(D=>{let F=[];return D.id===S&&F.push(I),S!==void 0&&D.parentId===S&&D.type==="LANE"&&D.id!==(L==null?void 0:L.draggedLaneId)&&F.push(Y),D.id===(L==null?void 0:L.draggedLaneId)&&F.push("lane-reorder-dragging"),D.id===(L==null?void 0:L.beforeLaneId)&&F.push("lane-reorder-before"),D.id===(L==null?void 0:L.afterLaneId)&&F.push("lane-reorder-after"),w(b({},D),{className:F.join(" ")})})})},v=(S,V)=>{let R=p();if(S.type==="LANE"){if(V){E();return}let k=R.filter(Z=>Z.id!==S.id&&Z.type==="LANE"&&!Z.parentId),D=tn(S,k);if(!D){E();return}if(to({parentId:D.id,nodes:e,excludeTypes:["LANE"]})){E(D.id,!0);return}E(D.id,!1,Z=>y(S,D.id,Z));return}let Y=R.filter(k=>k.id!==S.id&&k.type==="LANE"),B=tn(S,Y);if(!B){E();return}if(to({parentId:B.id,nodes:e,includeTypes:["LANE"]})){E();return}E(B.id)},N=S=>{let V=a(S.id),R=S.type==="LANE"&&to({parentId:S.id,nodes:e,includeTypes:["LANE"]});v(V,R)},T=S=>S.map(V=>w(b({},V),{className:void 0})),_=S=>S.some(R=>R.dragging)?S.map(R=>R.dragging?w(b({},R),{dragging:!1}):R):S,A=(S,V)=>{let R=0;for(let I of V){if(I.id===S||I.parentId||I.type==="LANE")continue;let Y=ot(I),B=Y.y+Y.h;R=Math.max(R,B)}return R+A0},M=(S,V)=>{if(!Vi(S,V))return V;let R=A(S,V);return V.map(I=>I.id===S?w(b({},I),{position:w(b({},I.position),{y:R})}):I)},C=S=>{if(S.preventDefault(),S.dataTransfer.dropEffect="move",!(r!=null&&r.type))return;let V=d({x:S.clientX,y:S.clientY}),R={id:"__sidebar_drag__",type:r.type,position:V,measured:{width:1,height:1},internals:{positionAbsolute:V}};v(R,!1)},O=S=>{let V=S.relatedTarget;(!V||!S.currentTarget.contains(V))&&E()},P=(S,V)=>{S.preventDefault(),N(V)},H=(S,V,R)=>{var F,Z;let I=[...R],Y=V.parentId?V.parentId:V.id;if(S.parentId===V.id)return I=Gi(S,V,I),I=St(I),I=oo(Y,I),T(I);if(S.type==="LANE"){if(to({parentId:V.id,nodes:I,excludeTypes:["LANE"]})){let W=Nr(V),oe=50,le=50;return I.map($=>{var xe,me;return $.id===S.id?w(b({},$),{position:{x:(xe=f==null?void 0:f.x)!=null?xe:W.x+oe,y:(me=f==null?void 0:f.y)!=null?me:W.y2+le}}):$})}let ee=I.filter(W=>W.parentId===V.id).reduce((W,oe)=>{var le,$;return W+(($=(le=oe.measured)==null?void 0:le.height)!=null?$:0)},0),ie={x:se.HEADER_WIDTH,y:ee};return I=I.map(W=>W.id===S.id?w(b({},W),{parentId:V.id,position:ie,className:void 0}):w(b({},W),{className:void 0})),I=St(I),I=M(Y,I),I}if(to({parentId:V.id,nodes:I,includeTypes:["LANE"]})){let X;if(S.parentId){let J=a(S.parentId),{x:ee,y:ie}=ot(J);X={x:ee+((F=S.position.x)!=null?F:0),y:ie+((Z=S.position.y)!=null?Z:0)}}return I=I.map(J=>J.id===S.id?w(b({},J),{position:X!=null?X:J.position,parentId:void 0,className:void 0}):w(b({},J),{className:void 0})),I=oo(Y,I),I}let k=sa(S,V);I=I.map(X=>X.id===S.id?w(b({},X),{parentId:V.id,position:k,className:void 0}):w(b({},X),{className:void 0}));let D=I.find(X=>X.id===S.id);return I=Gi(D,V,I),I=St(I),I=oo(Y,I),I},q=S=>{if(S.preventDefault(),!(r!=null&&r.type))return;if(!zt(r.type,l())){m(!1),i(null);return}let V=d({x:S.clientX,y:S.clientY}),R={width:ue[r.type].MIN_WIDTH,height:ue[r.type].MIN_HEIGHT},I=u(),Y={id:String(I),type:r.type,position:V,measured:R,data:{label:r.type==="TASK"?jr(e,s("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},B=w(b({},Y),{internals:{positionAbsolute:V}}),L=w(b({},B),{measured:{width:1,height:1}}),k=p(),D=r.type==="LANE",F=k.filter(W=>D?W.type==="LANE"&&!W.parentId:W.type==="LANE"),Z=tn(L,F),X=[...k.map(W=>w(b({},W),{selected:!1})),B];Z&&(X=H(B,Z,X)),X=eo(X),D&&!Z&&(X=M(B.id,X)),X=T(X),t(X),x();let J=S.dataTransfer.getData("sourceId"),ee=c(),ie=ee;if(J){let W={id:String(I+1),source:J,target:Y.id},oe=r.type==="ANNOTATION"?b(b({},W),ko):b(b({},W),rt);ie=ee.concat(oe),o(ie)}n("forceSave",{nodes:X,edges:ie}),m(!1),i(null)},Q=async(S,V,R)=>{let I=[...p()],Y=new Set;R.forEach(k=>{let D=a(k.id),F=k.type==="LANE",Z=I.filter(J=>J.id!==k.id&&(F?J.type==="LANE"&&!J.parentId:J.type==="LANE")),X=tn(D,Z);if(X){if(F&&to({parentId:k.id,nodes:I,includeTypes:["LANE"]})){k.parentId&&(I=z(k,I),Y.add(k.id));return}I=H(D,X,I);return}k.parentId&&(I=z(k,I),k.type==="LANE"&&Y.add(k.id))}),I=_(I);let B=R.filter(k=>k.type==="LANE"&&!k.parentId).map(k=>k.id);for(let k of B)Vi(k,I)&&f&&(I=I.map(D=>D.id===k?w(b({},D),{position:b({},f)}):D));for(let k of Y)I=M(k,I);if(R.some(k=>k.type!=="LANE"&&!k.parentId)){let k=I.filter(D=>D.type==="LANE"&&!D.parentId).map(D=>D.id);for(let D of k)I=oo(D,I)}I=eo(I),I=T(I),t(I),g(I),h(null)},te=(S,V)=>{h({x:V.position.x,y:V.position.y})},z=(S,V)=>{var Z,X,J,ee,ie,W,oe,le;let R=a(S.parentId);if(!R)return V;let I=S.type==="LANE",Y=V.filter($=>$.parentId===R.id&&$.id!==S.id),B=Y.filter($=>$.type==="LANE"),L;if(I&&B.length===0)L=se.MIN_HEIGHT;else if(I){let $=(X=(Z=S.measured)==null?void 0:Z.height)!=null?X:se.MIN_HEIGHT;L=((ee=(J=R.measured)==null?void 0:J.height)!=null?ee:se.MIN_HEIGHT)-$,L=Math.max(se.MIN_HEIGHT,L)}else L=Y.length>0?Y.reduce(($,xe)=>{var me,be;return $+((be=(me=xe.measured)==null?void 0:me.height)!=null?be:0)},0)+ve:Math.max(se.MIN_HEIGHT,(W=(ie=R.measured)==null?void 0:ie.height)!=null?W:0);let{x:k,y:D}=ot(R),F={x:k+((oe=S.position.x)!=null?oe:0),y:D+((le=S.position.y)!=null?le:0)};return V=V.map($=>$.id===S.id?w(b({},$),{position:F,parentId:void 0}):$.id===R.id?w(b({},$),{height:L,measured:w(b({},$.measured),{height:L})}):$),V=St(V),V};return{onDragOver:C,onDragLeave:O,onDrop:q,onNodeDrag:P,onNodeDragStart:te,onNodeDragStop:Q}};import{useReactFlow as C0}from"@xyflow/react";import{useTranslation as S0}from"@produto-lecom/lecom-ui";import{useEffect as M0}from"react";var P0=30,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},R0=e=>!L0(e.target),pu=({offset:e=P0,saveHistory:t})=>{let{t:o}=S0(),{getNodes:n,setNodes:r,getEdges:i,setEdges:s}=C0(),{getNextId:a}=st(),{mode:l}=U();M0(()=>{if(l!=="edit")return;let c=d=>{if(d.ctrlKey&&d.key.toLowerCase()==="d"&&R0(d)){d.preventDefault(),d.stopPropagation();let u=n(),m=i(),p=u.filter(_=>_.selected);if(!p.length)return;let g=new Map,x=[],f=p.filter(_=>zt(_.type,u));if(f.length===0)return;let h=m.filter(_=>f.some(A=>A.id===_.source)&&f.some(A=>A.id===_.target)),y=a(),E=f.map(_=>{var C;let A=String(y++);g.set(_.id,A);let M=w(b({},_),{id:A,selected:!0,position:{x:_.position.x+e,y:_.position.y+e}});if(_.type==="TASK"){let O=(C=_.data)==null?void 0:C.label,P=Wo(O||o("bpmn.task.label.prefix"),[...u,...x]);M.data=w(b({},_.data),{label:P})}return x.push(M),M}),v=h.map(_=>w(b({},_),{id:String(y++),selected:!0,source:g.get(_.source)||_.source,target:g.get(_.target)||_.target})),N=[...u.map(_=>w(b({},_),{selected:!1})),...E],T=[...m.map(_=>w(b({},_),{selected:!1})),...v];r(N),s(T),t("forceSave",{nodes:N,edges:T})}};return document.addEventListener("keydown",c,!0),()=>{document.removeEventListener("keydown",c,!0)}},[n,r,i,s,a,e,o,t,l])};import{useEffect as k0,useRef as fu}from"react";import{useReactFlow as D0}from"@xyflow/react";var O0=20,V0=50,Rn={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},H0=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},mu=e=>{let{getNodes:t}=D0(),{mode:o,isMoveTool:n}=U(),r=fu(0),i=fu(new Map);k0(()=>{let s=a=>{if(o!=="edit"||!n||H0(a.target)||!Object.values(Rn).includes(a.key))return;let u=t().filter(y=>y.selected);if(u.length===0){i.current.clear();return}a.preventDefault();let m=Date.now(),p=m-r.current<500;r.current=m;let g=a.shiftKey?V0:O0,x=0,f=0;switch(a.key){case Rn.UP:f=-g;break;case Rn.DOWN:f=g;break;case Rn.LEFT:x=-g;break;case Rn.RIGHT:x=g;break}let h=u.map(y=>{let E=i.current.get(y.id);(!p||!E)&&(E={x:y.position.x,y:y.position.y});let v={x:E.x+x,y:E.y+f};return i.current.set(y.id,v),{id:y.id,dragging:!0,type:"position",position:v}});e&&e(h)};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t,e,o,n])};import{useReactFlow as B0}from"@xyflow/react";var hu={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},yu={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},gu=(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}},G0=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=gu(i[0],o),a=gu(i[1],o);s&&a&&n.push({sourceId:s.step,targetId:a.step,label:s.edgeLabel||a.edgeLabel||""})}),{components:o,connections:n}},xu=e=>{let{components:t,connections:o}=G0(e);return{nodes:t,edges:o}};var Eu=()=>{let{setNodes:e,setEdges:t,fitView:o}=B0(),{getNextId:n}=st();return{importFromLia:i=>{let s=typeof i=="string"?i:i.diagramXml||"",{nodes:a,edges:l}=xu(s),c=[],d=new Map,u=!1,m=n();for(let[f,h]of Object.entries(a)){let y=String(m++),E=hu[h.type],v=yu[h.type];E==="START_EVENT"&&(u=!0),d.set(f,y);let N=ue[E].MIN_WIDTH,T=ue[E].MIN_HEIGHT;c.push({id:y,type:E,data:{label:h.label||"",variant:v,attribute:""},position:{x:0,y:0},width:N,height:T,measured:{width:N,height:T}})}let p=[];for(let f of l){let h=w(b({},rt),{id:String(m++),source:d.get(f.sourceId)||f.sourceId,target:d.get(f.targetId)||f.targetId});p.push(h)}if(!u&&c.length>0){let f=String(m++),h={id:f,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(h);let y=c[1];if(y){let E=w(b({},rt),{id:String(m++),source:f,target:y.id});p.unshift(E)}}let{nodes:g,edges:x}=Jc(c,p);e(g),t(x),o({padding:Xo,minZoom:Uo,maxZoom:$o})}}};import{useCallback as z0,useEffect as Y0}from"react";var W0={origin:"*",debug:!1};function li(e,t=W0){let{origin:o,debug:n}=t,r=z0((i,s)=>{let a={event:i,data:s};window.parent.postMessage(a,o||"*")},[o]);return Y0(()=>{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 X0}from"@xyflow/react";import{useEffect as ci,useRef as ws}from"react";var bu=()=>{let e=X0(),{initialDiagram:t,isNewDiagram:o,setIsInitialized:n,onElementChanges:r}=U(),{importFromMxGraph:i,exportToMxGraph:s}=Ko(),{sendMessage:a}=li(),l=ws(t),c=ws(r),d=ws(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 m;if(await Bn(),n(!0),a("INIT_MODELER",l.current),!o){let p=d.current();(m=c.current)==null||m.call(c,p)}})()},[e,o,n,a])};import{useCallback as _u}from"react";import{useReactFlow as U0}from"@xyflow/react";function Tu(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=ro(),{getEdges:n}=U0(),r=Kn(),i=_u(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=_u(()=>{t(),setTimeout(()=>{r()},0)},[t,r]);return{handleTasksStatus:i,handleClearTaskStatus:s}}import{useReactFlow as $0}from"@xyflow/react";import{useCallback as Lt,useState as K0,useEffect as Nu}from"react";import{useDebouncedCallback as q0}from"use-debounce";var Z0=500,vu=100,wu=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=$0(),{mode:i}=U(),[s,a]=K0({history:[],currentStep:0}),{history:l,currentStep:c}=s,d=c>0,u=c<l.length-1,m=Lt((T,_)=>{n(T[_].nodes),r(T[_].edges)},[n,r]),p=Lt(()=>{if(c>0){let T=c-1;a(_=>w(b({},_),{currentStep:T})),m(l,T)}},[c,l,m]),g=Lt(()=>{if(c<l.length-1){let T=c+1;a(_=>w(b({},_),{currentStep:T})),m(l,T)}},[l,c,m]),x=Lt(T=>{a(_=>{let A=_.history[_.currentStep];if(A&&JSON.stringify(A)===JSON.stringify(T))return _;let O=[..._.history.slice(0,_.currentStep+1),T],P=O.length>vu?O.slice(O.length-vu):O;return{history:P,currentStep:P.length-1}})},[]),f=Lt((T,_)=>{let A=T.map(C=>w(b({},C),{selected:!1,className:"",data:w(b({},C.data),{hasError:!1})})),M=_.map(C=>w(b({},C),{data:w(b({},C.data),{hasError:!1})}));return{nodes:eo(A),edges:M}},[]),h=Lt(()=>f(t(),o()),[t,o,f]),y=q0(()=>{let T=h();x(T)},Z0),E=Lt((T,_)=>{if(!e)return;if(l.length===0){let C=h();a({history:[C],currentStep:0})}if(T==="forceSave"){if(_){x(f(_.nodes,_.edges));return}y();return}T.some(C=>C.type==="select")||T.some(C=>C.type==="position"&&C.dragging)||y()},[e,y,l.length,h,x,f]);Nu(()=>{if(e&&l.length===0){let T=h();a({history:[T],currentStep:0})}},[e,l.length,h]);let v=Lt(T=>{a({history:T||[],currentStep:0})},[]),N=Lt(()=>{a({history:[],currentStep:0})},[]);return Nu(()=>{if(i!=="edit")return;let T=_=>{(_.ctrlKey||_.metaKey)&&(_.shiftKey&&_.key.toLowerCase()==="z"?(_.preventDefault(),g()):_.key.toLowerCase()==="z"&&(_.preventDefault(),p()))};return document.addEventListener("keydown",T),()=>{document.removeEventListener("keydown",T)}},[p,g,i]),{history:l,undo:p,redo:g,canUndo:d,canRedo:u,saveHistory:E,resetHistory:v,clearHistory:N}};var Iu=()=>{let{t:e}=J0(),[t,o,n]=j0([]),[r,i,s]=Q0([]),{getNodes:a,getNode:l}=tx(),{toast:c}=We(),d=ox(),{instanceId:u,isInitialized:m,setIsConnecting:p,setIsMultipleSelection:g,onElementClick:x}=U(),{updateHelperLines:f,HelperLines:h}=Ir(),{undo:y,redo:E,canUndo:v,canRedo:N,saveHistory:T}=wu(m),{onNodeDrag:_,onDrop:A,onDragOver:M,onDragLeave:C,onNodeDragStop:O,onNodeDragStart:P}=uu({nodes:t,setNodes:o,setEdges:i,saveHistory:T}),{isValidConnection:H,onConnect:q,onReconnect:Q,onReconnectStart:te,onReconnectEnd:z,setReconnectingEdge:S,clearReconnectingEdge:V}=Jd({setEdges:i,saveHistory:T}),{handleValidationComplete:R,clearValidation:I,dismissValidationPanel:Y,validateDiagram:B,getIsClearingValidation:L}=au(),{importFromLia:k}=Eu(),{handleTasksStatus:D,handleClearTaskStatus:F}=Tu(),{clearPathEdges:Z}=ro(),{emitElementChanges:X,handleNodeChanges:J,handleEdgeChanges:ee}=ii(),ie=Kn();du({saveHistory:T}),pu({saveHistory:T}),bu();let W=bt(()=>{o([]),i([]),Z(),setTimeout(ie,0)},[o,i,Z,ie]),{selectElements:oe,clearSelection:le}=Yt(),{importFromMxGraph:$,exportToMxGraph:xe}=Ko(),{configureElement:me,getConfigureElement:be}=kr(),K=bt(he=>{he!=null&&he.id&&oe([he.id])},[oe]),{sendMessage:de}=li({LIA_CREATE_DIAGRAM:k,CLEAR_DIAGRAM:W,TASKS_STATUS:D,CLEAR_TASKS_STATUS:F,EXTERNAL_TASK_SELECT:K}),re=bt(()=>t.length+r.length,[t,r]);nx(()=>(Et.set(u,{importFromMxGraph:$,exportToMxGraph:xe,selectElements:oe,clearSelection:le,configureElement:me,getConfigureElement:be,getElementsCount:re,setReconnectingEdge:S,clearReconnectingEdge:V}),()=>{Et.delete(u)}),[u,$,xe,oe,le,me,be,re,S,V]);let j=bt((he,fe)=>{if(fe.type!=="TASK"&&fe.type!=="GATEWAY")return;let pe=be(fe.id);pe&&(x==null||x(pe)),fe.type==="TASK"&&de("SELECT_TASK",{id:fe.id})},[be,x,de]),ge=bt((he,fe)=>{if(fe.type!=="SEQUENCE_EDGE")return;let pe=l(fe.source),Ne=l(fe.target),{isFromStartEvent:Ke,isGatewayToGateway:et,isActiviyToAndGateway:Be,isToEndEvent:mt}=$n(pe,Ne);if(!(!Ke&&!et&&!Be&&!mt))return;let Tt=be(fe.id);Tt&&(x==null||x(Tt))},[be,l,x]),_e=bt(he=>{let fe=f(he,t);n(fe),T(he),L()||Y(),J(he)},[t,n,T,L,Y,f,J]),Te=bt(he=>{s(he),T(he),L()||Y(),ee(he)},[s,T,L,Y,ee]);mu(_e);let Re=bt(({nodes:he,edges:fe})=>{g(he.length+fe.length>=2)},[g]);ex({onChange:Re});let je=bt(async({nodes:he})=>he.some(pe=>pe.type==="LANE"&&t.some(Ne=>Ne.parentId===pe.id))?(c({variant:"error",title:e("validation.errors.title"),content:e("editor.toolbar.delete_pool_lane_error")}),!1):!0,[t,e,c]),_t=()=>{T("forceSave"),X(),Y()},pt=()=>{p(!0)},ft=()=>{p(!1),Y()},$e=bt(he=>{let fe=new Set(he.filter(pe=>pe.type==="LANE"&&!!pe.parentId).map(pe=>pe.parentId));fe.size!==0&&setTimeout(()=>{var Ke,et;let pe=a(),Ne=new Map(pe.map(Be=>[Be.id,Be]));for(let Be of fe){let mt=no(pe.filter(Nt=>Nt.type==="LANE"&&Nt.parentId===Be));if(mt.length===0)continue;let kt=0;for(let Nt of mt)Ne.set(Nt.id,w(b({},Nt),{position:{x:se.HEADER_WIDTH,y:kt}})),kt+=(et=(Ke=Nt.measured)==null?void 0:Ke.height)!=null?et:0;let Tt=Ne.get(Be);Tt&&Ne.set(Be,w(b({},Tt),{height:kt,measured:w(b({},Tt.measured),{height:kt})}))}o(pe.map(Be=>{var mt;return(mt=Ne.get(Be.id))!=null?mt:Be}))},0)},[a,o]);return{nodes:t,setNodes:o,edges:r,setEdges:i,events:{isValidConnection:H,onConnect:q,onReconnect:Q,onReconnectStart:te,onReconnectEnd:z,onDrop:A,onDragOver:M,onDragLeave:C,onNodeDrag:_,onNodeDragStop:O,onNodeDragStart:P,onNodeClick:j,onEdgeClick:ge,onDropCapture:_t,onConnectStart:pt,onConnectEnd:ft,onSelectionEnd:()=>setTimeout(()=>d.setState({nodesSelectionActive:!1}),0),onNodesChange:_e,onEdgesChange:Te,onBeforeDelete:je,onNodesDelete:$e},ui:{handleCloseValidationPanel:I},controls:{undo:y,redo:E,canUndo:v,canRedo:N},components:{HelperLines:h},actions:{saveHistory:T,selectElements:oe,clearSelection:le,exportToMxGraph:xe,validateDiagram:B,handleValidationComplete:R,setReconnectingEdge:S,clearReconnectingEdge:V}}};import{useReactFlow as rx}from"@xyflow/react";import{useCallback as ix,useEffect as sx,useRef as ax,useState as lx}from"react";var cx=".react-flow__node, .react-flow__edge, .react-flow__node-toolbar";function Au(e,t,o){let[n,r]=lx(!1),i=ax(null),{getViewport:s,setViewport:a}=rx(),l=ix(()=>{i.current=null,r(!1)},[]);return sx(()=>{let c=e.current;if(!c)return;let d=p=>{if(!Cn.some(x=>x===p.button)||t.current||o.current||(r(!0),!(p.target instanceof Element))||!p.target.closest(cx))return;p.preventDefault(),p.stopPropagation();let g=s();i.current={pointerX:p.clientX,pointerY:p.clientY,viewportX:g.x,viewportY:g.y,zoom:g.zoom}},u=p=>{let g=i.current;if(g){if((p.buttons&vs)===0){l();return}a({x:g.viewportX+(p.clientX-g.pointerX),y:g.viewportY+(p.clientY-g.pointerY),zoom:g.zoom})}},m=p=>{(p.buttons&vs)===0&&l()};return c.addEventListener("pointerdown",d,!0),window.addEventListener("pointermove",u),window.addEventListener("pointerup",m),window.addEventListener("pointercancel",l),window.addEventListener("blur",l),()=>{c.removeEventListener("pointerdown",d,!0),window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",m),window.removeEventListener("pointercancel",l),window.removeEventListener("blur",l)}},[e,t,o,s,a,l]),n}import{jsx as Cu}from"react/jsx-runtime";var di=({id:e,className:t})=>Cu("marker",{id:e,className:G("react-flow__arrowhead",t),viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"7",markerHeight:"7",orient:"auto",markerUnits:"userSpaceOnUse",fill:"currentColor",stroke:"currentColor",children:Cu("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as ui,jsxs as dx}from"react/jsx-runtime";var Su=()=>ui("svg",{style:{position:"absolute",top:0,left:0},children:dx("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 kE,TooltipContent as DE,TooltipTrigger as OE,useTranslation as VE}from"@produto-lecom/lecom-ui";import{useKeyPress as Ku,useReactFlow as tE}from"@xyflow/react";import{Button as xi,Tooltip as Ei,TooltipContent as bi,TooltipTrigger as _i,useTranslation as oE}from"@produto-lecom/lecom-ui";import{HandIcon as nE,ListCheckIcon as rE,Loader2Icon as iE,MapIcon as sE,MousePointerIcon as aE}from"lucide-react";import{useCallback as Ss,useEffect as qu,useState as lE}from"react";import{Tooltip as Mx,TooltipContent as Px,TooltipTrigger as Lx,useTranslation as Rx}from"@produto-lecom/lecom-ui";var kn=(E=>(E.START_EVENT="START_EVENT",E.END_EVENT="END_EVENT",E.TASK="TASK",E.SUBPROCESS="SUBPROCESS",E.GATEWAY="GATEWAY",E.LANE="LANE",E.ANNOTATION="ANNOTATION",E.CONNECTION="CONNECTION",E.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",E.ACTIVITY="ACTIVITY",E.PROCESS_INTERFACE="PROCESS_INTERFACE",E.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",E.VARIANT_ACTIVITY="VARIANT_ACTIVITY",E.AUTO_ACTIVITY="AUTO_ACTIVITY",E.DATA_STORE="DATA_STORE",E.DATA_OBJECT="DATA_OBJECT",E.DATA_OUTPUT="DATA_OUTPUT",E.DATA_INPUT="DATA_INPUT",E.MARKER="MARKER",E))(kn||{});import{Button as Tx,useTranslation as Nx}from"@produto-lecom/lecom-ui";import{useReactFlow as vx}from"@xyflow/react";var Mu=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 Pu({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);pi(i,`${o}.csv`)}var pi=(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
|
|
39
|
+
</mxGraphModel>`,ed=(e,t)=>{if(!e.length&&!t.length)return vn;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var Hh=e=>{let t=Object.values(Nn),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=Wc[s],l=a==null?void 0:a(i,n);if(!l){console.warn(`Node ${s} not supported`);continue}r.push(l)}return r},Gh=(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=Fc(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},Bh=(e,t)=>{let o=[];return e.forEach(n=>{var s,a;let r=(a=(s=Uc)[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=$c(n,t);o.push(l)}}),o},zh=(e,t)=>{let o=[];return e.forEach(n=>{let r=Xc(n,t);o.push(r)}),o},Yh=(e=[],t=[],o)=>{let n=Bh(e,o),r=zh(t,e);return{mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}}},td=(e=[],t=[],o)=>{let n=Yh(e,t,o);return Vc(JSON.stringify(n),{compact:!0,spaces:0})},od=async e=>{var c,d,u,m,p;let t=await qr(e),o=((d=(c=t==null?void 0:t.mxGraphModel)==null?void 0:c.root)==null?void 0:d.mxCell)||[],n=Number(((p=(m=(u=t==null?void 0:t.mxGraphModel)==null?void 0:u.root)==null?void 0:m._attributes)==null?void 0:p.lastId)||vn),r=Hh(o),i=Gh(o,r),s=Jc(r),{nodes:a,edges:l}=aa(s,i);return{lastElementId:n,edges:l,nodes:eo(a)}};import{Position as Ut,useConnection as wy,useReactFlow as Iy}from"@xyflow/react";import{useCallback as hs}from"react";import{Handle as nd,useReactFlow as Wh}from"@xyflow/react";import{jsx as rd}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 rd(nd,b({type:e,position:t,className:G("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":a,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":!a},o)},r))},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}=Wh(),m=(()=>{if(n!=="source")return!1;let p=c();if(t==="TASK")return p.filter(E=>E.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return p.filter(E=>E.source===e).length>=2;if(t==="START_EVENT"){let h=d();return p.filter(f=>{if(f.source!==e)return!1;let g=h.find(y=>y.id===f.target);return(g==null?void 0:g.type)!=="ANNOTATION"}).length>=1}return!1})();return rd(nd,b({type:n,position:r,className:G("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":m,"hover:border-grey-500":!m},i),style:{pointerEvents:m?"none":"auto"}},s))};import{useRef as id}from"react";import{NodeResizeControl as sd,ResizeControlVariant as Xh,useReactFlow as Uh,useStoreApi as $h}from"@xyflow/react";import{useStoreApi as Fh}from"@xyflow/react";var Jr=()=>{let e=Fh();return{getInternalNodes:()=>{let{nodeLookup:o}=e.getState();return Array.from(o.values())}}};import{Fragment as Zh,jsxs as Jh}from"react/jsx-runtime";import{createElement as ad}from"react";var Kh=["top","right","bottom","left"],qh=["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}=Uh(),{getInternalNodes:l}=Jr(),{isMultipleSelection:c}=U(),d=$h(),u=id(0),m=id([]),p=({y:g,width:y,height:x})=>{cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{var K,te;if(!e)return;let{nodeLookup:w,onNodesChange:_}=d.getState(),N=w.get(e);if(!N||N.type!=="LANE")return;let T=!N.parentId,I=T?N.id:N.parentId;if(!I)return;let C=Array.from(w.values()).filter(z=>z.type==="LANE"&&z.parentId===I);if(!C.length)return;m.current.length===0&&(m.current=no(C).map(z=>z.id));let P=m.current.map(z=>C.find(M=>M.id===z)).filter(Boolean),R=[],S=0,L=P.findIndex(z=>z.id===N.id),$=!T&&L>0&&Math.abs(g-N.position.y)>.5;for(let z=0;z<P.length;z++){let M=P[z],H=M.id===N.id,D=z===P.length-1;if(H){S=$?g+x:S+x;continue}let A=(te=(K=M.measured)==null?void 0:K.height)!=null?te:0,Y=T?y-se.HEADER_WIDTH:y,B=A;T&&D&&(B=Math.max(se.MIN_HEIGHT,x-S)),$&&z===L-1&&(B=Math.max(se.MIN_HEIGHT,g-S)),R.push({id:M.id,type:"dimensions",dimensions:{width:Y,height:B},setAttributes:!0}),R.push({id:M.id,type:"position",position:{x:se.HEADER_WIDTH,y:S}}),S+=B}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:S},setAttributes:!0}),_==null||_(R)})},h=({y:g,width:y,height:x})=>{var N;if(cancelAnimationFrame(u.current),m.current=[],!e)return;let w=s(e);if(!w||w.type!=="LANE"&&!w.parentId)return;let _=[...l()];if(w.type!=="LANE"){_=_.map(T=>T.id===e?v(b({},T),{width:y,height:x,measured:{width:y,height:x}}):T),_=St(_),a(_);return}_=ua(w,y,x,_,g),_=St(_),_=oo((N=w.parentId)!=null?N:w.id,_),a(_)};if(!(!c&&t))return null;let f={"--resize-offset":`${o}px`};return Jh(Zh,{children:[Kh.map(g=>ad(sd,v(b({},n),{key:g,nodeId:e,position:g,variant:Xh.Line,className:"border-blue-400/90 border-dashed",style:f,onResize:(y,x)=>p(x),onResizeEnd:(y,x)=>h(x)}))),qh.map(g=>ad(sd,v(b({},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:f,onResize:(y,x)=>p(x),onResizeEnd:(y,x)=>h(x)})))]})};import{NodeToolbar as gy,useReactFlow as hy}from"@xyflow/react";import{Button as yy,Tooltip as xy,TooltipContent as Ey,TooltipTrigger as by,useTranslation as _y}from"@produto-lecom/lecom-ui";import{useCallback as gs,useEffect as Ty,useRef as Qr,useState as Ny}from"react";import{create as Qh}from"zustand";var Yo=Qh(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{useEffect as jh,useState as ey}from"react";var ld=(e,t=!1)=>{let[o,n]=ey({width:0,height:0});return jh(()=>{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 ty}from"@xyflow/react";import{useMemo as oy}from"react";var ny=120,ry=12,cd=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=ty(),{instanceId:i}=U();return oy(()=>{var p,h;if(!t)return{position:wn.Right,align:"start"};let s=n(e);if(!s)return{position:wn.Right,align:"start"};let a=r(),l=s.position.x*a.zoom+a.x,c=(((p=s.measured)==null?void 0:p.width)||s.width||100)*a.zoom,d=(h=document.getElementById(`modeler-${i}`))==null?void 0:h.clientWidth;if(!d)return{position:wn.Right,align:"start"};let u=(o==null?void 0:o.width)||ny;return{position:l+c+u+ry>d?wn.Left:wn.Right}},[i,e,t,o,n,r])};import{useNodesData as iy,useReactFlow as sy}from"@xyflow/react";import{Button as dd,DropdownMenu as ay,DropdownMenuContent as ly,DropdownMenuGroup as cy,DropdownMenuItem as dy,DropdownMenuLabel as uy,DropdownMenuTrigger as py,Tooltip as ps,TooltipContent as fs,TooltipTrigger as ms,useTranslation as fy}from"@produto-lecom/lecom-ui";import{WrenchIcon as my}from"lucide-react";import{jsx as Oe,jsxs as mo}from"react/jsx-runtime";var ud=({nodeId:e})=>{let{t}=fy(),{updateNodeData:o,getEdges:n,getNode:r}=sy(),i=iy(e),a=n().filter(p=>p.source===e).some(p=>{let h=r(p.target);return(h==null?void 0:h.type)==="END_EVENT"}),l=(i==null?void 0:i.data.variant)==="SUBPROCESS",c=u=>{o(e,{variant:(i==null?void 0:i.data.variant)===u?"":u})},d=u=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===u?"":u})};return mo(ay,{children:[mo(ps,{children:[Oe(ms,{asChild:!0,children:Oe(py,{asChild:!0,children:Oe(dd,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:Oe(my,{})})})}),Oe(fs,{color:"black",children:t("bpmn.task.menu.title")})]}),mo(ly,{align:"start",className:"w-60 bg-white text-grey-600",children:[mo(uy,{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(Fn).map(([u,m])=>{let p=u==="LOOP"&&(a||l),E=(()=>{if(u==="LOOP"&&a)return t("editor.task_menu.loop_not_allowed_when_connected_to_end");if(u==="LOOP"&&l)return t("editor.task_menu.loop_not_allowed_when_subprocess");if(u==="LOOP")return t("editor.task_menu.loop")})();return mo(ps,{children:[Oe(ms,{asChild:!0,children:Oe(dd,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:p,className:G({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===u,"opacity-50 cursor-not-allowed":p}),onClick:p?void 0:()=>d(u),children:Oe(m.icon,{className:"stroke-inherit"})})}),E&&Oe(fs,{color:"black",children:E})]},u)})})]}),Oe(cy,{children:mo(ps,{children:[Oe(ms,{asChild:!0,children:Oe("div",{className:G({"cursor-not-allowed":a}),children:mo(dy,{className:G({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":a}),disabled:a,onClick:()=>c("SCRIPT"),children:[Oe(Wn.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),a&&Oe(fs,{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 Mt={START_EVENT:{type:"START_EVENT",icon:Jo,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:bo,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:Jo,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:Gn,label:"bpmn.annotation.variant.default"}},vy={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:To,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:No,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}=_y(),{setDraggableNode:a}=Yo(),{getEdges:l,getNodes:c,getNode:d,setNodes:u}=hy(),{setIsDragging:m,mode:p,isConnecting:h,isDragging:E,isMultipleSelection:f}=U(),g=d(e),y=!!(g!=null&&g.selected)&&!g.dragging&&!h&&!E&&!f,{dimensions:x}=ld(r,y),{position:w}=cd(e,y,x),[_,N]=Ny(void 0),T=c(),I=l(),C=o==="SUBPROCESS",P=Qr(null),R=Qr(!1),S=gs(()=>{P.current!==null&&(clearTimeout(P.current),P.current=null),R.current=!1,m(!1),a(null),N(void 0),u(V=>V.map(F=>v(b({},F),{className:void 0})))},[m,a,u]);Ty(()=>{let V=F=>{R.current&&F.buttons===0&&S()};return document.addEventListener("dragend",S),document.addEventListener("mousemove",V),()=>{document.removeEventListener("dragend",S),document.removeEventListener("mousemove",V)}},[S]);let L=gs((V,F)=>{R.current=!0,m(!1),a({type:F.type,variant:F.variant,attribute:F.attribute,icon:F.icon}),F.icon&&N(Me(F.icon,{})),V.dataTransfer.effectAllowed="move",V.dataTransfer.setData("sourceId",e),i.current&&V.dataTransfer.setDragImage(i.current,10,10),P.current=setTimeout(()=>{P.current=null,m(!0)},100)},[e,a,m]),$=gs(()=>{S()},[S]),K=[{component:Me(Vr,{elementId:e})}],te=()=>{if(p==="view")return[];let V=!I.some(F=>{var J;return F.source===e&&((J=T.find(X=>X.id===F.target))==null?void 0:J.type)!=="ANNOTATION"});return[{component:Me(Po,{nodeId:e,disabled:!V,tooltipMessage:V?void 0:s("editor.toolbar.start_event_limit_reached")})},Mt.TASK,Mt.ANNOTATION,...K]},z=()=>p==="view"?[{component:Me(Wt,{elementId:e})}]:[{component:Me(Wt,{elementId:e})},...C?[]:[{component:Me(ud,{nodeId:e})}],{component:Me(Po,{nodeId:e})},Mt.TASK,{type:"TASK",variant:"SUBPROCESS",icon:jo,label:"bpmn.task.variant.subprocess"},Mt.ANNOTATION,...Object.values(vy),...uo(e,T,I)?[]:[Mt.END_EVENT],...K],M=()=>p==="view"?[{component:Me(Wt,{elementId:e,elementType:"gateway"})}]:[{component:Me(Wt,{elementId:e,elementType:"gateway"})},{component:Me(Po,{nodeId:e})},Mt.TASK,{type:"TASK",variant:"SUBPROCESS",icon:jo,label:"bpmn.task.variant.subprocess"},Mt.ANNOTATION,...K],H=()=>p==="view"?[]:[Mt.ANNOTATION,...K],D=()=>p==="view"?[]:[...n?[]:[{component:Me(Po,{nodeId:e})}],Mt.ANNOTATION,...K],A=()=>p==="view"?[]:[{component:Me(Po,{nodeId:e})},...K],Y=()=>p==="view"?[]:[...K],k=(V=>{switch(V){case"START_EVENT":return te();case"TASK":return z();case"GATEWAY":return M();case"END_EVENT":return H();case"LANE":return D();case"ANNOTATION":return A();case"UNSUPPORTED":return Y();default:return[]}})(t),O=k.length>6;if(!(k.length===0||p==="readonly"))return pd(gy,{position:w,align:"start",className:O?"-top-[4.5rem]":"-top-8",isVisible:y,children:[Me("div",{ref:r,className:`${O?"grid grid-cols-6":"flex"} gap-1 px-2 py-2 bg-white rounded-sm shadow-md`,children:k.map((V,F)=>{if(V.component)return Me("div",{children:V.component},F);let J={sourceNodeType:t,targetNodeType:V.type,sourceNodeId:e,nodes:T,edges:I},X=mc(J),Q={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")},ee=X.shouldDisable&&X.reason?Q[X.reason]||s(V.label):s(V.label)||"";return pd(xy,{children:[Me(by,{asChild:!0,children:Me(yy,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!X.shouldDisable,disabled:X.shouldDisable,className:X.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:X.shouldDisable?void 0:ie=>L(ie,V),onDragEnd:X.shouldDisable?void 0:$,children:V.icon&&Me(V.icon,{size:16})})}),Me(Ey,{color:"black",children:ee})]},F)})}),Me("div",{ref:i,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:_})]})};import{Fragment as fd,jsx as ct,jsxs as ys}from"react/jsx-runtime";var md=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r,setNodes:i}=Iy(),{inProgress:s,fromNode:a}=wy(),{mode:l,isReadOnly:c}=U(),d=s&&(a==null?void 0:a.id)!==e,u=hs(h=>{let x=h.split(`
|
|
40
|
+
`),w=x.reduce((I,C)=>Math.max(I,C.length),0),_=x.length,N=Math.max(wo.MIN_WIDTH,w*7+32),T=Math.max(wo.MIN_HEIGHT,_*20+24);i(I=>I.map(C=>C.id===e?v(b({},C),{width:N,height:T,style:v(b({},C.style),{width:N,height:T})}):C))},[e,i]),m=hs(h=>{r(e,{label:h}),u(h)},[e,r,u]),p=hs(h=>{u(h)},[u]);return ys("div",{className:G("relative w-full h-full min-w-44 min-h-16 flex text-grey-400 hover:text-grey-500 bg-white rounded-sm border-l-2 border-current before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-current after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-current hover:shadow-md transition-colors duration-75",{"pointer-events-none":c,"text-blue-500 hover:text-blue-600 shadow-md":o&&!c,"border-red-500 border-l-[3px] shadow-[0_0_5px_rgba(255,0,0,0.5)] before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-red-500 after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-red-500":t.hasError}),children:[ct(De,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:m,onInput:p,skipFirstCharValidation:!0}),ct(Fe,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&ct(it,{nodeId:e,minWidth:wo.MIN_WIDTH,minHeight:wo.MIN_HEIGHT,isVisible:!n&&o}),!s&&ys(fd,{children:[ct(ne,{type:"source",position:Ut.Left,id:"left"}),ct(ne,{type:"source",position:Ut.Right,id:"right"}),ct(ne,{type:"source",position:Ut.Top,id:"top"}),ct(ne,{type:"source",position:Ut.Bottom,id:"bottom"})]}),(!s||d)&&ys(fd,{children:[ct(ne,{type:"target",position:Ut.Left,id:"left",className:G({"annotation-handle":d})}),ct(ne,{type:"target",position:Ut.Right,id:"right",className:G({"annotation-handle":d})}),ct(ne,{type:"target",position:Ut.Top,id:"top",className:G({"annotation-handle":d})}),ct(ne,{type:"target",position:Ut.Bottom,id:"bottom",className:G({"annotation-handle":d})})]})]})};import{Position as $t,useConnection as Ay,useReactFlow as Cy}from"@xyflow/react";import{useState as Sy}from"react";import{Fragment as gd,jsx as qe,jsxs as xs}from"react/jsx-runtime";var hd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=Cy(),{inProgress:i,fromNode:s}=Ay(),{mode:a,isReadOnly:l,reconnectingEdgeId:c}=U(),[d,u]=Sy(!1),m=i&&(s==null?void 0:s.id)!==e||!!c,p=f=>{r(e,{label:f})},h=()=>{u(!0)},E=()=>{u(!1)};return xs("div",{className:"relative",onDoubleClick:h,children:[qe(bo,{className:G("w-full h-full min-w-9 min-h-9 hover:stroke-[#d33b3b] transition-colors duration-75",{"pointer-events-none":l,"stroke-blue-500 hover:stroke-blue-600":o&&!l,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),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:p})}),qe(Fe,{nodeId:e,nodeType:"END_EVENT"}),a==="edit"&&qe(it,{nodeId:e,isVisible:!n&&o,minWidth:Un.MIN_WIDTH,minHeight:Un.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||m)&&xs(gd,{children:[qe(ne,{type:"target",position:$t.Left,id:"left",className:G({"event-handle":m})}),qe(ne,{type:"target",position:$t.Right,id:"right",className:G({"event-handle":m})}),qe(ne,{type:"target",position:$t.Top,id:"top",className:G({"event-handle":m})}),qe(ne,{type:"target",position:$t.Bottom,id:"bottom",className:G({"event-handle":m})})]}),!i&&xs(gd,{children:[qe(ne,{type:"source",position:$t.Left,id:"left"}),qe(ne,{type:"source",position:$t.Right,id:"right"}),qe(ne,{type:"source",position:$t.Top,id:"top"}),qe(ne,{type:"source",position:$t.Bottom,id:"bottom"})]})]})};import{Position as Kt,useConnection as My,useReactFlow as Py}from"@xyflow/react";import{useCallback as Ly,useState as Ry}from"react";import{Fragment as yd,jsx as Ze,jsxs as Es}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}=Py(),{inProgress:l,fromNode:c}=My(),{mode:d,isReadOnly:u,reconnectingEdgeId:m}=U(),[p,h]=Ry(!1),E=l&&(c==null?void 0:c.id)!==e||!!m,f=Ly(x=>{a(e,{label:x})},[e,a]),g=()=>{h(!0)},y=()=>{h(!1)};return Es("div",{className:"relative",style:{width:o!=null?o:vo.MIN_WIDTH,height:n!=null?n:vo.MIN_HEIGHT},onDoubleClick:g,children:[Ze(s,{className:G("w-full h-full min-w-14 min-h-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"pointer-events-none":u,"stroke-blue-500 hover:stroke-blue-600":r&&!u,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),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:p,onBlur:y,onChange:f})}),Ze(Fe,{nodeId:e,nodeType:"GATEWAY",nodeVariant:t.variant}),d==="edit"&&Ze(it,{nodeId:e,isVisible:!i&&r,minWidth:vo.MIN_WIDTH,minHeight:vo.MIN_HEIGHT,offset:2,keepAspectRatio:!0}),(!l||E)&&Es(yd,{children:[Ze(ne,{type:"target",position:Kt.Left,id:"left",className:G({"gateway-handle":E})}),Ze(ne,{type:"target",position:Kt.Right,id:"right",className:G({"gateway-handle":E})}),Ze(ne,{type:"target",position:Kt.Top,id:"top",className:G({"gateway-handle":E})}),Ze(ne,{type:"target",position:Kt.Bottom,id:"bottom",className:G({"gateway-handle":E})})]}),!l&&Es(yd,{children:[Ze(Ge,{type:"source",position:Kt.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Ze(Ge,{type:"source",position:Kt.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Ze(Ge,{type:"source",position:Kt.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Ze(Ge,{type:"source",position:Kt.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})};import{useNodesData as NM,useReactFlow as vM}from"@xyflow/react";import{Button as IM,DropdownMenu as AM,DropdownMenuContent as CM,DropdownMenuGroup as SM,DropdownMenuItem as MM,DropdownMenuLabel as PM,DropdownMenuTrigger as LM,Tooltip as RM,TooltipContent as kM,TooltipTrigger as DM,useTranslation as OM}from"@produto-lecom/lecom-ui";import{WrenchIcon as HM}from"lucide-react";import{jsx as YM,jsxs as WM}from"react/jsx-runtime";import{Position as qt,useConnection as ky,useReactFlow as Dy}from"@xyflow/react";import{useState as Oy}from"react";import{Fragment as Ed,jsx as Je,jsxs as bs}from"react/jsx-runtime";var bd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=Dy(),{inProgress:i,fromNode:s}=ky(),{mode:a,isReadOnly:l,reconnectingEdgeId:c}=U(),[d,u]=Oy(!1),m=i&&(s==null?void 0:s.id)!==e||!!c,p=f=>{r(e,{label:f})},h=()=>{u(!0)},E=()=>{u(!1)};return bs("div",{className:"relative",onDoubleClick:h,children:[Je(zn,{className:G("w-full h-full min-w-9 min-h-9 hover:stroke-[#54890b] transition-colors duration-75",{"pointer-events-none":l,"stroke-blue-500 hover:stroke-blue-600":o&&!l,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),Je("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Je(De,{value:t.label,isEditing:d,onBlur:E,onChange:p})}),Je(Fe,{nodeId:e,nodeType:"START_EVENT"}),a==="edit"&&Je(it,{nodeId:e,isVisible:!n&&o,minWidth:Xn.MIN_WIDTH,minHeight:Xn.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||m)&&bs(Ed,{children:[Je(ne,{type:"target",position:qt.Left,id:"left",className:G({"event-handle":m})}),Je(ne,{type:"target",position:qt.Right,id:"right",className:G({"event-handle":m})}),Je(ne,{type:"target",position:qt.Top,id:"top",className:G({"event-handle":m})}),Je(ne,{type:"target",position:qt.Bottom,id:"bottom",className:G({"event-handle":m})})]}),!i&&bs(Ed,{children:[Je(Ge,{type:"source",position:qt.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),Je(Ge,{type:"source",position:qt.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),Je(Ge,{type:"source",position:qt.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),Je(Ge,{type:"source",position:qt.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};import{useTranslation as Gy}from"@produto-lecom/lecom-ui";import{Position as Zt,useConnection as By,useReactFlow as zy}from"@xyflow/react";import{useCallback as ei}from"react";var In=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<=In?i:i.substring(0,In).trim()},Wo=(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>In&&(n=n.substring(0,In).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=In-l.length,u=`${r.substring(0,c).trim()}${l}`;if(!o.has(u))return u;i++}return n};import{jsx as _d,jsxs as Vy}from"react/jsx-runtime";var Td=e=>Vy("svg",v(b({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[_d("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),_d("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as Nd}from"react/jsx-runtime";var vd=e=>Nd("svg",v(b({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:Nd("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 Hy}from"react/jsx-runtime";var Id=e=>Hy("svg",v(b({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 An}from"react/jsx-runtime";var Yy={APROVADO:Td,EM_ANDAMENTO:vd,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)]"},Wy={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}=Gy(),{toast:a}=We(),{updateNodeData:l,getNodes:c,setNodes:d}=zy(),{inProgress:u,fromNode:m}=By(),{mode:p,isReadOnly:h,onSubprocessValidationClick:E,reconnectingEdgeId:f}=U(),{getTaskStatus:g}=ro(),y=u&&(m==null?void 0:m.id)!==e||!!f,x=g(e),w=t.variant==="SUBPROCESS",_=!!t.variant&&!w||!!x,N=!!t.attribute||w,T=ei(z=>{let A=_||N?80:40,Y=z.split(`
|
|
41
|
+
`),B=Y.reduce((F,J)=>Math.max(F,J.length),0),k=Y.length,O=Math.max(Ot.MIN_WIDTH,B*7+64),V=Math.max(Ot.MIN_HEIGHT,k*24+A);d(F=>F.map(J=>J.id===e?v(b({},J),{width:O,height:V,style:v(b({},J.style),{width:O,height:V})}):J))},[e,d,_,N]),I=ei(z=>{let M=z.trim(),H=t.label||"";if(M===H)return;let D=M,A=c();if(!(M&&M!=="")){D=jr(A,s("bpmn.task.label.prefix")),l(e,{label:D}),T(D),a({variant:"warning",content:An(ti,{children:[s("bpmn.task.feedback.label_empty.prefix")," ",we("strong",{children:D})]})});return}let B=Wo(D,A);B===H||(l(e,{label:B}),T(B),B!==D&&a({variant:"warning",content:An(ti,{children:[s("bpmn.task.feedback.label_already_exists.prefix")," ",we("strong",{children:M})," ",s("bpmn.task.feedback.label_already_exists.middle")," ",we("strong",{children:B})]})}))},[t.label,c,e,s,l,T,a]),C=ei(z=>{T(z)},[T]),P=ei(()=>{a({variant:"error",content:s("bpmn.task.feedback.invalid_first_character")})},[s,a]),R=x?Yy[x]:null,S=t.variant?Wn[t.variant].icon:null,L=t.attribute?Fn[t.attribute].icon:null,$=()=>t.hasError?_s.error:x?_s[x]:h?_s.default:"",K=()=>{var z;return r&&(z=Wy[x])!=null?z:""},te=()=>{E==null||E({id:e,type:"sub_process",label:t.label})};return An("div",{className:G("relative w-full h-full min-w-44 min-h-24 flex flex-col items-stretch justify-stretch bg-white border-2 border-grey-400 hover:border-grey-500 rounded-md hover:shadow-md transition-colors duration-75",$(),{"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:Ot.MIN_WIDTH,height:n!=null?n:Ot.MIN_HEIGHT},children:[we("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:we(De,{value:t.label,maxLength:60,className:G(K(),{"py-10 px-8":_||N}),onChange:I,onInput:C,onInvalidFirstCharacter:P})}),S&&we("div",{className:G("absolute flex items-center p-1",w?"bottom-0 left-1/2 -translate-x-1/2":"top-0 left-0"),children:we(S,{size:16,className:G(t.hasError?"text-red-500":"text-grey-500",w&&"cursor-pointer"),onClick:w?te:void 0})}),L&&we("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:we("div",{className:G("flex items-center w-16 p-1",w?"justify-between":"justify-center"),children:we(L,{size:16,className:G(t.hasError?"text-red-500":"text-grey-500")})})}),R&&we("div",{className:"absolute top-0 right-0 flex items-center p-1",children:we(R,{})}),we(Fe,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),p==="edit"&&we(it,{nodeId:e,isVisible:!i&&r,minWidth:Ot.MIN_WIDTH,minHeight:Ot.MIN_HEIGHT}),(!u||y)&&An(ti,{children:[we(ne,{type:"target",position:Zt.Left,id:"left",className:G({"task-handle":y})}),we(ne,{type:"target",position:Zt.Right,id:"right",className:G({"task-handle":y})}),we(ne,{type:"target",position:Zt.Top,id:"top",className:G({"task-handle":y})}),we(ne,{type:"target",position:Zt.Bottom,id:"bottom",className:G({"task-handle":y})})]}),!u&&An(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 Cd}from"@xyflow/react";import{Fragment as Fy,jsx as oi,jsxs as Xy}from"react/jsx-runtime";var Sd=({id:e,data:t})=>Xy(Fy,{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:Cd.Right}),oi(ne,{type:"target",position:Cd.Left})]});import{BaseEdge as Uy,EdgeLabelRenderer as $y,getSmoothStepPath as Ky,MarkerType as qy,useInternalNode as Md,useReactFlow as Zy,useViewport as Jy,Position as Fo}from"@xyflow/react";import{useState as Qy,useMemo as jy}from"react";import{Fragment as Pd,jsx as Xe,jsxs as go}from"react/jsx-runtime";var A5={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:qy.Arrow},data:{label:""}},Ld=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:s,sourceHandleId:a,targetHandleId:l})=>{var B;let{zoom:c}=Jy(),{updateEdgeData:d}=Zy(),{isMultipleSelection:u,mode:m,instanceId:p}=U(),h=m!=="edit",[E,f]=Qy(!1),{reconnectingHandle:g,cursorPosition:y,hoveredNodeId:x,reconnectingSide:w,isValidReconnection:_,handleReconnectStart:N}=Ur({edgeId:e,source:t,target:o,instanceId:p,isReadOnly:h}),T=Md(t),I=Md(o),{sx:C,sy:P,tx:R,ty:S,sourcePos:L,targetPos:$}=jy(()=>{var oe,le;if(!T||!I)return{sx:0,sy:0,tx:0,ty:0,sourcePos:Fo.Left,targetPos:Fo.Right};let k=Io(T,I),O=a?i:k.sourcePos,V=l?s:k.targetPos,F=(q,xe,me)=>{var j,ge,_e,Te,Re,je;let{x:be,y:Z}=q.internals.positionAbsolute,de=(_e=(ge=(j=q.measured)==null?void 0:j.width)!=null?ge:q.width)!=null?_e:0,re=(je=(Re=(Te=q.measured)==null?void 0:Te.height)!=null?Re:q.height)!=null?je:0;switch(xe){case Fo.Top:return{x:be+de*me,y:Z};case Fo.Bottom:return{x:be+de*me,y:Z+re};case Fo.Left:return{x:be,y:Z+re*me};case Fo.Right:return{x:be+de,y:Z+re*me};default:return{x:be+de/2,y:Z+re/2}}},J=(oe=n==null?void 0:n.sourceOffset)!=null?oe:.5,X=(le=n==null?void 0:n.targetOffset)!=null?le:.5,Q=T?F(T,O,J).x:k.sx,ee=T?F(T,O,J).y:k.sy,ie=I?F(I,V,X).x:k.tx,W=I?F(I,V,X).y:k.ty;return g==="source"&&y?(Q=y.x,ee=y.y,w&&(O=w)):g==="target"&&y&&(ie=y.x,W=y.y,w&&(V=w)),{sx:Q,sy:ee,tx:ie,ty:W,sourcePos:O,targetPos:V}},[T,I,a,l,i,s,g,y,w,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!T||!I)return null;let[K,te,z]=Ky({sourceX:C,sourceY:P,targetX:R,targetY:S,sourcePosition:L,targetPosition:$}),M=r||(T==null?void 0:T.selected)||(I==null?void 0:I.selected),H=M?"sequence-edge-marker-highlighted":"sequence-edge-marker",D=E||(n==null?void 0:n.label.trim().length)>0,A=()=>{f(!1)},Y=k=>{d(e,{label:k.trim()})};return Xe(Pd,{children:go("g",{className:G("group bpmn-arrow-edge",{"is-highlighted":M}),onDoubleClick:()=>!h&&f(!0),children:[Xe("path",{d:K,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),go("g",{className:G("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":M}),children:[Xe(Uy,{id:e,path:K,interactionWidth:0,markerEnd:`url(#${H})`,strokeDasharray:4,className:G("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&&!_,"stroke-green-500":g&&x&&_,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":M&&!(n!=null&&n.hasError)&&!g})}),go($y,{children:[go("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${te}px, ${z}px)`},children:[r&&!u&&Xe(Ro,{sx:C,sy:P,tx:R,ty:S,hasLabel:!!((B=n==null?void 0:n.label)!=null&&B.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:A,onChange:Y})]}),r&&!u&&!h&&go(Pd,{children:[Xe("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${C}px, ${P}px)`},children:go("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:G("pointer-events-auto",{"cursor-move":!g||g!=="source","cursor-not-allowed":g==="source"&&x&&!_,"cursor-grabbing":g==="source"&&(!x||_)}),onMouseDown:k=>N("source",k.nativeEvent)})]})}),Xe("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${R}px, ${S}px)`},children:go("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:G("pointer-events-auto",{"cursor-move":!g||g!=="target","cursor-not-allowed":g==="target"&&x&&!_,"cursor-grabbing":g==="target"&&(!x||_)}),onMouseDown:k=>N("target",k.nativeEvent)})]})})]})]})]})]})})};import{getStraightPath as e0,Position as ni}from"@xyflow/react";import{jsx as Rd,jsxs as t0}from"react/jsx-runtime";var kd=({toX:e,toY:t,fromNode:o})=>{var u,m;if(!o)return null;let{internals:{positionAbsolute:{x:n,y:r}},measured:i}=o,s=(u=i.width)!=null?u:0,a=(m=i.height)!=null?m: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((p,h)=>{let E=Math.hypot(e-p.x,t-p.y);return Math.hypot(e-h.x,t-h.y)<E?h:p}),[d]=e0({sourceX:c.x,sourceY:c.y,targetX:e,targetY:t});return t0("g",{className:"group",children:[Rd("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d}),Rd("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})};import{Position as Jt,useConnection as o0,useReactFlow as n0}from"@xyflow/react";import{orderBy as r0}from"lodash";import{useMemo as Dd,useState as i0}from"react";import{Fragment as Ts,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}=n0(),{mode:a,isReadOnly:l}=U(),{inProgress:c,fromNode:d}=o0(),u=c&&(d==null?void 0:d.id)!==e,[m,p]=i0(!1),h=s(),E=!r,f=!E&&((T=h.find(I=>I.id===r))==null?void 0:T.selected),g=Dd(()=>r0([...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 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]),w=I=>{i(e,{label:I})},_=()=>{p(!0)},N=()=>{p(!1)};return ri(Ts,{children:[ri("div",{className:G("flex h-full min-h-64 w-full min-w-[50rem] hover:shadow-md bg-white outline outline-2 outline-grey-400",{"pointer-events-none":l,"outline-offset-0 outline-blue-500 shadow-sm":(o||f)&&!l}),children:[Ue("div",{className:G("flex align-items justify-center w-10 border-r-2 border-grey-400",{"border-blue-500":(o||f)&&!l}),onDoubleClick:_,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:G({"whitespace-nowrap":m}),isEditing:m,onBlur:N,onChange:w})})}),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(Ts,{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(Ts,{children:[Ue(ne,{type:"target",position:Jt.Left,id:"left",className:G({"annotation-handle":u})}),Ue(ne,{type:"target",position:Jt.Right,id:"right",className:G({"annotation-handle":u})}),Ue(ne,{type:"target",position:Jt.Top,id:"top",className:G({"annotation-handle":u})}),Ue(ne,{type:"target",position:Jt.Bottom,id:"bottom",className:G({"annotation-handle":u})})]})]})};var Vd={START_EVENT:bd,END_EVENT:hd,TASK:Ad,GATEWAY:xd,ANNOTATION:md,LANE:Od,UNSUPPORTED:Sd},Hd={SEQUENCE_EDGE:kc,MESSAGE_EDGE:Ld,ANNOTATION_EDGE:xc},Gd="#fafafa",Bd="#bebebe",zd=1,Yd=10,Wd="bottom-left",Ns=.05,Fd=5,Xo=.5,Uo=Ns,$o=1,Xd={x:0,y:0,zoom:.75},Ud=1,$d=2,s0={[Ud]:4,[$d]:2},Cn=[Ud,$d],vs=Cn.reduce((e,t)=>e|s0[t],0);import{useReactFlow as a0}from"@xyflow/react";var st=()=>{let{getEdges:e,getNodes:t}=a0(),{lastElementId:o}=U(),n=()=>{let i=t(),s=e(),a=ed(i,s);return Math.max(a,o)};return{getLastId:n,getNextId:()=>n()+1}};var Ko=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n,setViewport:r}=c0(),{getLastId:i}=st(),s=d0(),{setLastElementId:a}=U(),l=Kd(async(d="")=>{let{nodes:u,edges:m,lastElementId:p}=await od(d),{width:h,height:E}=s.getState();if(h>0&&E>0){let f=la(u);f&&r(l0(f,h,E,Uo,$o,Xo))}o(u),n(m),a(p)},[o,n,a,s,r]),c=Kd(()=>{let d=e(),u=t(),m=i();return td(d,u,m)},[e,t,i]);return{importFromMxGraph:l,exportToMxGraph:c}};import{useCallback as qd}from"react";var p0=500,ii=()=>{let{isInitialized:e,onElementChanges:t}=U(),{exportToMxGraph:o}=Ko(),n=u0(()=>{if(!e)return;let s=o();t==null||t(s)},p0),r=qd(s=>{s.every(c=>c.type==="select")||s.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=qd(s=>{s.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var Zd=({setEdges:e,saveHistory:t})=>{let{getNode:o,getEdges:n,getNodes:r,getInternalNode:i}=m0(),{emitElementChanges:s}=ii(),a=g0(null),{getNextId:l}=st(),c=ho(f=>{var _;let g=o(f.source),y=o(f.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:(_=a.current)!=null?_:void 0};return ns(x).isValid},[o,n,r]),d=ho(f=>{var x,w;let g=l(),y=i(f.source);if(y){let _=i(f.target),N=_?_.internals.positionAbsolute.x+((x=_.measured.width)!=null?x:0)/2:0,T=_?_.internals.positionAbsolute.y+((w=_.measured.height)!=null?w:0)/2:0,I=Dc(y,N,T),C=(_==null?void 0:_.type)==="ANNOTATION"||(y==null?void 0:y.type)==="ANNOTATION",P=C?ko:rt,R;if(!C&&_&&f.targetHandle){let $=Kr(I),K=Kr(f.targetHandle),{x:te,y:z}=ls(y,I),{x:M,y:H}=ls(_,f.targetHandle),A=Fr(te,z,M,H,$,K).slice(1,-1);A.length>0&&(R=A)}let S=v(b(b({},f),P),{id:String(g),sourceHandle:I,data:b(b({},C?{}:rt.data),R?{points:R}:{})}),L=n().concat(S);e(L),t("forceSave",{nodes:r(),edges:L}),s()}},[l,e,s,i,n,r,t]),u=ho((f,g)=>{a.current=g.id},[]),m=ho(()=>{a.current=null},[]),p=ho((f,g)=>{let y=o(g.source),x=o(g.target);if(!y||!x){a.current=null;return}let w={sourceNodeId:y.id,targetNodeId:x.id,sourceNodeType:y.type,targetNodeType:x.type,nodes:r(),edges:n(),reconnectingEdgeId:f.id};if(!ns(w).isValid){a.current=null;return}let N=f0(f,g,n()).map(T=>T.id===f.id?v(b({},T),{data:v(b({},T.data),{points:void 0})}):T);e(N),t("forceSave",{nodes:r(),edges:N}),a.current=null,s()},[o,r,n,e,s,t]),h=ho(f=>{a.current=f},[]),E=ho(()=>{a.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:p,onReconnectStart:u,onReconnectEnd:m,setReconnectingEdge:h,clearReconnectingEdge:E}};import{useTranslation as h0}from"@produto-lecom/lecom-ui";import{useReactFlow as y0}from"@xyflow/react";import{useCallback as Ln,useRef as iu,useState as x0}from"react";var Sn=(e=[])=>e.filter(t=>t.type==="START_EVENT"),yo=(e=[])=>e.filter(t=>t.type==="END_EVENT"),Qt=(e=[])=>e.filter(t=>t.type==="TASK")||[],Jd=(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"),Qd=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),Qe=(e,t=[])=>t.filter(o=>o.source===e),Mn=(e,t=[])=>t.filter(o=>o.target===e),jd=(e,t)=>{var n,r;let o=(n=t.nodes)==null?void 0:n.find(i=>i.id===e);return((r=o==null?void 0:o.properties)==null?void 0:r.attribute)==="LOOP"},eu=(e,t)=>{let o=Qe(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},tu=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:[]}},Pt=(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)}},ou=(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=yo(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=Qe(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=Pt(t,n=>Qe(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=Pt(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=Pt(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=Qe(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),...yo(e.nodes)],o=[],n=[];for(let r of t){let i=Qe(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=yo(e.nodes),o=[],n=[];for(let r of t){let i=Mn(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=Qe(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=Qd(e.nodes),o=Pt(t,r=>Qe(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>Qe(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=Pt(t,n=>!n.label||tu(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=yo(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=Pt(r,l=>!jd(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=yo(e.nodes)[0];if(!o)return Ee({isValid:!0});let n=t.filter(l=>{let c=Mn(l.id,e.edges),d=Qe(l.id,e.edges),u=c.some(p=>{var h;return((h=e.nodes.find(E=>E.id===p.source))==null?void 0:h.type)==="START_EVENT"}),m=d.some(p=>{var h;return((h=e.nodes.find(E=>E.id===p.target))==null?void 0:h.type)==="END_EVENT"});return u&&m}),r=Mn(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=Qe(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=Pt(t,n=>Qe(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),...yo(e.nodes)],o=[],n=[];for(let r of t){let i=Qe(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=Jd(e.nodes),o=Pt(t,n=>!eu(n.id,e));return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}}];var nu=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}},ru=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){return{isValid:!1,errors:[{id:"cannot_validate_subprocess_reference",message:"cannot_validate_subprocess_reference",nodeIds:t.map(i=>i.id)||[],edgeIds:[]}]}}};import{jsx as ai,jsxs as E0}from"react/jsx-runtime";var su=()=>{let{t:e}=h0(),{toast:t}=We(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=y0(),{validateCustomDiagram:s}=U(),[a,l]=x0(!1),c=iu(!1),d=iu(!1),u=Ln(async f=>{let g=ou(f.nodes,f.edges),y=nu(g),x=f.nodes.filter(({type:_,data:N})=>_==="TASK"&&(N==null?void 0:N.variant)==="SUBPROCESS");if(s&&x.length>0){let _=await ru(s,x);y={isValid:y.isValid&&_.isValid,errors:[...y.errors,..._.errors]}}let w=y.errors.map(_=>v(b({},_),{message:e(`validation.errors.${_.id}`)}));return a||l(!0),{isValid:y.isValid,errors:w}},[a,e,s]),m=Ln((f,g=!0)=>{if(g&&f&&t({variant:f.isValid?"success":"error",duration:5e3,title:f.isValid?e("validation.success.title"):e("validation.errors.title"),content:E0("div",{className:"flex flex-col gap-1",children:[!f.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:f.isValid?ai("li",{children:e("validation.success.message")}):f.errors.map(S=>ai("li",{className:"text-xs",children:S.message},S.id))})]})}),!f)return;c.current=!0,d.current=!0;let y=[],x=[];f.errors.forEach(S=>{S.nodeIds&&S.nodeIds.length>0&&S.nodeIds.forEach(L=>y.push(L)),S.edgeIds&&S.edgeIds.length>0&&S.edgeIds.forEach(L=>x.push(L))});let w=[...new Set(y)];o(S=>S.map(L=>v(b({},L),{data:v(b({},L.data),{hasError:!1})}))),n(S=>S.map(L=>v(b({},L),{data:v(b({},L.data),{hasError:!1})})));let _=r(),N=i(),T=new Set(w),I=new Set;f.errors.forEach(S=>{var K,te;let L=Pn.find(z=>z.id===S.id);(L==null?void 0:L.highlightRelatedEdges)!==!1&&((K=S.edgeIds)==null||K.forEach(z=>I.add(z)),(te=S.nodeIds)==null||te.forEach(z=>{N.forEach(M=>{(M.source===z||M.target===z)&&I.add(M.id)})}))});let C=new Set,P=new Set,R=new Set;_.forEach(S=>{S.type==="START_EVENT"?C.add(S.id):S.type==="END_EVENT"&&P.add(S.id)}),N.forEach(S=>{C.has(S.source)&&R.add(S.target),P.has(S.target)&&R.add(S.source)}),R.forEach(S=>{var L,$;if(T.has(S)){let K=(L=f.errors.find(z=>{var M;return(M=z.nodeIds)==null?void 0:M.includes(S)}))==null?void 0:L.id;(($=Pn.find(z=>z.id===K))==null?void 0:$.highlightRelatedEdges)!==!1&&N.forEach(z=>{z.source===S&&P.has(z.target)&&(T.add(z.target),I.add(z.id)),z.target===S&&C.has(z.source)&&(T.add(z.source),I.add(z.id))})}}),T.size>0&&o(S=>S.map(L=>v(b({},L),{data:v(b({},L.data),{hasError:T.has(L.id)})}))),I.size>0&&n(S=>S.map(L=>v(b({},L),{data:v(b({},L.data),{hasError:I.has(L.id)})}))),setTimeout(()=>{c.current=!1},0)},[e,i,r,n,o,t]),p=Ln(()=>{l(!1),d.current=!1,o(f=>f.map(g=>v(b({},g),{data:v(b({},g.data),{hasError:!1})}))),n(f=>f.map(g=>v(b({},g),{data:v(b({},g.data),{hasError:!1})})))},[n,o]),h=Ln(()=>{d.current&&(c.current=!0,d.current=!1,o(f=>f.map(g=>v(b({},g),{data:v(b({},g.data),{hasError:!1})}))),n(f=>f.map(g=>v(b({},g),{data:v(b({},g.data),{hasError:!1})}))),setTimeout(()=>{c.current=!1},0))},[n,o]),E=Ln(()=>c.current,[]);return{validateDiagram:u,handleValidationComplete:m,clearValidation:p,dismissValidationPanel:h,isAutoValidationEnabled:a,getIsClearingValidation:E}};import{useReactFlow as b0}from"@xyflow/react";import{useTranslation as _0}from"@produto-lecom/lecom-ui";import{useEffect as T0}from"react";var N0=15,au="bpmn:selection",v0=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",i=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||i},lu=e=>{if(!v0(e.target))return!0;let t=window.getSelection(),o=t&&t.toString().length>0;if(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement){let n=e.target;return n.selectionStart===n.selectionEnd&&!o}return!o},cu=({offset:e=N0,saveHistory:t})=>{let{t:o}=_0(),{getNodes:n,setNodes:r,getEdges:i,setEdges:s}=b0(),{getNextId:a}=st(),{mode:l,containerRef:c}=U();T0(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let u=p=>{var _,N;if(!lu(p)||!d.contains(document.activeElement))return;let E=n(),f=i(),g=E.filter(T=>T.selected);if(!g.length)return;p.preventDefault(),p.stopPropagation();let y=f.filter(T=>g.some(I=>I.id===T.source)&&g.some(I=>I.id===T.target)),w=JSON.stringify({nodes:g,edges:y});(_=p.clipboardData)==null||_.setData(au,w),(N=p.clipboardData)==null||N.setData("text/plain",`BPMN Selection: ${g.length} nodes`)},m=p=>{var R,S;if(!lu(p)||!d.contains(document.activeElement))return;let E=(R=p.clipboardData)==null?void 0:R.getData(au);if(!E)return;p.preventDefault(),p.stopPropagation();let f;try{f=JSON.parse(E)}catch(L){return}if(!((S=f.nodes)!=null&&S.length))return;let g=new Map,y=n(),x=[],w=f.nodes.filter(L=>zt(L.type,y));if(w.length===0)return;let _=a(),N=w.map(L=>{var te;let $=String(_++);g.set(L.id,$);let K=v(b({},L),{id:$,selected:!0,position:{x:L.position.x+e,y:L.position.y+e}});if(L.type==="TASK"){let z=(te=L.data)==null?void 0:te.label,M=Wo(z||o("bpmn.task.label.prefix"),[...y,...x]);K.data=v(b({},L.data),{label:M})}return x.push(K),K}),T=f.edges.map(L=>v(b({},L),{id:String(_++),selected:!0,source:g.get(L.source)||L.source,target:g.get(L.target)||L.target})),I=[...y.map(L=>v(b({},L),{selected:!1})),...N],P=[...i().map(L=>v(b({},L),{selected:!1})),...T];r(I),s(P),t("forceSave",{nodes:I,edges:P})};return d.addEventListener("copy",u,!0),d.addEventListener("paste",m,!0),()=>{d.removeEventListener("copy",u,!0),d.removeEventListener("paste",m,!0)}},[n,r,i,s,a,e,o,t,l,c])};import{useTranslation as w0}from"@produto-lecom/lecom-ui";import{useReactFlow as I0}from"@xyflow/react";import{useState as A0}from"react";var C0=50,du=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let{draggableNode:r,setDraggableNode:i}=Yo(),{t:s}=w0(),{getInternalNode:a,getNodes:l,getEdges:c,screenToFlowPosition:d}=I0(),{getNextId:u}=st(),{setIsDragging:m}=U(),{getInternalNodes:p}=Jr(),{rebuildIndex:h,forceRebuildIndex:E}=Ir(),[f,g]=A0(null),y=(M,H,D)=>{var k;if(M.parentId!==H)return null;let A=D.filter(O=>O.id!==M.id&&O.parentId===H&&O.type==="LANE").sort((O,V)=>O.position.y-V.position.y);if(A.length===0)return null;let Y=(k=D.find(O=>O.id===M.id))!=null?k:M,B=A.find(O=>Y.position.y<O.position.y);return B?{draggedLaneId:M.id,beforeLaneId:B.id}:{draggedLaneId:M.id,afterLaneId:A[A.length-1].id}},x=(M,H=!1,D)=>{let A=H?"node-drop-target-error":"node-drop-target",Y=H?"node-drop-target-lane-error":"node-drop-target-lane";t(B=>{var O;let k=(O=D==null?void 0:D(B))!=null?O:null;return B.map(V=>{let F=[];return V.id===M&&F.push(A),M!==void 0&&V.parentId===M&&V.type==="LANE"&&V.id!==(k==null?void 0:k.draggedLaneId)&&F.push(Y),V.id===(k==null?void 0:k.draggedLaneId)&&F.push("lane-reorder-dragging"),V.id===(k==null?void 0:k.beforeLaneId)&&F.push("lane-reorder-before"),V.id===(k==null?void 0:k.afterLaneId)&&F.push("lane-reorder-after"),v(b({},V),{className:F.join(" ")})})})},w=(M,H)=>{let D=p();if(M.type==="LANE"){if(H){x();return}let O=D.filter(J=>J.id!==M.id&&J.type==="LANE"&&!J.parentId),V=tn(M,O);if(!V){x();return}if(to({parentId:V.id,nodes:e,excludeTypes:["LANE"]})){x(V.id,!0);return}x(V.id,!1,J=>y(M,V.id,J));return}let Y=D.filter(O=>O.id!==M.id&&O.type==="LANE"),B=tn(M,Y);if(!B){x();return}if(to({parentId:B.id,nodes:e,includeTypes:["LANE"]})){x();return}x(B.id)},_=M=>{let H=a(M.id),D=M.type==="LANE"&&to({parentId:M.id,nodes:e,includeTypes:["LANE"]});w(H,D)},N=M=>M.map(H=>v(b({},H),{className:void 0})),T=M=>M.some(D=>D.dragging)?M.map(D=>D.dragging?v(b({},D),{dragging:!1}):D):M,I=(M,H)=>{let D=0;for(let A of H){if(A.id===M||A.parentId||A.type==="LANE")continue;let Y=ot(A),B=Y.y+Y.h;D=Math.max(D,B)}return D+C0},C=(M,H)=>{if(!Vi(M,H))return H;let D=I(M,H);return H.map(A=>A.id===M?v(b({},A),{position:v(b({},A.position),{y:D})}):A)},P=M=>{if(M.preventDefault(),M.dataTransfer.dropEffect="move",!(r!=null&&r.type))return;let H=d({x:M.clientX,y:M.clientY}),D={id:"__sidebar_drag__",type:r.type,position:H,measured:{width:1,height:1},internals:{positionAbsolute:H}};w(D,!1)},R=M=>{let H=M.relatedTarget;(!H||!M.currentTarget.contains(H))&&x()},S=(M,H)=>{M.preventDefault(),_(H)},L=(M,H,D)=>{var F,J;let A=[...D],Y=H.parentId?H.parentId:H.id;if(M.parentId===H.id)return A=Gi(M,H,A),A=St(A),A=oo(Y,A),N(A);if(M.type==="LANE"){if(to({parentId:H.id,nodes:A,excludeTypes:["LANE"]})){let W=Nr(H),oe=50,le=50;return A.map(q=>{var xe,me;return q.id===M.id?v(b({},q),{position:{x:(xe=f==null?void 0:f.x)!=null?xe:W.x+oe,y:(me=f==null?void 0:f.y)!=null?me:W.y2+le}}):q})}let ee=A.filter(W=>W.parentId===H.id).reduce((W,oe)=>{var le,q;return W+((q=(le=oe.measured)==null?void 0:le.height)!=null?q:0)},0),ie={x:se.HEADER_WIDTH,y:ee};return A=A.map(W=>W.id===M.id?v(b({},W),{parentId:H.id,position:ie,className:void 0}):v(b({},W),{className:void 0})),A=St(A),A=C(Y,A),A}if(to({parentId:H.id,nodes:A,includeTypes:["LANE"]})){let X;if(M.parentId){let Q=a(M.parentId),{x:ee,y:ie}=ot(Q);X={x:ee+((F=M.position.x)!=null?F:0),y:ie+((J=M.position.y)!=null?J:0)}}return A=A.map(Q=>Q.id===M.id?v(b({},Q),{position:X!=null?X:Q.position,parentId:void 0,className:void 0}):v(b({},Q),{className:void 0})),A=oo(Y,A),A}let O=ia(M,H);A=A.map(X=>X.id===M.id?v(b({},X),{parentId:H.id,position:O,className:void 0}):v(b({},X),{className:void 0}));let V=A.find(X=>X.id===M.id);return A=Gi(V,H,A),A=St(A),A=oo(Y,A),A},$=M=>{if(M.preventDefault(),!(r!=null&&r.type))return;if(!zt(r.type,l())){m(!1),i(null);return}let H=d({x:M.clientX,y:M.clientY}),D={width:ue[r.type].MIN_WIDTH,height:ue[r.type].MIN_HEIGHT},A=u(),Y={id:String(A),type:r.type,position:H,measured:D,data:{label:r.type==="TASK"?jr(e,s("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},B=v(b({},Y),{internals:{positionAbsolute:H}}),k=v(b({},B),{measured:{width:1,height:1}}),O=p(),V=r.type==="LANE",F=O.filter(W=>V?W.type==="LANE"&&!W.parentId:W.type==="LANE"),J=tn(k,F),X=[...O.map(W=>v(b({},W),{selected:!1})),B];J&&(X=L(B,J,X)),X=eo(X),V&&!J&&(X=C(B.id,X)),X=N(X),t(X),E();let Q=M.dataTransfer.getData("sourceId"),ee=c(),ie=ee;if(Q){let W={id:String(A+1),source:Q,target:Y.id},oe=r.type==="ANNOTATION"?b(b({},W),ko):b(b({},W),rt);ie=ee.concat(oe),o(ie)}n("forceSave",{nodes:X,edges:ie}),m(!1),i(null)},K=async(M,H,D)=>{let A=[...p()],Y=new Set;D.forEach(O=>{let V=a(O.id),F=O.type==="LANE",J=A.filter(Q=>Q.id!==O.id&&(F?Q.type==="LANE"&&!Q.parentId:Q.type==="LANE")),X=tn(V,J);if(X){if(F&&to({parentId:O.id,nodes:A,includeTypes:["LANE"]})){O.parentId&&(A=z(O,A),Y.add(O.id));return}A=L(V,X,A);return}O.parentId&&(A=z(O,A),O.type==="LANE"&&Y.add(O.id))}),A=T(A);let B=D.filter(O=>O.type==="LANE"&&!O.parentId).map(O=>O.id);for(let O of B)Vi(O,A)&&f&&(A=A.map(V=>V.id===O?v(b({},V),{position:b({},f)}):V));for(let O of Y)A=C(O,A);if(D.some(O=>O.type!=="LANE"&&!O.parentId)){let O=A.filter(V=>V.type==="LANE"&&!V.parentId).map(V=>V.id);for(let V of O)A=oo(V,A)}A=eo(A),A=N(A),t(A),h(A),g(null)},te=(M,H)=>{g({x:H.position.x,y:H.position.y})},z=(M,H)=>{var J,X,Q,ee,ie,W,oe,le;let D=a(M.parentId);if(!D)return H;let A=M.type==="LANE",Y=H.filter(q=>q.parentId===D.id&&q.id!==M.id),B=Y.filter(q=>q.type==="LANE"),k;if(A&&B.length===0)k=se.MIN_HEIGHT;else if(A){let q=(X=(J=M.measured)==null?void 0:J.height)!=null?X:se.MIN_HEIGHT;k=((ee=(Q=D.measured)==null?void 0:Q.height)!=null?ee:se.MIN_HEIGHT)-q,k=Math.max(se.MIN_HEIGHT,k)}else k=Y.length>0?Y.reduce((q,xe)=>{var me,be;return q+((be=(me=xe.measured)==null?void 0:me.height)!=null?be:0)},0)+ve:Math.max(se.MIN_HEIGHT,(W=(ie=D.measured)==null?void 0:ie.height)!=null?W:0);let{x:O,y:V}=ot(D),F={x:O+((oe=M.position.x)!=null?oe:0),y:V+((le=M.position.y)!=null?le:0)};return H=H.map(q=>q.id===M.id?v(b({},q),{position:F,parentId:void 0}):q.id===D.id?v(b({},q),{height:k,measured:v(b({},q.measured),{height:k})}):q),H=St(H),H};return{onDragOver:P,onDragLeave:R,onDrop:$,onNodeDrag:S,onNodeDragStart:te,onNodeDragStop:K}};import{useReactFlow as S0}from"@xyflow/react";import{useTranslation as M0}from"@produto-lecom/lecom-ui";import{useEffect as P0}from"react";var L0=30,R0=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},k0=e=>!R0(e.target),uu=({offset:e=L0,saveHistory:t})=>{let{t:o}=M0(),{getNodes:n,setNodes:r,getEdges:i,setEdges:s}=S0(),{getNextId:a}=st(),{mode:l,containerRef:c}=U();P0(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let u=m=>{if(d.contains(document.activeElement)&&m.ctrlKey&&m.key.toLowerCase()==="d"&&k0(m)){m.preventDefault(),m.stopPropagation();let h=n(),E=i(),f=h.filter(P=>P.selected);if(!f.length)return;let g=new Map,y=[],x=f.filter(P=>zt(P.type,h));if(x.length===0)return;let w=E.filter(P=>x.some(R=>R.id===P.source)&&x.some(R=>R.id===P.target)),_=a(),N=x.map(P=>{var L;let R=String(_++);g.set(P.id,R);let S=v(b({},P),{id:R,selected:!0,position:{x:P.position.x+e,y:P.position.y+e}});if(P.type==="TASK"){let $=(L=P.data)==null?void 0:L.label,K=Wo($||o("bpmn.task.label.prefix"),[...h,...y]);S.data=v(b({},P.data),{label:K})}return y.push(S),S}),T=w.map(P=>v(b({},P),{id:String(_++),selected:!0,source:g.get(P.source)||P.source,target:g.get(P.target)||P.target})),I=[...h.map(P=>v(b({},P),{selected:!1})),...N],C=[...E.map(P=>v(b({},P),{selected:!1})),...T];r(I),s(C),t("forceSave",{nodes:I,edges:C})}};return d.addEventListener("keydown",u,!0),()=>{d.removeEventListener("keydown",u,!0)}},[n,r,i,s,a,e,o,t,l,c])};import{useEffect as D0,useRef as pu}from"react";import{useReactFlow as O0}from"@xyflow/react";var V0=20,H0=50,Rn={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},G0=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},fu=e=>{let{getNodes:t}=O0(),{mode:o,isMoveTool:n}=U(),r=pu(0),i=pu(new Map);D0(()=>{let s=a=>{if(o!=="edit"||!n||G0(a.target)||!Object.values(Rn).includes(a.key))return;let u=t().filter(y=>y.selected);if(u.length===0){i.current.clear();return}a.preventDefault();let m=Date.now(),p=m-r.current<500;r.current=m;let h=a.shiftKey?H0:V0,E=0,f=0;switch(a.key){case Rn.UP:f=-h;break;case Rn.DOWN:f=h;break;case Rn.LEFT:E=-h;break;case Rn.RIGHT:E=h;break}let g=u.map(y=>{let x=i.current.get(y.id);(!p||!x)&&(x={x:y.position.x,y:y.position.y});let w={x:x.x+E,y:x.y+f};return i.current.set(y.id,w),{id:y.id,dragging:!0,type:"position",position:w}});e&&e(g)};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t,e,o,n])};import{useReactFlow as z0}from"@xyflow/react";var gu={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},hu={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},mu=(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}},B0=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=mu(i[0],o),a=mu(i[1],o);s&&a&&n.push({sourceId:s.step,targetId:a.step,label:s.edgeLabel||a.edgeLabel||""})}),{components:o,connections:n}},yu=e=>{let{components:t,connections:o}=B0(e);return{nodes:t,edges:o}};var xu=()=>{let{setNodes:e,setEdges:t,fitView:o}=z0(),{getNextId:n}=st();return{importFromLia:i=>{let s=typeof i=="string"?i:i.diagramXml||"",{nodes:a,edges:l}=yu(s),c=[],d=new Map,u=!1,m=n();for(let[f,g]of Object.entries(a)){let y=String(m++),x=gu[g.type],w=hu[g.type];x==="START_EVENT"&&(u=!0),d.set(f,y);let _=ue[x].MIN_WIDTH,N=ue[x].MIN_HEIGHT;c.push({id:y,type:x,data:{label:g.label||"",variant:w,attribute:""},position:{x:0,y:0},width:_,height:N,measured:{width:_,height:N}})}let p=[];for(let f of l){let g=v(b({},rt),{id:String(m++),source:d.get(f.sourceId)||f.sourceId,target:d.get(f.targetId)||f.targetId});p.push(g)}if(!u&&c.length>0){let f=String(m++),g={id:f,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=v(b({},rt),{id:String(m++),source:f,target:y.id});p.unshift(x)}}let{nodes:h,edges:E}=Zc(c,p);e(h),t(E),o({padding:Xo,minZoom:Uo,maxZoom:$o})}}};import{useCallback as Y0,useEffect as W0}from"react";var F0={origin:"*",debug:!1};function li(e,t=F0){let{origin:o,debug:n}=t,r=Y0((i,s)=>{let a={event:i,data:s};window.parent.postMessage(a,o||"*")},[o]);return W0(()=>{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 U0}from"@xyflow/react";import{useEffect as ci,useRef as ws}from"react";var Eu=()=>{let e=U0(),{initialDiagram:t,isNewDiagram:o,setIsInitialized:n,onElementChanges:r}=U(),{importFromMxGraph:i,exportToMxGraph:s}=Ko(),{sendMessage:a}=li(),l=ws(t),c=ws(r),d=ws(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 m;if(await Bn(),n(!0),a("INIT_MODELER",l.current),!o){let p=d.current();(m=c.current)==null||m.call(c,p)}})()},[e,o,n,a])};import{useCallback as bu}from"react";import{useReactFlow as $0}from"@xyflow/react";function _u(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=ro(),{getEdges:n}=$0(),r=Kn(),i=bu(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=bu(()=>{t(),setTimeout(()=>{r()},0)},[t,r]);return{handleTasksStatus:i,handleClearTaskStatus:s}}import{useReactFlow as K0}from"@xyflow/react";import{useCallback as Lt,useState as q0,useEffect as Tu}from"react";import{useDebouncedCallback as Z0}from"use-debounce";var J0=500,Nu=100,vu=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=K0(),{mode:i,containerRef:s}=U(),[a,l]=q0({history:[],currentStep:0}),{history:c,currentStep:d}=a,u=d>0,m=d<c.length-1,p=Lt((T,I)=>{n(T[I].nodes),r(T[I].edges)},[n,r]),h=Lt(()=>{if(d>0){let T=d-1;l(I=>v(b({},I),{currentStep:T})),p(c,T)}},[d,c,p]),E=Lt(()=>{if(d<c.length-1){let T=d+1;l(I=>v(b({},I),{currentStep:T})),p(c,T)}},[c,d,p]),f=Lt(T=>{l(I=>{let C=I.history[I.currentStep];if(C&&JSON.stringify(C)===JSON.stringify(T))return I;let S=[...I.history.slice(0,I.currentStep+1),T],L=S.length>Nu?S.slice(S.length-Nu):S;return{history:L,currentStep:L.length-1}})},[]),g=Lt((T,I)=>{let C=T.map(R=>v(b({},R),{selected:!1,className:"",data:v(b({},R.data),{hasError:!1})})),P=I.map(R=>v(b({},R),{data:v(b({},R.data),{hasError:!1})}));return{nodes:eo(C),edges:P}},[]),y=Lt(()=>g(t(),o()),[t,o,g]),x=Z0(()=>{let T=y();f(T)},J0),w=Lt((T,I)=>{if(!e)return;if(c.length===0){let R=y();l({history:[R],currentStep:0})}if(T==="forceSave"){if(I){f(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,f,g]);Tu(()=>{if(e&&c.length===0){let T=y();l({history:[T],currentStep:0})}},[e,c.length,y]);let _=Lt(T=>{l({history:T||[],currentStep:0})},[]),N=Lt(()=>{l({history:[],currentStep:0})},[]);return Tu(()=>{if(i!=="edit")return;let T=s.current;if(!T)return;let I=C=>{if(!T.contains(document.activeElement)||!(C.ctrlKey||C.metaKey))return;let S=C.key.toLowerCase();if(S==="y"||C.shiftKey&&S==="z"){C.preventDefault(),E();return}S==="z"&&(C.preventDefault(),h())};return T.addEventListener("keydown",I),()=>{T.removeEventListener("keydown",I)}},[h,E,i,s]),{history:c,undo:h,redo:E,canUndo:u,canRedo:m,saveHistory:w,resetHistory:_,clearHistory:N}};var wu=()=>{let{t:e}=Q0(),[t,o,n]=ex([]),[r,i,s]=j0([]),{getNodes:a,getNode:l}=ox(),{toast:c}=We(),d=nx(),{instanceId:u,isInitialized:m,setIsConnecting:p,setIsMultipleSelection:h,onElementClick:E}=U(),{updateHelperLines:f,HelperLines:g}=Ir(),{undo:y,redo:x,canUndo:w,canRedo:_,saveHistory:N}=vu(m),{onNodeDrag:T,onDrop:I,onDragOver:C,onDragLeave:P,onNodeDragStop:R,onNodeDragStart:S}=du({nodes:t,setNodes:o,setEdges:i,saveHistory:N}),{isValidConnection:L,onConnect:$,onReconnect:K,onReconnectStart:te,onReconnectEnd:z,setReconnectingEdge:M,clearReconnectingEdge:H}=Zd({setEdges:i,saveHistory:N}),{handleValidationComplete:D,clearValidation:A,dismissValidationPanel:Y,validateDiagram:B,getIsClearingValidation:k}=su(),{importFromLia:O}=xu(),{handleTasksStatus:V,handleClearTaskStatus:F}=_u(),{clearPathEdges:J}=ro(),{emitElementChanges:X,handleNodeChanges:Q,handleEdgeChanges:ee}=ii(),ie=Kn();cu({saveHistory:N}),uu({saveHistory:N}),Eu();let W=bt(()=>{o([]),i([]),J(),setTimeout(ie,0)},[o,i,J,ie]),{selectElements:oe,clearSelection:le}=Yt(),{importFromMxGraph:q,exportToMxGraph:xe}=Ko(),{configureElement:me,getConfigureElement:be}=kr(),Z=bt(he=>{he!=null&&he.id&&oe([he.id])},[oe]),{sendMessage:de}=li({LIA_CREATE_DIAGRAM:O,CLEAR_DIAGRAM:W,TASKS_STATUS:V,CLEAR_TASKS_STATUS:F,EXTERNAL_TASK_SELECT:Z}),re=bt(()=>t.length+r.length,[t,r]);rx(()=>(Et.set(u,{importFromMxGraph:q,exportToMxGraph:xe,selectElements:oe,clearSelection:le,configureElement:me,getConfigureElement:be,getElementsCount:re,setReconnectingEdge:M,clearReconnectingEdge:H}),()=>{Et.delete(u)}),[u,q,xe,oe,le,me,be,re,M,H]);let j=bt((he,fe)=>{if(fe.type!=="TASK"&&fe.type!=="GATEWAY")return;let pe=be(fe.id);pe&&(E==null||E(pe)),fe.type==="TASK"&&de("SELECT_TASK",{id:fe.id})},[be,E,de]),ge=bt((he,fe)=>{if(fe.type!=="SEQUENCE_EDGE")return;let pe=l(fe.source),Ne=l(fe.target),{isFromStartEvent:Ke,isGatewayToGateway:et,isActiviyToAndGateway:Be,isToEndEvent:mt}=$n(pe,Ne);if(!(!Ke&&!et&&!Be&&!mt))return;let Tt=be(fe.id);Tt&&(E==null||E(Tt))},[be,l,E]),_e=bt(he=>{let fe=f(he,t);n(fe),N(he),k()||Y(),Q(he)},[t,n,N,k,Y,f,Q]),Te=bt(he=>{s(he),N(he),k()||Y(),ee(he)},[s,N,k,Y,ee]);fu(_e);let Re=bt(({nodes:he,edges:fe})=>{h(he.length+fe.length>=2)},[h]);tx({onChange:Re});let je=bt(async({nodes:he})=>he.some(pe=>pe.type==="LANE"&&t.some(Ne=>Ne.parentId===pe.id))?(c({variant:"error",title:e("validation.errors.title"),content:e("editor.toolbar.delete_pool_lane_error")}),!1):!0,[t,e,c]),_t=()=>{N("forceSave"),X(),Y()},pt=()=>{p(!0)},ft=()=>{p(!1),Y()},$e=bt(he=>{let fe=new Set(he.filter(pe=>pe.type==="LANE"&&!!pe.parentId).map(pe=>pe.parentId));fe.size!==0&&setTimeout(()=>{var Ke,et;let pe=a(),Ne=new Map(pe.map(Be=>[Be.id,Be]));for(let Be of fe){let mt=no(pe.filter(Nt=>Nt.type==="LANE"&&Nt.parentId===Be));if(mt.length===0)continue;let kt=0;for(let Nt of mt)Ne.set(Nt.id,v(b({},Nt),{position:{x:se.HEADER_WIDTH,y:kt}})),kt+=(et=(Ke=Nt.measured)==null?void 0:Ke.height)!=null?et:0;let Tt=Ne.get(Be);Tt&&Ne.set(Be,v(b({},Tt),{height:kt,measured:v(b({},Tt.measured),{height:kt})}))}o(pe.map(Be=>{var mt;return(mt=Ne.get(Be.id))!=null?mt:Be}))},0)},[a,o]);return{nodes:t,setNodes:o,edges:r,setEdges:i,events:{isValidConnection:L,onConnect:$,onReconnect:K,onReconnectStart:te,onReconnectEnd:z,onDrop:I,onDragOver:C,onDragLeave:P,onNodeDrag:T,onNodeDragStop:R,onNodeDragStart:S,onNodeClick:j,onEdgeClick:ge,onDropCapture:_t,onConnectStart:pt,onConnectEnd:ft,onSelectionEnd:()=>setTimeout(()=>d.setState({nodesSelectionActive:!1}),0),onNodesChange:_e,onEdgesChange:Te,onBeforeDelete:je,onNodesDelete:$e},ui:{handleCloseValidationPanel:A},controls:{undo:y,redo:x,canUndo:w,canRedo:_},components:{HelperLines:g},actions:{saveHistory:N,selectElements:oe,clearSelection:le,exportToMxGraph:xe,validateDiagram:B,handleValidationComplete:D,setReconnectingEdge:M,clearReconnectingEdge:H}}};import{useReactFlow as ix}from"@xyflow/react";import{useCallback as sx,useEffect as ax,useRef as lx,useState as cx}from"react";var dx=".react-flow__node, .react-flow__edge, .react-flow__node-toolbar";function Iu(e,t,o){let[n,r]=cx(!1),i=lx(null),{getViewport:s,setViewport:a}=ix(),l=sx(()=>{i.current=null,r(!1)},[]);return ax(()=>{let c=e.current;if(!c)return;let d=p=>{if(!Cn.some(E=>E===p.button)||t.current||o.current||(r(!0),!(p.target instanceof Element))||!p.target.closest(dx))return;p.preventDefault(),p.stopPropagation();let h=s();i.current={pointerX:p.clientX,pointerY:p.clientY,viewportX:h.x,viewportY:h.y,zoom:h.zoom}},u=p=>{let h=i.current;if(h){if((p.buttons&vs)===0){l();return}a({x:h.viewportX+(p.clientX-h.pointerX),y:h.viewportY+(p.clientY-h.pointerY),zoom:h.zoom})}},m=p=>{(p.buttons&vs)===0&&l()};return c.addEventListener("pointerdown",d,!0),window.addEventListener("pointermove",u),window.addEventListener("pointerup",m),window.addEventListener("pointercancel",l),window.addEventListener("blur",l),()=>{c.removeEventListener("pointerdown",d,!0),window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",m),window.removeEventListener("pointercancel",l),window.removeEventListener("blur",l)}},[e,t,o,s,a,l]),n}import{jsx as Au}from"react/jsx-runtime";var di=({id:e,className:t})=>Au("marker",{id:e,className:G("react-flow__arrowhead",t),viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"7",markerHeight:"7",orient:"auto",markerUnits:"userSpaceOnUse",fill:"currentColor",stroke:"currentColor",children:Au("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as ui,jsxs as ux}from"react/jsx-runtime";var Cu=()=>ui("svg",{style:{position:"absolute",top:0,left:0},children:ux("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 DE,TooltipContent as OE,TooltipTrigger as VE,useTranslation as HE}from"@produto-lecom/lecom-ui";import{useKeyPress as $u,useReactFlow as oE}from"@xyflow/react";import{Button as xi,Tooltip as Ei,TooltipContent as bi,TooltipTrigger as _i,useTranslation as nE}from"@produto-lecom/lecom-ui";import{HandIcon as rE,ListCheckIcon as iE,Loader2Icon as sE,MapIcon as aE,MousePointerIcon as lE}from"lucide-react";import{useCallback as Ss,useEffect as Ku,useState as cE}from"react";import{Tooltip as Px,TooltipContent as Lx,TooltipTrigger as Rx,useTranslation as kx}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 Nx,useTranslation as vx}from"@produto-lecom/lecom-ui";import{useReactFlow as wx}from"@xyflow/react";var Su=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 Mu({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);pi(i,`${o}.csv`)}var pi=(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 Pu(e){return e==null?void 0:e.replaceAll("
"," ")}var Fk={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},Lu={script:"SCRIPT",subprocess:"SUBPROCESS"},Ru={"marker-loop":"LOOP"},ku={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL",inclusive:"EXCLUSIVE"};var xo=({cell:e,type:t,variant:o="",attribute:n=""})=>{let{_attributes:r,mxGeometry:i}=e,{value:s,parent:a}=r,l=Number(i._attributes.width),c=Number(i._attributes.height),d=a==="1"?void 0:a;return{id:r.id,parentId:d,type:t,data:{label:s||"",variant:o,attribute:n},position:{x:Number(i._attributes.x)||0,y:Number(i._attributes.y)||0},width:l,height:c,measured:{width:l,height:c}}},fx=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:xo({cell:e,type:"START_EVENT"}),status:n,originalType:o}},mx=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:xo({cell:e,type:"END_EVENT"}),status:n,originalType:o}},gx=(e,t)=>{let{id:o,subType:n,style:r}=e==null?void 0:e._attributes,i=Lu[n],s=t.get(o)||"",a=Ru[s]||"",l=a==="LOOP",c="imported";return!["script","none"].includes(n)&&!l&&(c="adapted"),e.mxGeometry._attributes.width=Dt(e.mxGeometry._attributes.width||0,ue.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=Dt(e.mxGeometry._attributes.height||0,ue.TASK.MIN_HEIGHT),{node:xo({cell:e,type:"TASK",variant:i,attribute:a}),status:c,originalType:r}},hx=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=ku[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:xo({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},yx=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:xo({cell:e,type:"LANE"}),status:"imported",originalType:t}},xx=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=Dt(e.mxGeometry._attributes.width||0,ue.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=Dt(e.mxGeometry._attributes.height||0,ue.ANNOTATION.MIN_HEIGHT),{node:xo({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},Du=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:xo({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},Ou=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return v(b({},rt),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},Vu={TASK:gx,GATEWAY:hx,START_EVENT:fx,END_EVENT:mx,LANE:yx,ANNOTATION:xx};var Ex=e=>{let t=new Map,o=Object.values(kn),n=[],r=new Map;e.forEach(a=>{var c;let l=(c=a._attributes)==null?void 0:c.type;if(l==="MARKER"){r.set(a._attributes.parent,a._attributes.style);return}if(o.includes(l)){n.push(a);return}});let i=[],s=[];for(let a of n){let{type:l}=a._attributes,c=Vu[l]||Du,{node:d,status:u,originalType:m}=c(a,r);s.push(d),i.push({originalType:m,type:d.type,variant:d.data.variant,value:Pu(d.data.label),status:u})}return{nodes:s,governanceIdToNodeIdMap:t,summary:i}},bx=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>Ou(r,t)),_x=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=Ex(t.root.mxCell),i=bx(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},Tx=async e=>{let t=await Su(e),o=qr(t);if(!o)throw new Error("EMPTY_FILE");let{metadata:n,mxGraphModel:r}=o.modeler||{},i=(n==null?void 0:n.app)&&(n==null?void 0:n.diagramType)&&(n==null?void 0:n.version),s=r==null?void 0:r.root;if(!i||!s)throw new Error("INVALID_FILE");if(!Object.keys(r.root.mxCell||{}).length)throw new Error("CONTAIN_NO_CELLS");return{metadata:n,mxGraphModel:r}},Hu=async e=>{try{let t=await Tx(e),{nodes:o,edges:n,summary:r}=_x(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};import{jsx as Ix}from"react/jsx-runtime";var Gu=()=>{let{t:e}=vx(),{toast:t}=We(),{setNodes:o,setEdges:n,fitView:r}=wx(),i=a=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],c=a.map(d=>[d.originalType,d.value,e(`adapter.governance.report.status.${d.status.toLowerCase()}`)]);t({variant:"warning",content:e("adapter.governance.success.incompatible_cells"),duration:1e3*60*1,action:Ix(Nx,{size:"small",variant:"ghost",onClick:()=>Mu({columns:l,rows:c,fileName:"governance-imported-cells"}),children:e("adapter.governance.action.download")})})};return{importFromGovernance:async a=>{try{let{nodes:l,edges:c,summary:d}=await Hu(a);if(o(m=>m.concat(l)),n(m=>m.concat(c)),r({padding:Xo,minZoom:Uo,maxZoom:$o}),d.some(m=>m.status==="unsupported")){i(d);return}t({variant:"success",content:e("adapter.governance.success.default")})}catch(l){let c=l instanceof Error?l.message:"DEFAULT";t({variant:"error",content:e(`adapter.governance.error.${c}`)})}}}};import{Button as Ax}from"@produto-lecom/lecom-ui";import{useRef as Cx}from"react";import{Fragment as Sx,jsx as Bu,jsxs as Mx}from"react/jsx-runtime";var zu=a=>{var l=a,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,s=gt(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=Cx(null),d=m=>{let p=m.target.files;p!=null&&p.length&&i(p),c.current&&(c.current.value="")};return Mx(Sx,{children:[Bu(Ax,v(b({disabled:n,onClick:m=>{var p;(p=c.current)==null||p.click(),r==null||r(m)}},s),{children:e})),Bu("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};import{jsx as fi,jsxs as Dx}from"react/jsx-runtime";var Yu=({disabled:e=!1})=>{let{t}=kx(),{toast:o}=We(),{importFromGovernance:n}=Gu(),r=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},i=s=>{let a=s[0];if(!a){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}n(a)};return Dx(Px,{children:[fi(Rx,{asChild:!0,children:fi(zu,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:fi(Us,{})})}),fi(Lx,{color:"black",children:t("editor.controls.actions.import_governance")})]})};import{jsx as Ox}from"react/jsx-runtime";var Is=({shortcut:e})=>Ox("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 Ux,DropdownMenu as $x,DropdownMenuContent as Kx,DropdownMenuItem as Cs,DropdownMenuTrigger as qx,Tooltip as gi,TooltipContent as hi,TooltipTrigger as yi,useTranslation as Zx}from"@produto-lecom/lecom-ui";import{FileCodeIcon as Jx,FileImageIcon as Qx,FolderOutputIcon as jx,PrinterIcon as eE}from"lucide-react";import{useState as tE}from"react";import{useTranslation as Vx}from"@produto-lecom/lecom-ui";import{useReactFlow as Hx}from"@xyflow/react";import{toPng as Wu,toSvg as Gx}from"html-to-image";import{useState as Bx}from"react";var zx=3,As="diagram",mi=50,Yx=96,Wx=25.4,Fx="sequence-edge-marker",Fu=e=>e*Wx/Yx,Xx=e=>{let t=document.getElementById(Fx);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},Xu=()=>{let{t:e}=Vx(),{toast:t}=We(),{getEdges:o,getNodes:n,getNodesBounds:r}=Hx(),{clearSelection:i}=Yt(),[s,a]=Bx({png:!1,html:!1,print:!1}),l=()=>{let p=us(n(),o()),h=r(p),E=h.width+mi*2,f=h.height+mi*2,g=mi-h.x,y=mi-h.y;return{width:E,height:f,style:{width:`${E}px`,height:`${f}px`,transform:`translate(${g}px, ${y}px)`,transformOrigin:"top left"}}},c=async(p,h)=>{a(E=>v(b({},E),{[h]:!0})),await i();try{if(us(n(),o()).length===0){t({content:e("editor.controls.actions.export.feedback.empty"),variant:"warning"});return}let f=Qc();if(!f)throw new Error("Flow element not found");let g=l(),y=Xx(f);try{return await p(f,g)}finally{y==null||y.remove()}}catch(E){console.error("Diagram export failed",E),t({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{a(E=>v(b({},E),{[h]:!1}))}};return{exportAsPng:async(p=As)=>{await c(async(h,E)=>{let f=await Wu(h,v(b({},E),{backgroundColor:"#fcfcfc",skipFonts:!0}));pi(f,`${p}.png`)},"png")},exportAsHtml:async(p=As)=>{await c(async(h,E)=>{let f=await Gx(h,v(b({},E),{backgroundColor:"#fcfcfc",skipFonts:!0})),g=`
|
|
44
44
|
<!DOCTYPE html>
|
|
45
45
|
<html>
|
|
46
46
|
<head>
|
|
@@ -67,9 +67,9 @@ var cp=Object.defineProperty,dp=Object.defineProperties;var up=Object.getOwnProp
|
|
|
67
67
|
<body>
|
|
68
68
|
<img src="${f}" alt="${p}" />
|
|
69
69
|
</body>
|
|
70
|
-
</html>`,y=new Blob([
|
|
70
|
+
</html>`,y=new Blob([g],{type:"text/html"}),x=URL.createObjectURL(y);pi(x,`${p}.html`),window.setTimeout(()=>URL.revokeObjectURL(x),1e4)},"html")},printDiagram:async(p=As)=>{await c(async(h,E)=>{var C;let f=await Wu(h,v(b({},E),{backgroundColor:"#fcfcfc",pixelRatio:zx,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 y=(C=g.contentWindow)==null?void 0:C.document;if(!y)throw document.body.removeChild(g),new Error("Unable to access print iframe document");let x=Fu(E.width).toFixed(2),w=Fu(E.height).toFixed(2),_=y.createElement("style");_.textContent=`
|
|
71
71
|
@page {
|
|
72
|
-
size: ${
|
|
72
|
+
size: ${x}mm ${w}mm;
|
|
73
73
|
margin: 0;
|
|
74
74
|
}
|
|
75
75
|
html, body {
|
|
@@ -83,4 +83,4 @@ var cp=Object.defineProperty,dp=Object.defineProperties;var up=Object.getOwnProp
|
|
|
83
83
|
height: 100%;
|
|
84
84
|
object-fit: contain;
|
|
85
85
|
}
|
|
86
|
-
`,y.head.appendChild(N),y.title=p;let T=y.createElement("img");T.alt="Diagram",y.body.appendChild(T),await new Promise((C,O)=>{let P=!1,H=q=>{P||(P=!0,q?O(q):C())};T.onload=()=>H(),T.onerror=()=>H(new Error("Failed to load print image")),T.src=f,T.complete&&T.naturalWidth>0&&H()});let _=h.contentWindow;if(!_)throw document.body.removeChild(h),new Error("Unable to access print iframe window");let A=()=>{h.parentNode&&document.body.removeChild(h)};_.addEventListener("afterprint",A,{once:!0}),window.setTimeout(A,6e4),_.focus(),_.print()},"print")},isPrintingPng:s.png,isPrintingHtml:s.html,isPrinting:s.print}};import{jsx as Le,jsxs as qo}from"react/jsx-runtime";function $u(){let{t:e}=qx(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:s}=Uu(),[a,l]=eE(!1);return qo(Ux,{modal:!1,open:a,onOpenChange:l,children:[Le(Kx,{asChild:!0,children:Le("div",{children:qo(gi,{children:[Le(yi,{asChild:!0,children:Le(Xx,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:Le(Qx,{})})}),!a&&Le(hi,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),qo($x,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[qo(gi,{children:[Le(yi,{asChild:!0,children:Le(Cs,{className:"p-1.5",disabled:i,onClick:()=>t(),children:Le(Jx,{})})}),Le(hi,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),qo(gi,{children:[Le(yi,{asChild:!0,children:Le(Cs,{className:"p-1.5",disabled:s,onClick:()=>o(),children:Le(Zx,{})})}),Le(hi,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),qo(gi,{children:[Le(yi,{asChild:!0,children:Le(Cs,{className:"p-1.5",disabled:r,onClick:()=>n(),children:Le(jx,{})})}),Le(hi,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as Zu,jsx as Pe,jsxs as Rt}from"react/jsx-runtime";var Ju=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=oE(),{clearSelection:i}=Yt(),{mode:s,isMinimapOpen:a,setIsMinimapOpen:l,isMoveTool:c,isHandTool:d,setIsMoveTool:u,setIsHandTool:m}=U(),{getNodes:p,getEdges:g}=tE(),x=Ku(["v","V"]),f=Ku(["h","H"]),h=Ss(()=>{i(),m(!0),u(!1)},[i,m,u]),y=Ss(()=>{u(!0),m(!1)},[u,m]),[E,v]=lE(!1),N=Ss(async()=>{v(!0);try{let T=p(),_=g(),A=await o({nodes:T,edges:_});n(A)}finally{v(!1)}},[p,g,o,n]);return qu(()=>{x&&!c&&s==="edit"&&y()},[x,y,c,s]),qu(()=>{f&&!d&&s==="edit"&&h()},[f,h,d,s]),Rt("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[s==="edit"&&Rt(Zu,{children:[Rt(Ei,{children:[Pe(_i,{asChild:!0,children:Pe(xi,{size:"small",variant:"ghost",color:"grey",className:G(c&&"bg-grey-400"),iconButton:!0,onClick:y,children:Pe(aE,{})})}),Rt(bi,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),Pe(Is,{shortcut:"V"})]})]}),Rt(Ei,{children:[Pe(_i,{asChild:!0,children:Pe(xi,{size:"small",variant:"ghost",color:"grey",className:G(d&&"bg-grey-400"),iconButton:!0,onClick:h,children:Pe(nE,{})})}),Rt(bi,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",Pe(Is,{shortcut:"H"})]})]})]}),Pe($u,{}),s==="edit"&&Rt(Zu,{children:[Rt(Ei,{children:[Pe(_i,{asChild:!0,children:Pe(xi,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:E,onClick:N,children:E?Pe(iE,{className:"animate-spin"}):Pe(rE,{})})}),Pe(bi,{color:"black",children:r(E?"editor.controls.actions.check_loading":"editor.controls.actions.check")})]}),Pe(Wu,{disabled:e.length>0||t.length>0})]}),Rt(Ei,{children:[Pe(_i,{asChild:!0,children:Pe(xi,{size:"small",variant:"ghost",color:"grey",className:G(a&&"bg-grey-400"),iconButton:!0,onClick:()=>l(!a),children:Pe(sE,{})})}),Pe(bi,{color:"black",children:r(a?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as Qu,Tooltip as ju,TooltipContent as ep,TooltipTrigger as tp,useTranslation as cE}from"@produto-lecom/lecom-ui";import{RedoIcon as dE,UndoIcon as uE}from"lucide-react";import{jsx as jt,jsxs as Ms}from"react/jsx-runtime";var op=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=cE();return Ms("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Ms(ju,{children:[jt(tp,{asChild:!0,children:jt(Qu,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:jt(uE,{})})}),jt(ep,{color:"black",children:r("editor.controls.history.undo")})]}),Ms(ju,{children:[jt(tp,{asChild:!0,children:jt(Qu,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:jt(dE,{})})}),jt(ep,{color:"black",children:r("editor.controls.history.redo")})]})]})};import{useEdges as pE,useNodes as fE,useReactFlow as mE}from"@xyflow/react";import{Button as Ti,Tooltip as Ni,TooltipContent as vi,TooltipTrigger as wi,useTranslation as gE}from"@produto-lecom/lecom-ui";import{ScanIcon as hE,ZoomIn as yE,ZoomOut as xE}from"lucide-react";import{jsx as Ve,jsxs as Dn}from"react/jsx-runtime";var np=()=>{let{t:e}=gE(),t=fE(),o=pE(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:s}=mE(),a=t.length===0&&o.length===0;return Dn("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Dn(Ni,{children:[Ve(wi,{asChild:!0,children:Ve(Ti,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>s(),children:Ve(hE,{})})}),Ve(vi,{color:"black",children:e("editor.controls.zoom.fit")})]}),Dn(Ni,{children:[Ve(wi,{asChild:!0,children:Ve(Ti,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>r(),children:Ve(xE,{})})}),Ve(vi,{color:"black",children:e("editor.controls.zoom.out")})]}),Dn(Ni,{children:[Ve(wi,{asChild:!0,children:Ve(Ti,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>i(1),children:Ve(Zs,{})})}),Ve(vi,{color:"black",children:e("editor.controls.zoom.reset")})]}),Dn(Ni,{children:[Ve(wi,{asChild:!0,children:Ve(Ti,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>n(),children:Ve(yE,{})})}),Ve(vi,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{useNodes as EE}from"@xyflow/react";import{Button as bE,Tooltip as _E,TooltipContent as TE,TooltipTrigger as NE,useTranslation as vE}from"@produto-lecom/lecom-ui";import{useRef as wE,useState as IE}from"react";import{jsx as Eo,jsxs as rp}from"react/jsx-runtime";var ip=()=>{let e=wE(null),{t}=vE(),{setDraggableNode:o}=Yo(),n=EE(),{setIsDragging:r}=U(),[i,s]=IE(void 0),a=[{type:"START_EVENT",icon:zn,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:bo,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:Jo,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:jo,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:ea,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:js,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:To,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:No,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:_o,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:qs,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:Gn,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),s(Eo(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return rp("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:a.map((c,d)=>{let u=!zt(c.type,n),m=u?t("editor.toolbar.start_event_already_exists"):c.label;return rp(_E,{children:[Eo(NE,{asChild:!0,children:Eo(bE,{className:G("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":u}),size:"small",variant:"ghost",color:"grey",draggable:!u,disabled:u,iconButton:!0,onDragStart:u?void 0:p=>l(p,c),children:Eo(c.icon,{})},d)}),Eo(TE,{color:"black",side:"right",children:m})]},d)})}),Eo("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{jsx as dt,jsxs as Ii}from"react/jsx-runtime";var Ls=e=>e.preventDefault(),Rs=LE((e,t)=>{let o=PE("Space"),{instanceId:n,mode:r,isMinimapOpen:i,isMoveTool:s,isHandTool:a}=U(),l=Ps(null),c=Ps(a),d=Ps(o),{nodes:u,edges:m,actions:p,events:g,components:x,controls:f}=Iu(),{t:h}=VE();c.current=a,d.current=o;let y=Au(l,c,d);RE(t,()=>({selectElements:p.selectElements,clearSelection:p.clearSelection}));let E=a||o||r!=="edit",v=E?[0,1,2]:Cn,N=a||o||y,T=s&&!o&&!y,_=r==="edit"&&T,A=!E&&!y,M=r==="view"||T;return Ii("div",{ref:l,className:"w-full h-full",children:[r==="edit"&&dt(ip,{}),dt(Su,{}),Ii(SE,w(b({},g),{id:`modeler-${n}`,className:G(r.toLowerCase(),{"is-hand-tool":N,"is-pan-tool-active":N}),edges:m,nodes:u,nodeTypes:Hd,edgeTypes:Gd,minZoom:Ns,maxZoom:Xd,panOnDrag:v,panOnScroll:!0,selectionOnDrag:A,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:M,nodesConnectable:_,nodesDraggable:_,connectionLineComponent:Dd,selectionMode:ME.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:_?"Delete":null,selectionKeyCode:null,defaultViewport:Ud,connectOnClick:!1,connectionRadius:50,onPaneContextMenu:Ls,onNodeContextMenu:Ls,onEdgeContextMenu:Ls,proOptions:{hideAttribution:!0},children:[dt(AE,{gap:Wd,size:Yd,color:zd,bgColor:Bd}),i&&Ii(kE,{children:[dt(OE,{asChild:!0,children:dt("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:dt(CE,{pannable:!0,zoomable:!0,position:Fd,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),dt(DE,{color:"black",children:h("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"&&dt(op,b({},f)),r!=="readonly"&&dt(Ju,{nodes:u,edges:m,validateDiagram:p.validateDiagram,handleValidationComplete:p.handleValidationComplete}),dt(np,{})]}),dt(x.HelperLines,{})]}))]})});Rs.displayName="Editor";import{useStore as HE}from"@xyflow/react";import{useEffect as GE,useRef as BE}from"react";import{jsx as YE}from"react/jsx-runtime";var zE=e=>({width:e.width,height:e.height,transform:e.transform}),ks="rgba(51, 103, 217, 0.4)",ac=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=HE(zE),i=BE(null);return GE(()=>{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]),YE("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as WE,Notification as FE,TooltipProvider as XE}from"@produto-lecom/lecom-ui";import{createContext as UE,useContext as $E,useEffect as KE,useState as qE}from"react";import{jsx as sp,jsxs as JE}from"react/jsx-runtime";var Et=new Map,ap=UE(null),bn=()=>{let e=$E(ap);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},ZE=({locale:e,defaultMode:t="view",toast:o,children:n})=>{let[r,i]=qE(e||"pt_BR");KE(()=>{e&&(i(e),WE.changeLanguage(e))},[e]);let s=g=>{let x=Et.size;if(x===0)throw new Error("No modeler instances found");if(x===1||!g){let[h]=Et.values();return h}let f=Et.get(g);if(!f)throw new Error(`Modeler instance with ID "${g}" not found`);return f},a=(g,x)=>{let f=s(x);return f==null?void 0:f.selectElements(g)},l=async g=>{let x=s(g);return x==null?void 0:x.clearSelection()},c=(g,x)=>{let f=s(x);return f==null?void 0:f.configureElement(g)},d=(g,x)=>{let f=s(x);return f==null?void 0:f.getConfigureElement(g)},u=async(g,x)=>{let f=s(x);await(f==null?void 0:f.importFromMxGraph(g))},m=g=>{let x=s(g);return x==null?void 0:x.exportToMxGraph()},p=g=>{let x=s(g);return(x==null?void 0:x.getElementsCount())||0};return sp(ap.Provider,{value:{defaultMode:t,locale:r,selectElements:a,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:u,exportDiagram:m,getElementsCount:p,toast:o},children:JE(XE,{children:[!o&&sp(FE,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};import{jsx as Ds}from"react/jsx-runtime";var lp=e1(null),U=()=>{let e=t1(lp);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},i1=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,edgeHighlight:r=!0,validateCustomDiagram:i,onElementChanges:s,onConfigureElement:a,onElementClick:l,onSubprocessValidationClick:c})=>{let{t:d}=QE(),{defaultMode:u}=bn(),m=n1(),[p]=ut(o||m),[g,x]=ut(n||u||"edit"),[f,h]=ut(vn),[y,E]=ut(!1),[v,N]=ut(!0),[T,_]=ut(!1),[A,M]=ut(!1),[C,O]=ut(!1),[P,H]=ut(!1),[q,Q]=ut(!1),[te,z]=ut(null);o1(()=>{n&&x(n)},[n]);let S=!!t,V=r1(()=>t||ed(d),[t,d]),R={instanceId:p,initialDiagram:V,mode:g,edgeHighlight:r,isEdit:g==="edit",isView:g==="view",isReadOnly:g==="readonly",isNewDiagram:S,lastElementId:f,isInitialized:y,isMinimapOpen:A,isMoveTool:v,isHandTool:T,isDragging:C,isMultipleSelection:q,isConnecting:P,setLastElementId:h,setIsInitialized:E,reconnectingEdgeId:te,setIsMinimapOpen:M,setIsMoveTool:N,setIsHandTool:_,setIsDragging:O,setIsConnecting:H,setIsMultipleSelection:Q,setReconnectingEdgeId:z,validateCustomDiagram:i,onElementChanges:s,onConfigureElement:a,onElementClick:l,onSubprocessValidationClick:c};return Ds(jE,{children:Ds(lp.Provider,{value:R,children:Ds(Rs,{ref:e})})})};export{Ie as EditorMode,Ci as ElementPosition,Vn as ElementType,Si as GatewayElementVariant,at as GatewayVariant,i1 as Modeler,ZE as ModelerProvider,ht as NodeAttribute,ae as NodeType,tt as NodeVariant,Mi as RoutingVariant,bn as useModeler};
|
|
86
|
+
`,y.head.appendChild(_),y.title=p;let N=y.createElement("img");N.alt="Diagram",y.body.appendChild(N),await new Promise((P,R)=>{let S=!1,L=$=>{S||(S=!0,$?R($):P())};N.onload=()=>L(),N.onerror=()=>L(new Error("Failed to load print image")),N.src=f,N.complete&&N.naturalWidth>0&&L()});let T=g.contentWindow;if(!T)throw document.body.removeChild(g),new Error("Unable to access print iframe window");let 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 qo}from"react/jsx-runtime";function Uu(){let{t:e}=Zx(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:s}=Xu(),[a,l]=tE(!1);return qo($x,{modal:!1,open:a,onOpenChange:l,children:[Le(qx,{asChild:!0,children:Le("div",{children:qo(gi,{children:[Le(yi,{asChild:!0,children:Le(Ux,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:Le(jx,{})})}),!a&&Le(hi,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),qo(Kx,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[qo(gi,{children:[Le(yi,{asChild:!0,children:Le(Cs,{className:"p-1.5",disabled:i,onClick:()=>t(),children:Le(Qx,{})})}),Le(hi,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),qo(gi,{children:[Le(yi,{asChild:!0,children:Le(Cs,{className:"p-1.5",disabled:s,onClick:()=>o(),children:Le(Jx,{})})}),Le(hi,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),qo(gi,{children:[Le(yi,{asChild:!0,children:Le(Cs,{className:"p-1.5",disabled:r,onClick:()=>n(),children:Le(eE,{})})}),Le(hi,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as qu,jsx as Pe,jsxs as Rt}from"react/jsx-runtime";var Zu=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=nE(),{clearSelection:i}=Yt(),{mode:s,containerRef:a,isMinimapOpen:l,setIsMinimapOpen:c,isMoveTool:d,isHandTool:u,setIsMoveTool:m,setIsHandTool:p}=U(),{getNodes:h,getEdges:E}=oE(),f=$u(["v","V"],{target:a==null?void 0:a.current}),g=$u(["h","H"],{target:a==null?void 0:a.current}),y=Ss(()=>{i(),p(!0),m(!1)},[i,p,m]),x=Ss(()=>{m(!0),p(!1)},[m,p]),[w,_]=cE(!1),N=Ss(async()=>{_(!0);try{let T=h(),I=E(),C=await o({nodes:T,edges:I});n(C)}finally{_(!1)}},[h,E,o,n]);return Ku(()=>{f&&!d&&s==="edit"&&x()},[f,x,d,s]),Ku(()=>{g&&!u&&s==="edit"&&y()},[g,y,u,s]),Rt("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[s==="edit"&&Rt(qu,{children:[Rt(Ei,{children:[Pe(_i,{asChild:!0,children:Pe(xi,{size:"small",variant:"ghost",color:"grey",className:G(d&&"bg-grey-400"),iconButton:!0,onClick:x,children:Pe(lE,{})})}),Rt(bi,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),Pe(Is,{shortcut:"V"})]})]}),Rt(Ei,{children:[Pe(_i,{asChild:!0,children:Pe(xi,{size:"small",variant:"ghost",color:"grey",className:G(u&&"bg-grey-400"),iconButton:!0,onClick:y,children:Pe(rE,{})})}),Rt(bi,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",Pe(Is,{shortcut:"H"})]})]})]}),Pe(Uu,{}),s==="edit"&&Rt(qu,{children:[Rt(Ei,{children:[Pe(_i,{asChild:!0,children:Pe(xi,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:w,onClick:N,children:w?Pe(sE,{className:"animate-spin"}):Pe(iE,{})})}),Pe(bi,{color:"black",children:r(w?"editor.controls.actions.check_loading":"editor.controls.actions.check")})]}),Pe(Yu,{disabled:e.length>0||t.length>0})]}),Rt(Ei,{children:[Pe(_i,{asChild:!0,children:Pe(xi,{size:"small",variant:"ghost",color:"grey",className:G(l&&"bg-grey-400"),iconButton:!0,onClick:()=>c(!l),children:Pe(aE,{})})}),Pe(bi,{color:"black",children:r(l?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as Ju,Tooltip as Qu,TooltipContent as ju,TooltipTrigger as ep,useTranslation as dE}from"@produto-lecom/lecom-ui";import{RedoIcon as uE,UndoIcon as pE}from"lucide-react";import{jsx as jt,jsxs as Ms}from"react/jsx-runtime";var tp=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=dE();return Ms("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Ms(Qu,{children:[jt(ep,{asChild:!0,children:jt(Ju,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:jt(pE,{})})}),jt(ju,{color:"black",children:r("editor.controls.history.undo")})]}),Ms(Qu,{children:[jt(ep,{asChild:!0,children:jt(Ju,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:jt(uE,{})})}),jt(ju,{color:"black",children:r("editor.controls.history.redo")})]})]})};import{useEdges as fE,useNodes as mE,useReactFlow as gE}from"@xyflow/react";import{Button as Ti,Tooltip as Ni,TooltipContent as vi,TooltipTrigger as wi,useTranslation as hE}from"@produto-lecom/lecom-ui";import{ScanIcon as yE,ZoomIn as xE,ZoomOut as EE}from"lucide-react";import{jsx as Ve,jsxs as Dn}from"react/jsx-runtime";var op=()=>{let{t:e}=hE(),t=mE(),o=fE(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:s}=gE(),a=t.length===0&&o.length===0;return Dn("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Dn(Ni,{children:[Ve(wi,{asChild:!0,children:Ve(Ti,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>s(),children:Ve(yE,{})})}),Ve(vi,{color:"black",children:e("editor.controls.zoom.fit")})]}),Dn(Ni,{children:[Ve(wi,{asChild:!0,children:Ve(Ti,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>r(),children:Ve(EE,{})})}),Ve(vi,{color:"black",children:e("editor.controls.zoom.out")})]}),Dn(Ni,{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(vi,{color:"black",children:e("editor.controls.zoom.reset")})]}),Dn(Ni,{children:[Ve(wi,{asChild:!0,children:Ve(Ti,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>n(),children:Ve(xE,{})})}),Ve(vi,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{useNodes as bE}from"@xyflow/react";import{Button as _E,Tooltip as TE,TooltipContent as NE,TooltipTrigger as vE,useTranslation as wE}from"@produto-lecom/lecom-ui";import{useRef as IE,useState as AE}from"react";import{jsx as Eo,jsxs as np}from"react/jsx-runtime";var rp=()=>{let e=IE(null),{t}=wE(),{setDraggableNode:o}=Yo(),n=bE(),{setIsDragging:r}=U(),[i,s]=AE(void 0),a=[{type:"START_EVENT",icon:zn,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:bo,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:Jo,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:jo,label:t("bpmn.task.variant.subprocess")},{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:To,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:No,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:Gn,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),s(Eo(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return np("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:a.map((c,d)=>{let u=!zt(c.type,n),m=u?t("editor.toolbar.start_event_already_exists"):c.label;return np(TE,{children:[Eo(vE,{asChild:!0,children:Eo(_E,{className:G("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":u}),size:"small",variant:"ghost",color:"grey",draggable:!u,disabled:u,iconButton:!0,onDragStart:u?void 0:p=>l(p,c),children:Eo(c.icon,{})},d)}),Eo(NE,{color:"black",side:"right",children:m})]},d)})}),Eo("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{jsx as dt,jsxs as Ii}from"react/jsx-runtime";var Ps=e=>e.preventDefault(),Ls=RE((e,t)=>{let{instanceId:o,containerRef:n,mode:r,isMinimapOpen:i,isMoveTool:s,isHandTool:a}=U(),l=LE("Space",{target:n==null?void 0:n.current}),c=ip(a),d=ip(l),{nodes:u,edges:m,actions:p,events:h,components:E,controls:f}=wu(),{t:g}=HE();c.current=a,d.current=l;let y=Iu(n,c,d);kE(t,()=>({selectElements:p.selectElements,clearSelection:p.clearSelection}));let x=a||l||r!=="edit",w=x?[0,1,2]:Cn,_=a||l||y,N=s&&!l&&!y,T=r==="edit"&&N,I=!x&&!y,C=r==="view"||N;return Ii("div",{ref:n,className:"w-full h-full outline-none",tabIndex:0,children:[r==="edit"&&dt(rp,{}),dt(Cu,{}),Ii(ME,v(b({},h),{id:`modeler-${o}`,className:G(r.toLowerCase(),{"is-hand-tool":_,"is-pan-tool-active":_}),edges:m,nodes:u,nodeTypes:Vd,edgeTypes:Hd,minZoom:Ns,maxZoom:Fd,panOnDrag:w,panOnScroll:!0,selectionOnDrag:I,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:C,nodesConnectable:T,nodesDraggable:T,connectionLineComponent:kd,selectionMode:PE.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:T?"Delete":null,selectionKeyCode:null,defaultViewport:Xd,connectOnClick:!1,connectionRadius:50,onPaneContextMenu:Ps,onNodeContextMenu:Ps,onEdgeContextMenu:Ps,proOptions:{hideAttribution:!0},children:[dt(CE,{gap:Yd,size:zd,color:Bd,bgColor:Gd}),i&&Ii(DE,{children:[dt(VE,{asChild:!0,children:dt("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:dt(SE,{pannable:!0,zoomable:!0,position:Wd,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),dt(OE,{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"&&dt(tp,b({},f)),r!=="readonly"&&dt(Zu,{nodes:u,edges:m,validateDiagram:p.validateDiagram,handleValidationComplete:p.handleValidationComplete}),dt(op,{})]}),dt(E.HelperLines,{})]}))]})});Ls.displayName="Editor";import{useStore as GE}from"@xyflow/react";import{useEffect as BE,useRef as zE}from"react";import{jsx as WE}from"react/jsx-runtime";var YE=e=>({width:e.width,height:e.height,transform:e.transform}),Rs="rgba(51, 103, 217, 0.4)",sc=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=GE(YE),i=zE(null);return BE(()=>{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=Rs,t&&(a.beginPath(),a.strokeStyle=t.color||Rs,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||Rs,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]),WE("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as FE,Notification as XE,TooltipProvider as UE}from"@produto-lecom/lecom-ui";import{createContext as $E,useContext as KE,useEffect as qE,useState as ZE}from"react";import{jsx as sp,jsxs as QE}from"react/jsx-runtime";var Et=new Map,ap=$E(null),bn=()=>{let e=KE(ap);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},JE=({locale:e,defaultMode:t="view",toast:o,children:n})=>{let[r,i]=ZE(e||"pt_BR");qE(()=>{e&&(i(e),FE.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 f=Et.get(h);if(!f)throw new Error(`Modeler instance with ID "${h}" not found`);return f},a=(h,E)=>{let f=s(E);return f==null?void 0:f.selectElements(h)},l=async h=>{let E=s(h);return E==null?void 0:E.clearSelection()},c=(h,E)=>{let f=s(E);return f==null?void 0:f.configureElement(h)},d=(h,E)=>{let f=s(E);return f==null?void 0:f.getConfigureElement(h)},u=async(h,E)=>{let f=s(E);await(f==null?void 0:f.importFromMxGraph(h))},m=h=>{let E=s(h);return E==null?void 0:E.exportToMxGraph()},p=h=>{let E=s(h);return(E==null?void 0:E.getElementsCount())||0};return sp(ap.Provider,{value:{defaultMode:t,locale:r,selectElements:a,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:u,exportDiagram:m,getElementsCount:p,toast:o},children:QE(UE,{children:[!o&&sp(XE,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};import{jsx as ks}from"react/jsx-runtime";var cp=t1(null),U=()=>{let e=o1(cp);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},s1=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,edgeHighlight:r=!0,validateCustomDiagram:i,onElementChanges:s,onConfigureElement:a,onElementClick:l,onSubprocessValidationClick:c})=>{let d=i1(null),{t:u}=jE(),{defaultMode:m}=bn(),p=r1(),[h]=ut(o||p),[E,f]=ut(n||m||"edit"),[g,y]=ut(vn),[x,w]=ut(!1),[_,N]=ut(!0),[T,I]=ut(!1),[C,P]=ut(!1),[R,S]=ut(!1),[L,$]=ut(!1),[K,te]=ut(!1),[z,M]=ut(null);n1(()=>{n&&f(n)},[n]);let H=!!t,D=lp(()=>t||jc(u),[t,u]),A=lp(()=>({instanceId:h,containerRef:d,initialDiagram:D,mode:E,edgeHighlight:r,isEdit:E==="edit",isView:E==="view",isReadOnly:E==="readonly",isNewDiagram:H,lastElementId:g,isInitialized:x,isMinimapOpen:C,isMoveTool:_,isHandTool:T,isDragging:R,isMultipleSelection:K,isConnecting:L,setLastElementId:y,setIsInitialized:w,reconnectingEdgeId:z,setIsMinimapOpen:P,setIsMoveTool:N,setIsHandTool:I,setIsDragging:S,setIsConnecting:$,setIsMultipleSelection:te,setReconnectingEdgeId:M,validateCustomDiagram:i,onElementChanges:s,onConfigureElement:a,onElementClick:l,onSubprocessValidationClick:c}),[h,d,D,E,r,H,g,x,C,_,T,R,K,L,z,i,s,a,l,c]);return ks(e1,{children:ks(cp.Provider,{value:A,children:ks(Ls,{ref:e})})})};export{Ie as EditorMode,Ci as ElementPosition,Vn as ElementType,Si as GatewayElementVariant,at as GatewayVariant,s1 as Modeler,JE as ModelerProvider,ht as NodeAttribute,ae as NodeType,tt as NodeVariant,Mi as RoutingVariant,bn as useModeler};
|