@blinkk/root-cms 3.0.4 → 3.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/dist/app.js +4 -2
  2. package/dist/{chunk-RLZFZT42.js → chunk-7L5OI5ES.js} +9 -9
  3. package/dist/core/plugin.d.ts +17 -0
  4. package/dist/core/schema.d.ts +20 -0
  5. package/dist/plugin.js +12 -1
  6. package/dist/shared/auto-slug-words.d.ts +7 -0
  7. package/dist/shared/auto-slug.d.ts +14 -0
  8. package/dist/ui/AIPage-JPZ4QUB4.js +1 -0
  9. package/dist/ui/{AssetsPage-4JNAOFYF.js → AssetsPage-GDJMKS3M.js} +1 -1
  10. package/dist/ui/{CollectionPage-JWHH5G55.js → CollectionPage-5DVXJEET.js} +1 -1
  11. package/dist/ui/ComparePage-LIXA6G66.js +1 -0
  12. package/dist/ui/{DataPage-VRCQSZZG.js → DataPage-AP4Z5JPS.js} +1 -1
  13. package/dist/ui/{DataSourcePage-WMSPBZ3W.js → DataSourcePage-WO3ZKMFI.js} +1 -1
  14. package/dist/ui/DocTranslationsPage-QKYFIVHP.js +1 -0
  15. package/dist/ui/DocumentPage-ON43I5KM.js +1 -0
  16. package/dist/ui/{EditDataSourcePage-LLCX6K4J.js → EditDataSourcePage-XVMEV2LJ.js} +1 -1
  17. package/dist/ui/{EditReleasePage-WQYXXMZQ.js → EditReleasePage-A2NB5TFG.js} +1 -1
  18. package/dist/ui/{ImageEditorDialog-4H665KK2.js → ImageEditorDialog-QEULJAT2.js} +2 -2
  19. package/dist/ui/LogsPage-4LZJX3O4.js +1 -0
  20. package/dist/ui/{NewDataSourcePage-RDYJC4DH.js → NewDataSourcePage-4YWX7IOG.js} +1 -1
  21. package/dist/ui/NewReleasePage-HWLVTEXX.js +1 -0
  22. package/dist/ui/{NotFoundPage-WDZ2K7EF.js → NotFoundPage-72AXQAYX.js} +1 -1
  23. package/dist/ui/{ProjectPage-HYJOQUWR.js → ProjectPage-L4GYDIA5.js} +1 -1
  24. package/dist/ui/ReleasePage-43BSWL5B.js +1 -0
  25. package/dist/ui/{ReleasesPage-NZIBBXU4.js → ReleasesPage-CJXAZBP6.js} +1 -1
  26. package/dist/ui/SettingsPage-SYXAMKSF.js +1 -0
  27. package/dist/ui/{SidebarToolsPage-5C6YBWJ7.js → SidebarToolsPage-OFF5BOXP.js} +1 -1
  28. package/dist/ui/TaskPage-HBDLHFI5.js +1 -0
  29. package/dist/ui/TasksPage-OLCDTQNB.js +1 -0
  30. package/dist/ui/{TranslationsArbPage-UHANA7JD.js → TranslationsArbPage-E3NCMAMS.js} +1 -1
  31. package/dist/ui/{TranslationsEditPage-PQY6W5YG.js → TranslationsEditPage-IWOI7Y5G.js} +1 -1
  32. package/dist/ui/{TranslationsPage-V2PQFCN5.js → TranslationsPage-OBN6CQZZ.js} +31 -31
  33. package/dist/ui/{ai-tools-5E5ELLZX.js → ai-tools-4DWMFQS6.js} +1 -1
  34. package/dist/ui/{chunk-KYDOSLTO.js → chunk-2225WAJ2.js} +1 -1
  35. package/dist/ui/chunk-32LRQ5MJ.js +1 -0
  36. package/dist/ui/{chunk-HKINZLMW.js → chunk-344GZOGG.js} +45 -45
  37. package/dist/ui/{chunk-FBJURT7Z.js → chunk-3HVDIPSS.js} +1 -1
  38. package/dist/ui/{chunk-BZIRGB4W.js → chunk-3IDOZ4MG.js} +1 -1
  39. package/dist/ui/{chunk-HHMG665Z.js → chunk-3XYCOR6Z.js} +1 -1
  40. package/dist/ui/chunk-4CUWZQXT.js +7 -0
  41. package/dist/ui/{chunk-3IYZCUPI.js → chunk-4IXGYXA2.js} +1 -1
  42. package/dist/ui/{chunk-PHBMVORG.js → chunk-6E7PGMZX.js} +1 -1
  43. package/dist/ui/{chunk-VMT7JFAM.js → chunk-6GPTGBA7.js} +1 -1
  44. package/dist/ui/{chunk-767BAQ53.js → chunk-6MOPIV5T.js} +1 -1
  45. package/dist/ui/{chunk-E2RCCK2T.js → chunk-AOCBDKLV.js} +1 -1
  46. package/dist/ui/chunk-AXETBZ6T.js +1 -0
  47. package/dist/ui/{chunk-54DVDYU6.js → chunk-BEDUTYQP.js} +1 -1
  48. package/dist/ui/{chunk-62UWGWON.js → chunk-CVGYBXVH.js} +1 -1
  49. package/dist/ui/{chunk-L4RHGQUG.js → chunk-D37DCENS.js} +1 -1
  50. package/dist/ui/{chunk-4W73RW5I.js → chunk-DXKEDMEI.js} +1 -1
  51. package/dist/ui/{chunk-C5NH23G4.js → chunk-EMYXSVTD.js} +1 -1
  52. package/dist/ui/{chunk-PWKJDYE2.js → chunk-GDSSFO5R.js} +1 -1
  53. package/dist/ui/{chunk-KFAZBEPV.js → chunk-HYARD7BK.js} +1 -1
  54. package/dist/ui/chunk-IDYKCAAL.js +1 -0
  55. package/dist/ui/chunk-IKED2IGU.js +1 -0
  56. package/dist/ui/{chunk-KKEWCXVV.js → chunk-J3EGGI57.js} +1 -1
  57. package/dist/ui/{chunk-HRGYNHZ3.js → chunk-KPJ53X55.js} +1 -1
  58. package/dist/ui/{chunk-W3BJ2EZX.js → chunk-KYKFNAX4.js} +1 -1
  59. package/dist/ui/{chunk-TJBVMFNQ.js → chunk-MZP6RIG2.js} +1 -1
  60. package/dist/ui/chunk-N4DFAIC5.js +7 -0
  61. package/dist/ui/{chunk-HLMBCVRX.js → chunk-N5Y5OWTV.js} +1 -1
  62. package/dist/ui/chunk-NMBXHKIJ.js +81 -0
  63. package/dist/ui/chunk-NQ5ARARP.js +1 -0
  64. package/dist/ui/{chunk-X2WHBGTP.js → chunk-NQB37NMX.js} +1 -1
  65. package/dist/ui/chunk-OVRTVMO5.js +1 -0
  66. package/dist/ui/{chunk-JT5L6GPZ.js → chunk-RI2JWWU3.js} +53 -53
  67. package/dist/ui/{chunk-AL3TN2KI.js → chunk-RPOP6MVJ.js} +1 -1
  68. package/dist/ui/{chunk-JHBAMPGB.js → chunk-RQKL4KXY.js} +1 -1
  69. package/dist/ui/{chunk-P3NETZZP.js → chunk-SEUH7LN2.js} +1 -1
  70. package/dist/ui/{chunk-V7S4IAGB.js → chunk-T47V6AGW.js} +1 -1
  71. package/dist/ui/{chunk-ONTGW2VA.js → chunk-TDKVKTW4.js} +1 -1
  72. package/dist/ui/chunk-TZEZEMRQ.js +1 -0
  73. package/dist/ui/{chunk-RSVO46S3.js → chunk-UA7UCTX5.js} +1 -1
  74. package/dist/ui/chunk-UFQSZ6J2.js +3 -0
  75. package/dist/ui/{chunk-DEGMKEHP.js → chunk-UHWNLNP4.js} +1 -1
  76. package/dist/ui/{chunk-CGCKJFL4.js → chunk-V7RAXP2W.js} +1 -1
  77. package/dist/ui/{chunk-JYFLU7DM.js → chunk-WKOX3VFN.js} +1 -1
  78. package/dist/ui/{chunk-SQRKKWRG.js → chunk-XYBHH5L4.js} +1 -1
  79. package/dist/ui/ui.css +1 -1
  80. package/dist/ui/ui.js +1 -1
  81. package/package.json +10 -10
  82. package/dist/ui/AIPage-YI3RFK5F.js +0 -1
  83. package/dist/ui/ComparePage-YZE3EMU4.js +0 -1
  84. package/dist/ui/DocTranslationsPage-RY2LOZBX.js +0 -1
  85. package/dist/ui/DocumentPage-EEGTJMIW.js +0 -1
  86. package/dist/ui/LogsPage-IP2DKEYR.js +0 -1
  87. package/dist/ui/NewReleasePage-DGMFU2JN.js +0 -1
  88. package/dist/ui/ReleasePage-2KSF23TK.js +0 -1
  89. package/dist/ui/SettingsPage-36XFWV62.js +0 -1
  90. package/dist/ui/TaskPage-SPIFPGPP.js +0 -1
  91. package/dist/ui/TasksPage-ZOXRPBQV.js +0 -1
  92. package/dist/ui/chunk-AFWBSIPL.js +0 -1
  93. package/dist/ui/chunk-GXSAEPU3.js +0 -1
  94. package/dist/ui/chunk-I6ICVKEC.js +0 -1
  95. package/dist/ui/chunk-JZFTZ4X4.js +0 -87
  96. package/dist/ui/chunk-MDUBCXU2.js +0 -1
  97. package/dist/ui/chunk-NXQVLOTK.js +0 -1
  98. package/dist/ui/chunk-NZHF733K.js +0 -7
  99. package/dist/ui/chunk-PJA7YP4A.js +0 -1
  100. package/dist/ui/chunk-XOQ3KDSR.js +0 -3
  101. package/dist/ui/chunk-YFA6U2CV.js +0 -1
  102. /package/dist/ui/{ImageEditorDialog-4H665KK2.js.LEGAL.txt → ImageEditorDialog-QEULJAT2.js.LEGAL.txt} +0 -0
  103. /package/dist/ui/{chunk-NZHF733K.js.LEGAL.txt → chunk-4CUWZQXT.js.LEGAL.txt} +0 -0
  104. /package/dist/ui/{chunk-JZFTZ4X4.js.LEGAL.txt → chunk-NMBXHKIJ.js.LEGAL.txt} +0 -0
  105. /package/dist/ui/{chunk-JT5L6GPZ.js.LEGAL.txt → chunk-RI2JWWU3.js.LEGAL.txt} +0 -0
  106. /package/dist/ui/{prerender-Q4YSDCPB.js → prerender-M47IWV5Q.js} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blinkk/root-cms",
3
- "version": "3.0.4",
3
+ "version": "3.0.6",
4
4
  "author": "s@blinkk.com",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -60,11 +60,11 @@
60
60
  "@ai-sdk/openai": "3.0.60",
61
61
  "@ai-sdk/openai-compatible": "2.0.46",
62
62
  "@ai-sdk/react": "3.0.177",
63
- "ai": "6.0.175",
64
- "zod": "4.4.3",
65
63
  "@google-cloud/firestore": "7.11.3",
66
64
  "@hello-pangea/dnd": "18.0.1",
65
+ "@mantine/spotlight": "4.2.12",
67
66
  "@types/cli-progress": "3.11.6",
67
+ "ai": "6.0.175",
68
68
  "body-parser": "1.20.2",
69
69
  "cli-progress": "3.12.0",
70
70
  "commander": "11.0.0",
@@ -74,14 +74,14 @@
74
74
  "date-fns-tz": "3.2.0",
75
75
  "diff": "8.0.2",
76
76
  "dts-dom": "3.7.0",
77
- "@mantine/spotlight": "4.2.12",
78
77
  "fnv-plus": "1.3.1",
79
78
  "jsonwebtoken": "9.0.2",
80
79
  "kleur": "4.1.5",
81
80
  "minisearch": "7.2.0",
82
81
  "sanitize-html": "2.13.1",
83
82
  "sirv": "2.0.3",
84
- "tiny-glob": "0.2.9"
83
+ "tiny-glob": "0.2.9",
84
+ "zod": "4.4.3"
85
85
  },
86
86
  "//": "NOTE(stevenle): due to compat issues with mantine and preact, mantine is pinned to v4.2.12",
87
87
  "devDependencies": {
@@ -125,8 +125,8 @@
125
125
  "@types/jsonwebtoken": "9.0.1",
126
126
  "@types/node": "24.3.1",
127
127
  "@types/sanitize-html": "2.13.0",
128
- "@vitest/browser": "4.1.6",
129
- "@vitest/browser-playwright": "4.1.6",
128
+ "@vitest/browser": "4.1.8",
129
+ "@vitest/browser-playwright": "4.1.8",
130
130
  "concurrently": "7.6.0",
131
131
  "esbuild": "0.28.0",
132
132
  "firebase": "12.2.1",
@@ -141,7 +141,7 @@
141
141
  "mdast-util-from-markdown": "2.0.1",
142
142
  "mdast-util-gfm": "3.0.0",
143
143
  "micromark-extension-gfm": "3.0.0",
144
- "playwright": "1.56.1",
144
+ "playwright": "1.60.0",
145
145
  "preact": "10.27.1",
146
146
  "preact-iso": "2.11.1",
147
147
  "preact-render-to-string": "6.6.7",
@@ -153,10 +153,10 @@
153
153
  "vite": "8.0.13",
154
154
  "vitest": "4.1.6",
155
155
  "yjs": "13.6.27",
156
- "@blinkk/root": "3.0.4"
156
+ "@blinkk/root": "3.0.6"
157
157
  },
158
158
  "peerDependencies": {
159
- "@blinkk/root": "3.0.4",
159
+ "@blinkk/root": "3.0.6",
160
160
  "firebase-admin": ">=11",
161
161
  "firebase-functions": ">=4"
162
162
  },
