openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 12.5 kB
JavaScript
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{GN as t,JN as n,ck as r,cl as i,dl as a,lk as o,ll as s,ul as c}from"./_2_____________________________.js";import{Bi as l,Di as u,Hi as ee,Oi as d}from"./deferred-ui-support-DZEPWjAk.js";import{C as f,F as te,O as p,Rt as m,U as h,b as g,d as _,f as v,g as y,j as b,l as x,p as S,r as C,s as w,u as T,x as E}from"./_6____________________.js";import{A as D}from"./route-controls-runtime-LXiVRSj4.js";import{Ht as ne,Ut as re}from"./control-ui-boot-new-pHXPNTZp.js";import{c as ie,s as O}from"./route-chrome-Dr9fhzjf.js";import{n as ae,r as k}from"./settings-disclosure-C2Lxm_wL.js";import"./skill-reader-dialog-DpT2WZGg.js";import{n as A}from"./library-file-text-95__9Rmm.js";function j(e){let t=()=>e.library.state,r=()=>e.library.saving()||t().busy;var o=M(),s=o.firstChild,l=s.firstChild,u=l.nextSibling;return o.addEventListener(`modal-cancel`,t=>{t.preventDefault(),e.library.close()}),o._$owner=m(),s._$$keydown=t=>{c(t)||e.editor&&(t.ctrlKey||t.metaKey)&&t.key===`Enter`&&!e.editor.disabled&&(t.preventDefault(),t.currentTarget.requestSubmit())},C(s,`keyup`,i,!0),C(s,`focusout`,i,!0),C(s,`compositionend`,a),s.addEventListener(`submit`,n=>{n.preventDefault();let r=t().importSource;e.editor?e.library.save():r?e.library.importClawHub(t().importSlug,r.slug,r.version):e.library.importFiles(t().importSelection)}),_(s,b(ne,{get title(){return e.editor?.title??n(`skillLibrary.import`)},get closeDisabled(){return r()},onClose:()=>void e.library.close()}),l),_(l,()=>e.children),_(s,()=>e.footer,u),x(()=>({e:e.editor?.title??n(`skillLibrary.import`),t:S(e.editor?{"--openclaw-modal-width":`960px`}:void 0),a:!e.editor}),({e,t,a:n},r)=>{e!==r?.e&&y(o,`label`,e),g(o,t,r?.t),n!==r?.a&&l.classList.toggle(`skill-library-import`,n)}),o}var M;function N(){return(N=e((()=>{T(),re(),s(),t(),M=E(`<openclaw-modal-dialog><form class="oc-dialog skill-library-dialog"><div class=oc-dialog__body></div><!>`,1),w([`focusout`,`keyup`,`keydown`])})))()}function P(e){let t=()=>e.library.state,r=()=>t().draft,i=()=>e.library.entry(),a=()=>e.library.saving()||t().busy,o=()=>a()||!e.library.canEdit()||t().loading,s=()=>r().files.find(e=>e.path===r().selectedFile),c=async()=>{let t=r(),i=t.selectedFile;await ee({title:n(`skillLibrary.deleteFileConfirm`,{path:i}),message:n(`skillLibrary.deleteFileBody`),confirmLabel:n(`common.remove`),danger:!0})&&r()===t&&e.library.edit(e=>{e.draft.files=e.draft.files.filter(e=>e.path!==i),e.draft.selectedFile=`SKILL.md`})},l=te(()=>r().selectedFile===`SKILL.md`?r().content:s()?A(s()):null),d=()=>o()||e.library.isDirty(),f=t=>{o()||e.library.edit(e=>{let n=e.draft;n.selectedFile===`SKILL.md`?n.content=t:n.files=n.files.map(e=>e.path===n.selectedFile?Object.assign({},e,{content:t,encoding:`utf8`}):e)})},h=t=>(()=>{var r=I();return r._$$click=()=>void e.library.mutate(t.action),_(r,()=>n(`skillLibrary.${t.action}`)),x(()=>({e:t.action===`remove`,t:t.locked??d()}),({e,t},n)=>{e!==n?.e&&r.classList.toggle(`danger`,e),t!==n?.t&&y(r,`disabled`,t)}),r})();return b(j,{get library(){return e.library},get editor(){return{title:i()?.slug??n(`skillLibrary.create`),disabled:o()}},get footer(){return b(p,{get when(){return e.library.canEdit()},get children(){var t=K(),s=t.firstChild;return t._$owner=m(),_(t,b(p,{get when(){return i()},get children(){return[b(h,{action:`remove`}),b(h,{get action(){return i().enabled?`disable`:`enable`}}),b(p,{get when(){return i()?.ownerProfileId},get children(){return b(h,{get action(){return i().shared?`unshare`:`share`}})}}),b(p,{get when(){return v(()=>!!e.library.canTransfer())()?i()?.ownerProfileId:e.library.canTransfer()},get children(){return b(h,{action:`transfer`})}})]}}),s),_(s,(()=>{var e=v(()=>!!a());return()=>e()?[q(),v(()=>n(`common.saving`))]:n(`skillLibrary.save`)})()),x(()=>o()||!(!r().importedFiles||e.library.uploadsEnabled())||!e.library.isDirty()||!r().content.trim(),e=>{y(s,`disabled`,e)}),t}})},get children(){return[(()=>{var e=L();return _(e,(()=>{var e=v(()=>!!i());return()=>e()?n(`skillLibrary.ownerRevision`,{owner:i().ownerLabel,revision:i().revision.slice(0,8)}):n(`skillLibrary.personalTarget`)})()),e})(),b(p,{get when(){return i()},get children(){return b(ae,{quiet:!0,class:`skill-library-details`,get title(){return n(`skillLibrary.technicalDetails`)},get children(){var e=R(),t=e.firstChild,r=t.nextSibling,a=r.nextSibling,o=a.nextSibling,s=o.nextSibling,c=s.nextSibling;return _(t,()=>n(`skillLibrary.skillId`)),_(r,()=>i().skillId),_(a,()=>n(`skillLibrary.revision`)),_(o,()=>i().revision),_(s,()=>n(`skillLibrary.command`)),_(c,()=>i().name),e}})}}),b(p,{get when(){return!e.library.canEdit()},get children(){var e=z();return _(e,()=>n(`skillLibrary.readOnly`)),e}}),(()=>{var t=B(),i=t.firstChild,a=i.nextSibling;return _(i,()=>n(`skillLibrary.slug`)),a._$$input=t=>e.library.edit(e=>{e.draft.slug=t.currentTarget.value}),x(()=>({e:n(`skillLibrary.slugHelp`),t:o(),a:r().slug}),({e,t,a:n},r)=>{e!==r?.e&&y(a,`title`,e),t!==r?.t&&y(a,`disabled`,t),a.value=n??``}),t})(),(()=>{var t=V(),i=t.firstChild,a=i.firstChild;return _(a,()=>n(`skillLibrary.file`)),_(i,b(O,{get"aria-label"(){return n(`skillLibrary.file`)},get value(){return r().selectedFile},onChange:t=>e.library.edit(e=>{e.draft.selectedFile=t.currentTarget.value}),get options(){return[{value:`SKILL.md`,label:`SKILL.md`},...r().files.map(e=>({value:e.path,label:`${e.path}${e.executable?` *`:``}`}))]}}),null),_(t,b(p,{get when(){return v(()=>!!s())()?e.library.canEdit():s()},get children(){var e=I();return e._$$click=()=>void c(),_(e,()=>n(`skillLibrary.deleteFile`)),x(()=>o(),t=>{y(e,`disabled`,t)}),e}}),null),t})(),b(p,{get when(){return v(()=>!!s())()?e.library.canEdit():s()},get children(){var t=H(),r=t.firstChild;return _(t,b(u,{name:`library-file-executable`,get disabled(){return o()},get checked(){return s().executable===!0},onChange:t=>e.library.edit(e=>{let n=t.currentTarget.checked,r=e.draft.selectedFile;e.draft.files=e.draft.files.map(e=>e.path===r?Object.assign({},e,{executable:n}):e)})}),r),_(r,()=>n(`skillLibrary.executable`)),t}}),b(p,{get when(){return l()!==null},get fallback(){var e=L();return _(e,()=>n(`skillLibrary.binary`)),e},get children(){var e=U(),t=e.firstChild,n=t.nextSibling;return _(t,()=>r().selectedFile),n._$$input=e=>f(e.currentTarget.value),x(()=>({e:o(),t:l()}),({e,t},r)=>{e!==r?.e&&y(n,`readonly`,e),n.value=t??``}),e}}),b(p,{get when(){return e.library.canEdit()},get children(){var t=W(),i=t.firstChild,a=i.firstChild,s=a.nextSibling,c=i.nextSibling;return _(a,()=>n(`skillLibrary.newFile`)),s._$$input=t=>e.library.setLocal(e=>{e.newFilePath=t.currentTarget.value}),c._$$click=()=>{let t=e.library.local.newFilePath.trim(),i=t===`SKILL.md`||r().files.some(e=>e.path===t);e.library.edit(e=>{if(i)e.error=n(`skillLibrary.fileExists`);else{let n=e.draft;n.files=[...n.files,{path:t,content:``,encoding:`utf8`}],n.selectedFile=t}}),i||e.library.setLocal(e=>{e.newFilePath=``})},_(c,()=>n(`skillLibrary.addFile`)),x(()=>({e:o(),t:e.library.local.newFilePath,a:o()||!e.library.local.newFilePath.trim()}),({e,t,a:n},r)=>{e!==r?.e&&y(s,`disabled`,e),s.value=t??``,n!==r?.a&&y(c,`disabled`,n)}),t}}),v(()=>e.feedback),b(p,{get when(){return v(()=>!!(e.library.canEdit()&&i()))()?r().revisions.length>1:e.library.canEdit()&&i()},get children(){var t=G(),a=t.firstChild,o=a.firstChild;return _(o,()=>n(`skillLibrary.revision`)),_(a,b(O,{get"aria-label"(){return n(`skillLibrary.revision`)},get value(){return r().rollbackRevision},get disabled(){return d()},onChange:t=>e.library.edit(e=>{e.draft.rollbackRevision=t.currentTarget.value}),get options(){return[{value:``,label:n(`skillLibrary.selectRevision`)},...r().revisions.filter(e=>e.revision!==i()?.revision).map(e=>({value:e.revision,label:`${new Date(e.createdAt).toLocaleString()} · ${e.revision.slice(0,8)}`}))]}}),null),_(t,b(h,{action:`rollback`,get locked(){return d()||!r().rollbackRevision}}),null),t}})]}})}function F(e){let t=()=>e.library.state,r=()=>e.library.saving()||t().busy,i=()=>{let e=t().importSelection;return e.length?n(e.length===1?`skillLibrary.selectedFile`:`skillLibrary.selectedFiles`,{count:String(e.length),names:e.slice(0,2).map(e=>e.webkitRelativePath||e.name).join(`, `)+(e.length>2?`, …`:``)}):n(`skillLibrary.noFilesSelected`)};return b(j,{get library(){return e.library},get footer(){var i=K(),a=i.firstChild;return i._$owner=m(),_(a,(()=>{var e=v(()=>!!r());return()=>e()?[q(),v(()=>n(`common.importing`))]:n(`skillLibrary.import`)})()),x(()=>r()||!e.library.canWrite()||!t().importSource&&(!e.library.uploadsEnabled()||t().importSelection.length===0),e=>{y(a,`disabled`,e)}),i},get children(){return[b(p,{get when(){return v(()=>!t().importSource)()&&!e.library.uploadsEnabled()},get children(){var e=z();return _(e,o),e}}),(()=>{var e=L();return _(e,(()=>{var e=v(()=>!!t().importSource);return()=>e()?n(`skillLibrary.importClawHub`,{source:t().importSource.slug}):n(`skillLibrary.importHelp`)})()),e})(),(()=>{var i=J(),a=i.firstChild,o=a.nextSibling;return _(a,()=>n(`skillLibrary.slug`)),o._$$input=t=>e.library.edit(e=>{e.importSlug=t.currentTarget.value}),x(()=>({e:n(`skillLibrary.slugHelp`),t:t().importSlug,a:r()}),({e,t,a:n},r)=>{e!==r?.e&&y(o,`title`,e),o.value=t??``,n!==r?.a&&y(o,`disabled`,n)}),i})(),b(p,{get when(){return v(()=>!t().importSource)()&&e.library.uploadsEnabled()},get children(){var a=X(),o=a.firstChild,s=o.nextSibling,c=s.nextSibling,l=c.nextSibling,u=l.firstChild;return _(o,()=>n(`skillLibrary.files`)),_(s,()=>n(`skillLibrary.filesHelp`)),_(c,b(f,{each:[!1,!0],keyed:!1,children:t=>[(()=>{var i=Z();return i._$$click=t=>{if(!e.library.uploadsEnabled())return;let n=t.currentTarget.nextElementSibling;n instanceof HTMLInputElement&&n.click()},_(i,()=>n(t()?`skillLibrary.chooseFolderButton`:`skillLibrary.chooseFilesButton`)),x(()=>r(),e=>{y(i,`disabled`,e)}),i})(),(()=>{var n=Q();return n.addEventListener(`change`,t=>{let n=t.currentTarget,r=e.library.uploadsEnabled()?Array.from(n.files??[]):[];e.library.edit(e=>{e.importSelection=r}),n.value=``}),x(()=>({e:t(),t:t()?`library-import-directory`:`library-import-files`,a:r()}),({e,t,a:r},i)=>{e!==i?.e&&y(n,`webkitdirectory`,e),t!==i?.t&&y(n,`name`,t),r!==i?.a&&y(n,`disabled`,r)}),n})()]})),_(u,i),_(l,b(p,{get when(){return t().importSelection.length>0},get children(){var t=Y();return t._$$click=()=>e.library.edit(e=>{e.importSelection=[]}),_(t,()=>n(`skillLibrary.clearSelection`)),x(()=>r(),e=>{y(t,`disabled`,e)}),t}}),null),a}}),v(()=>e.feedback)]}})}var I,L,R,z,B,V,H,U,W,G,K,q,J,Y,X,Z,Q;function $(){return($=e((()=>{T(),h(),l(),D(),d(),k(),ie(),t(),r(),N(),I=E(`<button type=button class=btn>`),L=E(`<p class=muted>`),R=E(`<dl><dt></dt><dd></dd><dt></dt><dd></dd><dt></dt><dd>`),z=E(`<p role=status>`),B=E(`<label class=field><span></span><input class=settings-input name=library-slug required pattern=[a-z0-9][a-z0-9\\-]{0,62} maxlength=63>`),V=E(`<div class=plugins-toolbar><label class=field style=min-width:0;flex:1><span>`),H=E(`<label class="field checkbox"><span>`),U=E(`<label class=field><span></span><textarea name=library-content class=settings-input spellcheck=false rows=18 style=font-family:var(--mono);min-width:0;max-width:100%;box-sizing:border-box;resize:vertical>`),W=E(`<div class=plugins-toolbar><label class=field style=flex:1;min-width:0><span></span><input class=settings-input name=library-file-path></label><button type=button class=btn>`),G=E(`<div class=plugins-toolbar><label class=field style=flex:1;min-width:0><span>`),K=E(`<openclaw-modal-actions class=oc-dialog__footer><button type=submit class="btn primary">`,1),q=E(`<span class=btn__spinner aria-hidden=true>`),J=E(`<label class=field><span></span><input class=settings-input required name=library-import-slug pattern=[a-z0-9][a-z0-9\\-]{0,62}>`),Y=E(`<button type=button class="btn btn--sm btn--ghost">`),X=E(`<div class=field role=group aria-labelledby=library-import-files-label><span id=library-import-files-label></span><small id=library-import-files-help class=settings-row__desc></small><div class="plugins-toolbar skill-library-import__pickers"></div><div class=plugins-toolbar><small id=library-import-selection class=settings-row__desc aria-live=polite>`),Z=E(`<button type=button class=btn aria-describedby="library-import-files-help library-import-selection">`),Q=E(`<input type=file hidden multiple>`),w([`click`,`input`])})))()}$();export{P as LibraryEditor,F as LibraryImport};