openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
2 lines • 60.3 kB
JavaScript
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./control-ui-connection-D5QrEAFW.css","./control-ui-boot-shared-styles-BorAdMVO.css"])))=>i.map(i=>d[i]);
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{$i as t,At as n,Ho as r,Oa as i,Ot as a,Qi as o,Qt as s,Sn as c,Tt as l,Xi as u,Xt as d,Yi as f,Zi as p,bn as m,bt as h,jt as g,ka as _,kt as v,lu as ee,nu as y,qo as te,sa as b,uu as x,va as ne,ya as S}from"./control-ui-connection-Bfj9beF_.js";import{A_ as C,B_ as w,Ck as T,Cp as re,Dp as ie,Ep as ae,IT as oe,Ik as se,M_ as ce,N_ as le,Oy as ue,QC as de,Qv as fe,RT as pe,Rc as me,U_ as he,Vk as ge,W_ as _e,XC as ve,ZC as ye,_D as be,_j as xe,aj as Se,dj as E,ej as Ce,fT as we,gj as Te,hD as Ee,hj as De,ir as Oe,j_ as ke,kk as Ae,ky as je,l as Me,mD as Ne,mT as Pe,mj as D,pT as Fe,pj as O,rj as Ie,rr as Le,tj as Re,ty as ze,u as Be,xp as Ve,xv as He,zc as Ue}from"./control-ui-boot-shared-DFTSUQQ0.js";import{$ as We,B as k,C as Ge,Ct as A,F as j,I as M,L as Ke,N as qe,O as N,Rt as P,S as F,St as I,U as L,_t as Je,a as Ye,d as R,f as z,g as B,gt as V,j as H,l as U,s as Xe,u as W,w as G,x as K,yt as Ze}from"./solid-runtime-C416s-HC.js";import{n as Qe,r as $e}from"./wizard-step-controls-DyqGnMlL.js";import{n as et,t as tt}from"./en-route-subtitles-C2EbTkck.js";import{o as nt,r as rt}from"./settings-targets-BBXeSTMi.js";import{_ as it,a as q,c as at,d as J,h as ot,l as st,m as ct,n as lt,o as ut,p as Y,s as dt,v as X,y as Z}from"./settings-ui-Ck6BJLhD.js";import{n as ft,t as pt}from"./en-profile-DtSNp9HC.js";import{a as mt,i as ht,n as gt,r as _t,t as vt}from"./device-scope-upgrade-owner.runtime--H72L-0g.js";import{a as yt,o as bt}from"./route-chrome-7YRVJwhf.js";import{n as xt,t as St}from"./en-github-connections-Bhx11Hwa.js";import{n as Ct,t as wt}from"./domain-github-identity-CfyeKYmd.js";import{i as Tt,n as Et,o as Dt,r as Ot,s as kt,t as At}from"./github-identity-view-DhLXsci2.js";function jt(e){let t=e.phase===`connected`?e.selfUser?.id??null:null,n=e.phase===`connected`&&!!e.hello?.auth&&a(e.hello?.auth??null);return{profileId:t,canRead:n,canAdmin:n&&l(e.hello?.auth??null)}}function Mt(){let e=Re(),t=le(e.gateway),n=Ue(e.agents),r=ke(e.settingsAgentSelection),[i,o]=k(`personal`),[s,c]=k(!1),u=null,d=0,f=!1,p=!1,m=null,h=()=>c(!1),g=wt({authorizationSucceeded:h}),_=wt({authorizationSucceeded:h,runExternalMutation:(t,n)=>e.runtimeConfig.runExternalMutation(t,n)}),v=()=>{if(!u)return;let t={client:u.client,connected:u.phase===`connected`&&u.selfUser!==void 0,permissionsReady:u.phase===`connected`&&!!u.hello,clientRevision:d};g.sync({...t,target:m?{kind:`personal`,profileId:m}:null,statusReadable:f&&m!==null,authorizable:f&&m!==null,configurable:!1});let n=e.settingsAgentSelection.state.selectedId;_.sync({...t,target:n?{kind:`shared`,scope:`system`,profileId:m,agentId:n,config:se(e.runtimeConfig.state)}:null,statusReadable:p,authorizable:p,configurable:p}),g.ensureVerified(),_.ensureVerified()},ee=t=>{let n=!u||u.client!==t.client||t.phase===`connected`&&t.selfUser!==void 0&&m!==(t.selfUser?.id??null),r=!u||u.client!==t.client||u.phase!==t.phase||u.hello!==t.hello||u.selfUser===void 0!=(t.selfUser===void 0)||t.selfUser!==void 0&&m!==(t.selfUser?.id??null);u=t,m=t.phase===`connected`&&t.selfUser!==void 0||n?t.selfUser?.id??null:m;let i=f,s=p;(t.phase===`connected`||n)&&(f=!!t.hello?.auth&&a(t.hello?.auth??null),p=f&&l(t.hello?.auth??null)),r&&(d+=1),(n||i&&!f||s&&!p)&&(c(!1),o(m?`personal`:`system`)),v(),p&&e.runtimeConfig.ensureLoaded()};V(()=>{let t=[e.gateway.subscribe(ee),e.agents.subscribe(v),e.settingsAgentSelection.subscribe(v),e.runtimeConfig.subscribe(v)];return ee(e.gateway.snapshot),()=>t.forEach(e=>e())});let y=j(()=>{let e=t.read().snapshot,i=g.read(),a=_.read(),o=i.personal,c=r.read().state.selectedId,l=n.read().agentsList?.agents?.find(e=>e.id===c),u=o?.state===`connected`,d=o?.state===`unavailable`||o?.refreshState===`expired`||o?.refreshState===`failed`;return{account:o,agentId:c,agent:l,connected:u,reconnectRequired:d,profileId:m,canRead:f,canAdmin:p,systemIdentity:a.status?.selected.identity??i.system,effective:a.status?.effective??null,locked:e.phase!==`connected`||e.selfUser===void 0||i.loading||a.loading||i.authorizationActive||a.authorizationActive||i.busy||a.busy,showSetup:s()||i.authorizationActive||a.authorizationActive,personalLabel:D(m?d?`githubConnections.reconnectRequired`:u?`githubConnections.connected`:`githubConnections.disconnected`:`githubConnections.signInRequired`)}}),b=g.read,x=_.read,ne=()=>i()===`personal`?g:_,S=t=>{let n=jt(e.gateway.snapshot);y().locked||(t===`personal`?!n.profileId||!n.canRead:!n.canAdmin)||(o(t),c(!0))},C=()=>{g.verify(),_.verify()};var w=It(),T=w.firstChild,re=T.firstChild,ie=re.nextSibling;return w._$owner=P(),R(T,H(Y,{get title(){return D(`githubConnections.title`)},get description(){return D(`githubConnections.description`)},get actions(){return z(()=>!!(y().canRead&&(y().profileId||y().canAdmin)))()?[(()=>{var e=Q();return e._$$click=()=>S(y().profileId?`personal`:`system`),R(e,()=>D(`githubConnections.manage`)),U(()=>y().locked||!y().profileId&&!x().status,t=>{B(e,`disabled`,t)}),e})(),(()=>{var e=Q();return e._$$click=C,R(e,()=>D(`agentTools.githubVerify`)),U(()=>y().locked,t=>{B(e,`disabled`,t)}),e})()]:void 0},get children(){return[(()=>{var e=Nt();return R(e,H(J,{get title(){return D(`githubConnections.mine`)},get description(){return z(()=>!!y().profileId)()?[z(()=>z(()=>!!y().account?.account)()?`@${y().account?.account?.login} · `:``),z(()=>D(`githubConnections.personalDescription`))]:D(`githubConnections.unboundDescription`)},get control(){return[z(()=>z(()=>!(!y().profileId||y().account))()?H(Dt,{get request(){return b()}}):H(ot,{get kind(){return z(()=>!!y().reconnectRequired)()?`warn`:y().connected?`ok`:`muted`},get label(){return y().personalLabel}})),z(()=>z(()=>!!(y().profileId&&y().canRead&&y().account))()?(()=>{var e=Q();return e._$$click=()=>S(`personal`),R(e,()=>D(y().connected?`githubConnections.changeMine`:`githubConnections.connectMine`)),U(()=>y().locked,t=>{B(e,`disabled`,t)}),e})():void 0)]}})),e})(),(()=>{var e=Pt();return R(e,H(J,{get title(){return D(`githubConnections.system`)},get description(){return[z(()=>z(()=>!!y().systemIdentity?.account)()?`@${y().systemIdentity?.account?.login} · `:``),z(()=>D(`githubConnections.systemDescription`))]},get control(){return[H(Tt,{get identity(){return y().systemIdentity},get request(){return z(()=>!!y().canAdmin)()?x():b()}}),z(()=>z(()=>!!y().canAdmin)()?(()=>{var e=Q();return e._$$click=()=>S(`system`),R(e,()=>D(`githubConnections.changeSystem`)),U(()=>y().locked||!x().status,t=>{B(e,`disabled`,t)}),e})():H(X,{get value(){return D(`githubConnections.adminManaged`)}}))]}})),e})(),z(()=>z(()=>!!(y().canAdmin&&y().agentId))()?(()=>{var t=Lt();return R(t,H(J,{get title(){return D(`githubConnections.agentFor`,{agent:y().agent?.identity?.name??y().agent?.name??y().agentId})},get description(){return[z(()=>z(()=>!!y().effective?.account)()?`@${y().effective?.account?.login} · `:``),z(()=>z(()=>!!y().effective)()?D(y().effective?.source===`agent-override`?`githubConnections.agentOverride`:`githubConnections.system`):``),Rt(),z(()=>D(`githubConnections.agentDescription`))]},get control(){return[H(Tt,{get identity(){return y().effective},get request(){return x()}}),(()=>{var t=Q();return t._$$click=()=>e.navigate(`agents`,{pathname:te(y().agentId,`tools`,e.basePath)}),R(t,()=>D(`githubConnections.viewAgent`)),t})()]}})),t})():void 0),H(At,{get error(){return b().error??x().error},get completion(){return b().completion},get secondaryCompletion(){return x().completion},get control(){var e=Q();return e._$$click=C,R(e,()=>D(`common.retry`)),U(()=>y().locked,t=>{B(e,`disabled`,t)}),e}}),z(()=>z(()=>!!y().showSetup)()?(()=>{var e=zt(),t=e.firstChild,n=t.nextSibling,r=n.nextSibling;return R(e,H(J,{get title(){return D(`githubConnections.purpose`)},get control(){return z(()=>!!(y().profileId&&y().canAdmin&&x().status))()?H(ct,{get value(){return i()},get options(){return[{value:`personal`,label:D(`githubConnections.forMe`)},{value:`system`,label:D(`githubConnections.forSystem`)}]},get disabled(){return y().locked},get ariaLabel(){return D(`githubConnections.purpose`)},onChange:S}):H(X,{get value(){return D(i()===`personal`?`githubConnections.forMe`:`githubConnections.forSystem`)}})}}),t),R(e,H(Et,{get identity(){return ne()}}),n),R(e,(()=>{var e=z(()=>!y().locked);return()=>e()?H(J,{get title(){return D(`githubConnections.purposeHint`)},get control(){var e=Q();return e._$$click=()=>{c(!1),ne().hidePatFallback()},R(e,()=>D(`common.close`)),e}}):void 0})(),r),e})():void 0),(()=>{var e=Ft(),t=e.firstChild,n=t.nextSibling;return R(t,()=>D(`githubConnections.usage`)),R(n,()=>D(`githubConnections.usageDescription`)),R(e,H(Ot,{get identity(){return y().systemIdentity}}),null),e})(),z(()=>z(()=>!!(y().canAdmin&&x().status?.selected.configured))()?H(J,{get title(){return D(`agentTools.githubUseNativeNewRuns`)},get description(){return D(`agentTools.githubSystemMutationHint`)},get control(){var e=Q();return e._$$click=()=>void _.inherit(),R(e,()=>D(`agentTools.githubUseNativeNewRuns`)),U(()=>y().locked,t=>{B(e,`disabled`,t)}),e}}):void 0)]}}),re),R(T,(()=>{var e=z(()=>!!(y().profileId&&y().canRead&&y().account&&y().account?.state!==`disconnected`));return()=>e()?H(Y,{danger:!0,get children(){return H(J,{get title(){return D(`githubConnections.disconnectMine`)},get description(){return D(`githubConnections.disconnectDescription`)},get control(){var e=Q();return e._$$click=()=>void g.disconnect(),R(e,()=>D(`githubConnections.disconnectMine`)),U(()=>y().locked,t=>{B(e,`disabled`,t)}),e}})}}):void 0})(),ie),U(()=>rt.githubConnections,e=>{B(T,`id`,e)}),w}var Nt,Pt,Ft,It,Q,Lt,Rt,zt;function Bt(){return(Bt=e((()=>{W(),L(),r(),g(),Z(),St(),ge(),C(),Ce(),me(),Ct(),E(),nt(),kt(),Nt=K(`<div data-github-connection=personal>`),Pt=K(`<div data-github-connection=system>`),Ft=K(`<details class="settings-row settings-row--stacked"><summary class=settings-row__title></summary><div class=settings-row__desc>`),It=K(`<openclaw-github-connections><div><!><!>`,1),Q=K(`<button class="btn btn--sm">`),Lt=K(`<div data-github-connection=agent>`),Rt=K(`<br>`),zt=K(`<div class=settings-subrows data-github-setup><!><!><!>`),xt(),Xe([`click`])})))()}function Vt(e){let t=j(()=>{let t=e();return{target:t.target,connected:t.connected,hello:t.hello}},{equals:(e,t)=>e.target===t.target&&e.connected===t.connected&&e.hello===t.hello}),n=j(()=>{let n=t(),r=j(()=>e().links),[i,a]=Ke(()=>r().map(({provider:e,authProfileId:t})=>({provider:e,authProfileId:t})),[],{key:`provider`}),o=j(()=>e().connectFlow),[s,c]=M(!1);return{...n,links:i,setLinks:a,flow:o,saving:s,setSaving:c}}),r=Ze(function*(t,n,r,i,a){let o=()=>{let n=e();return n.target===t.target&&n.connected===t.connected&&n.hello===t.hello&&n.generation===i&&n.actionRetired===r};try{o()&&(t.setSaving(!0),a&&t.setLinks(e=>{let t=a.kind===`select`?a.link.provider:a.provider,n=e.findIndex(e=>e.provider===t),r=e[n];a.kind===`unlink`?n!==-1&&e.splice(n,1):r?r.authProfileId=a.link.authProfileId:e.push(a.link)}),We(t.links),We(t.flow)),yield Promise.race([n,r]),o()&&(yield Promise.all([Je(t.links),Je(t.flow)]))}catch(t){if(o()){let n=e();n.error=d(t),n.publish()}}});async function i(t,i){let a=e(),o=n(),s=a.generation,c=t(a);if(!c||a.generation===s)return c;let l=a.generation,u=a.actionRetired;return await Promise.resolve(),r(o,c,u,l,i)}return{links:()=>n().links,flow:()=>n().flow(),saving:()=>n().saving(),updateAccount(t,n){let r=e().accounts.find(e=>e.authProfileId===n);return i(e=>e.updateAccount(t,n),t===`unlink`?{kind:t,provider:n}:t===`select`&&r?{kind:t,link:{provider:r.provider,authProfileId:n}}:void 0)},startConnect:()=>i(e=>e.startConnect()),answerStep:(e,t)=>i(n=>n.answerStep(e,t)),cancel:()=>i(e=>e.connectStatus(`cancel`))}}function Ht(){return(Ht=e((()=>{L(),s()})))()}function Ut(e){let t=URL.parse(e);return t?`${t.origin}${t.pathname}`:D(`profilePage.modelAccounts.gatewayUnavailable`)}function Wt(e){let t=()=>e.readState(),n=()=>e.row.kind===`linked`,r=()=>e.row.kind===`linked`?e.row.link:e.row.account,i=()=>e.row.kind===`linked`?t().accounts.find(e=>e.authProfileId===r().authProfileId):e.row.account,a=()=>i()?.label??D(`profilePage.modelAccounts.gatewayAccount`),o=()=>ie(r().provider),s=()=>D(n()?`profilePage.modelAccounts.unlinkAction`:`profilePage.modelAccounts.selectAction`);return H(J,{get title(){return[(()=>{var e=Zt();return R(e,a),e})(),` `,(()=>{var e=Qt();return R(e,o),e})()]},get description(){return[z(()=>z(()=>e.row.kind===`linked`)()?D(`profilePage.modelAccounts.linkedDescription`):D(`profilePage.modelAccounts.authTypes.${e.row.account.authType}`)),H(N,{get when(){return z(()=>!!i())()?t().accounts.some(e=>e.authProfileId!==r().authProfileId&&e.provider===r().provider&&e.label===a()):i()},get children(){return[` `,(()=>{var e=$t();return R(e,()=>r().authProfileId),e})()]}})]},get control(){return[H(N,{get when(){return n()},get children(){return H(ot,{kind:`ok`,get label(){return D(`profilePage.modelAccounts.linkedStatus`)}})}}),(()=>{var c=en();return c._$$click=()=>{n()?e.actions.updateAccount(`unlink`,r().provider):e.actions.updateAccount(`select`,r().authProfileId)},R(c,s),U(()=>({e:!!n(),t:!n(),a:n()?void 0:r().authProfileId,o:n()?`${s()}: ${o()} · ${i()?.label??r().authProfileId}`:`${s()}: ${o()} · ${a()} (${r().authProfileId})`,i:e.pending||e.actions.saving()||t().busy}),({e,t,a:n,o:r,i},a)=>{e!==a?.e&&c.classList.toggle(`profile-auth-link-unlink`,e),t!==a?.t&&c.classList.toggle(`profile-auth-account-select`,t),n!==a?.a&&B(c,`data-auth-profile-id`,n),r!==a?.o&&B(c,`aria-label`,r),i!==a?.i&&B(c,`disabled`,i)}),c})()]}})}function Gt(e){let t=()=>e.readState(),n=()=>t().signIn,r=()=>n()?.providers.find(e=>e.id===n()?.provider);var i=nn(),a=i.firstChild,o=a.nextSibling,s=o.nextSibling,c=s.firstChild;return R(i,H(he,{get params(){return{label:D(`profilePage.modelAccounts.provider`),className:`profile-auth-provider`,value:n()?.provider||null,options:n()?.providers.map(e=>({value:e.id,label:e.label}))??[],disabled:e.pending||t().busy,renderLeading:e=>H(Ve,{get provider(){return e.value}}),onChange:e=>t().selectProvider(e)}}}),a),R(i,H(N,{get when(){return r()},get children(){return H(he,{get params(){return{label:D(`profilePage.modelAccounts.method`),className:`profile-auth-method`,value:n()?.method||null,options:r()?.methods.map(e=>({value:e.id,label:e.label,description:e.hint}))??[],disabled:e.pending||t().busy,onChange:e=>t().selectMethod(e)}}})}}),o),R(i,H(N,{get when(){return z(()=>!(e.pending||t().busy||t().error))()?n()?.providers.length===0:!e.pending&&!t().busy&&!t().error},get children(){var e=tn();return R(e,()=>D(`profilePage.modelAccounts.noMethods`)),e}}),s),R(s,()=>e.cancel,c),c._$$click=()=>void e.actions.startConnect(),R(c,()=>D(`profilePage.modelAccounts.connectAction`)),U(()=>e.pending||t().busy||!n()?.method,e=>{B(c,`disabled`,e)}),i}function Kt(e){let t=()=>e.readState();return H(N,{get when(){return t().statusUnavailable||e.pending},get children(){var n=rn();return n._$$click=()=>e.onCheck(),R(n,()=>D(`profilePage.modelAccounts.checkStatusAction`)),U(()=>e.pending||t().cancelBusy,e=>{B(n,`disabled`,e)}),n}})}function qt(e){let t=()=>e.readState(),n=()=>t().signIn,r=()=>n()?.providers.find(e=>e.id===n()?.provider),i=()=>e.actions.flow(),a=j(()=>t().catalogReceipt),o=qe(()=>a().result.then(e=>{if(e)throw Error(e)})),s=j(()=>t().statusReceipt),c=qe(()=>s().result.then(e=>{if(e)throw Error(e)})),l=()=>(o(),null),u=()=>(c(),null),d=()=>(()=>{var n=an();return n._$$click=()=>{i()?e.actions.cancel():t().closeSignIn()},R(n,()=>D(`profilePage.modelAccounts.cancelAction`)),U(()=>t().cancelBusy,e=>{B(n,`disabled`,e)}),n})();return H(N,{get when(){return n()},get children(){return H(J,{stacked:!0,get title(){return z(()=>!!i())()?i()?.step?.title??r()?.label??D(`profilePage.modelAccounts.connectAction`):D(`profilePage.modelAccounts.addAccount`)},get control(){return H(N,{get when(){return i()},get fallback(){return H(F,{fallback:()=>H(Gt,{get readState(){return e.readState},get actions(){return e.actions},pending:!1,get cancel(){return d()}}),get children(){return H(G,{get fallback(){return H(Gt,{get readState(){return e.readState},get actions(){return e.actions},pending:!0,get cancel(){return d()}})},get children(){return[z(()=>l()),H(Gt,{get readState(){return e.readState},get actions(){return e.actions},get pending(){return I(o)},get cancel(){return d()}})]}})}})},get children(){var n=on(),r=n.firstChild,a=r.nextSibling;return R(n,H(N,{get when(){return i()?.step},get fallback(){return[(()=>{var e=sn();return R(e,()=>D(`common.loading`)),e})(),z(d)]},children:n=>H(Qe,{get step(){return n()},get value(){return t().stepValue},get busy(){return t().busy},inputId:`profile-account-auth-answer`,get leadingAction(){return d()},onValueChange:e=>t().setStepValue(n().id,e),onAnswer:t=>void e.actions.answerStep(n().id,t)})}),r),R(n,H(F,{fallback:(n,r)=>H(Kt,{get readState(){return e.readState},get actions(){return e.actions},pending:!1,onCheck:()=>{t().connectStatus(`status`),r()}}),get children(){return H(G,{get fallback(){return H(Kt,{get readState(){return e.readState},get actions(){return e.actions},pending:!0,onCheck:()=>void t().connectStatus(`status`)})},get children(){return[z(()=>u()),H(Kt,{get readState(){return e.readState},get actions(){return e.actions},get pending(){return I(c)},onCheck:()=>void t().connectStatus(`status`)})]}})}}),a),n}})}})}})}function Jt(e){let t=()=>e.readState();return[H(N,{get when(){return e.actions.links().length},get fallback(){return H(q,{get message(){return D(`profilePage.modelAccounts.empty`)}})},get children(){return H(Ge,{get each(){return e.actions.links()},keyed:e=>e.authProfileId,children:t=>H(Wt,{get readState(){return e.readState},get actions(){return e.actions},get pending(){return e.pending},get row(){return{kind:`linked`,link:t()}}})})}}),H(Ge,{get each(){return t().accounts.filter(t=>!e.actions.links().some(e=>e.authProfileId===t.authProfileId))},keyed:e=>e.authProfileId,children:t=>H(Wt,{get readState(){return e.readState},get actions(){return e.actions},get pending(){return e.pending},get row(){return{kind:`saved`,account:t()}}})}),H(N,{get when(){return!!t().nextCursor},get children(){return H(J,{get title(){return D(`profilePage.modelAccounts.savedAccounts`)},get control(){var n=cn();return n._$$click=()=>void t().loadAccounts(t().nextCursor),R(n,()=>D(`profilePage.modelAccounts.loadMore`)),U(()=>e.pending||e.actions.saving()||t().busy,e=>{B(n,`disabled`,e)}),n}})}})]}function Yt(e){let t=()=>e.readState();return[H(qt,{get readState(){return e.readState},get actions(){return e.actions}}),H(N,{get when(){return t().target?.canAdmin},get children(){return H(J,{get title(){return D(`profilePage.modelAccounts.inputLabel`)},get description(){return D(`profilePage.modelAccounts.inputDescription`)},stackedOnNarrow:!0,get control(){var n=fn(),r=n.firstChild,i=r.nextSibling;return n.addEventListener(`submit`,n=>{n.preventDefault(),e.actions.updateAccount(`link`,t().linkDraft.trim())}),r._$$input=e=>t().setLinkDraft(e.currentTarget.value),R(i,()=>D(`profilePage.modelAccounts.linkAction`)),U(()=>({e:D(`profilePage.modelAccounts.inputLabel`),t:t().linkDraft,a:D(`profilePage.modelAccounts.inputPlaceholder`),o:e.actions.saving()||t().busy,i:t().busy||!t().linkDraft.trim()}),({e,t,a:n,o:a,i:o},s)=>{e!==s?.e&&B(r,`aria-label`,e),r.value=t??``,n!==s?.a&&B(r,`placeholder`,n),a!==s?.o&&B(r,`disabled`,a),o!==s?.i&&B(i,`disabled`,o)}),n}})}}),H(N,{get when(){return t().notice},get children(){var e=ln(),n=e.firstChild;return R(n,()=>D(`profilePage.modelAccounts.notices.${t().notice}`)),e}}),H(N,{get when(){return t().error},get children(){var e=un(),n=e.firstChild;return R(n,()=>t().error),e}}),H(N,{get when(){return t().inventoryError},get children(){var e=dn(),n=e.firstChild,r=n.nextSibling;return R(e,()=>D(`profilePage.modelAccounts.inventoryFailed`),n),R(e,()=>t().inventoryError,r),e}})]}function Xt(e){let t=()=>e.readState(),r=()=>t().props.target.read().gateway,i=()=>r().selfUser?.id===t().props.target.read().identityId?r().selfUser:null,a=()=>i()||t().target?t().props.personLabel||i()?.name||i()?.email||D(`profilePage.modelAccounts.currentPerson`):null,o=()=>i()?n(r().hello?.auth??null)?`profile`:`write`:`identity`;return H(Y,{get title(){return D(`profilePage.modelAccounts.title`)},get description(){return D(`profilePage.modelAccounts.description`)},get actions(){return H(N,{get when(){return t().target},get children(){return[H(N,{get when(){return!t().signIn},get children(){var n=pn();return n._$$click=()=>t().openSignIn(),R(n,()=>D(`profilePage.modelAccounts.addAccount`)),U(()=>e.actions.saving()||t().busy,e=>{B(n,`disabled`,e)}),n}}),(()=>{var e=mn();return e._$$click=()=>void t().loadAccounts(),R(e,()=>D(`common.refresh`)),U(()=>!t().connected||t().inventoryLoading,t=>{B(e,`disabled`,t)}),e})()]}})},get children(){return[H(J,{get title(){return D(`profilePage.modelAccounts.gateway`)},stackedOnNarrow:!0,get control(){return H(X,{mono:!0,get value(){return Ut((t().target?.client??r().client).gatewayUrl)}})}}),H(J,{get title(){return D(`profilePage.modelAccounts.person`)},stackedOnNarrow:!0,get control(){return H(X,{get value(){return a()??D(`profilePage.modelAccounts.noPerson`)}})}}),H(J,{get title(){return D(`profilePage.modelAccounts.scope`)},get description(){return D(`profilePage.modelAccounts.personalDescription`)},get control(){return H(X,{get value(){return D(`profilePage.modelAccounts.personal`)}})}}),H(N,{get when(){return t().target},get fallback(){return H(J,{get title(){return D(`profilePage.modelAccounts.signInUnavailable`)},get description(){return D(`profilePage.modelAccounts.unavailable.${o()}`)},stacked:!0,get control(){return[(()=>{var e=en();return e._$$click=()=>t().context.navigate(`connection`),R(e,()=>D(`profilePage.modelAccounts.connectionSettings`)),e})(),H(lt,{url:`https://docs.openclaw.ai/concepts/multi-user#per-person-model-accounts`})]}})},get children(){return[z(()=>e.inventory),H(Yt,{get readState(){return e.readState},get actions(){return e.actions}})]}})]}})}var Zt,Qt,$t,en,tn,nn,rn,an,on,sn,cn,ln,un,dn,fn,pn,mn;function hn(){return(hn=e((()=>{W(),L(),g(),ae(),_e(),re(),Z(),$e(),Le(),E(),Zt=K(`<span class=model-accounts__id>`),Qt=K(`<span class=model-accounts__provider>`),$t=K(`<code>`),en=K(`<button type=button class="btn btn--sm">`),tn=K(`<span>`),nn=K(`<div class=model-accounts-choice><!><!><div class=wizard-step__actions><button type=button class="btn btn--sm primary profile-auth-connect-start">`),rn=K(`<button type=button class="btn btn--sm profile-auth-connect-check">`),an=K(`<button type=button class="btn btn--sm profile-auth-connect-cancel">`),on=K(`<div class=model-accounts-flow><!><!>`),sn=K(`<span role=status>`),cn=K(`<button type=button class="btn btn--sm profile-auth-accounts-more">`),ln=K(`<div class="settings-row model-accounts-notice"role=status><span class=settings-row__desc>`),un=K(`<div class="settings-row model-accounts-error"role=alert><span class=settings-row__desc>`),dn=K(`<div class="settings-row model-accounts-error"role=alert> <!>`),fn=K(`<form class=model-accounts-form><input class="settings-input profile-auth-link-input"type=text><button type=submit class="btn btn--sm profile-auth-link-submit">`),pn=K(`<button type=button class="btn btn--sm primary profile-auth-add-account">`),mn=K(`<button type=button class="btn btn--sm profile-auth-accounts-refresh">`),O(Oe),Xe([`click`,`input`])})))()}var gn;function _n(){return(_n=e((()=>{g(),s(),E(),gn=class{get actionRetired(){return this.actionLifetime.promise}retireAction(){this.actionLifetime.resolve(),this.actionLifetime=Promise.withResolvers()}constructor(e,t,n){this.context=e,this.props=t,this.publish=n,this.links=[],this.accounts=[],this.inventoryLoading=!1,this.inventoryError=null,this.inventoryReceipt={result:Promise.resolve(null)},this.action=null,this.error=null,this.notice=null,this.linkDraft=``,this.signIn=null,this.connectFlow=null,this.statusUnavailable=!1,this.catalogReceipt={result:Promise.resolve(null)},this.statusReceipt={result:Promise.resolve(null)},this.actionLifetime=Promise.withResolvers(),this.target=null,this.generation=0,this.inventoryRequest=0,this.pollTimer=null,this.connected=!0}dispose(){this.actionLifetime.resolve(),this.connected=!1,this.generation+=1,this.target=null,this.stopPoll()}applySnapshot({gateway:e,identityId:t,profileId:r}){let i=e.phase===`connected`,a=i&&e.selfUser!==void 0,o=a!==this.connected||a&&this.hello!==e.hello,s=i?n(e.hello?.auth??null):this.target!==null,c=s?e.client:null,u=a?e.selfUser?.id??null:this.target?.identityId??null,d=c&&u===t?r:null,f=i?s&&l(e.hello?.auth??null):this.target?.canAdmin??!1,p=this.target?.client===c&&this.target?.identityId===u&&this.target?.profileId===d&&this.target?.canAdmin===f;this.connected=a,this.hello=e.hello,(!p||o)&&(this.retireAction(),this.generation+=1,this.stopPoll(),this.inventoryRequest+=1,this.inventoryLoading=!1,this.inventoryError=null,this.inventoryReceipt={result:Promise.resolve(null)},this.catalogReceipt={result:Promise.resolve(null)},this.statusReceipt={result:Promise.resolve(null)},this.action=null,this.error=null,this.notice=null,p||(this.target=c&&u&&d?{client:c,identityId:u,profileId:d,canAdmin:f}:null,this.links=[],this.accounts=[],this.nextCursor=void 0,this.linkDraft=``,this.signIn=null,this.connectFlow=null,this.stepValue=void 0,this.statusUnavailable=!1),this.publish(),this.target&&a&&(this.loadAccounts(),this.schedulePoll()))}applyLinks(e){this.links=e,this.accounts=this.accounts.map(t=>({...t,selected:e.some(e=>e.authProfileId===t.authProfileId)}))}loadAccounts(e){let t=this.target;if(!t||!this.connected)return Promise.resolve();let n=++this.inventoryRequest;this.inventoryLoading=!0,this.inventoryError=null;let r=this.readAccounts(t,n,e);return this.inventoryReceipt={result:r},this.publish(),r.then(()=>{})}async readAccounts(e,t,n){let r=()=>this.connected&&this.target===e&&t===this.inventoryRequest;try{let t=await e.client.request(`users.listModelAccounts`,{profileId:e.profileId,...n?{cursor:n}:{}});return r()&&(this.accounts=n?[...this.accounts,...t.accounts]:t.accounts,this.nextCursor=t.nextCursor,this.applyLinks(t.links)),null}catch(e){return r()?(this.inventoryError=d(e),this.inventoryError):null}finally{r()&&(this.inventoryLoading=!1,this.publish())}}isCurrent(e,t){return this.connected&&this.target===e&&this.generation===t}async runAction(e,t,n){let r=this.target;if(!r||!this.connected||this.action&&(e!==`cancel`||this.action!==`answer`))return;this.retireAction();let i=++this.generation;this.stopPoll(),this.action=e,this.error=null,this.notice=null,this.statusUnavailable=!1,this.publish();try{let e=await t(r);this.isCurrent(r,i)&&n(e)}catch(e){this.isCurrent(r,i)&&(this.error=d(e,D(`profilePage.modelAccounts.actionFailed`)))}finally{this.isCurrent(r,i)&&(this.action=null,this.schedulePoll(this.connectFlow?.step?2e3:0),this.publish())}}updateAccount(e,t){if(e===`link`&&(!t||!this.target?.canAdmin))return;let n={link:`users.linkAuthProfile`,unlink:`users.unlinkAuthProfile`,select:`users.selectModelAccount`};return this.runAction(`request`,r=>r.client.request(n[e],{profileId:r.profileId,...e===`unlink`?{provider:t}:{authProfileId:t}}),t=>{this.applyLinks(t.links),e!==`select`&&(this.linkDraft=``),this.notice=e===`unlink`?`cleared`:`selected`,this.loadAccounts()})}openSignIn(){this.signIn={providers:[],provider:``,method:``};let e=this.runAction(`request`,e=>e.client.request(`users.authConnect.catalog`,{profileId:e.profileId}),e=>{this.signIn={providers:e.providers,provider:``,method:``}}),t=this.generation;this.catalogReceipt={result:e.then(()=>this.generation===t?this.error:null)},this.publish()}selectProvider(e){let t=this.signIn,n=t?.providers.find(t=>t.id===e);t&&n&&!this.action&&!this.connectFlow&&(this.signIn={...t,provider:e,method:n.methods.length===1?n.methods[0]?.id??``:``},this.publish())}startConnect(){let e=this.signIn;if(e?.providers.some(t=>t.id===e.provider&&t.methods.some(t=>t.id===e.method)))return this.runAction(`request`,t=>t.client.request(`users.authConnect.start`,{profileId:t.profileId,provider:e.provider,method:e.method}),e=>{this.connectFlow=e,this.stepValue=void 0})}applyConnectStatus(e){e.status===`pending`?(e.error&&(this.error=d(e.error)),this.connectFlow&&=(this.connectFlow.step?.id!==e.step?.id&&(this.stepValue=e.step?.sensitive?void 0:e.step?.initialValue),{...this.connectFlow,step:e.step})):(this.error=null,this.statusUnavailable=!1,this.stopPoll(),this.signIn=null,this.connectFlow=null,this.stepValue=void 0,e.status===`failed`?this.error=D(`profilePage.modelAccounts.connectErrors.${e.reason}`):(e.status===`connected`&&(this.applyLinks(e.links),this.loadAccounts()),this.notice=e.status))}connectStatus(e){let t=this.connectFlow;if(!t)return;let n=this.runAction(e===`status`?`request`:e,n=>n.client.request(`users.authConnect.${e}`,{profileId:n.profileId,connectId:t.connectId}),e=>this.applyConnectStatus(e));if(e===`status`){let e=this.generation;this.statusReceipt={result:n.then(()=>this.generation===e?(this.error&&this.connectFlow&&(this.statusUnavailable=!0,this.publish()),this.error):null)},this.publish()}return n}answerStep(e,t){let n=this.connectFlow,r=n?.step;if(this.connected&&n&&r&&r.id===e&&r.type!==`progress`)return r.sensitive&&(this.stepValue=void 0),this.runAction(`answer`,e=>e.client.request(`users.authConnect.answer`,{profileId:e.profileId,connectId:n.connectId,stepId:r.id,...t===void 0?{}:{value:t}}),e=>this.applyConnectStatus(e))}stopPoll(){this.pollTimer!==null&&(clearTimeout(this.pollTimer),this.pollTimer=null)}schedulePoll(e=2e3){this.stopPoll();let t=this.connectFlow;if(!this.connected||!t||!this.target||this.action)return;let n=Math.max(0,Math.min(e,t.expiresAtMs-Date.now()));this.pollTimer=setTimeout(()=>{this.pollTimer=null,this.pollStatus()},n)}async pollStatus(){let e=this.target,t=this.connectFlow,n=this.generation;if(this.connected&&e&&t&&!this.action)try{let r=await e.client.request(`users.authConnect.status`,{profileId:e.profileId,connectId:t.connectId});if(!this.isCurrent(e,n)||this.connectFlow?.connectId!==t.connectId)return;this.applyConnectStatus(r),this.publish(),this.connectFlow&&(Date.now()>=t.expiresAtMs?(this.statusUnavailable=!0,this.error=D(`profilePage.modelAccounts.statusTimedOut`),this.publish()):this.schedulePoll())}catch(t){this.isCurrent(e,n)&&(this.statusUnavailable=!0,this.error=d(t,D(`profilePage.modelAccounts.statusFailed`)),this.publish())}}get busy(){return!this.connected||this.inventoryLoading||this.action!==null}get cancelBusy(){return!this.connected||this.action!==null&&this.action!==`answer`}setLinkDraft(e){this.linkDraft=e,this.publish()}selectMethod(e){this.signIn&&!this.action&&!this.connectFlow&&(this.signIn={...this.signIn,method:e},this.publish())}closeSignIn(){!this.action&&!this.connectFlow&&(this.signIn=null,this.error=null,this.publish())}setStepValue(e,t){this.connectFlow?.step?.id===e&&(this.stepValue=t,this.publish())}}})))()}function vn(e){let t=Re(),n=new gn(t,e,()=>r.publish()),r=Te(n,e=>e),i=r.read,a=Vt(i),o=j(()=>i().target),s=j(()=>i().inventoryReceipt),c=qe(()=>s().result.then(e=>{if(e)throw Error(e)})),l=()=>(c(),null);V(()=>{let r=e.target,i=()=>{n.applySnapshot(r.read()),n.publish()},a=r.subscribe(i),o=t.gateway.subscribeEvents(e=>{pe(e)&&n.loadAccounts()});return i(),()=>{o(),a(),n.dispose()}});var u=yn();return u._$owner=P(),R(u,H(N,{get when(){return i().target||i().context.gateway.snapshot.phase===`connected`},get children(){return H(Xt,{readState:i,actions:a,get inventory(){return H(F,{fallback:()=>H(Jt,{readState:i,actions:a,pending:!1}),get children(){return H(G,{get on(){return A(o)},get fallback(){return H(Jt,{readState:i,actions:a,pending:!0})},get children(){return[z(()=>l()),H(Jt,{readState:i,actions:a,get pending(){return I(c)}})]}})}})}})}})),U(()=>a.saving()?`true`:`false`,e=>{B(u,`aria-busy`,e)}),u}var yn;function bn(){return(bn=e((()=>{W(),L(),Le(),oe(),Ce(),E(),De(),Ht(),hn(),_n(),yn=K(`<openclaw-model-accounts>`,1),O(Oe)})))()}var xn,Sn;function Cn(){return(Cn=e((()=>{_(),xn={profilePage:{personalInstructions:{signIn:`Sign in with your personal profile to edit your instructions. This requires operator.read or operator.sessions.read access.`,noAgents:`No agents are available on this connection.`,guidance:`{count} / 4,000 characters. Keep it brief: preferences, context, and working style.`,missing:`Your personal file will be created when you save.`,tooLong:`Shorten your instructions to 4,000 characters before saving.`,reload:`Reload`,dirty:`Unsaved changes`,saved:`Saved`,discard:`Discard your unsaved instructions and load the saved file?`,failureHint:`Your draft is unchanged. If the file changed elsewhere, copy your draft, then reload before saving again.`,contextChanged:`The returned file does not match this profile and agent. Reload before trying again.`}}},Sn=Object.assign(()=>{Object.assign(i.profilePage.personalInstructions,xn.profilePage.personalInstructions)},{catalog:xn})})))()}function wn(e){let t=Re(),[n,r]=k(0,{ownedWrite:!0}),[i,a]=k(null,{ownedWrite:!0}),o=j(()=>Promise.resolve(i())),[s,c]=M(),l=Ze(function*(e){c(e),yield e}),u=new Nn(t,()=>r(e=>e+1),e=>{a(e)}),f=()=>{let e=u.save();e&&setTimeout(()=>{u.available&&i()===e&&l(e).catch(()=>{})},0)},p=()=>(n(),u);V(()=>{let e=()=>u.syncContext(),n=[t.gateway.subscribe(e),t.agents.subscribe(e),t.settingsAgentSelection.subscribe(e)];return u.syncContext(),t.agents.ensureList(),()=>{n.forEach(e=>e()),u.dispose()}});function m(e){var t=An(),n=t.firstChild,r=n.nextSibling,a=r.firstChild,o=a.nextSibling;return R(t,H(N,{get when(){return z(()=>!!e.file)()?p().file:e.file},get children(){return[(()=>{var t=Tn();return t._$$input=e=>{u.draft=e.currentTarget.value,u.saved=!1,u.publish()},U(()=>({e:p().draft,t:e.pending,a:D(`profilePage.personalInstructions.title`)}),({e,t:n,a:r},i)=>{t.value=e??``,n!==i?.t&&B(t,`disabled`,n),r!==i?.a&&B(t,`aria-label`,r)}),t})(),(()=>{var e=En(),t=e.firstChild,n=t.nextSibling;return R(e,()=>D(`profilePage.personalInstructions.guidance`,{count:String(p().draft.length)}),t),R(e,(()=>{var e=z(()=>!!p().file?.missing);return()=>e()?` ${D(`profilePage.personalInstructions.missing`)}`:null})(),n),e})(),H(N,{get when(){return p().draft.length>4e3},get children(){var e=Dn();return R(e,()=>D(`profilePage.personalInstructions.tooLong`)),e}})]}}),n),R(t,H(N,{get when(){return e.error},get children(){var t=On(),n=t.firstChild,r=n.nextSibling;return R(t,()=>e.error,n),R(t,()=>D(`profilePage.personalInstructions.failureHint`),r),t}}),r),a._$$click=f,R(a,(()=>{var e=z(()=>s()===i());return()=>e()?D(`common.saving`):D(`common.save`)})()),R(r,H(N,{get when(){return e.error},get children(){var t=kn();return t._$$click=()=>u.reload(),R(t,()=>D(`profilePage.personalInstructions.reload`)),U(()=>e.pending,e=>{B(t,`disabled`,e)}),t}}),o),R(o,(()=>{var e=z(()=>!!p().dirty);return()=>e()?D(`profilePage.personalInstructions.dirty`):z(()=>!!p().saved)()?D(`profilePage.personalInstructions.saved`):null})()),U(()=>({e:e.pending?`true`:`false`,t:!p().file||!p().dirty||e.pending||p().draft.length>4e3||!p().agents.some(e=>e.id===p().agentId)}),({e,t:n},r)=>{e!==r?.e&&B(t,`aria-busy`,e),n!==r?.t&&B(a,`disabled`,n)}),t}var h=Mn();return h._$owner=P(),R(h,H(N,{get when(){return p().multipleProfiles},get children(){var e=jn();return R(e,H(Y,{get title(){return D(`profilePage.personalInstructions.title`)},get description(){return D(`profilePage.personalInstructions.description`)},get children(){return H(N,{get when(){return p().available},get fallback(){return H(q,{get message(){return D(`profilePage.personalInstructions.signIn`)}})},get children(){return H(N,{get when(){return p().agents.length},get fallback(){return H(q,{get message(){return D(`profilePage.personalInstructions.noAgents`)}})},get children(){return H(G,{get on(){return i()},get fallback(){return H(m,{get file(){return p().file},pending:!0})},get children(){return H(F,{fallback:e=>H(m,{get file(){return p().file},get error(){return d(e())}}),get children(){return H(m,{get file(){return o()},get pending(){return I(o)}})}})}})}})}})}})),U(()=>rt.personalInstructions,t=>{B(e,`id`,t)}),e}})),U(()=>e.hidden,e=>{B(h,`hidden`,e)}),h}var Tn,En,Dn,On,kn,An,jn,Mn,Nn;function Pn(){return(Pn=e((()=>{W(),L(),g(),Z(),Cn(),s(),Ce(),E(),nt(),Tn=K(`<textarea id=personal-instructions-content class="settings-input personal-instructions__editor"rows=7 aria-describedby=personal-instructions-guidance>`),En=K(`<div id=personal-instructions-guidance class=settings-row__desc><!><!>`),Dn=K(`<div role=alert>`),On=K(`<div class=personal-instructions__error role=alert> <!>`),kn=K(`<button class=btn>`),An=K(`<div class=personal-instructions><!><div class=personal-instructions__actions><button class=btn></button><span class=settings-row__desc role=status>`),jn=K(`<div>`),Mn=K(`<openclaw-personal-instructions>`,1),O(Sn),Nn=class{constructor(e,t,n){this.context=e,this.publish=t,this.presentFile=n,this.agentId=``,this.file=null,this.draft=``,this.busy=!1,this.saved=!1,this.client=null,this.profileId=null,this.connectionId=null,this.gatewayUrl=null,this.available=!1,this.multipleProfiles=!1,this.drafts=new Map}get agents(){return this.context.agents.state?.agentsList?.agents??[]}get dirty(){return this.file!==null&&this.draft!==this.file.content}dispose(){this.client=null,this.available=!1}syncContext(){let e=this.context.gateway.snapshot,t=e.phase===`connected`,n=e.selfUser?.id??this.profileId,r=this.context.gateway.connection.gatewayUrl,i=e.hello?.server?.connId??null;this.multipleProfiles=e.hello?.policy?.hasMultipleSessionSharingIdentities===!0;let a=t&&this.multipleProfiles&&!!e.selfUser?.id&&v(e.hello?.auth??null),o=n!==this.profileId||r!==this.gatewayUrl,s=o||e.client!==this.client||i!==this.connectionId||a!==this.available;s&&(this.client=e.client,this.connectionId=i,this.gatewayUrl=r,this.profileId=n,this.available=a,o&&(this.file=null,this.draft=``,this.agentId=``,this.drafts.clear()));let c=this.context.settingsAgentSelection.state.selectedId,l=this.agents.some(e=>e.id===c)?c:``,u=l!==this.agentId;if(u){this.dirty&&this.file?this.drafts.set(this.agentId,{file:this.file,content:this.draft}):this.drafts.delete(this.agentId),this.agentId=l;let e=this.drafts.get(l);this.drafts.delete(l),this.file=e?.file??null,this.draft=e?.content??``}(s||u)&&(this.busy=!1,this.saved=!1,this.presentFile(this.file)),this.available&&this.agentId&&!this.dirty&&(s||u)&&this.load(),this.publish()}load(){let e=this.client,t=this.agentId,n=this.profileId;e&&this.available&&t&&!this.busy&&this.requestFile(`load`,{agentId:t,profileId:n},()=>e.request(`users.personalFile.get`,{agentId:t}))}save(){let e=this.client,t=this.file;if(!e||!t||!this.available||this.busy||!this.dirty||t.agentId!==this.agentId||this.draft.length>4e3||!this.agents.some(e=>e.id===t.agentId))return;let n=this.draft;return this.requestFile(`save`,t,()=>e.request(`users.personalFile.set`,{agentId:t.agentId,content:n,expectedHash:t.hash}))}requestFile(e,t,n){let r=this.client,i=this.connectionId,a=this.draft,o=()=>this.available&&this.client===r&&this.connectionId===i&&this.agentId===t.agentId&&this.profileId===t.profileId;this.busy=!0,this.saved=!1;let s=(async()=>{try{let r=await n();if(!o())return null;if(r.agentId!==t.agentId||r.profileId!==t.profileId)throw Error(D(`profilePage.personalInstructions.contextChanged`));return this.file=r,this.draft===a&&(this.busy=!1,this.draft=r.content),this.drafts.delete(r.agentId),this.saved=e===`save`&&this.draft===r.content,r}catch(e){if(o())throw e;return null}finally{o()&&(this.draft===a&&(this.busy=!1),this.publish())}})();return s.catch(()=>{o()&&this.presentFile(s)}),this.presentFile(s),this.publish(),s}reload(){(!this.dirty||window.confirm(D(`profilePage.personalInstructions.discard`)))&&this.load()}},Xe([`input`,`click`])})))()}function Fn(e){let t=je,n=()=>({id:e.row.id,name:r(),avatar:c(e.row,e.identity),textAvatar:Ae(e.row,e.identity)}),r=()=>e.user?e.user.name?.trim()||e.user.email||D(`nav.owner`):e.identity?.name?.trim()||e.row.identity?.name?.trim()||e.row.name?.trim()||e.row.id,i=()=>e.user?e.user.email:`@${e.row.id}`;return H(ut,{get children(){var a=Ln(),o=a.firstChild,s=o.nextSibling,c=s.nextSibling,l=c.firstChild;return R(o,H(N,{get when(){return e.user},get fallback(){return H(fe,{get agent(){return n()}})},children:e=>(()=>{var t=Rn();return t._$owner=P(),U(()=>({...e(),name:r(),watchedSessions:[]}),e=>{t.user=e}),t})()})),R(s,r),R(c,H(N,{get when(){return i()},get children(){var e=In();return R(e,i),e}}),l),R(l,()=>t.read().brandName),a}})}var In,Ln,Rn;function zn(){return(zn=e((()=>{W(),L(),ze(),Z(),T(),w(),m(),E(),ue(),In=K(`<span class=profile-hero__email>`),Ln=K(`<section class=profile-hero><div class=profile-hero__avatar></div><div class=profile-hero__name></div><div class=profile-hero__handle><span class=profile-hero__badge>`),Rn=K(`<openclaw-viewer-avatar variant=profile>`,1)})))()}function Bn(e,t,n){return new Promise(r=>{e.toBlob(r,t,n)})}async function Vn(e){if(![`image/png`,`image/jpeg`,`image/webp`].includes(e.type))throw new $(`invalid-image`);if(e.size>Wn)throw new $(`source-too-large`);let t=URL.createObjectURL(e),n;try{n=new Image,n.decoding=`async`,n.src=t,await n.decode()}catch{throw new $(`invalid-image`)}finally{URL.revokeObjectURL(t)}let{naturalWidth:r,naturalHeight:i}=n;if(!Number.isFinite(r)||!Number.isFinite(i)||r<=0||i<=0)throw new $(`invalid-image`);let a=Math.min(r,i),o=Math.min(1,Hn/a),s=Math.max(1,Math.round(a*o)),c=document.createElement(`canvas`);c.width=s,c.height=s;let l=c.getContext(`2d`);if(!l)throw new $(`invalid-image`);l.drawImage(n,Math.max(0,Math.round((r-a)/2)),Math.max(0,Math.round((i-a)/2)),a,a,0,0,s,s);let u=e.type===`image/webp`?`image/webp`:`image/png`,d=await Bn(c,u,u===`image/webp`?.9:void 0);if((!d||d.type!==u||d.size>Un)&&(u=`image/webp`,d=await Bn(c,u,.82)),!d||d.type!==u)throw new $(`invalid-image`);if(d.size>Un)throw new $(`too-large`);let f=new Uint8Array(await d.arrayBuffer());return{mime:u,avatarBase64:h(f)}}var Hn,Un,Wn,$;function Gn(){return(Gn=e((()=>{Hn=512,Un=524288,Wn=10485760,$=class extends Error{constructor(e){super(e),this.code=e,this.name=`ProfileAvatarError`}}})))()}var Kn;function qn(){return(qn=e((()=>{o(),g(),we(),s(),E(),Ee(),Gn(),Me(),x(),Kn=class{constructor(e,t){this.context=e,this.invalidate=t,this.modelAccountsTarget={read:()=>({gateway:this.context.gateway.snapshot,identityId:this.selfUser?.id??null,profileId:this.ownProfile?.id??null}),subscribe:e=>(this.publishTarget=e,()=>{this.publishTarget=void 0})},this.selfUser=null,this.ownProfile=null,this.displayName=``,this.gitCoauthorEnabled=!0,this.prAttributionEnabled=!1,this.identityLoading=!1,this.identityBusy=null,this.identityError=null,this.client=null,this.connected=!1,this.identityReady=!1,this.connecting=!1,this.canRead=!1,this.canWrite=!1,this.connectionScopes=null,this.identityRequestId=0,this.identityScope={},this.presentationLifetime=Promise.withResolvers(),this.identityReceipt={result:Promise.resolve()}}publish(){this.invalidate(),this.publishTarget?.()}retirePresentation(){this.presentationLifetime.resolve(),this.presentationLifetime=Promise.withResolvers()}dispose(){this.publishTarget=void 0,this.retirePresentation(),this.identityRequestId+=1,this.client=null,this.connected=!1,this.identityReady=!1}applyGatewaySnapshot(e){let t=e.client!==this.client,n=e.phase===`connected`,r=n&&e.selfUser!==void 0,i=v(e.hello?.auth??null),a=n&&i,o=n!==this.connected||r!==this.identityReady||n&&this.hello!==e.hello,s=r?He({snapshotUser:e.selfUser}):t?null:this.selfUser,c=s?.id!==this.selfUser?.id||s?.identity?.id!==this.selfUser?.identity?.id,l=n&&this.canRead&&!i,u=t||c||l;this.client=e.client,this.connected=n,this.identityReady=r,this.hello=e.hello,this.connecting=e.phase===`connecting`||e.phase===`reconnecting`,this.canRead=n?i:!t&&this.canRead,this.canWrite=a&&r,this.connectionScopes=n||t?e.hello?.auth?.scopes??null:this.connectionScopes,this.selfUser=s,(u||o)&&(this.retirePresentation(),this.identityRequestId+=1,this.identityScope={},this.identityReceipt={result:Promise.resolve()},this.identityLoading=!1,this.identityBusy=null,this.identityError=null),u&&(this.ownProfile=null,this.displayName=``,this.gitCoauthorEnabled=!0,this.prAttributionEnabled=!1),this.publish(),r&&e.client&&((u||o)&&this.loadIdentity(),this.context.agents.ensureList().then(e=>{e&&this.context.agentIdentity.ensure([e.defaultId])}))}loadIdentity(){let e=this.client;if(!e||!this.identityReady||!this.canRead||this.identityLoading)return;let t=++this.identityRequestId,n=this.ownProfile,r=this.displayName,i=n!==null&&r.trim()!==(n.displayName??``);this.identityLoading=!0,this.identityError=null;let a=this.readIdentity(e,t,i,r);this.identityReceipt={result:a},this.publish()}async readIdentity(e,n,r,i){try{let a=await this.context.gateway.loadSelfProfile();if(n!==this.identityRequestId||(this.ownProfile=a,!a))return;this.displayName=r?i:a.displayName??``,this.gitCoauthorEnabled=!0,this.prAttributionEnabled=!1,this.publish();let{loadUserPreferences:o}=await ee(async()=>{let{loadUserPreferences:e}=await import(`./user-prefs-request-BE7DKPZP.js`).then(e=>(e.t(),e.r));return{loadUserPreferences:e}},__vite__mapDeps([0,1]),import.meta.url);if(n!==this.identityRequestId)return;let s=await o(e,a.id,{keys:a.id===`gateway-owner`?[p]:[u,p]});if(n!==this.identityRequestId)return;this.gitCoauthorEnabled=a.id!==`gateway-owner`&&s.status===`ok`&&t(s.entries[`git.coauthor.enabled`]),this.prAttributionEnabled=s.status===`ok`&&s.entries[`github.prAttribution.enabled`]===!0}catch(e){n===this.identityRequestId&&(this.identityError=d(e,D(`profilePage.identity.profileUnavailable`)))}finally{n===this.identityRequestId&&(this.identityLoading=!1,this.publish())}}async saveIdentity(e){let t=this.client,n=this.ownProfile;if(!t||!n||!this.canWrite||this.identityBusy||this.identityLoading||e.kind===`git-coauthor`&&n.id===`gateway-owner`)return;this.identityBusy=e.kind,this.identityError=null,this.publish();let r=this.identityRequestId,i=()=>t===this.client&&r===this.identityRequestId;try{switch(e.kind){case`display-name`:{let e=await t.request(`users.setDisplayName`,{profileId:n.id,displayName:this.displayName.trim()||null});if(!i())return;this.ownProfile=e.profile,this.displayName=e.profile.displayName??``,this.context.gateway.updateSelfUser?.({name:e.profile.displayName??void 0});break}case`avatar`:{Ne(this.context.config);let r=this.displayName,a=r.trim()!==(n.displayName??``),o=this.selfUser?.id===n.id?this.selfUser.avatarUrl:void 0,s=await Vn(e.file);if(!i())return;Ne(this.context.config);let c=await t.request(`users.setAvatar`,{profileId:n.id,mime:s.mime,avatarBase64:s.avatarBase64});if(!i())return;this.ownProfile=c.profile,this.displayName=a?r:c.profile.displayName??``;let l=Be(this.context.gateway.connection.gatewayUrl,c.profile.id,c.avatarRevision,this.context.resourceBasePath),u=this.selfUser?.id===c.profile.id&&this.selfUser.avatarUrl!==o;l&&!u&&this.context.gateway.updateSelfUser?.({avatarUrl:l});break}case`git-coauthor`:case`pr-attribution`:{let n=e.kind===`git-coauthor`?u:p,r=await Pe(t,{entries:{[n]:e.enabled}});if(!i())return;if(r.status!==`ok`)throw Error(D(`profilePage.identity.profileUnavailable`));e.kind===`git-coauthor`?this.gitCoauthorEnabled=e.enabled:this.prAttributionEnabled=e.enabled;return}}}catch(t){i()&&(this.identityError=e.kind===`avatar`&&t instanceof $?D(t.code===`too-large`?`profilePage.identity.avatarErrors.tooLarge`:t.code===`source-too-large`?`profilePage.identity.avatarErrors.sourceTooLarge`:`profilePage.identity.avatarErrors.invalid`):d(t,D(`profilePage.identity.profileUnavailable`)));return}finally{i()&&this.identityBusy===e.kind&&(this.identityBusy=null,this.publish())}if(i())return this.loadIdentity(),this.identityReceipt.result}refreshManually(){this.identityReady&&!this.identityBusy&&!this.identityLoading&&(this.client&&Fe(this.client),this.loadIdentity())}}})))()}function Jn(e){return e===null?`unknown`:e.length===0?`none`:[[`operator.admin`,`admin`],[`operator.write`,`write`],[`operator.sessions.write`,`sessionWrite`],[`operator.read`,`read`],[`operator.sessions.read`,`sessionRead`]].find(([t])=>e.includes(t))?.[1]??`limited`}function Yn(){let e=Re(),t=xe(e.scopeUpgrade,e=>e.state.phase===`hidden`?null:e.state);V(()=>e.scopeUpgrade.activate(vt));let n=xe(e.agents,e=>e.state.agentsList),r=xe(e.agentIdentity,e=>e),[i,a]=k(0,{ownedWrite:!0}),o=new Kn(e,()=>a(e=>e+1)),s=()=>(i(),o),c=j(()=>s().canWrite),l=j(()=>s().identityScope),u=j(()=>{let e=l(),[t,n]=M(null),[r,i]=M(()=>s().gitCoauthorEnabled),[a,o]=M(()=>s().prAttributionEnabled);return{scope:e,saving:t,setSaving:n,gitCoauthorEnabled:r,setGitCoauthorEnabled:i,prAttributionEnabled:a,setPrAttributionEnabled:o}}),p=()=>u().saving()??s().identityBusy,m=Ze(function*(e,t,n,r){let i=()=>e.scope===o.identityScope&&n===o.presentationLifetime.promise;try{i()&&(e.setSaving(r.kind),r.kind===`git-coauthor`?e.setGitCoauthorEnabled(r.enabled):r.kind===`pr-attribution`?e.setPrAttributionEnabled(r.enabled):We(b)),yield Promise.race([t,n]),i()&&(yield Je(r.kind===`git-coauthor`?e.gitCoauthorEnabled:r.kind===`pr-attribution`?e.prAttributionEnabled:b))}catch(e){i()&&(o.identityError=d(e,D(`profilePage.identity.profileUnavailable`)),o.publish())}});async function h(e){let t=u(),n=o.presentationLifetime.promise,r=o.saveIdentity(e);return o.identityBusy===e.kind?(await Promise.resolve(),m(t,r,n,e)):r}V(()=>{let t=e.router.subscribe(()=>{o.retirePresentation(),o.publish()}),n=e.gateway.subscribe(e=>o.applyGatewaySnapshot(e)),r=e.gateway.subscribeEvents(e=>{!o.identityBusy&&e.event===`sessions.changed`&&y(e.payload)?.reason===`profile-identity`&&(o.identityRequestId+=1,o.identityLoading=!1,o.loadIdentity())});return o.applyGatewaySnapshot(e.gateway.snapshot),()=>{t(),n(),r(),o.dispose()}});let g=()=>s().connected&&s().client!==null,_=()=>g()||s().connectionScopes!==null||s().selfUser!==null,v=()=>{let e=n.read(),t=e?.defaultId??`main`;return e?.agents.find(e=>e.id===t)??{id:t}},ee=()=>{let t=s().ownProfile;return t?s().selfUser?.id===t.id&&s().selfUser?.avatarUrl?s().selfUser.avatarUrl:Be(e.gateway.connection.gatewayUrl,t.id,t.updatedAt,e.resourceBasePath):null},te=j(()=>s().identityReceipt),b=j(()=>te().result),x=t=>H(N,{get when(){return z(()=>!!s().selfUser)()?s().ownProfile:s().selfUser},get fallback(){var e=Xn();return R(e,H(Y,{get title(){return D(`profilePage.identity.title`)},get children(){return z(()=>!!(t.pending||s().connected&&!s().identityReady))()?H(dt,{get label(){return D(`profilePage.identity.loading`)},rows:2}):H(q,{get message(){return s().identityError??D(s().selfUser?`profilePage.identity.profileUnavailable`:`profilePage.identity.unidentified`)}})}})),U(()=>rt.identity,t=>{B(e,`id`,t)}),e},children:n=>{function r(){let r=()=>p()??(t.pending?`loading`:null),i=j(()=>{let t=e.config;return t?ce(t):null}),a=()=>i()?.read().uploadsEnabled!==!1,l=()=>A(c),d=()=>n().id===f;var m=Xn();return R(m,H(Y,{get title(){return D(`profilePage.identity.title`)},get description(){return D(`profilePage.identity.description`)},get children(){return[H(N,{get when(){return z(()=>!l())()&&s().identityReady},get children(){return H(J,{get title(){return D(`profilePage.identity.writeRequired`)}})}}),H(J,{get title(){return D(`profilePage.identity.avatar`)},get description(){return D(`profilePage.identity.avatarDescription`)},get control(){var t=er(),i=t.firstChild;return i._$owner=P(),R(t,H(N,{get when(){return z(()=>!!l())()?a():l()},get children(){return[(()=>{var t=Qn();return t._$$click=t=>{let n=t.currentTarget.nextElementSibling;l()&&be(e.config)&&n instanceof HTMLInputElement&&n.click()},R(t,(()=>{var e=z(()=>r()===`avatar`);return()=>e()?D(`profilePage.identity.processingAvatar`):D(`profilePage.identity.chooseAvatar`)})()),U(()=>r()!==null,e=>{B(t,`disabled`,e)}),t})(),(()=>{var t=$n();return t.addEventListener(`change`,t=>{let n=t.currentTarget,r=n.files?.[0];n.value=``,r&&l()&&be(e.config)&&h({kind:`avatar`,file:r})}),U(()=>r()!==null,e=>{B(t,`disabled`,e)}),t})()]}}),null),U(()=>({id:n().id,name:n().displayName??void 0,email:n().emails[0],avatarUrl:ee()??void 0,watchedSessions:[]}),e=>{i.user=e}),t}}),H(J,{get title(){return D(`profilePage.identity.displayName`)},get description(){return D(`profilePage.identity.displayNameDescription`)},get control(){var e=tr(),t=e.firstChild,i=t.nextSibling;return e.addEventListener(`submit`,e=>{e.preventDefault(),h({kind:`display-name`})}),t._$$input=e=>{o.displayName=e.currentTarget.value,o.publish()},R(i,(()=>{var e=z(()=>r()===`display-name`);return()=>e()?D(`common.saving`):D(`common.save`)})()),U(()=>({e:D(`profilePage.identity.displayName`),t:s().displayName,a:!l()||r()!==null&&r()!==`display-name`,o:r()===`display-name`,i:!l()||r()!==null||s().displayName.trim()===(n().displayName??``)}),({e,t:n,a:r,o:a,i:o},s)=>{e!==s?.e&&B(t,`aria-label`,e),t.value=n??``,r!==s?.a&&B(t,`disabled`,r),a!==s?.o&&B(t,`readonly`,a),o!==s?.i&&B(i,`disabled`,o)}),e}}),H(N,{get when(){return!d()},get children(){return H(J,{get title(){return D(`profilePage.identity.linkedEmails`)},get description(){return D(`profilePage.identity.linkedEmailsDescription`)},get control(){return z(()=>!!n().emails.length)()?H(X,{get value(){return n().emails.join(`, `)}}):void 0}})}}),H(J,{get title(){return D(`profilePage.identity.githubAccount`)},get description(){return z(()=>!!d())()?D(`profilePage.identity.ownerGithubDescription`):z(()=>!!n().githubIdentity)()?D(`profilePage.identity.githubAccountDescription`):D(`profilePage.identity.githubUnavailableDescription`)},get control(){return H(N,{get when(){return n().githubIdentity},get fallback(){return H(ot,{kind:`muted`,get label(){return D(`profilePage.identity.githubUnavailable`)}})},children:e=>[(()=>{var t=nr(),n=t.firstChild,r=n.nextSibling;r.firstChild;var i=P();return B(t,`target`,ve),R(r,()=>e().login,null),U(()=>({e:e().profileUrl,t:ye(),a:e().avatarUrl}),({e,t:r,a},o)=>{e!==o?.e&&B(t,`href`,e),r!==o?.t&&B(t,`rel`,r),a!==o?.a&&B(n,`src`,a),Ye(t,i)}),t})(),H(ot,{kind:`ok`,get label(){return D(`profilePage.identity.githubVerified`)}})]})}}),H(it,{get title(){return D(`profilePage.identity.gitCoauthor`)},get description(){return z(()=>!!d())()?D(`profilePage.identity.ownerGitCoauthorDescription`):D(`profilePage.identity.gitCoauthorDescription`)},get checked(){return z(()=>!d())()&&u().gitCoauthorEnabled()},get disabled(){return!l()||r()!==null&&r()!==`git-coauthor`||d()},get saving(){return r()===`git-coauthor`},onChange:e=>void h({kind:`git-coauthor`,enabled:e})}),H(it,{get title(){return D(`profilePage.identity.prAttribution`)},get description(){return[z(()=>D(`profilePage.identity.prAttributionDescription`)),rr(),(()=>{var e=ir(),t=P();return B(e,`target`,ve),R(e,()=>D(`profilePage.identity.prAttributionLink`)),U(()=>ye(),n=>{B(e,`rel`,n),Ye(e,t)}),e})()]},get checked(){return u().prAttributionEnabled()},get disabled(){return!l()||r()!==null},onChange:e=>void h({kind:`pr-attribution`,enabled:e})}),H(N,{get when(){return s().identityError},get children(){var e=Zn(),t=e.firstChild;return R(t,()=>s().identityError),e}})]}})),U(()=>rt.identity,e=>{B(m,`id`,e)}),m}return H(r,{})}});var C=lr(),w=C.firstChild,T=w.nextSibling;return C._$owner=P(),R(C,H(Ie,{traits:{toolbarHeader:!0},get children(){var e=or(),t=e.firstChild.firstChild,n=t.nextSibling,r=n.firstChild,i=r.nextSibling;return R(t,()=>S(`profile`)),R(n,()=>ne(`profile`),r),R(n,H(lt,{url:pr}),i),R(e,H(N,{get when(){return s().connected},get children(){var e=ar();return e._$$click=()=>o.refreshManually(),R(e,(()=>{var e=z(()=>!!s().identityLoading);return()=>e()?D(`common.refreshing`):D(`common.refresh`)})()),U(()=>!s().identityReady||s().identityLoading||p()!==null,t=>{B(e,`disabled`,t)}),e}}),null),e}}),w),R(C,H(yt,{get children(){return H(st,{get children(){return[H(N,{get when(){return _()},get fallback(){return H(ut,{get children(){return z(()=>!!s().connecting)()?(()=>{var e=ur();return R(e,H(q,{get message(){return D(`profilePage.access.connecting`)}})),e})():H(q,{get message(){return D(`profilePage.offline`)}})}})},get children(){return[H(Fn,{get row(){return v()},get user(){return s().selfUser},get identity(){return r.read().get(v().id)}}),(()=>{var n=cr();return R(n,H(Y,{get title(){return D(`profilePage.access.title`)},get children(){return[H(J,{get title(){return D(`profilePage.access.${Jn(s().connectionScopes)}`)},get description(){return D(`profilePage.access.limits`)}}),H(J,{get title(){return D(`profilePage.access.help`)},get description(){return D(`profilePage.access.nextStep`)},stackedOnNarrow:!0,get control(){var t=dr();return t._$$click=()=>e.gateway.connect(),R(t,()=>D(`profilePage.access.reconnect`)),U(()=>p()!==null,e=>{B(t,`disabled`,e)}),t}}),H(N,{get when(){return t.read()},children:t=>H(J,{get title(){return D(`profilePage.access.adminRequest`)},get description(){return z(()=>t().phase===`available`)()?D(`profilePage.access.adminRequestHint`):mt(t())},stackedOnNarrow:!0,get control(){return H(_t,{get state(){return t()},onRequest:()=>e.scopeUpgrade.request(),onRetry:()=>e.scopeUpgrade.retry(),onCancel:()=>e.scopeUpgrade.cancel()})}})}),(()=>{var e=sr(),t=e.firstChild;return R(t,()=>D(`profilePage.access.details`)),R(e,H(J,{get title(){return D(`profilePage.access.scopes`)},get description(){return D(`profilePage.access.description`)},stacked:!0,get control(){return H(X,{get mono(){return z(()=>s().connectionScopes!==null)()&&s().connectionScopes.length>0},get value(){return z(()=>s().connectionScopes===null)()?D(`profilePage.access.unknown`):z(()=>s().connectionScopes.length===0)()?D(`profilePage.access.none`):s().connectionScopes.join(`, `)}})}}),null),e})()]}})),n})(),H(F,{fallback:(e,t)=>[(()=>{var n=fr(),r=n.firstChild,i=r.nextSibling;return R(n,()=>d(e()),r),i._$$click=()=>{o.refreshManually(),t()},R(i,()=>D(`common.retry`)),n})(),H(x,{pending:!1})],get children(){return H(G,{get on(){return A(l)},get fallback(){return H(x,{pending:!0})},get children(){return[z(()=>(A(b),null)),H(x,{get pending(){return I(b)}})]}})}})]}}),H(wn,{get hidden(){return!_()||s().context.gateway.snapshot.hello?.policy?.hasMultipleSessionSharingIdentities!==!0}}),H(N,{get when(){return _()},get children(){return[H(vn,{get target(){return o.modelAccountsTarget},get personLabel(){return z(()=>!!s().ownProfile)()?s().ownProfile.displayName?.trim()||s().ownProfile.emails[0]||D(`profilePage.modelAccounts.currentPerson`):null}}),H(Mt,{}),H(ut,{get children(){return H(at,{get title(){return D(`profilePage.usageStatistics`)},get description(){return D(`profilePage.usageStatisticsDescription`)},onClick:()=>e.navigate(`usage`)})}})]}})]}})}}),T),C}var Xn,Zn,Qn,$n,er,tr,nr,rr,ir,ar,or,sr,cr,lr,ur,dr,fr,pr;function mr(){return(mr=e((()=>{W(),L(),o(),b(),gt(),Se(),ht(),Z(),bt(),Bt(),Le(),pt(),tt(),de(),w(),s(),C(),Ce(),E(),De(),Ee(),nt(),bn(),Pn(),Me(),zn(),qn(),Xn=K(`<div>`),Zn=K(`<div class="settings-row identity-error"role=alert><span class=settings-row__desc>`),Qn=K(`<button type=button class="btn btn--sm">`),$n=K(`<input type=file accept=image/png,image/jpeg,image/webp hidden>`),er=K(`<span class=identity-avatar-control><openclaw-viewer-avatar variant=profile>`,1),tr=K(`<form class=identity-name-control><input class=settings-input type=text maxlength=256><button type=submit class="btn btn--sm">`),nr=K(`<a class=settings-account><img class=settings-account__avatar alt><span class="settings-row__value settings-row__value--mono">@`),rr=K(`<br>`),ir=K(`<a href=https://openclaw.ai>`),ar=K(`<button class="btn profile-refresh">`),or=K(`<section class=content-header><div><h1 class=page-title></h1><div class=page-subtitle> <!>`),sr=K(`<details class="settings-row settings-row--stacked"><summary>`),cr=K(`<div id=settings-profile-access>`),lr=K(`<openclaw-profile-page><!><!>`,1),ur=K(`<div role=status>`),dr=K(`<button type=button class=btn>`),fr=K(`<div class="callout danger"role=alert> <button class="btn btn--sm">`),et(),O(Oe),O(ft),pr=`https://docs.openclaw.ai/concepts/user-model`,Xe([`click`,`input`])})))()}mr();export{Yn as ProfilePage};