@@ -1 +0,0 @@
1
- import{a as o}from"./chunk-JYFLU7DM.js";import"./chunk-PHBMVORG.js";import"./chunk-JZFTZ4X4.js";import"./chunk-HKINZLMW.js";import"./chunk-SKEP5WYH.js";import"./chunk-YDO2EDVY.js";import{a,b as i}from"./chunk-FBJURT7Z.js";import"./chunk-5MV6XVGA.js";import"./chunk-EGEB6N4J.js";import"./chunk-AL3TN2KI.js";import{Ha as t}from"./chunk-NZHF733K.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";function n(r){return a("AI"),t(i,{children:t(o,{variant:"page",initialChatId:r.chatId})})}export{n as AIPage};
@@ -1 +0,0 @@
1
- import{b as s}from"./chunk-YFA6U2CV.js";import"./chunk-JZFTZ4X4.js";import"./chunk-AFWBSIPL.js";import"./chunk-XOQ3KDSR.js";import"./chunk-HLMBCVRX.js";import"./chunk-ORXEMIQC.js";import{a as d,b as m}from"./chunk-FBJURT7Z.js";import"./chunk-5MV6XVGA.js";import"./chunk-EGEB6N4J.js";import{d as t}from"./chunk-AL3TN2KI.js";import{Ha as a,g as i,j as p}from"./chunk-NZHF733K.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";p();function h(){let{query:r}=t();d("Compare");let o=i(()=>n(r.left||""),[r.left]),e=i(()=>n(r.right||""),[r.right]);return a(m,{children:a("div",{className:"ComparePage",children:o&&e?a(s,{className:"ComparePage__diff",left:o,right:e}):a("div",{className:"ComparePage__error",children:"Invalid params, double check query params."})})})}function n(r){let[o,e]=String(r).split("@");return o&&e?{docId:o,versionId:e}:null}export{h as ComparePage};
@@ -1 +0,0 @@
1
- import{b as na}from"./chunk-767BAQ53.js";import{a as ea}from"./chunk-4W73RW5I.js";import{a as aa}from"./chunk-P3NETZZP.js";import{a as Z}from"./chunk-VMT7JFAM.js";import"./chunk-HRGYNHZ3.js";import{b as j}from"./chunk-W3HIZQ4Z.js";import"./chunk-YDO2EDVY.js";import{A as V,t as U}from"./chunk-AFWBSIPL.js";import{b as G}from"./chunk-XOQ3KDSR.js";import{b as O}from"./chunk-62UWGWON.js";import{a as W,b as B}from"./chunk-I6ICVKEC.js";import"./chunk-HLMBCVRX.js";import"./chunk-ORXEMIQC.js";import{a as oa,b as S}from"./chunk-FBJURT7Z.js";import"./chunk-5MV6XVGA.js";import"./chunk-EGEB6N4J.js";import{f as y}from"./chunk-AL3TN2KI.js";import{Ab as q,Ga as p,Ha as a,Kc as Q,Oc as Y,V as E,W as w,a as r,c as k,da as R,e as $,ea as f,g as A,hc as J,j as _a,ra as C,zb as X,zc as K}from"./chunk-NZHF733K.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";_a();function u(e){oa(`Translations: ${e.collection}/${e.slug}`);let[_,l]=r(!0),[h,g]=r(!1),[o,t]=r([]),[s,c]=r({}),[M,ta]=r(null),[sa,N]=r(!1),[I,L]=r({}),[ra,z]=r(!1),m=e.collection,b=e.slug,i=`${m}/${b}`,ia=ea(),P=(window.__ROOT_CTX.rootConfig.i18n||{}).locales||[],[F,H]=na("locale",P);async function la(){try{let[n,d,T]=await Promise.all([aa(i),G(),V(i)]);t(n),c(d),ta(T),l(!1)}catch(n){console.error(n),l(!1),g(!0)}}if(k(()=>{la()},[]),h)return a(u.NotFound,{docId:i});function ca(n,d,T){N(!0),L(x=>{let D={...x},v=D[n]??{};return v.source=n,v[d]=T,D[n]=v,D})}async function da(){z(!0),await O(async()=>{console.log("EditTranslationsModal.onSave()");let n=`edit-translations-${i}`;W({id:n,loading:!0,title:"Saving translations",message:`Updating for ${i}...`,autoClose:!1,disallowClose:!0});let d=Object.values(I);console.log(d),await U(i,d),B({id:n,title:"Saved translations",message:`Updated translations for ${i}!`,autoClose:!0}),L({}),N(!1)}),z(!1)}function ga(n){F.length===P.length?H([n]):H(P)}return a(S,{children:a("div",{className:"DocTranslationsPage",children:[a("div",{className:"DocTranslationsPage__header",children:[a(R,{className:"DocTranslationsPage__header__breadcrumbs",children:[a("a",{href:`/cms/content/${m}`,children:m}),a("a",{href:`/cms/content/${m}/${b}`,children:b}),a("div",{children:"translations"})]}),a("div",{className:"DocTranslationsPage__header__titleWrap",children:a(Z,{size:"h1",children:["Translations: ",i]})}),a("div",{className:"DocTranslationsPage__header__controls",children:[M&&a("div",{className:"DocTranslationsPage__header__linkedSheet",children:a("div",{className:"DocTranslationsPage__header__linkedSheet__controls",children:[a(p,{label:"Open Google Sheet",children:a(w,{component:"a",href:j(M),target:"_blank",variant:"filled",color:"green",size:"sm",children:a(Q,{size:16,strokeWidth:2.25})})}),a(f,{variant:"default",size:"xs",leftIcon:a(q,{size:16,strokeWidth:1.75}),children:"Import from Sheet"}),a(f,{variant:"default",size:"xs",leftIcon:a(X,{size:16,strokeWidth:1.75}),children:"Export to Sheet"})]})}),a(C,{className:"DocTranslationsPage__toolsMenu",control:a(p,{label:"Tools",children:a(w,{variant:"default",children:a(Y,{size:16})})}),size:220,children:a(C.Item,{className:"DocTranslationsPage__toolsMenu__item",icon:a(K,{size:16}),onClick:()=>ia.open({docId:i,sourceStrings:o,onPruned:n=>{c(d=>{let T={...d};return n.forEach(x=>delete T[x]),T})}}),children:"Prune unused strings"})})]})]}),a("div",{className:y("DocTranslationsPage__content",_&&"DocTranslationsPage__content--loading"),children:_?a(E,{color:"gray",size:"xl"}):a(u.Table,{locales:F,sourceStrings:o,translationsMap:s,onChange:ca,changesMap:I,onSelectLocale:n=>ga(n)})}),a("div",{className:"DocTranslationsPage__footer",children:a("div",{className:"DocTranslationsPage__footer__buttons",children:a(f,{variant:"filled",color:"dark",disabled:!sa,loading:ra,onClick:()=>da(),children:"Save"})})})]})})}u.NotFound=e=>a(S,{children:a("div",{className:"DocTranslationsPage DocTranslationsPage--error",children:a("div",{className:"DocTranslationsPage__error",children:[a("div",{className:"DocTranslationsPage__error__icon",children:a(J,{size:60})}),a("div",{className:"DocTranslationsPage__error__title",children:["Not found: ",e.docId]})]})})});u.Table=e=>{let l=(window.__ROOT_CTX.rootConfig.i18n||{}).locales||[],h=A(()=>{let o={};return Object.values(e.translationsMap).forEach(t=>{o[t.source]=t}),o},[e.translationsMap]);function g(o,t){return{translation:(h[o]||{})[t]||"",hasChanges:!1}}return a("div",{className:"DocTranslationsPage__TableWrap",children:a("table",{className:"DocTranslationsPage__Table",children:[a("thead",{children:a("tr",{children:[a("th",{className:"DocTranslationsPage__Table__sourceCellHeader",children:a("div",{className:"DocTranslationsPage__Table__headerLabel",children:"source"})}),e.locales.map(o=>a("th",{onClick:()=>e.onSelectLocale(o),className:"DocTranslationsPage__Table__localeHeader",children:a(p,{className:"DocTranslationsPage__Table__headerTooltip",placement:"start",withArrow:!0,label:e.locales.length===l.length?`Show only ${o}`:"Show all locales",children:a("div",{className:"DocTranslationsPage__Table__headerLabel",children:o})})},o))]})}),a("tbody",{children:e.sourceStrings.map(o=>a("tr",{children:[a("td",{className:"DocTranslationsPage__Table__sourceCellWrap",children:a("div",{className:"DocTranslationsPage__Table__sourceCell",children:o})}),e.locales.map(t=>{let s=g(o,t);return a("td",{children:a(u.Textarea,{source:o,locale:t,value:s.translation,onChange:e.onChange,changesMap:e.changesMap})},t)})]},o))})]})})};u.Textarea=e=>{let _=$(null),[l,h]=r(e.value),g=null;e.locale in(e.changesMap[e.source]||{})&&(g=e.changesMap[e.source][e.locale]);let o=g!==null&&g!==e.value;function t(){window.requestAnimationFrame(()=>{let s=_.current;s.style.minHeight="auto";let c=s.scrollHeight;s.style.minHeight=`${c}px`})}return k(()=>{t()},[l]),a("textarea",{ref:_,className:y("DocTranslationsPage__Textarea",o&&"DocTranslationsPage__Textarea--hasChanges",!l&&"DocTranslationsPage__Textarea--empty"),onFocus:()=>t(),rows:1,onChange:s=>{let c=s.target.value;h(c),e.onChange(e.source,e.locale,c)},value:l})};export{u as DocTranslationsPage};
@@ -1 +0,0 @@
1
- import{a as je}from"./chunk-767BAQ53.js";import{c as Le,i as Ve,j as $e,k as We,m as Fe}from"./chunk-JT5L6GPZ.js";import"./chunk-HHMG665Z.js";import"./chunk-YFA6U2CV.js";import"./chunk-4W73RW5I.js";import"./chunk-P3NETZZP.js";import"./chunk-V7S4IAGB.js";import"./chunk-KFAZBEPV.js";import"./chunk-KYDOSLTO.js";import{a as Ue}from"./chunk-JYFLU7DM.js";import"./chunk-PHBMVORG.js";import{d as Ee}from"./chunk-JZFTZ4X4.js";import"./chunk-HKINZLMW.js";import{a as Me,d as Ae,f as X,h as Oe}from"./chunk-TJBVMFNQ.js";import"./chunk-CGCKJFL4.js";import"./chunk-VMT7JFAM.js";import"./chunk-SKEP5WYH.js";import"./chunk-GXSAEPU3.js";import{b as Re,c as ae,g as Te}from"./chunk-NXQVLOTK.js";import"./chunk-3IYZCUPI.js";import"./chunk-RSVO46S3.js";import"./chunk-54DVDYU6.js";import{a as T}from"./chunk-X2WHBGTP.js";import{b as Be,c as se}from"./chunk-ONTGW2VA.js";import"./chunk-4KE2SZKH.js";import{a as ze}from"./chunk-L4RHGQUG.js";import"./chunk-HRGYNHZ3.js";import"./chunk-W3HIZQ4Z.js";import"./chunk-JDW4UORS.js";import"./chunk-YDO2EDVY.js";import"./chunk-AFWBSIPL.js";import"./chunk-XOQ3KDSR.js";import"./chunk-62UWGWON.js";import"./chunk-I6ICVKEC.js";import"./chunk-HLMBCVRX.js";import"./chunk-ORXEMIQC.js";import{a as He,b as Xe}from"./chunk-FBJURT7Z.js";import"./chunk-5MV6XVGA.js";import"./chunk-EGEB6N4J.js";import{f as I}from"./chunk-AL3TN2KI.js";import{Aa as _e,Ac as Ie,Ga as L,Ha as e,Ja as pe,P as me,Pa as ge,Ra as oe,Ta as fe,Tc as Ne,Uc as ne,Va as ve,Vb as De,W as E,Wb as Ce,_a as Pe,a as y,c as x,ca as he,e as P,ea as H,g as M,h as C,j as te,pc as Se,qb as we,rb as xe,sb as be,tb as ke,tc as ye}from"./chunk-NZHF733K.js";import{d as V,j as ue,k as et}from"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";te();te();async function qe(t,o){let a=await(await fetch("/cms/api/check.test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({check:t,docId:o})})).json();if(!a.success)throw new Error(a.error||"Check failed.");return a.data}function Ke(t){let o=window.__ROOT_CTX.checks||[],n=t.docId.split("/")[0],a=o.filter(c=>!c.collections||c.collections.includes(n)),[i,r]=y({}),s=C(async c=>{r(m=>({...m,[c]:{loading:!0}}));try{let m=await qe(c,t.docId);r(h=>({...h,[c]:{loading:!1,result:m}}))}catch(m){r(h=>({...h,[c]:{loading:!1,error:m.message||"Unknown error."}}))}},[t.docId]),l=C(async()=>{let c={};for(let m of a)c[m.id]={loading:!0};r(c);for(let m of a)try{let h=await qe(m.id,t.docId);r(_=>({..._,[m.id]:{loading:!1,result:h}}))}catch(h){r(_=>({..._,[m.id]:{loading:!1,error:h.message||"Unknown error."}}))}},[t.docId,a]);return e("div",{className:"ChecksPanel",children:[e("div",{className:"ChecksPanel__header",children:[e("div",{className:"ChecksPanel__header__title",children:"Checks"}),e(H,{variant:"default",size:"xs",compact:!0,leftIcon:e(Se,{size:12}),onClick:l,children:"Run All"})]}),e("div",{className:"ChecksPanel__body",children:e("div",{className:"ChecksPanel__checks",children:a.map(c=>{let m=i[c.id];return e(tt,{check:c,state:m,onRun:()=>s(c.id)},c.id)})})})]})}function tt(t){let{check:o,state:n,onRun:a}=t;return e("div",{className:"ChecksPanel__check",children:[e("div",{className:"ChecksPanel__check__header",children:[e("div",{className:"ChecksPanel__check__label",children:[o.label,n?.result&&e(at,{status:n.result.status})]}),e(H,{className:"ChecksPanel__check__runButton",variant:"default",size:"xs",compact:!0,loading:n?.loading,onClick:a,children:"Run"})]}),o.description&&e("div",{className:"ChecksPanel__check__description",children:o.description}),n?.result&&e("div",{className:I("ChecksPanel__check__result",`ChecksPanel__check__result--${n.result.status}`),children:e(Ee,{code:n.result.message})}),n?.error&&e("div",{className:"ChecksPanel__check__error",children:n.error})]})}var ot={success:"green",warning:"yellow",error:"red"},nt={success:Pe,warning:pe,error:ne};function at(t){let o=ot[t.status],n=nt[t.status],a=t.status.charAt(0).toUpperCase()+t.status.slice(1);return e(he,{className:"ChecksPanel__statusBadge",color:o,size:"sm",variant:"filled",leftSection:e(n,{size:10}),children:a})}function Je(t){let{device:o,expandVertically:n,iframeUrl:a,localeOptions:i,selectedLocale:r,onToggleDevice:s,onToggleExpandVertically:l,onReloadClick:c,onOpenNewTab:m,onLocaleChange:h}=t;return e("div",{className:"DocumentPagePreviewBar",children:[e("div",{className:"DocumentPagePreviewBar__devices",children:[e(L,{label:"Mobile",children:e(E,{className:I("DocumentPagePreviewBar__device",o==="mobile"&&"active"),onClick:()=>s("mobile"),children:e(ke,{size:16})})}),e(L,{label:"Tablet",children:e(E,{className:I("DocumentPagePreviewBar__device",o==="tablet"&&"active"),onClick:()=>s("tablet"),children:e(be,{size:16})})}),e(L,{label:"Desktop",children:e(E,{className:I("DocumentPagePreviewBar__device",o==="desktop"&&"active"),onClick:()=>s("desktop"),children:e(we,{size:16})})}),e(L,{label:"Expand",children:e(E,{className:I("DocumentPagePreviewBar__device",n&&"active"),"aria-pressed":n,disabled:o==="",onClick:l,children:e(fe,{size:16})})})]}),e("div",{className:"DocumentPagePreviewBar__navbar",children:e("div",{className:"DocumentPagePreviewBar__navbar__url",children:a})}),e("div",{className:"DocumentPagePreviewBar__locales",children:e(_e,{data:i,placeholder:"Locale",radius:"xl",size:"xs",required:!0,icon:e(Ne,{size:16,strokeWidth:1.5}),value:r,onChange:_=>{h(_)}})}),e("div",{className:"DocumentPagePreviewBar__buttons",children:[e(L,{label:"Reload",children:e(E,{className:"DocumentPagePreviewBar__button DocumentPagePreviewBar__button--reload",onClick:c,children:e(ye,{size:16})})}),e(L,{label:"Open new tab",children:e(E,{className:"DocumentPagePreviewBar__button DocumentPagePreviewBar__button--openNewTab",onClick:m,children:e(oe,{size:16})})})]})]})}te();function Ye(t){let o=t.docId.split("/")[0],n=Te(o),a=X(),i=P(null),[r,s]=y(""),[l,c]=y([]),[m,h]=y(!1),_=P("");_.current=r;let g=P(n.schema?.fields||[]);g.current=n.schema?.fields||[];let k=P(n.schema?.types||{});k.current=n.schema?.types||{};let w=M(()=>Me(d=>{let b=d.trim();if(!b){c([]),h(!1);return}let S=a.controller?.getData()?.fields||{},z=We(b,S,g.current,k.current);c(z),h(!0)},150),[a.controller]);x(()=>{w(r)},[r,w]),Oe(()=>{_.current.trim()&&w(_.current)}),x(()=>{t.autoFocus&&requestAnimationFrame(()=>{i.current?.focus(),i.current?.select()})},[t.autoFocus]),x(()=>{let d=()=>{i.current?.focus(),i.current?.select()};return window.addEventListener("root:focus-search",d),()=>window.removeEventListener("root:focus-search",d)},[]);let p=d=>{ct(d)};return e("div",{className:"SearchPanel",children:[e("div",{className:"SearchPanel__header",children:[e("div",{className:"SearchPanel__header__title",children:"Search"}),t.onClose&&e(E,{size:"xs",onClick:t.onClose,title:"Close search",children:e(ne,{size:14})})]}),e("div",{className:"SearchPanel__searchInput",children:[e("span",{className:"SearchPanel__searchInput__icon",children:e(Ie,{size:14})}),e("input",{ref:i,type:"text",className:"SearchPanel__searchInput__input",value:r,onInput:d=>s(d.currentTarget.value),onKeyDown:d=>{d.key==="Escape"&&t.onClose&&(d.preventDefault(),t.onClose())},placeholder:"Search field values\u2026",autoComplete:"off",spellcheck:!1})]}),e("div",{className:"SearchPanel__body",children:[!m&&!r.trim()&&e("div",{className:"SearchPanel__empty",children:"Type a query above to search field values in this document."}),m&&l.length===0&&e("div",{className:"SearchPanel__empty",children:["No matches for ",e("strong",{children:r}),"."]}),l.length>0&&e(V,{children:[e("div",{className:"SearchPanel__resultsCount",children:[l.length," ",l.length===1?"match":"matches"]}),e("ul",{className:"SearchPanel__results",children:l.map((d,b)=>e(it,{result:d,onClick:()=>p(d)},`${d.deepKey}:${b}`))})]})]})]})}function it(t){let{result:o}=t;return e("li",{className:"SearchPanel__result",children:e("button",{type:"button",className:"SearchPanel__result__button",onClick:t.onClick,children:[e("div",{className:"SearchPanel__result__label",children:o.label}),e("div",{className:"SearchPanel__result__snippet",children:rt(o.snippet,o.matches)}),e("div",{className:"SearchPanel__result__meta",children:[e("span",{className:"SearchPanel__result__type",children:o.fieldType}),o.richTextBlock&&e("span",{className:"SearchPanel__result__badge",children:"in block"}),o.richTextInline&&e("span",{className:"SearchPanel__result__badge",children:"inline"})]})]})})}function rt(t,o){if(!o||o.length===0)return t;let n=[],a=0;for(let i of o)i.start>a&&n.push({text:t.slice(a,i.start),match:!1}),n.push({text:t.slice(i.start,i.end),match:!0}),a=i.end;return a<t.length&&n.push({text:t.slice(a),match:!1}),n.map((i,r)=>i.match?e("mark",{children:i.text},r):e("span",{children:i.text},r))}function ct(t){if(window.postMessage({scrollToDeeplink:{deepKey:t.deepKey}},"*"),t.richTextBlock){let o=t.richTextBlock;setTimeout(()=>{window.dispatchEvent(new CustomEvent(Ve,{detail:o}))},350)}else if(t.richTextInline){let o=t.richTextInline;setTimeout(()=>{window.dispatchEvent(new CustomEvent($e,{detail:o}))},350)}}et();te();var st=ue(null);function j(t){let{className:o,localStorageId:n,children:a}=t,[i,r]=T(`root::SplitPanel:${n}`,350),[s,l]=y(!1),[c,m]=y(0),h=M(()=>new Set,[]),_=P(null),g=P(null),k={onResize:p=>(h.add(p),()=>{h.delete(p)})};if(x(()=>{let p=()=>l(!1);window.addEventListener("mouseup",p);let d=_.current;return d&&m(d.getBoundingClientRect().left),()=>window.removeEventListener("mouseup",p)},[]),x(()=>{let p=d=>{let b=d.clientX-c;r(b),h.forEach(S=>S())};return s&&window.addEventListener("mousemove",p),()=>window.removeEventListener("mousemove",p)},[s]),a?.length!==2)throw new Error("SplitPanel should have two <SplitPanel.Item> children.");let w={"--panel-size":`${i}px`};return e(st.Provider,{value:k,children:e("div",{className:I(o,"SplitPanel",s&&"dragging"),ref:_,style:w,children:[a[0],e("div",{className:"SplitPanel__divider",ref:g,onMouseDown:()=>l(!0)}),a[1]]})})}j.Item=t=>e("div",{className:I("SplitPanel__item",t.className,t.fluid?"fluid":"static"),children:t.children});function le(t,o,n=""){let a=ae({collectionId:t,slug:o}),i=new URLSearchParams(window.location.search);i.set("preview","true"),i.delete("locale"),i.delete("modal");let r=`${i.toString()}${window.location.hash}`;return n?`${ae({collectionId:t,slug:o,locale:n})}?${r}`:`${a}?${r}`}function Ge(t){let o=t.collection,n=t.slug,a=`${o}/${n}`,{roles:i}=ze(),r=window.firebase.user.email||"",s=Be(i,r);return e(Ae,{docId:a,readOnly:!s,children:e(lt,{...t,canEdit:s})})}function lt(t){let o=t.canEdit,n=t.collection,a=t.slug,i=`${n}/${a}`;He(i);let r=window.__ROOT_CTX.collections[n],s=X(),l=!!r?.url,[c,m]=T(`root::DocumentPage::previewVisible::${n}`,l),h=M(()=>(window.__ROOT_CTX.checks||[]).some(f=>!f.collections||f.collections.includes(n)),[n]),[_,g]=T("root::DocumentPage::checksVisible",!1),k=P(_);k.current=_;let[w,p]=T("root::DocumentPage::searchVisible",!1),d=P(w);d.current=w;let b=!!(window.__ROOT_CTX.ai||window.__ROOT_CTX.experiments?.ai),[S,z]=T("root::DocumentPage::aiVisible",!1),O=P(S);O.current=S,x(()=>{window.dispatchEvent(new CustomEvent("root:checks-visible",{detail:_}))},[_]),x(()=>{window.dispatchEvent(new CustomEvent("root:search-visible",{detail:w}))},[w]),x(()=>{window.dispatchEvent(new CustomEvent("root:ai-visible",{detail:S}))},[S]);let[F,q]=T("root::DocumentPage::searchPanelWidth",360),[U,K]=y(F),[$,J]=y(!1),Y=P(null);if(x(()=>{let v=()=>{let f=!k.current;g(()=>f),f&&(p(()=>!1),z(()=>!1))};return window.addEventListener("root:toggle-checks",v),()=>window.removeEventListener("root:toggle-checks",v)},[]),x(()=>{let v=()=>{let f=!d.current;p(()=>f),f&&(g(()=>!1),z(()=>!1),requestAnimationFrame(()=>{window.dispatchEvent(new CustomEvent("root:focus-search"))}))};return window.addEventListener("root:toggle-search",v),()=>window.removeEventListener("root:toggle-search",v)},[]),x(()=>{let v=()=>{let f=!O.current;z(()=>f),f&&(g(()=>!1),p(()=>!1))};return window.addEventListener("root:toggle-ai",v),()=>window.removeEventListener("root:toggle-ai",v)},[]),x(()=>{if(!$)return;let v=A=>{let G=Y.current;if(!G)return;let re=G.getBoundingClientRect(),ce=Math.max(240,Math.min(re.right-A.clientX,800));K(ce)},f=()=>{J(!1),K(A=>(q(()=>A),A))};return window.addEventListener("mousemove",v),window.addEventListener("mouseup",f),()=>{window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",f)}},[$]),!r)return e("div",{children:"Could not find collection."});let ie=C(()=>{if(!l)return;let v=le(n,a),f=window.open(v,"_blank","noopener,noreferrer");f&&f.focus()},[l,n,a]),Q=C(()=>{o&&s.controller&&s.controller.flush()},[o,s.controller]),W=Le(),u=C(()=>{let v=s.controller?.getData()?.fields||{};W.open({data:v,onSave:f=>{s.controller&&f&&typeof f=="object"&&(s.controller.updateKey("fields",f),s.controller.flush()),W.close()}})},[s.controller]),D=C(()=>{window.dispatchEvent(new CustomEvent("root:toggle-search"))},[]),N=C(()=>{b&&window.dispatchEvent(new CustomEvent("root:toggle-ai"))},[b]),R=C(()=>{z(()=>!1)},[z]);return me([["mod+S",Q],["mod+shift+F",D],["mod+I",N]]),e(Xe,{children:e("div",{className:I("DocumentPage__layout",$&&"DocumentPage__layout--dragging"),ref:Y,children:[e(j,{className:"DocumentPage",localStorageId:"DocumentPage",children:[e(j.Item,{className:I("DocumentPage__side",(!l||!c)&&"DocumentPage__side--expanded"),children:[e("div",{className:"DocumentPage__side__header",children:[e("div",{className:"DocumentPage__side__header__nav",children:[e("a",{href:`/cms/content/${n}`,children:e(E,{className:"DocumentPage__side__header__back",children:e(ge,{size:16})})}),e("div",{className:"DocumentPage__side__header__docId",children:i})]}),e("div",{className:"DocumentPage__side__header__buttons",children:[e(se,{label:"You don't have access to edit this document",condition:!o,children:e(H,{className:"DocumentPage__side__header__saveButton",variant:"filled",color:"dark",size:"xs",compact:!0,leftIcon:e(xe,{size:16}),onClick:()=>Q(),disabled:!o,children:"Save"})}),e(se,{label:"You don't have access to edit this document",condition:!o,children:e(L,{label:"Edit JSON",disabled:!o,children:e(E,{className:"DocumentPage__side__header__editJson",onClick:()=>u(),disabled:!o,children:e(ve,{size:14})})})}),l&&e(V,{children:[e(L,{label:c?"Hide preview":"Show preview",children:e(E,{className:"DocumentPage__side__header__previewToggle",onClick:()=>m(!c),children:c?e(De,{size:16}):e(Ce,{size:16})})}),!c&&e(L,{label:"Open preview in new tab",children:e(E,{className:"DocumentPage__side__header__openNewTab",onClick:ie,children:e(oe,{size:16})})})]})]})]}),e("div",{className:I("DocumentPage__side__editor",(!l||!c)&&!_&&!w&&!S&&"DocumentPage__side__editor--centered"),children:e(Fe,{docId:i})})]}),e(j.Item,{className:I("DocumentPage__main",(!l||!c)&&"DocumentPage__main--hidden"),fluid:!0,children:l&&c&&e(Ge.Preview,{docId:i},i)})]}),h&&_&&e(ut,{docId:i}),w&&e(V,{children:[e("div",{className:"DocumentPage__searchDivider",onMouseDown:()=>J(!0)}),e("div",{className:"DocumentPage__search",style:{flexBasis:`${U}px`},children:e(Ye,{docId:i,autoFocus:!0,onClose:()=>p(()=>!1)})})]}),b&&S&&e(dt,{docId:i,onClose:R})]})})}function dt(t){let[o,n]=T("root::DocumentPage::aiPanelWidth",420),[a,i]=y(o),r=P(null),s=P(a),l=P(),c=M(()=>e(Ue,{variant:"panel",docContext:{docId:t.docId},onClose:t.onClose}),[t.docId,t.onClose]),m=C(()=>{let h=r.current?.parentElement;if(!h)return;s.current=a,h.classList.add("DocumentPage__layout--dragging");let _=w=>{let p=r.current?.parentElement;if(!p)return;let d=p.getBoundingClientRect(),b=Math.max(280,Math.min(d.right-w.clientX,800));s.current=b,i(b)},g=()=>{h.classList.remove("DocumentPage__layout--dragging"),window.removeEventListener("mousemove",_),window.removeEventListener("mouseup",k),l.current=void 0},k=()=>{g(),n(()=>s.current)};l.current=g,window.addEventListener("mousemove",_),window.addEventListener("mouseup",k)},[a,n]);return x(()=>()=>l.current?.(),[]),e(V,{children:[e("div",{className:"DocumentPage__aiDivider",ref:r,onMouseDown:m}),e("div",{className:"DocumentPage__ai",style:{flexBasis:`${a}px`},children:c})]})}function ut(t){let[o,n]=T("root::DocumentPage::checksPanelWidth",360),[a,i]=y(o),r=P(null),s=P(a),l=P(),c=M(()=>e(Ke,{docId:t.docId}),[t.docId]),m=C(()=>{let h=r.current?.parentElement;if(!h)return;s.current=a,h.classList.add("DocumentPage__layout--dragging");let _=w=>{let p=r.current?.parentElement;if(!p)return;let d=p.getBoundingClientRect(),b=Math.max(200,Math.min(d.right-w.clientX,800));s.current=b,i(b)},g=()=>{h.classList.remove("DocumentPage__layout--dragging"),window.removeEventListener("mousemove",_),window.removeEventListener("mouseup",k),l.current=void 0},k=()=>{g(),n(()=>s.current)};l.current=g,window.addEventListener("mousemove",_),window.addEventListener("mouseup",k)},[a,n]);return x(()=>()=>l.current?.(),[]),e(V,{children:[e("div",{className:"DocumentPage__checksDivider",ref:r,onMouseDown:m}),e("div",{className:"DocumentPage__checks",style:{flexBasis:`${a}px`},children:c})]})}var Qe={mobile:[430,932],tablet:[768,1024],desktop:[1440,800]};function mt(t){let o=new Intl.DisplayNames(["en"],{type:"language"}),a=t.split("_")[0];return`${o.of(a)||t} (${t})`}Ge.Preview=t=>{let o=X();if(o.loading)return null;let[n,a]=t.docId.split("/"),r=window.__ROOT_CTX.collections[n];if(!r)throw new Error(`collection not found: ${n}`);if(!r.url)return null;let s=r.domain||window.__ROOT_CTX.rootConfig.domain||"https://example.com",l=Re({collectionId:n,slug:a}),c=ae({collectionId:n,slug:a}),m=`${s}${l}`,[h,_]=y(m),[g,k]=T("root::DocumentPage::preview::device",""),[w,p]=T("root::DocumentPage::preview::expandVertically",!1),[d,b]=y({"--iframe-width":"100%","--iframe-height":"100%","--iframe-scale":"1"}),[S,z]=je("locale",""),O=P(null),F=P(null),q=o.controller.getLocales()||[],U=le(n,a,S),K=M(()=>[{value:"",label:"Select locale"},...q.map(u=>({value:u,label:mt(u)}))],[q]);function $(){if(document.hidden)return;let u=O.current;u.src="about:blank",window.requestAnimationFrame(()=>{u.src!==U?u.src=U:u.contentWindow.location.reload()})}x(()=>{let u=O.current;function D(){let R=u.contentWindow;if(R&&c===l&&!R.location.href.startsWith("about:blank")){let v=R.location.pathname;_(`${s}${v}`)}}u.addEventListener("load",D);let N=o.controller?.onFlush(()=>{$()});return()=>{N(),u.removeEventListener("load",D)}},[]),x(()=>{let u=O.current;u.src=U},[S]);let J=C(u=>{k(D=>{let N=D===u?"":u;return N===""&&p(!1),N})},[k,p]),Y=C(()=>{k(u=>(u&&p(D=>!D),u))},[k,p]),ie=C(()=>{o.controller&&o.controller.flush().then(()=>$())},[o.controller]),Q=C(()=>{let u=le(n,a,S),D=window.open(u,"_blank","noopener,noreferrer");D&&D.focus()},[n,a,S]),W=C(()=>{if(g===""){let B={"--iframe-width":"100%","--iframe-height":"100%","--iframe-scale":"1"};b(ee=>ee["--iframe-width"]===B["--iframe-width"]&&ee["--iframe-height"]===B["--iframe-height"]&&ee["--iframe-scale"]===B["--iframe-scale"]?ee:B);return}let u=F.current;if(!u)return;let D=u.getBoundingClientRect(),[N,R]=Qe[g],v=20,f=Math.max(D.width-2*v,0),A=Math.max(D.height-2*v,0),G=f>0&&N>0?f/N:1,re=A>0&&R>0?A/R:1,ce=Math.min(G,re,1),de=Number(ce.toFixed(4))||1,Ze=w?`${A/de}px`:`${R}px`,Z={"--iframe-width":`${N}px`,"--iframe-height":Ze,"--iframe-scale":String(de)};b(B=>B["--iframe-width"]===Z["--iframe-width"]&&B["--iframe-height"]===Z["--iframe-height"]&&B["--iframe-scale"]===Z["--iframe-scale"]?B:Z)},[g,w]);return x(()=>{W();let u=F.current;if(!u)return;let D=0,N=()=>{window.cancelAnimationFrame(D),D=window.requestAnimationFrame(W)},R=new window.ResizeObserver(N);return R.observe(u),window.addEventListener("resize",N),()=>{window.cancelAnimationFrame(D),R.disconnect(),window.removeEventListener("resize",N)}},[W]),e("div",{className:"DocumentPage__main__preview",children:[e(Je,{device:g,expandVertically:w,iframeUrl:h,localeOptions:K,selectedLocale:S,onToggleDevice:J,onToggleExpandVertically:Y,onReloadClick:ie,onOpenNewTab:Q,onLocaleChange:z}),e("div",{className:"DocumentPage__main__previewFrame","data-device":g||"full",ref:F,style:d,children:[e("div",{className:"DocumentPage__main__previewFrame__deviceLabel",style:{display:g?void 0:"none"},children:g?`${g}: ${Qe[g].join("x")}`:""}),e("div",{className:"DocumentPage__main__previewFrame__iframeWrap",children:e("iframe",{ref:O,title:"iframe preview"})})]})]})};export{Ge as DocumentPage};
@@ -1 +0,0 @@
1
- import{a as e}from"./chunk-E2RCCK2T.js";import"./chunk-KFAZBEPV.js";import"./chunk-KYDOSLTO.js";import{a}from"./chunk-VMT7JFAM.js";import"./chunk-W3HIZQ4Z.js";import"./chunk-PJA7YP4A.js";import"./chunk-ORXEMIQC.js";import{a as g,b as i}from"./chunk-FBJURT7Z.js";import"./chunk-EGEB6N4J.js";import"./chunk-AL3TN2KI.js";import{Ha as o}from"./chunk-NZHF733K.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";function L(){return g("Action Logs"),o(i,{children:o("div",{className:"LogsPage",children:[o("div",{className:"LogsPage__header",children:o(a,{size:"h1",children:"Action Logs"})}),o(e,{})]})})}export{L as LogsPage};
@@ -1 +0,0 @@
1
- import{a as m}from"./chunk-MDUBCXU2.js";import"./chunk-JHBAMPGB.js";import"./chunk-V7S4IAGB.js";import{a as r}from"./chunk-VMT7JFAM.js";import"./chunk-NXQVLOTK.js";import"./chunk-3IYZCUPI.js";import"./chunk-RSVO46S3.js";import"./chunk-54DVDYU6.js";import"./chunk-X2WHBGTP.js";import"./chunk-ONTGW2VA.js";import"./chunk-4KE2SZKH.js";import"./chunk-L4RHGQUG.js";import"./chunk-HRGYNHZ3.js";import"./chunk-W3HIZQ4Z.js";import"./chunk-JDW4UORS.js";import"./chunk-YDO2EDVY.js";import"./chunk-AFWBSIPL.js";import"./chunk-XOQ3KDSR.js";import"./chunk-62UWGWON.js";import"./chunk-I6ICVKEC.js";import"./chunk-HLMBCVRX.js";import"./chunk-ORXEMIQC.js";import{a as s,b as d}from"./chunk-FBJURT7Z.js";import"./chunk-5MV6XVGA.js";import"./chunk-EGEB6N4J.js";import"./chunk-AL3TN2KI.js";import{Ha as e,da as a}from"./chunk-NZHF733K.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";function w(){return s("New Release"),e(d,{children:e("div",{className:"NewReleasePage",children:[e("div",{className:"NewReleasePage__header",children:[e(a,{className:"NewReleasePage__header__breadcrumbs",children:[e("a",{href:"/cms/releases",children:"Releases"}),e("div",{children:"New"})]}),e(r,{size:"h1",children:"Add Release"})]}),e(m,{buttonLabel:"Create release"})]})})}export{w as NewReleasePage};
@@ -1 +0,0 @@
1
- import{a as F}from"./chunk-PWKJDYE2.js";import{a as O}from"./chunk-DEGMKEHP.js";import{a as m}from"./chunk-VMT7JFAM.js";import{f as M}from"./chunk-3IYZCUPI.js";import{c as B,g as E,j as H}from"./chunk-RSVO46S3.js";import{a as W,c as f}from"./chunk-ONTGW2VA.js";import"./chunk-4KE2SZKH.js";import{a as U}from"./chunk-L4RHGQUG.js";import{a as I,c as k}from"./chunk-HRGYNHZ3.js";import"./chunk-W3HIZQ4Z.js";import{a as y}from"./chunk-PJA7YP4A.js";import"./chunk-AFWBSIPL.js";import"./chunk-XOQ3KDSR.js";import{b as v}from"./chunk-62UWGWON.js";import{a as x,b as z}from"./chunk-I6ICVKEC.js";import{a as S}from"./chunk-HLMBCVRX.js";import{c as $}from"./chunk-ORXEMIQC.js";import{a as j,b as q}from"./chunk-FBJURT7Z.js";import"./chunk-5MV6XVGA.js";import"./chunk-EGEB6N4J.js";import"./chunk-AL3TN2KI.js";import{Dc as Y,Ea as N,Ga as u,Ha as e,V as w,W as A,a as c,c as D,da as T,ea as r,j as Q}from"./chunk-NZHF733K.js";import{d as C}from"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";Q();function d(t){let[o,i]=c(!0),[a,s]=c(null),[_,h]=c(0),l=t.id;j(`Release: ${l}`);async function p(){i(!0),await v(async()=>{let n=await B(l);s(n),h($())}),i(!1)}D(()=>{p()},[]);function P(n){console.log("onAction()",n),p()}return e(q,{children:e("div",{className:"ReleasePage",children:[e("div",{className:"ReleasePage__header",children:[e(T,{className:"ReleasePage__header__breadcrumbs",children:[e("a",{href:"/cms/releases",children:"Releases"}),e("div",{children:l})]}),e("div",{className:"ReleasePage__header__titleWrap",children:[e(m,{size:"h1",children:["Release: ",l]}),e("div",{className:"ReleasePage__header__controls",children:e(u,{label:"Configure",children:e(A,{component:"a",href:`/cms/releases/${t.id}/edit`,children:e(Y,{size:24,stroke:"1.5"})})})})]}),a?.description&&e(S,{as:"p",children:a.description})]}),o?e(w,{color:"gray",size:"xl"}):e(C,{children:[a&&e(d.PublishStatus,{release:a,onAction:P}),a&&a.docIds&&a.docIds.length>0&&e(d.DocsList,{release:a},`docs-list-${_}`),a&&a.dataSourceIds&&a.dataSourceIds.length>0&&e(d.DataSourcesList,{release:a},`data-sources-${_}`)]})]})})}d.PublishStatus=t=>{let{roles:o}=U(),i=window.firebase.user.email||"",a=W(o,i),s=t.release,[_,h]=c(!1),l=I(),p=k(),P=O({releaseId:s.id,onScheduled:()=>{t.onAction("scheduled")}});function n(){let g=s.docIds||[],R=s.dataSourceIds||[],b=g.length+R.length;if(b===0){x({title:"Cannot publish release",message:"Error: nothing in the release to publish.",color:"red",autoClose:!1});return}l.openConfirmModal({...p,title:`Publish release: ${s.id}`,children:e(S,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to publish this release? The ",b," items in the release will go live immediately."]}),labels:{confirm:"Publish",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"dark",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!0,onConfirm:()=>{G()}})}async function G(){h(!0),await v(async()=>{let g=`publish-release-${s.id}`,R=s.docIds?.length||0,b=s.dataSourceIds?.length||0,L=R+b;x({id:g,title:"Publishing release",message:`Publishing ${L} items...`,loading:!0,autoClose:!1}),await E(s.id),z({id:g,title:"Published release!",message:`Successfully published ${L} items!`,loading:!1,autoClose:5e3}),t.onAction&&t.onAction("publish")}),h(!1)}function J(){P.open()}async function K(){await H(s.id),t.onAction("cancel-schedule")}return e("div",{className:"ReleasePage__PublishStatus",children:[e(m,{size:"h2",children:"Status"}),e(y,{children:e(N,{className:"ReleasePage__PublishStatus__table",verticalSpacing:"xs",striped:!0,fontSize:"xs",children:[e("thead",{children:e("tr",{children:[e("th",{children:"status"}),e("th",{children:"actions"})]})}),e("tbody",{children:e("tr",{children:[e("td",{children:e(F,{release:s})}),e("td",{children:e("div",{className:"ReleasePage__PublishStatus__actions",children:[!s.archivedAt&&!s.scheduledAt&&e(f,{label:"You don't have access to publish this release",condition:!a,children:e(u,{label:"Publish the release immediately",position:"bottom",withArrow:!0,disabled:!a,children:e(r,{variant:"default",size:"xs",compact:!0,onClick:()=>n(),loading:_,disabled:!a,children:s.publishedAt?"Re-publish":"Publish"})})}),!s.archivedAt&&(s.scheduledAt?e(f,{label:"You don't have access to manage scheduled releases",condition:!a,children:e(u,{label:"Cancel the scheduled release",position:"bottom",withArrow:!0,disabled:!a,children:e(r,{variant:"default",size:"xs",compact:!0,onClick:()=>K(),disabled:!a,children:"Cancel Schedule"})})}):e(f,{label:"You don't have access to manage scheduled releases",condition:!a,children:e(u,{label:"Schedule the release to be published at a future date",position:"bottom",withArrow:!0,wrapLines:!0,width:180,disabled:!a,children:e(r,{variant:"default",size:"xs",compact:!0,onClick:()=>J(),disabled:!a,children:"Schedule"})})}))]})})]})})]})})]})};d.DocsList=t=>{let o=t.release,i=o.docIds||[];return e("div",{className:"ReleasePage__DocsList",children:[e("div",{className:"ReleasePage__DocsList__header",children:[e(m,{size:"h2",children:"Docs"}),e(r,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/releases/${o.id}/edit`,children:"Edit"})]}),e(y,{className:"ReleasePage__DocsList__cards",children:i.map(a=>e("div",{className:"ReleasePage__DocsList__card",children:e("a",{href:`/cms/content/${a}`,children:e(M,{docId:a,statusBadges:!0,hideReleases:!0})})},a))})]})};d.DataSourcesList=t=>{let o=t.release,i=o.dataSourceIds||[];return e("div",{className:"ReleasePage__DataSourcesList",children:[e("div",{className:"ReleasePage__DataSourcesList__header",children:[e(m,{size:"h2",children:"Data Sources"}),e(r,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/releases/${o.id}/edit`,children:"Edit"})]}),e("div",{className:"ReleasePage__DataSourcesList__items",children:i.map(a=>e("div",{className:"ReleasePage__DataSourcesList__item",children:e("a",{href:`/cms/data/${a}`,children:a})},a))})]})};export{d as ReleasePage};
@@ -1 +0,0 @@
1
- import{b as ae}from"./chunk-BZIRGB4W.js";import{a as te,c as ne,e as me}from"./chunk-HHMG665Z.js";import{b as ce,c as O,d as de,f as z}from"./chunk-KYDOSLTO.js";import{a as y}from"./chunk-VMT7JFAM.js";import"./chunk-54DVDYU6.js";import{a as le}from"./chunk-L4RHGQUG.js";import"./chunk-W3HIZQ4Z.js";import{a as I}from"./chunk-PJA7YP4A.js";import{b as ee}from"./chunk-62UWGWON.js";import{a as U}from"./chunk-I6ICVKEC.js";import{a as u}from"./chunk-HLMBCVRX.js";import{f as oe}from"./chunk-ORXEMIQC.js";import{a as ue,b as _e}from"./chunk-FBJURT7Z.js";import{c as se}from"./chunk-5MV6XVGA.js";import{c as V,n as Y,p as Q,q as Z}from"./chunk-EGEB6N4J.js";import{f as w}from"./chunk-AL3TN2KI.js";import{Aa as A,Da as q,Ha as e,Pc as ie,U as L,Uc as re,W as $,a as g,c as B,ca as J,e as W,ea as v,g as C,j as T,oa as F,qa as K,ta as X,va as G}from"./chunk-NZHF733K.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";T();T();var be={ADMIN:4,EDITOR:3,CONTRIBUTOR:2,VIEWER:1};function ge(o){return be[o]??0}function Se(o,s){return ge(o)>=ge(s)?o:s}function H(o,s,a){let t=o[s];o[s]=t?Se(t,a):a}function pe(o,s={}){let a={...s},t={};for(let n of o){let d=(n.users||[]).filter(Boolean);if(d.length===0)continue;let _=(n.collections||[]).filter(Boolean);if(_.length===0)for(let c of d)H(a,c,n.role);else{for(let c of d)H(a,c,"VIEWER");for(let c of _){t[c]||(t[c]={});for(let p of d)H(t[c],p,n.role)}}}return{projectRoles:a,collectionRoles:t}}function fe(o={}){return{id:o.id||`g_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`,name:o.name||"",role:o.role||"VIEWER",collections:o.collections?[...o.collections]:[],users:o.users?[...o.users]:[]}}T();function k(o){let s=o.size||28,[a,t]=g(!1),n=o.profile?.photoURL||"",d=o.profile?.displayName||o.email,_=w("EmailAvatar",o.className),c={width:s,height:s};return n&&!a?e("img",{className:_,style:c,src:n,alt:d,onError:()=>t(!0)}):e("svg",{className:_,style:c,viewBox:"0 0 28 28",role:"img","aria-label":d,children:[e("circle",{cx:"14",cy:"14",r:"14",fill:de(o.email)}),e("text",{x:"14",y:"14",textAnchor:"middle",dominantBaseline:"central",fill:"#fff",fontSize:"13",fontWeight:"600",children:ce(o.email)})]})}var ye=[{value:"ADMIN",label:"ADMIN"},{value:"EDITOR",label:"EDITOR"},{value:"CONTRIBUTOR",label:"CONTRIBUTOR"},{value:"VIEWER",label:"VIEWER"}];function xe(o){let{groups:s,onChange:a,collections:t,disabled:n}=o,d=C(()=>t.map(l=>({value:l,label:l})),[t]),[_,c]=g({});function p(l,i){a(s.map(m=>m.id===l?i(m):m))}function f(l){a(s.filter(i=>i.id!==l))}function P(){let l=s.length;a([...s,fe({name:"New group"})]),c(i=>({...i,[l]:!0}))}return e("div",{className:w(o.className,"PermissionGroupsBox"),children:[s.length===0?e("div",{className:"PermissionGroupsBox__empty",children:e(u,{size:"body-sm",weight:"semi-bold",color:"gray",children:"No permission groups yet. Create one to organize users by role and optionally scope access to specific collections."})}):e(L,{className:"PermissionGroupsBox__accordion",offsetIcon:!1,multiple:!0,state:_,onChange:c,children:s.map(l=>e(L.Item,{label:e("div",{className:"PermissionGroupsBox__trigger",children:[e("span",{className:"PermissionGroupsBox__trigger__name",children:l.name||"Untitled group"}),e(J,{color:"gray",radius:"sm",size:"xs",variant:"light",className:"PermissionGroupsBox__trigger__badge",children:[l.users.length," ",l.users.length===1?"user":"users"]})]}),children:e(Re,{group:l,collectionOptions:d,disabled:n,onChange:i=>p(l.id,()=>i),onDelete:()=>f(l.id)})},l.id))}),e("div",{className:"PermissionGroupsBox__addGroup",children:e(v,{variant:"default",size:"xs",radius:0,disabled:n,onClick:P,children:"+ Add group"})})]})}function Re(o){let{group:s,collectionOptions:a,disabled:t}=o,[n,d]=g(""),_=s.users.filter(r=>!O(r)),{profiles:c}=z(_);function p(r){o.onChange({...s,name:r})}function f(r){o.onChange({...s,role:r})}function P(r){o.onChange({...s,collections:r})}function l(r){let x=r.trim();if(!x||s.users.includes(x)){d("");return}o.onChange({...s,users:[...s.users,x]}),d("")}function i(r){o.onChange({...s,users:s.users.filter(x=>x!==r)})}function m(){window.confirm(`Delete the "${s.name||"Untitled group"}" group? This will remove its role assignments on next save.`)&&o.onDelete()}return e("div",{className:"PermissionGroupsBox__editor",children:[e("div",{className:"PermissionGroupsBox__editor__row",children:[e(G,{className:"PermissionGroupsBox__editor__name",label:"Group name",placeholder:"e.g. Blog Post Editors",value:s.name,radius:0,size:"xs",disabled:t,onChange:r=>p(r.target.value)}),e(A,{className:"PermissionGroupsBox__editor__role",label:"Role",data:ye,value:s.role,radius:0,size:"xs",disabled:t,onChange:r=>f(r)})]}),e(X,{className:"PermissionGroupsBox__editor__collections",label:"Collections",description:"Leave empty to apply project-wide. Otherwise restrict the group's role to the selected collections.",data:a,value:s.collections,radius:0,size:"xs",searchable:!0,clearable:!0,placeholder:"All collections (project-wide)",disabled:t,onChange:r=>P(r),dropdownComponent:"div"}),e("div",{className:"PermissionGroupsBox__editor__users",children:[e(u,{size:"body-sm",weight:"semi-bold",children:"Users"}),e("form",{className:"PermissionGroupsBox__editor__addUser",onSubmit:r=>{r.preventDefault(),l(n)},children:[e(G,{className:"PermissionGroupsBox__editor__addUser__email",placeholder:"grogu@example.com",type:"email",value:n,onChange:r=>d(r.target.value),radius:0,size:"xs",disabled:t}),e(v,{size:"xs",radius:0,color:"dark",type:"submit",disabled:t||!n.trim(),children:"Add user"})]}),s.users.length>0&&e("ul",{className:"PermissionGroupsBox__editor__userList",children:s.users.map(r=>{let x=c.get(r.toLowerCase())||null;return e("li",{className:"PermissionGroupsBox__editor__userItem",children:[e(k,{className:"PermissionGroupsBox__editor__userItem__avatar",email:r,profile:x,size:24}),e("span",{className:"PermissionGroupsBox__editor__userItem__email",children:r}),e($,{size:"sm",variant:"transparent",disabled:t,onClick:()=>i(r),title:`Remove ${r}`,children:e(re,{size:14})})]},r)})})]}),e("div",{className:"PermissionGroupsBox__editor__footer",children:e(v,{variant:"subtle",size:"xs",color:"red",compact:!0,disabled:t,leftIcon:e(ie,{size:14}),onClick:m,children:"Delete group"})})]})}T();function D(o){let{roles:s,onChange:a,currentUserIsAdmin:t}=o,[n,d]=g(""),_=Object.keys(s).filter(i=>!O(i)),{profiles:c}=z(_);function p(i,m){a({...s,[i]:m})}function f(i){let m={...s};delete m[i],a(m)}function P(i){let m=i.trim();d(""),!(!m||m in s)&&a({...s,[m]:"EDITOR"})}let l=se(Object.keys(s).map(i=>({email:i,role:s[i],profile:c.get(i.toLowerCase())||null})),"email");return e("div",{className:w(o.className,"ShareBox"),children:[e("form",{className:"ShareBox__addUser",onSubmit:i=>{i.preventDefault(),P(n)},children:[e(G,{className:"ShareBox__addUser__email",placeholder:"grogu@example.com",type:"email",value:n,onChange:i=>d(i.target.value),radius:0,size:"xs",disabled:!t}),e(v,{className:"ShareBox__addUser__button",size:"xs",radius:0,color:"dark",type:"submit",disabled:!t,children:"Add user"})]}),e("div",{className:"ShareBox__users",children:l.map(i=>e(D.User,{...i,currentUserIsAdmin:t,onRoleChange:p,onRemove:f},i.email))})]})}D.User=o=>{let s=o.email===window.firebase.user.email;return e("div",{className:"ShareBox__user",children:[e(k,{className:"ShareBox__user__avatar",email:o.email,profile:o.profile,size:24}),e(u,{className:"ShareBox__user__email",size:"body-sm",weight:"semi-bold",color:"gray",children:[o.email,s&&" (you)"]}),e("div",{className:"ShareBox__user__roleSelect",children:e(A,{data:[{value:"ADMIN",label:"ADMIN"},{value:"EDITOR",label:"EDITOR"},{value:"CONTRIBUTOR",label:"CONTRIBUTOR"},{value:"VIEWER",label:"VIEWER"},{value:"REMOVE",label:"REMOVE"}],value:o.role,radius:0,size:"xs",disabled:s||!o.currentUserIsAdmin,onChange:a=>{a==="REMOVE"?o.onRemove(o.email):o.onRoleChange(o.email,a)}})})]})};function we(o){if(!o)return"never";let s=Date.now()-o;return s<6e4?"just now":s<60*6e4?`${Math.floor(s/6e4)} min ago`:s<1440*6e4?`${Math.floor(s/(60*6e4))} hr ago`:new Date(o).toLocaleString()}function he(o){let s=window.firebase?.user?.email;if(!s)return!1;if(o[s]==="ADMIN")return!0;let a=s.split("@").at(-1);return!!(a&&o[`*@${a}`]==="ADMIN")}function Ne(){let o=ae(),[s,a]=g(!1),[t,n]=g(!1),[d,_]=g(!1),c=W(null);function p(){c.current!==null&&(window.clearInterval(c.current),c.current=null),n(!1),_(!1)}B(()=>p,[]),B(()=>{t&&o.running&&_(!0)},[t,o.running]);async function f(x){if(!(s||t)){a(!0);try{let S=await fetch("/cms/api/search.rebuild",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:x})});if(!S.ok){let j=await S.text().catch(()=>"");throw new Error(`HTTP ${S.status}: ${j||"rebuild failed"}`)}U({title:"Search index",message:x?"Full rebuild started.":"Incremental rebuild started.",color:"blue",autoClose:4e3}),n(!0),c.current=window.setInterval(()=>{o.refresh()},2e3),window.setTimeout(p,10*6e4)}catch(S){U({title:"Error",message:S?.message||String(S),color:"red",autoClose:!1})}finally{a(!1)}}}B(()=>{t&&d&&!o.running&&(p(),U({title:"Search index",message:"Rebuild complete.",color:"green",autoClose:3e3}))},[t,d,o.running]);let P=o.status.lastRun,l=o.status.docCount,i=o.status.fieldCount,m=o.status.shardCount,r=o.running||s;return e("div",{className:"SettingsPage__section",children:[e("div",{className:"SettingsPage__section__left",children:[e(y,{className:"SettingsPage__section__left__title",children:"Site Admin"}),e(u,{className:"SettingsPage__section__body",size:"body-sm",weight:"semi-bold",color:"gray",children:e("p",{children:"Project-wide administrative actions. Only admins see this section."})})]}),e(I,{className:"SettingsPage__section__right",children:e("div",{className:"SettingsPage__section__setting",children:[e(u,{size:"body",weight:"semi-bold",children:"Search index"}),e(u,{size:"body-sm",weight:"semi-bold",color:"gray",children:e("p",{children:"Powers the Cmd+K global search. Rebuilds run automatically on a schedule; trigger a manual rebuild here if you want immediate results (e.g. after a schema change)."})}),e("div",{className:"SettingsPage__siteAdmin__searchStats",children:[e("div",{children:[e("strong",{children:"Last indexed:"})," ",we(P)]}),e("div",{children:[e("strong",{children:"Indexed docs:"})," ",l.toLocaleString()]}),e("div",{children:[e("strong",{children:"Indexed fields:"})," ",i.toLocaleString()]}),e("div",{children:[e("strong",{children:"Shards:"})," ",m]})]}),e("div",{className:"SettingsPage__siteAdmin__searchButtons",children:[e(v,{variant:"default",size:"xs",compact:!0,loading:r,onClick:()=>f(!1),children:"Rebuild incremental"}),e(v,{variant:"default",size:"xs",compact:!0,loading:r,onClick:()=>{window.confirm("Force a full rebuild? This wipes the existing index and reindexes every doc from scratch.")&&f(!0)},children:"Force full rebuild"})]})]})})]})}function Be(o,s){return JSON.stringify(o)===JSON.stringify(s)}function Ge(){let o=window.__ROOT_CTX.rootConfig.projectId||"default",s=window.__ROOT_CTX.collections||{},a=C(()=>Object.keys(s).sort(),[s]),t=window.firebase.db,n=V(t,"Projects",o),[d,_]=g(!0),[c,p]=g(!1),[f,P]=g({roles:{},permissionGroups:[]}),[l,i]=g({roles:{},permissionGroups:[]});B(()=>{Y(n).then(h=>{let b=h.data()||{},N={roles:b.roles||{},permissionGroups:b.permissionGroups||[]};P(N),i({roles:{...N.roles},permissionGroups:N.permissionGroups.map(E=>({...E}))}),_(!1)})},[]);let m=he(f.roles),r=!Be(f,l);function x(h){i(b=>({...b,roles:h}))}function S(h){i(b=>({...b,permissionGroups:h}))}function j(){i({roles:{...f.roles},permissionGroups:f.permissionGroups.map(h=>({...h}))})}async function ve(){c||!r||(p(!0),await ee(async()=>{let{projectRoles:h,collectionRoles:b}=pe(l.permissionGroups,l.roles);await Z(n,{roles:h,permissionGroups:l.permissionGroups});let N=f.permissionGroups.flatMap(R=>R.collections||[]),E=new Set([...Object.keys(b),...N]);for(let R of E){let Pe=V(t,"Projects",o,"Collections",R);await Q(Pe,{roles:b[R]||{}},{merge:!0})}let M={roles:h,permissionGroups:l.permissionGroups};P(M),i({roles:{...M.roles},permissionGroups:M.permissionGroups.map(R=>({...R}))}),oe("acls.save_groups",{metadata:{groupCount:l.permissionGroups.length,userCount:Object.keys(h).length,collections:Array.from(E)}}),U({title:"Saved",message:"Sharing settings updated.",color:"green",autoClose:3e3})}),p(!1))}return e("div",{className:"SettingsPage__section SettingsPage__section__users",children:[e("div",{className:"SettingsPage__section__left",children:[e(y,{className:"SettingsPage__section__left__title",children:"Share"}),e(u,{className:"SettingsPage__section__body",size:"body-sm",weight:"semi-bold",color:"gray",children:[e("p",{children:"Share access to the CMS. To share with everyone in a domain, use *@example.com."}),e("ul",{children:[e("li",{children:"VIEWER: view docs but not edit"}),e("li",{children:"CONTRIBUTOR: view and edit docs, but not publish"}),e("li",{children:"EDITOR: view, edit, and publish docs"}),e("li",{children:"ADMIN: all of the above and change sharing settings"})]}),e("p",{children:["Use ",e("strong",{children:"groups"})," to manage many users at once and optionally scope a role to specific collections."]})]})]}),e(I,{className:"SettingsPage__section__right",children:e("div",{className:"SettingsPage__share",children:[e(K,{visible:d,loaderProps:{color:"gray",size:"xl"}}),e("div",{className:"SettingsPage__share__subsection",children:[e(y,{className:"SettingsPage__section__right__title",size:"h3",children:"Users"}),e(D,{className:"SettingsPage__section__users__sharebox",roles:l.roles,onChange:x,currentUserIsAdmin:m})]}),e("div",{className:"SettingsPage__share__subsection",children:[e(y,{className:"SettingsPage__section__right__title",size:"h3",children:"Groups"}),e(xe,{groups:l.permissionGroups,onChange:S,collections:a,disabled:!m})]}),e("div",{className:"SettingsPage__share__saveBar",children:[e(u,{size:"body-sm",weight:"semi-bold",color:"gray",children:r?"You have unsaved changes.":"All changes saved."}),e("div",{className:"SettingsPage__share__saveBar__actions",children:[e(v,{variant:"default",size:"xs",radius:0,disabled:!r||c,onClick:j,children:"Discard"}),e(v,{size:"xs",radius:0,color:"dark",loading:c,disabled:!r||!m,onClick:ve,children:"Save changes"})]})]})]})})]})}function Do(){ue("Settings");let o=me(),s=ne(),a=le(),t=!a.loading&&he(a.roles);return e(_e,{children:e("div",{className:"SettingsPage",children:[e(Ge,{}),e("div",{className:"SettingsPage__section",children:[e("div",{className:"SettingsPage__section__left",children:[e(y,{className:"SettingsPage__section__left__title",children:"Site Settings"}),e(u,{className:"SettingsPage__section__body",size:"body-sm",weight:"semi-bold",color:"gray",children:e("p",{children:"These settings apply to the project. Only admins can change them."})})]}),e(I,{className:"SettingsPage__section__right",children:te.map(n=>e("div",{className:"SettingsPage__section__setting",children:[e(u,{size:"body",weight:"semi-bold",children:n.name}),e(u,{size:"body-sm",weight:"semi-bold",color:"gray",children:e("p",{children:n.description})}),e(F,{autosize:!0,minRows:2,maxRows:4,value:s.settings[n.key]||"",placeholder:n.placeholder,onChange:d=>s.setSettings(n.key,d.currentTarget.value)}),n.ui&&e("div",{children:n.ui(s.settings[n.key])})]},n.key))})]}),t&&e(Ne,{}),e("div",{className:"SettingsPage__section",children:[e("div",{className:"SettingsPage__section__left",children:[e(y,{className:"SettingsPage__section__left__title",children:"User Preferences"}),e(u,{className:"SettingsPage__section__body",size:"body-sm",weight:"semi-bold",color:"gray",children:e("p",{children:"These settings are for you only."})})]}),e(I,{className:"SettingsPage__section__right",children:e("div",{className:"SettingsPage__section__userPref",children:[e("div",{className:"SettingsPage__section__userPref__description",children:[e(u,{className:"SettingsPage__section__userPref__description__title",size:"body",weight:"semi-bold",children:"Enable EditorJS Editor (legacy)"}),e(u,{className:"SettingsPage__section__userPref__description__body",size:"body-sm",weight:"semi-bold",color:"gray",children:e("p",{children:["Replaces the"," ",e("a",{href:"https://lexical.dev/",target:"_blank",rel:"noopener noreferrer nofollow",children:"Lexical"})," ","(default) rich text editor with the"," ",e("a",{href:"https://editorjs.io/",target:"_blank",rel:"noopener noreferrer nofollow",children:"EditorJS"})," ","(legacy) version."]})})]}),e("div",{className:"SettingsPage__section__userPref__input",children:e(q,{color:"dark",checked:o.preferences.EnableEditorJSEditor,onChange:n=>{let d=n.currentTarget.checked;o.setPreference("EnableEditorJSEditor",d)}})})]})})]})]})})}export{Do as SettingsPage};
@@ -1 +0,0 @@
1
- import{c as C,f as oe,g as re,h as le,i as ce,j as me,k as de,l as _e,m as ge,n as pe,o as ue,p as ke,q as fe,r as Te,s as he}from"./chunk-DUJYIOLE.js";import{l as ie}from"./chunk-JT5L6GPZ.js";import"./chunk-HHMG665Z.js";import"./chunk-YFA6U2CV.js";import"./chunk-4W73RW5I.js";import"./chunk-P3NETZZP.js";import"./chunk-V7S4IAGB.js";import"./chunk-KFAZBEPV.js";import"./chunk-KYDOSLTO.js";import"./chunk-PHBMVORG.js";import{c as R,d as ae}from"./chunk-JZFTZ4X4.js";import"./chunk-HKINZLMW.js";import"./chunk-TJBVMFNQ.js";import"./chunk-CGCKJFL4.js";import{a as W}from"./chunk-VMT7JFAM.js";import{f as te}from"./chunk-SKEP5WYH.js";import"./chunk-GXSAEPU3.js";import"./chunk-NXQVLOTK.js";import"./chunk-3IYZCUPI.js";import"./chunk-RSVO46S3.js";import"./chunk-54DVDYU6.js";import"./chunk-X2WHBGTP.js";import"./chunk-ONTGW2VA.js";import"./chunk-4KE2SZKH.js";import"./chunk-L4RHGQUG.js";import"./chunk-HRGYNHZ3.js";import"./chunk-W3HIZQ4Z.js";import"./chunk-JDW4UORS.js";import"./chunk-YDO2EDVY.js";import{a as I}from"./chunk-PJA7YP4A.js";import"./chunk-AFWBSIPL.js";import"./chunk-XOQ3KDSR.js";import{a as k}from"./chunk-62UWGWON.js";import{a as f}from"./chunk-I6ICVKEC.js";import"./chunk-HLMBCVRX.js";import"./chunk-ORXEMIQC.js";import{a as ne,b as se}from"./chunk-FBJURT7Z.js";import"./chunk-5MV6XVGA.js";import{a as Y}from"./chunk-EGEB6N4J.js";import{f as x}from"./chunk-AL3TN2KI.js";import{Aa as L,Db as J,Ga as P,Ha as e,Pc as M,Sc as ee,Uc as A,V,W as h,Xa as X,_a as b,a as d,c as y,da as U,e as O,ea as T,fc as Q,g as D,j as Ie,jc as F,kc as w,nb as B,oa as G,va as S,xb as Z}from"./chunk-NZHF733K.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";Ie();function H(a){return e(ie,{className:x("TaskCommentEditor",a.className),placeholder:a.placeholder,value:a.value,onChange:a.onChange,autoFocus:a.autoFocus,autosize:!0,variant:"comment"})}var we=[{value:"new",label:"New"},{value:"in-progress",label:"In progress"},{value:"in-review",label:"In review"},{value:"closed",label:"Closed"}],Ce=[{value:"high",label:"High"},{value:"medium",label:"Medium"},{value:"normal",label:"Normal"}];function yt(a){let t=a.id,[i,o]=d(null),[_,g]=d([]),[r,l]=d([]),[n,m]=d(!0),[c,s]=d("");return ne(i?`Task: ${i.title}`:`Task: ${t}`),y(()=>{m(!0),s("");let u=[oe(t,p=>{o(p),m(!1)},p=>{s(k(p)),m(!1)}),re(t,p=>g(p),p=>s(k(p))),le(t,p=>l(p),p=>s(k(p)))];return()=>u.forEach(p=>p())},[t]),e(se,{children:e("div",{className:"TaskPage",children:[e("div",{className:"TaskPage__header",children:[e(U,{className:"TaskPage__header__breadcrumbs",children:[e("a",{href:"/cms/tasks",children:"Tasks"}),e("div",{children:t})]}),e("div",{className:"TaskPage__header__titleWrap",children:[e(Ne,{task:i,taskId:t}),i&&e("span",{className:x("TaskPage__statusBadge",`TaskPage__statusBadge--${je(i.status)}`),children:$e(i.status)})]})]}),n&&e("div",{className:"TaskPage__loading",children:e(V,{color:"gray",size:"xl"})}),!n&&c&&e("div",{className:"TaskPage__error",children:c}),!n&&!c&&!i&&e(I,{className:"TaskPage__notFound",children:"Task not found."}),!n&&!c&&i&&e("div",{className:"TaskPage__body",children:[e("main",{className:"TaskPage__main",children:[e(ze,{task:i}),e(Ae,{task:i}),e(De,{task:i,comments:_,events:r}),e(ye,{taskId:i.id})]}),e("aside",{className:"TaskPage__side",children:e(Ee,{task:i})})]})]})})}function Ne(a){let{task:t}=a,[i,o]=d(!1),[_,g]=d(t?.title||""),[r,l]=d(!1);y(()=>{i||g(t?.title||"")},[t?.title,i]);async function n(){if(!t)return;let m=_.trim();if(!m){f({title:"Could not update title",message:"Task title is required.",color:"red"});return}if(m===t.title){g(t.title),o(!1);return}l(!0);try{await me(t.id,m),o(!1)}catch(c){f({title:"Could not update title",message:k(c),color:"red",autoClose:!1})}finally{l(!1)}}return t?i?e("form",{className:"TaskPage__header__titleForm",onSubmit:m=>{m.preventDefault(),n()},children:[e(S,{autoFocus:!0,className:"TaskPage__header__titleInput",disabled:r,value:_,onChange:m=>g(m.currentTarget.value),onKeyDown:m=>{m.key==="Escape"&&(g(t.title),o(!1))}}),e(T,{compact:!0,size:"xs",color:"dark",type:"submit",loading:r,leftIcon:e(b,{size:14,strokeWidth:"1.8"}),children:"Save"}),e(T,{compact:!0,size:"xs",variant:"default",type:"button",leftIcon:e(A,{size:14,strokeWidth:"1.8"}),onClick:()=>{g(t.title),o(!1)},children:"Cancel"})]}):e("div",{className:"TaskPage__header__titleContent",children:[e(W,{size:"h1",children:t.title}),e(P,{label:"Edit title",children:e(h,{size:"sm",onClick:()=>o(!0),children:e(w,{size:16,strokeWidth:"1.8"})})})]}):e(W,{size:"h1",children:`Task #${a.taskId}`})}function ze(a){let{task:t}=a,[i,o]=d(!1),[_,g]=d(t.description||""),[r,l]=d(!1);y(()=>{i||g(t.description||"")},[t.description,i]);async function n(){l(!0);try{await pe(t.id,_.trim()),o(!1)}catch(m){f({title:"Could not update description",message:k(m),color:"red",autoClose:!1})}finally{l(!1)}}return e(I,{className:"TaskPage__description",children:[e("div",{className:"TaskPage__description__top",children:[e("div",{className:"TaskPage__description__label",children:"Description"}),!i&&e(h,{size:"sm",onClick:()=>o(!0),children:e(w,{size:16,strokeWidth:"1.8"})})]}),i?e("div",{className:"TaskPage__description__edit",children:[e(G,{autosize:!0,autoFocus:!0,minRows:4,value:_,placeholder:"Add task details, scope, and acceptance criteria.",onChange:m=>g(m.currentTarget.value)}),e("div",{className:"TaskPage__description__editActions",children:[e(T,{compact:!0,size:"xs",variant:"default",leftIcon:e(A,{size:14,strokeWidth:"1.8"}),onClick:()=>{o(!1),g(t.description||"")},children:"Cancel"}),e(T,{compact:!0,size:"xs",color:"dark",loading:r,leftIcon:e(b,{size:14,strokeWidth:"1.8"}),onClick:n,children:"Save"})]})]}):e("div",{className:x("TaskPage__description__content",!t.description&&"TaskPage__description__content--empty"),children:t.description||"No description provided."})]})}function Ae(a){let{task:t}=a,i=O(null),[o,_]=d(!1),[g,r]=d(""),l=t.attachments||[];async function n(c){let s=Array.from(c);if(s.length!==0){_(!0);try{for(let u of s){let p=await te(u);await ue(t.id,{...p,filename:p.filename||u.name,contentType:u.type||void 0,size:u.size})}f({message:s.length===1?"File attached.":`${s.length} files attached.`,color:"green"})}catch(u){f({title:"Could not attach file",message:k(u),color:"red",autoClose:!1})}finally{_(!1),i.current&&(i.current.value="")}}}async function m(c){let s=xe(c);if(window.confirm(`Remove ${s} from this task?`)){r(c.id);try{await ke(t.id,c.id)}catch(u){f({title:"Could not remove attachment",message:k(u),color:"red",autoClose:!1})}finally{r("")}}}return e("section",{className:"TaskPage__attachments",children:[e("div",{className:"TaskPage__attachments__top",children:[e("div",{className:"TaskPage__attachments__label",children:"Attachments"}),e(T,{compact:!0,size:"xs",variant:"subtle",type:"button",loading:o,leftIcon:e(F,{size:14,strokeWidth:"1.8"}),onClick:()=>i.current?.click(),children:"Attach files"}),e("input",{ref:i,className:"TaskPage__attachments__input",type:"file",multiple:!0,onChange:c=>{n(c.currentTarget.files||[])}})]}),l.length>0?e("div",{className:"TaskPage__attachments__list",children:l.map(c=>e("div",{className:"TaskPage__attachments__item",children:[e("div",{className:"TaskPage__attachments__itemIcon",children:e(F,{size:16,strokeWidth:"1.8"})}),e("div",{className:"TaskPage__attachments__itemContent",children:[e("a",{href:c.src,target:"_blank",rel:"noreferrer",className:"TaskPage__attachments__itemTitle",children:xe(c)}),e("div",{className:"TaskPage__attachments__itemMeta",children:Re(c)})]}),e("div",{className:"TaskPage__attachments__itemActions",children:[e(P,{label:"Open file",children:e(h,{component:"a",href:c.src,target:"_blank",rel:"noreferrer",size:"sm",children:e(Z,{size:16,strokeWidth:"1.8"})})}),e(P,{label:"Remove attachment",children:e(h,{size:"sm",disabled:g===c.id,onClick:()=>m(c),children:e(M,{size:16,strokeWidth:"1.8"})})})]})]},c.id))}):e("div",{className:"TaskPage__attachments__empty",children:"No files attached."})]})}function Ee(a){let{task:t}=a,[i,o]=d(t.assignee||""),[_,g]=d(j(t.targetLaunchDate)),[r,l]=d("");y(()=>{o(t.assignee||""),g(j(t.targetLaunchDate))},[t.assignee,t.targetLaunchDate]);async function n(s,u){l(s);try{await u()}catch(p){f({title:"Could not update task",message:k(p),color:"red",autoClose:!1})}finally{l("")}}function m(){let s=i.trim();(t.assignee||"")!==s&&n("assignee",()=>ce(t.id,s||null))}function c(s){g(s),j(t.targetLaunchDate)!==s&&n("targetLaunchDate",()=>ge(t.id,Ke(s)))}return e(I,{className:"TaskPage__metadata",children:[e("div",{className:"TaskPage__metadata__field",children:[e("label",{children:"Status"}),e(L,{size:"xs",data:we,value:C(t.status),onChange:s=>{s&&s!==C(t.status)&&n("status",()=>de(t.id,s))}})]}),e("div",{className:"TaskPage__metadata__field",children:[e("label",{children:"Assignee"}),e("div",{className:"TaskPage__metadata__assignee",children:e(S,{size:"xs",type:"email",placeholder:"teammate@example.com",value:i,disabled:r==="assignee",onChange:s=>o(s.currentTarget.value),onBlur:()=>m(),onKeyDown:s=>{s.key==="Enter"&&s.currentTarget.blur()}})})]}),e("div",{className:"TaskPage__metadata__field",children:[e("label",{children:"Priority"}),e(L,{size:"xs",data:Ce,value:t.priority||"normal",onChange:s=>{s&&s!==(t.priority||"normal")&&n("priority",()=>_e(t.id,s))}})]}),e("div",{className:"TaskPage__metadata__field",children:[e("label",{children:"Target launch date"}),e("div",{className:"TaskPage__metadata__date",children:e("input",{type:"date",value:_,disabled:r==="targetLaunchDate",onInput:s=>c(s.currentTarget.value)})})]})]})}function De(a){let{task:t,comments:i,events:o}=a,_=D(()=>{let r=new Map;return i.filter(l=>l.parentId).forEach(l=>{let n=l.parentId||"";r.set(n,[...r.get(n)||[],l])}),r.forEach(l=>l.sort((n,m)=>E(n.createdAt)-E(m.createdAt))),r},[i]),g=D(()=>{let r=i.filter(n=>!n.parentId);return[{id:"opened",kind:"opened",createdAt:t.createdAt},...o.map(n=>({id:n.id,kind:"event",event:n,createdAt:n.createdAt})),...r.map(n=>({id:n.id,kind:"comment",comment:n,createdAt:n.createdAt}))].sort((n,m)=>E(n.createdAt)-E(m.createdAt))},[t,i,o]);return e("div",{className:"TaskPage__timeline",children:g.map(r=>r.kind==="opened"?e(Se,{task:t},r.id):r.kind==="event"?e(Le,{event:r.event},r.id):e(ve,{comment:r.comment,replies:_.get(r.comment.id)||[],threadParentId:r.comment.id},r.id))})}function Se(a){let{task:t}=a;return e("div",{className:"TaskPage__timelineItem TaskPage__timelineItem--event",children:[e("div",{className:"TaskPage__timelineItem__marker",children:e(b,{size:15,strokeWidth:"2"})}),e("div",{className:"TaskPage__timelineItem__content",children:[e("b",{children:z(t.createdBy||"unknown")})," opened this task"," ",N(t.createdAt),"."]})]})}function Le(a){let{event:t}=a;return e("div",{className:"TaskPage__timelineItem TaskPage__timelineItem--event",children:[e("div",{className:"TaskPage__timelineItem__marker",children:t.field==="title"?e(w,{size:15,strokeWidth:"2"}):t.field==="assignee"?e(ee,{size:15,strokeWidth:"2"}):t.field==="priority"?e(J,{size:15,strokeWidth:"2"}):t.field==="targetLaunchDate"?e(X,{size:15,strokeWidth:"2"}):e(b,{size:15,strokeWidth:"2"})}),e("div",{className:"TaskPage__timelineItem__content",children:[e("b",{children:z(t.createdBy||"unknown")})," changed"," ",qe(t.field)," from"," ",e("span",{className:"TaskPage__timelineValue",children:Pe(t.field,t.oldValue)})," ","to"," ",e("span",{className:"TaskPage__timelineValue",children:Pe(t.field,t.newValue)})," ",N(t.createdAt),"."]})]})}function ve(a){let{comment:t}=a,i=window.firebase.user.email||"",[o,_]=d(!1),[g,r]=d(!1),[l,n]=d(t.body||q(t.content)),[m,c]=d(!1),s=t.createdBy===i&&!t.isDeleted,u=a.threadParentId||t.parentId||t.id;y(()=>{n(t.body||q(t.content))},[t.body,t.content]);async function p(){if(l){c(!0);try{await Te(t.taskId,t.id,l),r(!1)}catch(v){f({title:"Could not edit comment",message:k(v),color:"red",autoClose:!1})}finally{c(!1)}}}async function be(){if(window.confirm("Delete this comment?"))try{await he(t.taskId,t.id)}catch(v){f({title:"Could not delete comment",message:k(v),color:"red",autoClose:!1})}}return e("div",{className:x("TaskPage__timelineItem","TaskPage__timelineItem--comment",a.isReply&&"TaskPage__timelineItem--reply"),children:[e("div",{className:"TaskPage__timelineItem__marker",children:a.isReply?e(B,{size:15,strokeWidth:"2"}):e(Q,{size:15,strokeWidth:"2"})}),e("div",{className:"TaskPage__timelineItem__content",children:[e(I,{className:"TaskPage__comment",children:[e("div",{className:"TaskPage__comment__header",children:[e("div",{children:[e("b",{children:z(t.createdBy||"unknown")})," ",e("span",{children:N(t.createdAt)}),t.updatedAt&&!t.isDeleted&&e("span",{children:[" edited ",N(t.updatedAt)]})]}),e("div",{className:"TaskPage__comment__actions",children:[!t.isDeleted&&e(P,{label:"Reply",children:e(h,{size:"sm",onClick:()=>_(!o),children:e(B,{size:16,strokeWidth:"1.8"})})}),s&&e(P,{label:"Edit",children:e(h,{size:"sm",onClick:()=>r(!0),children:e(w,{size:16,strokeWidth:"1.8"})})}),s&&e(P,{label:"Delete",children:e(h,{size:"sm",onClick:be,children:e(M,{size:16,strokeWidth:"1.8"})})})]})]}),g?e("div",{className:"TaskPage__comment__edit",children:[e(H,{value:l,placeholder:"Edit this comment...",onChange:n}),e("div",{className:"TaskPage__comment__editActions",children:[e(T,{compact:!0,size:"xs",variant:"default",leftIcon:e(A,{size:14,strokeWidth:"1.8"}),onClick:()=>{r(!1),n(t.body||q(t.content))},children:"Cancel"}),e(T,{compact:!0,size:"xs",color:"dark",loading:m,disabled:!l,leftIcon:e(b,{size:14,strokeWidth:"1.8"}),onClick:p,children:"Save"})]})]}):e("div",{className:x("TaskPage__comment__body",t.isDeleted&&"TaskPage__comment__body--deleted"),children:t.isDeleted?"Comment deleted.":t.body?e(Be,{className:"TaskPage__comment__richText",data:t.body}):e(ae,{className:"TaskPage__comment__markdown",code:t.content})})]}),o&&e(ye,{taskId:t.taskId,parentId:u,autoFocus:!0,onSubmitted:()=>_(!1),onCancel:()=>_(!1)}),a.replies&&a.replies.length>0&&e("div",{className:"TaskPage__replies",children:a.replies.map(v=>e(ve,{comment:v,isReply:!0,threadParentId:t.id},v.id))})]})]})}function ye(a){let[t,i]=d(null),[o,_]=d(0),[g,r]=d(!1),l=!!a.parentId;async function n(m){if(m.preventDefault(),!!t){r(!0);try{await fe(a.taskId,t,a.parentId),i(null),_(c=>c+1),a.onSubmitted?.()}catch(c){f({title:l?"Could not add reply":"Could not add comment",message:k(c),color:"red",autoClose:!1})}finally{r(!1)}}}return e(I,{className:x("TaskPage__composer",l&&"TaskPage__composer--reply"),children:e("form",{onSubmit:n,children:[e(H,{autoFocus:a.autoFocus,placeholder:l?"Write a reply...":"Leave a comment...",value:t,onChange:i},o),e("div",{className:"TaskPage__composer__actions",children:[a.onCancel&&e(T,{compact:!0,size:"xs",variant:"default",type:"button",onClick:a.onCancel,children:"Cancel"}),e(T,{compact:!0,size:"xs",color:"dark",type:"submit",loading:g,disabled:!t,children:l?"Reply":"Comment"})]})]})})}function Be(a){return e("div",{className:a.className,children:(a.data.blocks||[]).map((t,i)=>e(Fe,{block:t},i))})}function Fe(a){let{block:t}=a;switch(t.type){case"paragraph":return e($,{tag:"p",html:t.data?.text});case"heading":return e($,{tag:"h4",html:t.data?.text});case"quote":return e($,{tag:"blockquote",html:t.data?.text});case"orderedList":return e("ol",{children:(t.data?.items||[]).map((i,o)=>e(K,{item:i},o))});case"unorderedList":return e("ul",{children:(t.data?.items||[]).map((i,o)=>e(K,{item:i},o))});case"image":{let i=t.data?.file;return i?.url?e("img",{src:i.url,width:Number(i.width)||void 0,height:Number(i.height)||void 0,alt:i.alt||""}):null}default:return null}}function $(a){if(!a.html)return null;let t=a.tag;return e(t,{dangerouslySetInnerHTML:{__html:R(a.html)}})}function K(a){return e("li",{children:[a.item.content&&e("span",{dangerouslySetInnerHTML:{__html:R(a.item.content)}}),a.item.items&&a.item.items.length>0&&e("ul",{children:a.item.items.map((t,i)=>e(K,{item:t},i))})]})}function q(a){return a.trim()?{blocks:a.split(/\n{2,}/).map(t=>({type:"paragraph",data:{text:Me(t).replace(/\n/g,"<br>")}})),time:Date.now(),version:"plain-text"}:null}function Me(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function E(a){return a?.toMillis?.()||0}function xe(a){let t=a.src.split("?")[0].split("/").filter(Boolean).at(-1)||"",i=a.filename||t||"Attachment";try{return decodeURIComponent(i)}catch{return i}}function Re(a){let t=[We(a.size),a.contentType||"",a.attachedBy?`attached by ${z(a.attachedBy)}`:"",a.attachedAt?N(a.attachedAt):""].filter(Boolean);return t.length>0?t.join(" - "):"Attached file"}function We(a){if(typeof a!="number")return"";if(a<1024)return`${a} B`;let t=["KB","MB","GB"],i=a/1024,o=0;for(;i>=1024&&o<t.length-1;)i=i/1024,o+=1;return`${i.toFixed(i>=10?0:1)} ${t[o]}`}function z(a){return a.split("@")[0]||a}function He(a){return a?.toMillis?new Date(a.toMillis()).toLocaleDateString("en",{month:"short",day:"numeric",year:"numeric"}):"No date"}function N(a){return a?.toMillis?new Date(a.toMillis()).toLocaleString("en",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):"just now"}function $e(a){return C(a).replace(/[-_]/g," ")}function qe(a){return a.replace(/([A-Z])/g," $1").toLowerCase()}function Pe(a,t){return t?t instanceof Y?He(t):a==="assignee"?z(t):a==="title"?t:t.replace(/[-_]/g," "):"none"}function je(a){return C(a).replace(/[^a-z0-9]+/gi,"-").toLowerCase()}function j(a){if(!a?.toMillis)return"";let t=new Date(a.toMillis()),i=t.getFullYear(),o=String(t.getMonth()+1).padStart(2,"0"),_=String(t.getDate()).padStart(2,"0");return`${i}-${o}-${_}`}function Ke(a){if(!a)return null;let[t,i,o]=a.split("-").map(Number);return!t||!i||!o?null:new Date(t,i-1,o)}export{yt as TaskPage};
@@ -1 +0,0 @@
1
- import{a as g}from"./chunk-SQRKKWRG.js";import"./chunk-DUJYIOLE.js";import"./chunk-KFAZBEPV.js";import"./chunk-KYDOSLTO.js";import{a as e}from"./chunk-VMT7JFAM.js";import"./chunk-X2WHBGTP.js";import"./chunk-PJA7YP4A.js";import"./chunk-62UWGWON.js";import"./chunk-I6ICVKEC.js";import"./chunk-ORXEMIQC.js";import{a as s,b as i}from"./chunk-FBJURT7Z.js";import"./chunk-EGEB6N4J.js";import"./chunk-AL3TN2KI.js";import{Ha as a}from"./chunk-NZHF733K.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";function k(){return s("Tasks"),a(i,{children:a("div",{className:"TasksPage",children:[a("div",{className:"TasksPage__header",children:a(e,{size:"h1",children:"Tasks"})}),a(g,{variant:"page"})]})})}export{k as TasksPage};
@@ -1 +0,0 @@
1
- import{a as X,f as G,g as M}from"./chunk-XOQ3KDSR.js";import{f as u}from"./chunk-ORXEMIQC.js";import{a as C,b as k,c as d,f as L,g as A,h as j,i as I,j as V,l as $,n as D,o as B,p as E,q as x,s as _,t as w,u as h,v as F,w as T}from"./chunk-EGEB6N4J.js";function H(e){return typeof e=="object"&&!Array.isArray(e)&&e!==null}function Q(e){return H(e)&&Array.isArray(e.blocks)&&e.blocks.length>0}var P=new Map;function K(e){return P.get(e)||null}async function fe(e){let t=K(e);if(t)return t;let s=g(e),o=(await D(s)).data();return W(e,o),o}function W(e,t){P.set(e,t)}function v(e){P.delete(e)}function U(e){for(let t of e)v(t)}async function Te(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,[n,o]=e.split("/"),r=d(s,"Projects",t,"Collections",n,"Drafts",o),i=d(s,"Projects",t,"Collections",n,"Published",o),c=d(s,"Projects",t,"Collections",n,"Scheduled",o),a=T(s);a.delete(r),a.delete(i),a.delete(c),await a.commit(),console.log(`deleted doc: ${e}`),u("doc.delete",{metadata:{docId:e}})}async function Ce(e,t){await Y([e],t)}async function Y(e,t){if(e.length===0){console.log("no docs to publish");return}let s=window.firebase.db;if(e.length>100)throw new Error("publish docs exceeds limit of 100 docs. break up your request into multiple calls.");let n=await ie(e),o=t?.batch||T(s),r=["published"];t?.releaseId&&r.push(`release:${t.releaseId}`),e.forEach(i=>{let c=n[i];if(!c)throw new Error(`doc does not exist: ${i}`);Z(o,i,c,r,t?.publishMessage)}),await o.commit(),e.length===1?console.log(`published ${e[0]}`):console.log(`published ${e.length} docs: ${e.join(", ")}`);for(let i of e){let c={docId:i};t?.publishMessage&&(c.publishMessage=t.publishMessage),u("doc.publish",{metadata:c})}U(e)}function Z(e,t,s,n,o){if(te(s))throw new Error(`publishing is locked for doc: ${s.id}`);if(ee(s))throw new Error(`cannot publish archived doc: ${s.id}`);let r=window.__ROOT_CTX.rootConfig.projectId,i=window.firebase.db,[c,a]=t.split("/"),b=d(i,"Projects",r,"Collections",c,"Drafts",a),f=d(i,"Projects",r,"Collections",c,"Scheduled",a),p=d(i,"Projects",r,"Collections",c,"Published",a),m={...s},l=m.sys??{};l.modifiedAt=h(),l.modifiedBy=window.firebase.user.email,l.publishedAt=h(),l.publishedBy=window.firebase.user.email,l.firstPublishedAt??=h(),l.firstPublishedBy??=window.firebase.user.email,delete l.scheduledAt,delete l.scheduledBy,e.update(b,{sys:l}),e.set(p,{...m,sys:l}),e.delete(f);let y=d(i,"Projects",r,"Collections",c,"Drafts",a,"Versions",String(Date.now())),R={id:t,collection:c,slug:a,fields:m.fields||{},sys:l};n?.length&&(R.tags=n),o&&(R.publishMessage=o),e.set(y,R)}async function Ae(e,t,s){let n=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,[r,i]=e.split("/"),c=d(o,"Projects",n,"Collections",r,"Drafts",i),a=d(o,"Projects",n,"Collections",r,"Scheduled",i);await _(o,async f=>{let p=await f.get(c);if(!p.exists())throw new Error(`${c.id} does not exist`);let m={...p.data()},l=m.sys??{};l.modifiedAt=h(),l.modifiedBy=window.firebase.user.email,l.scheduledAt=C.fromMillis(t),l.scheduledBy=window.firebase.user.email,f.update(c,{sys:l});let y={...m,sys:l};s?.publishMessage&&(y.scheduledPublishMessage=s.publishMessage),f.set(a,y)}),console.log(`saved ${a.id}`);let b={docId:e,scheduledAt:t};s?.publishMessage&&(b.publishMessage=s.publishMessage),u("doc.schedule",{metadata:b})}async function ke(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,[n,o]=e.split("/"),r=d(s,"Projects",t,"Collections",n,"Drafts",o),i=d(s,"Projects",t,"Collections",n,"Scheduled",o),c=d(s,"Projects",t,"Collections",n,"Published",o),a=T(s);a.update(r,{"sys.modifiedAt":h(),"sys.modifiedBy":window.firebase.user.email,"sys.publishedAt":w(),"sys.publishedBy":w(),"sys.firstPublishedAt":w(),"sys.firstPublishedBy":w()}),a.delete(i),a.delete(c),await a.commit(),console.log(`unpublished ${e}`),u("doc.unpublish",{metadata:{docId:e}}),v(e)}async function je(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,[n,o]=e.split("/"),r=d(s,"Projects",t,"Collections",n,"Drafts",o),i=d(s,"Projects",t,"Collections",n,"Published",o);await _(s,async c=>{let a=await c.get(i);if(!a.exists())throw new Error(`${i.id} does not exist`);let b=a.data();c.set(r,b)}),console.log(`reverted draft ${e}`),u("doc.revert",{metadata:{docId:e}})}async function Be(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,[n,o]=e.split("/"),r=d(s,"Projects",t,"Collections",n,"Drafts",o),i=d(s,"Projects",t,"Collections",n,"Scheduled",o),c=T(s);c.update(r,{"sys.modifiedAt":h(),"sys.modifiedBy":window.firebase.user.email,"sys.scheduledAt":w(),"sys.scheduledBy":w()}),c.delete(i),await c.commit(),console.log(`unscheduled ${e}`),u("doc.unschedule",{metadata:{docId:e}})}async function _e(e,t){let s={lockedAt:h(),lockedBy:window.firebase.user.email,reason:t.reason||`Locked by ${window.firebase.user.email}.`};t.until&&(s.until=C.fromMillis(t.until));let n=g(e);await x(n,{"sys.publishingLocked":s});let r={docId:e,reason:t.reason};t.until&&(r.until=t.until),u("doc.lock_publishing",{metadata:r})}async function Me(e){let t=g(e),s={"sys.publishingLocked":w()};await x(t,s),u("doc.unlock_publishing",{metadata:{docId:e}})}async function Pe(e){let t=g(e);await x(t,{"sys.archivedAt":h(),"sys.archivedBy":window.firebase.user.email}),u("doc.archive",{metadata:{docId:e}})}async function ve(e){let t=g(e);await x(t,{"sys.archivedAt":w(),"sys.archivedBy":w()}),u("doc.unarchive",{metadata:{docId:e}})}function ee(e){return!!e?.sys?.archivedAt}function Se(e){let t=C.now().toMillis();return(e?.sys?.scheduledAt?.toMillis()||0)>t}function te(e){if(e?.sys?.publishingLocked){if(e.sys.publishingLocked.until){let t=C.now().toMillis(),s=e.sys.publishingLocked.until.toMillis();return t<s}return!0}return!1}async function Oe(e,t,s){let n=g(e),o=await D(n);if(!o.exists())throw new Error(`doc ${e} does not exist`);let r=o.data(),i=r.fields??{},c=r.sys?.locales;await se(t,{fields:i,locales:c,overwrite:s?.overwrite})}async function se(e,t){let[s,n]=e.split("/"),o=g(e),r=await D(o);if(r.exists()&&!t?.overwrite)throw new Error(`${e} already exists`);let i={id:e,collection:s,slug:n,sys:{createdAt:h(),createdBy:window.firebase.user.email,modifiedAt:h(),modifiedBy:window.firebase.user.email,locales:t?.locales??["en"]},fields:t?.fields??{}};if(r.exists()&&t?.overwrite){let c=r.data();i.sys={...c.sys,locales:t?.locales??c.sys.locales,modifiedAt:h(),modifiedBy:window.firebase.user.email}}await E(o,i),u("doc.create",{metadata:{docId:e}})}async function Le(e,t,s){let o=(window.__ROOT_CTX.rootConfig.i18n||{}).locales||["en"];function r(l){for(let y of o)if(String(y).toLowerCase()===l.toLowerCase())return y;return null}let i={};for(let l of t){if(!l.source)continue;let y={source:M(l.source)};Object.entries(l).forEach(([S,J])=>{if(S==="source")return;let O=r(S);O&&(y[O]=M(J||""))});let R=await G(y.source);i[R]=y}let a=[e.split("/")[0],e];s?.tags&&a.push(...s.tags);let b=X(),f=window.firebase.db,p=T(f),m=0;for(let l in i){let y=i[l],R=d(b,l);p.set(R,{...y,tags:F(...a)},{merge:!0}),m+=1,m>=500&&(await p.commit(),p=T(f),console.log(`saved ${m} strings`),m=0)}return m>0&&(await p.commit(),console.log(`saved ${m} strings`)),u("doc.import_translations",{metadata:{docId:e,...s?.actionMetadata},links:s?.actionLinks}),i}function g(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,[n,o]=e.split("/");return d(s,"Projects",t,"Collections",n,"Drafts",o)}function oe(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,[n,o]=e.split("/");return d(s,"Projects",t,"Collections",n,"Published",o)}function ne(e,t){let s=window.__ROOT_CTX.rootConfig.projectId,n=window.firebase.db,[o,r]=e.split("/");return d(n,"Projects",s,"Collections",o,"Drafts",r,"Versions",t)}async function ie(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,n={};e.forEach(r=>{let[i,c]=r.split("/");i in n?n[i].push(c):n[i]=[c]});let o={};return await Promise.all(Object.entries(n).map(async([r,i])=>{let c=k(s,"Projects",t,"Collections",r,"Drafts"),a=A(c,j(L(),"in",i));(await B(a)).forEach(f=>{let p=`${r}/${f.id}`;o[p]=f.data()})})),o}async function Ie(e,t){let s=window.firebase.db,n=g(e),o=k(s,n.path,"Versions"),r=t?.limit??50,i=A(o,I("sys.modifiedAt","desc"),V(r));t?.tags&&(i=A(i,j("tags","array-contains-any",t.tags))),t?.cursor&&(i=A(i,$(t.cursor)));let c=await B(i),a=[],b=null;return c.forEach(f=>{let p={...f.data(),_versionId:f.id};a.push(p),b=f}),{versions:a,lastDoc:b,hasMore:c.size===r}}async function Ve(e,t){let s=g(e),n={"sys.modifiedAt":h(),"sys.modifiedBy":window.firebase.user.email,fields:t.fields||{}};await x(s,n),u("doc.restore_version",{metadata:{docId:e,versionModifiedAt:t.sys?.modifiedAt,versionModifiedBy:t.sys?.modifiedBy}})}async function $e(e,t){let s;t==="draft"?s=g(e):t==="published"?s=oe(e):s=ne(e,t);let n=await D(s);return n.exists()?n.data():null}async function Ee(e,t){if(!t?.spreadsheetId)throw new Error("no spreadsheet id");let s=g(e),n={"sys.l10nSheet":{spreadsheetId:t.spreadsheetId,gid:t.gid||0,linkedAt:h(),linkedBy:window.firebase.user.email}};await x(s,n),u("doc.link_sheet",{metadata:{docId:e,sheetId:t}})}async function Fe(e){let t=g(e),s={"sys.l10nSheet":w()};await x(t,s),u("doc.unlink_sheet",{metadata:{docId:e}})}async function Xe(e){let t=g(e),o=(await D(t)).data()?.sys?.l10nSheet||{};return o?.spreadsheetId?{spreadsheetId:o.spreadsheetId,gid:o.gid||0}:null}function q(e,t){let s={};for(let n in e){let o=e[n];if(N(o))if(o.toMillis)s[n]=o.toMillis();else if(Object.hasOwn(o,"_array")&&Array.isArray(o._array)){let r=o._array.map(i=>{let c={...q(o[i]||{},t),_arrayKey:i};return t?.removeArrayKey&&delete c._arrayKey,c});s[n]=r}else s[n]=q(o,t);else s[n]=o}return s}async function Ge(e,t){let s=await window.fetch("/cms/api/ai.diff",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({docId:e,beforeVersion:t?.beforeVersion||"published",afterVersion:t?.afterVersion||"draft"})}),n=await s.text(),o=null;try{o=JSON.parse(n)}catch{}if(!s.ok||o?.success===!1){let r=o&&(o.error||o.message)||n;throw new Error(r||"Failed to fetch AI summary")}return typeof o?.summary=="string"?o.summary:typeof o?.data?.summary=="string"?o.data.summary:!o&&n?n:""}function N(e){return typeof e=="object"&&!Array.isArray(e)&&e!==null}function He(e){let[t,s]=e.split("/");return{id:e,collection:t,slug:s}}function z(e){if(re(e))return C.fromMillis(e.seconds*1e3);if(Q(e))return e.time=Date.now(),e;if(Array.isArray(e))return e.map(t=>z(t));if(N(e)){let t={};return Object.keys(e).forEach(s=>{t[s]=z(e[s])}),t}return e}function re(e){return e?.type==="firestore/timestamp/1.0"}export{Q as a,fe as b,W as c,Te as d,Ce as e,Y as f,Ae as g,ke as h,je as i,Be as j,_e as k,Me as l,Pe as m,ve as n,ee as o,Se as p,te as q,Oe as r,se as s,Le as t,ie as u,Ie as v,Ve as w,$e as x,Ee as y,Fe as z,Xe as A,q as B,Ge as C,He as D,z as E};
@@ -1 +0,0 @@
1
- import{d as Xe}from"./chunk-NXQVLOTK.js";import{f as He}from"./chunk-3IYZCUPI.js";import{a as Le,b as $e,d as Ve,i as Se}from"./chunk-RSVO46S3.js";import{a as Ke,b as eo}from"./chunk-ONTGW2VA.js";import{a as Je}from"./chunk-L4RHGQUG.js";import{a as N,c as H}from"./chunk-HRGYNHZ3.js";import{a as _e,b as ge,c as ae}from"./chunk-JDW4UORS.js";import{d as ye,h as ve,i as xe,j as Ce,k as Ie,l as le,m as ke,n as Ae,o as we,p as De,q as Te,r as Re,s as Pe,v as de,w as Ne,x as ze}from"./chunk-AFWBSIPL.js";import{b as be,e as Me}from"./chunk-XOQ3KDSR.js";import{b as U}from"./chunk-62UWGWON.js";import{a as _,b as F}from"./chunk-I6ICVKEC.js";import{a as M}from"./chunk-HLMBCVRX.js";import{e as he}from"./chunk-ORXEMIQC.js";import{d as fe}from"./chunk-AL3TN2KI.js";import{Ea as pe,Ha as e,Ia as Ee,La as Ue,Ma as Be,Mb as je,Oa as Oe,Pc as Ge,Ra as Fe,V as J,W as Q,a as c,aa as ue,ac as Y,bc as ee,c as j,e as ce,ea as b,fa as ie,gc as Qe,ic as Ye,j as X,jb as qe,mb as K,ra as P,ub as We,va as me,wc as Ze,ya as ne}from"./chunk-NZHF733K.js";import{d as S}from"./chunk-KUCVLANF.js";X();var oo="AddToReleaseModal";function so(s){let t=N(),u=H();return{open:()=>{t.openContextModal(oo,{...u,title:"Add docs to a release",innerProps:s,size:"600px"})}}}function mo(s){let{innerProps:t,context:u,id:l}=s,d=N(),[o,y]=c(""),[p,v]=c(!1),[m,k]=c(!1),[g,A]=c([]),[a,D]=c(""),[x,T]=c(Se()),[w,f]=c("");j(()=>{async function n(){v(!0),await U(async()=>{let E=(await $e()).filter(R=>!R.publishedAt&&!R.archivedAt);A(E)}),v(!1)}n()},[]);async function I(){o==="new"?await L():o==="existing"&&await $()}async function L(){if(!x){_({title:"Missing ID",message:"Please enter a release ID.",color:"red",autoClose:5e3});return}if(!_e(x)){_({title:"Invalid ID",message:"Release ID must use alphanumeric characters and dashes only.",color:"red",autoClose:5e3});return}k(!0),await U(async()=>{let n={docIds:t.docIds};w&&(n.description=w),await Le(x,n),_({title:`Release created: ${x}`,message:e("span",{children:["Created release with ",t.docIds.length," doc(s)."," ",e("a",{href:`/cms/releases/${x}`,children:"View release"})]}),autoClose:1e4}),d.closeAll()}),k(!1)}async function $(){if(!a){_({title:"No release selected",message:"Please select a release.",color:"red",autoClose:5e3});return}k(!0),await U(async()=>{let C=g.find(z=>z.id===a)?.docIds||[],E=Array.from(new Set([...C,...t.docIds])).sort();await Ve(a,{docIds:E});let R=E.length-C.length;_({title:`Docs added to release: ${a}`,message:e("span",{children:["Added ",R," new doc(s) to release."," ",e("a",{href:`/cms/releases/${a}`,children:"View release"})]}),autoClose:1e4}),d.closeAll()}),k(!1)}let r=!0;return(o==="new"&&x||o==="existing"&&a)&&(r=!1),e("div",{className:"AddToReleaseModal",children:e("div",{className:"AddToReleaseModal__content",children:[e("div",{className:"AddToReleaseModal__docs",children:[e("div",{className:"AddToReleaseModal__docs__label",children:["Docs to add (",t.docIds.length,")"]}),e("div",{className:"AddToReleaseModal__docs__list",children:t.docIds.map(n=>e(He,{docId:n,variant:"compact",statusBadges:!0},n))})]}),e("div",{className:"AddToReleaseModal__mode",children:[e("label",{className:`AddToReleaseModal__mode__option${o==="new"?" AddToReleaseModal__mode__option--selected":o?" AddToReleaseModal__mode__option--unselected":""}`,children:[e("div",{className:"AddToReleaseModal__mode__option__input",children:[e("input",{type:"radio",name:"release-mode",value:"new",checked:o==="new",onChange:()=>y("new")})," ","New release"]}),e("div",{className:"AddToReleaseModal__mode__option__help",children:"Create a new release with these docs."})]}),e("label",{className:`AddToReleaseModal__mode__option${o==="existing"?" AddToReleaseModal__mode__option--selected":o?" AddToReleaseModal__mode__option--unselected":""}`,children:[e("div",{className:"AddToReleaseModal__mode__option__input",children:[e("input",{type:"radio",name:"release-mode",value:"existing",checked:o==="existing",onChange:()=>y("existing")})," ","Existing release"]}),e("div",{className:"AddToReleaseModal__mode__option__help",children:"Add to an existing release."})]})]}),o==="new"&&e("div",{className:"AddToReleaseModal__form",children:[e("div",{className:"AddToReleaseModal__form__field",children:[e("label",{children:"Release ID"}),e("input",{type:"text",placeholder:"e.g. my-release",value:x,onInput:n=>{T(n.target.value)}})]}),e("div",{className:"AddToReleaseModal__form__field",children:[e("label",{children:"Description (optional)"}),e("textarea",{rows:2,placeholder:"Describe this release",value:w,onInput:n=>{f(n.target.value)}})]})]}),o==="existing"&&e("div",{className:"AddToReleaseModal__releases",children:p?e("div",{className:"AddToReleaseModal__releases__empty",children:e(J,{color:"gray",size:"sm"})}):g.length===0?e("div",{className:"AddToReleaseModal__releases__empty",children:"No unpublished releases found. Create a new one instead."}):g.map(n=>e("div",{className:`AddToReleaseModal__release${a===n.id?" AddToReleaseModal__release--selected":""}`,onClick:()=>D(n.id),children:[e("input",{type:"radio",name:"existing-release",checked:a===n.id,onChange:()=>D(n.id)}),e("div",{className:"AddToReleaseModal__release__info",children:[e("div",{className:"AddToReleaseModal__release__info__id",children:n.id}),n.description&&e("div",{className:"AddToReleaseModal__release__info__description",children:n.description})]}),e("div",{className:"AddToReleaseModal__release__docCount",children:[n.docIds?.length||0," doc(s)"]})]},n.id))}),e("div",{className:"AddToReleaseModal__buttons",children:[e(b,{variant:"outline",onClick:()=>u.closeModal(l),type:"button",size:"xs",color:"dark",children:"Cancel"}),e(b,{variant:"filled",size:"xs",color:"dark",disabled:r,loading:m,onClick:I,children:o==="new"?"Create release":"Add to release"})]})]})})}mo.id=oo;X();var to="CopyDocModal";function oe(s){let t=N(),u=H();return{open:l=>{t.openContextModal(to,{...u,innerProps:{...s,...l}})}}}function po(s){let{innerProps:t,context:u,id:l}=s,{route:d}=fe(),[o,y]=c(""),[p,v]=c(""),[m,k]=c(""),[g,A]=c(""),[a,D]=c(!1),[x,T]=c(!1),[w,f]=c({}),I=t.fromDocId,L=I.split("/")[0],$=t.fromLabel||I;j(()=>{be({tags:[I]}).then(f)},[I]);function r(C,E){let R=ae(C),z=window.__ROOT_CTX.collections[E]?.slugRegex;return R?ge(R,z):""}async function n(C){if(C.preventDefault(),T(!0),A(""),!L){A("Please select a collection."),T(!1);return}if(r(p,o)){T(!1);return}let R=ae(p),z=`${o}/${R}`;try{t.fields?await Pe(z,{fields:t.fields,overwrite:a}):await Re(I,z,{overwrite:a});let O=Object.keys(w);if(O.length>0){let i=O.map(h=>({hash:h,tags:[z]}));await Me(i,{mode:"union"})}u.closeModal(l);let q=`/cms/content/${o}/${R}`;_({title:"Copied!",message:e("div",{children:[e("div",{children:`Successfully copied ${$} to ${z}.`}),e(b,{className:"CopyDocModal__notificationButton",component:"a",href:q,size:"xs",compact:!0,variant:"default",children:"Open doc"})]}),autoClose:1e4}),t.onSuccess&&t.onSuccess(z)}catch(O){let q=String(O);A(q),q.includes("already exists")&&D(!0),T(!1);return}T(!1),d(`/cms/content/${o}/${R}`)}return e("div",{className:"CopyDocModal",children:e("form",{onSubmit:C=>n(C),children:[e("div",{className:"CopyDocModal__from",children:[e(M,{className:"CopyDocModal__from__label",size:"body",weight:"bold",children:"From:"}),e(M,{className:"CopyDocModal__from__value",size:"body-sm",children:e("code",{children:$})})]}),e("div",{className:"CopyDocModal__to",children:[e(M,{className:"CopyDocModal__to__label",size:"body",weight:"bold",children:"To:"}),e(Xe,{className:"CopyDocModal__slug",collectionId:L,onChange:C=>{y(C.collectionId),v(C.slug),k(r(C.slug,C.collectionId)),A(""),D(!1)}})]}),g&&e("div",{className:"CopyDocModal__error",children:g}),e("div",{className:"CopyDocModal__buttons",children:[e(b,{variant:"outline",onClick:()=>u.closeModal(l),type:"button",size:"xs",color:"dark",children:"Cancel"}),e(b,{variant:"filled",type:"submit",size:"xs",color:"dark",loading:x,disabled:!!m||!!g&&!a,children:a?"Overwrite?":"Submit"})]})]})})}po.id=to;X();function B(s){return e("div",{className:"DocIdBadge",children:e("code",{"data-testid":"doc-id",children:s.docId})})}var io="LockPublishingModal";function no(s){let t=N(),u=H();return{open:l=>{let d={...s,...l},o;d.unlock?o=`Unlock publishing for ${s.docId}`:d.existingLock?o=`Edit publishing lock for ${s.docId}`:o=`Lock publishing for ${s.docId}`,t.openContextModal(io,{...u,title:o,innerProps:{...s,...l},size:"600px"})}}}function fo(s){let t=l=>l<10?"0"+l:l,u=new Date(s);return`${u.getFullYear()}-${t(u.getMonth()+1)}-${t(u.getDate())}T${t(u.getHours())}:${t(u.getMinutes())}`}function Z(s){let{innerProps:t}=s;return t.unlock?e(Z.Unlock,{...s}):e(Z.Lock,{...s})}Z.Lock=s=>{let{innerProps:t,context:u,id:l}=s,d=!!t.existingLock,[o,y]=c(t.existingLock?.reason||""),[p,v]=c(t.existingLock?.until||0),[m,k]=c(!1),[g,A]=c(!1),a=N();function D(f){return f?Math.floor(new Date(f).getTime()):0}async function x(f){f.preventDefault(),k(!0),await U(async()=>{await Ie(t.docId,{reason:o,until:p}),_({title:d?"Updated!":"Locked!",message:d?`Publishing lock updated for ${t.docId}.`:`Publishing is locked for ${t.docId}.`,autoClose:1e4}),a.closeModal(l),t.onChange&&t.onChange("locked")}),k(!1)}async function T(){A(!0),await U(async()=>{await le(t.docId),_({title:"Unlocked!",message:`Publishing is unlocked for ${t.docId}.`,autoClose:1e4}),a.closeModal(l),t.onChange&&t.onChange("unlocked")}),A(!1)}return e("div",{className:"LockPublishingModal LockPublishingModal--lock",children:[e(M,{className:"LockPublishingModal__body",size:"body-sm",children:d?"Publishing is currently locked. Update the publishing lock details below, or remove the lock to re\u2011enable publishing.":"Are you sure you want to lock publishing? Content editors will not be able to publish until publishing is unlocked."}),e("form",{className:"LockPublishingModal__form",onSubmit:f=>x(f),children:[e("div",{className:"LockPublishingModal__form__section",children:e(me,{name:"reason",label:"Reason",description:"Specify a short reason so other content editors know why publishing is locked.",size:"xs",radius:0,value:o,onChange:f=>{y(f.currentTarget.value)}})}),e("div",{className:"LockPublishingModal__form__section",children:e(ue,{label:"Lock until",description:"Optional. Publishing is unlocked at the specified time. If not provided, publishing will be locked indefinitely.",size:"xs",children:e("div",{className:"DocEditor__DateTimeField",children:[e("input",{name:"until",type:"datetime-local",min:he(),defaultValue:p?fo(p):"",onChange:f=>{let L=f.target.value;v(D(L))}}),e("div",{className:"DocEditor__DateTimeField__timezone",children:["timezone: ",Intl.DateTimeFormat().resolvedOptions().timeZone]})]})})}),e("div",{className:"LockPublishingModal__buttons",children:[d&&e(b,{variant:"filled",size:"xs",color:"red",type:"button",leftIcon:e(Y,{size:14}),loading:g,disabled:m,onClick:()=>T(),className:"LockPublishingModal__buttons__unlock",children:"Unlock"}),e(b,{variant:"outline",onClick:()=>u.closeModal(l),type:"button",size:"xs",color:"dark",children:"Cancel"}),e(b,{variant:"filled",size:"xs",color:"dark",leftIcon:e(ee,{size:14}),disabled:!o||g,type:"submit",loading:m,children:d?"Save":"Lock"})]})]})]})};Z.Unlock=s=>{let{innerProps:t,context:u,id:l}=s,[d,o]=c(!1),y=N();async function p(){o(!0),await U(async()=>{await le(t.docId),_({title:"Unlocked!",message:`Publishing is unlocked for ${t.docId}.`,autoClose:1e4}),y.closeModal(l),t.onChange&&t.onChange("unlocked")})}return e("div",{className:"LockPublishingModal LockPublishingModal--unlock",children:[e(M,{className:"LockPublishingModal__body",children:"Are you sure you want to unlock publishing for the following doc? This will re-enable content editors to publish the doc."}),e(B,{docId:t.docId}),e("div",{className:"LockPublishingModal__buttons",children:[e(b,{variant:"outline",onClick:()=>u.closeModal(l),type:"button",size:"xs",color:"dark",children:"Cancel"}),e(b,{variant:"filled",size:"xs",color:"dark",leftIcon:e(Y,{size:14}),loading:d,onClick:()=>p(),children:"Unlock"})]})]})};Z.id=io;X();var ro="VersionHistoryModal",ao=50;function co(s){let t=N(),u=H();return{open:()=>{t.openContextModal(ro,{...u,title:`Version history: ${s.docId}`,innerProps:s,overflow:"inside",size:"min(calc(100% - 32px), 720px)"})}}}function _o(s){let{innerProps:t,context:u,id:l}=s,d=t.docId,[o,y]=c(!0),[p,v]=c(!1),[m,k]=c([]),[g,A]=c(!1),[a,D]=c([]),[x,T]=c(!1),[w,f]=c(null),I=ce(null),L=oe({fromDocId:d}),$=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});async function r(){y(!0);let[i,h]=await Promise.all([de(d,{limit:ao}),ze(d,"draft")]);I.current=i.lastDoc,A(i.hasMore);let V={_versionId:"draft",sys:{modifiedAt:h?.sys?.modifiedAt||{toDate:()=>new Date},modifiedBy:h?.sys?.modifiedBy||"Unknown"}};k([V,...i.versions]),D(["draft"]),y(!1)}async function n(){if(!g||p)return;v(!0);let i=await de(d,{limit:ao,cursor:I.current});I.current=i.lastDoc,A(i.hasMore),k(h=>[...h,...i.versions]),v(!1)}async function C(i){await Ne(d,i),_({title:"Saved!",message:`Restored ${d} to ${$.format(i.sys.modifiedAt.toDate())}.`,autoClose:5e3}),t.onRestore&&t.onRestore({version:i})}function E(i){let h=`${d}@${i._versionId}`,V=i.sys?.modifiedAt?.toDate();if(V){let W=go(V);h=`${d}@${W}`}L.open({fields:i.fields||{},fromLabel:h,onSuccess:()=>{u.closeModal(l)}})}function R(i){a.includes(i)?D(a.filter(h=>h!==i)):a.length<2&&D([...a,i])}function z(){if(a.length!==2)return"#";let i=m.find(te=>te._versionId===a[0]),h=m.find(te=>te._versionId===a[1]);if(!i||!h)return"#";let V=m.indexOf(i),W=m.indexOf(h),re=V>W?i:h,G=V>W?h:i,se=lo(d,re._versionId),uo=lo(d,G._versionId);return`/cms/compare?left=${se}&right=${uo}`}j(()=>{r()},[]);let O=m.filter(i=>i._versionId==="draft"||!x?!0:i.tags?.includes("published")),q=m.some(i=>i.tags?.includes("published"));return o?e(J,{}):e("div",{className:"VersionHistoryModal",children:[e("div",{className:"VersionHistoryModal__actions",children:[e(b,{component:a.length===2?"a":"button",variant:"filled",size:"xs",disabled:a.length!==2,href:a.length===2?z():void 0,target:a.length===2?"_blank":void 0,rightIcon:e(Fe,{size:16}),children:"Compare"}),q&&e(ie,{size:"xs",label:"Published versions only",checked:x,onChange:i=>T(i.currentTarget.checked)})]}),O.length===0?e(M,{className:"VersionHistoryModal__versionsEmpty",size:"body",children:[e("p",{children:"No versions found."}),e("p",{className:"VersionHistoryModal__versionsEmpty__developer",children:"For developers: Configure the Root CMS cron job to populate versions."})]}):e(S,{children:[e(pe,{className:"VersionHistoryModal__versions",children:[e("thead",{children:e("tr",{children:[e("th",{children:e("span",{className:"VersionHistoryModal__versions__selectLabel",children:"Select"})}),e("th",{children:"modified at"}),e("th",{children:"modified by"}),e("th",{children:"actions"})]})}),e("tbody",{children:O.map(i=>{let h=i._versionId==="draft",V=a.includes(i._versionId),W=!V&&a.length>=2;return e("tr",{children:[e("td",{children:e(ie,{size:"xs",checked:V,disabled:W,onChange:()=>R(i._versionId),className:"VersionHistoryModal__versions__checkbox"})}),e("td",{children:e("div",{className:"VersionHistoryModal__versions__modifiedAt",children:[e(M,{size:"body-sm",className:"VersionHistoryModal__versions__modifiedAt__text",children:h?e("span",{title:"Current Draft",children:[$.format(i.sys.modifiedAt.toDate())," ","(Latest)"]}):e(S,{children:[$.format(i.sys.modifiedAt.toDate()),i.tags?.includes("published")&&e("span",{className:"VersionHistoryModal__publishedLabel",children:"(Published)"})]})}),i.publishMessage&&e(ne,{withCloseButton:!0,opened:w===`${i._versionId}-message`,onClose:()=>f(null),position:"right",withArrow:!0,shadow:"md",width:320,classNames:{body:"VersionHistoryModal__popover__body",arrow:"VersionHistoryModal__popover__arrow",close:"VersionHistoryModal__popover__close"},target:e(Q,{size:"xs",variant:"light",className:"VersionHistoryModal__messageIcon",onClick:()=>f(w===`${i._versionId}-message`?null:`${i._versionId}-message`),children:e(Qe,{size:18})}),children:e("div",{className:"VersionHistoryModal__message",children:i.publishMessage})}),(()=>{let G=i.tags?.find(se=>se.startsWith("release:"))?.replace("release:","");return G&&e(ne,{withCloseButton:!0,opened:w===`${i._versionId}-release`,onClose:()=>f(null),position:"right",withArrow:!0,shadow:"md",width:320,target:e(Q,{size:"xs",variant:"light",className:"VersionHistoryModal__messageIcon",onClick:()=>f(w===`${i._versionId}-release`?null:`${i._versionId}-release`),children:e(Ze,{size:18})}),children:e("div",{className:"VersionHistoryModal__message",children:[e("strong",{children:"Release:"})," ",G]})})})()]})}),e("td",{children:e(M,{size:"body-sm",children:i.sys.modifiedBy})}),e("td",{children:e("div",{className:"VersionHistoryModal__versions__buttons",children:!h&&e(S,{children:[e(b,{variant:"default",size:"xs",compact:!0,onClick:()=>C(i),children:"restore"}),e(b,{variant:"default",size:"xs",compact:!0,onClick:()=>E(i),leftIcon:e(K,{size:12}),children:"copy to doc"})]})})})]},i._versionId)})})]}),g&&e("div",{className:"VersionHistoryModal__loadMore",children:e(b,{variant:"subtle",size:"xs",loading:p,onClick:n,children:"Load more versions"})})]})]})}function lo(s,t){return encodeURIComponent(`${s}@${t}`).replaceAll("%2F","/").replaceAll("%40","@")}function go(s){let t=s.getFullYear(),u=String(s.getMonth()+1).padStart(2,"0"),l=String(s.getDate()).padStart(2,"0"),d=String(s.getHours()).padStart(2,"0"),o=String(s.getMinutes()).padStart(2,"0");return`${t}-${u}-${l}T${d}:${o}`}_o.id=ro;function Js(s){let{roles:t}=Je(),u=window.firebase.user.email||"",l=eo(t,u),d=Ke(t,u),o=s.docId,y=s.data||{},p=y.sys||{},v=we(y),m=N(),k=oe({fromDocId:o,onSuccess:r=>{s.onAction&&s.onAction({action:"copy",newDocId:r})}}),g=H(),A=co({docId:o}),a=no({docId:o}),D=so({docIds:[o]}),x=()=>{let r=`revert-draft-${o}`,n=m.openConfirmModal({...g,title:`Discard draft edits for ${o}`,children:e(S,{children:[e(M,{size:"body-sm",weight:"semi-bold",className:"DocActionsMenu__confirmText",children:"Are you sure you want to discard draft changes for the following doc? The doc data will revert to the published version. There is no undo."}),e(B,{docId:o})]}),labels:{confirm:"Discard draft edits",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{_({id:r,title:"Discarding draft edits",message:`Discarding draft edits of ${o}...`,loading:!0,autoClose:!1}),await xe(o),F({id:r,title:"Discarded draft edits",message:`Successfully reverted ${o} back to its published version`,loading:!1,autoClose:5e3}),m.closeModal(n),s.onAction&&s.onAction({action:"revert-draft"})}})},T=()=>{let r=`unpublish-doc-${o}`,n=m.openConfirmModal({...g,title:`Unpublish ${o}`,children:e(S,{children:[e(M,{size:"body-sm",weight:"semi-bold",className:"DocActionsMenu__confirmText",children:"Are you sure you want to unpublish the following doc? There is no undo."}),e(B,{docId:o})]}),labels:{confirm:"Unpublish",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{_({id:r,title:"Unpublishing doc",message:`Requesting unpublish of ${o}...`,loading:!0,autoClose:!1}),await ve(o),F({id:r,title:"Unpublished!",message:`Successfully unpublished ${o}!`,loading:!1,autoClose:5e3}),m.closeModal(n),s.onAction&&s.onAction({action:"unpublish"})}})},w=r=>{s.onAction&&s.onAction({action:r})},f=()=>{let r=`unschedule-doc-${o}`,n=m.openConfirmModal({...g,title:`Unschedule ${o}`,children:e(S,{children:[e(M,{size:"body-sm",weight:"semi-bold",className:"DocActionsMenu__confirmText",children:"Are you sure you want to unschedule the following doc?"}),e(B,{docId:o})]}),labels:{confirm:"Unschedule",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{_({id:r,title:"Unschedule doc",message:`Requesting unschedule of ${o}...`,loading:!0,autoClose:!1}),await Ce(o),F({id:r,title:"Unscheduled!",message:`Successfully unscheduled ${o}!`,loading:!1,autoClose:5e3}),m.closeModal(n),s.onAction&&s.onAction({action:"unschedule"})}})},I=()=>{let r=`archive-doc-${o}`,n=m.openConfirmModal({...g,title:`Archive ${o}`,children:e(S,{children:[e(M,{size:"body-sm",weight:"semi-bold",className:"DocActionsMenu__confirmText",children:"Are you sure you want to archive the following doc? Archived docs are hidden from the collection list by default but can be restored later."}),e(B,{docId:o})]}),labels:{confirm:"Archive",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{_({id:r,title:"Archiving doc",message:`Requesting archive of ${o}...`,loading:!0,autoClose:!1}),await ke(o),F({id:r,title:"Archived!",message:`Successfully archived ${o}!`,loading:!1,autoClose:5e3}),m.closeModal(n),s.onAction&&s.onAction({action:"archive"})}})},L=async()=>{let r=`unarchive-doc-${o}`;_({id:r,title:"Unarchiving doc",message:`Requesting unarchive of ${o}...`,loading:!0,autoClose:!1}),await Ae(o),F({id:r,title:"Unarchived!",message:`Successfully unarchived ${o}!`,loading:!1,autoClose:5e3}),s.onAction&&s.onAction({action:"unarchive"})},$=()=>{let r=`delete-doc-${o}`,n=m.openConfirmModal({...g,title:"Delete doc",children:e(S,{children:[e(M,{size:"body-sm",weight:"semi-bold",className:"DocActionsMenu__confirmText",children:"Are you sure you want to delete the following doc? There is no undo."}),e(B,{docId:o})]}),labels:{confirm:"Delete",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{_({id:r,title:"Deleting doc",message:`Requesting deletion of ${o}...`,loading:!0,autoClose:!1}),await ye(o),F({id:r,title:"Deleted!",message:`Successfully deleted ${o}!`,loading:!1,autoClose:5e3}),m.closeModal(n),s.onDelete&&s.onDelete(),s.onAction&&s.onAction({action:"delete"})}})};return e(P,{className:"CollectionPage__collection__docsList__doc__controls__menu",position:"bottom",control:e(Q,{className:"DocEditor__ArrayField__item__header__controls__dots",children:e(We,{size:16})}),children:[!v&&e(P.Item,{icon:e(Ye,{size:20}),onClick:()=>D.open(),disabled:!d,children:"Add to release"}),e(P.Item,{icon:e(je,{size:20}),onClick:()=>A.open(),children:"Version history"}),e(P.Item,{icon:e(K,{size:20}),onClick:()=>k.open(),disabled:!l,children:"Copy"}),!v&&p.modifiedAt&&p.publishedAt&&p.modifiedAt>p.publishedAt&&e(P.Item,{icon:e(Oe,{size:20}),onClick:()=>x(),disabled:!l,children:"Discard draft edits"}),!v&&p.firstPublishedAt&&e(P.Item,{icon:e(qe,{size:20}),onClick:()=>T(),disabled:!d,children:"Unpublish"}),!v&&p.scheduledAt&&e(P.Item,{icon:e(Ee,{size:20}),onClick:()=>f(),disabled:!d,children:"Unschedule"}),!v&&(Te(y)?e(P.Item,{icon:e(Y,{size:20}),onClick:()=>a.open({unlock:!0,onChange:w}),disabled:!l,children:"Unlock publishing"}):e(P.Item,{icon:e(ee,{size:20}),onClick:()=>a.open({unlock:!1,onChange:w}),disabled:!l||De(y),children:"Lock publishing"})),v?e(P.Item,{icon:e(Ue,{size:20}),onClick:()=>L(),disabled:!l,children:"Unarchive"}):!p.publishedAt&&e(P.Item,{icon:e(Be,{size:20}),onClick:()=>I(),disabled:!l,children:"Archive"}),e(P.Item,{icon:e(Ge,{size:20}),onClick:()=>$(),disabled:!l,children:"Delete"})]})}export{so as a,mo as b,po as c,B as d,no as e,Z as f,_o as g,Js as h};
@@ -1 +0,0 @@
1
- import{C as at,D as st,G as pt,J as ut,K as ft,M as lt,N as ct,R as dt,X as mt,Z as ht,c as T,e as w,n as it,na as L,s as S,t as C,ua as Et,v as l,y as h}from"./chunk-NZHF733K.js";import{j as ot}from"./chunk-KUCVLANF.js";h();var R={show:"mantine:show-notification",hide:"mantine:hide-notification",update:"mantine:update-notification",clean:"mantine:clean-notifications",cleanQueue:"mantine:clean-notifications-queue"};function G(t,e){return new CustomEvent(t,{detail:e})}function $t(t){window.dispatchEvent(G(R.show,t))}function Yt(t){window.dispatchEvent(G(R.update,t))}function Bt(t){window.dispatchEvent(G(R.hide,t))}function vt(t){let e={show:n=>t.showNotification(n.detail),hide:n=>t.hideNotification(n.detail),update:n=>t.updateNotification(n.detail.id,n.detail),clean:t.clean,cleanQueue:t.cleanQueue};T(()=>(Object.keys(e).forEach(n=>{window.addEventListener(R[n],e[n])}),()=>{Object.keys(e).forEach(n=>{window.removeEventListener(R[n],e[n])})}),[])}h();function D(t,e){return D=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,o){return i.__proto__=o,i},D(t,e)}function I(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,D(t,e)}h();h();var W={disabled:!1};h();var O=l.createContext(null);var xt=function(e){return e.scrollTop};var M="unmounted",y="exited",_="entering",b="entered",Q="exiting",E=(function(t){I(e,t);function e(i,o){var r;r=t.call(this,i,o)||this;var a=o,s=a&&!a.isMounting?i.enter:i.appear,p;return r.appearStatus=null,i.in?s?(p=y,r.appearStatus=_):p=b:i.unmountOnExit||i.mountOnEnter?p=M:p=y,r.state={status:p},r.nextCallback=null,r}e.getDerivedStateFromProps=function(o,r){var a=o.in;return a&&r.status===M?{status:y}:null};var n=e.prototype;return n.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},n.componentDidUpdate=function(o){var r=null;if(o!==this.props){var a=this.state.status;this.props.in?a!==_&&a!==b&&(r=_):(a===_||a===b)&&(r=Q)}this.updateStatus(!1,r)},n.componentWillUnmount=function(){this.cancelNextCallback()},n.getTimeouts=function(){var o=this.props.timeout,r,a,s;return r=a=s=o,o!=null&&typeof o!="number"&&(r=o.exit,a=o.enter,s=o.appear!==void 0?o.appear:a),{exit:r,enter:a,appear:s}},n.updateStatus=function(o,r){if(o===void 0&&(o=!1),r!==null)if(this.cancelNextCallback(),r===_){if(this.props.unmountOnExit||this.props.mountOnEnter){var a=this.props.nodeRef?this.props.nodeRef.current:l.findDOMNode(this);a&&xt(a)}this.performEnter(o)}else this.performExit();else this.props.unmountOnExit&&this.state.status===y&&this.setState({status:M})},n.performEnter=function(o){var r=this,a=this.props.enter,s=this.context?this.context.isMounting:o,p=this.props.nodeRef?[s]:[l.findDOMNode(this),s],u=p[0],f=p[1],c=this.getTimeouts(),d=s?c.appear:c.enter;if(!o&&!a||W.disabled){this.safeSetState({status:b},function(){r.props.onEntered(u)});return}this.props.onEnter(u,f),this.safeSetState({status:_},function(){r.props.onEntering(u,f),r.onTransitionEnd(d,function(){r.safeSetState({status:b},function(){r.props.onEntered(u,f)})})})},n.performExit=function(){var o=this,r=this.props.exit,a=this.getTimeouts(),s=this.props.nodeRef?void 0:l.findDOMNode(this);if(!r||W.disabled){this.safeSetState({status:y},function(){o.props.onExited(s)});return}this.props.onExit(s),this.safeSetState({status:Q},function(){o.props.onExiting(s),o.onTransitionEnd(a.exit,function(){o.safeSetState({status:y},function(){o.props.onExited(s)})})})},n.cancelNextCallback=function(){this.nextCallback!==null&&(this.nextCallback.cancel(),this.nextCallback=null)},n.safeSetState=function(o,r){r=this.setNextCallback(r),this.setState(o,r)},n.setNextCallback=function(o){var r=this,a=!0;return this.nextCallback=function(s){a&&(a=!1,r.nextCallback=null,o(s))},this.nextCallback.cancel=function(){a=!1},this.nextCallback},n.onTransitionEnd=function(o,r){this.setNextCallback(r);var a=this.props.nodeRef?this.props.nodeRef.current:l.findDOMNode(this),s=o==null&&!this.props.addEndListener;if(!a||s){setTimeout(this.nextCallback,0);return}if(this.props.addEndListener){var p=this.props.nodeRef?[this.nextCallback]:[a,this.nextCallback],u=p[0],f=p[1];this.props.addEndListener(u,f)}o!=null&&setTimeout(this.nextCallback,o)},n.render=function(){var o=this.state.status;if(o===M)return null;var r=this.props,a=r.children,s=r.in,p=r.mountOnEnter,u=r.unmountOnExit,f=r.appear,c=r.enter,d=r.exit,v=r.timeout,m=r.addEndListener,U=r.onEnter,N=r.onEntering,B=r.onEntered,Z=r.onExit,J=r.onExiting,H=r.onExited,K=r.nodeRef,j=L(r,["children","in","mountOnEnter","unmountOnExit","appear","enter","exit","timeout","addEndListener","onEnter","onEntering","onEntered","onExit","onExiting","onExited","nodeRef"]);return l.createElement(O.Provider,{value:null},typeof a=="function"?a(o,j):l.cloneElement(l.Children.only(a),j))},e})(l.Component);E.contextType=O;E.propTypes={};function P(){}E.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:P,onEntering:P,onEntered:P,onExit:P,onExiting:P,onExited:P};E.UNMOUNTED=M;E.EXITED=y;E.ENTERING=_;E.ENTERED=b;E.EXITING=Q;var X=E;function q(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}h();h();function k(t,e){var n=function(r){return e&&S(r)?e(r):r},i=Object.create(null);return t&&it.map(t,function(o){return o}).forEach(function(o){i[o.key]=n(o)}),i}function Zt(t,e){t=t||{},e=e||{};function n(f){return f in e?e[f]:t[f]}var i=Object.create(null),o=[];for(var r in t)r in e?o.length&&(i[r]=o,o=[]):o.push(r);var a,s={};for(var p in e){if(i[p])for(a=0;a<i[p].length;a++){var u=i[p][a];s[i[p][a]]=n(u)}s[p]=n(p)}for(a=0;a<o.length;a++)s[o[a]]=n(o[a]);return s}function g(t,e,n){return n[e]!=null?n[e]:t.props[e]}function yt(t,e){return k(t.children,function(n){return C(n,{onExited:e.bind(null,n),in:!0,appear:g(n,"appear",t),enter:g(n,"enter",t),exit:g(n,"exit",t)})})}function _t(t,e,n){var i=k(t.children),o=Zt(e,i);return Object.keys(o).forEach(function(r){var a=o[r];if(S(a)){var s=r in e,p=r in i,u=e[r],f=S(u)&&!u.props.in;p&&(!s||f)?o[r]=C(a,{onExited:n.bind(null,a),in:!0,exit:g(a,"exit",t),enter:g(a,"enter",t)}):!p&&s&&!f?o[r]=C(a,{in:!1}):p&&s&&S(u)&&(o[r]=C(a,{onExited:n.bind(null,a),in:u.props.in,exit:g(a,"exit",t),enter:g(a,"enter",t)}))}}),o}var Jt=Object.values||function(t){return Object.keys(t).map(function(e){return t[e]})},Kt={component:"div",childFactory:function(e){return e}},z=(function(t){I(e,t);function e(i,o){var r;r=t.call(this,i,o)||this;var a=r.handleExited.bind(q(r));return r.state={contextValue:{isMounting:!0},handleExited:a,firstRender:!0},r}var n=e.prototype;return n.componentDidMount=function(){this.mounted=!0,this.setState({contextValue:{isMounting:!1}})},n.componentWillUnmount=function(){this.mounted=!1},e.getDerivedStateFromProps=function(o,r){var a=r.children,s=r.handleExited,p=r.firstRender;return{children:p?yt(o,s):_t(o,a,s),firstRender:!1}},n.handleExited=function(o,r){var a=k(this.props.children);o.key in a||(o.props.onExited&&o.props.onExited(r),this.mounted&&this.setState(function(s){var p=ht({},s.children);return delete p[o.key],{children:p}}))},n.render=function(){var o=this.props,r=o.component,a=o.childFactory,s=L(o,["component","childFactory"]),p=this.state.contextValue,u=Jt(this.state.children).map(a);return delete s.appear,delete s.enter,delete s.exit,r===null?l.createElement(O.Provider,{value:p},u):l.createElement(O.Provider,{value:p},l.createElement(r,s,u))},e})(l.Component);z.propTypes={};z.defaultProps=Kt;var A=z;h();var $=ot(null);$.displayName="@mantine/notifications/NotificationsContext";function te([t,e],n,i){let o={};return t==="top"&&(o.top=i),t==="bottom"&&(o.bottom=i),e==="left"&&(o.left=i),e==="right"&&(o.right=i),e==="center"&&(o.left="50%",o.transform="translateX(-50%)"),o}var gt=te;var ee=Object.defineProperty,Nt=Object.getOwnPropertySymbols,ne=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable,Ot=(t,e,n)=>e in t?ee(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Pt=(t,e)=>{for(var n in e||(e={}))ne.call(e,n)&&Ot(t,n,e[n]);if(Nt)for(var n of Nt(e))re.call(e,n)&&Ot(t,n,e[n]);return t},bt={left:"translateX(-100%)",right:"translateX(100%)","top-center":"translateY(-100%)","bottom-center":"translateY(100%)"},oe={left:"translateX(0)",right:"translateX(0)","top-center":"translateY(0)","bottom-center":"translateY(0)"};function ie({state:t,maxHeight:e,positioning:n,transitionDuration:i}){let[o,r]=n,a=r==="center"?`${o}-center`:r,s={opacity:0,maxHeight:e,transform:bt[a],transitionDuration:`${i}ms, ${i}ms, ${i}ms`,transitionTimingFunction:"cubic-bezier(.51,.3,0,1.21), cubic-bezier(.51,.3,0,1.21), linear",transitionProperty:"opacity, transform, max-height"},p={opacity:1,transform:oe[a]},u={opacity:0,maxHeight:0,transform:bt[a]},f={entering:p,entered:p,exiting:u,exited:u};return Pt(Pt({},s),f[t])}var Tt=ie;h();function ae(t,e){return typeof e=="number"?e:e===!1||t===!1?!1:t}var wt=ae;var se=Object.defineProperty,pe=Object.defineProperties,ue=Object.getOwnPropertyDescriptors,V=Object.getOwnPropertySymbols,Dt=Object.prototype.hasOwnProperty,It=Object.prototype.propertyIsEnumerable,St=(t,e,n)=>e in t?se(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Ct=(t,e)=>{for(var n in e||(e={}))Dt.call(e,n)&&St(t,n,e[n]);if(V)for(var n of V(e))It.call(e,n)&&St(t,n,e[n]);return t},fe=(t,e)=>pe(t,ue(e)),Rt=(t,e)=>{var n={};for(var i in t)Dt.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(t!=null&&V)for(var i of V(t))e.indexOf(i)<0&&It.call(t,i)&&(n[i]=t[i]);return n};function Mt(t){var e=t,{notification:n,autoClose:i,onHide:o,innerRef:r}=e,a=Rt(e,["notification","autoClose","onHide","innerRef"]);let s=n,{autoClose:p}=s,u=Rt(s,["autoClose"]),f=wt(i,p),c=w(),d=()=>{o(n.id),window.clearTimeout(c.current)},v=()=>{clearTimeout(c.current)},m=()=>{typeof f=="number"&&(c.current=window.setTimeout(d,f))};return T(()=>{typeof n.onOpen=="function"&&n.onOpen(n)},[]),T(()=>(m(),v),[i,n.autoClose]),l.createElement(Et,fe(Ct(Ct({},u),a),{onClose:d,onMouseEnter:v,onMouseLeave:m,ref:r}),n.message)}Mt.displayName="@mantine/notifications/NotificationContainer";var jt=Mt;var le=st(t=>({notifications:{width:`calc(100% - ${t.spacing.md*2}px)`,boxSizing:"border-box",position:"fixed",zIndex:1e3},notification:{"&:not(:first-of-type)":{marginTop:t.spacing.sm}}})),Lt=le;var ce=Object.defineProperty,de=Object.defineProperties,me=Object.getOwnPropertyDescriptors,kt=Object.getOwnPropertySymbols,he=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable,Vt=(t,e,n)=>e in t?ce(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ve=(t,e)=>{for(var n in e||(e={}))he.call(e,n)&&Vt(t,n,e[n]);if(kt)for(var n of kt(e))Ee.call(e,n)&&Vt(t,n,e[n]);return t},xe=(t,e)=>de(t,me(e));function ye({limit:t}){let{state:e,queue:n,update:i,cleanQueue:o}=lt({initialValues:[],limit:t});return{notifications:e,queue:n,showNotification:u=>{let f=u.id||ft();return i(c=>u.id&&c.some(d=>d.id===u.id)?c:[...c,xe(ve({},u),{id:f})]),f},updateNotification:(u,f)=>i(c=>{let d=c.findIndex(m=>m.id===u);if(d===-1)return c;let v=[...c];return v[d]=f,v}),hideNotification:u=>i(f=>f.filter(c=>c.id===u?(typeof c.onClose=="function"&&c.onClose(c),!1):!0)),cleanQueue:o,clean:()=>i(()=>[])}}var Ft=ye;var _e=Object.defineProperty,F=Object.getOwnPropertySymbols,Ht=Object.prototype.hasOwnProperty,Gt=Object.prototype.propertyIsEnumerable,Ut=(t,e,n)=>e in t?_e(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Y=(t,e)=>{for(var n in e||(e={}))Ht.call(e,n)&&Ut(t,n,e[n]);if(F)for(var n of F(e))Gt.call(e,n)&&Ut(t,n,e[n]);return t},ge=(t,e)=>{var n={};for(var i in t)Ht.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(t!=null&&F)for(var i of F(t))e.indexOf(i)<0&&Gt.call(t,i)&&(n[i]=t[i]);return n},Ne=["top-left","top-right","top-center","bottom-left","bottom-right","bottom-center"];function Wt(t){var e=t,{className:n,position:i="bottom-right",autoClose:o=4e3,transitionDuration:r=250,containerWidth:a=440,notificationMaxHeight:s=200,limit:p=5,zIndex:u=at("overlay"),style:f,children:c}=e,d=ge(e,["className","position","autoClose","transitionDuration","containerWidth","notificationMaxHeight","limit","zIndex","style","children"]);let v=ut(),m=w({}),U=w(0),{notifications:N,queue:B,showNotification:Z,updateNotification:J,hideNotification:H,clean:K,cleanQueue:j}=Ft({limit:p}),tt=ct()?1:r,{classes:et,cx:Qt,theme:Xt}=Lt(),nt=(Ne.includes(i)?i:"bottom-right").split("-"),rt={notifications:N,queue:B,showNotification:Z,hideNotification:H,updateNotification:J,clean:K,cleanQueue:j};pt(()=>{N.length>U.current&&setTimeout(()=>v(),0),U.current=N.length},[N]),vt(rt);let qt=N.map(x=>l.createElement(X,{key:x.id,timeout:tt,onEnter:()=>m.current[x.id].offsetHeight,nodeRef:{current:m.current[x.id]}},zt=>l.createElement(jt,{innerRef:At=>{m.current[x.id]=At},notification:x,onHide:H,className:et.notification,autoClose:o,sx:[Y({},Tt({state:zt,positioning:nt,transitionDuration:tt,maxHeight:s})),...Array.isArray(x.sx)?x.sx:[x.sx]]})));return l.createElement($.Provider,{value:rt},l.createElement(mt,{zIndex:u},l.createElement(dt,Y({className:Qt(et.notifications,n),style:f,sx:Y({maxWidth:a},gt(nt,a,Xt.spacing.md))},d),l.createElement(A,null,qt))),c)}Wt.displayName="@mantine/notifications/NotificationsProvider";export{$t as a,Yt as b,Bt as c,Wt as d};