@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
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a}from"./chunk-2RAVKX2Z.js";import"./chunk-HO3W4RVG.js";import"./chunk-2EPQJUGM.js";import"./chunk-NJMNOITA.js";import"./chunk-344GZOGG.js";import"./chunk-YDO2EDVY.js";import"./chunk-5MV6XVGA.js";import{a as i}from"./chunk-P2Z66DHV.js";import{b as o}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import"./chunk-BUNR5EU3.js";import{Ga as t}from"./chunk-LROR6N3B.js";import"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";function n(r){return i("AI"),t(o,{children:t(a,{variant:"page",initialChatId:r.chatId})})}export{n as AIPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as j}from"./chunk-4FGASIIX.js";import{a as U}from"./chunk-TOGLZDK3.js";import{h as B}from"./chunk-Q7IU4QCY.js";import{a as z,e as A,j as E}from"./chunk-YXSXWFLZ.js";import"./chunk-JTIQBW33.js";import{c as O,e as I}from"./chunk-PTPYMVFW.js";import"./chunk-2S5HMST6.js";import{a as w}from"./chunk-FJLNXXE3.js";import{a as P}from"./chunk-GT5EQSEX.js";import"./chunk-D3UIZHRK.js";import"./chunk-HARRKJFZ.js";import"./chunk-JS6TK4OP.js";import"./chunk-JDW4UORS.js";import"./chunk-YDO2EDVY.js";import{b as h}from"./chunk-5MV6XVGA.js";import"./chunk-AGFPVTBA.js";import"./chunk-YMBBWVBB.js";import{b as S}from"./chunk-W5DOO6ID.js";import{a as D}from"./chunk-NSOTG64N.js";import"./chunk-J5E457OI.js";import"./chunk-QHJOTXYB.js";import"./chunk-BW2MKGNP.js";import"./chunk-KRNQ6L35.js";import{a as $}from"./chunk-P2Z66DHV.js";import{b as R}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import{d as k}from"./chunk-BUNR5EU3.js";import{Ca as L,Ga as o,V as y,a as x,c as T,cb as u,da as C,j as M,za as N}from"./chunk-LROR6N3B.js";import{d as f}from"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";M();function p(e){let{route:i}=k(),l=window.__ROOT_CTX.rootConfig.projectId;$(e.collection?e.collection:"Content"),T(()=>{let a=window.__ROOT_CTX.collections,s=`root-cms::${l}::last_collection`;if(e.collection)window.localStorage.setItem(s,e.collection);else{let t=window.localStorage.getItem(s);if(t&&a[t]){i(`/cms/content/${t}`);return}if(window.__ROOT_CTX.collections.Pages){i("/cms/content/Pages");return}let _=Object.keys(window.__ROOT_CTX.collections)||[];if(_.length>0){let d=_[0];i(`/cms/content/${d}`);return}console.warn("no collections")}},[e.collection,l]);let n=window.__ROOT_CTX.collections;return o(R,{children:o("div",{className:"CollectionPage",children:o("div",{className:"CollectionPage__layout",children:[o("div",{className:"CollectionPage__side",children:o(j,{collections:n,activeCollectionId:e.collection,projectId:l})}),o("div",{className:"CollectionPage__main",children:e.collection&&o(p.Collection,{collection:e.collection},e.collection)})]})})})}p.Collection=e=>{let{roles:i}=D(),l=window.firebase.user.email||"",n=S(i,l),[a,s]=w(`root::CollectionPage:${e.collection}:orderBy`,"modifiedAt"),[t,_]=w(`root::CollectionPage:${e.collection}:showArchived`,!1),[d,r]=x(!1),m=window.__ROOT_CTX.collections[e.collection];if(!m)return route("/cms/content"),o(f,{});let v=[{value:"slug",label:"A-Z"},{value:"slugDesc",label:"Z-A"},{value:"newest",label:"Newest"},{value:"oldest",label:"Oldest"},{value:"modifiedAt",label:"Last modified"},...m.sortOptions?.map(g=>({value:g.id,label:g.label}))||[]],[c,X,b]=A(e.collection,{orderBy:a,includeArchived:t});return o(f,{children:[o(E,{collection:e.collection,opened:d,onClose:()=>r(!1)}),o("div",{className:"CollectionPage__collection",children:o("div",{className:"CollectionPage__collection__docsTab",children:[!c&&o("div",{className:"CollectionPage__collection__docsTab__header",children:[o("div",{className:"CollectionPage__collection__docsTab__header__title",children:m.name||e.collection}),o("div",{className:"CollectionPage__collection__docsTab__controls",children:[o("div",{className:"CollectionPage__collection__docsTab__controls__showArchived",children:o(L,{size:"sm",color:"dark",label:"Show archived:",checked:t,onChange:g=>_(!!g.currentTarget.checked)})}),o("div",{className:"CollectionPage__collection__docsTab__controls__sort",children:[o("div",{className:"CollectionPage__collection__docsTab__controls__sort__label",children:"Sort:"}),o(N,{size:"xs",value:a,onChange:g=>s(g||"modifiedAt"),data:v})]}),o("div",{className:"CollectionPage__collection__docsTab__controls__newDoc",children:o(P,{label:"You don't have access to create new documents",condition:!n,children:o(C,{color:"dark",size:"xs",leftIcon:o(u,{size:16}),onClick:()=>r(!0),disabled:!n,children:"New"})})})]})]}),o(U,{className:"CollectionPage__collection__docsTab__content",children:c?o("div",{className:"CollectionPage__collection__docsTab__content__loading",children:o(y,{color:"gray",size:"xl"})}):b.length===0?o("div",{class:"CollectionPage__collection__docsEmpty",children:[o("div",{class:"CollectionPage__collection__docsEmpty__title",children:"Collection is empty."}),o("div",{class:"CollectionPage__collection__docsEmpty__button",children:o(P,{label:"You don't have access to create new documents",condition:!n,children:o(C,{color:"dark",size:"xs",leftIcon:o(u,{size:16}),onClick:()=>r(!0),disabled:!n,children:"New"})})})]}):o(p.DocsList,{collection:e.collection,docs:b,reloadDocs:()=>X()})})]})})]})};p.DocsList=e=>{let i=e.collection,l=window.__ROOT_CTX.collections[e.collection];if(!l)throw new Error(`could not find collection: ${i}`);let n=!!l.url,a=e.docs||[];function s(t){return n?z({collectionId:i,slug:t}):""}return o("div",{className:"CollectionPage__collection__docsList",children:a.map(t=>{let _=`/cms/content/${i}/${t.slug}`,d=s(t.slug),r=t.fields||{},m=h(r,l.preview?.title||"meta.title"),v=h(r,l.preview?.image||"meta.image")||l.preview?.defaultImage;return o("div",{className:"CollectionPage__collection__docsList__doc",children:[o("div",{className:"CollectionPage__collection__docsList__doc__image",children:o("a",{href:_,children:o(I,{file:v,width:120,height:90,withPlaceholder:!v?.src})})}),o("a",{className:"CollectionPage__collection__docsList__doc__content",href:_,children:[o("div",{className:"CollectionPage__collection__docsList__doc__content__header",children:[o("div",{className:"CollectionPage__collection__docsList__doc__content__header__docId",children:t.id}),o(O,{doc:t})]}),o("div",{className:"CollectionPage__collection__docsList__doc__content__title",children:m||"[UNTITLED]"}),n&&d&&o("div",{className:"CollectionPage__collection__docsList__doc__content__url",children:d})]}),o("div",{className:"CollectionPage__collection__docsList__doc__controls",children:o(B,{docId:t.id,data:t,onAction:c=>{(c.action==="archive"||c.action==="copy"||c.action==="unarchive"||c.action==="delete"||c.action==="unpublish"||c.action==="locked"||c.action==="unlocked")&&e.reloadDocs()}})})]},t.id)})})};export{p as CollectionPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as s}from"./chunk-SKQECSUR.js";import"./chunk-2EPQJUGM.js";import"./chunk-NJMNOITA.js";import"./chunk-5MV6XVGA.js";import"./chunk-AGFPVTBA.js";import"./chunk-YMBBWVBB.js";import"./chunk-BW2MKGNP.js";import"./chunk-KRNQ6L35.js";import{a as m}from"./chunk-P2Z66DHV.js";import{b as d}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import{d as t}from"./chunk-BUNR5EU3.js";import{Ga as a,g as i,j as p}from"./chunk-LROR6N3B.js";import"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";p();function h(){let{query:r}=t();m("Compare");let o=i(()=>n(r.left||""),[r.left]),e=i(()=>n(r.right||""),[r.right]);return a(d,{children:a("div",{className:"ComparePage",children:o&&e?a(s,{className:"ComparePage__diff",left:o,right:e}):a("div",{className:"ComparePage__error",children:"Invalid params, double check query params."})})})}function n(r){let[o,e]=String(r).split("@");return o&&e?{docId:o,versionId:e}:null}export{h as ComparePage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as m}from"./chunk-TPJCPCRR.js";import"./chunk-3E6CASIN.js";import{a as y}from"./chunk-MSYTAJBV.js";import{a as k}from"./chunk-TOGLZDK3.js";import{a as x}from"./chunk-FJLNXXE3.js";import{a as w}from"./chunk-GT5EQSEX.js";import{b as v}from"./chunk-D3UIZHRK.js";import"./chunk-JS6TK4OP.js";import{b as P}from"./chunk-W5DOO6ID.js";import{a as T}from"./chunk-NSOTG64N.js";import"./chunk-QHJOTXYB.js";import{a as p}from"./chunk-BW2MKGNP.js";import{b as u}from"./chunk-KRNQ6L35.js";import{a as B}from"./chunk-P2Z66DHV.js";import{b as A}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import"./chunk-BUNR5EU3.js";import{Ca as b,Da as D,Fa as i,Ga as e,Mc as S,V as g,W as f,a as d,ba as s,c as h,da as _,g as c,j as G}from"./chunk-LROR6N3B.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";G();var z={transition:"pop"};function O(a){let o=a.dataSource;return N(o.archivedAt)?e(i,{...z,label:`Archived ${L(o.archivedAt)} by ${o.archivedBy}`,children:e(s,{size:"xs",color:"gray",variant:"filled",children:"Archived"})}):N(o.publishedAt)?e(i,{...z,label:`Published ${L(o.publishedAt)} by ${o.publishedBy}`,children:e(s,{size:"xs",variant:"gradient",gradient:{from:"teal",to:"lime",deg:105},children:"Published"})}):e(s,{size:"xs",variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:"Unpublished"})}function N(a){return!!(a&&a.toMillis)}function L(a){return a?.toMillis?u(a.toMillis()):u(new Date().getTime())}function E(){B("Data Sources");let{roles:a}=T(),o=window.firebase.user.email||"",r=P(a,o);return e(A,{children:e("div",{className:"DataPage",children:[e("div",{className:"DataPage__header",children:[e(y,{size:"h1",children:"Data Sources"}),e(p,{as:"p",children:"Add data sources to sync data from external services, like Google Sheets."}),e("div",{className:"DataPage__header__buttons",children:e(w,{label:"You don't have access to create new data sources",condition:!r,children:e(_,{component:"a",color:"blue",size:"xs",href:"/cms/data/new",disabled:!r,style:r?void 0:{pointerEvents:"none"},children:"New data source"})})})]}),e(E.DataSourcesTable,{})]})})}E.DataSourcesTable=()=>{let[a,o]=d(!0),[r,I]=d([]),[l,$]=x("root::DataPage:showArchived",!1),C=t=>!!t&&t.startsWith("https://docs.google.com/spreadsheets/");async function M(){let t=await v();I(t),o(!1)}let H=c(()=>r.some(t=>!!t.archivedAt),[r]),n=c(()=>r.filter(t=>{let U=!!t.archivedAt;return l?!0:!U}),[r,l]);return h(()=>{M()},[]),e("div",{className:"DataPage__DataSourcesTable",children:[!a&&H&&e("div",{className:"DataPage__DataSourcesTable__filters",children:e(b,{size:"sm",color:"dark",label:"Show archived",checked:l,onChange:t=>$(!!t.currentTarget.checked)})}),e(k,{children:[a&&e(g,{color:"gray",size:"xl"}),!a&&n.length>0&&e(D,{verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[e("thead",{children:e("tr",{children:[e("th",{children:"id"}),e("th",{children:"description"}),e("th",{children:"type"}),e("th",{children:"url"}),e("th",{children:"status"}),e("th",{children:"last synced"}),e("th",{children:"last published"})]})}),e("tbody",{children:n.map(t=>e("tr",{children:[e("td",{children:e("a",{href:`/cms/data/${t.id}`,children:t.id})}),e("td",{children:t.description||""}),e("td",{children:t.type}),e("td",{children:C(t.url)?e("div",{className:"DataPage__DataSourcesTable__url",children:[e(i,{label:"Open spreadsheet",children:e(f,{component:"a",href:t.url,target:"_blank",rel:"noreferrer",variant:"filled",color:"green",size:"sm","aria-label":"Open spreadsheet",children:e(S,{size:16,stroke:"2.25"})})}),e("a",{className:"DataPage__DataSourcesTable__url__text",href:t.url,target:"_blank",rel:"noreferrer",children:t.url})]}):t.url||""}),e("td",{children:e(O,{dataSource:t})}),e("td",{children:e(m,{dataSource:t,action:"sync"})}),e("td",{children:e(m,{dataSource:t,action:"publish"})})]},t.id))})]}),!a&&n.length===0&&e(p,{as:"p",children:"No data sources found for this filter."})]})]})};export{E as DataPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as f}from"./chunk-TPJCPCRR.js";import"./chunk-3E6CASIN.js";import{a as g}from"./chunk-MSYTAJBV.js";import{a as h}from"./chunk-TOGLZDK3.js";import"./chunk-GT5EQSEX.js";import{c as T,d as N}from"./chunk-D3UIZHRK.js";import"./chunk-JS6TK4OP.js";import"./chunk-W5DOO6ID.js";import"./chunk-NSOTG64N.js";import"./chunk-QHJOTXYB.js";import{a as A}from"./chunk-BW2MKGNP.js";import"./chunk-KRNQ6L35.js";import{a as H}from"./chunk-P2Z66DHV.js";import{b as W}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import"./chunk-BUNR5EU3.js";import{Da as D,Fa as p,Fc as k,Ga as a,Mc as z,V as y,W as m,a as _,c as b,ca as v,da as P,j as B,na as x,oa as w}from"./chunk-LROR6N3B.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";B();function r(t){H(`Data Source: ${t.id}`);let[o,l]=_(!0),[e,u]=_(null),[n,c]=_(null),i=t.id;async function d(){let s=await T(i);if(u(s),s){let I=await N(i,{mode:"draft"});c(I)}l(!1)}b(()=>{d()},[]);function S(s){s==="sync"&&d()}return a(W,{children:a("div",{className:"DataSourcePage",children:[a("div",{className:"DataSourcePage__header",children:[a(v,{className:"DataSourcePage__header__breadcrumbs",children:[a("a",{href:"/cms/data",children:"Data"}),a("div",{children:i})]}),a("div",{className:"DataSourcePage__header__titleWrap",children:[a(g,{size:"h1",children:["Data Source: ",i]}),a("div",{className:"DataSourcePage__header__controls",children:a(p,{label:"Configure",children:a(m,{component:"a",href:`/cms/data/${t.id}/edit`,children:a(k,{size:24,stroke:"1.5"})})})})]}),e?.description&&a(A,{as:"p",children:e.description})]}),e&&a(r.SyncStatus,{dataSource:e,onAction:S}),o?a(y,{color:"gray",size:"xl"}):e?a(r.DataSection,{dataSource:e,data:n}):a("div",{className:"DataSourcePage__notFound",children:"Not Found"})]})})}r.SyncStatus=t=>{let o=t.dataSource;return a("div",{className:"DataSourcePage__SyncStatus",children:[a(g,{size:"h2",children:"Status"}),a(h,{className:"DataSourcePage__SyncStatus__content",children:a(D,{verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[a("thead",{children:a("tr",{children:[a("th",{children:"last synced"}),a("th",{children:"last published"})]})}),a("tbody",{children:a("tr",{children:[a("td",{children:a(f,{dataSource:o,action:"sync",onAction:()=>{t.onAction&&t.onAction("sync")}})}),a("td",{children:a(f,{dataSource:o,action:"publish"})})]})})]})})]})};r.DataSection=t=>{let{data:o,headers:l}=t.data||{},e=t.dataSource;if(!o)return null;let u=e.dataFormat||"map";if(e.type==="gsheet"){let n=l,c=[];if(u==="array")c=o;else if(u==="map"){let i=o;if(!n){let d=new Set;i.forEach(S=>{for(let s in S)s&&d.add(s)}),n=Array.from(d)}i.forEach(d=>{c.push(n.map(S=>d[S]||""))})}return a(r.DataSectionWrap,{dataSource:e,children:a(r.DataTable,{headers:n,rows:c})})}return e.type==="http"?a(r.DataSectionWrap,{dataSource:e,children:a(r.DefaultDataDisplay,{data:o})}):(console.log(`unsupported data type: ${e.type}`),null)};r.DataSectionWrap=t=>a("div",{className:"DataSourcePage__DataSection",children:[a("div",{className:"DataSourcePage__DataSection__header",children:[a(g,{size:"h2",children:"Data"}),a("div",{className:"DataSourcePage__DataSection__header__actions",children:[t.dataSource.url?.startsWith("https://docs.google.com/spreadsheets/")&&a(p,{label:"Open spreadsheet",children:a(m,{component:"a",href:t.dataSource.url,target:"_blank",variant:"filled",color:"green",children:a(z,{size:16,stroke:"2.25"})})}),t.dataSource.previewUrl&&a(P,{component:"a",variant:"default",size:"xs",href:t.dataSource.previewUrl,target:"_blank",children:"Preview"})]})]}),a(h,{className:"DataSourcePage__DataSection__content",children:t.children})]});r.DataTable=t=>{let o=t.headers||[],l=t.rows||[];return a("div",{className:"DataSourcePage__DataTable",children:a(D,{className:"DataSourcePage__DataTable__table",verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[o.length>0&&a("thead",{children:a("tr",{children:o.map(e=>a("th",{children:e},e))})}),a("tbody",{children:l.map((e,u)=>a("tr",{children:e.map((n,c)=>a("td",{children:n},c))},u))})]})})};r.DefaultDataDisplay=t=>{let o=t.data;return typeof o=="object"?a(w,{value:JSON.stringify(o,null,2),minRows:20,maxRows:100}):a(x,{value:String(o),minRows:12,maxRows:100})};export{r as DataSourcePage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as ta}from"./chunk-VJUMFJIX.js";import{a as na}from"./chunk-JBHRZ4EX.js";import{c as ra}from"./chunk-W6LP22IK.js";import{a as oa}from"./chunk-MSYTAJBV.js";import"./chunk-HARRKJFZ.js";import{b as U}from"./chunk-JS6TK4OP.js";import"./chunk-YDO2EDVY.js";import"./chunk-5MV6XVGA.js";import{Q as q,X as J}from"./chunk-AGFPVTBA.js";import{b as V,h as y,k as S,m as X}from"./chunk-YMBBWVBB.js";import{b as G}from"./chunk-J5E457OI.js";import{a as O,b as j}from"./chunk-QHJOTXYB.js";import"./chunk-BW2MKGNP.js";import"./chunk-KRNQ6L35.js";import{a as sa}from"./chunk-P2Z66DHV.js";import{b as N}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import{e as M}from"./chunk-BUNR5EU3.js";import{Bc as Z,Fa as p,Ga as a,Mc as aa,Qc as ea,V as W,W as w,a as r,c as k,ca as B,da as f,e as E,g as R,j as ma,jc as Y,qa as C,yb as K,zb as Q}from"./chunk-LROR6N3B.js";import"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";ma();function u(e){sa(`Translations: ${e.collection}/${e.slug}`);let[g,l]=r(!0),[h,_]=r(!1),[o,t]=r([]),[s,c]=r({}),[L,ia]=r(null),[la,F]=r(!1),[I,z]=r({}),[ca,H]=r(!1),m=e.collection,b=e.slug,i=`${m}/${b}`,da=ta(),ga=window.__ROOT_CTX.rootConfig.i18n||{},x=S((ga.locales||[]).filter(n=>!y(n))),[$,A]=ra("locale",x);async function _a(){try{let[n,d,T]=await Promise.all([na(i),V(),J(i)]);t(n),c(d),ia(T),l(!1)}catch(n){console.error(n),l(!1),_(!0)}}if(k(()=>{_a()},[]),h)return a(u.NotFound,{docId:i});function Ta(n,d,T){F(!0),z(P=>{let D={...P},v=D[n]??{};return v.source=n,v[d]=T,D[n]=v,D})}async function ua(){H(!0),await G(async()=>{console.log("EditTranslationsModal.onSave()");let n=`edit-translations-${i}`;O({id:n,loading:!0,title:"Saving translations",message:`Updating for ${i}...`,autoClose:!1,disallowClose:!0});let d=Object.values(I);console.log(d),await q(i,d),j({id:n,title:"Saved translations",message:`Updated translations for ${i}!`,autoClose:!0}),z({}),F(!1)}),H(!1)}function ha(n){$.length===x.length?A([n]):A(x)}return a(N,{children:a("div",{className:"DocTranslationsPage",children:[a("div",{className:"DocTranslationsPage__header",children:[a(B,{className:"DocTranslationsPage__header__breadcrumbs",children:[a("a",{href:`/cms/content/${m}`,children:m}),a("a",{href:`/cms/content/${m}/${b}`,children:b}),a("div",{children:"translations"})]}),a("div",{className:"DocTranslationsPage__header__titleWrap",children:a(oa,{size:"h1",children:["Translations: ",i]})}),a("div",{className:"DocTranslationsPage__header__controls",children:[L&&a("div",{className:"DocTranslationsPage__header__linkedSheet",children:a("div",{className:"DocTranslationsPage__header__linkedSheet__controls",children:[a(p,{label:"Open Google Sheet",children:a(w,{component:"a",href:U(L),target:"_blank",variant:"filled",color:"green",size:"sm",children:a(aa,{size:16,strokeWidth:2.25})})}),a(f,{variant:"default",size:"xs",leftIcon:a(Q,{size:16,strokeWidth:1.75}),children:"Import from Sheet"}),a(f,{variant:"default",size:"xs",leftIcon:a(K,{size:16,strokeWidth:1.75}),children:"Export to Sheet"})]})}),a(C,{className:"DocTranslationsPage__toolsMenu",control:a(p,{label:"Tools",children:a(w,{variant:"default",children:a(ea,{size:16})})}),size:220,children:a(C.Item,{className:"DocTranslationsPage__toolsMenu__item",icon:a(Z,{size:16}),onClick:()=>da.open({docId:i,sourceStrings:o,onPruned:n=>{c(d=>{let T={...d};return n.forEach(P=>delete T[P]),T})}}),children:"Prune unused strings"})})]})]}),a("div",{className:M("DocTranslationsPage__content",g&&"DocTranslationsPage__content--loading"),children:g?a(W,{color:"gray",size:"xl"}):a(u.Table,{locales:$,sourceStrings:o,translationsMap:s,onChange:Ta,changesMap:I,onSelectLocale:n=>ha(n)})}),a("div",{className:"DocTranslationsPage__footer",children:a("div",{className:"DocTranslationsPage__footer__buttons",children:a(f,{variant:"filled",color:"dark",disabled:!la,loading:ca,onClick:()=>ua(),children:"Save"})})})]})})}u.NotFound=e=>a(N,{children:a("div",{className:"DocTranslationsPage DocTranslationsPage--error",children:a("div",{className:"DocTranslationsPage__error",children:[a("div",{className:"DocTranslationsPage__error__icon",children:a(Y,{size:60})}),a("div",{className:"DocTranslationsPage__error__title",children:["Not found: ",e.docId]})]})})});u.Table=e=>{let g=window.__ROOT_CTX.rootConfig.i18n||{},l=S((g.locales||[]).filter(o=>!y(o))),h=R(()=>{let o={};return Object.values(e.translationsMap).forEach(t=>{o[t.source]=t}),o},[e.translationsMap]);function _(o,t){let s=h[o]||{};return{translation:X(s,t),hasChanges:!1}}return a("div",{className:"DocTranslationsPage__TableWrap",children:a("table",{className:"DocTranslationsPage__Table",children:[a("thead",{children:a("tr",{children:[a("th",{className:"DocTranslationsPage__Table__sourceCellHeader",children:a("div",{className:"DocTranslationsPage__Table__headerLabel",children:"source"})}),e.locales.map(o=>a("th",{onClick:()=>e.onSelectLocale(o),className:"DocTranslationsPage__Table__localeHeader",children:a(p,{className:"DocTranslationsPage__Table__headerTooltip",placement:"start",withArrow:!0,label:e.locales.length===l.length?`Show only ${o}`:"Show all locales",children:a("div",{className:"DocTranslationsPage__Table__headerLabel",children:o})})},o))]})}),a("tbody",{children:e.sourceStrings.map(o=>a("tr",{children:[a("td",{className:"DocTranslationsPage__Table__sourceCellWrap",children:a("div",{className:"DocTranslationsPage__Table__sourceCell",children:o})}),e.locales.map(t=>{let s=_(o,t);return a("td",{children:a(u.Textarea,{source:o,locale:t,value:s.translation,onChange:e.onChange,changesMap:e.changesMap})},t)})]},o))})]})})};u.Textarea=e=>{let g=E(null),[l,h]=r(e.value),_=null;e.locale in(e.changesMap[e.source]||{})&&(_=e.changesMap[e.source][e.locale]);let o=_!==null&&_!==e.value;function t(){window.requestAnimationFrame(()=>{let s=g.current;s.style.minHeight="auto";let c=s.scrollHeight;s.style.minHeight=`${c}px`})}return k(()=>{t()},[l]),a("textarea",{ref:g,className:M("DocTranslationsPage__Textarea",o&&"DocTranslationsPage__Textarea--hasChanges",!l&&"DocTranslationsPage__Textarea--empty"),onFocus:()=>t(),rows:1,onChange:s=>{let c=s.target.value;h(c),e.onChange(e.source,e.locale,c)},value:l})};export{u as DocTranslationsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as Be,j as Ae,k as Oe,l as q,n as Ve,o as Ue,p as We,q as $e,s as Fe}from"./chunk-4ALFT4ES.js";import"./chunk-WFQU7V3W.js";import"./chunk-XWX2622O.js";import"./chunk-SKQECSUR.js";import"./chunk-VJUMFJIX.js";import"./chunk-JBHRZ4EX.js";import"./chunk-3E6CASIN.js";import"./chunk-FBSBL476.js";import{a as je}from"./chunk-2RAVKX2Z.js";import"./chunk-HO3W4RVG.js";import"./chunk-2EPQJUGM.js";import{c as Ne}from"./chunk-NJMNOITA.js";import"./chunk-344GZOGG.js";import{b as qe}from"./chunk-W6LP22IK.js";import"./chunk-XMESZUC5.js";import"./chunk-ENQKSLGJ.js";import"./chunk-CAY5NM4Z.js";import"./chunk-MSYTAJBV.js";import"./chunk-Q7IU4QCY.js";import{b as Le,c as ae,g as ze}from"./chunk-YXSXWFLZ.js";import"./chunk-JTIQBW33.js";import"./chunk-PTPYMVFW.js";import"./chunk-2S5HMST6.js";import{a as R}from"./chunk-FJLNXXE3.js";import{a as se}from"./chunk-GT5EQSEX.js";import"./chunk-D3UIZHRK.js";import"./chunk-HARRKJFZ.js";import"./chunk-JS6TK4OP.js";import"./chunk-JDW4UORS.js";import"./chunk-YDO2EDVY.js";import"./chunk-5MV6XVGA.js";import"./chunk-AGFPVTBA.js";import"./chunk-YMBBWVBB.js";import{b as Te}from"./chunk-W5DOO6ID.js";import{a as Re}from"./chunk-NSOTG64N.js";import"./chunk-J5E457OI.js";import"./chunk-QHJOTXYB.js";import"./chunk-BW2MKGNP.js";import"./chunk-KRNQ6L35.js";import{a as Xe}from"./chunk-P2Z66DHV.js";import{b as He}from"./chunk-WMICEDOT.js";import{a as Me}from"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import{e as I}from"./chunk-BUNR5EU3.js";import{Cc as Ie,Fa as T,Ga as e,Ia as pe,Oa as ge,P as me,Qa as oe,Sa as fe,Ua as ve,W as N,Wb as De,Xb as Ce,Xc as Ee,Yc as ne,Za as Pe,a as y,ba as he,c as b,da as X,e as P,g as B,h as C,j as te,pb as we,qb as xe,rb as be,rc as Se,sb as ke,vc as ye,za as _e}from"./chunk-LROR6N3B.js";import{d as O,j as ue,k as ot}from"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";te();te();async function Ke(t,n){let a=await(await fetch("/cms/api/check.test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({check:t,docId:n})})).json();if(!a.success)throw new Error(a.error||"Check failed.");return a.data}function Je(t){let n=window.__ROOT_CTX.checks||[],o=t.docId.split("/")[0],a=n.filter(s=>!s.collections||s.collections.includes(o)),[i,r]=y({}),c=C(async s=>{r(m=>({...m,[s]:{loading:!0}}));try{let m=await Ke(s,t.docId);r(h=>({...h,[s]:{loading:!1,result:m}}))}catch(m){r(h=>({...h,[s]:{loading:!1,error:m.message||"Unknown error."}}))}},[t.docId]),l=C(async()=>{let s={};for(let m of a)s[m.id]={loading:!0};r(s);for(let m of a)try{let h=await Ke(m.id,t.docId);r(_=>({..._,[m.id]:{loading:!1,result:h}}))}catch(h){r(_=>({..._,[m.id]:{loading:!1,error:h.message||"Unknown error."}}))}},[t.docId,a]);return e("div",{className:"ChecksPanel",children:[e("div",{className:"ChecksPanel__header",children:[e("div",{className:"ChecksPanel__header__title",children:"Checks"}),e(X,{variant:"default",size:"xs",compact:!0,leftIcon:e(Se,{size:12}),onClick:l,children:"Run All"})]}),e("div",{className:"ChecksPanel__body",children:e("div",{className:"ChecksPanel__checks",children:a.map(s=>{let m=i[s.id];return e(nt,{check:s,state:m,onRun:()=>c(s.id)},s.id)})})})]})}function nt(t){let{check:n,state:o,onRun:a}=t;return e("div",{className:"ChecksPanel__check",children:[e("div",{className:"ChecksPanel__check__header",children:[e("div",{className:"ChecksPanel__check__label",children:[n.label,o?.result&&e(rt,{status:o.result.status})]}),e(X,{className:"ChecksPanel__check__runButton",variant:"default",size:"xs",compact:!0,loading:o?.loading,onClick:a,children:"Run"})]}),n.description&&e("div",{className:"ChecksPanel__check__description",children:n.description}),o?.result&&e("div",{className:I("ChecksPanel__check__result",`ChecksPanel__check__result--${o.result.status}`),children:e(Ne,{code:o.result.message})}),o?.error&&e("div",{className:"ChecksPanel__check__error",children:o.error})]})}var at={success:"green",warning:"yellow",error:"red"},it={success:Pe,warning:pe,error:ne};function rt(t){let n=at[t.status],o=it[t.status],a=t.status.charAt(0).toUpperCase()+t.status.slice(1);return e(he,{className:"ChecksPanel__statusBadge",color:n,size:"sm",variant:"filled",leftSection:e(o,{size:10}),children:a})}function Ye(t){let{device:n,expandVertically:o,iframeUrl:a,localeOptions:i,selectedLocale:r,onToggleDevice:c,onToggleExpandVertically:l,onReloadClick:s,onOpenNewTab:m,onLocaleChange:h}=t;return e("div",{className:"DocumentPagePreviewBar",children:[e("div",{className:"DocumentPagePreviewBar__devices",children:[e(T,{label:"Mobile",children:e(N,{className:I("DocumentPagePreviewBar__device",n==="mobile"&&"active"),onClick:()=>c("mobile"),children:e(ke,{size:16})})}),e(T,{label:"Tablet",children:e(N,{className:I("DocumentPagePreviewBar__device",n==="tablet"&&"active"),onClick:()=>c("tablet"),children:e(be,{size:16})})}),e(T,{label:"Desktop",children:e(N,{className:I("DocumentPagePreviewBar__device",n==="desktop"&&"active"),onClick:()=>c("desktop"),children:e(we,{size:16})})}),e(T,{label:"Expand",children:e(N,{className:I("DocumentPagePreviewBar__device",o&&"active"),"aria-pressed":o,disabled:n==="",onClick:l,children:e(fe,{size:16})})})]}),e("div",{className:"DocumentPagePreviewBar__navbar",children:e("div",{className:"DocumentPagePreviewBar__navbar__url",children:a})}),e("div",{className:"DocumentPagePreviewBar__locales",children:e(_e,{data:i,placeholder:"Locale",radius:"xl",size:"xs",required:!0,icon:e(Ee,{size:16,strokeWidth:1.5}),value:r,onChange:_=>{h(_)}})}),e("div",{className:"DocumentPagePreviewBar__buttons",children:[e(T,{label:"Reload",children:e(N,{className:"DocumentPagePreviewBar__button DocumentPagePreviewBar__button--reload",onClick:s,children:e(ye,{size:16})})}),e(T,{label:"Open new tab",children:e(N,{className:"DocumentPagePreviewBar__button DocumentPagePreviewBar__button--openNewTab",onClick:m,children:e(oe,{size:16})})})]})]})}te();function Qe(t){let n=t.docId.split("/")[0],o=ze(n),a=q(),i=P(null),[r,c]=y(""),[l,s]=y([]),[m,h]=y(!1),_=P("");_.current=r;let v=P(o.schema?.fields||[]);v.current=o.schema?.fields||[];let D=P(o.schema?.types||{});D.current=o.schema?.types||{};let x=B(()=>Ae(u=>{let k=u.trim();if(!k){s([]),h(!1);return}let S=a.controller?.getData()?.fields||{},L=$e(k,S,v.current,D.current);s(L),h(!0)},150),[a.controller]);b(()=>{x(r)},[r,x]),Ve(()=>{_.current.trim()&&x(_.current)}),b(()=>{t.autoFocus&&requestAnimationFrame(()=>{i.current?.focus(),i.current?.select()})},[t.autoFocus]),b(()=>{let u=()=>{i.current?.focus(),i.current?.select()};return window.addEventListener("root:focus-search",u),()=>window.removeEventListener("root:focus-search",u)},[]);let g=u=>{lt(u)};return e("div",{className:"SearchPanel",children:[e("div",{className:"SearchPanel__header",children:[e("div",{className:"SearchPanel__header__title",children:"Search"}),t.onClose&&e(N,{size:"xs",onClick:t.onClose,title:"Close search",children:e(ne,{size:14})})]}),e("div",{className:"SearchPanel__searchInput",children:[e("span",{className:"SearchPanel__searchInput__icon",children:e(Ie,{size:14})}),e("input",{ref:i,type:"text",className:"SearchPanel__searchInput__input",value:r,onInput:u=>c(u.currentTarget.value),onKeyDown:u=>{u.key==="Escape"&&t.onClose&&(u.preventDefault(),t.onClose())},placeholder:"Search field values\u2026",autoComplete:"off",spellcheck:!1})]}),e("div",{className:"SearchPanel__body",children:[!m&&!r.trim()&&e("div",{className:"SearchPanel__empty",children:"Type a query above to search field values in this document."}),m&&l.length===0&&e("div",{className:"SearchPanel__empty",children:["No matches for ",e("strong",{children:r}),"."]}),l.length>0&&e(O,{children:[e("div",{className:"SearchPanel__resultsCount",children:[l.length," ",l.length===1?"match":"matches"]}),e("ul",{className:"SearchPanel__results",children:l.map((u,k)=>e(ct,{result:u,onClick:()=>g(u)},`${u.deepKey}:${k}`))})]})]})]})}function ct(t){let{result:n}=t;return e("li",{className:"SearchPanel__result",children:e("button",{type:"button",className:"SearchPanel__result__button",onClick:t.onClick,children:[e("div",{className:"SearchPanel__result__label",children:n.label}),e("div",{className:"SearchPanel__result__snippet",children:st(n.snippet,n.matches)}),e("div",{className:"SearchPanel__result__meta",children:[e("span",{className:"SearchPanel__result__type",children:n.fieldType}),n.richTextBlock&&e("span",{className:"SearchPanel__result__badge",children:"in block"}),n.richTextInline&&e("span",{className:"SearchPanel__result__badge",children:"inline"})]})]})})}function st(t,n){if(!n||n.length===0)return t;let o=[],a=0;for(let i of n)i.start>a&&o.push({text:t.slice(a,i.start),match:!1}),o.push({text:t.slice(i.start,i.end),match:!0}),a=i.end;return a<t.length&&o.push({text:t.slice(a),match:!1}),o.map((i,r)=>i.match?e("mark",{children:i.text},r):e("span",{children:i.text},r))}function lt(t){if(window.postMessage({scrollToDeeplink:{deepKey:t.deepKey}},"*"),t.richTextBlock){let n=t.richTextBlock;setTimeout(()=>{window.dispatchEvent(new CustomEvent(Ue,{detail:n}))},350)}else if(t.richTextInline){let n=t.richTextInline;setTimeout(()=>{window.dispatchEvent(new CustomEvent(We,{detail:n}))},350)}}ot();te();var dt=ue(null);function K(t){let{className:n,localStorageId:o,children:a}=t,[i,r]=R(`root::SplitPanel:${o}`,350),[c,l]=y(!1),[s,m]=y(0),h=B(()=>new Set,[]),_=P(null),v=P(null),D={onResize:g=>(h.add(g),()=>{h.delete(g)})};if(b(()=>{let g=()=>l(!1);window.addEventListener("mouseup",g);let u=_.current;return u&&m(u.getBoundingClientRect().left),()=>window.removeEventListener("mouseup",g)},[]),b(()=>{let g=u=>{let k=u.clientX-s;r(k),h.forEach(S=>S())};return c&&window.addEventListener("mousemove",g),()=>window.removeEventListener("mousemove",g)},[c]),a?.length!==2)throw new Error("SplitPanel should have two <SplitPanel.Item> children.");let x={"--panel-size":`${i}px`};return e(dt.Provider,{value:D,children:e("div",{className:I(n,"SplitPanel",c&&"dragging"),ref:_,style:x,children:[a[0],e("div",{className:"SplitPanel__divider",ref:v,onMouseDown:()=>l(!0)}),a[1]]})})}K.Item=t=>e("div",{className:I("SplitPanel__item",t.className,t.fluid?"fluid":"static"),children:t.children});function le(t,n,o=""){let a=ae({collectionId:t,slug:n}),i=new URLSearchParams(window.location.search);i.set("preview","true"),i.delete("locale"),i.delete("modal");let r=`${i.toString()}${window.location.hash}`;return o?`${ae({collectionId:t,slug:n,locale:o})}?${r}`:`${a}?${r}`}function ut(t,n){let o=new URL(n,window.location.origin);try{let a=t.contentWindow?.location.href;if(a&&!a.startsWith("about:blank")){let i=new URL(a);i.origin===o.origin&&i.pathname===o.pathname&&(i.searchParams.forEach((r,c)=>{o.searchParams.set(c,r)}),o.hash=i.hash)}}catch{}return o.searchParams.set("preview","true"),o.toString()}function Ze(t){let n=t.collection,o=t.slug,a=`${n}/${o}`,{roles:i}=Re(),r=window.firebase.user.email||"",c=Te(i,r);return e(Oe,{docId:a,readOnly:!c,children:e(mt,{...t,canEdit:c})})}function mt(t){let n=t.canEdit,o=t.collection,a=t.slug,i=`${o}/${a}`;Xe(i);let r=window.__ROOT_CTX.collections[o],c=q(),l=!!r?.url,[s,m]=R(`root::DocumentPage::previewVisible::${o}`,l),h=B(()=>(window.__ROOT_CTX.checks||[]).some(f=>!f.collections||f.collections.includes(o)),[o]),[_,v]=R("root::DocumentPage::checksVisible",!1),D=P(_);D.current=_;let[x,g]=R("root::DocumentPage::searchVisible",!1),u=P(x);u.current=x;let k=Me(),[S,L]=R("root::DocumentPage::aiVisible",!1),M=P(S);M.current=S,b(()=>{window.dispatchEvent(new CustomEvent("root:checks-visible",{detail:_}))},[_]),b(()=>{window.dispatchEvent(new CustomEvent("root:search-visible",{detail:x}))},[x]),b(()=>{window.dispatchEvent(new CustomEvent("root:ai-visible",{detail:S}))},[S]);let[U,J]=R("root::DocumentPage::searchPanelWidth",360),[W,$]=y(U),[F,H]=y(!1),Y=P(null);if(b(()=>{let p=()=>{let f=!D.current;v(()=>f),f&&(g(()=>!1),L(()=>!1))};return window.addEventListener("root:toggle-checks",p),()=>window.removeEventListener("root:toggle-checks",p)},[]),b(()=>{let p=()=>{let f=!u.current;g(()=>f),f&&(v(()=>!1),L(()=>!1),requestAnimationFrame(()=>{window.dispatchEvent(new CustomEvent("root:focus-search"))}))};return window.addEventListener("root:toggle-search",p),()=>window.removeEventListener("root:toggle-search",p)},[]),b(()=>{let p=()=>{let f=!M.current;L(()=>f),f&&(v(()=>!1),g(()=>!1))};return window.addEventListener("root:toggle-ai",p),()=>window.removeEventListener("root:toggle-ai",p)},[]),b(()=>{if(!F)return;let p=A=>{let V=Y.current;if(!V)return;let re=V.getBoundingClientRect(),ce=Math.max(240,Math.min(re.right-A.clientX,800));$(ce)},f=()=>{H(!1),$(A=>(J(()=>A),A))};return window.addEventListener("mousemove",p),window.addEventListener("mouseup",f),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",f)}},[F]),!r)return e("div",{children:"Could not find collection."});let ie=C(()=>{if(!l)return;let p=le(o,a),f=window.open(p,"_blank","noopener,noreferrer");f&&f.focus()},[l,o,a]),Q=C(()=>{n&&c.controller&&c.controller.flush()},[n,c.controller]),G=Be(),j=C(()=>{let p=c.controller?.getData()?.fields||{};G.open({data:p,onSave:f=>{c.controller&&f&&typeof f=="object"&&(c.controller.updateKey("fields",f),c.controller.flush()),G.close()}})},[c.controller]),d=C(()=>{window.dispatchEvent(new CustomEvent("root:toggle-search"))},[]),w=C(()=>{k&&window.dispatchEvent(new CustomEvent("root:toggle-ai"))},[k]),E=C(()=>{L(()=>!1)},[L]);return me([["mod+S",Q],["mod+shift+F",d],["mod+I",w]]),e(He,{children:e("div",{className:I("DocumentPage__layout",F&&"DocumentPage__layout--dragging"),ref:Y,children:[e(K,{className:"DocumentPage",localStorageId:"DocumentPage",children:[e(K.Item,{className:I("DocumentPage__side",(!l||!s)&&"DocumentPage__side--expanded"),children:[e("div",{className:"DocumentPage__side__header",children:[e("div",{className:"DocumentPage__side__header__nav",children:[e("a",{href:`/cms/content/${o}`,children:e(N,{className:"DocumentPage__side__header__back",children:e(ge,{size:16})})}),e("div",{className:"DocumentPage__side__header__docId",children:i})]}),e("div",{className:"DocumentPage__side__header__buttons",children:[e(se,{label:"You don't have access to edit this document",condition:!n,children:e(X,{className:"DocumentPage__side__header__saveButton",variant:"filled",color:"dark",size:"xs",compact:!0,leftIcon:e(xe,{size:16}),onClick:()=>Q(),disabled:!n,children:"Save"})}),e(se,{label:"You don't have access to edit this document",condition:!n,children:e(T,{label:"Edit JSON",disabled:!n,children:e(N,{className:"DocumentPage__side__header__editJson",onClick:()=>j(),disabled:!n,children:e(ve,{size:14})})})}),l&&e(O,{children:[e(T,{label:s?"Hide preview":"Show preview",children:e(N,{className:"DocumentPage__side__header__previewToggle",onClick:()=>m(!s),children:s?e(De,{size:16}):e(Ce,{size:16})})}),!s&&e(T,{label:"Open preview in new tab",children:e(N,{className:"DocumentPage__side__header__openNewTab",onClick:ie,children:e(oe,{size:16})})})]})]})]}),e("div",{className:I("DocumentPage__side__editor",(!l||!s)&&!_&&!x&&!S&&"DocumentPage__side__editor--centered"),children:e(Fe,{docId:i})})]}),e(K.Item,{className:I("DocumentPage__main",(!l||!s)&&"DocumentPage__main--hidden"),fluid:!0,children:l&&s&&e(Ze.Preview,{docId:i},i)})]}),h&&_&&e(_t,{docId:i}),x&&e(O,{children:[e("div",{className:"DocumentPage__searchDivider",onMouseDown:()=>H(!0)}),e("div",{className:"DocumentPage__search",style:{flexBasis:`${W}px`},children:e(Qe,{docId:i,autoFocus:!0,onClose:()=>g(()=>!1)})})]}),k&&S&&e(ht,{docId:i,onClose:E})]})})}function ht(t){let[n,o]=R("root::DocumentPage::aiPanelWidth",420),[a,i]=y(n),r=P(null),c=P(a),l=P(),s=B(()=>e(je,{variant:"panel",docContext:{docId:t.docId},onClose:t.onClose}),[t.docId,t.onClose]),m=C(()=>{let h=r.current?.parentElement;if(!h)return;c.current=a,h.classList.add("DocumentPage__layout--dragging");let _=x=>{let g=r.current?.parentElement;if(!g)return;let u=g.getBoundingClientRect(),k=Math.max(280,Math.min(u.right-x.clientX,800));c.current=k,i(k)},v=()=>{h.classList.remove("DocumentPage__layout--dragging"),window.removeEventListener("mousemove",_),window.removeEventListener("mouseup",D),l.current=void 0},D=()=>{v(),o(()=>c.current)};l.current=v,window.addEventListener("mousemove",_),window.addEventListener("mouseup",D)},[a,o]);return b(()=>()=>l.current?.(),[]),e(O,{children:[e("div",{className:"DocumentPage__aiDivider",ref:r,onMouseDown:m}),e("div",{className:"DocumentPage__ai",style:{flexBasis:`${a}px`},children:s})]})}function _t(t){let[n,o]=R("root::DocumentPage::checksPanelWidth",360),[a,i]=y(n),r=P(null),c=P(a),l=P(),s=B(()=>e(Je,{docId:t.docId}),[t.docId]),m=C(()=>{let h=r.current?.parentElement;if(!h)return;c.current=a,h.classList.add("DocumentPage__layout--dragging");let _=x=>{let g=r.current?.parentElement;if(!g)return;let u=g.getBoundingClientRect(),k=Math.max(200,Math.min(u.right-x.clientX,800));c.current=k,i(k)},v=()=>{h.classList.remove("DocumentPage__layout--dragging"),window.removeEventListener("mousemove",_),window.removeEventListener("mouseup",D),l.current=void 0},D=()=>{v(),o(()=>c.current)};l.current=v,window.addEventListener("mousemove",_),window.addEventListener("mouseup",D)},[a,o]);return b(()=>()=>l.current?.(),[]),e(O,{children:[e("div",{className:"DocumentPage__checksDivider",ref:r,onMouseDown:m}),e("div",{className:"DocumentPage__checks",style:{flexBasis:`${a}px`},children:s})]})}var Ge={mobile:[430,932],tablet:[768,1024],desktop:[1440,800]};function pt(t){let n=new Intl.DisplayNames(["en"],{type:"language"}),a=t.split("_")[0];return`${n.of(a)||t} (${t})`}Ze.Preview=t=>{let n=q();if(n.loading)return null;let[o,a]=t.docId.split("/"),r=window.__ROOT_CTX.collections[o];if(!r)throw new Error(`collection not found: ${o}`);if(!r.url)return null;let c=r.domain||window.__ROOT_CTX.rootConfig.domain||"https://example.com",l=Le({collectionId:o,slug:a}),s=ae({collectionId:o,slug:a}),m=`${c}${l}`,[h,_]=y(m),[v,D]=R("root::DocumentPage::preview::device",""),[x,g]=R("root::DocumentPage::preview::expandVertically",!1),[u,k]=y({"--iframe-width":"100%","--iframe-height":"100%","--iframe-scale":"1"}),[S,L]=qe("locale",""),M=P(null),U=P(null),J=n.controller.getLocales()||[],W=le(o,a,S),$=P(W);$.current=W;let F=B(()=>[{value:"",label:"Select locale"},...J.map(d=>({value:d,label:pt(d)}))],[J]);function H(){if(document.hidden)return;let d=M.current,w=ut(d,$.current);d.src="about:blank",window.requestAnimationFrame(()=>{d.src!==w?d.src=w:d.contentWindow.location.reload()})}b(()=>{let d=M.current;function w(){let p=d.contentWindow;if(p&&s===l&&!p.location.href.startsWith("about:blank")){let f=p.location;_(`${c}${f.pathname}`)}}d.addEventListener("load",w);let E=n.controller?.onFlush(()=>{H()});return()=>{E(),d.removeEventListener("load",w)}},[]),b(()=>{let d=M.current;d.src=W},[S]);let Y=C(d=>{D(w=>{let E=w===d?"":d;return E===""&&g(!1),E})},[D,g]),ie=C(()=>{D(d=>(d&&g(w=>!w),d))},[D,g]),Q=C(()=>{n.controller&&n.controller.flush().then(()=>H())},[n.controller]),G=C(()=>{let d=le(o,a,S),w=window.open(d,"_blank","noopener,noreferrer");w&&w.focus()},[o,a,S]),j=C(()=>{if(v===""){let z={"--iframe-width":"100%","--iframe-height":"100%","--iframe-scale":"1"};k(ee=>ee["--iframe-width"]===z["--iframe-width"]&&ee["--iframe-height"]===z["--iframe-height"]&&ee["--iframe-scale"]===z["--iframe-scale"]?ee:z);return}let d=U.current;if(!d)return;let w=d.getBoundingClientRect(),[E,p]=Ge[v],f=20,A=Math.max(w.width-2*f,0),V=Math.max(w.height-2*f,0),re=A>0&&E>0?A/E:1,ce=V>0&&p>0?V/p:1,et=Math.min(re,ce,1),de=Number(et.toFixed(4))||1,tt=x?`${Math.max(V-28,0)/de}px`:`${p}px`,Z={"--iframe-width":`${E}px`,"--iframe-height":tt,"--iframe-scale":String(de)};k(z=>z["--iframe-width"]===Z["--iframe-width"]&&z["--iframe-height"]===Z["--iframe-height"]&&z["--iframe-scale"]===Z["--iframe-scale"]?z:Z)},[v,x]);return b(()=>{j();let d=U.current;if(!d)return;let w=0,E=()=>{window.cancelAnimationFrame(w),w=window.requestAnimationFrame(j)},p=new window.ResizeObserver(E);return p.observe(d),window.addEventListener("resize",E),()=>{window.cancelAnimationFrame(w),p.disconnect(),window.removeEventListener("resize",E)}},[j]),e("div",{className:"DocumentPage__main__preview",children:[e(Ye,{device:v,expandVertically:x,iframeUrl:h,localeOptions:F,selectedLocale:S,onToggleDevice:Y,onToggleExpandVertically:ie,onReloadClick:Q,onOpenNewTab:G,onLocaleChange:L}),e("div",{className:"DocumentPage__main__previewFrame","data-device":v||"full",ref:U,style:u,children:[e("div",{className:"DocumentPage__main__previewFrame__deviceLabel",style:{display:v?void 0:"none"},children:v?`${v}: ${Ge[v].join("x")}`:""}),e("div",{className:"DocumentPage__main__previewFrame__iframeWrap",children:e("iframe",{ref:M,title:"iframe preview"})})]})]})};export{Ze as DocumentPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as H}from"./chunk-TVYAZN2Q.js";import"./chunk-3E6CASIN.js";import{a as B}from"./chunk-MSYTAJBV.js";import{a as F}from"./chunk-TOGLZDK3.js";import{a as _}from"./chunk-GT5EQSEX.js";import{c as u,f as A,g as E,j as T,l as z}from"./chunk-D3UIZHRK.js";import{a as w,c as p}from"./chunk-HARRKJFZ.js";import"./chunk-JS6TK4OP.js";import"./chunk-JDW4UORS.js";import{a as N}from"./chunk-W5DOO6ID.js";import{a as M}from"./chunk-NSOTG64N.js";import"./chunk-J5E457OI.js";import{a as s,b as r}from"./chunk-QHJOTXYB.js";import{a as m}from"./chunk-BW2MKGNP.js";import"./chunk-KRNQ6L35.js";import{a as L}from"./chunk-P2Z66DHV.js";import{b as O}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import{d as y}from"./chunk-BUNR5EU3.js";import{$c as $,Fa as n,Ga as e,La as I,W as l,a as D,c as x,ca as P,ib as k,j as K,wc as U}from"./chunk-LROR6N3B.js";import{d as S}from"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";K();function ve(a){L(`Edit Data Source: ${a.id}`);let{route:b}=y(),[v,h]=D(null),i=w(),f=p(),{roles:g}=M(),R=window.firebase.user.email||"",t=N(g,R);x(()=>{u(a.id).then(o=>{h(o)})},[a.id]);function W(){let o=`delete-data-source-${a.id}`,d=i.openConfirmModal({...f,title:"Delete data source",children:e(m,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to delete data source ",e("code",{children:a.id}),"? All previously synced data will be deleted. There is no undo."]}),labels:{confirm:"Delete",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{s({id:o,title:"Deleting data source",message:`Deleting ${a.id} and synced data...`,loading:!0,autoClose:!1}),await z(a.id),r({id:o,title:"Deleted data source",message:`Successfully deleted ${a.id}`,loading:!1,autoClose:5e3}),i.closeModal(d),b("/cms/data")}})}function Y(){let o=`archive-data-source-${a.id}`,d=!!v?.publishedAt,c=i.openConfirmModal({...f,title:"Archive data source",children:e(m,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to archive data source ",e("code",{children:a.id}),"? Archived data sources cannot be synced or published.",d&&e(S,{children:[" ","Note: previously published data will remain available until the data source is unpublished."]})]}),labels:{confirm:"Archive",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{s({id:o,title:"Archiving data source",message:`Archiving ${a.id}...`,loading:!0,autoClose:!1}),await A(a.id);let J=await u(a.id);h(J),r({id:o,title:"Archived data source",message:`Successfully archived ${a.id}`,loading:!1,autoClose:5e3}),i.closeModal(c),b("/cms/data")}})}function j(){let o=`unarchive-data-source-${a.id}`,d=i.openConfirmModal({...f,title:"Unarchive data source",children:e(m,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to unarchive data source ",e("code",{children:a.id}),"?"]}),labels:{confirm:"Unarchive",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"dark",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{s({id:o,title:"Unarchiving data source",message:`Unarchiving ${a.id}...`,loading:!0,autoClose:!1}),await E(a.id);let c=await u(a.id);h(c),r({id:o,title:"Unarchived data source",message:`Successfully unarchived ${a.id}`,loading:!1,autoClose:5e3}),i.closeModal(d),b(`/cms/data/${a.id}`)}})}function q(){let o=`unpublish-data-source-${a.id}`,d=i.openConfirmModal({...f,title:"Unpublish data source",children:e(m,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to unpublish data source ",e("code",{children:a.id}),"? The published data will be removed and will no longer be available to production. There is no undo."]}),labels:{confirm:"Unpublish",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{s({id:o,title:"Unpublishing data source",message:`Unpublishing ${a.id}...`,loading:!0,autoClose:!1}),await T(a.id);let c=await u(a.id);h(c),r({id:o,title:"Unpublished data source",message:`Successfully unpublished ${a.id}`,loading:!1,autoClose:5e3}),i.closeModal(d)}})}let G=!!v?.publishedAt,C=!!v?.archivedAt;return e(O,{children:e("div",{className:"EditDataSourcePage",children:[e("div",{className:"EditDataSourcePage__header",children:[e(P,{className:"EditDataSourcePage__header__breadcrumbs",children:[e("a",{href:"/cms/data",children:"Data Sources"}),e("a",{href:`/cms/data/${a.id}`,children:a.id}),e("div",{children:"Edit"})]}),e("div",{className:"EditDataSourcePage__header__titleWrap",children:[e(B,{size:"h1",children:["Edit Data Source: ",a.id]}),e("div",{className:"EditDataSourcePage__header__controls",children:[G&&!C&&e(_,{label:"You don't have access to unpublish data sources",condition:!t,children:e(n,{label:"Unpublish",disabled:!t,children:e(l,{onClick:q,loading:!g,disabled:!t,children:e(k,{size:20,stroke:"1.5"})})})}),e(_,{label:"You don't have access to archive data sources",condition:!t,children:C?e(n,{label:"Unarchive",disabled:!t,children:e(l,{onClick:j,loading:!g,disabled:!t,children:e(U,{size:20,stroke:"1.5"})})}):e(n,{label:"Archive",disabled:!t,children:e(l,{onClick:Y,loading:!g,disabled:!t,children:e(I,{size:20,stroke:"1.5"})})})}),e(n,{label:"Delete",children:e(l,{onClick:W,children:e($,{size:20,stroke:"1.5"})})})]})]})]}),e(F,{className:"EditDataSourcePage__form",children:e(H,{dataSourceId:a.id})})]})})}export{ve as EditDataSourcePage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as k}from"./chunk-SENZVSVZ.js";import"./chunk-N3JSLTMV.js";import"./chunk-XWX2622O.js";import{a as z}from"./chunk-MSYTAJBV.js";import"./chunk-YXSXWFLZ.js";import"./chunk-JTIQBW33.js";import"./chunk-PTPYMVFW.js";import{d as s,f as E,g as w}from"./chunk-2S5HMST6.js";import"./chunk-FJLNXXE3.js";import{a as I}from"./chunk-GT5EQSEX.js";import"./chunk-D3UIZHRK.js";import{a as x,c as P}from"./chunk-HARRKJFZ.js";import"./chunk-JS6TK4OP.js";import"./chunk-JDW4UORS.js";import"./chunk-YDO2EDVY.js";import"./chunk-5MV6XVGA.js";import"./chunk-AGFPVTBA.js";import"./chunk-YMBBWVBB.js";import{a as T}from"./chunk-W5DOO6ID.js";import{a as A}from"./chunk-NSOTG64N.js";import"./chunk-J5E457OI.js";import{a as h,b as f}from"./chunk-QHJOTXYB.js";import{a as g}from"./chunk-BW2MKGNP.js";import"./chunk-KRNQ6L35.js";import{a as U}from"./chunk-P2Z66DHV.js";import{b as $}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import{d as C}from"./chunk-BUNR5EU3.js";import{Fa as m,Ga as e,La as y,W as c,a as v,c as R,ca as b,j as B,wc as p}from"./chunk-LROR6N3B.js";import"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";B();function se(i){U(`Edit Release: ${i.id}`);let{route:u}=C(),[N,t]=v(null),l=x(),_=P(),{roles:d}=A(),M=window.firebase.user.email||"",o=T(d,M);R(()=>{s(i.id).then(a=>{t(a)})},[i.id]);function L(){let a=`archive-release-${i.id}`,n=l.openConfirmModal({..._,title:"Archive release",children:e(g,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to archive release ",e("code",{children:i.id}),"?"]}),labels:{confirm:"Archive",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{h({id:a,title:"Archiving release",message:`Archiving ${i.id}...`,loading:!0,autoClose:!1}),await E(i.id);let r=await s(i.id);t(r),f({id:a,title:"Archived release",message:`Successfully archived ${i.id}`,loading:!1,autoClose:5e3}),l.closeModal(n),u("/cms/releases")}})}function S(){let a=`unarchive-release-${i.id}`,n=l.openConfirmModal({..._,title:"Unarchive release",children:e(g,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to unarchive release ",e("code",{children:i.id}),"?"]}),labels:{confirm:"Unarchive",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"dark",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{h({id:a,title:"Unarchiving release",message:`Unarchiving ${i.id}...`,loading:!0,autoClose:!1}),await w(i.id);let r=await s(i.id);t(r),f({id:a,title:"Unarchived release",message:`Successfully unarchived ${i.id}`,loading:!1,autoClose:5e3}),l.closeModal(n),u(`/cms/releases/${i.id}`)}})}return e($,{children:e("div",{className:"EditReleasePage",children:[e("div",{className:"EditReleasePage__header",children:[e(b,{className:"EditReleasePage__header__breadcrumbs",children:[e("a",{href:"/cms/releases",children:"Releases"}),e("a",{href:`/cms/releases/${i.id}`,children:i.id}),e("div",{children:"Edit"})]}),e("div",{className:"EditReleasePage__header__titleWrap",children:[e(z,{size:"h1",children:["Edit Release: ",i.id]}),e("div",{className:"EditReleasePage__header__controls",children:e(I,{label:"You don't have access to archive releases",condition:!o,children:N?.archivedAt?e(m,{label:"Unarchive",disabled:!o,children:e(c,{onClick:S,loading:!d,disabled:!o,children:e(p,{size:20,stroke:"1.5"})})}):e(m,{label:"Archive",disabled:!o,children:e(c,{onClick:L,loading:!d,disabled:!o,children:e(y,{size:20,stroke:"1.5"})})})})})]})]}),e(k,{releaseId:i.id})]})})}export{se as EditReleasePage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as n}from"./chunk-FBSBL476.js";import{a}from"./chunk-2RAVKX2Z.js";import"./chunk-HO3W4RVG.js";import"./chunk-2EPQJUGM.js";import"./chunk-NJMNOITA.js";import"./chunk-344GZOGG.js";import{b as i}from"./chunk-W6LP22IK.js";import"./chunk-YDO2EDVY.js";import"./chunk-5MV6XVGA.js";import{a as f}from"./chunk-P2Z66DHV.js";import"./chunk-VD6G5NV4.js";import"./chunk-BUNR5EU3.js";import{Ga as o,c as r,e as t,j as m}from"./chunk-LROR6N3B.js";import"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";m();function v(){f("Root AI");let[e]=i("docId"),d=t(!1);return r(()=>{d.current||(d.current=!0,n({type:"ready",docId:e||void 0}))},[e]),o("div",{className:"EmbeddedAIPage",children:o(a,{variant:"panel",docContext:e?{docId:e}:void 0})})}export{v as EmbeddedAIPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./chunk-NWHGT476.js";import"./chunk-ENQKSLGJ.js";import"./chunk-CAY5NM4Z.js";import{a}from"./chunk-MSYTAJBV.js";import"./chunk-TOGLZDK3.js";import"./chunk-JS6TK4OP.js";import"./chunk-KRNQ6L35.js";import{a as i}from"./chunk-P2Z66DHV.js";import{b as g}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import"./chunk-BUNR5EU3.js";import{Ga as o}from"./chunk-LROR6N3B.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";function L(){return i("Action Logs"),o(g,{children:o("div",{className:"LogsPage",children:[o("div",{className:"LogsPage__header",children:o(a,{size:"h1",children:"Action Logs"})}),o(e,{})]})})}export{L as LogsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as d}from"./chunk-TVYAZN2Q.js";import"./chunk-3E6CASIN.js";import{a as r}from"./chunk-MSYTAJBV.js";import"./chunk-D3UIZHRK.js";import"./chunk-JS6TK4OP.js";import"./chunk-JDW4UORS.js";import"./chunk-J5E457OI.js";import"./chunk-QHJOTXYB.js";import"./chunk-KRNQ6L35.js";import{a as o}from"./chunk-P2Z66DHV.js";import{b as t}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import"./chunk-BUNR5EU3.js";import{Ga as a,ca as e}from"./chunk-LROR6N3B.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";function n(){return o("New Data Source"),a(t,{children:a("div",{className:"NewDataSourcePage",children:[a("div",{className:"NewDataSourcePage__header",children:[a(e,{className:"NewDataSourcePage__header__breadcrumbs",children:[a("a",{href:"/cms/data",children:"Data Sources"}),a("div",{children:"New"})]}),a(r,{size:"h1",children:"Add Data Source"})]}),a(d,{buttonLabel:"Create data source"})]})})}export{n as NewDataSourcePage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as m}from"./chunk-SENZVSVZ.js";import"./chunk-N3JSLTMV.js";import"./chunk-XWX2622O.js";import{a as r}from"./chunk-MSYTAJBV.js";import"./chunk-YXSXWFLZ.js";import"./chunk-JTIQBW33.js";import"./chunk-PTPYMVFW.js";import"./chunk-2S5HMST6.js";import"./chunk-FJLNXXE3.js";import"./chunk-GT5EQSEX.js";import"./chunk-D3UIZHRK.js";import"./chunk-HARRKJFZ.js";import"./chunk-JS6TK4OP.js";import"./chunk-JDW4UORS.js";import"./chunk-YDO2EDVY.js";import"./chunk-5MV6XVGA.js";import"./chunk-AGFPVTBA.js";import"./chunk-YMBBWVBB.js";import"./chunk-W5DOO6ID.js";import"./chunk-NSOTG64N.js";import"./chunk-J5E457OI.js";import"./chunk-QHJOTXYB.js";import"./chunk-BW2MKGNP.js";import"./chunk-KRNQ6L35.js";import{a as d}from"./chunk-P2Z66DHV.js";import{b as s}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import"./chunk-BUNR5EU3.js";import{Ga as e,ca as a}from"./chunk-LROR6N3B.js";import"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";function w(){return d("New Release"),e(s,{children:e("div",{className:"NewReleasePage",children:[e("div",{className:"NewReleasePage__header",children:[e(a,{className:"NewReleasePage__header__breadcrumbs",children:[e("a",{href:"/cms/releases",children:"Releases"}),e("div",{children:"New"})]}),e(r,{size:"h1",children:"Add Release"})]}),e(m,{buttonLabel:"Create release"})]})})}export{w as NewReleasePage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as G}from"./chunk-UUVAD4U4.js";import{a as j}from"./chunk-RHAJNURN.js";import{c as Y}from"./chunk-NJMNOITA.js";import{a as m}from"./chunk-MSYTAJBV.js";import{a as S}from"./chunk-TOGLZDK3.js";import{f as M}from"./chunk-PTPYMVFW.js";import{d as $,h as B,k as E}from"./chunk-2S5HMST6.js";import{a as f}from"./chunk-GT5EQSEX.js";import"./chunk-D3UIZHRK.js";import{a as T,c as k}from"./chunk-HARRKJFZ.js";import"./chunk-JS6TK4OP.js";import"./chunk-JDW4UORS.js";import"./chunk-5MV6XVGA.js";import"./chunk-AGFPVTBA.js";import"./chunk-YMBBWVBB.js";import{a as W}from"./chunk-W5DOO6ID.js";import{a as U}from"./chunk-NSOTG64N.js";import{b as v}from"./chunk-J5E457OI.js";import{a as x,b as I}from"./chunk-QHJOTXYB.js";import{a as O}from"./chunk-BW2MKGNP.js";import{c as z}from"./chunk-KRNQ6L35.js";import{a as F}from"./chunk-P2Z66DHV.js";import{b as q}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import"./chunk-BUNR5EU3.js";import{Da as N,Fa as u,Fc as H,Ga as e,V as C,W as D,a as c,c as w,ca as A,da as r,j as V}from"./chunk-LROR6N3B.js";import{d as L}from"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";V();function d(t){let[o,i]=c(!0),[a,s]=c(null),[_,h]=c(0),l=t.id;F(`Release: ${l}`);async function p(){i(!0),await v(async()=>{let n=await $(l);s(n),h(z())}),i(!1)}w(()=>{p()},[]);function P(n){console.log("onAction()",n),p()}return e(q,{children:e("div",{className:"ReleasePage",children:[e("div",{className:"ReleasePage__header",children:[e(A,{className:"ReleasePage__header__breadcrumbs",children:[e("a",{href:"/cms/releases",children:"Releases"}),e("div",{children:l})]}),e("div",{className:"ReleasePage__header__titleWrap",children:[e(m,{size:"h1",children:["Release: ",l]}),e("div",{className:"ReleasePage__header__controls",children:e(u,{label:"Configure",children:e(D,{component:"a",href:`/cms/releases/${t.id}/edit`,children:e(H,{size:24,stroke:"1.5"})})})})]}),a?.description&&e(Y,{className:"ReleasePage__header__description",code:a.description})]}),o?e(C,{color:"gray",size:"xl"}):e(L,{children:[a&&e(d.PublishStatus,{release:a,onAction:P}),a&&a.docIds&&a.docIds.length>0&&e(d.DocsList,{release:a},`docs-list-${_}`),a&&a.dataSourceIds&&a.dataSourceIds.length>0&&e(d.DataSourcesList,{release:a},`data-sources-${_}`)]})]})})}d.PublishStatus=t=>{let{roles:o}=U(),i=window.firebase.user.email||"",a=W(o,i),s=t.release,[_,h]=c(!1),l=T(),p=k(),P=j({releaseId:s.id,onScheduled:()=>{t.onAction("scheduled")}});function n(){let g=s.docIds||[],R=s.dataSourceIds||[],b=g.length+R.length;if(b===0){x({title:"Cannot publish release",message:"Error: nothing in the release to publish.",color:"red",autoClose:!1});return}l.openConfirmModal({...p,title:`Publish release: ${s.id}`,children:e(O,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to publish this release? The ",b," items in the release will go live immediately."]}),labels:{confirm:"Publish",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"dark",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!0,onConfirm:()=>{J()}})}async function J(){h(!0),await v(async()=>{let g=`publish-release-${s.id}`,R=s.docIds?.length||0,b=s.dataSourceIds?.length||0,y=R+b;x({id:g,title:"Publishing release",message:`Publishing ${y} items...`,loading:!0,autoClose:!1}),await B(s.id),I({id:g,title:"Published release!",message:`Successfully published ${y} items!`,loading:!1,autoClose:5e3}),t.onAction&&t.onAction("publish")}),h(!1)}function K(){P.open()}async function Q(){await E(s.id),t.onAction("cancel-schedule")}return e("div",{className:"ReleasePage__PublishStatus",children:[e(m,{size:"h2",children:"Status"}),e(S,{children:e(N,{className:"ReleasePage__PublishStatus__table",verticalSpacing:"xs",striped:!0,fontSize:"xs",children:[e("thead",{children:e("tr",{children:[e("th",{children:"status"}),e("th",{children:"actions"})]})}),e("tbody",{children:e("tr",{children:[e("td",{children:e(G,{release:s})}),e("td",{children:e("div",{className:"ReleasePage__PublishStatus__actions",children:[!s.archivedAt&&!s.scheduledAt&&e(f,{label:"You don't have access to publish this release",condition:!a,children:e(u,{label:"Publish the release immediately",position:"bottom",withArrow:!0,disabled:!a,children:e(r,{variant:"default",size:"xs",compact:!0,onClick:()=>n(),loading:_,disabled:!a,children:s.publishedAt?"Re-publish":"Publish"})})}),!s.archivedAt&&(s.scheduledAt?e(f,{label:"You don't have access to manage scheduled releases",condition:!a,children:e(u,{label:"Cancel the scheduled release",position:"bottom",withArrow:!0,disabled:!a,children:e(r,{variant:"default",size:"xs",compact:!0,onClick:()=>Q(),disabled:!a,children:"Cancel Schedule"})})}):e(f,{label:"You don't have access to manage scheduled releases",condition:!a,children:e(u,{label:"Schedule the release to be published at a future date",position:"bottom",withArrow:!0,wrapLines:!0,width:180,disabled:!a,children:e(r,{variant:"default",size:"xs",compact:!0,onClick:()=>K(),disabled:!a,children:"Schedule"})})}))]})})]})})]})})]})};d.DocsList=t=>{let o=t.release,i=o.docIds||[];return e("div",{className:"ReleasePage__DocsList",children:[e("div",{className:"ReleasePage__DocsList__header",children:[e(m,{size:"h2",children:"Docs"}),e(r,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/releases/${o.id}/edit`,children:"Edit"})]}),e(S,{className:"ReleasePage__DocsList__cards",children:i.map(a=>e("div",{className:"ReleasePage__DocsList__card",children:e("a",{href:`/cms/content/${a}`,children:e(M,{docId:a,statusBadges:!0,hideReleases:!0})})},a))})]})};d.DataSourcesList=t=>{let o=t.release,i=o.dataSourceIds||[];return e("div",{className:"ReleasePage__DataSourcesList",children:[e("div",{className:"ReleasePage__DataSourcesList__header",children:[e(m,{size:"h2",children:"Data Sources"}),e(r,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/releases/${o.id}/edit`,children:"Edit"})]}),e("div",{className:"ReleasePage__DataSourcesList__items",children:i.map(a=>e("div",{className:"ReleasePage__DataSourcesList__item",children:e("a",{href:`/cms/data/${a}`,children:a})},a))})]})};export{d as ReleasePage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as w}from"./chunk-UUVAD4U4.js";import{a as P}from"./chunk-MSYTAJBV.js";import{a as S}from"./chunk-TOGLZDK3.js";import{c as f}from"./chunk-2S5HMST6.js";import{a as T}from"./chunk-GT5EQSEX.js";import"./chunk-D3UIZHRK.js";import"./chunk-JS6TK4OP.js";import"./chunk-JDW4UORS.js";import"./chunk-AGFPVTBA.js";import"./chunk-YMBBWVBB.js";import{a as v}from"./chunk-W5DOO6ID.js";import{a as R}from"./chunk-NSOTG64N.js";import{a as d}from"./chunk-BW2MKGNP.js";import"./chunk-KRNQ6L35.js";import{a as y}from"./chunk-P2Z66DHV.js";import{b as x}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import"./chunk-BUNR5EU3.js";import{Da as _,Ga as e,V as h,a as o,c as m,da as b,g as p,j as A,ya as g}from"./chunk-LROR6N3B.js";import{d as c}from"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";A();function N(){y("Releases");let{roles:i}=R(),r=window.firebase.user.email||"",t=v(i,r);return e(x,{children:e("div",{className:"ReleasesPage",children:[e("div",{className:"ReleasesPage__header",children:[e(P,{size:"h1",children:"Releases"}),e(d,{as:"p",children:"Bundle one or more documents and publish them together. Schedule a release to go live at a specific time, or publish manually when you're ready."}),e("div",{className:"ReleasesPage__header__buttons",children:e(T,{label:"You don't have access to create new releases",condition:!t,children:e(b,{component:"a",color:"blue",size:"xs",href:"/cms/releases/new",disabled:!t,style:t?void 0:{pointerEvents:"none"},children:"New release"})})})]}),e(N.ReleasesTable,{})]})})}N.ReleasesTable=()=>{let[i,r]=o(!0),[t,L]=o([]),[l,B]=o("active");async function z(){let a=await f();L(a),r(!1)}let n=p(()=>t.filter(a=>{let s=!!a.archivedAt,u=!!a.publishedAt;return l==="active"?!s:l==="unpublished"?!s&&!u:l==="published"?!s&&u:s}),[t,l]);return m(()=>{z()},[]),e("div",{className:"ReleasesPage__ReleasesTable",children:[i&&e(h,{color:"gray",size:"xl"}),!i&&e(c,{children:[e("div",{className:"ReleasesPage__ReleasesTable__filters",children:e(g,{size:"sm",value:l,onChange:a=>B(a),data:[{label:"Active",value:"active"},{label:"Unpublished",value:"unpublished"},{label:"Published",value:"published"},{label:"Archived",value:"archived"}]})}),n.length>0&&e(S,{children:e(_,{className:"ReleasesPage__ReleasesTable__table",verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[e("thead",{children:e("tr",{children:[e("th",{children:"id"}),e("th",{children:"description"}),e("th",{children:"content"}),e("th",{children:"status"})]})}),e("tbody",{children:n.map(a=>e("tr",{children:[e("td",{children:e("a",{href:`/cms/releases/${a.id}`,children:a.id})}),e("td",{children:a.description||""}),e("td",{children:(a.docIds||[]).map(s=>e("div",{children:e("a",{href:`/cms/content/${s}`,children:s})},s))}),e("td",{children:e("div",{className:"ReleasesPage__ReleasesTable__publishStatus",children:e(w,{release:a})})})]},a.id))})]})}),n.length===0&&e(d,{as:"p",children:"No releases found for this filter."})]})]})};export{N as ReleasesPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as me,e as _e}from"./chunk-ZMS6NIGG.js";import{a as ce,c as de,e as ge}from"./chunk-WFQU7V3W.js";import{b as ae,c as O,d as le,f as z}from"./chunk-CAY5NM4Z.js";import{a as N}from"./chunk-MSYTAJBV.js";import{a as E}from"./chunk-TOGLZDK3.js";import"./chunk-JTIQBW33.js";import"./chunk-JS6TK4OP.js";import{c as se}from"./chunk-5MV6XVGA.js";import{a as ne}from"./chunk-NSOTG64N.js";import{b as ee}from"./chunk-J5E457OI.js";import{a as I}from"./chunk-QHJOTXYB.js";import{a as g}from"./chunk-BW2MKGNP.js";import{f as oe}from"./chunk-KRNQ6L35.js";import{a as pe}from"./chunk-P2Z66DHV.js";import{b as ue}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import{c as V,n as q,p as Q,q as Z}from"./chunk-VD6G5NV4.js";import{e as B}from"./chunk-BUNR5EU3.js";import{Ca as Y,Ga as e,Rc as re,U as L,W as $,Yc as te,Za as ie,a as _,ba as F,c as w,da as v,e as H,g as T,j as G,na as J,pa as K,sa as X,ua as U,za as A}from"./chunk-LROR6N3B.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";G();G();var Ne={ADMIN:4,EDITOR:3,CONTRIBUTOR:2,VIEWER:1};function fe(o){return Ne[o]??0}function Be(o,s){return fe(o)>=fe(s)?o:s}function W(o,s,a){let r=o[s];o[s]=r?Be(r,a):a}function xe(o,s={}){let a={...s},r={};for(let t of o){let m=(t.users||[]).filter(Boolean);if(m.length===0)continue;let u=(t.collections||[]).filter(Boolean);if(u.length===0)for(let d of m)W(a,d,t.role);else{for(let d of m)W(a,d,"VIEWER");for(let d of u){r[d]||(r[d]={});for(let p of m)W(r[d],p,t.role)}}}return{projectRoles:a,collectionRoles:r}}function he(o={}){return{id:o.id||`g_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`,name:o.name||"",role:o.role||"VIEWER",collections:o.collections?[...o.collections]:[],users:o.users?[...o.users]:[]}}G();function k(o){let s=o.size||28,[a,r]=_(!1),t=o.profile?.photoURL||"",m=o.profile?.displayName||o.email,u=B("EmailAvatar",o.className),d={width:s,height:s};return t&&!a?e("img",{className:u,style:d,src:t,alt:m,onError:()=>r(!0)}):e("svg",{className:u,style:d,viewBox:"0 0 28 28",role:"img","aria-label":m,children:[e("circle",{cx:"14",cy:"14",r:"14",fill:le(o.email)}),e("text",{x:"14",y:"14",textAnchor:"middle",dominantBaseline:"central",fill:"#fff",fontSize:"13",fontWeight:"600",children:ae(o.email)})]})}var Ge=[{value:"ADMIN",label:"ADMIN"},{value:"EDITOR",label:"EDITOR"},{value:"CONTRIBUTOR",label:"CONTRIBUTOR"},{value:"VIEWER",label:"VIEWER"}];function ve(o){let{groups:s,onChange:a,collections:r,disabled:t}=o,m=T(()=>r.map(l=>({value:l,label:l})),[r]),[u,d]=_({});function p(l,n){a(s.map(c=>c.id===l?n(c):c))}function b(l){a(s.filter(n=>n.id!==l))}function P(){let l=s.length;a([...s,he({name:"New group"})]),d(n=>({...n,[l]:!0}))}return e("div",{className:B(o.className,"PermissionGroupsBox"),children:[s.length===0?e("div",{className:"PermissionGroupsBox__empty",children:e(g,{size:"body-sm",weight:"semi-bold",color:"gray",children:"No permission groups yet. Create one to organize users by role and optionally scope access to specific collections."})}):e(L,{className:"PermissionGroupsBox__accordion",offsetIcon:!1,multiple:!0,state:u,onChange:d,children:s.map(l=>e(L.Item,{label:e("div",{className:"PermissionGroupsBox__trigger",children:[e("span",{className:"PermissionGroupsBox__trigger__name",children:l.name||"Untitled group"}),e(F,{color:"gray",radius:"sm",size:"xs",variant:"light",className:"PermissionGroupsBox__trigger__badge",children:[l.users.length," ",l.users.length===1?"user":"users"]})]}),children:e(Ue,{group:l,collectionOptions:m,disabled:t,onChange:n=>p(l.id,()=>n),onDelete:()=>b(l.id)})},l.id))}),e("div",{className:"PermissionGroupsBox__addGroup",children:e(v,{variant:"default",size:"xs",radius:0,disabled:t,onClick:P,children:"+ Add group"})})]})}function Ue(o){let{group:s,collectionOptions:a,disabled:r}=o,[t,m]=_(""),u=s.users.filter(i=>!O(i)),{profiles:d}=z(u);function p(i){o.onChange({...s,name:i})}function b(i){o.onChange({...s,role:i})}function P(i){o.onChange({...s,collections:i})}function l(i){let f=i.trim();if(!f||s.users.includes(f)){m("");return}o.onChange({...s,users:[...s.users,f]}),m("")}function n(i){o.onChange({...s,users:s.users.filter(f=>f!==i)})}function c(){window.confirm(`Delete the "${s.name||"Untitled group"}" group? This will remove its role assignments on next save.`)&&o.onDelete()}return e("div",{className:"PermissionGroupsBox__editor",children:[e("div",{className:"PermissionGroupsBox__editor__row",children:[e(U,{className:"PermissionGroupsBox__editor__name",label:"Group name",placeholder:"e.g. Blog Post Editors",value:s.name,radius:0,size:"xs",disabled:r,onChange:i=>p(i.target.value)}),e(A,{className:"PermissionGroupsBox__editor__role",label:"Role",data:Ge,value:s.role,radius:0,size:"xs",disabled:r,onChange:i=>b(i)})]}),e(X,{className:"PermissionGroupsBox__editor__collections",label:"Collections",description:"Leave empty to apply project-wide. Otherwise restrict the group's role to the selected collections.",data:a,value:s.collections,radius:0,size:"xs",searchable:!0,clearable:!0,placeholder:"All collections (project-wide)",disabled:r,onChange:i=>P(i),dropdownComponent:"div"}),e("div",{className:"PermissionGroupsBox__editor__users",children:[e(g,{size:"body-sm",weight:"semi-bold",children:"Users"}),e("form",{className:"PermissionGroupsBox__editor__addUser",onSubmit:i=>{i.preventDefault(),l(t)},children:[e(U,{className:"PermissionGroupsBox__editor__addUser__email",placeholder:"grogu@example.com",type:"email",value:t,onChange:i=>m(i.target.value),radius:0,size:"xs",disabled:r}),e(v,{size:"xs",radius:0,color:"dark",type:"submit",disabled:r||!t.trim(),children:"Add user"})]}),s.users.length>0&&e("ul",{className:"PermissionGroupsBox__editor__userList",children:s.users.map(i=>{let f=d.get(i.toLowerCase())||null;return e("li",{className:"PermissionGroupsBox__editor__userItem",children:[e(k,{className:"PermissionGroupsBox__editor__userItem__avatar",email:i,profile:f,size:24}),e("span",{className:"PermissionGroupsBox__editor__userItem__email",children:i}),e($,{size:"sm",variant:"transparent",disabled:r,onClick:()=>n(i),title:`Remove ${i}`,children:e(te,{size:14})})]},i)})})]}),e("div",{className:"PermissionGroupsBox__editor__footer",children:e(v,{variant:"subtle",size:"xs",color:"red",compact:!0,disabled:r,leftIcon:e(re,{size:14}),onClick:c,children:"Delete group"})})]})}G();function D(o){let{roles:s,onChange:a,currentUserIsAdmin:r}=o,[t,m]=_(""),u=Object.keys(s).filter(n=>!O(n)),{profiles:d}=z(u);function p(n,c){a({...s,[n]:c})}function b(n){let c={...s};delete c[n],a(c)}function P(n){let c=n.trim();m(""),!(!c||c in s)&&a({...s,[c]:"EDITOR"})}let l=se(Object.keys(s).map(n=>({email:n,role:s[n],profile:d.get(n.toLowerCase())||null})),"email");return e("div",{className:B(o.className,"ShareBox"),children:[e("form",{className:"ShareBox__addUser",onSubmit:n=>{n.preventDefault(),P(t)},children:[e(U,{className:"ShareBox__addUser__email",placeholder:"grogu@example.com",type:"email",value:t,onChange:n=>m(n.target.value),radius:0,size:"xs",disabled:!r}),e(v,{className:"ShareBox__addUser__button",size:"xs",radius:0,color:"dark",type:"submit",disabled:!r,children:"Add user"})]}),e("div",{className:"ShareBox__users",children:l.map(n=>e(D.User,{...n,currentUserIsAdmin:r,onRoleChange:p,onRemove:b},n.email))})]})}D.User=o=>{let s=o.email===window.firebase.user.email;return e("div",{className:"ShareBox__user",children:[e(k,{className:"ShareBox__user__avatar",email:o.email,profile:o.profile,size:24}),e(g,{className:"ShareBox__user__email",size:"body-sm",weight:"semi-bold",color:"gray",children:[o.email,s&&" (you)"]}),e("div",{className:"ShareBox__user__roleSelect",children:e(A,{data:[{value:"ADMIN",label:"ADMIN"},{value:"EDITOR",label:"EDITOR"},{value:"CONTRIBUTOR",label:"CONTRIBUTOR"},{value:"VIEWER",label:"VIEWER"},{value:"REMOVE",label:"REMOVE"}],value:o.role,radius:0,size:"xs",disabled:s||!o.currentUserIsAdmin,onChange:a=>{a==="REMOVE"?o.onRemove(o.email):o.onRoleChange(o.email,a)}})})]})};G();var Ie="You have unsaved changes. Are you sure you want to leave this page?";function be(o){w(()=>{if(o)return _e({message:Ie,url:window.location.href})},[o])}function Ee(o){if(!o)return"never";let s=Date.now()-o;return s<6e4?"just now":s<60*6e4?`${Math.floor(s/6e4)} min ago`:s<1440*6e4?`${Math.floor(s/(60*6e4))} hr ago`:new Date(o).toLocaleString()}function Pe(o){let s=window.firebase?.user?.email;if(!s)return!1;if(o[s]==="ADMIN")return!0;let a=s.split("@").at(-1);return!!(a&&o[`*@${a}`]==="ADMIN")}function Ce(){let o=me(),[s,a]=_(!1),[r,t]=_(!1),[m,u]=_(!1),d=H(null);function p(){d.current!==null&&(window.clearInterval(d.current),d.current=null),t(!1),u(!1)}w(()=>p,[]),w(()=>{r&&o.running&&u(!0)},[r,o.running]);async function b(f){if(!(s||r)){a(!0);try{let x=await fetch("/cms/api/search.rebuild",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:f})});if(!x.ok){let j=await x.text().catch(()=>"");throw new Error(`HTTP ${x.status}: ${j||"rebuild failed"}`)}I({title:"Search index",message:f?"Full rebuild started.":"Incremental rebuild started.",color:"blue",autoClose:4e3}),t(!0),d.current=window.setInterval(()=>{o.refresh()},2e3),window.setTimeout(p,10*6e4)}catch(x){I({title:"Error",message:x?.message||String(x),color:"red",autoClose:!1})}finally{a(!1)}}}w(()=>{r&&m&&!o.running&&(p(),I({title:"Search index",message:"Rebuild complete.",color:"green",autoClose:3e3}))},[r,m,o.running]);let P=o.status.lastRun,l=o.status.docCount,n=o.status.fieldCount,c=o.status.shardCount,i=o.running||s;return e("div",{className:"SettingsPage__section",children:[e("div",{className:"SettingsPage__section__left",children:[e(N,{className:"SettingsPage__section__left__title",children:"Site Admin"}),e(g,{className:"SettingsPage__section__body",size:"body-sm",weight:"semi-bold",color:"gray",children:e("p",{children:"Project-wide administrative actions. Only admins see this section."})})]}),e(E,{className:"SettingsPage__section__right",children:e("div",{className:"SettingsPage__section__setting",children:[e(g,{size:"body",weight:"semi-bold",children:"Search index"}),e(g,{size:"body-sm",weight:"semi-bold",color:"gray",children:e("p",{children:"Powers the Cmd+K global search. Rebuilds run automatically on a schedule; trigger a manual rebuild here if you want immediate results (e.g. after a schema change)."})}),e("div",{className:"SettingsPage__siteAdmin__searchStats",children:[e("div",{children:[e("strong",{children:"Last indexed:"})," ",Ee(P)]}),e("div",{children:[e("strong",{children:"Indexed docs:"})," ",l.toLocaleString()]}),e("div",{children:[e("strong",{children:"Indexed fields:"})," ",n.toLocaleString()]}),e("div",{children:[e("strong",{children:"Shards:"})," ",c]})]}),e("div",{className:"SettingsPage__siteAdmin__searchButtons",children:[e(v,{variant:"default",size:"xs",compact:!0,loading:i,onClick:()=>b(!1),children:"Rebuild incremental"}),e(v,{variant:"default",size:"xs",compact:!0,loading:i,onClick:()=>{window.confirm("Force a full rebuild? This wipes the existing index and reindexes every doc from scratch.")&&b(!0)},children:"Force full rebuild"})]})]})})]})}function Te(o,s){return JSON.stringify(o)===JSON.stringify(s)}function Ae(){let o=window.__ROOT_CTX.rootConfig.projectId||"default",s=window.__ROOT_CTX.collections||{},a=T(()=>Object.keys(s).sort(),[s]),r=window.firebase.db,t=V(r,"Projects",o),[m,u]=_(!0),[d,p]=_(!1),[b,P]=_({}),[l,n]=_({globalRoles:{},permissionGroups:[]}),[c,i]=_({globalRoles:{},permissionGroups:[]});w(()=>{q(t).then(h=>{let S=h.data()||{},C=S.roles||{},y={globalRoles:S.globalRoles||C,permissionGroups:S.permissionGroups||[]};P(C),n(y),i({globalRoles:{...y.globalRoles},permissionGroups:y.permissionGroups.map(R=>({...R}))}),u(!1)})},[]);let f=Pe(b),x=!Te(l,c);be(x);function j(h){i(S=>({...S,globalRoles:h}))}function Se(h){i(S=>({...S,permissionGroups:h}))}function Re(){i({globalRoles:{...l.globalRoles},permissionGroups:l.permissionGroups.map(h=>({...h}))})}async function ye(){d||!x||(p(!0),await ee(async()=>{let{projectRoles:h,collectionRoles:S}=xe(c.permissionGroups,c.globalRoles);await Z(t,{globalRoles:c.globalRoles,roles:h,permissionGroups:c.permissionGroups});let C=l.permissionGroups.flatMap(R=>R.collections||[]),M=new Set([...Object.keys(S),...C]);for(let R of M){let we=V(r,"Projects",o,"Collections",R);await Q(we,{roles:S[R]||{}},{merge:!0})}let y={globalRoles:c.globalRoles,permissionGroups:c.permissionGroups};P(h),n(y),i({globalRoles:{...y.globalRoles},permissionGroups:y.permissionGroups.map(R=>({...R}))}),oe("acls.save_groups",{metadata:{groupCount:c.permissionGroups.length,userCount:Object.keys(h).length,collections:Array.from(M)}}),I({title:"Saved",message:"Sharing settings updated.",color:"green",autoClose:3e3})}),p(!1))}return e("div",{className:"SettingsPage__section SettingsPage__section__users",children:[e("div",{className:"SettingsPage__section__left",children:[e(N,{className:"SettingsPage__section__left__title",children:"Share"}),e(g,{className:"SettingsPage__section__body",size:"body-sm",weight:"semi-bold",color:"gray",children:[e("p",{children:"Share access to the CMS. To share with everyone in a domain, use *@example.com."}),e("ul",{children:[e("li",{children:"VIEWER: view docs but not edit"}),e("li",{children:"CONTRIBUTOR: view and edit docs, but not publish"}),e("li",{children:"EDITOR: view, edit, and publish docs"}),e("li",{children:"ADMIN: all of the above and change sharing settings"})]}),e("p",{children:["Use ",e("strong",{children:"groups"})," to manage many users at once and optionally scope a role to specific collections."]})]})]}),e(E,{className:"SettingsPage__section__right",children:e("div",{className:"SettingsPage__share",children:[e(K,{visible:m,loaderProps:{color:"gray",size:"xl"}}),e("div",{className:"SettingsPage__share__subsection",children:[e(N,{className:"SettingsPage__section__right__title",size:"h3",children:"Users"}),e(D,{className:"SettingsPage__section__users__sharebox",roles:c.globalRoles,onChange:j,currentUserIsAdmin:f})]}),e("div",{className:"SettingsPage__share__subsection",children:[e(N,{className:"SettingsPage__section__right__title",size:"h3",children:"Groups"}),e(ve,{groups:c.permissionGroups,onChange:Se,collections:a,disabled:!f})]}),e("div",{className:"SettingsPage__share__saveBar",children:[e(g,{size:"body-sm",weight:"semi-bold",color:"gray",children:x?"You have unsaved changes.":"All changes saved."}),e("div",{className:"SettingsPage__share__saveBar__actions",children:[e(v,{variant:"default",size:"xs",radius:0,disabled:!x||d,onClick:Re,children:"Discard"}),e(v,{size:"xs",radius:0,color:x?"green":"dark",leftIcon:e(ie,{size:14}),loading:d,disabled:!x||!f,onClick:ye,children:"Save changes"})]})]})]})})]})}function Xo(){pe("Settings");let o=ge(),s=de(),a=ne(),r=!a.loading&&Pe(a.roles);return e(ue,{children:e("div",{className:"SettingsPage",children:[e(Ae,{}),e("div",{className:"SettingsPage__section",children:[e("div",{className:"SettingsPage__section__left",children:[e(N,{className:"SettingsPage__section__left__title",children:"Site Settings"}),e(g,{className:"SettingsPage__section__body",size:"body-sm",weight:"semi-bold",color:"gray",children:e("p",{children:"These settings apply to the project. Only admins can change them."})})]}),e(E,{className:"SettingsPage__section__right",children:ce.map(t=>e("div",{className:"SettingsPage__section__setting",children:[e(g,{size:"body",weight:"semi-bold",children:t.name}),e(g,{size:"body-sm",weight:"semi-bold",color:"gray",children:e("p",{children:t.description})}),e(J,{autosize:!0,minRows:2,maxRows:4,value:s.settings[t.key]||"",placeholder:t.placeholder,onChange:m=>s.setSettings(t.key,m.currentTarget.value)}),t.ui&&e("div",{children:t.ui(s.settings[t.key])})]},t.key))})]}),r&&e(Ce,{}),e("div",{className:"SettingsPage__section",children:[e("div",{className:"SettingsPage__section__left",children:[e(N,{className:"SettingsPage__section__left__title",children:"User Preferences"}),e(g,{className:"SettingsPage__section__body",size:"body-sm",weight:"semi-bold",color:"gray",children:e("p",{children:"These settings are for you only."})})]}),e(E,{className:"SettingsPage__section__right",children:e("div",{className:"SettingsPage__section__userPref",children:[e("div",{className:"SettingsPage__section__userPref__description",children:[e(g,{className:"SettingsPage__section__userPref__description__title",size:"body",weight:"semi-bold",children:"Enable EditorJS Editor (legacy)"}),e(g,{className:"SettingsPage__section__userPref__description__body",size:"body-sm",weight:"semi-bold",color:"gray",children:e("p",{children:["Replaces the"," ",e("a",{href:"https://lexical.dev/",target:"_blank",rel:"noopener noreferrer nofollow",children:"Lexical"})," ","(default) rich text editor with the"," ",e("a",{href:"https://editorjs.io/",target:"_blank",rel:"noopener noreferrer nofollow",children:"EditorJS"})," ","(legacy) version."]})})]}),e("div",{className:"SettingsPage__section__userPref__input",children:e(Y,{color:"dark",checked:o.preferences.EnableEditorJSEditor,onChange:t=>{let m=t.currentTarget.checked;o.setPreference("EnableEditorJSEditor",m)}})})]})})]})]})})}export{Xo as SettingsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as g}from"./chunk-QF3GPZTI.js";import"./chunk-4ISFTE2G.js";import"./chunk-ENQKSLGJ.js";import"./chunk-CAY5NM4Z.js";import{a as e}from"./chunk-MSYTAJBV.js";import"./chunk-TOGLZDK3.js";import"./chunk-FJLNXXE3.js";import"./chunk-J5E457OI.js";import"./chunk-QHJOTXYB.js";import"./chunk-KRNQ6L35.js";import{a as i}from"./chunk-P2Z66DHV.js";import{b as s}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import"./chunk-BUNR5EU3.js";import{Ga as a}from"./chunk-LROR6N3B.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";function k(){return i("Tasks"),a(s,{children:a("div",{className:"TasksPage",children:[a("div",{className:"TasksPage__header",children:a(e,{size:"h1",children:"Tasks"})}),a(g,{variant:"page"})]})})}export{k as TasksPage};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{b as q}from"./chunk-JBHRZ4EX.js";import{a as M}from"./chunk-MSYTAJBV.js";import"./chunk-YDO2EDVY.js";import"./chunk-5MV6XVGA.js";import{R as O}from"./chunk-AGFPVTBA.js";import{f as D}from"./chunk-YMBBWVBB.js";import{a as A}from"./chunk-BW2MKGNP.js";import"./chunk-KRNQ6L35.js";import{a as N}from"./chunk-P2Z66DHV.js";import{b as B}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import"./chunk-BUNR5EU3.js";import{Da as F,Ga as t,a as p,ca as y,da as T,na as C,w as H,yb as $}from"./chunk-LROR6N3B.js";import{d as S}from"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";H();var f=class{constructor(){this.data={}}setMeta(r){Object.entries(r).forEach(([e,s])=>{e.startsWith("@@")||(e=`@@${e}`),this.data[e]=s})}add(r,e,s){this.data[r]=e,s&&(this.data[`@${r}`]=s)}get(r){let e=this.data[r];return e?{source:e,meta:this.data[`@${r}`]}:null}list(){let r=[];return Object.entries(this.data).forEach(([e])=>{if(e.startsWith("@"))return;let s=this.data[e],c=this.data[`@${e}`];r.push({key:e,source:s,meta:c})}),r}toJson(){return{...this.data}}toString(){return JSON.stringify(this.toJson(),null,2)}};function h(){return N("ARB Translations"),t(B,{children:t("div",{className:"TranslationsArbPage",children:[t("div",{className:"TranslationsArbPage__header",children:[t(y,{className:"TranslationsArbPage__header__breadcrumbs",children:[t("a",{href:"/cms/translations",children:"Translations"}),t("div",{children:"ARB"})]}),t(M,{size:"h1",children:"ARB Translations"}),t(A,{as:"p",children:"Enter doc ids below (separated by newlines) to include in an ARB file."})]}),t(h.RequestForm,{})]})})}h.RequestForm=()=>{let[o,r]=p(""),[e,s]=p(!1),[c,l]=p(""),[m,I]=p(null);async function v(a){let u=await O(a),d=new f,g=window.__ROOT_CTX.rootConfig,b=[g.domain];g.base&&g.base!=="/"&&b.push(g.base);let n=b.join("");d.setMeta({locale:"en",context:n,last_modified:new Date().toISOString()}),console.log(u);for(let w in u){let W=await q(w);for(let[P,_]of W.entries()){let R=await D(P),i=d.get(R)?.meta;if(i){let x=i.context.split(", ");x.push(w),x.sort(),i.context=x.join(", "),!i.description&&_.description&&(i.description=_.description)}else i={context:w},_.notes&&(i.description=_.notes);d.add(R,P,i)}}return d}async function L(){try{let a=j(o),u=await v(a);I(u)}catch(a){console.error(a),l(`failed to preview arb: ${a}`)}}async function E(){try{s(!0),console.log("download arb");let a=j(o),d=(await v(a)).toString(),b=await new Response(d).blob(),n=document.createElement("a");n.href=window.URL.createObjectURL(b),n.download=k(a),document.body.appendChild(n),n.click(),document.body.removeChild(n),window.URL.revokeObjectURL(n.href),s(!1)}catch(a){console.error(a),l(`failed to download arb: ${a}`)}}return t("form",{className:"TranslationsArbPage__RequestForm",onSubmit:a=>{a.preventDefault(),E()},children:[t("div",{className:"TranslationsArbPage__RequestForm__textareaWrapper",children:t(C,{required:!0,size:"xs",radius:0,autosize:!0,minRows:8,maxRows:20,value:o,placeholder:"Pages/index",onChange:a=>{r(a.currentTarget.value||"")}})}),t("div",{className:"TranslationsArbPage__RequestForm__submit",children:[t(T,{variant:"default",color:"dark",size:"xs",onClick:L,children:"Preview"}),t(T,{color:"blue",size:"xs",loading:e,type:"submit",leftIcon:t($,{size:16,strokeWidth:1.75}),children:"Download ARB"})]}),c&&t(A,{as:"p",className:"TranslationsArbPage__RequestForm__error",children:c}),m&&t(h.Preview,{arb:m})]})};h.Preview=o=>{let r=o.arb.list().filter(e=>!!e.meta);return console.log(r),t(F,{verticalSpacing:"xs",highlightOnHover:!0,fontSize:"xs",children:[t("thead",{children:t("tr",{children:[t("th",{children:"source"}),t("th",{children:"context"})]})}),t("tbody",{children:r.map(e=>t("tr",{class:"TranslationsArbPage__Preview__Table__row",children:[t("td",{children:e.source}),t("td",{children:[e.meta?.context,e.meta?.description&&t(S,{children:["/ ",e.meta.description]})]})]},e.source))})]})};function j(o){return o.split(`
|
|
2
|
-
`).map(r=>r.trim()).filter(r=>U(r))}function U(o){return!!o&&o.includes("/")&&o.split("/").length===2}function k(o){let r=new Date,e=m=>m.toString().padStart(2,"0"),s=`${r.getFullYear()}${e(r.getMonth()+1)}${e(r.getDate())}t${e(r.getHours())}${e(r.getMinutes())}`,c=window.__ROOT_CTX.rootConfig.projectName||window.__ROOT_CTX.rootConfig.projectId,l=[z(c)];return o.length===1&&l.push(z(o[0])),l.push(s),`${l.join("_")}.arb`}function z(o){return o.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}export{h as TranslationsArbPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as p}from"./chunk-MSYTAJBV.js";import{c as F,d as y,g as N,k as z,m as C}from"./chunk-YMBBWVBB.js";import{a as x}from"./chunk-QHJOTXYB.js";import"./chunk-KRNQ6L35.js";import{a as S}from"./chunk-P2Z66DHV.js";import{b as w}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import"./chunk-BUNR5EU3.js";import{Ga as a,V as P,a as r,c as T,ca as f,da as h,j as H,na as _,sa as b,ua as v}from"./chunk-LROR6N3B.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";H();function L(i){S("Edit Translation");let t=i.hash,[u,l]=r(!1),[d,g]=r(!1),[n,o]=r({source:""});async function s(){l(!0);let e=await F(t);if(l(!1),!e?.source){g(!0);return}o(e)}async function c(e){console.log(e),await y(t,e),o(m=>({...m,...e})),x({title:"Saved translations",message:`Updated translations for ${t}.`,autoClose:5e3})}return T(()=>{s()},[i.hash]),a(w,{children:a("div",{className:"TranslationsEditPage",children:[a("div",{className:"TranslationsEditPage__header",children:[a(f,{className:"TranslationsEditPage__header__breadcrumbs",children:[a("a",{href:"/cms/translations",children:"Translations"}),a("div",{children:i.hash})]}),a(p,{size:"h1",children:"Edit Translations"})]}),u?a(P,{color:"gray",size:"xl"}):d?a("div",{className:"TranslationsEditPage__notFound",children:"Not Found"}):a(L.Form,{hash:i.hash,translations:n,onChange:c})]})})}L.Form=i=>{let t=i.translations,u=window.__ROOT_CTX.rootConfig.i18n.locales||[],l=z(u).filter(s=>s!=="en"),[d,g]=r(t.tags||[]),[n,o]=r(null);return T(()=>{g(t.tags||[])},[t.tags]),a("div",{className:"TranslationsEditPage__FormContainer",children:[a("form",{className:"TranslationsEditPage__Form",onSubmit:async s=>{s.preventDefault();let c=s.currentTarget,e=["en",...l],m={};e.forEach(E=>{let B=c.elements[E].value;m[E]=N(B)}),o("translations");try{await i.onChange(m)}finally{o(null)}},children:[a(v,{className:"TranslationsEditPage__Form__input",size:"xs",radius:0,name:"hash",label:"hash",value:i.hash,disabled:!0}),a(_,{className:"TranslationsEditPage__Form__input",size:"xs",radius:0,name:"source",label:"source",value:t.source,autosize:!0,disabled:!0}),a(_,{className:"TranslationsEditPage__Form__input",size:"xs",radius:0,name:"en",label:"en",value:t.en,autosize:!0,disabled:!!n}),l.map(s=>a(_,{className:"TranslationsEditPage__Form__input",size:"xs",radius:0,name:s,label:s,value:C(t,s),autosize:!0,disabled:!!n},s)),a(h,{className:"TranslationsEditPage__Form__input__submit",color:"blue",size:"xs",type:"submit",disabled:!!n,loading:n==="translations",children:n==="translations"?"Saving...":"Save"})]}),a("div",{className:"TranslationsEditPage__TagsForm",children:[a(p,{size:"h3",className:"TranslationsEditPage__TagsForm__heading",children:"Tags"}),a(b,{data:d,value:d,onChange:g,placeholder:"Add tags",searchable:!0,creatable:!0,disabled:!!n,getCreateLabel:s=>`+ Add tag ${s}`}),a(h,{className:"TranslationsEditPage__TagsForm__submit",color:"blue",size:"xs",disabled:!!n,loading:n==="tags",onClick:async()=>{o("tags");try{await i.onChange({...t,tags:d})}finally{o(null)}},children:n==="tags"?"Saving...":"Save tags"})]})]})};export{L as TranslationsEditPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as s,g as F}from"./chunk-344GZOGG.js";import{c as $}from"./chunk-JDW4UORS.js";import"./chunk-PVAE643M.js";function k(e,t){if(e==null)return[];if(typeof e!="object"||Array.isArray(e))return[{path:"",message:"Expected object for fields data",expected:"object",received:E(e)}];let i=[];for(let r of t.fields){if(!r.id||!(r.id in e))continue;let o=e[r.id];i.push(...g(o,r,r.id))}return i}function g(e,t,i){if(e===void 0)return[];switch(t.type){case"string":case"select":return typeof e!="string"?[c(i,"string",e)]:[];case"number":return typeof e!="number"?[c(i,"number",e)]:isNaN(e)?[c(i,"number",e)]:[];case"boolean":return typeof e!="boolean"?[c(i,"boolean",e)]:[];case"date":case"datetime":{if(typeof e!="object"||Array.isArray(e))return[c(i,"object",e)];let r=[],o=e.seconds,n=e.nanoseconds;return o===void 0?r.push({path:`${i}.seconds`,message:"Required",expected:"number",received:"undefined"}):typeof o!="number"&&r.push(c(`${i}.seconds`,"number",o)),n===void 0?r.push({path:`${i}.nanoseconds`,message:"Required",expected:"number",received:"undefined"}):typeof n!="number"&&r.push(c(`${i}.nanoseconds`,"number",n)),r}case"multiselect":return Array.isArray(e)?e.flatMap((r,o)=>typeof r!="string"?[c(`${i}.${o}`,"string",r)]:[]):[c(i,"array",e)];case"image":case"file":{if(typeof e!="object"||Array.isArray(e))return[c(i,"object",e)];let r=[];return e.src===void 0?r.push({path:`${i}.src`,message:"Required",expected:"string",received:"undefined"}):typeof e.src!="string"&&r.push(c(`${i}.src`,"string",e.src)),e.alt!==void 0&&typeof e.alt!="string"&&r.push(c(`${i}.alt`,"string",e.alt)),r}case"object":{if(typeof e!="object"||Array.isArray(e))return[c(i,"object",e)];let r=t,o=[];for(let n of r.fields)!n.id||!(n.id in e)||o.push(...g(e[n.id],n,`${i}.${n.id}`));return o}case"array":{if(!Array.isArray(e))return[c(i,"array",e)];let o=t.of;return e.flatMap((n,a)=>g(n,o,`${i}.${a}`))}case"oneof":{if(typeof e!="object"||Array.isArray(e))return[c(i,"object",e)];let r=t,o=e._type,n=new Map,a=[];for(let l of r.types){if(typeof l=="string"){a.push(l);continue}n.set(l.name,l),a.push(l.name)}if(!a.includes(o)){let l=a.map(u=>`'${u}'`).join(" | ");return[{path:`${i}._type`,message:`Invalid discriminator value. Expected ${l}`,expected:"valid discriminator value",received:o}]}let d=n.get(o);if(!d)return[];let f=[];for(let l of d.fields)!l.id||!(l.id in e)||f.push(...g(e[l.id],l,`${i}.${l.id}`));return f}case"richtext":{if(typeof e!="object"||Array.isArray(e))return[c(i,"object",e)];let r=[];return e.blocks===void 0?r.push({path:`${i}.blocks`,message:"Required",expected:"array",received:"undefined"}):Array.isArray(e.blocks)?e.blocks.forEach((o,n)=>{if(typeof o!="object"||o===null){r.push(c(`${i}.blocks.${n}`,"object",o));return}o.type===void 0?r.push({path:`${i}.blocks.${n}.type`,message:"Required",expected:"string",received:"undefined"}):typeof o.type!="string"&&r.push(c(`${i}.blocks.${n}.type`,"string",o.type))}):r.push(c(`${i}.blocks`,"array",e.blocks)),r}case"reference":{if(typeof e!="object"||Array.isArray(e))return[c(i,"object",e)];let r=[],o=["id","collection","slug"];for(let n of o)e[n]===void 0?r.push({path:`${i}.${n}`,message:"Required",expected:"string",received:"undefined"}):typeof e[n]!="string"&&r.push(c(`${i}.${n}`,"string",e[n]));return r}case"references":return Array.isArray(e)?e.flatMap((r,o)=>{if(typeof r!="object"||r===null||Array.isArray(r))return[c(`${i}.${o}`,"object",r)];let n=[],a=["id","collection","slug"];for(let d of a)r[d]===void 0?n.push({path:`${i}.${o}.${d}`,message:"Required",expected:"string",received:"undefined"}):typeof r[d]!="string"&&n.push(c(`${i}.${o}.${d}`,"string",r[d]));return n}):[c(i,"array",e)];default:return console.warn(`Unknown field type: ${t.type}`),[]}}function E(e){return e===null?"null":Array.isArray(e)?"array":typeof e=="number"&&Number.isNaN(e)?"nan":typeof e}function c(e,t,i){let r=E(i);return{path:e,message:`Expected ${t}, received ${r}`,expected:t,received:r}}var Y=["collections_list","docs_list","doc_get","doc_getVersion","doc_set","doc_create","doc_updateField","doc_edit","doc_duplicate","doc_listVersions","doc_translateField","schema_get"],T=["collections_list","docs_list","doc_get","doc_getVersion","doc_listVersions","schema_get"];function Z(e){let t=M(e),i={};for(let r of T)t[r]&&(i[r]=t[r]);return i}function M(e){return{collections_list:{description:"List all CMS collections defined in the project. Returns each collection id along with optional name/description metadata.",inputSchema:s.object({}),execute:async()=>{let t=await e.loadAllCollections();return{collections:Object.entries(t).map(([i,r])=>({id:i,name:r.name,description:r.description}))}}},docs_list:{description:"List documents inside a CMS collection. Returns up to `limit` docs (default 25, max 100). Use this to explore content before reading individual docs.",inputSchema:s.object({collectionId:s.string().describe('Collection id, e.g. "Pages" or "BlogPosts".'),mode:s.enum(["draft","published"]).default("draft").describe("Whether to read draft or published versions."),limit:s.number().int().min(1).max(100).default(25)}),execute:async({collectionId:t,mode:i="draft",limit:r=25})=>{let o=v(r,1,100,25);return{docs:(await e.cmsClient.listDocs(t,{mode:i,limit:o})).docs.map(a=>({id:a.id,slug:a.slug,sys:A(a.sys)}))}}},doc_get:{description:"Read a single CMS document. Returns the doc fields plus system metadata. Use this when you need the full content of a doc.",inputSchema:s.object({docId:s.string().describe('Full doc id in the form "Collection/slug" (e.g. "Pages/home").'),mode:s.enum(["draft","published"]).default("draft")}),execute:async({docId:t,mode:i="draft"})=>{let{collection:r,slug:o}=S(t),n=await e.cmsClient.getRawDoc(r,o,{mode:i});return n?{found:!0,doc:{id:n.id,collection:n.collection,slug:n.slug,sys:A(n.sys),fields:N(n.fields)}}:{found:!1}}},doc_getVersion:{description:'Read a specific version of a CMS document. Use versionId "draft" or "published" for the current draft/published state, or a numeric timestamp for a historical version (from `doc_listVersions`).',inputSchema:s.object({docId:s.string().describe('Full doc id in the form "Collection/slug" (e.g. "Pages/home").'),versionId:s.string().describe('Version identifier: "draft", "published", or a numeric timestamp.')}),execute:async({docId:t,versionId:i})=>{let{collection:r,slug:o}=S(t),n;i==="draft"?n=`Projects/${e.cmsClient.projectId}/Collections/${r}/Drafts/${o}`:i==="published"?n=`Projects/${e.cmsClient.projectId}/Collections/${r}/Published/${o}`:n=`Projects/${e.cmsClient.projectId}/Collections/${r}/Drafts/${o}/Versions/${i}`;let a=await e.cmsClient.db.doc(n).get();if(!a.exists)return{found:!1};let d=a.data();return{found:!0,doc:{id:d.id,collection:d.collection,slug:d.slug,sys:A(d.sys),fields:N(d.fields)}}}},doc_set:{description:"Replace the entire draft fields payload of a CMS document. Pass the full JSON object that should become the new draft contents \u2014 any fields omitted will be removed. The payload is validated against the collection schema and the call is rejected on validation errors. Prefer `doc_updateField` for targeted edits. Only writes the draft version; users must publish separately. Format: pass plain JSON. Arrays must be plain JSON arrays \u2014 do NOT use the `_array` object notation. The tool marshals the payload into Firestore storage shape on its own. Rich text fields use the `{version, time, blocks}` shape with `blocks` as a plain JSON array of `{type, data}` objects.",inputSchema:s.object({docId:s.string().describe('Full doc id in the form "Collection/slug" (e.g. "Pages/home").'),fields:s.record(s.string(),s.any()).describe("New fields object. Replaces the existing draft fields entirely.")})},doc_create:{description:"Create a new draft CMS document with the given slug. Fails if the doc already exists. Pass optional initial fields (validated against the collection schema). Format: pass plain JSON for `fields`. Arrays must be plain JSON arrays \u2014 do NOT use the `_array` object notation. The tool marshals the payload into Firestore storage shape on its own. Rich text fields use the `{version, time, blocks}` shape with `blocks` as a plain JSON array of `{type, data}` objects.",inputSchema:s.object({docId:s.string().describe('Full doc id in the form "Collection/slug" (e.g. "BlogPosts/my-new-post").'),fields:s.record(s.string(),s.any()).optional().describe("Optional initial fields for the new doc.")})},doc_updateField:{description:'Update a single field on a draft CMS document by JSON path. Paths are relative to the doc fields object; do not prefix them with "fields.". Use dotted paths (e.g. "hero.title") and zero-based array indices. For example, update the first module title with path "content.modules.0.title". To insert or remove array items, prefer `doc_edit` (it supports insert/remove operations); alternatively set the whole array path here (e.g. "content.modules") to the updated array. The value is validated against the field schema and the call is rejected if the shape is wrong (e.g. passing a string to a richtext field). Only updates the draft version; users must publish separately. Format: pass `value` as plain JSON. Arrays must be plain JSON arrays \u2014 do NOT use the `_array` object notation. The tool marshals the value into Firestore storage shape on its own. Rich text fields use the `{version, time, blocks}` shape and `blocks` MUST be a plain JSON array of `{type, data}` objects (never wrapped in `_array`).',inputSchema:s.object({docId:s.string(),path:s.string().describe('Dotted JSON path within the fields object, e.g. "content.modules.0.title".'),value:s.any().describe("JSON value to set at the path.")})},doc_edit:{description:'Apply multiple edits to a draft CMS document in a single call. Use this when a change spans more than one field or needs to add or remove array items (e.g. append a new module AND update a title). Pass an ordered `operations` list; each operation has an `op`:\n- "set": set the value at `path` (e.g. "hero.title" or "content.modules.0.title"). Provide `value`.\n- "insert_item": insert `value` into the array at `path` (e.g. "content.modules"). Optionally pass a zero-based `index` to insert before; omit `index` to append.\n- "remove_item": remove the array item at zero-based `index` from the array at `path`.\nOperations apply in order against the current draft. Array indices in each operation refer to the array state AFTER earlier operations have been applied. The whole result is validated against the collection schema and the call is rejected as a group on any error \u2014 nothing is written unless every operation succeeds. Paths are relative to the doc fields object; do not prefix them with "fields.". Use dotted paths and zero-based array indices. Only writes the draft version; users must publish separately. Format: pass `value` as plain JSON. Arrays must be plain JSON arrays \u2014 do NOT use the `_array` object notation. The tool marshals values into Firestore storage shape on its own. Rich text fields use the `{version, time, blocks}` shape with `blocks` as a plain JSON array of `{type, data}` objects.',inputSchema:s.object({docId:s.string().describe('Full doc id in the form "Collection/slug" (e.g. "Pages/home").'),operations:s.array(s.object({op:s.enum(["set","insert_item","remove_item"]).describe('Operation: "set" a field value, "insert_item" into an array, or "remove_item" from an array.'),path:s.string().describe('Dotted path within the fields object. For "set" it targets the field to write (e.g. "hero.title"); for "insert_item"/"remove_item" it targets the array (e.g. "content.modules").'),value:s.any().optional().describe('JSON value. Required for "set" (the new field value) and "insert_item" (the new array item). Ignored for "remove_item".'),index:s.number().int().min(0).optional().describe('Zero-based array index. For "insert_item" it is the position to insert before (omit to append); for "remove_item" it is the item to delete (required).')})).min(1).describe("Ordered list of edit operations to apply to the draft.")})},doc_duplicate:{description:"Duplicate an existing CMS document to a new slug. Copies all draft fields to the target doc id. Fails if the target already exists.",inputSchema:s.object({fromDocId:s.string().describe('Source doc id to copy from (e.g. "Pages/home").'),toDocId:s.string().describe('Target doc id for the copy (e.g. "Pages/home-copy").')})},doc_listVersions:{description:"List version history for a CMS document. Returns versions ordered by most recent first. Use the versionId from the results with `doc_getVersion` to read a specific version.",inputSchema:s.object({docId:s.string().describe('Full doc id in the form "Collection/slug" (e.g. "Pages/home").'),limit:s.number().int().min(1).max(50).default(10)}),execute:async({docId:t,limit:i=10})=>{let{collection:r,slug:o}=S(t),n=v(i,1,50,10),a=`Projects/${e.cmsClient.projectId}/Collections/${r}/Drafts/${o}/Versions`;return{versions:(await e.cmsClient.db.collection(a).orderBy("sys.modifiedAt","desc").limit(n).get()).docs.map(f=>{let l=f.data();return{versionId:f.id,sys:A(l.sys),tags:l.tags||[],publishMessage:l.publishMessage}})}}},doc_translateField:{description:"Translate a text value into one or more target locales using AI. Returns the translated strings keyed by locale. Use this to help with localization workflows.",inputSchema:s.object({sourceText:s.string().min(1).describe("The source text to translate."),targetLocales:s.array(s.string()).min(1).describe('Array of locale codes to translate into (e.g. ["es", "fr", "de"]).'),description:s.string().optional().describe("Optional context about the text to improve translation quality.")})},schema_get:{description:"Get the field schema for a CMS collection. Returns the full field definitions including types, labels, and validation rules. Use this to understand what fields a collection supports before creating or editing docs.",inputSchema:s.object({collectionId:s.string().describe('Collection id, e.g. "Pages" or "BlogPosts".')}),execute:async({collectionId:t})=>{let i=await e.loadCollection(t);return i?{found:!0,collectionId:t,fields:_(i.fields||[])}:{found:!1,collectionId:t}}}}}function S(e){let t=e.indexOf("/");if(t<=0||t===e.length-1)throw new Error(`invalid docId: "${e}" (expected "Collection/slug")`);return{collection:e.slice(0,t),slug:$(e.slice(t+1))}}function v(e,t,i,r){let o=Number.isFinite(e)?Math.trunc(e):r;return Math.min(Math.max(o,t),i)}function A(e){return F(e??{})}function N(e){return F(e??{})}function _(e){return e.map(t=>{let i={id:t.id,type:t.type};return t.label&&(i.label=t.label),t.description&&(i.description=t.description),t.required&&(i.required=!0),t.translate&&(i.translate=!0),t.options&&(i.options=t.options),t.type==="object"&&t.fields&&(i.fields=_(t.fields)),t.type==="array"&&t.of&&(i.of=_([t.of])[0]),t.type==="oneof"&&t.types&&(i.types=t.types.map(r=>typeof r=="string"?r:{id:r.id,fields:_(r.fields||[])})),i})}function H(e,t,i){let r=V(e,t);if(r.error)return[r.error];let o=r.field;return o?g(i,o,t):[]}function V(e,t){let i=R(t);if(i)return{field:null,error:i};let r=t.trim().split(".");if(r.length===0)return{field:null};let o=e.fields||[],n=null;for(let a=0;a<r.length;a++){let d=r[a],f=r.slice(0,a+1).join("."),l=/^\d+$/.test(d),u=/^(0|[1-9]\d*)$/.test(d);if(l&&!u)return{field:null,error:h(f,"Array indices must be zero-based numeric path segments without leading zeros.","array index",d)};if(u){if(!n||n.type!=="array")return{field:null,error:h(f,"Array index path segments can only be used after an array field.","array field",n?.type||"root")};let x=n.of;n=x,o=x.type==="object"?x.fields:[];continue}if(n?.type==="array")return{field:null,error:h(f,"Array fields must be followed by a zero-based numeric index before nested fields.","array index",d)};let m=o.find(p=>p.id===d);if(!m&&n?.type==="oneof"){let p=n,x=Array.isArray(p.types)?p.types:[];for(let C of x){if(typeof C=="string")continue;let O=(C.fields||[]).find(P=>P.id===d);if(O){m=O;break}}}if(!m)return{field:null};n=m,m.type==="object"?o=m.fields:m.type==="array"?o=[]:o=[]}return{field:n}}function R(e){let t=e.trim();if(!t)return h(e,"Path is required and must be relative to the doc fields object.","non-empty field path",e);let i=t.split(".");return i.some(r=>r.length===0)?h(e,"Path must use dotted field segments without empty segments.","dotted field path",e):i[0]==="fields"?h(e,'Path must be relative to the fields object; remove the leading "fields." prefix.',"field path without fields prefix",e):i.some(r=>/[[\]]/.test(r))?h(e,'Use dotted zero-based array indices, e.g. "content.modules.0.title".',"dotted array index path",e):null}function h(e,t,i,r){return{path:e,message:t,expected:i,received:r}}var w=/^(0|[1-9]\d*)$/;function K(e,t){let i=JSON.parse(JSON.stringify(e??{}));for(let r=0;r<t.length;r++){let o=D(i,t[r],r);if(o)return{ok:!1,error:o}}return{ok:!0,fields:i}}function D(e,t,i){if(t.op!=="set"&&t.op!=="insert_item"&&t.op!=="remove_item")return y(i,t,typeof t.path=="string"?t.path:String(t.path),`Unknown operation "${t.op}".`,"set | insert_item | remove_item",t.op);if(typeof t.path!="string")return y(i,t,String(t.path),"Operation `path` must be a string.","string",b(t.path));let r=R(t.path);if(r)return{opIndex:i,op:t.op,...r};let o=t.path.trim().split("."),n=o[o.length-1],a=t.path.trim(),d=w.test(n),f=q(e,o,t.op!=="remove_item");if(!f.ok)return{opIndex:i,op:t.op,...f.error};let l=f.container;if(t.op==="set"){if(t.value===void 0)return y(i,t,a,'A "set" operation requires a `value`.',"value","undefined");if(Array.isArray(l)){if(!d)return y(i,t,a,"Use a zero-based array index to set an array item.","array index",n);let m=Number(n);return m>l.length?y(i,t,a,"Array index is out of range; set an existing index or append at the array length.",`0..${l.length}`,m):(l[m]=t.value,null)}return l&&typeof l=="object"?d?y(i,t,a,"Array index used on a non-array field.","object key",n):(l[n]=t.value,null):y(i,t,a,"Cannot set a value here; the parent is not an object or array.","object or array",b(l))}let u=J(l,n,d);if(t.op==="insert_item"){if(t.value===void 0)return y(i,t,a,'An "insert_item" operation requires a `value`.',"value","undefined");if(u==null){u=[];let p=U(l,n,d,u,i,t);if(p)return p}if(!Array.isArray(u))return y(i,t,a,'The target of an "insert_item" must be an array field.',"array",b(u));let m=t.index===void 0?u.length:t.index;return m<0||m>u.length?y(i,t,a,"Insert index is out of range.",`0..${u.length}`,m):(u.splice(m,0,t.value),null)}return Array.isArray(u)?t.index===void 0?y(i,t,a,'A "remove_item" operation requires an `index`.',"index","undefined"):t.index<0||t.index>=u.length?y(i,t,a,"Remove index is out of range.",`0..${Math.max(u.length-1,0)}`,t.index):(u.splice(t.index,1),null):y(i,t,a,'The target of a "remove_item" must be an array field.',"array",b(u))}function q(e,t,i){let r=e;for(let o=0;o<t.length-1;o++){let n=t[o],a=t.slice(0,o+1).join("."),d=w.test(n);if(Array.isArray(r)){if(!d)return j(a,"Expected a zero-based array index after an array field.","array index",n);let f=Number(n);if(f>=r.length)return j(a,"Array index is out of range for the current draft.",`0..${Math.max(r.length-1,0)}`,f);r=r[f];continue}if(r===null||typeof r!="object")return j(a,"Path walks through a value that is not an object or array.","object or array",b(r));if(d)return j(a,"Array index used on a non-array field.","object key",n);if(r[n]===void 0||r[n]===null){if(!i)return j(a,"Path segment does not exist in the current draft.","existing field",n);r[n]=w.test(t[o+1])?[]:{}}r=r[n]}return{ok:!0,container:r}}function J(e,t,i){if(Array.isArray(e))return i?e[Number(t)]:void 0;if(e&&typeof e=="object")return e[t]}function U(e,t,i,r,o,n){return Array.isArray(e)?i?(e[Number(t)]=r,null):y(o,n,n.path.trim(),"Use a zero-based array index for an array field.","array index",t):e&&typeof e=="object"?i?y(o,n,n.path.trim(),"Array index used on a non-array field.","object key",t):(e[t]=r,null):y(o,n,n.path.trim(),"Cannot write here; the parent is not an object or array.","object or array",b(e))}function j(e,t,i,r){return{ok:!1,error:{path:e,message:t,expected:i,received:r}}}function y(e,t,i,r,o,n){return{opIndex:e,op:t.op,path:i,message:r,expected:o,received:n}}function b(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?"array":typeof e}export{Y as CMS_TOOL_NAMES,T as READ_ONLY_CMS_TOOL_NAMES,K as applyDocEdits,M as createCmsTools,Z as createReadOnlyCmsTools,k as validateFields,H as validateValueAtPath};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import{a as pt,b as ht,c as ut,d as tt}from"./chunk-HO3W4RVG.js";import{a as dt}from"./chunk-2EPQJUGM.js";import{a as mt,c as Z}from"./chunk-NJMNOITA.js";import{b as ct,d as _t}from"./chunk-344GZOGG.js";import{f as K}from"./chunk-5MV6XVGA.js";import{d as at,e as M}from"./chunk-BUNR5EU3.js";import{$a as Y,Dc as st,Fa as O,Ga as t,Rc as lt,V,W as E,Yc as B,Za as q,_a as X,a as p,ba as J,c as k,da as S,e as N,g as ot,gc as G,h as T,j as At,lb as it,lc as Q,mc as rt,qa as $,xc as j}from"./chunk-LROR6N3B.js";import{d as et}from"./chunk-KUCVLANF.js";import{h as nt}from"./chunk-7SK47HHZ.js";At();function ft(o){let{size:e=14}=o,a=e*3.57,i=e*2;return t("div",{className:"BouncingLoader",style:{"--dot-size":`${e}px`,width:`${a}px`,height:`${i}px`}})}var W=[{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."}],It="root-cms.ai.executionMode",vt="root-cms.ai.selectedModel";function bt(o){return W.some(e=>e.id===o)}function Rt(){if(typeof window>"u")return"approve";try{let o=window.localStorage.getItem(It);if(bt(o))return o}catch(o){console.error("failed to read AI execution mode preference",o)}return"approve"}function yt(o){if(typeof window>"u")return null;try{let e=window.localStorage.getItem(vt);if(e&&o.some(a=>a.id===e))return e}catch(e){console.error("failed to read AI model preference",e)}return null}function wt(o){if(!(typeof window>"u"))try{window.localStorage.setItem(vt,o)}catch(e){console.error("failed to save AI model preference",e)}}function kt(o){if(!(typeof window>"u"))try{window.localStorage.setItem(It,o)}catch(e){console.error("failed to save AI execution mode preference",e)}}var U="";function Ie(o){let[e,a]=p(null),[i,m]=p("");k(()=>{let r=!0;return fetch("/cms/api/ai.config",{credentials:"include"}).then(async l=>{let g=await l.json();r&&a(g)}).catch(l=>{r&&m(String(l))}),()=>{r=!1}},[]);let h=!!e?.enabled&&(e.models?.length||0)>0;return t("div",{className:M("RootAIChat",`RootAIChat--${o.variant}`),children:!e&&!i?t("div",{className:"RootAIChat__loading",children:t(V,{size:"md",color:"gray"})}):h?t(Mt,{variant:o.variant,config:e,initialChatId:o.variant==="panel"?void 0:o.initialChatId,docContext:o.docContext,onClose:o.onClose}):t(Nt,{error:i,onClose:o.onClose})})}function Nt(o){return t("div",{className:"RootAIChat__notEnabled",children:[o.onClose&&t(E,{className:"RootAIChat__notEnabled__close",onClick:o.onClose,title:"Close",children:t(B,{size:16})}),t("div",{className:"RootAIChat__notEnabled__icon",children:t(j,{size:36})}),t("div",{className:"RootAIChat__notEnabled__title",children:"Root AI is not configured for this project."}),t("div",{className:"RootAIChat__notEnabled__body",children:["Add an ",t("code",{children:"ai.models"})," entry to ",t("code",{children:"cmsPlugin()"})," in"," ",t("code",{children:"root.config.ts"}),"."]}),o.error&&t("pre",{className:"RootAIChat__notEnabled__error",children:o.error})]})}function Mt(o){let e=o.variant==="panel",{route:a}=at(),i=o.config.models||[],m=()=>yt(i)||o.config.defaultModel||i[0]?.id||"",[h,r]=p(m),[l,g]=p(Rt),[u,I]=p(o.initialChatId||U),[P,y]=p(o.initialChatId||U),[D,s]=p([]),[f,x]=p([]),[v,w]=p(0),z=async()=>{if(!e)try{let R=await(await fetch("/cms/api/ai.chats.list",{method:"POST",credentials:"include",headers:{"content-type":"application/json"},body:JSON.stringify({})})).json();R.success&&x(R.chats||[])}catch(d){console.error("failed to load chat list",d)}};k(()=>{z(),!e&&o.initialChatId&&n(o.initialChatId)},[]),k(()=>{kt(l)},[l]);let n=async d=>{try{let b=await(await fetch("/cms/api/ai.chats.get",{method:"POST",credentials:"include",headers:{"content-type":"application/json"},body:JSON.stringify({id:d})})).json();if(!b.success)return;I(d),y(d),s(b.chat.messages||[]),b.chat.modelId&&i.find(F=>F.id===b.chat.modelId)&&r(b.chat.modelId),w(L=>L+1)}catch(R){console.error("failed to load chat",R)}},_=()=>{r(m()),I(U),y(U),s([]),w(d=>d+1),e||a("/cms/ai")},c=async d=>{if(d!==P)try{let b=await(await fetch("/cms/api/ai.chats.get",{method:"POST",credentials:"include",headers:{"content-type":"application/json"},body:JSON.stringify({id:d})})).json();if(!b.success)return;I(d),y(d),s(b.chat.messages||[]),b.chat.modelId&&i.find(F=>F.id===b.chat.modelId)&&r(b.chat.modelId),w(L=>L+1),e||a(`/cms/ai/chat/${d}`)}catch(R){console.error("failed to load chat",R)}},C=async d=>{try{await fetch("/cms/api/ai.chats.delete",{method:"POST",credentials:"include",headers:{"content-type":"application/json"},body:JSON.stringify({id:d})}),P===d&&_(),z()}catch(R){console.error("failed to delete chat",R)}},A=i.find(d=>d.id===h)||i[0],H=d=>{r(d),wt(d)};return t("div",{className:"RootAIChat__layout",children:[!e&&t(Tt,{chats:f,activeChatId:P,onSelect:c,onNew:_,onDelete:C}),t("div",{className:"RootAIChat__main",children:[e&&t(Pt,{onNewChat:_,onClose:o.onClose}),t(zt,{initialChatId:u,model:A,initialMessages:D,executionMode:l,models:i,selectedModel:A,docContext:o.docContext,onSelectModel:H,onSelectExecutionMode:g,onChatPersisted:d=>{y(d),z(),e||window.history.replaceState(null,"",`/cms/ai/chat/${d}`)}},v)]})]})}function Pt(o){return t("div",{className:"RootAIChat__panelHeader",children:[t("div",{className:"RootAIChat__panelHeader__title",children:[t(j,{size:14}),t("span",{children:"Root AI"})]}),t("div",{className:"RootAIChat__panelHeader__actions",children:[t(O,{label:"New chat",children:t(E,{size:"xs",onClick:o.onNewChat,children:t(G,{size:14})})}),o.onClose&&t(O,{label:"Close (\u2318 + i)",children:t(E,{size:"xs",onClick:o.onClose,children:t(B,{size:14})})})]})]})}function Tt(o){return t("aside",{className:"RootAIChat__sidebar",children:[t("button",{type:"button",className:"RootAIChat__sidebar__newButton",onClick:o.onNew,children:[t(G,{size:18}),t("span",{children:"New chat"})]}),t("div",{className:"RootAIChat__sidebar__list",children:[o.chats.length===0&&t("div",{className:"RootAIChat__sidebar__empty",children:"No chats yet."}),o.chats.map(e=>t("div",{className:M("RootAIChat__sidebar__item",e.id===o.activeChatId&&"RootAIChat__sidebar__item--active"),onClick:()=>o.onSelect(e.id),children:[t("div",{className:"RootAIChat__sidebar__item__title",title:e.title||"Untitled chat",children:e.title||"Untitled chat"}),t("button",{type:"button",className:"RootAIChat__sidebar__item__delete",title:"Delete chat",onClick:a=>{a.stopPropagation(),window.confirm("Delete this chat?")&&o.onDelete(e.id)},children:t(lt,{size:14})})]},e.id))]})]})}function Et(o){let e=W.find(a=>a.id===o.executionMode)||W[0];return t("div",{className:"RootAIChat__options",children:[t($,{control:t(S,{type:"button",className:"RootAIChat__modePicker",variant:"subtle",color:"dark",size:"xs",compact:!0,leftIcon:t(rt,{size:16}),children:e.label}),children:W.map(a=>t($.Item,{onClick:()=>o.onSelectExecutionMode(a.id),children:t("div",{className:"RootAIChat__modePicker__option",children:[t("div",{className:"RootAIChat__modePicker__option__label",children:a.label}),t("div",{className:"RootAIChat__modePicker__option__description",children:a.description})]})},a.id))}),t($,{control:t(S,{type:"button",className:"RootAIChat__modelPicker",variant:"subtle",color:"dark",size:"xs",compact:!0,leftIcon:t(j,{size:16}),children:o.selectedModel?.label||"Select model"}),children:o.models.map(a=>t($.Item,{onClick:()=>o.onSelectModel(a.id),children:t("div",{className:"RootAIChat__modelPicker__option",children:[t("div",{className:"RootAIChat__modelPicker__option__label",children:a.label}),a.description&&t("div",{className:"RootAIChat__modelPicker__option__description",children:a.description})]})},a.id))})]})}function zt(o){let[e]=p(()=>o.initialChatId||Gt()),a=N(o.model?.id);a.current=o.model?.id;let i=N(o.executionMode);i.current=o.executionMode;let m=N(o.docContext);m.current=o.docContext;let[h,r]=p({}),l=N({});k(()=>()=>{for(let n of Object.values(l.current))n("reject");l.current={}},[]);let g=T((n,_,c,C)=>new Promise(A=>{l.current[n]=A,r(H=>({...H,[n]:{toolCallId:n,toolName:_,input:c,preview:C,status:"pending"}}))}),[]),u=T(n=>{r(_=>{let c=_[n];return c?{..._,[n]:{...c,status:"executing"}}:_}),l.current[n]?.("approve"),delete l.current[n]},[]),I=T(n=>{r(_=>{let c={..._};return delete c[n],c}),l.current[n]?.("reject"),delete l.current[n]},[]),P=T(async n=>{if(!ht(n.toolName))return await tt(n.toolName,n.input);let _=i.current;if(_==="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 ut(n.toolName,n.input)}catch(C){return{success:!1,error:"PREVIEW_FAILED",message:C?.message||String(C)}}if(c.error)return{success:!1,error:c.error,message:c.summary,errors:c.errors,hint:c.hint};if(_==="approve"&&await g(n.toolCallId,n.toolName,n.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 tt(n.toolName,n.input)}finally{r(C=>{if(!C[n.toolCallId])return C;let A={...C};return delete A[n.toolCallId],A})}},[g]),y=ot(()=>new ct({api:"/cms/api/ai.chat",credentials:"include",prepareSendMessagesRequest:({messages:n})=>({body:{message:n.at(-1),chatId:e,modelId:a.current,executionMode:i.current,docId:m.current?.docId}})}),[e]),{messages:D,sendMessage:s,status:f,error:x,stop:v,addToolOutput:w}=pt({id:e,messages:o.initialMessages,transport:y,sendAutomaticallyWhen:_t,onToolCall:async({toolCall:n})=>{let _=await P(n);w({tool:n.toolName,toolCallId:n.toolCallId,output:_})},onFinish:()=>{o.onChatPersisted(e)}}),z=f==="streaming"||f==="submitted";return t(et,{children:[t(St,{messages:D,isStreaming:z,emptyMessage:o.model?void 0:"Select a model to start.",toolApprovals:{approvals:h,onApprove:u,onReject:I}}),x&&t("div",{className:"RootAIChat__error",children:[t("strong",{children:"Error:"})," ",x.message]}),t(Vt,{disabled:!o.model,canAttach:o.model?.capabilities.attachments??!1,isStreaming:z,onStop:v,controls:t(Et,{models:o.models,selectedModel:o.selectedModel,onSelectModel:o.onSelectModel,executionMode:o.executionMode,onSelectExecutionMode:o.onSelectExecutionMode}),onSend:(n,_)=>{if(!n&&_.length===0)return;let c=Jt(_),C=[n,c.text].filter(Boolean).join(`
|
|
2
|
-
|
|
3
|
-
`);s({text:C,files:c.files.map(A=>({type:"file",mediaType:A.mediaType,url:A.url,filename:A.filename}))})}})]})}function St(o){let e=N(null);return k(()=>{let a=e.current;a&&(a.scrollTop=a.scrollHeight)},[o.messages]),o.messages.length===0?t("div",{className:"RootAIChat__transcript RootAIChat__transcript--empty",ref:e,children:t("div",{className:"RootAIChat__welcome",children:[t("div",{className:"RootAIChat__welcome__icon",children:t(j,{size:36})}),t("div",{className:"RootAIChat__welcome__title",children:"Root AI"}),t("div",{className:"RootAIChat__welcome__body",children:o.emptyMessage||"What are we going to get done today?"})]})}):t("div",{className:"RootAIChat__transcript",ref:e,children:t("div",{className:"RootAIChat__transcript__inner",children:[o.messages.map(a=>t(jt,{message:a,toolApprovals:o.toolApprovals},a.id)),o.isStreaming&&t("div",{className:"RootAIChat__streamingIndicator",children:t(ft,{size:6})})]})})}function jt(o){let e=o.message,a=e.role==="user",i=a?"You":"Root AI",m=a?window.firebase.user?.photoURL:null,[h,r]=p(!1),l=T(()=>(e.parts||[]).filter(u=>u.type==="text"&&u.text).map(u=>u.text).join(`
|
|
4
|
-
|
|
5
|
-
`),[e.parts]),g=T(async()=>{let u=l();if(!u)return;let I=mt.parse(u);try{await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([I],{type:"text/html"}),"text/plain":new Blob([u],{type:"text/plain"})})]),r(!0),setTimeout(()=>r(!1),2e3)}catch{await navigator.clipboard.writeText(u),r(!0),setTimeout(()=>r(!1),2e3)}},[l]);return t("div",{className:M("RootAIChat__message",`RootAIChat__message--${e.role}`),children:[t("div",{className:"RootAIChat__message__avatar",children:m?t("img",{src:m,alt:i}):t(j,{size:20})}),t("div",{className:"RootAIChat__message__body",children:[t("div",{className:"RootAIChat__message__username",children:i}),t("div",{className:"RootAIChat__message__parts",children:(e.parts||[]).map((u,I)=>t(Dt,{part:u,toolApprovals:o.toolApprovals},I))}),t("button",{type:"button",className:M("RootAIChat__message__copy",h&&"RootAIChat__message__copy--copied"),title:h?"Copied!":"Copy message",onClick:g,children:h?t(q,{size:14}):t(it,{size:14})})]})]})}function Dt(o){let e=o.part;return e.type==="text"?e.text?t("div",{className:"RootAIChat__textPart",children:t(Z,{code:e.text})}):null:e.type==="reasoning"?t(Lt,{text:e.text}):e.type==="file"?t($t,{part:e}):e.type==="source-url"?t("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-")?t(gt,{part:e,toolApprovals:o.toolApprovals}):e.type==="dynamic-tool"?t(gt,{part:e,toolApprovals:o.toolApprovals}):e.type==="step-start"?null:t("div",{className:"RootAIChat__unknownPart",children:t("pre",{children:JSON.stringify(e,null,2)})})}function Lt(o){let[e,a]=p(!1);return o.text?t("div",{className:M("RootAIChat__reasoning",e&&"RootAIChat__reasoning--open"),children:[t("button",{type:"button",className:"RootAIChat__reasoning__toggle",onClick:()=>a(!e),children:[t(X,{size:14,style:{transform:e?"rotate(0deg)":"rotate(-90deg)"}}),t("span",{children:"Thinking"})]}),e&&t("div",{className:"RootAIChat__reasoning__body",children:t(Z,{code:o.text})})]}):null}function $t(o){let e=o.part;return e.mediaType?.startsWith("image/")?t("div",{className:"RootAIChat__filePart",children:t("img",{src:e.url,alt:e.filename||"attachment"})}):t("a",{className:"RootAIChat__filePart RootAIChat__filePart--link",href:e.url,target:"_blank",rel:"noopener noreferrer",children:[t(Q,{size:14}),t("span",{children:e.filename||e.url})]})}function gt(o){let e=o.part,a=typeof e.type=="string"&&e.type.startsWith("tool-")?e.type.slice(5):e.toolName||"tool",i=e.state||"",m=Bt(e),h=o.toolApprovals,r=m?h?.approvals[m]:void 0,[l,g]=p(!!r);return k(()=>{r&&g(!0)},[r]),t("div",{className:"RootAIChat__tool",children:[t("button",{type:"button",className:"RootAIChat__tool__header",onClick:()=>g(!l),children:[t(X,{className:M("RootAIChat__tool__header__icon",l&&"RootAIChat__tool__header__icon--open"),size:14}),t(J,{color:"dark",variant:"filled",size:"xs",children:a}),t("span",{className:"RootAIChat__tool__title",children:Ot(a,e.input)}),t("span",{className:"RootAIChat__tool__state",children:r?Ht(r.status):Ft(i)})]}),l&&t("div",{className:"RootAIChat__tool__body",children:[r&&h&&t(Ut,{approval:r,onApprove:()=>h.onApprove(r.toolCallId),onReject:()=>h.onReject(r.toolCallId)}),e.output?.receipt&&t(Wt,{output:e.output}),e.input&&t("details",{children:[t("summary",{children:[t(Y,{size:14,className:"RootAIChat__tool__json__icon"}),t("span",{children:"Input"})]}),t("pre",{children:JSON.stringify(e.input,null,2)})]}),e.output&&t("details",{children:[t("summary",{children:[t(Y,{size:14,className:"RootAIChat__tool__json__icon"}),t("span",{children:"Output"})]}),t("pre",{children:JSON.stringify(e.output,null,2)})]}),e.errorText&&t("div",{className:"RootAIChat__tool__error",children:e.errorText})]})]})}function Bt(o){return o.toolCallId||o.id||""}function Ot(o,e){switch(o){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 o}}function Ut(o){let e=o.approval.preview,a=e.before!==void 0&&e.after!==void 0;return t("div",{className:"RootAIChat__approval",children:[t("div",{className:"RootAIChat__approval__header",children:[t("div",{children:[t("div",{className:"RootAIChat__approval__title",children:e.title}),t("div",{className:"RootAIChat__approval__summary",children:e.summary})]}),t(J,{className:"RootAIChat__approval__status",variant:"light",color:"gray",children:o.approval.status==="executing"?"Applying":"Review"})]}),e.details.length>0&&t("div",{className:"RootAIChat__approval__details",children:e.details.map(i=>t("div",{children:[t("span",{children:i.label}),t("strong",{children:i.value})]},`${i.label}:${i.value}`))}),a&&t(dt,{className:"RootAIChat__approval__diff",oldCode:K(e.before),newCode:K(e.after)}),t("div",{className:"RootAIChat__approval__actions",children:[t(S,{variant:"default",color:"dark",size:"xs",type:"button",className:"RootAIChat__approval__button",disabled:o.approval.status==="executing",onClick:o.onReject,children:"Reject"}),t(S,{variant:"filled",color:"green",size:"xs",type:"button",className:"RootAIChat__approval__button RootAIChat__approval__button--primary",disabled:o.approval.status==="executing",onClick:o.onApprove,children:"Approve draft edit"})]})]})}function Wt(o){let e=o.output.receipt;return t("div",{className:"RootAIChat__receipt",children:[t("div",{className:"RootAIChat__receipt__title",children:[t(q,{size:14}),t("span",{children:e.title})]}),t("div",{className:"RootAIChat__receipt__summary",children:e.summary}),e.details?.length>0&&t("div",{className:"RootAIChat__receipt__details",children:e.details.map(a=>t("div",{children:[t("span",{children:a.label}),t("strong",{children:a.value})]},`${a.label}:${a.value}`))}),e.adminUrl&&t(S,{component:"a",className:"RootAIChat__receipt__link",variant:"default",size:"xs",compact:!0,href:e.adminUrl,children:"Open document"})]})}function Ht(o){return o==="executing"?"applying\u2026":"waiting for approval"}function Ft(o){switch(o){case"input-streaming":return"preparing\u2026";case"input-available":return"running\u2026";case"output-available":return"done";case"output-error":return"error";default:return o}}function Vt(o){let[e,a]=p(""),[i,m]=p([]),[h,r]=p(!1),l=N(null),g=N(null);k(()=>{window.requestAnimationFrame(()=>{let s=g.current;s&&(s.style.height="auto",s.style.height=`${Math.min(s.scrollHeight,240)}px`)})},[e,i]);let I=()=>{o.disabled||o.isStreaming||!e&&i.length===0||(o.onSend(e,i),a(""),m([]),l.current&&(l.current.value=""))},P=s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),I())},y=async s=>{r(!0);try{let f=s.type||Yt(s.name),x=await qt(s,f),v=await nt(s,{disableGci:!0});m(w=>[...w,{url:v.src,filename:v.filename||s.name,mediaType:f,textContent:x?.text,textTruncated:x?.truncated,width:v.width,height:v.height}])}catch(f){console.error("upload failed",f)}finally{r(!1),l.current&&(l.current.value="")}},D=s=>{let f=s.target;Array.from(f.files||[]).forEach(y)};return t("div",{className:"RootAIChat__composer",children:[i.length>0&&t("div",{className:"RootAIChat__composer__attachments",children:i.map((s,f)=>t("div",{className:"RootAIChat__composer__attachment",children:[s.mediaType.startsWith("image/")?t("img",{src:s.url,alt:s.filename}):t("span",{className:"RootAIChat__composer__attachment__name",children:s.filename}),t("button",{type:"button",className:"RootAIChat__composer__attachment__remove",onClick:()=>m(x=>x.filter((v,w)=>w!==f)),children:t(B,{size:12})})]},f))}),t("div",{className:"RootAIChat__composer__row",children:[t(O,{label:o.canAttach?"Attach file":"Model doesn't support attachments",className:"RootAIChat__composer__attachTooltip",children:t(E,{component:"label",radius:"xl",className:M("RootAIChat__composer__attach",!o.canAttach&&"RootAIChat__composer__attach--disabled"),disabled:!o.canAttach,children:[h?t(V,{size:"xs"}):t(Q,{size:18}),t("input",{ref:l,type:"file",style:{display:"none"},onChange:D})]})}),t("textarea",{ref:g,className:"RootAIChat__composer__textarea",placeholder:o.disabled?"Select a model\u2026":"Ask anything\u2026",value:e,rows:1,autofocus:!0,disabled:o.disabled,onKeyDown:P,onChange:s=>a(s.target.value),onPaste:s=>{let f=s.clipboardData?.items||[];for(let x of f)if(x.kind==="file"){let v=x.getAsFile();v&&o.canAttach&&y(v)}}}),o.isStreaming?t(E,{className:"RootAIChat__composer__button RootAIChat__composer__stopButton",radius:"xl",color:"dark",variant:"filled",onClick:o.onStop,title:"Stop",children:t(B,{size:18})}):t(E,{className:"RootAIChat__composer__button RootAIChat__composer__submitButton",radius:"xl",color:"dark",variant:"filled",disabled:o.disabled||h||!e&&i.length===0,onClick:I,title:"Send",children:t(st,{size:18})})]}),o.controls]})}var xt=1e5;function Jt(o){let e=o.filter(Ct),a=o.filter(i=>!Ct(i)).map(Kt);return{files:e,text:a.length?`Attached files:
|
|
6
|
-
|
|
7
|
-
${a.join(`
|
|
8
|
-
|
|
9
|
-
`)}`:""}}function Ct(o){return o.mediaType.startsWith("image/")}function Kt(o){let e=`File: ${o.filename} (${o.mediaType})`;if(o.textContent!==void 0){let a=o.textTruncated?`
|
|
10
|
-
|
|
11
|
-
[Content truncated before sending to the model.]`:"";return`${e}
|
|
12
|
-
URL: ${o.url}
|
|
13
|
-
|
|
14
|
-
~~~
|
|
15
|
-
${o.textContent}${a}
|
|
16
|
-
~~~`}return`${e}
|
|
17
|
-
URL: ${o.url}
|
|
18
|
-
|
|
19
|
-
[The file was uploaded, but its binary content was not inlined into this chat message.]`}async function qt(o,e){if(!Xt(o.name,e))return null;let a=await o.text();return a.length<=xt?{text:a,truncated:!1}:{text:a.slice(0,xt),truncated:!0}}function Xt(o,e){return e.startsWith("text/")?!0:[".css",".js",".jsx",".json",".md",".mdx",".mjs",".scss",".ts",".tsx",".txt",".yaml",".yml"].some(a=>o.toLowerCase().endsWith(a))}function Yt(o){let e=o.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 Gt(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`chat-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}export{Ie as a};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{k as z}from"./chunk-D3UIZHRK.js";import{c as T}from"./chunk-JDW4UORS.js";import{C as _}from"./chunk-AGFPVTBA.js";import{f as l}from"./chunk-KRNQ6L35.js";import{a as f,b as w,c as s,g as b,i as k,n as v,o as j,q as u,t as R,u as c,v as y,x as I}from"./chunk-VD6G5NV4.js";var O=["agile","airy","alert","amber","amused","ancient","aqua","arctic","astral","autumn","avid","azure","balmy","beige","big","bitter","black","blazing","blissful","blooming","blue","bold","bouncy","brainy","brave","breezy","bright","brisk","broad","bronze","brown","bubbly","busy","calm","candid","careful","caring","charming","cheerful","cherry","chilly","chipper","classic","clean","clear","clever","cloudy","coastal","cobalt","cold","cool","copper","coral","cosmic","cosy","cozy","crafty","creamy","crimson","crisp","cuddly","curious","dandy","dapper","daring","dark","dawn","dazzling","dear","deep","deft","delicate","dewy","dizzy","dotted","dreamy","driven","dry","dusky","dusty","eager","early","earnest","earthy","eastern","easy","ebony","elated","electric","elegant","emerald","empty","epic","even","every","faint","fair","falling","famous","fancy","fast","feisty","festive","fierce","fiery","fine","firm","flat","floral","flowing","fluffy","foggy","fond","forest","fragrant","fresh","friendly","frisky","frosty","funky","funny","fuzzy","gallant","gentle","giant","gilded","glad","gleaming","glossy","glowing","gold","golden","good","graceful","grand","grassy","gray","green","groovy","gusty","handy","happy","hardy","hazy","hearty","heavy","helpful","heroic","hidden","high","holy","honest","honeyed","hopeful","humble","humming","hushed","icy","ideal","idle","indigo","inky","iron","ivory","jade","jaunty","jazzy","jolly","jovial","joyful","jubilant","juicy","jumpy","keen","kind","kindly","lacy","late","lazy","leafy","lemon","light","limber","lime","linen","little","lively","lone","long","loud","lovely","loyal","lucid","lucky","luminous","lunar","lush","magenta","magic","majestic","mango","marble","maritime","maroon","massive","mauve","mellow","merry","mighty","mild","milky","mindful","minty","misty","mocha","modest","morning","mossy","muddy","mysterious","mythic","narrow","navy","neat","neon","new","nimble","noble","noisy","noon","northern","nosy","nutty","oaken","oceanic","odd","old","olive","onyx","opal","open","orange","orderly","pale","pastel","patient","peaceful","peach","peachy","pearly","pebbly","peppy","perky","pink","placid","plain","playful","pleasant","plucky","plum","plush","polar","polite","prime","pristine","proud","pure","purple","quaint","quick","quiet","quirky","radiant","rapid","rare","raven","ready","red","regal","restless","rich","rolling","rosy","rough","round","royal","ruby","rugged","rumbling","russet","rustic","sable","safe","sage","salty","sandy","sapphire","savvy","scarlet","scenic","secret","sepia","serene","shaggy","sharp","shimmering","shiny","short","shrewd","shy","silent","silky","silly","silver","simple","sleek","sleepy","slim","slow","small","smart","smoky","smooth","snappy","snowy","soaring","soft","solar","solid","southern","sparkly","speedy","spicy","spiffy","spotted","spry","square","starry","steady","steel","stellar","sticky","still","stony","stormy","striped","strong","sturdy","subtle","sunlit","sunny","super","supreme","swank","sweet","swift","tame","tan","tangy","tart","teal","tender","thin","thirsty","thriving","tidal","tidy","tiny","tireless","toasty","topaz","tough","tranquil","trim","tropical","true","twinkly","umber","upbeat","urban","useful","valiant","vast","velvet","verdant","vernal","vibrant","vintage","violet","vivid","wandering","warm","watchful","wavy","wee","western","whimsical","whispering","white","wholesome","wild","winding","windy","winter","wintry","wise","witty","wondrous","woody","wool","yellow","young","youthful","zany","zealous","zen","zesty","zippy"],A=["acorn","almond","alpaca","anchor","antler","apple","apricot","arrow","aspen","aurora","autumn","avocado","badger","bagel","bamboo","banana","basil","bay","bayou","beach","bear","bee","beetle","bell","berry","birch","bird","biscuit","bison","blossom","bluff","boat","bobcat","bonfire","book","boot","bottle","boulder","branch","brass","breeze","bridge","brook","broom","brunch","bubble","bucket","bud","buffalo","bug","bunny","burrow","butter","button","cabin","cactus","cake","camel","canary","candle","canyon","cape","caravan","cardinal","carrot","cascade","cashew","castle","cat","cave","cedar","chair","cherry","chestnut","chickpea","chime","cinnamon","citadel","cliff","cloud","clove","clover","cocoa","comet","compass","condor","cookie","coral","cottage","cotton","cove","coyote","crane","crayon","creek","cricket","crocus","crow","crumpet","crystal","cup","cupcake","currant","cypress","daffodil","dahlia","daisy","dawn","deer","delta","desert","dew","diamond","dingo","dock","dogwood","dolphin","donut","dove","dragon","drift","drizzle","drum","duck","dumpling","dune","eagle","echo","eclipse","eel","egg","elder","elephant","elk","ember","ermine","estuary","evergreen","falcon","fawn","feather","fennel","fern","ferret","field","fig","finch","fir","firefly","fish","fjord","flame","flamingo","flask","flax","fleece","flicker","flower","flute","fog","forest","fossil","fountain","fox","frog","frost","galaxy","garden","gazelle","gecko","gem","geyser","ginger","glacier","glade","glen","globe","glow","goat","goose","gorge","gourd","granite","grape","grass","grotto","grove","gull","hammock","harbor","hare","harp","harvest","hat","hawk","haystack","hazel","hearth","heather","hedge","heron","hibiscus","hickory","hill","hollow","honey","horizon","horse","hummingbird","ibis","iceberg","icicle","inlet","iris","island","ivy","jackal","jacket","jade","jaguar","jam","jar","jasmine","jay","jelly","jetty","juniper","kayak","kelp","kestrel","kettle","key","kingfisher","kite","kitten","kiwi","knoll","koala","ladybug","lagoon","lake","lamp","lantern","lark","lava","lavender","leaf","ledge","lemon","lemur","leopard","lichen","lighthouse","lilac","lily","lime","lion","llama","lobster","log","loon","lotus","lynx","lyric","magnet","manatee","mango","mangrove","maple","marble","marigold","marlin","marsh","meadow","melody","melon","mermaid","mesa","meteor","minnow","mint","mirage","mist","mitten","mole","monkey","moon","moose","morel","mosaic","moss","moth","mountain","mouse","muffin","mushroom","mussel","narwhal","nautilus","nectar","needle","nest","nettle","newt","nightingale","nimbus","noodle","north","note","nutmeg","oak","oasis","oats","ocean","ocelot","octopus","olive","onion","opal","orange","orca","orchid","oriole","osprey","otter","owl","oyster","paddle","palm","panda","pansy","panther","papaya","paper","parrot","parsley","partridge","pasture","path","peach","peacock","pear","pebble","pecan","pelican","penguin","peony","pepper","petal","petunia","pheasant","phoenix","pie","pigeon","pine","pineapple","pistachio","planet","plateau","plover","plum","pond","pony","poppy","porpoise","pouch","prairie","pretzel","primrose","puffin","pumpkin","quail","quartz","queen","quill","quince","quokka","rabbit","raccoon","radish","rain","rainbow","rapids","raspberry","raven","redwood","reef","reel","reindeer","rhino","ribbon","ridge","river","road","robin","rock","rooster","rose","rosemary","rowan","rye","saffron","sage","salmon","sand","sapphire","satellite","savanna","scallop","scarf","sea","seagull","seal","seed","sequoia","sesame","shark","shell","shore","shrimp","silk","silo","sky","skylark","sleet","snail","snake","snow","sock","sorbet","spark","sparrow","spider","spire","spoon","spring","sprout","spruce","squirrel","star","starfish","starling","stone","stork","storm","stream","summer","sun","sundial","sunflower","swan","swift","sycamore","tadpole","tamarind","tangerine","tea","teal","tern","terrace","thicket","thistle","thrush","thunder","tide","tiger","timber","toad","toffee","tooth","topaz","tortoise","totem","toucan","tower","tractor","trail","tree","trout","truffle","tugboat","tulip","tundra","turnip","turtle","twig","twilight","umbrella","unicorn","urchin","valley","vanilla","vine","violet","vista","volcano","voyage","vulture","wagon","walnut","walrus","wasp","water","waterfall","wave","whale","wharf","wheat","whisker","wildcat","wildflower","willow","wind","window","winter","wisteria","wolf","wombat","wood","wren","yak","yam","yarrow","yew","yucca","zebra","zephyr","zinnia","zucchini"];var x="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",S="YYYYMMDD";function D(e,r){let a=r?.now??new Date,o=r?.random??Math.random,t=e.replace(/\{([^{}]+?)\}/g,(n,d)=>{let[p,g]=q(d);switch(p){case"date":return E(a,g||S);case"adjective":return C(O,o);case"noun":return C(A,o);case"random":return M(Y(g,6),o);default:return n}});return T(t.toLowerCase())}function q(e){let r=e.indexOf(":");return r===-1?[e.trim(),void 0]:[e.slice(0,r).trim(),e.slice(r+1)]}function Y(e,r){if(!e)return r;let a=parseInt(e,10);return Number.isFinite(a)&&a>0?a:r}function C(e,r){return e[Math.floor(r()*e.length)]}function M(e,r){let a=[];for(let o=0;o<e;o++)a.push(x.charAt(Math.floor(r()*x.length)));return a.join("")}function E(e,r){let a={YYYY:String(e.getFullYear()),YY:String(e.getFullYear()).slice(-2),MM:m(e.getMonth()+1),DD:m(e.getDate()),HH:m(e.getHours()),mm:m(e.getMinutes()),ss:m(e.getSeconds())};return r.replace(/YYYY|YY|MM|DD|HH|mm|ss/g,o=>a[o]??o)}function m(e){return e<10?`0${e}`:String(e)}var i="Releases";async function V(e,r){if(!e)throw new Error("missing data source id");let a=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,t=s(o,"Projects",a,i,e);await R(o,async n=>{if((await n.get(t)).exists())throw new Error(`release exists: ${e}`);await n.set(t,{...r,id:e,createdAt:y(),createdBy:window.firebase.user.email})}),l("release.create",{metadata:{releaseId:e}})}async function G(){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,a=w(r,"Projects",e,i),o=b(a,k("createdAt","desc")),t=await j(o),n=[];return t.forEach(d=>{n.push(d.data())}),n}async function h(e){let r=window.__ROOT_CTX.rootConfig.projectId,a=window.firebase.db,o=s(a,"Projects",r,i,e),t=await v(o);return t.exists()?t.data():null}async function K(e,r){let a=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,t=s(o,"Projects",a,i,e);await u(t,r),l("release.save",{metadata:{releaseId:e}})}async function Q(e){let r=window.__ROOT_CTX.rootConfig.projectId,a=window.firebase.db,o=s(a,"Projects",r,i,e);await u(o,{archivedAt:y(),archivedBy:window.firebase.user.email}),l("release.archive",{metadata:{releaseId:e}})}async function W(e){let r=window.__ROOT_CTX.rootConfig.projectId,a=window.firebase.db,o=s(a,"Projects",r,i,e);await u(o,{archivedAt:c(),archivedBy:c()}),l("release.unarchive",{metadata:{releaseId:e}})}async function Z(e){let r=await h(e);if(!r)throw new Error(`release not found: ${e}`);if(r.archivedAt)throw new Error(`release is archived: ${e}`);let a=r.docIds||[],o=r.dataSourceIds||[];if(a.length===0&&o.length===0)throw new Error(`no docs or data sources to publish for release: ${e}`);let t=window.__ROOT_CTX.rootConfig.projectId,n=window.firebase.db,d=s(n,"Projects",t,i,e),p=I(n);p.update(d,{publishedAt:y(),publishedBy:window.firebase.user.email,scheduledAt:c(),scheduledBy:c()}),o.length>0&&await z(o,{batch:p,commitBatch:!1}),await _(a,{batch:p,releaseId:e,publishMessage:r.description}),console.log(`published release: ${e}`);let g={releaseId:e,docIds:a,dataSourceIds:o};r.description&&(g.publishMessage=r.description),l("release.publish",{metadata:g})}async function ee(e,r){let a=await h(e);if(!a)throw new Error(`release not found: ${e}`);if(a.archivedAt)throw new Error(`release is archived: ${e}`);typeof r=="number"&&(r=f.fromMillis(r));let o=window.__ROOT_CTX.rootConfig.projectId,t=window.firebase.db,n=s(t,"Projects",o,i,e);await u(n,{scheduledAt:r,scheduledBy:window.firebase.user.email}),l("release.publish",{metadata:{releaseId:e,scheduledAt:r.toMillis()}})}function re(){return D("{date}-{adjective}-{noun}")}async function ae(e){if(!await h(e))throw new Error(`release not found: ${e}`);let a=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,t=s(o,"Projects",a,i,e);await u(t,{scheduledAt:c(),scheduledBy:c()}),l("release.unschedule",{metadata:{releaseId:e}})}export{D as a,V as b,G as c,h as d,K as e,Q as f,W as g,Z as h,ee as i,re as j,ae as k};
|