@blinkk/root-cms 3.1.6 → 3.1.7

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 (105) hide show
  1. package/dist/app.js +1 -1
  2. package/dist/{chunk-U4TMO2LI.js → chunk-NIBAHWGP.js} +2 -2
  3. package/dist/plugin.js +1 -1
  4. package/dist/ui/AIPage-XPE7F5AF.js +1 -0
  5. package/dist/ui/AssetsPage-C3ZEENBO.js +1 -0
  6. package/dist/ui/CollectionPage-VQ4WJHJB.js +1 -0
  7. package/dist/ui/ComparePage-VKOXKID4.js +1 -0
  8. package/dist/ui/{DataPage-YEIS7HBN.js → DataPage-JXZ2Z3DG.js} +1 -1
  9. package/dist/ui/{DataSourcePage-VD6YBDRW.js → DataSourcePage-X3NSUOTP.js} +1 -1
  10. package/dist/ui/{DocTranslationsPage-6XLREBPQ.js → DocTranslationsPage-AJGT52XQ.js} +1 -1
  11. package/dist/ui/DocumentPage-ZFD2KE3A.js +1 -0
  12. package/dist/ui/{EditDataSourcePage-E4PSKSG3.js → EditDataSourcePage-EMK3F6HD.js} +1 -1
  13. package/dist/ui/EditReleasePage-3IAERDSH.js +1 -0
  14. package/dist/ui/EmbeddedAIPage-2W5F7QFL.js +1 -0
  15. package/dist/ui/EmbeddedDocumentPage-BESFW2YZ.js +1 -0
  16. package/dist/ui/{ImageEditorDialog-YDKOGVJV.js → ImageEditorDialog-JDXMU2FC.js} +1 -1
  17. package/dist/ui/LogsPage-KCD4XZ2N.js +1 -0
  18. package/dist/ui/{NewDataSourcePage-NJJDHGPX.js → NewDataSourcePage-EZDU7HGA.js} +1 -1
  19. package/dist/ui/NewReleasePage-FFTRUIP4.js +1 -0
  20. package/dist/ui/{NotFoundPage-CA7XVXUO.js → NotFoundPage-JGG2NTUE.js} +1 -1
  21. package/dist/ui/{ProjectPage-XUBJSCWB.js → ProjectPage-HT5JKR33.js} +1 -1
  22. package/dist/ui/ReleasePage-OYWLGV4D.js +1 -0
  23. package/dist/ui/{ReleasesPage-OY7OKC3C.js → ReleasesPage-XEII7FBC.js} +1 -1
  24. package/dist/ui/{SettingsPage-5EQUY52A.js → SettingsPage-7GIBTPB5.js} +1 -1
  25. package/dist/ui/SidebarToolsPage-GQYTZDAC.js +1 -0
  26. package/dist/ui/TaskPage-SNDDYDZY.js +1 -0
  27. package/dist/ui/TasksPage-CEVWOY67.js +1 -0
  28. package/dist/ui/{TranslationsArbPage-PG5USRYB.js → TranslationsArbPage-ADRLLAIW.js} +1 -1
  29. package/dist/ui/{TranslationsEditPage-GV3ZJXTY.js → TranslationsEditPage-PSKA7K44.js} +1 -1
  30. package/dist/ui/{TranslationsPage-3AKSMCNF.js → TranslationsPage-NGCLDSK7.js} +2 -2
  31. package/dist/ui/{chunk-75NMQ3LW.js → chunk-3YBRRPAN.js} +1 -1
  32. package/dist/ui/{chunk-QLIIVG5Q.js → chunk-5F5XJPKD.js} +1 -1
  33. package/dist/ui/{chunk-ST6QNIWT.js → chunk-6ZVMJXLE.js} +7 -7
  34. package/dist/ui/chunk-7OU4ERTS.js +87 -0
  35. package/dist/ui/chunk-A2JZYRE3.js +1 -0
  36. package/dist/ui/chunk-B74M7NEV.js +1 -0
  37. package/dist/ui/{chunk-UOKVF54Y.js → chunk-BLHXP3SR.js} +1 -1
  38. package/dist/ui/{chunk-UJX25CXD.js → chunk-BOIY4J2R.js} +1 -1
  39. package/dist/ui/chunk-CEWU5VSJ.js +1 -0
  40. package/dist/ui/{chunk-34W6H4YG.js → chunk-CXMVFNX3.js} +1 -1
  41. package/dist/ui/{chunk-F7RQT4XN.js → chunk-EET5AS64.js} +1 -1
  42. package/dist/ui/{chunk-WASID5UU.js → chunk-GJ7ES2LA.js} +1 -1
  43. package/dist/ui/{chunk-2RRM4HEQ.js → chunk-H5JL376P.js} +1 -1
  44. package/dist/ui/{chunk-H37RXS4R.js → chunk-HKCOKHA2.js} +1 -1
  45. package/dist/ui/{chunk-QGAPMQEJ.js → chunk-HUYP5U4K.js} +1 -1
  46. package/dist/ui/{chunk-NCZD5IWS.js → chunk-HWON6MV4.js} +1 -1
  47. package/dist/ui/{chunk-HXSB6YB2.js → chunk-I3H465Z6.js} +1 -1
  48. package/dist/ui/{chunk-535JU7FU.js → chunk-ILFWJKSS.js} +1 -1
  49. package/dist/ui/chunk-K7IG7PO2.js +1 -0
  50. package/dist/ui/{chunk-LAXQZPE3.js → chunk-LKTN7YVM.js} +1 -1
  51. package/dist/ui/{chunk-PLYSJ7W5.js → chunk-LS2JH5QF.js} +1 -1
  52. package/dist/ui/{chunk-QFDU6FXP.js → chunk-MALK5YEV.js} +1 -1
  53. package/dist/ui/{chunk-YP6ZH3MT.js → chunk-MFRPYPCF.js} +1 -1
  54. package/dist/ui/{chunk-RB23LLKL.js → chunk-OKNBFTYR.js} +1 -1
  55. package/dist/ui/{chunk-A7IZAHBZ.js → chunk-P2RVKNG4.js} +1 -1
  56. package/dist/ui/{chunk-JBLSUM6W.js → chunk-P57AFOMR.js} +1 -1
  57. package/dist/ui/{chunk-HV3JJ5UT.js → chunk-PLTI4NG7.js} +1 -1
  58. package/dist/ui/chunk-PY4JH5SN.js +1 -0
  59. package/dist/ui/{chunk-44ZU5WMI.js → chunk-SBAY52SC.js} +1 -1
  60. package/dist/ui/{chunk-Y5EOMMNI.js → chunk-TCKR2BL4.js} +1 -1
  61. package/dist/ui/{chunk-C5FRMXDS.js → chunk-TCRDGNM4.js} +1 -1
  62. package/dist/ui/chunk-TCWN5YRW.js +1 -0
  63. package/dist/ui/{chunk-U7LSFUHT.js → chunk-TZWCCNSA.js} +1 -1
  64. package/dist/ui/{chunk-2PTLQRTU.js → chunk-U5OXKKBN.js} +1 -1
  65. package/dist/ui/{chunk-O7ESOZQO.js → chunk-VZGDXWRK.js} +1 -1
  66. package/dist/ui/{chunk-3LEYSXZP.js → chunk-X3VDQDHP.js} +1 -1
  67. package/dist/ui/chunk-XBYMUPZF.js +19 -0
  68. package/dist/ui/{chunk-QRAFYIAW.js → chunk-XYXL5HSZ.js} +1 -1
  69. package/dist/ui/chunk-Y7RYSRP7.js +7 -0
  70. package/dist/ui/{chunk-WRA24P66.js.LEGAL.txt → chunk-Y7RYSRP7.js.LEGAL.txt} +1 -0
  71. package/dist/ui/chunk-YIKHJONY.js +1 -0
  72. package/dist/ui/{chunk-UCYWQEAS.js → chunk-ZD3ORGA6.js} +1 -1
  73. package/dist/ui/{chunk-YBHFGQ3Z.js → chunk-ZQDUWURP.js} +1 -1
  74. package/dist/ui/{chunk-PIJ3E47R.js → chunk-ZYSR5UIW.js} +1 -1
  75. package/dist/ui/ui.css +1 -1
  76. package/dist/ui/ui.js +1 -1
  77. package/package.json +3 -3
  78. package/dist/ui/AIPage-EO5WH25R.js +0 -1
  79. package/dist/ui/AssetsPage-ESLB4R3I.js +0 -1
  80. package/dist/ui/CollectionPage-MXN7XKUX.js +0 -1
  81. package/dist/ui/ComparePage-TY7VJVE3.js +0 -1
  82. package/dist/ui/DocumentPage-2HNNEGRI.js +0 -1
  83. package/dist/ui/EditReleasePage-DOMXJXCU.js +0 -1
  84. package/dist/ui/EmbeddedAIPage-U5LONYH2.js +0 -1
  85. package/dist/ui/EmbeddedDocumentPage-HYV5GPK6.js +0 -1
  86. package/dist/ui/LogsPage-6KV3CQLH.js +0 -1
  87. package/dist/ui/NewReleasePage-FXHPFUVG.js +0 -1
  88. package/dist/ui/ReleasePage-NLGRYJX7.js +0 -1
  89. package/dist/ui/SidebarToolsPage-FWG6TIDI.js +0 -1
  90. package/dist/ui/TaskPage-APNRUOYG.js +0 -1
  91. package/dist/ui/TasksPage-FTEELXVZ.js +0 -1
  92. package/dist/ui/chunk-235TRWJF.js +0 -81
  93. package/dist/ui/chunk-56NMZYX6.js +0 -19
  94. package/dist/ui/chunk-6WJQBFN5.js +0 -1
  95. package/dist/ui/chunk-EYJ6GKZR.js +0 -1
  96. package/dist/ui/chunk-G5647K25.js +0 -1
  97. package/dist/ui/chunk-OWYV43BT.js +0 -1
  98. package/dist/ui/chunk-QWB6MAPJ.js +0 -7
  99. package/dist/ui/chunk-VJRMR2JM.js +0 -1
  100. package/dist/ui/chunk-WRA24P66.js +0 -7
  101. package/dist/ui/chunk-Z3ZJJWFT.js +0 -1
  102. package/dist/ui/chunk-ZAJPNVYS.js +0 -1
  103. /package/dist/ui/{ImageEditorDialog-YDKOGVJV.js.LEGAL.txt → ImageEditorDialog-JDXMU2FC.js.LEGAL.txt} +0 -0
  104. /package/dist/ui/{chunk-ST6QNIWT.js.LEGAL.txt → chunk-6ZVMJXLE.js.LEGAL.txt} +0 -0
  105. /package/dist/ui/{chunk-235TRWJF.js.LEGAL.txt → chunk-7OU4ERTS.js.LEGAL.txt} +0 -0
