lecom-modeler 0.16.4 → 0.17.1
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 +10 -10
- package/lib/index.js +10 -10
- package/lib/style.min.css +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var Wd=Object.defineProperty,Yd=Object.defineProperties;var Ud=Object.getOwnPropertyDescriptors;var rn=Object.getOwnPropertySymbols;var Ri=Object.prototype.hasOwnProperty,Oi=Object.prototype.propertyIsEnumerable;var Di=(e,t,o)=>t in e?Wd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,E=(e,t)=>{for(var o in t||(t={}))Ri.call(t,o)&&Di(e,o,t[o]);if(rn)for(var o of rn(t))Oi.call(t,o)&&Di(e,o,t[o]);return e},w=(e,t)=>Yd(e,Ud(t));var Xe=(e,t)=>{var o={};for(var n in e)Ri.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&rn)for(var n of rn(e))t.indexOf(n)<0&&Oi.call(e,n)&&(o[n]=e[n]);return o};var Vr=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 $d,Translations as Xd}from"lecom-ui";var Vi={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Delete",configure_node:"Configure activity",configure_edge:"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..."},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",export:{title:"Export diagram",print:"Print",html:"Export as HTML",png:"Export as PNG",feedback:{error:"Error exporting diagram"}},import_governance:"Import diagram from Governance platform",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_referenced_not_configured:"The subprocess reference is not properly 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 Hi={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",configure_node:"Configurar actividad",configure_edge:"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..."},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",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{error:"Error al exportar diagrama"}},import_governance:"Importar diagrama de la plataforma Governance",minimap:{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_referenced_not_configured:"La referencia al subproceso no est\xE1 configurada correctamente",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 Gi={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Excluir",configure_node:"Configurar atividade",configure_edge:"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..."},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",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{error:"Erro ao exportar o diagrama"}},import_governance:"Importar diagrama da plataforma Governance",minimap:{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_referenced_not_configured:"A refer\xEAncia ao subprocesso n\xE3o est\xE1 configurada corretamente",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 Bi={pt_BR:Gi,en_US:Vi,es_ES:Hi};var zi,Fi,Kd=(Fi=(zi=Vr("LecomUserLanguage"))!=null?zi:Vr("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?Fi:Xd.PT_BR;$d({lng:Kd,resources:Bi});var ke=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(ke||{});var sn=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(sn||{}),Hr=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Hr||{}),Gr=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Gr||{}),Br=(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))(Br||{});import{RotateCcw as su,ScrollText as au,SquarePlus as lu}from"lucide-react";import{jsx as an,jsxs as qd}from"react/jsx-runtime";var ln=({size:e=24,className:t})=>qd("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[an("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),an("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),an("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),an("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as Wi}from"react/jsx-runtime";var Ht=({size:e=24,className:t})=>Wi("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:Wi("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 xo,jsxs as Zd}from"react/jsx-runtime";var Gt=({size:e=24,className:t})=>Zd("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:[xo("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"}),xo("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),xo("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),xo("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),xo("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as zr,jsxs as Jd}from"react/jsx-runtime";var Bt=({size:e=24,className:t})=>Jd("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:[zr("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"}),zr("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),zr("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Fr,jsxs as Qd}from"react/jsx-runtime";var zt=({size:e=24,className:t})=>Qd("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:[Fr("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"}),Fr("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Fr("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Wr,jsxs as jd}from"react/jsx-runtime";var Yi=({size:e=24,className:t})=>Wr("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:jd("g",{children:[Wr("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"}),Wr("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as eu}from"clsx";import{twMerge as tu}from"tailwind-merge";function k(...e){return tu(eu(e))}var ot=(e=0,t=0)=>e<t?t:e,cn=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as Ui,jsxs as ou}from"react/jsx-runtime";var $i=({size:e=24,className:t})=>ou("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:k("stroke-2",t),children:[Ui("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"}),Ui("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Yr}from"react/jsx-runtime";var Xi=({size:e=24,className:t})=>Yr("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:Yr("g",{children:Yr("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 Ki}from"react/jsx-runtime";var dn=({size:e=24,className:t})=>Ki("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:Ki("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 qi}from"react/jsx-runtime";var Eo=({size:e=24,className:t})=>qi("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",className:k("stroke-2",t),children:qi("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 Ur,jsxs as nu}from"react/jsx-runtime";var Zi=({size:e=24,className:t})=>nu("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:[Ur("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"}),Ur("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"}),Ur("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as bo,jsxs as ru}from"react/jsx-runtime";var Ji=({size:e=24,className:t})=>ru("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:[bo("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"}),bo("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"}),bo("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"}),bo("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),bo("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as un,jsxs as iu}from"react/jsx-runtime";var Qi=({size:e=24,className:t})=>iu("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:[un("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),un("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),un("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),un("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var j=(s=>(s.START_EVENT="START_EVENT",s.END_EVENT="END_EVENT",s.TASK="TASK",s.LANE="LANE",s.GATEWAY="GATEWAY",s.ANNOTATION="ANNOTATION",s.UNSUPPORTED="UNSUPPORTED",s))(j||{}),Fe=(o=>(o.SCRIPT="SCRIPT",o.SUBPROCESS="SUBPROCESS",o))(Fe||{}),pn={SCRIPT:{icon:au},SUBPROCESS:{icon:lu}},nt=(t=>(t.LOOP="LOOP",t))(nt||{}),fn={LOOP:{icon:su}},We=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(We||{}),$r={EXCLUSIVE:{icon:Bt},PARALLEL:{icon:zt},COMPLEX:{icon:Gt}};import{ReactFlowProvider as zy}from"@xyflow/react";import{createContext as Fy,useContext as Wy,useEffect as Yy,useId as Uy,useMemo as $y,useState as $e}from"react";import{Background as _y,MiniMap as Ty,ReactFlow as vy,SelectionMode as Ny}from"@xyflow/react";import{forwardRef as wy,useImperativeHandle as Ay}from"react";import{useEdgesState as r0,useNodesState as i0,useOnSelectionChange as s0,useReactFlow as a0}from"@xyflow/react";import{useCallback as go,useEffect as l0}from"react";import{create as cu}from"zustand";import{useReactFlow as du}from"@xyflow/react";import{useCallback as uu}from"react";var mn=()=>{let{setEdges:e}=du();return uu(()=>{let o=vt.getState().pathEdgeIds;e(n=>n.map(r=>w(E({},r),{selected:o.includes(r.id)})))},[e])},vt=cu((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=E({},n.statusByNodeId),i=E({},n.statusData),a=!1;return o.forEach(s=>{let l=`${s.diagramId}-${s.activityId}`;r[s.diagramId]!==s.status&&(r[s.diagramId]=s.status,i[l]=s,a=!0)}),a?{statusByNodeId:r,statusData:i}:n})},getTaskStatus:o=>t().statusByNodeId[o]||null,clearTaskStatuses:()=>e({statusByNodeId:{},statusData:{},pathEdgeIds:[]}),setPathEdges:o=>{e({pathEdgeIds:o})},getPathEdgeIds:()=>t().pathEdgeIds,clearPathEdges:()=>{e({pathEdgeIds:[]})},calculateFlowPath:(o,n)=>{if(!o.length||!n.length)return;t().clearPathEdges();let r=n.filter(d=>t().statusByNodeId[d]);if(r.length<=1)return;let i=[],a={};o.forEach(d=>{a[d.source]||(a[d.source]=[]),a[d.source].push({targetId:d.target,edgeId:d.id})});let s=r[0],l=r[r.length-1];o.forEach(d=>{d.target===s&&i.push(d.id)}),o.forEach(d=>{d.source===l&&i.push(d.id)});let c=(d,u)=>{let p=[],m=new Set;for(p.push({node:d,path:[]}),m.add(d);p.length>0;){let{node:h,path:g}=p.shift();if(h===u)return g;let f=a[h]||[];for(let{targetId:y,edgeId:x}of f)m.has(y)||(m.add(y),p.push({node:y,path:[...g,x]}))}return[]};for(let d=0;d<r.length-1;d++){let u=r[d],p=r[d+1],m=c(u,p);m.length>0&&i.push(...m)}i.length>0&&e({pathEdgeIds:i})}}));import{useNodesInitialized as If,useReactFlow as Cf,useStore as Sf}from"@xyflow/react";var pu={value:()=>{}};function es(){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 gn(o)}function gn(e){this._=e}function fu(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}})}gn.prototype=es.prototype={constructor:gn,on:function(e,t){var o=this._,n=fu(e+"",o),r,i=-1,a=n.length;if(arguments.length<2){for(;++i<a;)if((r=(e=n[i]).type)&&(r=mu(o[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<a;)if(r=(e=n[i]).type)o[r]=ji(o[r],e.name,t);else if(t==null)for(r in o)o[r]=ji(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 gn(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 mu(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function ji(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=pu,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var Xr=es;var hn="http://www.w3.org/1999/xhtml",Kr={svg:"http://www.w3.org/2000/svg",xhtml:hn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Je(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),Kr.hasOwnProperty(t)?{space:Kr[t],local:e}:e}function gu(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===hn&&t.documentElement.namespaceURI===hn?t.createElement(e):t.createElementNS(o,e)}}function hu(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function yn(e){var t=Je(e);return(t.local?hu:gu)(t)}function yu(){}function Nt(e){return e==null?yu:function(){return this.querySelector(e)}}function ts(e){typeof e!="function"&&(e=Nt(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=new Array(a),l,c,d=0;d<a;++d)(l=i[d])&&(c=e.call(l,l.__data__,d,i))&&("__data__"in l&&(c.__data__=l.__data__),s[d]=c);return new me(n,this._parents)}function qr(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function xu(){return[]}function _o(e){return e==null?xu:function(){return this.querySelectorAll(e)}}function Eu(e){return function(){return qr(e.apply(this,arguments))}}function os(e){typeof e=="function"?e=Eu(e):e=_o(e);for(var t=this._groups,o=t.length,n=[],r=[],i=0;i<o;++i)for(var a=t[i],s=a.length,l,c=0;c<s;++c)(l=a[c])&&(n.push(e.call(l,l.__data__,c,a)),r.push(l));return new me(n,r)}function To(e){return function(){return this.matches(e)}}function xn(e){return function(t){return t.matches(e)}}var bu=Array.prototype.find;function _u(e){return function(){return bu.call(this.children,e)}}function Tu(){return this.firstElementChild}function ns(e){return this.select(e==null?Tu:_u(typeof e=="function"?e:xn(e)))}var vu=Array.prototype.filter;function Nu(){return Array.from(this.children)}function wu(e){return function(){return vu.call(this.children,e)}}function rs(e){return this.selectAll(e==null?Nu:wu(typeof e=="function"?e:xn(e)))}function is(e){typeof e!="function"&&(e=To(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=[],l,c=0;c<a;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&s.push(l);return new me(n,this._parents)}function En(e){return new Array(e.length)}function ss(){return new me(this._enter||this._groups.map(En),this._parents)}function vo(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}vo.prototype={constructor:vo,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 as(e){return function(){return e}}function Au(e,t,o,n,r,i){for(var a=0,s,l=t.length,c=i.length;a<c;++a)(s=t[a])?(s.__data__=i[a],n[a]=s):o[a]=new vo(e,i[a]);for(;a<l;++a)(s=t[a])&&(r[a]=s)}function Iu(e,t,o,n,r,i,a){var s,l,c=new Map,d=t.length,u=i.length,p=new Array(d),m;for(s=0;s<d;++s)(l=t[s])&&(p[s]=m=a.call(l,l.__data__,s,t)+"",c.has(m)?r[s]=l:c.set(m,l));for(s=0;s<u;++s)m=a.call(e,i[s],s,i)+"",(l=c.get(m))?(n[s]=l,l.__data__=i[s],c.delete(m)):o[s]=new vo(e,i[s]);for(s=0;s<d;++s)(l=t[s])&&c.get(p[s])===l&&(r[s]=l)}function Cu(e){return e.__data__}function ls(e,t){if(!arguments.length)return Array.from(this,Cu);var o=t?Iu:Au,n=this._parents,r=this._groups;typeof e!="function"&&(e=as(e));for(var i=r.length,a=new Array(i),s=new Array(i),l=new Array(i),c=0;c<i;++c){var d=n[c],u=r[c],p=u.length,m=Su(e.call(d,d&&d.__data__,c,n)),h=m.length,g=s[c]=new Array(h),f=a[c]=new Array(h),y=l[c]=new Array(p);o(d,u,g,f,y,m,t);for(var x=0,_=0,b,T;x<h;++x)if(b=g[x]){for(x>=_&&(_=x+1);!(T=f[_])&&++_<h;);b._next=T||null}}return a=new me(a,n),a._enter=s,a._exit=l,a}function Su(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function cs(){return new me(this._exit||this._groups.map(En),this._parents)}function ds(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 us(e){for(var t=e.selection?e.selection():e,o=this._groups,n=t._groups,r=o.length,i=n.length,a=Math.min(r,i),s=new Array(r),l=0;l<a;++l)for(var c=o[l],d=n[l],u=c.length,p=s[l]=new Array(u),m,h=0;h<u;++h)(m=c[h]||d[h])&&(p[h]=m);for(;l<r;++l)s[l]=o[l];return new me(s,this._parents)}function ps(){for(var e=this._groups,t=-1,o=e.length;++t<o;)for(var n=e[t],r=n.length-1,i=n[r],a;--r>=0;)(a=n[r])&&(i&&a.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(a,i),i=a);return this}function fs(e){e||(e=Mu);function t(u,p){return u&&p?e(u.__data__,p.__data__):!u-!p}for(var o=this._groups,n=o.length,r=new Array(n),i=0;i<n;++i){for(var a=o[i],s=a.length,l=r[i]=new Array(s),c,d=0;d<s;++d)(c=a[d])&&(l[d]=c);l.sort(t)}return new me(r,this._parents).order()}function Mu(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function ms(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function gs(){return Array.from(this)}function hs(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length;r<i;++r){var a=n[r];if(a)return a}return null}function ys(){let e=0;for(let t of this)++e;return e}function xs(){return!this.node()}function Es(e){for(var t=this._groups,o=0,n=t.length;o<n;++o)for(var r=t[o],i=0,a=r.length,s;i<a;++i)(s=r[i])&&e.call(s,s.__data__,i,r);return this}function Pu(e){return function(){this.removeAttribute(e)}}function Lu(e){return function(){this.removeAttributeNS(e.space,e.local)}}function ku(e,t){return function(){this.setAttribute(e,t)}}function Du(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Ru(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function Ou(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 bs(e,t){var o=Je(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?Lu:Pu:typeof t=="function"?o.local?Ou:Ru:o.local?Du:ku)(o,t))}function bn(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Vu(e){return function(){this.style.removeProperty(e)}}function Hu(e,t,o){return function(){this.style.setProperty(e,t,o)}}function Gu(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function _s(e,t,o){return arguments.length>1?this.each((t==null?Vu:typeof t=="function"?Gu:Hu)(e,t,o==null?"":o)):rt(this.node(),e)}function rt(e,t){return e.style.getPropertyValue(t)||bn(e).getComputedStyle(e,null).getPropertyValue(t)}function Bu(e){return function(){delete this[e]}}function zu(e,t){return function(){this[e]=t}}function Fu(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function Ts(e,t){return arguments.length>1?this.each((t==null?Bu:typeof t=="function"?Fu:zu)(e,t)):this.node()[e]}function vs(e){return e.trim().split(/^|\s+/)}function Zr(e){return e.classList||new Ns(e)}function Ns(e){this._node=e,this._names=vs(e.getAttribute("class")||"")}Ns.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 ws(e,t){for(var o=Zr(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function As(e,t){for(var o=Zr(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function Wu(e){return function(){ws(this,e)}}function Yu(e){return function(){As(this,e)}}function Uu(e,t){return function(){(t.apply(this,arguments)?ws:As)(this,e)}}function Is(e,t){var o=vs(e+"");if(arguments.length<2){for(var n=Zr(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?Uu:t?Wu:Yu)(o,t))}function $u(){this.textContent=""}function Xu(e){return function(){this.textContent=e}}function Ku(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function Cs(e){return arguments.length?this.each(e==null?$u:(typeof e=="function"?Ku:Xu)(e)):this.node().textContent}function qu(){this.innerHTML=""}function Zu(e){return function(){this.innerHTML=e}}function Ju(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function Ss(e){return arguments.length?this.each(e==null?qu:(typeof e=="function"?Ju:Zu)(e)):this.node().innerHTML}function Qu(){this.nextSibling&&this.parentNode.appendChild(this)}function Ms(){return this.each(Qu)}function ju(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ps(){return this.each(ju)}function Ls(e){var t=typeof e=="function"?e:yn(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function ep(){return null}function ks(e,t){var o=typeof e=="function"?e:yn(e),n=t==null?ep:typeof t=="function"?t:Nt(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function tp(){var e=this.parentNode;e&&e.removeChild(this)}function Ds(){return this.each(tp)}function op(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function np(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Rs(e){return this.select(e?np:op)}function Os(e){return arguments.length?this.property("__data__",e):this.node().__data__}function rp(e){return function(t){e.call(this,t,this.__data__)}}function ip(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 sp(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 ap(e,t,o){return function(){var n=this.__on,r,i=rp(t);if(n){for(var a=0,s=n.length;a<s;++a)if((r=n[a]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=o),r.value=t;return}}this.addEventListener(e.type,i,o),r={type:e.type,name:e.name,value:t,listener:i,options:o},n?n.push(r):this.__on=[r]}}function Vs(e,t,o){var n=ip(e+""),r,i=n.length,a;if(arguments.length<2){var s=this.node().__on;if(s){for(var l=0,c=s.length,d;l<c;++l)for(r=0,d=s[l];r<i;++r)if((a=n[r]).type===d.type&&a.name===d.name)return d.value}return}for(s=t?ap:sp,r=0;r<i;++r)this.each(s(n[r],t,o));return this}function Hs(e,t,o){var n=bn(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 lp(e,t){return function(){return Hs(this,e,t)}}function cp(e,t){return function(){return Hs(this,e,t.apply(this,arguments))}}function Gs(e,t){return this.each((typeof t=="function"?cp:lp)(e,t))}function*Bs(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length,a;r<i;++r)(a=n[r])&&(yield a)}var dp=[null];function me(e,t){this._groups=e,this._parents=t}function zs(){return new me([[document.documentElement]],dp)}function up(){return this}me.prototype=zs.prototype={constructor:me,select:ts,selectAll:os,selectChild:ns,selectChildren:rs,filter:is,data:ls,enter:ss,exit:cs,join:ds,merge:us,selection:up,order:ps,sort:fs,call:ms,nodes:gs,node:hs,size:ys,empty:xs,each:Es,attr:bs,style:_s,property:Ts,classed:Is,text:Cs,html:Ss,raise:Ms,lower:Ps,append:Ls,insert:ks,remove:Ds,clone:Rs,datum:Os,on:Vs,dispatch:Gs,[Symbol.iterator]:Bs};var Qe=zs;function _n(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function Jr(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function Ao(){}var No=.7,Nn=1/No,Ft="\\s*([+-]?\\d+)\\s*",wo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ke="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",pp=/^#([0-9a-f]{3,8})$/,fp=new RegExp(`^rgb\\(${Ft},${Ft},${Ft}\\)$`),mp=new RegExp(`^rgb\\(${Ke},${Ke},${Ke}\\)$`),gp=new RegExp(`^rgba\\(${Ft},${Ft},${Ft},${wo}\\)$`),hp=new RegExp(`^rgba\\(${Ke},${Ke},${Ke},${wo}\\)$`),yp=new RegExp(`^hsl\\(${wo},${Ke},${Ke}\\)$`),xp=new RegExp(`^hsla\\(${wo},${Ke},${Ke},${wo}\\)$`),Fs={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};_n(Ao,it,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Ws,formatHex:Ws,formatHex8:Ep,formatHsl:bp,formatRgb:Ys,toString:Ys});function Ws(){return this.rgb().formatHex()}function Ep(){return this.rgb().formatHex8()}function bp(){return Zs(this).formatHsl()}function Ys(){return this.rgb().formatRgb()}function it(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=pp.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?Us(t):o===3?new Me(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?Tn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?Tn(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=fp.exec(e))?new Me(t[1],t[2],t[3],1):(t=mp.exec(e))?new Me(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=gp.exec(e))?Tn(t[1],t[2],t[3],t[4]):(t=hp.exec(e))?Tn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=yp.exec(e))?Ks(t[1],t[2]/100,t[3]/100,1):(t=xp.exec(e))?Ks(t[1],t[2]/100,t[3]/100,t[4]):Fs.hasOwnProperty(e)?Us(Fs[e]):e==="transparent"?new Me(NaN,NaN,NaN,0):null}function Us(e){return new Me(e>>16&255,e>>8&255,e&255,1)}function Tn(e,t,o,n){return n<=0&&(e=t=o=NaN),new Me(e,t,o,n)}function _p(e){return e instanceof Ao||(e=it(e)),e?(e=e.rgb(),new Me(e.r,e.g,e.b,e.opacity)):new Me}function Wt(e,t,o,n){return arguments.length===1?_p(e):new Me(e,t,o,n==null?1:n)}function Me(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}_n(Me,Wt,Jr(Ao,{brighter(e){return e=e==null?Nn:Math.pow(Nn,e),new Me(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?No:Math.pow(No,e),new Me(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Me(At(this.r),At(this.g),At(this.b),wn(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:$s,formatHex:$s,formatHex8:Tp,formatRgb:Xs,toString:Xs}));function $s(){return`#${wt(this.r)}${wt(this.g)}${wt(this.b)}`}function Tp(){return`#${wt(this.r)}${wt(this.g)}${wt(this.b)}${wt((isNaN(this.opacity)?1:this.opacity)*255)}`}function Xs(){let e=wn(this.opacity);return`${e===1?"rgb(":"rgba("}${At(this.r)}, ${At(this.g)}, ${At(this.b)}${e===1?")":`, ${e})`}`}function wn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function At(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function wt(e){return e=At(e),(e<16?"0":"")+e.toString(16)}function Ks(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new Ye(e,t,o,n)}function Zs(e){if(e instanceof Ye)return new Ye(e.h,e.s,e.l,e.opacity);if(e instanceof Ao||(e=it(e)),!e)return new Ye;if(e instanceof Ye)return e;e=e.rgb();var t=e.r/255,o=e.g/255,n=e.b/255,r=Math.min(t,o,n),i=Math.max(t,o,n),a=NaN,s=i-r,l=(i+r)/2;return s?(t===i?a=(o-n)/s+(o<n)*6:o===i?a=(n-t)/s+2:a=(t-o)/s+4,s/=l<.5?i+r:2-i-r,a*=60):s=l>0&&l<1?0:a,new Ye(a,s,l,e.opacity)}function Js(e,t,o,n){return arguments.length===1?Zs(e):new Ye(e,t,o,n==null?1:n)}function Ye(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}_n(Ye,Js,Jr(Ao,{brighter(e){return e=e==null?Nn:Math.pow(Nn,e),new Ye(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?No:Math.pow(No,e),new Ye(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 Me(Qr(e>=240?e-240:e+120,r,n),Qr(e,r,n),Qr(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new Ye(qs(this.h),vn(this.s),vn(this.l),wn(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=wn(this.opacity);return`${e===1?"hsl(":"hsla("}${qs(this.h)}, ${vn(this.s)*100}%, ${vn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function qs(e){return e=(e||0)%360,e<0?e+360:e}function vn(e){return Math.max(0,Math.min(1,e||0))}function Qr(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 jr(e,t,o,n,r){var i=e*e,a=i*e;return((1-3*e+3*i-a)*t+(4-6*i+3*a)*o+(1+3*e+3*i-3*a)*n+a*r)/6}function Qs(e){var t=e.length-1;return function(o){var n=o<=0?o=0:o>=1?(o=1,t-1):Math.floor(o*t),r=e[n],i=e[n+1],a=n>0?e[n-1]:2*r-i,s=n<t-1?e[n+2]:2*i-r;return jr((o-n/t)*t,a,r,i,s)}}function js(e){var t=e.length;return function(o){var n=Math.floor(((o%=1)<0?++o:o)*t),r=e[(n+t-1)%t],i=e[n%t],a=e[(n+1)%t],s=e[(n+2)%t];return jr((o-n/t)*t,r,i,a,s)}}var ei=e=>()=>e;function vp(e,t){return function(o){return e+o*t}}function Np(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 ea(e){return(e=+e)==1?An:function(t,o){return o-t?Np(t,o,e):ei(isNaN(t)?o:t)}}function An(e,t){var o=t-e;return o?vp(e,o):ei(isNaN(e)?t:e)}var In=function e(t){var o=ea(t);function n(r,i){var a=o((r=Wt(r)).r,(i=Wt(i)).r),s=o(r.g,i.g),l=o(r.b,i.b),c=An(r.opacity,i.opacity);return function(d){return r.r=a(d),r.g=s(d),r.b=l(d),r.opacity=c(d),r+""}}return n.gamma=e,n}(1);function ta(e){return function(t){var o=t.length,n=new Array(o),r=new Array(o),i=new Array(o),a,s;for(a=0;a<o;++a)s=Wt(t[a]),n[a]=s.r||0,r[a]=s.g||0,i[a]=s.b||0;return n=e(n),r=e(r),i=e(i),s.opacity=1,function(l){return s.r=n(l),s.g=r(l),s.b=i(l),s+""}}}var wp=ta(Qs),Ap=ta(js);function Oe(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var oi=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ti=new RegExp(oi.source,"g");function Ip(e){return function(){return e}}function Cp(e){return function(t){return e(t)+""}}function ni(e,t){var o=oi.lastIndex=ti.lastIndex=0,n,r,i,a=-1,s=[],l=[];for(e=e+"",t=t+"";(n=oi.exec(e))&&(r=ti.exec(t));)(i=r.index)>o&&(i=t.slice(o,i),s[a]?s[a]+=i:s[++a]=i),(n=n[0])===(r=r[0])?s[a]?s[a]+=r:s[++a]=r:(s[++a]=null,l.push({i:a,x:Oe(n,r)})),o=ti.lastIndex;return o<t.length&&(i=t.slice(o),s[a]?s[a]+=i:s[++a]=i),s.length<2?l[0]?Cp(l[0].x):Ip(t):(t=l.length,function(c){for(var d=0,u;d<t;++d)s[(u=l[d]).i]=u.x(c);return s.join("")})}var oa=180/Math.PI,Cn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ri(e,t,o,n,r,i){var a,s,l;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(l=e*o+t*n)&&(o-=e*l,n-=t*l),(s=Math.sqrt(o*o+n*n))&&(o/=s,n/=s,l/=s),e*n<t*o&&(e=-e,t=-t,l=-l,a=-a),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*oa,skewX:Math.atan(l)*oa,scaleX:a,scaleY:s}}var Sn;function na(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Cn:ri(t.a,t.b,t.c,t.d,t.e,t.f)}function ra(e){return e==null?Cn:(Sn||(Sn=document.createElementNS("http://www.w3.org/2000/svg","g")),Sn.setAttribute("transform",e),(e=Sn.transform.baseVal.consolidate())?(e=e.matrix,ri(e.a,e.b,e.c,e.d,e.e,e.f)):Cn)}function ia(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,p,m,h){if(c!==u||d!==p){var g=m.push("translate(",null,t,null,o);h.push({i:g-4,x:Oe(c,u)},{i:g-2,x:Oe(d,p)})}else(u||p)&&m.push("translate("+u+t+p+o)}function a(c,d,u,p){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),p.push({i:u.push(r(u)+"rotate(",null,n)-2,x:Oe(c,d)})):d&&u.push(r(u)+"rotate("+d+n)}function s(c,d,u,p){c!==d?p.push({i:u.push(r(u)+"skewX(",null,n)-2,x:Oe(c,d)}):d&&u.push(r(u)+"skewX("+d+n)}function l(c,d,u,p,m,h){if(c!==u||d!==p){var g=m.push(r(m)+"scale(",null,",",null,")");h.push({i:g-4,x:Oe(c,u)},{i:g-2,x:Oe(d,p)})}else(u!==1||p!==1)&&m.push(r(m)+"scale("+u+","+p+")")}return function(c,d){var u=[],p=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,u,p),a(c.rotate,d.rotate,u,p),s(c.skewX,d.skewX,u,p),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,p),c=d=null,function(m){for(var h=-1,g=p.length,f;++h<g;)u[(f=p[h]).i]=f.x(m);return u.join("")}}}var ii=ia(na,"px, ","px)","deg)"),si=ia(ra,", ",")",")");var Yt=0,Co=0,Io=0,aa=1e3,Mn,So,Pn=0,It=0,Ln=0,Mo=typeof performance=="object"&&performance.now?performance:Date,la=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Lo(){return It||(la(Sp),It=Mo.now()+Ln)}function Sp(){It=0}function Po(){this._call=this._time=this._next=null}Po.prototype=kn.prototype={constructor:Po,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?Lo():+o)+(t==null?0:+t),!this._next&&So!==this&&(So?So._next=this:Mn=this,So=this),this._call=e,this._time=o,ai()},stop:function(){this._call&&(this._call=null,this._time=1/0,ai())}};function kn(e,t,o){var n=new Po;return n.restart(e,t,o),n}function ca(){Lo(),++Yt;for(var e=Mn,t;e;)(t=It-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Yt}function sa(){It=(Pn=Mo.now())+Ln,Yt=Co=0;try{ca()}finally{Yt=0,Pp(),It=0}}function Mp(){var e=Mo.now(),t=e-Pn;t>aa&&(Ln-=t,Pn=e)}function Pp(){for(var e,t=Mn,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:Mn=o);So=e,ai(n)}function ai(e){if(!Yt){Co&&(Co=clearTimeout(Co));var t=e-It;t>24?(e<1/0&&(Co=setTimeout(sa,e-Mo.now()-Ln)),Io&&(Io=clearInterval(Io))):(Io||(Pn=Mo.now(),Io=setInterval(Mp,aa)),Yt=1,la(sa))}}function Dn(e,t,o){var n=new Po;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var Lp=Xr("start","end","cancel","interrupt"),kp=[],pa=0,da=1,On=2,Rn=3,ua=4,Vn=5,ko=6;function st(e,t,o,n,r,i){var a=e.__transition;if(!a)e.__transition={};else if(o in a)return;Dp(e,o,{name:t,index:n,group:r,on:Lp,tween:kp,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:pa})}function Do(e,t){var o=ge(e,t);if(o.state>pa)throw new Error("too late; already scheduled");return o}function _e(e,t){var o=ge(e,t);if(o.state>Rn)throw new Error("too late; already running");return o}function ge(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function Dp(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=kn(i,0,o.time);function i(c){o.state=da,o.timer.restart(a,o.delay,o.time),o.delay<=c&&a(c-o.delay)}function a(c){var d,u,p,m;if(o.state!==da)return l();for(d in n)if(m=n[d],m.name===o.name){if(m.state===Rn)return Dn(a);m.state===ua?(m.state=ko,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete n[d]):+d<t&&(m.state=ko,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete n[d])}if(Dn(function(){o.state===Rn&&(o.state=ua,o.timer.restart(s,o.delay,o.time),s(c))}),o.state=On,o.on.call("start",e,e.__data__,o.index,o.group),o.state===On){for(o.state=Rn,r=new Array(p=o.tween.length),d=0,u=-1;d<p;++d)(m=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++u]=m);r.length=u+1}}function s(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=Vn,1),u=-1,p=r.length;++u<p;)r[u].call(e,d);o.state===Vn&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=ko,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function li(e,t){var o=e.__transition,n,r,i=!0,a;if(o){t=t==null?null:t+"";for(a in o){if((n=o[a]).name!==t){i=!1;continue}r=n.state>On&&n.state<Vn,n.state=ko,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[a]}i&&delete e.__transition}}function fa(e){return this.each(function(){li(this,e)})}function Rp(e,t){var o,n;return function(){var r=_e(this,e),i=r.tween;if(i!==o){n=o=i;for(var a=0,s=n.length;a<s;++a)if(n[a].name===t){n=n.slice(),n.splice(a,1);break}}r.tween=n}}function Op(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=_e(this,e),a=i.tween;if(a!==n){r=(n=a).slice();for(var s={name:t,value:o},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=s;break}l===c&&r.push(s)}i.tween=r}}function ma(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=ge(this.node(),o).tween,r=0,i=n.length,a;r<i;++r)if((a=n[r]).name===e)return a.value;return null}return this.each((t==null?Rp:Op)(o,e,t))}function Ut(e,t,o){var n=e._id;return e.each(function(){var r=_e(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return ge(r,n).value[t]}}function Hn(e,t){var o;return(typeof t=="number"?Oe:t instanceof it?In:(o=it(t))?(t=o,In):ni)(e,t)}function Vp(e){return function(){this.removeAttribute(e)}}function Hp(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Gp(e,t,o){var n,r=o+"",i;return function(){var a=this.getAttribute(e);return a===r?null:a===n?i:i=t(n=a,o)}}function Bp(e,t,o){var n,r=o+"",i;return function(){var a=this.getAttributeNS(e.space,e.local);return a===r?null:a===n?i:i=t(n=a,o)}}function zp(e,t,o){var n,r,i;return function(){var a,s=o(this),l;return s==null?void this.removeAttribute(e):(a=this.getAttribute(e),l=s+"",a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s)))}}function Fp(e,t,o){var n,r,i;return function(){var a,s=o(this),l;return s==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),l=s+"",a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s)))}}function ga(e,t){var o=Je(e),n=o==="transform"?si:Hn;return this.attrTween(e,typeof t=="function"?(o.local?Fp:zp)(o,n,Ut(this,"attr."+e,t)):t==null?(o.local?Hp:Vp)(o):(o.local?Bp:Gp)(o,n,t))}function Wp(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function Yp(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function Up(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Yp(e,i)),o}return r._value=t,r}function $p(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Wp(e,i)),o}return r._value=t,r}function ha(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=Je(e);return this.tween(o,(n.local?Up:$p)(n,t))}function Xp(e,t){return function(){Do(this,e).delay=+t.apply(this,arguments)}}function Kp(e,t){return t=+t,function(){Do(this,e).delay=t}}function ya(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Xp:Kp)(t,e)):ge(this.node(),t).delay}function qp(e,t){return function(){_e(this,e).duration=+t.apply(this,arguments)}}function Zp(e,t){return t=+t,function(){_e(this,e).duration=t}}function xa(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?qp:Zp)(t,e)):ge(this.node(),t).duration}function Jp(e,t){if(typeof t!="function")throw new Error;return function(){_e(this,e).ease=t}}function Ea(e){var t=this._id;return arguments.length?this.each(Jp(t,e)):ge(this.node(),t).ease}function Qp(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;_e(this,e).ease=o}}function ba(e){if(typeof e!="function")throw new Error;return this.each(Qp(this._id,e))}function _a(e){typeof e!="function"&&(e=To(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=[],l,c=0;c<a;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&s.push(l);return new Ae(n,this._parents,this._name,this._id)}function Ta(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,o=e._groups,n=t.length,r=o.length,i=Math.min(n,r),a=new Array(n),s=0;s<i;++s)for(var l=t[s],c=o[s],d=l.length,u=a[s]=new Array(d),p,m=0;m<d;++m)(p=l[m]||c[m])&&(u[m]=p);for(;s<n;++s)a[s]=t[s];return new Ae(a,this._parents,this._name,this._id)}function jp(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 ef(e,t,o){var n,r,i=jp(t)?Do:_e;return function(){var a=i(this,e),s=a.on;s!==n&&(r=(n=s).copy()).on(t,o),a.on=r}}function va(e,t){var o=this._id;return arguments.length<2?ge(this.node(),o).on.on(e):this.each(ef(o,e,t))}function tf(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function Na(){return this.on("end.remove",tf(this._id))}function wa(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Nt(e));for(var n=this._groups,r=n.length,i=new Array(r),a=0;a<r;++a)for(var s=n[a],l=s.length,c=i[a]=new Array(l),d,u,p=0;p<l;++p)(d=s[p])&&(u=e.call(d,d.__data__,p,s))&&("__data__"in d&&(u.__data__=d.__data__),c[p]=u,st(c[p],t,o,p,c,ge(d,o)));return new Ae(i,this._parents,t,o)}function Aa(e){var t=this._name,o=this._id;typeof e!="function"&&(e=_o(e));for(var n=this._groups,r=n.length,i=[],a=[],s=0;s<r;++s)for(var l=n[s],c=l.length,d,u=0;u<c;++u)if(d=l[u]){for(var p=e.call(d,d.__data__,u,l),m,h=ge(d,o),g=0,f=p.length;g<f;++g)(m=p[g])&&st(m,t,o,g,p,h);i.push(p),a.push(d)}return new Ae(i,a,t,o)}var of=Qe.prototype.constructor;function Ia(){return new of(this._groups,this._parents)}function nf(e,t){var o,n,r;return function(){var i=rt(this,e),a=(this.style.removeProperty(e),rt(this,e));return i===a?null:i===o&&a===n?r:r=t(o=i,n=a)}}function Ca(e){return function(){this.style.removeProperty(e)}}function rf(e,t,o){var n,r=o+"",i;return function(){var a=rt(this,e);return a===r?null:a===n?i:i=t(n=a,o)}}function sf(e,t,o){var n,r,i;return function(){var a=rt(this,e),s=o(this),l=s+"";return s==null&&(l=s=(this.style.removeProperty(e),rt(this,e))),a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s))}}function af(e,t){var o,n,r,i="style."+t,a="end."+i,s;return function(){var l=_e(this,e),c=l.on,d=l.value[i]==null?s||(s=Ca(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(a,r=d),l.on=n}}function Sa(e,t,o){var n=(e+="")=="transform"?ii:Hn;return t==null?this.styleTween(e,nf(e,n)).on("end.style."+e,Ca(e)):typeof t=="function"?this.styleTween(e,sf(e,n,Ut(this,"style."+e,t))).each(af(this._id,e)):this.styleTween(e,rf(e,n,t),o).on("end.style."+e,null)}function lf(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function cf(e,t,o){var n,r;function i(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&lf(e,a,o)),n}return i._value=t,i}function Ma(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,cf(e,t,o==null?"":o))}function df(e){return function(){this.textContent=e}}function uf(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function Pa(e){return this.tween("text",typeof e=="function"?uf(Ut(this,"text",e)):df(e==null?"":e+""))}function pf(e){return function(t){this.textContent=e.call(this,t)}}function ff(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&pf(r)),t}return n._value=e,n}function La(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,ff(e))}function ka(){for(var e=this._name,t=this._id,o=Gn(),n=this._groups,r=n.length,i=0;i<r;++i)for(var a=n[i],s=a.length,l,c=0;c<s;++c)if(l=a[c]){var d=ge(l,t);st(l,e,o,c,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Ae(n,this._parents,e,o)}function Da(){var e,t,o=this,n=o._id,r=o.size();return new Promise(function(i,a){var s={value:a},l={value:function(){--r===0&&i()}};o.each(function(){var c=_e(this,n),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(l)),c.on=t}),r===0&&i()})}var mf=0;function Ae(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function Ra(e){return Qe().transition(e)}function Gn(){return++mf}var je=Qe.prototype;Ae.prototype=Ra.prototype={constructor:Ae,select:wa,selectAll:Aa,selectChild:je.selectChild,selectChildren:je.selectChildren,filter:_a,merge:Ta,selection:Ia,transition:ka,call:je.call,nodes:je.nodes,node:je.node,size:je.size,empty:je.empty,each:je.each,on:va,attr:ga,attrTween:ha,style:Sa,styleTween:Ma,text:Pa,textTween:La,remove:Na,tween:ma,delay:ya,duration:xa,ease:Ea,easeVarying:ba,end:Da,[Symbol.iterator]:je[Symbol.iterator]};function Bn(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var gf={time:null,delay:0,duration:250,ease:Bn};function hf(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 Oa(e){var t,o;e instanceof Ae?(t=e._id,e=e._name):(t=Gn(),(o=gf).time=Lo(),e=e==null?null:e+"");for(var n=this._groups,r=n.length,i=0;i<r;++i)for(var a=n[i],s=a.length,l,c=0;c<s;++c)(l=a[c])&&st(l,e,t,c,a,o||hf(l,t));return new Ae(n,this._parents,e,t)}Qe.prototype.interrupt=fa;Qe.prototype.transition=Oa;function at(e,t,o){this.k=e,this.x=t,this.y=o}at.prototype={constructor:at,scale:function(e){return e===1?this:new at(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new at(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 zn=new at(1,0,0);Fn.prototype=at.prototype;function Fn(e){for(;!e.__zoom;)if(!(e=e.parentNode))return zn;return e.__zoom}var xf=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var Va;(function(e){e.Strict="strict",e.Loose="loose"})(Va||(Va={}));var Ha;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ha||(Ha={}));var Ga;(function(e){e.Partial="partial",e.Full="full"})(Ga||(Ga={}));var Ba;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ba||(Ba={}));var za;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(za||(za={}));var Pe;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Pe||(Pe={}));var Ev={[Pe.Left]:Pe.Right,[Pe.Right]:Pe.Left,[Pe.Top]:Pe.Bottom,[Pe.Bottom]:Pe.Top};var Ef=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var bf=(e,t=[0,0])=>{var s;let{width:o,height:n}=_f(e),r=(s=e.origin)!=null?s:t,i=o*r[0],a=n*r[1];return{x:e.position.x-i,y:e.position.y-a}};var De=(e,t=[0,0])=>{var r,i,a,s,l,c,d,u;let{x:o,y:n}=Ef(e)?e.internals.positionAbsolute:bf(e,t);return{x:o,y:n,x2:o+((s=(a=(i=(r=e.measured)==null?void 0:r.width)!=null?i:e.width)!=null?a:e.initialWidth)!=null?s:0),y2:n+((u=(d=(c=(l=e.measured)==null?void 0:l.height)!=null?c:e.height)!=null?d:e.initialHeight)!=null?u:0)}};function _f(e){var t,o,n,r,i,a,s,l;return{width:(r=(n=(o=(t=e.measured)==null?void 0:t.width)!=null?o:e.width)!=null?n:e.initialWidth)!=null?r:0,height:(l=(s=(a=(i=e.measured)==null?void 0:i.height)!=null?a:e.height)!=null?s:e.initialHeight)!=null?l:0}}var bv={[Pe.Left]:{x:-1,y:0},[Pe.Right]:{x:1,y:0},[Pe.Top]:{x:0,y:-1},[Pe.Bottom]:{x:0,y:1}};var Tf={nodeOrigin:[0,0],nodeExtent:xf,elevateNodesOnSelect:!0,defaults:{}},_v=w(E({},Tf),{checkEquality:!0});var Fa;(function(e){e.Line="line",e.Handle="handle"})(Fa||(Fa={}));var vf={width:0,height:0,x:0,y:0},Tv=w(E({},vf),{pointerX:0,pointerY:0,aspectRatio:1});import{useCallback as Ro,useEffect as Mf,useRef as Pf,useState as $a}from"react";import{shallow as Lf}from"zustand/shallow";var Nf=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function wf(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 Af(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 Wn=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){let i=t==="horizontal"?this.yLines:this.xLines,[a,s]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],l=[];for(let p of i){if(p.position<a)continue;if(p.position>s)break;if(p.node.id===n.id||p.node.parentId===n.id||!Nf(p.nodeBox,r))continue;let m=Math.abs(p.position-o);if(m>Yn)continue;let g=wf(p.nodeBox,De(n))>0?0:Af(p.nodeBox,De(n));l.push({line:p,lineDist:m,nodeDist:g})}let c=.5,d=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;l.sort((p,m)=>{if(d){if(p.line===d&&m.line!==d)return-1;if(m.line===d&&p.line!==d)return 1}return Math.abs(p.lineDist-m.lineDist)<=c?p.nodeDist-m.nodeDist:p.lineDist-m.lineDist});let u=l.length>0?l[0].line:void 0;return u&&(t==="horizontal"?this.lastHorizontalLine=u:this.lastVerticalLine=u),u}};function Wa(e,t=Ct,o){let n=[];return e==null||e.forEach(r=>{let i=o(r.id);if(!i)throw new Error(`Node with id ${r.id} not found in internal nodes.`);let a=De(i);Object.entries(t).forEach(([s,l])=>{var c;n.push({nodeBox:a,node:r,orientation:l.orientation,position:l.resolve(r,a),color:(c=r.style)==null?void 0:c.backgroundColor,anchorName:s})})}),n}function Ya(e,t,o,n,r=Object.keys(Ct)){let i=[];for(let s of r){let l=Ct[s],c=l.resolve(o,n),d=e.search(l.orientation,c,o,t);d&&i.push({anchorName:s,sourcePosition:c,anchor:l,line:d})}let a={horizontal:void 0,vertical:void 0};for(let s of i){let l=a[s.anchor.orientation],c=Math.abs(s.sourcePosition-s.line.position);(!l||c<Math.abs(l.sourcePosition-l.line.position))&&(a[s.anchor.orientation]=s)}return a}function Ua(e,t,o,n,r,i,a,s){var u,p,m,h,g,f,y,x;if(!(o!=null&&o.position))return{snappedX:!1,snappedY:!1};let l=!1,c=!1,d={x:o.position.x,y:o.position.y,x2:o.position.x+((p=(u=e.measured)==null?void 0:u.width)!=null?p:0),y2:o.position.y+((h=(m=e.measured)==null?void 0:m.height)!=null?h:0)};if(a){let b=a.anchor.resolve(e,d)-a.line.position;if(Math.abs(b)<=Yn){if(o.position.y-=b,r!=null&&r.dimensions)if(n){let T=t.internals.positionAbsolute.y+((f=(g=e.measured)==null?void 0:g.height)!=null?f:0);r.dimensions.height=T-a.line.position}else r.dimensions.height=a.line.position-t.internals.positionAbsolute.y;c=!0}}if(s){let b=s.anchor.resolve(e,d)-s.line.position;if(Math.abs(b)<=Yn){if(o.position.x-=b,r!=null&&r.dimensions)if(n){let T=t.internals.positionAbsolute.x+((x=(y=e.measured)==null?void 0:y.width)!=null?x:0);r.dimensions.width=T-s.line.position}else r.dimensions.width=s.line.position-t.internals.positionAbsolute.x;l=!0}}return i&&(l||c)&&(o.position.x-=i.position.x,o.position.y-=i.position.y),{snappedX:l,snappedY:c}}var Yn=10,Ct={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 Df}from"react/jsx-runtime";var kf=new Wn;function Un(){let[e,t]=$a(void 0),[o,n]=$a(void 0),{width:r,height:i}=Sf(f=>({width:f.width,height:f.height}),Lf),a=If(),s=Pf(kf),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=Cf(),u=Ro(()=>{t(void 0),n(void 0)},[]),p=Ro(f=>{let y=f!=null?f:d();u();let x=Wa(y,Ct,c);s.current.initialize(x)},[c,u,d]),m=Ro(()=>{setTimeout(()=>{p()},100)},[p]);Mf(()=>{a&&p(d())},[a,p,d]);let h=Ro((f,y)=>{var ee,C,V,Y,G;if(!s.current||f.length===0||f.length>2)return f;u();let x,_,b=Object.keys(Ct);f.length===1?f[0].type==="position"?x=f[0]:f[0].type==="dimensions"&&(_=f[0],b=["right","bottom"]):f[0].type==="position"&&f[1].type==="dimensions"&&f[1].dimensions&&(x=f[0],_=f[1],b=["top","left"]);let T=y.find($=>$.id===f[0].id);if(!T)return f;let v=c(T.id);if(!v)throw new Error(`Node with id ${T.id} not found in internal nodes`);let N=c((ee=v.parentId)!=null?ee:""),P=De(v);_!=null&&_.dimensions&&(P.x2=P.x+_.dimensions.width,P.y2=P.y+_.dimensions.height);let{x:R,y:I}=l({x:0,y:0}),{x:A,y:L}=l({x:r,y:i}),B={x:R,y:I,x2:A,y2:L},{horizontal:S,vertical:M}=Ya(s.current,B,T,P,b),D={id:T.id,type:"position",position:{x:v.internals.positionAbsolute.x,y:v.internals.positionAbsolute.y},dragging:!1};x!=null&&x.position&&D.position&&(N?(D.position.x=x.position.x+((V=(C=N==null?void 0:N.position)==null?void 0:C.x)!=null?V:0),D.position.y=x.position.y+((G=(Y=N==null?void 0:N.position)==null?void 0:Y.y)!=null?G:0)):(D.position.x=x.position.x,D.position.y=x.position.y));let{snappedX:F,snappedY:U}=Ua(T,v,D,x,_,N,S,M);if(F||U){if((_!=null&&_.resizing||x!=null&&x.dragging)&&(F&&n(M==null?void 0:M.line),U&&t(S==null?void 0:S.line)),_&&x)return[D,_];if(x)return[D];if(_)return[_]}return f},[l,c,r,i,t,n,u]),g=Ro(()=>Df(Xa,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:p,forceRebuildIndex:m,updateHelperLines:h,helperLineHorizontal:e,helperLineVertical:o,HelperLines:g}}import{reconnectEdge as Nh,useReactFlow as wh}from"@xyflow/react";import{useCallback as Dt,useRef as Ah}from"react";var St=e=>new Map(e.map(t=>[t.id,t])),Oo=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),Ka=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),$n=e=>e.some(t=>t.type==="START_EVENT"),qa=(e,t,o,n,r)=>{let i=St(o),a=i.get(e);if(!a||a.type!=="START_EVENT")return!1;let s=i.get(t);return(s==null?void 0:s.type)==="ANNOTATION"?!1:Oo(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Za=(e,t,o,n,r)=>{let i=St(o),a=i.get(t);if(!a||a.type!=="END_EVENT")return!1;let s=i.get(e);return(s==null?void 0:s.type)==="ANNOTATION"?!1:Ka(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Xn=(e,t,o,n)=>{var a;let r=t.find(s=>s.id===e);return!r||r.type!=="GATEWAY"||((a=r.data)==null?void 0:a.variant)!=="EXCLUSIVE"?!1:Oo(e,o,n).length>=2},Ja=(e,t,o)=>{var a,s,l,c;let n=St(o),r=n.get(e),i=n.get(t);return(r==null?void 0:r.type)!=="GATEWAY"||(i==null?void 0:i.type)!=="GATEWAY"||((a=r==null?void 0:r.data)==null?void 0:a.variant)==="EXCLUSIVE"&&((s=i==null?void 0:i.data)==null?void 0:s.variant)==="PARALLEL"||((l=r==null?void 0:r.data)==null?void 0:l.variant)==="COMPLEX"&&((c=i==null?void 0:i.data)==null?void 0:c.variant)==="PARALLEL"},Kn=(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"},Qa=(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"},qn=(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"},Vo=(e,t,o,n)=>{let r=St(t),i=r.get(e);return!i||i.type!=="TASK"?!1:Ka(e,o,n).some(s=>{let l=r.get(s.source);return(l==null?void 0:l.type)==="START_EVENT"})},Ho=(e,t,o,n)=>{let r=St(t),i=r.get(e);return!i||i.type!=="TASK"?!1:Oo(e,o,n).some(s=>{let l=r.get(s.target);return(l==null?void 0:l.type)==="END_EVENT"})},ja=(e,t,o,n,r)=>{let i=St(o),a=i.get(e),s=i.get(t);return(a==null?void 0:a.type)==="START_EVENT"&&(s==null?void 0:s.type)==="TASK"?Ho(t,o,n,r):(s==null?void 0:s.type)==="END_EVENT"&&(a==null?void 0:a.type)==="TASK"?Vo(e,o,n,r):!1},Zn=(e,t,o)=>Oo(e,t,o).length>0,Jn=(e,t,o,n,r)=>{let i=St(o),a=i.get(e);if(!a||a.type!=="TASK")return!1;let s=t?i.get(t):null;return(s==null?void 0:s.type)==="ANNOTATION"?!1:Oo(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var el=(e,t,o,n)=>o.some(r=>n&&r.id===n?!1:r.source===e&&r.target===t);var Rf=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!el(e.sourceNodeId,e.targetNodeId,e.edges,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!qa(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!Za(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!Xn(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!Jn(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:Ja(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"&&Qa(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:!(Kn(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(qn(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(Vo(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!ja(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(Ho(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(Zn(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"})],ci=e=>{for(let t of Rf){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var Of=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:Xn(e.sourceNodeId,e.nodes,e.edges),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:$n(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Kn(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:qn(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Vo(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Ho(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Zn(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Jn(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],tl=e=>{let t=Of.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 lm,EdgeLabelRenderer as cm,getStraightPath as dm,useInternalNode as rl,useViewport as um}from"@xyflow/react";import{Position as Go}from"@xyflow/react";function ol(e,t){var _,b,T,v;let{width:o=0,height:n=0}=e.measured||{width:0,height:0},r=e.internals.positionAbsolute,i=t.internals.positionAbsolute,a=o/2,s=n/2,l=r.x+a,c=r.y+s,d=i.x+((b=(_=t==null?void 0:t.measured)==null?void 0:_.width)!=null?b:0)/2,u=i.y+((v=(T=t==null?void 0:t.measured)==null?void 0:T.height)!=null?v:0)/2,p=(d-l)/(2*a)-(u-c)/(2*s),m=(d-l)/(2*a)+(u-c)/(2*s),h=1/(Math.abs(p)+Math.abs(m)||1),g=h*p,f=h*m,y=a*(g+f)+l,x=s*(-g+f)+c;return{x:y,y:x}}function nl(e,t){var c,d,u,p;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(p=(u=e.measured)==null?void 0:u.height)!=null?p:0,i=Math.round(o.x),a=Math.round(o.y),s=Math.round(t.x),l=Math.round(t.y);return s<=i+1?Go.Left:s>=i+n-1?Go.Right:l<=a+1?Go.Top:l>=a+r-1?Go.Bottom:Go.Top}function lt(e,t){let o=ol(e,t),n=ol(t,e),r=nl(e,o),i=nl(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function Qn(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"}}import{Button as Gf,Tooltip as Bf,TooltipContent as zf,TooltipTrigger as Ff,useTranslation as Wf}from"lecom-ui";import{Settings as Yf}from"lucide-react";import{getIncomers as jn,getOutgoers as er,useReactFlow as Hf}from"@xyflow/react";import{useStoreApi as Vf}from"@xyflow/react";var ct=()=>{let e=Vf();return{selectElements:n=>{let{edges:r,nodes:i,triggerEdgeChanges:a,triggerNodeChanges:s}=e.getState(),l=i.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]),c=r.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]);return s(l),a(c),!0},clearSelection:async()=>{let{unselectNodesAndEdges:n}=e.getState();return n(),await cn(),!0}}};var tr=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=Hf(),{selectElements:r}=ct(),i=f=>{let y=o(),x=n(),_=jn(f,y,x),b=er(f,y,x),T=_.some(N=>N.type==="START_EVENT"),v=b.some(N=>N.type==="END_EVENT");return T?"start":v?"end":"between"},a=(f,y,x)=>{var T,v,N,P;if(!f)return;let _={type:f.type,variant:(T=f.data)==null?void 0:T.variant,attribute:(v=f.data)==null?void 0:v.attribute},b={id:f.id,position:i(f),label:(N=f.data)==null?void 0:N.label,node:_};return f.type==="TASK"&&((P=f.data)==null?void 0:P.variant)==="SUBPROCESS"?w(E({},b),{type:"sub_process"}):f.type==="GATEWAY"?w(E({},b),{type:"gateway",variant:s(f,y,x)}):w(E({},b),{type:"activity"})},s=(f,y,x)=>{if(f.type!=="GATEWAY")return;let _=jn(f,y,x),b=!1,T=!1;if(_.forEach(v=>{var N,P;v.type==="TASK"&&(((N=v.data)==null?void 0:N.variant)==="SCRIPT"&&(b=!0),((P=v.data)==null?void 0:P.attribute)==="LOOP"&&(T=!0))}),b&&T)return"script_loop";if(b)return"script";if(T)return"loop"},l=(f,y,x)=>{var N,P,R,I;let _=e(f.source),b=e(f.target);if(!_||!b)return"simple";if(er(_,y,x).some(A=>A.type==="END_EVENT"))return"final";if(_.type==="GATEWAY")switch((N=_.data)==null?void 0:N.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(_.type==="TASK"){let A=(P=_.data)==null?void 0:P.variant,L=(R=_.data)==null?void 0:R.attribute;if(A==="SUBPROCESS")return"from_sub_process";if(b.type==="TASK"&&((I=b.data)==null?void 0:I.variant)==="SUBPROCESS")return"to_sub_process";let B=A==="SCRIPT",S=L==="LOOP";return B&&S?"script_loop":B?"script":S?"loop":"simple"}return"simple"},c=(f,y,x)=>{let _=[];function b(v,N,P=0){let R=a(v,y,x);if(R.depth=P,N.push(R),v.type==="TASK"){_.push([...N]),N.pop();return}let I=jn(v,y,x);if(I.length)for(let A of I)b(A,N,P+1);N.pop()}let T=jn(f,y,x);for(let v of T)b(v,[]);return _},d=(f,y,x)=>{let _=[];function b(v,N,P=0){let R=a(v,y,x);if(R.depth=P,N.push(R),v.type==="TASK"){_.push([...N]),N.pop();return}let I=er(v,y,x);if(I.length)for(let A of I)b(A,N,P+1);N.pop()}let T=er(f,y,x);for(let v of T)b(v,[]);return _},u=(f,y,x)=>(x=x.filter(b=>b.source===f.id),x.map(b=>{var N;let T=e(b.target),v;return T&&(v=a(T,y,x)),{id:b.id,type:"routing",variant:l(b,y,x),label:(N=b.data)==null?void 0:N.label,target:v}})),p=f=>{let y=e(f);if(!y)return;let x=o(),_=n(),b=a(y,x,_);return b.sources=c(y,x,_),b.targets=d(y,x,_),b.edgeTargets=u(y,x,_),y.type==="GATEWAY"&&(b.variant=s(y,x,_)),b},m=f=>{let y=t(f);if(!y)return;let x=o(),_=n(),b=l(y,x,_),v={id:y.id,type:"routing",variant:b,gatewayVariant:void 0},N=e(y.source);if(N){let R=a(N,x,_);v.source=R;let I=s(N,x,_);if(v.gatewayVariant=I,N.type==="TASK")v.sources=[[R]];else{let A=c(N,x,_);v.sources=A.length?A:[[R]]}}let P=e(y.target);if(P){let R=a(P,x,_);if(v.target=R,P.type==="TASK")v.targets=[[R]];else{let I=d(P,x,_);v.targets=I.length?I:[[R]]}}return v},h=f=>{let y=e(f);if(y)return p(y.id);let x=t(f);if(x)return m(x.id)};return{configureElement:f=>{let y=h(f);if(y)return r([f]),y},getConfigureElement:h,getNodeConfigure:p,getEdgeConfigure:m}};import{jsx as or,jsxs as Uf}from"react/jsx-runtime";var dt=({elementId:e,elementType:t="node"})=>{let{t:o}=Wf(),{onConfigureElement:n}=W(),{getConfigureElement:r}=tr();return Uf(Bf,{children:[or(Ff,{asChild:!0,children:or(Gf,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let a=r(e);a&&(n==null||n(a))},children:or(Yf,{size:16})})}),or(zf,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};import{useReactFlow as $f}from"@xyflow/react";import{Button as Xf,Tooltip as Kf,TooltipContent as qf,TooltipTrigger as Zf,useTranslation as Jf}from"lecom-ui";import{TrashIcon as Qf}from"lucide-react";import{jsx as nr,jsxs as jf}from"react/jsx-runtime";var rr=({elementId:e,elementType:t="node"})=>{let{t:o}=Jf(),{deleteElements:n}=$f();return jf(Kf,{children:[nr(Zf,{asChild:!0,children:nr(Xf,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{n(t==="node"?{nodes:[{id:e}]}:{edges:[{id:e}]})},children:nr(Qf,{size:16})})}),nr(qf,{color:"black",children:o("editor.toolbar.delete")})]})};import{Button as em,Tooltip as tm,TooltipContent as om,TooltipTrigger as nm,useTranslation as rm}from"lecom-ui";import{MoveUpRightIcon as im}from"lucide-react";import{useCallback as sm}from"react";import{jsx as ir,jsxs as am}from"react/jsx-runtime";var $t=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=rm(),r=sm(i=>{i.stopPropagation();let a=document.querySelector(`[data-id="${e}"]`);if(!a)return;let s=a.querySelector(".react-flow__handle.source");if(!s)return;let l=s.getBoundingClientRect(),c=l.left+l.width/2,d=l.top+l.height/2,u=new MouseEvent("mousedown",{clientX:c,clientY:d,bubbles:!0,cancelable:!0});s.dispatchEvent(u)},[e]);return am(tm,{children:[ir(nm,{asChild:!0,children:ir(em,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:ir(im,{size:16})})}),ir(om,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};import{jsx as Bo}from"react/jsx-runtime";var Kt=i=>{var a=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=a,r=Xe(a,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:s}=W(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d}=Qn(o,n),u=!l&&!c&&!d,p=[{component:Bo(rr,{elementId:e,elementType:"edge"})}],m=()=>s==="view"?u?[{component:Bo(dt,{elementId:e,elementType:"edge"})}]:[]:u?[{component:Bo(dt,{elementId:e,elementType:"edge"})},...p]:p,g=(f=>{switch(f){case"SEQUENCE_EDGE":return m();case"MESSAGE_EDGE":return s==="view"?[]:[...p];case"ANNOTATION_EDGE":return s==="view"?[]:[...p];default:return[]}})(t);if(!(g.length===0||s==="view"))return Bo("div",w(E({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:g.map((f,y)=>Bo("div",{children:f.component},y))}))};import{jsx as sr,jsxs as pm}from"react/jsx-runtime";var qt={type:"ANNOTATION_EDGE",reconnectable:!0},il=({id:e,source:t,target:o,selected:n,data:r})=>{let{zoom:i}=um(),{isMultipleSelection:a}=W(),s=rl(t),l=rl(o);if(!s||!l)return null;let{sx:c,sy:d,tx:u,ty:p}=lt(s,l),[m,h,g]=dm({sourceX:c,sourceY:d,targetX:u,targetY:p}),f=n||(s==null?void 0:s.selected)||(l==null?void 0:l.selected),y=1/i;return pm("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":f}),children:[sr(lm,{id:e,path:m,strokeDasharray:4,className:k("stroke-2 stroke-current transition-colors duration-75",{"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)]":f&&!(r!=null&&r.hasError)})}),sr(cm,{children:sr("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${h}px, ${g}px)`},children:n&&!a&&sr(Kt,{edgeId:e,edgeType:"ANNOTATION_EDGE",style:{transform:`scale(${y})`}})})})]})};import{useState as ul,useCallback as bm,useMemo as ur,useEffect as _m,useRef as pl}from"react";import{BaseEdge as Tm,EdgeLabelRenderer as vm,MarkerType as fl,useInternalNode as ml,useReactFlow as Nm,useViewport as wm,useEdges as Am,Position as jt}from"@xyflow/react";import{useEffect as sl,useRef as fm,useState as mm}from"react";import{jsx as al}from"react/jsx-runtime";var ve=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:a,onBlur:s,onInvalidFirstCharacter:l})=>{let c=fm(null),[d,u]=mm(!1);sl(()=>{u(i!=null?i:!1)},[i]),sl(()=>{if(d&&c.current){c.current.focus();let f=document.createRange();f.selectNodeContents(c.current);let y=window.getSelection();y&&(y.removeAllRanges(),y.addRange(f))}},[d]);let p=f=>{f.stopPropagation(),d||u(!0)},m=f=>{let y=f.currentTarget.innerText.trim(),x=t&&y.length>=t,_=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Enter","Escape","Shift"],b=f.ctrlKey||f.metaKey,T=b&&f.key==="a",v=b&&f.key==="c",N=b&&f.key==="x",P=b&&f.key==="v";function R(A){return/\w/.test(A)}if(y.length===0&&!R(f.key)&&!_.includes(f.key)&&!b){f.preventDefault();return}if(f.key==="Enter"){f.preventDefault(),f.currentTarget.blur();return}x&&(_.includes(f.key)||T||v||N||P||f.preventDefault())},h=f=>{f.preventDefault();let y=f.clipboardData.getData("text/plain"),x=f.currentTarget.innerText,_=window.getSelection();if(!_||_.rangeCount===0)return;let b=_.getRangeAt(0),T=x.substring(0,b.startOffset),v=x.substring(b.endOffset),N=T+y+v;if(T.trim().length===0&&N.trim().length>0){let I=N.trim()[0];if(!/\w/.test(I)){l==null||l();return}}let R=y;if(t&&N.length>t){let I=t-(x.length-(b.endOffset-b.startOffset));if(R=y.substring(0,Math.max(0,I)),!R)return}b.deleteContents(),b.insertNode(document.createTextNode(R)),b.setStartAfter(b.endContainer),b.collapse(!0),_.removeAllRanges(),_.addRange(b)},g=f=>{u(!1);let y=f.currentTarget.innerText.trim();t&&y.length>t&&(y=y.substring(0,t)),f.currentTarget.innerText=y,s==null||s(),y!==e&&(a==null||a(y))};return al("div",{className:k("flex-1 p-2 self-stretch content-center border border-transparent overflow-hidden text-ellipsis text-sm text-center",n,{"border border-dashed border-grey-400":d}),style:o,onDoubleClick:p,children:al("div",{ref:c,className:k("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":d}),contentEditable:d,suppressContentEditableWarning:!0,onKeyDown:m,onPaste:h,onBlur:g,children:e})})};import{Position as ar}from"@xyflow/react";var zo=e=>e===ar.Left||e===ar.Right,di=(e,t=30)=>e===ar.Right||e===ar.Bottom?t:-t,ui=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,Zt=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),lr=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2});var Fo={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15};function gm(e,t,o,n,r,i,a=0){let s=di(r,Fo.OFFSET),l=di(i,Fo.OFFSET),c=zo(r),d=zo(i),u=c?0:a,p=c?a:0,m=d?0:a,h=d?a:0,g={x:e+u,y:t+p},f={x:o+m,y:n+h};if(c&&d){let y=(t+n)/2+a;return[g,{x:e+s,y:t+a},{x:e+s,y},{x:o+l,y},{x:o+l,y:n+a},f]}if(!c&&!d){let y=(e+o)/2+a;return[g,{x:e+a,y:t+s},{x:y,y:t+s},{x:y,y:n+l},{x:o+a,y:n+l},f]}return c?[g,{x:e+s,y:t+a},{x:e+s,y:n+l+a},{x:o+a,y:n+l+a},f]:[g,{x:e+a,y:t+s},{x:o+l+a,y:t+s},{x:o+l+a,y:n+a},f]}function ll(e,t,o,n,r,i,a,s=0){let l=gm(e,t,o,n,r,i,s);if(!(a!=null&&a.length))return l;let c=[...a];if(c.length>0){let d={x:e,y:t},u=c[0],p=zo(r);p&&Math.abs(d.y-u.y)>1?c.unshift({x:u.x,y:d.y}):!p&&Math.abs(d.x-u.x)>1&&c.unshift({x:d.x,y:u.y})}if(c.length>0){let d={x:o,y:n},u=c[c.length-1],p=zo(i);p&&Math.abs(d.y-u.y)>1?c.push({x:u.x,y:d.y}):!p&&Math.abs(d.x-u.x)>1&&c.push({x:d.x,y:u.y})}return[{x:e,y:t},...c,{x:o,y:n}]}var cl=e=>{if(e.length<2)return"";let[t,...o]=e;return`M ${t.x},${t.y}${o.map(n=>` L ${n.x},${n.y}`).join("")}`};import{useCallback as Jt,useEffect as cr,useRef as Wo,useState as Qt}from"react";import{useReactFlow as hm,useStore as ym}from"@xyflow/react";var xm=50,dl=.1,Em=.6,dr=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:a,getNodes:s,getEdge:l,screenToFlowPosition:c}=hm(),{setIsDragging:d,setReconnectingEdgeId:u}=W(),p=ym(C=>C.isValidConnection),[m,h]=Qt(null),[g,f]=Qt(null),[y,x]=Qt(null),[_,b]=Qt(null),[T,v]=Qt(null),[N,P]=Qt(!1),R=Wo(null),I=Wo(null),A=Wo(null),L=Wo(t),B=Wo(o);cr(()=>{L.current=t,B.current=o},[t,o]),cr(()=>{R.current=m},[m]),cr(()=>{I.current=T},[T]);let S=Jt(C=>{let V=s(),Y=V.find(oe=>oe.id===C);if(!Y)return{x:0,y:0};let G=Y.position.x,$=Y.position.y,q=Y.parentId;for(;q;){let oe=V.find(O=>O.id===q);if(!oe)break;G+=oe.position.x,$+=oe.position.y,q=oe.parentId}return{x:G,y:$}},[s]),M=Jt(C=>{var q,oe,O,K,X,z;let V=s(),Y=null,G=xm,$=V.filter(H=>H.type!=="LANE"&&H.type!=="ANNOTATION");for(let H of $){if(H.id===e)continue;let Z=S(H.id),J=(O=(oe=(q=H.measured)==null?void 0:q.width)!=null?oe:H.width)!=null?O:0,ne=(z=(X=(K=H.measured)==null?void 0:K.height)!=null?X:H.height)!=null?z:0;if(C.x>=Z.x&&C.x<=Z.x+J&&C.y>=Z.y&&C.y<=Z.y+ne)return H.id;let le=Math.max(Z.x-C.x,0,C.x-(Z.x+J)),ce=Math.max(Z.y-C.y,0,C.y-(Z.y+ne)),ye=Math.sqrt(le*le+ce*ce);ye<G&&(G=ye,Y=H.id)}return Y},[s,S,e]),D=Jt((C,V)=>{var le,ce,ye,xe,Te,fe;let Y=a(C);if(!Y)return null;let G=S(C),$=(ye=(ce=(le=Y.measured)==null?void 0:le.width)!=null?ce:Y.width)!=null?ye:0,q=(fe=(Te=(xe=Y.measured)==null?void 0:xe.height)!=null?Te:Y.height)!=null?fe:0,oe=Math.abs(G.x+$-V.x),O=Math.abs(V.x-G.x),K=Math.abs(G.y+q-V.y),X=Math.abs(V.y-G.y),z={right:oe,left:O,bottom:K,top:X},H=Object.entries(z).reduce((se,[Q,ae])=>ae<se[1]?[Q,ae]:se,["right",z.right])[0],Z=A.current;if(Z&&Z!==H){let se=z[H],Q=z[Z],ae=Math.abs(Q-se),Se=Math.min(Math.abs(Q),Math.abs(se));ae<Se*Em&&(H=Z)}let J=H,ne,ue;if(J==="right"||J==="left"){let Q=(Math.max(G.y,Math.min(G.y+q,V.y))-G.y)/(q||1);Math.abs(Q-.5)<dl&&(Q=.5),ue=Q,ne={x:J==="right"?G.x+$:G.x,y:G.y+ue*q}}else{let Q=(Math.max(G.x,Math.min(G.x+$,V.x))-G.x)/($||1);Math.abs(Q-.5)<dl&&(Q=.5),ue=Q,ne={x:G.x+ue*$,y:J==="bottom"?G.y+q:G.y}}return{side:J,snapPosition:ne,offset:ue}},[a,S]),F=Jt(C=>{var O,K,X;let V=R.current;if(!V)return;let Y=c({x:C.clientX,y:C.clientY}),G=M(Y);x(G);let $=Y,q=null,oe=null;if(G){let z=D(G,Y);z&&(q=z.side,$=z.snapPosition,oe=z.offset,A.current=q);let H=l(e),Z={source:V==="source"?G:L.current,target:V==="target"?G:B.current,sourceHandle:V==="source"?q:(O=H==null?void 0:H.sourceHandle)!=null?O:null,targetHandle:V==="target"?q:(K=H==null?void 0:H.targetHandle)!=null?K:null},J=(X=p==null?void 0:p(Z))!=null?X:!0;P(J)}else A.current=null,P(!1);b(q),v(oe),f($)},[M,D,l,e,c,p]),U=Jt(C=>{var q,oe,O,K,X;let V=R.current;if(!V)return;let Y=c({x:C.clientX,y:C.clientY}),G=M(Y);if(G){let z=D(G,Y),H=(q=z==null?void 0:z.side)!=null?q:null,Z=(oe=z==null?void 0:z.offset)!=null?oe:.5,J=l(e),ne={source:V==="source"?G:L.current,target:V==="target"?G:B.current,sourceHandle:V==="source"?H:(O=J==null?void 0:J.sourceHandle)!=null?O:null,targetHandle:V==="target"?H:(K=J==null?void 0:J.targetHandle)!=null?K:null};((X=p==null?void 0:p(ne))==null||X)&&i(ue=>ue.map(le=>{var ce,ye;return le.id===e?w(E({},le),{source:ne.source,target:ne.target,sourceHandle:ne.sourceHandle,targetHandle:ne.targetHandle,data:w(E({},le.data),{points:void 0,sourceOffset:V==="source"?Z:(ce=le.data)==null?void 0:ce.sourceOffset,targetOffset:V==="target"?Z:(ye=le.data)==null?void 0:ye.targetOffset})}):le}))}h(null),f(null),x(null),b(null),v(null),d(!1),P(!1),u(null),A.current=null,document.removeEventListener("mouseup",U),document.removeEventListener("mousemove",F);let $=qe.get(n);$==null||$.clearReconnectingEdge()},[e,M,D,l,i,n,F,p,c,d,u]),ee=Jt((C,V)=>{if(r||V.button!==0)return;V.stopPropagation(),V.preventDefault(),i(G=>G.map($=>$.id===e?w(E({},$),{data:w(E({},$.data),{points:void 0})}):$)),h(C),u(e);let Y=qe.get(n);Y==null||Y.setReconnectingEdge(e),document.addEventListener("mousemove",F),document.addEventListener("mouseup",U)},[r,e,n,F,U,u,i]);return cr(()=>()=>{if(R.current){document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",U),u(null);let C=qe.get(n);C==null||C.clearReconnectingEdge()}},[n,F,U,u]),{reconnectingHandle:m,cursorPosition:g,hoveredNodeId:y,reconnectingSide:_,reconnectingOffset:T,isValidReconnection:N,handleReconnectStart:ee}};import{Fragment as hl,jsx as Ne,jsxs as ut}from"react/jsx-runtime";var Ue={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:fl.ArrowClosed},markerEnd:{type:fl.Arrow},data:{label:""}},{MOVE_THRESHOLD:pr,MIN_SEGMENT_LENGTH:Im,PARALLEL_OFFSET:gl}=Fo;function Cm(e,t,o,n){let r=n.filter(s=>s.source===t&&s.target===o||s.source===o&&s.target===t);if(r.length<=1){let s=n.filter(d=>d.source===t);if(s.length<=1)return 0;let l=s.findIndex(d=>d.id===e);if(l<=0)return 0;let c=(s.length-1)/2;return(l-c)*gl}let i=r.findIndex(s=>s.id===e),a=(r.length-1)/2;return(i-a)*gl}var yl=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var oe;let{zoom:c}=wm(),{updateEdgeData:d}=Nm(),u=Am(),{isMultipleSelection:p,mode:m,instanceId:h}=W(),[g,f]=ul(!1),[y,x]=ul(null),_=pl(null),b=pl(null),T=m!=="edit",{reconnectingHandle:v,cursorPosition:N,hoveredNodeId:P,reconnectingSide:R,isValidReconnection:I,handleReconnectStart:A}=dr({edgeId:e,source:t,target:o,instanceId:h,isReadOnly:T}),L=ml(t),B=ml(o),{sx:S,sy:M,tx:D,ty:F,sourcePos:U,targetPos:ee}=ur(()=>{var ce,ye;let O=L&&B?lt(L,B):{sx:0,sy:0,tx:0,ty:0,sourcePos:jt.Right,targetPos:jt.Left},K=s?i:O.sourcePos,X=l?a:O.targetPos,z=(xe,Te,fe)=>{var Et,bt,_t,Tt,Or,yo;let{x:se,y:Q}=xe.internals.positionAbsolute,ae=(_t=(bt=(Et=xe.measured)==null?void 0:Et.width)!=null?bt:xe.width)!=null?_t:0,Se=(yo=(Or=(Tt=xe.measured)==null?void 0:Tt.height)!=null?Or:xe.height)!=null?yo:0;switch(Te){case jt.Top:return{x:se+ae*fe,y:Q};case jt.Bottom:return{x:se+ae*fe,y:Q+Se};case jt.Left:return{x:se,y:Q+Se*fe};case jt.Right:return{x:se+ae,y:Q+Se*fe};default:return{x:se+ae/2,y:Q+Se/2}}},H=(ce=n==null?void 0:n.sourceOffset)!=null?ce:.5,Z=(ye=n==null?void 0:n.targetOffset)!=null?ye:.5,J=L?z(L,K,H).x:O.sx,ne=L?z(L,K,H).y:O.sy,ue=B?z(B,X,Z).x:O.tx,le=B?z(B,X,Z).y:O.ty;return v==="source"&&N?(J=N.x,ne=N.y,R&&(K=R)):v==="target"&&N&&(ue=N.x,le=N.y,R&&(X=R)),{sx:J,sy:ne,tx:ue,ty:le,sourcePos:K,targetPos:X}},[L,B,s,l,i,a,v,N,R,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);_m(()=>{var X;if(!b.current){b.current={sx:S,sy:M,tx:D,ty:F,sourcePos:U,targetPos:ee};return}let O=b.current;(Math.abs(S-O.sx)>pr||Math.abs(M-O.sy)>pr||Math.abs(D-O.tx)>pr||Math.abs(F-O.ty)>pr||O.sourcePos!==U||O.targetPos!==ee)&&((X=n==null?void 0:n.points)!=null&&X.length)&&!v&&d(e,w(E({},n),{points:void 0})),b.current={sx:S,sy:M,tx:D,ty:F,sourcePos:U,targetPos:ee}},[S,M,D,F,U,ee,n,e,d,v]);let C=ur(()=>{let O=Cm(e,t,o,u);return ll(S,M,D,F,U,ee,n==null?void 0:n.points,O)},[S,M,D,F,U,ee,n==null?void 0:n.points,u,e,t,o]),V=ur(()=>{if(C.length<2)return lr({x:S,y:M},{x:D,y:F});let O=0;for(let z=0;z<C.length-1;z++)O+=Zt(C[z],C[z+1]);let K=O/2,X=0;for(let z=0;z<C.length-1;z++){let H=Zt(C[z],C[z+1]);if(X+H>=K){let Z=(K-X)/H,J=C[z],ne=C[z+1];return{x:J.x+(ne.x-J.x)*Z,y:J.y+(ne.y-J.y)*Z}}X+=H}return lr({x:S,y:M},{x:D,y:F})},[C,S,M,D,F]),Y=ur(()=>{if(C.length<2){let H=Math.abs(D-S);return Math.abs(F-M)>H?{x:-60,y:0}:{x:0,y:-60}}let K=0;for(let H=0;H<C.length-1;H++)K+=Zt(C[H],C[H+1]);let X=K/2,z=0;for(let H=0;H<C.length-1;H++){let Z=Zt(C[H],C[H+1]);if(z+Z>=X){let J=C[H],ne=C[H+1],ue=Math.abs(ne.x-J.x);return Math.abs(ne.y-J.y)>ue?{x:-60,y:0}:{x:0,y:-60}}z+=Z}return{x:0,y:-60}},[C,S,M,D,F]),G=bm((O,K)=>{if(m!=="edit"||K.button!==0)return;K.stopPropagation(),K.preventDefault();let X=C[O],z=C[O+1],H=ui(X,z,"y"),Z=H?X.y:X.x,J=[...C],ne=J.length,ue=O,le=O+1;x(O);let ce=xe=>{let Te=Z+(H?xe.clientY-K.clientY:xe.clientX-K.clientX)/c;_.current=H?{x:(X.x+z.x)/2,y:Te}:{x:Te,y:(X.y+z.y)/2};let fe=[];for(let se=1;se<ne-1;se++){let Q=J[se];se===ue||se===le?H?fe.push({x:Q.x,y:Te}):fe.push({x:Te,y:Q.y}):fe.push(E({},Q))}d(e,w(E({},n),{points:fe}))},ye=()=>{x(null),_.current=null,document.removeEventListener("mousemove",ce),document.removeEventListener("mouseup",ye)};document.addEventListener("mousemove",ce),document.addEventListener("mouseup",ye)},[m,C,c,n,e,d]);if(!L||!B)return null;let $=cl(C),q=r||L.selected||B.selected;return ut(hl,{children:[ut("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":q}),onDoubleClick:()=>f(!0),children:[Ne(Tm,{id:e,path:$,markerEnd:`url(#${q?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:k("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||v&&P&&!I,"stroke-green-500":v&&P&&I,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":q&&!(n!=null&&n.hasError)&&!v})}),r&&!p&&!T&&Ne("g",{children:C.slice(0,-1).map((O,K)=>{let X=C[K+1];if(K===0||K===C.length-2||Zt(O,X)<Im)return null;let z=ui(O,X,"y"),H=y===K,Z=H&&_.current?_.current:lr(O,X);return ut("g",{children:[Ne("line",{x1:O.x,y1:O.y,x2:X.x,y2:X.y,stroke:"transparent",strokeWidth:20/c,className:k("cursor-pointer",{"cursor-ns-resize":z,"cursor-ew-resize":!z}),onMouseDown:J=>G(K,J)}),Ne("circle",{cx:Z.x,cy:Z.y,r:4/c,fill:H?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ne("circle",{cx:Z.x,cy:Z.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:H?.6:.3,className:"pointer-events-none"})]},K)})})]}),ut(vm,{children:[ut("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${V.x}px, ${V.y}px)`},children:[r&&!p&&Ne("div",{className:"absolute pointer-events-auto",style:{transform:`translate(${Y.x}px, ${Y.y}px)`},children:Ne(Kt,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:L,targetNode:B,style:{transform:`scale(${1/c})`}})}),(g||((oe=n==null?void 0:n.label)==null?void 0:oe.trim()))&&Ne(ve,{value:n==null?void 0:n.label,className:k("min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",{"pointer-events-auto":g,"pointer-events-none":!g}),isEditing:g,onBlur:()=>f(!1),onChange:O=>d(e,{label:O.trim()})})]}),r&&!p&&!T&&ut(hl,{children:[Ne("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${C[0].x}px, ${C[0].y}px)`},children:ut("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Ne("circle",{cx:6/c,cy:6/c,r:4/c,fill:v==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ne("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:v==="source"?.6:.3,className:"pointer-events-none"}),Ne("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:k("pointer-events-auto",{"cursor-move":!v||v!=="source","cursor-not-allowed":v==="source"&&P&&!I,"cursor-grabbing":v==="source"&&(!P||I)}),onMouseDown:O=>A("source",O.nativeEvent)})]})}),Ne("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${C[C.length-1].x}px, ${C[C.length-1].y}px)`},children:ut("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Ne("circle",{cx:6/c,cy:6/c,r:4/c,fill:v==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ne("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:v==="target"?.6:.3,className:"pointer-events-none"}),Ne("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:k("pointer-events-auto",{"cursor-move":!v||v!=="target","cursor-not-allowed":v==="target"&&P&&!I,"cursor-grabbing":v==="target"&&(!P||I)}),onMouseDown:O=>A("target",O.nativeEvent)})]})})]})]})]})};import{useDebouncedCallback as Th}from"use-debounce";import{useReactFlow as _h}from"@xyflow/react";import{useCallback as Lc}from"react";var Yo=(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))(Yo||{});import{xml2json as Sm,json2xml as Mm}from"xml-js";var xl={compact:!0,spaces:4},Pm=e=>e.replaceAll(`
|
|
2
|
-
`,"
");function
|
|
1
|
+
var $d=Object.defineProperty,Xd=Object.defineProperties;var Kd=Object.getOwnPropertyDescriptors;var ln=Object.getOwnPropertySymbols;var Hi=Object.prototype.hasOwnProperty,Gi=Object.prototype.propertyIsEnumerable;var Vi=(e,t,o)=>t in e?$d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,b=(e,t)=>{for(var o in t||(t={}))Hi.call(t,o)&&Vi(e,o,t[o]);if(ln)for(var o of ln(t))Gi.call(t,o)&&Vi(e,o,t[o]);return e},v=(e,t)=>Xd(e,Kd(t));var Xe=(e,t)=>{var o={};for(var n in e)Hi.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&ln)for(var n of ln(e))t.indexOf(n)<0&&Gi.call(e,n)&&(o[n]=e[n]);return o};var Gr=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 qd,Translations as Zd}from"lecom-ui";var Bi={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Delete",configure_node:"Configure activity",configure_edge:"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..."},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",export:{title:"Export diagram",print:"Print",html:"Export as HTML",png:"Export as PNG",feedback:{error:"Error exporting diagram"}},import_governance:"Import diagram from Governance platform",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_referenced_not_configured:"The subprocess reference is not properly 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 zi={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",configure_node:"Configurar actividad",configure_edge:"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..."},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",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{error:"Error al exportar diagrama"}},import_governance:"Importar diagrama de la plataforma Governance",minimap:{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_referenced_not_configured:"La referencia al subproceso no est\xE1 configurada correctamente",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 Fi={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Excluir",configure_node:"Configurar atividade",configure_edge:"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..."},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",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{error:"Erro ao exportar o diagrama"}},import_governance:"Importar diagrama da plataforma Governance",minimap:{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_referenced_not_configured:"A refer\xEAncia ao subprocesso n\xE3o est\xE1 configurada corretamente",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 Wi={pt_BR:Fi,en_US:Bi,es_ES:zi};var Yi,Ui,Jd=(Ui=(Yi=Gr("LecomUserLanguage"))!=null?Yi:Gr("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?Ui:Zd.PT_BR;qd({lng:Jd,resources:Wi});var ke=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(ke||{});var cn=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(cn||{}),Br=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Br||{}),zr=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(zr||{}),Fr=(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))(Fr||{});import{RotateCcw as cu,ScrollText as du,SquarePlus as uu}from"lucide-react";import{jsx as dn,jsxs as Qd}from"react/jsx-runtime";var un=({size:e=24,className:t})=>Qd("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[dn("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),dn("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),dn("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),dn("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as $i}from"react/jsx-runtime";var Gt=({size:e=24,className:t})=>$i("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:$i("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 Eo,jsxs as jd}from"react/jsx-runtime";var Bt=({size:e=24,className:t})=>jd("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:[Eo("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"}),Eo("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Eo("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),Eo("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Eo("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Wr,jsxs as eu}from"react/jsx-runtime";var zt=({size:e=24,className:t})=>eu("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:[Wr("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"}),Wr("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Wr("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Yr,jsxs as tu}from"react/jsx-runtime";var Ft=({size:e=24,className:t})=>tu("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:[Yr("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"}),Yr("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Yr("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Ur,jsxs as ou}from"react/jsx-runtime";var Xi=({size:e=24,className:t})=>Ur("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:ou("g",{children:[Ur("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"}),Ur("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as nu}from"clsx";import{twMerge as ru}from"tailwind-merge";function k(...e){return ru(nu(e))}var nt=(e=0,t=0)=>e<t?t:e,pn=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as Ki,jsxs as iu}from"react/jsx-runtime";var qi=({size:e=24,className:t})=>iu("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:k("stroke-2",t),children:[Ki("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"}),Ki("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as $r}from"react/jsx-runtime";var Zi=({size:e=24,className:t})=>$r("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:$r("g",{children:$r("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 Ji}from"react/jsx-runtime";var fn=({size:e=24,className:t})=>Ji("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:Ji("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 Qi}from"react/jsx-runtime";var bo=({size:e=24,className:t})=>Qi("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",className:k("stroke-2",t),children:Qi("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 Xr,jsxs as su}from"react/jsx-runtime";var ji=({size:e=24,className:t})=>su("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:[Xr("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"}),Xr("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"}),Xr("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as _o,jsxs as au}from"react/jsx-runtime";var es=({size:e=24,className:t})=>au("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:[_o("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"}),_o("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"}),_o("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"}),_o("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),_o("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as mn,jsxs as lu}from"react/jsx-runtime";var ts=({size:e=24,className:t})=>lu("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:[mn("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"}),mn("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),mn("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),mn("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var ee=(s=>(s.START_EVENT="START_EVENT",s.END_EVENT="END_EVENT",s.TASK="TASK",s.LANE="LANE",s.GATEWAY="GATEWAY",s.ANNOTATION="ANNOTATION",s.UNSUPPORTED="UNSUPPORTED",s))(ee||{}),Fe=(o=>(o.SCRIPT="SCRIPT",o.SUBPROCESS="SUBPROCESS",o))(Fe||{}),gn={SCRIPT:{icon:du},SUBPROCESS:{icon:uu}},Ke=(t=>(t.LOOP="LOOP",t))(Ke||{}),hn={LOOP:{icon:cu}},We=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(We||{}),Kr={EXCLUSIVE:{icon:zt},PARALLEL:{icon:Ft},COMPLEX:{icon:Bt}};import{ReactFlowProvider as $y}from"@xyflow/react";import{createContext as Xy,useContext as Ky,useEffect as qy,useId as Zy,useMemo as Jy,useState as $e}from"react";import{Background as Ay,MiniMap as Iy,ReactFlow as Cy,SelectionMode as Sy}from"@xyflow/react";import{forwardRef as My,useImperativeHandle as Py}from"react";import{useEdgesState as a0,useNodesState as l0,useOnSelectionChange as c0,useReactFlow as d0}from"@xyflow/react";import{useCallback as ho,useEffect as u0}from"react";import{create as pu}from"zustand";import{useReactFlow as fu}from"@xyflow/react";import{useCallback as mu}from"react";var yn=()=>{let{setEdges:e}=fu();return mu(()=>{let o=wt.getState().pathEdgeIds;e(n=>n.map(r=>v(b({},r),{selected:o.includes(r.id)})))},[e])},wt=pu((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=b({},n.statusByNodeId),i=b({},n.statusData),a=!1;return o.forEach(s=>{let l=`${s.diagramId}-${s.activityId}`;r[s.diagramId]!==s.status&&(r[s.diagramId]=s.status,i[l]=s,a=!0)}),a?{statusByNodeId:r,statusData:i}:n})},getTaskStatus:o=>t().statusByNodeId[o]||null,clearTaskStatuses:()=>e({statusByNodeId:{},statusData:{},pathEdgeIds:[]}),setPathEdges:o=>{e({pathEdgeIds:o})},getPathEdgeIds:()=>t().pathEdgeIds,clearPathEdges:()=>{e({pathEdgeIds:[]})},calculateFlowPath:(o,n)=>{if(!o.length||!n.length)return;t().clearPathEdges();let r=n.filter(d=>t().statusByNodeId[d]);if(r.length<=1)return;let i=[],a={};o.forEach(d=>{a[d.source]||(a[d.source]=[]),a[d.source].push({targetId:d.target,edgeId:d.id})});let s=r[0],l=r[r.length-1];o.forEach(d=>{d.target===s&&i.push(d.id)}),o.forEach(d=>{d.source===l&&i.push(d.id)});let c=(d,u)=>{let p=[],f=new Set;for(p.push({node:d,path:[]}),f.add(d);p.length>0;){let{node:g,path:x}=p.shift();if(g===u)return x;let m=a[g]||[];for(let{targetId:E,edgeId:y}of m)f.has(E)||(f.add(E),p.push({node:E,path:[...x,y]}))}return[]};for(let d=0;d<r.length-1;d++){let u=r[d],p=r[d+1],f=c(u,p);f.length>0&&i.push(...f)}i.length>0&&e({pathEdgeIds:i})}}));import{useNodesInitialized as Mf,useReactFlow as Pf,useStore as Lf}from"@xyflow/react";var gu={value:()=>{}};function ns(){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 xn(o)}function xn(e){this._=e}function hu(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}})}xn.prototype=ns.prototype={constructor:xn,on:function(e,t){var o=this._,n=hu(e+"",o),r,i=-1,a=n.length;if(arguments.length<2){for(;++i<a;)if((r=(e=n[i]).type)&&(r=yu(o[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<a;)if(r=(e=n[i]).type)o[r]=os(o[r],e.name,t);else if(t==null)for(r in o)o[r]=os(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 xn(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 yu(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function os(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=gu,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var qr=ns;var En="http://www.w3.org/1999/xhtml",Zr={svg:"http://www.w3.org/2000/svg",xhtml:En,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Qe(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),Zr.hasOwnProperty(t)?{space:Zr[t],local:e}:e}function xu(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===En&&t.documentElement.namespaceURI===En?t.createElement(e):t.createElementNS(o,e)}}function Eu(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function bn(e){var t=Qe(e);return(t.local?Eu:xu)(t)}function bu(){}function At(e){return e==null?bu:function(){return this.querySelector(e)}}function rs(e){typeof e!="function"&&(e=At(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=new Array(a),l,c,d=0;d<a;++d)(l=i[d])&&(c=e.call(l,l.__data__,d,i))&&("__data__"in l&&(c.__data__=l.__data__),s[d]=c);return new me(n,this._parents)}function Jr(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function _u(){return[]}function To(e){return e==null?_u:function(){return this.querySelectorAll(e)}}function Tu(e){return function(){return Jr(e.apply(this,arguments))}}function is(e){typeof e=="function"?e=Tu(e):e=To(e);for(var t=this._groups,o=t.length,n=[],r=[],i=0;i<o;++i)for(var a=t[i],s=a.length,l,c=0;c<s;++c)(l=a[c])&&(n.push(e.call(l,l.__data__,c,a)),r.push(l));return new me(n,r)}function No(e){return function(){return this.matches(e)}}function _n(e){return function(t){return t.matches(e)}}var Nu=Array.prototype.find;function vu(e){return function(){return Nu.call(this.children,e)}}function wu(){return this.firstElementChild}function ss(e){return this.select(e==null?wu:vu(typeof e=="function"?e:_n(e)))}var Au=Array.prototype.filter;function Iu(){return Array.from(this.children)}function Cu(e){return function(){return Au.call(this.children,e)}}function as(e){return this.selectAll(e==null?Iu:Cu(typeof e=="function"?e:_n(e)))}function ls(e){typeof e!="function"&&(e=No(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=[],l,c=0;c<a;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&s.push(l);return new me(n,this._parents)}function Tn(e){return new Array(e.length)}function cs(){return new me(this._enter||this._groups.map(Tn),this._parents)}function vo(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}vo.prototype={constructor:vo,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 ds(e){return function(){return e}}function Su(e,t,o,n,r,i){for(var a=0,s,l=t.length,c=i.length;a<c;++a)(s=t[a])?(s.__data__=i[a],n[a]=s):o[a]=new vo(e,i[a]);for(;a<l;++a)(s=t[a])&&(r[a]=s)}function Mu(e,t,o,n,r,i,a){var s,l,c=new Map,d=t.length,u=i.length,p=new Array(d),f;for(s=0;s<d;++s)(l=t[s])&&(p[s]=f=a.call(l,l.__data__,s,t)+"",c.has(f)?r[s]=l:c.set(f,l));for(s=0;s<u;++s)f=a.call(e,i[s],s,i)+"",(l=c.get(f))?(n[s]=l,l.__data__=i[s],c.delete(f)):o[s]=new vo(e,i[s]);for(s=0;s<d;++s)(l=t[s])&&c.get(p[s])===l&&(r[s]=l)}function Pu(e){return e.__data__}function us(e,t){if(!arguments.length)return Array.from(this,Pu);var o=t?Mu:Su,n=this._parents,r=this._groups;typeof e!="function"&&(e=ds(e));for(var i=r.length,a=new Array(i),s=new Array(i),l=new Array(i),c=0;c<i;++c){var d=n[c],u=r[c],p=u.length,f=Lu(e.call(d,d&&d.__data__,c,n)),g=f.length,x=s[c]=new Array(g),m=a[c]=new Array(g),E=l[c]=new Array(p);o(d,u,x,m,E,f,t);for(var y=0,h=0,_,N;y<g;++y)if(_=x[y]){for(y>=h&&(h=y+1);!(N=m[h])&&++h<g;);_._next=N||null}}return a=new me(a,n),a._enter=s,a._exit=l,a}function Lu(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function ps(){return new me(this._exit||this._groups.map(Tn),this._parents)}function fs(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 ms(e){for(var t=e.selection?e.selection():e,o=this._groups,n=t._groups,r=o.length,i=n.length,a=Math.min(r,i),s=new Array(r),l=0;l<a;++l)for(var c=o[l],d=n[l],u=c.length,p=s[l]=new Array(u),f,g=0;g<u;++g)(f=c[g]||d[g])&&(p[g]=f);for(;l<r;++l)s[l]=o[l];return new me(s,this._parents)}function gs(){for(var e=this._groups,t=-1,o=e.length;++t<o;)for(var n=e[t],r=n.length-1,i=n[r],a;--r>=0;)(a=n[r])&&(i&&a.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(a,i),i=a);return this}function hs(e){e||(e=ku);function t(u,p){return u&&p?e(u.__data__,p.__data__):!u-!p}for(var o=this._groups,n=o.length,r=new Array(n),i=0;i<n;++i){for(var a=o[i],s=a.length,l=r[i]=new Array(s),c,d=0;d<s;++d)(c=a[d])&&(l[d]=c);l.sort(t)}return new me(r,this._parents).order()}function ku(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function ys(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function xs(){return Array.from(this)}function Es(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length;r<i;++r){var a=n[r];if(a)return a}return null}function bs(){let e=0;for(let t of this)++e;return e}function _s(){return!this.node()}function Ts(e){for(var t=this._groups,o=0,n=t.length;o<n;++o)for(var r=t[o],i=0,a=r.length,s;i<a;++i)(s=r[i])&&e.call(s,s.__data__,i,r);return this}function Du(e){return function(){this.removeAttribute(e)}}function Ru(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Ou(e,t){return function(){this.setAttribute(e,t)}}function Vu(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Hu(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function Gu(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 Ns(e,t){var o=Qe(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?Ru:Du:typeof t=="function"?o.local?Gu:Hu:o.local?Vu:Ou)(o,t))}function Nn(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Bu(e){return function(){this.style.removeProperty(e)}}function zu(e,t,o){return function(){this.style.setProperty(e,t,o)}}function Fu(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function vs(e,t,o){return arguments.length>1?this.each((t==null?Bu:typeof t=="function"?Fu:zu)(e,t,o==null?"":o)):rt(this.node(),e)}function rt(e,t){return e.style.getPropertyValue(t)||Nn(e).getComputedStyle(e,null).getPropertyValue(t)}function Wu(e){return function(){delete this[e]}}function Yu(e,t){return function(){this[e]=t}}function Uu(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function ws(e,t){return arguments.length>1?this.each((t==null?Wu:typeof t=="function"?Uu:Yu)(e,t)):this.node()[e]}function As(e){return e.trim().split(/^|\s+/)}function Qr(e){return e.classList||new Is(e)}function Is(e){this._node=e,this._names=As(e.getAttribute("class")||"")}Is.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 Cs(e,t){for(var o=Qr(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function Ss(e,t){for(var o=Qr(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function $u(e){return function(){Cs(this,e)}}function Xu(e){return function(){Ss(this,e)}}function Ku(e,t){return function(){(t.apply(this,arguments)?Cs:Ss)(this,e)}}function Ms(e,t){var o=As(e+"");if(arguments.length<2){for(var n=Qr(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?Ku:t?$u:Xu)(o,t))}function qu(){this.textContent=""}function Zu(e){return function(){this.textContent=e}}function Ju(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function Ps(e){return arguments.length?this.each(e==null?qu:(typeof e=="function"?Ju:Zu)(e)):this.node().textContent}function Qu(){this.innerHTML=""}function ju(e){return function(){this.innerHTML=e}}function ep(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function Ls(e){return arguments.length?this.each(e==null?Qu:(typeof e=="function"?ep:ju)(e)):this.node().innerHTML}function tp(){this.nextSibling&&this.parentNode.appendChild(this)}function ks(){return this.each(tp)}function op(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ds(){return this.each(op)}function Rs(e){var t=typeof e=="function"?e:bn(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function np(){return null}function Os(e,t){var o=typeof e=="function"?e:bn(e),n=t==null?np:typeof t=="function"?t:At(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function rp(){var e=this.parentNode;e&&e.removeChild(this)}function Vs(){return this.each(rp)}function ip(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function sp(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Hs(e){return this.select(e?sp:ip)}function Gs(e){return arguments.length?this.property("__data__",e):this.node().__data__}function ap(e){return function(t){e.call(this,t,this.__data__)}}function lp(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 cp(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 dp(e,t,o){return function(){var n=this.__on,r,i=ap(t);if(n){for(var a=0,s=n.length;a<s;++a)if((r=n[a]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=o),r.value=t;return}}this.addEventListener(e.type,i,o),r={type:e.type,name:e.name,value:t,listener:i,options:o},n?n.push(r):this.__on=[r]}}function Bs(e,t,o){var n=lp(e+""),r,i=n.length,a;if(arguments.length<2){var s=this.node().__on;if(s){for(var l=0,c=s.length,d;l<c;++l)for(r=0,d=s[l];r<i;++r)if((a=n[r]).type===d.type&&a.name===d.name)return d.value}return}for(s=t?dp:cp,r=0;r<i;++r)this.each(s(n[r],t,o));return this}function zs(e,t,o){var n=Nn(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 up(e,t){return function(){return zs(this,e,t)}}function pp(e,t){return function(){return zs(this,e,t.apply(this,arguments))}}function Fs(e,t){return this.each((typeof t=="function"?pp:up)(e,t))}function*Ws(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length,a;r<i;++r)(a=n[r])&&(yield a)}var fp=[null];function me(e,t){this._groups=e,this._parents=t}function Ys(){return new me([[document.documentElement]],fp)}function mp(){return this}me.prototype=Ys.prototype={constructor:me,select:rs,selectAll:is,selectChild:ss,selectChildren:as,filter:ls,data:us,enter:cs,exit:ps,join:fs,merge:ms,selection:mp,order:gs,sort:hs,call:ys,nodes:xs,node:Es,size:bs,empty:_s,each:Ts,attr:Ns,style:vs,property:ws,classed:Ms,text:Ps,html:Ls,raise:ks,lower:Ds,append:Rs,insert:Os,remove:Vs,clone:Hs,datum:Gs,on:Bs,dispatch:Fs,[Symbol.iterator]:Ws};var je=Ys;function vn(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function jr(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function Io(){}var wo=.7,In=1/wo,Wt="\\s*([+-]?\\d+)\\s*",Ao="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",qe="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",gp=/^#([0-9a-f]{3,8})$/,hp=new RegExp(`^rgb\\(${Wt},${Wt},${Wt}\\)$`),yp=new RegExp(`^rgb\\(${qe},${qe},${qe}\\)$`),xp=new RegExp(`^rgba\\(${Wt},${Wt},${Wt},${Ao}\\)$`),Ep=new RegExp(`^rgba\\(${qe},${qe},${qe},${Ao}\\)$`),bp=new RegExp(`^hsl\\(${Ao},${qe},${qe}\\)$`),_p=new RegExp(`^hsla\\(${Ao},${qe},${qe},${Ao}\\)$`),Us={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};vn(Io,it,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:$s,formatHex:$s,formatHex8:Tp,formatHsl:Np,formatRgb:Xs,toString:Xs});function $s(){return this.rgb().formatHex()}function Tp(){return this.rgb().formatHex8()}function Np(){return js(this).formatHsl()}function Xs(){return this.rgb().formatRgb()}function it(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=gp.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?Ks(t):o===3?new Me(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?wn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?wn(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=hp.exec(e))?new Me(t[1],t[2],t[3],1):(t=yp.exec(e))?new Me(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=xp.exec(e))?wn(t[1],t[2],t[3],t[4]):(t=Ep.exec(e))?wn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=bp.exec(e))?Js(t[1],t[2]/100,t[3]/100,1):(t=_p.exec(e))?Js(t[1],t[2]/100,t[3]/100,t[4]):Us.hasOwnProperty(e)?Ks(Us[e]):e==="transparent"?new Me(NaN,NaN,NaN,0):null}function Ks(e){return new Me(e>>16&255,e>>8&255,e&255,1)}function wn(e,t,o,n){return n<=0&&(e=t=o=NaN),new Me(e,t,o,n)}function vp(e){return e instanceof Io||(e=it(e)),e?(e=e.rgb(),new Me(e.r,e.g,e.b,e.opacity)):new Me}function Yt(e,t,o,n){return arguments.length===1?vp(e):new Me(e,t,o,n==null?1:n)}function Me(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}vn(Me,Yt,jr(Io,{brighter(e){return e=e==null?In:Math.pow(In,e),new Me(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?wo:Math.pow(wo,e),new Me(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Me(Ct(this.r),Ct(this.g),Ct(this.b),Cn(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:qs,formatHex:qs,formatHex8:wp,formatRgb:Zs,toString:Zs}));function qs(){return`#${It(this.r)}${It(this.g)}${It(this.b)}`}function wp(){return`#${It(this.r)}${It(this.g)}${It(this.b)}${It((isNaN(this.opacity)?1:this.opacity)*255)}`}function Zs(){let e=Cn(this.opacity);return`${e===1?"rgb(":"rgba("}${Ct(this.r)}, ${Ct(this.g)}, ${Ct(this.b)}${e===1?")":`, ${e})`}`}function Cn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ct(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function It(e){return e=Ct(e),(e<16?"0":"")+e.toString(16)}function Js(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new Ye(e,t,o,n)}function js(e){if(e instanceof Ye)return new Ye(e.h,e.s,e.l,e.opacity);if(e instanceof Io||(e=it(e)),!e)return new Ye;if(e instanceof Ye)return e;e=e.rgb();var t=e.r/255,o=e.g/255,n=e.b/255,r=Math.min(t,o,n),i=Math.max(t,o,n),a=NaN,s=i-r,l=(i+r)/2;return s?(t===i?a=(o-n)/s+(o<n)*6:o===i?a=(n-t)/s+2:a=(t-o)/s+4,s/=l<.5?i+r:2-i-r,a*=60):s=l>0&&l<1?0:a,new Ye(a,s,l,e.opacity)}function ea(e,t,o,n){return arguments.length===1?js(e):new Ye(e,t,o,n==null?1:n)}function Ye(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}vn(Ye,ea,jr(Io,{brighter(e){return e=e==null?In:Math.pow(In,e),new Ye(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?wo:Math.pow(wo,e),new Ye(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 Me(ei(e>=240?e-240:e+120,r,n),ei(e,r,n),ei(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new Ye(Qs(this.h),An(this.s),An(this.l),Cn(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=Cn(this.opacity);return`${e===1?"hsl(":"hsla("}${Qs(this.h)}, ${An(this.s)*100}%, ${An(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Qs(e){return e=(e||0)%360,e<0?e+360:e}function An(e){return Math.max(0,Math.min(1,e||0))}function ei(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 ti(e,t,o,n,r){var i=e*e,a=i*e;return((1-3*e+3*i-a)*t+(4-6*i+3*a)*o+(1+3*e+3*i-3*a)*n+a*r)/6}function ta(e){var t=e.length-1;return function(o){var n=o<=0?o=0:o>=1?(o=1,t-1):Math.floor(o*t),r=e[n],i=e[n+1],a=n>0?e[n-1]:2*r-i,s=n<t-1?e[n+2]:2*i-r;return ti((o-n/t)*t,a,r,i,s)}}function oa(e){var t=e.length;return function(o){var n=Math.floor(((o%=1)<0?++o:o)*t),r=e[(n+t-1)%t],i=e[n%t],a=e[(n+1)%t],s=e[(n+2)%t];return ti((o-n/t)*t,r,i,a,s)}}var oi=e=>()=>e;function Ap(e,t){return function(o){return e+o*t}}function Ip(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 na(e){return(e=+e)==1?Sn:function(t,o){return o-t?Ip(t,o,e):oi(isNaN(t)?o:t)}}function Sn(e,t){var o=t-e;return o?Ap(e,o):oi(isNaN(e)?t:e)}var Mn=function e(t){var o=na(t);function n(r,i){var a=o((r=Yt(r)).r,(i=Yt(i)).r),s=o(r.g,i.g),l=o(r.b,i.b),c=Sn(r.opacity,i.opacity);return function(d){return r.r=a(d),r.g=s(d),r.b=l(d),r.opacity=c(d),r+""}}return n.gamma=e,n}(1);function ra(e){return function(t){var o=t.length,n=new Array(o),r=new Array(o),i=new Array(o),a,s;for(a=0;a<o;++a)s=Yt(t[a]),n[a]=s.r||0,r[a]=s.g||0,i[a]=s.b||0;return n=e(n),r=e(r),i=e(i),s.opacity=1,function(l){return s.r=n(l),s.g=r(l),s.b=i(l),s+""}}}var Cp=ra(ta),Sp=ra(oa);function Oe(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var ri=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ni=new RegExp(ri.source,"g");function Mp(e){return function(){return e}}function Pp(e){return function(t){return e(t)+""}}function ii(e,t){var o=ri.lastIndex=ni.lastIndex=0,n,r,i,a=-1,s=[],l=[];for(e=e+"",t=t+"";(n=ri.exec(e))&&(r=ni.exec(t));)(i=r.index)>o&&(i=t.slice(o,i),s[a]?s[a]+=i:s[++a]=i),(n=n[0])===(r=r[0])?s[a]?s[a]+=r:s[++a]=r:(s[++a]=null,l.push({i:a,x:Oe(n,r)})),o=ni.lastIndex;return o<t.length&&(i=t.slice(o),s[a]?s[a]+=i:s[++a]=i),s.length<2?l[0]?Pp(l[0].x):Mp(t):(t=l.length,function(c){for(var d=0,u;d<t;++d)s[(u=l[d]).i]=u.x(c);return s.join("")})}var ia=180/Math.PI,Pn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function si(e,t,o,n,r,i){var a,s,l;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(l=e*o+t*n)&&(o-=e*l,n-=t*l),(s=Math.sqrt(o*o+n*n))&&(o/=s,n/=s,l/=s),e*n<t*o&&(e=-e,t=-t,l=-l,a=-a),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*ia,skewX:Math.atan(l)*ia,scaleX:a,scaleY:s}}var Ln;function sa(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Pn:si(t.a,t.b,t.c,t.d,t.e,t.f)}function aa(e){return e==null?Pn:(Ln||(Ln=document.createElementNS("http://www.w3.org/2000/svg","g")),Ln.setAttribute("transform",e),(e=Ln.transform.baseVal.consolidate())?(e=e.matrix,si(e.a,e.b,e.c,e.d,e.e,e.f)):Pn)}function la(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,p,f,g){if(c!==u||d!==p){var x=f.push("translate(",null,t,null,o);g.push({i:x-4,x:Oe(c,u)},{i:x-2,x:Oe(d,p)})}else(u||p)&&f.push("translate("+u+t+p+o)}function a(c,d,u,p){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),p.push({i:u.push(r(u)+"rotate(",null,n)-2,x:Oe(c,d)})):d&&u.push(r(u)+"rotate("+d+n)}function s(c,d,u,p){c!==d?p.push({i:u.push(r(u)+"skewX(",null,n)-2,x:Oe(c,d)}):d&&u.push(r(u)+"skewX("+d+n)}function l(c,d,u,p,f,g){if(c!==u||d!==p){var x=f.push(r(f)+"scale(",null,",",null,")");g.push({i:x-4,x:Oe(c,u)},{i:x-2,x:Oe(d,p)})}else(u!==1||p!==1)&&f.push(r(f)+"scale("+u+","+p+")")}return function(c,d){var u=[],p=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,u,p),a(c.rotate,d.rotate,u,p),s(c.skewX,d.skewX,u,p),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,p),c=d=null,function(f){for(var g=-1,x=p.length,m;++g<x;)u[(m=p[g]).i]=m.x(f);return u.join("")}}}var ai=la(sa,"px, ","px)","deg)"),li=la(aa,", ",")",")");var Ut=0,So=0,Co=0,da=1e3,kn,Mo,Dn=0,St=0,Rn=0,Po=typeof performance=="object"&&performance.now?performance:Date,ua=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ko(){return St||(ua(Lp),St=Po.now()+Rn)}function Lp(){St=0}function Lo(){this._call=this._time=this._next=null}Lo.prototype=On.prototype={constructor:Lo,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?ko():+o)+(t==null?0:+t),!this._next&&Mo!==this&&(Mo?Mo._next=this:kn=this,Mo=this),this._call=e,this._time=o,ci()},stop:function(){this._call&&(this._call=null,this._time=1/0,ci())}};function On(e,t,o){var n=new Lo;return n.restart(e,t,o),n}function pa(){ko(),++Ut;for(var e=kn,t;e;)(t=St-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ut}function ca(){St=(Dn=Po.now())+Rn,Ut=So=0;try{pa()}finally{Ut=0,Dp(),St=0}}function kp(){var e=Po.now(),t=e-Dn;t>da&&(Rn-=t,Dn=e)}function Dp(){for(var e,t=kn,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:kn=o);Mo=e,ci(n)}function ci(e){if(!Ut){So&&(So=clearTimeout(So));var t=e-St;t>24?(e<1/0&&(So=setTimeout(ca,e-Po.now()-Rn)),Co&&(Co=clearInterval(Co))):(Co||(Dn=Po.now(),Co=setInterval(kp,da)),Ut=1,ua(ca))}}function Vn(e,t,o){var n=new Lo;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var Rp=qr("start","end","cancel","interrupt"),Op=[],ga=0,fa=1,Gn=2,Hn=3,ma=4,Bn=5,Do=6;function st(e,t,o,n,r,i){var a=e.__transition;if(!a)e.__transition={};else if(o in a)return;Vp(e,o,{name:t,index:n,group:r,on:Rp,tween:Op,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:ga})}function Ro(e,t){var o=ge(e,t);if(o.state>ga)throw new Error("too late; already scheduled");return o}function _e(e,t){var o=ge(e,t);if(o.state>Hn)throw new Error("too late; already running");return o}function ge(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function Vp(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=On(i,0,o.time);function i(c){o.state=fa,o.timer.restart(a,o.delay,o.time),o.delay<=c&&a(c-o.delay)}function a(c){var d,u,p,f;if(o.state!==fa)return l();for(d in n)if(f=n[d],f.name===o.name){if(f.state===Hn)return Vn(a);f.state===ma?(f.state=Do,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete n[d]):+d<t&&(f.state=Do,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete n[d])}if(Vn(function(){o.state===Hn&&(o.state=ma,o.timer.restart(s,o.delay,o.time),s(c))}),o.state=Gn,o.on.call("start",e,e.__data__,o.index,o.group),o.state===Gn){for(o.state=Hn,r=new Array(p=o.tween.length),d=0,u=-1;d<p;++d)(f=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++u]=f);r.length=u+1}}function s(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=Bn,1),u=-1,p=r.length;++u<p;)r[u].call(e,d);o.state===Bn&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=Do,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function di(e,t){var o=e.__transition,n,r,i=!0,a;if(o){t=t==null?null:t+"";for(a in o){if((n=o[a]).name!==t){i=!1;continue}r=n.state>Gn&&n.state<Bn,n.state=Do,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[a]}i&&delete e.__transition}}function ha(e){return this.each(function(){di(this,e)})}function Hp(e,t){var o,n;return function(){var r=_e(this,e),i=r.tween;if(i!==o){n=o=i;for(var a=0,s=n.length;a<s;++a)if(n[a].name===t){n=n.slice(),n.splice(a,1);break}}r.tween=n}}function Gp(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=_e(this,e),a=i.tween;if(a!==n){r=(n=a).slice();for(var s={name:t,value:o},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=s;break}l===c&&r.push(s)}i.tween=r}}function ya(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=ge(this.node(),o).tween,r=0,i=n.length,a;r<i;++r)if((a=n[r]).name===e)return a.value;return null}return this.each((t==null?Hp:Gp)(o,e,t))}function $t(e,t,o){var n=e._id;return e.each(function(){var r=_e(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return ge(r,n).value[t]}}function zn(e,t){var o;return(typeof t=="number"?Oe:t instanceof it?Mn:(o=it(t))?(t=o,Mn):ii)(e,t)}function Bp(e){return function(){this.removeAttribute(e)}}function zp(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Fp(e,t,o){var n,r=o+"",i;return function(){var a=this.getAttribute(e);return a===r?null:a===n?i:i=t(n=a,o)}}function Wp(e,t,o){var n,r=o+"",i;return function(){var a=this.getAttributeNS(e.space,e.local);return a===r?null:a===n?i:i=t(n=a,o)}}function Yp(e,t,o){var n,r,i;return function(){var a,s=o(this),l;return s==null?void this.removeAttribute(e):(a=this.getAttribute(e),l=s+"",a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s)))}}function Up(e,t,o){var n,r,i;return function(){var a,s=o(this),l;return s==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),l=s+"",a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s)))}}function xa(e,t){var o=Qe(e),n=o==="transform"?li:zn;return this.attrTween(e,typeof t=="function"?(o.local?Up:Yp)(o,n,$t(this,"attr."+e,t)):t==null?(o.local?zp:Bp)(o):(o.local?Wp:Fp)(o,n,t))}function $p(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function Xp(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function Kp(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Xp(e,i)),o}return r._value=t,r}function qp(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&$p(e,i)),o}return r._value=t,r}function Ea(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=Qe(e);return this.tween(o,(n.local?Kp:qp)(n,t))}function Zp(e,t){return function(){Ro(this,e).delay=+t.apply(this,arguments)}}function Jp(e,t){return t=+t,function(){Ro(this,e).delay=t}}function ba(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Zp:Jp)(t,e)):ge(this.node(),t).delay}function Qp(e,t){return function(){_e(this,e).duration=+t.apply(this,arguments)}}function jp(e,t){return t=+t,function(){_e(this,e).duration=t}}function _a(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Qp:jp)(t,e)):ge(this.node(),t).duration}function ef(e,t){if(typeof t!="function")throw new Error;return function(){_e(this,e).ease=t}}function Ta(e){var t=this._id;return arguments.length?this.each(ef(t,e)):ge(this.node(),t).ease}function tf(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;_e(this,e).ease=o}}function Na(e){if(typeof e!="function")throw new Error;return this.each(tf(this._id,e))}function va(e){typeof e!="function"&&(e=No(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=[],l,c=0;c<a;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&s.push(l);return new Ie(n,this._parents,this._name,this._id)}function wa(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,o=e._groups,n=t.length,r=o.length,i=Math.min(n,r),a=new Array(n),s=0;s<i;++s)for(var l=t[s],c=o[s],d=l.length,u=a[s]=new Array(d),p,f=0;f<d;++f)(p=l[f]||c[f])&&(u[f]=p);for(;s<n;++s)a[s]=t[s];return new Ie(a,this._parents,this._name,this._id)}function of(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 nf(e,t,o){var n,r,i=of(t)?Ro:_e;return function(){var a=i(this,e),s=a.on;s!==n&&(r=(n=s).copy()).on(t,o),a.on=r}}function Aa(e,t){var o=this._id;return arguments.length<2?ge(this.node(),o).on.on(e):this.each(nf(o,e,t))}function rf(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function Ia(){return this.on("end.remove",rf(this._id))}function Ca(e){var t=this._name,o=this._id;typeof e!="function"&&(e=At(e));for(var n=this._groups,r=n.length,i=new Array(r),a=0;a<r;++a)for(var s=n[a],l=s.length,c=i[a]=new Array(l),d,u,p=0;p<l;++p)(d=s[p])&&(u=e.call(d,d.__data__,p,s))&&("__data__"in d&&(u.__data__=d.__data__),c[p]=u,st(c[p],t,o,p,c,ge(d,o)));return new Ie(i,this._parents,t,o)}function Sa(e){var t=this._name,o=this._id;typeof e!="function"&&(e=To(e));for(var n=this._groups,r=n.length,i=[],a=[],s=0;s<r;++s)for(var l=n[s],c=l.length,d,u=0;u<c;++u)if(d=l[u]){for(var p=e.call(d,d.__data__,u,l),f,g=ge(d,o),x=0,m=p.length;x<m;++x)(f=p[x])&&st(f,t,o,x,p,g);i.push(p),a.push(d)}return new Ie(i,a,t,o)}var sf=je.prototype.constructor;function Ma(){return new sf(this._groups,this._parents)}function af(e,t){var o,n,r;return function(){var i=rt(this,e),a=(this.style.removeProperty(e),rt(this,e));return i===a?null:i===o&&a===n?r:r=t(o=i,n=a)}}function Pa(e){return function(){this.style.removeProperty(e)}}function lf(e,t,o){var n,r=o+"",i;return function(){var a=rt(this,e);return a===r?null:a===n?i:i=t(n=a,o)}}function cf(e,t,o){var n,r,i;return function(){var a=rt(this,e),s=o(this),l=s+"";return s==null&&(l=s=(this.style.removeProperty(e),rt(this,e))),a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s))}}function df(e,t){var o,n,r,i="style."+t,a="end."+i,s;return function(){var l=_e(this,e),c=l.on,d=l.value[i]==null?s||(s=Pa(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(a,r=d),l.on=n}}function La(e,t,o){var n=(e+="")=="transform"?ai:zn;return t==null?this.styleTween(e,af(e,n)).on("end.style."+e,Pa(e)):typeof t=="function"?this.styleTween(e,cf(e,n,$t(this,"style."+e,t))).each(df(this._id,e)):this.styleTween(e,lf(e,n,t),o).on("end.style."+e,null)}function uf(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function pf(e,t,o){var n,r;function i(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&uf(e,a,o)),n}return i._value=t,i}function ka(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,pf(e,t,o==null?"":o))}function ff(e){return function(){this.textContent=e}}function mf(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function Da(e){return this.tween("text",typeof e=="function"?mf($t(this,"text",e)):ff(e==null?"":e+""))}function gf(e){return function(t){this.textContent=e.call(this,t)}}function hf(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&gf(r)),t}return n._value=e,n}function Ra(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,hf(e))}function Oa(){for(var e=this._name,t=this._id,o=Fn(),n=this._groups,r=n.length,i=0;i<r;++i)for(var a=n[i],s=a.length,l,c=0;c<s;++c)if(l=a[c]){var d=ge(l,t);st(l,e,o,c,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Ie(n,this._parents,e,o)}function Va(){var e,t,o=this,n=o._id,r=o.size();return new Promise(function(i,a){var s={value:a},l={value:function(){--r===0&&i()}};o.each(function(){var c=_e(this,n),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(l)),c.on=t}),r===0&&i()})}var yf=0;function Ie(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function Ha(e){return je().transition(e)}function Fn(){return++yf}var et=je.prototype;Ie.prototype=Ha.prototype={constructor:Ie,select:Ca,selectAll:Sa,selectChild:et.selectChild,selectChildren:et.selectChildren,filter:va,merge:wa,selection:Ma,transition:Oa,call:et.call,nodes:et.nodes,node:et.node,size:et.size,empty:et.empty,each:et.each,on:Aa,attr:xa,attrTween:Ea,style:La,styleTween:ka,text:Da,textTween:Ra,remove:Ia,tween:ya,delay:ba,duration:_a,ease:Ta,easeVarying:Na,end:Va,[Symbol.iterator]:et[Symbol.iterator]};function Wn(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var xf={time:null,delay:0,duration:250,ease:Wn};function Ef(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 Ga(e){var t,o;e instanceof Ie?(t=e._id,e=e._name):(t=Fn(),(o=xf).time=ko(),e=e==null?null:e+"");for(var n=this._groups,r=n.length,i=0;i<r;++i)for(var a=n[i],s=a.length,l,c=0;c<s;++c)(l=a[c])&&st(l,e,t,c,a,o||Ef(l,t));return new Ie(n,this._parents,e,t)}je.prototype.interrupt=ha;je.prototype.transition=Ga;function at(e,t,o){this.k=e,this.x=t,this.y=o}at.prototype={constructor:at,scale:function(e){return e===1?this:new at(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new at(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 Yn=new at(1,0,0);Un.prototype=at.prototype;function Un(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Yn;return e.__zoom}var _f=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var Ba;(function(e){e.Strict="strict",e.Loose="loose"})(Ba||(Ba={}));var za;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(za||(za={}));var Fa;(function(e){e.Partial="partial",e.Full="full"})(Fa||(Fa={}));var Wa;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Wa||(Wa={}));var Ya;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ya||(Ya={}));var Pe;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Pe||(Pe={}));var wN={[Pe.Left]:Pe.Right,[Pe.Right]:Pe.Left,[Pe.Top]:Pe.Bottom,[Pe.Bottom]:Pe.Top};var Tf=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var Nf=(e,t=[0,0])=>{var s;let{width:o,height:n}=vf(e),r=(s=e.origin)!=null?s:t,i=o*r[0],a=n*r[1];return{x:e.position.x-i,y:e.position.y-a}};var De=(e,t=[0,0])=>{var r,i,a,s,l,c,d,u;let{x:o,y:n}=Tf(e)?e.internals.positionAbsolute:Nf(e,t);return{x:o,y:n,x2:o+((s=(a=(i=(r=e.measured)==null?void 0:r.width)!=null?i:e.width)!=null?a:e.initialWidth)!=null?s:0),y2:n+((u=(d=(c=(l=e.measured)==null?void 0:l.height)!=null?c:e.height)!=null?d:e.initialHeight)!=null?u:0)}};function vf(e){var t,o,n,r,i,a,s,l;return{width:(r=(n=(o=(t=e.measured)==null?void 0:t.width)!=null?o:e.width)!=null?n:e.initialWidth)!=null?r:0,height:(l=(s=(a=(i=e.measured)==null?void 0:i.height)!=null?a:e.height)!=null?s:e.initialHeight)!=null?l:0}}var AN={[Pe.Left]:{x:-1,y:0},[Pe.Right]:{x:1,y:0},[Pe.Top]:{x:0,y:-1},[Pe.Bottom]:{x:0,y:1}};var wf={nodeOrigin:[0,0],nodeExtent:_f,elevateNodesOnSelect:!0,defaults:{}},IN=v(b({},wf),{checkEquality:!0});var Ua;(function(e){e.Line="line",e.Handle="handle"})(Ua||(Ua={}));var Af={width:0,height:0,x:0,y:0},CN=v(b({},Af),{pointerX:0,pointerY:0,aspectRatio:1});import{useCallback as Oo,useEffect as kf,useRef as Df,useState as qa}from"react";import{shallow as Rf}from"zustand/shallow";var If=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function Cf(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 Sf(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 $n=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){let i=t==="horizontal"?this.yLines:this.xLines,[a,s]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],l=[];for(let p of i){if(p.position<a)continue;if(p.position>s)break;if(p.node.id===n.id||p.node.parentId===n.id||!If(p.nodeBox,r))continue;let f=Math.abs(p.position-o);if(f>Xn)continue;let x=Cf(p.nodeBox,De(n))>0?0:Sf(p.nodeBox,De(n));l.push({line:p,lineDist:f,nodeDist:x})}let c=.5,d=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;l.sort((p,f)=>{if(d){if(p.line===d&&f.line!==d)return-1;if(f.line===d&&p.line!==d)return 1}return Math.abs(p.lineDist-f.lineDist)<=c?p.nodeDist-f.nodeDist:p.lineDist-f.lineDist});let u=l.length>0?l[0].line:void 0;return u&&(t==="horizontal"?this.lastHorizontalLine=u:this.lastVerticalLine=u),u}};function $a(e,t=Mt,o){let n=[];return e==null||e.forEach(r=>{let i=o(r.id);if(!i)throw new Error(`Node with id ${r.id} not found in internal nodes.`);let a=De(i);Object.entries(t).forEach(([s,l])=>{var c;n.push({nodeBox:a,node:r,orientation:l.orientation,position:l.resolve(r,a),color:(c=r.style)==null?void 0:c.backgroundColor,anchorName:s})})}),n}function Xa(e,t,o,n,r=Object.keys(Mt)){let i=[];for(let s of r){let l=Mt[s],c=l.resolve(o,n),d=e.search(l.orientation,c,o,t);d&&i.push({anchorName:s,sourcePosition:c,anchor:l,line:d})}let a={horizontal:void 0,vertical:void 0};for(let s of i){let l=a[s.anchor.orientation],c=Math.abs(s.sourcePosition-s.line.position);(!l||c<Math.abs(l.sourcePosition-l.line.position))&&(a[s.anchor.orientation]=s)}return a}function Ka(e,t,o,n,r,i,a,s){var u,p,f,g,x,m,E,y;if(!(o!=null&&o.position))return{snappedX:!1,snappedY:!1};let l=!1,c=!1,d={x:o.position.x,y:o.position.y,x2:o.position.x+((p=(u=e.measured)==null?void 0:u.width)!=null?p:0),y2:o.position.y+((g=(f=e.measured)==null?void 0:f.height)!=null?g:0)};if(a){let _=a.anchor.resolve(e,d)-a.line.position;if(Math.abs(_)<=Xn){if(o.position.y-=_,r!=null&&r.dimensions)if(n){let N=t.internals.positionAbsolute.y+((m=(x=e.measured)==null?void 0:x.height)!=null?m:0);r.dimensions.height=N-a.line.position}else r.dimensions.height=a.line.position-t.internals.positionAbsolute.y;c=!0}}if(s){let _=s.anchor.resolve(e,d)-s.line.position;if(Math.abs(_)<=Xn){if(o.position.x-=_,r!=null&&r.dimensions)if(n){let N=t.internals.positionAbsolute.x+((y=(E=e.measured)==null?void 0:E.width)!=null?y:0);r.dimensions.width=N-s.line.position}else r.dimensions.width=s.line.position-t.internals.positionAbsolute.x;l=!0}}return i&&(l||c)&&(o.position.x-=i.position.x,o.position.y-=i.position.y),{snappedX:l,snappedY:c}}var Xn=10,Mt={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 Vf}from"react/jsx-runtime";var Of=new $n;function Kn(){let[e,t]=qa(void 0),[o,n]=qa(void 0),{width:r,height:i}=Lf(m=>({width:m.width,height:m.height}),Rf),a=Mf(),s=Df(Of),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=Pf(),u=Oo(()=>{t(void 0),n(void 0)},[]),p=Oo(m=>{let E=m!=null?m:d();u();let y=$a(E,Mt,c);s.current.initialize(y)},[c,u,d]),f=Oo(()=>{setTimeout(()=>{p()},100)},[p]);kf(()=>{a&&p(d())},[a,p,d]);let g=Oo((m,E)=>{var q,S,O,H,z;if(!s.current||m.length===0||m.length>2)return m;u();let y,h,_=Object.keys(Mt);m.length===1?m[0].type==="position"?y=m[0]:m[0].type==="dimensions"&&(h=m[0],_=["right","bottom"]):m[0].type==="position"&&m[1].type==="dimensions"&&m[1].dimensions&&(y=m[0],h=m[1],_=["top","left"]);let N=E.find(Z=>Z.id===m[0].id);if(!N)return m;let T=c(N.id);if(!T)throw new Error(`Node with id ${N.id} not found in internal nodes`);let A=c((q=T.parentId)!=null?q:""),M=De(T);h!=null&&h.dimensions&&(M.x2=M.x+h.dimensions.width,M.y2=M.y+h.dimensions.height);let{x:R,y:I}=l({x:0,y:0}),{x:D,y:C}=l({x:r,y:i}),L={x:R,y:I,x2:D,y2:C},{horizontal:V,vertical:w}=Xa(s.current,L,N,M,_),P={id:N.id,type:"position",position:{x:T.internals.positionAbsolute.x,y:T.internals.positionAbsolute.y},dragging:!1};y!=null&&y.position&&P.position&&(A?(P.position.x=y.position.x+((O=(S=A==null?void 0:A.position)==null?void 0:S.x)!=null?O:0),P.position.y=y.position.y+((z=(H=A==null?void 0:A.position)==null?void 0:H.y)!=null?z:0)):(P.position.x=y.position.x,P.position.y=y.position.y));let{snappedX:F,snappedY:X}=Ka(N,T,P,y,h,A,V,w);if(F||X){if((h!=null&&h.resizing||y!=null&&y.dragging)&&(F&&n(w==null?void 0:w.line),X&&t(V==null?void 0:V.line)),h&&y)return[P,h];if(y)return[P];if(h)return[h]}return m},[l,c,r,i,t,n,u]),x=Oo(()=>Vf(Za,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:p,forceRebuildIndex:f,updateHelperLines:g,helperLineHorizontal:e,helperLineVertical:o,HelperLines:x}}import{reconnectEdge as Ih,useReactFlow as Ch}from"@xyflow/react";import{useCallback as Rt,useRef as Sh}from"react";var lt=e=>new Map(e.map(t=>[t.id,t])),Vo=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),Ja=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),ui=e=>e.some(t=>t.type==="START_EVENT"),ct=(e,t)=>e==="START_EVENT"?!ui(t):!0,Qa=(e,t,o,n,r)=>{let i=lt(o),a=i.get(e);if(!a||a.type!=="START_EVENT")return!1;let s=i.get(t);return(s==null?void 0:s.type)==="ANNOTATION"?!1:Vo(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},ja=(e,t,o,n,r)=>{let i=lt(o),a=i.get(t);if(!a||a.type!=="END_EVENT")return!1;let s=i.get(e);return(s==null?void 0:s.type)==="ANNOTATION"?!1:Ja(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},qn=(e,t,o,n,r)=>{var c;let i=lt(o),a=i.get(e);if(!a||a.type!=="GATEWAY"||((c=a.data)==null?void 0:c.variant)!=="EXCLUSIVE")return!1;let s=t?i.get(t):null;return(s==null?void 0:s.type)==="ANNOTATION"?!1:Vo(e,n,r).filter(d=>{let u=i.get(d.target);return(u==null?void 0:u.type)!=="ANNOTATION"}).length>=2},el=(e,t,o)=>{var a,s,l,c;let n=lt(o),r=n.get(e),i=n.get(t);return(r==null?void 0:r.type)!=="GATEWAY"||(i==null?void 0:i.type)!=="GATEWAY"||((a=r==null?void 0:r.data)==null?void 0:a.variant)==="EXCLUSIVE"&&((s=i==null?void 0:i.data)==null?void 0:s.variant)==="PARALLEL"||((l=r==null?void 0:r.data)==null?void 0:l.variant)==="COMPLEX"&&((c=i==null?void 0:i.data)==null?void 0:c.variant)==="PARALLEL"},Zn=(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"},tl=(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"},Jn=(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"},Ho=(e,t,o,n)=>{let r=lt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:Ja(e,o,n).some(s=>{let l=r.get(s.source);return(l==null?void 0:l.type)==="START_EVENT"})},Go=(e,t,o,n)=>{let r=lt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:Vo(e,o,n).some(s=>{let l=r.get(s.target);return(l==null?void 0:l.type)==="END_EVENT"})},ol=(e,t,o,n,r)=>{let i=lt(o),a=i.get(e),s=i.get(t);return(a==null?void 0:a.type)==="START_EVENT"&&(s==null?void 0:s.type)==="TASK"?Go(t,o,n,r):(s==null?void 0:s.type)==="END_EVENT"&&(a==null?void 0:a.type)==="TASK"?Ho(e,o,n,r):!1},Qn=(e,t,o)=>Vo(e,t,o).length>0,jn=(e,t,o,n,r)=>{let i=lt(o),a=i.get(e);if(!a||a.type!=="TASK")return!1;let s=t?i.get(t):null;return(s==null?void 0:s.type)==="ANNOTATION"?!1:Vo(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var nl=(e,t,o,n)=>o.some(r=>n&&r.id===n?!1:r.source===e&&r.target===t);var Hf=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!nl(e.sourceNodeId,e.targetNodeId,e.edges,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!Qa(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!ja(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!qn(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!jn(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:el(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"&&tl(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:!(Zn(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(Jn(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(Ho(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!ol(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(Go(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(Qn(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"})],pi=e=>{for(let t of Hf){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var Gf=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:qn(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:ui(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Zn(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Jn(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Ho(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Go(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Qn(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:jn(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],rl=e=>{let t=Gf.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 um,EdgeLabelRenderer as pm,getStraightPath as fm,useInternalNode as al,useViewport as mm}from"@xyflow/react";import{Position as Bo}from"@xyflow/react";function il(e,t){var h,_,N,T;let{width:o=0,height:n=0}=e.measured||{width:0,height:0},r=e.internals.positionAbsolute,i=t.internals.positionAbsolute,a=o/2,s=n/2,l=r.x+a,c=r.y+s,d=i.x+((_=(h=t==null?void 0:t.measured)==null?void 0:h.width)!=null?_:0)/2,u=i.y+((T=(N=t==null?void 0:t.measured)==null?void 0:N.height)!=null?T:0)/2,p=(d-l)/(2*a)-(u-c)/(2*s),f=(d-l)/(2*a)+(u-c)/(2*s),g=1/(Math.abs(p)+Math.abs(f)||1),x=g*p,m=g*f,E=a*(x+m)+l,y=s*(-x+m)+c;return{x:E,y}}function sl(e,t){var c,d,u,p;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(p=(u=e.measured)==null?void 0:u.height)!=null?p:0,i=Math.round(o.x),a=Math.round(o.y),s=Math.round(t.x),l=Math.round(t.y);return s<=i+1?Bo.Left:s>=i+n-1?Bo.Right:l<=a+1?Bo.Top:l>=a+r-1?Bo.Bottom:Bo.Top}function dt(e,t){let o=il(e,t),n=il(t,e),r=sl(e,o),i=sl(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function er(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"}}import{Button as Ff,Tooltip as Wf,TooltipContent as Yf,TooltipTrigger as Uf,useTranslation as $f}from"lecom-ui";import{Settings as Xf}from"lucide-react";import{getIncomers as tr,getOutgoers as or,useReactFlow as zf}from"@xyflow/react";import{useStoreApi as Bf}from"@xyflow/react";var ut=()=>{let e=Bf();return{selectElements:n=>{let{edges:r,nodes:i,triggerEdgeChanges:a,triggerNodeChanges:s}=e.getState(),l=i.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]),c=r.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]);return s(l),a(c),!0},clearSelection:async()=>{let{unselectNodesAndEdges:n}=e.getState();return n(),await pn(),!0}}};var nr=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=zf(),{selectElements:r}=ut(),i=m=>{let E=o(),y=n(),h=tr(m,E,y),_=or(m,E,y),N=h.some(A=>A.type==="START_EVENT"),T=_.some(A=>A.type==="END_EVENT");return N?"start":T?"end":"between"},a=(m,E,y)=>{var N,T,A,M;if(!m)return;let h={type:m.type,variant:(N=m.data)==null?void 0:N.variant,attribute:(T=m.data)==null?void 0:T.attribute},_={id:m.id,position:i(m),label:(A=m.data)==null?void 0:A.label,node:h};return m.type==="TASK"&&((M=m.data)==null?void 0:M.variant)==="SUBPROCESS"?v(b({},_),{type:"sub_process"}):m.type==="GATEWAY"?v(b({},_),{type:"gateway",variant:s(m,E,y)}):v(b({},_),{type:"activity"})},s=(m,E,y)=>{if(m.type!=="GATEWAY")return;let h=tr(m,E,y),_=!1,N=!1;if(h.forEach(T=>{var A,M;T.type==="TASK"&&(((A=T.data)==null?void 0:A.variant)==="SCRIPT"&&(_=!0),((M=T.data)==null?void 0:M.attribute)==="LOOP"&&(N=!0))}),_&&N)return"script_loop";if(_)return"script";if(N)return"loop"},l=(m,E,y)=>{var A,M,R,I;let h=e(m.source),_=e(m.target);if(!h||!_)return"simple";if(or(h,E,y).some(D=>D.type==="END_EVENT"))return"final";if(h.type==="GATEWAY")switch((A=h.data)==null?void 0:A.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(h.type==="TASK"){let D=(M=h.data)==null?void 0:M.variant,C=(R=h.data)==null?void 0:R.attribute;if(D==="SUBPROCESS")return"from_sub_process";if(_.type==="TASK"&&((I=_.data)==null?void 0:I.variant)==="SUBPROCESS")return"to_sub_process";let L=D==="SCRIPT",V=C==="LOOP";return L&&V?"script_loop":L?"script":V?"loop":"simple"}return"simple"},c=(m,E,y)=>{let h=[];function _(T,A,M=0){let R=a(T,E,y);if(R.depth=M,A.push(R),T.type==="TASK"){h.push([...A]),A.pop();return}let I=tr(T,E,y);if(I.length)for(let D of I)_(D,A,M+1);A.pop()}let N=tr(m,E,y);for(let T of N)_(T,[]);return h},d=(m,E,y)=>{let h=[];function _(T,A,M=0){let R=a(T,E,y);if(R.depth=M,A.push(R),T.type==="TASK"){h.push([...A]),A.pop();return}let I=or(T,E,y);if(I.length)for(let D of I)_(D,A,M+1);A.pop()}let N=or(m,E,y);for(let T of N)_(T,[]);return h},u=(m,E,y)=>(y=y.filter(_=>_.source===m.id),y.map(_=>{var A;let N=e(_.target),T;return N&&(T=a(N,E,y)),{id:_.id,type:"routing",variant:l(_,E,y),label:(A=_.data)==null?void 0:A.label,target:T}})),p=m=>{let E=e(m);if(!E)return;let y=o(),h=n(),_=a(E,y,h);return _.sources=c(E,y,h),_.targets=d(E,y,h),_.edgeTargets=u(E,y,h),E.type==="GATEWAY"&&(_.variant=s(E,y,h)),_},f=m=>{let E=t(m);if(!E)return;let y=o(),h=n(),_=l(E,y,h),T={id:E.id,type:"routing",variant:_,gatewayVariant:void 0},A=e(E.source);if(A){let R=a(A,y,h);T.source=R;let I=s(A,y,h);if(T.gatewayVariant=I,A.type==="TASK")T.sources=[[R]];else{let D=c(A,y,h);T.sources=D.length?D:[[R]]}}let M=e(E.target);if(M){let R=a(M,y,h);if(T.target=R,M.type==="TASK")T.targets=[[R]];else{let I=d(M,y,h);T.targets=I.length?I:[[R]]}}return T},g=m=>{let E=e(m);if(E)return p(E.id);let y=t(m);if(y)return f(y.id)};return{configureElement:m=>{let E=g(m);if(E)return r([m]),E},getConfigureElement:g,getNodeConfigure:p,getEdgeConfigure:f}};import{jsx as rr,jsxs as Kf}from"react/jsx-runtime";var pt=({elementId:e,elementType:t="node"})=>{let{t:o}=$f(),{onConfigureElement:n}=U(),{getConfigureElement:r}=nr();return Kf(Wf,{children:[rr(Uf,{asChild:!0,children:rr(Ff,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let a=r(e);a&&(n==null||n(a))},children:rr(Xf,{size:16})})}),rr(Yf,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};import{useReactFlow as qf}from"@xyflow/react";import{Button as Zf,Tooltip as Jf,TooltipContent as Qf,TooltipTrigger as jf,useTranslation as em}from"lecom-ui";import{TrashIcon as tm}from"lucide-react";import{jsx as ir,jsxs as om}from"react/jsx-runtime";var sr=({elementId:e,elementType:t="node"})=>{let{t:o}=em(),{deleteElements:n}=qf();return om(Jf,{children:[ir(jf,{asChild:!0,children:ir(Zf,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{n(t==="node"?{nodes:[{id:e}]}:{edges:[{id:e}]})},children:ir(tm,{size:16})})}),ir(Qf,{color:"black",children:o("editor.toolbar.delete")})]})};import{Button as nm,Tooltip as rm,TooltipContent as im,TooltipTrigger as sm,useTranslation as am}from"lecom-ui";import{MoveUpRightIcon as lm}from"lucide-react";import{useCallback as cm}from"react";import{jsx as ar,jsxs as dm}from"react/jsx-runtime";var Xt=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=am(),r=cm(i=>{i.stopPropagation();let a=document.querySelector(`[data-id="${e}"]`);if(!a)return;let s=a.querySelector(".react-flow__handle.source");if(!s)return;let l=s.getBoundingClientRect(),c=l.left+l.width/2,d=l.top+l.height/2,u=new MouseEvent("mousedown",{clientX:c,clientY:d,bubbles:!0,cancelable:!0});s.dispatchEvent(u)},[e]);return dm(rm,{children:[ar(sm,{asChild:!0,children:ar(nm,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:ar(lm,{size:16})})}),ar(im,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};import{jsx as zo}from"react/jsx-runtime";var qt=i=>{var a=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=a,r=Xe(a,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:s}=U(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d}=er(o,n),u=!l&&!c&&!d,p=[{component:zo(sr,{elementId:e,elementType:"edge"})}],f=()=>s==="view"?u?[{component:zo(pt,{elementId:e,elementType:"edge"})}]:[]:u?[{component:zo(pt,{elementId:e,elementType:"edge"})},...p]:p,x=(m=>{switch(m){case"SEQUENCE_EDGE":return f();case"MESSAGE_EDGE":return s==="view"?[]:[...p];case"ANNOTATION_EDGE":return s==="view"?[]:[...p];default:return[]}})(t);if(!(x.length===0||s==="view"))return zo("div",v(b({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:x.map((m,E)=>zo("div",{children:m.component},E))}))};import{jsx as lr,jsxs as gm}from"react/jsx-runtime";var Zt={type:"ANNOTATION_EDGE",reconnectable:!0},ll=({id:e,source:t,target:o,selected:n,data:r})=>{let{zoom:i}=mm(),{isMultipleSelection:a}=U(),s=al(t),l=al(o);if(!s||!l)return null;let{sx:c,sy:d,tx:u,ty:p}=dt(s,l),[f,g,x]=fm({sourceX:c,sourceY:d,targetX:u,targetY:p}),m=n||(s==null?void 0:s.selected)||(l==null?void 0:l.selected),E=1/i;return gm("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":m}),children:[lr(um,{id:e,path:f,strokeDasharray:4,className:k("stroke-2 stroke-current transition-colors duration-75",{"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)]":m&&!(r!=null&&r.hasError)})}),lr(pm,{children:lr("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${g}px, ${x}px)`},children:n&&!a&&lr(qt,{edgeId:e,edgeType:"ANNOTATION_EDGE",style:{transform:`scale(${E})`}})})})]})};import{useState as ml,useCallback as Nm,useMemo as fr,useEffect as vm,useRef as gl}from"react";import{BaseEdge as wm,EdgeLabelRenderer as Am,MarkerType as hl,useInternalNode as yl,useReactFlow as Im,useViewport as Cm,useEdges as Sm,Position as eo}from"@xyflow/react";import{useEffect as cl,useRef as hm,useState as ym}from"react";import{jsx as dl}from"react/jsx-runtime";var Ne=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:a,onBlur:s,onInput:l,onInvalidFirstCharacter:c})=>{let d=hm(null),[u,p]=ym(!1);cl(()=>{p(i!=null?i:!1)},[i]),cl(()=>{if(u&&d.current){d.current.focus();let y=document.createRange();y.selectNodeContents(d.current);let h=window.getSelection();h&&(h.removeAllRanges(),h.addRange(y))}},[u]);let f=y=>{y.stopPropagation(),u||p(!0)},g=y=>{let h=y.currentTarget.innerText.replace(/\n$/,""),_=t&&h.length>=t,N=window.getSelection(),T=(N==null?void 0:N.toString())||"",A=T.length>0,M=y.ctrlKey||y.metaKey,R=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Enter","Escape","Shift"],I=M&&y.key==="a",D=M&&y.key==="c",C=M&&y.key==="x",L=M&&y.key==="v";function V(P){return/[a-zA-Z0-9À-ÖØ-öø-ÿ]/.test(P)}if((h.length===0||A&&T.length===h.length)&&!V(y.key)&&!R.includes(y.key)&&!M){y.preventDefault();return}if(y.key==="Enter"){y.preventDefault(),y.currentTarget.blur();return}_&&!A&&(R.includes(y.key)||I||D||C||L||y.preventDefault())},x=y=>{y.preventDefault();let h=y.clipboardData.getData("text/plain").replace(/[\n\r]+/g," "),_=y.currentTarget.innerText.replace(/\n$/,""),N=window.getSelection();if(!N||N.rangeCount===0)return;let T=N.toString(),A=_.length-T.length,M=t?Math.max(0,t-A):1/0;if(M<=0&&T.length===0)return;let R=h;if(R.length>M&&(R=R.substring(0,M)),!R&&T.length===0)return;let I=N.getRangeAt(0);if(I.startOffset===0&&(I.startContainer===y.currentTarget||I.startContainer.parentNode===y.currentTarget)&&R.length>0){let L=R[0];if(!/[a-zA-Z0-9À-ÖØ-öø-ÿ]/.test(L)){c==null||c();return}}I.deleteContents();let C=document.createTextNode(R);I.insertNode(C),I.setStartAfter(C),I.collapse(!0),N.removeAllRanges(),N.addRange(I),l==null||l(y.currentTarget.innerText.replace(/\n$/,""))},m=y=>{l==null||l(y.currentTarget.innerText.replace(/\n$/,""))},E=y=>{p(!1);let h=y.currentTarget.innerText.trim();t&&h.length>t&&(h=h.substring(0,t)),y.currentTarget.innerText=h,s==null||s(),h!==e&&(a==null||a(h))};return dl("div",{className:k("flex-1 p-2 self-stretch content-center border border-transparent overflow-hidden text-ellipsis body-medium-400 text-center rounded-sm",{"border border-dashed border-grey-400 bg-white":u,"bg-white":e.length>0},n),style:o,onDoubleClick:f,children:dl("div",{ref:d,className:k("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":u}),contentEditable:u,suppressContentEditableWarning:!0,onKeyDown:g,onPaste:x,onInput:m,onBlur:E,children:e})})};import{Position as cr}from"@xyflow/react";var Fo=e=>e===cr.Left||e===cr.Right,fi=(e,t=30)=>e===cr.Right||e===cr.Bottom?t:-t,mi=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,Jt=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),dr=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2});var Wo={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15};function xm(e,t,o,n,r,i,a=0){let s=fi(r,Wo.OFFSET),l=fi(i,Wo.OFFSET),c=Fo(r),d=Fo(i),u=c?0:a,p=c?a:0,f=d?0:a,g=d?a:0,x={x:e+u,y:t+p},m={x:o+f,y:n+g};if(c&&d){let E=(t+n)/2+a;return[x,{x:e+s,y:t+a},{x:e+s,y:E},{x:o+l,y:E},{x:o+l,y:n+a},m]}if(!c&&!d){let E=(e+o)/2+a;return[x,{x:e+a,y:t+s},{x:E,y:t+s},{x:E,y:n+l},{x:o+a,y:n+l},m]}return c?[x,{x:e+s,y:t+a},{x:e+s,y:n+l+a},{x:o+a,y:n+l+a},m]:[x,{x:e+a,y:t+s},{x:o+l+a,y:t+s},{x:o+l+a,y:n+a},m]}function ul(e,t,o,n,r,i,a,s=0){let l=xm(e,t,o,n,r,i,s);if(!(a!=null&&a.length))return l;let c=[...a];if(c.length>0){let d={x:e,y:t},u=c[0],p=Fo(r);p&&Math.abs(d.y-u.y)>1?c.unshift({x:u.x,y:d.y}):!p&&Math.abs(d.x-u.x)>1&&c.unshift({x:d.x,y:u.y})}if(c.length>0){let d={x:o,y:n},u=c[c.length-1],p=Fo(i);p&&Math.abs(d.y-u.y)>1?c.push({x:u.x,y:d.y}):!p&&Math.abs(d.x-u.x)>1&&c.push({x:d.x,y:u.y})}return[{x:e,y:t},...c,{x:o,y:n}]}var pl=e=>{if(e.length<2)return"";let[t,...o]=e;return`M ${t.x},${t.y}${o.map(n=>` L ${n.x},${n.y}`).join("")}`};import{useCallback as Qt,useEffect as ur,useRef as Yo,useState as jt}from"react";import{useReactFlow as Em,useStore as bm}from"@xyflow/react";var _m=50,fl=.1,Tm=.6,pr=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:a,getNodes:s,getEdge:l,screenToFlowPosition:c}=Em(),{setIsDragging:d,setReconnectingEdgeId:u}=U(),p=bm(S=>S.isValidConnection),[f,g]=jt(null),[x,m]=jt(null),[E,y]=jt(null),[h,_]=jt(null),[N,T]=jt(null),[A,M]=jt(!1),R=Yo(null),I=Yo(null),D=Yo(null),C=Yo(t),L=Yo(o);ur(()=>{C.current=t,L.current=o},[t,o]),ur(()=>{R.current=f},[f]),ur(()=>{I.current=N},[N]);let V=Qt(S=>{let O=s(),H=O.find(ne=>ne.id===S);if(!H)return{x:0,y:0};let z=H.position.x,Z=H.position.y,Y=H.parentId;for(;Y;){let ne=O.find(G=>G.id===Y);if(!ne)break;z+=ne.position.x,Z+=ne.position.y,Y=ne.parentId}return{x:z,y:Z}},[s]),w=Qt(S=>{var Y,ne,G,$,K,W;let O=s(),H=null,z=_m,Z=O.filter(B=>B.type!=="LANE"&&B.type!=="ANNOTATION");for(let B of Z){if(B.id===e)continue;let J=V(B.id),Q=(G=(ne=(Y=B.measured)==null?void 0:Y.width)!=null?ne:B.width)!=null?G:0,oe=(W=(K=($=B.measured)==null?void 0:$.height)!=null?K:B.height)!=null?W:0;if(S.x>=J.x&&S.x<=J.x+Q&&S.y>=J.y&&S.y<=J.y+oe)return B.id;let le=Math.max(J.x-S.x,0,S.x-(J.x+Q)),ce=Math.max(J.y-S.y,0,S.y-(J.y+oe)),ye=Math.sqrt(le*le+ce*ce);ye<z&&(z=ye,H=B.id)}return H},[s,V,e]),P=Qt((S,O)=>{var le,ce,ye,xe,Te,fe;let H=a(S);if(!H)return null;let z=V(S),Z=(ye=(ce=(le=H.measured)==null?void 0:le.width)!=null?ce:H.width)!=null?ye:0,Y=(fe=(Te=(xe=H.measured)==null?void 0:xe.height)!=null?Te:H.height)!=null?fe:0,ne=Math.abs(z.x+Z-O.x),G=Math.abs(O.x-z.x),$=Math.abs(z.y+Y-O.y),K=Math.abs(O.y-z.y),W={right:ne,left:G,bottom:$,top:K},B=Object.entries(W).reduce((se,[j,ae])=>ae<se[1]?[j,ae]:se,["right",W.right])[0],J=D.current;if(J&&J!==B){let se=W[B],j=W[J],ae=Math.abs(j-se),Se=Math.min(Math.abs(j),Math.abs(se));ae<Se*Tm&&(B=J)}let Q=B,oe,ue;if(Q==="right"||Q==="left"){let j=(Math.max(z.y,Math.min(z.y+Y,O.y))-z.y)/(Y||1);Math.abs(j-.5)<fl&&(j=.5),ue=j,oe={x:Q==="right"?z.x+Z:z.x,y:z.y+ue*Y}}else{let j=(Math.max(z.x,Math.min(z.x+Z,O.x))-z.x)/(Z||1);Math.abs(j-.5)<fl&&(j=.5),ue=j,oe={x:z.x+ue*Z,y:Q==="bottom"?z.y+Y:z.y}}return{side:Q,snapPosition:oe,offset:ue}},[a,V]),F=Qt(S=>{var G,$,K;let O=R.current;if(!O)return;let H=c({x:S.clientX,y:S.clientY}),z=w(H);y(z);let Z=H,Y=null,ne=null;if(z){let W=P(z,H);W&&(Y=W.side,Z=W.snapPosition,ne=W.offset,D.current=Y);let B=l(e),J={source:O==="source"?z:C.current,target:O==="target"?z:L.current,sourceHandle:O==="source"?Y:(G=B==null?void 0:B.sourceHandle)!=null?G:null,targetHandle:O==="target"?Y:($=B==null?void 0:B.targetHandle)!=null?$:null},Q=(K=p==null?void 0:p(J))!=null?K:!0;M(Q)}else D.current=null,M(!1);_(Y),T(ne),m(Z)},[w,P,l,e,c,p]),X=Qt(S=>{var Y,ne,G,$,K;let O=R.current;if(!O)return;let H=c({x:S.clientX,y:S.clientY}),z=w(H);if(z){let W=P(z,H),B=(Y=W==null?void 0:W.side)!=null?Y:null,J=(ne=W==null?void 0:W.offset)!=null?ne:.5,Q=l(e),oe={source:O==="source"?z:C.current,target:O==="target"?z:L.current,sourceHandle:O==="source"?B:(G=Q==null?void 0:Q.sourceHandle)!=null?G:null,targetHandle:O==="target"?B:($=Q==null?void 0:Q.targetHandle)!=null?$:null};((K=p==null?void 0:p(oe))==null||K)&&i(ue=>ue.map(le=>{var ce,ye;return le.id===e?v(b({},le),{source:oe.source,target:oe.target,sourceHandle:oe.sourceHandle,targetHandle:oe.targetHandle,data:v(b({},le.data),{points:void 0,sourceOffset:O==="source"?J:(ce=le.data)==null?void 0:ce.sourceOffset,targetOffset:O==="target"?J:(ye=le.data)==null?void 0:ye.targetOffset})}):le}))}g(null),m(null),y(null),_(null),T(null),d(!1),M(!1),u(null),D.current=null,document.removeEventListener("mouseup",X),document.removeEventListener("mousemove",F);let Z=Ze.get(n);Z==null||Z.clearReconnectingEdge()},[e,w,P,l,i,n,F,p,c,d,u]),q=Qt((S,O)=>{if(r||O.button!==0)return;O.stopPropagation(),O.preventDefault(),i(z=>z.map(Z=>Z.id===e?v(b({},Z),{data:v(b({},Z.data),{points:void 0})}):Z)),g(S),u(e);let H=Ze.get(n);H==null||H.setReconnectingEdge(e),document.addEventListener("mousemove",F),document.addEventListener("mouseup",X)},[r,e,n,F,X,u,i]);return ur(()=>()=>{if(R.current){document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",X),u(null);let S=Ze.get(n);S==null||S.clearReconnectingEdge()}},[n,F,X,u]),{reconnectingHandle:f,cursorPosition:x,hoveredNodeId:E,reconnectingSide:h,reconnectingOffset:N,isValidReconnection:A,handleReconnectStart:q}};import{Fragment as El,jsx as ve,jsxs as ft}from"react/jsx-runtime";var Ue={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:hl.ArrowClosed},markerEnd:{type:hl.Arrow},data:{label:""}},{MOVE_THRESHOLD:mr,MIN_SEGMENT_LENGTH:Mm,PARALLEL_OFFSET:xl}=Wo;function Pm(e,t,o,n){let r=n.filter(s=>s.source===t&&s.target===o||s.source===o&&s.target===t);if(r.length<=1){let s=n.filter(d=>d.source===t);if(s.length<=1)return 0;let l=s.findIndex(d=>d.id===e);if(l<=0)return 0;let c=(s.length-1)/2;return(l-c)*xl}let i=r.findIndex(s=>s.id===e),a=(r.length-1)/2;return(i-a)*xl}var bl=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var ne;let{zoom:c}=Cm(),{updateEdgeData:d}=Im(),u=Sm(),{isMultipleSelection:p,mode:f,instanceId:g}=U(),[x,m]=ml(!1),[E,y]=ml(null),h=gl(null),_=gl(null),N=f!=="edit",{reconnectingHandle:T,cursorPosition:A,hoveredNodeId:M,reconnectingSide:R,isValidReconnection:I,handleReconnectStart:D}=pr({edgeId:e,source:t,target:o,instanceId:g,isReadOnly:N}),C=yl(t),L=yl(o),{sx:V,sy:w,tx:P,ty:F,sourcePos:X,targetPos:q}=fr(()=>{var ce,ye;let G=C&&L?dt(C,L):{sx:0,sy:0,tx:0,ty:0,sourcePos:eo.Right,targetPos:eo.Left},$=s?i:G.sourcePos,K=l?a:G.targetPos,W=(xe,Te,fe)=>{var _t,Tt,Nt,vt,Hr,xo;let{x:se,y:j}=xe.internals.positionAbsolute,ae=(Nt=(Tt=(_t=xe.measured)==null?void 0:_t.width)!=null?Tt:xe.width)!=null?Nt:0,Se=(xo=(Hr=(vt=xe.measured)==null?void 0:vt.height)!=null?Hr:xe.height)!=null?xo:0;switch(Te){case eo.Top:return{x:se+ae*fe,y:j};case eo.Bottom:return{x:se+ae*fe,y:j+Se};case eo.Left:return{x:se,y:j+Se*fe};case eo.Right:return{x:se+ae,y:j+Se*fe};default:return{x:se+ae/2,y:j+Se/2}}},B=(ce=n==null?void 0:n.sourceOffset)!=null?ce:.5,J=(ye=n==null?void 0:n.targetOffset)!=null?ye:.5,Q=C?W(C,$,B).x:G.sx,oe=C?W(C,$,B).y:G.sy,ue=L?W(L,K,J).x:G.tx,le=L?W(L,K,J).y:G.ty;return T==="source"&&A?(Q=A.x,oe=A.y,R&&($=R)):T==="target"&&A&&(ue=A.x,le=A.y,R&&(K=R)),{sx:Q,sy:oe,tx:ue,ty:le,sourcePos:$,targetPos:K}},[C,L,s,l,i,a,T,A,R,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);vm(()=>{var K;if(!_.current){_.current={sx:V,sy:w,tx:P,ty:F,sourcePos:X,targetPos:q};return}let G=_.current;(Math.abs(V-G.sx)>mr||Math.abs(w-G.sy)>mr||Math.abs(P-G.tx)>mr||Math.abs(F-G.ty)>mr||G.sourcePos!==X||G.targetPos!==q)&&((K=n==null?void 0:n.points)!=null&&K.length)&&!T&&d(e,v(b({},n),{points:void 0})),_.current={sx:V,sy:w,tx:P,ty:F,sourcePos:X,targetPos:q}},[V,w,P,F,X,q,n,e,d,T]);let S=fr(()=>{let G=Pm(e,t,o,u);return ul(V,w,P,F,X,q,n==null?void 0:n.points,G)},[V,w,P,F,X,q,n==null?void 0:n.points,u,e,t,o]),O=fr(()=>{if(S.length<2)return dr({x:V,y:w},{x:P,y:F});let G=0;for(let W=0;W<S.length-1;W++)G+=Jt(S[W],S[W+1]);let $=G/2,K=0;for(let W=0;W<S.length-1;W++){let B=Jt(S[W],S[W+1]);if(K+B>=$){let J=($-K)/B,Q=S[W],oe=S[W+1];return{x:Q.x+(oe.x-Q.x)*J,y:Q.y+(oe.y-Q.y)*J}}K+=B}return dr({x:V,y:w},{x:P,y:F})},[S,V,w,P,F]),H=fr(()=>{if(S.length<2){let B=Math.abs(P-V);return Math.abs(F-w)>B?{x:-60,y:0}:{x:0,y:-60}}let $=0;for(let B=0;B<S.length-1;B++)$+=Jt(S[B],S[B+1]);let K=$/2,W=0;for(let B=0;B<S.length-1;B++){let J=Jt(S[B],S[B+1]);if(W+J>=K){let Q=S[B],oe=S[B+1],ue=Math.abs(oe.x-Q.x);return Math.abs(oe.y-Q.y)>ue?{x:-60,y:0}:{x:0,y:-60}}W+=J}return{x:0,y:-60}},[S,V,w,P,F]),z=Nm((G,$)=>{if(f!=="edit"||$.button!==0)return;$.stopPropagation(),$.preventDefault();let K=S[G],W=S[G+1],B=mi(K,W,"y"),J=B?K.y:K.x,Q=[...S],oe=Q.length,ue=G,le=G+1;y(G);let ce=xe=>{let Te=J+(B?xe.clientY-$.clientY:xe.clientX-$.clientX)/c;h.current=B?{x:(K.x+W.x)/2,y:Te}:{x:Te,y:(K.y+W.y)/2};let fe=[];for(let se=1;se<oe-1;se++){let j=Q[se];se===ue||se===le?B?fe.push({x:j.x,y:Te}):fe.push({x:Te,y:j.y}):fe.push(b({},j))}d(e,v(b({},n),{points:fe}))},ye=()=>{y(null),h.current=null,document.removeEventListener("mousemove",ce),document.removeEventListener("mouseup",ye)};document.addEventListener("mousemove",ce),document.addEventListener("mouseup",ye)},[f,S,c,n,e,d]);if(!C||!L)return null;let Z=pl(S),Y=r||C.selected||L.selected;return ft(El,{children:[ft("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":Y}),onDoubleClick:()=>m(!0),children:[ve(wm,{id:e,path:Z,markerEnd:`url(#${Y?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:k("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||T&&M&&!I,"stroke-green-500":T&&M&&I,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":Y&&!(n!=null&&n.hasError)&&!T})}),r&&!p&&!N&&ve("g",{children:S.slice(0,-1).map((G,$)=>{let K=S[$+1];if($===0||$===S.length-2||Jt(G,K)<Mm)return null;let W=mi(G,K,"y"),B=E===$,J=B&&h.current?h.current:dr(G,K);return ft("g",{children:[ve("line",{x1:G.x,y1:G.y,x2:K.x,y2:K.y,stroke:"transparent",strokeWidth:20/c,className:k("cursor-pointer",{"cursor-ns-resize":W,"cursor-ew-resize":!W}),onMouseDown:Q=>z($,Q)}),ve("circle",{cx:J.x,cy:J.y,r:4/c,fill:B?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),ve("circle",{cx:J.x,cy:J.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:B?.6:.3,className:"pointer-events-none"})]},$)})})]}),ft(Am,{children:[ft("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&&ve("div",{className:"absolute pointer-events-auto",style:{transform:`translate(${H.x}px, ${H.y}px)`},children:ve(qt,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:C,targetNode:L,style:{transform:`scale(${1/c})`}})}),(x||((ne=n==null?void 0:n.label)==null?void 0:ne.trim()))&&ve(Ne,{value:n==null?void 0:n.label,className:k("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":x,"pointer-events-none":!x}),isEditing:x,onBlur:()=>m(!1),onChange:G=>d(e,{label:G.trim()})})]}),r&&!p&&!N&&ft(El,{children:[ve("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${S[0].x}px, ${S[0].y}px)`},children:ft("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[ve("circle",{cx:6/c,cy:6/c,r:4/c,fill:T==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),ve("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:T==="source"?.6:.3,className:"pointer-events-none"}),ve("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:k("pointer-events-auto",{"cursor-move":!T||T!=="source","cursor-not-allowed":T==="source"&&M&&!I,"cursor-grabbing":T==="source"&&(!M||I)}),onMouseDown:G=>D("source",G.nativeEvent)})]})}),ve("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${S[S.length-1].x}px, ${S[S.length-1].y}px)`},children:ft("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[ve("circle",{cx:6/c,cy:6/c,r:4/c,fill:T==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),ve("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:T==="target"?.6:.3,className:"pointer-events-none"}),ve("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:k("pointer-events-auto",{"cursor-move":!T||T!=="target","cursor-not-allowed":T==="target"&&M&&!I,"cursor-grabbing":T==="target"&&(!M||I)}),onMouseDown:G=>D("target",G.nativeEvent)})]})})]})]})]})};import{useDebouncedCallback as wh}from"use-debounce";import{useReactFlow as vh}from"@xyflow/react";import{useCallback as Dc}from"react";var Uo=(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))(Uo||{});import{xml2json as Lm,json2xml as km}from"xml-js";var _l={compact:!0,spaces:4},Dm=e=>e.replaceAll(`
|
|
2
|
+
`,"
");function gr(e,t=_l){if(e)return JSON.parse(Lm(e,v(b({},t),{attributeValueFn:Dm})))}function Tl(e,t=_l){return e?km(e,t):""}var Rm={MIN_WIDTH:36,MIN_HEIGHT:36},Om={MIN_WIDTH:36,MIN_HEIGHT:36},Vm={MIN_WIDTH:56,MIN_HEIGHT:56},$o={MIN_WIDTH:176,MIN_HEIGHT:96},hr={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},de={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},yr={MIN_WIDTH:176,MIN_HEIGHT:64},Hm={MIN_WIDTH:128,MIN_HEIGHT:64},te={START_EVENT:Rm,END_EVENT:Om,GATEWAY:Vm,TASK:$o,LANE:de,ANNOTATION:yr,UNSUPPORTED:Hm};var Nl={"attribute-loop":"LOOP"},vl={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS"},wl={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Al={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed"},Il={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var to=(e,t,o)=>{let n=e._attributes.width||0,r=e._attributes.height||0,i=nt(Number(n),t),a=nt(Number(r),o);return{width:i,height:a,measured:{width:i,height:a}}},oo=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,parent:r,value:i}=t,a={x:Number(o._attributes.x||0),y:Number(o._attributes.y||0)},s={id:n,position:a,data:{label:i||""}},l=r==="1"?void 0:r;return l&&(s.parentId=l),s},Bm=e=>{let{mxGeometry:t}=e,o=oo(e),n=to(t,te.START_EVENT.MIN_WIDTH,te.START_EVENT.MIN_HEIGHT);return v(b(b({},o),n),{type:"START_EVENT"})},zm=e=>{let{mxGeometry:t}=e,o=oo(e),n=to(t,te.END_EVENT.MIN_WIDTH,te.END_EVENT.MIN_HEIGHT);return v(b(b({},o),n),{type:"END_EVENT"})},gi=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=oo(e),i=to(n,te.TASK.MIN_WIDTH,te.TASK.MIN_HEIGHT),a=t==null?void 0:t.find(l=>{let{parent:c}=l._attributes;return c===e._attributes.id});if(a){let{style:l}=a._attributes,c=Nl[l];c&&(r.data.attribute=c)}let s=vl[o.style];return s&&(r.data.variant=s),v(b(b({},r),i),{type:"TASK"})},hi=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=oo(e),i=to(o,te.GATEWAY.MIN_WIDTH,te.GATEWAY.MIN_HEIGHT);return r.data.variant=wl[n],v(b(b({},r),i),{type:"GATEWAY"})},Fm=e=>{let{mxGeometry:t}=e,o=oo(e),n=to(t,te.ANNOTATION.MIN_WIDTH,te.ANNOTATION.MIN_HEIGHT);return v(b(b({},o),n),{type:"ANNOTATION"})},Wm=e=>{let{mxGeometry:t}=e,o=oo(e),n=to(t,te.LANE.MIN_WIDTH,te.LANE.MIN_HEIGHT);return v(b(b({},o),n),{type:"LANE"})},Cl={task:gi,"task-script":gi,"subprocess-collapsed":gi,"start-event":Bm,"end-event-terminate":zm,"gateway-parallel":hi,"gateway-exclusive":hi,"gateway-complex":hi,annotation:Fm,lane:Wm},Ym=e=>{if(e&&Array.isArray(e))return e.map(t=>({x:Number(t._attributes.x),y:Number(t._attributes.y)}))},Sl=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,source:r,target:i,value:a,style:s}=t,l=Ym(o==null?void 0:o.Array),c={id:n,source:r,target:i,data:b({label:a||""},l&&l.length>0?{points:l}:{})};return s.includes("association")&&s.includes('endArrow=""')?b(b({},Zt),c):b(b({},Ue),c)},Ml=(e,t)=>{let{id:o,type:n,source:r,target:i,data:a}=e,s=t==null?void 0:t.find(u=>u.id===r),l="";n==="ANNOTATION_EDGE"&&(l='association;endArrow=""');let c={_attributes:{as:"geometry",relative:"1"}};return a!=null&&a.points&&Array.isArray(a.points)&&a.points.length>0&&(c.Array=a.points.map(u=>({_attributes:{as:"mxPoint",x:u.x,y:u.y}}))),{_attributes:{id:o,parent:(s==null?void 0:s.parentId)||"1",edge:"1",style:l,source:r,target:i,value:(a==null?void 0:a.label)||""},mxGeometry:c}},no=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}}}},Um=e=>{let{variant:t}=e.data,o=no(e);return v(b({},o),{_attributes:v(b({},o._attributes),{style:Al[t]||"task"})})},$m=e=>{let t=no(e);return v(b({},t),{_attributes:v(b({},t._attributes),{style:"start-event"})})},Xm=e=>{let t=no(e);return v(b({},t),{_attributes:v(b({},t._attributes),{style:"end-event-terminate"})})},Km=e=>{let{variant:t}=e.data,o=no(e);return v(b({},o),{_attributes:v(b({},o._attributes),{style:Il[t]})})},qm=e=>{let t=no(e);return v(b({},t),{_attributes:v(b({},t._attributes),{style:"lane"})})},Zm=e=>{let t=no(e);return v(b({},t),{_attributes:v(b({},t._attributes),{style:"annotation"})})},Pl={TASK:Um,START_EVENT:$m,END_EVENT:Xm,GATEWAY:Km,ANNOTATION:Zm,LANE:qm},Ll=(e,t)=>{var a,s;let r=((a=e.measured)==null?void 0:a.width)||0,i=((s=e.measured)==null?void 0:s.height)||0;return{_attributes:{id:`${t+1}`,parent:e.id,style:"attribute-loop",connectable:"0"},mxGeometry:{_attributes:{as:"geometry",x:r/2-22/2,y:i-22,width:22,height:22}}}};import Rl from"@dagrejs/dagre";import{getNodesBounds as eg}from"@xyflow/react";import{orderBy as tg}from"lodash";import{orderBy as Jm}from"lodash";var tt=e=>{var t,o,n,r,i,a,s,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(r=(n=e.internals)==null?void 0:n.positionAbsolute.y)!=null?r:0,w:(a=(i=e.measured)==null?void 0:i.width)!=null?a:0,h:(l=(s=e.measured)==null?void 0:s.height)!=null?l:0}},Pt=e=>Jm(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),kl=(e,t)=>{let{x:o,y:n}=tt(e),{x:r,y:i}=tt(t);return{x:o-r,y:n-i}};var ro=({parentId:e,nodes:t,includeTypes:o=[...Object.values(ee)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),Qm=(e,t)=>{let{x:o,y:n}=tt(e),{x:r,y:i}=tt(t),a=o-r,s=n-i;return Math.sqrt(a*a+s*s)},jm=(e,t)=>{let{x:o,y:n,w:r,h:i}=tt(e),{x:a,y:s,w:l,h:c}=tt(t);return o<a+l&&a<o+r&&n<s+c&&s<n+i},Xo=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&jm(e,r)){let i=Qm(e,r);i<n&&(n=i,o=r)}return o},Dl=(e,t)=>t.filter(o=>o.parentId===e).reduce((o,n)=>{var r,i;return Math.max(o,(i=(r=n.measured)==null?void 0:r.width)!=null?i:0)},0);var Ol=(e=[],t=[],o="LR")=>{let n=new Rl.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:i,width:a,height:s})=>n.setNode(i,{width:a,height:s})),t.forEach(i=>n.setEdge(i.source,i.target)),Rl.layout(n),{nodes:e.map(i=>{let a=n.node(i.id);return v(b({},i),{position:{x:a.x-i.width/2,y:a.y-i.height/2}})}),edges:t}},Ko=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId),o=[...e];return t.forEach(n=>{o=qo(n.id,o)}),o},qo=(e,t)=>{var f,g;let o=[...t],n=o.find(x=>x.id===e);if(!n)return o;let r=o.filter(x=>x.parentId===e&&x.type==="LANE");if(r.length===0)return o;let i=tg(r,["position.y"]),a=Math.max((g=(f=n.measured)==null?void 0:f.width)!=null?g:0,hr.MIN_WIDTH),s=Dl(e,i)||de.MIN_WIDTH,l=Math.max(a,s),c=a-de.HEADER_WIDTH>=s,d=0,u=0;i.forEach(x=>{var m,E,y,h;o=o.map(_=>_.id===x.id?v(b({},_),{width:c?l-de.HEADER_WIDTH:l,measured:v(b({},_.measured),{width:c?l-de.HEADER_WIDTH:l}),position:{x:de.HEADER_WIDTH,y:d}}):_),d+=(E=(m=x.measured)==null?void 0:m.height)!=null?E:0,u+=(h=(y=x.measured)==null?void 0:y.height)!=null?h:0}),o=o.map(x=>x.id===e?v(b({},x),{height:u,width:c?l:l+de.HEADER_WIDTH,measured:v(b({},x.measured),{height:u,width:c?l:l+de.HEADER_WIDTH})}):x);let p=o.find(x=>x.id===e);return p!=null&&p.parentId&&(o=qo(p.parentId,o)),o},Vl=(e,t,o)=>{if(e.type==="LANE")return o;let n=De(t),r=De(e);return r.y<n.y&&(e.position.y=0),r.x<n.x+de.HEADER_WIDTH&&(e.position.x=de.HEADER_WIDTH),r.y2>n.y2&&(t.height=r.y2-n.y,t.measured.height=r.y2-n.y),r.x2>n.x2&&(t.width=r.x2-n.x,t.measured.width=r.x2-n.x),o=o.map(i=>i.id===t.id?v(b({},i),{height:t.height,width:t.width,measured:t.measured}):i.id===e.id?v(b({},i),{position:e.position}):i),o},Hl=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},og=50,Gl=(e,t=og)=>{let o=eg(e);return{x:o.x-t,y:o.y-t,width:o.width+t*2,height:o.height+t*2}};var Zo=1,Bl=e=>`<mxGraphModel>
|
|
3
3
|
<root version="1.1">
|
|
4
4
|
<mxCell id="0" />
|
|
5
5
|
<mxCell id="1" parent="0" />
|
|
@@ -14,7 +14,7 @@ var Wd=Object.defineProperty,Yd=Object.defineProperties;var Ud=Object.getOwnProp
|
|
|
14
14
|
<mxCell
|
|
15
15
|
id="3"
|
|
16
16
|
parent="1"
|
|
17
|
-
value="
|
|
17
|
+
value="${e("editor.toolbar.initial_task")}"
|
|
18
18
|
vertex="1"
|
|
19
19
|
style="task"
|
|
20
20
|
>
|
|
@@ -32,9 +32,9 @@ var Wd=Object.defineProperty,Yd=Object.defineProperties;var Ud=Object.getOwnProp
|
|
|
32
32
|
<mxGeometry as="geometry" relative="1" />
|
|
33
33
|
</mxCell>
|
|
34
34
|
</root>
|
|
35
|
-
</mxGraphModel>`,Hl=(e,t)=>{if(!e.length&&!t.length)return Ko;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var eg=e=>{let t=Object.values(Yo),o=e.filter(i=>{var s;let a=(s=i._attributes)==null?void 0:s.style;return t.includes(a)}),n=e.filter(i=>{var s;let a=(s=i._attributes)==null?void 0:s.style;return["attribute-loop"].includes(a)}),r=[];for(let i of o){let{style:a}=i._attributes,s=wl[a],l=s==null?void 0:s(i,n);if(!l){console.warn(`Node ${a} not supported`);continue}r.push(l)}return r},tg=(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=Al(r),a=t.find(l=>l.id===i.source),s=t.find(l=>l.id===i.target);(a==null?void 0:a.type)==="LANE"||(s==null?void 0:s.type)==="LANE"||n.push(i)}return n},og=(e,t)=>{let o=[];return e.forEach(n=>{var a,s;let r=(s=(a=Cl)[n.type])==null?void 0:s.call(a,n);if(!r){console.warn(`Node ${n.type} not supported`);return}if(o.push(r),n.type==="TASK"&&n.data.attribute==="LOOP"){let l=Sl(n,t);o.push(l)}}),o},ng=(e,t)=>{let o=[];return e.forEach(n=>{let r=Il(n,t);o.push(r)}),o},Gl=(e=[],t=[],o)=>{let n=og(e,o),r=ng(t,e),i={mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}};return El(JSON.stringify(i),{compact:!0,spaces:0})},Bl=async e=>{var s,l,c,d,u;let t=await fr(e),o=((l=(s=t==null?void 0:t.mxGraphModel)==null?void 0:s.root)==null?void 0:l.mxCell)||[],n=Number(((u=(d=(c=t==null?void 0:t.mxGraphModel)==null?void 0:c.root)==null?void 0:d._attributes)==null?void 0:u.lastId)||Ko),r=eg(o),i=tg(o,r);return{nodes:Mt($o(r)),edges:i,lastElementId:n}};import{Position as ql,useConnection as Og,useReactFlow as Vg}from"@xyflow/react";import{Handle as zl,useReactFlow as rg}from"@xyflow/react";import{jsx as Fl}from"react/jsx-runtime";var re=i=>{var a=i,{type:e,position:t,className:o,nodeType:n}=a,r=Xe(a,["type","position","className","nodeType"]);let s=n==="TASK";return Fl(zl,E({type:e,position:t,className:k("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent":s,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent":!s},o)},r))},Ie=s=>{var l=s,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,a=Xe(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=rg(),p=(()=>{if(n!=="source")return!1;let m=c();if(t==="TASK")return m.filter(g=>g.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return m.filter(g=>g.source===e).length>=2;if(t==="START_EVENT"){let h=d();return m.filter(f=>{if(f.source!==e)return!1;let y=h.find(x=>x.id===f.target);return(y==null?void 0:y.type)!=="ANNOTATION"}).length>=1}return!1})();return Fl(zl,E({type:n,position:r,className:k("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":p,"hover:border-grey-500":!p},i),style:{pointerEvents:p?"none":"auto"}},a))};import{NodeResizer as ig,useReactFlow as sg}from"@xyflow/react";import{orderBy as ag}from"lodash";import{jsx as lg}from"react/jsx-runtime";var ro=n=>{var r=n,{nodeId:e,isVisible:t}=r,o=Xe(r,["nodeId","isVisible"]);let{getNode:i,getNodes:a,setNodes:s}=sg(),{isMultipleSelection:l}=W(),c=({width:u,height:p})=>{if(!e)return;let m=i(e);if((m==null?void 0:m.type)!=="LANE")return;let h=[...a()],g=!m.parentId,f=g?m.id:m.parentId,y=h.filter(b=>b.type==="LANE"&&b.parentId===f);if(!y.length)return;let x=ag(y,["position.y"]),_=0;x.forEach((b,T)=>{var P,R;let v=T===x.length-1,N=(R=(P=b.measured)==null?void 0:P.height)!=null?R:0;h=h.map(I=>{if(I.id===b.id){let A=g?u-de.HEADER_WIDTH:u,L=w(E({},I),{width:A,measured:w(E({},I.measured),{width:A}),position:w(E({},I.position),{y:_})});return v&&g&&(L.height=p-_),L}return I}),_+=N}),h=h.map(b=>{if(b.id===f){let T=g?u:u+de.HEADER_WIDTH;return w(E({},b),{width:T,height:g?p:_,measured:{width:T,height:g?p:_}})}return b}),s(h)};return lg(ig,E({nodeId:e,handleClassName:"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]",lineClassName:"border-blue-400/90 border-dashed",isVisible:!l&&t,onResizeEnd:(u,p)=>c(p)},o))};import{NodeToolbar as Ag,useReactFlow as Ig}from"@xyflow/react";import{Button as Cg,Tooltip as Sg,TooltipContent as Mg,TooltipTrigger as Pg,useTranslation as Lg}from"lecom-ui";import{useCallback as kg,useRef as Xl,useState as Dg}from"react";import{create as cg}from"zustand";var io=cg(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{useEffect as dg,useState as ug}from"react";var Wl=(e,t=!1)=>{let[o,n]=ug({width:0,height:0});return dg(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};import{Position as qo,useReactFlow as pg}from"@xyflow/react";import{useMemo as fg}from"react";var mg=120,gg=12,Yl=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=pg(),{instanceId:i}=W();return fg(()=>{var m,h;if(!t)return{position:qo.Right,align:"start"};let a=n(e);if(!a)return{position:qo.Right,align:"start"};let s=r(),l=a.position.x*s.zoom+s.x,c=(((m=a.measured)==null?void 0:m.width)||a.width||100)*s.zoom,d=(h=document.getElementById(`modeler-${i}`))==null?void 0:h.clientWidth;if(!d)return{position:qo.Right,align:"start"};let u=(o==null?void 0:o.width)||mg;return{position:l+c+u+gg>d?qo.Left:qo.Right}},[i,e,t,o,n,r])};import{useNodesData as hg,useReactFlow as yg}from"@xyflow/react";import{Button as Ul,DropdownMenu as xg,DropdownMenuContent as Eg,DropdownMenuGroup as bg,DropdownMenuItem as _g,DropdownMenuLabel as Tg,DropdownMenuTrigger as vg,Tooltip as mi,TooltipContent as gi,TooltipTrigger as hi,useTranslation as Ng}from"lecom-ui";import{WrenchIcon as wg}from"lucide-react";import{jsx as Ce,jsxs as Pt}from"react/jsx-runtime";var $l=({nodeId:e})=>{let{t}=Ng(),{updateNodeData:o,getEdges:n,getNode:r}=yg(),i=hg(e),s=n().filter(m=>m.source===e).some(m=>{let h=r(m.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 Pt(xg,{children:[Pt(mi,{children:[Ce(hi,{asChild:!0,children:Ce(vg,{asChild:!0,children:Ce(Ul,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:Ce(wg,{})})})}),Ce(gi,{color:"black",children:t("bpmn.task.menu.title")})]}),Pt(Eg,{align:"start",className:"w-60 bg-white text-grey-600",children:[Pt(Tg,{className:"flex items-center gap-1",children:[Ce("div",{className:"flex-1 text-sm font-semibold",children:t("bpmn.task.menu.title")}),Ce("div",{className:"flex items-center gap-1",children:Object.entries(fn).map(([u,p])=>{let m=u==="LOOP"&&(s||l),g=(()=>{if(u==="LOOP"&&s)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 Pt(mi,{children:[Ce(hi,{asChild:!0,children:Ce(Ul,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:m,className:k({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===u,"opacity-50 cursor-not-allowed":m}),onClick:m?void 0:()=>d(u),children:Ce(p.icon,{className:"stroke-inherit"})})}),g&&Ce(gi,{color:"black",children:g})]},u)})})]}),Ce(bg,{children:Pt(mi,{children:[Ce(hi,{asChild:!0,children:Pt(_g,{className:k({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50 cursor-not-allowed":s}),disabled:s,onClick:s?void 0:()=>c("SCRIPT"),children:[Ce(pn.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})}),s&&Ce(gi,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};import{jsx as he,jsxs as Kl}from"react/jsx-runtime";var Lt={START_EVENT:{type:"START_EVENT",icon:Eo,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:Ht,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:Eo,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:ln,label:"bpmn.annotation.variant.default"}},Rg={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:Bt,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:zt,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:Gt,label:"bpmn.gateway.variant.complex"}},Le=({nodeId:e,nodeType:t,nodeVariant:o,isChild:n,isVisible:r})=>{let i=Xl(null),a=Xl(null),{t:s}=Lg(),{setDraggableNode:l}=io(),{getEdges:c,getNodes:d}=Ig(),{setIsDragging:u,mode:p}=W(),{dimensions:m}=Wl(i,r),{position:h}=Yl(e,r,m),[g,f]=Dg(void 0),y=d(),x=c(),_=o==="SUBPROCESS",b=kg((M,D)=>{u(!1),l({type:D.type,variant:D.variant,attribute:D.attribute,icon:D.icon}),D.icon&&f(he(D.icon,{})),M.dataTransfer.effectAllowed="move",M.dataTransfer.setData("sourceId",e),a.current&&M.dataTransfer.setDragImage(a.current,10,10),setTimeout(()=>{u(!0)},100)},[e,l,u]),T=[{component:he(rr,{elementId:e})}],v=()=>{if(p==="view")return[];let M=!x.some(D=>{var F;return D.source===e&&((F=y.find(U=>U.id===D.target))==null?void 0:F.type)!=="ANNOTATION"});return[{component:he($t,{nodeId:e,disabled:!M,tooltipMessage:M?void 0:s("editor.toolbar.start_event_limit_reached")})},Lt.TASK,Lt.ANNOTATION,...T]},N=()=>p==="view"?[{component:he(dt,{elementId:e})}]:[{component:he(dt,{elementId:e})},..._?[]:[{component:he($l,{nodeId:e})}],{component:he($t,{nodeId:e})},Lt.TASK,...Object.values(Rg),...T],P=()=>p==="view"?[{component:he(dt,{elementId:e})}]:[{component:he(dt,{elementId:e})},{component:he($t,{nodeId:e})},Lt.TASK,Lt.ANNOTATION,...T],R=()=>p==="view"?[]:[{component:he($t,{nodeId:e})},Lt.ANNOTATION,...T],I=()=>p==="view"?[]:[...n?[]:[Lt.ANNOTATION],...T],A=()=>p==="view"?[]:[{component:he($t,{nodeId:e})},...T],L=()=>p==="view"?[]:[...T],S=(M=>{switch(M){case"START_EVENT":return v();case"TASK":return N();case"GATEWAY":return P();case"END_EVENT":return R();case"LANE":return I();case"ANNOTATION":return A();case"UNSUPPORTED":return L();default:return[]}})(t);if(!(S.length===0||p==="readonly"))return Kl(Ag,{position:h,align:"start",className:"-top-8",isVisible:r,children:[he("div",{ref:i,className:"flex items-center gap-1 px-3 py-2 bg-white rounded-sm shadow-md",children:S.map((M,D)=>{if(M.component)return he("div",{children:M.component},D);let F={sourceNodeType:t,targetNodeType:M.type,sourceNodeId:e,nodes:y,edges:x},U=tl(F),ee={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")},C=U.shouldDisable&&U.reason?ee[U.reason]||s(M.label):s(M.label)||"";return Kl(Sg,{children:[he(Pg,{asChild:!0,children:he(Cg,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!U.shouldDisable,disabled:U.shouldDisable,className:U.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:U.shouldDisable?void 0:V=>b(V,M),children:M.icon&&he(M.icon,{size:16})})}),he(Mg,{color:"black",children:C})]},D)})}),he("div",{ref:a,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:g})]})};import{jsx as Zo,jsxs as Hg}from"react/jsx-runtime";var Zl=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=Vg(),{inProgress:i,fromNode:a}=Og(),{mode:s,isConnecting:l,isDragging:c,isMultipleSelection:d}=W(),u=i&&(a==null?void 0:a.id)!==e,p=h=>{r(e,{label:h})},m=!l&&!c&&!d;return Hg("div",{className:k("relative w-full h-full min-w-44 min-h-16 flex text-grey-400 hover:text-grey-500 bg-transparent 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",{"text-blue-500 hover:text-blue-600 shadow-md":o,"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:[Zo(ve,{value:t.label,className:"m-1 text-grey-600",onChange:p}),Zo(Le,{nodeId:e,nodeType:"ANNOTATION",isVisible:!n&&o&&m}),s==="edit"&&Zo(ro,{minWidth:hr.MIN_WIDTH,minHeight:hr.MIN_HEIGHT,isVisible:!n&&o}),!i&&Zo(re,{type:"source",position:ql.Right}),(!i||u)&&Zo(re,{type:"target",position:ql.Left,className:k({"annotation-handle":u})})]})};import{Position as pt,useConnection as Gg,useReactFlow as Bg}from"@xyflow/react";import{useState as zg}from"react";import{Fragment as Jl,jsx as Ve,jsxs as yi}from"react/jsx-runtime";var Ql=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=Bg(),{inProgress:i,fromNode:a}=Gg(),{isConnecting:s,isDragging:l,isMultipleSelection:c,reconnectingEdgeId:d}=W(),[u,p]=zg(!1),m=i&&(a==null?void 0:a.id)!==e||!!d,h=x=>{r(e,{label:x})},g=()=>{p(!0)},f=()=>{p(!1)},y=!s&&!l&&!c;return yi("div",{className:"relative",onDoubleClick:g,children:[Ve(Ht,{className:k("size-9 hover:stroke-[#d33b3b] transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),Ve("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Ve(ve,{value:t.label,isEditing:u,onBlur:f,onChange:h})}),Ve(Le,{nodeId:e,nodeType:"END_EVENT",isVisible:!n&&o&&y}),(!i||m)&&yi(Jl,{children:[Ve(re,{type:"target",position:pt.Left,id:"left",className:k({"event-handle":m})}),Ve(re,{type:"target",position:pt.Right,id:"right",className:k({"event-handle":m})}),Ve(re,{type:"target",position:pt.Top,id:"top",className:k({"event-handle":m})}),Ve(re,{type:"target",position:pt.Bottom,id:"bottom",className:k({"event-handle":m})})]}),!i&&yi(Jl,{children:[Ve(re,{type:"source",position:pt.Left,id:"left"}),Ve(re,{type:"source",position:pt.Right,id:"right"}),Ve(re,{type:"source",position:pt.Top,id:"top"}),Ve(re,{type:"source",position:pt.Bottom,id:"bottom"})]})]})};import{Position as ft,useConnection as Fg,useReactFlow as Wg}from"@xyflow/react";import{useCallback as Yg,useState as Ug}from"react";import{Fragment as jl,jsx as He,jsxs as xi}from"react/jsx-runtime";var ec=({id:e,data:t,selected:o,dragging:n})=>{let r=$r[t.variant].icon,{updateNodeData:i}=Wg(),{inProgress:a,fromNode:s}=Fg(),{isConnecting:l,isDragging:c,isMultipleSelection:d,reconnectingEdgeId:u}=W(),[p,m]=Ug(!1),h=a&&(s==null?void 0:s.id)!==e||!!u,g=Yg(_=>{i(e,{label:_})},[e,i]),f=()=>{m(!0)},y=()=>{m(!1)},x=!l&&!c&&!d;return xi("div",{className:"relative",onDoubleClick:f,children:[He(r,{className:k("size-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),He("div",{className:"absolute top-14 left-1/2 -translate-x-1/2 max-w-80 w-max",children:He(ve,{value:t.label,isEditing:p,onBlur:y,onChange:g})}),He(Le,{nodeId:e,nodeType:"GATEWAY",isVisible:!n&&o&&x}),(!a||h)&&xi(jl,{children:[He(re,{type:"target",position:ft.Left,id:"left",className:k({"gateway-handle":h})}),He(re,{type:"target",position:ft.Right,id:"right",className:k({"gateway-handle":h})}),He(re,{type:"target",position:ft.Top,id:"top",className:k({"gateway-handle":h})}),He(re,{type:"target",position:ft.Bottom,id:"bottom",className:k({"gateway-handle":h})})]}),!a&&xi(jl,{children:[He(Ie,{type:"source",position:ft.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),He(Ie,{type:"source",position:ft.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),He(Ie,{type:"source",position:ft.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),He(Ie,{type:"source",position:ft.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})};import{useNodesData as wI,useReactFlow as AI}from"@xyflow/react";import{Button as CI,DropdownMenu as SI,DropdownMenuContent as MI,DropdownMenuGroup as PI,DropdownMenuItem as LI,DropdownMenuLabel as kI,DropdownMenuTrigger as DI,Tooltip as RI,TooltipContent as OI,TooltipTrigger as VI,useTranslation as HI}from"lecom-ui";import{WrenchIcon as BI}from"lucide-react";import{jsx as YI,jsxs as UI}from"react/jsx-runtime";import{Position as mt,useConnection as $g,useReactFlow as Xg}from"@xyflow/react";import{useState as Kg}from"react";import{Fragment as tc,jsx as Ge,jsxs as Ei}from"react/jsx-runtime";var oc=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=Xg(),{inProgress:i,fromNode:a}=$g(),{isConnecting:s,isDragging:l,isMultipleSelection:c,reconnectingEdgeId:d}=W(),[u,p]=Kg(!1),m=i&&(a==null?void 0:a.id)!==e||!!d,h=x=>{r(e,{label:x})},g=()=>{p(!0)},f=()=>{p(!1)},y=!s&&!l&&!c;return Ei("div",{className:"relative",onDoubleClick:g,children:[Ge(dn,{className:k("size-9 hover:stroke-[#54890b] transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),Ge("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Ge(ve,{value:t.label,isEditing:u,onBlur:f,onChange:h})}),Ge(Le,{nodeId:e,nodeType:"START_EVENT",isVisible:!n&&o&&y}),(!i||m)&&Ei(tc,{children:[Ge(re,{type:"target",position:mt.Left,id:"left",className:k({"event-handle":m})}),Ge(re,{type:"target",position:mt.Right,id:"right",className:k({"event-handle":m})}),Ge(re,{type:"target",position:mt.Top,id:"top",className:k({"event-handle":m})}),Ge(re,{type:"target",position:mt.Bottom,id:"bottom",className:k({"event-handle":m})})]}),!i&&Ei(tc,{children:[Ge(Ie,{type:"source",position:mt.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),Ge(Ie,{type:"source",position:mt.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),Ge(Ie,{type:"source",position:mt.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),Ge(Ie,{type:"source",position:mt.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};import{Position as gt,useConnection as Jg,useReactFlow as Qg}from"@xyflow/react";import{toast as bi,useTranslation as jg}from"lecom-ui";import{useCallback as cc}from"react";var yr=(e,t)=>{let n=e.filter(i=>i.type==="TASK").map(i=>{var s;let a=(s=i.data)==null?void 0:s.label;if(a&&a.startsWith(`${t} `)){let l=a.match(new RegExp(`^${t} (\\d+)$`));return l?parseInt(l[1],10):0}return 0}).filter(i=>i>0),r=n.length>0?Math.max(...n)+1:1;return`${t} ${r}`},so=(e,t)=>{let n=t.filter(l=>l.type==="TASK").map(l=>{var c;return(c=l.data)==null?void 0:c.label}).filter(Boolean);if(!n.includes(e))return e;let i=e.replace(/\s+\(\d+\)$/,""),a=n.filter(l=>l===i||l.startsWith(`${i} (`)).map(l=>{if(l===i)return 1;let c=l.match(/\s+\((\d+)\)$/);return c?parseInt(c[1],10):0}).filter(l=>l>0),s=2;for(;a.includes(s);)s++;return`${i} (${s})`};import{jsx as nc,jsxs as qg}from"react/jsx-runtime";var rc=e=>qg("svg",w(E({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[nc("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),nc("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as ic}from"react/jsx-runtime";var sc=e=>ic("svg",w(E({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:ic("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 ac,jsxs as Zg}from"react/jsx-runtime";var lc=e=>Zg("svg",w(E({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[ac("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),ac("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{Fragment as xr,jsx as pe,jsxs as Jo}from"react/jsx-runtime";var eh={APROVADO:rc,EM_ANDAMENTO:sc,REJEITADO:lc},_i={APROVADO:"border-green-500 border-[3px] border-solid",EM_ANDAMENTO:"border-turquoise-400 border-[3px] border-solid",REJEITADO:"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)]"},dc=({id:e,data:t,selected:o,dragging:n})=>{let{t:r}=jg(),{updateNodeData:i,getNodes:a}=Qg(),{inProgress:s,fromNode:l}=Jg(),{mode:c,isConnecting:d,isDragging:u,isMultipleSelection:p,onSubprocessValidationClick:m,reconnectingEdgeId:h}=W(),{getTaskStatus:g}=vt(),f=s&&(l==null?void 0:l.id)!==e||!!h,y=cc(B=>{let S=B.trim(),M=t.label||"";if(S===M)return;let D=S,F=a();if(!(S&&S!=="")){D=yr(F,r("bpmn.task.label.prefix")),i(e,{label:D}),bi({variant:"warning",content:Jo(xr,{children:[r("bpmn.task.feedback.label_empty.prefix")," ",pe("strong",{children:D})]})});return}let ee=so(D,F);ee===M||(i(e,{label:ee}),ee!==D&&bi({variant:"warning",content:Jo(xr,{children:[r("bpmn.task.feedback.label_already_exists.prefix")," ",pe("strong",{children:S})," ",r("bpmn.task.feedback.label_already_exists.middle")," ",pe("strong",{children:ee})]})}))},[t.label,a,e,r,i]),x=cc(()=>{bi({variant:"error",content:r("bpmn.task.feedback.invalid_first_character")})},[r]),_=g(e),b=_?eh[_]:null,T=t.variant?pn[t.variant].icon:null,v=t.attribute?fn[t.attribute].icon:null,N=t.variant==="SUBPROCESS",P=T&&!N,R=v||N,I=()=>t.hasError?_i.error:_?_i[_]:_i.default,A=()=>{m==null||m({id:e,type:"sub_process",label:t.label})},L=!d&&!u&&!p;return Jo("div",{className:k("relative w-full h-full min-w-44 min-h-24 flex items-center justify-center bg-white border-2 border-grey-400 hover:border-grey-500 rounded-md hover:shadow-md transition-colors duration-75",I(),{"border-blue-500 hover:border-blue-600 shadow-md":o,"border-red-500 hover:border-red-600 shadow-[0_0_5px_rgba(255,0,0,0.5)]":t.hasError}),children:[pe(ve,{value:t.label,maxLength:60,className:k("m-1",{"py-6":P||R}),onChange:y,onInvalidFirstCharacter:x}),T&&pe("div",{className:k("absolute flex items-center p-1",N?"bottom-0":"top-0 left-0"),children:pe(T,{size:16,className:k(t.hasError?"text-red-500":"text-grey-500",N&&"cursor-pointer"),onClick:N?A:void 0})}),v&&pe("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:pe("div",{className:k("flex items-center w-16 p-1",N?"justify-between":"justify-center"),children:pe(v,{size:16,className:k(t.hasError?"text-red-500":"text-grey-500")})})}),b&&pe("div",{className:"absolute top-0 right-0 flex items-center p-1",children:pe(b,{})}),pe(Le,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant,isVisible:!n&&o&&L}),c==="edit"&&pe(ro,{minWidth:mr.MIN_WIDTH,minHeight:mr.MIN_HEIGHT,isVisible:!n&&o}),(!s||f)&&Jo(xr,{children:[pe(re,{type:"target",position:gt.Left,id:"left",className:k({"task-handle":f})}),pe(re,{type:"target",position:gt.Right,id:"right",className:k({"task-handle":f})}),pe(re,{type:"target",position:gt.Top,id:"top",className:k({"task-handle":f})}),pe(re,{type:"target",position:gt.Bottom,id:"bottom",className:k({"task-handle":f})})]}),!s&&Jo(xr,{children:[pe(Ie,{type:"source",position:gt.Left,id:"left",nodeId:e,nodeType:"TASK"}),pe(Ie,{type:"source",position:gt.Right,id:"right",nodeId:e,nodeType:"TASK"}),pe(Ie,{type:"source",position:gt.Top,id:"top",nodeId:e,nodeType:"TASK"}),pe(Ie,{type:"source",position:gt.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})};import{Position as uc}from"@xyflow/react";import{Fragment as th,jsx as Er,jsxs as oh}from"react/jsx-runtime";var pc=({id:e,data:t,selected:o,dragging:n})=>{let{isConnecting:r,isDragging:i,isMultipleSelection:a}=W(),s=!r&&!i&&!a;return oh(th,{children:[Er("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}),Er(Le,{nodeId:e,nodeType:"UNSUPPORTED",isVisible:!n&&o&&s}),Er(re,{type:"source",position:uc.Right}),Er(re,{type:"target",position:uc.Left})]})};import{BaseEdge as nh,EdgeLabelRenderer as rh,getSmoothStepPath as ih,MarkerType as sh,useInternalNode as fc,useReactFlow as ah,useViewport as lh,Position as ao}from"@xyflow/react";import{useState as ch,useMemo as dh}from"react";import{Fragment as mc,jsx as Be,jsxs as lo}from"react/jsx-runtime";var NS={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:sh.Arrow},data:{label:""}},gc=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{let{zoom:c}=lh(),{updateEdgeData:d}=ah(),{isMultipleSelection:u,mode:p,instanceId:m}=W(),h=p!=="edit",[g,f]=ch(!1),{reconnectingHandle:y,cursorPosition:x,hoveredNodeId:_,reconnectingSide:b,isValidReconnection:T,handleReconnectStart:v}=dr({edgeId:e,source:t,target:o,instanceId:m,isReadOnly:h}),N=fc(t),P=fc(o),{sx:R,sy:I,tx:A,ty:L,sourcePos:B,targetPos:S}=dh(()=>{var ue,le;if(!N||!P)return{sx:0,sy:0,tx:0,ty:0,sourcePos:ao.Left,targetPos:ao.Right};let q=lt(N,P),oe=s?i:q.sourcePos,O=l?a:q.targetPos,K=(ce,ye,xe)=>{var ae,Se,Et,bt,_t,Tt;let{x:Te,y:fe}=ce.internals.positionAbsolute,se=(Et=(Se=(ae=ce.measured)==null?void 0:ae.width)!=null?Se:ce.width)!=null?Et:0,Q=(Tt=(_t=(bt=ce.measured)==null?void 0:bt.height)!=null?_t:ce.height)!=null?Tt:0;switch(ye){case ao.Top:return{x:Te+se*xe,y:fe};case ao.Bottom:return{x:Te+se*xe,y:fe+Q};case ao.Left:return{x:Te,y:fe+Q*xe};case ao.Right:return{x:Te+se,y:fe+Q*xe};default:return{x:Te+se/2,y:fe+Q/2}}},X=(ue=n==null?void 0:n.sourceOffset)!=null?ue:.5,z=(le=n==null?void 0:n.targetOffset)!=null?le:.5,H=N?K(N,oe,X).x:q.sx,Z=N?K(N,oe,X).y:q.sy,J=P?K(P,O,z).x:q.tx,ne=P?K(P,O,z).y:q.ty;return y==="source"&&x?(H=x.x,Z=x.y,b&&(oe=b)):y==="target"&&x&&(J=x.x,ne=x.y,b&&(O=b)),{sx:H,sy:Z,tx:J,ty:ne,sourcePos:oe,targetPos:O}},[N,P,s,l,i,a,y,x,b,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!N||!P)return null;let[M,D,F]=ih({sourceX:R,sourceY:I,targetX:A,targetY:L,sourcePosition:B,targetPosition:S}),U=r||(N==null?void 0:N.selected)||(P==null?void 0:P.selected),ee=U?"sequence-edge-marker-highlighted":"sequence-edge-marker",C=g||(n==null?void 0:n.label.trim().length)>0,V=1/c,Y=()=>{f(!0)},G=()=>{f(!1)},$=q=>{d(e,{label:q.trim()})};return Be(mc,{children:lo("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":U}),onDoubleClick:Y,children:[Be(nh,{id:e,path:M,markerEnd:`url(#${ee})`,strokeDasharray:4,className:k("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||y&&_&&!T,"stroke-green-500":y&&_&&T,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":U&&!(n!=null&&n.hasError)&&!y})}),lo(rh,{children:[lo("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${D}px, ${F}px)`},children:[r&&!u&&Be(Kt,{edgeId:e,edgeType:"MESSAGE_EDGE",style:{transform:`scale(${V})`}}),C&&Be(ve,{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:g,onBlur:G,onChange:$})]}),r&&!u&&!h&&lo(mc,{children:[Be("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${R}px, ${I}px)`},children:lo("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Be("circle",{cx:6/c,cy:6/c,r:4/c,fill:y==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Be("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:y==="source"?.6:.3,className:"pointer-events-none"}),Be("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:k("pointer-events-auto",{"cursor-move":!y||y!=="source","cursor-not-allowed":y==="source"&&_&&!T,"cursor-grabbing":y==="source"&&(!_||T)}),onMouseDown:q=>v("source",q.nativeEvent)})]})}),Be("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${A}px, ${L}px)`},children:lo("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Be("circle",{cx:6/c,cy:6/c,r:4/c,fill:y==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Be("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:y==="target"?.6:.3,className:"pointer-events-none"}),Be("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:k("pointer-events-auto",{"cursor-move":!y||y!=="target","cursor-not-allowed":y==="target"&&_&&!T,"cursor-grabbing":y==="target"&&(!_||T)}),onMouseDown:q=>v("target",q.nativeEvent)})]})})]})]})]})})};import{getStraightPath as uh}from"@xyflow/react";import{jsx as hc,jsxs as ph}from"react/jsx-runtime";var yc=({toX:e,toY:t,fromNode:o})=>{if(!o)return null;let n={id:"connection-target",measured:{width:1,height:1},internals:{positionAbsolute:{x:e,y:t}}},{sx:r,sy:i,tx:a,ty:s}=lt(o,n),[l]=uh({sourceX:r,sourceY:i,targetX:a||e,targetY:s||t});return ph("g",{children:[hc("path",{fill:"none",className:"stroke-2 stroke-grey-400 animated",d:l}),hc("circle",{cx:a||e,cy:s||t,fill:"none",r:4,className:"stroke-2 stroke-grey-500"})]})};import{Position as fh,useReactFlow as mh}from"@xyflow/react";import{orderBy as gh}from"lodash";import{useMemo as xc,useState as hh}from"react";import{Fragment as yh,jsx as kt,jsxs as Ec}from"react/jsx-runtime";var bc=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{let{updateNodeData:i,getNodes:a}=mh(),{mode:s,isConnecting:l,isDragging:c,isMultipleSelection:d}=W(),[u,p]=hh(!1),m=a(),h=!r,g=xc(()=>gh([...m.filter(v=>v.parentId===e&&v.type==="LANE")],"position.y","asc"),[m,e]),f=h?gr.MIN_WIDTH:de.MIN_WIDTH,y=xc(()=>{if(h&&g.length>1){let v=[...g];return v.pop(),v.reduce((P,R)=>{var I,A;return P+((A=(I=R.measured)==null?void 0:I.height)!=null?A:0)},0)+de.MIN_HEIGHT}return de.MIN_HEIGHT},[h,g]),x=v=>{i(e,{label:v})},_=()=>{p(!0)},b=()=>{p(!1)},T=!l&&!c&&!d;return Ec(yh,{children:[Ec("div",{className:k("flex h-full min-h-64 w-full min-w-[50rem] hover:shadow-md bg-white outline outline-2 outline-grey-400",{"outline-offset-2 outline-blue-500 shadow-sm":o}),children:[kt("div",{className:"flex align-items justify-center w-10 border-r-2 border-grey-400",onDoubleClick:_,children:kt("div",{className:k("relative flex-1",{"[writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180":!u}),children:kt(ve,{value:t.label,className:"w-full h-full self-auto",contentClassName:k({"whitespace-nowrap":u}),isEditing:u,onBlur:b,onChange:x})})}),kt("div",{className:"flex-1"})]}),kt(Le,{nodeId:e,nodeType:"LANE",isChild:!h,isVisible:!n&&o&&T}),s==="edit"&&kt(ro,{nodeId:e,minWidth:f,minHeight:y,isVisible:!n&&o}),h&&kt(re,{type:"source",position:fh.Right})]})};var _c={START_EVENT:oc,END_EVENT:Ql,TASK:dc,GATEWAY:ec,ANNOTATION:Zl,LANE:bc,UNSUPPORTED:pc},Tc={SEQUENCE_EDGE:yl,MESSAGE_EDGE:gc,ANNOTATION_EDGE:il},vc="#fafafa",Nc="#bebebe",wc=1,Ac=10,Ic="bottom-left",Cc=.2,Sc=5,co=.5,uo=.4,po=1,Mc={x:0,y:0,zoom:.75},xh=1,Eh=2,Pc=[xh,Eh];import{useReactFlow as bh}from"@xyflow/react";var ze=()=>{let{getEdges:e,getNodes:t}=bh(),{lastElementId:o}=W(),n=()=>{let i=t(),a=e(),s=Hl(i,a);return Math.max(s,o)};return{getLastId:n,getNextId:()=>n()+1}};var fo=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n,fitView:r}=_h(),{getLastId:i}=ze(),{setLastElementId:a}=W(),s=Lc(async(c="")=>{let{nodes:d,edges:u,lastElementId:p}=await Bl(c);o(d),n(u),a(p),r({padding:co,minZoom:uo,maxZoom:po})},[o,n,a,r]),l=Lc((c,d)=>{let u=c||e()||[],p=d||t()||[],m=i();return Gl(u,p,m)},[e,t,i]);return{importFromMxGraph:s,exportToMxGraph:l}};import{useCallback as kc}from"react";var vh=500,br=()=>{let{isInitialized:e,onElementChanges:t}=W(),{exportToMxGraph:o}=fo(),n=Th(()=>{if(!e)return;let a=o();t==null||t(a)},vh),r=kc(a=>{a.every(c=>c.type==="select")||a.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=kc(a=>{a.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var Dc=({setEdges:e})=>{let{getNode:t,getEdges:o,getNodes:n}=wh(),{emitElementChanges:r}=br(),i=Ah(null),{getNextId:a}=ze(),s=Dt(h=>{var _;let g=t(h.source),f=t(h.target);if(!g||!f)return!1;let y={sourceNodeId:g.id,targetNodeId:f.id,sourceNodeType:g.type,targetNodeType:f.type,nodes:n(),edges:o(),reconnectingEdgeId:(_=i.current)!=null?_:void 0};return ci(y).isValid},[t,o,n]),l=Dt(h=>{let g=a(),f=t(h.source),y=t(h.target),x=(y==null?void 0:y.type)==="ANNOTATION"||(f==null?void 0:f.type)==="ANNOTATION"?qt:Ue,_=w(E(E({},h),x),{id:String(g)});e(b=>b.concat(_)),r()},[t,a,e,r]),c=Dt((h,g)=>{i.current=g.id},[]),d=Dt(()=>{i.current=null},[]),u=Dt((h,g)=>{let f=t(g.source),y=t(g.target);if(!f||!y){i.current=null;return}let x={sourceNodeId:f.id,targetNodeId:y.id,sourceNodeType:f.type,targetNodeType:y.type,nodes:n(),edges:o(),reconnectingEdgeId:h.id};if(!ci(x).isValid){i.current=null;return}e(b=>Nh(h,g,b).map(v=>v.id===h.id?w(E({},v),{data:w(E({},v.data),{points:void 0})}):v)),i.current=null,r()},[t,n,o,e,r]),p=Dt(h=>{i.current=h},[]),m=Dt(()=>{i.current=null},[]);return{isValidConnection:s,onConnect:l,onReconnect:u,onReconnectStart:c,onReconnectEnd:d,setReconnectingEdge:p,clearReconnectingEdge:m}};import{useReactFlow as Ih}from"@xyflow/react";import{toast as Ch,useTranslation as Sh}from"lecom-ui";import{useCallback as tn,useRef as Wc,useState as Mh}from"react";var Qo=(e=[])=>e.filter(t=>t.type==="START_EVENT"),Rt=(e=[])=>e.filter(t=>t.type==="END_EVENT"),ht=(e=[])=>e.filter(t=>t.type==="TASK")||[],Rc=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),Oc=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),_r=(e=[])=>e.filter(t=>t.type==="GATEWAY"),Vc=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),Re=(e,t=[])=>t.filter(o=>o.source===e),jo=(e,t=[])=>t.filter(o=>o.target===e),Hc=(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"},Gc=(e,t)=>{let o=Re(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},Bc=e=>e?/\w/g.test(e.trim()):!1,ie=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:[]}},Ze=(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)}},zc=(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 en=[{id:"start_event_not_found",validate:e=>{let t=Qo(e.nodes);return ie({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=Rt(e.nodes);return ie({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Qo(e.nodes),o=t.length===1;if(t.length===0)return ie({isValid:!0});if(!o)return ie({isValid:!1,nodeIds:t.map(i=>i.id)});let n=Re(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(a=>a.id),...n.map(a=>a.target)];return ie({isValid:!1,nodeIds:[...new Set(i)]})}return ie({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=ht(e.nodes),o=Ze(t,n=>Re(n.id,e.edges).length<=2);return ie({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=ht(e.nodes),o=Ze(t,n=>!!n.label&&n.label.trim()!=="");return ie({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=ht(e.nodes),n=Ze(o,r=>!r.label||r.label.length<=60);return ie({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=ht(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 ie({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=_r(e.nodes),o=[],n=[];for(let r of t){let i=Re(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="GATEWAY"&&(o.push(r.id,s.id),n.push(a.id))}}return ie({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Qo(e.nodes),...Rt(e.nodes)],o=[],n=[];for(let r of t){let i=Re(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&(s.type==="START_EVENT"||s.type==="END_EVENT")&&(o.push(r.id,s.id),n.push(a.id))}}return ie({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=Rt(e.nodes),o=[],n=[];for(let r of t){let i=jo(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.source);if(s&&s.type==="TASK"){let l=Re(s.id,e.edges);l.length>1&&(o.push(s.id),l.forEach(c=>n.push(c.id)))}}}return ie({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=Vc(e.nodes),o=Ze(t,r=>Re(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>Re(r,e.edges).map(i=>i.id));return ie({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=ht(e.nodes),o=Ze(t,n=>!n.label||Bc(n.label));return ie({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var a,s;if(!((a=e==null?void 0:e.nodes)!=null&&a.length)||!((s=e==null?void 0:e.edges)!=null&&s.length))return ie({isValid:!0});let t=Rt(e.nodes)[0];if(!t)return ie({isValid:!0});let o=jo(t.id,e.edges);if(!o.length)return ie({isValid:!0});let r=ht(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=Ze(r,l=>!Hc(l.id,e));return ie({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=ht(e.nodes),o=Rt(e.nodes)[0];if(!o)return ie({isValid:!0});let n=t.filter(l=>{let c=jo(l.id,e.edges),d=Re(l.id,e.edges),u=c.some(m=>{var h;return((h=e.nodes.find(g=>g.id===m.source))==null?void 0:h.type)==="START_EVENT"}),p=d.some(m=>{var h;return((h=e.nodes.find(g=>g.id===m.target))==null?void 0:h.type)==="END_EVENT"});return u&&p}),r=jo(o.id,e.edges),i=r.length>1,a=r.map(l=>l.source),s={isValid:n.length===0&&!i,nodeIds:[...n.map(l=>l.id),...i?a:[]]};return ie(s)}},{id:"gateway_flow_to_event",validate:e=>{let t=_r(e.nodes),o=[],n=[];for(let r of t){let i=Re(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="END_EVENT"&&(o.push(r.id,s.id),n.push(a.id))}}return ie({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=_r(e.nodes),o=Ze(t,n=>Re(n.id,e.edges).length>=1);return ie({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Qo(e.nodes),...Rt(e.nodes)],o=[],n=[];for(let r of t){let i=Re(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="GATEWAY"&&(o.push(r.id,s.id),n.push(a.id))}}return ie({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=Rc(e.nodes),o=Ze(t,n=>!Gc(n.id,e));return ie({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=Oc(e.nodes),o=Ze(t,n=>{var r,i;return((r=n.properties)==null?void 0:r.subprocessRef)!==void 0&&((i=n.properties)==null?void 0:i.subprocessRef)!==""});return ie({isValid:o.isValid,nodeIds:o.invalidIds})}}];var Fc=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of en){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}};import{jsx as Tr,jsxs as Ph}from"react/jsx-runtime";var Yc=()=>{let{t:e}=Sh(),{setNodes:t,setEdges:o,getNodes:n,getEdges:r}=Ih(),[i,a]=Mh(!1),s=Wc(!1),l=Wc(!1),c=tn(h=>{let g=zc(h.nodes,h.edges),f=Fc(g),y=f.errors.map(x=>w(E({},x),{message:e(`validation.errors.${x.id}`)}));return i||a(!0),{isValid:f.isValid,errors:y}},[i,e]),d=tn((h,g=!0)=>{if(g&&h&&Ch({variant:h.isValid?"success":"error",duration:5e3,title:h.isValid?e("validation.success.title"):e("validation.errors.title"),content:Ph("div",{className:"flex flex-col gap-1",children:[!h.isValid&&Tr("span",{className:"body-small-500",children:e("validation.errors.subtitle")}),Tr("ul",{className:"list-disc list-inside max-h-40 overflow-y-auto",children:h.isValid?Tr("li",{children:e("validation.success.message")}):h.errors.map(I=>Tr("li",{className:"text-xs",children:I.message},I.id))})]})}),!h)return;s.current=!0,l.current=!0;let f=[],y=[];h.errors.forEach(I=>{I.nodeIds&&I.nodeIds.length>0&&I.nodeIds.forEach(A=>f.push(A)),I.edgeIds&&I.edgeIds.length>0&&I.edgeIds.forEach(A=>y.push(A))});let x=[...new Set(f)];t(I=>I.map(A=>w(E({},A),{data:w(E({},A.data),{hasError:!1})}))),o(I=>I.map(A=>w(E({},A),{data:w(E({},A.data),{hasError:!1})})));let _=n(),b=r(),T=new Set(x),v=new Set;h.errors.forEach(I=>{var B,S;let A=en.find(M=>M.id===I.id);(A==null?void 0:A.highlightRelatedEdges)!==!1&&((B=I.edgeIds)==null||B.forEach(M=>v.add(M)),(S=I.nodeIds)==null||S.forEach(M=>{b.forEach(D=>{(D.source===M||D.target===M)&&v.add(D.id)})}))});let N=new Set,P=new Set,R=new Set;_.forEach(I=>{I.type==="START_EVENT"?N.add(I.id):I.type==="END_EVENT"&&P.add(I.id)}),b.forEach(I=>{N.has(I.source)&&R.add(I.target),P.has(I.target)&&R.add(I.source)}),R.forEach(I=>{var A,L;if(T.has(I)){let B=(A=h.errors.find(M=>{var D;return(D=M.nodeIds)==null?void 0:D.includes(I)}))==null?void 0:A.id;((L=en.find(M=>M.id===B))==null?void 0:L.highlightRelatedEdges)!==!1&&b.forEach(M=>{M.source===I&&P.has(M.target)&&(T.add(M.target),v.add(M.id)),M.target===I&&N.has(M.source)&&(T.add(M.source),v.add(M.id))})}}),T.size>0&&t(I=>I.map(A=>w(E({},A),{data:w(E({},A.data),{hasError:T.has(A.id)})}))),v.size>0&&o(I=>I.map(A=>w(E({},A),{data:w(E({},A.data),{hasError:v.has(A.id)})}))),setTimeout(()=>{s.current=!1},0)},[e,r,n,o,t]),u=tn(()=>{a(!1),l.current=!1,t(h=>h.map(g=>w(E({},g),{data:w(E({},g.data),{hasError:!1})}))),o(h=>h.map(g=>w(E({},g),{data:w(E({},g.data),{hasError:!1})})))},[o,t]),p=tn(()=>{l.current&&(s.current=!0,l.current=!1,t(h=>h.map(g=>w(E({},g),{data:w(E({},g.data),{hasError:!1})}))),o(h=>h.map(g=>w(E({},g),{data:w(E({},g.data),{hasError:!1})}))),setTimeout(()=>{s.current=!1},0))},[o,t]),m=tn(()=>s.current,[]);return{validateDiagram:c,handleValidationComplete:d,clearValidation:u,dismissValidationPanel:p,isAutoValidationEnabled:i,getIsClearingValidation:m}};import{useReactFlow as Lh}from"@xyflow/react";import{useTranslation as kh}from"lecom-ui";import{useEffect as Dh}from"react";var Rh=15,Uc="bpmn:selection",Oh=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},$c=e=>{if(!Oh(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},Xc=({offset:e=Rh}={})=>{let{t}=kh(),{getNodes:o,setNodes:n,getEdges:r,setEdges:i}=Lh(),{getNextId:a}=ze();Dh(()=>{let s=c=>{var f,y;if(!$c(c))return;let d=o(),u=r(),p=d.filter(x=>x.selected);if(!p.length)return;c.preventDefault(),c.stopPropagation();let m=u.filter(x=>p.some(_=>_.id===x.source)&&p.some(_=>_.id===x.target)),g=JSON.stringify({nodes:p,edges:m});(f=c.clipboardData)==null||f.setData(Uc,g),(y=c.clipboardData)==null||y.setData("text/plain",`BPMN Selection: ${p.length} nodes`)},l=c=>{var T,v;if(!$c(c))return;let d=(T=c.clipboardData)==null?void 0:T.getData(Uc);if(!d)return;c.preventDefault(),c.stopPropagation();let u;try{u=JSON.parse(d)}catch(N){return}if(!((v=u.nodes)!=null&&v.length))return;let p=new Map,m=o(),h=[],g=m.some(N=>N.type==="START_EVENT"),f=u.nodes.filter(N=>N.type==="START_EVENT"),y=u.nodes;if(g&&f.length>0&&(y=u.nodes.filter(N=>N.type!=="START_EVENT"),y.length===0))return;let x=a(),_=y.map(N=>{var I;let P=String(x++);p.set(N.id,P);let R=w(E({},N),{id:P,selected:!0,position:{x:N.position.x+e,y:N.position.y+e}});if(N.type==="TASK"){let A=(I=N.data)==null?void 0:I.label,L=so(A||t("bpmn.task.label.prefix"),[...m,...h]);R.data=w(E({},N.data),{label:L})}return h.push(R),R}),b=u.edges.map(N=>w(E({},N),{id:String(x++),selected:!0,source:p.get(N.source)||N.source,target:p.get(N.target)||N.target}));n(N=>[...N.map(P=>w(E({},P),{selected:!1})),..._]),i(N=>[...N.map(P=>w(E({},P),{selected:!1})),...b])};return document.addEventListener("copy",s,!0),document.addEventListener("paste",l,!0),()=>{document.removeEventListener("copy",s,!0),document.removeEventListener("paste",l,!0)}},[o,n,r,i,a,e,t])};import{useReactFlow as Vh,useStoreApi as Hh}from"@xyflow/react";import{useTranslation as Gh}from"lecom-ui";import{useState as Bh}from"react";var Kc=({nodes:e,setNodes:t,setEdges:o})=>{let n=Hh(),{draggableNode:r,setDraggableNode:i}=io(),{t:a}=Gh(),{getInternalNode:s,screenToFlowPosition:l}=Vh(),{getNextId:c}=ze(),{setIsDragging:d}=W(),{rebuildIndex:u,forceRebuildIndex:p}=Un(),[m,h]=Bh(null),g=(A,L=!1)=>{let B=L?"[&>div]:bg-red-50 [&>div]:outline [&>div]:outline-[3px] [&>div]:outline-red-500":"[&>div]:bg-green-50/75 [&>div]:outline [&>div]:outline-[3px] [&>div]:outline-green-500";t(S=>S.map(M=>w(E({},M),{className:M.id===A?B:""})))},f=()=>{let{nodeLookup:A}=n.getState();return Array.from(A.values())},y=A=>{let L=s(A.id),B=f();if(A.type==="LANE"){if(no({parentId:A.id,nodes:e,includeTypes:["LANE"]})){g();return}let ee=B.filter(Y=>Y.id!==A.id&&Y.type==="LANE"&&!Y.parentId),C=Uo(L,ee);if(!C){g();return}if(no({parentId:C.id,nodes:e,excludeTypes:["LANE"]})){g(C.id,!0);return}g(C.id);return}let M=B.filter(U=>U.id!==A.id&&U.type==="LANE"),D=Uo(L,M);if(!D){g();return}if(no({parentId:D.id,nodes:e,includeTypes:["LANE"]})){g();return}g(D.id)},x=A=>A.map(L=>w(E({},L),{className:void 0})),_=A=>A.some(B=>B.dragging)?A.map(B=>B.dragging?w(E({},B),{dragging:!1}):B):A,b=A=>{A.preventDefault(),A.dataTransfer.dropEffect="move"},T=(A,L)=>{A.preventDefault(),y(L)},v=(A,L,B)=>{var U,ee;let S=[...B];if(A.parentId===L.id)return S=Dl(A,L,S),S=$o(S),x(S);if(A.type==="LANE"){if(no({parentId:L.id,nodes:S,excludeTypes:["LANE"]})){let $=De(L),q=50,oe=50;return S.map(O=>{var K,X;return O.id===A.id?w(E({},O),{position:{x:(K=m==null?void 0:m.x)!=null?K:$.x+q,y:(X=m==null?void 0:m.y)!=null?X:$.y2+oe}}):O})}let Y=S.filter($=>$.parentId===L.id).reduce(($,q)=>{var oe,O;return $+((O=(oe=q.measured)==null?void 0:oe.height)!=null?O:0)},0),G={x:de.HEADER_WIDTH,y:Y};return S=S.map($=>$.id===A.id?w(E({},$),{parentId:L.id,position:G,className:void 0}):w(E({},$),{className:void 0})),S=Xo(L.id,S),S}if(no({parentId:L.id,nodes:S,includeTypes:["LANE"]})){let C;if(A.parentId){let V=s(A.parentId),{x:Y,y:G}=et(V);C={x:Y+((U=A.position.x)!=null?U:0),y:G+((ee=A.position.y)!=null?ee:0)}}return S=S.map(V=>V.id===A.id?w(E({},V),{position:C!=null?C:V.position,parentId:void 0,className:void 0}):w(E({},V),{className:void 0})),S}let F=Ml(A,L);return S=S.map(C=>{if(C.id===A.id){let V=De(A),Y=De(L);return V.y<Y.y&&(F.y=0),V.x<Y.x+de.HEADER_WIDTH&&(F.x=de.HEADER_WIDTH),w(E({},C),{parentId:L.id,position:F,className:void 0})}return w(E({},C),{className:void 0})}),S=$o(S),S},N=A=>{if(A.preventDefault(),!(r!=null&&r.type))return;let L=l({x:A.clientX,y:A.clientY}),B={width:te[r.type].MIN_WIDTH,height:te[r.type].MIN_HEIGHT},S=c(),M={id:String(S),type:r.type,position:L,measured:B,data:{label:r.type==="TASK"?yr(e,a("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},D=w(E({},M),{internals:{positionAbsolute:L}}),F=f(),U=r.type==="LANE",ee=F.filter(G=>U?G.type==="LANE"&&!G.parentId:G.type==="LANE"),C=Uo(D,ee),V=[...e.map(G=>w(E({},G),{selected:!1})),M];C&&(V=v(D,C,V)),V=Mt(V),t(V),p();let Y=A.dataTransfer.getData("sourceId");if(Y){let G={id:String(S+1),source:Y,target:M.id};r.type==="ANNOTATION"?o($=>$.concat(E(E({},G),qt))):o($=>$.concat(E(E({},G),Ue)))}d(!1),i(null)},P=async(A,L,B)=>{let S=[...e];B.forEach(M=>{let D=f(),F=s(M.id),U=M.type==="LANE",ee=D.filter(V=>V.id!==M.id&&(U?V.type==="LANE"&&!V.parentId:V.type==="LANE")),C=Uo(F,ee);if(C){S=v(F,C,S);return}M.parentId&&(S=I(M,S))}),S=_(S),S=Mt(S),S=x(S),t(S),u(S),h(null)},R=(A,L)=>{h({x:L.position.x,y:L.position.y})},I=(A,L)=>{var F,U;let B=s(A.parentId),{x:S,y:M}=et(B),D={x:S+((F=A.position.x)!=null?F:0),y:M+((U=A.position.y)!=null?U:0)};return L=L.map(ee=>ee.id===A.id?w(E({},ee),{position:D,parentId:void 0}):ee),L=Xo(A.parentId,L),L};return{onDragOver:b,onDrop:N,onNodeDrag:T,onNodeDragStart:R,onNodeDragStop:P}};import{useReactFlow as zh}from"@xyflow/react";import{useTranslation as Fh}from"lecom-ui";import{useEffect as Wh}from"react";var Yh=30,Uh=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},$h=e=>!Uh(e.target),qc=({offset:e=Yh}={})=>{let{t}=Fh(),{getNodes:o,setNodes:n,getEdges:r,setEdges:i}=zh(),{getNextId:a}=ze();Wh(()=>{let s=l=>{if(l.ctrlKey&&l.key.toLowerCase()==="d"&&$h(l)){l.preventDefault(),l.stopPropagation();let c=o(),d=r(),u=c.filter(T=>T.selected);if(!u.length)return;let p=new Map,m=[],h=c.some(T=>T.type==="START_EVENT"),g=u.filter(T=>T.type==="START_EVENT"),f=u;if(h&&g.length>0&&(f=u.filter(T=>T.type!=="START_EVENT"),f.length===0))return;let y=d.filter(T=>f.some(v=>v.id===T.source)&&f.some(v=>v.id===T.target)),x=a(),_=f.map(T=>{var P;let v=String(x++);p.set(T.id,v);let N=w(E({},T),{id:v,selected:!0,position:{x:T.position.x+e,y:T.position.y+e}});if(T.type==="TASK"){let R=(P=T.data)==null?void 0:P.label,I=so(R||t("bpmn.task.label.prefix"),[...c,...m]);N.data=w(E({},T.data),{label:I})}return m.push(N),N}),b=y.map(T=>w(E({},T),{id:String(x++),selected:!0,source:p.get(T.source)||T.source,target:p.get(T.target)||T.target}));n(T=>[...T.map(v=>w(E({},v),{selected:!1})),..._]),i(T=>[...T.map(v=>w(E({},v),{selected:!1})),...b])}};return document.addEventListener("keydown",s,!0),()=>{document.removeEventListener("keydown",s,!0)}},[o,n,r,i,a,e,t])};import{useReactFlow as Kh}from"@xyflow/react";var Jc={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},Qc={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},Zc=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],n=e.match(/(\[.*?\])/)||[],r=e.match(/(\{.*?\})/)||[],i=e.match(/(--.*|\|.*?\|)/i)||[],a="",s="",l="";if(o.length){switch(o[1]){case"<start>":a="start-event";break;case"<end>":a="end-event";break}e=e.replace(o[1],"")}return n.length&&(a="task",s=n[1].replace(/\[|\]/g,""),e=e.replace(n[1],"")),r.length&&(a="gateway-exclusive",s=r[1].replace(/\{|\}/g,""),e=e.replace(r[1],"")),a||(a="task",s=e),i.length&&(l=i[1].replace(/(\||--)/g,""),e=e.replace(i[1],"")),e=e.trim(),t[e]||(t[e]={type:a,label:s}),{step:e,type:a,label:s,edgeLabel:l}},Xh=e=>{e=e||"";let t=e.trim().split(`
|
|
36
|
-
`),o={},n=[];return t.forEach(r=>{r=r||"";let i=r.trim().split("-->");if(i.length!==2){console.warn("Invalid number of steps");return}let a=
|
|
37
|
-
`),i=encodeURI(r);
|
|
35
|
+
</mxGraphModel>`,zl=(e,t)=>{if(!e.length&&!t.length)return Zo;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var ng=e=>{let t=Object.values(Uo),o=e.filter(i=>{var s;let a=(s=i._attributes)==null?void 0:s.style;return t.includes(a)}),n=e.filter(i=>{var s;let a=(s=i._attributes)==null?void 0:s.style;return["attribute-loop"].includes(a)}),r=[];for(let i of o){let{style:a}=i._attributes,s=Cl[a],l=s==null?void 0:s(i,n);if(!l){console.warn(`Node ${a} not supported`);continue}r.push(l)}return r},rg=(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=Sl(r),a=t.find(l=>l.id===i.source),s=t.find(l=>l.id===i.target);(a==null?void 0:a.type)==="LANE"||(s==null?void 0:s.type)==="LANE"||n.push(i)}return n},ig=(e,t)=>{let o=[];return e.forEach(n=>{var a,s;let r=(s=(a=Pl)[n.type])==null?void 0:s.call(a,n);if(!r){console.warn(`Node ${n.type} not supported`);return}if(o.push(r),n.type==="TASK"&&n.data.attribute==="LOOP"){let l=Ll(n,t);o.push(l)}}),o},sg=(e,t)=>{let o=[];return e.forEach(n=>{let r=Ml(n,t);o.push(r)}),o},Fl=(e=[],t=[],o)=>{let n=ig(e,o),r=sg(t,e),i={mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}};return Tl(JSON.stringify(i),{compact:!0,spaces:0})},Wl=async e=>{var s,l,c,d,u;let t=await gr(e),o=((l=(s=t==null?void 0:t.mxGraphModel)==null?void 0:s.root)==null?void 0:l.mxCell)||[],n=Number(((u=(d=(c=t==null?void 0:t.mxGraphModel)==null?void 0:c.root)==null?void 0:d._attributes)==null?void 0:u.lastId)||Zo),r=ng(o),i=rg(o,r);return{nodes:Pt(Ko(r)),edges:i,lastElementId:n}};import{Position as Ql,useConnection as Gg,useReactFlow as Bg}from"@xyflow/react";import{Handle as Yl,useReactFlow as ag}from"@xyflow/react";import{jsx as Ul}from"react/jsx-runtime";var re=i=>{var a=i,{type:e,position:t,className:o,nodeType:n}=a,r=Xe(a,["type","position","className","nodeType"]);let s=n==="TASK";return Ul(Yl,b({type:e,position:t,className:k("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent":s,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent":!s},o)},r))},Ce=s=>{var l=s,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,a=Xe(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=ag(),p=(()=>{if(n!=="source")return!1;let f=c();if(t==="TASK")return f.filter(x=>x.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return f.filter(x=>x.source===e).length>=2;if(t==="START_EVENT"){let g=d();return f.filter(m=>{if(m.source!==e)return!1;let E=g.find(y=>y.id===m.target);return(E==null?void 0:E.type)!=="ANNOTATION"}).length>=1}return!1})();return Ul(Yl,b({type:n,position:r,className:k("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":p,"hover:border-grey-500":!p},i),style:{pointerEvents:p?"none":"auto"}},a))};import{NodeResizer as lg,useReactFlow as cg}from"@xyflow/react";import{orderBy as dg}from"lodash";import{jsx as ug}from"react/jsx-runtime";var io=n=>{var r=n,{nodeId:e,isVisible:t}=r,o=Xe(r,["nodeId","isVisible"]);let{getNode:i,getNodes:a,setNodes:s}=cg(),{isMultipleSelection:l}=U(),c=({width:u,height:p})=>{if(!e)return;let f=i(e);if((f==null?void 0:f.type)!=="LANE")return;let g=[...a()],x=!f.parentId,m=x?f.id:f.parentId,E=g.filter(_=>_.type==="LANE"&&_.parentId===m);if(!E.length)return;let y=dg(E,["position.y"]),h=0;y.forEach((_,N)=>{var M,R;let T=N===y.length-1,A=(R=(M=_.measured)==null?void 0:M.height)!=null?R:0;g=g.map(I=>{if(I.id===_.id){let D=x?u-de.HEADER_WIDTH:u,C=v(b({},I),{width:D,measured:v(b({},I.measured),{width:D}),position:v(b({},I.position),{y:h})});return T&&x&&(C.height=p-h),C}return I}),h+=A}),g=g.map(_=>{if(_.id===m){let N=x?u:u+de.HEADER_WIDTH;return v(b({},_),{width:N,height:x?p:h,measured:{width:N,height:x?p:h}})}return _}),s(g)};return ug(lg,b({nodeId:e,handleClassName:"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]",lineClassName:"border-blue-400/90 border-dashed",isVisible:!l&&t,onResizeEnd:(u,p)=>c(p)},o))};import{NodeToolbar as Sg,useReactFlow as Mg}from"@xyflow/react";import{Button as Pg,Tooltip as Lg,TooltipContent as kg,TooltipTrigger as Dg,useTranslation as Rg}from"lecom-ui";import{useCallback as Og,useRef as Zl,useState as Vg}from"react";import{create as pg}from"zustand";var so=pg(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{useEffect as fg,useState as mg}from"react";var $l=(e,t=!1)=>{let[o,n]=mg({width:0,height:0});return fg(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};import{Position as Jo,useReactFlow as gg}from"@xyflow/react";import{useMemo as hg}from"react";var yg=120,xg=12,Xl=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=gg(),{instanceId:i}=U();return hg(()=>{var f,g;if(!t)return{position:Jo.Right,align:"start"};let a=n(e);if(!a)return{position:Jo.Right,align:"start"};let s=r(),l=a.position.x*s.zoom+s.x,c=(((f=a.measured)==null?void 0:f.width)||a.width||100)*s.zoom,d=(g=document.getElementById(`modeler-${i}`))==null?void 0:g.clientWidth;if(!d)return{position:Jo.Right,align:"start"};let u=(o==null?void 0:o.width)||yg;return{position:l+c+u+xg>d?Jo.Left:Jo.Right}},[i,e,t,o,n,r])};import{useNodesData as Eg,useReactFlow as bg}from"@xyflow/react";import{Button as Kl,DropdownMenu as _g,DropdownMenuContent as Tg,DropdownMenuGroup as Ng,DropdownMenuItem as vg,DropdownMenuLabel as wg,DropdownMenuTrigger as Ag,Tooltip as yi,TooltipContent as xi,TooltipTrigger as Ei,useTranslation as Ig}from"lecom-ui";import{WrenchIcon as Cg}from"lucide-react";import{jsx as we,jsxs as Lt}from"react/jsx-runtime";var ql=({nodeId:e})=>{let{t}=Ig(),{updateNodeData:o,getEdges:n,getNode:r}=bg(),i=Eg(e),s=n().filter(f=>f.source===e).some(f=>{let g=r(f.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 Lt(_g,{children:[Lt(yi,{children:[we(Ei,{asChild:!0,children:we(Ag,{asChild:!0,children:we(Kl,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:we(Cg,{})})})}),we(xi,{color:"black",children:t("bpmn.task.menu.title")})]}),Lt(Tg,{align:"start",className:"w-60 bg-white text-grey-600",children:[Lt(wg,{className:"flex items-center gap-1",children:[we("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),we("div",{className:"flex items-center gap-1",children:Object.entries(hn).map(([u,p])=>{let f=u==="LOOP"&&(s||l),x=(()=>{if(u==="LOOP"&&s)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")})();return Lt(yi,{children:[we(Ei,{asChild:!0,children:we(Kl,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:f,className:k({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===u,"opacity-50 cursor-not-allowed":f}),onClick:f?void 0:()=>d(u),children:we(p.icon,{className:"stroke-inherit"})})}),x&&we(xi,{color:"black",children:x})]},u)})})]}),we(Ng,{children:Lt(yi,{children:[we(Ei,{asChild:!0,children:we("div",{className:k({"cursor-not-allowed":s}),children:Lt(vg,{className:k({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":s}),disabled:s,onClick:()=>c("SCRIPT"),children:[we(gn.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),s&&we(xi,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};import{jsx as he,jsxs as Jl}from"react/jsx-runtime";var kt={START_EVENT:{type:"START_EVENT",icon:bo,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:Gt,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:bo,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:un,label:"bpmn.annotation.variant.default"}},Hg={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:zt,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:Ft,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:Bt,label:"bpmn.gateway.variant.complex"}},Le=({nodeId:e,nodeType:t,nodeVariant:o,isChild:n,isVisible:r})=>{let i=Zl(null),a=Zl(null),{t:s}=Rg(),{setDraggableNode:l}=so(),{getEdges:c,getNodes:d}=Mg(),{setIsDragging:u,mode:p}=U(),{dimensions:f}=$l(i,r),{position:g}=Xl(e,r,f),[x,m]=Vg(void 0),E=d(),y=c(),h=o==="SUBPROCESS",_=Og((w,P)=>{u(!1),l({type:P.type,variant:P.variant,attribute:P.attribute,icon:P.icon}),P.icon&&m(he(P.icon,{})),w.dataTransfer.effectAllowed="move",w.dataTransfer.setData("sourceId",e),a.current&&w.dataTransfer.setDragImage(a.current,10,10),setTimeout(()=>{u(!0)},100)},[e,l,u]),N=[{component:he(sr,{elementId:e})}],T=()=>{if(p==="view")return[];let w=!y.some(P=>{var F;return P.source===e&&((F=E.find(X=>X.id===P.target))==null?void 0:F.type)!=="ANNOTATION"});return[{component:he(Xt,{nodeId:e,disabled:!w,tooltipMessage:w?void 0:s("editor.toolbar.start_event_limit_reached")})},kt.TASK,kt.ANNOTATION,...N]},A=()=>p==="view"?[{component:he(pt,{elementId:e})}]:[{component:he(pt,{elementId:e})},...h?[]:[{component:he(ql,{nodeId:e})}],{component:he(Xt,{nodeId:e})},kt.TASK,...Object.values(Hg),...N],M=()=>p==="view"?[{component:he(pt,{elementId:e})}]:[{component:he(pt,{elementId:e})},{component:he(Xt,{nodeId:e})},kt.TASK,kt.ANNOTATION,...N],R=()=>p==="view"?[]:[{component:he(Xt,{nodeId:e})},kt.ANNOTATION,...N],I=()=>p==="view"?[]:[...n?[]:[kt.ANNOTATION],...N],D=()=>p==="view"?[]:[{component:he(Xt,{nodeId:e})},...N],C=()=>p==="view"?[]:[...N],V=(w=>{switch(w){case"START_EVENT":return T();case"TASK":return A();case"GATEWAY":return M();case"END_EVENT":return R();case"LANE":return I();case"ANNOTATION":return D();case"UNSUPPORTED":return C();default:return[]}})(t);if(!(V.length===0||p==="readonly"))return Jl(Sg,{position:g,align:"start",className:"-top-8",isVisible:r,children:[he("div",{ref:i,className:"flex items-center gap-1 px-3 py-2 bg-white rounded-sm shadow-md",children:V.map((w,P)=>{if(w.component)return he("div",{children:w.component},P);let F={sourceNodeType:t,targetNodeType:w.type,sourceNodeId:e,nodes:E,edges:y},X=rl(F),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")},S=X.shouldDisable&&X.reason?q[X.reason]||s(w.label):s(w.label)||"";return Jl(Lg,{children:[he(Dg,{asChild:!0,children:he(Pg,{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:O=>_(O,w),children:w.icon&&he(w.icon,{size:16})})}),he(kg,{color:"black",children:S})]},P)})}),he("div",{ref:a,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:x})]})};import{jsx as Qo,jsxs as zg}from"react/jsx-runtime";var jl=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=Bg(),{inProgress:i,fromNode:a}=Gg(),{mode:s,isConnecting:l,isDragging:c,isMultipleSelection:d}=U(),u=i&&(a==null?void 0:a.id)!==e,p=g=>{r(e,{label:g})},f=!l&&!c&&!d;return zg("div",{className:k("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",{"text-blue-500 hover:text-blue-600 shadow-md":o,"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:[Qo(Ne,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:p}),Qo(Le,{nodeId:e,nodeType:"ANNOTATION",isVisible:!n&&o&&f}),s==="edit"&&Qo(io,{minWidth:yr.MIN_WIDTH,minHeight:yr.MIN_HEIGHT,isVisible:!n&&o}),!i&&Qo(re,{type:"source",position:Ql.Right}),(!i||u)&&Qo(re,{type:"target",position:Ql.Left,className:k({"annotation-handle":u})})]})};import{Position as mt,useConnection as Fg,useReactFlow as Wg}from"@xyflow/react";import{useState as Yg}from"react";import{Fragment as ec,jsx as Ve,jsxs as bi}from"react/jsx-runtime";var tc=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=Wg(),{inProgress:i,fromNode:a}=Fg(),{isConnecting:s,isDragging:l,isMultipleSelection:c,reconnectingEdgeId:d}=U(),[u,p]=Yg(!1),f=i&&(a==null?void 0:a.id)!==e||!!d,g=y=>{r(e,{label:y})},x=()=>{p(!0)},m=()=>{p(!1)},E=!s&&!l&&!c;return bi("div",{className:"relative",onDoubleClick:x,children:[Ve(Gt,{className:k("size-9 hover:stroke-[#d33b3b] transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),Ve("div",{className:"absolute top-10 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Ve(Ne,{value:t.label,isEditing:u,onBlur:m,onChange:g})}),Ve(Le,{nodeId:e,nodeType:"END_EVENT",isVisible:!n&&o&&E}),(!i||f)&&bi(ec,{children:[Ve(re,{type:"target",position:mt.Left,id:"left",className:k({"event-handle":f})}),Ve(re,{type:"target",position:mt.Right,id:"right",className:k({"event-handle":f})}),Ve(re,{type:"target",position:mt.Top,id:"top",className:k({"event-handle":f})}),Ve(re,{type:"target",position:mt.Bottom,id:"bottom",className:k({"event-handle":f})})]}),!i&&bi(ec,{children:[Ve(re,{type:"source",position:mt.Left,id:"left"}),Ve(re,{type:"source",position:mt.Right,id:"right"}),Ve(re,{type:"source",position:mt.Top,id:"top"}),Ve(re,{type:"source",position:mt.Bottom,id:"bottom"})]})]})};import{Position as gt,useConnection as Ug,useReactFlow as $g}from"@xyflow/react";import{useCallback as Xg,useState as Kg}from"react";import{Fragment as oc,jsx as He,jsxs as _i}from"react/jsx-runtime";var nc=({id:e,data:t,selected:o,dragging:n})=>{let r=Kr[t.variant].icon,{updateNodeData:i}=$g(),{inProgress:a,fromNode:s}=Ug(),{isConnecting:l,isDragging:c,isMultipleSelection:d,reconnectingEdgeId:u}=U(),[p,f]=Kg(!1),g=a&&(s==null?void 0:s.id)!==e||!!u,x=Xg(h=>{i(e,{label:h})},[e,i]),m=()=>{f(!0)},E=()=>{f(!1)},y=!l&&!c&&!d;return _i("div",{className:"relative",onDoubleClick:m,children:[He(r,{className:k("size-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),He("div",{className:"absolute top-14 left-1/2 -translate-x-1/2 max-w-80 w-max",children:He(Ne,{value:t.label,isEditing:p,onBlur:E,onChange:x})}),He(Le,{nodeId:e,nodeType:"GATEWAY",isVisible:!n&&o&&y}),(!a||g)&&_i(oc,{children:[He(re,{type:"target",position:gt.Left,id:"left",className:k({"gateway-handle":g})}),He(re,{type:"target",position:gt.Right,id:"right",className:k({"gateway-handle":g})}),He(re,{type:"target",position:gt.Top,id:"top",className:k({"gateway-handle":g})}),He(re,{type:"target",position:gt.Bottom,id:"bottom",className:k({"gateway-handle":g})})]}),!a&&_i(oc,{children:[He(Ce,{type:"source",position:gt.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),He(Ce,{type:"source",position:gt.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),He(Ce,{type:"source",position:gt.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),He(Ce,{type:"source",position:gt.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})};import{useNodesData as PI,useReactFlow as LI}from"@xyflow/react";import{Button as DI,DropdownMenu as RI,DropdownMenuContent as OI,DropdownMenuGroup as VI,DropdownMenuItem as HI,DropdownMenuLabel as GI,DropdownMenuTrigger as BI,Tooltip as zI,TooltipContent as FI,TooltipTrigger as WI,useTranslation as YI}from"lecom-ui";import{WrenchIcon as $I}from"lucide-react";import{jsx as ZI,jsxs as JI}from"react/jsx-runtime";import{Position as ht,useConnection as qg,useReactFlow as Zg}from"@xyflow/react";import{useState as Jg}from"react";import{Fragment as rc,jsx as Ge,jsxs as Ti}from"react/jsx-runtime";var ic=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=Zg(),{inProgress:i,fromNode:a}=qg(),{isConnecting:s,isDragging:l,isMultipleSelection:c,reconnectingEdgeId:d}=U(),[u,p]=Jg(!1),f=i&&(a==null?void 0:a.id)!==e||!!d,g=y=>{r(e,{label:y})},x=()=>{p(!0)},m=()=>{p(!1)},E=!s&&!l&&!c;return Ti("div",{className:"relative",onDoubleClick:x,children:[Ge(fn,{className:k("size-9 hover:stroke-[#54890b] transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),Ge("div",{className:"absolute top-10 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Ge(Ne,{value:t.label,isEditing:u,onBlur:m,onChange:g})}),Ge(Le,{nodeId:e,nodeType:"START_EVENT",isVisible:!n&&o&&E}),(!i||f)&&Ti(rc,{children:[Ge(re,{type:"target",position:ht.Left,id:"left",className:k({"event-handle":f})}),Ge(re,{type:"target",position:ht.Right,id:"right",className:k({"event-handle":f})}),Ge(re,{type:"target",position:ht.Top,id:"top",className:k({"event-handle":f})}),Ge(re,{type:"target",position:ht.Bottom,id:"bottom",className:k({"event-handle":f})})]}),!i&&Ti(rc,{children:[Ge(Ce,{type:"source",position:ht.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),Ge(Ce,{type:"source",position:ht.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),Ge(Ce,{type:"source",position:ht.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),Ge(Ce,{type:"source",position:ht.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};import{Position as yt,useConnection as eh,useReactFlow as th}from"@xyflow/react";import{toast as Ni,useTranslation as oh}from"lecom-ui";import{useCallback as Er}from"react";var jo=60,xr=(e,t)=>{var a;let o=[],n=`${t} `;for(let s of e){if(!(s.type==="TASK"))continue;let c=(a=s.data)==null?void 0:a.label;if(c&&c.startsWith(n)){let d=c.substring(n.length);/^\d{1,15}$/.test(d)&&o.push(parseInt(d,10))}}let r=o.length>0?Math.max(...o)+1:1,i=`${t} ${r}`;return i.length<=jo?i:i.substring(0,jo).trim()},ao=(e,t)=>{var s;let o=new Set;for(let l of t)l.type==="TASK"&&((s=l.data)!=null&&s.label)&&o.add(l.data.label);let n=e;if(n.length>jo&&(n=n.substring(0,jo).trim()),!o.has(n))return n;let r=n.replace(/\s+\(\d+\)$/,""),i=2,a=o.size+2;for(;i<=a;){let l=` (${i})`,c=jo-l.length,u=`${r.substring(0,c).trim()}${l}`;if(!o.has(u))return u;i++}return n};import{jsx as sc,jsxs as Qg}from"react/jsx-runtime";var ac=e=>Qg("svg",v(b({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[sc("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),sc("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as lc}from"react/jsx-runtime";var cc=e=>lc("svg",v(b({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:lc("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 dc,jsxs as jg}from"react/jsx-runtime";var uc=e=>jg("svg",v(b({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[dc("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),dc("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{Fragment as br,jsx as pe,jsxs as en}from"react/jsx-runtime";var nh={APROVADO:ac,EM_ANDAMENTO:cc,REJEITADO:uc},vi={APROVADO:"border-green-500 border-[3px] border-solid",EM_ANDAMENTO:"border-turquoise-400 border-[3px] border-solid",REJEITADO:"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)]"},pc=({id:e,data:t,selected:o,dragging:n})=>{let{t:r}=oh(),{updateNodeData:i,getNodes:a,setNodes:s}=th(),{inProgress:l,fromNode:c}=eh(),{mode:d,isConnecting:u,isDragging:p,isMultipleSelection:f,onSubprocessValidationClick:g,reconnectingEdgeId:x}=U(),{getTaskStatus:m}=wt(),E=l&&(c==null?void 0:c.id)!==e||!!x,y=Er(P=>{let q=Math.max($o.MIN_WIDTH,P.length*7+48);s(S=>S.map(O=>O.id===e?v(b({},O),{width:q,style:v(b({},O.style),{width:q})}):O))},[e,s]),h=Er(P=>{let F=P.trim(),X=t.label||"";if(F===X)return;let q=F,S=a();if(!(F&&F!=="")){q=xr(S,r("bpmn.task.label.prefix")),i(e,{label:q}),y(q),Ni({variant:"warning",content:en(br,{children:[r("bpmn.task.feedback.label_empty.prefix")," ",pe("strong",{children:q})]})});return}let H=ao(q,S);H===X||(i(e,{label:H}),y(H),H!==q&&Ni({variant:"warning",content:en(br,{children:[r("bpmn.task.feedback.label_already_exists.prefix")," ",pe("strong",{children:F})," ",r("bpmn.task.feedback.label_already_exists.middle")," ",pe("strong",{children:H})]})}))},[t.label,a,e,r,i,y]),_=Er(P=>{y(P)},[y]),N=Er(()=>{Ni({variant:"error",content:r("bpmn.task.feedback.invalid_first_character")})},[r]),T=m(e),A=T?nh[T]:null,M=t.variant?gn[t.variant].icon:null,R=t.attribute?hn[t.attribute].icon:null,I=t.variant==="SUBPROCESS",D=M&&!I,C=R||I,L=()=>t.hasError?vi.error:T?vi[T]:vi.default,V=()=>{g==null||g({id:e,type:"sub_process",label:t.label})},w=!u&&!p&&!f;return en("div",{className:k("relative w-full h-full min-w-44 min-h-24 flex items-center justify-center bg-white border-2 border-grey-400 hover:border-grey-500 rounded-md hover:shadow-md transition-colors duration-75",L(),{"border-blue-500 hover:border-blue-600 shadow-md":o,"border-red-500 hover:border-red-600 shadow-[0_0_5px_rgba(255,0,0,0.5)]":t.hasError}),children:[pe(Ne,{value:t.label,maxLength:60,className:k("m-1",{"py-6":D||C}),onChange:h,onInput:_,onInvalidFirstCharacter:N}),M&&pe("div",{className:k("absolute flex items-center p-1",I?"bottom-0":"top-0 left-0"),children:pe(M,{size:16,className:k(t.hasError?"text-red-500":"text-grey-500",I&&"cursor-pointer"),onClick:I?V:void 0})}),R&&pe("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:pe("div",{className:k("flex items-center w-16 p-1",I?"justify-between":"justify-center"),children:pe(R,{size:16,className:k(t.hasError?"text-red-500":"text-grey-500")})})}),A&&pe("div",{className:"absolute top-0 right-0 flex items-center p-1",children:pe(A,{})}),pe(Le,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant,isVisible:!n&&o&&w}),d==="edit"&&pe(io,{minWidth:$o.MIN_WIDTH,minHeight:$o.MIN_HEIGHT,isVisible:!n&&o}),(!l||E)&&en(br,{children:[pe(re,{type:"target",position:yt.Left,id:"left",className:k({"task-handle":E})}),pe(re,{type:"target",position:yt.Right,id:"right",className:k({"task-handle":E})}),pe(re,{type:"target",position:yt.Top,id:"top",className:k({"task-handle":E})}),pe(re,{type:"target",position:yt.Bottom,id:"bottom",className:k({"task-handle":E})})]}),!l&&en(br,{children:[pe(Ce,{type:"source",position:yt.Left,id:"left",nodeId:e,nodeType:"TASK"}),pe(Ce,{type:"source",position:yt.Right,id:"right",nodeId:e,nodeType:"TASK"}),pe(Ce,{type:"source",position:yt.Top,id:"top",nodeId:e,nodeType:"TASK"}),pe(Ce,{type:"source",position:yt.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})};import{Position as fc}from"@xyflow/react";import{Fragment as rh,jsx as _r,jsxs as ih}from"react/jsx-runtime";var mc=({id:e,data:t,selected:o,dragging:n})=>{let{isConnecting:r,isDragging:i,isMultipleSelection:a}=U(),s=!r&&!i&&!a;return ih(rh,{children:[_r("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}),_r(Le,{nodeId:e,nodeType:"UNSUPPORTED",isVisible:!n&&o&&s}),_r(re,{type:"source",position:fc.Right}),_r(re,{type:"target",position:fc.Left})]})};import{BaseEdge as sh,EdgeLabelRenderer as ah,getSmoothStepPath as lh,MarkerType as ch,useInternalNode as gc,useReactFlow as dh,useViewport as uh,Position as lo}from"@xyflow/react";import{useState as ph,useMemo as fh}from"react";import{Fragment as hc,jsx as Be,jsxs as co}from"react/jsx-runtime";var PS={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:ch.Arrow},data:{label:""}},yc=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{let{zoom:c}=uh(),{updateEdgeData:d}=dh(),{isMultipleSelection:u,mode:p,instanceId:f}=U(),g=p!=="edit",[x,m]=ph(!1),{reconnectingHandle:E,cursorPosition:y,hoveredNodeId:h,reconnectingSide:_,isValidReconnection:N,handleReconnectStart:T}=pr({edgeId:e,source:t,target:o,instanceId:f,isReadOnly:g}),A=gc(t),M=gc(o),{sx:R,sy:I,tx:D,ty:C,sourcePos:L,targetPos:V}=fh(()=>{var ue,le;if(!A||!M)return{sx:0,sy:0,tx:0,ty:0,sourcePos:lo.Left,targetPos:lo.Right};let Y=dt(A,M),ne=s?i:Y.sourcePos,G=l?a:Y.targetPos,$=(ce,ye,xe)=>{var ae,Se,_t,Tt,Nt,vt;let{x:Te,y:fe}=ce.internals.positionAbsolute,se=(_t=(Se=(ae=ce.measured)==null?void 0:ae.width)!=null?Se:ce.width)!=null?_t:0,j=(vt=(Nt=(Tt=ce.measured)==null?void 0:Tt.height)!=null?Nt:ce.height)!=null?vt:0;switch(ye){case lo.Top:return{x:Te+se*xe,y:fe};case lo.Bottom:return{x:Te+se*xe,y:fe+j};case lo.Left:return{x:Te,y:fe+j*xe};case lo.Right:return{x:Te+se,y:fe+j*xe};default:return{x:Te+se/2,y:fe+j/2}}},K=(ue=n==null?void 0:n.sourceOffset)!=null?ue:.5,W=(le=n==null?void 0:n.targetOffset)!=null?le:.5,B=A?$(A,ne,K).x:Y.sx,J=A?$(A,ne,K).y:Y.sy,Q=M?$(M,G,W).x:Y.tx,oe=M?$(M,G,W).y:Y.ty;return E==="source"&&y?(B=y.x,J=y.y,_&&(ne=_)):E==="target"&&y&&(Q=y.x,oe=y.y,_&&(G=_)),{sx:B,sy:J,tx:Q,ty:oe,sourcePos:ne,targetPos:G}},[A,M,s,l,i,a,E,y,_,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!A||!M)return null;let[w,P,F]=lh({sourceX:R,sourceY:I,targetX:D,targetY:C,sourcePosition:L,targetPosition:V}),X=r||(A==null?void 0:A.selected)||(M==null?void 0:M.selected),q=X?"sequence-edge-marker-highlighted":"sequence-edge-marker",S=x||(n==null?void 0:n.label.trim().length)>0,O=1/c,H=()=>{m(!0)},z=()=>{m(!1)},Z=Y=>{d(e,{label:Y.trim()})};return Be(hc,{children:co("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":X}),onDoubleClick:H,children:[Be(sh,{id:e,path:w,markerEnd:`url(#${q})`,strokeDasharray:4,className:k("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||E&&h&&!N,"stroke-green-500":E&&h&&N,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":X&&!(n!=null&&n.hasError)&&!E})}),co(ah,{children:[co("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${P}px, ${F}px)`},children:[r&&!u&&Be(qt,{edgeId:e,edgeType:"MESSAGE_EDGE",style:{transform:`scale(${O})`}}),S&&Be(Ne,{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:z,onChange:Z})]}),r&&!u&&!g&&co(hc,{children:[Be("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${R}px, ${I}px)`},children:co("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Be("circle",{cx:6/c,cy:6/c,r:4/c,fill:E==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Be("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:E==="source"?.6:.3,className:"pointer-events-none"}),Be("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:k("pointer-events-auto",{"cursor-move":!E||E!=="source","cursor-not-allowed":E==="source"&&h&&!N,"cursor-grabbing":E==="source"&&(!h||N)}),onMouseDown:Y=>T("source",Y.nativeEvent)})]})}),Be("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${D}px, ${C}px)`},children:co("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Be("circle",{cx:6/c,cy:6/c,r:4/c,fill:E==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Be("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:E==="target"?.6:.3,className:"pointer-events-none"}),Be("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:k("pointer-events-auto",{"cursor-move":!E||E!=="target","cursor-not-allowed":E==="target"&&h&&!N,"cursor-grabbing":E==="target"&&(!h||N)}),onMouseDown:Y=>T("target",Y.nativeEvent)})]})})]})]})]})})};import{getStraightPath as mh}from"@xyflow/react";import{jsx as xc,jsxs as gh}from"react/jsx-runtime";var Ec=({toX:e,toY:t,fromNode:o})=>{if(!o)return null;let n={id:"connection-target",measured:{width:1,height:1},internals:{positionAbsolute:{x:e,y:t}}},{sx:r,sy:i,tx:a,ty:s}=dt(o,n),[l]=mh({sourceX:r,sourceY:i,targetX:a||e,targetY:s||t});return gh("g",{children:[xc("path",{fill:"none",className:"stroke-2 stroke-grey-400 animated",d:l}),xc("circle",{cx:a||e,cy:s||t,fill:"none",r:4,className:"stroke-2 stroke-grey-500"})]})};import{Position as hh,useReactFlow as yh}from"@xyflow/react";import{orderBy as xh}from"lodash";import{useMemo as bc,useState as Eh}from"react";import{Fragment as bh,jsx as Dt,jsxs as _c}from"react/jsx-runtime";var Tc=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{let{updateNodeData:i,getNodes:a}=yh(),{mode:s,isConnecting:l,isDragging:c,isMultipleSelection:d}=U(),[u,p]=Eh(!1),f=a(),g=!r,x=bc(()=>xh([...f.filter(T=>T.parentId===e&&T.type==="LANE")],"position.y","asc"),[f,e]),m=g?hr.MIN_WIDTH:de.MIN_WIDTH,E=bc(()=>{if(g&&x.length>1){let T=[...x];return T.pop(),T.reduce((M,R)=>{var I,D;return M+((D=(I=R.measured)==null?void 0:I.height)!=null?D:0)},0)+de.MIN_HEIGHT}return de.MIN_HEIGHT},[g,x]),y=T=>{i(e,{label:T})},h=()=>{p(!0)},_=()=>{p(!1)},N=!l&&!c&&!d;return _c(bh,{children:[_c("div",{className:k("flex h-full min-h-64 w-full min-w-[50rem] hover:shadow-md bg-white outline outline-2 outline-grey-400",{"outline-offset-2 outline-blue-500 shadow-sm":o}),children:[Dt("div",{className:"flex align-items justify-center w-10 border-r-2 border-grey-400",onDoubleClick:h,children:Dt("div",{className:k("relative flex-1",{"[writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180":!u}),children:Dt(Ne,{value:t.label,className:"w-full h-full self-auto",contentClassName:k({"whitespace-nowrap":u}),isEditing:u,onBlur:_,onChange:y})})}),Dt("div",{className:"flex-1"})]}),Dt(Le,{nodeId:e,nodeType:"LANE",isChild:!g,isVisible:!n&&o&&N}),s==="edit"&&Dt(io,{nodeId:e,minWidth:m,minHeight:E,isVisible:!n&&o}),g&&Dt(re,{type:"source",position:hh.Right})]})};var Nc={START_EVENT:ic,END_EVENT:tc,TASK:pc,GATEWAY:nc,ANNOTATION:jl,LANE:Tc,UNSUPPORTED:mc},vc={SEQUENCE_EDGE:bl,MESSAGE_EDGE:yc,ANNOTATION_EDGE:ll},wc="#fafafa",Ac="#bebebe",Ic=1,Cc=10,Sc="bottom-left",Mc=.2,Pc=5,uo=.5,po=.4,fo=1,Lc={x:0,y:0,zoom:.75},_h=1,Th=2,kc=[_h,Th];import{useReactFlow as Nh}from"@xyflow/react";var ze=()=>{let{getEdges:e,getNodes:t}=Nh(),{lastElementId:o}=U(),n=()=>{let i=t(),a=e(),s=zl(i,a);return Math.max(s,o)};return{getLastId:n,getNextId:()=>n()+1}};var mo=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n,fitView:r}=vh(),{getLastId:i}=ze(),{setLastElementId:a}=U(),s=Dc(async(c="")=>{let{nodes:d,edges:u,lastElementId:p}=await Wl(c);o(d),n(u),a(p),r({padding:uo,minZoom:po,maxZoom:fo})},[o,n,a,r]),l=Dc((c,d)=>{let u=c||e()||[],p=d||t()||[],f=i();return Fl(u,p,f)},[e,t,i]);return{importFromMxGraph:s,exportToMxGraph:l}};import{useCallback as Rc}from"react";var Ah=500,Tr=()=>{let{isInitialized:e,onElementChanges:t}=U(),{exportToMxGraph:o}=mo(),n=wh(()=>{if(!e)return;let a=o();t==null||t(a)},Ah),r=Rc(a=>{a.every(c=>c.type==="select")||a.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=Rc(a=>{a.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var Oc=({setEdges:e})=>{let{getNode:t,getEdges:o,getNodes:n}=Ch(),{emitElementChanges:r}=Tr(),i=Sh(null),{getNextId:a}=ze(),s=Rt(g=>{var h;let x=t(g.source),m=t(g.target);if(!x||!m)return!1;let E={sourceNodeId:x.id,targetNodeId:m.id,sourceNodeType:x.type,targetNodeType:m.type,nodes:n(),edges:o(),reconnectingEdgeId:(h=i.current)!=null?h:void 0};return pi(E).isValid},[t,o,n]),l=Rt(g=>{let x=a(),m=t(g.source),E=t(g.target),y=(E==null?void 0:E.type)==="ANNOTATION"||(m==null?void 0:m.type)==="ANNOTATION"?Zt:Ue,h=v(b(b({},g),y),{id:String(x)});e(_=>_.concat(h)),r()},[t,a,e,r]),c=Rt((g,x)=>{i.current=x.id},[]),d=Rt(()=>{i.current=null},[]),u=Rt((g,x)=>{let m=t(x.source),E=t(x.target);if(!m||!E){i.current=null;return}let y={sourceNodeId:m.id,targetNodeId:E.id,sourceNodeType:m.type,targetNodeType:E.type,nodes:n(),edges:o(),reconnectingEdgeId:g.id};if(!pi(y).isValid){i.current=null;return}e(_=>Ih(g,x,_).map(T=>T.id===g.id?v(b({},T),{data:v(b({},T.data),{points:void 0})}):T)),i.current=null,r()},[t,n,o,e,r]),p=Rt(g=>{i.current=g},[]),f=Rt(()=>{i.current=null},[]);return{isValidConnection:s,onConnect:l,onReconnect:u,onReconnectStart:c,onReconnectEnd:d,setReconnectingEdge:p,clearReconnectingEdge:f}};import{useReactFlow as Mh}from"@xyflow/react";import{toast as Ph,useTranslation as Lh}from"lecom-ui";import{useCallback as rn,useRef as Uc,useState as kh}from"react";var tn=(e=[])=>e.filter(t=>t.type==="START_EVENT"),Ot=(e=[])=>e.filter(t=>t.type==="END_EVENT"),xt=(e=[])=>e.filter(t=>t.type==="TASK")||[],Vc=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),Hc=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),Nr=(e=[])=>e.filter(t=>t.type==="GATEWAY"),Gc=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),Re=(e,t=[])=>t.filter(o=>o.source===e),on=(e,t=[])=>t.filter(o=>o.target===e),Bc=(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"},zc=(e,t)=>{let o=Re(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},Fc=e=>e?/[^\s]/.test(e.trim()):!1,ie=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:[]}},Je=(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)}},Wc=(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 nn=[{id:"start_event_not_found",validate:e=>{let t=tn(e.nodes);return ie({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=Ot(e.nodes);return ie({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=tn(e.nodes),o=t.length===1;if(t.length===0)return ie({isValid:!0});if(!o)return ie({isValid:!1,nodeIds:t.map(i=>i.id)});let n=Re(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(a=>a.id),...n.map(a=>a.target)];return ie({isValid:!1,nodeIds:[...new Set(i)]})}return ie({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=xt(e.nodes),o=Je(t,n=>Re(n.id,e.edges).length<=2);return ie({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=xt(e.nodes),o=Je(t,n=>!!n.label&&n.label.trim()!=="");return ie({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=xt(e.nodes),n=Je(o,r=>!r.label||r.label.length<=60);return ie({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=xt(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 ie({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=Nr(e.nodes),o=[],n=[];for(let r of t){let i=Re(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="GATEWAY"&&(o.push(r.id,s.id),n.push(a.id))}}return ie({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...tn(e.nodes),...Ot(e.nodes)],o=[],n=[];for(let r of t){let i=Re(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&(s.type==="START_EVENT"||s.type==="END_EVENT")&&(o.push(r.id,s.id),n.push(a.id))}}return ie({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=Ot(e.nodes),o=[],n=[];for(let r of t){let i=on(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.source);if(s&&s.type==="TASK"){let l=Re(s.id,e.edges);l.length>1&&(o.push(s.id),l.forEach(c=>n.push(c.id)))}}}return ie({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=Gc(e.nodes),o=Je(t,r=>Re(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>Re(r,e.edges).map(i=>i.id));return ie({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=xt(e.nodes),o=Je(t,n=>!n.label||Fc(n.label));return ie({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var a,s;if(!((a=e==null?void 0:e.nodes)!=null&&a.length)||!((s=e==null?void 0:e.edges)!=null&&s.length))return ie({isValid:!0});let t=Ot(e.nodes)[0];if(!t)return ie({isValid:!0});let o=on(t.id,e.edges);if(!o.length)return ie({isValid:!0});let r=xt(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=Je(r,l=>!Bc(l.id,e));return ie({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=xt(e.nodes),o=Ot(e.nodes)[0];if(!o)return ie({isValid:!0});let n=t.filter(l=>{let c=on(l.id,e.edges),d=Re(l.id,e.edges),u=c.some(f=>{var g;return((g=e.nodes.find(x=>x.id===f.source))==null?void 0:g.type)==="START_EVENT"}),p=d.some(f=>{var g;return((g=e.nodes.find(x=>x.id===f.target))==null?void 0:g.type)==="END_EVENT"});return u&&p}),r=on(o.id,e.edges),i=r.length>1,a=r.map(l=>l.source),s={isValid:n.length===0&&!i,nodeIds:[...n.map(l=>l.id),...i?a:[]]};return ie(s)}},{id:"gateway_flow_to_event",validate:e=>{let t=Nr(e.nodes),o=[],n=[];for(let r of t){let i=Re(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="END_EVENT"&&(o.push(r.id,s.id),n.push(a.id))}}return ie({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=Nr(e.nodes),o=Je(t,n=>Re(n.id,e.edges).length>=1);return ie({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...tn(e.nodes),...Ot(e.nodes)],o=[],n=[];for(let r of t){let i=Re(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="GATEWAY"&&(o.push(r.id,s.id),n.push(a.id))}}return ie({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=Vc(e.nodes),o=Je(t,n=>!zc(n.id,e));return ie({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=Hc(e.nodes),o=Je(t,n=>{var r,i;return((r=n.properties)==null?void 0:r.subprocessRef)!==void 0&&((i=n.properties)==null?void 0:i.subprocessRef)!==""});return ie({isValid:o.isValid,nodeIds:o.invalidIds})}}];var Yc=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of nn){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}};import{jsx as vr,jsxs as Dh}from"react/jsx-runtime";var $c=()=>{let{t:e}=Lh(),{setNodes:t,setEdges:o,getNodes:n,getEdges:r}=Mh(),[i,a]=kh(!1),s=Uc(!1),l=Uc(!1),c=rn(g=>{let x=Wc(g.nodes,g.edges),m=Yc(x),E=m.errors.map(y=>v(b({},y),{message:e(`validation.errors.${y.id}`)}));return i||a(!0),{isValid:m.isValid,errors:E}},[i,e]),d=rn((g,x=!0)=>{if(x&&g&&Ph({variant:g.isValid?"success":"error",duration:5e3,title:g.isValid?e("validation.success.title"):e("validation.errors.title"),content:Dh("div",{className:"flex flex-col gap-1",children:[!g.isValid&&vr("span",{className:"body-small-500",children:e("validation.errors.subtitle")}),vr("ul",{className:"list-disc list-inside max-h-40 overflow-y-auto",children:g.isValid?vr("li",{children:e("validation.success.message")}):g.errors.map(I=>vr("li",{className:"text-xs",children:I.message},I.id))})]})}),!g)return;s.current=!0,l.current=!0;let m=[],E=[];g.errors.forEach(I=>{I.nodeIds&&I.nodeIds.length>0&&I.nodeIds.forEach(D=>m.push(D)),I.edgeIds&&I.edgeIds.length>0&&I.edgeIds.forEach(D=>E.push(D))});let y=[...new Set(m)];t(I=>I.map(D=>v(b({},D),{data:v(b({},D.data),{hasError:!1})}))),o(I=>I.map(D=>v(b({},D),{data:v(b({},D.data),{hasError:!1})})));let h=n(),_=r(),N=new Set(y),T=new Set;g.errors.forEach(I=>{var L,V;let D=nn.find(w=>w.id===I.id);(D==null?void 0:D.highlightRelatedEdges)!==!1&&((L=I.edgeIds)==null||L.forEach(w=>T.add(w)),(V=I.nodeIds)==null||V.forEach(w=>{_.forEach(P=>{(P.source===w||P.target===w)&&T.add(P.id)})}))});let A=new Set,M=new Set,R=new Set;h.forEach(I=>{I.type==="START_EVENT"?A.add(I.id):I.type==="END_EVENT"&&M.add(I.id)}),_.forEach(I=>{A.has(I.source)&&R.add(I.target),M.has(I.target)&&R.add(I.source)}),R.forEach(I=>{var D,C;if(N.has(I)){let L=(D=g.errors.find(w=>{var P;return(P=w.nodeIds)==null?void 0:P.includes(I)}))==null?void 0:D.id;((C=nn.find(w=>w.id===L))==null?void 0:C.highlightRelatedEdges)!==!1&&_.forEach(w=>{w.source===I&&M.has(w.target)&&(N.add(w.target),T.add(w.id)),w.target===I&&A.has(w.source)&&(N.add(w.source),T.add(w.id))})}}),N.size>0&&t(I=>I.map(D=>v(b({},D),{data:v(b({},D.data),{hasError:N.has(D.id)})}))),T.size>0&&o(I=>I.map(D=>v(b({},D),{data:v(b({},D.data),{hasError:T.has(D.id)})}))),setTimeout(()=>{s.current=!1},0)},[e,r,n,o,t]),u=rn(()=>{a(!1),l.current=!1,t(g=>g.map(x=>v(b({},x),{data:v(b({},x.data),{hasError:!1})}))),o(g=>g.map(x=>v(b({},x),{data:v(b({},x.data),{hasError:!1})})))},[o,t]),p=rn(()=>{l.current&&(s.current=!0,l.current=!1,t(g=>g.map(x=>v(b({},x),{data:v(b({},x.data),{hasError:!1})}))),o(g=>g.map(x=>v(b({},x),{data:v(b({},x.data),{hasError:!1})}))),setTimeout(()=>{s.current=!1},0))},[o,t]),f=rn(()=>s.current,[]);return{validateDiagram:c,handleValidationComplete:d,clearValidation:u,dismissValidationPanel:p,isAutoValidationEnabled:i,getIsClearingValidation:f}};import{useReactFlow as Rh}from"@xyflow/react";import{useTranslation as Oh}from"lecom-ui";import{useEffect as Vh}from"react";var Hh=15,Xc="bpmn:selection",Gh=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},Kc=e=>{if(!Gh(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},qc=({offset:e=Hh}={})=>{let{t}=Oh(),{getNodes:o,setNodes:n,getEdges:r,setEdges:i}=Rh(),{getNextId:a}=ze();Vh(()=>{let s=c=>{var m,E;if(!Kc(c))return;let d=o(),u=r(),p=d.filter(y=>y.selected);if(!p.length)return;c.preventDefault(),c.stopPropagation();let f=u.filter(y=>p.some(h=>h.id===y.source)&&p.some(h=>h.id===y.target)),x=JSON.stringify({nodes:p,edges:f});(m=c.clipboardData)==null||m.setData(Xc,x),(E=c.clipboardData)==null||E.setData("text/plain",`BPMN Selection: ${p.length} nodes`)},l=c=>{var h,_;if(!Kc(c))return;let d=(h=c.clipboardData)==null?void 0:h.getData(Xc);if(!d)return;c.preventDefault(),c.stopPropagation();let u;try{u=JSON.parse(d)}catch(N){return}if(!((_=u.nodes)!=null&&_.length))return;let p=new Map,f=o(),g=[],x=u.nodes.filter(N=>ct(N.type,f));if(x.length===0)return;let m=a(),E=x.map(N=>{var M;let T=String(m++);p.set(N.id,T);let A=v(b({},N),{id:T,selected:!0,position:{x:N.position.x+e,y:N.position.y+e}});if(N.type==="TASK"){let R=(M=N.data)==null?void 0:M.label,I=ao(R||t("bpmn.task.label.prefix"),[...f,...g]);A.data=v(b({},N.data),{label:I})}return g.push(A),A}),y=u.edges.map(N=>v(b({},N),{id:String(m++),selected:!0,source:p.get(N.source)||N.source,target:p.get(N.target)||N.target}));n(N=>[...N.map(T=>v(b({},T),{selected:!1})),...E]),i(N=>[...N.map(T=>v(b({},T),{selected:!1})),...y])};return document.addEventListener("copy",s,!0),document.addEventListener("paste",l,!0),()=>{document.removeEventListener("copy",s,!0),document.removeEventListener("paste",l,!0)}},[o,n,r,i,a,e,t])};import{useReactFlow as Bh,useStoreApi as zh}from"@xyflow/react";import{useTranslation as Fh}from"lecom-ui";import{useState as Wh}from"react";var Zc=({nodes:e,setNodes:t,setEdges:o})=>{let n=zh(),{draggableNode:r,setDraggableNode:i}=so(),{t:a}=Fh(),{getInternalNode:s,getNodes:l,screenToFlowPosition:c}=Bh(),{getNextId:d}=ze(),{setIsDragging:u}=U(),{rebuildIndex:p,forceRebuildIndex:f}=Kn(),[g,x]=Wh(null),m=(C,L=!1)=>{let V=L?"[&>div]:bg-red-50 [&>div]:outline [&>div]:outline-[3px] [&>div]:outline-red-500":"[&>div]:bg-green-50/75 [&>div]:outline [&>div]:outline-[3px] [&>div]:outline-green-500";t(w=>w.map(P=>v(b({},P),{className:P.id===C?V:""})))},E=()=>{let{nodeLookup:C}=n.getState();return Array.from(C.values())},y=C=>{let L=s(C.id),V=E();if(C.type==="LANE"){if(ro({parentId:C.id,nodes:e,includeTypes:["LANE"]})){m();return}let S=V.filter(z=>z.id!==C.id&&z.type==="LANE"&&!z.parentId),O=Xo(L,S);if(!O){m();return}if(ro({parentId:O.id,nodes:e,excludeTypes:["LANE"]})){m(O.id,!0);return}m(O.id);return}let P=V.filter(q=>q.id!==C.id&&q.type==="LANE"),F=Xo(L,P);if(!F){m();return}if(ro({parentId:F.id,nodes:e,includeTypes:["LANE"]})){m();return}m(F.id)},h=C=>C.map(L=>v(b({},L),{className:void 0})),_=C=>C.some(V=>V.dragging)?C.map(V=>V.dragging?v(b({},V),{dragging:!1}):V):C,N=C=>{C.preventDefault(),C.dataTransfer.dropEffect="move"},T=(C,L)=>{C.preventDefault(),y(L)},A=(C,L,V)=>{var q,S;let w=[...V];if(C.parentId===L.id)return w=Vl(C,L,w),w=Ko(w),h(w);if(C.type==="LANE"){if(ro({parentId:L.id,nodes:w,excludeTypes:["LANE"]})){let Y=De(L),ne=50,G=50;return w.map($=>{var K,W;return $.id===C.id?v(b({},$),{position:{x:(K=g==null?void 0:g.x)!=null?K:Y.x+ne,y:(W=g==null?void 0:g.y)!=null?W:Y.y2+G}}):$})}let z=w.filter(Y=>Y.parentId===L.id).reduce((Y,ne)=>{var G,$;return Y+(($=(G=ne.measured)==null?void 0:G.height)!=null?$:0)},0),Z={x:de.HEADER_WIDTH,y:z};return w=w.map(Y=>Y.id===C.id?v(b({},Y),{parentId:L.id,position:Z,className:void 0}):v(b({},Y),{className:void 0})),w=qo(L.id,w),w}if(ro({parentId:L.id,nodes:w,includeTypes:["LANE"]})){let O;if(C.parentId){let H=s(C.parentId),{x:z,y:Z}=tt(H);O={x:z+((q=C.position.x)!=null?q:0),y:Z+((S=C.position.y)!=null?S:0)}}return w=w.map(H=>H.id===C.id?v(b({},H),{position:O!=null?O:H.position,parentId:void 0,className:void 0}):v(b({},H),{className:void 0})),w}let X=kl(C,L);return w=w.map(O=>{if(O.id===C.id){let H=De(C),z=De(L);return H.y<z.y&&(X.y=0),H.x<z.x+de.HEADER_WIDTH&&(X.x=de.HEADER_WIDTH),v(b({},O),{parentId:L.id,position:X,className:void 0})}return v(b({},O),{className:void 0})}),w=Ko(w),w},M=C=>{if(C.preventDefault(),!(r!=null&&r.type))return;if(!ct(r.type,l())){u(!1),i(null);return}let L=c({x:C.clientX,y:C.clientY}),V={width:te[r.type].MIN_WIDTH,height:te[r.type].MIN_HEIGHT},w=d(),P={id:String(w),type:r.type,position:L,measured:V,data:{label:r.type==="TASK"?xr(e,a("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},F=v(b({},P),{internals:{positionAbsolute:L}}),X=E(),q=r.type==="LANE",S=X.filter(Z=>q?Z.type==="LANE"&&!Z.parentId:Z.type==="LANE"),O=Xo(F,S),H=[...e.map(Z=>v(b({},Z),{selected:!1})),P];O&&(H=A(F,O,H)),H=Pt(H),t(H),f();let z=C.dataTransfer.getData("sourceId");if(z){let Z={id:String(w+1),source:z,target:P.id};r.type==="ANNOTATION"?o(Y=>Y.concat(b(b({},Z),Zt))):o(Y=>Y.concat(b(b({},Z),Ue)))}u(!1),i(null)},R=async(C,L,V)=>{let w=[...e];V.forEach(P=>{let F=E(),X=s(P.id),q=P.type==="LANE",S=F.filter(H=>H.id!==P.id&&(q?H.type==="LANE"&&!H.parentId:H.type==="LANE")),O=Xo(X,S);if(O){w=A(X,O,w);return}P.parentId&&(w=D(P,w))}),w=_(w),w=Pt(w),w=h(w),t(w),p(w),x(null)},I=(C,L)=>{x({x:L.position.x,y:L.position.y})},D=(C,L)=>{var X,q;let V=s(C.parentId),{x:w,y:P}=tt(V),F={x:w+((X=C.position.x)!=null?X:0),y:P+((q=C.position.y)!=null?q:0)};return L=L.map(S=>S.id===C.id?v(b({},S),{position:F,parentId:void 0}):S),L=qo(C.parentId,L),L};return{onDragOver:N,onDrop:M,onNodeDrag:T,onNodeDragStart:I,onNodeDragStop:R}};import{useReactFlow as Yh}from"@xyflow/react";import{useTranslation as Uh}from"lecom-ui";import{useEffect as $h}from"react";var Xh=30,Kh=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",i=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||i},qh=e=>!Kh(e.target),Jc=({offset:e=Xh}={})=>{let{t}=Uh(),{getNodes:o,setNodes:n,getEdges:r,setEdges:i}=Yh(),{getNextId:a}=ze();$h(()=>{let s=l=>{if(l.ctrlKey&&l.key.toLowerCase()==="d"&&qh(l)){l.preventDefault(),l.stopPropagation();let c=o(),d=r(),u=c.filter(h=>h.selected);if(!u.length)return;let p=new Map,f=[],g=u.filter(h=>ct(h.type,c));if(g.length===0)return;let x=d.filter(h=>g.some(_=>_.id===h.source)&&g.some(_=>_.id===h.target)),m=a(),E=g.map(h=>{var T;let _=String(m++);p.set(h.id,_);let N=v(b({},h),{id:_,selected:!0,position:{x:h.position.x+e,y:h.position.y+e}});if(h.type==="TASK"){let A=(T=h.data)==null?void 0:T.label,M=ao(A||t("bpmn.task.label.prefix"),[...c,...f]);N.data=v(b({},h.data),{label:M})}return f.push(N),N}),y=x.map(h=>v(b({},h),{id:String(m++),selected:!0,source:p.get(h.source)||h.source,target:p.get(h.target)||h.target}));n(h=>[...h.map(_=>v(b({},_),{selected:!1})),...E]),i(h=>[...h.map(_=>v(b({},_),{selected:!1})),...y])}};return document.addEventListener("keydown",s,!0),()=>{document.removeEventListener("keydown",s,!0)}},[o,n,r,i,a,e,t])};import{useReactFlow as Jh}from"@xyflow/react";var jc={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},ed={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},Qc=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],n=e.match(/(\[.*?\])/)||[],r=e.match(/(\{.*?\})/)||[],i=e.match(/(--.*|\|.*?\|)/i)||[],a="",s="",l="";if(o.length){switch(o[1]){case"<start>":a="start-event";break;case"<end>":a="end-event";break}e=e.replace(o[1],"")}return n.length&&(a="task",s=n[1].replace(/\[|\]/g,""),e=e.replace(n[1],"")),r.length&&(a="gateway-exclusive",s=r[1].replace(/\{|\}/g,""),e=e.replace(r[1],"")),a||(a="task",s=e),i.length&&(l=i[1].replace(/(\||--)/g,""),e=e.replace(i[1],"")),e=e.trim(),t[e]||(t[e]={type:a,label:s}),{step:e,type:a,label:s,edgeLabel:l}},Zh=e=>{e=e||"";let t=e.trim().split(`
|
|
36
|
+
`),o={},n=[];return t.forEach(r=>{r=r||"";let i=r.trim().split("-->");if(i.length!==2){console.warn("Invalid number of steps");return}let a=Qc(i[0],o),s=Qc(i[1],o);a&&s&&n.push({sourceId:a.step,targetId:s.step,label:a.edgeLabel||s.edgeLabel||""})}),{components:o,connections:n}},td=e=>{let{components:t,connections:o}=Zh(e);return{nodes:t,edges:o}};var od=()=>{let{setNodes:e,setEdges:t,fitView:o}=Jh(),{getNextId:n}=ze();return{importFromLia:i=>{let a=typeof i=="string"?i:i.diagramXml||"",{nodes:s,edges:l}=td(a),c=[],d=new Map,u=!1,p=n();for(let[m,E]of Object.entries(s)){let y=String(p++),h=jc[E.type],_=ed[E.type];h==="START_EVENT"&&(u=!0),d.set(m,y);let N=te[h].MIN_WIDTH,T=te[h].MIN_HEIGHT;c.push({id:y,type:h,data:{label:E.label||"",variant:_,attribute:""},position:{x:0,y:0},width:N,height:T,measured:{width:N,height:T}})}let f=[];for(let m of l){let E=v(b({},Ue),{id:String(p++),source:d.get(m.sourceId)||m.sourceId,target:d.get(m.targetId)||m.targetId});f.push(E)}if(!u&&c.length>0){let m=String(p++),E={id:m,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:te.START_EVENT.MIN_WIDTH,height:te.START_EVENT.MIN_HEIGHT,measured:{width:te.START_EVENT.MIN_WIDTH,height:te.START_EVENT.MIN_HEIGHT}};c.unshift(E);let y=c[1];if(y){let h=v(b({},Ue),{id:String(p++),source:m,target:y.id});f.unshift(h)}}let{nodes:g,edges:x}=Ol(c,f);e(g),t(x),o({padding:uo,minZoom:po,maxZoom:fo})}}};import{useEffect as Qh,useCallback as jh}from"react";var e0={origin:"*",debug:!1};function nd(e,t=e0){let{origin:o,debug:n}=t,r=jh((i,a)=>{let s={event:i,data:[i,{event:i,data:a}]};window.parent.postMessage(s,o||"*")},[o]);return Qh(()=>{let i=a=>{let s=a.data;if(!(s!=null&&s.event)||(s==null?void 0:s.data)===void 0)return;let{event:l,data:c}=s,d;if(Array.isArray(c)){let[,u]=c;d=u.data}else d=c;n&&(console.debug("[postMessage] received:",s),console.debug("[postMessage] eventData:",d)),l&&e[l]&&e[l](d)};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[e,n]),{sendMessage:r}}import{useNodesInitialized as t0}from"@xyflow/react";import{useEffect as rd}from"react";var id=()=>{let e=t0(),{initialDiagram:t,setIsInitialized:o}=U(),{importFromMxGraph:n}=mo();rd(()=>{t&&n(t)},[t,n,o]),rd(()=>{if(!e)return;(async()=>{await pn(),o(!0)})()},[e,o])};import{useCallback as sd}from"react";import{useReactFlow as o0}from"@xyflow/react";function ad(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=wt(),{getEdges:n}=o0(),r=yn(),i=sd(s=>{if(!(s!=null&&s.activities))return;e(s.activities);let l=s.activities.map(d=>d.diagramId),c=n();o(c,l),setTimeout(()=>{r()},0)},[e,o,n,r]),a=sd(()=>{t(),setTimeout(()=>{r()},0)},[t,r]);return{handleTasksStatus:i,handleClearTaskStatus:a}}import{useReactFlow as n0}from"@xyflow/react";import{useCallback as go,useState as ld,useEffect as r0}from"react";import{useDebouncedCallback as i0}from"use-debounce";var s0=500,cd=100,dd=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=n0(),[i,a]=ld([]),[s,l]=ld(0),c=i[s],d=s>0,u=s<i.length-1,p=go(_=>{n(i[_].nodes),r(i[_].edges)},[i,n,r]),f=go(()=>{if(s>0){let _=s-1;l(_),p(_)}},[s,p]),g=go(()=>{if(s<i.length-1){let _=s+1;l(_),p(_)}},[i,s,p]),x=_=>{let T=[...i.slice(0,s+1),_],A=T.length>cd?T.slice(T.length-cd):T;a(A),l(A.length-1)},m=i0(()=>{let _=t(),N=o(),T=_.map(R=>v(b({},R),{selected:!1,className:""})),A={nodes:Pt(T),edges:N};JSON.stringify(c)!==JSON.stringify(A)&&x(A)},s0),E=go(_=>{if(!e)return;if(i.length===0){m();return}if(_==="forceSave"){m();return}_.some(A=>A.type==="select")||_.some(A=>A.type==="position"&&A.dragging)||m()},[e,m,i.length]),y=go(_=>{a(_||[]),l(0)},[]),h=go(()=>{a([]),l(0)},[]);return r0(()=>{let _=N=>{(N.ctrlKey||N.metaKey)&&(N.shiftKey&&N.key.toLowerCase()==="z"?(N.preventDefault(),g()):N.key.toLowerCase()==="z"&&(N.preventDefault(),f()))};return document.addEventListener("keydown",_),()=>{document.removeEventListener("keydown",_)}},[f,g]),{history:i,undo:f,redo:g,canUndo:d,canRedo:u,saveHistory:E,resetHistory:y,clearHistory:h}};var ud=()=>{let[e,t,o]=l0([]),[n,r,i]=a0([]),{getNode:a}=d0(),{instanceId:s,isInitialized:l,setIsConnecting:c,setIsMultipleSelection:d,onElementClick:u}=U(),{updateHelperLines:p,HelperLines:f}=Kn(),{undo:g,redo:x,canUndo:m,canRedo:E,saveHistory:y}=dd(l),{onNodeDrag:h,onDrop:_,onDragOver:N,onNodeDragStop:T,onNodeDragStart:A}=Zc({nodes:e,setNodes:t,setEdges:r}),{isValidConnection:M,onConnect:R,onReconnect:I,onReconnectStart:D,onReconnectEnd:C,setReconnectingEdge:L,clearReconnectingEdge:V}=Oc({setEdges:r}),{handleValidationComplete:w,clearValidation:P,dismissValidationPanel:F,validateDiagram:X,getIsClearingValidation:q}=$c(),{importFromLia:S}=od(),{handleTasksStatus:O,handleClearTaskStatus:H}=ad(),{clearPathEdges:z}=wt(),Z=yn(),{emitElementChanges:Y,handleNodeChanges:ne,handleEdgeChanges:G}=Tr();qc(),Jc(),id();let $=ho(()=>{t([]),r([]),z(),setTimeout(()=>{Z()},0)},[t,r,z,Z]);nd({LIA_CREATE_DIAGRAM:S,CLEAR_DIAGRAM:$,TASKS_STATUS:O,CLEAR_TASKS_STATUS:H});let{selectElements:K,clearSelection:W}=ut(),{importFromMxGraph:B,exportToMxGraph:J}=mo(),{configureElement:Q,getConfigureElement:oe}=nr(),ue=ho(()=>e.length+n.length,[e,n]);u0(()=>(Ze.set(s,{importFromMxGraph:B,exportToMxGraph:J,selectElements:K,clearSelection:W,configureElement:Q,getConfigureElement:oe,getElementsCount:ue,setReconnectingEdge:L,clearReconnectingEdge:V}),()=>{Ze.delete(s)}),[s,B,J,K,W,Q,oe,ue,L,V]);let le=ho((j,ae)=>{if(ae.type!=="TASK"&&ae.type!=="GATEWAY")return;let Se=oe(ae.id);Se&&(u==null||u(Se))},[oe,u]),ce=ho((j,ae)=>{if(ae.type!=="SEQUENCE_EDGE")return;let Se=a(ae.source),_t=a(ae.target),{isFromStartEvent:Tt,isGatewayToGateway:Nt,isActiviyToAndGateway:vt}=er(Se,_t);if(!(!Tt&&!Nt&&!vt))return;let xo=oe(ae.id);xo&&(u==null||u(xo))},[oe,a,u]),ye=ho(j=>{let ae=p(j,e);o(ae),y(j),q()||F(),ne(j)},[e,o,y,q,F,p,ne]),xe=ho(j=>{i(j),y(j),q()||F(),G(j)},[i,y,q,F,G]);return c0({onChange:({nodes:j,edges:ae})=>{d(j.length+ae.length>1)}}),{nodes:e,setNodes:t,edges:n,setEdges:r,events:{isValidConnection:M,onConnect:R,onReconnect:I,onReconnectStart:D,onReconnectEnd:C,onDrop:_,onDragOver:N,onNodeDrag:h,onNodeDragStop:T,onNodeDragStart:A,onNodeClick:le,onEdgeClick:ce,onDropCapture:()=>{y("forceSave"),Y(),F()},onConnectStart:()=>{c(!0)},onConnectEnd:()=>{c(!1),F()},onNodesChange:ye,onEdgesChange:xe},ui:{handleCloseValidationPanel:P},controls:{undo:g,redo:x,canUndo:m,canRedo:E},components:{HelperLines:f},actions:{saveHistory:y,selectElements:K,clearSelection:W,exportToMxGraph:J,validateDiagram:X,handleValidationComplete:w,setReconnectingEdge:L,clearReconnectingEdge:V}}};import{jsx as pd}from"react/jsx-runtime";var wi=({id:e,className:t})=>pd("marker",{id:e,className:k("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:pd("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as Ai,jsxs as p0}from"react/jsx-runtime";var fd=()=>Ai("svg",{style:{position:"absolute",top:0,left:0},children:p0("defs",{children:[Ai(wi,{id:"sequence-edge-marker",className:"text-grey-400"}),Ai(wi,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{useKeyPress as Pd,useReactFlow as oy}from"@xyflow/react";import{Button as Mr,Tooltip as Pr,TooltipContent as Lr,TooltipTrigger as kr,useTranslation as ny}from"lecom-ui";import{HandIcon as ry,ListCheckIcon as iy,MapIcon as sy,MousePointerIcon as ay}from"lucide-react";import{useCallback as Mi,useEffect as Ld}from"react";import{Tooltip as k0,TooltipContent as D0,TooltipTrigger as R0,useNotificationToast as O0,useTranslation as V0}from"lecom-ui";var sn=(h=>(h.START_EVENT="START_EVENT",h.END_EVENT="END_EVENT",h.TASK="TASK",h.SUBPROCESS="SUBPROCESS",h.GATEWAY="GATEWAY",h.LANE="LANE",h.ANNOTATION="ANNOTATION",h.CONNECTION="CONNECTION",h.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",h.ACTIVITY="ACTIVITY",h.PROCESS_INTERFACE="PROCESS_INTERFACE",h.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",h.VARIANT_ACTIVITY="VARIANT_ACTIVITY",h.AUTO_ACTIVITY="AUTO_ACTIVITY",h.DATA_STORE="DATA_STORE",h.DATA_OBJECT="DATA_OBJECT",h.DATA_OUTPUT="DATA_OUTPUT",h.DATA_INPUT="DATA_INPUT",h.MARKER="MARKER",h))(sn||{});import{useReactFlow as v0}from"@xyflow/react";import{useNotificationToast as w0,useTranslation as A0,Button as I0}from"lecom-ui";var md=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 gd({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let r="data:text/csv;charset=utf-8,"+[e,...t].map(a=>a.join(",")).join(`
|
|
37
|
+
`),i=encodeURI(r);wr(i,`${o}.csv`)}var wr=(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 hd(e){return e==null?void 0:e.replaceAll("
"," ")}var pP={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},yd={script:"SCRIPT",subprocess:"SUBPROCESS"},xd={"marker-loop":"LOOP"},Ed={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL",inclusive:"EXCLUSIVE"};var Vt=({cell:e,type:t,variant:o="",attribute:n=""})=>{let{_attributes:r,mxGeometry:i}=e,{value:a,parent:s}=r,l=Number(i._attributes.width),c=Number(i._attributes.height),d=s==="1"?void 0:s;return{id:r.id,parentId:d,type:t,data:{label:a||"",variant:o,attribute:n},position:{x:Number(i._attributes.x)||0,y:Number(i._attributes.y)||0},width:l,height:c,measured:{width:l,height:c}}},m0=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=te.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=te.START_EVENT.MIN_HEIGHT,{node:Vt({cell:e,type:"START_EVENT"}),status:n,originalType:o}},g0=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=te.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=te.END_EVENT.MIN_HEIGHT,{node:Vt({cell:e,type:"END_EVENT"}),status:n,originalType:o}},h0=(e,t)=>{let{id:o,subType:n,style:r}=e==null?void 0:e._attributes,i=yd[n],a=t.get(o)||"",s=xd[a]||"",l=s==="LOOP",c="imported";return!["script","none"].includes(n)&&!l&&(c="adapted"),e.mxGeometry._attributes.width=nt(e.mxGeometry._attributes.width||0,te.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=nt(e.mxGeometry._attributes.height||0,te.TASK.MIN_HEIGHT),{node:Vt({cell:e,type:"TASK",variant:i,attribute:s}),status:c,originalType:r}},y0=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=Ed[o],r=["none","inclusive","event-based"],i="imported";return r.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=te.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=te.GATEWAY.MIN_HEIGHT,{node:Vt({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},x0=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:Vt({cell:e,type:"LANE"}),status:"imported",originalType:t}},E0=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=nt(e.mxGeometry._attributes.width||0,te.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=nt(e.mxGeometry._attributes.height||0,te.ANNOTATION.MIN_HEIGHT),{node:Vt({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},bd=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=te.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=te.UNSUPPORTED.MIN_HEIGHT,{node:Vt({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},_d=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return v(b({},Ue),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},Td={TASK:h0,GATEWAY:y0,START_EVENT:m0,END_EVENT:g0,LANE:x0,ANNOTATION:E0};var b0=e=>{let t=new Map,o=Object.values(sn),n=[],r=new Map;e.forEach(s=>{var c;let l=(c=s._attributes)==null?void 0:c.type;if(l==="MARKER"){r.set(s._attributes.parent,s._attributes.style);return}if(o.includes(l)){n.push(s);return}});let i=[],a=[];for(let s of n){let{type:l}=s._attributes,c=Td[l]||bd,{node:d,status:u,originalType:p}=c(s,r);a.push(d),i.push({originalType:p,type:d.type,variant:d.data.variant,value:hd(d.data.label),status:u})}return{nodes:a,governanceIdToNodeIdMap:t,summary:i}},_0=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>_d(r,t)),T0=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=b0(t.root.mxCell),i=_0(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},N0=async e=>{let t=await md(e),o=gr(t);if(!o)throw new Error("EMPTY_FILE");let{metadata:n,mxGraphModel:r}=o.modeler||{},i=(n==null?void 0:n.app)&&(n==null?void 0:n.diagramType)&&(n==null?void 0:n.version),a=r==null?void 0:r.root;if(!i||!a)throw new Error("INVALID_FILE");if(!Object.keys(r.root.mxCell||{}).length)throw new Error("CONTAIN_NO_CELLS");return{metadata:n,mxGraphModel:r}},Nd=async e=>{try{let t=await N0(e),{nodes:o,edges:n,summary:r}=T0(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};import{jsx as C0}from"react/jsx-runtime";var vd=()=>{let{t:e}=A0(),{toast:t}=w0(),{setNodes:o,setEdges:n,fitView:r}=v0(),i=s=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],c=s.map(d=>[d.originalType,d.value,e(`adapter.governance.report.status.${d.status.toLowerCase()}`)]);t({variant:"warning",content:e("adapter.governance.success.incompatible_cells"),duration:1e3*60*1,action:C0(I0,{size:"small",variant:"ghost",onClick:()=>gd({columns:l,rows:c,fileName:"governance-imported-cells"}),children:e("adapter.governance.action.download")})})};return{importFromGovernance:async s=>{try{let{nodes:l,edges:c,summary:d}=await Nd(s);if(o(p=>p.concat(l)),n(p=>p.concat(c)),r({padding:uo,minZoom:po,maxZoom:fo}),d.some(p=>p.status==="unsupported")){i(d);return}t({variant:"success",content:e("adapter.governance.success.default")})}catch(l){let c=l instanceof Error?l.message:"DEFAULT";t({variant:"error",content:e(`adapter.governance.error.${c}`)})}}}};import{Button as S0}from"lecom-ui";import{useRef as M0}from"react";import{Fragment as P0,jsx as wd,jsxs as L0}from"react/jsx-runtime";var Ad=s=>{var l=s,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,a=Xe(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=M0(null),d=p=>{let f=p.target.files;f!=null&&f.length&&i(f),c.current&&(c.current.value="")};return L0(P0,{children:[wd(S0,v(b({disabled:n,onClick:p=>{var f;(f=c.current)==null||f.click(),r==null||r(p)}},a),{children:e})),wd("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};import{jsx as Ar,jsxs as H0}from"react/jsx-runtime";var Id=({disabled:e=!1})=>{let{t}=V0(),{toast:o}=O0(),{importFromGovernance:n}=vd(),r=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},i=a=>{let s=a[0];if(!s){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}n(s)};return H0(k0,{children:[Ar(R0,{asChild:!0,children:Ar(Ad,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:Ar(Xi,{})})}),Ar(D0,{color:"black",children:t("editor.controls.actions.import_governance")})]})};import{jsx as G0}from"react/jsx-runtime";var Ii=({shortcut:e})=>G0("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 $0,DropdownMenu as X0,DropdownMenuContent as K0,DropdownMenuItem as Si,DropdownMenuTrigger as q0,Tooltip as Ir,TooltipContent as Cr,TooltipTrigger as Sr,useTranslation as Z0}from"lecom-ui";import{FileCodeIcon as J0,FileImageIcon as Q0,FolderOutputIcon as j0,PrinterIcon as ey}from"lucide-react";import{useState as ty}from"react";import{useReactFlow as B0}from"@xyflow/react";import{toPng as Cd,toSvg as z0}from"html-to-image";import{toast as F0,useTranslation as W0}from"lecom-ui";import{useState as Y0}from"react";var U0=3,Ci="diagram",Sd=()=>{let{t:e}=W0(),{getNodes:t}=B0(),{clearSelection:o}=ut(),[n,r]=Y0({png:!1,html:!1,print:!1}),i=()=>{let{x:d,y:u,width:p,height:f}=Gl(t());return{width:p,height:f,style:{width:`${p}px`,height:`${f}px`,transform:`translate(${-d}px, ${-u}px)`}}},a=async(d,u)=>{r(v(b({},n),{[u]:!0})),await o();try{let p=Hl();if(!p)throw new Error("Flow element not found");let f=i();return await d(p,f)}catch(p){F0({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{r(v(b({},n),{[u]:!1}))}};return{exportAsPng:async(d=Ci)=>{await a(async(u,p)=>{let f=await Cd(u,v(b({},p),{backgroundColor:"#fcfcfc"}));wr(f,`${d}.png`)},"png")},exportAsHtml:async(d=Ci)=>{await a(async(u,p)=>{let f=await z0(u,v(b({},p),{backgroundColor:"#fcfcfc"})),g=`
|
|
38
38
|
<!DOCTYPE html>
|
|
39
39
|
<html>
|
|
40
40
|
<head>
|
|
@@ -45,10 +45,10 @@ var Wd=Object.defineProperty,Yd=Object.defineProperties;var Ud=Object.getOwnProp
|
|
|
45
45
|
</style>
|
|
46
46
|
</head>
|
|
47
47
|
<body>
|
|
48
|
-
<img src="${
|
|
48
|
+
<img src="${f}" alt="Diagram" />
|
|
49
49
|
</body>
|
|
50
50
|
</html>
|
|
51
|
-
`,
|
|
51
|
+
`,x=new Blob([g],{type:"text/html"}),m=URL.createObjectURL(x);wr(m,`${d}.html`),setTimeout(()=>URL.revokeObjectURL(m),100)},"html")},printDiagram:async(d=Ci)=>{await a(async(u,p)=>{let f=await Cd(u,v(b({},p),{pixelRatio:U0})),g=window.open("","_blank");if(!g)throw new Error("Failed to open print window.");let x=g.document;x.open(),x.write(`
|
|
52
52
|
<!DOCTYPE html>
|
|
53
53
|
<html>
|
|
54
54
|
<head>
|
|
@@ -61,7 +61,7 @@ var Wd=Object.defineProperty,Yd=Object.defineProperties;var Ud=Object.getOwnProp
|
|
|
61
61
|
</style>
|
|
62
62
|
</head>
|
|
63
63
|
<body>
|
|
64
|
-
<img src="${
|
|
64
|
+
<img src="${f}" alt="Diagram" onload="window.print(); window.close();" />
|
|
65
65
|
</body>
|
|
66
66
|
</html>
|
|
67
|
-
`),g.close()},"print")},isPrintingPng:n.png,isPrintingHtml:n.html,isPrinting:n.print}};import{jsx as Ee,jsxs as ho}from"react/jsx-runtime";function Id(){let{t:e}=X0(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:a}=Ad(),[s,l]=Q0(!1);return ho(Y0,{modal:!1,open:s,onOpenChange:l,children:[Ee($0,{asChild:!0,children:Ee("div",{children:ho(wr,{children:[Ee(Ir,{asChild:!0,children:Ee(W0,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:Ee(Z0,{})})}),!s&&Ee(Ar,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),ho(U0,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[ho(wr,{children:[Ee(Ir,{asChild:!0,children:Ee(Ai,{className:"p-1.5",disabled:i,onClick:()=>t(),children:Ee(q0,{})})}),Ee(Ar,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),ho(wr,{children:[Ee(Ir,{asChild:!0,children:Ee(Ai,{className:"p-1.5",disabled:a,onClick:()=>o(),children:Ee(K0,{})})}),Ee(Ar,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),ho(wr,{children:[Ee(Ir,{asChild:!0,children:Ee(Ai,{className:"p-1.5",disabled:r,onClick:()=>n(),children:Ee(J0,{})})}),Ee(Ar,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as Md,jsx as be,jsxs as tt}from"react/jsx-runtime";var Pd=({nodes:e,validateDiagram:t,handleValidationComplete:o})=>{let{t:n}=ey(),{clearSelection:r}=ct(),{mode:i,isMinimapOpen:a,setIsMinimapOpen:s,isMoveTool:l,isHandTool:c,setIsMoveTool:d,setIsHandTool:u}=W(),{getNodes:p,getEdges:m}=j0(),h=Cd(["v","V"]),g=Cd(["h","H"]),f=Ii(()=>{r(),u(!0),d(!1)},[r,u,d]),y=Ii(()=>{d(!0),u(!1)},[d,u]),x=Ii(()=>{let _=p(),b=m(),T=t({nodes:_,edges:b});o(T)},[p,m,t,o]);return Sd(()=>{h&&!l&&i==="edit"&&y()},[h,y,l,i]),Sd(()=>{g&&!c&&i==="edit"&&f()},[g,f,c,i]),tt("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[i==="edit"&&tt(Md,{children:[tt(Sr,{children:[be(Pr,{asChild:!0,children:be(Cr,{size:"small",variant:"ghost",color:"grey",className:k(l&&"bg-grey-400"),iconButton:!0,onClick:y,children:be(ry,{})})}),tt(Mr,{color:"black",className:"flex items-center gap-2",children:[n("editor.controls.actions.move_tool"),be(Ni,{shortcut:"V"})]})]}),tt(Sr,{children:[be(Pr,{asChild:!0,children:be(Cr,{size:"small",variant:"ghost",color:"grey",className:k(c&&"bg-grey-400"),iconButton:!0,onClick:f,children:be(ty,{})})}),tt(Mr,{color:"black",className:"flex items-center gap-2",children:[n("editor.controls.actions.hand_tool")," ",be(Ni,{shortcut:"H"})]})]})]}),be(Id,{}),i==="edit"&&tt(Md,{children:[tt(Sr,{children:[be(Pr,{asChild:!0,children:be(Cr,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:x,children:be(oy,{})})}),be(Mr,{color:"black",children:n("editor.controls.actions.check")})]}),be(Nd,{disabled:e.length>0})]}),tt(Sr,{children:[be(Pr,{asChild:!0,children:be(Cr,{size:"small",variant:"ghost",color:"grey",className:k(a&&"bg-grey-400"),iconButton:!0,onClick:()=>s(!a),children:be(ny,{})})}),be(Mr,{color:"black",children:n(a?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as Ld,Tooltip as kd,TooltipContent as Dd,TooltipTrigger as Rd,useTranslation as iy}from"lecom-ui";import{RedoIcon as sy,UndoIcon as ay}from"lucide-react";import{jsx as yt,jsxs as Ci}from"react/jsx-runtime";var Od=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=iy();return Ci("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Ci(kd,{children:[yt(Rd,{asChild:!0,children:yt(Ld,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:yt(ay,{})})}),yt(Dd,{color:"black",children:r("editor.controls.history.undo")})]}),Ci(kd,{children:[yt(Rd,{asChild:!0,children:yt(Ld,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:yt(sy,{})})}),yt(Dd,{color:"black",children:r("editor.controls.history.redo")})]})]})};import{useReactFlow as ly}from"@xyflow/react";import{Button as Lr,Tooltip as kr,TooltipContent as Dr,TooltipTrigger as Rr,useTranslation as cy}from"lecom-ui";import{ScanIcon as dy,ZoomIn as uy,ZoomOut as py}from"lucide-react";import{jsx as we,jsxs as nn}from"react/jsx-runtime";var Vd=()=>{let{t:e}=cy(),{zoomIn:t,zoomOut:o,zoomTo:n,fitView:r}=ly();return nn("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[nn(kr,{children:[we(Rr,{asChild:!0,children:we(Lr,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>r(),children:we(dy,{})})}),we(Dr,{color:"black",children:e("editor.controls.zoom.fit")})]}),nn(kr,{children:[we(Rr,{asChild:!0,children:we(Lr,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>o(),children:we(py,{})})}),we(Dr,{color:"black",children:e("editor.controls.zoom.out")})]}),nn(kr,{children:[we(Rr,{asChild:!0,children:we(Lr,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>n(1),children:we(Xi,{})})}),we(Dr,{color:"black",children:e("editor.controls.zoom.reset")})]}),nn(kr,{children:[we(Rr,{asChild:!0,children:we(Lr,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>t(),children:we(uy,{})})}),we(Dr,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{useReactFlow as fy}from"@xyflow/react";import{Button as my,Tooltip as gy,TooltipContent as hy,TooltipTrigger as yy,useTranslation as xy}from"lecom-ui";import{useRef as Ey,useState as by}from"react";import{jsx as Vt,jsxs as Hd}from"react/jsx-runtime";var Gd=()=>{let e=Ey(null),{t}=xy(),{setDraggableNode:o}=io(),{getNodes:n}=fy(),{setIsDragging:r}=W(),[i,a]=by(void 0),s=n(),l=$n(s),c=[{type:"START_EVENT",icon:dn,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:Ht,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:Eo,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:Qi,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:Ji,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:Zi,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:Bt,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:zt,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:Gt,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:$i,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:ln,label:t("bpmn.annotation.variant.default")}],d=(u,p)=>{o({type:p.type,variant:p.variant,attribute:p.attribute,icon:p.icon}),a(Vt(p.icon,{})),u.dataTransfer.effectAllowed="move",e.current&&u.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return Hd("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[Vt("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:c.map((u,p)=>{let m=l&&u.type==="START_EVENT",h=m?t("editor.toolbar.start_event_already_exists"):u.label;return Hd(gy,{children:[Vt(yy,{asChild:!0,children:Vt(my,{className:k("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":m}),size:"small",variant:"ghost",color:"grey",draggable:!m,disabled:m,iconButton:!0,onDragStart:m?void 0:g=>d(g,u),children:Vt(u.icon,{})},p)}),Vt(hy,{color:"black",side:"right",children:h})]},p)})}),Vt("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{jsx as xt,jsxs as Si}from"react/jsx-runtime";var Mi=wy((e,t)=>{let{instanceId:o,mode:n,isMinimapOpen:r,isMoveTool:i,isHandTool:a}=W(),{nodes:s,edges:l,actions:c,events:d,components:u,controls:p}=cd();return Ay(t,()=>({selectElements:c.selectElements,clearSelection:c.clearSelection})),Si("div",{className:"w-full h-full",children:[n==="edit"&&xt(Gd,{}),xt(ud,{}),Si(vy,w(E({},d),{id:`modeler-${o}`,edges:l,nodes:s,nodeTypes:_c,edgeTypes:Tc,minZoom:Cc,maxZoom:Sc,panOnDrag:a||n!=="edit"?!0:Pc,panOnScroll:!0,selectionOnDrag:!0,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!1,elementsSelectable:n!=="readonly"&&i,nodesConnectable:n==="edit"&&i,nodesDraggable:n==="edit"&&i,connectionLineComponent:yc,selectionMode:Ny.Partial,multiSelectionKeyCode:"Shift",deleteKeyCode:"Delete",selectionKeyCode:null,defaultViewport:Mc,connectOnClick:!1,connectionRadius:30,proOptions:{hideAttribution:!0},children:[xt(_y,{gap:Ac,size:wc,color:Nc,bgColor:vc}),r&&xt(Ty,{pannable:!0,zoomable:!0,position:Ic,className:"shadow-md rounded-md"}),Si("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[n==="edit"&&xt(Od,E({},p)),xt(Pd,{nodes:s,validateDiagram:c.validateDiagram,handleValidationComplete:c.handleValidationComplete}),xt(Vd,{})]}),xt(u.HelperLines,{})]}))]})});Mi.displayName="Editor";import{useStore as Iy}from"@xyflow/react";import{useEffect as Cy,useRef as Sy}from"react";import{jsx as Py}from"react/jsx-runtime";var My=e=>({width:e.width,height:e.height,transform:e.transform}),Pi="rgba(51, 103, 217, 0.4)",Xa=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=Iy(My),i=Sy(null);return Cy(()=>{let a=i.current,s=a==null?void 0:a.getContext("2d");if(!s||!a)return;let l=window.devicePixelRatio;a.width=o*l,a.height=n*l,s.clearRect(0,0,o,n),s.scale(l,l),s.strokeStyle=Pi,t&&(s.beginPath(),s.strokeStyle=t.color||Pi,s.moveTo(t.position*r[2]+r[0],0),s.lineTo(t.position*r[2]+r[0],n),s.stroke()),e&&(s.beginPath(),s.strokeStyle=e.color||Pi,s.moveTo(0,e.position*r[2]+r[1]),s.lineTo(o,e.position*r[2]+r[1]),s.stroke())},[o,n,r,e,t]),Py("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as Ly,Notification as ky,TooltipProvider as Dy}from"lecom-ui";import{createContext as Ry,useContext as Oy,useEffect as Vy,useState as Hy}from"react";import{jsx as Bd,jsxs as By}from"react/jsx-runtime";var qe=new Map,zd=Ry(null),Li=()=>{let e=Oy(zd);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},Gy=({locale:e,defaultMode:t="view",showNotification:o=!0,children:n})=>{let[r,i]=Hy(e||"pt_BR");Vy(()=>{e&&(i(e),Ly.changeLanguage(e))},[e]);let a=h=>{let g=qe.size;if(g===0)throw new Error("No modeler instances found");if(g===1||!h){let[y]=qe.values();return y}let f=qe.get(h);if(!f)throw new Error(`Modeler instance with ID "${h}" not found`);return f},s=(h,g)=>{let f=a(g);return f==null?void 0:f.selectElements(h)},l=async h=>{let g=a(h);return g==null?void 0:g.clearSelection()},c=(h,g)=>{let f=a(g);return f==null?void 0:f.configureElement(h)},d=(h,g)=>{let f=a(g);return f==null?void 0:f.getConfigureElement(h)},u=async(h,g)=>{let f=a(g);await(f==null?void 0:f.importFromMxGraph(h))},p=h=>{let g=a(h);return g==null?void 0:g.exportToMxGraph()},m=h=>{let g=a(h);return(g==null?void 0:g.getElementsCount())||0};return Bd(zd.Provider,{value:{defaultMode:t,locale:r,selectElements:s,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:u,exportDiagram:p,getElementsCount:m},children:By(Dy,{children:[o&&Bd(ky,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};import{jsx as ki}from"react/jsx-runtime";var Fd=Fy(null),W=()=>{let e=Wy(Fd);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},Xy=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,onElementChanges:r,onConfigureElement:i,onElementClick:a,onSubprocessValidationClick:s})=>{let{defaultMode:l}=Li(),c=Uy(),[d]=$e(o||c),[u,p]=$e(n||l||"edit"),[m,h]=$e(Ko),[g,f]=$e(!1),[y,x]=$e(!0),[_,b]=$e(!1),[T,v]=$e(!1),[N,P]=$e(!1),[R,I]=$e(!1),[A,L]=$e(!1),[B,S]=$e(null);Yy(()=>{n&&p(n)},[n]);let M=$y(()=>t||Vl(),[t]),D={instanceId:d,initialDiagram:M,mode:u,lastElementId:m,isInitialized:g,isMinimapOpen:T,isMoveTool:y,isHandTool:_,isDragging:N,isMultipleSelection:A,isConnecting:R,setLastElementId:h,setIsInitialized:f,reconnectingEdgeId:B,setIsMinimapOpen:v,setIsMoveTool:x,setIsHandTool:b,setIsDragging:P,setIsConnecting:I,setIsMultipleSelection:L,setReconnectingEdgeId:S,onElementChanges:r,onConfigureElement:i,onElementClick:a,onSubprocessValidationClick:s};return ki(zy,{children:ki(Fd.Provider,{value:D,children:ki(Mi,{ref:e})})})};export{ke as EditorMode,Hr as ElementPosition,sn as ElementType,Gr as GatewayElementVariant,We as GatewayVariant,Xy as Modeler,Gy as ModelerProvider,nt as NodeAttribute,j as NodeType,Fe as NodeVariant,Br as RoutingVariant,Li as useModeler};
|
|
67
|
+
`),x.close()},"print")},isPrintingPng:n.png,isPrintingHtml:n.html,isPrinting:n.print}};import{jsx as Ee,jsxs as yo}from"react/jsx-runtime";function Md(){let{t:e}=Z0(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:a}=Sd(),[s,l]=ty(!1);return yo(X0,{modal:!1,open:s,onOpenChange:l,children:[Ee(q0,{asChild:!0,children:Ee("div",{children:yo(Ir,{children:[Ee(Sr,{asChild:!0,children:Ee($0,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:Ee(j0,{})})}),!s&&Ee(Cr,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),yo(K0,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[yo(Ir,{children:[Ee(Sr,{asChild:!0,children:Ee(Si,{className:"p-1.5",disabled:i,onClick:()=>t(),children:Ee(Q0,{})})}),Ee(Cr,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),yo(Ir,{children:[Ee(Sr,{asChild:!0,children:Ee(Si,{className:"p-1.5",disabled:a,onClick:()=>o(),children:Ee(J0,{})})}),Ee(Cr,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),yo(Ir,{children:[Ee(Sr,{asChild:!0,children:Ee(Si,{className:"p-1.5",disabled:r,onClick:()=>n(),children:Ee(ey,{})})}),Ee(Cr,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as kd,jsx as be,jsxs as ot}from"react/jsx-runtime";var Dd=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=ny(),{clearSelection:i}=ut(),{mode:a,isMinimapOpen:s,setIsMinimapOpen:l,isMoveTool:c,isHandTool:d,setIsMoveTool:u,setIsHandTool:p}=U(),{getNodes:f,getEdges:g}=oy(),x=Pd(["v","V"]),m=Pd(["h","H"]),E=Mi(()=>{i(),p(!0),u(!1)},[i,p,u]),y=Mi(()=>{u(!0),p(!1)},[u,p]),h=Mi(()=>{let _=f(),N=g(),T=o({nodes:_,edges:N});n(T)},[f,g,o,n]);return Ld(()=>{x&&!c&&a==="edit"&&y()},[x,y,c,a]),Ld(()=>{m&&!d&&a==="edit"&&E()},[m,E,d,a]),ot("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[a==="edit"&&ot(kd,{children:[ot(Pr,{children:[be(kr,{asChild:!0,children:be(Mr,{size:"small",variant:"ghost",color:"grey",className:k(c&&"bg-grey-400"),iconButton:!0,onClick:y,children:be(ay,{})})}),ot(Lr,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),be(Ii,{shortcut:"V"})]})]}),ot(Pr,{children:[be(kr,{asChild:!0,children:be(Mr,{size:"small",variant:"ghost",color:"grey",className:k(d&&"bg-grey-400"),iconButton:!0,onClick:E,children:be(ry,{})})}),ot(Lr,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",be(Ii,{shortcut:"H"})]})]})]}),be(Md,{}),a==="edit"&&ot(kd,{children:[ot(Pr,{children:[be(kr,{asChild:!0,children:be(Mr,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:h,children:be(iy,{})})}),be(Lr,{color:"black",children:r("editor.controls.actions.check")})]}),be(Id,{disabled:e.length>0||t.length>0})]}),ot(Pr,{children:[be(kr,{asChild:!0,children:be(Mr,{size:"small",variant:"ghost",color:"grey",className:k(s&&"bg-grey-400"),iconButton:!0,onClick:()=>l(!s),children:be(sy,{})})}),be(Lr,{color:"black",children:r(s?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as Rd,Tooltip as Od,TooltipContent as Vd,TooltipTrigger as Hd,useTranslation as ly}from"lecom-ui";import{RedoIcon as cy,UndoIcon as dy}from"lucide-react";import{jsx as Et,jsxs as Pi}from"react/jsx-runtime";var Gd=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=ly();return Pi("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Pi(Od,{children:[Et(Hd,{asChild:!0,children:Et(Rd,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:Et(dy,{})})}),Et(Vd,{color:"black",children:r("editor.controls.history.undo")})]}),Pi(Od,{children:[Et(Hd,{asChild:!0,children:Et(Rd,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:Et(cy,{})})}),Et(Vd,{color:"black",children:r("editor.controls.history.redo")})]})]})};import{useEdges as uy,useNodes as py,useReactFlow as fy}from"@xyflow/react";import{Button as Dr,Tooltip as Rr,TooltipContent as Or,TooltipTrigger as Vr,useTranslation as my}from"lecom-ui";import{ScanIcon as gy,ZoomIn as hy,ZoomOut as yy}from"lucide-react";import{jsx as Ae,jsxs as an}from"react/jsx-runtime";var Bd=()=>{let{t:e}=my(),t=py(),o=uy(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:a}=fy(),s=t.length===0&&o.length===0;return an("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[an(Rr,{children:[Ae(Vr,{asChild:!0,children:Ae(Dr,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>a(),children:Ae(gy,{})})}),Ae(Or,{color:"black",children:e("editor.controls.zoom.fit")})]}),an(Rr,{children:[Ae(Vr,{asChild:!0,children:Ae(Dr,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>r(),children:Ae(yy,{})})}),Ae(Or,{color:"black",children:e("editor.controls.zoom.out")})]}),an(Rr,{children:[Ae(Vr,{asChild:!0,children:Ae(Dr,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>i(1),children:Ae(Zi,{})})}),Ae(Or,{color:"black",children:e("editor.controls.zoom.reset")})]}),an(Rr,{children:[Ae(Vr,{asChild:!0,children:Ae(Dr,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>n(),children:Ae(hy,{})})}),Ae(Or,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{useNodes as xy}from"@xyflow/react";import{Button as Ey,Tooltip as by,TooltipContent as _y,TooltipTrigger as Ty,useTranslation as Ny}from"lecom-ui";import{useRef as vy,useState as wy}from"react";import{jsx as Ht,jsxs as zd}from"react/jsx-runtime";var Fd=()=>{let e=vy(null),{t}=Ny(),{setDraggableNode:o}=so(),n=xy(),{setIsDragging:r}=U(),[i,a]=wy(void 0),s=[{type:"START_EVENT",icon:fn,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:Gt,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:bo,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:ts,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:es,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:ji,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:zt,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:Ft,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:Bt,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:qi,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:un,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),a(Ht(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return zd("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[Ht("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:s.map((c,d)=>{let u=!ct(c.type,n),p=u?t("editor.toolbar.start_event_already_exists"):c.label;return zd(by,{children:[Ht(Ty,{asChild:!0,children:Ht(Ey,{className:k("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":u}),size:"small",variant:"ghost",color:"grey",draggable:!u,disabled:u,iconButton:!0,onDragStart:u?void 0:f=>l(f,c),children:Ht(c.icon,{})},d)}),Ht(_y,{color:"black",side:"right",children:p})]},d)})}),Ht("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{jsx as bt,jsxs as Li}from"react/jsx-runtime";var ki=My((e,t)=>{let{instanceId:o,mode:n,isMinimapOpen:r,isMoveTool:i,isHandTool:a}=U(),{nodes:s,edges:l,actions:c,events:d,components:u,controls:p}=ud();return Py(t,()=>({selectElements:c.selectElements,clearSelection:c.clearSelection})),Li("div",{className:"w-full h-full",children:[n==="edit"&&bt(Fd,{}),bt(fd,{}),Li(Cy,v(b({},d),{id:`modeler-${o}`,edges:l,nodes:s,nodeTypes:Nc,edgeTypes:vc,minZoom:Mc,maxZoom:Pc,panOnDrag:a||n!=="edit"?!0:kc,panOnScroll:!0,selectionOnDrag:!0,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!1,elementsSelectable:n!=="readonly"&&i,nodesConnectable:n==="edit"&&i,nodesDraggable:n==="edit"&&i,connectionLineComponent:Ec,selectionMode:Sy.Partial,multiSelectionKeyCode:"Shift",deleteKeyCode:"Delete",selectionKeyCode:null,defaultViewport:Lc,connectOnClick:!1,connectionRadius:30,proOptions:{hideAttribution:!0},children:[bt(Ay,{gap:Cc,size:Ic,color:Ac,bgColor:wc}),r&&bt(Iy,{pannable:!0,zoomable:!0,position:Sc,className:"shadow-md rounded-md"}),Li("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[n==="edit"&&bt(Gd,b({},p)),bt(Dd,{nodes:s,edges:l,validateDiagram:c.validateDiagram,handleValidationComplete:c.handleValidationComplete}),bt(Bd,{})]}),bt(u.HelperLines,{})]}))]})});ki.displayName="Editor";import{useStore as Ly}from"@xyflow/react";import{useEffect as ky,useRef as Dy}from"react";import{jsx as Oy}from"react/jsx-runtime";var Ry=e=>({width:e.width,height:e.height,transform:e.transform}),Di="rgba(51, 103, 217, 0.4)",Za=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=Ly(Ry),i=Dy(null);return ky(()=>{let a=i.current,s=a==null?void 0:a.getContext("2d");if(!s||!a)return;let l=window.devicePixelRatio;a.width=o*l,a.height=n*l,s.clearRect(0,0,o,n),s.scale(l,l),s.strokeStyle=Di,t&&(s.beginPath(),s.strokeStyle=t.color||Di,s.moveTo(t.position*r[2]+r[0],0),s.lineTo(t.position*r[2]+r[0],n),s.stroke()),e&&(s.beginPath(),s.strokeStyle=e.color||Di,s.moveTo(0,e.position*r[2]+r[1]),s.lineTo(o,e.position*r[2]+r[1]),s.stroke())},[o,n,r,e,t]),Oy("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as Vy,Notification as Hy,TooltipProvider as Gy}from"lecom-ui";import{createContext as By,useContext as zy,useEffect as Fy,useState as Wy}from"react";import{jsx as Wd,jsxs as Uy}from"react/jsx-runtime";var Ze=new Map,Yd=By(null),Ri=()=>{let e=zy(Yd);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},Yy=({locale:e,defaultMode:t="view",showNotification:o=!0,children:n})=>{let[r,i]=Wy(e||"pt_BR");Fy(()=>{e&&(i(e),Vy.changeLanguage(e))},[e]);let a=g=>{let x=Ze.size;if(x===0)throw new Error("No modeler instances found");if(x===1||!g){let[E]=Ze.values();return E}let m=Ze.get(g);if(!m)throw new Error(`Modeler instance with ID "${g}" not found`);return m},s=(g,x)=>{let m=a(x);return m==null?void 0:m.selectElements(g)},l=async g=>{let x=a(g);return x==null?void 0:x.clearSelection()},c=(g,x)=>{let m=a(x);return m==null?void 0:m.configureElement(g)},d=(g,x)=>{let m=a(x);return m==null?void 0:m.getConfigureElement(g)},u=async(g,x)=>{let m=a(x);await(m==null?void 0:m.importFromMxGraph(g))},p=g=>{let x=a(g);return x==null?void 0:x.exportToMxGraph()},f=g=>{let x=a(g);return(x==null?void 0:x.getElementsCount())||0};return Wd(Yd.Provider,{value:{defaultMode:t,locale:r,selectElements:s,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:u,exportDiagram:p,getElementsCount:f},children:Uy(Gy,{children:[o&&Wd(Hy,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};import{useTranslation as Qy}from"lecom-ui";import{jsx as Oi}from"react/jsx-runtime";var Ud=Xy(null),U=()=>{let e=Ky(Ud);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},jy=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,onElementChanges:r,onConfigureElement:i,onElementClick:a,onSubprocessValidationClick:s})=>{let{t:l}=Qy(),{defaultMode:c}=Ri(),d=Zy(),[u]=$e(o||d),[p,f]=$e(n||c||"edit"),[g,x]=$e(Zo),[m,E]=$e(!1),[y,h]=$e(!0),[_,N]=$e(!1),[T,A]=$e(!1),[M,R]=$e(!1),[I,D]=$e(!1),[C,L]=$e(!1),[V,w]=$e(null);qy(()=>{n&&f(n)},[n]);let P=Jy(()=>t||Bl(l),[t,l]),F={instanceId:u,initialDiagram:P,mode:p,lastElementId:g,isInitialized:m,isMinimapOpen:T,isMoveTool:y,isHandTool:_,isDragging:M,isMultipleSelection:C,isConnecting:I,setLastElementId:x,setIsInitialized:E,reconnectingEdgeId:V,setIsMinimapOpen:A,setIsMoveTool:h,setIsHandTool:N,setIsDragging:R,setIsConnecting:D,setIsMultipleSelection:L,setReconnectingEdgeId:w,onElementChanges:r,onConfigureElement:i,onElementClick:a,onSubprocessValidationClick:s};return Oi($y,{children:Oi(Ud.Provider,{value:F,children:Oi(ki,{ref:e})})})};export{ke as EditorMode,Br as ElementPosition,cn as ElementType,zr as GatewayElementVariant,We as GatewayVariant,jy as Modeler,Yy as ModelerProvider,Ke as NodeAttribute,ee as NodeType,Fe as NodeVariant,Fr as RoutingVariant,Ri as useModeler};
|