import{n as e}from"./rolldown-runtime-BG2f4sTM.js";import{A4 as t,Evt as n,Kmt as r,M_t as i,Mvt as a,O_t as o,P4 as s,P_t as c,U4 as l,a3 as u,b as d,c2 as f,ddt as p,i_t as m,lvt as h,m2 as g,m_t as _,npt as v,odt as y,pvt as b,r3 as x,sdt as S,udt as C,v_t as w,y as T,y_t as E}from"./app-initial-BHB6SClA.js";function D(){let e=(0,A.c)(16),r=n(),a=c(f),{data:o}=i(l,a),s=u(),d;e[0]===a?d=e[1]:(d=[...t,a],e[0]=a,e[1]=d);let m=d,h;e[2]!==a||e[3]!==o?.configWriteTarget?.filePath?(h=e=>{let{enabled:t}=e;return p(`batch-write-config-value`,{hostId:a,edits:[{keyPath:j,value:t,mergeStrategy:`upsert`}],filePath:o?.configWriteTarget?.filePath??null,expectedVersion:null,reloadUserConfig:!0})},e[2]=a,e[3]=o?.configWriteTarget?.filePath,e[4]=h):h=e[4];let g,_;e[5]!==r||e[6]!==m?(g=async e=>{let{enabled:t}=e;await r.cancelQueries({queryKey:m});let n=r.getQueryData(m);return r.setQueryData(m,e=>e==null?e:{...e,config:O(e.config,t)}),{previousUserConfig:n}},_=(e,t,n)=>{S.error(`Failed to update Chronicle config`,{safe:{error:String(e)},sensitive:{}}),r.setQueryData(m,n?.previousUserConfig)},e[5]=r,e[6]=m,e[7]=g,e[8]=_):(g=e[7],_=e[8]);let v;e[9]===s?v=e[10]:(v=async()=>{await Promise.all([s(t),s([`user-saved-config`])])},e[9]=s,e[10]=v);let y;return e[11]!==h||e[12]!==g||e[13]!==_||e[14]!==v?(y={mutationFn:h,onMutate:g,onError:_,onSettled:v},e[11]=h,e[12]=g,e[13]=_,e[14]=v,e[15]=y):y=e[15],b(y)}function O(e,t){return Object.assign(structuredClone(e),{features:{...k(e.features,T,t)}})}function k(e,t,n){let r=M.safeParse(e);return{...r.success?r.data:{},[t]:n}}var A,j,M,N=e((()=>{A=a(),h(),o(),v(),m(),g(),C(),s(),x(),y(),d(),j=r(T),M=w(E(),_())}));export{N as n,D as r,O as t};
//# sourceMappingURL=chronicle-config-queries-Dqaq04vs.js.map