@blinkk/root-cms 3.1.2 → 3.1.4
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/app.js +1 -4
- package/dist/chunk-MYN76V3L.js +764 -0
- package/dist/{chunk-4VZTYUQ7.js → chunk-NC3CRIFA.js} +191 -13
- package/dist/core/ai-tools.d.ts +82 -42
- package/dist/core/ai.d.ts +54 -218
- package/dist/core/plugin.d.ts +10 -4
- package/dist/functions.js +1 -2
- package/dist/plugin.js +42 -208
- package/dist/shared/ai/models.d.ts +110 -0
- package/dist/shared/ai/prompt-utils.d.ts +59 -0
- package/dist/ui/AIPage-4W4MFELY.js +1 -0
- package/dist/ui/{AssetsPage-KLGNE6D6.js → AssetsPage-QUL2NBWK.js} +1 -1
- package/dist/ui/CollectionPage-7VU6SUUP.js +1 -0
- package/dist/ui/ComparePage-DCP5QHDE.js +1 -0
- package/dist/ui/DataPage-TUVFBALT.js +1 -0
- package/dist/ui/DataSourcePage-YE2ZOHYI.js +1 -0
- package/dist/ui/DocTranslationsPage-3ILTQOP2.js +1 -0
- package/dist/ui/DocumentPage-JFQ3Y2GH.js +1 -0
- package/dist/ui/EditDataSourcePage-WHPZDMD4.js +1 -0
- package/dist/ui/EditReleasePage-QKWHIURV.js +1 -0
- package/dist/ui/EmbeddedAIPage-SQLOV4IT.js +1 -0
- package/dist/ui/{EmbeddedDocumentPage-4TLMCDSO.js → EmbeddedDocumentPage-6FYHUHTE.js} +1 -1
- package/dist/ui/{ImageEditorDialog-GGS4VFEA.js → ImageEditorDialog-Q44YTLB5.js} +1 -1
- package/dist/ui/LogsPage-RC5O722W.js +1 -0
- package/dist/ui/NewDataSourcePage-QXW54CHQ.js +1 -0
- package/dist/ui/NewReleasePage-TKYWVTOH.js +1 -0
- package/dist/ui/{NotFoundPage-A6OCYREA.js → NotFoundPage-RMNPVSD3.js} +1 -1
- package/dist/ui/{ProjectPage-UHRXNN7O.js → ProjectPage-VY4EJX6J.js} +1 -1
- package/dist/ui/ReleasePage-VZAL4KUI.js +1 -0
- package/dist/ui/ReleasesPage-A4BLUNJE.js +1 -0
- package/dist/ui/SettingsPage-MP3YHQDP.js +1 -0
- package/dist/ui/{SidebarToolsPage-VXVRZ2C3.js → SidebarToolsPage-S5DMIEQ6.js} +1 -1
- package/dist/ui/{TaskPage-LDPRN3G6.js → TaskPage-LCBDMA4I.js} +1 -1
- package/dist/ui/TasksPage-72KVSUQY.js +1 -0
- package/dist/ui/TranslationsArbPage-B7TIRREV.js +2 -0
- package/dist/ui/TranslationsEditPage-VQG4YHA6.js +1 -0
- package/dist/ui/{TranslationsPage-674JU6L4.js → TranslationsPage-6VCVMNXI.js} +1 -1
- package/dist/ui/ai-tools-7S4URTMT.js +1 -0
- package/dist/ui/chunk-2PDMFZBF.js +1 -0
- package/dist/ui/{chunk-SKQECSUR.js → chunk-3WQCVKK4.js} +1 -1
- package/dist/ui/{chunk-WMICEDOT.js → chunk-4N6CPIOQ.js} +1 -1
- package/dist/ui/{chunk-NJMNOITA.js → chunk-5SY2SVEX.js} +1 -1
- package/dist/ui/chunk-62VPTZJL.js +1 -0
- package/dist/ui/{chunk-GT5EQSEX.js → chunk-6P75AZ3B.js} +1 -1
- package/dist/ui/{chunk-CAY5NM4Z.js → chunk-74OB6FM4.js} +1 -1
- package/dist/ui/{chunk-XWX2622O.js → chunk-76PG55CM.js} +1 -1
- package/dist/ui/chunk-AAR7DBEN.js +110 -0
- package/dist/ui/{chunk-JS6TK4OP.js → chunk-ATTW36EM.js} +1 -1
- package/dist/ui/chunk-AZ2SK2ZK.js +1 -0
- package/dist/ui/chunk-CSUKZZK5.js +1 -0
- package/dist/ui/chunk-DZYYWCHX.js +3 -0
- package/dist/ui/{chunk-NSOTG64N.js → chunk-EIMRPYCD.js} +1 -1
- package/dist/ui/{chunk-HARRKJFZ.js → chunk-ELKXEMOU.js} +1 -1
- package/dist/ui/{chunk-LROR6N3B.js → chunk-ETPZ3TXX.js} +2 -2
- package/dist/ui/{chunk-LROR6N3B.js.LEGAL.txt → chunk-ETPZ3TXX.js.LEGAL.txt} +1 -0
- package/dist/ui/{chunk-J5E457OI.js → chunk-EYVQCOAD.js} +1 -1
- package/dist/ui/{chunk-Q7IU4QCY.js → chunk-F4F5MH7A.js} +1 -1
- package/dist/ui/chunk-FF4CLAZS.js +1 -0
- package/dist/ui/{chunk-W6LP22IK.js → chunk-GCMX5V3P.js} +1 -1
- package/dist/ui/{chunk-FJLNXXE3.js → chunk-H3PYPGNR.js} +1 -1
- package/dist/ui/{chunk-WFQU7V3W.js → chunk-HVYNDEA7.js} +1 -1
- package/dist/ui/{chunk-TVYAZN2Q.js → chunk-IMXZTYAA.js} +1 -1
- package/dist/ui/{chunk-YXSXWFLZ.js → chunk-J5KDO4RM.js} +1 -1
- package/dist/ui/chunk-JSWRHHTZ.js +1 -0
- package/dist/ui/{chunk-MSYTAJBV.js → chunk-K3UM5OQF.js} +1 -1
- package/dist/ui/{chunk-BW2MKGNP.js → chunk-KBJ4AK5O.js} +1 -1
- package/dist/ui/{chunk-4FGASIIX.js → chunk-L3O3CLWO.js} +1 -1
- package/dist/ui/{chunk-JTIQBW33.js → chunk-LC6WLVRS.js} +1 -1
- package/dist/ui/{chunk-VJUMFJIX.js → chunk-MAZJRNAL.js} +1 -1
- package/dist/ui/{chunk-3E6CASIN.js → chunk-MYKJ6VAM.js} +1 -1
- package/dist/ui/chunk-NEA3XU6N.js +19 -0
- package/dist/ui/{chunk-UUVAD4U4.js → chunk-PR7NB5VK.js} +1 -1
- package/dist/ui/{chunk-QF3GPZTI.js → chunk-QHOZXW7Y.js} +1 -1
- package/dist/ui/chunk-RN4XVVWD.js +1 -0
- package/dist/ui/{chunk-PTPYMVFW.js → chunk-SLLTYDVX.js} +1 -1
- package/dist/ui/chunk-SWTNOWNE.js +1 -0
- package/dist/ui/{chunk-JBHRZ4EX.js → chunk-SYDHFYRC.js} +1 -1
- package/dist/ui/{chunk-ZMS6NIGG.js → chunk-UHK5N75L.js} +1 -1
- package/dist/ui/chunk-V3G3554T.js +31 -0
- package/dist/ui/chunk-VB5VMEN7.js +1 -0
- package/dist/ui/{chunk-2EPQJUGM.js → chunk-VRRRFAIV.js} +1 -1
- package/dist/ui/{chunk-4ALFT4ES.js → chunk-W2ZAVRAT.js} +56 -56
- package/dist/ui/{chunk-P2Z66DHV.js → chunk-W3ICOHMF.js} +1 -1
- package/dist/ui/{chunk-ENQKSLGJ.js → chunk-WAT22UHZ.js} +1 -1
- package/dist/ui/chunk-WN7HUDGY.js +1 -0
- package/dist/ui/{chunk-BUNR5EU3.js → chunk-WS37MDM3.js} +1 -1
- package/dist/ui/chunk-XACLTYBB.js +5 -0
- package/dist/ui/chunk-XJUQOX4E.js +1 -0
- package/dist/ui/{chunk-QHJOTXYB.js → chunk-XM35ZJBQ.js} +1 -1
- package/dist/ui/{chunk-VD6G5NV4.js → chunk-XOWWPE7X.js} +12 -12
- package/dist/ui/chunk-YV5SGR24.js +1 -0
- package/dist/ui/ui.css +1 -1
- package/dist/ui/ui.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-AJDMNTZQ.js +0 -187
- package/dist/chunk-X5CNR4CK.js +0 -1411
- package/dist/ui/AIPage-2N5UYBRX.js +0 -1
- package/dist/ui/CollectionPage-D7IG6526.js +0 -1
- package/dist/ui/ComparePage-726NIJW5.js +0 -1
- package/dist/ui/DataPage-YMSQCIVK.js +0 -1
- package/dist/ui/DataSourcePage-7VPFUG3K.js +0 -1
- package/dist/ui/DocTranslationsPage-FO7O76VK.js +0 -1
- package/dist/ui/DocumentPage-M7SJ4ITQ.js +0 -1
- package/dist/ui/EditDataSourcePage-Y7YK6IWT.js +0 -1
- package/dist/ui/EditReleasePage-XZ4RHHRT.js +0 -1
- package/dist/ui/EmbeddedAIPage-RJOUIPF2.js +0 -1
- package/dist/ui/LogsPage-IGDDZGEI.js +0 -1
- package/dist/ui/NewDataSourcePage-YUPRHL7F.js +0 -1
- package/dist/ui/NewReleasePage-6HHLYOQP.js +0 -1
- package/dist/ui/ReleasePage-V2JMPWX7.js +0 -1
- package/dist/ui/ReleasesPage-SCR4SVKN.js +0 -1
- package/dist/ui/SettingsPage-5XKHPG6K.js +0 -1
- package/dist/ui/TasksPage-DIXUWYXM.js +0 -1
- package/dist/ui/TranslationsArbPage-QPD3ZBT4.js +0 -2
- package/dist/ui/TranslationsEditPage-475Z7UPC.js +0 -1
- package/dist/ui/ai-tools-4DWMFQS6.js +0 -1
- package/dist/ui/chunk-2RAVKX2Z.js +0 -19
- package/dist/ui/chunk-2S5HMST6.js +0 -1
- package/dist/ui/chunk-344GZOGG.js +0 -84
- package/dist/ui/chunk-4ISFTE2G.js +0 -5
- package/dist/ui/chunk-AGFPVTBA.js +0 -1
- package/dist/ui/chunk-D3UIZHRK.js +0 -1
- package/dist/ui/chunk-HO3W4RVG.js +0 -1
- package/dist/ui/chunk-KRNQ6L35.js +0 -1
- package/dist/ui/chunk-N3JSLTMV.js +0 -1
- package/dist/ui/chunk-NWHGT476.js +0 -1
- package/dist/ui/chunk-RHAJNURN.js +0 -1
- package/dist/ui/chunk-SENZVSVZ.js +0 -1
- package/dist/ui/chunk-TOGLZDK3.js +0 -1
- package/dist/ui/chunk-TPJCPCRR.js +0 -1
- package/dist/ui/chunk-XMESZUC5.js +0 -1
- package/dist/ui/chunk-YMBBWVBB.js +0 -3
- /package/dist/ui/{ImageEditorDialog-GGS4VFEA.js.LEGAL.txt → ImageEditorDialog-Q44YTLB5.js.LEGAL.txt} +0 -0
- /package/dist/ui/{chunk-NJMNOITA.js.LEGAL.txt → chunk-5SY2SVEX.js.LEGAL.txt} +0 -0
- /package/dist/ui/{chunk-4ALFT4ES.js.LEGAL.txt → chunk-W2ZAVRAT.js.LEGAL.txt} +0 -0
- /package/dist/ui/{chunk-VD6G5NV4.js.LEGAL.txt → chunk-XOWWPE7X.js.LEGAL.txt} +0 -0
|
@@ -64,6 +64,7 @@ react-is/cjs/react-is.production.min.js:
|
|
|
64
64
|
@tabler/icons-preact/dist/esm/icons/IconClipboard.mjs:
|
|
65
65
|
@tabler/icons-preact/dist/esm/icons/IconClock.mjs:
|
|
66
66
|
@tabler/icons-preact/dist/esm/icons/IconCode.mjs:
|
|
67
|
+
@tabler/icons-preact/dist/esm/icons/IconColumns2.mjs:
|
|
67
68
|
@tabler/icons-preact/dist/esm/icons/IconColumns3.mjs:
|
|
68
69
|
@tabler/icons-preact/dist/esm/icons/IconCopy.mjs:
|
|
69
70
|
@tabler/icons-preact/dist/esm/icons/IconCrop.mjs:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as t}from"./chunk-
|
|
1
|
+
import{a as t}from"./chunk-XM35ZJBQ.js";function s(e){if(typeof e=="object"&&e!==null){let o=e;if(typeof o.code=="string"&&typeof o.message=="string")return`${o.code}: ${o.message}`;if(typeof o.body=="string")return o.body;if(typeof o.message=="string")return o.message}return String(e)}async function i(e){try{await e()}catch(o){console.error(o);let r=s(o);t({title:"Error",message:r,color:"red",autoClose:!1})}}export{s as a,i as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as eo}from"./chunk-YXSXWFLZ.js";import{f as He}from"./chunk-PTPYMVFW.js";import{b as Le,c as $e,e as Ve,j as Se}from"./chunk-2S5HMST6.js";import{a as N,c as H}from"./chunk-HARRKJFZ.js";import{a as _e,b as ge,c as ae}from"./chunk-JDW4UORS.js";import{A as ye,E as ve,F as xe,G as Ce,H as Ie,I as le,J as ke,K as Ae,L as we,M as De,N as Te,O as Re,P as Pe,S as de,T as Ne,U as ze}from"./chunk-AGFPVTBA.js";import{b as be,e as Me}from"./chunk-YMBBWVBB.js";import{a as Je,b as Ke}from"./chunk-W5DOO6ID.js";import{a as Xe}from"./chunk-NSOTG64N.js";import{b as U}from"./chunk-J5E457OI.js";import{a as _,b as F}from"./chunk-QHJOTXYB.js";import{a as M}from"./chunk-BW2MKGNP.js";import{e as he}from"./chunk-KRNQ6L35.js";import{d as fe}from"./chunk-BUNR5EU3.js";import{$ as ue,Da as pe,Ga as e,Ha as Ee,Ka as Ue,La as Be,Na as Oe,Nb as je,Qa as Fe,Rc as Ge,V as J,W as Q,a as c,c as j,cc as Y,da as b,dc as ee,e as ce,ea as ie,ib as qe,ic as Qe,j as X,kc as Ye,lb as K,qa as P,tb as We,ua as me,xa as ne,yc as Ze}from"./chunk-LROR6N3B.js";import{d as S}from"./chunk-KUCVLANF.js";X();var oo="AddToReleaseModal";function so(s){let t=N(),u=H();return{open:()=>{t.openContextModal(oo,{...u,title:"Add docs to a release",innerProps:s,size:"600px"})}}}function mo(s){let{innerProps:t,context:u,id:l}=s,d=N(),[o,y]=c(""),[p,v]=c(!1),[m,k]=c(!1),[g,A]=c([]),[a,D]=c(""),[x,T]=c(Se()),[w,f]=c("");j(()=>{async function n(){v(!0),await U(async()=>{let E=(await $e()).filter(R=>!R.publishedAt&&!R.archivedAt);A(E)}),v(!1)}n()},[]);async function I(){o==="new"?await L():o==="existing"&&await $()}async function L(){if(!x){_({title:"Missing ID",message:"Please enter a release ID.",color:"red",autoClose:5e3});return}if(!_e(x)){_({title:"Invalid ID",message:"Release ID must use alphanumeric characters and dashes only.",color:"red",autoClose:5e3});return}k(!0),await U(async()=>{let n={docIds:t.docIds};w&&(n.description=w),await Le(x,n),_({title:`Release created: ${x}`,message:e("span",{children:["Created release with ",t.docIds.length," doc(s)."," ",e("a",{href:`/cms/releases/${x}`,children:"View release"})]}),autoClose:1e4}),d.closeAll()}),k(!1)}async function $(){if(!a){_({title:"No release selected",message:"Please select a release.",color:"red",autoClose:5e3});return}k(!0),await U(async()=>{let C=g.find(z=>z.id===a)?.docIds||[],E=Array.from(new Set([...C,...t.docIds])).sort();await Ve(a,{docIds:E});let R=E.length-C.length;_({title:`Docs added to release: ${a}`,message:e("span",{children:["Added ",R," new doc(s) to release."," ",e("a",{href:`/cms/releases/${a}`,children:"View release"})]}),autoClose:1e4}),d.closeAll()}),k(!1)}let r=!0;return(o==="new"&&x||o==="existing"&&a)&&(r=!1),e("div",{className:"AddToReleaseModal",children:e("div",{className:"AddToReleaseModal__content",children:[e("div",{className:"AddToReleaseModal__docs",children:[e("div",{className:"AddToReleaseModal__docs__label",children:["Docs to add (",t.docIds.length,")"]}),e("div",{className:"AddToReleaseModal__docs__list",children:t.docIds.map(n=>e(He,{docId:n,variant:"compact",statusBadges:!0},n))})]}),e("div",{className:"AddToReleaseModal__mode",children:[e("label",{className:`AddToReleaseModal__mode__option${o==="new"?" AddToReleaseModal__mode__option--selected":o?" AddToReleaseModal__mode__option--unselected":""}`,children:[e("div",{className:"AddToReleaseModal__mode__option__input",children:[e("input",{type:"radio",name:"release-mode",value:"new",checked:o==="new",onChange:()=>y("new")})," ","New release"]}),e("div",{className:"AddToReleaseModal__mode__option__help",children:"Create a new release with these docs."})]}),e("label",{className:`AddToReleaseModal__mode__option${o==="existing"?" AddToReleaseModal__mode__option--selected":o?" AddToReleaseModal__mode__option--unselected":""}`,children:[e("div",{className:"AddToReleaseModal__mode__option__input",children:[e("input",{type:"radio",name:"release-mode",value:"existing",checked:o==="existing",onChange:()=>y("existing")})," ","Existing release"]}),e("div",{className:"AddToReleaseModal__mode__option__help",children:"Add to an existing release."})]})]}),o==="new"&&e("div",{className:"AddToReleaseModal__form",children:[e("div",{className:"AddToReleaseModal__form__field",children:[e("label",{children:"Release ID"}),e("input",{type:"text",placeholder:"e.g. my-release",value:x,onInput:n=>{T(n.target.value)}})]}),e("div",{className:"AddToReleaseModal__form__field",children:[e("label",{children:"Description (optional)"}),e("textarea",{rows:2,placeholder:"Describe this release",value:w,onInput:n=>{f(n.target.value)}})]})]}),o==="existing"&&e("div",{className:"AddToReleaseModal__releases",children:p?e("div",{className:"AddToReleaseModal__releases__empty",children:e(J,{color:"gray",size:"sm"})}):g.length===0?e("div",{className:"AddToReleaseModal__releases__empty",children:"No unpublished releases found. Create a new one instead."}):g.map(n=>e("div",{className:`AddToReleaseModal__release${a===n.id?" AddToReleaseModal__release--selected":""}`,onClick:()=>D(n.id),children:[e("input",{type:"radio",name:"existing-release",checked:a===n.id,onChange:()=>D(n.id)}),e("div",{className:"AddToReleaseModal__release__info",children:[e("div",{className:"AddToReleaseModal__release__info__id",children:n.id}),n.description&&e("div",{className:"AddToReleaseModal__release__info__description",children:n.description})]}),e("div",{className:"AddToReleaseModal__release__docCount",children:[n.docIds?.length||0," doc(s)"]})]},n.id))}),e("div",{className:"AddToReleaseModal__buttons",children:[e(b,{variant:"outline",onClick:()=>u.closeModal(l),type:"button",size:"xs",color:"dark",children:"Cancel"}),e(b,{variant:"filled",size:"xs",color:"dark",disabled:r,loading:m,onClick:I,children:o==="new"?"Create release":"Add to release"})]})]})})}mo.id=oo;X();var to="CopyDocModal";function oe(s){let t=N(),u=H();return{open:l=>{t.openContextModal(to,{...u,innerProps:{...s,...l}})}}}function po(s){let{innerProps:t,context:u,id:l}=s,{route:d}=fe(),[o,y]=c(""),[p,v]=c(""),[m,k]=c(""),[g,A]=c(""),[a,D]=c(!1),[x,T]=c(!1),[w,f]=c({}),I=t.fromDocId,L=I.split("/")[0],$=t.fromLabel||I;j(()=>{be({tags:[I]}).then(f)},[I]);function r(C,E){let R=ae(C),z=window.__ROOT_CTX.collections[E]?.slugRegex;return R?ge(R,z):""}async function n(C){if(C.preventDefault(),T(!0),A(""),!L){A("Please select a collection."),T(!1);return}if(r(p,o)){T(!1);return}let R=ae(p),z=`${o}/${R}`;try{t.fields?await Pe(z,{fields:t.fields,overwrite:a}):await Re(I,z,{overwrite:a});let O=Object.keys(w);if(O.length>0){let i=O.map(h=>({hash:h,tags:[z]}));await Me(i,{mode:"union"})}u.closeModal(l);let q=`/cms/content/${o}/${R}`;_({title:"Copied!",message:e("div",{children:[e("div",{children:`Successfully copied ${$} to ${z}.`}),e(b,{className:"CopyDocModal__notificationButton",component:"a",href:q,size:"xs",compact:!0,variant:"default",children:"Open doc"})]}),autoClose:1e4}),t.onSuccess&&t.onSuccess(z)}catch(O){let q=String(O);A(q),q.includes("already exists")&&D(!0),T(!1);return}T(!1),d(`/cms/content/${o}/${R}`)}return e("div",{className:"CopyDocModal",children:e("form",{onSubmit:C=>n(C),children:[e("div",{className:"CopyDocModal__from",children:[e(M,{className:"CopyDocModal__from__label",size:"body",weight:"bold",children:"From:"}),e(M,{className:"CopyDocModal__from__value",size:"body-sm",children:e("code",{children:$})})]}),e("div",{className:"CopyDocModal__to",children:[e(M,{className:"CopyDocModal__to__label",size:"body",weight:"bold",children:"To:"}),e(eo,{className:"CopyDocModal__slug",collectionId:L,onChange:C=>{y(C.collectionId),v(C.slug),k(r(C.slug,C.collectionId)),A(""),D(!1)}})]}),g&&e("div",{className:"CopyDocModal__error",children:g}),e("div",{className:"CopyDocModal__buttons",children:[e(b,{variant:"outline",onClick:()=>u.closeModal(l),type:"button",size:"xs",color:"dark",children:"Cancel"}),e(b,{variant:"filled",type:"submit",size:"xs",color:"dark",loading:x,disabled:!!m||!!g&&!a,children:a?"Overwrite?":"Submit"})]})]})})}po.id=to;X();function B(s){return e("div",{className:"DocIdBadge",children:e("code",{"data-testid":"doc-id",children:s.docId})})}var io="LockPublishingModal";function no(s){let t=N(),u=H();return{open:l=>{let d={...s,...l},o;d.unlock?o=`Unlock publishing for ${s.docId}`:d.existingLock?o=`Edit publishing lock for ${s.docId}`:o=`Lock publishing for ${s.docId}`,t.openContextModal(io,{...u,title:o,innerProps:{...s,...l},size:"600px"})}}}function fo(s){let t=l=>l<10?"0"+l:l,u=new Date(s);return`${u.getFullYear()}-${t(u.getMonth()+1)}-${t(u.getDate())}T${t(u.getHours())}:${t(u.getMinutes())}`}function Z(s){let{innerProps:t}=s;return t.unlock?e(Z.Unlock,{...s}):e(Z.Lock,{...s})}Z.Lock=s=>{let{innerProps:t,context:u,id:l}=s,d=!!t.existingLock,[o,y]=c(t.existingLock?.reason||""),[p,v]=c(t.existingLock?.until||0),[m,k]=c(!1),[g,A]=c(!1),a=N();function D(f){return f?Math.floor(new Date(f).getTime()):0}async function x(f){f.preventDefault(),k(!0),await U(async()=>{await Ie(t.docId,{reason:o,until:p}),_({title:d?"Updated!":"Locked!",message:d?`Publishing lock updated for ${t.docId}.`:`Publishing is locked for ${t.docId}.`,autoClose:1e4}),a.closeModal(l),t.onChange&&t.onChange("locked")}),k(!1)}async function T(){A(!0),await U(async()=>{await le(t.docId),_({title:"Unlocked!",message:`Publishing is unlocked for ${t.docId}.`,autoClose:1e4}),a.closeModal(l),t.onChange&&t.onChange("unlocked")}),A(!1)}return e("div",{className:"LockPublishingModal LockPublishingModal--lock",children:[e(M,{className:"LockPublishingModal__body",size:"body-sm",children:d?"Publishing is currently locked. Update the publishing lock details below, or remove the lock to re\u2011enable publishing.":"Are you sure you want to lock publishing? Content editors will not be able to publish until publishing is unlocked."}),e("form",{className:"LockPublishingModal__form",onSubmit:f=>x(f),children:[e("div",{className:"LockPublishingModal__form__section",children:e(me,{name:"reason",label:"Reason",description:"Specify a short reason so other content editors know why publishing is locked.",size:"xs",radius:0,value:o,onChange:f=>{y(f.currentTarget.value)}})}),e("div",{className:"LockPublishingModal__form__section",children:e(ue,{label:"Lock until",description:"Optional. Publishing is unlocked at the specified time. If not provided, publishing will be locked indefinitely.",size:"xs",children:e("div",{className:"DocEditor__DateTimeField",children:[e("input",{name:"until",type:"datetime-local",min:he(),defaultValue:p?fo(p):"",onChange:f=>{let L=f.target.value;v(D(L))}}),e("div",{className:"DocEditor__DateTimeField__timezone",children:["timezone: ",Intl.DateTimeFormat().resolvedOptions().timeZone]})]})})}),e("div",{className:"LockPublishingModal__buttons",children:[d&&e(b,{variant:"filled",size:"xs",color:"red",type:"button",leftIcon:e(Y,{size:14}),loading:g,disabled:m,onClick:()=>T(),className:"LockPublishingModal__buttons__unlock",children:"Unlock"}),e(b,{variant:"outline",onClick:()=>u.closeModal(l),type:"button",size:"xs",color:"dark",children:"Cancel"}),e(b,{variant:"filled",size:"xs",color:"dark",leftIcon:e(ee,{size:14}),disabled:!o||g,type:"submit",loading:m,children:d?"Save":"Lock"})]})]})]})};Z.Unlock=s=>{let{innerProps:t,context:u,id:l}=s,[d,o]=c(!1),y=N();async function p(){o(!0),await U(async()=>{await le(t.docId),_({title:"Unlocked!",message:`Publishing is unlocked for ${t.docId}.`,autoClose:1e4}),y.closeModal(l),t.onChange&&t.onChange("unlocked")})}return e("div",{className:"LockPublishingModal LockPublishingModal--unlock",children:[e(M,{className:"LockPublishingModal__body",children:"Are you sure you want to unlock publishing for the following doc? This will re-enable content editors to publish the doc."}),e(B,{docId:t.docId}),e("div",{className:"LockPublishingModal__buttons",children:[e(b,{variant:"outline",onClick:()=>u.closeModal(l),type:"button",size:"xs",color:"dark",children:"Cancel"}),e(b,{variant:"filled",size:"xs",color:"dark",leftIcon:e(Y,{size:14}),loading:d,onClick:()=>p(),children:"Unlock"})]})]})};Z.id=io;X();var ro="VersionHistoryModal",ao=50;function co(s){let t=N(),u=H();return{open:()=>{t.openContextModal(ro,{...u,title:`Version history: ${s.docId}`,innerProps:s,overflow:"inside",size:"min(calc(100% - 32px), 720px)"})}}}function _o(s){let{innerProps:t,context:u,id:l}=s,d=t.docId,[o,y]=c(!0),[p,v]=c(!1),[m,k]=c([]),[g,A]=c(!1),[a,D]=c([]),[x,T]=c(!1),[w,f]=c(null),I=ce(null),L=oe({fromDocId:d}),$=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});async function r(){y(!0);let[i,h]=await Promise.all([de(d,{limit:ao}),ze(d,"draft")]);I.current=i.lastDoc,A(i.hasMore);let V={_versionId:"draft",sys:{modifiedAt:h?.sys?.modifiedAt||{toDate:()=>new Date},modifiedBy:h?.sys?.modifiedBy||"Unknown"}};k([V,...i.versions]),D(["draft"]),y(!1)}async function n(){if(!g||p)return;v(!0);let i=await de(d,{limit:ao,cursor:I.current});I.current=i.lastDoc,A(i.hasMore),k(h=>[...h,...i.versions]),v(!1)}async function C(i){await Ne(d,i),_({title:"Saved!",message:`Restored ${d} to ${$.format(i.sys.modifiedAt.toDate())}.`,autoClose:5e3}),t.onRestore&&t.onRestore({version:i})}function E(i){let h=`${d}@${i._versionId}`,V=i.sys?.modifiedAt?.toDate();if(V){let W=go(V);h=`${d}@${W}`}L.open({fields:i.fields||{},fromLabel:h,onSuccess:()=>{u.closeModal(l)}})}function R(i){a.includes(i)?D(a.filter(h=>h!==i)):a.length<2&&D([...a,i])}function z(){if(a.length!==2)return"#";let i=m.find(te=>te._versionId===a[0]),h=m.find(te=>te._versionId===a[1]);if(!i||!h)return"#";let V=m.indexOf(i),W=m.indexOf(h),re=V>W?i:h,G=V>W?h:i,se=lo(d,re._versionId),uo=lo(d,G._versionId);return`/cms/compare?left=${se}&right=${uo}`}j(()=>{r()},[]);let O=m.filter(i=>i._versionId==="draft"||!x?!0:i.tags?.includes("published")),q=m.some(i=>i.tags?.includes("published"));return o?e(J,{}):e("div",{className:"VersionHistoryModal",children:[e("div",{className:"VersionHistoryModal__actions",children:[e(b,{component:a.length===2?"a":"button",variant:"filled",size:"xs",disabled:a.length!==2,href:a.length===2?z():void 0,target:a.length===2?"_blank":void 0,rightIcon:e(Fe,{size:16}),children:"Compare"}),q&&e(ie,{size:"xs",label:"Published versions only",checked:x,onChange:i=>T(i.currentTarget.checked)})]}),O.length===0?e(M,{className:"VersionHistoryModal__versionsEmpty",size:"body",children:[e("p",{children:"No versions found."}),e("p",{className:"VersionHistoryModal__versionsEmpty__developer",children:"For developers: Configure the Root CMS cron job to populate versions."})]}):e(S,{children:[e(pe,{className:"VersionHistoryModal__versions",children:[e("thead",{children:e("tr",{children:[e("th",{children:e("span",{className:"VersionHistoryModal__versions__selectLabel",children:"Select"})}),e("th",{children:"modified at"}),e("th",{children:"modified by"}),e("th",{children:"actions"})]})}),e("tbody",{children:O.map(i=>{let h=i._versionId==="draft",V=a.includes(i._versionId),W=!V&&a.length>=2;return e("tr",{children:[e("td",{children:e(ie,{size:"xs",checked:V,disabled:W,onChange:()=>R(i._versionId),className:"VersionHistoryModal__versions__checkbox"})}),e("td",{children:e("div",{className:"VersionHistoryModal__versions__modifiedAt",children:[e(M,{size:"body-sm",className:"VersionHistoryModal__versions__modifiedAt__text",children:h?e("span",{title:"Current Draft",children:[$.format(i.sys.modifiedAt.toDate())," ","(Latest)"]}):e(S,{children:[$.format(i.sys.modifiedAt.toDate()),i.tags?.includes("published")&&e("span",{className:"VersionHistoryModal__publishedLabel",children:"(Published)"})]})}),i.publishMessage&&e(ne,{withCloseButton:!0,opened:w===`${i._versionId}-message`,onClose:()=>f(null),position:"right",withArrow:!0,shadow:"md",width:320,classNames:{body:"VersionHistoryModal__popover__body",arrow:"VersionHistoryModal__popover__arrow",close:"VersionHistoryModal__popover__close"},target:e(Q,{size:"xs",variant:"light",className:"VersionHistoryModal__messageIcon",onClick:()=>f(w===`${i._versionId}-message`?null:`${i._versionId}-message`),children:e(Qe,{size:18})}),children:e("div",{className:"VersionHistoryModal__message",children:i.publishMessage})}),(()=>{let G=i.tags?.find(se=>se.startsWith("release:"))?.replace("release:","");return G&&e(ne,{withCloseButton:!0,opened:w===`${i._versionId}-release`,onClose:()=>f(null),position:"right",withArrow:!0,shadow:"md",width:320,target:e(Q,{size:"xs",variant:"light",className:"VersionHistoryModal__messageIcon",onClick:()=>f(w===`${i._versionId}-release`?null:`${i._versionId}-release`),children:e(Ze,{size:18})}),children:e("div",{className:"VersionHistoryModal__message",children:[e("strong",{children:"Release:"})," ",G]})})})()]})}),e("td",{children:e(M,{size:"body-sm",children:i.sys.modifiedBy})}),e("td",{children:e("div",{className:"VersionHistoryModal__versions__buttons",children:!h&&e(S,{children:[e(b,{variant:"default",size:"xs",compact:!0,onClick:()=>C(i),children:"restore"}),e(b,{variant:"default",size:"xs",compact:!0,onClick:()=>E(i),leftIcon:e(K,{size:12}),children:"copy to doc"})]})})})]},i._versionId)})})]}),g&&e("div",{className:"VersionHistoryModal__loadMore",children:e(b,{variant:"subtle",size:"xs",loading:p,onClick:n,children:"Load more versions"})})]})]})}function lo(s,t){return encodeURIComponent(`${s}@${t}`).replaceAll("%2F","/").replaceAll("%40","@")}function go(s){let t=s.getFullYear(),u=String(s.getMonth()+1).padStart(2,"0"),l=String(s.getDate()).padStart(2,"0"),d=String(s.getHours()).padStart(2,"0"),o=String(s.getMinutes()).padStart(2,"0");return`${t}-${u}-${l}T${d}:${o}`}_o.id=ro;function Js(s){let{roles:t}=Xe(),u=window.firebase.user.email||"",l=Ke(t,u),d=Je(t,u),o=s.docId,y=s.data||{},p=y.sys||{},v=we(y),m=N(),k=oe({fromDocId:o,onSuccess:r=>{s.onAction&&s.onAction({action:"copy",newDocId:r})}}),g=H(),A=co({docId:o}),a=no({docId:o}),D=so({docIds:[o]}),x=()=>{let r=`revert-draft-${o}`,n=m.openConfirmModal({...g,title:`Discard draft edits for ${o}`,children:e(S,{children:[e(M,{size:"body-sm",weight:"semi-bold",className:"DocActionsMenu__confirmText",children:"Are you sure you want to discard draft changes for the following doc? The doc data will revert to the published version. There is no undo."}),e(B,{docId:o})]}),labels:{confirm:"Discard draft edits",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{_({id:r,title:"Discarding draft edits",message:`Discarding draft edits of ${o}...`,loading:!0,autoClose:!1}),await xe(o),F({id:r,title:"Discarded draft edits",message:`Successfully reverted ${o} back to its published version`,loading:!1,autoClose:5e3}),m.closeModal(n),s.onAction&&s.onAction({action:"revert-draft"})}})},T=()=>{let r=`unpublish-doc-${o}`,n=m.openConfirmModal({...g,title:`Unpublish ${o}`,children:e(S,{children:[e(M,{size:"body-sm",weight:"semi-bold",className:"DocActionsMenu__confirmText",children:"Are you sure you want to unpublish the following doc? There is no undo."}),e(B,{docId:o})]}),labels:{confirm:"Unpublish",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{_({id:r,title:"Unpublishing doc",message:`Requesting unpublish of ${o}...`,loading:!0,autoClose:!1}),await ve(o),F({id:r,title:"Unpublished!",message:`Successfully unpublished ${o}!`,loading:!1,autoClose:5e3}),m.closeModal(n),s.onAction&&s.onAction({action:"unpublish"})}})},w=r=>{s.onAction&&s.onAction({action:r})},f=()=>{let r=`unschedule-doc-${o}`,n=m.openConfirmModal({...g,title:`Unschedule ${o}`,children:e(S,{children:[e(M,{size:"body-sm",weight:"semi-bold",className:"DocActionsMenu__confirmText",children:"Are you sure you want to unschedule the following doc?"}),e(B,{docId:o})]}),labels:{confirm:"Unschedule",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{_({id:r,title:"Unschedule doc",message:`Requesting unschedule of ${o}...`,loading:!0,autoClose:!1}),await Ce(o),F({id:r,title:"Unscheduled!",message:`Successfully unscheduled ${o}!`,loading:!1,autoClose:5e3}),m.closeModal(n),s.onAction&&s.onAction({action:"unschedule"})}})},I=()=>{let r=`archive-doc-${o}`,n=m.openConfirmModal({...g,title:`Archive ${o}`,children:e(S,{children:[e(M,{size:"body-sm",weight:"semi-bold",className:"DocActionsMenu__confirmText",children:"Are you sure you want to archive the following doc? Archived docs are hidden from the collection list by default but can be restored later."}),e(B,{docId:o})]}),labels:{confirm:"Archive",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{_({id:r,title:"Archiving doc",message:`Requesting archive of ${o}...`,loading:!0,autoClose:!1}),await ke(o),F({id:r,title:"Archived!",message:`Successfully archived ${o}!`,loading:!1,autoClose:5e3}),m.closeModal(n),s.onAction&&s.onAction({action:"archive"})}})},L=async()=>{let r=`unarchive-doc-${o}`;_({id:r,title:"Unarchiving doc",message:`Requesting unarchive of ${o}...`,loading:!0,autoClose:!1}),await Ae(o),F({id:r,title:"Unarchived!",message:`Successfully unarchived ${o}!`,loading:!1,autoClose:5e3}),s.onAction&&s.onAction({action:"unarchive"})},$=()=>{let r=`delete-doc-${o}`,n=m.openConfirmModal({...g,title:"Delete doc",children:e(S,{children:[e(M,{size:"body-sm",weight:"semi-bold",className:"DocActionsMenu__confirmText",children:"Are you sure you want to delete the following doc? There is no undo."}),e(B,{docId:o})]}),labels:{confirm:"Delete",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{_({id:r,title:"Deleting doc",message:`Requesting deletion of ${o}...`,loading:!0,autoClose:!1}),await ye(o),F({id:r,title:"Deleted!",message:`Successfully deleted ${o}!`,loading:!1,autoClose:5e3}),m.closeModal(n),s.onDelete&&s.onDelete(),s.onAction&&s.onAction({action:"delete"})}})};return e(P,{className:"CollectionPage__collection__docsList__doc__controls__menu",position:"bottom",control:e(Q,{className:"DocEditor__ArrayField__item__header__controls__dots",children:e(We,{size:16})}),children:[!v&&e(P.Item,{icon:e(Ye,{size:20}),onClick:()=>D.open(),disabled:!d,children:"Add to release"}),e(P.Item,{icon:e(je,{size:20}),onClick:()=>A.open(),children:"Version history"}),e(P.Item,{icon:e(K,{size:20}),onClick:()=>k.open(),disabled:!l,children:"Copy"}),!v&&p.modifiedAt&&p.publishedAt&&p.modifiedAt>p.publishedAt&&e(P.Item,{icon:e(Oe,{size:20}),onClick:()=>x(),disabled:!l,children:"Discard draft edits"}),!v&&p.firstPublishedAt&&e(P.Item,{icon:e(qe,{size:20}),onClick:()=>T(),disabled:!d,children:"Unpublish"}),!v&&p.scheduledAt&&e(P.Item,{icon:e(Ee,{size:20}),onClick:()=>f(),disabled:!d,children:"Unschedule"}),!v&&(Te(y)?e(P.Item,{icon:e(Y,{size:20}),onClick:()=>a.open({unlock:!0,onChange:w}),disabled:!l,children:"Unlock publishing"}):e(P.Item,{icon:e(ee,{size:20}),onClick:()=>a.open({unlock:!1,onChange:w}),disabled:!l||De(y),children:"Lock publishing"})),v?e(P.Item,{icon:e(Ue,{size:20}),onClick:()=>L(),disabled:!l,children:"Unarchive"}):!p.publishedAt&&e(P.Item,{icon:e(Be,{size:20}),onClick:()=>I(),disabled:!l,children:"Archive"}),e(P.Item,{icon:e(Ge,{size:20}),onClick:()=>$(),disabled:!l,children:"Delete"})]})}export{so as a,mo as b,po as c,B as d,no as e,Z as f,_o as g,Js as h};
|
|
1
|
+
import{d as eo}from"./chunk-J5KDO4RM.js";import{f as He}from"./chunk-SLLTYDVX.js";import{b as Le,c as $e,e as Ve,j as Se}from"./chunk-CSUKZZK5.js";import{a as _e,b as ge,c as ae}from"./chunk-JDW4UORS.js";import{a as N,c as H}from"./chunk-ELKXEMOU.js";import{a as Je,b as Ke}from"./chunk-W5DOO6ID.js";import{a as Xe}from"./chunk-EIMRPYCD.js";import{b as U}from"./chunk-EYVQCOAD.js";import{a as _,b as F}from"./chunk-XM35ZJBQ.js";import{a as M}from"./chunk-KBJ4AK5O.js";import{A as ye,E as ve,F as xe,G as Ce,H as Ie,I as le,J as ke,K as Ae,L as we,M as De,N as Te,O as Re,P as Pe,S as de,T as Ne,U as ze}from"./chunk-YV5SGR24.js";import{b as be,f as Me}from"./chunk-DZYYWCHX.js";import{C as he}from"./chunk-XOWWPE7X.js";import{d as fe}from"./chunk-WS37MDM3.js";import{$ as ue,Da as pe,Ga as e,Ha as Ee,Ka as Ue,La as Be,Na as Oe,Ob as je,Qa as Fe,Sc as Ge,V as J,W as Q,a as c,c as j,da as b,dc as Y,e as ce,ea as ie,ec as ee,ib as qe,j as X,jc as Qe,lc as Ye,mb as K,qa as P,ua as me,ub as We,xa as ne,zc as Ze}from"./chunk-ETPZ3TXX.js";import{d as S}from"./chunk-KUCVLANF.js";X();var oo="AddToReleaseModal";function so(s){let t=N(),u=H();return{open:()=>{t.openContextModal(oo,{...u,title:"Add docs to a release",innerProps:s,size:"600px"})}}}function mo(s){let{innerProps:t,context:u,id:l}=s,d=N(),[o,y]=c(""),[p,v]=c(!1),[m,k]=c(!1),[g,A]=c([]),[a,D]=c(""),[x,T]=c(Se()),[w,f]=c("");j(()=>{async function n(){v(!0),await U(async()=>{let E=(await $e()).filter(R=>!R.publishedAt&&!R.archivedAt);A(E)}),v(!1)}n()},[]);async function I(){o==="new"?await L():o==="existing"&&await $()}async function L(){if(!x){_({title:"Missing ID",message:"Please enter a release ID.",color:"red",autoClose:5e3});return}if(!_e(x)){_({title:"Invalid ID",message:"Release ID must use alphanumeric characters and dashes only.",color:"red",autoClose:5e3});return}k(!0),await U(async()=>{let n={docIds:t.docIds};w&&(n.description=w),await Le(x,n),_({title:`Release created: ${x}`,message:e("span",{children:["Created release with ",t.docIds.length," doc(s)."," ",e("a",{href:`/cms/releases/${x}`,children:"View release"})]}),autoClose:1e4}),d.closeAll()}),k(!1)}async function $(){if(!a){_({title:"No release selected",message:"Please select a release.",color:"red",autoClose:5e3});return}k(!0),await U(async()=>{let C=g.find(z=>z.id===a)?.docIds||[],E=Array.from(new Set([...C,...t.docIds])).sort();await Ve(a,{docIds:E});let R=E.length-C.length;_({title:`Docs added to release: ${a}`,message:e("span",{children:["Added ",R," new doc(s) to release."," ",e("a",{href:`/cms/releases/${a}`,children:"View release"})]}),autoClose:1e4}),d.closeAll()}),k(!1)}let r=!0;return(o==="new"&&x||o==="existing"&&a)&&(r=!1),e("div",{className:"AddToReleaseModal",children:e("div",{className:"AddToReleaseModal__content",children:[e("div",{className:"AddToReleaseModal__docs",children:[e("div",{className:"AddToReleaseModal__docs__label",children:["Docs to add (",t.docIds.length,")"]}),e("div",{className:"AddToReleaseModal__docs__list",children:t.docIds.map(n=>e(He,{docId:n,variant:"compact",statusBadges:!0},n))})]}),e("div",{className:"AddToReleaseModal__mode",children:[e("label",{className:`AddToReleaseModal__mode__option${o==="new"?" AddToReleaseModal__mode__option--selected":o?" AddToReleaseModal__mode__option--unselected":""}`,children:[e("div",{className:"AddToReleaseModal__mode__option__input",children:[e("input",{type:"radio",name:"release-mode",value:"new",checked:o==="new",onChange:()=>y("new")})," ","New release"]}),e("div",{className:"AddToReleaseModal__mode__option__help",children:"Create a new release with these docs."})]}),e("label",{className:`AddToReleaseModal__mode__option${o==="existing"?" AddToReleaseModal__mode__option--selected":o?" AddToReleaseModal__mode__option--unselected":""}`,children:[e("div",{className:"AddToReleaseModal__mode__option__input",children:[e("input",{type:"radio",name:"release-mode",value:"existing",checked:o==="existing",onChange:()=>y("existing")})," ","Existing release"]}),e("div",{className:"AddToReleaseModal__mode__option__help",children:"Add to an existing release."})]})]}),o==="new"&&e("div",{className:"AddToReleaseModal__form",children:[e("div",{className:"AddToReleaseModal__form__field",children:[e("label",{children:"Release ID"}),e("input",{type:"text",placeholder:"e.g. my-release",value:x,onInput:n=>{T(n.target.value)}})]}),e("div",{className:"AddToReleaseModal__form__field",children:[e("label",{children:"Description (optional)"}),e("textarea",{rows:2,placeholder:"Describe this release",value:w,onInput:n=>{f(n.target.value)}})]})]}),o==="existing"&&e("div",{className:"AddToReleaseModal__releases",children:p?e("div",{className:"AddToReleaseModal__releases__empty",children:e(J,{color:"gray",size:"sm"})}):g.length===0?e("div",{className:"AddToReleaseModal__releases__empty",children:"No unpublished releases found. Create a new one instead."}):g.map(n=>e("div",{className:`AddToReleaseModal__release${a===n.id?" AddToReleaseModal__release--selected":""}`,onClick:()=>D(n.id),children:[e("input",{type:"radio",name:"existing-release",checked:a===n.id,onChange:()=>D(n.id)}),e("div",{className:"AddToReleaseModal__release__info",children:[e("div",{className:"AddToReleaseModal__release__info__id",children:n.id}),n.description&&e("div",{className:"AddToReleaseModal__release__info__description",children:n.description})]}),e("div",{className:"AddToReleaseModal__release__docCount",children:[n.docIds?.length||0," doc(s)"]})]},n.id))}),e("div",{className:"AddToReleaseModal__buttons",children:[e(b,{variant:"outline",onClick:()=>u.closeModal(l),type:"button",size:"xs",color:"dark",children:"Cancel"}),e(b,{variant:"filled",size:"xs",color:"dark",disabled:r,loading:m,onClick:I,children:o==="new"?"Create release":"Add to release"})]})]})})}mo.id=oo;X();var to="CopyDocModal";function oe(s){let t=N(),u=H();return{open:l=>{t.openContextModal(to,{...u,innerProps:{...s,...l}})}}}function po(s){let{innerProps:t,context:u,id:l}=s,{route:d}=fe(),[o,y]=c(""),[p,v]=c(""),[m,k]=c(""),[g,A]=c(""),[a,D]=c(!1),[x,T]=c(!1),[w,f]=c({}),I=t.fromDocId,L=I.split("/")[0],$=t.fromLabel||I;j(()=>{be({tags:[I]}).then(f)},[I]);function r(C,E){let R=ae(C),z=window.__ROOT_CTX.collections[E]?.slugRegex;return R?ge(R,z):""}async function n(C){if(C.preventDefault(),T(!0),A(""),!L){A("Please select a collection."),T(!1);return}if(r(p,o)){T(!1);return}let R=ae(p),z=`${o}/${R}`;try{t.fields?await Pe(z,{fields:t.fields,overwrite:a}):await Re(I,z,{overwrite:a});let O=Object.keys(w);if(O.length>0){let i=O.map(h=>({hash:h,tags:[z]}));await Me(i,{mode:"union"})}u.closeModal(l);let q=`/cms/content/${o}/${R}`;_({title:"Copied!",message:e("div",{children:[e("div",{children:`Successfully copied ${$} to ${z}.`}),e(b,{className:"CopyDocModal__notificationButton",component:"a",href:q,size:"xs",compact:!0,variant:"default",children:"Open doc"})]}),autoClose:1e4}),t.onSuccess&&t.onSuccess(z)}catch(O){let q=String(O);A(q),q.includes("already exists")&&D(!0),T(!1);return}T(!1),d(`/cms/content/${o}/${R}`)}return e("div",{className:"CopyDocModal",children:e("form",{onSubmit:C=>n(C),children:[e("div",{className:"CopyDocModal__from",children:[e(M,{className:"CopyDocModal__from__label",size:"body",weight:"bold",children:"From:"}),e(M,{className:"CopyDocModal__from__value",size:"body-sm",children:e("code",{children:$})})]}),e("div",{className:"CopyDocModal__to",children:[e(M,{className:"CopyDocModal__to__label",size:"body",weight:"bold",children:"To:"}),e(eo,{className:"CopyDocModal__slug",collectionId:L,onChange:C=>{y(C.collectionId),v(C.slug),k(r(C.slug,C.collectionId)),A(""),D(!1)}})]}),g&&e("div",{className:"CopyDocModal__error",children:g}),e("div",{className:"CopyDocModal__buttons",children:[e(b,{variant:"outline",onClick:()=>u.closeModal(l),type:"button",size:"xs",color:"dark",children:"Cancel"}),e(b,{variant:"filled",type:"submit",size:"xs",color:"dark",loading:x,disabled:!!m||!!g&&!a,children:a?"Overwrite?":"Submit"})]})]})})}po.id=to;X();function B(s){return e("div",{className:"DocIdBadge",children:e("code",{"data-testid":"doc-id",children:s.docId})})}var io="LockPublishingModal";function no(s){let t=N(),u=H();return{open:l=>{let d={...s,...l},o;d.unlock?o=`Unlock publishing for ${s.docId}`:d.existingLock?o=`Edit publishing lock for ${s.docId}`:o=`Lock publishing for ${s.docId}`,t.openContextModal(io,{...u,title:o,innerProps:{...s,...l},size:"600px"})}}}function fo(s){let t=l=>l<10?"0"+l:l,u=new Date(s);return`${u.getFullYear()}-${t(u.getMonth()+1)}-${t(u.getDate())}T${t(u.getHours())}:${t(u.getMinutes())}`}function Z(s){let{innerProps:t}=s;return t.unlock?e(Z.Unlock,{...s}):e(Z.Lock,{...s})}Z.Lock=s=>{let{innerProps:t,context:u,id:l}=s,d=!!t.existingLock,[o,y]=c(t.existingLock?.reason||""),[p,v]=c(t.existingLock?.until||0),[m,k]=c(!1),[g,A]=c(!1),a=N();function D(f){return f?Math.floor(new Date(f).getTime()):0}async function x(f){f.preventDefault(),k(!0),await U(async()=>{await Ie(t.docId,{reason:o,until:p}),_({title:d?"Updated!":"Locked!",message:d?`Publishing lock updated for ${t.docId}.`:`Publishing is locked for ${t.docId}.`,autoClose:1e4}),a.closeModal(l),t.onChange&&t.onChange("locked")}),k(!1)}async function T(){A(!0),await U(async()=>{await le(t.docId),_({title:"Unlocked!",message:`Publishing is unlocked for ${t.docId}.`,autoClose:1e4}),a.closeModal(l),t.onChange&&t.onChange("unlocked")}),A(!1)}return e("div",{className:"LockPublishingModal LockPublishingModal--lock",children:[e(M,{className:"LockPublishingModal__body",size:"body-sm",children:d?"Publishing is currently locked. Update the publishing lock details below, or remove the lock to re\u2011enable publishing.":"Are you sure you want to lock publishing? Content editors will not be able to publish until publishing is unlocked."}),e("form",{className:"LockPublishingModal__form",onSubmit:f=>x(f),children:[e("div",{className:"LockPublishingModal__form__section",children:e(me,{name:"reason",label:"Reason",description:"Specify a short reason so other content editors know why publishing is locked.",size:"xs",radius:0,value:o,onChange:f=>{y(f.currentTarget.value)}})}),e("div",{className:"LockPublishingModal__form__section",children:e(ue,{label:"Lock until",description:"Optional. Publishing is unlocked at the specified time. If not provided, publishing will be locked indefinitely.",size:"xs",children:e("div",{className:"DocEditor__DateTimeField",children:[e("input",{name:"until",type:"datetime-local",min:he(),defaultValue:p?fo(p):"",onChange:f=>{let L=f.target.value;v(D(L))}}),e("div",{className:"DocEditor__DateTimeField__timezone",children:["timezone: ",Intl.DateTimeFormat().resolvedOptions().timeZone]})]})})}),e("div",{className:"LockPublishingModal__buttons",children:[d&&e(b,{variant:"filled",size:"xs",color:"red",type:"button",leftIcon:e(Y,{size:14}),loading:g,disabled:m,onClick:()=>T(),className:"LockPublishingModal__buttons__unlock",children:"Unlock"}),e(b,{variant:"outline",onClick:()=>u.closeModal(l),type:"button",size:"xs",color:"dark",children:"Cancel"}),e(b,{variant:"filled",size:"xs",color:"dark",leftIcon:e(ee,{size:14}),disabled:!o||g,type:"submit",loading:m,children:d?"Save":"Lock"})]})]})]})};Z.Unlock=s=>{let{innerProps:t,context:u,id:l}=s,[d,o]=c(!1),y=N();async function p(){o(!0),await U(async()=>{await le(t.docId),_({title:"Unlocked!",message:`Publishing is unlocked for ${t.docId}.`,autoClose:1e4}),y.closeModal(l),t.onChange&&t.onChange("unlocked")})}return e("div",{className:"LockPublishingModal LockPublishingModal--unlock",children:[e(M,{className:"LockPublishingModal__body",children:"Are you sure you want to unlock publishing for the following doc? This will re-enable content editors to publish the doc."}),e(B,{docId:t.docId}),e("div",{className:"LockPublishingModal__buttons",children:[e(b,{variant:"outline",onClick:()=>u.closeModal(l),type:"button",size:"xs",color:"dark",children:"Cancel"}),e(b,{variant:"filled",size:"xs",color:"dark",leftIcon:e(Y,{size:14}),loading:d,onClick:()=>p(),children:"Unlock"})]})]})};Z.id=io;X();var ro="VersionHistoryModal",ao=50;function co(s){let t=N(),u=H();return{open:()=>{t.openContextModal(ro,{...u,title:`Version history: ${s.docId}`,innerProps:s,overflow:"inside",size:"min(calc(100% - 32px), 720px)"})}}}function _o(s){let{innerProps:t,context:u,id:l}=s,d=t.docId,[o,y]=c(!0),[p,v]=c(!1),[m,k]=c([]),[g,A]=c(!1),[a,D]=c([]),[x,T]=c(!1),[w,f]=c(null),I=ce(null),L=oe({fromDocId:d}),$=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});async function r(){y(!0);let[i,h]=await Promise.all([de(d,{limit:ao}),ze(d,"draft")]);I.current=i.lastDoc,A(i.hasMore);let V={_versionId:"draft",sys:{modifiedAt:h?.sys?.modifiedAt||{toDate:()=>new Date},modifiedBy:h?.sys?.modifiedBy||"Unknown"}};k([V,...i.versions]),D(["draft"]),y(!1)}async function n(){if(!g||p)return;v(!0);let i=await de(d,{limit:ao,cursor:I.current});I.current=i.lastDoc,A(i.hasMore),k(h=>[...h,...i.versions]),v(!1)}async function C(i){await Ne(d,i),_({title:"Saved!",message:`Restored ${d} to ${$.format(i.sys.modifiedAt.toDate())}.`,autoClose:5e3}),t.onRestore&&t.onRestore({version:i})}function E(i){let h=`${d}@${i._versionId}`,V=i.sys?.modifiedAt?.toDate();if(V){let W=go(V);h=`${d}@${W}`}L.open({fields:i.fields||{},fromLabel:h,onSuccess:()=>{u.closeModal(l)}})}function R(i){a.includes(i)?D(a.filter(h=>h!==i)):a.length<2&&D([...a,i])}function z(){if(a.length!==2)return"#";let i=m.find(te=>te._versionId===a[0]),h=m.find(te=>te._versionId===a[1]);if(!i||!h)return"#";let V=m.indexOf(i),W=m.indexOf(h),re=V>W?i:h,G=V>W?h:i,se=lo(d,re._versionId),uo=lo(d,G._versionId);return`/cms/compare?left=${se}&right=${uo}`}j(()=>{r()},[]);let O=m.filter(i=>i._versionId==="draft"||!x?!0:i.tags?.includes("published")),q=m.some(i=>i.tags?.includes("published"));return o?e(J,{}):e("div",{className:"VersionHistoryModal",children:[e("div",{className:"VersionHistoryModal__actions",children:[e(b,{component:a.length===2?"a":"button",variant:"filled",size:"xs",disabled:a.length!==2,href:a.length===2?z():void 0,target:a.length===2?"_blank":void 0,rightIcon:e(Fe,{size:16}),children:"Compare"}),q&&e(ie,{size:"xs",label:"Published versions only",checked:x,onChange:i=>T(i.currentTarget.checked)})]}),O.length===0?e(M,{className:"VersionHistoryModal__versionsEmpty",size:"body",children:[e("p",{children:"No versions found."}),e("p",{className:"VersionHistoryModal__versionsEmpty__developer",children:"For developers: Configure the Root CMS cron job to populate versions."})]}):e(S,{children:[e(pe,{className:"VersionHistoryModal__versions",children:[e("thead",{children:e("tr",{children:[e("th",{children:e("span",{className:"VersionHistoryModal__versions__selectLabel",children:"Select"})}),e("th",{children:"modified at"}),e("th",{children:"modified by"}),e("th",{children:"actions"})]})}),e("tbody",{children:O.map(i=>{let h=i._versionId==="draft",V=a.includes(i._versionId),W=!V&&a.length>=2;return e("tr",{children:[e("td",{children:e(ie,{size:"xs",checked:V,disabled:W,onChange:()=>R(i._versionId),className:"VersionHistoryModal__versions__checkbox"})}),e("td",{children:e("div",{className:"VersionHistoryModal__versions__modifiedAt",children:[e(M,{size:"body-sm",className:"VersionHistoryModal__versions__modifiedAt__text",children:h?e("span",{title:"Current Draft",children:[$.format(i.sys.modifiedAt.toDate())," ","(Latest)"]}):e(S,{children:[$.format(i.sys.modifiedAt.toDate()),i.tags?.includes("published")&&e("span",{className:"VersionHistoryModal__publishedLabel",children:"(Published)"})]})}),i.publishMessage&&e(ne,{withCloseButton:!0,opened:w===`${i._versionId}-message`,onClose:()=>f(null),position:"right",withArrow:!0,shadow:"md",width:320,classNames:{body:"VersionHistoryModal__popover__body",arrow:"VersionHistoryModal__popover__arrow",close:"VersionHistoryModal__popover__close"},target:e(Q,{size:"xs",variant:"light",className:"VersionHistoryModal__messageIcon",onClick:()=>f(w===`${i._versionId}-message`?null:`${i._versionId}-message`),children:e(Qe,{size:18})}),children:e("div",{className:"VersionHistoryModal__message",children:i.publishMessage})}),(()=>{let G=i.tags?.find(se=>se.startsWith("release:"))?.replace("release:","");return G&&e(ne,{withCloseButton:!0,opened:w===`${i._versionId}-release`,onClose:()=>f(null),position:"right",withArrow:!0,shadow:"md",width:320,target:e(Q,{size:"xs",variant:"light",className:"VersionHistoryModal__messageIcon",onClick:()=>f(w===`${i._versionId}-release`?null:`${i._versionId}-release`),children:e(Ze,{size:18})}),children:e("div",{className:"VersionHistoryModal__message",children:[e("strong",{children:"Release:"})," ",G]})})})()]})}),e("td",{children:e(M,{size:"body-sm",children:i.sys.modifiedBy})}),e("td",{children:e("div",{className:"VersionHistoryModal__versions__buttons",children:!h&&e(S,{children:[e(b,{variant:"default",size:"xs",compact:!0,onClick:()=>C(i),children:"restore"}),e(b,{variant:"default",size:"xs",compact:!0,onClick:()=>E(i),leftIcon:e(K,{size:12}),children:"copy to doc"})]})})})]},i._versionId)})})]}),g&&e("div",{className:"VersionHistoryModal__loadMore",children:e(b,{variant:"subtle",size:"xs",loading:p,onClick:n,children:"Load more versions"})})]})]})}function lo(s,t){return encodeURIComponent(`${s}@${t}`).replaceAll("%2F","/").replaceAll("%40","@")}function go(s){let t=s.getFullYear(),u=String(s.getMonth()+1).padStart(2,"0"),l=String(s.getDate()).padStart(2,"0"),d=String(s.getHours()).padStart(2,"0"),o=String(s.getMinutes()).padStart(2,"0");return`${t}-${u}-${l}T${d}:${o}`}_o.id=ro;function Js(s){let{roles:t}=Xe(),u=window.firebase.user.email||"",l=Ke(t,u),d=Je(t,u),o=s.docId,y=s.data||{},p=y.sys||{},v=we(y),m=N(),k=oe({fromDocId:o,onSuccess:r=>{s.onAction&&s.onAction({action:"copy",newDocId:r})}}),g=H(),A=co({docId:o}),a=no({docId:o}),D=so({docIds:[o]}),x=()=>{let r=`revert-draft-${o}`,n=m.openConfirmModal({...g,title:`Discard draft edits for ${o}`,children:e(S,{children:[e(M,{size:"body-sm",weight:"semi-bold",className:"DocActionsMenu__confirmText",children:"Are you sure you want to discard draft changes for the following doc? The doc data will revert to the published version. There is no undo."}),e(B,{docId:o})]}),labels:{confirm:"Discard draft edits",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{_({id:r,title:"Discarding draft edits",message:`Discarding draft edits of ${o}...`,loading:!0,autoClose:!1}),await xe(o),F({id:r,title:"Discarded draft edits",message:`Successfully reverted ${o} back to its published version`,loading:!1,autoClose:5e3}),m.closeModal(n),s.onAction&&s.onAction({action:"revert-draft"})}})},T=()=>{let r=`unpublish-doc-${o}`,n=m.openConfirmModal({...g,title:`Unpublish ${o}`,children:e(S,{children:[e(M,{size:"body-sm",weight:"semi-bold",className:"DocActionsMenu__confirmText",children:"Are you sure you want to unpublish the following doc? There is no undo."}),e(B,{docId:o})]}),labels:{confirm:"Unpublish",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{_({id:r,title:"Unpublishing doc",message:`Requesting unpublish of ${o}...`,loading:!0,autoClose:!1}),await ve(o),F({id:r,title:"Unpublished!",message:`Successfully unpublished ${o}!`,loading:!1,autoClose:5e3}),m.closeModal(n),s.onAction&&s.onAction({action:"unpublish"})}})},w=r=>{s.onAction&&s.onAction({action:r})},f=()=>{let r=`unschedule-doc-${o}`,n=m.openConfirmModal({...g,title:`Unschedule ${o}`,children:e(S,{children:[e(M,{size:"body-sm",weight:"semi-bold",className:"DocActionsMenu__confirmText",children:"Are you sure you want to unschedule the following doc?"}),e(B,{docId:o})]}),labels:{confirm:"Unschedule",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{_({id:r,title:"Unschedule doc",message:`Requesting unschedule of ${o}...`,loading:!0,autoClose:!1}),await Ce(o),F({id:r,title:"Unscheduled!",message:`Successfully unscheduled ${o}!`,loading:!1,autoClose:5e3}),m.closeModal(n),s.onAction&&s.onAction({action:"unschedule"})}})},I=()=>{let r=`archive-doc-${o}`,n=m.openConfirmModal({...g,title:`Archive ${o}`,children:e(S,{children:[e(M,{size:"body-sm",weight:"semi-bold",className:"DocActionsMenu__confirmText",children:"Are you sure you want to archive the following doc? Archived docs are hidden from the collection list by default but can be restored later."}),e(B,{docId:o})]}),labels:{confirm:"Archive",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{_({id:r,title:"Archiving doc",message:`Requesting archive of ${o}...`,loading:!0,autoClose:!1}),await ke(o),F({id:r,title:"Archived!",message:`Successfully archived ${o}!`,loading:!1,autoClose:5e3}),m.closeModal(n),s.onAction&&s.onAction({action:"archive"})}})},L=async()=>{let r=`unarchive-doc-${o}`;_({id:r,title:"Unarchiving doc",message:`Requesting unarchive of ${o}...`,loading:!0,autoClose:!1}),await Ae(o),F({id:r,title:"Unarchived!",message:`Successfully unarchived ${o}!`,loading:!1,autoClose:5e3}),s.onAction&&s.onAction({action:"unarchive"})},$=()=>{let r=`delete-doc-${o}`,n=m.openConfirmModal({...g,title:"Delete doc",children:e(S,{children:[e(M,{size:"body-sm",weight:"semi-bold",className:"DocActionsMenu__confirmText",children:"Are you sure you want to delete the following doc? There is no undo."}),e(B,{docId:o})]}),labels:{confirm:"Delete",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{_({id:r,title:"Deleting doc",message:`Requesting deletion of ${o}...`,loading:!0,autoClose:!1}),await ye(o),F({id:r,title:"Deleted!",message:`Successfully deleted ${o}!`,loading:!1,autoClose:5e3}),m.closeModal(n),s.onDelete&&s.onDelete(),s.onAction&&s.onAction({action:"delete"})}})};return e(P,{className:"CollectionPage__collection__docsList__doc__controls__menu",position:"bottom",control:e(Q,{className:"DocEditor__ArrayField__item__header__controls__dots",children:e(We,{size:16})}),children:[!v&&e(P.Item,{icon:e(Ye,{size:20}),onClick:()=>D.open(),disabled:!d,children:"Add to release"}),e(P.Item,{icon:e(je,{size:20}),onClick:()=>A.open(),children:"Version history"}),e(P.Item,{icon:e(K,{size:20}),onClick:()=>k.open(),disabled:!l,children:"Copy"}),!v&&p.modifiedAt&&p.publishedAt&&p.modifiedAt>p.publishedAt&&e(P.Item,{icon:e(Oe,{size:20}),onClick:()=>x(),disabled:!l,children:"Discard draft edits"}),!v&&p.firstPublishedAt&&e(P.Item,{icon:e(qe,{size:20}),onClick:()=>T(),disabled:!d,children:"Unpublish"}),!v&&p.scheduledAt&&e(P.Item,{icon:e(Ee,{size:20}),onClick:()=>f(),disabled:!d,children:"Unschedule"}),!v&&(Te(y)?e(P.Item,{icon:e(Y,{size:20}),onClick:()=>a.open({unlock:!0,onChange:w}),disabled:!l,children:"Unlock publishing"}):e(P.Item,{icon:e(ee,{size:20}),onClick:()=>a.open({unlock:!1,onChange:w}),disabled:!l||De(y),children:"Lock publishing"})),v?e(P.Item,{icon:e(Ue,{size:20}),onClick:()=>L(),disabled:!l,children:"Unarchive"}):!p.publishedAt&&e(P.Item,{icon:e(Be,{size:20}),onClick:()=>I(),disabled:!l,children:"Archive"}),e(P.Item,{icon:e(Ge,{size:20}),onClick:()=>$(),disabled:!l,children:"Delete"})]})}export{so as a,mo as b,po as c,B as d,no as e,Z as f,_o as g,Js as h};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as u}from"./chunk-WS37MDM3.js";import{Ga as m,a as l,c as P,g as p,j as h,wa as f}from"./chunk-ETPZ3TXX.js";h();function $(t,i){let{pageSize:n,resetDeps:o}=i,[s,r]=l(1),e=t.length,a=Math.max(1,Math.ceil(e/n)),g=Math.min(Math.max(s,1),a);P(()=>{r(1)},o??[]);let b=p(()=>{let c=(g-1)*n;return t.slice(c,c+n)},[t,g,n]),d=e===0?0:(g-1)*n+1,x=Math.min(g*n,e);return{page:g,setPage:r,totalPages:a,pageItems:b,totalItems:e,start:d,end:x}}function T(t){return t.total<=1?null:m("div",{className:u(t.className,"Pagination"),children:m(f,{total:t.total,value:t.page,onChange:t.onChange,size:"sm"})})}function z(t){let{start:i,end:n,total:o,noun:s,note:r}=t,e=o===1?s:`${s}s`,a;return o===0?a=`No ${s}s`:i===n?a=`Showing ${i} of ${o} ${e}`:a=`Showing ${i}\u2013${n} of ${o} ${e}`,m("div",{className:u(t.className,"Pagination__summary"),children:[a,r?` (${r})`:""]})}export{$ as a,T as b,z as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as Q}from"./chunk-
|
|
1
|
+
import{d as Q}from"./chunk-WS37MDM3.js";import{a as z,c as d,e as i,h as c,j as h}from"./chunk-ETPZ3TXX.js";h();function R(r,t,n={}){let{query:l,route:g}=Q(),{replace:m=!1,serialize:y=e=>String(e),deserialize:f=e=>e}=n,a=i(t),T=i(y),P=i(f);a.current=t,T.current=y,P.current=f;let o=c(()=>{let e=l[r];return e!==void 0?P.current(e):a.current},[l,r]),[S,p]=z(o);d(()=>{p(o())},[o]);let b=c(e=>{p(e);let s=new URL(window.location.href),u=T.current(e);u===String(a.current)||u===""?s.searchParams.delete(r):s.searchParams.set(r,u);let k=s.pathname+s.search;g(k,m)},[r,m,g]);return[S,b]}function O(r,t=""){return R(r,t)}function w(r,t=[]){return R(r,t,{serialize:n=>Array.isArray(n)?n.join(","):"",deserialize:n=>n?n.split(",").filter(Boolean):t})}export{R as a,O as b,w as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,h as n,j as s}from"./chunk-
|
|
1
|
+
import{a,h as n,j as s}from"./chunk-ETPZ3TXX.js";s();s();function T(e,r){let[c,i]=a(()=>{try{let t=window.localStorage.getItem(e);return t?JSON.parse(t):r}catch(t){return console.error(t),r}}),u=n(t=>{i(l=>{let o=typeof t=="function"?t(l):t;return window.localStorage.setItem(e,JSON.stringify(o)),o})},[e]);return[c,u]}export{T as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as C}from"./chunk-
|
|
1
|
+
import{b as C}from"./chunk-LC6WLVRS.js";import{e as F}from"./chunk-ATTW36EM.js";import{c,e as y,p as w,q as U,s as m}from"./chunk-XOWWPE7X.js";import{Ga as d,a as f,c as g,da as v,h as S,i as p,j as b,xb as k}from"./chunk-ETPZ3TXX.js";import{j as a,k as h}from"./chunk-KUCVLANF.js";h();b();var z=[{name:"Google Drive Folder",key:"googleDriveFolder",placeholder:"https://drive.google.com/drive/folders/...",description:`Where Google Sheets created by Root CMS's localization process are stored. If unspecified, they will be created in your "My Drive".`,ui:e=>d(v,{disabled:!e,variant:"default",size:"xs",compact:!0,rightIcon:d(k,{size:14}),onClick:()=>{e&&window.open(e,F(e))},children:"Open"})}],D=a(null);function X(e){let{db:r,user:s}=C(),o=window.__ROOT_CTX.rootConfig.projectId,[P,u]=f({});g(()=>{let n=c(r,"Projects",o),i=m(n,t=>{if(t.exists()){let l=t.data()||{};u(l.settings||{})}else u({})},t=>{console.error("Failed to subscribe to site settings:",t)});return()=>i()},[r,o,s.uid]);let x=S(async(n,i)=>{let t=c(r,"Projects",o);try{await U(t,new y("settings",n),i)}catch(l){console.error("Failed to set setting",n,l)}},[r,o,s.uid]);return d(D.Provider,{value:{settings:P,setSettings:x},children:e.children})}function B(){let e=p(D);if(!e)throw new Error("useSiteSettings must be used within a <SiteSettingsProvider>");return e}h();b();var I=a(null);function H(e){let{db:r,user:s}=C(),o=window.__ROOT_CTX.rootConfig.projectId,[P,u]=f({});g(()=>{let n=c(r,"Projects",o,"Users",s.uid),i=m(n,t=>{t.exists()?u(t.data()):u({})},t=>{console.error("Failed to subscribe to user preferences:",t)});return()=>i()},[r,o,s.uid]);let x=S(async(n,i)=>{let t=c(r,"Projects",o,"Users",s.uid);try{await w(t,{[n]:i},{merge:!0})}catch(l){console.error("Failed to set user preference",n,l)}},[r,o,s.uid]);return d(I.Provider,{value:{preferences:P,setPreference:x},children:e.children})}function K(){let e=p(I);if(!e)throw new Error("useUserPreferences must be used within a <UserPreferencesProvider>");return e}export{z as a,X as b,B as c,H as d,K as e};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as Z}from"./chunk-
|
|
1
|
+
import{a as Z}from"./chunk-MYKJ6VAM.js";import{a as j}from"./chunk-JDW4UORS.js";import{a as Q,c as X,e as Y}from"./chunk-RN4XVVWD.js";import{c as K}from"./chunk-ATTW36EM.js";import{b as J}from"./chunk-EYVQCOAD.js";import{a as x}from"./chunk-XM35ZJBQ.js";import{d as W}from"./chunk-WS37MDM3.js";import{Ga as e,a as s,c as q,da as A,e as B,ea as P,j as re,na as b,pa as $,ua as F,va as V,za as S}from"./chunk-ETPZ3TXX.js";import{d as M}from"./chunk-KUCVLANF.js";re();var se="Enter the URL to make the HTTP request.",ne="Enter the URL of the Google Sheet, e.g. https://docs.google.com/spreadsheets/d/SPREADSHEET_ID/edit#gid=SHEET_ID";function Ne(a){let{route:n}=W(),c=B(null),i=Z(),[h,d]=s(!1),[r,U]=s(i.enabled?"gsheet":"http"),[g,z]=s("map"),[v,ee]=s("GET"),[y,T]=s(!1),[w,N]=s(1),[E,H]=s("hours"),[R,C]=s(!1),[L,p]=s(""),[te,O]=s(!!a.dataSourceId),[_,G]=s(null),I="";r==="http"?I=se:r==="gsheet"&&(I=ne);async function ae(t){await J(async()=>{let o=await X(t);G(o),U(o?.type||"http"),z(o?.dataFormat||"map"),o?.cron?(T(o.cron.enabled||!1),N(o.cron.interval||1),H(o.cron.unit||"hours"),C(o.cron.autoPublish||!1)):(T(!1),N(1),H("hours"),C(!1))}),O(!1)}q(()=>{a.dataSourceId&&(O(!0),ae(a.dataSourceId))},[a.dataSourceId]);async function oe(){p("");let t=c.current;function o(l){let f=t.elements[l];return f?f.value.trim():""}let m=a.dataSourceId||o("id");if(!m){p("missing id");return}if(!j(m)){p("id is invalid (alphanumeric characters and dashes only)");return}let D=o("url");if(!D){p("missing url");return}let u={id:m,description:o("description"),type:r,url:D,previewUrl:o("previewUrl")};if(r==="http"){if(!ie(D)){p("invalid url");return}u.httpOptions={method:v};let l=o("httpHeaders");if(l&&(u.httpOptions.headers=ue(l)),v==="POST"){let f=o("httpBody");f&&(u.httpOptions.body=f)}}else if(r==="gsheet"){if(!K(D)?.spreadsheetId){p("failed to parse spreadsheet url");return}u.dataFormat=g||"map"}y?u.cron={enabled:!0,interval:w,unit:E,autoPublish:R}:u.cron={enabled:!1,interval:w,unit:E};try{G(u),d(!0),a.dataSourceId?(await Y(a.dataSourceId,u),x({title:"Saved data source",message:`Successfully updated ${m}`,autoClose:5e3}),d(!1)):(await Q(m,u),x({title:"Added data source",message:`Successfully added ${m}`,autoClose:5e3}),d(!1),n(`/cms/data/${m}`))}catch(l){console.error(l),x({title:"Failed to save data source",message:String(l),color:"red",autoClose:!1}),d(!1)}}let k=[{value:"http",label:"HTTP"}];return(i.enabled||r==="gsheet")&&k.push({value:"gsheet",label:"Google Sheet"}),e("form",{className:"DataSourceForm",ref:c,onSubmit:t=>{t.preventDefault(),oe()},children:[e($,{visible:te}),e("div",{className:"DataSourceForm__input",children:e(S,{name:"type",label:"Type",data:k,value:r,onChange:t=>U(t),size:"xs",radius:0,dropdownComponent:"div"})}),e(F,{className:"DataSourceForm__input",name:"id",label:"ID",description:"Unique identifier for the data source. Use alphanumeric characters and dashes only, e.g. grogus-favorite-meals",size:"xs",radius:0,value:a.dataSourceId,disabled:!!a.dataSourceId}),e(b,{className:"DataSourceForm__input",name:"description",label:"Description",description:"Optional.",size:"xs",radius:0,value:_?.description}),e(F,{className:"DataSourceForm__input",name:"url",label:"URL",description:I,size:"xs",radius:0,value:_?.url}),r==="http"&&e(M,{children:[e("div",{className:"DataSourceForm__input",children:e(S,{name:"httpMethod",label:"HTTP Request Method",data:[{value:"GET",label:"GET"},{value:"POST",label:"POST"}],value:v,onChange:t=>ee(t),size:"xs",radius:0,dropdownComponent:"div"})}),e(b,{className:"DataSourceForm__input",name:"httpHeaders",label:"HTTP Request Headers",description:"Format as `HeaderName: Value`, each value on its own line.",size:"xs",radius:0,value:ce(_?.httpOptions?.headers||{})}),v==="POST"&&e(b,{className:"DataSourceForm__input",name:"httpRequestBody",label:"HTTP Request Body",size:"xs",radius:0,value:_?.httpOptions?.body})]}),r==="gsheet"&&e("div",{className:"DataSourceForm__input",children:[e(S,{name:"dataFormat",label:"Data Format",data:[{value:"map",label:"map"}],value:g,onChange:t=>z(t),size:"xs",radius:0,dropdownComponent:"div"}),g==="array"&&e("div",{className:"DataSourceForm__input__example",children:["Data is stored as an array of arrays, e.g.",e("code",{children:"[[header1, header2], [foo, bar]]"})]}),g==="map"&&e("div",{className:"DataSourceForm__input__example",children:["Data is stored as an array of maps, e.g.",e("code",{children:["[","{","header1: foo, header2: bar","}","]"]})]})]}),e("div",{className:"DataSourceForm__section",children:[e("div",{className:"DataSourceForm__section__label",children:"Sync Schedule"}),e(P,{className:"DataSourceForm__input",label:"Enable scheduled sync",checked:y,onChange:t=>T(t.currentTarget.checked),size:"xs"}),y&&e("div",{className:"DataSourceForm__cron",children:[e("div",{className:"DataSourceForm__cron__row",children:[e("span",{children:"Run every"}),e(V,{className:"DataSourceForm__cron__interval",value:w,onChange:t=>N(Number(t)||1),min:1,size:"xs",radius:0}),e(S,{className:"DataSourceForm__cron__unit",data:[{value:"minutes",label:"minutes"},{value:"hours",label:"hours"},{value:"days",label:"days"}],value:E,onChange:t=>H(t),size:"xs",radius:0,dropdownComponent:"div"})]}),e(P,{className:"DataSourceForm__input",label:"Auto-publish after sync",checked:R,onChange:t=>C(t.currentTarget.checked),size:"xs"})]})]}),e(F,{className:"DataSourceForm__input",name:"previewUrl",label:"Preview URL",description:"URL where users can preview the data source.",size:"xs",radius:0,value:_?.previewUrl}),e(A,{className:"DataSourceForm__submit",color:"blue",size:"xs",type:"submit",loading:h,children:a.buttonLabel||"Save"}),L&&e("div",{className:"DataSourceForm__error",children:["Error: ",L]})]})}function ie(a){let n,c=a.startsWith("/")?"http://localhost":void 0;try{n=new URL(a,c)}catch(i){return console.error(i),!1}return n.protocol==="http:"||n.protocol==="https:"}function ue(a){let n={};return a.split(`
|
|
2
2
|
`).forEach(i=>{let h=i.indexOf(":");if(h===-1)return;let d=i.slice(0,h).trim(),r=i.slice(h+1).trim();d&&r&&(n[d]=r)}),n}function ce(a){let n=[];for(let c in a){let i=a[c];n.push(`${c}: ${i}`)}return n.join(`
|
|
3
3
|
`)}export{Ne as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as le}from"./chunk-
|
|
1
|
+
import{b as le}from"./chunk-LC6WLVRS.js";import{a as oe}from"./chunk-CSUKZZK5.js";import{a as ee,b as R,c as T}from"./chunk-JDW4UORS.js";import{a as ie}from"./chunk-YDO2EDVY.js";import{a as M}from"./chunk-5MV6XVGA.js";import{b as te}from"./chunk-EYVQCOAD.js";import{a as $}from"./chunk-XM35ZJBQ.js";import{a as j}from"./chunk-KBJ4AK5O.js";import{P as re,c as ne}from"./chunk-YV5SGR24.js";import{b as K,f as U,g as _,i as y,o as Y}from"./chunk-XOWWPE7X.js";import{d as Z,e as se}from"./chunk-WS37MDM3.js";import{A as G,Ga as f,a as p,c as w,da as P,e as v,g as B,h as I,i as W,j as O,ra as Q,ua as q,za as J}from"./chunk-ETPZ3TXX.js";import{j as X,k as Se}from"./chunk-KUCVLANF.js";function z(e){let t=window.__ROOT_CTX.collections[e.collectionId];if(!t)throw new Error(`collection not found: ${e.collectionId}`);if(!t.url)return"";let n=t.domain||window.__ROOT_CTX.rootConfig.domain||"https://example.com",r=Ee(e);return`${n}${r}`}function Ee(e){let o=window.__ROOT_CTX.collections,{collectionId:t,slug:n,locale:r}=e,s=o[t];if(!s)throw new Error(`collection not found: ${t}`);if(!s.url)return"";let l=window.__ROOT_CTX.rootConfig,g=l.base||"/",u="/[base]/[path]";r&&(u=l.i18n.urlFormat||"/[locale]/[base]/[path]");let d="",a=s?.url;if(a)if(n){let c=a.replace(/\[.*slug\]/,n).replaceAll("--","/").replace(/\/+/g,"/");c==="/index"&&(c="/"),d=c}else d=a;return ce(u,{base:g,path:d,locale:r||"",slug:n})}function ye(e){let o=window.__ROOT_CTX.collections,{collectionId:t,slug:n,locale:r}=e,s=o[t];if(!s)throw new Error(`collection not found: ${t}`);let l=window.__ROOT_CTX.rootConfig,g=l.base||"/",u="/[base]/[path]";r&&(u=l.i18n.urlFormat||"/[locale]/[base]/[path]");let d="",a=s?.previewUrl||s?.url;if(a)if(n){let c=a.replace(/\[.*slug\]/,n).replaceAll("--","/").replace(/\/+/g,"/");c==="/index"&&(c="/"),d=c}else d=a;return ce(u,{base:g,path:d,locale:r||"",slug:n})}function ce(e,o){let t=e.replaceAll(/\[\[?(\.\.\.)?([\w\-_]*)\]?\]/g,(n,r,s)=>o[s]??n);return Ce(t,{trailingSlash:window.__ROOT_CTX.rootConfig.server.trailingSlash})}function Ce(e,o){return e=e.replace(/\/+/g,"/"),o?.trailingSlash===!1&&e!=="/"&&e.endsWith("/")&&(e=e.replace(/\/*$/g,"")),(e.endsWith("/index")||e.endsWith("/index/"))&&(e=e.slice(0,-6)),e.startsWith("/")||(e=`/${e}`),o?.trailingSlash&&!e.endsWith("/")&&(e=`${e}/`),e}O();function Re(e,o){let[t,n]=p([]),[r,s]=p(!0),g=le().db,u=window.__ROOT_CTX.rootConfig.projectId||"default",d=o.includeArchived??!1,a=async()=>{s(!0);let c=K(g,"Projects",u,"Collections",e,"Drafts"),i=c,m=o.orderBy;if(m==="modifiedAt")i=_(c,y("sys.modifiedAt","desc"));else if(m==="newest")i=_(c,y("sys.createdAt","desc"));else if(m==="oldest")i=_(c,y("sys.createdAt"));else if(m==="slug")i=_(c,y(U()));else if(m==="slugDesc")i=_(c,y(U(),"desc"));else{let S=window.__ROOT_CTX.collections[e]?.sortOptions?.find(C=>C.id===m);S&&(i=S.direction==="desc"?_(c,y(S.field,"desc")):_(c,y(S.field)))}await te(async()=>{let h=await Y(i),S=[];h.docs.forEach(C=>{let k=C.data(),E=C.id,b=`${e}/${E}`,x={...k,id:b,slug:E};ne(b,x),!(!d&&x?.sys?.archivedAt)&&S.push(x)}),n(S)}),s(!1)};return w(()=>{s(!0),a()},[e,o.orderBy,d]),[r,a,t]}Se();O();var D={CONNECTED:"connected",SCHEMA_CHANGED:"schemaChanged"};function ae(e){let t=new URLSearchParams(window.location.search).get("e");return t?t.split(",").includes(e):!1}var ve="/cms/api/sse.connect",L=ae("EnableVerboseLogging"),ue=window.location.hostname==="localhost",F=class{constructor(){this.map=new Map}on(o,t){return this.map.has(o)||this.map.set(o,new Set),this.map.get(o).add(t),()=>{this.map.get(o)?.delete(t)}}emit(o,t,n){this.map.get(o)?.forEach(r=>r(t,n)),this.map.get("*")?.forEach(r=>r({type:o,data:t},n))}},fe=X(null);function Fe(e){let t=v(new F).current,n=v(null),r=v(!1),s=v({attempt:0,timer:0}),l=v(""),g=()=>{n.current&&(n.current.close(),n.current=null)},u=I(()=>{L&&console.log("[sse] connecting..."),g();let a=new EventSource(ve);n.current=a,a.addEventListener(D.CONNECTED,i=>{if(L&&console.log("[sse] connected"),r.current=!1,s.current.attempt=0,ue){let h=de(i.data)?.serverVersion||"";l.current?l.current!==h&&(console.log(`server version changed: ${l.current} -> ${h}`),console.log("reloading..."),window.location.reload()):l.current=h}});let c=i=>{if(!i||!i.type)return;let m=de(i.data);L&&console.log("[sse] event:",i.type,m),t.emit(i.type,m,i)};Object.values(D).forEach(i=>{a.addEventListener(i,c)}),a.addEventListener("error",()=>{L&&console.log("[sse] disconnected"),a.readyState===EventSource.CLOSED&&!r.current&&(r.current=!0,(()=>{let m=++s.current.attempt,h=Math.min(3e4,Math.pow(2,m)*500),S=Math.random()*.3*h,C=h+S;window.clearTimeout(s.current.timer),s.current.timer=window.setTimeout(()=>{r.current=!1,u()},C)})())})},[t]);w(()=>{if(!ue)return;u();let a=()=>{document.visibilityState==="visible"&&n.current?.readyState!==EventSource.OPEN&&u()};return document.addEventListener("visibilitychange",a),()=>{document.removeEventListener("visibilitychange",a),window.clearTimeout(s.current.timer),g()}},[u]);let d=B(()=>({emitter:t}),[t]);return f(fe.Provider,{value:d,children:e.children})}function de(e){try{return JSON.parse(e)}catch{return e}}function ge(e,o){let t=W(fe);if(!t)throw new Error("useSSE() must be used within an <SSEProvider>");let n=v(o);w(()=>{n.current=o},[o]),w(()=>t.emitter.on(e,(r,s)=>n.current(r,s)),[t,e])}O();O();function me(e){let[o,t]=p(!0),[n,r]=p(null),s=I(async()=>{try{let l=await ie(e);r(l)}catch(l){console.error(l),$({title:`Failed to load collection: ${e}`,message:String(l),color:"red",autoClose:!1})}t(!1)},[e]);return w(()=>{s()},[e]),ge(D.SCHEMA_CHANGED,async l=>{await s();let g=l.file?`Applied updates from changes to ${l.file}.`:"Applied updates from changes to a .schema.ts file.";$({title:"Updated schema!",message:g})}),{loading:o,schema:n}}function H(e){let o={_array:[]};return e.forEach(t=>{let n=we();o._array.push(n),o[n]=t}),o}function we(){let e=[],o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=o.length;for(let n=0;n<6;n++)e.push(o.charAt(Math.floor(Math.random()*t)));return e.join("")}function V(e){let o={};return e.fields.forEach(t=>{t.id&&(t.type==="array"&&t.default&&Array.isArray(t.default)?o[t.id]=H(t.default):t.default?o[t.id]=t.default:t.type==="object"&&(o[t.id]=V(t)))}),o}function A(e,o,t){let n={...o};return e.fields.forEach(r=>{if(!r.id)return;let s=n[r.id];if(s!=null){if(r.type==="array"&&Array.isArray(s)){let l=s.map(g=>_e(r.of,g,t));n[r.id]=H(l)}else if(r.type==="object"&&M(s))n[r.id]=A(r,s,t);else if(r.type==="oneof"&&M(s)&&typeof s._type=="string"&&t){let l=t[s._type];l&&(n[r.id]=A(l,s,t))}}}),n}function _e(e,o,t){if(!M(o))return o;if(e.type==="object")return A(e,o,t);if(e.type==="oneof"&&typeof o._type=="string"&&t){let n=t[o._type];if(n)return A(n,o,t)}return o}O();function pe(e){let[o,t]=p(e.collectionId||""),n=v(null),[r,s]=p(e.initialSlug||""),l=window.__ROOT_CTX.collections[o],g=[];e.collectionId&&e.collectionDisabled?g.push({value:e.collectionId,label:e.collectionId}):Object.keys(window.__ROOT_CTX.collections).forEach(i=>{g.push({value:i,label:i})});let u="",d="";if(l?.url){if(r){let i=T(r),m=l?.slugRegex;ee(i,m)?u=z({collectionId:o,slug:i}):d=R(i,m)}else u=z({collectionId:o,slug:"[slug]"});u.endsWith("/index")&&(u=u.replace(/\/index$/,"/"))}function a(i){t(i),e.onChange&&e.onChange({collectionId:i,slug:r})}function c(i){s(i),e.onChange&&e.onChange({collectionId:o,slug:i})}return f("div",{className:se(e.className,"SlugInput"),children:[f("div",{className:"SlugInput__inputs",children:[f(J,{className:"SlugInput__collection",placeholder:"Collection",size:"xs",data:g,onChange:i=>a(i),value:o,disabled:!!e.collectionDisabled}),f("div",{className:"SlugInput__divider",children:"/"}),f(q,{className:"SlugInput__slug",name:"slug",ref:n,value:r,onChange:i=>{c(i.currentTarget.value)},placeholder:"slug",autoComplete:"off",size:"xs"})]}),u&&f(j,{className:"SlugInput__urlHelp",size:"body-sm",children:u}),d&&f(j,{className:"SlugInput__slugError",size:"body-sm",children:d})]})}function bt(e){let{route:o}=Z(),t=G(),n=e.collection,r=window.__ROOT_CTX.collections[n];if(!r)throw new Error(`collection not found: ${n}`);let[s]=p(()=>r.autoSlug?oe(r.autoSlug):""),[l,g]=p(s),[u,d]=p(!1),[a,c]=p(()=>S(s)),[i,m]=p(""),h=me(n);function S(E){let b=T(E);return b?R(b,r.slugRegex):""}function C(){e.onClose&&e.onClose()}async function k(E){if(E.preventDefault(),d(!0),c(""),S(l)){d(!1);return}let x=T(l),he=`${n}/${x}`;try{let N={};!h.loading&&h.schema&&(N=await V(h.schema)),await re(he,{fields:N})}catch(N){m(String(N)),d(!1);return}d(!1),e.skipNavigation?C():o(`/cms/content/${e.collection}/${x}`)}return f(Q,{className:"NewDocModal",opened:e.opened||!1,onClose:()=>C(),title:"New",size:"500px",overlayColor:t.colorScheme==="dark"?t.colors.dark[9]:t.colors.gray[2],children:[f("div",{className:"NewDocModal__body",children:"Enter a slug for the new doc. The slug is the ID of the page and is what's used in the URL. Use only lowercase letters, numbers, and dashes."}),f("form",{onSubmit:E=>k(E),children:[f(pe,{className:"NewDocModal__slug",collectionId:n,initialSlug:s,onChange:E=>{g(E.slug),c(S(E.slug)),m("")}}),i&&f("div",{className:"NewDocModal__slugError",children:i}),f("div",{className:"NewDocModal__buttons",children:[f(P,{variant:"outline",onClick:()=>C(),type:"button",size:"xs",color:"dark",children:"Cancel"}),f(P,{variant:"filled",type:"submit",size:"xs",color:"dark",loading:h.loading||u,disabled:!!a||!!i,children:"Submit"})]})]})]})}export{z as a,Ee as b,ye as c,pe as d,Re as e,Fe as f,me as g,V as h,A as i,bt as j};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as P}from"./chunk-MYKJ6VAM.js";import{a as $}from"./chunk-6P75AZ3B.js";import{h as w,i as A}from"./chunk-RN4XVVWD.js";import{a as C}from"./chunk-W5DOO6ID.js";import{a as B}from"./chunk-EIMRPYCD.js";import{a as v,b as S}from"./chunk-XM35ZJBQ.js";import{a as D,z as l}from"./chunk-XOWWPE7X.js";import{Fa as c,Ga as o,a as e,c as y,da as T,j as g}from"./chunk-ETPZ3TXX.js";g();g();function x(t){let i=k(t.timestamp),[s,a]=e(i>0?l(i,{style:"short"}):"never");return i?(y(()=>{let u=window.setInterval(()=>{a(l(i,{style:"short"}))},6e4);return()=>window.clearInterval(u)},[]),o(c,{transition:"pop",label:`${U(i)} by ${t.email}`,children:l(i,{style:"short"})})):o("div",{children:s})}function U(t){return new Date(t).toLocaleDateString("en",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function k(t){return typeof t=="number"?t:t?.toMillis?t.toMillis():0}function et(t){let i=t.dataSource,[s,a]=e(!1),[u,N]=e(t.action==="sync"?i.syncedAt:i.publishedAt),[I,L]=e(t.action==="sync"?i.syncedBy:i.publishedBy),b=P(),{roles:_}=B(),E=window.firebase.user.email||"",m=C(_,E),d=t.action==="publish",r=!!i.archivedAt;async function M(){a(!0);let p=`data-source-${t.action}-${i.id}`;v({id:p,loading:!0,title:`Running Data Source ${t.action}`,message:`Updating ${i.id}...`,autoClose:!1,disallowClose:!0});try{t.action==="sync"?(i.type==="gsheet"&&!b.isLoggedIn()&&await b.login(),await w(i.id)):t.action==="publish"&&await A(i.id),N(D.now()),L(window.firebase.user.email),a(!1),t.onAction&&t.onAction(),S({id:p,title:"Success",message:`Updated Data Source ${i.id}`,autoClose:!1})}catch(n){console.error(n);let h=n;typeof n=="object"&&n.body&&(h=String(n.body)),a(!1),S({id:p,title:`Data Source ${t.action} failed`,message:String(h),color:"red",autoClose:!1})}}let f="";return t.action==="sync"?f="Sync data to a draft state":t.action==="publish"&&(f="Publish synced data to prod"),o("div",{className:"DataSourceStatusButton",children:[o("div",{className:"DataSourceStatusButton__label",children:!s&&o(x,{timestamp:u,email:I})}),o("div",{className:"DataSourceStatusButton__button",children:o($,{label:r?"Data source is archived":"You don't have access to publish this data source",condition:r||d&&!m,children:o(c,{transition:"pop",label:f,disabled:r||d&&!m,children:o(T,{variant:"default",size:"xs",compact:!0,onClick:()=>M(),loading:s,disabled:r||d&&!m,children:t.action})})})})]})}export{et as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as n}from"./chunk-
|
|
1
|
+
import{e as n}from"./chunk-WS37MDM3.js";import{Ga as t}from"./chunk-ETPZ3TXX.js";function f(a){let{className:r,as:h,size:e,weight:o,color:i,children:g,...s}=a;return t(h||"h2",{...s,className:n(r,"heading",e&&`size:${e}`,o&&`weight:${o}`,i&&`color:${i}`),children:g})}export{f as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as r}from"./chunk-
|
|
1
|
+
import{e as r}from"./chunk-WS37MDM3.js";import{Ga as i}from"./chunk-ETPZ3TXX.js";function f(n){let{className:a,as:l,size:t,weight:e,color:o,children:s,...x}=n;return i(l||"div",{...x,className:r(a,"text",t&&`size:${t}`,e&&`weight:${e}`,o&&`color:${o}`),children:s})}export{f as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as C}from"./chunk-
|
|
1
|
+
import{a as C}from"./chunk-H3PYPGNR.js";import{e as p}from"./chunk-WS37MDM3.js";import{Ga as o,Gb as u,U as _,g,j as b}from"./chunk-ETPZ3TXX.js";b();function m(s){let e={},t=[],r={};if(Object.entries(s).forEach(([n,i])=>{e[n]={id:n,name:i.name||n,description:i.description,isGroup:!1,collection:i,children:[]}}),Object.entries(s).forEach(([n,i])=>{let c=e[n],d=i.group||"Content";d?(r[d]||(r[d]={id:`group:${d}`,name:d,isGroup:!0,children:[]}),r[d].children.push(c)):t.push(c)}),Object.keys(r).length>0&&t.length>0){let n={id:"group:Content",name:"Content",isGroup:!0,children:t},i=Object.values(r).sort((c,d)=>c.name.localeCompare(d.name));return[n,...i]}Object.values(r).forEach(n=>{t.push(n)});let l=n=>{n.sort((i,c)=>i.name.localeCompare(c.name)),n.forEach(i=>{i.children.length>0&&l(i.children)})};return l(t),t}function O(s){let{collections:e,activeCollectionId:t,projectId:r}=s,[a,l]=C(`root-cms::${r}::closed_groups`,[]),n=g(()=>m(e),[]),i=(c,d)=>{d?l(a.filter(v=>v!==c)):a.includes(c)||l([...a,c])};return o("div",{className:p(s.className,"CollectionTree"),children:[n.map(c=>o(h,{node:c,depth:0,activeCollectionId:t,closedGroups:a,onAccordionChange:i},c.id)),n.length===0&&o("div",{className:"CollectionTree__collections__empty",children:"No collections match your query."})]})}function h(s){let{node:e,depth:t,activeCollectionId:r,closedGroups:a,onAccordionChange:l}=s,n=e.children.length>0;return e.isGroup?n?o(f,{node:e,depth:t,activeCollectionId:r,closedGroups:a,onAccordionChange:l,label:o("div",{className:"CollectionTree__group__label",children:o("span",{children:e.name})})}):o("div",{className:"CollectionTree__group-empty",style:{paddingLeft:`${t*16}px`},children:[o(u,{size:20,strokeWidth:"1.75"}),o("span",{children:e.name})]}):n?o(f,{node:e,depth:t,activeCollectionId:r,closedGroups:a,onAccordionChange:l,label:o("div",{className:"CollectionTree__collection__label",children:o("a",{className:p("CollectionTree__collection-link",e.id===r&&"active"),href:`/cms/content/${e.id}`,onClick:i=>i.stopPropagation(),children:e.name})})}):o("a",{className:p("CollectionTree__collection",e.id===r&&"active"),href:`/cms/content/${e.id}`,children:[o("div",{className:"CollectionTree__collection__icon",children:o(u,{size:20,strokeWidth:"1.75"})}),o("div",{className:"CollectionTree__collection__content",children:[o("div",{className:"CollectionTree__collection__name",children:e.name}),e.description&&o("div",{className:"CollectionTree__collection__desc",children:e.description})]})]})}function f(s){let{node:e,depth:t,label:r,activeCollectionId:a,closedGroups:l,onAccordionChange:n}=s,i=!l.includes(e.id);return o("div",{className:"CollectionTree__accordion",children:o(_,{iconPosition:"left",initialItem:i?0:-1,offsetIcon:!1,onChange:()=>n(e.id,!i),children:o(_.Item,{label:r,children:o("div",{className:"CollectionTree__accordion__children",children:e.children.map(c=>o(h,{node:c,depth:t+1,activeCollectionId:a,closedGroups:l,onAccordionChange:n},c.id))})})})})}export{O as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as t,j as i}from"./chunk-
|
|
1
|
+
import{i as t,j as i}from"./chunk-ETPZ3TXX.js";import{j as r,k as o}from"./chunk-KUCVLANF.js";o();i();var s=r(null);function n(){let e=t(s);if(!e)throw new Error("useFirebase() should be called within a <FirebaseProvider>");return e}export{s as a,n as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as b,c as w}from"./chunk-
|
|
1
|
+
import{a as b,c as w}from"./chunk-ELKXEMOU.js";import{a as p}from"./chunk-XM35ZJBQ.js";import{a}from"./chunk-KBJ4AK5O.js";import{b as z,f as I,g as C}from"./chunk-DZYYWCHX.js";import{Cc as N,Ga as n,V as v,a as c,c as y,da as m,j as L}from"./chunk-ETPZ3TXX.js";import{d as M}from"./chunk-KUCVLANF.js";L();var S="PruneTranslationsModal";function W(){let u=b(),o=w();return{open:r=>{u.openContextModal(S,{...o,title:`Prune unused strings from ${r.docId}`,innerProps:r,size:600})}}}function $(u){let{innerProps:o,context:r,id:f}=u,[l,h]=c(!0),[e,k]=c([]),[E,x]=c(!1);y(()=>{let s=!1;async function d(){let t=o.docId,g=await z({tags:[t]}),H=new Set(await Promise.all(o.sourceStrings.map(i=>C(i)))),T=[];for(let[i,P]of Object.entries(g))if(!H.has(i)){let _=P.tags||[];_.includes(t)&&T.push({hash:i,source:P.source||i,tags:_.filter(B=>B!==t)})}s||(k(T),h(!1))}return d().catch(t=>{console.error(t),s||h(!1)}),()=>{s=!0}},[o.docId,o.sourceStrings]);async function U(){if(e.length!==0){x(!0);try{let s=e.map(({hash:t,tags:g})=>({hash:t,tags:g}));await I(s,{mode:"replace"});let d=e.map(t=>t.hash);p({title:"Pruned translations",message:`Removed "${o.docId}" tag from ${d.length} unused translation(s).`,color:"green",autoClose:5e3}),o.onPruned?.(d),r.closeModal(f)}catch(s){console.error(s),p({title:"Error pruning translations",message:String(s),color:"red",autoClose:!1})}finally{x(!1)}}}return n("div",{className:"PruneTranslationsModal",children:[n("div",{className:"PruneTranslationsModal__description",children:n(a,{size:"body",children:["Pruning removes the ",n("strong",{children:o.docId})," tag from translation strings that are no longer referenced by this document. The translations themselves are not deleted and will remain available to other documents that still reference them."]})}),l&&n("div",{className:"PruneTranslationsModal__loading",children:[n(v,{color:"gray",size:"sm"}),n(a,{size:"body",color:"gray",children:"Scanning for unused strings\u2026"})]}),!l&&e.length===0&&n("div",{className:"PruneTranslationsModal__empty",children:n(a,{size:"body",color:"gray",children:['All translations tagged with "',o.docId,'" are still in use. Nothing to prune.']})}),!l&&e.length>0&&n(M,{children:[n(a,{size:"body",weight:"semi-bold",children:[e.length," unused string",e.length!==1?"s":""," will be untagged:"]}),n("div",{className:"PruneTranslationsModal__list",children:e.map(s=>n("div",{className:"PruneTranslationsModal__list__item",children:n(a,{size:"body-sm",children:s.source})},s.hash))})]}),n("div",{className:"PruneTranslationsModal__actions",children:[n(m,{variant:"default",size:"xs",onClick:()=>r.closeModal(f),children:"Cancel"}),n(m,{variant:"filled",size:"xs",color:"red",leftIcon:n(N,{size:14}),loading:E,disabled:l||e.length===0,onClick:U,children:["Prune ",e.length>0?e.length:""," string",e.length!==1?"s":""]})]})]})}$.id=S;export{W as a,$ as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{L as m,a,c as f,j as O}from"./chunk-
|
|
1
|
+
import{L as m,a,c as f,j as O}from"./chunk-ETPZ3TXX.js";O();var G=["https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/spreadsheets"],P=["https://www.googleapis.com/discovery/v1/apis/drive/v3/rest","https://sheets.googleapis.com/$discovery/rest?version=v4"];function R(){let o=window.__ROOT_CTX.rootConfig.projectId,t=!!(window.__ROOT_CTX.gapi?.apiKey&&window.__ROOT_CTX.gapi?.clientId),[e,n]=a(t),[i,w]=a(0),[s,h]=m({key:`root-cms::${o}::gapi-user-consent`,defaultValue:{}});async function C(){await Promise.all([E(),b()]),n(!1)}f(()=>{t&&C()},[]);function _(r){return new Promise(v=>{let g=window.__ROOT_CTX.gapi.clientId,c=Array.from(new Set([...G,...r?.scopes||[]])),u=google.accounts.oauth2.initTokenClient({client_id:g,scope:c.join(" "),callback:async I=>{let y=l()+parseInt(I.expires_in);w(y),h({at:l(),clientId:g,scopes:c}),v()}});s&&k(s,c)?(console.log("requesting token without prompt"),u.requestAccessToken({prompt:""})):(console.log("requesting token with prompt"),u.requestAccessToken({prompt:"consent"}))})}function S(){return l()<i}function T(r){return s?.scopes?.includes(r)||!1}return{enabled:t,loading:e,isLoggedIn:S,login:_,hasScope:T}}function k(o,t){if(!o||!o.at)return!1;let e=window.__ROOT_CTX.gapi?.clientId;if(o.clientId!==e)return!1;let n=o.scopes||[];return t.every(i=>n.includes(i))}function l(){return Math.floor(new Date().getTime()/1e3)}var p=null;async function E(){return p||(p=new Promise((o,t)=>{let e=document.createElement("script");e.src="https://apis.google.com/js/api.js",e.onload=()=>{gapi.load("client",async()=>{try{await gapi.client.init({}),await Promise.all(P.map(n=>gapi.client.load(n))),console.log("gapi loaded"),o()}catch(n){console.error("Error initializing gapi:",n),t(n)}})},e.onerror=()=>{console.error("gapi script failed to load"),t(new Error("gapi script failed to load"))},document.head.appendChild(e)})),p}var d=null;async function b(){return d||(d=new Promise((o,t)=>{let e=document.createElement("script");e.src="https://accounts.google.com/gsi/client",e.onload=()=>{o()},e.onerror=()=>{console.error("gis script failed to load"),t(new Error("gis script failed to load"))},document.head.appendChild(e)})),d}export{R as a};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import{a as Nt,b as Pt,c as Et,d as St,e as zt,f as jt,g as Dt,h as Lt,i as $t,j as Bt,k as Ut,l as Ot,m as Wt,n as Ht,o as nt}from"./chunk-V3G3554T.js";import{a as wt}from"./chunk-VRRRFAIV.js";import{a as Tt,c as at}from"./chunk-5SY2SVEX.js";import{P as kt,T as Mt}from"./chunk-AAR7DBEN.js";import{f as Y}from"./chunk-5MV6XVGA.js";import{b as _t,c as mt,g as ut,h as ht,j as ft,n as q,o as gt,p as xt,r as Ct,v as G}from"./chunk-XOWWPE7X.js";import{d as At,e as N}from"./chunk-WS37MDM3.js";import{$a as tt,Ec as yt,Fa as H,Ga as o,Sc as Rt,V as J,W as P,Za as Q,Zc as U,_a as Z,a as h,ba as X,c as k,da as z,e as v,g as pt,h as M,hc as et,j as oe,mb as vt,mc as ot,nc as bt,qa as B,yc as j}from"./chunk-ETPZ3TXX.js";import{d as ct}from"./chunk-KUCVLANF.js";import{h as It}from"./chunk-7SK47HHZ.js";oe();var ae=500;function Ft(){return window.firebase.db}function Vt(){return window.__ROOT_CTX.rootConfig.projectId}function it(){return window.firebase.user?.email||""}function ne(){return _t(Ft(),"Projects",Vt(),"AiChats")}function rt(t){return mt(Ft(),"Projects",Vt(),"AiChats",t)}function D(t){return t&&typeof t.toMillis=="function"?t.toMillis():typeof t=="number"?t:0}async function Kt(t){let e=it();if(!e)return[];let a=t?.limit,n=typeof a=="number"&&Number.isFinite(a)&&a>0?Math.min(Math.floor(a),100):50,p=ut(ne(),ht("createdBy","==",e),ft(ae)),s=(await gt(p)).docs.map(l=>l.data());return s.sort((l,g)=>D(g.modifiedAt)-D(l.modifiedAt)),s.slice(0,n).map(l=>({id:l.id,title:l.title,modelId:l.modelId,createdAt:D(l.createdAt),modifiedAt:D(l.modifiedAt)}))}async function st(t){let e=await q(rt(t));if(!e.exists())return null;let a=e.data();return a.createdBy!==it()?null:{id:a.id||t,title:a.title,modelId:a.modelId,createdAt:D(a.createdAt),modifiedAt:D(a.modifiedAt),messages:a.messages||[]}}async function Jt(t,e){let a=it(),n=rt(t),p=await q(n);if(p.exists()&&p.data().createdBy!==a)throw new Error("chat is owned by another user");let _={id:t,createdBy:a,modifiedAt:G(),messages:$t(e.messages)};p.exists()||(_.createdAt=G()),e.modelId&&(_.modelId=e.modelId),e.title&&(_.title=e.title),await xt(n,_,{merge:!0})}async function Xt(t){await st(t)&&await Ct(rt(t))}async function qt(t,e){let a=St(e);if(a==="New chat")return a;let n=zt(e);if(!n)return a;try{let p=Et(Pt(t)),_=await kt({model:p,system:Dt,prompt:Lt(n),maxOutputTokens:64,temperature:.3}),s=jt(_.text);if(s)return s}catch(p){console.error("failed to generate chat title:",p)}return a}function Gt(t){let{size:e=14}=t,a=e*3.57,n=e*2;return o("div",{className:"BouncingLoader",style:{"--dot-size":`${e}px`,width:`${a}px`,height:`${n}px`}})}var lt=[{id:"read",label:"Read only",description:"Inspect CMS content without planning or applying writes."},{id:"approve",label:"Ask before writing",description:"Read freely, then pause for approval before draft edits."},{id:"auto",label:"Auto-apply draft edits",description:"Apply draft-only writes without approval in this chat."}],te="root-cms.ai.executionMode",ee="root-cms.ai.selectedModel";function ie(t){return lt.some(e=>e.id===t)}function re(){if(typeof window>"u")return"approve";try{let t=window.localStorage.getItem(te);if(ie(t))return t}catch(t){console.error("failed to read AI execution mode preference",t)}return"approve"}function se(t){if(typeof window>"u")return null;try{let e=window.localStorage.getItem(ee);if(e&&t.some(a=>a.id===e))return e}catch(e){console.error("failed to read AI model preference",e)}return null}function le(t){if(!(typeof window>"u"))try{window.localStorage.setItem(ee,t)}catch(e){console.error("failed to save AI model preference",e)}}function de(t){if(!(typeof window>"u"))try{window.localStorage.setItem(te,t)}catch(e){console.error("failed to save AI execution mode preference",e)}}var F="";function mo(t){let[e,a]=h(null),[n,p]=h("");k(()=>{let s=!0;return fetch("/cms/api/ai.config",{credentials:"include"}).then(async l=>{let g=await l.json();s&&a(g)}).catch(l=>{s&&p(String(l))}),()=>{s=!1}},[]);let _=!!e?.enabled&&(e.models?.length||0)>0;return o("div",{className:N("RootAIChat",`RootAIChat--${t.variant}`),children:!e&&!n?o("div",{className:"RootAIChat__loading",children:o(J,{size:"md",color:"gray"})}):_?o(pe,{variant:t.variant,config:e,initialChatId:t.variant==="panel"?void 0:t.initialChatId,docContext:t.docContext,onClose:t.onClose}):o(ce,{error:n,onClose:t.onClose})})}function ce(t){return o("div",{className:"RootAIChat__notEnabled",children:[t.onClose&&o(P,{className:"RootAIChat__notEnabled__close",onClick:t.onClose,title:"Close",children:o(U,{size:16})}),o("div",{className:"RootAIChat__notEnabled__icon",children:o(j,{size:36})}),o("div",{className:"RootAIChat__notEnabled__title",children:"Root AI is not configured for this project."}),o("div",{className:"RootAIChat__notEnabled__body",children:["Add an ",o("code",{children:"ai.models"})," entry to ",o("code",{children:"cmsPlugin()"})," in"," ",o("code",{children:"root.config.ts"}),"."]}),t.error&&o("pre",{className:"RootAIChat__notEnabled__error",children:t.error})]})}function pe(t){let e=t.variant==="panel",{route:a}=At(),n=t.config.models||[],p=()=>se(n)||t.config.defaultModel||n[0]?.id||"",[_,s]=h(p),[l,g]=h(re),[f,b]=h(t.initialChatId||F),[y,C]=h(t.initialChatId||F),[E,d]=h([]),[x,A]=h(""),[I,T]=h([]),[V,O]=h(0),S=async()=>{if(!e)try{let i=await Kt();T(i)}catch(i){console.error("failed to load chat list",i)}};k(()=>{S(),!e&&t.initialChatId&&K(t.initialChatId)},[]),k(()=>{de(l)},[l]);let L=async i=>{try{let u=await st(i);return u?(b(i),C(i),d(u.messages||[]),A(u.title||""),u.modelId&&n.find(R=>R.id===u.modelId)&&s(u.modelId),O(w=>w+1),!0):!1}catch(u){return console.error("failed to load chat",u),!1}},K=i=>L(i),$=()=>{s(p()),b(F),C(F),d([]),A(""),O(i=>i+1),e||a("/cms/ai")},W=async i=>{if(i===y)return;await L(i)&&!e&&a(`/cms/ai/chat/${i}`)},r=async i=>{try{await Xt(i),y===i&&$(),S()}catch(u){console.error("failed to delete chat",u)}},m=n.find(i=>i.id===_)||n[0],c=i=>{s(i),le(i)};return o("div",{className:"RootAIChat__layout",children:[!e&&o(me,{chats:I,activeChatId:y,onSelect:W,onNew:$,onDelete:r}),o("div",{className:"RootAIChat__main",children:[e&&o(_e,{onNewChat:$,onClose:t.onClose}),o(he,{initialChatId:f,initialTitle:x,model:m,initialMessages:E,executionMode:l,canAutoApply:t.config.canAutoApply??!1,models:n,selectedModel:m,docContext:t.docContext,onSelectModel:c,onSelectExecutionMode:g,onChatPersisted:i=>{C(i),S(),e||window.history.replaceState(null,"",`/cms/ai/chat/${i}`)}},V)]})]})}function _e(t){return o("div",{className:"RootAIChat__panelHeader",children:[o("div",{className:"RootAIChat__panelHeader__title",children:[o(j,{size:14}),o("span",{children:"Root AI"})]}),o("div",{className:"RootAIChat__panelHeader__actions",children:[o(H,{label:"New chat",children:o(P,{size:"xs",onClick:t.onNewChat,children:o(et,{size:14})})}),t.onClose&&o(H,{label:"Close (\u2318 + i)",children:o(P,{size:"xs",onClick:t.onClose,children:o(U,{size:14})})})]})]})}function me(t){return o("aside",{className:"RootAIChat__sidebar",children:[o("button",{type:"button",className:"RootAIChat__sidebar__newButton",onClick:t.onNew,children:[o(et,{size:18}),o("span",{children:"New chat"})]}),o("div",{className:"RootAIChat__sidebar__list",children:[t.chats.length===0&&o("div",{className:"RootAIChat__sidebar__empty",children:"No chats yet."}),t.chats.map(e=>o("div",{className:N("RootAIChat__sidebar__item",e.id===t.activeChatId&&"RootAIChat__sidebar__item--active"),onClick:()=>t.onSelect(e.id),children:[o("div",{className:"RootAIChat__sidebar__item__title",title:e.title||"Untitled chat",children:e.title||"Untitled chat"}),o("button",{type:"button",className:"RootAIChat__sidebar__item__delete",title:"Delete chat",onClick:a=>{a.stopPropagation(),window.confirm("Delete this chat?")&&t.onDelete(e.id)},children:o(Rt,{size:14})})]},e.id))]})]})}function ue(t){let e=t.canAutoApply?lt:lt.filter(n=>n.id!=="auto"),a=e.find(n=>n.id===t.executionMode)||e[0];return o("div",{className:"RootAIChat__options",children:[o(B,{control:o(z,{type:"button",className:"RootAIChat__modePicker",variant:"subtle",color:"dark",size:"xs",compact:!0,leftIcon:o(bt,{size:16}),children:a.label}),children:e.map(n=>o(B.Item,{onClick:()=>t.onSelectExecutionMode(n.id),children:o("div",{className:"RootAIChat__modePicker__option",children:[o("div",{className:"RootAIChat__modePicker__option__label",children:n.label}),o("div",{className:"RootAIChat__modePicker__option__description",children:n.description})]})},n.id))}),o(B,{control:o(z,{type:"button",className:"RootAIChat__modelPicker",variant:"subtle",color:"dark",size:"xs",compact:!0,leftIcon:o(j,{size:16}),children:t.selectedModel?.label||"Select model"}),children:t.models.map(n=>o(B.Item,{onClick:()=>t.onSelectModel(n.id),children:o("div",{className:"RootAIChat__modelPicker__option",children:[o("div",{className:"RootAIChat__modelPicker__option__label",children:n.label}),n.description&&o("div",{className:"RootAIChat__modelPicker__option__description",children:n.description})]})},n.id))})]})}function he(t){let[e]=h(()=>t.initialChatId||Se()),a=v(t.model?.id);a.current=t.model?.id;let n=v(t.executionMode);n.current=t.executionMode;let p=v(t.docContext);p.current=t.docContext;let _=v(t.onChatPersisted);_.current=t.onChatPersisted;let s=v(null),l=v(t.executionMode),g=v(t.initialTitle),f=v(null),[b,y]=h({}),C=v({});k(()=>()=>{for(let r of Object.values(C.current))r("reject");C.current={}},[]);let E=M((r,m,c,i)=>new Promise(u=>{C.current[r]=u,y(w=>({...w,[r]:{toolCallId:r,toolName:m,input:c,preview:i,status:"pending"}}))}),[]),d=M(r=>{y(m=>{let c=m[r];return c?{...m,[r]:{...c,status:"executing"}}:m}),C.current[r]?.("approve"),delete C.current[r]},[]),x=M(r=>{y(m=>{let c={...m};return delete c[r],c}),C.current[r]?.("reject"),delete C.current[r]},[]),A=M(async r=>{if(!Wt(r.toolName))return await nt(r.toolName,r.input);let m=l.current;if(m==="read")return{success:!1,error:"WRITE_BLOCKED_BY_MODE",message:"The current execution mode is read only. Do not call write tools."};let c;try{c=await Ht(r.toolName,r.input)}catch(i){return{success:!1,error:"PREVIEW_FAILED",message:i?.message||String(i)}}if(c.error)return{success:!1,error:c.error,message:c.summary,errors:c.errors,hint:c.hint};if(m==="approve"&&await E(r.toolCallId,r.toolName,r.input,c)==="reject")return{success:!1,error:"USER_REJECTED",message:"The user rejected this draft change. Do not retry unless they ask for a revised version."};try{return await nt(r.toolName,r.input)}finally{y(i=>{if(!i[r.toolCallId])return i;let u={...i};return delete u[r.toolCallId],u})}},[E]),I=M(async r=>{let m=s.current;try{let c=g.current;if(!c&&m){let i=await qt(m,r);i&&i!=="New chat"&&(c=i,g.current=i)}await Jt(e,{messages:r,modelId:m?.id||a.current,title:c||void 0})}catch(c){console.error("failed to persist chat history",c)}_.current(e)},[e]),T=pt(()=>Bt({loadTurnConfig:async()=>{let r=a.current,m=n.current,c=p.current?.docId,i=`${r}|${m}|${c||""}`,u=f.current;if(u&&u.key===i)return u.config;let w=await fetch("/cms/api/ai.chat.prepare",{method:"POST",credentials:"include",headers:{"content-type":"application/json"},body:JSON.stringify({modelId:r,executionMode:m,docId:c})}),R=await w.json();if(!w.ok||!R.success)throw new Error(R.error||`ai.chat.prepare failed: ${w.status}`);let dt={model:R.model,system:R.system,maxSteps:R.maxSteps};return s.current=R.model,l.current=R.executionMode||m,f.current={key:i,config:dt},dt},buildTools:r=>r.capabilities.tools?l.current==="read"?Ot():Ut():{},onFinish:I}),[I]),{messages:V,sendMessage:O,status:S,error:L,stop:K,addToolOutput:$}=Nt({id:e,messages:t.initialMessages,transport:T,sendAutomaticallyWhen:Mt,onToolCall:async({toolCall:r})=>{let m=await A(r);$({tool:r.toolName,toolCallId:r.toolCallId,output:m})}}),W=S==="streaming"||S==="submitted";return o(ct,{children:[o(fe,{messages:V,isStreaming:W,emptyMessage:t.model?void 0:"Select a model to start.",toolApprovals:{approvals:b,onApprove:d,onReject:x}}),L&&o("div",{className:"RootAIChat__error",children:[o("strong",{children:"Error:"})," ",L.message]}),o(ke,{disabled:!t.model,canAttach:t.model?.capabilities.attachments??!1,isStreaming:W,onStop:K,controls:o(ue,{models:t.models,selectedModel:t.selectedModel,onSelectModel:t.onSelectModel,executionMode:t.executionMode,canAutoApply:t.canAutoApply,onSelectExecutionMode:t.onSelectExecutionMode}),onSend:(r,m)=>{if(!r&&m.length===0)return;let c=Me(m),i=[r,c.text].filter(Boolean).join(`
|
|
2
|
+
|
|
3
|
+
`);O({text:i,files:c.files.map(u=>({type:"file",mediaType:u.mediaType,url:u.url,filename:u.filename}))})}})]})}function fe(t){let e=v(null);return k(()=>{let a=e.current;a&&(a.scrollTop=a.scrollHeight)},[t.messages]),t.messages.length===0?o("div",{className:"RootAIChat__transcript RootAIChat__transcript--empty",ref:e,children:o("div",{className:"RootAIChat__welcome",children:[o("div",{className:"RootAIChat__welcome__icon",children:o(j,{size:36})}),o("div",{className:"RootAIChat__welcome__title",children:"Root AI"}),o("div",{className:"RootAIChat__welcome__body",children:t.emptyMessage||"What are we going to get done today?"})]})}):o("div",{className:"RootAIChat__transcript",ref:e,children:o("div",{className:"RootAIChat__transcript__inner",children:[t.messages.map(a=>o(ge,{message:a,toolApprovals:t.toolApprovals},a.id)),t.isStreaming&&o("div",{className:"RootAIChat__streamingIndicator",children:o(Gt,{size:6})})]})})}function ge(t){let e=t.message,a=e.role==="user",n=a?"You":"Root AI",p=a?window.firebase.user?.photoURL:null,[_,s]=h(!1),l=M(()=>(e.parts||[]).filter(f=>f.type==="text"&&f.text).map(f=>f.text).join(`
|
|
4
|
+
|
|
5
|
+
`),[e.parts]),g=M(async()=>{let f=l();if(!f)return;let b=Tt.parse(f);try{await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([b],{type:"text/html"}),"text/plain":new Blob([f],{type:"text/plain"})})]),s(!0),setTimeout(()=>s(!1),2e3)}catch{await navigator.clipboard.writeText(f),s(!0),setTimeout(()=>s(!1),2e3)}},[l]);return o("div",{className:N("RootAIChat__message",`RootAIChat__message--${e.role}`),children:[o("div",{className:"RootAIChat__message__avatar",children:p?o("img",{src:p,alt:n}):o(j,{size:20})}),o("div",{className:"RootAIChat__message__body",children:[o("div",{className:"RootAIChat__message__username",children:n}),o("div",{className:"RootAIChat__message__parts",children:(e.parts||[]).map((f,b)=>o(xe,{part:f,toolApprovals:t.toolApprovals},b))}),o("button",{type:"button",className:N("RootAIChat__message__copy",_&&"RootAIChat__message__copy--copied"),title:_?"Copied!":"Copy message",onClick:g,children:_?o(Q,{size:14}):o(vt,{size:14})})]})]})}function xe(t){let e=t.part;return e.type==="text"?e.text?o("div",{className:"RootAIChat__textPart",children:o(at,{code:e.text})}):null:e.type==="reasoning"?o(Ce,{text:e.text}):e.type==="file"?o(Ae,{part:e}):e.type==="source-url"?o("a",{className:"RootAIChat__sourcePart",href:e.url,target:"_blank",rel:"noopener noreferrer",children:e.title||e.url}):typeof e.type=="string"&&e.type.startsWith("tool-")?o(Yt,{part:e,toolApprovals:t.toolApprovals}):e.type==="dynamic-tool"?o(Yt,{part:e,toolApprovals:t.toolApprovals}):e.type==="step-start"?null:o("div",{className:"RootAIChat__unknownPart",children:o("pre",{children:JSON.stringify(e,null,2)})})}function Ce(t){let[e,a]=h(!1);return t.text?o("div",{className:N("RootAIChat__reasoning",e&&"RootAIChat__reasoning--open"),children:[o("button",{type:"button",className:"RootAIChat__reasoning__toggle",onClick:()=>a(!e),children:[o(Z,{size:14,style:{transform:e?"rotate(0deg)":"rotate(-90deg)"}}),o("span",{children:"Thinking"})]}),e&&o("div",{className:"RootAIChat__reasoning__body",children:o(at,{code:t.text})})]}):null}function Ae(t){let e=t.part;return e.mediaType?.startsWith("image/")?o("div",{className:"RootAIChat__filePart",children:o("img",{src:e.url,alt:e.filename||"attachment"})}):o("a",{className:"RootAIChat__filePart RootAIChat__filePart--link",href:e.url,target:"_blank",rel:"noopener noreferrer",children:[o(ot,{size:14}),o("span",{children:e.filename||e.url})]})}function Yt(t){let e=t.part,a=typeof e.type=="string"&&e.type.startsWith("tool-")?e.type.slice(5):e.toolName||"tool",n=e.state||"",p=Ie(e),_=t.toolApprovals,s=p?_?.approvals[p]:void 0,[l,g]=h(!!s);return k(()=>{s&&g(!0)},[s]),o("div",{className:"RootAIChat__tool",children:[o("button",{type:"button",className:"RootAIChat__tool__header",onClick:()=>g(!l),children:[o(Z,{className:N("RootAIChat__tool__header__icon",l&&"RootAIChat__tool__header__icon--open"),size:14}),o(X,{color:"dark",variant:"filled",size:"xs",children:a}),o("span",{className:"RootAIChat__tool__title",children:ve(a,e.input)}),o("span",{className:"RootAIChat__tool__state",children:s?Re(s.status):we(n)})]}),l&&o("div",{className:"RootAIChat__tool__body",children:[s&&_&&o(be,{approval:s,onApprove:()=>_.onApprove(s.toolCallId),onReject:()=>_.onReject(s.toolCallId)}),e.output?.receipt&&o(ye,{output:e.output}),e.input&&o("details",{children:[o("summary",{children:[o(tt,{size:14,className:"RootAIChat__tool__json__icon"}),o("span",{children:"Input"})]}),o("pre",{children:JSON.stringify(e.input,null,2)})]}),e.output&&o("details",{children:[o("summary",{children:[o(tt,{size:14,className:"RootAIChat__tool__json__icon"}),o("span",{children:"Output"})]}),o("pre",{children:JSON.stringify(e.output,null,2)})]}),e.errorText&&o("div",{className:"RootAIChat__tool__error",children:e.errorText})]})]})}function Ie(t){return t.toolCallId||t.id||""}function ve(t,e){switch(t){case"collections_list":return"List collections";case"docs_list":return`List ${e?.collectionId||"documents"}`;case"docs_search":return`Search docs${e?.query?` for "${e.query}"`:""}`;case"doc_get":return`Read ${e?.docId||"document"}`;case"doc_getVersion":return`Read ${e?.docId||"document"} version`;case"doc_set":return`Replace ${e?.docId||"draft fields"}`;case"doc_create":return`Create ${e?.docId||"draft document"}`;case"doc_updateField":return`Update ${e?.path||"field"}`;case"doc_edit":return`Edit ${e?.docId||"document"}`;case"doc_duplicate":return`Duplicate ${e?.fromDocId||"document"}`;case"doc_listVersions":return`List versions for ${e?.docId||"document"}`;case"doc_translateField":return"Translate field text";case"schema_get":return`Read ${e?.collectionId||"collection"} schema`;default:return t}}function be(t){let e=t.approval.preview,a=e.before!==void 0&&e.after!==void 0;return o("div",{className:"RootAIChat__approval",children:[o("div",{className:"RootAIChat__approval__header",children:[o("div",{children:[o("div",{className:"RootAIChat__approval__title",children:e.title}),o("div",{className:"RootAIChat__approval__summary",children:e.summary})]}),o(X,{className:"RootAIChat__approval__status",variant:"light",color:"gray",children:t.approval.status==="executing"?"Applying":"Review"})]}),e.details.length>0&&o("div",{className:"RootAIChat__approval__details",children:e.details.map(n=>o("div",{children:[o("span",{children:n.label}),o("strong",{children:n.value})]},`${n.label}:${n.value}`))}),a&&o(wt,{className:"RootAIChat__approval__diff",oldCode:Y(e.before),newCode:Y(e.after)}),o("div",{className:"RootAIChat__approval__actions",children:[o(z,{variant:"default",color:"dark",size:"xs",type:"button",className:"RootAIChat__approval__button",disabled:t.approval.status==="executing",onClick:t.onReject,children:"Reject"}),o(z,{variant:"filled",color:"green",size:"xs",type:"button",className:"RootAIChat__approval__button RootAIChat__approval__button--primary",disabled:t.approval.status==="executing",onClick:t.onApprove,children:"Approve draft edit"})]})]})}function ye(t){let e=t.output.receipt;return o("div",{className:"RootAIChat__receipt",children:[o("div",{className:"RootAIChat__receipt__title",children:[o(Q,{size:14}),o("span",{children:e.title})]}),o("div",{className:"RootAIChat__receipt__summary",children:e.summary}),e.details?.length>0&&o("div",{className:"RootAIChat__receipt__details",children:e.details.map(a=>o("div",{children:[o("span",{children:a.label}),o("strong",{children:a.value})]},`${a.label}:${a.value}`))}),e.adminUrl&&o(z,{component:"a",className:"RootAIChat__receipt__link",variant:"default",size:"xs",compact:!0,href:e.adminUrl,children:"Open document"})]})}function Re(t){return t==="executing"?"applying\u2026":"waiting for approval"}function we(t){switch(t){case"input-streaming":return"preparing\u2026";case"input-available":return"running\u2026";case"output-available":return"done";case"output-error":return"error";default:return t}}function ke(t){let[e,a]=h(""),[n,p]=h([]),[_,s]=h(!1),l=v(null),g=v(null);k(()=>{window.requestAnimationFrame(()=>{let d=g.current;d&&(d.style.height="auto",d.style.height=`${Math.min(d.scrollHeight,240)}px`)})},[e,n]);let b=()=>{t.disabled||t.isStreaming||!e&&n.length===0||(t.onSend(e,n),a(""),p([]),l.current&&(l.current.value=""))},y=d=>{d.key==="Enter"&&!d.shiftKey&&(d.preventDefault(),b())},C=async d=>{s(!0);try{let x=d.type||Ee(d.name),A=await Te(d,x),I=await It(d,{disableGci:!0});p(T=>[...T,{url:I.src,filename:I.filename||d.name,mediaType:x,textContent:A?.text,textTruncated:A?.truncated,width:I.width,height:I.height}])}catch(x){console.error("upload failed",x)}finally{s(!1),l.current&&(l.current.value="")}},E=d=>{let x=d.target;Array.from(x.files||[]).forEach(C)};return o("div",{className:"RootAIChat__composer",children:[n.length>0&&o("div",{className:"RootAIChat__composer__attachments",children:n.map((d,x)=>o("div",{className:"RootAIChat__composer__attachment",children:[d.mediaType.startsWith("image/")?o("img",{src:d.url,alt:d.filename}):o("span",{className:"RootAIChat__composer__attachment__name",children:d.filename}),o("button",{type:"button",className:"RootAIChat__composer__attachment__remove",onClick:()=>p(A=>A.filter((I,T)=>T!==x)),children:o(U,{size:12})})]},x))}),o("div",{className:"RootAIChat__composer__row",children:[o(H,{label:t.canAttach?"Attach file":"Model doesn't support attachments",className:"RootAIChat__composer__attachTooltip",children:o(P,{component:"label",radius:"xl",className:N("RootAIChat__composer__attach",!t.canAttach&&"RootAIChat__composer__attach--disabled"),disabled:!t.canAttach,children:[_?o(J,{size:"xs"}):o(ot,{size:18}),o("input",{ref:l,type:"file",style:{display:"none"},onChange:E})]})}),o("textarea",{ref:g,className:"RootAIChat__composer__textarea",placeholder:t.disabled?"Select a model\u2026":"Ask anything\u2026",value:e,rows:1,autofocus:!0,disabled:t.disabled,onKeyDown:y,onChange:d=>a(d.target.value),onPaste:d=>{let x=d.clipboardData?.items||[];for(let A of x)if(A.kind==="file"){let I=A.getAsFile();I&&t.canAttach&&C(I)}}}),t.isStreaming?o(P,{className:"RootAIChat__composer__button RootAIChat__composer__stopButton",radius:"xl",color:"dark",variant:"filled",onClick:t.onStop,title:"Stop",children:o(U,{size:18})}):o(P,{className:"RootAIChat__composer__button RootAIChat__composer__submitButton",radius:"xl",color:"dark",variant:"filled",disabled:t.disabled||_||!e&&n.length===0,onClick:b,title:"Send",children:o(yt,{size:18})})]}),t.controls]})}var Qt=1e5;function Me(t){let e=t.filter(Zt),a=t.filter(n=>!Zt(n)).map(Ne);return{files:e,text:a.length?`Attached files:
|
|
6
|
+
|
|
7
|
+
${a.join(`
|
|
8
|
+
|
|
9
|
+
`)}`:""}}function Zt(t){return t.mediaType.startsWith("image/")}function Ne(t){let e=`File: ${t.filename} (${t.mediaType})`;if(t.textContent!==void 0){let a=t.textTruncated?`
|
|
10
|
+
|
|
11
|
+
[Content truncated before sending to the model.]`:"";return`${e}
|
|
12
|
+
URL: ${t.url}
|
|
13
|
+
|
|
14
|
+
~~~
|
|
15
|
+
${t.textContent}${a}
|
|
16
|
+
~~~`}return`${e}
|
|
17
|
+
URL: ${t.url}
|
|
18
|
+
|
|
19
|
+
[The file was uploaded, but its binary content was not inlined into this chat message.]`}async function Te(t,e){if(!Pe(t.name,e))return null;let a=await t.text();return a.length<=Qt?{text:a,truncated:!1}:{text:a.slice(0,Qt),truncated:!0}}function Pe(t,e){return e.startsWith("text/")?!0:[".css",".js",".jsx",".json",".md",".mdx",".mjs",".scss",".ts",".tsx",".txt",".yaml",".yml"].some(a=>t.toLowerCase().endsWith(a))}function Ee(t){let e=t.toLowerCase();return e.endsWith(".png")?"image/png":e.endsWith(".webp")?"image/webp":e.endsWith(".jpg")||e.endsWith(".jpeg")?"image/jpeg":e.endsWith(".gif")?"image/gif":e.endsWith(".svg")?"image/svg+xml":e.endsWith(".pdf")?"application/pdf":e.endsWith(".json")?"application/json":e.endsWith(".csv")?"text/csv":e.endsWith(".md")?"text/markdown":e.endsWith(".txt")?"text/plain":"application/octet-stream"}function Se(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`chat-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}export{mo as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{z as o}from"./chunk-XOWWPE7X.js";import{Fa as r,Ga as i,ba as a}from"./chunk-ETPZ3TXX.js";var l={transition:"pop"};function g(t){let e=t.release;return n(e.archivedAt)?i(r,{...l,label:`Archived ${d(e.archivedAt)} by ${e.archivedBy}`,children:i(a,{size:"xs",color:"gray",variant:"filled",children:"Archived"})}):n(e.scheduledAt)?i(r,{...l,label:`Scheduled ${s(e.scheduledAt)} by ${e.scheduledBy}`,wrapLines:!0,width:240,children:i(a,{size:"xs",variant:"gradient",gradient:{from:"grape",to:"pink",deg:35},children:"Scheduled"})}):n(e.publishedAt)?i(r,{...l,label:`Published ${d(e.publishedAt)} by ${e.publishedBy}`,children:i(a,{size:"xs",variant:"gradient",gradient:{from:"teal",to:"lime",deg:105},children:"Published"})}):i(a,{size:"xs",variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:"Unpublished"})}function n(t){return!!(t&&t.toMillis)}function d(t){return t?.toMillis?o(t.toMillis()):o(new Date().getTime())}function s(t){return new Date(t.toMillis()).toLocaleDateString("en",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}export{g as a};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as na,b as P,c as I,d as ia,e as la}from"./chunk-
|
|
1
|
+
import{a as na,b as P,c as I,d as ia,e as la}from"./chunk-XACLTYBB.js";import{a as v}from"./chunk-WAT22UHZ.js";import{a as d}from"./chunk-SWTNOWNE.js";import{a as oa}from"./chunk-H3PYPGNR.js";import{a as D}from"./chunk-EYVQCOAD.js";import{a as A}from"./chunk-XM35ZJBQ.js";import{e as Q}from"./chunk-WS37MDM3.js";import{Da as J,Db as ta,Ga as a,Nc as ra,Pa as X,V as G,Wa as Z,Wc as sa,_a as aa,a as l,c as W,da as _,g as V,j as fa,lb as ea,qa as z,ua as Y,xa as R,ya as q}from"./chunk-ETPZ3TXX.js";fa();var O=[{value:"new",label:"New"},{value:"in-progress",label:"In progress"},{value:"in-review",label:"In review"},{value:"closed",label:"Closed"}],Ta=O.filter(t=>t.value!=="closed"),xa=O.filter(t=>t.value==="closed"),va=[{value:"table",label:a("span",{className:"TaskManager__layoutOption",children:[a(ra,{size:14,strokeWidth:"1.8"}),"Table"]})},{value:"board",label:a("span",{className:"TaskManager__layoutOption",children:[a(ea,{size:14,strokeWidth:"1.8"}),"Board"]})}],ba=[{value:"open",label:"Active"},{value:"assigned-to-me",label:"Assigned to me"}],ha=[{value:"open",label:"Active"},{value:"assigned-to-me",label:"Assigned to me"},{value:"created-by-me",label:"Created by me"},{value:"closed",label:"Closed"},{value:"all",label:"All"}];function qa(t){let e=window.firebase.user.email||"",r=(t.variant||"compact")==="page",{tasks:i,loading:n,error:c}=Sa(r?"all":"open"),[f,b]=l("open"),[p,da]=oa("root-cms-task-manager-layout-v2","table"),[h,j]=l(""),[g,y]=l(""),[M,T]=l(!1),[w,B]=l("normal"),[x,N]=l(""),[C,L]=l(!1),[H,F]=l(!1),pa=r?ha:ba,U=V(()=>za(i,f,e),[i,f,e]),K=U.length,ga=r?`${K} shown`:`${K} active`,ma=!!h.trim()&&!H;async function ka(o){o.preventDefault();let $=h.trim();if(!$)return;let S=Ca($);F(!0);try{await na({title:S.title,description:S.description,assignee:g.trim()||void 0,priority:w,targetLaunchDate:_a(x)}),j(""),y(""),B("normal"),N(""),A({title:"Task created",message:S.title,autoClose:4e3})}catch(ua){A({title:"Could not create task",message:D(ua),color:"red",autoClose:!1})}finally{F(!1)}}return a("div",{className:Q(t.className,"TaskManager",r&&"TaskManager--page"),children:[a(d,{className:"TaskManager__composer",children:a("form",{onSubmit:o=>ka(o),children:[a("div",{className:"TaskManager__composer__header",children:[a("div",{className:"TaskManager__composer__avatar",children:g&&a(v,{email:g,size:32})}),a("div",{children:[a("div",{className:"TaskManager__composer__title",children:"Create a task"}),a("div",{className:"TaskManager__composer__subtitle",children:"Assign it to an agent, a teammate, or yourself."})]})]}),a("textarea",{className:"TaskManager__composer__textarea",value:h,rows:3,placeholder:"Enter a task description. Specify scope, collection, and acceptance criteria.",onInput:o=>{j(o.currentTarget.value)}}),a("div",{className:"TaskManager__composer__footer",children:[a("div",{className:"TaskManager__composer__controls",children:[a(R,{opened:M,onClose:()=>T(!1),position:"bottom",shadow:"md",width:280,withArrow:!0,target:a("button",{className:"TaskManager__composer__control",type:"button","aria-expanded":M,onClick:()=>T(!M),children:[a(sa,{size:15,strokeWidth:"1.8"}),a("span",{children:"assign to..."}),g&&a("span",{className:"TaskManager__composer__control__value",children:m(g)})]}),children:a("div",{className:"TaskManager__composer__popover",children:[a(Y,{autoFocus:!0,label:"Email",placeholder:"teammate@example.com",size:"xs",type:"email",value:g,onChange:o=>y(o.currentTarget.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),T(!1))}}),a("div",{className:"TaskManager__composer__popover__actions",children:[a(_,{compact:!0,size:"xs",variant:"default",onClick:()=>y(""),children:"Clear"}),a(_,{compact:!0,size:"xs",color:"dark",onClick:()=>T(!1),children:"Done"})]})]})}),a(z,{position:"bottom",shadow:"md",control:a("button",{className:"TaskManager__composer__control",type:"button",children:[a(ta,{size:15,strokeWidth:"1.8"}),a("span",{children:w}),a(aa,{size:14,strokeWidth:"1.8"})]}),children:["high","medium","normal"].map(o=>a(z.Item,{className:w===o?"TaskManager__composer__menuItem--active":"",onClick:()=>B(o),children:o},o))}),a(R,{opened:C,onClose:()=>L(!1),position:"bottom",shadow:"md",width:260,withArrow:!0,target:a("button",{className:"TaskManager__composer__control",type:"button","aria-expanded":C,onClick:()=>L(!C),children:[a(Z,{size:15,strokeWidth:"1.8"}),a("span",{children:x?Da(x):"target launch date"})]}),children:a("div",{className:"TaskManager__composer__popover",children:[a("label",{className:"TaskManager__composer__dateLabel",children:["Target launch date",a("input",{type:"date",value:x,onInput:o=>{N(o.currentTarget.value)}})]}),a("div",{className:"TaskManager__composer__popover__actions",children:[a(_,{compact:!0,size:"xs",variant:"default",onClick:()=>N(""),children:"Clear"}),a(_,{compact:!0,size:"xs",color:"dark",onClick:()=>L(!1),children:"Done"})]})]})})]}),a(_,{type:"submit",size:"xs",color:"dark",loading:H,disabled:!ma,rightIcon:a(X,{size:15,strokeWidth:"1.8"}),children:"Create task"})]})]})}),a("div",{className:"TaskManager__listHeader",children:[a("div",{className:"TaskManager__listHeader__summary",children:[a("div",{className:"TaskManager__listHeader__titleLine",children:[a("div",{className:"TaskManager__sectionTitle",children:r?"Tasks":"Active tasks"}),a("span",{className:"TaskManager__listHeader__count",children:ga})]}),a("div",{className:"TaskManager__filters","aria-label":"Task filters",children:pa.map(o=>a("button",{className:f===o.value?"active":"",type:"button",onClick:()=>b(o.value),children:o.label},o.value))})]}),a("div",{className:"TaskManager__listHeader__actions",children:r?a(q,{className:"TaskManager__layoutToggle",size:"xs",value:p,onChange:o=>da(o),data:va}):a(_,{component:"a",href:"/cms/tasks",variant:"default",size:"xs",compact:!0,children:"Show all"})})]}),a(ya,{error:c,filter:f,layout:r?p:"compact",loading:n,tasks:U})]})}function ya(t){let{error:e,filter:s,layout:r,loading:i,tasks:n}=t;return i?a(d,{className:"TaskManager__list",children:a("div",{className:"TaskManager__list__state",children:a(G,{color:"gray",size:"sm"})})}):e?a(d,{className:"TaskManager__list",children:a("div",{className:"TaskManager__list__state error",children:e})}):n.length===0?a(d,{className:"TaskManager__list",children:a("div",{className:"TaskManager__list__state",children:Ra(s,r)})}):r==="board"?a(wa,{filter:s,tasks:n}):r==="table"?a(Ma,{tasks:n}):a(d,{className:"TaskManager__list",children:n.map(c=>a(La,{task:c},c.id))})}function Ma(t){return a(d,{className:"TaskManager__tableSurface",children:a(J,{className:"TaskManager__table",verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[a("thead",{children:a("tr",{children:[a("th",{children:"task"}),a("th",{children:"status"}),a("th",{children:"priority"}),a("th",{children:"assignee"}),a("th",{children:"target"}),a("th",{children:"opened"})]})}),a("tbody",{children:t.tasks.map(e=>{let s=e.createdBy||"unknown";return a("tr",{children:[a("td",{children:a("a",{className:"TaskManager__tableTask",href:`/cms/tasks/${e.id}`,children:[a("div",{className:"TaskManager__taskRow__avatar",children:e.assignee&&a(v,{email:e.assignee,size:24})}),a("span",{className:"TaskManager__tableTask__content",children:[a("span",{className:"TaskManager__tableTask__title",children:e.title}),a("span",{className:"TaskManager__tableTask__meta",children:["#",e.id," by ",m(s)]})]})]})}),a("td",{children:a("span",{className:"TaskManager__taskRow__status",children:[a("span",{}),E(e.status)]})}),a("td",{children:a("span",{className:`TaskManager__taskRow__priority TaskManager__taskRow__priority--${u(e.priority)}`,children:u(e.priority)})}),a("td",{children:e.assignee?m(e.assignee):"Unassigned"}),a("td",{children:e.targetLaunchDate?k(e.targetLaunchDate):"None"}),a("td",{children:k(e.createdAt)})]},e.id)})})]})})}function wa(t){let e=Aa(t.tasks,t.filter);return a("div",{className:"TaskManager__board",children:e.map(s=>{let r=t.tasks.filter(i=>ca(i)===s.value);return a("section",{className:"TaskManager__boardColumn",children:[a("div",{className:"TaskManager__boardColumn__header",children:[a("span",{children:s.label}),a("span",{children:r.length})]}),a("div",{className:"TaskManager__boardColumn__tasks",children:[r.length===0&&a("div",{className:"TaskManager__boardColumn__empty",children:"No tasks"}),r.map(i=>a(Na,{task:i},i.id))]})]},s.value)})})}function Na(t){let{task:e}=t,s=e.createdBy||"unknown";return a("a",{className:"TaskManager__boardCard",href:`/cms/tasks/${e.id}`,children:[a("div",{className:"TaskManager__boardCard__title",children:e.title}),e.description&&a("div",{className:"TaskManager__boardCard__description",children:e.description}),a("div",{className:"TaskManager__boardCard__meta",children:["#",e.id," opened ",k(e.createdAt)," by"," ",m(s)]}),a("div",{className:"TaskManager__boardCard__badges",children:[a("span",{className:`TaskManager__taskRow__priority TaskManager__taskRow__priority--${u(e.priority)}`,children:u(e.priority)}),a("span",{className:"TaskManager__boardCard__badge",children:e.assignee?m(e.assignee):"Unassigned"}),e.targetLaunchDate&&a("span",{className:"TaskManager__boardCard__badge",children:["target ",k(e.targetLaunchDate)]})]})]})}function Ca(t){let[e,...s]=t.split(`
|
|
2
2
|
`);for(;s.length>0&&s[0].trim().length===0;)s.shift();return{title:e.trim(),description:s.join(`
|
|
3
3
|
`).trim()}}function La(t){let{task:e}=t,s=e.createdBy||"unknown";return a("a",{className:"TaskManager__taskRow",href:`/cms/tasks/${e.id}`,children:[a("div",{className:"TaskManager__taskRow__avatar",children:e.assignee&&a(v,{email:e.assignee,size:28})}),a("div",{className:"TaskManager__taskRow__content",children:[a("div",{className:"TaskManager__taskRow__title",children:e.title}),a("div",{className:"TaskManager__taskRow__meta",children:["opened ",k(e.createdAt)," by ",m(s)]})]}),a("div",{className:"TaskManager__taskRow__badges",children:[a("div",{className:"TaskManager__taskRow__status",children:[a("span",{}),E(e.status)]}),a("div",{className:`TaskManager__taskRow__priority TaskManager__taskRow__priority--${u(e.priority)}`,children:u(e.priority)}),e.targetLaunchDate&&a("div",{className:"TaskManager__taskRow__date",children:["target ",k(e.targetLaunchDate)]})]})]})}function Sa(t){let[e,s]=l([]),[r,i]=l(!0),[n,c]=l("");return W(()=>{i(!0);let b=(t==="all"?ia:la)(p=>{s(p),c(""),i(!1)},p=>{c(D(p)),i(!1)});return()=>b()},[t]),{tasks:e,loading:r,error:n}}function za(t,e,s){switch(e){case"all":return t;case"closed":return t.filter(r=>!P(r.status));case"assigned-to-me":return t.filter(r=>r.assignee===s);case"created-by-me":return t.filter(r=>r.createdBy===s);default:return t.filter(r=>P(r.status))}}function Ra(t,e){switch(t){case"assigned-to-me":return e==="compact"?"No active tasks are assigned to you.":"No tasks are assigned to you.";case"created-by-me":return"No tasks created by you.";case"closed":return"No closed tasks yet.";case"all":return"No tasks yet.";default:return"No active tasks yet."}}function m(t){return t.split("@")[0]||t}function k(t){return t?.toMillis?new Date(t.toMillis()).toLocaleDateString("en",{month:"short",day:"numeric"}):"just now"}function E(t){return I(t).replace(/[-_]/g," ")}function ca(t){return I(t.status)}function Aa(t,e){let s=e==="open"?Ta:e==="closed"?xa:O,r=new Set(s.map(n=>n.value)),i=t.map(n=>ca(n)).filter(n=>!r.has(n));return[...s,...Array.from(new Set(i)).map(n=>({value:n,label:E(n)}))]}function u(t){return t||"normal"}function _a(t){if(!t)return null;let[e,s,r]=t.split("-").map(Number);return!e||!s||!r?null:new Date(e,s-1,r)}function Da(t){let e=_a(t);return e?e.toLocaleDateString("en",{month:"short",day:"numeric"}):"target launch date"}export{qa as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as _,c as P}from"./chunk-ATTW36EM.js";import{D as u,a as w,b as j,c as n,g as T,n as b,o as R,p as I,q as m,u as h,v as l,x as f}from"./chunk-XOWWPE7X.js";async function F(t,a){if(!t)throw new Error("missing data source id");let o=window.__ROOT_CTX.rootConfig.projectId,e=window.firebase.db,s=n(e,"Projects",o,"DataSources",t);await I(s,{...a,id:t,createdAt:l(),createdBy:window.firebase.user.email}),u("datasource.create",{metadata:{datasourceId:t}})}async function G(){let t=window.__ROOT_CTX.rootConfig.projectId,a=window.firebase.db,o=j(a,"Projects",t,"DataSources"),e=T(o),s=await R(e),r=[];return s.forEach(c=>{r.push(c.data())}),r}async function S(t){let a=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,e=n(o,"Projects",a,"DataSources",t),s=await b(e);return s.exists()?s.data():null}async function O(t,a){let o=a?.mode||"draft",e=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,r=n(s,"Projects",e,"DataSources",t,"Data",o),c=await b(r);return c.exists()?c.data():null}async function U(t,a){let o=window.__ROOT_CTX.rootConfig.projectId,e=window.firebase.db,s=n(e,"Projects",o,"DataSources",t);await m(s,a),u("datasource.save",{metadata:{datasourceId:t}})}async function q(t){let a=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,e=n(o,"Projects",a,"DataSources",t);await m(e,{archivedAt:l(),archivedBy:window.firebase.user.email}),u("datasource.archive",{metadata:{datasourceId:t}})}async function H(t){let a=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,e=n(o,"Projects",a,"DataSources",t);await m(e,{archivedAt:h(),archivedBy:h()}),u("datasource.unarchive",{metadata:{datasourceId:t}})}async function W(t){let a=await S(t);if(!a)throw new Error(`data source not found: ${t}`);if(a.archivedAt)throw new Error(`data source is archived: ${t}`);if(a.type==="http"&&a.url&&!C(a.url)){let o=await fetch("/cms/api/data.sync",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({id:a.id})});if(o.status!==200){let e=await o.text();throw new Error(`sync failed: ${e}`)}}else{let{data:o,headers:e}=await x(a),s=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,c=n(r,"Projects",s,"DataSources",t),d=n(r,"Projects",s,"DataSources",t,"Data","draft"),p={...a,syncedAt:w.now(),syncedBy:window.firebase.user.email},i=f(r);i.set(d,{dataSource:p,data:o,...e?{headers:e}:{}}),i.update(c,{syncedAt:w.now(),syncedBy:window.firebase.user.email}),await i.commit()}console.log(`synced data source: ${t}`),u("datasource.sync",{metadata:{datasourceId:t}})}async function M(t){let a=await S(t);if(!a)throw new Error(`data source not found: ${t}`);if(a.archivedAt)throw new Error(`data source is archived: ${t}`);let o=window.__ROOT_CTX.rootConfig.projectId,e=window.firebase.db,s=n(e,"Projects",o,"DataSources",t),r=n(e,"Projects",o,"DataSources",t,"Data","draft"),c=n(e,"Projects",o,"DataSources",t,"Data","published"),d=await O(t,{mode:"draft"}),p={...a,publishedAt:w.now(),publishedBy:window.firebase.user.email},i=f(e);i.set(c,{dataSource:p,data:d?.data||null,...d?.headers?{headers:d.headers}:{}}),i.update(r,{dataSource:p}),i.update(s,{publishedAt:w.now(),publishedBy:window.firebase.user.email}),await i.commit(),console.log(`published data ${t}`),u("datasource.publish",{metadata:{datasourceId:t}})}async function k(t){if(!await S(t))throw new Error(`data source not found: ${t}`);let o=window.__ROOT_CTX.rootConfig.projectId,e=window.firebase.db,s=n(e,"Projects",o,"DataSources",t),r=n(e,"Projects",o,"DataSources",t,"Data","draft"),c=n(e,"Projects",o,"DataSources",t,"Data","published"),d=f(e);d.update(s,{publishedAt:h(),publishedBy:h()}),(await b(r)).exists()&&d.update(r,{"dataSource.publishedAt":h(),"dataSource.publishedBy":h()}),d.delete(c),await d.commit(),console.log(`unpublished data source: ${t}`),u("datasource.unpublish",{metadata:{datasourceId:t}})}async function J(t,a){if(t.length===0)return;let o=window.firebase.db,e=window.__ROOT_CTX.rootConfig.projectId,s=a?.batch||f(o);for(let r of t){let c=await S(r);if(!c)throw new Error(`data source not found: ${r}`);if(c.archivedAt)throw new Error(`data source is archived: ${r}`);let d=await O(r,{mode:"draft"}),p=n(o,"Projects",e,"DataSources",r),i=n(o,"Projects",e,"DataSources",r,"Data","draft"),y=n(o,"Projects",e,"DataSources",r,"Data","published"),D={...c,publishedAt:l(),publishedBy:window.firebase.user.email};s.set(y,{dataSource:D,data:d?.data||null,...d?.headers?{headers:d.headers}:{}}),s.update(i,{dataSource:D}),s.update(p,{publishedAt:l(),publishedBy:window.firebase.user.email}),u("datasource.publish",{metadata:{datasourceId:r}})}(!a?.batch||a?.commitBatch)&&await s.commit()}async function N(t){let a=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,e=n(o,"Projects",a,"DataSources",t),s=n(o,"Projects",a,"DataSources",t,"Data","draft"),r=n(o,"Projects",a,"DataSources",t,"Data","published"),c=f(o);c.delete(s),c.delete(r),c.delete(e),await c.commit(),console.log(`deleted data source ${t}`),u("datasource.delete",{metadata:{datasourceId:t}})}async function x(t){if(t.type==="http")return{data:await B(t)};if(t.type==="gsheet")return await v(t);throw new Error(`unsupported data source: ${t.type}`)}async function v(t){let a=P(t.url);if(!a?.spreadsheetId)throw new Error(`failed to parse google sheet url: ${t.url}`);let e=await new _(a.spreadsheetId).getSheet(a.gid??0);if(!e)throw new Error(`could not find sheet: ${t.url}`);let s=t.dataFormat||"map",[r,c]=await e.getValues();return s==="array"?{data:[r,c],headers:r}:{data:c.map(p=>{let i={};return p.forEach((y,D)=>{let g=r[D];g&&(i[g]=String(y||""))}),i}),headers:r}}async function B(t){if(!C(t.url))throw new Error(`unsupported url: ${t.url}`);let a=await fetch(t.url,{method:t.httpOptions?.method||"GET",headers:t.httpOptions?.headers||[],body:t.httpOptions?.body||void 0});if(a.status!==200){let e=await a.text();throw new Error(`req failed: ${e}`)}return String(a.headers.get("content-type")).includes("application/json")?await a.json():a.text()}function C(t){return t&&t.startsWith("/")}export{F as a,G as b,S as c,O as d,U as e,q as f,H as g,W as h,M as i,k as j,J as k,N as l};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as F}from"./chunk-
|
|
1
|
+
import{c as F}from"./chunk-CSUKZZK5.js";import{b as P}from"./chunk-5MV6XVGA.js";import{b as $}from"./chunk-EYVQCOAD.js";import{N as T,b as S}from"./chunk-YV5SGR24.js";import{B as b,z as p}from"./chunk-XOWWPE7X.js";import{e as w}from"./chunk-WS37MDM3.js";import{Fa as g,Ga as t,V as N,a as f,ba as l,c as h,e as k,i as R,j as B,la as I}from"./chunk-ETPZ3TXX.js";import{d as y,j as x,k as M}from"./chunk-KUCVLANF.js";M();B();var L=x(null);function W(e){let[i,n]=f([]),[o,a]=f(!1),r=k("idle");function u(){r.current==="idle"&&(r.current="fetching",a(!0),F().then(s=>{let c=s.filter(m=>!m.publishedAt&&!m.archivedAt);n(c)}).catch(s=>{console.error("Failed to fetch pending releases:",s)}).finally(()=>{r.current="done",a(!1)}))}function d(s){return i.filter(c=>c.docIds?.includes(s))}return t(L.Provider,{value:{releases:i,getReleasesForDoc:d,loading:o,fetchReleases:u},children:e.children})}function A(){let e=R(L);if(!e)throw new Error("usePendingReleases must be used within a <PendingReleasesProvider>");let{fetchReleases:i,...n}=e;return h(()=>{i()},[]),n}function z(e){let i={transition:"pop"},n=e.doc,o=n.sys;return t("div",{className:"DocStatusBadges",children:[(!o.publishedAt||!o.modifiedAt||o.modifiedAt>o.publishedAt)&&t(g,{...i,label:`Modified ${_(o.modifiedAt)} by ${o.modifiedBy}`,children:t(l,{size:"xs",variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:"Draft"})}),!!o.publishedAt&&t(g,{...i,label:`Published ${_(o.publishedAt)} by ${o.publishedBy}`,children:t(l,{size:"xs",variant:"gradient",gradient:{from:"teal",to:"lime",deg:105},children:"Published"})}),!!o.scheduledAt&&t(g,{...i,label:`Scheduled ${b(o.scheduledAt)} by ${o.scheduledBy}`,children:t(l,{size:"xs",variant:"gradient",gradient:{from:"grape",to:"pink",deg:35},children:"Scheduled"})}),!e.hideReleases&&t(K,{docId:e.docId||n.id,tooltipProps:i}),T(n)&&t(g,{...i,label:O(n),children:t(l,{size:"xs",variant:"gradient",gradient:{from:"orange",to:"red"},className:e.onPublishingLockClick?"DocStatusBadges__badge--clickable":void 0,style:e.onPublishingLockClick?{cursor:"pointer"}:void 0,role:e.onPublishingLockClick?"button":void 0,tabIndex:e.onPublishingLockClick?0:void 0,onClick:e.onPublishingLockClick,onKeyDown:e.onPublishingLockClick?a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),e.onPublishingLockClick())}:void 0,children:"Locked"})}),!!o.archivedAt&&t(g,{...i,label:`Archived ${_(o.archivedAt)} by ${o.archivedBy}`,children:t(l,{size:"xs",variant:"gradient",gradient:{from:"gray",to:"dark"},children:"Archived"})})]})}function O(e){let i=e.sys?.publishingLocked;return i?i.until?`Locked until ${b(i.until)} by ${i.lockedBy}: "${i.reason}"`:`Locked by ${i.lockedBy}: "${i.reason}"`:""}function K(e){let{getReleasesForDoc:i}=A(),n=i(e.docId);return n.length===0?null:t(y,{children:n.map(o=>t(g,{...e.tooltipProps,label:`In release: ${o.id}`,children:t(l,{component:"a",href:`/cms/releases/${o.id}`,size:"xs",variant:"gradient",gradient:{from:"violet",to:"grape"},style:{cursor:"pointer"},children:o.id})},o.id))})}function _(e){return e?p(e.toMillis()):p(new Date().getTime())}function E(e){let{file:i,width:n,height:o,withPlaceholder:a,className:r,alt:u}=e,d=typeof i=="string"?i:i?.src;return U(i)?t(X,{className:r,src:d,width:n,height:o}):t(I,{className:r,src:d,width:n,height:o,withPlaceholder:a,alt:u})}function U(e){if(!e)return!1;if(typeof e=="string")return/\.mp4($|\?)/i.test(e);if(typeof e.mimeType=="string")return e.mimeType.toLowerCase()==="video/mp4";let i=e.src;return typeof i!="string"?!1:/\.mp4($|\?)/i.test(i)}function X(e){return t("video",{className:e.className,src:e.src,width:e.width,height:e.height,muted:!0,playsInline:!0,preload:"metadata",style:{width:`${e.width}px`,height:`${e.height}px`,backgroundColor:"#f1f3f5",objectFit:"cover",display:"block"}})}B();function De(e){let i=e.docId,[n,o]=f(e.doc),[a,r]=f(!e.doc);async function u(){r(!0),await $(async()=>{let V=await S(i);o(V)}),r(!1)}if(h(()=>{u()},[i]),a)return t("div",{className:w(e.className,"DocPreviewCard","DocPreviewCard--loading",e.variant&&`DocPreviewCard--${e.variant}`),children:t(N,{color:"gray",size:"sm"})});if(!n)return;let[d]=i.split("/"),s=n.fields||{},c=window.__ROOT_CTX.collections[d];if(!c)return console.error(`could not find collection: ${d}`),t("div",{className:"DocPreviewCard",children:["Collection ",t("b",{children:d})," not found."]});let m=P(s,c.preview?.title||"meta.title"),C=P(s,c.preview?.image||"meta.image")||c.preview?.defaultImage,D="div",v={};return e.clickable&&(D="a",v.href=`/cms/content/${e.docId}`,v.target="_blank"),t(D,{className:w(e.className,"DocPreviewCard",e.variant&&`DocPreviewCard--${e.variant}`),...v,children:[t("div",{className:"DocPreviewCard__image",children:t(E,{file:C,width:80,height:60,withPlaceholder:!C?.src})}),t("div",{className:"DocPreviewCard__content",children:[t("div",{className:"DocPreviewCard__content__header",children:t("div",{className:"DocPreviewCard__content__header__docId",children:n.id})}),t("div",{className:"DocPreviewCard__content__title",children:m||"[UNTITLED]"}),e.statusBadges&&n&&t("div",{className:"DocPreviewCard__content__badges",children:t(z,{doc:n,hideReleases:e.hideReleases})})]})]})}export{W as a,A as b,z as c,O as d,E as e,De as f};
|