@@ -1,19 +0,0 @@
1
- import{a as Te,b as Se,c as Pe,d as ke,e as je,f as ze,g as De,h as Ue,i as Oe,j as We,k as Be,l as Le,m as $e,n as He,o as Fe,p as ae,q as Ke,r as Ve}from"./chunk-LAXQZPE3.js";import{a as we}from"./chunk-QWB6MAPJ.js";import{a as Ee,c as ne}from"./chunk-235TRWJF.js";import{P as Me,T as Ne}from"./chunk-AAR7DBEN.js";import{f as q}from"./chunk-5MV6XVGA.js";import{b as me,c as pe,g as fe,h as _e,j as he,n as X,o as ge,p as Ce,r as ve,v as Y}from"./chunk-XOWWPE7X.js";import{d as Ae,e as T}from"./chunk-WASID5UU.js";import{$a as Q,Bc as z,Fa as H,Ga as e,Hc as xe,V as J,Vc as be,W as E,a as _,ab as Z,ad as B,ba as G,bb as ee,c as M,da as j,e as y,g as ue,h as N,j as at,kc as te,pb as ye,pc as oe,qa as W,qc as Re}from"./chunk-WRA24P66.js";import{d as de}from"./chunk-KUCVLANF.js";import{h as Ie}from"./chunk-7SK47HHZ.js";at();var it=500;function Je(){return window.firebase.db}function Ge(){return window.__ROOT_CTX.rootConfig.projectId}function ie(){return window.firebase.user?.email||""}function st(){return me(Je(),"Projects",Ge(),"AiChats")}function se(t){return pe(Je(),"Projects",Ge(),"AiChats",t)}function D(t){return t&&typeof t.toMillis=="function"?t.toMillis():typeof t=="number"?t:0}async function Xe(t){let o=ie();if(!o)return[];let n=t?.limit,a=typeof n=="number"&&Number.isFinite(n)&&n>0?Math.min(Math.floor(n),100):50,u=fe(st(),_e("createdBy","==",o),he(it)),r=(await ge(u)).docs.map(l=>l.data());return r.sort((l,g)=>D(g.modifiedAt)-D(l.modifiedAt)),r.slice(0,a).map(l=>({id:l.id,title:l.title,modelId:l.modelId,createdAt:D(l.createdAt),modifiedAt:D(l.modifiedAt)}))}async function re(t){let o=await X(se(t));if(!o.exists())return null;let n=o.data();return n.createdBy!==ie()?null:{id:n.id||t,title:n.title,modelId:n.modelId,createdAt:D(n.createdAt),modifiedAt:D(n.modifiedAt),messages:n.messages||[]}}async function Ye(t,o){let n=ie(),a=se(t),u=await X(a);if(u.exists()&&u.data().createdBy!==n)throw new Error("chat is owned by another user");let m={id:t,createdBy:n,modifiedAt:Y(),messages:We(o.messages)};u.exists()||(m.createdAt=Y()),o.modelId&&(m.modelId=o.modelId),o.title&&(m.title=o.title),await Ce(a,m,{merge:!0})}async function qe(t){await re(t)&&await ve(se(t))}async function Qe(t,o){let n=je(o);if(n==="New chat")return n;let a=ze(o);if(!a)return n;try{let u=ke(Pe(t)),m=await Me({model:u,system:Ue,prompt:Oe(a),maxOutputTokens:64,temperature:.3}),r=De(m.text);if(r)return r}catch(u){console.error("failed to generate chat title:",u)}return n}var le=[{id:"read",label:"Read only",description:"Inspect CMS content without planning or applying writes."},{id:"approve",label:"Ask before writing",description:"Read freely, then pause for approval before draft edits."},{id:"auto",label:"Auto-apply draft edits",description:"Apply draft-only writes without approval in this chat."}],ot="root-cms.ai.executionMode",nt="root-cms.ai.selectedModel";function rt(t){return le.some(o=>o.id===t)}function lt(){if(typeof window>"u")return"approve";try{let t=window.localStorage.getItem(ot);if(rt(t))return t}catch(t){console.error("failed to read AI execution mode preference",t)}return"approve"}function ct(t){if(typeof window>"u")return null;try{let o=window.localStorage.getItem(nt);if(o&&t.some(n=>n.id===o))return o}catch(o){console.error("failed to read AI model preference",o)}return null}function dt(t){if(!(typeof window>"u"))try{window.localStorage.setItem(nt,t)}catch(o){console.error("failed to save AI model preference",o)}}function ut(t){if(!(typeof window>"u"))try{window.localStorage.setItem(ot,t)}catch(o){console.error("failed to save AI execution mode preference",o)}}var F="";function so(t){let[o,n]=_(null),[a,u]=_("");M(()=>{let r=!0;return fetch("/cms/api/ai.config",{credentials:"include"}).then(async l=>{let g=await l.json();r&&n(g)}).catch(l=>{r&&u(String(l))}),()=>{r=!1}},[]);let m=!!o?.enabled&&(o.models?.length||0)>0;return e("div",{className:T("RootAIChat",`RootAIChat--${t.variant}`),children:!o&&!a?e("div",{className:"RootAIChat__loading",children:e(J,{size:"md",color:"gray"})}):m?e(pt,{variant:t.variant,config:o,initialChatId:t.variant==="panel"?void 0:t.initialChatId,docContext:t.docContext,onClose:t.onClose}):e(mt,{error:a,onClose:t.onClose})})}function mt(t){return e("div",{className:"RootAIChat__notEnabled",children:[t.onClose&&e(E,{className:"RootAIChat__notEnabled__close",onClick:t.onClose,title:"Close",children:e(B,{size:16})}),e("div",{className:"RootAIChat__notEnabled__icon",children:e(z,{size:36})}),e("div",{className:"RootAIChat__notEnabled__title",children:"Root AI is not configured for this project."}),e("div",{className:"RootAIChat__notEnabled__body",children:["Add an ",e("code",{children:"ai.models"})," entry to ",e("code",{children:"cmsPlugin()"})," in"," ",e("code",{children:"root.config.ts"}),"."]}),t.error&&e("pre",{className:"RootAIChat__notEnabled__error",children:t.error})]})}function pt(t){let o=t.variant==="panel",{route:n}=Ae(),a=t.config.models||[],u=()=>ct(a)||t.config.defaultModel||a[0]?.id||"",[m,r]=_(u),[l,g]=_(lt),[h,R]=_(t.initialChatId||F),[x,v]=_(t.initialChatId||F),[P,c]=_([]),[C,A]=_(""),[I,S]=_([]),[K,L]=_(0),k=async()=>{if(!o)try{let i=await Xe();S(i)}catch(i){console.error("failed to load chat list",i)}};M(()=>{k(),!o&&t.initialChatId&&V(t.initialChatId)},[]),M(()=>{ut(l)},[l]);let U=async i=>{try{let f=await re(i);return f?(R(i),v(i),c(f.messages||[]),A(f.title||""),f.modelId&&a.find(b=>b.id===f.modelId)&&r(f.modelId),L(w=>w+1),!0):!1}catch(f){return console.error("failed to load chat",f),!1}},V=i=>U(i),O=()=>{r(u()),R(F),v(F),c([]),A(""),L(i=>i+1),o||n("/cms/ai")},$=async i=>{if(i===x)return;await U(i)&&!o&&n(`/cms/ai/chat/${i}`)},s=async i=>{try{await qe(i),x===i&&O(),k()}catch(f){console.error("failed to delete chat",f)}},p=a.find(i=>i.id===m)||a[0],d=i=>{r(i),dt(i)};return e("div",{className:"RootAIChat__layout",children:[!o&&e(_t,{chats:I,activeChatId:x,onSelect:$,onNew:O,onDelete:s}),e("div",{className:"RootAIChat__main",children:[o&&e(ft,{onNewChat:O,onClose:t.onClose}),e(gt,{initialChatId:h,initialTitle:C,model:p,initialMessages:P,executionMode:l,canAutoApply:t.config.canAutoApply??!1,models:a,selectedModel:p,docContext:t.docContext,onSelectModel:d,onSelectExecutionMode:g,onChatPersisted:i=>{v(i),k(),o||window.history.replaceState(null,"",`/cms/ai/chat/${i}`)}},K)]})]})}function ft(t){return e("div",{className:"RootAIChat__panelHeader",children:[e("div",{className:"RootAIChat__panelHeader__title",children:[e(z,{size:14}),e("span",{children:"Root AI"})]}),e("div",{className:"RootAIChat__panelHeader__actions",children:[e(H,{label:"New chat",children:e(E,{size:"xs",onClick:t.onNewChat,children:e(te,{size:14})})}),t.onClose&&e(H,{label:"Close (\u2318 + i)",children:e(E,{size:"xs",onClick:t.onClose,children:e(B,{size:14})})})]})]})}function _t(t){return e("aside",{className:"RootAIChat__sidebar",children:[e("button",{type:"button",className:"RootAIChat__sidebar__newButton",onClick:t.onNew,children:[e(te,{size:18}),e("span",{children:"New chat"})]}),e("div",{className:"RootAIChat__sidebar__list",children:[t.chats.length===0&&e("div",{className:"RootAIChat__sidebar__empty",children:"No chats yet."}),t.chats.map(o=>e("div",{className:T("RootAIChat__sidebar__item",o.id===t.activeChatId&&"RootAIChat__sidebar__item--active"),onClick:()=>t.onSelect(o.id),children:[e("div",{className:"RootAIChat__sidebar__item__title",title:o.title||"Untitled chat",children:o.title||"Untitled chat"}),e("button",{type:"button",className:"RootAIChat__sidebar__item__delete",title:"Delete chat",onClick:n=>{n.stopPropagation(),window.confirm("Delete this chat?")&&t.onDelete(o.id)},children:e(be,{size:14})})]},o.id))]})]})}function ht(t){let o=t.canAutoApply?le:le.filter(a=>a.id!=="auto"),n=o.find(a=>a.id===t.executionMode)||o[0];return e("div",{className:"RootAIChat__options",children:[e(W,{control:e(j,{type:"button",className:"RootAIChat__modePicker",variant:"subtle",color:"dark",size:"xs",compact:!0,leftIcon:e(Re,{size:16}),children:n.label}),children:o.map(a=>e(W.Item,{onClick:()=>t.onSelectExecutionMode(a.id),children:e("div",{className:"RootAIChat__modePicker__option",children:[e("div",{className:"RootAIChat__modePicker__option__label",children:a.label}),e("div",{className:"RootAIChat__modePicker__option__description",children:a.description})]})},a.id))}),e(W,{control:e(j,{type:"button",className:"RootAIChat__modelPicker",variant:"subtle",color:"dark",size:"xs",compact:!0,leftIcon:e(z,{size:16}),children:t.selectedModel?.label||"Select model"}),children:t.models.map(a=>e(W.Item,{onClick:()=>t.onSelectModel(a.id),children:e("div",{className:"RootAIChat__modelPicker__option",children:[e("div",{className:"RootAIChat__modelPicker__option__label",children:a.label}),a.description&&e("div",{className:"RootAIChat__modelPicker__option__description",children:a.description})]})},a.id))})]})}function gt(t){let[o]=_(()=>t.initialChatId||kt()),n=y(t.model?.id);n.current=t.model?.id;let a=y(t.executionMode);a.current=t.executionMode;let u=y(t.docContext);u.current=t.docContext;let m=y(t.onChatPersisted);m.current=t.onChatPersisted;let r=y(null),l=y(t.executionMode),g=y(t.initialTitle),h=y(null),[R,x]=_({}),v=y({});M(()=>()=>{for(let s of Object.values(v.current))s("reject");v.current={}},[]);let P=N((s,p,d,i)=>new Promise(f=>{v.current[s]=f,x(w=>({...w,[s]:{toolCallId:s,toolName:p,input:d,preview:i,status:"pending"}}))}),[]),c=N(s=>{x(p=>{let d=p[s];return d?{...p,[s]:{...d,status:"executing"}}:p}),v.current[s]?.("approve"),delete v.current[s]},[]),C=N(s=>{x(p=>{let d={...p};return delete d[s],d}),v.current[s]?.("reject"),delete v.current[s]},[]),A=N(async s=>{if(!He(s.toolName))return await ae(s.toolName,s.input);let p=l.current;if(p==="read")return{success:!1,error:"WRITE_BLOCKED_BY_MODE",message:"The current execution mode is read only. Do not call write tools."};let d;try{d=await Fe(s.toolName,s.input)}catch(i){return{success:!1,error:"PREVIEW_FAILED",message:i?.message||String(i)}}if(d.error)return{success:!1,error:d.error,message:d.summary,errors:d.errors,hint:d.hint};if(p==="approve"&&await P(s.toolCallId,s.toolName,s.input,d)==="reject")return{success:!1,error:"USER_REJECTED",message:"The user rejected this draft change. Do not retry unless they ask for a revised version."};try{return await ae(s.toolName,s.input)}finally{x(i=>{if(!i[s.toolCallId])return i;let f={...i};return delete f[s.toolCallId],f})}},[P]),I=N(async s=>{let p=r.current;try{let d=g.current;if(!d&&p){let i=await Qe(p,s);i&&i!=="New chat"&&(d=i,g.current=i)}await Ye(o,{messages:s,modelId:p?.id||n.current,title:d||void 0})}catch(d){console.error("failed to persist chat history",d)}m.current(o)},[o]),S=ue(()=>Be({loadTurnConfig:async()=>{let s=n.current,p=a.current,d=u.current?.docId,i=`${s}|${p}|${d||""}`,f=h.current;if(f&&f.key===i)return f.config;let w=await fetch("/cms/api/ai.chat.prepare",{method:"POST",credentials:"include",headers:{"content-type":"application/json"},body:JSON.stringify({modelId:s,executionMode:p,docId:d})}),b=await w.json();if(!w.ok||!b.success)throw new Error(b.error||`ai.chat.prepare failed: ${w.status}`);let ce={model:b.model,system:b.system,maxSteps:b.maxSteps};return r.current=b.model,l.current=b.executionMode||p,h.current={key:i,config:ce},ce},buildTools:s=>s.capabilities.tools?l.current==="read"?$e():Le():{},onFinish:I}),[I]),{messages:K,sendMessage:L,status:k,error:U,stop:V,addToolOutput:O}=Te({id:o,messages:t.initialMessages,transport:S,sendAutomaticallyWhen:Ne,onToolCall:async({toolCall:s})=>{let p=await A(s);O({tool:s.toolName,toolCallId:s.toolCallId,output:p})}}),$=k==="streaming"||k==="submitted";return e(de,{children:[e(Ct,{messages:K,isStreaming:$,emptyMessage:t.model?void 0:"Select a model to start.",toolApprovals:{approvals:R,onApprove:c,onReject:C}}),U&&e("div",{className:"RootAIChat__error",children:[e("strong",{children:"Error:"})," ",U.message]}),e(Mt,{disabled:!t.model,canAttach:t.model?.capabilities.attachments??!1,isStreaming:$,onStop:V,controls:e(ht,{models:t.models,selectedModel:t.selectedModel,onSelectModel:t.onSelectModel,executionMode:t.executionMode,canAutoApply:t.canAutoApply,onSelectExecutionMode:t.onSelectExecutionMode}),onSend:(s,p)=>{if(!s&&p.length===0)return;let d=Nt(p),i=[s,d.text].filter(Boolean).join(`
2
-
3
- `);L({text:i,files:d.files.map(f=>({type:"file",mediaType:f.mediaType,url:f.url,filename:f.filename}))})}})]})}function Ct(t){let o=y(null);return M(()=>{let n=o.current;n&&(n.scrollTop=n.scrollHeight)},[t.messages]),t.messages.length===0?e("div",{className:"RootAIChat__transcript RootAIChat__transcript--empty",ref:o,children:e("div",{className:"RootAIChat__welcome",children:[e("div",{className:"RootAIChat__welcome__icon",children:e(z,{size:36})}),e("div",{className:"RootAIChat__welcome__title",children:"Root AI"}),e("div",{className:"RootAIChat__welcome__body",children:t.emptyMessage||"What are we going to get done today?"})]})}):e("div",{className:"RootAIChat__transcript",ref:o,children:e("div",{className:"RootAIChat__transcript__inner",children:[t.messages.map(n=>e(vt,{message:n,toolApprovals:t.toolApprovals},n.id)),t.isStreaming&&e("div",{className:"RootAIChat__streamingIndicator",children:e(Se,{size:6})})]})})}function vt(t){let o=t.message,n=o.role==="user",a=n?"You":"Root AI",u=n?window.firebase.user?.photoURL:null,[m,r]=_(!1),l=N(()=>(o.parts||[]).filter(h=>h.type==="text"&&h.text).map(h=>h.text).join(`
4
-
5
- `),[o.parts]),g=N(async()=>{let h=l();if(!h)return;let R=Ee.parse(h);try{await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([R],{type:"text/html"}),"text/plain":new Blob([h],{type:"text/plain"})})]),r(!0),setTimeout(()=>r(!1),2e3)}catch{await navigator.clipboard.writeText(h),r(!0),setTimeout(()=>r(!1),2e3)}},[l]);return e("div",{className:T("RootAIChat__message",`RootAIChat__message--${o.role}`),children:[e("div",{className:"RootAIChat__message__avatar",children:u?e("img",{src:u,alt:a}):e(z,{size:20})}),e("div",{className:"RootAIChat__message__body",children:[e("div",{className:"RootAIChat__message__username",children:a}),e("div",{className:"RootAIChat__message__parts",children:(o.parts||[]).map((h,R)=>e(At,{part:h,toolApprovals:t.toolApprovals},R))}),e("button",{type:"button",className:T("RootAIChat__message__copy",m&&"RootAIChat__message__copy--copied"),title:m?"Copied!":"Copy message",onClick:g,children:m?e(Q,{size:14}):e(ye,{size:14})})]})]})}function At(t){let o=t.part;return o.type==="text"?o.text?e("div",{className:"RootAIChat__textPart",children:e(ne,{code:o.text})}):null:o.type==="reasoning"?e(It,{text:o.text}):o.type==="file"?e(yt,{part:o}):o.type==="source-url"?e("a",{className:"RootAIChat__sourcePart",href:o.url,target:"_blank",rel:"noopener noreferrer",children:o.title||o.url}):typeof o.type=="string"&&o.type.startsWith("tool-")?e(Ze,{part:o,toolApprovals:t.toolApprovals}):o.type==="dynamic-tool"?e(Ze,{part:o,toolApprovals:t.toolApprovals}):o.type==="step-start"?null:e("div",{className:"RootAIChat__unknownPart",children:e("pre",{children:JSON.stringify(o,null,2)})})}function It(t){let[o,n]=_(!1);return t.text?e("div",{className:T("RootAIChat__reasoning",o&&"RootAIChat__reasoning--open"),children:[e("button",{type:"button",className:"RootAIChat__reasoning__toggle",onClick:()=>n(!o),children:[e(Z,{size:14,style:{transform:o?"rotate(0deg)":"rotate(-90deg)"}}),e("span",{children:"Thinking"})]}),o&&e("div",{className:"RootAIChat__reasoning__body",children:e(ne,{code:t.text})})]}):null}function yt(t){let o=t.part;return o.mediaType?.startsWith("image/")?e("div",{className:"RootAIChat__filePart",children:e("img",{src:o.url,alt:o.filename||"attachment"})}):e("a",{className:"RootAIChat__filePart RootAIChat__filePart--link",href:o.url,target:"_blank",rel:"noopener noreferrer",children:[e(oe,{size:14}),e("span",{children:o.filename||o.url})]})}function Ze(t){let o=t.part,n=typeof o.type=="string"&&o.type.startsWith("tool-")?o.type.slice(5):o.toolName||"tool",a=o.state||"",u=Rt(o),m=t.toolApprovals,r=u?m?.approvals[u]:void 0,[l,g]=_(!!r);return M(()=>{r&&g(!0)},[r]),e("div",{className:"RootAIChat__tool",children:[e("button",{type:"button",className:"RootAIChat__tool__header",onClick:()=>g(!l),children:[e(Z,{className:T("RootAIChat__tool__header__icon",l&&"RootAIChat__tool__header__icon--open"),size:14}),e(G,{color:"dark",variant:"filled",size:"xs",children:n}),e("span",{className:"RootAIChat__tool__title",children:Ke(n,o.input)}),e("span",{className:"RootAIChat__tool__state",children:r?wt(r.status):Ve(a)})]}),l&&e("div",{className:"RootAIChat__tool__body",children:[r&&m&&e(xt,{approval:r,onApprove:()=>m.onApprove(r.toolCallId),onReject:()=>m.onReject(r.toolCallId)}),o.output?.receipt&&e(bt,{output:o.output}),o.input&&e("details",{children:[e("summary",{children:[e(ee,{size:14,className:"RootAIChat__tool__json__icon"}),e("span",{children:"Input"})]}),e("pre",{children:JSON.stringify(o.input,null,2)})]}),o.output&&e("details",{children:[e("summary",{children:[e(ee,{size:14,className:"RootAIChat__tool__json__icon"}),e("span",{children:"Output"})]}),e("pre",{children:JSON.stringify(o.output,null,2)})]}),o.errorText&&e("div",{className:"RootAIChat__tool__error",children:o.errorText})]})]})}function Rt(t){return t.toolCallId||t.id||""}function xt(t){let o=t.approval.preview,n=o.before!==void 0&&o.after!==void 0;return e("div",{className:"RootAIChat__approval",children:[e("div",{className:"RootAIChat__approval__header",children:[e("div",{children:[e("div",{className:"RootAIChat__approval__title",children:o.title}),e("div",{className:"RootAIChat__approval__summary",children:o.summary})]}),e(G,{className:"RootAIChat__approval__status",variant:"light",color:"gray",children:t.approval.status==="executing"?"Applying":"Review"})]}),o.details.length>0&&e("div",{className:"RootAIChat__approval__details",children:o.details.map(a=>e("div",{children:[e("span",{children:a.label}),e("strong",{children:a.value})]},`${a.label}:${a.value}`))}),n&&e(we,{className:"RootAIChat__approval__diff",oldCode:q(o.before),newCode:q(o.after)}),e("div",{className:"RootAIChat__approval__actions",children:[e(j,{variant:"default",color:"dark",size:"xs",type:"button",className:"RootAIChat__approval__button",disabled:t.approval.status==="executing",onClick:t.onReject,children:"Reject"}),e(j,{variant:"filled",color:"green",size:"xs",type:"button",className:"RootAIChat__approval__button RootAIChat__approval__button--primary",disabled:t.approval.status==="executing",onClick:t.onApprove,children:"Approve draft edit"})]})]})}function bt(t){let o=t.output.receipt;return e("div",{className:"RootAIChat__receipt",children:[e("div",{className:"RootAIChat__receipt__title",children:[e(Q,{size:14}),e("span",{children:o.title})]}),e("div",{className:"RootAIChat__receipt__summary",children:o.summary}),o.details?.length>0&&e("div",{className:"RootAIChat__receipt__details",children:o.details.map(n=>e("div",{children:[e("span",{children:n.label}),e("strong",{children:n.value})]},`${n.label}:${n.value}`))}),o.adminUrl&&e(j,{component:"a",className:"RootAIChat__receipt__link",variant:"default",size:"xs",compact:!0,href:o.adminUrl,children:"Open document"})]})}function wt(t){return t==="executing"?"applying\u2026":"waiting for approval"}function Mt(t){let[o,n]=_(""),[a,u]=_([]),[m,r]=_(!1),l=y(null),g=y(null);M(()=>{window.requestAnimationFrame(()=>{let c=g.current;c&&(c.style.height="auto",c.style.height=`${Math.min(c.scrollHeight,240)}px`)})},[o,a]);let R=()=>{t.disabled||t.isStreaming||!o&&a.length===0||(t.onSend(o,a),n(""),u([]),l.current&&(l.current.value=""))},x=c=>{c.key==="Enter"&&!c.shiftKey&&(c.preventDefault(),R())},v=async c=>{r(!0);try{let C=c.type||Pt(c.name),A=await St(c,C),I=await Ie(c,{disableGci:!0});u(S=>[...S,{url:I.src,filename:I.filename||c.name,mediaType:C,textContent:A?.text,textTruncated:A?.truncated,width:I.width,height:I.height}])}catch(C){console.error("upload failed",C)}finally{r(!1),l.current&&(l.current.value="")}},P=c=>{let C=c.target;Array.from(C.files||[]).forEach(v)};return e("div",{className:"RootAIChat__composer",children:[a.length>0&&e("div",{className:"RootAIChat__composer__attachments",children:a.map((c,C)=>e("div",{className:"RootAIChat__composer__attachment",children:[c.mediaType.startsWith("image/")?e("img",{src:c.url,alt:c.filename}):e("span",{className:"RootAIChat__composer__attachment__name",children:c.filename}),e("button",{type:"button",className:"RootAIChat__composer__attachment__remove",onClick:()=>u(A=>A.filter((I,S)=>S!==C)),children:e(B,{size:12})})]},C))}),e("div",{className:"RootAIChat__composer__row",children:[e(H,{label:t.canAttach?"Attach file":"Model doesn't support attachments",className:"RootAIChat__composer__attachTooltip",children:e(E,{component:"label",radius:"xl",className:T("RootAIChat__composer__attach",!t.canAttach&&"RootAIChat__composer__attach--disabled"),disabled:!t.canAttach,children:[m?e(J,{size:"xs"}):e(oe,{size:18}),e("input",{ref:l,type:"file",style:{display:"none"},onChange:P})]})}),e("textarea",{ref:g,className:"RootAIChat__composer__textarea",placeholder:t.disabled?"Select a model\u2026":"Ask anything\u2026",value:o,rows:1,autofocus:!0,disabled:t.disabled,onKeyDown:x,onChange:c=>n(c.target.value),onPaste:c=>{let C=c.clipboardData?.items||[];for(let A of C)if(A.kind==="file"){let I=A.getAsFile();I&&t.canAttach&&v(I)}}}),t.isStreaming?e(E,{className:"RootAIChat__composer__button RootAIChat__composer__stopButton",radius:"xl",color:"dark",variant:"filled",onClick:t.onStop,title:"Stop",children:e(B,{size:18})}):e(E,{className:"RootAIChat__composer__button RootAIChat__composer__submitButton",radius:"xl",color:"dark",variant:"filled",disabled:t.disabled||m||!o&&a.length===0,onClick:R,title:"Send",children:e(xe,{size:18})})]}),t.controls]})}var et=1e5;function Nt(t){let o=t.filter(tt),n=t.filter(a=>!tt(a)).map(Tt);return{files:o,text:n.length?`Attached files:
6
-
7
- ${n.join(`
8
-
9
- `)}`:""}}function tt(t){return t.mediaType.startsWith("image/")}function Tt(t){let o=`File: ${t.filename} (${t.mediaType})`;if(t.textContent!==void 0){let n=t.textTruncated?`
10
-
11
- [Content truncated before sending to the model.]`:"";return`${o}
12
- URL: ${t.url}
13
-
14
- ~~~
15
- ${t.textContent}${n}
16
- ~~~`}return`${o}
17
- URL: ${t.url}
18
-
19
- [The file was uploaded, but its binary content was not inlined into this chat message.]`}async function St(t,o){if(!Et(t.name,o))return null;let n=await t.text();return n.length<=et?{text:n,truncated:!1}:{text:n.slice(0,et),truncated:!0}}function Et(t,o){return o.startsWith("text/")?!0:[".css",".js",".jsx",".json",".md",".mdx",".mjs",".scss",".ts",".tsx",".txt",".yaml",".yml"].some(n=>t.toLowerCase().endsWith(n))}function Pt(t){let o=t.toLowerCase();return o.endsWith(".png")?"image/png":o.endsWith(".webp")?"image/webp":o.endsWith(".jpg")||o.endsWith(".jpeg")?"image/jpeg":o.endsWith(".gif")?"image/gif":o.endsWith(".svg")?"image/svg+xml":o.endsWith(".pdf")?"application/pdf":o.endsWith(".json")?"application/json":o.endsWith(".csv")?"text/csv":o.endsWith(".md")?"text/markdown":o.endsWith(".txt")?"text/plain":"application/octet-stream"}function kt(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`chat-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}export{so as a};
@@ -1 +0,0 @@
1
- import{a as z}from"./chunk-QWB6MAPJ.js";import{c as C}from"./chunk-235TRWJF.js";import{f as h}from"./chunk-5MV6XVGA.js";import{a as x}from"./chunk-NCZD5IWS.js";import{a as P}from"./chunk-AAHM6RYJ.js";import{U as b,Y as A,Z as I}from"./chunk-ISUGBMXC.js";import{e as D}from"./chunk-WASID5UU.js";import{Ga as e,Kc as N,U as y,V as u,a as t,bd as k,c as v,da as S,e as w,j as V}from"./chunk-WRA24P66.js";import{d as g}from"./chunk-KUCVLANF.js";V();V();function R(o){let r=o.docId,[i,d]=t("idle"),[c,f]=t(""),[s,l]=t(""),m=w(!1);async function p(){d("loading");try{let n=await I(r,{beforeVersion:o.beforeVersion,afterVersion:o.afterVersion});f(n),d("success")}catch(n){console.error(n),l(n instanceof Error?n.message:"Unknown error"),d("error")}}function _(){m.current||(m.current=!0,p())}let a;return i==="idle"||i==="loading"?a=e("div",{className:"AiSummary__loading",children:e(u,{size:"md",color:"gray"})}):i==="error"?a=e(x,{className:"AiSummary__content",size:"body-sm",color:"gray",children:["Failed to load AI summary.",s&&e(g,{children:[e("br",{}),s]})]}):c?a=e(C,{className:"AiSummary__content",code:c}):a=e(x,{className:"AiSummary__content",size:"body-sm",color:"gray",children:"No AI summary available for this draft yet."}),e("div",{className:D(o.className,"AiSummary"),children:e(y,{iconPosition:"right",onChange:()=>_(),disableIconRotation:!0,children:e(y.Item,{label:"Summarize changes",icon:e(N,{stroke:"1.5"}),iconPosition:"left",children:a})})})}function me(o){let r=o.left,i=o.right,[d,c]=t(!1),[f,s]=t(null),[l,m]=t(null),p=P()&&r.docId===i.docId&&o.showAiSummary!==!1,_=h(E(f?.fields||{})),a=h(E(l?.fields||{})),n=!d&&f&&l&&_===a,M=`/cms/compare?left=${F(r)}&right=${F(i)}`;async function $(){c(!0);let[j,T]=await Promise.all([b(r.docId,r.versionId),b(i.docId,i.versionId)]);s(j),m(T),c(!1)}return v(()=>{$()},[]),d?e("div",{className:"DocDiffViewer DocDiffViewer--loading",children:e(u,{size:"md",color:"gray"})}):e(g,{children:[p&&e(R,{className:"DocDiffViewer__aiSummary",docId:r.docId,beforeVersion:String(r.versionId),afterVersion:String(i.versionId)}),e("div",{className:D(o.className,"DocDiffViewer"),children:[o.showExpandButton&&e("div",{className:"DocDiffViewer__expand",children:e(S,{component:"a",variant:"default",size:"xs",compact:!0,href:M,target:"_blank",children:"Open in new tab"})}),e("div",{className:"DocDiffViewer__header",children:[e("div",{className:"DocDiffViewer__header__label",children:[e("div",{className:"DocDiffViewer__header__label__title",children:[o.left.docId,"@",o.left.versionId]}),e("div",{className:"DocDiffViewer__header__label__meta",children:B(f)})]}),e("div",{className:"DocDiffViewer__header__label",children:[e("div",{className:"DocDiffViewer__header__label__title",children:[o.right.docId,"@",o.right.versionId]}),e("div",{className:"DocDiffViewer__header__label__meta",children:B(l)})]})]}),e("div",{className:"DocDiffViewer__diff",children:n?e("div",{className:"DocDiffViewer__identical",children:[e(k,{size:20}),e("span",{children:"No changes. Both versions are identical."})]}):e(z,{oldCode:_,newCode:a})})]})]})}function B(o){if(!o?.sys?.modifiedAt)return"never";let r=o.sys.modifiedAt.toDate();return`${new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(r)} by ${o.sys.modifiedBy}`}function E(o){return A(o,{removeArrayKey:!0})}function F(o){return encodeURIComponent(`${o.docId}@${o.versionId}`).replaceAll("%2F","/").replaceAll("%40","@")}export{R as a,me as b};
@@ -1 +0,0 @@
1
- import{b as le}from"./chunk-HV3JJ5UT.js";import{a as oe}from"./chunk-VJRMR2JM.js";import{a as ee,b as A,c as T}from"./chunk-JDW4UORS.js";import{a as ie}from"./chunk-YDO2EDVY.js";import{a as M}from"./chunk-5MV6XVGA.js";import{b as te}from"./chunk-2PTLQRTU.js";import{a as U}from"./chunk-PIJ3E47R.js";import{a as j}from"./chunk-NCZD5IWS.js";import{P as re,c as ne}from"./chunk-ISUGBMXC.js";import{b as K,f as R,g as C,i as v,o as Y}from"./chunk-XOWWPE7X.js";import{d as Z,e as se}from"./chunk-WASID5UU.js";import{A as G,Ga as g,a as S,c as y,da as $,e as _,g as B,h as I,i as W,j as O,ra as Q,ua as q,za as J}from"./chunk-WRA24P66.js";import{j as X,k as Se}from"./chunk-KUCVLANF.js";function F(e){let t=window.__ROOT_CTX.collections[e.collectionId];if(!t)throw new Error(`collection not found: ${e.collectionId}`);if(!t.url)return"";let n=t.domain||window.__ROOT_CTX.rootConfig.domain||"https://example.com",r=Ee(e);return`${n}${r}`}function Ee(e){let o=window.__ROOT_CTX.collections,{collectionId:t,slug:n,locale:r}=e,i=o[t];if(!i)throw new Error(`collection not found: ${t}`);if(!i.url)return"";let l=window.__ROOT_CTX.rootConfig,m=l.base||"/",u="/[base]/[path]";r&&(u=l.i18n.urlFormat||"/[locale]/[base]/[path]");let f="",a=i?.url;if(a)if(n){let c=a.replace(/\[.*slug\]/,n).replaceAll("--","/").replace(/\/+/g,"/");c==="/index"&&(c="/"),f=c}else f=a;return ce(u,{base:m,path:f,locale:r||"",slug:n})}function be(e){let o=window.__ROOT_CTX.collections,{collectionId:t,slug:n,locale:r}=e,i=o[t];if(!i)throw new Error(`collection not found: ${t}`);let l=window.__ROOT_CTX.rootConfig,m=l.base||"/",u="/[base]/[path]";r&&(u=l.i18n.urlFormat||"/[locale]/[base]/[path]");let f="",a=i?.previewUrl||i?.url;if(a)if(n){let c=a.replace(/\[.*slug\]/,n).replaceAll("--","/").replace(/\/+/g,"/");c==="/index"&&(c="/"),f=c}else f=a;return ce(u,{base:m,path:f,locale:r||"",slug:n})}function ce(e,o){let t=e.replaceAll(/\[\[?(\.\.\.)?([\w\-_]*)\]?\]/g,(n,r,i)=>o[i]??n);return Ce(t,{trailingSlash:window.__ROOT_CTX.rootConfig.server.trailingSlash})}function Ce(e,o){return e=e.replace(/\/+/g,"/"),o?.trailingSlash===!1&&e!=="/"&&e.endsWith("/")&&(e=e.replace(/\/*$/g,"")),(e.endsWith("/index")||e.endsWith("/index/"))&&(e=e.slice(0,-6)),e.startsWith("/")||(e=`/${e}`),o?.trailingSlash&&!e.endsWith("/")&&(e=`${e}/`),e}O();function Ae(e,o){let[t,n]=S([]),[r,i]=S(!0),m=le().db,u=window.__ROOT_CTX.rootConfig.projectId||"default",f=o.includeArchived??!1,a=async()=>{i(!0);let c=K(m,"Projects",u,"Collections",e,"Drafts"),s=c,d=o.orderBy;if(d==="modifiedAt")s=C(c,v("sys.modifiedAt","desc"));else if(d==="modifiedAtAsc")s=C(c,v("sys.modifiedAt"));else if(d==="newest")s=C(c,v("sys.createdAt","desc"));else if(d==="oldest")s=C(c,v("sys.createdAt"));else if(d==="slug")s=C(c,v(R()));else if(d==="slugDesc")s=C(c,v(R(),"desc"));else if(d==="title"||d==="titleDesc"){let p=d==="titleDesc"?"desc":"asc",h=ve(e);s=h?C(c,v(h,p)):C(c,v(R(),p))}else{let h=window.__ROOT_CTX.collections[e]?.sortOptions?.find(w=>w.id===d);h&&(s=h.direction==="desc"?C(c,v(h.field,"desc")):C(c,v(h.field)))}await te(async()=>{let p=await Y(s),h=[];p.docs.forEach(w=>{let P=w.data(),E=w.id,b=`${e}/${E}`,x={...P,id:b,slug:E};ne(b,x),!(!f&&x?.sys?.archivedAt)&&h.push(x)}),n(h)}),i(!1)};return y(()=>{i(!0),a()},[e,o.orderBy,f]),[r,a,t]}function ve(e){let t=window.__ROOT_CTX.collections[e]?.preview?.title??"meta.title";return Array.isArray(t)&&(t=t[0]),typeof t!="string"||!t||t.includes("{")?"":`fields.${t}`}Se();O();var D={CONNECTED:"connected",SCHEMA_CHANGED:"schemaChanged"};function ae(e){let t=new URLSearchParams(window.location.search).get("e");return t?t.split(",").includes(e):!1}var we="/cms/api/sse.connect",L=ae("EnableVerboseLogging"),ue=window.location.hostname==="localhost",z=class{constructor(){this.map=new Map}on(o,t){return this.map.has(o)||this.map.set(o,new Set),this.map.get(o).add(t),()=>{this.map.get(o)?.delete(t)}}emit(o,t,n){this.map.get(o)?.forEach(r=>r(t,n)),this.map.get("*")?.forEach(r=>r({type:o,data:t},n))}},fe=X(null);function He(e){let t=_(new z).current,n=_(null),r=_(!1),i=_({attempt:0,timer:0}),l=_(""),m=()=>{n.current&&(n.current.close(),n.current=null)},u=I(()=>{L&&console.log("[sse] connecting..."),m();let a=new EventSource(we);n.current=a,a.addEventListener(D.CONNECTED,s=>{if(L&&console.log("[sse] connected"),r.current=!1,i.current.attempt=0,ue){let p=de(s.data)?.serverVersion||"";l.current?l.current!==p&&(console.log(`server version changed: ${l.current} -> ${p}`),console.log("reloading..."),window.location.reload()):l.current=p}});let c=s=>{if(!s||!s.type)return;let d=de(s.data);L&&console.log("[sse] event:",s.type,d),t.emit(s.type,d,s)};Object.values(D).forEach(s=>{a.addEventListener(s,c)}),a.addEventListener("error",()=>{L&&console.log("[sse] disconnected"),a.readyState===EventSource.CLOSED&&!r.current&&(r.current=!0,(()=>{let d=++i.current.attempt,p=Math.min(3e4,Math.pow(2,d)*500),h=Math.random()*.3*p,w=p+h;window.clearTimeout(i.current.timer),i.current.timer=window.setTimeout(()=>{r.current=!1,u()},w)})())})},[t]);y(()=>{if(!ue)return;u();let a=()=>{document.visibilityState==="visible"&&n.current?.readyState!==EventSource.OPEN&&u()};return document.addEventListener("visibilitychange",a),()=>{document.removeEventListener("visibilitychange",a),window.clearTimeout(i.current.timer),m()}},[u]);let f=B(()=>({emitter:t}),[t]);return g(fe.Provider,{value:f,children:e.children})}function de(e){try{return JSON.parse(e)}catch{return e}}function ge(e,o){let t=W(fe);if(!t)throw new Error("useSSE() must be used within an <SSEProvider>");let n=_(o);y(()=>{n.current=o},[o]),y(()=>t.emitter.on(e,(r,i)=>n.current(r,i)),[t,e])}O();O();function me(e){let[o,t]=S(!0),[n,r]=S(null),i=I(async()=>{try{let l=await ie(e);r(l)}catch(l){console.error(l),U({title:`Failed to load collection: ${e}`,message:String(l),color:"red",autoClose:!1})}t(!1)},[e]);return y(()=>{i()},[e]),ge(D.SCHEMA_CHANGED,async l=>{await i();let m=l.file?`Applied updates from changes to ${l.file}.`:"Applied updates from changes to a .schema.ts file.";U({title:"Updated schema!",message:m})}),{loading:o,schema:n}}function H(e){let o={_array:[]};return e.forEach(t=>{let n=_e();o._array.push(n),o[n]=t}),o}function _e(){let e=[],o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=o.length;for(let n=0;n<6;n++)e.push(o.charAt(Math.floor(Math.random()*t)));return e.join("")}function V(e){let o={};return e.fields.forEach(t=>{t.id&&(t.type==="array"&&t.default&&Array.isArray(t.default)?o[t.id]=H(t.default):t.default?o[t.id]=t.default:t.type==="object"&&(o[t.id]=V(t)))}),o}function k(e,o,t){let n={...o};return e.fields.forEach(r=>{if(!r.id)return;let i=n[r.id];if(i!=null){if(r.type==="array"&&Array.isArray(i)){let l=i.map(m=>ye(r.of,m,t));n[r.id]=H(l)}else if(r.type==="object"&&M(i))n[r.id]=k(r,i,t);else if(r.type==="oneof"&&M(i)&&typeof i._type=="string"&&t){let l=t[i._type];l&&(n[r.id]=k(l,i,t))}}}),n}function ye(e,o,t){if(!M(o))return o;if(e.type==="object")return k(e,o,t);if(e.type==="oneof"&&typeof o._type=="string"&&t){let n=t[o._type];if(n)return k(n,o,t)}return o}O();function pe(e){let[o,t]=S(e.collectionId||""),n=_(null),[r,i]=S(e.initialSlug||""),l=window.__ROOT_CTX.collections[o],m=[];e.collectionId&&e.collectionDisabled?m.push({value:e.collectionId,label:e.collectionId}):Object.keys(window.__ROOT_CTX.collections).forEach(s=>{m.push({value:s,label:s})});let u="",f="";if(l?.url){if(r){let s=T(r),d=l?.slugRegex;ee(s,d)?u=F({collectionId:o,slug:s}):f=A(s,d)}else u=F({collectionId:o,slug:"[slug]"});u.endsWith("/index")&&(u=u.replace(/\/index$/,"/"))}function a(s){t(s),e.onChange&&e.onChange({collectionId:s,slug:r})}function c(s){i(s),e.onChange&&e.onChange({collectionId:o,slug:s})}return g("div",{className:se(e.className,"SlugInput"),children:[g("div",{className:"SlugInput__inputs",children:[g(J,{className:"SlugInput__collection",placeholder:"Collection",size:"xs",data:m,onChange:s=>a(s),value:o,disabled:!!e.collectionDisabled}),g("div",{className:"SlugInput__divider",children:"/"}),g(q,{className:"SlugInput__slug",name:"slug",ref:n,value:r,onChange:s=>{c(s.currentTarget.value)},placeholder:"slug",autoComplete:"off",size:"xs"})]}),u&&g(j,{className:"SlugInput__urlHelp",size:"body-sm",children:u}),f&&g(j,{className:"SlugInput__slugError",size:"body-sm",children:f})]})}function xt(e){let{route:o}=Z(),t=G(),n=e.collection,r=window.__ROOT_CTX.collections[n];if(!r)throw new Error(`collection not found: ${n}`);let[i]=S(()=>r.autoSlug?oe(r.autoSlug):""),[l,m]=S(i),[u,f]=S(!1),[a,c]=S(()=>h(i)),[s,d]=S(""),p=me(n);function h(E){let b=T(E);return b?A(b,r.slugRegex):""}function w(){e.onClose&&e.onClose()}async function P(E){if(E.preventDefault(),f(!0),c(""),h(l)){f(!1);return}let x=T(l),he=`${n}/${x}`;try{let N={};!p.loading&&p.schema&&(N=await V(p.schema)),await re(he,{fields:N})}catch(N){d(String(N)),f(!1);return}f(!1),e.skipNavigation?w():o(`/cms/content/${e.collection}/${x}`)}return g(Q,{className:"NewDocModal",opened:e.opened||!1,onClose:()=>w(),title:"New",size:"500px",overlayColor:t.colorScheme==="dark"?t.colors.dark[9]:t.colors.gray[2],children:[g("div",{className:"NewDocModal__body",children:"Enter a slug for the new doc. The slug is the ID of the page and is what's used in the URL. Use only lowercase letters, numbers, and dashes."}),g("form",{onSubmit:E=>P(E),children:[g(pe,{className:"NewDocModal__slug",collectionId:n,initialSlug:i,onChange:E=>{m(E.slug),c(h(E.slug)),d("")}}),s&&g("div",{className:"NewDocModal__slugError",children:s}),g("div",{className:"NewDocModal__buttons",children:[g($,{variant:"outline",onClick:()=>w(),type:"button",size:"xs",color:"dark",children:"Cancel"}),g($,{variant:"filled",type:"submit",size:"xs",color:"dark",loading:p.loading||u,disabled:!!a||!!s,children:"Submit"})]})]})]})}export{F as a,Ee as b,be as c,pe as d,Ae as e,He as f,me as g,V as h,k as i,xt as j};
@@ -1 +0,0 @@
1
- import{c as F}from"./chunk-VJRMR2JM.js";import{b as _}from"./chunk-5MV6XVGA.js";import{a as U}from"./chunk-PLYSJ7W5.js";import{b as L}from"./chunk-2PTLQRTU.js";import{N as S,b as I}from"./chunk-ISUGBMXC.js";import{B as v,z as P}from"./chunk-XOWWPE7X.js";import{e as b}from"./chunk-WASID5UU.js";import{Fa as p,Ga as t,V as B,a as g,ba as c,c as h,e as A,i as T,j as R,la as N}from"./chunk-WRA24P66.js";import{d as y,j as k,k as O}from"./chunk-KUCVLANF.js";O();R();var $=k(null);function Z(e){let[i,n]=g([]),[o,r]=g(!1),a=A("idle");function u(){a.current==="idle"&&(a.current="fetching",r(!0),F().then(l=>{let d=l.filter(f=>!f.publishedAt&&!f.archivedAt);n(d)}).catch(l=>{console.error("Failed to fetch pending releases:",l)}).finally(()=>{a.current="done",r(!1)}))}function s(l){return i.filter(d=>d.docIds?.includes(l))}return t($.Provider,{value:{releases:i,getReleasesForDoc:s,loading:o,fetchReleases:u},children:e.children})}function z(){let e=T($);if(!e)throw new Error("usePendingReleases must be used within a <PendingReleasesProvider>");let{fetchReleases:i,...n}=e;return h(()=>{i()},[]),n}function m(e){let{message:i,detail:n,user:o}=e;return t(p,{label:t("div",{className:"UserActionTooltip",children:[o&&t(U,{email:o,size:20,withTooltip:!1}),t("div",{className:"UserActionTooltip__text",children:[t("span",{children:i}),n&&t("span",{className:"UserActionTooltip__detail",children:n}),o&&t("span",{children:["by ",o]})]})]}),position:e.position,transition:e.transition??"pop",withArrow:e.withArrow??!0,children:e.children})}function M(e){let i={transition:"pop"},n=e.doc,o=n.sys;return t("div",{className:"DocStatusBadges",children:[(!o.publishedAt||!o.modifiedAt||o.modifiedAt>o.publishedAt)&&t(m,{position:e.tooltipPosition,message:`Modified ${C(o.modifiedAt)}`,user:o.modifiedBy,children:t(c,{size:"xs",variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:"Draft"})}),!!o.publishedAt&&t(m,{position:e.tooltipPosition,message:`Published ${C(o.publishedAt)}`,user:o.publishedBy,children:t(c,{size:"xs",variant:"gradient",gradient:{from:"teal",to:"lime",deg:105},children:"Published"})}),!!o.scheduledAt&&t(m,{position:e.tooltipPosition,message:`Scheduled ${v(o.scheduledAt)}`,user:o.scheduledBy,children:t(c,{size:"xs",variant:"gradient",gradient:{from:"grape",to:"pink",deg:35},children:"Scheduled"})}),!e.hideReleases&&t(X,{docId:e.docId||n.id,tooltipProps:i}),S(n)&&t(m,{position:e.tooltipPosition,message:K(n),detail:n.sys?.publishingLocked?.reason,user:n.sys?.publishingLocked?.lockedBy,children:t(c,{size:"xs",variant:"gradient",gradient:{from:"orange",to:"red"},className:e.onPublishingLockClick?"DocStatusBadges__badge--clickable":void 0,style:e.onPublishingLockClick?{cursor:"pointer"}:void 0,role:e.onPublishingLockClick?"button":void 0,tabIndex:e.onPublishingLockClick?0:void 0,onClick:e.onPublishingLockClick,onKeyDown:e.onPublishingLockClick?r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),e.onPublishingLockClick())}:void 0,children:"Locked"})}),!!o.archivedAt&&t(m,{position:e.tooltipPosition,message:`Archived ${C(o.archivedAt)}`,user:o.archivedBy,children:t(c,{size:"xs",variant:"gradient",gradient:{from:"gray",to:"dark"},children:"Archived"})})]})}function K(e){let i=e.sys?.publishingLocked;return i?.until?`Locked until ${v(i.until)}`:"Locked"}function ve(e){let i=e.sys?.publishingLocked;return i?i.until?`Locked until ${v(i.until)} by ${i.lockedBy}: "${i.reason}"`:`Locked by ${i.lockedBy}: "${i.reason}"`:""}function X(e){let{getReleasesForDoc:i}=z(),n=i(e.docId);return n.length===0?null:t(y,{children:n.map(o=>t(p,{...e.tooltipProps,label:`In release: ${o.id}`,children:t(c,{component:"a",href:`/cms/releases/${o.id}`,size:"xs",variant:"gradient",gradient:{from:"violet",to:"grape"},style:{cursor:"pointer"},children:o.id})},o.id))})}function C(e){return e?P(e.toMillis()):P(new Date().getTime())}function E(e){let{file:i,width:n,height:o,withPlaceholder:r,className:a,alt:u}=e,s=typeof i=="string"?i:i?.src;return q(i)?t(G,{className:a,src:s,width:n,height:o}):t(N,{className:a,src:s,width:n,height:o,withPlaceholder:r,alt:u})}function q(e){if(!e)return!1;if(typeof e=="string")return/\.mp4($|\?)/i.test(e);if(typeof e.mimeType=="string")return e.mimeType.toLowerCase()==="video/mp4";let i=e.src;return typeof i!="string"?!1:/\.mp4($|\?)/i.test(i)}function G(e){return t("video",{className:e.className,src:e.src,width:e.width,height:e.height,muted:!0,playsInline:!0,preload:"metadata",style:{width:`${e.width}px`,height:`${e.height}px`,backgroundColor:"#f1f3f5",objectFit:"cover",display:"block"}})}R();function Se(e){let i=e.docId,[n,o]=g(e.doc),[r,a]=g(!e.doc);async function u(){a(!0),await L(async()=>{let V=await I(i);o(V)}),a(!1)}if(h(()=>{u()},[i]),r)return t("div",{className:b(e.className,"DocPreviewCard","DocPreviewCard--loading",e.variant&&`DocPreviewCard--${e.variant}`),children:t(B,{color:"gray",size:"sm"})});if(!n)return;let[s]=i.split("/"),l=n.fields||{},d=window.__ROOT_CTX.collections[s];if(!d)return console.error(`could not find collection: ${s}`),t("div",{className:"DocPreviewCard",children:["Collection ",t("b",{children:s})," not found."]});let f=_(l,d.preview?.title||"meta.title"),x=_(l,d.preview?.image||"meta.image")||d.preview?.defaultImage,D="div",w={};return e.clickable&&(D="a",w.href=`/cms/content/${e.docId}`,w.target="_blank"),t(D,{className:b(e.className,"DocPreviewCard",e.variant&&`DocPreviewCard--${e.variant}`),...w,children:[t("div",{className:"DocPreviewCard__image",children:t(E,{file:x,width:80,height:60,withPlaceholder:!x?.src})}),t("div",{className:"DocPreviewCard__content",children:[t("div",{className:"DocPreviewCard__content__header",children:t("div",{className:"DocPreviewCard__content__header__docId",children:n.id})}),t("div",{className:"DocPreviewCard__content__title",children:f||"[UNTITLED]"}),e.statusBadges&&n&&t("div",{className:"DocPreviewCard__content__badges",children:t(M,{doc:n,hideReleases:e.hideReleases})})]})]})}export{Z as a,z as b,m as c,M as d,ve as e,E as f,Se as g};
@@ -1 +0,0 @@
1
- import{e}from"./chunk-WASID5UU.js";import{Ga as o}from"./chunk-WRA24P66.js";function n(r){return o("div",{className:e(r.className,"Surface"),children:r.children})}export{n as a};
@@ -1,7 +0,0 @@
1
- import{f as k}from"./chunk-5MV6XVGA.js";import{e as b}from"./chunk-WASID5UU.js";import{Ga as a,a as M,c as y,e as z,g as P,j as O}from"./chunk-WRA24P66.js";var L=class{diff(e,o,n={}){let i;typeof n=="function"?(i=n,n={}):"callback"in n&&(i=n.callback);let l=this.castInput(e,n),c=this.castInput(o,n),h=this.removeEmpty(this.tokenize(l,n)),r=this.removeEmpty(this.tokenize(c,n));return this.diffWithOptionsObj(h,r,n,i)}diffWithOptionsObj(e,o,n,i){var l;let c=t=>{if(t=this.postProcess(t,n),i){setTimeout(function(){i(t)},0);return}else return t},h=o.length,r=e.length,s=1,f=h+r;n.maxEditLength!=null&&(f=Math.min(f,n.maxEditLength));let m=(l=n.timeout)!==null&&l!==void 0?l:1/0,g=Date.now()+m,d=[{oldPos:-1,lastComponent:void 0}],u=this.extractCommon(d[0],o,e,0,n);if(d[0].oldPos+1>=r&&u+1>=h)return c(this.buildValues(d[0].lastComponent,o,e));let x=-1/0,p=1/0,_=()=>{for(let t=Math.max(x,-s);t<=Math.min(p,s);t+=2){let C,w=d[t-1],D=d[t+1];w&&(d[t-1]=void 0);let J=!1;if(D){let I=D.oldPos-t;J=D&&0<=I&&I<h}let T=w&&w.oldPos+1<r;if(!J&&!T){d[t]=void 0;continue}if(!T||J&&w.oldPos<D.oldPos?C=this.addToPath(D,!0,!1,0,n):C=this.addToPath(w,!1,!0,1,n),u=this.extractCommon(C,o,e,t,n),C.oldPos+1>=r&&u+1>=h)return c(this.buildValues(C.lastComponent,o,e))||!0;d[t]=C,C.oldPos+1>=r&&(p=Math.min(p,t-1)),u+1>=h&&(x=Math.max(x,t+1))}s++};if(i)(function t(){setTimeout(function(){if(s>f||Date.now()>g)return i(void 0);_()||t()},0)})();else for(;s<=f&&Date.now()<=g;){let t=_();if(t)return t}}addToPath(e,o,n,i,l){let c=e.lastComponent;return c&&!l.oneChangePerToken&&c.added===o&&c.removed===n?{oldPos:e.oldPos+i,lastComponent:{count:c.count+1,added:o,removed:n,previousComponent:c.previousComponent}}:{oldPos:e.oldPos+i,lastComponent:{count:1,added:o,removed:n,previousComponent:c}}}extractCommon(e,o,n,i,l){let c=o.length,h=n.length,r=e.oldPos,s=r-i,f=0;for(;s+1<c&&r+1<h&&this.equals(n[r+1],o[s+1],l);)s++,r++,f++,l.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return f&&!l.oneChangePerToken&&(e.lastComponent={count:f,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=r,s}equals(e,o,n){return n.comparator?n.comparator(e,o):e===o||!!n.ignoreCase&&e.toLowerCase()===o.toLowerCase()}removeEmpty(e){let o=[];for(let n=0;n<e.length;n++)e[n]&&o.push(e[n]);return o}castInput(e,o){return e}tokenize(e,o){return Array.from(e)}join(e){return e.join("")}postProcess(e,o){return e}get useLongestToken(){return!1}buildValues(e,o,n){let i=[],l;for(;e;)i.push(e),l=e.previousComponent,delete e.previousComponent,e=l;i.reverse();let c=i.length,h=0,r=0,s=0;for(;h<c;h++){let f=i[h];if(f.removed)f.value=this.join(n.slice(s,s+f.count)),s+=f.count;else{if(!f.added&&this.useLongestToken){let m=o.slice(r,r+f.count);m=m.map(function(g,d){let u=n[s+d];return u.length>g.length?u:g}),f.value=this.join(m)}else f.value=this.join(o.slice(r,r+f.count));r+=f.count,f.added||(s+=f.count)}}return i}};var N=class extends L{constructor(){super(...arguments),this.tokenize=A}equals(e,o,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
2
- `))&&(e=e.trim()),(!n.newlineIsToken||!o.includes(`
3
- `))&&(o=o.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
4
- `)&&(e=e.slice(0,-1)),o.endsWith(`
5
- `)&&(o=o.slice(0,-1))),super.equals(e,o,n)}},j=new N;function E(v,e,o){return j.diff(v,e,o)}function A(v,e){e.stripTrailingCr&&(v=v.replace(/\r\n/g,`
6
- `));let o=[],n=v.split(/(\n|\r\n)/);n[n.length-1]||n.pop();for(let i=0;i<n.length;i++){let l=n[i];i%2&&!e.newlineIsToken?o[o.length-1]+=l:o.push(l)}return o}O();var R=4;function oe(v){let{oldCode:e,newCode:o,className:n=""}=v,[i,l]=M({}),c=P(()=>{let m=W(e),g=W(o);return m!==void 0&&g!==void 0?{oldCode:k(m),newCode:k(g)}:{oldCode:e,newCode:o}},[e,o]),h=P(()=>E(c.oldCode,c.newCode),[c]);y(()=>{l({})},[c]);let r=z(null);y(()=>{if(r.current){let m=r.current.querySelector(".JsDiff__diffLine--added, .JsDiff__diffLine--removed");m&&m.scrollIntoView({behavior:"smooth",block:"center"})}},[c]);let s=P(()=>{let m=[],g=0;return h.forEach((d,u)=>{let x=d.added?"+":d.removed?"-":" ",p=d.added?"added":d.removed?"removed":"unchanged",_=d.value.split(`
7
- `);_.forEach((t,C)=>{(t.length>0||C<_.length-1)&&m.push({key:`${u}-${C}`,type:p,lineNumber:++g,sign:x,text:t})})}),m},[h]),f=()=>{let m=new Set;s.forEach((p,_)=>{p.type!=="unchanged"&&m.add(_)});let g=new Set;if(s.forEach((p,_)=>{if(m.has(_)){g.add(_);for(let t=1;t<=R;t++)_-t>=0&&g.add(_-t),_+t<s.length&&g.add(_+t)}}),m.size===0)return s.map(p=>a(S,{line:p},p.key));let d=[],u=0,x=0;for(;u<s.length;)if(g.has(u))d.push(a(S,{line:s[u]},s[u].key)),u++;else{let p=x++,_=u;for(;u<s.length&&!g.has(u);)u++;let t=s.slice(_,u),C=t.length;i[p]?(d.push(a("div",{className:"JsDiff__collapsed",onClick:()=>l(D=>({...D,[p]:!1})),children:[a(V,{}),a("span",{children:["Hide ",C," unchanged line",C!==1?"s":""]})]},`collapse-${p}`)),d.push(...t.map(D=>a(S,{line:D},D.key)))):d.push(a("div",{className:"JsDiff__collapsed",onClick:()=>l(D=>({...D,[p]:!0})),children:[a(q,{}),a("span",{children:[C," unchanged line",C!==1?"s":""," hidden"]})]},`collapse-${p}`))}return d};return a("div",{className:b("JsDiff__container",n),children:a("div",{className:"JsDiff__content",ref:r,children:f()})})}function S(v){let{line:e}=v;return a("div",{className:b("JsDiff__diffLine",e.type==="added"&&"JsDiff__diffLine--added",e.type==="removed"&&"JsDiff__diffLine--removed",e.type==="unchanged"&&"JsDiff__diffLine--unchanged"),children:[a("span",{className:"JsDiff__lineNumber",children:e.lineNumber}),a("span",{className:"JsDiff__lineContent",children:[a("span",{className:"JsDiff__sign",children:e.sign}),a("span",{children:e.text||" "})]})]})}function W(v){try{return JSON.parse(v)}catch{return}}function q(){return a("svg",{className:"JsDiff__collapsed__icon",width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round",children:a("path",{d:"M4 6l4 4 4-4"})})}function V(){return a("svg",{className:"JsDiff__collapsed__icon",width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round",children:a("path",{d:"M4 10l4-4 4 4"})})}export{oe as a};
@@ -1 +0,0 @@
1
- import{c as T}from"./chunk-JDW4UORS.js";import{k as z}from"./chunk-Z2CRNO3I.js";import{C as _}from"./chunk-ISUGBMXC.js";import{D as l,a as f,b as w,c as s,g as b,i as k,n as v,o as j,q as u,t as R,u as c,v as y,x as I}from"./chunk-XOWWPE7X.js";var O=["agile","airy","alert","amber","amused","ancient","aqua","arctic","astral","autumn","avid","azure","balmy","beige","big","bitter","black","blazing","blissful","blooming","blue","bold","bouncy","brainy","brave","breezy","bright","brisk","broad","bronze","brown","bubbly","busy","calm","candid","careful","caring","charming","cheerful","cherry","chilly","chipper","classic","clean","clear","clever","cloudy","coastal","cobalt","cold","cool","copper","coral","cosmic","cosy","cozy","crafty","creamy","crimson","crisp","cuddly","curious","dandy","dapper","daring","dark","dawn","dazzling","dear","deep","deft","delicate","dewy","dizzy","dotted","dreamy","driven","dry","dusky","dusty","eager","early","earnest","earthy","eastern","easy","ebony","elated","electric","elegant","emerald","empty","epic","even","every","faint","fair","falling","famous","fancy","fast","feisty","festive","fierce","fiery","fine","firm","flat","floral","flowing","fluffy","foggy","fond","forest","fragrant","fresh","friendly","frisky","frosty","funky","funny","fuzzy","gallant","gentle","giant","gilded","glad","gleaming","glossy","glowing","gold","golden","good","graceful","grand","grassy","gray","green","groovy","gusty","handy","happy","hardy","hazy","hearty","heavy","helpful","heroic","hidden","high","holy","honest","honeyed","hopeful","humble","humming","hushed","icy","ideal","idle","indigo","inky","iron","ivory","jade","jaunty","jazzy","jolly","jovial","joyful","jubilant","juicy","jumpy","keen","kind","kindly","lacy","late","lazy","leafy","lemon","light","limber","lime","linen","little","lively","lone","long","loud","lovely","loyal","lucid","lucky","luminous","lunar","lush","magenta","magic","majestic","mango","marble","maritime","maroon","massive","mauve","mellow","merry","mighty","mild","milky","mindful","minty","misty","mocha","modest","morning","mossy","muddy","mysterious","mythic","narrow","navy","neat","neon","new","nimble","noble","noisy","noon","northern","nosy","nutty","oaken","oceanic","odd","old","olive","onyx","opal","open","orange","orderly","pale","pastel","patient","peaceful","peach","peachy","pearly","pebbly","peppy","perky","pink","placid","plain","playful","pleasant","plucky","plum","plush","polar","polite","prime","pristine","proud","pure","purple","quaint","quick","quiet","quirky","radiant","rapid","rare","raven","ready","red","regal","restless","rich","rolling","rosy","rough","round","royal","ruby","rugged","rumbling","russet","rustic","sable","safe","sage","salty","sandy","sapphire","savvy","scarlet","scenic","secret","sepia","serene","shaggy","sharp","shimmering","shiny","short","shrewd","shy","silent","silky","silly","silver","simple","sleek","sleepy","slim","slow","small","smart","smoky","smooth","snappy","snowy","soaring","soft","solar","solid","southern","sparkly","speedy","spicy","spiffy","spotted","spry","square","starry","steady","steel","stellar","sticky","still","stony","stormy","striped","strong","sturdy","subtle","sunlit","sunny","super","supreme","swank","sweet","swift","tame","tan","tangy","tart","teal","tender","thin","thirsty","thriving","tidal","tidy","tiny","tireless","toasty","topaz","tough","tranquil","trim","tropical","true","twinkly","umber","upbeat","urban","useful","valiant","vast","velvet","verdant","vernal","vibrant","vintage","violet","vivid","wandering","warm","watchful","wavy","wee","western","whimsical","whispering","white","wholesome","wild","winding","windy","winter","wintry","wise","witty","wondrous","woody","wool","yellow","young","youthful","zany","zealous","zen","zesty","zippy"],A=["acorn","almond","alpaca","anchor","antler","apple","apricot","arrow","aspen","aurora","autumn","avocado","badger","bagel","bamboo","banana","basil","bay","bayou","beach","bear","bee","beetle","bell","berry","birch","bird","biscuit","bison","blossom","bluff","boat","bobcat","bonfire","book","boot","bottle","boulder","branch","brass","breeze","bridge","brook","broom","brunch","bubble","bucket","bud","buffalo","bug","bunny","burrow","butter","button","cabin","cactus","cake","camel","canary","candle","canyon","cape","caravan","cardinal","carrot","cascade","cashew","castle","cat","cave","cedar","chair","cherry","chestnut","chickpea","chime","cinnamon","citadel","cliff","cloud","clove","clover","cocoa","comet","compass","condor","cookie","coral","cottage","cotton","cove","coyote","crane","crayon","creek","cricket","crocus","crow","crumpet","crystal","cup","cupcake","currant","cypress","daffodil","dahlia","daisy","dawn","deer","delta","desert","dew","diamond","dingo","dock","dogwood","dolphin","donut","dove","dragon","drift","drizzle","drum","duck","dumpling","dune","eagle","echo","eclipse","eel","egg","elder","elephant","elk","ember","ermine","estuary","evergreen","falcon","fawn","feather","fennel","fern","ferret","field","fig","finch","fir","firefly","fish","fjord","flame","flamingo","flask","flax","fleece","flicker","flower","flute","fog","forest","fossil","fountain","fox","frog","frost","galaxy","garden","gazelle","gecko","gem","geyser","ginger","glacier","glade","glen","globe","glow","goat","goose","gorge","gourd","granite","grape","grass","grotto","grove","gull","hammock","harbor","hare","harp","harvest","hat","hawk","haystack","hazel","hearth","heather","hedge","heron","hibiscus","hickory","hill","hollow","honey","horizon","horse","hummingbird","ibis","iceberg","icicle","inlet","iris","island","ivy","jackal","jacket","jade","jaguar","jam","jar","jasmine","jay","jelly","jetty","juniper","kayak","kelp","kestrel","kettle","key","kingfisher","kite","kitten","kiwi","knoll","koala","ladybug","lagoon","lake","lamp","lantern","lark","lava","lavender","leaf","ledge","lemon","lemur","leopard","lichen","lighthouse","lilac","lily","lime","lion","llama","lobster","log","loon","lotus","lynx","lyric","magnet","manatee","mango","mangrove","maple","marble","marigold","marlin","marsh","meadow","melody","melon","mermaid","mesa","meteor","minnow","mint","mirage","mist","mitten","mole","monkey","moon","moose","morel","mosaic","moss","moth","mountain","mouse","muffin","mushroom","mussel","narwhal","nautilus","nectar","needle","nest","nettle","newt","nightingale","nimbus","noodle","north","note","nutmeg","oak","oasis","oats","ocean","ocelot","octopus","olive","onion","opal","orange","orca","orchid","oriole","osprey","otter","owl","oyster","paddle","palm","panda","pansy","panther","papaya","paper","parrot","parsley","partridge","pasture","path","peach","peacock","pear","pebble","pecan","pelican","penguin","peony","pepper","petal","petunia","pheasant","phoenix","pie","pigeon","pine","pineapple","pistachio","planet","plateau","plover","plum","pond","pony","poppy","porpoise","pouch","prairie","pretzel","primrose","puffin","pumpkin","quail","quartz","queen","quill","quince","quokka","rabbit","raccoon","radish","rain","rainbow","rapids","raspberry","raven","redwood","reef","reel","reindeer","rhino","ribbon","ridge","river","road","robin","rock","rooster","rose","rosemary","rowan","rye","saffron","sage","salmon","sand","sapphire","satellite","savanna","scallop","scarf","sea","seagull","seal","seed","sequoia","sesame","shark","shell","shore","shrimp","silk","silo","sky","skylark","sleet","snail","snake","snow","sock","sorbet","spark","sparrow","spider","spire","spoon","spring","sprout","spruce","squirrel","star","starfish","starling","stone","stork","storm","stream","summer","sun","sundial","sunflower","swan","swift","sycamore","tadpole","tamarind","tangerine","tea","teal","tern","terrace","thicket","thistle","thrush","thunder","tide","tiger","timber","toad","toffee","tooth","topaz","tortoise","totem","toucan","tower","tractor","trail","tree","trout","truffle","tugboat","tulip","tundra","turnip","turtle","twig","twilight","umbrella","unicorn","urchin","valley","vanilla","vine","violet","vista","volcano","voyage","vulture","wagon","walnut","walrus","wasp","water","waterfall","wave","whale","wharf","wheat","whisker","wildcat","wildflower","willow","wind","window","winter","wisteria","wolf","wombat","wood","wren","yak","yam","yarrow","yew","yucca","zebra","zephyr","zinnia","zucchini"];var x="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",S="YYYYMMDD";function D(e,r){let a=r?.now??new Date,o=r?.random??Math.random,t=e.replace(/\{([^{}]+?)\}/g,(n,d)=>{let[p,g]=q(d);switch(p){case"date":return E(a,g||S);case"adjective":return C(O,o);case"noun":return C(A,o);case"random":return M(Y(g,6),o);default:return n}});return T(t.toLowerCase())}function q(e){let r=e.indexOf(":");return r===-1?[e.trim(),void 0]:[e.slice(0,r).trim(),e.slice(r+1)]}function Y(e,r){if(!e)return r;let a=parseInt(e,10);return Number.isFinite(a)&&a>0?a:r}function C(e,r){return e[Math.floor(r()*e.length)]}function M(e,r){let a=[];for(let o=0;o<e;o++)a.push(x.charAt(Math.floor(r()*x.length)));return a.join("")}function E(e,r){let a={YYYY:String(e.getFullYear()),YY:String(e.getFullYear()).slice(-2),MM:m(e.getMonth()+1),DD:m(e.getDate()),HH:m(e.getHours()),mm:m(e.getMinutes()),ss:m(e.getSeconds())};return r.replace(/YYYY|YY|MM|DD|HH|mm|ss/g,o=>a[o]??o)}function m(e){return e<10?`0${e}`:String(e)}var i="Releases";async function V(e,r){if(!e)throw new Error("missing data source id");let a=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,t=s(o,"Projects",a,i,e);await R(o,async n=>{if((await n.get(t)).exists())throw new Error(`release exists: ${e}`);await n.set(t,{...r,id:e,createdAt:y(),createdBy:window.firebase.user.email})}),l("release.create",{metadata:{releaseId:e}})}async function G(){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,a=w(r,"Projects",e,i),o=b(a,k("createdAt","desc")),t=await j(o),n=[];return t.forEach(d=>{n.push(d.data())}),n}async function h(e){let r=window.__ROOT_CTX.rootConfig.projectId,a=window.firebase.db,o=s(a,"Projects",r,i,e),t=await v(o);return t.exists()?t.data():null}async function K(e,r){let a=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,t=s(o,"Projects",a,i,e);await u(t,r),l("release.save",{metadata:{releaseId:e}})}async function Q(e){let r=window.__ROOT_CTX.rootConfig.projectId,a=window.firebase.db,o=s(a,"Projects",r,i,e);await u(o,{archivedAt:y(),archivedBy:window.firebase.user.email}),l("release.archive",{metadata:{releaseId:e}})}async function W(e){let r=window.__ROOT_CTX.rootConfig.projectId,a=window.firebase.db,o=s(a,"Projects",r,i,e);await u(o,{archivedAt:c(),archivedBy:c()}),l("release.unarchive",{metadata:{releaseId:e}})}async function Z(e){let r=await h(e);if(!r)throw new Error(`release not found: ${e}`);if(r.archivedAt)throw new Error(`release is archived: ${e}`);let a=r.docIds||[],o=r.dataSourceIds||[];if(a.length===0&&o.length===0)throw new Error(`no docs or data sources to publish for release: ${e}`);let t=window.__ROOT_CTX.rootConfig.projectId,n=window.firebase.db,d=s(n,"Projects",t,i,e),p=I(n);p.update(d,{publishedAt:y(),publishedBy:window.firebase.user.email,scheduledAt:c(),scheduledBy:c()}),o.length>0&&await z(o,{batch:p,commitBatch:!1}),await _(a,{batch:p,releaseId:e,publishMessage:r.description}),console.log(`published release: ${e}`);let g={releaseId:e,docIds:a,dataSourceIds:o};r.description&&(g.publishMessage=r.description),l("release.publish",{metadata:g})}async function ee(e,r){let a=await h(e);if(!a)throw new Error(`release not found: ${e}`);if(a.archivedAt)throw new Error(`release is archived: ${e}`);typeof r=="number"&&(r=f.fromMillis(r));let o=window.__ROOT_CTX.rootConfig.projectId,t=window.firebase.db,n=s(t,"Projects",o,i,e);await u(n,{scheduledAt:r,scheduledBy:window.firebase.user.email}),l("release.publish",{metadata:{releaseId:e,scheduledAt:r.toMillis()}})}function re(){return D("{date}-{adjective}-{noun}")}async function ae(e){if(!await h(e))throw new Error(`release not found: ${e}`);let a=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,t=s(o,"Projects",a,i,e);await u(t,{scheduledAt:c(),scheduledBy:c()}),l("release.unschedule",{metadata:{releaseId:e}})}export{D as a,V as b,G as c,h as d,K as e,Q as f,W as g,Z as h,ee as i,re as j,ae as k};