@blinkk/root-cms 3.1.4 → 3.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/dist/app.js +3 -2
  2. package/dist/{chunk-AFBSITEO.js → chunk-PLSNGCYU.js} +200 -22
  3. package/dist/{chunk-MYN76V3L.js → chunk-U4TMO2LI.js} +2 -2
  4. package/dist/{chunk-NC3CRIFA.js → chunk-Z2CTQVYR.js} +1 -1
  5. package/dist/cli.js +1 -1
  6. package/dist/client.js +1 -1
  7. package/dist/core/client.d.ts +30 -2
  8. package/dist/core/cron-schedule.d.ts +63 -0
  9. package/dist/core/plugin.d.ts +6 -1
  10. package/dist/core/schema.d.ts +88 -3
  11. package/dist/core.js +1 -1
  12. package/dist/functions.js +2 -2
  13. package/dist/plugin.js +7 -5
  14. package/dist/richtext.js +1 -1
  15. package/dist/shared/embed-protocol.d.ts +19 -0
  16. package/dist/ui/AIPage-EO5WH25R.js +1 -0
  17. package/dist/ui/{AssetsPage-QUL2NBWK.js → AssetsPage-ESLB4R3I.js} +1 -1
  18. package/dist/ui/CollectionPage-MXN7XKUX.js +1 -0
  19. package/dist/ui/{ComparePage-DCP5QHDE.js → ComparePage-TY7VJVE3.js} +1 -1
  20. package/dist/ui/{DataPage-TUVFBALT.js → DataPage-YEIS7HBN.js} +1 -1
  21. package/dist/ui/{DataSourcePage-YE2ZOHYI.js → DataSourcePage-VD6YBDRW.js} +1 -1
  22. package/dist/ui/{DocTranslationsPage-3ILTQOP2.js → DocTranslationsPage-6XLREBPQ.js} +1 -1
  23. package/dist/ui/DocumentPage-2HNNEGRI.js +1 -0
  24. package/dist/ui/{EditDataSourcePage-WHPZDMD4.js → EditDataSourcePage-E4PSKSG3.js} +1 -1
  25. package/dist/ui/EditReleasePage-DOMXJXCU.js +1 -0
  26. package/dist/ui/EmbeddedAIPage-U5LONYH2.js +1 -0
  27. package/dist/ui/EmbeddedDocumentPage-HYV5GPK6.js +1 -0
  28. package/dist/ui/{ImageEditorDialog-Q44YTLB5.js → ImageEditorDialog-YDKOGVJV.js} +1 -1
  29. package/dist/ui/LogsPage-6KV3CQLH.js +1 -0
  30. package/dist/ui/NewDataSourcePage-NJJDHGPX.js +1 -0
  31. package/dist/ui/NewReleasePage-FXHPFUVG.js +1 -0
  32. package/dist/ui/{NotFoundPage-RMNPVSD3.js → NotFoundPage-CA7XVXUO.js} +1 -1
  33. package/dist/ui/{ProjectPage-VY4EJX6J.js → ProjectPage-XUBJSCWB.js} +1 -1
  34. package/dist/ui/ReleasePage-NLGRYJX7.js +1 -0
  35. package/dist/ui/{ReleasesPage-A4BLUNJE.js → ReleasesPage-OY7OKC3C.js} +1 -1
  36. package/dist/ui/{SettingsPage-MP3YHQDP.js → SettingsPage-5EQUY52A.js} +1 -1
  37. package/dist/ui/SidebarToolsPage-FWG6TIDI.js +1 -0
  38. package/dist/ui/TaskPage-APNRUOYG.js +1 -0
  39. package/dist/ui/TasksPage-FTEELXVZ.js +1 -0
  40. package/dist/ui/{TranslationsArbPage-B7TIRREV.js → TranslationsArbPage-PG5USRYB.js} +1 -1
  41. package/dist/ui/{TranslationsEditPage-VQG4YHA6.js → TranslationsEditPage-GV3ZJXTY.js} +1 -1
  42. package/dist/ui/{TranslationsPage-6VCVMNXI.js → TranslationsPage-3AKSMCNF.js} +1 -1
  43. package/dist/ui/{chunk-5SY2SVEX.js → chunk-235TRWJF.js} +2 -2
  44. package/dist/ui/{chunk-EYVQCOAD.js → chunk-2PTLQRTU.js} +1 -1
  45. package/dist/ui/{chunk-FF4CLAZS.js → chunk-2RRM4HEQ.js} +1 -1
  46. package/dist/ui/{chunk-MAZJRNAL.js → chunk-34W6H4YG.js} +1 -1
  47. package/dist/ui/{chunk-AZ2SK2ZK.js → chunk-3LEYSXZP.js} +1 -1
  48. package/dist/ui/{chunk-L3O3CLWO.js → chunk-44ZU5WMI.js} +1 -1
  49. package/dist/ui/{chunk-MYKJ6VAM.js → chunk-535JU7FU.js} +1 -1
  50. package/dist/ui/chunk-56NMZYX6.js +19 -0
  51. package/dist/ui/{chunk-3WQCVKK4.js → chunk-6WJQBFN5.js} +1 -1
  52. package/dist/ui/{chunk-UHK5N75L.js → chunk-75NMQ3LW.js} +1 -1
  53. package/dist/ui/{chunk-4N6CPIOQ.js → chunk-A7IZAHBZ.js} +1 -1
  54. package/dist/ui/{chunk-2PDMFZBF.js → chunk-C5FRMXDS.js} +1 -1
  55. package/dist/ui/chunk-EYJ6GKZR.js +1 -0
  56. package/dist/ui/{chunk-VB5VMEN7.js → chunk-F7RQT4XN.js} +1 -1
  57. package/dist/ui/chunk-G5647K25.js +1 -0
  58. package/dist/ui/{chunk-74OB6FM4.js → chunk-H37RXS4R.js} +1 -1
  59. package/dist/ui/{chunk-LC6WLVRS.js → chunk-HV3JJ5UT.js} +1 -1
  60. package/dist/ui/{chunk-K3UM5OQF.js → chunk-HXSB6YB2.js} +1 -1
  61. package/dist/ui/chunk-ISUGBMXC.js +1 -0
  62. package/dist/ui/{chunk-WN7HUDGY.js → chunk-JBLSUM6W.js} +1 -1
  63. package/dist/ui/chunk-LAXQZPE3.js +31 -0
  64. package/dist/ui/chunk-MYPLMHFW.js +1 -0
  65. package/dist/ui/{chunk-KBJ4AK5O.js → chunk-NCZD5IWS.js} +1 -1
  66. package/dist/ui/{chunk-XJUQOX4E.js → chunk-O7ESOZQO.js} +1 -1
  67. package/dist/ui/chunk-OWYV43BT.js +1 -0
  68. package/dist/ui/{chunk-XM35ZJBQ.js → chunk-PIJ3E47R.js} +1 -1
  69. package/dist/ui/{chunk-WAT22UHZ.js → chunk-PLYSJ7W5.js} +1 -1
  70. package/dist/ui/{chunk-H3PYPGNR.js → chunk-QFDU6FXP.js} +1 -1
  71. package/dist/ui/{chunk-JSWRHHTZ.js → chunk-QGAPMQEJ.js} +1 -1
  72. package/dist/ui/{chunk-W3ICOHMF.js → chunk-QLIIVG5Q.js} +1 -1
  73. package/dist/ui/{chunk-ELKXEMOU.js → chunk-QRAFYIAW.js} +1 -1
  74. package/dist/ui/{chunk-VRRRFAIV.js → chunk-QWB6MAPJ.js} +1 -1
  75. package/dist/ui/{chunk-GCMX5V3P.js → chunk-RB23LLKL.js} +1 -1
  76. package/dist/ui/{chunk-W2ZAVRAT.js → chunk-ST6QNIWT.js} +57 -57
  77. package/dist/ui/{chunk-76PG55CM.js → chunk-U7LSFUHT.js} +1 -1
  78. package/dist/ui/{chunk-HVYNDEA7.js → chunk-UCYWQEAS.js} +1 -1
  79. package/dist/ui/{chunk-6P75AZ3B.js → chunk-UJX25CXD.js} +1 -1
  80. package/dist/ui/chunk-UOKVF54Y.js +3 -0
  81. package/dist/ui/{chunk-CSUKZZK5.js → chunk-VJRMR2JM.js} +1 -1
  82. package/dist/ui/{chunk-WS37MDM3.js → chunk-WASID5UU.js} +1 -1
  83. package/dist/ui/chunk-WRA24P66.js +7 -0
  84. package/dist/ui/{chunk-ETPZ3TXX.js.LEGAL.txt → chunk-WRA24P66.js.LEGAL.txt} +4 -1
  85. package/dist/ui/{chunk-QHOZXW7Y.js → chunk-Y5EOMMNI.js} +1 -1
  86. package/dist/ui/{chunk-EIMRPYCD.js → chunk-YBHFGQ3Z.js} +1 -1
  87. package/dist/ui/{chunk-62VPTZJL.js → chunk-YP6ZH3MT.js} +1 -1
  88. package/dist/ui/chunk-Z2CRNO3I.js +1 -0
  89. package/dist/ui/{chunk-PR7NB5VK.js → chunk-Z3ZJJWFT.js} +1 -1
  90. package/dist/ui/{chunk-F4F5MH7A.js → chunk-ZAJPNVYS.js} +1 -1
  91. package/dist/ui/ui.css +1 -1
  92. package/dist/ui/ui.js +1 -1
  93. package/package.json +3 -3
  94. package/dist/ui/AIPage-4W4MFELY.js +0 -1
  95. package/dist/ui/CollectionPage-7VU6SUUP.js +0 -1
  96. package/dist/ui/DocumentPage-JFQ3Y2GH.js +0 -1
  97. package/dist/ui/EditReleasePage-QKWHIURV.js +0 -1
  98. package/dist/ui/EmbeddedAIPage-SQLOV4IT.js +0 -1
  99. package/dist/ui/EmbeddedDocumentPage-6FYHUHTE.js +0 -1
  100. package/dist/ui/LogsPage-RC5O722W.js +0 -1
  101. package/dist/ui/NewDataSourcePage-QXW54CHQ.js +0 -1
  102. package/dist/ui/NewReleasePage-TKYWVTOH.js +0 -1
  103. package/dist/ui/ReleasePage-VZAL4KUI.js +0 -1
  104. package/dist/ui/SidebarToolsPage-S5DMIEQ6.js +0 -1
  105. package/dist/ui/TaskPage-LCBDMA4I.js +0 -1
  106. package/dist/ui/TasksPage-72KVSUQY.js +0 -1
  107. package/dist/ui/chunk-ETPZ3TXX.js +0 -7
  108. package/dist/ui/chunk-IMXZTYAA.js +0 -3
  109. package/dist/ui/chunk-J5KDO4RM.js +0 -1
  110. package/dist/ui/chunk-NEA3XU6N.js +0 -19
  111. package/dist/ui/chunk-RN4XVVWD.js +0 -1
  112. package/dist/ui/chunk-SLLTYDVX.js +0 -1
  113. package/dist/ui/chunk-SWTNOWNE.js +0 -1
  114. package/dist/ui/chunk-V3G3554T.js +0 -31
  115. package/dist/ui/chunk-YV5SGR24.js +0 -1
  116. /package/dist/ui/{ImageEditorDialog-Q44YTLB5.js.LEGAL.txt → ImageEditorDialog-YDKOGVJV.js.LEGAL.txt} +0 -0
  117. /package/dist/ui/{chunk-5SY2SVEX.js.LEGAL.txt → chunk-235TRWJF.js.LEGAL.txt} +0 -0
  118. /package/dist/ui/{chunk-W2ZAVRAT.js.LEGAL.txt → chunk-ST6QNIWT.js.LEGAL.txt} +0 -0
