@oktis-works/admin 0.14.0 → 0.15.0

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.
Files changed (78) hide show
  1. package/dist/client/_astro/{ActivityWidget.DmhtX3Xm.js → ActivityWidget.CedrZ3yN.js} +1 -1
  2. package/dist/client/_astro/{AdminBar.DKoQ5M3w.js → AdminBar.CkfSUzJJ.js} +1 -1
  3. package/dist/client/_astro/{ApiKeysManager.BaPrAyqm.js → ApiKeysManager.ChCtr3J2.js} +1 -1
  4. package/dist/client/_astro/{AtGlanceWidget.zlWIhmzI.js → AtGlanceWidget.DMrAc7qb.js} +1 -1
  5. package/dist/client/_astro/{CommentsManager.DROGQRli.js → CommentsManager.CtiI8mwU.js} +1 -1
  6. package/dist/client/_astro/ContentEditor.BQTSumnU.js +1 -0
  7. package/dist/client/_astro/{ContentEditor.ChA5r0aE.js → ContentEditor.Bl295osh.js} +1 -1
  8. package/dist/client/_astro/{ContentTypeWorkspace.Dj9dP14a.js → ContentTypeWorkspace.xZAsn-ok.js} +1 -1
  9. package/dist/client/_astro/{DashboardHome.Dn6_pJuX.js → DashboardHome.B7PYDcS1.js} +1 -1
  10. package/dist/client/_astro/{DashboardLayout.astro_astro_type_script_index_0_lang.NiobGnWg.js → DashboardLayout.astro_astro_type_script_index_0_lang.BFY8jBwE.js} +1 -1
  11. package/dist/client/_astro/{FieldGroupEditor.CiFoYYb2.js → FieldGroupEditor.BsV0u51p.js} +1 -1
  12. package/dist/client/_astro/{FieldGroupList.CdN99hvU.js → FieldGroupList.CXyFKdsR.js} +1 -1
  13. package/dist/client/_astro/{FieldRenderer.DYMREsip.js → FieldRenderer.2TxRD88c.js} +1 -1
  14. package/dist/client/_astro/{Footer.VGpnxqkW.js → Footer.BKD9_ctB.js} +1 -1
  15. package/dist/client/_astro/{GeneralSettings.mQ7FyhM-.js → GeneralSettings.Di8ILdOl.js} +1 -1
  16. package/dist/client/_astro/{LogsManager.BUJ7baOa.js → LogsManager.WBGR0Ci2.js} +1 -1
  17. package/dist/client/_astro/{MediaLibrary.DMvI8KXX.js → MediaLibrary.B5ozN2R7.js} +1 -1
  18. package/dist/client/_astro/{MenuManager._4YgarRt.js → MenuManager.9UORktNs.js} +1 -1
  19. package/dist/client/_astro/{Modal.DbBPpkbR.js → Modal.CPaZJlDP.js} +1 -1
  20. package/dist/client/_astro/PluginManager._RYLLtJI.js +112 -0
  21. package/dist/client/_astro/{PostTypesManager.CifIQbeV.js → PostTypesManager.B6dDnCOy.js} +1 -1
  22. package/dist/client/_astro/{QuickDraftWidget.CsG3_wS2.js → QuickDraftWidget.DCVYrBPm.js} +1 -1
  23. package/dist/client/_astro/{ResourceHubs.DedTFbiz.js → ResourceHubs.Cd0KB4Rx.js} +1 -1
  24. package/dist/client/_astro/{TaxonomiesManager.JqBPU1pf.js → TaxonomiesManager.9I03xqrR.js} +1 -1
  25. package/dist/client/_astro/{TaxonomyTermsManager.BLGRLt8p.js → TaxonomyTermsManager.btLVdHr-.js} +1 -1
  26. package/dist/client/_astro/{ThemeCustomizer.DrSQPj4W.js → ThemeCustomizer.CXg9hm9t.js} +1 -1
  27. package/dist/client/_astro/ThemeManager.BfQh8JJa.js +144 -0
  28. package/dist/client/_astro/{UserCreateForm.C54wZYbf.js → UserCreateForm.BAd11jYs.js} +1 -1
  29. package/dist/client/_astro/{UsersManager.BYTWz2I8.js → UsersManager.gkehfvoP.js} +1 -1
  30. package/dist/client/_astro/{WebhooksManager.DeJ_f1Gk.js → WebhooksManager.BCilUaGs.js} +1 -1
  31. package/dist/client/_astro/{api.flUgn70U.js → api.B03e8F6d.js} +1 -1
  32. package/dist/client/_astro/{extensions.DtuT3Phu.js → extensions.EzvpwBZm.js} +1 -1
  33. package/dist/client/_astro/{i18n.CBexpqud.js → i18n.LMZI7jyc.js} +1 -1
  34. package/dist/client/_astro/{login.astro_astro_type_script_index_0_lang.COYjmQTY.js → login.astro_astro_type_script_index_0_lang.BUOUZuDy.js} +1 -1
  35. package/dist/client/_astro/{pt-BR.DlIhl4_A.js → pt-BR.CfJP86YC.js} +1 -1
  36. package/dist/client/_astro/{store.CYzqtRKs.js → store.DJjOMYcw.js} +1 -1
  37. package/dist/server/chunks/{404_BxFvEXYq.mjs → 404_CIlW8Cz9.mjs} +1 -1
  38. package/dist/server/chunks/{BaseLayout_BTzlA_Yr.mjs → BaseLayout_DdN9Gl3i.mjs} +1 -1
  39. package/dist/server/chunks/{ContentEditor_DStZ4RZE.mjs → ContentEditor_GenRIOIJ.mjs} +3 -3
  40. package/dist/server/chunks/{DashboardLayout_PXoRmnBH.mjs → DashboardLayout_BY4AqWC6.mjs} +2 -2
  41. package/dist/server/chunks/{FieldRenderer_BlZgS0Im.mjs → FieldRenderer_pM3Tq7vY.mjs} +2 -2
  42. package/dist/server/chunks/{MediaLibrary_D7vu5VMd.mjs → MediaLibrary_woj8kWSK.mjs} +2 -2
  43. package/dist/server/chunks/{Modal_I_mBEOz2.mjs → Modal_BQZlVP1o.mjs} +1 -1
  44. package/dist/server/chunks/{_id__DFFoFesR.mjs → _id__CIrIQBGk.mjs} +2 -2
  45. package/dist/server/chunks/{_slug__DBH2w1la.mjs → _slug__DP5cppSD.mjs} +1 -1
  46. package/dist/server/chunks/{access_D1rk89Sh.mjs → access_Cr1RkoC8.mjs} +3 -3
  47. package/dist/server/chunks/{api-keys_BqhmvOer.mjs → api-keys_DxCfUQiR.mjs} +3 -3
  48. package/dist/server/chunks/{comments_D_ta2fip.mjs → comments_CDCO_DTQ.mjs} +2 -2
  49. package/dist/server/chunks/{custom-fields_Cl8P-rrK.mjs → custom-fields_DUby1Cd7.mjs} +2 -2
  50. package/dist/server/chunks/{customize_DgtzmFmz.mjs → customize_DITLWxTB.mjs} +2 -2
  51. package/dist/server/chunks/{edit_DTk4qFj5.mjs → edit_6xBPrb1J.mjs} +2 -2
  52. package/dist/server/chunks/{general_B-fEXuQn.mjs → general_CA6aT6cZ.mjs} +2 -2
  53. package/dist/server/chunks/{i18n_BmAxDr2Q.mjs → i18n_BBVOgA0q.mjs} +5 -32
  54. package/dist/server/chunks/{index_DXsKda1J.mjs → index_1C4PfYEy.mjs} +2 -2
  55. package/dist/server/chunks/{index_DI8jAAVQ.mjs → index_CO2SvpwW.mjs} +1 -1
  56. package/dist/server/chunks/{index_BcVtYp1L.mjs → index_Cn92C8CO.mjs} +2 -2
  57. package/dist/server/chunks/{index_BKjRvOw4.mjs → index_D2ypKpAG.mjs} +3 -3
  58. package/dist/server/chunks/{index_BXnSMGRk.mjs → index_D_AiNQGl.mjs} +2 -2
  59. package/dist/server/chunks/{login_BGPEB2l4.mjs → login_vyj4WhBt.mjs} +1 -1
  60. package/dist/server/chunks/{logs_XjDk7dqi.mjs → logs_BjuW-do3.mjs} +2 -2
  61. package/dist/server/chunks/{menus_Kqym4CNK.mjs → menus_CPi_m-b8.mjs} +2 -2
  62. package/dist/server/chunks/{new_Dnp7PIHP.mjs → new_BlENJv6A.mjs} +2 -2
  63. package/dist/server/chunks/{new_BiikYmvu.mjs → new_D_pNdD5e.mjs} +2 -2
  64. package/dist/server/chunks/plugins_sYgOSowJ.mjs +150 -0
  65. package/dist/server/chunks/{post-types_Dr4t-TYB.mjs → post-types_Bm8olePm.mjs} +2 -2
  66. package/dist/server/chunks/{pt-BR_DH_fNjEo.mjs → pt-BR_DYDMLZu_.mjs} +4 -19
  67. package/dist/server/chunks/{taxonomies_B0YzIdmD.mjs → taxonomies_DbsqX_QZ.mjs} +2 -2
  68. package/dist/server/chunks/{taxonomy_CCWZ58qQ.mjs → taxonomy_ByKdjp9j.mjs} +3 -3
  69. package/dist/server/chunks/{themes_C7G3LcIz.mjs → themes_BKAM_crI.mjs} +27 -129
  70. package/dist/server/chunks/{upload_BT3ud_vb.mjs → upload_CE4Lbc1u.mjs} +2 -2
  71. package/dist/server/chunks/{webhooks_CWW0L8EK.mjs → webhooks_CpruP30e.mjs} +2 -2
  72. package/dist/server/entry.mjs +28 -28
  73. package/dist/server/virtual_astro_middleware.mjs +1 -1
  74. package/package.json +1 -1
  75. package/dist/client/_astro/ContentEditor.CtCFQb14.js +0 -1
  76. package/dist/client/_astro/PluginManager.BozI4gXB.js +0 -136
  77. package/dist/client/_astro/ThemeManager.Csu39Xjr.js +0 -176
  78. package/dist/server/chunks/plugins_C6qX0SAE.mjs +0 -179
