@plumix/admin 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{-errors-D-cmkYbY.js → -errors-BJp83S61.js} +1 -1
- package/dist/assets/{-locale-param-R7YAVhAm.js → -locale-param-Y_oYVkUX.js} +1 -1
- package/dist/assets/{_-BgcFcUpb.js → _-DJH2KLIq.js} +1 -1
- package/dist/assets/{_authenticated-DabO2Qyv.js → _authenticated-CPS6rcL1.js} +1 -1
- package/dist/assets/{_authenticated-B2GjUlkG.js → _authenticated-DECJJkSG.js} +1 -1
- package/dist/assets/{_editor-Cj750bOw.js → _editor-DTQYo5H1.js} +1 -1
- package/dist/assets/{_name-4UEpyf0-.js → _name-Cn1TxMiD.js} +1 -1
- package/dist/assets/{_page-CW9_6SD1.js → _page-6Dt_H-t-.js} +1 -1
- package/dist/assets/{_page-B65xT7CY.js → _page-Dd9iXh9Y.js} +1 -1
- package/dist/assets/{_slug-B4JG-9fs.js → _slug-DfiOgvp-.js} +1 -1
- package/dist/assets/{_token-DbYWXSFn.js → _token-B5HSAv6u.js} +1 -1
- package/dist/assets/{allowed-domains-DYhKp_Ib.js → allowed-domains-C45hb_hj.js} +1 -1
- package/dist/assets/{bootstrap-DJz3cWv9.js → bootstrap-BGjxcccw.js} +1 -1
- package/dist/assets/breadcrumb-BV7HWDmi.js +1 -0
- package/dist/assets/{create-GWJoFtGc.js → create-Drjr9dfU.js} +1 -1
- package/dist/assets/{create-BBUSAO26.js → create-YjhP8uPI.js} +1 -1
- package/dist/assets/{create-CoSsIQco.js → create-twMn3ZJK.js} +1 -1
- package/dist/assets/{device-EMoc4lMH.js → device-CU0nQStx.js} +1 -1
- package/dist/assets/dist-9yav4OBD.js +46 -0
- package/dist/assets/{edit-DlHnrl_y.js → edit-BfhVPnGf.js} +1 -1
- package/dist/assets/{edit-DR0NupUB.js → edit-Bv4iDBop.js} +1 -1
- package/dist/assets/{edit-Bz9riMHP.js → edit-C7ilZiba.js} +1 -1
- package/dist/assets/{edit-BsC2RNOq.js → edit-CrzTOGqo.js} +1 -1
- package/dist/assets/edit-DVuHDSbc.js +2 -0
- package/dist/assets/{edit-C1985Bqy.js → edit-DwrFb_ta.js} +1 -1
- package/dist/assets/{form-BhMVtuYF.js → form-5CBmFjhZ.js} +1 -1
- package/dist/assets/{index-bWipSZdM.js → index-8CVr3Qp5.js} +4 -4
- package/dist/assets/{login-Cky2mine.js → login-CxdAEUCn.js} +1 -1
- package/dist/assets/{mailer-CnGqwCP4.js → mailer-DT9FFkYI.js} +1 -1
- package/dist/assets/{meta-box-CjxoPlkT.js → meta-box-B-N73b0I.js} +1 -1
- package/dist/assets/{meta-box-field-Cgn0DXDv.js → meta-box-field-gLyOLbwB.js} +1 -1
- package/dist/assets/{meta-box-grid-DJBtTRhe.js → meta-box-grid-CRboB-BG.js} +1 -1
- package/dist/assets/{plugin-error-boundary-3Oze9sdd.js → plugin-error-boundary-DlVIsgFV.js} +1 -1
- package/dist/assets/{rich-text-field-DGbPE_N0.js → rich-text-field-CHHhfy_b.js} +3 -3
- package/dist/assets/{search-input-BpOKuC8D.js → search-input-BSW1rAKi.js} +1 -1
- package/dist/assets/{separator-DCQAFSsS.js → separator-u9O31sRo.js} +1 -1
- package/dist/assets/{settings-DCqQvJiy.js → settings-szU4x17b.js} +1 -1
- package/dist/assets/{textarea-BoWLuA0I.js → textarea-BsZaGkV-.js} +1 -1
- package/dist/assets/{toast-CQk_AYCo.js → toast-UQxADDWA.js} +1 -1
- package/dist/assets/{toggle-Bfw56q6s.js → toggle-BfrQLxbv.js} +1 -1
- package/dist/assets/{tooltip-Pch4JgRX.js → tooltip-Dm_CbtVl.js} +1 -1
- package/dist/assets/{use-formatters-BlYPsMo8.js → use-formatters-HWxEQWaC.js} +1 -1
- package/dist/assets/{users-CYvrBtzp.js → users-BHorpfgX.js} +1 -1
- package/dist/assets/{utils-BBTvNyQG.js → utils-BtfRir_X.js} +2 -2
- package/dist/assets/{valibot-BKzEbLVK.js → valibot-D1tw6tkr.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +9 -9
- package/dist/assets/breadcrumb-TUgLmtOo.js +0 -1
- package/dist/assets/dist-Bdi1pykC.js +0 -46
- package/dist/assets/edit-CG12fZGb.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{n}from"./dist-BL2bKHuR.js";import{t as r}from"./textarea-
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{n}from"./dist-BL2bKHuR.js";import{t as r}from"./textarea-BsZaGkV-.js";import{t as i}from"./use-label-CykSHq9A.js";import{D as a,b as o,d as s,h as c,k as l,l as u,p as d,w as f,x as p,y as m}from"./dist-ClOzYsk5.js";import{n as h,o as g}from"./validation-CwFumc7a.js";import{F as _,I as v,L as y,P as b,Pt as x,R as S}from"./index-8CVr3Qp5.js";import{t as C}from"./input-xYuLUQID.js";import{a as w,f as T,i as E,n as D,o as O,s as k,t as A}from"./form-5CBmFjhZ.js";import{n as j,t as M}from"./alert-cwX3fWUu.js";import{t as N}from"./valibot-D1tw6tkr.js";import{t as P}from"./meta-box-B-N73b0I.js";var F=e(t(),1),I={slugFormat:{id:`termForm.slug.format`},rootOption:{id:`termForm.parent.rootOption`}},L=`__root__`,R=c({name:m(f(),a(),s(1),u(200)),slug:m(f(),a(),u(200),p(/^[a-z0-9-]*$/,g(I.slugFormat))),description:m(f(),a(),u(2e3)),parentId:d(h),meta:o(f(),l())});function z({initialValues:e,isHierarchical:t,parentOptions:a,isSubmitting:o,serverError:s,submitLabel:c,metaBoxes:l,onSubmit:u,onCancel:d}){let f=i(),p=T({resolver:N(R),defaultValues:e}),m=p.handleSubmit(e=>{u(e)});return(0,F.jsx)(A,{...p,children:(0,F.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:m,children:[(0,F.jsx)(E,{control:p.control,name:`name`,render:({field:e})=>(0,F.jsxs)(w,{children:[(0,F.jsx)(O,{children:(0,F.jsx)(n,{id:`termForm.name`,message:`Name`})}),(0,F.jsx)(D,{children:(0,F.jsx)(C,{type:`text`,required:!0,disabled:o,"data-testid":`term-form-name-input`,...e})}),(0,F.jsx)(k,{})]})}),(0,F.jsx)(E,{control:p.control,name:`slug`,render:({field:e})=>(0,F.jsxs)(w,{children:[(0,F.jsx)(O,{children:(0,F.jsx)(n,{id:`termForm.slug`,message:`Slug`})}),(0,F.jsx)(D,{children:(0,F.jsx)(C,{type:`text`,autoComplete:`off`,disabled:o,"data-testid":`term-form-slug-input`,...e})}),(0,F.jsx)(k,{})]})}),(0,F.jsx)(E,{control:p.control,name:`description`,render:({field:e})=>(0,F.jsxs)(w,{children:[(0,F.jsx)(O,{children:(0,F.jsx)(n,{id:`termForm.description`,message:`Description`})}),(0,F.jsx)(D,{children:(0,F.jsx)(r,{...e,disabled:o,rows:3,"data-testid":`term-form-description-input`,className:`min-h-20`})}),(0,F.jsx)(k,{})]})}),t?(0,F.jsx)(E,{control:p.control,name:`parentId`,render:({field:e})=>(0,F.jsxs)(w,{children:[(0,F.jsx)(O,{children:(0,F.jsx)(n,{id:`termForm.parent`,message:`Parent`})}),(0,F.jsxs)(b,{value:e.value==null?L:String(e.value),onValueChange:t=>{e.onChange(t===L?null:Number(t))},disabled:o,children:[(0,F.jsx)(D,{children:(0,F.jsx)(y,{className:`w-full`,onBlur:e.onBlur,"data-testid":`term-form-parent-select`,children:(0,F.jsx)(S,{})})}),(0,F.jsxs)(_,{children:[(0,F.jsx)(v,{value:L,"data-testid":`term-form-parent-select-option-root`,children:f(I.rootOption)}),a.map(e=>(0,F.jsx)(v,{value:String(e.id),"data-testid":`term-form-parent-select-option-${e.id}`,children:e.label},e.id))]})]}),(0,F.jsx)(k,{})]})}):null,l.map(e=>(0,F.jsx)(P,{box:e,basePath:`meta`,disabled:o},e.id)),s?(0,F.jsx)(M,{variant:`destructive`,"data-testid":`term-form-server-error`,children:(0,F.jsx)(j,{children:f(s)})}):null,(0,F.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,F.jsx)(x,{type:`button`,variant:`outline`,onClick:d,disabled:o,children:(0,F.jsx)(n,{id:`termForm.cancel`,message:`Cancel`})}),(0,F.jsx)(x,{type:`submit`,disabled:o,"data-testid":`term-form-submit`,children:o?(0,F.jsx)(n,{id:`termForm.submitting`,message:`Saving…`}):f(c)})]})]})})}var B={slug_taken:{id:`terms.error.slugTaken`},parent_mismatch:{id:`terms.error.parentMismatch`},parent_self_or_cycle:{id:`terms.error.parentSelfOrCycle`}};function V(){let e=i();return(t,n)=>{let r=H(t);return r===`slug_taken`?e(B.slug_taken):r===`parent_mismatch`?e(B.parent_mismatch):r===`parent_is_self`||r===`parent_cycle`?e(B.parent_self_or_cycle):t instanceof Error?t.message:n}}function H(e){if(e&&typeof e==`object`&&`data`in e)return e.data?.reason}export{z as n,V as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{i as n}from"./dist-BL2bKHuR.js";import{o as r}from"./orpc-DURDArDu.js";import{F as i,I as a,L as o,P as s,R as c}from"./index-
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{i as n}from"./dist-BL2bKHuR.js";import{o as r}from"./orpc-DURDArDu.js";import{F as i,I as a,L as o,P as s,R as c}from"./index-8CVr3Qp5.js";function l(e,t){return t===``?e:e===`/`?t:`${t}${e}`}var u=`plumix_locale`,d=`/_plumix/`,f=31536e3;function p(e,t,n=``){let r=[`${u}=${e}`,`Path=${l(d,n)}`,`Max-Age=${f}`,`SameSite=Lax`];return t&&r.push(`Secure`),r.join(`; `)}var m=e(t(),1);function h({currentCode:e,manifest:t,onSelect:r}){let{i18n:l}=n(),u=t.i18n?.locales??[];return u.length<=1?null:(0,m.jsxs)(s,{value:e,onValueChange:r,children:[(0,m.jsx)(o,{"data-testid":`login-locale-switcher-trigger`,"aria-label":l._(`login.locale.aria`,void 0,{message:`Language`}),children:(0,m.jsx)(c,{})}),(0,m.jsx)(i,{children:u.map(e=>(0,m.jsx)(a,{value:e.code,"data-testid":`login-locale-switcher-option-${e.code}`,children:e.label},e.code))})]})}function g(e,t){let{lang:n,...r}=e;return{...r,lang:t}}function _(e,t){let n=g(e,t),r=new URLSearchParams;for(let[e,t]of Object.entries(n))typeof t==`string`?r.set(e,t):typeof t==`number`&&r.set(e,String(t));return`${window.location.pathname}?${r.toString()}`}function v(e,t={}){let n=t.secure??(typeof location<`u`&&location.protocol===`https:`);document.cookie=p(e,n,r())}export{v as n,h as r,_ as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{t as a}from"./use-label-CykSHq9A.js";import{E as o,d as s,w as c}from"./index-
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{t as a}from"./use-label-CykSHq9A.js";import{E as o,d as s,w as c}from"./index-8CVr3Qp5.js";import{t as l}from"./plugin-error-boundary-DlVIsgFV.js";var u=e(n()),d=e(t()),f={loadingAria:{id:`pluginPage.loading.aria`}};function p(){let{navItem:e}=c.useRouteContext(),{i18n:t}=r(),n=a()(e.label),i=e.to.replace(/^\/pages/,``),p=s(i);return p?(0,d.jsx)(l,{kind:`page`,pluginLabel:n,children:(0,d.jsx)(u.Suspense,{fallback:(0,d.jsx)(o,{ariaLabel:t._(f.loadingAria.id,{label:n},{message:f.loadingAria.message}),testId:`plugin-page__loading__${i}`}),children:(0,d.jsx)(p,{})})}):(0,d.jsx)(m,{path:i})}function m({path:e}){return(0,d.jsxs)(`div`,{className:`mx-auto max-w-2xl py-12`,"data-testid":`plugin-page__not-loaded__${e}`,children:[(0,d.jsx)(`h1`,{className:`text-2xl font-semibold`,children:(0,d.jsx)(i,{id:`pluginPage.notLoaded.title`,message:`Plugin not loaded`})}),(0,d.jsx)(`p`,{className:`text-muted-foreground mt-2 text-sm`,children:(0,d.jsx)(i,{id:`pluginPage.notLoaded.body`,message:`The admin manifest declares a page at <code>{path}</code> but no React component has been registered for it.`,values:{path:e},components:{code:(0,d.jsx)(`code`,{className:`font-mono`})},comment:`path: the manifest-declared admin-route path (e.g. '/audit-log'); pass through verbatim`})})]})}export{p as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{f as a,t as o}from"./orpc-DURDArDu.js";import{l as s}from"./esm-DfD3iRfG.js";import{t as c}from"./createLucideIcon-C0O-yxZG.js";import{n as l,t as u}from"./puzzle-CkL6fcG1.js";import{t as d}from"./use-label-CykSHq9A.js";import{t as f}from"./use-formatters-
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{f as a,t as o}from"./orpc-DURDArDu.js";import{l as s}from"./esm-DfD3iRfG.js";import{t as c}from"./createLucideIcon-C0O-yxZG.js";import{n as l,t as u}from"./puzzle-CkL6fcG1.js";import{t as d}from"./use-label-CykSHq9A.js";import{t as f}from"./use-formatters-HWxEQWaC.js";import{a as p,i as m,n as h,r as g,t as _}from"./card-L2-kK5VK.js";import{t as v}from"./skeleton-BnBM1862.js";import{At as y,K as b,Mt as x,Nt as S,Ot as C,Pt as w,ct as T,jt as E,l as D,lt as O}from"./index-8CVr3Qp5.js";import{t as k}from"./dates-CSmOj6E-.js";import{t as A}from"./entries-MizUUcD8.js";import{t as j}from"./plugin-error-boundary-DlVIsgFV.js";var M=c(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),N=e(n(),1),P=e(t(),1);function F({widgets:e}){let t=d(),n=e.flatMap(e=>{let t=D(e.id);return t?[{widget:e,Component:t}]:[]});return n.length===0?null:(0,P.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,"data-testid":`dashboard-widgets`,children:n.map(({widget:e,Component:n})=>(0,P.jsxs)(_,{"data-testid":`dashboard-widget-${e.id}`,children:[(0,P.jsx)(m,{children:(0,P.jsx)(p,{children:t(e.title)})}),(0,P.jsx)(h,{children:(0,P.jsx)(j,{kind:`widget`,pluginLabel:t(e.title),children:(0,P.jsx)(N.Suspense,{fallback:(0,P.jsx)(v,{className:`h-16 w-full`}),children:(0,P.jsx)(n,{})})})})]},e.id))})}var I={countPublished:{id:`dashboard.count.published`},countDraft:{id:`dashboard.count.draft`}};function L(){let{user:e}=b.useRouteContext(),t=e.name??e.email,n=O(e.capabilities),c=d(),{i18n:v}=r(),{formatRelative:D}=f(),j=a(o.entry.stats.queryOptions({input:{}})),L=a(o.entry.recentActivity.queryOptions({input:{limit:8}})),R=(0,N.useMemo)(()=>{let e={};for(let t of j.data??[])(e[t.type]??={})[t.status]=t.count;return e},[j.data]);return(0,P.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h1`,{"data-testid":`dashboard-welcome-heading`,className:`text-2xl font-semibold`,children:(0,P.jsx)(i,{id:`dashboard.welcome`,message:`Welcome, {greeting}`,values:{greeting:(0,P.jsx)(`bdi`,{children:t})},comment:`greeting: the user's display name or email`})}),(0,P.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:(0,P.jsx)(i,{id:`dashboard.tagline`,message:`What would you like to work on today?`})})]}),n.length>0?(0,P.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 lg:grid-cols-3`,children:n.map(e=>{let t=c(e.labels?.plural??e.label),n=R[e.name]??{};return(0,P.jsxs)(_,{"data-testid":`dashboard-tile-${e.name}`,children:[(0,P.jsxs)(m,{children:[(0,P.jsx)(`div`,{className:`bg-primary/10 text-primary mb-2 flex size-10 items-center justify-center rounded-md`,children:(0,P.jsx)(l,{className:`size-5`,"aria-hidden":!0})}),(0,P.jsx)(p,{children:t}),(0,P.jsxs)(g,{"data-testid":`dashboard-tile-${e.name}-counts`,children:[v._(I.countPublished.id,{count:n.published??0},{message:I.countPublished.message}),` · `,v._(I.countDraft.id,{count:n.draft??0},{message:I.countDraft.message})]})]}),(0,P.jsx)(h,{children:(0,P.jsx)(w,{asChild:!0,variant:`outline`,className:`w-full`,children:(0,P.jsxs)(s,{to:`/entries/$slug`,params:{slug:e.adminSlug},search:A,"data-testid":`dashboard-tile-${e.name}-link`,children:[(0,P.jsx)(i,{id:`dashboard.tile.browse.generic`,message:`Browse`}),(0,P.jsx)(M,{className:`rtl:rotate-180`})]})})})]},e.name)})}):(0,P.jsx)(_,{className:`max-w-xl`,"data-testid":`dashboard-empty-state`,children:(0,P.jsx)(C,{children:(0,P.jsxs)(E,{children:[(0,P.jsx)(x,{variant:`icon`,children:(0,P.jsx)(u,{})}),(0,P.jsx)(S,{children:(0,P.jsx)(i,{id:`dashboard.empty.title`,message:`No content types yet`})}),(0,P.jsx)(y,{children:(0,P.jsx)(i,{id:`dashboard.empty.description`,message:`Add a plugin that registers a post type (e.g. <0>@plumix/plugin-blog</0>) to see it here.`,components:{0:(0,P.jsx)(`code`,{})}})})]})})}),n.length>0?(0,P.jsxs)(_,{"data-testid":`dashboard-recent-activity`,children:[(0,P.jsx)(m,{children:(0,P.jsx)(p,{children:(0,P.jsx)(i,{id:`dashboard.recent.title`,message:`Recent activity`})})}),(0,P.jsx)(h,{children:(L.data??[]).length===0?(0,P.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:(0,P.jsx)(i,{id:`dashboard.recent.empty`,message:`Nothing yet.`})}):(0,P.jsx)(`ul`,{className:`flex flex-col divide-y`,children:(L.data??[]).map(e=>{let t=n.find(t=>t.name===e.type),r=(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{className:`truncate`,children:e.title}),(0,P.jsx)(`span`,{className:`text-muted-foreground ms-auto shrink-0 text-xs`,children:D(k(e.updatedAt))})]});return(0,P.jsx)(`li`,{"data-testid":`dashboard-recent-${e.id}`,children:t?(0,P.jsx)(s,{to:`/entries/$slug/$id/edit`,params:{slug:t.adminSlug,id:e.id},className:`hover:text-primary flex items-center gap-2 py-2 text-sm`,children:r}):(0,P.jsx)(`div`,{className:`flex items-center gap-2 py-2 text-sm`,children:r})},e.id)})})})]}):null,(0,P.jsx)(F,{widgets:T(e.capabilities)})]})}export{L as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{f as a,s as o,t as ee,u as s}from"./orpc-DURDArDu.js";import{a as c,d as l,l as u,n as d,u as f}from"./esm-DfD3iRfG.js";import{t as p}from"./createLucideIcon-C0O-yxZG.js";import{A as m,B as h,C as g,D as _,E as v,H as y,I as b,L as x,M as te,N as ne,O as re,P as ie,R as S,S as ae,T as C,V as w,a as T,b as oe,d as se,f as E,g as ce,h as le,i as ue,j as de,k as fe,l as pe,m as me,n as he,o as D,p as O,r as k,s as A,t as j,u as M,v as N,w as P,x as F,y as I,z as L}from"./breadcrumb-TUgLmtOo.js";import{t as R}from"./chevrons-up-down-DmmG8bmI.js";import{n as z,t as B}from"./puzzle-CkL6fcG1.js";import{t as V}from"./settings-K6TF73jB.js";import{t as H}from"./use-label-CykSHq9A.js";import{Q as U,St as ge,X as _e,Y as ve,n as ye,q as be,st as W,t as xe}from"./index-bWipSZdM.js";import{i as Se}from"./passkey-C_CqNV1S.js";import{t as G}from"./separator-DCQAFSsS.js";import{r as Ce}from"./tooltip-Pch4JgRX.js";var we=p(`panels-top-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M9 21V9`,key:`1oto5p`}]]),Te=p(`calendar`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}]]),Ee=p(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),De=p(`key`,[[`path`,{d:`m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4`,key:`g0fldk`}],[`path`,{d:`m21 2-9.6 9.6`,key:`1j0ho8`}],[`circle`,{cx:`7.5`,cy:`15.5`,r:`5.5`,key:`yqb3hr`}]]),Oe=p(`layout-dashboard`,[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]),ke=p(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),Ae=p(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]),je=p(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]),Me=p(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),Ne=p(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),K=e(t(),1),Pe={dashboard:Oe,content:z,"file-text":z,layout:we,image:ge,calendar:Te,tag:je,folder:Ee,users:Ne,settings:V,puzzle:B,mail:Ae,key:De};function q({name:e}){return(0,K.jsx)(e?Pe[e]:B,{})}function Fe({user:e}){let{isMobile:t}=y(),n=l(),r=s({mutationFn:Se,onSettled:async e=>{if(await n.invalidate(),n.options.context.queryClient.removeQueries({queryKey:ve}),e?.redirectTo){window.location.assign(e.redirectTo);return}await n.navigate({to:`/login`})}}),a=e.name??e.email,o=a.slice(0,2).toUpperCase();return(0,K.jsxs)(oe,{children:[(0,K.jsx)(v,{asChild:!0,children:(0,K.jsxs)(S,{size:`lg`,"data-testid":`user-menu-trigger`,className:`data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground`,children:[(0,K.jsx)(_,{className:`size-8`,children:(0,K.jsx)(re,{className:`bg-sidebar-accent text-sidebar-accent-foreground text-xs font-semibold`,children:o})}),(0,K.jsxs)(`div`,{className:`grid flex-1 text-start text-sm leading-tight`,children:[(0,K.jsx)(`span`,{className:`truncate font-medium`,children:a}),(0,K.jsx)(`span`,{className:`text-muted-foreground truncate text-xs`,children:e.email})]}),(0,K.jsx)(R,{className:`ms-auto size-4`})]})}),(0,K.jsxs)(F,{className:`w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg`,side:t?`bottom`:`right`,align:`end`,sideOffset:4,children:[(0,K.jsx)(P,{className:`p-0 font-normal`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-1 py-1.5 text-start text-sm`,children:[(0,K.jsx)(`div`,{"aria-hidden":!0,className:`bg-sidebar-accent text-sidebar-accent-foreground flex size-8 items-center justify-center rounded-md text-xs font-semibold`,children:o}),(0,K.jsxs)(`div`,{className:`grid flex-1 text-start text-sm leading-tight`,children:[(0,K.jsx)(`span`,{className:`truncate font-medium`,children:a}),(0,K.jsx)(`span`,{className:`text-muted-foreground truncate text-xs`,children:e.email})]})]})}),(0,K.jsx)(C,{}),(0,K.jsxs)(ae,{children:[(0,K.jsx)(g,{asChild:!0,children:(0,K.jsxs)(u,{to:`/profile`,"data-testid":`user-menu-profile-link`,children:[(0,K.jsx)(Me,{className:`size-4`}),(0,K.jsx)(i,{id:`menu.profile`,message:`Profile`})]})}),(0,K.jsxs)(g,{disabled:!0,children:[(0,K.jsx)(V,{className:`size-4`}),(0,K.jsx)(i,{id:`menu.settings`,message:`Settings`})]})]}),(0,K.jsx)(C,{}),(0,K.jsxs)(g,{onSelect:()=>r.mutate(),disabled:r.isPending,"data-testid":`user-menu-sign-out`,children:[(0,K.jsx)(ke,{className:`size-4`}),r.isPending?(0,K.jsx)(i,{id:`menu.signOut.pending`,message:`Signing out…`}):(0,K.jsx)(i,{id:`menu.signOut`,message:`Sign out`})]})]})]})}function Ie({user:e,capabilities:t}){let n=W(t),r=H();return(0,K.jsxs)(fe,{collapsible:`icon`,variant:`inset`,children:[(0,K.jsx)(m,{children:n.map(e=>(0,K.jsxs)(te,{children:[(0,K.jsx)(ie,{children:r(e.label)}),(0,K.jsx)(ne,{children:(0,K.jsx)(x,{children:e.items.map(e=>(0,K.jsx)(L,{children:(0,K.jsx)(S,{asChild:!0,tooltip:r(e.label),children:(0,K.jsxs)(u,{to:e.to,activeProps:{"data-active":`true`},activeOptions:{exact:e.exact??!1},children:[(0,K.jsx)(q,{name:e.coreIcon}),(0,K.jsx)(`span`,{children:r(e.label)})]})})},e.to))})})]},e.id))}),(0,K.jsx)(de,{children:(0,K.jsx)(x,{children:(0,K.jsx)(L,{children:(0,K.jsx)(Fe,{user:e})})})})]})}var J=e(n(),1);function Le(e,t){return W(e,t).flatMap(e=>e.items.map(e=>({to:e.to,label:e.label,...e.coreIcon?{coreIcon:e.coreIcon}:{},...e.keywords?{keywords:e.keywords}:{}})))}function Re(e,t,n){let r=t.trim().toLowerCase();return r.length===0?e:e.filter(e=>[e.label,...e.keywords??[]].map(n).join(` `).toLowerCase().includes(r))}function Y(e){let t=e.indexOf(`:`);return t===-1?{domain:e,name:``}:{domain:e.slice(0,t),name:e.slice(t+1)}}function ze(e,t,n){let{domain:r,name:i}=Y(e),a=encodeURIComponent(t);switch(r){case`entry`:return`${o}/entries/${encodeURIComponent(n(i))}/${a}/edit`;case`term`:return`${o}/terms/${encodeURIComponent(i)}/${a}/edit`;case`users`:return`${o}/users/${a}/edit`;default:return null}}function Be(e){return e.metaKey||e.ctrlKey}var X=`plumix.v2.palette.recent`,Ve=8;function He(e){try{let t=[e,...Z().filter(t=>t!==e)].slice(0,Ve);localStorage.setItem(X,JSON.stringify(t))}catch{}}function Z(){try{let e=localStorage.getItem(X);if(e===null)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Ue(e,t,n){let r=new Map(e.map(e=>[e.to,e])),i=[];for(let e of t){let t=r.get(e);if(t&&i.push(t),i.length>=n)break}return i}var Q=2,We=250,Ge=5,$={title:{id:`palette.title`},description:{id:`palette.description`},placeholder:{id:`palette.placeholder`},empty:{id:`palette.empty`},navigation:{id:`palette.group.navigation`},recent:{id:`palette.group.recent`},commands:{id:`palette.group.commands`},loading:{id:`palette.loading`},hintNavigate:{id:`palette.hint.navigate`},hintSelect:{id:`palette.hint.select`},hintClose:{id:`palette.hint.close`}},Ke=[{id:`core:profile`,title:{id:`palette.command.profile`},coreIcon:`users`,run:({navigate:e})=>void e({to:`/profile`})},{id:`core:settings`,title:{id:`palette.command.settings`},coreIcon:`settings`,capability:`settings:manage`,run:({navigate:e})=>void e({to:`/settings`})}];function qe(e,t){let[n,r]=(0,J.useState)(e);return(0,J.useEffect)(()=>{let n=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(n)}},[e,t]),n}function Je({capabilities:e}){let[t,n]=(0,J.useState)(!1),[r,i]=(0,J.useState)(``),o=f(),s=H(),c=(0,J.useRef)(!1);(0,J.useEffect)(()=>{function e(e){e.key===`k`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),n(e=>!e))}return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[]);let l=r.trim(),u=qe(l,We),d=a(ee.search.query.queryOptions({input:{query:u},enabled:t&&u.length>=Q})),p=ye([...Ke,...xe()],e,l,s),m=Re(Le(e),l,s),h=t&&l.length===0?Ue(m,Z(),Ge):[],g=l.length>=Q?d.data??[]:[],_=l.length>=Q&&(l!==u||d.isFetching);function v(){n(!1),i(``)}function y(e){He(e),v(),o({to:e})}function b(e,t){let n=c.current;if(c.current=!1,v(),n){let n=ze(e,t,e=>U(e)?.adminSlug??e);n&&window.open(n,`_blank`,`noopener,noreferrer`);return}let{domain:r,name:i}=Y(e);switch(r){case`entry`:o({to:`/entries/$slug/$id/edit`,params:{slug:U(i)?.adminSlug??i,id:Number(t)}});return;case`term`:o({to:`/terms/$name/$id/edit`,params:{name:i,id:Number(t)}});return;case`users`:o({to:`/users/$id/edit`,params:{id:Number(t)}});return}}function x(e){c.current=Be(e)}return(0,K.jsxs)(me,{open:t,onOpenChange:e=>{n(e),e||i(``)},children:[(0,K.jsxs)(N,{className:`sr-only`,children:[(0,K.jsx)(I,{children:s($.title)}),(0,K.jsx)(ce,{children:s($.description)})]}),(0,K.jsx)(le,{className:`overflow-hidden p-0`,children:(0,K.jsxs)(A,{shouldFilter:!1,onClickCapture:x,onKeyDown:e=>{e.key===`Enter`&&x(e)},children:[(0,K.jsx)(se,{value:r,onValueChange:i,"data-testid":`command-palette-input`,placeholder:s($.placeholder)}),(0,K.jsxs)(O,{children:[_?(0,K.jsx)(`div`,{"data-testid":`command-palette-loading`,className:`text-muted-foreground px-3 py-2 text-sm`,children:s($.loading)}):(0,K.jsx)(pe,{children:s($.empty)}),h.length>0?(0,K.jsx)(M,{heading:s($.recent),children:h.map(e=>(0,K.jsxs)(E,{value:`recent:${e.to}`,"data-testid":`command-palette-recent-${e.to}`,onSelect:()=>{y(e.to)},children:[(0,K.jsx)(q,{name:e.coreIcon}),(0,K.jsx)(`span`,{children:s(e.label)})]},`recent:${e.to}`))}):null,p.length>0?(0,K.jsx)(M,{heading:s($.commands),children:p.map(e=>(0,K.jsxs)(E,{value:e.id,"data-testid":`command-palette-command-${e.id}`,onSelect:()=>{v(),e.run({navigate:o})},children:[e.coreIcon?(0,K.jsx)(q,{name:e.coreIcon}):null,(0,K.jsx)(`span`,{children:s(e.title)})]},e.id))}):null,m.length>0?(0,K.jsx)(M,{heading:s($.navigation),children:m.map(e=>(0,K.jsxs)(E,{value:e.to,"data-testid":`command-palette-nav-${e.to}`,onSelect:()=>{y(e.to)},children:[(0,K.jsx)(q,{name:e.coreIcon}),(0,K.jsx)(`span`,{children:s(e.label)})]},e.to))}):null,g.map(e=>(0,K.jsx)(M,{heading:s(e.label),children:e.items.map(t=>(0,K.jsx)(E,{value:`${e.key}:${t.id}`,"data-testid":`command-palette-result-${e.key}:${t.id}`,onSelect:()=>{b(e.key,t.id)},children:(0,K.jsx)(`span`,{children:t.title})},`${e.key}:${t.id}`))},e.key))]}),(0,K.jsxs)(`div`,{"data-testid":`command-palette-footer`,className:`text-muted-foreground flex items-center gap-4 border-t px-3 py-2 text-xs`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(D,{children:`↑↓`}),s($.hintNavigate)]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(D,{children:`↵`}),s($.hintSelect)]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(D,{children:`⎋`}),s($.hintClose)]})]})]})})]})}function Ye(){return _e(d({select:e=>e.location.pathname}))}function Xe(){let e=Ye(),{i18n:t}=r(),n=e=>typeof e.label==`string`?e.label:t._(e.label.id,e.values,{message:e.label.message});return(0,K.jsxs)(`header`,{className:`flex h-14 shrink-0 items-center gap-2 border-b px-4`,children:[(0,K.jsx)(w,{className:`-ms-1`}),(0,K.jsx)(G,{orientation:`vertical`,className:`me-2 h-4`}),(0,K.jsx)(j,{children:(0,K.jsx)(k,{children:e.map((t,r)=>{let i=r===e.length-1,a=n(t);return(0,K.jsxs)(J.Fragment,{children:[r>0?(0,K.jsx)(T,{}):null,(0,K.jsx)(he,{children:i?(0,K.jsx)(ue,{children:a}):t.to===void 0?(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:a}):(0,K.jsx)(u,{to:t.to,className:`text-muted-foreground hover:text-foreground transition-colors`,children:a})})]},`${String(r)}-${a}`)})})})]})}function Ze(){let{user:e}=be.useRouteContext();return(0,K.jsx)(Ce,{delayDuration:100,children:(0,K.jsxs)(h,{children:[(0,K.jsx)(Je,{capabilities:e.capabilities}),(0,K.jsx)(Ie,{user:e,capabilities:e.capabilities}),(0,K.jsxs)(b,{children:[(0,K.jsx)(Xe,{}),(0,K.jsx)(`main`,{className:`flex-1 overflow-y-auto p-6`,children:(0,K.jsx)(c,{})})]})]})})}export{Ze as component};
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{f as a,s as o,t as ee,u as s}from"./orpc-DURDArDu.js";import{a as c,d as l,l as u,n as d,u as f}from"./esm-DfD3iRfG.js";import{t as p}from"./createLucideIcon-C0O-yxZG.js";import{A as m,B as h,C as g,D as _,E as v,H as y,I as b,L as x,M as te,N as ne,O as re,P as ie,R as S,S as ae,T as C,V as w,a as T,b as oe,d as se,f as E,g as ce,h as le,i as ue,j as de,k as fe,l as pe,m as me,n as he,o as D,p as O,r as k,s as A,t as j,u as M,v as N,w as P,x as F,y as I,z as L}from"./breadcrumb-BV7HWDmi.js";import{t as R}from"./chevrons-up-down-DmmG8bmI.js";import{n as z,t as B}from"./puzzle-CkL6fcG1.js";import{t as V}from"./settings-K6TF73jB.js";import{t as H}from"./use-label-CykSHq9A.js";import{Q as U,St as ge,X as _e,Y as ve,n as ye,q as be,st as W,t as xe}from"./index-8CVr3Qp5.js";import{i as Se}from"./passkey-C_CqNV1S.js";import{t as G}from"./separator-u9O31sRo.js";import{r as Ce}from"./tooltip-Dm_CbtVl.js";var we=p(`panels-top-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M9 21V9`,key:`1oto5p`}]]),Te=p(`calendar`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}]]),Ee=p(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),De=p(`key`,[[`path`,{d:`m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4`,key:`g0fldk`}],[`path`,{d:`m21 2-9.6 9.6`,key:`1j0ho8`}],[`circle`,{cx:`7.5`,cy:`15.5`,r:`5.5`,key:`yqb3hr`}]]),Oe=p(`layout-dashboard`,[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]),ke=p(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),Ae=p(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]),je=p(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]),Me=p(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),Ne=p(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),K=e(t(),1),Pe={dashboard:Oe,content:z,"file-text":z,layout:we,image:ge,calendar:Te,tag:je,folder:Ee,users:Ne,settings:V,puzzle:B,mail:Ae,key:De};function q({name:e}){return(0,K.jsx)(e?Pe[e]:B,{})}function Fe({user:e}){let{isMobile:t}=y(),n=l(),r=s({mutationFn:Se,onSettled:async e=>{if(await n.invalidate(),n.options.context.queryClient.removeQueries({queryKey:ve}),e?.redirectTo){window.location.assign(e.redirectTo);return}await n.navigate({to:`/login`})}}),a=e.name??e.email,o=a.slice(0,2).toUpperCase();return(0,K.jsxs)(oe,{children:[(0,K.jsx)(v,{asChild:!0,children:(0,K.jsxs)(S,{size:`lg`,"data-testid":`user-menu-trigger`,className:`data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground`,children:[(0,K.jsx)(_,{className:`size-8`,children:(0,K.jsx)(re,{className:`bg-sidebar-accent text-sidebar-accent-foreground text-xs font-semibold`,children:o})}),(0,K.jsxs)(`div`,{className:`grid flex-1 text-start text-sm leading-tight`,children:[(0,K.jsx)(`span`,{className:`truncate font-medium`,children:a}),(0,K.jsx)(`span`,{className:`text-muted-foreground truncate text-xs`,children:e.email})]}),(0,K.jsx)(R,{className:`ms-auto size-4`})]})}),(0,K.jsxs)(F,{className:`w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg`,side:t?`bottom`:`right`,align:`end`,sideOffset:4,children:[(0,K.jsx)(P,{className:`p-0 font-normal`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-1 py-1.5 text-start text-sm`,children:[(0,K.jsx)(`div`,{"aria-hidden":!0,className:`bg-sidebar-accent text-sidebar-accent-foreground flex size-8 items-center justify-center rounded-md text-xs font-semibold`,children:o}),(0,K.jsxs)(`div`,{className:`grid flex-1 text-start text-sm leading-tight`,children:[(0,K.jsx)(`span`,{className:`truncate font-medium`,children:a}),(0,K.jsx)(`span`,{className:`text-muted-foreground truncate text-xs`,children:e.email})]})]})}),(0,K.jsx)(C,{}),(0,K.jsxs)(ae,{children:[(0,K.jsx)(g,{asChild:!0,children:(0,K.jsxs)(u,{to:`/profile`,"data-testid":`user-menu-profile-link`,children:[(0,K.jsx)(Me,{className:`size-4`}),(0,K.jsx)(i,{id:`menu.profile`,message:`Profile`})]})}),(0,K.jsxs)(g,{disabled:!0,children:[(0,K.jsx)(V,{className:`size-4`}),(0,K.jsx)(i,{id:`menu.settings`,message:`Settings`})]})]}),(0,K.jsx)(C,{}),(0,K.jsxs)(g,{onSelect:()=>r.mutate(),disabled:r.isPending,"data-testid":`user-menu-sign-out`,children:[(0,K.jsx)(ke,{className:`size-4`}),r.isPending?(0,K.jsx)(i,{id:`menu.signOut.pending`,message:`Signing out…`}):(0,K.jsx)(i,{id:`menu.signOut`,message:`Sign out`})]})]})]})}function Ie({user:e,capabilities:t}){let n=W(t),r=H();return(0,K.jsxs)(fe,{collapsible:`icon`,variant:`inset`,children:[(0,K.jsx)(m,{children:n.map(e=>(0,K.jsxs)(te,{children:[(0,K.jsx)(ie,{children:r(e.label)}),(0,K.jsx)(ne,{children:(0,K.jsx)(x,{children:e.items.map(e=>(0,K.jsx)(L,{children:(0,K.jsx)(S,{asChild:!0,tooltip:r(e.label),children:(0,K.jsxs)(u,{to:e.to,activeProps:{"data-active":`true`},activeOptions:{exact:e.exact??!1},children:[(0,K.jsx)(q,{name:e.coreIcon}),(0,K.jsx)(`span`,{children:r(e.label)})]})})},e.to))})})]},e.id))}),(0,K.jsx)(de,{children:(0,K.jsx)(x,{children:(0,K.jsx)(L,{children:(0,K.jsx)(Fe,{user:e})})})})]})}var J=e(n(),1);function Le(e,t){return W(e,t).flatMap(e=>e.items.map(e=>({to:e.to,label:e.label,...e.coreIcon?{coreIcon:e.coreIcon}:{},...e.keywords?{keywords:e.keywords}:{}})))}function Re(e,t,n){let r=t.trim().toLowerCase();return r.length===0?e:e.filter(e=>[e.label,...e.keywords??[]].map(n).join(` `).toLowerCase().includes(r))}function Y(e){let t=e.indexOf(`:`);return t===-1?{domain:e,name:``}:{domain:e.slice(0,t),name:e.slice(t+1)}}function ze(e,t,n){let{domain:r,name:i}=Y(e),a=encodeURIComponent(t);switch(r){case`entry`:return`${o}/entries/${encodeURIComponent(n(i))}/${a}/edit`;case`term`:return`${o}/terms/${encodeURIComponent(i)}/${a}/edit`;case`users`:return`${o}/users/${a}/edit`;default:return null}}function Be(e){return e.metaKey||e.ctrlKey}var X=`plumix.v2.palette.recent`,Ve=8;function He(e){try{let t=[e,...Z().filter(t=>t!==e)].slice(0,Ve);localStorage.setItem(X,JSON.stringify(t))}catch{}}function Z(){try{let e=localStorage.getItem(X);if(e===null)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Ue(e,t,n){let r=new Map(e.map(e=>[e.to,e])),i=[];for(let e of t){let t=r.get(e);if(t&&i.push(t),i.length>=n)break}return i}var Q=2,We=250,Ge=5,$={title:{id:`palette.title`},description:{id:`palette.description`},placeholder:{id:`palette.placeholder`},empty:{id:`palette.empty`},navigation:{id:`palette.group.navigation`},recent:{id:`palette.group.recent`},commands:{id:`palette.group.commands`},loading:{id:`palette.loading`},hintNavigate:{id:`palette.hint.navigate`},hintSelect:{id:`palette.hint.select`},hintClose:{id:`palette.hint.close`}},Ke=[{id:`core:profile`,title:{id:`palette.command.profile`},coreIcon:`users`,run:({navigate:e})=>void e({to:`/profile`})},{id:`core:settings`,title:{id:`palette.command.settings`},coreIcon:`settings`,capability:`settings:manage`,run:({navigate:e})=>void e({to:`/settings`})}];function qe(e,t){let[n,r]=(0,J.useState)(e);return(0,J.useEffect)(()=>{let n=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(n)}},[e,t]),n}function Je({capabilities:e}){let[t,n]=(0,J.useState)(!1),[r,i]=(0,J.useState)(``),o=f(),s=H(),c=(0,J.useRef)(!1);(0,J.useEffect)(()=>{function e(e){e.key===`k`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),n(e=>!e))}return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[]);let l=r.trim(),u=qe(l,We),d=a(ee.search.query.queryOptions({input:{query:u},enabled:t&&u.length>=Q})),p=ye([...Ke,...xe()],e,l,s),m=Re(Le(e),l,s),h=t&&l.length===0?Ue(m,Z(),Ge):[],g=l.length>=Q?d.data??[]:[],_=l.length>=Q&&(l!==u||d.isFetching);function v(){n(!1),i(``)}function y(e){He(e),v(),o({to:e})}function b(e,t){let n=c.current;if(c.current=!1,v(),n){let n=ze(e,t,e=>U(e)?.adminSlug??e);n&&window.open(n,`_blank`,`noopener,noreferrer`);return}let{domain:r,name:i}=Y(e);switch(r){case`entry`:o({to:`/entries/$slug/$id/edit`,params:{slug:U(i)?.adminSlug??i,id:Number(t)}});return;case`term`:o({to:`/terms/$name/$id/edit`,params:{name:i,id:Number(t)}});return;case`users`:o({to:`/users/$id/edit`,params:{id:Number(t)}});return}}function x(e){c.current=Be(e)}return(0,K.jsxs)(me,{open:t,onOpenChange:e=>{n(e),e||i(``)},children:[(0,K.jsxs)(N,{className:`sr-only`,children:[(0,K.jsx)(I,{children:s($.title)}),(0,K.jsx)(ce,{children:s($.description)})]}),(0,K.jsx)(le,{className:`overflow-hidden p-0`,children:(0,K.jsxs)(A,{shouldFilter:!1,onClickCapture:x,onKeyDown:e=>{e.key===`Enter`&&x(e)},children:[(0,K.jsx)(se,{value:r,onValueChange:i,"data-testid":`command-palette-input`,placeholder:s($.placeholder)}),(0,K.jsxs)(O,{children:[_?(0,K.jsx)(`div`,{"data-testid":`command-palette-loading`,className:`text-muted-foreground px-3 py-2 text-sm`,children:s($.loading)}):(0,K.jsx)(pe,{children:s($.empty)}),h.length>0?(0,K.jsx)(M,{heading:s($.recent),children:h.map(e=>(0,K.jsxs)(E,{value:`recent:${e.to}`,"data-testid":`command-palette-recent-${e.to}`,onSelect:()=>{y(e.to)},children:[(0,K.jsx)(q,{name:e.coreIcon}),(0,K.jsx)(`span`,{children:s(e.label)})]},`recent:${e.to}`))}):null,p.length>0?(0,K.jsx)(M,{heading:s($.commands),children:p.map(e=>(0,K.jsxs)(E,{value:e.id,"data-testid":`command-palette-command-${e.id}`,onSelect:()=>{v(),e.run({navigate:o})},children:[e.coreIcon?(0,K.jsx)(q,{name:e.coreIcon}):null,(0,K.jsx)(`span`,{children:s(e.title)})]},e.id))}):null,m.length>0?(0,K.jsx)(M,{heading:s($.navigation),children:m.map(e=>(0,K.jsxs)(E,{value:e.to,"data-testid":`command-palette-nav-${e.to}`,onSelect:()=>{y(e.to)},children:[(0,K.jsx)(q,{name:e.coreIcon}),(0,K.jsx)(`span`,{children:s(e.label)})]},e.to))}):null,g.map(e=>(0,K.jsx)(M,{heading:s(e.label),children:e.items.map(t=>(0,K.jsx)(E,{value:`${e.key}:${t.id}`,"data-testid":`command-palette-result-${e.key}:${t.id}`,onSelect:()=>{b(e.key,t.id)},children:(0,K.jsx)(`span`,{children:t.title})},`${e.key}:${t.id}`))},e.key))]}),(0,K.jsxs)(`div`,{"data-testid":`command-palette-footer`,className:`text-muted-foreground flex items-center gap-4 border-t px-3 py-2 text-xs`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(D,{children:`↑↓`}),s($.hintNavigate)]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(D,{children:`↵`}),s($.hintSelect)]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(D,{children:`⎋`}),s($.hintClose)]})]})]})})]})}function Ye(){return _e(d({select:e=>e.location.pathname}))}function Xe(){let e=Ye(),{i18n:t}=r(),n=e=>typeof e.label==`string`?e.label:t._(e.label.id,e.values,{message:e.label.message});return(0,K.jsxs)(`header`,{className:`flex h-14 shrink-0 items-center gap-2 border-b px-4`,children:[(0,K.jsx)(w,{className:`-ms-1`}),(0,K.jsx)(G,{orientation:`vertical`,className:`me-2 h-4`}),(0,K.jsx)(j,{children:(0,K.jsx)(k,{children:e.map((t,r)=>{let i=r===e.length-1,a=n(t);return(0,K.jsxs)(J.Fragment,{children:[r>0?(0,K.jsx)(T,{}):null,(0,K.jsx)(he,{children:i?(0,K.jsx)(ue,{children:a}):t.to===void 0?(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:a}):(0,K.jsx)(u,{to:t.to,className:`text-muted-foreground hover:text-foreground transition-colors`,children:a})})]},`${String(r)}-${a}`)})})})]})}function Ze(){let{user:e}=be.useRouteContext();return(0,K.jsx)(Ce,{delayDuration:100,children:(0,K.jsxs)(h,{children:[(0,K.jsx)(Je,{capabilities:e.capabilities}),(0,K.jsx)(Ie,{user:e,capabilities:e.capabilities}),(0,K.jsxs)(b,{children:[(0,K.jsx)(Xe,{}),(0,K.jsx)(`main`,{className:`flex-1 overflow-y-auto p-6`,children:(0,K.jsx)(c,{})})]})]})})}export{Ze as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{a as n}from"./esm-DfD3iRfG.js";import{r}from"./tooltip-
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{a as n}from"./esm-DfD3iRfG.js";import{r}from"./tooltip-Dm_CbtVl.js";var i=e(t());function a(){return(0,i.jsx)(r,{delayDuration:100,children:(0,i.jsx)(`div`,{className:`flex h-dvh flex-col`,children:(0,i.jsx)(n,{})})})}export{a as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{n as r}from"./dist-BL2bKHuR.js";import{f as i,t as a}from"./orpc-DURDArDu.js";import{l as o}from"./esm-DfD3iRfG.js";import{n as s,r as c,t as l}from"./search-input-
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{n as r}from"./dist-BL2bKHuR.js";import{f as i,t as a}from"./orpc-DURDArDu.js";import{l as o}from"./esm-DfD3iRfG.js";import{n as s,r as c,t as l}from"./search-input-BSW1rAKi.js";import{X as u}from"./utils-BtfRir_X.js";import{t as d}from"./use-label-CykSHq9A.js";import{n as f}from"./type-labels-DEpt0nSb.js";import{At as p,Nt as m,Ot as h,Pt as g,V as _,jt as v,kt as y,x as b}from"./index-8CVr3Qp5.js";import{n as x,t as S}from"./alert-cwX3fWUu.js";import{r as C,t as w}from"./tree-BUpunTXw.js";var T=e(n()),E=e(t()),D={columnName:{id:`terms.list.column.name`},columnDescription:{id:`terms.list.column.description`}},O=50,k=200;function A(e,t,n){return!t||n?e.map(e=>({term:e,displayDepth:0})):C(w(e)).map(e=>({term:e.term,displayDepth:e.depth}))}function j(){let e=b.useNavigate();return{setPage:(0,T.useCallback)(t=>{e({search:e=>({...e,page:t})})},[e]),setSearch:(0,T.useCallback)(t=>{e({search:e=>({...e,q:t,page:1})})},[e])}}function M(){let e=b.useSearch(),{user:t,taxonomy:n}=b.useRouteContext(),r=d(),p=n.isHierarchical===!0,m=p?k:O,h=i(a.term.list.queryOptions({input:{taxonomy:n.name,limit:m,offset:(e.page-1)*m,...e.q?{search:e.q}:{}}})),{setPage:v,setSearch:y}=j(),C=h.data,w=(0,T.useMemo)(()=>A(C??[],p,!!e.q),[C,p,e.q]),M=e.page>1,P=(C?.length??0)===m,F=_(t.capabilities,`term:${n.name}:edit`),I=(0,T.useMemo)(()=>[{accessorKey:`name`,header:r(D.columnName),cell:({row:e})=>{let t=e.original.term,r=e.original.displayDepth;return(0,E.jsxs)(o,{to:`/terms/$name/$id/edit`,params:{name:n.name,id:t.id},"data-testid":`taxonomy-list-row-${String(t.id)}`,"aria-level":r+1,className:`hover:text-primary flex min-w-0 flex-col transition-colors`,children:[(0,E.jsxs)(`span`,{className:`font-medium`,children:[r>0?(0,E.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/60 me-1 font-normal select-none`,children:`— `.repeat(r)}):null,t.name]}),(0,E.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:t.slug})]})}},{accessorKey:`description`,header:r(D.columnDescription),cell:({row:e})=>{let t=e.original.term.description;return t===null||t.length===0?(0,E.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`—`}):(0,E.jsx)(`span`,{className:`text-muted-foreground line-clamp-1 text-sm`,children:t})}}],[n.name,r]);return(0,E.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,E.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h1`,{"data-testid":`taxonomy-list-heading`,className:`text-2xl font-semibold capitalize`,children:r(n.label)}),n.description?(0,E.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:n.description}):null]}),F?(0,E.jsx)(g,{asChild:!0,children:(0,E.jsxs)(o,{to:`/terms/$name/create`,params:{name:n.name},"data-testid":`taxonomy-list-new-button`,children:[(0,E.jsx)(u,{}),r(f(n,`addNewItem`))]})}):null]}),(0,E.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,E.jsx)(`div`,{className:`ms-auto`,children:(0,E.jsx)(l,{initialValue:e.q??``,placeholder:r(f(n,`searchItems`)),testId:`taxonomy-list-search-input`,onCommit:y},e.q??``)})}),h.isError?(0,E.jsx)(S,{variant:`destructive`,children:(0,E.jsx)(x,{children:h.error instanceof Error?h.error.message:r(f(n,`loadErrorItems`))})}):(0,E.jsx)(c,{columns:I,data:w,isLoading:h.isPending,loadingLabel:r(f(n,`loadingItems`)),emptyState:(0,E.jsx)(N,{taxonomy:n,canCreate:F})}),(0,E.jsx)(s,{page:e.page,canPrev:M,canNext:P,isLoading:h.isPending,onPageChange:v})]})}function N({taxonomy:e,canCreate:t}){let n=d(),i=n(f(e,`addNewItem`));return(0,E.jsxs)(h,{"data-testid":`taxonomy-list-empty-state`,className:`border`,children:[(0,E.jsxs)(v,{children:[(0,E.jsx)(m,{children:n(f(e,`notFound`))}),(0,E.jsx)(p,{children:(0,E.jsx)(r,{id:`terms.list.empty.description`,message:`Create one to see it here.`})})]}),(0,E.jsx)(y,{children:t?(0,E.jsx)(g,{asChild:!0,children:(0,E.jsxs)(o,{to:`/terms/$name/create`,params:{name:e.name},children:[(0,E.jsx)(u,{}),i]})}):(0,E.jsxs)(g,{disabled:!0,children:[(0,E.jsx)(u,{}),i]})})]})}export{M as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{d as a,h as o,t as s,u as c}from"./orpc-DURDArDu.js";import{t as l}from"./use-label-CykSHq9A.js";import{a as u,i as d,n as f,r as p,t as m}from"./card-L2-kK5VK.js";import{At as h,D as g,Nt as _,Ot as v,Pt as y,T as b,it as x,jt as S,pt as C}from"./index-
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{d as a,h as o,t as s,u as c}from"./orpc-DURDArDu.js";import{t as l}from"./use-label-CykSHq9A.js";import{a as u,i as d,n as f,r as p,t as m}from"./card-L2-kK5VK.js";import{At as h,D as g,Nt as _,Ot as v,Pt as y,T as b,it as x,jt as S,pt as C}from"./index-8CVr3Qp5.js";import{f as w,t as T}from"./form-5CBmFjhZ.js";import{n as E,t as D}from"./alert-cwX3fWUu.js";import{t as O}from"./meta-box-field-gLyOLbwB.js";import{t as k}from"./meta-box-grid-CRboB-BG.js";var A=e(n()),j=e(t()),M=`ctx.registerSettingsPage(name, { groups: [...] })`;function N(){let{page:e}=b.useRouteContext(),t=x(e),n=l();return(0,j.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col gap-6`,children:[(0,j.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,j.jsx)(`h1`,{className:`text-2xl font-semibold`,"data-testid":`settings-page-heading`,children:n(e.label)}),e.description?(0,j.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:n(e.description)}):null]}),t.length===0?(0,j.jsx)(F,{}):t.map(e=>(0,j.jsx)(P,{group:e},e.name))]})}function P({group:e}){let{i18n:t}=r(),n=l(),h=o(),[_,v]=(0,A.useState)(null),[b,x]=(0,A.useState)(null),{data:S}=a(s.settings.get.queryOptions({input:{group:e.name}})),M=w({defaultValues:C([e],S)}),N=c({mutationFn:t=>s.settings.upsert.call({group:e.name,values:t}),onMutate:()=>{v(null),x(null)},onSuccess:async t=>{M.reset(C([e],t)),await h.invalidateQueries({queryKey:s.settings.get.queryOptions({input:{group:e.name}}).queryKey}),x(g.saved)},onError:e=>{v(e instanceof Error?e.message:g.saveFailed)}}),P=M.handleSubmit(e=>{N.mutate(e)});return(0,j.jsx)(m,{className:`@container`,"data-testid":`settings-group-card-${e.name}`,children:(0,j.jsx)(T,{...M,children:(0,j.jsxs)(`form`,{onSubmit:P,children:[(0,j.jsxs)(d,{children:[(0,j.jsx)(u,{children:(0,j.jsx)(`h2`,{className:`text-lg font-semibold`,"data-testid":`settings-group-heading-${e.name}`,children:n(e.label)})}),e.description?(0,j.jsx)(p,{children:n(e.description)}):null]}),(0,j.jsxs)(f,{className:`flex flex-col gap-4`,children:[(0,j.jsx)(`div`,{className:`grid grid-cols-12 gap-4`,children:e.fields.map(e=>(0,j.jsx)(O,{field:e,name:e.key,disabled:N.isPending,className:k(e.span)},e.key))}),_?(0,j.jsx)(D,{variant:`destructive`,role:`alert`,"data-testid":`settings-server-error-${e.name}`,children:(0,j.jsx)(E,{children:typeof _==`string`?_:t._(_.id,void 0,{message:_.message})})}):null,b?(0,j.jsx)(D,{role:`status`,"aria-live":`polite`,"data-testid":`settings-save-notice-${e.name}`,children:(0,j.jsx)(E,{children:t._(b.id,void 0,{message:b.message})})}):null]}),(0,j.jsx)(`div`,{className:`flex justify-end px-6 pb-6`,children:(0,j.jsx)(y,{type:`submit`,disabled:N.isPending,"data-testid":`settings-submit-${e.name}`,children:N.isPending?(0,j.jsx)(i,{id:`settings.page.submit.pending`,message:`Saving…`}):(0,j.jsx)(i,{id:`settings.page.submit.idle`,message:`Save changes`})})})]})})})}function F(){return(0,j.jsx)(m,{children:(0,j.jsx)(v,{children:(0,j.jsxs)(S,{children:[(0,j.jsx)(_,{children:(0,j.jsx)(i,{id:`settings.page.empty.title`,message:`No groups on this page`})}),(0,j.jsxs)(h,{children:[(0,j.jsx)(i,{id:`settings.page.empty.description`,message:`This settings page doesn't reference any registered groups yet. Plugins compose pages with the registerSettingsPage helper:`}),` `,(0,j.jsx)(`code`,{className:`font-mono text-xs`,children:M})]})]})})})}export{N as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{i as n,n as r}from"./dist-BL2bKHuR.js";import{D as i,gt as a}from"./index-
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{i as n,n as r}from"./dist-BL2bKHuR.js";import{D as i,gt as a}from"./index-8CVr3Qp5.js";var o=e(t());function s(){return(0,o.jsx)(c,{message:i.loadFailed})}function c({message:e}){let{i18n:t}=n();return(0,o.jsx)(a,{title:(0,o.jsx)(r,{id:`settings.page.notFound.title`,message:`Not found`}),description:t._(e.id,void 0,{message:e.message})})}export{s as errorComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{f as a,h as o,t as s,u as c}from"./orpc-DURDArDu.js";import{l}from"./esm-DfD3iRfG.js";import{t as u}from"./utils-DKOQrNEG.js";import{t as d}from"./createLucideIcon-C0O-yxZG.js";import{a as f,i as p,n as m,o as h,s as g,t as _}from"./toast-CQk_AYCo.js";import{n as v,r as y,t as ee}from"./search-input-BpOKuC8D.js";import{B as b,F as x,I as S,L as C,M as w,N as T,P as E,R as D,V as O,X as k,n as A,t as te,z as j}from"./utils-BBTvNyQG.js";import{t as M}from"./use-label-CykSHq9A.js";import{t as N}from"./use-formatters-BlYPsMo8.js";import{r as P,t as F}from"./type-labels-DEpt0nSb.js";import{At as I,F as L,Ft as R,I as z,L as B,Nt as V,Ot as H,P as ne,Pt as U,R as re,V as ie,b as ae,et as oe,jt as W,kt as se}from"./index-bWipSZdM.js";import{n as ce,t as le}from"./alert-cwX3fWUu.js";import{t as G}from"./dates-CSmOj6E-.js";var K=d(`arrow-up-down`,[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]),q=e(n(),1),J=e(t(),1),Y={selected:{id:`entries.list.bulk.selected`},trash:{id:`entries.list.bulk.trash`},restore:{id:`entries.list.bulk.restore`},delete:{id:`entries.list.bulk.delete`},trashTitle:{id:`entries.list.bulk.trashTitle`},deleteTitle:{id:`entries.list.bulk.deleteTitle`},deleteBody:{id:`entries.list.bulk.deleteBody`},confirm:{id:`entries.list.bulk.confirm`},cancel:{id:`entries.list.bulk.cancel`}};function ue({count:e,view:t,busy:n,onTrash:i,onRestore:a,onDeletePermanent:o}){let{i18n:s}=r(),[c,l]=(0,q.useState)(null),u=t=>s._(t.id,{count:e},{message:t.message});return(0,J.jsxs)(`div`,{"data-testid":`content-list-bulk-bar`,className:`bg-muted/40 flex items-center gap-3 rounded-md border px-4 py-2`,children:[(0,J.jsx)(`span`,{"data-testid":`content-list-bulk-count`,className:`text-sm font-medium`,children:u(Y.selected)}),(0,J.jsx)(`div`,{className:`ms-auto flex items-center gap-2`,children:t===`trash`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(U,{variant:`outline`,size:`sm`,disabled:n,onClick:a,"data-testid":`content-list-bulk-restore`,children:s._(Y.restore.id,{},{message:Y.restore.message})}),(0,J.jsx)(U,{variant:`destructive`,size:`sm`,disabled:n,onClick:()=>{l(`delete`)},"data-testid":`content-list-bulk-delete`,children:s._(Y.delete.id,{},{message:Y.delete.message})})]}):(0,J.jsx)(U,{variant:`outline`,size:`sm`,disabled:n,onClick:()=>{l(`trash`)},"data-testid":`content-list-bulk-trash`,children:s._(Y.trash.id,{},{message:Y.trash.message})})}),(0,J.jsx)(E,{open:c!==null,onOpenChange:e=>{e||l(null)},children:(0,J.jsxs)(C,{children:[(0,J.jsxs)(b,{children:[(0,J.jsx)(O,{children:u(c===`delete`?Y.deleteTitle:Y.trashTitle)}),c===`delete`?(0,J.jsx)(D,{children:s._(Y.deleteBody.id,{},{message:Y.deleteBody.message})}):null]}),(0,J.jsxs)(j,{children:[(0,J.jsx)(S,{disabled:n,children:s._(Y.cancel.id,{},{message:Y.cancel.message})}),(0,J.jsx)(x,{"data-testid":`content-list-bulk-confirm`,className:R({variant:`destructive`}),disabled:n,onClick:e=>{e.preventDefault();let t=c;l(null),t===`delete`?o():t===`trash`&&i()},children:s._(Y.confirm.id,{},{message:Y.confirm.message})})]})]})})]})}var de=20,X={published:`default`,draft:`secondary`,scheduled:`outline`,trash:`destructive`},Z={columnTitle:{id:`entries.list.column.title`},columnStatus:{id:`entries.list.column.status`},columnUpdated:{id:`entries.list.column.updated`},statusAll:{id:`entries.list.statusFilter.all`},statusPublished:{id:`entries.list.statusFilter.published`},statusDraft:{id:`entries.list.statusFilter.draft`},statusScheduled:{id:`entries.list.statusFilter.scheduled`},statusTrash:{id:`entries.list.statusFilter.trash`},authorAll:{id:`entries.list.authorFilter.all`},authorMine:{id:`entries.list.authorFilter.mine`},filterStatusAria:{id:`entries.list.filterStatusAria`},filterAuthorAria:{id:`entries.list.filterAuthorAria`},sortAria:{id:`entries.list.sortAria`},noTitle:{id:`entries.list.noTitle`},rowEdit:{id:`entries.list.row.edit`},rowTrash:{id:`entries.list.row.trash`},rowTrashing:{id:`entries.list.row.trashing`},trashingMove:{id:`entries.list.trashDialog.moving`},trashingConfirm:{id:`entries.list.trashDialog.confirm`},rowRestore:{id:`entries.list.row.restore`},rowRestoring:{id:`entries.list.row.restoring`},rowDelete:{id:`entries.list.row.deletePermanently`},deleteDialogTitle:{id:`entries.list.deleteDialog.title`},deleteDialogDeleting:{id:`entries.list.deleteDialog.deleting`},deleteDialogConfirm:{id:`entries.list.deleteDialog.confirm`},toastTrashed:{id:`entries.list.toast.trashed`},toastRestored:{id:`entries.list.toast.restored`},toastDeleted:{id:`entries.list.toast.deleted`},toastFailed:{id:`entries.list.toast.failed`},toastDuplicated:{id:`entries.list.toast.duplicated`},rowDuplicate:{id:`entries.list.row.duplicate`},rowDuplicating:{id:`entries.list.row.duplicating`},selectAllAria:{id:`entries.list.selectAllAria`},selectRowAria:{id:`entries.list.selectRowAria`},bulkFailed:{id:`entries.list.bulk.toastFailed`},bulkTrashed:{id:`entries.list.bulk.toastTrashed`},bulkRestored:{id:`entries.list.bulk.toastRestored`},bulkDeleted:{id:`entries.list.bulk.toastDeleted`}},fe=[{value:`all`,label:Z.statusAll},{value:`published`,label:Z.statusPublished},{value:`draft`,label:Z.statusDraft},{value:`scheduled`,label:Z.statusScheduled},{value:`trash`,label:Z.statusTrash}];function pe({activeOrderBy:e,activeOrder:t,onSort:n,adminSlug:r,canDelete:i,canCreate:a,onTrash:o,trashingId:s,onDuplicate:c,duplicatingId:l,onRestore:u,restoringId:d,onDeletePermanent:f,showSelect:p,selectAllLabel:m,selectRowLabel:h,renderLabel:g,editLabel:_,formatDate:v}){return[...p?[{id:`select`,meta:{className:`w-8`},header:({table:e})=>{let t=e.getIsAllPageRowsSelected(),n=e.getIsSomePageRowsSelected();return(0,J.jsx)(w,{checked:t?!0:n?`indeterminate`:!1,onCheckedChange:t=>{e.toggleAllPageRowsSelected(t===!0)},"aria-label":m,"data-testid":`content-list-select-all`})},cell:({row:e})=>(0,J.jsx)(w,{checked:e.getIsSelected(),disabled:!e.getCanSelect(),onCheckedChange:t=>{e.toggleSelected(t===!0)},"aria-label":h,"data-testid":`content-list-select-${String(e.original.id)}`})}]:[],{accessorKey:`title`,header:()=>(0,J.jsx)(ve,{label:g(Z.columnTitle),column:`title`,defaultDirection:`asc`,activeOrderBy:e,activeOrder:t,onSort:n}),cell:({row:e})=>(0,J.jsx)(ye,{entry:e.original,adminSlug:r,canDelete:i,canCreate:a,onTrash:o,isTrashing:s===e.original.id,onDuplicate:c,isDuplicating:l===e.original.id,onRestore:u,isRestoring:d===e.original.id,onDeletePermanent:f,editLabel:_})},{accessorKey:`status`,header:g(Z.columnStatus),cell:({row:e})=>(0,J.jsx)(T,{variant:X[e.original.status],className:`capitalize`,children:e.original.status})},{accessorKey:`updatedAt`,meta:{className:`text-end`},header:()=>(0,J.jsx)(ve,{label:g(Z.columnUpdated),column:`updated_at`,defaultDirection:`desc`,activeOrderBy:e,activeOrder:t,onSort:n,align:`right`}),cell:({row:e})=>(0,J.jsx)(`span`,{className:`text-muted-foreground text-sm`,children:v(G(e.original.updatedAt),{dateStyle:`medium`,timeStyle:`short`})})}]}function me(e,t){let n={};for(let r of t){let t=e[r];if(typeof t!=`string`||t.length===0)continue;let i=t.split(`,`).map(e=>e.trim()).filter(e=>e.length>0);i.length>0&&(n[r]=i)}return n}function he(){let e=ae.useNavigate();return{setStatus:(0,q.useCallback)(t=>{e({search:e=>({...e,status:t,page:1})})},[e]),setPage:(0,q.useCallback)(t=>{e({search:e=>({...e,page:t})})},[e]),setSearch:(0,q.useCallback)(t=>{e({search:e=>({...e,q:t,page:1})})},[e]),setAuthor:(0,q.useCallback)(t=>{e({search:e=>({...e,author:t,page:1})})},[e]),setTermFilter:(0,q.useCallback)((t,n)=>{e({search:e=>{let r={...e,page:1};return n.length>0?r[t]=n.join(`,`):delete r[t],r}})},[e]),setSort:(0,q.useCallback)((t,n)=>{e({search:e=>({...e,orderBy:t,order:Q(e.orderBy===t,e.order,n),page:1})})},[e])}}function ge({entryType:e,rows:t,canDelete:n,renderLabel:i}){let a=o(),l=(0,q.useCallback)(()=>a.invalidateQueries({queryKey:s.entry.list.key({input:{type:e.name}})}),[a,e.name]),[u,d]=(0,q.useState)(null),f=(0,q.useCallback)(()=>{_(i(Z.toastFailed))},[i]),p=(0,q.useCallback)(e=>()=>(m(i(e)),l()),[i,l]),h=c({mutationFn:e=>s.entry.trash.call({id:e}),onSuccess:p(Z.toastTrashed),onError:f,onSettled:()=>{d(null)}}),g=(0,q.useCallback)(e=>{d(e)},[d]),v=h.isPending&&typeof h.variables==`number`?h.variables:null,y=c({mutationFn:e=>s.entry.duplicate.call({id:e}),onSuccess:p(Z.toastDuplicated),onError:f}),ee=(0,q.useCallback)(e=>{y.mutate(e)},[y]),b=y.isPending&&typeof y.variables==`number`?y.variables:null,x=c({mutationFn:e=>s.entry.restore.call({id:e}),onSuccess:p(Z.toastRestored),onError:f}),S=(0,q.useCallback)(e=>{x.mutate(e)},[x]),C=x.isPending&&typeof x.variables==`number`?x.variables:null,[w,T]=(0,q.useState)(null),E=c({mutationFn:e=>s.entry.deletePermanent.call({id:e}),onSuccess:p(Z.toastDeleted),onError:f,onSettled:()=>{T(null)}}),D=(0,q.useCallback)(e=>{T(e)},[T]),{i18n:O}=r(),[k,A]=(0,q.useState)({}),te=(0,q.useMemo)(()=>{let e=new Set(t.map(e=>e.id));return Object.keys(k).map(Number).filter(t=>k[String(t)]&&e.has(t))},[k,t]),j=n&&t.length>0,M=(0,q.useCallback)((e,t)=>{m(O._(e.id,{count:t},{message:e.message}))},[O]),N=(0,q.useCallback)(e=>t=>(M(e,t.ids.length),A({}),l()),[M,l]),P=c({mutationFn:e=>s.entry.trashMany.call({ids:e}),onSuccess:N(Z.bulkTrashed),onError:f}),F=c({mutationFn:e=>s.entry.restoreMany.call({ids:e}),onSuccess:N(Z.bulkRestored),onError:f}),I=c({mutationFn:e=>s.entry.deletePermanentMany.call({ids:e}),onSuccess:N(Z.bulkDeleted),onError:f});return{onTrash:g,trashingId:v,onDuplicate:ee,duplicatingId:b,onRestore:S,restoringId:C,onDeletePermanent:D,pendingTrashId:u,setPendingTrashId:d,trash:h,pendingDeleteId:w,setPendingDeleteId:T,deletePermanent:E,rowSelection:k,setRowSelection:A,selectedIds:te,showSelect:j,bulkBusy:P.isPending||F.isPending||I.isPending,trashMany:P,restoreMany:F,deletePermanentMany:I}}function _e(){let e=ae.useSearch(),{user:t,entryType:n}=ae.useRouteContext(),r=n.termTaxonomies??Se,o=(0,q.useMemo)(()=>me(e,r),[e,r]),c=a(s.entry.list.queryOptions({input:{type:n.name,limit:de,offset:(e.page-1)*de,orderBy:e.orderBy,order:e.order,...e.status===`all`?{}:{status:e.status},...e.q?{search:e.q}:{},...e.author===`mine`?{authorId:t.id}:{},...Object.keys(o).length>0?{termTaxonomies:o}:{}}})),{setStatus:u,setPage:d,setSearch:f,setAuthor:p,setTermFilter:m,setSort:h}=he(),g=(0,q.useMemo)(()=>c.data??[],[c.data]),_=e.page>1,w=g.length===de,T=M(),A=T(n.labels?.plural??n.label),te=`entry:${n.capabilityType??n.name}:create`,P=ie(t.capabilities,te),I=`entry:${n.capabilityType??n.name}:delete`,L=ie(t.capabilities,I),{onTrash:z,trashingId:B,onDuplicate:V,duplicatingId:H,onRestore:ne,restoringId:re,onDeletePermanent:oe,pendingTrashId:W,setPendingTrashId:se,trash:G,pendingDeleteId:K,setPendingDeleteId:Y,deletePermanent:X,rowSelection:fe,setRowSelection:_e,selectedIds:Q,showSelect:$,bulkBusy:ve,trashMany:ye,restoreMany:xe,deletePermanentMany:Ce}=ge({entryType:n,rows:g,canDelete:L,renderLabel:T}),De=e.status===`trash`,Oe=T(F(n,`editItem`)),{formatDate:ke}=N(),Ae=(0,q.useMemo)(()=>pe({activeOrderBy:e.orderBy,activeOrder:e.order,onSort:h,adminSlug:n.adminSlug,canDelete:L,canCreate:P,onTrash:z,trashingId:B,onDuplicate:V,duplicatingId:H,onRestore:ne,restoringId:re,onDeletePermanent:oe,showSelect:$,selectAllLabel:T(Z.selectAllAria),selectRowLabel:T(Z.selectRowAria),renderLabel:T,editLabel:Oe,formatDate:ke}),[e.orderBy,e.order,h,n.adminSlug,L,P,z,B,V,H,ne,re,oe,$,T,Oe,ke]);return(0,J.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,J.jsx)(`div`,{children:(0,J.jsx)(`h1`,{"data-testid":`content-list-heading`,className:`text-2xl font-semibold`,children:A})}),P?(0,J.jsx)(U,{asChild:!0,children:(0,J.jsxs)(l,{to:`/entries/$slug/create`,params:{slug:n.adminSlug},"data-testid":`content-list-new-button`,children:[(0,J.jsx)(k,{}),T(F(n,`addNewItem`))]})}):null]}),(0,J.jsx)(be,{value:e.status,onChange:u}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(we,{value:e.author,onChange:p}),r.map(e=>(0,J.jsx)(Te,{taxonomyName:e,value:o[e]??Se,onChange:t=>{m(e,t)}},e)),(0,J.jsx)(`div`,{className:`ms-auto`,children:(0,J.jsx)(ee,{initialValue:e.q??``,placeholder:T(F(n,`searchItems`)),testId:`content-list-search-input`,onCommit:f},e.q??``)})]}),$&&Q.length>0?(0,J.jsx)(ue,{count:Q.length,view:De?`trash`:`active`,busy:ve,onTrash:()=>{ye.mutate(Q)},onRestore:()=>{xe.mutate(Q)},onDeletePermanent:()=>{Ce.mutate(Q)}}):null,c.isError?(0,J.jsx)(le,{variant:`destructive`,"data-testid":`content-list-load-error`,children:(0,J.jsx)(ce,{children:c.error instanceof Error?c.error.message:T(F(n,`loadErrorItems`))})}):(0,J.jsx)(y,{columns:Ae,data:g,isLoading:c.isPending,loadingLabel:T(F(n,`loadingItems`)),...$?{rowSelection:fe,onRowSelectionChange:_e,getRowId:e=>String(e.id)}:{},emptyState:(0,J.jsx)(Ee,{entryType:n,canCreate:P,entryTypeSlug:n.adminSlug})}),(0,J.jsx)(v,{page:e.page,canPrev:_,canNext:w,isLoading:c.isPending,onPageChange:d}),(0,J.jsx)(E,{open:W!==null,onOpenChange:e=>{e||se(null)},children:(0,J.jsxs)(C,{children:[(0,J.jsxs)(b,{children:[(0,J.jsx)(O,{children:T(F(n,`moveToTrash`))}),(0,J.jsx)(D,{children:(0,J.jsx)(i,{id:`entries.list.trashDialog.description`,message:`You can restore it from the Trash view later.`})})]}),(0,J.jsxs)(j,{children:[(0,J.jsx)(S,{disabled:G.isPending,children:(0,J.jsx)(i,{id:`entries.list.trashDialog.cancel`,message:`Cancel`})}),(0,J.jsx)(x,{"data-testid":`content-list-trash-confirm`,className:R({variant:`destructive`}),disabled:G.isPending,onClick:e=>{e.preventDefault(),W!==null&&G.mutate(W)},children:G.isPending?T(Z.trashingMove):T(Z.trashingConfirm)})]})]})}),(0,J.jsx)(E,{open:K!==null,onOpenChange:e=>{e||Y(null)},children:(0,J.jsxs)(C,{children:[(0,J.jsxs)(b,{children:[(0,J.jsx)(O,{children:T(Z.deleteDialogTitle)}),(0,J.jsx)(D,{children:(0,J.jsx)(i,{id:`entries.list.deleteDialog.description`,message:`This permanently deletes the entry and its revisions. It cannot be undone.`})})]}),(0,J.jsxs)(j,{children:[(0,J.jsx)(S,{disabled:X.isPending,children:(0,J.jsx)(i,{id:`entries.list.deleteDialog.cancel`,message:`Cancel`})}),(0,J.jsx)(x,{"data-testid":`content-list-delete-confirm`,className:R({variant:`destructive`}),disabled:X.isPending,onClick:e=>{e.preventDefault(),K!==null&&X.mutate(K)},children:X.isPending?T(Z.deleteDialogDeleting):T(Z.deleteDialogConfirm)})]})]})})]})}function Q(e,t,n){return e?t===`asc`?`desc`:`asc`:n}function $({isActive:e,order:t}){return e?t===`asc`?(0,J.jsx)(h,{"aria-hidden":!0,className:`size-3.5`}):(0,J.jsx)(g,{"aria-hidden":!0,className:`size-3.5`}):(0,J.jsx)(K,{"aria-hidden":!0,className:`size-3.5`})}function ve({label:e,column:t,defaultDirection:n,activeOrderBy:i,activeOrder:a,onSort:o,align:s=`left`}){let{i18n:c}=r(),l=i===t,d=Q(l,a,n);return(0,J.jsxs)(`button`,{type:`button`,onClick:()=>{o(t,n)},"data-testid":`content-list-sort-${t}`,className:u(`hover:text-foreground inline-flex items-center gap-1 rounded px-2 py-1 font-medium transition-colors`,s===`right`?`-me-2 text-end`:`-ms-2 text-start`),"aria-label":c._(Z.sortAria.id,{label:e,direction:d},{message:Z.sortAria.message}),"aria-pressed":l,children:[e,(0,J.jsx)($,{isActive:l,order:a})]})}function ye({entry:e,adminSlug:t,canDelete:n,canCreate:r,onTrash:a,isTrashing:o,onDuplicate:s,isDuplicating:c,onRestore:d,isRestoring:f,onDeletePermanent:p,editLabel:m}){let h=M(),g=e.status===`trash`,_=n&&!g,v=r&&!g,y=n&&g;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,J.jsx)(l,{to:`/entries/$slug/$id/edit`,params:{slug:t,id:e.id},"data-testid":`content-list-row-${String(e.id)}`,className:`hover:text-primary font-medium transition-colors`,children:e.title||(0,J.jsx)(`span`,{className:`text-muted-foreground italic`,children:(0,J.jsx)(i,{id:`entries.list.noTitle`,message:`(no title)`})})}),(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e.slug}),(0,J.jsxs)(`div`,{className:u(`flex h-4 items-center gap-2 text-xs transition-opacity`,`invisible group-hover/row:visible focus-within:visible`),"data-testid":`content-list-row-actions-${String(e.id)}`,children:[(0,J.jsx)(l,{to:`/entries/$slug/$id/edit`,params:{slug:t,id:e.id},className:`text-muted-foreground hover:text-foreground`,children:m}),_?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`|`}),(0,J.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>{a(e.id)},className:`text-muted-foreground hover:text-destructive disabled:opacity-50`,"data-testid":`content-list-row-trash-${String(e.id)}`,children:h(o?Z.rowTrashing:Z.rowTrash)})]}):null,v?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`|`}),(0,J.jsx)(`button`,{type:`button`,disabled:c,onClick:()=>{s(e.id)},className:`text-muted-foreground hover:text-foreground disabled:opacity-50`,"data-testid":`content-list-row-duplicate-${String(e.id)}`,children:h(c?Z.rowDuplicating:Z.rowDuplicate)})]}):null,y?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`|`}),(0,J.jsx)(`button`,{type:`button`,disabled:f,onClick:()=>{d(e.id)},className:`text-muted-foreground hover:text-foreground disabled:opacity-50`,"data-testid":`content-list-row-restore-${String(e.id)}`,children:h(f?Z.rowRestoring:Z.rowRestore)}),(0,J.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`|`}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>{p(e.id)},className:`text-muted-foreground hover:text-destructive`,"data-testid":`content-list-row-delete-${String(e.id)}`,children:h(Z.rowDelete)})]}):null]})]})}function be({value:e,onChange:t}){let n=M();return(0,J.jsx)(te,{type:`single`,variant:`outline`,value:e,onValueChange:e=>{t(e||`all`)},"aria-label":n(Z.filterStatusAria),children:fe.map(e=>(0,J.jsx)(A,{value:e.value,"data-testid":`status-view-${e.value}`,children:n(e.label)},e.value))})}var xe=[],Se=[],Ce=[{value:`all`,label:Z.authorAll},{value:`mine`,label:Z.authorMine}];function we({value:e,onChange:t}){let n=M();return(0,J.jsxs)(ne,{value:e,onValueChange:e=>{t(e)},children:[(0,J.jsx)(B,{size:`sm`,"aria-label":n(Z.filterAuthorAria),"data-testid":`author-filter`,children:(0,J.jsx)(re,{})}),(0,J.jsx)(L,{children:Ce.map(e=>(0,J.jsx)(z,{value:e.value,"data-testid":`author-filter-${e.value}`,children:n(e.label)},e.value))})]})}function Te({taxonomyName:e,value:t,onChange:n}){let r=M(),i=oe(e),o=a(s.term.list.queryOptions({input:{taxonomy:e,limit:200}})),c=i?.isHierarchical===!0;return(0,J.jsx)(f,{options:(0,q.useMemo)(()=>p(o.data??xe,c),[o.data,c]),value:t,onChange:n,placeholder:r(P(i,`allItems`)),searchPlaceholder:r(P(i,`searchItems`)),emptyText:r(P(i,`noMatch`)),"aria-label":r(P(i,`filterByItem`)),testId:`taxonomy-filter-${e}`})}function Ee({entryType:e,canCreate:t,entryTypeSlug:n}){let r=M(),a=r(F(e,`addNewItem`));return(0,J.jsxs)(H,{"data-testid":`content-list-empty-state`,className:`border`,children:[(0,J.jsxs)(W,{children:[(0,J.jsx)(V,{children:r(F(e,`notFound`))}),(0,J.jsx)(I,{children:(0,J.jsx)(i,{id:`entries.list.empty.description`,message:`Create one to see it here.`})})]}),(0,J.jsx)(se,{children:t?(0,J.jsx)(U,{asChild:!0,children:(0,J.jsxs)(l,{to:`/entries/$slug/create`,params:{slug:n},children:[(0,J.jsx)(k,{}),a]})}):(0,J.jsxs)(U,{disabled:!0,children:[(0,J.jsx)(k,{}),a]})})]})}export{_e as component};
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{f as a,h as o,t as s,u as c}from"./orpc-DURDArDu.js";import{l}from"./esm-DfD3iRfG.js";import{t as u}from"./utils-DKOQrNEG.js";import{t as d}from"./createLucideIcon-C0O-yxZG.js";import{a as f,i as p,n as m,o as h,s as g,t as _}from"./toast-UQxADDWA.js";import{n as v,r as y,t as ee}from"./search-input-BSW1rAKi.js";import{B as b,F as x,I as S,L as C,M as w,N as T,P as E,R as D,V as O,X as k,n as A,t as te,z as j}from"./utils-BtfRir_X.js";import{t as M}from"./use-label-CykSHq9A.js";import{t as N}from"./use-formatters-HWxEQWaC.js";import{r as P,t as F}from"./type-labels-DEpt0nSb.js";import{At as I,F as L,Ft as R,I as z,L as B,Nt as V,Ot as H,P as ne,Pt as U,R as re,V as ie,b as ae,et as oe,jt as W,kt as se}from"./index-8CVr3Qp5.js";import{n as ce,t as le}from"./alert-cwX3fWUu.js";import{t as G}from"./dates-CSmOj6E-.js";var K=d(`arrow-up-down`,[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]),q=e(n(),1),J=e(t(),1),Y={selected:{id:`entries.list.bulk.selected`},trash:{id:`entries.list.bulk.trash`},restore:{id:`entries.list.bulk.restore`},delete:{id:`entries.list.bulk.delete`},trashTitle:{id:`entries.list.bulk.trashTitle`},deleteTitle:{id:`entries.list.bulk.deleteTitle`},deleteBody:{id:`entries.list.bulk.deleteBody`},confirm:{id:`entries.list.bulk.confirm`},cancel:{id:`entries.list.bulk.cancel`}};function ue({count:e,view:t,busy:n,onTrash:i,onRestore:a,onDeletePermanent:o}){let{i18n:s}=r(),[c,l]=(0,q.useState)(null),u=t=>s._(t.id,{count:e},{message:t.message});return(0,J.jsxs)(`div`,{"data-testid":`content-list-bulk-bar`,className:`bg-muted/40 flex items-center gap-3 rounded-md border px-4 py-2`,children:[(0,J.jsx)(`span`,{"data-testid":`content-list-bulk-count`,className:`text-sm font-medium`,children:u(Y.selected)}),(0,J.jsx)(`div`,{className:`ms-auto flex items-center gap-2`,children:t===`trash`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(U,{variant:`outline`,size:`sm`,disabled:n,onClick:a,"data-testid":`content-list-bulk-restore`,children:s._(Y.restore.id,{},{message:Y.restore.message})}),(0,J.jsx)(U,{variant:`destructive`,size:`sm`,disabled:n,onClick:()=>{l(`delete`)},"data-testid":`content-list-bulk-delete`,children:s._(Y.delete.id,{},{message:Y.delete.message})})]}):(0,J.jsx)(U,{variant:`outline`,size:`sm`,disabled:n,onClick:()=>{l(`trash`)},"data-testid":`content-list-bulk-trash`,children:s._(Y.trash.id,{},{message:Y.trash.message})})}),(0,J.jsx)(E,{open:c!==null,onOpenChange:e=>{e||l(null)},children:(0,J.jsxs)(C,{children:[(0,J.jsxs)(b,{children:[(0,J.jsx)(O,{children:u(c===`delete`?Y.deleteTitle:Y.trashTitle)}),c===`delete`?(0,J.jsx)(D,{children:s._(Y.deleteBody.id,{},{message:Y.deleteBody.message})}):null]}),(0,J.jsxs)(j,{children:[(0,J.jsx)(S,{disabled:n,children:s._(Y.cancel.id,{},{message:Y.cancel.message})}),(0,J.jsx)(x,{"data-testid":`content-list-bulk-confirm`,className:R({variant:`destructive`}),disabled:n,onClick:e=>{e.preventDefault();let t=c;l(null),t===`delete`?o():t===`trash`&&i()},children:s._(Y.confirm.id,{},{message:Y.confirm.message})})]})]})})]})}var de=20,X={published:`default`,draft:`secondary`,scheduled:`outline`,trash:`destructive`},Z={columnTitle:{id:`entries.list.column.title`},columnStatus:{id:`entries.list.column.status`},columnUpdated:{id:`entries.list.column.updated`},statusAll:{id:`entries.list.statusFilter.all`},statusPublished:{id:`entries.list.statusFilter.published`},statusDraft:{id:`entries.list.statusFilter.draft`},statusScheduled:{id:`entries.list.statusFilter.scheduled`},statusTrash:{id:`entries.list.statusFilter.trash`},authorAll:{id:`entries.list.authorFilter.all`},authorMine:{id:`entries.list.authorFilter.mine`},filterStatusAria:{id:`entries.list.filterStatusAria`},filterAuthorAria:{id:`entries.list.filterAuthorAria`},sortAria:{id:`entries.list.sortAria`},noTitle:{id:`entries.list.noTitle`},rowEdit:{id:`entries.list.row.edit`},rowTrash:{id:`entries.list.row.trash`},rowTrashing:{id:`entries.list.row.trashing`},trashingMove:{id:`entries.list.trashDialog.moving`},trashingConfirm:{id:`entries.list.trashDialog.confirm`},rowRestore:{id:`entries.list.row.restore`},rowRestoring:{id:`entries.list.row.restoring`},rowDelete:{id:`entries.list.row.deletePermanently`},deleteDialogTitle:{id:`entries.list.deleteDialog.title`},deleteDialogDeleting:{id:`entries.list.deleteDialog.deleting`},deleteDialogConfirm:{id:`entries.list.deleteDialog.confirm`},toastTrashed:{id:`entries.list.toast.trashed`},toastRestored:{id:`entries.list.toast.restored`},toastDeleted:{id:`entries.list.toast.deleted`},toastFailed:{id:`entries.list.toast.failed`},toastDuplicated:{id:`entries.list.toast.duplicated`},rowDuplicate:{id:`entries.list.row.duplicate`},rowDuplicating:{id:`entries.list.row.duplicating`},selectAllAria:{id:`entries.list.selectAllAria`},selectRowAria:{id:`entries.list.selectRowAria`},bulkFailed:{id:`entries.list.bulk.toastFailed`},bulkTrashed:{id:`entries.list.bulk.toastTrashed`},bulkRestored:{id:`entries.list.bulk.toastRestored`},bulkDeleted:{id:`entries.list.bulk.toastDeleted`}},fe=[{value:`all`,label:Z.statusAll},{value:`published`,label:Z.statusPublished},{value:`draft`,label:Z.statusDraft},{value:`scheduled`,label:Z.statusScheduled},{value:`trash`,label:Z.statusTrash}];function pe({activeOrderBy:e,activeOrder:t,onSort:n,adminSlug:r,canDelete:i,canCreate:a,onTrash:o,trashingId:s,onDuplicate:c,duplicatingId:l,onRestore:u,restoringId:d,onDeletePermanent:f,showSelect:p,selectAllLabel:m,selectRowLabel:h,renderLabel:g,editLabel:_,formatDate:v}){return[...p?[{id:`select`,meta:{className:`w-8`},header:({table:e})=>{let t=e.getIsAllPageRowsSelected(),n=e.getIsSomePageRowsSelected();return(0,J.jsx)(w,{checked:t?!0:n?`indeterminate`:!1,onCheckedChange:t=>{e.toggleAllPageRowsSelected(t===!0)},"aria-label":m,"data-testid":`content-list-select-all`})},cell:({row:e})=>(0,J.jsx)(w,{checked:e.getIsSelected(),disabled:!e.getCanSelect(),onCheckedChange:t=>{e.toggleSelected(t===!0)},"aria-label":h,"data-testid":`content-list-select-${String(e.original.id)}`})}]:[],{accessorKey:`title`,header:()=>(0,J.jsx)(ve,{label:g(Z.columnTitle),column:`title`,defaultDirection:`asc`,activeOrderBy:e,activeOrder:t,onSort:n}),cell:({row:e})=>(0,J.jsx)(ye,{entry:e.original,adminSlug:r,canDelete:i,canCreate:a,onTrash:o,isTrashing:s===e.original.id,onDuplicate:c,isDuplicating:l===e.original.id,onRestore:u,isRestoring:d===e.original.id,onDeletePermanent:f,editLabel:_})},{accessorKey:`status`,header:g(Z.columnStatus),cell:({row:e})=>(0,J.jsx)(T,{variant:X[e.original.status],className:`capitalize`,children:e.original.status})},{accessorKey:`updatedAt`,meta:{className:`text-end`},header:()=>(0,J.jsx)(ve,{label:g(Z.columnUpdated),column:`updated_at`,defaultDirection:`desc`,activeOrderBy:e,activeOrder:t,onSort:n,align:`right`}),cell:({row:e})=>(0,J.jsx)(`span`,{className:`text-muted-foreground text-sm`,children:v(G(e.original.updatedAt),{dateStyle:`medium`,timeStyle:`short`})})}]}function me(e,t){let n={};for(let r of t){let t=e[r];if(typeof t!=`string`||t.length===0)continue;let i=t.split(`,`).map(e=>e.trim()).filter(e=>e.length>0);i.length>0&&(n[r]=i)}return n}function he(){let e=ae.useNavigate();return{setStatus:(0,q.useCallback)(t=>{e({search:e=>({...e,status:t,page:1})})},[e]),setPage:(0,q.useCallback)(t=>{e({search:e=>({...e,page:t})})},[e]),setSearch:(0,q.useCallback)(t=>{e({search:e=>({...e,q:t,page:1})})},[e]),setAuthor:(0,q.useCallback)(t=>{e({search:e=>({...e,author:t,page:1})})},[e]),setTermFilter:(0,q.useCallback)((t,n)=>{e({search:e=>{let r={...e,page:1};return n.length>0?r[t]=n.join(`,`):delete r[t],r}})},[e]),setSort:(0,q.useCallback)((t,n)=>{e({search:e=>({...e,orderBy:t,order:Q(e.orderBy===t,e.order,n),page:1})})},[e])}}function ge({entryType:e,rows:t,canDelete:n,renderLabel:i}){let a=o(),l=(0,q.useCallback)(()=>a.invalidateQueries({queryKey:s.entry.list.key({input:{type:e.name}})}),[a,e.name]),[u,d]=(0,q.useState)(null),f=(0,q.useCallback)(()=>{_(i(Z.toastFailed))},[i]),p=(0,q.useCallback)(e=>()=>(m(i(e)),l()),[i,l]),h=c({mutationFn:e=>s.entry.trash.call({id:e}),onSuccess:p(Z.toastTrashed),onError:f,onSettled:()=>{d(null)}}),g=(0,q.useCallback)(e=>{d(e)},[d]),v=h.isPending&&typeof h.variables==`number`?h.variables:null,y=c({mutationFn:e=>s.entry.duplicate.call({id:e}),onSuccess:p(Z.toastDuplicated),onError:f}),ee=(0,q.useCallback)(e=>{y.mutate(e)},[y]),b=y.isPending&&typeof y.variables==`number`?y.variables:null,x=c({mutationFn:e=>s.entry.restore.call({id:e}),onSuccess:p(Z.toastRestored),onError:f}),S=(0,q.useCallback)(e=>{x.mutate(e)},[x]),C=x.isPending&&typeof x.variables==`number`?x.variables:null,[w,T]=(0,q.useState)(null),E=c({mutationFn:e=>s.entry.deletePermanent.call({id:e}),onSuccess:p(Z.toastDeleted),onError:f,onSettled:()=>{T(null)}}),D=(0,q.useCallback)(e=>{T(e)},[T]),{i18n:O}=r(),[k,A]=(0,q.useState)({}),te=(0,q.useMemo)(()=>{let e=new Set(t.map(e=>e.id));return Object.keys(k).map(Number).filter(t=>k[String(t)]&&e.has(t))},[k,t]),j=n&&t.length>0,M=(0,q.useCallback)((e,t)=>{m(O._(e.id,{count:t},{message:e.message}))},[O]),N=(0,q.useCallback)(e=>t=>(M(e,t.ids.length),A({}),l()),[M,l]),P=c({mutationFn:e=>s.entry.trashMany.call({ids:e}),onSuccess:N(Z.bulkTrashed),onError:f}),F=c({mutationFn:e=>s.entry.restoreMany.call({ids:e}),onSuccess:N(Z.bulkRestored),onError:f}),I=c({mutationFn:e=>s.entry.deletePermanentMany.call({ids:e}),onSuccess:N(Z.bulkDeleted),onError:f});return{onTrash:g,trashingId:v,onDuplicate:ee,duplicatingId:b,onRestore:S,restoringId:C,onDeletePermanent:D,pendingTrashId:u,setPendingTrashId:d,trash:h,pendingDeleteId:w,setPendingDeleteId:T,deletePermanent:E,rowSelection:k,setRowSelection:A,selectedIds:te,showSelect:j,bulkBusy:P.isPending||F.isPending||I.isPending,trashMany:P,restoreMany:F,deletePermanentMany:I}}function _e(){let e=ae.useSearch(),{user:t,entryType:n}=ae.useRouteContext(),r=n.termTaxonomies??Se,o=(0,q.useMemo)(()=>me(e,r),[e,r]),c=a(s.entry.list.queryOptions({input:{type:n.name,limit:de,offset:(e.page-1)*de,orderBy:e.orderBy,order:e.order,...e.status===`all`?{}:{status:e.status},...e.q?{search:e.q}:{},...e.author===`mine`?{authorId:t.id}:{},...Object.keys(o).length>0?{termTaxonomies:o}:{}}})),{setStatus:u,setPage:d,setSearch:f,setAuthor:p,setTermFilter:m,setSort:h}=he(),g=(0,q.useMemo)(()=>c.data??[],[c.data]),_=e.page>1,w=g.length===de,T=M(),A=T(n.labels?.plural??n.label),te=`entry:${n.capabilityType??n.name}:create`,P=ie(t.capabilities,te),I=`entry:${n.capabilityType??n.name}:delete`,L=ie(t.capabilities,I),{onTrash:z,trashingId:B,onDuplicate:V,duplicatingId:H,onRestore:ne,restoringId:re,onDeletePermanent:oe,pendingTrashId:W,setPendingTrashId:se,trash:G,pendingDeleteId:K,setPendingDeleteId:Y,deletePermanent:X,rowSelection:fe,setRowSelection:_e,selectedIds:Q,showSelect:$,bulkBusy:ve,trashMany:ye,restoreMany:xe,deletePermanentMany:Ce}=ge({entryType:n,rows:g,canDelete:L,renderLabel:T}),De=e.status===`trash`,Oe=T(F(n,`editItem`)),{formatDate:ke}=N(),Ae=(0,q.useMemo)(()=>pe({activeOrderBy:e.orderBy,activeOrder:e.order,onSort:h,adminSlug:n.adminSlug,canDelete:L,canCreate:P,onTrash:z,trashingId:B,onDuplicate:V,duplicatingId:H,onRestore:ne,restoringId:re,onDeletePermanent:oe,showSelect:$,selectAllLabel:T(Z.selectAllAria),selectRowLabel:T(Z.selectRowAria),renderLabel:T,editLabel:Oe,formatDate:ke}),[e.orderBy,e.order,h,n.adminSlug,L,P,z,B,V,H,ne,re,oe,$,T,Oe,ke]);return(0,J.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,J.jsx)(`div`,{children:(0,J.jsx)(`h1`,{"data-testid":`content-list-heading`,className:`text-2xl font-semibold`,children:A})}),P?(0,J.jsx)(U,{asChild:!0,children:(0,J.jsxs)(l,{to:`/entries/$slug/create`,params:{slug:n.adminSlug},"data-testid":`content-list-new-button`,children:[(0,J.jsx)(k,{}),T(F(n,`addNewItem`))]})}):null]}),(0,J.jsx)(be,{value:e.status,onChange:u}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(we,{value:e.author,onChange:p}),r.map(e=>(0,J.jsx)(Te,{taxonomyName:e,value:o[e]??Se,onChange:t=>{m(e,t)}},e)),(0,J.jsx)(`div`,{className:`ms-auto`,children:(0,J.jsx)(ee,{initialValue:e.q??``,placeholder:T(F(n,`searchItems`)),testId:`content-list-search-input`,onCommit:f},e.q??``)})]}),$&&Q.length>0?(0,J.jsx)(ue,{count:Q.length,view:De?`trash`:`active`,busy:ve,onTrash:()=>{ye.mutate(Q)},onRestore:()=>{xe.mutate(Q)},onDeletePermanent:()=>{Ce.mutate(Q)}}):null,c.isError?(0,J.jsx)(le,{variant:`destructive`,"data-testid":`content-list-load-error`,children:(0,J.jsx)(ce,{children:c.error instanceof Error?c.error.message:T(F(n,`loadErrorItems`))})}):(0,J.jsx)(y,{columns:Ae,data:g,isLoading:c.isPending,loadingLabel:T(F(n,`loadingItems`)),...$?{rowSelection:fe,onRowSelectionChange:_e,getRowId:e=>String(e.id)}:{},emptyState:(0,J.jsx)(Ee,{entryType:n,canCreate:P,entryTypeSlug:n.adminSlug})}),(0,J.jsx)(v,{page:e.page,canPrev:_,canNext:w,isLoading:c.isPending,onPageChange:d}),(0,J.jsx)(E,{open:W!==null,onOpenChange:e=>{e||se(null)},children:(0,J.jsxs)(C,{children:[(0,J.jsxs)(b,{children:[(0,J.jsx)(O,{children:T(F(n,`moveToTrash`))}),(0,J.jsx)(D,{children:(0,J.jsx)(i,{id:`entries.list.trashDialog.description`,message:`You can restore it from the Trash view later.`})})]}),(0,J.jsxs)(j,{children:[(0,J.jsx)(S,{disabled:G.isPending,children:(0,J.jsx)(i,{id:`entries.list.trashDialog.cancel`,message:`Cancel`})}),(0,J.jsx)(x,{"data-testid":`content-list-trash-confirm`,className:R({variant:`destructive`}),disabled:G.isPending,onClick:e=>{e.preventDefault(),W!==null&&G.mutate(W)},children:G.isPending?T(Z.trashingMove):T(Z.trashingConfirm)})]})]})}),(0,J.jsx)(E,{open:K!==null,onOpenChange:e=>{e||Y(null)},children:(0,J.jsxs)(C,{children:[(0,J.jsxs)(b,{children:[(0,J.jsx)(O,{children:T(Z.deleteDialogTitle)}),(0,J.jsx)(D,{children:(0,J.jsx)(i,{id:`entries.list.deleteDialog.description`,message:`This permanently deletes the entry and its revisions. It cannot be undone.`})})]}),(0,J.jsxs)(j,{children:[(0,J.jsx)(S,{disabled:X.isPending,children:(0,J.jsx)(i,{id:`entries.list.deleteDialog.cancel`,message:`Cancel`})}),(0,J.jsx)(x,{"data-testid":`content-list-delete-confirm`,className:R({variant:`destructive`}),disabled:X.isPending,onClick:e=>{e.preventDefault(),K!==null&&X.mutate(K)},children:X.isPending?T(Z.deleteDialogDeleting):T(Z.deleteDialogConfirm)})]})]})})]})}function Q(e,t,n){return e?t===`asc`?`desc`:`asc`:n}function $({isActive:e,order:t}){return e?t===`asc`?(0,J.jsx)(h,{"aria-hidden":!0,className:`size-3.5`}):(0,J.jsx)(g,{"aria-hidden":!0,className:`size-3.5`}):(0,J.jsx)(K,{"aria-hidden":!0,className:`size-3.5`})}function ve({label:e,column:t,defaultDirection:n,activeOrderBy:i,activeOrder:a,onSort:o,align:s=`left`}){let{i18n:c}=r(),l=i===t,d=Q(l,a,n);return(0,J.jsxs)(`button`,{type:`button`,onClick:()=>{o(t,n)},"data-testid":`content-list-sort-${t}`,className:u(`hover:text-foreground inline-flex items-center gap-1 rounded px-2 py-1 font-medium transition-colors`,s===`right`?`-me-2 text-end`:`-ms-2 text-start`),"aria-label":c._(Z.sortAria.id,{label:e,direction:d},{message:Z.sortAria.message}),"aria-pressed":l,children:[e,(0,J.jsx)($,{isActive:l,order:a})]})}function ye({entry:e,adminSlug:t,canDelete:n,canCreate:r,onTrash:a,isTrashing:o,onDuplicate:s,isDuplicating:c,onRestore:d,isRestoring:f,onDeletePermanent:p,editLabel:m}){let h=M(),g=e.status===`trash`,_=n&&!g,v=r&&!g,y=n&&g;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,J.jsx)(l,{to:`/entries/$slug/$id/edit`,params:{slug:t,id:e.id},"data-testid":`content-list-row-${String(e.id)}`,className:`hover:text-primary font-medium transition-colors`,children:e.title||(0,J.jsx)(`span`,{className:`text-muted-foreground italic`,children:(0,J.jsx)(i,{id:`entries.list.noTitle`,message:`(no title)`})})}),(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e.slug}),(0,J.jsxs)(`div`,{className:u(`flex h-4 items-center gap-2 text-xs transition-opacity`,`invisible group-hover/row:visible focus-within:visible`),"data-testid":`content-list-row-actions-${String(e.id)}`,children:[(0,J.jsx)(l,{to:`/entries/$slug/$id/edit`,params:{slug:t,id:e.id},className:`text-muted-foreground hover:text-foreground`,children:m}),_?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`|`}),(0,J.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>{a(e.id)},className:`text-muted-foreground hover:text-destructive disabled:opacity-50`,"data-testid":`content-list-row-trash-${String(e.id)}`,children:h(o?Z.rowTrashing:Z.rowTrash)})]}):null,v?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`|`}),(0,J.jsx)(`button`,{type:`button`,disabled:c,onClick:()=>{s(e.id)},className:`text-muted-foreground hover:text-foreground disabled:opacity-50`,"data-testid":`content-list-row-duplicate-${String(e.id)}`,children:h(c?Z.rowDuplicating:Z.rowDuplicate)})]}):null,y?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`|`}),(0,J.jsx)(`button`,{type:`button`,disabled:f,onClick:()=>{d(e.id)},className:`text-muted-foreground hover:text-foreground disabled:opacity-50`,"data-testid":`content-list-row-restore-${String(e.id)}`,children:h(f?Z.rowRestoring:Z.rowRestore)}),(0,J.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`|`}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>{p(e.id)},className:`text-muted-foreground hover:text-destructive`,"data-testid":`content-list-row-delete-${String(e.id)}`,children:h(Z.rowDelete)})]}):null]})]})}function be({value:e,onChange:t}){let n=M();return(0,J.jsx)(te,{type:`single`,variant:`outline`,value:e,onValueChange:e=>{t(e||`all`)},"aria-label":n(Z.filterStatusAria),children:fe.map(e=>(0,J.jsx)(A,{value:e.value,"data-testid":`status-view-${e.value}`,children:n(e.label)},e.value))})}var xe=[],Se=[],Ce=[{value:`all`,label:Z.authorAll},{value:`mine`,label:Z.authorMine}];function we({value:e,onChange:t}){let n=M();return(0,J.jsxs)(ne,{value:e,onValueChange:e=>{t(e)},children:[(0,J.jsx)(B,{size:`sm`,"aria-label":n(Z.filterAuthorAria),"data-testid":`author-filter`,children:(0,J.jsx)(re,{})}),(0,J.jsx)(L,{children:Ce.map(e=>(0,J.jsx)(z,{value:e.value,"data-testid":`author-filter-${e.value}`,children:n(e.label)},e.value))})]})}function Te({taxonomyName:e,value:t,onChange:n}){let r=M(),i=oe(e),o=a(s.term.list.queryOptions({input:{taxonomy:e,limit:200}})),c=i?.isHierarchical===!0;return(0,J.jsx)(f,{options:(0,q.useMemo)(()=>p(o.data??xe,c),[o.data,c]),value:t,onChange:n,placeholder:r(P(i,`allItems`)),searchPlaceholder:r(P(i,`searchItems`)),emptyText:r(P(i,`noMatch`)),"aria-label":r(P(i,`filterByItem`)),testId:`taxonomy-filter-${e}`})}function Ee({entryType:e,canCreate:t,entryTypeSlug:n}){let r=M(),a=r(F(e,`addNewItem`));return(0,J.jsxs)(H,{"data-testid":`content-list-empty-state`,className:`border`,children:[(0,J.jsxs)(W,{children:[(0,J.jsx)(V,{children:r(F(e,`notFound`))}),(0,J.jsx)(I,{children:(0,J.jsx)(i,{id:`entries.list.empty.description`,message:`Create one to see it here.`})})]}),(0,J.jsx)(se,{children:t?(0,J.jsx)(U,{asChild:!0,children:(0,J.jsxs)(l,{to:`/entries/$slug/create`,params:{slug:n},children:[(0,J.jsx)(k,{}),a]})}):(0,J.jsxs)(U,{disabled:!0,children:[(0,J.jsx)(k,{}),a]})})]})}export{_e as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{u as a}from"./orpc-DURDArDu.js";import{d as o}from"./esm-DfD3iRfG.js";import{n as s,r as c,t as l}from"./-locale-param-
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{u as a}from"./orpc-DURDArDu.js";import{d as o}from"./esm-DfD3iRfG.js";import{n as s,r as c,t as l}from"./-locale-param-Y_oYVkUX.js";import{a as u,i as d,n as f,r as p,t as m}from"./card-L2-kK5VK.js";import{Pt as h,S as g,Y as _,at as v}from"./index-8CVr3Qp5.js";import{t as y}from"./input-xYuLUQID.js";import{a as b,o as x,t as S}from"./passkey-C_CqNV1S.js";import{a as C,f as w,i as T,n as E,o as D,s as O,t as k}from"./form-5CBmFjhZ.js";import{n as A,t as j}from"./alert-cwX3fWUu.js";var M=e(n()),N=e(t());function P(){let e=x(),{token:t}=g.useParams(),n=g.useSearch(),P=v(),{i18n:F}=r(),I=o(),[L,R]=(0,M.useState)(null),z=e=>{s(e),window.location.assign(l(n,e))},B=a({mutationFn:e=>S({token:t,...e.name?{name:e.name}:{}}),onMutate:()=>{R(null)},onSuccess:async()=>{await I.options.context.queryClient.invalidateQueries({queryKey:_}),await I.navigate({to:`/`})},onError:e=>{R(e instanceof b?e.code:`unknown`)}}),V=w({defaultValues:{name:``}}),H=V.handleSubmit(e=>{B.mutate({name:e.name||void 0})});return(0,N.jsxs)(m,{children:[(0,N.jsxs)(d,{children:[(0,N.jsx)(u,{children:(0,N.jsx)(`h1`,{"data-testid":`accept-invite-heading`,children:(0,N.jsx)(i,{id:`auth.acceptInvite.title`,message:`Accept your invite`})})}),(0,N.jsx)(p,{children:(0,N.jsx)(i,{id:`auth.acceptInvite.description`,message:`Set up a passkey to finish creating your account. Your browser or device will guide you through the prompt.`})})]}),(0,N.jsxs)(f,{children:[(0,N.jsx)(k,{...V,children:(0,N.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:H,children:[(0,N.jsx)(T,{control:V.control,name:`name`,render:({field:e})=>(0,N.jsxs)(C,{children:[(0,N.jsx)(D,{children:(0,N.jsx)(i,{id:`auth.acceptInvite.name`,message:`Name`})}),(0,N.jsx)(E,{children:(0,N.jsx)(y,{type:`text`,autoComplete:`name`,disabled:B.isPending,"data-testid":`accept-invite-name-input`,...e})}),(0,N.jsx)(O,{})]})}),L?(0,N.jsx)(j,{variant:`destructive`,"data-testid":`accept-invite-error`,children:(0,N.jsx)(A,{children:e(L)})}):null,(0,N.jsx)(h,{type:`submit`,disabled:B.isPending,"data-testid":`accept-invite-submit`,children:B.isPending?(0,N.jsx)(i,{id:`auth.acceptInvite.submit.pending`,message:`Setting up…`}):(0,N.jsx)(i,{id:`auth.acceptInvite.submit.idle`,message:`Create passkey`})})]})}),(0,N.jsx)(c,{currentCode:F.locale,manifest:P,onSelect:z})]})]})}export{P as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{f as a,h as o,t as s,u as c}from"./orpc-DURDArDu.js";import{t as l}from"./trash-2-Bn-rv3EX.js";import{t as u}from"./use-label-CykSHq9A.js";import{D as d,T as f,h as p,v as m,w as h,x as g,y as _}from"./dist-ClOzYsk5.js";import{o as v}from"./validation-CwFumc7a.js";import{a as y,i as b,n as x,r as S,t as C}from"./card-L2-kK5VK.js";import{F as w,I as T,L as E,P as D,Pt as O,R as k,z as A}from"./index-
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{f as a,h as o,t as s,u as c}from"./orpc-DURDArDu.js";import{t as l}from"./trash-2-Bn-rv3EX.js";import{t as u}from"./use-label-CykSHq9A.js";import{D as d,T as f,h as p,v as m,w as h,x as g,y as _}from"./dist-ClOzYsk5.js";import{o as v}from"./validation-CwFumc7a.js";import{a as y,i as b,n as x,r as S,t as C}from"./card-L2-kK5VK.js";import{F as w,I as T,L as E,P as D,Pt as O,R as k,z as A}from"./index-8CVr3Qp5.js";import{t as j}from"./input-xYuLUQID.js";import{t as M}from"./toggle-BfrQLxbv.js";import{a as N,f as P,i as F,n as I,o as L,s as R,t as z}from"./form-5CBmFjhZ.js";import{n as B,t as V}from"./alert-cwX3fWUu.js";import{t as H}from"./valibot-D1tw6tkr.js";var U=e(n()),W=e(t()),G=[`subscriber`,`contributor`,`author`,`editor`,`admin`],K={domainPlaceholder:{id:`allowedDomains.add.placeholder`},deleteAria:{id:`allowedDomains.row.deleteAria`},errDomainExists:{id:`allowedDomains.error.domainExists`},errFallback:{id:`allowedDomains.error.fallback`}},q=p({domain:_(h(),d(),f(),g(/^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/,v({id:`allowedDomains.add.domain.invalid`}))),defaultRole:m(G)});function J(){let e=u(),t=o(),[n,r]=(0,U.useState)(null),l=a(s.auth.allowedDomains.list.queryOptions({input:{}})),d=()=>t.invalidateQueries({queryKey:s.auth.allowedDomains.list.key()}),f=c({mutationFn:e=>s.auth.allowedDomains.create.call(e),onMutate:()=>r(null),onSuccess:async()=>{await d(),h.reset({domain:``,defaultRole:`subscriber`})},onError:e=>r(X(e))}),p=c({mutationFn:e=>s.auth.allowedDomains.update.call(e),onSuccess:()=>d()}),m=c({mutationFn:e=>s.auth.allowedDomains.delete.call(e),onSuccess:()=>d()}),h=P({resolver:H(q),defaultValues:{domain:``,defaultRole:`subscriber`},mode:`onBlur`}),g=h.handleSubmit(e=>{f.mutate({domain:e.domain,defaultRole:e.defaultRole})});return(0,W.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4`,children:[(0,W.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,W.jsx)(`h1`,{className:`text-2xl font-semibold`,"data-testid":`allowed-domains-heading`,children:(0,W.jsx)(i,{id:`allowedDomains.title`,message:`Allowed domains`})}),(0,W.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:(0,W.jsx)(i,{id:`allowedDomains.description`,message:`Email domains permitted to sign up via OAuth. New OAuth accounts are created with the role set here. Disabled rows reject signup but preserve their role mapping.`})})]}),(0,W.jsxs)(C,{children:[(0,W.jsxs)(b,{children:[(0,W.jsx)(y,{children:(0,W.jsx)(`h2`,{className:`text-base font-semibold`,children:(0,W.jsx)(i,{id:`allowedDomains.add.title`,message:`Add domain`})})}),(0,W.jsx)(S,{children:(0,W.jsx)(i,{id:`allowedDomains.add.description`,message:`Use the bare domain — no protocol, no path.`})})]}),(0,W.jsxs)(x,{children:[(0,W.jsx)(z,{...h,children:(0,W.jsxs)(`form`,{className:`flex flex-col gap-4 sm:flex-row sm:items-end`,onSubmit:g,children:[(0,W.jsx)(F,{control:h.control,name:`domain`,render:({field:t})=>(0,W.jsxs)(N,{className:`flex-1`,children:[(0,W.jsx)(L,{children:(0,W.jsx)(i,{id:`allowedDomains.add.domain.label`,message:`Domain`})}),(0,W.jsx)(I,{children:(0,W.jsx)(j,{type:`text`,placeholder:e(K.domainPlaceholder),autoComplete:`off`,spellCheck:!1,"data-testid":`allowed-domains-domain-input`,disabled:f.isPending,...t})}),(0,W.jsx)(R,{})]})}),(0,W.jsx)(F,{control:h.control,name:`defaultRole`,render:({field:t})=>(0,W.jsxs)(N,{className:`sm:w-48`,children:[(0,W.jsx)(L,{children:(0,W.jsx)(i,{id:`allowedDomains.add.defaultRole.label`,message:`Default role`})}),(0,W.jsxs)(D,{value:t.value,onValueChange:t.onChange,disabled:f.isPending,children:[(0,W.jsx)(I,{children:(0,W.jsx)(E,{"data-testid":`allowed-domains-role-select`,children:(0,W.jsx)(k,{})})}),(0,W.jsx)(w,{children:G.map(t=>(0,W.jsx)(T,{value:t,children:e(A[t])},t))})]}),(0,W.jsx)(R,{})]})}),(0,W.jsx)(O,{type:`submit`,disabled:f.isPending,"data-testid":`allowed-domains-add-button`,children:f.isPending?(0,W.jsx)(i,{id:`allowedDomains.add.submit.pending`,message:`Adding…`}):(0,W.jsx)(i,{id:`allowedDomains.add.submit.idle`,message:`Add`})})]})}),n?(0,W.jsx)(V,{variant:`destructive`,className:`mt-4`,"data-testid":`allowed-domains-error`,children:(0,W.jsx)(B,{children:e(n)})}):null]})]}),(0,W.jsxs)(C,{children:[(0,W.jsx)(b,{children:(0,W.jsx)(y,{children:(0,W.jsx)(`h2`,{className:`text-base font-semibold`,children:(0,W.jsx)(i,{id:`allowedDomains.list.title`,message:`Configured domains`})})})}),(0,W.jsx)(x,{children:l.isLoading?(0,W.jsx)(`p`,{className:`text-muted-foreground text-sm`,"data-testid":`allowed-domains-loading`,children:(0,W.jsx)(i,{id:`allowedDomains.list.loading`,message:`Loading…`})}):(l.data??[]).length===0?(0,W.jsx)(`p`,{className:`text-muted-foreground text-sm`,"data-testid":`allowed-domains-empty`,children:(0,W.jsx)(i,{id:`allowedDomains.list.empty`,message:`No domains configured. OAuth signup is closed until at least one enabled domain is added.`})}):(0,W.jsx)(`ul`,{className:`flex flex-col gap-2`,"data-testid":`allowed-domains-list`,children:(l.data??[]).map(e=>(0,W.jsx)(Y,{row:e,onToggle:t=>{p.mutate({domain:e.domain,isEnabled:t})},onChangeRole:t=>{p.mutate({domain:e.domain,defaultRole:t})},onDelete:()=>{m.mutate({domain:e.domain})},busy:p.isPending||m.isPending},e.domain))})})]})]})}function Y({row:e,onToggle:t,onChangeRole:n,onDelete:a,busy:o}){let{i18n:s}=r(),c=u(),[d,f]=(0,U.useState)(!1);return(0,W.jsxs)(`li`,{className:`flex flex-col gap-3 rounded-md border p-3 sm:flex-row sm:items-center sm:gap-4`,"data-testid":`allowed-domains-row-${e.domain}`,children:[(0,W.jsx)(`span`,{className:`flex-1 font-mono text-sm`,children:e.domain}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(D,{value:e.defaultRole,onValueChange:e=>n(e),disabled:o,children:[(0,W.jsx)(E,{className:`w-44`,"data-testid":`allowed-domains-row-role-${e.domain}`,children:(0,W.jsx)(k,{})}),(0,W.jsx)(w,{children:G.map(e=>(0,W.jsx)(T,{value:e,children:c(A[e])},e))})]}),(0,W.jsx)(M,{variant:`outline`,size:`sm`,pressed:e.isEnabled,onPressedChange:t,disabled:o,"data-testid":`allowed-domains-row-toggle-${e.domain}`,children:e.isEnabled?(0,W.jsx)(i,{id:`allowedDomains.row.enabled`,message:`Enabled`}):(0,W.jsx)(i,{id:`allowedDomains.row.disabled`,message:`Disabled`})}),d?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(O,{type:`button`,variant:`destructive`,size:`sm`,onClick:()=>{f(!1),a()},disabled:o,"data-testid":`allowed-domains-row-delete-confirm-${e.domain}`,children:(0,W.jsx)(i,{id:`allowedDomains.row.deleteConfirm`,message:`Confirm delete`})}),(0,W.jsx)(O,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>f(!1),disabled:o,"data-testid":`allowed-domains-row-delete-cancel-${e.domain}`,children:(0,W.jsx)(i,{id:`allowedDomains.row.deleteCancel`,message:`Cancel`})})]}):(0,W.jsx)(O,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>f(!0),disabled:o,"aria-label":s._(K.deleteAria.id,{domain:e.domain},{message:K.deleteAria.message}),"data-testid":`allowed-domains-row-delete-${e.domain}`,children:(0,W.jsx)(l,{className:`size-4`})})]})]})}function X(e){return e&&typeof e==`object`&&`data`in e&&e.data?.reason===`domain_exists`?K.errDomainExists:e instanceof Error?e.message:K.errFallback}export{J as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{u as a}from"./orpc-DURDArDu.js";import{d as o}from"./esm-DfD3iRfG.js";import{n as s,r as c,t as l}from"./-locale-param-
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{u as a}from"./orpc-DURDArDu.js";import{d as o}from"./esm-DfD3iRfG.js";import{n as s,r as c,t as l}from"./-locale-param-Y_oYVkUX.js";import{a as u,i as d,n as f,r as p,t as m}from"./card-L2-kK5VK.js";import{H as h,Pt as g,U as _,Y as v,at as y}from"./index-8CVr3Qp5.js";import{t as b}from"./input-xYuLUQID.js";import{a as x,n as S,o as C}from"./passkey-C_CqNV1S.js";import{a as w,f as T,i as E,n as D,o as O,s as k,t as A}from"./form-5CBmFjhZ.js";import{n as j,t as M}from"./alert-cwX3fWUu.js";import{t as N}from"./valibot-D1tw6tkr.js";var P=e(n()),F=e(t());function I(){let e=C(),t=o(),n=h.useSearch(),I=y(),{i18n:L}=r(),[R,z]=(0,P.useState)(null),B=e=>{s(e),window.location.assign(l(n,e))},V=a({mutationFn:S,onMutate:()=>z(null),onSuccess:async()=>{await t.options.context.queryClient.invalidateQueries({queryKey:v}),await t.navigate({to:`/`})},onError:e=>{z(e instanceof x?e.code:`unknown`)}}),H=T({resolver:N(_),defaultValues:{email:``,name:``},mode:`onBlur`}),U=H.handleSubmit(e=>{V.mutate({email:e.email,...e.name?{name:e.name}:{}})});return(0,F.jsxs)(m,{children:[(0,F.jsxs)(d,{children:[(0,F.jsx)(u,{children:(0,F.jsx)(`h1`,{"data-testid":`bootstrap-heading`,children:(0,F.jsx)(i,{id:`auth.bootstrap.title`,message:`Create admin account`})})}),(0,F.jsx)(p,{children:(0,F.jsx)(i,{id:`auth.bootstrap.description`,message:`Set up your site — this email becomes the admin account.`})})]}),(0,F.jsxs)(f,{children:[(0,F.jsx)(A,{...H,children:(0,F.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:U,children:[(0,F.jsx)(E,{control:H.control,name:`email`,render:({field:e})=>(0,F.jsxs)(w,{children:[(0,F.jsx)(O,{children:(0,F.jsx)(i,{id:`auth.bootstrap.email`,message:`Email`})}),(0,F.jsx)(D,{children:(0,F.jsx)(b,{type:`email`,autoComplete:`username webauthn`,required:!0,disabled:V.isPending,...e})}),(0,F.jsx)(k,{})]})}),(0,F.jsx)(E,{control:H.control,name:`name`,render:({field:e})=>(0,F.jsxs)(w,{children:[(0,F.jsx)(O,{children:(0,F.jsx)(i,{id:`auth.bootstrap.name`,message:`Name`})}),(0,F.jsx)(D,{children:(0,F.jsx)(b,{type:`text`,autoComplete:`name`,disabled:V.isPending,...e})}),(0,F.jsx)(k,{})]})}),R?(0,F.jsx)(M,{variant:`destructive`,children:(0,F.jsx)(j,{children:e(R)})}):null,(0,F.jsx)(g,{type:`submit`,disabled:V.isPending,children:V.isPending?(0,F.jsx)(i,{id:`auth.bootstrap.submit.pending`,message:`Creating account…`}):(0,F.jsx)(i,{id:`auth.bootstrap.submit.idle`,message:`Create account with passkey`})})]})}),(0,F.jsx)(c,{currentCode:L.locale,manifest:I,onSelect:B})]})]})}export{I as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{t as r}from"./react-dom-i-Mcm3wj.js";import{$ as i,Ct as a,Ft as o,It as s,J as c,Lt as l,Mt as u,Nt as d,Pt as f,Q as p,St as m,X as h,Y as g,Z as _,_t as v,bt as ee,et as y,gt as b,ht as x,it as S,jt as C,mt as w,pt as T,q as E,rt as D,vt as O,wt as k,xt as A,yt as j}from"./dist-9yav4OBD.js";import{t as M}from"./utils-DKOQrNEG.js";import{t as te}from"./dist-B66OmIyr.js";import{t as N}from"./createLucideIcon-C0O-yxZG.js";import"./skeleton-BnBM1862.js";import{Pt as P}from"./index-8CVr3Qp5.js";import"./input-xYuLUQID.js";import"./separator-u9O31sRo.js";import{i as ne,n as re,r as ie,t as ae}from"./tooltip-Dm_CbtVl.js";var oe=N(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),se=N(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),ce=N(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),le=N(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),F=e(n(),1),I=e(t(),1);function ue({...e}){return(0,I.jsx)(T,{"data-slot":`sheet`,...e})}function de({...e}){return(0,I.jsx)(ee,{"data-slot":`sheet-trigger`,...e})}function fe({...e}){return(0,I.jsx)(O,{"data-slot":`sheet-portal`,...e})}function pe({className:e,...t}){return(0,I.jsx)(v,{"data-slot":`sheet-overlay`,className:M(`data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50`,e),...t})}function me({className:e,children:t,side:n=`right`,showCloseButton:r=!0,...i}){return(0,I.jsxs)(fe,{children:[(0,I.jsx)(pe,{}),(0,I.jsxs)(x,{"data-slot":`sheet-content`,className:M(`bg-background data-[state=closed]:animate-out data-[state=open]:animate-in fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500`,n===`right`&&`data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 end-0 h-full w-3/4 border-s sm:max-w-sm`,n===`left`&&`data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 start-0 h-full w-3/4 border-e sm:max-w-sm`,n===`top`&&`data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b`,n===`bottom`&&`data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t`,e),...i,children:[t,r&&(0,I.jsxs)(w,{className:`ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute end-4 top-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none`,children:[(0,I.jsx)(le,{className:`size-4`}),(0,I.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function he({className:e,...t}){return(0,I.jsx)(`div`,{"data-slot":`sheet-header`,className:M(`flex flex-col gap-1.5 p-4`,e),...t})}function ge({className:e,...t}){return(0,I.jsx)(j,{"data-slot":`sheet-title`,className:M(`text-foreground font-semibold`,e),...t})}function _e({className:e,...t}){return(0,I.jsx)(b,{"data-slot":`sheet-description`,className:M(`text-muted-foreground text-sm`,e),...t})}var ve=768;function ye(){let[e,t]=F.useState(void 0);return F.useEffect(()=>{let e=window.matchMedia(`(max-width: ${ve-1}px)`),n=()=>{t(window.innerWidth<ve)};return e.addEventListener(`change`,n),t(window.innerWidth<ve),()=>e.removeEventListener(`change`,n)},[]),!!e}var be=`sidebar_state`,xe=3600*24*7,Se=`16rem`,Ce=`18rem`,we=`3rem`,Te=`b`,Ee=F.createContext(null);function L(){let e=F.useContext(Ee);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function De({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:a,...o}){let s=ye(),[c,l]=F.useState(!1),[u,d]=F.useState(e),f=t??u,p=F.useCallback(e=>{let t=typeof e==`function`?e(f):e;n?n(t):d(t),document.cookie=`${be}=${t}; path=/; max-age=${xe}`},[n,f]),m=F.useCallback(()=>s?l(e=>!e):p(e=>!e),[s,p,l]);F.useEffect(()=>{let e=e=>{e.key===Te&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),m())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[m]);let h=f?`expanded`:`collapsed`,g=F.useMemo(()=>({state:h,open:f,setOpen:p,isMobile:s,openMobile:c,setOpenMobile:l,toggleSidebar:m}),[h,f,p,s,c,l,m]);return(0,I.jsx)(Ee.Provider,{value:g,children:(0,I.jsx)(ie,{delayDuration:0,children:(0,I.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:{"--sidebar-width":Se,"--sidebar-width-icon":we,...i},className:M(`group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full`,r),...o,children:a})})})}function Oe({side:e=`left`,variant:t=`sidebar`,collapsible:n=`offcanvas`,className:r,children:i,...a}){let{isMobile:o,state:s,openMobile:c,setOpenMobile:l}=L();return n===`none`?(0,I.jsx)(`div`,{"data-slot":`sidebar`,className:M(`bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col`,r),...a,children:i}):o?(0,I.jsx)(ue,{open:c,onOpenChange:l,...a,children:(0,I.jsxs)(me,{"data-sidebar":`sidebar`,"data-slot":`sidebar`,"data-mobile":`true`,className:`bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden`,style:{"--sidebar-width":Ce},side:e,children:[(0,I.jsxs)(he,{className:`sr-only`,children:[(0,I.jsx)(ge,{children:`Sidebar`}),(0,I.jsx)(_e,{children:`Displays the mobile sidebar.`})]}),(0,I.jsx)(`div`,{className:`flex h-full w-full flex-col`,children:i})]})}):(0,I.jsxs)(`div`,{className:`group peer text-sidebar-foreground hidden md:block`,"data-state":s,"data-collapsible":s===`collapsed`?n:``,"data-variant":t,"data-side":e,"data-slot":`sidebar`,children:[(0,I.jsx)(`div`,{"data-slot":`sidebar-gap`,className:M(`relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear`,`group-data-[collapsible=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,t===`floating`||t===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`)}),(0,I.jsx)(`div`,{"data-slot":`sidebar-container`,className:M(`fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex`,e===`left`?`start-0 group-data-[collapsible=offcanvas]:start-[calc(var(--sidebar-width)*-1)]`:`end-0 group-data-[collapsible=offcanvas]:end-[calc(var(--sidebar-width)*-1)]`,t===`floating`||t===`inset`?`p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-e group-data-[side=right]:border-s`,r),...a,children:(0,I.jsx)(`div`,{"data-sidebar":`sidebar`,"data-slot":`sidebar-inner`,className:`bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow-sm`,children:i})})]})}function ke({className:e,onClick:t,...n}){let{toggleSidebar:r}=L();return(0,I.jsxs)(P,{"data-sidebar":`trigger`,"data-slot":`sidebar-trigger`,variant:`ghost`,size:`icon`,className:M(`size-7`,e),onClick:e=>{t?.(e),r()},...n,children:[(0,I.jsx)(oe,{className:`rtl:rotate-180`}),(0,I.jsx)(`span`,{className:`sr-only`,children:`Toggle Sidebar`})]})}function Ae({className:e,...t}){return(0,I.jsx)(`main`,{"data-slot":`sidebar-inset`,className:M(`bg-background relative flex w-full flex-1 flex-col`,`md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ms-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ms-2`,e),...t})}function je({className:e,...t}){return(0,I.jsx)(`div`,{"data-slot":`sidebar-header`,"data-sidebar":`header`,className:M(`flex flex-col gap-2 p-2`,e),...t})}function Me({className:e,...t}){return(0,I.jsx)(`div`,{"data-slot":`sidebar-footer`,"data-sidebar":`footer`,className:M(`flex flex-col gap-2 p-2`,e),...t})}function Ne({className:e,...t}){return(0,I.jsx)(`div`,{"data-slot":`sidebar-content`,"data-sidebar":`content`,className:M(`flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden`,e),...t})}function Pe({className:e,...t}){return(0,I.jsx)(`div`,{"data-slot":`sidebar-group`,"data-sidebar":`group`,className:M(`relative flex w-full min-w-0 flex-col p-2`,e),...t})}function Fe({className:e,asChild:t=!1,...n}){return(0,I.jsx)(t?f:`div`,{"data-slot":`sidebar-group-label`,"data-sidebar":`group-label`,className:M(`text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium outline-hidden transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0`,`group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0`,e),...n})}function Ie({className:e,...t}){return(0,I.jsx)(`div`,{"data-slot":`sidebar-group-content`,"data-sidebar":`group-content`,className:M(`w-full text-sm`,e),...t})}function Le({className:e,...t}){return(0,I.jsx)(`ul`,{"data-slot":`sidebar-menu`,"data-sidebar":`menu`,className:M(`flex w-full min-w-0 flex-col gap-1`,e),...t})}function Re({className:e,...t}){return(0,I.jsx)(`li`,{"data-slot":`sidebar-menu-item`,"data-sidebar":`menu-item`,className:M(`group/menu-item relative`,e),...t})}var ze=te(`peer/menu-button ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-start text-sm outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pe-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:font-medium [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0`,{variants:{variant:{default:`hover:bg-sidebar-accent hover:text-sidebar-accent-foreground`,outline:`bg-background hover:bg-sidebar-accent hover:text-sidebar-accent-foreground shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]`},size:{default:`h-8 text-sm`,sm:`h-7 text-xs`,lg:`h-12 text-sm group-data-[collapsible=icon]:p-0!`}},defaultVariants:{variant:`default`,size:`default`}});function Be({asChild:e=!1,isActive:t=!1,variant:n=`default`,size:r=`default`,tooltip:i,className:a,...o}){let s=e?f:`button`,{isMobile:c,state:l}=L(),u=(0,I.jsx)(s,{"data-slot":`sidebar-menu-button`,"data-sidebar":`menu-button`,"data-size":r,"data-active":t,className:M(ze({variant:n,size:r}),a),...o});return i?(typeof i==`string`&&(i={children:i}),(0,I.jsxs)(ae,{children:[(0,I.jsx)(ne,{asChild:!0,children:u}),(0,I.jsx)(re,{side:`right`,align:`center`,hidden:l!==`collapsed`||c,...i})]})):u}function Ve({className:e,size:t=`default`,...n}){return(0,I.jsx)(D,{"data-slot":`avatar`,"data-size":t,className:M(`group/avatar relative flex size-8 shrink-0 overflow-hidden rounded-full select-none data-[size=lg]:size-10 data-[size=sm]:size-6`,e),...n})}function He({className:e,...t}){return(0,I.jsx)(S,{"data-slot":`avatar-fallback`,className:M(`bg-muted text-muted-foreground flex size-full items-center justify-center rounded-full text-sm group-data-[size=sm]/avatar:text-xs`,e),...t})}function Ue({...e}){return(0,I.jsx)(p,{"data-slot":`dropdown-menu`,...e})}function We({...e}){return(0,I.jsx)(y,{"data-slot":`dropdown-menu-trigger`,...e})}function Ge({className:e,sideOffset:t=4,...n}){return(0,I.jsx)(_,{children:(0,I.jsx)(E,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:M(`bg-popover text-popover-foreground data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md`,e),...n})})}function Ke({...e}){return(0,I.jsx)(c,{"data-slot":`dropdown-menu-group`,...e})}function qe({className:e,inset:t,variant:n=`default`,...r}){return(0,I.jsx)(g,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:M(`focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive! relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:ps-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r})}function Je({className:e,inset:t,...n}){return(0,I.jsx)(h,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:M(`px-2 py-1.5 text-sm font-medium data-[inset]:ps-8`,e),...n})}function Ye({className:e,...t}){return(0,I.jsx)(i,{"data-slot":`dropdown-menu-separator`,className:M(`bg-border -mx-1 my-1 h-px`,e),...t})}var Xe=1,Ze=.9,Qe=.8,$e=.17,et=.1,tt=.999,nt=.9999,rt=.99,it=/[\\\/_+.#"@\[\(\{&]/,at=/[\\\/_+.#"@\[\(\{&]/g,ot=/[\s-]/,st=/[\s-]/g;function ct(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?Xe:rt;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=ct(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=Xe:it.test(e.charAt(l-1))?(d*=Qe,p=e.slice(i,l-1).match(at),p&&i>0&&(d*=tt**+p.length)):ot.test(e.charAt(l-1))?(d*=Ze,m=e.slice(i,l-1).match(st),m&&i>0&&(d*=tt**+m.length)):(d*=$e,i>0&&(d*=tt**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=nt)),(d<et&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=ct(e,t,n,r,l+1,a+2,o),f*et>d&&(d=f*et)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function lt(e){return e.toLowerCase().replace(st,` `)}function ut(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,ct(e,t,lt(e),lt(t),0,0,{})}typeof window<`u`&&window.document&&window.document.createElement;function R(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function dt(e,t=[]){let n=[];function r(t,r){let i=F.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=F.useMemo(()=>o,Object.values(o));return(0,I.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=F.useContext(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>F.createContext(e));return function(n){let r=n?.[e]||t;return F.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,ft(i,...t)]}function ft(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return F.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}var pt=e(r(),1),z=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=o(`Primitive.${t}`),r=F.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,I.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function mt(e,t){e&&pt.flushSync(()=>e.dispatchEvent(t))}function ht(e,t=globalThis?.document){let n=k(e);F.useEffect(()=>{let e=e=>{e.key===`Escape`&&n(e)};return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}var gt=`DismissableLayer`,_t=`dismissableLayer.update`,vt=`dismissableLayer.pointerDownOutside`,yt=`dismissableLayer.focusOutside`,bt,xt=F.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),St=F.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:s,onDismiss:c,...u}=e,d=F.useContext(xt),[f,p]=F.useState(null),m=f?.ownerDocument??globalThis?.document,[,h]=F.useState({}),g=l(t,e=>p(e)),_=Array.from(d.layers),[v]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),ee=_.indexOf(v),y=f?_.indexOf(f):-1,b=d.layersWithOutsidePointerEventsDisabled.size>0,x=y>=ee,S=F.useRef(!1),C=Et(e=>{let t=e.target;if(!(t instanceof Node))return;let n=[...d.branches].some(e=>e.contains(t));!x||n||(a?.(e),s?.(e),e.defaultPrevented||c?.())},{ownerDocument:m,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:S,dismissableSurfaces:d.dismissableSurfaces}),w=Dt(e=>{if(r&&S.current)return;let t=e.target;[...d.branches].some(e=>e.contains(t))||(o?.(e),s?.(e),e.defaultPrevented||c?.())},m);return ht(e=>{y===d.layers.size-1&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))},m),F.useEffect(()=>{if(f)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(bt=m.body.style.pointerEvents,m.body.style.pointerEvents=`none`),d.layersWithOutsidePointerEventsDisabled.add(f)),d.layers.add(f),Ot(),()=>{n&&(d.layersWithOutsidePointerEventsDisabled.delete(f),d.layersWithOutsidePointerEventsDisabled.size===0&&(m.body.style.pointerEvents=bt))}},[f,m,n,d]),F.useEffect(()=>()=>{f&&(d.layers.delete(f),d.layersWithOutsidePointerEventsDisabled.delete(f),Ot())},[f,d]),F.useEffect(()=>{let e=()=>h({});return document.addEventListener(_t,e),()=>document.removeEventListener(_t,e)},[]),(0,I.jsx)(z.div,{...u,ref:g,style:{pointerEvents:b?x?`auto`:`none`:void 0,...e.style},onFocusCapture:R(e.onFocusCapture,w.onFocusCapture),onBlurCapture:R(e.onBlurCapture,w.onBlurCapture),onPointerDownCapture:R(e.onPointerDownCapture,C.onPointerDownCapture)})});St.displayName=gt;var Ct=`DismissableLayerBranch`,wt=F.forwardRef((e,t)=>{let n=F.useContext(xt),r=F.useRef(null),i=l(t,r);return F.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,I.jsx)(z.div,{...e,ref:i})});wt.displayName=Ct;function Tt(){let e=F.useContext(xt),[t,n]=F.useState(null);return F.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}function Et(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a}=t,o=k(e),s=F.useRef(!1),c=F.useRef(!1),l=F.useRef(new Map),u=F.useRef(()=>{});return F.useEffect(()=>{function e(){c.current=!1,i.current=!1,l.current.clear()}function t(){return Array.from(l.current.values()).some(Boolean)}function d(e){if(!c.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||l.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{c.current&&u.current()},0)}function f(e){c.current&&l.current.set(e.type,!1)}let p=a=>{if(a.target&&!s.current){let s=function(){n.removeEventListener(`click`,u.current);let r=t();e(),r||kt(vt,o,d,{discrete:!0})},d={originalEvent:a};c.current=!0,i.current=r&&a.button===0,l.current.clear(),!r||a.button!==0?s():(n.removeEventListener(`click`,u.current),u.current=s,n.addEventListener(`click`,u.current,{once:!0}))}else n.removeEventListener(`click`,u.current),e();s.current=!1},m=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of m)n.addEventListener(e,d,!0),n.addEventListener(e,f);let h=window.setTimeout(()=>{n.addEventListener(`pointerdown`,p)},0);return()=>{window.clearTimeout(h),n.removeEventListener(`pointerdown`,p),n.removeEventListener(`click`,u.current);for(let e of m)n.removeEventListener(e,d,!0),n.removeEventListener(e,f)}},[n,o,r,i,a]),{onPointerDownCapture:()=>s.current=!0}}function Dt(e,t=globalThis?.document){let n=k(e),r=F.useRef(!1);return F.useEffect(()=>{let e=e=>{e.target&&!r.current&&kt(yt,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Ot(){let e=new CustomEvent(_t);document.dispatchEvent(e)}function kt(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?mt(i,a):i.dispatchEvent(a)}var At=`focusScope.autoFocusOnMount`,jt=`focusScope.autoFocusOnUnmount`,Mt={bubbles:!1,cancelable:!0},Nt=`FocusScope`,Pt=F.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=F.useState(null),u=k(i),d=k(a),f=F.useRef(null),p=l(t,e=>c(e)),m=F.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;F.useEffect(()=>{if(r){let e=function(e){if(m.paused||!s)return;let t=e.target;s.contains(t)?f.current=t:B(f.current,{select:!0})},t=function(e){if(m.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||B(f.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&B(s)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,m.paused]),F.useEffect(()=>{if(s){Vt.add(m);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(At,Mt);s.addEventListener(At,u),s.dispatchEvent(t),t.defaultPrevented||(Ft(Wt(Lt(s)),{select:!0}),document.activeElement===e&&B(s))}return()=>{s.removeEventListener(At,u),setTimeout(()=>{let t=new CustomEvent(jt,Mt);s.addEventListener(jt,d),s.dispatchEvent(t),t.defaultPrevented||B(e??document.body,{select:!0}),s.removeEventListener(jt,d),Vt.remove(m)},0)}}},[s,u,d,m]);let h=F.useCallback(e=>{if(!n&&!r||m.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=It(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&B(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&B(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,m.paused]);return(0,I.jsx)(z.div,{tabIndex:-1,...o,ref:p,onKeyDown:h})});Pt.displayName=Nt;function Ft(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(B(r,{select:t}),document.activeElement!==n)return}function It(e){let t=Lt(e);return[Rt(t,e),Rt(t.reverse(),e)]}function Lt(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Rt(e,t){for(let n of e)if(!zt(n,{upTo:t}))return n}function zt(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function Bt(e){return e instanceof HTMLInputElement&&`select`in e}function B(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Bt(e)&&t&&e.select()}}var Vt=Ht();function Ht(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=Ut(e,t),e.unshift(t)},remove(t){e=Ut(e,t),e[0]?.resume()}}}function Ut(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Wt(e){return e.filter(e=>e.tagName!==`A`)}var Gt=`Portal`,Kt=F.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=F.useState(!1);d(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?pt.createPortal((0,I.jsx)(z.div,{...r,ref:t}),o):null});Kt.displayName=Gt;function qt(e,t){return F.useReducer((e,n)=>t[e][n]??e,e)}var V=e=>{let{present:t,children:n}=e,r=Jt(t),i=typeof n==`function`?n({present:r.isPresent}):F.Children.only(n),a=Xt(r.ref,Zt(i));return typeof n==`function`||r.isPresent?F.cloneElement(i,{ref:a}):null};V.displayName=`Presence`;function Jt(e){let[t,n]=F.useState(),r=F.useRef(null),i=F.useRef(e),a=F.useRef(`none`),[o,s]=qt(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return F.useEffect(()=>{let e=H(r.current);a.current=o===`mounted`?e:`none`},[o]),d(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=H(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),d(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=H(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(s(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},c=e=>{e.target===t&&(a.current=H(r.current))};return t.addEventListener(`animationstart`,c),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,c),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:F.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function Yt(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Xt(...e){let t=F.useRef(e);return t.current=e,F.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=Yt(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():Yt(n[e],null)}}},[])}function H(e){return e?.animationName||`none`}function Zt(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var U=`Dialog`,[Qt,$t]=dt(U),[en,W]=Qt(U),tn=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=F.useRef(null),c=F.useRef(null),[l,d]=u({prop:r,defaultProp:i??!1,onChange:a,caller:U});return(0,I.jsx)(en,{scope:t,triggerRef:s,contentRef:c,contentId:C(),titleId:C(),descriptionId:C(),open:l,onOpenChange:d,onOpenToggle:F.useCallback(()=>d(e=>!e),[d]),modal:o,children:n})};tn.displayName=U;var nn=`DialogTrigger`,rn=F.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=W(nn,n),a=l(t,i.triggerRef);return(0,I.jsx)(z.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":Sn(i.open),...r,ref:a,onClick:R(e.onClick,i.onOpenToggle)})});rn.displayName=nn;var an=`DialogPortal`,[on,sn]=Qt(an,{forceMount:void 0}),cn=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=W(an,t);return(0,I.jsx)(on,{scope:t,forceMount:n,children:F.Children.map(r,e=>(0,I.jsx)(V,{present:n||a.open,children:(0,I.jsx)(Kt,{asChild:!0,container:i,children:e})}))})};cn.displayName=an;var G=`DialogOverlay`,ln=F.forwardRef((e,t)=>{let n=sn(G,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=W(G,e.__scopeDialog);return a.modal?(0,I.jsx)(V,{present:r||a.open,children:(0,I.jsx)(dn,{...i,ref:t})}):null});ln.displayName=G;var un=o(`DialogOverlay.RemoveScroll`),dn=F.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=W(G,n),a=l(t,Tt());return(0,I.jsx)(m,{as:un,allowPinchZoom:!0,shards:[i.contentRef],children:(0,I.jsx)(z.div,{"data-state":Sn(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})}),K=`DialogContent`,fn=F.forwardRef((e,t)=>{let n=sn(K,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=W(K,e.__scopeDialog);return(0,I.jsx)(V,{present:r||a.open,children:a.modal?(0,I.jsx)(pn,{...i,ref:t}):(0,I.jsx)(mn,{...i,ref:t})})});fn.displayName=K;var pn=F.forwardRef((e,t)=>{let n=W(K,e.__scopeDialog),r=F.useRef(null),i=l(t,n.contentRef,r);return F.useEffect(()=>{let e=r.current;if(e)return A(e)},[]),(0,I.jsx)(hn,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:R(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:R(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:R(e.onFocusOutside,e=>e.preventDefault())})}),mn=F.forwardRef((e,t)=>{let n=W(K,e.__scopeDialog),r=F.useRef(!1),i=F.useRef(!1);return(0,I.jsx)(hn,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),hn=F.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,...s}=e,c=W(K,n);return a(),(0,I.jsx)(I.Fragment,{children:(0,I.jsx)(Pt,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:o,children:(0,I.jsx)(St,{role:`dialog`,id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":Sn(c.open),...s,ref:t,deferPointerDownOutside:!0,onDismiss:()=>c.onOpenChange(!1)})})})}),gn=`DialogTitle`,_n=F.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=W(gn,n);return(0,I.jsx)(z.h2,{id:i.titleId,...r,ref:t})});_n.displayName=gn;var vn=`DialogDescription`,yn=F.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=W(vn,n);return(0,I.jsx)(z.p,{id:i.descriptionId,...r,ref:t})});yn.displayName=vn;var bn=`DialogClose`,xn=F.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=W(bn,n);return(0,I.jsx)(z.button,{type:`button`,...r,ref:t,onClick:R(e.onClick,()=>i.onOpenChange(!1))})});xn.displayName=bn;function Sn(e){return e?`open`:`closed`}var q=`[cmdk-group=""]`,Cn=`[cmdk-group-items=""]`,wn=`[cmdk-group-heading=""]`,Tn=`[cmdk-item=""]`,En=`${Tn}:not([aria-disabled="true"])`,Dn=`cmdk-item-select`,J=`data-value`,On=(e,t,n)=>ut(e,t,n),kn=F.createContext(void 0),Y=()=>F.useContext(kn),An=F.createContext(void 0),jn=()=>F.useContext(An),Mn=F.createContext(void 0),Nn=F.forwardRef((e,t)=>{let n=Q(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=Q(()=>new Set),i=Q(()=>new Map),a=Q(()=>new Map),o=Q(()=>new Set),s=Wn(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=C(),ee=C(),y=C(),b=F.useRef(null),x=Kn();Z(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,S.emit()}},[u]),Z(()=>{x(6,k)},[]);let S=F.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),x(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(y);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(x(7,()=>{n.current.selectedItemId=A()?.id,S.emit()}),r||x(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}S.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=F.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),x(2,()=>{E(),S.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),x(3,()=>{O(),E(),n.current.value||D(),S.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();x(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),S.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:y,labelId:ee,listInnerRef:b}),[]);function T(e,t){let r=s.current?.filter??On;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=b.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(Cn);t?t.appendChild(e.parentElement===t?e:e.closest(`${Cn} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${Cn} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=b.current?.querySelector(`${q}[${J}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(J);S.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function k(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(q)?.querySelector(wn))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return b.current?.querySelector(`${Tn}[aria-selected="true"]`)}function j(){return Array.from(b.current?.querySelectorAll(En)||[])}function M(e){let t=j()[e];t&&S.setState(`value`,t.getAttribute(J))}function te(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&S.setState(`value`,a.getAttribute(J))}function N(e){let t=A()?.closest(q),n;for(;t&&!n;)t=e>0?Hn(t,q):Un(t,q),n=t?.querySelector(En);n?S.setState(`value`,n.getAttribute(J)):te(e)}let P=()=>M(j().length-1),ne=e=>{e.preventDefault(),e.metaKey?P():e.altKey?N(1):te(1)},re=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?N(-1):te(-1)};return F.createElement(z.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&ne(e);break;case`ArrowDown`:ne(e);break;case`p`:case`k`:g&&e.ctrlKey&&re(e);break;case`ArrowUp`:re(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),P();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(Dn);t.dispatchEvent(e)}}}}},F.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:Yn},c),Jn(e,e=>F.createElement(An.Provider,{value:S},F.createElement(kn.Provider,{value:w},e))))}),Pn=F.forwardRef((e,t)=>{let n=C(),r=F.useRef(null),i=F.useContext(Mn),a=Y(),o=Wn(e),c=o.current?.forceMount??i?.forceMount;Z(()=>{if(!c)return a.item(n,i?.id)},[c]);let l=Gn(n,r,[e.value,e.children,r],e.keywords),u=jn(),d=$(e=>e.value&&e.value===l.current),f=$(e=>c||a.filter()===!1?!0:e.search?e.filtered.items.get(n)>0:!0);F.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(Dn,p),()=>t.removeEventListener(Dn,p)},[f,e.onSelect,e.disabled]);function p(){var e,t;m(),(t=(e=o.current).onSelect)==null||t.call(e,l.current)}function m(){u.setState(`value`,l.current,!0)}if(!f)return null;let{disabled:h,value:g,onSelect:_,forceMount:v,keywords:ee,...y}=e;return F.createElement(z.div,{ref:s(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!h,"aria-selected":!!d,"data-disabled":!!h,"data-selected":!!d,onPointerMove:h||a.getDisablePointerSelection()?void 0:m,onClick:h?void 0:p},e.children)}),Fn=F.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=C(),c=F.useRef(null),l=F.useRef(null),u=C(),d=Y(),f=$(e=>i||d.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);Z(()=>d.group(o),[]),Gn(o,c,[e.value,e.heading,l]);let p=F.useMemo(()=>({id:o,forceMount:i}),[i]);return F.createElement(z.div,{ref:s(c,t),...a,"cmdk-group":``,role:`presentation`,hidden:f?void 0:!0},n&&F.createElement(`div`,{ref:l,"cmdk-group-heading":``,"aria-hidden":!0,id:u},n),Jn(e,e=>F.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?u:void 0},F.createElement(Mn.Provider,{value:p},e))))}),In=F.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=F.useRef(null),a=$(e=>!e.search);return!n&&!a?null:F.createElement(z.div,{ref:s(i,t),...r,"cmdk-separator":``,role:`separator`})}),Ln=F.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=jn(),o=$(e=>e.search),s=$(e=>e.selectedItemId),c=Y();return F.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),F.createElement(z.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),Rn=F.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=F.useRef(null),o=F.useRef(null),c=$(e=>e.selectedItemId),l=Y();return F.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),F.createElement(z.div,{ref:s(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":c,"aria-label":r,id:l.listId},Jn(e,e=>F.createElement(`div`,{ref:s(o,l.listInnerRef),"cmdk-list-sizer":``},e)))}),zn=F.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return F.createElement(tn,{open:n,onOpenChange:r},F.createElement(cn,{container:o},F.createElement(ln,{"cmdk-overlay":``,className:i}),F.createElement(fn,{"aria-label":e.label,"cmdk-dialog":``,className:a},F.createElement(Nn,{ref:t,...s}))))}),Bn=F.forwardRef((e,t)=>$(e=>e.filtered.count===0)?F.createElement(z.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),Vn=F.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return F.createElement(z.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Jn(e,e=>F.createElement(`div`,{"aria-hidden":!0},e)))}),X=Object.assign(Nn,{List:Rn,Item:Pn,Input:Ln,Group:Fn,Separator:In,Dialog:zn,Empty:Bn,Loading:Vn});function Hn(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Un(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Wn(e){let t=F.useRef(e);return Z(()=>{t.current=e}),t}var Z=typeof window>`u`?F.useEffect:F.useLayoutEffect;function Q(e){let t=F.useRef();return t.current===void 0&&(t.current=e()),t}function $(e){let t=jn(),n=()=>e(t.snapshot());return F.useSyncExternalStore(t.subscribe,n,n)}function Gn(e,t,n,r=[]){let i=F.useRef(),a=Y();return Z(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(J,s),i.current=s}),i}var Kn=()=>{let[e,t]=F.useState(),n=Q(()=>new Map);return Z(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function qn(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function Jn({asChild:e,children:t},n){return e&&F.isValidElement(t)?F.cloneElement(qn(t),{ref:t.ref},n(t.props.children)):n(t)}var Yn={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function Xn({...e}){return(0,I.jsx)(T,{"data-slot":`dialog`,...e})}function Zn({...e}){return(0,I.jsx)(O,{"data-slot":`dialog-portal`,...e})}function Qn({className:e,...t}){return(0,I.jsx)(v,{"data-slot":`dialog-overlay`,className:M(`data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50`,e),...t})}function $n({className:e,children:t,showCloseButton:n=!0,...r}){return(0,I.jsxs)(Zn,{"data-slot":`dialog-portal`,children:[(0,I.jsx)(Qn,{}),(0,I.jsxs)(x,{"data-slot":`dialog-content`,className:M(`bg-background data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 fixed start-[50%] top-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 outline-none sm:max-w-lg rtl:-translate-x-[-50%]`,e),...r,children:[t,n&&(0,I.jsxs)(w,{"data-slot":`dialog-close`,className:`ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute end-4 top-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,I.jsx)(le,{}),(0,I.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function er({className:e,...t}){return(0,I.jsx)(`div`,{"data-slot":`dialog-header`,className:M(`flex flex-col gap-2 text-center sm:text-start`,e),...t})}function tr({className:e,showCloseButton:t=!1,children:n,...r}){return(0,I.jsxs)(`div`,{"data-slot":`dialog-footer`,className:M(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...r,children:[n,t&&(0,I.jsx)(w,{asChild:!0,children:(0,I.jsx)(P,{variant:`outline`,children:`Close`})})]})}function nr({className:e,...t}){return(0,I.jsx)(j,{"data-slot":`dialog-title`,className:M(`text-lg leading-none font-semibold`,e),...t})}function rr({className:e,...t}){return(0,I.jsx)(b,{"data-slot":`dialog-description`,className:M(`text-muted-foreground text-sm`,e),...t})}function ir({className:e,...t}){return(0,I.jsx)(X,{"data-slot":`command`,className:M(`bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md`,e),...t})}function ar({title:e=`Command Palette`,description:t=`Search for a command to run...`,children:n,className:r,showCloseButton:i=!0,...a}){return(0,I.jsxs)(Xn,{...a,children:[(0,I.jsxs)(er,{className:`sr-only`,children:[(0,I.jsx)(nr,{children:e}),(0,I.jsx)(rr,{children:t})]}),(0,I.jsx)($n,{className:M(`overflow-hidden p-0`,r),showCloseButton:i,children:(0,I.jsx)(ir,{className:`[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5`,children:n})})]})}function or({className:e,...t}){return(0,I.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,I.jsx)(ce,{className:`size-4 shrink-0 opacity-50`}),(0,I.jsx)(X.Input,{"data-slot":`command-input`,className:M(`placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50`,e),...t})]})}function sr({className:e,...t}){return(0,I.jsx)(X.List,{"data-slot":`command-list`,className:M(`max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto`,e),...t})}function cr({...e}){return(0,I.jsx)(X.Empty,{"data-slot":`command-empty`,className:`py-6 text-center text-sm`,...e})}function lr({className:e,...t}){return(0,I.jsx)(X.Group,{"data-slot":`command-group`,className:M(`text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium`,e),...t})}function ur({className:e,...t}){return(0,I.jsx)(X.Item,{"data-slot":`command-item`,className:M(`data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...t})}function dr({className:e,...t}){return(0,I.jsx)(`kbd`,{"data-slot":`kbd`,className:M(`bg-muted text-muted-foreground pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none`,`[&_svg:not([class*='size-'])]:size-3`,e),...t})}function fr({...e}){return(0,I.jsx)(`nav`,{"aria-label":`breadcrumb`,"data-slot":`breadcrumb`,...e})}function pr({className:e,...t}){return(0,I.jsx)(`ol`,{"data-slot":`breadcrumb-list`,className:M(`text-muted-foreground flex flex-wrap items-center gap-1.5 text-sm break-words sm:gap-2.5`,e),...t})}function mr({className:e,...t}){return(0,I.jsx)(`li`,{"data-slot":`breadcrumb-item`,className:M(`inline-flex items-center gap-1.5`,e),...t})}function hr({className:e,...t}){return(0,I.jsx)(`span`,{"data-slot":`breadcrumb-page`,role:`link`,"aria-disabled":`true`,"aria-current":`page`,className:M(`text-foreground font-normal`,e),...t})}function gr({children:e,className:t,...n}){return(0,I.jsx)(`li`,{"data-slot":`breadcrumb-separator`,role:`presentation`,"aria-hidden":`true`,className:M(`[&>svg]:size-3.5`,t),...n,children:e??(0,I.jsx)(se,{})})}export{Ne as A,De as B,qe as C,Ve as D,We as E,je as F,_e as G,L as H,Ae as I,de as J,he as K,Le as L,Pe as M,Ie as N,He as O,Fe as P,Be as R,Ke as S,Ye as T,ue as U,ke as V,me as W,ce as X,le as Y,se as Z,tr as _,gr as a,Ue as b,ar as c,or as d,ur as f,rr as g,$n as h,hr as i,Me as j,Oe as k,cr as l,Xn as m,mr as n,dr as o,sr as p,ge as q,pr as r,ir as s,fr as t,lr as u,er as v,Je as w,Ge as x,nr as y,Re as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{s as a,t as o,u as s}from"./orpc-DURDArDu.js";import{l as c,u as l}from"./esm-DfD3iRfG.js";import{t as u}from"./arrow-left-CWzmtp8T.js";import{n as d,t as f}from"./clipboard-D6ZMYUE8.js";import{t as p}from"./use-label-CykSHq9A.js";import{D as m,h,l as g,r as _,v,w as y,y as b}from"./dist-ClOzYsk5.js";import{o as x}from"./validation-CwFumc7a.js";import{a as S,i as C,n as w,r as T,t as E}from"./card-L2-kK5VK.js";import{B as D,F as O,I as k,L as A,M as j,N as M,P as N,Pt as P,R as F,Tt as I,j as L}from"./index-
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{s as a,t as o,u as s}from"./orpc-DURDArDu.js";import{l as c,u as l}from"./esm-DfD3iRfG.js";import{t as u}from"./arrow-left-CWzmtp8T.js";import{n as d,t as f}from"./clipboard-D6ZMYUE8.js";import{t as p}from"./use-label-CykSHq9A.js";import{D as m,h,l as g,r as _,v,w as y,y as b}from"./dist-ClOzYsk5.js";import{o as x}from"./validation-CwFumc7a.js";import{a as S,i as C,n as w,r as T,t as E}from"./card-L2-kK5VK.js";import{B as D,F as O,I as k,L as A,M as j,N as M,P as N,Pt as P,R as F,Tt as I,j as L}from"./index-8CVr3Qp5.js";import{t as R}from"./input-xYuLUQID.js";import{a as z,c as B,f as V,i as H,n as U,o as W,s as G,t as K}from"./form-5CBmFjhZ.js";import{n as q,t as J}from"./alert-cwX3fWUu.js";import{t as Y}from"./valibot-D1tw6tkr.js";var X=e(n()),Z=e(t()),Q={copyAria:{id:`userInvite.copy.aria`},errEmailTaken:{id:`userInvite.error.emailTaken`},errFallback:{id:`userInvite.error.fallback`}},$=h({email:b(y(),m(),_(x({id:`userInvite.email.invalid`})),g(255)),name:b(y(),m(),g(100)),role:v(j)});function ee(){let e=l(),t=p(),[n,r]=(0,X.useState)({status:`idle`}),[a,d]=(0,X.useState)(null),f=s({mutationFn:e=>o.user.invite.call({email:e.email,role:e.role,...e.name.length>0?{name:e.name}:{}}),onMutate:()=>{d(null)},onSuccess:e=>{r({status:`success`,user:e.user,inviteUrl:te(e.inviteToken)})},onError:e=>{d(ne(e))}}),m=V({resolver:Y($),defaultValues:{email:``,name:``,role:`subscriber`},mode:`onBlur`}),h=m.handleSubmit(e=>{f.mutate(e)});return n.status===`success`?(0,Z.jsx)(re,{user:n.user,inviteUrl:n.inviteUrl,onInviteAnother:()=>{r({status:`idle`}),d(null),m.reset()},onBackToList:()=>{e({to:`/users`,search:L})}}):(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col gap-4`,children:[(0,Z.jsxs)(c,{to:`/users`,search:L,className:`text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-sm`,"data-testid":`invite-back-link`,children:[(0,Z.jsx)(u,{className:`size-4 rtl:rotate-180`}),(0,Z.jsx)(i,{id:`userInvite.backToList`,message:`Back to users`})]}),(0,Z.jsxs)(E,{children:[(0,Z.jsxs)(C,{children:[(0,Z.jsx)(S,{children:(0,Z.jsx)(`h1`,{"data-testid":`invite-heading`,children:(0,Z.jsx)(i,{id:`userInvite.title`,message:`Invite user`})})}),(0,Z.jsx)(T,{children:(0,Z.jsx)(i,{id:`userInvite.description`,message:`They'll enrol a passkey the first time they open the invite link. No password required.`})})]}),(0,Z.jsx)(w,{children:(0,Z.jsx)(K,{...m,children:(0,Z.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:h,children:[(0,Z.jsx)(H,{control:m.control,name:`email`,render:({field:e})=>(0,Z.jsxs)(z,{children:[(0,Z.jsx)(W,{children:(0,Z.jsx)(i,{id:`userInvite.email.label`,message:`Email`})}),(0,Z.jsx)(U,{children:(0,Z.jsx)(R,{type:`email`,autoComplete:`email`,required:!0,disabled:f.isPending,"data-testid":`invite-email-input`,...e})}),(0,Z.jsx)(G,{})]})}),(0,Z.jsx)(H,{control:m.control,name:`name`,render:({field:e})=>(0,Z.jsxs)(z,{children:[(0,Z.jsx)(W,{children:(0,Z.jsx)(i,{id:`userInvite.name.label`,message:`Name`})}),(0,Z.jsx)(U,{children:(0,Z.jsx)(R,{type:`text`,autoComplete:`name`,disabled:f.isPending,"data-testid":`invite-name-input`,...e})}),(0,Z.jsx)(G,{})]})}),(0,Z.jsx)(H,{control:m.control,name:`role`,render:({field:e})=>(0,Z.jsxs)(z,{children:[(0,Z.jsx)(W,{children:(0,Z.jsx)(i,{id:`userInvite.role.label`,message:`Role`})}),(0,Z.jsxs)(N,{value:e.value,onValueChange:t=>{M(t)&&e.onChange(t)},disabled:f.isPending,children:[(0,Z.jsx)(U,{children:(0,Z.jsx)(A,{className:`w-full`,onBlur:e.onBlur,"data-testid":`invite-role-select`,children:(0,Z.jsx)(F,{})})}),(0,Z.jsx)(O,{children:j.map(e=>(0,Z.jsx)(k,{value:e,"data-testid":`invite-role-select-${e}`,children:t(D[e])},e))})]}),(0,Z.jsx)(G,{})]})}),a?(0,Z.jsx)(J,{variant:`destructive`,"data-testid":`invite-server-error`,children:(0,Z.jsx)(q,{children:t(a)})}):null,(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(P,{type:`button`,variant:`outline`,onClick:()=>{e({to:`/users`,search:L})},disabled:f.isPending,children:(0,Z.jsx)(i,{id:`userInvite.cancel`,message:`Cancel`})}),(0,Z.jsx)(P,{type:`submit`,disabled:f.isPending,"data-testid":`invite-submit`,children:f.isPending?(0,Z.jsx)(i,{id:`userInvite.submit.pending`,message:`Inviting…`}):(0,Z.jsx)(i,{id:`userInvite.submit.idle`,message:`Send invite`})})]})]})})})]})]})}function te(e){return`${window.location.origin}${a}/accept-invite/${e}`}function ne(e){return e&&typeof e==`object`&&`data`in e&&e.data?.reason===`email_taken`?Q.errEmailTaken:e instanceof Error?e.message:Q.errFallback}function re({user:e,inviteUrl:t,onInviteAnother:n,onBackToList:a}){let{i18n:o}=r(),[s,c]=(0,X.useState)(!1),l=async()=>{try{await f(t),c(!0),setTimeout(()=>{c(!1)},2e3)}catch{let e=document.getElementById(`invite-url`);e instanceof HTMLInputElement&&(e.focus(),e.select())}},u=(0,Z.jsx)(`bdi`,{children:e.email});return(0,Z.jsx)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col gap-4`,children:(0,Z.jsxs)(E,{children:[(0,Z.jsxs)(C,{children:[(0,Z.jsx)(S,{children:(0,Z.jsx)(`h1`,{"data-testid":`invite-success-heading`,children:(0,Z.jsx)(i,{id:`userInvite.success.title`,message:`Invite ready`})})}),(0,Z.jsx)(T,{children:(0,Z.jsx)(i,{id:`userInvite.success.description`,message:`Share the link below with {email}. They'll enrol a passkey the first time they open it. Link expires in 7 days.`,values:{email:u},comment:`email: the invited user's address`})})]}),(0,Z.jsxs)(w,{className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(B,{htmlFor:`invite-url`,children:(0,Z.jsx)(i,{id:`userInvite.success.link.label`,message:`Invite link`})}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(R,{id:`invite-url`,readOnly:!0,value:t,onFocus:e=>{e.currentTarget.select()},"data-testid":`invite-url-input`,className:`bg-muted text-muted-foreground font-mono`}),(0,Z.jsx)(P,{type:`button`,variant:`outline`,onClick:()=>{l()},"data-testid":`invite-copy-button`,"aria-label":o._(Q.copyAria.id,void 0,{message:Q.copyAria.message}),children:s?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(I,{}),(0,Z.jsx)(`span`,{children:(0,Z.jsx)(i,{id:`userInvite.copy.copied`,message:`Copied`})})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(d,{}),(0,Z.jsx)(`span`,{children:(0,Z.jsx)(i,{id:`userInvite.copy.idle`,message:`Copy`})})]})})]})]}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(P,{type:`button`,variant:`outline`,onClick:n,"data-testid":`invite-another-button`,children:(0,Z.jsx)(i,{id:`userInvite.success.another`,message:`Invite another`})}),(0,Z.jsx)(P,{type:`button`,onClick:a,"data-testid":`invite-done-button`,children:(0,Z.jsx)(i,{id:`userInvite.success.backToList`,message:`Back to users`})})]})]})]})})}export{ee as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{t as r,u as i}from"./orpc-DURDArDu.js";import{u as a}from"./esm-DfD3iRfG.js";import{t as o}from"./use-label-CykSHq9A.js";import{Pt as s,gt as c,y as l}from"./index-
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{t as r,u as i}from"./orpc-DURDArDu.js";import{u as a}from"./esm-DfD3iRfG.js";import{t as o}from"./use-label-CykSHq9A.js";import{Pt as s,gt as c,y as l}from"./index-8CVr3Qp5.js";import{t as u}from"./slugify-DglnCNxs.js";var d=e(n()),f=e(t()),p={untitled:{id:`editor.entry.create.untitled`},pendingGeneric:{id:`editor.entry.create.pending.generic`},failedTitle:{id:`editor.entry.create.failedTitle`},failedBody:{id:`editor.entry.create.failed`},retry:{id:`editor.entry.create.retry`}};function m(){let{entryType:e}=l.useRouteContext(),t=o(),n=a(),m=(0,d.useRef)(!1),h=i({mutationFn:()=>r.entry.create.call({type:e.name,title:t(p.untitled),slug:u(`untitled-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`),status:`draft`}),onSuccess:t=>{n({to:`/entries/$slug/$id/edit`,params:{slug:e.adminSlug,id:t.id},replace:!0})}});return(0,d.useEffect)(()=>{m.current||(m.current=!0,h.mutate())},[h]),h.isError?(0,f.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-4`,children:[(0,f.jsx)(c,{testId:`create-entry-error`,title:t(p.failedTitle),description:t(p.failedBody)}),(0,f.jsx)(s,{variant:`outline`,"data-testid":`create-entry-retry`,onClick:()=>h.mutate(),children:t(p.retry)})]}):(0,f.jsx)(`div`,{className:`text-muted-foreground flex flex-1 items-center justify-center text-sm`,"data-testid":`create-entry-pending`,children:t(p.pendingGeneric)})}export{m as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{f as r,h as i,t as a,u as o}from"./orpc-DURDArDu.js";import{l as s,u as c}from"./esm-DfD3iRfG.js";import{t as l}from"./arrow-left-CWzmtp8T.js";import{t as u}from"./use-label-CykSHq9A.js";import{n as d}from"./type-labels-DEpt0nSb.js";import{a as f,i as p,n as m,r as h,t as g}from"./card-L2-kK5VK.js";import{g as _,h as v}from"./index-
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{f as r,h as i,t as a,u as o}from"./orpc-DURDArDu.js";import{l as s,u as c}from"./esm-DfD3iRfG.js";import{t as l}from"./arrow-left-CWzmtp8T.js";import{t as u}from"./use-label-CykSHq9A.js";import{n as d}from"./type-labels-DEpt0nSb.js";import{a as f,i as p,n as m,r as h,t as g}from"./card-L2-kK5VK.js";import{g as _,h as v}from"./index-8CVr3Qp5.js";import{i as y}from"./tree-BUpunTXw.js";import{n as b,t as x}from"./-errors-BJp83S61.js";import{t as S}from"./slugify-DglnCNxs.js";var C=e(n()),w=e(t()),T={createFallback:{id:`terms.create.error.createFallback`},emptySlug:{id:`terms.create.error.emptySlug`},hierarchicalDescription:{id:`terms.create.description.hierarchical`},flatDescription:{id:`terms.create.description.flat`}};function E(){let e=c(),t=i(),{taxonomy:n}=v.useRouteContext(),E=u(),D=x(),[O,k]=(0,C.useState)(null),A=n.isHierarchical===!0,j=r({...a.term.list.queryOptions({input:{taxonomy:n.name,limit:200}}),enabled:A}),M=A?y(j.data??[]):[],N=o({mutationFn:e=>a.term.create.call({taxonomy:n.name,name:e.name,slug:e.slug.length>0?e.slug:S(e.name),...e.description.length>0?{description:e.description}:{},...e.parentId==null?{}:{parentId:e.parentId}}),onMutate:()=>{k(null)},onSuccess:async()=>{await t.invalidateQueries({queryKey:a.term.list.key({input:{taxonomy:n.name}})}),e({to:`/terms/$name`,params:{name:n.name},search:_})},onError:e=>{k(D(e,E(T.createFallback)))}});return(0,w.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col gap-4`,children:[(0,w.jsxs)(s,{to:`/terms/$name`,params:{name:n.name},search:_,className:`text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-sm`,"data-testid":`term-new-back-link`,children:[(0,w.jsx)(l,{className:`size-4 rtl:rotate-180`}),E(d(n,`allItems`))]}),(0,w.jsxs)(g,{children:[(0,w.jsxs)(p,{children:[(0,w.jsx)(f,{children:(0,w.jsx)(`h1`,{"data-testid":`term-new-heading`,children:E(d(n,`addNewItem`))})}),(0,w.jsx)(h,{children:E(A?T.hierarchicalDescription:T.flatDescription)})]}),(0,w.jsx)(m,{children:(0,w.jsx)(b,{initialValues:{name:``,slug:``,description:``,parentId:null,meta:{}},isHierarchical:A,parentOptions:M,isSubmitting:N.isPending,serverError:O,submitLabel:E(d(n,`addNewItem`)),metaBoxes:[],onSubmit:e=>{if(e.slug.length===0&&S(e.name).length===0){k(E(T.emptySlug));return}N.mutate(e)},onCancel:()=>{e({to:`/terms/$name`,params:{name:n.name},search:_})}})})]})]})}export{E as component};
|