@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
@@ -0,0 +1 @@
1
+ import{a as X,f as G,g as P,h as H}from"./chunk-UFQSZ6J2.js";import{f as u}from"./chunk-ORXEMIQC.js";import{a as C,b as j,c as d,f as L,g as A,h as B,i as I,j as V,l as $,n as D,o as _,p as E,q as x,s as M,t as w,u as h,v as F,w as T}from"./chunk-EGEB6N4J.js";function Q(e){return typeof e=="object"&&!Array.isArray(e)&&e!==null}function U(e){return Q(e)&&Array.isArray(e.blocks)&&e.blocks.length>0}var v=new Map;function W(e){return v.get(e)||null}async function he(e){let t=W(e);if(t)return t;let s=g(e),o=(await D(s)).data();return Y(e,o),o}function Y(e,t){v.set(e,t)}function S(e){v.delete(e)}function q(e){for(let t of e)S(t)}async function Ce(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 Ae(e,t){await Z([e],t)}async function Z(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 re(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}`);ee(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})}q(e)}function ee(e,t,s,n,o){if(se(s))throw new Error(`publishing is locked for doc: ${s.id}`);if(te(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 ke(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 M(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 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,"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}}),S(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,"Published",o);await M(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 _e(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 Me(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 Pe(e){let t=g(e),s={"sys.publishingLocked":w()};await x(t,s),u("doc.unlock_publishing",{metadata:{docId:e}})}async function ve(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 Se(e){let t=g(e);await x(t,{"sys.archivedAt":w(),"sys.archivedBy":w()}),u("doc.unarchive",{metadata:{docId:e}})}function te(e){return!!e?.sys?.archivedAt}function Oe(e){let t=C.now().toMillis();return(e?.sys?.scheduledAt?.toMillis()||0)>t}function se(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 Le(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 oe(t,{fields:i,locales:c,overwrite:s?.overwrite})}async function oe(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 Ie(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:P(l.source)};Object.entries(l).forEach(([O,K])=>{if(O==="source")return;let k=r(O);k&&!H(k)&&(y[k]=P(K||""))});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 ne(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 ie(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 re(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=j(s,"Projects",t,"Collections",r,"Drafts"),a=A(c,B(L(),"in",i));(await _(a)).forEach(f=>{let p=`${r}/${f.id}`;o[p]=f.data()})})),o}async function Ve(e,t){let s=window.firebase.db,n=g(e),o=j(s,n.path,"Versions"),r=t?.limit??50,i=A(o,I("sys.modifiedAt","desc"),V(r));t?.tags&&(i=A(i,B("tags","array-contains-any",t.tags))),t?.cursor&&(i=A(i,$(t.cursor)));let c=await _(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 $e(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 Ee(e,t){let s;t==="draft"?s=g(e):t==="published"?s=ne(e):s=ie(e,t);let n=await D(s);return n.exists()?n.data():null}async function Fe(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 Xe(e){let t=g(e),s={"sys.l10nSheet":w()};await x(t,s),u("doc.unlink_sheet",{metadata:{docId:e}})}async function Ge(e){let t=g(e),o=(await D(t)).data()?.sys?.l10nSheet||{};return o?.spreadsheetId?{spreadsheetId:o.spreadsheetId,gid:o.gid||0}:null}function z(e,t){let s={};for(let n in e){let o=e[n];if(J(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={...z(o[i]||{},t),_arrayKey:i};return t?.removeArrayKey&&delete c._arrayKey,c});s[n]=r}else s[n]=z(o,t);else s[n]=o}return s}async function He(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 J(e){return typeof e=="object"&&!Array.isArray(e)&&e!==null}function Qe(e){let[t,s]=e.split("/");return{id:e,collection:t,slug:s}}function N(e){if(ce(e))return C.fromMillis(e.seconds*1e3);if(U(e))return e.time=Date.now(),e;if(Array.isArray(e))return e.map(t=>N(t));if(J(e)){let t={};return Object.keys(e).forEach(s=>{t[s]=N(e[s])}),t}return e}function ce(e){return e?.type==="firestore/timestamp/1.0"}export{U as a,he as b,Y as c,Ce as d,Ae as e,Z as f,ke as g,je as h,Be as i,_e as j,Me as k,Pe as l,ve as m,Se as n,te as o,Oe as p,se as q,Le as r,oe as s,Ie as t,re as u,Ve as v,$e as w,Ee as x,Fe as y,Xe as z,Ge as A,z as B,He as C,Qe as D,N as E};
@@ -1 +1 @@
1
- import{a,h as n,j as s}from"./chunk-NZHF733K.js";s();s();function T(e,r){let[c,i]=a(()=>{try{let t=window.localStorage.getItem(e);return t?JSON.parse(t):r}catch(t){return console.error(t),r}}),u=n(t=>{i(l=>{let o=typeof t=="function"?t(l):t;return window.localStorage.setItem(e,JSON.stringify(o)),o})},[e]);return[c,u]}export{T as a};
1
+ import{a,h as n,j as s}from"./chunk-4CUWZQXT.js";s();s();function T(e,r){let[c,i]=a(()=>{try{let t=window.localStorage.getItem(e);return t?JSON.parse(t):r}catch(t){return console.error(t),r}}),u=n(t=>{i(l=>{let o=typeof t=="function"?t(l):t;return window.localStorage.setItem(e,JSON.stringify(o)),o})},[e]);return[c,u]}export{T as a};
@@ -0,0 +1 @@
1
+ import{d as Xe}from"./chunk-IKED2IGU.js";import{f as He}from"./chunk-4IXGYXA2.js";import{a as Le,b as $e,d as Ve,i as Se}from"./chunk-UA7UCTX5.js";import{a as Ke,b as eo}from"./chunk-TDKVKTW4.js";import{a as Je}from"./chunk-D37DCENS.js";import{a as N,c as H}from"./chunk-KPJ53X55.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-NQ5ARARP.js";import{b as be,e as Me}from"./chunk-UFQSZ6J2.js";import{b as U}from"./chunk-CVGYBXVH.js";import{a as _,b as F}from"./chunk-AXETBZ6T.js";import{a as M}from"./chunk-N5Y5OWTV.js";import{e as he}from"./chunk-ORXEMIQC.js";import{d as fe}from"./chunk-RPOP6MVJ.js";import{$ as ue,$b as Y,Da as pe,Ga as e,Ha as Ee,Ka as Ue,La as Be,Lb as je,Na as Oe,Oc as Ge,Qa as Fe,V as J,W as Q,a as c,ac as ee,c as j,da as b,e as ce,ea as ie,fc as Qe,hc as Ye,ib as qe,j as X,lb as K,qa as P,tb as We,ua as me,vc as Ze,xa as ne}from"./chunk-4CUWZQXT.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};