const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./applied-history.runtime-DOjIkwDo.js","./rolldown-runtime-DkW27tQK.js","./lit-runtime-BEtFSUCp.js","./control-ui-foundation-CeFMP1Ly.js","./control-ui-core-pH6nakZ-.js","./control-ui-core-DGVkFhVB.js","./control-ui-core-Br5DB0Zj.js","./gateway-runtime-DUNO4Mi1.js","./control-ui-core-C8H8-RSs.css","./control-ui-boot-Cdpgu1Gm.js","./control-ui-boot-wpHCbPL9.js","./control-ui-boot-gfE6fZcA.js","./config-runtime-C4gfjhZc.js","./control-ui-boot-CKTkvwFZ.js","./control-ui-boot-BPFwXC8p.js","./control-ui-boot-DdPrPuw0.js","./control-ui-boot-9_2QGLIL.js","./control-ui-boot-J-x6DHHT.js","./control-ui-boot-B1lcIXow.js","./control-ui-boot-Clhp68JE.js","./control-ui-boot-D1DWJlBr.js","./control-ui-boot-CQvujP8f.js","./control-ui-boot-BW_XZcbY.js","./control-ui-boot-__AsqpzJ.css","./markdown-runtime-BcrsAQtF.js"])))=>i.map(i=>d[i]);
import{n as e}from"./rolldown-runtime-DkW27tQK.js";import{Ci as t,Jt as n,Nr as r,Pr as i,Q as a,Y as o,bn as s,er as c}from"./control-ui-foundation-CeFMP1Ly.js";import{Ba as l,Da as u,Lc as d,Na as f,Va as p,ao as m,b as h,bc as g,dc as _,fl as v,fs as ee,hl as y,ja as te,mc as ne,ml as re,ms as ie,pl as ae,ps as b,uc as oe,vr as se,w as ce,yr as le}from"./control-ui-core-pH6nakZ-.js";import{C as ue,E as de,G as x,J as S,O as fe,W as C,Z as pe,_ as me,a as he,at as w,b as ge,et as _e,lt as ve,s as ye,w as be}from"./lit-runtime-BEtFSUCp.js";import{B as xe,Kn as Se,U as Ce,m as we,p as Te,zn as Ee}from"./control-ui-core-DGVkFhVB.js";import{Ft as T,Ht as E,Lt as D,Mt as De,Nt as O,Q as Oe,Rt as k,et as ke,qt as A}from"./control-ui-core-Br5DB0Zj.js";import{F as Ae,I as je,In as Me,L as Ne,Ln as Pe}from"./control-ui-boot-wpHCbPL9.js";import{n as Fe,r as Ie}from"./gateway-runtime-DUNO4Mi1.js";import{da as Le,fa as Re}from"./control-ui-boot-Cdpgu1Gm.js";import{n as ze,t as Be}from"./hub-tabs-mHLCJmKB.js";import{i as Ve,n as He,r as Ue,t as We}from"./plugins-hub-header-2-MSECVZ.js";import{a as Ge,i as Ke,n as qe,r as Je,t as Ye}from"./history-scan-page-controller-DQM5Mm_P.js";import{a as Xe,c as Ze,f as Qe,i as $e,l as j,n as M,o as et,p as N,s as P,t as tt}from"./proposals-B4WDxsHz.js";function F(e,t){return Fe(e,t,`operator.admin`)}function nt(e){return{canEvaluate:F(e,`skills.proposals.evaluate`),canApply:F(e,`skills.proposals.apply`),canRevise:F(e,`skills.proposals.requestRevision`),canReject:F(e,`skills.proposals.reject`),canScanHistory:F(e,`skills.proposals.historyScan`)}}function I(){return(I=e((()=>{Ie()})))()}function rt(e){let t=s(s(e.skills)?.workshop);return s(t?.autonomous)?.mode!==`off`}function it(e,t,n,r){let i=_(e?.state.configSnapshot);return i?{enabled:rt(i),busy:t,canUpdate:r,error:n}:null}async function at(e,t,n=()=>!0){let r={raw:{skills:{workshop:{autonomous:{mode:t?`auto`:`off`}}}},note:t?`Enable Skill Workshop self-learning`:`Disable Skill Workshop self-learning`},i=await e.patch(r);if(!n())return null;if(!i&&e.state.lastError?.includes(L)){if(await e.refresh(),!n())return null;if(e.state.lastError)return e.state.lastError;if(i=await e.patch(r),!n())return null}return i?(await e.refresh(),n(),null):e.state.lastError??A(`skillWorkshop.selfLearning.updateError`)}function ot(e,t){return e?S`
    <label
      class="sw-revision-session-toggle"
      title=${A(`skillWorkshop.header.selfLearningTooltip`)}
    >
      <input
        type="checkbox"
        aria-label=${A(`skillWorkshop.header.selfLearningAria`)}
        .checked=${e.enabled}
        ?disabled=${e.busy||!e.canUpdate}
        @change=${e=>t(e.currentTarget.checked)}
      />
      <span class="sw-revision-session-toggle__track" aria-hidden="true"></span>
      <span class="sw-revision-session-toggle__label"
        >${A(`skillWorkshop.header.selfLearning`)}</span
      >
    </label>
  `:x}function st(e,t){return!e||e.enabled?x:S`
    <div class="sw-empty-state__selflearn">
      <h3>${A(`skillWorkshop.selfLearning.pitchTitle`)}</h3>
      <p>${A(`skillWorkshop.selfLearning.pitchBody`)}</p>
      <button
        type="button"
        class="sw-btn sw-btn--primary ${e.busy?`is-busy`:``}"
        ?disabled=${e.busy||!e.canUpdate}
        @click=${()=>t(!0)}
      >
        ${e.busy?A(`skillWorkshop.selfLearning.enabling`):A(`skillWorkshop.selfLearning.enable`)}
      </button>
    </div>
  `}function ct(e){return e?.error?S`<div class="sw-error" role="status"><span>${e.error}</span></div>`:x}var L;function R(){return(R=e((()=>{C(),E(),oe(),L=`config changed since last load`})))()}function lt(){try{return y()?.getItem(z)===`board`?`board`:`today`}catch{return`today`}}function ut(e){try{y()?.setItem(z,e)}catch{}}function dt(){try{return y()?.getItem(B)===`true`}catch{return!1}}function ft(e){try{y()?.setItem(B,String(e))}catch{}}var z,B;function V(){return(V=e((()=>{z=`openclaw:control-ui:skill-workshop-mode:v1`,B=`openclaw:control-ui:skill-workshop-current-chat-revisions:v1`})))()}function pt(e,t,n){e.skillWorkshopUseCurrentChatForRevisions!==t&&(e.skillWorkshopUseCurrentChatForRevisions=t,ft(t),n())}function H(e,t,n){e.skillWorkshopMode!==t&&(e.skillWorkshopMode=t,ut(t),n())}function mt(e,{selfLearning:t,onSelfLearningToggle:n},r){let i=A(`skillWorkshop.header.useCurrentChat`);return S`
    <div class="sw-header-controls">
      ${ot(t,n)}
      <label
        class="sw-revision-session-toggle"
        title=${A(`skillWorkshop.header.useCurrentChatTooltip`)}
      >
        <input
          type="checkbox"
          aria-label=${A(`skillWorkshop.header.useCurrentChatAria`)}
          .checked=${e.skillWorkshopUseCurrentChatForRevisions}
          @change=${t=>pt(e,t.currentTarget.checked,r)}
        />
        <span class="sw-revision-session-toggle__track" aria-hidden="true"></span>
        <span class="sw-revision-session-toggle__label">${i}</span>
      </label>
      ${ze({id:`skill-workshop-mode`,active:e.skillWorkshopMode,tabs:[{value:`board`,label:S`
              <svg viewBox="0 0 24 24" class="sw-mode-tabs__icon" aria-hidden="true">
                <rect x="3" y="4" width="7" height="16" rx="1.5" />
                <rect x="14" y="4" width="7" height="9" rx="1.5" />
                <rect x="14" y="15" width="7" height="5" rx="1.5" />
              </svg>
              <span>${A(`skillWorkshop.header.board`)}</span>
            `},{value:`today`,label:S`
              <svg viewBox="0 0 24 24" class="sw-mode-tabs__icon" aria-hidden="true">
                <circle cx="12" cy="12" r="4" />
                <path
                  d="M12 3v2M12 19v2M3 12h2M19 12h2M5.6 5.6l1.4 1.4M17 17l1.4 1.4M5.6 18.4 7 17M17 7l1.4-1.4"
                />
              </svg>
              <span>${A(`skillWorkshop.header.today`)}</span>
            `}],ariaLabel:A(`skillWorkshop.header.view`),panelId:`skill-workshop-mode-panel`,variant:`sub`,onSelect:t=>H(e,t,r)})}
    </div>
  `}function U(){return(U=e((()=>{C(),Be(),E(),R(),V()})))()}function ht(e,t){if(t!==`workshop`){if(t===`skills`){e.navigate(`skills`);return}e.navigate(`plugins`,{pathname:Se(t,e.basePath)})}}function gt(){return(gt=e((()=>{Ee()})))()}function _t(e,t){let n=t?.trim();return n?e?.sessions.find(e=>ne(e.key,n))??null:null}function vt(e){return!!(e&&!e.archived&&!e.hasActiveRun)}async function yt(e,t){let n=e.sessions.state;return n.agentId===t&&n.result?.sessions.length?n.result:e.sessions.list({agentId:t})}function W(e,n,r){let i=r?.sessionId?.trim();return{sessionKey:e,targetAgentId:t(r?.agentId??n),...i?{sessionId:i}:{}}}async function bt(e,r,i){if(!i())return null;let a=r.gateway.snapshot,o=a.hello;if(e.useCurrentChatForRevisions){let t=m(Ce().sessionKey,o).trim();if(!t)return null;let n=d({assistantAgentId:a.assistantAgentId,agentsList:r.agents.state.agentsList,hello:o,sessionKey:t},t)??e.proposalAgentId,s=await yt(r,n);return i()?W(t,n,_t(s,t)):null}let s=t(e.proposalOriginAgentId??e.proposalAgentId),c=await yt(r,s);if(!i())return null;let l=_t(c,e.proposalOriginSessionKey);if(vt(l))return W(l.key,s,l);let u={agentId:s,label:n(`Skill Workshop: ${e.proposalSlug||e.proposalId}`,80)},f=p(r.gateway.snapshot,{method:`sessions.create`,params:u});if(!f.allowed)throw Error(f.reason);if(!i())return null;let h=await r.sessions.create(u);if(!i())return null;let g=m(h,o).trim();if(!g)throw Error(r.sessions.state.error??`Could not prepare a Skill Workshop thread.`);return W(g,s)}function xt(){return(xt=e((()=>{xe(),l(),f(),g()})))()}async function St(e){let n=e.context.gateway.snapshot,r=n.client;if(!r)throw Error(`Gateway is not connected.`);let i=()=>{let t=e.context.gateway.snapshot;return t.phase===`connected`&&t.client===r&&t.hello===n.hello},o=e.entry;if(!o.expectedRevisionHash){let n=await r.request(`skills.proposals.inspect`,{agentId:t(o.proposalAgentId),proposalId:o.proposalId});if(!i())throw Error(`Revision request was interrupted before proposal inspection completed.`);let a=n.revisionHash?.trim();if(!a)throw Error(`The proposal revision binding is unavailable.`);let s=n.record.origin,c=e.materialize({expectedRevisionHash:a,...s?.agentId?{proposalOriginAgentId:s.agentId}:{},...s?.sessionKey?{proposalOriginSessionKey:s.sessionKey}:{}});if(!c)throw Error(`Revision recovery is no longer available.`);o=c}if(!o.expectedRevisionHash)throw Error(`Revision recovery is no longer available.`);let s=await bt(o,e.context,i);if(!s)throw Error(`Revision request was interrupted before admission.`);let c=await r.request(`skills.proposals.requestRevision`,{agentId:t(o.proposalOriginAgentId??o.proposalAgentId),targetAgentId:s.targetAgentId,proposalId:o.proposalId,expectedRevisionHash:o.expectedRevisionHash,instructions:o.instructions,sessionKey:s.sessionKey,...s.sessionId?{sessionId:s.sessionId}:{},idempotencyKey:o.idempotencyKey}).catch(e=>{if(a(e))return{status:`revision-changed`};throw e});if(c.status===`revision-changed`)return c;if(c.status!==`started`&&c.status!==`in_flight`&&c.status!==`ok`)throw Error(`Gateway returned ${c.status} before admitting the revision request.`);return{sessionKey:s.sessionKey,status:`admitted`}}function Ct(){return(Ct=e((()=>{o(),g(),xt()})))()}var wt;function Tt(){return(Tt=e((()=>{E(),ie(),M(),Ct(),wt=class{constructor(e){this.requestUpdate=e,this.recoveryId=null}get active(){return this.recoveryId!==null}request(e){let t=e.context.skillWorkshopRevisionAdmissions,n=this.recoveryId?t.retry(this.recoveryId):t.start({...e.expectedRevisionHash?{expectedRevisionHash:e.expectedRevisionHash}:{},instructions:e.instructions,proposalAgentId:e.proposalAgentId,proposalId:e.proposal.key,...e.proposal.origin?.agentId?{proposalOriginAgentId:e.proposal.origin.agentId}:{},...e.proposal.origin?.sessionKey?{proposalOriginSessionKey:e.proposal.origin.sessionKey}:{},proposalSlug:e.proposal.slug,useCurrentChatForRevisions:e.state.skillWorkshopUseCurrentChatForRevisions},(t,n)=>St({context:e.context,entry:t,materialize:n}));return n?(this.recoveryId=n.entry.id,n.completion):Promise.resolve({error:`Revision recovery is no longer available.`,id:this.recoveryId??`missing`,status:`retryable-failed`})}sync(e,t){if(this.recoveryId){let n=e.skillWorkshopRevisionAdmissions.get(this.recoveryId);if(n?.phase===`retryable-failed`){this.restore(t,n);return}if(n)return;this.recoveryId=null;let r=!!(t.skillWorkshopRevisionKey||t.skillWorkshopRevisionDraft||t.skillWorkshopActionBusy||t.skillWorkshopError);t.skillWorkshopRevisionKey=null,t.skillWorkshopRevisionDraft=``,t.skillWorkshopActionBusy=null,t.skillWorkshopError=null,r&&this.requestUpdate()}if(t.skillWorkshopRevisionKey||t.skillWorkshopRevisionDraft)return;let n=e.skillWorkshopRevisionAdmissions.firstFailed(Xe(e));n&&(this.recoveryId=n.id,this.restore(t,n))}restore(e,t){let n=A(`skillWorkshop.revision.notAdmitted`,{error:ee(t.error??`Retry the revision request.`)}),r=e.skillWorkshopRevisionKey!==t.proposalId||e.skillWorkshopRevisionDraft!==t.instructions||e.skillWorkshopActionBusy!==null||e.skillWorkshopError!==n;e.skillWorkshopRevisionKey=t.proposalId,e.skillWorkshopRevisionDraft=t.instructions,e.skillWorkshopActionBusy=null,e.skillWorkshopError=n,r&&this.requestUpdate()}}})))()}function Et(e){let{state:t,context:n}=e;return t&&n?{state:t,context:n,epoch:e.epoch,gateway:n.gateway,agentSelection:n.agentSelection,sessions:n.sessions,navigate:n.navigate}:null}function Dt(e,t){let n=t.context;return t.state===e.state&&n===e.context&&t.epoch===e.epoch&&n?.gateway===e.gateway&&n.agentSelection===e.agentSelection&&n.sessions===e.sessions&&n.navigate===e.navigate}function Ot(e){let t=e.split(`
`),n=[];for(let e=0;e<t.length;e+=K)n.push(t.slice(e,e+K).join(`
`));return n}function kt(e){let t=e.split(`.`).pop()?.toLowerCase()??``;return{md:`Markdown`,txt:A(`filePreview.kind.text`),json:`JSON`,yaml:`YAML`,yml:`YAML`,ts:`TypeScript`,js:`JavaScript`,py:`Python`,sh:A(`filePreview.kind.shell`)}[t]??(t?t.toUpperCase():A(`filePreview.kind.file`))}function At(e){return jt[Le(e)]}var G,K,jt;function Mt(){return(Mt=e((()=>{C(),pe(),E(),re(),Oe(),Re(),k(),O(),G=class extends ae{constructor(...e){super(...e),this.files=[],this.activePath=``,this.query=``,this.label=``,this.listLabel=``,this.searchPlaceholder=``,this.contextLabel=``,this.readOnlyLabel=``,this.emptyTitle=``,this.emptySubtitle=``,this.copyLabel=``,this.filteredFiles=[],this.derivedInputsReady=!1,this.codeChunks=[],this.resetScrollAfterUpdate=!0,this.focusAfterUpdate=!1,this.handleQueryInput=e=>{let t=e.target.value??``;this.dispatchEvent(new CustomEvent(`file-preview-query-change`,{bubbles:!0,composed:!0,detail:t}))},this.preventItemPointerFocus=e=>{e.preventDefault()},this.handleKeydown=e=>{switch(e.key){case`Escape`:e.preventDefault(),e.stopPropagation(),this.emitClose();return;case`ArrowDown`:this.moveSelection(1,e);return;case`ArrowUp`:this.moveSelection(-1,e)}},this.emitClose=()=>{this.dispatchEvent(new CustomEvent(`file-preview-close`,{bubbles:!0,composed:!0}))}}static{this.styles=ve`
    :host {
      display: contents;
    }

    .modal {
      width: 100%;
      height: min(780px, 86vh);
      background: var(--bg);
      border: 1px solid var(--border-strong);
      border-radius: var(--radius-lg);
      box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }

    .head {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 16px 20px;
      border-bottom: 1px solid var(--border);
      background: var(--bg);
    }

    .search-icon {
      color: var(--muted);
      font-size: 18px;
    }

    .search {
      flex: 1;
      min-width: 0;
      background: transparent;
      border: none;
      outline: none;
      color: var(--text-strong);
      font: inherit;
      font-size: 18px;
      font-weight: 400;
      padding: 4px 0;
    }

    .search:focus,
    .search:focus-visible {
      outline: none;
      border: none;
      box-shadow: none;
    }

    .search::placeholder {
      color: var(--muted);
    }

    .state {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      font-size: 12px;
      color: var(--muted);
      padding: 5px 10px;
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      background: var(--bg-elevated);
    }

    .body {
      flex: 1;
      display: grid;
      grid-template-columns: 360px 1fr;
      min-height: 0;
    }

    .list {
      border-right: 1px solid var(--border);
      padding: 14px 10px;
      overflow-y: auto;
      display: flex;
      flex-direction: column;
      gap: 2px;
    }

    .list-section {
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: var(--muted);
      padding: 4px 12px 8px;
    }

    .item {
      display: grid;
      grid-template-columns: 16px 1fr auto;
      gap: 12px;
      align-items: center;
      padding: 12px 14px;
      border-radius: var(--radius-md);
      border: none;
      background: transparent;
      color: var(--text);
      font: inherit;
      outline: none;
      text-align: left;
    }

    .item:focus-visible {
      box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent);
    }

    .item:hover {
      background: var(--bg-elevated);
    }

    .item.is-active {
      background: var(--accent-subtle);
    }

    .item.is-active .item-name {
      color: var(--text-strong);
    }

    .item-icon {
      width: 16px;
      height: 16px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      color: var(--muted);
      opacity: 0.85;
    }

    .item.is-active .item-icon {
      color: var(--accent);
      opacity: 1;
    }

    .item-icon svg,
    .chat-copy-btn svg {
      width: 16px;
      height: 16px;
      stroke: currentColor;
      fill: none;
      stroke-width: 1.5px;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    .item-name {
      font-family: var(--mono);
      font-size: 14px;
      color: var(--text);
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .item-meta {
      color: var(--muted);
      font-size: 12px;
    }

    .empty-list {
      color: var(--muted);
      font-size: 13px;
      padding: 12px;
    }

    .detail {
      display: flex;
      flex-direction: column;
      min-width: 0;
      min-height: 0;
    }

    .detail.empty {
      align-items: center;
      justify-content: center;
      text-align: center;
      padding: 24px;
    }

    .detail-head {
      padding: 20px 24px 14px;
      border-bottom: 1px solid var(--border);
    }

    .detail-title-row {
      display: flex;
      align-items: center;
      gap: 12px;
      margin-bottom: 10px;
    }

    .title {
      flex: 1;
      min-width: 0;
      margin: 0;
      font-family: var(--mono);
      font-size: 22px;
      color: var(--text-strong);
      font-weight: 700;
      letter-spacing: -0.01em;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .chat-copy-btn {
      width: 32px;
      height: 32px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      flex: 0 0 auto;
      padding: 0;
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      background: var(--bg-elevated);
      color: var(--muted);
    }

    .chat-copy-btn:hover {
      border-color: var(--border-strong);
      color: var(--text-strong);
    }

    .chat-copy-btn:focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: 2px;
    }

    .chat-copy-btn__icon {
      display: inline-flex;
      width: 16px;
      height: 16px;
      position: relative;
    }

    .chat-copy-btn__icon-copy,
    .chat-copy-btn__icon-check {
      position: absolute;
      inset: 0;
      transition: opacity 150ms ease;
    }

    .chat-copy-btn__icon-check,
    .chat-copy-btn[data-copy-state="copied"] .chat-copy-btn__icon-copy {
      opacity: 0;
    }

    .chat-copy-btn[data-copy-state="copied"] .chat-copy-btn__icon-check {
      opacity: 1;
    }

    .chat-copy-btn[data-copy-state="copying"] {
      opacity: 0;
      pointer-events: none;
    }

    .chat-copy-btn[data-copy-state="error"] {
      border-color: var(--danger-subtle);
      background: var(--danger-subtle);
      color: var(--danger);
    }

    .chat-copy-btn[data-copy-state="copied"] {
      border-color: var(--ok-subtle);
      background: var(--ok-subtle);
      color: var(--ok);
    }

    .chips {
      display: flex;
      gap: 6px;
      flex-wrap: wrap;
    }

    .chip {
      display: inline-flex;
      align-items: center;
      padding: 3px 10px;
      border-radius: 999px;
      font-size: 11.5px;
      background: var(--bg-elevated);
      border: 1px solid var(--border);
      color: var(--muted);
    }

    .chip.accent {
      background: var(--accent-subtle);
      border-color: color-mix(in srgb, var(--accent) 30%, transparent);
      color: var(--accent);
    }

    .chip.ok {
      background: color-mix(in srgb, var(--ok) 12%, transparent);
      border-color: color-mix(in srgb, var(--ok) 30%, transparent);
      color: var(--ok);
    }

    .detail-body {
      flex: 1;
      overflow-x: hidden;
      overflow-y: auto;
      padding: 20px 24px 24px;
    }

    .code-content {
      min-width: 0;
    }

    .code-chunk {
      margin: 0;
      min-width: 0;
      font-family: var(--mono);
      font-size: 13px;
      line-height: 1.7;
      color: var(--text);
      white-space: pre-wrap;
      word-break: break-word;
      content-visibility: auto;
      contain-intrinsic-block-size: auto 1414px;
    }

    .foot {
      display: flex;
      align-items: center;
      gap: 18px;
      padding: 12px 20px;
      border-top: 1px solid var(--border);
      background: var(--bg);
      font-size: 12px;
      color: var(--muted);
    }

    .foot-group {
      display: inline-flex;
      align-items: center;
      gap: 6px;
    }

    .kbd {
      font-family: var(--mono);
      font-size: 10.5px;
      padding: 2px 6px;
      border: 1px solid var(--border);
      border-radius: 4px;
      background: var(--bg-elevated);
      color: var(--text);
    }

    .spacer {
      flex: 1;
    }

    .button {
      height: 36px;
      padding: 0 14px;
      border-radius: var(--radius-md);
      border: 1px solid var(--border);
      background: var(--bg-elevated);
      color: var(--text);
      font-weight: 600;
    }

    .button:hover {
      border-color: var(--border-strong);
      color: var(--text-strong);
    }

    .empty-title {
      font-size: 16px;
      font-weight: 600;
      color: var(--text-strong);
      margin: 0 0 8px;
    }

    .empty-subtitle {
      margin: 0;
      font-size: 13px;
      color: var(--muted);
      max-width: 380px;
    }

    @media (max-width: 640px) {
      .head {
        padding: 12px;
      }

      .body {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: minmax(0, min(180px, 30dvh)) minmax(0, 1fr);
      }

      .list {
        min-width: 0;
        border-right: 0;
        border-bottom: 1px solid var(--border);
        padding: 10px 8px;
      }

      .item {
        min-width: 0;
      }

      .foot {
        gap: 8px;
        padding: 10px 12px;
      }
    }
  `}willUpdate(e){if(!(!this.derivedInputsReady||e.has(`activePath`)||e.has(`query`)||e.has(`files`)))return;this.derivedInputsReady=!0,this.filteredFiles=this.filterFiles();let t=this.resolveActiveFile(this.filteredFiles);this.activeFile=t;let n=t?.contents;n!==this.codeSource&&(this.codeSource=n,this.codeChunks=n===void 0?[]:Ot(n)),this.resetScrollAfterUpdate=!0}render(){let e=this.filteredFiles,t=this.activeFile,n=e.length===this.files.length?A(`filePreview.fileCount`,{count:String(this.files.length)}):A(`filePreview.filteredFileCount`,{count:String(e.length),total:String(this.files.length)}),r=this.label||A(`filePreview.label`),i=this.listLabel||A(`filePreview.listLabel`),a=this.searchPlaceholder||A(`filePreview.searchPlaceholder`);return S`
      <openclaw-modal-dialog
        label=${r}
        style="--openclaw-modal-width: min(1100px, 92vw); --openclaw-modal-max-height: 86vh;"
        @modal-cancel=${this.emitClose}
        @keydown=${this.handleKeydown}
      >
        <div class="modal">
          <header class="head">
            <span class="search-icon">⌕</span>
            <input
              class="search"
              placeholder=${a}
              .value=${this.query}
              @input=${this.handleQueryInput}
            />
            <span class="state">${n}</span>
          </header>
          <div class="body">
            <aside class="list">
              <div class="list-section">${i} · ${e.length}</div>
              ${e.length===0?S`<div class="empty-list">${A(`filePreview.noMatches`)}</div>`:e.map(e=>S`
                      <button
                        class="item ${e.path===t?.path?`is-active`:``}"
                        @pointerdown=${this.preventItemPointerFocus}
                        @mousedown=${this.preventItemPointerFocus}
                        @click=${()=>this.emitSelect(e.path)}
                      >
                        <span class="item-icon">${At(e.path)}</span>
                        <span class="item-name">${e.path}</span>
                        <span class="item-meta">${e.size}</span>
                      </button>
                    `)}
            </aside>
            ${t?this.renderFile(t):this.renderEmpty()}
          </div>
          <footer class="foot">
            <span class="foot-group"><span class="kbd">↑↓</span> ${A(`filePreview.navigate`)}</span>
            <span class="spacer"></span>
            <button class="button" @click=${this.emitClose}>
              ${A(`common.close`)} <span class="kbd">esc</span>
            </button>
          </footer>
        </div>
      </openclaw-modal-dialog>
    `}renderFile(e){return S`
      <section class="detail">
        <div class="detail-head">
          <div class="detail-title-row">
            <h2 class="title">${e.path}</h2>
            ${e.contents?ke(e.contents,this.copyLabel||A(`filePreview.copyFile`)):``}
          </div>
          <div class="chips">
            <span class="chip accent">${kt(e.path)}</span>
            <span class="chip">${e.size}</span>
            <span class="chip">${this.readOnlyLabel||A(`filePreview.readOnly`)}</span>
            ${this.contextLabel?S`<span class="chip ok">${this.contextLabel}</span>`:``}
          </div>
        </div>
        <div class="detail-body">
          <div class="code-content">
            ${this.codeChunks.map((e,t)=>S`<pre class="code-chunk" data-chunk=${t}>${e}</pre>`)}
          </div>
        </div>
      </section>
    `}renderEmpty(){return S`
      <section class="detail empty">
        <p class="empty-title">${this.emptyTitle||A(`filePreview.emptyTitle`)}</p>
        <p class="empty-subtitle">${this.emptySubtitle||A(`filePreview.emptySubtitle`)}</p>
      </section>
    `}filterFiles(){let e=this.query.trim().toLowerCase();return e?this.files.filter(t=>`${t.path}\n${t.contents}`.toLowerCase().includes(e)):this.files}resolveActiveFile(e){return e.find(e=>e.path===this.activePath)??e[0]}connectedCallback(){super.connectedCallback(),this.resetScrollAfterUpdate=!0,this.focusAfterUpdate=!0,this.requestUpdate()}updated(e){if(this.resetScrollAfterUpdate){this.resetScrollAfterUpdate=!1;let e=this.detailBody;e&&(e.scrollTop=0,e.scrollLeft=0)}(e.has(`activePath`)||e.has(`query`)||e.has(`files`))&&this.scrollActiveFileIntoView(),this.focusAfterUpdate&&this.isConnected&&(this.focusAfterUpdate=!1,this.focusModal())}focusModal(){(this.searchInput??this.shadowRoot?.querySelector(`.modal`))?.focus({preventScroll:!0})}moveSelection(e,t){t.preventDefault(),t.stopPropagation();let n=this.filterFiles();if(n.length===0)return;let r=this.resolveActiveFile(n),i=r?n.findIndex(e=>e.path===r.path):-1,a=n[Math.max(0,Math.min(n.length-1,i+e))];a&&a.path!==r?.path&&this.emitSelect(a.path)}scrollActiveFileIntoView(){this.updateComplete.then(()=>{this.isConnected&&this.shadowRoot?.querySelector(`.item.is-active`)?.scrollIntoView({block:`nearest`})}).catch(()=>{})}emitSelect(e){this.dispatchEvent(new CustomEvent(`file-preview-select`,{bubbles:!0,composed:!0,detail:e})),this.focusModal()}},c([w({attribute:!1})],G.prototype,`files`,void 0),c([w()],G.prototype,`activePath`,void 0),c([w()],G.prototype,`query`,void 0),c([w()],G.prototype,`label`,void 0),c([w()],G.prototype,`listLabel`,void 0),c([w()],G.prototype,`searchPlaceholder`,void 0),c([w()],G.prototype,`contextLabel`,void 0),c([w()],G.prototype,`readOnlyLabel`,void 0),c([w()],G.prototype,`emptyTitle`,void 0),c([w()],G.prototype,`emptySubtitle`,void 0),c([w()],G.prototype,`copyLabel`,void 0),c([_e(`.search`)],G.prototype,`searchInput`,void 0),c([_e(`.detail-body`)],G.prototype,`detailBody`,void 0),K=64,jt={code:D.fileCode,component:D.layoutGrid,data:D.braces,file:D.fileText,image:D.image,markdown:D.book,package:D.box,shell:D.terminal}})))()}function Nt(){return(Nt=e((()=>{Mt(),customElements.get(`openclaw-file-preview-modal`)||customElements.define(`openclaw-file-preview-modal`,G)})))()}function Pt(){return Vt??=r(()=>import(`./applied-history.runtime-DOjIkwDo.js`).then(e=>(q=e,e)),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]),import.meta.url)}function Ft(){return S`<p class="sw-muted" aria-busy="true">${A(`common.loading`)}</p>`}function It(e,t,n){let r=Qe(e,t),i=r.find(e=>e.revisions.some(({proposal:e})=>e.key===n))??r[0];return{skills:r,selectedSkill:i,selectedProposal:i?.revisions.find(({proposal:e})=>e.key===n)?.proposal??i?.latest}}function Lt(e,t,n){return!n||e.appliedDiffMode===`full`?{kind:`full`}:n.bodyLoaded?n.body.length+t.body.length>Bt?{kind:`tooLarge`}:{kind:`diff`,previous:n}:e.inspectingKey===n.key?{kind:`loadingPrevious`}:{kind:`previousUnavailable`}}function Rt(e,t){return q?q.renderAppliedHistory(e,t):ye(Pt().then(n=>n.renderAppliedHistory(e,t)),Ft())}function zt(e,t){return q?q.renderAppliedRevisionDiff(e,t):ye(Pt().then(n=>n.renderAppliedRevisionDiff(e,t)),Ft())}var Bt,q,Vt;function Ht(){return(Ht=e((()=>{C(),he(),E(),i(),Bt=12e4})))()}function Ut(e,t){let n=Wt(e,t);return S`
    <div class="sw-detail sw-detail--empty">
      <div class="sw-filter-empty">
        <div class="sw-filter-empty__icon" aria-hidden="true">
          ${Gt(n.icon)}
        </div>
        <p class="sw-empty__title">${n.title}</p>
        <p class="sw-empty__sub">${n.body}</p>
      </div>
    </div>
  `}function Wt(e,t){if(e.trim())return{icon:`search`,title:A(`skillWorkshop.empty.searchTitle`),body:A(`skillWorkshop.empty.searchBody`)};switch(t){case`pending`:return{icon:`clock`,title:A(`skillWorkshop.empty.pendingTitle`),body:A(`skillWorkshop.empty.pendingBody`)};case`applied`:return{icon:`check`,title:A(`skillWorkshop.empty.appliedTitle`),body:A(`skillWorkshop.empty.appliedBody`)};case`rejected`:return{icon:`x`,title:A(`skillWorkshop.empty.rejectedTitle`),body:A(`skillWorkshop.empty.rejectedBody`)};case`quarantined`:return{icon:`shield`,title:A(`skillWorkshop.empty.quarantinedTitle`),body:A(`skillWorkshop.empty.quarantinedBody`)};case`stale`:return{icon:`refresh`,title:A(`skillWorkshop.empty.staleTitle`),body:A(`skillWorkshop.empty.staleBody`)};case`all`:return{icon:`search`,title:A(`skillWorkshop.empty.allTitle`),body:A(`skillWorkshop.empty.allBody`)}}return{icon:`search`,title:A(`skillWorkshop.empty.allTitle`),body:A(`skillWorkshop.empty.allBody`)}}function Gt(e){return qt[e]}function Kt(e){return S`
    <div class="sw-empty-state">
      <section class="sw-empty-state__panel" aria-label=${A(`skillWorkshop.empty.noProposalsAria`)}>
        <div class="sw-empty-state__glyph" aria-hidden="true">
          <span></span>
          <span></span>
          <span></span>
        </div>
        <p class="sw-empty-state__eyebrow">${A(`skillWorkshop.title`)}</p>
        <h2>${A(`skillWorkshop.empty.noProposalsTitle`)}</h2>
        <p>${A(`skillWorkshop.empty.noProposalsBody`,{agent:e.agentName})}</p>
        <div class="sw-empty-state__footer">${A(`skillWorkshop.empty.noProposalsFooter`)}</div>
        ${st(e.selfLearning,e.onSelfLearningToggle)}
      </section>
    </div>
  `}var qt;function Jt(){return(Jt=e((()=>{C(),k(),E(),R(),qt={search:D.search,clock:D.clock,check:D.check,x:D.x,shield:D.shieldCheck,refresh:D.refresh}})))()}function Yt(e,t,n,r,i){let a=t.reduce((e,t)=>e+t.items.length,0),o=new Map(r.map(e=>[e.slug,e]));return S`
    <aside class="sw-queue">
      <div class="sw-queue__search">
        <input
          placeholder=${A(`skillWorkshop.queue.search`)}
          .value=${e.query}
          @input=${t=>e.onQueryChange(t.currentTarget.value??``)}
        />
      </div>
      <div class="sw-queue__body">
        ${a===0?S`<div class="sw-queue__empty">${i}</div>`:t.map(t=>S`
                <div class="sw-queue__group">
                  ${A(t.label)}
                  <span class="settings-count">${t.items.length}</span>
                </div>
                ${t.items.map(t=>Xt(e,t,n,o.get(t.slug)))}
              `)}
      </div>
    </aside>
  `}function Xt(e,t,n,r){let i=r?.latest??t,a=r?r.revisions.some(({proposal:t})=>t.key===e.selectedKey):n?.key===t.key,o=r?.revisions.length===1?`skillWorkshop.applied.revision`:`skillWorkshop.applied.revisions`;return S`
    <button
      class="sw-row ${i.isNew?`is-new`:`is-seen`} ${a?`is-selected`:``}"
      @click=${()=>e.onSelect(i.key)}
    >
      <span class="sw-row__dot"></span>
      <span>
        <span class="sw-row__title">${r?.slug??t.name}</span>
        <span class="sw-row__desc">${i.oneLine}</span>
      </span>
      ${r?S`
            <span class="sw-row__meta sw-row__meta--applied">
              <span class="sw-row__revision-count">
                ${A(o,{count:String(r.revisions.length)})}
              </span>
              <span>${i.ageLabel}</span>
            </span>
          `:S`<span class="sw-row__meta">${t.ageLabel}</span>`}
    </button>
  `}function Zt(){return(Zt=e((()=>{C(),E()})))()}function Qt(e){let t=e.statusFilter===`applied`?It(e.proposals,e.query,e.selectedKey):void 0,n=t?t.skills.map(e=>e.latest):N(e.proposals,e.statusFilter,e.query),r=t?.selectedProposal??n.find(t=>t.key===e.selectedKey)??n[0],i=En(n),a=r&&e.filePreviewKey?r.supportFiles.find(t=>t.path===e.filePreviewKey):null,o=e.revisionKey?e.proposals.find(t=>t.key===e.revisionKey):null,s=e.proposals.filter(e=>e.status===`pending`),c=r??s[0]??e.proposals[0],l=e.proposals.length===0&&!e.loading&&!e.error?Kt({agentName:un(e,A(`skillWorkshop.empty.defaultAgent`)),selfLearning:e.selfLearning,onSelfLearningToggle:e.onSelfLearningToggle}):e.mode===`today`?dn(e,c,s):en(e,i,r,t?.skills??[],t?.selectedSkill);return S`
    <section class="skill-workshop sw-mode-${e.mode}">
      ${e.error?S`<div class="sw-error" role="status">
            <span>${e.error}</span>
            <button type="button" class="btn btn--sm" @click=${e.onRetry}>
              ${A(`pluginsPage.tryAgain`)}
            </button>
          </div>`:x}
      ${ct(e.selfLearning)}
      ${Ge({state:e.historyScan,canScan:e.access.canScanHistory,onScan:e.onHistoryScan})}
      <div class="sw-view" data-mode=${e.mode}>
        ${be(e.mode,S`<div class="sw-view__pane">${l}</div>`)}
      </div>
    </section>
    ${a&&r?S`
          <openclaw-file-preview-modal
            .files=${r.supportFiles}
            .activePath=${a.path}
            .query=${e.filePreviewQuery}
            .contextLabel=${A(`skillWorkshop.previewContext`,{slug:r.slug})}
            @file-preview-query-change=${t=>e.onFilePreviewQueryChange(t.detail)}
            @file-preview-select=${t=>e.onPreviewFile(r.key,t.detail)}
            @file-preview-close=${e.onClosePreview}
          ></openclaw-file-preview-modal>
        `:x}
    ${o?$t(e,o):x}
  `}function $t(e,t){let n=e.actionBusy?.key===t.key&&e.actionBusy.action===`revise`,r=!!e.actionBusy||e.revisionRecoveryActive,i=e.access.canRevise&&e.revisionDraft.trim().length>0&&!e.actionBusy,a=e.mode===`board`?A(`skillWorkshop.actions.revise`):A(`skillWorkshop.actions.tweak`);return S`
    <openclaw-modal-dialog
      .label=${`${A(`skillWorkshop.revision.title`,{verb:a})}: ${t.slug}`}
      .description=${A(`skillWorkshop.revision.description`)}
      style="--openclaw-modal-width: 560px"
      @modal-cancel=${r?void 0:e.onRevisionCancel}
    >
      <section class="sw-revision-dialog ${n?`sw-revision-dialog--sending`:``}">
        <div class="sw-revision-dialog__head">
          <div>
            <div class="sw-revision-dialog__eyebrow">
              ${A(`skillWorkshop.revision.title`,{verb:a})}
            </div>
            <h2 id="sw-revision-title">${t.slug}</h2>
          </div>
          <openclaw-tooltip content=${A(`skillWorkshop.actions.close`)}>
            <button
              type="button"
              class="sw-revision-dialog__close"
              aria-label=${A(`skillWorkshop.actions.close`)}
              ?disabled=${r}
              @click=${e.onRevisionCancel}
            >
              ×
            </button>
          </openclaw-tooltip>
        </div>
        <p class="sw-revision-dialog__copy">${A(`skillWorkshop.revision.description`)}</p>
        <textarea
          class="sw-revision-dialog__input"
          autofocus
          placeholder=${A(`skillWorkshop.revision.placeholder`)}
          .value=${e.revisionDraft}
          ?disabled=${!e.access.canRevise||!!e.actionBusy||e.revisionRecoveryActive}
          @input=${t=>e.onRevisionDraftChange(t.target.value??``)}
        ></textarea>
        ${n?S`
              <div class="sw-revision-dialog__status" role="status">
                <span class="sw-revision-dialog__status-dot" aria-hidden="true"></span>
                <span>${A(`skillWorkshop.revision.preparing`)}</span>
              </div>
            `:x}
        <div class="sw-revision-dialog__actions">
          <button
            type="button"
            class="sw-btn sw-btn--ghost"
            ?disabled=${r}
            @click=${e.onRevisionCancel}
          >
            ${A(`skillWorkshop.actions.cancel`)}
          </button>
          <button
            type="button"
            class="sw-btn sw-btn--primary ${n?`is-busy`:``}"
            ?disabled=${!i}
            @click=${()=>e.onRevisionSubmit(t.key)}
          >
            ${A(n?`skillWorkshop.actions.sending`:`skillWorkshop.revision.send`)}
          </button>
        </div>
      </section>
    </openclaw-modal-dialog>
  `}function en(e,t,n,r,i){return S`
    ${nn(e)}
    <div class="sw-triage" style=${fe({"--sw-queue-width":`${e.queueWidth}px`})}>
      ${Yt(e,t,n,r,Dn(e))}
      ${tn(e)}
      ${n?sn(e,n,i):Ut(e.query,e.statusFilter)}
    </div>
  `}function tn(e){let t,n=()=>(t?.previousElementSibling?.getBoundingClientRect().width??0)+(t?.nextElementSibling?.getBoundingClientRect().width??0);return S`<resizable-divider
    ${ge(e=>t=e instanceof HTMLElement?e:void 0)}
    class="sw-queue-resizer"
    .label=${A(`skillWorkshop.queue.resize`)}
    .splitRatio=${.5}
    .minRatio=${.2}
    .maxRatio=${.8}
    .measureRatio=${()=>e.queueWidth/n()}
    .measureSize=${n}
    @resize=${t=>e.onQueueWidthChange(t.detail.splitRatio*n())}
  ></resizable-divider>`}function nn(e){return S`
    <div class="sw-lifecycle-tabs">
      ${On.map(t=>{let n=e.statusFilter===t,r=e.counts[t]??0;return S`
          <button
            class="sw-lifecycle-tab ${n?`is-active`:``}"
            @click=${()=>e.onStatusFilterChange(t)}
          >
            ${A(Z[t])} <span class="settings-count">${r}</span>
          </button>
        `})}
    </div>
  `}function rn(e,t,n){let r=e.appliedDiffMode===t;return S`
    <button
      class="sw-body-mode__button ${r?`is-active`:``}"
      aria-pressed=${r?`true`:`false`}
      @click=${()=>e.onAppliedDiffModeChange(t)}
    >
      ${n}
    </button>
  `}function an(e){return S`
    <div class="sw-body-mode" role="group" aria-label=${A(`skillWorkshop.diff.viewLabel`)}>
      ${rn(e,`changes`,A(`skillWorkshop.diff.changes`))}
      ${rn(e,`full`,A(`skillWorkshop.diff.fullBody`))}
    </div>
  `}function on(e,t){return e.kind===`diff`?zt(e.previous.body,t.body):e.kind===`loadingPrevious`?S`<p class="sw-muted" aria-busy="true">
      ${A(`skillWorkshop.diff.loadingPrevious`)}
    </p>`:e.kind===`previousUnavailable`?S`
      <p class="sw-muted">${A(`skillWorkshop.diff.previousUnavailable`)}</p>
      ${wn(t.body)}
    `:e.kind===`tooLarge`?S`<p class="sw-muted">${A(`skillWorkshop.diff.tooLarge`)}</p>`:wn(t.body)}function sn(e,t,n){let r=t.updatedAt&&t.updatedAt>t.createdAt?t.updatedAt:null,i=r?A(`skillWorkshop.detail.edited`,{time:X(r)}):A(`skillWorkshop.detail.created`,{time:X(t.createdAt)}),a=e.inspectingKey===t.key&&!t.bodyLoaded,o=t.supportFiles[0],s=n?.revisions.find(({proposal:e})=>e.key===t.key)?.previous??null,c=Lt(e,t,s);return S`
    <div class="sw-detail">
      <div class="sw-detail__head">
        <div class="sw-detail__head-left">
          <h1 class="sw-detail__title">${t.name}</h1>
          <div class="sw-detail__one-line">${t.oneLine}</div>
          <div class="sw-detail__meta">
            <span>${i}</span>
            <span>·</span>
            <span>v${t.version}</span>
            <span>·</span>
            ${o?S`<button
                  class="sw-detail__meta-link"
                  @click=${()=>e.onPreviewFile(t.key,o.path)}
                >
                  ${A(`skillWorkshop.detail.supportFiles`,{count:String(t.supportFiles.length)})}
                </button>`:S`<span>${A(`skillWorkshop.detail.noSupportFiles`)}</span>`}
          </div>
        </div>
        <div class="sw-detail__nav">
          <openclaw-tooltip content=${A(`skillWorkshop.actions.previous`)}>
            <button aria-label=${A(`skillWorkshop.actions.previous`)} @click=${e.onPrev}>
              ↑
            </button>
          </openclaw-tooltip>
          <openclaw-tooltip content=${A(`skillWorkshop.actions.next`)}>
            <button aria-label=${A(`skillWorkshop.actions.next`)} @click=${e.onNext}>↓</button>
          </openclaw-tooltip>
        </div>
      </div>

      <div class="sw-detail__body">
        <div class="sw-body-card">
          <div class="sw-body-card__head">
            <h1>${t.slug}</h1>
            ${s?an(e):x}
          </div>
          ${a?S`<p class="sw-muted">${A(`skillWorkshop.detail.loading`)}</p>`:on(c,t)}
        </div>

        ${n?Rt(e,n):x}
        ${t.supportFiles.length>0?S`
              <div class="sw-section" style="margin-top: 18px;">
                <h3 class="sw-section__label">${A(`skillWorkshop.detail.supportFilesTitle`)}</h3>
                <div class="sw-files">
                  ${t.supportFiles.map(n=>S`
                      <button
                        class="sw-file"
                        @click=${()=>e.onPreviewFile(t.key,n.path)}
                      >
                        <span>📄</span>
                        <span class="sw-file__name">${n.path}</span>
                        <span class="sw-file__size"
                          >${n.size}
                          <span class="sw-file__hint"
                            >${A(`skillWorkshop.detail.clickToPreview`)}</span
                          ></span
                        >
                      </button>
                    `)}
                </div>
              </div>
            `:x}
        ${t.evaluation?Y(t.evaluation):x}
      </div>

      ${e.actionNotice?.key===t.key?cn(e.actionNotice):x}
      ${t.status===`pending`?ln(e,t):x}
    </div>
  `}function cn(e){return S`
    <div class="sw-action-toast" role="status" aria-live="polite">
      <span>${e.label}</span>
      <strong>${e.slug}</strong>
      <span>·</span>
    </div>
  `}function J(e){return{proposalId:e.key,expectedRevisionHash:e.revisionHash}}function ln(e,t){let n=e.actionBusy?.key===t.key?e.actionBusy.action:null,r=!!e.actionBusy;return S`
    <div class="sw-action-bar" aria-busy=${n?`true`:`false`}>
      <button
        class="sw-btn ${n===`evaluate`?`is-busy`:``}"
        ?disabled=${r||!e.access.canEvaluate}
        @click=${()=>e.onEvaluate(t.key)}
      >
        ${A(n===`evaluate`?`skillWorkshop.actions.evaluating`:`skillWorkshop.actions.evaluate`)}
      </button>
      <button
        class="sw-btn sw-btn--primary ${n===`apply`?`is-busy`:``}"
        ?disabled=${r||!e.access.canApply}
        @click=${()=>e.onApply(J(t))}
      >
        ${A(n===`apply`?`skillWorkshop.actions.applying`:`skillWorkshop.actions.apply`)}
      </button>
      <button
        class="sw-btn ${n===`revise`?`is-busy`:``}"
        ?disabled=${r||!e.access.canRevise}
        @click=${()=>e.onRevise(t.key)}
      >
        ${A(n===`revise`?`skillWorkshop.actions.opening`:`skillWorkshop.actions.revise`)}
      </button>
      <button
        class="sw-btn sw-btn--ghost sw-btn--danger ${n===`reject`?`is-busy`:``}"
        ?disabled=${r||!e.access.canReject}
        @click=${()=>e.onReject(J(t))}
      >
        ${A(n===`reject`?`skillWorkshop.actions.rejecting`:`skillWorkshop.actions.reject`)}
      </button>
    </div>
  `}function un(e,t){return e.workshopAgentName.trim()||e.assistantName.trim()||t}function dn(e,t,n){if(!t)return S`
      <div class="sw-today sw-today--empty">
        <p class="sw-empty__title">${A(`skillWorkshop.today.emptyTitle`)}</p>
        <p class="sw-empty__sub">${A(`skillWorkshop.today.emptyBody`)}</p>
      </div>
    `;let r=Math.max(0,n.findIndex(e=>e.key===t.key)),i=Math.max(n.length,1),a=n.filter(e=>e.key!==t.key).slice(0,3),o=e.proposals.filter(e=>e.status===`applied`).slice(0,3),s=t.isNew?A(`skillWorkshop.today.new`):t.status===`pending`?A(`skillWorkshop.today.waiting`):A(`skillWorkshop.today.reviewed`),c=t.ageLabel,l=Cn(Date.now()),u=t.status===`pending`,d=e.actionBusy?.key===t.key?e.actionBusy.action:null,f=!!e.actionBusy,p=un(e,A(`skillWorkshop.today.agent`)),m=t.supportFiles[0];return S`
    <div class="sw-today">
      <div class="sw-today__head">
        <div class="sw-today__date">${l}</div>
        <h1 class="sw-today__h1">
          ${A(`skillWorkshop.today.proposalsWaiting`,{count:String(n.length)})}
        </h1>
        ${n.length===0?S`<div class="sw-today__sub">${A(`skillWorkshop.today.browseApplied`)}</div>`:x}
        ${n.length>0?S`
              <div class="sw-today__progress">
                <span
                  >${A(`skillWorkshop.today.progress`,{current:String(r+1),total:String(i)})}</span
                >
                <div class="sw-today__dots">
                  ${n.map((e,t)=>S`
                      <span
                        class="sw-today__dot ${t<r?`is-done`:t===r?`is-now`:``}"
                      ></span>
                    `)}
                </div>
              </div>
            `:x}
      </div>

      <article class="sw-today__hero">
        <div class="sw-today__label">
          <span class="sw-today__ping"></span>
          ${s} · ${c}
        </div>
        <h2 class="sw-today__name">${t.slug}</h2>
        <p class="sw-today__one-liner">${t.oneLine}</p>

        ${hn(t)}

        <div class="sw-today__author">
          <span class="sw-today__avatar">v${t.version}</span>
          <span>
            ${A(`skillWorkshop.today.draftedBy`)}
            <strong>${p}</strong> · ${c}.
            ${m?S`
                  <button
                    class="sw-today__files-link"
                    @click=${()=>e.onPreviewFile(t.key,m.path)}
                  >
                    ${A(t.supportFiles.length===1?`skillWorkshop.today.supportFile`:`skillWorkshop.today.supportFiles`,{count:String(t.supportFiles.length)})}
                  </button>
                  ${A(`skillWorkshop.today.comeWithIt`)}
                `:x}
          </span>
        </div>

        ${t.evaluation?Y(t.evaluation,!0):x}
        ${u?S`
              <div class="sw-today__actions" aria-busy=${d?`true`:`false`}>
                <button
                  class="sw-today__big sw-today__big--evaluate ${d===`evaluate`?`is-busy`:``}"
                  ?disabled=${f||!e.access.canEvaluate}
                  @click=${()=>e.onEvaluate(t.key)}
                >
                  ${A(d===`evaluate`?`skillWorkshop.actions.evaluating`:`skillWorkshop.today.evaluate`)}
                  <span class="sw-today__big-sub">${A(`skillWorkshop.today.runChecks`)}</span>
                </button>
                <button
                  class="sw-today__big sw-today__big--primary ${d===`apply`?`is-busy`:``}"
                  ?disabled=${f||!e.access.canApply}
                  @click=${()=>e.onApply(J(t))}
                >
                  ${A(d===`apply`?`skillWorkshop.actions.applying`:`skillWorkshop.today.useIt`)}
                  <span class="sw-today__big-sub">${A(`skillWorkshop.today.addToSkills`)}</span>
                </button>
                <button
                  class="sw-today__big sw-today__big--tweak ${d===`revise`?`is-busy`:``}"
                  ?disabled=${f||!e.access.canRevise}
                  @click=${()=>e.onRevise(t.key)}
                >
                  ${A(d===`revise`?`skillWorkshop.actions.opening`:`skillWorkshop.today.tweakIt`)}
                  <span class="sw-today__big-sub">${A(`skillWorkshop.today.askAgent`)}</span>
                </button>
                <button
                  class="sw-today__big sw-today__big--skip ${d===`reject`?`is-busy`:``}"
                  ?disabled=${f||!e.access.canReject}
                  @click=${()=>e.onReject(J(t))}
                >
                  ${A(d===`reject`?`skillWorkshop.today.skipping`:`skillWorkshop.today.skip`)}
                  <span class="sw-today__big-sub">${A(`skillWorkshop.today.notForMe`)}</span>
                </button>
              </div>
            `:x}
        ${e.actionNotice?.key===t.key?cn(e.actionNotice):x}
      </article>

      ${a.length>0?S`
            <section class="sw-today__section">
              <header class="sw-today__section-head">
                <h3>
                  ${A(`skillWorkshop.today.upNext`,{count:String(n.length-1)})}
                </h3>
                <button class="sw-today__link" @click=${()=>e.onModeChange(`board`)}>
                  ${A(`skillWorkshop.today.seeAll`)}
                </button>
              </header>
              <div class="sw-today__upnext">
                ${a.map(t=>S`
                    <button class="sw-today__mini" @click=${()=>e.onSelect(t.key)}>
                      <div class="sw-today__mini-name">${t.slug}</div>
                      <div class="sw-today__mini-desc">${t.oneLine}</div>
                      <div class="sw-today__mini-meta">${t.ageLabel}</div>
                    </button>
                  `)}
              </div>
            </section>
          `:x}
      ${o.length>0?S`
            <section class="sw-today__section">
              <header class="sw-today__section-head">
                <h3>
                  ${A(`skillWorkshop.today.collection`,{count:String(e.counts.applied)})}
                </h3>
                <button
                  class="sw-today__link sw-today__link--muted"
                  @click=${()=>e.onModeChange(`board`)}
                >
                  ${A(`skillWorkshop.today.manage`)}
                </button>
              </header>
              <div class="sw-today__applied">
                ${o.map(t=>S`
                    <button
                      class="sw-today__applied-row"
                      @click=${()=>{e.onSelect(t.key),e.onModeChange(`board`)}}
                    >
                      <span class="sw-today__check">✓</span>
                      <span class="sw-today__applied-name">
                        <strong>${t.slug}</strong> — ${t.oneLine}
                      </span>
                      <span class="sw-today__applied-when">${t.ageLabel}</span>
                    </button>
                  `)}
              </div>
            </section>
          `:x}
    </div>
  `}function Y(e,t=!1){let n=Date.parse(e.completedAt);return S`
    <section class="sw-evaluation ${t?`sw-evaluation--today`:``}">
      <header class="sw-evaluation__head">
        <h3>${A(`skillWorkshop.evaluation.title`)}</h3>
        <div class="sw-evaluation__meta">
          <span>
            ${A(`skillWorkshop.evaluation.version`,{version:e.proposedVersion})}
          </span>
          ${Number.isFinite(n)?S`<span>
                ${A(`skillWorkshop.evaluation.completedAt`,{time:X(n)})}
              </span>`:x}
        </div>
      </header>
      <div class="sw-evaluation__outcomes">
        ${e.outcomes.map(e=>fn(e))}
      </div>
    </section>
  `}function fn(e){let t=e.result,n=e.pluginVersion?`${e.pluginId} ${e.pluginVersion}`:e.pluginId;return S`
    <section class="sw-evaluation__outcome">
      <div class="sw-evaluation__outcome-head">
        <div class="sw-evaluation__identity">
          <strong>${e.evaluatorId}</strong>
          <span>${n}</span>
        </div>
        <div class="sw-evaluation__badges">
          <span class="sw-evaluation__badge is-${e.status}">
            ${A(`skillWorkshop.evaluation.status.${e.status}`)}
          </span>
          ${t?.decision?S`<span class="sw-evaluation__badge is-${t.decision}">
                ${A(`skillWorkshop.evaluation.decision.${t.decision}`)}
              </span>`:x}
        </div>
      </div>
      ${t?.summary?S`<p class="sw-evaluation__summary">${t.summary}</p>`:x}
      ${t?.decisionReason?S`<p class="sw-evaluation__reason">${b(t.decisionReason)}</p>`:x}
      ${e.error?S`<p class="sw-evaluation__error">${b(e.error)}</p>`:x}
      ${t?.findings?.length?pn(t.findings):x}
      ${t?.metrics&&Object.keys(t.metrics).length>0?mn(t.metrics):x}
      ${t?.evaluatorVersion||t?.mode?S`
            <div class="sw-evaluation__runtime">
              ${t.evaluatorVersion?S`<span>
                    ${A(`skillWorkshop.evaluation.evaluatorVersion`,{version:t.evaluatorVersion})}
                  </span>`:x}
              ${t.mode?S`<span> ${A(`skillWorkshop.evaluation.mode`,{mode:t.mode})} </span>`:x}
            </div>
          `:x}
    </section>
  `}function pn(e){return S`
    <div class="sw-evaluation__findings">
      <h4>${A(`skillWorkshop.evaluation.findings`)}</h4>
      <ul>
        ${e.map(e=>{let t=e.file?e.line?A(`skillWorkshop.evaluation.fileLine`,{file:e.file,line:String(e.line)}):e.file:null;return S`
            <li>
              <span class="sw-evaluation__severity is-${e.severity}">
                ${A(`skillWorkshop.evaluation.severity.${e.severity}`)}
              </span>
              <span>
                <code class="sw-evaluation__rule">${e.ruleId}</code>
                ${b(e.message)}
                ${t?S`<small>${t}</small>`:x}
              </span>
            </li>
          `})}
      </ul>
    </div>
  `}function mn(e){return S`
    <div class="sw-evaluation__metrics">
      <h4>${A(`skillWorkshop.evaluation.metrics`)}</h4>
      <dl>
        ${Object.entries(e).toSorted(([e],[t])=>e.localeCompare(t)).map(([e,t])=>S`
              <div>
                <dt>${e}</dt>
                <dd>${String(t)}</dd>
              </div>
            `)}
      </dl>
    </div>
  `}function hn(e){let t=gn(e.body);return t?S`
    <div class="sw-today__does">
      <div class="sw-today__does-h">${t.heading}</div>
      <ul>
        ${t.items.map(e=>S`<li>${e}</li>`)}
      </ul>
    </div>
  `:x}function gn(e){let t=_n(e),n=vn(t,[`workflow`,`procedure`,`steps`,`agent workflow`,`process`]),r=n?bn(n.lines):[];if(r.length>0)return{heading:A(`skillWorkshop.today.workflowHeading`),items:r.slice(0,Q)};let i=vn(t,[`when to use`,`use when`,`applies when`,`trigger`,`triggers`]),a=i?bn(i.lines):[];return a.length>0?{heading:A(`skillWorkshop.today.applicabilityHeading`),items:a.slice(0,Q)}:null}function _n(e){let t=[],n=null,r=!1;for(let i of e.split(`
`)){let e=i.trim();e.startsWith("```")&&(r=!r);let a=(r?null:/^(#{2,4})\s+(.+?)\s*$/.exec(e))?.[2];if(a){n={title:yn(a),lines:[]},t.push(n);continue}n?.lines.push(i)}return t}function vn(e,t){let n=new Set(t.map(yn));return e.find(e=>n.has(e.title))}function yn(e){return e.replace(/[#*_`[\]().:]/g,` `).replace(/\s+/g,` `).trim().toLowerCase()}function bn(e){let t=[];for(let n of e){if(/^\s{2,}/.test(n))continue;let e=n.trim(),r=/^(?:[-*]|\d+\.)\s+(.+)/.exec(e)?.[1];r&&t.push(xn(r))}return t.filter(Boolean)}function xn(e){return Sn(e.replace(/^\*\*[^*]+\*\*\s*/,``).replace(/\[([^\]]+)\]\([^)]+\)/g,`$1`).replace(/`([^`]+)`/g,`$1`).replace(/\s+/g,` `).trim(),kn)}function Sn(e,t){if(e.length<=t)return e;let r=n(e,t-1),i=r.lastIndexOf(` `);return`${(i>48?r.slice(0,i):r).trimEnd()}…`}function Cn(e){let t=new Date(e);return`${t.toLocaleDateString(void 0,{weekday:`long`})} · ${t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}`}function wn(e){let t=e.split(`
`),n=[],r=[],i=[],a=!1,o=[],s=()=>{r.length&&(n.push(S`<p>${Tn(r.join(` `))}</p>`),r=[])},c=()=>{if(i.length){let e=i;n.push(S`
        <ol>
          ${e.map(e=>S`<li>${Tn(e)}</li>`)}
        </ol>
      `),i=[]}};for(let e of t){let t=e.trimEnd();if(t.startsWith("```")){s(),c(),a?(n.push(S`<pre>${o.join(`
`)}</pre>`),o=[],a=!1):a=!0;continue}if(a){o.push(e);continue}if(t===``){s(),c();continue}if(t.startsWith(`## `)){s(),c(),n.push(S`<h3>${t.slice(3)}</h3>`);continue}if(t.startsWith(`# `)){s(),c(),n.push(S`<h3>${t.slice(2)}</h3>`);continue}let l=/^\d+\.\s+(.+)/.exec(t)?.[1];if(l){s(),i.push(l);continue}r.push(t)}return s(),c(),a&&o.length&&n.push(S`<pre>${o.join(`
`)}</pre>`),n}function Tn(e){let t=[],n=/(`[^`]+`|\*\*[^*]+\*\*)/g,r=0,i;for(;i=n.exec(e);){i.index>r&&t.push(e.slice(r,i.index));let n=i[0];n.startsWith("`")?t.push(S`<code>${n.slice(1,-1)}</code>`):t.push(S`<strong>${n.slice(2,-2)}</strong>`),r=i.index+n.length}return r<e.length&&t.push(e.slice(r)),t}function En(e){let t=new Map;for(let n of e){let e=t.get(n.recencyGroup)??[];e.push(n),t.set(n.recencyGroup,e)}return[`today`,`yesterday`,`earlier`].filter(e=>t.has(e)).map(e=>({label:An[e],items:t.get(e)??[]}))}function Dn(e){return e.error?A(`skillWorkshop.queue.loadError`):e.loading?A(`skillWorkshop.queue.loading`):e.statusFilter===`all`?A(`skillWorkshop.queue.noMatch`):A(`skillWorkshop.queue.noStatus`,{status:A(Z[e.statusFilter]).toLocaleLowerCase()})}function X(e){return h(e,{dateFallback:!0})}var On,Z,Q,kn,An;function jn(){return(jn=e((()=>{C(),ue(),me(),de(),Nt(),O(),De(),T(),E(),ie(),ce(),Ht(),Jt(),Ke(),Zt(),R(),On=[`all`,`pending`,`applied`,`rejected`,`quarantined`,`stale`],Z={all:`skillWorkshop.status.all`,pending:`skillWorkshop.status.pending`,applied:`skillWorkshop.status.applied`,rejected:`skillWorkshop.status.rejected`,quarantined:`skillWorkshop.status.quarantined`,stale:`skillWorkshop.status.stale`},Q=3,kn=120,An={today:`skillWorkshop.recency.today`,yesterday:`skillWorkshop.recency.yesterday`,earlier:`skillWorkshop.recency.earlier`}})))()}function Mn(e,t,n){let{context:r,revisionRecoveryActive:i,workshopAgentName:a,onEvaluate:o,onRevisionSubmit:s,selfLearning:c,onSelfLearningToggle:l,onHistoryScan:u,onRetry:d}=t,f=e.skillWorkshopMode===`today`?`content--skill-workshop content--skill-workshop-today`:`content--skill-workshop`,p=nt(r.gateway.snapshot);return S`
    <section class=${f}>
      ${He({active:`workshop`,onSelect:e=>ht(r,e)})}
      <wa-tab-panel
        id=${Ue}
        class="sw-hub-panel"
        name="workshop"
        active
        aria-labelledby="plugins-tab-workshop"
      >
        <div class="sw-workshop-toolbar">
          ${mt(e,t,n)}
        </div>
        ${(()=>{let t=N(e.skillWorkshopProposals,e.skillWorkshopStatusFilter,e.skillWorkshopQuery),f=e.skillWorkshopProposals.find(t=>t.key===e.skillWorkshopSelectedKey),m=t=>t.key===e.skillWorkshopSelectedKey||e.skillWorkshopStatusFilter===`applied`&&f?.status===`applied`&&t.slug===f?.slug,h=t.findIndex(m),g=t=>{e.skillWorkshopFilePreviewKey=null,Ze(e,r,t).finally(n),n()},_=e=>{if(t.length===0)return;let n=h<0?0:(h+e+t.length)%t.length,r=t[n];r&&g(r.key)},v=e=>{if(e.length===0||e.some(m))return;let t=e[0];t&&g(t.key)};return S`<wa-tab-panel
            id="skill-workshop-mode-panel"
            name=${e.skillWorkshopMode}
            active
            aria-labelledby=${`skill-workshop-mode-tab-${e.skillWorkshopMode}`}
          >
            ${Qt({access:p,loading:e.skillWorkshopLoading,error:e.skillWorkshopError,inspectingKey:e.skillWorkshopInspectingKey,proposals:e.skillWorkshopProposals,selectedKey:e.skillWorkshopSelectedKey,appliedDiffMode:e.skillWorkshopAppliedDiffMode,statusFilter:e.skillWorkshopStatusFilter,query:e.skillWorkshopQuery,filePreviewKey:e.skillWorkshopFilePreviewKey,filePreviewQuery:e.skillWorkshopFilePreviewQuery,queueWidth:e.skillWorkshopQueueWidth,mode:e.skillWorkshopMode,actionBusy:e.skillWorkshopActionBusy,actionNotice:e.skillWorkshopActionNotice,revisionKey:e.skillWorkshopRevisionKey,revisionDraft:e.skillWorkshopRevisionDraft,revisionRecoveryActive:i,assistantName:r.config.current.assistantIdentity.name,workshopAgentName:a,selfLearning:c,historyScan:e.skillWorkshopHistoryScan,counts:tt(e.skillWorkshopProposals),onRetry:()=>{d()},onStatusFilterChange:t=>{e.skillWorkshopStatusFilter=t,n(),v(N(e.skillWorkshopProposals,t,e.skillWorkshopQuery))},onQueryChange:t=>{e.skillWorkshopQuery=t,n(),v(N(e.skillWorkshopProposals,e.skillWorkshopStatusFilter,t))},onFilePreviewQueryChange:t=>{e.skillWorkshopFilePreviewQuery=t,n()},onQueueWidthChange:t=>{e.skillWorkshopQueueWidth=t,n()},onModeChange:t=>H(e,t,n),onSelect:g,onAppliedDiffModeChange:t=>{e.skillWorkshopAppliedDiffMode=t,n()},onPrev:()=>_(-1),onNext:()=>_(1),onApply:t=>{F(r.gateway.snapshot,`skills.proposals.apply`)&&(P(e,r,`apply`,t).finally(n),n())},onEvaluate:e=>{F(r.gateway.snapshot,`skills.proposals.evaluate`)&&(o(e),n())},onRevise:t=>{F(r.gateway.snapshot,`skills.proposals.requestRevision`)&&(e.skillWorkshopRevisionKey=t,e.skillWorkshopRevisionDraft=``,n())},onReject:t=>{F(r.gateway.snapshot,`skills.proposals.reject`)&&(P(e,r,`reject`,t).finally(n),n())},onRevisionDraftChange:t=>{e.skillWorkshopRevisionDraft=t,n()},onRevisionCancel:()=>{i||(e.skillWorkshopRevisionKey=null,e.skillWorkshopRevisionDraft=``,n())},onRevisionSubmit:e=>F(r.gateway.snapshot,`skills.proposals.requestRevision`)?s(e):void 0,onPreviewFile:(t,r)=>{e.skillWorkshopSelectedKey=t,e.skillWorkshopFilePreviewKey=r,n()},onClosePreview:()=>{e.skillWorkshopFilePreviewKey=null,e.skillWorkshopFilePreviewQuery=``,n()},onSelfLearningToggle:l,onHistoryScan:u})}
          </wa-tab-panel>`})()}
      </wa-tab-panel>
    </section>
  `}var $;function Nn(){return(Nn=e((()=>{Pe(),Ae(),C(),pe(),we(),T(),u(),re(),le(),We(),Ve(),I(),U(),Ye(),gt(),M(),Tt(),R(),V(),jn(),$=class extends v{constructor(...e){super(...e),this.operationEpoch=0,this.hasBoundContext=!1,this.gatewayClient=null,this.gatewayHello=null,this.gatewayConnected=!1,this.hasBoundAgentSelection=!1,this.hasBoundSessions=!1,this.selfLearningBusy=!1,this.selfLearningError=null,this.requestPageUpdate=()=>{this.isConnected&&this.requestUpdate()},this.revisionRecovery=new wt(this.requestPageUpdate),this.proposalsTask=new je(this,{autoRun:!1,args:()=>[this.gatewayConnected?this.context??null:null,this.gatewayConnected?this.state??null:null,this.selectedAgentId??null,!1],task:([e,t,n,r])=>e&&t?qe({state:t,context:e,force:r}):Ne,onComplete:()=>{this.requestPageUpdate()},onError:()=>{this.requestPageUpdate()}}),this.subscriptions=new se(this).effect(()=>this.context,e=>{let t=this.hasBoundContext&&this.contextSource!==e;if(this.hasBoundContext=!0,this.contextSource=e,t){let t=e.gateway;this.gatewaySource=t,this.gatewayClient=t.snapshot.client,this.gatewayHello=t.snapshot.hello,this.gatewayConnected=t.snapshot.phase===`connected`,this.agentSelectionSource=e.agentSelection,this.selectedAgentId=e.agentSelection.state.selectedId,this.sessionsSource=e.sessions,this.resetSourceState(),this.loadProposals(!0)}}).effect(()=>this.context?.gateway,e=>{let t=e.snapshot,n=this.gatewaySource!==void 0&&this.gatewaySource!==e,r=this.gatewaySource!==void 0&&this.gatewayClient!==t.client,i=this.gatewaySource!==void 0&&this.gatewayConnected!==(t.phase===`connected`),a=this.gatewaySource!==void 0&&this.gatewayHello!==t.hello;return this.applyGatewaySnapshot(e,t,n||r||i||a),e.subscribe(t=>{if(this.gatewaySource!==e||this.context?.gateway!==e)return;let n=t.client!==this.gatewayClient||t.phase===`connected`!==this.gatewayConnected||t.hello!==this.gatewayHello;this.applyGatewaySnapshot(e,t,n)})}).watch(()=>this.context?.config,(e,t)=>e.subscribe(t)).effect(()=>this.context?.agentSelection,e=>{let t=this.hasBoundAgentSelection&&this.agentSelectionSource!==e;this.hasBoundAgentSelection=!0,this.agentSelectionSource=e;let n=!0,r=()=>{if(this.agentSelectionSource!==e||this.context?.agentSelection!==e)return;let r=e.state.selectedId,i=!n&&this.selectedAgentId!==r;this.selectedAgentId=r;let a=t||i;t=!1,n=!1,a&&this.resetSourceState(),this.loadProposals(a)};return r(),e.subscribe(r)}).effect(()=>this.context?.sessions,e=>{let t=this.hasBoundSessions&&this.sessionsSource!==e;this.hasBoundSessions=!0,this.sessionsSource=e,t&&(this.resetSourceState(),this.loadProposals(!0))}).watch(()=>this.context?.agentIdentity,(e,t)=>e.subscribe(t)).watch(()=>this.context?.runtimeConfig,(e,t)=>e.subscribe(t)).watch(()=>this.context?.skillWorkshopRevisionAdmissions,(e,t)=>e.subscribe(t)),this.handleRevisionRequest=async(e,t,n,r)=>{let i=this.captureSourceScope();return i?await this.revisionRecovery.request({context:i.context,expectedRevisionHash:r,instructions:e,proposal:t,proposalAgentId:n,state:i.state}):{error:`Skill Workshop is not ready.`,id:`unowned`,status:`retryable-failed`}},this.handleEvaluation=e=>{let t=this.captureSourceScope();t&&et(t.state,t.context,e,()=>this.isCurrentSourceScope(t)).finally(this.requestPageUpdate)},this.handleRevisionSubmit=e=>{let t=this.captureSourceScope(),n=this.onRevisionRequest??this.handleRevisionRequest;t&&$e(t.state,t.context,e,n,()=>this.isCurrentSourceScope(t)).then(e=>{!e||e.status!==`admitted`||!this.isCurrentSourceScope(t)||t.navigate(`chat`,te({context:t.context,face:`chat`,sessionKey:e.sessionKey}).options)}).finally(this.requestPageUpdate)},this.handleHistoryScan=()=>{if(!F(this.context?.gateway?.snapshot,`skills.proposals.historyScan`))return;let e=this.captureSourceScope();e&&(Je({state:e.state,context:e.context,isCurrent:()=>this.isCurrentSourceScope(e),current:()=>{let e=this.state,t=this.context;return e&&t?{state:e,context:t}:void 0}}).finally(this.requestPageUpdate),this.requestPageUpdate())},this.handleSelfLearningToggle=e=>{this.applySelfLearningToggle(e)}}willUpdate(){!this.state&&this.context&&(this.state=j(this.data),this.state.skillWorkshopMode=lt(),this.state.skillWorkshopUseCurrentChatForRevisions=dt())}updated(){this.state&&this.context&&this.revisionRecovery.sync(this.context,this.state);let e=this.state,t=e&&!e.skillWorkshopLoaded&&!e.skillWorkshopLoading&&!e.skillWorkshopError;this.gatewayConnected&&t&&this.loadProposals(!1),this.ensureWorkshopAgentIdentity();let n=this.context?.runtimeConfig;n&&this.gatewayConnected&&!n.state.configSnapshot&&!n.state.configLoading&&n.ensureLoaded()}resetSourceState(){this.operationEpoch+=1,this.selfLearningBusy=!1,this.selfLearningError=null,this.proposalsTask.run([null,null,null,!1]);let e=this.state;if(!e)return;e.skillWorkshopActionNoticeTimer&&globalThis.clearTimeout(e.skillWorkshopActionNoticeTimer);let t=j();t.skillWorkshopAgentId=e.skillWorkshopAgentId,t.skillWorkshopStatusFilter=e.skillWorkshopStatusFilter,t.skillWorkshopQuery=e.skillWorkshopQuery,t.skillWorkshopQueueWidth=e.skillWorkshopQueueWidth,t.skillWorkshopMode=e.skillWorkshopMode,t.skillWorkshopUseCurrentChatForRevisions=e.skillWorkshopUseCurrentChatForRevisions,this.state=t,this.requestPageUpdate()}applyGatewaySnapshot(e,t,n){this.gatewaySource=e,this.gatewayClient=t.client,this.gatewayHello=t.hello,this.gatewayConnected=t.phase===`connected`,n&&this.resetSourceState(),t.phase===`connected`&&(n||!this.state?.skillWorkshopLoaded)&&this.loadProposals(n)}captureSourceScope(){return Et({state:this.state,context:this.context,epoch:this.operationEpoch})}isCurrentSourceScope(e){return Dt(e,{state:this.state,context:this.context,epoch:this.operationEpoch})}loadProposals(e){let t=this.state,n=this.context;!t||!n||n.gateway.snapshot.phase!==`connected`||this.proposalsTask.run([n,t,n.agentSelection.state.selectedId,e])}async applySelfLearningToggle(e){if(!F(this.context?.gateway?.snapshot,`config.patch`))return;let t=this.captureSourceScope(),n=t?.context.runtimeConfig;if(!(!t||!n||this.selfLearningBusy)){this.selfLearningBusy=!0,this.selfLearningError=null,this.requestPageUpdate();try{let r=await at(n,e,()=>this.isCurrentSourceScope(t));this.isCurrentSourceScope(t)&&(this.selfLearningError=r)}finally{this.isCurrentSourceScope(t)&&(this.selfLearningBusy=!1,this.requestPageUpdate())}}}ensureWorkshopAgentIdentity(){let e=this.context,t=this.state?.skillWorkshopAgentId;!e||!t||e.agentIdentity.get(t)||e.agentIdentity.ensure([t])}disconnectedCallback(){this.subscriptions.clear(),this.resetSourceState(),super.disconnectedCallback()}render(){return this.state&&this.context?Mn(this.state,{context:this.context,revisionRecoveryActive:this.revisionRecovery.active,workshopAgentName:this.context.agentIdentity.get(this.state.skillWorkshopAgentId)?.name?.trim()??``,onEvaluate:this.handleEvaluation,onRevisionSubmit:this.handleRevisionSubmit,selfLearning:it(this.context.runtimeConfig,this.selfLearningBusy,this.selfLearningError,F(this.context.gateway.snapshot,`config.patch`)),onSelfLearningToggle:this.handleSelfLearningToggle,onHistoryScan:this.handleHistoryScan,onRetry:()=>this.loadProposals(!0)},this.requestPageUpdate):x}},c([Me({context:Te,subscribe:!0})],$.prototype,`context`,void 0),c([w({attribute:!1})],$.prototype,`data`,void 0),c([w({attribute:!1})],$.prototype,`onRevisionRequest`,void 0),customElements.get(`openclaw-skill-workshop-page`)||customElements.define(`openclaw-skill-workshop-page`,$)})))()}Nn();
//# sourceMappingURL=skill-workshop-page-B59l2-F4.js.map