@oktis-works/admin 0.12.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/_astro/{ActivityWidget.D9s4FOLp.js → ActivityWidget.CCls_jrK.js} +1 -1
- package/dist/client/_astro/AdminBar.BW8zYZI3.js +253 -0
- package/dist/client/_astro/{ApiKeysManager.BjyxI6JT.js → ApiKeysManager.Cj5tsk4N.js} +1 -1
- package/dist/client/_astro/{AtGlanceWidget.DBA3mEnF.js → AtGlanceWidget.DPkp-rxl.js} +1 -1
- package/dist/client/_astro/ContentEditor.CByEz10Q.js +3 -0
- package/dist/client/_astro/ContentEditor.kdYzULib.js +1 -0
- package/dist/client/_astro/{ContentTypeWorkspace.BhHFc6WZ.js → ContentTypeWorkspace.BMVbiGGy.js} +1 -1
- package/dist/client/_astro/{DashboardHome.BXIUgb4u.js → DashboardHome.BuDu0DuB.js} +1 -1
- package/dist/client/_astro/{DashboardLayout.astro_astro_type_script_index_0_lang.Cc0PvXrs.js → DashboardLayout.astro_astro_type_script_index_0_lang.D2eyDf2o.js} +1 -1
- package/dist/client/_astro/FieldGroupEditor.DGjV1n67.js +69 -0
- package/dist/client/_astro/{FieldGroupList.BG2ET5gZ.js → FieldGroupList.BJ2TKSgY.js} +1 -1
- package/dist/client/_astro/{Footer.Chcu8yzV.js → Footer.JI2Mqd9V.js} +1 -1
- package/dist/client/_astro/{GeneralSettings.CefkBcVj.js → GeneralSettings.BSObhTfM.js} +1 -1
- package/dist/client/_astro/{LogsManager.ya0kmAUm.js → LogsManager.B4-BxzoP.js} +1 -1
- package/dist/client/_astro/{MediaLibrary.Bod2Afk4.js → MediaLibrary.BHVM3oJh.js} +1 -1
- package/dist/client/_astro/{MenuManager.d6_0hgNg.js → MenuManager.BAn4_w6-.js} +1 -1
- package/dist/client/_astro/{Modal.DR905gyF.js → Modal.BSZ5IjBl.js} +1 -1
- package/dist/client/_astro/{PluginManager.BHvKQlj2.js → PluginManager.D_E-lPWP.js} +1 -1
- package/dist/client/_astro/{PostTypesManager.DMUxfOp9.js → PostTypesManager.BHU1d2ta.js} +1 -1
- package/dist/client/_astro/{QuickDraftWidget.DyX_bJ1p.js → QuickDraftWidget.ClSsMYB_.js} +1 -1
- package/dist/client/_astro/{ResourceHubs.BwxYHeE5.js → ResourceHubs.C3suqlP0.js} +1 -1
- package/dist/client/_astro/{TaxonomiesManager.DlVS4Ujm.js → TaxonomiesManager.BXYUiJEA.js} +1 -1
- package/dist/client/_astro/{TaxonomyTermsManager.B_ZDFU-K.js → TaxonomyTermsManager.obB3lkr3.js} +1 -1
- package/dist/client/_astro/{ThemeManager.DuHgcKyn.js → ThemeManager.C0TKggfZ.js} +1 -1
- package/dist/client/_astro/{UserCreateForm.1KIa3Aa2.js → UserCreateForm.DaIOqr8v.js} +1 -1
- package/dist/client/_astro/{UsersManager.v24y8OSk.js → UsersManager.B5zFoWmR.js} +1 -1
- package/dist/client/_astro/{WebhooksManager.DPkFhoVr.js → WebhooksManager.BRvVuxLt.js} +1 -1
- package/dist/client/_astro/{i18n.AbBpo2WD.js → i18n.vdBFsiPK.js} +1 -1
- package/dist/client/_astro/{pt-BR.B0jeLTb0.js → pt-BR.CKJnipDe.js} +1 -1
- package/dist/server/chunks/{404_C9d1fN7T.mjs → 404_C9Eokbcv.mjs} +1 -1
- package/dist/server/chunks/{BaseLayout_D-10OcWZ.mjs → BaseLayout_DgDmTH8p.mjs} +3 -3
- package/dist/server/chunks/{ContentEditor_DZWLWgAD.mjs → ContentEditor_VK16JJMh.mjs} +154 -22
- package/dist/server/chunks/{DashboardLayout_HxBoC5fJ.mjs → DashboardLayout_CrxyUavx.mjs} +15 -15
- package/dist/server/chunks/{FbIcon_D0f6QiFJ.mjs → FbIcon_7YixzwO3.mjs} +1 -1
- package/dist/server/chunks/{FloatingPanel_DI2CdUZK.mjs → FloatingPanel_BtB-nNBT.mjs} +1 -1
- package/dist/server/chunks/{MediaLibrary_CD_cadEt.mjs → MediaLibrary_CZuj5byR.mjs} +3 -3
- package/dist/server/chunks/{Modal_vHjkS4i2.mjs → Modal_BfWFiyry.mjs} +2 -2
- package/dist/server/chunks/{PageHeader_CBOioOjo.mjs → PageHeader_CRpzf5xU.mjs} +1 -1
- package/dist/server/chunks/{_id__DrGJOSWh.mjs → _id__BYx77RvL.mjs} +208 -66
- package/dist/server/chunks/{_slug__C6TfwYcI.mjs → _slug__CR6t9xra.mjs} +2 -2
- package/dist/server/chunks/{access_D46Rg5g2.mjs → access_Bp3EnO2H.mjs} +8 -8
- package/dist/server/chunks/{api-keys_BUCeuDw4.mjs → api-keys_Dt87wCbg.mjs} +6 -6
- package/dist/server/chunks/{custom-fields_B7PeZo06.mjs → custom-fields_CC_ZhBpp.mjs} +5 -5
- package/dist/server/chunks/{edit_H_Z0tUXd.mjs → edit_VYWajKgt.mjs} +4 -4
- package/dist/server/chunks/{general_BROn356D.mjs → general_DtYlpwnZ.mjs} +7 -7
- package/dist/server/chunks/{i18n_CItvcX64.mjs → i18n_B-DWAN0e.mjs} +8 -8
- package/dist/server/chunks/{index_BYjGHhFv.mjs → index_6a-jaApt.mjs} +7 -7
- package/dist/server/chunks/{index_GXbAk6jt.mjs → index_CDmqkl48.mjs} +4 -4
- package/dist/server/chunks/{index_9wINU7Wu.mjs → index_DXmHKYjS.mjs} +5 -5
- package/dist/server/chunks/{index_BSanLOwq.mjs → index_DgVVWosZ.mjs} +4 -4
- package/dist/server/chunks/{index_WgopTFB2.mjs → index_ieyhXCVt.mjs} +2 -2
- package/dist/server/chunks/{login_BzHv0uQ0.mjs → login_DRJNLDt7.mjs} +1 -1
- package/dist/server/chunks/{logs_C32euU-n.mjs → logs_CaMNxV6h.mjs} +5 -5
- package/dist/server/chunks/{menus_EJ0NIw-1.mjs → menus_BsV0U5D5.mjs} +4 -4
- package/dist/server/chunks/{new_BwrgYLev.mjs → new_BQ2d8AHk.mjs} +4 -4
- package/dist/server/chunks/{new_CWKqh8oV.mjs → new_CyBl1PM1.mjs} +5 -5
- package/dist/server/chunks/{plugins_C8RXEzie.mjs → plugins_BiaE4So1.mjs} +5 -5
- package/dist/server/chunks/{post-types_bDF0xDxo.mjs → post-types_BBKtACUm.mjs} +7 -7
- package/dist/server/chunks/{pt-BR_DpWzkRv5.mjs → pt-BR_Da5G4GOV.mjs} +1 -1
- package/dist/server/chunks/{taxonomies_AHnU1mD0.mjs → taxonomies_gwfTSCOV.mjs} +5 -5
- package/dist/server/chunks/{taxonomy_DwH2xYGw.mjs → taxonomy_BKdLzLps.mjs} +5 -5
- package/dist/server/chunks/{themes_DE_yoCn2.mjs → themes_CqOUZiNg.mjs} +5 -5
- package/dist/server/chunks/{upload_BQA9bixd.mjs → upload_keeE9Mn0.mjs} +4 -4
- package/dist/server/chunks/{webhooks_iWH_jV-x.mjs → webhooks_sTUPF0Xn.mjs} +5 -5
- package/dist/server/entry.mjs +26 -26
- package/dist/server/virtual_astro_middleware.mjs +3 -3
- package/package.json +3 -3
- package/dist/client/_astro/AdminBar.D8078Gqs.js +0 -253
- package/dist/client/_astro/ContentEditor.BZ8aLcGz.js +0 -3
- package/dist/client/_astro/ContentEditor.CfQqsa6r.js +0 -1
- package/dist/client/_astro/FieldGroupEditor.CVoPJ2v-.js +0 -69
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,i as t,p as n,r,s as i,y as a}from"./solid.D49dPDCT.js";import{a as o,c as s,d as ee,f as c,g as l,i as u,l as d,o as f,p}from"./web.Bqbl_1YR.js";import{n as m}from"./i18n.AbBpo2WD.js";import{n as h}from"./api.CYg1SW2X.js";import{a as g,i as _,n as v,o as y,s as te}from"./src.DXVWCoHp.js";var ne=l(`<div class="notice notice--error">`),re=l(`<div class=notice>`),ie=l(`<div class=media-grid>`),ae=l(`<div class=media-library><!$><!/><!$><!/><div class=upload-zone><p><strong></strong> ou</p><label class="btn btn-primary"style=cursor:pointer><!$><!/><input type=file multiple style=display:none></label><p class=muted></p></div><div class=toolbar><!$><!/><!$><!/><!$><!/></div><!$><!/><!$><!/><!$><!/>`),oe=l(`<p class=muted>`),se=l(`<img loading=lazy>`,!0,!1,!1),ce=l(`<button type=button class=media-card><div class=media-card__preview></div><div class=media-card__meta><span class=media-card__name></span><span class=muted><!$><!/> · <!$><!/>`),le=l(`<span class=media-card__ext>`),ue=l(`<img>`),de=l(`<video controls>`),fe=l(`<audio controls>`),pe=l(`<iframe>`),me=l(`<div class="media-card__ext media-modal__file-icon">`),he=l(`<dt>`),ge=l(`<dd>`),_e=l(`<div class=media-modal><div class=media-modal__preview><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/></div><div class=media-modal__layout><div class=media-modal__fields><!$><!/><!$><!/><!$><!/><label class=field__label><!$><!/><textarea class="input media-modal__textarea"name=media-description></textarea></label></div><dl class="media-details__list media-modal__facts"><dt></dt><dd></dd><dt></dt><dd></dd><dt></dt><dd></dd><!$><!/><dt></dt><dd></dd><dt></dt><dd class=media-details__url><code></code><button class="btn btn-secondary btn-sm"type=button></button></dd></dl></div><div class=media-modal__replace><label class="btn btn-secondary"style=cursor:pointer><!$><!/><input type=file style=display:none></label><span class=muted></span></div><div class=media-details__actions><!$><!/><!$><!/><!$><!/>`);function ve(e){return Number.isFinite(e)?e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`:`—`}function b(e){return e.mime_type.startsWith(`image/`)}function ye(e){return e.mime_type.startsWith(`video/`)}function be(e){return e.mime_type.startsWith(`audio/`)}function xe(e){return e.mime_type===`application/pdf`}function x(e){return e.title?.trim()||e.filename}function Se(e){let t=e.metadata,n=Number(t?.width),r=Number(t?.height);return n>0&&r>0?`${n} × ${r} px`:null}function S(e){return{title:e.title??e.filename,alt:e.alt??``,caption:e.caption??``,description:e.description??``}}function C(l){let{t:u}=m(),[C,w]=n([]),[Ce,T]=n(0),[E,D]=n(1),[O,we]=n(``),[k,A]=n(``),[j,M]=n(``),[Te,N]=n(``),[Ee,P]=n(!1),[F,I]=n(null),[L,R]=n({title:``,alt:``,caption:``,description:``}),[De,z]=n(!1),[Oe,B]=n(!1),[ke,V]=n(!1),H=e=>h.mediaUrl(e.url),U=async()=>{try{let e=await h.listMedia({page:E(),limit:24,search:O()||void 0,mimeType:k()||void 0});w(e.data??[]),T(e.total??0)}catch(e){M(e instanceof Error?e.message:String(e))}};a(U);let W=async()=>{D(1),await U()},Ae=e=>{I(e),R(S(e)),M(``)},G=async e=>{if(e.length===0)return;P(!0),M(``),N(``);let t=0;for(let n of Array.from(e))try{await h.uploadMedia(n,{alt:``}),t+=1}catch(e){M(`${n.name}: ${e instanceof Error?e.message:String(e)}`)}P(!1),t>0&&(N(u(`media.toasts.uploaded`,{count:t})),D(1),await U())},je=async e=>{if(confirm(u(`media.details.confirmDelete`,{filename:e.filename})))try{await h.deleteMedia(e.id),F()?.id===e.id&&I(null),await U()}catch(e){M(e instanceof Error?e.message:String(e))}},Me=async()=>{let e=F();if(e){B(!0),M(``);try{let t=await h.updateMedia(e.id,L()),n={...e,...t};I(n),R(S(n)),N(u(`media.details.saved`)),await U()}catch(e){M(e instanceof Error?e.message:String(e))}finally{B(!1)}}},Ne=async e=>{let t=F();if(t){V(!0),M(``);try{let n=await h.replaceMediaFile(t.id,e),r={...t,...n};I(r),R(S(r)),N(u(`media.details.replaced`)),await U()}catch(e){M(e instanceof Error?e.message:String(e))}finally{V(!1)}}},Pe=async e=>{try{await navigator.clipboard.writeText(e),N(u(`media.details.copied`))}catch{M(u(`media.details.copyError`))}};return(()=>{var n=o(ae),a=n.firstChild,[m,h]=f(a.nextSibling),S=m.nextSibling,[w,T]=f(S.nextSibling),M=w.nextSibling,N=M.firstChild,P=N.firstChild,B=N.nextSibling,V=B.firstChild,[Fe,Ie]=f(V.nextSibling),K=Fe.nextSibling,Le=B.nextSibling,q=M.nextSibling,Re=q.firstChild,[J,Y]=f(Re.nextSibling),ze=J.nextSibling,[X,Be]=f(ze.nextSibling),Ve=X.nextSibling,[He,Z]=f(Ve.nextSibling),Ue=q.nextSibling,[Q,We]=f(Ue.nextSibling),Ge=Q.nextSibling,[$,Ke]=f(Ge.nextSibling),qe=$.nextSibling,[Je,Ye]=f(qe.nextSibling);return s(n,i(t,{get when(){return j()},get children(){var e=o(ne);return s(e,j),e}}),m,h),s(n,i(t,{get when(){return Te()},get children(){var e=o(re);return s(e,Te),e}}),w,T),M.addEventListener(`drop`,e=>{e.preventDefault(),z(!1),e.dataTransfer&&G(e.dataTransfer.files)}),M.addEventListener(`dragleave`,()=>z(!1)),M.addEventListener(`dragover`,e=>{e.preventDefault(),z(!0)}),s(P,()=>u(`media.upload.dropzone`)),s(B,(()=>{var e=d(()=>!!Ee());return()=>e()?u(`media.upload.uploading`):u(`media.upload.select`)})(),Fe,Ie),K.addEventListener(`change`,e=>{e.currentTarget.files&&G(e.currentTarget.files),e.currentTarget.value=``}),s(Le,()=>u(`media.upload.hint`)),s(q,i(_,{name:`media-search`,get placeholder(){return u(`media.toolbar.search`)},get value(){return O()},onInput:e=>{we(e),W()}}),J,Y),s(q,i(te,{name:`media-mime`,get placeholder(){return u(`media.toolbar.allTypes`)},get value(){return k()},get options(){return[{value:`image/png`,label:u(`media.mimeTypes.png`)},{value:`image/jpeg`,label:u(`media.mimeTypes.jpeg`)},{value:`image/gif`,label:u(`media.mimeTypes.gif`)},{value:`image/webp`,label:u(`media.mimeTypes.webp`)},{value:`image/svg+xml`,label:u(`media.mimeTypes.svg`)},{value:`application/pdf`,label:u(`media.mimeTypes.pdf`)},{value:`video/mp4`,label:u(`media.mimeTypes.mp4`)},{value:`audio/mpeg`,label:u(`media.mimeTypes.mp3`)}]},onChange:e=>{A(e),W()}}),X,Be),s(q,i(v,{variant:`secondary`,onClick:()=>void W(),get children(){return u(`media.toolbar.searchBtn`)}}),He,Z),s(n,i(t,{get when(){return C().length>0},get fallback(){return(()=>{var e=o(oe);return s(e,()=>u(`media.empty`)),e})()},get children(){var n=o(ie);return s(n,i(r,{get each(){return C()},children:n=>(()=>{var r=o(ce),a=r.firstChild,l=a.nextSibling.firstChild,u=l.nextSibling,d=u.firstChild,[p,m]=f(d.nextSibling),h=p.nextSibling.nextSibling,[g,_]=f(h.nextSibling);return r.$$click=()=>Ae(n),s(a,i(t,{get when(){return b(n)},get fallback(){return(()=>{var e=o(le);return s(e,()=>n.mime_type.split(`/`)[1]?.toUpperCase()??`FILE`),e})()},get children(){var t=o(se);return e(e=>{var r=H(n),i=n.alt??x(n);return r!==e.e&&c(t,`src`,e.e=r),i!==e.t&&c(t,`alt`,e.t=i),e},{e:void 0,t:void 0}),t}})),s(l,()=>x(n)),s(u,()=>n.filename,p,m),s(u,()=>ve(n.size),g,_),e(e=>{var t=F()?.id===n.id,i=x(n);return t!==e.e&&r.classList.toggle(`media-card--selected`,e.e=t),i!==e.t&&c(l,`title`,e.t=i),e},{e:void 0,t:void 0}),ee(),r})()})),n}}),Q,We),s(n,i(y,{get page(){return E()},limit:24,get total(){return Ce()},onPageChange:e=>{D(e),U()}}),$,Ke),s(n,i(g,{get open(){return!!F()},get title(){return d(()=>!!F())()?x(F()):u(`media.details.title`)},onClose:()=>I(null),get children(){return i(t,{get when(){return F()},children:n=>(()=>{var r=o(_e),a=r.firstChild,l=a.firstChild,[m,h]=f(l.nextSibling),g=m.nextSibling,[y,te]=f(g.nextSibling),ne=y.nextSibling,[re,ie]=f(ne.nextSibling),ae=re.nextSibling,[oe,se]=f(ae.nextSibling),ce=oe.nextSibling,[le,S]=f(ce.nextSibling),C=a.nextSibling,w=C.firstChild,Ce=w.firstChild,[T,E]=f(Ce.nextSibling),D=T.nextSibling,[O,we]=f(D.nextSibling),k=O.nextSibling,[A,j]=f(k.nextSibling),M=A.nextSibling,Te=M.firstChild,[N,Ee]=f(Te.nextSibling),P=N.nextSibling,F=w.nextSibling,De=F.firstChild,z=De.nextSibling,B=z.nextSibling,V=B.nextSibling,U=V.nextSibling,W=U.nextSibling,Ae=W.nextSibling,[G,Fe]=f(Ae.nextSibling),Ie=G.nextSibling,K=Ie.nextSibling,Le=K.nextSibling,q=Le.nextSibling.firstChild,Re=q.nextSibling,J=C.nextSibling,Y=J.firstChild,ze=Y.firstChild,[X,Be]=f(ze.nextSibling),Ve=X.nextSibling,He=Y.nextSibling,Z=J.nextSibling,Ue=Z.firstChild,[Q,We]=f(Ue.nextSibling),Ge=Q.nextSibling,[$,Ke]=f(Ge.nextSibling),qe=$.nextSibling,[Je,Ye]=f(qe.nextSibling);return s(a,i(t,{get when(){return b(n())},get children(){var t=o(ue);return e(e=>{var r=H(n()),i=L().alt||x(n());return r!==e.e&&c(t,`src`,e.e=r),i!==e.t&&c(t,`alt`,e.t=i),e},{e:void 0,t:void 0}),t}}),m,h),s(a,i(t,{get when(){return ye(n())},get children(){var t=o(de);return e(()=>c(t,`src`,H(n()))),t}}),y,te),s(a,i(t,{get when(){return be(n())},get children(){var t=o(fe);return e(()=>c(t,`src`,H(n()))),t}}),re,ie),s(a,i(t,{get when(){return xe(n())},get children(){var t=o(pe);return e(e=>{var r=x(n()),i=H(n());return r!==e.e&&c(t,`title`,e.e=r),i!==e.t&&c(t,`src`,e.t=i),e},{e:void 0,t:void 0}),t}}),oe,se),s(a,i(t,{get when(){return d(()=>!(b(n())||ye(n())||be(n())))()&&!xe(n())},get children(){var e=o(me);return s(e,()=>n().mime_type.split(`/`)[1]?.toUpperCase()??`FILE`),e}}),le,S),s(w,i(_,{name:`media-title`,get label(){return u(`media.details.titleField`)},get value(){return L().title},onInput:e=>R({...L(),title:e})}),T,E),s(w,i(_,{name:`media-alt`,get label(){return u(`media.details.alt`)},get value(){return L().alt},onInput:e=>R({...L(),alt:e})}),O,we),s(w,i(_,{name:`media-caption`,get label(){return u(`media.details.caption`)},get value(){return L().caption},onInput:e=>R({...L(),caption:e})}),A,j),s(M,()=>u(`media.details.description`),N,Ee),P.$$input=e=>R({...L(),description:e.currentTarget.value}),s(De,()=>u(`media.details.file`)),s(z,()=>n().filename),s(B,()=>u(`media.details.type`)),s(V,()=>n().mime_type),s(U,()=>u(`media.details.size`)),s(W,()=>ve(n().size)),s(F,i(t,{get when(){return Se(n())},get children(){return[(()=>{var e=o(he);return s(e,()=>u(`media.details.dimensions`)),e})(),(()=>{var e=o(ge);return s(e,()=>Se(n())),e})()]}}),G,Fe),s(Ie,()=>u(`media.details.uploaded`)),s(K,(()=>{var e=d(()=>!!n().created_at);return()=>e()?new Date(n().created_at).toLocaleString():`—`})()),s(Le,()=>u(`media.details.url`)),s(q,()=>H(n())),Re.$$click=()=>void Pe(H(n())),s(Re,()=>u(`media.details.copy`)),s(Y,(()=>{var e=d(()=>!!ke());return()=>e()?u(`media.details.replacing`):u(`media.details.replace`)})(),X,Be),Ve.addEventListener(`change`,e=>{let t=e.currentTarget.files?.[0];t&&Ne(t),e.currentTarget.value=``}),s(He,()=>u(`media.details.replaceHint`)),s(Z,i(v,{variant:`primary`,get disabled(){return Oe()},get loading(){return Oe()},onClick:()=>void Me(),get children(){return u(`media.details.save`)}}),Q,We),s(Z,i(v,{variant:`danger`,onClick:()=>void je(n()),get children(){return u(`media.details.delete`)}}),$,Ke),s(Z,i(v,{variant:`secondary`,onClick:()=>I(null),get children(){return u(`media.details.close`)}}),Je,Ye),e(()=>p(Ve,`disabled`,ke())),e(()=>p(P,`value`,L().description)),ee(),r})()})}}),Je,Ye),e(e=>{var t=!!(De()||l.focusUpload),n=Ee();return t!==e.e&&M.classList.toggle(`upload-zone--active`,e.e=t),n!==e.t&&p(K,`disabled`,e.t=n),e},{e:void 0,t:void 0}),n})()}u([`click`,`input`]);export{C as MediaLibrary};
|
|
1
|
+
import{d as e,i as t,p as n,r,s as i,y as a}from"./solid.D49dPDCT.js";import{a as o,c as s,d as ee,f as c,g as l,i as u,l as d,o as f,p}from"./web.Bqbl_1YR.js";import{n as m}from"./i18n.vdBFsiPK.js";import{n as h}from"./api.CYg1SW2X.js";import{a as g,i as _,n as v,o as y,s as te}from"./src.DXVWCoHp.js";var ne=l(`<div class="notice notice--error">`),re=l(`<div class=notice>`),ie=l(`<div class=media-grid>`),ae=l(`<div class=media-library><!$><!/><!$><!/><div class=upload-zone><p><strong></strong> ou</p><label class="btn btn-primary"style=cursor:pointer><!$><!/><input type=file multiple style=display:none></label><p class=muted></p></div><div class=toolbar><!$><!/><!$><!/><!$><!/></div><!$><!/><!$><!/><!$><!/>`),oe=l(`<p class=muted>`),se=l(`<img loading=lazy>`,!0,!1,!1),ce=l(`<button type=button class=media-card><div class=media-card__preview></div><div class=media-card__meta><span class=media-card__name></span><span class=muted><!$><!/> · <!$><!/>`),le=l(`<span class=media-card__ext>`),ue=l(`<img>`),de=l(`<video controls>`),fe=l(`<audio controls>`),pe=l(`<iframe>`),me=l(`<div class="media-card__ext media-modal__file-icon">`),he=l(`<dt>`),ge=l(`<dd>`),_e=l(`<div class=media-modal><div class=media-modal__preview><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/></div><div class=media-modal__layout><div class=media-modal__fields><!$><!/><!$><!/><!$><!/><label class=field__label><!$><!/><textarea class="input media-modal__textarea"name=media-description></textarea></label></div><dl class="media-details__list media-modal__facts"><dt></dt><dd></dd><dt></dt><dd></dd><dt></dt><dd></dd><!$><!/><dt></dt><dd></dd><dt></dt><dd class=media-details__url><code></code><button class="btn btn-secondary btn-sm"type=button></button></dd></dl></div><div class=media-modal__replace><label class="btn btn-secondary"style=cursor:pointer><!$><!/><input type=file style=display:none></label><span class=muted></span></div><div class=media-details__actions><!$><!/><!$><!/><!$><!/>`);function ve(e){return Number.isFinite(e)?e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`:`—`}function b(e){return e.mime_type.startsWith(`image/`)}function ye(e){return e.mime_type.startsWith(`video/`)}function be(e){return e.mime_type.startsWith(`audio/`)}function xe(e){return e.mime_type===`application/pdf`}function x(e){return e.title?.trim()||e.filename}function Se(e){let t=e.metadata,n=Number(t?.width),r=Number(t?.height);return n>0&&r>0?`${n} × ${r} px`:null}function S(e){return{title:e.title??e.filename,alt:e.alt??``,caption:e.caption??``,description:e.description??``}}function C(l){let{t:u}=m(),[C,w]=n([]),[Ce,T]=n(0),[E,D]=n(1),[O,we]=n(``),[k,A]=n(``),[j,M]=n(``),[Te,N]=n(``),[Ee,P]=n(!1),[F,I]=n(null),[L,R]=n({title:``,alt:``,caption:``,description:``}),[De,z]=n(!1),[Oe,B]=n(!1),[ke,V]=n(!1),H=e=>h.mediaUrl(e.url),U=async()=>{try{let e=await h.listMedia({page:E(),limit:24,search:O()||void 0,mimeType:k()||void 0});w(e.data??[]),T(e.total??0)}catch(e){M(e instanceof Error?e.message:String(e))}};a(U);let W=async()=>{D(1),await U()},Ae=e=>{I(e),R(S(e)),M(``)},G=async e=>{if(e.length===0)return;P(!0),M(``),N(``);let t=0;for(let n of Array.from(e))try{await h.uploadMedia(n,{alt:``}),t+=1}catch(e){M(`${n.name}: ${e instanceof Error?e.message:String(e)}`)}P(!1),t>0&&(N(u(`media.toasts.uploaded`,{count:t})),D(1),await U())},je=async e=>{if(confirm(u(`media.details.confirmDelete`,{filename:e.filename})))try{await h.deleteMedia(e.id),F()?.id===e.id&&I(null),await U()}catch(e){M(e instanceof Error?e.message:String(e))}},Me=async()=>{let e=F();if(e){B(!0),M(``);try{let t=await h.updateMedia(e.id,L()),n={...e,...t};I(n),R(S(n)),N(u(`media.details.saved`)),await U()}catch(e){M(e instanceof Error?e.message:String(e))}finally{B(!1)}}},Ne=async e=>{let t=F();if(t){V(!0),M(``);try{let n=await h.replaceMediaFile(t.id,e),r={...t,...n};I(r),R(S(r)),N(u(`media.details.replaced`)),await U()}catch(e){M(e instanceof Error?e.message:String(e))}finally{V(!1)}}},Pe=async e=>{try{await navigator.clipboard.writeText(e),N(u(`media.details.copied`))}catch{M(u(`media.details.copyError`))}};return(()=>{var n=o(ae),a=n.firstChild,[m,h]=f(a.nextSibling),S=m.nextSibling,[w,T]=f(S.nextSibling),M=w.nextSibling,N=M.firstChild,P=N.firstChild,B=N.nextSibling,V=B.firstChild,[Fe,Ie]=f(V.nextSibling),K=Fe.nextSibling,Le=B.nextSibling,q=M.nextSibling,Re=q.firstChild,[J,Y]=f(Re.nextSibling),ze=J.nextSibling,[X,Be]=f(ze.nextSibling),Ve=X.nextSibling,[He,Z]=f(Ve.nextSibling),Ue=q.nextSibling,[Q,We]=f(Ue.nextSibling),Ge=Q.nextSibling,[$,Ke]=f(Ge.nextSibling),qe=$.nextSibling,[Je,Ye]=f(qe.nextSibling);return s(n,i(t,{get when(){return j()},get children(){var e=o(ne);return s(e,j),e}}),m,h),s(n,i(t,{get when(){return Te()},get children(){var e=o(re);return s(e,Te),e}}),w,T),M.addEventListener(`drop`,e=>{e.preventDefault(),z(!1),e.dataTransfer&&G(e.dataTransfer.files)}),M.addEventListener(`dragleave`,()=>z(!1)),M.addEventListener(`dragover`,e=>{e.preventDefault(),z(!0)}),s(P,()=>u(`media.upload.dropzone`)),s(B,(()=>{var e=d(()=>!!Ee());return()=>e()?u(`media.upload.uploading`):u(`media.upload.select`)})(),Fe,Ie),K.addEventListener(`change`,e=>{e.currentTarget.files&&G(e.currentTarget.files),e.currentTarget.value=``}),s(Le,()=>u(`media.upload.hint`)),s(q,i(_,{name:`media-search`,get placeholder(){return u(`media.toolbar.search`)},get value(){return O()},onInput:e=>{we(e),W()}}),J,Y),s(q,i(te,{name:`media-mime`,get placeholder(){return u(`media.toolbar.allTypes`)},get value(){return k()},get options(){return[{value:`image/png`,label:u(`media.mimeTypes.png`)},{value:`image/jpeg`,label:u(`media.mimeTypes.jpeg`)},{value:`image/gif`,label:u(`media.mimeTypes.gif`)},{value:`image/webp`,label:u(`media.mimeTypes.webp`)},{value:`image/svg+xml`,label:u(`media.mimeTypes.svg`)},{value:`application/pdf`,label:u(`media.mimeTypes.pdf`)},{value:`video/mp4`,label:u(`media.mimeTypes.mp4`)},{value:`audio/mpeg`,label:u(`media.mimeTypes.mp3`)}]},onChange:e=>{A(e),W()}}),X,Be),s(q,i(v,{variant:`secondary`,onClick:()=>void W(),get children(){return u(`media.toolbar.searchBtn`)}}),He,Z),s(n,i(t,{get when(){return C().length>0},get fallback(){return(()=>{var e=o(oe);return s(e,()=>u(`media.empty`)),e})()},get children(){var n=o(ie);return s(n,i(r,{get each(){return C()},children:n=>(()=>{var r=o(ce),a=r.firstChild,l=a.nextSibling.firstChild,u=l.nextSibling,d=u.firstChild,[p,m]=f(d.nextSibling),h=p.nextSibling.nextSibling,[g,_]=f(h.nextSibling);return r.$$click=()=>Ae(n),s(a,i(t,{get when(){return b(n)},get fallback(){return(()=>{var e=o(le);return s(e,()=>n.mime_type.split(`/`)[1]?.toUpperCase()??`FILE`),e})()},get children(){var t=o(se);return e(e=>{var r=H(n),i=n.alt??x(n);return r!==e.e&&c(t,`src`,e.e=r),i!==e.t&&c(t,`alt`,e.t=i),e},{e:void 0,t:void 0}),t}})),s(l,()=>x(n)),s(u,()=>n.filename,p,m),s(u,()=>ve(n.size),g,_),e(e=>{var t=F()?.id===n.id,i=x(n);return t!==e.e&&r.classList.toggle(`media-card--selected`,e.e=t),i!==e.t&&c(l,`title`,e.t=i),e},{e:void 0,t:void 0}),ee(),r})()})),n}}),Q,We),s(n,i(y,{get page(){return E()},limit:24,get total(){return Ce()},onPageChange:e=>{D(e),U()}}),$,Ke),s(n,i(g,{get open(){return!!F()},get title(){return d(()=>!!F())()?x(F()):u(`media.details.title`)},onClose:()=>I(null),get children(){return i(t,{get when(){return F()},children:n=>(()=>{var r=o(_e),a=r.firstChild,l=a.firstChild,[m,h]=f(l.nextSibling),g=m.nextSibling,[y,te]=f(g.nextSibling),ne=y.nextSibling,[re,ie]=f(ne.nextSibling),ae=re.nextSibling,[oe,se]=f(ae.nextSibling),ce=oe.nextSibling,[le,S]=f(ce.nextSibling),C=a.nextSibling,w=C.firstChild,Ce=w.firstChild,[T,E]=f(Ce.nextSibling),D=T.nextSibling,[O,we]=f(D.nextSibling),k=O.nextSibling,[A,j]=f(k.nextSibling),M=A.nextSibling,Te=M.firstChild,[N,Ee]=f(Te.nextSibling),P=N.nextSibling,F=w.nextSibling,De=F.firstChild,z=De.nextSibling,B=z.nextSibling,V=B.nextSibling,U=V.nextSibling,W=U.nextSibling,Ae=W.nextSibling,[G,Fe]=f(Ae.nextSibling),Ie=G.nextSibling,K=Ie.nextSibling,Le=K.nextSibling,q=Le.nextSibling.firstChild,Re=q.nextSibling,J=C.nextSibling,Y=J.firstChild,ze=Y.firstChild,[X,Be]=f(ze.nextSibling),Ve=X.nextSibling,He=Y.nextSibling,Z=J.nextSibling,Ue=Z.firstChild,[Q,We]=f(Ue.nextSibling),Ge=Q.nextSibling,[$,Ke]=f(Ge.nextSibling),qe=$.nextSibling,[Je,Ye]=f(qe.nextSibling);return s(a,i(t,{get when(){return b(n())},get children(){var t=o(ue);return e(e=>{var r=H(n()),i=L().alt||x(n());return r!==e.e&&c(t,`src`,e.e=r),i!==e.t&&c(t,`alt`,e.t=i),e},{e:void 0,t:void 0}),t}}),m,h),s(a,i(t,{get when(){return ye(n())},get children(){var t=o(de);return e(()=>c(t,`src`,H(n()))),t}}),y,te),s(a,i(t,{get when(){return be(n())},get children(){var t=o(fe);return e(()=>c(t,`src`,H(n()))),t}}),re,ie),s(a,i(t,{get when(){return xe(n())},get children(){var t=o(pe);return e(e=>{var r=x(n()),i=H(n());return r!==e.e&&c(t,`title`,e.e=r),i!==e.t&&c(t,`src`,e.t=i),e},{e:void 0,t:void 0}),t}}),oe,se),s(a,i(t,{get when(){return d(()=>!(b(n())||ye(n())||be(n())))()&&!xe(n())},get children(){var e=o(me);return s(e,()=>n().mime_type.split(`/`)[1]?.toUpperCase()??`FILE`),e}}),le,S),s(w,i(_,{name:`media-title`,get label(){return u(`media.details.titleField`)},get value(){return L().title},onInput:e=>R({...L(),title:e})}),T,E),s(w,i(_,{name:`media-alt`,get label(){return u(`media.details.alt`)},get value(){return L().alt},onInput:e=>R({...L(),alt:e})}),O,we),s(w,i(_,{name:`media-caption`,get label(){return u(`media.details.caption`)},get value(){return L().caption},onInput:e=>R({...L(),caption:e})}),A,j),s(M,()=>u(`media.details.description`),N,Ee),P.$$input=e=>R({...L(),description:e.currentTarget.value}),s(De,()=>u(`media.details.file`)),s(z,()=>n().filename),s(B,()=>u(`media.details.type`)),s(V,()=>n().mime_type),s(U,()=>u(`media.details.size`)),s(W,()=>ve(n().size)),s(F,i(t,{get when(){return Se(n())},get children(){return[(()=>{var e=o(he);return s(e,()=>u(`media.details.dimensions`)),e})(),(()=>{var e=o(ge);return s(e,()=>Se(n())),e})()]}}),G,Fe),s(Ie,()=>u(`media.details.uploaded`)),s(K,(()=>{var e=d(()=>!!n().created_at);return()=>e()?new Date(n().created_at).toLocaleString():`—`})()),s(Le,()=>u(`media.details.url`)),s(q,()=>H(n())),Re.$$click=()=>void Pe(H(n())),s(Re,()=>u(`media.details.copy`)),s(Y,(()=>{var e=d(()=>!!ke());return()=>e()?u(`media.details.replacing`):u(`media.details.replace`)})(),X,Be),Ve.addEventListener(`change`,e=>{let t=e.currentTarget.files?.[0];t&&Ne(t),e.currentTarget.value=``}),s(He,()=>u(`media.details.replaceHint`)),s(Z,i(v,{variant:`primary`,get disabled(){return Oe()},get loading(){return Oe()},onClick:()=>void Me(),get children(){return u(`media.details.save`)}}),Q,We),s(Z,i(v,{variant:`danger`,onClick:()=>void je(n()),get children(){return u(`media.details.delete`)}}),$,Ke),s(Z,i(v,{variant:`secondary`,onClick:()=>I(null),get children(){return u(`media.details.close`)}}),Je,Ye),e(()=>p(Ve,`disabled`,ke())),e(()=>p(P,`value`,L().description)),ee(),r})()})}}),Je,Ye),e(e=>{var t=!!(De()||l.focusUpload),n=Ee();return t!==e.e&&M.classList.toggle(`upload-zone--active`,e.e=t),n!==e.t&&p(K,`disabled`,e.t=n),e},{e:void 0,t:void 0}),n})()}u([`click`,`input`]);export{C as MediaLibrary};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,i as t,p as n,r,s as i,u as a,y as o}from"./solid.D49dPDCT.js";import{a as s,c,d as l,f as u,g as d,i as f,l as p,o as m,p as h}from"./web.Bqbl_1YR.js";import{n as g}from"./i18n.AbBpo2WD.js";import{n as _}from"./api.CYg1SW2X.js";var v=d(`<div class=wp-menu-empty-level>`),y=d(`<div class=wp-menu-tree><!$><!/><!$><!/>`),b=d(`<article class=wp-menu-item><div class=wp-menu-item__header><span class=wp-menu-drag draggable=true>⠿⠿⠿</span><span class=wp-menu-item__label><strong></strong><small></small></span><div class=wp-menu-item__actions><button type=button class="btn btn-sm">↑</button><button type=button class="btn btn-sm">↓</button><button type=button class="btn btn-sm">→</button><button type=button class="btn btn-sm">←</button></div></div><details class=wp-menu-item__details><summary></summary><div class=wp-menu-item__fields><label><!$><!/><input class=input></label><label><!$><!/><input class=input></label><label><!$><!/><input class=input></label><label><!$><!/><input class=input></label><label><!$><!/><select class=input><option value=_self></option><option value=_blank></option></select></label><label><!$><!/><input class=input></label><label class=wp-menu-item__wide><!$><!/><textarea class=input rows=2></textarea></label><button type=button class="btn btn-danger btn-sm"></button></div></details><!$><!/>`),x=d(`<p class=muted>`),S=d(`<details class=wp-menu-box><summary></summary><div class=wp-menu-box__body><!$><!/><!$><!/>`),C=d(`<div class="notice notice--error">`),w=d(`<div class=notice>`),T=d(`<div class="menus-manager wp-menus-manager"><!$><!/><!$><!/><!$><!/><style>.wp-menu-editor__top,.wp-structure-heading,.wp-menu-editor__identity,.wp-menu-item__header,.wp-menu-item__actions,.form-actions{display:flex;align-items:center;gap:.7rem}.wp-menu-editor__top,.wp-structure-heading{justify-content:space-between}.wp-menu-editor__top{margin-bottom:1rem}.wp-menu-editor__top h3{margin:.25rem 0 0}.wp-eyebrow{display:block;margin-top:.7rem;font-size:.72rem;text-transform:uppercase;letter-spacing:.08em;color:var(--color-muted)}.wp-menu-editor__identity{margin-bottom:1rem;align-items:end}.wp-menu-editor__identity label{display:grid;gap:.35rem;flex:1}.wp-menu-editor__columns{display:grid;grid-template-columns:330px minmax(0,1fr);gap:1.2rem;align-items:start}.wp-menu-sources,.wp-menu-structure{min-width:0}.wp-menu-sources>h4,.wp-structure-heading h4{margin:0}.wp-menu-box{background:var(--color-surface,#fff);border:1px solid var(--color-border,#ddd);margin-bottom:.7rem}.wp-menu-box summary{cursor:pointer;padding:.8rem;font-weight:600}.wp-menu-box__body{padding:0 .8rem .8rem;display:grid;gap:.6rem}.wp-menu-box__body p{margin:0}.wp-source-list{display:grid;gap:.35rem;max-height:220px;overflow:auto;border:1px solid var(--color-border,#ddd);padding:.45rem}.wp-source-row{display:flex!important;align-items:start;gap:.45rem!important;padding:.3rem}.wp-source-row span,.wp-source-link{display:grid;gap:.12rem;text-align:left}.wp-source-row small,.wp-source-link small,.wp-menu-item__label small{color:var(--color-muted);font-size:.75rem}.wp-source-link{border:0;background:none;color:inherit;padding:.35rem;width:100%;cursor:pointer}.wp-source-link:hover{background:var(--color-surface-muted,#f5f5f5)}.wp-taxonomy-source{display:grid;gap:.2rem;border-top:1px solid var(--color-border,#ddd);padding-top:.5rem}.wp-taxonomy-source:first-child{border-top:0;padding-top:0}.wp-menu-structure{background:var(--color-surface-muted,#f7f7f7);padding:1rem}.wp-menu-structure .wp-structure-heading{margin-bottom:1rem}.wp-menu-tree{display:grid;gap:.55rem}.wp-menu-tree[data-depth="1"]{margin:.55rem 0 0 2rem}.wp-menu-item{background:var(--color-surface,#fff);border:1px solid var(--color-border,#dcdcde);box-shadow:0 1px 1px rgba(0,0,0,.04)}.wp-menu-item__header{padding:.55rem .7rem}.wp-menu-drag{cursor:grab;letter-spacing:-.2rem;width:1.4rem;color:var(--color-muted);user-select:none}.wp-menu-item__label{display:grid;gap:.15rem;flex:1;min-width:0}.wp-menu-item__label small{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wp-menu-item__actions{margin-left:auto}.wp-menu-item__details{border-top:1px solid var(--color-border,#ddd)}.wp-menu-item__details summary{padding:.5rem .7rem;cursor:pointer;color:var(--color-muted);font-size:.85rem}.wp-menu-item__fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.7rem;padding:.7rem;border-top:1px solid var(--color-border,#ddd)}.wp-menu-item__fields label{display:grid;gap:.3rem}.wp-menu-item__wide{grid-column:1/-1}.wp-menu-empty,.wp-menu-empty-level{text-align:center;padding:2rem;color:var(--color-muted)}.wp-menu-empty-level{border:1px dashed var(--color-border,#ccc);padding:1rem}.wp-menu-settings{margin-top:1rem}.wp-menu-settings h4{margin-top:0}.wp-menu-settings p{margin-bottom:0}.wp-menus-manager .menu-actions{white-space:nowrap;text-align:right}@media(max-width:850px){.wp-menu-editor__columns{grid-template-columns:1fr}.wp-menu-sources{order:2}.wp-menu-structure{order:1}.wp-menu-editor__identity,.wp-menu-editor__top{align-items:stretch;display:grid}.wp-menu-item__fields{grid-template-columns:1fr}.wp-menu-item__wide{grid-column:auto}}`),E=d(`<div class=skeleton>`),ee=d(`<div class=manager-toolbar><p class=muted></p><button class="btn btn-primary"type=button>+ <!$><!/>`),D=d(`<table class=table><thead><tr><th></th><th></th><th></th><th></th></tr></thead><tbody>`),te=d(`<section class=card>`),O=d(`<p class="muted empty-state">`),k=d(`<tr><td><strong></strong></td><td><code></code></td><td></td><td class=menu-actions><button class="btn btn-secondary btn-sm"type=button></button> <button class="btn btn-danger btn-sm"type=button>`),ne=d(`<input class=input>`),A=d(`<div class=wp-source-list>`),j=d(`<button type=button class="btn btn-secondary btn-sm">`),re=d(`<label><!$><!/><input class=input placeholder=https://>`),ie=d(`<label><!$><!/><input class=input>`),ae=d(`<form class=wp-menu-editor><div class=wp-menu-editor__top><div><button type=button class="btn btn-secondary btn-sm">← <!$><!/></button><span class=wp-eyebrow></span><h3></h3></div><div class=form-actions><button class="btn btn-secondary"type=button></button><button class="btn btn-primary"type=submit></button></div></div><div class="wp-menu-editor__identity card"><label><!$><!/><input class=input required></label><label><!$><!/><input class=input></label></div><div class=wp-menu-editor__columns><aside class=wp-menu-sources><h4></h4><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/></aside><main class=wp-menu-structure><div class=wp-structure-heading><div><h4></h4><p class=muted></p></div><span class=badge><!$><!/> <!$><!/></span></div><!$><!/><section class="card wp-menu-settings"><h4></h4><label class=checkbox-label><input type=checkbox> <!$><!/></label><p class=muted>`),oe=d(`<label class=wp-source-row><input type=checkbox><span><!$><!/><small>/<!$><!/>`),se=d(`<label class=wp-source-row><input type=checkbox><span><!$><!/><small>/post/<!$><!/>`),M=d(`<div class=wp-taxonomy-source><strong></strong><!$><!/>`),N=d(`<button type=button class=wp-source-link><!$><!/><small>/<!$><!/>/<!$><!/>`),ce=d(`<button type=button class=wp-source-link><!$><!/><small>/<!$><!/>`),le=d(`<div class="wp-menu-empty card">`);function P(e){return`${e}_${typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():Math.random().toString(36).slice(2)}`}function F(e){return e.toLowerCase().normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/(^-|-$)/g,``)}function I(e,t=null){let n=e.id||P(`item`);return{...e,id:n,clientId:n,parentId:t??e.parentId??null,children:[]}}function ue(e){let t=(Array.isArray(e)?e:[]).map(e=>I(e)),n=new Map(t.map(e=>[e.id,e])),r=[];for(let e of t){let t=e.parentId?n.get(e.parentId):void 0;t&&t.id!==e.id?t.children.push(e):r.push(e)}let i=e=>(e.sort((e,t)=>(e.order??0)-(t.order??0)),e.forEach(e=>i(e.children)),e);return i(r)}function L(e,t=null){let n=[];return e.forEach((e,r)=>{let{clientId:i,children:a,...o}=e;n.push({...o,id:e.id,parentId:t,order:r}),n.push(...L(a,e.id))}),n}function R(e){return e.map(e=>({...e,children:R(e.children)}))}function z(e,t){return e.id===t||e.children.some(e=>z(e,t))}function B(e,t){let n=e.findIndex(e=>e.id===t);if(n>=0){let t=[...e],[r]=t.splice(n,1);return{items:t,removed:r}}for(let n=0;n<e.length;n+=1){let r=B(e[n].children,t);if(r.removed){let t=[...e];return t[n]={...t[n],children:r.items},{items:t,removed:r.removed}}}return{items:e}}function V(e,t,n){let r=e.findIndex(e=>e.id===t);if(r>=0){let t=[...e];return t.splice(r,0,n),{items:t,inserted:!0}}for(let r=0;r<e.length;r+=1){let i=V(e[r].children,t,n);if(i.inserted){let t=[...e];return t[r]={...t[r],children:i.items},{items:t,inserted:!0}}}return{items:e,inserted:!1}}function H(e,t,n){for(let r=0;r<e.length;r+=1){let i=e[r];if(i.id===t){let t=[...e];return t[r]={...i,children:[...i.children,n]},{items:t,inserted:!0}}let a=H(i.children,t,n);if(a.inserted){let t=[...e];return t[r]={...i,children:a.items},{items:t,inserted:!0}}}return{items:e,inserted:!1}}function U(e,t,n){return e.map(e=>e.id===t?{...e,...n}:{...e,children:U(e.children,t,n)})}function de(e,t){return B(e,t).items}function fe(e,t,n){if(t===n||e.some(e=>e.id===t&&z(e,n)))return e;let r=B(e,t);if(!r.removed)return e;let i=V(r.items,n,r.removed);return i.inserted?i.items:e}function pe(e,t,n){if(t===n||e.some(e=>e.id===t&&z(e,n)))return e;let r=B(e,t);if(!r.removed)return e;let i=H(r.items,n,r.removed);return i.inserted?i.items:e}function W(e,t,n){let r=e.findIndex(e=>e.id===t);if(r>=0)return{siblings:e,index:r,parent:n};for(let n of e){let e=W(n.children,t,n);if(e)return e}return null}function me(e,t,n){let r=R(e),i=W(r,t);if(!i)return e;let a=i.index+n;return a<0||a>=i.siblings.length?e:([i.siblings[i.index],i.siblings[a]]=[i.siblings[a],i.siblings[i.index]],r)}function he(e,t){let n=R(e),r=W(n,t);return!r||r.index===0?e:pe(n,t,r.siblings[r.index-1].id)}function ge(e,t){let n=R(e),r=W(n,t);return r?.parent?fe(n,t,r.parent.id):e}function _e(e){let t=P(`item`);return{id:t,clientId:t,type:e.type,label:e.label,url:e.url,objectId:e.objectId,objectType:e.objectType,parentId:null,order:0,target:`_self`,children:[]}}function ve(a){let[o,d]=n(null);return(()=>{var n=s(y),f=n.firstChild,[p,g]=m(f.nextSibling),_=p.nextSibling,[x,S]=m(_.nextSibling);return c(n,i(r,{get each(){return a.items},children:n=>(()=>{var r=s(b),f=r.firstChild,p=f.firstChild,g=p.nextSibling,_=g.firstChild,v=_.nextSibling,y=g.nextSibling.firstChild,x=y.nextSibling,S=x.nextSibling,C=S.nextSibling,w=f.nextSibling,T=w.firstChild,E=T.nextSibling.firstChild,ee=E.firstChild,[D,te]=m(ee.nextSibling),O=D.nextSibling,k=E.nextSibling,ne=k.firstChild,[A,j]=m(ne.nextSibling),re=A.nextSibling,ie=k.nextSibling,ae=ie.firstChild,[oe,se]=m(ae.nextSibling),M=oe.nextSibling,N=ie.nextSibling,ce=N.firstChild,[le,P]=m(ce.nextSibling),F=le.nextSibling,I=N.nextSibling,ue=I.firstChild,[L,R]=m(ue.nextSibling),z=L.nextSibling,B=z.firstChild,V=B.nextSibling,H=I.nextSibling,pe=H.firstChild,[W,_e]=m(pe.nextSibling),G=W.nextSibling,K=H.nextSibling,q=K.firstChild,[J,ye]=m(q.nextSibling),Y=J.nextSibling,be=K.nextSibling,xe=w.nextSibling,[Se,Ce]=m(xe.nextSibling);return r.addEventListener(`drop`,e=>{e.preventDefault();let t=o()??e.dataTransfer?.getData(`text/plain`);t&&a.onChange(fe(a.items,t,n.id)),d(null)}),r.addEventListener(`dragover`,e=>e.preventDefault()),p.addEventListener(`dragend`,()=>d(null)),p.addEventListener(`dragstart`,e=>{d(n.id),e.dataTransfer?.setData(`text/plain`,n.id)}),c(_,()=>n.label||a.t(`menus.editor.untitled`)),c(v,()=>n.url||a.t(`menus.editor.noUrl`)),y.$$click=()=>a.onChange(me(a.items,n.id,-1)),x.$$click=()=>a.onChange(me(a.items,n.id,1)),S.$$click=()=>a.onChange(he(a.items,n.id)),C.$$click=()=>a.onChange(ge(a.items,n.id)),c(T,()=>a.t(`menus.editor.itemSettings`)),c(E,()=>a.t(`menus.editor.navigationLabel`),D,te),O.$$input=e=>a.onChange(U(a.items,n.id,{label:e.currentTarget.value})),c(k,()=>a.t(`menus.editor.url`),A,j),re.$$input=e=>a.onChange(U(a.items,n.id,{url:e.currentTarget.value})),c(ie,()=>a.t(`menus.editor.titleAttribute`),oe,se),M.$$input=e=>a.onChange(U(a.items,n.id,{attrTitle:e.currentTarget.value})),c(N,()=>a.t(`menus.editor.cssClasses`),le,P),F.$$input=e=>a.onChange(U(a.items,n.id,{cssClasses:e.currentTarget.value})),c(I,()=>a.t(`menus.editor.target`),L,R),z.addEventListener(`change`,e=>a.onChange(U(a.items,n.id,{target:e.currentTarget.value}))),c(B,()=>a.t(`menus.editor.sameWindow`)),c(V,()=>a.t(`menus.editor.newWindow`)),c(H,()=>a.t(`menus.editor.xfn`),W,_e),G.$$input=e=>a.onChange(U(a.items,n.id,{xfn:e.currentTarget.value})),c(K,()=>a.t(`menus.editor.description`),J,ye),Y.$$input=e=>a.onChange(U(a.items,n.id,{description:e.currentTarget.value})),be.$$click=()=>a.onChange(de(a.items,n.id)),c(be,()=>a.t(`menus.editor.remove`)),c(r,i(t,{get when(){return n.children.length>0},get children(){return i(ve,{get items(){return n.children},get depth(){return(a.depth??0)+1},get t(){return a.t},onChange:e=>a.onChange(U(a.items,n.id,{children:e}))})}}),Se,Ce),e(e=>{var t=a.t(`menus.editor.drag`),n=a.t(`menus.editor.up`),r=a.t(`menus.editor.down`),i=a.t(`menus.editor.indent`),o=a.t(`menus.editor.outdent`);return t!==e.e&&u(p,`title`,e.e=t),n!==e.t&&u(y,`title`,e.t=n),r!==e.a&&u(x,`title`,e.a=r),i!==e.o&&u(S,`title`,e.o=i),o!==e.i&&u(C,`title`,e.i=o),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e(()=>h(O,`value`,n.label)),e(()=>h(re,`value`,n.url??``)),e(()=>h(M,`value`,n.attrTitle??``)),e(()=>h(F,`value`,n.cssClasses??``)),e(()=>h(z,`value`,n.target??`_self`)),e(()=>h(G,`value`,n.xfn??``)),e(()=>h(Y,`value`,n.description??``)),l(),r})()}),p,g),c(n,i(t,{get when(){return a.items.length===0},get children(){var e=s(v);return c(e,()=>a.t(`menus.editor.emptyLevel`)),e}}),x,S),e(()=>u(n,`data-depth`,a.depth??0)),n})()}function G(n){return(()=>{var r=s(S),a=r.firstChild,o=a.nextSibling,l=o.firstChild,[u,d]=m(l.nextSibling),f=u.nextSibling,[p,g]=m(f.nextSibling);return c(a,()=>n.title),c(o,i(t,{get when(){return n.description},get children(){var e=s(x);return c(e,()=>n.description),e}}),u,d),c(o,()=>n.children,p,g),e(()=>h(r,`open`,n.open)),r})()}function K(){let{t:d}=g(),[f,v]=n([]),[y,b]=n(null),[x,S]=n([]),[I,R]=n([]),[z,B]=n({}),[V,H]=n([]),[U,de]=n([]),[fe,pe]=n({}),[W,me]=n(``),[he,ge]=n(``),[K,q]=n([]),[J,ye]=n(``),[Y,be]=n(``),[xe,Se]=n(!0),[Ce,we]=n(!1),[Te,X]=n(``),[Ee,Z]=n(``),De=async()=>{Se(!0),X(``);try{let[e,t,n,r,i]=await Promise.all([_.getMenus(),_.getContent({type:`page`,status:`PUBLISHED`,limit:100}),_.getContent({type:`post`,status:`PUBLISHED`,limit:100}),_.getContentTypes(),_.getTaxonomies()]);v(e),S(t.data),R(n.data),H(r),de(i);let a=await Promise.all(r.filter(e=>e.slug!==`page`&&e.slug!==`post`&&!e.singleton).map(async e=>[e.slug,(await _.getContent({type:e.slug,status:`PUBLISHED`,limit:100})).data]));B(Object.fromEntries(a));let o=await Promise.all(i.map(async e=>[e.slug,await _.getTaxonomyTerms(e.slug)]));pe(Object.fromEntries(o))}catch(e){X(e instanceof Error?e.message:String(e))}finally{Se(!1)}};o(De);let Oe=e=>{b({id:e?.id,name:e?.name??``,slug:e?.slug??``,items:ue(e?.items),settings:{...e?.settings??{}}}),q([]),X(``),Z(``)},Q=e=>{let t=y();t&&b({...t,...e})},$=e=>{let t=y();t&&Q({items:[...t.items,_e(e)]})},ke=e=>{let t=new Set(K()),n=y();n&&(Q({items:[...n.items,...e.filter(e=>t.has(e.id)).map(_e)]}),q([]))},Ae=()=>{J().trim()&&Y().trim()&&($({id:P(`custom`),type:`custom`,label:Y().trim(),url:J().trim()}),ye(``),be(``))},je=async e=>{e.preventDefault();let t=y();if(t){if(!t.name.trim()){X(d(`menus.nameRequired`));return}we(!0),X(``);try{let e={name:t.name.trim(),slug:t.slug.trim()||F(t.name),items:L(t.items),settings:t.settings};t.id?await _.updateMenu(t.id,e):await _.createMenu(e),b(null),Z(d(`menus.saved`)),await De()}catch(e){X(e instanceof Error?e.message:String(e))}finally{we(!1)}}},Me=async e=>{if(e.id&&confirm(d(`menus.confirmDelete`,{name:e.name})))try{await _.deleteMenu(e.id),Z(d(`menus.deleted`)),await De()}catch(e){X(e instanceof Error?e.message:String(e))}},Ne=a(()=>x().filter(e=>!W()||`${e.title} ${e.slug}`.toLowerCase().includes(W().toLowerCase()))),Pe=a(()=>I().filter(e=>!he()||`${e.title} ${e.slug}`.toLowerCase().includes(he().toLowerCase()))),Fe=e=>({id:`page:${e.id}`,type:`page`,label:e.title,url:`/${e.slug}`,objectId:e.id,objectType:`page`}),Ie=e=>({id:`post:${e.id}`,type:`post`,label:e.title,url:`/post/${e.slug}`,objectId:e.id,objectType:`post`}),Le=e=>({id:`content:${e.type}:${e.id}`,type:`content`,label:e.title,url:`/${e.type}/${e.slug}`,objectId:e.id,objectType:e.type});return(()=>{var n=s(T),a=n.firstChild,[o,g]=m(a.nextSibling),_=o.nextSibling,[v,x]=m(_.nextSibling),S=v.nextSibling,[P,I]=m(S.nextSibling);return P.nextSibling,c(n,i(t,{get when(){return Te()},get children(){var e=s(C);return c(e,Te),e}}),o,g),c(n,i(t,{get when(){return Ee()},get children(){var e=s(w);return c(e,Ee),e}}),v,x),c(n,i(t,{get when(){return!xe()},get fallback(){return(()=>{var e=s(E);return c(e,()=>d(`common.loading`)),e})()},get children(){return i(t,{get when(){return y()},get fallback(){return[(()=>{var e=s(ee),t=e.firstChild,n=t.nextSibling,r=n.firstChild.nextSibling,[i,a]=m(r.nextSibling);return c(t,()=>d(`menus.hint`)),n.$$click=()=>Oe(),c(n,()=>d(`menus.new`),i,a),l(),e})(),(()=>{var e=s(te);return c(e,i(t,{get when(){return f().length>0},get fallback(){return(()=>{var e=s(O);return c(e,()=>d(`menus.empty`)),e})()},get children(){var e=s(D),t=e.firstChild,n=t.firstChild.firstChild,a=n.nextSibling,o=a.nextSibling,u=t.nextSibling;return c(n,()=>d(`menus.name`)),c(a,()=>d(`menus.slug`)),c(o,()=>d(`menus.items`)),c(u,i(r,{get each(){return f()},children:e=>(()=>{var t=s(k),n=t.firstChild,r=n.firstChild,i=n.nextSibling,a=i.firstChild,o=i.nextSibling,u=o.nextSibling.firstChild,f=u.nextSibling.nextSibling;return c(r,()=>e.name),c(a,()=>e.slug),c(o,()=>e.items?.length??0),u.$$click=()=>Oe(e),c(u,()=>d(`common.edit`)),f.$$click=()=>void Me(e),c(f,()=>d(`common.delete`)),l(),t})()})),e}})),e})()]},children:n=>(()=>{var a=s(ae),o=a.firstChild,f=o.firstChild,g=f.firstChild,_=g.firstChild.nextSibling,[v,y]=m(_.nextSibling),x=g.nextSibling,S=x.nextSibling,C=f.nextSibling.firstChild,w=C.nextSibling,T=o.nextSibling,E=T.firstChild,ee=E.firstChild,[D,te]=m(ee.nextSibling),O=D.nextSibling,k=E.nextSibling,P=k.firstChild,[I,ue]=m(P.nextSibling),L=I.nextSibling,R=T.nextSibling.firstChild,B=R.firstChild,H=B.nextSibling,[de,pe]=m(H.nextSibling),_e=de.nextSibling,[xe,Se]=m(_e.nextSibling),we=xe.nextSibling,[Te,X]=m(we.nextSibling),Ee=Te.nextSibling,[Z,De]=m(Ee.nextSibling),Oe=Z.nextSibling,[Me,Re]=m(Oe.nextSibling),ze=Me.nextSibling,[Be,Ve]=m(ze.nextSibling),He=Be.nextSibling,[Ue,We]=m(He.nextSibling),Ge=R.nextSibling,Ke=Ge.firstChild,qe=Ke.firstChild,Je=qe.firstChild,Ye=Je.nextSibling,Xe=qe.nextSibling,Ze=Xe.firstChild,[Qe,$e]=m(Ze.nextSibling),et=Qe.nextSibling.nextSibling,[tt,nt]=m(et.nextSibling),rt=Ke.nextSibling,[it,at]=m(rt.nextSibling),ot=it.nextSibling.firstChild,st=ot.nextSibling,ct=st.firstChild,lt=ct.nextSibling.nextSibling,[ut,dt]=m(lt.nextSibling),ft=st.nextSibling;return a.addEventListener(`submit`,je),g.$$click=()=>b(null),c(g,()=>d(`menus.back`),v,y),c(x,()=>d(`menus.editor.eyebrow`)),c(S,(()=>{var e=p(()=>!!n().id);return()=>e()?d(`menus.edit`):d(`menus.create`)})()),C.$$click=()=>b(null),c(C,()=>d(`common.cancel`)),c(w,(()=>{var e=p(()=>!!Ce());return()=>e()?d(`common.loading`):d(`common.save`)})()),c(E,()=>d(`menus.name`),D,te),O.$$input=e=>Q({name:e.currentTarget.value}),c(k,()=>d(`menus.slug`),I,ue),L.$$input=e=>Q({slug:e.currentTarget.value}),c(B,()=>d(`menus.editor.addItems`)),c(R,i(G,{get title(){return d(`menus.sources.pages`)},open:!0,get children(){return[(()=>{var t=s(ne);return t.$$input=e=>me(e.currentTarget.value),e(()=>u(t,`placeholder`,d(`menus.editor.search`))),e(()=>h(t,`value`,W())),l(),t})(),(()=>{var t=s(A);return c(t,i(r,{get each(){return Ne()},children:t=>(()=>{var n=s(oe),r=n.firstChild,i=r.nextSibling,a=i.firstChild,[o,l]=m(a.nextSibling),u=o.nextSibling,d=u.firstChild.nextSibling,[f,p]=m(d.nextSibling);return r.addEventListener(`change`,e=>q(e.currentTarget.checked?[...K(),`page:${t.id}`]:K().filter(e=>e!==`page:${t.id}`))),c(i,()=>t.title,o,l),c(u,()=>t.slug,f,p),e(()=>h(r,`checked`,K().includes(`page:${t.id}`))),n})()})),t})(),(()=>{var e=s(j);return e.$$click=()=>ke(Ne().map(Fe)),c(e,()=>d(`menus.editor.addSelected`)),l(),e})()]}}),de,pe),c(R,i(G,{get title(){return d(`menus.sources.posts`)},get children(){return[(()=>{var t=s(ne);return t.$$input=e=>ge(e.currentTarget.value),e(()=>u(t,`placeholder`,d(`menus.editor.search`))),e(()=>h(t,`value`,he())),l(),t})(),(()=>{var t=s(A);return c(t,i(r,{get each(){return Pe()},children:t=>(()=>{var n=s(se),r=n.firstChild,i=r.nextSibling,a=i.firstChild,[o,l]=m(a.nextSibling),u=o.nextSibling,d=u.firstChild.nextSibling,[f,p]=m(d.nextSibling);return r.addEventListener(`change`,e=>q(e.currentTarget.checked?[...K(),`post:${t.id}`]:K().filter(e=>e!==`post:${t.id}`))),c(i,()=>t.title,o,l),c(u,()=>t.slug,f,p),e(()=>h(r,`checked`,K().includes(`post:${t.id}`))),n})()})),t})(),(()=>{var e=s(j);return e.$$click=()=>ke(Pe().map(Ie)),c(e,()=>d(`menus.editor.addSelected`)),l(),e})()]}}),xe,Se),c(R,i(G,{get title(){return d(`menus.sources.contentTypes`)},get children(){return i(r,{get each(){return V().filter(e=>e.slug!==`page`&&e.slug!==`post`&&!e.singleton)},children:e=>(()=>{var t=s(M),n=t.firstChild,a=n.nextSibling,[o,u]=m(a.nextSibling);return c(n,()=>e.pluralLabel),c(t,i(r,{get each(){return z()[e.slug]??[]},children:t=>(()=>{var n=s(N),r=n.firstChild,[i,a]=m(r.nextSibling),o=i.nextSibling,u=o.firstChild.nextSibling,[d,f]=m(u.nextSibling),p=d.nextSibling.nextSibling,[h,g]=m(p.nextSibling);return n.$$click=()=>$(Le(t)),c(n,()=>t.title,i,a),c(o,()=>e.slug,d,f),c(o,()=>t.slug,h,g),l(),n})()}),o,u),t})()})}}),Te,X),c(R,i(G,{get title(){return d(`menus.sources.custom`)},get description(){return d(`menus.sources.customHint`)},get children(){return[(()=>{var t=s(re),n=t.firstChild,[r,i]=m(n.nextSibling),a=r.nextSibling;return c(t,()=>d(`menus.editor.url`),r,i),a.$$input=e=>ye(e.currentTarget.value),e(()=>h(a,`value`,J())),l(),t})(),(()=>{var t=s(ie),n=t.firstChild,[r,i]=m(n.nextSibling),a=r.nextSibling;return c(t,()=>d(`menus.editor.navigationLabel`),r,i),a.$$input=e=>be(e.currentTarget.value),e(()=>h(a,`value`,Y())),l(),t})(),(()=>{var e=s(j);return e.$$click=Ae,c(e,()=>d(`menus.editor.addToMenu`)),l(),e})()]}}),Z,De),c(R,i(G,{get title(){return d(`menus.sources.home`)},get children(){var e=s(j);return e.$$click=()=>$({id:`home`,type:`home`,label:d(`menus.sources.home`),url:`/`}),c(e,()=>d(`menus.editor.addToMenu`)),l(),e}}),Me,Re),c(R,i(G,{get title(){return d(`menus.sources.archives`)},get children(){var e=s(A);return c(e,i(r,{get each(){return V().filter(e=>e.hasArchive)},children:e=>(()=>{var t=s(ce),n=t.firstChild,[r,i]=m(n.nextSibling),a=r.nextSibling,o=a.firstChild.nextSibling,[u,d]=m(o.nextSibling);return t.$$click=()=>$({id:`archive:${e.slug}`,type:`archive`,label:e.pluralLabel,url:`/${e.slug}`,objectType:e.slug}),c(t,()=>e.pluralLabel,r,i),c(a,()=>e.slug,u,d),l(),t})()})),e}}),Be,Ve),c(R,i(G,{get title(){return d(`menus.sources.taxonomies`)},get children(){return i(r,{get each(){return U()},children:e=>(()=>{var t=s(M),n=t.firstChild,a=n.nextSibling,[o,u]=m(a.nextSibling);return c(n,()=>e.name),c(t,i(r,{get each(){return fe()[e.slug]??[]},children:t=>(()=>{var n=s(N),r=n.firstChild,[i,a]=m(r.nextSibling),o=i.nextSibling,u=o.firstChild.nextSibling,[d,f]=m(u.nextSibling),p=d.nextSibling.nextSibling,[h,g]=m(p.nextSibling);return n.$$click=()=>$({id:`term:${e.slug}:${t.slug}`,type:`taxonomy`,label:t.name,url:`/${e.slug}/${t.slug}`,objectId:t.id,objectType:e.slug}),c(n,()=>t.name,i,a),c(o,()=>e.slug,d,f),c(o,()=>t.slug,h,g),l(),n})()}),o,u),t})()})}}),Ue,We),c(Je,()=>d(`menus.editor.structure`)),c(Ye,()=>d(`menus.editor.structureHint`)),c(Xe,()=>n().items.length,Qe,$e),c(Xe,()=>d(`menus.items`),tt,nt),c(Ge,i(t,{get when(){return n().items.length>0},get fallback(){return(()=>{var e=s(le);return c(e,()=>d(`menus.editor.empty`)),e})()},get children(){return i(ve,{get items(){return n().items},t:d,onChange:e=>Q({items:e})})}}),it,at),c(ot,()=>d(`menus.editor.settings`)),ct.addEventListener(`change`,e=>Q({settings:{...n().settings,autoAddNewPages:e.currentTarget.checked}})),c(st,()=>d(`menus.editor.autoAddPages`),ut,dt),c(ft,()=>d(`menus.editor.autoAddPagesHint`)),e(e=>{var t=Ce(),r=F(n().name);return t!==e.e&&h(w,`disabled`,e.e=t),r!==e.t&&u(L,`placeholder`,e.t=r),e},{e:void 0,t:void 0}),e(()=>h(O,`value`,n().name)),e(()=>h(L,`value`,n().slug)),e(()=>h(ct,`checked`,n().settings.autoAddNewPages===!0)),l(),a})()})}}),P,I),n})()}f([`click`,`input`]);export{K as MenuManager};
|
|
1
|
+
import{d as e,i as t,p as n,r,s as i,u as a,y as o}from"./solid.D49dPDCT.js";import{a as s,c,d as l,f as u,g as d,i as f,l as p,o as m,p as h}from"./web.Bqbl_1YR.js";import{n as g}from"./i18n.vdBFsiPK.js";import{n as _}from"./api.CYg1SW2X.js";var v=d(`<div class=wp-menu-empty-level>`),y=d(`<div class=wp-menu-tree><!$><!/><!$><!/>`),b=d(`<article class=wp-menu-item><div class=wp-menu-item__header><span class=wp-menu-drag draggable=true>⠿⠿⠿</span><span class=wp-menu-item__label><strong></strong><small></small></span><div class=wp-menu-item__actions><button type=button class="btn btn-sm">↑</button><button type=button class="btn btn-sm">↓</button><button type=button class="btn btn-sm">→</button><button type=button class="btn btn-sm">←</button></div></div><details class=wp-menu-item__details><summary></summary><div class=wp-menu-item__fields><label><!$><!/><input class=input></label><label><!$><!/><input class=input></label><label><!$><!/><input class=input></label><label><!$><!/><input class=input></label><label><!$><!/><select class=input><option value=_self></option><option value=_blank></option></select></label><label><!$><!/><input class=input></label><label class=wp-menu-item__wide><!$><!/><textarea class=input rows=2></textarea></label><button type=button class="btn btn-danger btn-sm"></button></div></details><!$><!/>`),x=d(`<p class=muted>`),S=d(`<details class=wp-menu-box><summary></summary><div class=wp-menu-box__body><!$><!/><!$><!/>`),C=d(`<div class="notice notice--error">`),w=d(`<div class=notice>`),T=d(`<div class="menus-manager wp-menus-manager"><!$><!/><!$><!/><!$><!/><style>.wp-menu-editor__top,.wp-structure-heading,.wp-menu-editor__identity,.wp-menu-item__header,.wp-menu-item__actions,.form-actions{display:flex;align-items:center;gap:.7rem}.wp-menu-editor__top,.wp-structure-heading{justify-content:space-between}.wp-menu-editor__top{margin-bottom:1rem}.wp-menu-editor__top h3{margin:.25rem 0 0}.wp-eyebrow{display:block;margin-top:.7rem;font-size:.72rem;text-transform:uppercase;letter-spacing:.08em;color:var(--color-muted)}.wp-menu-editor__identity{margin-bottom:1rem;align-items:end}.wp-menu-editor__identity label{display:grid;gap:.35rem;flex:1}.wp-menu-editor__columns{display:grid;grid-template-columns:330px minmax(0,1fr);gap:1.2rem;align-items:start}.wp-menu-sources,.wp-menu-structure{min-width:0}.wp-menu-sources>h4,.wp-structure-heading h4{margin:0}.wp-menu-box{background:var(--color-surface,#fff);border:1px solid var(--color-border,#ddd);margin-bottom:.7rem}.wp-menu-box summary{cursor:pointer;padding:.8rem;font-weight:600}.wp-menu-box__body{padding:0 .8rem .8rem;display:grid;gap:.6rem}.wp-menu-box__body p{margin:0}.wp-source-list{display:grid;gap:.35rem;max-height:220px;overflow:auto;border:1px solid var(--color-border,#ddd);padding:.45rem}.wp-source-row{display:flex!important;align-items:start;gap:.45rem!important;padding:.3rem}.wp-source-row span,.wp-source-link{display:grid;gap:.12rem;text-align:left}.wp-source-row small,.wp-source-link small,.wp-menu-item__label small{color:var(--color-muted);font-size:.75rem}.wp-source-link{border:0;background:none;color:inherit;padding:.35rem;width:100%;cursor:pointer}.wp-source-link:hover{background:var(--color-surface-muted,#f5f5f5)}.wp-taxonomy-source{display:grid;gap:.2rem;border-top:1px solid var(--color-border,#ddd);padding-top:.5rem}.wp-taxonomy-source:first-child{border-top:0;padding-top:0}.wp-menu-structure{background:var(--color-surface-muted,#f7f7f7);padding:1rem}.wp-menu-structure .wp-structure-heading{margin-bottom:1rem}.wp-menu-tree{display:grid;gap:.55rem}.wp-menu-tree[data-depth="1"]{margin:.55rem 0 0 2rem}.wp-menu-item{background:var(--color-surface,#fff);border:1px solid var(--color-border,#dcdcde);box-shadow:0 1px 1px rgba(0,0,0,.04)}.wp-menu-item__header{padding:.55rem .7rem}.wp-menu-drag{cursor:grab;letter-spacing:-.2rem;width:1.4rem;color:var(--color-muted);user-select:none}.wp-menu-item__label{display:grid;gap:.15rem;flex:1;min-width:0}.wp-menu-item__label small{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wp-menu-item__actions{margin-left:auto}.wp-menu-item__details{border-top:1px solid var(--color-border,#ddd)}.wp-menu-item__details summary{padding:.5rem .7rem;cursor:pointer;color:var(--color-muted);font-size:.85rem}.wp-menu-item__fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.7rem;padding:.7rem;border-top:1px solid var(--color-border,#ddd)}.wp-menu-item__fields label{display:grid;gap:.3rem}.wp-menu-item__wide{grid-column:1/-1}.wp-menu-empty,.wp-menu-empty-level{text-align:center;padding:2rem;color:var(--color-muted)}.wp-menu-empty-level{border:1px dashed var(--color-border,#ccc);padding:1rem}.wp-menu-settings{margin-top:1rem}.wp-menu-settings h4{margin-top:0}.wp-menu-settings p{margin-bottom:0}.wp-menus-manager .menu-actions{white-space:nowrap;text-align:right}@media(max-width:850px){.wp-menu-editor__columns{grid-template-columns:1fr}.wp-menu-sources{order:2}.wp-menu-structure{order:1}.wp-menu-editor__identity,.wp-menu-editor__top{align-items:stretch;display:grid}.wp-menu-item__fields{grid-template-columns:1fr}.wp-menu-item__wide{grid-column:auto}}`),E=d(`<div class=skeleton>`),ee=d(`<div class=manager-toolbar><p class=muted></p><button class="btn btn-primary"type=button>+ <!$><!/>`),D=d(`<table class=table><thead><tr><th></th><th></th><th></th><th></th></tr></thead><tbody>`),te=d(`<section class=card>`),O=d(`<p class="muted empty-state">`),k=d(`<tr><td><strong></strong></td><td><code></code></td><td></td><td class=menu-actions><button class="btn btn-secondary btn-sm"type=button></button> <button class="btn btn-danger btn-sm"type=button>`),ne=d(`<input class=input>`),A=d(`<div class=wp-source-list>`),j=d(`<button type=button class="btn btn-secondary btn-sm">`),re=d(`<label><!$><!/><input class=input placeholder=https://>`),ie=d(`<label><!$><!/><input class=input>`),ae=d(`<form class=wp-menu-editor><div class=wp-menu-editor__top><div><button type=button class="btn btn-secondary btn-sm">← <!$><!/></button><span class=wp-eyebrow></span><h3></h3></div><div class=form-actions><button class="btn btn-secondary"type=button></button><button class="btn btn-primary"type=submit></button></div></div><div class="wp-menu-editor__identity card"><label><!$><!/><input class=input required></label><label><!$><!/><input class=input></label></div><div class=wp-menu-editor__columns><aside class=wp-menu-sources><h4></h4><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/></aside><main class=wp-menu-structure><div class=wp-structure-heading><div><h4></h4><p class=muted></p></div><span class=badge><!$><!/> <!$><!/></span></div><!$><!/><section class="card wp-menu-settings"><h4></h4><label class=checkbox-label><input type=checkbox> <!$><!/></label><p class=muted>`),oe=d(`<label class=wp-source-row><input type=checkbox><span><!$><!/><small>/<!$><!/>`),se=d(`<label class=wp-source-row><input type=checkbox><span><!$><!/><small>/post/<!$><!/>`),M=d(`<div class=wp-taxonomy-source><strong></strong><!$><!/>`),N=d(`<button type=button class=wp-source-link><!$><!/><small>/<!$><!/>/<!$><!/>`),ce=d(`<button type=button class=wp-source-link><!$><!/><small>/<!$><!/>`),le=d(`<div class="wp-menu-empty card">`);function P(e){return`${e}_${typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():Math.random().toString(36).slice(2)}`}function F(e){return e.toLowerCase().normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/(^-|-$)/g,``)}function I(e,t=null){let n=e.id||P(`item`);return{...e,id:n,clientId:n,parentId:t??e.parentId??null,children:[]}}function ue(e){let t=(Array.isArray(e)?e:[]).map(e=>I(e)),n=new Map(t.map(e=>[e.id,e])),r=[];for(let e of t){let t=e.parentId?n.get(e.parentId):void 0;t&&t.id!==e.id?t.children.push(e):r.push(e)}let i=e=>(e.sort((e,t)=>(e.order??0)-(t.order??0)),e.forEach(e=>i(e.children)),e);return i(r)}function L(e,t=null){let n=[];return e.forEach((e,r)=>{let{clientId:i,children:a,...o}=e;n.push({...o,id:e.id,parentId:t,order:r}),n.push(...L(a,e.id))}),n}function R(e){return e.map(e=>({...e,children:R(e.children)}))}function z(e,t){return e.id===t||e.children.some(e=>z(e,t))}function B(e,t){let n=e.findIndex(e=>e.id===t);if(n>=0){let t=[...e],[r]=t.splice(n,1);return{items:t,removed:r}}for(let n=0;n<e.length;n+=1){let r=B(e[n].children,t);if(r.removed){let t=[...e];return t[n]={...t[n],children:r.items},{items:t,removed:r.removed}}}return{items:e}}function V(e,t,n){let r=e.findIndex(e=>e.id===t);if(r>=0){let t=[...e];return t.splice(r,0,n),{items:t,inserted:!0}}for(let r=0;r<e.length;r+=1){let i=V(e[r].children,t,n);if(i.inserted){let t=[...e];return t[r]={...t[r],children:i.items},{items:t,inserted:!0}}}return{items:e,inserted:!1}}function H(e,t,n){for(let r=0;r<e.length;r+=1){let i=e[r];if(i.id===t){let t=[...e];return t[r]={...i,children:[...i.children,n]},{items:t,inserted:!0}}let a=H(i.children,t,n);if(a.inserted){let t=[...e];return t[r]={...i,children:a.items},{items:t,inserted:!0}}}return{items:e,inserted:!1}}function U(e,t,n){return e.map(e=>e.id===t?{...e,...n}:{...e,children:U(e.children,t,n)})}function de(e,t){return B(e,t).items}function fe(e,t,n){if(t===n||e.some(e=>e.id===t&&z(e,n)))return e;let r=B(e,t);if(!r.removed)return e;let i=V(r.items,n,r.removed);return i.inserted?i.items:e}function pe(e,t,n){if(t===n||e.some(e=>e.id===t&&z(e,n)))return e;let r=B(e,t);if(!r.removed)return e;let i=H(r.items,n,r.removed);return i.inserted?i.items:e}function W(e,t,n){let r=e.findIndex(e=>e.id===t);if(r>=0)return{siblings:e,index:r,parent:n};for(let n of e){let e=W(n.children,t,n);if(e)return e}return null}function me(e,t,n){let r=R(e),i=W(r,t);if(!i)return e;let a=i.index+n;return a<0||a>=i.siblings.length?e:([i.siblings[i.index],i.siblings[a]]=[i.siblings[a],i.siblings[i.index]],r)}function he(e,t){let n=R(e),r=W(n,t);return!r||r.index===0?e:pe(n,t,r.siblings[r.index-1].id)}function ge(e,t){let n=R(e),r=W(n,t);return r?.parent?fe(n,t,r.parent.id):e}function _e(e){let t=P(`item`);return{id:t,clientId:t,type:e.type,label:e.label,url:e.url,objectId:e.objectId,objectType:e.objectType,parentId:null,order:0,target:`_self`,children:[]}}function ve(a){let[o,d]=n(null);return(()=>{var n=s(y),f=n.firstChild,[p,g]=m(f.nextSibling),_=p.nextSibling,[x,S]=m(_.nextSibling);return c(n,i(r,{get each(){return a.items},children:n=>(()=>{var r=s(b),f=r.firstChild,p=f.firstChild,g=p.nextSibling,_=g.firstChild,v=_.nextSibling,y=g.nextSibling.firstChild,x=y.nextSibling,S=x.nextSibling,C=S.nextSibling,w=f.nextSibling,T=w.firstChild,E=T.nextSibling.firstChild,ee=E.firstChild,[D,te]=m(ee.nextSibling),O=D.nextSibling,k=E.nextSibling,ne=k.firstChild,[A,j]=m(ne.nextSibling),re=A.nextSibling,ie=k.nextSibling,ae=ie.firstChild,[oe,se]=m(ae.nextSibling),M=oe.nextSibling,N=ie.nextSibling,ce=N.firstChild,[le,P]=m(ce.nextSibling),F=le.nextSibling,I=N.nextSibling,ue=I.firstChild,[L,R]=m(ue.nextSibling),z=L.nextSibling,B=z.firstChild,V=B.nextSibling,H=I.nextSibling,pe=H.firstChild,[W,_e]=m(pe.nextSibling),G=W.nextSibling,K=H.nextSibling,q=K.firstChild,[J,ye]=m(q.nextSibling),Y=J.nextSibling,be=K.nextSibling,xe=w.nextSibling,[Se,Ce]=m(xe.nextSibling);return r.addEventListener(`drop`,e=>{e.preventDefault();let t=o()??e.dataTransfer?.getData(`text/plain`);t&&a.onChange(fe(a.items,t,n.id)),d(null)}),r.addEventListener(`dragover`,e=>e.preventDefault()),p.addEventListener(`dragend`,()=>d(null)),p.addEventListener(`dragstart`,e=>{d(n.id),e.dataTransfer?.setData(`text/plain`,n.id)}),c(_,()=>n.label||a.t(`menus.editor.untitled`)),c(v,()=>n.url||a.t(`menus.editor.noUrl`)),y.$$click=()=>a.onChange(me(a.items,n.id,-1)),x.$$click=()=>a.onChange(me(a.items,n.id,1)),S.$$click=()=>a.onChange(he(a.items,n.id)),C.$$click=()=>a.onChange(ge(a.items,n.id)),c(T,()=>a.t(`menus.editor.itemSettings`)),c(E,()=>a.t(`menus.editor.navigationLabel`),D,te),O.$$input=e=>a.onChange(U(a.items,n.id,{label:e.currentTarget.value})),c(k,()=>a.t(`menus.editor.url`),A,j),re.$$input=e=>a.onChange(U(a.items,n.id,{url:e.currentTarget.value})),c(ie,()=>a.t(`menus.editor.titleAttribute`),oe,se),M.$$input=e=>a.onChange(U(a.items,n.id,{attrTitle:e.currentTarget.value})),c(N,()=>a.t(`menus.editor.cssClasses`),le,P),F.$$input=e=>a.onChange(U(a.items,n.id,{cssClasses:e.currentTarget.value})),c(I,()=>a.t(`menus.editor.target`),L,R),z.addEventListener(`change`,e=>a.onChange(U(a.items,n.id,{target:e.currentTarget.value}))),c(B,()=>a.t(`menus.editor.sameWindow`)),c(V,()=>a.t(`menus.editor.newWindow`)),c(H,()=>a.t(`menus.editor.xfn`),W,_e),G.$$input=e=>a.onChange(U(a.items,n.id,{xfn:e.currentTarget.value})),c(K,()=>a.t(`menus.editor.description`),J,ye),Y.$$input=e=>a.onChange(U(a.items,n.id,{description:e.currentTarget.value})),be.$$click=()=>a.onChange(de(a.items,n.id)),c(be,()=>a.t(`menus.editor.remove`)),c(r,i(t,{get when(){return n.children.length>0},get children(){return i(ve,{get items(){return n.children},get depth(){return(a.depth??0)+1},get t(){return a.t},onChange:e=>a.onChange(U(a.items,n.id,{children:e}))})}}),Se,Ce),e(e=>{var t=a.t(`menus.editor.drag`),n=a.t(`menus.editor.up`),r=a.t(`menus.editor.down`),i=a.t(`menus.editor.indent`),o=a.t(`menus.editor.outdent`);return t!==e.e&&u(p,`title`,e.e=t),n!==e.t&&u(y,`title`,e.t=n),r!==e.a&&u(x,`title`,e.a=r),i!==e.o&&u(S,`title`,e.o=i),o!==e.i&&u(C,`title`,e.i=o),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e(()=>h(O,`value`,n.label)),e(()=>h(re,`value`,n.url??``)),e(()=>h(M,`value`,n.attrTitle??``)),e(()=>h(F,`value`,n.cssClasses??``)),e(()=>h(z,`value`,n.target??`_self`)),e(()=>h(G,`value`,n.xfn??``)),e(()=>h(Y,`value`,n.description??``)),l(),r})()}),p,g),c(n,i(t,{get when(){return a.items.length===0},get children(){var e=s(v);return c(e,()=>a.t(`menus.editor.emptyLevel`)),e}}),x,S),e(()=>u(n,`data-depth`,a.depth??0)),n})()}function G(n){return(()=>{var r=s(S),a=r.firstChild,o=a.nextSibling,l=o.firstChild,[u,d]=m(l.nextSibling),f=u.nextSibling,[p,g]=m(f.nextSibling);return c(a,()=>n.title),c(o,i(t,{get when(){return n.description},get children(){var e=s(x);return c(e,()=>n.description),e}}),u,d),c(o,()=>n.children,p,g),e(()=>h(r,`open`,n.open)),r})()}function K(){let{t:d}=g(),[f,v]=n([]),[y,b]=n(null),[x,S]=n([]),[I,R]=n([]),[z,B]=n({}),[V,H]=n([]),[U,de]=n([]),[fe,pe]=n({}),[W,me]=n(``),[he,ge]=n(``),[K,q]=n([]),[J,ye]=n(``),[Y,be]=n(``),[xe,Se]=n(!0),[Ce,we]=n(!1),[Te,X]=n(``),[Ee,Z]=n(``),De=async()=>{Se(!0),X(``);try{let[e,t,n,r,i]=await Promise.all([_.getMenus(),_.getContent({type:`page`,status:`PUBLISHED`,limit:100}),_.getContent({type:`post`,status:`PUBLISHED`,limit:100}),_.getContentTypes(),_.getTaxonomies()]);v(e),S(t.data),R(n.data),H(r),de(i);let a=await Promise.all(r.filter(e=>e.slug!==`page`&&e.slug!==`post`&&!e.singleton).map(async e=>[e.slug,(await _.getContent({type:e.slug,status:`PUBLISHED`,limit:100})).data]));B(Object.fromEntries(a));let o=await Promise.all(i.map(async e=>[e.slug,await _.getTaxonomyTerms(e.slug)]));pe(Object.fromEntries(o))}catch(e){X(e instanceof Error?e.message:String(e))}finally{Se(!1)}};o(De);let Oe=e=>{b({id:e?.id,name:e?.name??``,slug:e?.slug??``,items:ue(e?.items),settings:{...e?.settings??{}}}),q([]),X(``),Z(``)},Q=e=>{let t=y();t&&b({...t,...e})},$=e=>{let t=y();t&&Q({items:[...t.items,_e(e)]})},ke=e=>{let t=new Set(K()),n=y();n&&(Q({items:[...n.items,...e.filter(e=>t.has(e.id)).map(_e)]}),q([]))},Ae=()=>{J().trim()&&Y().trim()&&($({id:P(`custom`),type:`custom`,label:Y().trim(),url:J().trim()}),ye(``),be(``))},je=async e=>{e.preventDefault();let t=y();if(t){if(!t.name.trim()){X(d(`menus.nameRequired`));return}we(!0),X(``);try{let e={name:t.name.trim(),slug:t.slug.trim()||F(t.name),items:L(t.items),settings:t.settings};t.id?await _.updateMenu(t.id,e):await _.createMenu(e),b(null),Z(d(`menus.saved`)),await De()}catch(e){X(e instanceof Error?e.message:String(e))}finally{we(!1)}}},Me=async e=>{if(e.id&&confirm(d(`menus.confirmDelete`,{name:e.name})))try{await _.deleteMenu(e.id),Z(d(`menus.deleted`)),await De()}catch(e){X(e instanceof Error?e.message:String(e))}},Ne=a(()=>x().filter(e=>!W()||`${e.title} ${e.slug}`.toLowerCase().includes(W().toLowerCase()))),Pe=a(()=>I().filter(e=>!he()||`${e.title} ${e.slug}`.toLowerCase().includes(he().toLowerCase()))),Fe=e=>({id:`page:${e.id}`,type:`page`,label:e.title,url:`/${e.slug}`,objectId:e.id,objectType:`page`}),Ie=e=>({id:`post:${e.id}`,type:`post`,label:e.title,url:`/post/${e.slug}`,objectId:e.id,objectType:`post`}),Le=e=>({id:`content:${e.type}:${e.id}`,type:`content`,label:e.title,url:`/${e.type}/${e.slug}`,objectId:e.id,objectType:e.type});return(()=>{var n=s(T),a=n.firstChild,[o,g]=m(a.nextSibling),_=o.nextSibling,[v,x]=m(_.nextSibling),S=v.nextSibling,[P,I]=m(S.nextSibling);return P.nextSibling,c(n,i(t,{get when(){return Te()},get children(){var e=s(C);return c(e,Te),e}}),o,g),c(n,i(t,{get when(){return Ee()},get children(){var e=s(w);return c(e,Ee),e}}),v,x),c(n,i(t,{get when(){return!xe()},get fallback(){return(()=>{var e=s(E);return c(e,()=>d(`common.loading`)),e})()},get children(){return i(t,{get when(){return y()},get fallback(){return[(()=>{var e=s(ee),t=e.firstChild,n=t.nextSibling,r=n.firstChild.nextSibling,[i,a]=m(r.nextSibling);return c(t,()=>d(`menus.hint`)),n.$$click=()=>Oe(),c(n,()=>d(`menus.new`),i,a),l(),e})(),(()=>{var e=s(te);return c(e,i(t,{get when(){return f().length>0},get fallback(){return(()=>{var e=s(O);return c(e,()=>d(`menus.empty`)),e})()},get children(){var e=s(D),t=e.firstChild,n=t.firstChild.firstChild,a=n.nextSibling,o=a.nextSibling,u=t.nextSibling;return c(n,()=>d(`menus.name`)),c(a,()=>d(`menus.slug`)),c(o,()=>d(`menus.items`)),c(u,i(r,{get each(){return f()},children:e=>(()=>{var t=s(k),n=t.firstChild,r=n.firstChild,i=n.nextSibling,a=i.firstChild,o=i.nextSibling,u=o.nextSibling.firstChild,f=u.nextSibling.nextSibling;return c(r,()=>e.name),c(a,()=>e.slug),c(o,()=>e.items?.length??0),u.$$click=()=>Oe(e),c(u,()=>d(`common.edit`)),f.$$click=()=>void Me(e),c(f,()=>d(`common.delete`)),l(),t})()})),e}})),e})()]},children:n=>(()=>{var a=s(ae),o=a.firstChild,f=o.firstChild,g=f.firstChild,_=g.firstChild.nextSibling,[v,y]=m(_.nextSibling),x=g.nextSibling,S=x.nextSibling,C=f.nextSibling.firstChild,w=C.nextSibling,T=o.nextSibling,E=T.firstChild,ee=E.firstChild,[D,te]=m(ee.nextSibling),O=D.nextSibling,k=E.nextSibling,P=k.firstChild,[I,ue]=m(P.nextSibling),L=I.nextSibling,R=T.nextSibling.firstChild,B=R.firstChild,H=B.nextSibling,[de,pe]=m(H.nextSibling),_e=de.nextSibling,[xe,Se]=m(_e.nextSibling),we=xe.nextSibling,[Te,X]=m(we.nextSibling),Ee=Te.nextSibling,[Z,De]=m(Ee.nextSibling),Oe=Z.nextSibling,[Me,Re]=m(Oe.nextSibling),ze=Me.nextSibling,[Be,Ve]=m(ze.nextSibling),He=Be.nextSibling,[Ue,We]=m(He.nextSibling),Ge=R.nextSibling,Ke=Ge.firstChild,qe=Ke.firstChild,Je=qe.firstChild,Ye=Je.nextSibling,Xe=qe.nextSibling,Ze=Xe.firstChild,[Qe,$e]=m(Ze.nextSibling),et=Qe.nextSibling.nextSibling,[tt,nt]=m(et.nextSibling),rt=Ke.nextSibling,[it,at]=m(rt.nextSibling),ot=it.nextSibling.firstChild,st=ot.nextSibling,ct=st.firstChild,lt=ct.nextSibling.nextSibling,[ut,dt]=m(lt.nextSibling),ft=st.nextSibling;return a.addEventListener(`submit`,je),g.$$click=()=>b(null),c(g,()=>d(`menus.back`),v,y),c(x,()=>d(`menus.editor.eyebrow`)),c(S,(()=>{var e=p(()=>!!n().id);return()=>e()?d(`menus.edit`):d(`menus.create`)})()),C.$$click=()=>b(null),c(C,()=>d(`common.cancel`)),c(w,(()=>{var e=p(()=>!!Ce());return()=>e()?d(`common.loading`):d(`common.save`)})()),c(E,()=>d(`menus.name`),D,te),O.$$input=e=>Q({name:e.currentTarget.value}),c(k,()=>d(`menus.slug`),I,ue),L.$$input=e=>Q({slug:e.currentTarget.value}),c(B,()=>d(`menus.editor.addItems`)),c(R,i(G,{get title(){return d(`menus.sources.pages`)},open:!0,get children(){return[(()=>{var t=s(ne);return t.$$input=e=>me(e.currentTarget.value),e(()=>u(t,`placeholder`,d(`menus.editor.search`))),e(()=>h(t,`value`,W())),l(),t})(),(()=>{var t=s(A);return c(t,i(r,{get each(){return Ne()},children:t=>(()=>{var n=s(oe),r=n.firstChild,i=r.nextSibling,a=i.firstChild,[o,l]=m(a.nextSibling),u=o.nextSibling,d=u.firstChild.nextSibling,[f,p]=m(d.nextSibling);return r.addEventListener(`change`,e=>q(e.currentTarget.checked?[...K(),`page:${t.id}`]:K().filter(e=>e!==`page:${t.id}`))),c(i,()=>t.title,o,l),c(u,()=>t.slug,f,p),e(()=>h(r,`checked`,K().includes(`page:${t.id}`))),n})()})),t})(),(()=>{var e=s(j);return e.$$click=()=>ke(Ne().map(Fe)),c(e,()=>d(`menus.editor.addSelected`)),l(),e})()]}}),de,pe),c(R,i(G,{get title(){return d(`menus.sources.posts`)},get children(){return[(()=>{var t=s(ne);return t.$$input=e=>ge(e.currentTarget.value),e(()=>u(t,`placeholder`,d(`menus.editor.search`))),e(()=>h(t,`value`,he())),l(),t})(),(()=>{var t=s(A);return c(t,i(r,{get each(){return Pe()},children:t=>(()=>{var n=s(se),r=n.firstChild,i=r.nextSibling,a=i.firstChild,[o,l]=m(a.nextSibling),u=o.nextSibling,d=u.firstChild.nextSibling,[f,p]=m(d.nextSibling);return r.addEventListener(`change`,e=>q(e.currentTarget.checked?[...K(),`post:${t.id}`]:K().filter(e=>e!==`post:${t.id}`))),c(i,()=>t.title,o,l),c(u,()=>t.slug,f,p),e(()=>h(r,`checked`,K().includes(`post:${t.id}`))),n})()})),t})(),(()=>{var e=s(j);return e.$$click=()=>ke(Pe().map(Ie)),c(e,()=>d(`menus.editor.addSelected`)),l(),e})()]}}),xe,Se),c(R,i(G,{get title(){return d(`menus.sources.contentTypes`)},get children(){return i(r,{get each(){return V().filter(e=>e.slug!==`page`&&e.slug!==`post`&&!e.singleton)},children:e=>(()=>{var t=s(M),n=t.firstChild,a=n.nextSibling,[o,u]=m(a.nextSibling);return c(n,()=>e.pluralLabel),c(t,i(r,{get each(){return z()[e.slug]??[]},children:t=>(()=>{var n=s(N),r=n.firstChild,[i,a]=m(r.nextSibling),o=i.nextSibling,u=o.firstChild.nextSibling,[d,f]=m(u.nextSibling),p=d.nextSibling.nextSibling,[h,g]=m(p.nextSibling);return n.$$click=()=>$(Le(t)),c(n,()=>t.title,i,a),c(o,()=>e.slug,d,f),c(o,()=>t.slug,h,g),l(),n})()}),o,u),t})()})}}),Te,X),c(R,i(G,{get title(){return d(`menus.sources.custom`)},get description(){return d(`menus.sources.customHint`)},get children(){return[(()=>{var t=s(re),n=t.firstChild,[r,i]=m(n.nextSibling),a=r.nextSibling;return c(t,()=>d(`menus.editor.url`),r,i),a.$$input=e=>ye(e.currentTarget.value),e(()=>h(a,`value`,J())),l(),t})(),(()=>{var t=s(ie),n=t.firstChild,[r,i]=m(n.nextSibling),a=r.nextSibling;return c(t,()=>d(`menus.editor.navigationLabel`),r,i),a.$$input=e=>be(e.currentTarget.value),e(()=>h(a,`value`,Y())),l(),t})(),(()=>{var e=s(j);return e.$$click=Ae,c(e,()=>d(`menus.editor.addToMenu`)),l(),e})()]}}),Z,De),c(R,i(G,{get title(){return d(`menus.sources.home`)},get children(){var e=s(j);return e.$$click=()=>$({id:`home`,type:`home`,label:d(`menus.sources.home`),url:`/`}),c(e,()=>d(`menus.editor.addToMenu`)),l(),e}}),Me,Re),c(R,i(G,{get title(){return d(`menus.sources.archives`)},get children(){var e=s(A);return c(e,i(r,{get each(){return V().filter(e=>e.hasArchive)},children:e=>(()=>{var t=s(ce),n=t.firstChild,[r,i]=m(n.nextSibling),a=r.nextSibling,o=a.firstChild.nextSibling,[u,d]=m(o.nextSibling);return t.$$click=()=>$({id:`archive:${e.slug}`,type:`archive`,label:e.pluralLabel,url:`/${e.slug}`,objectType:e.slug}),c(t,()=>e.pluralLabel,r,i),c(a,()=>e.slug,u,d),l(),t})()})),e}}),Be,Ve),c(R,i(G,{get title(){return d(`menus.sources.taxonomies`)},get children(){return i(r,{get each(){return U()},children:e=>(()=>{var t=s(M),n=t.firstChild,a=n.nextSibling,[o,u]=m(a.nextSibling);return c(n,()=>e.name),c(t,i(r,{get each(){return fe()[e.slug]??[]},children:t=>(()=>{var n=s(N),r=n.firstChild,[i,a]=m(r.nextSibling),o=i.nextSibling,u=o.firstChild.nextSibling,[d,f]=m(u.nextSibling),p=d.nextSibling.nextSibling,[h,g]=m(p.nextSibling);return n.$$click=()=>$({id:`term:${e.slug}:${t.slug}`,type:`taxonomy`,label:t.name,url:`/${e.slug}/${t.slug}`,objectId:t.id,objectType:e.slug}),c(n,()=>t.name,i,a),c(o,()=>e.slug,d,f),c(o,()=>t.slug,h,g),l(),n})()}),o,u),t})()})}}),Ue,We),c(Je,()=>d(`menus.editor.structure`)),c(Ye,()=>d(`menus.editor.structureHint`)),c(Xe,()=>n().items.length,Qe,$e),c(Xe,()=>d(`menus.items`),tt,nt),c(Ge,i(t,{get when(){return n().items.length>0},get fallback(){return(()=>{var e=s(le);return c(e,()=>d(`menus.editor.empty`)),e})()},get children(){return i(ve,{get items(){return n().items},t:d,onChange:e=>Q({items:e})})}}),it,at),c(ot,()=>d(`menus.editor.settings`)),ct.addEventListener(`change`,e=>Q({settings:{...n().settings,autoAddNewPages:e.currentTarget.checked}})),c(st,()=>d(`menus.editor.autoAddPages`),ut,dt),c(ft,()=>d(`menus.editor.autoAddPagesHint`)),e(e=>{var t=Ce(),r=F(n().name);return t!==e.e&&h(w,`disabled`,e.e=t),r!==e.t&&u(L,`placeholder`,e.t=r),e},{e:void 0,t:void 0}),e(()=>h(O,`value`,n().name)),e(()=>h(L,`value`,n().slug)),e(()=>h(ct,`checked`,n().settings.autoAddNewPages===!0)),l(),a})()})}}),P,I),n})()}f([`click`,`input`]);export{K as MenuManager};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,i as t,l as n,s as r,v as i}from"./solid.D49dPDCT.js";import{a,c as o,d as s,f as c,g as l,i as u,o as d}from"./web.Bqbl_1YR.js";import{n as f}from"./i18n.
|
|
1
|
+
import{d as e,i as t,l as n,s as r,v as i}from"./solid.D49dPDCT.js";import{a,c as o,d as s,f as c,g as l,i as u,o as d}from"./web.Bqbl_1YR.js";import{n as f}from"./i18n.vdBFsiPK.js";var p=l(`<div class=modal-overlay role=presentation><section class=modal role=dialog aria-modal=true><header class=modal-header><h3></h3><button type=button class=modal-close>×</button></header><!$><!/>`);function m(l){let{t:u}=f();return n(()=>{if(!l.open)return;let e=e=>{e.key===`Escape`&&l.onClose()};document.addEventListener(`keydown`,e),i(()=>document.removeEventListener(`keydown`,e))}),r(t,{get when(){return l.open},get children(){var t=a(p),n=t.firstChild,r=n.firstChild,i=r.firstChild,f=i.nextSibling,m=r.nextSibling,[h,g]=d(m.nextSibling);return t.$$mousedown=e=>{e.target===e.currentTarget&&l.onClose()},o(i,()=>l.title),f.$$click=()=>l.onClose(),o(n,()=>l.children,h,g),e(e=>{var t=l.title,r=u(`common.close`);return t!==e.e&&c(n,`aria-label`,e.e=t),r!==e.t&&c(f,`aria-label`,e.t=r),e},{e:void 0,t:void 0}),s(),t}})}u([`mousedown`,`click`]);export{m as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as e,p as t,r as n,s as r,y as i}from"./solid.D49dPDCT.js";import{a,c as o,d as s,f as c,g as l,i as u,l as d,o as f,p,r as m}from"./web.Bqbl_1YR.js";import{n as h}from"./i18n.
|
|
1
|
+
import{d as e,p as t,r as n,s as r,y as i}from"./solid.D49dPDCT.js";import{a,c as o,d as s,f as c,g as l,i as u,l as d,o as f,p,r as m}from"./web.Bqbl_1YR.js";import{n as h}from"./i18n.vdBFsiPK.js";import{n as g}from"./api.CYg1SW2X.js";var _=l(`<div class=plugin-manager><p class=page-hint></p><!$><!/><!$><!/><!$><!/><style>
|
|
2
2
|
.page-hint {
|
|
3
3
|
margin: 0 0 1.25rem;
|
|
4
4
|
color: var(--color-muted);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,i as t,l as n,p as r,r as i,s as a,u as o,v as s,y as c}from"./solid.D49dPDCT.js";import{_ as l,a as u,c as d,d as f,f as p,g as m,i as h,l as g,m as _,o as v,p as y}from"./web.Bqbl_1YR.js";import{n as b}from"./i18n.AbBpo2WD.js";import{n as x}from"./api.CYg1SW2X.js";import{t as S}from"./FloatingPanel.BeCEt_JP.js";import{t as C}from"./iconsAndAliases.ujTnkhnl.js";var w=m(`<input type=search class="input icon-picker__search">`),T=m(`<div class=icon-picker__viewport><div class=icon-picker__grid role=listbox>`),E=m(`<p class=icon-picker__count>`),D=m(`<div class=icon-picker><button type=button class="input icon-picker__trigger"aria-haspopup=dialog><span class=icon-picker__value><span class=icon-picker__preview aria-hidden=true></span><span class=icon-picker__name></span></span><span class=icon-picker__caret aria-hidden=true></span></button><!$><!/>`),O=m(`<p class=icon-picker__empty>`),k=m(`<button type=button role=option class=icon-picker__cell style=height:56px>`),A=56,j=60,M=300,ee=2,N=Math.ceil(M/j)+4,P=e=>e.replace(/(^|[-_])(\w)/g,(e,t,n)=>n.toUpperCase()),F=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).replace(/([A-Z])([A-Z][a-z])/g,`$1-$2`).toLowerCase(),I=`xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"`,L=e=>Object.entries(e).map(([e,t])=>`${e}="${String(t).replace(/"/g,`"`)}"`).join(` `),R=null,z=()=>(R||=[...new Set(Object.keys(C).map(F))].sort(),R),B=new Map;function te(e){let t=B.get(e);if(t!==void 0)return t;let n=C[P(e)],r=``;return Array.isArray(n)&&(r=`<svg ${I}>${n.map(([e,t])=>`<${e} ${L(t)} />`).join(``)}</svg>`),B.set(e,r),r}var V=e=>e.toLowerCase().replace(/[-_\s]+/g,` `).trim();function H(m){let[h,b]=r(!1),[x,C]=r(``),[P,F]=r(-1),[I,L]=r(0),[R,B]=r(6),[H,ne]=r(void 0),[re,ie]=r(void 0),U,W,ae,G,K=o(()=>{let e=V(x()).split(` `).filter(Boolean),t=z();return e.length===0?t:t.filter(t=>{let n=V(t);return e.every(e=>n.includes(e))})}),q=o(()=>{let e=Math.max(1,R());return K().map((t,n)=>({name:t,index:n,row:Math.floor(n/e),col:n%e}))}),oe=o(()=>Math.max(0,Math.floor(I()/j)-ee)*R()),J=o(()=>{let e=oe();return q().slice(e,e+N*R())}),Y=o(()=>Math.ceil(q().length/Math.max(1,R()))),X=e=>{let t=e?.clientWidth??0;if(t<=0)return;let n=Math.max(3,Math.floor(t/A));B(e=>e===n?e:n)},Z=(e,t=`nearest`)=>{let n=W;if(!n||e<0)return;let r=Math.max(1,R()),i=Math.floor(e/r)*j,a=i+j,o=n.scrollTop;t===`center`?o=i-M/2+j/2:i<n.scrollTop?o=i:a>n.scrollTop+M&&(o=a-M);let s=Math.max(0,Y()*j-M);o=Math.min(Math.max(0,o),s),n.scrollTop=o,L(o)},se=e=>{m.onChange(e),b(!1),C(``)},Q=e=>{let t=K();if(t.length===0)return;let n=P(),r=n<0?e>0?-1:t.length:n,i=Math.min(Math.max(0,r+e),t.length-1);F(i),Z(i)},$=e=>{let t=Math.max(1,R());switch(e.key){case`ArrowDown`:e.preventDefault(),Q(t);break;case`ArrowUp`:e.preventDefault(),Q(-t);break;case`ArrowRight`:e.preventDefault(),Q(1);break;case`ArrowLeft`:e.preventDefault(),Q(-1);break;case`Home`:e.preventDefault(),F(0),Z(0);break;case`End`:e.preventDefault(),F(K().length-1),Z(K().length-1);break;case`Enter`:{e.preventDefault();let t=K()[P()];t&&se(t);break}}};return c(()=>{typeof ResizeObserver<`u`&&(G=new ResizeObserver(e=>{X(e[0]?.target)})),X(H()),s(()=>G?.disconnect())}),n(()=>{let e=H();e&&(X(e),G?.observe(e))}),n(()=>{h()&&(F(-1),queueMicrotask(()=>{let e=K().indexOf(m.value);e>=0&&Z(e,`center`),ae?.focus()}))}),n(()=>{x(),F(-1),W&&(W.scrollTop=0),L(0)}),(()=>{var n=u(D),r=n.firstChild,o=r.firstChild,s=o.firstChild,c=s.nextSibling,A=o.nextSibling,M=r.nextSibling,[ee,N]=v(M.nextSibling),F=U;return typeof F==`function`?l(F,n):U=n,r.$$click=()=>b(!h()),l(ie,r),d(c,()=>m.value||`box`),d(A,()=>h()?`▴`:`▾`),d(n,a(S,{get open(){return h()},get trigger(){return re()},onClose:()=>b(!1),class:`icon-picker__panel`,role:`dialog`,get"aria-label"(){return m.label},minWidth:360,onKeyDown:$,get children(){return[(()=>{var t=u(w);return l(e=>ae=e,t),t.$$input=e=>C(e.currentTarget.value),e(()=>p(t,`placeholder`,m.searchPlaceholder)),e(()=>y(t,`value`,x())),f(),t})(),a(t,{get when(){return K().length>0},get fallback(){return(()=>{var e=u(O);return d(e,()=>m.emptyLabel??`—`),e})()},get children(){var t=u(T),n=t.firstChild;return t.addEventListener(`scroll`,e=>L(e.currentTarget.scrollTop)),l(e=>W=e,t),l(ne,n),d(n,a(i,{get each(){return J()},children:t=>(()=>{var n=u(k);return n.$$click=()=>se(t.name),e(e=>{var r=t.name,i=t.name,a=m.value===t.name,o=m.value===t.name,s=P()===t.index,c=`${t.row*j}px`,l=`${t.col*(100/Math.max(1,R()))}%`,u=`${100/Math.max(1,R())}%`,d=te(t.name);return r!==e.e&&p(n,`title`,e.e=r),i!==e.t&&p(n,`aria-label`,e.t=i),a!==e.a&&p(n,`aria-selected`,e.a=a),o!==e.o&&n.classList.toggle(`is-selected`,e.o=o),s!==e.i&&n.classList.toggle(`is-active`,e.i=s),c!==e.n&&_(n,`top`,e.n=c),l!==e.s&&_(n,`left`,e.s=l),u!==e.h&&_(n,`width`,e.h=u),d!==e.r&&y(n,`innerHTML`,e.r=d),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0}),f(),n})()})),e(e=>{var t=m.label,r=`${Y()*j}px`;return t!==e.e&&p(n,`aria-label`,e.e=t),r!==e.t&&_(n,`height`,e.t=r),e},{e:void 0,t:void 0}),t}}),a(t,{get when(){return g(()=>!!m.countLabel)()&&K().length>0},get children(){var e=u(E);return d(e,()=>m.countLabel?.(K().length)),e}})]}}),ee,N),e(e=>{var t=h(),n=te(m.value||`box`);return t!==e.e&&p(r,`aria-expanded`,e.e=t),n!==e.t&&y(s,`innerHTML`,e.t=n),e},{e:void 0,t:void 0}),f(),n})()}h([`click`,`input`]);var ne=m(`<div class="notice notice--error">`),re=m(`<button type=button class="btn btn-secondary">`),ie=m(`<div class=post-types-manager><!$><!/><form class=card><h3></h3><div class=form-grid><label><!$><!/><input class=input required pattern=[a-z0-9_]+></label><label><!$><!/><input class=input required></label><label><!$><!/><input class=input required></label><label class=post-types-manager__icon-field><!$><!/><!$><!/><small class=muted></small></label></div><fieldset class=supports><legend></legend><!$><!/><label><input type=checkbox> <!$><!/></label><label><input type=checkbox> <!$><!/></label></fieldset><button type=submit class="btn btn-primary"></button><!$><!/></form><div class="card settings-table-card"><table class=table><thead><tr><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th></tr></thead><tbody>`),U=m(`<label><input type=checkbox> <!$><!/>`),W=m(`<button type=button class="btn btn-danger">`),ae=m(`<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td><span class=post-types-manager__icon><span class=post-types-manager__icon-preview aria-hidden=true></span><!$><!/></span></td><td><button type=button class="btn btn-secondary"></button> <!$><!/>`);function G(){let{t:n}=b(),[s,l]=r([]),[m,h]=r(``),[_,S]=r(!1),[C,w]=r(null),T=o(()=>[{value:`title`,label:n(`settings.postTypes.form.supportsOptions.title`)},{value:`editor`,label:n(`settings.postTypes.form.supportsOptions.editor`)},{value:`thumbnail`,label:n(`settings.postTypes.form.supportsOptions.thumbnail`)},{value:`excerpt`,label:n(`settings.postTypes.form.supportsOptions.excerpt`)},{value:`revisions`,label:n(`settings.postTypes.form.supportsOptions.revisions`)}]),[E,D]=r({name:``,slug:``,singularLabel:``,pluralLabel:``,hasArchive:!1,singleton:!1,menuIcon:`box`,supports:[`title`,`editor`]}),O=()=>{w(null),D({name:``,slug:``,singularLabel:``,pluralLabel:``,hasArchive:!1,singleton:!1,menuIcon:`box`,supports:[`title`,`editor`]})},k=async()=>{try{l(await x.getContentTypes())}catch(e){h(e instanceof Error?e.message:String(e))}};c(k);let A=async e=>{e.preventDefault(),h(``),S(!0);try{let e={name:E().name||E().slug,slug:E().slug,singularLabel:E().singularLabel,pluralLabel:E().pluralLabel,hasArchive:E().hasArchive,singleton:E().singleton,menuIcon:E().menuIcon||`box`,supports:E().supports};C()?await x.updateContentType(C(),e):await x.createContentType(e),O(),await k(),window.dispatchEvent(new Event(`okcms:content-models-changed`))}catch(e){h(e instanceof Error?e.message:String(e))}finally{S(!1)}},j=e=>{w(e.slug),D({name:e.name,slug:e.slug,singularLabel:e.singularLabel,pluralLabel:e.pluralLabel,hasArchive:e.hasArchive??!1,singleton:e.singleton??!1,menuIcon:e.menuIcon??`box`,supports:[...e.supports??[`title`,`editor`]]})},M=async e=>{try{await x.deleteContentType(e),await k(),window.dispatchEvent(new Event(`okcms:content-models-changed`))}catch(e){h(e instanceof Error?e.message:String(e))}};return(()=>{var r=u(ie),o=r.firstChild,[c,l]=v(o.nextSibling),h=c.nextSibling,b=h.firstChild,x=b.nextSibling,S=x.firstChild,w=S.firstChild,[k,ee]=v(w.nextSibling),N=k.nextSibling,P=S.nextSibling,F=P.firstChild,[I,L]=v(F.nextSibling),R=I.nextSibling,z=P.nextSibling,B=z.firstChild,[V,G]=v(B.nextSibling),K=V.nextSibling,q=z.nextSibling,oe=q.firstChild,[J,Y]=v(oe.nextSibling),X=J.nextSibling,[Z,se]=v(X.nextSibling),Q=Z.nextSibling,$=x.nextSibling,ce=$.firstChild,le=ce.nextSibling,[ue,de]=v(le.nextSibling),fe=ue.nextSibling,pe=fe.firstChild,me=pe.nextSibling.nextSibling,[he,ge]=v(me.nextSibling),_e=fe.nextSibling,ve=_e.firstChild,ye=ve.nextSibling.nextSibling,[be,xe]=v(ye.nextSibling),Se=$.nextSibling,Ce=Se.nextSibling,[we,Te]=v(Ce.nextSibling),Ee=h.nextSibling.firstChild.firstChild,De=Ee.firstChild.firstChild,Oe=De.nextSibling,ke=Oe.nextSibling,Ae=ke.nextSibling,je=Ae.nextSibling,Me=je.nextSibling,Ne=Me.nextSibling,Pe=Ne.nextSibling,Fe=Ee.nextSibling;return d(r,a(t,{get when(){return m()},get children(){var e=u(ne);return d(e,m),e}}),c,l),h.addEventListener(`submit`,A),d(b,(()=>{var e=g(()=>!!C());return()=>e()?n(`settings.postTypes.form.editTitle`):n(`settings.postTypes.form.title`)})()),d(S,()=>n(`settings.postTypes.form.slug`),k,ee),N.$$input=e=>D({...E(),slug:e.currentTarget.value}),d(P,()=>n(`settings.postTypes.form.singular`),I,L),R.$$input=e=>D({...E(),singularLabel:e.currentTarget.value}),d(z,()=>n(`settings.postTypes.form.plural`),V,G),K.$$input=e=>D({...E(),pluralLabel:e.currentTarget.value}),d(q,()=>n(`settings.postTypes.form.icon`),J,Y),d(q,a(H,{get value(){return E().menuIcon},onChange:e=>D({...E(),menuIcon:e}),get searchPlaceholder(){return n(`settings.postTypes.form.iconSearchPlaceholder`)},get emptyLabel(){return n(`settings.postTypes.form.iconEmpty`)},countLabel:e=>n(`settings.postTypes.form.iconCount`,{count:e}),get label(){return n(`settings.postTypes.form.icon`)}}),Z,se),d(Q,()=>n(`settings.postTypes.form.iconHint`)),d(ce,()=>n(`settings.postTypes.form.supports`)),d($,a(i,{get each(){return T()},children:t=>(()=>{var n=u(U),r=n.firstChild,i=r.nextSibling.nextSibling,[a,o]=v(i.nextSibling);return r.addEventListener(`change`,e=>D({...E(),supports:e.currentTarget.checked?[...E().supports,t.value]:E().supports.filter(e=>e!==t.value)})),d(n,()=>t.label,a,o),e(()=>y(r,`checked`,E().supports.includes(t.value))),n})()}),ue,de),pe.addEventListener(`change`,e=>D({...E(),hasArchive:e.currentTarget.checked})),d(fe,()=>n(`settings.postTypes.form.hasArchive`),he,ge),ve.addEventListener(`change`,e=>D({...E(),singleton:e.currentTarget.checked})),d(_e,()=>n(`settings.postTypes.form.singleton`),be,xe),d(Se,(()=>{var e=g(()=>!!C());return()=>e()?n(`settings.postTypes.form.update`):n(`settings.postTypes.form.create`)})()),d(h,a(t,{get when(){return C()},get children(){var e=u(re);return e.$$click=O,d(e,()=>n(`settings.postTypes.form.cancel`)),f(),e}}),we,Te),d(De,()=>n(`settings.postTypes.table.slug`)),d(Oe,()=>n(`settings.postTypes.table.singular`)),d(ke,()=>n(`settings.postTypes.table.plural`)),d(Ae,()=>n(`settings.postTypes.table.source`)),d(je,()=>n(`settings.postTypes.table.supports`)),d(Me,()=>n(`settings.postTypes.table.archive`)),d(Ne,()=>n(`settings.postTypes.table.mode`)),d(Pe,()=>n(`settings.postTypes.table.icon`)),d(Fe,a(i,{get each(){return s()},children:r=>(()=>{var i=u(ae),o=i.firstChild,s=o.nextSibling,c=s.nextSibling,l=c.nextSibling,p=l.nextSibling,m=p.nextSibling,h=m.nextSibling,_=h.nextSibling,b=_.firstChild,x=b.firstChild,S=x.nextSibling,[C,w]=v(S.nextSibling),T=_.nextSibling,E=T.firstChild,D=E.nextSibling.nextSibling,[O,k]=v(D.nextSibling);return d(o,()=>r.slug),d(s,()=>r.singularLabel),d(c,()=>r.pluralLabel),d(l,()=>r.source??n(`settings.postTypes.sources.admin`)),d(p,()=>(r.supports??[]).join(`, `)),d(m,(()=>{var e=g(()=>!!r.hasArchive);return()=>e()?n(`common.yes`):n(`common.no`)})()),d(h,(()=>{var e=g(()=>!!r.singleton);return()=>e()?n(`settings.postTypes.table.singleton`):n(`settings.postTypes.table.collection`)})()),d(b,()=>r.menuIcon??`box`,C,w),E.$$click=()=>j(r),d(E,()=>n(`settings.postTypes.table.actions.edit`)),d(T,a(t,{get when(){return r.source!==`CORE`},get children(){var e=u(W);return e.$$click=()=>M(r.slug),d(e,()=>n(`settings.postTypes.table.actions.remove`)),f(),e}}),O,k),e(()=>y(x,`innerHTML`,te(r.menuIcon??`box`))),f(),i})()})),e(e=>{var t=n(`settings.postTypes.form.slugHint`),r=_();return t!==e.e&&p(N,`title`,e.e=t),r!==e.t&&y(Se,`disabled`,e.t=r),e},{e:void 0,t:void 0}),e(()=>y(N,`value`,E().slug)),e(()=>y(R,`value`,E().singularLabel)),e(()=>y(K,`value`,E().pluralLabel)),e(()=>y(pe,`checked`,E().hasArchive)),e(()=>y(ve,`checked`,E().singleton)),f(),r})()}h([`input`,`click`]);export{G as PostTypesManager};
|
|
1
|
+
import{d as e,i as t,l as n,p as r,r as i,s as a,u as o,v as s,y as c}from"./solid.D49dPDCT.js";import{_ as l,a as u,c as d,d as f,f as p,g as m,i as h,l as g,m as _,o as v,p as y}from"./web.Bqbl_1YR.js";import{n as b}from"./i18n.vdBFsiPK.js";import{n as x}from"./api.CYg1SW2X.js";import{t as S}from"./FloatingPanel.BeCEt_JP.js";import{t as C}from"./iconsAndAliases.ujTnkhnl.js";var w=m(`<input type=search class="input icon-picker__search">`),T=m(`<div class=icon-picker__viewport><div class=icon-picker__grid role=listbox>`),E=m(`<p class=icon-picker__count>`),D=m(`<div class=icon-picker><button type=button class="input icon-picker__trigger"aria-haspopup=dialog><span class=icon-picker__value><span class=icon-picker__preview aria-hidden=true></span><span class=icon-picker__name></span></span><span class=icon-picker__caret aria-hidden=true></span></button><!$><!/>`),O=m(`<p class=icon-picker__empty>`),k=m(`<button type=button role=option class=icon-picker__cell style=height:56px>`),A=56,j=60,M=300,ee=2,N=Math.ceil(M/j)+4,P=e=>e.replace(/(^|[-_])(\w)/g,(e,t,n)=>n.toUpperCase()),F=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).replace(/([A-Z])([A-Z][a-z])/g,`$1-$2`).toLowerCase(),I=`xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"`,L=e=>Object.entries(e).map(([e,t])=>`${e}="${String(t).replace(/"/g,`"`)}"`).join(` `),R=null,z=()=>(R||=[...new Set(Object.keys(C).map(F))].sort(),R),B=new Map;function te(e){let t=B.get(e);if(t!==void 0)return t;let n=C[P(e)],r=``;return Array.isArray(n)&&(r=`<svg ${I}>${n.map(([e,t])=>`<${e} ${L(t)} />`).join(``)}</svg>`),B.set(e,r),r}var V=e=>e.toLowerCase().replace(/[-_\s]+/g,` `).trim();function H(m){let[h,b]=r(!1),[x,C]=r(``),[P,F]=r(-1),[I,L]=r(0),[R,B]=r(6),[H,ne]=r(void 0),[re,ie]=r(void 0),U,W,ae,G,K=o(()=>{let e=V(x()).split(` `).filter(Boolean),t=z();return e.length===0?t:t.filter(t=>{let n=V(t);return e.every(e=>n.includes(e))})}),q=o(()=>{let e=Math.max(1,R());return K().map((t,n)=>({name:t,index:n,row:Math.floor(n/e),col:n%e}))}),oe=o(()=>Math.max(0,Math.floor(I()/j)-ee)*R()),J=o(()=>{let e=oe();return q().slice(e,e+N*R())}),Y=o(()=>Math.ceil(q().length/Math.max(1,R()))),X=e=>{let t=e?.clientWidth??0;if(t<=0)return;let n=Math.max(3,Math.floor(t/A));B(e=>e===n?e:n)},Z=(e,t=`nearest`)=>{let n=W;if(!n||e<0)return;let r=Math.max(1,R()),i=Math.floor(e/r)*j,a=i+j,o=n.scrollTop;t===`center`?o=i-M/2+j/2:i<n.scrollTop?o=i:a>n.scrollTop+M&&(o=a-M);let s=Math.max(0,Y()*j-M);o=Math.min(Math.max(0,o),s),n.scrollTop=o,L(o)},se=e=>{m.onChange(e),b(!1),C(``)},Q=e=>{let t=K();if(t.length===0)return;let n=P(),r=n<0?e>0?-1:t.length:n,i=Math.min(Math.max(0,r+e),t.length-1);F(i),Z(i)},$=e=>{let t=Math.max(1,R());switch(e.key){case`ArrowDown`:e.preventDefault(),Q(t);break;case`ArrowUp`:e.preventDefault(),Q(-t);break;case`ArrowRight`:e.preventDefault(),Q(1);break;case`ArrowLeft`:e.preventDefault(),Q(-1);break;case`Home`:e.preventDefault(),F(0),Z(0);break;case`End`:e.preventDefault(),F(K().length-1),Z(K().length-1);break;case`Enter`:{e.preventDefault();let t=K()[P()];t&&se(t);break}}};return c(()=>{typeof ResizeObserver<`u`&&(G=new ResizeObserver(e=>{X(e[0]?.target)})),X(H()),s(()=>G?.disconnect())}),n(()=>{let e=H();e&&(X(e),G?.observe(e))}),n(()=>{h()&&(F(-1),queueMicrotask(()=>{let e=K().indexOf(m.value);e>=0&&Z(e,`center`),ae?.focus()}))}),n(()=>{x(),F(-1),W&&(W.scrollTop=0),L(0)}),(()=>{var n=u(D),r=n.firstChild,o=r.firstChild,s=o.firstChild,c=s.nextSibling,A=o.nextSibling,M=r.nextSibling,[ee,N]=v(M.nextSibling),F=U;return typeof F==`function`?l(F,n):U=n,r.$$click=()=>b(!h()),l(ie,r),d(c,()=>m.value||`box`),d(A,()=>h()?`▴`:`▾`),d(n,a(S,{get open(){return h()},get trigger(){return re()},onClose:()=>b(!1),class:`icon-picker__panel`,role:`dialog`,get"aria-label"(){return m.label},minWidth:360,onKeyDown:$,get children(){return[(()=>{var t=u(w);return l(e=>ae=e,t),t.$$input=e=>C(e.currentTarget.value),e(()=>p(t,`placeholder`,m.searchPlaceholder)),e(()=>y(t,`value`,x())),f(),t})(),a(t,{get when(){return K().length>0},get fallback(){return(()=>{var e=u(O);return d(e,()=>m.emptyLabel??`—`),e})()},get children(){var t=u(T),n=t.firstChild;return t.addEventListener(`scroll`,e=>L(e.currentTarget.scrollTop)),l(e=>W=e,t),l(ne,n),d(n,a(i,{get each(){return J()},children:t=>(()=>{var n=u(k);return n.$$click=()=>se(t.name),e(e=>{var r=t.name,i=t.name,a=m.value===t.name,o=m.value===t.name,s=P()===t.index,c=`${t.row*j}px`,l=`${t.col*(100/Math.max(1,R()))}%`,u=`${100/Math.max(1,R())}%`,d=te(t.name);return r!==e.e&&p(n,`title`,e.e=r),i!==e.t&&p(n,`aria-label`,e.t=i),a!==e.a&&p(n,`aria-selected`,e.a=a),o!==e.o&&n.classList.toggle(`is-selected`,e.o=o),s!==e.i&&n.classList.toggle(`is-active`,e.i=s),c!==e.n&&_(n,`top`,e.n=c),l!==e.s&&_(n,`left`,e.s=l),u!==e.h&&_(n,`width`,e.h=u),d!==e.r&&y(n,`innerHTML`,e.r=d),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0}),f(),n})()})),e(e=>{var t=m.label,r=`${Y()*j}px`;return t!==e.e&&p(n,`aria-label`,e.e=t),r!==e.t&&_(n,`height`,e.t=r),e},{e:void 0,t:void 0}),t}}),a(t,{get when(){return g(()=>!!m.countLabel)()&&K().length>0},get children(){var e=u(E);return d(e,()=>m.countLabel?.(K().length)),e}})]}}),ee,N),e(e=>{var t=h(),n=te(m.value||`box`);return t!==e.e&&p(r,`aria-expanded`,e.e=t),n!==e.t&&y(s,`innerHTML`,e.t=n),e},{e:void 0,t:void 0}),f(),n})()}h([`click`,`input`]);var ne=m(`<div class="notice notice--error">`),re=m(`<button type=button class="btn btn-secondary">`),ie=m(`<div class=post-types-manager><!$><!/><form class=card><h3></h3><div class=form-grid><label><!$><!/><input class=input required pattern=[a-z0-9_]+></label><label><!$><!/><input class=input required></label><label><!$><!/><input class=input required></label><label class=post-types-manager__icon-field><!$><!/><!$><!/><small class=muted></small></label></div><fieldset class=supports><legend></legend><!$><!/><label><input type=checkbox> <!$><!/></label><label><input type=checkbox> <!$><!/></label></fieldset><button type=submit class="btn btn-primary"></button><!$><!/></form><div class="card settings-table-card"><table class=table><thead><tr><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th></tr></thead><tbody>`),U=m(`<label><input type=checkbox> <!$><!/>`),W=m(`<button type=button class="btn btn-danger">`),ae=m(`<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td><span class=post-types-manager__icon><span class=post-types-manager__icon-preview aria-hidden=true></span><!$><!/></span></td><td><button type=button class="btn btn-secondary"></button> <!$><!/>`);function G(){let{t:n}=b(),[s,l]=r([]),[m,h]=r(``),[_,S]=r(!1),[C,w]=r(null),T=o(()=>[{value:`title`,label:n(`settings.postTypes.form.supportsOptions.title`)},{value:`editor`,label:n(`settings.postTypes.form.supportsOptions.editor`)},{value:`thumbnail`,label:n(`settings.postTypes.form.supportsOptions.thumbnail`)},{value:`excerpt`,label:n(`settings.postTypes.form.supportsOptions.excerpt`)},{value:`revisions`,label:n(`settings.postTypes.form.supportsOptions.revisions`)}]),[E,D]=r({name:``,slug:``,singularLabel:``,pluralLabel:``,hasArchive:!1,singleton:!1,menuIcon:`box`,supports:[`title`,`editor`]}),O=()=>{w(null),D({name:``,slug:``,singularLabel:``,pluralLabel:``,hasArchive:!1,singleton:!1,menuIcon:`box`,supports:[`title`,`editor`]})},k=async()=>{try{l(await x.getContentTypes())}catch(e){h(e instanceof Error?e.message:String(e))}};c(k);let A=async e=>{e.preventDefault(),h(``),S(!0);try{let e={name:E().name||E().slug,slug:E().slug,singularLabel:E().singularLabel,pluralLabel:E().pluralLabel,hasArchive:E().hasArchive,singleton:E().singleton,menuIcon:E().menuIcon||`box`,supports:E().supports};C()?await x.updateContentType(C(),e):await x.createContentType(e),O(),await k(),window.dispatchEvent(new Event(`okcms:content-models-changed`))}catch(e){h(e instanceof Error?e.message:String(e))}finally{S(!1)}},j=e=>{w(e.slug),D({name:e.name,slug:e.slug,singularLabel:e.singularLabel,pluralLabel:e.pluralLabel,hasArchive:e.hasArchive??!1,singleton:e.singleton??!1,menuIcon:e.menuIcon??`box`,supports:[...e.supports??[`title`,`editor`]]})},M=async e=>{try{await x.deleteContentType(e),await k(),window.dispatchEvent(new Event(`okcms:content-models-changed`))}catch(e){h(e instanceof Error?e.message:String(e))}};return(()=>{var r=u(ie),o=r.firstChild,[c,l]=v(o.nextSibling),h=c.nextSibling,b=h.firstChild,x=b.nextSibling,S=x.firstChild,w=S.firstChild,[k,ee]=v(w.nextSibling),N=k.nextSibling,P=S.nextSibling,F=P.firstChild,[I,L]=v(F.nextSibling),R=I.nextSibling,z=P.nextSibling,B=z.firstChild,[V,G]=v(B.nextSibling),K=V.nextSibling,q=z.nextSibling,oe=q.firstChild,[J,Y]=v(oe.nextSibling),X=J.nextSibling,[Z,se]=v(X.nextSibling),Q=Z.nextSibling,$=x.nextSibling,ce=$.firstChild,le=ce.nextSibling,[ue,de]=v(le.nextSibling),fe=ue.nextSibling,pe=fe.firstChild,me=pe.nextSibling.nextSibling,[he,ge]=v(me.nextSibling),_e=fe.nextSibling,ve=_e.firstChild,ye=ve.nextSibling.nextSibling,[be,xe]=v(ye.nextSibling),Se=$.nextSibling,Ce=Se.nextSibling,[we,Te]=v(Ce.nextSibling),Ee=h.nextSibling.firstChild.firstChild,De=Ee.firstChild.firstChild,Oe=De.nextSibling,ke=Oe.nextSibling,Ae=ke.nextSibling,je=Ae.nextSibling,Me=je.nextSibling,Ne=Me.nextSibling,Pe=Ne.nextSibling,Fe=Ee.nextSibling;return d(r,a(t,{get when(){return m()},get children(){var e=u(ne);return d(e,m),e}}),c,l),h.addEventListener(`submit`,A),d(b,(()=>{var e=g(()=>!!C());return()=>e()?n(`settings.postTypes.form.editTitle`):n(`settings.postTypes.form.title`)})()),d(S,()=>n(`settings.postTypes.form.slug`),k,ee),N.$$input=e=>D({...E(),slug:e.currentTarget.value}),d(P,()=>n(`settings.postTypes.form.singular`),I,L),R.$$input=e=>D({...E(),singularLabel:e.currentTarget.value}),d(z,()=>n(`settings.postTypes.form.plural`),V,G),K.$$input=e=>D({...E(),pluralLabel:e.currentTarget.value}),d(q,()=>n(`settings.postTypes.form.icon`),J,Y),d(q,a(H,{get value(){return E().menuIcon},onChange:e=>D({...E(),menuIcon:e}),get searchPlaceholder(){return n(`settings.postTypes.form.iconSearchPlaceholder`)},get emptyLabel(){return n(`settings.postTypes.form.iconEmpty`)},countLabel:e=>n(`settings.postTypes.form.iconCount`,{count:e}),get label(){return n(`settings.postTypes.form.icon`)}}),Z,se),d(Q,()=>n(`settings.postTypes.form.iconHint`)),d(ce,()=>n(`settings.postTypes.form.supports`)),d($,a(i,{get each(){return T()},children:t=>(()=>{var n=u(U),r=n.firstChild,i=r.nextSibling.nextSibling,[a,o]=v(i.nextSibling);return r.addEventListener(`change`,e=>D({...E(),supports:e.currentTarget.checked?[...E().supports,t.value]:E().supports.filter(e=>e!==t.value)})),d(n,()=>t.label,a,o),e(()=>y(r,`checked`,E().supports.includes(t.value))),n})()}),ue,de),pe.addEventListener(`change`,e=>D({...E(),hasArchive:e.currentTarget.checked})),d(fe,()=>n(`settings.postTypes.form.hasArchive`),he,ge),ve.addEventListener(`change`,e=>D({...E(),singleton:e.currentTarget.checked})),d(_e,()=>n(`settings.postTypes.form.singleton`),be,xe),d(Se,(()=>{var e=g(()=>!!C());return()=>e()?n(`settings.postTypes.form.update`):n(`settings.postTypes.form.create`)})()),d(h,a(t,{get when(){return C()},get children(){var e=u(re);return e.$$click=O,d(e,()=>n(`settings.postTypes.form.cancel`)),f(),e}}),we,Te),d(De,()=>n(`settings.postTypes.table.slug`)),d(Oe,()=>n(`settings.postTypes.table.singular`)),d(ke,()=>n(`settings.postTypes.table.plural`)),d(Ae,()=>n(`settings.postTypes.table.source`)),d(je,()=>n(`settings.postTypes.table.supports`)),d(Me,()=>n(`settings.postTypes.table.archive`)),d(Ne,()=>n(`settings.postTypes.table.mode`)),d(Pe,()=>n(`settings.postTypes.table.icon`)),d(Fe,a(i,{get each(){return s()},children:r=>(()=>{var i=u(ae),o=i.firstChild,s=o.nextSibling,c=s.nextSibling,l=c.nextSibling,p=l.nextSibling,m=p.nextSibling,h=m.nextSibling,_=h.nextSibling,b=_.firstChild,x=b.firstChild,S=x.nextSibling,[C,w]=v(S.nextSibling),T=_.nextSibling,E=T.firstChild,D=E.nextSibling.nextSibling,[O,k]=v(D.nextSibling);return d(o,()=>r.slug),d(s,()=>r.singularLabel),d(c,()=>r.pluralLabel),d(l,()=>r.source??n(`settings.postTypes.sources.admin`)),d(p,()=>(r.supports??[]).join(`, `)),d(m,(()=>{var e=g(()=>!!r.hasArchive);return()=>e()?n(`common.yes`):n(`common.no`)})()),d(h,(()=>{var e=g(()=>!!r.singleton);return()=>e()?n(`settings.postTypes.table.singleton`):n(`settings.postTypes.table.collection`)})()),d(b,()=>r.menuIcon??`box`,C,w),E.$$click=()=>j(r),d(E,()=>n(`settings.postTypes.table.actions.edit`)),d(T,a(t,{get when(){return r.source!==`CORE`},get children(){var e=u(W);return e.$$click=()=>M(r.slug),d(e,()=>n(`settings.postTypes.table.actions.remove`)),f(),e}}),O,k),e(()=>y(x,`innerHTML`,te(r.menuIcon??`box`))),f(),i})()})),e(e=>{var t=n(`settings.postTypes.form.slugHint`),r=_();return t!==e.e&&p(N,`title`,e.e=t),r!==e.t&&y(Se,`disabled`,e.t=r),e},{e:void 0,t:void 0}),e(()=>y(N,`value`,E().slug)),e(()=>y(R,`value`,E().singularLabel)),e(()=>y(K,`value`,E().pluralLabel)),e(()=>y(pe,`checked`,E().hasArchive)),e(()=>y(ve,`checked`,E().singleton)),f(),r})()}h([`input`,`click`]);export{G as PostTypesManager};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as e,p as t,r as n,s as r,y as i}from"./solid.D49dPDCT.js";import{a,c as o,d as s,f as c,g as l,i as u,l as d,o as f,p}from"./web.Bqbl_1YR.js";import{n as m}from"./i18n.
|
|
1
|
+
import{d as e,p as t,r as n,s as r,y as i}from"./solid.D49dPDCT.js";import{a,c as o,d as s,f as c,g as l,i as u,l as d,o as f,p}from"./web.Bqbl_1YR.js";import{n as m}from"./i18n.vdBFsiPK.js";import{n as h}from"./api.CYg1SW2X.js";import{DashboardWidget as g}from"./AtGlanceWidget.DPkp-rxl.js";var _=l(`<div class=quick-draft-wrapper><div class=quick-draft-content-wrapper>`),v=l(`<style>
|
|
2
2
|
.quick-draft-form { display: flex; flex-direction: column; gap: 1rem; }
|
|
3
3
|
.form-group textarea { min-height: 100px; resize: vertical; font-family: inherit; }
|
|
4
4
|
.drafts-list h4 { margin-bottom: 1rem; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,i as t,p as n,r,s as i,u as a,y as o}from"./solid.D49dPDCT.js";import{_ as s,a as c,c as l,d as u,f as d,g as f,i as p,l as m,o as h,p as g}from"./web.Bqbl_1YR.js";import{n as _}from"./i18n.AbBpo2WD.js";import{n as v}from"./api.CYg1SW2X.js";import{t as y}from"./Modal.DR905gyF.js";import{t as b}from"./FloatingPanel.BeCEt_JP.js";var x=f(`<input type=search class="input permission-picker__search">`),S=f(`<div class=permission-picker__matrix role=presentation><div class="permission-picker__row permission-picker__row--head"role=presentation><span class=permission-picker__resource></span><!$><!/><!$><!/></div><!$><!/>`),C=f(`<div class=permission-picker__custom><p class=permission-picker__custom-label></p><div class=permission-picker__chips><!$><!/><form class=permission-picker__custom-form><input class="input permission-picker__custom-input"><button class="btn btn-secondary btn-sm"type=submit>`),w=f(`<p class=icon-picker__count>`),T=f(`<div class=permission-picker><button type=button class="input permission-picker__trigger"aria-haspopup=dialog><span class=permission-picker__value></span><span class=icon-picker__caret aria-hidden=true></span></button><!$><!/>`),E=f(`<span class=permission-picker__action-label>`),D=f(`<p class=permission-picker__empty>`),O=f(`<div class=permission-picker__row><span class=permission-picker__resource></span><!$><!/>`),k=f(`<label class=permission-picker__cell><input type=checkbox><span aria-hidden=true>✓`),A=f(`<span class="permission-picker__cell permission-picker__cell--empty">`),ee=f(`<span class=permission-picker__chip><code></code><button type=button>×`),j=[`read`,`create`,`update`,`delete`],M=[`content`,`media`,`category`,`tag`,`menu`,`user`,`roles`,`theme`,`plugin`,`setting`,`webhook`,`tenants`,`audit`,`build`,`system`],N={media:[`upload`]},P=(e,t)=>`${e}:${t}`,F=e=>{let[t,n]=e.split(`:`);return!t||!n?!1:j.includes(t)&&M.includes(n)};function I(o){let{t:f}=_(),[p,m]=n(!1),[v,y]=n(``),[I,L]=n(``),[R,z]=n(void 0),B=a(()=>new Set(o.value)),V=a(()=>o.value.filter(e=>!F(e))),H=a(()=>{let e=v().trim().toLowerCase();return e?M.filter(t=>t.includes(e)||f(`access.resources.${t}`).toLowerCase().includes(e)):M}),U=a(()=>{let e=new Set;for(let t of H())for(let n of N[t]??[])e.add(n);return[...e]}),W=(e,t)=>j.includes(e)||(N[t]??[]).includes(e),G=(e,t)=>{let n=P(e,t);o.onChange(B().has(n)?o.value.filter(e=>e!==n):[...o.value,n])},K=e=>{o.onChange(o.value.filter(t=>t!==e))},q=()=>{let e=I().trim().toLowerCase().replace(/\s+/g,`-`);e&&!B().has(e)&&o.onChange([...o.value,e]),L(``)},J=()=>{let e=o.value.length;if(e===0)return o.placeholder??f(`access.permissionsPlaceholder`);let t=new Set(o.value.map(e=>e.split(`:`)[1]??e));return f(`access.permissionsSummary`,{resources:t.size,count:e})};return(()=>{var n=c(T),a=n.firstChild,_=a.firstChild,M=_.nextSibling,N=a.nextSibling,[F,Y]=h(N.nextSibling);return a.$$click=()=>m(!p()),s(z,a),l(_,J),l(M,()=>p()?`▴`:`▾`),l(n,i(b,{get open(){return p()},get trigger(){return R()},onClose:()=>m(!1),class:`permission-picker__panel`,role:`dialog`,get"aria-label"(){return f(`access.permissions`)},minWidth:440,get children(){return[(()=>{var t=c(x);return t.$$input=e=>y(e.currentTarget.value),e(()=>d(t,`placeholder`,o.searchPlaceholder??f(`access.permissionSearch`))),e(()=>g(t,`value`,v())),u(),t})(),(()=>{var t=c(S),n=t.firstChild,a=n.firstChild.nextSibling,[o,s]=h(a.nextSibling),u=o.nextSibling,[p,m]=h(u.nextSibling),_=n.nextSibling,[v,y]=h(_.nextSibling);return l(n,i(r,{each:j,children:e=>(()=>{var t=c(E);return l(t,e),t})()}),o,s),l(n,i(r,{get each(){return U()},children:e=>(()=>{var t=c(E);return l(t,e),t})()}),p,m),l(t,i(r,{get each(){return H()},get fallback(){return(()=>{var e=c(D);return l(e,()=>f(`access.permissionNoMatches`)),e})()},children:t=>(()=>{var n=c(O),a=n.firstChild,o=a.nextSibling,[s,u]=h(o.nextSibling);return d(a,`title`,t),l(a,()=>f(`access.resources.${t}`)),l(n,i(r,{get each(){return[...j,...U()]},children:n=>W(n,t)?(()=>{var r=c(k),i=r.firstChild;return d(r,`title`,`${n}:${t}`),i.addEventListener(`change`,()=>G(n,t)),e(()=>r.classList.toggle(`is-checked`,!!B().has(P(n,t)))),e(()=>g(i,`checked`,B().has(P(n,t)))),r})():c(A)}),s,u),n})()}),v,y),t})(),(()=>{var t=c(C),n=t.firstChild,a=n.nextSibling,o=a.firstChild,[s,p]=h(o.nextSibling),m=s.nextSibling,_=m.firstChild,v=_.nextSibling;return l(n,()=>f(`access.customPermissions`)),l(a,i(r,{get each(){return V()},children:t=>(()=>{var n=c(ee),r=n.firstChild,i=r.nextSibling;return l(r,t),i.$$click=()=>K(t),e(()=>d(i,`aria-label`,`${f(`common.remove`)}: ${t}`)),u(),n})()}),s,p),m.addEventListener(`submit`,e=>{e.preventDefault(),q()}),_.$$input=e=>L(e.currentTarget.value),l(v,()=>f(`common.add`)),e(()=>d(_,`placeholder`,f(`access.customPermission`))),e(()=>g(_,`value`,I())),u(),t})(),i(t,{get when(){return o.value.length>0},get children(){var e=c(w);return l(e,()=>f(`access.permissionsSelected`,{count:o.value.length})),e}})]}}),F,Y),e(e=>{var t=p(),n=o.value.length===0;return t!==e.e&&d(a,`aria-expanded`,e.e=t),n!==e.t&&_.classList.toggle(`is-empty`,e.t=n),e},{e:void 0,t:void 0}),u(),n})()}p([`click`,`input`]);var L=f(`<div class="notice notice--error">`),R=f(`<div class=resource-hub><!$><!/><div class=access-grid><section class=card><div class=card-header-row><h3></h3><button class="btn btn-primary"type=button>+ <!$><!/></button></div><table class=table><thead><tr><th></th><th></th><th></th><th></th></tr></thead><tbody></tbody></table><!$><!/></section><section class=card><div class=card-header-row><h3></h3><button class="btn btn-primary"type=button>+ <!$><!/></button></div><table class=table><thead><tr><th></th><th></th><th></th><th></th></tr></thead><tbody></tbody></table><!$><!/>`),z=f(`<button class="btn btn-danger btn-sm"type=button>`),B=f(`<tr><td></td><td><code></code></td><td class=access-permissions-cell></td><td class=access-actions><button class="btn btn-secondary btn-sm"type=button></button><!$><!/>`),V=f(`<form class=resource-form><label><span class=resource-form__label></span><input class=input required></label><label><span class=resource-form__label></span><input class=input required></label><div class=resource-form__field><span class=resource-form__label></span><!$><!/></div><div class=form-actions><button class="btn btn-secondary"type=button></button><button class="btn btn-primary"type=submit>`),H=f(`<tr><td></td><td><code></code></td><td></td><td class=access-actions><button class="btn btn-secondary btn-sm"type=button></button><button class="btn btn-danger btn-sm"type=button>`),U=f(`<form class=resource-form><label><span class=resource-form__label></span><input class=input required></label><label><span class=resource-form__label></span><input class=input required></label><label><span class=resource-form__label></span><input class=input></label><div class=form-actions><button class="btn btn-secondary"type=button></button><button class="btn btn-primary"type=submit>`);function W(){let{t:a}=_(),[s,f]=n([]),[p,b]=n([]),[x,S]=n(null),[C,w]=n(null),[T,E]=n(!1),[D,O]=n(``),k=async()=>{try{f(await v.listRoles()),b((await v.listTenants({limit:100})).data??[])}catch(e){O(e instanceof Error?e.message:String(e))}};o(k);let A=e=>{e.preventDefault();let t=x();t&&(E(!0),(t.id?v.updateRole(t.id,t):v.createRole(t)).then(()=>(S(null),k())).catch(e=>O(e instanceof Error?e.message:String(e))).finally(()=>E(!1)))},ee=e=>{e.preventDefault();let t=C();t&&(E(!0),(t.id?v.updateTenant(t.id,t):v.createTenant(t)).then(()=>(w(null),k())).catch(e=>O(e instanceof Error?e.message:String(e))).finally(()=>E(!1)))},j=e=>{let t=e.permissions??[];return t.length===0?`—`:t.slice(0,4).join(`, `)+(t.length>4?` +${t.length-4}`:``)};return(()=>{var n=c(R),o=n.firstChild,[f,_]=h(o.nextSibling),b=f.nextSibling.firstChild,E=b.firstChild,O=E.firstChild,M=O.nextSibling,N=M.firstChild.nextSibling,[P,F]=h(N.nextSibling),W=E.nextSibling,G=W.firstChild,K=G.firstChild.firstChild,q=K.nextSibling,J=q.nextSibling,Y=G.nextSibling,te=W.nextSibling,[ne,re]=h(te.nextSibling),X=b.nextSibling,Z=X.firstChild,Q=Z.firstChild,$=Q.nextSibling,ie=$.firstChild.nextSibling,[ae,oe]=h(ie.nextSibling),se=Z.nextSibling,ce=se.firstChild,le=ce.firstChild.firstChild,ue=le.nextSibling,de=ue.nextSibling,fe=ce.nextSibling,pe=se.nextSibling,[me,he]=h(pe.nextSibling);return l(n,i(t,{get when(){return D()},get children(){var e=c(L);return l(e,D),e}}),f,_),l(O,()=>a(`access.roles`)),M.$$click=()=>S({name:``,slug:``,permissions:[]}),l(M,()=>a(`common.create`),P,F),l(K,()=>a(`resources.name`)),l(q,()=>a(`resources.slug`)),l(J,()=>a(`access.permissions`)),l(Y,i(r,{get each(){return s()},children:n=>(()=>{var r=c(B),o=r.firstChild,s=o.nextSibling,f=s.firstChild,p=s.nextSibling,m=p.nextSibling,g=m.firstChild,_=g.nextSibling,[y,b]=h(_.nextSibling);return l(o,()=>n.name),l(f,()=>n.slug),l(p,()=>j(n)),g.$$click=()=>S({...n,permissions:[...n.permissions??[]]}),l(g,()=>a(`common.edit`)),l(m,i(t,{get when(){return!n.is_system},get children(){var e=c(z);return e.$$click=()=>void v.deleteRole(n.id).then(k),l(e,()=>a(`common.delete`)),u(),e}}),y,b),e(()=>d(p,`title`,(n.permissions??[]).join(`, `))),u(),r})()})),l(b,i(y,{get open(){return x()!==null},onClose:()=>S(null),get title(){return m(()=>!!x()?.id)()?a(`access.editRole`):a(`access.newRole`)},get children(){return i(t,{get when(){return x()},children:t=>(()=>{var n=c(V),r=n.firstChild,o=r.firstChild,s=o.nextSibling,f=r.nextSibling,p=f.firstChild,_=p.nextSibling,v=f.nextSibling,y=v.firstChild,b=y.nextSibling,[x,C]=h(b.nextSibling),w=v.nextSibling.firstChild,E=w.nextSibling;return n.addEventListener(`submit`,A),l(o,()=>a(`resources.name`)),s.$$input=e=>S({...t(),name:e.currentTarget.value}),l(p,()=>a(`resources.slug`)),_.$$input=e=>S({...t(),slug:e.currentTarget.value}),l(y,()=>a(`access.permissions`)),l(v,i(I,{get value(){return t().permissions??[]},onChange:e=>S({...t(),permissions:e})}),x,C),w.$$click=()=>S(null),l(w,()=>a(`common.cancel`)),l(E,(()=>{var e=m(()=>!!T());return()=>e()?a(`common.loading`):a(`common.save`)})()),e(e=>{var t=a(`resources.name`),n=a(`resources.slug`),r=T();return t!==e.e&&d(s,`placeholder`,e.e=t),n!==e.t&&d(_,`placeholder`,e.t=n),r!==e.a&&g(E,`disabled`,e.a=r),e},{e:void 0,t:void 0,a:void 0}),e(()=>g(s,`value`,t().name??``)),e(()=>g(_,`value`,t().slug??``)),u(),n})()})}}),ne,re),l(Q,()=>a(`access.tenants`)),$.$$click=()=>w({name:``,slug:``}),l($,()=>a(`common.create`),ae,oe),l(le,()=>a(`resources.name`)),l(ue,()=>a(`resources.slug`)),l(de,()=>a(`common.status`)),l(fe,i(r,{get each(){return p()},children:e=>(()=>{var t=c(H),n=t.firstChild,r=n.nextSibling,i=r.firstChild,o=r.nextSibling,s=o.nextSibling.firstChild,d=s.nextSibling;return l(n,()=>e.name),l(i,()=>e.slug),l(o,()=>e.status),s.$$click=()=>w({...e}),l(s,()=>a(`common.edit`)),d.$$click=()=>e.id&&void v.deleteTenant(e.id).then(k),l(d,()=>a(`common.delete`)),u(),t})()})),l(X,i(y,{get open(){return C()!==null},onClose:()=>w(null),get title(){return m(()=>!!C()?.id)()?a(`access.editTenant`):a(`access.newTenant`)},get children(){return i(t,{get when(){return C()},children:t=>(()=>{var n=c(U),r=n.firstChild,i=r.firstChild,o=i.nextSibling,s=r.nextSibling,f=s.firstChild,p=f.nextSibling,h=s.nextSibling,_=h.firstChild,v=_.nextSibling,y=h.nextSibling.firstChild,b=y.nextSibling;return n.addEventListener(`submit`,ee),l(i,()=>a(`resources.name`)),o.$$input=e=>w({...t(),name:e.currentTarget.value}),l(f,()=>a(`resources.slug`)),p.$$input=e=>w({...t(),slug:e.currentTarget.value}),l(_,()=>a(`access.domain`)),v.$$input=e=>w({...t(),domain:e.currentTarget.value}),y.$$click=()=>w(null),l(y,()=>a(`common.cancel`)),l(b,(()=>{var e=m(()=>!!T());return()=>e()?a(`common.loading`):a(`common.save`)})()),e(e=>{var t=a(`resources.name`),n=a(`resources.slug`),r=a(`access.domain`),i=T();return t!==e.e&&d(o,`placeholder`,e.e=t),n!==e.t&&d(p,`placeholder`,e.t=n),r!==e.a&&d(v,`placeholder`,e.a=r),i!==e.o&&g(b,`disabled`,e.o=i),e},{e:void 0,t:void 0,a:void 0,o:void 0}),e(()=>g(o,`value`,t().name??``)),e(()=>g(p,`value`,t().slug??``)),e(()=>g(v,`value`,t().domain??``)),u(),n})()})}}),me,he),u(),n})()}p([`click`,`input`]);export{W as AccessManager};
|
|
1
|
+
import{d as e,i as t,p as n,r,s as i,u as a,y as o}from"./solid.D49dPDCT.js";import{_ as s,a as c,c as l,d as u,f as d,g as f,i as p,l as m,o as h,p as g}from"./web.Bqbl_1YR.js";import{n as _}from"./i18n.vdBFsiPK.js";import{n as v}from"./api.CYg1SW2X.js";import{t as y}from"./Modal.BSZ5IjBl.js";import{t as b}from"./FloatingPanel.BeCEt_JP.js";var x=f(`<input type=search class="input permission-picker__search">`),S=f(`<div class=permission-picker__matrix role=presentation><div class="permission-picker__row permission-picker__row--head"role=presentation><span class=permission-picker__resource></span><!$><!/><!$><!/></div><!$><!/>`),C=f(`<div class=permission-picker__custom><p class=permission-picker__custom-label></p><div class=permission-picker__chips><!$><!/><form class=permission-picker__custom-form><input class="input permission-picker__custom-input"><button class="btn btn-secondary btn-sm"type=submit>`),w=f(`<p class=icon-picker__count>`),T=f(`<div class=permission-picker><button type=button class="input permission-picker__trigger"aria-haspopup=dialog><span class=permission-picker__value></span><span class=icon-picker__caret aria-hidden=true></span></button><!$><!/>`),E=f(`<span class=permission-picker__action-label>`),D=f(`<p class=permission-picker__empty>`),O=f(`<div class=permission-picker__row><span class=permission-picker__resource></span><!$><!/>`),k=f(`<label class=permission-picker__cell><input type=checkbox><span aria-hidden=true>✓`),A=f(`<span class="permission-picker__cell permission-picker__cell--empty">`),ee=f(`<span class=permission-picker__chip><code></code><button type=button>×`),j=[`read`,`create`,`update`,`delete`],M=[`content`,`media`,`category`,`tag`,`menu`,`user`,`roles`,`theme`,`plugin`,`setting`,`webhook`,`tenants`,`audit`,`build`,`system`],N={media:[`upload`]},P=(e,t)=>`${e}:${t}`,F=e=>{let[t,n]=e.split(`:`);return!t||!n?!1:j.includes(t)&&M.includes(n)};function I(o){let{t:f}=_(),[p,m]=n(!1),[v,y]=n(``),[I,L]=n(``),[R,z]=n(void 0),B=a(()=>new Set(o.value)),V=a(()=>o.value.filter(e=>!F(e))),H=a(()=>{let e=v().trim().toLowerCase();return e?M.filter(t=>t.includes(e)||f(`access.resources.${t}`).toLowerCase().includes(e)):M}),U=a(()=>{let e=new Set;for(let t of H())for(let n of N[t]??[])e.add(n);return[...e]}),W=(e,t)=>j.includes(e)||(N[t]??[]).includes(e),G=(e,t)=>{let n=P(e,t);o.onChange(B().has(n)?o.value.filter(e=>e!==n):[...o.value,n])},K=e=>{o.onChange(o.value.filter(t=>t!==e))},q=()=>{let e=I().trim().toLowerCase().replace(/\s+/g,`-`);e&&!B().has(e)&&o.onChange([...o.value,e]),L(``)},J=()=>{let e=o.value.length;if(e===0)return o.placeholder??f(`access.permissionsPlaceholder`);let t=new Set(o.value.map(e=>e.split(`:`)[1]??e));return f(`access.permissionsSummary`,{resources:t.size,count:e})};return(()=>{var n=c(T),a=n.firstChild,_=a.firstChild,M=_.nextSibling,N=a.nextSibling,[F,Y]=h(N.nextSibling);return a.$$click=()=>m(!p()),s(z,a),l(_,J),l(M,()=>p()?`▴`:`▾`),l(n,i(b,{get open(){return p()},get trigger(){return R()},onClose:()=>m(!1),class:`permission-picker__panel`,role:`dialog`,get"aria-label"(){return f(`access.permissions`)},minWidth:440,get children(){return[(()=>{var t=c(x);return t.$$input=e=>y(e.currentTarget.value),e(()=>d(t,`placeholder`,o.searchPlaceholder??f(`access.permissionSearch`))),e(()=>g(t,`value`,v())),u(),t})(),(()=>{var t=c(S),n=t.firstChild,a=n.firstChild.nextSibling,[o,s]=h(a.nextSibling),u=o.nextSibling,[p,m]=h(u.nextSibling),_=n.nextSibling,[v,y]=h(_.nextSibling);return l(n,i(r,{each:j,children:e=>(()=>{var t=c(E);return l(t,e),t})()}),o,s),l(n,i(r,{get each(){return U()},children:e=>(()=>{var t=c(E);return l(t,e),t})()}),p,m),l(t,i(r,{get each(){return H()},get fallback(){return(()=>{var e=c(D);return l(e,()=>f(`access.permissionNoMatches`)),e})()},children:t=>(()=>{var n=c(O),a=n.firstChild,o=a.nextSibling,[s,u]=h(o.nextSibling);return d(a,`title`,t),l(a,()=>f(`access.resources.${t}`)),l(n,i(r,{get each(){return[...j,...U()]},children:n=>W(n,t)?(()=>{var r=c(k),i=r.firstChild;return d(r,`title`,`${n}:${t}`),i.addEventListener(`change`,()=>G(n,t)),e(()=>r.classList.toggle(`is-checked`,!!B().has(P(n,t)))),e(()=>g(i,`checked`,B().has(P(n,t)))),r})():c(A)}),s,u),n})()}),v,y),t})(),(()=>{var t=c(C),n=t.firstChild,a=n.nextSibling,o=a.firstChild,[s,p]=h(o.nextSibling),m=s.nextSibling,_=m.firstChild,v=_.nextSibling;return l(n,()=>f(`access.customPermissions`)),l(a,i(r,{get each(){return V()},children:t=>(()=>{var n=c(ee),r=n.firstChild,i=r.nextSibling;return l(r,t),i.$$click=()=>K(t),e(()=>d(i,`aria-label`,`${f(`common.remove`)}: ${t}`)),u(),n})()}),s,p),m.addEventListener(`submit`,e=>{e.preventDefault(),q()}),_.$$input=e=>L(e.currentTarget.value),l(v,()=>f(`common.add`)),e(()=>d(_,`placeholder`,f(`access.customPermission`))),e(()=>g(_,`value`,I())),u(),t})(),i(t,{get when(){return o.value.length>0},get children(){var e=c(w);return l(e,()=>f(`access.permissionsSelected`,{count:o.value.length})),e}})]}}),F,Y),e(e=>{var t=p(),n=o.value.length===0;return t!==e.e&&d(a,`aria-expanded`,e.e=t),n!==e.t&&_.classList.toggle(`is-empty`,e.t=n),e},{e:void 0,t:void 0}),u(),n})()}p([`click`,`input`]);var L=f(`<div class="notice notice--error">`),R=f(`<div class=resource-hub><!$><!/><div class=access-grid><section class=card><div class=card-header-row><h3></h3><button class="btn btn-primary"type=button>+ <!$><!/></button></div><table class=table><thead><tr><th></th><th></th><th></th><th></th></tr></thead><tbody></tbody></table><!$><!/></section><section class=card><div class=card-header-row><h3></h3><button class="btn btn-primary"type=button>+ <!$><!/></button></div><table class=table><thead><tr><th></th><th></th><th></th><th></th></tr></thead><tbody></tbody></table><!$><!/>`),z=f(`<button class="btn btn-danger btn-sm"type=button>`),B=f(`<tr><td></td><td><code></code></td><td class=access-permissions-cell></td><td class=access-actions><button class="btn btn-secondary btn-sm"type=button></button><!$><!/>`),V=f(`<form class=resource-form><label><span class=resource-form__label></span><input class=input required></label><label><span class=resource-form__label></span><input class=input required></label><div class=resource-form__field><span class=resource-form__label></span><!$><!/></div><div class=form-actions><button class="btn btn-secondary"type=button></button><button class="btn btn-primary"type=submit>`),H=f(`<tr><td></td><td><code></code></td><td></td><td class=access-actions><button class="btn btn-secondary btn-sm"type=button></button><button class="btn btn-danger btn-sm"type=button>`),U=f(`<form class=resource-form><label><span class=resource-form__label></span><input class=input required></label><label><span class=resource-form__label></span><input class=input required></label><label><span class=resource-form__label></span><input class=input></label><div class=form-actions><button class="btn btn-secondary"type=button></button><button class="btn btn-primary"type=submit>`);function W(){let{t:a}=_(),[s,f]=n([]),[p,b]=n([]),[x,S]=n(null),[C,w]=n(null),[T,E]=n(!1),[D,O]=n(``),k=async()=>{try{f(await v.listRoles()),b((await v.listTenants({limit:100})).data??[])}catch(e){O(e instanceof Error?e.message:String(e))}};o(k);let A=e=>{e.preventDefault();let t=x();t&&(E(!0),(t.id?v.updateRole(t.id,t):v.createRole(t)).then(()=>(S(null),k())).catch(e=>O(e instanceof Error?e.message:String(e))).finally(()=>E(!1)))},ee=e=>{e.preventDefault();let t=C();t&&(E(!0),(t.id?v.updateTenant(t.id,t):v.createTenant(t)).then(()=>(w(null),k())).catch(e=>O(e instanceof Error?e.message:String(e))).finally(()=>E(!1)))},j=e=>{let t=e.permissions??[];return t.length===0?`—`:t.slice(0,4).join(`, `)+(t.length>4?` +${t.length-4}`:``)};return(()=>{var n=c(R),o=n.firstChild,[f,_]=h(o.nextSibling),b=f.nextSibling.firstChild,E=b.firstChild,O=E.firstChild,M=O.nextSibling,N=M.firstChild.nextSibling,[P,F]=h(N.nextSibling),W=E.nextSibling,G=W.firstChild,K=G.firstChild.firstChild,q=K.nextSibling,J=q.nextSibling,Y=G.nextSibling,te=W.nextSibling,[ne,re]=h(te.nextSibling),X=b.nextSibling,Z=X.firstChild,Q=Z.firstChild,$=Q.nextSibling,ie=$.firstChild.nextSibling,[ae,oe]=h(ie.nextSibling),se=Z.nextSibling,ce=se.firstChild,le=ce.firstChild.firstChild,ue=le.nextSibling,de=ue.nextSibling,fe=ce.nextSibling,pe=se.nextSibling,[me,he]=h(pe.nextSibling);return l(n,i(t,{get when(){return D()},get children(){var e=c(L);return l(e,D),e}}),f,_),l(O,()=>a(`access.roles`)),M.$$click=()=>S({name:``,slug:``,permissions:[]}),l(M,()=>a(`common.create`),P,F),l(K,()=>a(`resources.name`)),l(q,()=>a(`resources.slug`)),l(J,()=>a(`access.permissions`)),l(Y,i(r,{get each(){return s()},children:n=>(()=>{var r=c(B),o=r.firstChild,s=o.nextSibling,f=s.firstChild,p=s.nextSibling,m=p.nextSibling,g=m.firstChild,_=g.nextSibling,[y,b]=h(_.nextSibling);return l(o,()=>n.name),l(f,()=>n.slug),l(p,()=>j(n)),g.$$click=()=>S({...n,permissions:[...n.permissions??[]]}),l(g,()=>a(`common.edit`)),l(m,i(t,{get when(){return!n.is_system},get children(){var e=c(z);return e.$$click=()=>void v.deleteRole(n.id).then(k),l(e,()=>a(`common.delete`)),u(),e}}),y,b),e(()=>d(p,`title`,(n.permissions??[]).join(`, `))),u(),r})()})),l(b,i(y,{get open(){return x()!==null},onClose:()=>S(null),get title(){return m(()=>!!x()?.id)()?a(`access.editRole`):a(`access.newRole`)},get children(){return i(t,{get when(){return x()},children:t=>(()=>{var n=c(V),r=n.firstChild,o=r.firstChild,s=o.nextSibling,f=r.nextSibling,p=f.firstChild,_=p.nextSibling,v=f.nextSibling,y=v.firstChild,b=y.nextSibling,[x,C]=h(b.nextSibling),w=v.nextSibling.firstChild,E=w.nextSibling;return n.addEventListener(`submit`,A),l(o,()=>a(`resources.name`)),s.$$input=e=>S({...t(),name:e.currentTarget.value}),l(p,()=>a(`resources.slug`)),_.$$input=e=>S({...t(),slug:e.currentTarget.value}),l(y,()=>a(`access.permissions`)),l(v,i(I,{get value(){return t().permissions??[]},onChange:e=>S({...t(),permissions:e})}),x,C),w.$$click=()=>S(null),l(w,()=>a(`common.cancel`)),l(E,(()=>{var e=m(()=>!!T());return()=>e()?a(`common.loading`):a(`common.save`)})()),e(e=>{var t=a(`resources.name`),n=a(`resources.slug`),r=T();return t!==e.e&&d(s,`placeholder`,e.e=t),n!==e.t&&d(_,`placeholder`,e.t=n),r!==e.a&&g(E,`disabled`,e.a=r),e},{e:void 0,t:void 0,a:void 0}),e(()=>g(s,`value`,t().name??``)),e(()=>g(_,`value`,t().slug??``)),u(),n})()})}}),ne,re),l(Q,()=>a(`access.tenants`)),$.$$click=()=>w({name:``,slug:``}),l($,()=>a(`common.create`),ae,oe),l(le,()=>a(`resources.name`)),l(ue,()=>a(`resources.slug`)),l(de,()=>a(`common.status`)),l(fe,i(r,{get each(){return p()},children:e=>(()=>{var t=c(H),n=t.firstChild,r=n.nextSibling,i=r.firstChild,o=r.nextSibling,s=o.nextSibling.firstChild,d=s.nextSibling;return l(n,()=>e.name),l(i,()=>e.slug),l(o,()=>e.status),s.$$click=()=>w({...e}),l(s,()=>a(`common.edit`)),d.$$click=()=>e.id&&void v.deleteTenant(e.id).then(k),l(d,()=>a(`common.delete`)),u(),t})()})),l(X,i(y,{get open(){return C()!==null},onClose:()=>w(null),get title(){return m(()=>!!C()?.id)()?a(`access.editTenant`):a(`access.newTenant`)},get children(){return i(t,{get when(){return C()},children:t=>(()=>{var n=c(U),r=n.firstChild,i=r.firstChild,o=i.nextSibling,s=r.nextSibling,f=s.firstChild,p=f.nextSibling,h=s.nextSibling,_=h.firstChild,v=_.nextSibling,y=h.nextSibling.firstChild,b=y.nextSibling;return n.addEventListener(`submit`,ee),l(i,()=>a(`resources.name`)),o.$$input=e=>w({...t(),name:e.currentTarget.value}),l(f,()=>a(`resources.slug`)),p.$$input=e=>w({...t(),slug:e.currentTarget.value}),l(_,()=>a(`access.domain`)),v.$$input=e=>w({...t(),domain:e.currentTarget.value}),y.$$click=()=>w(null),l(y,()=>a(`common.cancel`)),l(b,(()=>{var e=m(()=>!!T());return()=>e()?a(`common.loading`):a(`common.save`)})()),e(e=>{var t=a(`resources.name`),n=a(`resources.slug`),r=a(`access.domain`),i=T();return t!==e.e&&d(o,`placeholder`,e.e=t),n!==e.t&&d(p,`placeholder`,e.t=n),r!==e.a&&d(v,`placeholder`,e.a=r),i!==e.o&&g(b,`disabled`,e.o=i),e},{e:void 0,t:void 0,a:void 0,o:void 0}),e(()=>g(o,`value`,t().name??``)),e(()=>g(p,`value`,t().slug??``)),e(()=>g(v,`value`,t().domain??``)),u(),n})()})}}),me,he),u(),n})()}p([`click`,`input`]);export{W as AccessManager};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,i as t,p as n,r,s as i,y as a}from"./solid.D49dPDCT.js";import{a as o,c as s,d as c,f as l,g as u,i as d,l as f,o as p,p as m}from"./web.Bqbl_1YR.js";import{n as h}from"./i18n.
|
|
1
|
+
import{d as e,i as t,p as n,r,s as i,y as a}from"./solid.D49dPDCT.js";import{a as o,c as s,d as c,f as l,g as u,i as d,l as f,o as p,p as m}from"./web.Bqbl_1YR.js";import{n as h}from"./i18n.vdBFsiPK.js";import{n as g}from"./api.CYg1SW2X.js";var _=u(`<div class="notice notice--error">`),v=u(`<div class=taxonomies-manager><!$><!/><form class=card><h3></h3><div class=form-grid><label><!$><!/><input class=input required></label><label><!$><!/><input class=input pattern=[a-z0-9_]*></label><label class=checkbox-label><input type=checkbox> <!$><!/></label></div><fieldset><legend></legend><!$><!/></fieldset><button type=submit class="btn btn-primary"></button></form><div class="card settings-table-card"><table class=table><thead><tr><th></th><th></th><th></th><th></th></tr></thead><tbody>`),y=u(`<label><input type=checkbox> <!$><!/> (<!$><!/>)`),ee=u(`<button type=button class="btn btn-danger">`),te=u(`<tr><td><!$><!/> (<!$><!/>)</td><td></td><td></td><td>`),ne=u(`<label style=margin-right:0.75rem><input type=checkbox> <!$><!/>`);function b(){let{t:u}=h(),[d,b]=n([]),[x,S]=n([]),[C,w]=n(``),[T,E]=n(!1),[D,O]=n({name:``,slug:``,hierarchical:!1,attachTo:[]}),k=async()=>{try{let[e,t]=await Promise.all([g.getTaxonomies(),g.getContentTypes()]);b(e),S(t)}catch(e){w(e instanceof Error?e.message:String(e))}};a(k);let A=async e=>{e.preventDefault(),w(``),E(!0);try{await g.createTaxonomy({name:D().name,slug:D().slug||void 0,hierarchical:D().hierarchical,attachTo:D().attachTo,labels:{singular_name:D().name}}),O({name:``,slug:``,hierarchical:!1,attachTo:[]}),await k(),window.dispatchEvent(new Event(`okcms:content-models-changed`))}catch(e){w(e instanceof Error?e.message:String(e))}finally{E(!1)}},j=async(e,t)=>{let n=e.attachTo?.includes(t);try{n?await g.detachTaxonomy(e.slug,t):await g.attachTaxonomy(e.slug,t),await k(),window.dispatchEvent(new Event(`okcms:content-models-changed`))}catch(e){w(e instanceof Error?e.message:String(e))}},M=async e=>{try{await g.deleteTaxonomy(e),await k(),window.dispatchEvent(new Event(`okcms:content-models-changed`))}catch(e){w(e instanceof Error?e.message:String(e))}};return(()=>{var n=o(v),a=n.firstChild,[h,g]=p(a.nextSibling),b=h.nextSibling,S=b.firstChild,w=S.nextSibling,E=w.firstChild,k=E.firstChild,[N,P]=p(k.nextSibling),F=N.nextSibling,I=E.nextSibling,re=I.firstChild,[L,R]=p(re.nextSibling),z=L.nextSibling,B=I.nextSibling,V=B.firstChild,H=V.nextSibling.nextSibling,[U,W]=p(H.nextSibling),G=w.nextSibling,K=G.firstChild,q=K.nextSibling,[J,Y]=p(q.nextSibling),X=G.nextSibling,Z=b.nextSibling.firstChild.firstChild,Q=Z.firstChild.firstChild,$=Q.nextSibling,ie=$.nextSibling,ae=Z.nextSibling;return s(n,i(t,{get when(){return C()},get children(){var e=o(_);return s(e,C),e}}),h,g),b.addEventListener(`submit`,A),s(S,()=>u(`settings.taxonomies.form.title`)),s(E,()=>u(`settings.taxonomies.form.name`),N,P),F.$$input=e=>O({...D(),name:e.currentTarget.value}),s(I,()=>u(`settings.taxonomies.form.slug`),L,R),z.$$input=e=>O({...D(),slug:e.currentTarget.value}),V.addEventListener(`change`,e=>O({...D(),hierarchical:e.currentTarget.checked})),s(B,()=>u(`settings.taxonomies.form.hierarchical`),U,W),s(K,()=>u(`settings.taxonomies.form.attachTo`)),s(G,i(r,{get each(){return x()},children:t=>(()=>{var n=o(y),r=n.firstChild,i=r.nextSibling.nextSibling,[a,c]=p(i.nextSibling),l=a.nextSibling.nextSibling,[u,d]=p(l.nextSibling);return u.nextSibling,r.addEventListener(`change`,e=>O({...D(),attachTo:e.currentTarget.checked?[...D().attachTo,t.slug]:D().attachTo.filter(e=>e!==t.slug)})),s(n,()=>t.pluralLabel,a,c),s(n,()=>t.slug,u,d),e(()=>m(r,`checked`,D().attachTo.includes(t.slug))),n})()}),J,Y),s(X,()=>u(`settings.taxonomies.form.create`)),s(Q,()=>u(`settings.taxonomies.table.taxonomy`)),s($,()=>u(`settings.taxonomies.table.hierarchical`)),s(ie,()=>u(`settings.taxonomies.table.attachedTypes`)),s(ae,i(r,{get each(){return d()},children:n=>(()=>{var a=o(te),l=a.firstChild,d=l.firstChild,[h,g]=p(d.nextSibling),_=h.nextSibling.nextSibling,[v,y]=p(_.nextSibling);v.nextSibling;var b=l.nextSibling,S=b.nextSibling,C=S.nextSibling;return s(l,()=>n.name,h,g),s(l,()=>n.slug,v,y),s(b,(()=>{var e=f(()=>!!n.hierarchical);return()=>e()?u(`common.yes`):u(`common.no`)})()),s(S,i(r,{get each(){return x()},children:t=>(()=>{var r=o(ne),i=r.firstChild,a=i.nextSibling.nextSibling,[c,l]=p(a.nextSibling);return i.addEventListener(`change`,()=>j(n,t.slug)),s(r,()=>t.slug,c,l),e(()=>m(i,`checked`,n.attachTo?.includes(t.slug)??!1)),r})()})),s(C,i(t,{get when(){return n.source!==`CORE`},get children(){var e=o(ee);return e.$$click=()=>M(n.slug),s(e,()=>u(`settings.taxonomies.table.actions.remove`)),c(),e}})),a})()})),e(e=>{var t=u(`settings.taxonomies.form.slugHint`),n=T();return t!==e.e&&l(z,`title`,e.e=t),n!==e.t&&m(X,`disabled`,e.t=n),e},{e:void 0,t:void 0}),e(()=>m(F,`value`,D().name)),e(()=>m(z,`value`,D().slug)),e(()=>m(V,`checked`,D().hierarchical)),c(),n})()}d([`input`,`click`]);export{b as TaxonomiesManager};
|
package/dist/client/_astro/{TaxonomyTermsManager.B_ZDFU-K.js → TaxonomyTermsManager.obB3lkr3.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,i as t,p as n,r,s as i,y as a}from"./solid.D49dPDCT.js";import{a as o,c as s,d as c,g as l,i as u,l as d,o as f,p}from"./web.Bqbl_1YR.js";import{n as m}from"./i18n.
|
|
1
|
+
import{d as e,i as t,p as n,r,s as i,y as a}from"./solid.D49dPDCT.js";import{a as o,c as s,d as c,g as l,i as u,l as d,o as f,p}from"./web.Bqbl_1YR.js";import{n as m}from"./i18n.vdBFsiPK.js";import{n as h}from"./api.CYg1SW2X.js";var g=l(`<div class="notice notice--error">`),_=l(`<button class=btn type=button>`),v=l(`<form class="card term-form"><h3></h3><label><!$><!/><input class=input required></label><label><!$><!/><input class=input></label><label><!$><!/><textarea class=input rows=3></textarea></label><div class=form-actions><button class="btn btn-primary"type=submit></button><!$><!/>`),y=l(`<table class=table><thead><tr><th></th><th></th><th></th></tr></thead><tbody>`),b=l(`<div class=card><div class=card-header><div><h3></h3><p class=muted></p></div><span class=badge></span></div><!$><!/>`),x=l(`<div class=terms-panel><!$><!/><!$><!/><!$><!/>`),S=l(`<p class=muted>`),C=l(`<tr><td></td><td></td><td><button class="btn btn-secondary btn-sm"type=button></button> <button class="btn btn-danger btn-sm"type=button>`);function w(l){let{t:u}=m(),[w,T]=n(null),[E,D]=n([]),[O,k]=n(``),[A,j]=n(``),[M,N]=n(``),[P,F]=n(null),[I,L]=n(``),[R,z]=n(!1),B=async()=>{if(l.taxonomySlug)try{let[e,t]=await Promise.all([h.getTaxonomies(),h.getTaxonomyTerms(l.taxonomySlug)]);T(e.find(e=>e.slug===l.taxonomySlug)??null),D(t)}catch(e){L(e instanceof Error?e.message:String(e))}};a(B);let V=()=>{F(null),k(``),j(``),N(``)},H=e=>{F(e.id??null),k(e.name),j(e.slug),N(e.description??``),L(``)},U=async e=>{e.preventDefault(),L(``),z(!0);try{let e={name:O(),slug:A()||void 0,description:M()||void 0};P()?await h.updateTaxonomyTerm(l.taxonomySlug,P(),e):await h.createTaxonomyTerm(l.taxonomySlug,e),V(),await B()}catch(e){L(e instanceof Error?e.message:String(e))}finally{z(!1)}},W=async e=>{if(e.id&&confirm(u(`content.taxonomy.confirmDelete`,{name:e.name})))try{await h.deleteTaxonomyTerm(l.taxonomySlug,e.id),await B()}catch(e){L(e instanceof Error?e.message:String(e))}};return(()=>{var n=o(x),a=n.firstChild,[m,h]=f(a.nextSibling),T=m.nextSibling,[D,F]=f(T.nextSibling),L=D.nextSibling,[z,B]=f(L.nextSibling);return s(n,i(t,{get when(){return I()},get children(){var e=o(g);return s(e,I),e}}),m,h),s(n,i(t,{get when(){return d(()=>!w())()&&l.taxonomySlug},get children(){var e=o(g);return s(e,()=>u(`content.taxonomy.notFound`)),e}}),D,F),s(n,i(t,{get when(){return w()},get children(){return[(()=>{var n=o(v),r=n.firstChild,a=r.nextSibling,l=a.firstChild,[m,h]=f(l.nextSibling),g=m.nextSibling,y=a.nextSibling,b=y.firstChild,[x,S]=f(b.nextSibling),C=x.nextSibling,w=y.nextSibling,T=w.firstChild,[E,D]=f(T.nextSibling),F=E.nextSibling,I=w.nextSibling,L=I.firstChild,z=L.nextSibling,[B,H]=f(z.nextSibling);return n.addEventListener(`submit`,U),s(r,(()=>{var e=d(()=>!!P());return()=>e()?u(`content.taxonomy.editTerm`):u(`content.taxonomy.addTerm`)})()),s(a,()=>u(`content.taxonomy.name`),m,h),g.$$input=e=>k(e.currentTarget.value),s(y,()=>u(`content.taxonomy.slug`),x,S),C.$$input=e=>j(e.currentTarget.value),s(w,()=>u(`content.taxonomy.description`),E,D),F.$$input=e=>N(e.currentTarget.value),s(L,(()=>{var e=d(()=>!!P());return()=>e()?u(`common.save`):u(`content.taxonomy.add`)})()),s(I,i(t,{get when(){return P()},get children(){var e=o(_);return e.$$click=V,s(e,()=>u(`common.cancel`)),c(),e}}),B,H),e(()=>p(L,`disabled`,R())),e(()=>p(g,`value`,O())),e(()=>p(C,`value`,A())),e(()=>p(F,`value`,M())),c(),n})(),(()=>{var e=o(b),n=e.firstChild,a=n.firstChild,p=a.firstChild,m=p.nextSibling,h=a.nextSibling,g=n.nextSibling,[_,v]=f(g.nextSibling);return s(p,()=>w().name),s(m,(()=>{var e=d(()=>!!l.contentType);return()=>e()?`${u(`content.taxonomy.attachedTo`)}: ${l.contentType}`:u(`content.taxonomy.descriptionHint`)})()),s(h,()=>E().length),s(e,i(t,{get when(){return E().length>0},get fallback(){return(()=>{var e=o(S);return s(e,()=>u(`content.taxonomy.empty`)),e})()},get children(){var e=o(y),t=e.firstChild,n=t.firstChild.firstChild,a=n.nextSibling,l=t.nextSibling;return s(n,()=>u(`content.taxonomy.name`)),s(a,()=>u(`content.taxonomy.slug`)),s(l,i(r,{get each(){return E()},children:e=>(()=>{var t=o(C),n=t.firstChild,r=n.nextSibling,i=r.nextSibling.firstChild,a=i.nextSibling.nextSibling;return s(n,()=>e.name),s(r,()=>e.slug),i.$$click=()=>H(e),s(i,()=>u(`common.edit`)),a.$$click=()=>void W(e),s(a,()=>u(`content.taxonomy.delete`)),c(),t})()})),e}}),_,v),e})()]}}),z,B),n})()}u([`input`,`click`]);export{w as TaxonomyTermsManager};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as e,i as t,p as n,r,s as i,y as a}from"./solid.D49dPDCT.js";import{a as o,c as s,d as c,f as l,g as u,i as d,l as f,o as p,p as m,r as h}from"./web.Bqbl_1YR.js";import{n as g}from"./i18n.
|
|
1
|
+
import{d as e,i as t,p as n,r,s as i,y as a}from"./solid.D49dPDCT.js";import{a as o,c as s,d as c,f as l,g as u,i as d,l as f,o as p,p as m,r as h}from"./web.Bqbl_1YR.js";import{n as g}from"./i18n.vdBFsiPK.js";import{n as _}from"./api.CYg1SW2X.js";var v=u(`<div class=theme-manager><div class=theme-toolbar><p class=page-hint></p><button class="btn btn-refresh"></button></div><!$><!/><!$><!/><!$><!/><style>
|
|
2
2
|
.theme-toolbar {
|
|
3
3
|
display: flex;
|
|
4
4
|
align-items: flex-start;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,i as t,p as n,r,s as i,y as a}from"./solid.D49dPDCT.js";import{a as o,c as s,d as c,g as l,i as u,l as d,o as f,p}from"./web.Bqbl_1YR.js";import{n as m}from"./i18n.
|
|
1
|
+
import{d as e,i as t,p as n,r,s as i,y as a}from"./solid.D49dPDCT.js";import{a as o,c as s,d as c,g as l,i as u,l as d,o as f,p}from"./web.Bqbl_1YR.js";import{n as m}from"./i18n.vdBFsiPK.js";import{n as h}from"./api.CYg1SW2X.js";var ee=l(`<div class="notice notice--error">`),te=l(`<div class=user-create><!$><!/><form class=card><h3></h3><div class=form-grid><label><!$><!/><input class=input required></label><label><!$><!/><input class=input type=email required></label><label><!$><!/><span class=muted></span><input class=input type=password required minlength=8></label><label><!$><!/><select class=input><option value></option><!$><!/></select></label></div><p class=muted><!$><!/> <!$><!/> — <!$><!/> <!$><!/>.</p><div class=media-details__actions><button class="btn btn-primary"type=submit></button><a class="btn btn-secondary"href=/users>`),g=l(`<option><!$><!/> (<!$><!/>)`);function _(){let{t:l}=m(),[u,_]=n(``),[v,y]=n(``),[b,ne]=n(``),[x,S]=n(``),[C,w]=n([]),[T,E]=n(``),[D,O]=n(!1);a(async()=>{try{let e=await h.listRoles();w(e),S(e.find(e=>e.slug===`EDITOR`)?.id??e[0]?.id??``)}catch{}});let re=async e=>{if(e.preventDefault(),E(``),b().length<8){E(l(`users.detail.passwordError`));return}O(!0);try{await h.createUser({name:u(),email:v(),password:b(),roleId:x()||void 0}),window.location.href=`/users`}catch(e){E(e instanceof Error?e.message:String(e)),O(!1)}};return(()=>{var n=o(te),a=n.firstChild,[m,h]=f(a.nextSibling),w=m.nextSibling,E=w.firstChild,O=E.nextSibling,k=O.firstChild,A=k.firstChild,[j,M]=f(A.nextSibling),N=j.nextSibling,P=k.nextSibling,ie=P.firstChild,[F,ae]=f(ie.nextSibling),I=F.nextSibling,L=P.nextSibling,oe=L.firstChild,[R,z]=f(oe.nextSibling),B=R.nextSibling,V=B.nextSibling,H=L.nextSibling,U=H.firstChild,[W,G]=f(U.nextSibling),K=W.nextSibling,q=K.firstChild,se=q.nextSibling,[ce,le]=f(se.nextSibling),J=O.nextSibling,ue=J.firstChild,[Y,de]=f(ue.nextSibling),fe=Y.nextSibling.nextSibling,[X,pe]=f(fe.nextSibling),me=X.nextSibling.nextSibling,[Z,he]=f(me.nextSibling),ge=Z.nextSibling.nextSibling,[Q,_e]=f(ge.nextSibling);Q.nextSibling;var $=J.nextSibling.firstChild,ve=$.nextSibling;return s(n,i(t,{get when(){return T()},get children(){var e=o(ee);return s(e,T),e}}),m,h),w.addEventListener(`submit`,re),s(E,()=>l(`users.new`)),s(k,()=>l(`users.detail.fields.name`),j,M),N.$$input=e=>_(e.currentTarget.value),s(P,()=>l(`users.detail.fields.email`),F,ae),I.$$input=e=>y(e.currentTarget.value),s(L,()=>l(`users.detail.fields.password`),R,z),s(B,()=>l(`users.detail.passwordPrompt`,{email:``})),V.$$input=e=>ne(e.currentTarget.value),s(H,()=>l(`users.detail.fields.role`),W,G),K.addEventListener(`change`,e=>S(e.currentTarget.value)),s(q,()=>l(`users.detail.rolePlaceholder`)),s(K,i(r,{get each(){return C()},children:t=>(()=>{var n=o(g),r=n.firstChild,[i,a]=f(r.nextSibling),c=i.nextSibling.nextSibling,[l,u]=f(c.nextSibling);return l.nextSibling,s(n,()=>t.name,i,a),s(n,()=>t.slug,l,u),e(()=>p(n,`value`,t.id)),n})()}),ce,le),s(J,()=>l(`common.save`),Y,de),s(J,()=>l(`users.new`).toLowerCase(),X,pe),s(J,()=>l(`users.detail.fields.role`),Z,he),s(J,()=>l(`users.toolbar.newBtn`).toLowerCase(),Q,_e),s($,(()=>{var e=d(()=>!!D());return()=>e()?l(`common.loading`):l(`common.create`)})()),s(ve,()=>l(`common.back`)),e(()=>p($,`disabled`,D())),e(()=>p(N,`value`,u())),e(()=>p(I,`value`,v())),e(()=>p(V,`value`,b())),e(()=>p(K,`value`,x())),c(),n})()}u([`input`]);export{_ as UserCreateForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,i as t,p as n,r,s as i,y as a}from"./solid.D49dPDCT.js";import{a as o,c as s,d as c,g as l,i as u,o as d,p as f}from"./web.Bqbl_1YR.js";import{n as p}from"./i18n.
|
|
1
|
+
import{d as e,i as t,p as n,r,s as i,y as a}from"./solid.D49dPDCT.js";import{a as o,c as s,d as c,g as l,i as u,o as d,p as f}from"./web.Bqbl_1YR.js";import{n as p}from"./i18n.vdBFsiPK.js";import{n as m}from"./api.CYg1SW2X.js";import{i as h,n as g,o as _,s as v,t as y}from"./src.DXVWCoHp.js";var b=l(`<div class="notice notice--error">`),x=l(`<div class=notice>`),S=l(`<table class=users-table><thead><tr><th></th><th></th><th></th><th></th><th></th><th></th></tr></thead><tbody>`),C=l(`<div class=users-manager><!$><!/><!$><!/><div class=toolbar><!$><!/><!$><!/><a class="btn btn-primary"href=/users/new></a><!$><!/></div><!$><!/><!$><!/><!$><!/>`),w=l(`<p class=muted>`),T=l(`<tr><td></td><td class=muted></td><td></td><td><span class=status-dot></span><!$><!/></td><td class=muted></td><td class=users-table__actions><!$><!/><!$><!/>`),E=l(`<span class=muted>`),D=l(`<div class="card user-details"><h3></h3><div class=form-grid><label><!$><!/><input class=input></label><label><!$><!/><input class=input type=email></label><label><!$><!/><select class=input><option value=ACTIVE></option><option value=INACTIVE></option></select></label><label><!$><!/><select class=input><option value></option><!$><!/></select></label></div><p class=muted></p><div class=media-details__actions><!$><!/><!$><!/><!$><!/>`),O=l(`<option><!$><!/> (<!$><!/>)`);function k(e){if(!e)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleString(`pt-BR`)}function A(){let{t:l}=p(),[u,A]=n([]),[j,M]=n([]),[N,P]=n(0),[F,I]=n(1),[L,R]=n(``),[z,B]=n(``),[V,H]=n(``),[U,W]=n(``),[G,K]=n(null),[q,J]=n(!1),Y=async()=>{try{let e=await m.listUsers({page:F(),limit:20,search:L()||void 0,status:z()||void 0});A(e.data??[]),P(e.total??0)}catch(e){H(e instanceof Error?e.message:String(e))}};a(async()=>{await Y();try{M(await m.listRoles())}catch{}});let X=async()=>{I(1),await Y()},ee=async(e,t)=>{if(t){J(!0),H(``);try{let n=await m.assignRole(e.id,t);K({...e,roles:n.roles}),W(l(`users.detail.toasts.roleUpdated`,{name:e.name})),await Y()}catch(e){H(e instanceof Error?e.message:String(e))}finally{J(!1)}}},te=async e=>{let t=prompt(l(`users.detail.passwordPrompt`,{email:e.email}));if(t){if(t.length<8){H(l(`users.detail.passwordError`));return}J(!0),H(``);try{await m.setUserPassword(e.id,t),W(l(`users.detail.toasts.passwordChanged`,{name:e.name}))}catch(e){H(e instanceof Error?e.message:String(e))}finally{J(!1)}}},ne=async e=>{J(!0),H(``);try{await m.updateUser(e.id,{name:e.name,email:e.email,status:e.status}),W(l(`users.detail.toasts.saved`,{name:e.name})),K(null),await Y()}catch(e){H(e instanceof Error?e.message:String(e))}finally{J(!1)}},re=async e=>{if(confirm(l(`users.detail.confirmDelete`,{email:e.email}))){J(!0),H(``);try{await m.deleteUser(e.id),G()?.id===e.id&&K(null),W(l(`users.detail.toasts.deleted`,{name:e.name})),await Y()}catch(e){H(e instanceof Error?e.message:String(e))}finally{J(!1)}}},ie=e=>j().find(t=>t.slug===e.roles[0]);return(()=>{var n=o(C),a=n.firstChild,[p,m]=d(a.nextSibling),A=p.nextSibling,[M,P]=d(A.nextSibling),H=M.nextSibling,W=H.firstChild,[J,Z]=d(W.nextSibling),ae=J.nextSibling,[Q,oe]=d(ae.nextSibling),$=Q.nextSibling,se=$.nextSibling,[ce,le]=d(se.nextSibling),ue=H.nextSibling,[de,fe]=d(ue.nextSibling),pe=de.nextSibling,[me,he]=d(pe.nextSibling),ge=me.nextSibling,[_e,ve]=d(ge.nextSibling);return s(n,i(t,{get when(){return V()},get children(){var e=o(b);return s(e,V),e}}),p,m),s(n,i(t,{get when(){return U()},get children(){var e=o(x);return s(e,U),e}}),M,P),s(H,i(h,{name:`user-search`,get placeholder(){return l(`users.toolbar.search`)},get value(){return L()},onInput:e=>{R(e),X()}}),J,Z),s(H,i(v,{name:`user-status`,get placeholder(){return l(`users.toolbar.allStatus`)},get value(){return z()},get options(){return[{value:`ACTIVE`,label:l(`users.toolbar.active`)},{value:`INACTIVE`,label:l(`users.toolbar.inactive`)}]},onChange:e=>{B(e),X()}}),Q,oe),s($,()=>l(`users.toolbar.newBtn`)),s(H,i(g,{variant:`secondary`,onClick:()=>void X(),get children(){return l(`users.toolbar.searchBtn`)}}),ce,le),s(n,i(t,{get when(){return u().length>0},get fallback(){return(()=>{var e=o(w);return s(e,()=>l(`users.empty`)),e})()},get children(){var n=o(S),a=n.firstChild,c=a.firstChild.firstChild,f=c.nextSibling,p=f.nextSibling,m=p.nextSibling,h=m.nextSibling,_=a.nextSibling;return s(c,()=>l(`users.table.name`)),s(f,()=>l(`users.table.email`)),s(p,()=>l(`users.table.role`)),s(m,()=>l(`users.table.status`)),s(h,()=>l(`users.table.lastAccess`)),s(_,i(r,{get each(){return u()},children:n=>(()=>{var r=o(T),a=r.firstChild,c=a.nextSibling,u=c.nextSibling,f=u.nextSibling,p=f.firstChild,m=p.nextSibling,[h,_]=d(m.nextSibling),v=f.nextSibling,b=v.nextSibling,x=b.firstChild,[S,C]=d(x.nextSibling),w=S.nextSibling,[D,O]=d(w.nextSibling);return s(a,()=>n.name),s(c,()=>n.email),s(u,i(t,{get when(){return n.roles.length>0},get fallback(){return(()=>{var e=o(E);return s(e,()=>l(`users.noRole`)),e})()},get children(){return i(y,{get children(){return n.roles.join(`, `)}})}})),s(f,()=>l(`common.status.`+n.status.toLowerCase()),h,_),s(v,()=>k(n.last_login_at)),s(b,i(g,{variant:`secondary`,size:`sm`,onClick:()=>K(n),get children(){return l(`users.table.actions.manage`)}}),S,C),s(b,i(g,{variant:`danger`,size:`sm`,onClick:()=>void re(n),get children(){return l(`users.table.actions.delete`)}}),D,O),e(e=>{var t=G()?.id===n.id,i=n.status===`ACTIVE`;return t!==e.e&&r.classList.toggle(`users-table__row--selected`,e.e=t),i!==e.t&&p.classList.toggle(`status-dot--active`,e.t=i),e},{e:void 0,t:void 0}),r})()})),n}}),de,fe),s(n,i(_,{get page(){return F()},limit:20,get total(){return N()},onPageChange:e=>{I(e),Y()}}),me,he),s(n,i(t,{get when(){return G()},children:t=>(()=>{var n=o(D),a=n.firstChild,u=a.nextSibling,p=u.firstChild,m=p.firstChild,[h,_]=d(m.nextSibling),v=h.nextSibling,y=p.nextSibling,b=y.firstChild,[x,S]=d(b.nextSibling),C=x.nextSibling,w=y.nextSibling,T=w.firstChild,[E,A]=d(T.nextSibling),M=E.nextSibling,N=M.firstChild,P=N.nextSibling,F=w.nextSibling,I=F.firstChild,[L,R]=d(I.nextSibling),z=L.nextSibling,B=z.firstChild,V=B.nextSibling,[H,U]=d(V.nextSibling),W=u.nextSibling,G=W.nextSibling,J=G.firstChild,[Y,X]=d(J.nextSibling),re=Y.nextSibling,[Z,ae]=d(re.nextSibling),Q=Z.nextSibling,[oe,$]=d(Q.nextSibling);return s(a,()=>l(`users.detail.title`)),s(p,()=>l(`users.detail.fields.name`),h,_),v.$$input=e=>K({...t(),name:e.currentTarget.value}),s(y,()=>l(`users.detail.fields.email`),x,S),C.$$input=e=>K({...t(),email:e.currentTarget.value}),s(w,()=>l(`users.detail.fields.status`),E,A),M.addEventListener(`change`,e=>K({...t(),status:e.currentTarget.value})),s(N,()=>l(`users.detail.statusOptions.active`)),s(P,()=>l(`users.detail.statusOptions.inactive`)),s(F,()=>l(`users.detail.fields.role`),L,R),z.addEventListener(`change`,e=>void ee(t(),e.currentTarget.value)),s(B,()=>l(`users.detail.rolePlaceholder`)),s(z,i(r,{get each(){return j()},children:t=>(()=>{var n=o(O),r=n.firstChild,[i,a]=d(r.nextSibling),c=i.nextSibling.nextSibling,[l,u]=d(c.nextSibling);return l.nextSibling,s(n,()=>t.name,i,a),s(n,()=>t.slug,l,u),e(()=>f(n,`value`,t.id)),n})()}),H,U),s(W,()=>l(`users.detail.meta`,{created:k(t().created_at),lastAccess:k(t().last_login_at)})),s(G,i(g,{variant:`primary`,get disabled(){return q()},get loading(){return q()},onClick:()=>void ne(t()),get children(){return l(`users.detail.actions.save`)}}),Y,X),s(G,i(g,{variant:`secondary`,get disabled(){return q()},onClick:()=>void te(t()),get children(){return l(`users.detail.actions.resetPassword`)}}),Z,ae),s(G,i(g,{variant:`secondary`,onClick:()=>K(null),get children(){return l(`users.detail.actions.close`)}}),oe,$),e(()=>f(z,`disabled`,q())),e(()=>f(v,`value`,t().name)),e(()=>f(C,`value`,t().email)),e(()=>f(M,`value`,t().status)),e(()=>f(z,`value`,ie(t())?.id??``)),c(),n})()}),_e,ve),n})()}u([`input`]);export{A as UsersManager};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,i as t,p as n,r,s as i,v as a,y as o}from"./solid.D49dPDCT.js";import{_ as s,a as c,c as l,d as u,f as d,g as f,i as p,l as m,o as h,p as g}from"./web.Bqbl_1YR.js";import{n as _}from"./i18n.AbBpo2WD.js";import{n as v}from"./api.CYg1SW2X.js";var y=f(`<div class=webhook-event-select__dropdown role=listbox><input class=input><div class=webhook-event-select__options>`),b=f(`<div class=webhook-event-select><button type=button class="input webhook-event-select__trigger"aria-haspopup=listbox><span></span><span aria-hidden=true>⌄</span></button><!$><!/><div class=webhook-event-select__chips>`),x=f(`<span class=muted>`),S=f(`<label class=webhook-event-option><input type=checkbox><span><!$><!/><small>`),C=f(`<button type=button class=webhook-event-chip><!$><!/> ×`),w=f(`<div class="notice notice--error">`),T=f(`<div class=table-scroll><table class=table><thead><tr><th></th><th></th><th></th><th></th><th></th></tr></thead><tbody>`),E=f(`<div class="resource-hub webhooks-manager"><!$><!/><div class=card-header-row><div><h3></h3></div><button class="btn btn-primary"type=button></button></div><!$><!/><section class=card></section><style>.webhook-event-select{position:relative}.webhook-event-select__trigger{width:100%;display:flex;justify-content:space-between;align-items:center;text-align:left;cursor:pointer}.webhook-event-select__dropdown{position:absolute;z-index:20;top:calc(100% + .25rem);left:0;right:0;background:var(--color-surface,#fff);border:1px solid var(--color-border,#dcdcde);box-shadow:0 8px 22px rgba(0,0,0,.14);padding:.6rem}.webhook-event-select__options{max-height:240px;overflow:auto;margin-top:.5rem;display:grid;gap:.2rem}.webhook-event-option{display:flex!important;align-items:flex-start;gap:.5rem!important;padding:.45rem;border-radius:4px;cursor:pointer}.webhook-event-option:hover{background:var(--color-surface-muted,#f5f5f5)}.webhook-event-option span{display:grid;gap:.12rem}.webhook-event-option small{color:var(--color-muted);font-size:.75rem}.webhook-event-select__chips{display:flex;flex-wrap:wrap;gap:.35rem;margin-top:.4rem}.webhook-event-chip{border:1px solid var(--color-border,#dcdcde);background:var(--color-surface-muted,#f5f5f5);border-radius:999px;padding:.2rem .55rem;cursor:pointer;font-size:.78rem}`),D=f(`<label><!$><!/><input class=input type=password>`),O=f(`<div class=form-grid><label><!$><!/><input class=input></label><label><!$><!/><input class=input type=password>`),k=f(`<div class=form-grid><label><!$><!/><input class=input type=password></label><label><!$><!/><input class=input>`),A=f(`<section class=card><h3></h3><form class=resource-form><label><!$><!/><input class=input required type=url></label><label><!$><!/><!$><!/></label><label><!$><!/><select class=input><option value=none></option><option value=bearer></option><option value=basic></option><option value=api_key></option><option value=hmac_sha256></option></select></label><!$><!/><!$><!/><!$><!/><!$><!/><label class=checkbox-label><input type=checkbox> <!$><!/></label><div><button class="btn btn-primary"type=submit></button> <button class=btn type=button>`),j=f(`<p>`),M=f(`<tr><td></td><td></td><td></td><td></td><td><button class=btn type=button></button> <button class="btn btn-danger"type=button>`),N=()=>({url:``,events:[],active:!0,auth_type:`hmac_sha256`,auth_config:{signatureHeader:`X-Webhook-Signature`}});function P(f){let[p,_]=n(!1),[v,w]=n(``),T;o(()=>{let e=e=>{T&&!T.contains(e.target)&&_(!1)};document.addEventListener(`mousedown`,e),a(()=>document.removeEventListener(`mousedown`,e))});let E=()=>f.options.filter(e=>`${e.label} ${e.value}`.toLowerCase().includes(v().toLowerCase())),D=e=>f.onChange(f.value.includes(e)?f.value.filter(t=>t!==e):[...f.value,e]);return(()=>{var n=c(b),a=n.firstChild,o=a.firstChild,O=a.nextSibling,[k,A]=h(O.nextSibling),j=k.nextSibling,M=T;return typeof M==`function`?s(M,n):T=n,a.$$click=()=>_(!p()),l(o,(()=>{var e=m(()=>f.value.length>0);return()=>e()?`${f.value.length} selecionado(s)`:f.placeholder})()),l(n,i(t,{get when(){return p()},get children(){var n=c(y),a=n.firstChild,o=a.nextSibling;return a.$$input=e=>w(e.currentTarget.value),l(o,i(t,{get when(){return E().length>0},get fallback(){return(()=>{var e=c(x);return l(e,()=>f.empty),e})()},get children(){return i(r,{get each(){return E()},children:t=>(()=>{var n=c(S),r=n.firstChild,i=r.nextSibling,a=i.firstChild,[o,s]=h(a.nextSibling),u=o.nextSibling;return r.addEventListener(`change`,()=>D(t.value)),l(i,()=>t.label,o,s),l(u,()=>t.value),e(()=>g(r,`checked`,f.value.includes(t.value))),n})()})}})),e(()=>d(a,`placeholder`,f.searchPlaceholder)),e(()=>g(a,`value`,v())),u(),n}}),k,A),l(j,i(r,{get each(){return f.value},children:e=>(()=>{var t=c(C),n=t.firstChild,[r,i]=h(n.nextSibling);return r.nextSibling,t.$$click=()=>D(e),l(t,()=>f.options.find(t=>t.value===e)?.label??e,r,i),u(),t})()})),e(()=>d(a,`aria-expanded`,p())),u(),n})()}function F(){let{t:a}=_(),[s,f]=n([]),[p,y]=n([]),[b,x]=n(null),[S,C]=n(``),[F,I]=n(!0),L=async()=>{I(!0);try{let[e,t]=await Promise.all([v.getWebhooks(),v.getWebhookEvents()]);f(e),y(t)}catch(e){C(e instanceof Error?e.message:String(e))}finally{I(!1)}};o(L);let R=e=>{if(!e){x(N());return}x({...e,events:[...e.events??[]],auth_type:e.auth_type??`hmac_sha256`,auth_config:{...e.auth_config??{}}})},z=(e,t)=>{let n=b();if(n){if(!n.events||n.events.length===0){C(a(`webhooks.eventsRequired`));return}x({...n,auth_config:{...n.auth_config,[e]:t}})}},B=async e=>{e.preventDefault();let t=b();if(!t)return;let n=Object.fromEntries(Object.entries(t.auth_config).filter(([,e])=>e));try{t.id?await v.updateWebhook(t.id,{...t,auth_config:n}):await v.createWebhook({...t,auth_config:n}),x(null),await L()}catch(e){C(e instanceof Error?e.message:String(e))}};return(()=>{var n=c(E),o=n.firstChild,[f,_]=h(o.nextSibling),y=f.nextSibling,C=y.firstChild,N=C.firstChild,I=C.nextSibling,V=y.nextSibling,[H,U]=h(V.nextSibling),W=H.nextSibling;return l(n,i(t,{get when(){return S()},get children(){var e=c(w);return l(e,S),e}}),f,_),l(N,()=>a(`webhooks.listTitle`)),I.$$click=()=>R(),l(I,()=>a(`webhooks.new`)),l(n,i(t,{get when(){return b()},children:n=>(()=>{var r=c(A),o=r.firstChild,s=o.nextSibling,f=s.firstChild,_=f.firstChild,[v,y]=h(_.nextSibling),b=v.nextSibling,S=f.nextSibling,C=S.firstChild,[w,T]=h(C.nextSibling),E=w.nextSibling,[j,M]=h(E.nextSibling),N=S.nextSibling,F=N.firstChild,[I,L]=h(F.nextSibling),R=I.nextSibling,V=R.firstChild,H=V.nextSibling,U=H.nextSibling,W=U.nextSibling,G=W.nextSibling,ee=N.nextSibling,[K,te]=h(ee.nextSibling),ne=K.nextSibling,[q,re]=h(ne.nextSibling),ie=q.nextSibling,[J,ae]=h(ie.nextSibling),oe=J.nextSibling,[Y,se]=h(oe.nextSibling),X=Y.nextSibling,Z=X.firstChild,ce=Z.nextSibling.nextSibling,[le,ue]=h(ce.nextSibling),Q=X.nextSibling.firstChild,$=Q.nextSibling.nextSibling;return l(o,(()=>{var e=m(()=>!!n().id);return()=>e()?a(`webhooks.edit`):a(`webhooks.create`)})()),s.addEventListener(`submit`,B),l(f,()=>a(`webhooks.url`),v,y),b.$$input=e=>x({...n(),url:e.currentTarget.value}),l(S,()=>a(`webhooks.events`),w,T),l(S,i(P,{get options(){return p()},get value(){return n().events??[]},onChange:e=>x({...n(),events:e}),get placeholder(){return a(`webhooks.selectEvents`)},get searchPlaceholder(){return a(`webhooks.searchEvents`)},get empty(){return a(`webhooks.noEvents`)}}),j,M),l(N,()=>a(`webhooks.authentication`),I,L),R.addEventListener(`change`,e=>x({...n(),auth_type:e.currentTarget.value,auth_config:{}})),l(V,()=>a(`webhooks.auth.none`)),l(H,()=>a(`webhooks.auth.bearer`)),l(U,()=>a(`webhooks.auth.basic`)),l(W,()=>a(`webhooks.auth.apiKey`)),l(G,()=>a(`webhooks.auth.hmac_sha256`)),l(s,i(t,{get when(){return n().auth_type===`bearer`},get children(){var t=c(D),r=t.firstChild,[i,o]=h(r.nextSibling),s=i.nextSibling;return l(t,()=>a(`webhooks.token`),i,o),s.$$input=e=>z(`token`,e.currentTarget.value),e(()=>d(s,`placeholder`,n().id?a(`webhooks.keepExisting`):``)),e(()=>g(s,`value`,n().auth_config.token??``)),u(),t}}),K,te),l(s,i(t,{get when(){return n().auth_type===`basic`},get children(){var t=c(O),r=t.firstChild,i=r.firstChild,[o,s]=h(i.nextSibling),f=o.nextSibling,p=r.nextSibling,m=p.firstChild,[_,v]=h(m.nextSibling),y=_.nextSibling;return l(r,()=>a(`webhooks.username`),o,s),f.$$input=e=>z(`username`,e.currentTarget.value),l(p,()=>a(`webhooks.password`),_,v),y.$$input=e=>z(`password`,e.currentTarget.value),e(()=>d(y,`placeholder`,n().id?a(`webhooks.keepExisting`):``)),e(()=>g(f,`value`,n().auth_config.username??``)),e(()=>g(y,`value`,n().auth_config.password??``)),u(),t}}),q,re),l(s,i(t,{get when(){return n().auth_type===`api_key`},get children(){var t=c(O),r=t.firstChild,i=r.firstChild,[o,s]=h(i.nextSibling),f=o.nextSibling,p=r.nextSibling,m=p.firstChild,[_,v]=h(m.nextSibling),y=_.nextSibling;return l(r,()=>a(`webhooks.headerName`),o,s),f.$$input=e=>z(`headerName`,e.currentTarget.value),l(p,()=>a(`webhooks.apiKeyValue`),_,v),y.$$input=e=>z(`value`,e.currentTarget.value),e(()=>d(y,`placeholder`,n().id?a(`webhooks.keepExisting`):``)),e(()=>g(f,`value`,n().auth_config.headerName??``)),e(()=>g(y,`value`,n().auth_config.value??``)),u(),t}}),J,ae),l(s,i(t,{get when(){return n().auth_type===`hmac_sha256`},get children(){var t=c(k),r=t.firstChild,i=r.firstChild,[o,s]=h(i.nextSibling),f=o.nextSibling,p=r.nextSibling,m=p.firstChild,[_,v]=h(m.nextSibling),y=_.nextSibling;return l(r,()=>a(`webhooks.secret`),o,s),f.$$input=e=>z(`secret`,e.currentTarget.value),l(p,()=>a(`webhooks.signatureHeader`),_,v),y.$$input=e=>z(`signatureHeader`,e.currentTarget.value),e(e=>{var t=!n().id,r=n().id?a(`webhooks.keepExisting`):``;return t!==e.e&&g(f,`required`,e.e=t),r!==e.t&&d(f,`placeholder`,e.t=r),e},{e:void 0,t:void 0}),e(()=>g(f,`value`,n().auth_config.secret??``)),e(()=>g(y,`value`,n().auth_config.signatureHeader??`X-Webhook-Signature`)),u(),t}}),Y,se),Z.addEventListener(`change`,e=>x({...n(),active:e.currentTarget.checked})),l(X,()=>a(`webhooks.active`),le,ue),l(Q,()=>a(`common.save`)),$.$$click=()=>x(null),l($,()=>a(`common.cancel`)),e(()=>g(b,`value`,n().url??``)),e(()=>g(R,`value`,n().auth_type)),e(()=>g(Z,`checked`,n().active??!0)),u(),r})()}),H,U),l(W,i(t,{get when(){return!F()},get fallback(){return(()=>{var e=c(j);return l(e,()=>a(`webhooks.loading`)),e})()},get children(){return i(t,{get when(){return s().length>0},get fallback(){return(()=>{var e=c(j);return l(e,()=>a(`webhooks.empty`)),e})()},get children(){var e=c(T),t=e.firstChild.firstChild,n=t.firstChild.firstChild,o=n.nextSibling,d=o.nextSibling,f=d.nextSibling,p=f.nextSibling,h=t.nextSibling;return l(n,()=>a(`webhooks.url`)),l(o,()=>a(`webhooks.events`)),l(d,()=>a(`webhooks.authentication`)),l(f,()=>a(`webhooks.active`)),l(p,()=>a(`common.actions`)),l(h,i(r,{get each(){return s()},children:e=>(()=>{var t=c(M),n=t.firstChild,r=n.nextSibling,i=r.nextSibling,o=i.nextSibling,s=o.nextSibling.firstChild,d=s.nextSibling.nextSibling;return l(n,()=>e.url),l(r,()=>(e.events??[]).join(`, `)),l(i,()=>a(`webhooks.auth.${e.auth_type??`hmac_sha256`}`)),l(o,(()=>{var t=m(()=>!!e.active);return()=>t()?a(`common.yes`):a(`common.no`)})()),s.$$click=()=>R(e),l(s,()=>a(`common.edit`)),d.$$click=()=>e.id&&void v.deleteWebhook(e.id).then(L),l(d,()=>a(`common.delete`)),u(),t})()})),e}})}})),u(),n})()}p([`click`,`input`]);export{F as WebhooksManager};
|
|
1
|
+
import{d as e,i as t,p as n,r,s as i,v as a,y as o}from"./solid.D49dPDCT.js";import{_ as s,a as c,c as l,d as u,f as d,g as f,i as p,l as m,o as h,p as g}from"./web.Bqbl_1YR.js";import{n as _}from"./i18n.vdBFsiPK.js";import{n as v}from"./api.CYg1SW2X.js";var y=f(`<div class=webhook-event-select__dropdown role=listbox><input class=input><div class=webhook-event-select__options>`),b=f(`<div class=webhook-event-select><button type=button class="input webhook-event-select__trigger"aria-haspopup=listbox><span></span><span aria-hidden=true>⌄</span></button><!$><!/><div class=webhook-event-select__chips>`),x=f(`<span class=muted>`),S=f(`<label class=webhook-event-option><input type=checkbox><span><!$><!/><small>`),C=f(`<button type=button class=webhook-event-chip><!$><!/> ×`),w=f(`<div class="notice notice--error">`),T=f(`<div class=table-scroll><table class=table><thead><tr><th></th><th></th><th></th><th></th><th></th></tr></thead><tbody>`),E=f(`<div class="resource-hub webhooks-manager"><!$><!/><div class=card-header-row><div><h3></h3></div><button class="btn btn-primary"type=button></button></div><!$><!/><section class=card></section><style>.webhook-event-select{position:relative}.webhook-event-select__trigger{width:100%;display:flex;justify-content:space-between;align-items:center;text-align:left;cursor:pointer}.webhook-event-select__dropdown{position:absolute;z-index:20;top:calc(100% + .25rem);left:0;right:0;background:var(--color-surface,#fff);border:1px solid var(--color-border,#dcdcde);box-shadow:0 8px 22px rgba(0,0,0,.14);padding:.6rem}.webhook-event-select__options{max-height:240px;overflow:auto;margin-top:.5rem;display:grid;gap:.2rem}.webhook-event-option{display:flex!important;align-items:flex-start;gap:.5rem!important;padding:.45rem;border-radius:4px;cursor:pointer}.webhook-event-option:hover{background:var(--color-surface-muted,#f5f5f5)}.webhook-event-option span{display:grid;gap:.12rem}.webhook-event-option small{color:var(--color-muted);font-size:.75rem}.webhook-event-select__chips{display:flex;flex-wrap:wrap;gap:.35rem;margin-top:.4rem}.webhook-event-chip{border:1px solid var(--color-border,#dcdcde);background:var(--color-surface-muted,#f5f5f5);border-radius:999px;padding:.2rem .55rem;cursor:pointer;font-size:.78rem}`),D=f(`<label><!$><!/><input class=input type=password>`),O=f(`<div class=form-grid><label><!$><!/><input class=input></label><label><!$><!/><input class=input type=password>`),k=f(`<div class=form-grid><label><!$><!/><input class=input type=password></label><label><!$><!/><input class=input>`),A=f(`<section class=card><h3></h3><form class=resource-form><label><!$><!/><input class=input required type=url></label><label><!$><!/><!$><!/></label><label><!$><!/><select class=input><option value=none></option><option value=bearer></option><option value=basic></option><option value=api_key></option><option value=hmac_sha256></option></select></label><!$><!/><!$><!/><!$><!/><!$><!/><label class=checkbox-label><input type=checkbox> <!$><!/></label><div><button class="btn btn-primary"type=submit></button> <button class=btn type=button>`),j=f(`<p>`),M=f(`<tr><td></td><td></td><td></td><td></td><td><button class=btn type=button></button> <button class="btn btn-danger"type=button>`),N=()=>({url:``,events:[],active:!0,auth_type:`hmac_sha256`,auth_config:{signatureHeader:`X-Webhook-Signature`}});function P(f){let[p,_]=n(!1),[v,w]=n(``),T;o(()=>{let e=e=>{T&&!T.contains(e.target)&&_(!1)};document.addEventListener(`mousedown`,e),a(()=>document.removeEventListener(`mousedown`,e))});let E=()=>f.options.filter(e=>`${e.label} ${e.value}`.toLowerCase().includes(v().toLowerCase())),D=e=>f.onChange(f.value.includes(e)?f.value.filter(t=>t!==e):[...f.value,e]);return(()=>{var n=c(b),a=n.firstChild,o=a.firstChild,O=a.nextSibling,[k,A]=h(O.nextSibling),j=k.nextSibling,M=T;return typeof M==`function`?s(M,n):T=n,a.$$click=()=>_(!p()),l(o,(()=>{var e=m(()=>f.value.length>0);return()=>e()?`${f.value.length} selecionado(s)`:f.placeholder})()),l(n,i(t,{get when(){return p()},get children(){var n=c(y),a=n.firstChild,o=a.nextSibling;return a.$$input=e=>w(e.currentTarget.value),l(o,i(t,{get when(){return E().length>0},get fallback(){return(()=>{var e=c(x);return l(e,()=>f.empty),e})()},get children(){return i(r,{get each(){return E()},children:t=>(()=>{var n=c(S),r=n.firstChild,i=r.nextSibling,a=i.firstChild,[o,s]=h(a.nextSibling),u=o.nextSibling;return r.addEventListener(`change`,()=>D(t.value)),l(i,()=>t.label,o,s),l(u,()=>t.value),e(()=>g(r,`checked`,f.value.includes(t.value))),n})()})}})),e(()=>d(a,`placeholder`,f.searchPlaceholder)),e(()=>g(a,`value`,v())),u(),n}}),k,A),l(j,i(r,{get each(){return f.value},children:e=>(()=>{var t=c(C),n=t.firstChild,[r,i]=h(n.nextSibling);return r.nextSibling,t.$$click=()=>D(e),l(t,()=>f.options.find(t=>t.value===e)?.label??e,r,i),u(),t})()})),e(()=>d(a,`aria-expanded`,p())),u(),n})()}function F(){let{t:a}=_(),[s,f]=n([]),[p,y]=n([]),[b,x]=n(null),[S,C]=n(``),[F,I]=n(!0),L=async()=>{I(!0);try{let[e,t]=await Promise.all([v.getWebhooks(),v.getWebhookEvents()]);f(e),y(t)}catch(e){C(e instanceof Error?e.message:String(e))}finally{I(!1)}};o(L);let R=e=>{if(!e){x(N());return}x({...e,events:[...e.events??[]],auth_type:e.auth_type??`hmac_sha256`,auth_config:{...e.auth_config??{}}})},z=(e,t)=>{let n=b();if(n){if(!n.events||n.events.length===0){C(a(`webhooks.eventsRequired`));return}x({...n,auth_config:{...n.auth_config,[e]:t}})}},B=async e=>{e.preventDefault();let t=b();if(!t)return;let n=Object.fromEntries(Object.entries(t.auth_config).filter(([,e])=>e));try{t.id?await v.updateWebhook(t.id,{...t,auth_config:n}):await v.createWebhook({...t,auth_config:n}),x(null),await L()}catch(e){C(e instanceof Error?e.message:String(e))}};return(()=>{var n=c(E),o=n.firstChild,[f,_]=h(o.nextSibling),y=f.nextSibling,C=y.firstChild,N=C.firstChild,I=C.nextSibling,V=y.nextSibling,[H,U]=h(V.nextSibling),W=H.nextSibling;return l(n,i(t,{get when(){return S()},get children(){var e=c(w);return l(e,S),e}}),f,_),l(N,()=>a(`webhooks.listTitle`)),I.$$click=()=>R(),l(I,()=>a(`webhooks.new`)),l(n,i(t,{get when(){return b()},children:n=>(()=>{var r=c(A),o=r.firstChild,s=o.nextSibling,f=s.firstChild,_=f.firstChild,[v,y]=h(_.nextSibling),b=v.nextSibling,S=f.nextSibling,C=S.firstChild,[w,T]=h(C.nextSibling),E=w.nextSibling,[j,M]=h(E.nextSibling),N=S.nextSibling,F=N.firstChild,[I,L]=h(F.nextSibling),R=I.nextSibling,V=R.firstChild,H=V.nextSibling,U=H.nextSibling,W=U.nextSibling,G=W.nextSibling,ee=N.nextSibling,[K,te]=h(ee.nextSibling),ne=K.nextSibling,[q,re]=h(ne.nextSibling),ie=q.nextSibling,[J,ae]=h(ie.nextSibling),oe=J.nextSibling,[Y,se]=h(oe.nextSibling),X=Y.nextSibling,Z=X.firstChild,ce=Z.nextSibling.nextSibling,[le,ue]=h(ce.nextSibling),Q=X.nextSibling.firstChild,$=Q.nextSibling.nextSibling;return l(o,(()=>{var e=m(()=>!!n().id);return()=>e()?a(`webhooks.edit`):a(`webhooks.create`)})()),s.addEventListener(`submit`,B),l(f,()=>a(`webhooks.url`),v,y),b.$$input=e=>x({...n(),url:e.currentTarget.value}),l(S,()=>a(`webhooks.events`),w,T),l(S,i(P,{get options(){return p()},get value(){return n().events??[]},onChange:e=>x({...n(),events:e}),get placeholder(){return a(`webhooks.selectEvents`)},get searchPlaceholder(){return a(`webhooks.searchEvents`)},get empty(){return a(`webhooks.noEvents`)}}),j,M),l(N,()=>a(`webhooks.authentication`),I,L),R.addEventListener(`change`,e=>x({...n(),auth_type:e.currentTarget.value,auth_config:{}})),l(V,()=>a(`webhooks.auth.none`)),l(H,()=>a(`webhooks.auth.bearer`)),l(U,()=>a(`webhooks.auth.basic`)),l(W,()=>a(`webhooks.auth.apiKey`)),l(G,()=>a(`webhooks.auth.hmac_sha256`)),l(s,i(t,{get when(){return n().auth_type===`bearer`},get children(){var t=c(D),r=t.firstChild,[i,o]=h(r.nextSibling),s=i.nextSibling;return l(t,()=>a(`webhooks.token`),i,o),s.$$input=e=>z(`token`,e.currentTarget.value),e(()=>d(s,`placeholder`,n().id?a(`webhooks.keepExisting`):``)),e(()=>g(s,`value`,n().auth_config.token??``)),u(),t}}),K,te),l(s,i(t,{get when(){return n().auth_type===`basic`},get children(){var t=c(O),r=t.firstChild,i=r.firstChild,[o,s]=h(i.nextSibling),f=o.nextSibling,p=r.nextSibling,m=p.firstChild,[_,v]=h(m.nextSibling),y=_.nextSibling;return l(r,()=>a(`webhooks.username`),o,s),f.$$input=e=>z(`username`,e.currentTarget.value),l(p,()=>a(`webhooks.password`),_,v),y.$$input=e=>z(`password`,e.currentTarget.value),e(()=>d(y,`placeholder`,n().id?a(`webhooks.keepExisting`):``)),e(()=>g(f,`value`,n().auth_config.username??``)),e(()=>g(y,`value`,n().auth_config.password??``)),u(),t}}),q,re),l(s,i(t,{get when(){return n().auth_type===`api_key`},get children(){var t=c(O),r=t.firstChild,i=r.firstChild,[o,s]=h(i.nextSibling),f=o.nextSibling,p=r.nextSibling,m=p.firstChild,[_,v]=h(m.nextSibling),y=_.nextSibling;return l(r,()=>a(`webhooks.headerName`),o,s),f.$$input=e=>z(`headerName`,e.currentTarget.value),l(p,()=>a(`webhooks.apiKeyValue`),_,v),y.$$input=e=>z(`value`,e.currentTarget.value),e(()=>d(y,`placeholder`,n().id?a(`webhooks.keepExisting`):``)),e(()=>g(f,`value`,n().auth_config.headerName??``)),e(()=>g(y,`value`,n().auth_config.value??``)),u(),t}}),J,ae),l(s,i(t,{get when(){return n().auth_type===`hmac_sha256`},get children(){var t=c(k),r=t.firstChild,i=r.firstChild,[o,s]=h(i.nextSibling),f=o.nextSibling,p=r.nextSibling,m=p.firstChild,[_,v]=h(m.nextSibling),y=_.nextSibling;return l(r,()=>a(`webhooks.secret`),o,s),f.$$input=e=>z(`secret`,e.currentTarget.value),l(p,()=>a(`webhooks.signatureHeader`),_,v),y.$$input=e=>z(`signatureHeader`,e.currentTarget.value),e(e=>{var t=!n().id,r=n().id?a(`webhooks.keepExisting`):``;return t!==e.e&&g(f,`required`,e.e=t),r!==e.t&&d(f,`placeholder`,e.t=r),e},{e:void 0,t:void 0}),e(()=>g(f,`value`,n().auth_config.secret??``)),e(()=>g(y,`value`,n().auth_config.signatureHeader??`X-Webhook-Signature`)),u(),t}}),Y,se),Z.addEventListener(`change`,e=>x({...n(),active:e.currentTarget.checked})),l(X,()=>a(`webhooks.active`),le,ue),l(Q,()=>a(`common.save`)),$.$$click=()=>x(null),l($,()=>a(`common.cancel`)),e(()=>g(b,`value`,n().url??``)),e(()=>g(R,`value`,n().auth_type)),e(()=>g(Z,`checked`,n().active??!0)),u(),r})()}),H,U),l(W,i(t,{get when(){return!F()},get fallback(){return(()=>{var e=c(j);return l(e,()=>a(`webhooks.loading`)),e})()},get children(){return i(t,{get when(){return s().length>0},get fallback(){return(()=>{var e=c(j);return l(e,()=>a(`webhooks.empty`)),e})()},get children(){var e=c(T),t=e.firstChild.firstChild,n=t.firstChild.firstChild,o=n.nextSibling,d=o.nextSibling,f=d.nextSibling,p=f.nextSibling,h=t.nextSibling;return l(n,()=>a(`webhooks.url`)),l(o,()=>a(`webhooks.events`)),l(d,()=>a(`webhooks.authentication`)),l(f,()=>a(`webhooks.active`)),l(p,()=>a(`common.actions`)),l(h,i(r,{get each(){return s()},children:e=>(()=>{var t=c(M),n=t.firstChild,r=n.nextSibling,i=r.nextSibling,o=i.nextSibling,s=o.nextSibling.firstChild,d=s.nextSibling.nextSibling;return l(n,()=>e.url),l(r,()=>(e.events??[]).join(`, `)),l(i,()=>a(`webhooks.auth.${e.auth_type??`hmac_sha256`}`)),l(o,(()=>{var t=m(()=>!!e.active);return()=>t()?a(`common.yes`):a(`common.no`)})()),s.$$click=()=>R(e),l(s,()=>a(`common.edit`)),d.$$click=()=>e.id&&void v.deleteWebhook(e.id).then(L),l(d,()=>a(`common.delete`)),u(),t})()})),e}})}})),u(),n})()}p([`click`,`input`]);export{F as WebhooksManager};
|