@blinkk/root-cms 3.0.5 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/README.md +77 -0
  2. package/dist/app.js +7 -4
  3. package/dist/browser-client/browser-client.d.ts +148 -0
  4. package/dist/browser-client/embed-window.d.ts +66 -0
  5. package/dist/browser-client/emitter.d.ts +11 -0
  6. package/dist/browser-client.js +377 -0
  7. package/dist/{chunk-RXWDB3K4.js → chunk-4VZTYUQ7.js} +1 -1
  8. package/dist/{chunk-N4K6ICFR.js → chunk-AFBSITEO.js} +4 -6
  9. package/dist/{chunk-PNLLZXVY.js → chunk-AJDMNTZQ.js} +2 -2
  10. package/dist/{chunk-VSPPZPMP.js → chunk-GXV4UQ6Z.js} +15 -11
  11. package/dist/chunk-J72JK4KR.js +8 -0
  12. package/dist/cli.js +2 -1
  13. package/dist/client.js +2 -1
  14. package/dist/core/client.d.ts +5 -0
  15. package/dist/core/plugin.d.ts +17 -0
  16. package/dist/core.js +4 -2
  17. package/dist/functions.js +4 -3
  18. package/dist/plugin.js +16 -4
  19. package/dist/shared/embed-protocol.d.ts +72 -0
  20. package/dist/ui/AIPage-EL6DQYII.js +1 -0
  21. package/dist/ui/AssetsPage-5S6PNMF6.js +1 -0
  22. package/dist/ui/CollectionPage-CU3VDEXA.js +1 -0
  23. package/dist/ui/ComparePage-FTZLYO2O.js +1 -0
  24. package/dist/ui/DataPage-XIXFKXDN.js +1 -0
  25. package/dist/ui/DataSourcePage-ORIEQH3Y.js +1 -0
  26. package/dist/ui/DocTranslationsPage-4OVBIPSG.js +1 -0
  27. package/dist/ui/DocumentPage-3JPFJF3E.js +1 -0
  28. package/dist/ui/EditDataSourcePage-HIGZZQJC.js +1 -0
  29. package/dist/ui/EditReleasePage-KUHBU2HQ.js +1 -0
  30. package/dist/ui/EmbeddedAIPage-CJWZE5FC.js +1 -0
  31. package/dist/ui/EmbeddedDocumentPage-6XQHYIAO.js +1 -0
  32. package/dist/ui/{ImageEditorDialog-4H665KK2.js → ImageEditorDialog-GGS4VFEA.js} +2 -2
  33. package/dist/ui/LogsPage-4DVGYXZY.js +1 -0
  34. package/dist/ui/NewDataSourcePage-7TUUE6ZL.js +1 -0
  35. package/dist/ui/NewReleasePage-6UT36HDW.js +1 -0
  36. package/dist/ui/NotFoundPage-AW6UC6II.js +1 -0
  37. package/dist/ui/ProjectPage-US5FJGFK.js +1 -0
  38. package/dist/ui/ReleasePage-W2R3DIFX.js +1 -0
  39. package/dist/ui/ReleasesPage-HBBUGE7D.js +1 -0
  40. package/dist/ui/SettingsPage-7JQQILUV.js +1 -0
  41. package/dist/ui/SidebarToolsPage-MIYXKHF2.js +1 -0
  42. package/dist/ui/TaskPage-JYUQEGRB.js +1 -0
  43. package/dist/ui/TasksPage-4VFQF243.js +1 -0
  44. package/dist/ui/TranslationsArbPage-AJLM5VSD.js +2 -0
  45. package/dist/ui/TranslationsEditPage-RTTGTIGI.js +1 -0
  46. package/dist/ui/{TranslationsPage-WIDVSTYF.js → TranslationsPage-HPYAJQ4Q.js} +31 -31
  47. package/dist/ui/{ai-tools-5E5ELLZX.js → ai-tools-4DWMFQS6.js} +1 -1
  48. package/dist/ui/{chunk-JYFLU7DM.js → chunk-2KSMCQ6H.js} +2 -2
  49. package/dist/ui/{chunk-HKINZLMW.js → chunk-344GZOGG.js} +45 -45
  50. package/dist/ui/{chunk-CGCKJFL4.js → chunk-3E6CASIN.js} +1 -1
  51. package/dist/ui/chunk-3T4ZWQR4.js +7 -0
  52. package/dist/ui/chunk-4ISFTE2G.js +5 -0
  53. package/dist/ui/chunk-5AVRMJVW.js +1 -0
  54. package/dist/ui/chunk-764W6634.js +1 -0
  55. package/dist/ui/chunk-76ZGLKLT.js +1 -0
  56. package/dist/ui/{chunk-SKEP5WYH.js → chunk-7SK47HHZ.js} +3 -3
  57. package/dist/ui/chunk-AZCGXQTL.js +1 -0
  58. package/dist/ui/{chunk-W3BJ2EZX.js → chunk-B6M55OFE.js} +1 -1
  59. package/dist/ui/{chunk-KYDOSLTO.js → chunk-CAY5NM4Z.js} +1 -1
  60. package/dist/ui/{chunk-4KE2SZKH.js → chunk-D3UIZHRK.js} +1 -1
  61. package/dist/ui/chunk-E76ECIOX.js +81 -0
  62. package/dist/ui/chunk-FBSBL476.js +1 -0
  63. package/dist/ui/chunk-FFHV5S6A.js +1 -0
  64. package/dist/ui/{chunk-X2WHBGTP.js → chunk-FJLNXXE3.js} +1 -1
  65. package/dist/ui/chunk-FSVNOZ6F.js +1 -0
  66. package/dist/ui/{chunk-BZIRGB4W.js → chunk-GDXNSFLE.js} +1 -1
  67. package/dist/ui/{chunk-C5NH23G4.js → chunk-GQ5IRK43.js} +1 -1
  68. package/dist/ui/{chunk-DEGMKEHP.js → chunk-GU24U5RM.js} +1 -1
  69. package/dist/ui/{chunk-HRGYNHZ3.js → chunk-HARRKJFZ.js} +1 -1
  70. package/dist/ui/{chunk-PHBMVORG.js → chunk-HO3W4RVG.js} +1 -1
  71. package/dist/ui/{chunk-62UWGWON.js → chunk-J5E457OI.js} +1 -1
  72. package/dist/ui/{chunk-W3HIZQ4Z.js → chunk-JS6TK4OP.js} +1 -1
  73. package/dist/ui/{chunk-54DVDYU6.js → chunk-JTIQBW33.js} +1 -1
  74. package/dist/ui/{chunk-ORXEMIQC.js → chunk-KRNQ6L35.js} +1 -1
  75. package/dist/ui/chunk-LROR6N3B.js +7 -0
  76. package/dist/ui/{chunk-NZHF733K.js.LEGAL.txt → chunk-LROR6N3B.js.LEGAL.txt} +6 -1
  77. package/dist/ui/{chunk-E2RCCK2T.js → chunk-M3T56ZRP.js} +1 -1
  78. package/dist/ui/chunk-MXGHX55S.js +141 -0
  79. package/dist/ui/{chunk-KFAZBEPV.js → chunk-MZTOPPWQ.js} +1 -1
  80. package/dist/ui/{chunk-JHBAMPGB.js → chunk-N3JSLTMV.js} +1 -1
  81. package/dist/ui/{chunk-L4RHGQUG.js → chunk-NSOTG64N.js} +1 -1
  82. package/dist/ui/{chunk-HLMBCVRX.js → chunk-O5P3CPJ4.js} +1 -1
  83. package/dist/ui/chunk-OWQL5DVE.js +1 -0
  84. package/dist/ui/{chunk-P3NETZZP.js → chunk-OXVYTSIZ.js} +1 -1
  85. package/dist/ui/chunk-P2Z66DHV.js +1 -0
  86. package/dist/ui/chunk-QEE7XS6O.js +1 -0
  87. package/dist/ui/chunk-QHJOTXYB.js +1 -0
  88. package/dist/ui/{chunk-3IYZCUPI.js → chunk-R6B3W5AJ.js} +1 -1
  89. package/dist/ui/{chunk-QGBR3J2Y.js → chunk-RAXWL656.js} +1 -1
  90. package/dist/ui/chunk-SRX7EWL4.js +1 -0
  91. package/dist/ui/chunk-TDUBSLEC.js +1 -0
  92. package/dist/ui/chunk-TFB3VGWP.js +1 -0
  93. package/dist/ui/{chunk-767BAQ53.js → chunk-U7PWJV6F.js} +1 -1
  94. package/dist/ui/{chunk-PWKJDYE2.js → chunk-UUVAD4U4.js} +1 -1
  95. package/dist/ui/chunk-V4CTOC6E.js +1 -0
  96. package/dist/ui/{chunk-EGEB6N4J.js → chunk-VD6G5NV4.js} +11 -11
  97. package/dist/ui/chunk-W5DOO6ID.js +1 -0
  98. package/dist/ui/{chunk-HHMG665Z.js → chunk-WFQU7V3W.js} +1 -1
  99. package/dist/ui/{chunk-SQRKKWRG.js → chunk-WKF7CSWS.js} +1 -1
  100. package/dist/ui/{chunk-4W73RW5I.js → chunk-WXT7LTQM.js} +1 -1
  101. package/dist/ui/{chunk-VMT7JFAM.js → chunk-XT5FNJCX.js} +1 -1
  102. package/dist/ui/chunk-YLSRRNSE.js +1 -0
  103. package/dist/ui/chunk-ZN2Y5OUF.js +3 -0
  104. package/dist/ui/gcs-ECSDFCIU.js +1 -0
  105. package/dist/ui/ui.css +1 -1
  106. package/dist/ui/ui.js +1 -1
  107. package/package.json +14 -10
  108. package/dist/ui/AIPage-F3NNYM5E.js +0 -1
  109. package/dist/ui/AssetsPage-DZQHAENZ.js +0 -1
  110. package/dist/ui/CollectionPage-WVVG62NR.js +0 -1
  111. package/dist/ui/ComparePage-CRDHP45W.js +0 -1
  112. package/dist/ui/DataPage-WMLBCPGF.js +0 -1
  113. package/dist/ui/DataSourcePage-POZAQFPU.js +0 -1
  114. package/dist/ui/DocTranslationsPage-UR5D2RF2.js +0 -1
  115. package/dist/ui/DocumentPage-SQ7ROBMC.js +0 -1
  116. package/dist/ui/EditDataSourcePage-PUA2AJ4C.js +0 -1
  117. package/dist/ui/EditReleasePage-CENP46EO.js +0 -1
  118. package/dist/ui/LogsPage-FZRN6MBJ.js +0 -1
  119. package/dist/ui/NewDataSourcePage-FTILYFJY.js +0 -1
  120. package/dist/ui/NewReleasePage-MHJC66KK.js +0 -1
  121. package/dist/ui/NotFoundPage-EP2OE4JV.js +0 -1
  122. package/dist/ui/ProjectPage-6J7QCG75.js +0 -1
  123. package/dist/ui/ReleasePage-IZ3DNGT4.js +0 -1
  124. package/dist/ui/ReleasesPage-RWFOJ5VG.js +0 -1
  125. package/dist/ui/SettingsPage-M4SIDBTI.js +0 -1
  126. package/dist/ui/SidebarToolsPage-GAX3XJ7W.js +0 -1
  127. package/dist/ui/TaskPage-UCATTNZ5.js +0 -1
  128. package/dist/ui/TasksPage-4AQLQ4IT.js +0 -1
  129. package/dist/ui/TranslationsArbPage-JGQGATCS.js +0 -2
  130. package/dist/ui/TranslationsEditPage-7AGZGHKS.js +0 -1
  131. package/dist/ui/chunk-7MTDTPYB.js +0 -1
  132. package/dist/ui/chunk-7UIUAHC4.js +0 -1
  133. package/dist/ui/chunk-AEWL2RWR.js +0 -141
  134. package/dist/ui/chunk-AFWBSIPL.js +0 -1
  135. package/dist/ui/chunk-AL3TN2KI.js +0 -1
  136. package/dist/ui/chunk-DUJYIOLE.js +0 -5
  137. package/dist/ui/chunk-I6ICVKEC.js +0 -1
  138. package/dist/ui/chunk-JKCZGT6B.js +0 -1
  139. package/dist/ui/chunk-JZFTZ4X4.js +0 -87
  140. package/dist/ui/chunk-KKEWCXVV.js +0 -1
  141. package/dist/ui/chunk-NZHF733K.js +0 -7
  142. package/dist/ui/chunk-ONTGW2VA.js +0 -1
  143. package/dist/ui/chunk-P4U2LUTF.js +0 -1
  144. package/dist/ui/chunk-PJA7YP4A.js +0 -1
  145. package/dist/ui/chunk-RSVO46S3.js +0 -1
  146. package/dist/ui/chunk-TJBVMFNQ.js +0 -1
  147. package/dist/ui/chunk-XOQ3KDSR.js +0 -3
  148. package/dist/ui/chunk-YFA6U2CV.js +0 -1
  149. package/dist/ui/gcs-L33FIRZU.js +0 -1
  150. /package/dist/ui/{ImageEditorDialog-4H665KK2.js.LEGAL.txt → ImageEditorDialog-GGS4VFEA.js.LEGAL.txt} +0 -0
  151. /package/dist/ui/{chunk-SKEP5WYH.js.LEGAL.txt → chunk-7SK47HHZ.js.LEGAL.txt} +0 -0
  152. /package/dist/ui/{chunk-JZFTZ4X4.js.LEGAL.txt → chunk-E76ECIOX.js.LEGAL.txt} +0 -0
  153. /package/dist/ui/{chunk-AEWL2RWR.js.LEGAL.txt → chunk-MXGHX55S.js.LEGAL.txt} +0 -0
  154. /package/dist/ui/{chunk-EGEB6N4J.js.LEGAL.txt → chunk-VD6G5NV4.js.LEGAL.txt} +0 -0
  155. /package/dist/ui/{prerender-Q4YSDCPB.js → prerender-M47IWV5Q.js} +0 -0
