openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 1.57 kB
JavaScript
import{n as e}from"./rolldown-runtime-8BhlS34s.js";import{M as t,N as n,P as r}from"./control-ui-foundation-ZY_Flbbd.js";import{$n as i,Ft as a,Nt as o,Pt as s,b as c,er as l,y as u}from"./control-ui-core-CFW9Qtjn.js";import{n as d,t as f}from"./user-prefs-request-Y0ykMyQk.js";async function p(e,n,r){if(!e||!r)return{ok:!1,reason:`unavailable`,error:`Profile preferences are unavailable.`};let o=n.theme!==void 0||n.themeMode!==void 0;o&&s(e);try{if(o){let t={...n.accent===void 0?{}:{accent:n.accent},...n.fontUi===void 0?{}:{fontUi:n.fontUi},...n.fontChat===void 0?{}:{fontChat:n.fontChat}};return{ok:!0,value:await e.request(`themes.set`,{...n.theme===void 0?{}:{id:n.theme},...n.themeMode===void 0?{}:{mode:n.themeMode},...Object.keys(t).length?{appearance:t}:{}}),refresh:{ok:!0}}}let r=Object.fromEntries(Object.entries(n).flatMap(([e,n])=>c(e)?[[t[e],n]]:[])),i=await a(e,{entries:r});return i.status===`ok`?{ok:!0,value:i,refresh:{ok:!0}}:{ok:!1,reason:`rejected`,error:`Profile preferences are unavailable.`}}catch(e){return{ok:!1,reason:e instanceof i&&(e.gatewayCode===`INVALID_REQUEST`||e.gatewayCode===`FORBIDDEN`)?`rejected`:`error`,error:e instanceof Error?e.message:String(e)}}finally{o&&s(e)}}async function m(e,n){let i=await d(e,n,{keys:Object.values(t)});if(i.status!==`ok`)return null;let a={};for(let[e,n]of Object.entries(t)){if(!c(e))continue;let t=r(n,i.entries[n]);t!==void 0&&Object.assign(a,{[e]:t})}return a}function h(){return(h=e((()=>{n(),l(),u(),o(),f()})))()}h();export{m as readProfileAppearancePrefs,p as writeProfileAppearancePrefs};