lecom-modeler 0.37.0 → 0.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.cjs CHANGED
@@ -1,9 +1,8 @@
1
- "use strict";var tf=Object.create;var Kn=Object.defineProperty,of=Object.defineProperties,nf=Object.getOwnPropertyDescriptor,rf=Object.getOwnPropertyDescriptors,sf=Object.getOwnPropertyNames,Hr=Object.getOwnPropertySymbols,af=Object.getPrototypeOf,xs=Object.prototype.hasOwnProperty,xa=Object.prototype.propertyIsEnumerable;var ya=(e,t,o)=>t in e?Kn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,_=(e,t)=>{for(var o in t||(t={}))xs.call(t,o)&&ya(e,o,t[o]);if(Hr)for(var o of Hr(t))xa.call(t,o)&&ya(e,o,t[o]);return e},w=(e,t)=>of(e,rf(t));var Wt=(e,t)=>{var o={};for(var n in e)xs.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Hr)for(var n of Hr(e))t.indexOf(n)<0&&xa.call(e,n)&&(o[n]=e[n]);return o};var lf=(e,t)=>{for(var o in t)Kn(e,o,{get:t[o],enumerable:!0})},Ea=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of sf(t))!xs.call(e,r)&&r!==o&&Kn(e,r,{get:()=>t[r],enumerable:!(n=nf(t,r))||n.enumerable});return e};var cf=(e,t,o)=>(o=e!=null?tf(af(e)):{},Ea(t||!e||!e.__esModule?Kn(o,"default",{value:e,enumerable:!0}):o,e)),df=e=>Ea(Kn({},"__esModule",{value:!0}),e);var cy={};lf(cy,{EditorMode:()=>Ye,ElementPosition:()=>Br,ElementType:()=>qn,GatewayElementVariant:()=>zr,GatewayVariant:()=>It,Modeler:()=>ef,ModelerProvider:()=>Zp,NodeAttribute:()=>kt,NodeType:()=>se,NodeVariant:()=>rt,RoutingVariant:()=>Yr,useModeler:()=>Sn});module.exports=df(cy);var Es=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 Gr=require("@produto-lecom/lecom-ui");var _a={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Delete",configure_node:"Configure activity",configure_edge:"Configure routing",configure_gateway:"Configure routing",initial_task:"Initial Activity",gateway_limit_reached:"Exclusive gateway cannot have more than 2 outgoing connections",task_limit_reached:"Task cannot have more than 2 outgoing connections",start_event_limit_reached:"Start event can only connect to a single element",gateway_to_gateway_not_allowed:"Gateways cannot connect directly to other gateways",start_event_already_exists:"A start event already exists. Delete the current event to add another",script_to_end_not_allowed:"Script activities cannot connect directly to the end event",loop_to_end_not_allowed:"Loop activities cannot connect directly to the end event",initial_activity_to_end_not_allowed:"Initial activity cannot connect directly to the end event",final_activity_cannot_connect:"Final activity cannot connect to other elements",activity_has_outgoing_connections:"Activity with outgoing connections cannot connect to end event",end_event_cannot_connect_to_initial_activity:"End event cannot connect to an initial activity",initial_activity_cannot_connect_to_start_event:"Initial activity cannot connect to start event",concurrent_initial_and_final_activity:"An activity cannot be connected to both start and end events",start_event_to_service_task_not_allowed:"Start event cannot connect to an automatic activity",service_task_to_end_not_allowed:"Automatic activities cannot connect to the end event",duplicate_connection_not_allowed:"A connection already exists between these elements",connect_node:"Connect element",connecting:"Connecting...",delete_pool_lane_error:"Cannot delete the pool or lane while there are elements inside it."},controls:{zoom:{fit:"Fit zoom",in:"Zoom in",out:"Zoom out",reset:"Reset zoom"},actions:{move_tool:"Select elements",hand_tool:"Navigate the diagram",check:"Check diagram",check_loading:"Validating diagram...",export:{title:"Export diagram",print:"Print",html:"Export as HTML",png:"Export as PNG",feedback:{empty:"Cannot export an empty diagram",error:"Error exporting diagram"}},import_governance:"Import diagram from Governance platform",minimap:{label:"Minimap",open:"Open minimap",close:"Hide minimap"}},history:{undo:"Undo",redo:"Redo"}},modals:{delete_elements:{title:"Delete elements",callout:"When deleting, the activity and routing settings will be deleted.",content:"Are you sure you want to delete?",confirm:"Delete",cancel:"Cancel"}},task_menu:{loop_not_allowed_when_connected_to_end:"Cannot create loop on activity connected to end event",script_not_allowed_when_connected_to_end:"Cannot transform to Script activity connected to end event",loop_not_allowed_when_subprocess:"Cannot create loop on subprocess",loop_not_allowed_when_service_task:"Cannot create loop on automatic activity",loop:"Activity with loop"}},validation:{success:{title:"Validation Successful",message:"The diagram was validated successfully with no errors."},errors:{title:"The diagram contains errors",subtitle:"Please review the following:",task_label_length:"Task name exceeds the maximum character limit",multiple_start_event_not_allowed:"Multiple start events are not allowed",task_flows_limit_exceeds:"The number of output connections exceeds the limit of two",duplicate_task_name:"There are multiple activities with the same name",flows_on_end_tasks_not_allowed:"Activities connected to end events cannot have other connections",conditions_flows_limit_exceeds:"Exclusive gateway has too many output connections (maximum of two)",task_label_empty:"One or more activities have no name",activity_name_invalid:"Activity name is invalid",final_activity_has_loop:"Final activities cannot have loops",nested_gateway:"Connecting gateways directly is not allowed",concurrent_initial_and_final_event:"The same activity cannot have both initial and final events",gateway_flow_to_event:"Connecting a gateway to an output event is not allowed",gateway_missing_output_streams:"The gateway does not have the correct number of outputs",events_nested:"Connecting events directly is not allowed",event_to_condition:"Connecting an event directly to a gateway is not allowed",script_in_final_activity:"Final activity cannot be a script type",subprocess_not_configured:"The subprocess reference is not properly configured",cannot_validate_subprocess_reference:"Could not validate whether the subprocess reference is configured",start_event_not_found:"At least one start event is required",end_event_not_found:"At least one end event is required",service_task_without_rejection_routing:"Automated activity (RPA) without rejection routing configured",service_task_without_automation:"Automated activity (RPA) without a configured robot",service_task_connector_inactive:"Automated activity (RPA) linked to an inactive connector",service_task_integration_suspended:"Automated activity (RPA) linked to a suspended integration",service_task_automation_status_unavailable:"Could not verify the automation (RPA) status",service_task_initial_or_final:"Automated activity (RPA) cannot be an initial, final or concentrator step",service_task_in_loop:"Automated activity (RPA) cannot be in a loop"}},bpmn:{start_event:{variant:{default:"Start event"}},end_event:{variant:{default:"End event"}},annotation:{variant:{default:"Annotation"}},gateway:{menu:{title:"Change gateway type"},variant:{default:"Gateway",exclusive:"Exclusive gateway",parallel:"Parallel gateway",complex:"Complex gateway"}},task:{menu:{title:"Change task type"},variant:{default:"Task",script:"Script task",subprocess:"Subprocess",service_task:"RPA"},attribute:{loop:"Task with loop"},label:{prefix:"Activity"},feedback:{label_empty:{prefix:"Activity name was automatically set to"},label_already_exists:{prefix:"The name",middle:"already exists. The name was changed to"},invalid_first_character:"Activity name must start with a letter or number"}},lane:{variant:{default:"Pool / Lane"}},unsupported:{variant:{default:"Unsupported element"}}},adapter:{governance:{error:{DEFAULT:"Error importing diagram",NO_FILE:"No file selected",EMPTY_FILE:"Empty file",INVALID_FILE:"Invalid file",CONTAIN_NO_CELLS:"No cells found to be imported",ALREADY_INITIALIZED:"It is not possible to import the diagram from the Governance platform, since the diagram has already been initialized"},success:{default:"The diagram was imported from the Governance platform successfully and without any incompatibility detected.",incompatible_cells:"The diagram was imported from the Governance platform with incompatibilities. To know more details, click on the button below."},report:{columns:{type:"Type",value:"Value",status:"Status"},status:{imported:"Imported",adapted:"Adapted",unsupported:"Unsupported"}},action:{download:"Download report"}}}}};var ba={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",configure_node:"Configurar actividad",configure_edge:"Configurar enrutamiento",configure_gateway:"Configurar enrutamiento",initial_task:"Actividad Inicial",gateway_limit_reached:"Compuerta exclusiva no puede tener m\xE1s de 2 conexiones de salida",task_limit_reached:"Actividad no puede tener m\xE1s de 2 conexiones de salida",start_event_limit_reached:"Evento inicial solo puede conectarse a un \xFAnico elemento",gateway_to_gateway_not_allowed:"Las compuertas no pueden conectarse directamente con otras compuertas",start_event_already_exists:"Ya existe un evento de inicio. Elimine el evento actual para agregar otro",script_to_end_not_allowed:"Las actividades Script no pueden conectarse directamente al evento final",loop_to_end_not_allowed:"Las actividades Loop no pueden conectarse directamente al evento final",initial_activity_to_end_not_allowed:"Actividad inicial no puede conectarse directamente al evento final",final_activity_cannot_connect:"Actividad final no puede conectarse a otros elementos",activity_has_outgoing_connections:"Actividad con conexiones de salida no puede conectarse al evento final",end_event_cannot_connect_to_initial_activity:"El evento final no puede conectarse a una actividad inicial",initial_activity_cannot_connect_to_start_event:"Actividad inicial no puede conectarse a evento de inicio",concurrent_initial_and_final_activity:"Una actividad no puede estar conectada al evento inicial y final al mismo tiempo",start_event_to_service_task_not_allowed:"El evento inicial no puede conectarse a una actividad autom\xE1tica",service_task_to_end_not_allowed:"Las actividades autom\xE1ticas no pueden conectarse al evento final",duplicate_connection_not_allowed:"Ya existe una conexi\xF3n entre estos elementos",connect_node:"Conectar elemento",connecting:"Conectando...",delete_pool_lane_error:"No se puede eliminar la piscina o carril mientras haya elementos dentro."},controls:{zoom:{fit:"Ajustar zoom",in:"Acercar",out:"Alejar",reset:"Restablecer zoom"},actions:{move_tool:"Seleccionar elementos",hand_tool:"Navegar por el diagrama",check:"Validar diagrama",check_loading:"Validando diagrama...",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"No es posible exportar un diagrama vac\xEDo",error:"Error al exportar diagrama"}},import_governance:"Importar diagrama de la plataforma Governance",minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Deshacer",redo:"Rehacer"}},modals:{delete_elements:{title:"Eliminar elementos",callout:"Al eliminar, las configuraciones de actividades y enrutamiento ser\xE1n eliminadas.",content:"\xBFEst\xE1s seguro de querer eliminar?",confirm:"Eliminar",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"No se puede crear bucle en actividad conectada al evento final",script_not_allowed_when_connected_to_end:"No se puede transformar a Script actividad conectada al evento final",loop_not_allowed_when_subprocess:"No se puede crear bucle en subproceso",loop_not_allowed_when_service_task:"No se puede crear bucle en actividad autom\xE1tica",loop:"Actividad con loop"}},validation:{success:{title:"Validaci\xF3n exitosa",message:"El diagrama ha sido validado correctamente sin errores."},errors:{title:"El diagrama contiene errores",subtitle:"Revise lo siguiente:",task_label_length:"El nombre de la actividad excede el l\xEDmite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"No se permite tener m\xE1s de un evento de inicio",task_flows_limit_exceeds:"El n\xFAmero de conexiones de salida supera el l\xEDmite de dos",duplicate_task_name:"Hay varias actividades con el mismo nombre",flows_on_end_tasks_not_allowed:"Las actividades conectadas a eventos finales no pueden tener otras conexiones",conditions_flows_limit_exceeds:"Compuerta exclusiva con exceso de conexiones de salida (m\xE1ximo de dos)",task_label_empty:"El nombre de una o m\xE1s actividades no ha sido completado",activity_name_invalid:"El nombre de la actividad no es v\xE1lido",final_activity_has_loop:"Las actividades finales no pueden tener bucles",nested_gateway:"No se permite conectar compuertas directamente",concurrent_initial_and_final_event:"Una misma actividad no puede tener eventos iniciales y finales",gateway_flow_to_event:"No se permite conectar una compuerta a un evento de salida",gateway_missing_output_streams:"La compuerta no tiene el n\xFAmero correcto de salidas",events_nested:"No se permite conectar eventos directamente",event_to_condition:"No se permite conectar un evento directamente a una compuerta",script_in_final_activity:"La actividad final no puede ser de tipo script",subprocess_not_configured:"La referencia al subproceso no est\xE1 configurada correctamente",cannot_validate_subprocess_reference:"No fue posible validar si la referencia al subproceso est\xE1 configurada",start_event_not_found:"Es necesario tener al menos un evento de inicio",end_event_not_found:"Es necesario tener al menos un evento final",service_task_without_rejection_routing:"Actividad autom\xE1tica (RPA) sin enrutamiento de rechazo configurado",service_task_without_automation:"Actividad autom\xE1tica (RPA) sin robot configurado",service_task_connector_inactive:"Actividad autom\xE1tica (RPA) vinculada a un conector inactivo",service_task_integration_suspended:"Actividad autom\xE1tica (RPA) vinculada a una integraci\xF3n suspendida",service_task_automation_status_unavailable:"No se pudo verificar el estado de la automatizaci\xF3n (RPA)",service_task_initial_or_final:"La actividad autom\xE1tica (RPA) no puede ser etapa inicial, final o concentradora",service_task_in_loop:"La actividad autom\xE1tica (RPA) no puede estar en un bucle"}},bpmn:{start_event:{variant:{default:"Evento de inicio"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anotaci\xF3n"}},gateway:{menu:{title:"Cambiar tipo de compuerta"},variant:{default:"Compuerta",exclusive:"Compuerta exclusiva",parallel:"Compuerta paralela",complex:"Compuerta compleja"}},task:{menu:{title:"Cambiar tipo de tarea"},variant:{default:"Tarea",script:"Tarea de script",subprocess:"Subproceso",service_task:"RPA"},attribute:{loop:"Tarea con bucle"},label:{prefix:"Actividad"},feedback:{label_empty:{prefix:"El nombre de la actividad se estableci\xF3 autom\xE1ticamente como"},label_already_exists:{prefix:"El nombre",middle:"ya existe. El nombre fue cambiado a"},invalid_first_character:"El nombre de la actividad debe comenzar con una letra o n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento no soportado"}}},adapter:{governance:{error:{DEFAULT:"Error al importar diagrama",NO_FILE:"No se ha seleccionado ning\xFAn archivo",EMPTY_FILE:"Archivo vac\xEDo",INVALID_FILE:"Archivo inv\xE1lido",CONTAIN_NO_CELLS:"No se encontraron c\xE9lulas para importar",ALREADY_INITIALIZED:"No es posible importar el diagrama de la plataforma Governance, ya que el diagrama ya ha sido iniciado"},success:{default:"El diagrama se ha importado de la plataforma Governance correctamente y sin ninguna incompatibilidad detectada.",incompatible_cells:"El diagrama se ha importado de la plataforma Governance con incompatibilidades. Para saber m\xE1s detalles, haz click en el bot\xF3n de abajo."},report:{columns:{type:"Tipo",value:"Valor",status:"Estado"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"No soportado"}},action:{download:"Descargar informe"}}}}};var Ta={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Excluir",configure_node:"Configurar atividade",configure_edge:"Configurar roteamento",configure_gateway:"Configurar roteamento",initial_task:"Atividade Inicial",gateway_limit_reached:"Gateway exclusivo n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",task_limit_reached:"Atividade n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",start_event_limit_reached:"Evento inicial s\xF3 pode se conectar a um \xFAnico elemento",gateway_to_gateway_not_allowed:"Gateways n\xE3o podem se conectar diretamente com outros gateways",start_event_already_exists:"J\xE1 existe um evento de in\xEDcio. Exclua o evento atual para adicionar outro",script_to_end_not_allowed:"Atividades Script n\xE3o podem se conectar diretamente ao evento final",loop_to_end_not_allowed:"Atividades Loop n\xE3o podem se conectar diretamente ao evento final",initial_activity_to_end_not_allowed:"Atividade inicial n\xE3o pode se conectar diretamente ao evento final",final_activity_cannot_connect:"Atividade final n\xE3o pode se conectar a outros elementos",activity_has_outgoing_connections:"Atividade com conex\xF5es de sa\xEDda n\xE3o pode se conectar a um evento final",end_event_cannot_connect_to_initial_activity:"O evento final n\xE3o pode ser conectado a uma atividade inicial",initial_activity_cannot_connect_to_start_event:"Atividade inicial n\xE3o pode se conectar a evento de in\xEDcio",concurrent_initial_and_final_activity:"Uma atividade n\xE3o pode estar conectada ao evento inicial e final ao mesmo tempo",duplicate_connection_not_allowed:"J\xE1 existe uma conex\xE3o entre esses elementos",start_event_to_subprocess_not_allowed:"Evento inicial n\xE3o pode se conectar a um subprocesso",start_event_to_service_task_not_allowed:"Evento inicial n\xE3o pode se conectar a uma atividade autom\xE1tica",service_task_to_end_not_allowed:"Atividades autom\xE1ticas n\xE3o podem se conectar ao evento final",connect_node:"Conectar elemento",connecting:"Conectando...",delete_pool_lane_error:"N\xE3o \xE9 poss\xEDvel excluir a piscina ou raia enquanto houver elementos dentro dela."},controls:{zoom:{fit:"Ajustar o zoom",in:"Aumentar o zoom",out:"Diminuir o zoom",reset:"Resetar o zoom"},actions:{move_tool:"Selecionar elementos",hand_tool:"Navegar pelo diagrama",check:"Validar diagrama",check_loading:"Validando diagrama...",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"N\xE3o \xE9 poss\xEDvel exportar um diagrama vazio",error:"Erro ao exportar o diagrama"}},import_governance:"Importar diagrama da plataforma Governance",minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Desfazer",redo:"Refazer"}},modals:{delete_elements:{title:"Excluir elementos",callout:"Ao excluir, as configura\xE7\xF5es de atividades e roteamento ser\xE3o exclu\xEDdas.",content:"Deseja realmente excluir?",confirm:"Excluir",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel criar loop em atividade conectada ao evento final",script_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel transformar em Script atividade conectada ao evento final",loop_not_allowed_when_subprocess:"N\xE3o \xE9 poss\xEDvel criar loop em subprocesso",loop_not_allowed_when_service_task:"N\xE3o \xE9 poss\xEDvel criar loop em atividade autom\xE1tica",loop:"Atividade com loop"}},validation:{success:{title:"Diagrama v\xE1lidado com sucesso!",message:"Nenhum erro encontrado."},errors:{title:"O diagrama cont\xE9m erros",subtitle:"Veja abaixo o que precisa ser corrigido:",task_label_length:"O nome da atividade excede o limite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"N\xE3o \xE9 permitido ter mais de um evento de in\xEDcio",task_flows_limit_exceeds:"O n\xFAmero de conex\xF5es de sa\xEDda ultrapassa o limite de dois",duplicate_task_name:"H\xE1 v\xE1rias atividades com o mesmo nome",flows_on_end_tasks_not_allowed:"Atividades conectadas a eventos finais n\xE3o podem ter outras conex\xF5es",conditions_flows_limit_exceeds:"Gateway exclusivo com excesso de conex\xF5es de sa\xEDda (m\xE1ximo de dois)",task_label_empty:"O nome de uma ou mais atividades n\xE3o foi preenchido",activity_name_invalid:"O nome da atividade n\xE3o \xE9 v\xE1lido",final_activity_has_loop:"Atividades finais n\xE3o podem ter loops",nested_gateway:"N\xE3o \xE9 permitido conectar gateways",concurrent_initial_and_final_event:"Uma mesma atividade n\xE3o pode ter eventos iniciais e finais",gateway_flow_to_event:"N\xE3o \xE9 permitido conectar um gateway a um evento de sa\xEDda",gateway_missing_output_streams:"O gateway n\xE3o possui o n\xFAmero correto de sa\xEDdas",events_nested:"N\xE3o \xE9 permitido conectar eventos",event_to_condition:"N\xE3o \xE9 permitido conectar um evento diretamente em um gateway",script_in_final_activity:"Atividade final n\xE3o pode ser do tipo script",subprocess_not_configured:"A refer\xEAncia ao subprocesso n\xE3o est\xE1 configurada corretamente",cannot_validate_subprocess_reference:"N\xE3o foi poss\xEDvel validar se a refer\xEAncia ao subprocesso est\xE1 configurada",start_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento inicial",end_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento final",service_task_without_rejection_routing:"Atividade autom\xE1tica (RPA) sem roteamento de rejei\xE7\xE3o configurado",service_task_without_automation:"Atividade autom\xE1tica (RPA) sem rob\xF4 configurado",service_task_connector_inactive:"Atividade autom\xE1tica (RPA) vinculada a um conector inativo",service_task_integration_suspended:"Atividade autom\xE1tica (RPA) vinculada a uma integra\xE7\xE3o suspensa",service_task_automation_status_unavailable:"N\xE3o foi poss\xEDvel verificar o status da automa\xE7\xE3o (RPA)",service_task_initial_or_final:"Atividade autom\xE1tica (RPA) n\xE3o pode ser etapa inicial, final ou concentradora",service_task_in_loop:"Atividade autom\xE1tica (RPA) n\xE3o pode estar em loop"}},bpmn:{start_event:{variant:{default:"Evento inicial"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anota\xE7\xE3o"}},gateway:{menu:{title:"Alterar tipo de gateway"},variant:{default:"Gateway",exclusive:"Gateway exclusivo",parallel:"Gateway paralelo",complex:"Gateway complexo"}},task:{menu:{title:"Alterar tipo de atividade"},variant:{default:"Atividade",script:"Atividade de script",subprocess:"Subprocesso",service_task:"RPA"},attribute:{loop:"Atividade com loop"},label:{prefix:"Atividade"},feedback:{label_empty:{prefix:"O nome da atividade foi definido automaticamente como"},label_already_exists:{prefix:"O nome",middle:"j\xE1 existe. O nome foi alterado para"},invalid_first_character:"O nome da atividade deve come\xE7ar com uma letra ou n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento n\xE3o suportado"}}},adapter:{governance:{error:{DEFAULT:"Erro ao importar diagrama",NO_FILE:"Nenhum arquivo selecionado",EMPTY_FILE:"Arquivo vazio",INVALID_FILE:"Arquivo inv\xE1lido",CONTAIN_NO_CELLS:"N\xE3o foram encontradas c\xE9lulas para serem importadas",ALREADY_INITIALIZED:"N\xE3o \xE9 poss\xEDvel importar o diagrama da plataforma Governance, pois o diagrama j\xE1 foi iniciado"},success:{default:"O diagrama foi importado da plataforma Governance com sucesso e sem nenhuma incompatibilidade detectada.",incompatible_cells:"O diagrama foi importado da plataforma Governance com incompatibilidades. Para saber mais detalhes, clique no bot\xE3o abaixo."},report:{columns:{type:"Tipo do elemento",value:"Valor",status:"Status"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"N\xE3o suportado"}},action:{download:"Baixar relat\xF3rio"}}}}};var va={pt_BR:Ta,en_US:_a,es_ES:ba};var Na,wa,uf=(wa=(Na=Es("LecomUserLanguage"))!=null?Na:Es("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?wa:Gr.Translations.PT_BR;(0,Gr.initializeI18n)({lng:uf,resources:va});var Ye=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(Ye||{});var qn=(i=>(i.ACTIVITY="activity",i.ROUTING="routing",i.GATEWAY="gateway",i.SUB_PROCESS="sub_process",i.SERVICE_TASK="service_task",i))(qn||{}),Br=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Br||{}),zr=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(zr||{}),Yr=(p=>(p.SIMPLE="simple",p.LOOP="loop",p.SCRIPT="script",p.SCRIPT_LOOP="script_loop",p.COMPLEX="complex",p.EXCLUSIVE="exclusive",p.PARALLEL="parallel",p.FINAL="final",p.TO_SUB_PROCESS="to_sub_process",p.FROM_SUB_PROCESS="from_sub_process",p.TO_SERVICE_TASK="to_service_task",p.FROM_SERVICE_TASK="from_service_task",p))(Yr||{});var To=require("lucide-react");var Go=require("react/jsx-runtime"),Wr=({size:e=24,className:t})=>(0,Go.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:[(0,Go.jsx)("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),(0,Go.jsx)("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),(0,Go.jsx)("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),(0,Go.jsx)("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});var _s=require("react/jsx-runtime"),un=({size:e=24,className:t})=>(0,_s.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,_s.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 Eo=require("react/jsx-runtime"),pn=({size:e=24,className:t})=>(0,Eo.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,Eo.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,Eo.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Eo.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Eo.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Eo.jsx)("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var fn=require("react/jsx-runtime"),mn=({size:e=24,className:t})=>(0,fn.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,fn.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,fn.jsx)("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,fn.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var gn=require("react/jsx-runtime"),hn=({size:e=24,className:t})=>(0,gn.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,gn.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,gn.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,gn.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});var yn=require("react/jsx-runtime"),Ia=({size:e=24,className:t})=>(0,yn.jsx)("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:(0,yn.jsxs)("g",{children:[(0,yn.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,yn.jsx)("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});var Aa=require("clsx"),Sa=require("tailwind-merge");function H(...e){return(0,Sa.twMerge)((0,Aa.clsx)(e))}var _o=(e=0,t=0)=>e<t?t:e,Fr=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});var Zn=require("react/jsx-runtime"),Ca=({size:e=24,className:t})=>(0,Zn.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,Zn.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,Zn.jsx)("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});var Xr=require("react/jsx-runtime"),Ma=({size:e=24,className:t})=>(0,Xr.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:(0,Xr.jsx)("g",{children:(0,Xr.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 bs=require("react/jsx-runtime"),Ur=({size:e=24,className:t})=>(0,bs.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,bs.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 Ts=require("react/jsx-runtime"),Jn=({size:e=24,className:t})=>(0,Ts.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,Ts.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 xn=require("react/jsx-runtime"),Pa=({size:e=24,className:t})=>(0,xn.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,xn.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,xn.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,xn.jsx)("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});var bo=require("react/jsx-runtime"),La=({size:e=24,className:t})=>(0,bo.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,bo.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,bo.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,bo.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,bo.jsx)("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,bo.jsx)("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var Bo=require("react/jsx-runtime"),Qn=({size:e=24,className:t})=>(0,Bo.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,Bo.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,Bo.jsx)("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),(0,Bo.jsx)("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Bo.jsx)("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var se=(a=>(a.START_EVENT="START_EVENT",a.END_EVENT="END_EVENT",a.TASK="TASK",a.LANE="LANE",a.GATEWAY="GATEWAY",a.ANNOTATION="ANNOTATION",a.UNSUPPORTED="UNSUPPORTED",a))(se||{}),rt=(n=>(n.SCRIPT="SCRIPT",n.SUBPROCESS="SUBPROCESS",n.SERVICE_TASK="SERVICE_TASK",n))(rt||{}),$r={SCRIPT:{icon:To.ScrollText},SUBPROCESS:{icon:To.SquarePlus},SERVICE_TASK:{icon:To.Bot}},kt=(t=>(t.LOOP="LOOP",t))(kt||{}),Kr={LOOP:{icon:To.RotateCcw}},It=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(It||{}),vs={EXCLUSIVE:{icon:mn},PARALLEL:{icon:hn},COMPLEX:{icon:pn}};var Jp=require("@produto-lecom/lecom-ui"),Qp=require("@xyflow/react"),Le=require("react");var oo=require("@xyflow/react"),dn=require("react");var up=require("@produto-lecom/lecom-ui"),jt=require("@xyflow/react"),Tt=require("react");var qr={MIN_WIDTH:36,MIN_HEIGHT:36},Zr={MIN_WIDTH:36,MIN_HEIGHT:36},En={MIN_WIDTH:56,MIN_HEIGHT:56},vo={MIN_WIDTH:176,MIN_HEIGHT:96},ka={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},ae={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},_n={MIN_WIDTH:176,MIN_HEIGHT:64},pf={MIN_WIDTH:128,MIN_HEIGHT:64},ue={START_EVENT:qr,END_EVENT:Zr,GATEWAY:En,TASK:vo,LANE:ae,ANNOTATION:_n,UNSUPPORTED:pf};var bn=require("@xyflow/react");function Ra(e,t){var E,N,b,v;let{width:o=0,height:n=0}=e.measured||{width:0,height:0},r=e.internals.positionAbsolute,i=t.internals.positionAbsolute,s=o/2,a=n/2,l=r.x+s,c=r.y+a,d=i.x+((N=(E=t==null?void 0:t.measured)==null?void 0:E.width)!=null?N:0)/2,u=i.y+((v=(b=t==null?void 0:t.measured)==null?void 0:b.height)!=null?v:0)/2,p=(d-l)/(2*s)-(u-c)/(2*a),m=(d-l)/(2*s)+(u-c)/(2*a),g=1/(Math.abs(p)+Math.abs(m)||1),x=g*p,f=g*m,h=s*(x+f)+l,y=a*(-x+f)+c;return{x:h,y}}function Da(e,t){var c,d,u,p;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(p=(u=e.measured)==null?void 0:u.height)!=null?p:0,i=Math.round(o.x),s=Math.round(o.y),a=Math.round(t.x),l=Math.round(t.y);return a<=i+1?bn.Position.Left:a>=i+n-1?bn.Position.Right:l<=s+1?bn.Position.Top:l>=s+r-1?bn.Position.Bottom:bn.Position.Top}function Tn(e,t){let o=Ra(e,t),n=Ra(t,e),r=Da(e,o),i=Da(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function Jr(e,t){return{isFromStartEvent:(e==null?void 0:e.type)==="START_EVENT",isGatewayToGateway:(e==null?void 0:e.type)==="GATEWAY"&&(t==null?void 0:t.type)==="GATEWAY",isActiviyToAndGateway:(e==null?void 0:e.type)==="TASK"&&(t==null?void 0:t.type)==="GATEWAY",isToEndEvent:(t==null?void 0:t.type)==="END_EVENT"}}var Oa=require("lodash");var Va=e=>new Map(e.map(t=>[t.id,t])),Ha=(e,t)=>e.map(o=>{var n;return(n=t.get(o.id))!=null?n:o}),At=e=>{var t,o,n,r,i,s,a,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(r=(n=e.internals)==null?void 0:n.positionAbsolute.y)!=null?r:0,w:(s=(i=e.measured)==null?void 0:i.width)!=null?s:0,h:(l=(a=e.measured)==null?void 0:a.height)!=null?l:0}},zo=e=>(0,Oa.orderBy)(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),Ga=(e,t)=>{let{x:o,y:n}=At(e),{x:r,y:i}=At(t);return{x:o-r,y:n-i}};var Yo=({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)),ff=(e,t)=>{let{x:o,y:n}=At(e),{x:r,y:i}=At(t),s=o-r,a=n-i;return Math.sqrt(s*s+a*a)},mf=(e,t)=>{let{x:o,y:n,w:r,h:i}=At(e),{x:s,y:a,w:l,h:c}=At(t),d=o+r/2,u=n+i/2;return d>=s&&d<=s+l&&u>=a&&u<=a+c},jn=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&mf(e,r)){let i=ff(e,r);i<n&&(n=i,o=r)}return o},Ba=(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),za=(e,t)=>{let o=e.filter(c=>!c.parentId);if(o.length===0)return{nodes:e,edges:t};let n=o.filter(c=>c.type==="LANE"),r=n.length>0?n:o,i=Math.min(...r.map(c=>c.position.x||0)),s=Math.min(...r.map(c=>c.position.y||0)),a=e.map(c=>c.parentId?c:w(_({},c),{position:{x:c.position.x-i,y:c.position.y-s}})),l=t.map(c=>{let d=c.data;return d!=null&&d.points?w(_({},c),{data:w(_({},d),{points:d.points.map(u=>({x:u.x-i,y:u.y-s}))})}):c});return{nodes:a,edges:l}},Ya=e=>{var l,c;let t=e.filter(d=>!d.parentId),o=t.filter(d=>d.type==="LANE"),n=o.length>0?o:t;if(n.length===0)return null;let r=1/0,i=1/0,s=-1/0,a=-1/0;for(let d of n){let u=d.position.x+((l=d.width)!=null?l:0),p=d.position.y+((c=d.height)!=null?c:0);d.position.x<r&&(r=d.position.x),d.position.y<i&&(i=d.position.y),u>s&&(s=u),p>a&&(a=p)}return{x:r,y:i,width:s-r,height:a-i}};var Ns=(e,t)=>{let o=t.find(s=>s.id===e);if(!o||o.type!=="LANE"||o.parentId)return!1;let n=At(o),r=n.x+n.w,i=n.y+n.h;return t.some(s=>{if(s.id===e||s.parentId||s.type==="LANE")return!1;let a=At(s);return a.x<r&&a.x+a.w>n.x&&a.y<i&&a.y+a.h>n.y})};var gf=50,Wo=(e,t)=>{var p,m,g,x,f,h,y,E,N,b,v,T,I,S,P,R;let o=t.find(C=>C.id===e);if(!o)return t;let n=(m=(p=o.position)==null?void 0:p.x)!=null?m:0,r=(x=(g=o.position)==null?void 0:g.y)!=null?x:0,i=(h=(f=o.measured)==null?void 0:f.width)!=null?h:0,s=(E=(y=o.measured)==null?void 0:y.height)!=null?E:0,a=r+s,l=n+i,c=new Set,d=1/0;for(let C of t){if(C.id===e||C.parentId)continue;let L=(b=(N=C.position)==null?void 0:N.y)!=null?b:0,K=(T=(v=C.position)==null?void 0:v.x)!=null?T:0,Q=(S=(I=C.measured)==null?void 0:I.width)!=null?S:0,j=(R=(P=C.measured)==null?void 0:P.height)!=null?R:0;K<l&&K+Q>n&&L<a&&L+j>r&&(c.add(C.id),d=Math.min(d,L))}if(c.size===0)return t;let u=a+gf-d;return t.map(C=>{var K,Q,j;if(!c.has(C.id))return C;let L=(Q=(K=C.position)==null?void 0:K.y)!=null?Q:0;return w(_({},C),{position:w(_({},(j=C.position)!=null?j:{x:0,y:0}),{y:L+u})})})},He=15,Fo=e=>[...e].sort((t,o)=>t.position.y-o.position.y),hf=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)},yf=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)},ws=(e,t,o)=>{var d,u,p,m,g,x,f,h,y,E,N,b,v,T,I;if(t.length===0)return e;let n=(p=(u=e.width)!=null?u:(d=e.measured)==null?void 0:d.width)!=null?p:0,r=(x=(g=e.height)!=null?g:(m=e.measured)==null?void 0:m.height)!=null?x:0,i=0,s=0;for(let S of t){let P=hf(S),R=yf(S);if(((h=(f=S.position)==null?void 0:f.y)!=null?h:0)<He&&(o.set(S.id,w(_({},S),{position:w(_({},S.position),{y:He})})),R=He+((E=(y=S.measured)==null?void 0:y.height)!=null?E:0)),((b=(N=S.position)==null?void 0:N.x)!=null?b:0)<ae.HEADER_WIDTH+He){let C=(v=o.get(S.id))!=null?v:S;o.set(S.id,w(_({},C),{position:w(_({},C.position),{x:ae.HEADER_WIDTH+He})})),P=ae.HEADER_WIDTH+He+((I=(T=S.measured)==null?void 0:T.width)!=null?I:0)}i=Math.max(i,P),s=Math.max(s,R)}let a=Math.max(n,ae.MIN_WIDTH),l=Math.max(r,ae.MIN_HEIGHT);i+He>a&&(a=i+He),s+He>l&&(l=s+He);let c=w(_({},e),{width:a,height:l,measured:w(_({},e.measured),{width:a,height:l})});return o.set(e.id,c),c},Wa=(e,t,o)=>{var s,a;let n=Fo(e),r=new Map;for(let l of o)l.parentId&&(r.has(l.parentId)||r.set(l.parentId,[]),r.get(l.parentId).push(l));let i=0;for(let l of n){let c=(s=r.get(l.id))!=null?s:[],d=ws(l,c,t);t.set(d.id,w(_({},d),{position:{x:ae.HEADER_WIDTH,y:i}})),i+=(a=d.height)!=null?a:0}},Fa=(e,t)=>{var g,x,f,h;let o=[];for(let y of t.values())y.parentId===e.id&&o.push(y);let n=Fo(o),r=((x=(g=e.measured)==null?void 0:g.width)!=null?x:0)-ae.HEADER_WIDTH,i=Ba(e.id,o)||ae.MIN_WIDTH,s=o.reduce((y,E)=>{var N;return y+((N=E.height)!=null?N:ae.MIN_HEIGHT)},0),a=Math.max(r,i),l=s,c=r>i,d=c?a:a+ae.HEADER_WIDTH,u=c?a-ae.HEADER_WIDTH:a,p=0;for(let y=0;y<n.length;y++){let E=n[y],N=Math.max(ae.MIN_HEIGHT,(f=E.height)!=null?f:ae.MIN_HEIGHT),b=w(_({},E),{width:u,height:N,measured:w(_({},E.measured),{width:u,height:N}),position:{x:ae.HEADER_WIDTH,y:p}});if(y===o.length-1){let v=Math.max(ae.MIN_HEIGHT,l-p);b=w(_({},b),{height:v,measured:w(_({},E.measured),{width:u,height:v})})}t.set(E.id,b),p+=(h=b.height)!=null?h:0}let m=Math.max(l,p);t.set(e.id,w(_({},e),{width:d,height:m,measured:w(_({},e.measured),{width:d,height:m})}))},Xa=(e,t,o,n,r)=>{var g,x;let i=!e.parentId,s=i?e.id:e.parentId,a=n.filter(f=>f.type==="LANE"&&f.parentId===s);if(!a.length)return n;let l=Fo(a),c=l.findIndex(f=>f.id===e.id),d=(x=(g=e.position)==null?void 0:g.y)!=null?x:0,u=!i&&r!==void 0&&c>0&&Math.abs(r-d)>.5,p=0,m=[...n];return l.forEach((f,h)=>{var v,T;let y=h===l.length-1,E=f.id===e.id,b=(T=(v=f.measured)==null?void 0:v.height)!=null?T:0;E?b=o:u&&h===c-1&&(b=Math.max(ae.MIN_HEIGHT,r-p)),y&&i&&(b=Math.max(ae.MIN_HEIGHT,o-p)),m=m.map(I=>{if(I.id===f.id){let S=i?t-ae.HEADER_WIDTH:t;return w(_({},I),{width:S,height:b,measured:w(_({},I.measured),{width:S,height:b}),position:{x:ae.HEADER_WIDTH,y:p}})}return I}),E&&u?p=r+o:p+=b}),m=m.map(f=>{if(f.id===s){let h=i?t:t+ae.HEADER_WIDTH;return w(_({},f),{width:h,height:i?o:p,measured:{width:h,height:i?o:p}})}return f}),m};var Is=(e,t,o)=>{var a,l,c,d,u,p,m,g;if(e.type==="LANE")return o;let n=(l=(a=t.measured)==null?void 0:a.width)!=null?l:0,r=(d=(c=t.measured)==null?void 0:c.height)!=null?d:0;e.position.y<He&&(e.position.y=He),e.position.x<ae.HEADER_WIDTH+He&&(e.position.x=ae.HEADER_WIDTH+He);let i=e.position.x+((p=(u=e.measured)==null?void 0:u.width)!=null?p:0),s=e.position.y+((g=(m=e.measured)==null?void 0:m.height)!=null?g:0);return i+He>n&&(t.width=i+He,t.measured.width=i+He),s+He>r&&(t.height=s+He,t.measured.height=s+He),o=o.map(x=>x.id===t.id?w(_({},x),{height:t.height,width:t.width,measured:t.measured}):x.id===e.id?w(_({},x),{position:e.position}):x),o};var Ua=require("zustand"),$a=require("@xyflow/react"),Ka=require("react");var Qr=()=>{let{setEdges:e}=(0,$a.useReactFlow)();return(0,Ka.useCallback)(()=>{let o=Xo.getState().pathEdgeIds;e(n=>n.map(r=>w(_({},r),{selected:o.includes(r.id)})))},[e])},Xo=(0,Ua.create)((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=_({},n.statusByNodeId),i=_({},n.statusData),s=!1;return o.forEach(a=>{let l=`${a.diagramId}-${a.activityId}`;r[a.diagramId]!==a.status&&(r[a.diagramId]=a.status,i[l]=a,s=!0)}),s?{statusByNodeId:r,statusData:i}:n})},getTaskStatus:o=>t().statusByNodeId[o]||null,clearTaskStatuses:()=>e({statusByNodeId:{},statusData:{},pathEdgeIds:[]}),setPathEdges:o=>{e({pathEdgeIds:o})},getPathEdgeIds:()=>t().pathEdgeIds,clearPathEdges:()=>{e({pathEdgeIds:[]})},calculateFlowPath:(o,n)=>{if(!o.length||!n.length)return;t().clearPathEdges();let r=n.filter(d=>t().statusByNodeId[d]);if(r.length<=1)return;let i=[],s={};o.forEach(d=>{s[d.source]||(s[d.source]=[]),s[d.source].push({targetId:d.target,edgeId:d.id})});let a=r[0],l=r[r.length-1];o.forEach(d=>{d.target===a&&i.push(d.id)}),o.forEach(d=>{d.source===l&&i.push(d.id)});let c=(d,u)=>{let p=[],m=new Set;for(p.push({node:d,path:[]}),m.add(d);p.length>0;){let{node:g,path:x}=p.shift();if(g===u)return x;let f=s[g]||[];for(let{targetId:h,edgeId:y}of f)m.has(h)||(m.add(h),p.push({node:h,path:[...x,y]}))}return[]};for(let d=0;d<r.length-1;d++){let u=r[d],p=r[d+1],m=c(u,p);m.length>0&&i.push(...m)}i.length>0&&e({pathEdgeIds:i})}}));var An=require("@xyflow/react"),pt=require("react"),Yc=require("zustand/shallow");var xf={value:()=>{}};function Za(){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 jr(o)}function jr(e){this._=e}function Ef(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}})}jr.prototype=Za.prototype={constructor:jr,on:function(e,t){var o=this._,n=Ef(e+"",o),r,i=-1,s=n.length;if(arguments.length<2){for(;++i<s;)if((r=(e=n[i]).type)&&(r=_f(o[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(r=(e=n[i]).type)o[r]=qa(o[r],e.name,t);else if(t==null)for(r in o)o[r]=qa(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 jr(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 _f(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function qa(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=xf,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var As=Za;var ei="http://www.w3.org/1999/xhtml",Ss={svg:"http://www.w3.org/2000/svg",xhtml:ei,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function so(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),Ss.hasOwnProperty(t)?{space:Ss[t],local:e}:e}function bf(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===ei&&t.documentElement.namespaceURI===ei?t.createElement(e):t.createElementNS(o,e)}}function Tf(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function ti(e){var t=so(e);return(t.local?Tf:bf)(t)}function vf(){}function Uo(e){return e==null?vf:function(){return this.querySelector(e)}}function Ja(e){typeof e!="function"&&(e=Uo(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=new Array(s),l,c,d=0;d<s;++d)(l=i[d])&&(c=e.call(l,l.__data__,d,i))&&("__data__"in l&&(c.__data__=l.__data__),a[d]=c);return new Ue(n,this._parents)}function Cs(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Nf(){return[]}function er(e){return e==null?Nf:function(){return this.querySelectorAll(e)}}function wf(e){return function(){return Cs(e.apply(this,arguments))}}function Qa(e){typeof e=="function"?e=wf(e):e=er(e);for(var t=this._groups,o=t.length,n=[],r=[],i=0;i<o;++i)for(var s=t[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&(n.push(e.call(l,l.__data__,c,s)),r.push(l));return new Ue(n,r)}function tr(e){return function(){return this.matches(e)}}function oi(e){return function(t){return t.matches(e)}}var If=Array.prototype.find;function Af(e){return function(){return If.call(this.children,e)}}function Sf(){return this.firstElementChild}function ja(e){return this.select(e==null?Sf:Af(typeof e=="function"?e:oi(e)))}var Cf=Array.prototype.filter;function Mf(){return Array.from(this.children)}function Pf(e){return function(){return Cf.call(this.children,e)}}function el(e){return this.selectAll(e==null?Mf:Pf(typeof e=="function"?e:oi(e)))}function tl(e){typeof e!="function"&&(e=tr(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new Ue(n,this._parents)}function ni(e){return new Array(e.length)}function ol(){return new Ue(this._enter||this._groups.map(ni),this._parents)}function or(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}or.prototype={constructor:or,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 nl(e){return function(){return e}}function Lf(e,t,o,n,r,i){for(var s=0,a,l=t.length,c=i.length;s<c;++s)(a=t[s])?(a.__data__=i[s],n[s]=a):o[s]=new or(e,i[s]);for(;s<l;++s)(a=t[s])&&(r[s]=a)}function kf(e,t,o,n,r,i,s){var a,l,c=new Map,d=t.length,u=i.length,p=new Array(d),m;for(a=0;a<d;++a)(l=t[a])&&(p[a]=m=s.call(l,l.__data__,a,t)+"",c.has(m)?r[a]=l:c.set(m,l));for(a=0;a<u;++a)m=s.call(e,i[a],a,i)+"",(l=c.get(m))?(n[a]=l,l.__data__=i[a],c.delete(m)):o[a]=new or(e,i[a]);for(a=0;a<d;++a)(l=t[a])&&c.get(p[a])===l&&(r[a]=l)}function Rf(e){return e.__data__}function rl(e,t){if(!arguments.length)return Array.from(this,Rf);var o=t?kf:Lf,n=this._parents,r=this._groups;typeof e!="function"&&(e=nl(e));for(var i=r.length,s=new Array(i),a=new Array(i),l=new Array(i),c=0;c<i;++c){var d=n[c],u=r[c],p=u.length,m=Df(e.call(d,d&&d.__data__,c,n)),g=m.length,x=a[c]=new Array(g),f=s[c]=new Array(g),h=l[c]=new Array(p);o(d,u,x,f,h,m,t);for(var y=0,E=0,N,b;y<g;++y)if(N=x[y]){for(y>=E&&(E=y+1);!(b=f[E])&&++E<g;);N._next=b||null}}return s=new Ue(s,n),s._enter=a,s._exit=l,s}function Df(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function il(){return new Ue(this._exit||this._groups.map(ni),this._parents)}function sl(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 al(e){for(var t=e.selection?e.selection():e,o=this._groups,n=t._groups,r=o.length,i=n.length,s=Math.min(r,i),a=new Array(r),l=0;l<s;++l)for(var c=o[l],d=n[l],u=c.length,p=a[l]=new Array(u),m,g=0;g<u;++g)(m=c[g]||d[g])&&(p[g]=m);for(;l<r;++l)a[l]=o[l];return new Ue(a,this._parents)}function ll(){for(var e=this._groups,t=-1,o=e.length;++t<o;)for(var n=e[t],r=n.length-1,i=n[r],s;--r>=0;)(s=n[r])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function cl(e){e||(e=Of);function t(u,p){return u&&p?e(u.__data__,p.__data__):!u-!p}for(var o=this._groups,n=o.length,r=new Array(n),i=0;i<n;++i){for(var s=o[i],a=s.length,l=r[i]=new Array(a),c,d=0;d<a;++d)(c=s[d])&&(l[d]=c);l.sort(t)}return new Ue(r,this._parents).order()}function Of(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function dl(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function ul(){return Array.from(this)}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;r<i;++r){var s=n[r];if(s)return s}return null}function fl(){let e=0;for(let t of this)++e;return e}function ml(){return!this.node()}function gl(e){for(var t=this._groups,o=0,n=t.length;o<n;++o)for(var r=t[o],i=0,s=r.length,a;i<s;++i)(a=r[i])&&e.call(a,a.__data__,i,r);return this}function Vf(e){return function(){this.removeAttribute(e)}}function Hf(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Gf(e,t){return function(){this.setAttribute(e,t)}}function Bf(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function zf(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function Yf(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 hl(e,t){var o=so(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?Hf:Vf:typeof t=="function"?o.local?Yf:zf:o.local?Bf:Gf)(o,t))}function ri(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Wf(e){return function(){this.style.removeProperty(e)}}function Ff(e,t,o){return function(){this.style.setProperty(e,t,o)}}function Xf(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function yl(e,t,o){return arguments.length>1?this.each((t==null?Wf:typeof t=="function"?Xf:Ff)(e,t,o==null?"":o)):No(this.node(),e)}function No(e,t){return e.style.getPropertyValue(t)||ri(e).getComputedStyle(e,null).getPropertyValue(t)}function Uf(e){return function(){delete this[e]}}function $f(e,t){return function(){this[e]=t}}function Kf(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function xl(e,t){return arguments.length>1?this.each((t==null?Uf:typeof t=="function"?Kf:$f)(e,t)):this.node()[e]}function El(e){return e.trim().split(/^|\s+/)}function Ms(e){return e.classList||new _l(e)}function _l(e){this._node=e,this._names=El(e.getAttribute("class")||"")}_l.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 bl(e,t){for(var o=Ms(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function Tl(e,t){for(var o=Ms(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function qf(e){return function(){bl(this,e)}}function Zf(e){return function(){Tl(this,e)}}function Jf(e,t){return function(){(t.apply(this,arguments)?bl:Tl)(this,e)}}function vl(e,t){var o=El(e+"");if(arguments.length<2){for(var n=Ms(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?Jf:t?qf:Zf)(o,t))}function Qf(){this.textContent=""}function jf(e){return function(){this.textContent=e}}function em(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function Nl(e){return arguments.length?this.each(e==null?Qf:(typeof e=="function"?em:jf)(e)):this.node().textContent}function tm(){this.innerHTML=""}function om(e){return function(){this.innerHTML=e}}function nm(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function wl(e){return arguments.length?this.each(e==null?tm:(typeof e=="function"?nm:om)(e)):this.node().innerHTML}function rm(){this.nextSibling&&this.parentNode.appendChild(this)}function Il(){return this.each(rm)}function im(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Al(){return this.each(im)}function Sl(e){var t=typeof e=="function"?e:ti(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function sm(){return null}function Cl(e,t){var o=typeof e=="function"?e:ti(e),n=t==null?sm:typeof t=="function"?t:Uo(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function am(){var e=this.parentNode;e&&e.removeChild(this)}function Ml(){return this.each(am)}function lm(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function cm(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Pl(e){return this.select(e?cm:lm)}function Ll(e){return arguments.length?this.property("__data__",e):this.node().__data__}function dm(e){return function(t){e.call(this,t,this.__data__)}}function um(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 pm(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 fm(e,t,o){return function(){var n=this.__on,r,i=dm(t);if(n){for(var s=0,a=n.length;s<a;++s)if((r=n[s]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=o),r.value=t;return}}this.addEventListener(e.type,i,o),r={type:e.type,name:e.name,value:t,listener:i,options:o},n?n.push(r):this.__on=[r]}}function kl(e,t,o){var n=um(e+""),r,i=n.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,c=a.length,d;l<c;++l)for(r=0,d=a[l];r<i;++r)if((s=n[r]).type===d.type&&s.name===d.name)return d.value}return}for(a=t?fm:pm,r=0;r<i;++r)this.each(a(n[r],t,o));return this}function Rl(e,t,o){var n=ri(e),r=n.CustomEvent;typeof r=="function"?r=new r(t,o):(r=n.document.createEvent("Event"),o?(r.initEvent(t,o.bubbles,o.cancelable),r.detail=o.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function mm(e,t){return function(){return Rl(this,e,t)}}function gm(e,t){return function(){return Rl(this,e,t.apply(this,arguments))}}function Dl(e,t){return this.each((typeof t=="function"?gm:mm)(e,t))}function*Ol(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length,s;r<i;++r)(s=n[r])&&(yield s)}var hm=[null];function Ue(e,t){this._groups=e,this._parents=t}function Vl(){return new Ue([[document.documentElement]],hm)}function ym(){return this}Ue.prototype=Vl.prototype={constructor:Ue,select:Ja,selectAll:Qa,selectChild:ja,selectChildren:el,filter:tl,data:rl,enter:ol,exit:il,join:sl,merge:al,selection:ym,order:ll,sort:cl,call:dl,nodes:ul,node:pl,size:fl,empty:ml,each:gl,attr:hl,style:yl,property:xl,classed:vl,text:Nl,html:wl,raise:Il,lower:Al,append:Sl,insert:Cl,remove:Ml,clone:Pl,datum:Ll,on:kl,dispatch:Dl,[Symbol.iterator]:Ol};var ao=Vl;function ii(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function Ps(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function ir(){}var nr=.7,li=1/nr,vn="\\s*([+-]?\\d+)\\s*",rr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ft="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",xm=/^#([0-9a-f]{3,8})$/,Em=new RegExp(`^rgb\\(${vn},${vn},${vn}\\)$`),_m=new RegExp(`^rgb\\(${Ft},${Ft},${Ft}\\)$`),bm=new RegExp(`^rgba\\(${vn},${vn},${vn},${rr}\\)$`),Tm=new RegExp(`^rgba\\(${Ft},${Ft},${Ft},${rr}\\)$`),vm=new RegExp(`^hsl\\(${rr},${Ft},${Ft}\\)$`),Nm=new RegExp(`^hsla\\(${rr},${Ft},${Ft},${rr}\\)$`),Hl={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};ii(ir,wo,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Gl,formatHex:Gl,formatHex8:wm,formatHsl:Im,formatRgb:Bl,toString:Bl});function Gl(){return this.rgb().formatHex()}function wm(){return this.rgb().formatHex8()}function Im(){return Ul(this).formatHsl()}function Bl(){return this.rgb().formatRgb()}function wo(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=xm.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?zl(t):o===3?new it(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?si(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?si(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=Em.exec(e))?new it(t[1],t[2],t[3],1):(t=_m.exec(e))?new it(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=bm.exec(e))?si(t[1],t[2],t[3],t[4]):(t=Tm.exec(e))?si(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=vm.exec(e))?Fl(t[1],t[2]/100,t[3]/100,1):(t=Nm.exec(e))?Fl(t[1],t[2]/100,t[3]/100,t[4]):Hl.hasOwnProperty(e)?zl(Hl[e]):e==="transparent"?new it(NaN,NaN,NaN,0):null}function zl(e){return new it(e>>16&255,e>>8&255,e&255,1)}function si(e,t,o,n){return n<=0&&(e=t=o=NaN),new it(e,t,o,n)}function Am(e){return e instanceof ir||(e=wo(e)),e?(e=e.rgb(),new it(e.r,e.g,e.b,e.opacity)):new it}function Nn(e,t,o,n){return arguments.length===1?Am(e):new it(e,t,o,n==null?1:n)}function it(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}ii(it,Nn,Ps(ir,{brighter(e){return e=e==null?li:Math.pow(li,e),new it(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?nr:Math.pow(nr,e),new it(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new it(Ko(this.r),Ko(this.g),Ko(this.b),ci(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:Yl,formatHex:Yl,formatHex8:Sm,formatRgb:Wl,toString:Wl}));function Yl(){return`#${$o(this.r)}${$o(this.g)}${$o(this.b)}`}function Sm(){return`#${$o(this.r)}${$o(this.g)}${$o(this.b)}${$o((isNaN(this.opacity)?1:this.opacity)*255)}`}function Wl(){let e=ci(this.opacity);return`${e===1?"rgb(":"rgba("}${Ko(this.r)}, ${Ko(this.g)}, ${Ko(this.b)}${e===1?")":`, ${e})`}`}function ci(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ko(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function $o(e){return e=Ko(e),(e<16?"0":"")+e.toString(16)}function Fl(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 Ul(e){if(e instanceof Rt)return new Rt(e.h,e.s,e.l,e.opacity);if(e instanceof ir||(e=wo(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),s=NaN,a=i-r,l=(i+r)/2;return a?(t===i?s=(o-n)/a+(o<n)*6:o===i?s=(n-t)/a+2:s=(t-o)/a+4,a/=l<.5?i+r:2-i-r,s*=60):a=l>0&&l<1?0:s,new Rt(s,a,l,e.opacity)}function $l(e,t,o,n){return arguments.length===1?Ul(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}ii(Rt,$l,Ps(ir,{brighter(e){return e=e==null?li:Math.pow(li,e),new Rt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?nr:Math.pow(nr,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 it(Ls(e>=240?e-240:e+120,r,n),Ls(e,r,n),Ls(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new Rt(Xl(this.h),ai(this.s),ai(this.l),ci(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=ci(this.opacity);return`${e===1?"hsl(":"hsla("}${Xl(this.h)}, ${ai(this.s)*100}%, ${ai(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Xl(e){return e=(e||0)%360,e<0?e+360:e}function ai(e){return Math.max(0,Math.min(1,e||0))}function Ls(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 ks(e,t,o,n,r){var i=e*e,s=i*e;return((1-3*e+3*i-s)*t+(4-6*i+3*s)*o+(1+3*e+3*i-3*s)*n+s*r)/6}function Kl(e){var t=e.length-1;return function(o){var n=o<=0?o=0:o>=1?(o=1,t-1):Math.floor(o*t),r=e[n],i=e[n+1],s=n>0?e[n-1]:2*r-i,a=n<t-1?e[n+2]:2*i-r;return ks((o-n/t)*t,s,r,i,a)}}function ql(e){var t=e.length;return function(o){var n=Math.floor(((o%=1)<0?++o:o)*t),r=e[(n+t-1)%t],i=e[n%t],s=e[(n+1)%t],a=e[(n+2)%t];return ks((o-n/t)*t,r,i,s,a)}}var Rs=e=>()=>e;function Cm(e,t){return function(o){return e+o*t}}function Mm(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 Zl(e){return(e=+e)==1?di:function(t,o){return o-t?Mm(t,o,e):Rs(isNaN(t)?o:t)}}function di(e,t){var o=t-e;return o?Cm(e,o):Rs(isNaN(e)?t:e)}var ui=function e(t){var o=Zl(t);function n(r,i){var s=o((r=Nn(r)).r,(i=Nn(i)).r),a=o(r.g,i.g),l=o(r.b,i.b),c=di(r.opacity,i.opacity);return function(d){return r.r=s(d),r.g=a(d),r.b=l(d),r.opacity=c(d),r+""}}return n.gamma=e,n}(1);function Jl(e){return function(t){var o=t.length,n=new Array(o),r=new Array(o),i=new Array(o),s,a;for(s=0;s<o;++s)a=Nn(t[s]),n[s]=a.r||0,r[s]=a.g||0,i[s]=a.b||0;return n=e(n),r=e(r),i=e(i),a.opacity=1,function(l){return a.r=n(l),a.g=r(l),a.b=i(l),a+""}}}var Pm=Jl(Kl),Lm=Jl(ql);function St(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var Os=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ds=new RegExp(Os.source,"g");function km(e){return function(){return e}}function Rm(e){return function(t){return e(t)+""}}function Vs(e,t){var o=Os.lastIndex=Ds.lastIndex=0,n,r,i,s=-1,a=[],l=[];for(e=e+"",t=t+"";(n=Os.exec(e))&&(r=Ds.exec(t));)(i=r.index)>o&&(i=t.slice(o,i),a[s]?a[s]+=i:a[++s]=i),(n=n[0])===(r=r[0])?a[s]?a[s]+=r:a[++s]=r:(a[++s]=null,l.push({i:s,x:St(n,r)})),o=Ds.lastIndex;return o<t.length&&(i=t.slice(o),a[s]?a[s]+=i:a[++s]=i),a.length<2?l[0]?Rm(l[0].x):km(t):(t=l.length,function(c){for(var d=0,u;d<t;++d)a[(u=l[d]).i]=u.x(c);return a.join("")})}var Ql=180/Math.PI,pi={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Hs(e,t,o,n,r,i){var s,a,l;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(l=e*o+t*n)&&(o-=e*l,n-=t*l),(a=Math.sqrt(o*o+n*n))&&(o/=a,n/=a,l/=a),e*n<t*o&&(e=-e,t=-t,l=-l,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*Ql,skewX:Math.atan(l)*Ql,scaleX:s,scaleY:a}}var fi;function jl(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?pi:Hs(t.a,t.b,t.c,t.d,t.e,t.f)}function ec(e){return e==null?pi:(fi||(fi=document.createElementNS("http://www.w3.org/2000/svg","g")),fi.setAttribute("transform",e),(e=fi.transform.baseVal.consolidate())?(e=e.matrix,Hs(e.a,e.b,e.c,e.d,e.e,e.f)):pi)}function tc(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,p,m,g){if(c!==u||d!==p){var x=m.push("translate(",null,t,null,o);g.push({i:x-4,x:St(c,u)},{i:x-2,x:St(d,p)})}else(u||p)&&m.push("translate("+u+t+p+o)}function s(c,d,u,p){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),p.push({i:u.push(r(u)+"rotate(",null,n)-2,x:St(c,d)})):d&&u.push(r(u)+"rotate("+d+n)}function a(c,d,u,p){c!==d?p.push({i:u.push(r(u)+"skewX(",null,n)-2,x:St(c,d)}):d&&u.push(r(u)+"skewX("+d+n)}function l(c,d,u,p,m,g){if(c!==u||d!==p){var x=m.push(r(m)+"scale(",null,",",null,")");g.push({i:x-4,x:St(c,u)},{i:x-2,x:St(d,p)})}else(u!==1||p!==1)&&m.push(r(m)+"scale("+u+","+p+")")}return function(c,d){var u=[],p=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,u,p),s(c.rotate,d.rotate,u,p),a(c.skewX,d.skewX,u,p),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,p),c=d=null,function(m){for(var g=-1,x=p.length,f;++g<x;)u[(f=p[g]).i]=f.x(m);return u.join("")}}}var Gs=tc(jl,"px, ","px)","deg)"),Bs=tc(ec,", ",")",")");var wn=0,ar=0,sr=0,nc=1e3,mi,lr,gi=0,qo=0,hi=0,cr=typeof performance=="object"&&performance.now?performance:Date,rc=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ur(){return qo||(rc(Dm),qo=cr.now()+hi)}function Dm(){qo=0}function dr(){this._call=this._time=this._next=null}dr.prototype=yi.prototype={constructor:dr,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?ur():+o)+(t==null?0:+t),!this._next&&lr!==this&&(lr?lr._next=this:mi=this,lr=this),this._call=e,this._time=o,zs()},stop:function(){this._call&&(this._call=null,this._time=1/0,zs())}};function yi(e,t,o){var n=new dr;return n.restart(e,t,o),n}function ic(){ur(),++wn;for(var e=mi,t;e;)(t=qo-e._time)>=0&&e._call.call(void 0,t),e=e._next;--wn}function oc(){qo=(gi=cr.now())+hi,wn=ar=0;try{ic()}finally{wn=0,Vm(),qo=0}}function Om(){var e=cr.now(),t=e-gi;t>nc&&(hi-=t,gi=e)}function Vm(){for(var e,t=mi,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:mi=o);lr=e,zs(n)}function zs(e){if(!wn){ar&&(ar=clearTimeout(ar));var t=e-qo;t>24?(e<1/0&&(ar=setTimeout(oc,e-cr.now()-hi)),sr&&(sr=clearInterval(sr))):(sr||(gi=cr.now(),sr=setInterval(Om,nc)),wn=1,rc(oc))}}function xi(e,t,o){var n=new dr;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var Hm=As("start","end","cancel","interrupt"),Gm=[],lc=0,sc=1,_i=2,Ei=3,ac=4,bi=5,pr=6;function Io(e,t,o,n,r,i){var s=e.__transition;if(!s)e.__transition={};else if(o in s)return;Bm(e,o,{name:t,index:n,group:r,on:Hm,tween:Gm,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:lc})}function fr(e,t){var o=$e(e,t);if(o.state>lc)throw new Error("too late; already scheduled");return o}function Ze(e,t){var o=$e(e,t);if(o.state>Ei)throw new Error("too late; already running");return o}function $e(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function Bm(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=yi(i,0,o.time);function i(c){o.state=sc,o.timer.restart(s,o.delay,o.time),o.delay<=c&&s(c-o.delay)}function s(c){var d,u,p,m;if(o.state!==sc)return l();for(d in n)if(m=n[d],m.name===o.name){if(m.state===Ei)return xi(s);m.state===ac?(m.state=pr,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete n[d]):+d<t&&(m.state=pr,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete n[d])}if(xi(function(){o.state===Ei&&(o.state=ac,o.timer.restart(a,o.delay,o.time),a(c))}),o.state=_i,o.on.call("start",e,e.__data__,o.index,o.group),o.state===_i){for(o.state=Ei,r=new Array(p=o.tween.length),d=0,u=-1;d<p;++d)(m=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++u]=m);r.length=u+1}}function a(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=bi,1),u=-1,p=r.length;++u<p;)r[u].call(e,d);o.state===bi&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=pr,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function Ys(e,t){var o=e.__transition,n,r,i=!0,s;if(o){t=t==null?null:t+"";for(s in o){if((n=o[s]).name!==t){i=!1;continue}r=n.state>_i&&n.state<bi,n.state=pr,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[s]}i&&delete e.__transition}}function cc(e){return this.each(function(){Ys(this,e)})}function zm(e,t){var o,n;return function(){var r=Ze(this,e),i=r.tween;if(i!==o){n=o=i;for(var s=0,a=n.length;s<a;++s)if(n[s].name===t){n=n.slice(),n.splice(s,1);break}}r.tween=n}}function Ym(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=Ze(this,e),s=i.tween;if(s!==n){r=(n=s).slice();for(var a={name:t,value:o},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=a;break}l===c&&r.push(a)}i.tween=r}}function dc(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=$e(this.node(),o).tween,r=0,i=n.length,s;r<i;++r)if((s=n[r]).name===e)return s.value;return null}return this.each((t==null?zm:Ym)(o,e,t))}function In(e,t,o){var n=e._id;return e.each(function(){var r=Ze(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return $e(r,n).value[t]}}function Ti(e,t){var o;return(typeof t=="number"?St:t instanceof wo?ui:(o=wo(t))?(t=o,ui):Vs)(e,t)}function Wm(e){return function(){this.removeAttribute(e)}}function Fm(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Xm(e,t,o){var n,r=o+"",i;return function(){var s=this.getAttribute(e);return s===r?null:s===n?i:i=t(n=s,o)}}function Um(e,t,o){var n,r=o+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===r?null:s===n?i:i=t(n=s,o)}}function $m(e,t,o){var n,r,i;return function(){var s,a=o(this),l;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),l=a+"",s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a)))}}function Km(e,t,o){var n,r,i;return function(){var s,a=o(this),l;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),l=a+"",s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a)))}}function uc(e,t){var o=so(e),n=o==="transform"?Bs:Ti;return this.attrTween(e,typeof t=="function"?(o.local?Km:$m)(o,n,In(this,"attr."+e,t)):t==null?(o.local?Fm:Wm)(o):(o.local?Um:Xm)(o,n,t))}function qm(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function Zm(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function Jm(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Zm(e,i)),o}return r._value=t,r}function Qm(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&qm(e,i)),o}return r._value=t,r}function pc(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=so(e);return this.tween(o,(n.local?Jm:Qm)(n,t))}function jm(e,t){return function(){fr(this,e).delay=+t.apply(this,arguments)}}function eg(e,t){return t=+t,function(){fr(this,e).delay=t}}function fc(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?jm:eg)(t,e)):$e(this.node(),t).delay}function tg(e,t){return function(){Ze(this,e).duration=+t.apply(this,arguments)}}function og(e,t){return t=+t,function(){Ze(this,e).duration=t}}function mc(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?tg:og)(t,e)):$e(this.node(),t).duration}function ng(e,t){if(typeof t!="function")throw new Error;return function(){Ze(this,e).ease=t}}function gc(e){var t=this._id;return arguments.length?this.each(ng(t,e)):$e(this.node(),t).ease}function rg(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;Ze(this,e).ease=o}}function hc(e){if(typeof e!="function")throw new Error;return this.each(rg(this._id,e))}function yc(e){typeof e!="function"&&(e=tr(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new et(n,this._parents,this._name,this._id)}function xc(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,o=e._groups,n=t.length,r=o.length,i=Math.min(n,r),s=new Array(n),a=0;a<i;++a)for(var l=t[a],c=o[a],d=l.length,u=s[a]=new Array(d),p,m=0;m<d;++m)(p=l[m]||c[m])&&(u[m]=p);for(;a<n;++a)s[a]=t[a];return new et(s,this._parents,this._name,this._id)}function ig(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 sg(e,t,o){var n,r,i=ig(t)?fr:Ze;return function(){var s=i(this,e),a=s.on;a!==n&&(r=(n=a).copy()).on(t,o),s.on=r}}function Ec(e,t){var o=this._id;return arguments.length<2?$e(this.node(),o).on.on(e):this.each(sg(o,e,t))}function ag(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function _c(){return this.on("end.remove",ag(this._id))}function bc(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Uo(e));for(var n=this._groups,r=n.length,i=new Array(r),s=0;s<r;++s)for(var a=n[s],l=a.length,c=i[s]=new Array(l),d,u,p=0;p<l;++p)(d=a[p])&&(u=e.call(d,d.__data__,p,a))&&("__data__"in d&&(u.__data__=d.__data__),c[p]=u,Io(c[p],t,o,p,c,$e(d,o)));return new et(i,this._parents,t,o)}function Tc(e){var t=this._name,o=this._id;typeof e!="function"&&(e=er(e));for(var n=this._groups,r=n.length,i=[],s=[],a=0;a<r;++a)for(var l=n[a],c=l.length,d,u=0;u<c;++u)if(d=l[u]){for(var p=e.call(d,d.__data__,u,l),m,g=$e(d,o),x=0,f=p.length;x<f;++x)(m=p[x])&&Io(m,t,o,x,p,g);i.push(p),s.push(d)}return new et(i,s,t,o)}var lg=ao.prototype.constructor;function vc(){return new lg(this._groups,this._parents)}function cg(e,t){var o,n,r;return function(){var i=No(this,e),s=(this.style.removeProperty(e),No(this,e));return i===s?null:i===o&&s===n?r:r=t(o=i,n=s)}}function Nc(e){return function(){this.style.removeProperty(e)}}function dg(e,t,o){var n,r=o+"",i;return function(){var s=No(this,e);return s===r?null:s===n?i:i=t(n=s,o)}}function ug(e,t,o){var n,r,i;return function(){var s=No(this,e),a=o(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),No(this,e))),s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a))}}function pg(e,t){var o,n,r,i="style."+t,s="end."+i,a;return function(){var l=Ze(this,e),c=l.on,d=l.value[i]==null?a||(a=Nc(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(s,r=d),l.on=n}}function wc(e,t,o){var n=(e+="")=="transform"?Gs:Ti;return t==null?this.styleTween(e,cg(e,n)).on("end.style."+e,Nc(e)):typeof t=="function"?this.styleTween(e,ug(e,n,In(this,"style."+e,t))).each(pg(this._id,e)):this.styleTween(e,dg(e,n,t),o).on("end.style."+e,null)}function fg(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function mg(e,t,o){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&fg(e,s,o)),n}return i._value=t,i}function Ic(e,t,o){var n="style."+(e+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;return this.tween(n,mg(e,t,o==null?"":o))}function gg(e){return function(){this.textContent=e}}function hg(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function Ac(e){return this.tween("text",typeof e=="function"?hg(In(this,"text",e)):gg(e==null?"":e+""))}function yg(e){return function(t){this.textContent=e.call(this,t)}}function xg(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&yg(r)),t}return n._value=e,n}function Sc(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,xg(e))}function Cc(){for(var e=this._name,t=this._id,o=vi(),n=this._groups,r=n.length,i=0;i<r;++i)for(var s=n[i],a=s.length,l,c=0;c<a;++c)if(l=s[c]){var d=$e(l,t);Io(l,e,o,c,s,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new et(n,this._parents,e,o)}function Mc(){var e,t,o=this,n=o._id,r=o.size();return new Promise(function(i,s){var a={value:s},l={value:function(){--r===0&&i()}};o.each(function(){var c=Ze(this,n),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(l)),c.on=t}),r===0&&i()})}var Eg=0;function et(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function Pc(e){return ao().transition(e)}function vi(){return++Eg}var lo=ao.prototype;et.prototype=Pc.prototype={constructor:et,select:bc,selectAll:Tc,selectChild:lo.selectChild,selectChildren:lo.selectChildren,filter:yc,merge:xc,selection:vc,transition:Cc,call:lo.call,nodes:lo.nodes,node:lo.node,size:lo.size,empty:lo.empty,each:lo.each,on:Ec,attr:uc,attrTween:pc,style:wc,styleTween:Ic,text:Ac,textTween:Sc,remove:_c,tween:dc,delay:fc,duration:mc,ease:gc,easeVarying:hc,end:Mc,[Symbol.iterator]:lo[Symbol.iterator]};function Ni(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var _g={time:null,delay:0,duration:250,ease:Ni};function bg(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 Lc(e){var t,o;e instanceof et?(t=e._id,e=e._name):(t=vi(),(o=_g).time=ur(),e=e==null?null:e+"");for(var n=this._groups,r=n.length,i=0;i<r;++i)for(var s=n[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&Io(l,e,t,c,s,o||bg(l,t));return new et(n,this._parents,e,t)}ao.prototype.interrupt=cc;ao.prototype.transition=Lc;function Ao(e,t,o){this.k=e,this.x=t,this.y=o}Ao.prototype={constructor:Ao,scale:function(e){return e===1?this:new Ao(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ao(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 wi=new Ao(1,0,0);Ii.prototype=Ao.prototype;function Ii(e){for(;!e.__zoom;)if(!(e=e.parentNode))return wi;return e.__zoom}var vg=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var kc;(function(e){e.Strict="strict",e.Loose="loose"})(kc||(kc={}));var Rc;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Rc||(Rc={}));var Dc;(function(e){e.Partial="partial",e.Full="full"})(Dc||(Dc={}));var Oc;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Oc||(Oc={}));var Vc;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Vc||(Vc={}));var st;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(st||(st={}));var S1={[st.Left]:st.Right,[st.Right]:st.Left,[st.Top]:st.Bottom,[st.Bottom]:st.Top};var Ng=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var wg=(e,t=[0,0])=>{var a;let{width:o,height:n}=Ig(e),r=(a=e.origin)!=null?a:t,i=o*r[0],s=n*r[1];return{x:e.position.x-i,y:e.position.y-s}};var Ai=(e,t=[0,0])=>{var r,i,s,a,l,c,d,u;let{x:o,y:n}=Ng(e)?e.internals.positionAbsolute:wg(e,t);return{x:o,y:n,x2:o+((a=(s=(i=(r=e.measured)==null?void 0:r.width)!=null?i:e.width)!=null?s:e.initialWidth)!=null?a:0),y2:n+((u=(d=(c=(l=e.measured)==null?void 0:l.height)!=null?c:e.height)!=null?d:e.initialHeight)!=null?u:0)}};function Ig(e){var t,o,n,r,i,s,a,l;return{width:(r=(n=(o=(t=e.measured)==null?void 0:t.width)!=null?o:e.width)!=null?n:e.initialWidth)!=null?r:0,height:(l=(a=(s=(i=e.measured)==null?void 0:i.height)!=null?s:e.height)!=null?a:e.initialHeight)!=null?l:0}}var C1={[st.Left]:{x:-1,y:0},[st.Right]:{x:1,y:0},[st.Top]:{x:0,y:-1},[st.Bottom]:{x:0,y:1}};var Ag={nodeOrigin:[0,0],nodeExtent:vg,elevateNodesOnSelect:!0,defaults:{}},M1=w(_({},Ag),{checkEquality:!0});var Hc;(function(e){e.Line="line",e.Handle="handle"})(Hc||(Hc={}));var Sg={width:0,height:0,x:0,y:0},P1=w(_({},Sg),{pointerX:0,pointerY:0,aspectRatio:1});var Cg=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function Mg(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 Pg(e,t){let o=Math.max(0,Math.max(e.x-t.x2,t.x-e.x2)),n=Math.max(0,Math.max(e.y-t.y2,t.y-e.y2));return Math.sqrt(o*o+n*n)}var Si=class{constructor(){this.xLines=[];this.yLines=[]}initialize(t){this.xLines=t.filter(o=>o.orientation==="vertical"),this.yLines=t.filter(o=>o.orientation==="horizontal"),this.xLines.sort((o,n)=>o.position-n.position),this.yLines.sort((o,n)=>o.position-n.position),this.lastHorizontalLine=void 0,this.lastVerticalLine=void 0}search(t,o,n,r,i){let s=t==="horizontal"?this.yLines:this.xLines,[a,l]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],c=[];for(let m of s){if(m.position<a)continue;if(m.position>l)break;if(i.has(m.node.id)||m.node.parentId&&i.has(m.node.parentId)||!Cg(m.nodeBox,r))continue;let g=Math.abs(m.position-o);if(g>Ci)continue;let f=Mg(m.nodeBox,n)>0?0:Pg(m.nodeBox,n);c.push({line:m,lineDist:g,nodeDist:f})}let d=.5,u=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;c.sort((m,g)=>{if(u){if(m.line===u&&g.line!==u)return-1;if(g.line===u&&m.line!==u)return 1}return Math.abs(m.lineDist-g.lineDist)<=d?m.nodeDist-g.nodeDist:m.lineDist-g.lineDist});let p=c.length>0?c[0].line:void 0;return p&&(t==="horizontal"?this.lastHorizontalLine=p:this.lastVerticalLine=p),p}};function Gc(e,t=Zo,o){let n=[];return e==null||e.forEach(r=>{let i=o(r.id);if(!i)throw new Error(`Node with id ${r.id} not found in internal nodes.`);let s=Ai(i);Object.entries(t).forEach(([a,l])=>{var c;n.push({position:l.resolve(r,s),color:(c=r.style)==null?void 0:c.backgroundColor,orientation:l.orientation,anchorName:a,nodeBox:s,node:r})})}),n}function Bc(e,t,o,n,r=Object.keys(Zo)){let i=[];for(let a of r){let l=Zo[a],c=l.resolve(null,o),d=e.search(l.orientation,c,o,t,n);d&&i.push({sourcePosition:c,anchorName:a,anchor:l,line:d})}let s={horizontal:void 0,vertical:void 0};for(let a of i){let l=s[a.anchor.orientation],c=Math.abs(a.sourcePosition-a.line.position);(!l||c<Math.abs(l.sourcePosition-l.line.position))&&(s[a.anchor.orientation]=a)}return s}function zc(e,t,o){let n=0,r=0,i=!1,s=!1;if(t){let l=t.anchor.resolve(null,e)-t.line.position;Math.abs(l)<=Ci&&(r=l,s=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=Ci&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:s}}var Ci=10,Zo={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 Wc=require("react/jsx-runtime"),Lg=new Si;function Mi(){let[e,t]=(0,pt.useState)(void 0),[o,n]=(0,pt.useState)(void 0),{width:r,height:i}=(0,An.useStore)(f=>({width:f.width,height:f.height}),Yc.shallow),s=(0,An.useNodesInitialized)(),a=(0,pt.useRef)(Lg),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=(0,An.useReactFlow)(),u=(0,pt.useCallback)(()=>{t(void 0),n(void 0)},[]),p=(0,pt.useCallback)(f=>{let h=f!=null?f:d();u();let y=Gc(h,Zo,c);a.current.initialize(y)},[c,u,d]),m=(0,pt.useCallback)(()=>{setTimeout(()=>{p()},100)},[p]);(0,pt.useEffect)(()=>{s&&p(d())},[s,p,d]);let g=(0,pt.useCallback)((f,h)=>{var G,k,O,Y,W,U,X,$,te,ie;if(!a.current||f.length===0||f.filter(F=>F.type==="dimensions").length>1)return f;u();let E=f.filter(F=>F.type==="position"&&!!F.position),N=f.find(F=>F.type==="dimensions");if(E.length===0&&!N)return f;let b=Object.keys(Zo),v=new Set,T=1/0,I=1/0,S=-1/0,P=-1/0;if(E.length>0)E.forEach(F=>{var de,re,ee,xe,Se,Re;let oe=h.find(qe=>qe.id===F.id);if(!oe)return;v.add(oe.id);let le=c(oe.id);if(!le)return;let Z=le.parentId?c(le.parentId):void 0,ve=F.position.x+((de=Z==null?void 0:Z.internals.positionAbsolute.x)!=null?de:0),ye=F.position.y+((re=Z==null?void 0:Z.internals.positionAbsolute.y)!=null?re:0),Ae=(xe=(ee=oe.measured)==null?void 0:ee.width)!=null?xe:0,J=(Re=(Se=oe.measured)==null?void 0:Se.height)!=null?Re:0;T=Math.min(T,ve),I=Math.min(I,ye),S=Math.max(S,ve+Ae),P=Math.max(P,ye+J)}),N&&(b=["top","left"]);else if(N){let F=h.find(Ae=>Ae.id===N.id);if(!F)return f;v.add(F.id);let oe=c(F.id);if(!oe)return f;let le=oe.internals.positionAbsolute.x,Z=oe.internals.positionAbsolute.y,ve=(Y=(O=(G=N.dimensions)==null?void 0:G.width)!=null?O:(k=F.measured)==null?void 0:k.width)!=null?Y:0,ye=($=(X=(W=N.dimensions)==null?void 0:W.height)!=null?X:(U=F.measured)==null?void 0:U.height)!=null?$:0;T=le,I=Z,S=le+ve,P=Z+ye,b=["right","bottom"]}if(T===1/0)return f;let R={x:T,y:I,x2:S,y2:P},{x:C,y:L}=l({x:0,y:0}),{x:K,y:Q}=l({x:r,y:i}),j={x:C,y:L,x2:K,y2:Q},{horizontal:z,vertical:M}=Bc(a.current,j,R,v,b),{deltaX:V,deltaY:D,snappedX:A,snappedY:B}=zc(R,z,M);if(A||B){let F=E.some(le=>le.dragging),oe=!!(N!=null&&N.resizing);(F||oe)&&(A&&n(M==null?void 0:M.line),B&&t(z==null?void 0:z.line)),A&&(E.forEach(le=>{le.position&&(le.position.x-=V)}),(N==null?void 0:N.id)===((te=E[0])==null?void 0:te.id)?N.dimensions&&(N.dimensions.width+=V):N&&!E.length&&N.dimensions&&(N.dimensions.width-=V)),B&&(E.forEach(le=>{le.position&&(le.position.y-=D)}),(N==null?void 0:N.id)===((ie=E[0])==null?void 0:ie.id)?N.dimensions&&(N.dimensions.height+=D):N&&!E.length&&N.dimensions&&(N.dimensions.height-=D))}return f},[l,c,r,i,t,n,u]),x=(0,pt.useCallback)(()=>(0,Wc.jsx)(Fc,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:p,forceRebuildIndex:m,updateHelperLines:g,helperLineHorizontal:e,helperLineVertical:o,HelperLines:x}}var ss=require("@xyflow/react"),Qt=require("react");var co=e=>new Map(e.map(t=>[t.id,t])),mr=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),Xc=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),Ws=e=>e.some(t=>t.type==="START_EVENT"),So=(e,t)=>e==="START_EVENT"?!Ws(t):!0,Uc=(e,t,o,n,r)=>{let i=co(o),s=i.get(e);if(!s||s.type!=="START_EVENT")return!1;let a=i.get(t);return(a==null?void 0:a.type)==="ANNOTATION"?!1:mr(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},$c=(e,t,o,n,r)=>{let i=co(o),s=i.get(t);if(!s||s.type!=="END_EVENT")return!1;let a=i.get(e);return(a==null?void 0:a.type)==="ANNOTATION"?!1:Xc(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Pi=(e,t,o,n,r)=>{var c;let i=co(o),s=i.get(e);if(!s||s.type!=="GATEWAY"||((c=s.data)==null?void 0:c.variant)!=="EXCLUSIVE")return!1;let a=t?i.get(t):null;return(a==null?void 0:a.type)==="ANNOTATION"?!1:mr(e,n,r).filter(d=>{let u=i.get(d.target);return(u==null?void 0:u.type)!=="ANNOTATION"}).length>=2},Kc=(e,t,o)=>{var s,a,l,c;let n=co(o),r=n.get(e),i=n.get(t);return(r==null?void 0:r.type)!=="GATEWAY"||(i==null?void 0:i.type)!=="GATEWAY"||((s=r==null?void 0:r.data)==null?void 0:s.variant)==="EXCLUSIVE"&&((a=i==null?void 0:i.data)==null?void 0:a.variant)==="PARALLEL"||((l=r==null?void 0:r.data)==null?void 0:l.variant)==="COMPLEX"&&((c=i==null?void 0:i.data)==null?void 0:c.variant)==="PARALLEL"},Li=(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"},qc=(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"},gr=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SERVICE_TASK"},ki=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.attribute)==="LOOP"},Jo=(e,t,o,n)=>{let r=co(t),i=r.get(e);return!i||i.type!=="TASK"?!1:Xc(e,o,n).some(a=>{let l=r.get(a.source);return(l==null?void 0:l.type)==="START_EVENT"})},hr=(e,t,o,n)=>{let r=co(t),i=r.get(e);return!i||i.type!=="TASK"?!1:mr(e,o,n).some(a=>{let l=r.get(a.target);return(l==null?void 0:l.type)==="END_EVENT"})},Zc=(e,t,o,n,r)=>{let i=co(o),s=i.get(e),a=i.get(t);return(s==null?void 0:s.type)==="START_EVENT"&&(a==null?void 0:a.type)==="TASK"?hr(t,o,n,r):(a==null?void 0:a.type)==="END_EVENT"&&(s==null?void 0:s.type)==="TASK"?Jo(e,o,n,r):!1},Ri=(e,t,o)=>mr(e,t,o).length>0,Di=(e,t,o,n,r)=>{let i=co(o),s=i.get(e);if(!s||s.type!=="TASK")return!1;let a=t?i.get(t):null;return(a==null?void 0:a.type)==="ANNOTATION"?!1:mr(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var Jc=(e,t,o,n,r)=>{var a,l;let i=co(n),s=((a=i.get(e))==null?void 0:a.type)==="ANNOTATION"||((l=i.get(t))==null?void 0:l.type)==="ANNOTATION";return o.some(c=>r&&c.id===r?!1:!!(c.source===e&&c.target===t||s&&c.source===t&&c.target===e))};var kg=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!Jc(e.sourceNodeId,e.targetNodeId,e.edges,e.nodes,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!Uc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!$c(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!Pi(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!Di(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:Kc(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"&&qc(e.targetNodeId,e.nodes)),reason:"start_event_to_subprocess_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&gr(e.targetNodeId,e.nodes)),reason:"start_event_to_service_task_not_allowed"}),e=>({isValid:!(gr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"service_task_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="GATEWAY"&&e.targetNodeType==="END_EVENT"),reason:"gateway_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&e.targetNodeType==="GATEWAY"),reason:"start_to_gateway_not_allowed"}),e=>({isValid:!(Li(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(ki(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(Jo(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!Zc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(hr(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(Ri(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"})],Fs=e=>{for(let t of kg){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var Rg=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:Pi(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:Ws(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Li(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:ki(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:gr(e.sourceNodeId,e.nodes),reason:"service_task_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Jo(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:hr(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Ri(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Di(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],Qc=e=>{let t=Rg.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 Xt=require("@produto-lecom/lecom-ui"),ed=require("lucide-react");var Ct=require("@xyflow/react");var jc=require("@xyflow/react"),Co=()=>{let e=(0,jc.useStoreApi)();return{selectElements:n=>{let{edges:r,nodes:i,triggerEdgeChanges:s,triggerNodeChanges:a}=e.getState(),l=i.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]),c=r.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]);return a(l),s(c),!0},clearSelection:async()=>{let{unselectNodesAndEdges:n}=e.getState();return n(),await Fr(),!0}}};var Oi=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=(0,Ct.useReactFlow)(),{selectElements:r}=Co(),i=f=>{let h=o(),y=n(),E=(0,Ct.getIncomers)(f,h,y),N=(0,Ct.getOutgoers)(f,h,y),b=E.some(T=>T.type==="START_EVENT"),v=N.some(T=>T.type==="END_EVENT");return b?"start":v?"end":"between"},s=(f,h,y)=>{var b,v,T,I,S;if(!f)return;let E={type:f.type,variant:(b=f.data)==null?void 0:b.variant,attribute:(v=f.data)==null?void 0:v.attribute},N={id:f.id,position:i(f),label:(T=f.data)==null?void 0:T.label,node:E};return f.type==="TASK"&&((I=f.data)==null?void 0:I.variant)==="SUBPROCESS"?w(_({},N),{type:"sub_process"}):f.type==="TASK"&&((S=f.data)==null?void 0:S.variant)==="SERVICE_TASK"?w(_({},N),{type:"service_task"}):f.type==="GATEWAY"?w(_({},N),{type:"gateway",variant:a(f,h,y)}):w(_({},N),{type:"activity"})},a=(f,h,y)=>{if(f.type!=="GATEWAY")return;let E=(0,Ct.getIncomers)(f,h,y),N=!1,b=!1;if(E.forEach(v=>{var T,I;v.type==="TASK"&&(((T=v.data)==null?void 0:T.variant)==="SCRIPT"&&(N=!0),((I=v.data)==null?void 0:I.attribute)==="LOOP"&&(b=!0))}),N&&b)return"script_loop";if(N)return"script";if(b)return"loop"},l=(f,h,y)=>{var T,I,S,P,R;let E=e(f.source),N=e(f.target);if(!E||!N)return"simple";if((0,Ct.getOutgoers)(E,h,y).some(C=>C.type==="END_EVENT"))return"final";if(E.type==="GATEWAY")switch((T=E.data)==null?void 0:T.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(E.type==="TASK"){let C=(I=E.data)==null?void 0:I.variant,L=(S=E.data)==null?void 0:S.attribute;if(C==="SUBPROCESS")return"from_sub_process";if(C==="SERVICE_TASK")return"from_service_task";if(N.type==="TASK"&&((P=N.data)==null?void 0:P.variant)==="SUBPROCESS")return"to_sub_process";if(N.type==="TASK"&&((R=N.data)==null?void 0:R.variant)==="SERVICE_TASK")return"to_service_task";let K=C==="SCRIPT",Q=L==="LOOP";return K&&Q?"script_loop":K?"script":Q?"loop":"simple"}return"simple"},c=(f,h,y)=>{let E=[];function N(v,T,I=0){let S=s(v,h,y);if(S.depth=I,T.push(S),v.type==="TASK"){E.push([...T]),T.pop();return}let P=(0,Ct.getIncomers)(v,h,y);if(P.length)for(let R of P)N(R,T,I+1);T.pop()}let b=(0,Ct.getIncomers)(f,h,y);for(let v of b)N(v,[]);return E},d=(f,h,y)=>{let E=[];function N(v,T,I=0){let S=s(v,h,y);if(S.depth=I,T.push(S),v.type==="TASK"){E.push([...T]),T.pop();return}let P=(0,Ct.getOutgoers)(v,h,y);if(P.length)for(let R of P)N(R,T,I+1);T.pop()}let b=(0,Ct.getOutgoers)(f,h,y);for(let v of b)N(v,[]);return E},u=(f,h,y)=>(y=y.filter(N=>N.source===f.id),y.map(N=>{var T;let b=e(N.target),v;return b&&(v=s(b,h,y)),{id:N.id,type:"routing",variant:l(N,h,y),label:(T=N.data)==null?void 0:T.label,target:v}})),p=f=>{let h=e(f);if(!h)return;let y=o(),E=n(),N=s(h,y,E);return N.sources=c(h,y,E),N.targets=d(h,y,E),N.edgeTargets=u(h,y,E),h.type==="GATEWAY"&&(N.variant=a(h,y,E)),N},m=f=>{let h=t(f);if(!h)return;let y=o(),E=n(),N=l(h,y,E),v={id:h.id,type:"routing",variant:N,gatewayVariant:void 0},T=e(h.source);if(T){let S=s(T,y,E);v.source=S;let P=a(T,y,E);if(v.gatewayVariant=P,T.type==="TASK")v.sources=[[S]];else{let R=c(T,y,E);v.sources=R.length?R:[[S]]}}let I=e(h.target);if(I){let S=s(I,y,E);if(v.target=S,I.type==="TASK")v.targets=[[S]];else{let P=d(I,y,E);v.targets=P.length?P:[[S]]}}return v},g=f=>{let h=e(f);if(h)return p(h.id);let y=t(f);if(y)return m(y.id)};return{configureElement:f=>{let h=g(f);if(h)return r([f]),h},getConfigureElement:g,getNodeConfigure:p,getEdgeConfigure:m}};var Qo=require("react/jsx-runtime"),Dg={node:"editor.toolbar.configure_node",edge:"editor.toolbar.configure_edge",gateway:"editor.toolbar.configure_gateway"},Mo=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,Xt.useTranslation)(),{onConfigureElement:n}=q(),{getConfigureElement:r}=Oi();return(0,Qo.jsxs)(Xt.Tooltip,{children:[(0,Qo.jsx)(Xt.TooltipTrigger,{asChild:!0,children:(0,Qo.jsx)(Xt.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let s=r(e);s&&(n==null||n(s))},children:(0,Qo.jsx)(ed.Settings,{size:16})})}),(0,Qo.jsx)(Xt.TooltipContent,{color:"black",children:o(Dg[t])})]})};var Ut=require("@produto-lecom/lecom-ui"),od=require("@xyflow/react"),nd=require("lucide-react");var td=require("@produto-lecom/lecom-ui");function at(){let{toast:e}=Sn(),{toast:t}=(0,td.useNotificationToast)();return{toast:e||t}}var jo=require("react/jsx-runtime"),Vi=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,Ut.useTranslation)(),{toast:n}=at(),{deleteElements:r,getNodes:i}=(0,od.useReactFlow)();return(0,jo.jsxs)(Ut.Tooltip,{children:[(0,jo.jsx)(Ut.TooltipTrigger,{asChild:!0,children:(0,jo.jsx)(Ut.Button,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{if(t==="node"){let a=i(),l=a.find(c=>c.id===e);if((l==null?void 0:l.type)==="LANE"&&a.some(d=>d.parentId===e)){n({variant:"error",title:o("validation.errors.title"),content:o("editor.toolbar.delete_pool_lane_error")});return}r({nodes:[{id:e}]})}else r({edges:[{id:e}]})},children:(0,jo.jsx)(nd.TrashIcon,{size:16})})}),(0,jo.jsx)(Ut.TooltipContent,{color:"black",children:o("editor.toolbar.delete")})]})};var $t=require("@produto-lecom/lecom-ui"),rd=require("lucide-react"),id=require("react"),en=require("react/jsx-runtime"),Cn=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=(0,$t.useTranslation)(),r=(0,id.useCallback)(i=>{i.stopPropagation();let s=document.querySelectorAll(`.react-flow__handle.source[data-nodeid="${e}"]`);if(s.length===0)return;let a=Array.from(s).reduce((p,m)=>{let g=p.getBoundingClientRect(),x=m.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?m:p}),l=a.getBoundingClientRect(),c=l.left+l.width/2,d=l.top+l.height/2,u=new MouseEvent("mousedown",{clientX:c,clientY:d,bubbles:!0,cancelable:!0});a.dispatchEvent(u)},[e]);return(0,en.jsxs)($t.Tooltip,{children:[(0,en.jsx)($t.TooltipTrigger,{asChild:!0,children:(0,en.jsx)($t.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,en.jsx)(rd.MoveUpRightIcon,{size:16})})}),(0,en.jsx)($t.TooltipContent,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};var Mn=require("react/jsx-runtime"),Pn=i=>{var s=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=s,r=Wt(s,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:a}=q(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d,isToEndEvent:u}=Jr(o,n),p=!l&&!c&&!d&&!u,m=[{component:(0,Mn.jsx)(Vi,{elementId:e,elementType:"edge"})}],g=()=>a==="view"?p?[{component:(0,Mn.jsx)(Mo,{elementId:e,elementType:"edge"})}]:[]:p?[{component:(0,Mn.jsx)(Mo,{elementId:e,elementType:"edge"})},...m]:m,f=(h=>{switch(h){case"SEQUENCE_EDGE":return g();case"MESSAGE_EDGE":return a==="view"?[]:[...m];case"ANNOTATION_EDGE":return a==="view"?[]:[...m];default:return[]}})(t);if(!(f.length===0||a==="readonly"))return(0,Mn.jsx)("div",w(_({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,Mn.jsx)("div",{children:h.component},y))}))};var sd=require("@xyflow/react"),ad=require("react");var Xs=require("react/jsx-runtime"),Kt=12,Ln=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:s}=(0,sd.useViewport)(),a=1/s,l=(0,ad.useMemo)(()=>t===n?{bottom:`${Kt}px`,transform:"translateX(-50%)"}:e===o?{left:`${Kt}px`,transform:r?"translateY(-100%)":"translateY(-50%)"}:n>t&&o>e?{left:`${Kt}px`,bottom:`${Kt}px`}:n>t&&o<e?{right:`${Kt}px`,bottom:`${Kt}px`}:t>n&&o>e?{right:`${Kt}px`,bottom:`${Kt}px`}:{left:`${Kt}px`,bottom:`${Kt}px`},[e,t,o,n,r]);return(0,Xs.jsx)("div",{style:{transform:`scale(${a})`},children:(0,Xs.jsx)("div",{className:"absolute pointer-events-auto",style:_({},l),children:i})})};var ft=require("react/jsx-runtime"),kn={type:"ANNOTATION_EDGE",reconnectable:!0},ld=({id:e,source:t,target:o,selected:n,data:r})=>{let{isMultipleSelection:i,isReadOnly:s,edgeHighlight:a}=q(),{zoom:l}=(0,Dt.useViewport)(),c=(0,Dt.useInternalNode)(t),d=(0,Dt.useInternalNode)(o);if(!c||!d)return null;let{sx:u,sy:p,tx:m,ty:g}=Tn(c,d),[x,f,h]=(0,Dt.getStraightPath)({sourceX:u,sourceY:p,targetX:m,targetY:g}),y=a&&(n||(c==null?void 0:c.selected)||(d==null?void 0:d.selected));return(0,ft.jsx)(ft.Fragment,{children:(0,ft.jsxs)("g",{className:H("group bpmn-edge",{"is-highlighted":y}),children:[(0,ft.jsx)("path",{d:x,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/l),style:{pointerEvents:"stroke",cursor:"pointer"}}),(0,ft.jsxs)("g",{className:H("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!s,"text-blue-500 group-hover:text-blue-600":y}),children:[(0,ft.jsx)(Dt.BaseEdge,{id:e,path:x,interactionWidth:0,strokeDasharray:4,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":r==null?void 0:r.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":y&&!(r!=null&&r.hasError)})}),(0,ft.jsx)(Dt.EdgeLabelRenderer,{children:(0,ft.jsx)("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${f}px, ${h}px)`},children:n&&!i&&(0,ft.jsx)(Ln,{sx:u,sy:p,tx:m,ty:g,children:(0,ft.jsx)(Pn,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})})})]})]})})};var je=require("react"),Me=require("@xyflow/react");var Ot=require("react");var $s=require("react/jsx-runtime"),Us=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,cd=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Escape","Shift"],Qe=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:s,onBlur:a,onInput:l,onInvalidFirstCharacter:c,skipFirstCharValidation:d})=>{let u=(0,Ot.useRef)(null),p=(0,Ot.useRef)(null),[m,g]=(0,Ot.useState)(!1);(0,Ot.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]),(0,Ot.useEffect)(()=>{g(i!=null?i:!1)},[i]),(0,Ot.useEffect)(()=>{if(m&&u.current){u.current.focus();let b=document.createRange();b.selectNodeContents(u.current);let v=window.getSelection();v&&(v.removeAllRanges(),v.addRange(b))}},[m]);let x=(0,Ot.useCallback)(()=>{p.current||(c==null||c(),p.current=setTimeout(()=>{p.current=null},500))},[c]),f=b=>{b.stopPropagation(),m||g(!0)},h=b=>{let v=b.currentTarget.innerText.replace(/\n$/,""),T=t&&v.length>=t,I=window.getSelection(),S=(I==null?void 0:I.toString())||"",P=S.length>0,R=(b.ctrlKey||b.metaKey)&&!b.altKey,C=R&&b.key==="a",L=R&&b.key==="c",K=R&&b.key==="x",Q=R&&b.key==="v",j=v.length===0||P&&S.length===v.length;if(!d&&j&&!Us.test(b.key)&&!cd.includes(b.key)&&!R){b.preventDefault(),x();return}T&&!P&&(cd.includes(b.key)||C||L||K||Q||b.preventDefault())},y=b=>{b.preventDefault();let v=b.clipboardData.getData("text/plain").replace(/\r\n/g,`
1
+ "use strict";var lf=Object.create;var Xn=Object.defineProperty,cf=Object.defineProperties,df=Object.getOwnPropertyDescriptor,uf=Object.getOwnPropertyDescriptors,pf=Object.getOwnPropertyNames,Or=Object.getOwnPropertySymbols,ff=Object.getPrototypeOf,ys=Object.prototype.hasOwnProperty,ya=Object.prototype.propertyIsEnumerable;var ha=(e,t,o)=>t in e?Xn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,_=(e,t)=>{for(var o in t||(t={}))ys.call(t,o)&&ha(e,o,t[o]);if(Or)for(var o of Or(t))ya.call(t,o)&&ha(e,o,t[o]);return e},w=(e,t)=>cf(e,uf(t));var Wt=(e,t)=>{var o={};for(var n in e)ys.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Or)for(var n of Or(e))t.indexOf(n)<0&&ya.call(e,n)&&(o[n]=e[n]);return o};var mf=(e,t)=>{for(var o in t)Xn(e,o,{get:t[o],enumerable:!0})},xa=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of pf(t))!ys.call(e,r)&&r!==o&&Xn(e,r,{get:()=>t[r],enumerable:!(n=df(t,r))||n.enumerable});return e};var gf=(e,t,o)=>(o=e!=null?lf(ff(e)):{},xa(t||!e||!e.__esModule?Xn(o,"default",{value:e,enumerable:!0}):o,e)),hf=e=>xa(Xn({},"__esModule",{value:!0}),e);var gy={};mf(gy,{EditorMode:()=>Ye,ElementPosition:()=>Hr,ElementType:()=>Un,GatewayElementVariant:()=>Gr,GatewayVariant:()=>It,Modeler:()=>af,ModelerProvider:()=>of,NodeAttribute:()=>kt,NodeType:()=>se,NodeVariant:()=>rt,RoutingVariant:()=>Br,useModeler:()=>Sn});module.exports=hf(gy);var xs=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 Vr=require("@produto-lecom/lecom-ui");var Ea={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Delete",configure_node:"Configure activity",configure_edge:"Configure routing",configure_gateway:"Configure routing",initial_task:"Initial Activity",gateway_limit_reached:"Exclusive gateway cannot have more than 2 outgoing connections",task_limit_reached:"Task cannot have more than 2 outgoing connections",start_event_limit_reached:"Start event can only connect to a single element",gateway_to_gateway_not_allowed:"Gateways cannot connect directly to other gateways",start_event_already_exists:"A start event already exists. Delete the current event to add another",script_to_end_not_allowed:"Script activities cannot connect directly to the end event",loop_to_end_not_allowed:"Loop activities cannot connect directly to the end event",initial_activity_to_end_not_allowed:"Initial activity cannot connect directly to the end event",final_activity_cannot_connect:"Final activity cannot connect to other elements",activity_has_outgoing_connections:"Activity with outgoing connections cannot connect to end event",end_event_cannot_connect_to_initial_activity:"End event cannot connect to an initial activity",initial_activity_cannot_connect_to_start_event:"Initial activity cannot connect to start event",concurrent_initial_and_final_activity:"An activity cannot be connected to both start and end events",start_event_to_service_task_not_allowed:"Start event cannot connect to an automatic activity",service_task_to_end_not_allowed:"Automatic activities cannot connect to the end event",duplicate_connection_not_allowed:"A connection already exists between these elements",connect_node:"Connect element",connecting:"Connecting...",delete_pool_lane_error:"Cannot delete the pool or lane while there are elements inside it."},controls:{zoom:{fit:"Fit zoom",in:"Zoom in",out:"Zoom out",reset:"Reset zoom"},actions:{move_tool:"Select elements",hand_tool:"Navigate the diagram",check:"Check diagram",check_loading:"Validating diagram...",export:{title:"Export diagram",print:"Print",html:"Export as HTML",png:"Export as PNG",feedback:{empty:"Cannot export an empty diagram",error:"Error exporting diagram"}},import_governance:"Import diagram from Governance platform",minimap:{label:"Minimap",open:"Open minimap",close:"Hide minimap"}},history:{undo:"Undo",redo:"Redo"}},modals:{delete_elements:{title:"Delete elements",callout:"When deleting, the activity and routing settings will be deleted.",content:"Are you sure you want to delete?",confirm:"Delete",cancel:"Cancel"}},task_menu:{loop_not_allowed_when_connected_to_end:"Cannot create loop on activity connected to end event",script_not_allowed_when_connected_to_end:"Cannot transform to Script activity connected to end event",loop_not_allowed_when_subprocess:"Cannot create loop on subprocess",loop_not_allowed_when_service_task:"Cannot create loop on automatic activity",loop:"Activity with loop"}},validation:{success:{title:"Validation Successful",message:"The diagram was validated successfully with no errors."},errors:{title:"The diagram contains errors",subtitle:"Please review the following:",task_label_length:"Task name exceeds the maximum character limit",multiple_start_event_not_allowed:"Multiple start events are not allowed",task_flows_limit_exceeds:"The number of output connections exceeds the limit of two",duplicate_task_name:"There are multiple activities with the same name",flows_on_end_tasks_not_allowed:"Activities connected to end events cannot have other connections",conditions_flows_limit_exceeds:"Exclusive gateway has too many output connections (maximum of two)",task_label_empty:"One or more activities have no name",activity_name_invalid:"Activity name is invalid",final_activity_has_loop:"Final activities cannot have loops",nested_gateway:"Connecting gateways directly is not allowed",concurrent_initial_and_final_event:"The same activity cannot have both initial and final events",gateway_flow_to_event:"Connecting a gateway to an output event is not allowed",gateway_missing_output_streams:"The gateway does not have the correct number of outputs",events_nested:"Connecting events directly is not allowed",event_to_condition:"Connecting an event directly to a gateway is not allowed",script_in_final_activity:"Final activity cannot be a script type",subprocess_not_configured:"The subprocess reference is not properly configured",cannot_validate_subprocess_reference:"Could not validate whether the subprocess reference is configured",start_event_not_found:"At least one start event is required",end_event_not_found:"At least one end event is required",service_task_without_rejection_routing:"Automated activity (RPA) without rejection routing configured",service_task_without_automation:"Automated activity (RPA) without a configured robot",service_task_connector_inactive:"Automated activity (RPA) linked to an inactive connector",service_task_integration_suspended:"Automated activity (RPA) linked to a suspended integration",service_task_automation_status_unavailable:"Could not verify the automation (RPA) status",service_task_initial_or_final:"Automated activity (RPA) cannot be an initial, final or concentrator step",service_task_in_loop:"Automated activity (RPA) cannot be in a loop"}},bpmn:{start_event:{variant:{default:"Start event"}},end_event:{variant:{default:"End event"}},annotation:{variant:{default:"Annotation"}},gateway:{menu:{title:"Change gateway type"},variant:{default:"Gateway",exclusive:"Exclusive gateway",parallel:"Parallel gateway",complex:"Complex gateway"}},task:{menu:{title:"Change task type"},variant:{default:"Task",script:"Script task",subprocess:"Subprocess",service_task:"RPA"},attribute:{loop:"Task with loop"},label:{prefix:"Activity"},feedback:{label_empty:{prefix:"Activity name was automatically set to"},label_already_exists:{prefix:"The name",middle:"already exists. The name was changed to"},invalid_first_character:"Activity name must start with a letter or number"}},lane:{variant:{default:"Pool / Lane"}},unsupported:{variant:{default:"Unsupported element"}}},adapter:{governance:{error:{DEFAULT:"Error importing diagram",NO_FILE:"No file selected",EMPTY_FILE:"Empty file",INVALID_FILE:"Invalid file",CONTAIN_NO_CELLS:"No cells found to be imported",ALREADY_INITIALIZED:"It is not possible to import the diagram from the Governance platform, since the diagram has already been initialized"},success:{default:"The diagram was imported from the Governance platform successfully and without any incompatibility detected.",incompatible_cells:"The diagram was imported from the Governance platform with incompatibilities. To know more details, click on the button below."},report:{columns:{type:"Type",value:"Value",status:"Status"},status:{imported:"Imported",adapted:"Adapted",unsupported:"Unsupported"}},action:{download:"Download report"}}}}};var _a={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",configure_node:"Configurar actividad",configure_edge:"Configurar enrutamiento",configure_gateway:"Configurar enrutamiento",initial_task:"Actividad Inicial",gateway_limit_reached:"Compuerta exclusiva no puede tener m\xE1s de 2 conexiones de salida",task_limit_reached:"Actividad no puede tener m\xE1s de 2 conexiones de salida",start_event_limit_reached:"Evento inicial solo puede conectarse a un \xFAnico elemento",gateway_to_gateway_not_allowed:"Las compuertas no pueden conectarse directamente con otras compuertas",start_event_already_exists:"Ya existe un evento de inicio. Elimine el evento actual para agregar otro",script_to_end_not_allowed:"Las actividades Script no pueden conectarse directamente al evento final",loop_to_end_not_allowed:"Las actividades Loop no pueden conectarse directamente al evento final",initial_activity_to_end_not_allowed:"Actividad inicial no puede conectarse directamente al evento final",final_activity_cannot_connect:"Actividad final no puede conectarse a otros elementos",activity_has_outgoing_connections:"Actividad con conexiones de salida no puede conectarse al evento final",end_event_cannot_connect_to_initial_activity:"El evento final no puede conectarse a una actividad inicial",initial_activity_cannot_connect_to_start_event:"Actividad inicial no puede conectarse a evento de inicio",concurrent_initial_and_final_activity:"Una actividad no puede estar conectada al evento inicial y final al mismo tiempo",start_event_to_service_task_not_allowed:"El evento inicial no puede conectarse a una actividad autom\xE1tica",service_task_to_end_not_allowed:"Las actividades autom\xE1ticas no pueden conectarse al evento final",duplicate_connection_not_allowed:"Ya existe una conexi\xF3n entre estos elementos",connect_node:"Conectar elemento",connecting:"Conectando...",delete_pool_lane_error:"No se puede eliminar la piscina o carril mientras haya elementos dentro."},controls:{zoom:{fit:"Ajustar zoom",in:"Acercar",out:"Alejar",reset:"Restablecer zoom"},actions:{move_tool:"Seleccionar elementos",hand_tool:"Navegar por el diagrama",check:"Validar diagrama",check_loading:"Validando diagrama...",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"No es posible exportar un diagrama vac\xEDo",error:"Error al exportar diagrama"}},import_governance:"Importar diagrama de la plataforma Governance",minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Deshacer",redo:"Rehacer"}},modals:{delete_elements:{title:"Eliminar elementos",callout:"Al eliminar, las configuraciones de actividades y enrutamiento ser\xE1n eliminadas.",content:"\xBFEst\xE1s seguro de querer eliminar?",confirm:"Eliminar",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"No se puede crear bucle en actividad conectada al evento final",script_not_allowed_when_connected_to_end:"No se puede transformar a Script actividad conectada al evento final",loop_not_allowed_when_subprocess:"No se puede crear bucle en subproceso",loop_not_allowed_when_service_task:"No se puede crear bucle en actividad autom\xE1tica",loop:"Actividad con loop"}},validation:{success:{title:"Validaci\xF3n exitosa",message:"El diagrama ha sido validado correctamente sin errores."},errors:{title:"El diagrama contiene errores",subtitle:"Revise lo siguiente:",task_label_length:"El nombre de la actividad excede el l\xEDmite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"No se permite tener m\xE1s de un evento de inicio",task_flows_limit_exceeds:"El n\xFAmero de conexiones de salida supera el l\xEDmite de dos",duplicate_task_name:"Hay varias actividades con el mismo nombre",flows_on_end_tasks_not_allowed:"Las actividades conectadas a eventos finales no pueden tener otras conexiones",conditions_flows_limit_exceeds:"Compuerta exclusiva con exceso de conexiones de salida (m\xE1ximo de dos)",task_label_empty:"El nombre de una o m\xE1s actividades no ha sido completado",activity_name_invalid:"El nombre de la actividad no es v\xE1lido",final_activity_has_loop:"Las actividades finales no pueden tener bucles",nested_gateway:"No se permite conectar compuertas directamente",concurrent_initial_and_final_event:"Una misma actividad no puede tener eventos iniciales y finales",gateway_flow_to_event:"No se permite conectar una compuerta a un evento de salida",gateway_missing_output_streams:"La compuerta no tiene el n\xFAmero correcto de salidas",events_nested:"No se permite conectar eventos directamente",event_to_condition:"No se permite conectar un evento directamente a una compuerta",script_in_final_activity:"La actividad final no puede ser de tipo script",subprocess_not_configured:"La referencia al subproceso no est\xE1 configurada correctamente",cannot_validate_subprocess_reference:"No fue posible validar si la referencia al subproceso est\xE1 configurada",start_event_not_found:"Es necesario tener al menos un evento de inicio",end_event_not_found:"Es necesario tener al menos un evento final",service_task_without_rejection_routing:"Actividad autom\xE1tica (RPA) sin enrutamiento de rechazo configurado",service_task_without_automation:"Actividad autom\xE1tica (RPA) sin robot configurado",service_task_connector_inactive:"Actividad autom\xE1tica (RPA) vinculada a un conector inactivo",service_task_integration_suspended:"Actividad autom\xE1tica (RPA) vinculada a una integraci\xF3n suspendida",service_task_automation_status_unavailable:"No se pudo verificar el estado de la automatizaci\xF3n (RPA)",service_task_initial_or_final:"La actividad autom\xE1tica (RPA) no puede ser etapa inicial, final o concentradora",service_task_in_loop:"La actividad autom\xE1tica (RPA) no puede estar en un bucle"}},bpmn:{start_event:{variant:{default:"Evento de inicio"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anotaci\xF3n"}},gateway:{menu:{title:"Cambiar tipo de compuerta"},variant:{default:"Compuerta",exclusive:"Compuerta exclusiva",parallel:"Compuerta paralela",complex:"Compuerta compleja"}},task:{menu:{title:"Cambiar tipo de tarea"},variant:{default:"Tarea",script:"Tarea de script",subprocess:"Subproceso",service_task:"RPA"},attribute:{loop:"Tarea con bucle"},label:{prefix:"Actividad"},feedback:{label_empty:{prefix:"El nombre de la actividad se estableci\xF3 autom\xE1ticamente como"},label_already_exists:{prefix:"El nombre",middle:"ya existe. El nombre fue cambiado a"},invalid_first_character:"El nombre de la actividad debe comenzar con una letra o n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento no soportado"}}},adapter:{governance:{error:{DEFAULT:"Error al importar diagrama",NO_FILE:"No se ha seleccionado ning\xFAn archivo",EMPTY_FILE:"Archivo vac\xEDo",INVALID_FILE:"Archivo inv\xE1lido",CONTAIN_NO_CELLS:"No se encontraron c\xE9lulas para importar",ALREADY_INITIALIZED:"No es posible importar el diagrama de la plataforma Governance, ya que el diagrama ya ha sido iniciado"},success:{default:"El diagrama se ha importado de la plataforma Governance correctamente y sin ninguna incompatibilidad detectada.",incompatible_cells:"El diagrama se ha importado de la plataforma Governance con incompatibilidades. Para saber m\xE1s detalles, haz click en el bot\xF3n de abajo."},report:{columns:{type:"Tipo",value:"Valor",status:"Estado"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"No soportado"}},action:{download:"Descargar informe"}}}}};var ba={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Excluir",configure_node:"Configurar atividade",configure_edge:"Configurar roteamento",configure_gateway:"Configurar roteamento",initial_task:"Atividade Inicial",gateway_limit_reached:"Gateway exclusivo n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",task_limit_reached:"Atividade n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",start_event_limit_reached:"Evento inicial s\xF3 pode se conectar a um \xFAnico elemento",gateway_to_gateway_not_allowed:"Gateways n\xE3o podem se conectar diretamente com outros gateways",start_event_already_exists:"J\xE1 existe um evento de in\xEDcio. Exclua o evento atual para adicionar outro",script_to_end_not_allowed:"Atividades Script n\xE3o podem se conectar diretamente ao evento final",loop_to_end_not_allowed:"Atividades Loop n\xE3o podem se conectar diretamente ao evento final",initial_activity_to_end_not_allowed:"Atividade inicial n\xE3o pode se conectar diretamente ao evento final",final_activity_cannot_connect:"Atividade final n\xE3o pode se conectar a outros elementos",activity_has_outgoing_connections:"Atividade com conex\xF5es de sa\xEDda n\xE3o pode se conectar a um evento final",end_event_cannot_connect_to_initial_activity:"O evento final n\xE3o pode ser conectado a uma atividade inicial",initial_activity_cannot_connect_to_start_event:"Atividade inicial n\xE3o pode se conectar a evento de in\xEDcio",concurrent_initial_and_final_activity:"Uma atividade n\xE3o pode estar conectada ao evento inicial e final ao mesmo tempo",duplicate_connection_not_allowed:"J\xE1 existe uma conex\xE3o entre esses elementos",start_event_to_subprocess_not_allowed:"Evento inicial n\xE3o pode se conectar a um subprocesso",start_event_to_service_task_not_allowed:"Evento inicial n\xE3o pode se conectar a uma atividade autom\xE1tica",service_task_to_end_not_allowed:"Atividades autom\xE1ticas n\xE3o podem se conectar ao evento final",connect_node:"Conectar elemento",connecting:"Conectando...",delete_pool_lane_error:"N\xE3o \xE9 poss\xEDvel excluir a piscina ou raia enquanto houver elementos dentro dela."},controls:{zoom:{fit:"Ajustar o zoom",in:"Aumentar o zoom",out:"Diminuir o zoom",reset:"Resetar o zoom"},actions:{move_tool:"Selecionar elementos",hand_tool:"Navegar pelo diagrama",check:"Validar diagrama",check_loading:"Validando diagrama...",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"N\xE3o \xE9 poss\xEDvel exportar um diagrama vazio",error:"Erro ao exportar o diagrama"}},import_governance:"Importar diagrama da plataforma Governance",minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Desfazer",redo:"Refazer"}},modals:{delete_elements:{title:"Excluir elementos",callout:"Ao excluir, as configura\xE7\xF5es de atividades e roteamento ser\xE3o exclu\xEDdas.",content:"Deseja realmente excluir?",confirm:"Excluir",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel criar loop em atividade conectada ao evento final",script_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel transformar em Script atividade conectada ao evento final",loop_not_allowed_when_subprocess:"N\xE3o \xE9 poss\xEDvel criar loop em subprocesso",loop_not_allowed_when_service_task:"N\xE3o \xE9 poss\xEDvel criar loop em atividade autom\xE1tica",loop:"Atividade com loop"}},validation:{success:{title:"Diagrama v\xE1lidado com sucesso!",message:"Nenhum erro encontrado."},errors:{title:"O diagrama cont\xE9m erros",subtitle:"Veja abaixo o que precisa ser corrigido:",task_label_length:"O nome da atividade excede o limite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"N\xE3o \xE9 permitido ter mais de um evento de in\xEDcio",task_flows_limit_exceeds:"O n\xFAmero de conex\xF5es de sa\xEDda ultrapassa o limite de dois",duplicate_task_name:"H\xE1 v\xE1rias atividades com o mesmo nome",flows_on_end_tasks_not_allowed:"Atividades conectadas a eventos finais n\xE3o podem ter outras conex\xF5es",conditions_flows_limit_exceeds:"Gateway exclusivo com excesso de conex\xF5es de sa\xEDda (m\xE1ximo de dois)",task_label_empty:"O nome de uma ou mais atividades n\xE3o foi preenchido",activity_name_invalid:"O nome da atividade n\xE3o \xE9 v\xE1lido",final_activity_has_loop:"Atividades finais n\xE3o podem ter loops",nested_gateway:"N\xE3o \xE9 permitido conectar gateways",concurrent_initial_and_final_event:"Uma mesma atividade n\xE3o pode ter eventos iniciais e finais",gateway_flow_to_event:"N\xE3o \xE9 permitido conectar um gateway a um evento de sa\xEDda",gateway_missing_output_streams:"O gateway n\xE3o possui o n\xFAmero correto de sa\xEDdas",events_nested:"N\xE3o \xE9 permitido conectar eventos",event_to_condition:"N\xE3o \xE9 permitido conectar um evento diretamente em um gateway",script_in_final_activity:"Atividade final n\xE3o pode ser do tipo script",subprocess_not_configured:"A refer\xEAncia ao subprocesso n\xE3o est\xE1 configurada corretamente",cannot_validate_subprocess_reference:"N\xE3o foi poss\xEDvel validar se a refer\xEAncia ao subprocesso est\xE1 configurada",start_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento inicial",end_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento final",service_task_without_rejection_routing:"Atividade autom\xE1tica (RPA) sem roteamento de rejei\xE7\xE3o configurado",service_task_without_automation:"Atividade autom\xE1tica (RPA) sem rob\xF4 configurado",service_task_connector_inactive:"Atividade autom\xE1tica (RPA) vinculada a um conector inativo",service_task_integration_suspended:"Atividade autom\xE1tica (RPA) vinculada a uma integra\xE7\xE3o suspensa",service_task_automation_status_unavailable:"N\xE3o foi poss\xEDvel verificar o status da automa\xE7\xE3o (RPA)",service_task_initial_or_final:"Atividade autom\xE1tica (RPA) n\xE3o pode ser etapa inicial, final ou concentradora",service_task_in_loop:"Atividade autom\xE1tica (RPA) n\xE3o pode estar em loop"}},bpmn:{start_event:{variant:{default:"Evento inicial"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anota\xE7\xE3o"}},gateway:{menu:{title:"Alterar tipo de gateway"},variant:{default:"Gateway",exclusive:"Gateway exclusivo",parallel:"Gateway paralelo",complex:"Gateway complexo"}},task:{menu:{title:"Alterar tipo de atividade"},variant:{default:"Atividade",script:"Atividade de script",subprocess:"Subprocesso",service_task:"RPA"},attribute:{loop:"Atividade com loop"},label:{prefix:"Atividade"},feedback:{label_empty:{prefix:"O nome da atividade foi definido automaticamente como"},label_already_exists:{prefix:"O nome",middle:"j\xE1 existe. O nome foi alterado para"},invalid_first_character:"O nome da atividade deve come\xE7ar com uma letra ou n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento n\xE3o suportado"}}},adapter:{governance:{error:{DEFAULT:"Erro ao importar diagrama",NO_FILE:"Nenhum arquivo selecionado",EMPTY_FILE:"Arquivo vazio",INVALID_FILE:"Arquivo inv\xE1lido",CONTAIN_NO_CELLS:"N\xE3o foram encontradas c\xE9lulas para serem importadas",ALREADY_INITIALIZED:"N\xE3o \xE9 poss\xEDvel importar o diagrama da plataforma Governance, pois o diagrama j\xE1 foi iniciado"},success:{default:"O diagrama foi importado da plataforma Governance com sucesso e sem nenhuma incompatibilidade detectada.",incompatible_cells:"O diagrama foi importado da plataforma Governance com incompatibilidades. Para saber mais detalhes, clique no bot\xE3o abaixo."},report:{columns:{type:"Tipo do elemento",value:"Valor",status:"Status"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"N\xE3o suportado"}},action:{download:"Baixar relat\xF3rio"}}}}};var Ta={pt_BR:ba,en_US:Ea,es_ES:_a};var va,Na,yf=(Na=(va=xs("LecomUserLanguage"))!=null?va:xs("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?Na:Vr.Translations.PT_BR;(0,Vr.initializeI18n)({lng:yf,resources:Ta});var Ye=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(Ye||{});var Un=(i=>(i.ACTIVITY="activity",i.ROUTING="routing",i.GATEWAY="gateway",i.SUB_PROCESS="sub_process",i.SERVICE_TASK="service_task",i))(Un||{}),Hr=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Hr||{}),Gr=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Gr||{}),Br=(f=>(f.SIMPLE="simple",f.LOOP="loop",f.SCRIPT="script",f.SCRIPT_LOOP="script_loop",f.COMPLEX="complex",f.EXCLUSIVE="exclusive",f.PARALLEL="parallel",f.FINAL="final",f.TO_SUB_PROCESS="to_sub_process",f.FROM_SUB_PROCESS="from_sub_process",f.TO_SERVICE_TASK="to_service_task",f.FROM_SERVICE_TASK="from_service_task",f))(Br||{});var bo=require("lucide-react");var Go=require("react/jsx-runtime"),zr=({size:e=24,className:t})=>(0,Go.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:[(0,Go.jsx)("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),(0,Go.jsx)("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),(0,Go.jsx)("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),(0,Go.jsx)("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});var Es=require("react/jsx-runtime"),un=({size:e=24,className:t})=>(0,Es.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,Es.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 xo=require("react/jsx-runtime"),pn=({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:"currentColor",strokeWidth:2,className:t,children:[(0,xo.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,xo.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,xo.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,xo.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,xo.jsx)("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var fn=require("react/jsx-runtime"),mn=({size:e=24,className:t})=>(0,fn.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,fn.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,fn.jsx)("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,fn.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var gn=require("react/jsx-runtime"),hn=({size:e=24,className:t})=>(0,gn.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,gn.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,gn.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,gn.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});var yn=require("react/jsx-runtime"),wa=({size:e=24,className:t})=>(0,yn.jsx)("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:(0,yn.jsxs)("g",{children:[(0,yn.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,yn.jsx)("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});var Ia=require("clsx"),Aa=require("tailwind-merge");function H(...e){return(0,Aa.twMerge)((0,Ia.clsx)(e))}var Eo=(e=0,t=0)=>e<t?t:e,Yr=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});var $n=require("react/jsx-runtime"),Sa=({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 Wr=require("react/jsx-runtime"),Ca=({size:e=24,className:t})=>(0,Wr.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:(0,Wr.jsx)("g",{children:(0,Wr.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 _s=require("react/jsx-runtime"),Fr=({size:e=24,className:t})=>(0,_s.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,_s.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 bs=require("react/jsx-runtime"),Kn=({size:e=24,className:t})=>(0,bs.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,bs.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 xn=require("react/jsx-runtime"),Ma=({size:e=24,className:t})=>(0,xn.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,xn.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,xn.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,xn.jsx)("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});var _o=require("react/jsx-runtime"),Pa=({size:e=24,className:t})=>(0,_o.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,_o.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,_o.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,_o.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,_o.jsx)("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,_o.jsx)("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var Bo=require("react/jsx-runtime"),qn=({size:e=24,className:t})=>(0,Bo.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,Bo.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,Bo.jsx)("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),(0,Bo.jsx)("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Bo.jsx)("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var se=(a=>(a.START_EVENT="START_EVENT",a.END_EVENT="END_EVENT",a.TASK="TASK",a.LANE="LANE",a.GATEWAY="GATEWAY",a.ANNOTATION="ANNOTATION",a.UNSUPPORTED="UNSUPPORTED",a))(se||{}),rt=(n=>(n.SCRIPT="SCRIPT",n.SUBPROCESS="SUBPROCESS",n.SERVICE_TASK="SERVICE_TASK",n))(rt||{}),Xr={SCRIPT:{icon:bo.ScrollText},SUBPROCESS:{icon:bo.SquarePlus},SERVICE_TASK:{icon:bo.Bot}},kt=(t=>(t.LOOP="LOOP",t))(kt||{}),Ur={LOOP:{icon:bo.RotateCcw}},It=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(It||{}),Ts={EXCLUSIVE:{icon:mn},PARALLEL:{icon:hn},COMPLEX:{icon:pn}};var nf=require("@produto-lecom/lecom-ui"),rf=require("@xyflow/react"),Le=require("react");var oo=require("@xyflow/react"),dn=require("react");var gp=require("@produto-lecom/lecom-ui"),jt=require("@xyflow/react"),Tt=require("react");var $r={MIN_WIDTH:36,MIN_HEIGHT:36},Kr={MIN_WIDTH:36,MIN_HEIGHT:36},En={MIN_WIDTH:56,MIN_HEIGHT:56},To={MIN_WIDTH:176,MIN_HEIGHT:96},La={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},ae={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},_n={MIN_WIDTH:176,MIN_HEIGHT:64},xf={MIN_WIDTH:128,MIN_HEIGHT:64},ue={START_EVENT:$r,END_EVENT:Kr,GATEWAY:En,TASK:To,LANE:ae,ANNOTATION:_n,UNSUPPORTED:xf};var bn=require("@xyflow/react");function ka(e,t){var x,N,b,v;let{width:o=0,height:n=0}=e.measured||{width:0,height:0},r=e.internals.positionAbsolute,i=t.internals.positionAbsolute,s=o/2,a=n/2,l=r.x+s,c=r.y+a,d=i.x+((N=(x=t==null?void 0:t.measured)==null?void 0:x.width)!=null?N:0)/2,u=i.y+((v=(b=t==null?void 0:t.measured)==null?void 0:b.height)!=null?v:0)/2,f=(d-l)/(2*s)-(u-c)/(2*a),m=(d-l)/(2*s)+(u-c)/(2*a),h=1/(Math.abs(f)+Math.abs(m)||1),E=h*f,p=h*m,g=s*(E+p)+l,y=a*(-E+p)+c;return{x:g,y}}function Ra(e,t){var c,d,u,f;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(f=(u=e.measured)==null?void 0:u.height)!=null?f:0,i=Math.round(o.x),s=Math.round(o.y),a=Math.round(t.x),l=Math.round(t.y);return a<=i+1?bn.Position.Left:a>=i+n-1?bn.Position.Right:l<=s+1?bn.Position.Top:l>=s+r-1?bn.Position.Bottom:bn.Position.Top}function Tn(e,t){let o=ka(e,t),n=ka(t,e),r=Ra(e,o),i=Ra(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function qr(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 Da=require("lodash");var Oa=e=>new Map(e.map(t=>[t.id,t])),Va=(e,t)=>e.map(o=>{var n;return(n=t.get(o.id))!=null?n:o}),At=e=>{var t,o,n,r,i,s,a,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(r=(n=e.internals)==null?void 0:n.positionAbsolute.y)!=null?r:0,w:(s=(i=e.measured)==null?void 0:i.width)!=null?s:0,h:(l=(a=e.measured)==null?void 0:a.height)!=null?l:0}},Zn=e=>(0,Da.orderBy)(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),Ha=(e,t)=>{let{x:o,y:n}=At(e),{x:r,y:i}=At(t);return{x:o-r,y:n-i}};var zo=({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)),Ef=(e,t)=>{let{x:o,y:n}=At(e),{x:r,y:i}=At(t),s=o-r,a=n-i;return Math.sqrt(s*s+a*a)},_f=(e,t)=>{let{x:o,y:n,w:r,h:i}=At(e),{x:s,y:a,w:l,h:c}=At(t),d=o+r/2,u=n+i/2;return d>=s&&d<=s+l&&u>=a&&u<=a+c},Jn=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&_f(e,r)){let i=Ef(e,r);i<n&&(n=i,o=r)}return o},Ga=(e,t)=>t.filter(o=>o.parentId===e).reduce((o,n)=>{var r,i;return Math.max(o,(i=(r=n.measured)==null?void 0:r.width)!=null?i:0)},0);var Ba=e=>{let t=e.filter(s=>!s.parentId);if(t.length===0)return null;let o=1/0,n=1/0,r=-1/0,i=-1/0;for(let s of t){let{position:a,width:l,height:c}=s,d=a.x+(l||0),u=a.y+(c||0);a.x<o&&(o=a.x),a.y<n&&(n=a.y),d>r&&(r=d),u>i&&(i=u)}return{x:o,y:n,w:r-o,h:i-n}},za=({bounds:e,canvasWidth:t,canvasHeight:o,minZoom:n=.5,maxZoom:r=5,offsetX:i=0,offsetY:s=0})=>{let a=t-i*2,l=o-s*2,c=Math.min(a/e.w,l/e.h),d=Math.min(1,c),u=Math.min(Math.max(d,n),r);return{x:-e.x*u+i,y:-e.y*u+s,zoom:u}};var vs=(e,t)=>{let o=t.find(s=>s.id===e);if(!o||o.type!=="LANE"||o.parentId)return!1;let n=At(o),r=n.x+n.w,i=n.y+n.h;return t.some(s=>{if(s.id===e||s.parentId||s.type==="LANE")return!1;let a=At(s);return a.x<r&&a.x+a.w>n.x&&a.y<i&&a.y+a.h>n.y})};var bf=50,Yo=(e,t)=>{var f,m,h,E,p,g,y,x,N,b,v,T,I,S,P,R;let o=t.find(C=>C.id===e);if(!o)return t;let n=(m=(f=o.position)==null?void 0:f.x)!=null?m:0,r=(E=(h=o.position)==null?void 0:h.y)!=null?E:0,i=(g=(p=o.measured)==null?void 0:p.width)!=null?g:0,s=(x=(y=o.measured)==null?void 0:y.height)!=null?x:0,a=r+s,l=n+i,c=new Set,d=1/0;for(let C of t){if(C.id===e||C.parentId)continue;let L=(b=(N=C.position)==null?void 0:N.y)!=null?b:0,K=(T=(v=C.position)==null?void 0:v.x)!=null?T:0,Q=(S=(I=C.measured)==null?void 0:I.width)!=null?S:0,j=(R=(P=C.measured)==null?void 0:P.height)!=null?R:0;K<l&&K+Q>n&&L<a&&L+j>r&&(c.add(C.id),d=Math.min(d,L))}if(c.size===0)return t;let u=a+bf-d;return t.map(C=>{var K,Q,j;if(!c.has(C.id))return C;let L=(Q=(K=C.position)==null?void 0:K.y)!=null?Q:0;return w(_({},C),{position:w(_({},(j=C.position)!=null?j:{x:0,y:0}),{y:L+u})})})},He=15,Wo=e=>[...e].sort((t,o)=>t.position.y-o.position.y),Tf=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)},vf=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)},Ns=(e,t,o)=>{var d,u,f,m,h,E,p,g,y,x,N,b,v,T,I;if(t.length===0)return e;let n=(f=(u=e.width)!=null?u:(d=e.measured)==null?void 0:d.width)!=null?f:0,r=(E=(h=e.height)!=null?h:(m=e.measured)==null?void 0:m.height)!=null?E:0,i=0,s=0;for(let S of t){let P=Tf(S),R=vf(S);if(((g=(p=S.position)==null?void 0:p.y)!=null?g:0)<He&&(o.set(S.id,w(_({},S),{position:w(_({},S.position),{y:He})})),R=He+((x=(y=S.measured)==null?void 0:y.height)!=null?x:0)),((b=(N=S.position)==null?void 0:N.x)!=null?b:0)<ae.HEADER_WIDTH+He){let C=(v=o.get(S.id))!=null?v:S;o.set(S.id,w(_({},C),{position:w(_({},C.position),{x:ae.HEADER_WIDTH+He})})),P=ae.HEADER_WIDTH+He+((I=(T=S.measured)==null?void 0:T.width)!=null?I:0)}i=Math.max(i,P),s=Math.max(s,R)}let a=Math.max(n,ae.MIN_WIDTH),l=Math.max(r,ae.MIN_HEIGHT);i+He>a&&(a=i+He),s+He>l&&(l=s+He);let c=w(_({},e),{width:a,height:l,measured:w(_({},e.measured),{width:a,height:l})});return o.set(e.id,c),c},Ya=(e,t,o)=>{var s,a;let n=Wo(e),r=new Map;for(let l of o)l.parentId&&(r.has(l.parentId)||r.set(l.parentId,[]),r.get(l.parentId).push(l));let i=0;for(let l of n){let c=(s=r.get(l.id))!=null?s:[],d=Ns(l,c,t);t.set(d.id,w(_({},d),{position:{x:ae.HEADER_WIDTH,y:i}})),i+=(a=d.height)!=null?a:0}},Wa=(e,t)=>{var h,E,p,g;let o=[];for(let y of t.values())y.parentId===e.id&&o.push(y);let n=Wo(o),r=((E=(h=e.measured)==null?void 0:h.width)!=null?E:0)-ae.HEADER_WIDTH,i=Ga(e.id,o)||ae.MIN_WIDTH,s=o.reduce((y,x)=>{var N;return y+((N=x.height)!=null?N:ae.MIN_HEIGHT)},0),a=Math.max(r,i),l=s,c=r>i,d=c?a:a+ae.HEADER_WIDTH,u=c?a-ae.HEADER_WIDTH:a,f=0;for(let y=0;y<n.length;y++){let x=n[y],N=Math.max(ae.MIN_HEIGHT,(p=x.height)!=null?p:ae.MIN_HEIGHT),b=w(_({},x),{width:u,height:N,measured:w(_({},x.measured),{width:u,height:N}),position:{x:ae.HEADER_WIDTH,y:f}});if(y===o.length-1){let v=Math.max(ae.MIN_HEIGHT,l-f);b=w(_({},b),{height:v,measured:w(_({},x.measured),{width:u,height:v})})}t.set(x.id,b),f+=(g=b.height)!=null?g:0}let m=Math.max(l,f);t.set(e.id,w(_({},e),{width:d,height:m,measured:w(_({},e.measured),{width:d,height:m})}))},Fa=(e,t,o,n,r)=>{var h,E;let i=!e.parentId,s=i?e.id:e.parentId,a=n.filter(p=>p.type==="LANE"&&p.parentId===s);if(!a.length)return n;let l=Wo(a),c=l.findIndex(p=>p.id===e.id),d=(E=(h=e.position)==null?void 0:h.y)!=null?E:0,u=!i&&r!==void 0&&c>0&&Math.abs(r-d)>.5,f=0,m=[...n];return l.forEach((p,g)=>{var v,T;let y=g===l.length-1,x=p.id===e.id,b=(T=(v=p.measured)==null?void 0:v.height)!=null?T:0;x?b=o:u&&g===c-1&&(b=Math.max(ae.MIN_HEIGHT,r-f)),y&&i&&(b=Math.max(ae.MIN_HEIGHT,o-f)),m=m.map(I=>{if(I.id===p.id){let S=i?t-ae.HEADER_WIDTH:t;return w(_({},I),{width:S,height:b,measured:w(_({},I.measured),{width:S,height:b}),position:{x:ae.HEADER_WIDTH,y:f}})}return I}),x&&u?f=r+o:f+=b}),m=m.map(p=>{if(p.id===s){let g=i?t:t+ae.HEADER_WIDTH;return w(_({},p),{width:g,height:i?o:f,measured:{width:g,height:i?o:f}})}return p}),m};var ws=(e,t,o)=>{var a,l,c,d,u,f,m,h;if(e.type==="LANE")return o;let n=(l=(a=t.measured)==null?void 0:a.width)!=null?l:0,r=(d=(c=t.measured)==null?void 0:c.height)!=null?d:0;e.position.y<He&&(e.position.y=He),e.position.x<ae.HEADER_WIDTH+He&&(e.position.x=ae.HEADER_WIDTH+He);let i=e.position.x+((f=(u=e.measured)==null?void 0:u.width)!=null?f:0),s=e.position.y+((h=(m=e.measured)==null?void 0:m.height)!=null?h:0);return i+He>n&&(t.width=i+He,t.measured.width=i+He),s+He>r&&(t.height=s+He,t.measured.height=s+He),o=o.map(E=>E.id===t.id?w(_({},E),{height:t.height,width:t.width,measured:t.measured}):E.id===e.id?w(_({},E),{position:e.position}):E),o};var Xa=require("zustand"),Ua=require("@xyflow/react"),$a=require("react");var Zr=()=>{let{setEdges:e}=(0,Ua.useReactFlow)();return(0,$a.useCallback)(()=>{let o=Fo.getState().pathEdgeIds;e(n=>n.map(r=>w(_({},r),{selected:o.includes(r.id)})))},[e])},Fo=(0,Xa.create)((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=_({},n.statusByNodeId),i=_({},n.statusData),s=!1;return o.forEach(a=>{let l=`${a.diagramId}-${a.activityId}`;r[a.diagramId]!==a.status&&(r[a.diagramId]=a.status,i[l]=a,s=!0)}),s?{statusByNodeId:r,statusData:i}:n})},getTaskStatus:o=>t().statusByNodeId[o]||null,clearTaskStatuses:()=>e({statusByNodeId:{},statusData:{},pathEdgeIds:[]}),setPathEdges:o=>{e({pathEdgeIds:o})},getPathEdgeIds:()=>t().pathEdgeIds,clearPathEdges:()=>{e({pathEdgeIds:[]})},calculateFlowPath:(o,n)=>{if(!o.length||!n.length)return;t().clearPathEdges();let r=n.filter(d=>t().statusByNodeId[d]);if(r.length<=1)return;let i=[],s={};o.forEach(d=>{s[d.source]||(s[d.source]=[]),s[d.source].push({targetId:d.target,edgeId:d.id})});let a=r[0],l=r[r.length-1];o.forEach(d=>{d.target===a&&i.push(d.id)}),o.forEach(d=>{d.source===l&&i.push(d.id)});let c=(d,u)=>{let f=[],m=new Set;for(f.push({node:d,path:[]}),m.add(d);f.length>0;){let{node:h,path:E}=f.shift();if(h===u)return E;let p=s[h]||[];for(let{targetId:g,edgeId:y}of p)m.has(g)||(m.add(g),f.push({node:g,path:[...E,y]}))}return[]};for(let d=0;d<r.length-1;d++){let u=r[d],f=r[d+1],m=c(u,f);m.length>0&&i.push(...m)}i.length>0&&e({pathEdgeIds:i})}}));var An=require("@xyflow/react"),pt=require("react"),zc=require("zustand/shallow");var Nf={value:()=>{}};function qa(){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 Jr(o)}function Jr(e){this._=e}function wf(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}})}Jr.prototype=qa.prototype={constructor:Jr,on:function(e,t){var o=this._,n=wf(e+"",o),r,i=-1,s=n.length;if(arguments.length<2){for(;++i<s;)if((r=(e=n[i]).type)&&(r=If(o[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(r=(e=n[i]).type)o[r]=Ka(o[r],e.name,t);else if(t==null)for(r in o)o[r]=Ka(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 Jr(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 If(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function Ka(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=Nf,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var Is=qa;var Qr="http://www.w3.org/1999/xhtml",As={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 so(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),As.hasOwnProperty(t)?{space:As[t],local:e}:e}function Af(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 Sf(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function jr(e){var t=so(e);return(t.local?Sf:Af)(t)}function Cf(){}function Xo(e){return e==null?Cf:function(){return this.querySelector(e)}}function Za(e){typeof e!="function"&&(e=Xo(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=new Array(s),l,c,d=0;d<s;++d)(l=i[d])&&(c=e.call(l,l.__data__,d,i))&&("__data__"in l&&(c.__data__=l.__data__),a[d]=c);return new Ue(n,this._parents)}function Ss(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Mf(){return[]}function Qn(e){return e==null?Mf:function(){return this.querySelectorAll(e)}}function Pf(e){return function(){return Ss(e.apply(this,arguments))}}function Ja(e){typeof e=="function"?e=Pf(e):e=Qn(e);for(var t=this._groups,o=t.length,n=[],r=[],i=0;i<o;++i)for(var s=t[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&(n.push(e.call(l,l.__data__,c,s)),r.push(l));return new Ue(n,r)}function jn(e){return function(){return this.matches(e)}}function ei(e){return function(t){return t.matches(e)}}var Lf=Array.prototype.find;function kf(e){return function(){return Lf.call(this.children,e)}}function Rf(){return this.firstElementChild}function Qa(e){return this.select(e==null?Rf:kf(typeof e=="function"?e:ei(e)))}var Df=Array.prototype.filter;function Of(){return Array.from(this.children)}function Vf(e){return function(){return Df.call(this.children,e)}}function ja(e){return this.selectAll(e==null?Of:Vf(typeof e=="function"?e:ei(e)))}function el(e){typeof e!="function"&&(e=jn(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new Ue(n,this._parents)}function ti(e){return new Array(e.length)}function tl(){return new Ue(this._enter||this._groups.map(ti),this._parents)}function er(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}er.prototype={constructor:er,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 ol(e){return function(){return e}}function Hf(e,t,o,n,r,i){for(var s=0,a,l=t.length,c=i.length;s<c;++s)(a=t[s])?(a.__data__=i[s],n[s]=a):o[s]=new er(e,i[s]);for(;s<l;++s)(a=t[s])&&(r[s]=a)}function Gf(e,t,o,n,r,i,s){var a,l,c=new Map,d=t.length,u=i.length,f=new Array(d),m;for(a=0;a<d;++a)(l=t[a])&&(f[a]=m=s.call(l,l.__data__,a,t)+"",c.has(m)?r[a]=l:c.set(m,l));for(a=0;a<u;++a)m=s.call(e,i[a],a,i)+"",(l=c.get(m))?(n[a]=l,l.__data__=i[a],c.delete(m)):o[a]=new er(e,i[a]);for(a=0;a<d;++a)(l=t[a])&&c.get(f[a])===l&&(r[a]=l)}function Bf(e){return e.__data__}function nl(e,t){if(!arguments.length)return Array.from(this,Bf);var o=t?Gf:Hf,n=this._parents,r=this._groups;typeof e!="function"&&(e=ol(e));for(var i=r.length,s=new Array(i),a=new Array(i),l=new Array(i),c=0;c<i;++c){var d=n[c],u=r[c],f=u.length,m=zf(e.call(d,d&&d.__data__,c,n)),h=m.length,E=a[c]=new Array(h),p=s[c]=new Array(h),g=l[c]=new Array(f);o(d,u,E,p,g,m,t);for(var y=0,x=0,N,b;y<h;++y)if(N=E[y]){for(y>=x&&(x=y+1);!(b=p[x])&&++x<h;);N._next=b||null}}return s=new Ue(s,n),s._enter=a,s._exit=l,s}function zf(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function rl(){return new Ue(this._exit||this._groups.map(ti),this._parents)}function il(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 sl(e){for(var t=e.selection?e.selection():e,o=this._groups,n=t._groups,r=o.length,i=n.length,s=Math.min(r,i),a=new Array(r),l=0;l<s;++l)for(var c=o[l],d=n[l],u=c.length,f=a[l]=new Array(u),m,h=0;h<u;++h)(m=c[h]||d[h])&&(f[h]=m);for(;l<r;++l)a[l]=o[l];return new Ue(a,this._parents)}function al(){for(var e=this._groups,t=-1,o=e.length;++t<o;)for(var n=e[t],r=n.length-1,i=n[r],s;--r>=0;)(s=n[r])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function ll(e){e||(e=Yf);function t(u,f){return u&&f?e(u.__data__,f.__data__):!u-!f}for(var o=this._groups,n=o.length,r=new Array(n),i=0;i<n;++i){for(var s=o[i],a=s.length,l=r[i]=new Array(a),c,d=0;d<a;++d)(c=s[d])&&(l[d]=c);l.sort(t)}return new Ue(r,this._parents).order()}function Yf(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function cl(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function dl(){return Array.from(this)}function ul(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length;r<i;++r){var s=n[r];if(s)return s}return null}function pl(){let e=0;for(let t of this)++e;return e}function fl(){return!this.node()}function ml(e){for(var t=this._groups,o=0,n=t.length;o<n;++o)for(var r=t[o],i=0,s=r.length,a;i<s;++i)(a=r[i])&&e.call(a,a.__data__,i,r);return this}function Wf(e){return function(){this.removeAttribute(e)}}function Ff(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Xf(e,t){return function(){this.setAttribute(e,t)}}function Uf(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function $f(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function Kf(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 gl(e,t){var o=so(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?Ff:Wf:typeof t=="function"?o.local?Kf:$f:o.local?Uf:Xf)(o,t))}function oi(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function qf(e){return function(){this.style.removeProperty(e)}}function Zf(e,t,o){return function(){this.style.setProperty(e,t,o)}}function Jf(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function hl(e,t,o){return arguments.length>1?this.each((t==null?qf:typeof t=="function"?Jf:Zf)(e,t,o==null?"":o)):vo(this.node(),e)}function vo(e,t){return e.style.getPropertyValue(t)||oi(e).getComputedStyle(e,null).getPropertyValue(t)}function Qf(e){return function(){delete this[e]}}function jf(e,t){return function(){this[e]=t}}function em(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function yl(e,t){return arguments.length>1?this.each((t==null?Qf:typeof t=="function"?em:jf)(e,t)):this.node()[e]}function xl(e){return e.trim().split(/^|\s+/)}function Cs(e){return e.classList||new El(e)}function El(e){this._node=e,this._names=xl(e.getAttribute("class")||"")}El.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 _l(e,t){for(var o=Cs(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function bl(e,t){for(var o=Cs(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function tm(e){return function(){_l(this,e)}}function om(e){return function(){bl(this,e)}}function nm(e,t){return function(){(t.apply(this,arguments)?_l:bl)(this,e)}}function Tl(e,t){var o=xl(e+"");if(arguments.length<2){for(var n=Cs(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?nm:t?tm:om)(o,t))}function rm(){this.textContent=""}function im(e){return function(){this.textContent=e}}function sm(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function vl(e){return arguments.length?this.each(e==null?rm:(typeof e=="function"?sm:im)(e)):this.node().textContent}function am(){this.innerHTML=""}function lm(e){return function(){this.innerHTML=e}}function cm(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function Nl(e){return arguments.length?this.each(e==null?am:(typeof e=="function"?cm:lm)(e)):this.node().innerHTML}function dm(){this.nextSibling&&this.parentNode.appendChild(this)}function wl(){return this.each(dm)}function um(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Il(){return this.each(um)}function Al(e){var t=typeof e=="function"?e:jr(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function pm(){return null}function Sl(e,t){var o=typeof e=="function"?e:jr(e),n=t==null?pm:typeof t=="function"?t:Xo(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function fm(){var e=this.parentNode;e&&e.removeChild(this)}function Cl(){return this.each(fm)}function mm(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function gm(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Ml(e){return this.select(e?gm:mm)}function Pl(e){return arguments.length?this.property("__data__",e):this.node().__data__}function hm(e){return function(t){e.call(this,t,this.__data__)}}function ym(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 xm(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 Em(e,t,o){return function(){var n=this.__on,r,i=hm(t);if(n){for(var s=0,a=n.length;s<a;++s)if((r=n[s]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=o),r.value=t;return}}this.addEventListener(e.type,i,o),r={type:e.type,name:e.name,value:t,listener:i,options:o},n?n.push(r):this.__on=[r]}}function Ll(e,t,o){var n=ym(e+""),r,i=n.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,c=a.length,d;l<c;++l)for(r=0,d=a[l];r<i;++r)if((s=n[r]).type===d.type&&s.name===d.name)return d.value}return}for(a=t?Em:xm,r=0;r<i;++r)this.each(a(n[r],t,o));return this}function kl(e,t,o){var n=oi(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 _m(e,t){return function(){return kl(this,e,t)}}function bm(e,t){return function(){return kl(this,e,t.apply(this,arguments))}}function Rl(e,t){return this.each((typeof t=="function"?bm:_m)(e,t))}function*Dl(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length,s;r<i;++r)(s=n[r])&&(yield s)}var Tm=[null];function Ue(e,t){this._groups=e,this._parents=t}function Ol(){return new Ue([[document.documentElement]],Tm)}function vm(){return this}Ue.prototype=Ol.prototype={constructor:Ue,select:Za,selectAll:Ja,selectChild:Qa,selectChildren:ja,filter:el,data:nl,enter:tl,exit:rl,join:il,merge:sl,selection:vm,order:al,sort:ll,call:cl,nodes:dl,node:ul,size:pl,empty:fl,each:ml,attr:gl,style:hl,property:yl,classed:Tl,text:vl,html:Nl,raise:wl,lower:Il,append:Al,insert:Sl,remove:Cl,clone:Ml,datum:Pl,on:Ll,dispatch:Rl,[Symbol.iterator]:Dl};var ao=Ol;function ni(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function Ms(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function nr(){}var tr=.7,si=1/tr,vn="\\s*([+-]?\\d+)\\s*",or="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ft="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Nm=/^#([0-9a-f]{3,8})$/,wm=new RegExp(`^rgb\\(${vn},${vn},${vn}\\)$`),Im=new RegExp(`^rgb\\(${Ft},${Ft},${Ft}\\)$`),Am=new RegExp(`^rgba\\(${vn},${vn},${vn},${or}\\)$`),Sm=new RegExp(`^rgba\\(${Ft},${Ft},${Ft},${or}\\)$`),Cm=new RegExp(`^hsl\\(${or},${Ft},${Ft}\\)$`),Mm=new RegExp(`^hsla\\(${or},${Ft},${Ft},${or}\\)$`),Vl={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};ni(nr,No,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Hl,formatHex:Hl,formatHex8:Pm,formatHsl:Lm,formatRgb:Gl,toString:Gl});function Hl(){return this.rgb().formatHex()}function Pm(){return this.rgb().formatHex8()}function Lm(){return Xl(this).formatHsl()}function Gl(){return this.rgb().formatRgb()}function No(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=Nm.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?Bl(t):o===3?new it(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?ri(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?ri(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=wm.exec(e))?new it(t[1],t[2],t[3],1):(t=Im.exec(e))?new it(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Am.exec(e))?ri(t[1],t[2],t[3],t[4]):(t=Sm.exec(e))?ri(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Cm.exec(e))?Wl(t[1],t[2]/100,t[3]/100,1):(t=Mm.exec(e))?Wl(t[1],t[2]/100,t[3]/100,t[4]):Vl.hasOwnProperty(e)?Bl(Vl[e]):e==="transparent"?new it(NaN,NaN,NaN,0):null}function Bl(e){return new it(e>>16&255,e>>8&255,e&255,1)}function ri(e,t,o,n){return n<=0&&(e=t=o=NaN),new it(e,t,o,n)}function km(e){return e instanceof nr||(e=No(e)),e?(e=e.rgb(),new it(e.r,e.g,e.b,e.opacity)):new it}function Nn(e,t,o,n){return arguments.length===1?km(e):new it(e,t,o,n==null?1:n)}function it(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}ni(it,Nn,Ms(nr,{brighter(e){return e=e==null?si:Math.pow(si,e),new it(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?tr:Math.pow(tr,e),new it(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new it($o(this.r),$o(this.g),$o(this.b),ai(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:zl,formatHex:zl,formatHex8:Rm,formatRgb:Yl,toString:Yl}));function zl(){return`#${Uo(this.r)}${Uo(this.g)}${Uo(this.b)}`}function Rm(){return`#${Uo(this.r)}${Uo(this.g)}${Uo(this.b)}${Uo((isNaN(this.opacity)?1:this.opacity)*255)}`}function Yl(){let e=ai(this.opacity);return`${e===1?"rgb(":"rgba("}${$o(this.r)}, ${$o(this.g)}, ${$o(this.b)}${e===1?")":`, ${e})`}`}function ai(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function $o(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Uo(e){return e=$o(e),(e<16?"0":"")+e.toString(16)}function Wl(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 Xl(e){if(e instanceof Rt)return new Rt(e.h,e.s,e.l,e.opacity);if(e instanceof nr||(e=No(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),s=NaN,a=i-r,l=(i+r)/2;return a?(t===i?s=(o-n)/a+(o<n)*6:o===i?s=(n-t)/a+2:s=(t-o)/a+4,a/=l<.5?i+r:2-i-r,s*=60):a=l>0&&l<1?0:s,new Rt(s,a,l,e.opacity)}function Ul(e,t,o,n){return arguments.length===1?Xl(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}ni(Rt,Ul,Ms(nr,{brighter(e){return e=e==null?si:Math.pow(si,e),new Rt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?tr:Math.pow(tr,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 it(Ps(e>=240?e-240:e+120,r,n),Ps(e,r,n),Ps(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new Rt(Fl(this.h),ii(this.s),ii(this.l),ai(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=ai(this.opacity);return`${e===1?"hsl(":"hsla("}${Fl(this.h)}, ${ii(this.s)*100}%, ${ii(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Fl(e){return e=(e||0)%360,e<0?e+360:e}function ii(e){return Math.max(0,Math.min(1,e||0))}function Ps(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 Ls(e,t,o,n,r){var i=e*e,s=i*e;return((1-3*e+3*i-s)*t+(4-6*i+3*s)*o+(1+3*e+3*i-3*s)*n+s*r)/6}function $l(e){var t=e.length-1;return function(o){var n=o<=0?o=0:o>=1?(o=1,t-1):Math.floor(o*t),r=e[n],i=e[n+1],s=n>0?e[n-1]:2*r-i,a=n<t-1?e[n+2]:2*i-r;return Ls((o-n/t)*t,s,r,i,a)}}function Kl(e){var t=e.length;return function(o){var n=Math.floor(((o%=1)<0?++o:o)*t),r=e[(n+t-1)%t],i=e[n%t],s=e[(n+1)%t],a=e[(n+2)%t];return Ls((o-n/t)*t,r,i,s,a)}}var ks=e=>()=>e;function Dm(e,t){return function(o){return e+o*t}}function Om(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 ql(e){return(e=+e)==1?li:function(t,o){return o-t?Om(t,o,e):ks(isNaN(t)?o:t)}}function li(e,t){var o=t-e;return o?Dm(e,o):ks(isNaN(e)?t:e)}var ci=function e(t){var o=ql(t);function n(r,i){var s=o((r=Nn(r)).r,(i=Nn(i)).r),a=o(r.g,i.g),l=o(r.b,i.b),c=li(r.opacity,i.opacity);return function(d){return r.r=s(d),r.g=a(d),r.b=l(d),r.opacity=c(d),r+""}}return n.gamma=e,n}(1);function Zl(e){return function(t){var o=t.length,n=new Array(o),r=new Array(o),i=new Array(o),s,a;for(s=0;s<o;++s)a=Nn(t[s]),n[s]=a.r||0,r[s]=a.g||0,i[s]=a.b||0;return n=e(n),r=e(r),i=e(i),a.opacity=1,function(l){return a.r=n(l),a.g=r(l),a.b=i(l),a+""}}}var Vm=Zl($l),Hm=Zl(Kl);function St(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var Ds=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Rs=new RegExp(Ds.source,"g");function Gm(e){return function(){return e}}function Bm(e){return function(t){return e(t)+""}}function Os(e,t){var o=Ds.lastIndex=Rs.lastIndex=0,n,r,i,s=-1,a=[],l=[];for(e=e+"",t=t+"";(n=Ds.exec(e))&&(r=Rs.exec(t));)(i=r.index)>o&&(i=t.slice(o,i),a[s]?a[s]+=i:a[++s]=i),(n=n[0])===(r=r[0])?a[s]?a[s]+=r:a[++s]=r:(a[++s]=null,l.push({i:s,x:St(n,r)})),o=Rs.lastIndex;return o<t.length&&(i=t.slice(o),a[s]?a[s]+=i:a[++s]=i),a.length<2?l[0]?Bm(l[0].x):Gm(t):(t=l.length,function(c){for(var d=0,u;d<t;++d)a[(u=l[d]).i]=u.x(c);return a.join("")})}var Jl=180/Math.PI,di={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Vs(e,t,o,n,r,i){var s,a,l;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(l=e*o+t*n)&&(o-=e*l,n-=t*l),(a=Math.sqrt(o*o+n*n))&&(o/=a,n/=a,l/=a),e*n<t*o&&(e=-e,t=-t,l=-l,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*Jl,skewX:Math.atan(l)*Jl,scaleX:s,scaleY:a}}var ui;function Ql(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?di:Vs(t.a,t.b,t.c,t.d,t.e,t.f)}function jl(e){return e==null?di:(ui||(ui=document.createElementNS("http://www.w3.org/2000/svg","g")),ui.setAttribute("transform",e),(e=ui.transform.baseVal.consolidate())?(e=e.matrix,Vs(e.a,e.b,e.c,e.d,e.e,e.f)):di)}function ec(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,f,m,h){if(c!==u||d!==f){var E=m.push("translate(",null,t,null,o);h.push({i:E-4,x:St(c,u)},{i:E-2,x:St(d,f)})}else(u||f)&&m.push("translate("+u+t+f+o)}function s(c,d,u,f){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),f.push({i:u.push(r(u)+"rotate(",null,n)-2,x:St(c,d)})):d&&u.push(r(u)+"rotate("+d+n)}function a(c,d,u,f){c!==d?f.push({i:u.push(r(u)+"skewX(",null,n)-2,x:St(c,d)}):d&&u.push(r(u)+"skewX("+d+n)}function l(c,d,u,f,m,h){if(c!==u||d!==f){var E=m.push(r(m)+"scale(",null,",",null,")");h.push({i:E-4,x:St(c,u)},{i:E-2,x:St(d,f)})}else(u!==1||f!==1)&&m.push(r(m)+"scale("+u+","+f+")")}return function(c,d){var u=[],f=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,u,f),s(c.rotate,d.rotate,u,f),a(c.skewX,d.skewX,u,f),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,f),c=d=null,function(m){for(var h=-1,E=f.length,p;++h<E;)u[(p=f[h]).i]=p.x(m);return u.join("")}}}var Hs=ec(Ql,"px, ","px)","deg)"),Gs=ec(jl,", ",")",")");var wn=0,ir=0,rr=0,oc=1e3,pi,sr,fi=0,Ko=0,mi=0,ar=typeof performance=="object"&&performance.now?performance:Date,nc=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function cr(){return Ko||(nc(zm),Ko=ar.now()+mi)}function zm(){Ko=0}function lr(){this._call=this._time=this._next=null}lr.prototype=gi.prototype={constructor:lr,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?cr():+o)+(t==null?0:+t),!this._next&&sr!==this&&(sr?sr._next=this:pi=this,sr=this),this._call=e,this._time=o,Bs()},stop:function(){this._call&&(this._call=null,this._time=1/0,Bs())}};function gi(e,t,o){var n=new lr;return n.restart(e,t,o),n}function rc(){cr(),++wn;for(var e=pi,t;e;)(t=Ko-e._time)>=0&&e._call.call(void 0,t),e=e._next;--wn}function tc(){Ko=(fi=ar.now())+mi,wn=ir=0;try{rc()}finally{wn=0,Wm(),Ko=0}}function Ym(){var e=ar.now(),t=e-fi;t>oc&&(mi-=t,fi=e)}function Wm(){for(var e,t=pi,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:pi=o);sr=e,Bs(n)}function Bs(e){if(!wn){ir&&(ir=clearTimeout(ir));var t=e-Ko;t>24?(e<1/0&&(ir=setTimeout(tc,e-ar.now()-mi)),rr&&(rr=clearInterval(rr))):(rr||(fi=ar.now(),rr=setInterval(Ym,oc)),wn=1,nc(tc))}}function hi(e,t,o){var n=new lr;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var Fm=Is("start","end","cancel","interrupt"),Xm=[],ac=0,ic=1,xi=2,yi=3,sc=4,Ei=5,dr=6;function wo(e,t,o,n,r,i){var s=e.__transition;if(!s)e.__transition={};else if(o in s)return;Um(e,o,{name:t,index:n,group:r,on:Fm,tween:Xm,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:ac})}function ur(e,t){var o=$e(e,t);if(o.state>ac)throw new Error("too late; already scheduled");return o}function Je(e,t){var o=$e(e,t);if(o.state>yi)throw new Error("too late; already running");return o}function $e(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function Um(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=gi(i,0,o.time);function i(c){o.state=ic,o.timer.restart(s,o.delay,o.time),o.delay<=c&&s(c-o.delay)}function s(c){var d,u,f,m;if(o.state!==ic)return l();for(d in n)if(m=n[d],m.name===o.name){if(m.state===yi)return hi(s);m.state===sc?(m.state=dr,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete n[d]):+d<t&&(m.state=dr,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete n[d])}if(hi(function(){o.state===yi&&(o.state=sc,o.timer.restart(a,o.delay,o.time),a(c))}),o.state=xi,o.on.call("start",e,e.__data__,o.index,o.group),o.state===xi){for(o.state=yi,r=new Array(f=o.tween.length),d=0,u=-1;d<f;++d)(m=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++u]=m);r.length=u+1}}function a(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=Ei,1),u=-1,f=r.length;++u<f;)r[u].call(e,d);o.state===Ei&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=dr,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function zs(e,t){var o=e.__transition,n,r,i=!0,s;if(o){t=t==null?null:t+"";for(s in o){if((n=o[s]).name!==t){i=!1;continue}r=n.state>xi&&n.state<Ei,n.state=dr,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[s]}i&&delete e.__transition}}function lc(e){return this.each(function(){zs(this,e)})}function $m(e,t){var o,n;return function(){var r=Je(this,e),i=r.tween;if(i!==o){n=o=i;for(var s=0,a=n.length;s<a;++s)if(n[s].name===t){n=n.slice(),n.splice(s,1);break}}r.tween=n}}function Km(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=Je(this,e),s=i.tween;if(s!==n){r=(n=s).slice();for(var a={name:t,value:o},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=a;break}l===c&&r.push(a)}i.tween=r}}function cc(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=$e(this.node(),o).tween,r=0,i=n.length,s;r<i;++r)if((s=n[r]).name===e)return s.value;return null}return this.each((t==null?$m:Km)(o,e,t))}function In(e,t,o){var n=e._id;return e.each(function(){var r=Je(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return $e(r,n).value[t]}}function _i(e,t){var o;return(typeof t=="number"?St:t instanceof No?ci:(o=No(t))?(t=o,ci):Os)(e,t)}function qm(e){return function(){this.removeAttribute(e)}}function Zm(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Jm(e,t,o){var n,r=o+"",i;return function(){var s=this.getAttribute(e);return s===r?null:s===n?i:i=t(n=s,o)}}function Qm(e,t,o){var n,r=o+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===r?null:s===n?i:i=t(n=s,o)}}function jm(e,t,o){var n,r,i;return function(){var s,a=o(this),l;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),l=a+"",s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a)))}}function eg(e,t,o){var n,r,i;return function(){var s,a=o(this),l;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),l=a+"",s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a)))}}function dc(e,t){var o=so(e),n=o==="transform"?Gs:_i;return this.attrTween(e,typeof t=="function"?(o.local?eg:jm)(o,n,In(this,"attr."+e,t)):t==null?(o.local?Zm:qm)(o):(o.local?Qm:Jm)(o,n,t))}function tg(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function og(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function ng(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&og(e,i)),o}return r._value=t,r}function rg(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&tg(e,i)),o}return r._value=t,r}function uc(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=so(e);return this.tween(o,(n.local?ng:rg)(n,t))}function ig(e,t){return function(){ur(this,e).delay=+t.apply(this,arguments)}}function sg(e,t){return t=+t,function(){ur(this,e).delay=t}}function pc(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?ig:sg)(t,e)):$e(this.node(),t).delay}function ag(e,t){return function(){Je(this,e).duration=+t.apply(this,arguments)}}function lg(e,t){return t=+t,function(){Je(this,e).duration=t}}function fc(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?ag:lg)(t,e)):$e(this.node(),t).duration}function cg(e,t){if(typeof t!="function")throw new Error;return function(){Je(this,e).ease=t}}function mc(e){var t=this._id;return arguments.length?this.each(cg(t,e)):$e(this.node(),t).ease}function dg(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;Je(this,e).ease=o}}function gc(e){if(typeof e!="function")throw new Error;return this.each(dg(this._id,e))}function hc(e){typeof e!="function"&&(e=jn(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new et(n,this._parents,this._name,this._id)}function yc(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,o=e._groups,n=t.length,r=o.length,i=Math.min(n,r),s=new Array(n),a=0;a<i;++a)for(var l=t[a],c=o[a],d=l.length,u=s[a]=new Array(d),f,m=0;m<d;++m)(f=l[m]||c[m])&&(u[m]=f);for(;a<n;++a)s[a]=t[a];return new et(s,this._parents,this._name,this._id)}function ug(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 pg(e,t,o){var n,r,i=ug(t)?ur:Je;return function(){var s=i(this,e),a=s.on;a!==n&&(r=(n=a).copy()).on(t,o),s.on=r}}function xc(e,t){var o=this._id;return arguments.length<2?$e(this.node(),o).on.on(e):this.each(pg(o,e,t))}function fg(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function Ec(){return this.on("end.remove",fg(this._id))}function _c(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Xo(e));for(var n=this._groups,r=n.length,i=new Array(r),s=0;s<r;++s)for(var a=n[s],l=a.length,c=i[s]=new Array(l),d,u,f=0;f<l;++f)(d=a[f])&&(u=e.call(d,d.__data__,f,a))&&("__data__"in d&&(u.__data__=d.__data__),c[f]=u,wo(c[f],t,o,f,c,$e(d,o)));return new et(i,this._parents,t,o)}function bc(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Qn(e));for(var n=this._groups,r=n.length,i=[],s=[],a=0;a<r;++a)for(var l=n[a],c=l.length,d,u=0;u<c;++u)if(d=l[u]){for(var f=e.call(d,d.__data__,u,l),m,h=$e(d,o),E=0,p=f.length;E<p;++E)(m=f[E])&&wo(m,t,o,E,f,h);i.push(f),s.push(d)}return new et(i,s,t,o)}var mg=ao.prototype.constructor;function Tc(){return new mg(this._groups,this._parents)}function gg(e,t){var o,n,r;return function(){var i=vo(this,e),s=(this.style.removeProperty(e),vo(this,e));return i===s?null:i===o&&s===n?r:r=t(o=i,n=s)}}function vc(e){return function(){this.style.removeProperty(e)}}function hg(e,t,o){var n,r=o+"",i;return function(){var s=vo(this,e);return s===r?null:s===n?i:i=t(n=s,o)}}function yg(e,t,o){var n,r,i;return function(){var s=vo(this,e),a=o(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),vo(this,e))),s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a))}}function xg(e,t){var o,n,r,i="style."+t,s="end."+i,a;return function(){var l=Je(this,e),c=l.on,d=l.value[i]==null?a||(a=vc(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(s,r=d),l.on=n}}function Nc(e,t,o){var n=(e+="")=="transform"?Hs:_i;return t==null?this.styleTween(e,gg(e,n)).on("end.style."+e,vc(e)):typeof t=="function"?this.styleTween(e,yg(e,n,In(this,"style."+e,t))).each(xg(this._id,e)):this.styleTween(e,hg(e,n,t),o).on("end.style."+e,null)}function Eg(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function _g(e,t,o){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&Eg(e,s,o)),n}return i._value=t,i}function wc(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,_g(e,t,o==null?"":o))}function bg(e){return function(){this.textContent=e}}function Tg(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function Ic(e){return this.tween("text",typeof e=="function"?Tg(In(this,"text",e)):bg(e==null?"":e+""))}function vg(e){return function(t){this.textContent=e.call(this,t)}}function Ng(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&vg(r)),t}return n._value=e,n}function Ac(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,Ng(e))}function Sc(){for(var e=this._name,t=this._id,o=bi(),n=this._groups,r=n.length,i=0;i<r;++i)for(var s=n[i],a=s.length,l,c=0;c<a;++c)if(l=s[c]){var d=$e(l,t);wo(l,e,o,c,s,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new et(n,this._parents,e,o)}function Cc(){var e,t,o=this,n=o._id,r=o.size();return new Promise(function(i,s){var a={value:s},l={value:function(){--r===0&&i()}};o.each(function(){var c=Je(this,n),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(l)),c.on=t}),r===0&&i()})}var wg=0;function et(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function Mc(e){return ao().transition(e)}function bi(){return++wg}var lo=ao.prototype;et.prototype=Mc.prototype={constructor:et,select:_c,selectAll:bc,selectChild:lo.selectChild,selectChildren:lo.selectChildren,filter:hc,merge:yc,selection:Tc,transition:Sc,call:lo.call,nodes:lo.nodes,node:lo.node,size:lo.size,empty:lo.empty,each:lo.each,on:xc,attr:dc,attrTween:uc,style:Nc,styleTween:wc,text:Ic,textTween:Ac,remove:Ec,tween:cc,delay:pc,duration:fc,ease:mc,easeVarying:gc,end:Cc,[Symbol.iterator]:lo[Symbol.iterator]};function Ti(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Ig={time:null,delay:0,duration:250,ease:Ti};function Ag(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 Pc(e){var t,o;e instanceof et?(t=e._id,e=e._name):(t=bi(),(o=Ig).time=cr(),e=e==null?null:e+"");for(var n=this._groups,r=n.length,i=0;i<r;++i)for(var s=n[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&wo(l,e,t,c,s,o||Ag(l,t));return new et(n,this._parents,e,t)}ao.prototype.interrupt=lc;ao.prototype.transition=Pc;function Io(e,t,o){this.k=e,this.x=t,this.y=o}Io.prototype={constructor:Io,scale:function(e){return e===1?this:new Io(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Io(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 vi=new Io(1,0,0);Ni.prototype=Io.prototype;function Ni(e){for(;!e.__zoom;)if(!(e=e.parentNode))return vi;return e.__zoom}var Cg=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var Lc;(function(e){e.Strict="strict",e.Loose="loose"})(Lc||(Lc={}));var kc;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(kc||(kc={}));var Rc;(function(e){e.Partial="partial",e.Full="full"})(Rc||(Rc={}));var Dc;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Dc||(Dc={}));var Oc;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Oc||(Oc={}));var st;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(st||(st={}));var Rb={[st.Left]:st.Right,[st.Right]:st.Left,[st.Top]:st.Bottom,[st.Bottom]:st.Top};var Mg=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var Pg=(e,t=[0,0])=>{var a;let{width:o,height:n}=Lg(e),r=(a=e.origin)!=null?a:t,i=o*r[0],s=n*r[1];return{x:e.position.x-i,y:e.position.y-s}};var wi=(e,t=[0,0])=>{var r,i,s,a,l,c,d,u;let{x:o,y:n}=Mg(e)?e.internals.positionAbsolute:Pg(e,t);return{x:o,y:n,x2:o+((a=(s=(i=(r=e.measured)==null?void 0:r.width)!=null?i:e.width)!=null?s:e.initialWidth)!=null?a:0),y2:n+((u=(d=(c=(l=e.measured)==null?void 0:l.height)!=null?c:e.height)!=null?d:e.initialHeight)!=null?u:0)}};function Lg(e){var t,o,n,r,i,s,a,l;return{width:(r=(n=(o=(t=e.measured)==null?void 0:t.width)!=null?o:e.width)!=null?n:e.initialWidth)!=null?r:0,height:(l=(a=(s=(i=e.measured)==null?void 0:i.height)!=null?s:e.height)!=null?a:e.initialHeight)!=null?l:0}}var Db={[st.Left]:{x:-1,y:0},[st.Right]:{x:1,y:0},[st.Top]:{x:0,y:-1},[st.Bottom]:{x:0,y:1}};var kg={nodeOrigin:[0,0],nodeExtent:Cg,elevateNodesOnSelect:!0,defaults:{}},Ob=w(_({},kg),{checkEquality:!0});var Vc;(function(e){e.Line="line",e.Handle="handle"})(Vc||(Vc={}));var Rg={width:0,height:0,x:0,y:0},Vb=w(_({},Rg),{pointerX:0,pointerY:0,aspectRatio:1});var Dg=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function Og(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 Ii=class{constructor(){this.xLines=[];this.yLines=[]}initialize(t){this.xLines=t.filter(o=>o.orientation==="vertical"),this.yLines=t.filter(o=>o.orientation==="horizontal"),this.xLines.sort((o,n)=>o.position-n.position),this.yLines.sort((o,n)=>o.position-n.position),this.lastHorizontalLine=void 0,this.lastVerticalLine=void 0}search(t,o,n,r,i){let s=t==="horizontal"?this.yLines:this.xLines,[a,l]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],c=[];for(let m of s){if(m.position<a)continue;if(m.position>l)break;if(i.has(m.node.id)||m.node.parentId&&i.has(m.node.parentId)||!Dg(m.nodeBox,r))continue;let h=Math.abs(m.position-o);if(h>Ai)continue;let p=Og(m.nodeBox,n)>0?0:Vg(m.nodeBox,n);c.push({line:m,lineDist:h,nodeDist:p})}let d=.5,u=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;c.sort((m,h)=>{if(u){if(m.line===u&&h.line!==u)return-1;if(h.line===u&&m.line!==u)return 1}return Math.abs(m.lineDist-h.lineDist)<=d?m.nodeDist-h.nodeDist:m.lineDist-h.lineDist});let f=c.length>0?c[0].line:void 0;return f&&(t==="horizontal"?this.lastHorizontalLine=f:this.lastVerticalLine=f),f}};function Hc(e,t=qo,o){let n=[];return e==null||e.forEach(r=>{let i=o(r.id);if(!i)throw new Error(`Node with id ${r.id} not found in internal nodes.`);let s=wi(i);Object.entries(t).forEach(([a,l])=>{var c;n.push({position:l.resolve(r,s),color:(c=r.style)==null?void 0:c.backgroundColor,orientation:l.orientation,anchorName:a,nodeBox:s,node:r})})}),n}function Gc(e,t,o,n,r=Object.keys(qo)){let i=[];for(let a of r){let l=qo[a],c=l.resolve(null,o),d=e.search(l.orientation,c,o,t,n);d&&i.push({sourcePosition:c,anchorName:a,anchor:l,line:d})}let s={horizontal:void 0,vertical:void 0};for(let a of i){let l=s[a.anchor.orientation],c=Math.abs(a.sourcePosition-a.line.position);(!l||c<Math.abs(l.sourcePosition-l.line.position))&&(s[a.anchor.orientation]=a)}return s}function Bc(e,t,o){let n=0,r=0,i=!1,s=!1;if(t){let l=t.anchor.resolve(null,e)-t.line.position;Math.abs(l)<=Ai&&(r=l,s=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=Ai&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:s}}var Ai=10,qo={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 Yc=require("react/jsx-runtime"),Hg=new Ii;function Si(){let[e,t]=(0,pt.useState)(void 0),[o,n]=(0,pt.useState)(void 0),{width:r,height:i}=(0,An.useStore)(p=>({width:p.width,height:p.height}),zc.shallow),s=(0,An.useNodesInitialized)(),a=(0,pt.useRef)(Hg),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=(0,An.useReactFlow)(),u=(0,pt.useCallback)(()=>{t(void 0),n(void 0)},[]),f=(0,pt.useCallback)(p=>{let g=p!=null?p:d();u();let y=Hc(g,qo,c);a.current.initialize(y)},[c,u,d]),m=(0,pt.useCallback)(()=>{setTimeout(()=>{f()},100)},[f]);(0,pt.useEffect)(()=>{s&&f(d())},[s,f,d]);let h=(0,pt.useCallback)((p,g)=>{var G,k,O,Y,W,U,X,$,te,ie;if(!a.current||p.length===0||p.filter(F=>F.type==="dimensions").length>1)return p;u();let x=p.filter(F=>F.type==="position"&&!!F.position),N=p.find(F=>F.type==="dimensions");if(x.length===0&&!N)return p;let b=Object.keys(qo),v=new Set,T=1/0,I=1/0,S=-1/0,P=-1/0;if(x.length>0)x.forEach(F=>{var de,re,ee,xe,Se,Re;let oe=g.find(Ze=>Ze.id===F.id);if(!oe)return;v.add(oe.id);let le=c(oe.id);if(!le)return;let Z=le.parentId?c(le.parentId):void 0,ve=F.position.x+((de=Z==null?void 0:Z.internals.positionAbsolute.x)!=null?de:0),ye=F.position.y+((re=Z==null?void 0:Z.internals.positionAbsolute.y)!=null?re:0),Ae=(xe=(ee=oe.measured)==null?void 0:ee.width)!=null?xe:0,J=(Re=(Se=oe.measured)==null?void 0:Se.height)!=null?Re:0;T=Math.min(T,ve),I=Math.min(I,ye),S=Math.max(S,ve+Ae),P=Math.max(P,ye+J)}),N&&(b=["top","left"]);else if(N){let F=g.find(Ae=>Ae.id===N.id);if(!F)return p;v.add(F.id);let oe=c(F.id);if(!oe)return p;let le=oe.internals.positionAbsolute.x,Z=oe.internals.positionAbsolute.y,ve=(Y=(O=(G=N.dimensions)==null?void 0:G.width)!=null?O:(k=F.measured)==null?void 0:k.width)!=null?Y:0,ye=($=(X=(W=N.dimensions)==null?void 0:W.height)!=null?X:(U=F.measured)==null?void 0:U.height)!=null?$:0;T=le,I=Z,S=le+ve,P=Z+ye,b=["right","bottom"]}if(T===1/0)return p;let R={x:T,y:I,x2:S,y2:P},{x:C,y:L}=l({x:0,y:0}),{x:K,y:Q}=l({x:r,y:i}),j={x:C,y:L,x2:K,y2:Q},{horizontal:z,vertical:M}=Gc(a.current,j,R,v,b),{deltaX:V,deltaY:D,snappedX:A,snappedY:B}=Bc(R,z,M);if(A||B){let F=x.some(le=>le.dragging),oe=!!(N!=null&&N.resizing);(F||oe)&&(A&&n(M==null?void 0:M.line),B&&t(z==null?void 0:z.line)),A&&(x.forEach(le=>{le.position&&(le.position.x-=V)}),(N==null?void 0:N.id)===((te=x[0])==null?void 0:te.id)?N.dimensions&&(N.dimensions.width+=V):N&&!x.length&&N.dimensions&&(N.dimensions.width-=V)),B&&(x.forEach(le=>{le.position&&(le.position.y-=D)}),(N==null?void 0:N.id)===((ie=x[0])==null?void 0:ie.id)?N.dimensions&&(N.dimensions.height+=D):N&&!x.length&&N.dimensions&&(N.dimensions.height-=D))}return p},[l,c,r,i,t,n,u]),E=(0,pt.useCallback)(()=>(0,Yc.jsx)(Wc,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:f,forceRebuildIndex:m,updateHelperLines:h,helperLineHorizontal:e,helperLineVertical:o,HelperLines:E}}var is=require("@xyflow/react"),Qt=require("react");var co=e=>new Map(e.map(t=>[t.id,t])),pr=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),Fc=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),Ys=e=>e.some(t=>t.type==="START_EVENT"),Ao=(e,t)=>e==="START_EVENT"?!Ys(t):!0,Xc=(e,t,o,n,r)=>{let i=co(o),s=i.get(e);if(!s||s.type!=="START_EVENT")return!1;let a=i.get(t);return(a==null?void 0:a.type)==="ANNOTATION"?!1:pr(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Uc=(e,t,o,n,r)=>{let i=co(o),s=i.get(t);if(!s||s.type!=="END_EVENT")return!1;let a=i.get(e);return(a==null?void 0:a.type)==="ANNOTATION"?!1:Fc(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Ci=(e,t,o,n,r)=>{var c;let i=co(o),s=i.get(e);if(!s||s.type!=="GATEWAY"||((c=s.data)==null?void 0:c.variant)!=="EXCLUSIVE")return!1;let a=t?i.get(t):null;return(a==null?void 0:a.type)==="ANNOTATION"?!1:pr(e,n,r).filter(d=>{let u=i.get(d.target);return(u==null?void 0:u.type)!=="ANNOTATION"}).length>=2},$c=(e,t,o)=>{var s,a,l,c;let n=co(o),r=n.get(e),i=n.get(t);return(r==null?void 0:r.type)!=="GATEWAY"||(i==null?void 0:i.type)!=="GATEWAY"||((s=r==null?void 0:r.data)==null?void 0:s.variant)==="EXCLUSIVE"&&((a=i==null?void 0:i.data)==null?void 0:a.variant)==="PARALLEL"||((l=r==null?void 0:r.data)==null?void 0:l.variant)==="COMPLEX"&&((c=i==null?void 0:i.data)==null?void 0:c.variant)==="PARALLEL"},Mi=(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"},Kc=(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"},fr=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SERVICE_TASK"},Pi=(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"},Zo=(e,t,o,n)=>{let r=co(t),i=r.get(e);return!i||i.type!=="TASK"?!1:Fc(e,o,n).some(a=>{let l=r.get(a.source);return(l==null?void 0:l.type)==="START_EVENT"})},mr=(e,t,o,n)=>{let r=co(t),i=r.get(e);return!i||i.type!=="TASK"?!1:pr(e,o,n).some(a=>{let l=r.get(a.target);return(l==null?void 0:l.type)==="END_EVENT"})},qc=(e,t,o,n,r)=>{let i=co(o),s=i.get(e),a=i.get(t);return(s==null?void 0:s.type)==="START_EVENT"&&(a==null?void 0:a.type)==="TASK"?mr(t,o,n,r):(a==null?void 0:a.type)==="END_EVENT"&&(s==null?void 0:s.type)==="TASK"?Zo(e,o,n,r):!1},Li=(e,t,o)=>pr(e,t,o).length>0,ki=(e,t,o,n,r)=>{let i=co(o),s=i.get(e);if(!s||s.type!=="TASK")return!1;let a=t?i.get(t):null;return(a==null?void 0:a.type)==="ANNOTATION"?!1:pr(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var Zc=(e,t,o,n,r)=>{var a,l;let i=co(n),s=((a=i.get(e))==null?void 0:a.type)==="ANNOTATION"||((l=i.get(t))==null?void 0:l.type)==="ANNOTATION";return o.some(c=>r&&c.id===r?!1:!!(c.source===e&&c.target===t||s&&c.source===t&&c.target===e))};var Gg=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!Zc(e.sourceNodeId,e.targetNodeId,e.edges,e.nodes,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!Xc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!Uc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!Ci(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!ki(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:$c(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"&&Kc(e.targetNodeId,e.nodes)),reason:"start_event_to_subprocess_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&fr(e.targetNodeId,e.nodes)),reason:"start_event_to_service_task_not_allowed"}),e=>({isValid:!(fr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"service_task_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="GATEWAY"&&e.targetNodeType==="END_EVENT"),reason:"gateway_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&e.targetNodeType==="GATEWAY"),reason:"start_to_gateway_not_allowed"}),e=>({isValid:!(Mi(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(Pi(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(Zo(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!qc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(mr(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(Li(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"})],Ws=e=>{for(let t of Gg){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var Bg=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:Ci(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:Ys(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Mi(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Pi(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:fr(e.sourceNodeId,e.nodes),reason:"service_task_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Zo(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:mr(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Li(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:ki(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],Jc=e=>{let t=Bg.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 Xt=require("@produto-lecom/lecom-ui"),jc=require("lucide-react");var Ct=require("@xyflow/react");var Qc=require("@xyflow/react"),So=()=>{let e=(0,Qc.useStoreApi)();return{selectElements:n=>{let{edges:r,nodes:i,triggerEdgeChanges:s,triggerNodeChanges:a}=e.getState(),l=i.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]),c=r.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]);return a(l),s(c),!0},clearSelection:async()=>{let{unselectNodesAndEdges:n}=e.getState();return n(),await Yr(),!0}}};var Ri=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=(0,Ct.useReactFlow)(),{selectElements:r}=So(),i=p=>{let g=o(),y=n(),x=(0,Ct.getIncomers)(p,g,y),N=(0,Ct.getOutgoers)(p,g,y),b=x.some(T=>T.type==="START_EVENT"),v=N.some(T=>T.type==="END_EVENT");return b?"start":v?"end":"between"},s=(p,g,y)=>{var b,v,T,I,S;if(!p)return;let x={type:p.type,variant:(b=p.data)==null?void 0:b.variant,attribute:(v=p.data)==null?void 0:v.attribute},N={id:p.id,position:i(p),label:(T=p.data)==null?void 0:T.label,node:x};return p.type==="TASK"&&((I=p.data)==null?void 0:I.variant)==="SUBPROCESS"?w(_({},N),{type:"sub_process"}):p.type==="TASK"&&((S=p.data)==null?void 0:S.variant)==="SERVICE_TASK"?w(_({},N),{type:"service_task"}):p.type==="GATEWAY"?w(_({},N),{type:"gateway",variant:a(p,g,y)}):w(_({},N),{type:"activity"})},a=(p,g,y)=>{if(p.type!=="GATEWAY")return;let x=(0,Ct.getIncomers)(p,g,y),N=!1,b=!1;if(x.forEach(v=>{var T,I;v.type==="TASK"&&(((T=v.data)==null?void 0:T.variant)==="SCRIPT"&&(N=!0),((I=v.data)==null?void 0:I.attribute)==="LOOP"&&(b=!0))}),N&&b)return"script_loop";if(N)return"script";if(b)return"loop"},l=(p,g,y)=>{var T,I,S,P,R;let x=e(p.source),N=e(p.target);if(!x||!N)return"simple";if((0,Ct.getOutgoers)(x,g,y).some(C=>C.type==="END_EVENT"))return"final";if(x.type==="GATEWAY")switch((T=x.data)==null?void 0:T.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(x.type==="TASK"){let C=(I=x.data)==null?void 0:I.variant,L=(S=x.data)==null?void 0:S.attribute;if(C==="SUBPROCESS")return"from_sub_process";if(C==="SERVICE_TASK")return"from_service_task";if(N.type==="TASK"&&((P=N.data)==null?void 0:P.variant)==="SUBPROCESS")return"to_sub_process";if(N.type==="TASK"&&((R=N.data)==null?void 0:R.variant)==="SERVICE_TASK")return"to_service_task";let K=C==="SCRIPT",Q=L==="LOOP";return K&&Q?"script_loop":K?"script":Q?"loop":"simple"}return"simple"},c=(p,g,y)=>{let x=[];function N(v,T,I=0){let S=s(v,g,y);if(S.depth=I,T.push(S),v.type==="TASK"){x.push([...T]),T.pop();return}let P=(0,Ct.getIncomers)(v,g,y);if(P.length)for(let R of P)N(R,T,I+1);T.pop()}let b=(0,Ct.getIncomers)(p,g,y);for(let v of b)N(v,[]);return x},d=(p,g,y)=>{let x=[];function N(v,T,I=0){let S=s(v,g,y);if(S.depth=I,T.push(S),v.type==="TASK"){x.push([...T]),T.pop();return}let P=(0,Ct.getOutgoers)(v,g,y);if(P.length)for(let R of P)N(R,T,I+1);T.pop()}let b=(0,Ct.getOutgoers)(p,g,y);for(let v of b)N(v,[]);return x},u=(p,g,y)=>(y=y.filter(N=>N.source===p.id),y.map(N=>{var T;let b=e(N.target),v;return b&&(v=s(b,g,y)),{id:N.id,type:"routing",variant:l(N,g,y),label:(T=N.data)==null?void 0:T.label,target:v}})),f=p=>{let g=e(p);if(!g)return;let y=o(),x=n(),N=s(g,y,x);return N.sources=c(g,y,x),N.targets=d(g,y,x),N.edgeTargets=u(g,y,x),g.type==="GATEWAY"&&(N.variant=a(g,y,x)),N},m=p=>{let g=t(p);if(!g)return;let y=o(),x=n(),N=l(g,y,x),v={id:g.id,type:"routing",variant:N,gatewayVariant:void 0},T=e(g.source);if(T){let S=s(T,y,x);v.source=S;let P=a(T,y,x);if(v.gatewayVariant=P,T.type==="TASK")v.sources=[[S]];else{let R=c(T,y,x);v.sources=R.length?R:[[S]]}}let I=e(g.target);if(I){let S=s(I,y,x);if(v.target=S,I.type==="TASK")v.targets=[[S]];else{let P=d(I,y,x);v.targets=P.length?P:[[S]]}}return v},h=p=>{let g=e(p);if(g)return f(g.id);let y=t(p);if(y)return m(y.id)};return{configureElement:p=>{let g=h(p);if(g)return r([p]),g},getConfigureElement:h,getNodeConfigure:f,getEdgeConfigure:m}};var Jo=require("react/jsx-runtime"),zg={node:"editor.toolbar.configure_node",edge:"editor.toolbar.configure_edge",gateway:"editor.toolbar.configure_gateway"},Co=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,Xt.useTranslation)(),{onConfigureElement:n}=q(),{getConfigureElement:r}=Ri();return(0,Jo.jsxs)(Xt.Tooltip,{children:[(0,Jo.jsx)(Xt.TooltipTrigger,{asChild:!0,children:(0,Jo.jsx)(Xt.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let s=r(e);s&&(n==null||n(s))},children:(0,Jo.jsx)(jc.Settings,{size:16})})}),(0,Jo.jsx)(Xt.TooltipContent,{color:"black",children:o(zg[t])})]})};var Ut=require("@produto-lecom/lecom-ui"),td=require("@xyflow/react"),od=require("lucide-react");var ed=require("@produto-lecom/lecom-ui");function at(){let{toast:e}=Sn(),{toast:t}=(0,ed.useNotificationToast)();return{toast:e||t}}var Qo=require("react/jsx-runtime"),Di=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,Ut.useTranslation)(),{toast:n}=at(),{deleteElements:r,getNodes:i}=(0,td.useReactFlow)();return(0,Qo.jsxs)(Ut.Tooltip,{children:[(0,Qo.jsx)(Ut.TooltipTrigger,{asChild:!0,children:(0,Qo.jsx)(Ut.Button,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{if(t==="node"){let a=i(),l=a.find(c=>c.id===e);if((l==null?void 0:l.type)==="LANE"&&a.some(d=>d.parentId===e)){n({variant:"error",title:o("validation.errors.title"),content:o("editor.toolbar.delete_pool_lane_error")});return}r({nodes:[{id:e}]})}else r({edges:[{id:e}]})},children:(0,Qo.jsx)(od.TrashIcon,{size:16})})}),(0,Qo.jsx)(Ut.TooltipContent,{color:"black",children:o("editor.toolbar.delete")})]})};var $t=require("@produto-lecom/lecom-ui"),nd=require("lucide-react"),rd=require("react"),jo=require("react/jsx-runtime"),Cn=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=(0,$t.useTranslation)(),r=(0,rd.useCallback)(i=>{i.stopPropagation();let s=document.querySelectorAll(`.react-flow__handle.source[data-nodeid="${e}"]`);if(s.length===0)return;let a=Array.from(s).reduce((f,m)=>{let h=f.getBoundingClientRect(),E=m.getBoundingClientRect(),p=Math.hypot(i.clientX-(h.left+h.width/2),i.clientY-(h.top+h.height/2));return Math.hypot(i.clientX-(E.left+E.width/2),i.clientY-(E.top+E.height/2))<p?m:f}),l=a.getBoundingClientRect(),c=l.left+l.width/2,d=l.top+l.height/2,u=new MouseEvent("mousedown",{clientX:c,clientY:d,bubbles:!0,cancelable:!0});a.dispatchEvent(u)},[e]);return(0,jo.jsxs)($t.Tooltip,{children:[(0,jo.jsx)($t.TooltipTrigger,{asChild:!0,children:(0,jo.jsx)($t.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)(nd.MoveUpRightIcon,{size:16})})}),(0,jo.jsx)($t.TooltipContent,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};var Mn=require("react/jsx-runtime"),Pn=i=>{var s=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=s,r=Wt(s,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:a}=q(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d,isToEndEvent:u}=qr(o,n),f=!l&&!c&&!d&&!u,m=[{component:(0,Mn.jsx)(Di,{elementId:e,elementType:"edge"})}],h=()=>a==="view"?f?[{component:(0,Mn.jsx)(Co,{elementId:e,elementType:"edge"})}]:[]:f?[{component:(0,Mn.jsx)(Co,{elementId:e,elementType:"edge"})},...m]:m,p=(g=>{switch(g){case"SEQUENCE_EDGE":return h();case"MESSAGE_EDGE":return a==="view"?[]:[...m];case"ANNOTATION_EDGE":return a==="view"?[]:[...m];default:return[]}})(t);if(!(p.length===0||a==="readonly"))return(0,Mn.jsx)("div",w(_({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:p.map((g,y)=>(0,Mn.jsx)("div",{children:g.component},y))}))};var id=require("@xyflow/react"),sd=require("react");var Fs=require("react/jsx-runtime"),Kt=12,Ln=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:s}=(0,id.useViewport)(),a=1/s,l=(0,sd.useMemo)(()=>t===n?{bottom:`${Kt}px`,transform:"translateX(-50%)"}:e===o?{left:`${Kt}px`,transform:r?"translateY(-100%)":"translateY(-50%)"}:n>t&&o>e?{left:`${Kt}px`,bottom:`${Kt}px`}:n>t&&o<e?{right:`${Kt}px`,bottom:`${Kt}px`}:t>n&&o>e?{right:`${Kt}px`,bottom:`${Kt}px`}:{left:`${Kt}px`,bottom:`${Kt}px`},[e,t,o,n,r]);return(0,Fs.jsx)("div",{style:{transform:`scale(${a})`},children:(0,Fs.jsx)("div",{className:"absolute pointer-events-auto",style:_({},l),children:i})})};var ft=require("react/jsx-runtime"),kn={type:"ANNOTATION_EDGE",reconnectable:!0},ad=({id:e,source:t,target:o,selected:n,data:r})=>{let{isMultipleSelection:i,isReadOnly:s,edgeHighlight:a}=q(),{zoom:l}=(0,Dt.useViewport)(),c=(0,Dt.useInternalNode)(t),d=(0,Dt.useInternalNode)(o);if(!c||!d)return null;let{sx:u,sy:f,tx:m,ty:h}=Tn(c,d),[E,p,g]=(0,Dt.getStraightPath)({sourceX:u,sourceY:f,targetX:m,targetY:h}),y=a&&(n||(c==null?void 0:c.selected)||(d==null?void 0:d.selected));return(0,ft.jsx)(ft.Fragment,{children:(0,ft.jsxs)("g",{className:H("group bpmn-edge",{"is-highlighted":y}),children:[(0,ft.jsx)("path",{d:E,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/l),style:{pointerEvents:"stroke",cursor:"pointer"}}),(0,ft.jsxs)("g",{className:H("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!s,"text-blue-500 group-hover:text-blue-600":y}),children:[(0,ft.jsx)(Dt.BaseEdge,{id:e,path:E,interactionWidth:0,strokeDasharray:4,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":r==null?void 0:r.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":y&&!(r!=null&&r.hasError)})}),(0,ft.jsx)(Dt.EdgeLabelRenderer,{children:(0,ft.jsx)("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${p}px, ${g}px)`},children:n&&!i&&(0,ft.jsx)(Ln,{sx:u,sy:f,tx:m,ty:h,children:(0,ft.jsx)(Pn,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})})})]})]})})};var je=require("react"),Me=require("@xyflow/react");var Ot=require("react");var Us=require("react/jsx-runtime"),Xs=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,ld=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Escape","Shift"],Qe=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:s,onBlur:a,onInput:l,onInvalidFirstCharacter:c,skipFirstCharValidation:d})=>{let u=(0,Ot.useRef)(null),f=(0,Ot.useRef)(null),[m,h]=(0,Ot.useState)(!1);(0,Ot.useEffect)(()=>()=>{f.current&&clearTimeout(f.current)},[]),(0,Ot.useEffect)(()=>{h(i!=null?i:!1)},[i]),(0,Ot.useEffect)(()=>{if(m&&u.current){u.current.focus();let b=document.createRange();b.selectNodeContents(u.current);let v=window.getSelection();v&&(v.removeAllRanges(),v.addRange(b))}},[m]);let E=(0,Ot.useCallback)(()=>{f.current||(c==null||c(),f.current=setTimeout(()=>{f.current=null},500))},[c]),p=b=>{b.stopPropagation(),m||h(!0)},g=b=>{let v=b.currentTarget.innerText.replace(/\n$/,""),T=t&&v.length>=t,I=window.getSelection(),S=(I==null?void 0:I.toString())||"",P=S.length>0,R=(b.ctrlKey||b.metaKey)&&!b.altKey,C=R&&b.key==="a",L=R&&b.key==="c",K=R&&b.key==="x",Q=R&&b.key==="v",j=v.length===0||P&&S.length===v.length;if(!d&&j&&!Xs.test(b.key)&&!ld.includes(b.key)&&!R){b.preventDefault(),E();return}T&&!P&&(ld.includes(b.key)||C||L||K||Q||b.preventDefault())},y=b=>{b.preventDefault();let v=b.clipboardData.getData("text/plain").replace(/\r\n/g,`
2
2
  `).replace(/\r/g,`
3
- `),T=b.currentTarget.innerText.replace(/\n$/,""),I=window.getSelection();if(!I||I.rangeCount===0)return;let S=I.toString(),P=T.length-S.length,R=t?Math.max(0,t-P):1/0;if(R<=0&&S.length===0)return;let C=v;if(C.length>R&&(C=C.substring(0,R)),!C&&S.length===0)return;let L=I.getRangeAt(0),K=L.startOffset===0&&(L.startContainer===b.currentTarget||L.startContainer.parentNode===b.currentTarget);if(!d&&K&&C.length>0&&!Us.test(C[0])){x();return}L.deleteContents();let Q=document.createTextNode(C);L.insertNode(Q),L.setStartAfter(Q),L.collapse(!0),I.removeAllRanges(),I.addRange(L),l==null||l(b.currentTarget.innerText.replace(/\n$/,""))},E=b=>{let v=b.currentTarget,T=v.innerText.replace(/\n$/,"");if(!d&&T.length>0&&!Us.test(T[0])){let I=T.slice(1);if(v.innerText=I,I.length>0&&v.firstChild){let S=document.createRange(),P=window.getSelection();S.setStart(v.firstChild,0),S.collapse(!0),P==null||P.removeAllRanges(),P==null||P.addRange(S)}x(),l==null||l(I);return}l==null||l(T)},N=b=>{g(!1);let v=b.currentTarget.innerText.replace(/\r\n/g,`
3
+ `),T=b.currentTarget.innerText.replace(/\n$/,""),I=window.getSelection();if(!I||I.rangeCount===0)return;let S=I.toString(),P=T.length-S.length,R=t?Math.max(0,t-P):1/0;if(R<=0&&S.length===0)return;let C=v;if(C.length>R&&(C=C.substring(0,R)),!C&&S.length===0)return;let L=I.getRangeAt(0),K=L.startOffset===0&&(L.startContainer===b.currentTarget||L.startContainer.parentNode===b.currentTarget);if(!d&&K&&C.length>0&&!Xs.test(C[0])){E();return}L.deleteContents();let Q=document.createTextNode(C);L.insertNode(Q),L.setStartAfter(Q),L.collapse(!0),I.removeAllRanges(),I.addRange(L),l==null||l(b.currentTarget.innerText.replace(/\n$/,""))},x=b=>{let v=b.currentTarget,T=v.innerText.replace(/\n$/,"");if(!d&&T.length>0&&!Xs.test(T[0])){let I=T.slice(1);if(v.innerText=I,I.length>0&&v.firstChild){let S=document.createRange(),P=window.getSelection();S.setStart(v.firstChild,0),S.collapse(!0),P==null||P.removeAllRanges(),P==null||P.addRange(S)}E(),l==null||l(I);return}l==null||l(T)},N=b=>{h(!1);let v=b.currentTarget.innerText.replace(/\r\n/g,`
4
4
  `).replace(/\r/g,`
5
- `).trim();t&&v.length>t&&(v=v.substring(0,t)),b.currentTarget.innerText=v,a==null||a(),v!==e&&(s==null||s(v))};return(0,$s.jsx)("div",{className:H("flex-1 p-2 self-stretch flex items-center justify-center border border-transparent overflow-hidden text-ellipsis body-medium-400 text-center rounded-sm",{"border border-dashed border-grey-400 bg-white shadow-md":m,"bg-white":e.length>0},n),style:o,onDoubleClick:f,children:(0,$s.jsx)("div",{ref:u,className:H("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":m}),contentEditable:m,suppressContentEditableWarning:!0,onKeyDown:h,onPaste:y,onInput:E,onBlur:N,children:e})})};var Og=require("@xyflow/react");var _e=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,Rn=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),Hi=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),Vg=(e,t,o)=>{let n=o.x-t.x,r=o.y-t.y,i=n*n+r*r;if(i===0)return Rn(e,t);let s=Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*r)/i));return Rn(e,{x:t.x+s*n,y:t.y+s*r})},dd=(e,t)=>{let o=1/0;for(let n=0;n<t.length-1;n++)o=Math.min(o,Vg(e,t[n],t[n+1]));return o};var yr=require("@xyflow/react");var Po={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15,MAX_LABEL_DISTANCE:80};var{TOLERANCE:ce}=Po;function Hg(e,t,o){return _e(e,t,"x",ce)&&_e(t,o,"x",ce)&&_e(e,o,"x",ce)}function Gg(e,t,o){return _e(e,t,"y",ce)&&_e(t,o,"y",ce)&&_e(e,o,"y",ce)}function Bg(e,t,o){if(!Hg(e,t,o))return!1;let n=t.y-e.y,r=o.y-t.y;return Math.abs(n)<ce||Math.abs(r)<ce?!1:n*r<0}function zg(e,t,o){if(!Gg(e,t,o))return!1;let n=t.x-e.x,r=o.x-t.x;return Math.abs(n)<ce||Math.abs(r)<ce?!1:n*r<0}function Yg(e,t,o,n){let r=t.x!==0,i=t.x===-n.x&&t.y===-n.y,s=t.x===n.x&&t.y===n.y,a=120;if(i)if(r){if((o.x-e.x)*t.x>=0)return[{x:(e.x+o.x)/2,y:e.y},{x:(e.x+o.x)/2,y:o.y}];{let l=(e.y+o.y)/2,c=Math.abs(e.y-o.y)<a?Math.max(e.y,o.y)+a:l;return[{x:e.x,y:c},{x:o.x,y:c}]}}else{if((o.y-e.y)*t.y>=0)return[{x:e.x,y:(e.y+o.y)/2},{x:o.x,y:(e.y+o.y)/2}];{let l=(e.x+o.x)/2,c=Math.abs(e.x-o.x)<a?Math.max(e.x,o.x)+a:l;return[{x:c,y:e.y},{x:c,y:o.y}]}}else if(s)if(r)if((o.x-e.x)*t.x>0&&Math.abs(e.y-o.y)<a){let l=Math.max(e.y,o.y)+a,c=o.x+t.x*(a/2);return[{x:e.x,y:l},{x:c,y:l},{x:c,y:o.y}]}else{let l=t.x>0?Math.max(e.x,o.x):Math.min(e.x,o.x);return[{x:l,y:e.y},{x:l,y:o.y}]}else if((o.y-e.y)*t.y>0&&Math.abs(e.x-o.x)<a){let l=Math.max(e.x,o.x)+a,c=o.y+t.y*(a/2);return[{x:l,y:e.y},{x:l,y:c},{x:o.x,y:c}]}else{let l=t.y>0?Math.max(e.y,o.y):Math.min(e.y,o.y);return[{x:e.x,y:l},{x:o.x,y:l}]}else{let l=t.x!==0?o.x:e.x,c=t.y!==0?o.y:e.y,d=t.x!==0?(l-e.x)*t.x:(c-e.y)*t.y,u=n.x!==0?(l-o.x)*n.x:(c-o.y)*n.y;return d>=0&&u>=0?[{x:l,y:c}]:r?[{x:e.x,y:o.y}]:[{x:o.x,y:e.y}]}}function ud(e){if(e.length<=2)return e;let t=[e[0]];for(let o=1;o<e.length-1;o++){let n=t[t.length-1],r=e[o],i=e[o+1];_e(n,r,"x",ce)&&_e(r,i,"x",ce)||_e(n,r,"y",ce)&&_e(r,i,"y",ce)||t.push(r)}return t.push(e[e.length-1]),t}function Gi(e){let t=[];for(let o of e){let n=t[t.length-1];(!n||Math.abs(n.x-o.x)>=ce||Math.abs(n.y-o.y)>=ce)&&t.push(o)}return t}function Wg(e){let t=[...e],o=!0;for(;o;){o=!1;for(let n=1;n<t.length-1;n++){let r=t[n-1],i=t[n],s=t[n+1];if(Bg(r,i,s)||zg(r,i,s)){t.splice(n,1),o=!0;break}}}return t}function pd(e){let t=Gi(ud([...e]));return t=Wg(t),Gi(ud(t))}function Bi(e){switch(e){case yr.Position.Left:return{x:-1,y:0};case yr.Position.Right:return{x:1,y:0};case yr.Position.Top:return{x:0,y:-1};case yr.Position.Bottom:return{x:0,y:1};default:return{x:0,y:0}}}function fd(e,t,o,n){let r=Po.OFFSET,i=Po.OFFSET;if(t.x===-n.x&&t.y===-n.y)if(t.x!==0){let s=(o.x-e.x)*t.x;s>0&&s<2*Po.OFFSET&&(r=s/2,i=s/2)}else{let s=(o.y-e.y)*t.y;s>0&&s<2*Po.OFFSET&&(r=s/2,i=s/2)}return{sourceOffset:r,targetOffset:i}}function Fg(e,t,o,n,r,i,s=0){let a=Bi(r),l=Bi(i),c=a.x===0?s:0,d=a.y===0?s:0,u=l.x===0?s:0,p=l.y===0?s:0,m={x:e+c,y:t+d},g={x:o+u,y:n+p},{sourceOffset:x,targetOffset:f}=fd(m,a,g,l),h={x:m.x+a.x*x,y:m.y+a.y*x},y={x:g.x+l.x*f,y:g.y+l.y*f},E=Yg(h,a,y,l),N=[m,h,...E,y,g],b=pd(N);if(b.length===2&&zi(m,g)>ce){let v=_e(m,h,"x",ce)&&_e(h,y,"x",ce)&&_e(y,g,"x",ce),T=_e(m,h,"y",ce)&&_e(h,y,"y",ce)&&_e(y,g,"y",ce);if(v||T){let I=T&&(y.x-h.x)*a.x<0,S=v&&(y.y-h.y)*a.y<0;if(!I&&!S)return Gi([m,h,y,g])}}return b}function Yi(e,t,o,n,r,i,s,a=0){if(!(s!=null&&s.length))return Fg(e,t,o,n,r,i,a);let l=Bi(r),c=Bi(i),d=l.x===0?a:0,u=l.y===0?a:0,p=c.x===0?a:0,m=c.y===0?a:0,g={x:e+d,y:t+u},x={x:o+p,y:n+m},{sourceOffset:f,targetOffset:h}=fd(g,l,x,c),y={x:g.x+l.x*f,y:g.y+l.y*f},E={x:x.x+c.x*h,y:x.y+c.y*h},N=[...s],b=N[0],v=l.y===0;v&&Math.abs(g.y-b.y)>ce?N.unshift({x:b.x,y:g.y}):!v&&Math.abs(g.x-b.x)>ce&&N.unshift({x:g.x,y:b.y});let T=N[N.length-1],I=c.y===0,S=[];(Math.abs(T.x-E.x)>ce||Math.abs(T.y-E.y)>ce)&&(I?S.push({x:E.x,y:T.y}):S.push({x:T.x,y:E.y})),S.push(E);let P=[g,...N,...S,x],R=pd(P);if(R.length===2&&zi(g,x)>ce){let C=_e(g,y,"x",ce)&&_e(y,E,"x",ce)&&_e(E,x,"x",ce),L=_e(g,y,"y",ce)&&_e(y,E,"y",ce)&&_e(E,x,"y",ce);if(C||L){let K=L&&(E.x-y.x)*l.x<0,Q=C&&(E.y-y.y)*l.y<0;if(!K&&!Q)return Gi([g,y,E,x])}}return R}var zi=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Xg(e,t,o){return _e(e,t,"x",ce)&&_e(t,o,"x",ce)||_e(e,t,"y",ce)&&_e(t,o,"y",ce)}function Ug(e,t,o,n){if(Xg(e,t,o))return`L${t.x} ${t.y}`;let r=zi(e,t),i=zi(t,o),s=Math.min(r/2,i/2,n);if(s<1)return`L${t.x} ${t.y}`;let a=e.x-t.x,l=e.y-t.y,c=o.x-t.x,d=o.y-t.y,u={x:a/r,y:l/r},p={x:c/i,y:d/i},m={x:t.x+u.x*s,y:t.y+u.y*s},g={x:t.x+p.x*s,y:t.y+p.y*s},x=-u.x,f=-u.y,h=p.x,y=p.y,N=x*y-f*h>0?1:0;return`L${m.x} ${m.y}A${s} ${s} 0 0 ${N} ${g.x} ${g.y}`}var md=(e,t=5)=>e.length<2?"":e.reduce((o,n,r)=>{let i="";return r>0&&r<e.length-1?i=Ug(e[r-1],n,e[r+1],t):i=`${r===0?"M":"L"}${n.x} ${n.y}`,o+=i,o},"");var Ce=require("react"),Wi=require("@xyflow/react");var $g=50,gd=.1,Kg=.6,Fi=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:s,getNodes:a,getEdge:l,screenToFlowPosition:c}=(0,Wi.useReactFlow)(),{setIsDragging:d,setReconnectingEdgeId:u}=q(),p=(0,Wi.useStore)(D=>D.isValidConnection),[m,g]=(0,Ce.useState)(null),[x,f]=(0,Ce.useState)(null),[h,y]=(0,Ce.useState)(null),[E,N]=(0,Ce.useState)(null),[b,v]=(0,Ce.useState)(null),[T,I]=(0,Ce.useState)(!1),S=(0,Ce.useRef)(null),P=(0,Ce.useRef)(null),R=(0,Ce.useRef)(null),C=(0,Ce.useRef)(t),L=(0,Ce.useRef)(o);(0,Ce.useEffect)(()=>{C.current=t,L.current=o},[t,o]),(0,Ce.useEffect)(()=>{S.current=m},[m]),(0,Ce.useEffect)(()=>{P.current=b},[b]);let K=(0,Ce.useCallback)(D=>{let A=a(),B=A.find(Y=>Y.id===D);if(!B)return{x:0,y:0};let G=B.position.x,k=B.position.y,O=B.parentId;for(;O;){let Y=A.find(W=>W.id===O);if(!Y)break;G+=Y.position.x,k+=Y.position.y,O=Y.parentId}return{x:G,y:k}},[a]),Q=(0,Ce.useCallback)(D=>{var O,Y,W,U,X,$;let A=a(),B=null,G=$g,k=A.filter(te=>te.type!=="LANE"&&te.type!=="ANNOTATION");for(let te of k){if(te.id===e)continue;let ie=K(te.id),F=(W=(Y=(O=te.measured)==null?void 0:O.width)!=null?Y:te.width)!=null?W:0,oe=($=(X=(U=te.measured)==null?void 0:U.height)!=null?X:te.height)!=null?$:0;if(D.x>=ie.x&&D.x<=ie.x+F&&D.y>=ie.y&&D.y<=ie.y+oe)return te.id;let Z=Math.max(ie.x-D.x,0,D.x-(ie.x+F)),ve=Math.max(ie.y-D.y,0,D.y-(ie.y+oe)),ye=Math.sqrt(Z*Z+ve*ve);ye<G&&(G=ye,B=te.id)}return B},[a,K,e]),j=(0,Ce.useCallback)((D,A)=>{var Z,ve,ye,Ae,J,de;let B=s(D);if(!B)return null;let G=K(D),k=(ye=(ve=(Z=B.measured)==null?void 0:Z.width)!=null?ve:B.width)!=null?ye:0,O=(de=(J=(Ae=B.measured)==null?void 0:Ae.height)!=null?J:B.height)!=null?de:0,Y=Math.abs(G.x+k-A.x),W=Math.abs(A.x-G.x),U=Math.abs(G.y+O-A.y),X=Math.abs(A.y-G.y),$={right:Y,left:W,bottom:U,top:X},te=Object.entries($).reduce((re,[ee,xe])=>xe<re[1]?[ee,xe]:re,["right",$.right])[0],ie=R.current;if(ie&&ie!==te){let re=$[te],ee=$[ie],xe=Math.abs(ee-re),Se=Math.min(Math.abs(ee),Math.abs(re));xe<Se*Kg&&(te=ie)}let F=te,oe,le;if(F==="right"||F==="left"){let ee=(Math.max(G.y,Math.min(G.y+O,A.y))-G.y)/(O||1);Math.abs(ee-.5)<gd&&(ee=.5),le=ee,oe={x:F==="right"?G.x+k:G.x,y:G.y+le*O}}else{let ee=(Math.max(G.x,Math.min(G.x+k,A.x))-G.x)/(k||1);Math.abs(ee-.5)<gd&&(ee=.5),le=ee,oe={x:G.x+le*k,y:F==="bottom"?G.y+O:G.y}}return{side:F,snapPosition:oe,offset:le}},[s,K]),z=(0,Ce.useCallback)(D=>{var W,U,X;let A=S.current;if(!A)return;let B=c({x:D.clientX,y:D.clientY}),G=Q(B);y(G);let k=B,O=null,Y=null;if(G){let $=j(G,B);$&&(O=$.side,k=$.snapPosition,Y=$.offset,R.current=O);let te=l(e),ie={source:A==="source"?G:C.current,target:A==="target"?G:L.current,sourceHandle:A==="source"?O:(W=te==null?void 0:te.sourceHandle)!=null?W:null,targetHandle:A==="target"?O:(U=te==null?void 0:te.targetHandle)!=null?U:null},F=(X=p==null?void 0:p(ie))!=null?X:!0;I(F)}else R.current=null,I(!1);N(O),v(Y),f(k)},[Q,j,l,e,c,p]),M=(0,Ce.useCallback)(D=>{var O,Y,W,U,X;let A=S.current;if(!A)return;let B=c({x:D.clientX,y:D.clientY}),G=Q(B);if(G){let $=j(G,B),te=(O=$==null?void 0:$.side)!=null?O:null,ie=(Y=$==null?void 0:$.offset)!=null?Y:.5,F=l(e),oe={source:A==="source"?G:C.current,target:A==="target"?G:L.current,sourceHandle:A==="source"?te:(W=F==null?void 0:F.sourceHandle)!=null?W:null,targetHandle:A==="target"?te:(U=F==null?void 0:F.targetHandle)!=null?U:null};((X=p==null?void 0:p(oe))==null||X)&&i(le=>le.map(Z=>{var ve,ye;return Z.id===e?w(_({},Z),{source:oe.source,target:oe.target,sourceHandle:oe.sourceHandle,targetHandle:oe.targetHandle,data:w(_({},Z.data),{points:void 0,sourceOffset:A==="source"?ie:(ve=Z.data)==null?void 0:ve.sourceOffset,targetOffset:A==="target"?ie:(ye=Z.data)==null?void 0:ye.targetOffset})}):Z}))}g(null),f(null),y(null),N(null),v(null),d(!1),I(!1),u(null),R.current=null,document.removeEventListener("mouseup",M),document.removeEventListener("mousemove",z);let k=qt.get(n);k==null||k.clearReconnectingEdge()},[e,Q,j,l,i,n,z,p,c,d,u]),V=(0,Ce.useCallback)((D,A)=>{if(r||A.button!==0)return;A.stopPropagation(),A.preventDefault(),i(G=>G.map(k=>k.id===e?w(_({},k),{data:w(_({},k.data),{points:void 0})}):k)),g(D),u(e);let B=qt.get(n);B==null||B.setReconnectingEdge(e),document.addEventListener("mousemove",z),document.addEventListener("mouseup",M)},[r,e,n,z,M,u,i]);return(0,Ce.useEffect)(()=>()=>{if(S.current){document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",M),u(null);let D=qt.get(n);D==null||D.clearReconnectingEdge()}},[n,z,M,u]),{reconnectingHandle:m,cursorPosition:x,hoveredNodeId:h,reconnectingSide:E,reconnectingOffset:b,isValidReconnection:T,handleReconnectStart:V}};var ge=require("react/jsx-runtime"),Mt={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:Me.MarkerType.ArrowClosed},markerEnd:{type:Me.MarkerType.Arrow},data:{label:""}},{MOVE_THRESHOLD:Xi,MIN_SEGMENT_LENGTH:qg,PARALLEL_OFFSET:hd,MAX_LABEL_DISTANCE:Zg}=Po;function Jg(e,t,o,n,r){let i=r.find(d=>d.id===t),s=r.find(d=>d.id===o);if((i==null?void 0:i.type)==="GATEWAY"||(s==null?void 0:s.type)==="GATEWAY")return 0;let a=n.filter(d=>d.source===t&&d.target===o||d.source===o&&d.target===t);if(a.length<=1){let d=n.filter(m=>m.source===t);if(d.length<=1)return 0;let u=d.findIndex(m=>m.id===e);if(u<=0)return 0;let p=(d.length-1)/2;return(u-p)*hd}let l=a.findIndex(d=>d.id===e),c=(a.length-1)/2;return(l-c)*hd}var yd=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:s,sourceHandleId:a,targetHandleId:l})=>{var $,te,ie,F,oe,le,Z,ve,ye,Ae;let{zoom:c}=(0,Me.useViewport)(),{updateEdgeData:d}=(0,Me.useReactFlow)(),u=(0,Me.useEdges)(),p=(0,Me.useNodes)(),{isMultipleSelection:m,isReadOnly:g,mode:x,instanceId:f,edgeHighlight:h}=q(),[y,E]=(0,je.useState)(!1),[N,b]=(0,je.useState)(null),v=(0,je.useRef)(null),T=(0,je.useRef)(n==null?void 0:n.labelOffset),I=(0,je.useRef)(null),S=x!=="edit",{reconnectingHandle:P,cursorPosition:R,hoveredNodeId:C,reconnectingSide:L,isValidReconnection:K,handleReconnectStart:Q}=Fi({edgeId:e,source:t,target:o,instanceId:f,isReadOnly:S}),j=(0,Me.useInternalNode)(t),z=(0,Me.useInternalNode)(o),{sx:M,sy:V,tx:D,ty:A,sourcePos:B,targetPos:G}=(0,je.useMemo)(()=>{var Bt,zt;let J=j&&z?Tn(j,z):{sx:0,sy:0,tx:0,ty:0,sourcePos:Me.Position.Right,targetPos:Me.Position.Left},de=a?i:J.sourcePos,re=l?s:J.targetPos,ee=(dt,Ee,he)=>{var nt,Yt,xo,ro,io,ha;let{x:pe,y:De}=dt.internals.positionAbsolute,ut=(xo=(Yt=(nt=dt.measured)==null?void 0:nt.width)!=null?Yt:dt.width)!=null?xo:0,wt=(ha=(io=(ro=dt.measured)==null?void 0:ro.height)!=null?io:dt.height)!=null?ha:0;switch(Ee){case Me.Position.Top:return{x:pe+ut*he,y:De};case Me.Position.Bottom:return{x:pe+ut*he,y:De+wt};case Me.Position.Left:return{x:pe,y:De+wt*he};case Me.Position.Right:return{x:pe+ut,y:De+wt*he};default:return{x:pe+ut/2,y:De+wt/2}}},xe=(Bt=n==null?void 0:n.sourceOffset)!=null?Bt:.5,Se=(zt=n==null?void 0:n.targetOffset)!=null?zt:.5,Re=j?ee(j,de,xe).x:J.sx,qe=j?ee(j,de,xe).y:J.sy,Nt=z?ee(z,re,Se).x:J.tx,no=z?ee(z,re,Se).y:J.ty;return P==="source"&&R?(Re=R.x,qe=R.y,L&&(de=L)):P==="target"&&R&&(Nt=R.x,no=R.y,L&&(re=L)),{sx:Re,sy:qe,tx:Nt,ty:no,sourcePos:de,targetPos:re}},[j,z,a,l,i,s,P,R,L,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);(0,je.useEffect)(()=>{var re;if(!I.current){I.current={sx:M,sy:V,tx:D,ty:A,sourcePos:B,targetPos:G};return}let J=I.current;if(Math.abs(M-J.sx)>Xi||Math.abs(V-J.sy)>Xi||Math.abs(D-J.tx)>Xi||Math.abs(A-J.ty)>Xi||J.sourcePos!==B||J.targetPos!==G){let ee={};(re=n==null?void 0:n.points)!=null&&re.length&&(ee.points=void 0),n!=null&&n.labelOffset&&(ee.labelOffset=void 0),Object.keys(ee).length>0&&d(e,_(_({},n),ee))}I.current={sx:M,sy:V,tx:D,ty:A,sourcePos:B,targetPos:G}},[M,V,D,A,B,G,n,e,d,P]);let k=(0,je.useMemo)(()=>{let J=Jg(e,t,o,u,p);return Yi(M,V,D,A,B,G,n==null?void 0:n.points,J)},[M,V,D,A,B,G,n==null?void 0:n.points,u,p,e,t,o]),O=(0,je.useMemo)(()=>{if(k.length<2)return Hi({x:M,y:V},{x:D,y:A});let J=0;for(let ee=0;ee<k.length-1;ee++)J+=Rn(k[ee],k[ee+1]);let de=J/2,re=0;for(let ee=0;ee<k.length-1;ee++){let xe=Rn(k[ee],k[ee+1]);if(re+xe>=de){let Se=(de-re)/xe,Re=k[ee],qe=k[ee+1];return{x:Re.x+(qe.x-Re.x)*Se,y:Re.y+(qe.y-Re.y)*Se}}re+=xe}return Hi({x:M,y:V},{x:D,y:A})},[k,M,V,D,A]),Y=(0,je.useCallback)((J,de)=>{if(x!=="edit"||de.button!==0)return;de.stopPropagation(),de.preventDefault();let re=k[J],ee=k[J+1],xe=_e(re,ee,"y"),Se=xe?re.y:re.x,Re=[...k],qe=Re.length,Nt=J,no=J+1;b(J);let Bt=dt=>{let Ee=Se+(xe?dt.clientY-de.clientY:dt.clientX-de.clientX)/c;v.current=xe?{x:(re.x+ee.x)/2,y:Ee}:{x:Ee,y:(re.y+ee.y)/2};let he=[];for(let pe=1;pe<qe-1;pe++){let De=Re[pe];pe===Nt||pe===no?xe?he.push({x:De.x,y:Ee}):he.push({x:Ee,y:De.y}):he.push(_({},De))}d(e,w(_({},n),{points:he}))},zt=()=>{b(null),v.current=null,document.removeEventListener("mousemove",Bt),document.removeEventListener("mouseup",zt)};document.addEventListener("mousemove",Bt),document.addEventListener("mouseup",zt)},[x,k,c,n,e,d]),W=(0,je.useCallback)(J=>{var Bt,zt,dt,Ee,he;if(y||S||J.button!==0||!((Bt=n==null?void 0:n.label)!=null&&Bt.trim()))return;J.stopPropagation(),J.preventDefault();let de=J.clientX,re=J.clientY,ee=(dt=(zt=n==null?void 0:n.labelOffset)==null?void 0:zt.x)!=null?dt:0,xe=(he=(Ee=n==null?void 0:n.labelOffset)==null?void 0:Ee.y)!=null?he:0,Se=[...k],Re={x:O.x,y:O.y},qe=!1,Nt=pe=>{let De=(pe.clientX-de)/c,ut=(pe.clientY-re)/c;if(!qe&&Math.abs(De)<3&&Math.abs(ut)<3)return;qe=!0;let wt={x:ee+De,y:xe+ut};T.current=wt,d(e,w(_({},n),{labelOffset:wt}))},no=()=>{document.removeEventListener("mousemove",Nt),document.removeEventListener("mouseup",no);let pe=T.current;if(!pe)return;let De={x:Re.x+pe.x,y:Re.y+pe.y};dd(De,Se)>Zg&&(T.current=void 0,d(e,w(_({},n),{labelOffset:void 0})))};document.addEventListener("mousemove",Nt),document.addEventListener("mouseup",no)},[y,S,c,n,e,d,k,O]);if(!j||!z)return null;let U=md(k),X=h&&(r||j.selected||z.selected);return(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsxs)("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":X}),onDoubleClick:()=>!S&&E(!0),children:[(0,ge.jsx)("path",{d:U,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),className:H({"nopan nodrag":!y&&!S&&!!(($=n==null?void 0:n.label)!=null&&$.trim())}),style:{pointerEvents:"stroke",cursor:!y&&!S&&((te=n==null?void 0:n.label)!=null&&te.trim())?"move":"pointer"},onMouseDown:W}),(0,ge.jsxs)("g",{className:H("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!g,"text-blue-500 group-hover:text-blue-600":X}),children:[(0,ge.jsx)(Me.BaseEdge,{id:e,path:U,interactionWidth:0,markerEnd:`url(#${X?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75",{"group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]":!g,"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||P&&C&&!K,"stroke-green-500":P&&C&&K,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":X&&!(n!=null&&n.hasError)&&!P})}),r&&!m&&!S&&(0,ge.jsx)("g",{children:k.slice(0,-1).map((J,de)=>{let re=k[de+1];if(de===0||de===k.length-2||Rn(J,re)<qg)return null;let ee=_e(J,re,"y"),xe=N===de,Se=xe&&v.current?v.current:Hi(J,re);return(0,ge.jsxs)("g",{children:[(0,ge.jsx)("line",{x1:J.x,y1:J.y,x2:re.x,y2:re.y,stroke:"transparent",strokeWidth:20/c,className:H("cursor-pointer",{"cursor-ns-resize":ee,"cursor-ew-resize":!ee}),onMouseDown:Re=>Y(de,Re)}),(0,ge.jsx)("circle",{cx:Se.x,cy:Se.y,r:4/c,fill:xe?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ge.jsx)("circle",{cx:Se.x,cy:Se.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:xe?.6:.3,className:"pointer-events-none"})]},de)})})]})]}),(0,ge.jsxs)(Me.EdgeLabelRenderer,{children:[(0,ge.jsx)("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${O.x}px, ${O.y}px)`},children:r&&!m&&(0,ge.jsx)(Ln,{sx:M,sy:V,tx:D,ty:A,hasLabel:!!((ie=n==null?void 0:n.label)!=null&&ie.trim()),children:(0,ge.jsx)(Pn,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:j,targetNode:z})})}),(y||((F=n==null?void 0:n.label)==null?void 0:F.trim()))&&(0,ge.jsx)("div",{className:H("absolute nodrag nopan",!y&&!S&&((oe=n==null?void 0:n.label)!=null&&oe.trim())?"z-[10001] pointer-events-auto":"z-[3000] pointer-events-none"),style:{transform:`translate(-50%, -50%) translate(${O.x+((Z=(le=n==null?void 0:n.labelOffset)==null?void 0:le.x)!=null?Z:0)}px, ${O.y+((ye=(ve=n==null?void 0:n.labelOffset)==null?void 0:ve.y)!=null?ye:0)}px)`,cursor:!y&&!S&&((Ae=n==null?void 0:n.label)!=null&&Ae.trim())?"move":void 0},onMouseDown:!y&&!S?W:void 0,onDoubleClick:J=>{S||(J.stopPropagation(),E(!0))},children:(0,ge.jsx)(Qe,{value:n==null?void 0:n.label,className:H("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":y,"pointer-events-none":!y}),isEditing:y,onBlur:()=>E(!1),onChange:J=>d(e,{label:J.trim()})})}),r&&!m&&!S&&(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsx)("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${k[0].x}px, ${k[0].y}px)`},children:(0,ge.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:P==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:P==="source"?.6:.3,className:"pointer-events-none"}),(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!P||P!=="source","cursor-not-allowed":P==="source"&&C&&!K,"cursor-grabbing":P==="source"&&(!C||K)}),onMouseDown:J=>Q("source",J.nativeEvent)})]})}),(0,ge.jsx)("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${k[k.length-1].x}px, ${k[k.length-1].y}px)`},children:(0,ge.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:P==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:P==="target"?.6:.3,className:"pointer-events-none"}),(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!P||P!=="target","cursor-not-allowed":P==="target"&&C&&!K,"cursor-grabbing":P==="target"&&(!C||K)}),onMouseDown:J=>Q("target",J.nativeEvent)})]})})]})]})]})};var Zt=require("@xyflow/react"),Qg={right:Zt.Position.Right,left:Zt.Position.Left,top:Zt.Position.Top,bottom:Zt.Position.Bottom},Ui=e=>{var t;return(t=Qg[e!=null?e:""])!=null?t:Zt.Position.Right},Ks=(e,t,o=.5)=>{var l,c,d,u;let{x:n,y:r}=e.internals.positionAbsolute,i=(c=(l=e.measured)==null?void 0:l.width)!=null?c:0,s=(u=(d=e.measured)==null?void 0:d.height)!=null?u:0;switch(Ui(t)){case Zt.Position.Right:return{x:n+i,y:r+s*o};case Zt.Position.Left:return{x:n,y:r+s*o};case Zt.Position.Top:return{x:n+i*o,y:r};case Zt.Position.Bottom:return{x:n+i*o,y:r+s};default:return{x:n+i/2,y:r+s/2}}},xd=(e,t,o)=>{var d,u;let{position:{x:n,y:r},measured:i}=e,s=(d=i.width)!=null?d:0,a=(u=i.height)!=null?u:0;return[{id:"left",x:n,y:r+a/2},{id:"right",x:n+s,y:r+a/2},{id:"top",x:n+s/2,y:r},{id:"bottom",x:n+s/2,y:r+a}].reduce((p,m)=>{let g=Math.hypot(t-p.x,o-p.y);return Math.hypot(t-m.x,o-m.y)<g?m:p}).id};var Tu=require("use-debounce");var Wn=require("@xyflow/react"),aa=require("react");var xr=(u=>(u.START_EVENT="start-event",u.END_EVENT_TERMINATE="end-event-terminate",u.TASK="task",u.TASK_SCRIPT="task-script",u.SUBPROCESS="subprocess-collapsed",u.GATEWAY_EXCLUSIVE="gateway-exclusive",u.GATEWAY_PARALLEL="gateway-parallel",u.GATEWAY_COMPLEX="gateway-complex",u.SERVICE_TASK="service-task",u.ANNOTATION="annotation",u.LANE="lane",u))(xr||{});var $i=require("xml-js");var Ed={compact:!0,spaces:4},jg=e=>e.replace(/\n/g,"&#xA;");function Ki(e,t=Ed){if(e)return JSON.parse((0,$i.xml2json)(e,t))}function _d(e,t=Ed){return e?(0,$i.json2xml)(e,w(_({},t),{attributeValueFn:jg})):""}var bd={"attribute-loop":"LOOP"},Td={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS","service-task":"SERVICE_TASK"},vd={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Nd={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed",SERVICE_TASK:"service-task"},wd={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var Dn=(e,t,o,n,r,i)=>{let s=e._attributes.width||0,a=e._attributes.height||0,l=0,c=0;if(n&&r!==void 0&&i!==void 0){let g=n.split(`
6
- `),x=g.length;l=g.reduce((h,y)=>Math.max(h,y.length),0)*7+r,c=x*20+i}let d=Math.max(_o(Number(s),t),l),u=Math.max(_o(Number(a),o),c);return{width:d,height:u,measured:{width:d,height:u}}},On=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,parent:r,value:i}=t,s={x:Number(o._attributes.x||0),y:Number(o._attributes.y||0)},a={id:n,position:s,data:{label:i||""}},l=r==="1"?void 0:r;return l&&(a.parentId=l),a},th=e=>{let{mxGeometry:t}=e,o=On(e),n=Dn(t,ue.START_EVENT.MIN_WIDTH,ue.START_EVENT.MIN_HEIGHT);return w(_(_({},o),n),{type:"START_EVENT"})},oh=e=>{let{mxGeometry:t}=e,o=On(e),n=Dn(t,ue.END_EVENT.MIN_WIDTH,ue.END_EVENT.MIN_HEIGHT);return w(_(_({},o),n),{type:"END_EVENT"})},qi=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=On(e),a=Dn(n,ue.TASK.MIN_WIDTH,ue.TASK.MIN_HEIGHT,r.data.label,48,24),l=t==null?void 0:t.find(d=>{let{parent:u}=d._attributes;return u===e._attributes.id});if(l){let{style:d}=l._attributes,u=bd[d];u&&(r.data.attribute=u)}let c=Td[o.style];return c&&(r.data.variant=c),w(_(_({},r),a),{type:"TASK"})},qs=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=On(e),i=Dn(o,ue.GATEWAY.MIN_WIDTH,ue.GATEWAY.MIN_HEIGHT);return r.data.variant=vd[n],w(_(_({},r),i),{type:"GATEWAY"})},nh=e=>{let{mxGeometry:t}=e,o=On(e),i=Dn(t,ue.ANNOTATION.MIN_WIDTH,ue.ANNOTATION.MIN_HEIGHT,o.data.label,32,24);return w(_(_({},o),i),{type:"ANNOTATION"})},rh=e=>{let{mxGeometry:t}=e,o=On(e),n=Dn(t,ue.LANE.MIN_WIDTH,ue.LANE.MIN_HEIGHT);return w(_(_({},o),n),{type:"LANE"})},Id={task:qi,"task-script":qi,"subprocess-collapsed":qi,"service-task":qi,"start-event":th,"end-event-terminate":oh,"gateway-parallel":qs,"gateway-exclusive":qs,"gateway-complex":qs,annotation:nh,lane:rh},ih=e=>{if(e&&Array.isArray(e))return e.map(t=>({x:Number(t._attributes.x),y:Number(t._attributes.y)}))},Ad=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,source:r,target:i,value:s,style:a,sourceHandle:l,targetHandle:c,sourceOffset:d,targetOffset:u,labelOffsetX:p,labelOffsetY:m}=t,g=ih(o==null?void 0:o.Array),x=d!==void 0?Number(d):void 0,f=u!==void 0?Number(u):void 0,h=p!==void 0?Number(p):void 0,y=m!==void 0?Number(m):void 0,E=w(_(_({id:n,source:r,target:i},l?{sourceHandle:l}:{}),c?{targetHandle:c}:{}),{data:_(_(_(_({label:s||""},g&&g.length>0?{points:g}:{}),x!==void 0?{sourceOffset:x}:{}),f!==void 0?{targetOffset:f}:{}),h!==void 0&&y!==void 0?{labelOffset:{x:h,y}}:{})});return a.includes("association")&&a.includes('endArrow=""')?_(_({},kn),E):_(_({},Mt),E)},Sd=(e,t)=>{var m,g;let{id:o,type:n,source:r,target:i,sourceHandle:s,targetHandle:a,data:l}=e,c=t==null?void 0:t.find(x=>x.id===r),d="";n==="ANNOTATION_EDGE"&&(d='association;endArrow=""');let u={_attributes:{as:"geometry",relative:"1"}};return l!=null&&l.points&&Array.isArray(l.points)&&l.points.length>0&&(u.Array=l.points.map(x=>({_attributes:{as:"mxPoint",x:x.x,y:x.y}}))),{_attributes:{id:o,parent:(c==null?void 0:c.parentId)||"1",edge:"1",style:d,source:r,target:i,value:(l==null?void 0:l.label)||"",sourceHandle:s!=null?s:void 0,targetHandle:a!=null?a:void 0,sourceOffset:(l==null?void 0:l.sourceOffset)!==void 0?String(l.sourceOffset):void 0,targetOffset:(l==null?void 0:l.targetOffset)!==void 0?String(l.targetOffset):void 0,labelOffsetX:((m=l==null?void 0:l.labelOffset)==null?void 0:m.x)!==void 0?String(l.labelOffset.x):void 0,labelOffsetY:((g=l==null?void 0:l.labelOffset)==null?void 0:g.y)!==void 0?String(l.labelOffset.y):void 0},mxGeometry:u}},Vn=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}}}},sh=e=>{let{variant:t}=e.data,o=Vn(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:Nd[t]||"task"})})},ah=e=>{let t=Vn(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"start-event"})})},lh=e=>{let t=Vn(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"end-event-terminate"})})},ch=e=>{let{variant:t}=e.data,o=Vn(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:wd[t]})})},dh=e=>{let t=Vn(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"lane"})})},uh=e=>{let t=Vn(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"annotation"})})},Cd={TASK:sh,START_EVENT:ah,END_EVENT:lh,GATEWAY:ch,ANNOTATION:uh,LANE:dh},Md=(e,t)=>{var s,a;let r=((s=e.measured)==null?void 0:s.width)||0,i=((a=e.measured)==null?void 0:a.height)||0;return{_attributes:{id:`${t+1}`,parent:e.id,style:"attribute-loop",connectable:"0"},mxGeometry:{_attributes:{as:"geometry",x:r/2-22/2,y:i-22,width:22,height:22}}}};var Zs=cf(require("@dagrejs/dagre"),1),Er=require("@xyflow/react");var Ld=(e=[],t=[],o="LR")=>{let n=new Zs.default.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:i,width:s,height:a})=>n.setNode(i,{width:s,height:a})),t.forEach(i=>n.setEdge(i.source,i.target)),Zs.default.layout(n),{nodes:e.map(i=>{let s=n.node(i.id);return w(_({},i),{position:{x:s.x-i.width/2,y:s.y-i.height/2}})}),edges:t}},uo=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId);if(t.length===0)return e;let o=Va(e);for(let n of t){let r=[...o.values()],i=r.filter(a=>a.parentId===n.id);if(i.length===0)continue;let s=i.filter(a=>a.type==="LANE");if(s.length>0){Wa(s,o,r),Fa(n,o);continue}ws(n,i,o)}return Ha(e,o)},kd=uo,Rd=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)};var ph=500;var fh=e=>e.type==="LANE"&&!e.parentId,mh=(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},gh=(e,t)=>{let o=e.x+e.width,n=e.y+e.height,r=t.x+t.width,i=t.y+t.height,s=Math.max(e.x-r,t.x-o,0),a=Math.max(e.y-i,t.y-n,0);return Math.hypot(s,a)},hh=e=>{let t=new Set;for(let o of e)t.add(o.source),t.add(o.target);return t},Pd=(e,t,o)=>{if(e.type!=="ANNOTATION"||o.has(e.id))return!1;let n=(0,Er.getNodesBounds)([e]);return gh(t,n)>ph},Js=(e,t=[])=>{var x;let o=e.filter(fh);if(o.length===0)return e;let n=new Map;for(let f of e){if(!f.parentId)continue;let h=(x=n.get(f.parentId))!=null?x:[];h.push(f.id),n.set(f.parentId,h)}let r=new Set,i=o.map(f=>f.id);for(;i.length>0;){let f=i.pop();if(!f||r.has(f))continue;r.add(f);let h=n.get(f);if(h)for(let y of h)r.has(y)||i.push(y)}let s=e.filter(f=>r.has(f.id));if(s.length===0)return e;let a=hh(t),l=s.filter(f=>f.type!=="ANNOTATION"),c=(0,Er.getNodesBounds)(l.length>0?l:s),d=s.filter(f=>!Pd(f,c,a)),u=(0,Er.getNodesBounds)(d),g=e.filter(f=>!r.has(f.id)).filter(f=>{let h=(0,Er.getNodesBounds)([f]);return!mh(u,h)}).filter(f=>!Pd(f,u,a));return[...d,...g]};var _r=1,Dd=e=>`<mxGraphModel>
5
+ `).trim();t&&v.length>t&&(v=v.substring(0,t)),b.currentTarget.innerText=v,a==null||a(),v!==e&&(s==null||s(v))};return(0,Us.jsx)("div",{className:H("flex-1 p-2 self-stretch flex items-center justify-center border border-transparent overflow-hidden text-ellipsis body-medium-400 text-center rounded-sm",{"border border-dashed border-grey-400 bg-white shadow-md":m,"bg-white":e.length>0},n),style:o,onDoubleClick:p,children:(0,Us.jsx)("div",{ref:u,className:H("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":m}),contentEditable:m,suppressContentEditableWarning:!0,onKeyDown:g,onPaste:y,onInput:x,onBlur:N,children:e})})};var Yg=require("@xyflow/react");var _e=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,Rn=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),Oi=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),Wg=(e,t,o)=>{let n=o.x-t.x,r=o.y-t.y,i=n*n+r*r;if(i===0)return Rn(e,t);let s=Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*r)/i));return Rn(e,{x:t.x+s*n,y:t.y+s*r})},cd=(e,t)=>{let o=1/0;for(let n=0;n<t.length-1;n++)o=Math.min(o,Wg(e,t[n],t[n+1]));return o};var gr=require("@xyflow/react");var Mo={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15,MAX_LABEL_DISTANCE:80};var{TOLERANCE:ce}=Mo;function Fg(e,t,o){return _e(e,t,"x",ce)&&_e(t,o,"x",ce)&&_e(e,o,"x",ce)}function Xg(e,t,o){return _e(e,t,"y",ce)&&_e(t,o,"y",ce)&&_e(e,o,"y",ce)}function Ug(e,t,o){if(!Fg(e,t,o))return!1;let n=t.y-e.y,r=o.y-t.y;return Math.abs(n)<ce||Math.abs(r)<ce?!1:n*r<0}function $g(e,t,o){if(!Xg(e,t,o))return!1;let n=t.x-e.x,r=o.x-t.x;return Math.abs(n)<ce||Math.abs(r)<ce?!1:n*r<0}function Kg(e,t,o,n){let r=t.x!==0,i=t.x===-n.x&&t.y===-n.y,s=t.x===n.x&&t.y===n.y,a=120;if(i)if(r){if((o.x-e.x)*t.x>=0)return[{x:(e.x+o.x)/2,y:e.y},{x:(e.x+o.x)/2,y:o.y}];{let l=(e.y+o.y)/2,c=Math.abs(e.y-o.y)<a?Math.max(e.y,o.y)+a:l;return[{x:e.x,y:c},{x:o.x,y:c}]}}else{if((o.y-e.y)*t.y>=0)return[{x:e.x,y:(e.y+o.y)/2},{x:o.x,y:(e.y+o.y)/2}];{let l=(e.x+o.x)/2,c=Math.abs(e.x-o.x)<a?Math.max(e.x,o.x)+a:l;return[{x:c,y:e.y},{x:c,y:o.y}]}}else if(s)if(r)if((o.x-e.x)*t.x>0&&Math.abs(e.y-o.y)<a){let l=Math.max(e.y,o.y)+a,c=o.x+t.x*(a/2);return[{x:e.x,y:l},{x:c,y:l},{x:c,y:o.y}]}else{let l=t.x>0?Math.max(e.x,o.x):Math.min(e.x,o.x);return[{x:l,y:e.y},{x:l,y:o.y}]}else if((o.y-e.y)*t.y>0&&Math.abs(e.x-o.x)<a){let l=Math.max(e.x,o.x)+a,c=o.y+t.y*(a/2);return[{x:l,y:e.y},{x:l,y:c},{x:o.x,y:c}]}else{let l=t.y>0?Math.max(e.y,o.y):Math.min(e.y,o.y);return[{x:e.x,y:l},{x:o.x,y:l}]}else{let l=t.x!==0?o.x:e.x,c=t.y!==0?o.y:e.y,d=t.x!==0?(l-e.x)*t.x:(c-e.y)*t.y,u=n.x!==0?(l-o.x)*n.x:(c-o.y)*n.y;return d>=0&&u>=0?[{x:l,y:c}]:r?[{x:e.x,y:o.y}]:[{x:o.x,y:e.y}]}}function dd(e){if(e.length<=2)return e;let t=[e[0]];for(let o=1;o<e.length-1;o++){let n=t[t.length-1],r=e[o],i=e[o+1];_e(n,r,"x",ce)&&_e(r,i,"x",ce)||_e(n,r,"y",ce)&&_e(r,i,"y",ce)||t.push(r)}return t.push(e[e.length-1]),t}function Vi(e){let t=[];for(let o of e){let n=t[t.length-1];(!n||Math.abs(n.x-o.x)>=ce||Math.abs(n.y-o.y)>=ce)&&t.push(o)}return t}function qg(e){let t=[...e],o=!0;for(;o;){o=!1;for(let n=1;n<t.length-1;n++){let r=t[n-1],i=t[n],s=t[n+1];if(Ug(r,i,s)||$g(r,i,s)){t.splice(n,1),o=!0;break}}}return t}function ud(e){let t=Vi(dd([...e]));return t=qg(t),Vi(dd(t))}function Hi(e){switch(e){case gr.Position.Left:return{x:-1,y:0};case gr.Position.Right:return{x:1,y:0};case gr.Position.Top:return{x:0,y:-1};case gr.Position.Bottom:return{x:0,y:1};default:return{x:0,y:0}}}function pd(e,t,o,n){let r=Mo.OFFSET,i=Mo.OFFSET;if(t.x===-n.x&&t.y===-n.y)if(t.x!==0){let s=(o.x-e.x)*t.x;s>0&&s<2*Mo.OFFSET&&(r=s/2,i=s/2)}else{let s=(o.y-e.y)*t.y;s>0&&s<2*Mo.OFFSET&&(r=s/2,i=s/2)}return{sourceOffset:r,targetOffset:i}}function Zg(e,t,o,n,r,i,s=0){let a=Hi(r),l=Hi(i),c=a.x===0?s:0,d=a.y===0?s:0,u=l.x===0?s:0,f=l.y===0?s:0,m={x:e+c,y:t+d},h={x:o+u,y:n+f},{sourceOffset:E,targetOffset:p}=pd(m,a,h,l),g={x:m.x+a.x*E,y:m.y+a.y*E},y={x:h.x+l.x*p,y:h.y+l.y*p},x=Kg(g,a,y,l),N=[m,g,...x,y,h],b=ud(N);if(b.length===2&&Gi(m,h)>ce){let v=_e(m,g,"x",ce)&&_e(g,y,"x",ce)&&_e(y,h,"x",ce),T=_e(m,g,"y",ce)&&_e(g,y,"y",ce)&&_e(y,h,"y",ce);if(v||T){let I=T&&(y.x-g.x)*a.x<0,S=v&&(y.y-g.y)*a.y<0;if(!I&&!S)return Vi([m,g,y,h])}}return b}function Bi(e,t,o,n,r,i,s,a=0){if(!(s!=null&&s.length))return Zg(e,t,o,n,r,i,a);let l=Hi(r),c=Hi(i),d=l.x===0?a:0,u=l.y===0?a:0,f=c.x===0?a:0,m=c.y===0?a:0,h={x:e+d,y:t+u},E={x:o+f,y:n+m},{sourceOffset:p,targetOffset:g}=pd(h,l,E,c),y={x:h.x+l.x*p,y:h.y+l.y*p},x={x:E.x+c.x*g,y:E.y+c.y*g},N=[...s],b=N[0],v=l.y===0;v&&Math.abs(h.y-b.y)>ce?N.unshift({x:b.x,y:h.y}):!v&&Math.abs(h.x-b.x)>ce&&N.unshift({x:h.x,y:b.y});let T=N[N.length-1],I=c.y===0,S=[];(Math.abs(T.x-x.x)>ce||Math.abs(T.y-x.y)>ce)&&(I?S.push({x:x.x,y:T.y}):S.push({x:T.x,y:x.y})),S.push(x);let P=[h,...N,...S,E],R=ud(P);if(R.length===2&&Gi(h,E)>ce){let C=_e(h,y,"x",ce)&&_e(y,x,"x",ce)&&_e(x,E,"x",ce),L=_e(h,y,"y",ce)&&_e(y,x,"y",ce)&&_e(x,E,"y",ce);if(C||L){let K=L&&(x.x-y.x)*l.x<0,Q=C&&(x.y-y.y)*l.y<0;if(!K&&!Q)return Vi([h,y,x,E])}}return R}var Gi=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Jg(e,t,o){return _e(e,t,"x",ce)&&_e(t,o,"x",ce)||_e(e,t,"y",ce)&&_e(t,o,"y",ce)}function Qg(e,t,o,n){if(Jg(e,t,o))return`L${t.x} ${t.y}`;let r=Gi(e,t),i=Gi(t,o),s=Math.min(r/2,i/2,n);if(s<1)return`L${t.x} ${t.y}`;let a=e.x-t.x,l=e.y-t.y,c=o.x-t.x,d=o.y-t.y,u={x:a/r,y:l/r},f={x:c/i,y:d/i},m={x:t.x+u.x*s,y:t.y+u.y*s},h={x:t.x+f.x*s,y:t.y+f.y*s},E=-u.x,p=-u.y,g=f.x,y=f.y,N=E*y-p*g>0?1:0;return`L${m.x} ${m.y}A${s} ${s} 0 0 ${N} ${h.x} ${h.y}`}var fd=(e,t=5)=>e.length<2?"":e.reduce((o,n,r)=>{let i="";return r>0&&r<e.length-1?i=Qg(e[r-1],n,e[r+1],t):i=`${r===0?"M":"L"}${n.x} ${n.y}`,o+=i,o},"");var Ce=require("react"),zi=require("@xyflow/react");var jg=50,md=.1,eh=.6,Yi=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:s,getNodes:a,getEdge:l,screenToFlowPosition:c}=(0,zi.useReactFlow)(),{setIsDragging:d,setReconnectingEdgeId:u}=q(),f=(0,zi.useStore)(D=>D.isValidConnection),[m,h]=(0,Ce.useState)(null),[E,p]=(0,Ce.useState)(null),[g,y]=(0,Ce.useState)(null),[x,N]=(0,Ce.useState)(null),[b,v]=(0,Ce.useState)(null),[T,I]=(0,Ce.useState)(!1),S=(0,Ce.useRef)(null),P=(0,Ce.useRef)(null),R=(0,Ce.useRef)(null),C=(0,Ce.useRef)(t),L=(0,Ce.useRef)(o);(0,Ce.useEffect)(()=>{C.current=t,L.current=o},[t,o]),(0,Ce.useEffect)(()=>{S.current=m},[m]),(0,Ce.useEffect)(()=>{P.current=b},[b]);let K=(0,Ce.useCallback)(D=>{let A=a(),B=A.find(Y=>Y.id===D);if(!B)return{x:0,y:0};let G=B.position.x,k=B.position.y,O=B.parentId;for(;O;){let Y=A.find(W=>W.id===O);if(!Y)break;G+=Y.position.x,k+=Y.position.y,O=Y.parentId}return{x:G,y:k}},[a]),Q=(0,Ce.useCallback)(D=>{var O,Y,W,U,X,$;let A=a(),B=null,G=jg,k=A.filter(te=>te.type!=="LANE"&&te.type!=="ANNOTATION");for(let te of k){if(te.id===e)continue;let ie=K(te.id),F=(W=(Y=(O=te.measured)==null?void 0:O.width)!=null?Y:te.width)!=null?W:0,oe=($=(X=(U=te.measured)==null?void 0:U.height)!=null?X:te.height)!=null?$:0;if(D.x>=ie.x&&D.x<=ie.x+F&&D.y>=ie.y&&D.y<=ie.y+oe)return te.id;let Z=Math.max(ie.x-D.x,0,D.x-(ie.x+F)),ve=Math.max(ie.y-D.y,0,D.y-(ie.y+oe)),ye=Math.sqrt(Z*Z+ve*ve);ye<G&&(G=ye,B=te.id)}return B},[a,K,e]),j=(0,Ce.useCallback)((D,A)=>{var Z,ve,ye,Ae,J,de;let B=s(D);if(!B)return null;let G=K(D),k=(ye=(ve=(Z=B.measured)==null?void 0:Z.width)!=null?ve:B.width)!=null?ye:0,O=(de=(J=(Ae=B.measured)==null?void 0:Ae.height)!=null?J:B.height)!=null?de:0,Y=Math.abs(G.x+k-A.x),W=Math.abs(A.x-G.x),U=Math.abs(G.y+O-A.y),X=Math.abs(A.y-G.y),$={right:Y,left:W,bottom:U,top:X},te=Object.entries($).reduce((re,[ee,xe])=>xe<re[1]?[ee,xe]:re,["right",$.right])[0],ie=R.current;if(ie&&ie!==te){let re=$[te],ee=$[ie],xe=Math.abs(ee-re),Se=Math.min(Math.abs(ee),Math.abs(re));xe<Se*eh&&(te=ie)}let F=te,oe,le;if(F==="right"||F==="left"){let ee=(Math.max(G.y,Math.min(G.y+O,A.y))-G.y)/(O||1);Math.abs(ee-.5)<md&&(ee=.5),le=ee,oe={x:F==="right"?G.x+k:G.x,y:G.y+le*O}}else{let ee=(Math.max(G.x,Math.min(G.x+k,A.x))-G.x)/(k||1);Math.abs(ee-.5)<md&&(ee=.5),le=ee,oe={x:G.x+le*k,y:F==="bottom"?G.y+O:G.y}}return{side:F,snapPosition:oe,offset:le}},[s,K]),z=(0,Ce.useCallback)(D=>{var W,U,X;let A=S.current;if(!A)return;let B=c({x:D.clientX,y:D.clientY}),G=Q(B);y(G);let k=B,O=null,Y=null;if(G){let $=j(G,B);$&&(O=$.side,k=$.snapPosition,Y=$.offset,R.current=O);let te=l(e),ie={source:A==="source"?G:C.current,target:A==="target"?G:L.current,sourceHandle:A==="source"?O:(W=te==null?void 0:te.sourceHandle)!=null?W:null,targetHandle:A==="target"?O:(U=te==null?void 0:te.targetHandle)!=null?U:null},F=(X=f==null?void 0:f(ie))!=null?X:!0;I(F)}else R.current=null,I(!1);N(O),v(Y),p(k)},[Q,j,l,e,c,f]),M=(0,Ce.useCallback)(D=>{var O,Y,W,U,X;let A=S.current;if(!A)return;let B=c({x:D.clientX,y:D.clientY}),G=Q(B);if(G){let $=j(G,B),te=(O=$==null?void 0:$.side)!=null?O:null,ie=(Y=$==null?void 0:$.offset)!=null?Y:.5,F=l(e),oe={source:A==="source"?G:C.current,target:A==="target"?G:L.current,sourceHandle:A==="source"?te:(W=F==null?void 0:F.sourceHandle)!=null?W:null,targetHandle:A==="target"?te:(U=F==null?void 0:F.targetHandle)!=null?U:null};((X=f==null?void 0:f(oe))==null||X)&&i(le=>le.map(Z=>{var ve,ye;return Z.id===e?w(_({},Z),{source:oe.source,target:oe.target,sourceHandle:oe.sourceHandle,targetHandle:oe.targetHandle,data:w(_({},Z.data),{points:void 0,sourceOffset:A==="source"?ie:(ve=Z.data)==null?void 0:ve.sourceOffset,targetOffset:A==="target"?ie:(ye=Z.data)==null?void 0:ye.targetOffset})}):Z}))}h(null),p(null),y(null),N(null),v(null),d(!1),I(!1),u(null),R.current=null,document.removeEventListener("mouseup",M),document.removeEventListener("mousemove",z);let k=qt.get(n);k==null||k.clearReconnectingEdge()},[e,Q,j,l,i,n,z,f,c,d,u]),V=(0,Ce.useCallback)((D,A)=>{if(r||A.button!==0)return;A.stopPropagation(),A.preventDefault(),i(G=>G.map(k=>k.id===e?w(_({},k),{data:w(_({},k.data),{points:void 0})}):k)),h(D),u(e);let B=qt.get(n);B==null||B.setReconnectingEdge(e),document.addEventListener("mousemove",z),document.addEventListener("mouseup",M)},[r,e,n,z,M,u,i]);return(0,Ce.useEffect)(()=>()=>{if(S.current){document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",M),u(null);let D=qt.get(n);D==null||D.clearReconnectingEdge()}},[n,z,M,u]),{reconnectingHandle:m,cursorPosition:E,hoveredNodeId:g,reconnectingSide:x,reconnectingOffset:b,isValidReconnection:T,handleReconnectStart:V}};var ge=require("react/jsx-runtime"),Mt={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:Me.MarkerType.ArrowClosed},markerEnd:{type:Me.MarkerType.Arrow},data:{label:""}},{MOVE_THRESHOLD:Wi,MIN_SEGMENT_LENGTH:th,PARALLEL_OFFSET:gd,MAX_LABEL_DISTANCE:oh}=Mo;function nh(e,t,o,n,r){let i=r.find(d=>d.id===t),s=r.find(d=>d.id===o);if((i==null?void 0:i.type)==="GATEWAY"||(s==null?void 0:s.type)==="GATEWAY")return 0;let a=n.filter(d=>d.source===t&&d.target===o||d.source===o&&d.target===t);if(a.length<=1){let d=n.filter(m=>m.source===t);if(d.length<=1)return 0;let u=d.findIndex(m=>m.id===e);if(u<=0)return 0;let f=(d.length-1)/2;return(u-f)*gd}let l=a.findIndex(d=>d.id===e),c=(a.length-1)/2;return(l-c)*gd}var hd=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:s,sourceHandleId:a,targetHandleId:l})=>{var $,te,ie,F,oe,le,Z,ve,ye,Ae;let{zoom:c}=(0,Me.useViewport)(),{updateEdgeData:d}=(0,Me.useReactFlow)(),u=(0,Me.useEdges)(),f=(0,Me.useNodes)(),{isMultipleSelection:m,isReadOnly:h,mode:E,instanceId:p,edgeHighlight:g}=q(),[y,x]=(0,je.useState)(!1),[N,b]=(0,je.useState)(null),v=(0,je.useRef)(null),T=(0,je.useRef)(n==null?void 0:n.labelOffset),I=(0,je.useRef)(null),S=E!=="edit",{reconnectingHandle:P,cursorPosition:R,hoveredNodeId:C,reconnectingSide:L,isValidReconnection:K,handleReconnectStart:Q}=Yi({edgeId:e,source:t,target:o,instanceId:p,isReadOnly:S}),j=(0,Me.useInternalNode)(t),z=(0,Me.useInternalNode)(o),{sx:M,sy:V,tx:D,ty:A,sourcePos:B,targetPos:G}=(0,je.useMemo)(()=>{var Bt,zt;let J=j&&z?Tn(j,z):{sx:0,sy:0,tx:0,ty:0,sourcePos:Me.Position.Right,targetPos:Me.Position.Left},de=a?i:J.sourcePos,re=l?s:J.targetPos,ee=(dt,Ee,he)=>{var nt,Yt,yo,ro,io,ga;let{x:pe,y:De}=dt.internals.positionAbsolute,ut=(yo=(Yt=(nt=dt.measured)==null?void 0:nt.width)!=null?Yt:dt.width)!=null?yo:0,wt=(ga=(io=(ro=dt.measured)==null?void 0:ro.height)!=null?io:dt.height)!=null?ga:0;switch(Ee){case Me.Position.Top:return{x:pe+ut*he,y:De};case Me.Position.Bottom:return{x:pe+ut*he,y:De+wt};case Me.Position.Left:return{x:pe,y:De+wt*he};case Me.Position.Right:return{x:pe+ut,y:De+wt*he};default:return{x:pe+ut/2,y:De+wt/2}}},xe=(Bt=n==null?void 0:n.sourceOffset)!=null?Bt:.5,Se=(zt=n==null?void 0:n.targetOffset)!=null?zt:.5,Re=j?ee(j,de,xe).x:J.sx,Ze=j?ee(j,de,xe).y:J.sy,Nt=z?ee(z,re,Se).x:J.tx,no=z?ee(z,re,Se).y:J.ty;return P==="source"&&R?(Re=R.x,Ze=R.y,L&&(de=L)):P==="target"&&R&&(Nt=R.x,no=R.y,L&&(re=L)),{sx:Re,sy:Ze,tx:Nt,ty:no,sourcePos:de,targetPos:re}},[j,z,a,l,i,s,P,R,L,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);(0,je.useEffect)(()=>{var re;if(!I.current){I.current={sx:M,sy:V,tx:D,ty:A,sourcePos:B,targetPos:G};return}let J=I.current;if(Math.abs(M-J.sx)>Wi||Math.abs(V-J.sy)>Wi||Math.abs(D-J.tx)>Wi||Math.abs(A-J.ty)>Wi||J.sourcePos!==B||J.targetPos!==G){let ee={};(re=n==null?void 0:n.points)!=null&&re.length&&(ee.points=void 0),n!=null&&n.labelOffset&&(ee.labelOffset=void 0),Object.keys(ee).length>0&&d(e,_(_({},n),ee))}I.current={sx:M,sy:V,tx:D,ty:A,sourcePos:B,targetPos:G}},[M,V,D,A,B,G,n,e,d,P]);let k=(0,je.useMemo)(()=>{let J=nh(e,t,o,u,f);return Bi(M,V,D,A,B,G,n==null?void 0:n.points,J)},[M,V,D,A,B,G,n==null?void 0:n.points,u,f,e,t,o]),O=(0,je.useMemo)(()=>{if(k.length<2)return Oi({x:M,y:V},{x:D,y:A});let J=0;for(let ee=0;ee<k.length-1;ee++)J+=Rn(k[ee],k[ee+1]);let de=J/2,re=0;for(let ee=0;ee<k.length-1;ee++){let xe=Rn(k[ee],k[ee+1]);if(re+xe>=de){let Se=(de-re)/xe,Re=k[ee],Ze=k[ee+1];return{x:Re.x+(Ze.x-Re.x)*Se,y:Re.y+(Ze.y-Re.y)*Se}}re+=xe}return Oi({x:M,y:V},{x:D,y:A})},[k,M,V,D,A]),Y=(0,je.useCallback)((J,de)=>{if(E!=="edit"||de.button!==0)return;de.stopPropagation(),de.preventDefault();let re=k[J],ee=k[J+1],xe=_e(re,ee,"y"),Se=xe?re.y:re.x,Re=[...k],Ze=Re.length,Nt=J,no=J+1;b(J);let Bt=dt=>{let Ee=Se+(xe?dt.clientY-de.clientY:dt.clientX-de.clientX)/c;v.current=xe?{x:(re.x+ee.x)/2,y:Ee}:{x:Ee,y:(re.y+ee.y)/2};let he=[];for(let pe=1;pe<Ze-1;pe++){let De=Re[pe];pe===Nt||pe===no?xe?he.push({x:De.x,y:Ee}):he.push({x:Ee,y:De.y}):he.push(_({},De))}d(e,w(_({},n),{points:he}))},zt=()=>{b(null),v.current=null,document.removeEventListener("mousemove",Bt),document.removeEventListener("mouseup",zt)};document.addEventListener("mousemove",Bt),document.addEventListener("mouseup",zt)},[E,k,c,n,e,d]),W=(0,je.useCallback)(J=>{var Bt,zt,dt,Ee,he;if(y||S||J.button!==0||!((Bt=n==null?void 0:n.label)!=null&&Bt.trim()))return;J.stopPropagation(),J.preventDefault();let de=J.clientX,re=J.clientY,ee=(dt=(zt=n==null?void 0:n.labelOffset)==null?void 0:zt.x)!=null?dt:0,xe=(he=(Ee=n==null?void 0:n.labelOffset)==null?void 0:Ee.y)!=null?he:0,Se=[...k],Re={x:O.x,y:O.y},Ze=!1,Nt=pe=>{let De=(pe.clientX-de)/c,ut=(pe.clientY-re)/c;if(!Ze&&Math.abs(De)<3&&Math.abs(ut)<3)return;Ze=!0;let wt={x:ee+De,y:xe+ut};T.current=wt,d(e,w(_({},n),{labelOffset:wt}))},no=()=>{document.removeEventListener("mousemove",Nt),document.removeEventListener("mouseup",no);let pe=T.current;if(!pe)return;let De={x:Re.x+pe.x,y:Re.y+pe.y};cd(De,Se)>oh&&(T.current=void 0,d(e,w(_({},n),{labelOffset:void 0})))};document.addEventListener("mousemove",Nt),document.addEventListener("mouseup",no)},[y,S,c,n,e,d,k,O]);if(!j||!z)return null;let U=fd(k),X=g&&(r||j.selected||z.selected);return(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsxs)("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":X}),onDoubleClick:()=>!S&&x(!0),children:[(0,ge.jsx)("path",{d:U,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),className:H({"nopan nodrag":!y&&!S&&!!(($=n==null?void 0:n.label)!=null&&$.trim())}),style:{pointerEvents:"stroke",cursor:!y&&!S&&((te=n==null?void 0:n.label)!=null&&te.trim())?"move":"pointer"},onMouseDown:W}),(0,ge.jsxs)("g",{className:H("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!h,"text-blue-500 group-hover:text-blue-600":X}),children:[(0,ge.jsx)(Me.BaseEdge,{id:e,path:U,interactionWidth:0,markerEnd:`url(#${X?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75",{"group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]":!h,"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||P&&C&&!K,"stroke-green-500":P&&C&&K,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":X&&!(n!=null&&n.hasError)&&!P})}),r&&!m&&!S&&(0,ge.jsx)("g",{children:k.slice(0,-1).map((J,de)=>{let re=k[de+1];if(de===0||de===k.length-2||Rn(J,re)<th)return null;let ee=_e(J,re,"y"),xe=N===de,Se=xe&&v.current?v.current:Oi(J,re);return(0,ge.jsxs)("g",{children:[(0,ge.jsx)("line",{x1:J.x,y1:J.y,x2:re.x,y2:re.y,stroke:"transparent",strokeWidth:20/c,className:H("cursor-pointer",{"cursor-ns-resize":ee,"cursor-ew-resize":!ee}),onMouseDown:Re=>Y(de,Re)}),(0,ge.jsx)("circle",{cx:Se.x,cy:Se.y,r:4/c,fill:xe?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ge.jsx)("circle",{cx:Se.x,cy:Se.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:xe?.6:.3,className:"pointer-events-none"})]},de)})})]})]}),(0,ge.jsxs)(Me.EdgeLabelRenderer,{children:[(0,ge.jsx)("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${O.x}px, ${O.y}px)`},children:r&&!m&&(0,ge.jsx)(Ln,{sx:M,sy:V,tx:D,ty:A,hasLabel:!!((ie=n==null?void 0:n.label)!=null&&ie.trim()),children:(0,ge.jsx)(Pn,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:j,targetNode:z})})}),(y||((F=n==null?void 0:n.label)==null?void 0:F.trim()))&&(0,ge.jsx)("div",{className:H("absolute nodrag nopan",!y&&!S&&((oe=n==null?void 0:n.label)!=null&&oe.trim())?"z-[10001] pointer-events-auto":"z-[3000] pointer-events-none"),style:{transform:`translate(-50%, -50%) translate(${O.x+((Z=(le=n==null?void 0:n.labelOffset)==null?void 0:le.x)!=null?Z:0)}px, ${O.y+((ye=(ve=n==null?void 0:n.labelOffset)==null?void 0:ve.y)!=null?ye:0)}px)`,cursor:!y&&!S&&((Ae=n==null?void 0:n.label)!=null&&Ae.trim())?"move":void 0},onMouseDown:!y&&!S?W:void 0,onDoubleClick:J=>{S||(J.stopPropagation(),x(!0))},children:(0,ge.jsx)(Qe,{value:n==null?void 0:n.label,className:H("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":y,"pointer-events-none":!y}),isEditing:y,onBlur:()=>x(!1),onChange:J=>d(e,{label:J.trim()})})}),r&&!m&&!S&&(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsx)("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${k[0].x}px, ${k[0].y}px)`},children:(0,ge.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:P==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:P==="source"?.6:.3,className:"pointer-events-none"}),(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!P||P!=="source","cursor-not-allowed":P==="source"&&C&&!K,"cursor-grabbing":P==="source"&&(!C||K)}),onMouseDown:J=>Q("source",J.nativeEvent)})]})}),(0,ge.jsx)("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${k[k.length-1].x}px, ${k[k.length-1].y}px)`},children:(0,ge.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:P==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:P==="target"?.6:.3,className:"pointer-events-none"}),(0,ge.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!P||P!=="target","cursor-not-allowed":P==="target"&&C&&!K,"cursor-grabbing":P==="target"&&(!C||K)}),onMouseDown:J=>Q("target",J.nativeEvent)})]})})]})]})]})};var Zt=require("@xyflow/react"),rh={right:Zt.Position.Right,left:Zt.Position.Left,top:Zt.Position.Top,bottom:Zt.Position.Bottom},Fi=e=>{var t;return(t=rh[e!=null?e:""])!=null?t:Zt.Position.Right},$s=(e,t,o=.5)=>{var l,c,d,u;let{x:n,y:r}=e.internals.positionAbsolute,i=(c=(l=e.measured)==null?void 0:l.width)!=null?c:0,s=(u=(d=e.measured)==null?void 0:d.height)!=null?u:0;switch(Fi(t)){case Zt.Position.Right:return{x:n+i,y:r+s*o};case Zt.Position.Left:return{x:n,y:r+s*o};case Zt.Position.Top:return{x:n+i*o,y:r};case Zt.Position.Bottom:return{x:n+i*o,y:r+s};default:return{x:n+i/2,y:r+s/2}}},yd=(e,t,o)=>{var d,u;let{position:{x:n,y:r},measured:i}=e,s=(d=i.width)!=null?d:0,a=(u=i.height)!=null?u:0;return[{id:"left",x:n,y:r+a/2},{id:"right",x:n+s,y:r+a/2},{id:"top",x:n+s/2,y:r},{id:"bottom",x:n+s/2,y:r+a}].reduce((f,m)=>{let h=Math.hypot(t-f.x,o-f.y);return Math.hypot(t-m.x,o-m.y)<h?m:f}).id};var Iu=require("use-debounce");var wu=require("@xyflow/react"),sa=require("react");var hr=(u=>(u.START_EVENT="start-event",u.END_EVENT_TERMINATE="end-event-terminate",u.TASK="task",u.TASK_SCRIPT="task-script",u.SUBPROCESS="subprocess-collapsed",u.GATEWAY_EXCLUSIVE="gateway-exclusive",u.GATEWAY_PARALLEL="gateway-parallel",u.GATEWAY_COMPLEX="gateway-complex",u.SERVICE_TASK="service-task",u.ANNOTATION="annotation",u.LANE="lane",u))(hr||{});var yr=1,xd=e=>`<mxGraphModel>
7
6
  <root version="1.1">
8
7
  <mxCell id="0" />
9
8
  <mxCell id="1" parent="0" />
@@ -36,11 +35,12 @@
36
35
  <mxGeometry as="geometry" relative="1" />
37
36
  </mxCell>
38
37
  </root>
39
- </mxGraphModel>`,Od=(e,t)=>{if(!e.length&&!t.length)return _r;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var yh=e=>{let t=Object.values(xr),o=e.filter(i=>{var a;let s=(a=i._attributes)==null?void 0:a.style;return t.includes(s)}),n=e.filter(i=>{var a;let s=(a=i._attributes)==null?void 0:a.style;return["attribute-loop"].includes(s)}),r=[];for(let i of o){let{style:s}=i._attributes,a=Id[s],l=a==null?void 0:a(i,n);if(!l){console.warn(`Node ${s} not supported`);continue}r.push(l)}return r},xh=(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=Ad(r),s=t.find(c=>c.id===i.source),a=t.find(c=>c.id===i.target);((s==null?void 0:s.type)==="LANE"||(a==null?void 0:a.type)==="LANE")&&i.type!=="ANNOTATION_EDGE"||n.push(i)}return n},Eh=(e,t)=>{let o=[];return e.forEach(n=>{var s,a;let r=(a=(s=Cd)[n.type])==null?void 0:a.call(s,n);if(!r){console.warn(`Node ${n.type} not supported`);return}if(o.push(r),n.type==="TASK"&&n.data.attribute==="LOOP"){let l=Md(n,t);o.push(l)}}),o},_h=(e,t)=>{let o=[];return e.forEach(n=>{let r=Sd(n,t);o.push(r)}),o},bh=(e=[],t=[],o)=>{let n=Eh(e,o),r=_h(t,e);return{mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}}},Vd=(e=[],t=[],o)=>{let n=bh(e,t,o);return _d(JSON.stringify(n),{compact:!0,spaces:0})},Hd=async e=>{var c,d,u,p,m;let t=await Ki(e),o=((d=(c=t==null?void 0:t.mxGraphModel)==null?void 0:c.root)==null?void 0:d.mxCell)||[],n=Number(((m=(p=(u=t==null?void 0:t.mxGraphModel)==null?void 0:u.root)==null?void 0:p._attributes)==null?void 0:m.lastId)||_r),r=yh(o),i=xh(o,r),s=kd(r),{nodes:a,edges:l}=za(s,i);return{lastElementId:n,edges:l,nodes:zo(a)}};var gt=require("@xyflow/react"),ts=require("react");var br=require("@xyflow/react");var Qs=require("react/jsx-runtime"),ne=i=>{var s=i,{type:e,position:t,className:o,nodeType:n}=s,r=Wt(s,["type","position","className","nodeType"]);let a=n==="TASK";return(0,Qs.jsx)(br.Handle,_({type:e,position:t,className:H("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":a,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":!a},o)},r))},tt=a=>{var l=a,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,s=Wt(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=(0,br.useReactFlow)(),p=(()=>{if(n!=="source")return!1;let m=c();if(t==="TASK")return m.filter(x=>x.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return m.filter(x=>x.source===e).length>=2;if(t==="START_EVENT"){let g=d();return m.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,Qs.jsx)(br.Handle,_({type:n,position:r,className:H("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":p,"hover:border-grey-500":!p},i),style:{pointerEvents:p?"none":"auto"}},s))};var js=require("react"),po=require("@xyflow/react");var Gd=require("@xyflow/react"),Zi=()=>{let e=(0,Gd.useStoreApi)();return{getInternalNodes:()=>{let{nodeLookup:o}=e.getState();return Array.from(o.values())}}};var Ji=require("react/jsx-runtime"),ea=require("react"),Th=["top","right","bottom","left"],vh=["top-left","top-middle","top-right","right-middle","bottom-left","left-middle","bottom-right","bottom-middle"],Pt=r=>{var i=r,{nodeId:e,isVisible:t,offset:o=8}=i,n=Wt(i,["nodeId","isVisible","offset"]);let{getInternalNode:s,setNodes:a}=(0,po.useReactFlow)(),{getInternalNodes:l}=Zi(),{isMultipleSelection:c}=q(),d=(0,po.useStoreApi)(),u=(0,js.useRef)(0),p=(0,js.useRef)([]),m=({y:h,width:y,height:E})=>{cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{var Q,j;if(!e)return;let{nodeLookup:N,onNodesChange:b}=d.getState(),v=N.get(e);if(!v||v.type!=="LANE")return;let T=!v.parentId,I=T?v.id:v.parentId;if(!I)return;let S=Array.from(N.values()).filter(z=>z.type==="LANE"&&z.parentId===I);if(!S.length)return;p.current.length===0&&(p.current=Fo(S).map(z=>z.id));let P=p.current.map(z=>S.find(M=>M.id===z)).filter(Boolean),R=[],C=0,L=P.findIndex(z=>z.id===v.id),K=!T&&L>0&&Math.abs(h-v.position.y)>.5;for(let z=0;z<P.length;z++){let M=P[z],V=M.id===v.id,D=z===P.length-1;if(V){C=K?h+E:C+E;continue}let A=(j=(Q=M.measured)==null?void 0:Q.height)!=null?j:0,B=T?y-ae.HEADER_WIDTH:y,G=A;T&&D&&(G=Math.max(ae.MIN_HEIGHT,E-C)),K&&z===L-1&&(G=Math.max(ae.MIN_HEIGHT,h-C)),R.push({id:M.id,type:"dimensions",dimensions:{width:B,height:G},setAttributes:!0}),R.push({id:M.id,type:"position",position:{x:ae.HEADER_WIDTH,y:C}}),C+=G}T?R.push({id:I,type:"dimensions",dimensions:{width:y,height:E},setAttributes:!0}):R.push({id:I,type:"dimensions",dimensions:{width:y+ae.HEADER_WIDTH,height:C},setAttributes:!0}),b==null||b(R)})},g=({y:h,width:y,height:E})=>{var v;if(cancelAnimationFrame(u.current),p.current=[],!e)return;let N=s(e);if(!N||N.type!=="LANE"&&!N.parentId)return;let b=[...l()];if(N.type!=="LANE"){b=b.map(T=>T.id===e?w(_({},T),{width:y,height:E,measured:{width:y,height:E}}):T),b=uo(b),a(b);return}b=Xa(N,y,E,b,h),b=uo(b),b=Wo((v=N.parentId)!=null?v:N.id,b),a(b)};if(!(!c&&t))return null;let f={"--resize-offset":`${o}px`};return(0,Ji.jsxs)(Ji.Fragment,{children:[Th.map(h=>(0,ea.createElement)(po.NodeResizeControl,w(_({},n),{key:h,nodeId:e,position:h,variant:po.ResizeControlVariant.Line,className:"border-blue-400/90 border-dashed",style:f,onResize:(y,E)=>m(E),onResizeEnd:(y,E)=>g(E)}))),vh.map(h=>(0,ea.createElement)(po.NodeResizeControl,w(_({},n),{key:h,nodeId:e,position:h,className:"size-1.5 bg-blue-400 relative before:content-[''] before:absolute before:w-5 before:h-5 before:left-1/2 before:top-1/2 before:-translate-x-1/2 before:-translate-y-1/2 before:cursor-[inherit]",style:f,onResize:(y,E)=>m(E),onResizeEnd:(y,E)=>g(E)})))]})};var es=require("@xyflow/react"),Jt=require("@produto-lecom/lecom-ui"),mt=require("react");var Bd=require("zustand"),Hn=(0,Bd.create)(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));var Qi=require("react"),zd=(e,t=!1)=>{let[o,n]=(0,Qi.useState)({width:0,height:0});return(0,Qi.useEffect)(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};var Lo=require("@xyflow/react"),Yd=require("react"),Nh=120,wh=12,Wd=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=(0,Lo.useReactFlow)(),{instanceId:i}=q();return(0,Yd.useMemo)(()=>{var m,g;if(!t)return{position:Lo.Position.Right,align:"start"};let s=n(e);if(!s)return{position:Lo.Position.Right,align:"start"};let a=r(),l=s.position.x*a.zoom+a.x,c=(((m=s.measured)==null?void 0:m.width)||s.width||100)*a.zoom,d=(g=document.getElementById(`modeler-${i}`))==null?void 0:g.clientWidth;if(!d)return{position:Lo.Position.Right,align:"start"};let u=(o==null?void 0:o.width)||Nh;return{position:l+c+u+wh>d?Lo.Position.Left:Lo.Position.Right}},[i,e,t,o,n,r])};var ta=require("lucide-react");var ji=require("@xyflow/react"),be=require("@produto-lecom/lecom-ui"),Fd=require("lucide-react");var Pe=require("react/jsx-runtime"),Xd=({nodeId:e})=>{let{t}=(0,be.useTranslation)(),{updateNodeData:o,getEdges:n,getNode:r}=(0,ji.useReactFlow)(),i=(0,ji.useNodesData)(e),a=n().filter(g=>g.source===e).some(g=>{let x=r(g.target);return(x==null?void 0:x.type)==="END_EVENT"}),l=(i==null?void 0:i.data.variant)==="SUBPROCESS",c=(i==null?void 0:i.data.variant)==="SERVICE_TASK",d=p=>{o(e,{variant:(i==null?void 0:i.data.variant)===p?"":p})},u=p=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===p?"":p})};return(0,Pe.jsxs)(be.DropdownMenu,{children:[(0,Pe.jsxs)(be.Tooltip,{children:[(0,Pe.jsx)(be.TooltipTrigger,{asChild:!0,children:(0,Pe.jsx)(be.DropdownMenuTrigger,{asChild:!0,children:(0,Pe.jsx)(be.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:(0,Pe.jsx)(Fd.WrenchIcon,{})})})}),(0,Pe.jsx)(be.TooltipContent,{color:"black",children:t("bpmn.task.menu.title")})]}),(0,Pe.jsxs)(be.DropdownMenuContent,{align:"start",className:"w-60 bg-white text-grey-600",children:[(0,Pe.jsxs)(be.DropdownMenuLabel,{className:"flex items-center gap-1",children:[(0,Pe.jsx)("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),(0,Pe.jsx)("div",{className:"flex items-center gap-1",children:Object.entries(Kr).map(([p,m])=>{let g=p==="LOOP"&&(a||l||c),f=(()=>{if(p==="LOOP"&&a)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"&&c)return t("editor.task_menu.loop_not_allowed_when_service_task");if(p==="LOOP")return t("editor.task_menu.loop")})();return(0,Pe.jsxs)(be.Tooltip,{children:[(0,Pe.jsx)(be.TooltipTrigger,{asChild:!0,children:(0,Pe.jsx)(be.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:g,className:H({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===p,"opacity-50 cursor-not-allowed":g}),onClick:g?void 0:()=>u(p),children:(0,Pe.jsx)(m.icon,{className:"stroke-inherit"})})}),f&&(0,Pe.jsx)(be.TooltipContent,{color:"black",children:f})]},p)})})]}),(0,Pe.jsx)(be.DropdownMenuGroup,{children:(0,Pe.jsxs)(be.Tooltip,{children:[(0,Pe.jsx)(be.TooltipTrigger,{asChild:!0,children:(0,Pe.jsx)("div",{className:H({"cursor-not-allowed":a}),children:(0,Pe.jsxs)(be.DropdownMenuItem,{className:H({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":a}),disabled:a,onClick:()=>d("SCRIPT"),children:[(0,Pe.jsx)($r.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),a&&(0,Pe.jsx)(be.TooltipContent,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};var Oe=require("react/jsx-runtime"),fo={START_EVENT:{type:"START_EVENT",icon:Jn,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:un,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:Jn,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:Wr,label:"bpmn.annotation.variant.default"}},Ih={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:mn,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:hn,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:pn,label:"bpmn.gateway.variant.complex"}},lt=({nodeId:e,nodeType:t,nodeVariant:o,isChild:n})=>{let r=(0,mt.useRef)(null),i=(0,mt.useRef)(null),{t:s}=(0,Jt.useTranslation)(),{setDraggableNode:a}=Hn(),{getEdges:l,getNodes:c,getNode:d,setNodes:u}=(0,es.useReactFlow)(),{setIsDragging:p,mode:m,isConnecting:g,isDragging:x,isMultipleSelection:f}=q(),h=d(e),y=!!(h!=null&&h.selected)&&!h.dragging&&!g&&!x&&!f,{dimensions:E}=zd(r,y),{position:N}=Wd(e,y,E),[b,v]=(0,mt.useState)(void 0),T=c(),I=l(),S=o==="SUBPROCESS",P=o==="SERVICE_TASK",R=(0,mt.useRef)(null),C=(0,mt.useRef)(!1),L=(0,mt.useCallback)(()=>{R.current!==null&&(clearTimeout(R.current),R.current=null),C.current=!1,p(!1),a(null),v(void 0),u(W=>W.map(U=>w(_({},U),{className:void 0})))},[p,a,u]);(0,mt.useEffect)(()=>{let W=U=>{C.current&&U.buttons===0&&L()};return document.addEventListener("dragend",L),document.addEventListener("mousemove",W),()=>{document.removeEventListener("dragend",L),document.removeEventListener("mousemove",W)}},[L]);let K=(0,mt.useCallback)((W,U)=>{C.current=!0,p(!1),a({type:U.type,variant:U.variant,attribute:U.attribute,icon:U.icon}),U.icon&&v((0,Oe.jsx)(U.icon,{})),W.dataTransfer.effectAllowed="move",W.dataTransfer.setData("sourceId",e),i.current&&W.dataTransfer.setDragImage(i.current,10,10),R.current=setTimeout(()=>{R.current=null,p(!0)},100)},[e,a,p]),Q=(0,mt.useCallback)(()=>{L()},[L]),j=[{component:(0,Oe.jsx)(Vi,{elementId:e})}],z=()=>{if(m==="view")return[];let W=!I.some(U=>{var X;return U.source===e&&((X=T.find($=>$.id===U.target))==null?void 0:X.type)!=="ANNOTATION"});return[{component:(0,Oe.jsx)(Cn,{nodeId:e,disabled:!W,tooltipMessage:W?void 0:s("editor.toolbar.start_event_limit_reached")})},fo.TASK,fo.ANNOTATION,...j]},M=()=>m==="view"?[{component:(0,Oe.jsx)(Mo,{elementId:e})}]:[{component:(0,Oe.jsx)(Mo,{elementId:e})},...S||P?[]:[{component:(0,Oe.jsx)(Xd,{nodeId:e})}],{component:(0,Oe.jsx)(Cn,{nodeId:e})},fo.TASK,{type:"TASK",variant:"SUBPROCESS",icon:Qn,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:ta.Bot,label:"bpmn.task.variant.service_task"},fo.ANNOTATION,...Object.values(Ih),...Jo(e,T,I)?[]:[fo.END_EVENT],...j],V=()=>m==="view"?[{component:(0,Oe.jsx)(Mo,{elementId:e,elementType:"gateway"})}]:[{component:(0,Oe.jsx)(Mo,{elementId:e,elementType:"gateway"})},{component:(0,Oe.jsx)(Cn,{nodeId:e})},fo.TASK,{type:"TASK",variant:"SUBPROCESS",icon:Qn,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:ta.Bot,label:"bpmn.task.variant.service_task"},fo.ANNOTATION,...j],D=()=>m==="view"?[]:[fo.ANNOTATION,...j],A=()=>m==="view"?[]:[...n?[]:[{component:(0,Oe.jsx)(Cn,{nodeId:e})}],fo.ANNOTATION,...j],B=()=>m==="view"?[]:[{component:(0,Oe.jsx)(Cn,{nodeId:e})},...j],G=()=>m==="view"?[]:[...j],O=(W=>{switch(W){case"START_EVENT":return z();case"TASK":return M();case"GATEWAY":return V();case"END_EVENT":return D();case"LANE":return A();case"ANNOTATION":return B();case"UNSUPPORTED":return G();default:return[]}})(t),Y=O.length>6;if(!(O.length===0||m==="readonly"))return(0,Oe.jsxs)(es.NodeToolbar,{position:N,align:"start",className:Y?"-top-[4.5rem]":"-top-8",isVisible:y,children:[(0,Oe.jsx)("div",{ref:r,className:`${Y?"grid grid-cols-6":"flex"} gap-1 px-2 py-2 bg-white rounded-sm shadow-md`,children:O.map((W,U)=>{if(W.component)return(0,Oe.jsx)("div",{children:W.component},U);let X={sourceNodeType:t,targetNodeType:W.type,sourceNodeId:e,nodes:T,edges:I},$=Qc(X),te={gateway_limit_reached:s("editor.toolbar.gateway_limit_reached"),start_event_limit_reached:s("editor.toolbar.start_event_limit_reached"),start_event_already_exists:s("editor.toolbar.start_event_already_exists"),script_to_end_not_allowed:s("editor.toolbar.script_to_end_not_allowed"),loop_to_end_not_allowed:s("editor.toolbar.loop_to_end_not_allowed"),initial_activity_to_end_not_allowed:s("editor.toolbar.initial_activity_to_end_not_allowed"),final_activity_cannot_connect:s("editor.toolbar.final_activity_cannot_connect"),activity_has_outgoing_connections:s("editor.toolbar.activity_has_outgoing_connections"),task_limit_reached:s("editor.toolbar.task_limit_reached"),start_event_to_service_task_not_allowed:s("editor.toolbar.start_event_to_service_task_not_allowed"),service_task_to_end_not_allowed:s("editor.toolbar.service_task_to_end_not_allowed")},ie=$.shouldDisable&&$.reason?te[$.reason]||s(W.label):s(W.label)||"";return(0,Oe.jsxs)(Jt.Tooltip,{children:[(0,Oe.jsx)(Jt.TooltipTrigger,{asChild:!0,children:(0,Oe.jsx)(Jt.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!$.shouldDisable,disabled:$.shouldDisable,className:$.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:$.shouldDisable?void 0:F=>K(F,W),onDragEnd:$.shouldDisable?void 0:Q,children:W.icon&&(0,Oe.jsx)(W.icon,{size:16})})}),(0,Oe.jsx)(Jt.TooltipContent,{color:"black",children:ie})]},U)})}),(0,Oe.jsx)("div",{ref:i,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:b})]})};var Ke=require("react/jsx-runtime"),Ud=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r,setNodes:i}=(0,gt.useReactFlow)(),{inProgress:s,fromNode:a}=(0,gt.useConnection)(),{mode:l,isReadOnly:c}=q(),d=s&&(a==null?void 0:a.id)!==e,u=(0,ts.useCallback)(g=>{let E=g.split(`
40
- `),N=E.reduce((I,S)=>Math.max(I,S.length),0),b=E.length,v=Math.max(_n.MIN_WIDTH,N*7+32),T=Math.max(_n.MIN_HEIGHT,b*20+24);i(I=>I.map(S=>S.id===e?w(_({},S),{width:v,height:T,style:w(_({},S.style),{width:v,height:T})}):S))},[e,i]),p=(0,ts.useCallback)(g=>{r(e,{label:g}),u(g)},[e,r,u]),m=(0,ts.useCallback)(g=>{u(g)},[u]);return(0,Ke.jsxs)("div",{className:H("relative w-full h-full min-w-44 min-h-16 flex text-grey-400 hover:text-grey-500 bg-white rounded-sm border-l-2 border-current before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-current after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-current hover:shadow-md transition-colors duration-75",{"pointer-events-none":c,"text-blue-500 hover:text-blue-600 shadow-md":o&&!c,"border-red-500 border-l-[3px] shadow-[0_0_5px_rgba(255,0,0,0.5)] before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-red-500 after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-red-500":t.hasError}),children:[(0,Ke.jsx)(Qe,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:p,onInput:m,skipFirstCharValidation:!0}),(0,Ke.jsx)(lt,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&(0,Ke.jsx)(Pt,{nodeId:e,minWidth:_n.MIN_WIDTH,minHeight:_n.MIN_HEIGHT,isVisible:!n&&o}),!s&&(0,Ke.jsxs)(Ke.Fragment,{children:[(0,Ke.jsx)(ne,{type:"source",position:gt.Position.Left,id:"left"}),(0,Ke.jsx)(ne,{type:"source",position:gt.Position.Right,id:"right"}),(0,Ke.jsx)(ne,{type:"source",position:gt.Position.Top,id:"top"}),(0,Ke.jsx)(ne,{type:"source",position:gt.Position.Bottom,id:"bottom"})]}),(!s||d)&&(0,Ke.jsxs)(Ke.Fragment,{children:[(0,Ke.jsx)(ne,{type:"target",position:gt.Position.Left,id:"left",className:H({"annotation-handle":d})}),(0,Ke.jsx)(ne,{type:"target",position:gt.Position.Right,id:"right",className:H({"annotation-handle":d})}),(0,Ke.jsx)(ne,{type:"target",position:gt.Position.Top,id:"top",className:H({"annotation-handle":d})}),(0,Ke.jsx)(ne,{type:"target",position:gt.Position.Bottom,id:"bottom",className:H({"annotation-handle":d})})]})]})};var ht=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,ht.useReactFlow)(),{inProgress:i,fromNode:s}=(0,ht.useConnection)(),{mode:a,isReadOnly:l,reconnectingEdgeId:c}=q(),[d,u]=(0,$d.useState)(!1),p=i&&(s==null?void 0:s.id)!==e||!!c,m=f=>{r(e,{label:f})},g=()=>{u(!0)},x=()=>{u(!1)};return(0,We.jsxs)("div",{className:"relative",onDoubleClick:g,children:[(0,We.jsx)(un,{className:H("w-full h-full min-w-9 min-h-9 hover:stroke-[#d33b3b] transition-colors duration-75",{"pointer-events-none":l,"stroke-blue-500 hover:stroke-blue-600":o&&!l,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),(0,We.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,We.jsx)(Qe,{value:t.label,isEditing:d,onBlur:x,onChange:m})}),(0,We.jsx)(lt,{nodeId:e,nodeType:"END_EVENT"}),a==="edit"&&(0,We.jsx)(Pt,{nodeId:e,isVisible:!n&&o,minWidth:Zr.MIN_WIDTH,minHeight:Zr.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||p)&&(0,We.jsxs)(We.Fragment,{children:[(0,We.jsx)(ne,{type:"target",position:ht.Position.Left,id:"left",className:H({"event-handle":p})}),(0,We.jsx)(ne,{type:"target",position:ht.Position.Right,id:"right",className:H({"event-handle":p})}),(0,We.jsx)(ne,{type:"target",position:ht.Position.Top,id:"top",className:H({"event-handle":p})}),(0,We.jsx)(ne,{type:"target",position:ht.Position.Bottom,id:"bottom",className:H({"event-handle":p})})]}),!i&&(0,We.jsxs)(We.Fragment,{children:[(0,We.jsx)(ne,{type:"source",position:ht.Position.Left,id:"left"}),(0,We.jsx)(ne,{type:"source",position:ht.Position.Right,id:"right"}),(0,We.jsx)(ne,{type:"source",position:ht.Position.Top,id:"top"}),(0,We.jsx)(ne,{type:"source",position:ht.Position.Bottom,id:"bottom"})]})]})};var yt=require("@xyflow/react"),os=require("react");var Fe=require("react/jsx-runtime"),qd=({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let s=vs[t.variant].icon,{updateNodeData:a}=(0,yt.useReactFlow)(),{inProgress:l,fromNode:c}=(0,yt.useConnection)(),{mode:d,isReadOnly:u,reconnectingEdgeId:p}=q(),[m,g]=(0,os.useState)(!1),x=l&&(c==null?void 0:c.id)!==e||!!p,f=(0,os.useCallback)(E=>{a(e,{label:E})},[e,a]),h=()=>{g(!0)},y=()=>{g(!1)};return(0,Fe.jsxs)("div",{className:"relative",style:{width:o!=null?o:En.MIN_WIDTH,height:n!=null?n:En.MIN_HEIGHT},onDoubleClick:h,children:[(0,Fe.jsx)(s,{className:H("w-full h-full min-w-14 min-h-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"pointer-events-none":u,"stroke-blue-500 hover:stroke-blue-600":r&&!u,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),(0,Fe.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,Fe.jsx)(Qe,{value:t.label,isEditing:m,onBlur:y,onChange:f})}),(0,Fe.jsx)(lt,{nodeId:e,nodeType:"GATEWAY",nodeVariant:t.variant}),d==="edit"&&(0,Fe.jsx)(Pt,{nodeId:e,isVisible:!i&&r,minWidth:En.MIN_WIDTH,minHeight:En.MIN_HEIGHT,offset:2,keepAspectRatio:!0}),(!l||x)&&(0,Fe.jsxs)(Fe.Fragment,{children:[(0,Fe.jsx)(ne,{type:"target",position:yt.Position.Left,id:"left",className:H({"gateway-handle":x})}),(0,Fe.jsx)(ne,{type:"target",position:yt.Position.Right,id:"right",className:H({"gateway-handle":x})}),(0,Fe.jsx)(ne,{type:"target",position:yt.Position.Top,id:"top",className:H({"gateway-handle":x})}),(0,Fe.jsx)(ne,{type:"target",position:yt.Position.Bottom,id:"bottom",className:H({"gateway-handle":x})})]}),!l&&(0,Fe.jsxs)(Fe.Fragment,{children:[(0,Fe.jsx)(tt,{type:"source",position:yt.Position.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,Fe.jsx)(tt,{type:"source",position:yt.Position.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,Fe.jsx)(tt,{type:"source",position:yt.Position.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,Fe.jsx)(tt,{type:"source",position:yt.Position.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})};var Zd=require("@xyflow/react"),Vt=require("@produto-lecom/lecom-ui"),Ah=require("lucide-react");var Jd=require("react/jsx-runtime");var xt=require("@xyflow/react"),Qd=require("react");var Xe=require("react/jsx-runtime"),jd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=(0,xt.useReactFlow)(),{inProgress:i,fromNode:s}=(0,xt.useConnection)(),{mode:a,isReadOnly:l,reconnectingEdgeId:c}=q(),[d,u]=(0,Qd.useState)(!1),p=i&&(s==null?void 0:s.id)!==e||!!c,m=f=>{r(e,{label:f})},g=()=>{u(!0)},x=()=>{u(!1)};return(0,Xe.jsxs)("div",{className:"relative",onDoubleClick:g,children:[(0,Xe.jsx)(Ur,{className:H("w-full h-full min-w-9 min-h-9 hover:stroke-[#54890b] transition-colors duration-75",{"pointer-events-none":l,"stroke-blue-500 hover:stroke-blue-600":o&&!l,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),(0,Xe.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,Xe.jsx)(Qe,{value:t.label,isEditing:d,onBlur:x,onChange:m})}),(0,Xe.jsx)(lt,{nodeId:e,nodeType:"START_EVENT"}),a==="edit"&&(0,Xe.jsx)(Pt,{nodeId:e,isVisible:!n&&o,minWidth:qr.MIN_WIDTH,minHeight:qr.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||p)&&(0,Xe.jsxs)(Xe.Fragment,{children:[(0,Xe.jsx)(ne,{type:"target",position:xt.Position.Left,id:"left",className:H({"event-handle":p})}),(0,Xe.jsx)(ne,{type:"target",position:xt.Position.Right,id:"right",className:H({"event-handle":p})}),(0,Xe.jsx)(ne,{type:"target",position:xt.Position.Top,id:"top",className:H({"event-handle":p})}),(0,Xe.jsx)(ne,{type:"target",position:xt.Position.Bottom,id:"bottom",className:H({"event-handle":p})})]}),!i&&(0,Xe.jsxs)(Xe.Fragment,{children:[(0,Xe.jsx)(tt,{type:"source",position:xt.Position.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),(0,Xe.jsx)(tt,{type:"source",position:xt.Position.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),(0,Xe.jsx)(tt,{type:"source",position:xt.Position.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),(0,Xe.jsx)(tt,{type:"source",position:xt.Position.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};var nu=require("@produto-lecom/lecom-ui"),Et=require("@xyflow/react"),wr=require("react");var Tr=60,ns=(e,t)=>{var s;let o=[],n=`${t} `;for(let a of e){if(!(a.type==="TASK"))continue;let c=(s=a.data)==null?void 0:s.label;if(c&&c.startsWith(n)){let d=c.substring(n.length);/^\d{1,15}$/.test(d)&&o.push(parseInt(d,10))}}let r=o.length>0?Math.max(...o)+1:1,i=`${t} ${r}`;return i.length<=Tr?i:i.substring(0,Tr).trim()},Gn=(e,t)=>{var a;let o=new Set;for(let l of t)l.type==="TASK"&&((a=l.data)!=null&&a.label)&&o.add(l.data.label);let n=e;if(n.length>Tr&&(n=n.substring(0,Tr).trim()),!o.has(n))return n;let r=n.replace(/\s+\(\d+\)$/,""),i=2,s=o.size+2;for(;i<=s;){let l=` (${i})`,c=Tr-l.length,u=`${r.substring(0,c).trim()}${l}`;if(!o.has(u))return u;i++}return n};var vr=require("react/jsx-runtime"),eu=e=>(0,vr.jsxs)("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[(0,vr.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),(0,vr.jsx)("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));var oa=require("react/jsx-runtime"),tu=e=>(0,oa.jsx)("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:(0,oa.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 Nr=require("react/jsx-runtime"),ou=e=>(0,Nr.jsxs)("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[(0,Nr.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),(0,Nr.jsx)("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));var fe=require("react/jsx-runtime"),Sh={APROVADO:eu,EM_ANDAMENTO:tu,REJEITADO:ou},na={APROVADO:"border-green-500 hover:border-green-500 border-[3px] border-solid",EM_ANDAMENTO:"border-turquoise-400 hover:border-turquoise-400 border-[3px] border-solid",REJEITADO:"border-red-500 hover:border-red-500 border-[3px] border-solid",default:"border-grey-400 border-2 border-solid",error:"border-red-500 border-[3px] shadow-[0_0_5px_rgba(255,0,0,0.5)]"},Ch={APROVADO:"bg-green-50",EM_ANDAMENTO:"bg-turquoise-50",REJEITADO:"bg-red-50"},ru=({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let{t:s}=(0,nu.useTranslation)(),{toast:a}=at(),{updateNodeData:l,getNodes:c,setNodes:d}=(0,Et.useReactFlow)(),{inProgress:u,fromNode:p}=(0,Et.useConnection)(),{mode:m,isReadOnly:g,onSubprocessValidationClick:x,reconnectingEdgeId:f}=q(),{getTaskStatus:h}=Xo(),y=u&&(p==null?void 0:p.id)!==e||!!f,E=h(e),N=t.variant==="SUBPROCESS",b=t.variant==="SERVICE_TASK",v=!!t.variant&&!N&&!b||!!E,T=!!t.attribute||N||b,I=(0,wr.useCallback)(M=>{let B=v||T?80:40,G=M.split(`
41
- `),k=G.reduce((U,X)=>Math.max(U,X.length),0),O=G.length,Y=Math.max(vo.MIN_WIDTH,k*7+64),W=Math.max(vo.MIN_HEIGHT,O*24+B);d(U=>U.map(X=>X.id===e?w(_({},X),{width:Y,height:W,style:w(_({},X.style),{width:Y,height:W})}):X))},[e,d,v,T]),S=(0,wr.useCallback)(M=>{let V=M.trim(),D=t.label||"";if(V===D)return;let A=V,B=c();if(!(V&&V!=="")){A=ns(B,s("bpmn.task.label.prefix")),l(e,{label:A}),I(A),a({variant:"warning",content:(0,fe.jsxs)(fe.Fragment,{children:[s("bpmn.task.feedback.label_empty.prefix")," ",(0,fe.jsx)("strong",{children:A})]})});return}let k=Gn(A,B);k===D||(l(e,{label:k}),I(k),k!==A&&a({variant:"warning",content:(0,fe.jsxs)(fe.Fragment,{children:[s("bpmn.task.feedback.label_already_exists.prefix")," ",(0,fe.jsx)("strong",{children:V})," ",s("bpmn.task.feedback.label_already_exists.middle")," ",(0,fe.jsx)("strong",{children:k})]})}))},[t.label,c,e,s,l,I,a]),P=(0,wr.useCallback)(M=>{I(M)},[I]),R=(0,wr.useCallback)(()=>{a({variant:"error",content:s("bpmn.task.feedback.invalid_first_character")})},[s,a]),C=E?Sh[E]:null,L=t.variant?$r[t.variant].icon:null,K=t.attribute?Kr[t.attribute].icon:null,Q=()=>t.hasError?na.error:E?na[E]:g?na.default:"",j=()=>{var M;return r&&(M=Ch[E])!=null?M:""},z=()=>{x==null||x({id:e,type:"sub_process",label:t.label})};return(0,fe.jsxs)("div",{className:H("relative w-full h-full min-w-44 min-h-24 flex flex-col items-stretch justify-stretch bg-white border-2 border-grey-400 hover:border-grey-500 rounded-md hover:shadow-md transition-colors duration-75",Q(),{"cursor-pointer":g,"border-blue-500 hover:border-blue-600 shadow-md":r&&!g&&!E,"border-red-500 hover:border-red-600 shadow-[0_0_5px_rgba(255,0,0,0.5)]":t.hasError}),style:{width:o!=null?o:vo.MIN_WIDTH,height:n!=null?n:vo.MIN_HEIGHT},children:[(0,fe.jsx)("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:(0,fe.jsx)(Qe,{value:t.label,maxLength:60,className:H(j(),{"py-10 px-8":v||T}),onChange:S,onInput:P,onInvalidFirstCharacter:R})}),L&&(0,fe.jsx)("div",{className:H("absolute flex items-center p-1",N||b?"bottom-0 left-1/2 -translate-x-1/2":"top-0 left-0"),children:(0,fe.jsx)(L,{size:b?20:16,className:H(t.hasError?"text-red-500":"text-grey-500",N&&"cursor-pointer"),onClick:N?z:void 0})}),K&&(0,fe.jsx)("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:(0,fe.jsx)("div",{className:H("flex items-center w-16 p-1",N||b?"justify-between":"justify-center"),children:(0,fe.jsx)(K,{size:16,className:H(t.hasError?"text-red-500":"text-grey-500")})})}),C&&(0,fe.jsx)("div",{className:"absolute top-0 right-0 flex items-center p-1",children:(0,fe.jsx)(C,{})}),(0,fe.jsx)(lt,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),m==="edit"&&(0,fe.jsx)(Pt,{nodeId:e,isVisible:!i&&r,minWidth:vo.MIN_WIDTH,minHeight:vo.MIN_HEIGHT}),(!u||y)&&(0,fe.jsxs)(fe.Fragment,{children:[(0,fe.jsx)(ne,{type:"target",position:Et.Position.Left,id:"left",className:H({"task-handle":y})}),(0,fe.jsx)(ne,{type:"target",position:Et.Position.Right,id:"right",className:H({"task-handle":y})}),(0,fe.jsx)(ne,{type:"target",position:Et.Position.Top,id:"top",className:H({"task-handle":y})}),(0,fe.jsx)(ne,{type:"target",position:Et.Position.Bottom,id:"bottom",className:H({"task-handle":y})})]}),!u&&(0,fe.jsxs)(fe.Fragment,{children:[(0,fe.jsx)(tt,{type:"source",position:Et.Position.Left,id:"left",nodeId:e,nodeType:"TASK"}),(0,fe.jsx)(tt,{type:"source",position:Et.Position.Right,id:"right",nodeId:e,nodeType:"TASK"}),(0,fe.jsx)(tt,{type:"source",position:Et.Position.Top,id:"top",nodeId:e,nodeType:"TASK"}),(0,fe.jsx)(tt,{type:"source",position:Et.Position.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})};var ra=require("@xyflow/react");var mo=require("react/jsx-runtime"),iu=({id:e,data:t})=>(0,mo.jsxs)(mo.Fragment,{children:[(0,mo.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,mo.jsx)(lt,{nodeId:e,nodeType:"UNSUPPORTED"}),(0,mo.jsx)(ne,{type:"source",position:ra.Position.Right}),(0,mo.jsx)(ne,{type:"target",position:ra.Position.Left})]});var Ge=require("@xyflow/react"),rs=require("react");var Ne=require("react/jsx-runtime"),yI={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:Ge.MarkerType.Arrow},data:{label:""}},su=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:s,sourceHandleId:a,targetHandleId:l})=>{var G;let{zoom:c}=(0,Ge.useViewport)(),{updateEdgeData:d}=(0,Ge.useReactFlow)(),{isMultipleSelection:u,mode:p,instanceId:m}=q(),g=p!=="edit",[x,f]=(0,rs.useState)(!1),{reconnectingHandle:h,cursorPosition:y,hoveredNodeId:E,reconnectingSide:N,isValidReconnection:b,handleReconnectStart:v}=Fi({edgeId:e,source:t,target:o,instanceId:m,isReadOnly:g}),T=(0,Ge.useInternalNode)(t),I=(0,Ge.useInternalNode)(o),{sx:S,sy:P,tx:R,ty:C,sourcePos:L,targetPos:K}=(0,rs.useMemo)(()=>{var oe,le;if(!T||!I)return{sx:0,sy:0,tx:0,ty:0,sourcePos:Ge.Position.Left,targetPos:Ge.Position.Right};let k=Tn(T,I),O=a?i:k.sourcePos,Y=l?s:k.targetPos,W=(Z,ve,ye)=>{var ee,xe,Se,Re,qe,Nt;let{x:Ae,y:J}=Z.internals.positionAbsolute,de=(Se=(xe=(ee=Z.measured)==null?void 0:ee.width)!=null?xe:Z.width)!=null?Se:0,re=(Nt=(qe=(Re=Z.measured)==null?void 0:Re.height)!=null?qe:Z.height)!=null?Nt:0;switch(ve){case Ge.Position.Top:return{x:Ae+de*ye,y:J};case Ge.Position.Bottom:return{x:Ae+de*ye,y:J+re};case Ge.Position.Left:return{x:Ae,y:J+re*ye};case Ge.Position.Right:return{x:Ae+de,y:J+re*ye};default:return{x:Ae+de/2,y:J+re/2}}},U=(oe=n==null?void 0:n.sourceOffset)!=null?oe:.5,X=(le=n==null?void 0:n.targetOffset)!=null?le:.5,$=T?W(T,O,U).x:k.sx,te=T?W(T,O,U).y:k.sy,ie=I?W(I,Y,X).x:k.tx,F=I?W(I,Y,X).y:k.ty;return h==="source"&&y?($=y.x,te=y.y,N&&(O=N)):h==="target"&&y&&(ie=y.x,F=y.y,N&&(Y=N)),{sx:$,sy:te,tx:ie,ty:F,sourcePos:O,targetPos:Y}},[T,I,a,l,i,s,h,y,N,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!T||!I)return null;let[Q,j,z]=(0,Ge.getSmoothStepPath)({sourceX:S,sourceY:P,targetX:R,targetY:C,sourcePosition:L,targetPosition:K}),M=r||(T==null?void 0:T.selected)||(I==null?void 0:I.selected),V=M?"sequence-edge-marker-highlighted":"sequence-edge-marker",D=x||(n==null?void 0:n.label.trim().length)>0,A=()=>{f(!1)},B=k=>{d(e,{label:k.trim()})};return(0,Ne.jsx)(Ne.Fragment,{children:(0,Ne.jsxs)("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":M}),onDoubleClick:()=>!g&&f(!0),children:[(0,Ne.jsx)("path",{d:Q,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),(0,Ne.jsxs)("g",{className:H("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":M}),children:[(0,Ne.jsx)(Ge.BaseEdge,{id:e,path:Q,interactionWidth:0,markerEnd:`url(#${V})`,strokeDasharray:4,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||h&&E&&!b,"stroke-green-500":h&&E&&b,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":M&&!(n!=null&&n.hasError)&&!h})}),(0,Ne.jsxs)(Ge.EdgeLabelRenderer,{children:[(0,Ne.jsxs)("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${j}px, ${z}px)`},children:[r&&!u&&(0,Ne.jsx)(Ln,{sx:S,sy:P,tx:R,ty:C,hasLabel:!!((G=n==null?void 0:n.label)!=null&&G.trim()),children:(0,Ne.jsx)(Pn,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),D&&(0,Ne.jsx)(Qe,{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:A,onChange:B})]}),r&&!u&&!g&&(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${S}px, ${P}px)`},children:(0,Ne.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:h==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:h==="source"?.6:.3,className:"pointer-events-none"}),(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!h||h!=="source","cursor-not-allowed":h==="source"&&E&&!b,"cursor-grabbing":h==="source"&&(!E||b)}),onMouseDown:k=>v("source",k.nativeEvent)})]})}),(0,Ne.jsx)("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${R}px, ${C}px)`},children:(0,Ne.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:h==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:h==="target"?.6:.3,className:"pointer-events-none"}),(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!h||h!=="target","cursor-not-allowed":h==="target"&&E&&!b,"cursor-grabbing":h==="target"&&(!E||b)}),onMouseDown:k=>v("target",k.nativeEvent)})]})})]})]})]})]})})};var on=require("@xyflow/react"),Ir=require("react/jsx-runtime"),au=({toX:e,toY:t,fromNode:o})=>{var u,p;if(!o)return null;let{internals:{positionAbsolute:{x:n,y:r}},measured:i}=o,s=(u=i.width)!=null?u:0,a=(p=i.height)!=null?p:0,c=[{x:n,y:r+a/2,pos:on.Position.Left},{x:n+s,y:r+a/2,pos:on.Position.Right},{x:n+s/2,y:r,pos:on.Position.Top},{x:n+s/2,y:r+a,pos:on.Position.Bottom}].reduce((m,g)=>{let x=Math.hypot(e-m.x,t-m.y);return Math.hypot(e-g.x,t-g.y)<x?g:m}),[d]=(0,on.getStraightPath)({sourceX:c.x,sourceY:c.y,targetX:e,targetY:t});return(0,Ir.jsxs)("g",{className:"group",children:[(0,Ir.jsx)("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d}),(0,Ir.jsx)("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})};var _t=require("@xyflow/react"),lu=require("lodash"),Ar=require("react");var ke=require("react/jsx-runtime"),cu=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{var T;let{updateNodeData:i,getNodes:s}=(0,_t.useReactFlow)(),{mode:a,isReadOnly:l}=q(),{inProgress:c,fromNode:d}=(0,_t.useConnection)(),u=c&&(d==null?void 0:d.id)!==e,[p,m]=(0,Ar.useState)(!1),g=s(),x=!r,f=!x&&((T=g.find(I=>I.id===r))==null?void 0:T.selected),h=(0,Ar.useMemo)(()=>(0,lu.orderBy)([...g.filter(I=>I.parentId===e&&I.type==="LANE")],"position.y","asc"),[g,e]),y=x?ka.MIN_WIDTH:ae.MIN_WIDTH,E=(0,Ar.useMemo)(()=>{if(x&&h.length>1){let I=[...h];return I.pop(),I.reduce((P,R)=>{var C,L;return P+((L=(C=R.measured)==null?void 0:C.height)!=null?L:0)},0)+ae.MIN_HEIGHT}return ae.MIN_HEIGHT},[x,h]),N=I=>{i(e,{label:I})},b=()=>{m(!0)},v=()=>{m(!1)};return(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsxs)("div",{className:H("flex h-full min-h-64 w-full min-w-[50rem] hover:shadow-md bg-white outline outline-2 outline-grey-400",{"pointer-events-none":l,"outline-offset-0 outline-blue-500 shadow-sm":(o||f)&&!l}),children:[(0,ke.jsx)("div",{className:H("flex align-items justify-center w-10 border-r-2 border-grey-400",{"border-blue-500":(o||f)&&!l}),onDoubleClick:b,children:(0,ke.jsx)("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:(0,ke.jsx)(Qe,{value:t.label,className:"w-full h-full self-auto",contentClassName:H({"whitespace-nowrap":p}),isEditing:p,onBlur:v,onChange:N})})}),(0,ke.jsx)("div",{className:"flex-1"})]}),(0,ke.jsx)(lt,{nodeId:e,nodeType:"LANE",isChild:!x}),a==="edit"&&(0,ke.jsx)(Pt,{nodeId:e,isVisible:!n&&o,minWidth:y,minHeight:E,offset:10}),!c&&(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsx)(ne,{type:"source",position:_t.Position.Left,id:"left"}),(0,ke.jsx)(ne,{type:"source",position:_t.Position.Right,id:"right"}),(0,ke.jsx)(ne,{type:"source",position:_t.Position.Top,id:"top"}),(0,ke.jsx)(ne,{type:"source",position:_t.Position.Bottom,id:"bottom"})]}),(!c||u)&&(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsx)(ne,{type:"target",position:_t.Position.Left,id:"left",className:H({"annotation-handle":u})}),(0,ke.jsx)(ne,{type:"target",position:_t.Position.Right,id:"right",className:H({"annotation-handle":u})}),(0,ke.jsx)(ne,{type:"target",position:_t.Position.Top,id:"top",className:H({"annotation-handle":u})}),(0,ke.jsx)(ne,{type:"target",position:_t.Position.Bottom,id:"bottom",className:H({"annotation-handle":u})})]})]})};var du={START_EVENT:jd,END_EVENT:Kd,TASK:ru,GATEWAY:qd,ANNOTATION:Ud,LANE:cu,UNSUPPORTED:iu},uu={SEQUENCE_EDGE:yd,MESSAGE_EDGE:su,ANNOTATION_EDGE:ld},pu="#fafafa",fu="#bebebe",mu=1,gu=10,hu="bottom-left",ia=.05,yu=5,Bn=.5,zn=ia,Yn=1,xu={x:0,y:0,zoom:.75},Eu=1,_u=2,Mh={[Eu]:4,[_u]:2},Sr=[Eu,_u],sa=Sr.reduce((e,t)=>e|Mh[t],0);var bu=require("@xyflow/react");var Lt=()=>{let{getEdges:e,getNodes:t}=(0,bu.useReactFlow)(),{lastElementId:o}=q(),n=()=>{let i=t(),s=e(),a=Od(i,s);return Math.max(a,o)};return{getLastId:n,getNextId:()=>n()+1}};var Fn=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n,setViewport:r}=(0,Wn.useReactFlow)(),{getLastId:i}=Lt(),s=(0,Wn.useStoreApi)(),{setLastElementId:a}=q(),l=(0,aa.useCallback)(async(d="")=>{let{nodes:u,edges:p,lastElementId:m}=await Hd(d),{width:g,height:x}=s.getState();if(g>0&&x>0){let f=Ya(u);f&&r((0,Wn.getViewportForBounds)(f,g,x,zn,Yn,Bn))}o(u),n(p),a(m)},[o,n,a,s,r]),c=(0,aa.useCallback)(()=>{let d=e(),u=t(),p=i();return Vd(d,u,p)},[e,t,i]);return{importFromMxGraph:l,exportToMxGraph:c}};var la=require("react"),Ph=500,is=()=>{let{isInitialized:e,onElementChanges:t}=q(),{exportToMxGraph:o}=Fn(),n=(0,Tu.useDebouncedCallback)(()=>{if(!e)return;let s=o();t==null||t(s)},Ph),r=(0,la.useCallback)(s=>{s.every(c=>c.type==="select")||s.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=(0,la.useCallback)(s=>{s.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var vu=({setEdges:e,saveHistory:t})=>{let{getNode:o,getEdges:n,getNodes:r,getInternalNode:i}=(0,ss.useReactFlow)(),{emitElementChanges:s}=is(),a=(0,Qt.useRef)(null),{getNextId:l}=Lt(),c=(0,Qt.useCallback)(f=>{var b;let h=o(f.source),y=o(f.target);if(!h||!y)return!1;let E={sourceNodeId:h.id,targetNodeId:y.id,sourceNodeType:h.type,targetNodeType:y.type,nodes:r(),edges:n(),reconnectingEdgeId:(b=a.current)!=null?b:void 0};return Fs(E).isValid},[o,n,r]),d=(0,Qt.useCallback)(f=>{var E,N;let h=l(),y=i(f.source);if(y){let b=i(f.target),v=b?b.internals.positionAbsolute.x+((E=b.measured.width)!=null?E:0)/2:0,T=b?b.internals.positionAbsolute.y+((N=b.measured.height)!=null?N:0)/2:0,I=xd(y,v,T),S=(b==null?void 0:b.type)==="ANNOTATION"||(y==null?void 0:y.type)==="ANNOTATION",P=S?kn:Mt,R;if(!S&&b&&f.targetHandle){let K=Ui(I),Q=Ui(f.targetHandle),{x:j,y:z}=Ks(y,I),{x:M,y:V}=Ks(b,f.targetHandle),A=Yi(j,z,M,V,K,Q).slice(1,-1);A.length>0&&(R=A)}let C=w(_(_({},f),P),{id:String(h),sourceHandle:I,data:_(_({},S?{}:Mt.data),R?{points:R}:{})}),L=n().concat(C);e(L),t("forceSave",{nodes:r(),edges:L}),s()}},[l,e,s,i,n,r,t]),u=(0,Qt.useCallback)((f,h)=>{a.current=h.id},[]),p=(0,Qt.useCallback)(()=>{a.current=null},[]),m=(0,Qt.useCallback)((f,h)=>{let y=o(h.source),E=o(h.target);if(!y||!E){a.current=null;return}let N={sourceNodeId:y.id,targetNodeId:E.id,sourceNodeType:y.type,targetNodeType:E.type,nodes:r(),edges:n(),reconnectingEdgeId:f.id};if(!Fs(N).isValid){a.current=null;return}let v=(0,ss.reconnectEdge)(f,h,n()).map(T=>T.id===f.id?w(_({},T),{data:w(_({},T.data),{points:void 0})}):T);e(v),t("forceSave",{nodes:r(),edges:v}),a.current=null,s()},[o,r,n,e,s,t]),g=(0,Qt.useCallback)(f=>{a.current=f},[]),x=(0,Qt.useCallback)(()=>{a.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:m,onReconnectStart:u,onReconnectEnd:p,setReconnectingEdge:g,clearReconnectingEdge:x}};var Lu=require("@produto-lecom/lecom-ui"),ku=require("@xyflow/react"),Ht=require("react");var Cr=(e=[])=>e.filter(t=>t.type==="START_EVENT"),nn=(e=[])=>e.filter(t=>t.type==="END_EVENT"),ko=(e=[])=>e.filter(t=>t.type==="TASK")||[],Nu=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"});var as=(e=[])=>e.filter(t=>t.type==="GATEWAY"),wu=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),bt=(e,t=[])=>t.filter(o=>o.source===e),Mr=(e,t=[])=>t.filter(o=>o.target===e),Iu=(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"},Au=(e,t)=>{let o=bt(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},Su=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:[]}},go=(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)}},Cu=(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 Pr=[{id:"start_event_not_found",validate:e=>{let t=Cr(e.nodes);return we({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=nn(e.nodes);return we({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Cr(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=bt(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(s=>s.id),...n.map(s=>s.target)];return we({isValid:!1,nodeIds:[...new Set(i)]})}return we({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=ko(e.nodes),o=go(t,n=>bt(n.id,e.edges).length<=2);return we({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=ko(e.nodes),o=go(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=ko(e.nodes),n=go(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=ko(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=as(e.nodes),o=[],n=[];for(let r of t){let i=bt(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&a.type==="GATEWAY"&&(o.push(r.id,a.id),n.push(s.id))}}return we({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Cr(e.nodes),...nn(e.nodes)],o=[],n=[];for(let r of t){let i=bt(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&(a.type==="START_EVENT"||a.type==="END_EVENT")&&(o.push(r.id,a.id),n.push(s.id))}}return 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=nn(e.nodes),o=[],n=[];for(let r of t){let i=Mr(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.source);if(a&&a.type==="TASK"){let l=bt(a.id,e.edges);l.length>1&&(o.push(a.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=wu(e.nodes),o=go(t,r=>bt(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>bt(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=ko(e.nodes),o=go(t,n=>!n.label||Su(n.label));return we({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var s,a;if(!((s=e==null?void 0:e.nodes)!=null&&s.length)||!((a=e==null?void 0:e.edges)!=null&&a.length))return we({isValid:!0});let t=nn(e.nodes)[0];if(!t)return we({isValid:!0});let o=Mr(t.id,e.edges);if(!o.length)return we({isValid:!0});let r=ko(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=go(r,l=>!Iu(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=ko(e.nodes),o=nn(e.nodes)[0];if(!o)return we({isValid:!0});let n=t.filter(l=>{let c=Mr(l.id,e.edges),d=bt(l.id,e.edges),u=c.some(m=>{var g;return((g=e.nodes.find(x=>x.id===m.source))==null?void 0:g.type)==="START_EVENT"}),p=d.some(m=>{var g;return((g=e.nodes.find(x=>x.id===m.target))==null?void 0:g.type)==="END_EVENT"});return u&&p}),r=Mr(o.id,e.edges),i=r.length>1,s=r.map(l=>l.source),a={isValid:n.length===0&&!i,nodeIds:[...n.map(l=>l.id),...i?s:[]]};return we(a)}},{id:"gateway_flow_to_event",validate:e=>{let t=as(e.nodes),o=[],n=[];for(let r of t){let i=bt(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&a.type==="END_EVENT"&&(o.push(r.id,a.id),n.push(s.id))}}return we({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=as(e.nodes),o=go(t,n=>bt(n.id,e.edges).length>=1);return we({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Cr(e.nodes),...nn(e.nodes)],o=[],n=[];for(let r of t){let i=bt(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&a.type==="GATEWAY"&&(o.push(r.id,a.id),n.push(s.id))}}return we({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=Nu(e.nodes),o=go(t,n=>!Au(n.id,e));return we({isValid:o.isValid,nodeIds:o.invalidIds})}}];var Mu=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of Pr){let r=n.validate(e);r.isValid||t.push({id:n.id,message:n.id,nodeIds:r.nodeIds||[],edgeIds:r.edgeIds||[]})}return{isValid:t.length===0,errors:t}},Pu=async(e,t)=>{var n;let o=[];try{let r=await e(),i=(n=r==null?void 0:r.filter(s=>s.area==="DIAGRAM"))!=null?n:[];return i.length===0?{isValid:!0,errors:[]}:(i.forEach(s=>{var l,c;let a=(c=(l=s==null?void 0:s.detail)==null?void 0:l.phases)==null?void 0:c.map(d=>d.diagramCellId);o.push({id:s.code,message:s.code,nodeIds:a,edgeIds:[]})}),{isValid:!1,errors:o})}catch(r){let i=[],s=(a,l)=>{let c=t.filter(d=>{var u;return((u=d.data)==null?void 0:u.variant)===a}).map(d=>d.id);c.length>0&&i.push({id:l,message:l,nodeIds:c,edgeIds:[]})};return s("SUBPROCESS","cannot_validate_subprocess_reference"),s("SERVICE_TASK","service_task_automation_status_unavailable"),{isValid:!1,errors:i}}};var rn=require("react/jsx-runtime"),Ru=()=>{let{t:e}=(0,Lu.useTranslation)(),{toast:t}=at(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=(0,ku.useReactFlow)(),{validateCustomDiagram:s}=q(),[a,l]=(0,Ht.useState)(!1),c=(0,Ht.useRef)(!1),d=(0,Ht.useRef)(!1),u=(0,Ht.useCallback)(async f=>{let h=Cu(f.nodes,f.edges),y=Mu(h),E=f.nodes.filter(({type:b,data:v})=>b==="TASK"&&((v==null?void 0:v.variant)==="SUBPROCESS"||(v==null?void 0:v.variant)==="SERVICE_TASK"));if(s&&E.length>0){let b=await Pu(s,E);y={isValid:y.isValid&&b.isValid,errors:[...y.errors,...b.errors]}}let N=y.errors.map(b=>w(_({},b),{message:e(`validation.errors.${b.id}`)}));return a||l(!0),{isValid:y.isValid,errors:N}},[a,e,s]),p=(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,rn.jsxs)("div",{className:"flex flex-col gap-1",children:[!f.isValid&&(0,rn.jsx)("span",{className:"body-small-500",children:e("validation.errors.subtitle")}),(0,rn.jsx)("ul",{className:"list-disc list-inside max-h-40 overflow-y-auto",children:f.isValid?(0,rn.jsx)("li",{children:e("validation.success.message")}):f.errors.map(C=>(0,rn.jsx)("li",{className:"text-xs",children:C.message},C.id))})]})}),!f)return;c.current=!0,d.current=!0;let y=[],E=[];f.errors.forEach(C=>{C.nodeIds&&C.nodeIds.length>0&&C.nodeIds.forEach(L=>y.push(L)),C.edgeIds&&C.edgeIds.length>0&&C.edgeIds.forEach(L=>E.push(L))});let N=[...new Set(y)];o(C=>C.map(L=>w(_({},L),{data:w(_({},L.data),{hasError:!1})}))),n(C=>C.map(L=>w(_({},L),{data:w(_({},L.data),{hasError:!1})})));let b=r(),v=i(),T=new Set(N),I=new Set;f.errors.forEach(C=>{var Q,j;let L=Pr.find(z=>z.id===C.id);(L==null?void 0:L.highlightRelatedEdges)!==!1&&((Q=C.edgeIds)==null||Q.forEach(z=>I.add(z)),(j=C.nodeIds)==null||j.forEach(z=>{v.forEach(M=>{(M.source===z||M.target===z)&&I.add(M.id)})}))});let S=new Set,P=new Set,R=new Set;b.forEach(C=>{C.type==="START_EVENT"?S.add(C.id):C.type==="END_EVENT"&&P.add(C.id)}),v.forEach(C=>{S.has(C.source)&&R.add(C.target),P.has(C.target)&&R.add(C.source)}),R.forEach(C=>{var L,K;if(T.has(C)){let Q=(L=f.errors.find(z=>{var M;return(M=z.nodeIds)==null?void 0:M.includes(C)}))==null?void 0:L.id;((K=Pr.find(z=>z.id===Q))==null?void 0:K.highlightRelatedEdges)!==!1&&v.forEach(z=>{z.source===C&&P.has(z.target)&&(T.add(z.target),I.add(z.id)),z.target===C&&S.has(z.source)&&(T.add(z.source),I.add(z.id))})}}),T.size>0&&o(C=>C.map(L=>w(_({},L),{data:w(_({},L.data),{hasError:T.has(L.id)})}))),I.size>0&&n(C=>C.map(L=>w(_({},L),{data:w(_({},L.data),{hasError:I.has(L.id)})}))),setTimeout(()=>{c.current=!1},0)},[e,i,r,n,o,t]),m=(0,Ht.useCallback)(()=>{l(!1),d.current=!1,o(f=>f.map(h=>w(_({},h),{data:w(_({},h.data),{hasError:!1})}))),n(f=>f.map(h=>w(_({},h),{data:w(_({},h.data),{hasError:!1})})))},[n,o]),g=(0,Ht.useCallback)(()=>{d.current&&(c.current=!0,d.current=!1,o(f=>f.map(h=>w(_({},h),{data:w(_({},h.data),{hasError:!1})}))),n(f=>f.map(h=>w(_({},h),{data:w(_({},h.data),{hasError:!1})}))),setTimeout(()=>{c.current=!1},0))},[n,o]),x=(0,Ht.useCallback)(()=>c.current,[]);return{validateDiagram:u,handleValidationComplete:p,clearValidation:m,dismissValidationPanel:g,isAutoValidationEnabled:a,getIsClearingValidation:x}};var Vu=require("@xyflow/react"),Hu=require("@produto-lecom/lecom-ui"),Gu=require("react");var Lh=15,Du="bpmn:selection",kh=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",i=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||i},Ou=e=>{if(!kh(e.target))return!0;let t=window.getSelection(),o=t&&t.toString().length>0;if(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement){let n=e.target;return n.selectionStart===n.selectionEnd&&!o}return!o},Bu=({offset:e=Lh,saveHistory:t})=>{let{t:o}=(0,Hu.useTranslation)(),{getNodes:n,setNodes:r,getEdges:i,setEdges:s}=(0,Vu.useReactFlow)(),{getNextId:a}=Lt(),{mode:l,containerRef:c}=q();(0,Gu.useEffect)(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let u=m=>{var b,v;if(!Ou(m)||!d.contains(document.activeElement))return;let x=n(),f=i(),h=x.filter(T=>T.selected);if(!h.length)return;m.preventDefault(),m.stopPropagation();let y=f.filter(T=>h.some(I=>I.id===T.source)&&h.some(I=>I.id===T.target)),N=JSON.stringify({nodes:h,edges:y});(b=m.clipboardData)==null||b.setData(Du,N),(v=m.clipboardData)==null||v.setData("text/plain",`BPMN Selection: ${h.length} nodes`)},p=m=>{var R,C;if(!Ou(m)||!d.contains(document.activeElement))return;let x=(R=m.clipboardData)==null?void 0:R.getData(Du);if(!x)return;m.preventDefault(),m.stopPropagation();let f;try{f=JSON.parse(x)}catch(L){return}if(!((C=f.nodes)!=null&&C.length))return;let h=new Map,y=n(),E=[],N=f.nodes.filter(L=>So(L.type,y));if(N.length===0)return;let b=a(),v=N.map(L=>{var j;let K=String(b++);h.set(L.id,K);let Q=w(_({},L),{id:K,selected:!0,position:{x:L.position.x+e,y:L.position.y+e}});if(L.type==="TASK"){let z=(j=L.data)==null?void 0:j.label,M=Gn(z||o("bpmn.task.label.prefix"),[...y,...E]);Q.data=w(_({},L.data),{label:M})}return E.push(Q),Q}),T=f.edges.map(L=>w(_({},L),{id:String(b++),selected:!0,source:h.get(L.source)||L.source,target:h.get(L.target)||L.target})),I=[...y.map(L=>w(_({},L),{selected:!1})),...v],P=[...i().map(L=>w(_({},L),{selected:!1})),...T];r(I),s(P),t("forceSave",{nodes:I,edges:P})};return d.addEventListener("copy",u,!0),d.addEventListener("paste",p,!0),()=>{d.removeEventListener("copy",u,!0),d.removeEventListener("paste",p,!0)}},[n,r,i,s,a,e,o,t,l,c])};var zu=require("@produto-lecom/lecom-ui"),Yu=require("@xyflow/react");var Wu=require("react");var Rh=50,Fu=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let{draggableNode:r,setDraggableNode:i}=Hn(),{t:s}=(0,zu.useTranslation)(),{getInternalNode:a,getNodes:l,getEdges:c,screenToFlowPosition:d}=(0,Yu.useReactFlow)(),{getNextId:u}=Lt(),{setIsDragging:p}=q(),{getInternalNodes:m}=Zi(),{rebuildIndex:g,forceRebuildIndex:x}=Mi(),[f,h]=(0,Wu.useState)(null),y=(M,V,D)=>{var k;if(M.parentId!==V)return null;let A=D.filter(O=>O.id!==M.id&&O.parentId===V&&O.type==="LANE").sort((O,Y)=>O.position.y-Y.position.y);if(A.length===0)return null;let B=(k=D.find(O=>O.id===M.id))!=null?k:M,G=A.find(O=>B.position.y<O.position.y);return G?{draggedLaneId:M.id,beforeLaneId:G.id}:{draggedLaneId:M.id,afterLaneId:A[A.length-1].id}},E=(M,V=!1,D)=>{let A=V?"node-drop-target-error":"node-drop-target",B=V?"node-drop-target-lane-error":"node-drop-target-lane";t(G=>{var O;let k=(O=D==null?void 0:D(G))!=null?O:null;return G.map(Y=>{let W=[];return Y.id===M&&W.push(A),M!==void 0&&Y.parentId===M&&Y.type==="LANE"&&Y.id!==(k==null?void 0:k.draggedLaneId)&&W.push(B),Y.id===(k==null?void 0:k.draggedLaneId)&&W.push("lane-reorder-dragging"),Y.id===(k==null?void 0:k.beforeLaneId)&&W.push("lane-reorder-before"),Y.id===(k==null?void 0:k.afterLaneId)&&W.push("lane-reorder-after"),w(_({},Y),{className:W.join(" ")})})})},N=(M,V)=>{let D=m();if(M.type==="LANE"){if(V){E();return}let O=D.filter(U=>U.id!==M.id&&U.type==="LANE"&&!U.parentId),Y=jn(M,O);if(!Y){E();return}if(Yo({parentId:Y.id,nodes:e,excludeTypes:["LANE"]})){E(Y.id,!0);return}E(Y.id,!1,U=>y(M,Y.id,U));return}let B=D.filter(O=>O.id!==M.id&&O.type==="LANE"),G=jn(M,B);if(!G){E();return}if(Yo({parentId:G.id,nodes:e,includeTypes:["LANE"]})){E();return}E(G.id)},b=M=>{let V=a(M.id),D=M.type==="LANE"&&Yo({parentId:M.id,nodes:e,includeTypes:["LANE"]});N(V,D)},v=M=>M.map(V=>w(_({},V),{className:void 0})),T=M=>M.some(D=>D.dragging)?M.map(D=>D.dragging?w(_({},D),{dragging:!1}):D):M,I=(M,V)=>{let D=0;for(let A of V){if(A.id===M||A.parentId||A.type==="LANE")continue;let B=At(A),G=B.y+B.h;D=Math.max(D,G)}return D+Rh},S=(M,V)=>{if(!Ns(M,V))return V;let D=I(M,V);return V.map(A=>A.id===M?w(_({},A),{position:w(_({},A.position),{y:D})}):A)},P=M=>{if(M.preventDefault(),M.dataTransfer.dropEffect="move",!(r!=null&&r.type))return;let V=d({x:M.clientX,y:M.clientY}),D={id:"__sidebar_drag__",type:r.type,position:V,measured:{width:1,height:1},internals:{positionAbsolute:V}};N(D,!1)},R=M=>{let V=M.relatedTarget;(!V||!M.currentTarget.contains(V))&&E()},C=(M,V)=>{M.preventDefault(),b(V)},L=(M,V,D)=>{var W,U;let A=[...D],B=V.parentId?V.parentId:V.id;if(M.parentId===V.id)return A=Is(M,V,A),A=uo(A),A=Wo(B,A),v(A);if(M.type==="LANE"){if(Yo({parentId:V.id,nodes:A,excludeTypes:["LANE"]})){let F=Ai(V),oe=50,le=50;return A.map(Z=>{var ve,ye;return Z.id===M.id?w(_({},Z),{position:{x:(ve=f==null?void 0:f.x)!=null?ve:F.x+oe,y:(ye=f==null?void 0:f.y)!=null?ye:F.y2+le}}):Z})}let te=A.filter(F=>F.parentId===V.id).reduce((F,oe)=>{var le,Z;return F+((Z=(le=oe.measured)==null?void 0:le.height)!=null?Z:0)},0),ie={x:ae.HEADER_WIDTH,y:te};return A=A.map(F=>F.id===M.id?w(_({},F),{parentId:V.id,position:ie,className:void 0}):w(_({},F),{className:void 0})),A=uo(A),A=S(B,A),A}if(Yo({parentId:V.id,nodes:A,includeTypes:["LANE"]})){let X;if(M.parentId){let $=a(M.parentId),{x:te,y:ie}=At($);X={x:te+((W=M.position.x)!=null?W:0),y:ie+((U=M.position.y)!=null?U:0)}}return A=A.map($=>$.id===M.id?w(_({},$),{position:X!=null?X:$.position,parentId:void 0,className:void 0}):w(_({},$),{className:void 0})),A=Wo(B,A),A}let O=Ga(M,V);A=A.map(X=>X.id===M.id?w(_({},X),{parentId:V.id,position:O,className:void 0}):w(_({},X),{className:void 0}));let Y=A.find(X=>X.id===M.id);return A=Is(Y,V,A),A=uo(A),A=Wo(B,A),A},K=M=>{if(M.preventDefault(),!(r!=null&&r.type))return;if(!So(r.type,l())){p(!1),i(null);return}let V=d({x:M.clientX,y:M.clientY}),D={width:ue[r.type].MIN_WIDTH,height:ue[r.type].MIN_HEIGHT},A=u(),B={id:String(A),type:r.type,position:V,measured:D,data:{label:r.type==="TASK"?ns(e,s("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},G=w(_({},B),{internals:{positionAbsolute:V}}),k=w(_({},G),{measured:{width:1,height:1}}),O=m(),Y=r.type==="LANE",W=O.filter(F=>Y?F.type==="LANE"&&!F.parentId:F.type==="LANE"),U=jn(k,W),X=[...O.map(F=>w(_({},F),{selected:!1})),G];U&&(X=L(G,U,X)),X=zo(X),Y&&!U&&(X=S(G.id,X)),X=v(X),t(X),x();let $=M.dataTransfer.getData("sourceId"),te=c(),ie=te;if($){let F={id:String(A+1),source:$,target:B.id},oe=r.type==="ANNOTATION"?_(_({},F),kn):_(_({},F),Mt);ie=te.concat(oe),o(ie)}n("forceSave",{nodes:X,edges:ie}),p(!1),i(null)},Q=async(M,V,D)=>{let A=[...m()],B=new Set;D.forEach(O=>{let Y=a(O.id),W=O.type==="LANE",U=A.filter($=>$.id!==O.id&&(W?$.type==="LANE"&&!$.parentId:$.type==="LANE")),X=jn(Y,U);if(X){if(W&&Yo({parentId:O.id,nodes:A,includeTypes:["LANE"]})){O.parentId&&(A=z(O,A),B.add(O.id));return}A=L(Y,X,A);return}O.parentId&&(A=z(O,A),O.type==="LANE"&&B.add(O.id))}),A=T(A);let G=D.filter(O=>O.type==="LANE"&&!O.parentId).map(O=>O.id);for(let O of G)Ns(O,A)&&f&&(A=A.map(Y=>Y.id===O?w(_({},Y),{position:_({},f)}):Y));for(let O of B)A=S(O,A);if(D.some(O=>O.type!=="LANE"&&!O.parentId)){let O=A.filter(Y=>Y.type==="LANE"&&!Y.parentId).map(Y=>Y.id);for(let Y of O)A=Wo(Y,A)}A=zo(A),A=v(A),t(A),g(A),h(null)},j=(M,V)=>{h({x:V.position.x,y:V.position.y})},z=(M,V)=>{var U,X,$,te,ie,F,oe,le;let D=a(M.parentId);if(!D)return V;let A=M.type==="LANE",B=V.filter(Z=>Z.parentId===D.id&&Z.id!==M.id),G=B.filter(Z=>Z.type==="LANE"),k;if(A&&G.length===0)k=ae.MIN_HEIGHT;else if(A){let Z=(X=(U=M.measured)==null?void 0:U.height)!=null?X:ae.MIN_HEIGHT;k=((te=($=D.measured)==null?void 0:$.height)!=null?te:ae.MIN_HEIGHT)-Z,k=Math.max(ae.MIN_HEIGHT,k)}else k=B.length>0?B.reduce((Z,ve)=>{var ye,Ae;return Z+((Ae=(ye=ve.measured)==null?void 0:ye.height)!=null?Ae:0)},0)+He:Math.max(ae.MIN_HEIGHT,(F=(ie=D.measured)==null?void 0:ie.height)!=null?F:0);let{x:O,y:Y}=At(D),W={x:O+((oe=M.position.x)!=null?oe:0),y:Y+((le=M.position.y)!=null?le:0)};return V=V.map(Z=>Z.id===M.id?w(_({},Z),{position:W,parentId:void 0}):Z.id===D.id?w(_({},Z),{height:k,measured:w(_({},Z.measured),{height:k})}):Z),V=uo(V),V};return{onDragOver:P,onDragLeave:R,onDrop:K,onNodeDrag:C,onNodeDragStart:j,onNodeDragStop:Q}};var Xu=require("@xyflow/react"),Uu=require("@produto-lecom/lecom-ui"),$u=require("react");var Dh=30,Oh=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",i=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||i},Vh=e=>!Oh(e.target),Ku=({offset:e=Dh,saveHistory:t})=>{let{t:o}=(0,Uu.useTranslation)(),{getNodes:n,setNodes:r,getEdges:i,setEdges:s}=(0,Xu.useReactFlow)(),{getNextId:a}=Lt(),{mode:l,containerRef:c}=q();(0,$u.useEffect)(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let u=p=>{if(d.contains(document.activeElement)&&p.ctrlKey&&p.key.toLowerCase()==="d"&&Vh(p)){p.preventDefault(),p.stopPropagation();let g=n(),x=i(),f=g.filter(P=>P.selected);if(!f.length)return;let h=new Map,y=[],E=f.filter(P=>So(P.type,g));if(E.length===0)return;let N=x.filter(P=>E.some(R=>R.id===P.source)&&E.some(R=>R.id===P.target)),b=a(),v=E.map(P=>{var L;let R=String(b++);h.set(P.id,R);let C=w(_({},P),{id:R,selected:!0,position:{x:P.position.x+e,y:P.position.y+e}});if(P.type==="TASK"){let K=(L=P.data)==null?void 0:L.label,Q=Gn(K||o("bpmn.task.label.prefix"),[...g,...y]);C.data=w(_({},P.data),{label:Q})}return y.push(C),C}),T=N.map(P=>w(_({},P),{id:String(b++),selected:!0,source:h.get(P.source)||P.source,target:h.get(P.target)||P.target})),I=[...g.map(P=>w(_({},P),{selected:!1})),...v],S=[...x.map(P=>w(_({},P),{selected:!1})),...T];r(I),s(S),t("forceSave",{nodes:I,edges:S})}};return d.addEventListener("keydown",u,!0),()=>{d.removeEventListener("keydown",u,!0)}},[n,r,i,s,a,e,o,t,l,c])};var kr=require("react"),qu=require("@xyflow/react");var Hh=20,Gh=50,Lr={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},Bh=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},Zu=e=>{let{getNodes:t}=(0,qu.useReactFlow)(),{mode:o,isMoveTool:n}=q(),r=(0,kr.useRef)(0),i=(0,kr.useRef)(new Map);(0,kr.useEffect)(()=>{let s=a=>{if(o!=="edit"||!n||Bh(a.target)||!Object.values(Lr).includes(a.key))return;let u=t().filter(y=>y.selected);if(u.length===0){i.current.clear();return}a.preventDefault();let p=Date.now(),m=p-r.current<500;r.current=p;let g=a.shiftKey?Gh:Hh,x=0,f=0;switch(a.key){case Lr.UP:f=-g;break;case Lr.DOWN:f=g;break;case Lr.LEFT:x=-g;break;case Lr.RIGHT:x=g;break}let h=u.map(y=>{let E=i.current.get(y.id);(!m||!E)&&(E={x:y.position.x,y:y.position.y});let N={x:E.x+x,y:E.y+f};return i.current.set(y.id,N),{id:y.id,dragging:!0,type:"position",position:N}});e&&e(h)};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t,e,o,n])};var tp=require("@xyflow/react");var Qu={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},ju={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},Ju=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],n=e.match(/(\[.*?\])/)||[],r=e.match(/(\{.*?\})/)||[],i=e.match(/(--.*|\|.*?\|)/i)||[],s="",a="",l="";if(o.length){switch(o[1]){case"<start>":s="start-event";break;case"<end>":s="end-event";break}e=e.replace(o[1],"")}return n.length&&(s="task",a=n[1].replace(/\[|\]/g,""),e=e.replace(n[1],"")),r.length&&(s="gateway-exclusive",a=r[1].replace(/\{|\}/g,""),e=e.replace(r[1],"")),s||(s="task",a=e),i.length&&(l=i[1].replace(/(\||--)/g,""),e=e.replace(i[1],"")),e=e.trim(),t[e]||(t[e]={type:s,label:a}),{step:e,type:s,label:a,edgeLabel:l}},zh=e=>{e=e||"";let t=e.trim().split(`
42
- `),o={},n=[];return t.forEach(r=>{r=r||"";let i=r.trim().split("-->");if(i.length!==2){console.warn("Invalid number of steps");return}let s=Ju(i[0],o),a=Ju(i[1],o);s&&a&&n.push({sourceId:s.step,targetId:a.step,label:s.edgeLabel||a.edgeLabel||""})}),{components:o,connections:n}},ep=e=>{let{components:t,connections:o}=zh(e);return{nodes:t,edges:o}};var op=()=>{let{setNodes:e,setEdges:t,fitView:o}=(0,tp.useReactFlow)(),{getNextId:n}=Lt();return{importFromLia:i=>{let s=typeof i=="string"?i:i.diagramXml||"",{nodes:a,edges:l}=ep(s),c=[],d=new Map,u=!1,p=n();for(let[f,h]of Object.entries(a)){let y=String(p++),E=Qu[h.type],N=ju[h.type];E==="START_EVENT"&&(u=!0),d.set(f,y);let b=ue[E].MIN_WIDTH,v=ue[E].MIN_HEIGHT;c.push({id:y,type:E,data:{label:h.label||"",variant:N,attribute:""},position:{x:0,y:0},width:b,height:v,measured:{width:b,height:v}})}let m=[];for(let f of l){let h=w(_({},Mt),{id:String(p++),source:d.get(f.sourceId)||f.sourceId,target:d.get(f.targetId)||f.targetId});m.push(h)}if(!u&&c.length>0){let f=String(p++),h={id:f,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:ue.START_EVENT.MIN_WIDTH,height:ue.START_EVENT.MIN_HEIGHT,measured:{width:ue.START_EVENT.MIN_WIDTH,height:ue.START_EVENT.MIN_HEIGHT}};c.unshift(h);let y=c[1];if(y){let E=w(_({},Mt),{id:String(p++),source:f,target:y.id});m.unshift(E)}}let{nodes:g,edges:x}=Ld(c,m);e(g),t(x),o({padding:Bn,minZoom:zn,maxZoom:Yn})}}};var ls=require("react"),Yh={origin:"*",debug:!1};function cs(e,t=Yh){let{origin:o,debug:n}=t,r=(0,ls.useCallback)((i,s)=>{let a={event:i,data:s};window.parent.postMessage(a,o||"*")},[o]);return(0,ls.useEffect)(()=>{if(!e)return;let i=s=>{let a=s.data;if(!(a!=null&&a.event)||(a==null?void 0:a.data)===void 0)return;let{event:l,data:c}=a,d;if(Array.isArray(c)){let[,u]=c;d=u.data}else d=c;n&&(console.debug("[postMessage] received:",a),console.debug("[postMessage] eventData:",d)),l&&e[l]&&e[l](d)};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[e,n]),{sendMessage:r}}var np=require("@xyflow/react"),ho=require("react");var rp=()=>{let e=(0,np.useNodesInitialized)(),{initialDiagram:t,isNewDiagram:o,setIsInitialized:n,onElementChanges:r}=q(),{importFromMxGraph:i,exportToMxGraph:s}=Fn(),{sendMessage:a}=cs(),l=(0,ho.useRef)(t),c=(0,ho.useRef)(r),d=(0,ho.useRef)(s);(0,ho.useEffect)(()=>{c.current=r},[r]),(0,ho.useEffect)(()=>{d.current=s},[s]),(0,ho.useEffect)(()=>{t&&(i(t),l.current=t)},[t,i]),(0,ho.useEffect)(()=>{if(!e)return;(async()=>{var p;if(await Fr(),n(!0),a("INIT_MODELER",l.current),!o){let m=d.current();(p=c.current)==null||p.call(c,m)}})()},[e,o,n,a])};var ca=require("react"),ip=require("@xyflow/react");function sp(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=Xo(),{getEdges:n}=(0,ip.useReactFlow)(),r=Qr(),i=(0,ca.useCallback)(a=>{if(!(a!=null&&a.activities))return;e(a.activities);let l=a.activities.map(d=>d.diagramId),c=n();o(c,l),setTimeout(()=>{r()},0)},[e,o,n,r]),s=(0,ca.useCallback)(()=>{t(),setTimeout(()=>{r()},0)},[t,r]);return{handleTasksStatus:i,handleClearTaskStatus:s}}var lp=require("@xyflow/react"),ot=require("react"),cp=require("use-debounce");var Fh=500,ap=100,dp=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=(0,lp.useReactFlow)(),{mode:i,containerRef:s}=q(),[a,l]=(0,ot.useState)({history:[],currentStep:0}),{history:c,currentStep:d}=a,u=d>0,p=d<c.length-1,m=(0,ot.useCallback)((T,I)=>{n(T[I].nodes),r(T[I].edges)},[n,r]),g=(0,ot.useCallback)(()=>{if(d>0){let T=d-1;l(I=>w(_({},I),{currentStep:T})),m(c,T)}},[d,c,m]),x=(0,ot.useCallback)(()=>{if(d<c.length-1){let T=d+1;l(I=>w(_({},I),{currentStep:T})),m(c,T)}},[c,d,m]),f=(0,ot.useCallback)(T=>{l(I=>{let S=I.history[I.currentStep];if(S&&JSON.stringify(S)===JSON.stringify(T))return I;let C=[...I.history.slice(0,I.currentStep+1),T],L=C.length>ap?C.slice(C.length-ap):C;return{history:L,currentStep:L.length-1}})},[]),h=(0,ot.useCallback)((T,I)=>{let S=T.map(R=>w(_({},R),{selected:!1,className:"",data:w(_({},R.data),{hasError:!1})})),P=I.map(R=>w(_({},R),{data:w(_({},R.data),{hasError:!1})}));return{nodes:zo(S),edges:P}},[]),y=(0,ot.useCallback)(()=>h(t(),o()),[t,o,h]),E=(0,cp.useDebouncedCallback)(()=>{let T=y();f(T)},Fh),N=(0,ot.useCallback)((T,I)=>{if(!e)return;if(c.length===0){let R=y();l({history:[R],currentStep:0})}if(T==="forceSave"){if(I){f(h(I.nodes,I.edges));return}E();return}T.some(R=>R.type==="select")||T.some(R=>R.type==="position"&&R.dragging)||E()},[e,E,c.length,y,f,h]);(0,ot.useEffect)(()=>{if(e&&c.length===0){let T=y();l({history:[T],currentStep:0})}},[e,c.length,y]);let b=(0,ot.useCallback)(T=>{l({history:T||[],currentStep:0})},[]),v=(0,ot.useCallback)(()=>{l({history:[],currentStep:0})},[]);return(0,ot.useEffect)(()=>{if(i!=="edit")return;let T=s.current;if(!T)return;let I=S=>{if(!T.contains(document.activeElement)||!(S.ctrlKey||S.metaKey))return;let C=S.key.toLowerCase();if(S.shiftKey&&C==="z"){S.preventDefault(),x();return}C==="z"&&(S.preventDefault(),g())};return T.addEventListener("keydown",I),()=>{T.removeEventListener("keydown",I)}},[g,x,i,s]),{history:c,undo:g,redo:x,canUndo:u,canRedo:p,saveHistory:N,resetHistory:b,clearHistory:v}};var pp=()=>{let{t:e}=(0,up.useTranslation)(),[t,o,n]=(0,jt.useNodesState)([]),[r,i,s]=(0,jt.useEdgesState)([]),{getNodes:a,getNode:l}=(0,jt.useReactFlow)(),{toast:c}=at(),d=(0,jt.useStoreApi)(),{instanceId:u,isInitialized:p,setIsConnecting:m,setIsMultipleSelection:g,onElementClick:x}=q(),{updateHelperLines:f,HelperLines:h}=Mi(),{undo:y,redo:E,canUndo:N,canRedo:b,saveHistory:v}=dp(p),{onNodeDrag:T,onDrop:I,onDragOver:S,onDragLeave:P,onNodeDragStop:R,onNodeDragStart:C}=Fu({nodes:t,setNodes:o,setEdges:i,saveHistory:v}),{isValidConnection:L,onConnect:K,onReconnect:Q,onReconnectStart:j,onReconnectEnd:z,setReconnectingEdge:M,clearReconnectingEdge:V}=vu({setEdges:i,saveHistory:v}),{handleValidationComplete:D,clearValidation:A,dismissValidationPanel:B,validateDiagram:G,getIsClearingValidation:k}=Ru(),{importFromLia:O}=op(),{handleTasksStatus:Y,handleClearTaskStatus:W}=sp(),{clearPathEdges:U}=Xo(),{emitElementChanges:X,handleNodeChanges:$,handleEdgeChanges:te}=is(),ie=Qr();Bu({saveHistory:v}),Ku({saveHistory:v}),rp();let F=(0,Tt.useCallback)(()=>{o([]),i([]),U(),setTimeout(ie,0)},[o,i,U,ie]),{selectElements:oe,clearSelection:le}=Co(),{importFromMxGraph:Z,exportToMxGraph:ve}=Fn(),{configureElement:ye,getConfigureElement:Ae}=Oi(),J=(0,Tt.useCallback)(Ee=>{Ee!=null&&Ee.id&&oe([Ee.id])},[oe]),{sendMessage:de}=cs({LIA_CREATE_DIAGRAM:O,CLEAR_DIAGRAM:F,TASKS_STATUS:Y,CLEAR_TASKS_STATUS:W,EXTERNAL_TASK_SELECT:J}),re=(0,Tt.useCallback)(()=>t.length+r.length,[t,r]);(0,Tt.useEffect)(()=>(qt.set(u,{importFromMxGraph:Z,exportToMxGraph:ve,selectElements:oe,clearSelection:le,configureElement:ye,getConfigureElement:Ae,getElementsCount:re,setReconnectingEdge:M,clearReconnectingEdge:V}),()=>{qt.delete(u)}),[u,Z,ve,oe,le,ye,Ae,re,M,V]);let ee=(0,Tt.useCallback)((Ee,he)=>{if(he.type!=="TASK"&&he.type!=="GATEWAY")return;let pe=Ae(he.id);pe&&(x==null||x(pe)),he.type==="TASK"&&de("SELECT_TASK",{id:he.id})},[Ae,x,de]),xe=(0,Tt.useCallback)((Ee,he)=>{if(he.type!=="SEQUENCE_EDGE")return;let pe=l(he.source),De=l(he.target),{isFromStartEvent:ut,isGatewayToGateway:wt,isActiviyToAndGateway:nt,isToEndEvent:Yt}=Jr(pe,De);if(!(!ut&&!wt&&!nt&&!Yt))return;let ro=Ae(he.id);ro&&(x==null||x(ro))},[Ae,l,x]),Se=(0,Tt.useCallback)(Ee=>{let he=f(Ee,t);n(he),v(Ee),k()||B(),$(Ee)},[t,n,v,k,B,f,$]),Re=(0,Tt.useCallback)(Ee=>{s(Ee),v(Ee),k()||B(),te(Ee)},[s,v,k,B,te]);Zu(Se);let qe=(0,Tt.useCallback)(({nodes:Ee,edges:he})=>{g(Ee.length+he.length>=2)},[g]);(0,jt.useOnSelectionChange)({onChange:qe});let Nt=(0,Tt.useCallback)(async({nodes:Ee})=>Ee.some(pe=>pe.type==="LANE"&&t.some(De=>De.parentId===pe.id))?(c({variant:"error",title:e("validation.errors.title"),content:e("editor.toolbar.delete_pool_lane_error")}),!1):!0,[t,e,c]),no=()=>{v("forceSave"),X(),B()},Bt=()=>{m(!0)},zt=()=>{m(!1),B()},dt=(0,Tt.useCallback)(Ee=>{let he=new Set(Ee.filter(pe=>pe.type==="LANE"&&!!pe.parentId).map(pe=>pe.parentId));he.size!==0&&setTimeout(()=>{var ut,wt;let pe=a(),De=new Map(pe.map(nt=>[nt.id,nt]));for(let nt of he){let Yt=Fo(pe.filter(io=>io.type==="LANE"&&io.parentId===nt));if(Yt.length===0)continue;let xo=0;for(let io of Yt)De.set(io.id,w(_({},io),{position:{x:ae.HEADER_WIDTH,y:xo}})),xo+=(wt=(ut=io.measured)==null?void 0:ut.height)!=null?wt:0;let ro=De.get(nt);ro&&De.set(nt,w(_({},ro),{height:xo,measured:w(_({},ro.measured),{height:xo})}))}o(pe.map(nt=>{var Yt;return(Yt=De.get(nt.id))!=null?Yt:nt}))},0)},[a,o]);return{nodes:t,setNodes:o,edges:r,setEdges:i,events:{isValidConnection:L,onConnect:K,onReconnect:Q,onReconnectStart:j,onReconnectEnd:z,onDrop:I,onDragOver:S,onDragLeave:P,onNodeDrag:T,onNodeDragStop:R,onNodeDragStart:C,onNodeClick:ee,onEdgeClick:xe,onDropCapture:no,onConnectStart:Bt,onConnectEnd:zt,onSelectionEnd:()=>setTimeout(()=>d.setState({nodesSelectionActive:!1}),0),onNodesChange:Se,onEdgesChange:Re,onBeforeDelete:Nt,onNodesDelete:dt},ui:{handleCloseValidationPanel:A},controls:{undo:y,redo:E,canUndo:N,canRedo:b},components:{HelperLines:h},actions:{saveHistory:v,selectElements:oe,clearSelection:le,exportToMxGraph:ve,validateDiagram:G,handleValidationComplete:D,setReconnectingEdge:M,clearReconnectingEdge:V}}};var fp=require("@xyflow/react"),Ro=require("react");var Xh=".react-flow__node, .react-flow__edge, .react-flow__node-toolbar";function mp(e,t,o){let[n,r]=(0,Ro.useState)(!1),i=(0,Ro.useRef)(null),{getViewport:s,setViewport:a}=(0,fp.useReactFlow)(),l=(0,Ro.useCallback)(()=>{i.current=null,r(!1)},[]);return(0,Ro.useEffect)(()=>{let c=e.current;if(!c)return;let d=m=>{if(!Sr.some(x=>x===m.button)||t.current||o.current||(r(!0),!(m.target instanceof Element))||!m.target.closest(Xh))return;m.preventDefault(),m.stopPropagation();let g=s();i.current={pointerX:m.clientX,pointerY:m.clientY,viewportX:g.x,viewportY:g.y,zoom:g.zoom}},u=m=>{let g=i.current;if(g){if((m.buttons&sa)===0){l();return}a({x:g.viewportX+(m.clientX-g.pointerX),y:g.viewportY+(m.clientY-g.pointerY),zoom:g.zoom})}},p=m=>{(m.buttons&sa)===0&&l()};return c.addEventListener("pointerdown",d,!0),window.addEventListener("pointermove",u),window.addEventListener("pointerup",p),window.addEventListener("pointercancel",l),window.addEventListener("blur",l),()=>{c.removeEventListener("pointerdown",d,!0),window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",l),window.removeEventListener("blur",l)}},[e,t,o,s,a,l]),n}var da=require("react/jsx-runtime"),ds=({id:e,className:t})=>(0,da.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,da.jsx)("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});var sn=require("react/jsx-runtime"),gp=()=>(0,sn.jsx)("svg",{style:{position:"absolute",top:0,left:0},children:(0,sn.jsxs)("defs",{children:[(0,sn.jsx)(ds,{id:"sequence-edge-marker",className:"text-grey-500"}),(0,sn.jsx)(ds,{id:"sequence-edge-marker-hovered",className:"text-grey-800"}),(0,sn.jsx)(ds,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});var Vo=require("@produto-lecom/lecom-ui");var Or=require("@xyflow/react"),Be=require("@produto-lecom/lecom-ui"),eo=require("lucide-react"),yo=require("react");var Do=require("@produto-lecom/lecom-ui");var Rr=(E=>(E.START_EVENT="START_EVENT",E.END_EVENT="END_EVENT",E.TASK="TASK",E.SUBPROCESS="SUBPROCESS",E.GATEWAY="GATEWAY",E.LANE="LANE",E.ANNOTATION="ANNOTATION",E.CONNECTION="CONNECTION",E.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",E.ACTIVITY="ACTIVITY",E.PROCESS_INTERFACE="PROCESS_INTERFACE",E.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",E.VARIANT_ACTIVITY="VARIANT_ACTIVITY",E.AUTO_ACTIVITY="AUTO_ACTIVITY",E.DATA_STORE="DATA_STORE",E.DATA_OBJECT="DATA_OBJECT",E.DATA_OUTPUT="DATA_OUTPUT",E.DATA_INPUT="DATA_INPUT",E.MARKER="MARKER",E))(Rr||{});var ps=require("@produto-lecom/lecom-ui"),Ip=require("@xyflow/react");var hp=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 yp({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let r="data:text/csv;charset=utf-8,"+[e,...t].map(s=>s.join(",")).join(`
43
- `),i=encodeURI(r);us(i,`${o}.csv`)}var us=(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 xp(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}var FC={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},Ep={script:"SCRIPT",subprocess:"SUBPROCESS"},_p={"marker-loop":"LOOP"},bp={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL",inclusive:"EXCLUSIVE"};var an=({cell:e,type:t,variant:o="",attribute:n=""})=>{let{_attributes:r,mxGeometry:i}=e,{value:s,parent:a}=r,l=Number(i._attributes.width),c=Number(i._attributes.height),d=a==="1"?void 0:a;return{id:r.id,parentId:d,type:t,data:{label:s||"",variant:o,attribute:n},position:{x:Number(i._attributes.x)||0,y:Number(i._attributes.y)||0},width:l,height:c,measured:{width:l,height:c}}},$h=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=ue.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=ue.START_EVENT.MIN_HEIGHT,{node:an({cell:e,type:"START_EVENT"}),status:n,originalType:o}},Kh=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=ue.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=ue.END_EVENT.MIN_HEIGHT,{node:an({cell:e,type:"END_EVENT"}),status:n,originalType:o}},qh=(e,t)=>{let{id:o,subType:n,style:r}=e==null?void 0:e._attributes,i=Ep[n],s=t.get(o)||"",a=_p[s]||"",l=a==="LOOP",c="imported";return!["script","none"].includes(n)&&!l&&(c="adapted"),e.mxGeometry._attributes.width=_o(e.mxGeometry._attributes.width||0,ue.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=_o(e.mxGeometry._attributes.height||0,ue.TASK.MIN_HEIGHT),{node:an({cell:e,type:"TASK",variant:i,attribute:a}),status:c,originalType:r}},Zh=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=bp[o],r=["none","inclusive","event-based"],i="imported";return r.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=ue.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=ue.GATEWAY.MIN_HEIGHT,{node:an({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},Jh=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:an({cell:e,type:"LANE"}),status:"imported",originalType:t}},Qh=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=_o(e.mxGeometry._attributes.width||0,ue.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=_o(e.mxGeometry._attributes.height||0,ue.ANNOTATION.MIN_HEIGHT),{node:an({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},Tp=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=ue.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=ue.UNSUPPORTED.MIN_HEIGHT,{node:an({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},vp=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return w(_({},Mt),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},Np={TASK:qh,GATEWAY:Zh,START_EVENT:$h,END_EVENT:Kh,LANE:Jh,ANNOTATION:Qh};var jh=e=>{let t=new Map,o=Object.values(Rr),n=[],r=new Map;e.forEach(a=>{var c;let l=(c=a._attributes)==null?void 0:c.type;if(l==="MARKER"){r.set(a._attributes.parent,a._attributes.style);return}if(o.includes(l)){n.push(a);return}});let i=[],s=[];for(let a of n){let{type:l}=a._attributes,c=Np[l]||Tp,{node:d,status:u,originalType:p}=c(a,r);s.push(d),i.push({originalType:p,type:d.type,variant:d.data.variant,value:xp(d.data.label),status:u})}return{nodes:s,governanceIdToNodeIdMap:t,summary:i}},ey=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>vp(r,t)),ty=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=jh(t.root.mxCell),i=ey(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},oy=async e=>{let t=await hp(e),o=Ki(t);if(!o)throw new Error("EMPTY_FILE");let{metadata:n,mxGraphModel:r}=o.modeler||{},i=(n==null?void 0:n.app)&&(n==null?void 0:n.diagramType)&&(n==null?void 0:n.version),s=r==null?void 0:r.root;if(!i||!s)throw new Error("INVALID_FILE");if(!Object.keys(r.root.mxCell||{}).length)throw new Error("CONTAIN_NO_CELLS");return{metadata:n,mxGraphModel:r}},wp=async e=>{try{let t=await oy(e),{nodes:o,edges:n,summary:r}=ty(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};var Sp=require("react/jsx-runtime"),Ap=()=>{let{t:e}=(0,ps.useTranslation)(),{toast:t}=at(),{setNodes:o,setEdges:n,fitView:r}=(0,Ip.useReactFlow)(),i=a=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],c=a.map(d=>[d.originalType,d.value,e(`adapter.governance.report.status.${d.status.toLowerCase()}`)]);t({variant:"warning",content:e("adapter.governance.success.incompatible_cells"),duration:1e3*60*1,action:(0,Sp.jsx)(ps.Button,{size:"small",variant:"ghost",onClick:()=>yp({columns:l,rows:c,fileName:"governance-imported-cells"}),children:e("adapter.governance.action.download")})})};return{importFromGovernance:async a=>{try{let{nodes:l,edges:c,summary:d}=await wp(a);if(o(p=>p.concat(l)),n(p=>p.concat(c)),r({padding:Bn,minZoom:zn,maxZoom:Yn}),d.some(p=>p.status==="unsupported")){i(d);return}t({variant:"success",content:e("adapter.governance.success.default")})}catch(l){let c=l instanceof Error?l.message:"DEFAULT";t({variant:"error",content:e(`adapter.governance.error.${c}`)})}}}};var Cp=require("@produto-lecom/lecom-ui"),Mp=require("react");var ln=require("react/jsx-runtime"),Pp=a=>{var l=a,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,s=Wt(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=(0,Mp.useRef)(null),d=p=>{let m=p.target.files;m!=null&&m.length&&i(m),c.current&&(c.current.value="")};return(0,ln.jsxs)(ln.Fragment,{children:[(0,ln.jsx)(Cp.Button,w(_({disabled:n,onClick:p=>{var m;(m=c.current)==null||m.click(),r==null||r(p)}},s),{children:e})),(0,ln.jsx)("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};var cn=require("react/jsx-runtime"),Lp=({disabled:e=!1})=>{let{t}=(0,Do.useTranslation)(),{toast:o}=at(),{importFromGovernance:n}=Ap(),r=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},i=s=>{let a=s[0];if(!a){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}n(a)};return(0,cn.jsxs)(Do.Tooltip,{children:[(0,cn.jsx)(Do.TooltipTrigger,{asChild:!0,children:(0,cn.jsx)(Pp,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:(0,cn.jsx)(Ia,{})})}),(0,cn.jsx)(Do.TooltipContent,{color:"black",children:t("editor.controls.actions.import_governance")})]})};var kp=require("react/jsx-runtime"),ua=({shortcut:e})=>(0,kp.jsx)("span",{className:"min-h-7.5 inline-flex justify-center items-center py-0.5 px-1.5 bg-grey-100 border border-grey-300 font-mono text-gray-800 shadow-lg rounded-md text-grey-900",children:e});var Te=require("@produto-lecom/lecom-ui"),Oo=require("lucide-react"),Gp=require("react");var Dp=require("@produto-lecom/lecom-ui"),Op=require("@xyflow/react"),Dr=require("html-to-image"),Vp=require("react");var ny=3,pa="diagram",fs=50,ry=96,iy=25.4,sy="sequence-edge-marker",Rp=e=>e*iy/ry,ay=e=>{let t=document.getElementById(sy);if(!(t instanceof SVGElement)||!t.ownerSVGElement)return null;let n=t.ownerSVGElement.cloneNode(!0);return n.style.position="absolute",n.style.width="0",n.style.height="0",n.style.overflow="hidden",n.setAttribute("aria-hidden","true"),n.setAttribute("data-export-marker-defs","true"),e.prepend(n),n},Hp=()=>{let{t:e}=(0,Dp.useTranslation)(),{toast:t}=at(),{getEdges:o,getNodes:n,getNodesBounds:r}=(0,Op.useReactFlow)(),{clearSelection:i}=Co(),[s,a]=(0,Vp.useState)({png:!1,html:!1,print:!1}),l=()=>{let m=Js(n(),o()),g=r(m),x=g.width+fs*2,f=g.height+fs*2,h=fs-g.x,y=fs-g.y;return{width:x,height:f,style:{width:`${x}px`,height:`${f}px`,transform:`translate(${h}px, ${y}px)`,transformOrigin:"top left"}}},c=async(m,g)=>{a(x=>w(_({},x),{[g]:!0})),await i();try{if(Js(n(),o()).length===0){t({content:e("editor.controls.actions.export.feedback.empty"),variant:"warning"});return}let f=Rd();if(!f)throw new Error("Flow element not found");let h=l(),y=ay(f);try{return await m(f,h)}finally{y==null||y.remove()}}catch(x){console.error("Diagram export failed",x),t({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{a(x=>w(_({},x),{[g]:!1}))}};return{exportAsPng:async(m=pa)=>{await c(async(g,x)=>{let f=await(0,Dr.toPng)(g,w(_({},x),{backgroundColor:"#fcfcfc",skipFonts:!0}));us(f,`${m}.png`)},"png")},exportAsHtml:async(m=pa)=>{await c(async(g,x)=>{let f=await(0,Dr.toSvg)(g,w(_({},x),{backgroundColor:"#fcfcfc",skipFonts:!0})),h=`
38
+ </mxGraphModel>`,Ed=(e,t)=>{if(!e.length&&!t.length)return yr;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var Xi=require("xml-js");var _d={compact:!0,spaces:4},ih=e=>e.replace(/\n/g,"&#xA;");function Ui(e,t=_d){if(e)return JSON.parse((0,Xi.xml2json)(e,t))}function bd(e,t=_d){return e?(0,Xi.json2xml)(e,w(_({},t),{attributeValueFn:ih})):""}var Td={"attribute-loop":"LOOP"},vd={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS","service-task":"SERVICE_TASK"},Nd={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},wd={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed",SERVICE_TASK:"service-task"},Id={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var Dn=(e,t,o,n,r,i)=>{let s=e._attributes.width||0,a=e._attributes.height||0,l=0,c=0;if(n&&r!==void 0&&i!==void 0){let h=n.split(`
39
+ `),E=h.length;l=h.reduce((g,y)=>Math.max(g,y.length),0)*7+r,c=E*20+i}let d=Math.max(Eo(Number(s),t),l),u=Math.max(Eo(Number(a),o),c);return{width:d,height:u,measured:{width:d,height:u}}},On=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,parent:r,value:i}=t,s={x:Number(o._attributes.x||0),y:Number(o._attributes.y||0)},a={id:n,position:s,data:{label:i||""}},l=r==="1"?void 0:r;return l&&(a.parentId=l),a},ah=e=>{let{mxGeometry:t}=e,o=On(e),n=Dn(t,ue.START_EVENT.MIN_WIDTH,ue.START_EVENT.MIN_HEIGHT);return w(_(_({},o),n),{type:"START_EVENT"})},lh=e=>{let{mxGeometry:t}=e,o=On(e),n=Dn(t,ue.END_EVENT.MIN_WIDTH,ue.END_EVENT.MIN_HEIGHT);return w(_(_({},o),n),{type:"END_EVENT"})},$i=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=On(e),a=Dn(n,ue.TASK.MIN_WIDTH,ue.TASK.MIN_HEIGHT,r.data.label,48,24),l=t==null?void 0:t.find(d=>{let{parent:u}=d._attributes;return u===e._attributes.id});if(l){let{style:d}=l._attributes,u=Td[d];u&&(r.data.attribute=u)}let c=vd[o.style];return c&&(r.data.variant=c),w(_(_({},r),a),{type:"TASK"})},Ks=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=On(e),i=Dn(o,ue.GATEWAY.MIN_WIDTH,ue.GATEWAY.MIN_HEIGHT);return r.data.variant=Nd[n],w(_(_({},r),i),{type:"GATEWAY"})},ch=e=>{let{mxGeometry:t}=e,o=On(e),i=Dn(t,ue.ANNOTATION.MIN_WIDTH,ue.ANNOTATION.MIN_HEIGHT,o.data.label,32,24);return w(_(_({},o),i),{type:"ANNOTATION"})},dh=e=>{let{mxGeometry:t}=e,o=On(e),n=Dn(t,ue.LANE.MIN_WIDTH,ue.LANE.MIN_HEIGHT);return w(_(_({},o),n),{type:"LANE"})},Ad={task:$i,"task-script":$i,"subprocess-collapsed":$i,"service-task":$i,"start-event":ah,"end-event-terminate":lh,"gateway-parallel":Ks,"gateway-exclusive":Ks,"gateway-complex":Ks,annotation:ch,lane:dh},uh=e=>{if(e&&Array.isArray(e))return e.map(t=>({x:Number(t._attributes.x),y:Number(t._attributes.y)}))},Sd=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,source:r,target:i,value:s,style:a,sourceHandle:l,targetHandle:c,sourceOffset:d,targetOffset:u,labelOffsetX:f,labelOffsetY:m}=t,h=uh(o==null?void 0:o.Array),E=d!==void 0?Number(d):void 0,p=u!==void 0?Number(u):void 0,g=f!==void 0?Number(f):void 0,y=m!==void 0?Number(m):void 0,x=w(_(_({id:n,source:r,target:i},l?{sourceHandle:l}:{}),c?{targetHandle:c}:{}),{data:_(_(_(_({label:s||""},h&&h.length>0?{points:h}:{}),E!==void 0?{sourceOffset:E}:{}),p!==void 0?{targetOffset:p}:{}),g!==void 0&&y!==void 0?{labelOffset:{x:g,y}}:{})});return a.includes("association")&&a.includes('endArrow=""')?_(_({},kn),x):_(_({},Mt),x)},Cd=(e,t)=>{var m,h;let{id:o,type:n,source:r,target:i,sourceHandle:s,targetHandle:a,data:l}=e,c=t==null?void 0:t.find(E=>E.id===r),d="";n==="ANNOTATION_EDGE"&&(d='association;endArrow=""');let u={_attributes:{as:"geometry",relative:"1"}};return l!=null&&l.points&&Array.isArray(l.points)&&l.points.length>0&&(u.Array=l.points.map(E=>({_attributes:{as:"mxPoint",x:E.x,y:E.y}}))),{_attributes:{id:o,parent:(c==null?void 0:c.parentId)||"1",edge:"1",style:d,source:r,target:i,value:(l==null?void 0:l.label)||"",sourceHandle:s!=null?s:void 0,targetHandle:a!=null?a:void 0,sourceOffset:(l==null?void 0:l.sourceOffset)!==void 0?String(l.sourceOffset):void 0,targetOffset:(l==null?void 0:l.targetOffset)!==void 0?String(l.targetOffset):void 0,labelOffsetX:((m=l==null?void 0:l.labelOffset)==null?void 0:m.x)!==void 0?String(l.labelOffset.x):void 0,labelOffsetY:((h=l==null?void 0:l.labelOffset)==null?void 0:h.y)!==void 0?String(l.labelOffset.y):void 0},mxGeometry:u}},Vn=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}}}},ph=e=>{let{variant:t}=e.data,o=Vn(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:wd[t]||"task"})})},fh=e=>{let t=Vn(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"start-event"})})},mh=e=>{let t=Vn(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"end-event-terminate"})})},gh=e=>{let{variant:t}=e.data,o=Vn(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:Id[t]})})},hh=e=>{let t=Vn(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"lane"})})},yh=e=>{let t=Vn(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"annotation"})})},Md={TASK:ph,START_EVENT:fh,END_EVENT:mh,GATEWAY:gh,ANNOTATION:yh,LANE:hh},Pd=(e,t)=>{var s,a;let r=((s=e.measured)==null?void 0:s.width)||0,i=((a=e.measured)==null?void 0:a.height)||0;return{_attributes:{id:`${t+1}`,parent:e.id,style:"attribute-loop",connectable:"0"},mxGeometry:{_attributes:{as:"geometry",x:r/2-22/2,y:i-22,width:22,height:22}}}};var xh=e=>{let t=Object.values(hr),o=e.filter(i=>{var a;let s=(a=i._attributes)==null?void 0:a.style;return t.includes(s)}),n=e.filter(i=>{var a;let s=(a=i._attributes)==null?void 0:a.style;return["attribute-loop"].includes(s)}),r=[];for(let i of o){let{style:s}=i._attributes,a=Ad[s],l=a==null?void 0:a(i,n);if(!l){console.warn(`Node ${s} not supported`);continue}r.push(l)}return r},Eh=(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=Sd(r),s=t.find(c=>c.id===i.source),a=t.find(c=>c.id===i.target);((s==null?void 0:s.type)==="LANE"||(a==null?void 0:a.type)==="LANE")&&i.type!=="ANNOTATION_EDGE"||n.push(i)}return n},_h=(e,t)=>{let o=[];return e.forEach(n=>{var s,a;let r=(a=(s=Md)[n.type])==null?void 0:a.call(s,n);if(!r){console.warn(`Node ${n.type} not supported`);return}if(o.push(r),n.type==="TASK"&&n.data.attribute==="LOOP"){let l=Pd(n,t);o.push(l)}}),o},bh=(e,t)=>{let o=[];return e.forEach(n=>{let r=Cd(n,t);o.push(r)}),o},Th=(e=[],t=[],o)=>{let n=_h(e,o),r=bh(t,e);return{mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}}},Ld=(e=[],t=[],o)=>{let n=Th(e,t,o);return bd(JSON.stringify(n),{compact:!0,spaces:0})},kd=async e=>{var s,a,l,c,d;let t=await Ui(e),o=((a=(s=t==null?void 0:t.mxGraphModel)==null?void 0:s.root)==null?void 0:a.mxCell)||[],n=Number(((d=(c=(l=t==null?void 0:t.mxGraphModel)==null?void 0:l.root)==null?void 0:c._attributes)==null?void 0:d.lastId)||yr),r=xh(o),i=Eh(o,r);return{lastElementId:n,edges:i,nodes:r}};var ns=require("@xyflow/react"),vu=require("react");var gt=require("@xyflow/react"),ji=require("react");var xr=require("@xyflow/react");var qs=require("react/jsx-runtime"),ne=i=>{var s=i,{type:e,position:t,className:o,nodeType:n}=s,r=Wt(s,["type","position","className","nodeType"]);let a=n==="TASK";return(0,qs.jsx)(xr.Handle,_({type:e,position:t,className:H("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":a,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":!a},o)},r))},tt=a=>{var l=a,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,s=Wt(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=(0,xr.useReactFlow)(),f=(()=>{if(n!=="source")return!1;let m=c();if(t==="TASK")return m.filter(E=>E.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return m.filter(E=>E.source===e).length>=2;if(t==="START_EVENT"){let h=d();return m.filter(p=>{if(p.source!==e)return!1;let g=h.find(y=>y.id===p.target);return(g==null?void 0:g.type)!=="ANNOTATION"}).length>=1}return!1})();return(0,qs.jsx)(xr.Handle,_({type:n,position:r,className:H("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":f,"hover:border-grey-500":!f},i),style:{pointerEvents:f?"none":"auto"}},s))};var Qs=require("react"),uo=require("@xyflow/react");var Rd=require("@xyflow/react"),Ki=()=>{let e=(0,Rd.useStoreApi)();return{getInternalNodes:()=>{let{nodeLookup:o}=e.getState();return Array.from(o.values())}}};var Zs=gf(require("@dagrejs/dagre"),1),Er=require("@xyflow/react");var Od=(e=[],t=[],o="LR")=>{let n=new Zs.default.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:i,width:s,height:a})=>n.setNode(i,{width:s,height:a})),t.forEach(i=>n.setEdge(i.source,i.target)),Zs.default.layout(n),{nodes:e.map(i=>{let s=n.node(i.id);return w(_({},i),{position:{x:s.x-i.width/2,y:s.y-i.height/2}})}),edges:t}},Po=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId);if(t.length===0)return e;let o=Oa(e);for(let n of t){let r=[...o.values()],i=r.filter(a=>a.parentId===n.id);if(i.length===0)continue;let s=i.filter(a=>a.type==="LANE");if(s.length>0){Ya(s,o,r),Wa(n,o);continue}Ns(n,i,o)}return Va(e,o)};var Vd=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)};var vh=500;var Nh=e=>e.type==="LANE"&&!e.parentId,wh=(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},Ih=(e,t)=>{let o=e.x+e.width,n=e.y+e.height,r=t.x+t.width,i=t.y+t.height,s=Math.max(e.x-r,t.x-o,0),a=Math.max(e.y-i,t.y-n,0);return Math.hypot(s,a)},Ah=e=>{let t=new Set;for(let o of e)t.add(o.source),t.add(o.target);return t},Dd=(e,t,o)=>{if(e.type!=="ANNOTATION"||o.has(e.id))return!1;let n=(0,Er.getNodesBounds)([e]);return Ih(t,n)>vh},Js=(e,t=[])=>{var E;let o=e.filter(Nh);if(o.length===0)return e;let n=new Map;for(let p of e){if(!p.parentId)continue;let g=(E=n.get(p.parentId))!=null?E:[];g.push(p.id),n.set(p.parentId,g)}let r=new Set,i=o.map(p=>p.id);for(;i.length>0;){let p=i.pop();if(!p||r.has(p))continue;r.add(p);let g=n.get(p);if(g)for(let y of g)r.has(y)||i.push(y)}let s=e.filter(p=>r.has(p.id));if(s.length===0)return e;let a=Ah(t),l=s.filter(p=>p.type!=="ANNOTATION"),c=(0,Er.getNodesBounds)(l.length>0?l:s),d=s.filter(p=>!Dd(p,c,a)),u=(0,Er.getNodesBounds)(d),h=e.filter(p=>!r.has(p.id)).filter(p=>{let g=(0,Er.getNodesBounds)([p]);return!wh(u,g)}).filter(p=>!Dd(p,u,a));return[...d,...h]};var qi=require("react/jsx-runtime"),js=require("react"),Sh=["top","right","bottom","left"],Ch=["top-left","top-middle","top-right","right-middle","bottom-left","left-middle","bottom-right","bottom-middle"],Pt=r=>{var i=r,{nodeId:e,isVisible:t,offset:o=8}=i,n=Wt(i,["nodeId","isVisible","offset"]);let{getInternalNode:s,setNodes:a}=(0,uo.useReactFlow)(),{getInternalNodes:l}=Ki(),{isMultipleSelection:c}=q(),d=(0,uo.useStoreApi)(),u=(0,Qs.useRef)(0),f=(0,Qs.useRef)([]),m=({y:g,width:y,height:x})=>{cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{var Q,j;if(!e)return;let{nodeLookup:N,onNodesChange:b}=d.getState(),v=N.get(e);if(!v||v.type!=="LANE")return;let T=!v.parentId,I=T?v.id:v.parentId;if(!I)return;let S=Array.from(N.values()).filter(z=>z.type==="LANE"&&z.parentId===I);if(!S.length)return;f.current.length===0&&(f.current=Wo(S).map(z=>z.id));let P=f.current.map(z=>S.find(M=>M.id===z)).filter(Boolean),R=[],C=0,L=P.findIndex(z=>z.id===v.id),K=!T&&L>0&&Math.abs(g-v.position.y)>.5;for(let z=0;z<P.length;z++){let M=P[z],V=M.id===v.id,D=z===P.length-1;if(V){C=K?g+x:C+x;continue}let A=(j=(Q=M.measured)==null?void 0:Q.height)!=null?j:0,B=T?y-ae.HEADER_WIDTH:y,G=A;T&&D&&(G=Math.max(ae.MIN_HEIGHT,x-C)),K&&z===L-1&&(G=Math.max(ae.MIN_HEIGHT,g-C)),R.push({id:M.id,type:"dimensions",dimensions:{width:B,height:G},setAttributes:!0}),R.push({id:M.id,type:"position",position:{x:ae.HEADER_WIDTH,y:C}}),C+=G}T?R.push({id:I,type:"dimensions",dimensions:{width:y,height:x},setAttributes:!0}):R.push({id:I,type:"dimensions",dimensions:{width:y+ae.HEADER_WIDTH,height:C},setAttributes:!0}),b==null||b(R)})},h=({y:g,width:y,height:x})=>{var v;if(cancelAnimationFrame(u.current),f.current=[],!e)return;let N=s(e);if(!N||N.type!=="LANE"&&!N.parentId)return;let b=[...l()];if(N.type!=="LANE"){b=b.map(T=>T.id===e?w(_({},T),{width:y,height:x,measured:{width:y,height:x}}):T),b=Po(b),a(b);return}b=Fa(N,y,x,b,g),b=Po(b),b=Yo((v=N.parentId)!=null?v:N.id,b),a(b)};if(!(!c&&t))return null;let p={"--resize-offset":`${o}px`};return(0,qi.jsxs)(qi.Fragment,{children:[Sh.map(g=>(0,js.createElement)(uo.NodeResizeControl,w(_({},n),{key:g,nodeId:e,position:g,variant:uo.ResizeControlVariant.Line,className:"border-blue-400/90 border-dashed",style:p,onResize:(y,x)=>m(x),onResizeEnd:(y,x)=>h(x)}))),Ch.map(g=>(0,js.createElement)(uo.NodeResizeControl,w(_({},n),{key:g,nodeId:e,position:g,className:"size-1.5 bg-blue-400 relative before:content-[''] before:absolute before:w-5 before:h-5 before:left-1/2 before:top-1/2 before:-translate-x-1/2 before:-translate-y-1/2 before:cursor-[inherit]",style:p,onResize:(y,x)=>m(x),onResizeEnd:(y,x)=>h(x)})))]})};var Qi=require("@xyflow/react"),Jt=require("@produto-lecom/lecom-ui"),mt=require("react");var Hd=require("zustand"),Hn=(0,Hd.create)(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));var Zi=require("react"),Gd=(e,t=!1)=>{let[o,n]=(0,Zi.useState)({width:0,height:0});return(0,Zi.useEffect)(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};var Lo=require("@xyflow/react"),Bd=require("react"),Mh=120,Ph=12,zd=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=(0,Lo.useReactFlow)(),{instanceId:i}=q();return(0,Bd.useMemo)(()=>{var m,h;if(!t)return{position:Lo.Position.Right,align:"start"};let s=n(e);if(!s)return{position:Lo.Position.Right,align:"start"};let a=r(),l=s.position.x*a.zoom+a.x,c=(((m=s.measured)==null?void 0:m.width)||s.width||100)*a.zoom,d=(h=document.getElementById(`modeler-${i}`))==null?void 0:h.clientWidth;if(!d)return{position:Lo.Position.Right,align:"start"};let u=(o==null?void 0:o.width)||Mh;return{position:l+c+u+Ph>d?Lo.Position.Left:Lo.Position.Right}},[i,e,t,o,n,r])};var ea=require("lucide-react");var Ji=require("@xyflow/react"),be=require("@produto-lecom/lecom-ui"),Yd=require("lucide-react");var Pe=require("react/jsx-runtime"),Wd=({nodeId:e})=>{let{t}=(0,be.useTranslation)(),{updateNodeData:o,getEdges:n,getNode:r}=(0,Ji.useReactFlow)(),i=(0,Ji.useNodesData)(e),a=n().filter(h=>h.source===e).some(h=>{let E=r(h.target);return(E==null?void 0:E.type)==="END_EVENT"}),l=(i==null?void 0:i.data.variant)==="SUBPROCESS",c=(i==null?void 0:i.data.variant)==="SERVICE_TASK",d=f=>{o(e,{variant:(i==null?void 0:i.data.variant)===f?"":f})},u=f=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===f?"":f})};return(0,Pe.jsxs)(be.DropdownMenu,{children:[(0,Pe.jsxs)(be.Tooltip,{children:[(0,Pe.jsx)(be.TooltipTrigger,{asChild:!0,children:(0,Pe.jsx)(be.DropdownMenuTrigger,{asChild:!0,children:(0,Pe.jsx)(be.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:(0,Pe.jsx)(Yd.WrenchIcon,{})})})}),(0,Pe.jsx)(be.TooltipContent,{color:"black",children:t("bpmn.task.menu.title")})]}),(0,Pe.jsxs)(be.DropdownMenuContent,{align:"start",className:"w-60 bg-white text-grey-600",children:[(0,Pe.jsxs)(be.DropdownMenuLabel,{className:"flex items-center gap-1",children:[(0,Pe.jsx)("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),(0,Pe.jsx)("div",{className:"flex items-center gap-1",children:Object.entries(Ur).map(([f,m])=>{let h=f==="LOOP"&&(a||l||c),p=(()=>{if(f==="LOOP"&&a)return t("editor.task_menu.loop_not_allowed_when_connected_to_end");if(f==="LOOP"&&l)return t("editor.task_menu.loop_not_allowed_when_subprocess");if(f==="LOOP"&&c)return t("editor.task_menu.loop_not_allowed_when_service_task");if(f==="LOOP")return t("editor.task_menu.loop")})();return(0,Pe.jsxs)(be.Tooltip,{children:[(0,Pe.jsx)(be.TooltipTrigger,{asChild:!0,children:(0,Pe.jsx)(be.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:h,className:H({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===f,"opacity-50 cursor-not-allowed":h}),onClick:h?void 0:()=>u(f),children:(0,Pe.jsx)(m.icon,{className:"stroke-inherit"})})}),p&&(0,Pe.jsx)(be.TooltipContent,{color:"black",children:p})]},f)})})]}),(0,Pe.jsx)(be.DropdownMenuGroup,{children:(0,Pe.jsxs)(be.Tooltip,{children:[(0,Pe.jsx)(be.TooltipTrigger,{asChild:!0,children:(0,Pe.jsx)("div",{className:H({"cursor-not-allowed":a}),children:(0,Pe.jsxs)(be.DropdownMenuItem,{className:H({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":a}),disabled:a,onClick:()=>d("SCRIPT"),children:[(0,Pe.jsx)(Xr.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),a&&(0,Pe.jsx)(be.TooltipContent,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};var Oe=require("react/jsx-runtime"),po={START_EVENT:{type:"START_EVENT",icon:Kn,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:un,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:Kn,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:zr,label:"bpmn.annotation.variant.default"}},Lh={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:mn,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:hn,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:pn,label:"bpmn.gateway.variant.complex"}},lt=({nodeId:e,nodeType:t,nodeVariant:o,isChild:n})=>{let r=(0,mt.useRef)(null),i=(0,mt.useRef)(null),{t:s}=(0,Jt.useTranslation)(),{setDraggableNode:a}=Hn(),{getEdges:l,getNodes:c,getNode:d,setNodes:u}=(0,Qi.useReactFlow)(),{setIsDragging:f,mode:m,isConnecting:h,isDragging:E,isMultipleSelection:p}=q(),g=d(e),y=!!(g!=null&&g.selected)&&!g.dragging&&!h&&!E&&!p,{dimensions:x}=Gd(r,y),{position:N}=zd(e,y,x),[b,v]=(0,mt.useState)(void 0),T=c(),I=l(),S=o==="SUBPROCESS",P=o==="SERVICE_TASK",R=(0,mt.useRef)(null),C=(0,mt.useRef)(!1),L=(0,mt.useCallback)(()=>{R.current!==null&&(clearTimeout(R.current),R.current=null),C.current=!1,f(!1),a(null),v(void 0),u(W=>W.map(U=>w(_({},U),{className:void 0})))},[f,a,u]);(0,mt.useEffect)(()=>{let W=U=>{C.current&&U.buttons===0&&L()};return document.addEventListener("dragend",L),document.addEventListener("mousemove",W),()=>{document.removeEventListener("dragend",L),document.removeEventListener("mousemove",W)}},[L]);let K=(0,mt.useCallback)((W,U)=>{C.current=!0,f(!1),a({type:U.type,variant:U.variant,attribute:U.attribute,icon:U.icon}),U.icon&&v((0,Oe.jsx)(U.icon,{})),W.dataTransfer.effectAllowed="move",W.dataTransfer.setData("sourceId",e),i.current&&W.dataTransfer.setDragImage(i.current,10,10),R.current=setTimeout(()=>{R.current=null,f(!0)},100)},[e,a,f]),Q=(0,mt.useCallback)(()=>{L()},[L]),j=[{component:(0,Oe.jsx)(Di,{elementId:e})}],z=()=>{if(m==="view")return[];let W=!I.some(U=>{var X;return U.source===e&&((X=T.find($=>$.id===U.target))==null?void 0:X.type)!=="ANNOTATION"});return[{component:(0,Oe.jsx)(Cn,{nodeId:e,disabled:!W,tooltipMessage:W?void 0:s("editor.toolbar.start_event_limit_reached")})},po.TASK,po.ANNOTATION,...j]},M=()=>m==="view"?[{component:(0,Oe.jsx)(Co,{elementId:e})}]:[{component:(0,Oe.jsx)(Co,{elementId:e})},...S||P?[]:[{component:(0,Oe.jsx)(Wd,{nodeId:e})}],{component:(0,Oe.jsx)(Cn,{nodeId:e})},po.TASK,{type:"TASK",variant:"SUBPROCESS",icon:qn,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:ea.Bot,label:"bpmn.task.variant.service_task"},po.ANNOTATION,...Object.values(Lh),...Zo(e,T,I)?[]:[po.END_EVENT],...j],V=()=>m==="view"?[{component:(0,Oe.jsx)(Co,{elementId:e,elementType:"gateway"})}]:[{component:(0,Oe.jsx)(Co,{elementId:e,elementType:"gateway"})},{component:(0,Oe.jsx)(Cn,{nodeId:e})},po.TASK,{type:"TASK",variant:"SUBPROCESS",icon:qn,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:ea.Bot,label:"bpmn.task.variant.service_task"},po.ANNOTATION,...j],D=()=>m==="view"?[]:[po.ANNOTATION,...j],A=()=>m==="view"?[]:[...n?[]:[{component:(0,Oe.jsx)(Cn,{nodeId:e})}],po.ANNOTATION,...j],B=()=>m==="view"?[]:[{component:(0,Oe.jsx)(Cn,{nodeId:e})},...j],G=()=>m==="view"?[]:[...j],O=(W=>{switch(W){case"START_EVENT":return z();case"TASK":return M();case"GATEWAY":return V();case"END_EVENT":return D();case"LANE":return A();case"ANNOTATION":return B();case"UNSUPPORTED":return G();default:return[]}})(t),Y=O.length>6;if(!(O.length===0||m==="readonly"))return(0,Oe.jsxs)(Qi.NodeToolbar,{position:N,align:"start",className:Y?"-top-[4.5rem]":"-top-8",isVisible:y,children:[(0,Oe.jsx)("div",{ref:r,className:`${Y?"grid grid-cols-6":"flex"} gap-1 px-2 py-2 bg-white rounded-sm shadow-md`,children:O.map((W,U)=>{if(W.component)return(0,Oe.jsx)("div",{children:W.component},U);let X={sourceNodeType:t,targetNodeType:W.type,sourceNodeId:e,nodes:T,edges:I},$=Jc(X),te={gateway_limit_reached:s("editor.toolbar.gateway_limit_reached"),start_event_limit_reached:s("editor.toolbar.start_event_limit_reached"),start_event_already_exists:s("editor.toolbar.start_event_already_exists"),script_to_end_not_allowed:s("editor.toolbar.script_to_end_not_allowed"),loop_to_end_not_allowed:s("editor.toolbar.loop_to_end_not_allowed"),initial_activity_to_end_not_allowed:s("editor.toolbar.initial_activity_to_end_not_allowed"),final_activity_cannot_connect:s("editor.toolbar.final_activity_cannot_connect"),activity_has_outgoing_connections:s("editor.toolbar.activity_has_outgoing_connections"),task_limit_reached:s("editor.toolbar.task_limit_reached"),start_event_to_service_task_not_allowed:s("editor.toolbar.start_event_to_service_task_not_allowed"),service_task_to_end_not_allowed:s("editor.toolbar.service_task_to_end_not_allowed")},ie=$.shouldDisable&&$.reason?te[$.reason]||s(W.label):s(W.label)||"";return(0,Oe.jsxs)(Jt.Tooltip,{children:[(0,Oe.jsx)(Jt.TooltipTrigger,{asChild:!0,children:(0,Oe.jsx)(Jt.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!$.shouldDisable,disabled:$.shouldDisable,className:$.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:$.shouldDisable?void 0:F=>K(F,W),onDragEnd:$.shouldDisable?void 0:Q,children:W.icon&&(0,Oe.jsx)(W.icon,{size:16})})}),(0,Oe.jsx)(Jt.TooltipContent,{color:"black",children:ie})]},U)})}),(0,Oe.jsx)("div",{ref:i,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:b})]})};var Ke=require("react/jsx-runtime"),Fd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r,setNodes:i}=(0,gt.useReactFlow)(),{inProgress:s,fromNode:a}=(0,gt.useConnection)(),{mode:l,isReadOnly:c}=q(),d=s&&(a==null?void 0:a.id)!==e,u=(0,ji.useCallback)(h=>{let x=h.split(`
40
+ `),N=x.reduce((I,S)=>Math.max(I,S.length),0),b=x.length,v=Math.max(_n.MIN_WIDTH,N*7+32),T=Math.max(_n.MIN_HEIGHT,b*20+24);i(I=>I.map(S=>S.id===e?w(_({},S),{width:v,height:T,style:w(_({},S.style),{width:v,height:T})}):S))},[e,i]),f=(0,ji.useCallback)(h=>{r(e,{label:h}),u(h)},[e,r,u]),m=(0,ji.useCallback)(h=>{u(h)},[u]);return(0,Ke.jsxs)("div",{className:H("relative w-full h-full min-w-44 min-h-16 flex text-grey-400 hover:text-grey-500 bg-white rounded-sm border-l-2 border-current before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-current after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-current hover:shadow-md transition-colors duration-75",{"pointer-events-none":c,"text-blue-500 hover:text-blue-600 shadow-md":o&&!c,"border-red-500 border-l-[3px] shadow-[0_0_5px_rgba(255,0,0,0.5)] before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-red-500 after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-red-500":t.hasError}),children:[(0,Ke.jsx)(Qe,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:f,onInput:m,skipFirstCharValidation:!0}),(0,Ke.jsx)(lt,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&(0,Ke.jsx)(Pt,{nodeId:e,minWidth:_n.MIN_WIDTH,minHeight:_n.MIN_HEIGHT,isVisible:!n&&o}),!s&&(0,Ke.jsxs)(Ke.Fragment,{children:[(0,Ke.jsx)(ne,{type:"source",position:gt.Position.Left,id:"left"}),(0,Ke.jsx)(ne,{type:"source",position:gt.Position.Right,id:"right"}),(0,Ke.jsx)(ne,{type:"source",position:gt.Position.Top,id:"top"}),(0,Ke.jsx)(ne,{type:"source",position:gt.Position.Bottom,id:"bottom"})]}),(!s||d)&&(0,Ke.jsxs)(Ke.Fragment,{children:[(0,Ke.jsx)(ne,{type:"target",position:gt.Position.Left,id:"left",className:H({"annotation-handle":d})}),(0,Ke.jsx)(ne,{type:"target",position:gt.Position.Right,id:"right",className:H({"annotation-handle":d})}),(0,Ke.jsx)(ne,{type:"target",position:gt.Position.Top,id:"top",className:H({"annotation-handle":d})}),(0,Ke.jsx)(ne,{type:"target",position:gt.Position.Bottom,id:"bottom",className:H({"annotation-handle":d})})]})]})};var ht=require("@xyflow/react"),Xd=require("react");var We=require("react/jsx-runtime"),Ud=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=(0,ht.useReactFlow)(),{inProgress:i,fromNode:s}=(0,ht.useConnection)(),{mode:a,isReadOnly:l,reconnectingEdgeId:c}=q(),[d,u]=(0,Xd.useState)(!1),f=i&&(s==null?void 0:s.id)!==e||!!c,m=p=>{r(e,{label:p})},h=()=>{u(!0)},E=()=>{u(!1)};return(0,We.jsxs)("div",{className:"relative",onDoubleClick:h,children:[(0,We.jsx)(un,{className:H("w-full h-full min-w-9 min-h-9 hover:stroke-[#d33b3b] transition-colors duration-75",{"pointer-events-none":l,"stroke-blue-500 hover:stroke-blue-600":o&&!l,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),(0,We.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,We.jsx)(Qe,{value:t.label,isEditing:d,onBlur:E,onChange:m})}),(0,We.jsx)(lt,{nodeId:e,nodeType:"END_EVENT"}),a==="edit"&&(0,We.jsx)(Pt,{nodeId:e,isVisible:!n&&o,minWidth:Kr.MIN_WIDTH,minHeight:Kr.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||f)&&(0,We.jsxs)(We.Fragment,{children:[(0,We.jsx)(ne,{type:"target",position:ht.Position.Left,id:"left",className:H({"event-handle":f})}),(0,We.jsx)(ne,{type:"target",position:ht.Position.Right,id:"right",className:H({"event-handle":f})}),(0,We.jsx)(ne,{type:"target",position:ht.Position.Top,id:"top",className:H({"event-handle":f})}),(0,We.jsx)(ne,{type:"target",position:ht.Position.Bottom,id:"bottom",className:H({"event-handle":f})})]}),!i&&(0,We.jsxs)(We.Fragment,{children:[(0,We.jsx)(ne,{type:"source",position:ht.Position.Left,id:"left"}),(0,We.jsx)(ne,{type:"source",position:ht.Position.Right,id:"right"}),(0,We.jsx)(ne,{type:"source",position:ht.Position.Top,id:"top"}),(0,We.jsx)(ne,{type:"source",position:ht.Position.Bottom,id:"bottom"})]})]})};var yt=require("@xyflow/react"),es=require("react");var Fe=require("react/jsx-runtime"),$d=({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let s=Ts[t.variant].icon,{updateNodeData:a}=(0,yt.useReactFlow)(),{inProgress:l,fromNode:c}=(0,yt.useConnection)(),{mode:d,isReadOnly:u,reconnectingEdgeId:f}=q(),[m,h]=(0,es.useState)(!1),E=l&&(c==null?void 0:c.id)!==e||!!f,p=(0,es.useCallback)(x=>{a(e,{label:x})},[e,a]),g=()=>{h(!0)},y=()=>{h(!1)};return(0,Fe.jsxs)("div",{className:"relative",style:{width:o!=null?o:En.MIN_WIDTH,height:n!=null?n:En.MIN_HEIGHT},onDoubleClick:g,children:[(0,Fe.jsx)(s,{className:H("w-full h-full min-w-14 min-h-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"pointer-events-none":u,"stroke-blue-500 hover:stroke-blue-600":r&&!u,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),(0,Fe.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,Fe.jsx)(Qe,{value:t.label,isEditing:m,onBlur:y,onChange:p})}),(0,Fe.jsx)(lt,{nodeId:e,nodeType:"GATEWAY",nodeVariant:t.variant}),d==="edit"&&(0,Fe.jsx)(Pt,{nodeId:e,isVisible:!i&&r,minWidth:En.MIN_WIDTH,minHeight:En.MIN_HEIGHT,offset:2,keepAspectRatio:!0}),(!l||E)&&(0,Fe.jsxs)(Fe.Fragment,{children:[(0,Fe.jsx)(ne,{type:"target",position:yt.Position.Left,id:"left",className:H({"gateway-handle":E})}),(0,Fe.jsx)(ne,{type:"target",position:yt.Position.Right,id:"right",className:H({"gateway-handle":E})}),(0,Fe.jsx)(ne,{type:"target",position:yt.Position.Top,id:"top",className:H({"gateway-handle":E})}),(0,Fe.jsx)(ne,{type:"target",position:yt.Position.Bottom,id:"bottom",className:H({"gateway-handle":E})})]}),!l&&(0,Fe.jsxs)(Fe.Fragment,{children:[(0,Fe.jsx)(tt,{type:"source",position:yt.Position.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,Fe.jsx)(tt,{type:"source",position:yt.Position.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,Fe.jsx)(tt,{type:"source",position:yt.Position.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,Fe.jsx)(tt,{type:"source",position:yt.Position.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})};var Kd=require("@xyflow/react"),Vt=require("@produto-lecom/lecom-ui"),kh=require("lucide-react");var qd=require("react/jsx-runtime");var xt=require("@xyflow/react"),Zd=require("react");var Xe=require("react/jsx-runtime"),Jd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=(0,xt.useReactFlow)(),{inProgress:i,fromNode:s}=(0,xt.useConnection)(),{mode:a,isReadOnly:l,reconnectingEdgeId:c}=q(),[d,u]=(0,Zd.useState)(!1),f=i&&(s==null?void 0:s.id)!==e||!!c,m=p=>{r(e,{label:p})},h=()=>{u(!0)},E=()=>{u(!1)};return(0,Xe.jsxs)("div",{className:"relative",onDoubleClick:h,children:[(0,Xe.jsx)(Fr,{className:H("w-full h-full min-w-9 min-h-9 hover:stroke-[#54890b] transition-colors duration-75",{"pointer-events-none":l,"stroke-blue-500 hover:stroke-blue-600":o&&!l,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),(0,Xe.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,Xe.jsx)(Qe,{value:t.label,isEditing:d,onBlur:E,onChange:m})}),(0,Xe.jsx)(lt,{nodeId:e,nodeType:"START_EVENT"}),a==="edit"&&(0,Xe.jsx)(Pt,{nodeId:e,isVisible:!n&&o,minWidth:$r.MIN_WIDTH,minHeight:$r.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||f)&&(0,Xe.jsxs)(Xe.Fragment,{children:[(0,Xe.jsx)(ne,{type:"target",position:xt.Position.Left,id:"left",className:H({"event-handle":f})}),(0,Xe.jsx)(ne,{type:"target",position:xt.Position.Right,id:"right",className:H({"event-handle":f})}),(0,Xe.jsx)(ne,{type:"target",position:xt.Position.Top,id:"top",className:H({"event-handle":f})}),(0,Xe.jsx)(ne,{type:"target",position:xt.Position.Bottom,id:"bottom",className:H({"event-handle":f})})]}),!i&&(0,Xe.jsxs)(Xe.Fragment,{children:[(0,Xe.jsx)(tt,{type:"source",position:xt.Position.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),(0,Xe.jsx)(tt,{type:"source",position:xt.Position.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),(0,Xe.jsx)(tt,{type:"source",position:xt.Position.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),(0,Xe.jsx)(tt,{type:"source",position:xt.Position.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};var tu=require("@produto-lecom/lecom-ui"),Et=require("@xyflow/react"),vr=require("react");var _r=60,ts=(e,t)=>{var s;let o=[],n=`${t} `;for(let a of e){if(!(a.type==="TASK"))continue;let c=(s=a.data)==null?void 0:s.label;if(c&&c.startsWith(n)){let d=c.substring(n.length);/^\d{1,15}$/.test(d)&&o.push(parseInt(d,10))}}let r=o.length>0?Math.max(...o)+1:1,i=`${t} ${r}`;return i.length<=_r?i:i.substring(0,_r).trim()},Gn=(e,t)=>{var a;let o=new Set;for(let l of t)l.type==="TASK"&&((a=l.data)!=null&&a.label)&&o.add(l.data.label);let n=e;if(n.length>_r&&(n=n.substring(0,_r).trim()),!o.has(n))return n;let r=n.replace(/\s+\(\d+\)$/,""),i=2,s=o.size+2;for(;i<=s;){let l=` (${i})`,c=_r-l.length,u=`${r.substring(0,c).trim()}${l}`;if(!o.has(u))return u;i++}return n};var br=require("react/jsx-runtime"),Qd=e=>(0,br.jsxs)("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[(0,br.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),(0,br.jsx)("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));var ta=require("react/jsx-runtime"),jd=e=>(0,ta.jsx)("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:(0,ta.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 Tr=require("react/jsx-runtime"),eu=e=>(0,Tr.jsxs)("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[(0,Tr.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),(0,Tr.jsx)("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));var fe=require("react/jsx-runtime"),Rh={APROVADO:Qd,EM_ANDAMENTO:jd,REJEITADO:eu},oa={APROVADO:"border-green-500 hover:border-green-500 border-[3px] border-solid",EM_ANDAMENTO:"border-turquoise-400 hover:border-turquoise-400 border-[3px] border-solid",REJEITADO:"border-red-500 hover:border-red-500 border-[3px] border-solid",default:"border-grey-400 border-2 border-solid",error:"border-red-500 border-[3px] shadow-[0_0_5px_rgba(255,0,0,0.5)]"},Dh={APROVADO:"bg-green-50",EM_ANDAMENTO:"bg-turquoise-50",REJEITADO:"bg-red-50"},ou=({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let{t:s}=(0,tu.useTranslation)(),{toast:a}=at(),{updateNodeData:l,getNodes:c,setNodes:d}=(0,Et.useReactFlow)(),{inProgress:u,fromNode:f}=(0,Et.useConnection)(),{mode:m,isReadOnly:h,onSubprocessValidationClick:E,reconnectingEdgeId:p}=q(),{getTaskStatus:g}=Fo(),y=u&&(f==null?void 0:f.id)!==e||!!p,x=g(e),N=t.variant==="SUBPROCESS",b=t.variant==="SERVICE_TASK",v=!!t.variant&&!N&&!b||!!x,T=!!t.attribute||N||b,I=(0,vr.useCallback)(M=>{let B=v||T?80:40,G=M.split(`
41
+ `),k=G.reduce((U,X)=>Math.max(U,X.length),0),O=G.length,Y=Math.max(To.MIN_WIDTH,k*7+64),W=Math.max(To.MIN_HEIGHT,O*24+B);d(U=>U.map(X=>X.id===e?w(_({},X),{width:Y,height:W,style:w(_({},X.style),{width:Y,height:W})}):X))},[e,d,v,T]),S=(0,vr.useCallback)(M=>{let V=M.trim(),D=t.label||"";if(V===D)return;let A=V,B=c();if(!(V&&V!=="")){A=ts(B,s("bpmn.task.label.prefix")),l(e,{label:A}),I(A),a({variant:"warning",content:(0,fe.jsxs)(fe.Fragment,{children:[s("bpmn.task.feedback.label_empty.prefix")," ",(0,fe.jsx)("strong",{children:A})]})});return}let k=Gn(A,B);k===D||(l(e,{label:k}),I(k),k!==A&&a({variant:"warning",content:(0,fe.jsxs)(fe.Fragment,{children:[s("bpmn.task.feedback.label_already_exists.prefix")," ",(0,fe.jsx)("strong",{children:V})," ",s("bpmn.task.feedback.label_already_exists.middle")," ",(0,fe.jsx)("strong",{children:k})]})}))},[t.label,c,e,s,l,I,a]),P=(0,vr.useCallback)(M=>{I(M)},[I]),R=(0,vr.useCallback)(()=>{a({variant:"error",content:s("bpmn.task.feedback.invalid_first_character")})},[s,a]),C=x?Rh[x]:null,L=t.variant?Xr[t.variant].icon:null,K=t.attribute?Ur[t.attribute].icon:null,Q=()=>t.hasError?oa.error:x?oa[x]:h?oa.default:"",j=()=>{var M;return r&&(M=Dh[x])!=null?M:""},z=()=>{E==null||E({id:e,type:"sub_process",label:t.label})};return(0,fe.jsxs)("div",{className:H("relative w-full h-full min-w-44 min-h-24 flex flex-col items-stretch justify-stretch bg-white border-2 border-grey-400 hover:border-grey-500 rounded-md hover:shadow-md transition-colors duration-75",Q(),{"cursor-pointer":h,"border-blue-500 hover:border-blue-600 shadow-md":r&&!h&&!x,"border-red-500 hover:border-red-600 shadow-[0_0_5px_rgba(255,0,0,0.5)]":t.hasError}),style:{width:o!=null?o:To.MIN_WIDTH,height:n!=null?n:To.MIN_HEIGHT},children:[(0,fe.jsx)("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:(0,fe.jsx)(Qe,{value:t.label,maxLength:60,className:H(j(),{"py-10 px-8":v||T}),onChange:S,onInput:P,onInvalidFirstCharacter:R})}),L&&(0,fe.jsx)("div",{className:H("absolute flex items-center p-1",N||b?"bottom-0 left-1/2 -translate-x-1/2":"top-0 left-0"),children:(0,fe.jsx)(L,{size:b?20:16,className:H(t.hasError?"text-red-500":"text-grey-500",N&&"cursor-pointer"),onClick:N?z:void 0})}),K&&(0,fe.jsx)("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:(0,fe.jsx)("div",{className:H("flex items-center w-16 p-1",N||b?"justify-between":"justify-center"),children:(0,fe.jsx)(K,{size:16,className:H(t.hasError?"text-red-500":"text-grey-500")})})}),C&&(0,fe.jsx)("div",{className:"absolute top-0 right-0 flex items-center p-1",children:(0,fe.jsx)(C,{})}),(0,fe.jsx)(lt,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),m==="edit"&&(0,fe.jsx)(Pt,{nodeId:e,isVisible:!i&&r,minWidth:To.MIN_WIDTH,minHeight:To.MIN_HEIGHT}),(!u||y)&&(0,fe.jsxs)(fe.Fragment,{children:[(0,fe.jsx)(ne,{type:"target",position:Et.Position.Left,id:"left",className:H({"task-handle":y})}),(0,fe.jsx)(ne,{type:"target",position:Et.Position.Right,id:"right",className:H({"task-handle":y})}),(0,fe.jsx)(ne,{type:"target",position:Et.Position.Top,id:"top",className:H({"task-handle":y})}),(0,fe.jsx)(ne,{type:"target",position:Et.Position.Bottom,id:"bottom",className:H({"task-handle":y})})]}),!u&&(0,fe.jsxs)(fe.Fragment,{children:[(0,fe.jsx)(tt,{type:"source",position:Et.Position.Left,id:"left",nodeId:e,nodeType:"TASK"}),(0,fe.jsx)(tt,{type:"source",position:Et.Position.Right,id:"right",nodeId:e,nodeType:"TASK"}),(0,fe.jsx)(tt,{type:"source",position:Et.Position.Top,id:"top",nodeId:e,nodeType:"TASK"}),(0,fe.jsx)(tt,{type:"source",position:Et.Position.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})};var na=require("@xyflow/react");var fo=require("react/jsx-runtime"),nu=({id:e,data:t})=>(0,fo.jsxs)(fo.Fragment,{children:[(0,fo.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,fo.jsx)(lt,{nodeId:e,nodeType:"UNSUPPORTED"}),(0,fo.jsx)(ne,{type:"source",position:na.Position.Right}),(0,fo.jsx)(ne,{type:"target",position:na.Position.Left})]});var Ge=require("@xyflow/react"),os=require("react");var Ne=require("react/jsx-runtime"),bI={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:Ge.MarkerType.Arrow},data:{label:""}},ru=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:s,sourceHandleId:a,targetHandleId:l})=>{var G;let{zoom:c}=(0,Ge.useViewport)(),{updateEdgeData:d}=(0,Ge.useReactFlow)(),{isMultipleSelection:u,mode:f,instanceId:m}=q(),h=f!=="edit",[E,p]=(0,os.useState)(!1),{reconnectingHandle:g,cursorPosition:y,hoveredNodeId:x,reconnectingSide:N,isValidReconnection:b,handleReconnectStart:v}=Yi({edgeId:e,source:t,target:o,instanceId:m,isReadOnly:h}),T=(0,Ge.useInternalNode)(t),I=(0,Ge.useInternalNode)(o),{sx:S,sy:P,tx:R,ty:C,sourcePos:L,targetPos:K}=(0,os.useMemo)(()=>{var oe,le;if(!T||!I)return{sx:0,sy:0,tx:0,ty:0,sourcePos:Ge.Position.Left,targetPos:Ge.Position.Right};let k=Tn(T,I),O=a?i:k.sourcePos,Y=l?s:k.targetPos,W=(Z,ve,ye)=>{var ee,xe,Se,Re,Ze,Nt;let{x:Ae,y:J}=Z.internals.positionAbsolute,de=(Se=(xe=(ee=Z.measured)==null?void 0:ee.width)!=null?xe:Z.width)!=null?Se:0,re=(Nt=(Ze=(Re=Z.measured)==null?void 0:Re.height)!=null?Ze:Z.height)!=null?Nt:0;switch(ve){case Ge.Position.Top:return{x:Ae+de*ye,y:J};case Ge.Position.Bottom:return{x:Ae+de*ye,y:J+re};case Ge.Position.Left:return{x:Ae,y:J+re*ye};case Ge.Position.Right:return{x:Ae+de,y:J+re*ye};default:return{x:Ae+de/2,y:J+re/2}}},U=(oe=n==null?void 0:n.sourceOffset)!=null?oe:.5,X=(le=n==null?void 0:n.targetOffset)!=null?le:.5,$=T?W(T,O,U).x:k.sx,te=T?W(T,O,U).y:k.sy,ie=I?W(I,Y,X).x:k.tx,F=I?W(I,Y,X).y:k.ty;return g==="source"&&y?($=y.x,te=y.y,N&&(O=N)):g==="target"&&y&&(ie=y.x,F=y.y,N&&(Y=N)),{sx:$,sy:te,tx:ie,ty:F,sourcePos:O,targetPos:Y}},[T,I,a,l,i,s,g,y,N,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!T||!I)return null;let[Q,j,z]=(0,Ge.getSmoothStepPath)({sourceX:S,sourceY:P,targetX:R,targetY:C,sourcePosition:L,targetPosition:K}),M=r||(T==null?void 0:T.selected)||(I==null?void 0:I.selected),V=M?"sequence-edge-marker-highlighted":"sequence-edge-marker",D=E||(n==null?void 0:n.label.trim().length)>0,A=()=>{p(!1)},B=k=>{d(e,{label:k.trim()})};return(0,Ne.jsx)(Ne.Fragment,{children:(0,Ne.jsxs)("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":M}),onDoubleClick:()=>!h&&p(!0),children:[(0,Ne.jsx)("path",{d:Q,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),(0,Ne.jsxs)("g",{className:H("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":M}),children:[(0,Ne.jsx)(Ge.BaseEdge,{id:e,path:Q,interactionWidth:0,markerEnd:`url(#${V})`,strokeDasharray:4,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||g&&x&&!b,"stroke-green-500":g&&x&&b,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":M&&!(n!=null&&n.hasError)&&!g})}),(0,Ne.jsxs)(Ge.EdgeLabelRenderer,{children:[(0,Ne.jsxs)("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${j}px, ${z}px)`},children:[r&&!u&&(0,Ne.jsx)(Ln,{sx:S,sy:P,tx:R,ty:C,hasLabel:!!((G=n==null?void 0:n.label)!=null&&G.trim()),children:(0,Ne.jsx)(Pn,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),D&&(0,Ne.jsx)(Qe,{value:n==null?void 0:n.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:E,onBlur:A,onChange:B})]}),r&&!u&&!h&&(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${S}px, ${P}px)`},children:(0,Ne.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:g==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:g==="source"?.6:.3,className:"pointer-events-none"}),(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!g||g!=="source","cursor-not-allowed":g==="source"&&x&&!b,"cursor-grabbing":g==="source"&&(!x||b)}),onMouseDown:k=>v("source",k.nativeEvent)})]})}),(0,Ne.jsx)("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${R}px, ${C}px)`},children:(0,Ne.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:g==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:g==="target"?.6:.3,className:"pointer-events-none"}),(0,Ne.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!g||g!=="target","cursor-not-allowed":g==="target"&&x&&!b,"cursor-grabbing":g==="target"&&(!x||b)}),onMouseDown:k=>v("target",k.nativeEvent)})]})})]})]})]})]})})};var tn=require("@xyflow/react"),Nr=require("react/jsx-runtime"),iu=({toX:e,toY:t,fromNode:o})=>{var u,f;if(!o)return null;let{internals:{positionAbsolute:{x:n,y:r}},measured:i}=o,s=(u=i.width)!=null?u:0,a=(f=i.height)!=null?f:0,c=[{x:n,y:r+a/2,pos:tn.Position.Left},{x:n+s,y:r+a/2,pos:tn.Position.Right},{x:n+s/2,y:r,pos:tn.Position.Top},{x:n+s/2,y:r+a,pos:tn.Position.Bottom}].reduce((m,h)=>{let E=Math.hypot(e-m.x,t-m.y);return Math.hypot(e-h.x,t-h.y)<E?h:m}),[d]=(0,tn.getStraightPath)({sourceX:c.x,sourceY:c.y,targetX:e,targetY:t});return(0,Nr.jsxs)("g",{className:"group",children:[(0,Nr.jsx)("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d}),(0,Nr.jsx)("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})};var _t=require("@xyflow/react"),su=require("lodash"),wr=require("react");var ke=require("react/jsx-runtime"),au=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{var T;let{updateNodeData:i,getNodes:s}=(0,_t.useReactFlow)(),{mode:a,isReadOnly:l}=q(),{inProgress:c,fromNode:d}=(0,_t.useConnection)(),u=c&&(d==null?void 0:d.id)!==e,[f,m]=(0,wr.useState)(!1),h=s(),E=!r,p=!E&&((T=h.find(I=>I.id===r))==null?void 0:T.selected),g=(0,wr.useMemo)(()=>(0,su.orderBy)([...h.filter(I=>I.parentId===e&&I.type==="LANE")],"position.y","asc"),[h,e]),y=E?La.MIN_WIDTH:ae.MIN_WIDTH,x=(0,wr.useMemo)(()=>{if(E&&g.length>1){let I=[...g];return I.pop(),I.reduce((P,R)=>{var C,L;return P+((L=(C=R.measured)==null?void 0:C.height)!=null?L:0)},0)+ae.MIN_HEIGHT}return ae.MIN_HEIGHT},[E,g]),N=I=>{i(e,{label:I})},b=()=>{m(!0)},v=()=>{m(!1)};return(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsxs)("div",{className:H("flex h-full min-h-64 w-full min-w-[50rem] hover:shadow-md bg-white outline outline-2 outline-grey-400",{"pointer-events-none":l,"outline-offset-0 outline-blue-500 shadow-sm":(o||p)&&!l}),children:[(0,ke.jsx)("div",{className:H("flex align-items justify-center w-10 border-r-2 border-grey-400",{"border-blue-500":(o||p)&&!l}),onDoubleClick:b,children:(0,ke.jsx)("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:(0,ke.jsx)(Qe,{value:t.label,className:"w-full h-full self-auto",contentClassName:H({"whitespace-nowrap":f}),isEditing:f,onBlur:v,onChange:N})})}),(0,ke.jsx)("div",{className:"flex-1"})]}),(0,ke.jsx)(lt,{nodeId:e,nodeType:"LANE",isChild:!E}),a==="edit"&&(0,ke.jsx)(Pt,{nodeId:e,isVisible:!n&&o,minWidth:y,minHeight:x,offset:10}),!c&&(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsx)(ne,{type:"source",position:_t.Position.Left,id:"left"}),(0,ke.jsx)(ne,{type:"source",position:_t.Position.Right,id:"right"}),(0,ke.jsx)(ne,{type:"source",position:_t.Position.Top,id:"top"}),(0,ke.jsx)(ne,{type:"source",position:_t.Position.Bottom,id:"bottom"})]}),(!c||u)&&(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsx)(ne,{type:"target",position:_t.Position.Left,id:"left",className:H({"annotation-handle":u})}),(0,ke.jsx)(ne,{type:"target",position:_t.Position.Right,id:"right",className:H({"annotation-handle":u})}),(0,ke.jsx)(ne,{type:"target",position:_t.Position.Top,id:"top",className:H({"annotation-handle":u})}),(0,ke.jsx)(ne,{type:"target",position:_t.Position.Bottom,id:"bottom",className:H({"annotation-handle":u})})]})]})};var lu={START_EVENT:Jd,END_EVENT:Ud,TASK:ou,GATEWAY:$d,ANNOTATION:Fd,LANE:au,UNSUPPORTED:nu},cu={SEQUENCE_EDGE:hd,MESSAGE_EDGE:ru,ANNOTATION_EDGE:ad},du="#fafafa",uu="#bebebe",pu=1,fu=10,mu="bottom-left",ra=.05,gu=5,hu=150,yu=100,xu=ra,Eu=1,_u={x:0,y:0,zoom:.75},bu=1,Tu=2,Oh={[bu]:4,[Tu]:2},Ir=[bu,Tu],ia=Ir.reduce((e,t)=>e|Oh[t],0);var Bn=()=>{let{setViewport:e}=(0,ns.useReactFlow)(),t=(0,ns.useStoreApi)();return{fitToNodes:(0,vu.useCallback)(n=>{let{width:r,height:i}=t.getState();if(i<=0||r<=0)return;let s=Ba(n);if(!s)return;let a=za({bounds:s,canvasHeight:i,canvasWidth:r,minZoom:xu,maxZoom:Eu,offsetX:hu,offsetY:yu});e(a)},[t,e])}};var Nu=require("@xyflow/react");var Lt=()=>{let{getEdges:e,getNodes:t}=(0,Nu.useReactFlow)(),{lastElementId:o}=q(),n=()=>{let i=t(),s=e(),a=Ed(i,s);return Math.max(a,o)};return{getLastId:n,getNextId:()=>n()+1}};var zn=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n}=(0,wu.useReactFlow)(),{getLastId:r}=Lt(),{fitToNodes:i}=Bn(),{setLastElementId:s}=q(),a=(0,sa.useCallback)(async(c="")=>{let{nodes:d,edges:u,lastElementId:f}=await kd(c);i(d),o(d),n(u),s(f)},[o,n,s,i]),l=(0,sa.useCallback)(()=>{let c=e(),d=t(),u=r();return Ld(c,d,u)},[e,t,r]);return{importFromMxGraph:a,exportToMxGraph:l}};var aa=require("react"),Vh=500,rs=()=>{let{isInitialized:e,onElementChanges:t}=q(),{exportToMxGraph:o}=zn(),n=(0,Iu.useDebouncedCallback)(()=>{if(!e)return;let s=o();t==null||t(s)},Vh),r=(0,aa.useCallback)(s=>{s.every(c=>c.type==="select")||s.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=(0,aa.useCallback)(s=>{s.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var Au=({setEdges:e,saveHistory:t})=>{let{getNode:o,getEdges:n,getNodes:r,getInternalNode:i}=(0,is.useReactFlow)(),{emitElementChanges:s}=rs(),a=(0,Qt.useRef)(null),{getNextId:l}=Lt(),c=(0,Qt.useCallback)(p=>{var b;let g=o(p.source),y=o(p.target);if(!g||!y)return!1;let x={sourceNodeId:g.id,targetNodeId:y.id,sourceNodeType:g.type,targetNodeType:y.type,nodes:r(),edges:n(),reconnectingEdgeId:(b=a.current)!=null?b:void 0};return Ws(x).isValid},[o,n,r]),d=(0,Qt.useCallback)(p=>{var x,N;let g=l(),y=i(p.source);if(y){let b=i(p.target),v=b?b.internals.positionAbsolute.x+((x=b.measured.width)!=null?x:0)/2:0,T=b?b.internals.positionAbsolute.y+((N=b.measured.height)!=null?N:0)/2:0,I=yd(y,v,T),S=(b==null?void 0:b.type)==="ANNOTATION"||(y==null?void 0:y.type)==="ANNOTATION",P=S?kn:Mt,R;if(!S&&b&&p.targetHandle){let K=Fi(I),Q=Fi(p.targetHandle),{x:j,y:z}=$s(y,I),{x:M,y:V}=$s(b,p.targetHandle),A=Bi(j,z,M,V,K,Q).slice(1,-1);A.length>0&&(R=A)}let C=w(_(_({},p),P),{id:String(g),sourceHandle:I,data:_(_({},S?{}:Mt.data),R?{points:R}:{})}),L=n().concat(C);e(L),t("forceSave",{nodes:r(),edges:L}),s()}},[l,e,s,i,n,r,t]),u=(0,Qt.useCallback)((p,g)=>{a.current=g.id},[]),f=(0,Qt.useCallback)(()=>{a.current=null},[]),m=(0,Qt.useCallback)((p,g)=>{let y=o(g.source),x=o(g.target);if(!y||!x){a.current=null;return}let N={sourceNodeId:y.id,targetNodeId:x.id,sourceNodeType:y.type,targetNodeType:x.type,nodes:r(),edges:n(),reconnectingEdgeId:p.id};if(!Ws(N).isValid){a.current=null;return}let v=(0,is.reconnectEdge)(p,g,n()).map(T=>T.id===p.id?w(_({},T),{data:w(_({},T.data),{points:void 0})}):T);e(v),t("forceSave",{nodes:r(),edges:v}),a.current=null,s()},[o,r,n,e,s,t]),h=(0,Qt.useCallback)(p=>{a.current=p},[]),E=(0,Qt.useCallback)(()=>{a.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:m,onReconnectStart:u,onReconnectEnd:f,setReconnectingEdge:h,clearReconnectingEdge:E}};var Ou=require("@produto-lecom/lecom-ui"),Vu=require("@xyflow/react"),Ht=require("react");var Ar=(e=[])=>e.filter(t=>t.type==="START_EVENT"),on=(e=[])=>e.filter(t=>t.type==="END_EVENT"),ko=(e=[])=>e.filter(t=>t.type==="TASK")||[],Su=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"});var ss=(e=[])=>e.filter(t=>t.type==="GATEWAY"),Cu=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),bt=(e,t=[])=>t.filter(o=>o.source===e),Sr=(e,t=[])=>t.filter(o=>o.target===e),Mu=(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"},Pu=(e,t)=>{let o=bt(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},Lu=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:[]}},mo=(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)}},ku=(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 Cr=[{id:"start_event_not_found",validate:e=>{let t=Ar(e.nodes);return we({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=on(e.nodes);return we({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Ar(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=bt(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(s=>s.id),...n.map(s=>s.target)];return we({isValid:!1,nodeIds:[...new Set(i)]})}return we({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=ko(e.nodes),o=mo(t,n=>bt(n.id,e.edges).length<=2);return we({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=ko(e.nodes),o=mo(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=ko(e.nodes),n=mo(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=ko(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=ss(e.nodes),o=[],n=[];for(let r of t){let i=bt(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&a.type==="GATEWAY"&&(o.push(r.id,a.id),n.push(s.id))}}return we({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Ar(e.nodes),...on(e.nodes)],o=[],n=[];for(let r of t){let i=bt(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&(a.type==="START_EVENT"||a.type==="END_EVENT")&&(o.push(r.id,a.id),n.push(s.id))}}return 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=on(e.nodes),o=[],n=[];for(let r of t){let i=Sr(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.source);if(a&&a.type==="TASK"){let l=bt(a.id,e.edges);l.length>1&&(o.push(a.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=Cu(e.nodes),o=mo(t,r=>bt(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>bt(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=ko(e.nodes),o=mo(t,n=>!n.label||Lu(n.label));return we({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var s,a;if(!((s=e==null?void 0:e.nodes)!=null&&s.length)||!((a=e==null?void 0:e.edges)!=null&&a.length))return we({isValid:!0});let t=on(e.nodes)[0];if(!t)return we({isValid:!0});let o=Sr(t.id,e.edges);if(!o.length)return we({isValid:!0});let r=ko(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=mo(r,l=>!Mu(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=ko(e.nodes),o=on(e.nodes)[0];if(!o)return we({isValid:!0});let n=t.filter(l=>{let c=Sr(l.id,e.edges),d=bt(l.id,e.edges),u=c.some(m=>{var h;return((h=e.nodes.find(E=>E.id===m.source))==null?void 0:h.type)==="START_EVENT"}),f=d.some(m=>{var h;return((h=e.nodes.find(E=>E.id===m.target))==null?void 0:h.type)==="END_EVENT"});return u&&f}),r=Sr(o.id,e.edges),i=r.length>1,s=r.map(l=>l.source),a={isValid:n.length===0&&!i,nodeIds:[...n.map(l=>l.id),...i?s:[]]};return we(a)}},{id:"gateway_flow_to_event",validate:e=>{let t=ss(e.nodes),o=[],n=[];for(let r of t){let i=bt(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&a.type==="END_EVENT"&&(o.push(r.id,a.id),n.push(s.id))}}return we({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=ss(e.nodes),o=mo(t,n=>bt(n.id,e.edges).length>=1);return we({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Ar(e.nodes),...on(e.nodes)],o=[],n=[];for(let r of t){let i=bt(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&a.type==="GATEWAY"&&(o.push(r.id,a.id),n.push(s.id))}}return we({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=Su(e.nodes),o=mo(t,n=>!Pu(n.id,e));return we({isValid:o.isValid,nodeIds:o.invalidIds})}}];var Ru=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of Cr){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}},Du=async(e,t)=>{var n;let o=[];try{let r=await e(),i=(n=r==null?void 0:r.filter(s=>s.area==="DIAGRAM"))!=null?n:[];return i.length===0?{isValid:!0,errors:[]}:(i.forEach(s=>{var l,c;let a=(c=(l=s==null?void 0:s.detail)==null?void 0:l.phases)==null?void 0:c.map(d=>d.diagramCellId);o.push({id:s.code,message:s.code,nodeIds:a,edgeIds:[]})}),{isValid:!1,errors:o})}catch(r){let i=[],s=(a,l)=>{let c=t.filter(d=>{var u;return((u=d.data)==null?void 0:u.variant)===a}).map(d=>d.id);c.length>0&&i.push({id:l,message:l,nodeIds:c,edgeIds:[]})};return s("SUBPROCESS","cannot_validate_subprocess_reference"),s("SERVICE_TASK","service_task_automation_status_unavailable"),{isValid:!1,errors:i}}};var nn=require("react/jsx-runtime"),Hu=()=>{let{t:e}=(0,Ou.useTranslation)(),{toast:t}=at(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=(0,Vu.useReactFlow)(),{validateCustomDiagram:s}=q(),[a,l]=(0,Ht.useState)(!1),c=(0,Ht.useRef)(!1),d=(0,Ht.useRef)(!1),u=(0,Ht.useCallback)(async p=>{let g=ku(p.nodes,p.edges),y=Ru(g),x=p.nodes.filter(({type:b,data:v})=>b==="TASK"&&((v==null?void 0:v.variant)==="SUBPROCESS"||(v==null?void 0:v.variant)==="SERVICE_TASK"));if(s&&x.length>0){let b=await Du(s,x);y={isValid:y.isValid&&b.isValid,errors:[...y.errors,...b.errors]}}let N=y.errors.map(b=>w(_({},b),{message:e(`validation.errors.${b.id}`)}));return a||l(!0),{isValid:y.isValid,errors:N}},[a,e,s]),f=(0,Ht.useCallback)((p,g=!0)=>{if(g&&p&&t({variant:p.isValid?"success":"error",duration:5e3,title:p.isValid?e("validation.success.title"):e("validation.errors.title"),content:(0,nn.jsxs)("div",{className:"flex flex-col gap-1",children:[!p.isValid&&(0,nn.jsx)("span",{className:"body-small-500",children:e("validation.errors.subtitle")}),(0,nn.jsx)("ul",{className:"list-disc list-inside max-h-40 overflow-y-auto",children:p.isValid?(0,nn.jsx)("li",{children:e("validation.success.message")}):p.errors.map(C=>(0,nn.jsx)("li",{className:"text-xs",children:C.message},C.id))})]})}),!p)return;c.current=!0,d.current=!0;let y=[],x=[];p.errors.forEach(C=>{C.nodeIds&&C.nodeIds.length>0&&C.nodeIds.forEach(L=>y.push(L)),C.edgeIds&&C.edgeIds.length>0&&C.edgeIds.forEach(L=>x.push(L))});let N=[...new Set(y)];o(C=>C.map(L=>w(_({},L),{data:w(_({},L.data),{hasError:!1})}))),n(C=>C.map(L=>w(_({},L),{data:w(_({},L.data),{hasError:!1})})));let b=r(),v=i(),T=new Set(N),I=new Set;p.errors.forEach(C=>{var Q,j;let L=Cr.find(z=>z.id===C.id);(L==null?void 0:L.highlightRelatedEdges)!==!1&&((Q=C.edgeIds)==null||Q.forEach(z=>I.add(z)),(j=C.nodeIds)==null||j.forEach(z=>{v.forEach(M=>{(M.source===z||M.target===z)&&I.add(M.id)})}))});let S=new Set,P=new Set,R=new Set;b.forEach(C=>{C.type==="START_EVENT"?S.add(C.id):C.type==="END_EVENT"&&P.add(C.id)}),v.forEach(C=>{S.has(C.source)&&R.add(C.target),P.has(C.target)&&R.add(C.source)}),R.forEach(C=>{var L,K;if(T.has(C)){let Q=(L=p.errors.find(z=>{var M;return(M=z.nodeIds)==null?void 0:M.includes(C)}))==null?void 0:L.id;((K=Cr.find(z=>z.id===Q))==null?void 0:K.highlightRelatedEdges)!==!1&&v.forEach(z=>{z.source===C&&P.has(z.target)&&(T.add(z.target),I.add(z.id)),z.target===C&&S.has(z.source)&&(T.add(z.source),I.add(z.id))})}}),T.size>0&&o(C=>C.map(L=>w(_({},L),{data:w(_({},L.data),{hasError:T.has(L.id)})}))),I.size>0&&n(C=>C.map(L=>w(_({},L),{data:w(_({},L.data),{hasError:I.has(L.id)})}))),setTimeout(()=>{c.current=!1},0)},[e,i,r,n,o,t]),m=(0,Ht.useCallback)(()=>{l(!1),d.current=!1,o(p=>p.map(g=>w(_({},g),{data:w(_({},g.data),{hasError:!1})}))),n(p=>p.map(g=>w(_({},g),{data:w(_({},g.data),{hasError:!1})})))},[n,o]),h=(0,Ht.useCallback)(()=>{d.current&&(c.current=!0,d.current=!1,o(p=>p.map(g=>w(_({},g),{data:w(_({},g.data),{hasError:!1})}))),n(p=>p.map(g=>w(_({},g),{data:w(_({},g.data),{hasError:!1})}))),setTimeout(()=>{c.current=!1},0))},[n,o]),E=(0,Ht.useCallback)(()=>c.current,[]);return{validateDiagram:u,handleValidationComplete:f,clearValidation:m,dismissValidationPanel:h,isAutoValidationEnabled:a,getIsClearingValidation:E}};var zu=require("@xyflow/react"),Yu=require("@produto-lecom/lecom-ui"),Wu=require("react");var Hh=15,Gu="bpmn:selection",Gh=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",i=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||i},Bu=e=>{if(!Gh(e.target))return!0;let t=window.getSelection(),o=t&&t.toString().length>0;if(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement){let n=e.target;return n.selectionStart===n.selectionEnd&&!o}return!o},Fu=({offset:e=Hh,saveHistory:t})=>{let{t:o}=(0,Yu.useTranslation)(),{getNodes:n,setNodes:r,getEdges:i,setEdges:s}=(0,zu.useReactFlow)(),{getNextId:a}=Lt(),{mode:l,containerRef:c}=q();(0,Wu.useEffect)(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let u=m=>{var b,v;if(!Bu(m)||!d.contains(document.activeElement))return;let E=n(),p=i(),g=E.filter(T=>T.selected);if(!g.length)return;m.preventDefault(),m.stopPropagation();let y=p.filter(T=>g.some(I=>I.id===T.source)&&g.some(I=>I.id===T.target)),N=JSON.stringify({nodes:g,edges:y});(b=m.clipboardData)==null||b.setData(Gu,N),(v=m.clipboardData)==null||v.setData("text/plain",`BPMN Selection: ${g.length} nodes`)},f=m=>{var R,C;if(!Bu(m)||!d.contains(document.activeElement))return;let E=(R=m.clipboardData)==null?void 0:R.getData(Gu);if(!E)return;m.preventDefault(),m.stopPropagation();let p;try{p=JSON.parse(E)}catch(L){return}if(!((C=p.nodes)!=null&&C.length))return;let g=new Map,y=n(),x=[],N=p.nodes.filter(L=>Ao(L.type,y));if(N.length===0)return;let b=a(),v=N.map(L=>{var j;let K=String(b++);g.set(L.id,K);let Q=w(_({},L),{id:K,selected:!0,position:{x:L.position.x+e,y:L.position.y+e}});if(L.type==="TASK"){let z=(j=L.data)==null?void 0:j.label,M=Gn(z||o("bpmn.task.label.prefix"),[...y,...x]);Q.data=w(_({},L.data),{label:M})}return x.push(Q),Q}),T=p.edges.map(L=>w(_({},L),{id:String(b++),selected:!0,source:g.get(L.source)||L.source,target:g.get(L.target)||L.target})),I=[...y.map(L=>w(_({},L),{selected:!1})),...v],P=[...i().map(L=>w(_({},L),{selected:!1})),...T];r(I),s(P),t("forceSave",{nodes:I,edges:P})};return d.addEventListener("copy",u,!0),d.addEventListener("paste",f,!0),()=>{d.removeEventListener("copy",u,!0),d.removeEventListener("paste",f,!0)}},[n,r,i,s,a,e,o,t,l,c])};var Xu=require("@produto-lecom/lecom-ui"),Uu=require("@xyflow/react");var $u=require("react");var Bh=50,Ku=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let{draggableNode:r,setDraggableNode:i}=Hn(),{t:s}=(0,Xu.useTranslation)(),{getInternalNode:a,getNodes:l,getEdges:c,screenToFlowPosition:d}=(0,Uu.useReactFlow)(),{getNextId:u}=Lt(),{setIsDragging:f}=q(),{getInternalNodes:m}=Ki(),{rebuildIndex:h,forceRebuildIndex:E}=Si(),[p,g]=(0,$u.useState)(null),y=(M,V,D)=>{var k;if(M.parentId!==V)return null;let A=D.filter(O=>O.id!==M.id&&O.parentId===V&&O.type==="LANE").sort((O,Y)=>O.position.y-Y.position.y);if(A.length===0)return null;let B=(k=D.find(O=>O.id===M.id))!=null?k:M,G=A.find(O=>B.position.y<O.position.y);return G?{draggedLaneId:M.id,beforeLaneId:G.id}:{draggedLaneId:M.id,afterLaneId:A[A.length-1].id}},x=(M,V=!1,D)=>{let A=V?"node-drop-target-error":"node-drop-target",B=V?"node-drop-target-lane-error":"node-drop-target-lane";t(G=>{var O;let k=(O=D==null?void 0:D(G))!=null?O:null;return G.map(Y=>{let W=[];return Y.id===M&&W.push(A),M!==void 0&&Y.parentId===M&&Y.type==="LANE"&&Y.id!==(k==null?void 0:k.draggedLaneId)&&W.push(B),Y.id===(k==null?void 0:k.draggedLaneId)&&W.push("lane-reorder-dragging"),Y.id===(k==null?void 0:k.beforeLaneId)&&W.push("lane-reorder-before"),Y.id===(k==null?void 0:k.afterLaneId)&&W.push("lane-reorder-after"),w(_({},Y),{className:W.join(" ")})})})},N=(M,V)=>{let D=m();if(M.type==="LANE"){if(V){x();return}let O=D.filter(U=>U.id!==M.id&&U.type==="LANE"&&!U.parentId),Y=Jn(M,O);if(!Y){x();return}if(zo({parentId:Y.id,nodes:e,excludeTypes:["LANE"]})){x(Y.id,!0);return}x(Y.id,!1,U=>y(M,Y.id,U));return}let B=D.filter(O=>O.id!==M.id&&O.type==="LANE"),G=Jn(M,B);if(!G){x();return}if(zo({parentId:G.id,nodes:e,includeTypes:["LANE"]})){x();return}x(G.id)},b=M=>{let V=a(M.id),D=M.type==="LANE"&&zo({parentId:M.id,nodes:e,includeTypes:["LANE"]});N(V,D)},v=M=>M.map(V=>w(_({},V),{className:void 0})),T=M=>M.some(D=>D.dragging)?M.map(D=>D.dragging?w(_({},D),{dragging:!1}):D):M,I=(M,V)=>{let D=0;for(let A of V){if(A.id===M||A.parentId||A.type==="LANE")continue;let B=At(A),G=B.y+B.h;D=Math.max(D,G)}return D+Bh},S=(M,V)=>{if(!vs(M,V))return V;let D=I(M,V);return V.map(A=>A.id===M?w(_({},A),{position:w(_({},A.position),{y:D})}):A)},P=M=>{if(M.preventDefault(),M.dataTransfer.dropEffect="move",!(r!=null&&r.type))return;let V=d({x:M.clientX,y:M.clientY}),D={id:"__sidebar_drag__",type:r.type,position:V,measured:{width:1,height:1},internals:{positionAbsolute:V}};N(D,!1)},R=M=>{let V=M.relatedTarget;(!V||!M.currentTarget.contains(V))&&x()},C=(M,V)=>{M.preventDefault(),b(V)},L=(M,V,D)=>{var W,U;let A=[...D],B=V.parentId?V.parentId:V.id;if(M.parentId===V.id)return A=ws(M,V,A),A=Po(A),A=Yo(B,A),v(A);if(M.type==="LANE"){if(zo({parentId:V.id,nodes:A,excludeTypes:["LANE"]})){let F=wi(V),oe=50,le=50;return A.map(Z=>{var ve,ye;return Z.id===M.id?w(_({},Z),{position:{x:(ve=p==null?void 0:p.x)!=null?ve:F.x+oe,y:(ye=p==null?void 0:p.y)!=null?ye:F.y2+le}}):Z})}let te=A.filter(F=>F.parentId===V.id).reduce((F,oe)=>{var le,Z;return F+((Z=(le=oe.measured)==null?void 0:le.height)!=null?Z:0)},0),ie={x:ae.HEADER_WIDTH,y:te};return A=A.map(F=>F.id===M.id?w(_({},F),{parentId:V.id,position:ie,className:void 0}):w(_({},F),{className:void 0})),A=Po(A),A=S(B,A),A}if(zo({parentId:V.id,nodes:A,includeTypes:["LANE"]})){let X;if(M.parentId){let $=a(M.parentId),{x:te,y:ie}=At($);X={x:te+((W=M.position.x)!=null?W:0),y:ie+((U=M.position.y)!=null?U:0)}}return A=A.map($=>$.id===M.id?w(_({},$),{position:X!=null?X:$.position,parentId:void 0,className:void 0}):w(_({},$),{className:void 0})),A=Yo(B,A),A}let O=Ha(M,V);A=A.map(X=>X.id===M.id?w(_({},X),{parentId:V.id,position:O,className:void 0}):w(_({},X),{className:void 0}));let Y=A.find(X=>X.id===M.id);return A=ws(Y,V,A),A=Po(A),A=Yo(B,A),A},K=M=>{if(M.preventDefault(),!(r!=null&&r.type))return;if(!Ao(r.type,l())){f(!1),i(null);return}let V=d({x:M.clientX,y:M.clientY}),D={width:ue[r.type].MIN_WIDTH,height:ue[r.type].MIN_HEIGHT},A=u(),B={id:String(A),type:r.type,position:V,measured:D,data:{label:r.type==="TASK"?ts(e,s("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},G=w(_({},B),{internals:{positionAbsolute:V}}),k=w(_({},G),{measured:{width:1,height:1}}),O=m(),Y=r.type==="LANE",W=O.filter(F=>Y?F.type==="LANE"&&!F.parentId:F.type==="LANE"),U=Jn(k,W),X=[...O.map(F=>w(_({},F),{selected:!1})),G];U&&(X=L(G,U,X)),X=Zn(X),Y&&!U&&(X=S(G.id,X)),X=v(X),t(X),E();let $=M.dataTransfer.getData("sourceId"),te=c(),ie=te;if($){let F={id:String(A+1),source:$,target:B.id},oe=r.type==="ANNOTATION"?_(_({},F),kn):_(_({},F),Mt);ie=te.concat(oe),o(ie)}n("forceSave",{nodes:X,edges:ie}),f(!1),i(null)},Q=async(M,V,D)=>{let A=[...m()],B=new Set;D.forEach(O=>{let Y=a(O.id),W=O.type==="LANE",U=A.filter($=>$.id!==O.id&&(W?$.type==="LANE"&&!$.parentId:$.type==="LANE")),X=Jn(Y,U);if(X){if(W&&zo({parentId:O.id,nodes:A,includeTypes:["LANE"]})){O.parentId&&(A=z(O,A),B.add(O.id));return}A=L(Y,X,A);return}O.parentId&&(A=z(O,A),O.type==="LANE"&&B.add(O.id))}),A=T(A);let G=D.filter(O=>O.type==="LANE"&&!O.parentId).map(O=>O.id);for(let O of G)vs(O,A)&&p&&(A=A.map(Y=>Y.id===O?w(_({},Y),{position:_({},p)}):Y));for(let O of B)A=S(O,A);if(D.some(O=>O.type!=="LANE"&&!O.parentId)){let O=A.filter(Y=>Y.type==="LANE"&&!Y.parentId).map(Y=>Y.id);for(let Y of O)A=Yo(Y,A)}A=Zn(A),A=v(A),t(A),h(A),g(null)},j=(M,V)=>{g({x:V.position.x,y:V.position.y})},z=(M,V)=>{var U,X,$,te,ie,F,oe,le;let D=a(M.parentId);if(!D)return V;let A=M.type==="LANE",B=V.filter(Z=>Z.parentId===D.id&&Z.id!==M.id),G=B.filter(Z=>Z.type==="LANE"),k;if(A&&G.length===0)k=ae.MIN_HEIGHT;else if(A){let Z=(X=(U=M.measured)==null?void 0:U.height)!=null?X:ae.MIN_HEIGHT;k=((te=($=D.measured)==null?void 0:$.height)!=null?te:ae.MIN_HEIGHT)-Z,k=Math.max(ae.MIN_HEIGHT,k)}else k=B.length>0?B.reduce((Z,ve)=>{var ye,Ae;return Z+((Ae=(ye=ve.measured)==null?void 0:ye.height)!=null?Ae:0)},0)+He:Math.max(ae.MIN_HEIGHT,(F=(ie=D.measured)==null?void 0:ie.height)!=null?F:0);let{x:O,y:Y}=At(D),W={x:O+((oe=M.position.x)!=null?oe:0),y:Y+((le=M.position.y)!=null?le:0)};return V=V.map(Z=>Z.id===M.id?w(_({},Z),{position:W,parentId:void 0}):Z.id===D.id?w(_({},Z),{height:k,measured:w(_({},Z.measured),{height:k})}):Z),V=Po(V),V};return{onDragOver:P,onDragLeave:R,onDrop:K,onNodeDrag:C,onNodeDragStart:j,onNodeDragStop:Q}};var qu=require("@xyflow/react"),Zu=require("@produto-lecom/lecom-ui"),Ju=require("react");var zh=30,Yh=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=>!Yh(e.target),Qu=({offset:e=zh,saveHistory:t})=>{let{t:o}=(0,Zu.useTranslation)(),{getNodes:n,setNodes:r,getEdges:i,setEdges:s}=(0,qu.useReactFlow)(),{getNextId:a}=Lt(),{mode:l,containerRef:c}=q();(0,Ju.useEffect)(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let u=f=>{if(d.contains(document.activeElement)&&f.ctrlKey&&f.key.toLowerCase()==="d"&&Wh(f)){f.preventDefault(),f.stopPropagation();let h=n(),E=i(),p=h.filter(P=>P.selected);if(!p.length)return;let g=new Map,y=[],x=p.filter(P=>Ao(P.type,h));if(x.length===0)return;let N=E.filter(P=>x.some(R=>R.id===P.source)&&x.some(R=>R.id===P.target)),b=a(),v=x.map(P=>{var L;let R=String(b++);g.set(P.id,R);let C=w(_({},P),{id:R,selected:!0,position:{x:P.position.x+e,y:P.position.y+e}});if(P.type==="TASK"){let K=(L=P.data)==null?void 0:L.label,Q=Gn(K||o("bpmn.task.label.prefix"),[...h,...y]);C.data=w(_({},P.data),{label:Q})}return y.push(C),C}),T=N.map(P=>w(_({},P),{id:String(b++),selected:!0,source:g.get(P.source)||P.source,target:g.get(P.target)||P.target})),I=[...h.map(P=>w(_({},P),{selected:!1})),...v],S=[...E.map(P=>w(_({},P),{selected:!1})),...T];r(I),s(S),t("forceSave",{nodes:I,edges:S})}};return d.addEventListener("keydown",u,!0),()=>{d.removeEventListener("keydown",u,!0)}},[n,r,i,s,a,e,o,t,l,c])};var Pr=require("react"),ju=require("@xyflow/react");var Fh=20,Xh=50,Mr={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},Uh=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",i=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||i},ep=e=>{let{getNodes:t}=(0,ju.useReactFlow)(),{mode:o,isMoveTool:n}=q(),r=(0,Pr.useRef)(0),i=(0,Pr.useRef)(new Map);(0,Pr.useEffect)(()=>{let s=a=>{if(o!=="edit"||!n||Uh(a.target)||!Object.values(Mr).includes(a.key))return;let u=t().filter(y=>y.selected);if(u.length===0){i.current.clear();return}a.preventDefault();let f=Date.now(),m=f-r.current<500;r.current=f;let h=a.shiftKey?Xh:Fh,E=0,p=0;switch(a.key){case Mr.UP:p=-h;break;case Mr.DOWN:p=h;break;case Mr.LEFT:E=-h;break;case Mr.RIGHT:E=h;break}let g=u.map(y=>{let x=i.current.get(y.id);(!m||!x)&&(x={x:y.position.x,y:y.position.y});let N={x:x.x+E,y:x.y+p};return i.current.set(y.id,N),{id:y.id,dragging:!0,type:"position",position:N}});e&&e(g)};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t,e,o,n])};var ip=require("@xyflow/react");var op={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},np={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},tp=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],n=e.match(/(\[.*?\])/)||[],r=e.match(/(\{.*?\})/)||[],i=e.match(/(--.*|\|.*?\|)/i)||[],s="",a="",l="";if(o.length){switch(o[1]){case"<start>":s="start-event";break;case"<end>":s="end-event";break}e=e.replace(o[1],"")}return n.length&&(s="task",a=n[1].replace(/\[|\]/g,""),e=e.replace(n[1],"")),r.length&&(s="gateway-exclusive",a=r[1].replace(/\{|\}/g,""),e=e.replace(r[1],"")),s||(s="task",a=e),i.length&&(l=i[1].replace(/(\||--)/g,""),e=e.replace(i[1],"")),e=e.trim(),t[e]||(t[e]={type:s,label:a}),{step:e,type:s,label:a,edgeLabel:l}},$h=e=>{e=e||"";let t=e.trim().split(`
42
+ `),o={},n=[];return t.forEach(r=>{r=r||"";let i=r.trim().split("-->");if(i.length!==2){console.warn("Invalid number of steps");return}let s=tp(i[0],o),a=tp(i[1],o);s&&a&&n.push({sourceId:s.step,targetId:a.step,label:s.edgeLabel||a.edgeLabel||""})}),{components:o,connections:n}},rp=e=>{let{components:t,connections:o}=$h(e);return{nodes:t,edges:o}};var sp=()=>{let{setNodes:e,setEdges:t}=(0,ip.useReactFlow)(),{fitToNodes:o}=Bn(),{getNextId:n}=Lt();return{importFromLia:i=>{let s=typeof i=="string"?i:i.diagramXml||"",{nodes:a,edges:l}=rp(s),c=[],d=new Map,u=!1,f=n();for(let[p,g]of Object.entries(a)){let y=String(f++),x=op[g.type],N=np[g.type];x==="START_EVENT"&&(u=!0),d.set(p,y);let b=ue[x].MIN_WIDTH,v=ue[x].MIN_HEIGHT;c.push({id:y,type:x,data:{label:g.label||"",variant:N,attribute:""},position:{x:0,y:0},width:b,height:v,measured:{width:b,height:v}})}let m=[];for(let p of l){let g=w(_({},Mt),{id:String(f++),source:d.get(p.sourceId)||p.sourceId,target:d.get(p.targetId)||p.targetId});m.push(g)}if(!u&&c.length>0){let p=String(f++),g={id:p,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:ue.START_EVENT.MIN_WIDTH,height:ue.START_EVENT.MIN_HEIGHT,measured:{width:ue.START_EVENT.MIN_WIDTH,height:ue.START_EVENT.MIN_HEIGHT}};c.unshift(g);let y=c[1];if(y){let x=w(_({},Mt),{id:String(f++),source:p,target:y.id});m.unshift(x)}}let{nodes:h,edges:E}=Od(c,m);e(h),t(E),o(h)}}};var as=require("react"),Kh={origin:"*",debug:!1};function ls(e,t=Kh){let{origin:o,debug:n}=t,r=(0,as.useCallback)((i,s)=>{let a={event:i,data:s};window.parent.postMessage(a,o||"*")},[o]);return(0,as.useEffect)(()=>{if(!e)return;let i=s=>{let a=s.data;if(!(a!=null&&a.event)||(a==null?void 0:a.data)===void 0)return;let{event:l,data:c}=a,d;if(Array.isArray(c)){let[,u]=c;d=u.data}else d=c;n&&(console.debug("[postMessage] received:",a),console.debug("[postMessage] eventData:",d)),l&&e[l]&&e[l](d)};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[e,n]),{sendMessage:r}}var ap=require("@xyflow/react"),go=require("react");var lp=()=>{let e=(0,ap.useNodesInitialized)(),{initialDiagram:t,isNewDiagram:o,setIsInitialized:n,onElementChanges:r}=q(),{importFromMxGraph:i,exportToMxGraph:s}=zn(),{sendMessage:a}=ls(),l=(0,go.useRef)(t),c=(0,go.useRef)(r),d=(0,go.useRef)(s);(0,go.useEffect)(()=>{c.current=r},[r]),(0,go.useEffect)(()=>{d.current=s},[s]),(0,go.useEffect)(()=>{t&&(i(t),l.current=t)},[t,i]),(0,go.useEffect)(()=>{if(!e)return;(async()=>{var f;if(await Yr(),n(!0),a("INIT_MODELER",l.current),!o){let m=d.current();(f=c.current)==null||f.call(c,m)}})()},[e,o,n,a])};var la=require("react"),cp=require("@xyflow/react");function dp(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=Fo(),{getEdges:n}=(0,cp.useReactFlow)(),r=Zr(),i=(0,la.useCallback)(a=>{if(!(a!=null&&a.activities))return;e(a.activities);let l=a.activities.map(d=>d.diagramId),c=n();o(c,l),setTimeout(()=>{r()},0)},[e,o,n,r]),s=(0,la.useCallback)(()=>{t(),setTimeout(()=>{r()},0)},[t,r]);return{handleTasksStatus:i,handleClearTaskStatus:s}}var pp=require("@xyflow/react"),ot=require("react"),fp=require("use-debounce");var Zh=500,up=100,mp=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=(0,pp.useReactFlow)(),{mode:i,containerRef:s}=q(),[a,l]=(0,ot.useState)({history:[],currentStep:0}),{history:c,currentStep:d}=a,u=d>0,f=d<c.length-1,m=(0,ot.useCallback)((T,I)=>{n(T[I].nodes),r(T[I].edges)},[n,r]),h=(0,ot.useCallback)(()=>{if(d>0){let T=d-1;l(I=>w(_({},I),{currentStep:T})),m(c,T)}},[d,c,m]),E=(0,ot.useCallback)(()=>{if(d<c.length-1){let T=d+1;l(I=>w(_({},I),{currentStep:T})),m(c,T)}},[c,d,m]),p=(0,ot.useCallback)(T=>{l(I=>{let S=I.history[I.currentStep];if(S&&JSON.stringify(S)===JSON.stringify(T))return I;let C=[...I.history.slice(0,I.currentStep+1),T],L=C.length>up?C.slice(C.length-up):C;return{history:L,currentStep:L.length-1}})},[]),g=(0,ot.useCallback)((T,I)=>{let S=T.map(R=>w(_({},R),{selected:!1,className:"",data:w(_({},R.data),{hasError:!1})})),P=I.map(R=>w(_({},R),{data:w(_({},R.data),{hasError:!1})}));return{nodes:Zn(S),edges:P}},[]),y=(0,ot.useCallback)(()=>g(t(),o()),[t,o,g]),x=(0,fp.useDebouncedCallback)(()=>{let T=y();p(T)},Zh),N=(0,ot.useCallback)((T,I)=>{if(!e)return;if(c.length===0){let R=y();l({history:[R],currentStep:0})}if(T==="forceSave"){if(I){p(g(I.nodes,I.edges));return}x();return}T.some(R=>R.type==="select")||T.some(R=>R.type==="position"&&R.dragging)||x()},[e,x,c.length,y,p,g]);(0,ot.useEffect)(()=>{if(e&&c.length===0){let T=y();l({history:[T],currentStep:0})}},[e,c.length,y]);let b=(0,ot.useCallback)(T=>{l({history:T||[],currentStep:0})},[]),v=(0,ot.useCallback)(()=>{l({history:[],currentStep:0})},[]);return(0,ot.useEffect)(()=>{if(i!=="edit")return;let T=s.current;if(!T)return;let I=S=>{if(!T.contains(document.activeElement)||!(S.ctrlKey||S.metaKey))return;let C=S.key.toLowerCase();if(S.shiftKey&&C==="z"){S.preventDefault(),E();return}C==="z"&&(S.preventDefault(),h())};return T.addEventListener("keydown",I),()=>{T.removeEventListener("keydown",I)}},[h,E,i,s]),{history:c,undo:h,redo:E,canUndo:u,canRedo:f,saveHistory:N,resetHistory:b,clearHistory:v}};var hp=()=>{let{t:e}=(0,gp.useTranslation)(),[t,o,n]=(0,jt.useNodesState)([]),[r,i,s]=(0,jt.useEdgesState)([]),{getNodes:a,getNode:l}=(0,jt.useReactFlow)(),{toast:c}=at(),d=(0,jt.useStoreApi)(),{instanceId:u,isInitialized:f,setIsConnecting:m,setIsMultipleSelection:h,onElementClick:E}=q(),{updateHelperLines:p,HelperLines:g}=Si(),{undo:y,redo:x,canUndo:N,canRedo:b,saveHistory:v}=mp(f),{onNodeDrag:T,onDrop:I,onDragOver:S,onDragLeave:P,onNodeDragStop:R,onNodeDragStart:C}=Ku({nodes:t,setNodes:o,setEdges:i,saveHistory:v}),{isValidConnection:L,onConnect:K,onReconnect:Q,onReconnectStart:j,onReconnectEnd:z,setReconnectingEdge:M,clearReconnectingEdge:V}=Au({setEdges:i,saveHistory:v}),{handleValidationComplete:D,clearValidation:A,dismissValidationPanel:B,validateDiagram:G,getIsClearingValidation:k}=Hu(),{importFromLia:O}=sp(),{handleTasksStatus:Y,handleClearTaskStatus:W}=dp(),{clearPathEdges:U}=Fo(),{emitElementChanges:X,handleNodeChanges:$,handleEdgeChanges:te}=rs(),ie=Zr();Fu({saveHistory:v}),Qu({saveHistory:v}),lp();let F=(0,Tt.useCallback)(()=>{o([]),i([]),U(),setTimeout(ie,0)},[o,i,U,ie]),{selectElements:oe,clearSelection:le}=So(),{importFromMxGraph:Z,exportToMxGraph:ve}=zn(),{configureElement:ye,getConfigureElement:Ae}=Ri(),J=(0,Tt.useCallback)(Ee=>{Ee!=null&&Ee.id&&oe([Ee.id])},[oe]),{sendMessage:de}=ls({LIA_CREATE_DIAGRAM:O,CLEAR_DIAGRAM:F,TASKS_STATUS:Y,CLEAR_TASKS_STATUS:W,EXTERNAL_TASK_SELECT:J}),re=(0,Tt.useCallback)(()=>t.length+r.length,[t,r]);(0,Tt.useEffect)(()=>(qt.set(u,{importFromMxGraph:Z,exportToMxGraph:ve,selectElements:oe,clearSelection:le,configureElement:ye,getConfigureElement:Ae,getElementsCount:re,setReconnectingEdge:M,clearReconnectingEdge:V}),()=>{qt.delete(u)}),[u,Z,ve,oe,le,ye,Ae,re,M,V]);let ee=(0,Tt.useCallback)((Ee,he)=>{if(he.type!=="TASK"&&he.type!=="GATEWAY")return;let pe=Ae(he.id);pe&&(E==null||E(pe)),he.type==="TASK"&&de("SELECT_TASK",{id:he.id})},[Ae,E,de]),xe=(0,Tt.useCallback)((Ee,he)=>{if(he.type!=="SEQUENCE_EDGE")return;let pe=l(he.source),De=l(he.target),{isFromStartEvent:ut,isGatewayToGateway:wt,isActiviyToAndGateway:nt,isToEndEvent:Yt}=qr(pe,De);if(!(!ut&&!wt&&!nt&&!Yt))return;let ro=Ae(he.id);ro&&(E==null||E(ro))},[Ae,l,E]),Se=(0,Tt.useCallback)(Ee=>{let he=p(Ee,t);n(he),v(Ee),k()||B(),$(Ee)},[t,n,v,k,B,p,$]),Re=(0,Tt.useCallback)(Ee=>{s(Ee),v(Ee),k()||B(),te(Ee)},[s,v,k,B,te]);ep(Se);let Ze=(0,Tt.useCallback)(({nodes:Ee,edges:he})=>{h(Ee.length+he.length>=2)},[h]);(0,jt.useOnSelectionChange)({onChange:Ze});let Nt=(0,Tt.useCallback)(async({nodes:Ee})=>Ee.some(pe=>pe.type==="LANE"&&t.some(De=>De.parentId===pe.id))?(c({variant:"error",title:e("validation.errors.title"),content:e("editor.toolbar.delete_pool_lane_error")}),!1):!0,[t,e,c]),no=()=>{v("forceSave"),X(),B()},Bt=()=>{m(!0)},zt=()=>{m(!1),B()},dt=(0,Tt.useCallback)(Ee=>{let he=new Set(Ee.filter(pe=>pe.type==="LANE"&&!!pe.parentId).map(pe=>pe.parentId));he.size!==0&&setTimeout(()=>{var ut,wt;let pe=a(),De=new Map(pe.map(nt=>[nt.id,nt]));for(let nt of he){let Yt=Wo(pe.filter(io=>io.type==="LANE"&&io.parentId===nt));if(Yt.length===0)continue;let yo=0;for(let io of Yt)De.set(io.id,w(_({},io),{position:{x:ae.HEADER_WIDTH,y:yo}})),yo+=(wt=(ut=io.measured)==null?void 0:ut.height)!=null?wt:0;let ro=De.get(nt);ro&&De.set(nt,w(_({},ro),{height:yo,measured:w(_({},ro.measured),{height:yo})}))}o(pe.map(nt=>{var Yt;return(Yt=De.get(nt.id))!=null?Yt:nt}))},0)},[a,o]);return{nodes:t,setNodes:o,edges:r,setEdges:i,events:{isValidConnection:L,onConnect:K,onReconnect:Q,onReconnectStart:j,onReconnectEnd:z,onDrop:I,onDragOver:S,onDragLeave:P,onNodeDrag:T,onNodeDragStop:R,onNodeDragStart:C,onNodeClick:ee,onEdgeClick:xe,onDropCapture:no,onConnectStart:Bt,onConnectEnd:zt,onSelectionEnd:()=>setTimeout(()=>d.setState({nodesSelectionActive:!1}),0),onNodesChange:Se,onEdgesChange:Re,onBeforeDelete:Nt,onNodesDelete:dt},ui:{handleCloseValidationPanel:A},controls:{undo:y,redo:x,canUndo:N,canRedo:b},components:{HelperLines:g},actions:{saveHistory:v,selectElements:oe,clearSelection:le,exportToMxGraph:ve,validateDiagram:G,handleValidationComplete:D,setReconnectingEdge:M,clearReconnectingEdge:V}}};var yp=require("@xyflow/react"),Ro=require("react");var Jh=".react-flow__node, .react-flow__edge, .react-flow__node-toolbar";function xp(e,t,o){let[n,r]=(0,Ro.useState)(!1),i=(0,Ro.useRef)(null),{getViewport:s,setViewport:a}=(0,yp.useReactFlow)(),l=(0,Ro.useCallback)(()=>{i.current=null,r(!1)},[]);return(0,Ro.useEffect)(()=>{let c=e.current;if(!c)return;let d=m=>{if(!Ir.some(E=>E===m.button)||t.current||o.current||(r(!0),!(m.target instanceof Element))||!m.target.closest(Jh))return;m.preventDefault(),m.stopPropagation();let h=s();i.current={pointerX:m.clientX,pointerY:m.clientY,viewportX:h.x,viewportY:h.y,zoom:h.zoom}},u=m=>{let h=i.current;if(h){if((m.buttons&ia)===0){l();return}a({x:h.viewportX+(m.clientX-h.pointerX),y:h.viewportY+(m.clientY-h.pointerY),zoom:h.zoom})}},f=m=>{(m.buttons&ia)===0&&l()};return c.addEventListener("pointerdown",d,!0),window.addEventListener("pointermove",u),window.addEventListener("pointerup",f),window.addEventListener("pointercancel",l),window.addEventListener("blur",l),()=>{c.removeEventListener("pointerdown",d,!0),window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",l),window.removeEventListener("blur",l)}},[e,t,o,s,a,l]),n}var ca=require("react/jsx-runtime"),cs=({id:e,className:t})=>(0,ca.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,ca.jsx)("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});var rn=require("react/jsx-runtime"),Ep=()=>(0,rn.jsx)("svg",{style:{position:"absolute",top:0,left:0},children:(0,rn.jsxs)("defs",{children:[(0,rn.jsx)(cs,{id:"sequence-edge-marker",className:"text-grey-500"}),(0,rn.jsx)(cs,{id:"sequence-edge-marker-hovered",className:"text-grey-800"}),(0,rn.jsx)(cs,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});var Vo=require("@produto-lecom/lecom-ui");var Rr=require("@xyflow/react"),Be=require("@produto-lecom/lecom-ui"),eo=require("lucide-react"),ho=require("react");var Do=require("@produto-lecom/lecom-ui");var Lr=(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))(Lr||{});var us=require("@produto-lecom/lecom-ui"),Mp=require("@xyflow/react");var _p=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 bp({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let r="data:text/csv;charset=utf-8,"+[e,...t].map(s=>s.join(",")).join(`
43
+ `),i=encodeURI(r);ds(i,`${o}.csv`)}var ds=(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 Tp(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}var ZC={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},vp={script:"SCRIPT",subprocess:"SUBPROCESS"},Np={"marker-loop":"LOOP"},wp={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL",inclusive:"EXCLUSIVE"};var sn=({cell:e,type:t,variant:o="",attribute:n=""})=>{let{_attributes:r,mxGeometry:i}=e,{value:s,parent:a}=r,l=Number(i._attributes.width),c=Number(i._attributes.height),d=a==="1"?void 0:a;return{id:r.id,parentId:d,type:t,data:{label:s||"",variant:o,attribute:n},position:{x:Number(i._attributes.x)||0,y:Number(i._attributes.y)||0},width:l,height:c,measured:{width:l,height:c}}},jh=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=ue.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=ue.START_EVENT.MIN_HEIGHT,{node:sn({cell:e,type:"START_EVENT"}),status:n,originalType:o}},ey=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=ue.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=ue.END_EVENT.MIN_HEIGHT,{node:sn({cell:e,type:"END_EVENT"}),status:n,originalType:o}},ty=(e,t)=>{let{id:o,subType:n,style:r}=e==null?void 0:e._attributes,i=vp[n],s=t.get(o)||"",a=Np[s]||"",l=a==="LOOP",c="imported";return!["script","none"].includes(n)&&!l&&(c="adapted"),e.mxGeometry._attributes.width=Eo(e.mxGeometry._attributes.width||0,ue.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=Eo(e.mxGeometry._attributes.height||0,ue.TASK.MIN_HEIGHT),{node:sn({cell:e,type:"TASK",variant:i,attribute:a}),status:c,originalType:r}},oy=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=wp[o],r=["none","inclusive","event-based"],i="imported";return r.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=ue.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=ue.GATEWAY.MIN_HEIGHT,{node:sn({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},ny=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:sn({cell:e,type:"LANE"}),status:"imported",originalType:t}},ry=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=Eo(e.mxGeometry._attributes.width||0,ue.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=Eo(e.mxGeometry._attributes.height||0,ue.ANNOTATION.MIN_HEIGHT),{node:sn({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},Ip=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=ue.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=ue.UNSUPPORTED.MIN_HEIGHT,{node:sn({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},Ap=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return w(_({},Mt),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},Sp={TASK:ty,GATEWAY:oy,START_EVENT:jh,END_EVENT:ey,LANE:ny,ANNOTATION:ry};var iy=e=>{let t=new Map,o=Object.values(Lr),n=[],r=new Map;e.forEach(a=>{var c;let l=(c=a._attributes)==null?void 0:c.type;if(l==="MARKER"){r.set(a._attributes.parent,a._attributes.style);return}if(o.includes(l)){n.push(a);return}});let i=[],s=[];for(let a of n){let{type:l}=a._attributes,c=Sp[l]||Ip,{node:d,status:u,originalType:f}=c(a,r);s.push(d),i.push({originalType:f,type:d.type,variant:d.data.variant,value:Tp(d.data.label),status:u})}return{nodes:s,governanceIdToNodeIdMap:t,summary:i}},sy=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>Ap(r,t)),ay=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=iy(t.root.mxCell),i=sy(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},ly=async e=>{let t=await _p(e),o=Ui(t);if(!o)throw new Error("EMPTY_FILE");let{metadata:n,mxGraphModel:r}=o.modeler||{},i=(n==null?void 0:n.app)&&(n==null?void 0:n.diagramType)&&(n==null?void 0:n.version),s=r==null?void 0:r.root;if(!i||!s)throw new Error("INVALID_FILE");if(!Object.keys(r.root.mxCell||{}).length)throw new Error("CONTAIN_NO_CELLS");return{metadata:n,mxGraphModel:r}},Cp=async e=>{try{let t=await ly(e),{nodes:o,edges:n,summary:r}=ay(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};var Lp=require("react/jsx-runtime"),Pp=()=>{let{t:e}=(0,us.useTranslation)(),{toast:t}=at(),{setNodes:o,setEdges:n}=(0,Mp.useReactFlow)(),{fitToNodes:r}=Bn(),i=a=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],c=a.map(d=>[d.originalType,d.value,e(`adapter.governance.report.status.${d.status.toLowerCase()}`)]);t({variant:"warning",content:e("adapter.governance.success.incompatible_cells"),duration:1e3*60*1,action:(0,Lp.jsx)(us.Button,{size:"small",variant:"ghost",onClick:()=>bp({columns:l,rows:c,fileName:"governance-imported-cells"}),children:e("adapter.governance.action.download")})})};return{importFromGovernance:async a=>{try{let{nodes:l,edges:c,summary:d}=await Cp(a);if(o(f=>f.concat(l)),n(f=>f.concat(c)),r(l),d.some(f=>f.status==="unsupported")){i(d);return}t({variant:"success",content:e("adapter.governance.success.default")})}catch(l){let c=l instanceof Error?l.message:"DEFAULT";t({variant:"error",content:e(`adapter.governance.error.${c}`)})}}}};var kp=require("@produto-lecom/lecom-ui"),Rp=require("react");var an=require("react/jsx-runtime"),Dp=a=>{var l=a,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,s=Wt(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=(0,Rp.useRef)(null),d=f=>{let m=f.target.files;m!=null&&m.length&&i(m),c.current&&(c.current.value="")};return(0,an.jsxs)(an.Fragment,{children:[(0,an.jsx)(kp.Button,w(_({disabled:n,onClick:f=>{var m;(m=c.current)==null||m.click(),r==null||r(f)}},s),{children:e})),(0,an.jsx)("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};var ln=require("react/jsx-runtime"),Op=({disabled:e=!1})=>{let{t}=(0,Do.useTranslation)(),{toast:o}=at(),{importFromGovernance:n}=Pp(),r=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},i=s=>{let a=s[0];if(!a){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}n(a)};return(0,ln.jsxs)(Do.Tooltip,{children:[(0,ln.jsx)(Do.TooltipTrigger,{asChild:!0,children:(0,ln.jsx)(Dp,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:(0,ln.jsx)(wa,{})})}),(0,ln.jsx)(Do.TooltipContent,{color:"black",children:t("editor.controls.actions.import_governance")})]})};var Vp=require("react/jsx-runtime"),da=({shortcut:e})=>(0,Vp.jsx)("span",{className:"min-h-7.5 inline-flex justify-center items-center py-0.5 px-1.5 bg-grey-100 border border-grey-300 font-mono text-gray-800 shadow-lg rounded-md text-grey-900",children:e});var Te=require("@produto-lecom/lecom-ui"),Oo=require("lucide-react"),Wp=require("react");var Gp=require("@produto-lecom/lecom-ui"),Bp=require("@xyflow/react"),kr=require("html-to-image"),zp=require("react");var cy=3,ua="diagram",ps=50,dy=96,uy=25.4,py="sequence-edge-marker",Hp=e=>e*uy/dy,fy=e=>{let t=document.getElementById(py);if(!(t instanceof SVGElement)||!t.ownerSVGElement)return null;let n=t.ownerSVGElement.cloneNode(!0);return n.style.position="absolute",n.style.width="0",n.style.height="0",n.style.overflow="hidden",n.setAttribute("aria-hidden","true"),n.setAttribute("data-export-marker-defs","true"),e.prepend(n),n},Yp=()=>{let{t:e}=(0,Gp.useTranslation)(),{toast:t}=at(),{getEdges:o,getNodes:n,getNodesBounds:r}=(0,Bp.useReactFlow)(),{clearSelection:i}=So(),[s,a]=(0,zp.useState)({png:!1,html:!1,print:!1}),l=()=>{let m=Js(n(),o()),h=r(m),E=h.width+ps*2,p=h.height+ps*2,g=ps-h.x,y=ps-h.y;return{width:E,height:p,style:{width:`${E}px`,height:`${p}px`,transform:`translate(${g}px, ${y}px)`,transformOrigin:"top left"}}},c=async(m,h)=>{a(E=>w(_({},E),{[h]:!0})),await i();try{if(Js(n(),o()).length===0){t({content:e("editor.controls.actions.export.feedback.empty"),variant:"warning"});return}let p=Vd();if(!p)throw new Error("Flow element not found");let g=l(),y=fy(p);try{return await m(p,g)}finally{y==null||y.remove()}}catch(E){console.error("Diagram export failed",E),t({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{a(E=>w(_({},E),{[h]:!1}))}};return{exportAsPng:async(m=ua)=>{await c(async(h,E)=>{let p=await(0,kr.toPng)(h,w(_({},E),{backgroundColor:"#fcfcfc",skipFonts:!0}));ds(p,`${m}.png`)},"png")},exportAsHtml:async(m=ua)=>{await c(async(h,E)=>{let p=await(0,kr.toSvg)(h,w(_({},E),{backgroundColor:"#fcfcfc",skipFonts:!0})),g=`
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="${f}" alt="${m}" />
68
+ <img src="${p}" alt="${m}" />
69
69
  </body>
70
- </html>`,y=new Blob([h],{type:"text/html"}),E=URL.createObjectURL(y);us(E,`${m}.html`),window.setTimeout(()=>URL.revokeObjectURL(E),1e4)},"html")},printDiagram:async(m=pa)=>{await c(async(g,x)=>{var S;let f=await(0,Dr.toPng)(g,w(_({},x),{backgroundColor:"#fcfcfc",pixelRatio:ny,skipFonts:!0})),h=document.createElement("iframe");h.style.position="fixed",h.style.right="0",h.style.bottom="0",h.style.width="0",h.style.height="0",h.style.border="0",document.body.appendChild(h);let y=(S=h.contentWindow)==null?void 0:S.document;if(!y)throw document.body.removeChild(h),new Error("Unable to access print iframe document");let E=Rp(x.width).toFixed(2),N=Rp(x.height).toFixed(2),b=y.createElement("style");b.textContent=`
70
+ </html>`,y=new Blob([g],{type:"text/html"}),x=URL.createObjectURL(y);ds(x,`${m}.html`),window.setTimeout(()=>URL.revokeObjectURL(x),1e4)},"html")},printDiagram:async(m=ua)=>{await c(async(h,E)=>{var S;let p=await(0,kr.toPng)(h,w(_({},E),{backgroundColor:"#fcfcfc",pixelRatio:cy,skipFonts:!0})),g=document.createElement("iframe");g.style.position="fixed",g.style.right="0",g.style.bottom="0",g.style.width="0",g.style.height="0",g.style.border="0",document.body.appendChild(g);let y=(S=g.contentWindow)==null?void 0:S.document;if(!y)throw document.body.removeChild(g),new Error("Unable to access print iframe document");let x=Hp(E.width).toFixed(2),N=Hp(E.height).toFixed(2),b=y.createElement("style");b.textContent=`
71
71
  @page {
72
- size: ${E}mm ${N}mm;
72
+ size: ${x}mm ${N}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
- `,y.head.appendChild(b),y.title=m;let v=y.createElement("img");v.alt="Diagram",y.body.appendChild(v),await new Promise((P,R)=>{let C=!1,L=K=>{C||(C=!0,K?R(K):P())};v.onload=()=>L(),v.onerror=()=>L(new Error("Failed to load print image")),v.src=f,v.complete&&v.naturalWidth>0&&L()});let T=h.contentWindow;if(!T)throw document.body.removeChild(h),new Error("Unable to access print iframe window");let I=()=>{h.parentNode&&document.body.removeChild(h)};T.addEventListener("afterprint",I,{once:!0}),window.setTimeout(I,6e4),T.focus(),T.print()},"print")},isPrintingPng:s.png,isPrintingHtml:s.html,isPrinting:s.print}};var Ie=require("react/jsx-runtime");function Bp(){let{t:e}=(0,Te.useTranslation)(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:s}=Hp(),[a,l]=(0,Gp.useState)(!1);return(0,Ie.jsxs)(Te.DropdownMenu,{modal:!1,open:a,onOpenChange:l,children:[(0,Ie.jsx)(Te.DropdownMenuTrigger,{asChild:!0,children:(0,Ie.jsx)("div",{children:(0,Ie.jsxs)(Te.Tooltip,{children:[(0,Ie.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,Ie.jsx)(Te.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:(0,Ie.jsx)(Oo.FolderOutputIcon,{})})}),!a&&(0,Ie.jsx)(Te.TooltipContent,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),(0,Ie.jsxs)(Te.DropdownMenuContent,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[(0,Ie.jsxs)(Te.Tooltip,{children:[(0,Ie.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,Ie.jsx)(Te.DropdownMenuItem,{className:"p-1.5",disabled:i,onClick:()=>t(),children:(0,Ie.jsx)(Oo.FileImageIcon,{})})}),(0,Ie.jsx)(Te.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),(0,Ie.jsxs)(Te.Tooltip,{children:[(0,Ie.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,Ie.jsx)(Te.DropdownMenuItem,{className:"p-1.5",disabled:s,onClick:()=>o(),children:(0,Ie.jsx)(Oo.FileCodeIcon,{})})}),(0,Ie.jsx)(Te.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),(0,Ie.jsxs)(Te.Tooltip,{children:[(0,Ie.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,Ie.jsx)(Te.DropdownMenuItem,{className:"p-1.5",disabled:r,onClick:()=>n(),children:(0,Ie.jsx)(Oo.PrinterIcon,{})})}),(0,Ie.jsx)(Te.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}var me=require("react/jsx-runtime"),zp=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=(0,Be.useTranslation)(),{clearSelection:i}=Co(),{mode:s,containerRef:a,isMinimapOpen:l,setIsMinimapOpen:c,isMoveTool:d,isHandTool:u,setIsMoveTool:p,setIsHandTool:m}=q(),{getNodes:g,getEdges:x}=(0,Or.useReactFlow)(),f=(0,Or.useKeyPress)(["v","V"],{target:a==null?void 0:a.current}),h=(0,Or.useKeyPress)(["h","H"],{target:a==null?void 0:a.current}),y=(0,yo.useCallback)(()=>{i(),m(!0),p(!1)},[i,m,p]),E=(0,yo.useCallback)(()=>{p(!0),m(!1)},[p,m]),[N,b]=(0,yo.useState)(!1),v=(0,yo.useCallback)(async()=>{b(!0);try{let T=g(),I=x(),S=await o({nodes:T,edges:I});n(S)}finally{b(!1)}},[g,x,o,n]);return(0,yo.useEffect)(()=>{f&&!d&&s==="edit"&&E()},[f,E,d,s]),(0,yo.useEffect)(()=>{h&&!u&&s==="edit"&&y()},[h,y,u,s]),(0,me.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[s==="edit"&&(0,me.jsxs)(me.Fragment,{children:[(0,me.jsxs)(Be.Tooltip,{children:[(0,me.jsx)(Be.TooltipTrigger,{asChild:!0,children:(0,me.jsx)(Be.Button,{size:"small",variant:"ghost",color:"grey",className:H(d&&"bg-grey-400"),iconButton:!0,onClick:E,children:(0,me.jsx)(eo.MousePointerIcon,{})})}),(0,me.jsxs)(Be.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),(0,me.jsx)(ua,{shortcut:"V"})]})]}),(0,me.jsxs)(Be.Tooltip,{children:[(0,me.jsx)(Be.TooltipTrigger,{asChild:!0,children:(0,me.jsx)(Be.Button,{size:"small",variant:"ghost",color:"grey",className:H(u&&"bg-grey-400"),iconButton:!0,onClick:y,children:(0,me.jsx)(eo.HandIcon,{})})}),(0,me.jsxs)(Be.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",(0,me.jsx)(ua,{shortcut:"H"})]})]})]}),(0,me.jsx)(Bp,{}),s==="edit"&&(0,me.jsxs)(me.Fragment,{children:[(0,me.jsxs)(Be.Tooltip,{children:[(0,me.jsx)(Be.TooltipTrigger,{asChild:!0,children:(0,me.jsx)(Be.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:N,onClick:v,children:N?(0,me.jsx)(eo.Loader2Icon,{className:"animate-spin"}):(0,me.jsx)(eo.ListCheckIcon,{})})}),(0,me.jsx)(Be.TooltipContent,{color:"black",children:r(N?"editor.controls.actions.check_loading":"editor.controls.actions.check")})]}),(0,me.jsx)(Lp,{disabled:e.length>0||t.length>0})]}),(0,me.jsxs)(Be.Tooltip,{children:[(0,me.jsx)(Be.TooltipTrigger,{asChild:!0,children:(0,me.jsx)(Be.Button,{size:"small",variant:"ghost",color:"grey",className:H(l&&"bg-grey-400"),iconButton:!0,onClick:()=>c(!l),children:(0,me.jsx)(eo.MapIcon,{})})}),(0,me.jsx)(Be.TooltipContent,{color:"black",children:r(l?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};var ct=require("@produto-lecom/lecom-ui"),ms=require("lucide-react"),vt=require("react/jsx-runtime"),Yp=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=(0,ct.useTranslation)();return(0,vt.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,vt.jsxs)(ct.Tooltip,{children:[(0,vt.jsx)(ct.TooltipTrigger,{asChild:!0,children:(0,vt.jsx)(ct.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:(0,vt.jsx)(ms.UndoIcon,{})})}),(0,vt.jsx)(ct.TooltipContent,{color:"black",children:r("editor.controls.history.undo")})]}),(0,vt.jsxs)(ct.Tooltip,{children:[(0,vt.jsx)(ct.TooltipTrigger,{asChild:!0,children:(0,vt.jsx)(ct.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:(0,vt.jsx)(ms.RedoIcon,{})})}),(0,vt.jsx)(ct.TooltipContent,{color:"black",children:r("editor.controls.history.redo")})]})]})};var Xn=require("@xyflow/react"),ze=require("@produto-lecom/lecom-ui"),Un=require("lucide-react");var Ve=require("react/jsx-runtime"),Wp=()=>{let{t:e}=(0,ze.useTranslation)(),t=(0,Xn.useNodes)(),o=(0,Xn.useEdges)(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:s}=(0,Xn.useReactFlow)(),a=t.length===0&&o.length===0;return(0,Ve.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,Ve.jsxs)(ze.Tooltip,{children:[(0,Ve.jsx)(ze.TooltipTrigger,{asChild:!0,children:(0,Ve.jsx)(ze.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>s(),children:(0,Ve.jsx)(Un.ScanIcon,{})})}),(0,Ve.jsx)(ze.TooltipContent,{color:"black",children:e("editor.controls.zoom.fit")})]}),(0,Ve.jsxs)(ze.Tooltip,{children:[(0,Ve.jsx)(ze.TooltipTrigger,{asChild:!0,children:(0,Ve.jsx)(ze.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>r(),children:(0,Ve.jsx)(Un.ZoomOut,{})})}),(0,Ve.jsx)(ze.TooltipContent,{color:"black",children:e("editor.controls.zoom.out")})]}),(0,Ve.jsxs)(ze.Tooltip,{children:[(0,Ve.jsx)(ze.TooltipTrigger,{asChild:!0,children:(0,Ve.jsx)(ze.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>i(1),children:(0,Ve.jsx)(Ma,{})})}),(0,Ve.jsx)(ze.TooltipContent,{color:"black",children:e("editor.controls.zoom.reset")})]}),(0,Ve.jsxs)(ze.Tooltip,{children:[(0,Ve.jsx)(ze.TooltipTrigger,{asChild:!0,children:(0,Ve.jsx)(ze.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>n(),children:(0,Ve.jsx)(Un.ZoomIn,{})})}),(0,Ve.jsx)(ze.TooltipContent,{color:"black",children:e("editor.controls.zoom.in")})]})]})};var Fp=require("@xyflow/react"),to=require("@produto-lecom/lecom-ui"),gs=require("react");var Xp=require("lucide-react");var Gt=require("react/jsx-runtime"),Up=()=>{let e=(0,gs.useRef)(null),{t}=(0,to.useTranslation)(),{setDraggableNode:o}=Hn(),n=(0,Fp.useNodes)(),{setIsDragging:r}=q(),[i,s]=(0,gs.useState)(void 0),a=[{type:"START_EVENT",icon:Ur,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:un,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:Jn,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:Qn,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SERVICE_TASK",icon:Xp.Bot,label:t("bpmn.task.variant.service_task")},{type:"TASK",variant:"SCRIPT",icon:La,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:Pa,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:mn,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:hn,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:pn,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:Ca,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:Wr,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),s((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:a.map((c,d)=>{let u=!So(c.type,n),p=u?t("editor.toolbar.start_event_already_exists"):c.label;return(0,Gt.jsxs)(to.Tooltip,{children:[(0,Gt.jsx)(to.TooltipTrigger,{asChild:!0,children:(0,Gt.jsx)(to.Button,{className:H("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":u}),size:"small",variant:"ghost",color:"grey",draggable:!u,disabled:u,iconButton:!0,onDragStart:u?void 0:m=>l(m,c),children:(0,Gt.jsx)(c.icon,{})},d)}),(0,Gt.jsx)(to.TooltipContent,{color:"black",side:"right",children:p})]},d)})}),(0,Gt.jsx)("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};var Je=require("react/jsx-runtime"),fa=e=>e.preventDefault(),ma=(0,dn.forwardRef)((e,t)=>{let{instanceId:o,containerRef:n,mode:r,isMinimapOpen:i,isMoveTool:s,isHandTool:a}=q(),l=(0,oo.useKeyPress)("Space",{target:n==null?void 0:n.current}),c=(0,dn.useRef)(a),d=(0,dn.useRef)(l),{nodes:u,edges:p,actions:m,events:g,components:x,controls:f}=pp(),{t:h}=(0,Vo.useTranslation)();c.current=a,d.current=l;let y=mp(n,c,d);(0,dn.useImperativeHandle)(t,()=>({selectElements:m.selectElements,clearSelection:m.clearSelection}));let E=a||l||r!=="edit",N=E?[0,1,2]:Sr,b=a||l||y,v=s&&!l&&!y,T=r==="edit"&&v,I=!E&&!y,S=r==="view"||v;return(0,Je.jsxs)("div",{ref:n,className:"w-full h-full outline-none",tabIndex:0,children:[r==="edit"&&(0,Je.jsx)(Up,{}),(0,Je.jsx)(gp,{}),(0,Je.jsxs)(oo.ReactFlow,w(_({},g),{id:`modeler-${o}`,className:H(r.toLowerCase(),{"is-hand-tool":b,"is-pan-tool-active":b}),edges:p,nodes:u,nodeTypes:du,edgeTypes:uu,minZoom:ia,maxZoom:yu,panOnDrag:N,panOnScroll:!0,selectionOnDrag:I,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:S,nodesConnectable:T,nodesDraggable:T,connectionLineComponent:au,selectionMode:oo.SelectionMode.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:T?"Delete":null,selectionKeyCode:null,defaultViewport:xu,connectOnClick:!1,connectionRadius:50,onPaneContextMenu:fa,onNodeContextMenu:fa,onEdgeContextMenu:fa,proOptions:{hideAttribution:!0},children:[(0,Je.jsx)(oo.Background,{gap:gu,size:mu,color:fu,bgColor:pu}),i&&(0,Je.jsxs)(Vo.Tooltip,{children:[(0,Je.jsx)(Vo.TooltipTrigger,{asChild:!0,children:(0,Je.jsx)("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:(0,Je.jsx)(oo.MiniMap,{pannable:!0,zoomable:!0,position:hu,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),(0,Je.jsx)(Vo.TooltipContent,{color:"black",children:h("editor.controls.actions.minimap.label")})]}),(0,Je.jsxs)("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&(0,Je.jsx)(Yp,_({},f)),r!=="readonly"&&(0,Je.jsx)(zp,{nodes:u,edges:p,validateDiagram:m.validateDiagram,handleValidationComplete:m.handleValidationComplete}),(0,Je.jsx)(Wp,{})]}),(0,Je.jsx)(x.HelperLines,{})]}))]})});ma.displayName="Editor";var $p=require("@xyflow/react"),hs=require("react"),Kp=require("react/jsx-runtime"),ly=e=>({width:e.width,height:e.height,transform:e.transform}),ga="rgba(51, 103, 217, 0.4)",Fc=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=(0,$p.useStore)(ly),i=(0,hs.useRef)(null);return(0,hs.useEffect)(()=>{let s=i.current,a=s==null?void 0:s.getContext("2d");if(!a||!s)return;let l=window.devicePixelRatio;s.width=o*l,s.height=n*l,a.clearRect(0,0,o,n),a.scale(l,l),a.strokeStyle=ga,t&&(a.beginPath(),a.strokeStyle=t.color||ga,a.moveTo(t.position*r[2]+r[0],0),a.lineTo(t.position*r[2]+r[0],n),a.stroke()),e&&(a.beginPath(),a.strokeStyle=e.color||ga,a.moveTo(0,e.position*r[2]+r[1]),a.lineTo(o,e.position*r[2]+r[1]),a.stroke())},[o,n,r,e,t]),(0,Kp.jsx)("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};var $n=require("@produto-lecom/lecom-ui"),Ho=require("react");var Vr=require("react/jsx-runtime"),qt=new Map,qp=(0,Ho.createContext)(null),Sn=()=>{let e=(0,Ho.useContext)(qp);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},Zp=({locale:e,defaultMode:t="view",toast:o,children:n})=>{let[r,i]=(0,Ho.useState)(e||"pt_BR");(0,Ho.useEffect)(()=>{e&&(i(e),$n.i18n.changeLanguage(e))},[e]);let s=g=>{let x=qt.size;if(x===0)throw new Error("No modeler instances found");if(x===1||!g){let[h]=qt.values();return h}let f=qt.get(g);if(!f)throw new Error(`Modeler instance with ID "${g}" not found`);return f},a=(g,x)=>{let f=s(x);return f==null?void 0:f.selectElements(g)},l=async g=>{let x=s(g);return x==null?void 0:x.clearSelection()},c=(g,x)=>{let f=s(x);return f==null?void 0:f.configureElement(g)},d=(g,x)=>{let f=s(x);return f==null?void 0:f.getConfigureElement(g)},u=async(g,x)=>{let f=s(x);await(f==null?void 0:f.importFromMxGraph(g))},p=g=>{let x=s(g);return x==null?void 0:x.exportToMxGraph()},m=g=>{let x=s(g);return(x==null?void 0:x.getElementsCount())||0};return(0,Vr.jsx)(qp.Provider,{value:{defaultMode:t,locale:r,selectElements:a,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:u,exportDiagram:p,getElementsCount:m,toast:o},children:(0,Vr.jsxs)($n.TooltipProvider,{children:[!o&&(0,Vr.jsx)($n.Notification,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};var ys=require("react/jsx-runtime"),jp=(0,Le.createContext)(null),q=()=>{let e=(0,Le.useContext)(jp);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},ef=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,edgeHighlight:r=!0,validateCustomDiagram:i,onElementChanges:s,onConfigureElement:a,onElementClick:l,onSubprocessValidationClick:c})=>{let d=(0,Le.useRef)(null),{t:u}=(0,Jp.useTranslation)(),{defaultMode:p}=Sn(),m=(0,Le.useId)(),[g]=(0,Le.useState)(o||m),[x,f]=(0,Le.useState)(n||p||"edit"),[h,y]=(0,Le.useState)(_r),[E,N]=(0,Le.useState)(!1),[b,v]=(0,Le.useState)(!0),[T,I]=(0,Le.useState)(!1),[S,P]=(0,Le.useState)(!1),[R,C]=(0,Le.useState)(!1),[L,K]=(0,Le.useState)(!1),[Q,j]=(0,Le.useState)(!1),[z,M]=(0,Le.useState)(null);(0,Le.useEffect)(()=>{n&&f(n)},[n]);let V=!!t,D=(0,Le.useMemo)(()=>t||Dd(u),[t,u]),A=(0,Le.useMemo)(()=>({instanceId:g,containerRef:d,initialDiagram:D,mode:x,edgeHighlight:r,isEdit:x==="edit",isView:x==="view",isReadOnly:x==="readonly",isNewDiagram:V,lastElementId:h,isInitialized:E,isMinimapOpen:S,isMoveTool:b,isHandTool:T,isDragging:R,isMultipleSelection:Q,isConnecting:L,setLastElementId:y,setIsInitialized:N,reconnectingEdgeId:z,setIsMinimapOpen:P,setIsMoveTool:v,setIsHandTool:I,setIsDragging:C,setIsConnecting:K,setIsMultipleSelection:j,setReconnectingEdgeId:M,validateCustomDiagram:i,onElementChanges:s,onConfigureElement:a,onElementClick:l,onSubprocessValidationClick:c}),[g,d,D,x,r,V,h,E,S,b,T,R,Q,L,z,i,s,a,l,c]);return(0,ys.jsx)(Qp.ReactFlowProvider,{children:(0,ys.jsx)(jp.Provider,{value:A,children:(0,ys.jsx)(ma,{ref:e})})})};0&&(module.exports={EditorMode,ElementPosition,ElementType,GatewayElementVariant,GatewayVariant,Modeler,ModelerProvider,NodeAttribute,NodeType,NodeVariant,RoutingVariant,useModeler});
86
+ `,y.head.appendChild(b),y.title=m;let v=y.createElement("img");v.alt="Diagram",y.body.appendChild(v),await new Promise((P,R)=>{let C=!1,L=K=>{C||(C=!0,K?R(K):P())};v.onload=()=>L(),v.onerror=()=>L(new Error("Failed to load print image")),v.src=p,v.complete&&v.naturalWidth>0&&L()});let T=g.contentWindow;if(!T)throw document.body.removeChild(g),new Error("Unable to access print iframe window");let I=()=>{g.parentNode&&document.body.removeChild(g)};T.addEventListener("afterprint",I,{once:!0}),window.setTimeout(I,6e4),T.focus(),T.print()},"print")},isPrintingPng:s.png,isPrintingHtml:s.html,isPrinting:s.print}};var Ie=require("react/jsx-runtime");function Fp(){let{t:e}=(0,Te.useTranslation)(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:s}=Yp(),[a,l]=(0,Wp.useState)(!1);return(0,Ie.jsxs)(Te.DropdownMenu,{modal:!1,open:a,onOpenChange:l,children:[(0,Ie.jsx)(Te.DropdownMenuTrigger,{asChild:!0,children:(0,Ie.jsx)("div",{children:(0,Ie.jsxs)(Te.Tooltip,{children:[(0,Ie.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,Ie.jsx)(Te.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:(0,Ie.jsx)(Oo.FolderOutputIcon,{})})}),!a&&(0,Ie.jsx)(Te.TooltipContent,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),(0,Ie.jsxs)(Te.DropdownMenuContent,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[(0,Ie.jsxs)(Te.Tooltip,{children:[(0,Ie.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,Ie.jsx)(Te.DropdownMenuItem,{className:"p-1.5",disabled:i,onClick:()=>t(),children:(0,Ie.jsx)(Oo.FileImageIcon,{})})}),(0,Ie.jsx)(Te.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),(0,Ie.jsxs)(Te.Tooltip,{children:[(0,Ie.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,Ie.jsx)(Te.DropdownMenuItem,{className:"p-1.5",disabled:s,onClick:()=>o(),children:(0,Ie.jsx)(Oo.FileCodeIcon,{})})}),(0,Ie.jsx)(Te.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),(0,Ie.jsxs)(Te.Tooltip,{children:[(0,Ie.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,Ie.jsx)(Te.DropdownMenuItem,{className:"p-1.5",disabled:r,onClick:()=>n(),children:(0,Ie.jsx)(Oo.PrinterIcon,{})})}),(0,Ie.jsx)(Te.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}var me=require("react/jsx-runtime"),Xp=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=(0,Be.useTranslation)(),{clearSelection:i}=So(),{mode:s,containerRef:a,isMinimapOpen:l,setIsMinimapOpen:c,isMoveTool:d,isHandTool:u,setIsMoveTool:f,setIsHandTool:m}=q(),{getNodes:h,getEdges:E}=(0,Rr.useReactFlow)(),p=(0,Rr.useKeyPress)(["v","V"],{target:a==null?void 0:a.current}),g=(0,Rr.useKeyPress)(["h","H"],{target:a==null?void 0:a.current}),y=(0,ho.useCallback)(()=>{i(),m(!0),f(!1)},[i,m,f]),x=(0,ho.useCallback)(()=>{f(!0),m(!1)},[f,m]),[N,b]=(0,ho.useState)(!1),v=(0,ho.useCallback)(async()=>{b(!0);try{let T=h(),I=E(),S=await o({nodes:T,edges:I});n(S)}finally{b(!1)}},[h,E,o,n]);return(0,ho.useEffect)(()=>{p&&!d&&s==="edit"&&x()},[p,x,d,s]),(0,ho.useEffect)(()=>{g&&!u&&s==="edit"&&y()},[g,y,u,s]),(0,me.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[s==="edit"&&(0,me.jsxs)(me.Fragment,{children:[(0,me.jsxs)(Be.Tooltip,{children:[(0,me.jsx)(Be.TooltipTrigger,{asChild:!0,children:(0,me.jsx)(Be.Button,{size:"small",variant:"ghost",color:"grey",className:H(d&&"bg-grey-400"),iconButton:!0,onClick:x,children:(0,me.jsx)(eo.MousePointerIcon,{})})}),(0,me.jsxs)(Be.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),(0,me.jsx)(da,{shortcut:"V"})]})]}),(0,me.jsxs)(Be.Tooltip,{children:[(0,me.jsx)(Be.TooltipTrigger,{asChild:!0,children:(0,me.jsx)(Be.Button,{size:"small",variant:"ghost",color:"grey",className:H(u&&"bg-grey-400"),iconButton:!0,onClick:y,children:(0,me.jsx)(eo.HandIcon,{})})}),(0,me.jsxs)(Be.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",(0,me.jsx)(da,{shortcut:"H"})]})]})]}),(0,me.jsx)(Fp,{}),s==="edit"&&(0,me.jsxs)(me.Fragment,{children:[(0,me.jsxs)(Be.Tooltip,{children:[(0,me.jsx)(Be.TooltipTrigger,{asChild:!0,children:(0,me.jsx)(Be.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:N,onClick:v,children:N?(0,me.jsx)(eo.Loader2Icon,{className:"animate-spin"}):(0,me.jsx)(eo.ListCheckIcon,{})})}),(0,me.jsx)(Be.TooltipContent,{color:"black",children:r(N?"editor.controls.actions.check_loading":"editor.controls.actions.check")})]}),(0,me.jsx)(Op,{disabled:e.length>0||t.length>0})]}),(0,me.jsxs)(Be.Tooltip,{children:[(0,me.jsx)(Be.TooltipTrigger,{asChild:!0,children:(0,me.jsx)(Be.Button,{size:"small",variant:"ghost",color:"grey",className:H(l&&"bg-grey-400"),iconButton:!0,onClick:()=>c(!l),children:(0,me.jsx)(eo.MapIcon,{})})}),(0,me.jsx)(Be.TooltipContent,{color:"black",children:r(l?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};var ct=require("@produto-lecom/lecom-ui"),fs=require("lucide-react"),vt=require("react/jsx-runtime"),Up=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=(0,ct.useTranslation)();return(0,vt.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,vt.jsxs)(ct.Tooltip,{children:[(0,vt.jsx)(ct.TooltipTrigger,{asChild:!0,children:(0,vt.jsx)(ct.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:(0,vt.jsx)(fs.UndoIcon,{})})}),(0,vt.jsx)(ct.TooltipContent,{color:"black",children:r("editor.controls.history.undo")})]}),(0,vt.jsxs)(ct.Tooltip,{children:[(0,vt.jsx)(ct.TooltipTrigger,{asChild:!0,children:(0,vt.jsx)(ct.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:(0,vt.jsx)(fs.RedoIcon,{})})}),(0,vt.jsx)(ct.TooltipContent,{color:"black",children:r("editor.controls.history.redo")})]})]})};var Yn=require("@xyflow/react"),ze=require("@produto-lecom/lecom-ui"),Wn=require("lucide-react");var Ve=require("react/jsx-runtime"),$p=()=>{let{t:e}=(0,ze.useTranslation)(),t=(0,Yn.useNodes)(),o=(0,Yn.useEdges)(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:s}=(0,Yn.useReactFlow)(),a=t.length===0&&o.length===0;return(0,Ve.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,Ve.jsxs)(ze.Tooltip,{children:[(0,Ve.jsx)(ze.TooltipTrigger,{asChild:!0,children:(0,Ve.jsx)(ze.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>s(),children:(0,Ve.jsx)(Wn.ScanIcon,{})})}),(0,Ve.jsx)(ze.TooltipContent,{color:"black",children:e("editor.controls.zoom.fit")})]}),(0,Ve.jsxs)(ze.Tooltip,{children:[(0,Ve.jsx)(ze.TooltipTrigger,{asChild:!0,children:(0,Ve.jsx)(ze.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>r(),children:(0,Ve.jsx)(Wn.ZoomOut,{})})}),(0,Ve.jsx)(ze.TooltipContent,{color:"black",children:e("editor.controls.zoom.out")})]}),(0,Ve.jsxs)(ze.Tooltip,{children:[(0,Ve.jsx)(ze.TooltipTrigger,{asChild:!0,children:(0,Ve.jsx)(ze.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>i(1),children:(0,Ve.jsx)(Ca,{})})}),(0,Ve.jsx)(ze.TooltipContent,{color:"black",children:e("editor.controls.zoom.reset")})]}),(0,Ve.jsxs)(ze.Tooltip,{children:[(0,Ve.jsx)(ze.TooltipTrigger,{asChild:!0,children:(0,Ve.jsx)(ze.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>n(),children:(0,Ve.jsx)(Wn.ZoomIn,{})})}),(0,Ve.jsx)(ze.TooltipContent,{color:"black",children:e("editor.controls.zoom.in")})]})]})};var Kp=require("@xyflow/react"),cn=require("react/jsx-runtime"),qp=()=>(0,cn.jsxs)(Kp.ViewportPortal,{children:[(0,cn.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 20 20",className:"text-grey-400 -translate-x-1/2 -translate-y-1/2 pointer-events-none",children:[(0,cn.jsx)("line",{x1:"0",y1:"10",x2:"20",y2:"10",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"}),(0,cn.jsx)("line",{x1:"10",y1:"0",x2:"10",y2:"20",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"})]}),(0,cn.jsx)("div",{className:"absolute top-1 left-1 text-xs font-medium text-grey-400 bg-white/70 px-1 rounded-sm pointer-events-none",children:"0,0"})]});var Zp=require("@xyflow/react"),to=require("@produto-lecom/lecom-ui"),ms=require("react");var Jp=require("lucide-react");var Gt=require("react/jsx-runtime"),Qp=()=>{let e=(0,ms.useRef)(null),{t}=(0,to.useTranslation)(),{setDraggableNode:o}=Hn(),n=(0,Zp.useNodes)(),{setIsDragging:r}=q(),[i,s]=(0,ms.useState)(void 0),a=[{type:"START_EVENT",icon:Fr,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:un,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:"SERVICE_TASK",icon:Jp.Bot,label:t("bpmn.task.variant.service_task")},{type:"TASK",variant:"SCRIPT",icon:Pa,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:Ma,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:mn,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:hn,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:pn,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:Sa,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:zr,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),s((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:a.map((c,d)=>{let u=!Ao(c.type,n),f=u?t("editor.toolbar.start_event_already_exists"):c.label;return(0,Gt.jsxs)(to.Tooltip,{children:[(0,Gt.jsx)(to.TooltipTrigger,{asChild:!0,children:(0,Gt.jsx)(to.Button,{className:H("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":u}),size:"small",variant:"ghost",color:"grey",draggable:!u,disabled:u,iconButton:!0,onDragStart:u?void 0:m=>l(m,c),children:(0,Gt.jsx)(c.icon,{})},d)}),(0,Gt.jsx)(to.TooltipContent,{color:"black",side:"right",children:f})]},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"),pa=e=>e.preventDefault(),fa=(0,dn.forwardRef)((e,t)=>{let{instanceId:o,containerRef:n,mode:r,isMinimapOpen:i,isMoveTool:s,isHandTool:a}=q(),l=(0,oo.useKeyPress)("Space",{target:n==null?void 0:n.current}),c=(0,dn.useRef)(a),d=(0,dn.useRef)(l),{nodes:u,edges:f,actions:m,events:h,components:E,controls:p}=hp(),{t:g}=(0,Vo.useTranslation)();c.current=a,d.current=l;let y=xp(n,c,d);(0,dn.useImperativeHandle)(t,()=>({selectElements:m.selectElements,clearSelection:m.clearSelection}));let x=a||l||r!=="edit",N=x?[0,1,2]:Ir,b=a||l||y,v=s&&!l&&!y,T=r==="edit"&&v,I=!x&&!y,S=r==="view"||v;return(0,qe.jsxs)("div",{ref:n,className:"w-full h-full outline-none",tabIndex:0,children:[r==="edit"&&(0,qe.jsx)(Qp,{}),(0,qe.jsx)(Ep,{}),(0,qe.jsxs)(oo.ReactFlow,w(_({},h),{id:`modeler-${o}`,className:H(r.toLowerCase(),{"is-hand-tool":b,"is-pan-tool-active":b}),edges:f,nodes:u,nodeTypes:lu,edgeTypes:cu,minZoom:ra,maxZoom:gu,panOnDrag:N,panOnScroll:!0,selectionOnDrag:I,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:S,nodesConnectable:T,nodesDraggable:T,connectionLineComponent:iu,selectionMode:oo.SelectionMode.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:T?"Delete":null,selectionKeyCode:null,defaultViewport:_u,connectOnClick:!1,connectionRadius:50,onPaneContextMenu:pa,onNodeContextMenu:pa,onEdgeContextMenu:pa,proOptions:{hideAttribution:!0},children:[(0,qe.jsx)(oo.Background,{gap:fu,size:pu,color:uu,bgColor:du}),(0,qe.jsx)(qp,{}),i&&(0,qe.jsxs)(Vo.Tooltip,{children:[(0,qe.jsx)(Vo.TooltipTrigger,{asChild:!0,children:(0,qe.jsx)("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:(0,qe.jsx)(oo.MiniMap,{pannable:!0,zoomable:!0,position:mu,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),(0,qe.jsx)(Vo.TooltipContent,{color:"black",children:g("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)(Up,_({},p)),r!=="readonly"&&(0,qe.jsx)(Xp,{nodes:u,edges:f,validateDiagram:m.validateDiagram,handleValidationComplete:m.handleValidationComplete}),(0,qe.jsx)($p,{})]}),(0,qe.jsx)(E.HelperLines,{})]}))]})});fa.displayName="Editor";var jp=require("@xyflow/react"),gs=require("react"),ef=require("react/jsx-runtime"),my=e=>({width:e.width,height:e.height,transform:e.transform}),ma="rgba(51, 103, 217, 0.4)",Wc=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=(0,jp.useStore)(my),i=(0,gs.useRef)(null);return(0,gs.useEffect)(()=>{let s=i.current,a=s==null?void 0:s.getContext("2d");if(!a||!s)return;let l=window.devicePixelRatio;s.width=o*l,s.height=n*l,a.clearRect(0,0,o,n),a.scale(l,l),a.strokeStyle=ma,t&&(a.beginPath(),a.strokeStyle=t.color||ma,a.moveTo(t.position*r[2]+r[0],0),a.lineTo(t.position*r[2]+r[0],n),a.stroke()),e&&(a.beginPath(),a.strokeStyle=e.color||ma,a.moveTo(0,e.position*r[2]+r[1]),a.lineTo(o,e.position*r[2]+r[1]),a.stroke())},[o,n,r,e,t]),(0,ef.jsx)("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};var Fn=require("@produto-lecom/lecom-ui"),Ho=require("react");var Dr=require("react/jsx-runtime"),qt=new Map,tf=(0,Ho.createContext)(null),Sn=()=>{let e=(0,Ho.useContext)(tf);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},of=({locale:e,defaultMode:t="view",toast:o,children:n})=>{let[r,i]=(0,Ho.useState)(e||"pt_BR");(0,Ho.useEffect)(()=>{e&&(i(e),Fn.i18n.changeLanguage(e))},[e]);let s=h=>{let E=qt.size;if(E===0)throw new Error("No modeler instances found");if(E===1||!h){let[g]=qt.values();return g}let p=qt.get(h);if(!p)throw new Error(`Modeler instance with ID "${h}" not found`);return p},a=(h,E)=>{let p=s(E);return p==null?void 0:p.selectElements(h)},l=async h=>{let E=s(h);return E==null?void 0:E.clearSelection()},c=(h,E)=>{let p=s(E);return p==null?void 0:p.configureElement(h)},d=(h,E)=>{let p=s(E);return p==null?void 0:p.getConfigureElement(h)},u=async(h,E)=>{let p=s(E);await(p==null?void 0:p.importFromMxGraph(h))},f=h=>{let E=s(h);return E==null?void 0:E.exportToMxGraph()},m=h=>{let E=s(h);return(E==null?void 0:E.getElementsCount())||0};return(0,Dr.jsx)(tf.Provider,{value:{defaultMode:t,locale:r,selectElements:a,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:u,exportDiagram:f,getElementsCount:m,toast:o},children:(0,Dr.jsxs)(Fn.TooltipProvider,{children:[!o&&(0,Dr.jsx)(Fn.Notification,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};var hs=require("react/jsx-runtime"),sf=(0,Le.createContext)(null),q=()=>{let e=(0,Le.useContext)(sf);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},af=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,edgeHighlight:r=!0,validateCustomDiagram:i,onElementChanges:s,onConfigureElement:a,onElementClick:l,onSubprocessValidationClick:c})=>{let d=(0,Le.useRef)(null),{t:u}=(0,nf.useTranslation)(),{defaultMode:f}=Sn(),m=(0,Le.useId)(),[h]=(0,Le.useState)(o||m),[E,p]=(0,Le.useState)(n||f||"edit"),[g,y]=(0,Le.useState)(yr),[x,N]=(0,Le.useState)(!1),[b,v]=(0,Le.useState)(!0),[T,I]=(0,Le.useState)(!1),[S,P]=(0,Le.useState)(!1),[R,C]=(0,Le.useState)(!1),[L,K]=(0,Le.useState)(!1),[Q,j]=(0,Le.useState)(!1),[z,M]=(0,Le.useState)(null);(0,Le.useEffect)(()=>{n&&p(n)},[n]);let V=!!t,D=(0,Le.useMemo)(()=>t||xd(u),[t,u]),A=(0,Le.useMemo)(()=>({instanceId:h,containerRef:d,initialDiagram:D,mode:E,edgeHighlight:r,isEdit:E==="edit",isView:E==="view",isReadOnly:E==="readonly",isNewDiagram:V,lastElementId:g,isInitialized:x,isMinimapOpen:S,isMoveTool:b,isHandTool:T,isDragging:R,isMultipleSelection:Q,isConnecting:L,setLastElementId:y,setIsInitialized:N,reconnectingEdgeId:z,setIsMinimapOpen:P,setIsMoveTool:v,setIsHandTool:I,setIsDragging:C,setIsConnecting:K,setIsMultipleSelection:j,setReconnectingEdgeId:M,validateCustomDiagram:i,onElementChanges:s,onConfigureElement:a,onElementClick:l,onSubprocessValidationClick:c}),[h,d,D,E,r,V,g,x,S,b,T,R,Q,L,z,i,s,a,l,c]);return(0,hs.jsx)(rf.ReactFlowProvider,{children:(0,hs.jsx)(sf.Provider,{value:A,children:(0,hs.jsx)(fa,{ref:e})})})};0&&(module.exports={EditorMode,ElementPosition,ElementType,GatewayElementVariant,GatewayVariant,Modeler,ModelerProvider,NodeAttribute,NodeType,NodeVariant,RoutingVariant,useModeler});