UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

2 lines • 3.96 kB
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./_1____________________________.css"])))=>i.map(i=>d[i]); import{n as e,r as t}from"./rolldown-runtime-CNOWq4Kh.js";import{$u as n,Br as r,G as i,Gr as a,K as o,Qu as s,Si as c,Ti as l,_n as u,dn as d,fn as f,gn as p,li as m,mn as h,oi as g,v as _,vn as v,xi as y,xn as b,y as x,yn as S}from"./_4____________________________.js";import{AN as C,EN as w,GN as T,eD as E,nD as D,qN as O,tD as k}from"./_2_____________________________.js";import{n as A,t as j}from"./server-prefs-write-batch-BFG8yduO.js";import{n as M,t as N}from"./user-prefs-request-DMVPtOdQ.js";var P=t({canSyncAppearancePreference:()=>F,loadProfileAppearancePrefs:()=>R,readProfileAppearancePrefs:()=>L,writeProfileAppearancePrefs:()=>I});function F(e,t){let{runtimeConfig:n}=e;if(!n.state.connected)return null;let r=e.gateway.snapshot;return t&&f[t].configSync===!1&&!r.selfUser?!1:t&&r.selfUser?i(r.hello?.auth??null):n.canPatch!==!1}async function I(e,t,n,i,a){let o=t,c=(e,t=`unavailable`,n=o)=>({ok:!1,reason:t,error:e,batch:n}),u=Object.keys(o).some(S);u&&(o=Object.fromEntries(Object.entries(o).filter(([e])=>S(e))));let d=o.theme!==void 0||o.themeMode!==void 0;if(d&&(o=Object.fromEntries(Object.entries(o).filter(([e])=>[`theme`,`themeMode`,`accent`,`fontUi`,`fontChat`].includes(e)))),!e||!n())return c(`Profile preferences are unavailable.`);if(o.background!==void 0&&a===void 0)return c(`Background preferences have not loaded.`);d&&k(e);try{if(u){if(!i)return c(`Navigation profile is unavailable.`);let a=t.sidebarEntriesBase,l=Object.keys(o).filter(S),u=await M(e,i,{keys:l.map(e=>h[e])});if(!n()||u.status!==`ok`)return c(`Navigation preferences are unavailable.`);let d={...o};if(Array.isArray(o.sidebarEntries)){let e=f.sidebarEntries.extract(a),n=f.sidebarEntries.extract(u.entries[h.sidebarEntries]??r);if(!e||!b(e,a)){let{registerPreferencesEnglish:e}=await s(async()=>{let{registerPreferencesEnglish:e}=await import(`./en-preferences-BxI3BUpx.js`).then(e=>(e.n(),e.t));return{registerPreferencesEnglish:e}},__vite__mapDeps([0]),import.meta.url);return O(e),c(m(`quickSettings.personal.shortcutsLocalOnly`),`rejected`,{sidebarEntries:o.sidebarEntries})}if(!n)return c(`Navigation preferences are unavailable.`);d.sidebarEntries=A(e,o.sidebarEntries,n,t.sidebarEntriesOrder)}let p=Object.fromEntries(l.map(e=>[h[e],d[e]])),g=Object.fromEntries(l.map(e=>{let t=h[e];return[t,u.entries[t]??null]})),_=await D(e,{entries:p,expectedEntries:g});return _.status===`ok`?{ok:!0,value:_,refresh:{ok:!0},batch:o,committedBatch:d}:c(`Navigation preferences changed or are unavailable.`,_.status===`conflict`?`conflict`:`unavailable`)}if(d){let t={...o.accent===void 0?{}:{accent:o.accent},...o.fontUi===void 0?{}:{fontUi:o.fontUi},...o.fontChat===void 0?{}:{fontChat:o.fontChat}};return{ok:!0,value:await e.request(`themes.set`,{...o.theme===void 0?{}:{id:o.theme},...o.themeMode===void 0?{}:{mode:o.themeMode},...Object.keys(t).length?{appearance:t}:{}}),refresh:{ok:!0},batch:o}}if(o.tabIcon!=null&&!l(o.tabIcon))return c(`Invalid tab icon preference.`,`rejected`);let p=Object.fromEntries(Object.entries(o).flatMap(([e,t])=>v(e)?[[y[e],t]]:[])),g=await D(e,{entries:p,...o.background===void 0?{}:{expectedEntries:{[y.background]:a}}});return g.status===`ok`?{ok:!0,value:g,refresh:{ok:!0},batch:o}:c(`Profile preferences are unavailable.`,g.status===`conflict`?`conflict`:`rejected`)}catch(e){let t=e instanceof _&&(e.gatewayCode===`INVALID_REQUEST`||e.gatewayCode===`FORBIDDEN`);return c(w(e),t?`rejected`:`error`)}finally{d&&k(e)}}async function L(e,t){let n=await M(e,t,{keys:d});return n.status===`ok`?p(n.entries):null}async function R(e,t,n,r,i,a){if(a!==i.requestId)return!1;let o=()=>a===i.requestId&&(r?.isCurrent()??!0),s=await L(e,t);return!o()||!s?!1:(i.appearance={profileId:t,scope:n,prefs:s},!0)}function z(){return(z=e((()=>{c(),x(),a(),g(),C(),T(),o(),u(),j(),E(),N(),n()})))()}export{z as n,P as r,F as t};