lecom-modeler 0.30.2 → 0.30.3
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 +13 -13
- package/lib/index.js +13 -13
- package/lib/style.min.css +1 -1
- package/package.json +2 -2
package/lib/index.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";var Kp=Object.create;var Wn=Object.defineProperty,qp=Object.defineProperties,Zp=Object.getOwnPropertyDescriptor,Jp=Object.getOwnPropertyDescriptors,Qp=Object.getOwnPropertyNames,Pr=Object.getOwnPropertySymbols,jp=Object.getPrototypeOf,ds=Object.prototype.hasOwnProperty,ua=Object.prototype.propertyIsEnumerable;var da=(e,t,o)=>t in e?Wn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,N=(e,t)=>{for(var o in t||(t={}))ds.call(t,o)&&da(e,o,t[o]);if(Pr)for(var o of Pr(t))ua.call(t,o)&&da(e,o,t[o]);return e},v=(e,t)=>qp(e,Jp(t));var Yt=(e,t)=>{var o={};for(var n in e)ds.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Pr)for(var n of Pr(e))t.indexOf(n)<0&&ua.call(e,n)&&(o[n]=e[n]);return o};var ef=(e,t)=>{for(var o in t)Wn(e,o,{get:t[o],enumerable:!0})},pa=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Qp(t))!ds.call(e,r)&&r!==o&&Wn(e,r,{get:()=>t[r],enumerable:!(n=Zp(t,r))||n.enumerable});return e};var tf=(e,t,o)=>(o=e!=null?Kp(jp(e)):{},pa(t||!e||!e.__esModule?Wn(o,"default",{value:e,enumerable:!0}):o,e)),of=e=>pa(Wn({},"__esModule",{value:!0}),e);var Kh={};ef(Kh,{EditorMode:()=>$e,ElementPosition:()=>kr,ElementType:()=>Fn,GatewayElementVariant:()=>Rr,GatewayVariant:()=>wt,Modeler:()=>$p,ModelerProvider:()=>Wp,NodeAttribute:()=>kt,NodeType:()=>se,NodeVariant:()=>pt,RoutingVariant:()=>Dr,useModeler:()=>Tn});module.exports=of(Kh);var us=e=>{if(typeof document=="undefined")return;let t=document.cookie.match(new RegExp(`(?:^|; )${e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")}=([^;]*)`));return t?decodeURIComponent(t[1]):void 0};var Lr=require("@produto-lecom/lecom-ui");var fa={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...",delete_pool_lane_error:"Cannot delete the pool or lane while there are elements inside it."},controls:{zoom:{fit:"Fit zoom",in:"Zoom in",out:"Zoom out",reset:"Reset zoom"},actions:{move_tool:"Select elements",hand_tool:"Navigate the diagram",check:"Check diagram",check_loading:"Validating diagram...",export:{title:"Export diagram",print:"Print",html:"Export as HTML",png:"Export as PNG",feedback:{empty:"Cannot export an empty diagram",error:"Error exporting diagram"}},import_governance:"Import diagram from Governance platform",minimap:{label:"Minimap",open:"Open minimap",close:"Hide minimap"}},history:{undo:"Undo",redo:"Redo"}},modals:{delete_elements:{title:"Delete elements",callout:"When deleting, the activity and routing settings will be deleted.",content:"Are you sure you want to delete?",confirm:"Delete",cancel:"Cancel"}},task_menu:{loop_not_allowed_when_connected_to_end:"Cannot create loop on activity connected to end event",script_not_allowed_when_connected_to_end:"Cannot transform to Script activity connected to end event",loop_not_allowed_when_subprocess:"Cannot create loop on subprocess",loop:"Activity with loop"}},validation:{success:{title:"Validation Successful",message:"The diagram was validated successfully with no errors."},errors:{title:"The diagram contains errors",subtitle:"Please review the following:",task_label_length:"Task name exceeds the maximum character limit",multiple_start_event_not_allowed:"Multiple start events are not allowed",task_flows_limit_exceeds:"The number of output connections exceeds the limit of two",duplicate_task_name:"There are multiple activities with the same name",flows_on_end_tasks_not_allowed:"Activities connected to end events cannot have other connections",conditions_flows_limit_exceeds:"Exclusive gateway has too many output connections (maximum of two)",task_label_empty:"One or more activities have no name",activity_name_invalid:"Activity name is invalid",final_activity_has_loop:"Final activities cannot have loops",nested_gateway:"Connecting gateways directly is not allowed",concurrent_initial_and_final_event:"The same activity cannot have both initial and final events",gateway_flow_to_event:"Connecting a gateway to an output event is not allowed",gateway_missing_output_streams:"The gateway does not have the correct number of outputs",events_nested:"Connecting events directly is not allowed",event_to_condition:"Connecting an event directly to a gateway is not allowed",script_in_final_activity:"Final activity cannot be a script type",subprocess_not_configured:"The subprocess reference is not properly configured",cannot_validate_subprocess_reference:"Could not validate whether the subprocess reference is configured",start_event_not_found:"At least one start event is required",end_event_not_found:"At least one end event is required"}},bpmn:{start_event:{variant:{default:"Start event"}},end_event:{variant:{default:"End event"}},annotation:{variant:{default:"Annotation"}},gateway:{menu:{title:"Change gateway type"},variant:{default:"Gateway",exclusive:"Exclusive gateway",parallel:"Parallel gateway",complex:"Complex gateway"}},task:{menu:{title:"Change task type"},variant:{default:"Task",script:"Script task",subprocess:"Subprocess"},attribute:{loop:"Task with loop"},label:{prefix:"Activity"},feedback:{label_empty:{prefix:"Activity name was automatically set to"},label_already_exists:{prefix:"The name",middle:"already exists. The name was changed to"},invalid_first_character:"Activity name must start with a letter or number"}},lane:{variant:{default:"Pool / Lane"}},unsupported:{variant:{default:"Unsupported element"}}},adapter:{governance:{error:{DEFAULT:"Error importing diagram",NO_FILE:"No file selected",EMPTY_FILE:"Empty file",INVALID_FILE:"Invalid file",CONTAIN_NO_CELLS:"No cells found to be imported",ALREADY_INITIALIZED:"It is not possible to import the diagram from the Governance platform, since the diagram has already been initialized"},success:{default:"The diagram was imported from the Governance platform successfully and without any incompatibility detected.",incompatible_cells:"The diagram was imported from the Governance platform with incompatibilities. To know more details, click on the button below."},report:{columns:{type:"Type",value:"Value",status:"Status"},status:{imported:"Imported",adapted:"Adapted",unsupported:"Unsupported"}},action:{download:"Download report"}}}}};var ma={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...",delete_pool_lane_error:"No se puede eliminar la piscina o carril mientras haya elementos dentro."},controls:{zoom:{fit:"Ajustar zoom",in:"Acercar",out:"Alejar",reset:"Restablecer zoom"},actions:{move_tool:"Seleccionar elementos",hand_tool:"Navegar por el diagrama",check:"Validar diagrama",check_loading:"Validando diagrama...",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"No es posible exportar un diagrama vac\xEDo",error:"Error al exportar diagrama"}},import_governance:"Importar diagrama de la plataforma Governance",minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Deshacer",redo:"Rehacer"}},modals:{delete_elements:{title:"Eliminar elementos",callout:"Al eliminar, las configuraciones de actividades y enrutamiento ser\xE1n eliminadas.",content:"\xBFEst\xE1s seguro de querer eliminar?",confirm:"Eliminar",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"No se puede crear bucle en actividad conectada al evento final",script_not_allowed_when_connected_to_end:"No se puede transformar a Script actividad conectada al evento final",loop_not_allowed_when_subprocess:"No se puede crear bucle en subproceso",loop:"Actividad con loop"}},validation:{success:{title:"Validaci\xF3n exitosa",message:"El diagrama ha sido validado correctamente sin errores."},errors:{title:"El diagrama contiene errores",subtitle:"Revise lo siguiente:",task_label_length:"El nombre de la actividad excede el l\xEDmite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"No se permite tener m\xE1s de un evento de inicio",task_flows_limit_exceeds:"El n\xFAmero de conexiones de salida supera el l\xEDmite de dos",duplicate_task_name:"Hay varias actividades con el mismo nombre",flows_on_end_tasks_not_allowed:"Las actividades conectadas a eventos finales no pueden tener otras conexiones",conditions_flows_limit_exceeds:"Compuerta exclusiva con exceso de conexiones de salida (m\xE1ximo de dos)",task_label_empty:"El nombre de una o m\xE1s actividades no ha sido completado",activity_name_invalid:"El nombre de la actividad no es v\xE1lido",final_activity_has_loop:"Las actividades finales no pueden tener bucles",nested_gateway:"No se permite conectar compuertas directamente",concurrent_initial_and_final_event:"Una misma actividad no puede tener eventos iniciales y finales",gateway_flow_to_event:"No se permite conectar una compuerta a un evento de salida",gateway_missing_output_streams:"La compuerta no tiene el n\xFAmero correcto de salidas",events_nested:"No se permite conectar eventos directamente",event_to_condition:"No se permite conectar un evento directamente a una compuerta",script_in_final_activity:"La actividad final no puede ser de tipo script",subprocess_not_configured:"La referencia al subproceso no est\xE1 configurada correctamente",cannot_validate_subprocess_reference:"No fue posible validar si la referencia al subproceso est\xE1 configurada",start_event_not_found:"Es necesario tener al menos un evento de inicio",end_event_not_found:"Es necesario tener al menos un evento final"}},bpmn:{start_event:{variant:{default:"Evento de inicio"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anotaci\xF3n"}},gateway:{menu:{title:"Cambiar tipo de compuerta"},variant:{default:"Compuerta",exclusive:"Compuerta exclusiva",parallel:"Compuerta paralela",complex:"Compuerta compleja"}},task:{menu:{title:"Cambiar tipo de tarea"},variant:{default:"Tarea",script:"Tarea de script",subprocess:"Subproceso"},attribute:{loop:"Tarea con bucle"},label:{prefix:"Actividad"},feedback:{label_empty:{prefix:"El nombre de la actividad se estableci\xF3 autom\xE1ticamente como"},label_already_exists:{prefix:"El nombre",middle:"ya existe. El nombre fue cambiado a"},invalid_first_character:"El nombre de la actividad debe comenzar con una letra o n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento no soportado"}}},adapter:{governance:{error:{DEFAULT:"Error al importar diagrama",NO_FILE:"No se ha seleccionado ning\xFAn archivo",EMPTY_FILE:"Archivo vac\xEDo",INVALID_FILE:"Archivo inv\xE1lido",CONTAIN_NO_CELLS:"No se encontraron c\xE9lulas para importar",ALREADY_INITIALIZED:"No es posible importar el diagrama de la plataforma Governance, ya que el diagrama ya ha sido iniciado"},success:{default:"El diagrama se ha importado de la plataforma Governance correctamente y sin ninguna incompatibilidad detectada.",incompatible_cells:"El diagrama se ha importado de la plataforma Governance con incompatibilidades. Para saber m\xE1s detalles, haz click en el bot\xF3n de abajo."},report:{columns:{type:"Tipo",value:"Valor",status:"Estado"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"No soportado"}},action:{download:"Descargar informe"}}}}};var ga={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...",delete_pool_lane_error:"N\xE3o \xE9 poss\xEDvel excluir a piscina ou raia enquanto houver elementos dentro dela."},controls:{zoom:{fit:"Ajustar o zoom",in:"Aumentar o zoom",out:"Diminuir o zoom",reset:"Resetar o zoom"},actions:{move_tool:"Selecionar elementos",hand_tool:"Navegar pelo diagrama",check:"Validar diagrama",check_loading:"Validando diagrama...",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"N\xE3o \xE9 poss\xEDvel exportar um diagrama vazio",error:"Erro ao exportar o diagrama"}},import_governance:"Importar diagrama da plataforma Governance",minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Desfazer",redo:"Refazer"}},modals:{delete_elements:{title:"Excluir elementos",callout:"Ao excluir, as configura\xE7\xF5es de atividades e roteamento ser\xE3o exclu\xEDdas.",content:"Deseja realmente excluir?",confirm:"Excluir",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel criar loop em atividade conectada ao evento final",script_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel transformar em Script atividade conectada ao evento final",loop_not_allowed_when_subprocess:"N\xE3o \xE9 poss\xEDvel criar loop em subprocesso",loop:"Atividade com loop"}},validation:{success:{title:"Diagrama v\xE1lidado com sucesso!",message:"Nenhum erro encontrado."},errors:{title:"O diagrama cont\xE9m erros",subtitle:"Veja abaixo o que precisa ser corrigido:",task_label_length:"O nome da atividade excede o limite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"N\xE3o \xE9 permitido ter mais de um evento de in\xEDcio",task_flows_limit_exceeds:"O n\xFAmero de conex\xF5es de sa\xEDda ultrapassa o limite de dois",duplicate_task_name:"H\xE1 v\xE1rias atividades com o mesmo nome",flows_on_end_tasks_not_allowed:"Atividades conectadas a eventos finais n\xE3o podem ter outras conex\xF5es",conditions_flows_limit_exceeds:"Gateway exclusivo com excesso de conex\xF5es de sa\xEDda (m\xE1ximo de dois)",task_label_empty:"O nome de uma ou mais atividades n\xE3o foi preenchido",activity_name_invalid:"O nome da atividade n\xE3o \xE9 v\xE1lido",final_activity_has_loop:"Atividades finais n\xE3o podem ter loops",nested_gateway:"N\xE3o \xE9 permitido conectar gateways",concurrent_initial_and_final_event:"Uma mesma atividade n\xE3o pode ter eventos iniciais e finais",gateway_flow_to_event:"N\xE3o \xE9 permitido conectar um gateway a um evento de sa\xEDda",gateway_missing_output_streams:"O gateway n\xE3o possui o n\xFAmero correto de sa\xEDdas",events_nested:"N\xE3o \xE9 permitido conectar eventos",event_to_condition:"N\xE3o \xE9 permitido conectar um evento diretamente em um gateway",script_in_final_activity:"Atividade final n\xE3o pode ser do tipo script",subprocess_not_configured:"A refer\xEAncia ao subprocesso n\xE3o est\xE1 configurada corretamente",cannot_validate_subprocess_reference:"N\xE3o foi poss\xEDvel validar se a refer\xEAncia ao subprocesso est\xE1 configurada",start_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento inicial",end_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento final"}},bpmn:{start_event:{variant:{default:"Evento inicial"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anota\xE7\xE3o"}},gateway:{menu:{title:"Alterar tipo de gateway"},variant:{default:"Gateway",exclusive:"Gateway exclusivo",parallel:"Gateway paralelo",complex:"Gateway complexo"}},task:{menu:{title:"Alterar tipo de Atividade"},variant:{default:"Atividade",script:"Atividade de script",subprocess:"Subprocesso"},attribute:{loop:"Atividade com loop"},label:{prefix:"Atividade"},feedback:{label_empty:{prefix:"O nome da atividade foi definido automaticamente como"},label_already_exists:{prefix:"O nome",middle:"j\xE1 existe. O nome foi alterado para"},invalid_first_character:"O nome da atividade deve come\xE7ar com uma letra ou n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento n\xE3o suportado"}}},adapter:{governance:{error:{DEFAULT:"Erro ao importar diagrama",NO_FILE:"Nenhum arquivo selecionado",EMPTY_FILE:"Arquivo vazio",INVALID_FILE:"Arquivo inv\xE1lido",CONTAIN_NO_CELLS:"N\xE3o foram encontradas c\xE9lulas para serem importadas",ALREADY_INITIALIZED:"N\xE3o \xE9 poss\xEDvel importar o diagrama da plataforma Governance, pois o diagrama j\xE1 foi iniciado"},success:{default:"O diagrama foi importado da plataforma Governance com sucesso e sem nenhuma incompatibilidade detectada.",incompatible_cells:"O diagrama foi importado da plataforma Governance com incompatibilidades. Para saber mais detalhes, clique no bot\xE3o abaixo."},report:{columns:{type:"Tipo do elemento",value:"Valor",status:"Status"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"N\xE3o suportado"}},action:{download:"Baixar relat\xF3rio"}}}}};var ha={pt_BR:ga,en_US:fa,es_ES:ma};var ya,xa,nf=(xa=(ya=us("LecomUserLanguage"))!=null?ya:us("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?xa:Lr.Translations.PT_BR;(0,Lr.initializeI18n)({lng:nf,resources:ha});var $e=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))($e||{});var Fn=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(Fn||{}),kr=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(kr||{}),Rr=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Rr||{}),Dr=(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))(Dr||{});var fn=require("lucide-react");var ko=require("react/jsx-runtime"),Or=({size:e=24,className:t})=>(0,ko.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[(0,ko.jsx)("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),(0,ko.jsx)("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),(0,ko.jsx)("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),(0,ko.jsx)("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});var ps=require("react/jsx-runtime"),rn=({size:e=24,className:t})=>(0,ps.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#ff6565",stroke:"#ec1616",strokeWidth:3,className:t,children:(0,ps.jsx)("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});var mo=require("react/jsx-runtime"),sn=({size:e=24,className:t})=>(0,mo.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:2,className:t,children:[(0,mo.jsx)("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,mo.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,mo.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,mo.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,mo.jsx)("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var an=require("react/jsx-runtime"),ln=({size:e=24,className:t})=>(0,an.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:2,className:t,children:[(0,an.jsx)("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,an.jsx)("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,an.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var cn=require("react/jsx-runtime"),dn=({size:e=24,className:t})=>(0,cn.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:2,className:t,children:[(0,cn.jsx)("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,cn.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,cn.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});var un=require("react/jsx-runtime"),Ea=({size:e=24,className:t})=>(0,un.jsx)("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:(0,un.jsxs)("g",{children:[(0,un.jsx)("path",{d:"M8.6543 11.4141V15.2148C8.51302 15.4017 8.29199 15.6068 7.99121 15.8301C7.69499 16.0488 7.30078 16.238 6.80859 16.3975C6.31641 16.557 5.70345 16.6367 4.96973 16.6367C4.34538 16.6367 3.77344 16.5319 3.25391 16.3223C2.73438 16.1081 2.28548 15.7959 1.90723 15.3857C1.53353 14.9756 1.24414 14.4766 1.03906 13.8887C0.833984 13.2962 0.731445 12.6217 0.731445 11.8652V11.1748C0.731445 10.4229 0.82487 9.75293 1.01172 9.16504C1.20312 8.57259 1.47656 8.07129 1.83203 7.66113C2.1875 7.25098 2.61589 6.94108 3.11719 6.73145C3.62305 6.51725 4.19499 6.41016 4.83301 6.41016C5.64876 6.41016 6.32324 6.54688 6.85645 6.82031C7.39421 7.08919 7.80892 7.46289 8.10059 7.94141C8.39225 8.41992 8.57682 8.9668 8.6543 9.58203H6.97266C6.91797 9.23568 6.81087 8.92578 6.65137 8.65234C6.49642 8.37891 6.27311 8.16471 5.98145 8.00977C5.69434 7.85026 5.32064 7.77051 4.86035 7.77051C4.46387 7.77051 4.11523 7.8457 3.81445 7.99609C3.51367 8.14648 3.26302 8.36751 3.0625 8.65918C2.86654 8.95085 2.71842 9.30632 2.61816 9.72559C2.5179 10.1449 2.46777 10.6234 2.46777 11.1611V11.8652C2.46777 12.4121 2.52474 12.8975 2.63867 13.3213C2.75716 13.7451 2.92578 14.1029 3.14453 14.3945C3.36784 14.6862 3.639 14.9072 3.95801 15.0576C4.27702 15.2035 4.63704 15.2764 5.03809 15.2764C5.43001 15.2764 5.7513 15.2445 6.00195 15.1807C6.2526 15.1123 6.45085 15.0326 6.59668 14.9414C6.74707 14.8457 6.86328 14.7546 6.94531 14.668V12.6924H4.87402V11.4141H8.6543ZM17.0912 11.25V11.7969C17.0912 12.5488 16.9932 13.2233 16.7973 13.8203C16.6013 14.4173 16.321 14.9255 15.9564 15.3447C15.5964 15.764 15.1635 16.0853 14.6576 16.3086C14.1518 16.5273 13.5912 16.6367 12.976 16.6367C12.3653 16.6367 11.807 16.5273 11.3012 16.3086C10.7999 16.0853 10.3646 15.764 9.99551 15.3447C9.62637 14.9255 9.33926 14.4173 9.13418 13.8203C8.93366 13.2233 8.8334 12.5488 8.8334 11.7969V11.25C8.8334 10.498 8.93366 9.82585 9.13418 9.2334C9.3347 8.63639 9.61725 8.12826 9.98184 7.70898C10.351 7.28516 10.7862 6.96387 11.2875 6.74512C11.7934 6.52181 12.3516 6.41016 12.9623 6.41016C13.5775 6.41016 14.1381 6.52181 14.6439 6.74512C15.1498 6.96387 15.585 7.28516 15.9496 7.70898C16.3142 8.12826 16.5945 8.63639 16.7904 9.2334C16.991 9.82585 17.0912 10.498 17.0912 11.25ZM15.3754 11.7969V11.2363C15.3754 10.6803 15.3207 10.1904 15.2113 9.7666C15.1065 9.33822 14.9493 8.98047 14.7396 8.69336C14.5346 8.40169 14.2816 8.18294 13.9809 8.03711C13.6801 7.88672 13.3406 7.81152 12.9623 7.81152C12.584 7.81152 12.2468 7.88672 11.9506 8.03711C11.6544 8.18294 11.4014 8.40169 11.1918 8.69336C10.9867 8.98047 10.8295 9.33822 10.7201 9.7666C10.6107 10.1904 10.5561 10.6803 10.5561 11.2363V11.7969C10.5561 12.3529 10.6107 12.8451 10.7201 13.2734C10.8295 13.7018 10.989 14.0641 11.1986 14.3604C11.4128 14.652 11.668 14.873 11.9643 15.0234C12.2605 15.1693 12.5977 15.2422 12.976 15.2422C13.3588 15.2422 13.6983 15.1693 13.9945 15.0234C14.2908 14.873 14.5414 14.652 14.7465 14.3604C14.9516 14.0641 15.1065 13.7018 15.2113 13.2734C15.3207 12.8451 15.3754 12.3529 15.3754 11.7969ZM20.6678 14.6816L23.2859 6.54688H25.1795L21.6111 16.5H20.3328L20.6678 14.6816ZM18.2479 6.54688L20.8455 14.6816L21.201 16.5H19.9158L16.3611 6.54688H18.2479Z"}),(0,un.jsx)("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});var ba=require("clsx"),_a=require("tailwind-merge");function H(...e){return(0,_a.twMerge)((0,ba.clsx)(e))}var go=(e=0,t=0)=>e<t?t:e,Vr=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});var Xn=require("react/jsx-runtime"),Na=({size:e=24,className:t})=>(0,Xn.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:H("stroke-2",t),children:[(0,Xn.jsx)("path",{d:"M19 3H5C3.89543 3 3 3.89543 3 5V19C3 20.1046 3.89543 21 5 21H19C20.1046 21 21 20.1046 21 19V5C21 3.89543 20.1046 3 19 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Xn.jsx)("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});var Hr=require("react/jsx-runtime"),Ta=({size:e=24,className:t})=>(0,Hr.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:(0,Hr.jsx)("g",{children:(0,Hr.jsx)("path",{d:"M4.85372 6.17472L5.31292 5.71552L5.31993 5.70863C6.88908 4.1924 8.98352 3.34122 11.1655 3.33301L11.1668 3.33301C11.167 3.33301 11.1673 3.33301 11.1675 3.33301C12.7165 3.33314 14.2308 3.79255 15.5188 4.65317C16.807 5.5139 17.811 6.7373 18.4039 8.16866C18.9968 9.60001 19.1519 11.175 18.8497 12.6945C18.5986 13.9567 18.0414 15.1334 17.232 16.1236L16.9457 16.4738L17.2655 16.7936L20.6617 20.1899L20.6617 20.1899C20.7919 20.3201 20.7919 20.5311 20.6617 20.6612L20.6616 20.6613C20.5316 20.7915 20.3205 20.7915 20.1903 20.6613L16.7941 17.265L16.4743 16.9452L16.1241 17.2315C15.1339 18.0409 13.9571 18.5981 12.695 18.8492C11.1755 19.1514 9.6005 18.9963 8.16915 18.4034C6.73778 17.8105 5.51439 16.8065 4.65365 15.5183C3.79291 14.2301 3.3335 12.7156 3.3335 11.1663C3.3335 10.9822 3.48273 10.833 3.66683 10.833C3.85093 10.833 4.00016 10.9822 4.00016 11.1663C4.00016 12.5838 4.42048 13.9694 5.20796 15.148C5.99545 16.3265 7.11474 17.245 8.42426 17.7874C9.73378 18.3299 11.1748 18.4719 12.565 18.1953C13.9552 17.9188 15.2321 17.2362 16.2344 16.234L16.2345 16.234C17.2367 15.2316 17.9193 13.9547 18.1958 12.5645C18.4724 11.1743 18.3304 9.7333 17.7879 8.42378C17.2455 7.11426 16.327 5.99497 15.1484 5.20748L14.8707 5.62322L15.1484 5.20748C13.9703 4.42031 12.5854 4.00001 11.1685 3.99968L11.1664 3.99969C9.15876 4.00767 7.23176 4.7903 5.78712 6.18424L5.78706 6.18418L5.78075 6.1905L5.32512 6.64613L4.47156 7.49968H5.67867H7.8335C8.01759 7.49968 8.16683 7.64892 8.16683 7.83302C8.16683 8.01711 8.01759 8.16635 7.8335 8.16635H3.66683C3.48274 8.16635 3.3335 8.01711 3.3335 7.83302V3.66635C3.3335 3.48225 3.48274 3.33302 3.66683 3.33302C3.85092 3.33302 4.00016 3.48225 4.00016 3.66635V5.82117V7.02827L4.85372 6.17472Z"})})});var fs=require("react/jsx-runtime"),Gr=({size:e=24,className:t})=>(0,fs.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#5fd9b0",stroke:"#1cad86",strokeWidth:"2",className:t,children:(0,fs.jsx)("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});var ms=require("react/jsx-runtime"),Un=({size:e=24,className:t})=>(0,ms.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",className:H("stroke-2",t),children:(0,ms.jsx)("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"})});var pn=require("react/jsx-runtime"),va=({size:e=24,className:t})=>(0,pn.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[(0,pn.jsx)("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,pn.jsx)("path",{d:"M7.5 12C7.5 12.89 7.76392 13.76 8.25839 14.5001C8.75285 15.2401 9.45566 15.8169 10.2779 16.1575C11.1002 16.4981 12.005 16.5872 12.8779 16.4135C13.7508 16.2399 14.5526 15.8113 15.182 15.182C15.8113 14.5526 16.2399 13.7508 16.4135 12.8779C16.5872 12.005 16.4981 11.1002 16.1575 10.2779C15.8169 9.45566 15.2401 8.75285 14.5001 8.25839C13.76 7.76392 12.89 7.5 12 7.5C10.742 7.50473 9.53448 7.99561 8.63 8.87L7.5 10",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,pn.jsx)("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});var ho=require("react/jsx-runtime"),wa=({size:e=24,className:t})=>(0,ho.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[(0,ho.jsx)("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ho.jsx)("path",{d:"M15.5 14.5V8.5C15.5 8.23478 15.3946 7.98043 15.2071 7.79289C15.0196 7.60536 14.7652 7.5 14.5 7.5H8",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ho.jsx)("path",{d:"M10 16.5H16C16.2652 16.5 16.5196 16.3946 16.7071 16.2071C16.8946 16.0196 17 15.7652 17 15.5V15C17 14.8674 16.9473 14.7402 16.8536 14.6464C16.7598 14.5527 16.6326 14.5 16.5 14.5H11.5C11.3674 14.5 11.2402 14.5527 11.1464 14.6464C11.0527 14.7402 11 14.8674 11 15V15.5C11 15.7652 10.8946 16.0196 10.7071 16.2071C10.5196 16.3946 10.2652 16.5 10 16.5ZM10 16.5C9.73478 16.5 9.48043 16.3946 9.29289 16.2071C9.10536 16.0196 9 15.7652 9 15.5V8.5C9 8.23478 8.89464 7.98043 8.70711 7.79289C8.51957 7.60536 8.26522 7.5 8 7.5C7.73478 7.5 7.48043 7.60536 7.29289 7.79289C7.10536 7.98043 7 8.23478 7 8.5V9.5C7 9.63261 7.05268 9.75979 7.14645 9.85355C7.24021 9.94732 7.36739 10 7.5 10H9",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ho.jsx)("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ho.jsx)("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var Ro=require("react/jsx-runtime"),Ia=({size:e=24,className:t})=>(0,Ro.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:2,className:t,children:[(0,Ro.jsx)("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Ro.jsx)("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),(0,Ro.jsx)("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Ro.jsx)("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var se=(s=>(s.START_EVENT="START_EVENT",s.END_EVENT="END_EVENT",s.TASK="TASK",s.LANE="LANE",s.GATEWAY="GATEWAY",s.ANNOTATION="ANNOTATION",s.UNSUPPORTED="UNSUPPORTED",s))(se||{}),pt=(o=>(o.SCRIPT="SCRIPT",o.SUBPROCESS="SUBPROCESS",o))(pt||{}),Br={SCRIPT:{icon:fn.ScrollText},SUBPROCESS:{icon:fn.SquarePlus}},kt=(t=>(t.LOOP="LOOP",t))(kt||{}),zr={LOOP:{icon:fn.RotateCcw}},wt=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(wt||{}),gs={EXCLUSIVE:{icon:ln},PARALLEL:{icon:dn},COMPLEX:{icon:sn}};var Fp=require("@produto-lecom/lecom-ui"),Xp=require("@xyflow/react"),Ge=require("react");var to=require("@xyflow/react"),Mo=require("react");var ip=require("@produto-lecom/lecom-ui"),Qt=require("@xyflow/react"),Lt=require("react");var mn=require("@xyflow/react");function Aa(e,t){var b,T,E,y;let{width:o=0,height:n=0}=e.measured||{width:0,height:0},r=e.internals.positionAbsolute,i=t.internals.positionAbsolute,a=o/2,s=n/2,l=r.x+a,c=r.y+s,d=i.x+((T=(b=t==null?void 0:t.measured)==null?void 0:b.width)!=null?T:0)/2,u=i.y+((y=(E=t==null?void 0:t.measured)==null?void 0:E.height)!=null?y:0)/2,m=(d-l)/(2*a)-(u-c)/(2*s),p=(d-l)/(2*a)+(u-c)/(2*s),g=1/(Math.abs(m)+Math.abs(p)||1),x=g*m,f=g*p,h=a*(x+f)+l,_=s*(-x+f)+c;return{x:h,y:_}}function Ca(e,t){var c,d,u,m;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(m=(u=e.measured)==null?void 0:u.height)!=null?m:0,i=Math.round(o.x),a=Math.round(o.y),s=Math.round(t.x),l=Math.round(t.y);return s<=i+1?mn.Position.Left:s>=i+n-1?mn.Position.Right:l<=a+1?mn.Position.Top:l>=a+r-1?mn.Position.Bottom:mn.Position.Top}function gn(e,t){let o=Aa(e,t),n=Aa(t,e),r=Ca(e,o),i=Ca(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function Yr(e,t){return{isFromStartEvent:(e==null?void 0:e.type)==="START_EVENT",isGatewayToGateway:(e==null?void 0:e.type)==="GATEWAY"&&(t==null?void 0:t.type)==="GATEWAY",isActiviyToAndGateway:(e==null?void 0:e.type)==="TASK"&&(t==null?void 0:t.type)==="GATEWAY",isToEndEvent:(t==null?void 0:t.type)==="END_EVENT"}}var Wr={MIN_WIDTH:36,MIN_HEIGHT:36},Fr={MIN_WIDTH:36,MIN_HEIGHT:36},Xr={MIN_WIDTH:56,MIN_HEIGHT:56},hn={MIN_WIDTH:176,MIN_HEIGHT:96},Sa={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},ie={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},yn={MIN_WIDTH:176,MIN_HEIGHT:64},rf={MIN_WIDTH:128,MIN_HEIGHT:64},pe={START_EVENT:Wr,END_EVENT:Fr,GATEWAY:Xr,TASK:hn,LANE:ie,ANNOTATION:yn,UNSUPPORTED:rf};var Ma=require("lodash");var Pa=e=>new Map(e.map(t=>[t.id,t])),La=(e,t)=>e.map(o=>{var n;return(n=t.get(o.id))!=null?n:o}),It=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}},Do=e=>(0,Ma.orderBy)(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),ka=(e,t)=>{let{x:o,y:n}=It(e),{x:r,y:i}=It(t);return{x:o-r,y:n-i}};var Oo=({parentId:e,nodes:t,includeTypes:o=[...Object.values(se)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),sf=(e,t)=>{let{x:o,y:n}=It(e),{x:r,y:i}=It(t),a=o-r,s=n-i;return Math.sqrt(a*a+s*s)},af=(e,t)=>{let{x:o,y:n,w:r,h:i}=It(e),{x:a,y:s,w:l,h:c}=It(t),d=o+r/2,u=n+i/2;return d>=a&&d<=a+l&&u>=s&&u<=s+c},$n=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&af(e,r)){let i=sf(e,r);i<n&&(n=i,o=r)}return o},Ra=(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),Da=(e,t)=>{let o=e.filter(c=>!c.parentId);if(o.length===0)return{nodes:e,edges:t};let n=o.filter(c=>c.type==="LANE"),r=n.length>0?n:o,i=Math.min(...r.map(c=>c.position.x||0)),a=Math.min(...r.map(c=>c.position.y||0)),s=e.map(c=>c.parentId?c:v(N({},c),{position:{x:c.position.x-i,y:c.position.y-a}})),l=t.map(c=>{let d=c.data;return d!=null&&d.points?v(N({},c),{data:v(N({},d),{points:d.points.map(u=>({x:u.x-i,y:u.y-a}))})}):c});return{nodes:s,edges:l}},Oa=e=>{var l,c;let t=e.filter(d=>!d.parentId),o=t.filter(d=>d.type==="LANE"),n=o.length>0?o:t;if(n.length===0)return null;let r=1/0,i=1/0,a=-1/0,s=-1/0;for(let d of n){let u=d.position.x+((l=d.width)!=null?l:0),m=d.position.y+((c=d.height)!=null?c:0);d.position.x<r&&(r=d.position.x),d.position.y<i&&(i=d.position.y),u>a&&(a=u),m>s&&(s=m)}return{x:r,y:i,width:a-r,height:s-i}};var hs=(e,t)=>{let o=t.find(a=>a.id===e);if(!o||o.type!=="LANE"||o.parentId)return!1;let n=It(o),r=n.x+n.w,i=n.y+n.h;return t.some(a=>{if(a.id===e||a.parentId||a.type==="LANE")return!1;let s=It(a);return s.x<r&&s.x+s.w>n.x&&s.y<i&&s.y+s.h>n.y})};var lf=50,Vo=(e,t)=>{var m,p,g,x,f,h,_,b,T,E,y,w,C,A,R,G;let o=t.find(M=>M.id===e);if(!o)return t;let n=(p=(m=o.position)==null?void 0:m.x)!=null?p:0,r=(x=(g=o.position)==null?void 0:g.y)!=null?x:0,i=(h=(f=o.measured)==null?void 0:f.width)!=null?h:0,a=(b=(_=o.measured)==null?void 0:_.height)!=null?b:0,s=r+a,l=n+i,c=new Set,d=1/0;for(let M of t){if(M.id===e||M.parentId)continue;let P=(E=(T=M.position)==null?void 0:T.y)!=null?E:0,X=(w=(y=M.position)==null?void 0:y.x)!=null?w:0,$=(A=(C=M.measured)==null?void 0:C.width)!=null?A:0,Z=(G=(R=M.measured)==null?void 0:R.height)!=null?G:0;X<l&&X+$>n&&P<s&&P+Z>r&&(c.add(M.id),d=Math.min(d,P))}if(c.size===0)return t;let u=s+lf-d;return t.map(M=>{var X,$,Z;if(!c.has(M.id))return M;let P=($=(X=M.position)==null?void 0:X.y)!=null?$:0;return v(N({},M),{position:v(N({},(Z=M.position)!=null?Z:{x:0,y:0}),{y:P+u})})})},De=15,Ho=e=>[...e].sort((t,o)=>t.position.y-o.position.y),cf=e=>{var t,o,n;return e.position.x+((n=(o=(t=e.measured)==null?void 0:t.width)!=null?o:e.width)!=null?n:0)},df=e=>{var t,o,n;return e.position.y+((n=(o=(t=e.measured)==null?void 0:t.height)!=null?o:e.height)!=null?n:0)},ys=(e,t,o)=>{var d,u,m,p,g,x,f,h,_,b,T,E,y,w,C;if(t.length===0)return e;let n=(m=(u=e.width)!=null?u:(d=e.measured)==null?void 0:d.width)!=null?m:0,r=(x=(g=e.height)!=null?g:(p=e.measured)==null?void 0:p.height)!=null?x:0,i=0,a=0;for(let A of t){let R=cf(A),G=df(A);if(((h=(f=A.position)==null?void 0:f.y)!=null?h:0)<De&&(o.set(A.id,v(N({},A),{position:v(N({},A.position),{y:De})})),G=De+((b=(_=A.measured)==null?void 0:_.height)!=null?b:0)),((E=(T=A.position)==null?void 0:T.x)!=null?E:0)<ie.HEADER_WIDTH+De){let M=(y=o.get(A.id))!=null?y:A;o.set(A.id,v(N({},M),{position:v(N({},M.position),{x:ie.HEADER_WIDTH+De})})),R=ie.HEADER_WIDTH+De+((C=(w=A.measured)==null?void 0:w.width)!=null?C:0)}i=Math.max(i,R),a=Math.max(a,G)}let s=Math.max(n,ie.MIN_WIDTH),l=Math.max(r,ie.MIN_HEIGHT);i+De>s&&(s=i+De),a+De>l&&(l=a+De);let c=v(N({},e),{width:s,height:l,measured:v(N({},e.measured),{width:s,height:l})});return o.set(e.id,c),c},Va=(e,t,o)=>{var a,s;let n=Ho(e),r=new Map;for(let l of o)l.parentId&&(r.has(l.parentId)||r.set(l.parentId,[]),r.get(l.parentId).push(l));let i=0;for(let l of n){let c=(a=r.get(l.id))!=null?a:[],d=ys(l,c,t);t.set(d.id,v(N({},d),{position:{x:ie.HEADER_WIDTH,y:i}})),i+=(s=d.height)!=null?s:0}},Ha=(e,t)=>{var g,x,f,h;let o=[];for(let _ of t.values())_.parentId===e.id&&o.push(_);let n=Ho(o),r=((x=(g=e.measured)==null?void 0:g.width)!=null?x:0)-ie.HEADER_WIDTH,i=Ra(e.id,o)||ie.MIN_WIDTH,a=o.reduce((_,b)=>{var T;return _+((T=b.height)!=null?T:ie.MIN_HEIGHT)},0),s=Math.max(r,i),l=a,c=r>i,d=c?s:s+ie.HEADER_WIDTH,u=c?s-ie.HEADER_WIDTH:s,m=0;for(let _=0;_<n.length;_++){let b=n[_],T=Math.max(ie.MIN_HEIGHT,(f=b.height)!=null?f:ie.MIN_HEIGHT),E=v(N({},b),{width:u,height:T,measured:v(N({},b.measured),{width:u,height:T}),position:{x:ie.HEADER_WIDTH,y:m}});if(_===o.length-1){let y=Math.max(ie.MIN_HEIGHT,l-m);E=v(N({},E),{height:y,measured:v(N({},b.measured),{width:u,height:y})})}t.set(b.id,E),m+=(h=E.height)!=null?h:0}let p=Math.max(l,m);t.set(e.id,v(N({},e),{width:d,height:p,measured:v(N({},e.measured),{width:d,height:p})}))},Ga=(e,t,o,n,r)=>{var g,x;let i=!e.parentId,a=i?e.id:e.parentId,s=n.filter(f=>f.type==="LANE"&&f.parentId===a);if(!s.length)return n;let l=Ho(s),c=l.findIndex(f=>f.id===e.id),d=(x=(g=e.position)==null?void 0:g.y)!=null?x:0,u=!i&&r!==void 0&&c>0&&Math.abs(r-d)>.5,m=0,p=[...n];return l.forEach((f,h)=>{var y,w;let _=h===l.length-1,b=f.id===e.id,E=(w=(y=f.measured)==null?void 0:y.height)!=null?w:0;b?E=o:u&&h===c-1&&(E=Math.max(ie.MIN_HEIGHT,r-m)),_&&i&&(E=Math.max(ie.MIN_HEIGHT,o-m)),p=p.map(C=>{if(C.id===f.id){let A=i?t-ie.HEADER_WIDTH:t;return v(N({},C),{width:A,height:E,measured:v(N({},C.measured),{width:A,height:E}),position:{x:ie.HEADER_WIDTH,y:m}})}return C}),b&&u?m=r+o:m+=E}),p=p.map(f=>{if(f.id===a){let h=i?t:t+ie.HEADER_WIDTH;return v(N({},f),{width:h,height:i?o:m,measured:{width:h,height:i?o:m}})}return f}),p};var xs=(e,t,o)=>{var s,l,c,d,u,m,p,g;if(e.type==="LANE")return o;let n=(l=(s=t.measured)==null?void 0:s.width)!=null?l:0,r=(d=(c=t.measured)==null?void 0:c.height)!=null?d:0;e.position.y<De&&(e.position.y=De),e.position.x<ie.HEADER_WIDTH+De&&(e.position.x=ie.HEADER_WIDTH+De);let i=e.position.x+((m=(u=e.measured)==null?void 0:u.width)!=null?m:0),a=e.position.y+((g=(p=e.measured)==null?void 0:p.height)!=null?g:0);return i+De>n&&(t.width=i+De,t.measured.width=i+De),a+De>r&&(t.height=a+De,t.measured.height=a+De),o=o.map(x=>x.id===t.id?v(N({},x),{height:t.height,width:t.width,measured:t.measured}):x.id===e.id?v(N({},x),{position:e.position}):x),o};var Ba=require("zustand"),za=require("@xyflow/react"),Ya=require("react");var Ur=()=>{let{setEdges:e}=(0,za.useReactFlow)();return(0,Ya.useCallback)(()=>{let o=Go.getState().pathEdgeIds;e(n=>n.map(r=>v(N({},r),{selected:o.includes(r.id)})))},[e])},Go=(0,Ba.create)((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=N({},n.statusByNodeId),i=N({},n.statusData),a=!1;return o.forEach(s=>{let l=`${s.diagramId}-${s.activityId}`;r[s.diagramId]!==s.status&&(r[s.diagramId]=s.status,i[l]=s,a=!0)}),a?{statusByNodeId:r,statusData:i}:n})},getTaskStatus:o=>t().statusByNodeId[o]||null,clearTaskStatuses:()=>e({statusByNodeId:{},statusData:{},pathEdgeIds:[]}),setPathEdges:o=>{e({pathEdgeIds:o})},getPathEdgeIds:()=>t().pathEdgeIds,clearPathEdges:()=>{e({pathEdgeIds:[]})},calculateFlowPath:(o,n)=>{if(!o.length||!n.length)return;t().clearPathEdges();let r=n.filter(d=>t().statusByNodeId[d]);if(r.length<=1)return;let i=[],a={};o.forEach(d=>{a[d.source]||(a[d.source]=[]),a[d.source].push({targetId:d.target,edgeId:d.id})});let s=r[0],l=r[r.length-1];o.forEach(d=>{d.target===s&&i.push(d.id)}),o.forEach(d=>{d.source===l&&i.push(d.id)});let c=(d,u)=>{let m=[],p=new Set;for(m.push({node:d,path:[]}),p.add(d);m.length>0;){let{node:g,path:x}=m.shift();if(g===u)return x;let f=a[g]||[];for(let{targetId:h,edgeId:_}of f)p.has(h)||(p.add(h),m.push({node:h,path:[...x,_]}))}return[]};for(let d=0;d<r.length-1;d++){let u=r[d],m=r[d+1],p=c(u,m);p.length>0&&i.push(...p)}i.length>0&&e({pathEdgeIds:i})}}));var Nn=require("@xyflow/react"),ft=require("react"),Oc=require("zustand/shallow");var uf={value:()=>{}};function Fa(){for(var e=0,t=arguments.length,o={},n;e<t;++e){if(!(n=arguments[e]+"")||n in o||/[\s.]/.test(n))throw new Error("illegal type: "+n);o[n]=[]}return new $r(o)}function $r(e){this._=e}function pf(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}})}$r.prototype=Fa.prototype={constructor:$r,on:function(e,t){var o=this._,n=pf(e+"",o),r,i=-1,a=n.length;if(arguments.length<2){for(;++i<a;)if((r=(e=n[i]).type)&&(r=ff(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]=Wa(o[r],e.name,t);else if(t==null)for(r in o)o[r]=Wa(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 $r(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 ff(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function Wa(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=uf,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var Es=Fa;var Kr="http://www.w3.org/1999/xhtml",bs={svg:"http://www.w3.org/2000/svg",xhtml:Kr,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ro(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),bs.hasOwnProperty(t)?{space:bs[t],local:e}:e}function mf(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===Kr&&t.documentElement.namespaceURI===Kr?t.createElement(e):t.createElementNS(o,e)}}function gf(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function qr(e){var t=ro(e);return(t.local?gf:mf)(t)}function hf(){}function Bo(e){return e==null?hf:function(){return this.querySelector(e)}}function Xa(e){typeof e!="function"&&(e=Bo(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 Fe(n,this._parents)}function _s(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function yf(){return[]}function Kn(e){return e==null?yf:function(){return this.querySelectorAll(e)}}function xf(e){return function(){return _s(e.apply(this,arguments))}}function Ua(e){typeof e=="function"?e=xf(e):e=Kn(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 Fe(n,r)}function qn(e){return function(){return this.matches(e)}}function Zr(e){return function(t){return t.matches(e)}}var Ef=Array.prototype.find;function bf(e){return function(){return Ef.call(this.children,e)}}function _f(){return this.firstElementChild}function $a(e){return this.select(e==null?_f:bf(typeof e=="function"?e:Zr(e)))}var Nf=Array.prototype.filter;function Tf(){return Array.from(this.children)}function vf(e){return function(){return Nf.call(this.children,e)}}function Ka(e){return this.selectAll(e==null?Tf:vf(typeof e=="function"?e:Zr(e)))}function qa(e){typeof e!="function"&&(e=qn(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 Fe(n,this._parents)}function Jr(e){return new Array(e.length)}function Za(){return new Fe(this._enter||this._groups.map(Jr),this._parents)}function Zn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Zn.prototype={constructor:Zn,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 Ja(e){return function(){return e}}function wf(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 Zn(e,i[a]);for(;a<l;++a)(s=t[a])&&(r[a]=s)}function If(e,t,o,n,r,i,a){var s,l,c=new Map,d=t.length,u=i.length,m=new Array(d),p;for(s=0;s<d;++s)(l=t[s])&&(m[s]=p=a.call(l,l.__data__,s,t)+"",c.has(p)?r[s]=l:c.set(p,l));for(s=0;s<u;++s)p=a.call(e,i[s],s,i)+"",(l=c.get(p))?(n[s]=l,l.__data__=i[s],c.delete(p)):o[s]=new Zn(e,i[s]);for(s=0;s<d;++s)(l=t[s])&&c.get(m[s])===l&&(r[s]=l)}function Af(e){return e.__data__}function Qa(e,t){if(!arguments.length)return Array.from(this,Af);var o=t?If:wf,n=this._parents,r=this._groups;typeof e!="function"&&(e=Ja(e));for(var i=r.length,a=new Array(i),s=new Array(i),l=new Array(i),c=0;c<i;++c){var d=n[c],u=r[c],m=u.length,p=Cf(e.call(d,d&&d.__data__,c,n)),g=p.length,x=s[c]=new Array(g),f=a[c]=new Array(g),h=l[c]=new Array(m);o(d,u,x,f,h,p,t);for(var _=0,b=0,T,E;_<g;++_)if(T=x[_]){for(_>=b&&(b=_+1);!(E=f[b])&&++b<g;);T._next=E||null}}return a=new Fe(a,n),a._enter=s,a._exit=l,a}function Cf(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function ja(){return new Fe(this._exit||this._groups.map(Jr),this._parents)}function el(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 tl(e){for(var t=e.selection?e.selection():e,o=this._groups,n=t._groups,r=o.length,i=n.length,a=Math.min(r,i),s=new Array(r),l=0;l<a;++l)for(var c=o[l],d=n[l],u=c.length,m=s[l]=new Array(u),p,g=0;g<u;++g)(p=c[g]||d[g])&&(m[g]=p);for(;l<r;++l)s[l]=o[l];return new Fe(s,this._parents)}function ol(){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 nl(e){e||(e=Sf);function t(u,m){return u&&m?e(u.__data__,m.__data__):!u-!m}for(var o=this._groups,n=o.length,r=new Array(n),i=0;i<n;++i){for(var a=o[i],s=a.length,l=r[i]=new Array(s),c,d=0;d<s;++d)(c=a[d])&&(l[d]=c);l.sort(t)}return new Fe(r,this._parents).order()}function Sf(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function rl(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function il(){return Array.from(this)}function sl(){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 al(){let e=0;for(let t of this)++e;return e}function ll(){return!this.node()}function cl(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 Mf(e){return function(){this.removeAttribute(e)}}function Pf(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Lf(e,t){return function(){this.setAttribute(e,t)}}function kf(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Rf(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function Df(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,o)}}function dl(e,t){var o=ro(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?Pf:Mf:typeof t=="function"?o.local?Df:Rf:o.local?kf:Lf)(o,t))}function Qr(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Of(e){return function(){this.style.removeProperty(e)}}function Vf(e,t,o){return function(){this.style.setProperty(e,t,o)}}function Hf(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function ul(e,t,o){return arguments.length>1?this.each((t==null?Of:typeof t=="function"?Hf:Vf)(e,t,o==null?"":o)):yo(this.node(),e)}function yo(e,t){return e.style.getPropertyValue(t)||Qr(e).getComputedStyle(e,null).getPropertyValue(t)}function Gf(e){return function(){delete this[e]}}function Bf(e,t){return function(){this[e]=t}}function zf(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function pl(e,t){return arguments.length>1?this.each((t==null?Gf:typeof t=="function"?zf:Bf)(e,t)):this.node()[e]}function fl(e){return e.trim().split(/^|\s+/)}function Ns(e){return e.classList||new ml(e)}function ml(e){this._node=e,this._names=fl(e.getAttribute("class")||"")}ml.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 gl(e,t){for(var o=Ns(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function hl(e,t){for(var o=Ns(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function Yf(e){return function(){gl(this,e)}}function Wf(e){return function(){hl(this,e)}}function Ff(e,t){return function(){(t.apply(this,arguments)?gl:hl)(this,e)}}function yl(e,t){var o=fl(e+"");if(arguments.length<2){for(var n=Ns(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?Ff:t?Yf:Wf)(o,t))}function Xf(){this.textContent=""}function Uf(e){return function(){this.textContent=e}}function $f(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function xl(e){return arguments.length?this.each(e==null?Xf:(typeof e=="function"?$f:Uf)(e)):this.node().textContent}function Kf(){this.innerHTML=""}function qf(e){return function(){this.innerHTML=e}}function Zf(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function El(e){return arguments.length?this.each(e==null?Kf:(typeof e=="function"?Zf:qf)(e)):this.node().innerHTML}function Jf(){this.nextSibling&&this.parentNode.appendChild(this)}function bl(){return this.each(Jf)}function Qf(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function _l(){return this.each(Qf)}function Nl(e){var t=typeof e=="function"?e:qr(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function jf(){return null}function Tl(e,t){var o=typeof e=="function"?e:qr(e),n=t==null?jf:typeof t=="function"?t:Bo(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function em(){var e=this.parentNode;e&&e.removeChild(this)}function vl(){return this.each(em)}function tm(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function om(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function wl(e){return this.select(e?om:tm)}function Il(e){return arguments.length?this.property("__data__",e):this.node().__data__}function nm(e){return function(t){e.call(this,t,this.__data__)}}function rm(e){return e.trim().split(/^|\s+/).map(function(t){var o="",n=t.indexOf(".");return n>=0&&(o=t.slice(n+1),t=t.slice(0,n)),{type:t,name:o}})}function im(e){return function(){var t=this.__on;if(t){for(var o=0,n=-1,r=t.length,i;o<r;++o)i=t[o],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++n]=i;++n?t.length=n:delete this.__on}}}function sm(e,t,o){return function(){var n=this.__on,r,i=nm(t);if(n){for(var a=0,s=n.length;a<s;++a)if((r=n[a]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=o),r.value=t;return}}this.addEventListener(e.type,i,o),r={type:e.type,name:e.name,value:t,listener:i,options:o},n?n.push(r):this.__on=[r]}}function Al(e,t,o){var n=rm(e+""),r,i=n.length,a;if(arguments.length<2){var s=this.node().__on;if(s){for(var l=0,c=s.length,d;l<c;++l)for(r=0,d=s[l];r<i;++r)if((a=n[r]).type===d.type&&a.name===d.name)return d.value}return}for(s=t?sm:im,r=0;r<i;++r)this.each(s(n[r],t,o));return this}function Cl(e,t,o){var n=Qr(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 am(e,t){return function(){return Cl(this,e,t)}}function lm(e,t){return function(){return Cl(this,e,t.apply(this,arguments))}}function Sl(e,t){return this.each((typeof t=="function"?lm:am)(e,t))}function*Ml(){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 cm=[null];function Fe(e,t){this._groups=e,this._parents=t}function Pl(){return new Fe([[document.documentElement]],cm)}function dm(){return this}Fe.prototype=Pl.prototype={constructor:Fe,select:Xa,selectAll:Ua,selectChild:$a,selectChildren:Ka,filter:qa,data:Qa,enter:Za,exit:ja,join:el,merge:tl,selection:dm,order:ol,sort:nl,call:rl,nodes:il,node:sl,size:al,empty:ll,each:cl,attr:dl,style:ul,property:pl,classed:yl,text:xl,html:El,raise:bl,lower:_l,append:Nl,insert:Tl,remove:vl,clone:wl,datum:Il,on:Al,dispatch:Sl,[Symbol.iterator]:Ml};var io=Pl;function jr(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function Ts(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function jn(){}var Jn=.7,oi=1/Jn,xn="\\s*([+-]?\\d+)\\s*",Qn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Wt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",um=/^#([0-9a-f]{3,8})$/,pm=new RegExp(`^rgb\\(${xn},${xn},${xn}\\)$`),fm=new RegExp(`^rgb\\(${Wt},${Wt},${Wt}\\)$`),mm=new RegExp(`^rgba\\(${xn},${xn},${xn},${Qn}\\)$`),gm=new RegExp(`^rgba\\(${Wt},${Wt},${Wt},${Qn}\\)$`),hm=new RegExp(`^hsl\\(${Qn},${Wt},${Wt}\\)$`),ym=new RegExp(`^hsla\\(${Qn},${Wt},${Wt},${Qn}\\)$`),Ll={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};jr(jn,xo,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:kl,formatHex:kl,formatHex8:xm,formatHsl:Em,formatRgb:Rl,toString:Rl});function kl(){return this.rgb().formatHex()}function xm(){return this.rgb().formatHex8()}function Em(){return Bl(this).formatHsl()}function Rl(){return this.rgb().formatRgb()}function xo(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=um.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?Dl(t):o===3?new rt(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?ei(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?ei(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=pm.exec(e))?new rt(t[1],t[2],t[3],1):(t=fm.exec(e))?new rt(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=mm.exec(e))?ei(t[1],t[2],t[3],t[4]):(t=gm.exec(e))?ei(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=hm.exec(e))?Hl(t[1],t[2]/100,t[3]/100,1):(t=ym.exec(e))?Hl(t[1],t[2]/100,t[3]/100,t[4]):Ll.hasOwnProperty(e)?Dl(Ll[e]):e==="transparent"?new rt(NaN,NaN,NaN,0):null}function Dl(e){return new rt(e>>16&255,e>>8&255,e&255,1)}function ei(e,t,o,n){return n<=0&&(e=t=o=NaN),new rt(e,t,o,n)}function bm(e){return e instanceof jn||(e=xo(e)),e?(e=e.rgb(),new rt(e.r,e.g,e.b,e.opacity)):new rt}function En(e,t,o,n){return arguments.length===1?bm(e):new rt(e,t,o,n==null?1:n)}function rt(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}jr(rt,En,Ts(jn,{brighter(e){return e=e==null?oi:Math.pow(oi,e),new rt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Jn:Math.pow(Jn,e),new rt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new rt(Yo(this.r),Yo(this.g),Yo(this.b),ni(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:Ol,formatHex:Ol,formatHex8:_m,formatRgb:Vl,toString:Vl}));function Ol(){return`#${zo(this.r)}${zo(this.g)}${zo(this.b)}`}function _m(){return`#${zo(this.r)}${zo(this.g)}${zo(this.b)}${zo((isNaN(this.opacity)?1:this.opacity)*255)}`}function Vl(){let e=ni(this.opacity);return`${e===1?"rgb(":"rgba("}${Yo(this.r)}, ${Yo(this.g)}, ${Yo(this.b)}${e===1?")":`, ${e})`}`}function ni(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Yo(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function zo(e){return e=Yo(e),(e<16?"0":"")+e.toString(16)}function Hl(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new Rt(e,t,o,n)}function Bl(e){if(e instanceof Rt)return new Rt(e.h,e.s,e.l,e.opacity);if(e instanceof jn||(e=xo(e)),!e)return new Rt;if(e instanceof Rt)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 Rt(a,s,l,e.opacity)}function zl(e,t,o,n){return arguments.length===1?Bl(e):new Rt(e,t,o,n==null?1:n)}function Rt(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}jr(Rt,zl,Ts(jn,{brighter(e){return e=e==null?oi:Math.pow(oi,e),new Rt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Jn:Math.pow(Jn,e),new Rt(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 rt(vs(e>=240?e-240:e+120,r,n),vs(e,r,n),vs(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new Rt(Gl(this.h),ti(this.s),ti(this.l),ni(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=ni(this.opacity);return`${e===1?"hsl(":"hsla("}${Gl(this.h)}, ${ti(this.s)*100}%, ${ti(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Gl(e){return e=(e||0)%360,e<0?e+360:e}function ti(e){return Math.max(0,Math.min(1,e||0))}function vs(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 ws(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 Yl(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 ws((o-n/t)*t,a,r,i,s)}}function Wl(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 ws((o-n/t)*t,r,i,a,s)}}var Is=e=>()=>e;function Nm(e,t){return function(o){return e+o*t}}function Tm(e,t,o){return e=Math.pow(e,o),t=Math.pow(t,o)-e,o=1/o,function(n){return Math.pow(e+n*t,o)}}function Fl(e){return(e=+e)==1?ri:function(t,o){return o-t?Tm(t,o,e):Is(isNaN(t)?o:t)}}function ri(e,t){var o=t-e;return o?Nm(e,o):Is(isNaN(e)?t:e)}var ii=function e(t){var o=Fl(t);function n(r,i){var a=o((r=En(r)).r,(i=En(i)).r),s=o(r.g,i.g),l=o(r.b,i.b),c=ri(r.opacity,i.opacity);return function(d){return r.r=a(d),r.g=s(d),r.b=l(d),r.opacity=c(d),r+""}}return n.gamma=e,n}(1);function Xl(e){return function(t){var o=t.length,n=new Array(o),r=new Array(o),i=new Array(o),a,s;for(a=0;a<o;++a)s=En(t[a]),n[a]=s.r||0,r[a]=s.g||0,i[a]=s.b||0;return n=e(n),r=e(r),i=e(i),s.opacity=1,function(l){return s.r=n(l),s.g=r(l),s.b=i(l),s+""}}}var vm=Xl(Yl),wm=Xl(Wl);function At(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var Cs=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,As=new RegExp(Cs.source,"g");function Im(e){return function(){return e}}function Am(e){return function(t){return e(t)+""}}function Ss(e,t){var o=Cs.lastIndex=As.lastIndex=0,n,r,i,a=-1,s=[],l=[];for(e=e+"",t=t+"";(n=Cs.exec(e))&&(r=As.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:At(n,r)})),o=As.lastIndex;return o<t.length&&(i=t.slice(o),s[a]?s[a]+=i:s[++a]=i),s.length<2?l[0]?Am(l[0].x):Im(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 Ul=180/Math.PI,si={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ms(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)*Ul,skewX:Math.atan(l)*Ul,scaleX:a,scaleY:s}}var ai;function $l(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?si:Ms(t.a,t.b,t.c,t.d,t.e,t.f)}function Kl(e){return e==null?si:(ai||(ai=document.createElementNS("http://www.w3.org/2000/svg","g")),ai.setAttribute("transform",e),(e=ai.transform.baseVal.consolidate())?(e=e.matrix,Ms(e.a,e.b,e.c,e.d,e.e,e.f)):si)}function ql(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,m,p,g){if(c!==u||d!==m){var x=p.push("translate(",null,t,null,o);g.push({i:x-4,x:At(c,u)},{i:x-2,x:At(d,m)})}else(u||m)&&p.push("translate("+u+t+m+o)}function a(c,d,u,m){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),m.push({i:u.push(r(u)+"rotate(",null,n)-2,x:At(c,d)})):d&&u.push(r(u)+"rotate("+d+n)}function s(c,d,u,m){c!==d?m.push({i:u.push(r(u)+"skewX(",null,n)-2,x:At(c,d)}):d&&u.push(r(u)+"skewX("+d+n)}function l(c,d,u,m,p,g){if(c!==u||d!==m){var x=p.push(r(p)+"scale(",null,",",null,")");g.push({i:x-4,x:At(c,u)},{i:x-2,x:At(d,m)})}else(u!==1||m!==1)&&p.push(r(p)+"scale("+u+","+m+")")}return function(c,d){var u=[],m=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,u,m),a(c.rotate,d.rotate,u,m),s(c.skewX,d.skewX,u,m),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,m),c=d=null,function(p){for(var g=-1,x=m.length,f;++g<x;)u[(f=m[g]).i]=f.x(p);return u.join("")}}}var Ps=ql($l,"px, ","px)","deg)"),Ls=ql(Kl,", ",")",")");var bn=0,tr=0,er=0,Jl=1e3,li,or,ci=0,Wo=0,di=0,nr=typeof performance=="object"&&performance.now?performance:Date,Ql=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ir(){return Wo||(Ql(Cm),Wo=nr.now()+di)}function Cm(){Wo=0}function rr(){this._call=this._time=this._next=null}rr.prototype=ui.prototype={constructor:rr,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?ir():+o)+(t==null?0:+t),!this._next&&or!==this&&(or?or._next=this:li=this,or=this),this._call=e,this._time=o,ks()},stop:function(){this._call&&(this._call=null,this._time=1/0,ks())}};function ui(e,t,o){var n=new rr;return n.restart(e,t,o),n}function jl(){ir(),++bn;for(var e=li,t;e;)(t=Wo-e._time)>=0&&e._call.call(void 0,t),e=e._next;--bn}function Zl(){Wo=(ci=nr.now())+di,bn=tr=0;try{jl()}finally{bn=0,Mm(),Wo=0}}function Sm(){var e=nr.now(),t=e-ci;t>Jl&&(di-=t,ci=e)}function Mm(){for(var e,t=li,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:li=o);or=e,ks(n)}function ks(e){if(!bn){tr&&(tr=clearTimeout(tr));var t=e-Wo;t>24?(e<1/0&&(tr=setTimeout(Zl,e-nr.now()-di)),er&&(er=clearInterval(er))):(er||(ci=nr.now(),er=setInterval(Sm,Jl)),bn=1,Ql(Zl))}}function pi(e,t,o){var n=new rr;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var Pm=Es("start","end","cancel","interrupt"),Lm=[],oc=0,ec=1,mi=2,fi=3,tc=4,gi=5,sr=6;function Eo(e,t,o,n,r,i){var a=e.__transition;if(!a)e.__transition={};else if(o in a)return;km(e,o,{name:t,index:n,group:r,on:Pm,tween:Lm,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:oc})}function ar(e,t){var o=Xe(e,t);if(o.state>oc)throw new Error("too late; already scheduled");return o}function Ke(e,t){var o=Xe(e,t);if(o.state>fi)throw new Error("too late; already running");return o}function Xe(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function km(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=ui(i,0,o.time);function i(c){o.state=ec,o.timer.restart(a,o.delay,o.time),o.delay<=c&&a(c-o.delay)}function a(c){var d,u,m,p;if(o.state!==ec)return l();for(d in n)if(p=n[d],p.name===o.name){if(p.state===fi)return pi(a);p.state===tc?(p.state=sr,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete n[d]):+d<t&&(p.state=sr,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete n[d])}if(pi(function(){o.state===fi&&(o.state=tc,o.timer.restart(s,o.delay,o.time),s(c))}),o.state=mi,o.on.call("start",e,e.__data__,o.index,o.group),o.state===mi){for(o.state=fi,r=new Array(m=o.tween.length),d=0,u=-1;d<m;++d)(p=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++u]=p);r.length=u+1}}function s(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=gi,1),u=-1,m=r.length;++u<m;)r[u].call(e,d);o.state===gi&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=sr,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function Rs(e,t){var o=e.__transition,n,r,i=!0,a;if(o){t=t==null?null:t+"";for(a in o){if((n=o[a]).name!==t){i=!1;continue}r=n.state>mi&&n.state<gi,n.state=sr,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[a]}i&&delete e.__transition}}function nc(e){return this.each(function(){Rs(this,e)})}function Rm(e,t){var o,n;return function(){var r=Ke(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 Dm(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=Ke(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 rc(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=Xe(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?Rm:Dm)(o,e,t))}function _n(e,t,o){var n=e._id;return e.each(function(){var r=Ke(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return Xe(r,n).value[t]}}function hi(e,t){var o;return(typeof t=="number"?At:t instanceof xo?ii:(o=xo(t))?(t=o,ii):Ss)(e,t)}function Om(e){return function(){this.removeAttribute(e)}}function Vm(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Hm(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 Gm(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 Bm(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 zm(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 ic(e,t){var o=ro(e),n=o==="transform"?Ls:hi;return this.attrTween(e,typeof t=="function"?(o.local?zm:Bm)(o,n,_n(this,"attr."+e,t)):t==null?(o.local?Vm:Om)(o):(o.local?Gm:Hm)(o,n,t))}function Ym(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function Wm(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function Fm(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Wm(e,i)),o}return r._value=t,r}function Xm(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Ym(e,i)),o}return r._value=t,r}function sc(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=ro(e);return this.tween(o,(n.local?Fm:Xm)(n,t))}function Um(e,t){return function(){ar(this,e).delay=+t.apply(this,arguments)}}function $m(e,t){return t=+t,function(){ar(this,e).delay=t}}function ac(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Um:$m)(t,e)):Xe(this.node(),t).delay}function Km(e,t){return function(){Ke(this,e).duration=+t.apply(this,arguments)}}function qm(e,t){return t=+t,function(){Ke(this,e).duration=t}}function lc(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Km:qm)(t,e)):Xe(this.node(),t).duration}function Zm(e,t){if(typeof t!="function")throw new Error;return function(){Ke(this,e).ease=t}}function cc(e){var t=this._id;return arguments.length?this.each(Zm(t,e)):Xe(this.node(),t).ease}function Jm(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;Ke(this,e).ease=o}}function dc(e){if(typeof e!="function")throw new Error;return this.each(Jm(this._id,e))}function uc(e){typeof e!="function"&&(e=qn(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 je(n,this._parents,this._name,this._id)}function pc(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,o=e._groups,n=t.length,r=o.length,i=Math.min(n,r),a=new Array(n),s=0;s<i;++s)for(var l=t[s],c=o[s],d=l.length,u=a[s]=new Array(d),m,p=0;p<d;++p)(m=l[p]||c[p])&&(u[p]=m);for(;s<n;++s)a[s]=t[s];return new je(a,this._parents,this._name,this._id)}function Qm(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 jm(e,t,o){var n,r,i=Qm(t)?ar:Ke;return function(){var a=i(this,e),s=a.on;s!==n&&(r=(n=s).copy()).on(t,o),a.on=r}}function fc(e,t){var o=this._id;return arguments.length<2?Xe(this.node(),o).on.on(e):this.each(jm(o,e,t))}function eg(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function mc(){return this.on("end.remove",eg(this._id))}function gc(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Bo(e));for(var n=this._groups,r=n.length,i=new Array(r),a=0;a<r;++a)for(var s=n[a],l=s.length,c=i[a]=new Array(l),d,u,m=0;m<l;++m)(d=s[m])&&(u=e.call(d,d.__data__,m,s))&&("__data__"in d&&(u.__data__=d.__data__),c[m]=u,Eo(c[m],t,o,m,c,Xe(d,o)));return new je(i,this._parents,t,o)}function hc(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Kn(e));for(var n=this._groups,r=n.length,i=[],a=[],s=0;s<r;++s)for(var l=n[s],c=l.length,d,u=0;u<c;++u)if(d=l[u]){for(var m=e.call(d,d.__data__,u,l),p,g=Xe(d,o),x=0,f=m.length;x<f;++x)(p=m[x])&&Eo(p,t,o,x,m,g);i.push(m),a.push(d)}return new je(i,a,t,o)}var tg=io.prototype.constructor;function yc(){return new tg(this._groups,this._parents)}function og(e,t){var o,n,r;return function(){var i=yo(this,e),a=(this.style.removeProperty(e),yo(this,e));return i===a?null:i===o&&a===n?r:r=t(o=i,n=a)}}function xc(e){return function(){this.style.removeProperty(e)}}function ng(e,t,o){var n,r=o+"",i;return function(){var a=yo(this,e);return a===r?null:a===n?i:i=t(n=a,o)}}function rg(e,t,o){var n,r,i;return function(){var a=yo(this,e),s=o(this),l=s+"";return s==null&&(l=s=(this.style.removeProperty(e),yo(this,e))),a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s))}}function ig(e,t){var o,n,r,i="style."+t,a="end."+i,s;return function(){var l=Ke(this,e),c=l.on,d=l.value[i]==null?s||(s=xc(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(a,r=d),l.on=n}}function Ec(e,t,o){var n=(e+="")=="transform"?Ps:hi;return t==null?this.styleTween(e,og(e,n)).on("end.style."+e,xc(e)):typeof t=="function"?this.styleTween(e,rg(e,n,_n(this,"style."+e,t))).each(ig(this._id,e)):this.styleTween(e,ng(e,n,t),o).on("end.style."+e,null)}function sg(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function ag(e,t,o){var n,r;function i(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&sg(e,a,o)),n}return i._value=t,i}function bc(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,ag(e,t,o==null?"":o))}function lg(e){return function(){this.textContent=e}}function cg(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function _c(e){return this.tween("text",typeof e=="function"?cg(_n(this,"text",e)):lg(e==null?"":e+""))}function dg(e){return function(t){this.textContent=e.call(this,t)}}function ug(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&dg(r)),t}return n._value=e,n}function Nc(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,ug(e))}function Tc(){for(var e=this._name,t=this._id,o=yi(),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=Xe(l,t);Eo(l,e,o,c,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new je(n,this._parents,e,o)}function vc(){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=Ke(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 pg=0;function je(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function wc(e){return io().transition(e)}function yi(){return++pg}var so=io.prototype;je.prototype=wc.prototype={constructor:je,select:gc,selectAll:hc,selectChild:so.selectChild,selectChildren:so.selectChildren,filter:uc,merge:pc,selection:yc,transition:Tc,call:so.call,nodes:so.nodes,node:so.node,size:so.size,empty:so.empty,each:so.each,on:fc,attr:ic,attrTween:sc,style:Ec,styleTween:bc,text:_c,textTween:Nc,remove:mc,tween:rc,delay:ac,duration:lc,ease:cc,easeVarying:dc,end:vc,[Symbol.iterator]:so[Symbol.iterator]};function xi(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var fg={time:null,delay:0,duration:250,ease:xi};function mg(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 Ic(e){var t,o;e instanceof je?(t=e._id,e=e._name):(t=yi(),(o=fg).time=ir(),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])&&Eo(l,e,t,c,a,o||mg(l,t));return new je(n,this._parents,e,t)}io.prototype.interrupt=nc;io.prototype.transition=Ic;function bo(e,t,o){this.k=e,this.x=t,this.y=o}bo.prototype={constructor:bo,scale:function(e){return e===1?this:new bo(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new bo(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 Ei=new bo(1,0,0);bi.prototype=bo.prototype;function bi(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Ei;return e.__zoom}var hg=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var Ac;(function(e){e.Strict="strict",e.Loose="loose"})(Ac||(Ac={}));var Cc;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Cc||(Cc={}));var Sc;(function(e){e.Partial="partial",e.Full="full"})(Sc||(Sc={}));var Mc;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Mc||(Mc={}));var Pc;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Pc||(Pc={}));var it;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(it||(it={}));var f_={[it.Left]:it.Right,[it.Right]:it.Left,[it.Top]:it.Bottom,[it.Bottom]:it.Top};var yg=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var xg=(e,t=[0,0])=>{var s;let{width:o,height:n}=Eg(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 _i=(e,t=[0,0])=>{var r,i,a,s,l,c,d,u;let{x:o,y:n}=yg(e)?e.internals.positionAbsolute:xg(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 Eg(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 m_={[it.Left]:{x:-1,y:0},[it.Right]:{x:1,y:0},[it.Top]:{x:0,y:-1},[it.Bottom]:{x:0,y:1}};var bg={nodeOrigin:[0,0],nodeExtent:hg,elevateNodesOnSelect:!0,defaults:{}},g_=v(N({},bg),{checkEquality:!0});var Lc;(function(e){e.Line="line",e.Handle="handle"})(Lc||(Lc={}));var _g={width:0,height:0,x:0,y:0},h_=v(N({},_g),{pointerX:0,pointerY:0,aspectRatio:1});var Ng=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function Tg(e,t){let o=Math.max(0,Math.min(e.x2,t.x2)-Math.max(e.x,t.x)),n=Math.max(0,Math.min(e.y2,t.y2)-Math.max(e.y,t.y));return o*n}function vg(e,t){let o=Math.max(0,Math.max(e.x-t.x2,t.x-e.x2)),n=Math.max(0,Math.max(e.y-t.y2,t.y-e.y2));return Math.sqrt(o*o+n*n)}var Ni=class{constructor(){this.xLines=[];this.yLines=[]}initialize(t){this.xLines=t.filter(o=>o.orientation==="vertical"),this.yLines=t.filter(o=>o.orientation==="horizontal"),this.xLines.sort((o,n)=>o.position-n.position),this.yLines.sort((o,n)=>o.position-n.position),this.lastHorizontalLine=void 0,this.lastVerticalLine=void 0}search(t,o,n,r,i){let a=t==="horizontal"?this.yLines:this.xLines,[s,l]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],c=[];for(let p of a){if(p.position<s)continue;if(p.position>l)break;if(i.has(p.node.id)||p.node.parentId&&i.has(p.node.parentId)||!Ng(p.nodeBox,r))continue;let g=Math.abs(p.position-o);if(g>Ti)continue;let f=Tg(p.nodeBox,n)>0?0:vg(p.nodeBox,n);c.push({line:p,lineDist:g,nodeDist:f})}let d=.5,u=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;c.sort((p,g)=>{if(u){if(p.line===u&&g.line!==u)return-1;if(g.line===u&&p.line!==u)return 1}return Math.abs(p.lineDist-g.lineDist)<=d?p.nodeDist-g.nodeDist:p.lineDist-g.lineDist});let m=c.length>0?c[0].line:void 0;return m&&(t==="horizontal"?this.lastHorizontalLine=m:this.lastVerticalLine=m),m}};function kc(e,t=Fo,o){let n=[];return e==null||e.forEach(r=>{let i=o(r.id);if(!i)throw new Error(`Node with id ${r.id} not found in internal nodes.`);let a=_i(i);Object.entries(t).forEach(([s,l])=>{var c;n.push({position:l.resolve(r,a),color:(c=r.style)==null?void 0:c.backgroundColor,orientation:l.orientation,anchorName:s,nodeBox:a,node:r})})}),n}function Rc(e,t,o,n,r=Object.keys(Fo)){let i=[];for(let s of r){let l=Fo[s],c=l.resolve(null,o),d=e.search(l.orientation,c,o,t,n);d&&i.push({sourcePosition:c,anchorName:s,anchor:l,line:d})}let a={horizontal:void 0,vertical:void 0};for(let s of i){let l=a[s.anchor.orientation],c=Math.abs(s.sourcePosition-s.line.position);(!l||c<Math.abs(l.sourcePosition-l.line.position))&&(a[s.anchor.orientation]=s)}return a}function Dc(e,t,o){let n=0,r=0,i=!1,a=!1;if(t){let l=t.anchor.resolve(null,e)-t.line.position;Math.abs(l)<=Ti&&(r=l,a=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=Ti&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:a}}var Ti=10,Fo={top:{orientation:"horizontal",resolve:(e,t)=>t.y},bottom:{orientation:"horizontal",resolve:(e,t)=>t.y2},left:{orientation:"vertical",resolve:(e,t)=>t.x},right:{orientation:"vertical",resolve:(e,t)=>t.x2},centerX:{orientation:"vertical",resolve:(e,t)=>(t.x+t.x2)/2},centerY:{orientation:"horizontal",resolve:(e,t)=>(t.y+t.y2)/2}};var Vc=require("react/jsx-runtime"),wg=new Ni;function vi(){let[e,t]=(0,ft.useState)(void 0),[o,n]=(0,ft.useState)(void 0),{width:r,height:i}=(0,Nn.useStore)(f=>({width:f.width,height:f.height}),Oc.shallow),a=(0,Nn.useNodesInitialized)(),s=(0,ft.useRef)(wg),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=(0,Nn.useReactFlow)(),u=(0,ft.useCallback)(()=>{t(void 0),n(void 0)},[]),m=(0,ft.useCallback)(f=>{let h=f!=null?f:d();u();let _=kc(h,Fo,c);s.current.initialize(_)},[c,u,d]),p=(0,ft.useCallback)(()=>{setTimeout(()=>{m()},100)},[m]);(0,ft.useEffect)(()=>{a&&m(d())},[a,m,d]);let g=(0,ft.useCallback)((f,h)=>{var L,k,O,B,ee,oe,K,J,Q,ae;if(!s.current||f.length===0||f.filter(F=>F.type==="dimensions").length>1)return f;u();let b=f.filter(F=>F.type==="position"&&!!F.position),T=f.find(F=>F.type==="dimensions");if(b.length===0&&!T)return f;let E=Object.keys(Fo),y=new Set,w=1/0,C=1/0,A=-1/0,R=-1/0;if(b.length>0)b.forEach(F=>{var re,fe,ue,Ne,We,Qe;let ne=h.find(ot=>ot.id===F.id);if(!ne)return;y.add(ne.id);let le=c(ne.id);if(!le)return;let U=le.parentId?c(le.parentId):void 0,Te=F.position.x+((re=U==null?void 0:U.internals.positionAbsolute.x)!=null?re:0),W=F.position.y+((fe=U==null?void 0:U.internals.positionAbsolute.y)!=null?fe:0),j=(Ne=(ue=ne.measured)==null?void 0:ue.width)!=null?Ne:0,ce=(Qe=(We=ne.measured)==null?void 0:We.height)!=null?Qe:0;w=Math.min(w,Te),C=Math.min(C,W),A=Math.max(A,Te+j),R=Math.max(R,W+ce)}),T&&(E=["top","left"]);else if(T){let F=h.find(j=>j.id===T.id);if(!F)return f;y.add(F.id);let ne=c(F.id);if(!ne)return f;let le=ne.internals.positionAbsolute.x,U=ne.internals.positionAbsolute.y,Te=(B=(O=(L=T.dimensions)==null?void 0:L.width)!=null?O:(k=F.measured)==null?void 0:k.width)!=null?B:0,W=(J=(K=(ee=T.dimensions)==null?void 0:ee.height)!=null?K:(oe=F.measured)==null?void 0:oe.height)!=null?J:0;w=le,C=U,A=le+Te,R=U+W,E=["right","bottom"]}if(w===1/0)return f;let G={x:w,y:C,x2:A,y2:R},{x:M,y:P}=l({x:0,y:0}),{x:X,y:$}=l({x:r,y:i}),Z={x:M,y:P,x2:X,y2:$},{horizontal:Y,vertical:S}=Rc(s.current,Z,G,y,E),{deltaX:V,deltaY:D,snappedX:I,snappedY:z}=Dc(G,Y,S);if(I||z){let F=b.some(le=>le.dragging),ne=!!(T!=null&&T.resizing);(F||ne)&&(I&&n(S==null?void 0:S.line),z&&t(Y==null?void 0:Y.line)),I&&(b.forEach(le=>{le.position&&(le.position.x-=V)}),(T==null?void 0:T.id)===((Q=b[0])==null?void 0:Q.id)?T.dimensions&&(T.dimensions.width+=V):T&&!b.length&&T.dimensions&&(T.dimensions.width-=V)),z&&(b.forEach(le=>{le.position&&(le.position.y-=D)}),(T==null?void 0:T.id)===((ae=b[0])==null?void 0:ae.id)?T.dimensions&&(T.dimensions.height+=D):T&&!b.length&&T.dimensions&&(T.dimensions.height-=D))}return f},[l,c,r,i,t,n,u]),x=(0,ft.useCallback)(()=>(0,Vc.jsx)(Hc,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:m,forceRebuildIndex:p,updateHelperLines:g,helperLineHorizontal:e,helperLineVertical:o,HelperLines:x}}var ji=require("@xyflow/react"),Jt=require("react");var ao=e=>new Map(e.map(t=>[t.id,t])),lr=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),Gc=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),Ds=e=>e.some(t=>t.type==="START_EVENT"),_o=(e,t)=>e==="START_EVENT"?!Ds(t):!0,Bc=(e,t,o,n,r)=>{let i=ao(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:lr(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},zc=(e,t,o,n,r)=>{let i=ao(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:Gc(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},wi=(e,t,o,n,r)=>{var c;let i=ao(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:lr(e,n,r).filter(d=>{let u=i.get(d.target);return(u==null?void 0:u.type)!=="ANNOTATION"}).length>=2},Yc=(e,t,o)=>{var a,s,l,c;let n=ao(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"},Ii=(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"},Wc=(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"},Ai=(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"},cr=(e,t,o,n)=>{let r=ao(t),i=r.get(e);return!i||i.type!=="TASK"?!1:Gc(e,o,n).some(s=>{let l=r.get(s.source);return(l==null?void 0:l.type)==="START_EVENT"})},dr=(e,t,o,n)=>{let r=ao(t),i=r.get(e);return!i||i.type!=="TASK"?!1:lr(e,o,n).some(s=>{let l=r.get(s.target);return(l==null?void 0:l.type)==="END_EVENT"})},Fc=(e,t,o,n,r)=>{let i=ao(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"?dr(t,o,n,r):(s==null?void 0:s.type)==="END_EVENT"&&(a==null?void 0:a.type)==="TASK"?cr(e,o,n,r):!1},Ci=(e,t,o)=>lr(e,t,o).length>0,Si=(e,t,o,n,r)=>{let i=ao(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:lr(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var Xc=(e,t,o,n,r)=>{var s,l;let i=ao(n),a=((s=i.get(e))==null?void 0:s.type)==="ANNOTATION"||((l=i.get(t))==null?void 0:l.type)==="ANNOTATION";return o.some(c=>r&&c.id===r?!1:!!(c.source===e&&c.target===t||a&&c.source===t&&c.target===e))};var Ig=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!Xc(e.sourceNodeId,e.targetNodeId,e.edges,e.nodes,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!Bc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!zc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!wi(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!Si(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:Yc(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"&&Wc(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:!(Ii(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(Ai(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(cr(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!Fc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(dr(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(Ci(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"})],Os=e=>{for(let t of Ig){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var Ag=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:wi(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:Ds(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Ii(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Ai(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:cr(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:dr(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Ci(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Si(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],Uc=e=>{let t=Ag.filter(o=>{let n=!o.sourceTypes||o.sourceTypes.includes(e.sourceNodeType),r=!o.targetTypes||o.targetTypes.includes(e.targetNodeType);return n&&r});for(let o of t){let n=o.validate(e);if(n.shouldDisable)return n}return{shouldDisable:!1}};var Dt=require("@xyflow/react");var Ft=require("@produto-lecom/lecom-ui"),Kc=require("lucide-react");var Ct=require("@xyflow/react");var $c=require("@xyflow/react"),No=()=>{let e=(0,$c.useStoreApi)();return{selectElements:n=>{let{edges:r,nodes:i,triggerEdgeChanges:a,triggerNodeChanges:s}=e.getState(),l=i.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]),c=r.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]);return s(l),a(c),!0},clearSelection:async()=>{let{unselectNodesAndEdges:n}=e.getState();return n(),await Vr(),!0}}};var Mi=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=(0,Ct.useReactFlow)(),{selectElements:r}=No(),i=f=>{let h=o(),_=n(),b=(0,Ct.getIncomers)(f,h,_),T=(0,Ct.getOutgoers)(f,h,_),E=b.some(w=>w.type==="START_EVENT"),y=T.some(w=>w.type==="END_EVENT");return E?"start":y?"end":"between"},a=(f,h,_)=>{var E,y,w,C;if(!f)return;let b={type:f.type,variant:(E=f.data)==null?void 0:E.variant,attribute:(y=f.data)==null?void 0:y.attribute},T={id:f.id,position:i(f),label:(w=f.data)==null?void 0:w.label,node:b};return f.type==="TASK"&&((C=f.data)==null?void 0:C.variant)==="SUBPROCESS"?v(N({},T),{type:"sub_process"}):f.type==="GATEWAY"?v(N({},T),{type:"gateway",variant:s(f,h,_)}):v(N({},T),{type:"activity"})},s=(f,h,_)=>{if(f.type!=="GATEWAY")return;let b=(0,Ct.getIncomers)(f,h,_),T=!1,E=!1;if(b.forEach(y=>{var w,C;y.type==="TASK"&&(((w=y.data)==null?void 0:w.variant)==="SCRIPT"&&(T=!0),((C=y.data)==null?void 0:C.attribute)==="LOOP"&&(E=!0))}),T&&E)return"script_loop";if(T)return"script";if(E)return"loop"},l=(f,h,_)=>{var w,C,A,R;let b=e(f.source),T=e(f.target);if(!b||!T)return"simple";if((0,Ct.getOutgoers)(b,h,_).some(G=>G.type==="END_EVENT"))return"final";if(b.type==="GATEWAY")switch((w=b.data)==null?void 0:w.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(b.type==="TASK"){let G=(C=b.data)==null?void 0:C.variant,M=(A=b.data)==null?void 0:A.attribute;if(G==="SUBPROCESS")return"from_sub_process";if(T.type==="TASK"&&((R=T.data)==null?void 0:R.variant)==="SUBPROCESS")return"to_sub_process";let P=G==="SCRIPT",X=M==="LOOP";return P&&X?"script_loop":P?"script":X?"loop":"simple"}return"simple"},c=(f,h,_)=>{let b=[];function T(y,w,C=0){let A=a(y,h,_);if(A.depth=C,w.push(A),y.type==="TASK"){b.push([...w]),w.pop();return}let R=(0,Ct.getIncomers)(y,h,_);if(R.length)for(let G of R)T(G,w,C+1);w.pop()}let E=(0,Ct.getIncomers)(f,h,_);for(let y of E)T(y,[]);return b},d=(f,h,_)=>{let b=[];function T(y,w,C=0){let A=a(y,h,_);if(A.depth=C,w.push(A),y.type==="TASK"){b.push([...w]),w.pop();return}let R=(0,Ct.getOutgoers)(y,h,_);if(R.length)for(let G of R)T(G,w,C+1);w.pop()}let E=(0,Ct.getOutgoers)(f,h,_);for(let y of E)T(y,[]);return b},u=(f,h,_)=>(_=_.filter(T=>T.source===f.id),_.map(T=>{var w;let E=e(T.target),y;return E&&(y=a(E,h,_)),{id:T.id,type:"routing",variant:l(T,h,_),label:(w=T.data)==null?void 0:w.label,target:y}})),m=f=>{let h=e(f);if(!h)return;let _=o(),b=n(),T=a(h,_,b);return T.sources=c(h,_,b),T.targets=d(h,_,b),T.edgeTargets=u(h,_,b),h.type==="GATEWAY"&&(T.variant=s(h,_,b)),T},p=f=>{let h=t(f);if(!h)return;let _=o(),b=n(),T=l(h,_,b),y={id:h.id,type:"routing",variant:T,gatewayVariant:void 0},w=e(h.source);if(w){let A=a(w,_,b);y.source=A;let R=s(w,_,b);if(y.gatewayVariant=R,w.type==="TASK")y.sources=[[A]];else{let G=c(w,_,b);y.sources=G.length?G:[[A]]}}let C=e(h.target);if(C){let A=a(C,_,b);if(y.target=A,C.type==="TASK")y.targets=[[A]];else{let R=d(C,_,b);y.targets=R.length?R:[[A]]}}return y},g=f=>{let h=e(f);if(h)return m(h.id);let _=t(f);if(_)return p(_.id)};return{configureElement:f=>{let h=g(f);if(h)return r([f]),h},getConfigureElement:g,getNodeConfigure:m,getEdgeConfigure:p}};var Xo=require("react/jsx-runtime"),To=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,Ft.useTranslation)(),{onConfigureElement:n}=q(),{getConfigureElement:r}=Mi();return(0,Xo.jsxs)(Ft.Tooltip,{children:[(0,Xo.jsx)(Ft.TooltipTrigger,{asChild:!0,children:(0,Xo.jsx)(Ft.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let a=r(e);a&&(n==null||n(a))},children:(0,Xo.jsx)(Kc.Settings,{size:16})})}),(0,Xo.jsx)(Ft.TooltipContent,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};var Xt=require("@produto-lecom/lecom-ui"),Zc=require("@xyflow/react"),Jc=require("lucide-react");var qc=require("@produto-lecom/lecom-ui");function st(){let{toast:e}=Tn(),{toast:t}=(0,qc.useNotificationToast)();return{toast:e||t}}var Uo=require("react/jsx-runtime"),Pi=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,Xt.useTranslation)(),{toast:n}=st(),{deleteElements:r,getNodes:i}=(0,Zc.useReactFlow)();return(0,Uo.jsxs)(Xt.Tooltip,{children:[(0,Uo.jsx)(Xt.TooltipTrigger,{asChild:!0,children:(0,Uo.jsx)(Xt.Button,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{if(t==="node"){let s=i(),l=s.find(c=>c.id===e);if((l==null?void 0:l.type)==="LANE"&&s.some(d=>d.parentId===e)){n({variant:"error",title:o("validation.errors.title"),content:o("editor.toolbar.delete_pool_lane_error")});return}r({nodes:[{id:e}]})}else r({edges:[{id:e}]})},children:(0,Uo.jsx)(Jc.TrashIcon,{size:16})})}),(0,Uo.jsx)(Xt.TooltipContent,{color:"black",children:o("editor.toolbar.delete")})]})};var Ut=require("@produto-lecom/lecom-ui"),Qc=require("lucide-react"),jc=require("react"),$o=require("react/jsx-runtime"),vn=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=(0,Ut.useTranslation)(),r=(0,jc.useCallback)(i=>{i.stopPropagation();let a=document.querySelectorAll(`.react-flow__handle.source[data-nodeid="${e}"]`);if(a.length===0)return;let s=Array.from(a).reduce((m,p)=>{let g=m.getBoundingClientRect(),x=p.getBoundingClientRect(),f=Math.hypot(i.clientX-(g.left+g.width/2),i.clientY-(g.top+g.height/2));return Math.hypot(i.clientX-(x.left+x.width/2),i.clientY-(x.top+x.height/2))<f?p:m}),l=s.getBoundingClientRect(),c=l.left+l.width/2,d=l.top+l.height/2,u=new MouseEvent("mousedown",{clientX:c,clientY:d,bubbles:!0,cancelable:!0});s.dispatchEvent(u)},[e]);return(0,$o.jsxs)(Ut.Tooltip,{children:[(0,$o.jsx)(Ut.TooltipTrigger,{asChild:!0,children:(0,$o.jsx)(Ut.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:(0,$o.jsx)(Qc.MoveUpRightIcon,{size:16})})}),(0,$o.jsx)(Ut.TooltipContent,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};var wn=require("react/jsx-runtime"),In=i=>{var a=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=a,r=Yt(a,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:s}=q(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d,isToEndEvent:u}=Yr(o,n),m=!l&&!c&&!d&&!u,p=[{component:(0,wn.jsx)(Pi,{elementId:e,elementType:"edge"})}],g=()=>s==="view"?m?[{component:(0,wn.jsx)(To,{elementId:e,elementType:"edge"})}]:[]:m?[{component:(0,wn.jsx)(To,{elementId:e,elementType:"edge"})},...p]:p,f=(h=>{switch(h){case"SEQUENCE_EDGE":return g();case"MESSAGE_EDGE":return s==="view"?[]:[...p];case"ANNOTATION_EDGE":return s==="view"?[]:[...p];default:return[]}})(t);if(!(f.length===0||s==="readonly"))return(0,wn.jsx)("div",v(N({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:f.map((h,_)=>(0,wn.jsx)("div",{children:h.component},_))}))};var ed=require("@xyflow/react"),td=require("react");var Vs=require("react/jsx-runtime"),$t=12,An=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:a}=(0,ed.useViewport)(),s=1/a,l=(0,td.useMemo)(()=>t===n?{bottom:`${$t}px`,transform:"translateX(-50%)"}:e===o?{left:`${$t}px`,transform:r?"translateY(-100%)":"translateY(-50%)"}:n>t&&o>e?{left:`${$t}px`,bottom:`${$t}px`}:n>t&&o<e?{right:`${$t}px`,bottom:`${$t}px`}:t>n&&o>e?{right:`${$t}px`,bottom:`${$t}px`}:{left:`${$t}px`,bottom:`${$t}px`},[e,t,o,n,r]);return(0,Vs.jsx)("div",{style:{transform:`scale(${s})`},children:(0,Vs.jsx)("div",{className:"absolute pointer-events-auto",style:N({},l),children:i})})};var mt=require("react/jsx-runtime"),Cn={type:"ANNOTATION_EDGE",reconnectable:!0},od=({id:e,source:t,target:o,selected:n,data:r})=>{let{isMultipleSelection:i}=q(),{zoom:a}=(0,Dt.useViewport)(),s=(0,Dt.useInternalNode)(t),l=(0,Dt.useInternalNode)(o);if(!s||!l)return null;let{sx:c,sy:d,tx:u,ty:m}=gn(s,l),[p,g,x]=(0,Dt.getStraightPath)({sourceX:c,sourceY:d,targetX:u,targetY:m}),f=n||(s==null?void 0:s.selected)||(l==null?void 0:l.selected);return(0,mt.jsx)(mt.Fragment,{children:(0,mt.jsxs)("g",{className:H("group bpmn-edge",{"is-highlighted":f}),children:[(0,mt.jsx)("path",{d:p,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/a),style:{pointerEvents:"stroke",cursor:"pointer"}}),(0,mt.jsxs)("g",{className:H("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":f}),children:[(0,mt.jsx)(Dt.BaseEdge,{id:e,path:p,interactionWidth:0,strokeDasharray:4,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":r==null?void 0:r.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":f&&!(r!=null&&r.hasError)})}),(0,mt.jsx)(Dt.EdgeLabelRenderer,{children:(0,mt.jsx)("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${g}px, ${x}px)`},children:n&&!i&&(0,mt.jsx)(An,{sx:c,sy:d,tx:u,ty:m,children:(0,mt.jsx)(In,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})})})]})]})})};var Je=require("react"),Le=require("@xyflow/react");var Ot=require("react");var Gs=require("react/jsx-runtime"),Hs=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,nd=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Escape","Shift"],Ze=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:a,onBlur:s,onInput:l,onInvalidFirstCharacter:c,skipFirstCharValidation:d})=>{let u=(0,Ot.useRef)(null),m=(0,Ot.useRef)(null),[p,g]=(0,Ot.useState)(!1);(0,Ot.useEffect)(()=>()=>{m.current&&clearTimeout(m.current)},[]),(0,Ot.useEffect)(()=>{g(i!=null?i:!1)},[i]),(0,Ot.useEffect)(()=>{if(p&&u.current){u.current.focus();let E=document.createRange();E.selectNodeContents(u.current);let y=window.getSelection();y&&(y.removeAllRanges(),y.addRange(E))}},[p]);let x=(0,Ot.useCallback)(()=>{m.current||(c==null||c(),m.current=setTimeout(()=>{m.current=null},500))},[c]),f=E=>{E.stopPropagation(),p||g(!0)},h=E=>{let y=E.currentTarget.innerText.replace(/\n$/,""),w=t&&y.length>=t,C=window.getSelection(),A=(C==null?void 0:C.toString())||"",R=A.length>0,G=(E.ctrlKey||E.metaKey)&&!E.altKey,M=G&&E.key==="a",P=G&&E.key==="c",X=G&&E.key==="x",$=G&&E.key==="v",Z=y.length===0||R&&A.length===y.length;if(!d&&Z&&!Hs.test(E.key)&&!nd.includes(E.key)&&!G){E.preventDefault(),x();return}w&&!R&&(nd.includes(E.key)||M||P||X||$||E.preventDefault())},_=E=>{E.preventDefault();let y=E.clipboardData.getData("text/plain").replace(/\r\n/g,`
|
|
1
|
+
"use strict";var Zp=Object.create;var Xn=Object.defineProperty,Jp=Object.defineProperties,Qp=Object.getOwnPropertyDescriptor,jp=Object.getOwnPropertyDescriptors,ef=Object.getOwnPropertyNames,kr=Object.getOwnPropertySymbols,tf=Object.getPrototypeOf,ps=Object.prototype.hasOwnProperty,fa=Object.prototype.propertyIsEnumerable;var pa=(e,t,o)=>t in e?Xn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,b=(e,t)=>{for(var o in t||(t={}))ps.call(t,o)&&pa(e,o,t[o]);if(kr)for(var o of kr(t))fa.call(t,o)&&pa(e,o,t[o]);return e},w=(e,t)=>Jp(e,jp(t));var Yt=(e,t)=>{var o={};for(var n in e)ps.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&kr)for(var n of kr(e))t.indexOf(n)<0&&fa.call(e,n)&&(o[n]=e[n]);return o};var of=(e,t)=>{for(var o in t)Xn(e,o,{get:t[o],enumerable:!0})},ma=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ef(t))!ps.call(e,r)&&r!==o&&Xn(e,r,{get:()=>t[r],enumerable:!(n=Qp(t,r))||n.enumerable});return e};var nf=(e,t,o)=>(o=e!=null?Zp(tf(e)):{},ma(t||!e||!e.__esModule?Xn(o,"default",{value:e,enumerable:!0}):o,e)),rf=e=>ma(Xn({},"__esModule",{value:!0}),e);var Jh={};of(Jh,{EditorMode:()=>Be,ElementPosition:()=>Dr,ElementType:()=>Un,GatewayElementVariant:()=>Or,GatewayVariant:()=>wt,Modeler:()=>qp,ModelerProvider:()=>Xp,NodeAttribute:()=>kt,NodeType:()=>ie,NodeVariant:()=>pt,RoutingVariant:()=>Vr,useModeler:()=>wn});module.exports=rf(Jh);var fs=e=>{if(typeof document=="undefined")return;let t=document.cookie.match(new RegExp(`(?:^|; )${e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")}=([^;]*)`));return t?decodeURIComponent(t[1]):void 0};var Rr=require("@produto-lecom/lecom-ui");var ga={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Delete",configure_node:"Configure activity",configure_edge:"Configure routing",configure_gateway:"Configure routing",initial_task:"Initial Activity",gateway_limit_reached:"Exclusive gateway cannot have more than 2 outgoing connections",task_limit_reached:"Task cannot have more than 2 outgoing connections",start_event_limit_reached:"Start event can only connect to a single element",gateway_to_gateway_not_allowed:"Gateways cannot connect directly to other gateways",start_event_already_exists:"A start event already exists. Delete the current event to add another",script_to_end_not_allowed:"Script activities cannot connect directly to the end event",loop_to_end_not_allowed:"Loop activities cannot connect directly to the end event",initial_activity_to_end_not_allowed:"Initial activity cannot connect directly to the end event",final_activity_cannot_connect:"Final activity cannot connect to other elements",activity_has_outgoing_connections:"Activity with outgoing connections cannot connect to end event",end_event_cannot_connect_to_initial_activity:"End event cannot connect to an initial activity",initial_activity_cannot_connect_to_start_event:"Initial activity cannot connect to start event",concurrent_initial_and_final_activity:"An activity cannot be connected to both start and end events",duplicate_connection_not_allowed:"A connection already exists between these elements",connect_node:"Connect element",connecting:"Connecting...",delete_pool_lane_error:"Cannot delete the pool or lane while there are elements inside it."},controls:{zoom:{fit:"Fit zoom",in:"Zoom in",out:"Zoom out",reset:"Reset zoom"},actions:{move_tool:"Select elements",hand_tool:"Navigate the diagram",check:"Check diagram",check_loading:"Validating diagram...",export:{title:"Export diagram",print:"Print",html:"Export as HTML",png:"Export as PNG",feedback:{empty:"Cannot export an empty diagram",error:"Error exporting diagram"}},import_governance:"Import diagram from Governance platform",minimap:{label:"Minimap",open:"Open minimap",close:"Hide minimap"}},history:{undo:"Undo",redo:"Redo"}},modals:{delete_elements:{title:"Delete elements",callout:"When deleting, the activity and routing settings will be deleted.",content:"Are you sure you want to delete?",confirm:"Delete",cancel:"Cancel"}},task_menu:{loop_not_allowed_when_connected_to_end:"Cannot create loop on activity connected to end event",script_not_allowed_when_connected_to_end:"Cannot transform to Script activity connected to end event",loop_not_allowed_when_subprocess:"Cannot create loop on subprocess",loop:"Activity with loop"}},validation:{success:{title:"Validation Successful",message:"The diagram was validated successfully with no errors."},errors:{title:"The diagram contains errors",subtitle:"Please review the following:",task_label_length:"Task name exceeds the maximum character limit",multiple_start_event_not_allowed:"Multiple start events are not allowed",task_flows_limit_exceeds:"The number of output connections exceeds the limit of two",duplicate_task_name:"There are multiple activities with the same name",flows_on_end_tasks_not_allowed:"Activities connected to end events cannot have other connections",conditions_flows_limit_exceeds:"Exclusive gateway has too many output connections (maximum of two)",task_label_empty:"One or more activities have no name",activity_name_invalid:"Activity name is invalid",final_activity_has_loop:"Final activities cannot have loops",nested_gateway:"Connecting gateways directly is not allowed",concurrent_initial_and_final_event:"The same activity cannot have both initial and final events",gateway_flow_to_event:"Connecting a gateway to an output event is not allowed",gateway_missing_output_streams:"The gateway does not have the correct number of outputs",events_nested:"Connecting events directly is not allowed",event_to_condition:"Connecting an event directly to a gateway is not allowed",script_in_final_activity:"Final activity cannot be a script type",subprocess_not_configured:"The subprocess reference is not properly configured",cannot_validate_subprocess_reference:"Could not validate whether the subprocess reference is configured",start_event_not_found:"At least one start event is required",end_event_not_found:"At least one end event is required"}},bpmn:{start_event:{variant:{default:"Start event"}},end_event:{variant:{default:"End event"}},annotation:{variant:{default:"Annotation"}},gateway:{menu:{title:"Change gateway type"},variant:{default:"Gateway",exclusive:"Exclusive gateway",parallel:"Parallel gateway",complex:"Complex gateway"}},task:{menu:{title:"Change task type"},variant:{default:"Task",script:"Script task",subprocess:"Subprocess"},attribute:{loop:"Task with loop"},label:{prefix:"Activity"},feedback:{label_empty:{prefix:"Activity name was automatically set to"},label_already_exists:{prefix:"The name",middle:"already exists. The name was changed to"},invalid_first_character:"Activity name must start with a letter or number"}},lane:{variant:{default:"Pool / Lane"}},unsupported:{variant:{default:"Unsupported element"}}},adapter:{governance:{error:{DEFAULT:"Error importing diagram",NO_FILE:"No file selected",EMPTY_FILE:"Empty file",INVALID_FILE:"Invalid file",CONTAIN_NO_CELLS:"No cells found to be imported",ALREADY_INITIALIZED:"It is not possible to import the diagram from the Governance platform, since the diagram has already been initialized"},success:{default:"The diagram was imported from the Governance platform successfully and without any incompatibility detected.",incompatible_cells:"The diagram was imported from the Governance platform with incompatibilities. To know more details, click on the button below."},report:{columns:{type:"Type",value:"Value",status:"Status"},status:{imported:"Imported",adapted:"Adapted",unsupported:"Unsupported"}},action:{download:"Download report"}}}}};var ha={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",configure_node:"Configurar actividad",configure_edge:"Configurar enrutamiento",configure_gateway:"Configurar enrutamiento",initial_task:"Actividad Inicial",gateway_limit_reached:"Compuerta exclusiva no puede tener m\xE1s de 2 conexiones de salida",task_limit_reached:"Actividad no puede tener m\xE1s de 2 conexiones de salida",start_event_limit_reached:"Evento inicial solo puede conectarse a un \xFAnico elemento",gateway_to_gateway_not_allowed:"Las compuertas no pueden conectarse directamente con otras compuertas",start_event_already_exists:"Ya existe un evento de inicio. Elimine el evento actual para agregar otro",script_to_end_not_allowed:"Las actividades Script no pueden conectarse directamente al evento final",loop_to_end_not_allowed:"Las actividades Loop no pueden conectarse directamente al evento final",initial_activity_to_end_not_allowed:"Actividad inicial no puede conectarse directamente al evento final",final_activity_cannot_connect:"Actividad final no puede conectarse a otros elementos",activity_has_outgoing_connections:"Actividad con conexiones de salida no puede conectarse al evento final",end_event_cannot_connect_to_initial_activity:"El evento final no puede conectarse a una actividad inicial",initial_activity_cannot_connect_to_start_event:"Actividad inicial no puede conectarse a evento de inicio",concurrent_initial_and_final_activity:"Una actividad no puede estar conectada al evento inicial y final al mismo tiempo",duplicate_connection_not_allowed:"Ya existe una conexi\xF3n entre estos elementos",connect_node:"Conectar elemento",connecting:"Conectando...",delete_pool_lane_error:"No se puede eliminar la piscina o carril mientras haya elementos dentro."},controls:{zoom:{fit:"Ajustar zoom",in:"Acercar",out:"Alejar",reset:"Restablecer zoom"},actions:{move_tool:"Seleccionar elementos",hand_tool:"Navegar por el diagrama",check:"Validar diagrama",check_loading:"Validando diagrama...",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"No es posible exportar un diagrama vac\xEDo",error:"Error al exportar diagrama"}},import_governance:"Importar diagrama de la plataforma Governance",minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Deshacer",redo:"Rehacer"}},modals:{delete_elements:{title:"Eliminar elementos",callout:"Al eliminar, las configuraciones de actividades y enrutamiento ser\xE1n eliminadas.",content:"\xBFEst\xE1s seguro de querer eliminar?",confirm:"Eliminar",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"No se puede crear bucle en actividad conectada al evento final",script_not_allowed_when_connected_to_end:"No se puede transformar a Script actividad conectada al evento final",loop_not_allowed_when_subprocess:"No se puede crear bucle en subproceso",loop:"Actividad con loop"}},validation:{success:{title:"Validaci\xF3n exitosa",message:"El diagrama ha sido validado correctamente sin errores."},errors:{title:"El diagrama contiene errores",subtitle:"Revise lo siguiente:",task_label_length:"El nombre de la actividad excede el l\xEDmite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"No se permite tener m\xE1s de un evento de inicio",task_flows_limit_exceeds:"El n\xFAmero de conexiones de salida supera el l\xEDmite de dos",duplicate_task_name:"Hay varias actividades con el mismo nombre",flows_on_end_tasks_not_allowed:"Las actividades conectadas a eventos finales no pueden tener otras conexiones",conditions_flows_limit_exceeds:"Compuerta exclusiva con exceso de conexiones de salida (m\xE1ximo de dos)",task_label_empty:"El nombre de una o m\xE1s actividades no ha sido completado",activity_name_invalid:"El nombre de la actividad no es v\xE1lido",final_activity_has_loop:"Las actividades finales no pueden tener bucles",nested_gateway:"No se permite conectar compuertas directamente",concurrent_initial_and_final_event:"Una misma actividad no puede tener eventos iniciales y finales",gateway_flow_to_event:"No se permite conectar una compuerta a un evento de salida",gateway_missing_output_streams:"La compuerta no tiene el n\xFAmero correcto de salidas",events_nested:"No se permite conectar eventos directamente",event_to_condition:"No se permite conectar un evento directamente a una compuerta",script_in_final_activity:"La actividad final no puede ser de tipo script",subprocess_not_configured:"La referencia al subproceso no est\xE1 configurada correctamente",cannot_validate_subprocess_reference:"No fue posible validar si la referencia al subproceso est\xE1 configurada",start_event_not_found:"Es necesario tener al menos un evento de inicio",end_event_not_found:"Es necesario tener al menos un evento final"}},bpmn:{start_event:{variant:{default:"Evento de inicio"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anotaci\xF3n"}},gateway:{menu:{title:"Cambiar tipo de compuerta"},variant:{default:"Compuerta",exclusive:"Compuerta exclusiva",parallel:"Compuerta paralela",complex:"Compuerta compleja"}},task:{menu:{title:"Cambiar tipo de tarea"},variant:{default:"Tarea",script:"Tarea de script",subprocess:"Subproceso"},attribute:{loop:"Tarea con bucle"},label:{prefix:"Actividad"},feedback:{label_empty:{prefix:"El nombre de la actividad se estableci\xF3 autom\xE1ticamente como"},label_already_exists:{prefix:"El nombre",middle:"ya existe. El nombre fue cambiado a"},invalid_first_character:"El nombre de la actividad debe comenzar con una letra o n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento no soportado"}}},adapter:{governance:{error:{DEFAULT:"Error al importar diagrama",NO_FILE:"No se ha seleccionado ning\xFAn archivo",EMPTY_FILE:"Archivo vac\xEDo",INVALID_FILE:"Archivo inv\xE1lido",CONTAIN_NO_CELLS:"No se encontraron c\xE9lulas para importar",ALREADY_INITIALIZED:"No es posible importar el diagrama de la plataforma Governance, ya que el diagrama ya ha sido iniciado"},success:{default:"El diagrama se ha importado de la plataforma Governance correctamente y sin ninguna incompatibilidad detectada.",incompatible_cells:"El diagrama se ha importado de la plataforma Governance con incompatibilidades. Para saber m\xE1s detalles, haz click en el bot\xF3n de abajo."},report:{columns:{type:"Tipo",value:"Valor",status:"Estado"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"No soportado"}},action:{download:"Descargar informe"}}}}};var ya={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Excluir",configure_node:"Configurar atividade",configure_edge:"Configurar roteamento",configure_gateway:"Configurar roteamento",initial_task:"Atividade Inicial",gateway_limit_reached:"Gateway exclusivo n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",task_limit_reached:"Atividade n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",start_event_limit_reached:"Evento inicial s\xF3 pode se conectar a um \xFAnico elemento",gateway_to_gateway_not_allowed:"Gateways n\xE3o podem se conectar diretamente com outros gateways",start_event_already_exists:"J\xE1 existe um evento de in\xEDcio. Exclua o evento atual para adicionar outro",script_to_end_not_allowed:"Atividades Script n\xE3o podem se conectar diretamente ao evento final",loop_to_end_not_allowed:"Atividades Loop n\xE3o podem se conectar diretamente ao evento final",initial_activity_to_end_not_allowed:"Atividade inicial n\xE3o pode se conectar diretamente ao evento final",final_activity_cannot_connect:"Atividade final n\xE3o pode se conectar a outros elementos",activity_has_outgoing_connections:"Atividade com conex\xF5es de sa\xEDda n\xE3o pode se conectar a um evento final",end_event_cannot_connect_to_initial_activity:"O evento final n\xE3o pode ser conectado a uma atividade inicial",initial_activity_cannot_connect_to_start_event:"Atividade inicial n\xE3o pode se conectar a evento de in\xEDcio",concurrent_initial_and_final_activity:"Uma atividade n\xE3o pode estar conectada ao evento inicial e final ao mesmo tempo",duplicate_connection_not_allowed:"J\xE1 existe uma conex\xE3o entre esses elementos",start_event_to_subprocess_not_allowed:"Evento inicial n\xE3o pode se conectar a um subprocesso",connect_node:"Conectar elemento",connecting:"Conectando...",delete_pool_lane_error:"N\xE3o \xE9 poss\xEDvel excluir a piscina ou raia enquanto houver elementos dentro dela."},controls:{zoom:{fit:"Ajustar o zoom",in:"Aumentar o zoom",out:"Diminuir o zoom",reset:"Resetar o zoom"},actions:{move_tool:"Selecionar elementos",hand_tool:"Navegar pelo diagrama",check:"Validar diagrama",check_loading:"Validando diagrama...",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"N\xE3o \xE9 poss\xEDvel exportar um diagrama vazio",error:"Erro ao exportar o diagrama"}},import_governance:"Importar diagrama da plataforma Governance",minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Desfazer",redo:"Refazer"}},modals:{delete_elements:{title:"Excluir elementos",callout:"Ao excluir, as configura\xE7\xF5es de atividades e roteamento ser\xE3o exclu\xEDdas.",content:"Deseja realmente excluir?",confirm:"Excluir",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel criar loop em atividade conectada ao evento final",script_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel transformar em Script atividade conectada ao evento final",loop_not_allowed_when_subprocess:"N\xE3o \xE9 poss\xEDvel criar loop em subprocesso",loop:"Atividade com loop"}},validation:{success:{title:"Diagrama v\xE1lidado com sucesso!",message:"Nenhum erro encontrado."},errors:{title:"O diagrama cont\xE9m erros",subtitle:"Veja abaixo o que precisa ser corrigido:",task_label_length:"O nome da atividade excede o limite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"N\xE3o \xE9 permitido ter mais de um evento de in\xEDcio",task_flows_limit_exceeds:"O n\xFAmero de conex\xF5es de sa\xEDda ultrapassa o limite de dois",duplicate_task_name:"H\xE1 v\xE1rias atividades com o mesmo nome",flows_on_end_tasks_not_allowed:"Atividades conectadas a eventos finais n\xE3o podem ter outras conex\xF5es",conditions_flows_limit_exceeds:"Gateway exclusivo com excesso de conex\xF5es de sa\xEDda (m\xE1ximo de dois)",task_label_empty:"O nome de uma ou mais atividades n\xE3o foi preenchido",activity_name_invalid:"O nome da atividade n\xE3o \xE9 v\xE1lido",final_activity_has_loop:"Atividades finais n\xE3o podem ter loops",nested_gateway:"N\xE3o \xE9 permitido conectar gateways",concurrent_initial_and_final_event:"Uma mesma atividade n\xE3o pode ter eventos iniciais e finais",gateway_flow_to_event:"N\xE3o \xE9 permitido conectar um gateway a um evento de sa\xEDda",gateway_missing_output_streams:"O gateway n\xE3o possui o n\xFAmero correto de sa\xEDdas",events_nested:"N\xE3o \xE9 permitido conectar eventos",event_to_condition:"N\xE3o \xE9 permitido conectar um evento diretamente em um gateway",script_in_final_activity:"Atividade final n\xE3o pode ser do tipo script",subprocess_not_configured:"A refer\xEAncia ao subprocesso n\xE3o est\xE1 configurada corretamente",cannot_validate_subprocess_reference:"N\xE3o foi poss\xEDvel validar se a refer\xEAncia ao subprocesso est\xE1 configurada",start_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento inicial",end_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento final"}},bpmn:{start_event:{variant:{default:"Evento inicial"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anota\xE7\xE3o"}},gateway:{menu:{title:"Alterar tipo de gateway"},variant:{default:"Gateway",exclusive:"Gateway exclusivo",parallel:"Gateway paralelo",complex:"Gateway complexo"}},task:{menu:{title:"Alterar tipo de atividade"},variant:{default:"Atividade",script:"Atividade de script",subprocess:"Subprocesso"},attribute:{loop:"Atividade com loop"},label:{prefix:"Atividade"},feedback:{label_empty:{prefix:"O nome da atividade foi definido automaticamente como"},label_already_exists:{prefix:"O nome",middle:"j\xE1 existe. O nome foi alterado para"},invalid_first_character:"O nome da atividade deve come\xE7ar com uma letra ou n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento n\xE3o suportado"}}},adapter:{governance:{error:{DEFAULT:"Erro ao importar diagrama",NO_FILE:"Nenhum arquivo selecionado",EMPTY_FILE:"Arquivo vazio",INVALID_FILE:"Arquivo inv\xE1lido",CONTAIN_NO_CELLS:"N\xE3o foram encontradas c\xE9lulas para serem importadas",ALREADY_INITIALIZED:"N\xE3o \xE9 poss\xEDvel importar o diagrama da plataforma Governance, pois o diagrama j\xE1 foi iniciado"},success:{default:"O diagrama foi importado da plataforma Governance com sucesso e sem nenhuma incompatibilidade detectada.",incompatible_cells:"O diagrama foi importado da plataforma Governance com incompatibilidades. Para saber mais detalhes, clique no bot\xE3o abaixo."},report:{columns:{type:"Tipo do elemento",value:"Valor",status:"Status"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"N\xE3o suportado"}},action:{download:"Baixar relat\xF3rio"}}}}};var xa={pt_BR:ya,en_US:ga,es_ES:ha};var Ea,ba,sf=(ba=(Ea=fs("LecomUserLanguage"))!=null?Ea:fs("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?ba:Rr.Translations.PT_BR;(0,Rr.initializeI18n)({lng:sf,resources:xa});var Be=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(Be||{});var Un=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(Un||{}),Dr=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Dr||{}),Or=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Or||{}),Vr=(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))(Vr||{});var gn=require("lucide-react");var Oo=require("react/jsx-runtime"),Hr=({size:e=24,className:t})=>(0,Oo.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:[(0,Oo.jsx)("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),(0,Oo.jsx)("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),(0,Oo.jsx)("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),(0,Oo.jsx)("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});var ms=require("react/jsx-runtime"),an=({size:e=24,className:t})=>(0,ms.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#ff6565",stroke:"#ec1616",strokeWidth:3,className:t,children:(0,ms.jsx)("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});var ho=require("react/jsx-runtime"),ln=({size:e=24,className:t})=>(0,ho.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[(0,ho.jsx)("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ho.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ho.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ho.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ho.jsx)("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var cn=require("react/jsx-runtime"),dn=({size:e=24,className:t})=>(0,cn.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[(0,cn.jsx)("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,cn.jsx)("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,cn.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var un=require("react/jsx-runtime"),pn=({size:e=24,className:t})=>(0,un.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[(0,un.jsx)("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,un.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,un.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});var fn=require("react/jsx-runtime"),_a=({size:e=24,className:t})=>(0,fn.jsx)("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:(0,fn.jsxs)("g",{children:[(0,fn.jsx)("path",{d:"M8.6543 11.4141V15.2148C8.51302 15.4017 8.29199 15.6068 7.99121 15.8301C7.69499 16.0488 7.30078 16.238 6.80859 16.3975C6.31641 16.557 5.70345 16.6367 4.96973 16.6367C4.34538 16.6367 3.77344 16.5319 3.25391 16.3223C2.73438 16.1081 2.28548 15.7959 1.90723 15.3857C1.53353 14.9756 1.24414 14.4766 1.03906 13.8887C0.833984 13.2962 0.731445 12.6217 0.731445 11.8652V11.1748C0.731445 10.4229 0.82487 9.75293 1.01172 9.16504C1.20312 8.57259 1.47656 8.07129 1.83203 7.66113C2.1875 7.25098 2.61589 6.94108 3.11719 6.73145C3.62305 6.51725 4.19499 6.41016 4.83301 6.41016C5.64876 6.41016 6.32324 6.54688 6.85645 6.82031C7.39421 7.08919 7.80892 7.46289 8.10059 7.94141C8.39225 8.41992 8.57682 8.9668 8.6543 9.58203H6.97266C6.91797 9.23568 6.81087 8.92578 6.65137 8.65234C6.49642 8.37891 6.27311 8.16471 5.98145 8.00977C5.69434 7.85026 5.32064 7.77051 4.86035 7.77051C4.46387 7.77051 4.11523 7.8457 3.81445 7.99609C3.51367 8.14648 3.26302 8.36751 3.0625 8.65918C2.86654 8.95085 2.71842 9.30632 2.61816 9.72559C2.5179 10.1449 2.46777 10.6234 2.46777 11.1611V11.8652C2.46777 12.4121 2.52474 12.8975 2.63867 13.3213C2.75716 13.7451 2.92578 14.1029 3.14453 14.3945C3.36784 14.6862 3.639 14.9072 3.95801 15.0576C4.27702 15.2035 4.63704 15.2764 5.03809 15.2764C5.43001 15.2764 5.7513 15.2445 6.00195 15.1807C6.2526 15.1123 6.45085 15.0326 6.59668 14.9414C6.74707 14.8457 6.86328 14.7546 6.94531 14.668V12.6924H4.87402V11.4141H8.6543ZM17.0912 11.25V11.7969C17.0912 12.5488 16.9932 13.2233 16.7973 13.8203C16.6013 14.4173 16.321 14.9255 15.9564 15.3447C15.5964 15.764 15.1635 16.0853 14.6576 16.3086C14.1518 16.5273 13.5912 16.6367 12.976 16.6367C12.3653 16.6367 11.807 16.5273 11.3012 16.3086C10.7999 16.0853 10.3646 15.764 9.99551 15.3447C9.62637 14.9255 9.33926 14.4173 9.13418 13.8203C8.93366 13.2233 8.8334 12.5488 8.8334 11.7969V11.25C8.8334 10.498 8.93366 9.82585 9.13418 9.2334C9.3347 8.63639 9.61725 8.12826 9.98184 7.70898C10.351 7.28516 10.7862 6.96387 11.2875 6.74512C11.7934 6.52181 12.3516 6.41016 12.9623 6.41016C13.5775 6.41016 14.1381 6.52181 14.6439 6.74512C15.1498 6.96387 15.585 7.28516 15.9496 7.70898C16.3142 8.12826 16.5945 8.63639 16.7904 9.2334C16.991 9.82585 17.0912 10.498 17.0912 11.25ZM15.3754 11.7969V11.2363C15.3754 10.6803 15.3207 10.1904 15.2113 9.7666C15.1065 9.33822 14.9493 8.98047 14.7396 8.69336C14.5346 8.40169 14.2816 8.18294 13.9809 8.03711C13.6801 7.88672 13.3406 7.81152 12.9623 7.81152C12.584 7.81152 12.2468 7.88672 11.9506 8.03711C11.6544 8.18294 11.4014 8.40169 11.1918 8.69336C10.9867 8.98047 10.8295 9.33822 10.7201 9.7666C10.6107 10.1904 10.5561 10.6803 10.5561 11.2363V11.7969C10.5561 12.3529 10.6107 12.8451 10.7201 13.2734C10.8295 13.7018 10.989 14.0641 11.1986 14.3604C11.4128 14.652 11.668 14.873 11.9643 15.0234C12.2605 15.1693 12.5977 15.2422 12.976 15.2422C13.3588 15.2422 13.6983 15.1693 13.9945 15.0234C14.2908 14.873 14.5414 14.652 14.7465 14.3604C14.9516 14.0641 15.1065 13.7018 15.2113 13.2734C15.3207 12.8451 15.3754 12.3529 15.3754 11.7969ZM20.6678 14.6816L23.2859 6.54688H25.1795L21.6111 16.5H20.3328L20.6678 14.6816ZM18.2479 6.54688L20.8455 14.6816L21.201 16.5H19.9158L16.3611 6.54688H18.2479Z"}),(0,fn.jsx)("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});var Na=require("clsx"),Ta=require("tailwind-merge");function H(...e){return(0,Ta.twMerge)((0,Na.clsx)(e))}var yo=(e=0,t=0)=>e<t?t:e,Gr=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});var $n=require("react/jsx-runtime"),va=({size:e=24,className:t})=>(0,$n.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:H("stroke-2",t),children:[(0,$n.jsx)("path",{d:"M19 3H5C3.89543 3 3 3.89543 3 5V19C3 20.1046 3.89543 21 5 21H19C20.1046 21 21 20.1046 21 19V5C21 3.89543 20.1046 3 19 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,$n.jsx)("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});var Br=require("react/jsx-runtime"),wa=({size:e=24,className:t})=>(0,Br.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:(0,Br.jsx)("g",{children:(0,Br.jsx)("path",{d:"M4.85372 6.17472L5.31292 5.71552L5.31993 5.70863C6.88908 4.1924 8.98352 3.34122 11.1655 3.33301L11.1668 3.33301C11.167 3.33301 11.1673 3.33301 11.1675 3.33301C12.7165 3.33314 14.2308 3.79255 15.5188 4.65317C16.807 5.5139 17.811 6.7373 18.4039 8.16866C18.9968 9.60001 19.1519 11.175 18.8497 12.6945C18.5986 13.9567 18.0414 15.1334 17.232 16.1236L16.9457 16.4738L17.2655 16.7936L20.6617 20.1899L20.6617 20.1899C20.7919 20.3201 20.7919 20.5311 20.6617 20.6612L20.6616 20.6613C20.5316 20.7915 20.3205 20.7915 20.1903 20.6613L16.7941 17.265L16.4743 16.9452L16.1241 17.2315C15.1339 18.0409 13.9571 18.5981 12.695 18.8492C11.1755 19.1514 9.6005 18.9963 8.16915 18.4034C6.73778 17.8105 5.51439 16.8065 4.65365 15.5183C3.79291 14.2301 3.3335 12.7156 3.3335 11.1663C3.3335 10.9822 3.48273 10.833 3.66683 10.833C3.85093 10.833 4.00016 10.9822 4.00016 11.1663C4.00016 12.5838 4.42048 13.9694 5.20796 15.148C5.99545 16.3265 7.11474 17.245 8.42426 17.7874C9.73378 18.3299 11.1748 18.4719 12.565 18.1953C13.9552 17.9188 15.2321 17.2362 16.2344 16.234L16.2345 16.234C17.2367 15.2316 17.9193 13.9547 18.1958 12.5645C18.4724 11.1743 18.3304 9.7333 17.7879 8.42378C17.2455 7.11426 16.327 5.99497 15.1484 5.20748L14.8707 5.62322L15.1484 5.20748C13.9703 4.42031 12.5854 4.00001 11.1685 3.99968L11.1664 3.99969C9.15876 4.00767 7.23176 4.7903 5.78712 6.18424L5.78706 6.18418L5.78075 6.1905L5.32512 6.64613L4.47156 7.49968H5.67867H7.8335C8.01759 7.49968 8.16683 7.64892 8.16683 7.83302C8.16683 8.01711 8.01759 8.16635 7.8335 8.16635H3.66683C3.48274 8.16635 3.3335 8.01711 3.3335 7.83302V3.66635C3.3335 3.48225 3.48274 3.33302 3.66683 3.33302C3.85092 3.33302 4.00016 3.48225 4.00016 3.66635V5.82117V7.02827L4.85372 6.17472Z"})})});var gs=require("react/jsx-runtime"),zr=({size:e=24,className:t})=>(0,gs.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#5fd9b0",stroke:"#1cad86",strokeWidth:"2",className:t,children:(0,gs.jsx)("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});var hs=require("react/jsx-runtime"),Kn=({size:e=24,className:t})=>(0,hs.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",className:H("stroke-2",t),children:(0,hs.jsx)("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"})});var mn=require("react/jsx-runtime"),Ia=({size:e=24,className:t})=>(0,mn.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[(0,mn.jsx)("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,mn.jsx)("path",{d:"M7.5 12C7.5 12.89 7.76392 13.76 8.25839 14.5001C8.75285 15.2401 9.45566 15.8169 10.2779 16.1575C11.1002 16.4981 12.005 16.5872 12.8779 16.4135C13.7508 16.2399 14.5526 15.8113 15.182 15.182C15.8113 14.5526 16.2399 13.7508 16.4135 12.8779C16.5872 12.005 16.4981 11.1002 16.1575 10.2779C15.8169 9.45566 15.2401 8.75285 14.5001 8.25839C13.76 7.76392 12.89 7.5 12 7.5C10.742 7.50473 9.53448 7.99561 8.63 8.87L7.5 10",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,mn.jsx)("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});var xo=require("react/jsx-runtime"),Aa=({size:e=24,className:t})=>(0,xo.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[(0,xo.jsx)("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,xo.jsx)("path",{d:"M15.5 14.5V8.5C15.5 8.23478 15.3946 7.98043 15.2071 7.79289C15.0196 7.60536 14.7652 7.5 14.5 7.5H8",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,xo.jsx)("path",{d:"M10 16.5H16C16.2652 16.5 16.5196 16.3946 16.7071 16.2071C16.8946 16.0196 17 15.7652 17 15.5V15C17 14.8674 16.9473 14.7402 16.8536 14.6464C16.7598 14.5527 16.6326 14.5 16.5 14.5H11.5C11.3674 14.5 11.2402 14.5527 11.1464 14.6464C11.0527 14.7402 11 14.8674 11 15V15.5C11 15.7652 10.8946 16.0196 10.7071 16.2071C10.5196 16.3946 10.2652 16.5 10 16.5ZM10 16.5C9.73478 16.5 9.48043 16.3946 9.29289 16.2071C9.10536 16.0196 9 15.7652 9 15.5V8.5C9 8.23478 8.89464 7.98043 8.70711 7.79289C8.51957 7.60536 8.26522 7.5 8 7.5C7.73478 7.5 7.48043 7.60536 7.29289 7.79289C7.10536 7.98043 7 8.23478 7 8.5V9.5C7 9.63261 7.05268 9.75979 7.14645 9.85355C7.24021 9.94732 7.36739 10 7.5 10H9",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,xo.jsx)("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,xo.jsx)("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var Vo=require("react/jsx-runtime"),qn=({size:e=24,className:t})=>(0,Vo.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[(0,Vo.jsx)("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Vo.jsx)("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),(0,Vo.jsx)("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Vo.jsx)("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var ie=(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))(ie||{}),pt=(o=>(o.SCRIPT="SCRIPT",o.SUBPROCESS="SUBPROCESS",o))(pt||{}),Yr={SCRIPT:{icon:gn.ScrollText},SUBPROCESS:{icon:gn.SquarePlus}},kt=(t=>(t.LOOP="LOOP",t))(kt||{}),Wr={LOOP:{icon:gn.RotateCcw}},wt=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(wt||{}),ys={EXCLUSIVE:{icon:dn},PARALLEL:{icon:pn},COMPLEX:{icon:ln}};var Up=require("@produto-lecom/lecom-ui"),$p=require("@xyflow/react"),Ge=require("react");var to=require("@xyflow/react"),ko=require("react");var ap=require("@produto-lecom/lecom-ui"),Qt=require("@xyflow/react"),Lt=require("react");var hn=require("@xyflow/react");function Ca(e,t){var x,v,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+((v=(x=t==null?void 0:t.measured)==null?void 0:x.width)!=null?v:0)/2,p=i.y+((T=(N=t==null?void 0:t.measured)==null?void 0:N.height)!=null?T:0)/2,m=(d-l)/(2*a)-(p-c)/(2*s),u=(d-l)/(2*a)+(p-c)/(2*s),g=1/(Math.abs(m)+Math.abs(u)||1),E=g*m,f=g*u,h=a*(E+f)+l,y=s*(-E+f)+c;return{x:h,y}}function Sa(e,t){var c,d,p,m;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(m=(p=e.measured)==null?void 0:p.height)!=null?m:0,i=Math.round(o.x),a=Math.round(o.y),s=Math.round(t.x),l=Math.round(t.y);return s<=i+1?hn.Position.Left:s>=i+n-1?hn.Position.Right:l<=a+1?hn.Position.Top:l>=a+r-1?hn.Position.Bottom:hn.Position.Top}function yn(e,t){let o=Ca(e,t),n=Ca(t,e),r=Sa(e,o),i=Sa(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function Fr(e,t){return{isFromStartEvent:(e==null?void 0:e.type)==="START_EVENT",isGatewayToGateway:(e==null?void 0:e.type)==="GATEWAY"&&(t==null?void 0:t.type)==="GATEWAY",isActiviyToAndGateway:(e==null?void 0:e.type)==="TASK"&&(t==null?void 0:t.type)==="GATEWAY",isToEndEvent:(t==null?void 0:t.type)==="END_EVENT"}}var Xr={MIN_WIDTH:36,MIN_HEIGHT:36},Ur={MIN_WIDTH:36,MIN_HEIGHT:36},xn={MIN_WIDTH:56,MIN_HEIGHT:56},Eo={MIN_WIDTH:176,MIN_HEIGHT:96},Ma={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},se={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},En={MIN_WIDTH:176,MIN_HEIGHT:64},af={MIN_WIDTH:128,MIN_HEIGHT:64},pe={START_EVENT:Xr,END_EVENT:Ur,GATEWAY:xn,TASK:Eo,LANE:se,ANNOTATION:En,UNSUPPORTED:af};var Pa=require("lodash");var La=e=>new Map(e.map(t=>[t.id,t])),ka=(e,t)=>e.map(o=>{var n;return(n=t.get(o.id))!=null?n:o}),It=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}},Ho=e=>(0,Pa.orderBy)(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),Ra=(e,t)=>{let{x:o,y:n}=It(e),{x:r,y:i}=It(t);return{x:o-r,y:n-i}};var Go=({parentId:e,nodes:t,includeTypes:o=[...Object.values(ie)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),lf=(e,t)=>{let{x:o,y:n}=It(e),{x:r,y:i}=It(t),a=o-r,s=n-i;return Math.sqrt(a*a+s*s)},cf=(e,t)=>{let{x:o,y:n,w:r,h:i}=It(e),{x:a,y:s,w:l,h:c}=It(t),d=o+r/2,p=n+i/2;return d>=a&&d<=a+l&&p>=s&&p<=s+c},Zn=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&cf(e,r)){let i=lf(e,r);i<n&&(n=i,o=r)}return o},Da=(e,t)=>t.filter(o=>o.parentId===e).reduce((o,n)=>{var r,i;return Math.max(o,(i=(r=n.measured)==null?void 0:r.width)!=null?i:0)},0),Oa=(e,t)=>{let o=e.filter(c=>!c.parentId);if(o.length===0)return{nodes:e,edges:t};let n=o.filter(c=>c.type==="LANE"),r=n.length>0?n:o,i=Math.min(...r.map(c=>c.position.x||0)),a=Math.min(...r.map(c=>c.position.y||0)),s=e.map(c=>c.parentId?c:w(b({},c),{position:{x:c.position.x-i,y:c.position.y-a}})),l=t.map(c=>{let d=c.data;return d!=null&&d.points?w(b({},c),{data:w(b({},d),{points:d.points.map(p=>({x:p.x-i,y:p.y-a}))})}):c});return{nodes:s,edges:l}},Va=e=>{var l,c;let t=e.filter(d=>!d.parentId),o=t.filter(d=>d.type==="LANE"),n=o.length>0?o:t;if(n.length===0)return null;let r=1/0,i=1/0,a=-1/0,s=-1/0;for(let d of n){let p=d.position.x+((l=d.width)!=null?l:0),m=d.position.y+((c=d.height)!=null?c:0);d.position.x<r&&(r=d.position.x),d.position.y<i&&(i=d.position.y),p>a&&(a=p),m>s&&(s=m)}return{x:r,y:i,width:a-r,height:s-i}};var xs=(e,t)=>{let o=t.find(a=>a.id===e);if(!o||o.type!=="LANE"||o.parentId)return!1;let n=It(o),r=n.x+n.w,i=n.y+n.h;return t.some(a=>{if(a.id===e||a.parentId||a.type==="LANE")return!1;let s=It(a);return s.x<r&&s.x+s.w>n.x&&s.y<i&&s.y+s.h>n.y})};var df=50,Bo=(e,t)=>{var m,u,g,E,f,h,y,x,v,N,T,_,I,S,P,R;let o=t.find(M=>M.id===e);if(!o)return t;let n=(u=(m=o.position)==null?void 0:m.x)!=null?u:0,r=(E=(g=o.position)==null?void 0:g.y)!=null?E:0,i=(h=(f=o.measured)==null?void 0:f.width)!=null?h:0,a=(x=(y=o.measured)==null?void 0:y.height)!=null?x:0,s=r+a,l=n+i,c=new Set,d=1/0;for(let M of t){if(M.id===e||M.parentId)continue;let B=(N=(v=M.position)==null?void 0:v.y)!=null?N:0,X=(_=(T=M.position)==null?void 0:T.x)!=null?_:0,U=(S=(I=M.measured)==null?void 0:I.width)!=null?S:0,Q=(R=(P=M.measured)==null?void 0:P.height)!=null?R:0;X<l&&X+U>n&&B<s&&B+Q>r&&(c.add(M.id),d=Math.min(d,B))}if(c.size===0)return t;let p=s+df-d;return t.map(M=>{var X,U,Q;if(!c.has(M.id))return M;let B=(U=(X=M.position)==null?void 0:X.y)!=null?U:0;return w(b({},M),{position:w(b({},(Q=M.position)!=null?Q:{x:0,y:0}),{y:B+p})})})},De=15,zo=e=>[...e].sort((t,o)=>t.position.y-o.position.y),uf=e=>{var t,o,n;return e.position.x+((n=(o=(t=e.measured)==null?void 0:t.width)!=null?o:e.width)!=null?n:0)},pf=e=>{var t,o,n;return e.position.y+((n=(o=(t=e.measured)==null?void 0:t.height)!=null?o:e.height)!=null?n:0)},Es=(e,t,o)=>{var d,p,m,u,g,E,f,h,y,x,v,N,T,_,I;if(t.length===0)return e;let n=(m=(p=e.width)!=null?p:(d=e.measured)==null?void 0:d.width)!=null?m:0,r=(E=(g=e.height)!=null?g:(u=e.measured)==null?void 0:u.height)!=null?E:0,i=0,a=0;for(let S of t){let P=uf(S),R=pf(S);if(((h=(f=S.position)==null?void 0:f.y)!=null?h:0)<De&&(o.set(S.id,w(b({},S),{position:w(b({},S.position),{y:De})})),R=De+((x=(y=S.measured)==null?void 0:y.height)!=null?x:0)),((N=(v=S.position)==null?void 0:v.x)!=null?N:0)<se.HEADER_WIDTH+De){let M=(T=o.get(S.id))!=null?T:S;o.set(S.id,w(b({},M),{position:w(b({},M.position),{x:se.HEADER_WIDTH+De})})),P=se.HEADER_WIDTH+De+((I=(_=S.measured)==null?void 0:_.width)!=null?I:0)}i=Math.max(i,P),a=Math.max(a,R)}let s=Math.max(n,se.MIN_WIDTH),l=Math.max(r,se.MIN_HEIGHT);i+De>s&&(s=i+De),a+De>l&&(l=a+De);let c=w(b({},e),{width:s,height:l,measured:w(b({},e.measured),{width:s,height:l})});return o.set(e.id,c),c},Ha=(e,t,o)=>{var a,s;let n=zo(e),r=new Map;for(let l of o)l.parentId&&(r.has(l.parentId)||r.set(l.parentId,[]),r.get(l.parentId).push(l));let i=0;for(let l of n){let c=(a=r.get(l.id))!=null?a:[],d=Es(l,c,t);t.set(d.id,w(b({},d),{position:{x:se.HEADER_WIDTH,y:i}})),i+=(s=d.height)!=null?s:0}},Ga=(e,t)=>{var g,E,f,h;let o=[];for(let y of t.values())y.parentId===e.id&&o.push(y);let n=zo(o),r=((E=(g=e.measured)==null?void 0:g.width)!=null?E:0)-se.HEADER_WIDTH,i=Da(e.id,o)||se.MIN_WIDTH,a=o.reduce((y,x)=>{var v;return y+((v=x.height)!=null?v:se.MIN_HEIGHT)},0),s=Math.max(r,i),l=a,c=r>i,d=c?s:s+se.HEADER_WIDTH,p=c?s-se.HEADER_WIDTH:s,m=0;for(let y=0;y<n.length;y++){let x=n[y],v=Math.max(se.MIN_HEIGHT,(f=x.height)!=null?f:se.MIN_HEIGHT),N=w(b({},x),{width:p,height:v,measured:w(b({},x.measured),{width:p,height:v}),position:{x:se.HEADER_WIDTH,y:m}});if(y===o.length-1){let T=Math.max(se.MIN_HEIGHT,l-m);N=w(b({},N),{height:T,measured:w(b({},x.measured),{width:p,height:T})})}t.set(x.id,N),m+=(h=N.height)!=null?h:0}let u=Math.max(l,m);t.set(e.id,w(b({},e),{width:d,height:u,measured:w(b({},e.measured),{width:d,height:u})}))},Ba=(e,t,o,n,r)=>{var g,E;let i=!e.parentId,a=i?e.id:e.parentId,s=n.filter(f=>f.type==="LANE"&&f.parentId===a);if(!s.length)return n;let l=zo(s),c=l.findIndex(f=>f.id===e.id),d=(E=(g=e.position)==null?void 0:g.y)!=null?E:0,p=!i&&r!==void 0&&c>0&&Math.abs(r-d)>.5,m=0,u=[...n];return l.forEach((f,h)=>{var T,_;let y=h===l.length-1,x=f.id===e.id,N=(_=(T=f.measured)==null?void 0:T.height)!=null?_:0;x?N=o:p&&h===c-1&&(N=Math.max(se.MIN_HEIGHT,r-m)),y&&i&&(N=Math.max(se.MIN_HEIGHT,o-m)),u=u.map(I=>{if(I.id===f.id){let S=i?t-se.HEADER_WIDTH:t;return w(b({},I),{width:S,height:N,measured:w(b({},I.measured),{width:S,height:N}),position:{x:se.HEADER_WIDTH,y:m}})}return I}),x&&p?m=r+o:m+=N}),u=u.map(f=>{if(f.id===a){let h=i?t:t+se.HEADER_WIDTH;return w(b({},f),{width:h,height:i?o:m,measured:{width:h,height:i?o:m}})}return f}),u};var bs=(e,t,o)=>{var s,l,c,d,p,m,u,g;if(e.type==="LANE")return o;let n=(l=(s=t.measured)==null?void 0:s.width)!=null?l:0,r=(d=(c=t.measured)==null?void 0:c.height)!=null?d:0;e.position.y<De&&(e.position.y=De),e.position.x<se.HEADER_WIDTH+De&&(e.position.x=se.HEADER_WIDTH+De);let i=e.position.x+((m=(p=e.measured)==null?void 0:p.width)!=null?m:0),a=e.position.y+((g=(u=e.measured)==null?void 0:u.height)!=null?g:0);return i+De>n&&(t.width=i+De,t.measured.width=i+De),a+De>r&&(t.height=a+De,t.measured.height=a+De),o=o.map(E=>E.id===t.id?w(b({},E),{height:t.height,width:t.width,measured:t.measured}):E.id===e.id?w(b({},E),{position:e.position}):E),o};var za=require("zustand"),Ya=require("@xyflow/react"),Wa=require("react");var $r=()=>{let{setEdges:e}=(0,Ya.useReactFlow)();return(0,Wa.useCallback)(()=>{let o=Yo.getState().pathEdgeIds;e(n=>n.map(r=>w(b({},r),{selected:o.includes(r.id)})))},[e])},Yo=(0,za.create)((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,p)=>{let m=[],u=new Set;for(m.push({node:d,path:[]}),u.add(d);m.length>0;){let{node:g,path:E}=m.shift();if(g===p)return E;let f=a[g]||[];for(let{targetId:h,edgeId:y}of f)u.has(h)||(u.add(h),m.push({node:h,path:[...E,y]}))}return[]};for(let d=0;d<r.length-1;d++){let p=r[d],m=r[d+1],u=c(p,m);u.length>0&&i.push(...u)}i.length>0&&e({pathEdgeIds:i})}}));var vn=require("@xyflow/react"),ft=require("react"),Vc=require("zustand/shallow");var ff={value:()=>{}};function Xa(){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 Kr(o)}function Kr(e){this._=e}function mf(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}})}Kr.prototype=Xa.prototype={constructor:Kr,on:function(e,t){var o=this._,n=mf(e+"",o),r,i=-1,a=n.length;if(arguments.length<2){for(;++i<a;)if((r=(e=n[i]).type)&&(r=gf(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]=Fa(o[r],e.name,t);else if(t==null)for(r in o)o[r]=Fa(o[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var o in t)e[o]=t[o].slice();return new Kr(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 gf(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function Fa(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=ff,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var _s=Xa;var qr="http://www.w3.org/1999/xhtml",Ns={svg:"http://www.w3.org/2000/svg",xhtml:qr,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ro(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),Ns.hasOwnProperty(t)?{space:Ns[t],local:e}:e}function hf(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===qr&&t.documentElement.namespaceURI===qr?t.createElement(e):t.createElementNS(o,e)}}function yf(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Zr(e){var t=ro(e);return(t.local?yf:hf)(t)}function xf(){}function Wo(e){return e==null?xf:function(){return this.querySelector(e)}}function Ua(e){typeof e!="function"&&(e=Wo(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 Xe(n,this._parents)}function Ts(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Ef(){return[]}function Jn(e){return e==null?Ef:function(){return this.querySelectorAll(e)}}function bf(e){return function(){return Ts(e.apply(this,arguments))}}function $a(e){typeof e=="function"?e=bf(e):e=Jn(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 Xe(n,r)}function Qn(e){return function(){return this.matches(e)}}function Jr(e){return function(t){return t.matches(e)}}var _f=Array.prototype.find;function Nf(e){return function(){return _f.call(this.children,e)}}function Tf(){return this.firstElementChild}function Ka(e){return this.select(e==null?Tf:Nf(typeof e=="function"?e:Jr(e)))}var vf=Array.prototype.filter;function wf(){return Array.from(this.children)}function If(e){return function(){return vf.call(this.children,e)}}function qa(e){return this.selectAll(e==null?wf:If(typeof e=="function"?e:Jr(e)))}function Za(e){typeof e!="function"&&(e=Qn(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 Xe(n,this._parents)}function Qr(e){return new Array(e.length)}function Ja(){return new Xe(this._enter||this._groups.map(Qr),this._parents)}function jn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}jn.prototype={constructor:jn,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 Qa(e){return function(){return e}}function Af(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 jn(e,i[a]);for(;a<l;++a)(s=t[a])&&(r[a]=s)}function Cf(e,t,o,n,r,i,a){var s,l,c=new Map,d=t.length,p=i.length,m=new Array(d),u;for(s=0;s<d;++s)(l=t[s])&&(m[s]=u=a.call(l,l.__data__,s,t)+"",c.has(u)?r[s]=l:c.set(u,l));for(s=0;s<p;++s)u=a.call(e,i[s],s,i)+"",(l=c.get(u))?(n[s]=l,l.__data__=i[s],c.delete(u)):o[s]=new jn(e,i[s]);for(s=0;s<d;++s)(l=t[s])&&c.get(m[s])===l&&(r[s]=l)}function Sf(e){return e.__data__}function ja(e,t){if(!arguments.length)return Array.from(this,Sf);var o=t?Cf:Af,n=this._parents,r=this._groups;typeof e!="function"&&(e=Qa(e));for(var i=r.length,a=new Array(i),s=new Array(i),l=new Array(i),c=0;c<i;++c){var d=n[c],p=r[c],m=p.length,u=Mf(e.call(d,d&&d.__data__,c,n)),g=u.length,E=s[c]=new Array(g),f=a[c]=new Array(g),h=l[c]=new Array(m);o(d,p,E,f,h,u,t);for(var y=0,x=0,v,N;y<g;++y)if(v=E[y]){for(y>=x&&(x=y+1);!(N=f[x])&&++x<g;);v._next=N||null}}return a=new Xe(a,n),a._enter=s,a._exit=l,a}function Mf(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function el(){return new Xe(this._exit||this._groups.map(Qr),this._parents)}function tl(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 ol(e){for(var t=e.selection?e.selection():e,o=this._groups,n=t._groups,r=o.length,i=n.length,a=Math.min(r,i),s=new Array(r),l=0;l<a;++l)for(var c=o[l],d=n[l],p=c.length,m=s[l]=new Array(p),u,g=0;g<p;++g)(u=c[g]||d[g])&&(m[g]=u);for(;l<r;++l)s[l]=o[l];return new Xe(s,this._parents)}function nl(){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 rl(e){e||(e=Pf);function t(p,m){return p&&m?e(p.__data__,m.__data__):!p-!m}for(var o=this._groups,n=o.length,r=new Array(n),i=0;i<n;++i){for(var a=o[i],s=a.length,l=r[i]=new Array(s),c,d=0;d<s;++d)(c=a[d])&&(l[d]=c);l.sort(t)}return new Xe(r,this._parents).order()}function Pf(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function il(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function sl(){return Array.from(this)}function al(){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 ll(){let e=0;for(let t of this)++e;return e}function cl(){return!this.node()}function dl(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 Lf(e){return function(){this.removeAttribute(e)}}function kf(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Rf(e,t){return function(){this.setAttribute(e,t)}}function Df(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Of(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function Vf(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 ul(e,t){var o=ro(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?kf:Lf:typeof t=="function"?o.local?Vf:Of:o.local?Df:Rf)(o,t))}function jr(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Hf(e){return function(){this.style.removeProperty(e)}}function Gf(e,t,o){return function(){this.style.setProperty(e,t,o)}}function Bf(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function pl(e,t,o){return arguments.length>1?this.each((t==null?Hf:typeof t=="function"?Bf:Gf)(e,t,o==null?"":o)):bo(this.node(),e)}function bo(e,t){return e.style.getPropertyValue(t)||jr(e).getComputedStyle(e,null).getPropertyValue(t)}function zf(e){return function(){delete this[e]}}function Yf(e,t){return function(){this[e]=t}}function Wf(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function fl(e,t){return arguments.length>1?this.each((t==null?zf:typeof t=="function"?Wf:Yf)(e,t)):this.node()[e]}function ml(e){return e.trim().split(/^|\s+/)}function vs(e){return e.classList||new gl(e)}function gl(e){this._node=e,this._names=ml(e.getAttribute("class")||"")}gl.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 hl(e,t){for(var o=vs(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function yl(e,t){for(var o=vs(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function Ff(e){return function(){hl(this,e)}}function Xf(e){return function(){yl(this,e)}}function Uf(e,t){return function(){(t.apply(this,arguments)?hl:yl)(this,e)}}function xl(e,t){var o=ml(e+"");if(arguments.length<2){for(var n=vs(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?Uf:t?Ff:Xf)(o,t))}function $f(){this.textContent=""}function Kf(e){return function(){this.textContent=e}}function qf(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function El(e){return arguments.length?this.each(e==null?$f:(typeof e=="function"?qf:Kf)(e)):this.node().textContent}function Zf(){this.innerHTML=""}function Jf(e){return function(){this.innerHTML=e}}function Qf(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function bl(e){return arguments.length?this.each(e==null?Zf:(typeof e=="function"?Qf:Jf)(e)):this.node().innerHTML}function jf(){this.nextSibling&&this.parentNode.appendChild(this)}function _l(){return this.each(jf)}function em(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Nl(){return this.each(em)}function Tl(e){var t=typeof e=="function"?e:Zr(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function tm(){return null}function vl(e,t){var o=typeof e=="function"?e:Zr(e),n=t==null?tm:typeof t=="function"?t:Wo(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function om(){var e=this.parentNode;e&&e.removeChild(this)}function wl(){return this.each(om)}function nm(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function rm(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Il(e){return this.select(e?rm:nm)}function Al(e){return arguments.length?this.property("__data__",e):this.node().__data__}function im(e){return function(t){e.call(this,t,this.__data__)}}function sm(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 am(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 lm(e,t,o){return function(){var n=this.__on,r,i=im(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 Cl(e,t,o){var n=sm(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?lm:am,r=0;r<i;++r)this.each(s(n[r],t,o));return this}function Sl(e,t,o){var n=jr(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 cm(e,t){return function(){return Sl(this,e,t)}}function dm(e,t){return function(){return Sl(this,e,t.apply(this,arguments))}}function Ml(e,t){return this.each((typeof t=="function"?dm:cm)(e,t))}function*Pl(){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 um=[null];function Xe(e,t){this._groups=e,this._parents=t}function Ll(){return new Xe([[document.documentElement]],um)}function pm(){return this}Xe.prototype=Ll.prototype={constructor:Xe,select:Ua,selectAll:$a,selectChild:Ka,selectChildren:qa,filter:Za,data:ja,enter:Ja,exit:el,join:tl,merge:ol,selection:pm,order:nl,sort:rl,call:il,nodes:sl,node:al,size:ll,empty:cl,each:dl,attr:ul,style:pl,property:fl,classed:xl,text:El,html:bl,raise:_l,lower:Nl,append:Tl,insert:vl,remove:wl,clone:Il,datum:Al,on:Cl,dispatch:Ml,[Symbol.iterator]:Pl};var io=Ll;function ei(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function ws(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function or(){}var er=.7,ni=1/er,bn="\\s*([+-]?\\d+)\\s*",tr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Wt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",fm=/^#([0-9a-f]{3,8})$/,mm=new RegExp(`^rgb\\(${bn},${bn},${bn}\\)$`),gm=new RegExp(`^rgb\\(${Wt},${Wt},${Wt}\\)$`),hm=new RegExp(`^rgba\\(${bn},${bn},${bn},${tr}\\)$`),ym=new RegExp(`^rgba\\(${Wt},${Wt},${Wt},${tr}\\)$`),xm=new RegExp(`^hsl\\(${tr},${Wt},${Wt}\\)$`),Em=new RegExp(`^hsla\\(${tr},${Wt},${Wt},${tr}\\)$`),kl={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};ei(or,_o,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Rl,formatHex:Rl,formatHex8:bm,formatHsl:_m,formatRgb:Dl,toString:Dl});function Rl(){return this.rgb().formatHex()}function bm(){return this.rgb().formatHex8()}function _m(){return zl(this).formatHsl()}function Dl(){return this.rgb().formatRgb()}function _o(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=fm.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?Ol(t):o===3?new rt(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?ti(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?ti(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=mm.exec(e))?new rt(t[1],t[2],t[3],1):(t=gm.exec(e))?new rt(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=hm.exec(e))?ti(t[1],t[2],t[3],t[4]):(t=ym.exec(e))?ti(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=xm.exec(e))?Gl(t[1],t[2]/100,t[3]/100,1):(t=Em.exec(e))?Gl(t[1],t[2]/100,t[3]/100,t[4]):kl.hasOwnProperty(e)?Ol(kl[e]):e==="transparent"?new rt(NaN,NaN,NaN,0):null}function Ol(e){return new rt(e>>16&255,e>>8&255,e&255,1)}function ti(e,t,o,n){return n<=0&&(e=t=o=NaN),new rt(e,t,o,n)}function Nm(e){return e instanceof or||(e=_o(e)),e?(e=e.rgb(),new rt(e.r,e.g,e.b,e.opacity)):new rt}function _n(e,t,o,n){return arguments.length===1?Nm(e):new rt(e,t,o,n==null?1:n)}function rt(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}ei(rt,_n,ws(or,{brighter(e){return e=e==null?ni:Math.pow(ni,e),new rt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?er:Math.pow(er,e),new rt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new rt(Xo(this.r),Xo(this.g),Xo(this.b),ri(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:Vl,formatHex:Vl,formatHex8:Tm,formatRgb:Hl,toString:Hl}));function Vl(){return`#${Fo(this.r)}${Fo(this.g)}${Fo(this.b)}`}function Tm(){return`#${Fo(this.r)}${Fo(this.g)}${Fo(this.b)}${Fo((isNaN(this.opacity)?1:this.opacity)*255)}`}function Hl(){let e=ri(this.opacity);return`${e===1?"rgb(":"rgba("}${Xo(this.r)}, ${Xo(this.g)}, ${Xo(this.b)}${e===1?")":`, ${e})`}`}function ri(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Xo(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Fo(e){return e=Xo(e),(e<16?"0":"")+e.toString(16)}function Gl(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new Rt(e,t,o,n)}function zl(e){if(e instanceof Rt)return new Rt(e.h,e.s,e.l,e.opacity);if(e instanceof or||(e=_o(e)),!e)return new Rt;if(e instanceof Rt)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 Rt(a,s,l,e.opacity)}function Yl(e,t,o,n){return arguments.length===1?zl(e):new Rt(e,t,o,n==null?1:n)}function Rt(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}ei(Rt,Yl,ws(or,{brighter(e){return e=e==null?ni:Math.pow(ni,e),new Rt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?er:Math.pow(er,e),new Rt(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 rt(Is(e>=240?e-240:e+120,r,n),Is(e,r,n),Is(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new Rt(Bl(this.h),oi(this.s),oi(this.l),ri(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=ri(this.opacity);return`${e===1?"hsl(":"hsla("}${Bl(this.h)}, ${oi(this.s)*100}%, ${oi(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Bl(e){return e=(e||0)%360,e<0?e+360:e}function oi(e){return Math.max(0,Math.min(1,e||0))}function Is(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 As(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 Wl(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 As((o-n/t)*t,a,r,i,s)}}function Fl(e){var t=e.length;return function(o){var n=Math.floor(((o%=1)<0?++o:o)*t),r=e[(n+t-1)%t],i=e[n%t],a=e[(n+1)%t],s=e[(n+2)%t];return As((o-n/t)*t,r,i,a,s)}}var Cs=e=>()=>e;function vm(e,t){return function(o){return e+o*t}}function wm(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 Xl(e){return(e=+e)==1?ii:function(t,o){return o-t?wm(t,o,e):Cs(isNaN(t)?o:t)}}function ii(e,t){var o=t-e;return o?vm(e,o):Cs(isNaN(e)?t:e)}var si=function e(t){var o=Xl(t);function n(r,i){var a=o((r=_n(r)).r,(i=_n(i)).r),s=o(r.g,i.g),l=o(r.b,i.b),c=ii(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 Ul(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=_n(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 Im=Ul(Wl),Am=Ul(Fl);function At(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var Ms=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ss=new RegExp(Ms.source,"g");function Cm(e){return function(){return e}}function Sm(e){return function(t){return e(t)+""}}function Ps(e,t){var o=Ms.lastIndex=Ss.lastIndex=0,n,r,i,a=-1,s=[],l=[];for(e=e+"",t=t+"";(n=Ms.exec(e))&&(r=Ss.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:At(n,r)})),o=Ss.lastIndex;return o<t.length&&(i=t.slice(o),s[a]?s[a]+=i:s[++a]=i),s.length<2?l[0]?Sm(l[0].x):Cm(t):(t=l.length,function(c){for(var d=0,p;d<t;++d)s[(p=l[d]).i]=p.x(c);return s.join("")})}var $l=180/Math.PI,ai={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ls(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)*$l,skewX:Math.atan(l)*$l,scaleX:a,scaleY:s}}var li;function Kl(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?ai:Ls(t.a,t.b,t.c,t.d,t.e,t.f)}function ql(e){return e==null?ai:(li||(li=document.createElementNS("http://www.w3.org/2000/svg","g")),li.setAttribute("transform",e),(e=li.transform.baseVal.consolidate())?(e=e.matrix,Ls(e.a,e.b,e.c,e.d,e.e,e.f)):ai)}function Zl(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,p,m,u,g){if(c!==p||d!==m){var E=u.push("translate(",null,t,null,o);g.push({i:E-4,x:At(c,p)},{i:E-2,x:At(d,m)})}else(p||m)&&u.push("translate("+p+t+m+o)}function a(c,d,p,m){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),m.push({i:p.push(r(p)+"rotate(",null,n)-2,x:At(c,d)})):d&&p.push(r(p)+"rotate("+d+n)}function s(c,d,p,m){c!==d?m.push({i:p.push(r(p)+"skewX(",null,n)-2,x:At(c,d)}):d&&p.push(r(p)+"skewX("+d+n)}function l(c,d,p,m,u,g){if(c!==p||d!==m){var E=u.push(r(u)+"scale(",null,",",null,")");g.push({i:E-4,x:At(c,p)},{i:E-2,x:At(d,m)})}else(p!==1||m!==1)&&u.push(r(u)+"scale("+p+","+m+")")}return function(c,d){var p=[],m=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,p,m),a(c.rotate,d.rotate,p,m),s(c.skewX,d.skewX,p,m),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,p,m),c=d=null,function(u){for(var g=-1,E=m.length,f;++g<E;)p[(f=m[g]).i]=f.x(u);return p.join("")}}}var ks=Zl(Kl,"px, ","px)","deg)"),Rs=Zl(ql,", ",")",")");var Nn=0,rr=0,nr=0,Ql=1e3,ci,ir,di=0,Uo=0,ui=0,sr=typeof performance=="object"&&performance.now?performance:Date,jl=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function lr(){return Uo||(jl(Mm),Uo=sr.now()+ui)}function Mm(){Uo=0}function ar(){this._call=this._time=this._next=null}ar.prototype=pi.prototype={constructor:ar,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?lr():+o)+(t==null?0:+t),!this._next&&ir!==this&&(ir?ir._next=this:ci=this,ir=this),this._call=e,this._time=o,Ds()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ds())}};function pi(e,t,o){var n=new ar;return n.restart(e,t,o),n}function ec(){lr(),++Nn;for(var e=ci,t;e;)(t=Uo-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Nn}function Jl(){Uo=(di=sr.now())+ui,Nn=rr=0;try{ec()}finally{Nn=0,Lm(),Uo=0}}function Pm(){var e=sr.now(),t=e-di;t>Ql&&(ui-=t,di=e)}function Lm(){for(var e,t=ci,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:ci=o);ir=e,Ds(n)}function Ds(e){if(!Nn){rr&&(rr=clearTimeout(rr));var t=e-Uo;t>24?(e<1/0&&(rr=setTimeout(Jl,e-sr.now()-ui)),nr&&(nr=clearInterval(nr))):(nr||(di=sr.now(),nr=setInterval(Pm,Ql)),Nn=1,jl(Jl))}}function fi(e,t,o){var n=new ar;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var km=_s("start","end","cancel","interrupt"),Rm=[],nc=0,tc=1,gi=2,mi=3,oc=4,hi=5,cr=6;function No(e,t,o,n,r,i){var a=e.__transition;if(!a)e.__transition={};else if(o in a)return;Dm(e,o,{name:t,index:n,group:r,on:km,tween:Rm,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:nc})}function dr(e,t){var o=Ue(e,t);if(o.state>nc)throw new Error("too late; already scheduled");return o}function Ke(e,t){var o=Ue(e,t);if(o.state>mi)throw new Error("too late; already running");return o}function Ue(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function Dm(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=pi(i,0,o.time);function i(c){o.state=tc,o.timer.restart(a,o.delay,o.time),o.delay<=c&&a(c-o.delay)}function a(c){var d,p,m,u;if(o.state!==tc)return l();for(d in n)if(u=n[d],u.name===o.name){if(u.state===mi)return fi(a);u.state===oc?(u.state=cr,u.timer.stop(),u.on.call("interrupt",e,e.__data__,u.index,u.group),delete n[d]):+d<t&&(u.state=cr,u.timer.stop(),u.on.call("cancel",e,e.__data__,u.index,u.group),delete n[d])}if(fi(function(){o.state===mi&&(o.state=oc,o.timer.restart(s,o.delay,o.time),s(c))}),o.state=gi,o.on.call("start",e,e.__data__,o.index,o.group),o.state===gi){for(o.state=mi,r=new Array(m=o.tween.length),d=0,p=-1;d<m;++d)(u=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++p]=u);r.length=p+1}}function s(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=hi,1),p=-1,m=r.length;++p<m;)r[p].call(e,d);o.state===hi&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=cr,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function Os(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>gi&&n.state<hi,n.state=cr,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[a]}i&&delete e.__transition}}function rc(e){return this.each(function(){Os(this,e)})}function Om(e,t){var o,n;return function(){var r=Ke(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 Vm(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=Ke(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 ic(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=Ue(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?Om:Vm)(o,e,t))}function Tn(e,t,o){var n=e._id;return e.each(function(){var r=Ke(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return Ue(r,n).value[t]}}function yi(e,t){var o;return(typeof t=="number"?At:t instanceof _o?si:(o=_o(t))?(t=o,si):Ps)(e,t)}function Hm(e){return function(){this.removeAttribute(e)}}function Gm(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Bm(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 zm(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 Ym(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 Wm(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 sc(e,t){var o=ro(e),n=o==="transform"?Rs:yi;return this.attrTween(e,typeof t=="function"?(o.local?Wm:Ym)(o,n,Tn(this,"attr."+e,t)):t==null?(o.local?Gm:Hm)(o):(o.local?zm:Bm)(o,n,t))}function Fm(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function Xm(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function Um(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Xm(e,i)),o}return r._value=t,r}function $m(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Fm(e,i)),o}return r._value=t,r}function ac(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=ro(e);return this.tween(o,(n.local?Um:$m)(n,t))}function Km(e,t){return function(){dr(this,e).delay=+t.apply(this,arguments)}}function qm(e,t){return t=+t,function(){dr(this,e).delay=t}}function lc(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Km:qm)(t,e)):Ue(this.node(),t).delay}function Zm(e,t){return function(){Ke(this,e).duration=+t.apply(this,arguments)}}function Jm(e,t){return t=+t,function(){Ke(this,e).duration=t}}function cc(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Zm:Jm)(t,e)):Ue(this.node(),t).duration}function Qm(e,t){if(typeof t!="function")throw new Error;return function(){Ke(this,e).ease=t}}function dc(e){var t=this._id;return arguments.length?this.each(Qm(t,e)):Ue(this.node(),t).ease}function jm(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;Ke(this,e).ease=o}}function uc(e){if(typeof e!="function")throw new Error;return this.each(jm(this._id,e))}function pc(e){typeof e!="function"&&(e=Qn(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 je(n,this._parents,this._name,this._id)}function fc(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,o=e._groups,n=t.length,r=o.length,i=Math.min(n,r),a=new Array(n),s=0;s<i;++s)for(var l=t[s],c=o[s],d=l.length,p=a[s]=new Array(d),m,u=0;u<d;++u)(m=l[u]||c[u])&&(p[u]=m);for(;s<n;++s)a[s]=t[s];return new je(a,this._parents,this._name,this._id)}function eg(e){return(e+"").trim().split(/^|\s+/).every(function(t){var o=t.indexOf(".");return o>=0&&(t=t.slice(0,o)),!t||t==="start"})}function tg(e,t,o){var n,r,i=eg(t)?dr:Ke;return function(){var a=i(this,e),s=a.on;s!==n&&(r=(n=s).copy()).on(t,o),a.on=r}}function mc(e,t){var o=this._id;return arguments.length<2?Ue(this.node(),o).on.on(e):this.each(tg(o,e,t))}function og(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function gc(){return this.on("end.remove",og(this._id))}function hc(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Wo(e));for(var n=this._groups,r=n.length,i=new Array(r),a=0;a<r;++a)for(var s=n[a],l=s.length,c=i[a]=new Array(l),d,p,m=0;m<l;++m)(d=s[m])&&(p=e.call(d,d.__data__,m,s))&&("__data__"in d&&(p.__data__=d.__data__),c[m]=p,No(c[m],t,o,m,c,Ue(d,o)));return new je(i,this._parents,t,o)}function yc(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Jn(e));for(var n=this._groups,r=n.length,i=[],a=[],s=0;s<r;++s)for(var l=n[s],c=l.length,d,p=0;p<c;++p)if(d=l[p]){for(var m=e.call(d,d.__data__,p,l),u,g=Ue(d,o),E=0,f=m.length;E<f;++E)(u=m[E])&&No(u,t,o,E,m,g);i.push(m),a.push(d)}return new je(i,a,t,o)}var ng=io.prototype.constructor;function xc(){return new ng(this._groups,this._parents)}function rg(e,t){var o,n,r;return function(){var i=bo(this,e),a=(this.style.removeProperty(e),bo(this,e));return i===a?null:i===o&&a===n?r:r=t(o=i,n=a)}}function Ec(e){return function(){this.style.removeProperty(e)}}function ig(e,t,o){var n,r=o+"",i;return function(){var a=bo(this,e);return a===r?null:a===n?i:i=t(n=a,o)}}function sg(e,t,o){var n,r,i;return function(){var a=bo(this,e),s=o(this),l=s+"";return s==null&&(l=s=(this.style.removeProperty(e),bo(this,e))),a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s))}}function ag(e,t){var o,n,r,i="style."+t,a="end."+i,s;return function(){var l=Ke(this,e),c=l.on,d=l.value[i]==null?s||(s=Ec(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(a,r=d),l.on=n}}function bc(e,t,o){var n=(e+="")=="transform"?ks:yi;return t==null?this.styleTween(e,rg(e,n)).on("end.style."+e,Ec(e)):typeof t=="function"?this.styleTween(e,sg(e,n,Tn(this,"style."+e,t))).each(ag(this._id,e)):this.styleTween(e,ig(e,n,t),o).on("end.style."+e,null)}function lg(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function cg(e,t,o){var n,r;function i(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&lg(e,a,o)),n}return i._value=t,i}function _c(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,cg(e,t,o==null?"":o))}function dg(e){return function(){this.textContent=e}}function ug(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function Nc(e){return this.tween("text",typeof e=="function"?ug(Tn(this,"text",e)):dg(e==null?"":e+""))}function pg(e){return function(t){this.textContent=e.call(this,t)}}function fg(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&pg(r)),t}return n._value=e,n}function Tc(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,fg(e))}function vc(){for(var e=this._name,t=this._id,o=xi(),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=Ue(l,t);No(l,e,o,c,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new je(n,this._parents,e,o)}function wc(){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=Ke(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 mg=0;function je(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function Ic(e){return io().transition(e)}function xi(){return++mg}var so=io.prototype;je.prototype=Ic.prototype={constructor:je,select:hc,selectAll:yc,selectChild:so.selectChild,selectChildren:so.selectChildren,filter:pc,merge:fc,selection:xc,transition:vc,call:so.call,nodes:so.nodes,node:so.node,size:so.size,empty:so.empty,each:so.each,on:mc,attr:sc,attrTween:ac,style:bc,styleTween:_c,text:Nc,textTween:Tc,remove:gc,tween:ic,delay:lc,duration:cc,ease:dc,easeVarying:uc,end:wc,[Symbol.iterator]:so[Symbol.iterator]};function Ei(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var gg={time:null,delay:0,duration:250,ease:Ei};function hg(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 Ac(e){var t,o;e instanceof je?(t=e._id,e=e._name):(t=xi(),(o=gg).time=lr(),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])&&No(l,e,t,c,a,o||hg(l,t));return new je(n,this._parents,e,t)}io.prototype.interrupt=rc;io.prototype.transition=Ac;function To(e,t,o){this.k=e,this.x=t,this.y=o}To.prototype={constructor:To,scale:function(e){return e===1?this:new To(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new To(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 bi=new To(1,0,0);_i.prototype=To.prototype;function _i(e){for(;!e.__zoom;)if(!(e=e.parentNode))return bi;return e.__zoom}var xg=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var Cc;(function(e){e.Strict="strict",e.Loose="loose"})(Cc||(Cc={}));var Sc;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Sc||(Sc={}));var Mc;(function(e){e.Partial="partial",e.Full="full"})(Mc||(Mc={}));var Pc;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Pc||(Pc={}));var Lc;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Lc||(Lc={}));var it;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(it||(it={}));var h_={[it.Left]:it.Right,[it.Right]:it.Left,[it.Top]:it.Bottom,[it.Bottom]:it.Top};var Eg=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var bg=(e,t=[0,0])=>{var s;let{width:o,height:n}=_g(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 Ni=(e,t=[0,0])=>{var r,i,a,s,l,c,d,p;let{x:o,y:n}=Eg(e)?e.internals.positionAbsolute:bg(e,t);return{x:o,y:n,x2:o+((s=(a=(i=(r=e.measured)==null?void 0:r.width)!=null?i:e.width)!=null?a:e.initialWidth)!=null?s:0),y2:n+((p=(d=(c=(l=e.measured)==null?void 0:l.height)!=null?c:e.height)!=null?d:e.initialHeight)!=null?p:0)}};function _g(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 y_={[it.Left]:{x:-1,y:0},[it.Right]:{x:1,y:0},[it.Top]:{x:0,y:-1},[it.Bottom]:{x:0,y:1}};var Ng={nodeOrigin:[0,0],nodeExtent:xg,elevateNodesOnSelect:!0,defaults:{}},x_=w(b({},Ng),{checkEquality:!0});var kc;(function(e){e.Line="line",e.Handle="handle"})(kc||(kc={}));var Tg={width:0,height:0,x:0,y:0},E_=w(b({},Tg),{pointerX:0,pointerY:0,aspectRatio:1});var vg=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function wg(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 Ig(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 Ti=class{constructor(){this.xLines=[];this.yLines=[]}initialize(t){this.xLines=t.filter(o=>o.orientation==="vertical"),this.yLines=t.filter(o=>o.orientation==="horizontal"),this.xLines.sort((o,n)=>o.position-n.position),this.yLines.sort((o,n)=>o.position-n.position),this.lastHorizontalLine=void 0,this.lastVerticalLine=void 0}search(t,o,n,r,i){let a=t==="horizontal"?this.yLines:this.xLines,[s,l]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],c=[];for(let u of a){if(u.position<s)continue;if(u.position>l)break;if(i.has(u.node.id)||u.node.parentId&&i.has(u.node.parentId)||!vg(u.nodeBox,r))continue;let g=Math.abs(u.position-o);if(g>vi)continue;let f=wg(u.nodeBox,n)>0?0:Ig(u.nodeBox,n);c.push({line:u,lineDist:g,nodeDist:f})}let d=.5,p=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;c.sort((u,g)=>{if(p){if(u.line===p&&g.line!==p)return-1;if(g.line===p&&u.line!==p)return 1}return Math.abs(u.lineDist-g.lineDist)<=d?u.nodeDist-g.nodeDist:u.lineDist-g.lineDist});let m=c.length>0?c[0].line:void 0;return m&&(t==="horizontal"?this.lastHorizontalLine=m:this.lastVerticalLine=m),m}};function Rc(e,t=$o,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=Ni(i);Object.entries(t).forEach(([s,l])=>{var c;n.push({position:l.resolve(r,a),color:(c=r.style)==null?void 0:c.backgroundColor,orientation:l.orientation,anchorName:s,nodeBox:a,node:r})})}),n}function Dc(e,t,o,n,r=Object.keys($o)){let i=[];for(let s of r){let l=$o[s],c=l.resolve(null,o),d=e.search(l.orientation,c,o,t,n);d&&i.push({sourcePosition:c,anchorName:s,anchor:l,line:d})}let a={horizontal:void 0,vertical:void 0};for(let s of i){let l=a[s.anchor.orientation],c=Math.abs(s.sourcePosition-s.line.position);(!l||c<Math.abs(l.sourcePosition-l.line.position))&&(a[s.anchor.orientation]=s)}return a}function Oc(e,t,o){let n=0,r=0,i=!1,a=!1;if(t){let l=t.anchor.resolve(null,e)-t.line.position;Math.abs(l)<=vi&&(r=l,a=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=vi&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:a}}var vi=10,$o={top:{orientation:"horizontal",resolve:(e,t)=>t.y},bottom:{orientation:"horizontal",resolve:(e,t)=>t.y2},left:{orientation:"vertical",resolve:(e,t)=>t.x},right:{orientation:"vertical",resolve:(e,t)=>t.x2},centerX:{orientation:"vertical",resolve:(e,t)=>(t.x+t.x2)/2},centerY:{orientation:"horizontal",resolve:(e,t)=>(t.y+t.y2)/2}};var Hc=require("react/jsx-runtime"),Ag=new Ti;function wi(){let[e,t]=(0,ft.useState)(void 0),[o,n]=(0,ft.useState)(void 0),{width:r,height:i}=(0,vn.useStore)(f=>({width:f.width,height:f.height}),Vc.shallow),a=(0,vn.useNodesInitialized)(),s=(0,ft.useRef)(Ag),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=(0,vn.useReactFlow)(),p=(0,ft.useCallback)(()=>{t(void 0),n(void 0)},[]),m=(0,ft.useCallback)(f=>{let h=f!=null?f:d();p();let y=Rc(h,$o,c);s.current.initialize(y)},[c,p,d]),u=(0,ft.useCallback)(()=>{setTimeout(()=>{m()},100)},[m]);(0,ft.useEffect)(()=>{a&&m(d())},[a,m,d]);let g=(0,ft.useCallback)((f,h)=>{var G,z,L,V,j,Z,J,q,ee,ae;if(!s.current||f.length===0||f.filter(F=>F.type==="dimensions").length>1)return f;p();let x=f.filter(F=>F.type==="position"&&!!F.position),v=f.find(F=>F.type==="dimensions");if(x.length===0&&!v)return f;let N=Object.keys($o),T=new Set,_=1/0,I=1/0,S=-1/0,P=-1/0;if(x.length>0)x.forEach(F=>{var re,fe,ue,Ne,Fe,Qe;let ne=h.find(ot=>ot.id===F.id);if(!ne)return;T.add(ne.id);let le=c(ne.id);if(!le)return;let K=le.parentId?c(le.parentId):void 0,Te=F.position.x+((re=K==null?void 0:K.internals.positionAbsolute.x)!=null?re:0),W=F.position.y+((fe=K==null?void 0:K.internals.positionAbsolute.y)!=null?fe:0),te=(Ne=(ue=ne.measured)==null?void 0:ue.width)!=null?Ne:0,ce=(Qe=(Fe=ne.measured)==null?void 0:Fe.height)!=null?Qe:0;_=Math.min(_,Te),I=Math.min(I,W),S=Math.max(S,Te+te),P=Math.max(P,W+ce)}),v&&(N=["top","left"]);else if(v){let F=h.find(te=>te.id===v.id);if(!F)return f;T.add(F.id);let ne=c(F.id);if(!ne)return f;let le=ne.internals.positionAbsolute.x,K=ne.internals.positionAbsolute.y,Te=(V=(L=(G=v.dimensions)==null?void 0:G.width)!=null?L:(z=F.measured)==null?void 0:z.width)!=null?V:0,W=(q=(J=(j=v.dimensions)==null?void 0:j.height)!=null?J:(Z=F.measured)==null?void 0:Z.height)!=null?q:0;_=le,I=K,S=le+Te,P=K+W,N=["right","bottom"]}if(_===1/0)return f;let R={x:_,y:I,x2:S,y2:P},{x:M,y:B}=l({x:0,y:0}),{x:X,y:U}=l({x:r,y:i}),Q={x:M,y:B,x2:X,y2:U},{horizontal:Y,vertical:C}=Dc(s.current,Q,R,T,N),{deltaX:O,deltaY:D,snappedX:A,snappedY:k}=Oc(R,Y,C);if(A||k){let F=x.some(le=>le.dragging),ne=!!(v!=null&&v.resizing);(F||ne)&&(A&&n(C==null?void 0:C.line),k&&t(Y==null?void 0:Y.line)),A&&(x.forEach(le=>{le.position&&(le.position.x-=O)}),(v==null?void 0:v.id)===((ee=x[0])==null?void 0:ee.id)?v.dimensions&&(v.dimensions.width+=O):v&&!x.length&&v.dimensions&&(v.dimensions.width-=O)),k&&(x.forEach(le=>{le.position&&(le.position.y-=D)}),(v==null?void 0:v.id)===((ae=x[0])==null?void 0:ae.id)?v.dimensions&&(v.dimensions.height+=D):v&&!x.length&&v.dimensions&&(v.dimensions.height-=D))}return f},[l,c,r,i,t,n,p]),E=(0,ft.useCallback)(()=>(0,Hc.jsx)(Gc,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:m,forceRebuildIndex:u,updateHelperLines:g,helperLineHorizontal:e,helperLineVertical:o,HelperLines:E}}var ts=require("@xyflow/react"),Jt=require("react");var ao=e=>new Map(e.map(t=>[t.id,t])),ur=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),Bc=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),Vs=e=>e.some(t=>t.type==="START_EVENT"),vo=(e,t)=>e==="START_EVENT"?!Vs(t):!0,zc=(e,t,o,n,r)=>{let i=ao(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:ur(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Yc=(e,t,o,n,r)=>{let i=ao(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:Bc(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Ii=(e,t,o,n,r)=>{var c;let i=ao(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:ur(e,n,r).filter(d=>{let p=i.get(d.target);return(p==null?void 0:p.type)!=="ANNOTATION"}).length>=2},Wc=(e,t,o)=>{var a,s,l,c;let n=ao(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"},Ai=(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"},Fc=(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"},Ci=(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"},Ko=(e,t,o,n)=>{let r=ao(t),i=r.get(e);return!i||i.type!=="TASK"?!1:Bc(e,o,n).some(s=>{let l=r.get(s.source);return(l==null?void 0:l.type)==="START_EVENT"})},pr=(e,t,o,n)=>{let r=ao(t),i=r.get(e);return!i||i.type!=="TASK"?!1:ur(e,o,n).some(s=>{let l=r.get(s.target);return(l==null?void 0:l.type)==="END_EVENT"})},Xc=(e,t,o,n,r)=>{let i=ao(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"?pr(t,o,n,r):(s==null?void 0:s.type)==="END_EVENT"&&(a==null?void 0:a.type)==="TASK"?Ko(e,o,n,r):!1},Si=(e,t,o)=>ur(e,t,o).length>0,Mi=(e,t,o,n,r)=>{let i=ao(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:ur(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var Uc=(e,t,o,n,r)=>{var s,l;let i=ao(n),a=((s=i.get(e))==null?void 0:s.type)==="ANNOTATION"||((l=i.get(t))==null?void 0:l.type)==="ANNOTATION";return o.some(c=>r&&c.id===r?!1:!!(c.source===e&&c.target===t||a&&c.source===t&&c.target===e))};var Cg=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!Uc(e.sourceNodeId,e.targetNodeId,e.edges,e.nodes,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!zc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!Yc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!Ii(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!Mi(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:Wc(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"&&Fc(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:!(Ai(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(Ci(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(Ko(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!Xc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(pr(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(Si(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"})],Hs=e=>{for(let t of Cg){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var Sg=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:Ii(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:Vs(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Ai(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Ci(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Ko(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:pr(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Si(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Mi(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],$c=e=>{let t=Sg.filter(o=>{let n=!o.sourceTypes||o.sourceTypes.includes(e.sourceNodeType),r=!o.targetTypes||o.targetTypes.includes(e.targetNodeType);return n&&r});for(let o of t){let n=o.validate(e);if(n.shouldDisable)return n}return{shouldDisable:!1}};var Dt=require("@xyflow/react");var Ft=require("@produto-lecom/lecom-ui"),qc=require("lucide-react");var Ct=require("@xyflow/react");var Kc=require("@xyflow/react"),wo=()=>{let e=(0,Kc.useStoreApi)();return{selectElements:n=>{let{edges:r,nodes:i,triggerEdgeChanges:a,triggerNodeChanges:s}=e.getState(),l=i.reduce((d,p)=>[...d,{id:p.id,type:"select",selected:n.includes(p.id)}],[]),c=r.reduce((d,p)=>[...d,{id:p.id,type:"select",selected:n.includes(p.id)}],[]);return s(l),a(c),!0},clearSelection:async()=>{let{unselectNodesAndEdges:n}=e.getState();return n(),await Gr(),!0}}};var Pi=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=(0,Ct.useReactFlow)(),{selectElements:r}=wo(),i=f=>{let h=o(),y=n(),x=(0,Ct.getIncomers)(f,h,y),v=(0,Ct.getOutgoers)(f,h,y),N=x.some(_=>_.type==="START_EVENT"),T=v.some(_=>_.type==="END_EVENT");return N?"start":T?"end":"between"},a=(f,h,y)=>{var N,T,_,I;if(!f)return;let x={type:f.type,variant:(N=f.data)==null?void 0:N.variant,attribute:(T=f.data)==null?void 0:T.attribute},v={id:f.id,position:i(f),label:(_=f.data)==null?void 0:_.label,node:x};return f.type==="TASK"&&((I=f.data)==null?void 0:I.variant)==="SUBPROCESS"?w(b({},v),{type:"sub_process"}):f.type==="GATEWAY"?w(b({},v),{type:"gateway",variant:s(f,h,y)}):w(b({},v),{type:"activity"})},s=(f,h,y)=>{if(f.type!=="GATEWAY")return;let x=(0,Ct.getIncomers)(f,h,y),v=!1,N=!1;if(x.forEach(T=>{var _,I;T.type==="TASK"&&(((_=T.data)==null?void 0:_.variant)==="SCRIPT"&&(v=!0),((I=T.data)==null?void 0:I.attribute)==="LOOP"&&(N=!0))}),v&&N)return"script_loop";if(v)return"script";if(N)return"loop"},l=(f,h,y)=>{var _,I,S,P;let x=e(f.source),v=e(f.target);if(!x||!v)return"simple";if((0,Ct.getOutgoers)(x,h,y).some(R=>R.type==="END_EVENT"))return"final";if(x.type==="GATEWAY")switch((_=x.data)==null?void 0:_.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(x.type==="TASK"){let R=(I=x.data)==null?void 0:I.variant,M=(S=x.data)==null?void 0:S.attribute;if(R==="SUBPROCESS")return"from_sub_process";if(v.type==="TASK"&&((P=v.data)==null?void 0:P.variant)==="SUBPROCESS")return"to_sub_process";let B=R==="SCRIPT",X=M==="LOOP";return B&&X?"script_loop":B?"script":X?"loop":"simple"}return"simple"},c=(f,h,y)=>{let x=[];function v(T,_,I=0){let S=a(T,h,y);if(S.depth=I,_.push(S),T.type==="TASK"){x.push([..._]),_.pop();return}let P=(0,Ct.getIncomers)(T,h,y);if(P.length)for(let R of P)v(R,_,I+1);_.pop()}let N=(0,Ct.getIncomers)(f,h,y);for(let T of N)v(T,[]);return x},d=(f,h,y)=>{let x=[];function v(T,_,I=0){let S=a(T,h,y);if(S.depth=I,_.push(S),T.type==="TASK"){x.push([..._]),_.pop();return}let P=(0,Ct.getOutgoers)(T,h,y);if(P.length)for(let R of P)v(R,_,I+1);_.pop()}let N=(0,Ct.getOutgoers)(f,h,y);for(let T of N)v(T,[]);return x},p=(f,h,y)=>(y=y.filter(v=>v.source===f.id),y.map(v=>{var _;let N=e(v.target),T;return N&&(T=a(N,h,y)),{id:v.id,type:"routing",variant:l(v,h,y),label:(_=v.data)==null?void 0:_.label,target:T}})),m=f=>{let h=e(f);if(!h)return;let y=o(),x=n(),v=a(h,y,x);return v.sources=c(h,y,x),v.targets=d(h,y,x),v.edgeTargets=p(h,y,x),h.type==="GATEWAY"&&(v.variant=s(h,y,x)),v},u=f=>{let h=t(f);if(!h)return;let y=o(),x=n(),v=l(h,y,x),T={id:h.id,type:"routing",variant:v,gatewayVariant:void 0},_=e(h.source);if(_){let S=a(_,y,x);T.source=S;let P=s(_,y,x);if(T.gatewayVariant=P,_.type==="TASK")T.sources=[[S]];else{let R=c(_,y,x);T.sources=R.length?R:[[S]]}}let I=e(h.target);if(I){let S=a(I,y,x);if(T.target=S,I.type==="TASK")T.targets=[[S]];else{let P=d(I,y,x);T.targets=P.length?P:[[S]]}}return T},g=f=>{let h=e(f);if(h)return m(h.id);let y=t(f);if(y)return u(y.id)};return{configureElement:f=>{let h=g(f);if(h)return r([f]),h},getConfigureElement:g,getNodeConfigure:m,getEdgeConfigure:u}};var qo=require("react/jsx-runtime"),Mg={node:"editor.toolbar.configure_node",edge:"editor.toolbar.configure_edge",gateway:"editor.toolbar.configure_gateway"},Io=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,Ft.useTranslation)(),{onConfigureElement:n}=$(),{getConfigureElement:r}=Pi();return(0,qo.jsxs)(Ft.Tooltip,{children:[(0,qo.jsx)(Ft.TooltipTrigger,{asChild:!0,children:(0,qo.jsx)(Ft.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let a=r(e);a&&(n==null||n(a))},children:(0,qo.jsx)(qc.Settings,{size:16})})}),(0,qo.jsx)(Ft.TooltipContent,{color:"black",children:o(Mg[t])})]})};var Xt=require("@produto-lecom/lecom-ui"),Jc=require("@xyflow/react"),Qc=require("lucide-react");var Zc=require("@produto-lecom/lecom-ui");function st(){let{toast:e}=wn(),{toast:t}=(0,Zc.useNotificationToast)();return{toast:e||t}}var Zo=require("react/jsx-runtime"),Li=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,Xt.useTranslation)(),{toast:n}=st(),{deleteElements:r,getNodes:i}=(0,Jc.useReactFlow)();return(0,Zo.jsxs)(Xt.Tooltip,{children:[(0,Zo.jsx)(Xt.TooltipTrigger,{asChild:!0,children:(0,Zo.jsx)(Xt.Button,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{if(t==="node"){let s=i(),l=s.find(c=>c.id===e);if((l==null?void 0:l.type)==="LANE"&&s.some(d=>d.parentId===e)){n({variant:"error",title:o("validation.errors.title"),content:o("editor.toolbar.delete_pool_lane_error")});return}r({nodes:[{id:e}]})}else r({edges:[{id:e}]})},children:(0,Zo.jsx)(Qc.TrashIcon,{size:16})})}),(0,Zo.jsx)(Xt.TooltipContent,{color:"black",children:o("editor.toolbar.delete")})]})};var Ut=require("@produto-lecom/lecom-ui"),jc=require("lucide-react"),ed=require("react"),Jo=require("react/jsx-runtime"),In=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=(0,Ut.useTranslation)(),r=(0,ed.useCallback)(i=>{i.stopPropagation();let a=document.querySelectorAll(`.react-flow__handle.source[data-nodeid="${e}"]`);if(a.length===0)return;let s=Array.from(a).reduce((m,u)=>{let g=m.getBoundingClientRect(),E=u.getBoundingClientRect(),f=Math.hypot(i.clientX-(g.left+g.width/2),i.clientY-(g.top+g.height/2));return Math.hypot(i.clientX-(E.left+E.width/2),i.clientY-(E.top+E.height/2))<f?u:m}),l=s.getBoundingClientRect(),c=l.left+l.width/2,d=l.top+l.height/2,p=new MouseEvent("mousedown",{clientX:c,clientY:d,bubbles:!0,cancelable:!0});s.dispatchEvent(p)},[e]);return(0,Jo.jsxs)(Ut.Tooltip,{children:[(0,Jo.jsx)(Ut.TooltipTrigger,{asChild:!0,children:(0,Jo.jsx)(Ut.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:(0,Jo.jsx)(jc.MoveUpRightIcon,{size:16})})}),(0,Jo.jsx)(Ut.TooltipContent,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};var An=require("react/jsx-runtime"),Cn=i=>{var a=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=a,r=Yt(a,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:s}=$(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d,isToEndEvent:p}=Fr(o,n),m=!l&&!c&&!d&&!p,u=[{component:(0,An.jsx)(Li,{elementId:e,elementType:"edge"})}],g=()=>s==="view"?m?[{component:(0,An.jsx)(Io,{elementId:e,elementType:"edge"})}]:[]:m?[{component:(0,An.jsx)(Io,{elementId:e,elementType:"edge"})},...u]:u,f=(h=>{switch(h){case"SEQUENCE_EDGE":return g();case"MESSAGE_EDGE":return s==="view"?[]:[...u];case"ANNOTATION_EDGE":return s==="view"?[]:[...u];default:return[]}})(t);if(!(f.length===0||s==="readonly"))return(0,An.jsx)("div",w(b({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:f.map((h,y)=>(0,An.jsx)("div",{children:h.component},y))}))};var td=require("@xyflow/react"),od=require("react");var Gs=require("react/jsx-runtime"),$t=12,Sn=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:a}=(0,td.useViewport)(),s=1/a,l=(0,od.useMemo)(()=>t===n?{bottom:`${$t}px`,transform:"translateX(-50%)"}:e===o?{left:`${$t}px`,transform:r?"translateY(-100%)":"translateY(-50%)"}:n>t&&o>e?{left:`${$t}px`,bottom:`${$t}px`}:n>t&&o<e?{right:`${$t}px`,bottom:`${$t}px`}:t>n&&o>e?{right:`${$t}px`,bottom:`${$t}px`}:{left:`${$t}px`,bottom:`${$t}px`},[e,t,o,n,r]);return(0,Gs.jsx)("div",{style:{transform:`scale(${s})`},children:(0,Gs.jsx)("div",{className:"absolute pointer-events-auto",style:b({},l),children:i})})};var mt=require("react/jsx-runtime"),Mn={type:"ANNOTATION_EDGE",reconnectable:!0},nd=({id:e,source:t,target:o,selected:n,data:r})=>{let{isMultipleSelection:i}=$(),{zoom:a}=(0,Dt.useViewport)(),s=(0,Dt.useInternalNode)(t),l=(0,Dt.useInternalNode)(o);if(!s||!l)return null;let{sx:c,sy:d,tx:p,ty:m}=yn(s,l),[u,g,E]=(0,Dt.getStraightPath)({sourceX:c,sourceY:d,targetX:p,targetY:m}),f=n||(s==null?void 0:s.selected)||(l==null?void 0:l.selected);return(0,mt.jsx)(mt.Fragment,{children:(0,mt.jsxs)("g",{className:H("group bpmn-edge",{"is-highlighted":f}),children:[(0,mt.jsx)("path",{d:u,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/a),style:{pointerEvents:"stroke",cursor:"pointer"}}),(0,mt.jsxs)("g",{className:H("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":f}),children:[(0,mt.jsx)(Dt.BaseEdge,{id:e,path:u,interactionWidth:0,strokeDasharray:4,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":r==null?void 0:r.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":f&&!(r!=null&&r.hasError)})}),(0,mt.jsx)(Dt.EdgeLabelRenderer,{children:(0,mt.jsx)("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${g}px, ${E}px)`},children:n&&!i&&(0,mt.jsx)(Sn,{sx:c,sy:d,tx:p,ty:m,children:(0,mt.jsx)(Cn,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})})})]})]})})};var Je=require("react"),Se=require("@xyflow/react");var Ot=require("react");var zs=require("react/jsx-runtime"),Bs=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,rd=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Escape","Shift"],Ze=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:a,onBlur:s,onInput:l,onInvalidFirstCharacter:c,skipFirstCharValidation:d})=>{let p=(0,Ot.useRef)(null),m=(0,Ot.useRef)(null),[u,g]=(0,Ot.useState)(!1);(0,Ot.useEffect)(()=>()=>{m.current&&clearTimeout(m.current)},[]),(0,Ot.useEffect)(()=>{g(i!=null?i:!1)},[i]),(0,Ot.useEffect)(()=>{if(u&&p.current){p.current.focus();let N=document.createRange();N.selectNodeContents(p.current);let T=window.getSelection();T&&(T.removeAllRanges(),T.addRange(N))}},[u]);let E=(0,Ot.useCallback)(()=>{m.current||(c==null||c(),m.current=setTimeout(()=>{m.current=null},500))},[c]),f=N=>{N.stopPropagation(),u||g(!0)},h=N=>{let T=N.currentTarget.innerText.replace(/\n$/,""),_=t&&T.length>=t,I=window.getSelection(),S=(I==null?void 0:I.toString())||"",P=S.length>0,R=(N.ctrlKey||N.metaKey)&&!N.altKey,M=R&&N.key==="a",B=R&&N.key==="c",X=R&&N.key==="x",U=R&&N.key==="v",Q=T.length===0||P&&S.length===T.length;if(!d&&Q&&!Bs.test(N.key)&&!rd.includes(N.key)&&!R){N.preventDefault(),E();return}_&&!P&&(rd.includes(N.key)||M||B||X||U||N.preventDefault())},y=N=>{N.preventDefault();let T=N.clipboardData.getData("text/plain").replace(/\r\n/g,`
|
|
2
2
|
`).replace(/\r/g,`
|
|
3
|
-
`),
|
|
3
|
+
`),_=N.currentTarget.innerText.replace(/\n$/,""),I=window.getSelection();if(!I||I.rangeCount===0)return;let S=I.toString(),P=_.length-S.length,R=t?Math.max(0,t-P):1/0;if(R<=0&&S.length===0)return;let M=T;if(M.length>R&&(M=M.substring(0,R)),!M&&S.length===0)return;let B=I.getRangeAt(0),X=B.startOffset===0&&(B.startContainer===N.currentTarget||B.startContainer.parentNode===N.currentTarget);if(!d&&X&&M.length>0&&!Bs.test(M[0])){E();return}B.deleteContents();let U=document.createTextNode(M);B.insertNode(U),B.setStartAfter(U),B.collapse(!0),I.removeAllRanges(),I.addRange(B),l==null||l(N.currentTarget.innerText.replace(/\n$/,""))},x=N=>{let T=N.currentTarget,_=T.innerText.replace(/\n$/,"");if(!d&&_.length>0&&!Bs.test(_[0])){let I=_.slice(1);if(T.innerText=I,I.length>0&&T.firstChild){let S=document.createRange(),P=window.getSelection();S.setStart(T.firstChild,0),S.collapse(!0),P==null||P.removeAllRanges(),P==null||P.addRange(S)}E(),l==null||l(I);return}l==null||l(_)},v=N=>{g(!1);let T=N.currentTarget.innerText.replace(/\r\n/g,`
|
|
4
4
|
`).replace(/\r/g,`
|
|
5
|
-
`).trim();t&&y.length>t&&(y=y.substring(0,t)),E.currentTarget.innerText=y,s==null||s(),y!==e&&(a==null||a(y))};return(0,Gs.jsx)("div",{className:H("flex-1 p-2 self-stretch flex items-center justify-center border border-transparent overflow-hidden text-ellipsis body-medium-400 text-center rounded-sm",{"border border-dashed border-grey-400 bg-white shadow-md":p,"bg-white":e.length>0},n),style:o,onDoubleClick:f,children:(0,Gs.jsx)("div",{ref:u,className:H("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":p}),contentEditable:p,suppressContentEditableWarning:!0,onKeyDown:h,onPaste:_,onInput:b,onBlur:T,children:e})})};var Cg=require("@xyflow/react");var xe=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,Sn=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),Li=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),Sg=(e,t,o)=>{let n=o.x-t.x,r=o.y-t.y,i=n*n+r*r;if(i===0)return Sn(e,t);let a=Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*r)/i));return Sn(e,{x:t.x+a*n,y:t.y+a*r})},rd=(e,t)=>{let o=1/0;for(let n=0;n<t.length-1;n++)o=Math.min(o,Sg(e,t[n],t[n+1]));return o};var ur=require("@xyflow/react");var vo={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15,MAX_LABEL_DISTANCE:80};var{TOLERANCE:de}=vo;function Mg(e,t,o){return xe(e,t,"x",de)&&xe(t,o,"x",de)&&xe(e,o,"x",de)}function Pg(e,t,o){return xe(e,t,"y",de)&&xe(t,o,"y",de)&&xe(e,o,"y",de)}function Lg(e,t,o){if(!Mg(e,t,o))return!1;let n=t.y-e.y,r=o.y-t.y;return Math.abs(n)<de||Math.abs(r)<de?!1:n*r<0}function kg(e,t,o){if(!Pg(e,t,o))return!1;let n=t.x-e.x,r=o.x-t.x;return Math.abs(n)<de||Math.abs(r)<de?!1:n*r<0}function Rg(e,t,o,n){let r=t.x!==0,i=t.x===-n.x&&t.y===-n.y,a=t.x===n.x&&t.y===n.y,s=120;if(i)if(r){if((o.x-e.x)*t.x>=0)return[{x:(e.x+o.x)/2,y:e.y},{x:(e.x+o.x)/2,y:o.y}];{let l=(e.y+o.y)/2,c=Math.abs(e.y-o.y)<s?Math.max(e.y,o.y)+s:l;return[{x:e.x,y:c},{x:o.x,y:c}]}}else{if((o.y-e.y)*t.y>=0)return[{x:e.x,y:(e.y+o.y)/2},{x:o.x,y:(e.y+o.y)/2}];{let l=(e.x+o.x)/2,c=Math.abs(e.x-o.x)<s?Math.max(e.x,o.x)+s:l;return[{x:c,y:e.y},{x:c,y:o.y}]}}else if(a)if(r)if((o.x-e.x)*t.x>0&&Math.abs(e.y-o.y)<s){let l=Math.max(e.y,o.y)+s,c=o.x+t.x*(s/2);return[{x:e.x,y:l},{x:c,y:l},{x:c,y:o.y}]}else{let l=t.x>0?Math.max(e.x,o.x):Math.min(e.x,o.x);return[{x:l,y:e.y},{x:l,y:o.y}]}else if((o.y-e.y)*t.y>0&&Math.abs(e.x-o.x)<s){let l=Math.max(e.x,o.x)+s,c=o.y+t.y*(s/2);return[{x:l,y:e.y},{x:l,y:c},{x:o.x,y:c}]}else{let l=t.y>0?Math.max(e.y,o.y):Math.min(e.y,o.y);return[{x:e.x,y:l},{x:o.x,y:l}]}else{let l=t.x!==0?o.x:e.x,c=t.y!==0?o.y:e.y,d=t.x!==0?(l-e.x)*t.x:(c-e.y)*t.y,u=n.x!==0?(l-o.x)*n.x:(c-o.y)*n.y;return d>=0&&u>=0?[{x:l,y:c}]:r?[{x:e.x,y:o.y}]:[{x:o.x,y:e.y}]}}function id(e){if(e.length<=2)return e;let t=[e[0]];for(let o=1;o<e.length-1;o++){let n=t[t.length-1],r=e[o],i=e[o+1];xe(n,r,"x",de)&&xe(r,i,"x",de)||xe(n,r,"y",de)&&xe(r,i,"y",de)||t.push(r)}return t.push(e[e.length-1]),t}function ki(e){let t=[];for(let o of e){let n=t[t.length-1];(!n||Math.abs(n.x-o.x)>=de||Math.abs(n.y-o.y)>=de)&&t.push(o)}return t}function Dg(e){let t=[...e],o=!0;for(;o;){o=!1;for(let n=1;n<t.length-1;n++){let r=t[n-1],i=t[n],a=t[n+1];if(Lg(r,i,a)||kg(r,i,a)){t.splice(n,1),o=!0;break}}}return t}function sd(e){let t=ki(id([...e]));return t=Dg(t),ki(id(t))}function Ri(e){switch(e){case ur.Position.Left:return{x:-1,y:0};case ur.Position.Right:return{x:1,y:0};case ur.Position.Top:return{x:0,y:-1};case ur.Position.Bottom:return{x:0,y:1};default:return{x:0,y:0}}}function ad(e,t,o,n){let r=vo.OFFSET,i=vo.OFFSET;if(t.x===-n.x&&t.y===-n.y)if(t.x!==0){let a=(o.x-e.x)*t.x;a>0&&a<2*vo.OFFSET&&(r=a/2,i=a/2)}else{let a=(o.y-e.y)*t.y;a>0&&a<2*vo.OFFSET&&(r=a/2,i=a/2)}return{sourceOffset:r,targetOffset:i}}function Og(e,t,o,n,r,i,a=0){let s=Ri(r),l=Ri(i),c=s.x===0?a:0,d=s.y===0?a:0,u=l.x===0?a:0,m=l.y===0?a:0,p={x:e+c,y:t+d},g={x:o+u,y:n+m},{sourceOffset:x,targetOffset:f}=ad(p,s,g,l),h={x:p.x+s.x*x,y:p.y+s.y*x},_={x:g.x+l.x*f,y:g.y+l.y*f},b=Rg(h,s,_,l),T=[p,h,...b,_,g],E=sd(T);if(E.length===2&&Di(p,g)>de){let y=xe(p,h,"x",de)&&xe(h,_,"x",de)&&xe(_,g,"x",de),w=xe(p,h,"y",de)&&xe(h,_,"y",de)&&xe(_,g,"y",de);if(y||w){let C=w&&(_.x-h.x)*s.x<0,A=y&&(_.y-h.y)*s.y<0;if(!C&&!A)return ki([p,h,_,g])}}return E}function Oi(e,t,o,n,r,i,a,s=0){if(!(a!=null&&a.length))return Og(e,t,o,n,r,i,s);let l=Ri(r),c=Ri(i),d=l.x===0?s:0,u=l.y===0?s:0,m=c.x===0?s:0,p=c.y===0?s:0,g={x:e+d,y:t+u},x={x:o+m,y:n+p},{sourceOffset:f,targetOffset:h}=ad(g,l,x,c),_={x:g.x+l.x*f,y:g.y+l.y*f},b={x:x.x+c.x*h,y:x.y+c.y*h},T=[...a],E=T[0],y=l.y===0;y&&Math.abs(g.y-E.y)>de?T.unshift({x:E.x,y:g.y}):!y&&Math.abs(g.x-E.x)>de&&T.unshift({x:g.x,y:E.y});let w=T[T.length-1],C=c.y===0,A=[];(Math.abs(w.x-b.x)>de||Math.abs(w.y-b.y)>de)&&(C?A.push({x:b.x,y:w.y}):A.push({x:w.x,y:b.y})),A.push(b);let R=[g,...T,...A,x],G=sd(R);if(G.length===2&&Di(g,x)>de){let M=xe(g,_,"x",de)&&xe(_,b,"x",de)&&xe(b,x,"x",de),P=xe(g,_,"y",de)&&xe(_,b,"y",de)&&xe(b,x,"y",de);if(M||P){let X=P&&(b.x-_.x)*l.x<0,$=M&&(b.y-_.y)*l.y<0;if(!X&&!$)return ki([g,_,b,x])}}return G}var Di=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Vg(e,t,o){return xe(e,t,"x",de)&&xe(t,o,"x",de)||xe(e,t,"y",de)&&xe(t,o,"y",de)}function Hg(e,t,o,n){if(Vg(e,t,o))return`L${t.x} ${t.y}`;let r=Di(e,t),i=Di(t,o),a=Math.min(r/2,i/2,n);if(a<1)return`L${t.x} ${t.y}`;let s=e.x-t.x,l=e.y-t.y,c=o.x-t.x,d=o.y-t.y,u={x:s/r,y:l/r},m={x:c/i,y:d/i},p={x:t.x+u.x*a,y:t.y+u.y*a},g={x:t.x+m.x*a,y:t.y+m.y*a},x=-u.x,f=-u.y,h=m.x,_=m.y,T=x*_-f*h>0?1:0;return`L${p.x} ${p.y}A${a} ${a} 0 0 ${T} ${g.x} ${g.y}`}var ld=(e,t=5)=>e.length<2?"":e.reduce((o,n,r)=>{let i="";return r>0&&r<e.length-1?i=Hg(e[r-1],n,e[r+1],t):i=`${r===0?"M":"L"}${n.x} ${n.y}`,o+=i,o},"");var Ce=require("react"),Vi=require("@xyflow/react");var Gg=50,cd=.1,Bg=.6,Hi=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:a,getNodes:s,getEdge:l,screenToFlowPosition:c}=(0,Vi.useReactFlow)(),{setIsDragging:d,setReconnectingEdgeId:u}=q(),m=(0,Vi.useStore)(D=>D.isValidConnection),[p,g]=(0,Ce.useState)(null),[x,f]=(0,Ce.useState)(null),[h,_]=(0,Ce.useState)(null),[b,T]=(0,Ce.useState)(null),[E,y]=(0,Ce.useState)(null),[w,C]=(0,Ce.useState)(!1),A=(0,Ce.useRef)(null),R=(0,Ce.useRef)(null),G=(0,Ce.useRef)(null),M=(0,Ce.useRef)(t),P=(0,Ce.useRef)(o);(0,Ce.useEffect)(()=>{M.current=t,P.current=o},[t,o]),(0,Ce.useEffect)(()=>{A.current=p},[p]),(0,Ce.useEffect)(()=>{R.current=E},[E]);let X=(0,Ce.useCallback)(D=>{let I=s(),z=I.find(B=>B.id===D);if(!z)return{x:0,y:0};let L=z.position.x,k=z.position.y,O=z.parentId;for(;O;){let B=I.find(ee=>ee.id===O);if(!B)break;L+=B.position.x,k+=B.position.y,O=B.parentId}return{x:L,y:k}},[s]),$=(0,Ce.useCallback)(D=>{var O,B,ee,oe,K,J;let I=s(),z=null,L=Gg,k=I.filter(Q=>Q.type!=="LANE"&&Q.type!=="ANNOTATION");for(let Q of k){if(Q.id===e)continue;let ae=X(Q.id),F=(ee=(B=(O=Q.measured)==null?void 0:O.width)!=null?B:Q.width)!=null?ee:0,ne=(J=(K=(oe=Q.measured)==null?void 0:oe.height)!=null?K:Q.height)!=null?J:0;if(D.x>=ae.x&&D.x<=ae.x+F&&D.y>=ae.y&&D.y<=ae.y+ne)return Q.id;let U=Math.max(ae.x-D.x,0,D.x-(ae.x+F)),Te=Math.max(ae.y-D.y,0,D.y-(ae.y+ne)),W=Math.sqrt(U*U+Te*Te);W<L&&(L=W,z=Q.id)}return z},[s,X,e]),Z=(0,Ce.useCallback)((D,I)=>{var U,Te,W,j,ce,re;let z=a(D);if(!z)return null;let L=X(D),k=(W=(Te=(U=z.measured)==null?void 0:U.width)!=null?Te:z.width)!=null?W:0,O=(re=(ce=(j=z.measured)==null?void 0:j.height)!=null?ce:z.height)!=null?re:0,B=Math.abs(L.x+k-I.x),ee=Math.abs(I.x-L.x),oe=Math.abs(L.y+O-I.y),K=Math.abs(I.y-L.y),J={right:B,left:ee,bottom:oe,top:K},Q=Object.entries(J).reduce((fe,[ue,Ne])=>Ne<fe[1]?[ue,Ne]:fe,["right",J.right])[0],ae=G.current;if(ae&&ae!==Q){let fe=J[Q],ue=J[ae],Ne=Math.abs(ue-fe),We=Math.min(Math.abs(ue),Math.abs(fe));Ne<We*Bg&&(Q=ae)}let F=Q,ne,le;if(F==="right"||F==="left"){let ue=(Math.max(L.y,Math.min(L.y+O,I.y))-L.y)/(O||1);Math.abs(ue-.5)<cd&&(ue=.5),le=ue,ne={x:F==="right"?L.x+k:L.x,y:L.y+le*O}}else{let ue=(Math.max(L.x,Math.min(L.x+k,I.x))-L.x)/(k||1);Math.abs(ue-.5)<cd&&(ue=.5),le=ue,ne={x:L.x+le*k,y:F==="bottom"?L.y+O:L.y}}return{side:F,snapPosition:ne,offset:le}},[a,X]),Y=(0,Ce.useCallback)(D=>{var ee,oe,K;let I=A.current;if(!I)return;let z=c({x:D.clientX,y:D.clientY}),L=$(z);_(L);let k=z,O=null,B=null;if(L){let J=Z(L,z);J&&(O=J.side,k=J.snapPosition,B=J.offset,G.current=O);let Q=l(e),ae={source:I==="source"?L:M.current,target:I==="target"?L:P.current,sourceHandle:I==="source"?O:(ee=Q==null?void 0:Q.sourceHandle)!=null?ee:null,targetHandle:I==="target"?O:(oe=Q==null?void 0:Q.targetHandle)!=null?oe:null},F=(K=m==null?void 0:m(ae))!=null?K:!0;C(F)}else G.current=null,C(!1);T(O),y(B),f(k)},[$,Z,l,e,c,m]),S=(0,Ce.useCallback)(D=>{var O,B,ee,oe,K;let I=A.current;if(!I)return;let z=c({x:D.clientX,y:D.clientY}),L=$(z);if(L){let J=Z(L,z),Q=(O=J==null?void 0:J.side)!=null?O:null,ae=(B=J==null?void 0:J.offset)!=null?B:.5,F=l(e),ne={source:I==="source"?L:M.current,target:I==="target"?L:P.current,sourceHandle:I==="source"?Q:(ee=F==null?void 0:F.sourceHandle)!=null?ee:null,targetHandle:I==="target"?Q:(oe=F==null?void 0:F.targetHandle)!=null?oe:null};((K=m==null?void 0:m(ne))==null||K)&&i(le=>le.map(U=>{var Te,W;return U.id===e?v(N({},U),{source:ne.source,target:ne.target,sourceHandle:ne.sourceHandle,targetHandle:ne.targetHandle,data:v(N({},U.data),{points:void 0,sourceOffset:I==="source"?ae:(Te=U.data)==null?void 0:Te.sourceOffset,targetOffset:I==="target"?ae:(W=U.data)==null?void 0:W.targetOffset})}):U}))}g(null),f(null),_(null),T(null),y(null),d(!1),C(!1),u(null),G.current=null,document.removeEventListener("mouseup",S),document.removeEventListener("mousemove",Y);let k=Kt.get(n);k==null||k.clearReconnectingEdge()},[e,$,Z,l,i,n,Y,m,c,d,u]),V=(0,Ce.useCallback)((D,I)=>{if(r||I.button!==0)return;I.stopPropagation(),I.preventDefault(),i(L=>L.map(k=>k.id===e?v(N({},k),{data:v(N({},k.data),{points:void 0})}):k)),g(D),u(e);let z=Kt.get(n);z==null||z.setReconnectingEdge(e),document.addEventListener("mousemove",Y),document.addEventListener("mouseup",S)},[r,e,n,Y,S,u,i]);return(0,Ce.useEffect)(()=>()=>{if(A.current){document.removeEventListener("mousemove",Y),document.removeEventListener("mouseup",S),u(null);let D=Kt.get(n);D==null||D.clearReconnectingEdge()}},[n,Y,S,u]),{reconnectingHandle:p,cursorPosition:x,hoveredNodeId:h,reconnectingSide:b,reconnectingOffset:E,isValidReconnection:w,handleReconnectStart:V}};var ye=require("react/jsx-runtime"),St={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:Le.MarkerType.ArrowClosed},markerEnd:{type:Le.MarkerType.Arrow},data:{label:""}},{MOVE_THRESHOLD:Gi,MIN_SEGMENT_LENGTH:zg,PARALLEL_OFFSET:dd,MAX_LABEL_DISTANCE:Yg}=vo;function Wg(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)*dd}let i=r.findIndex(s=>s.id===e),a=(r.length-1)/2;return(i-a)*dd}var ud=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var ee,oe,K,J,Q,ae,F,ne,le,U,Te;let{zoom:c}=(0,Le.useViewport)(),{updateEdgeData:d}=(0,Le.useReactFlow)(),u=(0,Le.useEdges)(),{isMultipleSelection:m,mode:p,instanceId:g}=q(),[x,f]=(0,Je.useState)(!1),[h,_]=(0,Je.useState)(null),b=(0,Je.useRef)(null),T=(0,Je.useRef)(n==null?void 0:n.labelOffset),E=(0,Je.useRef)(null),y=p!=="edit",{reconnectingHandle:w,cursorPosition:C,hoveredNodeId:A,reconnectingSide:R,isValidReconnection:G,handleReconnectStart:M}=Hi({edgeId:e,source:t,target:o,instanceId:g,isReadOnly:y}),P=(0,Le.useInternalNode)(t),X=(0,Le.useInternalNode)(o),{sx:$,sy:Z,tx:Y,ty:S,sourcePos:V,targetPos:D}=(0,Je.useMemo)(()=>{var ct,Bt;let W=P&&X?gn(P,X):{sx:0,sy:0,tx:0,ty:0,sourcePos:Le.Position.Right,targetPos:Le.Position.Left},j=s?i:W.sourcePos,ce=l?a:W.targetPos,re=(dt,Ae,Ee)=>{var nt,oo,zt,nn,no,ca;let{x:me,y:Pe}=dt.internals.positionAbsolute,ut=(zt=(oo=(nt=dt.measured)==null?void 0:nt.width)!=null?oo:dt.width)!=null?zt:0,vt=(ca=(no=(nn=dt.measured)==null?void 0:nn.height)!=null?no:dt.height)!=null?ca:0;switch(Ae){case Le.Position.Top:return{x:me+ut*Ee,y:Pe};case Le.Position.Bottom:return{x:me+ut*Ee,y:Pe+vt};case Le.Position.Left:return{x:me,y:Pe+vt*Ee};case Le.Position.Right:return{x:me+ut,y:Pe+vt*Ee};default:return{x:me+ut/2,y:Pe+vt/2}}},fe=(ct=n==null?void 0:n.sourceOffset)!=null?ct:.5,ue=(Bt=n==null?void 0:n.targetOffset)!=null?Bt:.5,Ne=P?re(P,j,fe).x:W.sx,We=P?re(P,j,fe).y:W.sy,Qe=X?re(X,ce,ue).x:W.tx,ot=X?re(X,ce,ue).y:W.ty;return w==="source"&&C?(Ne=C.x,We=C.y,R&&(j=R)):w==="target"&&C&&(Qe=C.x,ot=C.y,R&&(ce=R)),{sx:Ne,sy:We,tx:Qe,ty:ot,sourcePos:j,targetPos:ce}},[P,X,s,l,i,a,w,C,R,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);(0,Je.useEffect)(()=>{var ce;if(!E.current){E.current={sx:$,sy:Z,tx:Y,ty:S,sourcePos:V,targetPos:D};return}let W=E.current;if(Math.abs($-W.sx)>Gi||Math.abs(Z-W.sy)>Gi||Math.abs(Y-W.tx)>Gi||Math.abs(S-W.ty)>Gi||W.sourcePos!==V||W.targetPos!==D){let re={};(ce=n==null?void 0:n.points)!=null&&ce.length&&(re.points=void 0),n!=null&&n.labelOffset&&(re.labelOffset=void 0),Object.keys(re).length>0&&d(e,N(N({},n),re))}E.current={sx:$,sy:Z,tx:Y,ty:S,sourcePos:V,targetPos:D}},[$,Z,Y,S,V,D,n,e,d,w]);let I=(0,Je.useMemo)(()=>{let W=Wg(e,t,o,u);return Oi($,Z,Y,S,V,D,n==null?void 0:n.points,W)},[$,Z,Y,S,V,D,n==null?void 0:n.points,u,e,t,o]),z=(0,Je.useMemo)(()=>{if(I.length<2)return Li({x:$,y:Z},{x:Y,y:S});let W=0;for(let re=0;re<I.length-1;re++)W+=Sn(I[re],I[re+1]);let j=W/2,ce=0;for(let re=0;re<I.length-1;re++){let fe=Sn(I[re],I[re+1]);if(ce+fe>=j){let ue=(j-ce)/fe,Ne=I[re],We=I[re+1];return{x:Ne.x+(We.x-Ne.x)*ue,y:Ne.y+(We.y-Ne.y)*ue}}ce+=fe}return Li({x:$,y:Z},{x:Y,y:S})},[I,$,Z,Y,S]),L=(0,Je.useCallback)((W,j)=>{if(p!=="edit"||j.button!==0)return;j.stopPropagation(),j.preventDefault();let ce=I[W],re=I[W+1],fe=xe(ce,re,"y"),ue=fe?ce.y:ce.x,Ne=[...I],We=Ne.length,Qe=W,ot=W+1;_(W);let ct=dt=>{let Ae=ue+(fe?dt.clientY-j.clientY:dt.clientX-j.clientX)/c;b.current=fe?{x:(ce.x+re.x)/2,y:Ae}:{x:Ae,y:(ce.y+re.y)/2};let Ee=[];for(let me=1;me<We-1;me++){let Pe=Ne[me];me===Qe||me===ot?fe?Ee.push({x:Pe.x,y:Ae}):Ee.push({x:Ae,y:Pe.y}):Ee.push(N({},Pe))}d(e,v(N({},n),{points:Ee}))},Bt=()=>{_(null),b.current=null,document.removeEventListener("mousemove",ct),document.removeEventListener("mouseup",Bt)};document.addEventListener("mousemove",ct),document.addEventListener("mouseup",Bt)},[p,I,c,n,e,d]),k=(0,Je.useCallback)(W=>{var ct,Bt,dt,Ae,Ee;if(x||y||W.button!==0||!((ct=n==null?void 0:n.label)!=null&&ct.trim()))return;W.stopPropagation(),W.preventDefault();let j=W.clientX,ce=W.clientY,re=(dt=(Bt=n==null?void 0:n.labelOffset)==null?void 0:Bt.x)!=null?dt:0,fe=(Ee=(Ae=n==null?void 0:n.labelOffset)==null?void 0:Ae.y)!=null?Ee:0,ue=[...I],Ne={x:z.x,y:z.y},We=!1,Qe=me=>{let Pe=(me.clientX-j)/c,ut=(me.clientY-ce)/c;if(!We&&Math.abs(Pe)<3&&Math.abs(ut)<3)return;We=!0;let vt={x:re+Pe,y:fe+ut};T.current=vt,d(e,v(N({},n),{labelOffset:vt}))},ot=()=>{document.removeEventListener("mousemove",Qe),document.removeEventListener("mouseup",ot);let me=T.current;if(!me)return;let Pe={x:Ne.x+me.x,y:Ne.y+me.y};rd(Pe,ue)>Yg&&(T.current=void 0,d(e,v(N({},n),{labelOffset:void 0})))};document.addEventListener("mousemove",Qe),document.addEventListener("mouseup",ot)},[x,y,c,n,e,d,I,z]);if(!P||!X)return null;let O=ld(I),B=r||P.selected||X.selected;return(0,ye.jsxs)(ye.Fragment,{children:[(0,ye.jsxs)("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":B}),onDoubleClick:()=>!y&&f(!0),children:[(0,ye.jsx)("path",{d:O,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),className:H({"nopan nodrag":!x&&!y&&!!((ee=n==null?void 0:n.label)!=null&&ee.trim())}),style:{pointerEvents:"stroke",cursor:!x&&!y&&((oe=n==null?void 0:n.label)!=null&&oe.trim())?"move":"pointer"},onMouseDown:k}),(0,ye.jsxs)("g",{className:H("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":B}),children:[(0,ye.jsx)(Le.BaseEdge,{id:e,path:O,interactionWidth:0,markerEnd:`url(#${B?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||w&&A&&!G,"stroke-green-500":w&&A&&G,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":B&&!(n!=null&&n.hasError)&&!w})}),r&&!m&&!y&&(0,ye.jsx)("g",{children:I.slice(0,-1).map((W,j)=>{let ce=I[j+1];if(j===0||j===I.length-2||Sn(W,ce)<zg)return null;let re=xe(W,ce,"y"),fe=h===j,ue=fe&&b.current?b.current:Li(W,ce);return(0,ye.jsxs)("g",{children:[(0,ye.jsx)("line",{x1:W.x,y1:W.y,x2:ce.x,y2:ce.y,stroke:"transparent",strokeWidth:20/c,className:H("cursor-pointer",{"cursor-ns-resize":re,"cursor-ew-resize":!re}),onMouseDown:Ne=>L(j,Ne)}),(0,ye.jsx)("circle",{cx:ue.x,cy:ue.y,r:4/c,fill:fe?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ye.jsx)("circle",{cx:ue.x,cy:ue.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:fe?.6:.3,className:"pointer-events-none"})]},j)})})]})]}),(0,ye.jsxs)(Le.EdgeLabelRenderer,{children:[(0,ye.jsx)("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${z.x}px, ${z.y}px)`},children:r&&!m&&(0,ye.jsx)(An,{sx:$,sy:Z,tx:Y,ty:S,hasLabel:!!((K=n==null?void 0:n.label)!=null&&K.trim()),children:(0,ye.jsx)(In,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:P,targetNode:X})})}),(x||((J=n==null?void 0:n.label)==null?void 0:J.trim()))&&(0,ye.jsx)("div",{className:H("absolute nodrag nopan",{"z-[10001] pointer-events-auto":!x&&!y&&!!((Q=n==null?void 0:n.label)!=null&&Q.trim()),"z-[3000] pointer-events-none":x||!((ae=n==null?void 0:n.label)!=null&&ae.trim())}),style:{transform:`translate(-50%, -50%) translate(${z.x+((ne=(F=n==null?void 0:n.labelOffset)==null?void 0:F.x)!=null?ne:0)}px, ${z.y+((U=(le=n==null?void 0:n.labelOffset)==null?void 0:le.y)!=null?U:0)}px)`,cursor:!x&&!y&&((Te=n==null?void 0:n.label)!=null&&Te.trim())?"move":void 0},onMouseDown:!x&&!y?k:void 0,onDoubleClick:W=>{y||(W.stopPropagation(),f(!0))},children:(0,ye.jsx)(Ze,{value:n==null?void 0:n.label,className:H("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":x,"pointer-events-none":!x}),isEditing:x,onBlur:()=>f(!1),onChange:W=>d(e,{label:W.trim()})})}),r&&!m&&!y&&(0,ye.jsxs)(ye.Fragment,{children:[(0,ye.jsx)("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${I[0].x}px, ${I[0].y}px)`},children:(0,ye.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,ye.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:w==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ye.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:w==="source"?.6:.3,className:"pointer-events-none"}),(0,ye.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!w||w!=="source","cursor-not-allowed":w==="source"&&A&&!G,"cursor-grabbing":w==="source"&&(!A||G)}),onMouseDown:W=>M("source",W.nativeEvent)})]})}),(0,ye.jsx)("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${I[I.length-1].x}px, ${I[I.length-1].y}px)`},children:(0,ye.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,ye.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:w==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ye.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:w==="target"?.6:.3,className:"pointer-events-none"}),(0,ye.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!w||w!=="target","cursor-not-allowed":w==="target"&&A&&!G,"cursor-grabbing":w==="target"&&(!A||G)}),onMouseDown:W=>M("target",W.nativeEvent)})]})})]})]})]})};var qt=require("@xyflow/react"),Fg={right:qt.Position.Right,left:qt.Position.Left,top:qt.Position.Top,bottom:qt.Position.Bottom},Bi=e=>{var t;return(t=Fg[e!=null?e:""])!=null?t:qt.Position.Right},Bs=(e,t,o=.5)=>{var l,c,d,u;let{x:n,y:r}=e.internals.positionAbsolute,i=(c=(l=e.measured)==null?void 0:l.width)!=null?c:0,a=(u=(d=e.measured)==null?void 0:d.height)!=null?u:0;switch(Bi(t)){case qt.Position.Right:return{x:n+i,y:r+a*o};case qt.Position.Left:return{x:n,y:r+a*o};case qt.Position.Top:return{x:n+i*o,y:r};case qt.Position.Bottom:return{x:n+i*o,y:r+a};default:return{x:n+i/2,y:r+a/2}}},pd=(e,t,o)=>{var d,u;let{position:{x:n,y:r},measured:i}=e,a=(d=i.width)!=null?d:0,s=(u=i.height)!=null?u:0;return[{id:"left",x:n,y:r+s/2},{id:"right",x:n+a,y:r+s/2},{id:"top",x:n+a/2,y:r},{id:"bottom",x:n+a/2,y:r+s}].reduce((m,p)=>{let g=Math.hypot(t-m.x,o-m.y);return Math.hypot(t-p.x,o-p.y)<g?p:m}).id};var gu=require("use-debounce");var Hn=require("@xyflow/react"),js=require("react");var pr=(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))(pr||{});var zi=require("xml-js");var fd={compact:!0,spaces:4},Xg=e=>e.replace(/\n/g,"
");function Yi(e,t=fd){if(e)return JSON.parse((0,zi.xml2json)(e,t))}function md(e,t=fd){return e?(0,zi.json2xml)(e,v(N({},t),{attributeValueFn:Xg})):""}var gd={"attribute-loop":"LOOP"},hd={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS"},yd={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},xd={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed"},Ed={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var Mn=(e,t,o,n,r,i)=>{let a=e._attributes.width||0,s=e._attributes.height||0,l=0,c=0;if(n&&r!==void 0&&i!==void 0){let g=n.split(`
|
|
6
|
-
`),
|
|
5
|
+
`).trim();t&&T.length>t&&(T=T.substring(0,t)),N.currentTarget.innerText=T,s==null||s(),T!==e&&(a==null||a(T))};return(0,zs.jsx)("div",{className:H("flex-1 p-2 self-stretch flex items-center justify-center border border-transparent overflow-hidden text-ellipsis body-medium-400 text-center rounded-sm",{"border border-dashed border-grey-400 bg-white shadow-md":u,"bg-white":e.length>0},n),style:o,onDoubleClick:f,children:(0,zs.jsx)("div",{ref:p,className:H("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":u}),contentEditable:u,suppressContentEditableWarning:!0,onKeyDown:h,onPaste:y,onInput:x,onBlur:v,children:e})})};var Pg=require("@xyflow/react");var xe=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,Pn=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),ki=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),Lg=(e,t,o)=>{let n=o.x-t.x,r=o.y-t.y,i=n*n+r*r;if(i===0)return Pn(e,t);let a=Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*r)/i));return Pn(e,{x:t.x+a*n,y:t.y+a*r})},id=(e,t)=>{let o=1/0;for(let n=0;n<t.length-1;n++)o=Math.min(o,Lg(e,t[n],t[n+1]));return o};var fr=require("@xyflow/react");var Ao={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15,MAX_LABEL_DISTANCE:80};var{TOLERANCE:de}=Ao;function kg(e,t,o){return xe(e,t,"x",de)&&xe(t,o,"x",de)&&xe(e,o,"x",de)}function Rg(e,t,o){return xe(e,t,"y",de)&&xe(t,o,"y",de)&&xe(e,o,"y",de)}function Dg(e,t,o){if(!kg(e,t,o))return!1;let n=t.y-e.y,r=o.y-t.y;return Math.abs(n)<de||Math.abs(r)<de?!1:n*r<0}function Og(e,t,o){if(!Rg(e,t,o))return!1;let n=t.x-e.x,r=o.x-t.x;return Math.abs(n)<de||Math.abs(r)<de?!1:n*r<0}function Vg(e,t,o,n){let r=t.x!==0,i=t.x===-n.x&&t.y===-n.y,a=t.x===n.x&&t.y===n.y,s=120;if(i)if(r){if((o.x-e.x)*t.x>=0)return[{x:(e.x+o.x)/2,y:e.y},{x:(e.x+o.x)/2,y:o.y}];{let l=(e.y+o.y)/2,c=Math.abs(e.y-o.y)<s?Math.max(e.y,o.y)+s:l;return[{x:e.x,y:c},{x:o.x,y:c}]}}else{if((o.y-e.y)*t.y>=0)return[{x:e.x,y:(e.y+o.y)/2},{x:o.x,y:(e.y+o.y)/2}];{let l=(e.x+o.x)/2,c=Math.abs(e.x-o.x)<s?Math.max(e.x,o.x)+s:l;return[{x:c,y:e.y},{x:c,y:o.y}]}}else if(a)if(r)if((o.x-e.x)*t.x>0&&Math.abs(e.y-o.y)<s){let l=Math.max(e.y,o.y)+s,c=o.x+t.x*(s/2);return[{x:e.x,y:l},{x:c,y:l},{x:c,y:o.y}]}else{let l=t.x>0?Math.max(e.x,o.x):Math.min(e.x,o.x);return[{x:l,y:e.y},{x:l,y:o.y}]}else if((o.y-e.y)*t.y>0&&Math.abs(e.x-o.x)<s){let l=Math.max(e.x,o.x)+s,c=o.y+t.y*(s/2);return[{x:l,y:e.y},{x:l,y:c},{x:o.x,y:c}]}else{let l=t.y>0?Math.max(e.y,o.y):Math.min(e.y,o.y);return[{x:e.x,y:l},{x:o.x,y:l}]}else{let l=t.x!==0?o.x:e.x,c=t.y!==0?o.y:e.y,d=t.x!==0?(l-e.x)*t.x:(c-e.y)*t.y,p=n.x!==0?(l-o.x)*n.x:(c-o.y)*n.y;return d>=0&&p>=0?[{x:l,y:c}]:r?[{x:e.x,y:o.y}]:[{x:o.x,y:e.y}]}}function sd(e){if(e.length<=2)return e;let t=[e[0]];for(let o=1;o<e.length-1;o++){let n=t[t.length-1],r=e[o],i=e[o+1];xe(n,r,"x",de)&&xe(r,i,"x",de)||xe(n,r,"y",de)&&xe(r,i,"y",de)||t.push(r)}return t.push(e[e.length-1]),t}function Ri(e){let t=[];for(let o of e){let n=t[t.length-1];(!n||Math.abs(n.x-o.x)>=de||Math.abs(n.y-o.y)>=de)&&t.push(o)}return t}function Hg(e){let t=[...e],o=!0;for(;o;){o=!1;for(let n=1;n<t.length-1;n++){let r=t[n-1],i=t[n],a=t[n+1];if(Dg(r,i,a)||Og(r,i,a)){t.splice(n,1),o=!0;break}}}return t}function ad(e){let t=Ri(sd([...e]));return t=Hg(t),Ri(sd(t))}function Di(e){switch(e){case fr.Position.Left:return{x:-1,y:0};case fr.Position.Right:return{x:1,y:0};case fr.Position.Top:return{x:0,y:-1};case fr.Position.Bottom:return{x:0,y:1};default:return{x:0,y:0}}}function ld(e,t,o,n){let r=Ao.OFFSET,i=Ao.OFFSET;if(t.x===-n.x&&t.y===-n.y)if(t.x!==0){let a=(o.x-e.x)*t.x;a>0&&a<2*Ao.OFFSET&&(r=a/2,i=a/2)}else{let a=(o.y-e.y)*t.y;a>0&&a<2*Ao.OFFSET&&(r=a/2,i=a/2)}return{sourceOffset:r,targetOffset:i}}function Gg(e,t,o,n,r,i,a=0){let s=Di(r),l=Di(i),c=s.x===0?a:0,d=s.y===0?a:0,p=l.x===0?a:0,m=l.y===0?a:0,u={x:e+c,y:t+d},g={x:o+p,y:n+m},{sourceOffset:E,targetOffset:f}=ld(u,s,g,l),h={x:u.x+s.x*E,y:u.y+s.y*E},y={x:g.x+l.x*f,y:g.y+l.y*f},x=Vg(h,s,y,l),v=[u,h,...x,y,g],N=ad(v);if(N.length===2&&Oi(u,g)>de){let T=xe(u,h,"x",de)&&xe(h,y,"x",de)&&xe(y,g,"x",de),_=xe(u,h,"y",de)&&xe(h,y,"y",de)&&xe(y,g,"y",de);if(T||_){let I=_&&(y.x-h.x)*s.x<0,S=T&&(y.y-h.y)*s.y<0;if(!I&&!S)return Ri([u,h,y,g])}}return N}function Vi(e,t,o,n,r,i,a,s=0){if(!(a!=null&&a.length))return Gg(e,t,o,n,r,i,s);let l=Di(r),c=Di(i),d=l.x===0?s:0,p=l.y===0?s:0,m=c.x===0?s:0,u=c.y===0?s:0,g={x:e+d,y:t+p},E={x:o+m,y:n+u},{sourceOffset:f,targetOffset:h}=ld(g,l,E,c),y={x:g.x+l.x*f,y:g.y+l.y*f},x={x:E.x+c.x*h,y:E.y+c.y*h},v=[...a],N=v[0],T=l.y===0;T&&Math.abs(g.y-N.y)>de?v.unshift({x:N.x,y:g.y}):!T&&Math.abs(g.x-N.x)>de&&v.unshift({x:g.x,y:N.y});let _=v[v.length-1],I=c.y===0,S=[];(Math.abs(_.x-x.x)>de||Math.abs(_.y-x.y)>de)&&(I?S.push({x:x.x,y:_.y}):S.push({x:_.x,y:x.y})),S.push(x);let P=[g,...v,...S,E],R=ad(P);if(R.length===2&&Oi(g,E)>de){let M=xe(g,y,"x",de)&&xe(y,x,"x",de)&&xe(x,E,"x",de),B=xe(g,y,"y",de)&&xe(y,x,"y",de)&&xe(x,E,"y",de);if(M||B){let X=B&&(x.x-y.x)*l.x<0,U=M&&(x.y-y.y)*l.y<0;if(!X&&!U)return Ri([g,y,x,E])}}return R}var Oi=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Bg(e,t,o){return xe(e,t,"x",de)&&xe(t,o,"x",de)||xe(e,t,"y",de)&&xe(t,o,"y",de)}function zg(e,t,o,n){if(Bg(e,t,o))return`L${t.x} ${t.y}`;let r=Oi(e,t),i=Oi(t,o),a=Math.min(r/2,i/2,n);if(a<1)return`L${t.x} ${t.y}`;let s=e.x-t.x,l=e.y-t.y,c=o.x-t.x,d=o.y-t.y,p={x:s/r,y:l/r},m={x:c/i,y:d/i},u={x:t.x+p.x*a,y:t.y+p.y*a},g={x:t.x+m.x*a,y:t.y+m.y*a},E=-p.x,f=-p.y,h=m.x,y=m.y,v=E*y-f*h>0?1:0;return`L${u.x} ${u.y}A${a} ${a} 0 0 ${v} ${g.x} ${g.y}`}var cd=(e,t=5)=>e.length<2?"":e.reduce((o,n,r)=>{let i="";return r>0&&r<e.length-1?i=zg(e[r-1],n,e[r+1],t):i=`${r===0?"M":"L"}${n.x} ${n.y}`,o+=i,o},"");var Ce=require("react"),Hi=require("@xyflow/react");var Yg=50,dd=.1,Wg=.6,Gi=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:a,getNodes:s,getEdge:l,screenToFlowPosition:c}=(0,Hi.useReactFlow)(),{setIsDragging:d,setReconnectingEdgeId:p}=$(),m=(0,Hi.useStore)(D=>D.isValidConnection),[u,g]=(0,Ce.useState)(null),[E,f]=(0,Ce.useState)(null),[h,y]=(0,Ce.useState)(null),[x,v]=(0,Ce.useState)(null),[N,T]=(0,Ce.useState)(null),[_,I]=(0,Ce.useState)(!1),S=(0,Ce.useRef)(null),P=(0,Ce.useRef)(null),R=(0,Ce.useRef)(null),M=(0,Ce.useRef)(t),B=(0,Ce.useRef)(o);(0,Ce.useEffect)(()=>{M.current=t,B.current=o},[t,o]),(0,Ce.useEffect)(()=>{S.current=u},[u]),(0,Ce.useEffect)(()=>{P.current=N},[N]);let X=(0,Ce.useCallback)(D=>{let A=s(),k=A.find(V=>V.id===D);if(!k)return{x:0,y:0};let G=k.position.x,z=k.position.y,L=k.parentId;for(;L;){let V=A.find(j=>j.id===L);if(!V)break;G+=V.position.x,z+=V.position.y,L=V.parentId}return{x:G,y:z}},[s]),U=(0,Ce.useCallback)(D=>{var L,V,j,Z,J,q;let A=s(),k=null,G=Yg,z=A.filter(ee=>ee.type!=="LANE"&&ee.type!=="ANNOTATION");for(let ee of z){if(ee.id===e)continue;let ae=X(ee.id),F=(j=(V=(L=ee.measured)==null?void 0:L.width)!=null?V:ee.width)!=null?j:0,ne=(q=(J=(Z=ee.measured)==null?void 0:Z.height)!=null?J:ee.height)!=null?q:0;if(D.x>=ae.x&&D.x<=ae.x+F&&D.y>=ae.y&&D.y<=ae.y+ne)return ee.id;let K=Math.max(ae.x-D.x,0,D.x-(ae.x+F)),Te=Math.max(ae.y-D.y,0,D.y-(ae.y+ne)),W=Math.sqrt(K*K+Te*Te);W<G&&(G=W,k=ee.id)}return k},[s,X,e]),Q=(0,Ce.useCallback)((D,A)=>{var K,Te,W,te,ce,re;let k=a(D);if(!k)return null;let G=X(D),z=(W=(Te=(K=k.measured)==null?void 0:K.width)!=null?Te:k.width)!=null?W:0,L=(re=(ce=(te=k.measured)==null?void 0:te.height)!=null?ce:k.height)!=null?re:0,V=Math.abs(G.x+z-A.x),j=Math.abs(A.x-G.x),Z=Math.abs(G.y+L-A.y),J=Math.abs(A.y-G.y),q={right:V,left:j,bottom:Z,top:J},ee=Object.entries(q).reduce((fe,[ue,Ne])=>Ne<fe[1]?[ue,Ne]:fe,["right",q.right])[0],ae=R.current;if(ae&&ae!==ee){let fe=q[ee],ue=q[ae],Ne=Math.abs(ue-fe),Fe=Math.min(Math.abs(ue),Math.abs(fe));Ne<Fe*Wg&&(ee=ae)}let F=ee,ne,le;if(F==="right"||F==="left"){let ue=(Math.max(G.y,Math.min(G.y+L,A.y))-G.y)/(L||1);Math.abs(ue-.5)<dd&&(ue=.5),le=ue,ne={x:F==="right"?G.x+z:G.x,y:G.y+le*L}}else{let ue=(Math.max(G.x,Math.min(G.x+z,A.x))-G.x)/(z||1);Math.abs(ue-.5)<dd&&(ue=.5),le=ue,ne={x:G.x+le*z,y:F==="bottom"?G.y+L:G.y}}return{side:F,snapPosition:ne,offset:le}},[a,X]),Y=(0,Ce.useCallback)(D=>{var j,Z,J;let A=S.current;if(!A)return;let k=c({x:D.clientX,y:D.clientY}),G=U(k);y(G);let z=k,L=null,V=null;if(G){let q=Q(G,k);q&&(L=q.side,z=q.snapPosition,V=q.offset,R.current=L);let ee=l(e),ae={source:A==="source"?G:M.current,target:A==="target"?G:B.current,sourceHandle:A==="source"?L:(j=ee==null?void 0:ee.sourceHandle)!=null?j:null,targetHandle:A==="target"?L:(Z=ee==null?void 0:ee.targetHandle)!=null?Z:null},F=(J=m==null?void 0:m(ae))!=null?J:!0;I(F)}else R.current=null,I(!1);v(L),T(V),f(z)},[U,Q,l,e,c,m]),C=(0,Ce.useCallback)(D=>{var L,V,j,Z,J;let A=S.current;if(!A)return;let k=c({x:D.clientX,y:D.clientY}),G=U(k);if(G){let q=Q(G,k),ee=(L=q==null?void 0:q.side)!=null?L:null,ae=(V=q==null?void 0:q.offset)!=null?V:.5,F=l(e),ne={source:A==="source"?G:M.current,target:A==="target"?G:B.current,sourceHandle:A==="source"?ee:(j=F==null?void 0:F.sourceHandle)!=null?j:null,targetHandle:A==="target"?ee:(Z=F==null?void 0:F.targetHandle)!=null?Z:null};((J=m==null?void 0:m(ne))==null||J)&&i(le=>le.map(K=>{var Te,W;return K.id===e?w(b({},K),{source:ne.source,target:ne.target,sourceHandle:ne.sourceHandle,targetHandle:ne.targetHandle,data:w(b({},K.data),{points:void 0,sourceOffset:A==="source"?ae:(Te=K.data)==null?void 0:Te.sourceOffset,targetOffset:A==="target"?ae:(W=K.data)==null?void 0:W.targetOffset})}):K}))}g(null),f(null),y(null),v(null),T(null),d(!1),I(!1),p(null),R.current=null,document.removeEventListener("mouseup",C),document.removeEventListener("mousemove",Y);let z=Kt.get(n);z==null||z.clearReconnectingEdge()},[e,U,Q,l,i,n,Y,m,c,d,p]),O=(0,Ce.useCallback)((D,A)=>{if(r||A.button!==0)return;A.stopPropagation(),A.preventDefault(),i(G=>G.map(z=>z.id===e?w(b({},z),{data:w(b({},z.data),{points:void 0})}):z)),g(D),p(e);let k=Kt.get(n);k==null||k.setReconnectingEdge(e),document.addEventListener("mousemove",Y),document.addEventListener("mouseup",C)},[r,e,n,Y,C,p,i]);return(0,Ce.useEffect)(()=>()=>{if(S.current){document.removeEventListener("mousemove",Y),document.removeEventListener("mouseup",C),p(null);let D=Kt.get(n);D==null||D.clearReconnectingEdge()}},[n,Y,C,p]),{reconnectingHandle:u,cursorPosition:E,hoveredNodeId:h,reconnectingSide:x,reconnectingOffset:N,isValidReconnection:_,handleReconnectStart:O}};var ye=require("react/jsx-runtime"),St={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:Se.MarkerType.ArrowClosed},markerEnd:{type:Se.MarkerType.Arrow},data:{label:""}},{MOVE_THRESHOLD:Bi,MIN_SEGMENT_LENGTH:Fg,PARALLEL_OFFSET:ud,MAX_LABEL_DISTANCE:Xg}=Ao;function Ug(e,t,o,n,r){let i=r.find(d=>d.id===t),a=r.find(d=>d.id===o);if((i==null?void 0:i.type)==="GATEWAY"||(a==null?void 0:a.type)==="GATEWAY")return 0;let s=n.filter(d=>d.source===t&&d.target===o||d.source===o&&d.target===t);if(s.length<=1){let d=n.filter(u=>u.source===t);if(d.length<=1)return 0;let p=d.findIndex(u=>u.id===e);if(p<=0)return 0;let m=(d.length-1)/2;return(p-m)*ud}let l=s.findIndex(d=>d.id===e),c=(s.length-1)/2;return(l-c)*ud}var pd=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var Z,J,q,ee,ae,F,ne,le,K,Te;let{zoom:c}=(0,Se.useViewport)(),{updateEdgeData:d}=(0,Se.useReactFlow)(),p=(0,Se.useEdges)(),m=(0,Se.useNodes)(),{isMultipleSelection:u,mode:g,instanceId:E}=$(),[f,h]=(0,Je.useState)(!1),[y,x]=(0,Je.useState)(null),v=(0,Je.useRef)(null),N=(0,Je.useRef)(n==null?void 0:n.labelOffset),T=(0,Je.useRef)(null),_=g!=="edit",{reconnectingHandle:I,cursorPosition:S,hoveredNodeId:P,reconnectingSide:R,isValidReconnection:M,handleReconnectStart:B}=Gi({edgeId:e,source:t,target:o,instanceId:E,isReadOnly:_}),X=(0,Se.useInternalNode)(t),U=(0,Se.useInternalNode)(o),{sx:Q,sy:Y,tx:C,ty:O,sourcePos:D,targetPos:A}=(0,Je.useMemo)(()=>{var ct,Bt;let W=X&&U?yn(X,U):{sx:0,sy:0,tx:0,ty:0,sourcePos:Se.Position.Right,targetPos:Se.Position.Left},te=s?i:W.sourcePos,ce=l?a:W.targetPos,re=(dt,Ae,Ee)=>{var nt,zt,go,oo,no,ua;let{x:me,y:Le}=dt.internals.positionAbsolute,ut=(go=(zt=(nt=dt.measured)==null?void 0:nt.width)!=null?zt:dt.width)!=null?go:0,vt=(ua=(no=(oo=dt.measured)==null?void 0:oo.height)!=null?no:dt.height)!=null?ua:0;switch(Ae){case Se.Position.Top:return{x:me+ut*Ee,y:Le};case Se.Position.Bottom:return{x:me+ut*Ee,y:Le+vt};case Se.Position.Left:return{x:me,y:Le+vt*Ee};case Se.Position.Right:return{x:me+ut,y:Le+vt*Ee};default:return{x:me+ut/2,y:Le+vt/2}}},fe=(ct=n==null?void 0:n.sourceOffset)!=null?ct:.5,ue=(Bt=n==null?void 0:n.targetOffset)!=null?Bt:.5,Ne=X?re(X,te,fe).x:W.sx,Fe=X?re(X,te,fe).y:W.sy,Qe=U?re(U,ce,ue).x:W.tx,ot=U?re(U,ce,ue).y:W.ty;return I==="source"&&S?(Ne=S.x,Fe=S.y,R&&(te=R)):I==="target"&&S&&(Qe=S.x,ot=S.y,R&&(ce=R)),{sx:Ne,sy:Fe,tx:Qe,ty:ot,sourcePos:te,targetPos:ce}},[X,U,s,l,i,a,I,S,R,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);(0,Je.useEffect)(()=>{var ce;if(!T.current){T.current={sx:Q,sy:Y,tx:C,ty:O,sourcePos:D,targetPos:A};return}let W=T.current;if(Math.abs(Q-W.sx)>Bi||Math.abs(Y-W.sy)>Bi||Math.abs(C-W.tx)>Bi||Math.abs(O-W.ty)>Bi||W.sourcePos!==D||W.targetPos!==A){let re={};(ce=n==null?void 0:n.points)!=null&&ce.length&&(re.points=void 0),n!=null&&n.labelOffset&&(re.labelOffset=void 0),Object.keys(re).length>0&&d(e,b(b({},n),re))}T.current={sx:Q,sy:Y,tx:C,ty:O,sourcePos:D,targetPos:A}},[Q,Y,C,O,D,A,n,e,d,I]);let k=(0,Je.useMemo)(()=>{let W=Ug(e,t,o,p,m);return Vi(Q,Y,C,O,D,A,n==null?void 0:n.points,W)},[Q,Y,C,O,D,A,n==null?void 0:n.points,p,m,e,t,o]),G=(0,Je.useMemo)(()=>{if(k.length<2)return ki({x:Q,y:Y},{x:C,y:O});let W=0;for(let re=0;re<k.length-1;re++)W+=Pn(k[re],k[re+1]);let te=W/2,ce=0;for(let re=0;re<k.length-1;re++){let fe=Pn(k[re],k[re+1]);if(ce+fe>=te){let ue=(te-ce)/fe,Ne=k[re],Fe=k[re+1];return{x:Ne.x+(Fe.x-Ne.x)*ue,y:Ne.y+(Fe.y-Ne.y)*ue}}ce+=fe}return ki({x:Q,y:Y},{x:C,y:O})},[k,Q,Y,C,O]),z=(0,Je.useCallback)((W,te)=>{if(g!=="edit"||te.button!==0)return;te.stopPropagation(),te.preventDefault();let ce=k[W],re=k[W+1],fe=xe(ce,re,"y"),ue=fe?ce.y:ce.x,Ne=[...k],Fe=Ne.length,Qe=W,ot=W+1;x(W);let ct=dt=>{let Ae=ue+(fe?dt.clientY-te.clientY:dt.clientX-te.clientX)/c;v.current=fe?{x:(ce.x+re.x)/2,y:Ae}:{x:Ae,y:(ce.y+re.y)/2};let Ee=[];for(let me=1;me<Fe-1;me++){let Le=Ne[me];me===Qe||me===ot?fe?Ee.push({x:Le.x,y:Ae}):Ee.push({x:Ae,y:Le.y}):Ee.push(b({},Le))}d(e,w(b({},n),{points:Ee}))},Bt=()=>{x(null),v.current=null,document.removeEventListener("mousemove",ct),document.removeEventListener("mouseup",Bt)};document.addEventListener("mousemove",ct),document.addEventListener("mouseup",Bt)},[g,k,c,n,e,d]),L=(0,Je.useCallback)(W=>{var ct,Bt,dt,Ae,Ee;if(f||_||W.button!==0||!((ct=n==null?void 0:n.label)!=null&&ct.trim()))return;W.stopPropagation(),W.preventDefault();let te=W.clientX,ce=W.clientY,re=(dt=(Bt=n==null?void 0:n.labelOffset)==null?void 0:Bt.x)!=null?dt:0,fe=(Ee=(Ae=n==null?void 0:n.labelOffset)==null?void 0:Ae.y)!=null?Ee:0,ue=[...k],Ne={x:G.x,y:G.y},Fe=!1,Qe=me=>{let Le=(me.clientX-te)/c,ut=(me.clientY-ce)/c;if(!Fe&&Math.abs(Le)<3&&Math.abs(ut)<3)return;Fe=!0;let vt={x:re+Le,y:fe+ut};N.current=vt,d(e,w(b({},n),{labelOffset:vt}))},ot=()=>{document.removeEventListener("mousemove",Qe),document.removeEventListener("mouseup",ot);let me=N.current;if(!me)return;let Le={x:Ne.x+me.x,y:Ne.y+me.y};id(Le,ue)>Xg&&(N.current=void 0,d(e,w(b({},n),{labelOffset:void 0})))};document.addEventListener("mousemove",Qe),document.addEventListener("mouseup",ot)},[f,_,c,n,e,d,k,G]);if(!X||!U)return null;let V=cd(k),j=r||X.selected||U.selected;return(0,ye.jsxs)(ye.Fragment,{children:[(0,ye.jsxs)("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":j}),onDoubleClick:()=>!_&&h(!0),children:[(0,ye.jsx)("path",{d:V,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),className:H({"nopan nodrag":!f&&!_&&!!((Z=n==null?void 0:n.label)!=null&&Z.trim())}),style:{pointerEvents:"stroke",cursor:!f&&!_&&((J=n==null?void 0:n.label)!=null&&J.trim())?"move":"pointer"},onMouseDown:L}),(0,ye.jsxs)("g",{className:H("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":j}),children:[(0,ye.jsx)(Se.BaseEdge,{id:e,path:V,interactionWidth:0,markerEnd:`url(#${j?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||I&&P&&!M,"stroke-green-500":I&&P&&M,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":j&&!(n!=null&&n.hasError)&&!I})}),r&&!u&&!_&&(0,ye.jsx)("g",{children:k.slice(0,-1).map((W,te)=>{let ce=k[te+1];if(te===0||te===k.length-2||Pn(W,ce)<Fg)return null;let re=xe(W,ce,"y"),fe=y===te,ue=fe&&v.current?v.current:ki(W,ce);return(0,ye.jsxs)("g",{children:[(0,ye.jsx)("line",{x1:W.x,y1:W.y,x2:ce.x,y2:ce.y,stroke:"transparent",strokeWidth:20/c,className:H("cursor-pointer",{"cursor-ns-resize":re,"cursor-ew-resize":!re}),onMouseDown:Ne=>z(te,Ne)}),(0,ye.jsx)("circle",{cx:ue.x,cy:ue.y,r:4/c,fill:fe?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ye.jsx)("circle",{cx:ue.x,cy:ue.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:fe?.6:.3,className:"pointer-events-none"})]},te)})})]})]}),(0,ye.jsxs)(Se.EdgeLabelRenderer,{children:[(0,ye.jsx)("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${G.x}px, ${G.y}px)`},children:r&&!u&&(0,ye.jsx)(Sn,{sx:Q,sy:Y,tx:C,ty:O,hasLabel:!!((q=n==null?void 0:n.label)!=null&&q.trim()),children:(0,ye.jsx)(Cn,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:X,targetNode:U})})}),(f||((ee=n==null?void 0:n.label)==null?void 0:ee.trim()))&&(0,ye.jsx)("div",{className:H("absolute nodrag nopan",!f&&!_&&((ae=n==null?void 0:n.label)!=null&&ae.trim())?"z-[10001] pointer-events-auto":"z-[3000] pointer-events-none"),style:{transform:`translate(-50%, -50%) translate(${G.x+((ne=(F=n==null?void 0:n.labelOffset)==null?void 0:F.x)!=null?ne:0)}px, ${G.y+((K=(le=n==null?void 0:n.labelOffset)==null?void 0:le.y)!=null?K:0)}px)`,cursor:!f&&!_&&((Te=n==null?void 0:n.label)!=null&&Te.trim())?"move":void 0},onMouseDown:!f&&!_?L:void 0,onDoubleClick:W=>{_||(W.stopPropagation(),h(!0))},children:(0,ye.jsx)(Ze,{value:n==null?void 0:n.label,className:H("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":f,"pointer-events-none":!f}),isEditing:f,onBlur:()=>h(!1),onChange:W=>d(e,{label:W.trim()})})}),r&&!u&&!_&&(0,ye.jsxs)(ye.Fragment,{children:[(0,ye.jsx)("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${k[0].x}px, ${k[0].y}px)`},children:(0,ye.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,ye.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:I==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ye.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:I==="source"?.6:.3,className:"pointer-events-none"}),(0,ye.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!I||I!=="source","cursor-not-allowed":I==="source"&&P&&!M,"cursor-grabbing":I==="source"&&(!P||M)}),onMouseDown:W=>B("source",W.nativeEvent)})]})}),(0,ye.jsx)("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${k[k.length-1].x}px, ${k[k.length-1].y}px)`},children:(0,ye.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,ye.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:I==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ye.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:I==="target"?.6:.3,className:"pointer-events-none"}),(0,ye.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!I||I!=="target","cursor-not-allowed":I==="target"&&P&&!M,"cursor-grabbing":I==="target"&&(!P||M)}),onMouseDown:W=>B("target",W.nativeEvent)})]})})]})]})]})};var qt=require("@xyflow/react"),$g={right:qt.Position.Right,left:qt.Position.Left,top:qt.Position.Top,bottom:qt.Position.Bottom},zi=e=>{var t;return(t=$g[e!=null?e:""])!=null?t:qt.Position.Right},Ys=(e,t,o=.5)=>{var l,c,d,p;let{x:n,y:r}=e.internals.positionAbsolute,i=(c=(l=e.measured)==null?void 0:l.width)!=null?c:0,a=(p=(d=e.measured)==null?void 0:d.height)!=null?p:0;switch(zi(t)){case qt.Position.Right:return{x:n+i,y:r+a*o};case qt.Position.Left:return{x:n,y:r+a*o};case qt.Position.Top:return{x:n+i*o,y:r};case qt.Position.Bottom:return{x:n+i*o,y:r+a};default:return{x:n+i/2,y:r+a/2}}},fd=(e,t,o)=>{var d,p;let{position:{x:n,y:r},measured:i}=e,a=(d=i.width)!=null?d:0,s=(p=i.height)!=null?p:0;return[{id:"left",x:n,y:r+s/2},{id:"right",x:n+a,y:r+s/2},{id:"top",x:n+a/2,y:r},{id:"bottom",x:n+a/2,y:r+s}].reduce((m,u)=>{let g=Math.hypot(t-m.x,o-m.y);return Math.hypot(t-u.x,o-u.y)<g?u:m}).id};var yu=require("use-debounce");var Bn=require("@xyflow/react"),ta=require("react");var mr=(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))(mr||{});var Yi=require("xml-js");var md={compact:!0,spaces:4},Kg=e=>e.replace(/\n/g,"
");function Wi(e,t=md){if(e)return JSON.parse((0,Yi.xml2json)(e,t))}function gd(e,t=md){return e?(0,Yi.json2xml)(e,w(b({},t),{attributeValueFn:Kg})):""}var hd={"attribute-loop":"LOOP"},yd={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS"},xd={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Ed={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed"},bd={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var Ln=(e,t,o,n,r,i)=>{let a=e._attributes.width||0,s=e._attributes.height||0,l=0,c=0;if(n&&r!==void 0&&i!==void 0){let g=n.split(`
|
|
6
|
+
`),E=g.length;l=g.reduce((h,y)=>Math.max(h,y.length),0)*7+r,c=E*20+i}let d=Math.max(yo(Number(a),t),l),p=Math.max(yo(Number(s),o),c);return{width:d,height:p,measured:{width:d,height:p}}},kn=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},Zg=e=>{let{mxGeometry:t}=e,o=kn(e),n=Ln(t,pe.START_EVENT.MIN_WIDTH,pe.START_EVENT.MIN_HEIGHT);return w(b(b({},o),n),{type:"START_EVENT"})},Jg=e=>{let{mxGeometry:t}=e,o=kn(e),n=Ln(t,pe.END_EVENT.MIN_WIDTH,pe.END_EVENT.MIN_HEIGHT);return w(b(b({},o),n),{type:"END_EVENT"})},Ws=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=kn(e),s=Ln(n,pe.TASK.MIN_WIDTH,pe.TASK.MIN_HEIGHT,r.data.label,48,24),l=t==null?void 0:t.find(d=>{let{parent:p}=d._attributes;return p===e._attributes.id});if(l){let{style:d}=l._attributes,p=hd[d];p&&(r.data.attribute=p)}let c=yd[o.style];return c&&(r.data.variant=c),w(b(b({},r),s),{type:"TASK"})},Fs=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=kn(e),i=Ln(o,pe.GATEWAY.MIN_WIDTH,pe.GATEWAY.MIN_HEIGHT);return r.data.variant=xd[n],w(b(b({},r),i),{type:"GATEWAY"})},Qg=e=>{let{mxGeometry:t}=e,o=kn(e),i=Ln(t,pe.ANNOTATION.MIN_WIDTH,pe.ANNOTATION.MIN_HEIGHT,o.data.label,32,24);return w(b(b({},o),i),{type:"ANNOTATION"})},jg=e=>{let{mxGeometry:t}=e,o=kn(e),n=Ln(t,pe.LANE.MIN_WIDTH,pe.LANE.MIN_HEIGHT);return w(b(b({},o),n),{type:"LANE"})},_d={task:Ws,"task-script":Ws,"subprocess-collapsed":Ws,"start-event":Zg,"end-event-terminate":Jg,"gateway-parallel":Fs,"gateway-exclusive":Fs,"gateway-complex":Fs,annotation:Qg,lane:jg},eh=e=>{if(e&&Array.isArray(e))return e.map(t=>({x:Number(t._attributes.x),y:Number(t._attributes.y)}))},Nd=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,source:r,target:i,value:a,style:s,sourceHandle:l,targetHandle:c,sourceOffset:d,targetOffset:p,labelOffsetX:m,labelOffsetY:u}=t,g=eh(o==null?void 0:o.Array),E=d!==void 0?Number(d):void 0,f=p!==void 0?Number(p):void 0,h=m!==void 0?Number(m):void 0,y=u!==void 0?Number(u):void 0,x=w(b(b({id:n,source:r,target:i},l?{sourceHandle:l}:{}),c?{targetHandle:c}:{}),{data:b(b(b(b({label:a||""},g&&g.length>0?{points:g}:{}),E!==void 0?{sourceOffset:E}:{}),f!==void 0?{targetOffset:f}:{}),h!==void 0&&y!==void 0?{labelOffset:{x:h,y}}:{})});return s.includes("association")&&s.includes('endArrow=""')?b(b({},Mn),x):b(b({},St),x)},Td=(e,t)=>{var u,g;let{id:o,type:n,source:r,target:i,sourceHandle:a,targetHandle:s,data:l}=e,c=t==null?void 0:t.find(E=>E.id===r),d="";n==="ANNOTATION_EDGE"&&(d='association;endArrow=""');let p={_attributes:{as:"geometry",relative:"1"}};return l!=null&&l.points&&Array.isArray(l.points)&&l.points.length>0&&(p.Array=l.points.map(E=>({_attributes:{as:"mxPoint",x:E.x,y:E.y}}))),{_attributes:{id:o,parent:(c==null?void 0:c.parentId)||"1",edge:"1",style:d,source:r,target:i,value:(l==null?void 0:l.label)||"",sourceHandle:a!=null?a:void 0,targetHandle:s!=null?s:void 0,sourceOffset:(l==null?void 0:l.sourceOffset)!==void 0?String(l.sourceOffset):void 0,targetOffset:(l==null?void 0:l.targetOffset)!==void 0?String(l.targetOffset):void 0,labelOffsetX:((u=l==null?void 0:l.labelOffset)==null?void 0:u.x)!==void 0?String(l.labelOffset.x):void 0,labelOffsetY:((g=l==null?void 0:l.labelOffset)==null?void 0:g.y)!==void 0?String(l.labelOffset.y):void 0},mxGeometry:p}},Rn=e=>{let{id:t,parentId:o,position:n,measured:r,data:i}=e;return{_attributes:{id:t,parent:o||"1",value:i.label,vertex:"1"},mxGeometry:{_attributes:{as:"geometry",width:(r==null?void 0:r.width)||0,height:(r==null?void 0:r.height)||0,x:n.x||0,y:n.y||0}}}},th=e=>{let{variant:t}=e.data,o=Rn(e);return w(b({},o),{_attributes:w(b({},o._attributes),{style:Ed[t]||"task"})})},oh=e=>{let t=Rn(e);return w(b({},t),{_attributes:w(b({},t._attributes),{style:"start-event"})})},nh=e=>{let t=Rn(e);return w(b({},t),{_attributes:w(b({},t._attributes),{style:"end-event-terminate"})})},rh=e=>{let{variant:t}=e.data,o=Rn(e);return w(b({},o),{_attributes:w(b({},o._attributes),{style:bd[t]})})},ih=e=>{let t=Rn(e);return w(b({},t),{_attributes:w(b({},t._attributes),{style:"lane"})})},sh=e=>{let t=Rn(e);return w(b({},t),{_attributes:w(b({},t._attributes),{style:"annotation"})})},vd={TASK:th,START_EVENT:oh,END_EVENT:nh,GATEWAY:rh,ANNOTATION:sh,LANE:ih},wd=(e,t)=>{var a,s;let r=((a=e.measured)==null?void 0:a.width)||0,i=((s=e.measured)==null?void 0:s.height)||0;return{_attributes:{id:`${t+1}`,parent:e.id,style:"attribute-loop",connectable:"0"},mxGeometry:{_attributes:{as:"geometry",x:r/2-22/2,y:i-22,width:22,height:22}}}};var Xs=nf(require("@dagrejs/dagre"),1),Fi=require("@xyflow/react");var Ad=(e=[],t=[],o="LR")=>{let n=new Xs.default.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:i,width:a,height:s})=>n.setNode(i,{width:a,height:s})),t.forEach(i=>n.setEdge(i.source,i.target)),Xs.default.layout(n),{nodes:e.map(i=>{let a=n.node(i.id);return w(b({},i),{position:{x:a.x-i.width/2,y:a.y-i.height/2}})}),edges:t}},lo=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId);if(t.length===0)return e;let o=La(e);for(let n of t){let r=[...o.values()],i=r.filter(s=>s.parentId===n.id);if(i.length===0)continue;let a=i.filter(s=>s.type==="LANE");if(a.length>0){Ha(a,o,r),Ga(n,o);continue}Es(n,i,o)}return ka(e,o)},Cd=lo,Sd=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)};var ah=e=>e.type==="LANE"&&!e.parentId,lh=(e,t)=>{let o=e.x+e.width,n=e.y+e.height,r=t.x+t.width,i=t.y+t.height;return e.x<=t.x&&e.y<=t.y&&o>=r&&n>=i},Id=e=>e.width*e.height,Us=e=>{var m;let t=e.filter(ah);if(t.length===0)return e;let o=new Map;for(let u of e){if(!u.parentId)continue;let g=(m=o.get(u.parentId))!=null?m:[];g.push(u.id),o.set(u.parentId,g)}let n=new Set,r=t.map(u=>u.id);for(;r.length>0;){let u=r.pop();if(!u||n.has(u))continue;n.add(u);let g=o.get(u);if(g)for(let E of g)n.has(E)||r.push(E)}let i=e.filter(u=>n.has(u.id));if(i.length===0)return e;let a=(0,Fi.getNodesBounds)(i),l=e.filter(u=>!n.has(u.id)).filter(u=>{let g=(0,Fi.getNodesBounds)([u]);return!lh(a,g)});if(l.length===0)return i;let c=Id(a),d=l.reduce((u,g)=>u+Id((0,Fi.getNodesBounds)([g])),0);return l.some(u=>u.type!=="ANNOTATION")||l.length>1||d>=c*.05?e:i};var gr=1,Md=e=>`<mxGraphModel>
|
|
7
7
|
<root version="1.1">
|
|
8
8
|
<mxCell id="0" />
|
|
9
9
|
<mxCell id="1" parent="0" />
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
<mxGeometry as="geometry" relative="1" />
|
|
37
37
|
</mxCell>
|
|
38
38
|
</root>
|
|
39
|
-
</mxGraphModel>`,Sd=(e,t)=>{if(!e.length&&!t.length)return fr;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var sh=e=>{let t=Object.values(pr),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=bd[a],l=s==null?void 0:s(i,n);if(!l){console.warn(`Node ${a} not supported`);continue}r.push(l)}return r},ah=(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=_d(r),a=t.find(c=>c.id===i.source),s=t.find(c=>c.id===i.target);((a==null?void 0:a.type)==="LANE"||(s==null?void 0:s.type)==="LANE")&&i.type!=="ANNOTATION_EDGE"||n.push(i)}return n},lh=(e,t)=>{let o=[];return e.forEach(n=>{var a,s;let r=(s=(a=Td)[n.type])==null?void 0:s.call(a,n);if(!r){console.warn(`Node ${n.type} not supported`);return}if(o.push(r),n.type==="TASK"&&n.data.attribute==="LOOP"){let l=vd(n,t);o.push(l)}}),o},ch=(e,t)=>{let o=[];return e.forEach(n=>{let r=Nd(n,t);o.push(r)}),o},dh=(e=[],t=[],o)=>{let n=lh(e,o),r=ch(t,e);return{mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}}},Md=(e=[],t=[],o)=>{let n=dh(e,t,o);return md(JSON.stringify(n),{compact:!0,spaces:0})},Pd=async e=>{var c,d,u,m,p;let t=await Yi(e),o=((d=(c=t==null?void 0:t.mxGraphModel)==null?void 0:c.root)==null?void 0:d.mxCell)||[],n=Number(((p=(m=(u=t==null?void 0:t.mxGraphModel)==null?void 0:u.root)==null?void 0:m._attributes)==null?void 0:p.lastId)||fr),r=sh(o),i=ah(o,r),a=Id(r),{nodes:s,edges:l}=Da(a,i);return{lastElementId:n,edges:l,nodes:Do(s)}};var ht=require("@xyflow/react"),Ki=require("react");var mr=require("@xyflow/react");var Xs=require("react/jsx-runtime"),te=i=>{var a=i,{type:e,position:t,className:o,nodeType:n}=a,r=Yt(a,["type","position","className","nodeType"]);let s=n==="TASK";return(0,Xs.jsx)(mr.Handle,N({type:e,position:t,className:H("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":s,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":!s},o)},r))},et=s=>{var l=s,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,a=Yt(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=(0,mr.useReactFlow)(),m=(()=>{if(n!=="source")return!1;let p=c();if(t==="TASK")return p.filter(x=>x.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return p.filter(x=>x.source===e).length>=2;if(t==="START_EVENT"){let g=d();return p.filter(f=>{if(f.source!==e)return!1;let h=g.find(_=>_.id===f.target);return(h==null?void 0:h.type)!=="ANNOTATION"}).length>=1}return!1})();return(0,Xs.jsx)(mr.Handle,N({type:n,position:r,className:H("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":m,"hover:border-grey-500":!m},i),style:{pointerEvents:m?"none":"auto"}},a))};var Us=require("react"),co=require("@xyflow/react");var Ld=require("@xyflow/react"),Wi=()=>{let e=(0,Ld.useStoreApi)();return{getInternalNodes:()=>{let{nodeLookup:o}=e.getState();return Array.from(o.values())}}};var Fi=require("react/jsx-runtime"),$s=require("react"),uh=["top","right","bottom","left"],ph=["top-left","top-middle","top-right","right-middle","bottom-left","left-middle","bottom-right","bottom-middle"],Mt=r=>{var i=r,{nodeId:e,isVisible:t,offset:o=8}=i,n=Yt(i,["nodeId","isVisible","offset"]);let{getInternalNode:a,setNodes:s}=(0,co.useReactFlow)(),{getInternalNodes:l}=Wi(),{isMultipleSelection:c}=q(),d=(0,co.useStoreApi)(),u=(0,Us.useRef)(0),m=(0,Us.useRef)([]),p=({y:h,width:_,height:b})=>{cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{var $,Z;if(!e)return;let{nodeLookup:T,onNodesChange:E}=d.getState(),y=T.get(e);if(!y||y.type!=="LANE")return;let w=!y.parentId,C=w?y.id:y.parentId;if(!C)return;let A=Array.from(T.values()).filter(Y=>Y.type==="LANE"&&Y.parentId===C);if(!A.length)return;m.current.length===0&&(m.current=Ho(A).map(Y=>Y.id));let R=m.current.map(Y=>A.find(S=>S.id===Y)).filter(Boolean),G=[],M=0,P=R.findIndex(Y=>Y.id===y.id),X=!w&&P>0&&Math.abs(h-y.position.y)>.5;for(let Y=0;Y<R.length;Y++){let S=R[Y],V=S.id===y.id,D=Y===R.length-1;if(V){M=X?h+b:M+b;continue}let I=(Z=($=S.measured)==null?void 0:$.height)!=null?Z:0,z=w?_-ie.HEADER_WIDTH:_,L=I;w&&D&&(L=Math.max(ie.MIN_HEIGHT,b-M)),X&&Y===P-1&&(L=Math.max(ie.MIN_HEIGHT,h-M)),G.push({id:S.id,type:"dimensions",dimensions:{width:z,height:L},setAttributes:!0}),G.push({id:S.id,type:"position",position:{x:ie.HEADER_WIDTH,y:M}}),M+=L}w?G.push({id:C,type:"dimensions",dimensions:{width:_,height:b},setAttributes:!0}):G.push({id:C,type:"dimensions",dimensions:{width:_+ie.HEADER_WIDTH,height:M},setAttributes:!0}),E==null||E(G)})},g=({y:h,width:_,height:b})=>{var y;if(cancelAnimationFrame(u.current),m.current=[],!e)return;let T=a(e);if(!T||T.type!=="LANE"&&!T.parentId)return;let E=[...l()];if(T.type!=="LANE"){E=E.map(w=>w.id===e?v(N({},w),{width:_,height:b,measured:{width:_,height:b}}):w),E=lo(E),s(E);return}E=Ga(T,_,b,E,h),E=lo(E),E=Vo((y=T.parentId)!=null?y:T.id,E),s(E)};if(!(!c&&t))return null;let f={"--resize-offset":`${o}px`};return(0,Fi.jsxs)(Fi.Fragment,{children:[uh.map(h=>(0,$s.createElement)(co.NodeResizeControl,v(N({},n),{key:h,nodeId:e,position:h,variant:co.ResizeControlVariant.Line,className:"border-blue-400/90 border-dashed",style:f,onResize:(_,b)=>p(b),onResizeEnd:(_,b)=>g(b)}))),ph.map(h=>(0,$s.createElement)(co.NodeResizeControl,v(N({},n),{key:h,nodeId:e,position:h,className:"size-1.5 bg-blue-400 relative before:content-[''] before:absolute before:w-5 before:h-5 before:left-1/2 before:top-1/2 before:-translate-x-1/2 before:-translate-y-1/2 before:cursor-[inherit]",style:f,onResize:(_,b)=>p(b),onResizeEnd:(_,b)=>g(b)})))]})};var $i=require("@xyflow/react"),Zt=require("@produto-lecom/lecom-ui"),gt=require("react");var kd=require("zustand"),kn=(0,kd.create)(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));var Xi=require("react"),Rd=(e,t=!1)=>{let[o,n]=(0,Xi.useState)({width:0,height:0});return(0,Xi.useEffect)(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};var wo=require("@xyflow/react"),Dd=require("react"),fh=120,mh=12,Od=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=(0,wo.useReactFlow)(),{instanceId:i}=q();return(0,Dd.useMemo)(()=>{var p,g;if(!t)return{position:wo.Position.Right,align:"start"};let a=n(e);if(!a)return{position:wo.Position.Right,align:"start"};let s=r(),l=a.position.x*s.zoom+s.x,c=(((p=a.measured)==null?void 0:p.width)||a.width||100)*s.zoom,d=(g=document.getElementById(`modeler-${i}`))==null?void 0:g.clientWidth;if(!d)return{position:wo.Position.Right,align:"start"};let u=(o==null?void 0:o.width)||fh;return{position:l+c+u+mh>d?wo.Position.Left:wo.Position.Right}},[i,e,t,o,n,r])};var Ui=require("@xyflow/react"),be=require("@produto-lecom/lecom-ui"),Vd=require("lucide-react");var Se=require("react/jsx-runtime"),Hd=({nodeId:e})=>{let{t}=(0,be.useTranslation)(),{updateNodeData:o,getEdges:n,getNode:r}=(0,Ui.useReactFlow)(),i=(0,Ui.useNodesData)(e),s=n().filter(p=>p.source===e).some(p=>{let g=r(p.target);return(g==null?void 0:g.type)==="END_EVENT"}),l=(i==null?void 0:i.data.variant)==="SUBPROCESS",c=u=>{o(e,{variant:(i==null?void 0:i.data.variant)===u?"":u})},d=u=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===u?"":u})};return(0,Se.jsxs)(be.DropdownMenu,{children:[(0,Se.jsxs)(be.Tooltip,{children:[(0,Se.jsx)(be.TooltipTrigger,{asChild:!0,children:(0,Se.jsx)(be.DropdownMenuTrigger,{asChild:!0,children:(0,Se.jsx)(be.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:(0,Se.jsx)(Vd.WrenchIcon,{})})})}),(0,Se.jsx)(be.TooltipContent,{color:"black",children:t("bpmn.task.menu.title")})]}),(0,Se.jsxs)(be.DropdownMenuContent,{align:"start",className:"w-60 bg-white text-grey-600",children:[(0,Se.jsxs)(be.DropdownMenuLabel,{className:"flex items-center gap-1",children:[(0,Se.jsx)("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),(0,Se.jsx)("div",{className:"flex items-center gap-1",children:Object.entries(zr).map(([u,m])=>{let p=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");if(u==="LOOP")return t("editor.task_menu.loop")})();return(0,Se.jsxs)(be.Tooltip,{children:[(0,Se.jsx)(be.TooltipTrigger,{asChild:!0,children:(0,Se.jsx)(be.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:p,className:H({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===u,"opacity-50 cursor-not-allowed":p}),onClick:p?void 0:()=>d(u),children:(0,Se.jsx)(m.icon,{className:"stroke-inherit"})})}),x&&(0,Se.jsx)(be.TooltipContent,{color:"black",children:x})]},u)})})]}),(0,Se.jsx)(be.DropdownMenuGroup,{children:(0,Se.jsxs)(be.Tooltip,{children:[(0,Se.jsx)(be.TooltipTrigger,{asChild:!0,children:(0,Se.jsx)("div",{className:H({"cursor-not-allowed":s}),children:(0,Se.jsxs)(be.DropdownMenuItem,{className:H({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":s}),disabled:s,onClick:()=>c("SCRIPT"),children:[(0,Se.jsx)(Br.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),s&&(0,Se.jsx)(be.TooltipContent,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};var ke=require("react/jsx-runtime"),qo={START_EVENT:{type:"START_EVENT",icon:Un,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:rn,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:Un,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:Or,label:"bpmn.annotation.variant.default"}},gh={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:ln,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:dn,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:sn,label:"bpmn.gateway.variant.complex"}},at=({nodeId:e,nodeType:t,nodeVariant:o})=>{let n=(0,gt.useRef)(null),r=(0,gt.useRef)(null),{t:i}=(0,Zt.useTranslation)(),{setDraggableNode:a}=kn(),{getEdges:s,getNodes:l,getNode:c}=(0,$i.useReactFlow)(),{setIsDragging:d,mode:u,isConnecting:m,isDragging:p,isMultipleSelection:g}=q(),x=c(e),f=!!(x!=null&&x.selected)&&!x.dragging&&!m&&!p&&!g,{dimensions:h}=Rd(n,f),{position:_}=Od(e,f,h),[b,T]=(0,gt.useState)(void 0),E=l(),y=s(),w=o==="SUBPROCESS",C=(0,gt.useRef)(null),A=(0,gt.useRef)(!1),R=(0,gt.useCallback)(()=>{C.current!==null&&(clearTimeout(C.current),C.current=null),A.current=!1,d(!1),a(null),T(void 0)},[d,a]);(0,gt.useEffect)(()=>{let L=k=>{A.current&&k.buttons===0&&R()};return document.addEventListener("dragend",R),document.addEventListener("mousemove",L),()=>{document.removeEventListener("dragend",R),document.removeEventListener("mousemove",L)}},[R]);let G=(0,gt.useCallback)((L,k)=>{A.current=!0,d(!1),a({type:k.type,variant:k.variant,attribute:k.attribute,icon:k.icon}),k.icon&&T((0,ke.jsx)(k.icon,{})),L.dataTransfer.effectAllowed="move",L.dataTransfer.setData("sourceId",e),r.current&&L.dataTransfer.setDragImage(r.current,10,10),C.current=setTimeout(()=>{C.current=null,d(!0)},100)},[e,a,d]),M=(0,gt.useCallback)(()=>{R()},[R]),P=[{component:(0,ke.jsx)(Pi,{elementId:e})}],X=()=>{if(u==="view")return[];let L=!y.some(k=>{var O;return k.source===e&&((O=E.find(B=>B.id===k.target))==null?void 0:O.type)!=="ANNOTATION"});return[{component:(0,ke.jsx)(vn,{nodeId:e,disabled:!L,tooltipMessage:L?void 0:i("editor.toolbar.start_event_limit_reached")})},qo.TASK,qo.ANNOTATION,...P]},$=()=>u==="view"?[{component:(0,ke.jsx)(To,{elementId:e})}]:[{component:(0,ke.jsx)(To,{elementId:e})},...w?[]:[{component:(0,ke.jsx)(Hd,{nodeId:e})}],{component:(0,ke.jsx)(vn,{nodeId:e})},qo.TASK,...Object.values(gh),...P],Z=()=>u==="view"?[{component:(0,ke.jsx)(To,{elementId:e})}]:[{component:(0,ke.jsx)(To,{elementId:e})},{component:(0,ke.jsx)(vn,{nodeId:e})},qo.TASK,qo.ANNOTATION,...P],Y=()=>u==="view"?[]:[qo.ANNOTATION,...P],S=()=>u==="view"?[]:[{component:(0,ke.jsx)(vn,{nodeId:e})},qo.ANNOTATION,...P],V=()=>u==="view"?[]:[{component:(0,ke.jsx)(vn,{nodeId:e})},...P],D=()=>u==="view"?[]:[...P],z=(L=>{switch(L){case"START_EVENT":return X();case"TASK":return $();case"GATEWAY":return Z();case"END_EVENT":return Y();case"LANE":return S();case"ANNOTATION":return V();case"UNSUPPORTED":return D();default:return[]}})(t);if(!(z.length===0||u==="readonly"))return(0,ke.jsxs)($i.NodeToolbar,{position:_,align:"start",className:"-top-8",isVisible:f,children:[(0,ke.jsx)("div",{ref:n,className:"flex items-center gap-1 px-3 py-2 bg-white rounded-sm shadow-md",children:z.map((L,k)=>{if(L.component)return(0,ke.jsx)("div",{children:L.component},k);let O={sourceNodeType:t,targetNodeType:L.type,sourceNodeId:e,nodes:E,edges:y},B=Uc(O),ee={gateway_limit_reached:i("editor.toolbar.gateway_limit_reached"),start_event_limit_reached:i("editor.toolbar.start_event_limit_reached"),start_event_already_exists:i("editor.toolbar.start_event_already_exists"),script_to_end_not_allowed:i("editor.toolbar.script_to_end_not_allowed"),loop_to_end_not_allowed:i("editor.toolbar.loop_to_end_not_allowed"),initial_activity_to_end_not_allowed:i("editor.toolbar.initial_activity_to_end_not_allowed"),final_activity_cannot_connect:i("editor.toolbar.final_activity_cannot_connect"),activity_has_outgoing_connections:i("editor.toolbar.activity_has_outgoing_connections"),task_limit_reached:i("editor.toolbar.task_limit_reached")},oe=B.shouldDisable&&B.reason?ee[B.reason]||i(L.label):i(L.label)||"";return(0,ke.jsxs)(Zt.Tooltip,{children:[(0,ke.jsx)(Zt.TooltipTrigger,{asChild:!0,children:(0,ke.jsx)(Zt.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!B.shouldDisable,disabled:B.shouldDisable,className:B.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:B.shouldDisable?void 0:K=>G(K,L),onDragEnd:B.shouldDisable?void 0:M,children:L.icon&&(0,ke.jsx)(L.icon,{size:16})})}),(0,ke.jsx)(Zt.TooltipContent,{color:"black",children:oe})]},k)})}),(0,ke.jsx)("div",{ref:r,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:b})]})};var Ue=require("react/jsx-runtime"),Gd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r,setNodes:i}=(0,ht.useReactFlow)(),{inProgress:a,fromNode:s}=(0,ht.useConnection)(),{mode:l}=q(),c=a&&(s==null?void 0:s.id)!==e,d=(0,Ki.useCallback)(p=>{let _=p.split(`
|
|
40
|
-
`),b=_.reduce((w,C)=>Math.max(w,C.length),0),T=_.length,E=Math.max(yn.MIN_WIDTH,b*7+32),y=Math.max(yn.MIN_HEIGHT,T*20+24);i(w=>w.map(C=>C.id===e?v(N({},C),{width:E,height:y,style:v(N({},C.style),{width:E,height:y})}):C))},[e,i]),u=(0,Ki.useCallback)(p=>{r(e,{label:p}),d(p)},[e,r,d]),m=(0,Ki.useCallback)(p=>{d(p)},[d]);return(0,Ue.jsxs)("div",{className:H("relative w-full h-full min-w-44 min-h-16 flex text-grey-400 hover:text-grey-500 bg-white rounded-sm border-l-2 border-current before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-current after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-current hover:shadow-md transition-colors duration-75",{"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:[(0,Ue.jsx)(Ze,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:u,onInput:m,skipFirstCharValidation:!0}),(0,Ue.jsx)(at,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&(0,Ue.jsx)(Mt,{nodeId:e,minWidth:yn.MIN_WIDTH,minHeight:yn.MIN_HEIGHT,isVisible:!n&&o}),!a&&(0,Ue.jsxs)(Ue.Fragment,{children:[(0,Ue.jsx)(te,{type:"source",position:ht.Position.Left,id:"left"}),(0,Ue.jsx)(te,{type:"source",position:ht.Position.Right,id:"right"}),(0,Ue.jsx)(te,{type:"source",position:ht.Position.Top,id:"top"}),(0,Ue.jsx)(te,{type:"source",position:ht.Position.Bottom,id:"bottom"})]}),(!a||c)&&(0,Ue.jsxs)(Ue.Fragment,{children:[(0,Ue.jsx)(te,{type:"target",position:ht.Position.Left,id:"left",className:H({"annotation-handle":c})}),(0,Ue.jsx)(te,{type:"target",position:ht.Position.Right,id:"right",className:H({"annotation-handle":c})}),(0,Ue.jsx)(te,{type:"target",position:ht.Position.Top,id:"top",className:H({"annotation-handle":c})}),(0,Ue.jsx)(te,{type:"target",position:ht.Position.Bottom,id:"bottom",className:H({"annotation-handle":c})})]})]})};var yt=require("@xyflow/react"),Bd=require("react");var Be=require("react/jsx-runtime"),zd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=(0,yt.useReactFlow)(),{inProgress:i,fromNode:a}=(0,yt.useConnection)(),{mode:s,reconnectingEdgeId:l}=q(),[c,d]=(0,Bd.useState)(!1),u=i&&(a==null?void 0:a.id)!==e||!!l,m=x=>{r(e,{label:x})},p=()=>{d(!0)},g=()=>{d(!1)};return(0,Be.jsxs)("div",{className:"relative",onDoubleClick:p,children:[(0,Be.jsx)(rn,{className:H("w-full h-full min-w-9 min-h-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})}),(0,Be.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,Be.jsx)(Ze,{value:t.label,isEditing:c,onBlur:g,onChange:m})}),(0,Be.jsx)(at,{nodeId:e,nodeType:"END_EVENT"}),s==="edit"&&(0,Be.jsx)(Mt,{nodeId:e,isVisible:!n&&o,minWidth:Fr.MIN_WIDTH,minHeight:Fr.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||u)&&(0,Be.jsxs)(Be.Fragment,{children:[(0,Be.jsx)(te,{type:"target",position:yt.Position.Left,id:"left",className:H({"event-handle":u})}),(0,Be.jsx)(te,{type:"target",position:yt.Position.Right,id:"right",className:H({"event-handle":u})}),(0,Be.jsx)(te,{type:"target",position:yt.Position.Top,id:"top",className:H({"event-handle":u})}),(0,Be.jsx)(te,{type:"target",position:yt.Position.Bottom,id:"bottom",className:H({"event-handle":u})})]}),!i&&(0,Be.jsxs)(Be.Fragment,{children:[(0,Be.jsx)(te,{type:"source",position:yt.Position.Left,id:"left"}),(0,Be.jsx)(te,{type:"source",position:yt.Position.Right,id:"right"}),(0,Be.jsx)(te,{type:"source",position:yt.Position.Top,id:"top"}),(0,Be.jsx)(te,{type:"source",position:yt.Position.Bottom,id:"bottom"})]})]})};var xt=require("@xyflow/react"),qi=require("react");var ze=require("react/jsx-runtime"),Yd=({id:e,data:t,selected:o,dragging:n})=>{let r=gs[t.variant].icon,{updateNodeData:i}=(0,xt.useReactFlow)(),{inProgress:a,fromNode:s}=(0,xt.useConnection)(),{mode:l,reconnectingEdgeId:c}=q(),[d,u]=(0,qi.useState)(!1),m=a&&(s==null?void 0:s.id)!==e||!!c,p=(0,qi.useCallback)(f=>{i(e,{label:f})},[e,i]),g=()=>{u(!0)},x=()=>{u(!1)};return(0,ze.jsxs)("div",{className:"relative",onDoubleClick:g,children:[(0,ze.jsx)(r,{className:H("w-full h-full min-w-14 min-h-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"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})}),(0,ze.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,ze.jsx)(Ze,{value:t.label,isEditing:d,onBlur:x,onChange:p})}),(0,ze.jsx)(at,{nodeId:e,nodeType:"GATEWAY"}),l==="edit"&&(0,ze.jsx)(Mt,{nodeId:e,isVisible:!n&&o,minWidth:Xr.MIN_WIDTH,minHeight:Xr.MIN_HEIGHT,offset:2,keepAspectRatio:!0}),(!a||m)&&(0,ze.jsxs)(ze.Fragment,{children:[(0,ze.jsx)(te,{type:"target",position:xt.Position.Left,id:"left",className:H({"gateway-handle":m})}),(0,ze.jsx)(te,{type:"target",position:xt.Position.Right,id:"right",className:H({"gateway-handle":m})}),(0,ze.jsx)(te,{type:"target",position:xt.Position.Top,id:"top",className:H({"gateway-handle":m})}),(0,ze.jsx)(te,{type:"target",position:xt.Position.Bottom,id:"bottom",className:H({"gateway-handle":m})})]}),!a&&(0,ze.jsxs)(ze.Fragment,{children:[(0,ze.jsx)(et,{type:"source",position:xt.Position.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,ze.jsx)(et,{type:"source",position:xt.Position.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,ze.jsx)(et,{type:"source",position:xt.Position.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,ze.jsx)(et,{type:"source",position:xt.Position.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})};var Wd=require("@xyflow/react"),Vt=require("@produto-lecom/lecom-ui"),hh=require("lucide-react");var Fd=require("react/jsx-runtime");var Et=require("@xyflow/react"),Xd=require("react");var Ye=require("react/jsx-runtime"),Ud=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=(0,Et.useReactFlow)(),{inProgress:i,fromNode:a}=(0,Et.useConnection)(),{mode:s,reconnectingEdgeId:l}=q(),[c,d]=(0,Xd.useState)(!1),u=i&&(a==null?void 0:a.id)!==e||!!l,m=x=>{r(e,{label:x})},p=()=>{d(!0)},g=()=>{d(!1)};return(0,Ye.jsxs)("div",{className:"relative",onDoubleClick:p,children:[(0,Ye.jsx)(Gr,{className:H("w-full h-full min-w-9 min-h-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})}),(0,Ye.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,Ye.jsx)(Ze,{value:t.label,isEditing:c,onBlur:g,onChange:m})}),(0,Ye.jsx)(at,{nodeId:e,nodeType:"START_EVENT"}),s==="edit"&&(0,Ye.jsx)(Mt,{nodeId:e,isVisible:!n&&o,minWidth:Wr.MIN_WIDTH,minHeight:Wr.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||u)&&(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsx)(te,{type:"target",position:Et.Position.Left,id:"left",className:H({"event-handle":u})}),(0,Ye.jsx)(te,{type:"target",position:Et.Position.Right,id:"right",className:H({"event-handle":u})}),(0,Ye.jsx)(te,{type:"target",position:Et.Position.Top,id:"top",className:H({"event-handle":u})}),(0,Ye.jsx)(te,{type:"target",position:Et.Position.Bottom,id:"bottom",className:H({"event-handle":u})})]}),!i&&(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsx)(et,{type:"source",position:Et.Position.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),(0,Ye.jsx)(et,{type:"source",position:Et.Position.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),(0,Ye.jsx)(et,{type:"source",position:Et.Position.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),(0,Ye.jsx)(et,{type:"source",position:Et.Position.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};var Zd=require("@produto-lecom/lecom-ui"),bt=require("@xyflow/react"),xr=require("react");var gr=60,Zi=(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<=gr?i:i.substring(0,gr).trim()},Rn=(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>gr&&(n=n.substring(0,gr).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=gr-l.length,u=`${r.substring(0,c).trim()}${l}`;if(!o.has(u))return u;i++}return n};var hr=require("react/jsx-runtime"),$d=e=>(0,hr.jsxs)("svg",v(N({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[(0,hr.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),(0,hr.jsx)("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));var Ks=require("react/jsx-runtime"),Kd=e=>(0,Ks.jsx)("svg",v(N({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:(0,Ks.jsx)("path",{d:"M12 2C8.13 2 5 5.13 5 9C5 14.25 12 22 12 22C12 22 19 14.25 19 9C19 5.13 15.87 2 12 2ZM12 11.5C10.62 11.5 9.5 10.38 9.5 9C9.5 7.62 10.62 6.5 12 6.5C13.38 6.5 14.5 7.62 14.5 9C14.5 10.38 13.38 11.5 12 11.5Z",fill:"#38bdf8"})}));var yr=require("react/jsx-runtime"),qd=e=>(0,yr.jsxs)("svg",v(N({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[(0,yr.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),(0,yr.jsx)("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));var ge=require("react/jsx-runtime"),yh={APROVADO:$d,EM_ANDAMENTO:Kd,REJEITADO:qd},qs={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)]"},Jd=({id:e,data:t,selected:o,dragging:n})=>{let{t:r}=(0,Zd.useTranslation)(),{toast:i}=st(),{updateNodeData:a,getNodes:s,setNodes:l}=(0,bt.useReactFlow)(),{inProgress:c,fromNode:d}=(0,bt.useConnection)(),{mode:u,onSubprocessValidationClick:m,reconnectingEdgeId:p}=q(),{getTaskStatus:g}=Go(),x=c&&(d==null?void 0:d.id)!==e||!!p,f=g(e),h=t.variant==="SUBPROCESS",_=!!t.variant&&!h||!!f,b=!!t.attribute||h,T=(0,xr.useCallback)(P=>{let Y=_||b?80:40,S=P.split(`
|
|
41
|
-
`),V=S.reduce((L,k)=>Math.max(L,k.length),0),D=S.length,I=Math.max(hn.MIN_WIDTH,V*7+64),z=Math.max(hn.MIN_HEIGHT,D*24+Y);l(L=>L.map(k=>k.id===e?v(N({},k),{width:I,height:z,style:v(N({},k.style),{width:I,height:z})}):k))},[e,l,_,b]),E=(0,xr.useCallback)(P=>{let X=P.trim(),$=t.label||"";if(X===$)return;let Z=X,Y=s();if(!(X&&X!=="")){Z=Zi(Y,r("bpmn.task.label.prefix")),a(e,{label:Z}),T(Z),i({variant:"warning",content:(0,ge.jsxs)(ge.Fragment,{children:[r("bpmn.task.feedback.label_empty.prefix")," ",(0,ge.jsx)("strong",{children:Z})]})});return}let V=Rn(Z,Y);V===$||(a(e,{label:V}),T(V),V!==Z&&i({variant:"warning",content:(0,ge.jsxs)(ge.Fragment,{children:[r("bpmn.task.feedback.label_already_exists.prefix")," ",(0,ge.jsx)("strong",{children:X})," ",r("bpmn.task.feedback.label_already_exists.middle")," ",(0,ge.jsx)("strong",{children:V})]})}))},[t.label,s,e,r,a,T,i]),y=(0,xr.useCallback)(P=>{T(P)},[T]),w=(0,xr.useCallback)(()=>{i({variant:"error",content:r("bpmn.task.feedback.invalid_first_character")})},[r,i]),C=f?yh[f]:null,A=t.variant?Br[t.variant].icon:null,R=t.attribute?zr[t.attribute].icon:null,G=()=>t.hasError?qs.error:f?qs[f]:qs.default,M=()=>{m==null||m({id:e,type:"sub_process",label:t.label})};return(0,ge.jsxs)("div",{className:H("relative w-full h-full min-w-44 min-h-24 flex flex-col items-stretch justify-stretch bg-white border-2 border-grey-400 hover:border-grey-500 rounded-md hover:shadow-md transition-colors duration-75",G(),{"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:[(0,ge.jsx)("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:(0,ge.jsx)(Ze,{value:t.label,maxLength:60,className:H({"py-10 px-8":_||b}),onChange:E,onInput:y,onInvalidFirstCharacter:w})}),A&&(0,ge.jsx)("div",{className:H("absolute flex items-center p-1",h?"bottom-0 left-1/2 -translate-x-1/2":"top-0 left-0"),children:(0,ge.jsx)(A,{size:16,className:H(t.hasError?"text-red-500":"text-grey-500",h&&"cursor-pointer"),onClick:h?M:void 0})}),R&&(0,ge.jsx)("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:(0,ge.jsx)("div",{className:H("flex items-center w-16 p-1",h?"justify-between":"justify-center"),children:(0,ge.jsx)(R,{size:16,className:H(t.hasError?"text-red-500":"text-grey-500")})})}),C&&(0,ge.jsx)("div",{className:"absolute top-0 right-0 flex items-center p-1",children:(0,ge.jsx)(C,{})}),(0,ge.jsx)(at,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),u==="edit"&&(0,ge.jsx)(Mt,{nodeId:e,isVisible:!n&&o,minWidth:hn.MIN_WIDTH,minHeight:hn.MIN_HEIGHT}),(!c||x)&&(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsx)(te,{type:"target",position:bt.Position.Left,id:"left",className:H({"task-handle":x})}),(0,ge.jsx)(te,{type:"target",position:bt.Position.Right,id:"right",className:H({"task-handle":x})}),(0,ge.jsx)(te,{type:"target",position:bt.Position.Top,id:"top",className:H({"task-handle":x})}),(0,ge.jsx)(te,{type:"target",position:bt.Position.Bottom,id:"bottom",className:H({"task-handle":x})})]}),!c&&(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsx)(et,{type:"source",position:bt.Position.Left,id:"left",nodeId:e,nodeType:"TASK"}),(0,ge.jsx)(et,{type:"source",position:bt.Position.Right,id:"right",nodeId:e,nodeType:"TASK"}),(0,ge.jsx)(et,{type:"source",position:bt.Position.Top,id:"top",nodeId:e,nodeType:"TASK"}),(0,ge.jsx)(et,{type:"source",position:bt.Position.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})};var Zs=require("@xyflow/react");var uo=require("react/jsx-runtime"),Qd=({id:e,data:t})=>(0,uo.jsxs)(uo.Fragment,{children:[(0,uo.jsx)("div",{className:"relative w-full h-full min-w-32 min-h-16 flex items-center justify-center bg-white border-2 border-red-400 rounded-sm overflow-hidden",children:t.label}),(0,uo.jsx)(at,{nodeId:e,nodeType:"UNSUPPORTED"}),(0,uo.jsx)(te,{type:"source",position:Zs.Position.Right}),(0,uo.jsx)(te,{type:"target",position:Zs.Position.Left})]});var Oe=require("@xyflow/react"),Ji=require("react");var ve=require("react/jsx-runtime"),Q2={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:Oe.MarkerType.Arrow},data:{label:""}},jd=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var L;let{zoom:c}=(0,Oe.useViewport)(),{updateEdgeData:d}=(0,Oe.useReactFlow)(),{isMultipleSelection:u,mode:m,instanceId:p}=q(),g=m!=="edit",[x,f]=(0,Ji.useState)(!1),{reconnectingHandle:h,cursorPosition:_,hoveredNodeId:b,reconnectingSide:T,isValidReconnection:E,handleReconnectStart:y}=Hi({edgeId:e,source:t,target:o,instanceId:p,isReadOnly:g}),w=(0,Oe.useInternalNode)(t),C=(0,Oe.useInternalNode)(o),{sx:A,sy:R,tx:G,ty:M,sourcePos:P,targetPos:X}=(0,Ji.useMemo)(()=>{var ne,le;if(!w||!C)return{sx:0,sy:0,tx:0,ty:0,sourcePos:Oe.Position.Left,targetPos:Oe.Position.Right};let k=gn(w,C),O=s?i:k.sourcePos,B=l?a:k.targetPos,ee=(U,Te,W)=>{var ue,Ne,We,Qe,ot,ct;let{x:j,y:ce}=U.internals.positionAbsolute,re=(We=(Ne=(ue=U.measured)==null?void 0:ue.width)!=null?Ne:U.width)!=null?We:0,fe=(ct=(ot=(Qe=U.measured)==null?void 0:Qe.height)!=null?ot:U.height)!=null?ct:0;switch(Te){case Oe.Position.Top:return{x:j+re*W,y:ce};case Oe.Position.Bottom:return{x:j+re*W,y:ce+fe};case Oe.Position.Left:return{x:j,y:ce+fe*W};case Oe.Position.Right:return{x:j+re,y:ce+fe*W};default:return{x:j+re/2,y:ce+fe/2}}},oe=(ne=n==null?void 0:n.sourceOffset)!=null?ne:.5,K=(le=n==null?void 0:n.targetOffset)!=null?le:.5,J=w?ee(w,O,oe).x:k.sx,Q=w?ee(w,O,oe).y:k.sy,ae=C?ee(C,B,K).x:k.tx,F=C?ee(C,B,K).y:k.ty;return h==="source"&&_?(J=_.x,Q=_.y,T&&(O=T)):h==="target"&&_&&(ae=_.x,F=_.y,T&&(B=T)),{sx:J,sy:Q,tx:ae,ty:F,sourcePos:O,targetPos:B}},[w,C,s,l,i,a,h,_,T,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!w||!C)return null;let[$,Z,Y]=(0,Oe.getSmoothStepPath)({sourceX:A,sourceY:R,targetX:G,targetY:M,sourcePosition:P,targetPosition:X}),S=r||(w==null?void 0:w.selected)||(C==null?void 0:C.selected),V=S?"sequence-edge-marker-highlighted":"sequence-edge-marker",D=x||(n==null?void 0:n.label.trim().length)>0,I=()=>{f(!1)},z=k=>{d(e,{label:k.trim()})};return(0,ve.jsx)(ve.Fragment,{children:(0,ve.jsxs)("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":S}),onDoubleClick:()=>!g&&f(!0),children:[(0,ve.jsx)("path",{d:$,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),(0,ve.jsxs)("g",{className:H("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":S}),children:[(0,ve.jsx)(Oe.BaseEdge,{id:e,path:$,interactionWidth:0,markerEnd:`url(#${V})`,strokeDasharray:4,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||h&&b&&!E,"stroke-green-500":h&&b&&E,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":S&&!(n!=null&&n.hasError)&&!h})}),(0,ve.jsxs)(Oe.EdgeLabelRenderer,{children:[(0,ve.jsxs)("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${Z}px, ${Y}px)`},children:[r&&!u&&(0,ve.jsx)(An,{sx:A,sy:R,tx:G,ty:M,hasLabel:!!((L=n==null?void 0:n.label)!=null&&L.trim()),children:(0,ve.jsx)(In,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),D&&(0,ve.jsx)(Ze,{value:n==null?void 0:n.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:x,onBlur:I,onChange:z})]}),r&&!u&&!g&&(0,ve.jsxs)(ve.Fragment,{children:[(0,ve.jsx)("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${A}px, ${R}px)`},children:(0,ve.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,ve.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:h==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ve.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:h==="source"?.6:.3,className:"pointer-events-none"}),(0,ve.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!h||h!=="source","cursor-not-allowed":h==="source"&&b&&!E,"cursor-grabbing":h==="source"&&(!b||E)}),onMouseDown:k=>y("source",k.nativeEvent)})]})}),(0,ve.jsx)("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${G}px, ${M}px)`},children:(0,ve.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,ve.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:h==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ve.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:h==="target"?.6:.3,className:"pointer-events-none"}),(0,ve.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!h||h!=="target","cursor-not-allowed":h==="target"&&b&&!E,"cursor-grabbing":h==="target"&&(!b||E)}),onMouseDown:k=>y("target",k.nativeEvent)})]})})]})]})]})]})})};var Zo=require("@xyflow/react"),Er=require("react/jsx-runtime"),eu=({toX:e,toY:t,fromNode:o})=>{var u,m;if(!o)return null;let{internals:{positionAbsolute:{x:n,y:r}},measured:i}=o,a=(u=i.width)!=null?u:0,s=(m=i.height)!=null?m:0,c=[{x:n,y:r+s/2,pos:Zo.Position.Left},{x:n+a,y:r+s/2,pos:Zo.Position.Right},{x:n+a/2,y:r,pos:Zo.Position.Top},{x:n+a/2,y:r+s,pos:Zo.Position.Bottom}].reduce((p,g)=>{let x=Math.hypot(e-p.x,t-p.y);return Math.hypot(e-g.x,t-g.y)<x?g:p}),[d]=(0,Zo.getStraightPath)({sourceX:c.x,sourceY:c.y,targetX:e,targetY:t});return(0,Er.jsxs)("g",{className:"group",children:[(0,Er.jsx)("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d}),(0,Er.jsx)("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})};var _t=require("@xyflow/react"),tu=require("lodash"),br=require("react");var Me=require("react/jsx-runtime"),ou=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{let{updateNodeData:i,getNodes:a}=(0,_t.useReactFlow)(),{mode:s}=q(),{inProgress:l,fromNode:c}=(0,_t.useConnection)(),d=l&&(c==null?void 0:c.id)!==e,[u,m]=(0,br.useState)(!1),p=a(),g=!r,x=(0,br.useMemo)(()=>(0,tu.orderBy)([...p.filter(E=>E.parentId===e&&E.type==="LANE")],"position.y","asc"),[p,e]),f=g?Sa.MIN_WIDTH:ie.MIN_WIDTH,h=(0,br.useMemo)(()=>{if(g&&x.length>1){let E=[...x];return E.pop(),E.reduce((w,C)=>{var A,R;return w+((R=(A=C.measured)==null?void 0:A.height)!=null?R:0)},0)+ie.MIN_HEIGHT}return ie.MIN_HEIGHT},[g,x]),_=E=>{i(e,{label:E})},b=()=>{m(!0)},T=()=>{m(!1)};return(0,Me.jsxs)(Me.Fragment,{children:[(0,Me.jsxs)("div",{className:H("flex h-full min-h-64 w-full min-w-[50rem] hover:shadow-md bg-white outline outline-1 outline-grey-300",{"outline-offset-2 outline-blue-500 shadow-sm":o}),children:[(0,Me.jsx)("div",{className:"flex align-items justify-center w-10 border-r border-grey-300",onDoubleClick:b,children:(0,Me.jsx)("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:(0,Me.jsx)(Ze,{value:t.label,className:"w-full h-full self-auto",contentClassName:H({"whitespace-nowrap":u}),isEditing:u,onBlur:T,onChange:_})})}),(0,Me.jsx)("div",{className:"flex-1"})]}),(0,Me.jsx)(at,{nodeId:e,nodeType:"LANE",isChild:!g}),s==="edit"&&(0,Me.jsx)(Mt,{nodeId:e,isVisible:!n&&o,minWidth:f,minHeight:h,offset:10}),!l&&(0,Me.jsxs)(Me.Fragment,{children:[(0,Me.jsx)(te,{type:"source",position:_t.Position.Left,id:"left"}),(0,Me.jsx)(te,{type:"source",position:_t.Position.Right,id:"right"}),(0,Me.jsx)(te,{type:"source",position:_t.Position.Top,id:"top"}),(0,Me.jsx)(te,{type:"source",position:_t.Position.Bottom,id:"bottom"})]}),(!l||d)&&(0,Me.jsxs)(Me.Fragment,{children:[(0,Me.jsx)(te,{type:"target",position:_t.Position.Left,id:"left",className:H({"annotation-handle":d})}),(0,Me.jsx)(te,{type:"target",position:_t.Position.Right,id:"right",className:H({"annotation-handle":d})}),(0,Me.jsx)(te,{type:"target",position:_t.Position.Top,id:"top",className:H({"annotation-handle":d})}),(0,Me.jsx)(te,{type:"target",position:_t.Position.Bottom,id:"bottom",className:H({"annotation-handle":d})})]})]})};var nu={START_EVENT:Ud,END_EVENT:zd,TASK:Jd,GATEWAY:Yd,ANNOTATION:Gd,LANE:ou,UNSUPPORTED:Qd},ru={SEQUENCE_EDGE:ud,MESSAGE_EDGE:jd,ANNOTATION_EDGE:od},iu="#fafafa",su="#bebebe",au=1,lu=10,cu="bottom-left",Js=.05,du=5,Dn=.5,On=Js,Vn=1,uu={x:0,y:0,zoom:.75},pu=1,fu=2,xh={[pu]:4,[fu]:2},_r=[pu,fu],Qs=_r.reduce((e,t)=>e|xh[t],0);var mu=require("@xyflow/react");var Pt=()=>{let{getEdges:e,getNodes:t}=(0,mu.useReactFlow)(),{lastElementId:o}=q(),n=()=>{let i=t(),a=e(),s=Sd(i,a);return Math.max(s,o)};return{getLastId:n,getNextId:()=>n()+1}};var Gn=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n,setViewport:r}=(0,Hn.useReactFlow)(),{getLastId:i}=Pt(),a=(0,Hn.useStoreApi)(),{setLastElementId:s}=q(),l=(0,js.useCallback)(async(d="")=>{let{nodes:u,edges:m,lastElementId:p}=await Pd(d),{width:g,height:x}=a.getState();if(g>0&&x>0){let f=Oa(u);f&&r((0,Hn.getViewportForBounds)(f,g,x,On,Vn,Dn))}o(u),n(m),s(p)},[o,n,s,a,r]),c=(0,js.useCallback)(()=>{let d=e(),u=t(),m=i();return Md(d,u,m)},[e,t,i]);return{importFromMxGraph:l,exportToMxGraph:c}};var ea=require("react"),Eh=500,Qi=()=>{let{isInitialized:e,onElementChanges:t}=q(),{exportToMxGraph:o}=Gn(),n=(0,gu.useDebouncedCallback)(()=>{if(!e)return;let a=o();t==null||t(a)},Eh),r=(0,ea.useCallback)(a=>{a.every(c=>c.type==="select")||a.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=(0,ea.useCallback)(a=>{a.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var hu=({setEdges:e,saveHistory:t})=>{let{getNode:o,getEdges:n,getNodes:r,getInternalNode:i}=(0,ji.useReactFlow)(),{emitElementChanges:a}=Qi(),s=(0,Jt.useRef)(null),{getNextId:l}=Pt(),c=(0,Jt.useCallback)(f=>{var E;let h=o(f.source),_=o(f.target);if(!h||!_)return!1;let b={sourceNodeId:h.id,targetNodeId:_.id,sourceNodeType:h.type,targetNodeType:_.type,nodes:r(),edges:n(),reconnectingEdgeId:(E=s.current)!=null?E:void 0};return Os(b).isValid},[o,n,r]),d=(0,Jt.useCallback)(f=>{var b,T;let h=l(),_=i(f.source);if(_){let E=i(f.target),y=E?E.internals.positionAbsolute.x+((b=E.measured.width)!=null?b:0)/2:0,w=E?E.internals.positionAbsolute.y+((T=E.measured.height)!=null?T:0)/2:0,C=pd(_,y,w),A=(E==null?void 0:E.type)==="ANNOTATION"||(_==null?void 0:_.type)==="ANNOTATION",R=A?Cn:St,G;if(!A&&E&&f.targetHandle){let X=Bi(C),$=Bi(f.targetHandle),{x:Z,y:Y}=Bs(_,C),{x:S,y:V}=Bs(E,f.targetHandle),I=Oi(Z,Y,S,V,X,$).slice(1,-1);I.length>0&&(G=I)}let M=v(N(N({},f),R),{id:String(h),sourceHandle:C,data:N(N({},A?{}:St.data),G?{points:G}:{})}),P=n().concat(M);e(P),t("forceSave",{nodes:r(),edges:P}),a()}},[l,e,a,i,n,r,t]),u=(0,Jt.useCallback)((f,h)=>{s.current=h.id},[]),m=(0,Jt.useCallback)(()=>{s.current=null},[]),p=(0,Jt.useCallback)((f,h)=>{let _=o(h.source),b=o(h.target);if(!_||!b){s.current=null;return}let T={sourceNodeId:_.id,targetNodeId:b.id,sourceNodeType:_.type,targetNodeType:b.type,nodes:r(),edges:n(),reconnectingEdgeId:f.id};if(!Os(T).isValid){s.current=null;return}let y=(0,ji.reconnectEdge)(f,h,n()).map(w=>w.id===f.id?v(N({},w),{data:v(N({},w.data),{points:void 0})}):w);e(y),t("forceSave",{nodes:r(),edges:y}),s.current=null,a()},[o,r,n,e,a,t]),g=(0,Jt.useCallback)(f=>{s.current=f},[]),x=(0,Jt.useCallback)(()=>{s.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:p,onReconnectStart:u,onReconnectEnd:m,setReconnectingEdge:g,clearReconnectingEdge:x}};var wu=require("@produto-lecom/lecom-ui"),Iu=require("@xyflow/react"),Ht=require("react");var Nr=(e=[])=>e.filter(t=>t.type==="START_EVENT"),Jo=(e=[])=>e.filter(t=>t.type==="END_EVENT"),Io=(e=[])=>e.filter(t=>t.type==="TASK")||[],yu=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"});var es=(e=[])=>e.filter(t=>t.type==="GATEWAY"),xu=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),Nt=(e,t=[])=>t.filter(o=>o.source===e),Tr=(e,t=[])=>t.filter(o=>o.target===e),Eu=(e,t)=>{var n,r;let o=(n=t.nodes)==null?void 0:n.find(i=>i.id===e);return((r=o==null?void 0:o.properties)==null?void 0:r.attribute)==="LOOP"},bu=(e,t)=>{let o=Nt(e,t.edges||[]);for(let n of o){let r=(t.nodes||[]).find(i=>i.id===n.target);if(r&&r.type==="END_EVENT")return!0}return!1},_u=e=>e?/[^\s]/.test(e.trim()):!1,we=e=>{let{isValid:t,nodeIds:o,edgeIds:n}=e;return{isValid:t,nodeIds:!t&&o&&o.length>0?o:[],edgeIds:!t&&n&&n.length>0?n:[]}},po=(e=[],t)=>{if(!e||e.length===0)return{isValid:!0,invalidIds:[]};let o=e.filter(n=>!t(n));return{isValid:o.length===0,invalidIds:o.map(n=>n.id)}},Nu=(e=[],t=[])=>({nodes:e.map(o=>{var n;return{id:o.id,type:o.type||"",label:typeof((n=o.data)==null?void 0:n.label)=="string"?o.data.label:void 0,properties:o.data}}),edges:t.map(o=>({id:o.id,source:o.source,target:o.target,type:o.type||"default"}))});var vr=[{id:"start_event_not_found",validate:e=>{let t=Nr(e.nodes);return we({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=Jo(e.nodes);return we({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Nr(e.nodes),o=t.length===1;if(t.length===0)return we({isValid:!0});if(!o)return we({isValid:!1,nodeIds:t.map(i=>i.id)});let n=Nt(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(a=>a.id),...n.map(a=>a.target)];return we({isValid:!1,nodeIds:[...new Set(i)]})}return we({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=Io(e.nodes),o=po(t,n=>Nt(n.id,e.edges).length<=2);return we({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=Io(e.nodes),o=po(t,n=>!!n.label&&n.label.trim()!=="");return we({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=Io(e.nodes),n=po(o,r=>!r.label||r.label.length<=60);return we({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=Io(e.nodes),o=new Map;for(let r of t){if(!r.label)continue;let i=r.label.trim();i&&(o.has(i)||o.set(i,[]),o.get(i).push(r))}let n=[];for(let[,r]of o.entries())r.length>1&&r.forEach(i=>n.push(i.id));return we({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=es(e.nodes),o=[],n=[];for(let r of t){let i=Nt(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="GATEWAY"&&(o.push(r.id,s.id),n.push(a.id))}}return we({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Nr(e.nodes),...Jo(e.nodes)],o=[],n=[];for(let r of t){let i=Nt(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&(s.type==="START_EVENT"||s.type==="END_EVENT")&&(o.push(r.id,s.id),n.push(a.id))}}return we({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=Jo(e.nodes),o=[],n=[];for(let r of t){let i=Tr(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=Nt(s.id,e.edges);l.length>1&&(o.push(s.id),l.forEach(c=>n.push(c.id)))}}}return we({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=xu(e.nodes),o=po(t,r=>Nt(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>Nt(r,e.edges).map(i=>i.id));return we({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=Io(e.nodes),o=po(t,n=>!n.label||_u(n.label));return we({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var a,s;if(!((a=e==null?void 0:e.nodes)!=null&&a.length)||!((s=e==null?void 0:e.edges)!=null&&s.length))return we({isValid:!0});let t=Jo(e.nodes)[0];if(!t)return we({isValid:!0});let o=Tr(t.id,e.edges);if(!o.length)return we({isValid:!0});let r=Io(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=po(r,l=>!Eu(l.id,e));return we({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=Io(e.nodes),o=Jo(e.nodes)[0];if(!o)return we({isValid:!0});let n=t.filter(l=>{let c=Tr(l.id,e.edges),d=Nt(l.id,e.edges),u=c.some(p=>{var g;return((g=e.nodes.find(x=>x.id===p.source))==null?void 0:g.type)==="START_EVENT"}),m=d.some(p=>{var g;return((g=e.nodes.find(x=>x.id===p.target))==null?void 0:g.type)==="END_EVENT"});return u&&m}),r=Tr(o.id,e.edges),i=r.length>1,a=r.map(l=>l.source),s={isValid:n.length===0&&!i,nodeIds:[...n.map(l=>l.id),...i?a:[]]};return we(s)}},{id:"gateway_flow_to_event",validate:e=>{let t=es(e.nodes),o=[],n=[];for(let r of t){let i=Nt(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="END_EVENT"&&(o.push(r.id,s.id),n.push(a.id))}}return we({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=es(e.nodes),o=po(t,n=>Nt(n.id,e.edges).length>=1);return we({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Nr(e.nodes),...Jo(e.nodes)],o=[],n=[];for(let r of t){let i=Nt(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="GATEWAY"&&(o.push(r.id,s.id),n.push(a.id))}}return we({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=yu(e.nodes),o=po(t,n=>!bu(n.id,e));return we({isValid:o.isValid,nodeIds:o.invalidIds})}}];var Tu=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of vr){let r=n.validate(e);r.isValid||t.push({id:n.id,message:n.id,nodeIds:r.nodeIds||[],edgeIds:r.edgeIds||[]})}return{isValid:t.length===0,errors:t}},vu=async(e,t)=>{var n;let o=[];try{let r=await e(),i=(n=r==null?void 0:r.filter(a=>a.area==="DIAGRAM"))!=null?n:[];return i.length===0?{isValid:!0,errors:[]}:(i.forEach(a=>{var l,c;let s=(c=(l=a==null?void 0:a.detail)==null?void 0:l.phases)==null?void 0:c.map(d=>d.diagramCellId);o.push({id:a.code,message:a.code,nodeIds:s,edgeIds:[]})}),{isValid:!1,errors:o})}catch(r){return{isValid:!1,errors:[{id:"cannot_validate_subprocess_reference",message:"cannot_validate_subprocess_reference",nodeIds:t.map(i=>i.id)||[],edgeIds:[]}]}}};var Qo=require("react/jsx-runtime"),Au=()=>{let{t:e}=(0,wu.useTranslation)(),{toast:t}=st(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=(0,Iu.useReactFlow)(),{validateCustomDiagram:a}=q(),[s,l]=(0,Ht.useState)(!1),c=(0,Ht.useRef)(!1),d=(0,Ht.useRef)(!1),u=(0,Ht.useCallback)(async f=>{let h=Nu(f.nodes,f.edges),_=Tu(h),b=f.nodes.filter(({type:E,data:y})=>E==="TASK"&&(y==null?void 0:y.variant)==="SUBPROCESS");if(a&&b.length>0){let E=await vu(a,b);_={isValid:_.isValid&&E.isValid,errors:[..._.errors,...E.errors]}}let T=_.errors.map(E=>v(N({},E),{message:e(`validation.errors.${E.id}`)}));return s||l(!0),{isValid:_.isValid,errors:T}},[s,e,a]),m=(0,Ht.useCallback)((f,h=!0)=>{if(h&&f&&t({variant:f.isValid?"success":"error",duration:5e3,title:f.isValid?e("validation.success.title"):e("validation.errors.title"),content:(0,Qo.jsxs)("div",{className:"flex flex-col gap-1",children:[!f.isValid&&(0,Qo.jsx)("span",{className:"body-small-500",children:e("validation.errors.subtitle")}),(0,Qo.jsx)("ul",{className:"list-disc list-inside max-h-40 overflow-y-auto",children:f.isValid?(0,Qo.jsx)("li",{children:e("validation.success.message")}):f.errors.map(M=>(0,Qo.jsx)("li",{className:"text-xs",children:M.message},M.id))})]})}),!f)return;c.current=!0,d.current=!0;let _=[],b=[];f.errors.forEach(M=>{M.nodeIds&&M.nodeIds.length>0&&M.nodeIds.forEach(P=>_.push(P)),M.edgeIds&&M.edgeIds.length>0&&M.edgeIds.forEach(P=>b.push(P))});let T=[...new Set(_)];o(M=>M.map(P=>v(N({},P),{data:v(N({},P.data),{hasError:!1})}))),n(M=>M.map(P=>v(N({},P),{data:v(N({},P.data),{hasError:!1})})));let E=r(),y=i(),w=new Set(T),C=new Set;f.errors.forEach(M=>{var $,Z;let P=vr.find(Y=>Y.id===M.id);(P==null?void 0:P.highlightRelatedEdges)!==!1&&(($=M.edgeIds)==null||$.forEach(Y=>C.add(Y)),(Z=M.nodeIds)==null||Z.forEach(Y=>{y.forEach(S=>{(S.source===Y||S.target===Y)&&C.add(S.id)})}))});let A=new Set,R=new Set,G=new Set;E.forEach(M=>{M.type==="START_EVENT"?A.add(M.id):M.type==="END_EVENT"&&R.add(M.id)}),y.forEach(M=>{A.has(M.source)&&G.add(M.target),R.has(M.target)&&G.add(M.source)}),G.forEach(M=>{var P,X;if(w.has(M)){let $=(P=f.errors.find(Y=>{var S;return(S=Y.nodeIds)==null?void 0:S.includes(M)}))==null?void 0:P.id;((X=vr.find(Y=>Y.id===$))==null?void 0:X.highlightRelatedEdges)!==!1&&y.forEach(Y=>{Y.source===M&&R.has(Y.target)&&(w.add(Y.target),C.add(Y.id)),Y.target===M&&A.has(Y.source)&&(w.add(Y.source),C.add(Y.id))})}}),w.size>0&&o(M=>M.map(P=>v(N({},P),{data:v(N({},P.data),{hasError:w.has(P.id)})}))),C.size>0&&n(M=>M.map(P=>v(N({},P),{data:v(N({},P.data),{hasError:C.has(P.id)})}))),setTimeout(()=>{c.current=!1},0)},[e,i,r,n,o,t]),p=(0,Ht.useCallback)(()=>{l(!1),d.current=!1,o(f=>f.map(h=>v(N({},h),{data:v(N({},h.data),{hasError:!1})}))),n(f=>f.map(h=>v(N({},h),{data:v(N({},h.data),{hasError:!1})})))},[n,o]),g=(0,Ht.useCallback)(()=>{d.current&&(c.current=!0,d.current=!1,o(f=>f.map(h=>v(N({},h),{data:v(N({},h.data),{hasError:!1})}))),n(f=>f.map(h=>v(N({},h),{data:v(N({},h.data),{hasError:!1})}))),setTimeout(()=>{c.current=!1},0))},[n,o]),x=(0,Ht.useCallback)(()=>c.current,[]);return{validateDiagram:u,handleValidationComplete:m,clearValidation:p,dismissValidationPanel:g,isAutoValidationEnabled:s,getIsClearingValidation:x}};var Mu=require("@xyflow/react"),Pu=require("@produto-lecom/lecom-ui"),Lu=require("react");var bh=15,Cu="bpmn:selection",_h=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},Su=e=>{if(!_h(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},ku=({offset:e=bh,saveHistory:t})=>{let{t:o}=(0,Pu.useTranslation)(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=(0,Mu.useReactFlow)(),{getNextId:s}=Pt();(0,Lu.useEffect)(()=>{let l=d=>{var h,_;if(!Su(d))return;let u=n(),m=i(),p=u.filter(b=>b.selected);if(!p.length)return;d.preventDefault(),d.stopPropagation();let g=m.filter(b=>p.some(T=>T.id===b.source)&&p.some(T=>T.id===b.target)),f=JSON.stringify({nodes:p,edges:g});(h=d.clipboardData)==null||h.setData(Cu,f),(_=d.clipboardData)==null||_.setData("text/plain",`BPMN Selection: ${p.length} nodes`)},c=d=>{var w,C;if(!Su(d))return;let u=(w=d.clipboardData)==null?void 0:w.getData(Cu);if(!u)return;d.preventDefault(),d.stopPropagation();let m;try{m=JSON.parse(u)}catch(A){return}if(!((C=m.nodes)!=null&&C.length))return;let p=new Map,g=n(),x=[],f=m.nodes.filter(A=>_o(A.type,g));if(f.length===0)return;let h=s(),_=f.map(A=>{var M;let R=String(h++);p.set(A.id,R);let G=v(N({},A),{id:R,selected:!0,position:{x:A.position.x+e,y:A.position.y+e}});if(A.type==="TASK"){let P=(M=A.data)==null?void 0:M.label,X=Rn(P||o("bpmn.task.label.prefix"),[...g,...x]);G.data=v(N({},A.data),{label:X})}return x.push(G),G}),b=m.edges.map(A=>v(N({},A),{id:String(h++),selected:!0,source:p.get(A.source)||A.source,target:p.get(A.target)||A.target})),T=[...g.map(A=>v(N({},A),{selected:!1})),..._],y=[...i().map(A=>v(N({},A),{selected:!1})),...b];r(T),a(y),t("forceSave",{nodes:T,edges:y})};return document.addEventListener("copy",l,!0),document.addEventListener("paste",c,!0),()=>{document.removeEventListener("copy",l,!0),document.removeEventListener("paste",c,!0)}},[n,r,i,a,s,e,o,t])};var Ru=require("@produto-lecom/lecom-ui"),Du=require("@xyflow/react");var Ou=require("react");var Nh=50,Vu=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let{draggableNode:r,setDraggableNode:i}=kn(),{t:a}=(0,Ru.useTranslation)(),{getInternalNode:s,getNodes:l,getEdges:c,screenToFlowPosition:d}=(0,Du.useReactFlow)(),{getNextId:u}=Pt(),{setIsDragging:m}=q(),{getInternalNodes:p}=Wi(),{rebuildIndex:g,forceRebuildIndex:x}=vi(),[f,h]=(0,Ou.useState)(null),_=(S,V,D)=>{var k;if(S.parentId!==V)return null;let I=D.filter(O=>O.id!==S.id&&O.parentId===V&&O.type==="LANE").sort((O,B)=>O.position.y-B.position.y);if(I.length===0)return null;let z=(k=D.find(O=>O.id===S.id))!=null?k:S,L=I.find(O=>z.position.y<O.position.y);return L?{draggedLaneId:S.id,beforeLaneId:L.id}:{draggedLaneId:S.id,afterLaneId:I[I.length-1].id}},b=(S,V=!1,D)=>{let I=V?"node-drop-target-error":"node-drop-target",z=V?"node-drop-target-lane-error":"node-drop-target-lane";t(L=>{var O;let k=(O=D==null?void 0:D(L))!=null?O:null;return L.map(B=>{let ee=[];return B.id===S&&ee.push(I),S!==void 0&&B.parentId===S&&B.type==="LANE"&&B.id!==(k==null?void 0:k.draggedLaneId)&&ee.push(z),B.id===(k==null?void 0:k.draggedLaneId)&&ee.push("lane-reorder-dragging"),B.id===(k==null?void 0:k.beforeLaneId)&&ee.push("lane-reorder-before"),B.id===(k==null?void 0:k.afterLaneId)&&ee.push("lane-reorder-after"),v(N({},B),{className:ee.join(" ")})})})},T=(S,V)=>{let D=p();if(S.type==="LANE"){if(V){b();return}let O=D.filter(oe=>oe.id!==S.id&&oe.type==="LANE"&&!oe.parentId),B=$n(S,O);if(!B){b();return}if(Oo({parentId:B.id,nodes:e,excludeTypes:["LANE"]})){b(B.id,!0);return}b(B.id,!1,oe=>_(S,B.id,oe));return}let z=D.filter(O=>O.id!==S.id&&O.type==="LANE"),L=$n(S,z);if(!L){b();return}if(Oo({parentId:L.id,nodes:e,includeTypes:["LANE"]})){b();return}b(L.id)},E=S=>{let V=s(S.id),D=S.type==="LANE"&&Oo({parentId:S.id,nodes:e,includeTypes:["LANE"]});T(V,D)},y=S=>S.map(V=>v(N({},V),{className:void 0})),w=S=>S.some(D=>D.dragging)?S.map(D=>D.dragging?v(N({},D),{dragging:!1}):D):S,C=(S,V)=>{let D=0;for(let I of V){if(I.id===S||I.parentId||I.type==="LANE")continue;let z=It(I),L=z.y+z.h;D=Math.max(D,L)}return D+Nh},A=(S,V)=>{if(!hs(S,V))return V;let D=C(S,V);return V.map(I=>I.id===S?v(N({},I),{position:v(N({},I.position),{y:D})}):I)},R=S=>{if(S.preventDefault(),S.dataTransfer.dropEffect="move",!(r!=null&&r.type))return;let V=d({x:S.clientX,y:S.clientY}),D={id:"__sidebar_drag__",type:r.type,position:V,measured:{width:1,height:1},internals:{positionAbsolute:V}};T(D,!1)},G=S=>{let V=S.relatedTarget;(!V||!S.currentTarget.contains(V))&&b()},M=(S,V)=>{S.preventDefault(),E(V)},P=(S,V,D)=>{var ee,oe;let I=[...D],z=V.parentId?V.parentId:V.id;if(S.parentId===V.id)return I=xs(S,V,I),I=lo(I),I=Vo(z,I),y(I);if(S.type==="LANE"){if(Oo({parentId:V.id,nodes:I,excludeTypes:["LANE"]})){let F=_i(V),ne=50,le=50;return I.map(U=>{var Te,W;return U.id===S.id?v(N({},U),{position:{x:(Te=f==null?void 0:f.x)!=null?Te:F.x+ne,y:(W=f==null?void 0:f.y)!=null?W:F.y2+le}}):U})}let Q=I.filter(F=>F.parentId===V.id).reduce((F,ne)=>{var le,U;return F+((U=(le=ne.measured)==null?void 0:le.height)!=null?U:0)},0),ae={x:ie.HEADER_WIDTH,y:Q};return I=I.map(F=>F.id===S.id?v(N({},F),{parentId:V.id,position:ae,className:void 0}):v(N({},F),{className:void 0})),I=lo(I),I=A(z,I),I}if(Oo({parentId:V.id,nodes:I,includeTypes:["LANE"]})){let K;if(S.parentId){let J=s(S.parentId),{x:Q,y:ae}=It(J);K={x:Q+((ee=S.position.x)!=null?ee:0),y:ae+((oe=S.position.y)!=null?oe:0)}}return I=I.map(J=>J.id===S.id?v(N({},J),{position:K!=null?K:J.position,parentId:void 0,className:void 0}):v(N({},J),{className:void 0})),I=Vo(z,I),I}let O=ka(S,V);I=I.map(K=>K.id===S.id?v(N({},K),{parentId:V.id,position:O,className:void 0}):v(N({},K),{className:void 0}));let B=I.find(K=>K.id===S.id);return I=xs(B,V,I),I=lo(I),I=Vo(z,I),I},X=S=>{if(S.preventDefault(),!(r!=null&&r.type))return;if(!_o(r.type,l())){m(!1),i(null);return}let V=d({x:S.clientX,y:S.clientY}),D={width:pe[r.type].MIN_WIDTH,height:pe[r.type].MIN_HEIGHT},I=u(),z={id:String(I),type:r.type,position:V,measured:D,data:{label:r.type==="TASK"?Zi(e,a("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},L=v(N({},z),{internals:{positionAbsolute:V}}),k=v(N({},L),{measured:{width:1,height:1}}),O=p(),B=r.type==="LANE",ee=O.filter(F=>B?F.type==="LANE"&&!F.parentId:F.type==="LANE"),oe=$n(k,ee),K=[...O.map(F=>v(N({},F),{selected:!1})),L];oe&&(K=P(L,oe,K)),K=Do(K),B&&!oe&&(K=A(L.id,K)),K=y(K),t(K),x();let J=S.dataTransfer.getData("sourceId"),Q=c(),ae=Q;if(J){let F={id:String(I+1),source:J,target:z.id},ne=r.type==="ANNOTATION"?N(N({},F),Cn):N(N({},F),St);ae=Q.concat(ne),o(ae)}n("forceSave",{nodes:K,edges:ae}),m(!1),i(null)},$=async(S,V,D)=>{let I=[...p()],z=new Set;D.forEach(O=>{let B=s(O.id),ee=O.type==="LANE",oe=I.filter(J=>J.id!==O.id&&(ee?J.type==="LANE"&&!J.parentId:J.type==="LANE")),K=$n(B,oe);if(K){if(ee&&Oo({parentId:O.id,nodes:I,includeTypes:["LANE"]})){O.parentId&&(I=Y(O,I),z.add(O.id));return}I=P(B,K,I);return}O.parentId&&(I=Y(O,I),O.type==="LANE"&&z.add(O.id))}),I=w(I);let L=D.filter(O=>O.type==="LANE"&&!O.parentId).map(O=>O.id);for(let O of L)hs(O,I)&&f&&(I=I.map(B=>B.id===O?v(N({},B),{position:N({},f)}):B));for(let O of z)I=A(O,I);if(D.some(O=>O.type!=="LANE"&&!O.parentId)){let O=I.filter(B=>B.type==="LANE"&&!B.parentId).map(B=>B.id);for(let B of O)I=Vo(B,I)}I=Do(I),I=y(I),t(I),g(I),h(null)},Z=(S,V)=>{h({x:V.position.x,y:V.position.y})},Y=(S,V)=>{var oe,K,J,Q,ae,F,ne,le;let D=s(S.parentId);if(!D)return V;let I=S.type==="LANE",z=V.filter(U=>U.parentId===D.id&&U.id!==S.id),L=z.filter(U=>U.type==="LANE"),k;if(I&&L.length===0)k=ie.MIN_HEIGHT;else if(I){let U=(K=(oe=S.measured)==null?void 0:oe.height)!=null?K:ie.MIN_HEIGHT;k=((Q=(J=D.measured)==null?void 0:J.height)!=null?Q:ie.MIN_HEIGHT)-U,k=Math.max(ie.MIN_HEIGHT,k)}else k=z.length>0?z.reduce((U,Te)=>{var W,j;return U+((j=(W=Te.measured)==null?void 0:W.height)!=null?j:0)},0)+De:Math.max(ie.MIN_HEIGHT,(F=(ae=D.measured)==null?void 0:ae.height)!=null?F:0);let{x:O,y:B}=It(D),ee={x:O+((ne=S.position.x)!=null?ne:0),y:B+((le=S.position.y)!=null?le:0)};return V=V.map(U=>U.id===S.id?v(N({},U),{position:ee,parentId:void 0}):U.id===D.id?v(N({},U),{height:k,measured:v(N({},U.measured),{height:k})}):U),V=lo(V),V};return{onDragOver:R,onDragLeave:G,onDrop:X,onNodeDrag:M,onNodeDragStart:Z,onNodeDragStop:$}};var Hu=require("@xyflow/react"),Gu=require("@produto-lecom/lecom-ui"),Bu=require("react");var Th=30,vh=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},wh=e=>!vh(e.target),zu=({offset:e=Th,saveHistory:t})=>{let{t:o}=(0,Gu.useTranslation)(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=(0,Hu.useReactFlow)(),{getNextId:s}=Pt();(0,Bu.useEffect)(()=>{let l=c=>{if(c.ctrlKey&&c.key.toLowerCase()==="d"&&wh(c)){c.preventDefault(),c.stopPropagation();let d=n(),u=i(),m=d.filter(y=>y.selected);if(!m.length)return;let p=new Map,g=[],x=m.filter(y=>_o(y.type,d));if(x.length===0)return;let f=u.filter(y=>x.some(w=>w.id===y.source)&&x.some(w=>w.id===y.target)),h=s(),_=x.map(y=>{var A;let w=String(h++);p.set(y.id,w);let C=v(N({},y),{id:w,selected:!0,position:{x:y.position.x+e,y:y.position.y+e}});if(y.type==="TASK"){let R=(A=y.data)==null?void 0:A.label,G=Rn(R||o("bpmn.task.label.prefix"),[...d,...g]);C.data=v(N({},y.data),{label:G})}return g.push(C),C}),b=f.map(y=>v(N({},y),{id:String(h++),selected:!0,source:p.get(y.source)||y.source,target:p.get(y.target)||y.target})),T=[...d.map(y=>v(N({},y),{selected:!1})),..._],E=[...u.map(y=>v(N({},y),{selected:!1})),...b];r(T),a(E),t("forceSave",{nodes:T,edges:E})}};return document.addEventListener("keydown",l,!0),()=>{document.removeEventListener("keydown",l,!0)}},[n,r,i,a,s,e,o,t])};var Ir=require("react"),Yu=require("@xyflow/react");var Ih=20,Ah=50,wr={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},Ch=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},Wu=e=>{let{getNodes:t}=(0,Yu.useReactFlow)(),{mode:o,isMoveTool:n}=q(),r=(0,Ir.useRef)(0),i=(0,Ir.useRef)(new Map);(0,Ir.useEffect)(()=>{let a=s=>{if(o!=="edit"||!n||Ch(s.target)||!Object.values(wr).includes(s.key))return;let u=t().filter(_=>_.selected);if(u.length===0){i.current.clear();return}s.preventDefault();let m=Date.now(),p=m-r.current<500;r.current=m;let g=s.shiftKey?Ah:Ih,x=0,f=0;switch(s.key){case wr.UP:f=-g;break;case wr.DOWN:f=g;break;case wr.LEFT:x=-g;break;case wr.RIGHT:x=g;break}let h=u.map(_=>{let b=i.current.get(_.id);(!p||!b)&&(b={x:_.position.x,y:_.position.y});let T={x:b.x+x,y:b.y+f};return i.current.set(_.id,T),{id:_.id,dragging:!0,type:"position",position:T}});e&&e(h)};return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[t,e,o,n])};var Ku=require("@xyflow/react");var Xu={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},Uu={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},Fu=(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}},Sh=e=>{e=e||"";let t=e.trim().split(`
|
|
42
|
-
`),o={},n=[];return t.forEach(r=>{r=r||"";let i=r.trim().split("-->");if(i.length!==2){console.warn("Invalid number of steps");return}let a=Fu(i[0],o),s=Fu(i[1],o);a&&s&&n.push({sourceId:a.step,targetId:s.step,label:a.edgeLabel||s.edgeLabel||""})}),{components:o,connections:n}},$u=e=>{let{components:t,connections:o}=Sh(e);return{nodes:t,edges:o}};var qu=()=>{let{setNodes:e,setEdges:t,fitView:o}=(0,Ku.useReactFlow)(),{getNextId:n}=Pt();return{importFromLia:i=>{let a=typeof i=="string"?i:i.diagramXml||"",{nodes:s,edges:l}=$u(a),c=[],d=new Map,u=!1,m=n();for(let[f,h]of Object.entries(s)){let _=String(m++),b=Xu[h.type],T=Uu[h.type];b==="START_EVENT"&&(u=!0),d.set(f,_);let E=pe[b].MIN_WIDTH,y=pe[b].MIN_HEIGHT;c.push({id:_,type:b,data:{label:h.label||"",variant:T,attribute:""},position:{x:0,y:0},width:E,height:y,measured:{width:E,height:y}})}let p=[];for(let f of l){let h=v(N({},St),{id:String(m++),source:d.get(f.sourceId)||f.sourceId,target:d.get(f.targetId)||f.targetId});p.push(h)}if(!u&&c.length>0){let f=String(m++),h={id:f,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:pe.START_EVENT.MIN_WIDTH,height:pe.START_EVENT.MIN_HEIGHT,measured:{width:pe.START_EVENT.MIN_WIDTH,height:pe.START_EVENT.MIN_HEIGHT}};c.unshift(h);let _=c[1];if(_){let b=v(N({},St),{id:String(m++),source:f,target:_.id});p.unshift(b)}}let{nodes:g,edges:x}=wd(c,p);e(g),t(x),o({padding:Dn,minZoom:On,maxZoom:Vn})}}};var ts=require("react"),Mh={origin:"*",debug:!1};function Zu(e,t=Mh){let{origin:o,debug:n}=t,r=(0,ts.useCallback)((i,a)=>{let s={event:i,data:[i,{event:i,data:a}]};window.parent.postMessage(s,o||"*")},[o]);return(0,ts.useEffect)(()=>{let i=a=>{let s=a.data;if(!(s!=null&&s.event)||(s==null?void 0:s.data)===void 0)return;let{event:l,data:c}=s,d;if(Array.isArray(c)){let[,u]=c;d=u.data}else d=c;n&&(console.debug("[postMessage] received:",s),console.debug("[postMessage] eventData:",d)),l&&e[l]&&e[l](d)};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[e,n]),{sendMessage:r}}var Ju=require("@xyflow/react"),ta=require("react");var Qu=()=>{let e=(0,Ju.useNodesInitialized)(),{initialDiagram:t,setIsInitialized:o}=q(),{importFromMxGraph:n}=Gn();(0,ta.useEffect)(()=>{t&&n(t)},[t,n,o]),(0,ta.useEffect)(()=>{if(!e)return;(async()=>{await Vr(),o(!0)})()},[e,o])};var oa=require("react"),ju=require("@xyflow/react");function ep(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=Go(),{getEdges:n}=(0,ju.useReactFlow)(),r=Ur(),i=(0,oa.useCallback)(s=>{if(!(s!=null&&s.activities))return;e(s.activities);let l=s.activities.map(d=>d.diagramId),c=n();o(c,l),setTimeout(()=>{r()},0)},[e,o,n,r]),a=(0,oa.useCallback)(()=>{t(),setTimeout(()=>{r()},0)},[t,r]);return{handleTasksStatus:i,handleClearTaskStatus:a}}var op=require("@xyflow/react"),tt=require("react"),np=require("use-debounce");var Ph=500,tp=100,rp=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=(0,op.useReactFlow)(),[i,a]=(0,tt.useState)({history:[],currentStep:0}),{history:s,currentStep:l}=i,c=l>0,d=l<s.length-1,u=(0,tt.useCallback)((E,y)=>{n(E[y].nodes),r(E[y].edges)},[n,r]),m=(0,tt.useCallback)(()=>{if(l>0){let E=l-1;a(y=>v(N({},y),{currentStep:E})),u(s,E)}},[l,s,u]),p=(0,tt.useCallback)(()=>{if(l<s.length-1){let E=l+1;a(y=>v(N({},y),{currentStep:E})),u(s,E)}},[s,l,u]),g=(0,tt.useCallback)(E=>{a(y=>{let w=y.history[y.currentStep];if(w&&JSON.stringify(w)===JSON.stringify(E))return y;let R=[...y.history.slice(0,y.currentStep+1),E],G=R.length>tp?R.slice(R.length-tp):R;return{history:G,currentStep:G.length-1}})},[]),x=(0,tt.useCallback)((E,y)=>{let w=E.map(A=>v(N({},A),{selected:!1,className:"",data:v(N({},A.data),{hasError:!1})})),C=y.map(A=>v(N({},A),{data:v(N({},A.data),{hasError:!1})}));return{nodes:Do(w),edges:C}},[]),f=(0,tt.useCallback)(()=>x(t(),o()),[t,o,x]),h=(0,np.useDebouncedCallback)(()=>{let E=f();g(E)},Ph),_=(0,tt.useCallback)((E,y)=>{if(!e)return;if(s.length===0){let A=f();a({history:[A],currentStep:0})}if(E==="forceSave"){if(y){g(x(y.nodes,y.edges));return}h();return}E.some(A=>A.type==="select")||E.some(A=>A.type==="position"&&A.dragging)||h()},[e,h,s.length,f,g,x]);(0,tt.useEffect)(()=>{if(e&&s.length===0){let E=f();a({history:[E],currentStep:0})}},[e,s.length,f]);let b=(0,tt.useCallback)(E=>{a({history:E||[],currentStep:0})},[]),T=(0,tt.useCallback)(()=>{a({history:[],currentStep:0})},[]);return(0,tt.useEffect)(()=>{let E=y=>{(y.ctrlKey||y.metaKey)&&(y.shiftKey&&y.key.toLowerCase()==="z"?(y.preventDefault(),p()):y.key.toLowerCase()==="z"&&(y.preventDefault(),m()))};return document.addEventListener("keydown",E),()=>{document.removeEventListener("keydown",E)}},[m,p]),{history:s,undo:m,redo:p,canUndo:c,canRedo:d,saveHistory:_,resetHistory:b,clearHistory:T}};var sp=()=>{let{t:e}=(0,ip.useTranslation)(),[t,o,n]=(0,Qt.useNodesState)([]),[r,i,a]=(0,Qt.useEdgesState)([]),{getNodes:s,getNode:l}=(0,Qt.useReactFlow)(),{toast:c}=st(),d=(0,Qt.useStoreApi)(),{instanceId:u,isInitialized:m,setIsConnecting:p,setIsMultipleSelection:g,onElementClick:x}=q(),{updateHelperLines:f,HelperLines:h}=vi(),{undo:_,redo:b,canUndo:T,canRedo:E,saveHistory:y}=rp(m),{onNodeDrag:w,onDrop:C,onDragOver:A,onDragLeave:R,onNodeDragStop:G,onNodeDragStart:M}=Vu({nodes:t,setNodes:o,setEdges:i,saveHistory:y}),{isValidConnection:P,onConnect:X,onReconnect:$,onReconnectStart:Z,onReconnectEnd:Y,setReconnectingEdge:S,clearReconnectingEdge:V}=hu({setEdges:i,saveHistory:y}),{handleValidationComplete:D,clearValidation:I,dismissValidationPanel:z,validateDiagram:L,getIsClearingValidation:k}=Au(),{importFromLia:O}=qu(),{handleTasksStatus:B,handleClearTaskStatus:ee}=ep(),{clearPathEdges:oe}=Go(),{emitElementChanges:K,handleNodeChanges:J,handleEdgeChanges:Q}=Qi(),ae=Ur();ku({saveHistory:y}),zu({saveHistory:y}),Qu();let F=(0,Lt.useCallback)(()=>{o([]),i([]),oe(),setTimeout(ae,0)},[o,i,oe,ae]);Zu({LIA_CREATE_DIAGRAM:O,CLEAR_DIAGRAM:F,TASKS_STATUS:B,CLEAR_TASKS_STATUS:ee});let{selectElements:ne,clearSelection:le}=No(),{importFromMxGraph:U,exportToMxGraph:Te}=Gn(),{configureElement:W,getConfigureElement:j}=Mi(),ce=(0,Lt.useCallback)(()=>t.length+r.length,[t,r]);(0,Lt.useEffect)(()=>(Kt.set(u,{importFromMxGraph:U,exportToMxGraph:Te,selectElements:ne,clearSelection:le,configureElement:W,getConfigureElement:j,getElementsCount:ce,setReconnectingEdge:S,clearReconnectingEdge:V}),()=>{Kt.delete(u)}),[u,U,Te,ne,le,W,j,ce,S,V]);let re=(0,Lt.useCallback)((Ae,Ee)=>{if(Ee.type!=="TASK"&&Ee.type!=="GATEWAY")return;let me=j(Ee.id);me&&(x==null||x(me))},[j,x]),fe=(0,Lt.useCallback)((Ae,Ee)=>{if(Ee.type!=="SEQUENCE_EDGE")return;let me=l(Ee.source),Pe=l(Ee.target),{isFromStartEvent:ut,isGatewayToGateway:vt,isActiviyToAndGateway:nt}=Yr(me,Pe);if(!(!ut&&!vt&&!nt))return;let zt=j(Ee.id);zt&&(x==null||x(zt))},[j,l,x]),ue=(0,Lt.useCallback)(Ae=>{let Ee=f(Ae,t);n(Ee),y(Ae),k()||z(),J(Ae)},[t,n,y,k,z,f,J]),Ne=(0,Lt.useCallback)(Ae=>{a(Ae),y(Ae),k()||z(),Q(Ae)},[a,y,k,z,Q]);Wu(ue);let We=(0,Lt.useCallback)(({nodes:Ae,edges:Ee})=>{g(Ae.length+Ee.length>=2)},[g]);(0,Qt.useOnSelectionChange)({onChange:We});let Qe=(0,Lt.useCallback)(async({nodes:Ae})=>Ae.some(me=>me.type==="LANE"&&t.some(Pe=>Pe.parentId===me.id))?(c({variant:"error",title:e("validation.errors.title"),content:e("editor.toolbar.delete_pool_lane_error")}),!1):!0,[t,e,c]),ot=()=>{y("forceSave"),K(),z()},ct=()=>{p(!0)},Bt=()=>{p(!1),z()},dt=(0,Lt.useCallback)(Ae=>{let Ee=new Set(Ae.filter(me=>me.type==="LANE"&&!!me.parentId).map(me=>me.parentId));Ee.size!==0&&setTimeout(()=>{var ut,vt;let me=s(),Pe=new Map(me.map(nt=>[nt.id,nt]));for(let nt of Ee){let oo=Ho(me.filter(no=>no.type==="LANE"&&no.parentId===nt));if(oo.length===0)continue;let zt=0;for(let no of oo)Pe.set(no.id,v(N({},no),{position:{x:ie.HEADER_WIDTH,y:zt}})),zt+=(vt=(ut=no.measured)==null?void 0:ut.height)!=null?vt:0;let nn=Pe.get(nt);nn&&Pe.set(nt,v(N({},nn),{height:zt,measured:v(N({},nn.measured),{height:zt})}))}o(me.map(nt=>{var oo;return(oo=Pe.get(nt.id))!=null?oo:nt}))},0)},[s,o]);return{nodes:t,setNodes:o,edges:r,setEdges:i,events:{isValidConnection:P,onConnect:X,onReconnect:$,onReconnectStart:Z,onReconnectEnd:Y,onDrop:C,onDragOver:A,onDragLeave:R,onNodeDrag:w,onNodeDragStop:G,onNodeDragStart:M,onNodeClick:re,onEdgeClick:fe,onDropCapture:ot,onConnectStart:ct,onConnectEnd:Bt,onSelectionEnd:()=>setTimeout(()=>d.setState({nodesSelectionActive:!1}),0),onNodesChange:ue,onEdgesChange:Ne,onBeforeDelete:Qe,onNodesDelete:dt},ui:{handleCloseValidationPanel:I},controls:{undo:_,redo:b,canUndo:T,canRedo:E},components:{HelperLines:h},actions:{saveHistory:y,selectElements:ne,clearSelection:le,exportToMxGraph:Te,validateDiagram:L,handleValidationComplete:D,setReconnectingEdge:S,clearReconnectingEdge:V}}};var ap=require("@xyflow/react"),Ao=require("react");var Lh=".react-flow__node, .react-flow__edge, .react-flow__node-toolbar";function lp(e,t,o){let[n,r]=(0,Ao.useState)(!1),i=(0,Ao.useRef)(null),{getViewport:a,setViewport:s}=(0,ap.useReactFlow)(),l=(0,Ao.useCallback)(()=>{i.current=null,r(!1)},[]);return(0,Ao.useEffect)(()=>{let c=e.current;if(!c)return;let d=p=>{if(!_r.some(x=>x===p.button)||t.current||o.current||(r(!0),!(p.target instanceof Element))||!p.target.closest(Lh))return;p.preventDefault(),p.stopPropagation();let g=a();i.current={pointerX:p.clientX,pointerY:p.clientY,viewportX:g.x,viewportY:g.y,zoom:g.zoom}},u=p=>{let g=i.current;if(g){if((p.buttons&Qs)===0){l();return}s({x:g.viewportX+(p.clientX-g.pointerX),y:g.viewportY+(p.clientY-g.pointerY),zoom:g.zoom})}},m=p=>{(p.buttons&Qs)===0&&l()};return c.addEventListener("pointerdown",d,!0),window.addEventListener("pointermove",u),window.addEventListener("pointerup",m),window.addEventListener("pointercancel",l),window.addEventListener("blur",l),()=>{c.removeEventListener("pointerdown",d,!0),window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",m),window.removeEventListener("pointercancel",l),window.removeEventListener("blur",l)}},[e,t,o,a,s,l]),n}var na=require("react/jsx-runtime"),os=({id:e,className:t})=>(0,na.jsx)("marker",{id:e,className:H("react-flow__arrowhead",t),viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"7",markerHeight:"7",orient:"auto",markerUnits:"userSpaceOnUse",fill:"currentColor",stroke:"currentColor",children:(0,na.jsx)("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});var jo=require("react/jsx-runtime"),cp=()=>(0,jo.jsx)("svg",{style:{position:"absolute",top:0,left:0},children:(0,jo.jsxs)("defs",{children:[(0,jo.jsx)(os,{id:"sequence-edge-marker",className:"text-grey-500"}),(0,jo.jsx)(os,{id:"sequence-edge-marker-hovered",className:"text-grey-800"}),(0,jo.jsx)(os,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});var Po=require("@produto-lecom/lecom-ui");var Sr=require("@xyflow/react"),Ve=require("@produto-lecom/lecom-ui"),jt=require("lucide-react"),fo=require("react");var Co=require("@produto-lecom/lecom-ui");var Ar=(b=>(b.START_EVENT="START_EVENT",b.END_EVENT="END_EVENT",b.TASK="TASK",b.SUBPROCESS="SUBPROCESS",b.GATEWAY="GATEWAY",b.LANE="LANE",b.ANNOTATION="ANNOTATION",b.CONNECTION="CONNECTION",b.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",b.ACTIVITY="ACTIVITY",b.PROCESS_INTERFACE="PROCESS_INTERFACE",b.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",b.VARIANT_ACTIVITY="VARIANT_ACTIVITY",b.AUTO_ACTIVITY="AUTO_ACTIVITY",b.DATA_STORE="DATA_STORE",b.DATA_OBJECT="DATA_OBJECT",b.DATA_OUTPUT="DATA_OUTPUT",b.DATA_INPUT="DATA_INPUT",b.MARKER="MARKER",b))(Ar||{});var rs=require("@produto-lecom/lecom-ui"),bp=require("@xyflow/react");var dp=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 up({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let r="data:text/csv;charset=utf-8,"+[e,...t].map(a=>a.join(",")).join(`
|
|
43
|
-
`),i=encodeURI(r);
|
|
39
|
+
</mxGraphModel>`,Pd=(e,t)=>{if(!e.length&&!t.length)return gr;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var ch=e=>{let t=Object.values(mr),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=_d[a],l=s==null?void 0:s(i,n);if(!l){console.warn(`Node ${a} not supported`);continue}r.push(l)}return r},dh=(e,t)=>{let o=e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}),n=[];for(let r of o){let i=Nd(r),a=t.find(c=>c.id===i.source),s=t.find(c=>c.id===i.target);((a==null?void 0:a.type)==="LANE"||(s==null?void 0:s.type)==="LANE")&&i.type!=="ANNOTATION_EDGE"||n.push(i)}return n},uh=(e,t)=>{let o=[];return e.forEach(n=>{var a,s;let r=(s=(a=vd)[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=wd(n,t);o.push(l)}}),o},ph=(e,t)=>{let o=[];return e.forEach(n=>{let r=Td(n,t);o.push(r)}),o},fh=(e=[],t=[],o)=>{let n=uh(e,o),r=ph(t,e);return{mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}}},Ld=(e=[],t=[],o)=>{let n=fh(e,t,o);return gd(JSON.stringify(n),{compact:!0,spaces:0})},kd=async e=>{var c,d,p,m,u;let t=await Wi(e),o=((d=(c=t==null?void 0:t.mxGraphModel)==null?void 0:c.root)==null?void 0:d.mxCell)||[],n=Number(((u=(m=(p=t==null?void 0:t.mxGraphModel)==null?void 0:p.root)==null?void 0:m._attributes)==null?void 0:u.lastId)||gr),r=ch(o),i=dh(o,r),a=Cd(r),{nodes:s,edges:l}=Oa(a,i);return{lastElementId:n,edges:l,nodes:Ho(s)}};var ht=require("@xyflow/react"),Zi=require("react");var hr=require("@xyflow/react");var $s=require("react/jsx-runtime"),oe=i=>{var a=i,{type:e,position:t,className:o,nodeType:n}=a,r=Yt(a,["type","position","className","nodeType"]);let s=n==="TASK";return(0,$s.jsx)(hr.Handle,b({type:e,position:t,className:H("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":s,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":!s},o)},r))},et=s=>{var l=s,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,a=Yt(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=(0,hr.useReactFlow)(),m=(()=>{if(n!=="source")return!1;let u=c();if(t==="TASK")return u.filter(E=>E.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return u.filter(E=>E.source===e).length>=2;if(t==="START_EVENT"){let g=d();return u.filter(f=>{if(f.source!==e)return!1;let h=g.find(y=>y.id===f.target);return(h==null?void 0:h.type)!=="ANNOTATION"}).length>=1}return!1})();return(0,$s.jsx)(hr.Handle,b({type:n,position:r,className:H("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":m,"hover:border-grey-500":!m},i),style:{pointerEvents:m?"none":"auto"}},a))};var Ks=require("react"),co=require("@xyflow/react");var Rd=require("@xyflow/react"),Xi=()=>{let e=(0,Rd.useStoreApi)();return{getInternalNodes:()=>{let{nodeLookup:o}=e.getState();return Array.from(o.values())}}};var Ui=require("react/jsx-runtime"),qs=require("react"),mh=["top","right","bottom","left"],gh=["top-left","top-middle","top-right","right-middle","bottom-left","left-middle","bottom-right","bottom-middle"],Mt=r=>{var i=r,{nodeId:e,isVisible:t,offset:o=8}=i,n=Yt(i,["nodeId","isVisible","offset"]);let{getInternalNode:a,setNodes:s}=(0,co.useReactFlow)(),{getInternalNodes:l}=Xi(),{isMultipleSelection:c}=$(),d=(0,co.useStoreApi)(),p=(0,Ks.useRef)(0),m=(0,Ks.useRef)([]),u=({y:h,width:y,height:x})=>{cancelAnimationFrame(p.current),p.current=requestAnimationFrame(()=>{var U,Q;if(!e)return;let{nodeLookup:v,onNodesChange:N}=d.getState(),T=v.get(e);if(!T||T.type!=="LANE")return;let _=!T.parentId,I=_?T.id:T.parentId;if(!I)return;let S=Array.from(v.values()).filter(Y=>Y.type==="LANE"&&Y.parentId===I);if(!S.length)return;m.current.length===0&&(m.current=zo(S).map(Y=>Y.id));let P=m.current.map(Y=>S.find(C=>C.id===Y)).filter(Boolean),R=[],M=0,B=P.findIndex(Y=>Y.id===T.id),X=!_&&B>0&&Math.abs(h-T.position.y)>.5;for(let Y=0;Y<P.length;Y++){let C=P[Y],O=C.id===T.id,D=Y===P.length-1;if(O){M=X?h+x:M+x;continue}let A=(Q=(U=C.measured)==null?void 0:U.height)!=null?Q:0,k=_?y-se.HEADER_WIDTH:y,G=A;_&&D&&(G=Math.max(se.MIN_HEIGHT,x-M)),X&&Y===B-1&&(G=Math.max(se.MIN_HEIGHT,h-M)),R.push({id:C.id,type:"dimensions",dimensions:{width:k,height:G},setAttributes:!0}),R.push({id:C.id,type:"position",position:{x:se.HEADER_WIDTH,y:M}}),M+=G}_?R.push({id:I,type:"dimensions",dimensions:{width:y,height:x},setAttributes:!0}):R.push({id:I,type:"dimensions",dimensions:{width:y+se.HEADER_WIDTH,height:M},setAttributes:!0}),N==null||N(R)})},g=({y:h,width:y,height:x})=>{var T;if(cancelAnimationFrame(p.current),m.current=[],!e)return;let v=a(e);if(!v||v.type!=="LANE"&&!v.parentId)return;let N=[...l()];if(v.type!=="LANE"){N=N.map(_=>_.id===e?w(b({},_),{width:y,height:x,measured:{width:y,height:x}}):_),N=lo(N),s(N);return}N=Ba(v,y,x,N,h),N=lo(N),N=Bo((T=v.parentId)!=null?T:v.id,N),s(N)};if(!(!c&&t))return null;let f={"--resize-offset":`${o}px`};return(0,Ui.jsxs)(Ui.Fragment,{children:[mh.map(h=>(0,qs.createElement)(co.NodeResizeControl,w(b({},n),{key:h,nodeId:e,position:h,variant:co.ResizeControlVariant.Line,className:"border-blue-400/90 border-dashed",style:f,onResize:(y,x)=>u(x),onResizeEnd:(y,x)=>g(x)}))),gh.map(h=>(0,qs.createElement)(co.NodeResizeControl,w(b({},n),{key:h,nodeId:e,position:h,className:"size-1.5 bg-blue-400 relative before:content-[''] before:absolute before:w-5 before:h-5 before:left-1/2 before:top-1/2 before:-translate-x-1/2 before:-translate-y-1/2 before:cursor-[inherit]",style:f,onResize:(y,x)=>u(x),onResizeEnd:(y,x)=>g(x)})))]})};var qi=require("@xyflow/react"),Zt=require("@produto-lecom/lecom-ui"),gt=require("react");var Dd=require("zustand"),Dn=(0,Dd.create)(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));var $i=require("react"),Od=(e,t=!1)=>{let[o,n]=(0,$i.useState)({width:0,height:0});return(0,$i.useEffect)(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};var Co=require("@xyflow/react"),Vd=require("react"),hh=120,yh=12,Hd=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=(0,Co.useReactFlow)(),{instanceId:i}=$();return(0,Vd.useMemo)(()=>{var u,g;if(!t)return{position:Co.Position.Right,align:"start"};let a=n(e);if(!a)return{position:Co.Position.Right,align:"start"};let s=r(),l=a.position.x*s.zoom+s.x,c=(((u=a.measured)==null?void 0:u.width)||a.width||100)*s.zoom,d=(g=document.getElementById(`modeler-${i}`))==null?void 0:g.clientWidth;if(!d)return{position:Co.Position.Right,align:"start"};let p=(o==null?void 0:o.width)||hh;return{position:l+c+p+yh>d?Co.Position.Left:Co.Position.Right}},[i,e,t,o,n,r])};var Ki=require("@xyflow/react"),be=require("@produto-lecom/lecom-ui"),Gd=require("lucide-react");var Me=require("react/jsx-runtime"),Bd=({nodeId:e})=>{let{t}=(0,be.useTranslation)(),{updateNodeData:o,getEdges:n,getNode:r}=(0,Ki.useReactFlow)(),i=(0,Ki.useNodesData)(e),s=n().filter(u=>u.source===e).some(u=>{let g=r(u.target);return(g==null?void 0:g.type)==="END_EVENT"}),l=(i==null?void 0:i.data.variant)==="SUBPROCESS",c=p=>{o(e,{variant:(i==null?void 0:i.data.variant)===p?"":p})},d=p=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===p?"":p})};return(0,Me.jsxs)(be.DropdownMenu,{children:[(0,Me.jsxs)(be.Tooltip,{children:[(0,Me.jsx)(be.TooltipTrigger,{asChild:!0,children:(0,Me.jsx)(be.DropdownMenuTrigger,{asChild:!0,children:(0,Me.jsx)(be.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:(0,Me.jsx)(Gd.WrenchIcon,{})})})}),(0,Me.jsx)(be.TooltipContent,{color:"black",children:t("bpmn.task.menu.title")})]}),(0,Me.jsxs)(be.DropdownMenuContent,{align:"start",className:"w-60 bg-white text-grey-600",children:[(0,Me.jsxs)(be.DropdownMenuLabel,{className:"flex items-center gap-1",children:[(0,Me.jsx)("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),(0,Me.jsx)("div",{className:"flex items-center gap-1",children:Object.entries(Wr).map(([p,m])=>{let u=p==="LOOP"&&(s||l),E=(()=>{if(p==="LOOP"&&s)return t("editor.task_menu.loop_not_allowed_when_connected_to_end");if(p==="LOOP"&&l)return t("editor.task_menu.loop_not_allowed_when_subprocess");if(p==="LOOP")return t("editor.task_menu.loop")})();return(0,Me.jsxs)(be.Tooltip,{children:[(0,Me.jsx)(be.TooltipTrigger,{asChild:!0,children:(0,Me.jsx)(be.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:u,className:H({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===p,"opacity-50 cursor-not-allowed":u}),onClick:u?void 0:()=>d(p),children:(0,Me.jsx)(m.icon,{className:"stroke-inherit"})})}),E&&(0,Me.jsx)(be.TooltipContent,{color:"black",children:E})]},p)})})]}),(0,Me.jsx)(be.DropdownMenuGroup,{children:(0,Me.jsxs)(be.Tooltip,{children:[(0,Me.jsx)(be.TooltipTrigger,{asChild:!0,children:(0,Me.jsx)("div",{className:H({"cursor-not-allowed":s}),children:(0,Me.jsxs)(be.DropdownMenuItem,{className:H({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":s}),disabled:s,onClick:()=>c("SCRIPT"),children:[(0,Me.jsx)(Yr.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),s&&(0,Me.jsx)(be.TooltipContent,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};var ke=require("react/jsx-runtime"),uo={START_EVENT:{type:"START_EVENT",icon:Kn,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:an,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:Kn,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:Hr,label:"bpmn.annotation.variant.default"}},xh={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:dn,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:pn,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:ln,label:"bpmn.gateway.variant.complex"}},at=({nodeId:e,nodeType:t,nodeVariant:o,isChild:n})=>{let r=(0,gt.useRef)(null),i=(0,gt.useRef)(null),{t:a}=(0,Zt.useTranslation)(),{setDraggableNode:s}=Dn(),{getEdges:l,getNodes:c,getNode:d}=(0,qi.useReactFlow)(),{setIsDragging:p,mode:m,isConnecting:u,isDragging:g,isMultipleSelection:E}=$(),f=d(e),h=!!(f!=null&&f.selected)&&!f.dragging&&!u&&!g&&!E,{dimensions:y}=Od(r,h),{position:x}=Hd(e,h,y),[v,N]=(0,gt.useState)(void 0),T=c(),_=l(),I=o==="SUBPROCESS",S=(0,gt.useRef)(null),P=(0,gt.useRef)(!1),R=(0,gt.useCallback)(()=>{S.current!==null&&(clearTimeout(S.current),S.current=null),P.current=!1,p(!1),s(null),N(void 0)},[p,s]);(0,gt.useEffect)(()=>{let L=V=>{P.current&&V.buttons===0&&R()};return document.addEventListener("dragend",R),document.addEventListener("mousemove",L),()=>{document.removeEventListener("dragend",R),document.removeEventListener("mousemove",L)}},[R]);let M=(0,gt.useCallback)((L,V)=>{P.current=!0,p(!1),s({type:V.type,variant:V.variant,attribute:V.attribute,icon:V.icon}),V.icon&&N((0,ke.jsx)(V.icon,{})),L.dataTransfer.effectAllowed="move",L.dataTransfer.setData("sourceId",e),i.current&&L.dataTransfer.setDragImage(i.current,10,10),S.current=setTimeout(()=>{S.current=null,p(!0)},100)},[e,s,p]),B=(0,gt.useCallback)(()=>{R()},[R]),X=[{component:(0,ke.jsx)(Li,{elementId:e})}],U=()=>{if(m==="view")return[];let L=!_.some(V=>{var j;return V.source===e&&((j=T.find(Z=>Z.id===V.target))==null?void 0:j.type)!=="ANNOTATION"});return[{component:(0,ke.jsx)(In,{nodeId:e,disabled:!L,tooltipMessage:L?void 0:a("editor.toolbar.start_event_limit_reached")})},uo.TASK,uo.ANNOTATION,...X]},Q=()=>m==="view"?[{component:(0,ke.jsx)(Io,{elementId:e})}]:[{component:(0,ke.jsx)(Io,{elementId:e})},...I?[]:[{component:(0,ke.jsx)(Bd,{nodeId:e})}],{component:(0,ke.jsx)(In,{nodeId:e})},uo.TASK,{type:"TASK",variant:"SUBPROCESS",icon:qn,label:"bpmn.task.variant.subprocess"},uo.ANNOTATION,...Object.values(xh),...Ko(e,T,_)?[]:[uo.END_EVENT],...X],Y=()=>m==="view"?[{component:(0,ke.jsx)(Io,{elementId:e,elementType:"gateway"})}]:[{component:(0,ke.jsx)(Io,{elementId:e,elementType:"gateway"})},{component:(0,ke.jsx)(In,{nodeId:e})},uo.TASK,{type:"TASK",variant:"SUBPROCESS",icon:qn,label:"bpmn.task.variant.subprocess"},uo.ANNOTATION,...X],C=()=>m==="view"?[]:[uo.ANNOTATION,...X],O=()=>m==="view"?[]:[...n?[]:[{component:(0,ke.jsx)(In,{nodeId:e})}],uo.ANNOTATION,...X],D=()=>m==="view"?[]:[{component:(0,ke.jsx)(In,{nodeId:e})},...X],A=()=>m==="view"?[]:[...X],G=(L=>{switch(L){case"START_EVENT":return U();case"TASK":return Q();case"GATEWAY":return Y();case"END_EVENT":return C();case"LANE":return O();case"ANNOTATION":return D();case"UNSUPPORTED":return A();default:return[]}})(t),z=G.length>6;if(!(G.length===0||m==="readonly"))return(0,ke.jsxs)(qi.NodeToolbar,{position:x,align:"start",className:z?"-top-[4.5rem]":"-top-8",isVisible:h,children:[(0,ke.jsx)("div",{ref:r,className:`${z?"grid grid-cols-6":"flex"} gap-1 px-2 py-2 bg-white rounded-sm shadow-md`,children:G.map((L,V)=>{if(L.component)return(0,ke.jsx)("div",{children:L.component},V);let j={sourceNodeType:t,targetNodeType:L.type,sourceNodeId:e,nodes:T,edges:_},Z=$c(j),J={gateway_limit_reached:a("editor.toolbar.gateway_limit_reached"),start_event_limit_reached:a("editor.toolbar.start_event_limit_reached"),start_event_already_exists:a("editor.toolbar.start_event_already_exists"),script_to_end_not_allowed:a("editor.toolbar.script_to_end_not_allowed"),loop_to_end_not_allowed:a("editor.toolbar.loop_to_end_not_allowed"),initial_activity_to_end_not_allowed:a("editor.toolbar.initial_activity_to_end_not_allowed"),final_activity_cannot_connect:a("editor.toolbar.final_activity_cannot_connect"),activity_has_outgoing_connections:a("editor.toolbar.activity_has_outgoing_connections"),task_limit_reached:a("editor.toolbar.task_limit_reached")},q=Z.shouldDisable&&Z.reason?J[Z.reason]||a(L.label):a(L.label)||"";return(0,ke.jsxs)(Zt.Tooltip,{children:[(0,ke.jsx)(Zt.TooltipTrigger,{asChild:!0,children:(0,ke.jsx)(Zt.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!Z.shouldDisable,disabled:Z.shouldDisable,className:Z.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:Z.shouldDisable?void 0:ee=>M(ee,L),onDragEnd:Z.shouldDisable?void 0:B,children:L.icon&&(0,ke.jsx)(L.icon,{size:16})})}),(0,ke.jsx)(Zt.TooltipContent,{color:"black",children:q})]},V)})}),(0,ke.jsx)("div",{ref:i,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:v})]})};var $e=require("react/jsx-runtime"),zd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r,setNodes:i}=(0,ht.useReactFlow)(),{inProgress:a,fromNode:s}=(0,ht.useConnection)(),{mode:l}=$(),c=a&&(s==null?void 0:s.id)!==e,d=(0,Zi.useCallback)(u=>{let y=u.split(`
|
|
40
|
+
`),x=y.reduce((_,I)=>Math.max(_,I.length),0),v=y.length,N=Math.max(En.MIN_WIDTH,x*7+32),T=Math.max(En.MIN_HEIGHT,v*20+24);i(_=>_.map(I=>I.id===e?w(b({},I),{width:N,height:T,style:w(b({},I.style),{width:N,height:T})}):I))},[e,i]),p=(0,Zi.useCallback)(u=>{r(e,{label:u}),d(u)},[e,r,d]),m=(0,Zi.useCallback)(u=>{d(u)},[d]);return(0,$e.jsxs)("div",{className:H("relative w-full h-full min-w-44 min-h-16 flex text-grey-400 hover:text-grey-500 bg-white rounded-sm border-l-2 border-current before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-current after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-current hover:shadow-md transition-colors duration-75",{"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:[(0,$e.jsx)(Ze,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:p,onInput:m,skipFirstCharValidation:!0}),(0,$e.jsx)(at,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&(0,$e.jsx)(Mt,{nodeId:e,minWidth:En.MIN_WIDTH,minHeight:En.MIN_HEIGHT,isVisible:!n&&o}),!a&&(0,$e.jsxs)($e.Fragment,{children:[(0,$e.jsx)(oe,{type:"source",position:ht.Position.Left,id:"left"}),(0,$e.jsx)(oe,{type:"source",position:ht.Position.Right,id:"right"}),(0,$e.jsx)(oe,{type:"source",position:ht.Position.Top,id:"top"}),(0,$e.jsx)(oe,{type:"source",position:ht.Position.Bottom,id:"bottom"})]}),(!a||c)&&(0,$e.jsxs)($e.Fragment,{children:[(0,$e.jsx)(oe,{type:"target",position:ht.Position.Left,id:"left",className:H({"annotation-handle":c})}),(0,$e.jsx)(oe,{type:"target",position:ht.Position.Right,id:"right",className:H({"annotation-handle":c})}),(0,$e.jsx)(oe,{type:"target",position:ht.Position.Top,id:"top",className:H({"annotation-handle":c})}),(0,$e.jsx)(oe,{type:"target",position:ht.Position.Bottom,id:"bottom",className:H({"annotation-handle":c})})]})]})};var yt=require("@xyflow/react"),Yd=require("react");var ze=require("react/jsx-runtime"),Wd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=(0,yt.useReactFlow)(),{inProgress:i,fromNode:a}=(0,yt.useConnection)(),{mode:s,reconnectingEdgeId:l}=$(),[c,d]=(0,Yd.useState)(!1),p=i&&(a==null?void 0:a.id)!==e||!!l,m=E=>{r(e,{label:E})},u=()=>{d(!0)},g=()=>{d(!1)};return(0,ze.jsxs)("div",{className:"relative",onDoubleClick:u,children:[(0,ze.jsx)(an,{className:H("w-full h-full min-w-9 min-h-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})}),(0,ze.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,ze.jsx)(Ze,{value:t.label,isEditing:c,onBlur:g,onChange:m})}),(0,ze.jsx)(at,{nodeId:e,nodeType:"END_EVENT"}),s==="edit"&&(0,ze.jsx)(Mt,{nodeId:e,isVisible:!n&&o,minWidth:Ur.MIN_WIDTH,minHeight:Ur.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||p)&&(0,ze.jsxs)(ze.Fragment,{children:[(0,ze.jsx)(oe,{type:"target",position:yt.Position.Left,id:"left",className:H({"event-handle":p})}),(0,ze.jsx)(oe,{type:"target",position:yt.Position.Right,id:"right",className:H({"event-handle":p})}),(0,ze.jsx)(oe,{type:"target",position:yt.Position.Top,id:"top",className:H({"event-handle":p})}),(0,ze.jsx)(oe,{type:"target",position:yt.Position.Bottom,id:"bottom",className:H({"event-handle":p})})]}),!i&&(0,ze.jsxs)(ze.Fragment,{children:[(0,ze.jsx)(oe,{type:"source",position:yt.Position.Left,id:"left"}),(0,ze.jsx)(oe,{type:"source",position:yt.Position.Right,id:"right"}),(0,ze.jsx)(oe,{type:"source",position:yt.Position.Top,id:"top"}),(0,ze.jsx)(oe,{type:"source",position:yt.Position.Bottom,id:"bottom"})]})]})};var xt=require("@xyflow/react"),Ji=require("react");var Ye=require("react/jsx-runtime"),Fd=({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let a=ys[t.variant].icon,{updateNodeData:s}=(0,xt.useReactFlow)(),{inProgress:l,fromNode:c}=(0,xt.useConnection)(),{mode:d,reconnectingEdgeId:p}=$(),[m,u]=(0,Ji.useState)(!1),g=l&&(c==null?void 0:c.id)!==e||!!p,E=(0,Ji.useCallback)(y=>{s(e,{label:y})},[e,s]),f=()=>{u(!0)},h=()=>{u(!1)};return(0,Ye.jsxs)("div",{className:"relative",style:{width:o!=null?o:xn.MIN_WIDTH,height:n!=null?n:xn.MIN_HEIGHT},onDoubleClick:f,children:[(0,Ye.jsx)(a,{className:H("w-full h-full min-w-14 min-h-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":r,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),(0,Ye.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,Ye.jsx)(Ze,{value:t.label,isEditing:m,onBlur:h,onChange:E})}),(0,Ye.jsx)(at,{nodeId:e,nodeType:"GATEWAY",nodeVariant:t.variant}),d==="edit"&&(0,Ye.jsx)(Mt,{nodeId:e,isVisible:!i&&r,minWidth:xn.MIN_WIDTH,minHeight:xn.MIN_HEIGHT,offset:2,keepAspectRatio:!0}),(!l||g)&&(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsx)(oe,{type:"target",position:xt.Position.Left,id:"left",className:H({"gateway-handle":g})}),(0,Ye.jsx)(oe,{type:"target",position:xt.Position.Right,id:"right",className:H({"gateway-handle":g})}),(0,Ye.jsx)(oe,{type:"target",position:xt.Position.Top,id:"top",className:H({"gateway-handle":g})}),(0,Ye.jsx)(oe,{type:"target",position:xt.Position.Bottom,id:"bottom",className:H({"gateway-handle":g})})]}),!l&&(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsx)(et,{type:"source",position:xt.Position.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,Ye.jsx)(et,{type:"source",position:xt.Position.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,Ye.jsx)(et,{type:"source",position:xt.Position.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,Ye.jsx)(et,{type:"source",position:xt.Position.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})};var Xd=require("@xyflow/react"),Vt=require("@produto-lecom/lecom-ui"),Eh=require("lucide-react");var Ud=require("react/jsx-runtime");var Et=require("@xyflow/react"),$d=require("react");var We=require("react/jsx-runtime"),Kd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=(0,Et.useReactFlow)(),{inProgress:i,fromNode:a}=(0,Et.useConnection)(),{mode:s,reconnectingEdgeId:l}=$(),[c,d]=(0,$d.useState)(!1),p=i&&(a==null?void 0:a.id)!==e||!!l,m=E=>{r(e,{label:E})},u=()=>{d(!0)},g=()=>{d(!1)};return(0,We.jsxs)("div",{className:"relative",onDoubleClick:u,children:[(0,We.jsx)(zr,{className:H("w-full h-full min-w-9 min-h-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})}),(0,We.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,We.jsx)(Ze,{value:t.label,isEditing:c,onBlur:g,onChange:m})}),(0,We.jsx)(at,{nodeId:e,nodeType:"START_EVENT"}),s==="edit"&&(0,We.jsx)(Mt,{nodeId:e,isVisible:!n&&o,minWidth:Xr.MIN_WIDTH,minHeight:Xr.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||p)&&(0,We.jsxs)(We.Fragment,{children:[(0,We.jsx)(oe,{type:"target",position:Et.Position.Left,id:"left",className:H({"event-handle":p})}),(0,We.jsx)(oe,{type:"target",position:Et.Position.Right,id:"right",className:H({"event-handle":p})}),(0,We.jsx)(oe,{type:"target",position:Et.Position.Top,id:"top",className:H({"event-handle":p})}),(0,We.jsx)(oe,{type:"target",position:Et.Position.Bottom,id:"bottom",className:H({"event-handle":p})})]}),!i&&(0,We.jsxs)(We.Fragment,{children:[(0,We.jsx)(et,{type:"source",position:Et.Position.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),(0,We.jsx)(et,{type:"source",position:Et.Position.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),(0,We.jsx)(et,{type:"source",position:Et.Position.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),(0,We.jsx)(et,{type:"source",position:Et.Position.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};var Qd=require("@produto-lecom/lecom-ui"),bt=require("@xyflow/react"),br=require("react");var yr=60,Qi=(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<=yr?i:i.substring(0,yr).trim()},On=(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>yr&&(n=n.substring(0,yr).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=yr-l.length,p=`${r.substring(0,c).trim()}${l}`;if(!o.has(p))return p;i++}return n};var xr=require("react/jsx-runtime"),qd=e=>(0,xr.jsxs)("svg",w(b({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[(0,xr.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),(0,xr.jsx)("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));var Zs=require("react/jsx-runtime"),Zd=e=>(0,Zs.jsx)("svg",w(b({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:(0,Zs.jsx)("path",{d:"M12 2C8.13 2 5 5.13 5 9C5 14.25 12 22 12 22C12 22 19 14.25 19 9C19 5.13 15.87 2 12 2ZM12 11.5C10.62 11.5 9.5 10.38 9.5 9C9.5 7.62 10.62 6.5 12 6.5C13.38 6.5 14.5 7.62 14.5 9C14.5 10.38 13.38 11.5 12 11.5Z",fill:"#38bdf8"})}));var Er=require("react/jsx-runtime"),Jd=e=>(0,Er.jsxs)("svg",w(b({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[(0,Er.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),(0,Er.jsx)("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));var ge=require("react/jsx-runtime"),bh={APROVADO:qd,EM_ANDAMENTO:Zd,REJEITADO:Jd},Js={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)]"},jd=({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let{t:a}=(0,Qd.useTranslation)(),{toast:s}=st(),{updateNodeData:l,getNodes:c,setNodes:d}=(0,bt.useReactFlow)(),{inProgress:p,fromNode:m}=(0,bt.useConnection)(),{mode:u,onSubprocessValidationClick:g,reconnectingEdgeId:E}=$(),{getTaskStatus:f}=Yo(),h=p&&(m==null?void 0:m.id)!==e||!!E,y=f(e),x=t.variant==="SUBPROCESS",v=!!t.variant&&!x||!!y,N=!!t.attribute||x,T=(0,br.useCallback)(U=>{let O=v||N?80:40,D=U.split(`
|
|
41
|
+
`),A=D.reduce((L,V)=>Math.max(L,V.length),0),k=D.length,G=Math.max(Eo.MIN_WIDTH,A*7+64),z=Math.max(Eo.MIN_HEIGHT,k*24+O);d(L=>L.map(V=>V.id===e?w(b({},V),{width:G,height:z,style:w(b({},V.style),{width:G,height:z})}):V))},[e,d,v,N]),_=(0,br.useCallback)(U=>{let Q=U.trim(),Y=t.label||"";if(Q===Y)return;let C=Q,O=c();if(!(Q&&Q!=="")){C=Qi(O,a("bpmn.task.label.prefix")),l(e,{label:C}),T(C),s({variant:"warning",content:(0,ge.jsxs)(ge.Fragment,{children:[a("bpmn.task.feedback.label_empty.prefix")," ",(0,ge.jsx)("strong",{children:C})]})});return}let A=On(C,O);A===Y||(l(e,{label:A}),T(A),A!==C&&s({variant:"warning",content:(0,ge.jsxs)(ge.Fragment,{children:[a("bpmn.task.feedback.label_already_exists.prefix")," ",(0,ge.jsx)("strong",{children:Q})," ",a("bpmn.task.feedback.label_already_exists.middle")," ",(0,ge.jsx)("strong",{children:A})]})}))},[t.label,c,e,a,l,T,s]),I=(0,br.useCallback)(U=>{T(U)},[T]),S=(0,br.useCallback)(()=>{s({variant:"error",content:a("bpmn.task.feedback.invalid_first_character")})},[a,s]),P=y?bh[y]:null,R=t.variant?Yr[t.variant].icon:null,M=t.attribute?Wr[t.attribute].icon:null,B=()=>t.hasError?Js.error:y?Js[y]:Js.default,X=()=>{g==null||g({id:e,type:"sub_process",label:t.label})};return(0,ge.jsxs)("div",{className:H("relative w-full h-full min-w-44 min-h-24 flex flex-col items-stretch justify-stretch bg-white border-2 border-grey-400 hover:border-grey-500 rounded-md hover:shadow-md transition-colors duration-75",B(),{"border-blue-500 hover:border-blue-600 shadow-md":r,"border-red-500 hover:border-red-600 shadow-[0_0_5px_rgba(255,0,0,0.5)]":t.hasError}),style:{width:o!=null?o:Eo.MIN_WIDTH,height:n!=null?n:Eo.MIN_HEIGHT},children:[(0,ge.jsx)("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:(0,ge.jsx)(Ze,{value:t.label,maxLength:60,className:H({"py-10 px-8":v||N}),onChange:_,onInput:I,onInvalidFirstCharacter:S})}),R&&(0,ge.jsx)("div",{className:H("absolute flex items-center p-1",x?"bottom-0 left-1/2 -translate-x-1/2":"top-0 left-0"),children:(0,ge.jsx)(R,{size:16,className:H(t.hasError?"text-red-500":"text-grey-500",x&&"cursor-pointer"),onClick:x?X:void 0})}),M&&(0,ge.jsx)("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:(0,ge.jsx)("div",{className:H("flex items-center w-16 p-1",x?"justify-between":"justify-center"),children:(0,ge.jsx)(M,{size:16,className:H(t.hasError?"text-red-500":"text-grey-500")})})}),P&&(0,ge.jsx)("div",{className:"absolute top-0 right-0 flex items-center p-1",children:(0,ge.jsx)(P,{})}),(0,ge.jsx)(at,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),u==="edit"&&(0,ge.jsx)(Mt,{nodeId:e,isVisible:!i&&r,minWidth:Eo.MIN_WIDTH,minHeight:Eo.MIN_HEIGHT}),(!p||h)&&(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsx)(oe,{type:"target",position:bt.Position.Left,id:"left",className:H({"task-handle":h})}),(0,ge.jsx)(oe,{type:"target",position:bt.Position.Right,id:"right",className:H({"task-handle":h})}),(0,ge.jsx)(oe,{type:"target",position:bt.Position.Top,id:"top",className:H({"task-handle":h})}),(0,ge.jsx)(oe,{type:"target",position:bt.Position.Bottom,id:"bottom",className:H({"task-handle":h})})]}),!p&&(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsx)(et,{type:"source",position:bt.Position.Left,id:"left",nodeId:e,nodeType:"TASK"}),(0,ge.jsx)(et,{type:"source",position:bt.Position.Right,id:"right",nodeId:e,nodeType:"TASK"}),(0,ge.jsx)(et,{type:"source",position:bt.Position.Top,id:"top",nodeId:e,nodeType:"TASK"}),(0,ge.jsx)(et,{type:"source",position:bt.Position.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})};var Qs=require("@xyflow/react");var po=require("react/jsx-runtime"),eu=({id:e,data:t})=>(0,po.jsxs)(po.Fragment,{children:[(0,po.jsx)("div",{className:"relative w-full h-full min-w-32 min-h-16 flex items-center justify-center bg-white border-2 border-red-400 rounded-sm overflow-hidden",children:t.label}),(0,po.jsx)(at,{nodeId:e,nodeType:"UNSUPPORTED"}),(0,po.jsx)(oe,{type:"source",position:Qs.Position.Right}),(0,po.jsx)(oe,{type:"target",position:Qs.Position.Left})]});var Oe=require("@xyflow/react"),ji=require("react");var ve=require("react/jsx-runtime"),nI={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:Oe.MarkerType.Arrow},data:{label:""}},tu=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var G;let{zoom:c}=(0,Oe.useViewport)(),{updateEdgeData:d}=(0,Oe.useReactFlow)(),{isMultipleSelection:p,mode:m,instanceId:u}=$(),g=m!=="edit",[E,f]=(0,ji.useState)(!1),{reconnectingHandle:h,cursorPosition:y,hoveredNodeId:x,reconnectingSide:v,isValidReconnection:N,handleReconnectStart:T}=Gi({edgeId:e,source:t,target:o,instanceId:u,isReadOnly:g}),_=(0,Oe.useInternalNode)(t),I=(0,Oe.useInternalNode)(o),{sx:S,sy:P,tx:R,ty:M,sourcePos:B,targetPos:X}=(0,ji.useMemo)(()=>{var ne,le;if(!_||!I)return{sx:0,sy:0,tx:0,ty:0,sourcePos:Oe.Position.Left,targetPos:Oe.Position.Right};let z=yn(_,I),L=s?i:z.sourcePos,V=l?a:z.targetPos,j=(K,Te,W)=>{var ue,Ne,Fe,Qe,ot,ct;let{x:te,y:ce}=K.internals.positionAbsolute,re=(Fe=(Ne=(ue=K.measured)==null?void 0:ue.width)!=null?Ne:K.width)!=null?Fe:0,fe=(ct=(ot=(Qe=K.measured)==null?void 0:Qe.height)!=null?ot:K.height)!=null?ct:0;switch(Te){case Oe.Position.Top:return{x:te+re*W,y:ce};case Oe.Position.Bottom:return{x:te+re*W,y:ce+fe};case Oe.Position.Left:return{x:te,y:ce+fe*W};case Oe.Position.Right:return{x:te+re,y:ce+fe*W};default:return{x:te+re/2,y:ce+fe/2}}},Z=(ne=n==null?void 0:n.sourceOffset)!=null?ne:.5,J=(le=n==null?void 0:n.targetOffset)!=null?le:.5,q=_?j(_,L,Z).x:z.sx,ee=_?j(_,L,Z).y:z.sy,ae=I?j(I,V,J).x:z.tx,F=I?j(I,V,J).y:z.ty;return h==="source"&&y?(q=y.x,ee=y.y,v&&(L=v)):h==="target"&&y&&(ae=y.x,F=y.y,v&&(V=v)),{sx:q,sy:ee,tx:ae,ty:F,sourcePos:L,targetPos:V}},[_,I,s,l,i,a,h,y,v,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!_||!I)return null;let[U,Q,Y]=(0,Oe.getSmoothStepPath)({sourceX:S,sourceY:P,targetX:R,targetY:M,sourcePosition:B,targetPosition:X}),C=r||(_==null?void 0:_.selected)||(I==null?void 0:I.selected),O=C?"sequence-edge-marker-highlighted":"sequence-edge-marker",D=E||(n==null?void 0:n.label.trim().length)>0,A=()=>{f(!1)},k=z=>{d(e,{label:z.trim()})};return(0,ve.jsx)(ve.Fragment,{children:(0,ve.jsxs)("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":C}),onDoubleClick:()=>!g&&f(!0),children:[(0,ve.jsx)("path",{d:U,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),(0,ve.jsxs)("g",{className:H("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":C}),children:[(0,ve.jsx)(Oe.BaseEdge,{id:e,path:U,interactionWidth:0,markerEnd:`url(#${O})`,strokeDasharray:4,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||h&&x&&!N,"stroke-green-500":h&&x&&N,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":C&&!(n!=null&&n.hasError)&&!h})}),(0,ve.jsxs)(Oe.EdgeLabelRenderer,{children:[(0,ve.jsxs)("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${Q}px, ${Y}px)`},children:[r&&!p&&(0,ve.jsx)(Sn,{sx:S,sy:P,tx:R,ty:M,hasLabel:!!((G=n==null?void 0:n.label)!=null&&G.trim()),children:(0,ve.jsx)(Cn,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),D&&(0,ve.jsx)(Ze,{value:n==null?void 0:n.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:E,onBlur:A,onChange:k})]}),r&&!p&&!g&&(0,ve.jsxs)(ve.Fragment,{children:[(0,ve.jsx)("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${S}px, ${P}px)`},children:(0,ve.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,ve.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:h==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ve.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:h==="source"?.6:.3,className:"pointer-events-none"}),(0,ve.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!h||h!=="source","cursor-not-allowed":h==="source"&&x&&!N,"cursor-grabbing":h==="source"&&(!x||N)}),onMouseDown:z=>T("source",z.nativeEvent)})]})}),(0,ve.jsx)("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${R}px, ${M}px)`},children:(0,ve.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,ve.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:h==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ve.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:h==="target"?.6:.3,className:"pointer-events-none"}),(0,ve.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!h||h!=="target","cursor-not-allowed":h==="target"&&x&&!N,"cursor-grabbing":h==="target"&&(!x||N)}),onMouseDown:z=>T("target",z.nativeEvent)})]})})]})]})]})]})})};var jo=require("@xyflow/react"),_r=require("react/jsx-runtime"),ou=({toX:e,toY:t,fromNode:o})=>{var p,m;if(!o)return null;let{internals:{positionAbsolute:{x:n,y:r}},measured:i}=o,a=(p=i.width)!=null?p:0,s=(m=i.height)!=null?m:0,c=[{x:n,y:r+s/2,pos:jo.Position.Left},{x:n+a,y:r+s/2,pos:jo.Position.Right},{x:n+a/2,y:r,pos:jo.Position.Top},{x:n+a/2,y:r+s,pos:jo.Position.Bottom}].reduce((u,g)=>{let E=Math.hypot(e-u.x,t-u.y);return Math.hypot(e-g.x,t-g.y)<E?g:u}),[d]=(0,jo.getStraightPath)({sourceX:c.x,sourceY:c.y,targetX:e,targetY:t});return(0,_r.jsxs)("g",{className:"group",children:[(0,_r.jsx)("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d}),(0,_r.jsx)("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})};var _t=require("@xyflow/react"),nu=require("lodash"),Nr=require("react");var Pe=require("react/jsx-runtime"),ru=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{let{updateNodeData:i,getNodes:a}=(0,_t.useReactFlow)(),{mode:s}=$(),{inProgress:l,fromNode:c}=(0,_t.useConnection)(),d=l&&(c==null?void 0:c.id)!==e,[p,m]=(0,Nr.useState)(!1),u=a(),g=!r,E=(0,Nr.useMemo)(()=>(0,nu.orderBy)([...u.filter(N=>N.parentId===e&&N.type==="LANE")],"position.y","asc"),[u,e]),f=g?Ma.MIN_WIDTH:se.MIN_WIDTH,h=(0,Nr.useMemo)(()=>{if(g&&E.length>1){let N=[...E];return N.pop(),N.reduce((_,I)=>{var S,P;return _+((P=(S=I.measured)==null?void 0:S.height)!=null?P:0)},0)+se.MIN_HEIGHT}return se.MIN_HEIGHT},[g,E]),y=N=>{i(e,{label:N})},x=()=>{m(!0)},v=()=>{m(!1)};return(0,Pe.jsxs)(Pe.Fragment,{children:[(0,Pe.jsxs)("div",{className:H("flex h-full min-h-64 w-full min-w-[50rem] hover:shadow-md bg-white outline outline-1 outline-grey-300",{"outline-offset-2 outline-blue-500 shadow-sm":o}),children:[(0,Pe.jsx)("div",{className:"flex align-items justify-center w-10 border-r border-grey-300",onDoubleClick:x,children:(0,Pe.jsx)("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:(0,Pe.jsx)(Ze,{value:t.label,className:"w-full h-full self-auto",contentClassName:H({"whitespace-nowrap":p}),isEditing:p,onBlur:v,onChange:y})})}),(0,Pe.jsx)("div",{className:"flex-1"})]}),(0,Pe.jsx)(at,{nodeId:e,nodeType:"LANE",isChild:!g}),s==="edit"&&(0,Pe.jsx)(Mt,{nodeId:e,isVisible:!n&&o,minWidth:f,minHeight:h,offset:10}),!l&&(0,Pe.jsxs)(Pe.Fragment,{children:[(0,Pe.jsx)(oe,{type:"source",position:_t.Position.Left,id:"left"}),(0,Pe.jsx)(oe,{type:"source",position:_t.Position.Right,id:"right"}),(0,Pe.jsx)(oe,{type:"source",position:_t.Position.Top,id:"top"}),(0,Pe.jsx)(oe,{type:"source",position:_t.Position.Bottom,id:"bottom"})]}),(!l||d)&&(0,Pe.jsxs)(Pe.Fragment,{children:[(0,Pe.jsx)(oe,{type:"target",position:_t.Position.Left,id:"left",className:H({"annotation-handle":d})}),(0,Pe.jsx)(oe,{type:"target",position:_t.Position.Right,id:"right",className:H({"annotation-handle":d})}),(0,Pe.jsx)(oe,{type:"target",position:_t.Position.Top,id:"top",className:H({"annotation-handle":d})}),(0,Pe.jsx)(oe,{type:"target",position:_t.Position.Bottom,id:"bottom",className:H({"annotation-handle":d})})]})]})};var iu={START_EVENT:Kd,END_EVENT:Wd,TASK:jd,GATEWAY:Fd,ANNOTATION:zd,LANE:ru,UNSUPPORTED:eu},su={SEQUENCE_EDGE:pd,MESSAGE_EDGE:tu,ANNOTATION_EDGE:nd},au="#fafafa",lu="#bebebe",cu=1,du=10,uu="bottom-left",js=.05,pu=5,Vn=.5,Hn=js,Gn=1,fu={x:0,y:0,zoom:.75},mu=1,gu=2,_h={[mu]:4,[gu]:2},Tr=[mu,gu],ea=Tr.reduce((e,t)=>e|_h[t],0);var hu=require("@xyflow/react");var Pt=()=>{let{getEdges:e,getNodes:t}=(0,hu.useReactFlow)(),{lastElementId:o}=$(),n=()=>{let i=t(),a=e(),s=Pd(i,a);return Math.max(s,o)};return{getLastId:n,getNextId:()=>n()+1}};var zn=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n,setViewport:r}=(0,Bn.useReactFlow)(),{getLastId:i}=Pt(),a=(0,Bn.useStoreApi)(),{setLastElementId:s}=$(),l=(0,ta.useCallback)(async(d="")=>{let{nodes:p,edges:m,lastElementId:u}=await kd(d),{width:g,height:E}=a.getState();if(g>0&&E>0){let f=Va(p);f&&r((0,Bn.getViewportForBounds)(f,g,E,Hn,Gn,Vn))}o(p),n(m),s(u)},[o,n,s,a,r]),c=(0,ta.useCallback)(()=>{let d=e(),p=t(),m=i();return Ld(d,p,m)},[e,t,i]);return{importFromMxGraph:l,exportToMxGraph:c}};var oa=require("react"),Nh=500,es=()=>{let{isInitialized:e,onElementChanges:t}=$(),{exportToMxGraph:o}=zn(),n=(0,yu.useDebouncedCallback)(()=>{if(!e)return;let a=o();t==null||t(a)},Nh),r=(0,oa.useCallback)(a=>{a.every(c=>c.type==="select")||a.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=(0,oa.useCallback)(a=>{a.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var xu=({setEdges:e,saveHistory:t})=>{let{getNode:o,getEdges:n,getNodes:r,getInternalNode:i}=(0,ts.useReactFlow)(),{emitElementChanges:a}=es(),s=(0,Jt.useRef)(null),{getNextId:l}=Pt(),c=(0,Jt.useCallback)(f=>{var N;let h=o(f.source),y=o(f.target);if(!h||!y)return!1;let x={sourceNodeId:h.id,targetNodeId:y.id,sourceNodeType:h.type,targetNodeType:y.type,nodes:r(),edges:n(),reconnectingEdgeId:(N=s.current)!=null?N:void 0};return Hs(x).isValid},[o,n,r]),d=(0,Jt.useCallback)(f=>{var x,v;let h=l(),y=i(f.source);if(y){let N=i(f.target),T=N?N.internals.positionAbsolute.x+((x=N.measured.width)!=null?x:0)/2:0,_=N?N.internals.positionAbsolute.y+((v=N.measured.height)!=null?v:0)/2:0,I=fd(y,T,_),S=(N==null?void 0:N.type)==="ANNOTATION"||(y==null?void 0:y.type)==="ANNOTATION",P=S?Mn:St,R;if(!S&&N&&f.targetHandle){let X=zi(I),U=zi(f.targetHandle),{x:Q,y:Y}=Ys(y,I),{x:C,y:O}=Ys(N,f.targetHandle),A=Vi(Q,Y,C,O,X,U).slice(1,-1);A.length>0&&(R=A)}let M=w(b(b({},f),P),{id:String(h),sourceHandle:I,data:b(b({},S?{}:St.data),R?{points:R}:{})}),B=n().concat(M);e(B),t("forceSave",{nodes:r(),edges:B}),a()}},[l,e,a,i,n,r,t]),p=(0,Jt.useCallback)((f,h)=>{s.current=h.id},[]),m=(0,Jt.useCallback)(()=>{s.current=null},[]),u=(0,Jt.useCallback)((f,h)=>{let y=o(h.source),x=o(h.target);if(!y||!x){s.current=null;return}let v={sourceNodeId:y.id,targetNodeId:x.id,sourceNodeType:y.type,targetNodeType:x.type,nodes:r(),edges:n(),reconnectingEdgeId:f.id};if(!Hs(v).isValid){s.current=null;return}let T=(0,ts.reconnectEdge)(f,h,n()).map(_=>_.id===f.id?w(b({},_),{data:w(b({},_.data),{points:void 0})}):_);e(T),t("forceSave",{nodes:r(),edges:T}),s.current=null,a()},[o,r,n,e,a,t]),g=(0,Jt.useCallback)(f=>{s.current=f},[]),E=(0,Jt.useCallback)(()=>{s.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:u,onReconnectStart:p,onReconnectEnd:m,setReconnectingEdge:g,clearReconnectingEdge:E}};var Au=require("@produto-lecom/lecom-ui"),Cu=require("@xyflow/react"),Ht=require("react");var vr=(e=[])=>e.filter(t=>t.type==="START_EVENT"),en=(e=[])=>e.filter(t=>t.type==="END_EVENT"),So=(e=[])=>e.filter(t=>t.type==="TASK")||[],Eu=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"});var os=(e=[])=>e.filter(t=>t.type==="GATEWAY"),bu=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),Nt=(e,t=[])=>t.filter(o=>o.source===e),wr=(e,t=[])=>t.filter(o=>o.target===e),_u=(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"},Nu=(e,t)=>{let o=Nt(e,t.edges||[]);for(let n of o){let r=(t.nodes||[]).find(i=>i.id===n.target);if(r&&r.type==="END_EVENT")return!0}return!1},Tu=e=>e?/[^\s]/.test(e.trim()):!1,we=e=>{let{isValid:t,nodeIds:o,edgeIds:n}=e;return{isValid:t,nodeIds:!t&&o&&o.length>0?o:[],edgeIds:!t&&n&&n.length>0?n:[]}},fo=(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)}},vu=(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 Ir=[{id:"start_event_not_found",validate:e=>{let t=vr(e.nodes);return we({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=en(e.nodes);return we({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=vr(e.nodes),o=t.length===1;if(t.length===0)return we({isValid:!0});if(!o)return we({isValid:!1,nodeIds:t.map(i=>i.id)});let n=Nt(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(a=>a.id),...n.map(a=>a.target)];return we({isValid:!1,nodeIds:[...new Set(i)]})}return we({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=So(e.nodes),o=fo(t,n=>Nt(n.id,e.edges).length<=2);return we({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=So(e.nodes),o=fo(t,n=>!!n.label&&n.label.trim()!=="");return we({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=So(e.nodes),n=fo(o,r=>!r.label||r.label.length<=60);return we({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=So(e.nodes),o=new Map;for(let r of t){if(!r.label)continue;let i=r.label.trim();i&&(o.has(i)||o.set(i,[]),o.get(i).push(r))}let n=[];for(let[,r]of o.entries())r.length>1&&r.forEach(i=>n.push(i.id));return we({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=os(e.nodes),o=[],n=[];for(let r of t){let i=Nt(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="GATEWAY"&&(o.push(r.id,s.id),n.push(a.id))}}return we({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...vr(e.nodes),...en(e.nodes)],o=[],n=[];for(let r of t){let i=Nt(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&(s.type==="START_EVENT"||s.type==="END_EVENT")&&(o.push(r.id,s.id),n.push(a.id))}}return we({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=en(e.nodes),o=[],n=[];for(let r of t){let i=wr(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=Nt(s.id,e.edges);l.length>1&&(o.push(s.id),l.forEach(c=>n.push(c.id)))}}}return we({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=bu(e.nodes),o=fo(t,r=>Nt(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>Nt(r,e.edges).map(i=>i.id));return we({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=So(e.nodes),o=fo(t,n=>!n.label||Tu(n.label));return we({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var a,s;if(!((a=e==null?void 0:e.nodes)!=null&&a.length)||!((s=e==null?void 0:e.edges)!=null&&s.length))return we({isValid:!0});let t=en(e.nodes)[0];if(!t)return we({isValid:!0});let o=wr(t.id,e.edges);if(!o.length)return we({isValid:!0});let r=So(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=fo(r,l=>!_u(l.id,e));return we({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=So(e.nodes),o=en(e.nodes)[0];if(!o)return we({isValid:!0});let n=t.filter(l=>{let c=wr(l.id,e.edges),d=Nt(l.id,e.edges),p=c.some(u=>{var g;return((g=e.nodes.find(E=>E.id===u.source))==null?void 0:g.type)==="START_EVENT"}),m=d.some(u=>{var g;return((g=e.nodes.find(E=>E.id===u.target))==null?void 0:g.type)==="END_EVENT"});return p&&m}),r=wr(o.id,e.edges),i=r.length>1,a=r.map(l=>l.source),s={isValid:n.length===0&&!i,nodeIds:[...n.map(l=>l.id),...i?a:[]]};return we(s)}},{id:"gateway_flow_to_event",validate:e=>{let t=os(e.nodes),o=[],n=[];for(let r of t){let i=Nt(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="END_EVENT"&&(o.push(r.id,s.id),n.push(a.id))}}return we({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=os(e.nodes),o=fo(t,n=>Nt(n.id,e.edges).length>=1);return we({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...vr(e.nodes),...en(e.nodes)],o=[],n=[];for(let r of t){let i=Nt(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="GATEWAY"&&(o.push(r.id,s.id),n.push(a.id))}}return we({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=Eu(e.nodes),o=fo(t,n=>!Nu(n.id,e));return we({isValid:o.isValid,nodeIds:o.invalidIds})}}];var wu=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of Ir){let r=n.validate(e);r.isValid||t.push({id:n.id,message:n.id,nodeIds:r.nodeIds||[],edgeIds:r.edgeIds||[]})}return{isValid:t.length===0,errors:t}},Iu=async(e,t)=>{var n;let o=[];try{let r=await e(),i=(n=r==null?void 0:r.filter(a=>a.area==="DIAGRAM"))!=null?n:[];return i.length===0?{isValid:!0,errors:[]}:(i.forEach(a=>{var l,c;let s=(c=(l=a==null?void 0:a.detail)==null?void 0:l.phases)==null?void 0:c.map(d=>d.diagramCellId);o.push({id:a.code,message:a.code,nodeIds:s,edgeIds:[]})}),{isValid:!1,errors:o})}catch(r){return{isValid:!1,errors:[{id:"cannot_validate_subprocess_reference",message:"cannot_validate_subprocess_reference",nodeIds:t.map(i=>i.id)||[],edgeIds:[]}]}}};var tn=require("react/jsx-runtime"),Su=()=>{let{t:e}=(0,Au.useTranslation)(),{toast:t}=st(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=(0,Cu.useReactFlow)(),{validateCustomDiagram:a}=$(),[s,l]=(0,Ht.useState)(!1),c=(0,Ht.useRef)(!1),d=(0,Ht.useRef)(!1),p=(0,Ht.useCallback)(async f=>{let h=vu(f.nodes,f.edges),y=wu(h),x=f.nodes.filter(({type:N,data:T})=>N==="TASK"&&(T==null?void 0:T.variant)==="SUBPROCESS");if(a&&x.length>0){let N=await Iu(a,x);y={isValid:y.isValid&&N.isValid,errors:[...y.errors,...N.errors]}}let v=y.errors.map(N=>w(b({},N),{message:e(`validation.errors.${N.id}`)}));return s||l(!0),{isValid:y.isValid,errors:v}},[s,e,a]),m=(0,Ht.useCallback)((f,h=!0)=>{if(h&&f&&t({variant:f.isValid?"success":"error",duration:5e3,title:f.isValid?e("validation.success.title"):e("validation.errors.title"),content:(0,tn.jsxs)("div",{className:"flex flex-col gap-1",children:[!f.isValid&&(0,tn.jsx)("span",{className:"body-small-500",children:e("validation.errors.subtitle")}),(0,tn.jsx)("ul",{className:"list-disc list-inside max-h-40 overflow-y-auto",children:f.isValid?(0,tn.jsx)("li",{children:e("validation.success.message")}):f.errors.map(M=>(0,tn.jsx)("li",{className:"text-xs",children:M.message},M.id))})]})}),!f)return;c.current=!0,d.current=!0;let y=[],x=[];f.errors.forEach(M=>{M.nodeIds&&M.nodeIds.length>0&&M.nodeIds.forEach(B=>y.push(B)),M.edgeIds&&M.edgeIds.length>0&&M.edgeIds.forEach(B=>x.push(B))});let v=[...new Set(y)];o(M=>M.map(B=>w(b({},B),{data:w(b({},B.data),{hasError:!1})}))),n(M=>M.map(B=>w(b({},B),{data:w(b({},B.data),{hasError:!1})})));let N=r(),T=i(),_=new Set(v),I=new Set;f.errors.forEach(M=>{var U,Q;let B=Ir.find(Y=>Y.id===M.id);(B==null?void 0:B.highlightRelatedEdges)!==!1&&((U=M.edgeIds)==null||U.forEach(Y=>I.add(Y)),(Q=M.nodeIds)==null||Q.forEach(Y=>{T.forEach(C=>{(C.source===Y||C.target===Y)&&I.add(C.id)})}))});let S=new Set,P=new Set,R=new Set;N.forEach(M=>{M.type==="START_EVENT"?S.add(M.id):M.type==="END_EVENT"&&P.add(M.id)}),T.forEach(M=>{S.has(M.source)&&R.add(M.target),P.has(M.target)&&R.add(M.source)}),R.forEach(M=>{var B,X;if(_.has(M)){let U=(B=f.errors.find(Y=>{var C;return(C=Y.nodeIds)==null?void 0:C.includes(M)}))==null?void 0:B.id;((X=Ir.find(Y=>Y.id===U))==null?void 0:X.highlightRelatedEdges)!==!1&&T.forEach(Y=>{Y.source===M&&P.has(Y.target)&&(_.add(Y.target),I.add(Y.id)),Y.target===M&&S.has(Y.source)&&(_.add(Y.source),I.add(Y.id))})}}),_.size>0&&o(M=>M.map(B=>w(b({},B),{data:w(b({},B.data),{hasError:_.has(B.id)})}))),I.size>0&&n(M=>M.map(B=>w(b({},B),{data:w(b({},B.data),{hasError:I.has(B.id)})}))),setTimeout(()=>{c.current=!1},0)},[e,i,r,n,o,t]),u=(0,Ht.useCallback)(()=>{l(!1),d.current=!1,o(f=>f.map(h=>w(b({},h),{data:w(b({},h.data),{hasError:!1})}))),n(f=>f.map(h=>w(b({},h),{data:w(b({},h.data),{hasError:!1})})))},[n,o]),g=(0,Ht.useCallback)(()=>{d.current&&(c.current=!0,d.current=!1,o(f=>f.map(h=>w(b({},h),{data:w(b({},h.data),{hasError:!1})}))),n(f=>f.map(h=>w(b({},h),{data:w(b({},h.data),{hasError:!1})}))),setTimeout(()=>{c.current=!1},0))},[n,o]),E=(0,Ht.useCallback)(()=>c.current,[]);return{validateDiagram:p,handleValidationComplete:m,clearValidation:u,dismissValidationPanel:g,isAutoValidationEnabled:s,getIsClearingValidation:E}};var Lu=require("@xyflow/react"),ku=require("@produto-lecom/lecom-ui"),Ru=require("react");var Th=15,Mu="bpmn:selection",vh=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",i=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||i},Pu=e=>{if(!vh(e.target))return!0;let t=window.getSelection(),o=t&&t.toString().length>0;if(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement){let n=e.target;return n.selectionStart===n.selectionEnd&&!o}return!o},Du=({offset:e=Th,saveHistory:t})=>{let{t:o}=(0,ku.useTranslation)(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=(0,Lu.useReactFlow)(),{getNextId:s}=Pt(),{mode:l}=$();(0,Ru.useEffect)(()=>{if(l!=="edit")return;let c=p=>{var y,x;if(!Pu(p))return;let m=n(),u=i(),g=m.filter(v=>v.selected);if(!g.length)return;p.preventDefault(),p.stopPropagation();let E=u.filter(v=>g.some(N=>N.id===v.source)&&g.some(N=>N.id===v.target)),h=JSON.stringify({nodes:g,edges:E});(y=p.clipboardData)==null||y.setData(Mu,h),(x=p.clipboardData)==null||x.setData("text/plain",`BPMN Selection: ${g.length} nodes`)},d=p=>{var I,S;if(!Pu(p))return;let m=(I=p.clipboardData)==null?void 0:I.getData(Mu);if(!m)return;p.preventDefault(),p.stopPropagation();let u;try{u=JSON.parse(m)}catch(P){return}if(!((S=u.nodes)!=null&&S.length))return;let g=new Map,E=n(),f=[],h=u.nodes.filter(P=>vo(P.type,E));if(h.length===0)return;let y=s(),x=h.map(P=>{var B;let R=String(y++);g.set(P.id,R);let M=w(b({},P),{id:R,selected:!0,position:{x:P.position.x+e,y:P.position.y+e}});if(P.type==="TASK"){let X=(B=P.data)==null?void 0:B.label,U=On(X||o("bpmn.task.label.prefix"),[...E,...f]);M.data=w(b({},P.data),{label:U})}return f.push(M),M}),v=u.edges.map(P=>w(b({},P),{id:String(y++),selected:!0,source:g.get(P.source)||P.source,target:g.get(P.target)||P.target})),N=[...E.map(P=>w(b({},P),{selected:!1})),...x],_=[...i().map(P=>w(b({},P),{selected:!1})),...v];r(N),a(_),t("forceSave",{nodes:N,edges:_})};return document.addEventListener("copy",c,!0),document.addEventListener("paste",d,!0),()=>{document.removeEventListener("copy",c,!0),document.removeEventListener("paste",d,!0)}},[n,r,i,a,s,e,o,t,l])};var Ou=require("@produto-lecom/lecom-ui"),Vu=require("@xyflow/react");var Hu=require("react");var wh=50,Gu=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let{draggableNode:r,setDraggableNode:i}=Dn(),{t:a}=(0,Ou.useTranslation)(),{getInternalNode:s,getNodes:l,getEdges:c,screenToFlowPosition:d}=(0,Vu.useReactFlow)(),{getNextId:p}=Pt(),{setIsDragging:m}=$(),{getInternalNodes:u}=Xi(),{rebuildIndex:g,forceRebuildIndex:E}=wi(),[f,h]=(0,Hu.useState)(null),y=(C,O,D)=>{var z;if(C.parentId!==O)return null;let A=D.filter(L=>L.id!==C.id&&L.parentId===O&&L.type==="LANE").sort((L,V)=>L.position.y-V.position.y);if(A.length===0)return null;let k=(z=D.find(L=>L.id===C.id))!=null?z:C,G=A.find(L=>k.position.y<L.position.y);return G?{draggedLaneId:C.id,beforeLaneId:G.id}:{draggedLaneId:C.id,afterLaneId:A[A.length-1].id}},x=(C,O=!1,D)=>{let A=O?"node-drop-target-error":"node-drop-target",k=O?"node-drop-target-lane-error":"node-drop-target-lane";t(G=>{var L;let z=(L=D==null?void 0:D(G))!=null?L:null;return G.map(V=>{let j=[];return V.id===C&&j.push(A),C!==void 0&&V.parentId===C&&V.type==="LANE"&&V.id!==(z==null?void 0:z.draggedLaneId)&&j.push(k),V.id===(z==null?void 0:z.draggedLaneId)&&j.push("lane-reorder-dragging"),V.id===(z==null?void 0:z.beforeLaneId)&&j.push("lane-reorder-before"),V.id===(z==null?void 0:z.afterLaneId)&&j.push("lane-reorder-after"),w(b({},V),{className:j.join(" ")})})})},v=(C,O)=>{let D=u();if(C.type==="LANE"){if(O){x();return}let L=D.filter(Z=>Z.id!==C.id&&Z.type==="LANE"&&!Z.parentId),V=Zn(C,L);if(!V){x();return}if(Go({parentId:V.id,nodes:e,excludeTypes:["LANE"]})){x(V.id,!0);return}x(V.id,!1,Z=>y(C,V.id,Z));return}let k=D.filter(L=>L.id!==C.id&&L.type==="LANE"),G=Zn(C,k);if(!G){x();return}if(Go({parentId:G.id,nodes:e,includeTypes:["LANE"]})){x();return}x(G.id)},N=C=>{let O=s(C.id),D=C.type==="LANE"&&Go({parentId:C.id,nodes:e,includeTypes:["LANE"]});v(O,D)},T=C=>C.map(O=>w(b({},O),{className:void 0})),_=C=>C.some(D=>D.dragging)?C.map(D=>D.dragging?w(b({},D),{dragging:!1}):D):C,I=(C,O)=>{let D=0;for(let A of O){if(A.id===C||A.parentId||A.type==="LANE")continue;let k=It(A),G=k.y+k.h;D=Math.max(D,G)}return D+wh},S=(C,O)=>{if(!xs(C,O))return O;let D=I(C,O);return O.map(A=>A.id===C?w(b({},A),{position:w(b({},A.position),{y:D})}):A)},P=C=>{if(C.preventDefault(),C.dataTransfer.dropEffect="move",!(r!=null&&r.type))return;let O=d({x:C.clientX,y:C.clientY}),D={id:"__sidebar_drag__",type:r.type,position:O,measured:{width:1,height:1},internals:{positionAbsolute:O}};v(D,!1)},R=C=>{let O=C.relatedTarget;(!O||!C.currentTarget.contains(O))&&x()},M=(C,O)=>{C.preventDefault(),N(O)},B=(C,O,D)=>{var j,Z;let A=[...D],k=O.parentId?O.parentId:O.id;if(C.parentId===O.id)return A=bs(C,O,A),A=lo(A),A=Bo(k,A),T(A);if(C.type==="LANE"){if(Go({parentId:O.id,nodes:A,excludeTypes:["LANE"]})){let F=Ni(O),ne=50,le=50;return A.map(K=>{var Te,W;return K.id===C.id?w(b({},K),{position:{x:(Te=f==null?void 0:f.x)!=null?Te:F.x+ne,y:(W=f==null?void 0:f.y)!=null?W:F.y2+le}}):K})}let ee=A.filter(F=>F.parentId===O.id).reduce((F,ne)=>{var le,K;return F+((K=(le=ne.measured)==null?void 0:le.height)!=null?K:0)},0),ae={x:se.HEADER_WIDTH,y:ee};return A=A.map(F=>F.id===C.id?w(b({},F),{parentId:O.id,position:ae,className:void 0}):w(b({},F),{className:void 0})),A=lo(A),A=S(k,A),A}if(Go({parentId:O.id,nodes:A,includeTypes:["LANE"]})){let J;if(C.parentId){let q=s(C.parentId),{x:ee,y:ae}=It(q);J={x:ee+((j=C.position.x)!=null?j:0),y:ae+((Z=C.position.y)!=null?Z:0)}}return A=A.map(q=>q.id===C.id?w(b({},q),{position:J!=null?J:q.position,parentId:void 0,className:void 0}):w(b({},q),{className:void 0})),A=Bo(k,A),A}let L=Ra(C,O);A=A.map(J=>J.id===C.id?w(b({},J),{parentId:O.id,position:L,className:void 0}):w(b({},J),{className:void 0}));let V=A.find(J=>J.id===C.id);return A=bs(V,O,A),A=lo(A),A=Bo(k,A),A},X=C=>{if(C.preventDefault(),!(r!=null&&r.type))return;if(!vo(r.type,l())){m(!1),i(null);return}let O=d({x:C.clientX,y:C.clientY}),D={width:pe[r.type].MIN_WIDTH,height:pe[r.type].MIN_HEIGHT},A=p(),k={id:String(A),type:r.type,position:O,measured:D,data:{label:r.type==="TASK"?Qi(e,a("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},G=w(b({},k),{internals:{positionAbsolute:O}}),z=w(b({},G),{measured:{width:1,height:1}}),L=u(),V=r.type==="LANE",j=L.filter(F=>V?F.type==="LANE"&&!F.parentId:F.type==="LANE"),Z=Zn(z,j),J=[...L.map(F=>w(b({},F),{selected:!1})),G];Z&&(J=B(G,Z,J)),J=Ho(J),V&&!Z&&(J=S(G.id,J)),J=T(J),t(J),E();let q=C.dataTransfer.getData("sourceId"),ee=c(),ae=ee;if(q){let F={id:String(A+1),source:q,target:k.id},ne=r.type==="ANNOTATION"?b(b({},F),Mn):b(b({},F),St);ae=ee.concat(ne),o(ae)}n("forceSave",{nodes:J,edges:ae}),m(!1),i(null)},U=async(C,O,D)=>{let A=[...u()],k=new Set;D.forEach(L=>{let V=s(L.id),j=L.type==="LANE",Z=A.filter(q=>q.id!==L.id&&(j?q.type==="LANE"&&!q.parentId:q.type==="LANE")),J=Zn(V,Z);if(J){if(j&&Go({parentId:L.id,nodes:A,includeTypes:["LANE"]})){L.parentId&&(A=Y(L,A),k.add(L.id));return}A=B(V,J,A);return}L.parentId&&(A=Y(L,A),L.type==="LANE"&&k.add(L.id))}),A=_(A);let G=D.filter(L=>L.type==="LANE"&&!L.parentId).map(L=>L.id);for(let L of G)xs(L,A)&&f&&(A=A.map(V=>V.id===L?w(b({},V),{position:b({},f)}):V));for(let L of k)A=S(L,A);if(D.some(L=>L.type!=="LANE"&&!L.parentId)){let L=A.filter(V=>V.type==="LANE"&&!V.parentId).map(V=>V.id);for(let V of L)A=Bo(V,A)}A=Ho(A),A=T(A),t(A),g(A),h(null)},Q=(C,O)=>{h({x:O.position.x,y:O.position.y})},Y=(C,O)=>{var Z,J,q,ee,ae,F,ne,le;let D=s(C.parentId);if(!D)return O;let A=C.type==="LANE",k=O.filter(K=>K.parentId===D.id&&K.id!==C.id),G=k.filter(K=>K.type==="LANE"),z;if(A&&G.length===0)z=se.MIN_HEIGHT;else if(A){let K=(J=(Z=C.measured)==null?void 0:Z.height)!=null?J:se.MIN_HEIGHT;z=((ee=(q=D.measured)==null?void 0:q.height)!=null?ee:se.MIN_HEIGHT)-K,z=Math.max(se.MIN_HEIGHT,z)}else z=k.length>0?k.reduce((K,Te)=>{var W,te;return K+((te=(W=Te.measured)==null?void 0:W.height)!=null?te:0)},0)+De:Math.max(se.MIN_HEIGHT,(F=(ae=D.measured)==null?void 0:ae.height)!=null?F:0);let{x:L,y:V}=It(D),j={x:L+((ne=C.position.x)!=null?ne:0),y:V+((le=C.position.y)!=null?le:0)};return O=O.map(K=>K.id===C.id?w(b({},K),{position:j,parentId:void 0}):K.id===D.id?w(b({},K),{height:z,measured:w(b({},K.measured),{height:z})}):K),O=lo(O),O};return{onDragOver:P,onDragLeave:R,onDrop:X,onNodeDrag:M,onNodeDragStart:Q,onNodeDragStop:U}};var Bu=require("@xyflow/react"),zu=require("@produto-lecom/lecom-ui"),Yu=require("react");var Ih=30,Ah=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},Ch=e=>!Ah(e.target),Wu=({offset:e=Ih,saveHistory:t})=>{let{t:o}=(0,zu.useTranslation)(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=(0,Bu.useReactFlow)(),{getNextId:s}=Pt(),{mode:l}=$();(0,Yu.useEffect)(()=>{if(l!=="edit")return;let c=d=>{if(d.ctrlKey&&d.key.toLowerCase()==="d"&&Ch(d)){d.preventDefault(),d.stopPropagation();let p=n(),m=i(),u=p.filter(_=>_.selected);if(!u.length)return;let g=new Map,E=[],f=u.filter(_=>vo(_.type,p));if(f.length===0)return;let h=m.filter(_=>f.some(I=>I.id===_.source)&&f.some(I=>I.id===_.target)),y=s(),x=f.map(_=>{var P;let I=String(y++);g.set(_.id,I);let S=w(b({},_),{id:I,selected:!0,position:{x:_.position.x+e,y:_.position.y+e}});if(_.type==="TASK"){let R=(P=_.data)==null?void 0:P.label,M=On(R||o("bpmn.task.label.prefix"),[...p,...E]);S.data=w(b({},_.data),{label:M})}return E.push(S),S}),v=h.map(_=>w(b({},_),{id:String(y++),selected:!0,source:g.get(_.source)||_.source,target:g.get(_.target)||_.target})),N=[...p.map(_=>w(b({},_),{selected:!1})),...x],T=[...m.map(_=>w(b({},_),{selected:!1})),...v];r(N),a(T),t("forceSave",{nodes:N,edges:T})}};return document.addEventListener("keydown",c,!0),()=>{document.removeEventListener("keydown",c,!0)}},[n,r,i,a,s,e,o,t,l])};var Cr=require("react"),Fu=require("@xyflow/react");var Sh=20,Mh=50,Ar={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},Ph=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",i=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||i},Xu=e=>{let{getNodes:t}=(0,Fu.useReactFlow)(),{mode:o,isMoveTool:n}=$(),r=(0,Cr.useRef)(0),i=(0,Cr.useRef)(new Map);(0,Cr.useEffect)(()=>{let a=s=>{if(o!=="edit"||!n||Ph(s.target)||!Object.values(Ar).includes(s.key))return;let p=t().filter(y=>y.selected);if(p.length===0){i.current.clear();return}s.preventDefault();let m=Date.now(),u=m-r.current<500;r.current=m;let g=s.shiftKey?Mh:Sh,E=0,f=0;switch(s.key){case Ar.UP:f=-g;break;case Ar.DOWN:f=g;break;case Ar.LEFT:E=-g;break;case Ar.RIGHT:E=g;break}let h=p.map(y=>{let x=i.current.get(y.id);(!u||!x)&&(x={x:y.position.x,y:y.position.y});let v={x:x.x+E,y:x.y+f};return i.current.set(y.id,v),{id:y.id,dragging:!0,type:"position",position:v}});e&&e(h)};return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[t,e,o,n])};var Zu=require("@xyflow/react");var $u={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},Ku={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},Uu=(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}},Lh=e=>{e=e||"";let t=e.trim().split(`
|
|
42
|
+
`),o={},n=[];return t.forEach(r=>{r=r||"";let i=r.trim().split("-->");if(i.length!==2){console.warn("Invalid number of steps");return}let a=Uu(i[0],o),s=Uu(i[1],o);a&&s&&n.push({sourceId:a.step,targetId:s.step,label:a.edgeLabel||s.edgeLabel||""})}),{components:o,connections:n}},qu=e=>{let{components:t,connections:o}=Lh(e);return{nodes:t,edges:o}};var Ju=()=>{let{setNodes:e,setEdges:t,fitView:o}=(0,Zu.useReactFlow)(),{getNextId:n}=Pt();return{importFromLia:i=>{let a=typeof i=="string"?i:i.diagramXml||"",{nodes:s,edges:l}=qu(a),c=[],d=new Map,p=!1,m=n();for(let[f,h]of Object.entries(s)){let y=String(m++),x=$u[h.type],v=Ku[h.type];x==="START_EVENT"&&(p=!0),d.set(f,y);let N=pe[x].MIN_WIDTH,T=pe[x].MIN_HEIGHT;c.push({id:y,type:x,data:{label:h.label||"",variant:v,attribute:""},position:{x:0,y:0},width:N,height:T,measured:{width:N,height:T}})}let u=[];for(let f of l){let h=w(b({},St),{id:String(m++),source:d.get(f.sourceId)||f.sourceId,target:d.get(f.targetId)||f.targetId});u.push(h)}if(!p&&c.length>0){let f=String(m++),h={id:f,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:pe.START_EVENT.MIN_WIDTH,height:pe.START_EVENT.MIN_HEIGHT,measured:{width:pe.START_EVENT.MIN_WIDTH,height:pe.START_EVENT.MIN_HEIGHT}};c.unshift(h);let y=c[1];if(y){let x=w(b({},St),{id:String(m++),source:f,target:y.id});u.unshift(x)}}let{nodes:g,edges:E}=Ad(c,u);e(g),t(E),o({padding:Vn,minZoom:Hn,maxZoom:Gn})}}};var ns=require("react"),kh={origin:"*",debug:!1};function Qu(e,t=kh){let{origin:o,debug:n}=t,r=(0,ns.useCallback)((i,a)=>{let s={event:i,data:[i,{event:i,data:a}]};window.parent.postMessage(s,o||"*")},[o]);return(0,ns.useEffect)(()=>{let i=a=>{let s=a.data;if(!(s!=null&&s.event)||(s==null?void 0:s.data)===void 0)return;let{event:l,data:c}=s,d;if(Array.isArray(c)){let[,p]=c;d=p.data}else d=c;n&&(console.debug("[postMessage] received:",s),console.debug("[postMessage] eventData:",d)),l&&e[l]&&e[l](d)};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[e,n]),{sendMessage:r}}var ju=require("@xyflow/react"),na=require("react");var ep=()=>{let e=(0,ju.useNodesInitialized)(),{initialDiagram:t,setIsInitialized:o}=$(),{importFromMxGraph:n}=zn();(0,na.useEffect)(()=>{t&&n(t)},[t,n,o]),(0,na.useEffect)(()=>{if(!e)return;(async()=>{await Gr(),o(!0)})()},[e,o])};var ra=require("react"),tp=require("@xyflow/react");function op(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=Yo(),{getEdges:n}=(0,tp.useReactFlow)(),r=$r(),i=(0,ra.useCallback)(s=>{if(!(s!=null&&s.activities))return;e(s.activities);let l=s.activities.map(d=>d.diagramId),c=n();o(c,l),setTimeout(()=>{r()},0)},[e,o,n,r]),a=(0,ra.useCallback)(()=>{t(),setTimeout(()=>{r()},0)},[t,r]);return{handleTasksStatus:i,handleClearTaskStatus:a}}var rp=require("@xyflow/react"),tt=require("react"),ip=require("use-debounce");var Rh=500,np=100,sp=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=(0,rp.useReactFlow)(),{mode:i}=$(),[a,s]=(0,tt.useState)({history:[],currentStep:0}),{history:l,currentStep:c}=a,d=c>0,p=c<l.length-1,m=(0,tt.useCallback)((T,_)=>{n(T[_].nodes),r(T[_].edges)},[n,r]),u=(0,tt.useCallback)(()=>{if(c>0){let T=c-1;s(_=>w(b({},_),{currentStep:T})),m(l,T)}},[c,l,m]),g=(0,tt.useCallback)(()=>{if(c<l.length-1){let T=c+1;s(_=>w(b({},_),{currentStep:T})),m(l,T)}},[l,c,m]),E=(0,tt.useCallback)(T=>{s(_=>{let I=_.history[_.currentStep];if(I&&JSON.stringify(I)===JSON.stringify(T))return _;let R=[..._.history.slice(0,_.currentStep+1),T],M=R.length>np?R.slice(R.length-np):R;return{history:M,currentStep:M.length-1}})},[]),f=(0,tt.useCallback)((T,_)=>{let I=T.map(P=>w(b({},P),{selected:!1,className:"",data:w(b({},P.data),{hasError:!1})})),S=_.map(P=>w(b({},P),{data:w(b({},P.data),{hasError:!1})}));return{nodes:Ho(I),edges:S}},[]),h=(0,tt.useCallback)(()=>f(t(),o()),[t,o,f]),y=(0,ip.useDebouncedCallback)(()=>{let T=h();E(T)},Rh),x=(0,tt.useCallback)((T,_)=>{if(!e)return;if(l.length===0){let P=h();s({history:[P],currentStep:0})}if(T==="forceSave"){if(_){E(f(_.nodes,_.edges));return}y();return}T.some(P=>P.type==="select")||T.some(P=>P.type==="position"&&P.dragging)||y()},[e,y,l.length,h,E,f]);(0,tt.useEffect)(()=>{if(e&&l.length===0){let T=h();s({history:[T],currentStep:0})}},[e,l.length,h]);let v=(0,tt.useCallback)(T=>{s({history:T||[],currentStep:0})},[]),N=(0,tt.useCallback)(()=>{s({history:[],currentStep:0})},[]);return(0,tt.useEffect)(()=>{if(i!=="edit")return;let T=_=>{(_.ctrlKey||_.metaKey)&&(_.shiftKey&&_.key.toLowerCase()==="z"?(_.preventDefault(),g()):_.key.toLowerCase()==="z"&&(_.preventDefault(),u()))};return document.addEventListener("keydown",T),()=>{document.removeEventListener("keydown",T)}},[u,g,i]),{history:l,undo:u,redo:g,canUndo:d,canRedo:p,saveHistory:x,resetHistory:v,clearHistory:N}};var lp=()=>{let{t:e}=(0,ap.useTranslation)(),[t,o,n]=(0,Qt.useNodesState)([]),[r,i,a]=(0,Qt.useEdgesState)([]),{getNodes:s,getNode:l}=(0,Qt.useReactFlow)(),{toast:c}=st(),d=(0,Qt.useStoreApi)(),{instanceId:p,isInitialized:m,setIsConnecting:u,setIsMultipleSelection:g,onElementClick:E}=$(),{updateHelperLines:f,HelperLines:h}=wi(),{undo:y,redo:x,canUndo:v,canRedo:N,saveHistory:T}=sp(m),{onNodeDrag:_,onDrop:I,onDragOver:S,onDragLeave:P,onNodeDragStop:R,onNodeDragStart:M}=Gu({nodes:t,setNodes:o,setEdges:i,saveHistory:T}),{isValidConnection:B,onConnect:X,onReconnect:U,onReconnectStart:Q,onReconnectEnd:Y,setReconnectingEdge:C,clearReconnectingEdge:O}=xu({setEdges:i,saveHistory:T}),{handleValidationComplete:D,clearValidation:A,dismissValidationPanel:k,validateDiagram:G,getIsClearingValidation:z}=Su(),{importFromLia:L}=Ju(),{handleTasksStatus:V,handleClearTaskStatus:j}=op(),{clearPathEdges:Z}=Yo(),{emitElementChanges:J,handleNodeChanges:q,handleEdgeChanges:ee}=es(),ae=$r();Du({saveHistory:T}),Wu({saveHistory:T}),ep();let F=(0,Lt.useCallback)(()=>{o([]),i([]),Z(),setTimeout(ae,0)},[o,i,Z,ae]);Qu({LIA_CREATE_DIAGRAM:L,CLEAR_DIAGRAM:F,TASKS_STATUS:V,CLEAR_TASKS_STATUS:j});let{selectElements:ne,clearSelection:le}=wo(),{importFromMxGraph:K,exportToMxGraph:Te}=zn(),{configureElement:W,getConfigureElement:te}=Pi(),ce=(0,Lt.useCallback)(()=>t.length+r.length,[t,r]);(0,Lt.useEffect)(()=>(Kt.set(p,{importFromMxGraph:K,exportToMxGraph:Te,selectElements:ne,clearSelection:le,configureElement:W,getConfigureElement:te,getElementsCount:ce,setReconnectingEdge:C,clearReconnectingEdge:O}),()=>{Kt.delete(p)}),[p,K,Te,ne,le,W,te,ce,C,O]);let re=(0,Lt.useCallback)((Ae,Ee)=>{if(Ee.type!=="TASK"&&Ee.type!=="GATEWAY")return;let me=te(Ee.id);me&&(E==null||E(me))},[te,E]),fe=(0,Lt.useCallback)((Ae,Ee)=>{if(Ee.type!=="SEQUENCE_EDGE")return;let me=l(Ee.source),Le=l(Ee.target),{isFromStartEvent:ut,isGatewayToGateway:vt,isActiviyToAndGateway:nt,isToEndEvent:zt}=Fr(me,Le);if(!(!ut&&!vt&&!nt&&!zt))return;let oo=te(Ee.id);oo&&(E==null||E(oo))},[te,l,E]),ue=(0,Lt.useCallback)(Ae=>{let Ee=f(Ae,t);n(Ee),T(Ae),z()||k(),q(Ae)},[t,n,T,z,k,f,q]),Ne=(0,Lt.useCallback)(Ae=>{a(Ae),T(Ae),z()||k(),ee(Ae)},[a,T,z,k,ee]);Xu(ue);let Fe=(0,Lt.useCallback)(({nodes:Ae,edges:Ee})=>{g(Ae.length+Ee.length>=2)},[g]);(0,Qt.useOnSelectionChange)({onChange:Fe});let Qe=(0,Lt.useCallback)(async({nodes:Ae})=>Ae.some(me=>me.type==="LANE"&&t.some(Le=>Le.parentId===me.id))?(c({variant:"error",title:e("validation.errors.title"),content:e("editor.toolbar.delete_pool_lane_error")}),!1):!0,[t,e,c]),ot=()=>{T("forceSave"),J(),k()},ct=()=>{u(!0)},Bt=()=>{u(!1),k()},dt=(0,Lt.useCallback)(Ae=>{let Ee=new Set(Ae.filter(me=>me.type==="LANE"&&!!me.parentId).map(me=>me.parentId));Ee.size!==0&&setTimeout(()=>{var ut,vt;let me=s(),Le=new Map(me.map(nt=>[nt.id,nt]));for(let nt of Ee){let zt=zo(me.filter(no=>no.type==="LANE"&&no.parentId===nt));if(zt.length===0)continue;let go=0;for(let no of zt)Le.set(no.id,w(b({},no),{position:{x:se.HEADER_WIDTH,y:go}})),go+=(vt=(ut=no.measured)==null?void 0:ut.height)!=null?vt:0;let oo=Le.get(nt);oo&&Le.set(nt,w(b({},oo),{height:go,measured:w(b({},oo.measured),{height:go})}))}o(me.map(nt=>{var zt;return(zt=Le.get(nt.id))!=null?zt:nt}))},0)},[s,o]);return{nodes:t,setNodes:o,edges:r,setEdges:i,events:{isValidConnection:B,onConnect:X,onReconnect:U,onReconnectStart:Q,onReconnectEnd:Y,onDrop:I,onDragOver:S,onDragLeave:P,onNodeDrag:_,onNodeDragStop:R,onNodeDragStart:M,onNodeClick:re,onEdgeClick:fe,onDropCapture:ot,onConnectStart:ct,onConnectEnd:Bt,onSelectionEnd:()=>setTimeout(()=>d.setState({nodesSelectionActive:!1}),0),onNodesChange:ue,onEdgesChange:Ne,onBeforeDelete:Qe,onNodesDelete:dt},ui:{handleCloseValidationPanel:A},controls:{undo:y,redo:x,canUndo:v,canRedo:N},components:{HelperLines:h},actions:{saveHistory:T,selectElements:ne,clearSelection:le,exportToMxGraph:Te,validateDiagram:G,handleValidationComplete:D,setReconnectingEdge:C,clearReconnectingEdge:O}}};var cp=require("@xyflow/react"),Mo=require("react");var Dh=".react-flow__node, .react-flow__edge, .react-flow__node-toolbar";function dp(e,t,o){let[n,r]=(0,Mo.useState)(!1),i=(0,Mo.useRef)(null),{getViewport:a,setViewport:s}=(0,cp.useReactFlow)(),l=(0,Mo.useCallback)(()=>{i.current=null,r(!1)},[]);return(0,Mo.useEffect)(()=>{let c=e.current;if(!c)return;let d=u=>{if(!Tr.some(E=>E===u.button)||t.current||o.current||(r(!0),!(u.target instanceof Element))||!u.target.closest(Dh))return;u.preventDefault(),u.stopPropagation();let g=a();i.current={pointerX:u.clientX,pointerY:u.clientY,viewportX:g.x,viewportY:g.y,zoom:g.zoom}},p=u=>{let g=i.current;if(g){if((u.buttons&ea)===0){l();return}s({x:g.viewportX+(u.clientX-g.pointerX),y:g.viewportY+(u.clientY-g.pointerY),zoom:g.zoom})}},m=u=>{(u.buttons&ea)===0&&l()};return c.addEventListener("pointerdown",d,!0),window.addEventListener("pointermove",p),window.addEventListener("pointerup",m),window.addEventListener("pointercancel",l),window.addEventListener("blur",l),()=>{c.removeEventListener("pointerdown",d,!0),window.removeEventListener("pointermove",p),window.removeEventListener("pointerup",m),window.removeEventListener("pointercancel",l),window.removeEventListener("blur",l)}},[e,t,o,a,s,l]),n}var ia=require("react/jsx-runtime"),rs=({id:e,className:t})=>(0,ia.jsx)("marker",{id:e,className:H("react-flow__arrowhead",t),viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"7",markerHeight:"7",orient:"auto",markerUnits:"userSpaceOnUse",fill:"currentColor",stroke:"currentColor",children:(0,ia.jsx)("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});var on=require("react/jsx-runtime"),up=()=>(0,on.jsx)("svg",{style:{position:"absolute",top:0,left:0},children:(0,on.jsxs)("defs",{children:[(0,on.jsx)(rs,{id:"sequence-edge-marker",className:"text-grey-500"}),(0,on.jsx)(rs,{id:"sequence-edge-marker-hovered",className:"text-grey-800"}),(0,on.jsx)(rs,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});var Ro=require("@produto-lecom/lecom-ui");var Pr=require("@xyflow/react"),Ve=require("@produto-lecom/lecom-ui"),jt=require("lucide-react"),mo=require("react");var Po=require("@produto-lecom/lecom-ui");var Sr=(x=>(x.START_EVENT="START_EVENT",x.END_EVENT="END_EVENT",x.TASK="TASK",x.SUBPROCESS="SUBPROCESS",x.GATEWAY="GATEWAY",x.LANE="LANE",x.ANNOTATION="ANNOTATION",x.CONNECTION="CONNECTION",x.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",x.ACTIVITY="ACTIVITY",x.PROCESS_INTERFACE="PROCESS_INTERFACE",x.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",x.VARIANT_ACTIVITY="VARIANT_ACTIVITY",x.AUTO_ACTIVITY="AUTO_ACTIVITY",x.DATA_STORE="DATA_STORE",x.DATA_OBJECT="DATA_OBJECT",x.DATA_OUTPUT="DATA_OUTPUT",x.DATA_INPUT="DATA_INPUT",x.MARKER="MARKER",x))(Sr||{});var ss=require("@produto-lecom/lecom-ui"),Np=require("@xyflow/react");var pp=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 fp({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let r="data:text/csv;charset=utf-8,"+[e,...t].map(a=>a.join(",")).join(`
|
|
43
|
+
`),i=encodeURI(r);is(i,`${o}.csv`)}var is=(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 mp(e){return e==null?void 0:e.replaceAll("
"," ")}var AS={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},gp={script:"SCRIPT",subprocess:"SUBPROCESS"},hp={"marker-loop":"LOOP"},yp={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL",inclusive:"EXCLUSIVE"};var nn=({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}}},Vh=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=pe.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=pe.START_EVENT.MIN_HEIGHT,{node:nn({cell:e,type:"START_EVENT"}),status:n,originalType:o}},Hh=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=pe.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=pe.END_EVENT.MIN_HEIGHT,{node:nn({cell:e,type:"END_EVENT"}),status:n,originalType:o}},Gh=(e,t)=>{let{id:o,subType:n,style:r}=e==null?void 0:e._attributes,i=gp[n],a=t.get(o)||"",s=hp[a]||"",l=s==="LOOP",c="imported";return!["script","none"].includes(n)&&!l&&(c="adapted"),e.mxGeometry._attributes.width=yo(e.mxGeometry._attributes.width||0,pe.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=yo(e.mxGeometry._attributes.height||0,pe.TASK.MIN_HEIGHT),{node:nn({cell:e,type:"TASK",variant:i,attribute:s}),status:c,originalType:r}},Bh=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=yp[o],r=["none","inclusive","event-based"],i="imported";return r.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=pe.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=pe.GATEWAY.MIN_HEIGHT,{node:nn({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},zh=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:nn({cell:e,type:"LANE"}),status:"imported",originalType:t}},Yh=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=yo(e.mxGeometry._attributes.width||0,pe.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=yo(e.mxGeometry._attributes.height||0,pe.ANNOTATION.MIN_HEIGHT),{node:nn({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},xp=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=pe.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=pe.UNSUPPORTED.MIN_HEIGHT,{node:nn({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},Ep=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return w(b({},St),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},bp={TASK:Gh,GATEWAY:Bh,START_EVENT:Vh,END_EVENT:Hh,LANE:zh,ANNOTATION:Yh};var Wh=e=>{let t=new Map,o=Object.values(Sr),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=bp[l]||xp,{node:d,status:p,originalType:m}=c(s,r);a.push(d),i.push({originalType:m,type:d.type,variant:d.data.variant,value:mp(d.data.label),status:p})}return{nodes:a,governanceIdToNodeIdMap:t,summary:i}},Fh=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>Ep(r,t)),Xh=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=Wh(t.root.mxCell),i=Fh(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},Uh=async e=>{let t=await pp(e),o=Wi(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}},_p=async e=>{try{let t=await Uh(e),{nodes:o,edges:n,summary:r}=Xh(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};var vp=require("react/jsx-runtime"),Tp=()=>{let{t:e}=(0,ss.useTranslation)(),{toast:t}=st(),{setNodes:o,setEdges:n,fitView:r}=(0,Np.useReactFlow)(),i=s=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],c=s.map(d=>[d.originalType,d.value,e(`adapter.governance.report.status.${d.status.toLowerCase()}`)]);t({variant:"warning",content:e("adapter.governance.success.incompatible_cells"),duration:1e3*60*1,action:(0,vp.jsx)(ss.Button,{size:"small",variant:"ghost",onClick:()=>fp({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 _p(s);if(o(m=>m.concat(l)),n(m=>m.concat(c)),r({padding:Vn,minZoom:Hn,maxZoom:Gn}),d.some(m=>m.status==="unsupported")){i(d);return}t({variant:"success",content:e("adapter.governance.success.default")})}catch(l){let c=l instanceof Error?l.message:"DEFAULT";t({variant:"error",content:e(`adapter.governance.error.${c}`)})}}}};var wp=require("@produto-lecom/lecom-ui"),Ip=require("react");var rn=require("react/jsx-runtime"),Ap=s=>{var l=s,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,a=Yt(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=(0,Ip.useRef)(null),d=m=>{let u=m.target.files;u!=null&&u.length&&i(u),c.current&&(c.current.value="")};return(0,rn.jsxs)(rn.Fragment,{children:[(0,rn.jsx)(wp.Button,w(b({disabled:n,onClick:m=>{var u;(u=c.current)==null||u.click(),r==null||r(m)}},a),{children:e})),(0,rn.jsx)("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};var sn=require("react/jsx-runtime"),Cp=({disabled:e=!1})=>{let{t}=(0,Po.useTranslation)(),{toast:o}=st(),{importFromGovernance:n}=Tp(),r=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},i=a=>{let s=a[0];if(!s){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}n(s)};return(0,sn.jsxs)(Po.Tooltip,{children:[(0,sn.jsx)(Po.TooltipTrigger,{asChild:!0,children:(0,sn.jsx)(Ap,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:(0,sn.jsx)(_a,{})})}),(0,sn.jsx)(Po.TooltipContent,{color:"black",children:t("editor.controls.actions.import_governance")})]})};var Sp=require("react/jsx-runtime"),sa=({shortcut:e})=>(0,Sp.jsx)("span",{className:"min-h-7.5 inline-flex justify-center items-center py-0.5 px-1.5 bg-grey-100 border border-grey-300 font-mono text-gray-800 shadow-lg rounded-md text-grey-900",children:e});var _e=require("@produto-lecom/lecom-ui"),Lo=require("lucide-react"),Dp=require("react");var Pp=require("@produto-lecom/lecom-ui"),Lp=require("@xyflow/react"),Mr=require("html-to-image"),kp=require("react");var $h=3,aa="diagram",as=50,Kh=96,qh=25.4,Mp=e=>e*qh/Kh,Rp=()=>{let{t:e}=(0,Pp.useTranslation)(),{toast:t}=st(),{getNodes:o,getNodesBounds:n}=(0,Lp.useReactFlow)(),{clearSelection:r}=wo(),[i,a]=(0,kp.useState)({png:!1,html:!1,print:!1}),s=()=>{let m=Us(o()),u=n(m),g=u.width+as*2,E=u.height+as*2,f=as-u.x,h=as-u.y;return{width:g,height:E,style:{width:`${g}px`,height:`${E}px`,transform:`translate(${f}px, ${h}px)`,transformOrigin:"top left"}}},l=async(m,u)=>{a(g=>w(b({},g),{[u]:!0})),await r();try{if(Us(o()).length===0){t({content:e("editor.controls.actions.export.feedback.empty"),variant:"warning"});return}let E=Sd();if(!E)throw new Error("Flow element not found");let f=s();return await m(E,f)}catch(g){console.error("Diagram export failed",g),t({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{a(g=>w(b({},g),{[u]:!1}))}};return{exportAsPng:async(m=aa)=>{await l(async(u,g)=>{let E=await(0,Mr.toPng)(u,w(b({},g),{backgroundColor:"#fcfcfc",skipFonts:!0}));is(E,`${m}.png`)},"png")},exportAsHtml:async(m=aa)=>{await l(async(u,g)=>{let E=await(0,Mr.toSvg)(u,w(b({},g),{backgroundColor:"#fcfcfc",skipFonts:!0})),f=`
|
|
44
44
|
<!DOCTYPE html>
|
|
45
45
|
<html>
|
|
46
46
|
<head>
|
|
@@ -65,11 +65,11 @@
|
|
|
65
65
|
</style>
|
|
66
66
|
</head>
|
|
67
67
|
<body>
|
|
68
|
-
<img src="${
|
|
68
|
+
<img src="${E}" alt="${m}" />
|
|
69
69
|
</body>
|
|
70
|
-
</html>`,h=new Blob([f],{type:"text/html"}),
|
|
70
|
+
</html>`,h=new Blob([f],{type:"text/html"}),y=URL.createObjectURL(h);is(y,`${m}.html`),window.setTimeout(()=>URL.revokeObjectURL(y),1e4)},"html")},printDiagram:async(m=aa)=>{await l(async(u,g)=>{var I;let E=await(0,Mr.toPng)(u,w(b({},g),{backgroundColor:"#fcfcfc",pixelRatio:$h,skipFonts:!0})),f=document.createElement("iframe");f.style.position="fixed",f.style.right="0",f.style.bottom="0",f.style.width="0",f.style.height="0",f.style.border="0",document.body.appendChild(f);let h=(I=f.contentWindow)==null?void 0:I.document;if(!h)throw document.body.removeChild(f),new Error("Unable to access print iframe document");let y=Mp(g.width).toFixed(2),x=Mp(g.height).toFixed(2),v=h.createElement("style");v.textContent=`
|
|
71
71
|
@page {
|
|
72
|
-
size: ${
|
|
72
|
+
size: ${y}mm ${x}mm;
|
|
73
73
|
margin: 0;
|
|
74
74
|
}
|
|
75
75
|
html, body {
|
|
@@ -83,4 +83,4 @@
|
|
|
83
83
|
height: 100%;
|
|
84
84
|
object-fit: contain;
|
|
85
85
|
}
|
|
86
|
-
`,h.head.appendChild(T),h.title=m;let E=h.createElement("img");E.alt="Diagram",h.body.appendChild(E),await new Promise((A,R)=>{let G=!1,M=P=>{G||(G=!0,P?R(P):A())};E.onload=()=>M(),E.onerror=()=>M(new Error("Failed to load print image")),E.src=x,E.complete&&E.naturalWidth>0&&M()});let y=f.contentWindow;if(!y)throw document.body.removeChild(f),new Error("Unable to access print iframe window");let w=()=>{f.parentNode&&document.body.removeChild(f)};y.addEventListener("afterprint",w,{once:!0}),window.setTimeout(w,6e4),y.focus(),y.print()},"print")},isPrintingPng:i.png,isPrintingHtml:i.html,isPrinting:i.print}};var Ie=require("react/jsx-runtime");function Rp(){let{t:e}=(0,_e.useTranslation)(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:a}=Lp(),[s,l]=(0,kp.useState)(!1);return(0,Ie.jsxs)(_e.DropdownMenu,{modal:!1,open:s,onOpenChange:l,children:[(0,Ie.jsx)(_e.DropdownMenuTrigger,{asChild:!0,children:(0,Ie.jsx)("div",{children:(0,Ie.jsxs)(_e.Tooltip,{children:[(0,Ie.jsx)(_e.TooltipTrigger,{asChild:!0,children:(0,Ie.jsx)(_e.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:(0,Ie.jsx)(So.FolderOutputIcon,{})})}),!s&&(0,Ie.jsx)(_e.TooltipContent,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),(0,Ie.jsxs)(_e.DropdownMenuContent,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[(0,Ie.jsxs)(_e.Tooltip,{children:[(0,Ie.jsx)(_e.TooltipTrigger,{asChild:!0,children:(0,Ie.jsx)(_e.DropdownMenuItem,{className:"p-1.5",disabled:i,onClick:()=>t(),children:(0,Ie.jsx)(So.FileImageIcon,{})})}),(0,Ie.jsx)(_e.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),(0,Ie.jsxs)(_e.Tooltip,{children:[(0,Ie.jsx)(_e.TooltipTrigger,{asChild:!0,children:(0,Ie.jsx)(_e.DropdownMenuItem,{className:"p-1.5",disabled:a,onClick:()=>o(),children:(0,Ie.jsx)(So.FileCodeIcon,{})})}),(0,Ie.jsx)(_e.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),(0,Ie.jsxs)(_e.Tooltip,{children:[(0,Ie.jsx)(_e.TooltipTrigger,{asChild:!0,children:(0,Ie.jsx)(_e.DropdownMenuItem,{className:"p-1.5",disabled:r,onClick:()=>n(),children:(0,Ie.jsx)(So.PrinterIcon,{})})}),(0,Ie.jsx)(_e.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}var he=require("react/jsx-runtime"),Dp=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=(0,Ve.useTranslation)(),{clearSelection:i}=No(),{mode:a,isMinimapOpen:s,setIsMinimapOpen:l,isMoveTool:c,isHandTool:d,setIsMoveTool:u,setIsHandTool:m}=q(),{getNodes:p,getEdges:g}=(0,Sr.useReactFlow)(),x=(0,Sr.useKeyPress)(["v","V"]),f=(0,Sr.useKeyPress)(["h","H"]),h=(0,fo.useCallback)(()=>{i(),m(!0),u(!1)},[i,m,u]),_=(0,fo.useCallback)(()=>{u(!0),m(!1)},[u,m]),[b,T]=(0,fo.useState)(!1),E=(0,fo.useCallback)(async()=>{T(!0);try{let y=p(),w=g(),C=await o({nodes:y,edges:w});n(C)}finally{T(!1)}},[p,g,o,n]);return(0,fo.useEffect)(()=>{x&&!c&&a==="edit"&&_()},[x,_,c,a]),(0,fo.useEffect)(()=>{f&&!d&&a==="edit"&&h()},[f,h,d,a]),(0,he.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[a==="edit"&&(0,he.jsxs)(he.Fragment,{children:[(0,he.jsxs)(Ve.Tooltip,{children:[(0,he.jsx)(Ve.TooltipTrigger,{asChild:!0,children:(0,he.jsx)(Ve.Button,{size:"small",variant:"ghost",color:"grey",className:H(c&&"bg-grey-400"),iconButton:!0,onClick:_,children:(0,he.jsx)(jt.MousePointerIcon,{})})}),(0,he.jsxs)(Ve.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),(0,he.jsx)(ra,{shortcut:"V"})]})]}),(0,he.jsxs)(Ve.Tooltip,{children:[(0,he.jsx)(Ve.TooltipTrigger,{asChild:!0,children:(0,he.jsx)(Ve.Button,{size:"small",variant:"ghost",color:"grey",className:H(d&&"bg-grey-400"),iconButton:!0,onClick:h,children:(0,he.jsx)(jt.HandIcon,{})})}),(0,he.jsxs)(Ve.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",(0,he.jsx)(ra,{shortcut:"H"})]})]})]}),(0,he.jsx)(Rp,{}),a==="edit"&&(0,he.jsxs)(he.Fragment,{children:[(0,he.jsxs)(Ve.Tooltip,{children:[(0,he.jsx)(Ve.TooltipTrigger,{asChild:!0,children:(0,he.jsx)(Ve.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:b,onClick:E,children:b?(0,he.jsx)(jt.Loader2Icon,{className:"animate-spin"}):(0,he.jsx)(jt.ListCheckIcon,{})})}),(0,he.jsx)(Ve.TooltipContent,{color:"black",children:r(b?"editor.controls.actions.check_loading":"editor.controls.actions.check")})]}),(0,he.jsx)(Ip,{disabled:e.length>0||t.length>0})]}),(0,he.jsxs)(Ve.Tooltip,{children:[(0,he.jsx)(Ve.TooltipTrigger,{asChild:!0,children:(0,he.jsx)(Ve.Button,{size:"small",variant:"ghost",color:"grey",className:H(s&&"bg-grey-400"),iconButton:!0,onClick:()=>l(!s),children:(0,he.jsx)(jt.MapIcon,{})})}),(0,he.jsx)(Ve.TooltipContent,{color:"black",children:r(s?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};var lt=require("@produto-lecom/lecom-ui"),ss=require("lucide-react"),Tt=require("react/jsx-runtime"),Op=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=(0,lt.useTranslation)();return(0,Tt.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,Tt.jsxs)(lt.Tooltip,{children:[(0,Tt.jsx)(lt.TooltipTrigger,{asChild:!0,children:(0,Tt.jsx)(lt.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:(0,Tt.jsx)(ss.UndoIcon,{})})}),(0,Tt.jsx)(lt.TooltipContent,{color:"black",children:r("editor.controls.history.undo")})]}),(0,Tt.jsxs)(lt.Tooltip,{children:[(0,Tt.jsx)(lt.TooltipTrigger,{asChild:!0,children:(0,Tt.jsx)(lt.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:(0,Tt.jsx)(ss.RedoIcon,{})})}),(0,Tt.jsx)(lt.TooltipContent,{color:"black",children:r("editor.controls.history.redo")})]})]})};var Bn=require("@xyflow/react"),He=require("@produto-lecom/lecom-ui"),zn=require("lucide-react");var Re=require("react/jsx-runtime"),Vp=()=>{let{t:e}=(0,He.useTranslation)(),t=(0,Bn.useNodes)(),o=(0,Bn.useEdges)(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:a}=(0,Bn.useReactFlow)(),s=t.length===0&&o.length===0;return(0,Re.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,Re.jsxs)(He.Tooltip,{children:[(0,Re.jsx)(He.TooltipTrigger,{asChild:!0,children:(0,Re.jsx)(He.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>a(),children:(0,Re.jsx)(zn.ScanIcon,{})})}),(0,Re.jsx)(He.TooltipContent,{color:"black",children:e("editor.controls.zoom.fit")})]}),(0,Re.jsxs)(He.Tooltip,{children:[(0,Re.jsx)(He.TooltipTrigger,{asChild:!0,children:(0,Re.jsx)(He.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>r(),children:(0,Re.jsx)(zn.ZoomOut,{})})}),(0,Re.jsx)(He.TooltipContent,{color:"black",children:e("editor.controls.zoom.out")})]}),(0,Re.jsxs)(He.Tooltip,{children:[(0,Re.jsx)(He.TooltipTrigger,{asChild:!0,children:(0,Re.jsx)(He.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>i(1),children:(0,Re.jsx)(Ta,{})})}),(0,Re.jsx)(He.TooltipContent,{color:"black",children:e("editor.controls.zoom.reset")})]}),(0,Re.jsxs)(He.Tooltip,{children:[(0,Re.jsx)(He.TooltipTrigger,{asChild:!0,children:(0,Re.jsx)(He.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>n(),children:(0,Re.jsx)(zn.ZoomIn,{})})}),(0,Re.jsx)(He.TooltipContent,{color:"black",children:e("editor.controls.zoom.in")})]})]})};var Hp=require("@xyflow/react"),eo=require("@produto-lecom/lecom-ui"),as=require("react");var Gt=require("react/jsx-runtime"),Gp=()=>{let e=(0,as.useRef)(null),{t}=(0,eo.useTranslation)(),{setDraggableNode:o}=kn(),n=(0,Hp.useNodes)(),{setIsDragging:r}=q(),[i,a]=(0,as.useState)(void 0),s=[{type:"START_EVENT",icon:Gr,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:rn,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:Un,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:Ia,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:wa,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:va,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:ln,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:dn,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:sn,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:Na,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:Or,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),a((0,Gt.jsx)(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return(0,Gt.jsxs)("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[(0,Gt.jsx)("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:s.map((c,d)=>{let u=!_o(c.type,n),m=u?t("editor.toolbar.start_event_already_exists"):c.label;return(0,Gt.jsxs)(eo.Tooltip,{children:[(0,Gt.jsx)(eo.TooltipTrigger,{asChild:!0,children:(0,Gt.jsx)(eo.Button,{className:H("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":u}),size:"small",variant:"ghost",color:"grey",draggable:!u,disabled:u,iconButton:!0,onDragStart:u?void 0:p=>l(p,c),children:(0,Gt.jsx)(c.icon,{})},d)}),(0,Gt.jsx)(eo.TooltipContent,{color:"black",side:"right",children:m})]},d)})}),(0,Gt.jsx)("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};var qe=require("react/jsx-runtime"),sa=e=>e.preventDefault(),aa=(0,Mo.forwardRef)((e,t)=>{let o=(0,to.useKeyPress)("Space"),{instanceId:n,mode:r,isMinimapOpen:i,isMoveTool:a,isHandTool:s}=q(),l=(0,Mo.useRef)(null),c=(0,Mo.useRef)(s),d=(0,Mo.useRef)(o),{nodes:u,edges:m,actions:p,events:g,components:x,controls:f}=sp(),{t:h}=(0,Po.useTranslation)();c.current=s,d.current=o;let _=lp(l,c,d);(0,Mo.useImperativeHandle)(t,()=>({selectElements:p.selectElements,clearSelection:p.clearSelection}));let b=s||o||r!=="edit",T=b?[0,1,2]:_r,E=s||o||_,y=a&&!o&&!_,w=r==="edit"&&y,C=!b&&!_,A=r==="view"||y;return(0,qe.jsxs)("div",{ref:l,className:"w-full h-full",children:[r==="edit"&&(0,qe.jsx)(Gp,{}),(0,qe.jsx)(cp,{}),(0,qe.jsxs)(to.ReactFlow,v(N({},g),{id:`modeler-${n}`,className:H({"is-hand-tool":E,"is-pan-tool-active":E}),edges:m,nodes:u,nodeTypes:nu,edgeTypes:ru,minZoom:Js,maxZoom:du,panOnDrag:T,panOnScroll:!0,selectionOnDrag:C,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:A,nodesConnectable:w,nodesDraggable:w,connectionLineComponent:eu,selectionMode:to.SelectionMode.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:w?"Delete":null,selectionKeyCode:null,defaultViewport:uu,connectOnClick:!1,connectionRadius:50,onPaneContextMenu:sa,onNodeContextMenu:sa,onEdgeContextMenu:sa,proOptions:{hideAttribution:!0},children:[(0,qe.jsx)(to.Background,{gap:lu,size:au,color:su,bgColor:iu}),i&&(0,qe.jsxs)(Po.Tooltip,{children:[(0,qe.jsx)(Po.TooltipTrigger,{asChild:!0,children:(0,qe.jsx)("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:(0,qe.jsx)(to.MiniMap,{pannable:!0,zoomable:!0,position:cu,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),(0,qe.jsx)(Po.TooltipContent,{color:"black",children:h("editor.controls.actions.minimap.label")})]}),(0,qe.jsxs)("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&(0,qe.jsx)(Op,N({},f)),(0,qe.jsx)(Dp,{nodes:u,edges:m,validateDiagram:p.validateDiagram,handleValidationComplete:p.handleValidationComplete}),(0,qe.jsx)(Vp,{})]}),(0,qe.jsx)(x.HelperLines,{})]}))]})});aa.displayName="Editor";var Bp=require("@xyflow/react"),ls=require("react"),zp=require("react/jsx-runtime"),$h=e=>({width:e.width,height:e.height,transform:e.transform}),la="rgba(51, 103, 217, 0.4)",Hc=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=(0,Bp.useStore)($h),i=(0,ls.useRef)(null);return(0,ls.useEffect)(()=>{let a=i.current,s=a==null?void 0:a.getContext("2d");if(!s||!a)return;let l=window.devicePixelRatio;a.width=o*l,a.height=n*l,s.clearRect(0,0,o,n),s.scale(l,l),s.strokeStyle=la,t&&(s.beginPath(),s.strokeStyle=t.color||la,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||la,s.moveTo(0,e.position*r[2]+r[1]),s.lineTo(o,e.position*r[2]+r[1]),s.stroke())},[o,n,r,e,t]),(0,zp.jsx)("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};var Yn=require("@produto-lecom/lecom-ui"),Lo=require("react");var Mr=require("react/jsx-runtime"),Kt=new Map,Yp=(0,Lo.createContext)(null),Tn=()=>{let e=(0,Lo.useContext)(Yp);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},Wp=({locale:e,defaultMode:t="view",toast:o,children:n})=>{let[r,i]=(0,Lo.useState)(e||"pt_BR");(0,Lo.useEffect)(()=>{e&&(i(e),Yn.i18n.changeLanguage(e))},[e]);let a=g=>{let x=Kt.size;if(x===0)throw new Error("No modeler instances found");if(x===1||!g){let[h]=Kt.values();return h}let f=Kt.get(g);if(!f)throw new Error(`Modeler instance with ID "${g}" not found`);return f},s=(g,x)=>{let f=a(x);return f==null?void 0:f.selectElements(g)},l=async g=>{let x=a(g);return x==null?void 0:x.clearSelection()},c=(g,x)=>{let f=a(x);return f==null?void 0:f.configureElement(g)},d=(g,x)=>{let f=a(x);return f==null?void 0:f.getConfigureElement(g)},u=async(g,x)=>{let f=a(x);await(f==null?void 0:f.importFromMxGraph(g))},m=g=>{let x=a(g);return x==null?void 0:x.exportToMxGraph()},p=g=>{let x=a(g);return(x==null?void 0:x.getElementsCount())||0};return(0,Mr.jsx)(Yp.Provider,{value:{defaultMode:t,locale:r,selectElements:s,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:u,exportDiagram:m,getElementsCount:p,toast:o},children:(0,Mr.jsxs)(Yn.TooltipProvider,{children:[!o&&(0,Mr.jsx)(Yn.Notification,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};var cs=require("react/jsx-runtime"),Up=(0,Ge.createContext)(null),q=()=>{let e=(0,Ge.useContext)(Up);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},$p=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,validateCustomDiagram:r,onElementChanges:i,onConfigureElement:a,onElementClick:s,onSubprocessValidationClick:l})=>{let{t:c}=(0,Fp.useTranslation)(),{defaultMode:d}=Tn(),u=(0,Ge.useId)(),[m]=(0,Ge.useState)(o||u),[p,g]=(0,Ge.useState)(n||d||"edit"),[x,f]=(0,Ge.useState)(fr),[h,_]=(0,Ge.useState)(!1),[b,T]=(0,Ge.useState)(!0),[E,y]=(0,Ge.useState)(!1),[w,C]=(0,Ge.useState)(!1),[A,R]=(0,Ge.useState)(!1),[G,M]=(0,Ge.useState)(!1),[P,X]=(0,Ge.useState)(!1),[$,Z]=(0,Ge.useState)(null);(0,Ge.useEffect)(()=>{n&&g(n)},[n]);let Y=(0,Ge.useMemo)(()=>t||Cd(c),[t,c]),S={instanceId:m,initialDiagram:Y,mode:p,lastElementId:x,isInitialized:h,isMinimapOpen:w,isMoveTool:b,isHandTool:E,isDragging:A,isMultipleSelection:P,isConnecting:G,setLastElementId:f,setIsInitialized:_,reconnectingEdgeId:$,setIsMinimapOpen:C,setIsMoveTool:T,setIsHandTool:y,setIsDragging:R,setIsConnecting:M,setIsMultipleSelection:X,setReconnectingEdgeId:Z,validateCustomDiagram:r,onElementChanges:i,onConfigureElement:a,onElementClick:s,onSubprocessValidationClick:l};return(0,cs.jsx)(Xp.ReactFlowProvider,{children:(0,cs.jsx)(Up.Provider,{value:S,children:(0,cs.jsx)(aa,{ref:e})})})};0&&(module.exports={EditorMode,ElementPosition,ElementType,GatewayElementVariant,GatewayVariant,Modeler,ModelerProvider,NodeAttribute,NodeType,NodeVariant,RoutingVariant,useModeler});
|
|
86
|
+
`,h.head.appendChild(v),h.title=m;let N=h.createElement("img");N.alt="Diagram",h.body.appendChild(N),await new Promise((S,P)=>{let R=!1,M=B=>{R||(R=!0,B?P(B):S())};N.onload=()=>M(),N.onerror=()=>M(new Error("Failed to load print image")),N.src=E,N.complete&&N.naturalWidth>0&&M()});let T=f.contentWindow;if(!T)throw document.body.removeChild(f),new Error("Unable to access print iframe window");let _=()=>{f.parentNode&&document.body.removeChild(f)};T.addEventListener("afterprint",_,{once:!0}),window.setTimeout(_,6e4),T.focus(),T.print()},"print")},isPrintingPng:i.png,isPrintingHtml:i.html,isPrinting:i.print}};var Ie=require("react/jsx-runtime");function Op(){let{t:e}=(0,_e.useTranslation)(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:a}=Rp(),[s,l]=(0,Dp.useState)(!1);return(0,Ie.jsxs)(_e.DropdownMenu,{modal:!1,open:s,onOpenChange:l,children:[(0,Ie.jsx)(_e.DropdownMenuTrigger,{asChild:!0,children:(0,Ie.jsx)("div",{children:(0,Ie.jsxs)(_e.Tooltip,{children:[(0,Ie.jsx)(_e.TooltipTrigger,{asChild:!0,children:(0,Ie.jsx)(_e.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:(0,Ie.jsx)(Lo.FolderOutputIcon,{})})}),!s&&(0,Ie.jsx)(_e.TooltipContent,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),(0,Ie.jsxs)(_e.DropdownMenuContent,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[(0,Ie.jsxs)(_e.Tooltip,{children:[(0,Ie.jsx)(_e.TooltipTrigger,{asChild:!0,children:(0,Ie.jsx)(_e.DropdownMenuItem,{className:"p-1.5",disabled:i,onClick:()=>t(),children:(0,Ie.jsx)(Lo.FileImageIcon,{})})}),(0,Ie.jsx)(_e.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),(0,Ie.jsxs)(_e.Tooltip,{children:[(0,Ie.jsx)(_e.TooltipTrigger,{asChild:!0,children:(0,Ie.jsx)(_e.DropdownMenuItem,{className:"p-1.5",disabled:a,onClick:()=>o(),children:(0,Ie.jsx)(Lo.FileCodeIcon,{})})}),(0,Ie.jsx)(_e.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),(0,Ie.jsxs)(_e.Tooltip,{children:[(0,Ie.jsx)(_e.TooltipTrigger,{asChild:!0,children:(0,Ie.jsx)(_e.DropdownMenuItem,{className:"p-1.5",disabled:r,onClick:()=>n(),children:(0,Ie.jsx)(Lo.PrinterIcon,{})})}),(0,Ie.jsx)(_e.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}var he=require("react/jsx-runtime"),Vp=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=(0,Ve.useTranslation)(),{clearSelection:i}=wo(),{mode:a,isMinimapOpen:s,setIsMinimapOpen:l,isMoveTool:c,isHandTool:d,setIsMoveTool:p,setIsHandTool:m}=$(),{getNodes:u,getEdges:g}=(0,Pr.useReactFlow)(),E=(0,Pr.useKeyPress)(["v","V"]),f=(0,Pr.useKeyPress)(["h","H"]),h=(0,mo.useCallback)(()=>{i(),m(!0),p(!1)},[i,m,p]),y=(0,mo.useCallback)(()=>{p(!0),m(!1)},[p,m]),[x,v]=(0,mo.useState)(!1),N=(0,mo.useCallback)(async()=>{v(!0);try{let T=u(),_=g(),I=await o({nodes:T,edges:_});n(I)}finally{v(!1)}},[u,g,o,n]);return(0,mo.useEffect)(()=>{E&&!c&&a==="edit"&&y()},[E,y,c,a]),(0,mo.useEffect)(()=>{f&&!d&&a==="edit"&&h()},[f,h,d,a]),(0,he.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[a==="edit"&&(0,he.jsxs)(he.Fragment,{children:[(0,he.jsxs)(Ve.Tooltip,{children:[(0,he.jsx)(Ve.TooltipTrigger,{asChild:!0,children:(0,he.jsx)(Ve.Button,{size:"small",variant:"ghost",color:"grey",className:H(c&&"bg-grey-400"),iconButton:!0,onClick:y,children:(0,he.jsx)(jt.MousePointerIcon,{})})}),(0,he.jsxs)(Ve.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),(0,he.jsx)(sa,{shortcut:"V"})]})]}),(0,he.jsxs)(Ve.Tooltip,{children:[(0,he.jsx)(Ve.TooltipTrigger,{asChild:!0,children:(0,he.jsx)(Ve.Button,{size:"small",variant:"ghost",color:"grey",className:H(d&&"bg-grey-400"),iconButton:!0,onClick:h,children:(0,he.jsx)(jt.HandIcon,{})})}),(0,he.jsxs)(Ve.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",(0,he.jsx)(sa,{shortcut:"H"})]})]})]}),(0,he.jsx)(Op,{}),a==="edit"&&(0,he.jsxs)(he.Fragment,{children:[(0,he.jsxs)(Ve.Tooltip,{children:[(0,he.jsx)(Ve.TooltipTrigger,{asChild:!0,children:(0,he.jsx)(Ve.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:x,onClick:N,children:x?(0,he.jsx)(jt.Loader2Icon,{className:"animate-spin"}):(0,he.jsx)(jt.ListCheckIcon,{})})}),(0,he.jsx)(Ve.TooltipContent,{color:"black",children:r(x?"editor.controls.actions.check_loading":"editor.controls.actions.check")})]}),(0,he.jsx)(Cp,{disabled:e.length>0||t.length>0})]}),(0,he.jsxs)(Ve.Tooltip,{children:[(0,he.jsx)(Ve.TooltipTrigger,{asChild:!0,children:(0,he.jsx)(Ve.Button,{size:"small",variant:"ghost",color:"grey",className:H(s&&"bg-grey-400"),iconButton:!0,onClick:()=>l(!s),children:(0,he.jsx)(jt.MapIcon,{})})}),(0,he.jsx)(Ve.TooltipContent,{color:"black",children:r(s?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};var lt=require("@produto-lecom/lecom-ui"),ls=require("lucide-react"),Tt=require("react/jsx-runtime"),Hp=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=(0,lt.useTranslation)();return(0,Tt.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,Tt.jsxs)(lt.Tooltip,{children:[(0,Tt.jsx)(lt.TooltipTrigger,{asChild:!0,children:(0,Tt.jsx)(lt.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:(0,Tt.jsx)(ls.UndoIcon,{})})}),(0,Tt.jsx)(lt.TooltipContent,{color:"black",children:r("editor.controls.history.undo")})]}),(0,Tt.jsxs)(lt.Tooltip,{children:[(0,Tt.jsx)(lt.TooltipTrigger,{asChild:!0,children:(0,Tt.jsx)(lt.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:(0,Tt.jsx)(ls.RedoIcon,{})})}),(0,Tt.jsx)(lt.TooltipContent,{color:"black",children:r("editor.controls.history.redo")})]})]})};var Yn=require("@xyflow/react"),He=require("@produto-lecom/lecom-ui"),Wn=require("lucide-react");var Re=require("react/jsx-runtime"),Gp=()=>{let{t:e}=(0,He.useTranslation)(),t=(0,Yn.useNodes)(),o=(0,Yn.useEdges)(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:a}=(0,Yn.useReactFlow)(),s=t.length===0&&o.length===0;return(0,Re.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,Re.jsxs)(He.Tooltip,{children:[(0,Re.jsx)(He.TooltipTrigger,{asChild:!0,children:(0,Re.jsx)(He.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>a(),children:(0,Re.jsx)(Wn.ScanIcon,{})})}),(0,Re.jsx)(He.TooltipContent,{color:"black",children:e("editor.controls.zoom.fit")})]}),(0,Re.jsxs)(He.Tooltip,{children:[(0,Re.jsx)(He.TooltipTrigger,{asChild:!0,children:(0,Re.jsx)(He.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>r(),children:(0,Re.jsx)(Wn.ZoomOut,{})})}),(0,Re.jsx)(He.TooltipContent,{color:"black",children:e("editor.controls.zoom.out")})]}),(0,Re.jsxs)(He.Tooltip,{children:[(0,Re.jsx)(He.TooltipTrigger,{asChild:!0,children:(0,Re.jsx)(He.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>i(1),children:(0,Re.jsx)(wa,{})})}),(0,Re.jsx)(He.TooltipContent,{color:"black",children:e("editor.controls.zoom.reset")})]}),(0,Re.jsxs)(He.Tooltip,{children:[(0,Re.jsx)(He.TooltipTrigger,{asChild:!0,children:(0,Re.jsx)(He.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>n(),children:(0,Re.jsx)(Wn.ZoomIn,{})})}),(0,Re.jsx)(He.TooltipContent,{color:"black",children:e("editor.controls.zoom.in")})]})]})};var Bp=require("@xyflow/react"),eo=require("@produto-lecom/lecom-ui"),cs=require("react");var Gt=require("react/jsx-runtime"),zp=()=>{let e=(0,cs.useRef)(null),{t}=(0,eo.useTranslation)(),{setDraggableNode:o}=Dn(),n=(0,Bp.useNodes)(),{setIsDragging:r}=$(),[i,a]=(0,cs.useState)(void 0),s=[{type:"START_EVENT",icon:zr,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:an,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:Kn,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:qn,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:Aa,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:Ia,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:dn,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:pn,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:ln,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:va,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:Hr,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),a((0,Gt.jsx)(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return(0,Gt.jsxs)("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[(0,Gt.jsx)("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:s.map((c,d)=>{let p=!vo(c.type,n),m=p?t("editor.toolbar.start_event_already_exists"):c.label;return(0,Gt.jsxs)(eo.Tooltip,{children:[(0,Gt.jsx)(eo.TooltipTrigger,{asChild:!0,children:(0,Gt.jsx)(eo.Button,{className:H("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":p}),size:"small",variant:"ghost",color:"grey",draggable:!p,disabled:p,iconButton:!0,onDragStart:p?void 0:u=>l(u,c),children:(0,Gt.jsx)(c.icon,{})},d)}),(0,Gt.jsx)(eo.TooltipContent,{color:"black",side:"right",children:m})]},d)})}),(0,Gt.jsx)("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};var qe=require("react/jsx-runtime"),la=e=>e.preventDefault(),ca=(0,ko.forwardRef)((e,t)=>{let o=(0,to.useKeyPress)("Space"),{instanceId:n,mode:r,isMinimapOpen:i,isMoveTool:a,isHandTool:s}=$(),l=(0,ko.useRef)(null),c=(0,ko.useRef)(s),d=(0,ko.useRef)(o),{nodes:p,edges:m,actions:u,events:g,components:E,controls:f}=lp(),{t:h}=(0,Ro.useTranslation)();c.current=s,d.current=o;let y=dp(l,c,d);(0,ko.useImperativeHandle)(t,()=>({selectElements:u.selectElements,clearSelection:u.clearSelection}));let x=s||o||r!=="edit",v=x?[0,1,2]:Tr,N=s||o||y,T=a&&!o&&!y,_=r==="edit"&&T,I=!x&&!y,S=r==="view"||T;return(0,qe.jsxs)("div",{ref:l,className:"w-full h-full",children:[r==="edit"&&(0,qe.jsx)(zp,{}),(0,qe.jsx)(up,{}),(0,qe.jsxs)(to.ReactFlow,w(b({},g),{id:`modeler-${n}`,className:H({"is-hand-tool":N,"is-pan-tool-active":N}),edges:m,nodes:p,nodeTypes:iu,edgeTypes:su,minZoom:js,maxZoom:pu,panOnDrag:v,panOnScroll:!0,selectionOnDrag:I,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:S,nodesConnectable:_,nodesDraggable:_,connectionLineComponent:ou,selectionMode:to.SelectionMode.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:_?"Delete":null,selectionKeyCode:null,defaultViewport:fu,connectOnClick:!1,connectionRadius:50,onPaneContextMenu:la,onNodeContextMenu:la,onEdgeContextMenu:la,proOptions:{hideAttribution:!0},children:[(0,qe.jsx)(to.Background,{gap:du,size:cu,color:lu,bgColor:au}),i&&(0,qe.jsxs)(Ro.Tooltip,{children:[(0,qe.jsx)(Ro.TooltipTrigger,{asChild:!0,children:(0,qe.jsx)("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:(0,qe.jsx)(to.MiniMap,{pannable:!0,zoomable:!0,position:uu,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),(0,qe.jsx)(Ro.TooltipContent,{color:"black",children:h("editor.controls.actions.minimap.label")})]}),(0,qe.jsxs)("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&(0,qe.jsx)(Hp,b({},f)),(0,qe.jsx)(Vp,{nodes:p,edges:m,validateDiagram:u.validateDiagram,handleValidationComplete:u.handleValidationComplete}),(0,qe.jsx)(Gp,{})]}),(0,qe.jsx)(E.HelperLines,{})]}))]})});ca.displayName="Editor";var Yp=require("@xyflow/react"),ds=require("react"),Wp=require("react/jsx-runtime"),Zh=e=>({width:e.width,height:e.height,transform:e.transform}),da="rgba(51, 103, 217, 0.4)",Gc=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=(0,Yp.useStore)(Zh),i=(0,ds.useRef)(null);return(0,ds.useEffect)(()=>{let a=i.current,s=a==null?void 0:a.getContext("2d");if(!s||!a)return;let l=window.devicePixelRatio;a.width=o*l,a.height=n*l,s.clearRect(0,0,o,n),s.scale(l,l),s.strokeStyle=da,t&&(s.beginPath(),s.strokeStyle=t.color||da,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||da,s.moveTo(0,e.position*r[2]+r[1]),s.lineTo(o,e.position*r[2]+r[1]),s.stroke())},[o,n,r,e,t]),(0,Wp.jsx)("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};var Fn=require("@produto-lecom/lecom-ui"),Do=require("react");var Lr=require("react/jsx-runtime"),Kt=new Map,Fp=(0,Do.createContext)(null),wn=()=>{let e=(0,Do.useContext)(Fp);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},Xp=({locale:e,defaultMode:t="view",toast:o,children:n})=>{let[r,i]=(0,Do.useState)(e||"pt_BR");(0,Do.useEffect)(()=>{e&&(i(e),Fn.i18n.changeLanguage(e))},[e]);let a=g=>{let E=Kt.size;if(E===0)throw new Error("No modeler instances found");if(E===1||!g){let[h]=Kt.values();return h}let f=Kt.get(g);if(!f)throw new Error(`Modeler instance with ID "${g}" not found`);return f},s=(g,E)=>{let f=a(E);return f==null?void 0:f.selectElements(g)},l=async g=>{let E=a(g);return E==null?void 0:E.clearSelection()},c=(g,E)=>{let f=a(E);return f==null?void 0:f.configureElement(g)},d=(g,E)=>{let f=a(E);return f==null?void 0:f.getConfigureElement(g)},p=async(g,E)=>{let f=a(E);await(f==null?void 0:f.importFromMxGraph(g))},m=g=>{let E=a(g);return E==null?void 0:E.exportToMxGraph()},u=g=>{let E=a(g);return(E==null?void 0:E.getElementsCount())||0};return(0,Lr.jsx)(Fp.Provider,{value:{defaultMode:t,locale:r,selectElements:s,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:p,exportDiagram:m,getElementsCount:u,toast:o},children:(0,Lr.jsxs)(Fn.TooltipProvider,{children:[!o&&(0,Lr.jsx)(Fn.Notification,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};var us=require("react/jsx-runtime"),Kp=(0,Ge.createContext)(null),$=()=>{let e=(0,Ge.useContext)(Kp);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},qp=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,validateCustomDiagram:r,onElementChanges:i,onConfigureElement:a,onElementClick:s,onSubprocessValidationClick:l})=>{let{t:c}=(0,Up.useTranslation)(),{defaultMode:d}=wn(),p=(0,Ge.useId)(),[m]=(0,Ge.useState)(o||p),[u,g]=(0,Ge.useState)(n||d||"edit"),[E,f]=(0,Ge.useState)(gr),[h,y]=(0,Ge.useState)(!1),[x,v]=(0,Ge.useState)(!0),[N,T]=(0,Ge.useState)(!1),[_,I]=(0,Ge.useState)(!1),[S,P]=(0,Ge.useState)(!1),[R,M]=(0,Ge.useState)(!1),[B,X]=(0,Ge.useState)(!1),[U,Q]=(0,Ge.useState)(null);(0,Ge.useEffect)(()=>{n&&g(n)},[n]);let Y=(0,Ge.useMemo)(()=>t||Md(c),[t,c]),C={instanceId:m,initialDiagram:Y,mode:u,lastElementId:E,isInitialized:h,isMinimapOpen:_,isMoveTool:x,isHandTool:N,isDragging:S,isMultipleSelection:B,isConnecting:R,setLastElementId:f,setIsInitialized:y,reconnectingEdgeId:U,setIsMinimapOpen:I,setIsMoveTool:v,setIsHandTool:T,setIsDragging:P,setIsConnecting:M,setIsMultipleSelection:X,setReconnectingEdgeId:Q,validateCustomDiagram:r,onElementChanges:i,onConfigureElement:a,onElementClick:s,onSubprocessValidationClick:l};return(0,us.jsx)($p.ReactFlowProvider,{children:(0,us.jsx)(Kp.Provider,{value:C,children:(0,us.jsx)(ca,{ref:e})})})};0&&(module.exports={EditorMode,ElementPosition,ElementType,GatewayElementVariant,GatewayVariant,Modeler,ModelerProvider,NodeAttribute,NodeType,NodeVariant,RoutingVariant,useModeler});
|