@@ -1 +1 @@
1
- import{a as t}from"./chunk-XM35ZJBQ.js";function s(e){if(typeof e=="object"&&e!==null){let o=e;if(typeof o.code=="string"&&typeof o.message=="string")return`${o.code}: ${o.message}`;if(typeof o.body=="string")return o.body;if(typeof o.message=="string")return o.message}return String(e)}async function i(e){try{await e()}catch(o){console.error(o);let r=s(o);t({title:"Error",message:r,color:"red",autoClose:!1})}}export{s as a,i as b};
1
+ import{a as t}from"./chunk-PIJ3E47R.js";function s(e){if(typeof e=="object"&&e!==null){let o=e;if(typeof o.code=="string"&&typeof o.message=="string")return`${o.code}: ${o.message}`;if(typeof o.body=="string")return o.body;if(typeof o.message=="string")return o.message}return String(e)}async function i(e){try{await e()}catch(o){console.error(o);let r=s(o);t({title:"Error",message:r,color:"red",autoClose:!1})}}export{s as a,i as b};
@@ -1 +1 @@
1
- import{e as u}from"./chunk-WS37MDM3.js";import{Ga as m,a as l,c as P,g as p,j as h,wa as f}from"./chunk-ETPZ3TXX.js";h();function $(t,i){let{pageSize:n,resetDeps:o}=i,[s,r]=l(1),e=t.length,a=Math.max(1,Math.ceil(e/n)),g=Math.min(Math.max(s,1),a);P(()=>{r(1)},o??[]);let b=p(()=>{let c=(g-1)*n;return t.slice(c,c+n)},[t,g,n]),d=e===0?0:(g-1)*n+1,x=Math.min(g*n,e);return{page:g,setPage:r,totalPages:a,pageItems:b,totalItems:e,start:d,end:x}}function T(t){return t.total<=1?null:m("div",{className:u(t.className,"Pagination"),children:m(f,{total:t.total,value:t.page,onChange:t.onChange,size:"sm"})})}function z(t){let{start:i,end:n,total:o,noun:s,note:r}=t,e=o===1?s:`${s}s`,a;return o===0?a=`No ${s}s`:i===n?a=`Showing ${i} of ${o} ${e}`:a=`Showing ${i}\u2013${n} of ${o} ${e}`,m("div",{className:u(t.className,"Pagination__summary"),children:[a,r?` (${r})`:""]})}export{$ as a,T as b,z as c};
1
+ import{e as u}from"./chunk-WASID5UU.js";import{Ga as m,a as l,c as P,g as p,j as h,wa as f}from"./chunk-WRA24P66.js";h();function $(t,i){let{pageSize:n,resetDeps:o}=i,[s,r]=l(1),e=t.length,a=Math.max(1,Math.ceil(e/n)),g=Math.min(Math.max(s,1),a);P(()=>{r(1)},o??[]);let b=p(()=>{let c=(g-1)*n;return t.slice(c,c+n)},[t,g,n]),d=e===0?0:(g-1)*n+1,x=Math.min(g*n,e);return{page:g,setPage:r,totalPages:a,pageItems:b,totalItems:e,start:d,end:x}}function T(t){return t.total<=1?null:m("div",{className:u(t.className,"Pagination"),children:m(f,{total:t.total,value:t.page,onChange:t.onChange,size:"sm"})})}function z(t){let{start:i,end:n,total:o,noun:s,note:r}=t,e=o===1?s:`${s}s`,a;return o===0?a=`No ${s}s`:i===n?a=`Showing ${i} of ${o} ${e}`:a=`Showing ${i}\u2013${n} of ${o} ${e}`,m("div",{className:u(t.className,"Pagination__summary"),children:[a,r?` (${r})`:""]})}export{$ as a,T as b,z as c};
@@ -1 +1 @@
1
- import{a as b,c as w}from"./chunk-ELKXEMOU.js";import{a as p}from"./chunk-XM35ZJBQ.js";import{a}from"./chunk-KBJ4AK5O.js";import{b as z,f as I,g as C}from"./chunk-DZYYWCHX.js";import{Cc as N,Ga as n,V as v,a as c,c as y,da as m,j as L}from"./chunk-ETPZ3TXX.js";import{d as M}from"./chunk-KUCVLANF.js";L();var S="PruneTranslationsModal";function W(){let u=b(),o=w();return{open:r=>{u.openContextModal(S,{...o,title:`Prune unused strings from ${r.docId}`,innerProps:r,size:600})}}}function $(u){let{innerProps:o,context:r,id:f}=u,[l,h]=c(!0),[e,k]=c([]),[E,x]=c(!1);y(()=>{let s=!1;async function d(){let t=o.docId,g=await z({tags:[t]}),H=new Set(await Promise.all(o.sourceStrings.map(i=>C(i)))),T=[];for(let[i,P]of Object.entries(g))if(!H.has(i)){let _=P.tags||[];_.includes(t)&&T.push({hash:i,source:P.source||i,tags:_.filter(B=>B!==t)})}s||(k(T),h(!1))}return d().catch(t=>{console.error(t),s||h(!1)}),()=>{s=!0}},[o.docId,o.sourceStrings]);async function U(){if(e.length!==0){x(!0);try{let s=e.map(({hash:t,tags:g})=>({hash:t,tags:g}));await I(s,{mode:"replace"});let d=e.map(t=>t.hash);p({title:"Pruned translations",message:`Removed "${o.docId}" tag from ${d.length} unused translation(s).`,color:"green",autoClose:5e3}),o.onPruned?.(d),r.closeModal(f)}catch(s){console.error(s),p({title:"Error pruning translations",message:String(s),color:"red",autoClose:!1})}finally{x(!1)}}}return n("div",{className:"PruneTranslationsModal",children:[n("div",{className:"PruneTranslationsModal__description",children:n(a,{size:"body",children:["Pruning removes the ",n("strong",{children:o.docId})," tag from translation strings that are no longer referenced by this document. The translations themselves are not deleted and will remain available to other documents that still reference them."]})}),l&&n("div",{className:"PruneTranslationsModal__loading",children:[n(v,{color:"gray",size:"sm"}),n(a,{size:"body",color:"gray",children:"Scanning for unused strings\u2026"})]}),!l&&e.length===0&&n("div",{className:"PruneTranslationsModal__empty",children:n(a,{size:"body",color:"gray",children:['All translations tagged with "',o.docId,'" are still in use. Nothing to prune.']})}),!l&&e.length>0&&n(M,{children:[n(a,{size:"body",weight:"semi-bold",children:[e.length," unused string",e.length!==1?"s":""," will be untagged:"]}),n("div",{className:"PruneTranslationsModal__list",children:e.map(s=>n("div",{className:"PruneTranslationsModal__list__item",children:n(a,{size:"body-sm",children:s.source})},s.hash))})]}),n("div",{className:"PruneTranslationsModal__actions",children:[n(m,{variant:"default",size:"xs",onClick:()=>r.closeModal(f),children:"Cancel"}),n(m,{variant:"filled",size:"xs",color:"red",leftIcon:n(N,{size:14}),loading:E,disabled:l||e.length===0,onClick:U,children:["Prune ",e.length>0?e.length:""," string",e.length!==1?"s":""]})]})]})}$.id=S;export{W as a,$ as b};
1
+ import{a as b,c as w}from"./chunk-QRAFYIAW.js";import{a as p}from"./chunk-PIJ3E47R.js";import{a}from"./chunk-NCZD5IWS.js";import{b as z,f as I,g as C}from"./chunk-DZYYWCHX.js";import{Fc as N,Ga as n,V as v,a as c,c as y,da as m,j as L}from"./chunk-WRA24P66.js";import{d as M}from"./chunk-KUCVLANF.js";L();var S="PruneTranslationsModal";function W(){let u=b(),o=w();return{open:r=>{u.openContextModal(S,{...o,title:`Prune unused strings from ${r.docId}`,innerProps:r,size:600})}}}function $(u){let{innerProps:o,context:r,id:f}=u,[l,h]=c(!0),[e,k]=c([]),[E,x]=c(!1);y(()=>{let s=!1;async function d(){let t=o.docId,g=await z({tags:[t]}),H=new Set(await Promise.all(o.sourceStrings.map(i=>C(i)))),T=[];for(let[i,P]of Object.entries(g))if(!H.has(i)){let _=P.tags||[];_.includes(t)&&T.push({hash:i,source:P.source||i,tags:_.filter(B=>B!==t)})}s||(k(T),h(!1))}return d().catch(t=>{console.error(t),s||h(!1)}),()=>{s=!0}},[o.docId,o.sourceStrings]);async function U(){if(e.length!==0){x(!0);try{let s=e.map(({hash:t,tags:g})=>({hash:t,tags:g}));await I(s,{mode:"replace"});let d=e.map(t=>t.hash);p({title:"Pruned translations",message:`Removed "${o.docId}" tag from ${d.length} unused translation(s).`,color:"green",autoClose:5e3}),o.onPruned?.(d),r.closeModal(f)}catch(s){console.error(s),p({title:"Error pruning translations",message:String(s),color:"red",autoClose:!1})}finally{x(!1)}}}return n("div",{className:"PruneTranslationsModal",children:[n("div",{className:"PruneTranslationsModal__description",children:n(a,{size:"body",children:["Pruning removes the ",n("strong",{children:o.docId})," tag from translation strings that are no longer referenced by this document. The translations themselves are not deleted and will remain available to other documents that still reference them."]})}),l&&n("div",{className:"PruneTranslationsModal__loading",children:[n(v,{color:"gray",size:"sm"}),n(a,{size:"body",color:"gray",children:"Scanning for unused strings\u2026"})]}),!l&&e.length===0&&n("div",{className:"PruneTranslationsModal__empty",children:n(a,{size:"body",color:"gray",children:['All translations tagged with "',o.docId,'" are still in use. Nothing to prune.']})}),!l&&e.length>0&&n(M,{children:[n(a,{size:"body",weight:"semi-bold",children:[e.length," unused string",e.length!==1?"s":""," will be untagged:"]}),n("div",{className:"PruneTranslationsModal__list",children:e.map(s=>n("div",{className:"PruneTranslationsModal__list__item",children:n(a,{size:"body-sm",children:s.source})},s.hash))})]}),n("div",{className:"PruneTranslationsModal__actions",children:[n(m,{variant:"default",size:"xs",onClick:()=>r.closeModal(f),children:"Cancel"}),n(m,{variant:"filled",size:"xs",color:"red",leftIcon:n(N,{size:14}),loading:E,disabled:l||e.length===0,onClick:U,children:["Prune ",e.length>0?e.length:""," string",e.length!==1?"s":""]})]})]})}$.id=S;export{W as a,$ as b};
@@ -1 +1 @@
1
- import{a as G}from"./chunk-2PDMFZBF.js";import{a as Y}from"./chunk-VB5VMEN7.js";import{a as J}from"./chunk-76PG55CM.js";import{f as W}from"./chunk-SLLTYDVX.js";import{b as O,d as U,e as V,j as $}from"./chunk-CSUKZZK5.js";import{a as A}from"./chunk-JDW4UORS.js";import{a as K}from"./chunk-6P75AZ3B.js";import{c as L}from"./chunk-RN4XVVWD.js";import{a as q}from"./chunk-W5DOO6ID.js";import{a as j}from"./chunk-EIMRPYCD.js";import{b as B}from"./chunk-EYVQCOAD.js";import{a as S}from"./chunk-XM35ZJBQ.js";import{d as M}from"./chunk-WS37MDM3.js";import{$ as C,Fa as N,Ga as e,Qa as H,Sc as y,W as x,a as d,c as w,da as I,e as z,j as le,na as k,pa as E,ua as T}from"./chunk-ETPZ3TXX.js";le();function F(o){let{route:c}=M(),f=z(null),[l,i]=d(!1),[v,u]=d(""),[p,_]=d(!!o.releaseId),[Q,P]=d(null),[R,b]=d([]),[g,h]=d([]),X=J(),Z=G(),{roles:ee}=j(),oe=window.firebase.user.email||"",m=q(ee,oe);async function ae(r){console.log(r),await B(async()=>{let t=await U(r);P(t),b(t?.docIds||[]),h(t?.dataSourceIds||[])}),_(!1)}w(()=>{o.releaseId&&(_(!0),ae(o.releaseId))},[o.releaseId]);async function se(){u("");let r=f.current;function t(n){let D=r.elements[n];return D?D.value.trim():""}let a=o.releaseId||t("id");if(!a){u("missing id");return}if(!A(a)){u("id is invalid (alphanumeric characters and dashes only)");return}let s={id:a,description:t("description"),docIds:R,dataSourceIds:g};try{P(s),i(!0),o.releaseId?(await V(o.releaseId,s),S({title:"Saved release",message:`Updated ${a}`,autoClose:5e3}),i(!1)):(await O(a,s),S({title:"Added release",message:`Successfully added ${a}`,autoClose:5e3}),i(!1)),c(`/cms/releases/${a}`)}catch(n){console.error(n),S({title:"Failed to save release",message:String(n),color:"red",autoClose:!1}),i(!1)}}function re(){X.open({multiSelect:!0,selectedDocIds:R,onChangeMulti:(r,t)=>{b(a=>{let s=[...a];if(t)s.push(r);else{let n=s.findIndex(D=>D===r);n>-1&&s.splice(n,1)}return console.log(s),s.sort()})}})}function te(){Z.open({selectedDataSourceIds:g,onChange:(r,t)=>{h(a=>{let s=[...a];if(t)s.push(r);else{let n=s.indexOf(r);n>-1&&s.splice(n,1)}return s.sort()})}})}function ie(r){console.log("onRemoveDoc()",r),b(t=>{let a=[...t],s=a.indexOf(r);return s!==-1&&a.splice(s,1),console.log(a),a})}function ne(r){h(t=>{let a=[...t],s=a.indexOf(r);return s!==-1&&a.splice(s,1),a})}return e("form",{className:"ReleaseForm",ref:f,onSubmit:r=>{r.preventDefault(),se()},children:[e(E,{visible:p}),e(T,{className:"ReleaseForm__input",name:"id",label:"ID",description:"Unique identifier for the release. Use alphanumeric characters and dashes only, e.g. grogus-favorite-meals",size:"xs",radius:0,defaultValue:o.releaseId||$(),disabled:!!o.releaseId}),e(k,{className:"ReleaseForm__input",name:"description",label:"Description",description:"Optional.",size:"xs",radius:0,value:Q?.description,disabled:!m}),e(C,{className:"ReleaseForm__input",label:"Docs",description:"Select one or more docs to add to the release. Note: you can add or edit this list at a later time, if needed.",size:"xs",children:[R.length>0&&e(F.DocPreviewCards,{docIds:R,onRemoveDoc:ie,canEdit:m}),e(I,{className:"ReleaseForm__docSelectButton",color:"dark",size:"xs",onClick:()=>re(),disabled:!m,children:"Select"})]}),e(C,{className:"ReleaseForm__input",label:"Data Sources",description:"Optional. Data sources to publish with the release.",size:"xs",children:[g.length>0&&e(F.DataSourceIds,{ids:g,onRemove:ne,canEdit:m}),e(I,{className:"ReleaseForm__docSelectButton",color:"dark",size:"xs",onClick:()=>te(),disabled:!m,children:"Select"})]}),e("div",{className:"ReleaseForm__submit__buttons",children:e(K,{label:"You don't have access to create or edit releases",condition:!m,children:e("span",{children:e(I,{className:"ReleaseForm__submit",color:"blue",size:"xs",type:"submit",loading:l,disabled:!m,children:o.buttonLabel||"Save"})})})}),v&&e("div",{className:"ReleaseForm__error",children:["Error: ",v]})]})}F.DocPreviewCards=o=>e("div",{className:"ReleaseForm__DocPreviewCards",children:o.docIds.map(c=>e("div",{className:"ReleaseForm__DocPreviewCards__card",children:[e(W,{className:"ReleaseForm__DocPreviewCards__card__preview",docId:c}),e("div",{className:"ReleaseForm__DocPreviewCards__card__controls",children:[o.canEdit&&e("div",{className:"ReleaseForm__DocPreviewCards__card__controls__remove",children:e(N,{label:"Remove",children:e(x,{className:"ReleaseForm__DocPreviewCards__card__controls__remove__icon",onClick:()=>o.onRemoveDoc(c),children:e(y,{size:16})})})}),e("div",{className:"ReleaseForm__DocPreviewCards__card__controls__open",children:e(N,{label:"Open",children:e(x,{component:"a",className:"ReleaseForm__DocPreviewCards__card__controls__open__icon",href:`/cms/content/${c}`,target:"_blank",children:e(H,{size:16})})})})]})]},c))});F.DataSourceIds=o=>{let[c,f]=d({});return w(()=>{let l=!1;async function i(){let v=await Promise.all(o.ids.map(async p=>{let _=await L(p);return[p,_]}));if(l)return;let u={};for(let[p,_]of v)_&&(u[p]=_);f(u)}return i(),()=>{l=!0}},[o.ids.join(",")]),e("div",{className:"ReleaseForm__DataSourceIds",children:o.ids.map(l=>{let i=c[l];return e("div",{className:"ReleaseForm__DataSourceIds__item",children:[e(Y,{className:"ReleaseForm__DataSourceIds__item__icon",type:i?.type}),e("div",{className:"ReleaseForm__DataSourceIds__item__info",children:[e("div",{className:"ReleaseForm__DataSourceIds__item__id",children:l}),i?.description&&e("div",{className:"ReleaseForm__DataSourceIds__item__description",children:i.description})]}),o.canEdit&&e(x,{className:"ReleaseForm__DataSourceIds__item__remove",onClick:()=>o.onRemove(l),children:e(y,{size:16})})]},l)})})};export{F as a};
1
+ import{a as G}from"./chunk-C5FRMXDS.js";import{a as Y}from"./chunk-F7RQT4XN.js";import{a as J}from"./chunk-U7LSFUHT.js";import{g as W}from"./chunk-G5647K25.js";import{b as O,d as U,e as V,j as $}from"./chunk-VJRMR2JM.js";import{a as A}from"./chunk-JDW4UORS.js";import{a as K}from"./chunk-UJX25CXD.js";import{c as L}from"./chunk-Z2CRNO3I.js";import{a as q}from"./chunk-W5DOO6ID.js";import{a as j}from"./chunk-YBHFGQ3Z.js";import{b as B}from"./chunk-2PTLQRTU.js";import{a as S}from"./chunk-PIJ3E47R.js";import{d as M}from"./chunk-WASID5UU.js";import{$ as C,Fa as N,Ga as e,Qa as H,Vc as y,W as x,a as d,c as w,da as I,e as z,j as le,na as k,pa as E,ua as T}from"./chunk-WRA24P66.js";le();function F(o){let{route:c}=M(),f=z(null),[l,i]=d(!1),[v,u]=d(""),[p,_]=d(!!o.releaseId),[Q,P]=d(null),[R,b]=d([]),[g,h]=d([]),X=J(),Z=G(),{roles:ee}=j(),oe=window.firebase.user.email||"",m=q(ee,oe);async function ae(r){console.log(r),await B(async()=>{let t=await U(r);P(t),b(t?.docIds||[]),h(t?.dataSourceIds||[])}),_(!1)}w(()=>{o.releaseId&&(_(!0),ae(o.releaseId))},[o.releaseId]);async function se(){u("");let r=f.current;function t(n){let D=r.elements[n];return D?D.value.trim():""}let a=o.releaseId||t("id");if(!a){u("missing id");return}if(!A(a)){u("id is invalid (alphanumeric characters and dashes only)");return}let s={id:a,description:t("description"),docIds:R,dataSourceIds:g};try{P(s),i(!0),o.releaseId?(await V(o.releaseId,s),S({title:"Saved release",message:`Updated ${a}`,autoClose:5e3}),i(!1)):(await O(a,s),S({title:"Added release",message:`Successfully added ${a}`,autoClose:5e3}),i(!1)),c(`/cms/releases/${a}`)}catch(n){console.error(n),S({title:"Failed to save release",message:String(n),color:"red",autoClose:!1}),i(!1)}}function re(){X.open({multiSelect:!0,selectedDocIds:R,onChangeMulti:(r,t)=>{b(a=>{let s=[...a];if(t)s.push(r);else{let n=s.findIndex(D=>D===r);n>-1&&s.splice(n,1)}return console.log(s),s.sort()})}})}function te(){Z.open({selectedDataSourceIds:g,onChange:(r,t)=>{h(a=>{let s=[...a];if(t)s.push(r);else{let n=s.indexOf(r);n>-1&&s.splice(n,1)}return s.sort()})}})}function ie(r){console.log("onRemoveDoc()",r),b(t=>{let a=[...t],s=a.indexOf(r);return s!==-1&&a.splice(s,1),console.log(a),a})}function ne(r){h(t=>{let a=[...t],s=a.indexOf(r);return s!==-1&&a.splice(s,1),a})}return e("form",{className:"ReleaseForm",ref:f,onSubmit:r=>{r.preventDefault(),se()},children:[e(E,{visible:p}),e(T,{className:"ReleaseForm__input",name:"id",label:"ID",description:"Unique identifier for the release. Use alphanumeric characters and dashes only, e.g. grogus-favorite-meals",size:"xs",radius:0,defaultValue:o.releaseId||$(),disabled:!!o.releaseId}),e(k,{className:"ReleaseForm__input",name:"description",label:"Description",description:"Optional.",size:"xs",radius:0,value:Q?.description,disabled:!m}),e(C,{className:"ReleaseForm__input",label:"Docs",description:"Select one or more docs to add to the release. Note: you can add or edit this list at a later time, if needed.",size:"xs",children:[R.length>0&&e(F.DocPreviewCards,{docIds:R,onRemoveDoc:ie,canEdit:m}),e(I,{className:"ReleaseForm__docSelectButton",color:"dark",size:"xs",onClick:()=>re(),disabled:!m,children:"Select"})]}),e(C,{className:"ReleaseForm__input",label:"Data Sources",description:"Optional. Data sources to publish with the release.",size:"xs",children:[g.length>0&&e(F.DataSourceIds,{ids:g,onRemove:ne,canEdit:m}),e(I,{className:"ReleaseForm__docSelectButton",color:"dark",size:"xs",onClick:()=>te(),disabled:!m,children:"Select"})]}),e("div",{className:"ReleaseForm__submit__buttons",children:e(K,{label:"You don't have access to create or edit releases",condition:!m,children:e("span",{children:e(I,{className:"ReleaseForm__submit",color:"blue",size:"xs",type:"submit",loading:l,disabled:!m,children:o.buttonLabel||"Save"})})})}),v&&e("div",{className:"ReleaseForm__error",children:["Error: ",v]})]})}F.DocPreviewCards=o=>e("div",{className:"ReleaseForm__DocPreviewCards",children:o.docIds.map(c=>e("div",{className:"ReleaseForm__DocPreviewCards__card",children:[e(W,{className:"ReleaseForm__DocPreviewCards__card__preview",docId:c}),e("div",{className:"ReleaseForm__DocPreviewCards__card__controls",children:[o.canEdit&&e("div",{className:"ReleaseForm__DocPreviewCards__card__controls__remove",children:e(N,{label:"Remove",children:e(x,{className:"ReleaseForm__DocPreviewCards__card__controls__remove__icon",onClick:()=>o.onRemoveDoc(c),children:e(y,{size:16})})})}),e("div",{className:"ReleaseForm__DocPreviewCards__card__controls__open",children:e(N,{label:"Open",children:e(x,{component:"a",className:"ReleaseForm__DocPreviewCards__card__controls__open__icon",href:`/cms/content/${c}`,target:"_blank",children:e(H,{size:16})})})})]})]},c))});F.DataSourceIds=o=>{let[c,f]=d({});return w(()=>{let l=!1;async function i(){let v=await Promise.all(o.ids.map(async p=>{let _=await L(p);return[p,_]}));if(l)return;let u={};for(let[p,_]of v)_&&(u[p]=_);f(u)}return i(),()=>{l=!0}},[o.ids.join(",")]),e("div",{className:"ReleaseForm__DataSourceIds",children:o.ids.map(l=>{let i=c[l];return e("div",{className:"ReleaseForm__DataSourceIds__item",children:[e(Y,{className:"ReleaseForm__DataSourceIds__item__icon",type:i?.type}),e("div",{className:"ReleaseForm__DataSourceIds__item__info",children:[e("div",{className:"ReleaseForm__DataSourceIds__item__id",children:l}),i?.description&&e("div",{className:"ReleaseForm__DataSourceIds__item__description",children:i.description})]}),o.canEdit&&e(x,{className:"ReleaseForm__DataSourceIds__item__remove",onClick:()=>o.onRemove(l),children:e(y,{size:16})})]},l)})})};export{F as a};
@@ -1 +1 @@
1
- import{a as C}from"./chunk-H3PYPGNR.js";import{e as p}from"./chunk-WS37MDM3.js";import{Ga as o,Gb as u,U as _,g,j as b}from"./chunk-ETPZ3TXX.js";b();function m(s){let e={},t=[],r={};if(Object.entries(s).forEach(([n,i])=>{e[n]={id:n,name:i.name||n,description:i.description,isGroup:!1,collection:i,children:[]}}),Object.entries(s).forEach(([n,i])=>{let c=e[n],d=i.group||"Content";d?(r[d]||(r[d]={id:`group:${d}`,name:d,isGroup:!0,children:[]}),r[d].children.push(c)):t.push(c)}),Object.keys(r).length>0&&t.length>0){let n={id:"group:Content",name:"Content",isGroup:!0,children:t},i=Object.values(r).sort((c,d)=>c.name.localeCompare(d.name));return[n,...i]}Object.values(r).forEach(n=>{t.push(n)});let l=n=>{n.sort((i,c)=>i.name.localeCompare(c.name)),n.forEach(i=>{i.children.length>0&&l(i.children)})};return l(t),t}function O(s){let{collections:e,activeCollectionId:t,projectId:r}=s,[a,l]=C(`root-cms::${r}::closed_groups`,[]),n=g(()=>m(e),[]),i=(c,d)=>{d?l(a.filter(v=>v!==c)):a.includes(c)||l([...a,c])};return o("div",{className:p(s.className,"CollectionTree"),children:[n.map(c=>o(h,{node:c,depth:0,activeCollectionId:t,closedGroups:a,onAccordionChange:i},c.id)),n.length===0&&o("div",{className:"CollectionTree__collections__empty",children:"No collections match your query."})]})}function h(s){let{node:e,depth:t,activeCollectionId:r,closedGroups:a,onAccordionChange:l}=s,n=e.children.length>0;return e.isGroup?n?o(f,{node:e,depth:t,activeCollectionId:r,closedGroups:a,onAccordionChange:l,label:o("div",{className:"CollectionTree__group__label",children:o("span",{children:e.name})})}):o("div",{className:"CollectionTree__group-empty",style:{paddingLeft:`${t*16}px`},children:[o(u,{size:20,strokeWidth:"1.75"}),o("span",{children:e.name})]}):n?o(f,{node:e,depth:t,activeCollectionId:r,closedGroups:a,onAccordionChange:l,label:o("div",{className:"CollectionTree__collection__label",children:o("a",{className:p("CollectionTree__collection-link",e.id===r&&"active"),href:`/cms/content/${e.id}`,onClick:i=>i.stopPropagation(),children:e.name})})}):o("a",{className:p("CollectionTree__collection",e.id===r&&"active"),href:`/cms/content/${e.id}`,children:[o("div",{className:"CollectionTree__collection__icon",children:o(u,{size:20,strokeWidth:"1.75"})}),o("div",{className:"CollectionTree__collection__content",children:[o("div",{className:"CollectionTree__collection__name",children:e.name}),e.description&&o("div",{className:"CollectionTree__collection__desc",children:e.description})]})]})}function f(s){let{node:e,depth:t,label:r,activeCollectionId:a,closedGroups:l,onAccordionChange:n}=s,i=!l.includes(e.id);return o("div",{className:"CollectionTree__accordion",children:o(_,{iconPosition:"left",initialItem:i?0:-1,offsetIcon:!1,onChange:()=>n(e.id,!i),children:o(_.Item,{label:r,children:o("div",{className:"CollectionTree__accordion__children",children:e.children.map(c=>o(h,{node:c,depth:t+1,activeCollectionId:a,closedGroups:l,onAccordionChange:n},c.id))})})})})}export{O as a};
1
+ import{a as C}from"./chunk-QFDU6FXP.js";import{e as p}from"./chunk-WASID5UU.js";import{Ga as o,Jb as u,U as _,g,j as b}from"./chunk-WRA24P66.js";b();function m(s){let e={},t=[],r={};if(Object.entries(s).forEach(([n,i])=>{e[n]={id:n,name:i.name||n,description:i.description,isGroup:!1,collection:i,children:[]}}),Object.entries(s).forEach(([n,i])=>{let c=e[n],d=i.group||"Content";d?(r[d]||(r[d]={id:`group:${d}`,name:d,isGroup:!0,children:[]}),r[d].children.push(c)):t.push(c)}),Object.keys(r).length>0&&t.length>0){let n={id:"group:Content",name:"Content",isGroup:!0,children:t},i=Object.values(r).sort((c,d)=>c.name.localeCompare(d.name));return[n,...i]}Object.values(r).forEach(n=>{t.push(n)});let l=n=>{n.sort((i,c)=>i.name.localeCompare(c.name)),n.forEach(i=>{i.children.length>0&&l(i.children)})};return l(t),t}function O(s){let{collections:e,activeCollectionId:t,projectId:r}=s,[a,l]=C(`root-cms::${r}::closed_groups`,[]),n=g(()=>m(e),[]),i=(c,d)=>{d?l(a.filter(v=>v!==c)):a.includes(c)||l([...a,c])};return o("div",{className:p(s.className,"CollectionTree"),children:[n.map(c=>o(h,{node:c,depth:0,activeCollectionId:t,closedGroups:a,onAccordionChange:i},c.id)),n.length===0&&o("div",{className:"CollectionTree__collections__empty",children:"No collections match your query."})]})}function h(s){let{node:e,depth:t,activeCollectionId:r,closedGroups:a,onAccordionChange:l}=s,n=e.children.length>0;return e.isGroup?n?o(f,{node:e,depth:t,activeCollectionId:r,closedGroups:a,onAccordionChange:l,label:o("div",{className:"CollectionTree__group__label",children:o("span",{children:e.name})})}):o("div",{className:"CollectionTree__group-empty",style:{paddingLeft:`${t*16}px`},children:[o(u,{size:20,strokeWidth:"1.75"}),o("span",{children:e.name})]}):n?o(f,{node:e,depth:t,activeCollectionId:r,closedGroups:a,onAccordionChange:l,label:o("div",{className:"CollectionTree__collection__label",children:o("a",{className:p("CollectionTree__collection-link",e.id===r&&"active"),href:`/cms/content/${e.id}`,onClick:i=>i.stopPropagation(),children:e.name})})}):o("a",{className:p("CollectionTree__collection",e.id===r&&"active"),href:`/cms/content/${e.id}`,children:[o("div",{className:"CollectionTree__collection__icon",children:o(u,{size:20,strokeWidth:"1.75"})}),o("div",{className:"CollectionTree__collection__content",children:[o("div",{className:"CollectionTree__collection__name",children:e.name}),e.description&&o("div",{className:"CollectionTree__collection__desc",children:e.description})]})]})}function f(s){let{node:e,depth:t,label:r,activeCollectionId:a,closedGroups:l,onAccordionChange:n}=s,i=!l.includes(e.id);return o("div",{className:"CollectionTree__accordion",children:o(_,{iconPosition:"left",initialItem:i?0:-1,offsetIcon:!1,onChange:()=>n(e.id,!i),children:o(_.Item,{label:r,children:o("div",{className:"CollectionTree__accordion__children",children:e.children.map(c=>o(h,{node:c,depth:t+1,activeCollectionId:a,closedGroups:l,onAccordionChange:n},c.id))})})})})}export{O as a};
@@ -1 +1 @@
1
- import{L as m,a,c as f,j as O}from"./chunk-ETPZ3TXX.js";O();var G=["https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/spreadsheets"],P=["https://www.googleapis.com/discovery/v1/apis/drive/v3/rest","https://sheets.googleapis.com/$discovery/rest?version=v4"];function R(){let o=window.__ROOT_CTX.rootConfig.projectId,t=!!(window.__ROOT_CTX.gapi?.apiKey&&window.__ROOT_CTX.gapi?.clientId),[e,n]=a(t),[i,w]=a(0),[s,h]=m({key:`root-cms::${o}::gapi-user-consent`,defaultValue:{}});async function C(){await Promise.all([E(),b()]),n(!1)}f(()=>{t&&C()},[]);function _(r){return new Promise(v=>{let g=window.__ROOT_CTX.gapi.clientId,c=Array.from(new Set([...G,...r?.scopes||[]])),u=google.accounts.oauth2.initTokenClient({client_id:g,scope:c.join(" "),callback:async I=>{let y=l()+parseInt(I.expires_in);w(y),h({at:l(),clientId:g,scopes:c}),v()}});s&&k(s,c)?(console.log("requesting token without prompt"),u.requestAccessToken({prompt:""})):(console.log("requesting token with prompt"),u.requestAccessToken({prompt:"consent"}))})}function S(){return l()<i}function T(r){return s?.scopes?.includes(r)||!1}return{enabled:t,loading:e,isLoggedIn:S,login:_,hasScope:T}}function k(o,t){if(!o||!o.at)return!1;let e=window.__ROOT_CTX.gapi?.clientId;if(o.clientId!==e)return!1;let n=o.scopes||[];return t.every(i=>n.includes(i))}function l(){return Math.floor(new Date().getTime()/1e3)}var p=null;async function E(){return p||(p=new Promise((o,t)=>{let e=document.createElement("script");e.src="https://apis.google.com/js/api.js",e.onload=()=>{gapi.load("client",async()=>{try{await gapi.client.init({}),await Promise.all(P.map(n=>gapi.client.load(n))),console.log("gapi loaded"),o()}catch(n){console.error("Error initializing gapi:",n),t(n)}})},e.onerror=()=>{console.error("gapi script failed to load"),t(new Error("gapi script failed to load"))},document.head.appendChild(e)})),p}var d=null;async function b(){return d||(d=new Promise((o,t)=>{let e=document.createElement("script");e.src="https://accounts.google.com/gsi/client",e.onload=()=>{o()},e.onerror=()=>{console.error("gis script failed to load"),t(new Error("gis script failed to load"))},document.head.appendChild(e)})),d}export{R as a};
1
+ import{L as m,a,c as f,j as O}from"./chunk-WRA24P66.js";O();var G=["https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/spreadsheets"],P=["https://www.googleapis.com/discovery/v1/apis/drive/v3/rest","https://sheets.googleapis.com/$discovery/rest?version=v4"];function R(){let o=window.__ROOT_CTX.rootConfig.projectId,t=!!(window.__ROOT_CTX.gapi?.apiKey&&window.__ROOT_CTX.gapi?.clientId),[e,n]=a(t),[i,w]=a(0),[s,h]=m({key:`root-cms::${o}::gapi-user-consent`,defaultValue:{}});async function C(){await Promise.all([E(),b()]),n(!1)}f(()=>{t&&C()},[]);function _(r){return new Promise(v=>{let g=window.__ROOT_CTX.gapi.clientId,c=Array.from(new Set([...G,...r?.scopes||[]])),u=google.accounts.oauth2.initTokenClient({client_id:g,scope:c.join(" "),callback:async I=>{let y=l()+parseInt(I.expires_in);w(y),h({at:l(),clientId:g,scopes:c}),v()}});s&&k(s,c)?(console.log("requesting token without prompt"),u.requestAccessToken({prompt:""})):(console.log("requesting token with prompt"),u.requestAccessToken({prompt:"consent"}))})}function S(){return l()<i}function T(r){return s?.scopes?.includes(r)||!1}return{enabled:t,loading:e,isLoggedIn:S,login:_,hasScope:T}}function k(o,t){if(!o||!o.at)return!1;let e=window.__ROOT_CTX.gapi?.clientId;if(o.clientId!==e)return!1;let n=o.scopes||[];return t.every(i=>n.includes(i))}function l(){return Math.floor(new Date().getTime()/1e3)}var p=null;async function E(){return p||(p=new Promise((o,t)=>{let e=document.createElement("script");e.src="https://apis.google.com/js/api.js",e.onload=()=>{gapi.load("client",async()=>{try{await gapi.client.init({}),await Promise.all(P.map(n=>gapi.client.load(n))),console.log("gapi loaded"),o()}catch(n){console.error("Error initializing gapi:",n),t(n)}})},e.onerror=()=>{console.error("gapi script failed to load"),t(new Error("gapi script failed to load"))},document.head.appendChild(e)})),p}var d=null;async function b(){return d||(d=new Promise((o,t)=>{let e=document.createElement("script");e.src="https://accounts.google.com/gsi/client",e.onload=()=>{o()},e.onerror=()=>{console.error("gis script failed to load"),t(new Error("gis script failed to load"))},document.head.appendChild(e)})),d}export{R as a};
@@ -0,0 +1,19 @@
1
+ import{a as Te,b as Se,c as Pe,d as ke,e as je,f as ze,g as De,h as Ue,i as Oe,j as We,k as Be,l as Le,m as $e,n as He,o as Fe,p as ae,q as Ke,r as Ve}from"./chunk-LAXQZPE3.js";import{a as we}from"./chunk-QWB6MAPJ.js";import{a as Ee,c as ne}from"./chunk-235TRWJF.js";import{P as Me,T as Ne}from"./chunk-AAR7DBEN.js";import{f as q}from"./chunk-5MV6XVGA.js";import{b as me,c as pe,g as fe,h as _e,j as he,n as X,o as ge,p as Ce,r as ve,v as Y}from"./chunk-XOWWPE7X.js";import{d as Ae,e as T}from"./chunk-WASID5UU.js";import{$a as Q,Bc as z,Fa as H,Ga as e,Hc as xe,V as J,Vc as be,W as E,a as _,ab as Z,ad as B,ba as G,bb as ee,c as M,da as j,e as y,g as ue,h as N,j as at,kc as te,pb as ye,pc as oe,qa as W,qc as Re}from"./chunk-WRA24P66.js";import{d as de}from"./chunk-KUCVLANF.js";import{h as Ie}from"./chunk-7SK47HHZ.js";at();var it=500;function Je(){return window.firebase.db}function Ge(){return window.__ROOT_CTX.rootConfig.projectId}function ie(){return window.firebase.user?.email||""}function st(){return me(Je(),"Projects",Ge(),"AiChats")}function se(t){return pe(Je(),"Projects",Ge(),"AiChats",t)}function D(t){return t&&typeof t.toMillis=="function"?t.toMillis():typeof t=="number"?t:0}async function Xe(t){let o=ie();if(!o)return[];let n=t?.limit,a=typeof n=="number"&&Number.isFinite(n)&&n>0?Math.min(Math.floor(n),100):50,u=fe(st(),_e("createdBy","==",o),he(it)),r=(await ge(u)).docs.map(l=>l.data());return r.sort((l,g)=>D(g.modifiedAt)-D(l.modifiedAt)),r.slice(0,a).map(l=>({id:l.id,title:l.title,modelId:l.modelId,createdAt:D(l.createdAt),modifiedAt:D(l.modifiedAt)}))}async function re(t){let o=await X(se(t));if(!o.exists())return null;let n=o.data();return n.createdBy!==ie()?null:{id:n.id||t,title:n.title,modelId:n.modelId,createdAt:D(n.createdAt),modifiedAt:D(n.modifiedAt),messages:n.messages||[]}}async function Ye(t,o){let n=ie(),a=se(t),u=await X(a);if(u.exists()&&u.data().createdBy!==n)throw new Error("chat is owned by another user");let m={id:t,createdBy:n,modifiedAt:Y(),messages:We(o.messages)};u.exists()||(m.createdAt=Y()),o.modelId&&(m.modelId=o.modelId),o.title&&(m.title=o.title),await Ce(a,m,{merge:!0})}async function qe(t){await re(t)&&await ve(se(t))}async function Qe(t,o){let n=je(o);if(n==="New chat")return n;let a=ze(o);if(!a)return n;try{let u=ke(Pe(t)),m=await Me({model:u,system:Ue,prompt:Oe(a),maxOutputTokens:64,temperature:.3}),r=De(m.text);if(r)return r}catch(u){console.error("failed to generate chat title:",u)}return n}var le=[{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."}],ot="root-cms.ai.executionMode",nt="root-cms.ai.selectedModel";function rt(t){return le.some(o=>o.id===t)}function lt(){if(typeof window>"u")return"approve";try{let t=window.localStorage.getItem(ot);if(rt(t))return t}catch(t){console.error("failed to read AI execution mode preference",t)}return"approve"}function ct(t){if(typeof window>"u")return null;try{let o=window.localStorage.getItem(nt);if(o&&t.some(n=>n.id===o))return o}catch(o){console.error("failed to read AI model preference",o)}return null}function dt(t){if(!(typeof window>"u"))try{window.localStorage.setItem(nt,t)}catch(o){console.error("failed to save AI model preference",o)}}function ut(t){if(!(typeof window>"u"))try{window.localStorage.setItem(ot,t)}catch(o){console.error("failed to save AI execution mode preference",o)}}var F="";function so(t){let[o,n]=_(null),[a,u]=_("");M(()=>{let r=!0;return fetch("/cms/api/ai.config",{credentials:"include"}).then(async l=>{let g=await l.json();r&&n(g)}).catch(l=>{r&&u(String(l))}),()=>{r=!1}},[]);let m=!!o?.enabled&&(o.models?.length||0)>0;return e("div",{className:T("RootAIChat",`RootAIChat--${t.variant}`),children:!o&&!a?e("div",{className:"RootAIChat__loading",children:e(J,{size:"md",color:"gray"})}):m?e(pt,{variant:t.variant,config:o,initialChatId:t.variant==="panel"?void 0:t.initialChatId,docContext:t.docContext,onClose:t.onClose}):e(mt,{error:a,onClose:t.onClose})})}function mt(t){return e("div",{className:"RootAIChat__notEnabled",children:[t.onClose&&e(E,{className:"RootAIChat__notEnabled__close",onClick:t.onClose,title:"Close",children:e(B,{size:16})}),e("div",{className:"RootAIChat__notEnabled__icon",children:e(z,{size:36})}),e("div",{className:"RootAIChat__notEnabled__title",children:"Root AI is not configured for this project."}),e("div",{className:"RootAIChat__notEnabled__body",children:["Add an ",e("code",{children:"ai.models"})," entry to ",e("code",{children:"cmsPlugin()"})," in"," ",e("code",{children:"root.config.ts"}),"."]}),t.error&&e("pre",{className:"RootAIChat__notEnabled__error",children:t.error})]})}function pt(t){let o=t.variant==="panel",{route:n}=Ae(),a=t.config.models||[],u=()=>ct(a)||t.config.defaultModel||a[0]?.id||"",[m,r]=_(u),[l,g]=_(lt),[h,R]=_(t.initialChatId||F),[x,v]=_(t.initialChatId||F),[P,c]=_([]),[C,A]=_(""),[I,S]=_([]),[K,L]=_(0),k=async()=>{if(!o)try{let i=await Xe();S(i)}catch(i){console.error("failed to load chat list",i)}};M(()=>{k(),!o&&t.initialChatId&&V(t.initialChatId)},[]),M(()=>{ut(l)},[l]);let U=async i=>{try{let f=await re(i);return f?(R(i),v(i),c(f.messages||[]),A(f.title||""),f.modelId&&a.find(b=>b.id===f.modelId)&&r(f.modelId),L(w=>w+1),!0):!1}catch(f){return console.error("failed to load chat",f),!1}},V=i=>U(i),O=()=>{r(u()),R(F),v(F),c([]),A(""),L(i=>i+1),o||n("/cms/ai")},$=async i=>{if(i===x)return;await U(i)&&!o&&n(`/cms/ai/chat/${i}`)},s=async i=>{try{await qe(i),x===i&&O(),k()}catch(f){console.error("failed to delete chat",f)}},p=a.find(i=>i.id===m)||a[0],d=i=>{r(i),dt(i)};return e("div",{className:"RootAIChat__layout",children:[!o&&e(_t,{chats:I,activeChatId:x,onSelect:$,onNew:O,onDelete:s}),e("div",{className:"RootAIChat__main",children:[o&&e(ft,{onNewChat:O,onClose:t.onClose}),e(gt,{initialChatId:h,initialTitle:C,model:p,initialMessages:P,executionMode:l,canAutoApply:t.config.canAutoApply??!1,models:a,selectedModel:p,docContext:t.docContext,onSelectModel:d,onSelectExecutionMode:g,onChatPersisted:i=>{v(i),k(),o||window.history.replaceState(null,"",`/cms/ai/chat/${i}`)}},K)]})]})}function ft(t){return e("div",{className:"RootAIChat__panelHeader",children:[e("div",{className:"RootAIChat__panelHeader__title",children:[e(z,{size:14}),e("span",{children:"Root AI"})]}),e("div",{className:"RootAIChat__panelHeader__actions",children:[e(H,{label:"New chat",children:e(E,{size:"xs",onClick:t.onNewChat,children:e(te,{size:14})})}),t.onClose&&e(H,{label:"Close (\u2318 + i)",children:e(E,{size:"xs",onClick:t.onClose,children:e(B,{size:14})})})]})]})}function _t(t){return e("aside",{className:"RootAIChat__sidebar",children:[e("button",{type:"button",className:"RootAIChat__sidebar__newButton",onClick:t.onNew,children:[e(te,{size:18}),e("span",{children:"New chat"})]}),e("div",{className:"RootAIChat__sidebar__list",children:[t.chats.length===0&&e("div",{className:"RootAIChat__sidebar__empty",children:"No chats yet."}),t.chats.map(o=>e("div",{className:T("RootAIChat__sidebar__item",o.id===t.activeChatId&&"RootAIChat__sidebar__item--active"),onClick:()=>t.onSelect(o.id),children:[e("div",{className:"RootAIChat__sidebar__item__title",title:o.title||"Untitled chat",children:o.title||"Untitled chat"}),e("button",{type:"button",className:"RootAIChat__sidebar__item__delete",title:"Delete chat",onClick:n=>{n.stopPropagation(),window.confirm("Delete this chat?")&&t.onDelete(o.id)},children:e(be,{size:14})})]},o.id))]})]})}function ht(t){let o=t.canAutoApply?le:le.filter(a=>a.id!=="auto"),n=o.find(a=>a.id===t.executionMode)||o[0];return e("div",{className:"RootAIChat__options",children:[e(W,{control:e(j,{type:"button",className:"RootAIChat__modePicker",variant:"subtle",color:"dark",size:"xs",compact:!0,leftIcon:e(Re,{size:16}),children:n.label}),children:o.map(a=>e(W.Item,{onClick:()=>t.onSelectExecutionMode(a.id),children:e("div",{className:"RootAIChat__modePicker__option",children:[e("div",{className:"RootAIChat__modePicker__option__label",children:a.label}),e("div",{className:"RootAIChat__modePicker__option__description",children:a.description})]})},a.id))}),e(W,{control:e(j,{type:"button",className:"RootAIChat__modelPicker",variant:"subtle",color:"dark",size:"xs",compact:!0,leftIcon:e(z,{size:16}),children:t.selectedModel?.label||"Select model"}),children:t.models.map(a=>e(W.Item,{onClick:()=>t.onSelectModel(a.id),children:e("div",{className:"RootAIChat__modelPicker__option",children:[e("div",{className:"RootAIChat__modelPicker__option__label",children:a.label}),a.description&&e("div",{className:"RootAIChat__modelPicker__option__description",children:a.description})]})},a.id))})]})}function gt(t){let[o]=_(()=>t.initialChatId||kt()),n=y(t.model?.id);n.current=t.model?.id;let a=y(t.executionMode);a.current=t.executionMode;let u=y(t.docContext);u.current=t.docContext;let m=y(t.onChatPersisted);m.current=t.onChatPersisted;let r=y(null),l=y(t.executionMode),g=y(t.initialTitle),h=y(null),[R,x]=_({}),v=y({});M(()=>()=>{for(let s of Object.values(v.current))s("reject");v.current={}},[]);let P=N((s,p,d,i)=>new Promise(f=>{v.current[s]=f,x(w=>({...w,[s]:{toolCallId:s,toolName:p,input:d,preview:i,status:"pending"}}))}),[]),c=N(s=>{x(p=>{let d=p[s];return d?{...p,[s]:{...d,status:"executing"}}:p}),v.current[s]?.("approve"),delete v.current[s]},[]),C=N(s=>{x(p=>{let d={...p};return delete d[s],d}),v.current[s]?.("reject"),delete v.current[s]},[]),A=N(async s=>{if(!He(s.toolName))return await ae(s.toolName,s.input);let p=l.current;if(p==="read")return{success:!1,error:"WRITE_BLOCKED_BY_MODE",message:"The current execution mode is read only. Do not call write tools."};let d;try{d=await Fe(s.toolName,s.input)}catch(i){return{success:!1,error:"PREVIEW_FAILED",message:i?.message||String(i)}}if(d.error)return{success:!1,error:d.error,message:d.summary,errors:d.errors,hint:d.hint};if(p==="approve"&&await P(s.toolCallId,s.toolName,s.input,d)==="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 ae(s.toolName,s.input)}finally{x(i=>{if(!i[s.toolCallId])return i;let f={...i};return delete f[s.toolCallId],f})}},[P]),I=N(async s=>{let p=r.current;try{let d=g.current;if(!d&&p){let i=await Qe(p,s);i&&i!=="New chat"&&(d=i,g.current=i)}await Ye(o,{messages:s,modelId:p?.id||n.current,title:d||void 0})}catch(d){console.error("failed to persist chat history",d)}m.current(o)},[o]),S=ue(()=>Be({loadTurnConfig:async()=>{let s=n.current,p=a.current,d=u.current?.docId,i=`${s}|${p}|${d||""}`,f=h.current;if(f&&f.key===i)return f.config;let w=await fetch("/cms/api/ai.chat.prepare",{method:"POST",credentials:"include",headers:{"content-type":"application/json"},body:JSON.stringify({modelId:s,executionMode:p,docId:d})}),b=await w.json();if(!w.ok||!b.success)throw new Error(b.error||`ai.chat.prepare failed: ${w.status}`);let ce={model:b.model,system:b.system,maxSteps:b.maxSteps};return r.current=b.model,l.current=b.executionMode||p,h.current={key:i,config:ce},ce},buildTools:s=>s.capabilities.tools?l.current==="read"?$e():Le():{},onFinish:I}),[I]),{messages:K,sendMessage:L,status:k,error:U,stop:V,addToolOutput:O}=Te({id:o,messages:t.initialMessages,transport:S,sendAutomaticallyWhen:Ne,onToolCall:async({toolCall:s})=>{let p=await A(s);O({tool:s.toolName,toolCallId:s.toolCallId,output:p})}}),$=k==="streaming"||k==="submitted";return e(de,{children:[e(Ct,{messages:K,isStreaming:$,emptyMessage:t.model?void 0:"Select a model to start.",toolApprovals:{approvals:R,onApprove:c,onReject:C}}),U&&e("div",{className:"RootAIChat__error",children:[e("strong",{children:"Error:"})," ",U.message]}),e(Mt,{disabled:!t.model,canAttach:t.model?.capabilities.attachments??!1,isStreaming:$,onStop:V,controls:e(ht,{models:t.models,selectedModel:t.selectedModel,onSelectModel:t.onSelectModel,executionMode:t.executionMode,canAutoApply:t.canAutoApply,onSelectExecutionMode:t.onSelectExecutionMode}),onSend:(s,p)=>{if(!s&&p.length===0)return;let d=Nt(p),i=[s,d.text].filter(Boolean).join(`
2
+
3
+ `);L({text:i,files:d.files.map(f=>({type:"file",mediaType:f.mediaType,url:f.url,filename:f.filename}))})}})]})}function Ct(t){let o=y(null);return M(()=>{let n=o.current;n&&(n.scrollTop=n.scrollHeight)},[t.messages]),t.messages.length===0?e("div",{className:"RootAIChat__transcript RootAIChat__transcript--empty",ref:o,children:e("div",{className:"RootAIChat__welcome",children:[e("div",{className:"RootAIChat__welcome__icon",children:e(z,{size:36})}),e("div",{className:"RootAIChat__welcome__title",children:"Root AI"}),e("div",{className:"RootAIChat__welcome__body",children:t.emptyMessage||"What are we going to get done today?"})]})}):e("div",{className:"RootAIChat__transcript",ref:o,children:e("div",{className:"RootAIChat__transcript__inner",children:[t.messages.map(n=>e(vt,{message:n,toolApprovals:t.toolApprovals},n.id)),t.isStreaming&&e("div",{className:"RootAIChat__streamingIndicator",children:e(Se,{size:6})})]})})}function vt(t){let o=t.message,n=o.role==="user",a=n?"You":"Root AI",u=n?window.firebase.user?.photoURL:null,[m,r]=_(!1),l=N(()=>(o.parts||[]).filter(h=>h.type==="text"&&h.text).map(h=>h.text).join(`
4
+
5
+ `),[o.parts]),g=N(async()=>{let h=l();if(!h)return;let R=Ee.parse(h);try{await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([R],{type:"text/html"}),"text/plain":new Blob([h],{type:"text/plain"})})]),r(!0),setTimeout(()=>r(!1),2e3)}catch{await navigator.clipboard.writeText(h),r(!0),setTimeout(()=>r(!1),2e3)}},[l]);return e("div",{className:T("RootAIChat__message",`RootAIChat__message--${o.role}`),children:[e("div",{className:"RootAIChat__message__avatar",children:u?e("img",{src:u,alt:a}):e(z,{size:20})}),e("div",{className:"RootAIChat__message__body",children:[e("div",{className:"RootAIChat__message__username",children:a}),e("div",{className:"RootAIChat__message__parts",children:(o.parts||[]).map((h,R)=>e(At,{part:h,toolApprovals:t.toolApprovals},R))}),e("button",{type:"button",className:T("RootAIChat__message__copy",m&&"RootAIChat__message__copy--copied"),title:m?"Copied!":"Copy message",onClick:g,children:m?e(Q,{size:14}):e(ye,{size:14})})]})]})}function At(t){let o=t.part;return o.type==="text"?o.text?e("div",{className:"RootAIChat__textPart",children:e(ne,{code:o.text})}):null:o.type==="reasoning"?e(It,{text:o.text}):o.type==="file"?e(yt,{part:o}):o.type==="source-url"?e("a",{className:"RootAIChat__sourcePart",href:o.url,target:"_blank",rel:"noopener noreferrer",children:o.title||o.url}):typeof o.type=="string"&&o.type.startsWith("tool-")?e(Ze,{part:o,toolApprovals:t.toolApprovals}):o.type==="dynamic-tool"?e(Ze,{part:o,toolApprovals:t.toolApprovals}):o.type==="step-start"?null:e("div",{className:"RootAIChat__unknownPart",children:e("pre",{children:JSON.stringify(o,null,2)})})}function It(t){let[o,n]=_(!1);return t.text?e("div",{className:T("RootAIChat__reasoning",o&&"RootAIChat__reasoning--open"),children:[e("button",{type:"button",className:"RootAIChat__reasoning__toggle",onClick:()=>n(!o),children:[e(Z,{size:14,style:{transform:o?"rotate(0deg)":"rotate(-90deg)"}}),e("span",{children:"Thinking"})]}),o&&e("div",{className:"RootAIChat__reasoning__body",children:e(ne,{code:t.text})})]}):null}function yt(t){let o=t.part;return o.mediaType?.startsWith("image/")?e("div",{className:"RootAIChat__filePart",children:e("img",{src:o.url,alt:o.filename||"attachment"})}):e("a",{className:"RootAIChat__filePart RootAIChat__filePart--link",href:o.url,target:"_blank",rel:"noopener noreferrer",children:[e(oe,{size:14}),e("span",{children:o.filename||o.url})]})}function Ze(t){let o=t.part,n=typeof o.type=="string"&&o.type.startsWith("tool-")?o.type.slice(5):o.toolName||"tool",a=o.state||"",u=Rt(o),m=t.toolApprovals,r=u?m?.approvals[u]:void 0,[l,g]=_(!!r);return M(()=>{r&&g(!0)},[r]),e("div",{className:"RootAIChat__tool",children:[e("button",{type:"button",className:"RootAIChat__tool__header",onClick:()=>g(!l),children:[e(Z,{className:T("RootAIChat__tool__header__icon",l&&"RootAIChat__tool__header__icon--open"),size:14}),e(G,{color:"dark",variant:"filled",size:"xs",children:n}),e("span",{className:"RootAIChat__tool__title",children:Ke(n,o.input)}),e("span",{className:"RootAIChat__tool__state",children:r?wt(r.status):Ve(a)})]}),l&&e("div",{className:"RootAIChat__tool__body",children:[r&&m&&e(xt,{approval:r,onApprove:()=>m.onApprove(r.toolCallId),onReject:()=>m.onReject(r.toolCallId)}),o.output?.receipt&&e(bt,{output:o.output}),o.input&&e("details",{children:[e("summary",{children:[e(ee,{size:14,className:"RootAIChat__tool__json__icon"}),e("span",{children:"Input"})]}),e("pre",{children:JSON.stringify(o.input,null,2)})]}),o.output&&e("details",{children:[e("summary",{children:[e(ee,{size:14,className:"RootAIChat__tool__json__icon"}),e("span",{children:"Output"})]}),e("pre",{children:JSON.stringify(o.output,null,2)})]}),o.errorText&&e("div",{className:"RootAIChat__tool__error",children:o.errorText})]})]})}function Rt(t){return t.toolCallId||t.id||""}function xt(t){let o=t.approval.preview,n=o.before!==void 0&&o.after!==void 0;return e("div",{className:"RootAIChat__approval",children:[e("div",{className:"RootAIChat__approval__header",children:[e("div",{children:[e("div",{className:"RootAIChat__approval__title",children:o.title}),e("div",{className:"RootAIChat__approval__summary",children:o.summary})]}),e(G,{className:"RootAIChat__approval__status",variant:"light",color:"gray",children:t.approval.status==="executing"?"Applying":"Review"})]}),o.details.length>0&&e("div",{className:"RootAIChat__approval__details",children:o.details.map(a=>e("div",{children:[e("span",{children:a.label}),e("strong",{children:a.value})]},`${a.label}:${a.value}`))}),n&&e(we,{className:"RootAIChat__approval__diff",oldCode:q(o.before),newCode:q(o.after)}),e("div",{className:"RootAIChat__approval__actions",children:[e(j,{variant:"default",color:"dark",size:"xs",type:"button",className:"RootAIChat__approval__button",disabled:t.approval.status==="executing",onClick:t.onReject,children:"Reject"}),e(j,{variant:"filled",color:"green",size:"xs",type:"button",className:"RootAIChat__approval__button RootAIChat__approval__button--primary",disabled:t.approval.status==="executing",onClick:t.onApprove,children:"Approve draft edit"})]})]})}function bt(t){let o=t.output.receipt;return e("div",{className:"RootAIChat__receipt",children:[e("div",{className:"RootAIChat__receipt__title",children:[e(Q,{size:14}),e("span",{children:o.title})]}),e("div",{className:"RootAIChat__receipt__summary",children:o.summary}),o.details?.length>0&&e("div",{className:"RootAIChat__receipt__details",children:o.details.map(n=>e("div",{children:[e("span",{children:n.label}),e("strong",{children:n.value})]},`${n.label}:${n.value}`))}),o.adminUrl&&e(j,{component:"a",className:"RootAIChat__receipt__link",variant:"default",size:"xs",compact:!0,href:o.adminUrl,children:"Open document"})]})}function wt(t){return t==="executing"?"applying\u2026":"waiting for approval"}function Mt(t){let[o,n]=_(""),[a,u]=_([]),[m,r]=_(!1),l=y(null),g=y(null);M(()=>{window.requestAnimationFrame(()=>{let c=g.current;c&&(c.style.height="auto",c.style.height=`${Math.min(c.scrollHeight,240)}px`)})},[o,a]);let R=()=>{t.disabled||t.isStreaming||!o&&a.length===0||(t.onSend(o,a),n(""),u([]),l.current&&(l.current.value=""))},x=c=>{c.key==="Enter"&&!c.shiftKey&&(c.preventDefault(),R())},v=async c=>{r(!0);try{let C=c.type||Pt(c.name),A=await St(c,C),I=await Ie(c,{disableGci:!0});u(S=>[...S,{url:I.src,filename:I.filename||c.name,mediaType:C,textContent:A?.text,textTruncated:A?.truncated,width:I.width,height:I.height}])}catch(C){console.error("upload failed",C)}finally{r(!1),l.current&&(l.current.value="")}},P=c=>{let C=c.target;Array.from(C.files||[]).forEach(v)};return e("div",{className:"RootAIChat__composer",children:[a.length>0&&e("div",{className:"RootAIChat__composer__attachments",children:a.map((c,C)=>e("div",{className:"RootAIChat__composer__attachment",children:[c.mediaType.startsWith("image/")?e("img",{src:c.url,alt:c.filename}):e("span",{className:"RootAIChat__composer__attachment__name",children:c.filename}),e("button",{type:"button",className:"RootAIChat__composer__attachment__remove",onClick:()=>u(A=>A.filter((I,S)=>S!==C)),children:e(B,{size:12})})]},C))}),e("div",{className:"RootAIChat__composer__row",children:[e(H,{label:t.canAttach?"Attach file":"Model doesn't support attachments",className:"RootAIChat__composer__attachTooltip",children:e(E,{component:"label",radius:"xl",className:T("RootAIChat__composer__attach",!t.canAttach&&"RootAIChat__composer__attach--disabled"),disabled:!t.canAttach,children:[m?e(J,{size:"xs"}):e(oe,{size:18}),e("input",{ref:l,type:"file",style:{display:"none"},onChange:P})]})}),e("textarea",{ref:g,className:"RootAIChat__composer__textarea",placeholder:t.disabled?"Select a model\u2026":"Ask anything\u2026",value:o,rows:1,autofocus:!0,disabled:t.disabled,onKeyDown:x,onChange:c=>n(c.target.value),onPaste:c=>{let C=c.clipboardData?.items||[];for(let A of C)if(A.kind==="file"){let I=A.getAsFile();I&&t.canAttach&&v(I)}}}),t.isStreaming?e(E,{className:"RootAIChat__composer__button RootAIChat__composer__stopButton",radius:"xl",color:"dark",variant:"filled",onClick:t.onStop,title:"Stop",children:e(B,{size:18})}):e(E,{className:"RootAIChat__composer__button RootAIChat__composer__submitButton",radius:"xl",color:"dark",variant:"filled",disabled:t.disabled||m||!o&&a.length===0,onClick:R,title:"Send",children:e(xe,{size:18})})]}),t.controls]})}var et=1e5;function Nt(t){let o=t.filter(tt),n=t.filter(a=>!tt(a)).map(Tt);return{files:o,text:n.length?`Attached files:
6
+
7
+ ${n.join(`
8
+
9
+ `)}`:""}}function tt(t){return t.mediaType.startsWith("image/")}function Tt(t){let o=`File: ${t.filename} (${t.mediaType})`;if(t.textContent!==void 0){let n=t.textTruncated?`
10
+
11
+ [Content truncated before sending to the model.]`:"";return`${o}
12
+ URL: ${t.url}
13
+
14
+ ~~~
15
+ ${t.textContent}${n}
16
+ ~~~`}return`${o}
17
+ URL: ${t.url}
18
+
19
+ [The file was uploaded, but its binary content was not inlined into this chat message.]`}async function St(t,o){if(!Et(t.name,o))return null;let n=await t.text();return n.length<=et?{text:n,truncated:!1}:{text:n.slice(0,et),truncated:!0}}function Et(t,o){return o.startsWith("text/")?!0:[".css",".js",".jsx",".json",".md",".mdx",".mjs",".scss",".ts",".tsx",".txt",".yaml",".yml"].some(n=>t.toLowerCase().endsWith(n))}function Pt(t){let o=t.toLowerCase();return o.endsWith(".png")?"image/png":o.endsWith(".webp")?"image/webp":o.endsWith(".jpg")||o.endsWith(".jpeg")?"image/jpeg":o.endsWith(".gif")?"image/gif":o.endsWith(".svg")?"image/svg+xml":o.endsWith(".pdf")?"application/pdf":o.endsWith(".json")?"application/json":o.endsWith(".csv")?"text/csv":o.endsWith(".md")?"text/markdown":o.endsWith(".txt")?"text/plain":"application/octet-stream"}function kt(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`chat-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}export{so as a};
@@ -1 +1 @@
1
- import{a as z}from"./chunk-VRRRFAIV.js";import{c as C}from"./chunk-5SY2SVEX.js";import{f as h}from"./chunk-5MV6XVGA.js";import{a as x}from"./chunk-KBJ4AK5O.js";import{a as P}from"./chunk-AAHM6RYJ.js";import{U as b,Y as A,Z as I}from"./chunk-YV5SGR24.js";import{e as D}from"./chunk-WS37MDM3.js";import{Ga as e,Hc as N,U as y,V as u,_c as k,a as t,c as v,da as S,e as w,j as V}from"./chunk-ETPZ3TXX.js";import{d as g}from"./chunk-KUCVLANF.js";V();V();function R(o){let r=o.docId,[i,d]=t("idle"),[c,f]=t(""),[s,l]=t(""),m=w(!1);async function p(){d("loading");try{let n=await I(r,{beforeVersion:o.beforeVersion,afterVersion:o.afterVersion});f(n),d("success")}catch(n){console.error(n),l(n instanceof Error?n.message:"Unknown error"),d("error")}}function _(){m.current||(m.current=!0,p())}let a;return i==="idle"||i==="loading"?a=e("div",{className:"AiSummary__loading",children:e(u,{size:"md",color:"gray"})}):i==="error"?a=e(x,{className:"AiSummary__content",size:"body-sm",color:"gray",children:["Failed to load AI summary.",s&&e(g,{children:[e("br",{}),s]})]}):c?a=e(C,{className:"AiSummary__content",code:c}):a=e(x,{className:"AiSummary__content",size:"body-sm",color:"gray",children:"No AI summary available for this draft yet."}),e("div",{className:D(o.className,"AiSummary"),children:e(y,{iconPosition:"right",onChange:()=>_(),disableIconRotation:!0,children:e(y.Item,{label:"Summarize changes",icon:e(N,{stroke:"1.5"}),iconPosition:"left",children:a})})})}function me(o){let r=o.left,i=o.right,[d,c]=t(!1),[f,s]=t(null),[l,m]=t(null),p=P()&&r.docId===i.docId&&o.showAiSummary!==!1,_=h(E(f?.fields||{})),a=h(E(l?.fields||{})),n=!d&&f&&l&&_===a,M=`/cms/compare?left=${F(r)}&right=${F(i)}`;async function $(){c(!0);let[j,T]=await Promise.all([b(r.docId,r.versionId),b(i.docId,i.versionId)]);s(j),m(T),c(!1)}return v(()=>{$()},[]),d?e("div",{className:"DocDiffViewer DocDiffViewer--loading",children:e(u,{size:"md",color:"gray"})}):e(g,{children:[p&&e(R,{className:"DocDiffViewer__aiSummary",docId:r.docId,beforeVersion:String(r.versionId),afterVersion:String(i.versionId)}),e("div",{className:D(o.className,"DocDiffViewer"),children:[o.showExpandButton&&e("div",{className:"DocDiffViewer__expand",children:e(S,{component:"a",variant:"default",size:"xs",compact:!0,href:M,target:"_blank",children:"Open in new tab"})}),e("div",{className:"DocDiffViewer__header",children:[e("div",{className:"DocDiffViewer__header__label",children:[e("div",{className:"DocDiffViewer__header__label__title",children:[o.left.docId,"@",o.left.versionId]}),e("div",{className:"DocDiffViewer__header__label__meta",children:B(f)})]}),e("div",{className:"DocDiffViewer__header__label",children:[e("div",{className:"DocDiffViewer__header__label__title",children:[o.right.docId,"@",o.right.versionId]}),e("div",{className:"DocDiffViewer__header__label__meta",children:B(l)})]})]}),e("div",{className:"DocDiffViewer__diff",children:n?e("div",{className:"DocDiffViewer__identical",children:[e(k,{size:20}),e("span",{children:"No changes. Both versions are identical."})]}):e(z,{oldCode:_,newCode:a})})]})]})}function B(o){if(!o?.sys?.modifiedAt)return"never";let r=o.sys.modifiedAt.toDate();return`${new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(r)} by ${o.sys.modifiedBy}`}function E(o){return A(o,{removeArrayKey:!0})}function F(o){return encodeURIComponent(`${o.docId}@${o.versionId}`).replaceAll("%2F","/").replaceAll("%40","@")}export{R as a,me as b};
1
+ import{a as z}from"./chunk-QWB6MAPJ.js";import{c as C}from"./chunk-235TRWJF.js";import{f as h}from"./chunk-5MV6XVGA.js";import{a as x}from"./chunk-NCZD5IWS.js";import{a as P}from"./chunk-AAHM6RYJ.js";import{U as b,Y as A,Z as I}from"./chunk-ISUGBMXC.js";import{e as D}from"./chunk-WASID5UU.js";import{Ga as e,Kc as N,U as y,V as u,a as t,bd as k,c as v,da as S,e as w,j as V}from"./chunk-WRA24P66.js";import{d as g}from"./chunk-KUCVLANF.js";V();V();function R(o){let r=o.docId,[i,d]=t("idle"),[c,f]=t(""),[s,l]=t(""),m=w(!1);async function p(){d("loading");try{let n=await I(r,{beforeVersion:o.beforeVersion,afterVersion:o.afterVersion});f(n),d("success")}catch(n){console.error(n),l(n instanceof Error?n.message:"Unknown error"),d("error")}}function _(){m.current||(m.current=!0,p())}let a;return i==="idle"||i==="loading"?a=e("div",{className:"AiSummary__loading",children:e(u,{size:"md",color:"gray"})}):i==="error"?a=e(x,{className:"AiSummary__content",size:"body-sm",color:"gray",children:["Failed to load AI summary.",s&&e(g,{children:[e("br",{}),s]})]}):c?a=e(C,{className:"AiSummary__content",code:c}):a=e(x,{className:"AiSummary__content",size:"body-sm",color:"gray",children:"No AI summary available for this draft yet."}),e("div",{className:D(o.className,"AiSummary"),children:e(y,{iconPosition:"right",onChange:()=>_(),disableIconRotation:!0,children:e(y.Item,{label:"Summarize changes",icon:e(N,{stroke:"1.5"}),iconPosition:"left",children:a})})})}function me(o){let r=o.left,i=o.right,[d,c]=t(!1),[f,s]=t(null),[l,m]=t(null),p=P()&&r.docId===i.docId&&o.showAiSummary!==!1,_=h(E(f?.fields||{})),a=h(E(l?.fields||{})),n=!d&&f&&l&&_===a,M=`/cms/compare?left=${F(r)}&right=${F(i)}`;async function $(){c(!0);let[j,T]=await Promise.all([b(r.docId,r.versionId),b(i.docId,i.versionId)]);s(j),m(T),c(!1)}return v(()=>{$()},[]),d?e("div",{className:"DocDiffViewer DocDiffViewer--loading",children:e(u,{size:"md",color:"gray"})}):e(g,{children:[p&&e(R,{className:"DocDiffViewer__aiSummary",docId:r.docId,beforeVersion:String(r.versionId),afterVersion:String(i.versionId)}),e("div",{className:D(o.className,"DocDiffViewer"),children:[o.showExpandButton&&e("div",{className:"DocDiffViewer__expand",children:e(S,{component:"a",variant:"default",size:"xs",compact:!0,href:M,target:"_blank",children:"Open in new tab"})}),e("div",{className:"DocDiffViewer__header",children:[e("div",{className:"DocDiffViewer__header__label",children:[e("div",{className:"DocDiffViewer__header__label__title",children:[o.left.docId,"@",o.left.versionId]}),e("div",{className:"DocDiffViewer__header__label__meta",children:B(f)})]}),e("div",{className:"DocDiffViewer__header__label",children:[e("div",{className:"DocDiffViewer__header__label__title",children:[o.right.docId,"@",o.right.versionId]}),e("div",{className:"DocDiffViewer__header__label__meta",children:B(l)})]})]}),e("div",{className:"DocDiffViewer__diff",children:n?e("div",{className:"DocDiffViewer__identical",children:[e(k,{size:20}),e("span",{children:"No changes. Both versions are identical."})]}):e(z,{oldCode:_,newCode:a})})]})]})}function B(o){if(!o?.sys?.modifiedAt)return"never";let r=o.sys.modifiedAt.toDate();return`${new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(r)} by ${o.sys.modifiedBy}`}function E(o){return A(o,{removeArrayKey:!0})}function F(o){return encodeURIComponent(`${o.docId}@${o.versionId}`).replaceAll("%2F","/").replaceAll("%40","@")}export{R as a,me as b};
@@ -1 +1 @@
1
- import{b as N,f as R,g as U,i as H,j as O,k as P,m as j,o as M}from"./chunk-XOWWPE7X.js";import{a as u,c as C,e as G,h as A,j as F}from"./chunk-ETPZ3TXX.js";F();var X=200,Y=25,J=2;function ot(t,n={}){let[s,r]=u([]),[g,e]=u(!1),[o,h]=u(null),[y,a]=u(null),i=G(null),x=n.limit??Y,L=n.minQueryLength??J;return C(()=>{let m=t.trim();if(m.length<L){i.current?.abort(),i.current=null,r([]),e(!1),h(null);return}e(!0),h(null);let S=window.setTimeout(async()=>{i.current?.abort();let l=new AbortController;i.current=l;try{let c=await fetch("/cms/api/search.query",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({q:m,limit:x}),signal:l.signal});if(!c.ok)throw new Error(`search.query returned ${c.status}`);let d=await c.json();if(!d?.success)throw new Error(d?.error||"search failed");if(l.signal.aborted)return;r(Array.isArray(d.hits)?d.hits:[]),a(d.meta||null),e(!1)}catch(c){if(l.signal.aborted)return;console.error("global search failed:",c),h(String(c?.message||c)),r([]),e(!1)}},X);return()=>{window.clearTimeout(S)}},[t,x,L]),{hits:s,loading:g,error:o,status:y}}function st(){let[t,n]=u({status:{lastRun:null,docCount:0,fieldCount:0,shardCount:0},running:!1}),[s,r]=u(!0),g=A(async()=>{try{let e=await fetch("/cms/api/search.status",{method:"GET",headers:{"Content-Type":"application/json"}});if(!e.ok)return;let o=await e.json();if(!o?.success)return;n({status:o.status,running:!!o.running})}catch(e){console.error("search.status failed:",e)}finally{r(!1)}},[]);return C(()=>{g()},[g]),{...t,loading:s,refresh:g}}var V=200,W=5,z=2;function at(t,n={}){let[s,r]=u([]),[g,e]=u(!1),o=G(null),h=n.limit??10,y=n.minQueryLength??z;return C(()=>{let a=t.trim(),i=a.indexOf("/");if((i>=0?a.slice(i+1):a).length<y){o.current&&(o.current.aborted=!0),o.current=null,r([]),e(!1);return}e(!0);let L=window.setTimeout(async()=>{o.current&&(o.current.aborted=!0);let m={aborted:!1};o.current=m;let S=null,l=a;i>=0&&(S=a.slice(0,i),l=a.slice(i+1));let c=window.__ROOT_CTX?.rootConfig?.projectId,d=window.firebase?.db;if(!c||!d){r([]),e(!1);return}let v=Object.keys(window.__ROOT_CTX.collections||{}),$=S?v.filter(p=>p.toLowerCase()===S.toLowerCase()):v,q=l,B=`${l}\uF8FF`;try{let p=$.map(async f=>{let w=N(d,"Projects",c,"Collections",f,"Drafts"),E=U(w,H(R()),P(q),j(B),O(W));try{let b=await M(E),_=[];return b.forEach(D=>{_.push({collection:f,slug:D.id,docId:`${f}/${D.id}`})}),_}catch(b){return console.error(`docSlugSearch failed for ${f}:`,b),[]}}),K=(await Promise.all(p)).flat();if(m.aborted)return;let Q=K.sort((f,w)=>{let E=f.slug===l||f.docId===a?0:1,b=w.slug===l||w.docId===a?0:1;return E!==b?E-b:f.docId.localeCompare(w.docId)});r(Q.slice(0,h)),e(!1)}catch(p){if(m.aborted)return;console.error("docSlugSearch failed:",p),r([]),e(!1)}},V);return()=>{window.clearTimeout(L)}},[t,h,y]),{hits:s,loading:g}}var T=new Set,k=!1;function I(){return T.values().next().value}function Z(t){I()&&(t.preventDefault(),t.returnValue="")}function tt(t){let n=I();if(!n||t.defaultPrevented||t.ctrlKey||t.metaKey||t.altKey||t.shiftKey||t.button!==0)return;let s=t.composedPath().find(r=>r instanceof HTMLAnchorElement&&!!r.href);!s||(s.getAttribute("href")||"").startsWith("#")||s.download||s.origin!==window.location.origin||!/^(_?self)?$/i.test(s.target)||window.confirm(n.message)||(t.preventDefault(),t.stopImmediatePropagation())}function et(t){let n=I();n&&(window.confirm(n.message)||(t.stopImmediatePropagation(),window.history.pushState(null,"",n.url)))}function lt(){k||(k=!0,window.addEventListener("beforeunload",Z),window.addEventListener("click",tt,{capture:!0}),window.addEventListener("popstate",et))}function ct(t){return T.add(t),()=>T.delete(t)}export{ot as a,st as b,at as c,lt as d,ct as e};
1
+ import{b as N,f as R,g as U,i as H,j as O,k as P,m as j,o as M}from"./chunk-XOWWPE7X.js";import{a as u,c as C,e as G,h as A,j as F}from"./chunk-WRA24P66.js";F();var X=200,Y=25,J=2;function ot(t,n={}){let[s,r]=u([]),[g,e]=u(!1),[o,h]=u(null),[y,a]=u(null),i=G(null),x=n.limit??Y,L=n.minQueryLength??J;return C(()=>{let m=t.trim();if(m.length<L){i.current?.abort(),i.current=null,r([]),e(!1),h(null);return}e(!0),h(null);let S=window.setTimeout(async()=>{i.current?.abort();let l=new AbortController;i.current=l;try{let c=await fetch("/cms/api/search.query",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({q:m,limit:x}),signal:l.signal});if(!c.ok)throw new Error(`search.query returned ${c.status}`);let d=await c.json();if(!d?.success)throw new Error(d?.error||"search failed");if(l.signal.aborted)return;r(Array.isArray(d.hits)?d.hits:[]),a(d.meta||null),e(!1)}catch(c){if(l.signal.aborted)return;console.error("global search failed:",c),h(String(c?.message||c)),r([]),e(!1)}},X);return()=>{window.clearTimeout(S)}},[t,x,L]),{hits:s,loading:g,error:o,status:y}}function st(){let[t,n]=u({status:{lastRun:null,docCount:0,fieldCount:0,shardCount:0},running:!1}),[s,r]=u(!0),g=A(async()=>{try{let e=await fetch("/cms/api/search.status",{method:"GET",headers:{"Content-Type":"application/json"}});if(!e.ok)return;let o=await e.json();if(!o?.success)return;n({status:o.status,running:!!o.running})}catch(e){console.error("search.status failed:",e)}finally{r(!1)}},[]);return C(()=>{g()},[g]),{...t,loading:s,refresh:g}}var V=200,W=5,z=2;function at(t,n={}){let[s,r]=u([]),[g,e]=u(!1),o=G(null),h=n.limit??10,y=n.minQueryLength??z;return C(()=>{let a=t.trim(),i=a.indexOf("/");if((i>=0?a.slice(i+1):a).length<y){o.current&&(o.current.aborted=!0),o.current=null,r([]),e(!1);return}e(!0);let L=window.setTimeout(async()=>{o.current&&(o.current.aborted=!0);let m={aborted:!1};o.current=m;let S=null,l=a;i>=0&&(S=a.slice(0,i),l=a.slice(i+1));let c=window.__ROOT_CTX?.rootConfig?.projectId,d=window.firebase?.db;if(!c||!d){r([]),e(!1);return}let v=Object.keys(window.__ROOT_CTX.collections||{}),$=S?v.filter(p=>p.toLowerCase()===S.toLowerCase()):v,q=l,B=`${l}\uF8FF`;try{let p=$.map(async f=>{let w=N(d,"Projects",c,"Collections",f,"Drafts"),E=U(w,H(R()),P(q),j(B),O(W));try{let b=await M(E),_=[];return b.forEach(D=>{_.push({collection:f,slug:D.id,docId:`${f}/${D.id}`})}),_}catch(b){return console.error(`docSlugSearch failed for ${f}:`,b),[]}}),K=(await Promise.all(p)).flat();if(m.aborted)return;let Q=K.sort((f,w)=>{let E=f.slug===l||f.docId===a?0:1,b=w.slug===l||w.docId===a?0:1;return E!==b?E-b:f.docId.localeCompare(w.docId)});r(Q.slice(0,h)),e(!1)}catch(p){if(m.aborted)return;console.error("docSlugSearch failed:",p),r([]),e(!1)}},V);return()=>{window.clearTimeout(L)}},[t,h,y]),{hits:s,loading:g}}var T=new Set,k=!1;function I(){return T.values().next().value}function Z(t){I()&&(t.preventDefault(),t.returnValue="")}function tt(t){let n=I();if(!n||t.defaultPrevented||t.ctrlKey||t.metaKey||t.altKey||t.shiftKey||t.button!==0)return;let s=t.composedPath().find(r=>r instanceof HTMLAnchorElement&&!!r.href);!s||(s.getAttribute("href")||"").startsWith("#")||s.download||s.origin!==window.location.origin||!/^(_?self)?$/i.test(s.target)||window.confirm(n.message)||(t.preventDefault(),t.stopImmediatePropagation())}function et(t){let n=I();n&&(window.confirm(n.message)||(t.stopImmediatePropagation(),window.history.pushState(null,"",n.url)))}function lt(){k||(k=!0,window.addEventListener("beforeunload",Z),window.addEventListener("click",tt,{capture:!0}),window.addEventListener("popstate",et))}function ct(t){return T.add(t),()=>T.delete(t)}export{ot as a,st as b,at as c,lt as d,ct as e};
@@ -1 +1 @@
1
- import{a as Vt}from"./chunk-AAHM6RYJ.js";import{d as Y,e as N}from"./chunk-WS37MDM3.js";import{C as dt,D as j,Dc as zt,E as ut,Fa as Et,G as U,Ga as r,Gb as Bt,Gc as Wt,H as mt,I as gt,K as ft,O as ht,P as _t,Pb as It,Q as vt,S as Q,T as yt,Ub as Tt,Y as S,Ya as Pt,Z as bt,_ as Ct,a as x,aa as xt,c as O,e as pt,fa as wt,fb as At,fc as Mt,ha as St,ia as kt,j as je,ja as Lt,ka as Ot,pb as Nt,qa as Z,qc as Dt,ua as jt,v as n,y as w,yc as Ht,zc as Rt}from"./chunk-ETPZ3TXX.js";import{d as V,j as ct}from"./chunk-KUCVLANF.js";var tt={name:"@blinkk/root-cms",version:"3.1.4",author:"s@blinkk.com",license:"MIT",engines:{node:">=22.0.0"},repository:{type:"git",url:"git+https://github.com/blinkk/rootjs.git",directory:"packages/root-cms"},files:["dist/**/*"],bin:{"root-cms":"./bin/root-cms.js"},type:"module",module:"./dist/core.js",types:"./dist/core/core.d.ts",exports:{".":{types:"./dist/core/core.d.ts",import:"./dist/core.js"},"./browser-client":{types:"./dist/browser-client/browser-client.d.ts",import:"./dist/browser-client.js"},"./client":{types:"./dist/core/client.d.ts",import:"./dist/client.js"},"./core":{types:"./dist/core/core.d.ts",import:"./dist/core.js"},"./functions":{types:"./dist/core/functions.d.ts",import:"./dist/functions.js"},"./plugin":{types:"./dist/core/plugin.d.ts",import:"./dist/plugin.js"},"./project":{types:"./dist/core/project.d.ts",import:"./dist/project.js"},"./richtext":{types:"./dist/core/richtext.d.ts",import:"./dist/richtext.js"}},scripts:{build:'rm -rf dist && concurrently -n "core,signin,ui" npm:build:core npm:build:signin npm:build:ui',"build:core":"node ../../scripts/build-esbuild.mjs ./esbuild.config.json","build:ui":"pnpm build:ui:bundle && pnpm build:ui:clean","build:ui:bundle":"esbuild ui/ui.tsx --bundle --minify --alias:react=@preact/compat --alias:react-dom=@preact/compat --tsconfig=ui/tsconfig.json --outdir=dist/ui --legal-comments=external --splitting --format=esm","build:ui:clean":"rm -f dist/ui/*-*.css","build:signin":"esbuild signin/signin.tsx --bundle --minify --tsconfig=signin/tsconfig.json --outdir=dist/ui --legal-comments=external",dev:'rm -rf dist && concurrently -k -n "core,ui" npm:dev:core npm:dev:signin npm:dev:ui',"dev:core":"pnpm build:core --watch","dev:signin":"pnpm build:signin --watch","dev:ui":"pnpm build:ui:bundle --watch",test:"pnpm build && firebase emulators:exec 'vitest run --exclude=**/*.visual.test.tsx'","test:visual":"vitest run --config=vitest.config.visual.ts","test:watch":"pnpm build && firebase emulators:exec 'vitest'"},dependencies:{"@ag-grid-community/client-side-row-model":"32.3.9","@ag-grid-community/core":"32.3.9","@ag-grid-community/react":"32.3.9","@ag-grid-community/styles":"32.3.9","@ai-sdk/anthropic":"3.0.74","@ai-sdk/google":"3.0.67","@ai-sdk/openai":"3.0.60","@ai-sdk/openai-compatible":"2.0.46","@ai-sdk/react":"3.0.177","@google-cloud/firestore":"7.11.3","@hello-pangea/dnd":"18.0.1","@mantine/spotlight":"4.2.12","@types/cli-progress":"3.11.6",ai:"6.0.175","body-parser":"1.20.2","cli-progress":"3.12.0",commander:"11.0.0","csv-parse":"5.5.2","csv-stringify":"6.4.4","date-fns":"4.1.0","date-fns-tz":"3.2.0",diff:"8.0.2","dts-dom":"3.7.0","fnv-plus":"1.3.1",jsonwebtoken:"9.0.2",kleur:"4.1.5",minisearch:"7.2.0","sanitize-html":"2.13.1",sirv:"2.0.3","tiny-glob":"0.2.9",zod:"4.4.3"},"//":"NOTE(stevenle): due to compat issues with mantine and preact, mantine is pinned to v4.2.12",devDependencies:{"@babel/core":"7.17.9","@blinkk/root":"workspace:*","@editorjs/editorjs":"2.30.8","@editorjs/header":"2.8.8","@editorjs/image":"2.10.2","@editorjs/list":"2.0.6","@editorjs/nested-list":"1.4.3","@editorjs/raw":"2.5.1","@editorjs/table":"2.4.4","@editorjs/underline":"1.2.1","@emotion/react":"11.10.5","@firebase/app-compat":"0.5.2","@firebase/app-types":"0.9.3","@firebase/rules-unit-testing":"5.0.0","@lexical/code":"0.33.1","@lexical/html":"0.33.1","@lexical/link":"0.33.1","@lexical/list":"0.33.1","@lexical/markdown":"0.33.1","@lexical/react":"0.33.1","@lexical/rich-text":"0.33.1","@lexical/selection":"0.33.1","@lexical/table":"0.33.1","@lexical/utils":"0.33.1","@mantine/core":"4.2.12","@mantine/hooks":"4.2.12","@mantine/modals":"4.2.12","@mantine/notifications":"4.2.12","@preact/compat":"18.3.1","@tabler/icons-preact":"3.35.0","@testing-library/preact":"3.2.4","@testing-library/user-event":"14.6.1","@types/body-parser":"1.19.3","@types/fnv-plus":"1.3.2","@types/gapi":"0.0.47","@types/gapi.client.drive-v3":"0.0.4","@types/gapi.client.sheets-v4":"0.0.4","@types/google.accounts":"0.0.14","@types/jsonwebtoken":"9.0.1","@types/node":"24.3.1","@types/sanitize-html":"2.13.0","@vitest/browser":"4.1.8","@vitest/browser-playwright":"4.1.8",concurrently:"7.6.0",esbuild:"0.28.0",firebase:"12.2.1","firebase-admin":"13.5.0","firebase-functions":"6.4.0","firebase-tools":"14.15.2","highlight.js":"11.6.0",jsdom:"27.2.0","json-diff-kit":"1.0.29",lexical:"0.33.1",marked:"9.1.1","mdast-util-from-markdown":"2.0.1","mdast-util-gfm":"3.0.0","micromark-extension-gfm":"3.0.0",playwright:"1.60.0",preact:"10.27.1","preact-iso":"2.11.1","preact-render-to-string":"6.6.7",react:"npm:@preact/compat@18.3.1","react-dom":"npm:@preact/compat@18.3.1","react-easy-crop":"5.5.6","react-json-view-compare":"2.0.2",typescript:"6.0.3",vite:"8.0.13",vitest:"4.1.6",yjs:"13.6.27"},peerDependencies:{"@blinkk/root":"3.1.4","firebase-admin":">=11","firebase-functions":">=4"},peerDependenciesMeta:{"firebase-functions":{optional:!0}}};function Ut(){return r("svg",{width:"100",height:"23",viewBox:"0 0 100 23",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r("g",{"clip-path":"url(#clip0_1_318)",children:[r("path",{d:"M7.82998 5.01802C3.12925 5.6479 0.833937 18.1194 2.62578 19.6731C5.64773 22.2934 16.6441 14.1722 15.6786 9.46913C15.3009 6.61371 11.2717 4.28377 7.82998 5.01802Z",fill:"black"}),r("path",{d:"M13.9782 0.720147C12.6553 0.896474 12.0093 4.38767 12.5136 4.8226C13.364 5.55611 16.4587 3.28271 16.187 1.96616C16.0807 1.16683 14.9468 0.514607 13.9782 0.720147Z",fill:"black"}),r("path",{d:"M92.7383 17.6275C90.9681 17.6275 89.3816 17.0263 88.3796 16.0744C87.9955 15.7237 87.8953 15.3396 88.246 14.9555L88.8305 14.2541C89.1645 13.87 89.5486 13.7865 89.9327 14.1205C90.6007 14.6883 91.7029 15.1726 92.5713 15.1726C93.5232 15.1726 94.1244 14.8219 94.1244 14.2875C94.1244 13.5193 93.2059 13.4358 91.9868 13.0684C90.417 12.6008 88.5132 11.7324 88.5132 9.64493C88.5132 7.70773 90.25 6.37173 92.7383 6.37173C94.2413 6.37173 95.5272 6.87273 96.4123 7.57413C96.8131 7.90813 96.9467 8.27553 96.596 8.67633L96.0282 9.37773C95.7109 9.76183 95.3435 9.82863 94.926 9.51133C94.3916 9.09383 93.6568 8.69303 92.7884 8.69303C92.0202 8.69303 91.5192 9.01033 91.5192 9.51133C91.5192 10.1292 92.3041 10.4131 93.1224 10.6636C94.9761 11.2314 97.1304 11.8326 97.1304 14.2708C97.1304 16.4585 95.1264 17.6275 92.7383 17.6275Z",fill:"black"}),r("path",{d:"M87.0008 16.6756C87.0843 17.1766 86.8171 17.4271 86.2994 17.4271H85.097C84.596 17.4271 84.3789 17.1766 84.3121 16.6756L83.7443 11.9161L81.757 16.7424C81.5399 17.2434 81.1892 17.5106 80.6882 17.5106H80.5212C80.0202 17.5106 79.6695 17.2434 79.4524 16.7424L77.4651 11.8994L76.8973 16.6756C76.8472 17.1766 76.6301 17.4271 76.1291 17.4271H74.7263C74.2086 17.4271 73.9414 17.1766 74.0082 16.6756L75.4945 7.24013C75.5613 6.75583 75.8786 6.48863 76.3796 6.48863H76.5466C77.0476 6.48863 77.3315 6.75583 77.5486 7.24013L80.6047 13.8032L83.4938 7.24013C83.7109 6.75583 84.0115 6.48863 84.4958 6.48863H84.6795C85.1638 6.48863 85.4811 6.75583 85.5646 7.24013L87.0008 16.6756Z",fill:"black"}),r("path",{d:"M68.6496 17.6275C65.3096 17.6275 62.7211 15.2227 62.7211 11.9996C62.7211 8.77653 65.3096 6.37173 68.683 6.37173C70.3029 6.37173 71.7558 6.97293 72.7745 7.99163C73.1419 8.34233 73.1419 8.77653 72.7745 9.09383L71.9228 9.81193C71.5554 10.1292 71.2047 10.1125 70.8206 9.79523C70.2361 9.31093 69.5013 9.01033 68.683 9.01033C67.013 9.01033 65.7104 10.2628 65.7104 11.9996C65.7104 13.7364 67.013 14.9889 68.683 14.9889C69.5013 14.9889 70.2528 14.6883 70.8206 14.204C71.2047 13.8867 71.5554 13.87 71.9228 14.1873L72.7745 14.9054C73.1419 15.2227 73.1419 15.6569 72.7745 16.0076C71.7558 17.0263 70.3029 17.6275 68.6496 17.6275Z",fill:"black"}),r("path",{d:"M58.575 16.2915C58.7587 16.6923 58.4581 16.8927 58.241 17.0597C57.7233 17.4271 56.9384 17.6442 56.1201 17.6442C54.4501 17.6442 52.8469 16.6923 52.8469 14.4044V11.0978H52.1121C51.6111 11.0978 51.3439 10.8139 51.3439 10.3296V9.76183C51.3439 9.26083 51.6111 8.99363 52.1121 8.99363H52.8469V7.05643C52.8469 6.57213 53.1308 6.38843 53.6151 6.28823L54.9511 6.05443C55.4521 5.95423 55.7193 6.30493 55.7193 6.80593V8.99363H57.3726C57.8569 8.99363 58.1408 9.26083 58.1408 9.76183V10.3296C58.1408 10.8139 57.8569 11.0978 57.3726 11.0978H55.7193V14.1038C55.7193 14.9221 56.1368 15.1893 56.6545 15.1893C56.905 15.1893 57.1555 15.0724 57.3392 14.9555C57.7567 14.6883 57.9571 14.8887 58.1074 15.206L58.575 16.2915Z",fill:"black"}),r("path",{d:"M46.2592 17.6442C43.5538 17.6442 41.5999 15.7738 41.5999 13.2521C41.5999 10.7304 43.5538 8.86003 46.2592 8.86003C48.9646 8.86003 50.9185 10.7304 50.9185 13.2521C50.9185 15.7738 48.9646 17.6442 46.2592 17.6442ZM46.2592 15.1726C47.3113 15.1726 48.0628 14.3543 48.0628 13.2521C48.0628 12.1499 47.3113 11.3316 46.2592 11.3316C45.2071 11.3316 44.4389 12.1499 44.4389 13.2521C44.4389 14.3543 45.2071 15.1726 46.2592 15.1726Z",fill:"black"}),r("path",{d:"M36.052 17.6442C33.3466 17.6442 31.3927 15.7738 31.3927 13.2521C31.3927 10.7304 33.3466 8.86003 36.052 8.86003C38.7574 8.86003 40.7113 10.7304 40.7113 13.2521C40.7113 15.7738 38.7574 17.6442 36.052 17.6442ZM36.052 15.1726C37.1041 15.1726 37.8556 14.3543 37.8556 13.2521C37.8556 12.1499 37.1041 11.3316 36.052 11.3316C34.9999 11.3316 34.2317 12.1499 34.2317 13.2521C34.2317 14.3543 34.9999 15.1726 36.052 15.1726Z",fill:"black"}),r("path",{d:"M28.7099 13.0851L30.6805 16.6422C30.9644 17.1599 30.6638 17.4271 30.1628 17.4271H28.4594C27.9417 17.4271 27.8081 17.1766 27.5242 16.6589L25.7707 13.4859H24.6351V16.6422C24.6351 17.1432 24.3512 17.4271 23.8502 17.4271H22.4808C21.9798 17.4271 21.6959 17.1432 21.6959 16.6422V7.35703C21.6959 6.85603 21.9798 6.57213 22.4808 6.57213H26.5222C29.3111 6.57213 30.8141 7.92483 30.8141 10.1125C30.8141 11.5654 29.9791 12.5841 28.7099 13.0851ZM24.6351 8.96023V11.5153H26.4721C27.2236 11.5153 27.8248 11.0644 27.8248 10.2628C27.8248 9.44453 27.2236 8.96023 26.4721 8.96023H24.6351Z",fill:"black"})]}),r("defs",{children:r("clipPath",{id:"clip0_1_318",children:r("rect",{width:"99",height:"22",fill:"white",transform:"translate(0.0175781 0.177246)"})})})]})}w();var Qt=ct(null);w();w();var Pe=Object.defineProperty,Ae=Object.defineProperties,Ne=Object.getOwnPropertyDescriptors,Zt=Object.getOwnPropertySymbols,Be=Object.prototype.hasOwnProperty,Ie=Object.prototype.propertyIsEnumerable,Gt=(t,e,o)=>e in t?Pe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,Te=(t,e)=>{for(var o in e||(e={}))Be.call(e,o)&&Gt(t,o,e[o]);if(Zt)for(var o of Zt(e))Ie.call(e,o)&&Gt(t,o,e[o]);return t},Me=(t,e)=>Ae(t,Ne(e));function De(t){return Me(Te({},t),{id:t.id||ft()})}function He(t){let e=[];return t.reduceRight((o,i)=>(e.includes(i.id)||(e.push(i.id),o.push(i)),o),[]).reverse()}function G(t){return He(t.map(e=>De(e)))}function Ft(t,e){let[o,i]=x(G(typeof t=="function"?t(e):t));return O(()=>{typeof t=="function"&&i(G(t(e)))},[e]),[o,{registerActions:s=>i(a=>G([...a,...s])),updateActions:s=>i(G(typeof s=="function"?s(e):s)),removeActions:s=>i(a=>a.filter(d=>!s.includes(d.id))),triggerAction:s=>{var a;let d=o.find(g=>g.id===s);(a=d?.onTrigger)==null||a.call(d,d)}}]}function Re(t,e){return t===null?[]:Array.isArray(t)?t.map(o=>[o,e]):[[t,e]]}function Kt(t,e){_t(Re(t,e))}w();w();var ze=j((t,{radius:e})=>({action:{position:"relative",display:"block",width:"100%",padding:"10px 12px",borderRadius:t.fn.radius(e)},actionHovered:{backgroundColor:t.colorScheme==="dark"?t.colors.dark[4]:t.colors.gray[1]},actionIcon:{color:t.colorScheme==="dark"?t.colors.dark[2]:t.colors.gray[6]},actionBody:{flex:1}})),$t=ze;var We=Object.defineProperty,F=Object.getOwnPropertySymbols,qt=Object.prototype.hasOwnProperty,Jt=Object.prototype.propertyIsEnumerable,Xt=(t,e,o)=>e in t?We(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,Ve=(t,e)=>{for(var o in e||(e={}))qt.call(e,o)&&Xt(t,o,e[o]);if(F)for(var o of F(e))Jt.call(e,o)&&Xt(t,o,e[o]);return t},Ue=(t,e)=>{var o={};for(var i in t)qt.call(t,i)&&e.indexOf(i)<0&&(o[i]=t[i]);if(t!=null&&F)for(var i of F(t))e.indexOf(i)<0&&Jt.call(t,i)&&(o[i]=t[i]);return o};function et(t){var e=t,{action:o,styles:i,classNames:l,hovered:c,onTrigger:m,highlightQuery:_,highlightColor:s,query:a,radius:d}=e,g=Ue(e,["action","styles","classNames","hovered","onTrigger","highlightQuery","highlightColor","query","radius"]);let{classes:u,cx:h}=$t({radius:d},{styles:i,classNames:l,name:"Spotlight"});return n.createElement(Q,Ve({className:h(u.action,{[u.actionHovered]:c}),tabIndex:-1,onMouseDown:b=>b.preventDefault(),onClick:m},g),n.createElement(wt,{noWrap:!0},o.icon&&n.createElement(yt,{className:u.actionIcon},o.icon),n.createElement("div",{className:u.actionBody},n.createElement(Ot,{highlightColor:s,highlight:_?a:null},o.title),o.description&&n.createElement(S,{color:"dimmed",size:"xs"},o.description))))}et.displayName="@mantine/spotlight/DefaultAction";w();var Qe=j(t=>({nothingFound:{},actions:{padding:t.spacing.xs/2,borderTop:`1px solid ${t.colorScheme==="dark"?t.colors.dark[4]:t.colors.gray[2]}`},actionsGroup:{textTransform:"uppercase",fontSize:t.spacing.xs,fontWeight:700,padding:"10px 12px",paddingBottom:0,paddingTop:15}})),Yt=Qe;function ot({actions:t,styles:e,classNames:o,actionComponent:i,hovered:l,onActionHover:c,onActionTrigger:m,query:_,nothingFoundMessage:s,highlightQuery:a,highlightColor:d,radius:g}){let{classes:u}=Yt(null,{classNames:o,styles:e,name:"Spotlight"}),h=t.map(v=>v.type==="item"?n.createElement(i,{query:_,key:v.item.id,action:v.item,hovered:v.index===l,onMouseEnter:()=>c(v.index),classNames:o,styles:e,radius:g,onTrigger:()=>m(v.item),highlightQuery:a,highlightColor:d}):n.createElement(S,{className:u.actionsGroup,color:"dimmed",key:v.label},v.label)),b=h.length>0||!!s&&_.trim().length>0;return n.createElement(n.Fragment,null,b&&n.createElement("div",{className:u.actions},h.length>0?h:n.createElement(S,{color:"dimmed",className:u.nothingFound,align:"center",size:"lg",py:"md"},s)))}ot.displayName="@mantine/spotlight/ActionsList";function Ze(t){return Array.isArray(t)?t.map(e=>e.trim()).join(",").toLowerCase().trim():typeof t=="string"?t.toLowerCase().trim():""}function te(t,e){let o=t.trim().toLowerCase(),i=[[],[]];return e.forEach(l=>{var c,m;(c=l.title)!=null&&c.toLowerCase().includes(o)?i[0].push(l):((m=l.description)!=null&&m.toLowerCase().includes(o)||Ze(l.keywords).includes(o))&&i[1].push(l)}),i.flat()}var Ge=Object.defineProperty,Fe=Object.defineProperties,Ke=Object.getOwnPropertyDescriptors,ee=Object.getOwnPropertySymbols,$e=Object.prototype.hasOwnProperty,Xe=Object.prototype.propertyIsEnumerable,oe=(t,e,o)=>e in t?Ge(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,re=(t,e)=>{for(var o in e||(e={}))$e.call(e,o)&&oe(t,o,e[o]);if(ee)for(var o of ee(e))Xe.call(e,o)&&oe(t,o,e[o]);return t},ie=(t,e)=>Fe(t,Ke(e)),qe=j((t,{centered:e,maxWidth:o,topOffset:i,radius:l})=>({root:ie(re({},t.fn.cover()),{position:"fixed"}),spotlight:{position:"relative",zIndex:2,backgroundColor:t.colorScheme==="dark"?t.colors.dark[6]:t.white,borderRadius:t.fn.radius(l),width:"100%",maxWidth:o,overflow:"hidden",marginLeft:"calc(var(--removed-scroll-width, 0px) * -1)"},overlay:ie(re({},t.fn.cover()),{position:"fixed"}),inner:{height:"100vh",display:"flex",flexDirection:"column",paddingTop:e?t.spacing.md:i,justifyContent:e?"center":"flex-start",alignItems:"center"},searchInput:{border:0,borderBottomRightRadius:0,borderBottomLeftRadius:0,backgroundColor:t.colorScheme==="dark"?t.colors.dark[6]:t.white}})),ne=qe;var Je=Object.defineProperty,K=Object.getOwnPropertySymbols,se=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable,ae=(t,e,o)=>e in t?Je(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,Ye=(t,e)=>{for(var o in e||(e={}))se.call(e,o)&&ae(t,o,e[o]);if(K)for(var o of K(e))le.call(e,o)&&ae(t,o,e[o]);return t},to=(t,e)=>{var o={};for(var i in t)se.call(t,i)&&e.indexOf(i)<0&&(o[i]=t[i]);if(t!=null&&K)for(var i of K(t))e.indexOf(i)<0&&le.call(t,i)&&(o[i]=t[i]);return o};function rt(t){var e=t,{query:o,onQueryChange:i,actions:l,onClose:c,opened:m,withinPortal:_,transition:s="pop",transitionDuration:a,classNames:d,styles:g,overlayColor:u="#000",overlayOpacity:h=.25,overlayBlur:b=3,shadow:v="md",radius:E="sm",centered:X=!1,closeOnActionTrigger:B=!0,highlightQuery:I=!1,highlightColor:T,maxWidth:M=600,topOffset:D=120,className:q,searchPlaceholder:H,searchIcon:R,filter:fe=te,nothingFoundMessage:he,limit:_e=10,actionComponent:ve=et,actionsWrapperComponent:ye="div",zIndex:be=dt("modal")}=e,Ce=to(e,["query","onQueryChange","actions","onClose","opened","withinPortal","transition","transitionDuration","classNames","styles","overlayColor","overlayOpacity","overlayBlur","shadow","radius","centered","closeOnActionTrigger","highlightQuery","highlightColor","maxWidth","topOffset","className","searchPlaceholder","searchIcon","filter","nothingFoundMessage","limit","actionComponent","actionsWrapperComponent","zIndex"]);let[z,k]=x(-1),[xe,at]=x(!1),{classes:P,cx:we}=ne({centered:X,maxWidth:M,topOffset:D,radius:E},{classNames:d,styles:g,name:"Spotlight"}),[,st]=ht(),Se=gt(m),J=()=>k(-1),W=()=>{J(),c()};mt({transitionDuration:0,opened:m});let ke=fe(o,l).slice(0,_e),lt=ut(ke).items,L=lt.map(f=>f.type==="item"?f.item:void 0).filter(f=>f);U(()=>{L.length-1<z&&k(L.length-1)},[L.length]);let Le=f=>{var A;if(!xe)switch(f.code){case"ArrowDown":{f.preventDefault(),k(y=>y<L.length-1?y+1:0);break}case"ArrowUp":{f.preventDefault(),k(y=>y>0?y-1:L.length-1);break}case"Enter":{f.preventDefault();let y=L[z];(A=y?.onTrigger)==null||A.call(y,y),B&&y?.onTrigger&&W();break}case"Escape":f.preventDefault(),W()}},Oe=f=>{i(f.currentTarget.value),z===-1&&k(0)};return n.createElement(St,{withinPortal:_,zIndex:be},n.createElement(kt,{onExited:()=>st(!1),onEntered:()=>st(!0),mounted:m,transitions:{spotlight:{duration:a,transition:s,timingFunction:"ease"},overlay:{duration:a/2,transition:"fade",timingFunction:"ease"}}},f=>n.createElement("div",Ye({className:we(P.root,q)},Ce),n.createElement("div",{className:P.inner,ref:Se},n.createElement(bt,{style:f.spotlight,className:P.spotlight,shadow:v,radius:E,onMouseLeave:J},n.createElement(jt,{value:o,onChange:Oe,onKeyDown:Le,onCompositionStart:()=>at(!0),onCompositionEnd:()=>at(!1),classNames:{input:P.searchInput},size:"lg",placeholder:H,icon:R,onMouseEnter:J,autoComplete:"chrome-please-just-do-not-show-it-thanks"}),n.createElement(ye,null,n.createElement(ot,{highlightQuery:I,highlightColor:T,actions:lt,actionComponent:ve,hovered:z,query:o,nothingFoundMessage:he,onActionHover:k,onActionTrigger:A=>{A.onTrigger(A),B&&W()},styles:g,classNames:d,radius:E}))),n.createElement("div",{style:f.overlay},n.createElement(Lt,{className:P.overlay,zIndex:1,onMouseDown:W,color:u,opacity:h,blur:b}))))))}rt.displayName="@mantine/spotlight/Spotlight";w();var it={open:"mantine:open-spotlight",close:"mantine:close-spotlight",toggle:"mantine:toggle-spotlight",triggerAction:"mantine:trigger-spotlight-action",registerActions:"mantine:register-spotlight-actions",removeActions:"mantine:remove-spotlight-actions"};function eo(t,e){return new CustomEvent(t,{detail:e})}function nt(){window.dispatchEvent(eo(it.open))}function ce(t){let e={registerActions:o=>t.registerActions(o.detail),removeActions:o=>t.removeActions(o.detail),triggerAction:o=>t.triggerAction(o.detail),open:t.openSpotlight,close:t.closeSpotlight,toggle:t.toggleSpotlight};O(()=>(Object.keys(e).forEach(o=>{window.addEventListener(it[o],e[o])}),()=>{Object.keys(e).forEach(o=>{window.removeEventListener(it[o],e[o])})}),[])}var oo=Object.defineProperty,$=Object.getOwnPropertySymbols,de=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable,pe=(t,e,o)=>e in t?oo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,ro=(t,e)=>{for(var o in e||(e={}))de.call(e,o)&&pe(t,o,e[o]);if($)for(var o of $(e))ue.call(e,o)&&pe(t,o,e[o]);return t},io=(t,e)=>{var o={};for(var i in t)de.call(t,i)&&e.indexOf(i)<0&&(o[i]=t[i]);if(t!=null&&$)for(var i of $(t))e.indexOf(i)<0&&ue.call(t,i)&&(o[i]=t[i]);return o};function me(t){var e=t,{actions:o,children:i,shortcut:l="mod + K",onSpotlightClose:c,onSpotlightOpen:m,onQueryChange:_,cleanQueryOnClose:s=!0,transitionDuration:a=150}=e,d=io(e,["actions","children","shortcut","onSpotlightClose","onSpotlightOpen","onQueryChange","cleanQueryOnClose","transitionDuration"]);let g=pt(-1),[u,h]=x(""),[b,{registerActions:v,updateActions:E,removeActions:X,triggerAction:B}]=Ft(o,u);U(()=>{E(o)},[o]);let I=R=>{h(R),_?.(R)},[T,{open:M,close:D,toggle:q}]=vt(!1,{onClose:()=>{c?.(),s&&(g.current=window.setTimeout(()=>{I("")},a))},onOpen:()=>{m?.(),window.clearTimeout(g.current)}}),H={openSpotlight:M,closeSpotlight:D,toggleSpotlight:q,registerActions:v,removeActions:X,triggerAction:B,opened:T,actions:b,query:u};return Kt(l,M),ce(H),n.createElement(Qt.Provider,{value:H},n.createElement(rt,ro({actions:b,onClose:D,opened:T,query:u,onQueryChange:I,transitionDuration:a},d)),i)}me.displayName="@mantine/spotlight/SpotlightProvider";je();function ge(t){let[e,o]=x(!1);O(()=>{let l=navigator.userAgentData?.platform??navigator.platform;o(/mac/i.test(l||""))},[]);let i=()=>{nt()};return r("button",{type:"button",className:N("SearchBar",t.className),onClick:i,"aria-label":"Open search",children:[r(zt,{className:"SearchBar__icon",size:16,stroke:1.5}),r("span",{className:"SearchBar__placeholder",children:"Search"}),r("span",{className:"SearchBar__shortcut","aria-hidden":"true",children:e?"\u2318 + K":"Ctrl + K"})]})}var C="1.5";function p(t){return r("div",{className:"Layout",children:[r(p.Top,{}),r(p.Side,{}),r(p.Main,{...t,children:t.children}),r(p.Bottom,{})]})}function no(t){let o=t.split("?")[0].replace(/\/+$/g,"").split("/").filter(Boolean);return o.length===4&&o[0]==="cms"&&o[1]==="content"}p.Top=()=>{let t=window.__ROOT_CTX.rootConfig,e=t.projectName||t.projectId,o=t.minimalBranding,{url:i}=Y(),l=!no(i);return r("div",{className:"Layout__top",children:[o?r(V,{children:[r("a",{className:"Layout__top__logo",href:"/cms",children:e}),r("a",{className:"Layout__top__version",href:"https://github.com/blinkk/rootjs/blob/main/packages/root-cms/CHANGELOG.md",target:"_blank",rel:"noreferrer noopener",children:["v",tt.version]})]}):r(V,{children:[r("a",{className:"Layout__top__logo",href:"/cms",children:r(Ut,{})}),r("a",{className:"Layout__top__version",href:"https://github.com/blinkk/rootjs/blob/main/packages/root-cms/CHANGELOG.md",target:"_blank",rel:"noreferrer noopener",children:["v",tt.version]}),r("div",{className:"Layout__top__project",children:e})]}),l&&r("div",{className:"Layout__top__search",children:r(ge,{})})]})};p.Side=()=>{let{url:t}=Y(),e=t.replace(/\/*$/g,""),o=window.firebase.user,i=window.__ROOT_CTX.sidebar?.tools,l=new Set(window.__ROOT_CTX.sidebar?.hiddenBuiltInTools||[]),c=s=>l.has(s),m=window.__ROOT_CTX.experiments||{},_=async()=>{await window.firebase.auth.signOut(),window.location.href="/cms/login"};return r("div",{className:"Layout__side",children:[r("div",{className:"Layout__side__buttons",children:[!c("home")&&r(p.SideButton,{label:"Home",url:"/cms",active:e==="/cms",children:r(It,{stroke:C})}),!c("content")&&r(p.SideButton,{label:"Content",url:"/cms/content",active:e.startsWith("/cms/content"),children:r(Bt,{stroke:C})}),m.taskManager&&r(p.SideButton,{label:"Tasks",url:"/cms/tasks",active:e.startsWith("/cms/tasks"),children:r(At,{stroke:C})}),!c("releases")&&r(p.SideButton,{label:"Releases",url:"/cms/releases",active:e.startsWith("/cms/releases"),children:r(Rt,{stroke:C})}),!c("data")&&r(p.SideButton,{label:"Data",url:"/cms/data",active:e.startsWith("/cms/data"),children:r(Nt,{stroke:C})}),!c("assets")&&r(p.SideButton,{label:"Asset Library",url:"/cms/assets",active:e.startsWith("/cms/assets"),children:r(Dt,{stroke:C})}),!c("translations")&&r(p.SideButton,{label:"Translations",url:"/cms/translations",active:e.startsWith("/cms/translations"),children:r(Tt,{stroke:C})}),Vt()&&!c("ai")&&r(p.SideButton,{label:"Root AI",url:"/cms/ai",active:e.startsWith("/cms/ai"),children:r(Ht,{stroke:C})}),i&&r(V,{children:[r("div",{className:"Layout__side__divider"}),Object.entries(i).map(([s,a])=>{let d=a.cmsUrl?.startsWith("/cms/")?a.cmsUrl:void 0,g=a.externalUrl,u=g??d??`/cms/tools/${s}`,h=g?void 0:u.replace(/\/*$/g,""),b=!g&&!!h&&(e===h||e.startsWith(`${h}/`));return r(p.SideButton,{className:"Layout__side__tool",label:a.label||"",url:u,active:b,external:!!g,children:a.icon?r("img",{className:"Layout__side__tool__icon",src:a.icon,alt:a.label||""}):r(Pt,{stroke:C})},s)}),r("div",{className:"Layout__side__divider"})]}),!c("settings")&&r(p.SideButton,{label:"Settings",url:"/cms/settings",active:e.startsWith("/cms/settings"),children:r(Wt,{stroke:C})})]}),r("div",{className:"Layout__side__user",children:r(Z,{shadow:"md",position:"right",control:r(Q,{children:r(xt,{src:o.photoURL,alt:o.email,size:30,radius:"xl"})}),children:[r(Z.Label,{children:r(S,{size:"xs",color:"dimmed",truncate:!0,children:["Signed in as ",o.email]})}),r(Ct,{}),r(Z.Item,{color:"red",icon:r(Mt,{style:{width:14,height:14}}),onClick:_,children:"Sign out"})]})})]})};p.SideButton=t=>r(Et,{className:N("Layout__side__button",t.className),label:t.label,position:"right",withArrow:!0,children:r("a",{className:N(t.active&&"active"),href:t.url,target:t.external?"_blank":void 0,rel:t.external?"noreferrer noopener":void 0,children:t.children})});p.Main=t=>r("div",{className:"Layout__main",children:t.children});p.Bottom=()=>r("div",{className:"Layout__bottom"});export{me as a,p as b};
1
+ import{a as Vt}from"./chunk-AAHM6RYJ.js";import{d as Y,e as N}from"./chunk-WASID5UU.js";import{Bc as Ht,C as dt,Cc as Rt,D as j,E as ut,Fa as Et,G as U,Ga as r,Gc as zt,H as mt,I as gt,Jb as Bt,Jc as Wt,K as ft,O as ht,P as _t,Q as vt,S as Q,Sb as It,T as yt,Xb as Tt,Y as S,Z as bt,_ as Ct,_a as Pt,a as x,aa as xt,c as O,e as pt,fa as wt,ha as St,ia as kt,ib as At,ic as Mt,j as je,ja as Lt,ka as Ot,qa as Z,sb as Nt,tc as Dt,ua as jt,v as n,y as w}from"./chunk-WRA24P66.js";import{d as V,j as ct}from"./chunk-KUCVLANF.js";var tt={name:"@blinkk/root-cms",version:"3.1.6",author:"s@blinkk.com",license:"MIT",engines:{node:">=22.0.0"},repository:{type:"git",url:"git+https://github.com/blinkk/rootjs.git",directory:"packages/root-cms"},files:["dist/**/*"],bin:{"root-cms":"./bin/root-cms.js"},type:"module",module:"./dist/core.js",types:"./dist/core/core.d.ts",exports:{".":{types:"./dist/core/core.d.ts",import:"./dist/core.js"},"./browser-client":{types:"./dist/browser-client/browser-client.d.ts",import:"./dist/browser-client.js"},"./client":{types:"./dist/core/client.d.ts",import:"./dist/client.js"},"./core":{types:"./dist/core/core.d.ts",import:"./dist/core.js"},"./functions":{types:"./dist/core/functions.d.ts",import:"./dist/functions.js"},"./plugin":{types:"./dist/core/plugin.d.ts",import:"./dist/plugin.js"},"./project":{types:"./dist/core/project.d.ts",import:"./dist/project.js"},"./richtext":{types:"./dist/core/richtext.d.ts",import:"./dist/richtext.js"}},scripts:{build:'rm -rf dist && concurrently -n "core,signin,ui" npm:build:core npm:build:signin npm:build:ui',"build:core":"node ../../scripts/build-esbuild.mjs ./esbuild.config.json","build:ui":"pnpm build:ui:bundle && pnpm build:ui:clean","build:ui:bundle":"esbuild ui/ui.tsx --bundle --minify --alias:react=@preact/compat --alias:react-dom=@preact/compat --tsconfig=ui/tsconfig.json --outdir=dist/ui --legal-comments=external --splitting --format=esm","build:ui:clean":"rm -f dist/ui/*-*.css","build:signin":"esbuild signin/signin.tsx --bundle --minify --tsconfig=signin/tsconfig.json --outdir=dist/ui --legal-comments=external",dev:'rm -rf dist && concurrently -k -n "core,ui" npm:dev:core npm:dev:signin npm:dev:ui',"dev:core":"pnpm build:core --watch","dev:signin":"pnpm build:signin --watch","dev:ui":"pnpm build:ui:bundle --watch",test:"pnpm build && firebase emulators:exec 'vitest run --exclude=**/*.visual.test.tsx'","test:visual":"vitest run --config=vitest.config.visual.ts","test:watch":"pnpm build && firebase emulators:exec 'vitest'"},dependencies:{"@ag-grid-community/client-side-row-model":"32.3.9","@ag-grid-community/core":"32.3.9","@ag-grid-community/react":"32.3.9","@ag-grid-community/styles":"32.3.9","@ai-sdk/anthropic":"3.0.74","@ai-sdk/google":"3.0.67","@ai-sdk/openai":"3.0.60","@ai-sdk/openai-compatible":"2.0.46","@ai-sdk/react":"3.0.177","@google-cloud/firestore":"7.11.3","@hello-pangea/dnd":"18.0.1","@mantine/spotlight":"4.2.12","@types/cli-progress":"3.11.6",ai:"6.0.175","body-parser":"1.20.2","cli-progress":"3.12.0",commander:"11.0.0","csv-parse":"5.5.2","csv-stringify":"6.4.4","date-fns":"4.1.0","date-fns-tz":"3.2.0",diff:"8.0.2","dts-dom":"3.7.0","fnv-plus":"1.3.1",jsonwebtoken:"9.0.2",kleur:"4.1.5",minisearch:"7.2.0","sanitize-html":"2.13.1",sirv:"2.0.3","tiny-glob":"0.2.9",zod:"4.4.3"},"//":"NOTE(stevenle): due to compat issues with mantine and preact, mantine is pinned to v4.2.12",devDependencies:{"@babel/core":"7.17.9","@blinkk/root":"workspace:*","@editorjs/editorjs":"2.30.8","@editorjs/header":"2.8.8","@editorjs/image":"2.10.2","@editorjs/list":"2.0.6","@editorjs/nested-list":"1.4.3","@editorjs/raw":"2.5.1","@editorjs/table":"2.4.4","@editorjs/underline":"1.2.1","@emotion/react":"11.10.5","@firebase/app-compat":"0.5.2","@firebase/app-types":"0.9.3","@firebase/rules-unit-testing":"5.0.0","@lexical/code":"0.33.1","@lexical/html":"0.33.1","@lexical/link":"0.33.1","@lexical/list":"0.33.1","@lexical/markdown":"0.33.1","@lexical/react":"0.33.1","@lexical/rich-text":"0.33.1","@lexical/selection":"0.33.1","@lexical/table":"0.33.1","@lexical/utils":"0.33.1","@mantine/core":"4.2.12","@mantine/hooks":"4.2.12","@mantine/modals":"4.2.12","@mantine/notifications":"4.2.12","@preact/compat":"18.3.1","@tabler/icons-preact":"3.35.0","@testing-library/preact":"3.2.4","@testing-library/user-event":"14.6.1","@types/body-parser":"1.19.3","@types/fnv-plus":"1.3.2","@types/gapi":"0.0.47","@types/gapi.client.drive-v3":"0.0.4","@types/gapi.client.sheets-v4":"0.0.4","@types/google.accounts":"0.0.14","@types/jsonwebtoken":"9.0.1","@types/node":"24.3.1","@types/sanitize-html":"2.13.0","@vitest/browser":"4.1.8","@vitest/browser-playwright":"4.1.8",concurrently:"7.6.0",esbuild:"0.28.0",firebase:"12.2.1","firebase-admin":"13.5.0","firebase-functions":"6.4.0","firebase-tools":"14.15.2","highlight.js":"11.6.0",jsdom:"27.2.0","json-diff-kit":"1.0.29",lexical:"0.33.1",marked:"9.1.1","mdast-util-from-markdown":"2.0.1","mdast-util-gfm":"3.0.0","micromark-extension-gfm":"3.0.0",playwright:"1.60.0",preact:"10.27.1","preact-iso":"2.11.1","preact-render-to-string":"6.6.7",react:"npm:@preact/compat@18.3.1","react-dom":"npm:@preact/compat@18.3.1","react-easy-crop":"5.5.6","react-json-view-compare":"2.0.2",typescript:"6.0.3",vite:"8.0.13",vitest:"4.1.6",yjs:"13.6.27"},peerDependencies:{"@blinkk/root":"3.1.6","firebase-admin":">=11","firebase-functions":">=4"},peerDependenciesMeta:{"firebase-functions":{optional:!0}}};function Ut(){return r("svg",{width:"100",height:"23",viewBox:"0 0 100 23",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r("g",{"clip-path":"url(#clip0_1_318)",children:[r("path",{d:"M7.82998 5.01802C3.12925 5.6479 0.833937 18.1194 2.62578 19.6731C5.64773 22.2934 16.6441 14.1722 15.6786 9.46913C15.3009 6.61371 11.2717 4.28377 7.82998 5.01802Z",fill:"black"}),r("path",{d:"M13.9782 0.720147C12.6553 0.896474 12.0093 4.38767 12.5136 4.8226C13.364 5.55611 16.4587 3.28271 16.187 1.96616C16.0807 1.16683 14.9468 0.514607 13.9782 0.720147Z",fill:"black"}),r("path",{d:"M92.7383 17.6275C90.9681 17.6275 89.3816 17.0263 88.3796 16.0744C87.9955 15.7237 87.8953 15.3396 88.246 14.9555L88.8305 14.2541C89.1645 13.87 89.5486 13.7865 89.9327 14.1205C90.6007 14.6883 91.7029 15.1726 92.5713 15.1726C93.5232 15.1726 94.1244 14.8219 94.1244 14.2875C94.1244 13.5193 93.2059 13.4358 91.9868 13.0684C90.417 12.6008 88.5132 11.7324 88.5132 9.64493C88.5132 7.70773 90.25 6.37173 92.7383 6.37173C94.2413 6.37173 95.5272 6.87273 96.4123 7.57413C96.8131 7.90813 96.9467 8.27553 96.596 8.67633L96.0282 9.37773C95.7109 9.76183 95.3435 9.82863 94.926 9.51133C94.3916 9.09383 93.6568 8.69303 92.7884 8.69303C92.0202 8.69303 91.5192 9.01033 91.5192 9.51133C91.5192 10.1292 92.3041 10.4131 93.1224 10.6636C94.9761 11.2314 97.1304 11.8326 97.1304 14.2708C97.1304 16.4585 95.1264 17.6275 92.7383 17.6275Z",fill:"black"}),r("path",{d:"M87.0008 16.6756C87.0843 17.1766 86.8171 17.4271 86.2994 17.4271H85.097C84.596 17.4271 84.3789 17.1766 84.3121 16.6756L83.7443 11.9161L81.757 16.7424C81.5399 17.2434 81.1892 17.5106 80.6882 17.5106H80.5212C80.0202 17.5106 79.6695 17.2434 79.4524 16.7424L77.4651 11.8994L76.8973 16.6756C76.8472 17.1766 76.6301 17.4271 76.1291 17.4271H74.7263C74.2086 17.4271 73.9414 17.1766 74.0082 16.6756L75.4945 7.24013C75.5613 6.75583 75.8786 6.48863 76.3796 6.48863H76.5466C77.0476 6.48863 77.3315 6.75583 77.5486 7.24013L80.6047 13.8032L83.4938 7.24013C83.7109 6.75583 84.0115 6.48863 84.4958 6.48863H84.6795C85.1638 6.48863 85.4811 6.75583 85.5646 7.24013L87.0008 16.6756Z",fill:"black"}),r("path",{d:"M68.6496 17.6275C65.3096 17.6275 62.7211 15.2227 62.7211 11.9996C62.7211 8.77653 65.3096 6.37173 68.683 6.37173C70.3029 6.37173 71.7558 6.97293 72.7745 7.99163C73.1419 8.34233 73.1419 8.77653 72.7745 9.09383L71.9228 9.81193C71.5554 10.1292 71.2047 10.1125 70.8206 9.79523C70.2361 9.31093 69.5013 9.01033 68.683 9.01033C67.013 9.01033 65.7104 10.2628 65.7104 11.9996C65.7104 13.7364 67.013 14.9889 68.683 14.9889C69.5013 14.9889 70.2528 14.6883 70.8206 14.204C71.2047 13.8867 71.5554 13.87 71.9228 14.1873L72.7745 14.9054C73.1419 15.2227 73.1419 15.6569 72.7745 16.0076C71.7558 17.0263 70.3029 17.6275 68.6496 17.6275Z",fill:"black"}),r("path",{d:"M58.575 16.2915C58.7587 16.6923 58.4581 16.8927 58.241 17.0597C57.7233 17.4271 56.9384 17.6442 56.1201 17.6442C54.4501 17.6442 52.8469 16.6923 52.8469 14.4044V11.0978H52.1121C51.6111 11.0978 51.3439 10.8139 51.3439 10.3296V9.76183C51.3439 9.26083 51.6111 8.99363 52.1121 8.99363H52.8469V7.05643C52.8469 6.57213 53.1308 6.38843 53.6151 6.28823L54.9511 6.05443C55.4521 5.95423 55.7193 6.30493 55.7193 6.80593V8.99363H57.3726C57.8569 8.99363 58.1408 9.26083 58.1408 9.76183V10.3296C58.1408 10.8139 57.8569 11.0978 57.3726 11.0978H55.7193V14.1038C55.7193 14.9221 56.1368 15.1893 56.6545 15.1893C56.905 15.1893 57.1555 15.0724 57.3392 14.9555C57.7567 14.6883 57.9571 14.8887 58.1074 15.206L58.575 16.2915Z",fill:"black"}),r("path",{d:"M46.2592 17.6442C43.5538 17.6442 41.5999 15.7738 41.5999 13.2521C41.5999 10.7304 43.5538 8.86003 46.2592 8.86003C48.9646 8.86003 50.9185 10.7304 50.9185 13.2521C50.9185 15.7738 48.9646 17.6442 46.2592 17.6442ZM46.2592 15.1726C47.3113 15.1726 48.0628 14.3543 48.0628 13.2521C48.0628 12.1499 47.3113 11.3316 46.2592 11.3316C45.2071 11.3316 44.4389 12.1499 44.4389 13.2521C44.4389 14.3543 45.2071 15.1726 46.2592 15.1726Z",fill:"black"}),r("path",{d:"M36.052 17.6442C33.3466 17.6442 31.3927 15.7738 31.3927 13.2521C31.3927 10.7304 33.3466 8.86003 36.052 8.86003C38.7574 8.86003 40.7113 10.7304 40.7113 13.2521C40.7113 15.7738 38.7574 17.6442 36.052 17.6442ZM36.052 15.1726C37.1041 15.1726 37.8556 14.3543 37.8556 13.2521C37.8556 12.1499 37.1041 11.3316 36.052 11.3316C34.9999 11.3316 34.2317 12.1499 34.2317 13.2521C34.2317 14.3543 34.9999 15.1726 36.052 15.1726Z",fill:"black"}),r("path",{d:"M28.7099 13.0851L30.6805 16.6422C30.9644 17.1599 30.6638 17.4271 30.1628 17.4271H28.4594C27.9417 17.4271 27.8081 17.1766 27.5242 16.6589L25.7707 13.4859H24.6351V16.6422C24.6351 17.1432 24.3512 17.4271 23.8502 17.4271H22.4808C21.9798 17.4271 21.6959 17.1432 21.6959 16.6422V7.35703C21.6959 6.85603 21.9798 6.57213 22.4808 6.57213H26.5222C29.3111 6.57213 30.8141 7.92483 30.8141 10.1125C30.8141 11.5654 29.9791 12.5841 28.7099 13.0851ZM24.6351 8.96023V11.5153H26.4721C27.2236 11.5153 27.8248 11.0644 27.8248 10.2628C27.8248 9.44453 27.2236 8.96023 26.4721 8.96023H24.6351Z",fill:"black"})]}),r("defs",{children:r("clipPath",{id:"clip0_1_318",children:r("rect",{width:"99",height:"22",fill:"white",transform:"translate(0.0175781 0.177246)"})})})]})}w();var Qt=ct(null);w();w();var Pe=Object.defineProperty,Ae=Object.defineProperties,Ne=Object.getOwnPropertyDescriptors,Zt=Object.getOwnPropertySymbols,Be=Object.prototype.hasOwnProperty,Ie=Object.prototype.propertyIsEnumerable,Gt=(t,e,o)=>e in t?Pe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,Te=(t,e)=>{for(var o in e||(e={}))Be.call(e,o)&&Gt(t,o,e[o]);if(Zt)for(var o of Zt(e))Ie.call(e,o)&&Gt(t,o,e[o]);return t},Me=(t,e)=>Ae(t,Ne(e));function De(t){return Me(Te({},t),{id:t.id||ft()})}function He(t){let e=[];return t.reduceRight((o,i)=>(e.includes(i.id)||(e.push(i.id),o.push(i)),o),[]).reverse()}function G(t){return He(t.map(e=>De(e)))}function Ft(t,e){let[o,i]=x(G(typeof t=="function"?t(e):t));return O(()=>{typeof t=="function"&&i(G(t(e)))},[e]),[o,{registerActions:s=>i(a=>G([...a,...s])),updateActions:s=>i(G(typeof s=="function"?s(e):s)),removeActions:s=>i(a=>a.filter(d=>!s.includes(d.id))),triggerAction:s=>{var a;let d=o.find(g=>g.id===s);(a=d?.onTrigger)==null||a.call(d,d)}}]}function Re(t,e){return t===null?[]:Array.isArray(t)?t.map(o=>[o,e]):[[t,e]]}function Kt(t,e){_t(Re(t,e))}w();w();var ze=j((t,{radius:e})=>({action:{position:"relative",display:"block",width:"100%",padding:"10px 12px",borderRadius:t.fn.radius(e)},actionHovered:{backgroundColor:t.colorScheme==="dark"?t.colors.dark[4]:t.colors.gray[1]},actionIcon:{color:t.colorScheme==="dark"?t.colors.dark[2]:t.colors.gray[6]},actionBody:{flex:1}})),$t=ze;var We=Object.defineProperty,F=Object.getOwnPropertySymbols,qt=Object.prototype.hasOwnProperty,Jt=Object.prototype.propertyIsEnumerable,Xt=(t,e,o)=>e in t?We(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,Ve=(t,e)=>{for(var o in e||(e={}))qt.call(e,o)&&Xt(t,o,e[o]);if(F)for(var o of F(e))Jt.call(e,o)&&Xt(t,o,e[o]);return t},Ue=(t,e)=>{var o={};for(var i in t)qt.call(t,i)&&e.indexOf(i)<0&&(o[i]=t[i]);if(t!=null&&F)for(var i of F(t))e.indexOf(i)<0&&Jt.call(t,i)&&(o[i]=t[i]);return o};function et(t){var e=t,{action:o,styles:i,classNames:l,hovered:c,onTrigger:m,highlightQuery:_,highlightColor:s,query:a,radius:d}=e,g=Ue(e,["action","styles","classNames","hovered","onTrigger","highlightQuery","highlightColor","query","radius"]);let{classes:u,cx:h}=$t({radius:d},{styles:i,classNames:l,name:"Spotlight"});return n.createElement(Q,Ve({className:h(u.action,{[u.actionHovered]:c}),tabIndex:-1,onMouseDown:b=>b.preventDefault(),onClick:m},g),n.createElement(wt,{noWrap:!0},o.icon&&n.createElement(yt,{className:u.actionIcon},o.icon),n.createElement("div",{className:u.actionBody},n.createElement(Ot,{highlightColor:s,highlight:_?a:null},o.title),o.description&&n.createElement(S,{color:"dimmed",size:"xs"},o.description))))}et.displayName="@mantine/spotlight/DefaultAction";w();var Qe=j(t=>({nothingFound:{},actions:{padding:t.spacing.xs/2,borderTop:`1px solid ${t.colorScheme==="dark"?t.colors.dark[4]:t.colors.gray[2]}`},actionsGroup:{textTransform:"uppercase",fontSize:t.spacing.xs,fontWeight:700,padding:"10px 12px",paddingBottom:0,paddingTop:15}})),Yt=Qe;function ot({actions:t,styles:e,classNames:o,actionComponent:i,hovered:l,onActionHover:c,onActionTrigger:m,query:_,nothingFoundMessage:s,highlightQuery:a,highlightColor:d,radius:g}){let{classes:u}=Yt(null,{classNames:o,styles:e,name:"Spotlight"}),h=t.map(v=>v.type==="item"?n.createElement(i,{query:_,key:v.item.id,action:v.item,hovered:v.index===l,onMouseEnter:()=>c(v.index),classNames:o,styles:e,radius:g,onTrigger:()=>m(v.item),highlightQuery:a,highlightColor:d}):n.createElement(S,{className:u.actionsGroup,color:"dimmed",key:v.label},v.label)),b=h.length>0||!!s&&_.trim().length>0;return n.createElement(n.Fragment,null,b&&n.createElement("div",{className:u.actions},h.length>0?h:n.createElement(S,{color:"dimmed",className:u.nothingFound,align:"center",size:"lg",py:"md"},s)))}ot.displayName="@mantine/spotlight/ActionsList";function Ze(t){return Array.isArray(t)?t.map(e=>e.trim()).join(",").toLowerCase().trim():typeof t=="string"?t.toLowerCase().trim():""}function te(t,e){let o=t.trim().toLowerCase(),i=[[],[]];return e.forEach(l=>{var c,m;(c=l.title)!=null&&c.toLowerCase().includes(o)?i[0].push(l):((m=l.description)!=null&&m.toLowerCase().includes(o)||Ze(l.keywords).includes(o))&&i[1].push(l)}),i.flat()}var Ge=Object.defineProperty,Fe=Object.defineProperties,Ke=Object.getOwnPropertyDescriptors,ee=Object.getOwnPropertySymbols,$e=Object.prototype.hasOwnProperty,Xe=Object.prototype.propertyIsEnumerable,oe=(t,e,o)=>e in t?Ge(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,re=(t,e)=>{for(var o in e||(e={}))$e.call(e,o)&&oe(t,o,e[o]);if(ee)for(var o of ee(e))Xe.call(e,o)&&oe(t,o,e[o]);return t},ie=(t,e)=>Fe(t,Ke(e)),qe=j((t,{centered:e,maxWidth:o,topOffset:i,radius:l})=>({root:ie(re({},t.fn.cover()),{position:"fixed"}),spotlight:{position:"relative",zIndex:2,backgroundColor:t.colorScheme==="dark"?t.colors.dark[6]:t.white,borderRadius:t.fn.radius(l),width:"100%",maxWidth:o,overflow:"hidden",marginLeft:"calc(var(--removed-scroll-width, 0px) * -1)"},overlay:ie(re({},t.fn.cover()),{position:"fixed"}),inner:{height:"100vh",display:"flex",flexDirection:"column",paddingTop:e?t.spacing.md:i,justifyContent:e?"center":"flex-start",alignItems:"center"},searchInput:{border:0,borderBottomRightRadius:0,borderBottomLeftRadius:0,backgroundColor:t.colorScheme==="dark"?t.colors.dark[6]:t.white}})),ne=qe;var Je=Object.defineProperty,K=Object.getOwnPropertySymbols,se=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable,ae=(t,e,o)=>e in t?Je(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,Ye=(t,e)=>{for(var o in e||(e={}))se.call(e,o)&&ae(t,o,e[o]);if(K)for(var o of K(e))le.call(e,o)&&ae(t,o,e[o]);return t},to=(t,e)=>{var o={};for(var i in t)se.call(t,i)&&e.indexOf(i)<0&&(o[i]=t[i]);if(t!=null&&K)for(var i of K(t))e.indexOf(i)<0&&le.call(t,i)&&(o[i]=t[i]);return o};function rt(t){var e=t,{query:o,onQueryChange:i,actions:l,onClose:c,opened:m,withinPortal:_,transition:s="pop",transitionDuration:a,classNames:d,styles:g,overlayColor:u="#000",overlayOpacity:h=.25,overlayBlur:b=3,shadow:v="md",radius:E="sm",centered:X=!1,closeOnActionTrigger:B=!0,highlightQuery:I=!1,highlightColor:T,maxWidth:M=600,topOffset:D=120,className:q,searchPlaceholder:H,searchIcon:R,filter:fe=te,nothingFoundMessage:he,limit:_e=10,actionComponent:ve=et,actionsWrapperComponent:ye="div",zIndex:be=dt("modal")}=e,Ce=to(e,["query","onQueryChange","actions","onClose","opened","withinPortal","transition","transitionDuration","classNames","styles","overlayColor","overlayOpacity","overlayBlur","shadow","radius","centered","closeOnActionTrigger","highlightQuery","highlightColor","maxWidth","topOffset","className","searchPlaceholder","searchIcon","filter","nothingFoundMessage","limit","actionComponent","actionsWrapperComponent","zIndex"]);let[z,k]=x(-1),[xe,at]=x(!1),{classes:P,cx:we}=ne({centered:X,maxWidth:M,topOffset:D,radius:E},{classNames:d,styles:g,name:"Spotlight"}),[,st]=ht(),Se=gt(m),J=()=>k(-1),W=()=>{J(),c()};mt({transitionDuration:0,opened:m});let ke=fe(o,l).slice(0,_e),lt=ut(ke).items,L=lt.map(f=>f.type==="item"?f.item:void 0).filter(f=>f);U(()=>{L.length-1<z&&k(L.length-1)},[L.length]);let Le=f=>{var A;if(!xe)switch(f.code){case"ArrowDown":{f.preventDefault(),k(y=>y<L.length-1?y+1:0);break}case"ArrowUp":{f.preventDefault(),k(y=>y>0?y-1:L.length-1);break}case"Enter":{f.preventDefault();let y=L[z];(A=y?.onTrigger)==null||A.call(y,y),B&&y?.onTrigger&&W();break}case"Escape":f.preventDefault(),W()}},Oe=f=>{i(f.currentTarget.value),z===-1&&k(0)};return n.createElement(St,{withinPortal:_,zIndex:be},n.createElement(kt,{onExited:()=>st(!1),onEntered:()=>st(!0),mounted:m,transitions:{spotlight:{duration:a,transition:s,timingFunction:"ease"},overlay:{duration:a/2,transition:"fade",timingFunction:"ease"}}},f=>n.createElement("div",Ye({className:we(P.root,q)},Ce),n.createElement("div",{className:P.inner,ref:Se},n.createElement(bt,{style:f.spotlight,className:P.spotlight,shadow:v,radius:E,onMouseLeave:J},n.createElement(jt,{value:o,onChange:Oe,onKeyDown:Le,onCompositionStart:()=>at(!0),onCompositionEnd:()=>at(!1),classNames:{input:P.searchInput},size:"lg",placeholder:H,icon:R,onMouseEnter:J,autoComplete:"chrome-please-just-do-not-show-it-thanks"}),n.createElement(ye,null,n.createElement(ot,{highlightQuery:I,highlightColor:T,actions:lt,actionComponent:ve,hovered:z,query:o,nothingFoundMessage:he,onActionHover:k,onActionTrigger:A=>{A.onTrigger(A),B&&W()},styles:g,classNames:d,radius:E}))),n.createElement("div",{style:f.overlay},n.createElement(Lt,{className:P.overlay,zIndex:1,onMouseDown:W,color:u,opacity:h,blur:b}))))))}rt.displayName="@mantine/spotlight/Spotlight";w();var it={open:"mantine:open-spotlight",close:"mantine:close-spotlight",toggle:"mantine:toggle-spotlight",triggerAction:"mantine:trigger-spotlight-action",registerActions:"mantine:register-spotlight-actions",removeActions:"mantine:remove-spotlight-actions"};function eo(t,e){return new CustomEvent(t,{detail:e})}function nt(){window.dispatchEvent(eo(it.open))}function ce(t){let e={registerActions:o=>t.registerActions(o.detail),removeActions:o=>t.removeActions(o.detail),triggerAction:o=>t.triggerAction(o.detail),open:t.openSpotlight,close:t.closeSpotlight,toggle:t.toggleSpotlight};O(()=>(Object.keys(e).forEach(o=>{window.addEventListener(it[o],e[o])}),()=>{Object.keys(e).forEach(o=>{window.removeEventListener(it[o],e[o])})}),[])}var oo=Object.defineProperty,$=Object.getOwnPropertySymbols,de=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable,pe=(t,e,o)=>e in t?oo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,ro=(t,e)=>{for(var o in e||(e={}))de.call(e,o)&&pe(t,o,e[o]);if($)for(var o of $(e))ue.call(e,o)&&pe(t,o,e[o]);return t},io=(t,e)=>{var o={};for(var i in t)de.call(t,i)&&e.indexOf(i)<0&&(o[i]=t[i]);if(t!=null&&$)for(var i of $(t))e.indexOf(i)<0&&ue.call(t,i)&&(o[i]=t[i]);return o};function me(t){var e=t,{actions:o,children:i,shortcut:l="mod + K",onSpotlightClose:c,onSpotlightOpen:m,onQueryChange:_,cleanQueryOnClose:s=!0,transitionDuration:a=150}=e,d=io(e,["actions","children","shortcut","onSpotlightClose","onSpotlightOpen","onQueryChange","cleanQueryOnClose","transitionDuration"]);let g=pt(-1),[u,h]=x(""),[b,{registerActions:v,updateActions:E,removeActions:X,triggerAction:B}]=Ft(o,u);U(()=>{E(o)},[o]);let I=R=>{h(R),_?.(R)},[T,{open:M,close:D,toggle:q}]=vt(!1,{onClose:()=>{c?.(),s&&(g.current=window.setTimeout(()=>{I("")},a))},onOpen:()=>{m?.(),window.clearTimeout(g.current)}}),H={openSpotlight:M,closeSpotlight:D,toggleSpotlight:q,registerActions:v,removeActions:X,triggerAction:B,opened:T,actions:b,query:u};return Kt(l,M),ce(H),n.createElement(Qt.Provider,{value:H},n.createElement(rt,ro({actions:b,onClose:D,opened:T,query:u,onQueryChange:I,transitionDuration:a},d)),i)}me.displayName="@mantine/spotlight/SpotlightProvider";je();function ge(t){let[e,o]=x(!1);O(()=>{let l=navigator.userAgentData?.platform??navigator.platform;o(/mac/i.test(l||""))},[]);let i=()=>{nt()};return r("button",{type:"button",className:N("SearchBar",t.className),onClick:i,"aria-label":"Open search",children:[r(zt,{className:"SearchBar__icon",size:16,stroke:1.5}),r("span",{className:"SearchBar__placeholder",children:"Search"}),r("span",{className:"SearchBar__shortcut","aria-hidden":"true",children:e?"\u2318 + K":"Ctrl + K"})]})}var C="1.5";function p(t){return r("div",{className:"Layout",children:[r(p.Top,{}),r(p.Side,{}),r(p.Main,{...t,children:t.children}),r(p.Bottom,{})]})}function no(t){let o=t.split("?")[0].replace(/\/+$/g,"").split("/").filter(Boolean);return o.length===4&&o[0]==="cms"&&o[1]==="content"}p.Top=()=>{let t=window.__ROOT_CTX.rootConfig,e=t.projectName||t.projectId,o=t.minimalBranding,{url:i}=Y(),l=!no(i);return r("div",{className:"Layout__top",children:[o?r(V,{children:[r("a",{className:"Layout__top__logo",href:"/cms",children:e}),r("a",{className:"Layout__top__version",href:"https://github.com/blinkk/rootjs/blob/main/packages/root-cms/CHANGELOG.md",target:"_blank",rel:"noreferrer noopener",children:["v",tt.version]})]}):r(V,{children:[r("a",{className:"Layout__top__logo",href:"/cms",children:r(Ut,{})}),r("a",{className:"Layout__top__version",href:"https://github.com/blinkk/rootjs/blob/main/packages/root-cms/CHANGELOG.md",target:"_blank",rel:"noreferrer noopener",children:["v",tt.version]}),r("div",{className:"Layout__top__project",children:e})]}),l&&r("div",{className:"Layout__top__search",children:r(ge,{})})]})};p.Side=()=>{let{url:t}=Y(),e=t.replace(/\/*$/g,""),o=window.firebase.user,i=window.__ROOT_CTX.sidebar?.tools,l=new Set(window.__ROOT_CTX.sidebar?.hiddenBuiltInTools||[]),c=s=>l.has(s),m=window.__ROOT_CTX.experiments||{},_=async()=>{await window.firebase.auth.signOut(),window.location.href="/cms/login"};return r("div",{className:"Layout__side",children:[r("div",{className:"Layout__side__buttons",children:[!c("home")&&r(p.SideButton,{label:"Home",url:"/cms",active:e==="/cms",children:r(It,{stroke:C})}),!c("content")&&r(p.SideButton,{label:"Content",url:"/cms/content",active:e.startsWith("/cms/content"),children:r(Bt,{stroke:C})}),m.taskManager&&r(p.SideButton,{label:"Tasks",url:"/cms/tasks",active:e.startsWith("/cms/tasks"),children:r(At,{stroke:C})}),!c("releases")&&r(p.SideButton,{label:"Releases",url:"/cms/releases",active:e.startsWith("/cms/releases"),children:r(Rt,{stroke:C})}),!c("data")&&r(p.SideButton,{label:"Data",url:"/cms/data",active:e.startsWith("/cms/data"),children:r(Nt,{stroke:C})}),!c("assets")&&r(p.SideButton,{label:"Asset Library",url:"/cms/assets",active:e.startsWith("/cms/assets"),children:r(Dt,{stroke:C})}),!c("translations")&&r(p.SideButton,{label:"Translations",url:"/cms/translations",active:e.startsWith("/cms/translations"),children:r(Tt,{stroke:C})}),Vt()&&!c("ai")&&r(p.SideButton,{label:"Root AI",url:"/cms/ai",active:e.startsWith("/cms/ai"),children:r(Ht,{stroke:C})}),i&&r(V,{children:[r("div",{className:"Layout__side__divider"}),Object.entries(i).map(([s,a])=>{let d=a.cmsUrl?.startsWith("/cms/")?a.cmsUrl:void 0,g=a.externalUrl,u=g??d??`/cms/tools/${s}`,h=g?void 0:u.replace(/\/*$/g,""),b=!g&&!!h&&(e===h||e.startsWith(`${h}/`));return r(p.SideButton,{className:"Layout__side__tool",label:a.label||"",url:u,active:b,external:!!g,children:a.icon?r("img",{className:"Layout__side__tool__icon",src:a.icon,alt:a.label||""}):r(Pt,{stroke:C})},s)}),r("div",{className:"Layout__side__divider"})]}),!c("settings")&&r(p.SideButton,{label:"Settings",url:"/cms/settings",active:e.startsWith("/cms/settings"),children:r(Wt,{stroke:C})})]}),r("div",{className:"Layout__side__user",children:r(Z,{shadow:"md",position:"right",control:r(Q,{children:r(xt,{src:o.photoURL,alt:o.email,size:30,radius:"xl"})}),children:[r(Z.Label,{children:r(S,{size:"xs",color:"dimmed",truncate:!0,children:["Signed in as ",o.email]})}),r(Ct,{}),r(Z.Item,{color:"red",icon:r(Mt,{style:{width:14,height:14}}),onClick:_,children:"Sign out"})]})})]})};p.SideButton=t=>r(Et,{className:N("Layout__side__button",t.className),label:t.label,position:"right",withArrow:!0,children:r("a",{className:N(t.active&&"active"),href:t.url,target:t.external?"_blank":void 0,rel:t.external?"noreferrer noopener":void 0,children:t.children})});p.Main=t=>r("div",{className:"Layout__main",children:t.children});p.Bottom=()=>r("div",{className:"Layout__bottom"});export{nt as a,me as b,p as c};
@@ -1 +1 @@
1
- import{a as m}from"./chunk-VB5VMEN7.js";import{b as _}from"./chunk-RN4XVVWD.js";import{a as S,c as u}from"./chunk-ELKXEMOU.js";import{Ga as e,V as d,a as c,c as s,da as l,j as h}from"./chunk-ETPZ3TXX.js";h();var r="DataSourceSelectModal";function T(){let a=S(),t=u();return{open:i=>{a.openContextModal(r,{...t,innerProps:i,size:"600px",overflow:"inside"})},close:()=>{a.closeModal(r)}}}function N(a){let{innerProps:t}=a,[i,p]=c(!0),[n,D]=c([]),f=t.selectedDataSourceIds||[];s(()=>{async function o(){let g=await _();D(g.filter(x=>!x.archivedAt)),p(!1)}o()},[]);function M(o){t.onChange&&t.onChange(o,!0)}function v(o){t.onChange&&t.onChange(o,!1)}return e("div",{className:"DataSourceSelectModal",children:i?e("div",{className:"DataSourceSelectModal__loading",children:e(d,{color:"gray",size:"xl"})}):n.length===0?e("div",{className:"DataSourceSelectModal__empty",children:"No data sources."}):e("div",{className:"DataSourceSelectModal__list",children:n.map(o=>e("div",{className:"DataSourceSelectModal__item",children:[e(m,{className:"DataSourceSelectModal__item__icon",type:o.type}),e("div",{className:"DataSourceSelectModal__item__info",children:[e("div",{className:"DataSourceSelectModal__item__id",children:o.id}),o.description&&e("div",{className:"DataSourceSelectModal__item__description",children:o.description})]}),e("div",{className:"DataSourceSelectModal__item__action",children:f.includes(o.id)?e(l,{variant:"light",color:"blue",size:"xs",onClick:()=>v(o.id),children:"Unselect"}):e(l,{variant:"filled",color:"blue",size:"xs",onClick:()=>M(o.id),children:"Select"})})]},o.id))})})}N.id=r;export{T as a,N as b};
1
+ import{a as m}from"./chunk-F7RQT4XN.js";import{b as _}from"./chunk-Z2CRNO3I.js";import{a as S,c as u}from"./chunk-QRAFYIAW.js";import{Ga as e,V as d,a as c,c as s,da as l,j as h}from"./chunk-WRA24P66.js";h();var r="DataSourceSelectModal";function T(){let a=S(),t=u();return{open:i=>{a.openContextModal(r,{...t,innerProps:i,size:"600px",overflow:"inside"})},close:()=>{a.closeModal(r)}}}function N(a){let{innerProps:t}=a,[i,p]=c(!0),[n,D]=c([]),f=t.selectedDataSourceIds||[];s(()=>{async function o(){let g=await _();D(g.filter(x=>!x.archivedAt)),p(!1)}o()},[]);function M(o){t.onChange&&t.onChange(o,!0)}function v(o){t.onChange&&t.onChange(o,!1)}return e("div",{className:"DataSourceSelectModal",children:i?e("div",{className:"DataSourceSelectModal__loading",children:e(d,{color:"gray",size:"xl"})}):n.length===0?e("div",{className:"DataSourceSelectModal__empty",children:"No data sources."}):e("div",{className:"DataSourceSelectModal__list",children:n.map(o=>e("div",{className:"DataSourceSelectModal__item",children:[e(m,{className:"DataSourceSelectModal__item__icon",type:o.type}),e("div",{className:"DataSourceSelectModal__item__info",children:[e("div",{className:"DataSourceSelectModal__item__id",children:o.id}),o.description&&e("div",{className:"DataSourceSelectModal__item__description",children:o.description})]}),e("div",{className:"DataSourceSelectModal__item__action",children:f.includes(o.id)?e(l,{variant:"light",color:"blue",size:"xs",onClick:()=>v(o.id),children:"Unselect"}):e(l,{variant:"filled",color:"blue",size:"xs",onClick:()=>M(o.id),children:"Select"})})]},o.id))})})}N.id=r;export{T as a,N as b};
@@ -0,0 +1 @@
1
+ import{b as le}from"./chunk-HV3JJ5UT.js";import{a as oe}from"./chunk-VJRMR2JM.js";import{a as ee,b as A,c as T}from"./chunk-JDW4UORS.js";import{a as ie}from"./chunk-YDO2EDVY.js";import{a as M}from"./chunk-5MV6XVGA.js";import{b as te}from"./chunk-2PTLQRTU.js";import{a as U}from"./chunk-PIJ3E47R.js";import{a as j}from"./chunk-NCZD5IWS.js";import{P as re,c as ne}from"./chunk-ISUGBMXC.js";import{b as K,f as R,g as C,i as v,o as Y}from"./chunk-XOWWPE7X.js";import{d as Z,e as se}from"./chunk-WASID5UU.js";import{A as G,Ga as g,a as S,c as y,da as $,e as _,g as B,h as I,i as W,j as O,ra as Q,ua as q,za as J}from"./chunk-WRA24P66.js";import{j as X,k as Se}from"./chunk-KUCVLANF.js";function F(e){let t=window.__ROOT_CTX.collections[e.collectionId];if(!t)throw new Error(`collection not found: ${e.collectionId}`);if(!t.url)return"";let n=t.domain||window.__ROOT_CTX.rootConfig.domain||"https://example.com",r=Ee(e);return`${n}${r}`}function Ee(e){let o=window.__ROOT_CTX.collections,{collectionId:t,slug:n,locale:r}=e,i=o[t];if(!i)throw new Error(`collection not found: ${t}`);if(!i.url)return"";let l=window.__ROOT_CTX.rootConfig,m=l.base||"/",u="/[base]/[path]";r&&(u=l.i18n.urlFormat||"/[locale]/[base]/[path]");let f="",a=i?.url;if(a)if(n){let c=a.replace(/\[.*slug\]/,n).replaceAll("--","/").replace(/\/+/g,"/");c==="/index"&&(c="/"),f=c}else f=a;return ce(u,{base:m,path:f,locale:r||"",slug:n})}function be(e){let o=window.__ROOT_CTX.collections,{collectionId:t,slug:n,locale:r}=e,i=o[t];if(!i)throw new Error(`collection not found: ${t}`);let l=window.__ROOT_CTX.rootConfig,m=l.base||"/",u="/[base]/[path]";r&&(u=l.i18n.urlFormat||"/[locale]/[base]/[path]");let f="",a=i?.previewUrl||i?.url;if(a)if(n){let c=a.replace(/\[.*slug\]/,n).replaceAll("--","/").replace(/\/+/g,"/");c==="/index"&&(c="/"),f=c}else f=a;return ce(u,{base:m,path:f,locale:r||"",slug:n})}function ce(e,o){let t=e.replaceAll(/\[\[?(\.\.\.)?([\w\-_]*)\]?\]/g,(n,r,i)=>o[i]??n);return Ce(t,{trailingSlash:window.__ROOT_CTX.rootConfig.server.trailingSlash})}function Ce(e,o){return e=e.replace(/\/+/g,"/"),o?.trailingSlash===!1&&e!=="/"&&e.endsWith("/")&&(e=e.replace(/\/*$/g,"")),(e.endsWith("/index")||e.endsWith("/index/"))&&(e=e.slice(0,-6)),e.startsWith("/")||(e=`/${e}`),o?.trailingSlash&&!e.endsWith("/")&&(e=`${e}/`),e}O();function Ae(e,o){let[t,n]=S([]),[r,i]=S(!0),m=le().db,u=window.__ROOT_CTX.rootConfig.projectId||"default",f=o.includeArchived??!1,a=async()=>{i(!0);let c=K(m,"Projects",u,"Collections",e,"Drafts"),s=c,d=o.orderBy;if(d==="modifiedAt")s=C(c,v("sys.modifiedAt","desc"));else if(d==="modifiedAtAsc")s=C(c,v("sys.modifiedAt"));else if(d==="newest")s=C(c,v("sys.createdAt","desc"));else if(d==="oldest")s=C(c,v("sys.createdAt"));else if(d==="slug")s=C(c,v(R()));else if(d==="slugDesc")s=C(c,v(R(),"desc"));else if(d==="title"||d==="titleDesc"){let p=d==="titleDesc"?"desc":"asc",h=ve(e);s=h?C(c,v(h,p)):C(c,v(R(),p))}else{let h=window.__ROOT_CTX.collections[e]?.sortOptions?.find(w=>w.id===d);h&&(s=h.direction==="desc"?C(c,v(h.field,"desc")):C(c,v(h.field)))}await te(async()=>{let p=await Y(s),h=[];p.docs.forEach(w=>{let P=w.data(),E=w.id,b=`${e}/${E}`,x={...P,id:b,slug:E};ne(b,x),!(!f&&x?.sys?.archivedAt)&&h.push(x)}),n(h)}),i(!1)};return y(()=>{i(!0),a()},[e,o.orderBy,f]),[r,a,t]}function ve(e){let t=window.__ROOT_CTX.collections[e]?.preview?.title??"meta.title";return Array.isArray(t)&&(t=t[0]),typeof t!="string"||!t||t.includes("{")?"":`fields.${t}`}Se();O();var D={CONNECTED:"connected",SCHEMA_CHANGED:"schemaChanged"};function ae(e){let t=new URLSearchParams(window.location.search).get("e");return t?t.split(",").includes(e):!1}var we="/cms/api/sse.connect",L=ae("EnableVerboseLogging"),ue=window.location.hostname==="localhost",z=class{constructor(){this.map=new Map}on(o,t){return this.map.has(o)||this.map.set(o,new Set),this.map.get(o).add(t),()=>{this.map.get(o)?.delete(t)}}emit(o,t,n){this.map.get(o)?.forEach(r=>r(t,n)),this.map.get("*")?.forEach(r=>r({type:o,data:t},n))}},fe=X(null);function He(e){let t=_(new z).current,n=_(null),r=_(!1),i=_({attempt:0,timer:0}),l=_(""),m=()=>{n.current&&(n.current.close(),n.current=null)},u=I(()=>{L&&console.log("[sse] connecting..."),m();let a=new EventSource(we);n.current=a,a.addEventListener(D.CONNECTED,s=>{if(L&&console.log("[sse] connected"),r.current=!1,i.current.attempt=0,ue){let p=de(s.data)?.serverVersion||"";l.current?l.current!==p&&(console.log(`server version changed: ${l.current} -> ${p}`),console.log("reloading..."),window.location.reload()):l.current=p}});let c=s=>{if(!s||!s.type)return;let d=de(s.data);L&&console.log("[sse] event:",s.type,d),t.emit(s.type,d,s)};Object.values(D).forEach(s=>{a.addEventListener(s,c)}),a.addEventListener("error",()=>{L&&console.log("[sse] disconnected"),a.readyState===EventSource.CLOSED&&!r.current&&(r.current=!0,(()=>{let d=++i.current.attempt,p=Math.min(3e4,Math.pow(2,d)*500),h=Math.random()*.3*p,w=p+h;window.clearTimeout(i.current.timer),i.current.timer=window.setTimeout(()=>{r.current=!1,u()},w)})())})},[t]);y(()=>{if(!ue)return;u();let a=()=>{document.visibilityState==="visible"&&n.current?.readyState!==EventSource.OPEN&&u()};return document.addEventListener("visibilitychange",a),()=>{document.removeEventListener("visibilitychange",a),window.clearTimeout(i.current.timer),m()}},[u]);let f=B(()=>({emitter:t}),[t]);return g(fe.Provider,{value:f,children:e.children})}function de(e){try{return JSON.parse(e)}catch{return e}}function ge(e,o){let t=W(fe);if(!t)throw new Error("useSSE() must be used within an <SSEProvider>");let n=_(o);y(()=>{n.current=o},[o]),y(()=>t.emitter.on(e,(r,i)=>n.current(r,i)),[t,e])}O();O();function me(e){let[o,t]=S(!0),[n,r]=S(null),i=I(async()=>{try{let l=await ie(e);r(l)}catch(l){console.error(l),U({title:`Failed to load collection: ${e}`,message:String(l),color:"red",autoClose:!1})}t(!1)},[e]);return y(()=>{i()},[e]),ge(D.SCHEMA_CHANGED,async l=>{await i();let m=l.file?`Applied updates from changes to ${l.file}.`:"Applied updates from changes to a .schema.ts file.";U({title:"Updated schema!",message:m})}),{loading:o,schema:n}}function H(e){let o={_array:[]};return e.forEach(t=>{let n=_e();o._array.push(n),o[n]=t}),o}function _e(){let e=[],o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=o.length;for(let n=0;n<6;n++)e.push(o.charAt(Math.floor(Math.random()*t)));return e.join("")}function V(e){let o={};return e.fields.forEach(t=>{t.id&&(t.type==="array"&&t.default&&Array.isArray(t.default)?o[t.id]=H(t.default):t.default?o[t.id]=t.default:t.type==="object"&&(o[t.id]=V(t)))}),o}function k(e,o,t){let n={...o};return e.fields.forEach(r=>{if(!r.id)return;let i=n[r.id];if(i!=null){if(r.type==="array"&&Array.isArray(i)){let l=i.map(m=>ye(r.of,m,t));n[r.id]=H(l)}else if(r.type==="object"&&M(i))n[r.id]=k(r,i,t);else if(r.type==="oneof"&&M(i)&&typeof i._type=="string"&&t){let l=t[i._type];l&&(n[r.id]=k(l,i,t))}}}),n}function ye(e,o,t){if(!M(o))return o;if(e.type==="object")return k(e,o,t);if(e.type==="oneof"&&typeof o._type=="string"&&t){let n=t[o._type];if(n)return k(n,o,t)}return o}O();function pe(e){let[o,t]=S(e.collectionId||""),n=_(null),[r,i]=S(e.initialSlug||""),l=window.__ROOT_CTX.collections[o],m=[];e.collectionId&&e.collectionDisabled?m.push({value:e.collectionId,label:e.collectionId}):Object.keys(window.__ROOT_CTX.collections).forEach(s=>{m.push({value:s,label:s})});let u="",f="";if(l?.url){if(r){let s=T(r),d=l?.slugRegex;ee(s,d)?u=F({collectionId:o,slug:s}):f=A(s,d)}else u=F({collectionId:o,slug:"[slug]"});u.endsWith("/index")&&(u=u.replace(/\/index$/,"/"))}function a(s){t(s),e.onChange&&e.onChange({collectionId:s,slug:r})}function c(s){i(s),e.onChange&&e.onChange({collectionId:o,slug:s})}return g("div",{className:se(e.className,"SlugInput"),children:[g("div",{className:"SlugInput__inputs",children:[g(J,{className:"SlugInput__collection",placeholder:"Collection",size:"xs",data:m,onChange:s=>a(s),value:o,disabled:!!e.collectionDisabled}),g("div",{className:"SlugInput__divider",children:"/"}),g(q,{className:"SlugInput__slug",name:"slug",ref:n,value:r,onChange:s=>{c(s.currentTarget.value)},placeholder:"slug",autoComplete:"off",size:"xs"})]}),u&&g(j,{className:"SlugInput__urlHelp",size:"body-sm",children:u}),f&&g(j,{className:"SlugInput__slugError",size:"body-sm",children:f})]})}function xt(e){let{route:o}=Z(),t=G(),n=e.collection,r=window.__ROOT_CTX.collections[n];if(!r)throw new Error(`collection not found: ${n}`);let[i]=S(()=>r.autoSlug?oe(r.autoSlug):""),[l,m]=S(i),[u,f]=S(!1),[a,c]=S(()=>h(i)),[s,d]=S(""),p=me(n);function h(E){let b=T(E);return b?A(b,r.slugRegex):""}function w(){e.onClose&&e.onClose()}async function P(E){if(E.preventDefault(),f(!0),c(""),h(l)){f(!1);return}let x=T(l),he=`${n}/${x}`;try{let N={};!p.loading&&p.schema&&(N=await V(p.schema)),await re(he,{fields:N})}catch(N){d(String(N)),f(!1);return}f(!1),e.skipNavigation?w():o(`/cms/content/${e.collection}/${x}`)}return g(Q,{className:"NewDocModal",opened:e.opened||!1,onClose:()=>w(),title:"New",size:"500px",overlayColor:t.colorScheme==="dark"?t.colors.dark[9]:t.colors.gray[2],children:[g("div",{className:"NewDocModal__body",children:"Enter a slug for the new doc. The slug is the ID of the page and is what's used in the URL. Use only lowercase letters, numbers, and dashes."}),g("form",{onSubmit:E=>P(E),children:[g(pe,{className:"NewDocModal__slug",collectionId:n,initialSlug:i,onChange:E=>{m(E.slug),c(h(E.slug)),d("")}}),s&&g("div",{className:"NewDocModal__slugError",children:s}),g("div",{className:"NewDocModal__buttons",children:[g($,{variant:"outline",onClick:()=>w(),type:"button",size:"xs",color:"dark",children:"Cancel"}),g($,{variant:"filled",type:"submit",size:"xs",color:"dark",loading:p.loading||u,disabled:!!a||!!s,children:"Submit"})]})]})]})}export{F as a,Ee as b,be as c,pe as d,Ae as e,He as f,me as g,V as h,k as i,xt as j};
@@ -1 +1 @@
1
- import{Ga as o,Nc as c,Yc as r}from"./chunk-ETPZ3TXX.js";function m(e){let a=e.size??36,t=Math.round(a*.55),n=e.className?`DataSourceIcon ${e.className}`:"DataSourceIcon";return o("div",{className:n,style:{width:`${a}px`,height:`${a}px`},children:e.type==="gsheet"?o(c,{size:t,stroke:1.5}):o(r,{size:t,stroke:1.5})})}export{m as a};
1
+ import{$c as r,Ga as o,Qc as c}from"./chunk-WRA24P66.js";function m(e){let a=e.size??36,t=Math.round(a*.55),n=e.className?`DataSourceIcon ${e.className}`:"DataSourceIcon";return o("div",{className:n,style:{width:`${a}px`,height:`${a}px`},children:e.type==="gsheet"?o(c,{size:t,stroke:1.5}):o(r,{size:t,stroke:1.5})})}export{m as a};
@@ -0,0 +1 @@
1
+ import{c as F}from"./chunk-VJRMR2JM.js";import{b as _}from"./chunk-5MV6XVGA.js";import{a as U}from"./chunk-PLYSJ7W5.js";import{b as L}from"./chunk-2PTLQRTU.js";import{N as S,b as I}from"./chunk-ISUGBMXC.js";import{B as v,z as P}from"./chunk-XOWWPE7X.js";import{e as b}from"./chunk-WASID5UU.js";import{Fa as p,Ga as t,V as B,a as g,ba as c,c as h,e as A,i as T,j as R,la as N}from"./chunk-WRA24P66.js";import{d as y,j as k,k as O}from"./chunk-KUCVLANF.js";O();R();var $=k(null);function Z(e){let[i,n]=g([]),[o,r]=g(!1),a=A("idle");function u(){a.current==="idle"&&(a.current="fetching",r(!0),F().then(l=>{let d=l.filter(f=>!f.publishedAt&&!f.archivedAt);n(d)}).catch(l=>{console.error("Failed to fetch pending releases:",l)}).finally(()=>{a.current="done",r(!1)}))}function s(l){return i.filter(d=>d.docIds?.includes(l))}return t($.Provider,{value:{releases:i,getReleasesForDoc:s,loading:o,fetchReleases:u},children:e.children})}function z(){let e=T($);if(!e)throw new Error("usePendingReleases must be used within a <PendingReleasesProvider>");let{fetchReleases:i,...n}=e;return h(()=>{i()},[]),n}function m(e){let{message:i,detail:n,user:o}=e;return t(p,{label:t("div",{className:"UserActionTooltip",children:[o&&t(U,{email:o,size:20,withTooltip:!1}),t("div",{className:"UserActionTooltip__text",children:[t("span",{children:i}),n&&t("span",{className:"UserActionTooltip__detail",children:n}),o&&t("span",{children:["by ",o]})]})]}),position:e.position,transition:e.transition??"pop",withArrow:e.withArrow??!0,children:e.children})}function M(e){let i={transition:"pop"},n=e.doc,o=n.sys;return t("div",{className:"DocStatusBadges",children:[(!o.publishedAt||!o.modifiedAt||o.modifiedAt>o.publishedAt)&&t(m,{position:e.tooltipPosition,message:`Modified ${C(o.modifiedAt)}`,user:o.modifiedBy,children:t(c,{size:"xs",variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:"Draft"})}),!!o.publishedAt&&t(m,{position:e.tooltipPosition,message:`Published ${C(o.publishedAt)}`,user:o.publishedBy,children:t(c,{size:"xs",variant:"gradient",gradient:{from:"teal",to:"lime",deg:105},children:"Published"})}),!!o.scheduledAt&&t(m,{position:e.tooltipPosition,message:`Scheduled ${v(o.scheduledAt)}`,user:o.scheduledBy,children:t(c,{size:"xs",variant:"gradient",gradient:{from:"grape",to:"pink",deg:35},children:"Scheduled"})}),!e.hideReleases&&t(X,{docId:e.docId||n.id,tooltipProps:i}),S(n)&&t(m,{position:e.tooltipPosition,message:K(n),detail:n.sys?.publishingLocked?.reason,user:n.sys?.publishingLocked?.lockedBy,children:t(c,{size:"xs",variant:"gradient",gradient:{from:"orange",to:"red"},className:e.onPublishingLockClick?"DocStatusBadges__badge--clickable":void 0,style:e.onPublishingLockClick?{cursor:"pointer"}:void 0,role:e.onPublishingLockClick?"button":void 0,tabIndex:e.onPublishingLockClick?0:void 0,onClick:e.onPublishingLockClick,onKeyDown:e.onPublishingLockClick?r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),e.onPublishingLockClick())}:void 0,children:"Locked"})}),!!o.archivedAt&&t(m,{position:e.tooltipPosition,message:`Archived ${C(o.archivedAt)}`,user:o.archivedBy,children:t(c,{size:"xs",variant:"gradient",gradient:{from:"gray",to:"dark"},children:"Archived"})})]})}function K(e){let i=e.sys?.publishingLocked;return i?.until?`Locked until ${v(i.until)}`:"Locked"}function ve(e){let i=e.sys?.publishingLocked;return i?i.until?`Locked until ${v(i.until)} by ${i.lockedBy}: "${i.reason}"`:`Locked by ${i.lockedBy}: "${i.reason}"`:""}function X(e){let{getReleasesForDoc:i}=z(),n=i(e.docId);return n.length===0?null:t(y,{children:n.map(o=>t(p,{...e.tooltipProps,label:`In release: ${o.id}`,children:t(c,{component:"a",href:`/cms/releases/${o.id}`,size:"xs",variant:"gradient",gradient:{from:"violet",to:"grape"},style:{cursor:"pointer"},children:o.id})},o.id))})}function C(e){return e?P(e.toMillis()):P(new Date().getTime())}function E(e){let{file:i,width:n,height:o,withPlaceholder:r,className:a,alt:u}=e,s=typeof i=="string"?i:i?.src;return q(i)?t(G,{className:a,src:s,width:n,height:o}):t(N,{className:a,src:s,width:n,height:o,withPlaceholder:r,alt:u})}function q(e){if(!e)return!1;if(typeof e=="string")return/\.mp4($|\?)/i.test(e);if(typeof e.mimeType=="string")return e.mimeType.toLowerCase()==="video/mp4";let i=e.src;return typeof i!="string"?!1:/\.mp4($|\?)/i.test(i)}function G(e){return t("video",{className:e.className,src:e.src,width:e.width,height:e.height,muted:!0,playsInline:!0,preload:"metadata",style:{width:`${e.width}px`,height:`${e.height}px`,backgroundColor:"#f1f3f5",objectFit:"cover",display:"block"}})}R();function Se(e){let i=e.docId,[n,o]=g(e.doc),[r,a]=g(!e.doc);async function u(){a(!0),await L(async()=>{let V=await I(i);o(V)}),a(!1)}if(h(()=>{u()},[i]),r)return t("div",{className:b(e.className,"DocPreviewCard","DocPreviewCard--loading",e.variant&&`DocPreviewCard--${e.variant}`),children:t(B,{color:"gray",size:"sm"})});if(!n)return;let[s]=i.split("/"),l=n.fields||{},d=window.__ROOT_CTX.collections[s];if(!d)return console.error(`could not find collection: ${s}`),t("div",{className:"DocPreviewCard",children:["Collection ",t("b",{children:s})," not found."]});let f=_(l,d.preview?.title||"meta.title"),x=_(l,d.preview?.image||"meta.image")||d.preview?.defaultImage,D="div",w={};return e.clickable&&(D="a",w.href=`/cms/content/${e.docId}`,w.target="_blank"),t(D,{className:b(e.className,"DocPreviewCard",e.variant&&`DocPreviewCard--${e.variant}`),...w,children:[t("div",{className:"DocPreviewCard__image",children:t(E,{file:x,width:80,height:60,withPlaceholder:!x?.src})}),t("div",{className:"DocPreviewCard__content",children:[t("div",{className:"DocPreviewCard__content__header",children:t("div",{className:"DocPreviewCard__content__header__docId",children:n.id})}),t("div",{className:"DocPreviewCard__content__title",children:f||"[UNTITLED]"}),e.statusBadges&&n&&t("div",{className:"DocPreviewCard__content__badges",children:t(M,{doc:n,hideReleases:e.hideReleases})})]})]})}export{Z as a,z as b,m as c,M as d,ve as e,E as f,Se as g};
@@ -1 +1 @@
1
- import{c as x,n as y}from"./chunk-XOWWPE7X.js";import{a as d,c as g,j as R}from"./chunk-ETPZ3TXX.js";var v=3600*1e3,p=new Map,P=new Map,h=new Set;function A(e){return e.trim().toLowerCase()}function E(e){let r=p.get(e);if(r){if(Date.now()-r.fetchedAt>v){p.delete(e);return}return r}}function M(){h.forEach(e=>e())}function T(e){let r=window.firebase.db,s=window.__ROOT_CTX.rootConfig.projectId;return x(r,"Projects",s,"UserProfiles",e)}function a(e){if(!e)return null;let r=E(A(e));return r?r.value:void 0}async function U(e){if(!e)return null;let r=A(e),s=E(r);if(s)return s.value;let n=P.get(r);if(n)return n;let i=(async()=>{try{let t=await y(T(r)),l=t.exists()?t.data():null;return p.set(r,{value:l,fetchedAt:Date.now()}),M(),l}catch(t){return console.error("failed to fetch user profile:",e,t),p.set(r,{value:null,fetchedAt:Date.now()}),null}finally{P.delete(r)}})();return P.set(r,i),i}function b(e){return h.add(e),()=>{h.delete(e)}}function O(e,r){if(!(r||e||"").trim())return"?";if(r){let t=r.trim().split(/\s+/).map(l=>l.replace(/[^a-zA-Z0-9]/g,"")).filter(Boolean);if(t.length>=2)return(t[0][0]+t[1][0]).toUpperCase();if(t.length===1&&t[0].length>0)return t[0].slice(0,2).toUpperCase()}let i=(e.split("@")[0]||e).replace(/[^a-zA-Z0-9]/g,"");return i.length===0?"?":i.slice(0,2).toUpperCase()}function S(e){let r=e.trim();if(!r)return"?";let[s,n=""]=r.split("@"),t=(_(r)?n:s||r).replace(/[^a-zA-Z0-9]/g,"");return t.length===0?"?":t[0].toUpperCase()}function _(e){return e.trim().startsWith("*@")}function z(e){let r=["#1f6feb","#0e7490","#0f766e","#15803d","#9333ea","#c026d3","#db2777","#dc2626","#ea580c","#b45309"],s=0;for(let n=0;n<e.length;n++)s=s*31+e.charCodeAt(n)>>>0;return r[s%r.length]}R();function H(e){let r=e?a(e):null,[s,n]=d(r??null),[i,t]=d(!!e&&r===void 0);return g(()=>{if(!e){n(null),t(!1);return}let l=!1,o=a(e);o!==void 0?(n(o),t(!1)):(t(!0),U(e).then(f=>{l||(n(f),t(!1))}));let c=b(()=>{if(l||!e)return;let f=a(e);f!==void 0&&n(f)});return()=>{l=!0,c()}},[e]),{profile:s,loading:i}}function W(e){let r=e.filter(o=>!!o).map(o=>o.toLowerCase()),s=r.slice().sort().join(","),[n,i]=d(()=>{let o=new Map;return r.forEach(c=>{let f=a(c);f!==void 0&&o.set(c,f)}),o}),[t,l]=d(r.length>0);return g(()=>{if(r.length===0){i(new Map),l(!1);return}let o=!1;function c(){let u=new Map,w=!1;r.forEach(C=>{let m=a(C);m===void 0?w=!0:u.set(C,m)}),i(u),l(w)}c(),Promise.all(r.filter(u=>a(u)===void 0).map(u=>U(u))).then(()=>{o||c()});let f=b(()=>{o||c()});return()=>{o=!0,f()}},[s]),{profiles:n,loading:t}}export{O as a,S as b,_ as c,z as d,H as e,W as f};
1
+ import{c as x,n as y}from"./chunk-XOWWPE7X.js";import{a as d,c as g,j as R}from"./chunk-WRA24P66.js";var v=3600*1e3,p=new Map,P=new Map,h=new Set;function A(e){return e.trim().toLowerCase()}function E(e){let r=p.get(e);if(r){if(Date.now()-r.fetchedAt>v){p.delete(e);return}return r}}function M(){h.forEach(e=>e())}function T(e){let r=window.firebase.db,s=window.__ROOT_CTX.rootConfig.projectId;return x(r,"Projects",s,"UserProfiles",e)}function a(e){if(!e)return null;let r=E(A(e));return r?r.value:void 0}async function U(e){if(!e)return null;let r=A(e),s=E(r);if(s)return s.value;let n=P.get(r);if(n)return n;let i=(async()=>{try{let t=await y(T(r)),l=t.exists()?t.data():null;return p.set(r,{value:l,fetchedAt:Date.now()}),M(),l}catch(t){return console.error("failed to fetch user profile:",e,t),p.set(r,{value:null,fetchedAt:Date.now()}),null}finally{P.delete(r)}})();return P.set(r,i),i}function b(e){return h.add(e),()=>{h.delete(e)}}function O(e,r){if(!(r||e||"").trim())return"?";if(r){let t=r.trim().split(/\s+/).map(l=>l.replace(/[^a-zA-Z0-9]/g,"")).filter(Boolean);if(t.length>=2)return(t[0][0]+t[1][0]).toUpperCase();if(t.length===1&&t[0].length>0)return t[0].slice(0,2).toUpperCase()}let i=(e.split("@")[0]||e).replace(/[^a-zA-Z0-9]/g,"");return i.length===0?"?":i.slice(0,2).toUpperCase()}function S(e){let r=e.trim();if(!r)return"?";let[s,n=""]=r.split("@"),t=(_(r)?n:s||r).replace(/[^a-zA-Z0-9]/g,"");return t.length===0?"?":t[0].toUpperCase()}function _(e){return e.trim().startsWith("*@")}function z(e){let r=["#1f6feb","#0e7490","#0f766e","#15803d","#9333ea","#c026d3","#db2777","#dc2626","#ea580c","#b45309"],s=0;for(let n=0;n<e.length;n++)s=s*31+e.charCodeAt(n)>>>0;return r[s%r.length]}R();function H(e){let r=e?a(e):null,[s,n]=d(r??null),[i,t]=d(!!e&&r===void 0);return g(()=>{if(!e){n(null),t(!1);return}let l=!1,o=a(e);o!==void 0?(n(o),t(!1)):(t(!0),U(e).then(f=>{l||(n(f),t(!1))}));let c=b(()=>{if(l||!e)return;let f=a(e);f!==void 0&&n(f)});return()=>{l=!0,c()}},[e]),{profile:s,loading:i}}function W(e){let r=e.filter(o=>!!o).map(o=>o.toLowerCase()),s=r.slice().sort().join(","),[n,i]=d(()=>{let o=new Map;return r.forEach(c=>{let f=a(c);f!==void 0&&o.set(c,f)}),o}),[t,l]=d(r.length>0);return g(()=>{if(r.length===0){i(new Map),l(!1);return}let o=!1;function c(){let u=new Map,w=!1;r.forEach(C=>{let m=a(C);m===void 0?w=!0:u.set(C,m)}),i(u),l(w)}c(),Promise.all(r.filter(u=>a(u)===void 0).map(u=>U(u))).then(()=>{o||c()});let f=b(()=>{o||c()});return()=>{o=!0,f()}},[s]),{profiles:n,loading:t}}export{O as a,S as b,_ as c,z as d,H as e,W as f};
@@ -1 +1 @@
1
- import{i as t,j as i}from"./chunk-ETPZ3TXX.js";import{j as r,k as o}from"./chunk-KUCVLANF.js";o();i();var s=r(null);function n(){let e=t(s);if(!e)throw new Error("useFirebase() should be called within a <FirebaseProvider>");return e}export{s as a,n as b};
1
+ import{i as t,j as i}from"./chunk-WRA24P66.js";import{j as r,k as o}from"./chunk-KUCVLANF.js";o();i();var s=r(null);function n(){let e=t(s);if(!e)throw new Error("useFirebase() should be called within a <FirebaseProvider>");return e}export{s as a,n as b};
@@ -1 +1 @@
1
- import{e as n}from"./chunk-WS37MDM3.js";import{Ga as t}from"./chunk-ETPZ3TXX.js";function f(a){let{className:r,as:h,size:e,weight:o,color:i,children:g,...s}=a;return t(h||"h2",{...s,className:n(r,"heading",e&&`size:${e}`,o&&`weight:${o}`,i&&`color:${i}`),children:g})}export{f as a};
1
+ import{e as n}from"./chunk-WASID5UU.js";import{Ga as t}from"./chunk-WRA24P66.js";function f(a){let{className:r,as:h,size:e,weight:o,color:i,children:g,...s}=a;return t(h||"h2",{...s,className:n(r,"heading",e&&`size:${e}`,o&&`weight:${o}`,i&&`color:${i}`),children:g})}export{f as a};
@@ -0,0 +1 @@
1
+ import{a as se,g as oe,h as X,i as ne,j as ie,m as re}from"./chunk-DZYYWCHX.js";import{D as p,a as k,b as F,c as l,f as Y,g as x,h as D,i as O,j as M,l as Z,n as B,o as j,p as v,q as w,r as ee,t as N,u as R,v as m,w as te,x as T}from"./chunk-XOWWPE7X.js";import{k as U}from"./chunk-7SK47HHZ.js";function ce(e){return typeof e=="object"&&!Array.isArray(e)&&e!==null}function ae(e){return ce(e)&&Array.isArray(e.blocks)&&e.blocks.length>0}var q=new Map,E=new Map;function De(e){return q.get(e)||null}async function Je(e){let t=De(e);if(t)return t;let s=E.get(e);if(s)return s;let n=(async()=>{let o=b(e),r=(await B(o)).data();return Ce(e,r),r})().finally(()=>{E.delete(e)});return E.set(e,n),n}function Ce(e,t){q.set(e,t)}function G(e){q.delete(e),E.delete(e)}function L(e){for(let t of e)G(t)}function le(e){e||(e=6);let t=[],s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=s.length;for(let o=0;o<e;o++)t.push(s.charAt(Math.floor(Math.random()*n)));return t.join("")}var P=class extends Error{},de=200,Te=/[/\\\u0000-\u001f]/;function C(){let e=window.__ROOT_CTX.rootConfig.projectId,t=window.firebase.db;return F(t,"Projects",e,"Assets")}var Be="root-cms:assetPicker:lastFolder";function me(){let e=window.__ROOT_CTX.rootConfig.projectId;return`${Be}:${e}`}function ct(){try{return localStorage.getItem(me())||""}catch{return""}}function at(e){try{localStorage.setItem(me(),e||"")}catch{}}function Q(e){let t=(e||"").trim();if(!t)throw new P("Name is required.");if(t.length>de)throw new P(`Name is too long (max ${de} chars).`);if(Te.test(t))throw new P("Name cannot contain slashes.");if(t==="."||t==="..")throw new P("Invalid name.");return t}function _(e,t){return e?`${e}/${t}`:t}function lt(e){return e?e.split("/").filter(Boolean):[]}function V(e){return`folder-${encodeURIComponent(e)}`}function pe(e){return e.sort((t,s)=>t.type!==s.type?t.type==="folder"?-1:1:(t.name||"").localeCompare(s.name||"",void 0,{numeric:!0,sensitivity:"base"}))}function ge(e){return!!e&&typeof e.name=="string"&&(e.type==="file"||e.type==="folder")}async function je(e){let t=C(),s=x(t,D("parent","==",e||"")),n=await j(s),o=[];return n.forEach(i=>{let r=i.data();ge(r)&&o.push(r)}),pe(o)}var fe=1e3;async function dt(e){let t=C(),s;e?s=x(t,D("parent",">=",e),D("parent","<=",`${e}\uF8FF`),M(fe)):s=x(t,M(fe));let n=await j(s),o=[];return n.forEach(i=>{let r=i.data();ge(r)&&(!e||K(r.parent,e))&&o.push(r)}),pe(o)}function ft(e,t){return t?e===t?"":e.startsWith(`${t}/`)?e.slice(t.length+1):e:e}async function I(e){let t=l(C(),e),s=await B(t);return s.exists()?s.data():null}async function ut(e,t){let s=Q(t),n=_(e,s),o=V(n),i=l(C(),o),r={id:o,type:"folder",parent:e||"",name:s,createdAt:m(),createdBy:window.firebase.user.email,modifiedAt:m(),modifiedBy:window.firebase.user.email};return await v(i,r,{merge:!0}),p("asset.folder_create",{metadata:{folder:n}}),await I(o)}async function mt(e){let t=J(e.file),s=Q(e.name||t.filename||Pe(t.src)),n=le(12),o=l(C(),n);return await v(o,{id:n,type:"file",parent:e.parent||"",name:s,file:t,createdAt:m(),createdBy:window.firebase.user.email,modifiedAt:m(),modifiedBy:window.firebase.user.email}),p("asset.upload",{metadata:{assetId:n,name:s}}),await I(n)}async function pt(e,t){let s=Q(t);if(s===e.name)return;if(e.type==="folder"){let o=_(e.parent,e.name),i=_(e.parent,s);await ye(e,i,s,e.parent),p("asset.rename",{metadata:{from:o,to:i}});return}let n=l(C(),e.id);await w(n,{name:s,modifiedAt:m(),modifiedBy:window.firebase.user.email}),p("asset.rename",{metadata:{assetId:e.id,from:e.name,to:s}})}async function gt(e,t){let s=t||"";if(s===e.parent)return;if(e.type==="folder"){let o=_(e.parent,e.name),i=_(s,e.name);if(i===o||K(i,o))throw new Error("Cannot move a folder into itself.");await ye(e,i,e.name,s),p("asset.move",{metadata:{from:o,to:i}});return}let n=l(C(),e.id);await w(n,{parent:s,modifiedAt:m(),modifiedBy:window.firebase.user.email}),p("asset.move",{metadata:{assetId:e.id,from:e.parent,to:s}})}function K(e,t){return e===t||e.startsWith(`${t}/`)}async function ye(e,t,s,n){let o=_(e.parent,e.name),i=C(),r=window.firebase.db,c=x(i,D("parent",">=",o),D("parent","<=",`${o}\uF8FF`)),a=await j(c),f=[];a.forEach(h=>{let A=h.data();K(A.parent,o)&&f.push(A)});let d=T(r),g=0,y=async()=>{g+=1,g>=400&&(await d.commit(),d=T(r),g=0)},u=V(t);d.set(l(i,u),{id:u,type:"folder",parent:n,name:s,createdAt:e.createdAt??m(),createdBy:e.createdBy??window.firebase.user.email,modifiedAt:m(),modifiedBy:window.firebase.user.email}),await y();for(let h of f){let A=t+h.parent.slice(o.length);if(h.type==="folder"){let S=_(A,h.name);d.set(l(i,V(S)),{...h,id:V(S),parent:A,modifiedAt:m(),modifiedBy:window.firebase.user.email}),await y(),d.delete(l(i,h.id)),await y()}else d.update(l(i,h.id),{parent:A,modifiedAt:m(),modifiedBy:window.firebase.user.email}),await y()}u!==e.id&&(d.delete(l(i,e.id)),g+=1),g>0&&await d.commit()}async function yt(e){if(e.type==="folder"){let t=_(e.parent,e.name);if((await je(t)).length>0)throw new Error("Folder is not empty.")}await ee(l(C(),e.id)),p("asset.delete",{metadata:{assetId:e.id,name:e.name}})}async function ht(e,t){let s=J(t);!s.alt&&e.file?.alt&&(s.alt=e.file.alt),e.file?.altDisabled&&(s.altDisabled=!0);let n=l(C(),e.id),o={file:s,modifiedAt:m(),modifiedBy:window.firebase.user.email},i=U(s.filename||s.src||""),r=_e(e.name,i);return r!==e.name&&(o.name=r),await w(n,o),p("asset.replace",{metadata:{assetId:e.id,name:e.name}}),await I(e.id)}function _e(e,t){let s=(e||"").lastIndexOf(".");return!t||s<=0||U(e)===t?e:`${e.slice(0,s)}.${t}`}async function wt(e,t){let s=l(C(),e.id);return await w(s,{"file.alt":t||"",modifiedAt:m(),modifiedBy:window.firebase.user.email}),await I(e.id)}async function bt(e,t){let s=l(C(),e.id);return await w(s,{"file.altDisabled":t?!0:R(),modifiedAt:m(),modifiedBy:window.firebase.user.email}),p("asset.alt_disabled",{metadata:{assetId:e.id,name:e.name,disabled:t}}),await I(e.id)}function ke(e){let t={...J(e.file),assetId:e.id};return t.altDisabled&&(t.alt=""),t}function z(e){let t=new Set;return H(e,t),Array.from(t).sort()}function H(e,t){if(!(!e||typeof e!="object")){if(Array.isArray(e)){for(let s of e)H(s,t);return}if(typeof e.toMillis!="function"){if(W(e)){t.add(e.assetId);return}for(let s of Object.keys(e))H(e[s],t)}}}function W(e){return typeof e?.assetId=="string"&&typeof e?.src=="string"}function ue(e){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let t of e)if(ue(t))return!0;return!1}if(typeof e.toMillis=="function")return!1;if(W(e))return!0;for(let t of Object.keys(e))if(ue(e[t]))return!0;return!1}async function Fe(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,n=Object.keys(window.__ROOT_CTX.collections||{});return(await Promise.all(n.map(async r=>{let c=F(s,"Projects",t,"Collections",r,"Drafts"),a=x(c,D("sys.assets","array-contains",e)),f=await j(a),d=[];return f.forEach(g=>{d.push(g.data())}),d}))).flat().sort((r,c)=>r.id.localeCompare(c.id))}async function At(e,t={}){let s=window.__ROOT_CTX.rootConfig.projectId,n=window.firebase.db,o=t.docs??await Fe(e.id),i=[],r=[];for(let c of o){let a=[];if(he(c.fields,e.id,"fields",a),a.length===0)continue;let f={};for(let u of a)f[u.path]=Me(e,u.value,t.previousFile);f["sys.modifiedAt"]=m(),f["sys.modifiedBy"]=window.firebase.user.email;let[d,g]=c.id.split("/"),y=l(n,"Projects",s,"Collections",d,"Drafts",g);try{await w(y,f),i.push(c.id)}catch(u){console.error(`failed to sync asset ${e.id} to ${c.id}:`,u),r.push(c.id)}}return i.length>0&&(L(i),p("asset.sync",{metadata:{assetId:e.id,name:e.name,docIds:i}})),{updatedDocIds:i,failedDocIds:r}}function he(e,t,s,n){if(!(!e||typeof e!="object")&&!Array.isArray(e)&&typeof e.toMillis!="function"){if(W(e)){e.assetId===t&&n.push({path:s,value:e});return}for(let o of Object.keys(e))he(e[o],t,`${s}.${o}`,n)}}function Me(e,t,s){let n=ke(e);if(!e.file?.altDisabled){let i=s?.alt??e.file?.alt??"",r=t?.alt||"";r&&r!==i&&(n.alt=r)}let o=s?.canvasBgColor??e.file?.canvasBgColor;return t?.canvasBgColor&&t.canvasBgColor!==o&&(n.canvasBgColor=t.canvasBgColor),n}function J(e){let t={};return Object.entries(e||{}).forEach(([s,n])=>{n!==void 0&&(t[s]=n)}),t}function Pe(e){return(e||"").split("?")[0].split("/").pop()||"untitled"}async function Pt(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,[n,o]=e.split("/"),i=l(s,"Projects",t,"Collections",n,"Drafts",o),r=l(s,"Projects",t,"Collections",n,"Published",o),c=l(s,"Projects",t,"Collections",n,"Scheduled",o),a=T(s);a.delete(i),a.delete(r),a.delete(c),await a.commit(),console.log(`deleted doc: ${e}`),p("doc.delete",{metadata:{docId:e}})}async function vt(e,t){await ve([e],t)}async function ve(e,t){if(e.length===0){console.log("no docs to publish");return}let s=window.firebase.db;if(e.length>100)throw new Error("publish docs exceeds limit of 100 docs. break up your request into multiple calls.");let n=await $e(e),o=t?.batch||T(s),i=["published"];t?.releaseId&&i.push(`release:${t.releaseId}`),e.forEach(r=>{let c=n[r];if(!c)throw new Error(`doc does not exist: ${r}`);Ie(o,r,c,i,t?.publishMessage)}),await o.commit(),e.length===1?console.log(`published ${e[0]}`):console.log(`published ${e.length} docs: ${e.join(", ")}`);for(let r of e){let c={docId:r};t?.publishMessage&&(c.publishMessage=t.publishMessage),p("doc.publish",{metadata:c})}L(e)}function Ie(e,t,s,n,o){if(Oe(s))throw new Error(`publishing is locked for doc: ${s.id}`);if(Se(s))throw new Error(`cannot publish archived doc: ${s.id}`);let i=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,[c,a]=t.split("/"),f=l(r,"Projects",i,"Collections",c,"Drafts",a),d=l(r,"Projects",i,"Collections",c,"Scheduled",a),g=l(r,"Projects",i,"Collections",c,"Published",a),y={...s},u=y.sys??{};u.modifiedAt=m(),u.modifiedBy=window.firebase.user.email,u.publishedAt=m(),u.publishedBy=window.firebase.user.email,u.firstPublishedAt??=m(),u.firstPublishedBy??=window.firebase.user.email,delete u.scheduledAt,delete u.scheduledBy,e.update(f,{sys:u}),e.set(g,{...y,sys:u}),e.delete(d);let h=l(r,"Projects",i,"Collections",c,"Drafts",a,"Versions",String(Date.now())),A={id:t,collection:c,slug:a,fields:y.fields||{},sys:u};n?.length&&(A.tags=n),o&&(A.publishMessage=o),e.set(h,A)}async function It(e,t,s){let n=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,[i,r]=e.split("/"),c=l(o,"Projects",n,"Collections",i,"Drafts",r),a=l(o,"Projects",n,"Collections",i,"Scheduled",r);await N(o,async d=>{let g=await d.get(c);if(!g.exists())throw new Error(`${c.id} does not exist`);let y={...g.data()},u=y.sys??{};u.modifiedAt=m(),u.modifiedBy=window.firebase.user.email,u.scheduledAt=k.fromMillis(t),u.scheduledBy=window.firebase.user.email,d.update(c,{sys:u});let h={...y,sys:u};s?.publishMessage&&(h.scheduledPublishMessage=s.publishMessage),d.set(a,h)}),console.log(`saved ${a.id}`);let f={docId:e,scheduledAt:t};s?.publishMessage&&(f.publishMessage=s.publishMessage),p("doc.schedule",{metadata:f})}async function St(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,[n,o]=e.split("/"),i=l(s,"Projects",t,"Collections",n,"Drafts",o),r=l(s,"Projects",t,"Collections",n,"Scheduled",o),c=l(s,"Projects",t,"Collections",n,"Published",o),a=T(s);a.update(i,{"sys.modifiedAt":m(),"sys.modifiedBy":window.firebase.user.email,"sys.publishedAt":R(),"sys.publishedBy":R(),"sys.firstPublishedAt":R(),"sys.firstPublishedBy":R()}),a.delete(r),a.delete(c),await a.commit(),console.log(`unpublished ${e}`),p("doc.unpublish",{metadata:{docId:e}}),G(e)}async function Ot(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,[n,o]=e.split("/"),i=l(s,"Projects",t,"Collections",n,"Drafts",o),r=l(s,"Projects",t,"Collections",n,"Published",o);await N(s,async c=>{let a=await c.get(r);if(!a.exists())throw new Error(`${r.id} does not exist`);let f=a.data();c.set(i,f)}),console.log(`reverted draft ${e}`),p("doc.revert",{metadata:{docId:e}})}async function Et(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,[n,o]=e.split("/"),i=l(s,"Projects",t,"Collections",n,"Drafts",o),r=l(s,"Projects",t,"Collections",n,"Scheduled",o),c=T(s);c.update(i,{"sys.modifiedAt":m(),"sys.modifiedBy":window.firebase.user.email,"sys.scheduledAt":R(),"sys.scheduledBy":R()}),c.delete(r),await c.commit(),console.log(`unscheduled ${e}`),p("doc.unschedule",{metadata:{docId:e}})}async function Lt(e,t){let s={lockedAt:m(),lockedBy:window.firebase.user.email,reason:t.reason||`Locked by ${window.firebase.user.email}.`};t.until&&(s.until=k.fromMillis(t.until));let n=b(e);await w(n,{"sys.publishingLocked":s});let i={docId:e,reason:t.reason};t.until&&(i.until=t.until),p("doc.lock_publishing",{metadata:i})}async function Vt(e){let t=b(e),s={"sys.publishingLocked":R()};await w(t,s),p("doc.unlock_publishing",{metadata:{docId:e}})}async function $t(e){let t=b(e);await w(t,{"sys.archivedAt":m(),"sys.archivedBy":window.firebase.user.email}),p("doc.archive",{metadata:{docId:e}})}async function Nt(e){let t=b(e);await w(t,{"sys.archivedAt":R(),"sys.archivedBy":R()}),p("doc.unarchive",{metadata:{docId:e}})}function Se(e){return!!e?.sys?.archivedAt}function Ut(e){let t=k.now().toMillis();return(e?.sys?.scheduledAt?.toMillis()||0)>t}function Oe(e){if(e?.sys?.publishingLocked){if(e.sys.publishingLocked.until){let t=k.now().toMillis(),s=e.sys.publishingLocked.until.toMillis();return t<s}return!0}return!1}async function Xt(e,t,s){let n=b(e),o=await B(n);if(!o.exists())throw new Error(`doc ${e} does not exist`);let i=o.data(),r=i.fields??{},c=i.sys?.locales;await Ee(t,{fields:r,locales:c,overwrite:s?.overwrite})}async function Ee(e,t){let[s,n]=e.split("/"),o=b(e),i=await B(o);if(i.exists()&&!t?.overwrite)throw new Error(`${e} already exists`);let r=t?.fields??{},c={id:e,collection:s,slug:n,sys:{createdAt:m(),createdBy:window.firebase.user.email,modifiedAt:m(),modifiedBy:window.firebase.user.email,locales:t?.locales??["en"]},fields:r};if(i.exists()&&t?.overwrite){let f=i.data();c.sys={...f.sys,locales:t?.locales??f.sys.locales,modifiedAt:m(),modifiedBy:window.firebase.user.email}}let a=z(r);a.length>0?c.sys.assets=a:delete c.sys.assets,await v(o,c),p("doc.create",{metadata:{docId:e}})}async function qt(e,t,s){let n={};for(let d of t){if(!d.source)continue;let g={source:X(d.source)},y={},u={};Object.entries(d).forEach(([A,S])=>{if(A==="source")return;let xe=ie(A);for(let $ of re(A)){if(ne($))continue;let Re=$===xe?u:y;Re[$]=X(S||"")}}),Object.assign(g,y,u);let h=await oe(g.source);n[h]=g}let i=[e.split("/")[0],e];s?.tags&&i.push(...s.tags);let r=se(),c=window.firebase.db,a=T(c),f=0;for(let d in n){let g=n[d],y=l(r,d);a.set(y,{...g,tags:te(...i)},{merge:!0}),f+=1,f>=500&&(await a.commit(),a=T(c),console.log(`saved ${f} strings`),f=0)}return f>0&&(await a.commit(),console.log(`saved ${f} strings`)),p("doc.import_translations",{metadata:{docId:e,...s?.actionMetadata},links:s?.actionLinks}),n}function b(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,[n,o]=e.split("/");return l(s,"Projects",t,"Collections",n,"Drafts",o)}function Le(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,[n,o]=e.split("/");return l(s,"Projects",t,"Collections",n,"Published",o)}function Ve(e,t){let s=window.__ROOT_CTX.rootConfig.projectId,n=window.firebase.db,[o,i]=e.split("/");return l(n,"Projects",s,"Collections",o,"Drafts",i,"Versions",t)}async function $e(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,n={};e.forEach(i=>{let[r,c]=i.split("/");r in n?n[r].push(c):n[r]=[c]});let o={};return await Promise.all(Object.entries(n).map(async([i,r])=>{let c=F(s,"Projects",t,"Collections",i,"Drafts"),a=x(c,D(Y(),"in",r));(await j(a)).forEach(d=>{let g=`${i}/${d.id}`;o[g]=d.data()})})),o}async function Gt(e,t){let s=window.firebase.db,n=b(e),o=F(s,n.path,"Versions"),i=t?.limit??50,r=x(o,O("sys.modifiedAt","desc"),M(i));t?.tags&&(r=x(r,D("tags","array-contains-any",t.tags))),t?.cursor&&(r=x(r,Z(t.cursor)));let c=await j(r),a=[],f=null;return c.forEach(d=>{let g={...d.data(),_versionId:d.id};a.push(g),f=d}),{versions:a,lastDoc:f,hasMore:c.size===i}}async function Ht(e,t){let s=b(e),n={"sys.modifiedAt":m(),"sys.modifiedBy":window.firebase.user.email,"sys.assets":z(t.fields||{}),fields:t.fields||{}};await w(s,n),p("doc.restore_version",{metadata:{docId:e,versionModifiedAt:t.sys?.modifiedAt,versionModifiedBy:t.sys?.modifiedBy}})}var Ne=/^(before|after):(\d+)$/,Ue=10*1e3;async function Xe(e,t){let s=String(t).match(Ne);if(s)return await qe(e,s[1],parseInt(s[2]));let n;t==="draft"?n=b(e):t==="published"?n=Le(e):n=Ve(e,t);let o=await B(n);return o.exists()?o.data():null}async function qe(e,t,s){let n=window.firebase.db,o=b(e),i=F(n,o.path,"Versions"),r=k.fromMillis(s-Ue),c;t==="before"?c=x(i,D("sys.modifiedAt","<",r),O("sys.modifiedAt","desc"),M(1)):c=x(i,D("sys.modifiedAt",">=",r),O("sys.modifiedAt","asc"),M(1));let a=await j(c);return a.empty?t==="after"?await Xe(e,"draft"):null:a.docs[0].data()}async function Qt(e,t){if(!t?.spreadsheetId)throw new Error("no spreadsheet id");let s=b(e),n={"sys.l10nSheet":{spreadsheetId:t.spreadsheetId,gid:t.gid||0,linkedAt:m(),linkedBy:window.firebase.user.email}};await w(s,n),p("doc.link_sheet",{metadata:{docId:e,sheetId:t}})}async function Kt(e){let t=b(e),s={"sys.l10nSheet":R()};await w(t,s),p("doc.unlink_sheet",{metadata:{docId:e}})}async function zt(e){let t=b(e),o=(await B(t)).data()?.sys?.l10nSheet||{};return o?.spreadsheetId?{spreadsheetId:o.spreadsheetId,gid:o.gid||0}:null}function we(e,t){let s={};for(let n in e){let o=e[n];if(Ae(o))if(o.toMillis)s[n]=o.toMillis();else if(Object.hasOwn(o,"_array")&&Array.isArray(o._array)){let i=o._array.map(r=>{let c={...we(o[r]||{},t),_arrayKey:r};return t?.removeArrayKey&&delete c._arrayKey,c});s[n]=i}else s[n]=we(o,t);else s[n]=o}return s}async function Wt(e,t){let s=await window.fetch("/cms/api/ai.diff",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({docId:e,beforeVersion:t?.beforeVersion||"published",afterVersion:t?.afterVersion||"draft"})}),n=await s.text(),o=null;try{o=JSON.parse(n)}catch{}if(!s.ok||o?.success===!1){let i=o&&(o.error||o.message)||n;throw new Error(i||"Failed to fetch AI summary")}return typeof o?.summary=="string"?o.summary:typeof o?.data?.summary=="string"?o.data.summary:!o&&n?n:""}function Ae(e){return typeof e=="object"&&!Array.isArray(e)&&e!==null}function Jt(e){let[t,s]=e.split("/");return{id:e,collection:t,slug:s}}function be(e){if(Ge(e))return k.fromMillis(e.seconds*1e3);if(ae(e))return e.time=Date.now(),e;if(Array.isArray(e))return e.map(t=>be(t));if(Ae(e)){let t={};return Object.keys(e).forEach(s=>{t[s]=be(e[s])}),t}return e}function Ge(e){return e?.type==="firestore/timestamp/1.0"}export{ae as a,Je as b,Ce as c,le as d,ct as e,at as f,_ as g,lt as h,je as i,dt as j,ft as k,I as l,ut as m,mt as n,pt as o,gt as p,yt as q,ht as r,_e as s,wt as t,bt as u,ke as v,z as w,ue as x,Fe as y,At as z,Pt as A,vt as B,ve as C,It as D,St as E,Ot as F,Et as G,Lt as H,Vt as I,$t as J,Nt as K,Se as L,Ut as M,Oe as N,Xt as O,Ee as P,qt as Q,$e as R,Gt as S,Ht as T,Xe as U,Qt as V,Kt as W,zt as X,we as Y,Wt as Z,Jt as _,be as $};