openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 16.7 kB
JavaScript
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{ut as t}from"./_4____________________________.js";import{AN as n,EN as r,GN as i,JN as a,ON as o,fN as s,pN as c,qN as l}from"./_2_____________________________.js";import{C as u,Ct as d,F as f,H as p,I as m,O as h,S as g,St as ee,U as _,_t as te,d as v,f as y,g as b,gt as ne,j as x,l as S,s as C,u as w,w as T,x as E,yt as re}from"./_6____________________.js";import{n as ie,t as ae}from"./en-settings-DEvavpke.js";import{o as oe,t as se}from"./settings-targets-bvwku6ua.js";import{f as ce,m as D,n as le,t as O,w as k,x as A,y as j}from"./settings-controls-runtime-CwXZmgDo.js";import{n as ue,t as de}from"./route-chrome-Dr9fhzjf.js";import{n as fe,t as M}from"./settings-select-row-DhCp1sjn.js";function pe(e){return`${String(Math.floor(e/60)).padStart(2,`0`)}:${String(e%60).padStart(2,`0`)}`}function me(e,t){let n=/^(\d{2}):(\d{2})$/u.exec(e);return n?Number(n[1])*60+Number(n[2]):t}function N(e){return e===`identified`||e===`detailed`?e:`private`}function P(){return[{value:`private`,label:a(`configView.notifications.private`)},{value:`identified`,label:a(`configView.notifications.namesOnly`)},{value:`detailed`,label:a(`configView.notifications.detailed`)}]}function F(e){return[{value:`inherit`,label:e},{value:`on`,label:a(`configForm.enumOn`)},{value:`off`,label:a(`configForm.enumOff`)}]}function I(e){var t=R(),n=t.firstChild,r=n.nextSibling;return v(t,x(D,{get title(){return a(`configView.notifications.quietHoursWindow`)},get control(){return x(u,{each:[[`startMinute`,`quietHoursStart`],[`endMinute`,`quietHoursEnd`]],keyed:e=>e[0],children:(t,n)=>[y(()=>y(()=>n()>0)()&&B()),(()=>{var n=z();return n.addEventListener(`change`,n=>e.onChange({...e.quietHours,[t()[0]]:me(n.currentTarget.value,e.quietHours[t()[0]])})),S(()=>({e:e.disabled,t:a(`configView.notifications.${t()[1]}`),a:pe(e.quietHours[t()[0]])}),({e,t,a:r},i)=>{e!==i?.e&&b(n,`disabled`,e),t!==i?.t&&b(n,`aria-label`,t),n.value=r??``}),n})()]})}}),n),v(t,x(M,{get disabled(){return e.disabled},get title(){return a(`configView.notifications.timeZone`)},get value(){return e.quietHours.timeZone},get options(){return ue([e.quietHours.timeZone]).map(e=>({value:e,label:e.replaceAll(`_`,` `)}))},onChange:t=>e.onChange({...e.quietHours,timeZone:t})}),r),t}function L(e){let t=p();return x(D,{get title(){return a(`configView.notifications.onlyAgents`)},get description(){var e=V();return b(e,`id`,t),v(e,()=>a(`configView.notifications.onlyAgentsHint`)),e},get control(){var n=H();return n.addEventListener(`change`,t=>e.onChange(t.currentTarget.value.split(`,`).map(e=>e.trim()).filter(Boolean))),b(n,`aria-describedby`,t),S(()=>({e:e.disabled,t:a(`configView.notifications.onlyAgents`),a:e.agentIds.join(`, `)}),({e,t,a:r},i)=>{e!==i?.e&&b(n,`disabled`,e),t!==i?.t&&b(n,`aria-label`,t),n.value=r??``}),n}})}function he(e){let t=t=>e.onChange({...e.preferences,...t});var n=U(),r=n.firstChild,i=r.firstChild,o=i.nextSibling,s=o.nextSibling,c=s.nextSibling,l=c.nextSibling;return v(n,x(O,{get title(){return a(`configView.notifications.accountDefaults`)}}),r),v(r,x(u,{each:K,children:n=>x(A,{get disabled(){return e.disabled},get title(){return a(`configView.notifications.${n}`)},get checked(){return e.preferences.categories[n]===!0},onChange:r=>t({categories:{...e.preferences.categories,[n]:r}})})}),i),v(r,x(M,{get disabled(){return e.disabled},get title(){return a(`configView.notifications.lockScreenDetail`)},get description(){return a(`configView.notifications.lockScreenDetailHint`)},get value(){return e.preferences.detailLevel},get options(){return P()},onChange:e=>t({detailLevel:N(e)})}),o),v(r,x(A,{get disabled(){return e.disabled},get title(){return a(`configView.notifications.quietHours`)},get checked(){return e.preferences.quietHours.enabled},onChange:n=>t({quietHours:{...e.preferences.quietHours,enabled:n}})}),s),v(r,x(h,{get when(){return e.preferences.quietHours.enabled},get children(){return x(I,{get disabled(){return e.disabled},get quietHours(){return e.preferences.quietHours},onChange:e=>t({quietHours:e})})}}),c),v(r,x(L,{get disabled(){return e.disabled},get agentIds(){return e.preferences.agentIds},onChange:e=>t({agentIds:e})}),l),n}function ge(e){let t=t=>e.onChange({...e.preferences,...t});var n=W(),r=n.firstChild,i=r.firstChild,o=i.nextSibling,s=o.nextSibling,c=s.nextSibling,l=c.nextSibling,d=l.nextSibling,f=d.nextSibling,p=f.nextSibling;return v(n,x(O,{get title(){return a(`configView.notifications.installedApp`)}}),r),v(r,x(A,{get disabled(){return e.disabled},get title(){return a(`configView.notifications.deliverDevice`)},get checked(){return e.preferences.enabled},onChange:e=>t({enabled:e})}),i),v(r,x(D,{get title(){return a(`configView.notifications.notificationLabel`)},get control(){var n=G();return n.addEventListener(`change`,e=>t({label:e.currentTarget.value})),S(()=>({e:e.disabled,t:a(`configView.notifications.notificationLabel`),a:e.preferences.label}),({e,t,a:r},i)=>{e!==i?.e&&b(n,`disabled`,e),t!==i?.t&&b(n,`aria-label`,t),n.value=r??``}),n}}),o),v(r,x(M,{get disabled(){return e.disabled},get title(){return a(`configView.notifications.lockScreenDetail`)},get value(){return e.preferences.detailLevel??`inherit`},get options(){return[{value:`inherit`,label:a(`configView.notifications.inheritDetail`)},...P()]},onChange:e=>t({detailLevel:e===`inherit`?void 0:N(e)})}),s),v(r,x(M,{get disabled(){return e.disabled},get title(){return a(`configView.notifications.quietHours`)},get value(){return y(()=>e.preferences.quietHours===void 0)()?`inherit`:e.preferences.quietHours.enabled?`on`:`off`},get options(){return F(a(`configView.notifications.inheritQuietHours`))},onChange:n=>t({quietHours:n===`inherit`?void 0:{enabled:n===`on`,startMinute:e.preferences.quietHours?.startMinute??1320,endMinute:e.preferences.quietHours?.endMinute??420,timeZone:e.preferences.quietHours?.timeZone??`UTC`}})}),c),v(r,x(h,{get when(){return y(()=>!!e.preferences.quietHours?.enabled)()?e.preferences.quietHours:void 0},children:n=>x(I,{get disabled(){return e.disabled},get quietHours(){return n()},onChange:e=>t({quietHours:e})})}),l),v(r,x(M,{get disabled(){return e.disabled},get title(){return a(`configView.notifications.onlyAgents`)},get value(){return e.preferences.agentIds===void 0?`inherit`:`override`},get options(){return[{value:`inherit`,label:a(`configView.notifications.inherit`)},{value:`override`,label:a(`configView.notifications.overrideAgents`)}]},onChange:e=>t({agentIds:e===`inherit`?void 0:[]})}),d),v(r,x(h,{get when(){return e.preferences.agentIds},children:n=>x(L,{get disabled(){return e.disabled},get agentIds(){return n()},onChange:e=>t({agentIds:e})})}),f),v(r,x(u,{each:K,children:n=>x(M,{get disabled(){return e.disabled},get title(){return a(`configView.notifications.${n}`)},get value(){return y(()=>e.preferences.categories?.[n]===void 0)()?`inherit`:e.preferences.categories?.[n]?`on`:`off`},get options(){return F(a(`configView.notifications.inherit`))},onChange:r=>{let i={...e.preferences.categories};r===`inherit`?delete i[n]:i[n]=r===`on`,t({categories:i})}})}),p),n}var R,z,B,V,H,U,W,G,K;function q(){return(q=e((()=>{w(),_(),k(),i(),de(),le(),fe(),R=E(`<div class="settings-subrows quiet-hours-window"><!><!>`),z=E(`<input type=time class=settings-input>`),B=E(`<span class=settings-row__value aria-hidden=true>–`),V=E(`<span>`),H=E(`<input type=text class=settings-input>`),U=E(`<section class=settings-section><div class=settings-group><!><!><!><!><!>`),W=E(`<section class=settings-section><div class=settings-group><!><!><!><!><!><!><!><!>`),G=E(`<input type=text class=settings-input maxlength=80>`),K=[`approvalRequested`,`agentFinished`,`agentQuestion`,`humanMentioned`,`scheduledTaskFailed`]})))()}function J(e){var t=xe(),n=t.firstChild,r=n.firstChild,i=n.nextSibling;return v(r,()=>e.title),v(n,x(h,{get when(){return e.status},get children(){var t=be();return v(t,()=>e.status),t}}),null),v(t,()=>e.description,i),v(i,()=>e.children),S(()=>se.notifications,e=>{b(t,`id`,e)}),t}function _e(e){let n=()=>{switch(e.native.permission){case`granted`:return{kind:`ok`,label:a(`configView.notifications.granted`)};case`denied`:return{kind:`danger`,label:a(`configView.notifications.denied`)};case`notDetermined`:return{kind:`accent`,label:a(`configView.notifications.notRequested`)};default:return{kind:`muted`,label:a(`configView.notifications.checking`)}}},i=()=>e.native.test?.state===`sent`?a(`configView.notifications.testQueued`):``,[o,c]=m(!1),l=()=>o()||e.native.test?.state===`pending`,u=re(function*(t,n){n===e.actions.presentationRetired()&&c(!0),yield Promise.race([t,n])}),d=async()=>{let t=e.actions.presentationRetired(),n=e.actions.onNativeNotificationsSendTest?.();return await Promise.resolve(),u(n,t)};return x(J,{get title(){return a(`configView.notifications.nativeTitle`)},get children(){return[(()=>{var e=Ce();return v(e,i),e})(),x(D,{get title(){return a(`configView.notifications.permission`)},get description(){return y(()=>e.native.permission===`denied`)()?a(`configView.notifications.nativeBlockedHint`):void 0},get control(){return[x(j,{get kind(){return n().kind},get label(){return n().label}}),x(h,{get when(){return e.native.permission===`notDetermined`||e.native.permission===`denied`||e.native.permission===`granted`},get children(){return y(()=>e.native.permission===`granted`)()?(()=>{var e=we(),t=e.firstChild,n=t.nextSibling;return e._$$click=()=>void d(),v(e,(()=>{var e=y(()=>!!l());return()=>e()?X():x(s,{name:`send`})})(),t),v(e,(()=>{var e=y(()=>!!l());return()=>e()?a(`configView.notifications.sendingTest`):a(`configView.notifications.sendTest`)})(),n),S(()=>l(),t=>{b(e,`disabled`,t)}),e})():(()=>{var t=Y();return t._$$click=()=>e.actions.onNativeNotificationsRequestPermission?.(),v(t,()=>a(e.native.permission===`notDetermined`?`configView.notifications.enable`:`configView.notifications.openSystemSettings`)),S(()=>e.native.permission===`notDetermined`,e=>{t.classList.toggle(`primary`,e)}),t})()}})]}}),x(h,{get when(){return l()},get fallback(){return x(h,{get when(){return e.native.test},keyed:!0,children:e=>{let n=f(()=>{if(e.state===`error`)throw new t(e.message);return e.state});return x(g,{fallback:e=>x(Q,{state:`error`,get message(){return r(e())}}),get children(){return x(Q,{get state(){return n()}})}})}})},get children(){return x(Q,{state:`pending`})}})]}})}function ve(e){let t=f(()=>e.push.read),n=f(()=>(t(),e.push.preferences)),[r,i]=m(()=>n()),[c,l]=m(!1,{equals:!1}),u=f(()=>e.push.command),p=re(function*(e,t){l(!0),t&&i(e=>e&&{...e,[t.scope]:t.value}),yield e,te(n)}),_=(e,t)=>{e&&ne(()=>{p(e,t).catch(()=>{})})},C=()=>c()||e.push.loading,w=()=>e.push.subscription===`registered`,E=()=>w()||e.push.subscription===`vapid-mismatch`||e.push.subscription===`local`,ie=()=>a(e.push.supported?e.push.subscription===`local`?`configView.notifications.localSubscription`:e.push.canManage?e.push.permission===`denied`?`configView.notifications.blocked`:w()?`configView.notifications.subscribed`:e.push.subscription===`vapid-mismatch`?`configView.notifications.unavailable`:e.push.subscription===`unknown`?`configView.notifications.checking`:`configView.notifications.ready`:`configView.notifications.unavailable`:`configView.notifications.unsupported`),ae=()=>{if(e.push.permission===`denied`)return a(`configView.notifications.blockedHint`);if(e.push.supported&&!e.push.canManage)return a(e.actions.connected?`configView.notifications.gatewayAccessRequired`:`configView.notifications.gatewayDisconnected`);if(e.push.supported&&e.push.canManage&&w())return a(`configView.notifications.testAllBrowsersHint`)},oe=()=>!e.push.supported||!e.push.canManage?`muted`:e.push.permission===`denied`||e.push.subscription===`vapid-mismatch`?`danger`:w()?`ok`:`accent`;return[x(J,{get title(){return a(`configView.notifications.title`)},get description(){return y(()=>e.push.permission===`install-required`)()?(()=>{var e=De();return v(e,()=>a(`configView.notifications.iosInstallRequired`)),e})():void 0},get children(){return[x(D,{get title(){return a(`configView.notifications.status`)},get description(){return ae()},get control(){return[x(j,{get kind(){return oe()},get label(){return ie()}}),x(h,{get when(){return y(()=>!!(e.push.supported&&e.push.permission!==`denied`))()?e.push.canManage||E():e.push.supported&&e.push.permission!==`denied`},get children(){return y(()=>!!E())()?[(()=>{var t=Z(),n=t.firstChild,r=n.nextSibling;return t._$$click=()=>_(e.actions.onWebPushUnsubscribe?.()),v(t,x(s,{name:`x`}),n),v(t,()=>a(`configView.notifications.unsubscribe`),r),S(()=>C()||!e.actions.connected,e=>{b(t,`disabled`,e)}),t})(),x(h,{get when(){return y(()=>!!w())()?e.push.canManage:w()},get children(){var t=Z(),n=t.firstChild,r=n.nextSibling;return t._$$click=()=>_(e.actions.onWebPushTest?.()),v(t,x(s,{name:`send`}),n),v(t,()=>a(`configView.notifications.testAllBrowsers`),r),S(()=>C()||!e.actions.connected,e=>{b(t,`disabled`,e)}),t}})]:x(h,{get when(){return e.push.canManage},get children(){var t=Oe(),n=t.firstChild,r=n.nextSibling;return t._$$click=()=>_(e.actions.onWebPushSubscribe?.()),v(t,x(h,{get when(){return C()},get children(){return X()}}),n),v(t,()=>a(C()?`configView.notifications.subscribing`:`configView.notifications.enable`),r),S(()=>C()||!e.actions.connected,e=>{b(t,`disabled`,e)}),t}})}})]}}),x(h,{get when(){return e.push.error},get children(){var t=Ee(),n=t.firstChild.firstChild;return v(n,()=>o(e.push.error)),t}}),x(g,{fallback:$,get children(){return x(T,{get on(){return e.push.command},fallback:null,get children(){return u(),null}})}})]}}),x(g,{fallback:$,get children(){return x(T,{get on(){return e.push.read},fallback:null,get children(){return x(h,{get when(){return y(()=>!!e.push.canReadPreferences)()?d(r):(t(),void 0)},children:t=>(()=>{var r=ke(),i=r.firstChild,a=i.nextSibling;return v(r,x(h,{get when(){return t().durableIdentity},get children(){return x(he,{get disabled(){return!e.push.canManage||!e.actions.connected},get preferences(){return t().user},onChange:t=>_(e.actions.onWebPushSetUserPreferences?.(t),{scope:`user`,value:t})})}}),i),v(r,x(ge,{get disabled(){return!e.push.canManage||!e.actions.connected},get preferences(){return t().device},onChange:t=>_(e.actions.onWebPushSetDevicePreferences?.(t),{scope:`device`,value:t})}),a),S(()=>C()||ee(n),e=>{b(r,`inert`,e)}),r})()})}})}})]}function ye(e){return x(ce,{get children(){return x(h,{get when(){return e.nativeNotifications},get fallback(){return x(h,{get when(){return e.webPush},get fallback(){return x(J,{get title(){return a(`configView.notifications.title`)},get status(){return x(j,{kind:`muted`,get label(){return a(`configView.notifications.unavailable`)}})},get children(){var e=Ae(),t=e.firstChild.firstChild;return v(t,()=>a(`configView.notifications.unavailableHint`)),e}})},children:t=>x(ve,{get push(){return t()},actions:e})})},children:t=>x(_e,{get native(){return t()},actions:e})})}})}var be,xe,Se,Ce,we,Y,X,Te,Ee,De,Z,Oe,ke,Ae,Q,$;function je(){return(je=e((()=>{w(),_(),c(),k(),ae(),n(),i(),oe(),q(),be=E(`<div class=settings-section__actions>`),xe=E(`<section class=settings-section><div class=settings-section__header><h2 class=settings-section__heading></h2></div><div class=settings-group>`),Se=E(`<br>`),Ce=E(`<span class=sr-only role=status aria-live=polite>`),we=E(`<button class=btn><!><!>`),Y=E(`<button class=btn>`),X=E(`<span class=btn__spinner aria-hidden=true>`),Te=E(`<div class=settings-row><div class=settings-row__text><div class=cfg-field__error role=alert><div></div><div>`),Ee=E(`<div class=settings-row><div class=settings-row__text><span class=cfg-field__error role=alert>`),De=E(`<p class=settings-section__desc>`),Z=E(`<button class=btn> <!>`),Oe=E(`<button class="btn primary"><!><!>`),ke=E(`<div class=settings-stack><!><!>`),Ae=E(`<div class=settings-row><div class=settings-row__text><span class=settings-row__desc>`),l(ie),Q=e=>x(D,{get title(){return a(`configView.notifications.testOutcome`)},get description(){return y(()=>e.state===`error`)()?[y(()=>a(`configView.notifications.testFailed`)),Se(),y(()=>e.message)]:e.message},get role(){return e.state===`error`?`alert`:void 0},get control(){return x(j,{get kind(){return y(()=>e.state===`pending`)()?`accent`:e.state===`sent`?`ok`:`danger`},get label(){return a(e.state===`pending`?`configView.notifications.sendingTest`:e.state===`sent`?`configView.notifications.testQueued`:`configView.notifications.testError`)}})}}),$=e=>(()=>{var t=Te(),n=t.firstChild.firstChild.firstChild,i=n.nextSibling;return v(n,()=>a(`configView.notifications.updateFailed`)),v(i,()=>r(e())),t})(),C([`click`])})))()}je();export{ye as NotificationsSection};