@@ -1,4 +1,4 @@
1
- import{S as e,h as t,l as n,p as r,r as i}from"./solid.Ck4Vtfe4.js";import{_ as a,a as o,f as s,l as c,m as l,o as u,p as d,s as f,u as p}from"./web.DD6VKaIp.js";import{n as m}from"./i18n.CBexpqud.js";import{n as h}from"./api.flUgn70U.js";import{DashboardWidget as g}from"./AtGlanceWidget.zlWIhmzI.js";var _=a(`<div class=quick-draft-wrapper><div class=quick-draft-content-wrapper>`),v=a(`<style>
1
+ import{S as e,h as t,l as n,p as r,r as i}from"./solid.Ck4Vtfe4.js";import{_ as a,a as o,f as s,l as c,m as l,o as u,p as d,s as f,u as p}from"./web.DD6VKaIp.js";import{n as m}from"./i18n.LMZI7jyc.js";import{n as h}from"./api.B03e8F6d.js";import{DashboardWidget as g}from"./AtGlanceWidget.DMrAc7qb.js";var _=a(`<div class=quick-draft-wrapper><div class=quick-draft-content-wrapper>`),v=a(`<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{S as e,a as t,f as n,h as r,l as i,p as a,r as o}from"./solid.Ck4Vtfe4.js";import{_ as s,a as c,f as l,l as u,m as d,o as f,p,s as m,u as h,v as g}from"./web.DD6VKaIp.js";import{n as _}from"./i18n.CBexpqud.js";import{n as v}from"./api.flUgn70U.js";import{t as y}from"./Modal.DbBPpkbR.js";import{t as b}from"./FloatingPanel.BetdW5N2.js";var x=s(`<input type=search class="input permission-picker__search">`),S=s(`<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=s(`<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=s(`<p class=icon-picker__count>`),T=s(`<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=s(`<span class=permission-picker__action-label>`),D=s(`<p class=permission-picker__empty>`),O=s(`<div class=permission-picker__row><span class=permission-picker__resource></span><!$><!/>`),k=s(`<label class=permission-picker__cell><input type=checkbox><span aria-hidden=true>✓`),A=s(`<span class="permission-picker__cell permission-picker__cell--empty">`),ee=s(`<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(e){let{t:s}=_(),[c,h]=r(!1),[v,y]=r(``),[I,L]=r(``),[R,z]=r(void 0),B=n(()=>new Set(e.value)),V=n(()=>e.value.filter(e=>!F(e))),H=n(()=>{let e=v().trim().toLowerCase();return e?M.filter(t=>t.includes(e)||s(`access.resources.${t}`).toLowerCase().includes(e)):M}),U=n(()=>{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=(t,n)=>{let r=P(t,n);e.onChange(B().has(r)?e.value.filter(e=>e!==r):[...e.value,r])},K=t=>{e.onChange(e.value.filter(e=>e!==t))},q=()=>{let t=I().trim().toLowerCase().replace(/\s+/g,`-`);t&&!B().has(t)&&e.onChange([...e.value,t]),L(``)},J=()=>{let t=e.value.length;if(t===0)return e.placeholder??s(`access.permissionsPlaceholder`);let n=new Set(e.value.map(e=>e.split(`:`)[1]??e));return s(`access.permissionsSummary`,{resources:n.size,count:t})};return(()=>{var n=f(T),r=n.firstChild,_=r.firstChild,M=_.nextSibling,N=r.nextSibling,[F,Y]=m(N.nextSibling);return r.$$click=()=>h(!c()),g(z,r),u(_,J),u(M,()=>c()?`▴`:`▾`),u(n,i(b,{get open(){return c()},get trigger(){return R()},onClose:()=>h(!1),class:`permission-picker__panel`,role:`dialog`,get"aria-label"(){return s(`access.permissions`)},minWidth:440,get children(){return[(()=>{var t=f(x);return t.$$input=e=>y(e.currentTarget.value),a(()=>p(t,`placeholder`,e.searchPlaceholder??s(`access.permissionSearch`))),a(()=>d(t,`value`,v())),l(),t})(),(()=>{var e=f(S),t=e.firstChild,n=t.firstChild.nextSibling,[r,c]=m(n.nextSibling),l=r.nextSibling,[h,g]=m(l.nextSibling),_=t.nextSibling,[v,y]=m(_.nextSibling);return u(t,i(o,{each:j,children:e=>(()=>{var t=f(E);return u(t,e),t})()}),r,c),u(t,i(o,{get each(){return U()},children:e=>(()=>{var t=f(E);return u(t,e),t})()}),h,g),u(e,i(o,{get each(){return H()},get fallback(){return(()=>{var e=f(D);return u(e,()=>s(`access.permissionNoMatches`)),e})()},children:e=>(()=>{var t=f(O),n=t.firstChild,r=n.nextSibling,[c,l]=m(r.nextSibling);return p(n,`title`,e),u(n,()=>s(`access.resources.${e}`)),u(t,i(o,{get each(){return[...j,...U()]},children:t=>W(t,e)?(()=>{var n=f(k),r=n.firstChild;return p(n,`title`,`${t}:${e}`),r.addEventListener(`change`,()=>G(t,e)),a(()=>n.classList.toggle(`is-checked`,!!B().has(P(t,e)))),a(()=>d(r,`checked`,B().has(P(t,e)))),n})():f(A)}),c,l),t})()}),v,y),e})(),(()=>{var e=f(C),t=e.firstChild,n=t.nextSibling,r=n.firstChild,[c,h]=m(r.nextSibling),g=c.nextSibling,_=g.firstChild,v=_.nextSibling;return u(t,()=>s(`access.customPermissions`)),u(n,i(o,{get each(){return V()},children:e=>(()=>{var t=f(ee),n=t.firstChild,r=n.nextSibling;return u(n,e),r.$$click=()=>K(e),a(()=>p(r,`aria-label`,`${s(`common.remove`)}: ${e}`)),l(),t})()}),c,h),g.addEventListener(`submit`,e=>{e.preventDefault(),q()}),_.$$input=e=>L(e.currentTarget.value),u(v,()=>s(`common.add`)),a(()=>p(_,`placeholder`,s(`access.customPermission`))),a(()=>d(_,`value`,I())),l(),e})(),i(t,{get when(){return e.value.length>0},get children(){var t=f(w);return u(t,()=>s(`access.permissionsSelected`,{count:e.value.length})),t}})]}}),F,Y),a(t=>{var n=c(),i=e.value.length===0;return n!==t.e&&p(r,`aria-expanded`,t.e=n),i!==t.t&&_.classList.toggle(`is-empty`,t.t=i),t},{e:void 0,t:void 0}),l(),n})()}c([`click`,`input`]);var L=s(`<div class="notice notice--error">`),R=s(`<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=s(`<button class="btn btn-danger btn-sm"type=button>`),B=s(`<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=s(`<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=s(`<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=s(`<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:n}=_(),[s,c]=r([]),[g,b]=r([]),[x,S]=r(null),[C,w]=r(null),[T,E]=r(!1),[D,O]=r(``),k=async()=>{try{c(await v.listRoles()),b((await v.listTenants({limit:100})).data??[])}catch(e){O(e instanceof Error?e.message:String(e))}};e(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 e=f(R),r=e.firstChild,[c,_]=m(r.nextSibling),b=c.nextSibling.firstChild,E=b.firstChild,O=E.firstChild,M=O.nextSibling,N=M.firstChild.nextSibling,[P,F]=m(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]=m(te.nextSibling),X=b.nextSibling,Z=X.firstChild,Q=Z.firstChild,$=Q.nextSibling,ie=$.firstChild.nextSibling,[ae,oe]=m(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]=m(pe.nextSibling);return u(e,i(t,{get when(){return D()},get children(){var e=f(L);return u(e,D),e}}),c,_),u(O,()=>n(`access.roles`)),M.$$click=()=>S({name:``,slug:``,permissions:[]}),u(M,()=>n(`common.create`),P,F),u(K,()=>n(`resources.name`)),u(q,()=>n(`resources.slug`)),u(J,()=>n(`access.permissions`)),u(Y,i(o,{get each(){return s()},children:e=>(()=>{var r=f(B),o=r.firstChild,s=o.nextSibling,c=s.firstChild,d=s.nextSibling,h=d.nextSibling,g=h.firstChild,_=g.nextSibling,[y,b]=m(_.nextSibling);return u(o,()=>e.name),u(c,()=>e.slug),u(d,()=>j(e)),g.$$click=()=>S({...e,permissions:[...e.permissions??[]]}),u(g,()=>n(`common.edit`)),u(h,i(t,{get when(){return!e.is_system},get children(){var t=f(z);return t.$$click=()=>void v.deleteRole(e.id).then(k),u(t,()=>n(`common.delete`)),l(),t}}),y,b),a(()=>p(d,`title`,(e.permissions??[]).join(`, `))),l(),r})()})),u(b,i(y,{get open(){return x()!==null},onClose:()=>S(null),get title(){return h(()=>!!x()?.id)()?n(`access.editRole`):n(`access.newRole`)},get children(){return i(t,{get when(){return x()},children:e=>(()=>{var t=f(V),r=t.firstChild,o=r.firstChild,s=o.nextSibling,c=r.nextSibling,g=c.firstChild,_=g.nextSibling,v=c.nextSibling,y=v.firstChild,b=y.nextSibling,[x,C]=m(b.nextSibling),w=v.nextSibling.firstChild,E=w.nextSibling;return t.addEventListener(`submit`,A),u(o,()=>n(`resources.name`)),s.$$input=t=>S({...e(),name:t.currentTarget.value}),u(g,()=>n(`resources.slug`)),_.$$input=t=>S({...e(),slug:t.currentTarget.value}),u(y,()=>n(`access.permissions`)),u(v,i(I,{get value(){return e().permissions??[]},onChange:t=>S({...e(),permissions:t})}),x,C),w.$$click=()=>S(null),u(w,()=>n(`common.cancel`)),u(E,(()=>{var e=h(()=>!!T());return()=>e()?n(`common.loading`):n(`common.save`)})()),a(e=>{var t=n(`resources.name`),r=n(`resources.slug`),i=T();return t!==e.e&&p(s,`placeholder`,e.e=t),r!==e.t&&p(_,`placeholder`,e.t=r),i!==e.a&&d(E,`disabled`,e.a=i),e},{e:void 0,t:void 0,a:void 0}),a(()=>d(s,`value`,e().name??``)),a(()=>d(_,`value`,e().slug??``)),l(),t})()})}}),ne,re),u(Q,()=>n(`access.tenants`)),$.$$click=()=>w({name:``,slug:``}),u($,()=>n(`common.create`),ae,oe),u(le,()=>n(`resources.name`)),u(ue,()=>n(`resources.slug`)),u(de,()=>n(`common.status`)),u(fe,i(o,{get each(){return g()},children:e=>(()=>{var t=f(H),r=t.firstChild,i=r.nextSibling,a=i.firstChild,o=i.nextSibling,s=o.nextSibling.firstChild,c=s.nextSibling;return u(r,()=>e.name),u(a,()=>e.slug),u(o,()=>e.status),s.$$click=()=>w({...e}),u(s,()=>n(`common.edit`)),c.$$click=()=>e.id&&void v.deleteTenant(e.id).then(k),u(c,()=>n(`common.delete`)),l(),t})()})),u(X,i(y,{get open(){return C()!==null},onClose:()=>w(null),get title(){return h(()=>!!C()?.id)()?n(`access.editTenant`):n(`access.newTenant`)},get children(){return i(t,{get when(){return C()},children:e=>(()=>{var t=f(U),r=t.firstChild,i=r.firstChild,o=i.nextSibling,s=r.nextSibling,c=s.firstChild,m=c.nextSibling,g=s.nextSibling,_=g.firstChild,v=_.nextSibling,y=g.nextSibling.firstChild,b=y.nextSibling;return t.addEventListener(`submit`,ee),u(i,()=>n(`resources.name`)),o.$$input=t=>w({...e(),name:t.currentTarget.value}),u(c,()=>n(`resources.slug`)),m.$$input=t=>w({...e(),slug:t.currentTarget.value}),u(_,()=>n(`access.domain`)),v.$$input=t=>w({...e(),domain:t.currentTarget.value}),y.$$click=()=>w(null),u(y,()=>n(`common.cancel`)),u(b,(()=>{var e=h(()=>!!T());return()=>e()?n(`common.loading`):n(`common.save`)})()),a(e=>{var t=n(`resources.name`),r=n(`resources.slug`),i=n(`access.domain`),a=T();return t!==e.e&&p(o,`placeholder`,e.e=t),r!==e.t&&p(m,`placeholder`,e.t=r),i!==e.a&&p(v,`placeholder`,e.a=i),a!==e.o&&d(b,`disabled`,e.o=a),e},{e:void 0,t:void 0,a:void 0,o:void 0}),a(()=>d(o,`value`,e().name??``)),a(()=>d(m,`value`,e().slug??``)),a(()=>d(v,`value`,e().domain??``)),l(),t})()})}}),me,he),l(),e})()}c([`click`,`input`]);export{W as AccessManager};
1
+ import{S as e,a as t,f as n,h as r,l as i,p as a,r as o}from"./solid.Ck4Vtfe4.js";import{_ as s,a as c,f as l,l as u,m as d,o as f,p,s as m,u as h,v as g}from"./web.DD6VKaIp.js";import{n as _}from"./i18n.LMZI7jyc.js";import{n as v}from"./api.B03e8F6d.js";import{t as y}from"./Modal.CPaZJlDP.js";import{t as b}from"./FloatingPanel.BetdW5N2.js";var x=s(`<input type=search class="input permission-picker__search">`),S=s(`<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=s(`<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=s(`<p class=icon-picker__count>`),T=s(`<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=s(`<span class=permission-picker__action-label>`),D=s(`<p class=permission-picker__empty>`),O=s(`<div class=permission-picker__row><span class=permission-picker__resource></span><!$><!/>`),k=s(`<label class=permission-picker__cell><input type=checkbox><span aria-hidden=true>✓`),A=s(`<span class="permission-picker__cell permission-picker__cell--empty">`),ee=s(`<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(e){let{t:s}=_(),[c,h]=r(!1),[v,y]=r(``),[I,L]=r(``),[R,z]=r(void 0),B=n(()=>new Set(e.value)),V=n(()=>e.value.filter(e=>!F(e))),H=n(()=>{let e=v().trim().toLowerCase();return e?M.filter(t=>t.includes(e)||s(`access.resources.${t}`).toLowerCase().includes(e)):M}),U=n(()=>{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=(t,n)=>{let r=P(t,n);e.onChange(B().has(r)?e.value.filter(e=>e!==r):[...e.value,r])},K=t=>{e.onChange(e.value.filter(e=>e!==t))},q=()=>{let t=I().trim().toLowerCase().replace(/\s+/g,`-`);t&&!B().has(t)&&e.onChange([...e.value,t]),L(``)},J=()=>{let t=e.value.length;if(t===0)return e.placeholder??s(`access.permissionsPlaceholder`);let n=new Set(e.value.map(e=>e.split(`:`)[1]??e));return s(`access.permissionsSummary`,{resources:n.size,count:t})};return(()=>{var n=f(T),r=n.firstChild,_=r.firstChild,M=_.nextSibling,N=r.nextSibling,[F,Y]=m(N.nextSibling);return r.$$click=()=>h(!c()),g(z,r),u(_,J),u(M,()=>c()?`▴`:`▾`),u(n,i(b,{get open(){return c()},get trigger(){return R()},onClose:()=>h(!1),class:`permission-picker__panel`,role:`dialog`,get"aria-label"(){return s(`access.permissions`)},minWidth:440,get children(){return[(()=>{var t=f(x);return t.$$input=e=>y(e.currentTarget.value),a(()=>p(t,`placeholder`,e.searchPlaceholder??s(`access.permissionSearch`))),a(()=>d(t,`value`,v())),l(),t})(),(()=>{var e=f(S),t=e.firstChild,n=t.firstChild.nextSibling,[r,c]=m(n.nextSibling),l=r.nextSibling,[h,g]=m(l.nextSibling),_=t.nextSibling,[v,y]=m(_.nextSibling);return u(t,i(o,{each:j,children:e=>(()=>{var t=f(E);return u(t,e),t})()}),r,c),u(t,i(o,{get each(){return U()},children:e=>(()=>{var t=f(E);return u(t,e),t})()}),h,g),u(e,i(o,{get each(){return H()},get fallback(){return(()=>{var e=f(D);return u(e,()=>s(`access.permissionNoMatches`)),e})()},children:e=>(()=>{var t=f(O),n=t.firstChild,r=n.nextSibling,[c,l]=m(r.nextSibling);return p(n,`title`,e),u(n,()=>s(`access.resources.${e}`)),u(t,i(o,{get each(){return[...j,...U()]},children:t=>W(t,e)?(()=>{var n=f(k),r=n.firstChild;return p(n,`title`,`${t}:${e}`),r.addEventListener(`change`,()=>G(t,e)),a(()=>n.classList.toggle(`is-checked`,!!B().has(P(t,e)))),a(()=>d(r,`checked`,B().has(P(t,e)))),n})():f(A)}),c,l),t})()}),v,y),e})(),(()=>{var e=f(C),t=e.firstChild,n=t.nextSibling,r=n.firstChild,[c,h]=m(r.nextSibling),g=c.nextSibling,_=g.firstChild,v=_.nextSibling;return u(t,()=>s(`access.customPermissions`)),u(n,i(o,{get each(){return V()},children:e=>(()=>{var t=f(ee),n=t.firstChild,r=n.nextSibling;return u(n,e),r.$$click=()=>K(e),a(()=>p(r,`aria-label`,`${s(`common.remove`)}: ${e}`)),l(),t})()}),c,h),g.addEventListener(`submit`,e=>{e.preventDefault(),q()}),_.$$input=e=>L(e.currentTarget.value),u(v,()=>s(`common.add`)),a(()=>p(_,`placeholder`,s(`access.customPermission`))),a(()=>d(_,`value`,I())),l(),e})(),i(t,{get when(){return e.value.length>0},get children(){var t=f(w);return u(t,()=>s(`access.permissionsSelected`,{count:e.value.length})),t}})]}}),F,Y),a(t=>{var n=c(),i=e.value.length===0;return n!==t.e&&p(r,`aria-expanded`,t.e=n),i!==t.t&&_.classList.toggle(`is-empty`,t.t=i),t},{e:void 0,t:void 0}),l(),n})()}c([`click`,`input`]);var L=s(`<div class="notice notice--error">`),R=s(`<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=s(`<button class="btn btn-danger btn-sm"type=button>`),B=s(`<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=s(`<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=s(`<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=s(`<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:n}=_(),[s,c]=r([]),[g,b]=r([]),[x,S]=r(null),[C,w]=r(null),[T,E]=r(!1),[D,O]=r(``),k=async()=>{try{c(await v.listRoles()),b((await v.listTenants({limit:100})).data??[])}catch(e){O(e instanceof Error?e.message:String(e))}};e(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 e=f(R),r=e.firstChild,[c,_]=m(r.nextSibling),b=c.nextSibling.firstChild,E=b.firstChild,O=E.firstChild,M=O.nextSibling,N=M.firstChild.nextSibling,[P,F]=m(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]=m(te.nextSibling),X=b.nextSibling,Z=X.firstChild,Q=Z.firstChild,$=Q.nextSibling,ie=$.firstChild.nextSibling,[ae,oe]=m(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]=m(pe.nextSibling);return u(e,i(t,{get when(){return D()},get children(){var e=f(L);return u(e,D),e}}),c,_),u(O,()=>n(`access.roles`)),M.$$click=()=>S({name:``,slug:``,permissions:[]}),u(M,()=>n(`common.create`),P,F),u(K,()=>n(`resources.name`)),u(q,()=>n(`resources.slug`)),u(J,()=>n(`access.permissions`)),u(Y,i(o,{get each(){return s()},children:e=>(()=>{var r=f(B),o=r.firstChild,s=o.nextSibling,c=s.firstChild,d=s.nextSibling,h=d.nextSibling,g=h.firstChild,_=g.nextSibling,[y,b]=m(_.nextSibling);return u(o,()=>e.name),u(c,()=>e.slug),u(d,()=>j(e)),g.$$click=()=>S({...e,permissions:[...e.permissions??[]]}),u(g,()=>n(`common.edit`)),u(h,i(t,{get when(){return!e.is_system},get children(){var t=f(z);return t.$$click=()=>void v.deleteRole(e.id).then(k),u(t,()=>n(`common.delete`)),l(),t}}),y,b),a(()=>p(d,`title`,(e.permissions??[]).join(`, `))),l(),r})()})),u(b,i(y,{get open(){return x()!==null},onClose:()=>S(null),get title(){return h(()=>!!x()?.id)()?n(`access.editRole`):n(`access.newRole`)},get children(){return i(t,{get when(){return x()},children:e=>(()=>{var t=f(V),r=t.firstChild,o=r.firstChild,s=o.nextSibling,c=r.nextSibling,g=c.firstChild,_=g.nextSibling,v=c.nextSibling,y=v.firstChild,b=y.nextSibling,[x,C]=m(b.nextSibling),w=v.nextSibling.firstChild,E=w.nextSibling;return t.addEventListener(`submit`,A),u(o,()=>n(`resources.name`)),s.$$input=t=>S({...e(),name:t.currentTarget.value}),u(g,()=>n(`resources.slug`)),_.$$input=t=>S({...e(),slug:t.currentTarget.value}),u(y,()=>n(`access.permissions`)),u(v,i(I,{get value(){return e().permissions??[]},onChange:t=>S({...e(),permissions:t})}),x,C),w.$$click=()=>S(null),u(w,()=>n(`common.cancel`)),u(E,(()=>{var e=h(()=>!!T());return()=>e()?n(`common.loading`):n(`common.save`)})()),a(e=>{var t=n(`resources.name`),r=n(`resources.slug`),i=T();return t!==e.e&&p(s,`placeholder`,e.e=t),r!==e.t&&p(_,`placeholder`,e.t=r),i!==e.a&&d(E,`disabled`,e.a=i),e},{e:void 0,t:void 0,a:void 0}),a(()=>d(s,`value`,e().name??``)),a(()=>d(_,`value`,e().slug??``)),l(),t})()})}}),ne,re),u(Q,()=>n(`access.tenants`)),$.$$click=()=>w({name:``,slug:``}),u($,()=>n(`common.create`),ae,oe),u(le,()=>n(`resources.name`)),u(ue,()=>n(`resources.slug`)),u(de,()=>n(`common.status`)),u(fe,i(o,{get each(){return g()},children:e=>(()=>{var t=f(H),r=t.firstChild,i=r.nextSibling,a=i.firstChild,o=i.nextSibling,s=o.nextSibling.firstChild,c=s.nextSibling;return u(r,()=>e.name),u(a,()=>e.slug),u(o,()=>e.status),s.$$click=()=>w({...e}),u(s,()=>n(`common.edit`)),c.$$click=()=>e.id&&void v.deleteTenant(e.id).then(k),u(c,()=>n(`common.delete`)),l(),t})()})),u(X,i(y,{get open(){return C()!==null},onClose:()=>w(null),get title(){return h(()=>!!C()?.id)()?n(`access.editTenant`):n(`access.newTenant`)},get children(){return i(t,{get when(){return C()},children:e=>(()=>{var t=f(U),r=t.firstChild,i=r.firstChild,o=i.nextSibling,s=r.nextSibling,c=s.firstChild,m=c.nextSibling,g=s.nextSibling,_=g.firstChild,v=_.nextSibling,y=g.nextSibling.firstChild,b=y.nextSibling;return t.addEventListener(`submit`,ee),u(i,()=>n(`resources.name`)),o.$$input=t=>w({...e(),name:t.currentTarget.value}),u(c,()=>n(`resources.slug`)),m.$$input=t=>w({...e(),slug:t.currentTarget.value}),u(_,()=>n(`access.domain`)),v.$$input=t=>w({...e(),domain:t.currentTarget.value}),y.$$click=()=>w(null),u(y,()=>n(`common.cancel`)),u(b,(()=>{var e=h(()=>!!T());return()=>e()?n(`common.loading`):n(`common.save`)})()),a(e=>{var t=n(`resources.name`),r=n(`resources.slug`),i=n(`access.domain`),a=T();return t!==e.e&&p(o,`placeholder`,e.e=t),r!==e.t&&p(m,`placeholder`,e.t=r),i!==e.a&&p(v,`placeholder`,e.a=i),a!==e.o&&d(b,`disabled`,e.o=a),e},{e:void 0,t:void 0,a:void 0,o:void 0}),a(()=>d(o,`value`,e().name??``)),a(()=>d(m,`value`,e().slug??``)),a(()=>d(v,`value`,e().domain??``)),l(),t})()})}}),me,he),l(),e})()}c([`click`,`input`]);export{W as AccessManager};
@@ -1 +1 @@
1
- import{S as e,a as t,h as n,l as r,p as i,r as a}from"./solid.Ck4Vtfe4.js";import{_ as o,a as s,f as c,l,m as u,o as d,p as f,s as p,u as m}from"./web.DD6VKaIp.js";import{n as h}from"./i18n.CBexpqud.js";import{n as g}from"./api.flUgn70U.js";var _=o(`<div class="notice notice--error">`),v=o(`<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=o(`<label><input type=checkbox> <!$><!/> (<!$><!/>)`),b=o(`<button type=button class="btn btn-danger">`),x=o(`<tr><td><!$><!/> (<!$><!/>)</td><td></td><td></td><td>`),ee=o(`<label style=margin-right:0.75rem><input type=checkbox> <!$><!/>`);function S(){let{t:o}=h(),[s,S]=n([]),[C,w]=n([]),[T,E]=n(``),[D,O]=n(!1),[k,A]=n({name:``,slug:``,hierarchical:!1,attachTo:[]}),j=async()=>{try{let[e,t]=await Promise.all([g.getTaxonomies(),g.getContentTypes()]);S(e),w(t)}catch(e){E(e instanceof Error?e.message:String(e))}};e(j);let M=async e=>{e.preventDefault(),E(``),O(!0);try{await g.createTaxonomy({name:k().name,slug:k().slug||void 0,hierarchical:k().hierarchical,attachTo:k().attachTo,labels:{singular_name:k().name}}),A({name:``,slug:``,hierarchical:!1,attachTo:[]}),await j(),window.dispatchEvent(new Event(`okcms:content-models-changed`))}catch(e){E(e instanceof Error?e.message:String(e))}finally{O(!1)}},N=async(e,t)=>{let n=e.attachTo?.includes(t);try{n?await g.detachTaxonomy(e.slug,t):await g.attachTaxonomy(e.slug,t),await j(),window.dispatchEvent(new Event(`okcms:content-models-changed`))}catch(e){E(e instanceof Error?e.message:String(e))}},P=async e=>{try{await g.deleteTaxonomy(e),await j(),window.dispatchEvent(new Event(`okcms:content-models-changed`))}catch(e){E(e instanceof Error?e.message:String(e))}};return(()=>{var e=d(v),n=e.firstChild,[h,g]=p(n.nextSibling),S=h.nextSibling,w=S.firstChild,E=w.nextSibling,O=E.firstChild,j=O.firstChild,[F,I]=p(j.nextSibling),L=F.nextSibling,R=O.nextSibling,z=R.firstChild,[B,V]=p(z.nextSibling),H=B.nextSibling,U=R.nextSibling,W=U.firstChild,G=W.nextSibling.nextSibling,[K,q]=p(G.nextSibling),J=E.nextSibling,Y=J.firstChild,te=Y.nextSibling,[ne,re]=p(te.nextSibling),X=J.nextSibling,Z=S.nextSibling.firstChild.firstChild,Q=Z.firstChild.firstChild,$=Q.nextSibling,ie=$.nextSibling,ae=Z.nextSibling;return l(e,r(t,{get when(){return T()},get children(){var e=d(_);return l(e,T),e}}),h,g),S.addEventListener(`submit`,M),l(w,()=>o(`settings.taxonomies.form.title`)),l(O,()=>o(`settings.taxonomies.form.name`),F,I),L.$$input=e=>A({...k(),name:e.currentTarget.value}),l(R,()=>o(`settings.taxonomies.form.slug`),B,V),H.$$input=e=>A({...k(),slug:e.currentTarget.value}),W.addEventListener(`change`,e=>A({...k(),hierarchical:e.currentTarget.checked})),l(U,()=>o(`settings.taxonomies.form.hierarchical`),K,q),l(Y,()=>o(`settings.taxonomies.form.attachTo`)),l(J,r(a,{get each(){return C()},children:e=>(()=>{var t=d(y),n=t.firstChild,r=n.nextSibling.nextSibling,[a,o]=p(r.nextSibling),s=a.nextSibling.nextSibling,[c,f]=p(s.nextSibling);return c.nextSibling,n.addEventListener(`change`,t=>A({...k(),attachTo:t.currentTarget.checked?[...k().attachTo,e.slug]:k().attachTo.filter(t=>t!==e.slug)})),l(t,()=>e.pluralLabel,a,o),l(t,()=>e.slug,c,f),i(()=>u(n,`checked`,k().attachTo.includes(e.slug))),t})()}),ne,re),l(X,()=>o(`settings.taxonomies.form.create`)),l(Q,()=>o(`settings.taxonomies.table.taxonomy`)),l($,()=>o(`settings.taxonomies.table.hierarchical`)),l(ie,()=>o(`settings.taxonomies.table.attachedTypes`)),l(ae,r(a,{get each(){return s()},children:e=>(()=>{var n=d(x),s=n.firstChild,f=s.firstChild,[h,g]=p(f.nextSibling),_=h.nextSibling.nextSibling,[v,y]=p(_.nextSibling);v.nextSibling;var S=s.nextSibling,w=S.nextSibling,T=w.nextSibling;return l(s,()=>e.name,h,g),l(s,()=>e.slug,v,y),l(S,(()=>{var t=m(()=>!!e.hierarchical);return()=>t()?o(`common.yes`):o(`common.no`)})()),l(w,r(a,{get each(){return C()},children:t=>(()=>{var n=d(ee),r=n.firstChild,a=r.nextSibling.nextSibling,[o,s]=p(a.nextSibling);return r.addEventListener(`change`,()=>N(e,t.slug)),l(n,()=>t.slug,o,s),i(()=>u(r,`checked`,e.attachTo?.includes(t.slug)??!1)),n})()})),l(T,r(t,{get when(){return e.source!==`CORE`},get children(){var t=d(b);return t.$$click=()=>P(e.slug),l(t,()=>o(`settings.taxonomies.table.actions.remove`)),c(),t}})),n})()})),i(e=>{var t=o(`settings.taxonomies.form.slugHint`),n=D();return t!==e.e&&f(H,`title`,e.e=t),n!==e.t&&u(X,`disabled`,e.t=n),e},{e:void 0,t:void 0}),i(()=>u(L,`value`,k().name)),i(()=>u(H,`value`,k().slug)),i(()=>u(W,`checked`,k().hierarchical)),c(),e})()}s([`input`,`click`]);export{S as TaxonomiesManager};
1
+ import{S as e,a as t,h as n,l as r,p as i,r as a}from"./solid.Ck4Vtfe4.js";import{_ as o,a as s,f as c,l,m as u,o as d,p as f,s as p,u as m}from"./web.DD6VKaIp.js";import{n as h}from"./i18n.LMZI7jyc.js";import{n as g}from"./api.B03e8F6d.js";var _=o(`<div class="notice notice--error">`),v=o(`<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=o(`<label><input type=checkbox> <!$><!/> (<!$><!/>)`),b=o(`<button type=button class="btn btn-danger">`),x=o(`<tr><td><!$><!/> (<!$><!/>)</td><td></td><td></td><td>`),ee=o(`<label style=margin-right:0.75rem><input type=checkbox> <!$><!/>`);function S(){let{t:o}=h(),[s,S]=n([]),[C,w]=n([]),[T,E]=n(``),[D,O]=n(!1),[k,A]=n({name:``,slug:``,hierarchical:!1,attachTo:[]}),j=async()=>{try{let[e,t]=await Promise.all([g.getTaxonomies(),g.getContentTypes()]);S(e),w(t)}catch(e){E(e instanceof Error?e.message:String(e))}};e(j);let M=async e=>{e.preventDefault(),E(``),O(!0);try{await g.createTaxonomy({name:k().name,slug:k().slug||void 0,hierarchical:k().hierarchical,attachTo:k().attachTo,labels:{singular_name:k().name}}),A({name:``,slug:``,hierarchical:!1,attachTo:[]}),await j(),window.dispatchEvent(new Event(`okcms:content-models-changed`))}catch(e){E(e instanceof Error?e.message:String(e))}finally{O(!1)}},N=async(e,t)=>{let n=e.attachTo?.includes(t);try{n?await g.detachTaxonomy(e.slug,t):await g.attachTaxonomy(e.slug,t),await j(),window.dispatchEvent(new Event(`okcms:content-models-changed`))}catch(e){E(e instanceof Error?e.message:String(e))}},P=async e=>{try{await g.deleteTaxonomy(e),await j(),window.dispatchEvent(new Event(`okcms:content-models-changed`))}catch(e){E(e instanceof Error?e.message:String(e))}};return(()=>{var e=d(v),n=e.firstChild,[h,g]=p(n.nextSibling),S=h.nextSibling,w=S.firstChild,E=w.nextSibling,O=E.firstChild,j=O.firstChild,[F,I]=p(j.nextSibling),L=F.nextSibling,R=O.nextSibling,z=R.firstChild,[B,V]=p(z.nextSibling),H=B.nextSibling,U=R.nextSibling,W=U.firstChild,G=W.nextSibling.nextSibling,[K,q]=p(G.nextSibling),J=E.nextSibling,Y=J.firstChild,te=Y.nextSibling,[ne,re]=p(te.nextSibling),X=J.nextSibling,Z=S.nextSibling.firstChild.firstChild,Q=Z.firstChild.firstChild,$=Q.nextSibling,ie=$.nextSibling,ae=Z.nextSibling;return l(e,r(t,{get when(){return T()},get children(){var e=d(_);return l(e,T),e}}),h,g),S.addEventListener(`submit`,M),l(w,()=>o(`settings.taxonomies.form.title`)),l(O,()=>o(`settings.taxonomies.form.name`),F,I),L.$$input=e=>A({...k(),name:e.currentTarget.value}),l(R,()=>o(`settings.taxonomies.form.slug`),B,V),H.$$input=e=>A({...k(),slug:e.currentTarget.value}),W.addEventListener(`change`,e=>A({...k(),hierarchical:e.currentTarget.checked})),l(U,()=>o(`settings.taxonomies.form.hierarchical`),K,q),l(Y,()=>o(`settings.taxonomies.form.attachTo`)),l(J,r(a,{get each(){return C()},children:e=>(()=>{var t=d(y),n=t.firstChild,r=n.nextSibling.nextSibling,[a,o]=p(r.nextSibling),s=a.nextSibling.nextSibling,[c,f]=p(s.nextSibling);return c.nextSibling,n.addEventListener(`change`,t=>A({...k(),attachTo:t.currentTarget.checked?[...k().attachTo,e.slug]:k().attachTo.filter(t=>t!==e.slug)})),l(t,()=>e.pluralLabel,a,o),l(t,()=>e.slug,c,f),i(()=>u(n,`checked`,k().attachTo.includes(e.slug))),t})()}),ne,re),l(X,()=>o(`settings.taxonomies.form.create`)),l(Q,()=>o(`settings.taxonomies.table.taxonomy`)),l($,()=>o(`settings.taxonomies.table.hierarchical`)),l(ie,()=>o(`settings.taxonomies.table.attachedTypes`)),l(ae,r(a,{get each(){return s()},children:e=>(()=>{var n=d(x),s=n.firstChild,f=s.firstChild,[h,g]=p(f.nextSibling),_=h.nextSibling.nextSibling,[v,y]=p(_.nextSibling);v.nextSibling;var S=s.nextSibling,w=S.nextSibling,T=w.nextSibling;return l(s,()=>e.name,h,g),l(s,()=>e.slug,v,y),l(S,(()=>{var t=m(()=>!!e.hierarchical);return()=>t()?o(`common.yes`):o(`common.no`)})()),l(w,r(a,{get each(){return C()},children:t=>(()=>{var n=d(ee),r=n.firstChild,a=r.nextSibling.nextSibling,[o,s]=p(a.nextSibling);return r.addEventListener(`change`,()=>N(e,t.slug)),l(n,()=>t.slug,o,s),i(()=>u(r,`checked`,e.attachTo?.includes(t.slug)??!1)),n})()})),l(T,r(t,{get when(){return e.source!==`CORE`},get children(){var t=d(b);return t.$$click=()=>P(e.slug),l(t,()=>o(`settings.taxonomies.table.actions.remove`)),c(),t}})),n})()})),i(e=>{var t=o(`settings.taxonomies.form.slugHint`),n=D();return t!==e.e&&f(H,`title`,e.e=t),n!==e.t&&u(X,`disabled`,e.t=n),e},{e:void 0,t:void 0}),i(()=>u(L,`value`,k().name)),i(()=>u(H,`value`,k().slug)),i(()=>u(W,`checked`,k().hierarchical)),c(),e})()}s([`input`,`click`]);export{S as TaxonomiesManager};
@@ -1 +1 @@
1
- import{S as e,a as t,h as n,l as r,p as i,r as a}from"./solid.Ck4Vtfe4.js";import{_ as o,a as s,f as c,l,m as u,o as d,s as f,u as p}from"./web.DD6VKaIp.js";import{n as m}from"./i18n.CBexpqud.js";import{n as h}from"./api.flUgn70U.js";import{n as g,t as _}from"./FieldRenderer.DYMREsip.js";var v=o(`<div class="notice notice--error">`),y=o(`<div class=term-meta-fields><h4></h4><!$><!/>`),b=o(`<button class=btn type=button>`),x=o(`<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><!$><!/>`),S=o(`<table class=table><thead><tr><th></th><th></th><th></th></tr></thead><tbody>`),C=o(`<div class=card><div class=card-header><div><h3></h3><p class=muted></p></div><span class=badge></span></div><!$><!/>`),w=o(`<div class=terms-panel><!$><!/><!$><!/><!$><!/>`),T=o(`<p class=muted>`),E=o(`<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 D(o){let{t:s}=m(),[D,O]=n(null),[k,A]=n([]),[j,M]=n(``),[N,P]=n(``),[F,I]=n(``),[L,R]=n(null),[z,B]=n(``),[V,H]=n(!1),[U,W]=n([]),[G,K]=n({}),q=async()=>{if(o.taxonomySlug)try{let[e,t]=await Promise.all([h.getTaxonomies(),h.getTaxonomyTerms(o.taxonomySlug)]);O(e.find(e=>e.slug===o.taxonomySlug)??null),A(t)}catch(e){B(e instanceof Error?e.message:String(e))}},J=async()=>{if(o.taxonomySlug)try{let e=await h.getFieldGroups({taxonomy:o.taxonomySlug}),t=await Promise.all(e.filter(e=>e.active).map(async e=>h.getFieldGroup(e.id)));W(g(t.flatMap(e=>e.fields??[])))}catch{W([])}};e(()=>{q(),J()});let Y=()=>{R(null),M(``),P(``),I(``),K({})},X=e=>{R(e.id??null),M(e.name),P(e.slug),I(e.description??``),K({...e.meta??{}}),B(``)},Z=async e=>{e.preventDefault(),B(``),H(!0);try{let e=k().find(e=>e.id===L())?.meta??{},t={name:j(),slug:N()||void 0,description:F()||void 0,...U().length>0?{meta:{...e,...G()}}:{}};L()?await h.updateTaxonomyTerm(o.taxonomySlug,L(),t):await h.createTaxonomyTerm(o.taxonomySlug,t),Y(),await q()}catch(e){B(e instanceof Error?e.message:String(e))}finally{H(!1)}},Q=async e=>{if(e.id&&confirm(s(`content.taxonomy.confirmDelete`,{name:e.name})))try{await h.deleteTaxonomyTerm(o.taxonomySlug,e.id),await q()}catch(e){B(e instanceof Error?e.message:String(e))}};return(()=>{var e=d(w),n=e.firstChild,[m,h]=f(n.nextSibling),g=m.nextSibling,[O,A]=f(g.nextSibling),R=O.nextSibling,[B,H]=f(R.nextSibling);return l(e,r(t,{get when(){return z()},get children(){var e=d(v);return l(e,z),e}}),m,h),l(e,r(t,{get when(){return p(()=>!D())()&&o.taxonomySlug},get children(){var e=d(v);return l(e,()=>s(`content.taxonomy.notFound`)),e}}),O,A),l(e,r(t,{get when(){return D()},get children(){return[(()=>{var e=d(x),n=e.firstChild,o=n.nextSibling,m=o.firstChild,[h,g]=f(m.nextSibling),v=h.nextSibling,S=o.nextSibling,C=S.firstChild,[w,T]=f(C.nextSibling),E=w.nextSibling,D=S.nextSibling,O=D.firstChild,[k,A]=f(O.nextSibling),R=k.nextSibling,z=D.nextSibling,[B,H]=f(z.nextSibling),W=B.nextSibling,q=W.firstChild,J=q.nextSibling,[X,Q]=f(J.nextSibling);return e.addEventListener(`submit`,Z),l(n,(()=>{var e=p(()=>!!L());return()=>e()?s(`content.taxonomy.editTerm`):s(`content.taxonomy.addTerm`)})()),l(o,()=>s(`content.taxonomy.name`),h,g),v.$$input=e=>M(e.currentTarget.value),l(S,()=>s(`content.taxonomy.slug`),w,T),E.$$input=e=>P(e.currentTarget.value),l(D,()=>s(`content.taxonomy.description`),k,A),R.$$input=e=>I(e.currentTarget.value),l(e,r(t,{get when(){return U().length>0},get children(){var e=d(y),t=e.firstChild,n=t.nextSibling,[i,o]=f(n.nextSibling);return l(t,()=>s(`content.taxonomy.termFields`)),l(e,r(a,{get each(){return U()},children:e=>r(_,{field:e,get values(){return G()},onChange:(e,t)=>K({...G(),[e]:t}),t:s})}),i,o),e}}),B,H),l(q,(()=>{var e=p(()=>!!L());return()=>e()?s(`common.save`):s(`content.taxonomy.add`)})()),l(W,r(t,{get when(){return L()},get children(){var e=d(b);return e.$$click=Y,l(e,()=>s(`common.cancel`)),c(),e}}),X,Q),i(()=>u(q,`disabled`,V())),i(()=>u(v,`value`,j())),i(()=>u(E,`value`,N())),i(()=>u(R,`value`,F())),c(),e})(),(()=>{var e=d(C),n=e.firstChild,i=n.firstChild,u=i.firstChild,m=u.nextSibling,h=i.nextSibling,g=n.nextSibling,[_,v]=f(g.nextSibling);return l(u,()=>D().name),l(m,(()=>{var e=p(()=>!!o.contentType);return()=>e()?`${s(`content.taxonomy.attachedTo`)}: ${o.contentType}`:s(`content.taxonomy.descriptionHint`)})()),l(h,()=>k().length),l(e,r(t,{get when(){return k().length>0},get fallback(){return(()=>{var e=d(T);return l(e,()=>s(`content.taxonomy.empty`)),e})()},get children(){var e=d(S),t=e.firstChild,n=t.firstChild.firstChild,i=n.nextSibling,o=t.nextSibling;return l(n,()=>s(`content.taxonomy.name`)),l(i,()=>s(`content.taxonomy.slug`)),l(o,r(a,{get each(){return k()},children:e=>(()=>{var t=d(E),n=t.firstChild,r=n.nextSibling,i=r.nextSibling.firstChild,a=i.nextSibling.nextSibling;return l(n,()=>e.name),l(r,()=>e.slug),i.$$click=()=>X(e),l(i,()=>s(`common.edit`)),a.$$click=()=>void Q(e),l(a,()=>s(`content.taxonomy.delete`)),c(),t})()})),e}}),_,v),e})()]}}),B,H),e})()}s([`input`,`click`]);export{D as TaxonomyTermsManager};
1
+ import{S as e,a as t,h as n,l as r,p as i,r as a}from"./solid.Ck4Vtfe4.js";import{_ as o,a as s,f as c,l,m as u,o as d,s as f,u as p}from"./web.DD6VKaIp.js";import{n as m}from"./i18n.LMZI7jyc.js";import{n as h}from"./api.B03e8F6d.js";import{n as g,t as _}from"./FieldRenderer.2TxRD88c.js";var v=o(`<div class="notice notice--error">`),y=o(`<div class=term-meta-fields><h4></h4><!$><!/>`),b=o(`<button class=btn type=button>`),x=o(`<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><!$><!/>`),S=o(`<table class=table><thead><tr><th></th><th></th><th></th></tr></thead><tbody>`),C=o(`<div class=card><div class=card-header><div><h3></h3><p class=muted></p></div><span class=badge></span></div><!$><!/>`),w=o(`<div class=terms-panel><!$><!/><!$><!/><!$><!/>`),T=o(`<p class=muted>`),E=o(`<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 D(o){let{t:s}=m(),[D,O]=n(null),[k,A]=n([]),[j,M]=n(``),[N,P]=n(``),[F,I]=n(``),[L,R]=n(null),[z,B]=n(``),[V,H]=n(!1),[U,W]=n([]),[G,K]=n({}),q=async()=>{if(o.taxonomySlug)try{let[e,t]=await Promise.all([h.getTaxonomies(),h.getTaxonomyTerms(o.taxonomySlug)]);O(e.find(e=>e.slug===o.taxonomySlug)??null),A(t)}catch(e){B(e instanceof Error?e.message:String(e))}},J=async()=>{if(o.taxonomySlug)try{let e=await h.getFieldGroups({taxonomy:o.taxonomySlug}),t=await Promise.all(e.filter(e=>e.active).map(async e=>h.getFieldGroup(e.id)));W(g(t.flatMap(e=>e.fields??[])))}catch{W([])}};e(()=>{q(),J()});let Y=()=>{R(null),M(``),P(``),I(``),K({})},X=e=>{R(e.id??null),M(e.name),P(e.slug),I(e.description??``),K({...e.meta??{}}),B(``)},Z=async e=>{e.preventDefault(),B(``),H(!0);try{let e=k().find(e=>e.id===L())?.meta??{},t={name:j(),slug:N()||void 0,description:F()||void 0,...U().length>0?{meta:{...e,...G()}}:{}};L()?await h.updateTaxonomyTerm(o.taxonomySlug,L(),t):await h.createTaxonomyTerm(o.taxonomySlug,t),Y(),await q()}catch(e){B(e instanceof Error?e.message:String(e))}finally{H(!1)}},Q=async e=>{if(e.id&&confirm(s(`content.taxonomy.confirmDelete`,{name:e.name})))try{await h.deleteTaxonomyTerm(o.taxonomySlug,e.id),await q()}catch(e){B(e instanceof Error?e.message:String(e))}};return(()=>{var e=d(w),n=e.firstChild,[m,h]=f(n.nextSibling),g=m.nextSibling,[O,A]=f(g.nextSibling),R=O.nextSibling,[B,H]=f(R.nextSibling);return l(e,r(t,{get when(){return z()},get children(){var e=d(v);return l(e,z),e}}),m,h),l(e,r(t,{get when(){return p(()=>!D())()&&o.taxonomySlug},get children(){var e=d(v);return l(e,()=>s(`content.taxonomy.notFound`)),e}}),O,A),l(e,r(t,{get when(){return D()},get children(){return[(()=>{var e=d(x),n=e.firstChild,o=n.nextSibling,m=o.firstChild,[h,g]=f(m.nextSibling),v=h.nextSibling,S=o.nextSibling,C=S.firstChild,[w,T]=f(C.nextSibling),E=w.nextSibling,D=S.nextSibling,O=D.firstChild,[k,A]=f(O.nextSibling),R=k.nextSibling,z=D.nextSibling,[B,H]=f(z.nextSibling),W=B.nextSibling,q=W.firstChild,J=q.nextSibling,[X,Q]=f(J.nextSibling);return e.addEventListener(`submit`,Z),l(n,(()=>{var e=p(()=>!!L());return()=>e()?s(`content.taxonomy.editTerm`):s(`content.taxonomy.addTerm`)})()),l(o,()=>s(`content.taxonomy.name`),h,g),v.$$input=e=>M(e.currentTarget.value),l(S,()=>s(`content.taxonomy.slug`),w,T),E.$$input=e=>P(e.currentTarget.value),l(D,()=>s(`content.taxonomy.description`),k,A),R.$$input=e=>I(e.currentTarget.value),l(e,r(t,{get when(){return U().length>0},get children(){var e=d(y),t=e.firstChild,n=t.nextSibling,[i,o]=f(n.nextSibling);return l(t,()=>s(`content.taxonomy.termFields`)),l(e,r(a,{get each(){return U()},children:e=>r(_,{field:e,get values(){return G()},onChange:(e,t)=>K({...G(),[e]:t}),t:s})}),i,o),e}}),B,H),l(q,(()=>{var e=p(()=>!!L());return()=>e()?s(`common.save`):s(`content.taxonomy.add`)})()),l(W,r(t,{get when(){return L()},get children(){var e=d(b);return e.$$click=Y,l(e,()=>s(`common.cancel`)),c(),e}}),X,Q),i(()=>u(q,`disabled`,V())),i(()=>u(v,`value`,j())),i(()=>u(E,`value`,N())),i(()=>u(R,`value`,F())),c(),e})(),(()=>{var e=d(C),n=e.firstChild,i=n.firstChild,u=i.firstChild,m=u.nextSibling,h=i.nextSibling,g=n.nextSibling,[_,v]=f(g.nextSibling);return l(u,()=>D().name),l(m,(()=>{var e=p(()=>!!o.contentType);return()=>e()?`${s(`content.taxonomy.attachedTo`)}: ${o.contentType}`:s(`content.taxonomy.descriptionHint`)})()),l(h,()=>k().length),l(e,r(t,{get when(){return k().length>0},get fallback(){return(()=>{var e=d(T);return l(e,()=>s(`content.taxonomy.empty`)),e})()},get children(){var e=d(S),t=e.firstChild,n=t.firstChild.firstChild,i=n.nextSibling,o=t.nextSibling;return l(n,()=>s(`content.taxonomy.name`)),l(i,()=>s(`content.taxonomy.slug`)),l(o,r(a,{get each(){return k()},children:e=>(()=>{var t=d(E),n=t.firstChild,r=n.nextSibling,i=r.nextSibling.firstChild,a=i.nextSibling.nextSibling;return l(n,()=>e.name),l(r,()=>e.slug),i.$$click=()=>X(e),l(i,()=>s(`common.edit`)),a.$$click=()=>void Q(e),l(a,()=>s(`content.taxonomy.delete`)),c(),t})()})),e}}),_,v),e})()]}}),B,H),e})()}s([`input`,`click`]);export{D as TaxonomyTermsManager};
@@ -1,4 +1,4 @@
1
- import{S as e,a as t,f as n,h as r,l as i,p as a,r as o}from"./solid.Ck4Vtfe4.js";import{_ as s,a as c,f as l,l as u,m as d,o as f,p,s as m,u as h}from"./web.DD6VKaIp.js";import{n as g}from"./i18n.CBexpqud.js";import{n as _}from"./api.flUgn70U.js";var v=s(`<p class=muted>`),y=s(`<span class=customizer__saved>`),b=s(`<div class="alert alert-error">`),x=s(`<div class=customizer__layout><aside class=customizer__panel><h3><!$><!/> · <!$><!/></h3><!$><!/><!$><!/><div class=customizer__actions><button class="btn btn-primary"></button><button class="btn btn-secondary"></button><button class="btn btn-secondary"></button></div><!$><!/><!$><!/><p class="muted customizer__hint"></p></aside><section class=customizer__preview><div class=customizer__preview-bar><input class=input placeholder=/></div><iframe class=customizer__frame>`),S=s(`<div class=customizer><!$><!/><style>
1
+ import{S as e,a as t,f as n,h as r,l as i,p as a,r as o}from"./solid.Ck4Vtfe4.js";import{_ as s,a as c,f as l,l as u,m as d,o as f,p,s as m,u as h}from"./web.DD6VKaIp.js";import{n as g}from"./i18n.LMZI7jyc.js";import{n as _}from"./api.B03e8F6d.js";var v=s(`<p class=muted>`),y=s(`<span class=customizer__saved>`),b=s(`<div class="alert alert-error">`),x=s(`<div class=customizer__layout><aside class=customizer__panel><h3><!$><!/> · <!$><!/></h3><!$><!/><!$><!/><div class=customizer__actions><button class="btn btn-primary"></button><button class="btn btn-secondary"></button><button class="btn btn-secondary"></button></div><!$><!/><!$><!/><p class="muted customizer__hint"></p></aside><section class=customizer__preview><div class=customizer__preview-bar><input class=input placeholder=/></div><iframe class=customizer__frame>`),S=s(`<div class=customizer><!$><!/><style>
2
2
  .customizer__layout {
3
3
  display: grid;
4
4
  grid-template-columns: minmax(280px, 340px) 1fr;
@@ -0,0 +1,144 @@
1
+ import{S as e,a as t,h as n,l as r,p as i,r as a}from"./solid.Ck4Vtfe4.js";import{_ as o,a as s,f as c,i as l,l as u,m as d,o as f,p,s as m,u as h}from"./web.DD6VKaIp.js";import{n as g}from"./i18n.LMZI7jyc.js";import{n as _}from"./api.B03e8F6d.js";var v=o(`<div class=theme-manager><div class=theme-toolbar><p class=page-hint></p><button class="btn btn-refresh"></button></div><!$><!/><!$><!/><!$><!/><!$><!/><style>
2
+ .theme-toolbar {
3
+ display: flex;
4
+ align-items: flex-start;
5
+ justify-content: space-between;
6
+ gap: 1rem;
7
+ margin-bottom: 1.25rem;
8
+ }
9
+ .page-hint {
10
+ margin: 0;
11
+ color: var(--color-muted);
12
+ font-size: 0.8125rem;
13
+ }
14
+ .btn-refresh {
15
+ flex-shrink: 0;
16
+ }
17
+ .themes-grid {
18
+ display: grid;
19
+ grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
20
+ gap: 1.5rem;
21
+ }
22
+ .theme-card {
23
+ background: var(--color-surface);
24
+ border: 1px solid var(--color-border);
25
+ border-radius: var(--radius-lg);
26
+ padding: 1.5rem;
27
+ display: flex;
28
+ flex-direction: column;
29
+ gap: 1rem;
30
+ transition: all 0.2s;
31
+ }
32
+ .theme-card:hover {
33
+ border-color: var(--color-primary);
34
+ box-shadow: var(--shadow-md);
35
+ }
36
+ .theme-card.active {
37
+ border-color: var(--color-primary);
38
+ box-shadow: 0 0 0 1px var(--color-primary), var(--shadow-md);
39
+ }
40
+ .theme-preview {
41
+ position: relative;
42
+ }
43
+ .theme-preview__img {
44
+ display: block;
45
+ width: 100%;
46
+ border-radius: var(--radius-md);
47
+ border: 1px solid var(--color-border);
48
+ }
49
+ .theme-badge {
50
+ position: absolute;
51
+ top: 0.5rem;
52
+ right: 0.5rem;
53
+ background: var(--color-primary);
54
+ color: var(--color-primary-contrast);
55
+ padding: 0.25rem 0.5rem;
56
+ border-radius: var(--radius-full);
57
+ font-size: 0.625rem;
58
+ font-weight: 700;
59
+ text-transform: uppercase;
60
+ }
61
+ .theme-info {
62
+ display: flex;
63
+ flex-direction: column;
64
+ gap: 0.5rem;
65
+ }
66
+ .theme-info h3 {
67
+ margin: 0;
68
+ font-size: 1.125rem;
69
+ font-weight: 600;
70
+ }
71
+ .theme-version {
72
+ margin: 0;
73
+ font-size: 0.75rem;
74
+ color: var(--color-muted);
75
+ }
76
+ .theme-desc {
77
+ margin: 0;
78
+ font-size: 0.8125rem;
79
+ color: var(--color-text);
80
+ line-height: 1.5;
81
+ }
82
+ .theme-status {
83
+ display: flex;
84
+ align-items: center;
85
+ gap: 0.5rem;
86
+ }
87
+ .status-badge {
88
+ display: inline-flex;
89
+ align-items: center;
90
+ padding: 0.25rem 0.5rem;
91
+ border-radius: var(--radius-full);
92
+ font-size: 0.625rem;
93
+ font-weight: 600;
94
+ text-transform: uppercase;
95
+ }
96
+ .status-active {
97
+ background: var(--color-success-soft);
98
+ color: var(--color-success);
99
+ }
100
+ .status-installed {
101
+ background: var(--color-primary-soft);
102
+ color: var(--color-primary);
103
+ }
104
+ .status-inactive {
105
+ background: var(--color-muted-soft);
106
+ color: var(--color-muted);
107
+ }
108
+ .theme-actions {
109
+ margin-top: 0.5rem;
110
+ display: flex;
111
+ flex-wrap: wrap;
112
+ gap: 0.5rem;
113
+ }
114
+ .btn-loading {
115
+ opacity: 0.6;
116
+ cursor: wait;
117
+ }
118
+ .empty-state {
119
+ grid-column: 1 / -1;
120
+ padding: 3rem;
121
+ text-align: center;
122
+ color: var(--color-muted);
123
+ }
124
+ .alert {
125
+ padding: 0.75rem 1rem;
126
+ border-radius: var(--radius-md);
127
+ margin-bottom: 1rem;
128
+ }
129
+ .alert-error {
130
+ background: var(--color-error-soft);
131
+ color: var(--color-error);
132
+ border: 1px solid var(--color-error);
133
+ }
134
+ .alert-warning {
135
+ background: var(--color-warning-soft);
136
+ color: var(--color-warning);
137
+ border: 1px solid var(--color-warning);
138
+ }
139
+ .skeleton {
140
+ padding: 2rem;
141
+ text-align: center;
142
+ color: var(--color-muted);
143
+ }
144
+ `),y=o(`<div class="alert alert-error">`),b=o(`<div class="alert alert-warning">`),x=o(`<div class=skeleton>Loading...`),S=o(`<div class=themes-grid><!$><!/><!$><!/>`),C=o(`<img class=theme-preview__img alt loading=lazy>`,!0,!1,!1),w=o(`<div><div class=theme-preview><!$><!/><!$><!/></div><div class=theme-info><h3></h3><p class=theme-version><!$><!/>: <!$><!/></p><p class=theme-status><span></span></p><!$><!/></div><div class=theme-actions><button>`),T=o(`<div class="theme-badge active-badge">`),E=o(`<p class=theme-desc>`),D=o(`<div class=empty-state>`);function O(){let{t:o}=g(),[s,O]=n([]),[k,A]=n(!0),[j,M]=n(null),[N,P]=n(null),[F,I]=n(null);e(async()=>{await L()});async function L(){M(null),P(null);try{A(!0);let e;try{e=await _.syncThemes()}catch{e=await _.getThemes()}O(e)}catch{M(o(`themes.loadError`))}finally{A(!1)}}async function R(e){let t=e.status===`ACTIVE`;if(M(null),P(null),t&&s().length<=1){P(o(`themes.deactivateBlocked`));return}I(e.id);try{let n=t?await _.deactivateTheme(e.id):await _.activateTheme(e.id);O(s().map(t=>t.id===e.id?n:t.status===`ACTIVE`&&n.status===`ACTIVE`?{...t,status:`INACTIVE`}:t))}catch{M(o(t?`themes.deactivateError`:`themes.activateError`))}finally{I(null)}}function z(e){let t=e.manifest?.preview??e.manifest?.screenshots?.[0];return!t||typeof t!=`string`?null:/^(https?:)?\/\//.test(t)||t.startsWith(`/`)?t:`/themes/${encodeURIComponent(e.name)}/${t}`}let B=e=>{switch(e){case`ACTIVE`:return o(`themes.status.active`);case`INSTALLED`:return o(`themes.status.installed`);case`INACTIVE`:return o(`themes.status.inactive`);default:return e}},V=e=>{switch(e){case`ACTIVE`:return`status-active`;case`INSTALLED`:return`status-installed`;case`INACTIVE`:return`status-inactive`;default:return``}};return(()=>{var e=f(v),n=e.firstChild,g=n.firstChild,_=g.nextSibling,O=n.nextSibling,[A,M]=m(O.nextSibling),P=A.nextSibling,[I,H]=m(P.nextSibling),U=I.nextSibling,[W,G]=m(U.nextSibling),K=W.nextSibling,[q,J]=m(K.nextSibling);return q.nextSibling,u(g,()=>o(`themes.directoryHint`)),_.$$click=L,u(_,()=>o(`themes.reload`)),u(e,(()=>{var e=h(()=>!!j());return()=>e()&&(()=>{var e=f(y);return u(e,j),e})()})(),A,M),u(e,(()=>{var e=h(()=>!!N());return()=>e()&&(()=>{var e=f(b);return u(e,N),e})()})(),I,H),u(e,(()=>{var e=h(()=>!!k());return()=>e()&&f(x)})(),W,G),u(e,(()=>{var e=h(()=>!k());return()=>e()&&(()=>{var e=f(S),n=e.firstChild,[g,_]=m(n.nextSibling),v=g.nextSibling,[y,b]=m(v.nextSibling);return u(e,r(a,{get each(){return s()},children:e=>{let n=z(e);return(()=>{var a=f(w),s=a.firstChild,g=s.firstChild,[_,v]=m(g.nextSibling),y=_.nextSibling,[b,x]=m(y.nextSibling),S=s.nextSibling,D=S.firstChild,O=D.nextSibling,k=O.firstChild,[A,j]=m(k.nextSibling),M=A.nextSibling.nextSibling,[N,P]=m(M.nextSibling),I=O.nextSibling,L=I.firstChild,z=I.nextSibling,[H,U]=m(z.nextSibling),W=S.nextSibling.firstChild;return u(s,r(t,{when:n,get children(){var e=f(C);return e.addEventListener(`error`,e=>{e.currentTarget.style.display=`none`}),p(e,`src`,n),e}}),_,v),u(s,(()=>{var t=h(()=>e.status===`ACTIVE`);return()=>t()&&(()=>{var e=f(T);return u(e,()=>o(`themes.active`)),e})()})(),b,x),u(D,()=>e.name),u(O,()=>o(`themes.version`),A,j),u(O,()=>e.version,N,P),u(L,()=>B(e.status)),u(S,(()=>{var t=h(()=>!!e.manifest?.description);return()=>t()&&(()=>{var t=f(E);return u(t,()=>e.manifest.description),t})()})(),H,U),W.$$click=()=>R(e),u(W,(()=>{var t=h(()=>e.status===`ACTIVE`);return()=>t()?o(`themes.deactivate`):o(`themes.activate`)})()),i(t=>{var n=`theme-card ${e.status===`ACTIVE`?`active`:``}`,r=`status-badge ${V(e.status)}`,i=`btn ${F()===e.id?`btn-loading`:``}`,o=F()!==null;return n!==t.e&&l(a,t.e=n),r!==t.t&&l(L,t.t=r),i!==t.a&&l(W,t.a=i),o!==t.o&&d(W,`disabled`,t.o=o),t},{e:void 0,t:void 0,a:void 0,o:void 0}),c(),a})()}}),g,_),u(e,(()=>{var e=h(()=>s().length===0);return()=>e()&&(()=>{var e=f(D);return u(e,()=>o(`themes.empty`)),e})()})(),y,b),e})()})(),q,J),i(()=>d(_,`disabled`,k())),c(),e})()}s([`click`]);export{O as ThemeManager};
@@ -1 +1 @@
1
- import{S as e,a as t,h as n,l as r,p as i,r as a}from"./solid.Ck4Vtfe4.js";import{_ as o,a as s,f as c,l,m as u,o as d,s as f,u as ee}from"./web.DD6VKaIp.js";import{n as p}from"./i18n.CBexpqud.js";import{n as m}from"./api.flUgn70U.js";var h=o(`<div class="notice notice--error">`),te=o(`<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=o(`<option><!$><!/> (<!$><!/>)`);function _(){let{t:o}=p(),[s,_]=n(``),[v,y]=n(``),[b,ne]=n(``),[x,S]=n(``),[C,w]=n([]),[T,E]=n(``),[D,O]=n(!1);e(async()=>{try{let e=await m.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(o(`users.detail.passwordError`));return}O(!0);try{await m.createUser({name:s(),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 e=d(te),n=e.firstChild,[p,m]=f(n.nextSibling),w=p.nextSibling,E=w.firstChild,O=E.nextSibling,k=O.firstChild,ie=k.firstChild,[A,j]=f(ie.nextSibling),M=A.nextSibling,N=k.nextSibling,P=N.firstChild,[F,ae]=f(P.nextSibling),I=F.nextSibling,L=N.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 l(e,r(t,{get when(){return T()},get children(){var e=d(h);return l(e,T),e}}),p,m),w.addEventListener(`submit`,re),l(E,()=>o(`users.new`)),l(k,()=>o(`users.detail.fields.name`),A,j),M.$$input=e=>_(e.currentTarget.value),l(N,()=>o(`users.detail.fields.email`),F,ae),I.$$input=e=>y(e.currentTarget.value),l(L,()=>o(`users.detail.fields.password`),R,z),l(B,()=>o(`users.detail.passwordPrompt`,{email:``})),V.$$input=e=>ne(e.currentTarget.value),l(H,()=>o(`users.detail.fields.role`),W,G),K.addEventListener(`change`,e=>S(e.currentTarget.value)),l(q,()=>o(`users.detail.rolePlaceholder`)),l(K,r(a,{get each(){return C()},children:e=>(()=>{var t=d(g),n=t.firstChild,[r,a]=f(n.nextSibling),o=r.nextSibling.nextSibling,[s,c]=f(o.nextSibling);return s.nextSibling,l(t,()=>e.name,r,a),l(t,()=>e.slug,s,c),i(()=>u(t,`value`,e.id)),t})()}),ce,le),l(J,()=>o(`common.save`),Y,de),l(J,()=>o(`users.new`).toLowerCase(),X,pe),l(J,()=>o(`users.detail.fields.role`),Z,he),l(J,()=>o(`users.toolbar.newBtn`).toLowerCase(),Q,_e),l($,(()=>{var e=ee(()=>!!D());return()=>e()?o(`common.loading`):o(`common.create`)})()),l(ve,()=>o(`common.back`)),i(()=>u($,`disabled`,D())),i(()=>u(M,`value`,s())),i(()=>u(I,`value`,v())),i(()=>u(V,`value`,b())),i(()=>u(K,`value`,x())),c(),e})()}s([`input`]);export{_ as UserCreateForm};
1
+ import{S as e,a as t,h as n,l as r,p as i,r as a}from"./solid.Ck4Vtfe4.js";import{_ as o,a as s,f as c,l,m as u,o as d,s as f,u as ee}from"./web.DD6VKaIp.js";import{n as p}from"./i18n.LMZI7jyc.js";import{n as m}from"./api.B03e8F6d.js";var h=o(`<div class="notice notice--error">`),te=o(`<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=o(`<option><!$><!/> (<!$><!/>)`);function _(){let{t:o}=p(),[s,_]=n(``),[v,y]=n(``),[b,ne]=n(``),[x,S]=n(``),[C,w]=n([]),[T,E]=n(``),[D,O]=n(!1);e(async()=>{try{let e=await m.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(o(`users.detail.passwordError`));return}O(!0);try{await m.createUser({name:s(),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 e=d(te),n=e.firstChild,[p,m]=f(n.nextSibling),w=p.nextSibling,E=w.firstChild,O=E.nextSibling,k=O.firstChild,ie=k.firstChild,[A,j]=f(ie.nextSibling),M=A.nextSibling,N=k.nextSibling,P=N.firstChild,[F,ae]=f(P.nextSibling),I=F.nextSibling,L=N.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 l(e,r(t,{get when(){return T()},get children(){var e=d(h);return l(e,T),e}}),p,m),w.addEventListener(`submit`,re),l(E,()=>o(`users.new`)),l(k,()=>o(`users.detail.fields.name`),A,j),M.$$input=e=>_(e.currentTarget.value),l(N,()=>o(`users.detail.fields.email`),F,ae),I.$$input=e=>y(e.currentTarget.value),l(L,()=>o(`users.detail.fields.password`),R,z),l(B,()=>o(`users.detail.passwordPrompt`,{email:``})),V.$$input=e=>ne(e.currentTarget.value),l(H,()=>o(`users.detail.fields.role`),W,G),K.addEventListener(`change`,e=>S(e.currentTarget.value)),l(q,()=>o(`users.detail.rolePlaceholder`)),l(K,r(a,{get each(){return C()},children:e=>(()=>{var t=d(g),n=t.firstChild,[r,a]=f(n.nextSibling),o=r.nextSibling.nextSibling,[s,c]=f(o.nextSibling);return s.nextSibling,l(t,()=>e.name,r,a),l(t,()=>e.slug,s,c),i(()=>u(t,`value`,e.id)),t})()}),ce,le),l(J,()=>o(`common.save`),Y,de),l(J,()=>o(`users.new`).toLowerCase(),X,pe),l(J,()=>o(`users.detail.fields.role`),Z,he),l(J,()=>o(`users.toolbar.newBtn`).toLowerCase(),Q,_e),l($,(()=>{var e=ee(()=>!!D());return()=>e()?o(`common.loading`):o(`common.create`)})()),l(ve,()=>o(`common.back`)),i(()=>u($,`disabled`,D())),i(()=>u(M,`value`,s())),i(()=>u(I,`value`,v())),i(()=>u(V,`value`,b())),i(()=>u(K,`value`,x())),c(),e})()}s([`input`]);export{_ as UserCreateForm};
@@ -1 +1 @@
1
- import{S as e,a as t,h as n,l as r,p as i,r as a}from"./solid.Ck4Vtfe4.js";import{_ as o,a as s,f as c,l,m as u,o as d,s as f}from"./web.DD6VKaIp.js";import{n as p}from"./i18n.CBexpqud.js";import{n as m}from"./api.flUgn70U.js";import{i as h,n as g,o as _,s as v,t as y}from"./src.CYKGYEyR.js";var b=o(`<div class="notice notice--error">`),x=o(`<div class=notice>`),S=o(`<table class=users-table><thead><tr><th></th><th></th><th></th><th></th><th></th><th></th></tr></thead><tbody>`),C=o(`<div class=users-manager><!$><!/><!$><!/><div class=toolbar><!$><!/><!$><!/><a class="btn btn-primary"href=/users/new></a><!$><!/></div><!$><!/><!$><!/><!$><!/>`),w=o(`<p class=muted>`),T=o(`<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=o(`<span class=muted>`),D=o(`<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=o(`<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:o}=p(),[s,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))}};e(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(o(`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(o(`users.detail.passwordPrompt`,{email:e.email}));if(t){if(t.length<8){H(o(`users.detail.passwordError`));return}J(!0),H(``);try{await m.setUserPassword(e.id,t),W(o(`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(o(`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(o(`users.detail.confirmDelete`,{email:e.email}))){J(!0),H(``);try{await m.deleteUser(e.id),G()?.id===e.id&&K(null),W(o(`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 e=d(C),n=e.firstChild,[p,m]=f(n.nextSibling),A=p.nextSibling,[M,P]=f(A.nextSibling),H=M.nextSibling,W=H.firstChild,[J,Z]=f(W.nextSibling),ae=J.nextSibling,[Q,oe]=f(ae.nextSibling),$=Q.nextSibling,se=$.nextSibling,[ce,le]=f(se.nextSibling),ue=H.nextSibling,[de,fe]=f(ue.nextSibling),pe=de.nextSibling,[me,he]=f(pe.nextSibling),ge=me.nextSibling,[_e,ve]=f(ge.nextSibling);return l(e,r(t,{get when(){return V()},get children(){var e=d(b);return l(e,V),e}}),p,m),l(e,r(t,{get when(){return U()},get children(){var e=d(x);return l(e,U),e}}),M,P),l(H,r(h,{name:`user-search`,get placeholder(){return o(`users.toolbar.search`)},get value(){return L()},onInput:e=>{R(e),X()}}),J,Z),l(H,r(v,{name:`user-status`,get placeholder(){return o(`users.toolbar.allStatus`)},get value(){return z()},get options(){return[{value:`ACTIVE`,label:o(`users.toolbar.active`)},{value:`INACTIVE`,label:o(`users.toolbar.inactive`)}]},onChange:e=>{B(e),X()}}),Q,oe),l($,()=>o(`users.toolbar.newBtn`)),l(H,r(g,{variant:`secondary`,onClick:()=>void X(),get children(){return o(`users.toolbar.searchBtn`)}}),ce,le),l(e,r(t,{get when(){return s().length>0},get fallback(){return(()=>{var e=d(w);return l(e,()=>o(`users.empty`)),e})()},get children(){var e=d(S),n=e.firstChild,c=n.firstChild.firstChild,u=c.nextSibling,p=u.nextSibling,m=p.nextSibling,h=m.nextSibling,_=n.nextSibling;return l(c,()=>o(`users.table.name`)),l(u,()=>o(`users.table.email`)),l(p,()=>o(`users.table.role`)),l(m,()=>o(`users.table.status`)),l(h,()=>o(`users.table.lastAccess`)),l(_,r(a,{get each(){return s()},children:e=>(()=>{var n=d(T),a=n.firstChild,s=a.nextSibling,c=s.nextSibling,u=c.nextSibling,p=u.firstChild,m=p.nextSibling,[h,_]=f(m.nextSibling),v=u.nextSibling,b=v.nextSibling,x=b.firstChild,[S,C]=f(x.nextSibling),w=S.nextSibling,[D,O]=f(w.nextSibling);return l(a,()=>e.name),l(s,()=>e.email),l(c,r(t,{get when(){return e.roles.length>0},get fallback(){return(()=>{var e=d(E);return l(e,()=>o(`users.noRole`)),e})()},get children(){return r(y,{get children(){return e.roles.join(`, `)}})}})),l(u,()=>o(`common.status.`+e.status.toLowerCase()),h,_),l(v,()=>k(e.last_login_at)),l(b,r(g,{variant:`secondary`,size:`sm`,onClick:()=>K(e),get children(){return o(`users.table.actions.manage`)}}),S,C),l(b,r(g,{variant:`danger`,size:`sm`,onClick:()=>void re(e),get children(){return o(`users.table.actions.delete`)}}),D,O),i(t=>{var r=G()?.id===e.id,i=e.status===`ACTIVE`;return r!==t.e&&n.classList.toggle(`users-table__row--selected`,t.e=r),i!==t.t&&p.classList.toggle(`status-dot--active`,t.t=i),t},{e:void 0,t:void 0}),n})()})),e}}),de,fe),l(e,r(_,{get page(){return F()},limit:20,get total(){return N()},onPageChange:e=>{I(e),Y()}}),me,he),l(e,r(t,{get when(){return G()},children:e=>(()=>{var t=d(D),n=t.firstChild,s=n.nextSibling,p=s.firstChild,m=p.firstChild,[h,_]=f(m.nextSibling),v=h.nextSibling,y=p.nextSibling,b=y.firstChild,[x,S]=f(b.nextSibling),C=x.nextSibling,w=y.nextSibling,T=w.firstChild,[E,A]=f(T.nextSibling),M=E.nextSibling,N=M.firstChild,P=N.nextSibling,F=w.nextSibling,I=F.firstChild,[L,R]=f(I.nextSibling),z=L.nextSibling,B=z.firstChild,V=B.nextSibling,[H,U]=f(V.nextSibling),W=s.nextSibling,G=W.nextSibling,J=G.firstChild,[Y,X]=f(J.nextSibling),re=Y.nextSibling,[Z,ae]=f(re.nextSibling),Q=Z.nextSibling,[oe,$]=f(Q.nextSibling);return l(n,()=>o(`users.detail.title`)),l(p,()=>o(`users.detail.fields.name`),h,_),v.$$input=t=>K({...e(),name:t.currentTarget.value}),l(y,()=>o(`users.detail.fields.email`),x,S),C.$$input=t=>K({...e(),email:t.currentTarget.value}),l(w,()=>o(`users.detail.fields.status`),E,A),M.addEventListener(`change`,t=>K({...e(),status:t.currentTarget.value})),l(N,()=>o(`users.detail.statusOptions.active`)),l(P,()=>o(`users.detail.statusOptions.inactive`)),l(F,()=>o(`users.detail.fields.role`),L,R),z.addEventListener(`change`,t=>void ee(e(),t.currentTarget.value)),l(B,()=>o(`users.detail.rolePlaceholder`)),l(z,r(a,{get each(){return j()},children:e=>(()=>{var t=d(O),n=t.firstChild,[r,a]=f(n.nextSibling),o=r.nextSibling.nextSibling,[s,c]=f(o.nextSibling);return s.nextSibling,l(t,()=>e.name,r,a),l(t,()=>e.slug,s,c),i(()=>u(t,`value`,e.id)),t})()}),H,U),l(W,()=>o(`users.detail.meta`,{created:k(e().created_at),lastAccess:k(e().last_login_at)})),l(G,r(g,{variant:`primary`,get disabled(){return q()},get loading(){return q()},onClick:()=>void ne(e()),get children(){return o(`users.detail.actions.save`)}}),Y,X),l(G,r(g,{variant:`secondary`,get disabled(){return q()},onClick:()=>void te(e()),get children(){return o(`users.detail.actions.resetPassword`)}}),Z,ae),l(G,r(g,{variant:`secondary`,onClick:()=>K(null),get children(){return o(`users.detail.actions.close`)}}),oe,$),i(()=>u(z,`disabled`,q())),i(()=>u(v,`value`,e().name)),i(()=>u(C,`value`,e().email)),i(()=>u(M,`value`,e().status)),i(()=>u(z,`value`,ie(e())?.id??``)),c(),t})()}),_e,ve),e})()}s([`input`]);export{A as UsersManager};
1
+ import{S as e,a as t,h as n,l as r,p as i,r as a}from"./solid.Ck4Vtfe4.js";import{_ as o,a as s,f as c,l,m as u,o as d,s as f}from"./web.DD6VKaIp.js";import{n as p}from"./i18n.LMZI7jyc.js";import{n as m}from"./api.B03e8F6d.js";import{i as h,n as g,o as _,s as v,t as y}from"./src.CYKGYEyR.js";var b=o(`<div class="notice notice--error">`),x=o(`<div class=notice>`),S=o(`<table class=users-table><thead><tr><th></th><th></th><th></th><th></th><th></th><th></th></tr></thead><tbody>`),C=o(`<div class=users-manager><!$><!/><!$><!/><div class=toolbar><!$><!/><!$><!/><a class="btn btn-primary"href=/users/new></a><!$><!/></div><!$><!/><!$><!/><!$><!/>`),w=o(`<p class=muted>`),T=o(`<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=o(`<span class=muted>`),D=o(`<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=o(`<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:o}=p(),[s,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))}};e(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(o(`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(o(`users.detail.passwordPrompt`,{email:e.email}));if(t){if(t.length<8){H(o(`users.detail.passwordError`));return}J(!0),H(``);try{await m.setUserPassword(e.id,t),W(o(`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(o(`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(o(`users.detail.confirmDelete`,{email:e.email}))){J(!0),H(``);try{await m.deleteUser(e.id),G()?.id===e.id&&K(null),W(o(`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 e=d(C),n=e.firstChild,[p,m]=f(n.nextSibling),A=p.nextSibling,[M,P]=f(A.nextSibling),H=M.nextSibling,W=H.firstChild,[J,Z]=f(W.nextSibling),ae=J.nextSibling,[Q,oe]=f(ae.nextSibling),$=Q.nextSibling,se=$.nextSibling,[ce,le]=f(se.nextSibling),ue=H.nextSibling,[de,fe]=f(ue.nextSibling),pe=de.nextSibling,[me,he]=f(pe.nextSibling),ge=me.nextSibling,[_e,ve]=f(ge.nextSibling);return l(e,r(t,{get when(){return V()},get children(){var e=d(b);return l(e,V),e}}),p,m),l(e,r(t,{get when(){return U()},get children(){var e=d(x);return l(e,U),e}}),M,P),l(H,r(h,{name:`user-search`,get placeholder(){return o(`users.toolbar.search`)},get value(){return L()},onInput:e=>{R(e),X()}}),J,Z),l(H,r(v,{name:`user-status`,get placeholder(){return o(`users.toolbar.allStatus`)},get value(){return z()},get options(){return[{value:`ACTIVE`,label:o(`users.toolbar.active`)},{value:`INACTIVE`,label:o(`users.toolbar.inactive`)}]},onChange:e=>{B(e),X()}}),Q,oe),l($,()=>o(`users.toolbar.newBtn`)),l(H,r(g,{variant:`secondary`,onClick:()=>void X(),get children(){return o(`users.toolbar.searchBtn`)}}),ce,le),l(e,r(t,{get when(){return s().length>0},get fallback(){return(()=>{var e=d(w);return l(e,()=>o(`users.empty`)),e})()},get children(){var e=d(S),n=e.firstChild,c=n.firstChild.firstChild,u=c.nextSibling,p=u.nextSibling,m=p.nextSibling,h=m.nextSibling,_=n.nextSibling;return l(c,()=>o(`users.table.name`)),l(u,()=>o(`users.table.email`)),l(p,()=>o(`users.table.role`)),l(m,()=>o(`users.table.status`)),l(h,()=>o(`users.table.lastAccess`)),l(_,r(a,{get each(){return s()},children:e=>(()=>{var n=d(T),a=n.firstChild,s=a.nextSibling,c=s.nextSibling,u=c.nextSibling,p=u.firstChild,m=p.nextSibling,[h,_]=f(m.nextSibling),v=u.nextSibling,b=v.nextSibling,x=b.firstChild,[S,C]=f(x.nextSibling),w=S.nextSibling,[D,O]=f(w.nextSibling);return l(a,()=>e.name),l(s,()=>e.email),l(c,r(t,{get when(){return e.roles.length>0},get fallback(){return(()=>{var e=d(E);return l(e,()=>o(`users.noRole`)),e})()},get children(){return r(y,{get children(){return e.roles.join(`, `)}})}})),l(u,()=>o(`common.status.`+e.status.toLowerCase()),h,_),l(v,()=>k(e.last_login_at)),l(b,r(g,{variant:`secondary`,size:`sm`,onClick:()=>K(e),get children(){return o(`users.table.actions.manage`)}}),S,C),l(b,r(g,{variant:`danger`,size:`sm`,onClick:()=>void re(e),get children(){return o(`users.table.actions.delete`)}}),D,O),i(t=>{var r=G()?.id===e.id,i=e.status===`ACTIVE`;return r!==t.e&&n.classList.toggle(`users-table__row--selected`,t.e=r),i!==t.t&&p.classList.toggle(`status-dot--active`,t.t=i),t},{e:void 0,t:void 0}),n})()})),e}}),de,fe),l(e,r(_,{get page(){return F()},limit:20,get total(){return N()},onPageChange:e=>{I(e),Y()}}),me,he),l(e,r(t,{get when(){return G()},children:e=>(()=>{var t=d(D),n=t.firstChild,s=n.nextSibling,p=s.firstChild,m=p.firstChild,[h,_]=f(m.nextSibling),v=h.nextSibling,y=p.nextSibling,b=y.firstChild,[x,S]=f(b.nextSibling),C=x.nextSibling,w=y.nextSibling,T=w.firstChild,[E,A]=f(T.nextSibling),M=E.nextSibling,N=M.firstChild,P=N.nextSibling,F=w.nextSibling,I=F.firstChild,[L,R]=f(I.nextSibling),z=L.nextSibling,B=z.firstChild,V=B.nextSibling,[H,U]=f(V.nextSibling),W=s.nextSibling,G=W.nextSibling,J=G.firstChild,[Y,X]=f(J.nextSibling),re=Y.nextSibling,[Z,ae]=f(re.nextSibling),Q=Z.nextSibling,[oe,$]=f(Q.nextSibling);return l(n,()=>o(`users.detail.title`)),l(p,()=>o(`users.detail.fields.name`),h,_),v.$$input=t=>K({...e(),name:t.currentTarget.value}),l(y,()=>o(`users.detail.fields.email`),x,S),C.$$input=t=>K({...e(),email:t.currentTarget.value}),l(w,()=>o(`users.detail.fields.status`),E,A),M.addEventListener(`change`,t=>K({...e(),status:t.currentTarget.value})),l(N,()=>o(`users.detail.statusOptions.active`)),l(P,()=>o(`users.detail.statusOptions.inactive`)),l(F,()=>o(`users.detail.fields.role`),L,R),z.addEventListener(`change`,t=>void ee(e(),t.currentTarget.value)),l(B,()=>o(`users.detail.rolePlaceholder`)),l(z,r(a,{get each(){return j()},children:e=>(()=>{var t=d(O),n=t.firstChild,[r,a]=f(n.nextSibling),o=r.nextSibling.nextSibling,[s,c]=f(o.nextSibling);return s.nextSibling,l(t,()=>e.name,r,a),l(t,()=>e.slug,s,c),i(()=>u(t,`value`,e.id)),t})()}),H,U),l(W,()=>o(`users.detail.meta`,{created:k(e().created_at),lastAccess:k(e().last_login_at)})),l(G,r(g,{variant:`primary`,get disabled(){return q()},get loading(){return q()},onClick:()=>void ne(e()),get children(){return o(`users.detail.actions.save`)}}),Y,X),l(G,r(g,{variant:`secondary`,get disabled(){return q()},onClick:()=>void te(e()),get children(){return o(`users.detail.actions.resetPassword`)}}),Z,ae),l(G,r(g,{variant:`secondary`,onClick:()=>K(null),get children(){return o(`users.detail.actions.close`)}}),oe,$),i(()=>u(z,`disabled`,q())),i(()=>u(v,`value`,e().name)),i(()=>u(C,`value`,e().email)),i(()=>u(M,`value`,e().status)),i(()=>u(z,`value`,ie(e())?.id??``)),c(),t})()}),_e,ve),e})()}s([`input`]);export{A as UsersManager};
@@ -1 +1 @@
1
- import{S as e,a as t,h as n,l as r,p as i,r as a,x as o}from"./solid.Ck4Vtfe4.js";import{_ as s,a as c,f as l,l as u,m as d,o as f,p,s as m,u as h,v as g}from"./web.DD6VKaIp.js";import{n as _}from"./i18n.CBexpqud.js";import{n as v}from"./api.flUgn70U.js";var y=s(`<div class=webhook-event-select__dropdown role=listbox><input class=input><div class=webhook-event-select__options>`),b=s(`<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=s(`<span class=muted>`),S=s(`<label class=webhook-event-option><input type=checkbox><span><!$><!/><small>`),C=s(`<button type=button class=webhook-event-chip><!$><!/> ×`),w=s(`<div class="notice notice--error">`),T=s(`<div class=table-scroll><table class=table><thead><tr><th></th><th></th><th></th><th></th><th></th></tr></thead><tbody>`),E=s(`<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=s(`<label><!$><!/><input class=input type=password>`),O=s(`<div class=form-grid><label><!$><!/><input class=input></label><label><!$><!/><input class=input type=password>`),k=s(`<div class=form-grid><label><!$><!/><input class=input type=password></label><label><!$><!/><input class=input>`),A=s(`<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=s(`<p>`),M=s(`<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(s){let[c,_]=n(!1),[v,w]=n(``),T;e(()=>{let e=e=>{T&&!T.contains(e.target)&&_(!1)};document.addEventListener(`mousedown`,e),o(()=>document.removeEventListener(`mousedown`,e))});let E=()=>s.options.filter(e=>`${e.label} ${e.value}`.toLowerCase().includes(v().toLowerCase())),D=e=>s.onChange(s.value.includes(e)?s.value.filter(t=>t!==e):[...s.value,e]);return(()=>{var e=f(b),n=e.firstChild,o=n.firstChild,O=n.nextSibling,[k,A]=m(O.nextSibling),j=k.nextSibling,M=T;return typeof M==`function`?g(M,e):T=e,n.$$click=()=>_(!c()),u(o,(()=>{var e=h(()=>s.value.length>0);return()=>e()?`${s.value.length} selecionado(s)`:s.placeholder})()),u(e,r(t,{get when(){return c()},get children(){var e=f(y),n=e.firstChild,o=n.nextSibling;return n.$$input=e=>w(e.currentTarget.value),u(o,r(t,{get when(){return E().length>0},get fallback(){return(()=>{var e=f(x);return u(e,()=>s.empty),e})()},get children(){return r(a,{get each(){return E()},children:e=>(()=>{var t=f(S),n=t.firstChild,r=n.nextSibling,a=r.firstChild,[o,c]=m(a.nextSibling),l=o.nextSibling;return n.addEventListener(`change`,()=>D(e.value)),u(r,()=>e.label,o,c),u(l,()=>e.value),i(()=>d(n,`checked`,s.value.includes(e.value))),t})()})}})),i(()=>p(n,`placeholder`,s.searchPlaceholder)),i(()=>d(n,`value`,v())),l(),e}}),k,A),u(j,r(a,{get each(){return s.value},children:e=>(()=>{var t=f(C),n=t.firstChild,[r,i]=m(n.nextSibling);return r.nextSibling,t.$$click=()=>D(e),u(t,()=>s.options.find(t=>t.value===e)?.label??e,r,i),l(),t})()})),i(()=>p(n,`aria-expanded`,c())),l(),e})()}function F(){let{t:o}=_(),[s,c]=n([]),[g,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()]);c(e),y(t)}catch(e){C(e instanceof Error?e.message:String(e))}finally{I(!1)}};e(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(o(`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 e=f(E),n=e.firstChild,[c,_]=m(n.nextSibling),y=c.nextSibling,C=y.firstChild,N=C.firstChild,I=C.nextSibling,V=y.nextSibling,[H,U]=m(V.nextSibling),W=H.nextSibling;return u(e,r(t,{get when(){return S()},get children(){var e=f(w);return u(e,S),e}}),c,_),u(N,()=>o(`webhooks.listTitle`)),I.$$click=()=>R(),u(I,()=>o(`webhooks.new`)),u(e,r(t,{get when(){return b()},children:e=>(()=>{var n=f(A),a=n.firstChild,s=a.nextSibling,c=s.firstChild,_=c.firstChild,[v,y]=m(_.nextSibling),b=v.nextSibling,S=c.nextSibling,C=S.firstChild,[w,T]=m(C.nextSibling),E=w.nextSibling,[j,M]=m(E.nextSibling),N=S.nextSibling,F=N.firstChild,[I,L]=m(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]=m(ee.nextSibling),ne=K.nextSibling,[q,re]=m(ne.nextSibling),ie=q.nextSibling,[J,ae]=m(ie.nextSibling),oe=J.nextSibling,[Y,se]=m(oe.nextSibling),X=Y.nextSibling,Z=X.firstChild,ce=Z.nextSibling.nextSibling,[le,ue]=m(ce.nextSibling),Q=X.nextSibling.firstChild,$=Q.nextSibling.nextSibling;return u(a,(()=>{var t=h(()=>!!e().id);return()=>t()?o(`webhooks.edit`):o(`webhooks.create`)})()),s.addEventListener(`submit`,B),u(c,()=>o(`webhooks.url`),v,y),b.$$input=t=>x({...e(),url:t.currentTarget.value}),u(S,()=>o(`webhooks.events`),w,T),u(S,r(P,{get options(){return g()},get value(){return e().events??[]},onChange:t=>x({...e(),events:t}),get placeholder(){return o(`webhooks.selectEvents`)},get searchPlaceholder(){return o(`webhooks.searchEvents`)},get empty(){return o(`webhooks.noEvents`)}}),j,M),u(N,()=>o(`webhooks.authentication`),I,L),R.addEventListener(`change`,t=>x({...e(),auth_type:t.currentTarget.value,auth_config:{}})),u(V,()=>o(`webhooks.auth.none`)),u(H,()=>o(`webhooks.auth.bearer`)),u(U,()=>o(`webhooks.auth.basic`)),u(W,()=>o(`webhooks.auth.apiKey`)),u(G,()=>o(`webhooks.auth.hmac_sha256`)),u(s,r(t,{get when(){return e().auth_type===`bearer`},get children(){var t=f(D),n=t.firstChild,[r,a]=m(n.nextSibling),s=r.nextSibling;return u(t,()=>o(`webhooks.token`),r,a),s.$$input=e=>z(`token`,e.currentTarget.value),i(()=>p(s,`placeholder`,e().id?o(`webhooks.keepExisting`):``)),i(()=>d(s,`value`,e().auth_config.token??``)),l(),t}}),K,te),u(s,r(t,{get when(){return e().auth_type===`basic`},get children(){var t=f(O),n=t.firstChild,r=n.firstChild,[a,s]=m(r.nextSibling),c=a.nextSibling,h=n.nextSibling,g=h.firstChild,[_,v]=m(g.nextSibling),y=_.nextSibling;return u(n,()=>o(`webhooks.username`),a,s),c.$$input=e=>z(`username`,e.currentTarget.value),u(h,()=>o(`webhooks.password`),_,v),y.$$input=e=>z(`password`,e.currentTarget.value),i(()=>p(y,`placeholder`,e().id?o(`webhooks.keepExisting`):``)),i(()=>d(c,`value`,e().auth_config.username??``)),i(()=>d(y,`value`,e().auth_config.password??``)),l(),t}}),q,re),u(s,r(t,{get when(){return e().auth_type===`api_key`},get children(){var t=f(O),n=t.firstChild,r=n.firstChild,[a,s]=m(r.nextSibling),c=a.nextSibling,h=n.nextSibling,g=h.firstChild,[_,v]=m(g.nextSibling),y=_.nextSibling;return u(n,()=>o(`webhooks.headerName`),a,s),c.$$input=e=>z(`headerName`,e.currentTarget.value),u(h,()=>o(`webhooks.apiKeyValue`),_,v),y.$$input=e=>z(`value`,e.currentTarget.value),i(()=>p(y,`placeholder`,e().id?o(`webhooks.keepExisting`):``)),i(()=>d(c,`value`,e().auth_config.headerName??``)),i(()=>d(y,`value`,e().auth_config.value??``)),l(),t}}),J,ae),u(s,r(t,{get when(){return e().auth_type===`hmac_sha256`},get children(){var t=f(k),n=t.firstChild,r=n.firstChild,[a,s]=m(r.nextSibling),c=a.nextSibling,h=n.nextSibling,g=h.firstChild,[_,v]=m(g.nextSibling),y=_.nextSibling;return u(n,()=>o(`webhooks.secret`),a,s),c.$$input=e=>z(`secret`,e.currentTarget.value),u(h,()=>o(`webhooks.signatureHeader`),_,v),y.$$input=e=>z(`signatureHeader`,e.currentTarget.value),i(t=>{var n=!e().id,r=e().id?o(`webhooks.keepExisting`):``;return n!==t.e&&d(c,`required`,t.e=n),r!==t.t&&p(c,`placeholder`,t.t=r),t},{e:void 0,t:void 0}),i(()=>d(c,`value`,e().auth_config.secret??``)),i(()=>d(y,`value`,e().auth_config.signatureHeader??`X-Webhook-Signature`)),l(),t}}),Y,se),Z.addEventListener(`change`,t=>x({...e(),active:t.currentTarget.checked})),u(X,()=>o(`webhooks.active`),le,ue),u(Q,()=>o(`common.save`)),$.$$click=()=>x(null),u($,()=>o(`common.cancel`)),i(()=>d(b,`value`,e().url??``)),i(()=>d(R,`value`,e().auth_type)),i(()=>d(Z,`checked`,e().active??!0)),l(),n})()}),H,U),u(W,r(t,{get when(){return!F()},get fallback(){return(()=>{var e=f(j);return u(e,()=>o(`webhooks.loading`)),e})()},get children(){return r(t,{get when(){return s().length>0},get fallback(){return(()=>{var e=f(j);return u(e,()=>o(`webhooks.empty`)),e})()},get children(){var e=f(T),t=e.firstChild.firstChild,n=t.firstChild.firstChild,i=n.nextSibling,c=i.nextSibling,d=c.nextSibling,p=d.nextSibling,m=t.nextSibling;return u(n,()=>o(`webhooks.url`)),u(i,()=>o(`webhooks.events`)),u(c,()=>o(`webhooks.authentication`)),u(d,()=>o(`webhooks.active`)),u(p,()=>o(`common.actions`)),u(m,r(a,{get each(){return s()},children:e=>(()=>{var t=f(M),n=t.firstChild,r=n.nextSibling,i=r.nextSibling,a=i.nextSibling,s=a.nextSibling.firstChild,c=s.nextSibling.nextSibling;return u(n,()=>e.url),u(r,()=>(e.events??[]).join(`, `)),u(i,()=>o(`webhooks.auth.${e.auth_type??`hmac_sha256`}`)),u(a,(()=>{var t=h(()=>!!e.active);return()=>t()?o(`common.yes`):o(`common.no`)})()),s.$$click=()=>R(e),u(s,()=>o(`common.edit`)),c.$$click=()=>e.id&&void v.deleteWebhook(e.id).then(L),u(c,()=>o(`common.delete`)),l(),t})()})),e}})}})),l(),e})()}c([`click`,`input`]);export{F as WebhooksManager};
1
+ import{S as e,a as t,h as n,l as r,p as i,r as a,x as o}from"./solid.Ck4Vtfe4.js";import{_ as s,a as c,f as l,l as u,m as d,o as f,p,s as m,u as h,v as g}from"./web.DD6VKaIp.js";import{n as _}from"./i18n.LMZI7jyc.js";import{n as v}from"./api.B03e8F6d.js";var y=s(`<div class=webhook-event-select__dropdown role=listbox><input class=input><div class=webhook-event-select__options>`),b=s(`<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=s(`<span class=muted>`),S=s(`<label class=webhook-event-option><input type=checkbox><span><!$><!/><small>`),C=s(`<button type=button class=webhook-event-chip><!$><!/> ×`),w=s(`<div class="notice notice--error">`),T=s(`<div class=table-scroll><table class=table><thead><tr><th></th><th></th><th></th><th></th><th></th></tr></thead><tbody>`),E=s(`<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=s(`<label><!$><!/><input class=input type=password>`),O=s(`<div class=form-grid><label><!$><!/><input class=input></label><label><!$><!/><input class=input type=password>`),k=s(`<div class=form-grid><label><!$><!/><input class=input type=password></label><label><!$><!/><input class=input>`),A=s(`<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=s(`<p>`),M=s(`<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(s){let[c,_]=n(!1),[v,w]=n(``),T;e(()=>{let e=e=>{T&&!T.contains(e.target)&&_(!1)};document.addEventListener(`mousedown`,e),o(()=>document.removeEventListener(`mousedown`,e))});let E=()=>s.options.filter(e=>`${e.label} ${e.value}`.toLowerCase().includes(v().toLowerCase())),D=e=>s.onChange(s.value.includes(e)?s.value.filter(t=>t!==e):[...s.value,e]);return(()=>{var e=f(b),n=e.firstChild,o=n.firstChild,O=n.nextSibling,[k,A]=m(O.nextSibling),j=k.nextSibling,M=T;return typeof M==`function`?g(M,e):T=e,n.$$click=()=>_(!c()),u(o,(()=>{var e=h(()=>s.value.length>0);return()=>e()?`${s.value.length} selecionado(s)`:s.placeholder})()),u(e,r(t,{get when(){return c()},get children(){var e=f(y),n=e.firstChild,o=n.nextSibling;return n.$$input=e=>w(e.currentTarget.value),u(o,r(t,{get when(){return E().length>0},get fallback(){return(()=>{var e=f(x);return u(e,()=>s.empty),e})()},get children(){return r(a,{get each(){return E()},children:e=>(()=>{var t=f(S),n=t.firstChild,r=n.nextSibling,a=r.firstChild,[o,c]=m(a.nextSibling),l=o.nextSibling;return n.addEventListener(`change`,()=>D(e.value)),u(r,()=>e.label,o,c),u(l,()=>e.value),i(()=>d(n,`checked`,s.value.includes(e.value))),t})()})}})),i(()=>p(n,`placeholder`,s.searchPlaceholder)),i(()=>d(n,`value`,v())),l(),e}}),k,A),u(j,r(a,{get each(){return s.value},children:e=>(()=>{var t=f(C),n=t.firstChild,[r,i]=m(n.nextSibling);return r.nextSibling,t.$$click=()=>D(e),u(t,()=>s.options.find(t=>t.value===e)?.label??e,r,i),l(),t})()})),i(()=>p(n,`aria-expanded`,c())),l(),e})()}function F(){let{t:o}=_(),[s,c]=n([]),[g,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()]);c(e),y(t)}catch(e){C(e instanceof Error?e.message:String(e))}finally{I(!1)}};e(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(o(`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 e=f(E),n=e.firstChild,[c,_]=m(n.nextSibling),y=c.nextSibling,C=y.firstChild,N=C.firstChild,I=C.nextSibling,V=y.nextSibling,[H,U]=m(V.nextSibling),W=H.nextSibling;return u(e,r(t,{get when(){return S()},get children(){var e=f(w);return u(e,S),e}}),c,_),u(N,()=>o(`webhooks.listTitle`)),I.$$click=()=>R(),u(I,()=>o(`webhooks.new`)),u(e,r(t,{get when(){return b()},children:e=>(()=>{var n=f(A),a=n.firstChild,s=a.nextSibling,c=s.firstChild,_=c.firstChild,[v,y]=m(_.nextSibling),b=v.nextSibling,S=c.nextSibling,C=S.firstChild,[w,T]=m(C.nextSibling),E=w.nextSibling,[j,M]=m(E.nextSibling),N=S.nextSibling,F=N.firstChild,[I,L]=m(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]=m(ee.nextSibling),ne=K.nextSibling,[q,re]=m(ne.nextSibling),ie=q.nextSibling,[J,ae]=m(ie.nextSibling),oe=J.nextSibling,[Y,se]=m(oe.nextSibling),X=Y.nextSibling,Z=X.firstChild,ce=Z.nextSibling.nextSibling,[le,ue]=m(ce.nextSibling),Q=X.nextSibling.firstChild,$=Q.nextSibling.nextSibling;return u(a,(()=>{var t=h(()=>!!e().id);return()=>t()?o(`webhooks.edit`):o(`webhooks.create`)})()),s.addEventListener(`submit`,B),u(c,()=>o(`webhooks.url`),v,y),b.$$input=t=>x({...e(),url:t.currentTarget.value}),u(S,()=>o(`webhooks.events`),w,T),u(S,r(P,{get options(){return g()},get value(){return e().events??[]},onChange:t=>x({...e(),events:t}),get placeholder(){return o(`webhooks.selectEvents`)},get searchPlaceholder(){return o(`webhooks.searchEvents`)},get empty(){return o(`webhooks.noEvents`)}}),j,M),u(N,()=>o(`webhooks.authentication`),I,L),R.addEventListener(`change`,t=>x({...e(),auth_type:t.currentTarget.value,auth_config:{}})),u(V,()=>o(`webhooks.auth.none`)),u(H,()=>o(`webhooks.auth.bearer`)),u(U,()=>o(`webhooks.auth.basic`)),u(W,()=>o(`webhooks.auth.apiKey`)),u(G,()=>o(`webhooks.auth.hmac_sha256`)),u(s,r(t,{get when(){return e().auth_type===`bearer`},get children(){var t=f(D),n=t.firstChild,[r,a]=m(n.nextSibling),s=r.nextSibling;return u(t,()=>o(`webhooks.token`),r,a),s.$$input=e=>z(`token`,e.currentTarget.value),i(()=>p(s,`placeholder`,e().id?o(`webhooks.keepExisting`):``)),i(()=>d(s,`value`,e().auth_config.token??``)),l(),t}}),K,te),u(s,r(t,{get when(){return e().auth_type===`basic`},get children(){var t=f(O),n=t.firstChild,r=n.firstChild,[a,s]=m(r.nextSibling),c=a.nextSibling,h=n.nextSibling,g=h.firstChild,[_,v]=m(g.nextSibling),y=_.nextSibling;return u(n,()=>o(`webhooks.username`),a,s),c.$$input=e=>z(`username`,e.currentTarget.value),u(h,()=>o(`webhooks.password`),_,v),y.$$input=e=>z(`password`,e.currentTarget.value),i(()=>p(y,`placeholder`,e().id?o(`webhooks.keepExisting`):``)),i(()=>d(c,`value`,e().auth_config.username??``)),i(()=>d(y,`value`,e().auth_config.password??``)),l(),t}}),q,re),u(s,r(t,{get when(){return e().auth_type===`api_key`},get children(){var t=f(O),n=t.firstChild,r=n.firstChild,[a,s]=m(r.nextSibling),c=a.nextSibling,h=n.nextSibling,g=h.firstChild,[_,v]=m(g.nextSibling),y=_.nextSibling;return u(n,()=>o(`webhooks.headerName`),a,s),c.$$input=e=>z(`headerName`,e.currentTarget.value),u(h,()=>o(`webhooks.apiKeyValue`),_,v),y.$$input=e=>z(`value`,e.currentTarget.value),i(()=>p(y,`placeholder`,e().id?o(`webhooks.keepExisting`):``)),i(()=>d(c,`value`,e().auth_config.headerName??``)),i(()=>d(y,`value`,e().auth_config.value??``)),l(),t}}),J,ae),u(s,r(t,{get when(){return e().auth_type===`hmac_sha256`},get children(){var t=f(k),n=t.firstChild,r=n.firstChild,[a,s]=m(r.nextSibling),c=a.nextSibling,h=n.nextSibling,g=h.firstChild,[_,v]=m(g.nextSibling),y=_.nextSibling;return u(n,()=>o(`webhooks.secret`),a,s),c.$$input=e=>z(`secret`,e.currentTarget.value),u(h,()=>o(`webhooks.signatureHeader`),_,v),y.$$input=e=>z(`signatureHeader`,e.currentTarget.value),i(t=>{var n=!e().id,r=e().id?o(`webhooks.keepExisting`):``;return n!==t.e&&d(c,`required`,t.e=n),r!==t.t&&p(c,`placeholder`,t.t=r),t},{e:void 0,t:void 0}),i(()=>d(c,`value`,e().auth_config.secret??``)),i(()=>d(y,`value`,e().auth_config.signatureHeader??`X-Webhook-Signature`)),l(),t}}),Y,se),Z.addEventListener(`change`,t=>x({...e(),active:t.currentTarget.checked})),u(X,()=>o(`webhooks.active`),le,ue),u(Q,()=>o(`common.save`)),$.$$click=()=>x(null),u($,()=>o(`common.cancel`)),i(()=>d(b,`value`,e().url??``)),i(()=>d(R,`value`,e().auth_type)),i(()=>d(Z,`checked`,e().active??!0)),l(),n})()}),H,U),u(W,r(t,{get when(){return!F()},get fallback(){return(()=>{var e=f(j);return u(e,()=>o(`webhooks.loading`)),e})()},get children(){return r(t,{get when(){return s().length>0},get fallback(){return(()=>{var e=f(j);return u(e,()=>o(`webhooks.empty`)),e})()},get children(){var e=f(T),t=e.firstChild.firstChild,n=t.firstChild.firstChild,i=n.nextSibling,c=i.nextSibling,d=c.nextSibling,p=d.nextSibling,m=t.nextSibling;return u(n,()=>o(`webhooks.url`)),u(i,()=>o(`webhooks.events`)),u(c,()=>o(`webhooks.authentication`)),u(d,()=>o(`webhooks.active`)),u(p,()=>o(`common.actions`)),u(m,r(a,{get each(){return s()},children:e=>(()=>{var t=f(M),n=t.firstChild,r=n.nextSibling,i=r.nextSibling,a=i.nextSibling,s=a.nextSibling.firstChild,c=s.nextSibling.nextSibling;return u(n,()=>e.url),u(r,()=>(e.events??[]).join(`, `)),u(i,()=>o(`webhooks.auth.${e.auth_type??`hmac_sha256`}`)),u(a,(()=>{var t=h(()=>!!e.active);return()=>t()?o(`common.yes`):o(`common.no`)})()),s.$$click=()=>R(e),u(s,()=>o(`common.edit`)),c.$$click=()=>e.id&&void v.deleteWebhook(e.id).then(L),u(c,()=>o(`common.delete`)),l(),t})()})),e}})}})),l(),e})()}c([`click`,`input`]);export{F as WebhooksManager};
@@ -1 +1 @@
1
- function e(e,t){return e&&t.startsWith(`/api/`)&&/\/api\/?$/.test(e)?`${e.replace(/\/$/,``)}${t.replace(/^\/api/,``)}`:`${e}${t}`}var t=class e extends Error{status;code;retryAfter;constructor(e,t,n,r){super(n??t),this.name=`ApiError`,this.status=e,this.code=t,this.retryAfter=r}static async fromResponse(t){let n=t.headers?.get?.(`Retry-After`)??``,r=Number(n),i=await t.json().catch(()=>null);return new e(t.status,i?.error??`Request failed`,i?.message??(i?.error?void 0:`Request failed: ${t.status}`),n&&Number.isFinite(r)?r:void 0)}},n=`okcms:rate-limited`,r=2e3,i=3e5,a=6e4,o=3e3;function s(e){typeof window<`u`&&typeof CustomEvent<`u`&&window.dispatchEvent(new CustomEvent(n,{detail:{retryAfter:e??null}}))}function c(e){return new Promise(t=>setTimeout(t,e))}function l(){if(typeof document<`u`){let e=document.querySelector(`meta[name="okcms-api-url"]`)?.getAttribute(`content`)?.trim();if(e)return e.startsWith(`/`),e.replace(/\/$/,``)}return``}var u=l(),d=new class{baseUrl;csrfToken=null;refreshPromise=null;proactiveRefreshBound=!1;csrfFetchedAt=0;refreshOwner=typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():Math.random().toString(36).slice(2);refreshLockKey=`okcms:auth:refresh-lock`;constructor(e=u){this.baseUrl=e}mediaUrl(e){if(/^(?:https?:)?\/\//i.test(e)||!this.baseUrl)return e;try{return new URL(e,`${this.baseUrl.replace(/\/$/,``)}/`).toString()}catch{return e}}async init(){try{await this.ensureCsrfToken()}catch{}}async checkSession(){try{return await this.request(`GET`,`/api/v1/auth/me`,void 0,void 0,{skipRateLimitRetry:!0}),`authenticated`}catch(e){return e instanceof t&&e.status===401?`unauthenticated`:`unavailable`}}async isLoggedIn(){return await this.checkSession()===`authenticated`}async ensureFreshSession(){let e=this.readSessionExpiry();if(!(!e||e-Date.now()>i))try{await this.refreshTokens()}catch{}}installProactiveRefresh(){typeof document>`u`||this.proactiveRefreshBound||(this.proactiveRefreshBound=!0,document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&this.ensureFreshSession()}))}readSessionExpiry(){if(typeof document>`u`)return null;let e=document.cookie.match(/(?:^|;\s*)session_expires_at=([^;]+)/);if(!e?.[1])return null;let t=Date.parse(decodeURIComponent(e[1]));return Number.isNaN(t)?null:t}async getTenantId(){try{return(await this.request(`GET`,`/api/v1/auth/me`)).tenantId??null}catch{return null}}async getUserLocale(){try{return(await this.request(`GET`,`/api/v1/users/me/locale`)).locale??`pt-BR`}catch{return`pt-BR`}}async setUserLocale(e){await this.request(`PUT`,`/api/v1/users/me/locale`,{locale:e})}async getMe(){return this.request(`GET`,`/api/v1/auth/me`)}async getAuditLogs(e=8){return this.request(`GET`,`/api/v1/audit-logs?limit=${e}`)}async getAuditLogConfig(){return this.request(`GET`,`/api/v1/audit-logs/config`)}async updateAuditLogConfig(e){return this.request(`PUT`,`/api/v1/audit-logs/config`,{retentionDays:e})}async listAuditLogs(e){let t=new URLSearchParams;return e?.limit&&t.set(`limit`,String(e.limit)),e?.action&&t.set(`action`,e.action),e?.resourceType&&t.set(`resourceType`,e.resourceType),this.request(`GET`,`/api/v1/audit-logs?${t.toString()}`)}async login(e){return await this.ensureCsrfToken(),await this.request(`POST`,`/api/v1/auth/login`,e)}async logout(){await this.request(`POST`,`/api/v1/auth/logout`,{}),this.csrfToken=null}async refreshTokens(){return this.refreshPromise||=this.refreshWithCrossTabLock().finally(()=>{this.refreshPromise=null}),this.refreshPromise}async refreshWithCrossTabLock(){if(typeof window>`u`||typeof localStorage>`u`){await this.request(`POST`,`/api/v1/auth/refresh`,{},void 0,{skipRefresh:!0});return}let e=this.readRefreshLock();if(e?.owner&&e.owner!==this.refreshOwner&&Number(e.expiresAt)>Date.now()){await this.waitForOtherTabRefresh(Number(e.expiresAt));return}if(!this.acquireRefreshLock()){await this.waitForOtherTabRefresh(Date.now()+o);return}try{await this.request(`POST`,`/api/v1/auth/refresh`,{},void 0,{skipRefresh:!0})}finally{this.releaseRefreshLock()}}readRefreshLock(){try{return JSON.parse(localStorage.getItem(this.refreshLockKey)??`null`)}catch{return null}}acquireRefreshLock(){try{return localStorage.setItem(this.refreshLockKey,JSON.stringify({owner:this.refreshOwner,expiresAt:Date.now()+o})),!0}catch{return!1}}releaseRefreshLock(){try{this.readRefreshLock()?.owner===this.refreshOwner&&localStorage.removeItem(this.refreshLockKey)}catch{}}async waitForOtherTabRefresh(e){let t=Math.max(0,Math.min(e,Date.now()+o)-Date.now());await new Promise(e=>{let n=!1,r=()=>{n||(n=!0,window.removeEventListener(`storage`,i),clearTimeout(a),e())},i=e=>{e.key===this.refreshLockKey&&r()};window.addEventListener(`storage`,i);let a=setTimeout(r,t)})}async sendWithRecovery(t,n,i,a,o){let l=e(this.baseUrl,n),u=async()=>{let e={...a};if((o?.bodyInit!==void 0||i!==void 0)&&o?.bodyInit===void 0&&(e[`Content-Type`]=`application/json`),![`GET`,`HEAD`,`OPTIONS`].includes(t.toUpperCase())){let t=await this.ensureCsrfToken();t&&(e[`x-csrf-token`]=t)}return fetch(l,{method:t,headers:e,credentials:`include`,body:o?.bodyInit??(i===void 0?void 0:JSON.stringify(i))})},d=await u();if(d.status===401&&!o?.skipRefresh&&!n.includes(`/auth/refresh`)&&!n.includes(`/auth/logout`)&&(await this.refreshTokens(),d=await u()),d.status===403&&!o?.skipCsrfRecovery){let e=``;try{e=(await(typeof d.clone==`function`?d.clone():d).json()).error??``}catch{}e===`CSRF_TOKEN_INVALID`&&(await this.ensureCsrfToken(!0),d=await u())}if(d.status===429&&!o?.skipRateLimitRetry){let e=d.headers?.get?.(`Retry-After`)??``,t=Number(e),n=(Number.isFinite(t)&&t>0?t:1)*1e3;s(Number.isFinite(t)&&t>0?t:1),n<=r&&(await c(n+50),d=await u())}return d}async request(e,n,r,i,a){let o=await this.sendWithRecovery(e,n,r,i,a);if(!o.ok)throw await t.fromResponse(o);return o.json()}async requestRaw(e,t,n,r,i){return this.sendWithRecovery(e,t,n,r,i)}async ensureCsrfToken(t=!1){let n=this.readCsrfCookie();if(!t&&n)return this.csrfToken=n,n;if(!t&&this.csrfToken&&Date.now()-this.csrfFetchedAt<a)return this.csrfToken;try{let t=await fetch(e(this.baseUrl,`/api/v1/auth/csrf`),{credentials:`include`,headers:{Accept:`application/json`}});if(!t.ok)return this.csrfToken;let n=await t.json();this.csrfToken=n.csrfToken??this.readCsrfCookie(),this.csrfFetchedAt=Date.now()}catch{}return this.csrfToken}readCsrfCookie(){if(typeof document<`u`){let e=document.cookie.match(/(?:^|;\s*)csrf_token=([^;]+)/);if(e?.[1])return e[1]}return this.csrfToken}async getContent(e){let t=new URLSearchParams;return e?.page&&t.set(`page`,String(e.page)),e?.limit&&t.set(`limit`,String(e.limit)),e?.type&&t.set(`type`,e.type),e?.status&&t.set(`status`,e.status),e?.search&&t.set(`search`,e.search),e?.includeAuthor&&t.set(`include`,`author`),this.request(`GET`,`/api/v1/content?${t.toString()}`)}async getContentById(e){return this.request(`GET`,`/api/v1/content/${e}`)}async getSingletonContent(e){let t=await this.request(`GET`,`/api/v1/content/singleton/${encodeURIComponent(e)}`);return`content`in t?t.content:t}async createContent(e){return this.request(`POST`,`/api/v1/content`,e)}async updateContent(e,t){return this.request(`PUT`,`/api/v1/content/${e}`,t)}async deleteContent(e){await this.request(`DELETE`,`/api/v1/content/${e}`)}async publishContent(e){let t=await this.request(`POST`,`/api/v1/content/${e}/publish`);return`content`in t?t.content:t}async unpublishContent(e){let t=await this.request(`POST`,`/api/v1/content/${e}/unpublish`);return`content`in t?t.content:t}async publishToggle(e,t){return t?this.unpublishContent(e):this.publishContent(e)}async getContentTypes(){return this.request(`GET`,`/api/v1/content-types`)}async createContentType(e){return this.request(`POST`,`/api/v1/content-types`,e)}async updateContentType(e,t){return this.request(`PUT`,`/api/v1/content-types/${e}`,t)}async deleteContentType(e){await this.request(`DELETE`,`/api/v1/content-types/${e}`)}async getTaxonomies(){return this.request(`GET`,`/api/v1/taxonomies`)}async createTaxonomy(e){return this.request(`POST`,`/api/v1/taxonomies`,e)}async attachTaxonomy(e,t){await this.request(`POST`,`/api/v1/taxonomies/${e}/attach`,{contentType:t})}async detachTaxonomy(e,t){await this.request(`POST`,`/api/v1/taxonomies/${e}/detach`,{contentType:t})}async deleteTaxonomy(e){await this.request(`DELETE`,`/api/v1/taxonomies/${e}`)}async getTaxonomyTerms(e){return this.request(`GET`,`/api/v1/taxonomies/${encodeURIComponent(e)}/terms`)}async createTaxonomyTerm(e,t){return this.request(`POST`,`/api/v1/taxonomies/${encodeURIComponent(e)}/terms`,t)}async updateTaxonomyTerm(e,t,n){return this.request(`PUT`,`/api/v1/taxonomies/${encodeURIComponent(e)}/terms/${t}`,n)}async deleteTaxonomyTerm(e,t){await this.request(`DELETE`,`/api/v1/taxonomies/${encodeURIComponent(e)}/terms/${t}`)}async getComments(e={}){let t=new URLSearchParams;e.status&&t.set(`status`,e.status),e.contentId&&t.set(`contentId`,e.contentId),e.search&&t.set(`search`,e.search),e.limit!==void 0&&t.set(`limit`,String(e.limit)),e.offset!==void 0&&t.set(`offset`,String(e.offset));let n=t.toString();return this.request(`GET`,`/api/v1/comments${n?`?${n}`:``}`)}async updateComment(e,t){return this.request(`PATCH`,`/api/v1/comments/${e}`,t)}async deleteComment(e){await this.request(`DELETE`,`/api/v1/comments/${e}`)}async getCategories(){return this.request(`GET`,`/api/v1/categories`)}async createCategory(e){return this.request(`POST`,`/api/v1/categories`,e)}async updateCategory(e,t){return this.request(`PUT`,`/api/v1/categories/${e}`,t)}async deleteCategory(e){await this.request(`DELETE`,`/api/v1/categories/${e}`)}async getTags(){return this.request(`GET`,`/api/v1/tags`)}async createTag(e){return this.request(`POST`,`/api/v1/tags`,e)}async updateTag(e,t){return this.request(`PUT`,`/api/v1/tags/${e}`,t)}async deleteTag(e){await this.request(`DELETE`,`/api/v1/tags/${e}`)}async getMenus(){return this.request(`GET`,`/api/v1/menus`)}async createMenu(e){return this.request(`POST`,`/api/v1/menus`,e)}async updateMenu(e,t){return this.request(`PUT`,`/api/v1/menus/${e}`,t)}async deleteMenu(e){await this.request(`DELETE`,`/api/v1/menus/${e}`)}async getFieldGroups(e){if(e?.type){let t=new URLSearchParams({type:e.type});for(let[n,r]of Object.entries(e))n!==`type`&&r&&t.set(n,r);return this.request(`GET`,`/api/v1/field-groups?${t.toString()}`)}return this.request(`GET`,`/api/v1/field-groups`)}async getFieldGroup(e){return this.request(`GET`,`/api/v1/field-groups/${e}`)}async exportFieldGroup(e){let t=await this.requestRaw(`GET`,`/api/v1/field-groups/${e}/export`);if(!t.ok)throw Error(await t.text());return t.blob()}async importFieldGroups(e){return this.request(`POST`,`/api/v1/field-groups/import`,e)}async createFieldGroup(e){return this.request(`POST`,`/api/v1/field-groups`,e)}async updateFieldGroup(e,t){return this.request(`PUT`,`/api/v1/field-groups/${e}`,t)}async deleteFieldGroup(e){await this.request(`DELETE`,`/api/v1/field-groups/${e}`)}async getFieldTypes(e){let t=e?`?category=${encodeURIComponent(e)}`:``;return this.request(`GET`,`/api/v1/field-types${t}`)}async getWebhooks(){return this.request(`GET`,`/api/v1/webhooks`)}async getWebhookEvents(){return(await this.request(`GET`,`/api/v1/webhooks/events`)).data}async createWebhook(e){return this.request(`POST`,`/api/v1/webhooks`,e)}async updateWebhook(e,t){return this.request(`PUT`,`/api/v1/webhooks/${e}`,t)}async deleteWebhook(e){await this.request(`DELETE`,`/api/v1/webhooks/${e}`)}async getApiKeys(){return this.request(`GET`,`/api/v1/api-keys`)}async createApiKey(e){return this.request(`POST`,`/api/v1/api-keys`,e)}async deleteApiKey(e){await this.request(`DELETE`,`/api/v1/api-keys/${e}`)}async listMedia(e){let t=new URLSearchParams;return e?.page&&t.set(`page`,String(e.page)),e?.limit&&t.set(`limit`,String(e.limit)),e?.mimeType&&t.set(`mimeType`,e.mimeType),e?.search&&t.set(`search`,e.search),this.request(`GET`,`/api/v1/media?${t.toString()}`)}async getMedia(e){return this.request(`GET`,`/api/v1/media/${e}`)}async uploadMedia(e,n){let r=new FormData;r.append(`file`,e),n?.alt&&r.append(`alt`,n.alt),n?.caption&&r.append(`caption`,n.caption);let i=await this.sendWithRecovery(`POST`,`/api/v1/media/upload`,void 0,{},{bodyInit:r});if(!i.ok)throw await t.fromResponse(i);return i.json()}async updateMedia(e,t){return this.request(`PUT`,`/api/v1/media/${e}`,t)}async replaceMediaFile(e,n){let r=new FormData;r.append(`file`,n);let i=await this.sendWithRecovery(`PUT`,`/api/v1/media/${e}/file`,void 0,{},{bodyInit:r});if(!i.ok)throw await t.fromResponse(i);return i.json()}async deleteMedia(e){await this.request(`DELETE`,`/api/v1/media/${e}`)}async listUsers(e){let t=new URLSearchParams;return e?.page&&t.set(`page`,String(e.page)),e?.limit&&t.set(`limit`,String(e.limit)),e?.search&&t.set(`search`,e.search),e?.status&&t.set(`status`,e.status),this.request(`GET`,`/api/v1/users?${t.toString()}`)}async getUser(e){return this.request(`GET`,`/api/v1/users/${e}`)}async createUser(e){return this.request(`POST`,`/api/v1/users`,e)}async updateUser(e,t){return this.request(`PUT`,`/api/v1/users/${e}`,t)}async deleteUser(e){await this.request(`DELETE`,`/api/v1/users/${e}`)}async setUserPassword(e,t){await this.request(`PUT`,`/api/v1/users/${e}/password`,{password:t})}async assignRole(e,t){return this.request(`POST`,`/api/v1/users/${e}/roles`,{roleId:t})}async removeRole(e,t){return this.request(`DELETE`,`/api/v1/users/${e}/roles/${t}`)}async listRoles(){return this.request(`GET`,`/api/v1/roles`)}async createRole(e){return this.request(`POST`,`/api/v1/roles`,e)}async updateRole(e,t){return this.request(`PUT`,`/api/v1/roles/${e}`,t)}async deleteRole(e){await this.request(`DELETE`,`/api/v1/roles/${e}`)}async listTenants(e){let t=new URLSearchParams;return e?.page&&t.set(`page`,String(e.page)),e?.limit&&t.set(`limit`,String(e.limit)),e?.search&&t.set(`search`,e.search),this.request(`GET`,`/api/v1/tenants?${t.toString()}`)}async createTenant(e){return this.request(`POST`,`/api/v1/tenants`,e)}async updateTenant(e,t){return this.request(`PUT`,`/api/v1/tenants/${e}`,t)}async deleteTenant(e){await this.request(`DELETE`,`/api/v1/tenants/${e}`)}async getSettings(e){let t=e?`?group=${encodeURIComponent(e)}`:``;return this.request(`GET`,`/api/v1/settings${t}`)}async updateSettings(e){await this.request(`PUT`,`/api/v1/settings`,e)}async healthCheck(){return this.request(`GET`,`/health`)}async getThemes(){return(await this.request(`GET`,`/api/v1/themes`)).map(e=>({id:String(e.id??``),name:String(e.name??``),version:e.version?String(e.version):void 0,status:String(e.status??`INSTALLED`),config:e.config??{},manifest:e.manifest??null}))}async syncThemes(){return(await this.request(`POST`,`/api/v1/themes/sync`)).map(e=>({id:String(e.id??``),name:String(e.name??``),version:e.version?String(e.version):void 0,status:String(e.status??`INSTALLED`),config:e.config??{},manifest:e.manifest??null}))}async activateTheme(e){return this.request(`POST`,`/api/v1/themes/${e}/activate`)}async deactivateTheme(e){return this.request(`POST`,`/api/v1/themes/${e}/deactivate`)}async updateThemeConfig(e,t){return this.request(`PATCH`,`/api/v1/themes/${e}/config`,{config:t})}async installTheme(e){return this.request(`POST`,`/api/v1/themes/install`,e)}async uninstallTheme(e){await this.request(`DELETE`,`/api/v1/themes/${e}`)}async getPlugins(){return(await this.request(`GET`,`/api/v1/plugins`)).map(e=>({id:String(e.id??``),name:String(e.name??``),version:String(e.version??``),status:String(e.status??`INSTALLED`),enabled:e.enabled===!0,manifest:e.manifest??null}))}async getAdminExtensions(){return this.request(`GET`,`/api/v1/plugins/extensions`)}async activatePlugin(e,t){return this.request(`POST`,`/api/v1/plugins/${e}/activate`,{tenantId:t})}async deactivatePlugin(e,t){return this.request(`POST`,`/api/v1/plugins/${e}/deactivate`,{tenantId:t})}async uninstallPlugin(e){await this.request(`DELETE`,`/api/v1/plugins/${e}`)}async getPluginsRuntime(){return this.request(`GET`,`/api/v1/plugins/runtime`)}};export{d as n,n as t};
1
+ function e(e,t){return e&&t.startsWith(`/api/`)&&/\/api\/?$/.test(e)?`${e.replace(/\/$/,``)}${t.replace(/^\/api/,``)}`:`${e}${t}`}var t=class e extends Error{status;code;retryAfter;constructor(e,t,n,r){super(n??t),this.name=`ApiError`,this.status=e,this.code=t,this.retryAfter=r}static async fromResponse(t){let n=t.headers?.get?.(`Retry-After`)??``,r=Number(n),i=await t.json().catch(()=>null);return new e(t.status,i?.error??`Request failed`,i?.message??(i?.error?void 0:`Request failed: ${t.status}`),n&&Number.isFinite(r)?r:void 0)}},n=`okcms:rate-limited`,r=2e3,i=3e5,a=6e4,o=3e3;function s(e){typeof window<`u`&&typeof CustomEvent<`u`&&window.dispatchEvent(new CustomEvent(n,{detail:{retryAfter:e??null}}))}function c(e){return new Promise(t=>setTimeout(t,e))}function l(){if(typeof document<`u`){let e=document.querySelector(`meta[name="okcms-api-url"]`)?.getAttribute(`content`)?.trim();if(e)return e.startsWith(`/`),e.replace(/\/$/,``)}return``}var u=l(),d=new class{baseUrl;csrfToken=null;refreshPromise=null;proactiveRefreshBound=!1;csrfFetchedAt=0;refreshOwner=typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():Math.random().toString(36).slice(2);refreshLockKey=`okcms:auth:refresh-lock`;constructor(e=u){this.baseUrl=e}mediaUrl(e){if(/^(?:https?:)?\/\//i.test(e)||!this.baseUrl)return e;try{return new URL(e,`${this.baseUrl.replace(/\/$/,``)}/`).toString()}catch{return e}}async init(){try{await this.ensureCsrfToken()}catch{}}async checkSession(){try{return await this.request(`GET`,`/api/v1/auth/me`,void 0,void 0,{skipRateLimitRetry:!0}),`authenticated`}catch(e){return e instanceof t&&e.status===401?`unauthenticated`:`unavailable`}}async isLoggedIn(){return await this.checkSession()===`authenticated`}async ensureFreshSession(){let e=this.readSessionExpiry();if(!(!e||e-Date.now()>i))try{await this.refreshTokens()}catch{}}installProactiveRefresh(){typeof document>`u`||this.proactiveRefreshBound||(this.proactiveRefreshBound=!0,document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&this.ensureFreshSession()}))}readSessionExpiry(){if(typeof document>`u`)return null;let e=document.cookie.match(/(?:^|;\s*)session_expires_at=([^;]+)/);if(!e?.[1])return null;let t=Date.parse(decodeURIComponent(e[1]));return Number.isNaN(t)?null:t}async getTenantId(){try{return(await this.request(`GET`,`/api/v1/auth/me`)).tenantId??null}catch{return null}}async getUserLocale(){try{return(await this.request(`GET`,`/api/v1/users/me/locale`)).locale??`pt-BR`}catch{return`pt-BR`}}async setUserLocale(e){await this.request(`PUT`,`/api/v1/users/me/locale`,{locale:e})}async getMe(){return this.request(`GET`,`/api/v1/auth/me`)}async getAuditLogs(e=8){return this.request(`GET`,`/api/v1/audit-logs?limit=${e}`)}async getAuditLogConfig(){return this.request(`GET`,`/api/v1/audit-logs/config`)}async updateAuditLogConfig(e){return this.request(`PUT`,`/api/v1/audit-logs/config`,{retentionDays:e})}async listAuditLogs(e){let t=new URLSearchParams;return e?.limit&&t.set(`limit`,String(e.limit)),e?.action&&t.set(`action`,e.action),e?.resourceType&&t.set(`resourceType`,e.resourceType),this.request(`GET`,`/api/v1/audit-logs?${t.toString()}`)}async login(e){return await this.ensureCsrfToken(),await this.request(`POST`,`/api/v1/auth/login`,e)}async logout(){await this.request(`POST`,`/api/v1/auth/logout`,{}),this.csrfToken=null}async refreshTokens(){return this.refreshPromise||=this.refreshWithCrossTabLock().finally(()=>{this.refreshPromise=null}),this.refreshPromise}async refreshWithCrossTabLock(){if(typeof window>`u`||typeof localStorage>`u`){await this.request(`POST`,`/api/v1/auth/refresh`,{},void 0,{skipRefresh:!0});return}let e=this.readRefreshLock();if(e?.owner&&e.owner!==this.refreshOwner&&Number(e.expiresAt)>Date.now()){await this.waitForOtherTabRefresh(Number(e.expiresAt));return}if(!this.acquireRefreshLock()){await this.waitForOtherTabRefresh(Date.now()+o);return}try{await this.request(`POST`,`/api/v1/auth/refresh`,{},void 0,{skipRefresh:!0})}finally{this.releaseRefreshLock()}}readRefreshLock(){try{return JSON.parse(localStorage.getItem(this.refreshLockKey)??`null`)}catch{return null}}acquireRefreshLock(){try{return localStorage.setItem(this.refreshLockKey,JSON.stringify({owner:this.refreshOwner,expiresAt:Date.now()+o})),!0}catch{return!1}}releaseRefreshLock(){try{this.readRefreshLock()?.owner===this.refreshOwner&&localStorage.removeItem(this.refreshLockKey)}catch{}}async waitForOtherTabRefresh(e){let t=Math.max(0,Math.min(e,Date.now()+o)-Date.now());await new Promise(e=>{let n=!1,r=()=>{n||(n=!0,window.removeEventListener(`storage`,i),clearTimeout(a),e())},i=e=>{e.key===this.refreshLockKey&&r()};window.addEventListener(`storage`,i);let a=setTimeout(r,t)})}async sendWithRecovery(t,n,i,a,o){let l=e(this.baseUrl,n),u=async()=>{let e={...a};if((o?.bodyInit!==void 0||i!==void 0)&&o?.bodyInit===void 0&&(e[`Content-Type`]=`application/json`),![`GET`,`HEAD`,`OPTIONS`].includes(t.toUpperCase())){let t=await this.ensureCsrfToken();t&&(e[`x-csrf-token`]=t)}return fetch(l,{method:t,headers:e,credentials:`include`,body:o?.bodyInit??(i===void 0?void 0:JSON.stringify(i))})},d=await u();if(d.status===401&&!o?.skipRefresh&&!n.includes(`/auth/refresh`)&&!n.includes(`/auth/logout`)&&(await this.refreshTokens(),d=await u()),d.status===403&&!o?.skipCsrfRecovery){let e=``;try{e=(await(typeof d.clone==`function`?d.clone():d).json()).error??``}catch{}e===`CSRF_TOKEN_INVALID`&&(await this.ensureCsrfToken(!0),d=await u())}if(d.status===429&&!o?.skipRateLimitRetry){let e=d.headers?.get?.(`Retry-After`)??``,t=Number(e),n=(Number.isFinite(t)&&t>0?t:1)*1e3;s(Number.isFinite(t)&&t>0?t:1),n<=r&&(await c(n+50),d=await u())}return d}async request(e,n,r,i,a){let o=await this.sendWithRecovery(e,n,r,i,a);if(!o.ok)throw await t.fromResponse(o);return o.json()}async requestRaw(e,t,n,r,i){return this.sendWithRecovery(e,t,n,r,i)}async ensureCsrfToken(t=!1){let n=this.readCsrfCookie();if(!t&&n)return this.csrfToken=n,n;if(!t&&this.csrfToken&&Date.now()-this.csrfFetchedAt<a)return this.csrfToken;try{let t=await fetch(e(this.baseUrl,`/api/v1/auth/csrf`),{credentials:`include`,headers:{Accept:`application/json`}});if(!t.ok)return this.csrfToken;let n=await t.json();this.csrfToken=n.csrfToken??this.readCsrfCookie(),this.csrfFetchedAt=Date.now()}catch{}return this.csrfToken}readCsrfCookie(){if(typeof document<`u`){let e=document.cookie.match(/(?:^|;\s*)csrf_token=([^;]+)/);if(e?.[1])return e[1]}return this.csrfToken}async getContent(e){let t=new URLSearchParams;return e?.page&&t.set(`page`,String(e.page)),e?.limit&&t.set(`limit`,String(e.limit)),e?.type&&t.set(`type`,e.type),e?.status&&t.set(`status`,e.status),e?.search&&t.set(`search`,e.search),e?.includeAuthor&&t.set(`include`,`author`),this.request(`GET`,`/api/v1/content?${t.toString()}`)}async getContentById(e){return this.request(`GET`,`/api/v1/content/${e}`)}async getSingletonContent(e){let t=await this.request(`GET`,`/api/v1/content/singleton/${encodeURIComponent(e)}`);return`content`in t?t.content:t}async createContent(e){return this.request(`POST`,`/api/v1/content`,e)}async updateContent(e,t){return this.request(`PUT`,`/api/v1/content/${e}`,t)}async deleteContent(e){await this.request(`DELETE`,`/api/v1/content/${e}`)}async publishContent(e){let t=await this.request(`POST`,`/api/v1/content/${e}/publish`);return`content`in t?t.content:t}async unpublishContent(e){let t=await this.request(`POST`,`/api/v1/content/${e}/unpublish`);return`content`in t?t.content:t}async publishToggle(e,t){return t?this.unpublishContent(e):this.publishContent(e)}async getContentTypes(){return this.request(`GET`,`/api/v1/content-types`)}async createContentType(e){return this.request(`POST`,`/api/v1/content-types`,e)}async updateContentType(e,t){return this.request(`PUT`,`/api/v1/content-types/${e}`,t)}async deleteContentType(e){await this.request(`DELETE`,`/api/v1/content-types/${e}`)}async getTaxonomies(){return this.request(`GET`,`/api/v1/taxonomies`)}async createTaxonomy(e){return this.request(`POST`,`/api/v1/taxonomies`,e)}async attachTaxonomy(e,t){await this.request(`POST`,`/api/v1/taxonomies/${e}/attach`,{contentType:t})}async detachTaxonomy(e,t){await this.request(`POST`,`/api/v1/taxonomies/${e}/detach`,{contentType:t})}async deleteTaxonomy(e){await this.request(`DELETE`,`/api/v1/taxonomies/${e}`)}async getTaxonomyTerms(e){return this.request(`GET`,`/api/v1/taxonomies/${encodeURIComponent(e)}/terms`)}async createTaxonomyTerm(e,t){return this.request(`POST`,`/api/v1/taxonomies/${encodeURIComponent(e)}/terms`,t)}async updateTaxonomyTerm(e,t,n){return this.request(`PUT`,`/api/v1/taxonomies/${encodeURIComponent(e)}/terms/${t}`,n)}async deleteTaxonomyTerm(e,t){await this.request(`DELETE`,`/api/v1/taxonomies/${encodeURIComponent(e)}/terms/${t}`)}async getComments(e={}){let t=new URLSearchParams;e.status&&t.set(`status`,e.status),e.contentId&&t.set(`contentId`,e.contentId),e.search&&t.set(`search`,e.search),e.limit!==void 0&&t.set(`limit`,String(e.limit)),e.offset!==void 0&&t.set(`offset`,String(e.offset));let n=t.toString();return this.request(`GET`,`/api/v1/comments${n?`?${n}`:``}`)}async updateComment(e,t){return this.request(`PATCH`,`/api/v1/comments/${e}`,t)}async deleteComment(e){await this.request(`DELETE`,`/api/v1/comments/${e}`)}async getCategories(){return this.request(`GET`,`/api/v1/categories`)}async createCategory(e){return this.request(`POST`,`/api/v1/categories`,e)}async updateCategory(e,t){return this.request(`PUT`,`/api/v1/categories/${e}`,t)}async deleteCategory(e){await this.request(`DELETE`,`/api/v1/categories/${e}`)}async getTags(){return this.request(`GET`,`/api/v1/tags`)}async createTag(e){return this.request(`POST`,`/api/v1/tags`,e)}async updateTag(e,t){return this.request(`PUT`,`/api/v1/tags/${e}`,t)}async deleteTag(e){await this.request(`DELETE`,`/api/v1/tags/${e}`)}async getMenus(){return this.request(`GET`,`/api/v1/menus`)}async createMenu(e){return this.request(`POST`,`/api/v1/menus`,e)}async updateMenu(e,t){return this.request(`PUT`,`/api/v1/menus/${e}`,t)}async deleteMenu(e){await this.request(`DELETE`,`/api/v1/menus/${e}`)}async getFieldGroups(e){if(e?.type){let t=new URLSearchParams({type:e.type});for(let[n,r]of Object.entries(e))n!==`type`&&r&&t.set(n,r);return this.request(`GET`,`/api/v1/field-groups?${t.toString()}`)}return this.request(`GET`,`/api/v1/field-groups`)}async getFieldGroup(e){return this.request(`GET`,`/api/v1/field-groups/${e}`)}async exportFieldGroup(e){let t=await this.requestRaw(`GET`,`/api/v1/field-groups/${e}/export`);if(!t.ok)throw Error(await t.text());return t.blob()}async importFieldGroups(e){return this.request(`POST`,`/api/v1/field-groups/import`,e)}async createFieldGroup(e){return this.request(`POST`,`/api/v1/field-groups`,e)}async updateFieldGroup(e,t){return this.request(`PUT`,`/api/v1/field-groups/${e}`,t)}async deleteFieldGroup(e){await this.request(`DELETE`,`/api/v1/field-groups/${e}`)}async getFieldTypes(e){let t=e?`?category=${encodeURIComponent(e)}`:``;return this.request(`GET`,`/api/v1/field-types${t}`)}async getWebhooks(){return this.request(`GET`,`/api/v1/webhooks`)}async getWebhookEvents(){return(await this.request(`GET`,`/api/v1/webhooks/events`)).data}async createWebhook(e){return this.request(`POST`,`/api/v1/webhooks`,e)}async updateWebhook(e,t){return this.request(`PUT`,`/api/v1/webhooks/${e}`,t)}async deleteWebhook(e){await this.request(`DELETE`,`/api/v1/webhooks/${e}`)}async getApiKeys(){return this.request(`GET`,`/api/v1/api-keys`)}async createApiKey(e){return this.request(`POST`,`/api/v1/api-keys`,e)}async deleteApiKey(e){await this.request(`DELETE`,`/api/v1/api-keys/${e}`)}async listMedia(e){let t=new URLSearchParams;return e?.page&&t.set(`page`,String(e.page)),e?.limit&&t.set(`limit`,String(e.limit)),e?.mimeType&&t.set(`mimeType`,e.mimeType),e?.search&&t.set(`search`,e.search),this.request(`GET`,`/api/v1/media?${t.toString()}`)}async getMedia(e){return this.request(`GET`,`/api/v1/media/${e}`)}async uploadMedia(e,n){let r=new FormData;r.append(`file`,e),n?.alt&&r.append(`alt`,n.alt),n?.caption&&r.append(`caption`,n.caption);let i=await this.sendWithRecovery(`POST`,`/api/v1/media/upload`,void 0,{},{bodyInit:r});if(!i.ok)throw await t.fromResponse(i);return i.json()}async updateMedia(e,t){return this.request(`PUT`,`/api/v1/media/${e}`,t)}async replaceMediaFile(e,n){let r=new FormData;r.append(`file`,n);let i=await this.sendWithRecovery(`PUT`,`/api/v1/media/${e}/file`,void 0,{},{bodyInit:r});if(!i.ok)throw await t.fromResponse(i);return i.json()}async deleteMedia(e){await this.request(`DELETE`,`/api/v1/media/${e}`)}async listUsers(e){let t=new URLSearchParams;return e?.page&&t.set(`page`,String(e.page)),e?.limit&&t.set(`limit`,String(e.limit)),e?.search&&t.set(`search`,e.search),e?.status&&t.set(`status`,e.status),this.request(`GET`,`/api/v1/users?${t.toString()}`)}async getUser(e){return this.request(`GET`,`/api/v1/users/${e}`)}async createUser(e){return this.request(`POST`,`/api/v1/users`,e)}async updateUser(e,t){return this.request(`PUT`,`/api/v1/users/${e}`,t)}async deleteUser(e){await this.request(`DELETE`,`/api/v1/users/${e}`)}async setUserPassword(e,t){await this.request(`PUT`,`/api/v1/users/${e}/password`,{password:t})}async assignRole(e,t){return this.request(`POST`,`/api/v1/users/${e}/roles`,{roleId:t})}async removeRole(e,t){return this.request(`DELETE`,`/api/v1/users/${e}/roles/${t}`)}async listRoles(){return this.request(`GET`,`/api/v1/roles`)}async createRole(e){return this.request(`POST`,`/api/v1/roles`,e)}async updateRole(e,t){return this.request(`PUT`,`/api/v1/roles/${e}`,t)}async deleteRole(e){await this.request(`DELETE`,`/api/v1/roles/${e}`)}async listTenants(e){let t=new URLSearchParams;return e?.page&&t.set(`page`,String(e.page)),e?.limit&&t.set(`limit`,String(e.limit)),e?.search&&t.set(`search`,e.search),this.request(`GET`,`/api/v1/tenants?${t.toString()}`)}async createTenant(e){return this.request(`POST`,`/api/v1/tenants`,e)}async updateTenant(e,t){return this.request(`PUT`,`/api/v1/tenants/${e}`,t)}async deleteTenant(e){await this.request(`DELETE`,`/api/v1/tenants/${e}`)}async getSettings(e){let t=e?`?group=${encodeURIComponent(e)}`:``;return this.request(`GET`,`/api/v1/settings${t}`)}async updateSettings(e){await this.request(`PUT`,`/api/v1/settings`,e)}async healthCheck(){return this.request(`GET`,`/health`)}async getThemes(){return(await this.request(`GET`,`/api/v1/themes`)).map(e=>({id:String(e.id??``),name:String(e.name??``),version:e.version?String(e.version):void 0,status:String(e.status??`INSTALLED`),config:e.config??{},manifest:e.manifest??null}))}async syncThemes(){return(await this.request(`POST`,`/api/v1/themes/sync`)).map(e=>({id:String(e.id??``),name:String(e.name??``),version:e.version?String(e.version):void 0,status:String(e.status??`INSTALLED`),config:e.config??{},manifest:e.manifest??null}))}async activateTheme(e){return this.request(`POST`,`/api/v1/themes/${e}/activate`)}async deactivateTheme(e){return this.request(`POST`,`/api/v1/themes/${e}/deactivate`)}async updateThemeConfig(e,t){return this.request(`PATCH`,`/api/v1/themes/${e}/config`,{config:t})}async installTheme(e){return this.request(`POST`,`/api/v1/themes/install`,e)}async getPlugins(){return(await this.request(`GET`,`/api/v1/plugins`)).map(e=>({id:String(e.id??``),name:String(e.name??``),version:String(e.version??``),status:String(e.status??`INSTALLED`),enabled:e.enabled===!0,manifest:e.manifest??null}))}async getAdminExtensions(){return this.request(`GET`,`/api/v1/plugins/extensions`)}async getPluginsRuntime(){return this.request(`GET`,`/api/v1/plugins/runtime`)}};export{d as n,n as t};
@@ -1 +1 @@
1
- import{S as e,a as t,h as n,l as r}from"./solid.Ck4Vtfe4.js";import{_ as i,l as a,o,s}from"./web.DD6VKaIp.js";import"./src.CYKGYEyR.js";import{a as c,i as l,n as u,s as d,t as f}from"./store.CYzqtRKs.js";var p=i(`<div class=sidebar-plugins data-extensions=sidebar><!$><!/><!$><!/>`);function m(){let[i,c]=n(f());e(async()=>{c(await u())});let m=()=>!0;return r(t,{get when(){return i().menuPages.length>0||i().notices.length>0},get children(){var e=o(p),t=e.firstChild,[n,c]=s(t.nextSibling),u=n.nextSibling,[f,h]=s(u.nextSibling);return a(e,r(d,{get extensions(){return i()}}),n,c),a(e,r(l,{get extensions(){return i()},can:m}),f,h),e}})}function h(){let[i,a]=n(f());return e(async()=>{a(await u())}),r(t,{get when(){return i().dashboardWidgets.length>0},get children(){return r(c,{get extensions(){return i()}})}})}export{h as PluginDashboardWidgetsSlot,m as PluginExtensionsSlot,f as emptyExtensionsState};
1
+ import{S as e,a as t,h as n,l as r}from"./solid.Ck4Vtfe4.js";import{_ as i,l as a,o,s}from"./web.DD6VKaIp.js";import"./src.CYKGYEyR.js";import{a as c,i as l,n as u,s as d,t as f}from"./store.DJjOMYcw.js";var p=i(`<div class=sidebar-plugins data-extensions=sidebar><!$><!/><!$><!/>`);function m(){let[i,c]=n(f());e(async()=>{c(await u())});let m=()=>!0;return r(t,{get when(){return i().menuPages.length>0||i().notices.length>0},get children(){var e=o(p),t=e.firstChild,[n,c]=s(t.nextSibling),u=n.nextSibling,[f,h]=s(u.nextSibling);return a(e,r(d,{get extensions(){return i()}}),n,c),a(e,r(l,{get extensions(){return i()},can:m}),f,h),e}})}function h(){let[i,a]=n(f());return e(async()=>{a(await u())}),r(t,{get when(){return i().dashboardWidgets.length>0},get children(){return r(c,{get extensions(){return i()}})}})}export{h as PluginDashboardWidgetsSlot,m as PluginExtensionsSlot,f as emptyExtensionsState};