@airporting/integrations-app 0.4.42 → 0.4.43

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.
@@ -10,6 +10,7 @@ export type RecipeTask = {
10
10
  trace_count: number;
11
11
  github_job: string | null;
12
12
  grafana_url: string | null;
13
+ owner: string | null;
13
14
  connector_from?: ConnectorInfo;
14
15
  connector_to?: ConnectorInfo;
15
16
  };
@@ -7,4 +7,4 @@
7
7
  *
8
8
  * This source code is licensed under the MIT license found in the
9
9
  * LICENSE file in the root directory of this source tree.
10
- */var REACT_ELEMENT_TYPE=Symbol.for("react.transitional.element"),REACT_FRAGMENT_TYPE=Symbol.for("react.fragment");function jsxProd(type,config,maybeKey){var key=null;void 0!==maybeKey&&(key=""+maybeKey);void 0!==config.key&&(key=""+config.key);if("key"in config){maybeKey={};for(var propName in config)"key"!==propName&&(maybeKey[propName]=config[propName])}else maybeKey=config;config=maybeKey.ref;return{$$typeof:REACT_ELEMENT_TYPE,type:type,key:key,ref:void 0!==config?config:null,props:maybeKey}}exports.Fragment=REACT_FRAGMENT_TYPE;exports.jsx=jsxProd;exports.jsxs=jsxProd},4848:function(module,__unused_webpack_exports,__webpack_require__){module.exports=__webpack_require__(9698)},7461:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>Synchronisation});var jsx_runtime=__webpack_require__(4848);var index_js_=__webpack_require__(8556);var index_mjs_=__webpack_require__(2773);var InlineLoader=__webpack_require__(800);var modern_index_js_=__webpack_require__(7714);const AppConfigSynchroCtx=/*#__PURE__*/(0,index_js_.createContext)(null);const AppConfigSynchroProvider=AppConfigSynchroCtx.Provider;function useAppConfigSynchro(){const config=(0,index_js_.useContext)(AppConfigSynchroCtx);if(!config)throw new Error("Called `useAppConfigSynchro` outside a `<AppConfigSynchroProvider />`");return config}function useApiSynchro(){const config=useAppConfigSynchro();const baseUrl=config.api.replace(/\/$/,"");const headers={"Content-Type":"application/json",Authorization:config.token?`Bearer ${config.token}`:"",From:config.owner};const handleResponse=async res=>{if(!res.ok)throw new Error(`${res.status} ${res.statusText}`);return res.json()};return{get:path=>fetch(`${baseUrl}${path}`,{headers}).then(handleResponse),post:(path,body)=>fetch(`${baseUrl}${path}`,{method:"POST",headers,body:void 0!==body?JSON.stringify(body):void 0}).then(handleResponse),put:(path,body)=>fetch(`${baseUrl}${path}`,{method:"PUT",headers,body:void 0!==body?JSON.stringify(body):void 0}).then(handleResponse),delete:path=>fetch(`${baseUrl}${path}`,{method:"DELETE",headers}).then(handleResponse)}}function useSynchroListQuery(){const api=useApiSynchro();const config=useAppConfigSynchro();return(0,modern_index_js_.useQuery)({queryKey:["synchro","list",config.company],queryFn:()=>api.get(`/synchro?cid=${config.company}`),staleTime:6e4,refetchOnWindowFocus:true,refetchOnReconnect:true})}function useSynchroDetailQuery(id){const api=useApiSynchro();return(0,modern_index_js_.useQuery)({queryKey:["synchro","detail",id],queryFn:()=>api.get(`/synchro/${id}`),enabled:null!==id,staleTime:3e4,refetchOnWindowFocus:true,refetchOnReconnect:true,refetchInterval:query=>{const tasks=query.state.data?.tasks??[];const hasRunning=tasks.some(t=>null!==t.startedAt&&!t.finished);return hasRunning?5e3:false}})}var esm_index_mjs_=__webpack_require__(4931);function useSynchroRunMutation(){const api=useApiSynchro();const config=useAppConfigSynchro();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:id=>api.post(`/synchro/${id}/run`),onSuccess:(_,id)=>{queryClient.invalidateQueries({queryKey:["synchro","detail",id]});queryClient.invalidateQueries({queryKey:["synchro","list",config.company]});esm_index_mjs_.notifications.show({title:"Recette lanc\xe9e",message:"La synchronisation a d\xe9marr\xe9."})},onError:()=>{esm_index_mjs_.notifications.show({color:"red",title:"Erreur",message:"Impossible de lancer la recette."})}})}function useSynchroToggleMutation(){const api=useApiSynchro();const config=useAppConfigSynchro();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:({id,active})=>api.put(`/synchro/${id}`,{active}),onSuccess:(_,{id})=>{queryClient.invalidateQueries({queryKey:["synchro","detail",id]});queryClient.invalidateQueries({queryKey:["synchro","list",config.company]})},onError:()=>{esm_index_mjs_.notifications.show({color:"red",title:"Erreur",message:"Impossible de modifier la recette."})}})}var tabler_icons_react_mjs_=__webpack_require__(5200);function statusColor(customer){if(!customer.active)return"gray";const task=customer.lastTask;if(!task)return"gray";if(!task.finished)return"yellow";return task.error?"red":"green"}function connectorLogoUrl(c){return c.logo_key?`https://img.logo.dev/${c.logo_key}?token=pk_QvyqAb6uTRGJE2_sDsEb9g&retina=true`:`https://s3.eu-west-3.amazonaws.com/media.airporting/connectors/${c.codename}.png`}function ConnectorLogo({connector}){if(!connector)return null;return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:connector.name,withArrow:true,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Avatar,{src:connectorLogoUrl(connector),size:44,radius:"md",p:0,style:{flexShrink:0}})})}function isOverviewRecipe(r){return"Total"===r.recipe.name||"[Total]"===r.recipe.name}function buildSections(recipes){let overview=null;const byType=new Map;for(const r of recipes){if(isOverviewRecipe(r)){overview=r;continue}const t=r.recipe.connector_from?.type;const key=t?.codename??"other";if(!byType.has(key))byType.set(key,{type:t??{codename:"other",name:"Autres"},recipes:[]});byType.get(key).recipes.push(r)}const sections=Array.from(byType.values()).sort((a,b)=>a.type.name.localeCompare(b.type.name));return{overview,sections}}function RecipeRow({customer,selectedId,onSelect}){const color=statusColor(customer);const isSelected=customer.id===selectedId;const from=customer.recipe.connector_from;const to=customer.recipe.connector_to;const isOverview=isOverviewRecipe(customer);return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.UnstyledButton,{onClick:()=>onSelect(customer.id),style:{borderLeft:`3px solid var(--mantine-color-${color}-6)`,background:isSelected?"var(--mantine-color-dark-6)":"transparent",borderRadius:4,padding:"6px 10px"},children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{gap:8,wrap:"nowrap",justify:"center",children:isOverview?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:"Vue d'ensemble",withArrow:true,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:6,wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconHome,{size:20}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:"Vue d'ensemble"})]})}):from||to?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:12,wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(ConnectorLogo,{connector:from}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"lg",c:"dimmed",children:"→"}),/*#__PURE__*/(0,jsx_runtime.jsx)(ConnectorLogo,{connector:to})]}):/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",truncate:true,children:customer.recipe.name})})})}function SynchroList({recipes,selectedId,onSelect}){const{overview,sections}=buildSections(recipes);return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ScrollArea,{h:"100%",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:8,p:8,children:[overview&&/*#__PURE__*/(0,jsx_runtime.jsx)(RecipeRow,{customer:overview,selectedId:selectedId,onSelect:onSelect}),sections.map(section=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:4,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:6,c:"dimmed",pl:10,pt:6,children:section.type.name}),section.recipes.map(r=>/*#__PURE__*/(0,jsx_runtime.jsx)(RecipeRow,{customer:r,selectedId:selectedId,onSelect:onSelect},r.id))]},section.type.codename))]})})}var modals_esm_index_mjs_=__webpack_require__(4403);function useSynchroJobRunMutation(){const api=useApiSynchro();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:({id,jobId})=>api.post(`/synchro/${id}/jobs/${jobId}/run`),onSuccess:(_,{id})=>{queryClient.invalidateQueries({queryKey:["synchro","detail",id]});esm_index_mjs_.notifications.show({title:"T\xe2che lanc\xe9e",message:"La t\xe2che a d\xe9marr\xe9."})},onError:()=>{esm_index_mjs_.notifications.show({color:"red",title:"Erreur",message:"Impossible de lancer la t\xe2che."})}})}function useSynchroJobToggleMutation(){const api=useApiSynchro();const config=useAppConfigSynchro();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:({id,jobId,active})=>api.put(`/synchro/${id}/jobs/${jobId}/active`,{active}),onSuccess:(_,{id})=>{queryClient.invalidateQueries({queryKey:["synchro","detail",id]});queryClient.invalidateQueries({queryKey:["synchro","list",config.company]})},onError:()=>{esm_index_mjs_.notifications.show({color:"red",title:"Erreur",message:"Impossible de modifier la t\xe2che."})}})}function useSynchroJobDeleteMutation(){const api=useApiSynchro();const config=useAppConfigSynchro();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:({id,jobId})=>api.delete(`/synchro/${id}/jobs/${jobId}`),onSuccess:(_,{id})=>{queryClient.invalidateQueries({queryKey:["synchro","detail",id]});queryClient.invalidateQueries({queryKey:["synchro","list",config.company]})},onError:()=>{esm_index_mjs_.notifications.show({color:"red",title:"Erreur",message:"Impossible de supprimer la t\xe2che."})}})}const VISIBLE_JOBS_LIMIT=16;function jobStatusColor(job){const task=job.lastTask;if(!task)return"gray";if(!task.finished)return"yellow";return task.error?"red":"green"}function synchro_functions_connectorLogoUrl(c){return c.logo_key?`https://img.logo.dev/${c.logo_key}?token=pk_QvyqAb6uTRGJE2_sDsEb9g&retina=true`:`https://s3.eu-west-3.amazonaws.com/media.airporting/connectors/${c.codename}.png`}function JobLogos({job}){if(!job.connector_from&&!job.connector_to)return null;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:3,wrap:"nowrap",style:{flexShrink:0},children:[job.connector_from&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:job.connector_from.name,withArrow:true,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Avatar,{src:synchro_functions_connectorLogoUrl(job.connector_from),size:20,radius:"md",p:0})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:"→"}),job.connector_to&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:job.connector_to.name,withArrow:true,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Avatar,{src:synchro_functions_connectorLogoUrl(job.connector_to),size:20,radius:"md",p:0})})]})}function SynchroFunctions({detail,onConfigJob}){const runJob=useSynchroJobRunMutation();const toggleJob=useSynchroJobToggleMutation();const deleteJob=useSynchroJobDeleteMutation();const[expanded,setExpanded]=(0,index_js_.useState)(false);const renderJobCol=job=>{const color=jobStatusColor(job);return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid.Col,{span:{base:12,sm:6},children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Card,{p:"md",withBorder:true,style:{cursor:"pointer"},onClick:()=>onConfigJob(job),children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:8,wrap:"nowrap",style:{flex:1,minWidth:0},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Box,{w:8,h:8,style:{borderRadius:"50%",background:`var(--mantine-color-${color}-6)`,flexShrink:0}}),/*#__PURE__*/(0,jsx_runtime.jsx)(JobLogos,{job:job}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{truncate:true,style:{fontSize:"1rem"},children:job.task_fr})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:4,wrap:"nowrap",onClick:e=>e.stopPropagation(),children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{size:"sm",variant:"subtle",color:"green",loading:runJob.isPending,title:"Lancer",onClick:()=>runJob.mutate({id:detail.id,jobId:job.id}),children:"▶"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{size:"sm",variant:"subtle",color:"gray",title:"Configurer",onClick:()=>onConfigJob(job),children:"⚙"}),(job.allow_disable||job.allow_delete)&&/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Menu,{shadow:"md",width:180,position:"bottom-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Target,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{size:"sm",variant:"subtle",color:"gray",title:"Plus d'options",children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconDotsVertical,{size:16})})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Menu.Dropdown,{children:[job.allow_disable&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{leftSection:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconCpuOff,{size:14}),onClick:()=>{if(job.active)setTimeout(()=>{modals_esm_index_mjs_.modals.openConfirmModal({title:"D\xe9sactiver cette t\xe2che ?",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:"La t\xe2che ne sera plus ex\xe9cut\xe9e tant qu'elle reste d\xe9sactiv\xe9e."}),labels:{confirm:"D\xe9sactiver",cancel:"Annuler"},onConfirm:()=>toggleJob.mutate({id:detail.id,jobId:job.id,active:false})})},0);else toggleJob.mutate({id:detail.id,jobId:job.id,active:true})},children:job.active?"D\xe9sactiver":"Activer"}),job.allow_delete&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{color:"red",leftSection:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconTrash,{size:14}),onClick:()=>{setTimeout(()=>{modals_esm_index_mjs_.modals.openConfirmModal({title:"Supprimer cette t\xe2che ?",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:"Cette action est irr\xe9versible. La configuration de la t\xe2che sera perdue."}),labels:{confirm:"Supprimer",cancel:"Annuler"},confirmProps:{color:"red"},onConfirm:()=>deleteJob.mutate({id:detail.id,jobId:job.id})})},0)},children:"Supprimer"})]})]})]})]})})},job.id)};const visibleJobs=detail.jobs.slice(0,VISIBLE_JOBS_LIMIT);const hiddenJobs=detail.jobs.slice(VISIBLE_JOBS_LIMIT);const hasMore=hiddenJobs.length>0;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid,{gutter:"md",children:visibleJobs.map(renderJobCol)}),hasMore&&/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Collapse,{in:expanded,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid,{gutter:"md",children:hiddenJobs.map(renderJobCol)})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{justify:"center",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"subtle",size:"sm",color:"gray",rightSection:expanded?/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconChevronUp,{size:14}):/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconChevronDown,{size:14}),onClick:()=>setExpanded(v=>!v),children:expanded?"R\xe9duire":`Voir ${hiddenJobs.length} jobs suppl\xe9mentaires`})})]})]})}function formatDuration(ms){if(null===ms)return"—";if(ms<1e3)return`${ms}ms`;const secs=ms/1e3;if(secs<60)return`${secs.toFixed(1)}s`;const mins=Math.floor(secs/60);const remainSecs=Math.round(secs%60);return`${mins}mn ${remainSecs}s`}function formatDate(iso){if(!iso)return"—";return new Date(iso).toLocaleString("fr-FR",{day:"2-digit",month:"2-digit",hour:"2-digit",minute:"2-digit"})}function synchro_history_connectorLogoUrl(c){return c.logo_key?`https://img.logo.dev/${c.logo_key}?token=pk_QvyqAb6uTRGJE2_sDsEb9g&retina=true`:`https://s3.eu-west-3.amazonaws.com/media.airporting/connectors/${c.codename}.png`}function TaskLogos({task}){if(!task.connector_from&&!task.connector_to)return null;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:3,wrap:"nowrap",children:[task.connector_from&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:task.connector_from.name,withArrow:true,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Avatar,{src:synchro_history_connectorLogoUrl(task.connector_from),size:20,radius:"md",p:0})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:"→"}),task.connector_to&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:task.connector_to.name,withArrow:true,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Avatar,{src:synchro_history_connectorLogoUrl(task.connector_to),size:20,radius:"md",p:0})})]})}function SynchroHistory({tasks}){const showRecipeCol=tasks.some(t=>t.connector_from||t.connector_to);if(0===tasks.length)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",size:"sm",children:"Aucun historique disponible."});return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{striped:true,highlightOnHover:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Thead,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[showRecipeCol&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Recette"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"T\xe2che"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"D\xe9marr\xe9e"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Statut"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Dur\xe9e"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"#ops"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Logs"})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:tasks.map(task=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[showRecipeCol&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(TaskLogos,{task:task})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:task.job_name_fr}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:formatDate(task.startedAt)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:task.finished?task.error?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:"red",children:"Erreur"}):/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:"green",children:"OK"}):/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:"yellow",children:"En cours"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:formatDuration(task.runDuration)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:task.trace_count}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:task.grafana_url?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Anchor,{href:task.grafana_url,target:"_blank",size:"sm",children:"Logs"}):"—"})]},task.id))})]})}function useSynchroJobConfigQuery(recipeId,jobId){const api=useApiSynchro();return(0,modern_index_js_.useQuery)({queryKey:["synchro","job-config",recipeId,jobId],queryFn:()=>api.get(`/synchro/${recipeId}/jobs/${jobId}/config`),enabled:null!==recipeId&&null!==jobId})}function useSynchroJobSaveMutation(){const api=useApiSynchro();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:({id,jobId,data})=>api.put(`/synchro/${id}/jobs/${jobId}`,data),onSuccess:(_,{id})=>{queryClient.invalidateQueries({queryKey:["synchro","detail",id]});esm_index_mjs_.notifications.show({title:"Configuration sauvegard\xe9e",message:"Les param\xe8tres sont enregistr\xe9s."})},onError:()=>{esm_index_mjs_.notifications.show({color:"red",title:"Erreur",message:"Impossible de sauvegarder la configuration."})}})}var form_esm_index_mjs_=__webpack_require__(4491);var dates_esm_index_mjs_=__webpack_require__(5899);const START_PRESETS=[{value:"today",label:"Jour courant"},{value:"month_start",label:"D\xe9but du mois"},{value:"prev_month_start",label:"D\xe9but du mois pr\xe9c\xe9dent"},{value:"year_start",label:"D\xe9but de l'ann\xe9e"}];const END_PRESETS=[{value:"today",label:"Jour courant"},{value:"month_end",label:"Fin du mois"},{value:"prev_month_end",label:"Fin du mois pr\xe9c\xe9dent"},{value:"year_end",label:"Fin de l'ann\xe9e"}];const MODE_VALUES={TODAY:"today",MONTH_START:"month_start",PREV_MONTH_START:"prev_month_start",YEAR_START:"year_start",MONTH_END:"month_end",PREV_MONTH_END:"prev_month_end",YEAR_END:"year_end"};const MODE_KEYS={today:"TODAY",month_start:"MONTH_START",prev_month_start:"PREV_MONTH_START",year_start:"YEAR_START",month_end:"MONTH_END",prev_month_end:"PREV_MONTH_END",year_end:"YEAR_END",exact:"",relative:""};function parseValue(val){const defaults={exactDate:null,direction:"MINUS",amount:1,unit:"DAYS"};if(!val)return{mode:"today",...defaults};if(MODE_VALUES[val])return{mode:MODE_VALUES[val],...defaults};const relMatch=val.match(/^(MINUS|PLUS):(\d+):(\w+)$/);if(relMatch)return{mode:"relative",exactDate:null,direction:relMatch[1],amount:Number(relMatch[2]),unit:relMatch[3]};const d=new Date(val);if(!isNaN(d.getTime()))return{mode:"exact",exactDate:d,...defaults};return{mode:"today",...defaults}}function serializeValue(mode,exactDate,direction,amount,unit){if("exact"===mode)return exactDate?exactDate.toISOString():"";if("relative"===mode)return`${direction}:${amount}:${unit}`;return MODE_KEYS[mode]||"TODAY"}function InputDateBoundary({label,help,required,disabled,value,onChange,variant}){const parsed=parseValue(value);const[mode,setMode]=(0,index_js_.useState)(parsed.mode);const[exactDate,setExactDate]=(0,index_js_.useState)(parsed.exactDate);const[direction,setDirection]=(0,index_js_.useState)(parsed.direction);const[amount,setAmount]=(0,index_js_.useState)(parsed.amount);const[unit,setUnit]=(0,index_js_.useState)(parsed.unit);(0,index_js_.useEffect)(()=>{onChange(serializeValue(mode,exactDate,direction,amount,unit))},[mode,exactDate,direction,amount,unit]);const presets="start"===variant?START_PRESETS:END_PRESETS;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"xs",children:[label&&/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",fw:500,children:[label," ",required&&/*#__PURE__*/(0,jsx_runtime.jsx)("span",{style:{color:"var(--mantine-color-red-6)"},children:"*"})]}),help&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:help}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Radio.Group,{value:mode,onChange:v=>setMode(v),children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"sm",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"md",wrap:"nowrap",grow:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Radio,{value:"exact",label:"Date exacte",disabled:disabled}),/*#__PURE__*/(0,jsx_runtime.jsx)(dates_esm_index_mjs_.DateInput,{leftSection:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconCalendar,{size:16}),value:exactDate,onChange:d=>{setExactDate(d);setMode("exact")},disabled:disabled||"exact"!==mode,valueFormat:"DD-MM-YYYY",placeholder:"JJ-MM-AAAA"})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"md",wrap:"nowrap",grow:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Radio,{value:"relative",label:"Date relative",disabled:disabled}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{data:[{value:"MINUS",label:"pass\xe9e"},{value:"PLUS",label:"future"}],value:direction,onChange:v=>{setDirection(v??"MINUS");setMode("relative")},disabled:disabled||"relative"!==mode,w:100}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.NumberInput,{value:amount,onChange:v=>{setAmount(Number(v));setMode("relative")},min:0,disabled:disabled||"relative"!==mode,w:70}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{data:[{value:"DAYS",label:"Jour(s)"},{value:"MONTHS",label:"Mois"},{value:"YEARS",label:"Ann\xe9e(s)"}],value:unit,onChange:v=>{setUnit(v??"DAYS");setMode("relative")},disabled:disabled||"relative"!==mode,w:110})]}),presets.map(p=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Radio,{value:p.value,label:p.label,disabled:disabled},p.value))]})})]})}function useSpreadsheetsQuery(){const api=useApiSynchro();const config=useAppConfigSynchro();return(0,modern_index_js_.useQuery)({queryKey:["synchro","spreadsheets",config.company],queryFn:()=>api.get(`/synchro/spreadsheets?cid=${config.company}`)})}function InputGsheetsSelector({label,help,required,disabled,value,onChange,error}){const{data:spreadsheets,isPending}=useSpreadsheetsQuery();const options=(spreadsheets??[]).map(s=>({value:s.id,label:s.name}));return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:label??"Tableur",description:help??void 0,required:required,disabled:disabled||isPending,placeholder:isPending?"Chargement...":"S\xe9lectionner un tableur",data:options,value:value,onChange:onChange,error:error,searchable:true,clearable:true})}const ACCOUNT_ID_NAME_SHAPE={valueField:"account_id",labelField:"account_name",secondaryFields:["account_id"]};const ACCOUNT_SELECTOR_REGISTRY={airporting_account_selector:ACCOUNT_ID_NAME_SHAPE,alma_account_selector:ACCOUNT_ID_NAME_SHAPE,bridge_account_selector:ACCOUNT_ID_NAME_SHAPE,chargebee_account_selector:ACCOUNT_ID_NAME_SHAPE,hubspot_deal_property_selector:ACCOUNT_ID_NAME_SHAPE,hubspot_line_item_property_selector:ACCOUNT_ID_NAME_SHAPE,ibanfirst_account_selector:ACCOUNT_ID_NAME_SHAPE,paypal_account_selector:ACCOUNT_ID_NAME_SHAPE,pennylane_account_selector:ACCOUNT_ID_NAME_SHAPE,profitwell_account_selector:ACCOUNT_ID_NAME_SHAPE,qonto_account_selector:ACCOUNT_ID_NAME_SHAPE,revolut_account_selector:ACCOUNT_ID_NAME_SHAPE,shopify_account_selector:ACCOUNT_ID_NAME_SHAPE,sobank_account_selector:{valueField:"Account_Name",secondaryFields:["Iban"]},stripe_account_selector:ACCOUNT_ID_NAME_SHAPE,sycomore_account_selector:ACCOUNT_ID_NAME_SHAPE,wise_account_selector:ACCOUNT_ID_NAME_SHAPE};function buildAccountOptions(source,cfg){return source.map(row=>{const value=String(row?.[cfg.valueField]??"");const label=String(row?.[cfg.labelField??cfg.valueField]??value);const secondary=(cfg.secondaryFields??[]).map(f=>row?.[f]).filter(v=>null!=v&&""!==v).join(" \xb7 ");return{value,label,secondary}})}function FormField({config,value,onChange,error}){const label=config.label??config.name??"";const description=config.help??void 0;const required=config.required??false;const disabled=config.disabled??false;const selectOptions=(()=>{if(!config.full||"object"!=typeof config.full)return[];const f=config.full;if(Array.isArray(f.options))return f.options.map(o=>"string"==typeof o?{value:o,label:o}:{value:String(o.value??o.id??o),label:o.label??o.name??String(o)});return[]})();switch(config.type){case"text":if(config.multiple)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TagsInput,{label:label,description:description,required:required,disabled:disabled,value:Array.isArray(value)?value:value?[value]:[],onChange:onChange,error:error});return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:label,description:description,required:required,disabled:disabled,value:value??"",onChange:e=>onChange(e.currentTarget.value),error:error});case"email":return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{type:"email",label:label,description:description,required:required,disabled:disabled,value:value??"",onChange:e=>onChange(e.currentTarget.value),error:error});case"password":return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.PasswordInput,{label:label,description:description,required:required,disabled:disabled,value:value??"",onChange:e=>onChange(e.currentTarget.value),error:error});case"hidden":return null;case"msg":return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:"dimmed",children:label});case"switch":return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Switch,{label:label,description:description,disabled:disabled,checked:!!value,onChange:e=>onChange(e.currentTarget.checked)});case"select":return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:label,description:description,required:required,disabled:disabled,data:selectOptions,value:value??null,onChange:onChange,error:error,searchable:true});case"date_boundary_start":return/*#__PURE__*/(0,jsx_runtime.jsx)(InputDateBoundary,{label:label,help:description,required:required,disabled:disabled,value:value,onChange:onChange,variant:"start"});case"date_boundary_end":return/*#__PURE__*/(0,jsx_runtime.jsx)(InputDateBoundary,{label:label,help:description,required:required,disabled:disabled,value:value,onChange:onChange,variant:"end"});case"tags_multiple":return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TagsInput,{label:label,description:description,required:required,disabled:disabled,value:Array.isArray(value)?value:value?String(value).split(",").filter(Boolean):[],onChange:onChange,error:error});case"gsheets_account_selector":return/*#__PURE__*/(0,jsx_runtime.jsx)(InputGsheetsSelector,{label:label,help:description,required:required,disabled:disabled,value:value,onChange:onChange,error:error});case"totp":return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:label,description:description,required:required,disabled:disabled,value:value??"",onChange:e=>onChange(e.currentTarget.value),error:error,placeholder:"123456",autoComplete:"one-time-code",inputMode:"numeric"});case"select_multiple":{const sourceValues=config.full?.values;const data=Array.isArray(sourceValues)?sourceValues.map(o=>"string"==typeof o?{value:o,label:o}:{value:String(o.value??o.id??o),label:o.label??o.name??String(o)}):[];const fallbackDefault=config.full?.default;const currentValue=(()=>{if(Array.isArray(value))return value;if("string"==typeof value&&value.includes(","))return value.split(",").filter(Boolean);if(Array.isArray(fallbackDefault))return fallbackDefault;return[]})();return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.MultiSelect,{label:label,description:description,required:required,disabled:disabled,data:data,value:currentValue,onChange:onChange,error:error,searchable:true})}case"number":return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.NumberInput,{label:label,description:description,required:required,disabled:disabled,value:value??"",onChange:onChange,error:error});case"checkbox":return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Checkbox,{label:label,description:description,disabled:disabled,checked:!!value,onChange:e=>onChange(e.currentTarget.checked)});case"multi_select":return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.MultiSelect,{label:label,description:description,required:required,disabled:disabled,data:selectOptions,value:Array.isArray(value)?value:[],onChange:onChange,error:error,searchable:true});case"recipe_cf_pipedrive":return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TagsInput,{label:label,description:description,required:required,disabled:disabled,value:Array.isArray(value)?value:value?String(value).split(",").filter(Boolean):[],onChange:onChange,error:error});default:{const accountCfg=config.type?ACCOUNT_SELECTOR_REGISTRY[config.type]:void 0;if(accountCfg){const sourceValues=config.full?.values;if(Array.isArray(sourceValues)&&sourceValues.length>0){const options=buildAccountOptions(sourceValues,accountCfg);const renderOption=({option})=>{const match=options.find(d=>d.value===option.value);return/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:match?.label??option.value}),match?.secondary&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",opacity:.5,children:match.secondary})]})};if(config.multiple)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.MultiSelect,{label:label,description:description,required:required,disabled:disabled,data:options,value:Array.isArray(value)?value:[],onChange:onChange,renderOption:renderOption,error:error,searchable:true});return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:label,description:description,required:required,disabled:disabled,data:options,value:"string"==typeof value?value:null,onChange:v=>onChange(v??""),renderOption:renderOption,error:error,searchable:true})}return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:4,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Alert,{variant:"light",color:"gray",children:"Source non charg\xe9e — saisie manuelle de l'identifiant."}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:label,description:description,required:required,disabled:disabled,value:value??"",onChange:e=>onChange(e.currentTarget.value),error:error})]})}return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Alert,{variant:"light",color:"yellow",title:`Type "${config.type}" non support\xe9`,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"xs",children:["Champ : ",config.name]})})}}}function SynchroDynamicForm({config,save}){const form=(0,form_esm_index_mjs_.useForm)({initialValues:config.data?.initialData??{}});(0,index_js_.useEffect)(()=>{if(config.data?.initialData){form.setValues(config.data.initialData);form.resetDirty()}},[config.data]);if(config.isPending||!config.data)return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:30,mt:6,radius:"xl"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:12,mt:6,w:"30%",radius:"xl"})]});const{sections}=config.data;if(!sections?.length)return null;return/*#__PURE__*/(0,jsx_runtime.jsx)("form",{autoComplete:"off",onSubmit:form.onSubmit(values=>save.mutate(values)),children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"md",children:[sections.map((section,si)=>section.fields.map((fieldConfig,fi)=>/*#__PURE__*/(0,jsx_runtime.jsx)(FormField,{config:fieldConfig,value:form.values[fieldConfig.name],onChange:value=>form.setFieldValue(fieldConfig.name,value),error:form.errors[fieldConfig.name]},`${si}-${fi}`))),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{justify:"flex-end",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{type:"submit",loading:save.isPending,children:"Enregistrer"})})]})})}function JobConfigModal({job,recipeId,opened,onClose}){const save=useSynchroJobSaveMutation();const configQuery=useSynchroJobConfigQuery(opened?recipeId:null,opened?job?.id??null:null);const saveMutation=(0,index_js_.useMemo)(()=>({...save,mutate:values=>{if(!job)return;save.mutate({id:recipeId,jobId:job.id,data:values})}}),[save,job,recipeId]);if(!job)return null;const hasForm=configQuery.data?.sections?.length>0;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Modal,{opened:opened,onClose:onClose,title:job.task_fr,size:"lg",children:[configQuery.isPending||hasForm?/*#__PURE__*/(0,jsx_runtime.jsx)(SynchroDynamicForm,{config:configQuery,save:saveMutation}):/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",size:"sm",children:"Aucune configuration disponible pour cette t\xe2che."}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{justify:"flex-end",mt:"md",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"subtle",color:"gray",onClick:onClose,children:"Fermer"})})]})}var hooks_esm_index_mjs_=__webpack_require__(2667);function useCreateScheduleMutation(){const api=useApiSynchro();const qc=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:({recipeCustomerId,data})=>api.post(`/synchro/${recipeCustomerId}/schedules`,data),onSuccess:()=>qc.invalidateQueries({queryKey:["synchro"]})})}function useUpdateScheduleMutation(){const api=useApiSynchro();const qc=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:({recipeCustomerId,scheduleId,data})=>api.put(`/synchro/${recipeCustomerId}/schedules/${scheduleId}`,data),onSuccess:()=>qc.invalidateQueries({queryKey:["synchro"]})})}function useDeleteScheduleMutation(){const api=useApiSynchro();const qc=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:({recipeCustomerId,scheduleId})=>api.delete(`/synchro/${recipeCustomerId}/schedules/${scheduleId}`),onSuccess:()=>qc.invalidateQueries({queryKey:["synchro"]})})}const DAY_LABELS={monday:"Lun",tuesday:"Mar",wednesday:"Mer",thursday:"Jeu",friday:"Ven",saturday:"Sam",sunday:"Dim"};const ALL_DAYS=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"];function SynchroSchedules({schedules,jobs,recipeCustomerId}){const[opened,{open,close}]=(0,hooks_esm_index_mjs_.useDisclosure)(false);const[editing,setEditing]=(0,index_js_.useState)(null);const handleEdit=s=>{setEditing(s);open()};const handleNew=()=>{setEditing(null);open()};return/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"sm",children:[0===schedules.length&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",size:"sm",children:"Aucun d\xe9clencheur configur\xe9."}),schedules.map(s=>/*#__PURE__*/(0,jsx_runtime.jsx)(ScheduleCard,{schedule:s,jobs:jobs,recipeCustomerId:recipeCustomerId,onEdit:()=>handleEdit(s)},s.id)),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"light",size:"xs",leftSection:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconPlus,{size:14}),onClick:handleNew,w:"fit-content",children:"Ajouter un d\xe9clencheur"})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(ScheduleModal,{opened:opened,onClose:close,schedule:editing,jobs:jobs,recipeCustomerId:recipeCustomerId})]})}function ScheduleCard({schedule,jobs,recipeCustomerId,onEdit}){const deleteMut=useDeleteScheduleMutation();const hour=String(schedule.hour??0).padStart(2,"0");const minute=String(schedule.minute??0).padStart(2,"0");const taskLabels=schedule.tasks.map(t=>{const job=jobs.find(j=>String(j.id)===t);return job?.active?job.task_fr:null}).filter(Boolean);return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Card,{withBorder:true,p:"sm",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:6,style:{flex:1},children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconClock,{size:16}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",fw:500,children:[hour,":",minute]}),schedule.frequency&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{variant:"light",size:"sm",children:schedule.frequency}),schedule.draft&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{variant:"light",size:"sm",color:"yellow",children:"Brouillon"})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconCalendar,{size:16}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{gap:4,children:ALL_DAYS.map(day=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",variant:schedule.days.includes(day)?"filled":"light",color:schedule.days.includes(day)?"teal":"gray",children:DAY_LABELS[day]},day))})]}),taskLabels.length>0&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{gap:4,wrap:"wrap",children:taskLabels.map((label,i)=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",variant:"outline",children:label},i))})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:4,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{size:"sm",variant:"subtle",onClick:onEdit,title:"Modifier",children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconPencil,{size:14})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{size:"sm",variant:"subtle",color:"red",loading:deleteMut.isPending,onClick:()=>deleteMut.mutate({recipeCustomerId,scheduleId:schedule.id}),title:"Supprimer",children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconTrash,{size:14})})]})]})})}function ScheduleModal({opened,onClose,schedule,jobs,recipeCustomerId}){const createMut=useCreateScheduleMutation();const updateMut=useUpdateScheduleMutation();const[days,setDays]=(0,index_js_.useState)(ALL_DAYS);const[hour,setHour]=(0,index_js_.useState)(1);const[minute,setMinute]=(0,index_js_.useState)(0);const[selectedTasks,setSelectedTasks]=(0,index_js_.useState)([]);(0,index_js_.useEffect)(()=>{if(schedule){setDays(schedule.days);setHour(schedule.hour??1);setMinute(schedule.minute??0);setSelectedTasks(schedule.tasks)}else{setDays(ALL_DAYS);setHour(1);setMinute(0);setSelectedTasks([])}},[schedule,opened]);const toggleDay=day=>{setDays(prev=>prev.includes(day)?prev.filter(d=>d!==day):[...prev,day])};const toggleTask=task=>{setSelectedTasks(prev=>prev.includes(task)?prev.filter(t=>t!==task):[...prev,task])};const handleSave=()=>{const data={days,hour,minute,tasks:selectedTasks};if(schedule)updateMut.mutate({recipeCustomerId,scheduleId:schedule.id,data},{onSuccess:onClose});else createMut.mutate({recipeCustomerId,data},{onSuccess:onClose})};const isPending=createMut.isPending||updateMut.isPending;return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:opened,onClose:onClose,title:schedule?"Modifier le d\xe9clencheur":"Nouveau d\xe9clencheur",size:"md",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"sm",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.NumberInput,{label:"Heure",value:hour,onChange:v=>setHour(Number(v)),min:0,max:23,w:80}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.NumberInput,{label:"Minute",value:minute,onChange:v=>setMinute(Number(v)),min:0,max:59,w:80})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:4,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",fw:500,children:"Jours"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{gap:4,children:ALL_DAYS.map(day=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"lg",variant:days.includes(day)?"filled":"light",color:days.includes(day)?"teal":"gray",style:{cursor:"pointer"},onClick:()=>toggleDay(day),children:DAY_LABELS[day]},day))})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:4,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",fw:500,children:"Jobs \xe0 d\xe9clencher"}),jobs.map(job=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Checkbox,{label:job.task_fr??job.task,checked:selectedTasks.includes(String(job.id)),onChange:()=>toggleTask(String(job.id))},job.id))]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"subtle",color:"gray",onClick:onClose,children:"Annuler"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{onClick:handleSave,loading:isPending,children:schedule?"Enregistrer":"Cr\xe9er"})]})]})})}function SynchroApp(){const[selectedId,setSelectedIdState]=(0,index_js_.useState)(()=>{const param=new URLSearchParams(window.location.search).get("recipeId");const parsed=param?Number(param):NaN;return Number.isInteger(parsed)&&parsed>0?parsed:null});const[configJob,setConfigJob]=(0,index_js_.useState)(null);const listRes=useSynchroListQuery();const detailRes=useSynchroDetailQuery(selectedId);const runAll=useSynchroRunMutation();const toggle=useSynchroToggleMutation();const recipes=listRes.data??[];const detail=detailRes.data;const setSelectedId=(0,index_js_.useCallback)(id=>{setSelectedIdState(id);const url=new URL(window.location.href);if(null===id)url.searchParams.delete("recipeId");else url.searchParams.set("recipeId",String(id));window.history.replaceState({},"",url)},[]);(0,index_js_.useEffect)(()=>{if(0===recipes.length)return;const exists=null!==selectedId&&recipes.some(r=>r.id===selectedId);if(!exists)setSelectedId(recipes[0].id)},[recipes,selectedId,setSelectedId]);if(listRes.isPending)return/*#__PURE__*/(0,jsx_runtime.jsx)(InlineLoader.F,{label:"Chargement des synchronisations..."});return/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{wrap:"nowrap",h:"100%",align:"flex-start",gap:0,children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Box,{w:220,h:"100%",style:{flexShrink:0,borderRight:"1px solid var(--mantine-color-dark-5)"},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:5,p:"sm",c:"dimmed",children:"Synchronisations"}),0===recipes.length?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:"dimmed",px:"sm",children:"Aucune recette configur\xe9e."}):/*#__PURE__*/(0,jsx_runtime.jsx)(SynchroList,{recipes:recipes,selectedId:selectedId,onSelect:setSelectedId})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Box,{flex:1,p:"md",style:{overflowY:"auto"},children:null===selectedId?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"S\xe9lectionnez une recette."}):detailRes.isPending?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{h:40}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{h:120}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{h:200})]}):detail?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"lg",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:3,children:"Total"===detail.recipe.name||"[Total]"===detail.recipe.name?"Vue d'ensemble":detail.recipe.name}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"sm",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Switch,{checked:detail.active,label:detail.active?"Actif":"Inactif",onChange:()=>toggle.mutate({id:detail.id,active:!detail.active})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"light",color:"green",loading:runAll.isPending,onClick:()=>runAll.mutate(detail.id),children:"▶ Lancer tout"})]})]}),!("Total"===detail.recipe.name||"[Total]"===detail.recipe.name)&&/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:5,c:"dimmed",children:"D\xe9clencheurs"}),/*#__PURE__*/(0,jsx_runtime.jsx)(SynchroSchedules,{schedules:detail.schedules,jobs:detail.jobs,recipeCustomerId:detail.id})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(SynchroFunctions,{detail:detail,onConfigJob:setConfigJob}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Accordion,{defaultValue:null,variant:"default",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Accordion.Item,{value:"history",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Accordion.Control,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:5,c:"dimmed",children:"Historique"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Accordion.Panel,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(SynchroHistory,{tasks:detail.tasks})})]})})]}):/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"Impossible de charger la recette."})})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(JobConfigModal,{job:configJob,recipeId:selectedId??0,opened:null!==configJob,onClose:()=>setConfigJob(null)})]})}var dist_index_js_=__webpack_require__(6584);var dist_esm_index_mjs_=__webpack_require__(4449);const theme=(0,index_mjs_.createTheme)((0,dist_esm_index_mjs_.assign)(dist_index_js_.theme,{components:{}}));const cssVarResolver=x=>(0,dist_esm_index_mjs_.assign)(dist_index_js_.cssVarResolver(x),{dark:{},light:{},variables:{}});function ProvidersSynchro(props){const{children,config,mantine,tanstack}=props;return/*#__PURE__*/(0,jsx_runtime.jsx)(AppConfigSynchroProvider,{value:config,children:/*#__PURE__*/(0,jsx_runtime.jsx)(modern_index_js_.QueryClientProvider,{client:tanstack?.queryClient??new modern_index_js_.QueryClient,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.MantineProvider,{theme:theme,cssVariablesResolver:cssVarResolver,defaultColorScheme:mantine?.defaultColorScheme,forceColorScheme:mantine?.forceColorScheme,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(modals_esm_index_mjs_.ModalsProvider,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(esm_index_mjs_.Notifications,{}),children]})})})})}function Synchronisation(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_js_.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(ProvidersSynchro,{...props,children:/*#__PURE__*/(0,jsx_runtime.jsx)(SynchroApp,{})})})}},800:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{F:()=>InlineLoader});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(4848);var _mantine_core__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(2773);function InlineLoader({label}){return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Center,{flex:1,h:"100%",children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Stack,{align:"center",gap:"md",children:[/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Loader,{size:"md",color:"teal"}),label&&/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Text,{fz:"sm",c:"dimmed",children:label})]})})}}}]);
10
+ */var REACT_ELEMENT_TYPE=Symbol.for("react.transitional.element"),REACT_FRAGMENT_TYPE=Symbol.for("react.fragment");function jsxProd(type,config,maybeKey){var key=null;void 0!==maybeKey&&(key=""+maybeKey);void 0!==config.key&&(key=""+config.key);if("key"in config){maybeKey={};for(var propName in config)"key"!==propName&&(maybeKey[propName]=config[propName])}else maybeKey=config;config=maybeKey.ref;return{$$typeof:REACT_ELEMENT_TYPE,type:type,key:key,ref:void 0!==config?config:null,props:maybeKey}}exports.Fragment=REACT_FRAGMENT_TYPE;exports.jsx=jsxProd;exports.jsxs=jsxProd},4848:function(module,__unused_webpack_exports,__webpack_require__){module.exports=__webpack_require__(9698)},7461:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>Synchronisation});var jsx_runtime=__webpack_require__(4848);var index_js_=__webpack_require__(8556);var index_mjs_=__webpack_require__(2773);var InlineLoader=__webpack_require__(800);var modern_index_js_=__webpack_require__(7714);const AppConfigSynchroCtx=/*#__PURE__*/(0,index_js_.createContext)(null);const AppConfigSynchroProvider=AppConfigSynchroCtx.Provider;function useAppConfigSynchro(){const config=(0,index_js_.useContext)(AppConfigSynchroCtx);if(!config)throw new Error("Called `useAppConfigSynchro` outside a `<AppConfigSynchroProvider />`");return config}function useApiSynchro(){const config=useAppConfigSynchro();const baseUrl=config.api.replace(/\/$/,"");const headers={"Content-Type":"application/json",Authorization:config.token?`Bearer ${config.token}`:"",From:config.owner};const handleResponse=async res=>{if(!res.ok)throw new Error(`${res.status} ${res.statusText}`);return res.json()};return{get:path=>fetch(`${baseUrl}${path}`,{headers}).then(handleResponse),post:(path,body)=>fetch(`${baseUrl}${path}`,{method:"POST",headers,body:void 0!==body?JSON.stringify(body):void 0}).then(handleResponse),put:(path,body)=>fetch(`${baseUrl}${path}`,{method:"PUT",headers,body:void 0!==body?JSON.stringify(body):void 0}).then(handleResponse),delete:path=>fetch(`${baseUrl}${path}`,{method:"DELETE",headers}).then(handleResponse)}}function useSynchroListQuery(){const api=useApiSynchro();const config=useAppConfigSynchro();return(0,modern_index_js_.useQuery)({queryKey:["synchro","list",config.company],queryFn:()=>api.get(`/synchro?cid=${config.company}`),staleTime:6e4,refetchOnWindowFocus:true,refetchOnReconnect:true})}function useSynchroDetailQuery(id){const api=useApiSynchro();return(0,modern_index_js_.useQuery)({queryKey:["synchro","detail",id],queryFn:()=>api.get(`/synchro/${id}`),enabled:null!==id,staleTime:3e4,refetchOnWindowFocus:true,refetchOnReconnect:true,refetchInterval:query=>{const tasks=query.state.data?.tasks??[];const hasRunning=tasks.some(t=>null!==t.startedAt&&!t.finished);return hasRunning?5e3:false}})}var esm_index_mjs_=__webpack_require__(4931);function useSynchroRunMutation(){const api=useApiSynchro();const config=useAppConfigSynchro();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:id=>api.post(`/synchro/${id}/run`),onSuccess:(_,id)=>{queryClient.invalidateQueries({queryKey:["synchro","detail",id]});queryClient.invalidateQueries({queryKey:["synchro","list",config.company]});esm_index_mjs_.notifications.show({title:"Recette lanc\xe9e",message:"La synchronisation a d\xe9marr\xe9."})},onError:()=>{esm_index_mjs_.notifications.show({color:"red",title:"Erreur",message:"Impossible de lancer la recette."})}})}function useSynchroToggleMutation(){const api=useApiSynchro();const config=useAppConfigSynchro();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:({id,active})=>api.put(`/synchro/${id}`,{active}),onSuccess:(_,{id})=>{queryClient.invalidateQueries({queryKey:["synchro","detail",id]});queryClient.invalidateQueries({queryKey:["synchro","list",config.company]})},onError:()=>{esm_index_mjs_.notifications.show({color:"red",title:"Erreur",message:"Impossible de modifier la recette."})}})}var tabler_icons_react_mjs_=__webpack_require__(5200);function statusColor(customer){if(!customer.active)return"gray";const task=customer.lastTask;if(!task)return"gray";if(!task.finished)return"yellow";return task.error?"red":"green"}function connectorLogoUrl(c){return c.logo_key?`https://img.logo.dev/${c.logo_key}?token=pk_QvyqAb6uTRGJE2_sDsEb9g&retina=true`:`https://s3.eu-west-3.amazonaws.com/media.airporting/connectors/${c.codename}.png`}function ConnectorLogo({connector}){if(!connector)return null;return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:connector.name,withArrow:true,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Avatar,{src:connectorLogoUrl(connector),size:44,radius:"md",p:0,style:{flexShrink:0}})})}function isOverviewRecipe(r){return"Total"===r.recipe.name||"[Total]"===r.recipe.name}function buildSections(recipes){let overview=null;const byType=new Map;for(const r of recipes){if(isOverviewRecipe(r)){overview=r;continue}const t=r.recipe.connector_from?.type;const key=t?.codename??"other";if(!byType.has(key))byType.set(key,{type:t??{codename:"other",name:"Autres"},recipes:[]});byType.get(key).recipes.push(r)}const sections=Array.from(byType.values()).sort((a,b)=>a.type.name.localeCompare(b.type.name));return{overview,sections}}function RecipeRow({customer,selectedId,onSelect}){const color=statusColor(customer);const isSelected=customer.id===selectedId;const from=customer.recipe.connector_from;const to=customer.recipe.connector_to;const isOverview=isOverviewRecipe(customer);return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.UnstyledButton,{onClick:()=>onSelect(customer.id),style:{borderLeft:`3px solid var(--mantine-color-${color}-6)`,background:isSelected?"var(--mantine-color-dark-6)":"transparent",borderRadius:4,padding:"6px 10px"},children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{gap:8,wrap:"nowrap",justify:"center",children:isOverview?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:"Vue d'ensemble",withArrow:true,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:6,wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconHome,{size:20}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:"Vue d'ensemble"})]})}):from||to?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:12,wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(ConnectorLogo,{connector:from}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"lg",c:"dimmed",children:"→"}),/*#__PURE__*/(0,jsx_runtime.jsx)(ConnectorLogo,{connector:to})]}):/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",truncate:true,children:customer.recipe.name})})})}function SynchroList({recipes,selectedId,onSelect}){const{overview,sections}=buildSections(recipes);return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ScrollArea,{h:"100%",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:8,p:8,children:[overview&&/*#__PURE__*/(0,jsx_runtime.jsx)(RecipeRow,{customer:overview,selectedId:selectedId,onSelect:onSelect}),sections.map(section=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:4,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:6,c:"dimmed",pl:10,pt:6,children:section.type.name}),section.recipes.map(r=>/*#__PURE__*/(0,jsx_runtime.jsx)(RecipeRow,{customer:r,selectedId:selectedId,onSelect:onSelect},r.id))]},section.type.codename))]})})}var modals_esm_index_mjs_=__webpack_require__(4403);function useSynchroJobRunMutation(){const api=useApiSynchro();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:({id,jobId})=>api.post(`/synchro/${id}/jobs/${jobId}/run`),onSuccess:(_,{id})=>{queryClient.invalidateQueries({queryKey:["synchro","detail",id]});esm_index_mjs_.notifications.show({title:"T\xe2che lanc\xe9e",message:"La t\xe2che a d\xe9marr\xe9."})},onError:()=>{esm_index_mjs_.notifications.show({color:"red",title:"Erreur",message:"Impossible de lancer la t\xe2che."})}})}function useSynchroJobToggleMutation(){const api=useApiSynchro();const config=useAppConfigSynchro();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:({id,jobId,active})=>api.put(`/synchro/${id}/jobs/${jobId}/active`,{active}),onSuccess:(_,{id})=>{queryClient.invalidateQueries({queryKey:["synchro","detail",id]});queryClient.invalidateQueries({queryKey:["synchro","list",config.company]})},onError:()=>{esm_index_mjs_.notifications.show({color:"red",title:"Erreur",message:"Impossible de modifier la t\xe2che."})}})}function useSynchroJobDeleteMutation(){const api=useApiSynchro();const config=useAppConfigSynchro();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:({id,jobId})=>api.delete(`/synchro/${id}/jobs/${jobId}`),onSuccess:(_,{id})=>{queryClient.invalidateQueries({queryKey:["synchro","detail",id]});queryClient.invalidateQueries({queryKey:["synchro","list",config.company]})},onError:()=>{esm_index_mjs_.notifications.show({color:"red",title:"Erreur",message:"Impossible de supprimer la t\xe2che."})}})}const VISIBLE_JOBS_LIMIT=16;function jobStatusColor(job){const task=job.lastTask;if(!task)return"gray";if(!task.finished)return"yellow";return task.error?"red":"green"}function synchro_functions_connectorLogoUrl(c){return c.logo_key?`https://img.logo.dev/${c.logo_key}?token=pk_QvyqAb6uTRGJE2_sDsEb9g&retina=true`:`https://s3.eu-west-3.amazonaws.com/media.airporting/connectors/${c.codename}.png`}function JobLogos({job}){if(!job.connector_from&&!job.connector_to)return null;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:3,wrap:"nowrap",style:{flexShrink:0},children:[job.connector_from&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:job.connector_from.name,withArrow:true,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Avatar,{src:synchro_functions_connectorLogoUrl(job.connector_from),size:20,radius:"md",p:0})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:"→"}),job.connector_to&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:job.connector_to.name,withArrow:true,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Avatar,{src:synchro_functions_connectorLogoUrl(job.connector_to),size:20,radius:"md",p:0})})]})}function SynchroFunctions({detail,onConfigJob}){const runJob=useSynchroJobRunMutation();const toggleJob=useSynchroJobToggleMutation();const deleteJob=useSynchroJobDeleteMutation();const[expanded,setExpanded]=(0,index_js_.useState)(false);const renderJobCol=job=>{const color=jobStatusColor(job);return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid.Col,{span:{base:12,sm:6},children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Card,{p:"md",withBorder:true,style:{cursor:"pointer"},onClick:()=>onConfigJob(job),children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:8,wrap:"nowrap",style:{flex:1,minWidth:0},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Box,{w:8,h:8,style:{borderRadius:"50%",background:`var(--mantine-color-${color}-6)`,flexShrink:0}}),/*#__PURE__*/(0,jsx_runtime.jsx)(JobLogos,{job:job}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{truncate:true,style:{fontSize:"1rem"},children:job.task_fr})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:4,wrap:"nowrap",onClick:e=>e.stopPropagation(),children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{size:"sm",variant:"subtle",color:"green",loading:runJob.isPending,title:"Lancer",onClick:()=>runJob.mutate({id:detail.id,jobId:job.id}),children:"▶"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{size:"sm",variant:"subtle",color:"gray",title:"Configurer",onClick:()=>onConfigJob(job),children:"⚙"}),(job.allow_disable||job.allow_delete)&&/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Menu,{shadow:"md",width:180,position:"bottom-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Target,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{size:"sm",variant:"subtle",color:"gray",title:"Plus d'options",children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconDotsVertical,{size:16})})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Menu.Dropdown,{children:[job.allow_disable&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{leftSection:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconCpuOff,{size:14}),onClick:()=>{if(job.active)setTimeout(()=>{modals_esm_index_mjs_.modals.openConfirmModal({title:"D\xe9sactiver cette t\xe2che ?",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:"La t\xe2che ne sera plus ex\xe9cut\xe9e tant qu'elle reste d\xe9sactiv\xe9e."}),labels:{confirm:"D\xe9sactiver",cancel:"Annuler"},onConfirm:()=>toggleJob.mutate({id:detail.id,jobId:job.id,active:false})})},0);else toggleJob.mutate({id:detail.id,jobId:job.id,active:true})},children:job.active?"D\xe9sactiver":"Activer"}),job.allow_delete&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{color:"red",leftSection:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconTrash,{size:14}),onClick:()=>{setTimeout(()=>{modals_esm_index_mjs_.modals.openConfirmModal({title:"Supprimer cette t\xe2che ?",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:"Cette action est irr\xe9versible. La configuration de la t\xe2che sera perdue."}),labels:{confirm:"Supprimer",cancel:"Annuler"},confirmProps:{color:"red"},onConfirm:()=>deleteJob.mutate({id:detail.id,jobId:job.id})})},0)},children:"Supprimer"})]})]})]})]})})},job.id)};const visibleJobs=detail.jobs.slice(0,VISIBLE_JOBS_LIMIT);const hiddenJobs=detail.jobs.slice(VISIBLE_JOBS_LIMIT);const hasMore=hiddenJobs.length>0;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid,{gutter:"md",children:visibleJobs.map(renderJobCol)}),hasMore&&/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Collapse,{in:expanded,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid,{gutter:"md",children:hiddenJobs.map(renderJobCol)})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{justify:"center",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"subtle",size:"sm",color:"gray",rightSection:expanded?/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconChevronUp,{size:14}):/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconChevronDown,{size:14}),onClick:()=>setExpanded(v=>!v),children:expanded?"R\xe9duire":`Voir ${hiddenJobs.length} jobs suppl\xe9mentaires`})})]})]})}function formatDuration(ms){if(null===ms)return"—";if(ms<1e3)return`${ms}ms`;const secs=ms/1e3;if(secs<60)return`${secs.toFixed(1)}s`;const mins=Math.floor(secs/60);const remainSecs=Math.round(secs%60);return`${mins}mn ${remainSecs}s`}function formatDate(iso){if(!iso)return"—";return new Date(iso).toLocaleString("fr-FR",{day:"2-digit",month:"2-digit",hour:"2-digit",minute:"2-digit"})}function synchro_history_connectorLogoUrl(c){return c.logo_key?`https://img.logo.dev/${c.logo_key}?token=pk_QvyqAb6uTRGJE2_sDsEb9g&retina=true`:`https://s3.eu-west-3.amazonaws.com/media.airporting/connectors/${c.codename}.png`}function TaskLogos({task}){if(!task.connector_from&&!task.connector_to)return null;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:3,wrap:"nowrap",children:[task.connector_from&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:task.connector_from.name,withArrow:true,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Avatar,{src:synchro_history_connectorLogoUrl(task.connector_from),size:20,radius:"md",p:0})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:"→"}),task.connector_to&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:task.connector_to.name,withArrow:true,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Avatar,{src:synchro_history_connectorLogoUrl(task.connector_to),size:20,radius:"md",p:0})})]})}function SynchroHistory({tasks}){const showRecipeCol=tasks.some(t=>t.connector_from||t.connector_to);if(0===tasks.length)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",size:"sm",children:"Aucun historique disponible."});return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{striped:true,highlightOnHover:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Thead,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[showRecipeCol&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Recette"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"T\xe2che"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"D\xe9marr\xe9e"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Lanc\xe9e par"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Statut"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Dur\xe9e"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"#ops"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Logs"})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:tasks.map(task=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[showRecipeCol&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(TaskLogos,{task:task})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:task.job_name_fr}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:formatDate(task.startedAt)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:task.owner?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:task.owner}):/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:"gray",variant:"light",children:"Programm\xe9e"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:task.finished?task.error?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:"red",children:"Erreur"}):/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:"green",children:"OK"}):/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:"yellow",children:"En cours"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:formatDuration(task.runDuration)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:task.trace_count}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:task.grafana_url?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Anchor,{href:task.grafana_url,target:"_blank",size:"sm",children:"Logs"}):"—"})]},task.id))})]})}function useSynchroJobConfigQuery(recipeId,jobId){const api=useApiSynchro();return(0,modern_index_js_.useQuery)({queryKey:["synchro","job-config",recipeId,jobId],queryFn:()=>api.get(`/synchro/${recipeId}/jobs/${jobId}/config`),enabled:null!==recipeId&&null!==jobId})}function useSynchroJobSaveMutation(){const api=useApiSynchro();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:({id,jobId,data})=>api.put(`/synchro/${id}/jobs/${jobId}`,data),onSuccess:(_,{id})=>{queryClient.invalidateQueries({queryKey:["synchro","detail",id]});esm_index_mjs_.notifications.show({title:"Configuration sauvegard\xe9e",message:"Les param\xe8tres sont enregistr\xe9s."})},onError:()=>{esm_index_mjs_.notifications.show({color:"red",title:"Erreur",message:"Impossible de sauvegarder la configuration."})}})}var form_esm_index_mjs_=__webpack_require__(4491);var dates_esm_index_mjs_=__webpack_require__(5899);const START_PRESETS=[{value:"today",label:"Jour courant"},{value:"month_start",label:"D\xe9but du mois"},{value:"prev_month_start",label:"D\xe9but du mois pr\xe9c\xe9dent"},{value:"year_start",label:"D\xe9but de l'ann\xe9e"}];const END_PRESETS=[{value:"today",label:"Jour courant"},{value:"month_end",label:"Fin du mois"},{value:"prev_month_end",label:"Fin du mois pr\xe9c\xe9dent"},{value:"year_end",label:"Fin de l'ann\xe9e"}];const MODE_VALUES={TODAY:"today",MONTH_START:"month_start",PREV_MONTH_START:"prev_month_start",YEAR_START:"year_start",MONTH_END:"month_end",PREV_MONTH_END:"prev_month_end",YEAR_END:"year_end"};const MODE_KEYS={today:"TODAY",month_start:"MONTH_START",prev_month_start:"PREV_MONTH_START",year_start:"YEAR_START",month_end:"MONTH_END",prev_month_end:"PREV_MONTH_END",year_end:"YEAR_END",exact:"",relative:""};function parseValue(val){const defaults={exactDate:null,direction:"MINUS",amount:1,unit:"DAYS"};if(!val)return{mode:"today",...defaults};if(MODE_VALUES[val])return{mode:MODE_VALUES[val],...defaults};const relMatch=val.match(/^(MINUS|PLUS):(\d+):(\w+)$/);if(relMatch)return{mode:"relative",exactDate:null,direction:relMatch[1],amount:Number(relMatch[2]),unit:relMatch[3]};const d=new Date(val);if(!isNaN(d.getTime()))return{mode:"exact",exactDate:d,...defaults};return{mode:"today",...defaults}}function serializeValue(mode,exactDate,direction,amount,unit){if("exact"===mode)return exactDate?exactDate.toISOString():"";if("relative"===mode)return`${direction}:${amount}:${unit}`;return MODE_KEYS[mode]||"TODAY"}function InputDateBoundary({label,help,required,disabled,value,onChange,variant}){const parsed=parseValue(value);const[mode,setMode]=(0,index_js_.useState)(parsed.mode);const[exactDate,setExactDate]=(0,index_js_.useState)(parsed.exactDate);const[direction,setDirection]=(0,index_js_.useState)(parsed.direction);const[amount,setAmount]=(0,index_js_.useState)(parsed.amount);const[unit,setUnit]=(0,index_js_.useState)(parsed.unit);(0,index_js_.useEffect)(()=>{onChange(serializeValue(mode,exactDate,direction,amount,unit))},[mode,exactDate,direction,amount,unit]);const presets="start"===variant?START_PRESETS:END_PRESETS;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"xs",children:[label&&/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",fw:500,children:[label," ",required&&/*#__PURE__*/(0,jsx_runtime.jsx)("span",{style:{color:"var(--mantine-color-red-6)"},children:"*"})]}),help&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:help}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Radio.Group,{value:mode,onChange:v=>setMode(v),children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"sm",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"md",wrap:"nowrap",grow:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Radio,{value:"exact",label:"Date exacte",disabled:disabled}),/*#__PURE__*/(0,jsx_runtime.jsx)(dates_esm_index_mjs_.DateInput,{leftSection:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconCalendar,{size:16}),value:exactDate,onChange:d=>{setExactDate(d);setMode("exact")},disabled:disabled||"exact"!==mode,valueFormat:"DD-MM-YYYY",placeholder:"JJ-MM-AAAA"})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"md",wrap:"nowrap",grow:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Radio,{value:"relative",label:"Date relative",disabled:disabled}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{data:[{value:"MINUS",label:"pass\xe9e"},{value:"PLUS",label:"future"}],value:direction,onChange:v=>{setDirection(v??"MINUS");setMode("relative")},disabled:disabled||"relative"!==mode,w:100}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.NumberInput,{value:amount,onChange:v=>{setAmount(Number(v));setMode("relative")},min:0,disabled:disabled||"relative"!==mode,w:70}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{data:[{value:"DAYS",label:"Jour(s)"},{value:"MONTHS",label:"Mois"},{value:"YEARS",label:"Ann\xe9e(s)"}],value:unit,onChange:v=>{setUnit(v??"DAYS");setMode("relative")},disabled:disabled||"relative"!==mode,w:110})]}),presets.map(p=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Radio,{value:p.value,label:p.label,disabled:disabled},p.value))]})})]})}function useSpreadsheetsQuery(){const api=useApiSynchro();const config=useAppConfigSynchro();return(0,modern_index_js_.useQuery)({queryKey:["synchro","spreadsheets",config.company],queryFn:()=>api.get(`/synchro/spreadsheets?cid=${config.company}`)})}function InputGsheetsSelector({label,help,required,disabled,value,onChange,error}){const{data:spreadsheets,isPending}=useSpreadsheetsQuery();const options=(spreadsheets??[]).map(s=>({value:s.id,label:s.name}));return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:label??"Tableur",description:help??void 0,required:required,disabled:disabled||isPending,placeholder:isPending?"Chargement...":"S\xe9lectionner un tableur",data:options,value:value,onChange:onChange,error:error,searchable:true,clearable:true})}const ACCOUNT_ID_NAME_SHAPE={valueField:"account_id",labelField:"account_name",secondaryFields:["account_id"]};const ACCOUNT_SELECTOR_REGISTRY={airporting_account_selector:ACCOUNT_ID_NAME_SHAPE,alma_account_selector:ACCOUNT_ID_NAME_SHAPE,bridge_account_selector:ACCOUNT_ID_NAME_SHAPE,chargebee_account_selector:ACCOUNT_ID_NAME_SHAPE,hubspot_deal_property_selector:ACCOUNT_ID_NAME_SHAPE,hubspot_line_item_property_selector:ACCOUNT_ID_NAME_SHAPE,ibanfirst_account_selector:ACCOUNT_ID_NAME_SHAPE,paypal_account_selector:ACCOUNT_ID_NAME_SHAPE,pennylane_account_selector:ACCOUNT_ID_NAME_SHAPE,profitwell_account_selector:ACCOUNT_ID_NAME_SHAPE,qonto_account_selector:ACCOUNT_ID_NAME_SHAPE,revolut_account_selector:ACCOUNT_ID_NAME_SHAPE,shopify_account_selector:ACCOUNT_ID_NAME_SHAPE,sobank_account_selector:{valueField:"Account_Name",secondaryFields:["Iban"]},stripe_account_selector:ACCOUNT_ID_NAME_SHAPE,sycomore_account_selector:ACCOUNT_ID_NAME_SHAPE,wise_account_selector:ACCOUNT_ID_NAME_SHAPE};function buildAccountOptions(source,cfg){return source.map(row=>{const value=String(row?.[cfg.valueField]??"");const label=String(row?.[cfg.labelField??cfg.valueField]??value);const secondary=(cfg.secondaryFields??[]).map(f=>row?.[f]).filter(v=>null!=v&&""!==v).join(" \xb7 ");return{value,label,secondary}})}function FormField({config,value,onChange,error}){const label=config.label??config.name??"";const description=config.help??void 0;const required=config.required??false;const disabled=config.disabled??false;const selectOptions=(()=>{if(!config.full||"object"!=typeof config.full)return[];const f=config.full;if(Array.isArray(f.options))return f.options.map(o=>"string"==typeof o?{value:o,label:o}:{value:String(o.value??o.id??o),label:o.label??o.name??String(o)});return[]})();switch(config.type){case"text":if(config.multiple)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TagsInput,{label:label,description:description,required:required,disabled:disabled,value:Array.isArray(value)?value:value?[value]:[],onChange:onChange,error:error});return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:label,description:description,required:required,disabled:disabled,value:value??"",onChange:e=>onChange(e.currentTarget.value),error:error});case"email":return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{type:"email",label:label,description:description,required:required,disabled:disabled,value:value??"",onChange:e=>onChange(e.currentTarget.value),error:error});case"password":return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.PasswordInput,{label:label,description:description,required:required,disabled:disabled,value:value??"",onChange:e=>onChange(e.currentTarget.value),error:error});case"hidden":return null;case"msg":return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:"dimmed",children:label});case"switch":return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Switch,{label:label,description:description,disabled:disabled,checked:!!value,onChange:e=>onChange(e.currentTarget.checked)});case"select":return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:label,description:description,required:required,disabled:disabled,data:selectOptions,value:value??null,onChange:onChange,error:error,searchable:true});case"date_boundary_start":return/*#__PURE__*/(0,jsx_runtime.jsx)(InputDateBoundary,{label:label,help:description,required:required,disabled:disabled,value:value,onChange:onChange,variant:"start"});case"date_boundary_end":return/*#__PURE__*/(0,jsx_runtime.jsx)(InputDateBoundary,{label:label,help:description,required:required,disabled:disabled,value:value,onChange:onChange,variant:"end"});case"tags_multiple":return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TagsInput,{label:label,description:description,required:required,disabled:disabled,value:Array.isArray(value)?value:value?String(value).split(",").filter(Boolean):[],onChange:onChange,error:error});case"gsheets_account_selector":return/*#__PURE__*/(0,jsx_runtime.jsx)(InputGsheetsSelector,{label:label,help:description,required:required,disabled:disabled,value:value,onChange:onChange,error:error});case"totp":return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:label,description:description,required:required,disabled:disabled,value:value??"",onChange:e=>onChange(e.currentTarget.value),error:error,placeholder:"123456",autoComplete:"one-time-code",inputMode:"numeric"});case"select_multiple":{const sourceValues=config.full?.values;const data=Array.isArray(sourceValues)?sourceValues.map(o=>"string"==typeof o?{value:o,label:o}:{value:String(o.value??o.id??o),label:o.label??o.name??String(o)}):[];const fallbackDefault=config.full?.default;const currentValue=(()=>{if(Array.isArray(value))return value;if("string"==typeof value&&value.includes(","))return value.split(",").filter(Boolean);if(Array.isArray(fallbackDefault))return fallbackDefault;return[]})();return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.MultiSelect,{label:label,description:description,required:required,disabled:disabled,data:data,value:currentValue,onChange:onChange,error:error,searchable:true})}case"number":return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.NumberInput,{label:label,description:description,required:required,disabled:disabled,value:value??"",onChange:onChange,error:error});case"checkbox":return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Checkbox,{label:label,description:description,disabled:disabled,checked:!!value,onChange:e=>onChange(e.currentTarget.checked)});case"multi_select":return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.MultiSelect,{label:label,description:description,required:required,disabled:disabled,data:selectOptions,value:Array.isArray(value)?value:[],onChange:onChange,error:error,searchable:true});case"recipe_cf_pipedrive":return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TagsInput,{label:label,description:description,required:required,disabled:disabled,value:Array.isArray(value)?value:value?String(value).split(",").filter(Boolean):[],onChange:onChange,error:error});default:{const accountCfg=config.type?ACCOUNT_SELECTOR_REGISTRY[config.type]:void 0;if(accountCfg){const sourceValues=config.full?.values;if(Array.isArray(sourceValues)&&sourceValues.length>0){const options=buildAccountOptions(sourceValues,accountCfg);const renderOption=({option})=>{const match=options.find(d=>d.value===option.value);return/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:match?.label??option.value}),match?.secondary&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",opacity:.5,children:match.secondary})]})};if(config.multiple)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.MultiSelect,{label:label,description:description,required:required,disabled:disabled,data:options,value:Array.isArray(value)?value:[],onChange:onChange,renderOption:renderOption,error:error,searchable:true});return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:label,description:description,required:required,disabled:disabled,data:options,value:"string"==typeof value?value:null,onChange:v=>onChange(v??""),renderOption:renderOption,error:error,searchable:true})}return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:4,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Alert,{variant:"light",color:"gray",children:"Source non charg\xe9e — saisie manuelle de l'identifiant."}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:label,description:description,required:required,disabled:disabled,value:value??"",onChange:e=>onChange(e.currentTarget.value),error:error})]})}return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Alert,{variant:"light",color:"yellow",title:`Type "${config.type}" non support\xe9`,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"xs",children:["Champ : ",config.name]})})}}}function SynchroDynamicForm({config,save}){const form=(0,form_esm_index_mjs_.useForm)({initialValues:config.data?.initialData??{}});(0,index_js_.useEffect)(()=>{if(config.data?.initialData){form.setValues(config.data.initialData);form.resetDirty()}},[config.data]);if(config.isPending||!config.data)return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:30,mt:6,radius:"xl"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:12,mt:6,w:"30%",radius:"xl"})]});const{sections}=config.data;if(!sections?.length)return null;return/*#__PURE__*/(0,jsx_runtime.jsx)("form",{autoComplete:"off",onSubmit:form.onSubmit(values=>save.mutate(values)),children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"md",children:[sections.map((section,si)=>section.fields.map((fieldConfig,fi)=>/*#__PURE__*/(0,jsx_runtime.jsx)(FormField,{config:fieldConfig,value:form.values[fieldConfig.name],onChange:value=>form.setFieldValue(fieldConfig.name,value),error:form.errors[fieldConfig.name]},`${si}-${fi}`))),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{justify:"flex-end",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{type:"submit",loading:save.isPending,children:"Enregistrer"})})]})})}function JobConfigModal({job,recipeId,opened,onClose}){const save=useSynchroJobSaveMutation();const configQuery=useSynchroJobConfigQuery(opened?recipeId:null,opened?job?.id??null:null);const saveMutation=(0,index_js_.useMemo)(()=>({...save,mutate:values=>{if(!job)return;save.mutate({id:recipeId,jobId:job.id,data:values})}}),[save,job,recipeId]);if(!job)return null;const hasForm=configQuery.data?.sections?.length>0;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Modal,{opened:opened,onClose:onClose,title:job.task_fr,size:"lg",children:[configQuery.isPending||hasForm?/*#__PURE__*/(0,jsx_runtime.jsx)(SynchroDynamicForm,{config:configQuery,save:saveMutation}):/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",size:"sm",children:"Aucune configuration disponible pour cette t\xe2che."}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{justify:"flex-end",mt:"md",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"subtle",color:"gray",onClick:onClose,children:"Fermer"})})]})}var hooks_esm_index_mjs_=__webpack_require__(2667);function useCreateScheduleMutation(){const api=useApiSynchro();const qc=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:({recipeCustomerId,data})=>api.post(`/synchro/${recipeCustomerId}/schedules`,data),onSuccess:()=>qc.invalidateQueries({queryKey:["synchro"]})})}function useUpdateScheduleMutation(){const api=useApiSynchro();const qc=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:({recipeCustomerId,scheduleId,data})=>api.put(`/synchro/${recipeCustomerId}/schedules/${scheduleId}`,data),onSuccess:()=>qc.invalidateQueries({queryKey:["synchro"]})})}function useDeleteScheduleMutation(){const api=useApiSynchro();const qc=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:({recipeCustomerId,scheduleId})=>api.delete(`/synchro/${recipeCustomerId}/schedules/${scheduleId}`),onSuccess:()=>qc.invalidateQueries({queryKey:["synchro"]})})}const DAY_LABELS={monday:"Lun",tuesday:"Mar",wednesday:"Mer",thursday:"Jeu",friday:"Ven",saturday:"Sam",sunday:"Dim"};const ALL_DAYS=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"];function SynchroSchedules({schedules,jobs,recipeCustomerId}){const[opened,{open,close}]=(0,hooks_esm_index_mjs_.useDisclosure)(false);const[editing,setEditing]=(0,index_js_.useState)(null);const handleEdit=s=>{setEditing(s);open()};const handleNew=()=>{setEditing(null);open()};return/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"sm",children:[0===schedules.length&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",size:"sm",children:"Aucun d\xe9clencheur configur\xe9."}),schedules.map(s=>/*#__PURE__*/(0,jsx_runtime.jsx)(ScheduleCard,{schedule:s,jobs:jobs,recipeCustomerId:recipeCustomerId,onEdit:()=>handleEdit(s)},s.id)),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"light",size:"xs",leftSection:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconPlus,{size:14}),onClick:handleNew,w:"fit-content",children:"Ajouter un d\xe9clencheur"})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(ScheduleModal,{opened:opened,onClose:close,schedule:editing,jobs:jobs,recipeCustomerId:recipeCustomerId})]})}function ScheduleCard({schedule,jobs,recipeCustomerId,onEdit}){const deleteMut=useDeleteScheduleMutation();const hour=String(schedule.hour??0).padStart(2,"0");const minute=String(schedule.minute??0).padStart(2,"0");const taskLabels=schedule.tasks.map(t=>{const job=jobs.find(j=>String(j.id)===t);return job?.active?job.task_fr:null}).filter(Boolean);return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Card,{withBorder:true,p:"sm",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:6,style:{flex:1},children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconClock,{size:16}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",fw:500,children:[hour,":",minute]}),schedule.frequency&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{variant:"light",size:"sm",children:schedule.frequency}),schedule.draft&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{variant:"light",size:"sm",color:"yellow",children:"Brouillon"})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconCalendar,{size:16}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{gap:4,children:ALL_DAYS.map(day=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",variant:schedule.days.includes(day)?"filled":"light",color:schedule.days.includes(day)?"teal":"gray",children:DAY_LABELS[day]},day))})]}),taskLabels.length>0&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{gap:4,wrap:"wrap",children:taskLabels.map((label,i)=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",variant:"outline",children:label},i))})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:4,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{size:"sm",variant:"subtle",onClick:onEdit,title:"Modifier",children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconPencil,{size:14})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{size:"sm",variant:"subtle",color:"red",loading:deleteMut.isPending,onClick:()=>deleteMut.mutate({recipeCustomerId,scheduleId:schedule.id}),title:"Supprimer",children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconTrash,{size:14})})]})]})})}function ScheduleModal({opened,onClose,schedule,jobs,recipeCustomerId}){const createMut=useCreateScheduleMutation();const updateMut=useUpdateScheduleMutation();const[days,setDays]=(0,index_js_.useState)(ALL_DAYS);const[hour,setHour]=(0,index_js_.useState)(1);const[minute,setMinute]=(0,index_js_.useState)(0);const[selectedTasks,setSelectedTasks]=(0,index_js_.useState)([]);(0,index_js_.useEffect)(()=>{if(schedule){setDays(schedule.days);setHour(schedule.hour??1);setMinute(schedule.minute??0);setSelectedTasks(schedule.tasks)}else{setDays(ALL_DAYS);setHour(1);setMinute(0);setSelectedTasks([])}},[schedule,opened]);const toggleDay=day=>{setDays(prev=>prev.includes(day)?prev.filter(d=>d!==day):[...prev,day])};const toggleTask=task=>{setSelectedTasks(prev=>prev.includes(task)?prev.filter(t=>t!==task):[...prev,task])};const handleSave=()=>{const data={days,hour,minute,tasks:selectedTasks};if(schedule)updateMut.mutate({recipeCustomerId,scheduleId:schedule.id,data},{onSuccess:onClose});else createMut.mutate({recipeCustomerId,data},{onSuccess:onClose})};const isPending=createMut.isPending||updateMut.isPending;return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:opened,onClose:onClose,title:schedule?"Modifier le d\xe9clencheur":"Nouveau d\xe9clencheur",size:"md",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"sm",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.NumberInput,{label:"Heure",value:hour,onChange:v=>setHour(Number(v)),min:0,max:23,w:80}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.NumberInput,{label:"Minute",value:minute,onChange:v=>setMinute(Number(v)),min:0,max:59,w:80})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:4,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",fw:500,children:"Jours"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{gap:4,children:ALL_DAYS.map(day=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"lg",variant:days.includes(day)?"filled":"light",color:days.includes(day)?"teal":"gray",style:{cursor:"pointer"},onClick:()=>toggleDay(day),children:DAY_LABELS[day]},day))})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:4,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",fw:500,children:"Jobs \xe0 d\xe9clencher"}),jobs.map(job=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Checkbox,{label:job.task_fr??job.task,checked:selectedTasks.includes(String(job.id)),onChange:()=>toggleTask(String(job.id))},job.id))]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"subtle",color:"gray",onClick:onClose,children:"Annuler"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{onClick:handleSave,loading:isPending,children:schedule?"Enregistrer":"Cr\xe9er"})]})]})})}function SynchroApp(){const[selectedId,setSelectedIdState]=(0,index_js_.useState)(()=>{const param=new URLSearchParams(window.location.search).get("recipeId");const parsed=param?Number(param):NaN;return Number.isInteger(parsed)&&parsed>0?parsed:null});const[configJob,setConfigJob]=(0,index_js_.useState)(null);const listRes=useSynchroListQuery();const detailRes=useSynchroDetailQuery(selectedId);const runAll=useSynchroRunMutation();const toggle=useSynchroToggleMutation();const recipes=listRes.data??[];const detail=detailRes.data;const setSelectedId=(0,index_js_.useCallback)(id=>{setSelectedIdState(id);const url=new URL(window.location.href);if(null===id)url.searchParams.delete("recipeId");else url.searchParams.set("recipeId",String(id));window.history.replaceState({},"",url)},[]);(0,index_js_.useEffect)(()=>{if(0===recipes.length)return;const exists=null!==selectedId&&recipes.some(r=>r.id===selectedId);if(!exists)setSelectedId(recipes[0].id)},[recipes,selectedId,setSelectedId]);if(listRes.isPending)return/*#__PURE__*/(0,jsx_runtime.jsx)(InlineLoader.F,{label:"Chargement des synchronisations..."});return/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{wrap:"nowrap",h:"100%",align:"flex-start",gap:0,children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Box,{w:220,h:"100%",style:{flexShrink:0,borderRight:"1px solid var(--mantine-color-dark-5)"},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:5,p:"sm",c:"dimmed",children:"Synchronisations"}),0===recipes.length?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:"dimmed",px:"sm",children:"Aucune recette configur\xe9e."}):/*#__PURE__*/(0,jsx_runtime.jsx)(SynchroList,{recipes:recipes,selectedId:selectedId,onSelect:setSelectedId})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Box,{flex:1,p:"md",style:{overflowY:"auto"},children:null===selectedId?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"S\xe9lectionnez une recette."}):detailRes.isPending?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{h:40}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{h:120}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{h:200})]}):detail?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"lg",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:3,children:"Total"===detail.recipe.name||"[Total]"===detail.recipe.name?"Vue d'ensemble":detail.recipe.name}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"sm",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Switch,{checked:detail.active,label:detail.active?"Actif":"Inactif",onChange:()=>toggle.mutate({id:detail.id,active:!detail.active})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"light",color:"green",loading:runAll.isPending,onClick:()=>runAll.mutate(detail.id),children:"▶ Lancer tout"})]})]}),!("Total"===detail.recipe.name||"[Total]"===detail.recipe.name)&&/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:5,c:"dimmed",children:"D\xe9clencheurs"}),/*#__PURE__*/(0,jsx_runtime.jsx)(SynchroSchedules,{schedules:detail.schedules,jobs:detail.jobs,recipeCustomerId:detail.id})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(SynchroFunctions,{detail:detail,onConfigJob:setConfigJob}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Accordion,{defaultValue:null,variant:"default",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Accordion.Item,{value:"history",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Accordion.Control,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:5,c:"dimmed",children:"Historique"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Accordion.Panel,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(SynchroHistory,{tasks:detail.tasks})})]})})]}):/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"Impossible de charger la recette."})})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(JobConfigModal,{job:configJob,recipeId:selectedId??0,opened:null!==configJob,onClose:()=>setConfigJob(null)})]})}var dist_index_js_=__webpack_require__(6584);var dist_esm_index_mjs_=__webpack_require__(4449);const theme=(0,index_mjs_.createTheme)((0,dist_esm_index_mjs_.assign)(dist_index_js_.theme,{components:{}}));const cssVarResolver=x=>(0,dist_esm_index_mjs_.assign)(dist_index_js_.cssVarResolver(x),{dark:{},light:{},variables:{}});function ProvidersSynchro(props){const{children,config,mantine,tanstack}=props;return/*#__PURE__*/(0,jsx_runtime.jsx)(AppConfigSynchroProvider,{value:config,children:/*#__PURE__*/(0,jsx_runtime.jsx)(modern_index_js_.QueryClientProvider,{client:tanstack?.queryClient??new modern_index_js_.QueryClient,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.MantineProvider,{theme:theme,cssVariablesResolver:cssVarResolver,defaultColorScheme:mantine?.defaultColorScheme,forceColorScheme:mantine?.forceColorScheme,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(modals_esm_index_mjs_.ModalsProvider,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(esm_index_mjs_.Notifications,{}),children]})})})})}function Synchronisation(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_js_.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(ProvidersSynchro,{...props,children:/*#__PURE__*/(0,jsx_runtime.jsx)(SynchroApp,{})})})}},800:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{F:()=>InlineLoader});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(4848);var _mantine_core__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(2773);function InlineLoader({label}){return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Center,{flex:1,h:"100%",children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Stack,{align:"center",gap:"md",children:[/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Loader,{size:"md",color:"teal"}),label&&/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Text,{fz:"sm",c:"dimmed",children:label})]})})}}}]);