@@ -0,0 +1 @@
1
+ function i(){return window.__ROOT_CTX.allowedIframeOrigins||[]}function a(e){return e?e===window.location.origin?!0:i().includes(e):!1}function s(){if(!document.referrer)return"";try{return new URL(document.referrer).origin}catch{return""}}function d(e){let o=window.parent!==window?window.parent:window.opener;if(!o)return;let t={root:e},n=i();if(n.length===0){let r=s();r&&o.postMessage(t,r);return}n.forEach(r=>{o.postMessage(t,r)})}export{a,d as b};
@@ -0,0 +1 @@
1
+ import{a as U}from"./chunk-FSVNOZ6F.js";import{d as _,f as d}from"./chunk-YLSRRNSE.js";import{Cc as Z,Fa as S,Fb as M,Fc as P,Ga as t,Ob as T,S as x,Tb as I,Y as k,Ya as B,_ as L,a as v,aa as w,c as C,ec as H,fb as j,j as X,ob as N,pc as O,qa as g,xc as z,yc as R}from"./chunk-LROR6N3B.js";import{d as m}from"./chunk-KUCVLANF.js";var h={name:"@blinkk/root-cms",version:"3.1.1",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.1","firebase-admin":">=11","firebase-functions":">=4"},peerDependenciesMeta:{"firebase-functions":{optional:!0}}};function W(){return t("svg",{width:"100",height:"23",viewBox:"0 0 100 23",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t("g",{"clip-path":"url(#clip0_1_318)",children:[t("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"}),t("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"}),t("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"}),t("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"}),t("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"}),t("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"}),t("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"}),t("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"}),t("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"})]}),t("defs",{children:t("clipPath",{id:"clip0_1_318",children:t("rect",{width:"99",height:"22",fill:"white",transform:"translate(0.0175781 0.177246)"})})})]})}X();function V(e){let[i,a]=v(!1);C(()=>{let c=navigator.userAgentData?.platform??navigator.platform;a(/mac/i.test(c||""))},[]);let l=()=>{U()};return t("button",{type:"button",className:d("SearchBar",e.className),onClick:l,"aria-label":"Open search",children:[t(Z,{className:"SearchBar__icon",size:16,stroke:1.5}),t("span",{className:"SearchBar__placeholder",children:"Search"}),t("span",{className:"SearchBar__shortcut","aria-hidden":"true",children:i?"\u2318 + K":"Ctrl + K"})]})}var r="1.5";function o(e){return t("div",{className:"Layout",children:[t(o.Top,{}),t(o.Side,{}),t(o.Main,{...e,children:e.children}),t(o.Bottom,{})]})}function G(e){let a=e.split("?")[0].replace(/\/+$/g,"").split("/").filter(Boolean);return a.length===4&&a[0]==="cms"&&a[1]==="content"}o.Top=()=>{let e=window.__ROOT_CTX.rootConfig,i=e.projectName||e.projectId,a=e.minimalBranding,{url:l}=_(),c=!G(l);return t("div",{className:"Layout__top",children:[a?t(m,{children:[t("a",{className:"Layout__top__logo",href:"/cms",children:i}),t("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",h.version]})]}):t(m,{children:[t("a",{className:"Layout__top__logo",href:"/cms",children:t(W,{})}),t("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",h.version]}),t("div",{className:"Layout__top__project",children:i})]}),c&&t("div",{className:"Layout__top__search",children:t(V,{})})]})};o.Side=()=>{let{url:e}=_(),i=e.replace(/\/*$/g,""),a=window.firebase.user,l=window.__ROOT_CTX.sidebar?.tools,c=new Set(window.__ROOT_CTX.sidebar?.hiddenBuiltInTools||[]),s=u=>c.has(u),f=window.__ROOT_CTX.experiments||{},D=async()=>{await window.firebase.auth.signOut(),window.location.href="/cms/login"};return t("div",{className:"Layout__side",children:[t("div",{className:"Layout__side__buttons",children:[!s("home")&&t(o.SideButton,{label:"Home",url:"/cms",active:i==="/cms",children:t(T,{stroke:r})}),!s("content")&&t(o.SideButton,{label:"Content",url:"/cms/content",active:i.startsWith("/cms/content"),children:t(M,{stroke:r})}),f.taskManager&&t(o.SideButton,{label:"Tasks",url:"/cms/tasks",active:i.startsWith("/cms/tasks"),children:t(j,{stroke:r})}),!s("releases")&&t(o.SideButton,{label:"Releases",url:"/cms/releases",active:i.startsWith("/cms/releases"),children:t(R,{stroke:r})}),!s("data")&&t(o.SideButton,{label:"Data",url:"/cms/data",active:i.startsWith("/cms/data"),children:t(N,{stroke:r})}),!s("assets")&&t(o.SideButton,{label:"Asset Library",url:"/cms/assets",active:i.startsWith("/cms/assets"),children:t(O,{stroke:r})}),!s("translations")&&t(o.SideButton,{label:"Translations",url:"/cms/translations",active:i.startsWith("/cms/translations"),children:t(I,{stroke:r})}),(f.ai||window.__ROOT_CTX.ai)&&!s("ai")&&t(o.SideButton,{label:"Root AI",url:"/cms/ai",active:i.startsWith("/cms/ai"),children:t(z,{stroke:r})}),l&&t(m,{children:[t("div",{className:"Layout__side__divider"}),Object.entries(l).map(([u,n])=>{let A=n.cmsUrl?.startsWith("/cms/")?n.cmsUrl:void 0,p=n.externalUrl,y=p??A??`/cms/tools/${u}`,b=p?void 0:y.replace(/\/*$/g,""),E=!p&&!!b&&(i===b||i.startsWith(`${b}/`));return t(o.SideButton,{className:"Layout__side__tool",label:n.label||"",url:y,active:E,external:!!p,children:n.icon?t("img",{className:"Layout__side__tool__icon",src:n.icon,alt:n.label||""}):t(B,{stroke:r})},u)}),t("div",{className:"Layout__side__divider"})]}),!s("settings")&&t(o.SideButton,{label:"Settings",url:"/cms/settings",active:i.startsWith("/cms/settings"),children:t(P,{stroke:r})})]}),t("div",{className:"Layout__side__user",children:t(g,{shadow:"md",position:"right",control:t(x,{children:t(w,{src:a.photoURL,alt:a.email,size:30,radius:"xl"})}),children:[t(g.Label,{children:t(k,{size:"xs",color:"dimmed",truncate:!0,children:["Signed in as ",a.email]})}),t(L,{}),t(g.Item,{color:"red",icon:t(H,{style:{width:14,height:14}}),onClick:D,children:"Sign out"})]})})]})};o.SideButton=e=>t(S,{className:d("Layout__side__button",e.className),label:e.label,position:"right",withArrow:!0,children:t("a",{className:d(e.active&&"active"),href:e.url,target:e.external?"_blank":void 0,rel:e.external?"noreferrer noopener":void 0,children:e.children})});o.Main=e=>t("div",{className:"Layout__main",children:e.children});o.Bottom=()=>t("div",{className:"Layout__bottom"});export{o as a};
@@ -1 +1 @@
1
- import{a,h as n,j as s}from"./chunk-NZHF733K.js";s();s();function T(e,r){let[c,i]=a(()=>{try{let t=window.localStorage.getItem(e);return t?JSON.parse(t):r}catch(t){return console.error(t),r}}),u=n(t=>{i(l=>{let o=typeof t=="function"?t(l):t;return window.localStorage.setItem(e,JSON.stringify(o)),o})},[e]);return[c,u]}export{T as a};
1
+ import{a,h as n,j as s}from"./chunk-LROR6N3B.js";s();s();function T(e,r){let[c,i]=a(()=>{try{let t=window.localStorage.getItem(e);return t?JSON.parse(t):r}catch(t){return console.error(t),r}}),u=n(t=>{i(l=>{let o=typeof t=="function"?t(l):t;return window.localStorage.setItem(e,JSON.stringify(o)),o})},[e]);return[c,u]}export{T as a};
@@ -0,0 +1 @@
1
+ import{C as te,D as E,E as oe,G as H,H as re,I as ne,K as ie,O as ae,P as se,Q as le,S as ce,T as pe,Y as C,Z as ue,a as _,c as Q,e as ee,fa as de,ha as ge,ia as fe,ja as me,ka as he,ua as ve,v as n,y as w}from"./chunk-LROR6N3B.js";import{j as Y}from"./chunk-KUCVLANF.js";w();w();var tt=Object.defineProperty,ot=Object.defineProperties,rt=Object.getOwnPropertyDescriptors,ye=Object.getOwnPropertySymbols,nt=Object.prototype.hasOwnProperty,it=Object.prototype.propertyIsEnumerable,_e=(e,t,o)=>t in e?tt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,at=(e,t)=>{for(var o in t||(t={}))nt.call(t,o)&&_e(e,o,t[o]);if(ye)for(var o of ye(t))it.call(t,o)&&_e(e,o,t[o]);return e},st=(e,t)=>ot(e,rt(t));function lt(e){return st(at({},e),{id:e.id||ie()})}function ct(e){let t=[];return e.reduceRight((o,r)=>(t.includes(r.id)||(t.push(r.id),o.push(r)),o),[]).reverse()}function M(e){return ct(e.map(t=>lt(t)))}function we(e,t){let[o,r]=_(M(typeof e=="function"?e(t):e));return Q(()=>{typeof e=="function"&&r(M(e(t)))},[t]),[o,{registerActions:i=>r(s=>M([...s,...i])),updateActions:i=>r(M(typeof i=="function"?i(t):i)),removeActions:i=>r(s=>s.filter(l=>!i.includes(l.id))),triggerAction:i=>{var s;let l=o.find(m=>m.id===i);(s=l?.onTrigger)==null||s.call(l,l)}}]}function pt(e,t){return e===null?[]:Array.isArray(e)?e.map(o=>[o,t]):[[e,t]]}function Se(e,t){se(pt(e,t))}w();w();var ut=E((e,{radius:t})=>({action:{position:"relative",display:"block",width:"100%",padding:"10px 12px",borderRadius:e.fn.radius(t)},actionHovered:{backgroundColor:e.colorScheme==="dark"?e.colors.dark[4]:e.colors.gray[1]},actionIcon:{color:e.colorScheme==="dark"?e.colors.dark[2]:e.colors.gray[6]},actionBody:{flex:1}})),Oe=ut;var dt=Object.defineProperty,z=Object.getOwnPropertySymbols,Pe=Object.prototype.hasOwnProperty,Ae=Object.prototype.propertyIsEnumerable,Ee=(e,t,o)=>t in e?dt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,gt=(e,t)=>{for(var o in t||(t={}))Pe.call(t,o)&&Ee(e,o,t[o]);if(z)for(var o of z(t))Ae.call(t,o)&&Ee(e,o,t[o]);return e},ft=(e,t)=>{var o={};for(var r in e)Pe.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&z)for(var r of z(e))t.indexOf(r)<0&&Ae.call(e,r)&&(o[r]=e[r]);return o};function K(e){var t=e,{action:o,styles:r,classNames:a,hovered:d,onTrigger:p,highlightQuery:h,highlightColor:i,query:s,radius:l}=t,m=ft(t,["action","styles","classNames","hovered","onTrigger","highlightQuery","highlightColor","query","radius"]);let{classes:u,cx:v}=Oe({radius:l},{styles:r,classNames:a,name:"Spotlight"});return n.createElement(ce,gt({className:v(u.action,{[u.actionHovered]:d}),tabIndex:-1,onMouseDown:y=>y.preventDefault(),onClick:p},m),n.createElement(de,{noWrap:!0},o.icon&&n.createElement(pe,{className:u.actionIcon},o.icon),n.createElement("div",{className:u.actionBody},n.createElement(he,{highlightColor:i,highlight:h?s:null},o.title),o.description&&n.createElement(C,{color:"dimmed",size:"xs"},o.description))))}K.displayName="@mantine/spotlight/DefaultAction";w();var mt=E(e=>({nothingFound:{},actions:{padding:e.spacing.xs/2,borderTop:`1px solid ${e.colorScheme==="dark"?e.colors.dark[4]:e.colors.gray[2]}`},actionsGroup:{textTransform:"uppercase",fontSize:e.spacing.xs,fontWeight:700,padding:"10px 12px",paddingBottom:0,paddingTop:15}})),xe=mt;function U({actions:e,styles:t,classNames:o,actionComponent:r,hovered:a,onActionHover:d,onActionTrigger:p,query:h,nothingFoundMessage:i,highlightQuery:s,highlightColor:l,radius:m}){let{classes:u}=xe(null,{classNames:o,styles:t,name:"Spotlight"}),v=e.map(g=>g.type==="item"?n.createElement(r,{query:h,key:g.item.id,action:g.item,hovered:g.index===a,onMouseEnter:()=>d(g.index),classNames:o,styles:t,radius:m,onTrigger:()=>p(g.item),highlightQuery:s,highlightColor:l}):n.createElement(C,{className:u.actionsGroup,color:"dimmed",key:g.label},g.label)),y=v.length>0||!!i&&h.trim().length>0;return n.createElement(n.Fragment,null,y&&n.createElement("div",{className:u.actions},v.length>0?v:n.createElement(C,{color:"dimmed",className:u.nothingFound,align:"center",size:"lg",py:"md"},i)))}U.displayName="@mantine/spotlight/ActionsList";function ht(e){return Array.isArray(e)?e.map(t=>t.trim()).join(",").toLowerCase().trim():typeof e=="string"?e.toLowerCase().trim():""}function Ce(e,t){let o=e.trim().toLowerCase(),r=[[],[]];return t.forEach(a=>{var d,p;(d=a.title)!=null&&d.toLowerCase().includes(o)?r[0].push(a):((p=a.description)!=null&&p.toLowerCase().includes(o)||ht(a.keywords).includes(o))&&r[1].push(a)}),r.flat()}var vt=Object.defineProperty,yt=Object.defineProperties,_t=Object.getOwnPropertyDescriptors,be=Object.getOwnPropertySymbols,wt=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable,Ie=(e,t,o)=>t in e?vt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,De=(e,t)=>{for(var o in t||(t={}))wt.call(t,o)&&Ie(e,o,t[o]);if(be)for(var o of be(t))St.call(t,o)&&Ie(e,o,t[o]);return e},Ne=(e,t)=>yt(e,_t(t)),Ot=E((e,{centered:t,maxWidth:o,topOffset:r,radius:a})=>({root:Ne(De({},e.fn.cover()),{position:"fixed"}),spotlight:{position:"relative",zIndex:2,backgroundColor:e.colorScheme==="dark"?e.colors.dark[6]:e.white,borderRadius:e.fn.radius(a),width:"100%",maxWidth:o,overflow:"hidden",marginLeft:"calc(var(--removed-scroll-width, 0px) * -1)"},overlay:Ne(De({},e.fn.cover()),{position:"fixed"}),inner:{height:"100vh",display:"flex",flexDirection:"column",paddingTop:t?e.spacing.md:r,justifyContent:t?"center":"flex-start",alignItems:"center"},searchInput:{border:0,borderBottomRightRadius:0,borderBottomLeftRadius:0,backgroundColor:e.colorScheme==="dark"?e.colors.dark[6]:e.white}})),Te=Ot;var Et=Object.defineProperty,B=Object.getOwnPropertySymbols,Re=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable,je=(e,t,o)=>t in e?Et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,Pt=(e,t)=>{for(var o in t||(t={}))Re.call(t,o)&&je(e,o,t[o]);if(B)for(var o of B(t))Le.call(t,o)&&je(e,o,t[o]);return e},At=(e,t)=>{var o={};for(var r in e)Re.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&B)for(var r of B(e))t.indexOf(r)<0&&Le.call(e,r)&&(o[r]=e[r]);return o};function q(e){var t=e,{query:o,onQueryChange:r,actions:a,onClose:d,opened:p,withinPortal:h,transition:i="pop",transitionDuration:s,classNames:l,styles:m,overlayColor:u="#000",overlayOpacity:v=.25,overlayBlur:y=3,shadow:g="md",radius:P="sm",centered:W=!1,closeOnActionTrigger:b=!0,highlightQuery:I=!1,highlightColor:D,maxWidth:N=600,topOffset:T=120,className:G,searchPlaceholder:j,searchIcon:R,filter:Fe=Ce,nothingFoundMessage:We,limit:Ge=10,actionComponent:Ve=K,actionsWrapperComponent:Ke="div",zIndex:Ue=te("modal")}=t,qe=At(t,["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[L,S]=_(-1),[Ze,$]=_(!1),{classes:A,cx:$e}=Te({centered:W,maxWidth:N,topOffset:T,radius:P},{classNames:l,styles:m,name:"Spotlight"}),[,J]=ae(),Je=ne(p),V=()=>S(-1),k=()=>{V(),d()};re({transitionDuration:0,opened:p});let Xe=Fe(o,a).slice(0,Ge),X=oe(Xe).items,O=X.map(c=>c.type==="item"?c.item:void 0).filter(c=>c);H(()=>{O.length-1<L&&S(O.length-1)},[O.length]);let Ye=c=>{var x;if(!Ze)switch(c.code){case"ArrowDown":{c.preventDefault(),S(f=>f<O.length-1?f+1:0);break}case"ArrowUp":{c.preventDefault(),S(f=>f>0?f-1:O.length-1);break}case"Enter":{c.preventDefault();let f=O[L];(x=f?.onTrigger)==null||x.call(f,f),b&&f?.onTrigger&&k();break}case"Escape":c.preventDefault(),k()}},et=c=>{r(c.currentTarget.value),L===-1&&S(0)};return n.createElement(ge,{withinPortal:h,zIndex:Ue},n.createElement(fe,{onExited:()=>J(!1),onEntered:()=>J(!0),mounted:p,transitions:{spotlight:{duration:s,transition:i,timingFunction:"ease"},overlay:{duration:s/2,transition:"fade",timingFunction:"ease"}}},c=>n.createElement("div",Pt({className:$e(A.root,G)},qe),n.createElement("div",{className:A.inner,ref:Je},n.createElement(ue,{style:c.spotlight,className:A.spotlight,shadow:g,radius:P,onMouseLeave:V},n.createElement(ve,{value:o,onChange:et,onKeyDown:Ye,onCompositionStart:()=>$(!0),onCompositionEnd:()=>$(!1),classNames:{input:A.searchInput},size:"lg",placeholder:j,icon:R,onMouseEnter:V,autoComplete:"chrome-please-just-do-not-show-it-thanks"}),n.createElement(Ke,null,n.createElement(U,{highlightQuery:I,highlightColor:D,actions:X,actionComponent:Ve,hovered:L,query:o,nothingFoundMessage:We,onActionHover:S,onActionTrigger:x=>{x.onTrigger(x),b&&k()},styles:m,classNames:l,radius:P}))),n.createElement("div",{style:c.overlay},n.createElement(me,{className:A.overlay,zIndex:1,onMouseDown:k,color:u,opacity:v,blur:y}))))))}q.displayName="@mantine/spotlight/Spotlight";w();var Z={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 xt(e,t){return new CustomEvent(e,{detail:t})}function Ct(){window.dispatchEvent(xt(Z.open))}function ke(e){let t={registerActions:o=>e.registerActions(o.detail),removeActions:o=>e.removeActions(o.detail),triggerAction:o=>e.triggerAction(o.detail),open:e.openSpotlight,close:e.closeSpotlight,toggle:e.toggleSpotlight};Q(()=>(Object.keys(t).forEach(o=>{window.addEventListener(Z[o],t[o])}),()=>{Object.keys(t).forEach(o=>{window.removeEventListener(Z[o],t[o])})}),[])}w();var Qe=Y(null);var bt=Object.defineProperty,F=Object.getOwnPropertySymbols,Me=Object.prototype.hasOwnProperty,ze=Object.prototype.propertyIsEnumerable,He=(e,t,o)=>t in e?bt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,It=(e,t)=>{for(var o in t||(t={}))Me.call(t,o)&&He(e,o,t[o]);if(F)for(var o of F(t))ze.call(t,o)&&He(e,o,t[o]);return e},Dt=(e,t)=>{var o={};for(var r in e)Me.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&F)for(var r of F(e))t.indexOf(r)<0&&ze.call(e,r)&&(o[r]=e[r]);return o};function Be(e){var t=e,{actions:o,children:r,shortcut:a="mod + K",onSpotlightClose:d,onSpotlightOpen:p,onQueryChange:h,cleanQueryOnClose:i=!0,transitionDuration:s=150}=t,l=Dt(t,["actions","children","shortcut","onSpotlightClose","onSpotlightOpen","onQueryChange","cleanQueryOnClose","transitionDuration"]);let m=ee(-1),[u,v]=_(""),[y,{registerActions:g,updateActions:P,removeActions:W,triggerAction:b}]=we(o,u);H(()=>{P(o)},[o]);let I=R=>{v(R),h?.(R)},[D,{open:N,close:T,toggle:G}]=le(!1,{onClose:()=>{d?.(),i&&(m.current=window.setTimeout(()=>{I("")},s))},onOpen:()=>{p?.(),window.clearTimeout(m.current)}}),j={openSpotlight:N,closeSpotlight:T,toggleSpotlight:G,registerActions:g,removeActions:W,triggerAction:b,opened:D,actions:y,query:u};return Se(a,N),ke(j),n.createElement(Qe.Provider,{value:j},n.createElement(q,It({actions:y,onClose:T,opened:D,query:u,onQueryChange:I,transitionDuration:s},l)),r)}Be.displayName="@mantine/spotlight/SpotlightProvider";export{Ct as a,Be as b};
@@ -1 +1 @@
1
- import{b as R,f as O,g as U,i as A,j as H,k as j,m as N,o as M}from"./chunk-EGEB6N4J.js";import{a,c as E,e as x,h as D,j as B}from"./chunk-NZHF733K.js";B();var F=200,X=25,Y=2;function W(u,d={}){let[b,r]=a([]),[f,t]=a(!1),[e,g]=a(null),[y,n]=a(null),o=x(null),T=d.limit??X,L=d.minQueryLength??Y;return E(()=>{let h=u.trim();if(h.length<L){o.current?.abort(),o.current=null,r([]),t(!1),g(null);return}t(!0),g(null);let S=window.setTimeout(async()=>{o.current?.abort();let s=new AbortController;o.current=s;try{let l=await fetch("/cms/api/search.query",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({q:h,limit:T}),signal:s.signal});if(!l.ok)throw new Error(`search.query returned ${l.status}`);let c=await l.json();if(!c?.success)throw new Error(c?.error||"search failed");if(s.signal.aborted)return;r(Array.isArray(c.hits)?c.hits:[]),n(c.meta||null),t(!1)}catch(l){if(s.signal.aborted)return;console.error("global search failed:",l),g(String(l?.message||l)),r([]),t(!1)}},F);return()=>{window.clearTimeout(S)}},[u,T,L]),{hits:b,loading:f,error:e,status:y}}function Z(){let[u,d]=a({status:{lastRun:null,docCount:0,fieldCount:0,shardCount:0},running:!1}),[b,r]=a(!0),f=D(async()=>{try{let t=await fetch("/cms/api/search.status",{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok)return;let e=await t.json();if(!e?.success)return;d({status:e.status,running:!!e.running})}catch(t){console.error("search.status failed:",t)}finally{r(!1)}},[]);return E(()=>{f()},[f]),{...u,loading:b,refresh:f}}var v=200,J=5,K=2;function tt(u,d={}){let[b,r]=a([]),[f,t]=a(!1),e=x(null),g=d.limit??10,y=d.minQueryLength??K;return E(()=>{let n=u.trim(),o=n.indexOf("/");if((o>=0?n.slice(o+1):n).length<y){e.current&&(e.current.aborted=!0),e.current=null,r([]),t(!1);return}t(!0);let L=window.setTimeout(async()=>{e.current&&(e.current.aborted=!0);let h={aborted:!1};e.current=h;let S=null,s=n;o>=0&&(S=n.slice(0,o),s=n.slice(o+1));let l=window.__ROOT_CTX?.rootConfig?.projectId,c=window.firebase?.db;if(!l||!c){r([]),t(!1);return}let I=Object.keys(window.__ROOT_CTX.collections||{}),q=S?I.filter(p=>p.toLowerCase()===S.toLowerCase()):I,P=s,Q=`${s}\uF8FF`;try{let p=q.map(async i=>{let w=R(c,"Projects",l,"Collections",i,"Drafts"),C=U(w,A(O()),j(P),N(Q),H(J));try{let m=await M(C),_=[];return m.forEach(G=>{_.push({collection:i,slug:G.id,docId:`${i}/${G.id}`})}),_}catch(m){return console.error(`docSlugSearch failed for ${i}:`,m),[]}}),$=(await Promise.all(p)).flat();if(h.aborted)return;let k=$.sort((i,w)=>{let C=i.slug===s||i.docId===n?0:1,m=w.slug===s||w.docId===n?0:1;return C!==m?C-m:i.docId.localeCompare(w.docId)});r(k.slice(0,g)),t(!1)}catch(p){if(h.aborted)return;console.error("docSlugSearch failed:",p),r([]),t(!1)}},v);return()=>{window.clearTimeout(L)}},[u,g,y]),{hits:b,loading:f}}export{W as a,Z as b,tt as c};
1
+ import{b as R,f as O,g as U,i as A,j as H,k as j,m as N,o as M}from"./chunk-VD6G5NV4.js";import{a,c as E,e as x,h as D,j as B}from"./chunk-LROR6N3B.js";B();var F=200,X=25,Y=2;function W(u,d={}){let[b,r]=a([]),[f,t]=a(!1),[e,g]=a(null),[y,n]=a(null),o=x(null),T=d.limit??X,L=d.minQueryLength??Y;return E(()=>{let h=u.trim();if(h.length<L){o.current?.abort(),o.current=null,r([]),t(!1),g(null);return}t(!0),g(null);let S=window.setTimeout(async()=>{o.current?.abort();let s=new AbortController;o.current=s;try{let l=await fetch("/cms/api/search.query",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({q:h,limit:T}),signal:s.signal});if(!l.ok)throw new Error(`search.query returned ${l.status}`);let c=await l.json();if(!c?.success)throw new Error(c?.error||"search failed");if(s.signal.aborted)return;r(Array.isArray(c.hits)?c.hits:[]),n(c.meta||null),t(!1)}catch(l){if(s.signal.aborted)return;console.error("global search failed:",l),g(String(l?.message||l)),r([]),t(!1)}},F);return()=>{window.clearTimeout(S)}},[u,T,L]),{hits:b,loading:f,error:e,status:y}}function Z(){let[u,d]=a({status:{lastRun:null,docCount:0,fieldCount:0,shardCount:0},running:!1}),[b,r]=a(!0),f=D(async()=>{try{let t=await fetch("/cms/api/search.status",{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok)return;let e=await t.json();if(!e?.success)return;d({status:e.status,running:!!e.running})}catch(t){console.error("search.status failed:",t)}finally{r(!1)}},[]);return E(()=>{f()},[f]),{...u,loading:b,refresh:f}}var v=200,J=5,K=2;function tt(u,d={}){let[b,r]=a([]),[f,t]=a(!1),e=x(null),g=d.limit??10,y=d.minQueryLength??K;return E(()=>{let n=u.trim(),o=n.indexOf("/");if((o>=0?n.slice(o+1):n).length<y){e.current&&(e.current.aborted=!0),e.current=null,r([]),t(!1);return}t(!0);let L=window.setTimeout(async()=>{e.current&&(e.current.aborted=!0);let h={aborted:!1};e.current=h;let S=null,s=n;o>=0&&(S=n.slice(0,o),s=n.slice(o+1));let l=window.__ROOT_CTX?.rootConfig?.projectId,c=window.firebase?.db;if(!l||!c){r([]),t(!1);return}let I=Object.keys(window.__ROOT_CTX.collections||{}),q=S?I.filter(p=>p.toLowerCase()===S.toLowerCase()):I,P=s,Q=`${s}\uF8FF`;try{let p=q.map(async i=>{let w=R(c,"Projects",l,"Collections",i,"Drafts"),C=U(w,A(O()),j(P),N(Q),H(J));try{let m=await M(C),_=[];return m.forEach(G=>{_.push({collection:i,slug:G.id,docId:`${i}/${G.id}`})}),_}catch(m){return console.error(`docSlugSearch failed for ${i}:`,m),[]}}),$=(await Promise.all(p)).flat();if(h.aborted)return;let k=$.sort((i,w)=>{let C=i.slug===s||i.docId===n?0:1,m=w.slug===s||w.docId===n?0:1;return C!==m?C-m:i.docId.localeCompare(w.docId)});r(k.slice(0,g)),t(!1)}catch(p){if(h.aborted)return;console.error("docSlugSearch failed:",p),r([]),t(!1)}},v);return()=>{window.clearTimeout(L)}},[u,g,y]),{hits:b,loading:f}}export{W as a,Z as b,tt as c};
@@ -1,3 +1,3 @@
1
- import{a as Z}from"./chunk-CGCKJFL4.js";import{a as Q,c as X,e as Y}from"./chunk-4KE2SZKH.js";import{c as K}from"./chunk-W3HIZQ4Z.js";import{a as j}from"./chunk-JDW4UORS.js";import{b as J}from"./chunk-62UWGWON.js";import{a as x}from"./chunk-I6ICVKEC.js";import{d as W}from"./chunk-AL3TN2KI.js";import{Aa as S,Ha as e,a as s,c as q,e as B,ea as A,fa as P,j as re,oa as b,qa as $,va as F,wa as V}from"./chunk-NZHF733K.js";import{d as M}from"./chunk-KUCVLANF.js";re();var se="Enter the URL to make the HTTP request.",ne="Enter the URL of the Google Sheet, e.g. https://docs.google.com/spreadsheets/d/SPREADSHEET_ID/edit#gid=SHEET_ID";function Ne(a){let{route:n}=W(),c=B(null),i=Z(),[h,d]=s(!1),[r,U]=s(i.enabled?"gsheet":"http"),[g,z]=s("map"),[v,ee]=s("GET"),[y,T]=s(!1),[w,N]=s(1),[E,H]=s("hours"),[R,C]=s(!1),[L,p]=s(""),[te,O]=s(!!a.dataSourceId),[_,G]=s(null),I="";r==="http"?I=se:r==="gsheet"&&(I=ne);async function ae(t){await J(async()=>{let o=await X(t);G(o),U(o?.type||"http"),z(o?.dataFormat||"map"),o?.cron?(T(o.cron.enabled||!1),N(o.cron.interval||1),H(o.cron.unit||"hours"),C(o.cron.autoPublish||!1)):(T(!1),N(1),H("hours"),C(!1))}),O(!1)}q(()=>{a.dataSourceId&&(O(!0),ae(a.dataSourceId))},[a.dataSourceId]);async function oe(){p("");let t=c.current;function o(l){let f=t.elements[l];return f?f.value.trim():""}let m=a.dataSourceId||o("id");if(!m){p("missing id");return}if(!j(m)){p("id is invalid (alphanumeric characters and dashes only)");return}let D=o("url");if(!D){p("missing url");return}let u={id:m,description:o("description"),type:r,url:D,previewUrl:o("previewUrl")};if(r==="http"){if(!ie(D)){p("invalid url");return}u.httpOptions={method:v};let l=o("httpHeaders");if(l&&(u.httpOptions.headers=ue(l)),v==="POST"){let f=o("httpBody");f&&(u.httpOptions.body=f)}}else if(r==="gsheet"){if(!K(D)?.spreadsheetId){p("failed to parse spreadsheet url");return}u.dataFormat=g||"map"}y?u.cron={enabled:!0,interval:w,unit:E,autoPublish:R}:u.cron={enabled:!1,interval:w,unit:E};try{G(u),d(!0),a.dataSourceId?(await Y(a.dataSourceId,u),x({title:"Saved data source",message:`Successfully updated ${m}`,autoClose:5e3}),d(!1)):(await Q(m,u),x({title:"Added data source",message:`Successfully added ${m}`,autoClose:5e3}),d(!1),n(`/cms/data/${m}`))}catch(l){console.error(l),x({title:"Failed to save data source",message:String(l),color:"red",autoClose:!1}),d(!1)}}let k=[{value:"http",label:"HTTP"}];return(i.enabled||r==="gsheet")&&k.push({value:"gsheet",label:"Google Sheet"}),e("form",{className:"DataSourceForm",ref:c,onSubmit:t=>{t.preventDefault(),oe()},children:[e($,{visible:te}),e("div",{className:"DataSourceForm__input",children:e(S,{name:"type",label:"Type",data:k,value:r,onChange:t=>U(t),size:"xs",radius:0,dropdownComponent:"div"})}),e(F,{className:"DataSourceForm__input",name:"id",label:"ID",description:"Unique identifier for the data source. Use alphanumeric characters and dashes only, e.g. grogus-favorite-meals",size:"xs",radius:0,value:a.dataSourceId,disabled:!!a.dataSourceId}),e(b,{className:"DataSourceForm__input",name:"description",label:"Description",description:"Optional.",size:"xs",radius:0,value:_?.description}),e(F,{className:"DataSourceForm__input",name:"url",label:"URL",description:I,size:"xs",radius:0,value:_?.url}),r==="http"&&e(M,{children:[e("div",{className:"DataSourceForm__input",children:e(S,{name:"httpMethod",label:"HTTP Request Method",data:[{value:"GET",label:"GET"},{value:"POST",label:"POST"}],value:v,onChange:t=>ee(t),size:"xs",radius:0,dropdownComponent:"div"})}),e(b,{className:"DataSourceForm__input",name:"httpHeaders",label:"HTTP Request Headers",description:"Format as `HeaderName: Value`, each value on its own line.",size:"xs",radius:0,value:ce(_?.httpOptions?.headers||{})}),v==="POST"&&e(b,{className:"DataSourceForm__input",name:"httpRequestBody",label:"HTTP Request Body",size:"xs",radius:0,value:_?.httpOptions?.body})]}),r==="gsheet"&&e("div",{className:"DataSourceForm__input",children:[e(S,{name:"dataFormat",label:"Data Format",data:[{value:"map",label:"map"}],value:g,onChange:t=>z(t),size:"xs",radius:0,dropdownComponent:"div"}),g==="array"&&e("div",{className:"DataSourceForm__input__example",children:["Data is stored as an array of arrays, e.g.",e("code",{children:"[[header1, header2], [foo, bar]]"})]}),g==="map"&&e("div",{className:"DataSourceForm__input__example",children:["Data is stored as an array of maps, e.g.",e("code",{children:["[","{","header1: foo, header2: bar","}","]"]})]})]}),e("div",{className:"DataSourceForm__section",children:[e("div",{className:"DataSourceForm__section__label",children:"Sync Schedule"}),e(P,{className:"DataSourceForm__input",label:"Enable scheduled sync",checked:y,onChange:t=>T(t.currentTarget.checked),size:"xs"}),y&&e("div",{className:"DataSourceForm__cron",children:[e("div",{className:"DataSourceForm__cron__row",children:[e("span",{children:"Run every"}),e(V,{className:"DataSourceForm__cron__interval",value:w,onChange:t=>N(Number(t)||1),min:1,size:"xs",radius:0}),e(S,{className:"DataSourceForm__cron__unit",data:[{value:"minutes",label:"minutes"},{value:"hours",label:"hours"},{value:"days",label:"days"}],value:E,onChange:t=>H(t),size:"xs",radius:0,dropdownComponent:"div"})]}),e(P,{className:"DataSourceForm__input",label:"Auto-publish after sync",checked:R,onChange:t=>C(t.currentTarget.checked),size:"xs"})]})]}),e(F,{className:"DataSourceForm__input",name:"previewUrl",label:"Preview URL",description:"URL where users can preview the data source.",size:"xs",radius:0,value:_?.previewUrl}),e(A,{className:"DataSourceForm__submit",color:"blue",size:"xs",type:"submit",loading:h,children:a.buttonLabel||"Save"}),L&&e("div",{className:"DataSourceForm__error",children:["Error: ",L]})]})}function ie(a){let n,c=a.startsWith("/")?"http://localhost":void 0;try{n=new URL(a,c)}catch(i){return console.error(i),!1}return n.protocol==="http:"||n.protocol==="https:"}function ue(a){let n={};return a.split(`
1
+ import{a as Z}from"./chunk-3E6CASIN.js";import{a as Q,c as X,e as Y}from"./chunk-D3UIZHRK.js";import{c as K}from"./chunk-JS6TK4OP.js";import{a as j}from"./chunk-JDW4UORS.js";import{b as J}from"./chunk-J5E457OI.js";import{a as x}from"./chunk-QHJOTXYB.js";import{d as W}from"./chunk-YLSRRNSE.js";import{Ga as e,a as s,c as q,da as A,e as B,ea as P,j as re,na as b,pa as $,ua as F,va as V,za as S}from"./chunk-LROR6N3B.js";import{d as M}from"./chunk-KUCVLANF.js";re();var se="Enter the URL to make the HTTP request.",ne="Enter the URL of the Google Sheet, e.g. https://docs.google.com/spreadsheets/d/SPREADSHEET_ID/edit#gid=SHEET_ID";function Ne(a){let{route:n}=W(),c=B(null),i=Z(),[h,d]=s(!1),[r,U]=s(i.enabled?"gsheet":"http"),[g,z]=s("map"),[v,ee]=s("GET"),[y,T]=s(!1),[w,N]=s(1),[E,H]=s("hours"),[R,C]=s(!1),[L,p]=s(""),[te,O]=s(!!a.dataSourceId),[_,G]=s(null),I="";r==="http"?I=se:r==="gsheet"&&(I=ne);async function ae(t){await J(async()=>{let o=await X(t);G(o),U(o?.type||"http"),z(o?.dataFormat||"map"),o?.cron?(T(o.cron.enabled||!1),N(o.cron.interval||1),H(o.cron.unit||"hours"),C(o.cron.autoPublish||!1)):(T(!1),N(1),H("hours"),C(!1))}),O(!1)}q(()=>{a.dataSourceId&&(O(!0),ae(a.dataSourceId))},[a.dataSourceId]);async function oe(){p("");let t=c.current;function o(l){let f=t.elements[l];return f?f.value.trim():""}let m=a.dataSourceId||o("id");if(!m){p("missing id");return}if(!j(m)){p("id is invalid (alphanumeric characters and dashes only)");return}let D=o("url");if(!D){p("missing url");return}let u={id:m,description:o("description"),type:r,url:D,previewUrl:o("previewUrl")};if(r==="http"){if(!ie(D)){p("invalid url");return}u.httpOptions={method:v};let l=o("httpHeaders");if(l&&(u.httpOptions.headers=ue(l)),v==="POST"){let f=o("httpBody");f&&(u.httpOptions.body=f)}}else if(r==="gsheet"){if(!K(D)?.spreadsheetId){p("failed to parse spreadsheet url");return}u.dataFormat=g||"map"}y?u.cron={enabled:!0,interval:w,unit:E,autoPublish:R}:u.cron={enabled:!1,interval:w,unit:E};try{G(u),d(!0),a.dataSourceId?(await Y(a.dataSourceId,u),x({title:"Saved data source",message:`Successfully updated ${m}`,autoClose:5e3}),d(!1)):(await Q(m,u),x({title:"Added data source",message:`Successfully added ${m}`,autoClose:5e3}),d(!1),n(`/cms/data/${m}`))}catch(l){console.error(l),x({title:"Failed to save data source",message:String(l),color:"red",autoClose:!1}),d(!1)}}let k=[{value:"http",label:"HTTP"}];return(i.enabled||r==="gsheet")&&k.push({value:"gsheet",label:"Google Sheet"}),e("form",{className:"DataSourceForm",ref:c,onSubmit:t=>{t.preventDefault(),oe()},children:[e($,{visible:te}),e("div",{className:"DataSourceForm__input",children:e(S,{name:"type",label:"Type",data:k,value:r,onChange:t=>U(t),size:"xs",radius:0,dropdownComponent:"div"})}),e(F,{className:"DataSourceForm__input",name:"id",label:"ID",description:"Unique identifier for the data source. Use alphanumeric characters and dashes only, e.g. grogus-favorite-meals",size:"xs",radius:0,value:a.dataSourceId,disabled:!!a.dataSourceId}),e(b,{className:"DataSourceForm__input",name:"description",label:"Description",description:"Optional.",size:"xs",radius:0,value:_?.description}),e(F,{className:"DataSourceForm__input",name:"url",label:"URL",description:I,size:"xs",radius:0,value:_?.url}),r==="http"&&e(M,{children:[e("div",{className:"DataSourceForm__input",children:e(S,{name:"httpMethod",label:"HTTP Request Method",data:[{value:"GET",label:"GET"},{value:"POST",label:"POST"}],value:v,onChange:t=>ee(t),size:"xs",radius:0,dropdownComponent:"div"})}),e(b,{className:"DataSourceForm__input",name:"httpHeaders",label:"HTTP Request Headers",description:"Format as `HeaderName: Value`, each value on its own line.",size:"xs",radius:0,value:ce(_?.httpOptions?.headers||{})}),v==="POST"&&e(b,{className:"DataSourceForm__input",name:"httpRequestBody",label:"HTTP Request Body",size:"xs",radius:0,value:_?.httpOptions?.body})]}),r==="gsheet"&&e("div",{className:"DataSourceForm__input",children:[e(S,{name:"dataFormat",label:"Data Format",data:[{value:"map",label:"map"}],value:g,onChange:t=>z(t),size:"xs",radius:0,dropdownComponent:"div"}),g==="array"&&e("div",{className:"DataSourceForm__input__example",children:["Data is stored as an array of arrays, e.g.",e("code",{children:"[[header1, header2], [foo, bar]]"})]}),g==="map"&&e("div",{className:"DataSourceForm__input__example",children:["Data is stored as an array of maps, e.g.",e("code",{children:["[","{","header1: foo, header2: bar","}","]"]})]})]}),e("div",{className:"DataSourceForm__section",children:[e("div",{className:"DataSourceForm__section__label",children:"Sync Schedule"}),e(P,{className:"DataSourceForm__input",label:"Enable scheduled sync",checked:y,onChange:t=>T(t.currentTarget.checked),size:"xs"}),y&&e("div",{className:"DataSourceForm__cron",children:[e("div",{className:"DataSourceForm__cron__row",children:[e("span",{children:"Run every"}),e(V,{className:"DataSourceForm__cron__interval",value:w,onChange:t=>N(Number(t)||1),min:1,size:"xs",radius:0}),e(S,{className:"DataSourceForm__cron__unit",data:[{value:"minutes",label:"minutes"},{value:"hours",label:"hours"},{value:"days",label:"days"}],value:E,onChange:t=>H(t),size:"xs",radius:0,dropdownComponent:"div"})]}),e(P,{className:"DataSourceForm__input",label:"Auto-publish after sync",checked:R,onChange:t=>C(t.currentTarget.checked),size:"xs"})]})]}),e(F,{className:"DataSourceForm__input",name:"previewUrl",label:"Preview URL",description:"URL where users can preview the data source.",size:"xs",radius:0,value:_?.previewUrl}),e(A,{className:"DataSourceForm__submit",color:"blue",size:"xs",type:"submit",loading:h,children:a.buttonLabel||"Save"}),L&&e("div",{className:"DataSourceForm__error",children:["Error: ",L]})]})}function ie(a){let n,c=a.startsWith("/")?"http://localhost":void 0;try{n=new URL(a,c)}catch(i){return console.error(i),!1}return n.protocol==="http:"||n.protocol==="https:"}function ue(a){let n={};return a.split(`
2
2
  `).forEach(i=>{let h=i.indexOf(":");if(h===-1)return;let d=i.slice(0,h).trim(),r=i.slice(h+1).trim();d&&r&&(n[d]=r)}),n}function ce(a){let n=[];for(let c in a){let i=a[c];n.push(`${c}: ${i}`)}return n.join(`
3
3
  `)}export{Ne as a};
@@ -1 +1 @@
1
- import{h as M}from"./chunk-RSVO46S3.js";import{a as n,c as _}from"./chunk-HRGYNHZ3.js";import{b as h}from"./chunk-62UWGWON.js";import{a as u}from"./chunk-I6ICVKEC.js";import{e as f}from"./chunk-ORXEMIQC.js";import{a as m}from"./chunk-EGEB6N4J.js";import{Ha as e,a as i,e as c,ea as d,j as I}from"./chunk-NZHF733K.js";I();var S="ScheduleReleaseModal";function F(l){let t=n(),a=_();return{open:()=>{t.openContextModal(S,{...a,title:`Schedule release: ${l.releaseId}`,innerProps:l})}}}function T(l){let{innerProps:t,context:a,id:g}=l,[s,x]=i(""),[R,r]=i(!1),v=c(null),b=n();async function w(){r(!0),await h(async()=>{let o=Math.floor(new Date(s).getTime());if(Math.floor(new Date().getTime())>=o)throw new Error("bad datetime, please choose a date in the future");let y=m.fromMillis(o);await M(t.releaseId,o),u({title:"Scheduled!",message:`Release ${t.releaseId} will go live ${s}.`,autoClose:1e4}),b.closeAll(),t.onScheduled&&t.onScheduled(y)}),r(!1)}return e("div",{className:"ScheduleReleaseModal",children:e("div",{className:"ScheduleReleaseModal__content",children:e("form",{className:"ScheduleReleaseModal__form",onSubmit:o=>{o.preventDefault(),w()},children:[e("div",{className:"ScheduleReleaseModal__form__description",children:"Content in the release will go live at the datetime specified below."}),e("div",{className:"ScheduleReleaseModal__form__dateInput",children:[e("input",{ref:v,type:"datetime-local",value:s,min:f(),onChange:o=>{let p=o.target;x(p.value)}}),e("div",{className:"ScheduleReleaseModal__form__dateInput__help",children:["timezone: ",Intl.DateTimeFormat().resolvedOptions().timeZone]})]}),e("div",{className:"ScheduleReleaseModal__form__buttons",children:[e(d,{variant:"outline",onClick:()=>a.closeModal(g),type:"button",size:"xs",color:"dark",children:"Cancel"}),e(d,{variant:"filled",size:"xs",color:"dark",loading:R,type:"submit",children:"Schedule"})]})]})})})}T.id=S;export{F as a,T as b};
1
+ import{i as M}from"./chunk-AZCGXQTL.js";import{a as n,c as _}from"./chunk-HARRKJFZ.js";import{b as h}from"./chunk-J5E457OI.js";import{a as u}from"./chunk-QHJOTXYB.js";import{e as f}from"./chunk-KRNQ6L35.js";import{a as m}from"./chunk-VD6G5NV4.js";import{Ga as e,a as i,da as d,e as c,j as I}from"./chunk-LROR6N3B.js";I();var S="ScheduleReleaseModal";function F(l){let t=n(),a=_();return{open:()=>{t.openContextModal(S,{...a,title:`Schedule release: ${l.releaseId}`,innerProps:l})}}}function T(l){let{innerProps:t,context:a,id:g}=l,[s,x]=i(""),[R,r]=i(!1),v=c(null),b=n();async function w(){r(!0),await h(async()=>{let o=Math.floor(new Date(s).getTime());if(Math.floor(new Date().getTime())>=o)throw new Error("bad datetime, please choose a date in the future");let y=m.fromMillis(o);await M(t.releaseId,o),u({title:"Scheduled!",message:`Release ${t.releaseId} will go live ${s}.`,autoClose:1e4}),b.closeAll(),t.onScheduled&&t.onScheduled(y)}),r(!1)}return e("div",{className:"ScheduleReleaseModal",children:e("div",{className:"ScheduleReleaseModal__content",children:e("form",{className:"ScheduleReleaseModal__form",onSubmit:o=>{o.preventDefault(),w()},children:[e("div",{className:"ScheduleReleaseModal__form__description",children:"Content in the release will go live at the datetime specified below."}),e("div",{className:"ScheduleReleaseModal__form__dateInput",children:[e("input",{ref:v,type:"datetime-local",value:s,min:f(),onChange:o=>{let p=o.target;x(p.value)}}),e("div",{className:"ScheduleReleaseModal__form__dateInput__help",children:["timezone: ",Intl.DateTimeFormat().resolvedOptions().timeZone]})]}),e("div",{className:"ScheduleReleaseModal__form__buttons",children:[e(d,{variant:"outline",onClick:()=>a.closeModal(g),type:"button",size:"xs",color:"dark",children:"Cancel"}),e(d,{variant:"filled",size:"xs",color:"dark",loading:R,type:"submit",children:"Schedule"})]})]})})})}T.id=S;export{F as a,T as b};
@@ -1 +1 @@
1
- import{A as D,K as x,R as A,b as k,ea as L,ga as B,i as I,sa as F,v as d,y as M}from"./chunk-NZHF733K.js";import{j as R}from"./chunk-KUCVLANF.js";M();M();var h=R(null);h.displayName="@mantine/modals/ModalsContext";function j(){let o=I(h);if(!o)throw new Error("[@mantine/modals] useModals hook was called outside of context, wrap your app with ModalsProvider component");return o}M();M();var W=Object.defineProperty,X=Object.defineProperties,Y=Object.getOwnPropertyDescriptors,T=Object.getOwnPropertySymbols,Z=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable,V=(o,r,e)=>r in o?W(o,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[r]=e,S=(o,r)=>{for(var e in r||(r={}))Z.call(r,e)&&V(o,e,r[e]);if(T)for(var e of T(r))$.call(r,e)&&V(o,e,r[e]);return o},G=(o,r)=>X(o,Y(r));function q({id:o,cancelProps:r,confirmProps:e,labels:c={cancel:"",confirm:""},closeOnConfirm:n=!0,closeOnCancel:s=!0,groupProps:m,onCancel:u,onConfirm:f,children:v}){let{cancel:_,confirm:y}=c,P=j(),w=l=>{typeof r?.onClick=="function"&&r?.onClick(l),typeof u=="function"&&u(),s&&P.closeModal(o)},b=l=>{typeof e?.onClick=="function"&&e?.onClick(l),typeof f=="function"&&f(),n&&P.closeModal(o)};return d.createElement(d.Fragment,null,v&&d.createElement(A,{mb:"md"},v),d.createElement(B,S({position:"right"},m),d.createElement(L,G(S({variant:"default"},r),{onClick:w}),r?.children||_),d.createElement(L,G(S({},e),{onClick:b}),e?.children||y)))}function z(o,r){switch(r.type){case"OPEN":return{current:r.payload,modals:[...o.modals,r.payload]};case"CLOSE":return{current:o.modals[o.modals.length-2]||null,modals:o.modals.filter(e=>e.id!==r.payload)};case"CLOSE_ALL":return{current:o.current,modals:[]};default:return o}}var oo=Object.defineProperty,ro=Object.defineProperties,eo=Object.getOwnPropertyDescriptors,g=Object.getOwnPropertySymbols,K=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable,H=(o,r,e)=>r in o?oo(o,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[r]=e,E=(o,r)=>{for(var e in r||(r={}))K.call(r,e)&&H(o,e,r[e]);if(g)for(var e of g(r))Q.call(r,e)&&H(o,e,r[e]);return o},J=(o,r)=>ro(o,eo(r)),N=(o,r)=>{var e={};for(var c in o)K.call(o,c)&&r.indexOf(c)<0&&(e[c]=o[c]);if(o!=null&&g)for(var c of g(o))r.indexOf(c)<0&&Q.call(o,c)&&(e[c]=o[c]);return e};function to(o){if(!o)return{confirmProps:{},modalProps:{}};let r=o,{id:e,children:c,onCancel:n,onConfirm:s,closeOnConfirm:m,closeOnCancel:u,cancelProps:f,confirmProps:v,groupProps:_,labels:y}=r,P=N(r,["id","children","onCancel","onConfirm","closeOnConfirm","closeOnCancel","cancelProps","confirmProps","groupProps","labels"]);return{confirmProps:{id:e,children:c,onCancel:n,onConfirm:s,closeOnConfirm:m,closeOnCancel:u,cancelProps:f,confirmProps:v,groupProps:_,labels:y},modalProps:E({id:e},P)}}function no({children:o,modalProps:r,labels:e,modals:c}){let[n,s]=k(z,{modals:[],current:null}),m=l=>{n.modals.forEach(t=>{var a,p,i,O;t.type==="confirm"&&l&&((p=(a=t.props)==null?void 0:a.onCancel)==null||p.call(a)),(O=(i=t.props)==null?void 0:i.onClose)==null||O.call(i)}),s({type:"CLOSE_ALL"})},u=l=>{let t=l.id||x();return s({type:"OPEN",payload:{id:t,type:"content",props:l}}),t},f=l=>{let t=l.id||x();return s({type:"OPEN",payload:{id:t,type:"confirm",props:l}}),t},v=(l,t)=>{let a=t.id||x();return s({type:"OPEN",payload:{id:a,type:"context",props:t,ctx:l}}),a},_=(l,t)=>{var a,p,i,O;if(n.modals.length<=1){m(t);return}let C=n.modals.find(U=>U.id===l);C?.type==="confirm"&&t&&((p=(a=C.props)==null?void 0:a.onCancel)==null||p.call(a)),(O=(i=C?.props)==null?void 0:i.onClose)==null||O.call(i),s({type:"CLOSE",payload:C.id})},y={modals:n.modals,openModal:u,openConfirmModal:f,openContextModal:v,closeModal:_,closeAll:m},P=()=>{var l;switch((l=n.current)==null?void 0:l.type){case"context":{let t=n.current.props,{innerProps:a}=t,p=N(t,["innerProps"]),i=c[n.current.ctx];return{modalProps:p,content:d.createElement(i,{innerProps:a,context:y,id:n.current.id})}}case"confirm":{let{modalProps:t,confirmProps:a}=to(n.current.props);return{modalProps:t,content:d.createElement(q,J(E({},a),{id:n.current.id,labels:n.current.props.labels||e}))}}case"content":{let t=n.current.props,{children:a}=t;return{modalProps:N(t,["children"]),content:d.createElement(d.Fragment,null,a)}}default:return{modalProps:{},content:null}}},{modalProps:w,content:b}=P();return d.createElement(h.Provider,{value:y},d.createElement(F,J(E(E({},r),w),{opened:n.modals.length>0,onClose:()=>_(n.current.id)}),b),o)}function bo(){let o=D();return{overlayColor:o.colorScheme==="dark"?o.colors.dark[9]:o.colors.gray[2],overlayOpacity:.55,overlayBlur:3}}export{j as a,no as b,bo as c};
1
+ import{A as D,K as x,R as A,b as k,da as L,fa as B,i as I,ra as F,v as d,y as M}from"./chunk-LROR6N3B.js";import{j as R}from"./chunk-KUCVLANF.js";M();M();var h=R(null);h.displayName="@mantine/modals/ModalsContext";function j(){let o=I(h);if(!o)throw new Error("[@mantine/modals] useModals hook was called outside of context, wrap your app with ModalsProvider component");return o}M();M();var W=Object.defineProperty,X=Object.defineProperties,Y=Object.getOwnPropertyDescriptors,T=Object.getOwnPropertySymbols,Z=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable,V=(o,r,e)=>r in o?W(o,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[r]=e,S=(o,r)=>{for(var e in r||(r={}))Z.call(r,e)&&V(o,e,r[e]);if(T)for(var e of T(r))$.call(r,e)&&V(o,e,r[e]);return o},G=(o,r)=>X(o,Y(r));function q({id:o,cancelProps:r,confirmProps:e,labels:c={cancel:"",confirm:""},closeOnConfirm:n=!0,closeOnCancel:s=!0,groupProps:m,onCancel:u,onConfirm:f,children:v}){let{cancel:_,confirm:y}=c,P=j(),w=l=>{typeof r?.onClick=="function"&&r?.onClick(l),typeof u=="function"&&u(),s&&P.closeModal(o)},b=l=>{typeof e?.onClick=="function"&&e?.onClick(l),typeof f=="function"&&f(),n&&P.closeModal(o)};return d.createElement(d.Fragment,null,v&&d.createElement(A,{mb:"md"},v),d.createElement(B,S({position:"right"},m),d.createElement(L,G(S({variant:"default"},r),{onClick:w}),r?.children||_),d.createElement(L,G(S({},e),{onClick:b}),e?.children||y)))}function z(o,r){switch(r.type){case"OPEN":return{current:r.payload,modals:[...o.modals,r.payload]};case"CLOSE":return{current:o.modals[o.modals.length-2]||null,modals:o.modals.filter(e=>e.id!==r.payload)};case"CLOSE_ALL":return{current:o.current,modals:[]};default:return o}}var oo=Object.defineProperty,ro=Object.defineProperties,eo=Object.getOwnPropertyDescriptors,g=Object.getOwnPropertySymbols,K=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable,H=(o,r,e)=>r in o?oo(o,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[r]=e,E=(o,r)=>{for(var e in r||(r={}))K.call(r,e)&&H(o,e,r[e]);if(g)for(var e of g(r))Q.call(r,e)&&H(o,e,r[e]);return o},J=(o,r)=>ro(o,eo(r)),N=(o,r)=>{var e={};for(var c in o)K.call(o,c)&&r.indexOf(c)<0&&(e[c]=o[c]);if(o!=null&&g)for(var c of g(o))r.indexOf(c)<0&&Q.call(o,c)&&(e[c]=o[c]);return e};function to(o){if(!o)return{confirmProps:{},modalProps:{}};let r=o,{id:e,children:c,onCancel:n,onConfirm:s,closeOnConfirm:m,closeOnCancel:u,cancelProps:f,confirmProps:v,groupProps:_,labels:y}=r,P=N(r,["id","children","onCancel","onConfirm","closeOnConfirm","closeOnCancel","cancelProps","confirmProps","groupProps","labels"]);return{confirmProps:{id:e,children:c,onCancel:n,onConfirm:s,closeOnConfirm:m,closeOnCancel:u,cancelProps:f,confirmProps:v,groupProps:_,labels:y},modalProps:E({id:e},P)}}function no({children:o,modalProps:r,labels:e,modals:c}){let[n,s]=k(z,{modals:[],current:null}),m=l=>{n.modals.forEach(t=>{var a,p,i,O;t.type==="confirm"&&l&&((p=(a=t.props)==null?void 0:a.onCancel)==null||p.call(a)),(O=(i=t.props)==null?void 0:i.onClose)==null||O.call(i)}),s({type:"CLOSE_ALL"})},u=l=>{let t=l.id||x();return s({type:"OPEN",payload:{id:t,type:"content",props:l}}),t},f=l=>{let t=l.id||x();return s({type:"OPEN",payload:{id:t,type:"confirm",props:l}}),t},v=(l,t)=>{let a=t.id||x();return s({type:"OPEN",payload:{id:a,type:"context",props:t,ctx:l}}),a},_=(l,t)=>{var a,p,i,O;if(n.modals.length<=1){m(t);return}let C=n.modals.find(U=>U.id===l);C?.type==="confirm"&&t&&((p=(a=C.props)==null?void 0:a.onCancel)==null||p.call(a)),(O=(i=C?.props)==null?void 0:i.onClose)==null||O.call(i),s({type:"CLOSE",payload:C.id})},y={modals:n.modals,openModal:u,openConfirmModal:f,openContextModal:v,closeModal:_,closeAll:m},P=()=>{var l;switch((l=n.current)==null?void 0:l.type){case"context":{let t=n.current.props,{innerProps:a}=t,p=N(t,["innerProps"]),i=c[n.current.ctx];return{modalProps:p,content:d.createElement(i,{innerProps:a,context:y,id:n.current.id})}}case"confirm":{let{modalProps:t,confirmProps:a}=to(n.current.props);return{modalProps:t,content:d.createElement(q,J(E({},a),{id:n.current.id,labels:n.current.props.labels||e}))}}case"content":{let t=n.current.props,{children:a}=t;return{modalProps:N(t,["children"]),content:d.createElement(d.Fragment,null,a)}}default:return{modalProps:{},content:null}}},{modalProps:w,content:b}=P();return d.createElement(h.Provider,{value:y},d.createElement(F,J(E(E({},r),w),{opened:n.modals.length>0,onClose:()=>_(n.current.id)}),b),o)}function bo(){let o=D();return{overlayColor:o.colorScheme==="dark"?o.colors.dark[9]:o.colors.gray[2],overlayOpacity:.55,overlayBlur:3}}export{j as a,no as b,bo as c};
@@ -1 +1 @@
1
- import{c as Q,e as z,f as N,g as Z}from"./chunk-HKINZLMW.js";import{a as ee}from"./chunk-YDO2EDVY.js";import{a as G,c as K,n as g,p as P,q as B,u as b}from"./chunk-EGEB6N4J.js";import{c as V,e as O,h as S,k as L,y as j}from"./chunk-NZHF733K.js";import{b as ie,d as ne}from"./chunk-PVAE643M.js";var re=ie((ke,te)=>{"use strict";function fe(e,t){if(typeof e!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let r,o=0;return function(...a){clearTimeout(r);let n=Date.now(),c=n-o,d=t-c;d<=0?(o=n,e.apply(this,a)):r=setTimeout(()=>{o=Date.now(),e.apply(this,a)},d)}}te.exports=fe});j();var se=ne(re(),1);j();j();var oe=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},i=(e,t,r)=>(oe(e,t,"read from private field"),r?r.call(e):t.get(e)),p=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},C=(e,t,r,o)=>(oe(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r);function me(e,t){return t!=null?(0,se.default)(e,t):e}var y,U,W,$,k,R,A,J,X,Ie=class{constructor(e=[]){p(this,y,void 0),p(this,U,"ready"),p(this,W,void 0),p(this,$,new Set),p(this,k,new Set),p(this,R,new Set),this.pushMessage=t=>{C(this,y,i(this,y).concat(t)),i(this,A).call(this)},this.popMessage=()=>{C(this,y,i(this,y).slice(0,-1)),i(this,A).call(this)},this.replaceMessage=(t,r)=>{C(this,y,[...i(this,y).slice(0,t),this.snapshot(r),...i(this,y).slice(t+1)]),i(this,A).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,r)=>{let o=r?me(t,r):t;return i(this,$).add(o),()=>{i(this,$).delete(o)}},this["~registerStatusCallback"]=t=>(i(this,k).add(t),()=>{i(this,k).delete(t)}),this["~registerErrorCallback"]=t=>(i(this,R).add(t),()=>{i(this,R).delete(t)}),p(this,A,()=>{i(this,$).forEach(t=>t())}),p(this,J,()=>{i(this,k).forEach(t=>t())}),p(this,X,()=>{i(this,R).forEach(t=>t())}),C(this,y,e)}get status(){return i(this,U)}set status(e){C(this,U,e),i(this,J).call(this)}get error(){return i(this,W)}set error(e){C(this,W,e),i(this,X).call(this)}get messages(){return i(this,y)}set messages(e){C(this,y,[...e]),i(this,A).call(this)}};y=new WeakMap;U=new WeakMap;W=new WeakMap;$=new WeakMap;k=new WeakMap;R=new WeakMap;A=new WeakMap;J=new WeakMap;X=new WeakMap;var x,ae=class extends Q{constructor({messages:e,...t}){let r=new Ie(e);super({...t,state:r}),p(this,x,void 0),this["~registerMessagesCallback"]=(o,s)=>i(this,x)["~registerMessagesCallback"](o,s),this["~registerStatusCallback"]=o=>i(this,x)["~registerStatusCallback"](o),this["~registerErrorCallback"]=o=>i(this,x)["~registerErrorCallback"](o),C(this,x,r)}};x=new WeakMap;function Le({experimental_throttle:e,resume:t=!1,...r}={}){let o=O("chat"in r?{}:{onToolCall:r.onToolCall,onData:r.onData,onFinish:r.onFinish,onError:r.onError,sendAutomaticallyWhen:r.sendAutomaticallyWhen});"chat"in r||(o.current={onToolCall:r.onToolCall,onData:r.onData,onFinish:r.onFinish,onError:r.onError,sendAutomaticallyWhen:r.sendAutomaticallyWhen});let s={...r,onToolCall:u=>{var h,m;return(m=(h=o.current).onToolCall)==null?void 0:m.call(h,u)},onData:u=>{var h,m;return(m=(h=o.current).onData)==null?void 0:m.call(h,u)},onFinish:u=>{var h,m;return(m=(h=o.current).onFinish)==null?void 0:m.call(h,u)},onError:u=>{var h,m;return(m=(h=o.current).onError)==null?void 0:m.call(h,u)},sendAutomaticallyWhen:u=>{var h,m,H;return(H=(m=(h=o.current).sendAutomaticallyWhen)==null?void 0:m.call(h,u))!=null?H:!1}},a=O("chat"in r?r.chat:new ae(s));("chat"in r&&r.chat!==a.current||"id"in r&&a.current.id!==r.id)&&(a.current="chat"in r?r.chat:new ae(s));let c=S(u=>a.current["~registerMessagesCallback"](u,e),[e,a.current.id]),d=L(c,()=>a.current.messages,()=>a.current.messages),f=L(a.current["~registerStatusCallback"],()=>a.current.status,()=>a.current.status),l=L(a.current["~registerErrorCallback"],()=>a.current.error,()=>a.current.error),I=S(u=>{typeof u=="function"&&(u=u(a.current.messages)),a.current.messages=u},[a]);return V(()=>{t&&a.current.resumeStream()},[t,a]),{id:a.current.id,messages:d,setMessages:I,sendMessage:a.current.sendMessage,regenerate:a.current.regenerate,clearError:a.current.clearError,stop:a.current.stop,error:l,resumeStream:a.current.resumeStream,status:f,addToolResult:a.current.addToolOutput,addToolOutput:a.current.addToolOutput,addToolApprovalResponse:a.current.addToolApprovalResponse}}var Y=null;function _(){return Y||(Y=import("./ai-tools-5E5ELLZX.js")),Y}var ge=["doc_set","doc_create","doc_updateField","doc_edit","doc_duplicate"];function ye(e){return ge.includes(e)}function E(){let e=window;return{rootConfig:e.__ROOT_CTX.rootConfig,firebase:e.firebase}}function ve(e){let{collection:t,slug:r}=D(e);return`/cms/content/${encodeURIComponent(t)}/${encodeURIComponent(r)}`}function D(e){let t=e.indexOf("/");if(t<=0||t===e.length-1)throw new Error(`invalid docId: "${e}" (expected "Collection/slug")`);return{collection:e.slice(0,t),slug:e.slice(t+1).replace(/\//g,"--")}}function w(e){let{collection:t,slug:r}=D(e),{firebase:o,rootConfig:s}=E();return K(o.db,"Projects",s.projectId,"Collections",t,"Drafts",r)}function M(e){return Z(e,{isTimestamp:t=>t instanceof G,timestampToValue:t=>t.toMillis()})}function we(e){return JSON.parse(JSON.stringify(e??null))}function q(e){if(typeof e!="string")return e;let t=e.trim();if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]"))try{return JSON.parse(t)}catch{return e}return e}function ce(e){return Array.isArray(e)?e.map(t=>{let r={op:t?.op,path:t?.path};return t&&"value"in t&&(r.value=q(t.value)),t&&t.index!==void 0&&t.index!==null&&(r.index=t.index),r}):[]}function de(e){switch(e.op){case"set":return`Set ${e.path}`;case"insert_item":return e.index===void 0?`Insert into ${e.path} (append)`:`Insert into ${e.path} at ${e.index}`;case"remove_item":return`Remove ${e.path}[${e.index}]`;default:return`${e.op} ${e.path}`}}function De(e,t,r){let o=t.split("."),s=e;for(let c=0;c<o.length-1;c++){let d=o[c],f=Array.isArray(s)?Number(d):d,l=o[c+1];(s[f]===void 0||s[f]===null)&&(s[f]=/^\d+$/.test(l)?[]:{}),s=s[f]}let a=o[o.length-1],n=Array.isArray(s)?Number(a):a;s[n]=r}async function le(e){let t=await g(w(e));if(!t.exists())return{found:!1,fields:{}};let r=t.data();return{found:!0,fields:M(r.fields||{}),raw:r}}function F(e){return{type:"cms-write-receipt",title:e.title,summary:e.summary,docId:e.docId,adminUrl:e.docId?ve(e.docId):void 0,details:[...e.details||[],{label:"Status",value:"Saved to draft"},{label:"Publishing",value:"Manual publish still required"}]}}function v(e){return{toolName:e.toolName,title:e.title,summary:e.summary,docId:e.docId,path:e.path,details:e.details||[],error:e.error,errors:e.errors,hint:e.hint}}async function Xe(e,t){if(!ye(e))throw new Error(`not a write tool: ${e}`);switch(e){case"doc_set":return pe(t);case"doc_create":return be(t);case"doc_updateField":return Ce(t);case"doc_edit":return _e(t);case"doc_duplicate":return Te(t)}}async function pe(e){let{collection:t}=D(e.docId),r=await T(t),{validateFields:o}=await _(),s=o(e.fields,r);if(s.length>0)return v({toolName:"doc_set",title:"Replace draft fields",summary:`Could not validate the replacement fields for ${e.docId}.`,docId:e.docId,error:"VALIDATION_FAILED",errors:s,hint:"The fields payload does not match the collection schema. Read the doc and schema, then retry with a valid payload."});let a=await le(e.docId);return{toolName:"doc_set",title:"Replace draft fields",summary:`Replace all draft fields for ${e.docId}.`,docId:e.docId,before:a.found?a.fields:{},after:e.fields||{},details:[{label:"Document",value:e.docId},{label:"Operation",value:a.found?"Replace draft":"Create draft"}]}}async function be(e){let{collection:t}=D(e.docId);if((await g(w(e.docId))).exists())return v({toolName:"doc_create",title:"Create draft document",summary:`${e.docId} already exists.`,docId:e.docId,error:"ALREADY_EXISTS",hint:"Use an unused slug, or use an update tool for the existing draft."});if(e.fields){let o=await T(t),{validateFields:s}=await _(),a=s(e.fields,o);if(a.length>0)return v({toolName:"doc_create",title:"Create draft document",summary:`Could not validate the initial fields for ${e.docId}.`,docId:e.docId,error:"VALIDATION_FAILED",errors:a,hint:"The fields payload does not match the collection schema."})}return{toolName:"doc_create",title:"Create draft document",summary:`Create ${e.docId} as a new draft document.`,docId:e.docId,before:{},after:e.fields||{},details:[{label:"Document",value:e.docId},{label:"Operation",value:"Create draft"}]}}async function Ce(e){let t=q(e.value),{collection:r}=D(e.docId),o=await T(r),{validateValueAtPath:s}=await _(),a=s(o,e.path,t);if(a.length>0)return v({toolName:"doc_updateField",title:"Update draft field",summary:`Could not validate ${e.path} for ${e.docId}.`,docId:e.docId,path:e.path,error:"VALIDATION_FAILED",errors:a,hint:"The value does not match the field schema. Inspect the doc and schema, then retry with a valid value."});let n=w(e.docId),c=await g(n);if(!c.exists())return v({toolName:"doc_updateField",title:"Update draft field",summary:`${e.docId} does not exist.`,docId:e.docId,path:e.path,error:"NOT_FOUND",hint:`Doc "${e.docId}" does not exist.`});let d=c.data(),f=z(d.fields||{},e.path);if(!f.ok)return v({toolName:"doc_updateField",title:"Update draft field",summary:`Could not resolve ${e.path} in ${e.docId}.`,docId:e.docId,path:e.path,error:"VALIDATION_FAILED",errors:[f.error],hint:"Use zero-based array indices for existing array items, or set the whole array field when appending or removing items."});let l=M(d.fields||{}),I=we(l);return De(I,e.path,t),{toolName:"doc_updateField",title:"Update draft field",summary:`Update ${e.path} in ${e.docId}.`,docId:e.docId,path:e.path,before:l,after:I,details:[{label:"Document",value:e.docId},{label:"Field path",value:e.path},{label:"Operation",value:"Update draft field"}]}}async function _e(e){let t=ce(e.operations),{collection:r}=D(e.docId),o=await T(r),s=await le(e.docId);if(!s.found)return v({toolName:"doc_edit",title:"Edit draft document",summary:`${e.docId} does not exist.`,docId:e.docId,error:"NOT_FOUND",hint:`Doc "${e.docId}" does not exist. Create it with \`doc_create\` first.`});let{applyDocEdits:a,validateFields:n}=await _(),c=a(s.fields,t);if(!c.ok)return v({toolName:"doc_edit",title:"Edit draft document",summary:`Operation ${c.error.opIndex+1} (${c.error.op}) could not be applied to ${e.docId}.`,docId:e.docId,error:"INVALID_OPERATION",errors:[c.error],hint:"Fix the failing operation. Use zero-based array indices, target arrays for insert_item/remove_item, and read the doc with `doc_get` to confirm the current shape."});let d=n(c.fields,o);return d.length>0?v({toolName:"doc_edit",title:"Edit draft document",summary:`The edits to ${e.docId} did not match the collection schema.`,docId:e.docId,error:"VALIDATION_FAILED",errors:d,hint:"The resulting fields do not match the collection schema. Inspect the doc and schema, then retry with valid values."}):{toolName:"doc_edit",title:"Edit draft document",summary:`Apply ${t.length} edit${t.length===1?"":"s"} to ${e.docId}.`,docId:e.docId,before:s.fields,after:c.fields,details:[{label:"Document",value:e.docId},...t.map((f,l)=>({label:`Operation ${l+1}`,value:de(f)}))]}}async function Te(e){let t=w(e.fromDocId),r=await g(t);if(!r.exists())return v({toolName:"doc_duplicate",title:"Duplicate draft document",summary:`${e.fromDocId} does not exist.`,docId:e.toDocId,error:"NOT_FOUND",hint:`Source doc "${e.fromDocId}" does not exist.`,details:[{label:"Source",value:e.fromDocId}]});let o=w(e.toDocId);if((await g(o)).exists())return v({toolName:"doc_duplicate",title:"Duplicate draft document",summary:`${e.toDocId} already exists.`,docId:e.toDocId,error:"ALREADY_EXISTS",hint:`Target doc "${e.toDocId}" already exists.`,details:[{label:"Source",value:e.fromDocId},{label:"Target",value:e.toDocId}]});let a=r.data(),n=M(a.fields||{});return{toolName:"doc_duplicate",title:"Duplicate draft document",summary:`Duplicate ${e.fromDocId} to ${e.toDocId}.`,docId:e.toDocId,before:{},after:n,details:[{label:"Source",value:e.fromDocId},{label:"Target",value:e.toDocId},{label:"Operation",value:"Create draft copy"}]}}async function T(e){return await ee(e)}async function Ae(e){let{collection:t,slug:r}=D(e.docId),o=await T(t),{validateFields:s}=await _(),a=s(e.fields,o);if(a.length>0)return{success:!1,docId:e.docId,error:"VALIDATION_FAILED",errors:a,hint:"The fields payload did not match the collection schema. Read the doc with `doc_get` for an example of the expected shape, then retry with a valid payload."};let{firebase:n}=E(),c=w(e.docId),d=await g(c),l=(d.exists()?d.data():{}).sys||{},I=n.user?.email||"root-cms-ai",u={id:e.docId,collection:t,slug:r,sys:{...l,createdAt:l.createdAt??b(),createdBy:l.createdBy??I,modifiedAt:b(),modifiedBy:I,locales:l.locales??["en"]},fields:N(e.fields)};return await P(c,u),{success:!0,docId:e.docId,receipt:F({title:"Updated draft document",summary:`Replaced all draft fields for ${e.docId}.`,docId:e.docId,details:[{label:"Document",value:e.docId},{label:"Operation",value:"Replace draft fields"}]})}}async function xe(e){let{collection:t,slug:r}=D(e.docId),o=w(e.docId);if((await g(o)).exists())return{success:!1,docId:e.docId,error:"ALREADY_EXISTS",hint:"A doc with this id already exists. Use `doc_set` to overwrite."};if(e.fields){let d=await T(t),{validateFields:f}=await _(),l=f(e.fields,d);if(l.length>0)return{success:!1,docId:e.docId,error:"VALIDATION_FAILED",errors:l,hint:"The fields payload did not match the collection schema."}}let{firebase:a}=E(),n=a.user?.email||"root-cms-ai",c={id:e.docId,collection:t,slug:r,sys:{createdAt:b(),createdBy:n,modifiedAt:b(),modifiedBy:n,locales:["en"]},fields:e.fields?N(e.fields):{}};return await P(o,c),{success:!0,docId:e.docId,receipt:F({title:"Created draft document",summary:`Created ${e.docId} as a new draft document.`,docId:e.docId,details:[{label:"Document",value:e.docId},{label:"Operation",value:"Create draft"}]})}}async function Ee(e){let t=q(e.value),{collection:r}=D(e.docId),o=await T(r),{validateValueAtPath:s}=await _(),a=s(o,e.path,t);if(a.length>0)return{success:!1,docId:e.docId,path:e.path,error:"VALIDATION_FAILED",errors:a,hint:"The value did not match the field schema. Inspect the doc with `doc_get` to see the expected shape, then retry with a valid value."};let n=w(e.docId),c=await g(n);if(!c.exists())return{success:!1,docId:e.docId,path:e.path,error:"NOT_FOUND",hint:`Doc "${e.docId}" does not exist.`};let d=c.data(),f=z(d.fields||{},e.path);if(!f.ok)return{success:!1,docId:e.docId,path:e.path,error:"VALIDATION_FAILED",errors:[f.error],hint:"The path could not be resolved against the current draft. Use zero-based array indices for existing array items, or set the whole array field when appending or removing items."};let{firebase:l}=E(),I=`fields.${f.path}`,u=N(t);return await B(n,{[I]:u,"sys.modifiedAt":b(),"sys.modifiedBy":l.user?.email||"root-cms-ai"}),{success:!0,docId:e.docId,path:e.path,receipt:F({title:"Updated draft field",summary:`Updated ${e.path} in ${e.docId}.`,docId:e.docId,details:[{label:"Document",value:e.docId},{label:"Field path",value:e.path},{label:"Operation",value:"Update draft field"}]})}}async function Oe(e){let t=ce(e.operations),{collection:r}=D(e.docId),o=await T(r),s=w(e.docId),a=await g(s);if(!a.exists())return{success:!1,docId:e.docId,error:"NOT_FOUND",hint:`Doc "${e.docId}" does not exist.`};let n=a.data(),c=M(n.fields||{}),{applyDocEdits:d,validateFields:f}=await _(),l=d(c,t);if(!l.ok)return{success:!1,docId:e.docId,error:"INVALID_OPERATION",errors:[l.error],hint:"Fix the failing operation. Use zero-based array indices, target arrays for insert_item/remove_item, and read the doc with `doc_get` to confirm the current shape."};let I=f(l.fields,o);if(I.length>0)return{success:!1,docId:e.docId,error:"VALIDATION_FAILED",errors:I,hint:"The resulting fields did not match the collection schema. Inspect the doc with `doc_get`, then retry with valid values."};let{firebase:u}=E();return await B(s,{fields:N(l.fields),"sys.modifiedAt":b(),"sys.modifiedBy":u.user?.email||"root-cms-ai"}),{success:!0,docId:e.docId,receipt:F({title:"Edited draft document",summary:`Applied ${t.length} edit${t.length===1?"":"s"} to ${e.docId}.`,docId:e.docId,details:[{label:"Document",value:e.docId},{label:"Operations",value:String(t.length)},...t.map((h,m)=>({label:`Operation ${m+1}`,value:de(h)}))]})}}async function Se(e){let t=w(e.fromDocId),r=await g(t);if(!r.exists())return{success:!1,error:"NOT_FOUND",hint:`Source doc "${e.fromDocId}" does not exist.`};let o=w(e.toDocId);if((await g(o)).exists())return{success:!1,error:"ALREADY_EXISTS",hint:`Target doc "${e.toDocId}" already exists.`};let{collection:a,slug:n}=D(e.toDocId),{firebase:c}=E(),d=c.user?.email||"root-cms-ai",f=r.data(),l={id:e.toDocId,collection:a,slug:n,sys:{createdAt:b(),createdBy:d,modifiedAt:b(),modifiedBy:d,locales:f.sys?.locales??["en"]},fields:f.fields||{}};return await P(o,l),{success:!0,fromDocId:e.fromDocId,toDocId:e.toDocId,receipt:F({title:"Duplicated draft document",summary:`Duplicated ${e.fromDocId} to ${e.toDocId}.`,docId:e.toDocId,details:[{label:"Source",value:e.fromDocId},{label:"Target",value:e.toDocId},{label:"Operation",value:"Create draft copy"}]})}}async function Ne(e){let t=await fetch("/cms/api/ai.translate",{method:"POST",credentials:"include",headers:{"content-type":"application/json"},body:JSON.stringify({sourceText:e.sourceText,targetLocales:e.targetLocales,description:e.description})});if(!t.ok)throw new Error(`ai.translate failed: ${t.status}`);let r=await t.json();if(!r.success)throw new Error(r.error||"translation failed");return{translations:r.translations}}var $e={doc_set:Ae,doc_create:xe,doc_updateField:Ee,doc_edit:Oe,doc_duplicate:Se,doc_translateField:Ne};async function Ye(e,t){let r=$e[e];if(!r)return{error:"UNKNOWN_TOOL",toolName:e};try{return await r(t)}catch(o){return console.error(`tool ${e} failed:`,o),{error:"TOOL_EXECUTION_FAILED",message:o?.message||String(o)}}}export{Le as a,ye as b,Xe as c,Ye as d};
1
+ import{c as Q,e as z,f as N,g as Z}from"./chunk-344GZOGG.js";import{a as ee}from"./chunk-YDO2EDVY.js";import{a as G,c as K,n as g,p as P,q as B,v as b}from"./chunk-VD6G5NV4.js";import{c as V,e as O,h as S,k as L,y as j}from"./chunk-LROR6N3B.js";import{b as ie,d as ne}from"./chunk-PVAE643M.js";var re=ie((ke,te)=>{"use strict";function fe(e,t){if(typeof e!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let r,o=0;return function(...a){clearTimeout(r);let n=Date.now(),c=n-o,d=t-c;d<=0?(o=n,e.apply(this,a)):r=setTimeout(()=>{o=Date.now(),e.apply(this,a)},d)}}te.exports=fe});j();var se=ne(re(),1);j();j();var oe=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},i=(e,t,r)=>(oe(e,t,"read from private field"),r?r.call(e):t.get(e)),p=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},C=(e,t,r,o)=>(oe(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r);function me(e,t){return t!=null?(0,se.default)(e,t):e}var y,U,W,$,k,R,A,J,X,Ie=class{constructor(e=[]){p(this,y,void 0),p(this,U,"ready"),p(this,W,void 0),p(this,$,new Set),p(this,k,new Set),p(this,R,new Set),this.pushMessage=t=>{C(this,y,i(this,y).concat(t)),i(this,A).call(this)},this.popMessage=()=>{C(this,y,i(this,y).slice(0,-1)),i(this,A).call(this)},this.replaceMessage=(t,r)=>{C(this,y,[...i(this,y).slice(0,t),this.snapshot(r),...i(this,y).slice(t+1)]),i(this,A).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,r)=>{let o=r?me(t,r):t;return i(this,$).add(o),()=>{i(this,$).delete(o)}},this["~registerStatusCallback"]=t=>(i(this,k).add(t),()=>{i(this,k).delete(t)}),this["~registerErrorCallback"]=t=>(i(this,R).add(t),()=>{i(this,R).delete(t)}),p(this,A,()=>{i(this,$).forEach(t=>t())}),p(this,J,()=>{i(this,k).forEach(t=>t())}),p(this,X,()=>{i(this,R).forEach(t=>t())}),C(this,y,e)}get status(){return i(this,U)}set status(e){C(this,U,e),i(this,J).call(this)}get error(){return i(this,W)}set error(e){C(this,W,e),i(this,X).call(this)}get messages(){return i(this,y)}set messages(e){C(this,y,[...e]),i(this,A).call(this)}};y=new WeakMap;U=new WeakMap;W=new WeakMap;$=new WeakMap;k=new WeakMap;R=new WeakMap;A=new WeakMap;J=new WeakMap;X=new WeakMap;var x,ae=class extends Q{constructor({messages:e,...t}){let r=new Ie(e);super({...t,state:r}),p(this,x,void 0),this["~registerMessagesCallback"]=(o,s)=>i(this,x)["~registerMessagesCallback"](o,s),this["~registerStatusCallback"]=o=>i(this,x)["~registerStatusCallback"](o),this["~registerErrorCallback"]=o=>i(this,x)["~registerErrorCallback"](o),C(this,x,r)}};x=new WeakMap;function Le({experimental_throttle:e,resume:t=!1,...r}={}){let o=O("chat"in r?{}:{onToolCall:r.onToolCall,onData:r.onData,onFinish:r.onFinish,onError:r.onError,sendAutomaticallyWhen:r.sendAutomaticallyWhen});"chat"in r||(o.current={onToolCall:r.onToolCall,onData:r.onData,onFinish:r.onFinish,onError:r.onError,sendAutomaticallyWhen:r.sendAutomaticallyWhen});let s={...r,onToolCall:u=>{var h,m;return(m=(h=o.current).onToolCall)==null?void 0:m.call(h,u)},onData:u=>{var h,m;return(m=(h=o.current).onData)==null?void 0:m.call(h,u)},onFinish:u=>{var h,m;return(m=(h=o.current).onFinish)==null?void 0:m.call(h,u)},onError:u=>{var h,m;return(m=(h=o.current).onError)==null?void 0:m.call(h,u)},sendAutomaticallyWhen:u=>{var h,m,H;return(H=(m=(h=o.current).sendAutomaticallyWhen)==null?void 0:m.call(h,u))!=null?H:!1}},a=O("chat"in r?r.chat:new ae(s));("chat"in r&&r.chat!==a.current||"id"in r&&a.current.id!==r.id)&&(a.current="chat"in r?r.chat:new ae(s));let c=S(u=>a.current["~registerMessagesCallback"](u,e),[e,a.current.id]),d=L(c,()=>a.current.messages,()=>a.current.messages),f=L(a.current["~registerStatusCallback"],()=>a.current.status,()=>a.current.status),l=L(a.current["~registerErrorCallback"],()=>a.current.error,()=>a.current.error),I=S(u=>{typeof u=="function"&&(u=u(a.current.messages)),a.current.messages=u},[a]);return V(()=>{t&&a.current.resumeStream()},[t,a]),{id:a.current.id,messages:d,setMessages:I,sendMessage:a.current.sendMessage,regenerate:a.current.regenerate,clearError:a.current.clearError,stop:a.current.stop,error:l,resumeStream:a.current.resumeStream,status:f,addToolResult:a.current.addToolOutput,addToolOutput:a.current.addToolOutput,addToolApprovalResponse:a.current.addToolApprovalResponse}}var Y=null;function _(){return Y||(Y=import("./ai-tools-4DWMFQS6.js")),Y}var ge=["doc_set","doc_create","doc_updateField","doc_edit","doc_duplicate"];function ye(e){return ge.includes(e)}function E(){let e=window;return{rootConfig:e.__ROOT_CTX.rootConfig,firebase:e.firebase}}function ve(e){let{collection:t,slug:r}=D(e);return`/cms/content/${encodeURIComponent(t)}/${encodeURIComponent(r)}`}function D(e){let t=e.indexOf("/");if(t<=0||t===e.length-1)throw new Error(`invalid docId: "${e}" (expected "Collection/slug")`);return{collection:e.slice(0,t),slug:e.slice(t+1).replace(/\//g,"--")}}function w(e){let{collection:t,slug:r}=D(e),{firebase:o,rootConfig:s}=E();return K(o.db,"Projects",s.projectId,"Collections",t,"Drafts",r)}function M(e){return Z(e,{isTimestamp:t=>t instanceof G,timestampToValue:t=>t.toMillis()})}function we(e){return JSON.parse(JSON.stringify(e??null))}function q(e){if(typeof e!="string")return e;let t=e.trim();if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]"))try{return JSON.parse(t)}catch{return e}return e}function ce(e){return Array.isArray(e)?e.map(t=>{let r={op:t?.op,path:t?.path};return t&&"value"in t&&(r.value=q(t.value)),t&&t.index!==void 0&&t.index!==null&&(r.index=t.index),r}):[]}function de(e){switch(e.op){case"set":return`Set ${e.path}`;case"insert_item":return e.index===void 0?`Insert into ${e.path} (append)`:`Insert into ${e.path} at ${e.index}`;case"remove_item":return`Remove ${e.path}[${e.index}]`;default:return`${e.op} ${e.path}`}}function De(e,t,r){let o=t.split("."),s=e;for(let c=0;c<o.length-1;c++){let d=o[c],f=Array.isArray(s)?Number(d):d,l=o[c+1];(s[f]===void 0||s[f]===null)&&(s[f]=/^\d+$/.test(l)?[]:{}),s=s[f]}let a=o[o.length-1],n=Array.isArray(s)?Number(a):a;s[n]=r}async function le(e){let t=await g(w(e));if(!t.exists())return{found:!1,fields:{}};let r=t.data();return{found:!0,fields:M(r.fields||{}),raw:r}}function F(e){return{type:"cms-write-receipt",title:e.title,summary:e.summary,docId:e.docId,adminUrl:e.docId?ve(e.docId):void 0,details:[...e.details||[],{label:"Status",value:"Saved to draft"},{label:"Publishing",value:"Manual publish still required"}]}}function v(e){return{toolName:e.toolName,title:e.title,summary:e.summary,docId:e.docId,path:e.path,details:e.details||[],error:e.error,errors:e.errors,hint:e.hint}}async function Xe(e,t){if(!ye(e))throw new Error(`not a write tool: ${e}`);switch(e){case"doc_set":return pe(t);case"doc_create":return be(t);case"doc_updateField":return Ce(t);case"doc_edit":return _e(t);case"doc_duplicate":return Te(t)}}async function pe(e){let{collection:t}=D(e.docId),r=await T(t),{validateFields:o}=await _(),s=o(e.fields,r);if(s.length>0)return v({toolName:"doc_set",title:"Replace draft fields",summary:`Could not validate the replacement fields for ${e.docId}.`,docId:e.docId,error:"VALIDATION_FAILED",errors:s,hint:"The fields payload does not match the collection schema. Read the doc and schema, then retry with a valid payload."});let a=await le(e.docId);return{toolName:"doc_set",title:"Replace draft fields",summary:`Replace all draft fields for ${e.docId}.`,docId:e.docId,before:a.found?a.fields:{},after:e.fields||{},details:[{label:"Document",value:e.docId},{label:"Operation",value:a.found?"Replace draft":"Create draft"}]}}async function be(e){let{collection:t}=D(e.docId);if((await g(w(e.docId))).exists())return v({toolName:"doc_create",title:"Create draft document",summary:`${e.docId} already exists.`,docId:e.docId,error:"ALREADY_EXISTS",hint:"Use an unused slug, or use an update tool for the existing draft."});if(e.fields){let o=await T(t),{validateFields:s}=await _(),a=s(e.fields,o);if(a.length>0)return v({toolName:"doc_create",title:"Create draft document",summary:`Could not validate the initial fields for ${e.docId}.`,docId:e.docId,error:"VALIDATION_FAILED",errors:a,hint:"The fields payload does not match the collection schema."})}return{toolName:"doc_create",title:"Create draft document",summary:`Create ${e.docId} as a new draft document.`,docId:e.docId,before:{},after:e.fields||{},details:[{label:"Document",value:e.docId},{label:"Operation",value:"Create draft"}]}}async function Ce(e){let t=q(e.value),{collection:r}=D(e.docId),o=await T(r),{validateValueAtPath:s}=await _(),a=s(o,e.path,t);if(a.length>0)return v({toolName:"doc_updateField",title:"Update draft field",summary:`Could not validate ${e.path} for ${e.docId}.`,docId:e.docId,path:e.path,error:"VALIDATION_FAILED",errors:a,hint:"The value does not match the field schema. Inspect the doc and schema, then retry with a valid value."});let n=w(e.docId),c=await g(n);if(!c.exists())return v({toolName:"doc_updateField",title:"Update draft field",summary:`${e.docId} does not exist.`,docId:e.docId,path:e.path,error:"NOT_FOUND",hint:`Doc "${e.docId}" does not exist.`});let d=c.data(),f=z(d.fields||{},e.path);if(!f.ok)return v({toolName:"doc_updateField",title:"Update draft field",summary:`Could not resolve ${e.path} in ${e.docId}.`,docId:e.docId,path:e.path,error:"VALIDATION_FAILED",errors:[f.error],hint:"Use zero-based array indices for existing array items, or set the whole array field when appending or removing items."});let l=M(d.fields||{}),I=we(l);return De(I,e.path,t),{toolName:"doc_updateField",title:"Update draft field",summary:`Update ${e.path} in ${e.docId}.`,docId:e.docId,path:e.path,before:l,after:I,details:[{label:"Document",value:e.docId},{label:"Field path",value:e.path},{label:"Operation",value:"Update draft field"}]}}async function _e(e){let t=ce(e.operations),{collection:r}=D(e.docId),o=await T(r),s=await le(e.docId);if(!s.found)return v({toolName:"doc_edit",title:"Edit draft document",summary:`${e.docId} does not exist.`,docId:e.docId,error:"NOT_FOUND",hint:`Doc "${e.docId}" does not exist. Create it with \`doc_create\` first.`});let{applyDocEdits:a,validateFields:n}=await _(),c=a(s.fields,t);if(!c.ok)return v({toolName:"doc_edit",title:"Edit draft document",summary:`Operation ${c.error.opIndex+1} (${c.error.op}) could not be applied to ${e.docId}.`,docId:e.docId,error:"INVALID_OPERATION",errors:[c.error],hint:"Fix the failing operation. Use zero-based array indices, target arrays for insert_item/remove_item, and read the doc with `doc_get` to confirm the current shape."});let d=n(c.fields,o);return d.length>0?v({toolName:"doc_edit",title:"Edit draft document",summary:`The edits to ${e.docId} did not match the collection schema.`,docId:e.docId,error:"VALIDATION_FAILED",errors:d,hint:"The resulting fields do not match the collection schema. Inspect the doc and schema, then retry with valid values."}):{toolName:"doc_edit",title:"Edit draft document",summary:`Apply ${t.length} edit${t.length===1?"":"s"} to ${e.docId}.`,docId:e.docId,before:s.fields,after:c.fields,details:[{label:"Document",value:e.docId},...t.map((f,l)=>({label:`Operation ${l+1}`,value:de(f)}))]}}async function Te(e){let t=w(e.fromDocId),r=await g(t);if(!r.exists())return v({toolName:"doc_duplicate",title:"Duplicate draft document",summary:`${e.fromDocId} does not exist.`,docId:e.toDocId,error:"NOT_FOUND",hint:`Source doc "${e.fromDocId}" does not exist.`,details:[{label:"Source",value:e.fromDocId}]});let o=w(e.toDocId);if((await g(o)).exists())return v({toolName:"doc_duplicate",title:"Duplicate draft document",summary:`${e.toDocId} already exists.`,docId:e.toDocId,error:"ALREADY_EXISTS",hint:`Target doc "${e.toDocId}" already exists.`,details:[{label:"Source",value:e.fromDocId},{label:"Target",value:e.toDocId}]});let a=r.data(),n=M(a.fields||{});return{toolName:"doc_duplicate",title:"Duplicate draft document",summary:`Duplicate ${e.fromDocId} to ${e.toDocId}.`,docId:e.toDocId,before:{},after:n,details:[{label:"Source",value:e.fromDocId},{label:"Target",value:e.toDocId},{label:"Operation",value:"Create draft copy"}]}}async function T(e){return await ee(e)}async function Ae(e){let{collection:t,slug:r}=D(e.docId),o=await T(t),{validateFields:s}=await _(),a=s(e.fields,o);if(a.length>0)return{success:!1,docId:e.docId,error:"VALIDATION_FAILED",errors:a,hint:"The fields payload did not match the collection schema. Read the doc with `doc_get` for an example of the expected shape, then retry with a valid payload."};let{firebase:n}=E(),c=w(e.docId),d=await g(c),l=(d.exists()?d.data():{}).sys||{},I=n.user?.email||"root-cms-ai",u={id:e.docId,collection:t,slug:r,sys:{...l,createdAt:l.createdAt??b(),createdBy:l.createdBy??I,modifiedAt:b(),modifiedBy:I,locales:l.locales??["en"]},fields:N(e.fields)};return await P(c,u),{success:!0,docId:e.docId,receipt:F({title:"Updated draft document",summary:`Replaced all draft fields for ${e.docId}.`,docId:e.docId,details:[{label:"Document",value:e.docId},{label:"Operation",value:"Replace draft fields"}]})}}async function xe(e){let{collection:t,slug:r}=D(e.docId),o=w(e.docId);if((await g(o)).exists())return{success:!1,docId:e.docId,error:"ALREADY_EXISTS",hint:"A doc with this id already exists. Use `doc_set` to overwrite."};if(e.fields){let d=await T(t),{validateFields:f}=await _(),l=f(e.fields,d);if(l.length>0)return{success:!1,docId:e.docId,error:"VALIDATION_FAILED",errors:l,hint:"The fields payload did not match the collection schema."}}let{firebase:a}=E(),n=a.user?.email||"root-cms-ai",c={id:e.docId,collection:t,slug:r,sys:{createdAt:b(),createdBy:n,modifiedAt:b(),modifiedBy:n,locales:["en"]},fields:e.fields?N(e.fields):{}};return await P(o,c),{success:!0,docId:e.docId,receipt:F({title:"Created draft document",summary:`Created ${e.docId} as a new draft document.`,docId:e.docId,details:[{label:"Document",value:e.docId},{label:"Operation",value:"Create draft"}]})}}async function Ee(e){let t=q(e.value),{collection:r}=D(e.docId),o=await T(r),{validateValueAtPath:s}=await _(),a=s(o,e.path,t);if(a.length>0)return{success:!1,docId:e.docId,path:e.path,error:"VALIDATION_FAILED",errors:a,hint:"The value did not match the field schema. Inspect the doc with `doc_get` to see the expected shape, then retry with a valid value."};let n=w(e.docId),c=await g(n);if(!c.exists())return{success:!1,docId:e.docId,path:e.path,error:"NOT_FOUND",hint:`Doc "${e.docId}" does not exist.`};let d=c.data(),f=z(d.fields||{},e.path);if(!f.ok)return{success:!1,docId:e.docId,path:e.path,error:"VALIDATION_FAILED",errors:[f.error],hint:"The path could not be resolved against the current draft. Use zero-based array indices for existing array items, or set the whole array field when appending or removing items."};let{firebase:l}=E(),I=`fields.${f.path}`,u=N(t);return await B(n,{[I]:u,"sys.modifiedAt":b(),"sys.modifiedBy":l.user?.email||"root-cms-ai"}),{success:!0,docId:e.docId,path:e.path,receipt:F({title:"Updated draft field",summary:`Updated ${e.path} in ${e.docId}.`,docId:e.docId,details:[{label:"Document",value:e.docId},{label:"Field path",value:e.path},{label:"Operation",value:"Update draft field"}]})}}async function Oe(e){let t=ce(e.operations),{collection:r}=D(e.docId),o=await T(r),s=w(e.docId),a=await g(s);if(!a.exists())return{success:!1,docId:e.docId,error:"NOT_FOUND",hint:`Doc "${e.docId}" does not exist.`};let n=a.data(),c=M(n.fields||{}),{applyDocEdits:d,validateFields:f}=await _(),l=d(c,t);if(!l.ok)return{success:!1,docId:e.docId,error:"INVALID_OPERATION",errors:[l.error],hint:"Fix the failing operation. Use zero-based array indices, target arrays for insert_item/remove_item, and read the doc with `doc_get` to confirm the current shape."};let I=f(l.fields,o);if(I.length>0)return{success:!1,docId:e.docId,error:"VALIDATION_FAILED",errors:I,hint:"The resulting fields did not match the collection schema. Inspect the doc with `doc_get`, then retry with valid values."};let{firebase:u}=E();return await B(s,{fields:N(l.fields),"sys.modifiedAt":b(),"sys.modifiedBy":u.user?.email||"root-cms-ai"}),{success:!0,docId:e.docId,receipt:F({title:"Edited draft document",summary:`Applied ${t.length} edit${t.length===1?"":"s"} to ${e.docId}.`,docId:e.docId,details:[{label:"Document",value:e.docId},{label:"Operations",value:String(t.length)},...t.map((h,m)=>({label:`Operation ${m+1}`,value:de(h)}))]})}}async function Se(e){let t=w(e.fromDocId),r=await g(t);if(!r.exists())return{success:!1,error:"NOT_FOUND",hint:`Source doc "${e.fromDocId}" does not exist.`};let o=w(e.toDocId);if((await g(o)).exists())return{success:!1,error:"ALREADY_EXISTS",hint:`Target doc "${e.toDocId}" already exists.`};let{collection:a,slug:n}=D(e.toDocId),{firebase:c}=E(),d=c.user?.email||"root-cms-ai",f=r.data(),l={id:e.toDocId,collection:a,slug:n,sys:{createdAt:b(),createdBy:d,modifiedAt:b(),modifiedBy:d,locales:f.sys?.locales??["en"]},fields:f.fields||{}};return await P(o,l),{success:!0,fromDocId:e.fromDocId,toDocId:e.toDocId,receipt:F({title:"Duplicated draft document",summary:`Duplicated ${e.fromDocId} to ${e.toDocId}.`,docId:e.toDocId,details:[{label:"Source",value:e.fromDocId},{label:"Target",value:e.toDocId},{label:"Operation",value:"Create draft copy"}]})}}async function Ne(e){let t=await fetch("/cms/api/ai.translate",{method:"POST",credentials:"include",headers:{"content-type":"application/json"},body:JSON.stringify({sourceText:e.sourceText,targetLocales:e.targetLocales,description:e.description})});if(!t.ok)throw new Error(`ai.translate failed: ${t.status}`);let r=await t.json();if(!r.success)throw new Error(r.error||"translation failed");return{translations:r.translations}}var $e={doc_set:Ae,doc_create:xe,doc_updateField:Ee,doc_edit:Oe,doc_duplicate:Se,doc_translateField:Ne};async function Ye(e,t){let r=$e[e];if(!r)return{error:"UNKNOWN_TOOL",toolName:e};try{return await r(t)}catch(o){return console.error(`tool ${e} failed:`,o),{error:"TOOL_EXECUTION_FAILED",message:o?.message||String(o)}}}export{Le as a,ye as b,Xe as c,Ye as d};
@@ -1 +1 @@
1
- import{a as t}from"./chunk-I6ICVKEC.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-QHJOTXYB.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{c as b,n as x}from"./chunk-EGEB6N4J.js";async function A(){let r=window.firebase.db,e=window.__ROOT_CTX.rootConfig.projectId||"default",t=b(r,"Projects",e),s=await x(t);if(!s.exists)return[];let n=(s.data()||{}).roles||{},o=[];return Object.entries(n).forEach(([p,d])=>{(d==="ADMIN"||d==="EDITOR"||d==="CONTRIBUTOR")&&o.push(p)}),o}var E=class r{constructor(e){this.spreadsheetId=e}static async create(e){let t=e.share??!1,s={fields:"spreadsheetId"};e?.title&&(s.resource={properties:{title:e.title}});let n=(await gapi.client.sheets.spreadsheets.create(s)).result,o=new r(n.spreadsheetId);if(o.setSpreadsheet(n),e?.parent&&await gapi.client.drive.files.update({fileId:o.spreadsheetId,addParents:e.parent,removeParents:"root",fields:"id, parents",resource:{},supportsAllDrives:!0}),t)try{let p=await A();await o.share(p,"writer")}catch(p){console.warn("Failed to share spreadsheet:",p)}return o}getUrl(){return U({spreadsheetId:this.spreadsheetId})}async getSheet(e){if(this.sheets||await this.fetchSheets(),this.sheets){for(let t=0;t<this.sheets.length;t++)if(this.sheets[t].gid===e)return this.sheets[t]}return null}async createSheet(e){console.log("createSheet",this.spreadsheetId);let t=await gapi.client.sheets.spreadsheets.batchUpdate({spreadsheetId:this.spreadsheetId,resource:{requests:[{addSheet:{properties:{title:e.title}}}]}}),s=t.result.replies||[];if(s&&s.length>0){let i=s[0].addSheet?.properties?.sheetId;if(typeof i=="number")return new I(this,i,e.title)}throw console.error(t),new Error("failed to get gid of new tab")}async fetchSheets(){let t=(await gapi.client.sheets.spreadsheets.get({spreadsheetId:this.spreadsheetId,fields:"sheets.properties"})).result;this.setSpreadsheet(t)}setSpreadsheet(e){this.spreadsheet=e,this.spreadsheet.sheets&&this.setSheets(this.spreadsheet.sheets)}setSheets(e){let t=[];e.forEach(s=>{let i=s.properties?.sheetId,n=s.properties?.title,o=new I(this,i??0,n);t.push(o)}),this.sheets=t}async share(e,t){await Promise.all(e.map(async s=>{let i;s.startsWith("*@")?i={type:"domain",domain:s.slice(2),role:t}:i={type:"user",emailAddress:s,role:t},await gapi.client.drive.permissions.create({fileId:this.spreadsheetId,resource:i,sendNotificationEmail:!1,fields:"id",supportsAllDrives:!0})}))}},I=class{constructor(e,t,s){this.spreadsheet=e,this.gid=t,this.title=s}async updateValuesMap(e,t){let s=t.keyedBy,i=t.preserveColumns||[];if(!s)throw new Error('missing "keyedBy" argument');let[n,o]=await this.getValues(),p=[...n],d=[],w=-1,S=new Set;d.push(n.map((a,u)=>(a===s&&(w=u),i.includes(a)&&S.add(u),{hasChanges:!1,value:a})));function v(a){d[0].push({hasChanges:!0,value:a}),p.push(a)}w===-1&&v(s);let y={};o.forEach((a,u)=>{let h=u+1;d.push(a.map((c,l)=>(l===w&&c&&(c in y?console.warn(`multiple rows keyed by "${c}"`):y[c]=h),{hasChanges:!1,value:c})))});function O(a){for(let h in a)p.includes(h)||v(h);return p.map(h=>a[h]??null)}e.forEach(a=>{let u=O(a),h=a[s],c=y[h];if(c){let l=d[c];u.map((m,g)=>{g>=l.length?l.push({hasChanges:!0,value:m||""}):m!==null&&l[g].value!==m&&(!S.has(g)||!l[g].value)&&(l[g]={hasChanges:!0,value:m})})}else d.push(u.map(l=>({hasChanges:!!l,value:l||""})))});let C=p.length,R=d.length,$=n.length,F=o.length+1;(C>$||R>F)&&await this.resizeSheet({numCols:C+2,numRows:R+20});let f=[];d.forEach((a,u)=>{for(;a.length>0&&a.at(-1)?.hasChanges===!1;)a.pop();if(a.length!==0){if(a.every(h=>h.hasChanges)){f.push({range:`${this.title}!A${u+1}`,majorDimension:"ROWS",values:[a.map(h=>h.value||"")]});return}a.forEach((h,c)=>{if(h.hasChanges){let l=P(c);f.push({range:`${this.title}!${l}${u+1}`,majorDimension:"ROWS",values:[[h.value||""]]})}})}}),f.length>0&&await gapi.client.sheets.spreadsheets.values.batchUpdate({spreadsheetId:this.spreadsheet.spreadsheetId,resource:{data:f,valueInputOption:"RAW"}})}async replaceSheet(e,t){let s=e.length,i=t.length+1,n=[];n.push(e),n.push(...t.map(p=>e.map(d=>p[d]||""))),await this.resizeSheet({numCols:s+2,numRows:i+20}),console.log("updating cell values");let o=P(s-1);await gapi.client.sheets.spreadsheets.values.update({spreadsheetId:this.spreadsheet.spreadsheetId,range:`${this.title}!A1:${o}${i}`,valueInputOption:"RAW",resource:{range:`${this.title}!A1:${o}${i}`,majorDimension:"ROWS",values:n}})}async resizeSheet(e){let t=[];e.numCols&&t.push({updateSheetProperties:{properties:{sheetId:this.gid,gridProperties:{columnCount:e.numCols}},fields:"gridProperties.columnCount"}}),e.numRows&&t.push({updateSheetProperties:{properties:{sheetId:this.gid,gridProperties:{rowCount:e.numRows}},fields:"gridProperties.rowCount"}}),t.length>0&&(console.log("resizing sheet"),await gapi.client.sheets.spreadsheets.batchUpdate({spreadsheetId:this.spreadsheet.spreadsheetId,resource:{requests:t}}))}async getValues(){let t=(await gapi.client.sheets.spreadsheets.values.get({spreadsheetId:this.spreadsheet.spreadsheetId,range:this.title})).result.values;if(!t||t.length===0)return[[],[]];let s=t[0],i=t.slice(1);return[s,i]}async getValuesMap(){let[e,t]=await this.getValues();return t.map(i=>{let n={};return i.forEach((o,p)=>{let d=e[p];d&&(n[d]=String(o||""))}),n})}async setTitle(e){await gapi.client.sheets.spreadsheets.batchUpdate({spreadsheetId:this.spreadsheet.spreadsheetId,resource:{requests:[{updateSheetProperties:{properties:{title:e,sheetId:this.gid},fields:"title"}}]}}),this.title=e}getUrl(){return U({spreadsheetId:this.spreadsheet.spreadsheetId,gid:this.gid})}async applyL10nTheme(){await gapi.client.sheets.spreadsheets.batchUpdate({spreadsheetId:this.spreadsheet.spreadsheetId,resource:{requests:[{repeatCell:{range:{sheetId:this.gid,startRowIndex:0},cell:{userEnteredFormat:{textFormat:{fontFamily:"Ubuntu",fontSize:10}}},fields:"userEnteredFormat(textFormat)"}},{repeatCell:{range:{sheetId:this.gid,startRowIndex:0,endRowIndex:1},cell:{userEnteredFormat:{textFormat:{bold:!0,fontFamily:"Ubuntu",fontSize:10}}},fields:"userEnteredFormat(textFormat)"}},{updateSheetProperties:{properties:{sheetId:this.gid,gridProperties:{frozenRowCount:1}},fields:"gridProperties.frozenRowCount"}},{updateDimensionProperties:{range:{sheetId:this.gid,dimension:"COLUMNS",startIndex:0,endIndex:1},properties:{pixelSize:320},fields:"pixelSize"}},{updateDimensionProperties:{range:{sheetId:this.gid,dimension:"COLUMNS",startIndex:1},properties:{pixelSize:320},fields:"pixelSize"}},{repeatCell:{range:{sheetId:this.gid,startRowIndex:1,startColumnIndex:0},cell:{userEnteredFormat:{wrapStrategy:"WRAP"}},fields:"userEnteredFormat(wrapStrategy)"}}]}})}};function U(r){let t=[`https://docs.google.com/spreadsheets/d/${r.spreadsheetId}/edit`];return typeof r.gid=="number"&&t.push(`#gid=${r.gid}`),t.join("")}function k(r){if(!r.startsWith("https://docs.google.com/spreadsheets/d/"))return null;let e=r.split("/"),t=e[e.length-2],i=r.slice(r.indexOf("#")).match(/gid=(\d+)/),n=0;return i&&i[1]&&(n=parseInt(i[1])),{spreadsheetId:t,gid:n}}function P(r){let e=[];for(;r>=0;){let t=r%26;e.push(String.fromCharCode(t+65)),r=(r-t-1)/26}return e.reverse().join("")}function z(r){if(!r)return;if(!r.startsWith("https://drive.google.com/drive/folders/")){let s=r.trim();if(s.length===33&&/^[a-zA-Z0-9_-]+$/.test(s))return s}let e=r.trim().split("/");return e[e.length-1]||void 0}function W(r){let e=z(r);return e?`https://drive.google.com/drive/folders/${e}`:"https://drive.google.com/drive"}export{E as a,U as b,k as c,z as d,W as e};
1
+ import{c as b,n as x}from"./chunk-VD6G5NV4.js";async function A(){let r=window.firebase.db,e=window.__ROOT_CTX.rootConfig.projectId||"default",t=b(r,"Projects",e),s=await x(t);if(!s.exists)return[];let n=(s.data()||{}).roles||{},o=[];return Object.entries(n).forEach(([p,d])=>{(d==="ADMIN"||d==="EDITOR"||d==="CONTRIBUTOR")&&o.push(p)}),o}var E=class r{constructor(e){this.spreadsheetId=e}static async create(e){let t=e.share??!1,s={fields:"spreadsheetId"};e?.title&&(s.resource={properties:{title:e.title}});let n=(await gapi.client.sheets.spreadsheets.create(s)).result,o=new r(n.spreadsheetId);if(o.setSpreadsheet(n),e?.parent&&await gapi.client.drive.files.update({fileId:o.spreadsheetId,addParents:e.parent,removeParents:"root",fields:"id, parents",resource:{},supportsAllDrives:!0}),t)try{let p=await A();await o.share(p,"writer")}catch(p){console.warn("Failed to share spreadsheet:",p)}return o}getUrl(){return U({spreadsheetId:this.spreadsheetId})}async getSheet(e){if(this.sheets||await this.fetchSheets(),this.sheets){for(let t=0;t<this.sheets.length;t++)if(this.sheets[t].gid===e)return this.sheets[t]}return null}async createSheet(e){console.log("createSheet",this.spreadsheetId);let t=await gapi.client.sheets.spreadsheets.batchUpdate({spreadsheetId:this.spreadsheetId,resource:{requests:[{addSheet:{properties:{title:e.title}}}]}}),s=t.result.replies||[];if(s&&s.length>0){let i=s[0].addSheet?.properties?.sheetId;if(typeof i=="number")return new I(this,i,e.title)}throw console.error(t),new Error("failed to get gid of new tab")}async fetchSheets(){let t=(await gapi.client.sheets.spreadsheets.get({spreadsheetId:this.spreadsheetId,fields:"sheets.properties"})).result;this.setSpreadsheet(t)}setSpreadsheet(e){this.spreadsheet=e,this.spreadsheet.sheets&&this.setSheets(this.spreadsheet.sheets)}setSheets(e){let t=[];e.forEach(s=>{let i=s.properties?.sheetId,n=s.properties?.title,o=new I(this,i??0,n);t.push(o)}),this.sheets=t}async share(e,t){await Promise.all(e.map(async s=>{let i;s.startsWith("*@")?i={type:"domain",domain:s.slice(2),role:t}:i={type:"user",emailAddress:s,role:t},await gapi.client.drive.permissions.create({fileId:this.spreadsheetId,resource:i,sendNotificationEmail:!1,fields:"id",supportsAllDrives:!0})}))}},I=class{constructor(e,t,s){this.spreadsheet=e,this.gid=t,this.title=s}async updateValuesMap(e,t){let s=t.keyedBy,i=t.preserveColumns||[];if(!s)throw new Error('missing "keyedBy" argument');let[n,o]=await this.getValues(),p=[...n],d=[],w=-1,S=new Set;d.push(n.map((a,u)=>(a===s&&(w=u),i.includes(a)&&S.add(u),{hasChanges:!1,value:a})));function v(a){d[0].push({hasChanges:!0,value:a}),p.push(a)}w===-1&&v(s);let y={};o.forEach((a,u)=>{let h=u+1;d.push(a.map((c,l)=>(l===w&&c&&(c in y?console.warn(`multiple rows keyed by "${c}"`):y[c]=h),{hasChanges:!1,value:c})))});function O(a){for(let h in a)p.includes(h)||v(h);return p.map(h=>a[h]??null)}e.forEach(a=>{let u=O(a),h=a[s],c=y[h];if(c){let l=d[c];u.map((m,g)=>{g>=l.length?l.push({hasChanges:!0,value:m||""}):m!==null&&l[g].value!==m&&(!S.has(g)||!l[g].value)&&(l[g]={hasChanges:!0,value:m})})}else d.push(u.map(l=>({hasChanges:!!l,value:l||""})))});let C=p.length,R=d.length,$=n.length,F=o.length+1;(C>$||R>F)&&await this.resizeSheet({numCols:C+2,numRows:R+20});let f=[];d.forEach((a,u)=>{for(;a.length>0&&a.at(-1)?.hasChanges===!1;)a.pop();if(a.length!==0){if(a.every(h=>h.hasChanges)){f.push({range:`${this.title}!A${u+1}`,majorDimension:"ROWS",values:[a.map(h=>h.value||"")]});return}a.forEach((h,c)=>{if(h.hasChanges){let l=P(c);f.push({range:`${this.title}!${l}${u+1}`,majorDimension:"ROWS",values:[[h.value||""]]})}})}}),f.length>0&&await gapi.client.sheets.spreadsheets.values.batchUpdate({spreadsheetId:this.spreadsheet.spreadsheetId,resource:{data:f,valueInputOption:"RAW"}})}async replaceSheet(e,t){let s=e.length,i=t.length+1,n=[];n.push(e),n.push(...t.map(p=>e.map(d=>p[d]||""))),await this.resizeSheet({numCols:s+2,numRows:i+20}),console.log("updating cell values");let o=P(s-1);await gapi.client.sheets.spreadsheets.values.update({spreadsheetId:this.spreadsheet.spreadsheetId,range:`${this.title}!A1:${o}${i}`,valueInputOption:"RAW",resource:{range:`${this.title}!A1:${o}${i}`,majorDimension:"ROWS",values:n}})}async resizeSheet(e){let t=[];e.numCols&&t.push({updateSheetProperties:{properties:{sheetId:this.gid,gridProperties:{columnCount:e.numCols}},fields:"gridProperties.columnCount"}}),e.numRows&&t.push({updateSheetProperties:{properties:{sheetId:this.gid,gridProperties:{rowCount:e.numRows}},fields:"gridProperties.rowCount"}}),t.length>0&&(console.log("resizing sheet"),await gapi.client.sheets.spreadsheets.batchUpdate({spreadsheetId:this.spreadsheet.spreadsheetId,resource:{requests:t}}))}async getValues(){let t=(await gapi.client.sheets.spreadsheets.values.get({spreadsheetId:this.spreadsheet.spreadsheetId,range:this.title})).result.values;if(!t||t.length===0)return[[],[]];let s=t[0],i=t.slice(1);return[s,i]}async getValuesMap(){let[e,t]=await this.getValues();return t.map(i=>{let n={};return i.forEach((o,p)=>{let d=e[p];d&&(n[d]=String(o||""))}),n})}async setTitle(e){await gapi.client.sheets.spreadsheets.batchUpdate({spreadsheetId:this.spreadsheet.spreadsheetId,resource:{requests:[{updateSheetProperties:{properties:{title:e,sheetId:this.gid},fields:"title"}}]}}),this.title=e}getUrl(){return U({spreadsheetId:this.spreadsheet.spreadsheetId,gid:this.gid})}async applyL10nTheme(){await gapi.client.sheets.spreadsheets.batchUpdate({spreadsheetId:this.spreadsheet.spreadsheetId,resource:{requests:[{repeatCell:{range:{sheetId:this.gid,startRowIndex:0},cell:{userEnteredFormat:{textFormat:{fontFamily:"Ubuntu",fontSize:10}}},fields:"userEnteredFormat(textFormat)"}},{repeatCell:{range:{sheetId:this.gid,startRowIndex:0,endRowIndex:1},cell:{userEnteredFormat:{textFormat:{bold:!0,fontFamily:"Ubuntu",fontSize:10}}},fields:"userEnteredFormat(textFormat)"}},{updateSheetProperties:{properties:{sheetId:this.gid,gridProperties:{frozenRowCount:1}},fields:"gridProperties.frozenRowCount"}},{updateDimensionProperties:{range:{sheetId:this.gid,dimension:"COLUMNS",startIndex:0,endIndex:1},properties:{pixelSize:320},fields:"pixelSize"}},{updateDimensionProperties:{range:{sheetId:this.gid,dimension:"COLUMNS",startIndex:1},properties:{pixelSize:320},fields:"pixelSize"}},{repeatCell:{range:{sheetId:this.gid,startRowIndex:1,startColumnIndex:0},cell:{userEnteredFormat:{wrapStrategy:"WRAP"}},fields:"userEnteredFormat(wrapStrategy)"}}]}})}};function U(r){let t=[`https://docs.google.com/spreadsheets/d/${r.spreadsheetId}/edit`];return typeof r.gid=="number"&&t.push(`#gid=${r.gid}`),t.join("")}function k(r){if(!r.startsWith("https://docs.google.com/spreadsheets/d/"))return null;let e=r.split("/"),t=e[e.length-2],i=r.slice(r.indexOf("#")).match(/gid=(\d+)/),n=0;return i&&i[1]&&(n=parseInt(i[1])),{spreadsheetId:t,gid:n}}function P(r){let e=[];for(;r>=0;){let t=r%26;e.push(String.fromCharCode(t+65)),r=(r-t-1)/26}return e.reverse().join("")}function z(r){if(!r)return;if(!r.startsWith("https://drive.google.com/drive/folders/")){let s=r.trim();if(s.length===33&&/^[a-zA-Z0-9_-]+$/.test(s))return s}let e=r.trim().split("/");return e[e.length-1]||void 0}function W(r){let e=z(r);return e?`https://drive.google.com/drive/folders/${e}`:"https://drive.google.com/drive"}export{E as a,U as b,k as c,z as d,W as e};
@@ -1 +1 @@
1
- import{i as t,j as i}from"./chunk-NZHF733K.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-LROR6N3B.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{b as g,g as d,i as l,j as p,o as h}from"./chunk-EGEB6N4J.js";var r={year:31536e6,month:2628e6,week:6048e5,day:864e5,hour:36e5,minute:6e4,second:1e3};function w(e,t){let n=Math.abs(e-new Date().getTime());if(n<r.second)return"just now";let i=t||{numeric:"auto"},o=new Intl.RelativeTimeFormat("en",i);return n<r.minute?o.format(Math.round(-n/r.second),"second"):n<r.hour?o.format(Math.round(-n/r.minute),"minute"):n<r.day?o.format(Math.round(-n/r.hour),"hour"):n<r.week?o.format(Math.round(-n/r.day),"day"):new Date(e).toLocaleDateString("en",{year:"numeric",month:"short",day:"numeric"})}function f(){return Math.floor(new Date().getTime())}function I(e){return new Date(e.toMillis()).toLocaleDateString("en",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function M(){let e=a=>a<10?"0"+a:a,t=new Date,n=t.getFullYear(),i=e(t.getMonth()+1),o=e(t.getDate()),s=e(t.getHours()),u=e(t.getMinutes());return`${n}-${i}-${o}T${s}:${u}`}var y={};async function O(e,t){let n=t?.throttle||0,i=t?.throttleId?`${e}::${t.throttleId}`:e;if(b(i,n))return;let o=await fetch("/cms/api/actions.log",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:e,metadata:t?.metadata||{},links:t?.links})});if(o.status!==200){let s=await o.text();console.error(`failed to log action "${e}":`,s);return}y[i]=f()}async function k(e){let t=window.__ROOT_CTX.rootConfig.projectId,n=window.firebase.db,i=g(n,"Projects",t,"ActionLogs"),o=e?.limit,s;if(o){let c=Math.ceil(o*1.5);s=d(i,l("timestamp","desc"),p(c))}else s=d(i,l("timestamp","desc"));let u=await h(s),a=[];function T(c){if(a.length===0)return!1;let m=a.at(-1);return c.action==="doc.save"&&m.action==="doc.save"&&c.by===m.by&&c.metadata.docId===m.metadata.docId&&c.timestamp.toMillis()-m.timestamp.toMillis()<60*r.minute}for(let c of u.docs){if(o&&a.length>=o)break;let m=c.data();T(m)||a.push(m)}return a}function b(e,t){if(t===0)return!1;let n=y[e];return n?f()-n<t:!1}export{r as a,w as b,f as c,I as d,M as e,O as f,k as g};
1
+ import{b as g,g as d,i as l,j as p,o as h}from"./chunk-VD6G5NV4.js";var r={year:31536e6,month:2628e6,week:6048e5,day:864e5,hour:36e5,minute:6e4,second:1e3};function w(e,t){let n=Math.abs(e-new Date().getTime());if(n<r.second)return"just now";let i=t||{numeric:"auto"},o=new Intl.RelativeTimeFormat("en",i);return n<r.minute?o.format(Math.round(-n/r.second),"second"):n<r.hour?o.format(Math.round(-n/r.minute),"minute"):n<r.day?o.format(Math.round(-n/r.hour),"hour"):n<r.week?o.format(Math.round(-n/r.day),"day"):new Date(e).toLocaleDateString("en",{year:"numeric",month:"short",day:"numeric"})}function f(){return Math.floor(new Date().getTime())}function I(e){return new Date(e.toMillis()).toLocaleDateString("en",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function M(){let e=a=>a<10?"0"+a:a,t=new Date,n=t.getFullYear(),i=e(t.getMonth()+1),o=e(t.getDate()),s=e(t.getHours()),u=e(t.getMinutes());return`${n}-${i}-${o}T${s}:${u}`}var y={};async function O(e,t){let n=t?.throttle||0,i=t?.throttleId?`${e}::${t.throttleId}`:e;if(b(i,n))return;let o=await fetch("/cms/api/actions.log",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:e,metadata:t?.metadata||{},links:t?.links})});if(o.status!==200){let s=await o.text();console.error(`failed to log action "${e}":`,s);return}y[i]=f()}async function k(e){let t=window.__ROOT_CTX.rootConfig.projectId,n=window.firebase.db,i=g(n,"Projects",t,"ActionLogs"),o=e?.limit,s;if(o){let c=Math.ceil(o*1.5);s=d(i,l("timestamp","desc"),p(c))}else s=d(i,l("timestamp","desc"));let u=await h(s),a=[];function T(c){if(a.length===0)return!1;let m=a.at(-1);return c.action==="doc.save"&&m.action==="doc.save"&&c.by===m.by&&c.metadata.docId===m.metadata.docId&&c.timestamp.toMillis()-m.timestamp.toMillis()<60*r.minute}for(let c of u.docs){if(o&&a.length>=o)break;let m=c.data();T(m)||a.push(m)}return a}function b(e,t){if(t===0)return!1;let n=y[e];return n?f()-n<t:!1}export{r as a,w as b,f as c,I as d,M as e,O as f,k as g};