import{n as e}from"./rolldown-runtime-DaJ6WEGw.js";import{d as t,m as n,p as r}from"./control-ui-foundation-6sbDnmF4.js";import{Bt as i,Eo as a,Ga as o,Ht as s,It as c,Jo as l,Ka as u,Ko as d,Lo as ee,Lt as f,Nr as p,Pr as m,Rt as h,To as g,Ut as _,Vt as v,Wa as te,ns as y,qa as b,rs as x}from"./control-ui-core-DENrrOFp.js";import{dt as S,ft as C}from"./control-ui-foundation-EMTIMJQU.js";import{$ as w,G as T,J as E,U as D,X as O,z as k}from"./lit-runtime-DRK0WlLJ.js";import{A,O as j,ft as M,lt as N}from"./control-ui-foundation-BMJqgJ7G.js";import{C as ne,Dt as re,Et as ie,F as ae,G as oe,H as se,M as P,N as F,P as ce,S as le,St as ue,_ as de,b as fe,d as pe,f as me,ft as he,g as I,p as ge,pt as _e,u as ve,v as ye,wt as be}from"./control-ui-core-D08sO3TC.js";import{A as xe,j as Se}from"./config-runtime-BxOat2Bj.js";import{i as Ce,l as we,o as L,s as Te,t as R}from"./control-ui-core-DTinBYL8.js";import{$ as Ee,B as De,F as Oe,L as ke,M as z,N as Ae,R as je,it as Me,rt as B,z as Ne}from"./control-ui-core-DYkQMwnN.js";import{a as Pe,c as Fe,l as Ie,n as Le,s as Re,t as ze,u as Be}from"./control-ui-shared-7wH5xFOU.js";import{n as Ve,t as He}from"./settings-workspace-CkAuViph.js";import{a as Ue,c as V,d as H,f as U,i as We,l as W,n as Ge,o as G,r as Ke,s as K,t as q}from"./settings-ui-tqfn2bXq.js";import{a as qe,n as Je,t as Ye}from"./config-form-B-FFmL7_.js";import{i as Xe,n as Ze,o as Qe,t as $e}from"./realtime-talk-input-C1i3NNd3.js";import{a as et,i as tt}from"./fast-mode-DsV4zPDB.js";import{n as nt,t as rt}from"./redact-sensitive-url-Bm4EghNY.js";import{t as it}from"./web-awesome-select-DB7g84Rf.js";function at(e){return N(N(e.mcp)?.servers)??{}}function ot(e,t){let n=N(t)??{},r=typeof n.url==`string`?n.url:``,i=typeof n.command==`string`?n.command:``,a=r?`http`:i?`stdio`:`invalid`,o=typeof n.auth==`string`?n.auth:null,s=r||i||L(`mcpPage.missingTransport`),c=n.sslVerify===!1?L(`mcpPage.tlsVerifyOff`):n.clientCert||n.clientKey?L(`mcpPage.mtls`):null;return{name:e,enabled:n.enabled!==!1,transport:a,auth:o,launch:r?nt(s):s,toolFilter:!!n.toolFilter,parallel:n.supportsParallelToolCalls===!0,tls:c}}function st(e){return/^[A-Za-z0-9._:/-]+$/.test(e)?e:`'${e.replaceAll(`'`,`'\\''`)}'`}function ct(e){let t=st(e.name),n=`openclaw mcp probe ${t}`,r=`openclaw mcp login ${t}`,i=[e.transport,e.auth,e.toolFilter?L(`mcpPage.toolFilter`):null,e.parallel?L(`mcpPage.parallel`):null,e.tls].filter(e=>!!e);return w`
    <div class="settings-row mcp-server-row">
      <div class="settings-row__text">
        <span class="settings-row__title">${e.name}</span>
        <span class="settings-row__desc mcp-server-row__launch">${e.launch}</span>
        <span class="settings-row__desc">${i.join(` · `)}</span>
      </div>
      <div class="settings-row__control">
        ${W({kind:e.enabled?`ok`:`muted`,label:e.enabled?L(`common.enabled`):L(`common.disabled`)})}
        <code>${e.auth===`oauth`?r:n}</code>
      </div>
    </div>
  `}function lt(e){let t=Object.entries(at(e.configObject)).map(([e,t])=>ot(e,t)).toSorted((e,t)=>e.name.localeCompare(t.name)),n=t.filter(e=>e.enabled).length,r=t.filter(e=>e.auth===`oauth`).length,i=t.filter(e=>e.toolFilter).length;return w`
    <section class="mcp-page">
      <div class="settings-page">
        <section class="settings-section mcp-page__summary">
          <div class="settings-section__header">
            <h2 class="settings-section__heading">${L(`mcpPage.servers`)}</h2>
          </div>
          <div class="settings-group">
            ${G({title:L(`mcpPage.servers`),control:U(t.length)})}
            ${G({title:L(`common.enabled`),control:U(n)})}
            ${G({title:L(`mcpPage.oauth`),control:U(r)})}
            ${G({title:L(`mcpPage.filtered`),control:U(i)})}
          </div>
        </section>

        <section class="settings-section">
          <div class="settings-section__header">
            <h2 class="settings-section__heading">${L(`mcpPage.operatorCommands`)}</h2>
          </div>
          <p class="settings-section__desc">${L(`mcpPage.operatorCommandsHint`)}</p>
          <div class="settings-group">
            <div class="settings-row settings-row--stacked">
              <div class="mcp-command-card__grid">
                <code>openclaw mcp status --verbose</code>
                <code>openclaw mcp doctor --probe</code>
                <code>openclaw mcp login &lt;name&gt;</code>
                <code>openclaw mcp reload</code>
              </div>
            </div>
          </div>
        </section>

        <section class="settings-section mcp-server-list">
          <div class="settings-section__header">
            <h2 class="settings-section__heading">${L(`mcpPage.configuredServers`)}</h2>
          </div>
          <p class="settings-section__desc">
            ${L(`mcpPage.runtimeHint`)}
            <a href=${e.pluginsHref}>${L(`mcpPage.manageServersLink`)}</a>
          </p>
          <div class="settings-group">
            ${t.length?t.map(e=>ct(e)):Ge(L(`mcpPage.noServers`))}
          </div>
        </section>
      </div>

      ${e.editor}
    </section>
  `}var ut=e((()=>{rt(),M(),E(),q(),R()}));function dt(e,t){return w`
    <wa-select
      class="settings-select"
      value=${e}
      @change=${e=>t(e.currentTarget.value)}
    >
      <span slot="label" class="settings-control__sr-label">${L(`quickSettings.language`)}</span>
      ${Te.map(t=>{let n=L(`languages.${t.replace(/-([a-zA-Z])/g,(e,t)=>t.toUpperCase())}`);return w`
          <wa-option value=${t} .label=${n} .selected=${t===e}>
            ${n}
          </wa-option>
        `})}
    </wa-select>
  `}var ft=e((()=>{E(),it(),R()}));function pt(e){return G({title:e.title,control:w`
      <select
        class="settings-select"
        ?data-settings-send-shortcut=${e.setting===`send-shortcut`}
        ?data-settings-follow-up-mode=${e.setting===`follow-up-mode`}
        ?data-settings-catalog-open-target=${e.setting===`catalog-open-target`}
        aria-label=${e.title}
        .value=${e.value}
        @change=${t=>e.onChange(t.currentTarget.value)}
      >
        ${e.options.map(t=>w`
            <option value=${t.value} ?selected=${e.value===t.value}>
              ${t.label}
            </option>
          `)}
      </select>
    `})}var mt=e((()=>{E(),q()}));function ht(){return{rawRevealed:!1,rawDiffOpen:!1,envRevealed:!1,validityDismissed:!1,revealedSensitivePaths:new Set,lastCustomThemeImportFocusToken:null,lastConfigContextKey:null,lastFormModeForScroll:null}}function gt(e){return Y[e]??Y.default}function _t(e,t){if(!e||Be(e)!==`object`||!e.properties)return e;let n=t.include,r=t.exclude,i={};for(let t of Object.keys(e.properties)){if(n&&n.size>0&&!n.has(t)||r&&r.size>0&&r.has(t))continue;let a=e.properties[t];a&&(i[t]=a)}return{...e,properties:i}}function vt(e){return!e||typeof e!=`object`||Array.isArray(e)?null:e}function yt(e){return e?.length?e.join(``):``}function bt(e,t,n,r,i,a){let o=yt(n),s=yt(r),c=e.schemaAnalysisCache;if(c&&c.schema===t&&c.includeKey===o&&c.excludeKey===s)return c.analysis;let l=Je(_t(t,{include:i,exclude:a}));return e.schemaAnalysisCache={schema:t,includeKey:o,excludeKey:s,analysis:l},l}function xt(e){return e.length>0?e.join(`.`):L(`configView.root`)}function St(e,t){if(!e||!t)return[];let n=[],r=0;function i(e,t,r){n.length<qt&&n.push({path:e,from:t,to:r})}function a(e,t,n){if(e.length!==t.length||e.length>Jt)return!0;for(let r=0;r<e.length;r+=1)if(s(e[r],t[r],n+1))return!0;return!1}function o(e,t,n){let r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!0;for(let i of r)if(!Object.hasOwn(t,i)||s(e[i],t[i],n+1))return!0;return!1}function s(e,t,n){return r+=1,r>Kt||n>Gt?!0:e===t?!1:typeof e==typeof t?typeof e!=`object`||!e||t===null?e!==t:Array.isArray(e)||Array.isArray(t)?Array.isArray(e)&&Array.isArray(t)?a(e,t,n+1):!0:o(e,t,n+1):!0}function c(e,t,o,s){if(r+=1,r>Kt||s>Gt||n.length>=qt||e===t)return;if(typeof e!=typeof t){i(o,e,t);return}if(typeof e!=`object`||!e||t===null){e!==t&&i(o,e,t);return}if(Array.isArray(e)||Array.isArray(t)){(Array.isArray(e)&&Array.isArray(t)&&a(e,t,s+1)||!Array.isArray(e)||!Array.isArray(t))&&i(o,e,t);return}let l=e,u=t,d=new Set([...Object.keys(l),...Object.keys(u)]);for(let e of d)c(l[e],u[e],[...o,e],s+1)}return c(e,t,[],0),n}function Ct(e,t,n){if(e.rawDiffCache?.original===t&&e.rawDiffCache.current===n)return e.rawDiffCache.diff;if(t.length>X||n.length>X)return e.rawDiffCache={original:t,current:n,diff:[]},e.rawDiffCache.diff;try{let r=Se.parse(t),i=Se.parse(n);if(!r||!i||typeof r!=`object`||typeof i!=`object`||Array.isArray(r)||Array.isArray(i))return e.rawDiffCache={original:t,current:n,diff:[]},[];let a=St(r,i);return e.rawDiffCache={original:t,current:n,diff:a},a}catch{return e.rawDiffCache={original:t,current:n,diff:[]},[]}}function wt(e,t=40){if(Array.isArray(e))return L(e.length===1?`configView.itemCount`:`configView.itemCountPlural`,{count:String(e.length)});let n;try{n=JSON.stringify(e)??String(e)}catch{n=String(e)}return n.length<=t?n:A(n,t-3)+`...`}function Tt(e,t){let n=e.split(`.`);return n.length===t.length?n.every((e,n)=>e===`*`||e===t[n]):!1}function Et(e,t){return Object.entries(t).some(([t,n])=>!!n.sensitive&&Tt(t,e))}function Dt(e,t){for(let n=1;n<=e.length;n+=1){let r=e.slice(0,n),i=xt(r);if((Pe(r,t)?.sensitive??!1)||Et(r,t)||Fe(i))return!0}return!1}function Ot(e,t,n,r){let i=Le(t,e,n)>0;return!r&&t!=null&&(Dt(e,n)||i)?ze:wt(t)}function kt(e){return e.hasCustomTheme&&e.customThemeLabel?e.customThemeLabel:L(`configView.appearance.importedTheme`)}function At(){(typeof requestAnimationFrame==`function`?requestAnimationFrame:e=>window.setTimeout(()=>e(0),0))(()=>{let e=globalThis.document?.querySelector(`[data-custom-theme-import-input]`);e&&(typeof e.scrollIntoView==`function`&&e.scrollIntoView({block:`center`,behavior:`smooth`}),e.focus(),e.select())})}function jt(e){let t=e.webPush;if(!t)return w`
      <div class="settings-page">
        <section class="settings-section" id=${f.notifications}>
          <div class="settings-section__header">
            <h2 class="settings-section__heading">${L(`configView.notifications.title`)}</h2>
            <div class="settings-section__actions">
              ${W({kind:`muted`,label:L(`configView.notifications.unavailable`)})}
            </div>
          </div>
          <div class="settings-group">
            <div class="settings-row">
              <div class="settings-row__text">
                <span class="settings-row__desc">
                  ${L(`configView.notifications.unavailableHint`)}
                </span>
              </div>
            </div>
          </div>
        </section>
      </div>
    `;let n=t.permission===`granted`?L(`configView.notifications.granted`):t.permission===`denied`?L(`configView.notifications.denied`):t.permission==="default"?L(`configView.notifications.notRequested`):L(`configView.notifications.unsupported`),r=t.subscribed?L(`configView.notifications.subscribed`):L(`configView.notifications.notSubscribed`),i=t.supported?t.permission===`denied`?L(`configView.notifications.blocked`):t.subscribed?L(`configView.notifications.subscribed`):L(`configView.notifications.ready`):L(`configView.notifications.unsupported`),a=t.supported?t.permission===`denied`?`danger`:t.subscribed?`ok`:`accent`:`muted`,o=t.supported&&t.permission!==`denied`?t.subscribed?w`
            <button
              class="btn"
              ?disabled=${t.loading||!e.connected}
              @click=${()=>e.onWebPushUnsubscribe?.()}
            >
              ${B.x} ${L(`configView.notifications.unsubscribe`)}
            </button>
            <button
              class="btn primary"
              ?disabled=${t.loading||!e.connected}
              @click=${()=>e.onWebPushTest?.()}
            >
              ${B.send} ${L(`configView.notifications.sendTest`)}
            </button>
          `:w`
            <button
              class="btn primary"
              ?disabled=${t.loading||!e.connected}
              @click=${()=>e.onWebPushSubscribe?.()}
            >
              ${t.loading?B.loader:O}
              ${t.loading?L(`configView.notifications.subscribing`):L(`configView.notifications.enable`)}
            </button>
          `:O;return w`
    <div class="settings-page">
      <section class="settings-section" id=${f.notifications}>
        <div class="settings-section__header">
          <h2 class="settings-section__heading">${L(`configView.notifications.title`)}</h2>
          <div class="settings-section__actions">
            ${W({kind:a,label:i})}
          </div>
        </div>
        <p class="settings-section__desc">${L(`configView.notifications.hint`)}</p>
        <div class="settings-group">
          ${G({title:L(`configView.notifications.browserSupport`),control:U(t.supported?L(`configView.notifications.available`):L(`configView.notifications.notSupported`))})}
          ${G({title:L(`configView.notifications.permission`),control:U(n)})}
          ${G({title:L(`configView.notifications.status`),control:W({kind:t.subscribed?`ok`:`muted`,label:r})})}
          ${o===O?O:w`
                <div class="settings-row">
                  <div class="settings-row__control">${o}</div>
                </div>
              `}
          ${t.permission===`denied`?G({title:L(`configView.notifications.blocked`),description:L(`configView.notifications.blockedHint`),control:W({kind:`danger`,label:L(`configView.notifications.denied`)})}):O}
          ${t.error?w`
                <div class="settings-row">
                  <div class="settings-row__text">
                    <span class="cfg-field__error">${t.error}</span>
                  </div>
                </div>
              `:O}
        </div>
      </section>
    </div>
  `}function Mt(e){let t=e.microphone;if(!t||!e.onMicrophoneSelect)return O;let n=t.selectedDeviceId.trim(),r=t.devices.some(e=>e.deviceId===n),i=[{label:L(`chat.composer.systemDefaultMicrophone`),value:``},...t.devices.map(e=>({label:e.label,value:e.deviceId})),...n&&!r?[{label:L(`chat.composer.microphoneFallback`,{number:String(t.devices.length+1)}),value:n}]:[]],a=`${L(`common.refresh`)}: ${L(`chat.composer.microphoneInput`)}`,o=t.error?w`<span role="alert">${t.error}</span>`:!t.loading&&t.devices.length===0?L(`chat.composer.noMicrophones`):void 0;return G({title:L(`chat.composer.microphoneInput`),description:o,control:w`
      <select
        class="settings-select"
        data-settings-microphone
        aria-label=${L(`chat.composer.microphoneInput`)}
        .value=${n}
        @change=${t=>e.onMicrophoneSelect?.(t.currentTarget.value)}
      >
        ${i.map(e=>w`
            <option value=${e.value} ?selected=${e.value===n}>
              ${e.label}
            </option>
          `)}
      </select>
      <button
        type="button"
        class="btn btn--sm btn--icon"
        aria-label=${a}
        ?disabled=${t.loading}
        @click=${()=>e.onMicrophoneRefresh?.()}
      >
        ${t.loading?B.loader:B.refresh}
      </button>
    `})}function Nt(e){let t=e.chatFollowUpMode??`server`,n=e.serverQueueMode??L(`chat.followUpModeLoading`),r=e.chatFollowUpMode?L(`chat.followUpModeOverriding`,{mode:n}):L(`chat.followUpModeUsingServer`,{mode:n});return w`
    <section id=${c.chat} class="settings-section">
      <div class="settings-section__header">
        <h2 class="settings-section__heading">${L(`configView.chatPrefs.title`)}</h2>
      </div>
      <p class="settings-section__desc">${L(`configView.chatPrefs.hint`)}</p>
      <div class="settings-group">
        ${pt({title:L(`chat.sendShortcut`),value:e.chatSendShortcut,setting:`send-shortcut`,options:[{value:`enter`,label:L(`chat.sendShortcutEnter`)},{value:`modifier-enter`,label:L(`chat.sendShortcutModifierEnter`)}],onChange:t=>e.setChatSendShortcut(fe(t))})}
        ${G({title:L(`chat.followUpMode`),description:r,control:w`
            <select
              class="settings-select"
              data-settings-follow-up-mode
              aria-label=${L(`chat.followUpMode`)}
              .value=${t}
              @change=${t=>{let n=t.currentTarget.value;e.setChatFollowUpMode(n===`server`?void 0:ye(n))}}
            >
              <option value="server" ?selected=${t===`server`}>
                ${L(`chat.followUpModeServer`,{mode:n})}
              </option>
              <option value="steer" ?selected=${t===`steer`}>
                ${L(`chat.followUpModeSteer`)}
              </option>
              <option value="queue" ?selected=${t===`queue`}>
                ${L(`chat.followUpModeQueue`)}
              </option>
            </select>
            ${e.chatFollowUpMode?w`
                  <button
                    type="button"
                    class="btn btn--sm"
                    @click=${()=>e.setChatFollowUpMode(void 0)}
                  >
                    ${L(`chat.followUpModeReset`)}
                  </button>
                `:O}
          `})}
        ${pt({title:L(`chat.catalogOpenTarget`),value:e.catalogOpenTarget,setting:`catalog-open-target`,options:[{value:`viewer`,label:L(`chat.catalogOpenTargetViewer`)},{value:`terminal`,label:L(`chat.catalogOpenTargetTerminal`)}],onChange:t=>e.setCatalogOpenTarget(de(t))})}
        ${Mt(e)}
      </div>
    </section>
  `}function Pt(e){if(!e.setLobsterPetVisits||!e.setLobsterPetSounds)return O;let t=e.lobsterPetVisits===!0,n=e.lobsterPetSounds===!0;return w`
    <section class="settings-section">
      <div class="settings-section__header">
        <h2 class="settings-section__heading">${L(`quickSettings.appearance.lobsterdex`)}</h2>
      </div>
      <div class="settings-group">
        ${H({title:L(`quickSettings.appearance.lobsterVisits`),description:L(t?`quickSettings.appearance.lobsterVisitsOn`:`quickSettings.appearance.lobsterVisitsOff`),checked:t,onChange:t=>e.setLobsterPetVisits?.(t)})}
        ${H({title:L(`quickSettings.appearance.lobsterSounds`),description:L(n?`quickSettings.appearance.lobsterSoundsOn`:`quickSettings.appearance.lobsterSoundsOff`),checked:n,onChange:t=>e.setLobsterPetSounds?.(t)})}
        ${G({title:L(`quickSettings.appearance.lobsterdex`),description:L(`quickSettings.appearance.lobsterdexSeen`,{seen:String(z.filter(e=>je().has(e.id)).length),total:String(z.length)}),stacked:!0,control:w`
            <div class="lobsterdex">
              ${z.map(e=>{let t=Ne().get(e.id),n=t!==void 0,r=n?t.firstSeenAt===null?t.name??e.id:L(`quickSettings.appearance.lobsterdexFirstVisited`,{name:t.name??e.id,date:new Date(t.firstSeenAt).toLocaleDateString()}):`?`;return w`
                  <span
                    class="lobsterdex__mini lobster-pet--palette-${e.id} ${n?``:`lobsterdex__mini--unseen`}"
                    style="--lob-shell:${e.shell};--lob-claw:${e.claw}"
                    title=${r}
                  >
                    ${ke(Ae(e),{standalone:!0})}
                  </span>
                `})}
            </div>
          `})}
      </div>
    </section>
  `}function Ft(e){let t=e.viewState,n=e.hasCustomTheme||e.customThemeImportExpanded===!0;n&&e.customThemeImportFocusToken!=null&&e.customThemeImportFocusToken!==t.lastCustomThemeImportFocusToken&&(t.lastCustomThemeImportFocusToken=e.customThemeImportFocusToken,At());let r=kt(e),i=[...Yt.map(e=>({id:e.id,label:L(e.labelKey),description:L(e.descriptionKey),icon:e.icon})),{id:`custom`,label:e.hasCustomTheme?r:L(`configView.appearance.import`),description:e.hasCustomTheme?L(`configView.appearance.importedFrom`,{name:r}):L(`configView.appearance.importHint`),icon:B.spark}];return w`
    <div class="settings-page">
      <section id=${c.theme} class="settings-section">
        <div class="settings-section__header">
          <h2 class="settings-section__heading">${L(`configView.appearance.theme`)}</h2>
        </div>
        <p class="settings-section__desc">${L(`configView.appearance.chooseTheme`)}</p>
        <div class="settings-group">
          <div class="settings-row settings-row--stacked">
            <div class="settings-theme-grid">
              ${i.map(t=>w`
                  <button
                    class="settings-theme-card ${t.id===e.theme?`settings-theme-card--active`:``}"
                    title=${t.description}
                    @click=${n=>{if(t.id===`custom`&&!e.hasCustomTheme){e.onOpenCustomThemeImport?.();return}if(t.id!==e.theme){let r={element:n.currentTarget??void 0};e.setTheme(t.id,r)}}}
                  >
                    <span class="settings-theme-card__icon" aria-hidden="true">${t.icon}</span>
                    <span class="settings-theme-card__label">${t.label}</span>
                    ${t.id===e.theme?w`<span class="settings-theme-card__check" aria-hidden="true"
                          >${B.check}</span
                        >`:O}
                  </button>
                `)}
            </div>
          </div>
          <div class="settings-row settings-row--stacked">
            ${n?w`
                  <div class="settings-theme-import">
                    <div class="settings-theme-import__copy">
                      <div class="settings-theme-import__title">
                        ${L(`configView.appearance.importFromTweakcn`)}
                      </div>
                      <p class="settings-theme-import__hint">
                        ${L(`configView.appearance.tweakcnInstructions`)}
                      </p>
                    </div>
                    <a
                      class="settings-theme-import__external"
                      href="https://tweakcn.com/editor/theme"
                      target="_blank"
                      rel="noreferrer noopener"
                    >
                      ${L(`configView.appearance.browseTweakcn`)} ${B.externalLink}
                    </a>
                    <label class="settings-theme-import__field">
                      <span class="settings-theme-import__label"
                        >${L(`configView.appearance.themeLink`)}</span
                      >
                      <input
                        class="settings-theme-import__input"
                        data-custom-theme-import-input
                        type="text"
                        spellcheck="false"
                        placeholder="https://tweakcn.com/editor/theme?theme=... or amethyst-haze"
                        .value=${e.customThemeImportUrl}
                        @input=${t=>e.onCustomThemeImportUrlChange(t.currentTarget.value)}
                      />
                    </label>
                    <div class="settings-theme-import__actions">
                      <button
                        class="btn btn--sm primary"
                        ?disabled=${e.customThemeImportBusy||e.customThemeImportUrl.trim().length===0}
                        @click=${e.onImportCustomTheme}
                      >
                        ${e.customThemeImportBusy?L(`common.importing`):e.hasCustomTheme?L(`configView.appearance.replace`,{name:r}):L(`configView.appearance.importTheme`)}
                      </button>
                      ${e.hasCustomTheme?w`
                            <button class="btn btn--sm danger" @click=${e.onClearCustomTheme}>
                              ${L(`configView.appearance.clear`,{name:r})}
                            </button>
                          `:O}
                    </div>
                    ${e.hasCustomTheme?w`
                          <div class="settings-theme-import__meta">
                            <span class="settings-theme-import__meta-label"
                              >${L(`configView.appearance.loaded`)}</span
                            >
                            <span class="settings-theme-import__meta-value"
                              >${r} · ${e.customThemeSourceUrl??`tweakcn`}</span
                            >
                          </div>
                        `:O}
                    ${e.customThemeImportMessage?w`
                          <div
                            class="settings-theme-import__message settings-theme-import__message--${e.customThemeImportMessage.kind}"
                          >
                            ${e.customThemeImportMessage.text}
                          </div>
                        `:O}
                  </div>
                `:w`
                  <p class="settings-theme-import__inline-hint">
                    ${L(`configView.appearance.inlineHintBefore`)}
                    <strong>${L(`configView.appearance.import`)}</strong>
                    ${L(`configView.appearance.inlineHintAfter`)}
                  </p>
                `}
          </div>
        </div>
      </section>

      <section id=${c.textSize} class="settings-section">
        <div class="settings-section__header">
          <h2 class="settings-section__heading">${L(`configView.appearance.textSize`)}</h2>
        </div>
        <div class="settings-group">
          <div class="settings-row settings-row--stacked">
            <div class="settings-text-scale">
              <div class="settings-text-scale__options">
                ${me.map(t=>w`
                    <button
                      type="button"
                      class="settings-text-scale__btn ${t===e.textScale?`active`:``}"
                      @click=${()=>e.setTextScale(t)}
                    >
                      <span class="settings-text-scale__sample">${L(Ht[t])}</span>
                      <span class="settings-text-scale__label">${t}%</span>
                    </button>
                  `)}
              </div>
            </div>
          </div>
        </div>
      </section>

      ${Pt(e)} ${Nt(e)}

      <section id=${c.connection} class="settings-section">
        <div class="settings-section__header">
          <h2 class="settings-section__heading">${L(`configView.connection.title`)}</h2>
        </div>
        <div class="settings-group">
          ${G({title:L(`configView.connection.gateway`),control:U(e.gatewayUrl||`-`,{mono:!0})})}
          ${G({title:L(`configView.connection.status`),control:W({kind:e.connected?`ok`:`muted`,label:e.connected?L(`common.connected`):L(`common.offline`)})})}
          ${e.assistantName?G({title:L(`configView.connection.assistant`),control:U(e.assistantName)}):O}
        </div>
      </section>
    </div>
  `}function It(e){return e.needsApply?w`
    <div class="config-apply-banner" role="status">
      <span class="config-apply-banner__text">${L(`configView.applyBannerText`)}</span>
      <button
        class="btn btn--sm"
        ?disabled=${e.busy||e.applying||!e.connected}
        aria-busy=${e.applying?`true`:`false`}
        @click=${e.onApply}
      >
        ${Xt(e.applying,L(`configView.applyBannerAction`),L(`configView.applying`))}
      </button>
    </div>
  `:O}function Lt(e){switch(e.status){case`saving`:return W({kind:`accent`,label:L(`configView.autoSaveSaving`)});case`saved`:return W({kind:`ok`,label:L(`configView.autoSaveSaved`)});case`error`:return w`
        ${W({kind:`danger`,label:L(`configView.autoSaveFailed`)})}
        <button class="btn btn--sm" @click=${e.onRetry}>${L(`configView.retry`)}</button>
      `;case`conflict`:return w`
        ${W({kind:`danger`,label:L(`configView.autoSaveConflict`)})}
        <button class="btn btn--sm" @click=${e.onReload}>${L(`common.reload`)}</button>
      `;default:return O}}function Rt(e){e.rawRevealed=!1,e.rawDiffOpen=!1,e.envRevealed=!1,e.validityDismissed=!1,e.revealedSensitivePaths.clear(),e.lastCustomThemeImportFocusToken=null,e.rawDiffCache=void 0}function zt(e){let t=e.includeSections?.join(``)??``,n=e.excludeSections?.join(``)??``;return[e.configPath??``,e.gatewayUrl,e.navRootLabel??``,t,n].join(``)}function Bt(e,t){let n=Ie(t);return n?e.revealedSensitivePaths.has(n):!1}function Vt(e,t){let n=Ie(t);n&&(e.revealedSensitivePaths.has(n)?e.revealedSensitivePaths.delete(n):e.revealedSensitivePaths.add(n))}function J(e){let t=e.viewState,n=e.showModeToggle??!1,r=e.showRootTab??!0,i=e.valid==null?`unknown`:e.valid?`valid`:`invalid`,a=e.includeVirtualSections??!0,o=e.includeSections?.length?new Set(e.includeSections):null,s=e.excludeSections?.length?new Set(e.excludeSections):null,c=bt(t,vt(e.schema),e.includeSections,e.excludeSections,o,s),l=c.schema?c.unsupportedPaths.length>0:!1,u=e.rawAvailable??!0,d=!!e.rawDraftPending&&u,ee=n&&u?e.formMode:`form`,f=d?`raw`:ee,p=e.onViewStateChange,m=e=>{queueMicrotask(()=>{let t=[(e instanceof Element?e:null)?.closest(`.config-lead`)?.parentElement?.querySelector(`.config-content`)??globalThis.document?.querySelector(`.config-content`),globalThis.document?.querySelector(`.shell--settings .content`)];for(let e of t)e&&(typeof e.scrollTo==`function`?e.scrollTo({top:0,left:0,behavior:`auto`}):(e.scrollTop=0,e.scrollLeft=0))})};t.lastFormModeForScroll!==null&&t.lastFormModeForScroll!==f&&m(null),t.lastFormModeForScroll=f;let h=zt(e);t.lastConfigContextKey!==h&&(Rt(t),t.lastConfigContextKey=h);let g=t.envRevealed,_=c.schema?.properties??{},v=new Set([`__appearance__`,`__notifications__`]),te=e=>a&&v.has(e)&&(e===`__appearance__`||o?.has(e)===!0),y=e=>L(`configView.sections.${e===`__appearance__`?`theme`:e===`__notifications__`?`notifications`:e}`),b=Ut.map(e=>({id:e.id,label:L(`configView.categories.${e.id}`),sections:e.sections.filter(e=>(te(e)||e in _)&&(!o||o.has(e))&&(!s||!s.has(e))).map(e=>({key:e,label:y(e)}))})).filter(e=>e.sections.length>0),x=Object.keys(_).filter(e=>!Wt.has(e)).map(e=>({key:e,label:e.charAt(0).toUpperCase()+e.slice(1)})),S=x.length>0?{id:`other`,label:L(`configView.categories.other`),sections:x}:null,C=[...r?[{key:null,label:e.navRootLabel??L(`nav.settings`)}]:[],...[...b,...S?[S]:[]].flatMap(e=>e.sections.map(e=>({key:e.key,label:e.label})))],T=e.settingsLayout??`tabs`,E=[...b,...S?[S]:[]];function D(){return w`
      <div class="config-accordion-nav">
        ${E.map(t=>w`
            <div class="config-accordion-group">
              <button
                class="config-accordion-group__header ${e.activeSection!=null&&t.sections.some(t=>t.key===e.activeSection)?`config-accordion-group__header--active`:``}"
                @click=${n=>{let r=t.sections[0]?.key??null,i=t.sections.some(t=>t.key===e.activeSection);e.onSectionChange(i?null:r),m(n.currentTarget)}}
              >
                <span class="config-accordion-group__icon">
                  ${gt(t.sections[0]?.key??`default`)}
                </span>
                <span>${t.label}</span>
                <svg
                  class="config-accordion-group__chevron ${t.sections.some(t=>t.key===e.activeSection)?`config-accordion-group__chevron--open`:``}"
                  viewBox="0 0 24 24"
                  fill="none"
                  stroke="currentColor"
                  stroke-width="2"
                  width="14"
                  height="14"
                >
                  <polyline points="6 9 12 15 18 9"></polyline>
                </svg>
              </button>
              ${t.sections.some(t=>t.key===e.activeSection)?w`
                    <div class="config-accordion-group__items">
                      ${t.sections.map(t=>w`
                          <button
                            class="config-accordion-group__item ${e.activeSection===t.key?`config-accordion-group__item--active`:``}"
                            @click=${n=>{e.onSectionChange(t.key),m(n.currentTarget)}}
                          >
                            <span class="config-accordion-group__item-icon">
                              ${gt(t.key)}
                            </span>
                            ${t.label}
                          </button>
                        `)}
                    </div>
                  `:O}
            </div>
          `)}
      </div>
    `}let k=f===`raw`&&e.raw!==e.originalRaw;(!k||f!==`raw`)&&t.rawDiffOpen&&(t.rawDiffOpen=!1),(!k||f!==`raw`||!t.rawDiffOpen)&&(t.rawDiffCache=void 0);let A=f===`raw`&&k&&t.rawDiffOpen?Ct(t,e.originalRaw,e.raw):[],j=e.loading||e.saving||e.applying||e.updating,M=e.connected&&!j&&k,N=Lt({status:e.autoSaveStatus,onRetry:e.onSave,onReload:e.onRawDiscard}),ne=a&&f===`form`&&e.activeSection===null&&!!o?.has(`__appearance__`),re=k&&f===`raw`?w`
          <details
            class="config-diff"
            ?open=${t.rawDiffOpen}
            @toggle=${e=>{let n=e.target;t.rawDiffOpen!==n.open&&(t.rawDiffOpen=n.open,n.open||(t.rawDiffCache=void 0),p())}}
          >
            <summary class="config-diff__summary">
              <span>${L(`configView.viewPendingChangesRaw`)}</span>
              <svg
                class="config-diff__chevron"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
              >
                <polyline points="6 9 12 15 18 9"></polyline>
              </svg>
            </summary>
            <div class="config-diff__content">
              ${A.length>0?A.map(n=>w`
                      <div class="config-diff__item">
                        <div class="config-diff__path">${xt(n.path)}</div>
                        <div class="config-diff__values">
                          <span class="config-diff__from"
                            >${Ot(n.path,n.from,e.uiHints,t.rawRevealed)}</span
                          >
                          <span class="config-diff__arrow">→</span>
                          <span class="config-diff__to"
                            >${Ot(n.path,n.to,e.uiHints,t.rawRevealed)}</span
                          >
                        </div>
                      </div>
                    `):w`<div class="config-diff__item">${L(`configView.rawDiffUnavailable`)}</div>`}
            </div>
          </details>
        `:O,ie=T!==`accordion`&&C.length>1,ae=ie?V({value:e.activeSection??`root`,options:C.map(e=>({value:e.key??`root`,label:e.label})),ariaLabel:L(`common.settingsSections`),onChange:(t,n)=>{e.onSectionChange(t===`root`?null:t),m(n)}}):O,oe=n||ie||N!==O,se=It({needsApply:e.needsApply,applying:e.applying,busy:e.saving||e.loading||e.updating||e.autoSaveStatus===`saving`||k,connected:e.connected,onApply:e.onApply}),P=i===`invalid`&&!t.validityDismissed,F=oe||T===`accordion`||se!==O||P,ce=w`
    <div class="config-lead">
      ${oe?w`
            <div class="config-toolbar">
              ${n?w`
                    <div class="config-mode-toggle">
                      <button
                        class="config-mode-toggle__btn ${f===`form`?`active`:``}"
                        ?disabled=${e.schemaLoading||!e.schema||d}
                        title=${d?L(`configView.rawDraftPendingFormTitle`):l?L(`configView.formUnsafeTitle`):``}
                        @click=${()=>e.onFormModeChange(`form`)}
                      >
                        ${L(`configView.form`)}
                      </button>
                      <button
                        class="config-mode-toggle__btn ${f===`raw`?`active`:``}"
                        ?disabled=${!u}
                        title=${L(u?`configView.rawTitle`:`configView.rawUnavailableTitle`)}
                        @click=${()=>e.onFormModeChange(`raw`)}
                      >
                        ${L(`configView.raw`)}
                      </button>
                    </div>
                  `:O}
              ${ae}
              <div class="config-toolbar__status" role="status" aria-live="polite">
                ${N}
              </div>
            </div>
          `:O}
      ${T===`accordion`?D():O} ${se}
      ${P?w`
            <div class="config-validity-warning">
              <svg
                class="config-validity-warning__icon"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
                stroke-linecap="round"
                stroke-linejoin="round"
                width="16"
                height="16"
              >
                <path
                  d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"
                ></path>
                <line x1="12" y1="9" x2="12" y2="13"></line>
                <line x1="12" y1="17" x2="12.01" y2="17"></line>
              </svg>
              <span class="config-validity-warning__text">${L(`configView.invalidConfig`)}</span>
              <button
                class="btn btn--sm"
                @click=${()=>{t.validityDismissed=!0,p()}}
              >
                ${L(`configView.dismissWarning`)}
              </button>
            </div>
          `:O}
    </div>
  `;return w`
    ${F?ce:O}
    <!-- Form content -->
    <div
      id="config-section-panel"
      class="config-content"
      role="region"
      aria-label=${L(`common.settingsSections`)}
    >
      ${e.activeSection===`__appearance__`?a?Ft(e):O:e.activeSection===`__notifications__`?a?jt(e):O:f===`form`?w`
                ${l&&n&&u?w`<div class="callout info">${L(`configView.formUnsafe`)}</div>`:O}
                ${ne?Ft(e):O}
                ${e.schemaLoading?w`
                      <div class="config-loading">
                        <div class="config-loading__spinner"></div>
                        <span>${L(`configView.loadingSchema`)}</span>
                      </div>
                    `:qe({schema:c.schema,uiHints:e.uiHints,value:e.formValue,rawAvailable:u,disabled:j||!e.formValue,unsupportedPaths:c.unsupportedPaths,onPatch:e.onFormPatch,activeSection:e.activeSection,activeSubsection:null,sectionActions:e.activeSection===`env`?w`
                              <button
                                class="btn btn--sm ${g?`active`:``}"
                                aria-pressed=${g?`true`:`false`}
                                title=${L(g?`configView.hideEnvValues`:`configView.revealEnvValues`)}
                                @click=${()=>{t.envRevealed=!t.envRevealed,p()}}
                              >
                                ${g?B.eyeOff:B.eye}
                                ${L(`configView.peek`)}
                              </button>
                            `:void 0,revealSensitive:e.activeSection===`env`?g:!1,isSensitivePathRevealed:e=>Bt(t,e),onToggleSensitivePath:e=>{Vt(t,e),p()}})}
              `:(()=>{let n=Le(e.formValue,[],e.uiHints),r=n>0&&!t.rawRevealed;return w`
                  <div class="settings-page">
                    ${re}
                    <!-- Raw editor: one group surface owning file-level operations. -->
                    <div class="settings-group">
                      <div class="settings-row settings-row--stacked">
                        <div class="config-raw-actions">
                          ${e.onOpenFile?w`
                                <button class="btn btn--sm" @click=${e.onOpenFile}>
                                  ${B.fileText} ${L(`configView.open`)}
                                </button>
                              `:O}
                          <button
                            class="btn btn--sm"
                            ?disabled=${j||!k}
                            @click=${e.onRawDiscard}
                          >
                            ${L(`configView.rawDiscard`)}
                          </button>
                          <button
                            class="btn btn--sm primary"
                            ?disabled=${!M}
                            aria-busy=${e.saving?`true`:`false`}
                            @click=${e.onSave}
                          >
                            ${Xt(e.saving,L(`common.save`),L(`common.saving`))}
                          </button>
                        </div>
                        <div class="field config-raw-field">
                          <span style="display:flex;align-items:center;gap:8px;">
                            ${L(`configView.rawConfig`)}
                            ${n>0?w`
                                  <span class="settings-count"
                                    >${L(n===1?`configView.secretCount`:`configView.secretCountPlural`,{count:String(n)})}
                                    ${L(r?`configView.redacted`:`configView.visible`)}</span
                                  >
                                  <openclaw-tooltip
                                    .content=${L(r?`configView.revealSensitive`:`configView.hideSensitive`)}
                                  >
                                    <button
                                      class="btn btn--icon config-raw-toggle ${r?``:`active`}"
                                      aria-label=${L(`configView.toggleRawRedaction`)}
                                      aria-pressed=${!r}
                                      @click=${()=>{t.rawRevealed=!t.rawRevealed,p()}}
                                    >
                                      ${r?B.eyeOff:B.eye}
                                    </button>
                                  </openclaw-tooltip>
                                `:O}
                          </span>
                          ${r?w`
                                <div class="callout info" style="margin-top: 12px">
                                  ${L(n===1?`configView.sensitiveHidden`:`configView.sensitiveHiddenPlural`,{count:String(n)})}
                                </div>
                              `:w`
                                <textarea
                                  placeholder=${L(`configView.rawConfig`)}
                                  .value=${e.raw}
                                  ?disabled=${j}
                                  @input=${t=>{e.onRawChange(t.target.value)}}
                                ></textarea>
                              `}
                        </div>
                      </div>
                    </div>
                  </div>
                `})()}
      ${e.issues.length>0?w`<div class="callout danger" style="margin-top: 12px;">
            <pre class="code-block">${JSON.stringify(e.issues,null,2)}</pre>
          </div>`:O}
    </div>
  `}var Ht,Y,Ut,Wt,Gt,Kt,qt,Jt,X,Yt,Xt,Zt=e((()=>{j(),xe(),E(),ge(),Re(),Ee(),Ye(),Me(),De(),Oe(),q(),R(),mt(),i(),Ht={90:`configView.textSizes.small`,100:`configView.textSizes.default`,110:`configView.textSizes.large`,125:`configView.textSizes.xl`,140:`configView.textSizes.xxl`},Y={all:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <rect x="3" y="3" width="7" height="7"></rect>
      <rect x="14" y="3" width="7" height="7"></rect>
      <rect x="14" y="14" width="7" height="7"></rect>
      <rect x="3" y="14" width="7" height="7"></rect>
    </svg>
  `,env:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <circle cx="12" cy="12" r="3"></circle>
      <path
        d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"
      ></path>
    </svg>
  `,update:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path>
      <polyline points="7 10 12 15 17 10"></polyline>
      <line x1="12" y1="15" x2="12" y2="3"></line>
    </svg>
  `,agents:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path
        d="M12 2a2 2 0 0 1 2 2c0 .74-.4 1.39-1 1.73V7h1a7 7 0 0 1 7 7h1a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-1v1a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-1H2a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h1a7 7 0 0 1 7-7h1V5.73c-.6-.34-1-.99-1-1.73a2 2 0 0 1 2-2z"
      ></path>
      <circle cx="8" cy="14" r="1"></circle>
      <circle cx="16" cy="14" r="1"></circle>
    </svg>
  `,auth:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect>
      <path d="M7 11V7a5 5 0 0 1 10 0v4"></path>
    </svg>
  `,channels:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
    </svg>
  `,messages:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path>
      <polyline points="22,6 12,13 2,6"></polyline>
    </svg>
  `,commands:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <polyline points="4 17 10 11 4 5"></polyline>
      <line x1="12" y1="19" x2="20" y2="19"></line>
    </svg>
  `,hooks:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path>
      <path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path>
    </svg>
  `,skills:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <polygon
        points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"
      ></polygon>
    </svg>
  `,tools:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path
        d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"
      ></path>
    </svg>
  `,gateway:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <circle cx="12" cy="12" r="10"></circle>
      <line x1="2" y1="12" x2="22" y2="12"></line>
      <path
        d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"
      ></path>
    </svg>
  `,wizard:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M15 4V2"></path>
      <path d="M15 16v-2"></path>
      <path d="M8 9h2"></path>
      <path d="M20 9h2"></path>
      <path d="M17.8 11.8 19 13"></path>
      <path d="M15 9h0"></path>
      <path d="M17.8 6.2 19 5"></path>
      <path d="m3 21 9-9"></path>
      <path d="M12.2 6.2 11 5"></path>
    </svg>
  `,meta:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M12 20h9"></path>
      <path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"></path>
    </svg>
  `,logging:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
      <polyline points="14 2 14 8 20 8"></polyline>
      <line x1="16" y1="13" x2="8" y2="13"></line>
      <line x1="16" y1="17" x2="8" y2="17"></line>
      <polyline points="10 9 9 9 8 9"></polyline>
    </svg>
  `,browser:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <circle cx="12" cy="12" r="10"></circle>
      <circle cx="12" cy="12" r="4"></circle>
      <line x1="21.17" y1="8" x2="12" y2="8"></line>
      <line x1="3.95" y1="6.06" x2="8.54" y2="14"></line>
      <line x1="10.88" y1="21.94" x2="15.46" y2="14"></line>
    </svg>
  `,ui:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
      <line x1="3" y1="9" x2="21" y2="9"></line>
      <line x1="9" y1="21" x2="9" y2="9"></line>
    </svg>
  `,models:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path
        d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"
      ></path>
      <polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline>
      <line x1="12" y1="22.08" x2="12" y2="12"></line>
    </svg>
  `,bindings:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <rect x="2" y="2" width="20" height="8" rx="2" ry="2"></rect>
      <rect x="2" y="14" width="20" height="8" rx="2" ry="2"></rect>
      <line x1="6" y1="6" x2="6.01" y2="6"></line>
      <line x1="6" y1="18" x2="6.01" y2="18"></line>
    </svg>
  `,broadcast:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M4.9 19.1C1 15.2 1 8.8 4.9 4.9"></path>
      <path d="M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5"></path>
      <circle cx="12" cy="12" r="2"></circle>
      <path d="M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5"></path>
      <path d="M19.1 4.9C23 8.8 23 15.1 19.1 19"></path>
    </svg>
  `,audio:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M9 18V5l12-2v13"></path>
      <circle cx="6" cy="18" r="3"></circle>
      <circle cx="18" cy="16" r="3"></circle>
    </svg>
  `,session:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path>
      <circle cx="9" cy="7" r="4"></circle>
      <path d="M23 21v-2a4 4 0 0 0-3-3.87"></path>
      <path d="M16 3.13a4 4 0 0 1 0 7.75"></path>
    </svg>
  `,cron:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <circle cx="12" cy="12" r="10"></circle>
      <polyline points="12 6 12 12 16 14"></polyline>
    </svg>
  `,web:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <circle cx="12" cy="12" r="10"></circle>
      <line x1="2" y1="12" x2="22" y2="12"></line>
      <path
        d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"
      ></path>
    </svg>
  `,discovery:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <circle cx="11" cy="11" r="8"></circle>
      <line x1="21" y1="21" x2="16.65" y2="16.65"></line>
    </svg>
  `,canvasHost:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
      <circle cx="8.5" cy="8.5" r="1.5"></circle>
      <polyline points="21 15 16 10 5 21"></polyline>
    </svg>
  `,talk:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"></path>
      <path d="M19 10v2a7 7 0 0 1-14 0v-2"></path>
      <line x1="12" y1="19" x2="12" y2="23"></line>
      <line x1="8" y1="23" x2="16" y2="23"></line>
    </svg>
  `,plugins:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M12 2v6"></path>
      <path d="m4.93 10.93 4.24 4.24"></path>
      <path d="M2 12h6"></path>
      <path d="m4.93 13.07 4.24-4.24"></path>
      <path d="M12 22v-6"></path>
      <path d="m19.07 13.07-4.24-4.24"></path>
      <path d="M22 12h-6"></path>
      <path d="m19.07 10.93-4.24 4.24"></path>
    </svg>
  `,diagnostics:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <polyline points="22 12 18 12 15 21 9 3 6 12 2 12"></polyline>
    </svg>
  `,cli:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <polyline points="4 17 10 11 4 5"></polyline>
      <line x1="12" y1="19" x2="20" y2="19"></line>
    </svg>
  `,secrets:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path
        d="m21 2-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0 3 3L22 7l-3-3m-3.5 3.5L19 4"
      ></path>
    </svg>
  `,acp:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path>
      <circle cx="9" cy="7" r="4"></circle>
      <path d="M23 21v-2a4 4 0 0 0-3-3.87"></path>
      <path d="M16 3.13a4 4 0 0 1 0 7.75"></path>
    </svg>
  `,mcp:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <rect x="2" y="2" width="20" height="8" rx="2" ry="2"></rect>
      <rect x="2" y="14" width="20" height="8" rx="2" ry="2"></rect>
      <line x1="6" y1="6" x2="6.01" y2="6"></line>
      <line x1="6" y1="18" x2="6.01" y2="18"></line>
    </svg>
  `,__appearance__:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <circle cx="12" cy="12" r="5"></circle>
      <line x1="12" y1="1" x2="12" y2="3"></line>
      <line x1="12" y1="21" x2="12" y2="23"></line>
      <line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
      <line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
      <line x1="1" y1="12" x2="3" y2="12"></line>
      <line x1="21" y1="12" x2="23" y2="12"></line>
      <line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
      <line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
    </svg>
  `,__notifications__:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M18 8a6 6 0 0 0-12 0c0 7-3 7-3 9h18c0-2-3-2-3-9"></path>
      <path d="M13.73 21a2 2 0 0 1-3.46 0"></path>
    </svg>
  `,default:w`
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
      <polyline points="14 2 14 8 20 8"></polyline>
    </svg>
  `},Ut=[{id:`core`,sections:[`env`,`auth`,`update`,`meta`,`logging`,`diagnostics`,`cli`,`secrets`]},{id:`ai`,sections:[`agents`,`models`,`skills`,`tools`,`memory`,`session`]},{id:`communication`,sections:[`channels`,`messages`,`broadcast`,`__notifications__`,`talk`,`audio`]},{id:`security`,sections:[`security`,`approvals`]},{id:`automation`,sections:[`commands`,`hooks`,`bindings`,`cron`,`plugins`]},{id:`infrastructure`,sections:[`gateway`,`web`,`browser`,`nodeHost`,`canvasHost`,`discovery`,`media`,`acp`,`mcp`]},{id:`appearance`,sections:[`__appearance__`,`ui`,`wizard`]}],Wt=new Set(Ut.flatMap(e=>e.sections)),Gt=64,Kt=2e4,qt=1e3,Jt=2e3,X=2e5,Yt=[{id:`claw`,labelKey:`configView.themes.claw.label`,descriptionKey:`configView.themes.claw.description`,icon:B.zap},{id:`knot`,labelKey:`configView.themes.knot.label`,descriptionKey:`configView.themes.knot.description`,icon:B.link},{id:`dash`,labelKey:`configView.themes.dash.label`,descriptionKey:`configView.themes.dash.description`,icon:B.barChart}],Xt=(e,t,n)=>e?w`<span class="config-action-spinner" aria-hidden="true">${B.loader}</span
        >${n}`:t}));function Qt(e,t,n){return w`<div id=${e}>${K(t,n)}</div>`}function $t(e){return e===`auto`?`auto`:e===`on`}function en(e){return e.configLoading===!0||e.configSaving===!0||e.configApplying===!0||e.configUpdating===!0}function tn(e){return K({title:L(`nav.settingsGeneral`)},[G({title:L(`quickSettings.language`),control:dt(e.locale,e.onLocaleChange)})])}function nn(e){let t=tt(e.fastMode),n=en(e);return Qt(h.model,{title:L(`quickSettings.model.title`)},[We({title:L(`quickSettings.model.model`),control:U(e.currentModel||`default`,{mono:!0}),onClick:()=>e.onModelChange?.()}),G({title:L(`quickSettings.model.thinking`),control:V({value:e.thinkingLevel,options:hn.map(e=>({value:e,label:L(`quickSettings.model.thinkingLevels.${e}`)})),disabled:n,onChange:t=>e.onThinkingChange?.(t)})}),G({title:L(`quickSettings.model.fastMode`),control:V({value:t,options:[{value:`auto`,label:L(`quickSettings.model.fastModes.auto`)},{value:`on`,label:L(`quickSettings.model.fastModes.fast`)},{value:`off`,label:L(`quickSettings.model.fastModes.standard`)}],disabled:n,onChange:n=>{n!==t&&e.onFastModeChange?.($t(n))}})})])}function rn(e){return e>=.92?`critical`:e>=.75?`warn`:`ok`}function an(e,t){let n=Math.min(Math.max(t,0),1),r=Math.round(n*100);return w`
    <div
      class="config-host__meter"
      role="meter"
      aria-label=${L(`quickSettings.system.usage`,{label:e})}
      aria-valuemin="0"
      aria-valuemax="100"
      aria-valuenow=${r}
    >
      <div
        class="config-host__meter-fill config-host__meter-fill--${rn(n)}"
        style="--config-host-meter-fill: ${r}%"
      ></div>
    </div>
  `}function on(e){return w`
    <div class="config-host__stat" title=${e.title??``}>
      <div class="config-host__stat-label">${e.label}</div>
      <div class="config-host__stat-value">
        ${e.value}${e.unit?w` <span class="config-host__stat-unit">${e.unit}</span>`:O}
      </div>
      ${e.usedFraction==null?O:an(e.label,e.usedFraction)}
      ${e.detail?w`<div class="config-host__stat-detail">${e.detail}</div>`:O}
    </div>
  `}function sn(e,t){if(!(e==null||t==null||e<=0))return(e-t)/e}function cn(e){return`${Math.round(Math.min(Math.max(e,0),1)*100)}%`}function ln(e){let t=e.loadAverage?.[0],n=e.loadAverage?L(`quickSettings.system.loadAverage`,{values:e.loadAverage.map(e=>e.toFixed(1)).join(` · `)}):void 0,r=[e.cpuModel,n].filter(Boolean).join(` · `)||void 0,i=L(e.cpuCount===1?`quickSettings.system.core`:`quickSettings.system.cores`,{count:String(e.cpuCount)}),a=t==null?{label:L(`quickSettings.system.cpu`),value:i,detail:e.cpuModel,title:r}:{label:L(`quickSettings.system.cpu`),value:t.toFixed(1),unit:L(`quickSettings.system.load`),detail:i,usedFraction:e.cpuCount>0?t/e.cpuCount:void 0,title:r},o=sn(e.memoryTotalBytes,e.memoryFreeBytes),s=[a,{label:L(`quickSettings.system.memory`),value:o==null?`—`:cn(o),unit:o==null?void 0:L(`quickSettings.system.used`),detail:L(`quickSettings.system.freeOf`,{free:y(e.memoryFreeBytes),total:y(e.memoryTotalBytes)}),usedFraction:o}],c=sn(e.diskTotalBytes,e.diskAvailableBytes);return c!=null&&s.push({label:L(`quickSettings.system.disk`),value:cn(c),unit:L(`quickSettings.system.used`),detail:L(`quickSettings.system.freeOf`,{free:y(e.diskAvailableBytes),total:y(e.diskTotalBytes)}),usedFraction:c,title:e.diskPath}),s}function un(){return[{label:L(`quickSettings.system.cpu`),value:`—`},{label:L(`quickSettings.system.memory`),value:`—`},{label:L(`quickSettings.system.disk`),value:`—`}]}function dn(e){if(e.systemInfoUnavailable)return O;let n=e.systemInfo,r=n&&n.hostname!==n.machineName?n.hostname:void 0,i=n?.lanAddress?`${n.lanAddress}${n.port==null?``:`:${n.port}`}`:void 0,a=n?ln(n):un();return Qt(h.system,{title:L(`quickSettings.system.gatewayHost`),actions:n?W({kind:`ok`,label:L(`quickSettings.system.up`,{duration:t(n.uptimeMs)})}):void 0},w`
      <div class="config-host">
        <div class="config-host__identity">
          <div class="config-host__name" title=${r??``}>
            ${n?.machineName??`—`}
          </div>
          <div class="config-host__meta">
            ${n?`${n.osLabel} · ${n.arch}`:`—`}
          </div>
          <div class="config-host__meta">
            ${n?L(`quickSettings.system.runtime`,{version:n.nodeVersion,pid:String(n.pid)}):`—`}
          </div>
          ${i?w`<code class="config-host__address">${i}</code>`:O}
        </div>
        <div class="config-host__stats">${a.map(on)}</div>
      </div>
    `)}function fn(e){let t=[e.assistantName,e.version?`v${e.version}`:``].filter(Boolean).join(` · `);return Ke(G({title:W({kind:e.connected?`ok`:`muted`,label:e.connected?L(`common.connected`):L(`common.offline`)}),control:t?U(t):O}))}function pn(e){let t=Lt({status:e.configAutoSaveStatus??`idle`,onRetry:()=>e.onRetrySaveConfig?.(),onReload:()=>e.onDiscardConfig?.()});return t===O?O:w`
    <div class="config-toolbar__status" role="status" aria-live="polite">${t}</div>
  `}function mn(e){return Ue(w`
    ${pn(e)}
    ${It({needsApply:e.configNeedsApply===!0,applying:e.configApplying===!0,busy:e.configSaving===!0||e.configLoading===!0||e.configUpdating===!0||e.configAutoSaveStatus===`saving`||e.configRawDraftPending===!0,connected:e.connected,onApply:()=>e.onApplyConfig?.()})}
    ${nn(e)} ${tn(e)} ${dn(e)}
    ${fn(e)}
  `)}var hn,gn=e((()=>{E(),et(),q(),R(),x(),ee(),ft(),i(),Zt(),hn=[`off`,`low`,`medium`,`high`]}));function _n(e){let{gatewayAuth:t,execPolicy:n,deviceAuth:r,browserEnabled:i,toolProfile:a}=e.security,o=a.trim()||`full`,s=Z.includes(o)?Z:[...Z,o];return K({title:L(`quickSettings.security.title`)},[G({title:L(`quickSettings.security.gatewayAuth`),control:W({kind:t===`none`?`warn`:`ok`,label:t})}),G({title:L(`quickSettings.security.execPolicy`),control:U(n)}),H({title:L(`quickSettings.security.browserEnabled`),checked:i,disabled:e.configBusy,onChange:t=>e.onBrowserEnabledToggle?.(t)}),G({title:L(`quickSettings.security.toolProfile`),stacked:!0,control:V({value:o,options:s.map(e=>({value:e,label:e})),disabled:e.configBusy,onChange:t=>e.onToolProfileChange?.(t)})}),G({title:L(`quickSettings.security.deviceAuth`),control:W({kind:r?`ok`:`warn`,label:L(r?`common.enabled`:`common.disabled`)})}),G({title:L(`nodes.pairing.title`),control:w`
        <button
          class="btn"
          title=${e.canPairDevice?``:L(`nodes.pairing.adminRequired`)}
          ?disabled=${!e.canPairDevice}
          @click=${e.onPairMobile}
        >
          ${B.smartphone} ${L(`nodes.pairing.button`)}
        </button>
      `})])}function vn(e){return w`
    <section class="security-page">
      <div class="settings-page">${_n(e)}</div>
      ${e.editor}
    </section>
  `}var Z,yn=e((()=>{E(),Me(),q(),R(),Z=[`minimal`,`coding`,`messaging`,`full`]}));function bn(e){return e instanceof ie&&e.gatewayCode===`INVALID_REQUEST`&&e.message.includes(`unknown method: system.info`)}function xn(e){return e?.features?.methods?.includes(`system.info`)===!0}function Q(e){switch(e){case`communications`:return{activeSection:`messages`,activeSubsection:null};case`appearance`:return{activeSection:`__appearance__`,activeSubsection:null};case`notifications`:return{activeSection:`__notifications__`,activeSubsection:null};case`security`:return{activeSection:`security`,activeSubsection:null};case`automation`:return{activeSection:`commands`,activeSubsection:null};case`mcp`:return{activeSection:`mcp`,activeSubsection:null};case`infrastructure`:return{activeSection:`gateway`,activeSubsection:null};case`ai-agents`:return{activeSection:`agents`,activeSubsection:null};case`config`:case`advanced`:return{activeSection:null,activeSubsection:null}}throw Error(`Unknown config page`)}function Sn(e,t,n){let r=s(e)??null;return(e===`config`||e===`advanced`)&&t&&v.has(t)?{activeSection:null,activeSubsection:null}:r&&(!t||!r.includes(t))?Q(e):{activeSection:t,activeSubsection:n}}function Cn(e,t){let n=new URLSearchParams(t).get(`section`);return n?Sn(e,n,null):Q(e)}function wn(e){return L(e===`config`?`nav.settingsGeneral`:`tabs.${Dn[e]}`)}function Tn(e){let t=N(e?.configForm)??N(e);if(!t)return{gatewayAuth:`unknown`,execPolicy:`unknown`,deviceAuth:!1,browserEnabled:!0,toolProfile:`full`};let n=N(t.gateway),r=N(n?.auth),i=N(t.tools)??{},a=N(i.exec)??{},o=N(t.browser),s=N(n?.controlUi),c=`unknown`;r&&(c=(typeof r.mode==`string`?r.mode.trim():``)||(r.password?`password`:r.token?`token`:r.trustedProxy?`trusted-proxy`:`none`));let l=i.profile,u=a.security;return{gatewayAuth:c,execPolicy:typeof u==`string`&&u.trim()?u.trim():`allowlist`,deviceAuth:s?.dangerouslyDisableDeviceAuth!==!0,browserEnabled:o?.enabled!==!1,toolProfile:typeof l==`string`&&l.trim()?l.trim():`full`}}function En(e){typeof document>`u`||document.documentElement.style.setProperty(`--control-ui-text-scale`,(le(e)/100).toFixed(2))}var Dn,On,kn,$;e((()=>{S(),M(),E(),k(),re(),ue(),_e(),ae(),oe(),ge(),ve(),P(),He(),R(),Xe(),g(),l(),o(),b(),Ze(),_(),ut(),gn(),m(),yn(),Zt(),n(),Dn={config:`config`,communications:`communications`,appearance:`appearance`,notifications:`notifications`,security:`security`,automation:`automation`,mcp:`mcp`,infrastructure:`infrastructure`,"ai-agents":`aiAgents`,advanced:`advanced`},On={"communications:__notifications__":{routeId:`notifications`,keepSection:!1},"automation:approvals":{routeId:`security`,keepSection:!0}},kn=1e4,$=class extends d{constructor(...e){super(...e),this.pageId=`config`,this.routeData=null,this.settings=I(),this.systemInfo=null,this.systemInfoUnavailable=!1,this.microphoneDevices=[],this.microphoneLoading=!1,this.microphoneError=null,this.microphoneLoaded=!1,this.formModes={config:`form`,communications:`form`,appearance:`form`,notifications:`form`,security:`form`,automation:`form`,mcp:`form`,infrastructure:`form`,"ai-agents":`form`,advanced:`form`},this.selections={config:Q(`config`),communications:Q(`communications`),appearance:Q(`appearance`),notifications:Q(`notifications`),security:Q(`security`),automation:Q(`automation`),mcp:Q(`mcp`),infrastructure:Q(`infrastructure`),"ai-agents":Q(`ai-agents`),advanced:Q(`advanced`)},this.customThemeImportUrl=``,this.customThemeImportBusy=!1,this.customThemeImportMessage=null,this.customThemeImportExpanded=!1,this.customThemeImportFocusToken=0,this.customThemeImportSelectOnSuccess=!1,this.configViewState=ht(),this.runtimeConfigSource=null,this.systemInfoGatewaySource=null,this.systemInfoClient=null,this.systemInfoLoading=!1,this.systemInfoRequestId=0,this.systemInfoPolling=new te(this,kn,()=>{this.loadSystemInfo()},!1),this.pendingRouteTargetId=null,this.subscriptions=new u(this).watch(()=>this.context?.runtimeConfig,(e,t)=>e.subscribe(t),e=>this.synchronizeRuntimeConfig(e)).watch(()=>this.context?.overlays,(e,t)=>e.subscribe(t)).watch(()=>this.context?.config,(e,t)=>e.subscribe(t)).watch(()=>this.context?.gateway,(e,t)=>e.subscribe(t),e=>this.synchronizeSystemInfoGateway(e)).watch(()=>this.context?.webPush,(e,t)=>e.subscribe(t)).watch(()=>this.context?.theme,(e,t)=>e.subscribe(t),()=>{this.settings=I()})}connectedCallback(){super.connectedCallback(),this.settings=I(),this.syncRouteData()}disconnectedCallback(){this.systemInfoPolling.stop(),this.invalidateSystemInfoRequest(),this.runtimeConfigSource=null,this.resetConfigViewState(),this.systemInfoGatewaySource=null,this.systemInfoClient=null,this.subscriptions.clear(),super.disconnectedCallback()}willUpdate(e){(e.has(`pageId`)||e.has(`routeData`))&&this.syncRouteData()}updated(e){e.has(`pageId`)&&e.get(`pageId`)!==void 0&&this.invalidateSystemInfoRequest(),this.syncSystemInfoPolling(),this.scrollToPendingRouteTarget(),this.pageId===`appearance`&&!this.microphoneLoaded&&(this.microphoneLoaded=!0,this.refreshMicrophones(!1))}async refreshMicrophones(e){this.microphoneLoading=!0,this.microphoneError=null;try{let t=await $e(e);this.microphoneDevices=t.devices,this.microphoneError=t.warning}catch(e){this.microphoneError=e instanceof Error?e.message:String(e)}finally{this.microphoneLoading=!1}}syncRouteData(){let e=this.routeData?this.routeData.section:new URLSearchParams(globalThis.location?.search??``).get(`section`);if(e){let t=On[`${this.pageId}:${e}`];if(t){this.context?.navigate(t.routeId,{search:t.keepSection?`?section=${encodeURIComponent(e)}`:``,hash:globalThis.location?.hash??``});return}}let t=this.routeData?Sn(this.pageId,this.routeData.section,null):Cn(this.pageId,globalThis.location?.search??``);if(this.pageId===`config`&&t.activeSection){this.context?.navigate(`advanced`,{search:`?section=${encodeURIComponent(t.activeSection)}`,hash:globalThis.location?.hash??``});return}this.selections={...this.selections,[this.pageId]:t};let n=this.routeData?.targetBlockId??p(globalThis.location?.hash??``);this.pendingRouteTargetId=n}scrollToPendingRouteTarget(){let e=this.pendingRouteTargetId;if(!e)return;let t=[...this.renderRoot.querySelectorAll(`[id]`)].find(t=>t.id===e);t&&(t.scrollIntoView?.({behavior:`smooth`,block:`start`}),this.pendingRouteTargetId=null)}isSystemInfoVisible(){return this.pageId===`config`}synchronizeRuntimeConfig(e){e!==this.runtimeConfigSource&&(this.runtimeConfigSource=e,this.resetConfigViewState());let t=e.state;if(!t.configSnapshot&&!t.configLoading){e.ensureLoaded().then(()=>this.runtimeConfigSource===e?e.ensureSchemaLoaded():void 0).catch(()=>void 0);return}!t.configSchema&&!t.configSchemaLoading&&e.ensureSchemaLoaded().catch(()=>void 0)}synchronizeSystemInfoGateway(e){e!==this.systemInfoGatewaySource&&(this.systemInfoPolling.stop(),this.invalidateSystemInfoRequest(),this.systemInfoGatewaySource=e,this.resetConfigViewState(),this.systemInfoClient=null,this.systemInfo=null,this.systemInfoUnavailable=!1),this.handleSystemInfoGatewaySnapshot(e.snapshot)}resetConfigViewState(){this.configViewState=ht()}handleSystemInfoGatewaySnapshot(e){let t=e.client!==this.systemInfoClient,n=xn(e.hello);this.systemInfoClient=e.client,t?(this.invalidateSystemInfoRequest(),this.systemInfo=null,this.systemInfoUnavailable=!1):e.connected||(this.invalidateSystemInfoRequest(),this.systemInfo=null),e.connected&&e.hello&&(this.systemInfoUnavailable=!n,n||(this.invalidateSystemInfoRequest(),this.systemInfo=null)),this.syncSystemInfoPolling()}syncSystemInfoPolling(){let e=this.context.gateway.snapshot;if(!(this.isConnected&&this.isSystemInfoVisible()&&!this.systemInfoUnavailable&&e.connected&&xn(e.hello)&&e.client!=null)){this.systemInfoPolling.stop();return}this.systemInfoPolling.start()&&this.loadSystemInfo()}invalidateSystemInfoRequest(){this.systemInfoRequestId+=1,this.systemInfoLoading=!1}isCurrentSystemInfoRequest(e,t,n){let r=n.snapshot;return this.isConnected&&this.isSystemInfoVisible()&&e===this.systemInfoRequestId&&this.systemInfoGatewaySource===n&&this.context.gateway===n&&r.connected&&r.client===t}async loadSystemInfo(){let e=this.systemInfoGatewaySource;if(!e||e!==this.context.gateway)return;let t=e.snapshot,n=t.client;if(!t.connected||!n||!this.isSystemInfoVisible()||this.systemInfoUnavailable||this.systemInfoLoading)return;let r=++this.systemInfoRequestId;this.systemInfoLoading=!0;try{let t=await n.request(`system.info`,{});if(!this.isCurrentSystemInfoRequest(r,n,e))return;this.systemInfo=t}catch(t){if(!this.isCurrentSystemInfoRequest(r,n,e))return;(a(t)||bn(t))&&(this.systemInfo=null,this.systemInfoUnavailable=!0,this.systemInfoPolling.stop())}finally{this.isCurrentSystemInfoRequest(r,n,e)&&(this.systemInfoLoading=!1)}}navigate(e){this.context.navigate(e)}setFormMode(e){this.formModes={...this.formModes,[this.pageId]:e}}setActiveSection(e){this.selections={...this.selections,[this.pageId]:{activeSection:e,activeSubsection:null}}}setActiveSubsection(e){this.selections={...this.selections,[this.pageId]:{...this.selections[this.pageId],activeSubsection:e}}}applySettings(e){this.settings=ne({theme:e.theme,themeMode:e.themeMode,customTheme:e.customTheme,textScale:e.textScale,chatSendShortcut:e.chatSendShortcut,chatFollowUpMode:e.chatFollowUpMode,catalogOpenTarget:e.catalogOpenTarget,realtimeTalkInputDeviceId:e.realtimeTalkInputDeviceId,lobsterPetVisits:e.lobsterPetVisits,lobsterPetSounds:e.lobsterPetSounds}),En(this.settings.textScale),this.context.theme.refresh()}setLocale(e){this.settings=ne({locale:e}),Ce.setLocale(e)}setTheme(e,t){let n=F(this.settings.theme,this.settings.themeMode),r={...this.settings,theme:e};pe({currentTheme:n,nextTheme:F(r.theme,r.themeMode),context:t,applyTheme:()=>this.applySettings(r)})}setThemeMode(e,t){let n=F(this.settings.theme,this.settings.themeMode),r={...this.settings,themeMode:e};pe({currentTheme:n,nextTheme:F(r.theme,r.themeMode),context:t,applyTheme:()=>this.applySettings(r)})}setSetting(e,t){this.applySettings({...this.settings,[e]:t})}selectMicrophone(e){this.applySettings({...this.settings,realtimeTalkInputDeviceId:e.trim()||void 0})}openCustomThemeImport(){this.customThemeImportExpanded=!0,this.customThemeImportFocusToken+=1,this.settings.customTheme||(this.customThemeImportSelectOnSuccess=!0)}async importCustomTheme(){if(!this.customThemeImportBusy){this.customThemeImportExpanded=!0,this.customThemeImportBusy=!0,this.customThemeImportMessage=null;try{let e=await ce(this.customThemeImportUrl),t=!this.settings.customTheme||this.customThemeImportSelectOnSuccess;this.applySettings({...this.settings,customTheme:e,theme:t?`custom`:this.settings.theme}),this.customThemeImportUrl=``,this.customThemeImportSelectOnSuccess=!1,this.customThemeImportMessage={kind:`success`,text:L(`configPage.themeImported`,{name:e.label})}}catch(e){this.customThemeImportMessage={kind:`error`,text:e instanceof Error?e.message:String(e)}}finally{this.customThemeImportBusy=!1}}}clearCustomTheme(){this.customThemeImportExpanded=!0,this.customThemeImportSelectOnSuccess=!1,this.applySettings({...this.settings,theme:this.settings.theme===`custom`?`claw`:this.settings.theme,customTheme:void 0}),this.customThemeImportMessage={kind:`success`,text:L(`configPage.themeRemoved`)}}includeSections(){return s(this.pageId)}isUpdateBusy(){let e=this.context.overlays.snapshot;return e.updateRunning||e.updateReconciliationPending}renderAdvancedConfig(e){let t=this.context.runtimeConfig,n=t.state,r=this.includeSections(),i=this.pageId===`advanced`?[...v]:void 0,a=Sn(this.pageId,this.selections[this.pageId].activeSection,this.selections[this.pageId].activeSubsection),o=this.pageId===`mcp`?`mcp`:a.activeSection,s=this.pageId===`mcp`?null:a.activeSubsection,c={raw:n.configRaw,originalRaw:n.configRawOriginal,valid:n.configValid,issues:n.configIssues,loading:n.configLoading,saving:n.configSaving,applying:n.configApplying,updating:this.isUpdateBusy(),autoSaveStatus:n.configAutoSaveStatus,needsApply:n.configNeedsApply,connected:n.connected,schema:n.configSchema,schemaLoading:n.configSchemaLoading,uiHints:n.configUiHints,formMode:this.formModes[this.pageId],rawDraftPending:n.configFormMode===`raw`&&n.configFormDirty,viewState:this.configViewState,rawAvailable:!!(n.configSnapshot?.config||n.configForm||n.configRaw),showModeToggle:this.pageId===`advanced`,formValue:n.configForm,originalValue:n.configFormOriginal,activeSection:o,activeSubsection:s,onRawChange:e=>t.setRaw(e),onFormModeChange:e=>this.setFormMode(e),onViewStateChange:()=>this.requestUpdate(),onFormPatch:(e,n)=>t.patchForm(e,n),onSectionChange:e=>this.setActiveSection(e),onSubsectionChange:e=>this.setActiveSubsection(e),onSave:()=>void t.save(),onApply:()=>void t.apply(),onRawDiscard:()=>void t.discardDraft(),onOpenFile:()=>void t.openFile(),version:this.context.config.current.serverVersion??this.context.gateway.snapshot.hello?.server?.version??``,theme:this.settings.theme,themeMode:this.settings.themeMode,setTheme:(e,t)=>this.setTheme(e,t),setThemeMode:(e,t)=>this.setThemeMode(e,t),hasCustomTheme:!!this.settings.customTheme,customThemeLabel:this.settings.customTheme?.label??null,customThemeSourceUrl:this.settings.customTheme?.sourceUrl??null,customThemeImportUrl:this.customThemeImportUrl,customThemeImportBusy:this.customThemeImportBusy,customThemeImportMessage:this.customThemeImportMessage,customThemeImportExpanded:this.customThemeImportExpanded,customThemeImportFocusToken:this.customThemeImportFocusToken,onCustomThemeImportUrlChange:e=>{this.customThemeImportUrl=e,this.customThemeImportMessage?.kind===`error`&&(this.customThemeImportMessage=null)},onImportCustomTheme:()=>void this.importCustomTheme(),onClearCustomTheme:()=>this.clearCustomTheme(),onOpenCustomThemeImport:()=>this.openCustomThemeImport(),textScale:this.settings.textScale??100,setTextScale:e=>this.setSetting(`textScale`,le(e)),lobsterPetVisits:this.settings.lobsterPetVisits!==!1,setLobsterPetVisits:e=>this.applySettings({...this.settings,lobsterPetVisits:e}),lobsterPetSounds:this.settings.lobsterPetSounds===!0,setLobsterPetSounds:e=>this.applySettings({...this.settings,lobsterPetSounds:e}),chatSendShortcut:fe(this.settings.chatSendShortcut),setChatSendShortcut:e=>this.setSetting(`chatSendShortcut`,e),chatFollowUpMode:this.settings.chatFollowUpMode,serverQueueMode:n.configSnapshot?Qe(n.configSnapshot.runtimeConfig,{configNeedsApply:n.configNeedsApply}):void 0,setChatFollowUpMode:e=>this.setSetting(`chatFollowUpMode`,e),catalogOpenTarget:de(this.settings.catalogOpenTarget),setCatalogOpenTarget:e=>this.setSetting(`catalogOpenTarget`,e),microphone:{devices:this.microphoneDevices,selectedDeviceId:this.settings.realtimeTalkInputDeviceId??``,loading:this.microphoneLoading,error:this.microphoneError},onMicrophoneRefresh:()=>void this.refreshMicrophones(!0),onMicrophoneSelect:e=>this.selectMicrophone(e),gatewayUrl:this.context.gateway.connection.gatewayUrl,assistantName:this.context.config.current.assistantIdentity.name,configPath:n.configSnapshot?.path??null,navRootLabel:this.pageId===`advanced`?void 0:wn(this.pageId),showRootTab:!r?.length,includeSections:r?[...r]:void 0,excludeSections:i,includeVirtualSections:this.pageId===`appearance`||this.pageId===`notifications`,settingsLayout:this.pageId===`advanced`?`accordion`:void 0,webPush:this.context.webPush.snapshot,onWebPushSubscribe:()=>void this.context.webPush.enable(),onWebPushUnsubscribe:()=>void this.context.webPush.disable(),onWebPushTest:()=>void this.context.webPush.sendTest()};if(this.pageId===`mcp`)return lt({configObject:e,pluginsHref:be(`plugins`,this.context.basePath),editor:J({...c,activeSection:`mcp`,activeSubsection:null,showModeToggle:!1,includeSections:[`mcp`],navRootLabel:`MCP`})});if(this.pageId===`security`){let n=t.state,r=n.configLoading||n.configSaving||n.configApplying||this.isUpdateBusy();return vn({security:Tn(e),configBusy:r,canPairDevice:n.connected&&se(this.context.gateway.snapshot.hello?.auth??null),onPairMobile:()=>void this.context.overlays.openDevicePairSetup(),onBrowserEnabledToggle:e=>t.patchForm([`browser`,`enabled`],e),onToolProfileChange:e=>t.patchForm([`tools`,`profile`],e),editor:J(c)})}return J(c)}renderQuickConfig(e){let t=this.context.runtimeConfig,n=N(N(e.agents)?.defaults),r=typeof n?.model==`string`?n.model:`default`,i=typeof n?.thinkingDefault==`string`?n.thinkingDefault:`off`,a=n?.fastMode,o=this.context.config.current;return mn({locale:we(this.settings.locale)?this.settings.locale:Ce.getLocale(),onLocaleChange:e=>this.setLocale(e),currentModel:r,thinkingLevel:i,fastMode:a===`auto`||typeof a==`boolean`?a:!1,systemInfo:this.systemInfo,systemInfoUnavailable:this.systemInfoUnavailable,onModelChange:()=>{this.selections={...this.selections,"ai-agents":{activeSection:`models`,activeSubsection:null}},this.navigate(`ai-agents`)},connected:t.state.connected,assistantName:o.assistantIdentity.name,version:o.serverVersion??this.context.gateway.snapshot.hello?.server?.version??``,configLoading:t.state.configLoading,configSaving:t.state.configSaving,configApplying:t.state.configApplying,configUpdating:this.isUpdateBusy(),configNeedsApply:t.state.configNeedsApply,configRawDraftPending:t.state.configFormMode===`raw`&&t.state.configFormDirty,configAutoSaveStatus:t.state.configAutoSaveStatus,onApplyConfig:()=>void t.apply(),onRetrySaveConfig:()=>void t.save(),onDiscardConfig:()=>void t.discardDraft(),onThinkingChange:e=>t.patchForm([`agents`,`defaults`,`thinkingDefault`],e),onFastModeChange:e=>t.patchForm([`agents`,`defaults`,`fastMode`],e)})}render(){let e=this.context.runtimeConfig.state,t=N(e.configForm??e.configSnapshot?.config)??{},n=this.pageId===`config`?this.renderQuickConfig(t):this.renderAdvancedConfig(t);return w`
      <section class="content-header">
        <div>
          <div class="page-title">${wn(this.pageId)}</div>
        </div>
      </section>
      ${Ve(n,this.pageId===`config`?{id:`config-settings-panel`,ariaLabel:L(`configPage.content`)}:{})}
    `}},r([C({context:he,subscribe:!0})],$.prototype,`context`,void 0),r([T({attribute:`page-id`})],$.prototype,`pageId`,void 0),r([T({attribute:!1})],$.prototype,`routeData`,void 0),r([D()],$.prototype,`settings`,void 0),r([D()],$.prototype,`systemInfo`,void 0),r([D()],$.prototype,`systemInfoUnavailable`,void 0),r([D()],$.prototype,`microphoneDevices`,void 0),r([D()],$.prototype,`microphoneLoading`,void 0),r([D()],$.prototype,`microphoneError`,void 0),r([D()],$.prototype,`formModes`,void 0),r([D()],$.prototype,`selections`,void 0),r([D()],$.prototype,`customThemeImportUrl`,void 0),r([D()],$.prototype,`customThemeImportBusy`,void 0),r([D()],$.prototype,`customThemeImportMessage`,void 0),r([D()],$.prototype,`customThemeImportExpanded`,void 0),r([D()],$.prototype,`customThemeImportFocusToken`,void 0),customElements.get(`openclaw-config-page`)||customElements.define(`openclaw-config-page`,$)}))();
//# sourceMappingURL=config-page-lhxQYbp_.js.map