@blinkk/root-cms 3.1.5 → 3.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/app.js +1 -1
  2. package/dist/{chunk-ETHWZSNM.js → chunk-PLSNGCYU.js} +196 -22
  3. package/dist/{chunk-MUXSUGFF.js → chunk-U4TMO2LI.js} +2 -2
  4. package/dist/{chunk-6CTCV2PN.js → chunk-Z2CTQVYR.js} +1 -1
  5. package/dist/cli.js +1 -1
  6. package/dist/client.js +1 -1
  7. package/dist/core/client.d.ts +30 -2
  8. package/dist/core/cron-schedule.d.ts +63 -0
  9. package/dist/core/plugin.d.ts +6 -1
  10. package/dist/core.js +1 -1
  11. package/dist/functions.js +2 -2
  12. package/dist/plugin.js +7 -5
  13. package/dist/richtext.js +1 -1
  14. package/dist/shared/embed-protocol.d.ts +19 -0
  15. package/dist/ui/{AIPage-25WICIOT.js → AIPage-EO5WH25R.js} +1 -1
  16. package/dist/ui/{AssetsPage-WKTM2J2G.js → AssetsPage-ESLB4R3I.js} +1 -1
  17. package/dist/ui/{CollectionPage-5ZOVG7IG.js → CollectionPage-MXN7XKUX.js} +1 -1
  18. package/dist/ui/{ComparePage-DDIFYYTK.js → ComparePage-TY7VJVE3.js} +1 -1
  19. package/dist/ui/{DataPage-RFNGSDDN.js → DataPage-YEIS7HBN.js} +1 -1
  20. package/dist/ui/{DataSourcePage-U46CDIH2.js → DataSourcePage-VD6YBDRW.js} +1 -1
  21. package/dist/ui/{DocTranslationsPage-BFCM2PE3.js → DocTranslationsPage-6XLREBPQ.js} +1 -1
  22. package/dist/ui/DocumentPage-2HNNEGRI.js +1 -0
  23. package/dist/ui/{EditDataSourcePage-NKKIF6AD.js → EditDataSourcePage-E4PSKSG3.js} +1 -1
  24. package/dist/ui/{EditReleasePage-TKNOUT7A.js → EditReleasePage-DOMXJXCU.js} +1 -1
  25. package/dist/ui/{EmbeddedAIPage-4AX7VO3T.js → EmbeddedAIPage-U5LONYH2.js} +1 -1
  26. package/dist/ui/EmbeddedDocumentPage-HYV5GPK6.js +1 -0
  27. package/dist/ui/{LogsPage-SCECIAZH.js → LogsPage-6KV3CQLH.js} +1 -1
  28. package/dist/ui/{NewDataSourcePage-FAOPK2RZ.js → NewDataSourcePage-NJJDHGPX.js} +1 -1
  29. package/dist/ui/{NewReleasePage-HD6T6UV2.js → NewReleasePage-FXHPFUVG.js} +1 -1
  30. package/dist/ui/{NotFoundPage-JRYFUENW.js → NotFoundPage-CA7XVXUO.js} +1 -1
  31. package/dist/ui/{ProjectPage-2WIMWCSX.js → ProjectPage-XUBJSCWB.js} +1 -1
  32. package/dist/ui/{ReleasePage-GUMEMLF6.js → ReleasePage-NLGRYJX7.js} +1 -1
  33. package/dist/ui/{ReleasesPage-AW6PICTQ.js → ReleasesPage-OY7OKC3C.js} +1 -1
  34. package/dist/ui/{SettingsPage-KFLNZ356.js → SettingsPage-5EQUY52A.js} +1 -1
  35. package/dist/ui/SidebarToolsPage-FWG6TIDI.js +1 -0
  36. package/dist/ui/TaskPage-APNRUOYG.js +1 -0
  37. package/dist/ui/{TasksPage-G3GBTV3L.js → TasksPage-FTEELXVZ.js} +1 -1
  38. package/dist/ui/{TranslationsArbPage-K272JEAA.js → TranslationsArbPage-PG5USRYB.js} +1 -1
  39. package/dist/ui/{TranslationsEditPage-XWXPNKRQ.js → TranslationsEditPage-GV3ZJXTY.js} +1 -1
  40. package/dist/ui/{TranslationsPage-7KUHVTLK.js → TranslationsPage-3AKSMCNF.js} +1 -1
  41. package/dist/ui/{chunk-VPZHG7JL.js → chunk-235TRWJF.js} +1 -1
  42. package/dist/ui/{chunk-IGZDFHVM.js → chunk-3LEYSXZP.js} +1 -1
  43. package/dist/ui/chunk-56NMZYX6.js +19 -0
  44. package/dist/ui/{chunk-T5BJNOWE.js → chunk-6WJQBFN5.js} +1 -1
  45. package/dist/ui/{chunk-OWBT6YUM.js → chunk-A7IZAHBZ.js} +1 -1
  46. package/dist/ui/{chunk-WC7KMPEQ.js → chunk-C5FRMXDS.js} +1 -1
  47. package/dist/ui/{chunk-UPN3EMUS.js → chunk-EYJ6GKZR.js} +1 -1
  48. package/dist/ui/{chunk-TNW2GNUR.js → chunk-G5647K25.js} +1 -1
  49. package/dist/ui/chunk-LAXQZPE3.js +31 -0
  50. package/dist/ui/chunk-MYPLMHFW.js +1 -0
  51. package/dist/ui/{chunk-XUBZH4ON.js → chunk-O7ESOZQO.js} +1 -1
  52. package/dist/ui/{chunk-5KSGCGYY.js → chunk-QGAPMQEJ.js} +1 -1
  53. package/dist/ui/{chunk-7UHZS56B.js → chunk-ST6QNIWT.js} +53 -53
  54. package/dist/ui/{chunk-DWV5J2W7.js → chunk-U7LSFUHT.js} +1 -1
  55. package/dist/ui/chunk-UOKVF54Y.js +3 -0
  56. package/dist/ui/{chunk-FVWSVOOY.js → chunk-VJRMR2JM.js} +1 -1
  57. package/dist/ui/chunk-Z2CRNO3I.js +1 -0
  58. package/dist/ui/{chunk-N5RJIILP.js → chunk-ZAJPNVYS.js} +1 -1
  59. package/dist/ui/ui.css +1 -1
  60. package/dist/ui/ui.js +1 -1
  61. package/package.json +3 -3
  62. package/dist/ui/DocumentPage-OTBXM55S.js +0 -1
  63. package/dist/ui/EmbeddedDocumentPage-2CNQJTW5.js +0 -1
  64. package/dist/ui/SidebarToolsPage-3R7BQ2F7.js +0 -1
  65. package/dist/ui/TaskPage-GZGPKIL5.js +0 -1
  66. package/dist/ui/chunk-2FQMT5AB.js +0 -3
  67. package/dist/ui/chunk-GCSN3YEC.js +0 -31
  68. package/dist/ui/chunk-NXWYS4HG.js +0 -19
  69. package/dist/ui/chunk-RN4XVVWD.js +0 -1
  70. /package/dist/ui/{chunk-VPZHG7JL.js.LEGAL.txt → chunk-235TRWJF.js.LEGAL.txt} +0 -0
  71. /package/dist/ui/{chunk-7UHZS56B.js.LEGAL.txt → chunk-ST6QNIWT.js.LEGAL.txt} +0 -0
@@ -35,7 +35,7 @@ vulnerable to XSS attacks. Please remove it from \`allowedTags\`.
35
35
  Or, to disable this warning, add the \`allowVulnerableTags\` option
36
36
  and ensure you are accounting for this risk.
37
37
 
38
- `)});let o=e.nonTextTags||["script","style","textarea","option"],a,c;e.allowedAttributes&&(a={},c={},zt(e.allowedAttributes,function(h,w){a[w]=[];let m=[];h.forEach(function(_){typeof _=="string"&&_.indexOf("*")>=0?m.push(Ss(_).replace(/\\\*/g,".*")):a[w].push(_)}),m.length&&(c[w]=new RegExp("^("+m.join("|")+")$"))}));let l={},p={},f={};zt(e.allowedClasses,function(h,w){if(a&&(Ee(a,w)||(a[w]=[]),a[w].push("class")),l[w]=h,Array.isArray(h)){let m=[];l[w]=[],f[w]=[],h.forEach(function(_){typeof _=="string"&&_.indexOf("*")>=0?m.push(Ss(_).replace(/\\\*/g,".*")):_ instanceof RegExp?f[w].push(_):l[w].push(_)}),m.length&&(p[w]=new RegExp("^("+m.join("|")+")$"))}});let b={},E;zt(e.transformTags,function(h,w){let m;typeof h=="function"?m=h:typeof h=="string"&&(m=Ft.simpleTransform(h)),w==="*"?E=m:b[w]=m});let k,g,G,z,N,V,F=!1;xe();let fe=new cl.Parser({onopentag:function(h,w){if(e.enforceHtmlBoundary&&h==="html"&&xe(),N){V++;return}let m=new n(h,w);g.push(m);let _=!1,te=!!m.text,X;if(Ee(b,h)&&(X=b[h](h,w),m.attribs=w=X.attribs,X.text!==void 0&&(m.innerText=X.text),h!==X.tagName&&(m.name=h=X.tagName,z[k]=X.tagName)),E&&(X=E(h,w),m.attribs=w=X.attribs,h!==X.tagName&&(m.name=h=X.tagName,z[k]=X.tagName)),(!s(h)||e.disallowedTagsMode==="recursiveEscape"&&!gl(G)||e.nestingLimit!=null&&k>=e.nestingLimit)&&(_=!0,G[k]=!0,(e.disallowedTagsMode==="discard"||e.disallowedTagsMode==="completelyDiscard")&&o.indexOf(h)!==-1&&(N=!0,V=1),G[k]=!0),k++,_){if(e.disallowedTagsMode==="discard"||e.disallowedTagsMode==="completelyDiscard")return;i=u,u=""}u+="<"+h,h==="script"&&(e.allowedScriptHostnames||e.allowedScriptDomains)&&(m.innerText=""),(!a||Ee(a,h)||a["*"])&&zt(w,function(H,M){if(!xl.test(M)){delete m.attribs[M];return}if(H===""&&!e.allowedEmptyAttributes.includes(M)&&(e.nonBooleanAttributes.includes(M)||e.nonBooleanAttributes.includes("*"))){delete m.attribs[M];return}let Su=!1;if(!a||Ee(a,h)&&a[h].indexOf(M)!==-1||a["*"]&&a["*"].indexOf(M)!==-1||Ee(c,h)&&c[h].test(M)||c["*"]&&c["*"].test(M))Su=!0;else if(a&&a[h]){for(let D of a[h])if(fl(D)&&D.name&&D.name===M){Su=!0;let P="";if(D.multiple===!0){let He=H.split(" ");for(let ye of He)D.values.indexOf(ye)!==-1&&(P===""?P=ye:P+=" "+ye)}else D.values.indexOf(H)>=0&&(P=H);H=P}}if(Su){if(e.allowedSchemesAppliedToAttributes.indexOf(M)!==-1&&Z(h,H)){delete m.attribs[M];return}if(h==="script"&&M==="src"){let D=!0;try{let P=ne(H);if(e.allowedScriptHostnames||e.allowedScriptDomains){let He=(e.allowedScriptHostnames||[]).find(function(ae){return ae===P.url.hostname}),ye=(e.allowedScriptDomains||[]).find(function(ae){return P.url.hostname===ae||P.url.hostname.endsWith(`.${ae}`)});D=He||ye}}catch{D=!1}if(!D){delete m.attribs[M];return}}if(h==="iframe"&&M==="src"){let D=!0;try{let P=ne(H);if(P.isRelativeUrl)D=Ee(e,"allowIframeRelativeUrls")?e.allowIframeRelativeUrls:!e.allowedIframeHostnames&&!e.allowedIframeDomains;else if(e.allowedIframeHostnames||e.allowedIframeDomains){let He=(e.allowedIframeHostnames||[]).find(function(ae){return ae===P.url.hostname}),ye=(e.allowedIframeDomains||[]).find(function(ae){return P.url.hostname===ae||P.url.hostname.endsWith(`.${ae}`)});D=He||ye}}catch{D=!1}if(!D){delete m.attribs[M];return}}if(M==="srcset")try{let D=dl(H);if(D.forEach(function(P){Z("srcset",P.url)&&(P.evil=!0)}),D=ks(D,function(P){return!P.evil}),D.length)H=ml(ks(D,function(P){return!P.evil})),m.attribs[M]=H;else{delete m.attribs[M];return}}catch{delete m.attribs[M];return}if(M==="class"){let D=l[h],P=l["*"],He=p[h],ye=f[h],ae=f["*"],js=p["*"],_r=[He,js].concat(ye,ae).filter(function(Us){return Us});if(D&&P?H=Ar(H,Ts(D,P),_r):H=Ar(H,D||P,_r),!H.length){delete m.attribs[M];return}}if(M==="style"){if(e.parseStyleAttributes)try{let D=hl(h+" {"+H+"}",{map:!1}),P=se(D,e.allowedStyles);if(H=Ue(P),H.length===0){delete m.attribs[M];return}}catch{typeof window<"u"&&console.warn('Failed to parse "'+h+" {"+H+`}", If you're running this in a browser, we recommend to disable style parsing: options.parseStyleAttributes: false, since this only works in a node environment due to a postcss dependency, More info: https://github.com/apostrophecms/sanitize-html/issues/547`),delete m.attribs[M];return}else if(e.allowedStyles)throw new Error("allowedStyles option cannot be used together with parseStyleAttributes: false.")}u+=" "+M,H&&H.length?u+='="'+ee(H,!0)+'"':e.allowedEmptyAttributes.includes(M)&&(u+='=""')}else delete m.attribs[M]}),e.selfClosing.indexOf(h)!==-1?u+=" />":(u+=">",m.innerText&&!te&&!e.textFilter&&(u+=ee(m.innerText),F=!0)),_&&(u=i+ee(u),i="")},ontext:function(h){if(N)return;let w=g[g.length-1],m;if(w&&(m=w.tag,h=w.innerText!==void 0?w.innerText:h),e.disallowedTagsMode==="completelyDiscard"&&!s(m))h="";else if((e.disallowedTagsMode==="discard"||e.disallowedTagsMode==="completelyDiscard")&&(m==="script"||m==="style"))u+=h;else{let _=ee(h,!1);e.textFilter&&!F?u+=e.textFilter(_,m):F||(u+=_)}if(g.length){let _=g[g.length-1];_.text+=h}},onclosetag:function(h,w){if(N)if(V--,!V)N=!1;else return;let m=g.pop();if(!m)return;if(m.tag!==h){g.push(m);return}N=e.enforceHtmlBoundary?h==="html":!1,k--;let _=G[k];if(_){if(delete G[k],e.disallowedTagsMode==="discard"||e.disallowedTagsMode==="completelyDiscard"){m.updateParentNodeText();return}i=u,u=""}if(z[k]&&(h=z[k],delete z[k]),e.exclusiveFilter&&e.exclusiveFilter(m)){u=u.substr(0,m.tagPosition);return}if(m.updateParentNodeMediaChildren(),m.updateParentNodeText(),e.selfClosing.indexOf(h)!==-1||w&&!s(h)&&["escape","recursiveEscape"].indexOf(e.disallowedTagsMode)>=0){_&&(u=i,i="");return}u+="</"+h+">",_&&(u=i+ee(u),i=""),F=!1}},e.parser);return fe.write(r),fe.end(),u;function xe(){u="",k=0,g=[],G={},z={},N=!1,V=0}function ee(h,w){return typeof h!="string"&&(h=h+""),e.parser.decodeEntities&&(h=h.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),w&&(h=h.replace(/"/g,"&quot;"))),h=h.replace(/&(?![a-zA-Z0-9#]{1,20};)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),w&&(h=h.replace(/"/g,"&quot;")),h}function Z(h,w){for(w=w.replace(/[\x00-\x20]+/g,"");;){let te=w.indexOf("<!--");if(te===-1)break;let X=w.indexOf("-->",te+4);if(X===-1)break;w=w.substring(0,te)+w.substring(X+3)}let m=w.match(/^([a-zA-Z][a-zA-Z0-9.\-+]*):/);if(!m)return w.match(/^[/\\]{2}/)?!e.allowProtocolRelative:!1;let _=m[1].toLowerCase();return Ee(e.allowedSchemesByTag,h)?e.allowedSchemesByTag[h].indexOf(_)===-1:!e.allowedSchemes||e.allowedSchemes.indexOf(_)===-1}function ne(h){if(h=h.replace(/^(\w+:)?\s*[\\/]\s*[\\/]/,"$1//"),h.startsWith("relative:"))throw new Error("relative: exploit attempt");let w="relative://relative-site";for(let te=0;te<100;te++)w+=`/${te}`;let m=new URL(h,w);return{isRelativeUrl:m&&m.hostname==="relative-site"&&m.protocol==="relative:",url:m}}function se(h,w){if(!w)return h;let m=h.nodes[0],_;return w[m.selector]&&w["*"]?_=Ts(w[m.selector],w["*"]):_=w[m.selector]||w["*"],_&&(h.nodes[0].nodes=m.nodes.reduce(bt(_),[])),h}function Ue(h){return h.nodes[0].nodes.reduce(function(w,m){return w.push(`${m.prop}:${m.value}${m.important?" !important":""}`),w},[]).join(";")}function bt(h){return function(w,m){return Ee(h,m.prop)&&h[m.prop].some(function(te){return te.test(m.value)})&&w.push(m),w}}function Ar(h,w,m){return w?(h=h.split(/\s+/),h.filter(function(_){return w.indexOf(_)!==-1||m.some(function(te){return te.test(_)})}).join(" ")):h}}var yl={decodeEntities:!0};Ft.defaults={allowedTags:["address","article","aside","footer","header","h1","h2","h3","h4","h5","h6","hgroup","main","nav","section","blockquote","dd","div","dl","dt","figcaption","figure","hr","li","main","ol","p","pre","ul","a","abbr","b","bdi","bdo","br","cite","code","data","dfn","em","i","kbd","mark","q","rb","rp","rt","rtc","ruby","s","samp","small","span","strong","sub","sup","time","u","var","wbr","caption","col","colgroup","table","tbody","td","tfoot","th","thead","tr"],nonBooleanAttributes:["abbr","accept","accept-charset","accesskey","action","allow","alt","as","autocapitalize","autocomplete","blocking","charset","cite","class","color","cols","colspan","content","contenteditable","coords","crossorigin","data","datetime","decoding","dir","dirname","download","draggable","enctype","enterkeyhint","fetchpriority","for","form","formaction","formenctype","formmethod","formtarget","headers","height","hidden","high","href","hreflang","http-equiv","id","imagesizes","imagesrcset","inputmode","integrity","is","itemid","itemprop","itemref","itemtype","kind","label","lang","list","loading","low","max","maxlength","media","method","min","minlength","name","nonce","optimum","pattern","ping","placeholder","popover","popovertarget","popovertargetaction","poster","preload","referrerpolicy","rel","rows","rowspan","sandbox","scope","shape","size","sizes","slot","span","spellcheck","src","srcdoc","srclang","srcset","start","step","style","tabindex","target","title","translate","type","usemap","value","width","wrap","onauxclick","onafterprint","onbeforematch","onbeforeprint","onbeforeunload","onbeforetoggle","onblur","oncancel","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextlost","oncontextmenu","oncontextrestored","oncopy","oncuechange","oncut","ondblclick","ondrag","ondragend","ondragenter","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","onformdata","onhashchange","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onlanguagechange","onload","onloadeddata","onloadedmetadata","onloadstart","onmessage","onmessageerror","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onoffline","ononline","onpagehide","onpageshow","onpaste","onpause","onplay","onplaying","onpopstate","onprogress","onratechange","onreset","onresize","onrejectionhandled","onscroll","onscrollend","onsecuritypolicyviolation","onseeked","onseeking","onselect","onslotchange","onstalled","onstorage","onsubmit","onsuspend","ontimeupdate","ontoggle","onunhandledrejection","onunload","onvolumechange","onwaiting","onwheel"],disallowedTagsMode:"discard",allowedAttributes:{a:["href","name","target"],img:["src","srcset","alt","title","width","height","loading"]},allowedEmptyAttributes:["alt"],selfClosing:["img","br","hr","area","base","basefont","input","link","meta"],allowedSchemes:["http","https","ftp","mailto","tel"],allowedSchemesByTag:{},allowedSchemesAppliedToAttributes:["href","src","cite"],allowProtocolRelative:!0,enforceHtmlBoundary:!1,parseStyleAttributes:!0};Ft.simpleTransform=function(r,e,t){return t=t===void 0?!0:t,e=e||{},function(u,i){let n;if(t)for(n in e)i[n]=e[n];else i=e;return{tagName:r,attribs:i}}}});var Sr=Hs(As(),1),_s=["a","b","strong","i","em","u","s","del","code","span","br","sub","sup","mark","small"],wl=[..._s,"p","h1","h2","h3","h4","h5","h6","ul","ol","li","blockquote","pre","hr","table","thead","tbody","tfoot","tr","th","td","caption","figure","figcaption","img","div"],Os={a:["href","title","target","rel","id"],span:["class"],code:["class"],pre:["class"],th:["align","scope","colspan","rowspan"],td:["align","colspan","rowspan"],img:["src","alt","title","width","height"]},Is={allowedSchemes:["http","https","mailto"],allowedSchemesByTag:{img:["http","https","data"]},allowProtocolRelative:!1,transformTags:{a:(r,e)=>{let t={...e};return t.target==="_blank"&&(t.rel="noopener noreferrer"),{tagName:r,attribs:t}}}};function Ns(r){return r?(0,Sr.default)(r,{...Is,allowedTags:_s,allowedAttributes:Os}):""}function qs(r){return r?(0,Sr.default)(r,{...Is,allowedTags:wl,allowedAttributes:Os}):""}function Er(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Je=Er();function Rs(r){Je=r}var Ms=/[&<>"']/,vl=new RegExp(Ms.source,"g"),Bs=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Sl=new RegExp(Bs.source,"g"),Tl={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Cs=r=>Tl[r];function ie(r,e){if(e){if(Ms.test(r))return r.replace(vl,Cs)}else if(Bs.test(r))return r.replace(Sl,Cs);return r}var kl=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function El(r){return r.replace(kl,(e,t)=>(t=t.toLowerCase(),t==="colon"?":":t.charAt(0)==="#"?t.charAt(1)==="x"?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""))}var Al=/(^|[^\[])\^/g;function L(r,e){r=typeof r=="string"?r:r.source,e=e||"";let t={replace:(u,i)=>(i=typeof i=="object"&&"source"in i?i.source:i,i=i.replace(Al,"$1"),r=r.replace(u,i),t),getRegex:()=>new RegExp(r,e)};return t}function Ls(r){try{r=encodeURI(r).replace(/%25/g,"%")}catch{return null}return r}var vu={exec:()=>null};function Ds(r,e){let t=r.replace(/\|/g,(n,s,o)=>{let a=!1,c=s;for(;--c>=0&&o[c]==="\\";)a=!a;return a?"|":" |"}),u=t.split(/ \|/),i=0;if(u[0].trim()||u.shift(),u.length>0&&!u[u.length-1].trim()&&u.pop(),e)if(u.length>e)u.splice(e);else for(;u.length<e;)u.push("");for(;i<u.length;i++)u[i]=u[i].trim().replace(/\\\|/g,"|");return u}function Tr(r,e,t){let u=r.length;if(u===0)return"";let i=0;for(;i<u;){let n=r.charAt(u-i-1);if(n===e&&!t)i++;else if(n!==e&&t)i++;else break}return r.slice(0,u-i)}function _l(r,e){if(r.indexOf(e[1])===-1)return-1;let t=0;for(let u=0;u<r.length;u++)if(r[u]==="\\")u++;else if(r[u]===e[0])t++;else if(r[u]===e[1]&&(t--,t<0))return u;return-1}function Ps(r,e,t,u){let i=e.href,n=e.title?ie(e.title):null,s=r[1].replace(/\\([\[\]])/g,"$1");if(r[0].charAt(0)!=="!"){u.state.inLink=!0;let o={type:"link",raw:t,href:i,title:n,text:s,tokens:u.inlineTokens(s)};return u.state.inLink=!1,o}return{type:"image",raw:t,href:i,title:n,text:ie(s)}}function Ol(r,e){let t=r.match(/^(\s+)(?:```)/);if(t===null)return e;let u=t[1];return e.split(`
38
+ `)});let o=e.nonTextTags||["script","style","textarea","option"],a,c;e.allowedAttributes&&(a={},c={},zt(e.allowedAttributes,function(h,w){a[w]=[];let m=[];h.forEach(function(_){typeof _=="string"&&_.indexOf("*")>=0?m.push(Ss(_).replace(/\\\*/g,".*")):a[w].push(_)}),m.length&&(c[w]=new RegExp("^("+m.join("|")+")$"))}));let l={},p={},f={};zt(e.allowedClasses,function(h,w){if(a&&(Ee(a,w)||(a[w]=[]),a[w].push("class")),l[w]=h,Array.isArray(h)){let m=[];l[w]=[],f[w]=[],h.forEach(function(_){typeof _=="string"&&_.indexOf("*")>=0?m.push(Ss(_).replace(/\\\*/g,".*")):_ instanceof RegExp?f[w].push(_):l[w].push(_)}),m.length&&(p[w]=new RegExp("^("+m.join("|")+")$"))}});let b={},E;zt(e.transformTags,function(h,w){let m;typeof h=="function"?m=h:typeof h=="string"&&(m=Ft.simpleTransform(h)),w==="*"?E=m:b[w]=m});let k,g,G,z,N,V,F=!1;xe();let fe=new cl.Parser({onopentag:function(h,w){if(e.enforceHtmlBoundary&&h==="html"&&xe(),N){V++;return}let m=new n(h,w);g.push(m);let _=!1,te=!!m.text,X;if(Ee(b,h)&&(X=b[h](h,w),m.attribs=w=X.attribs,X.text!==void 0&&(m.innerText=X.text),h!==X.tagName&&(m.name=h=X.tagName,z[k]=X.tagName)),E&&(X=E(h,w),m.attribs=w=X.attribs,h!==X.tagName&&(m.name=h=X.tagName,z[k]=X.tagName)),(!s(h)||e.disallowedTagsMode==="recursiveEscape"&&!gl(G)||e.nestingLimit!=null&&k>=e.nestingLimit)&&(_=!0,G[k]=!0,(e.disallowedTagsMode==="discard"||e.disallowedTagsMode==="completelyDiscard")&&o.indexOf(h)!==-1&&(N=!0,V=1),G[k]=!0),k++,_){if(e.disallowedTagsMode==="discard"||e.disallowedTagsMode==="completelyDiscard")return;i=u,u=""}u+="<"+h,h==="script"&&(e.allowedScriptHostnames||e.allowedScriptDomains)&&(m.innerText=""),(!a||Ee(a,h)||a["*"])&&zt(w,function(H,M){if(!xl.test(M)){delete m.attribs[M];return}if(H===""&&!e.allowedEmptyAttributes.includes(M)&&(e.nonBooleanAttributes.includes(M)||e.nonBooleanAttributes.includes("*"))){delete m.attribs[M];return}let Su=!1;if(!a||Ee(a,h)&&a[h].indexOf(M)!==-1||a["*"]&&a["*"].indexOf(M)!==-1||Ee(c,h)&&c[h].test(M)||c["*"]&&c["*"].test(M))Su=!0;else if(a&&a[h]){for(let D of a[h])if(fl(D)&&D.name&&D.name===M){Su=!0;let P="";if(D.multiple===!0){let He=H.split(" ");for(let ye of He)D.values.indexOf(ye)!==-1&&(P===""?P=ye:P+=" "+ye)}else D.values.indexOf(H)>=0&&(P=H);H=P}}if(Su){if(e.allowedSchemesAppliedToAttributes.indexOf(M)!==-1&&Z(h,H)){delete m.attribs[M];return}if(h==="script"&&M==="src"){let D=!0;try{let P=ne(H);if(e.allowedScriptHostnames||e.allowedScriptDomains){let He=(e.allowedScriptHostnames||[]).find(function(ae){return ae===P.url.hostname}),ye=(e.allowedScriptDomains||[]).find(function(ae){return P.url.hostname===ae||P.url.hostname.endsWith(`.${ae}`)});D=He||ye}}catch{D=!1}if(!D){delete m.attribs[M];return}}if(h==="iframe"&&M==="src"){let D=!0;try{let P=ne(H);if(P.isRelativeUrl)D=Ee(e,"allowIframeRelativeUrls")?e.allowIframeRelativeUrls:!e.allowedIframeHostnames&&!e.allowedIframeDomains;else if(e.allowedIframeHostnames||e.allowedIframeDomains){let He=(e.allowedIframeHostnames||[]).find(function(ae){return ae===P.url.hostname}),ye=(e.allowedIframeDomains||[]).find(function(ae){return P.url.hostname===ae||P.url.hostname.endsWith(`.${ae}`)});D=He||ye}}catch{D=!1}if(!D){delete m.attribs[M];return}}if(M==="srcset")try{let D=dl(H);if(D.forEach(function(P){Z("srcset",P.url)&&(P.evil=!0)}),D=ks(D,function(P){return!P.evil}),D.length)H=ml(ks(D,function(P){return!P.evil})),m.attribs[M]=H;else{delete m.attribs[M];return}}catch{delete m.attribs[M];return}if(M==="class"){let D=l[h],P=l["*"],He=p[h],ye=f[h],ae=f["*"],js=p["*"],_r=[He,js].concat(ye,ae).filter(function(Us){return Us});if(D&&P?H=Ar(H,Ts(D,P),_r):H=Ar(H,D||P,_r),!H.length){delete m.attribs[M];return}}if(M==="style"){if(e.parseStyleAttributes)try{let D=hl(h+" {"+H+"}",{map:!1}),P=se(D,e.allowedStyles);if(H=Ue(P),H.length===0){delete m.attribs[M];return}}catch{typeof window<"u"&&console.warn('Failed to parse "'+h+" {"+H+`}", If you're running this in a browser, we recommend to disable style parsing: options.parseStyleAttributes: false, since this only works in a node environment due to a postcss dependency, More info: https://github.com/apostrophecms/sanitize-html/issues/547`),delete m.attribs[M];return}else if(e.allowedStyles)throw new Error("allowedStyles option cannot be used together with parseStyleAttributes: false.")}u+=" "+M,H&&H.length?u+='="'+ee(H,!0)+'"':e.allowedEmptyAttributes.includes(M)&&(u+='=""')}else delete m.attribs[M]}),e.selfClosing.indexOf(h)!==-1?u+=" />":(u+=">",m.innerText&&!te&&!e.textFilter&&(u+=ee(m.innerText),F=!0)),_&&(u=i+ee(u),i="")},ontext:function(h){if(N)return;let w=g[g.length-1],m;if(w&&(m=w.tag,h=w.innerText!==void 0?w.innerText:h),e.disallowedTagsMode==="completelyDiscard"&&!s(m))h="";else if((e.disallowedTagsMode==="discard"||e.disallowedTagsMode==="completelyDiscard")&&(m==="script"||m==="style"))u+=h;else{let _=ee(h,!1);e.textFilter&&!F?u+=e.textFilter(_,m):F||(u+=_)}if(g.length){let _=g[g.length-1];_.text+=h}},onclosetag:function(h,w){if(N)if(V--,!V)N=!1;else return;let m=g.pop();if(!m)return;if(m.tag!==h){g.push(m);return}N=e.enforceHtmlBoundary?h==="html":!1,k--;let _=G[k];if(_){if(delete G[k],e.disallowedTagsMode==="discard"||e.disallowedTagsMode==="completelyDiscard"){m.updateParentNodeText();return}i=u,u=""}if(z[k]&&(h=z[k],delete z[k]),e.exclusiveFilter&&e.exclusiveFilter(m)){u=u.substr(0,m.tagPosition);return}if(m.updateParentNodeMediaChildren(),m.updateParentNodeText(),e.selfClosing.indexOf(h)!==-1||w&&!s(h)&&["escape","recursiveEscape"].indexOf(e.disallowedTagsMode)>=0){_&&(u=i,i="");return}u+="</"+h+">",_&&(u=i+ee(u),i=""),F=!1}},e.parser);return fe.write(r),fe.end(),u;function xe(){u="",k=0,g=[],G={},z={},N=!1,V=0}function ee(h,w){return typeof h!="string"&&(h=h+""),e.parser.decodeEntities&&(h=h.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),w&&(h=h.replace(/"/g,"&quot;"))),h=h.replace(/&(?![a-zA-Z0-9#]{1,20};)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),w&&(h=h.replace(/"/g,"&quot;")),h}function Z(h,w){for(w=w.replace(/[\x00-\x20]+/g,"");;){let te=w.indexOf("<!--");if(te===-1)break;let X=w.indexOf("-->",te+4);if(X===-1)break;w=w.substring(0,te)+w.substring(X+3)}let m=w.match(/^([a-zA-Z][a-zA-Z0-9.\-+]*):/);if(!m)return w.match(/^[/\\]{2}/)?!e.allowProtocolRelative:!1;let _=m[1].toLowerCase();return Ee(e.allowedSchemesByTag,h)?e.allowedSchemesByTag[h].indexOf(_)===-1:!e.allowedSchemes||e.allowedSchemes.indexOf(_)===-1}function ne(h){if(h=h.replace(/^(\w+:)?\s*[\\/]\s*[\\/]/,"$1//"),h.startsWith("relative:"))throw new Error("relative: exploit attempt");let w="relative://relative-site";for(let te=0;te<100;te++)w+=`/${te}`;let m=new URL(h,w);return{isRelativeUrl:m&&m.hostname==="relative-site"&&m.protocol==="relative:",url:m}}function se(h,w){if(!w)return h;let m=h.nodes[0],_;return w[m.selector]&&w["*"]?_=Ts(w[m.selector],w["*"]):_=w[m.selector]||w["*"],_&&(h.nodes[0].nodes=m.nodes.reduce(bt(_),[])),h}function Ue(h){return h.nodes[0].nodes.reduce(function(w,m){return w.push(`${m.prop}:${m.value}${m.important?" !important":""}`),w},[]).join(";")}function bt(h){return function(w,m){return Ee(h,m.prop)&&h[m.prop].some(function(te){return te.test(m.value)})&&w.push(m),w}}function Ar(h,w,m){return w?(h=h.split(/\s+/),h.filter(function(_){return w.indexOf(_)!==-1||m.some(function(te){return te.test(_)})}).join(" ")):h}}var yl={decodeEntities:!0};Ft.defaults={allowedTags:["address","article","aside","footer","header","h1","h2","h3","h4","h5","h6","hgroup","main","nav","section","blockquote","dd","div","dl","dt","figcaption","figure","hr","li","main","ol","p","pre","ul","a","abbr","b","bdi","bdo","br","cite","code","data","dfn","em","i","kbd","mark","q","rb","rp","rt","rtc","ruby","s","samp","small","span","strong","sub","sup","time","u","var","wbr","caption","col","colgroup","table","tbody","td","tfoot","th","thead","tr"],nonBooleanAttributes:["abbr","accept","accept-charset","accesskey","action","allow","alt","as","autocapitalize","autocomplete","blocking","charset","cite","class","color","cols","colspan","content","contenteditable","coords","crossorigin","data","datetime","decoding","dir","dirname","download","draggable","enctype","enterkeyhint","fetchpriority","for","form","formaction","formenctype","formmethod","formtarget","headers","height","hidden","high","href","hreflang","http-equiv","id","imagesizes","imagesrcset","inputmode","integrity","is","itemid","itemprop","itemref","itemtype","kind","label","lang","list","loading","low","max","maxlength","media","method","min","minlength","name","nonce","optimum","pattern","ping","placeholder","popover","popovertarget","popovertargetaction","poster","preload","referrerpolicy","rel","rows","rowspan","sandbox","scope","shape","size","sizes","slot","span","spellcheck","src","srcdoc","srclang","srcset","start","step","style","tabindex","target","title","translate","type","usemap","value","width","wrap","onauxclick","onafterprint","onbeforematch","onbeforeprint","onbeforeunload","onbeforetoggle","onblur","oncancel","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextlost","oncontextmenu","oncontextrestored","oncopy","oncuechange","oncut","ondblclick","ondrag","ondragend","ondragenter","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","onformdata","onhashchange","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onlanguagechange","onload","onloadeddata","onloadedmetadata","onloadstart","onmessage","onmessageerror","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onoffline","ononline","onpagehide","onpageshow","onpaste","onpause","onplay","onplaying","onpopstate","onprogress","onratechange","onreset","onresize","onrejectionhandled","onscroll","onscrollend","onsecuritypolicyviolation","onseeked","onseeking","onselect","onslotchange","onstalled","onstorage","onsubmit","onsuspend","ontimeupdate","ontoggle","onunhandledrejection","onunload","onvolumechange","onwaiting","onwheel"],disallowedTagsMode:"discard",allowedAttributes:{a:["href","name","target"],img:["src","srcset","alt","title","width","height","loading"]},allowedEmptyAttributes:["alt"],selfClosing:["img","br","hr","area","base","basefont","input","link","meta"],allowedSchemes:["http","https","ftp","mailto","tel"],allowedSchemesByTag:{},allowedSchemesAppliedToAttributes:["href","src","cite"],allowProtocolRelative:!0,enforceHtmlBoundary:!1,parseStyleAttributes:!0};Ft.simpleTransform=function(r,e,t){return t=t===void 0?!0:t,e=e||{},function(u,i){let n;if(t)for(n in e)i[n]=e[n];else i=e;return{tagName:r,attribs:i}}}});var Sr=Hs(As(),1),_s=["a","b","strong","i","em","u","s","del","code","span","br","sub","sup","mark","small"],wl=[..._s,"p","h1","h2","h3","h4","h5","h6","ul","ol","li","blockquote","pre","hr","table","thead","tbody","tfoot","tr","th","td","caption","figure","figcaption","img","div"],Os={a:["href","title","target","rel","id"],span:["class"],code:["class"],pre:["class"],th:["align","scope","colspan","rowspan"],td:["align","colspan","rowspan"],img:["src","alt","title","width","height"]},Is={allowedSchemes:["http","https","mailto","tel","sms"],allowedSchemesByTag:{img:["http","https","data"]},allowProtocolRelative:!1,transformTags:{a:(r,e)=>{let t={...e};return t.target==="_blank"&&(t.rel="noopener noreferrer"),{tagName:r,attribs:t}}}};function Ns(r){return r?(0,Sr.default)(r,{...Is,allowedTags:_s,allowedAttributes:Os}):""}function qs(r){return r?(0,Sr.default)(r,{...Is,allowedTags:wl,allowedAttributes:Os}):""}function Er(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Je=Er();function Rs(r){Je=r}var Ms=/[&<>"']/,vl=new RegExp(Ms.source,"g"),Bs=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Sl=new RegExp(Bs.source,"g"),Tl={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Cs=r=>Tl[r];function ie(r,e){if(e){if(Ms.test(r))return r.replace(vl,Cs)}else if(Bs.test(r))return r.replace(Sl,Cs);return r}var kl=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function El(r){return r.replace(kl,(e,t)=>(t=t.toLowerCase(),t==="colon"?":":t.charAt(0)==="#"?t.charAt(1)==="x"?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""))}var Al=/(^|[^\[])\^/g;function L(r,e){r=typeof r=="string"?r:r.source,e=e||"";let t={replace:(u,i)=>(i=typeof i=="object"&&"source"in i?i.source:i,i=i.replace(Al,"$1"),r=r.replace(u,i),t),getRegex:()=>new RegExp(r,e)};return t}function Ls(r){try{r=encodeURI(r).replace(/%25/g,"%")}catch{return null}return r}var vu={exec:()=>null};function Ds(r,e){let t=r.replace(/\|/g,(n,s,o)=>{let a=!1,c=s;for(;--c>=0&&o[c]==="\\";)a=!a;return a?"|":" |"}),u=t.split(/ \|/),i=0;if(u[0].trim()||u.shift(),u.length>0&&!u[u.length-1].trim()&&u.pop(),e)if(u.length>e)u.splice(e);else for(;u.length<e;)u.push("");for(;i<u.length;i++)u[i]=u[i].trim().replace(/\\\|/g,"|");return u}function Tr(r,e,t){let u=r.length;if(u===0)return"";let i=0;for(;i<u;){let n=r.charAt(u-i-1);if(n===e&&!t)i++;else if(n!==e&&t)i++;else break}return r.slice(0,u-i)}function _l(r,e){if(r.indexOf(e[1])===-1)return-1;let t=0;for(let u=0;u<r.length;u++)if(r[u]==="\\")u++;else if(r[u]===e[0])t++;else if(r[u]===e[1]&&(t--,t<0))return u;return-1}function Ps(r,e,t,u){let i=e.href,n=e.title?ie(e.title):null,s=r[1].replace(/\\([\[\]])/g,"$1");if(r[0].charAt(0)!=="!"){u.state.inLink=!0;let o={type:"link",raw:t,href:i,title:n,text:s,tokens:u.inlineTokens(s)};return u.state.inLink=!1,o}return{type:"image",raw:t,href:i,title:n,text:ie(s)}}function Ol(r,e){let t=r.match(/^(\s+)(?:```)/);if(t===null)return e;let u=t[1];return e.split(`
39
39
  `).map(i=>{let n=i.match(/^\s+/);if(n===null)return i;let[s]=n;return s.length>=u.length?i.slice(u.length):i}).join(`
40
40
  `)}var ht=class{options;rules;lexer;constructor(e){this.options=e||Je}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let u=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?u:Tr(u,`
41
41
  `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let u=t[0],i=Ol(u,t[3]||"");return{type:"code",raw:u,lang:t[2]?t[2].trim().replace(this.rules.inline._escapes,"$1"):t[2],text:i}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let u=t[2].trim();if(/#$/.test(u)){let i=Tr(u,"#");(this.options.pedantic||!i||/ $/.test(i))&&(u=i.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:u,tokens:this.lexer.inline(u)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let u=t[0].replace(/^ *>[ \t]?/gm,""),i=this.lexer.state.top;this.lexer.state.top=!0;let n=this.lexer.blockTokens(u);return this.lexer.state.top=i,{type:"blockquote",raw:t[0],tokens:n,text:u}}}list(e){let t=this.rules.block.list.exec(e);if(t){let u=t[1].trim(),i=u.length>1,n={type:"list",raw:"",ordered:i,start:i?+u.slice(0,-1):"",loose:!1,items:[]};u=i?`\\d{1,9}\\${u.slice(-1)}`:`\\${u}`,this.options.pedantic&&(u=i?u:"[*+-]");let s=new RegExp(`^( {0,3}${u})((?:[ ][^\\n]*)?(?:\\n|$))`),o="",a="",c=!1;for(;e;){let l=!1;if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;o=t[0],e=e.substring(o.length);let p=t[2].split(`
@@ -1 +1 @@
1
- import{a as G}from"./chunk-WC7KMPEQ.js";import{a as Y}from"./chunk-F7RQT4XN.js";import{a as J}from"./chunk-DWV5J2W7.js";import{g as W}from"./chunk-TNW2GNUR.js";import{b as O,d as U,e as V,j as $}from"./chunk-FVWSVOOY.js";import{a as A}from"./chunk-JDW4UORS.js";import{a as K}from"./chunk-UJX25CXD.js";import{c as L}from"./chunk-RN4XVVWD.js";import{a as q}from"./chunk-W5DOO6ID.js";import{a as j}from"./chunk-YBHFGQ3Z.js";import{b as B}from"./chunk-2PTLQRTU.js";import{a as S}from"./chunk-PIJ3E47R.js";import{d as M}from"./chunk-WASID5UU.js";import{$ as C,Fa as N,Ga as e,Qa as H,Vc as y,W as x,a as d,c as w,da as I,e as z,j as le,na as k,pa as E,ua as T}from"./chunk-WRA24P66.js";le();function F(o){let{route:c}=M(),f=z(null),[l,i]=d(!1),[v,u]=d(""),[p,_]=d(!!o.releaseId),[Q,P]=d(null),[R,b]=d([]),[g,h]=d([]),X=J(),Z=G(),{roles:ee}=j(),oe=window.firebase.user.email||"",m=q(ee,oe);async function ae(r){console.log(r),await B(async()=>{let t=await U(r);P(t),b(t?.docIds||[]),h(t?.dataSourceIds||[])}),_(!1)}w(()=>{o.releaseId&&(_(!0),ae(o.releaseId))},[o.releaseId]);async function se(){u("");let r=f.current;function t(n){let D=r.elements[n];return D?D.value.trim():""}let a=o.releaseId||t("id");if(!a){u("missing id");return}if(!A(a)){u("id is invalid (alphanumeric characters and dashes only)");return}let s={id:a,description:t("description"),docIds:R,dataSourceIds:g};try{P(s),i(!0),o.releaseId?(await V(o.releaseId,s),S({title:"Saved release",message:`Updated ${a}`,autoClose:5e3}),i(!1)):(await O(a,s),S({title:"Added release",message:`Successfully added ${a}`,autoClose:5e3}),i(!1)),c(`/cms/releases/${a}`)}catch(n){console.error(n),S({title:"Failed to save release",message:String(n),color:"red",autoClose:!1}),i(!1)}}function re(){X.open({multiSelect:!0,selectedDocIds:R,onChangeMulti:(r,t)=>{b(a=>{let s=[...a];if(t)s.push(r);else{let n=s.findIndex(D=>D===r);n>-1&&s.splice(n,1)}return console.log(s),s.sort()})}})}function te(){Z.open({selectedDataSourceIds:g,onChange:(r,t)=>{h(a=>{let s=[...a];if(t)s.push(r);else{let n=s.indexOf(r);n>-1&&s.splice(n,1)}return s.sort()})}})}function ie(r){console.log("onRemoveDoc()",r),b(t=>{let a=[...t],s=a.indexOf(r);return s!==-1&&a.splice(s,1),console.log(a),a})}function ne(r){h(t=>{let a=[...t],s=a.indexOf(r);return s!==-1&&a.splice(s,1),a})}return e("form",{className:"ReleaseForm",ref:f,onSubmit:r=>{r.preventDefault(),se()},children:[e(E,{visible:p}),e(T,{className:"ReleaseForm__input",name:"id",label:"ID",description:"Unique identifier for the release. Use alphanumeric characters and dashes only, e.g. grogus-favorite-meals",size:"xs",radius:0,defaultValue:o.releaseId||$(),disabled:!!o.releaseId}),e(k,{className:"ReleaseForm__input",name:"description",label:"Description",description:"Optional.",size:"xs",radius:0,value:Q?.description,disabled:!m}),e(C,{className:"ReleaseForm__input",label:"Docs",description:"Select one or more docs to add to the release. Note: you can add or edit this list at a later time, if needed.",size:"xs",children:[R.length>0&&e(F.DocPreviewCards,{docIds:R,onRemoveDoc:ie,canEdit:m}),e(I,{className:"ReleaseForm__docSelectButton",color:"dark",size:"xs",onClick:()=>re(),disabled:!m,children:"Select"})]}),e(C,{className:"ReleaseForm__input",label:"Data Sources",description:"Optional. Data sources to publish with the release.",size:"xs",children:[g.length>0&&e(F.DataSourceIds,{ids:g,onRemove:ne,canEdit:m}),e(I,{className:"ReleaseForm__docSelectButton",color:"dark",size:"xs",onClick:()=>te(),disabled:!m,children:"Select"})]}),e("div",{className:"ReleaseForm__submit__buttons",children:e(K,{label:"You don't have access to create or edit releases",condition:!m,children:e("span",{children:e(I,{className:"ReleaseForm__submit",color:"blue",size:"xs",type:"submit",loading:l,disabled:!m,children:o.buttonLabel||"Save"})})})}),v&&e("div",{className:"ReleaseForm__error",children:["Error: ",v]})]})}F.DocPreviewCards=o=>e("div",{className:"ReleaseForm__DocPreviewCards",children:o.docIds.map(c=>e("div",{className:"ReleaseForm__DocPreviewCards__card",children:[e(W,{className:"ReleaseForm__DocPreviewCards__card__preview",docId:c}),e("div",{className:"ReleaseForm__DocPreviewCards__card__controls",children:[o.canEdit&&e("div",{className:"ReleaseForm__DocPreviewCards__card__controls__remove",children:e(N,{label:"Remove",children:e(x,{className:"ReleaseForm__DocPreviewCards__card__controls__remove__icon",onClick:()=>o.onRemoveDoc(c),children:e(y,{size:16})})})}),e("div",{className:"ReleaseForm__DocPreviewCards__card__controls__open",children:e(N,{label:"Open",children:e(x,{component:"a",className:"ReleaseForm__DocPreviewCards__card__controls__open__icon",href:`/cms/content/${c}`,target:"_blank",children:e(H,{size:16})})})})]})]},c))});F.DataSourceIds=o=>{let[c,f]=d({});return w(()=>{let l=!1;async function i(){let v=await Promise.all(o.ids.map(async p=>{let _=await L(p);return[p,_]}));if(l)return;let u={};for(let[p,_]of v)_&&(u[p]=_);f(u)}return i(),()=>{l=!0}},[o.ids.join(",")]),e("div",{className:"ReleaseForm__DataSourceIds",children:o.ids.map(l=>{let i=c[l];return e("div",{className:"ReleaseForm__DataSourceIds__item",children:[e(Y,{className:"ReleaseForm__DataSourceIds__item__icon",type:i?.type}),e("div",{className:"ReleaseForm__DataSourceIds__item__info",children:[e("div",{className:"ReleaseForm__DataSourceIds__item__id",children:l}),i?.description&&e("div",{className:"ReleaseForm__DataSourceIds__item__description",children:i.description})]}),o.canEdit&&e(x,{className:"ReleaseForm__DataSourceIds__item__remove",onClick:()=>o.onRemove(l),children:e(y,{size:16})})]},l)})})};export{F as a};
1
+ import{a as G}from"./chunk-C5FRMXDS.js";import{a as Y}from"./chunk-F7RQT4XN.js";import{a as J}from"./chunk-U7LSFUHT.js";import{g as W}from"./chunk-G5647K25.js";import{b as O,d as U,e as V,j as $}from"./chunk-VJRMR2JM.js";import{a as A}from"./chunk-JDW4UORS.js";import{a as K}from"./chunk-UJX25CXD.js";import{c as L}from"./chunk-Z2CRNO3I.js";import{a as q}from"./chunk-W5DOO6ID.js";import{a as j}from"./chunk-YBHFGQ3Z.js";import{b as B}from"./chunk-2PTLQRTU.js";import{a as S}from"./chunk-PIJ3E47R.js";import{d as M}from"./chunk-WASID5UU.js";import{$ as C,Fa as N,Ga as e,Qa as H,Vc as y,W as x,a as d,c as w,da as I,e as z,j as le,na as k,pa as E,ua as T}from"./chunk-WRA24P66.js";le();function F(o){let{route:c}=M(),f=z(null),[l,i]=d(!1),[v,u]=d(""),[p,_]=d(!!o.releaseId),[Q,P]=d(null),[R,b]=d([]),[g,h]=d([]),X=J(),Z=G(),{roles:ee}=j(),oe=window.firebase.user.email||"",m=q(ee,oe);async function ae(r){console.log(r),await B(async()=>{let t=await U(r);P(t),b(t?.docIds||[]),h(t?.dataSourceIds||[])}),_(!1)}w(()=>{o.releaseId&&(_(!0),ae(o.releaseId))},[o.releaseId]);async function se(){u("");let r=f.current;function t(n){let D=r.elements[n];return D?D.value.trim():""}let a=o.releaseId||t("id");if(!a){u("missing id");return}if(!A(a)){u("id is invalid (alphanumeric characters and dashes only)");return}let s={id:a,description:t("description"),docIds:R,dataSourceIds:g};try{P(s),i(!0),o.releaseId?(await V(o.releaseId,s),S({title:"Saved release",message:`Updated ${a}`,autoClose:5e3}),i(!1)):(await O(a,s),S({title:"Added release",message:`Successfully added ${a}`,autoClose:5e3}),i(!1)),c(`/cms/releases/${a}`)}catch(n){console.error(n),S({title:"Failed to save release",message:String(n),color:"red",autoClose:!1}),i(!1)}}function re(){X.open({multiSelect:!0,selectedDocIds:R,onChangeMulti:(r,t)=>{b(a=>{let s=[...a];if(t)s.push(r);else{let n=s.findIndex(D=>D===r);n>-1&&s.splice(n,1)}return console.log(s),s.sort()})}})}function te(){Z.open({selectedDataSourceIds:g,onChange:(r,t)=>{h(a=>{let s=[...a];if(t)s.push(r);else{let n=s.indexOf(r);n>-1&&s.splice(n,1)}return s.sort()})}})}function ie(r){console.log("onRemoveDoc()",r),b(t=>{let a=[...t],s=a.indexOf(r);return s!==-1&&a.splice(s,1),console.log(a),a})}function ne(r){h(t=>{let a=[...t],s=a.indexOf(r);return s!==-1&&a.splice(s,1),a})}return e("form",{className:"ReleaseForm",ref:f,onSubmit:r=>{r.preventDefault(),se()},children:[e(E,{visible:p}),e(T,{className:"ReleaseForm__input",name:"id",label:"ID",description:"Unique identifier for the release. Use alphanumeric characters and dashes only, e.g. grogus-favorite-meals",size:"xs",radius:0,defaultValue:o.releaseId||$(),disabled:!!o.releaseId}),e(k,{className:"ReleaseForm__input",name:"description",label:"Description",description:"Optional.",size:"xs",radius:0,value:Q?.description,disabled:!m}),e(C,{className:"ReleaseForm__input",label:"Docs",description:"Select one or more docs to add to the release. Note: you can add or edit this list at a later time, if needed.",size:"xs",children:[R.length>0&&e(F.DocPreviewCards,{docIds:R,onRemoveDoc:ie,canEdit:m}),e(I,{className:"ReleaseForm__docSelectButton",color:"dark",size:"xs",onClick:()=>re(),disabled:!m,children:"Select"})]}),e(C,{className:"ReleaseForm__input",label:"Data Sources",description:"Optional. Data sources to publish with the release.",size:"xs",children:[g.length>0&&e(F.DataSourceIds,{ids:g,onRemove:ne,canEdit:m}),e(I,{className:"ReleaseForm__docSelectButton",color:"dark",size:"xs",onClick:()=>te(),disabled:!m,children:"Select"})]}),e("div",{className:"ReleaseForm__submit__buttons",children:e(K,{label:"You don't have access to create or edit releases",condition:!m,children:e("span",{children:e(I,{className:"ReleaseForm__submit",color:"blue",size:"xs",type:"submit",loading:l,disabled:!m,children:o.buttonLabel||"Save"})})})}),v&&e("div",{className:"ReleaseForm__error",children:["Error: ",v]})]})}F.DocPreviewCards=o=>e("div",{className:"ReleaseForm__DocPreviewCards",children:o.docIds.map(c=>e("div",{className:"ReleaseForm__DocPreviewCards__card",children:[e(W,{className:"ReleaseForm__DocPreviewCards__card__preview",docId:c}),e("div",{className:"ReleaseForm__DocPreviewCards__card__controls",children:[o.canEdit&&e("div",{className:"ReleaseForm__DocPreviewCards__card__controls__remove",children:e(N,{label:"Remove",children:e(x,{className:"ReleaseForm__DocPreviewCards__card__controls__remove__icon",onClick:()=>o.onRemoveDoc(c),children:e(y,{size:16})})})}),e("div",{className:"ReleaseForm__DocPreviewCards__card__controls__open",children:e(N,{label:"Open",children:e(x,{component:"a",className:"ReleaseForm__DocPreviewCards__card__controls__open__icon",href:`/cms/content/${c}`,target:"_blank",children:e(H,{size:16})})})})]})]},c))});F.DataSourceIds=o=>{let[c,f]=d({});return w(()=>{let l=!1;async function i(){let v=await Promise.all(o.ids.map(async p=>{let _=await L(p);return[p,_]}));if(l)return;let u={};for(let[p,_]of v)_&&(u[p]=_);f(u)}return i(),()=>{l=!0}},[o.ids.join(",")]),e("div",{className:"ReleaseForm__DataSourceIds",children:o.ids.map(l=>{let i=c[l];return e("div",{className:"ReleaseForm__DataSourceIds__item",children:[e(Y,{className:"ReleaseForm__DataSourceIds__item__icon",type:i?.type}),e("div",{className:"ReleaseForm__DataSourceIds__item__info",children:[e("div",{className:"ReleaseForm__DataSourceIds__item__id",children:l}),i?.description&&e("div",{className:"ReleaseForm__DataSourceIds__item__description",children:i.description})]}),o.canEdit&&e(x,{className:"ReleaseForm__DataSourceIds__item__remove",onClick:()=>o.onRemove(l),children:e(y,{size:16})})]},l)})})};export{F as a};
@@ -0,0 +1,19 @@
1
+ import{a as Te,b as Se,c as Pe,d as ke,e as je,f as ze,g as De,h as Ue,i as Oe,j as We,k as Be,l as Le,m as $e,n as He,o as Fe,p as ae,q as Ke,r as Ve}from"./chunk-LAXQZPE3.js";import{a as we}from"./chunk-QWB6MAPJ.js";import{a as Ee,c as ne}from"./chunk-235TRWJF.js";import{P as Me,T as Ne}from"./chunk-AAR7DBEN.js";import{f as q}from"./chunk-5MV6XVGA.js";import{b as me,c as pe,g as fe,h as _e,j as he,n as X,o as ge,p as Ce,r as ve,v as Y}from"./chunk-XOWWPE7X.js";import{d as Ae,e as T}from"./chunk-WASID5UU.js";import{$a as Q,Bc as z,Fa as H,Ga as e,Hc as xe,V as J,Vc as be,W as E,a as _,ab as Z,ad as B,ba as G,bb as ee,c as M,da as j,e as y,g as ue,h as N,j as at,kc as te,pb as ye,pc as oe,qa as W,qc as Re}from"./chunk-WRA24P66.js";import{d as de}from"./chunk-KUCVLANF.js";import{h as Ie}from"./chunk-7SK47HHZ.js";at();var it=500;function Je(){return window.firebase.db}function Ge(){return window.__ROOT_CTX.rootConfig.projectId}function ie(){return window.firebase.user?.email||""}function st(){return me(Je(),"Projects",Ge(),"AiChats")}function se(t){return pe(Je(),"Projects",Ge(),"AiChats",t)}function D(t){return t&&typeof t.toMillis=="function"?t.toMillis():typeof t=="number"?t:0}async function Xe(t){let o=ie();if(!o)return[];let n=t?.limit,a=typeof n=="number"&&Number.isFinite(n)&&n>0?Math.min(Math.floor(n),100):50,u=fe(st(),_e("createdBy","==",o),he(it)),r=(await ge(u)).docs.map(l=>l.data());return r.sort((l,g)=>D(g.modifiedAt)-D(l.modifiedAt)),r.slice(0,a).map(l=>({id:l.id,title:l.title,modelId:l.modelId,createdAt:D(l.createdAt),modifiedAt:D(l.modifiedAt)}))}async function re(t){let o=await X(se(t));if(!o.exists())return null;let n=o.data();return n.createdBy!==ie()?null:{id:n.id||t,title:n.title,modelId:n.modelId,createdAt:D(n.createdAt),modifiedAt:D(n.modifiedAt),messages:n.messages||[]}}async function Ye(t,o){let n=ie(),a=se(t),u=await X(a);if(u.exists()&&u.data().createdBy!==n)throw new Error("chat is owned by another user");let m={id:t,createdBy:n,modifiedAt:Y(),messages:We(o.messages)};u.exists()||(m.createdAt=Y()),o.modelId&&(m.modelId=o.modelId),o.title&&(m.title=o.title),await Ce(a,m,{merge:!0})}async function qe(t){await re(t)&&await ve(se(t))}async function Qe(t,o){let n=je(o);if(n==="New chat")return n;let a=ze(o);if(!a)return n;try{let u=ke(Pe(t)),m=await Me({model:u,system:Ue,prompt:Oe(a),maxOutputTokens:64,temperature:.3}),r=De(m.text);if(r)return r}catch(u){console.error("failed to generate chat title:",u)}return n}var le=[{id:"read",label:"Read only",description:"Inspect CMS content without planning or applying writes."},{id:"approve",label:"Ask before writing",description:"Read freely, then pause for approval before draft edits."},{id:"auto",label:"Auto-apply draft edits",description:"Apply draft-only writes without approval in this chat."}],ot="root-cms.ai.executionMode",nt="root-cms.ai.selectedModel";function rt(t){return le.some(o=>o.id===t)}function lt(){if(typeof window>"u")return"approve";try{let t=window.localStorage.getItem(ot);if(rt(t))return t}catch(t){console.error("failed to read AI execution mode preference",t)}return"approve"}function ct(t){if(typeof window>"u")return null;try{let o=window.localStorage.getItem(nt);if(o&&t.some(n=>n.id===o))return o}catch(o){console.error("failed to read AI model preference",o)}return null}function dt(t){if(!(typeof window>"u"))try{window.localStorage.setItem(nt,t)}catch(o){console.error("failed to save AI model preference",o)}}function ut(t){if(!(typeof window>"u"))try{window.localStorage.setItem(ot,t)}catch(o){console.error("failed to save AI execution mode preference",o)}}var F="";function so(t){let[o,n]=_(null),[a,u]=_("");M(()=>{let r=!0;return fetch("/cms/api/ai.config",{credentials:"include"}).then(async l=>{let g=await l.json();r&&n(g)}).catch(l=>{r&&u(String(l))}),()=>{r=!1}},[]);let m=!!o?.enabled&&(o.models?.length||0)>0;return e("div",{className:T("RootAIChat",`RootAIChat--${t.variant}`),children:!o&&!a?e("div",{className:"RootAIChat__loading",children:e(J,{size:"md",color:"gray"})}):m?e(pt,{variant:t.variant,config:o,initialChatId:t.variant==="panel"?void 0:t.initialChatId,docContext:t.docContext,onClose:t.onClose}):e(mt,{error:a,onClose:t.onClose})})}function mt(t){return e("div",{className:"RootAIChat__notEnabled",children:[t.onClose&&e(E,{className:"RootAIChat__notEnabled__close",onClick:t.onClose,title:"Close",children:e(B,{size:16})}),e("div",{className:"RootAIChat__notEnabled__icon",children:e(z,{size:36})}),e("div",{className:"RootAIChat__notEnabled__title",children:"Root AI is not configured for this project."}),e("div",{className:"RootAIChat__notEnabled__body",children:["Add an ",e("code",{children:"ai.models"})," entry to ",e("code",{children:"cmsPlugin()"})," in"," ",e("code",{children:"root.config.ts"}),"."]}),t.error&&e("pre",{className:"RootAIChat__notEnabled__error",children:t.error})]})}function pt(t){let o=t.variant==="panel",{route:n}=Ae(),a=t.config.models||[],u=()=>ct(a)||t.config.defaultModel||a[0]?.id||"",[m,r]=_(u),[l,g]=_(lt),[h,R]=_(t.initialChatId||F),[x,v]=_(t.initialChatId||F),[P,c]=_([]),[C,A]=_(""),[I,S]=_([]),[K,L]=_(0),k=async()=>{if(!o)try{let i=await Xe();S(i)}catch(i){console.error("failed to load chat list",i)}};M(()=>{k(),!o&&t.initialChatId&&V(t.initialChatId)},[]),M(()=>{ut(l)},[l]);let U=async i=>{try{let f=await re(i);return f?(R(i),v(i),c(f.messages||[]),A(f.title||""),f.modelId&&a.find(b=>b.id===f.modelId)&&r(f.modelId),L(w=>w+1),!0):!1}catch(f){return console.error("failed to load chat",f),!1}},V=i=>U(i),O=()=>{r(u()),R(F),v(F),c([]),A(""),L(i=>i+1),o||n("/cms/ai")},$=async i=>{if(i===x)return;await U(i)&&!o&&n(`/cms/ai/chat/${i}`)},s=async i=>{try{await qe(i),x===i&&O(),k()}catch(f){console.error("failed to delete chat",f)}},p=a.find(i=>i.id===m)||a[0],d=i=>{r(i),dt(i)};return e("div",{className:"RootAIChat__layout",children:[!o&&e(_t,{chats:I,activeChatId:x,onSelect:$,onNew:O,onDelete:s}),e("div",{className:"RootAIChat__main",children:[o&&e(ft,{onNewChat:O,onClose:t.onClose}),e(gt,{initialChatId:h,initialTitle:C,model:p,initialMessages:P,executionMode:l,canAutoApply:t.config.canAutoApply??!1,models:a,selectedModel:p,docContext:t.docContext,onSelectModel:d,onSelectExecutionMode:g,onChatPersisted:i=>{v(i),k(),o||window.history.replaceState(null,"",`/cms/ai/chat/${i}`)}},K)]})]})}function ft(t){return e("div",{className:"RootAIChat__panelHeader",children:[e("div",{className:"RootAIChat__panelHeader__title",children:[e(z,{size:14}),e("span",{children:"Root AI"})]}),e("div",{className:"RootAIChat__panelHeader__actions",children:[e(H,{label:"New chat",children:e(E,{size:"xs",onClick:t.onNewChat,children:e(te,{size:14})})}),t.onClose&&e(H,{label:"Close (\u2318 + i)",children:e(E,{size:"xs",onClick:t.onClose,children:e(B,{size:14})})})]})]})}function _t(t){return e("aside",{className:"RootAIChat__sidebar",children:[e("button",{type:"button",className:"RootAIChat__sidebar__newButton",onClick:t.onNew,children:[e(te,{size:18}),e("span",{children:"New chat"})]}),e("div",{className:"RootAIChat__sidebar__list",children:[t.chats.length===0&&e("div",{className:"RootAIChat__sidebar__empty",children:"No chats yet."}),t.chats.map(o=>e("div",{className:T("RootAIChat__sidebar__item",o.id===t.activeChatId&&"RootAIChat__sidebar__item--active"),onClick:()=>t.onSelect(o.id),children:[e("div",{className:"RootAIChat__sidebar__item__title",title:o.title||"Untitled chat",children:o.title||"Untitled chat"}),e("button",{type:"button",className:"RootAIChat__sidebar__item__delete",title:"Delete chat",onClick:n=>{n.stopPropagation(),window.confirm("Delete this chat?")&&t.onDelete(o.id)},children:e(be,{size:14})})]},o.id))]})]})}function ht(t){let o=t.canAutoApply?le:le.filter(a=>a.id!=="auto"),n=o.find(a=>a.id===t.executionMode)||o[0];return e("div",{className:"RootAIChat__options",children:[e(W,{control:e(j,{type:"button",className:"RootAIChat__modePicker",variant:"subtle",color:"dark",size:"xs",compact:!0,leftIcon:e(Re,{size:16}),children:n.label}),children:o.map(a=>e(W.Item,{onClick:()=>t.onSelectExecutionMode(a.id),children:e("div",{className:"RootAIChat__modePicker__option",children:[e("div",{className:"RootAIChat__modePicker__option__label",children:a.label}),e("div",{className:"RootAIChat__modePicker__option__description",children:a.description})]})},a.id))}),e(W,{control:e(j,{type:"button",className:"RootAIChat__modelPicker",variant:"subtle",color:"dark",size:"xs",compact:!0,leftIcon:e(z,{size:16}),children:t.selectedModel?.label||"Select model"}),children:t.models.map(a=>e(W.Item,{onClick:()=>t.onSelectModel(a.id),children:e("div",{className:"RootAIChat__modelPicker__option",children:[e("div",{className:"RootAIChat__modelPicker__option__label",children:a.label}),a.description&&e("div",{className:"RootAIChat__modelPicker__option__description",children:a.description})]})},a.id))})]})}function gt(t){let[o]=_(()=>t.initialChatId||kt()),n=y(t.model?.id);n.current=t.model?.id;let a=y(t.executionMode);a.current=t.executionMode;let u=y(t.docContext);u.current=t.docContext;let m=y(t.onChatPersisted);m.current=t.onChatPersisted;let r=y(null),l=y(t.executionMode),g=y(t.initialTitle),h=y(null),[R,x]=_({}),v=y({});M(()=>()=>{for(let s of Object.values(v.current))s("reject");v.current={}},[]);let P=N((s,p,d,i)=>new Promise(f=>{v.current[s]=f,x(w=>({...w,[s]:{toolCallId:s,toolName:p,input:d,preview:i,status:"pending"}}))}),[]),c=N(s=>{x(p=>{let d=p[s];return d?{...p,[s]:{...d,status:"executing"}}:p}),v.current[s]?.("approve"),delete v.current[s]},[]),C=N(s=>{x(p=>{let d={...p};return delete d[s],d}),v.current[s]?.("reject"),delete v.current[s]},[]),A=N(async s=>{if(!He(s.toolName))return await ae(s.toolName,s.input);let p=l.current;if(p==="read")return{success:!1,error:"WRITE_BLOCKED_BY_MODE",message:"The current execution mode is read only. Do not call write tools."};let d;try{d=await Fe(s.toolName,s.input)}catch(i){return{success:!1,error:"PREVIEW_FAILED",message:i?.message||String(i)}}if(d.error)return{success:!1,error:d.error,message:d.summary,errors:d.errors,hint:d.hint};if(p==="approve"&&await P(s.toolCallId,s.toolName,s.input,d)==="reject")return{success:!1,error:"USER_REJECTED",message:"The user rejected this draft change. Do not retry unless they ask for a revised version."};try{return await ae(s.toolName,s.input)}finally{x(i=>{if(!i[s.toolCallId])return i;let f={...i};return delete f[s.toolCallId],f})}},[P]),I=N(async s=>{let p=r.current;try{let d=g.current;if(!d&&p){let i=await Qe(p,s);i&&i!=="New chat"&&(d=i,g.current=i)}await Ye(o,{messages:s,modelId:p?.id||n.current,title:d||void 0})}catch(d){console.error("failed to persist chat history",d)}m.current(o)},[o]),S=ue(()=>Be({loadTurnConfig:async()=>{let s=n.current,p=a.current,d=u.current?.docId,i=`${s}|${p}|${d||""}`,f=h.current;if(f&&f.key===i)return f.config;let w=await fetch("/cms/api/ai.chat.prepare",{method:"POST",credentials:"include",headers:{"content-type":"application/json"},body:JSON.stringify({modelId:s,executionMode:p,docId:d})}),b=await w.json();if(!w.ok||!b.success)throw new Error(b.error||`ai.chat.prepare failed: ${w.status}`);let ce={model:b.model,system:b.system,maxSteps:b.maxSteps};return r.current=b.model,l.current=b.executionMode||p,h.current={key:i,config:ce},ce},buildTools:s=>s.capabilities.tools?l.current==="read"?$e():Le():{},onFinish:I}),[I]),{messages:K,sendMessage:L,status:k,error:U,stop:V,addToolOutput:O}=Te({id:o,messages:t.initialMessages,transport:S,sendAutomaticallyWhen:Ne,onToolCall:async({toolCall:s})=>{let p=await A(s);O({tool:s.toolName,toolCallId:s.toolCallId,output:p})}}),$=k==="streaming"||k==="submitted";return e(de,{children:[e(Ct,{messages:K,isStreaming:$,emptyMessage:t.model?void 0:"Select a model to start.",toolApprovals:{approvals:R,onApprove:c,onReject:C}}),U&&e("div",{className:"RootAIChat__error",children:[e("strong",{children:"Error:"})," ",U.message]}),e(Mt,{disabled:!t.model,canAttach:t.model?.capabilities.attachments??!1,isStreaming:$,onStop:V,controls:e(ht,{models:t.models,selectedModel:t.selectedModel,onSelectModel:t.onSelectModel,executionMode:t.executionMode,canAutoApply:t.canAutoApply,onSelectExecutionMode:t.onSelectExecutionMode}),onSend:(s,p)=>{if(!s&&p.length===0)return;let d=Nt(p),i=[s,d.text].filter(Boolean).join(`
2
+
3
+ `);L({text:i,files:d.files.map(f=>({type:"file",mediaType:f.mediaType,url:f.url,filename:f.filename}))})}})]})}function Ct(t){let o=y(null);return M(()=>{let n=o.current;n&&(n.scrollTop=n.scrollHeight)},[t.messages]),t.messages.length===0?e("div",{className:"RootAIChat__transcript RootAIChat__transcript--empty",ref:o,children:e("div",{className:"RootAIChat__welcome",children:[e("div",{className:"RootAIChat__welcome__icon",children:e(z,{size:36})}),e("div",{className:"RootAIChat__welcome__title",children:"Root AI"}),e("div",{className:"RootAIChat__welcome__body",children:t.emptyMessage||"What are we going to get done today?"})]})}):e("div",{className:"RootAIChat__transcript",ref:o,children:e("div",{className:"RootAIChat__transcript__inner",children:[t.messages.map(n=>e(vt,{message:n,toolApprovals:t.toolApprovals},n.id)),t.isStreaming&&e("div",{className:"RootAIChat__streamingIndicator",children:e(Se,{size:6})})]})})}function vt(t){let o=t.message,n=o.role==="user",a=n?"You":"Root AI",u=n?window.firebase.user?.photoURL:null,[m,r]=_(!1),l=N(()=>(o.parts||[]).filter(h=>h.type==="text"&&h.text).map(h=>h.text).join(`
4
+
5
+ `),[o.parts]),g=N(async()=>{let h=l();if(!h)return;let R=Ee.parse(h);try{await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([R],{type:"text/html"}),"text/plain":new Blob([h],{type:"text/plain"})})]),r(!0),setTimeout(()=>r(!1),2e3)}catch{await navigator.clipboard.writeText(h),r(!0),setTimeout(()=>r(!1),2e3)}},[l]);return e("div",{className:T("RootAIChat__message",`RootAIChat__message--${o.role}`),children:[e("div",{className:"RootAIChat__message__avatar",children:u?e("img",{src:u,alt:a}):e(z,{size:20})}),e("div",{className:"RootAIChat__message__body",children:[e("div",{className:"RootAIChat__message__username",children:a}),e("div",{className:"RootAIChat__message__parts",children:(o.parts||[]).map((h,R)=>e(At,{part:h,toolApprovals:t.toolApprovals},R))}),e("button",{type:"button",className:T("RootAIChat__message__copy",m&&"RootAIChat__message__copy--copied"),title:m?"Copied!":"Copy message",onClick:g,children:m?e(Q,{size:14}):e(ye,{size:14})})]})]})}function At(t){let o=t.part;return o.type==="text"?o.text?e("div",{className:"RootAIChat__textPart",children:e(ne,{code:o.text})}):null:o.type==="reasoning"?e(It,{text:o.text}):o.type==="file"?e(yt,{part:o}):o.type==="source-url"?e("a",{className:"RootAIChat__sourcePart",href:o.url,target:"_blank",rel:"noopener noreferrer",children:o.title||o.url}):typeof o.type=="string"&&o.type.startsWith("tool-")?e(Ze,{part:o,toolApprovals:t.toolApprovals}):o.type==="dynamic-tool"?e(Ze,{part:o,toolApprovals:t.toolApprovals}):o.type==="step-start"?null:e("div",{className:"RootAIChat__unknownPart",children:e("pre",{children:JSON.stringify(o,null,2)})})}function It(t){let[o,n]=_(!1);return t.text?e("div",{className:T("RootAIChat__reasoning",o&&"RootAIChat__reasoning--open"),children:[e("button",{type:"button",className:"RootAIChat__reasoning__toggle",onClick:()=>n(!o),children:[e(Z,{size:14,style:{transform:o?"rotate(0deg)":"rotate(-90deg)"}}),e("span",{children:"Thinking"})]}),o&&e("div",{className:"RootAIChat__reasoning__body",children:e(ne,{code:t.text})})]}):null}function yt(t){let o=t.part;return o.mediaType?.startsWith("image/")?e("div",{className:"RootAIChat__filePart",children:e("img",{src:o.url,alt:o.filename||"attachment"})}):e("a",{className:"RootAIChat__filePart RootAIChat__filePart--link",href:o.url,target:"_blank",rel:"noopener noreferrer",children:[e(oe,{size:14}),e("span",{children:o.filename||o.url})]})}function Ze(t){let o=t.part,n=typeof o.type=="string"&&o.type.startsWith("tool-")?o.type.slice(5):o.toolName||"tool",a=o.state||"",u=Rt(o),m=t.toolApprovals,r=u?m?.approvals[u]:void 0,[l,g]=_(!!r);return M(()=>{r&&g(!0)},[r]),e("div",{className:"RootAIChat__tool",children:[e("button",{type:"button",className:"RootAIChat__tool__header",onClick:()=>g(!l),children:[e(Z,{className:T("RootAIChat__tool__header__icon",l&&"RootAIChat__tool__header__icon--open"),size:14}),e(G,{color:"dark",variant:"filled",size:"xs",children:n}),e("span",{className:"RootAIChat__tool__title",children:Ke(n,o.input)}),e("span",{className:"RootAIChat__tool__state",children:r?wt(r.status):Ve(a)})]}),l&&e("div",{className:"RootAIChat__tool__body",children:[r&&m&&e(xt,{approval:r,onApprove:()=>m.onApprove(r.toolCallId),onReject:()=>m.onReject(r.toolCallId)}),o.output?.receipt&&e(bt,{output:o.output}),o.input&&e("details",{children:[e("summary",{children:[e(ee,{size:14,className:"RootAIChat__tool__json__icon"}),e("span",{children:"Input"})]}),e("pre",{children:JSON.stringify(o.input,null,2)})]}),o.output&&e("details",{children:[e("summary",{children:[e(ee,{size:14,className:"RootAIChat__tool__json__icon"}),e("span",{children:"Output"})]}),e("pre",{children:JSON.stringify(o.output,null,2)})]}),o.errorText&&e("div",{className:"RootAIChat__tool__error",children:o.errorText})]})]})}function Rt(t){return t.toolCallId||t.id||""}function xt(t){let o=t.approval.preview,n=o.before!==void 0&&o.after!==void 0;return e("div",{className:"RootAIChat__approval",children:[e("div",{className:"RootAIChat__approval__header",children:[e("div",{children:[e("div",{className:"RootAIChat__approval__title",children:o.title}),e("div",{className:"RootAIChat__approval__summary",children:o.summary})]}),e(G,{className:"RootAIChat__approval__status",variant:"light",color:"gray",children:t.approval.status==="executing"?"Applying":"Review"})]}),o.details.length>0&&e("div",{className:"RootAIChat__approval__details",children:o.details.map(a=>e("div",{children:[e("span",{children:a.label}),e("strong",{children:a.value})]},`${a.label}:${a.value}`))}),n&&e(we,{className:"RootAIChat__approval__diff",oldCode:q(o.before),newCode:q(o.after)}),e("div",{className:"RootAIChat__approval__actions",children:[e(j,{variant:"default",color:"dark",size:"xs",type:"button",className:"RootAIChat__approval__button",disabled:t.approval.status==="executing",onClick:t.onReject,children:"Reject"}),e(j,{variant:"filled",color:"green",size:"xs",type:"button",className:"RootAIChat__approval__button RootAIChat__approval__button--primary",disabled:t.approval.status==="executing",onClick:t.onApprove,children:"Approve draft edit"})]})]})}function bt(t){let o=t.output.receipt;return e("div",{className:"RootAIChat__receipt",children:[e("div",{className:"RootAIChat__receipt__title",children:[e(Q,{size:14}),e("span",{children:o.title})]}),e("div",{className:"RootAIChat__receipt__summary",children:o.summary}),o.details?.length>0&&e("div",{className:"RootAIChat__receipt__details",children:o.details.map(n=>e("div",{children:[e("span",{children:n.label}),e("strong",{children:n.value})]},`${n.label}:${n.value}`))}),o.adminUrl&&e(j,{component:"a",className:"RootAIChat__receipt__link",variant:"default",size:"xs",compact:!0,href:o.adminUrl,children:"Open document"})]})}function wt(t){return t==="executing"?"applying\u2026":"waiting for approval"}function Mt(t){let[o,n]=_(""),[a,u]=_([]),[m,r]=_(!1),l=y(null),g=y(null);M(()=>{window.requestAnimationFrame(()=>{let c=g.current;c&&(c.style.height="auto",c.style.height=`${Math.min(c.scrollHeight,240)}px`)})},[o,a]);let R=()=>{t.disabled||t.isStreaming||!o&&a.length===0||(t.onSend(o,a),n(""),u([]),l.current&&(l.current.value=""))},x=c=>{c.key==="Enter"&&!c.shiftKey&&(c.preventDefault(),R())},v=async c=>{r(!0);try{let C=c.type||Pt(c.name),A=await St(c,C),I=await Ie(c,{disableGci:!0});u(S=>[...S,{url:I.src,filename:I.filename||c.name,mediaType:C,textContent:A?.text,textTruncated:A?.truncated,width:I.width,height:I.height}])}catch(C){console.error("upload failed",C)}finally{r(!1),l.current&&(l.current.value="")}},P=c=>{let C=c.target;Array.from(C.files||[]).forEach(v)};return e("div",{className:"RootAIChat__composer",children:[a.length>0&&e("div",{className:"RootAIChat__composer__attachments",children:a.map((c,C)=>e("div",{className:"RootAIChat__composer__attachment",children:[c.mediaType.startsWith("image/")?e("img",{src:c.url,alt:c.filename}):e("span",{className:"RootAIChat__composer__attachment__name",children:c.filename}),e("button",{type:"button",className:"RootAIChat__composer__attachment__remove",onClick:()=>u(A=>A.filter((I,S)=>S!==C)),children:e(B,{size:12})})]},C))}),e("div",{className:"RootAIChat__composer__row",children:[e(H,{label:t.canAttach?"Attach file":"Model doesn't support attachments",className:"RootAIChat__composer__attachTooltip",children:e(E,{component:"label",radius:"xl",className:T("RootAIChat__composer__attach",!t.canAttach&&"RootAIChat__composer__attach--disabled"),disabled:!t.canAttach,children:[m?e(J,{size:"xs"}):e(oe,{size:18}),e("input",{ref:l,type:"file",style:{display:"none"},onChange:P})]})}),e("textarea",{ref:g,className:"RootAIChat__composer__textarea",placeholder:t.disabled?"Select a model\u2026":"Ask anything\u2026",value:o,rows:1,autofocus:!0,disabled:t.disabled,onKeyDown:x,onChange:c=>n(c.target.value),onPaste:c=>{let C=c.clipboardData?.items||[];for(let A of C)if(A.kind==="file"){let I=A.getAsFile();I&&t.canAttach&&v(I)}}}),t.isStreaming?e(E,{className:"RootAIChat__composer__button RootAIChat__composer__stopButton",radius:"xl",color:"dark",variant:"filled",onClick:t.onStop,title:"Stop",children:e(B,{size:18})}):e(E,{className:"RootAIChat__composer__button RootAIChat__composer__submitButton",radius:"xl",color:"dark",variant:"filled",disabled:t.disabled||m||!o&&a.length===0,onClick:R,title:"Send",children:e(xe,{size:18})})]}),t.controls]})}var et=1e5;function Nt(t){let o=t.filter(tt),n=t.filter(a=>!tt(a)).map(Tt);return{files:o,text:n.length?`Attached files:
6
+
7
+ ${n.join(`
8
+
9
+ `)}`:""}}function tt(t){return t.mediaType.startsWith("image/")}function Tt(t){let o=`File: ${t.filename} (${t.mediaType})`;if(t.textContent!==void 0){let n=t.textTruncated?`
10
+
11
+ [Content truncated before sending to the model.]`:"";return`${o}
12
+ URL: ${t.url}
13
+
14
+ ~~~
15
+ ${t.textContent}${n}
16
+ ~~~`}return`${o}
17
+ URL: ${t.url}
18
+
19
+ [The file was uploaded, but its binary content was not inlined into this chat message.]`}async function St(t,o){if(!Et(t.name,o))return null;let n=await t.text();return n.length<=et?{text:n,truncated:!1}:{text:n.slice(0,et),truncated:!0}}function Et(t,o){return o.startsWith("text/")?!0:[".css",".js",".jsx",".json",".md",".mdx",".mjs",".scss",".ts",".tsx",".txt",".yaml",".yml"].some(n=>t.toLowerCase().endsWith(n))}function Pt(t){let o=t.toLowerCase();return o.endsWith(".png")?"image/png":o.endsWith(".webp")?"image/webp":o.endsWith(".jpg")||o.endsWith(".jpeg")?"image/jpeg":o.endsWith(".gif")?"image/gif":o.endsWith(".svg")?"image/svg+xml":o.endsWith(".pdf")?"application/pdf":o.endsWith(".json")?"application/json":o.endsWith(".csv")?"text/csv":o.endsWith(".md")?"text/markdown":o.endsWith(".txt")?"text/plain":"application/octet-stream"}function kt(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`chat-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}export{so as a};
@@ -1 +1 @@
1
- import{a as z}from"./chunk-QWB6MAPJ.js";import{c as C}from"./chunk-VPZHG7JL.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
+ import{a as z}from"./chunk-QWB6MAPJ.js";import{c as C}from"./chunk-235TRWJF.js";import{f as h}from"./chunk-5MV6XVGA.js";import{a as x}from"./chunk-NCZD5IWS.js";import{a as P}from"./chunk-AAHM6RYJ.js";import{U as b,Y as A,Z as I}from"./chunk-ISUGBMXC.js";import{e as D}from"./chunk-WASID5UU.js";import{Ga as e,Kc as N,U as y,V as u,a as t,bd as k,c as v,da as S,e as w,j as V}from"./chunk-WRA24P66.js";import{d as g}from"./chunk-KUCVLANF.js";V();V();function R(o){let r=o.docId,[i,d]=t("idle"),[c,f]=t(""),[s,l]=t(""),m=w(!1);async function p(){d("loading");try{let n=await I(r,{beforeVersion:o.beforeVersion,afterVersion:o.afterVersion});f(n),d("success")}catch(n){console.error(n),l(n instanceof Error?n.message:"Unknown error"),d("error")}}function _(){m.current||(m.current=!0,p())}let a;return i==="idle"||i==="loading"?a=e("div",{className:"AiSummary__loading",children:e(u,{size:"md",color:"gray"})}):i==="error"?a=e(x,{className:"AiSummary__content",size:"body-sm",color:"gray",children:["Failed to load AI summary.",s&&e(g,{children:[e("br",{}),s]})]}):c?a=e(C,{className:"AiSummary__content",code:c}):a=e(x,{className:"AiSummary__content",size:"body-sm",color:"gray",children:"No AI summary available for this draft yet."}),e("div",{className:D(o.className,"AiSummary"),children:e(y,{iconPosition:"right",onChange:()=>_(),disableIconRotation:!0,children:e(y.Item,{label:"Summarize changes",icon:e(N,{stroke:"1.5"}),iconPosition:"left",children:a})})})}function me(o){let r=o.left,i=o.right,[d,c]=t(!1),[f,s]=t(null),[l,m]=t(null),p=P()&&r.docId===i.docId&&o.showAiSummary!==!1,_=h(E(f?.fields||{})),a=h(E(l?.fields||{})),n=!d&&f&&l&&_===a,M=`/cms/compare?left=${F(r)}&right=${F(i)}`;async function $(){c(!0);let[j,T]=await Promise.all([b(r.docId,r.versionId),b(i.docId,i.versionId)]);s(j),m(T),c(!1)}return v(()=>{$()},[]),d?e("div",{className:"DocDiffViewer DocDiffViewer--loading",children:e(u,{size:"md",color:"gray"})}):e(g,{children:[p&&e(R,{className:"DocDiffViewer__aiSummary",docId:r.docId,beforeVersion:String(r.versionId),afterVersion:String(i.versionId)}),e("div",{className:D(o.className,"DocDiffViewer"),children:[o.showExpandButton&&e("div",{className:"DocDiffViewer__expand",children:e(S,{component:"a",variant:"default",size:"xs",compact:!0,href:M,target:"_blank",children:"Open in new tab"})}),e("div",{className:"DocDiffViewer__header",children:[e("div",{className:"DocDiffViewer__header__label",children:[e("div",{className:"DocDiffViewer__header__label__title",children:[o.left.docId,"@",o.left.versionId]}),e("div",{className:"DocDiffViewer__header__label__meta",children:B(f)})]}),e("div",{className:"DocDiffViewer__header__label",children:[e("div",{className:"DocDiffViewer__header__label__title",children:[o.right.docId,"@",o.right.versionId]}),e("div",{className:"DocDiffViewer__header__label__meta",children:B(l)})]})]}),e("div",{className:"DocDiffViewer__diff",children:n?e("div",{className:"DocDiffViewer__identical",children:[e(k,{size:20}),e("span",{children:"No changes. Both versions are identical."})]}):e(z,{oldCode:_,newCode:a})})]})]})}function B(o){if(!o?.sys?.modifiedAt)return"never";let r=o.sys.modifiedAt.toDate();return`${new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(r)} by ${o.sys.modifiedBy}`}function E(o){return A(o,{removeArrayKey:!0})}function F(o){return encodeURIComponent(`${o.docId}@${o.versionId}`).replaceAll("%2F","/").replaceAll("%40","@")}export{R as a,me as b};
@@ -1 +1 @@
1
- import{a as Vt}from"./chunk-AAHM6RYJ.js";import{d as Y,e as N}from"./chunk-WASID5UU.js";import{Bc as Ht,C as dt,Cc as Rt,D as j,E as ut,Fa as Et,G as U,Ga as r,Gc as zt,H as mt,I as gt,Jb as Bt,Jc as Wt,K as ft,O as ht,P as _t,Q as vt,S as Q,Sb as It,T as yt,Xb as Tt,Y as S,Z as bt,_ as Ct,_a as Pt,a as x,aa as xt,c as O,e as pt,fa as wt,ha as St,ia as kt,ib as At,ic as Mt,j as je,ja as Lt,ka as Ot,qa as Z,sb as Nt,tc as Dt,ua as jt,v as n,y as w}from"./chunk-WRA24P66.js";import{d as V,j as ct}from"./chunk-KUCVLANF.js";var tt={name:"@blinkk/root-cms",version:"3.1.5",author:"s@blinkk.com",license:"MIT",engines:{node:">=22.0.0"},repository:{type:"git",url:"git+https://github.com/blinkk/rootjs.git",directory:"packages/root-cms"},files:["dist/**/*"],bin:{"root-cms":"./bin/root-cms.js"},type:"module",module:"./dist/core.js",types:"./dist/core/core.d.ts",exports:{".":{types:"./dist/core/core.d.ts",import:"./dist/core.js"},"./browser-client":{types:"./dist/browser-client/browser-client.d.ts",import:"./dist/browser-client.js"},"./client":{types:"./dist/core/client.d.ts",import:"./dist/client.js"},"./core":{types:"./dist/core/core.d.ts",import:"./dist/core.js"},"./functions":{types:"./dist/core/functions.d.ts",import:"./dist/functions.js"},"./plugin":{types:"./dist/core/plugin.d.ts",import:"./dist/plugin.js"},"./project":{types:"./dist/core/project.d.ts",import:"./dist/project.js"},"./richtext":{types:"./dist/core/richtext.d.ts",import:"./dist/richtext.js"}},scripts:{build:'rm -rf dist && concurrently -n "core,signin,ui" npm:build:core npm:build:signin npm:build:ui',"build:core":"node ../../scripts/build-esbuild.mjs ./esbuild.config.json","build:ui":"pnpm build:ui:bundle && pnpm build:ui:clean","build:ui:bundle":"esbuild ui/ui.tsx --bundle --minify --alias:react=@preact/compat --alias:react-dom=@preact/compat --tsconfig=ui/tsconfig.json --outdir=dist/ui --legal-comments=external --splitting --format=esm","build:ui:clean":"rm -f dist/ui/*-*.css","build:signin":"esbuild signin/signin.tsx --bundle --minify --tsconfig=signin/tsconfig.json --outdir=dist/ui --legal-comments=external",dev:'rm -rf dist && concurrently -k -n "core,ui" npm:dev:core npm:dev:signin npm:dev:ui',"dev:core":"pnpm build:core --watch","dev:signin":"pnpm build:signin --watch","dev:ui":"pnpm build:ui:bundle --watch",test:"pnpm build && firebase emulators:exec 'vitest run --exclude=**/*.visual.test.tsx'","test:visual":"vitest run --config=vitest.config.visual.ts","test:watch":"pnpm build && firebase emulators:exec 'vitest'"},dependencies:{"@ag-grid-community/client-side-row-model":"32.3.9","@ag-grid-community/core":"32.3.9","@ag-grid-community/react":"32.3.9","@ag-grid-community/styles":"32.3.9","@ai-sdk/anthropic":"3.0.74","@ai-sdk/google":"3.0.67","@ai-sdk/openai":"3.0.60","@ai-sdk/openai-compatible":"2.0.46","@ai-sdk/react":"3.0.177","@google-cloud/firestore":"7.11.3","@hello-pangea/dnd":"18.0.1","@mantine/spotlight":"4.2.12","@types/cli-progress":"3.11.6",ai:"6.0.175","body-parser":"1.20.2","cli-progress":"3.12.0",commander:"11.0.0","csv-parse":"5.5.2","csv-stringify":"6.4.4","date-fns":"4.1.0","date-fns-tz":"3.2.0",diff:"8.0.2","dts-dom":"3.7.0","fnv-plus":"1.3.1",jsonwebtoken:"9.0.2",kleur:"4.1.5",minisearch:"7.2.0","sanitize-html":"2.13.1",sirv:"2.0.3","tiny-glob":"0.2.9",zod:"4.4.3"},"//":"NOTE(stevenle): due to compat issues with mantine and preact, mantine is pinned to v4.2.12",devDependencies:{"@babel/core":"7.17.9","@blinkk/root":"workspace:*","@editorjs/editorjs":"2.30.8","@editorjs/header":"2.8.8","@editorjs/image":"2.10.2","@editorjs/list":"2.0.6","@editorjs/nested-list":"1.4.3","@editorjs/raw":"2.5.1","@editorjs/table":"2.4.4","@editorjs/underline":"1.2.1","@emotion/react":"11.10.5","@firebase/app-compat":"0.5.2","@firebase/app-types":"0.9.3","@firebase/rules-unit-testing":"5.0.0","@lexical/code":"0.33.1","@lexical/html":"0.33.1","@lexical/link":"0.33.1","@lexical/list":"0.33.1","@lexical/markdown":"0.33.1","@lexical/react":"0.33.1","@lexical/rich-text":"0.33.1","@lexical/selection":"0.33.1","@lexical/table":"0.33.1","@lexical/utils":"0.33.1","@mantine/core":"4.2.12","@mantine/hooks":"4.2.12","@mantine/modals":"4.2.12","@mantine/notifications":"4.2.12","@preact/compat":"18.3.1","@tabler/icons-preact":"3.35.0","@testing-library/preact":"3.2.4","@testing-library/user-event":"14.6.1","@types/body-parser":"1.19.3","@types/fnv-plus":"1.3.2","@types/gapi":"0.0.47","@types/gapi.client.drive-v3":"0.0.4","@types/gapi.client.sheets-v4":"0.0.4","@types/google.accounts":"0.0.14","@types/jsonwebtoken":"9.0.1","@types/node":"24.3.1","@types/sanitize-html":"2.13.0","@vitest/browser":"4.1.8","@vitest/browser-playwright":"4.1.8",concurrently:"7.6.0",esbuild:"0.28.0",firebase:"12.2.1","firebase-admin":"13.5.0","firebase-functions":"6.4.0","firebase-tools":"14.15.2","highlight.js":"11.6.0",jsdom:"27.2.0","json-diff-kit":"1.0.29",lexical:"0.33.1",marked:"9.1.1","mdast-util-from-markdown":"2.0.1","mdast-util-gfm":"3.0.0","micromark-extension-gfm":"3.0.0",playwright:"1.60.0",preact:"10.27.1","preact-iso":"2.11.1","preact-render-to-string":"6.6.7",react:"npm:@preact/compat@18.3.1","react-dom":"npm:@preact/compat@18.3.1","react-easy-crop":"5.5.6","react-json-view-compare":"2.0.2",typescript:"6.0.3",vite:"8.0.13",vitest:"4.1.6",yjs:"13.6.27"},peerDependencies:{"@blinkk/root":"3.1.5","firebase-admin":">=11","firebase-functions":">=4"},peerDependenciesMeta:{"firebase-functions":{optional:!0}}};function Ut(){return r("svg",{width:"100",height:"23",viewBox:"0 0 100 23",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r("g",{"clip-path":"url(#clip0_1_318)",children:[r("path",{d:"M7.82998 5.01802C3.12925 5.6479 0.833937 18.1194 2.62578 19.6731C5.64773 22.2934 16.6441 14.1722 15.6786 9.46913C15.3009 6.61371 11.2717 4.28377 7.82998 5.01802Z",fill:"black"}),r("path",{d:"M13.9782 0.720147C12.6553 0.896474 12.0093 4.38767 12.5136 4.8226C13.364 5.55611 16.4587 3.28271 16.187 1.96616C16.0807 1.16683 14.9468 0.514607 13.9782 0.720147Z",fill:"black"}),r("path",{d:"M92.7383 17.6275C90.9681 17.6275 89.3816 17.0263 88.3796 16.0744C87.9955 15.7237 87.8953 15.3396 88.246 14.9555L88.8305 14.2541C89.1645 13.87 89.5486 13.7865 89.9327 14.1205C90.6007 14.6883 91.7029 15.1726 92.5713 15.1726C93.5232 15.1726 94.1244 14.8219 94.1244 14.2875C94.1244 13.5193 93.2059 13.4358 91.9868 13.0684C90.417 12.6008 88.5132 11.7324 88.5132 9.64493C88.5132 7.70773 90.25 6.37173 92.7383 6.37173C94.2413 6.37173 95.5272 6.87273 96.4123 7.57413C96.8131 7.90813 96.9467 8.27553 96.596 8.67633L96.0282 9.37773C95.7109 9.76183 95.3435 9.82863 94.926 9.51133C94.3916 9.09383 93.6568 8.69303 92.7884 8.69303C92.0202 8.69303 91.5192 9.01033 91.5192 9.51133C91.5192 10.1292 92.3041 10.4131 93.1224 10.6636C94.9761 11.2314 97.1304 11.8326 97.1304 14.2708C97.1304 16.4585 95.1264 17.6275 92.7383 17.6275Z",fill:"black"}),r("path",{d:"M87.0008 16.6756C87.0843 17.1766 86.8171 17.4271 86.2994 17.4271H85.097C84.596 17.4271 84.3789 17.1766 84.3121 16.6756L83.7443 11.9161L81.757 16.7424C81.5399 17.2434 81.1892 17.5106 80.6882 17.5106H80.5212C80.0202 17.5106 79.6695 17.2434 79.4524 16.7424L77.4651 11.8994L76.8973 16.6756C76.8472 17.1766 76.6301 17.4271 76.1291 17.4271H74.7263C74.2086 17.4271 73.9414 17.1766 74.0082 16.6756L75.4945 7.24013C75.5613 6.75583 75.8786 6.48863 76.3796 6.48863H76.5466C77.0476 6.48863 77.3315 6.75583 77.5486 7.24013L80.6047 13.8032L83.4938 7.24013C83.7109 6.75583 84.0115 6.48863 84.4958 6.48863H84.6795C85.1638 6.48863 85.4811 6.75583 85.5646 7.24013L87.0008 16.6756Z",fill:"black"}),r("path",{d:"M68.6496 17.6275C65.3096 17.6275 62.7211 15.2227 62.7211 11.9996C62.7211 8.77653 65.3096 6.37173 68.683 6.37173C70.3029 6.37173 71.7558 6.97293 72.7745 7.99163C73.1419 8.34233 73.1419 8.77653 72.7745 9.09383L71.9228 9.81193C71.5554 10.1292 71.2047 10.1125 70.8206 9.79523C70.2361 9.31093 69.5013 9.01033 68.683 9.01033C67.013 9.01033 65.7104 10.2628 65.7104 11.9996C65.7104 13.7364 67.013 14.9889 68.683 14.9889C69.5013 14.9889 70.2528 14.6883 70.8206 14.204C71.2047 13.8867 71.5554 13.87 71.9228 14.1873L72.7745 14.9054C73.1419 15.2227 73.1419 15.6569 72.7745 16.0076C71.7558 17.0263 70.3029 17.6275 68.6496 17.6275Z",fill:"black"}),r("path",{d:"M58.575 16.2915C58.7587 16.6923 58.4581 16.8927 58.241 17.0597C57.7233 17.4271 56.9384 17.6442 56.1201 17.6442C54.4501 17.6442 52.8469 16.6923 52.8469 14.4044V11.0978H52.1121C51.6111 11.0978 51.3439 10.8139 51.3439 10.3296V9.76183C51.3439 9.26083 51.6111 8.99363 52.1121 8.99363H52.8469V7.05643C52.8469 6.57213 53.1308 6.38843 53.6151 6.28823L54.9511 6.05443C55.4521 5.95423 55.7193 6.30493 55.7193 6.80593V8.99363H57.3726C57.8569 8.99363 58.1408 9.26083 58.1408 9.76183V10.3296C58.1408 10.8139 57.8569 11.0978 57.3726 11.0978H55.7193V14.1038C55.7193 14.9221 56.1368 15.1893 56.6545 15.1893C56.905 15.1893 57.1555 15.0724 57.3392 14.9555C57.7567 14.6883 57.9571 14.8887 58.1074 15.206L58.575 16.2915Z",fill:"black"}),r("path",{d:"M46.2592 17.6442C43.5538 17.6442 41.5999 15.7738 41.5999 13.2521C41.5999 10.7304 43.5538 8.86003 46.2592 8.86003C48.9646 8.86003 50.9185 10.7304 50.9185 13.2521C50.9185 15.7738 48.9646 17.6442 46.2592 17.6442ZM46.2592 15.1726C47.3113 15.1726 48.0628 14.3543 48.0628 13.2521C48.0628 12.1499 47.3113 11.3316 46.2592 11.3316C45.2071 11.3316 44.4389 12.1499 44.4389 13.2521C44.4389 14.3543 45.2071 15.1726 46.2592 15.1726Z",fill:"black"}),r("path",{d:"M36.052 17.6442C33.3466 17.6442 31.3927 15.7738 31.3927 13.2521C31.3927 10.7304 33.3466 8.86003 36.052 8.86003C38.7574 8.86003 40.7113 10.7304 40.7113 13.2521C40.7113 15.7738 38.7574 17.6442 36.052 17.6442ZM36.052 15.1726C37.1041 15.1726 37.8556 14.3543 37.8556 13.2521C37.8556 12.1499 37.1041 11.3316 36.052 11.3316C34.9999 11.3316 34.2317 12.1499 34.2317 13.2521C34.2317 14.3543 34.9999 15.1726 36.052 15.1726Z",fill:"black"}),r("path",{d:"M28.7099 13.0851L30.6805 16.6422C30.9644 17.1599 30.6638 17.4271 30.1628 17.4271H28.4594C27.9417 17.4271 27.8081 17.1766 27.5242 16.6589L25.7707 13.4859H24.6351V16.6422C24.6351 17.1432 24.3512 17.4271 23.8502 17.4271H22.4808C21.9798 17.4271 21.6959 17.1432 21.6959 16.6422V7.35703C21.6959 6.85603 21.9798 6.57213 22.4808 6.57213H26.5222C29.3111 6.57213 30.8141 7.92483 30.8141 10.1125C30.8141 11.5654 29.9791 12.5841 28.7099 13.0851ZM24.6351 8.96023V11.5153H26.4721C27.2236 11.5153 27.8248 11.0644 27.8248 10.2628C27.8248 9.44453 27.2236 8.96023 26.4721 8.96023H24.6351Z",fill:"black"})]}),r("defs",{children:r("clipPath",{id:"clip0_1_318",children:r("rect",{width:"99",height:"22",fill:"white",transform:"translate(0.0175781 0.177246)"})})})]})}w();var Qt=ct(null);w();w();var Pe=Object.defineProperty,Ae=Object.defineProperties,Ne=Object.getOwnPropertyDescriptors,Zt=Object.getOwnPropertySymbols,Be=Object.prototype.hasOwnProperty,Ie=Object.prototype.propertyIsEnumerable,Gt=(t,e,o)=>e in t?Pe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,Te=(t,e)=>{for(var o in e||(e={}))Be.call(e,o)&&Gt(t,o,e[o]);if(Zt)for(var o of Zt(e))Ie.call(e,o)&&Gt(t,o,e[o]);return t},Me=(t,e)=>Ae(t,Ne(e));function De(t){return Me(Te({},t),{id:t.id||ft()})}function He(t){let e=[];return t.reduceRight((o,i)=>(e.includes(i.id)||(e.push(i.id),o.push(i)),o),[]).reverse()}function G(t){return He(t.map(e=>De(e)))}function Ft(t,e){let[o,i]=x(G(typeof t=="function"?t(e):t));return O(()=>{typeof t=="function"&&i(G(t(e)))},[e]),[o,{registerActions:s=>i(a=>G([...a,...s])),updateActions:s=>i(G(typeof s=="function"?s(e):s)),removeActions:s=>i(a=>a.filter(d=>!s.includes(d.id))),triggerAction:s=>{var a;let d=o.find(g=>g.id===s);(a=d?.onTrigger)==null||a.call(d,d)}}]}function Re(t,e){return t===null?[]:Array.isArray(t)?t.map(o=>[o,e]):[[t,e]]}function Kt(t,e){_t(Re(t,e))}w();w();var ze=j((t,{radius:e})=>({action:{position:"relative",display:"block",width:"100%",padding:"10px 12px",borderRadius:t.fn.radius(e)},actionHovered:{backgroundColor:t.colorScheme==="dark"?t.colors.dark[4]:t.colors.gray[1]},actionIcon:{color:t.colorScheme==="dark"?t.colors.dark[2]:t.colors.gray[6]},actionBody:{flex:1}})),$t=ze;var We=Object.defineProperty,F=Object.getOwnPropertySymbols,qt=Object.prototype.hasOwnProperty,Jt=Object.prototype.propertyIsEnumerable,Xt=(t,e,o)=>e in t?We(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,Ve=(t,e)=>{for(var o in e||(e={}))qt.call(e,o)&&Xt(t,o,e[o]);if(F)for(var o of F(e))Jt.call(e,o)&&Xt(t,o,e[o]);return t},Ue=(t,e)=>{var o={};for(var i in t)qt.call(t,i)&&e.indexOf(i)<0&&(o[i]=t[i]);if(t!=null&&F)for(var i of F(t))e.indexOf(i)<0&&Jt.call(t,i)&&(o[i]=t[i]);return o};function et(t){var e=t,{action:o,styles:i,classNames:l,hovered:c,onTrigger:m,highlightQuery:_,highlightColor:s,query:a,radius:d}=e,g=Ue(e,["action","styles","classNames","hovered","onTrigger","highlightQuery","highlightColor","query","radius"]);let{classes:u,cx:h}=$t({radius:d},{styles:i,classNames:l,name:"Spotlight"});return n.createElement(Q,Ve({className:h(u.action,{[u.actionHovered]:c}),tabIndex:-1,onMouseDown:b=>b.preventDefault(),onClick:m},g),n.createElement(wt,{noWrap:!0},o.icon&&n.createElement(yt,{className:u.actionIcon},o.icon),n.createElement("div",{className:u.actionBody},n.createElement(Ot,{highlightColor:s,highlight:_?a:null},o.title),o.description&&n.createElement(S,{color:"dimmed",size:"xs"},o.description))))}et.displayName="@mantine/spotlight/DefaultAction";w();var Qe=j(t=>({nothingFound:{},actions:{padding:t.spacing.xs/2,borderTop:`1px solid ${t.colorScheme==="dark"?t.colors.dark[4]:t.colors.gray[2]}`},actionsGroup:{textTransform:"uppercase",fontSize:t.spacing.xs,fontWeight:700,padding:"10px 12px",paddingBottom:0,paddingTop:15}})),Yt=Qe;function ot({actions:t,styles:e,classNames:o,actionComponent:i,hovered:l,onActionHover:c,onActionTrigger:m,query:_,nothingFoundMessage:s,highlightQuery:a,highlightColor:d,radius:g}){let{classes:u}=Yt(null,{classNames:o,styles:e,name:"Spotlight"}),h=t.map(v=>v.type==="item"?n.createElement(i,{query:_,key:v.item.id,action:v.item,hovered:v.index===l,onMouseEnter:()=>c(v.index),classNames:o,styles:e,radius:g,onTrigger:()=>m(v.item),highlightQuery:a,highlightColor:d}):n.createElement(S,{className:u.actionsGroup,color:"dimmed",key:v.label},v.label)),b=h.length>0||!!s&&_.trim().length>0;return n.createElement(n.Fragment,null,b&&n.createElement("div",{className:u.actions},h.length>0?h:n.createElement(S,{color:"dimmed",className:u.nothingFound,align:"center",size:"lg",py:"md"},s)))}ot.displayName="@mantine/spotlight/ActionsList";function Ze(t){return Array.isArray(t)?t.map(e=>e.trim()).join(",").toLowerCase().trim():typeof t=="string"?t.toLowerCase().trim():""}function te(t,e){let o=t.trim().toLowerCase(),i=[[],[]];return e.forEach(l=>{var c,m;(c=l.title)!=null&&c.toLowerCase().includes(o)?i[0].push(l):((m=l.description)!=null&&m.toLowerCase().includes(o)||Ze(l.keywords).includes(o))&&i[1].push(l)}),i.flat()}var Ge=Object.defineProperty,Fe=Object.defineProperties,Ke=Object.getOwnPropertyDescriptors,ee=Object.getOwnPropertySymbols,$e=Object.prototype.hasOwnProperty,Xe=Object.prototype.propertyIsEnumerable,oe=(t,e,o)=>e in t?Ge(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,re=(t,e)=>{for(var o in e||(e={}))$e.call(e,o)&&oe(t,o,e[o]);if(ee)for(var o of ee(e))Xe.call(e,o)&&oe(t,o,e[o]);return t},ie=(t,e)=>Fe(t,Ke(e)),qe=j((t,{centered:e,maxWidth:o,topOffset:i,radius:l})=>({root:ie(re({},t.fn.cover()),{position:"fixed"}),spotlight:{position:"relative",zIndex:2,backgroundColor:t.colorScheme==="dark"?t.colors.dark[6]:t.white,borderRadius:t.fn.radius(l),width:"100%",maxWidth:o,overflow:"hidden",marginLeft:"calc(var(--removed-scroll-width, 0px) * -1)"},overlay:ie(re({},t.fn.cover()),{position:"fixed"}),inner:{height:"100vh",display:"flex",flexDirection:"column",paddingTop:e?t.spacing.md:i,justifyContent:e?"center":"flex-start",alignItems:"center"},searchInput:{border:0,borderBottomRightRadius:0,borderBottomLeftRadius:0,backgroundColor:t.colorScheme==="dark"?t.colors.dark[6]:t.white}})),ne=qe;var Je=Object.defineProperty,K=Object.getOwnPropertySymbols,se=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable,ae=(t,e,o)=>e in t?Je(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,Ye=(t,e)=>{for(var o in e||(e={}))se.call(e,o)&&ae(t,o,e[o]);if(K)for(var o of K(e))le.call(e,o)&&ae(t,o,e[o]);return t},to=(t,e)=>{var o={};for(var i in t)se.call(t,i)&&e.indexOf(i)<0&&(o[i]=t[i]);if(t!=null&&K)for(var i of K(t))e.indexOf(i)<0&&le.call(t,i)&&(o[i]=t[i]);return o};function rt(t){var e=t,{query:o,onQueryChange:i,actions:l,onClose:c,opened:m,withinPortal:_,transition:s="pop",transitionDuration:a,classNames:d,styles:g,overlayColor:u="#000",overlayOpacity:h=.25,overlayBlur:b=3,shadow:v="md",radius:E="sm",centered:X=!1,closeOnActionTrigger:B=!0,highlightQuery:I=!1,highlightColor:T,maxWidth:M=600,topOffset:D=120,className:q,searchPlaceholder:H,searchIcon:R,filter:fe=te,nothingFoundMessage:he,limit:_e=10,actionComponent:ve=et,actionsWrapperComponent:ye="div",zIndex:be=dt("modal")}=e,Ce=to(e,["query","onQueryChange","actions","onClose","opened","withinPortal","transition","transitionDuration","classNames","styles","overlayColor","overlayOpacity","overlayBlur","shadow","radius","centered","closeOnActionTrigger","highlightQuery","highlightColor","maxWidth","topOffset","className","searchPlaceholder","searchIcon","filter","nothingFoundMessage","limit","actionComponent","actionsWrapperComponent","zIndex"]);let[z,k]=x(-1),[xe,at]=x(!1),{classes:P,cx:we}=ne({centered:X,maxWidth:M,topOffset:D,radius:E},{classNames:d,styles:g,name:"Spotlight"}),[,st]=ht(),Se=gt(m),J=()=>k(-1),W=()=>{J(),c()};mt({transitionDuration:0,opened:m});let ke=fe(o,l).slice(0,_e),lt=ut(ke).items,L=lt.map(f=>f.type==="item"?f.item:void 0).filter(f=>f);U(()=>{L.length-1<z&&k(L.length-1)},[L.length]);let Le=f=>{var A;if(!xe)switch(f.code){case"ArrowDown":{f.preventDefault(),k(y=>y<L.length-1?y+1:0);break}case"ArrowUp":{f.preventDefault(),k(y=>y>0?y-1:L.length-1);break}case"Enter":{f.preventDefault();let y=L[z];(A=y?.onTrigger)==null||A.call(y,y),B&&y?.onTrigger&&W();break}case"Escape":f.preventDefault(),W()}},Oe=f=>{i(f.currentTarget.value),z===-1&&k(0)};return n.createElement(St,{withinPortal:_,zIndex:be},n.createElement(kt,{onExited:()=>st(!1),onEntered:()=>st(!0),mounted:m,transitions:{spotlight:{duration:a,transition:s,timingFunction:"ease"},overlay:{duration:a/2,transition:"fade",timingFunction:"ease"}}},f=>n.createElement("div",Ye({className:we(P.root,q)},Ce),n.createElement("div",{className:P.inner,ref:Se},n.createElement(bt,{style:f.spotlight,className:P.spotlight,shadow:v,radius:E,onMouseLeave:J},n.createElement(jt,{value:o,onChange:Oe,onKeyDown:Le,onCompositionStart:()=>at(!0),onCompositionEnd:()=>at(!1),classNames:{input:P.searchInput},size:"lg",placeholder:H,icon:R,onMouseEnter:J,autoComplete:"chrome-please-just-do-not-show-it-thanks"}),n.createElement(ye,null,n.createElement(ot,{highlightQuery:I,highlightColor:T,actions:lt,actionComponent:ve,hovered:z,query:o,nothingFoundMessage:he,onActionHover:k,onActionTrigger:A=>{A.onTrigger(A),B&&W()},styles:g,classNames:d,radius:E}))),n.createElement("div",{style:f.overlay},n.createElement(Lt,{className:P.overlay,zIndex:1,onMouseDown:W,color:u,opacity:h,blur:b}))))))}rt.displayName="@mantine/spotlight/Spotlight";w();var it={open:"mantine:open-spotlight",close:"mantine:close-spotlight",toggle:"mantine:toggle-spotlight",triggerAction:"mantine:trigger-spotlight-action",registerActions:"mantine:register-spotlight-actions",removeActions:"mantine:remove-spotlight-actions"};function eo(t,e){return new CustomEvent(t,{detail:e})}function nt(){window.dispatchEvent(eo(it.open))}function ce(t){let e={registerActions:o=>t.registerActions(o.detail),removeActions:o=>t.removeActions(o.detail),triggerAction:o=>t.triggerAction(o.detail),open:t.openSpotlight,close:t.closeSpotlight,toggle:t.toggleSpotlight};O(()=>(Object.keys(e).forEach(o=>{window.addEventListener(it[o],e[o])}),()=>{Object.keys(e).forEach(o=>{window.removeEventListener(it[o],e[o])})}),[])}var oo=Object.defineProperty,$=Object.getOwnPropertySymbols,de=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable,pe=(t,e,o)=>e in t?oo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,ro=(t,e)=>{for(var o in e||(e={}))de.call(e,o)&&pe(t,o,e[o]);if($)for(var o of $(e))ue.call(e,o)&&pe(t,o,e[o]);return t},io=(t,e)=>{var o={};for(var i in t)de.call(t,i)&&e.indexOf(i)<0&&(o[i]=t[i]);if(t!=null&&$)for(var i of $(t))e.indexOf(i)<0&&ue.call(t,i)&&(o[i]=t[i]);return o};function me(t){var e=t,{actions:o,children:i,shortcut:l="mod + K",onSpotlightClose:c,onSpotlightOpen:m,onQueryChange:_,cleanQueryOnClose:s=!0,transitionDuration:a=150}=e,d=io(e,["actions","children","shortcut","onSpotlightClose","onSpotlightOpen","onQueryChange","cleanQueryOnClose","transitionDuration"]);let g=pt(-1),[u,h]=x(""),[b,{registerActions:v,updateActions:E,removeActions:X,triggerAction:B}]=Ft(o,u);U(()=>{E(o)},[o]);let I=R=>{h(R),_?.(R)},[T,{open:M,close:D,toggle:q}]=vt(!1,{onClose:()=>{c?.(),s&&(g.current=window.setTimeout(()=>{I("")},a))},onOpen:()=>{m?.(),window.clearTimeout(g.current)}}),H={openSpotlight:M,closeSpotlight:D,toggleSpotlight:q,registerActions:v,removeActions:X,triggerAction:B,opened:T,actions:b,query:u};return Kt(l,M),ce(H),n.createElement(Qt.Provider,{value:H},n.createElement(rt,ro({actions:b,onClose:D,opened:T,query:u,onQueryChange:I,transitionDuration:a},d)),i)}me.displayName="@mantine/spotlight/SpotlightProvider";je();function ge(t){let[e,o]=x(!1);O(()=>{let l=navigator.userAgentData?.platform??navigator.platform;o(/mac/i.test(l||""))},[]);let i=()=>{nt()};return r("button",{type:"button",className:N("SearchBar",t.className),onClick:i,"aria-label":"Open search",children:[r(zt,{className:"SearchBar__icon",size:16,stroke:1.5}),r("span",{className:"SearchBar__placeholder",children:"Search"}),r("span",{className:"SearchBar__shortcut","aria-hidden":"true",children:e?"\u2318 + K":"Ctrl + K"})]})}var C="1.5";function p(t){return r("div",{className:"Layout",children:[r(p.Top,{}),r(p.Side,{}),r(p.Main,{...t,children:t.children}),r(p.Bottom,{})]})}function no(t){let o=t.split("?")[0].replace(/\/+$/g,"").split("/").filter(Boolean);return o.length===4&&o[0]==="cms"&&o[1]==="content"}p.Top=()=>{let t=window.__ROOT_CTX.rootConfig,e=t.projectName||t.projectId,o=t.minimalBranding,{url:i}=Y(),l=!no(i);return r("div",{className:"Layout__top",children:[o?r(V,{children:[r("a",{className:"Layout__top__logo",href:"/cms",children:e}),r("a",{className:"Layout__top__version",href:"https://github.com/blinkk/rootjs/blob/main/packages/root-cms/CHANGELOG.md",target:"_blank",rel:"noreferrer noopener",children:["v",tt.version]})]}):r(V,{children:[r("a",{className:"Layout__top__logo",href:"/cms",children:r(Ut,{})}),r("a",{className:"Layout__top__version",href:"https://github.com/blinkk/rootjs/blob/main/packages/root-cms/CHANGELOG.md",target:"_blank",rel:"noreferrer noopener",children:["v",tt.version]}),r("div",{className:"Layout__top__project",children:e})]}),l&&r("div",{className:"Layout__top__search",children:r(ge,{})})]})};p.Side=()=>{let{url:t}=Y(),e=t.replace(/\/*$/g,""),o=window.firebase.user,i=window.__ROOT_CTX.sidebar?.tools,l=new Set(window.__ROOT_CTX.sidebar?.hiddenBuiltInTools||[]),c=s=>l.has(s),m=window.__ROOT_CTX.experiments||{},_=async()=>{await window.firebase.auth.signOut(),window.location.href="/cms/login"};return r("div",{className:"Layout__side",children:[r("div",{className:"Layout__side__buttons",children:[!c("home")&&r(p.SideButton,{label:"Home",url:"/cms",active:e==="/cms",children:r(It,{stroke:C})}),!c("content")&&r(p.SideButton,{label:"Content",url:"/cms/content",active:e.startsWith("/cms/content"),children:r(Bt,{stroke:C})}),m.taskManager&&r(p.SideButton,{label:"Tasks",url:"/cms/tasks",active:e.startsWith("/cms/tasks"),children:r(At,{stroke:C})}),!c("releases")&&r(p.SideButton,{label:"Releases",url:"/cms/releases",active:e.startsWith("/cms/releases"),children:r(Rt,{stroke:C})}),!c("data")&&r(p.SideButton,{label:"Data",url:"/cms/data",active:e.startsWith("/cms/data"),children:r(Nt,{stroke:C})}),!c("assets")&&r(p.SideButton,{label:"Asset Library",url:"/cms/assets",active:e.startsWith("/cms/assets"),children:r(Dt,{stroke:C})}),!c("translations")&&r(p.SideButton,{label:"Translations",url:"/cms/translations",active:e.startsWith("/cms/translations"),children:r(Tt,{stroke:C})}),Vt()&&!c("ai")&&r(p.SideButton,{label:"Root AI",url:"/cms/ai",active:e.startsWith("/cms/ai"),children:r(Ht,{stroke:C})}),i&&r(V,{children:[r("div",{className:"Layout__side__divider"}),Object.entries(i).map(([s,a])=>{let d=a.cmsUrl?.startsWith("/cms/")?a.cmsUrl:void 0,g=a.externalUrl,u=g??d??`/cms/tools/${s}`,h=g?void 0:u.replace(/\/*$/g,""),b=!g&&!!h&&(e===h||e.startsWith(`${h}/`));return r(p.SideButton,{className:"Layout__side__tool",label:a.label||"",url:u,active:b,external:!!g,children:a.icon?r("img",{className:"Layout__side__tool__icon",src:a.icon,alt:a.label||""}):r(Pt,{stroke:C})},s)}),r("div",{className:"Layout__side__divider"})]}),!c("settings")&&r(p.SideButton,{label:"Settings",url:"/cms/settings",active:e.startsWith("/cms/settings"),children:r(Wt,{stroke:C})})]}),r("div",{className:"Layout__side__user",children:r(Z,{shadow:"md",position:"right",control:r(Q,{children:r(xt,{src:o.photoURL,alt:o.email,size:30,radius:"xl"})}),children:[r(Z.Label,{children:r(S,{size:"xs",color:"dimmed",truncate:!0,children:["Signed in as ",o.email]})}),r(Ct,{}),r(Z.Item,{color:"red",icon:r(Mt,{style:{width:14,height:14}}),onClick:_,children:"Sign out"})]})})]})};p.SideButton=t=>r(Et,{className:N("Layout__side__button",t.className),label:t.label,position:"right",withArrow:!0,children:r("a",{className:N(t.active&&"active"),href:t.url,target:t.external?"_blank":void 0,rel:t.external?"noreferrer noopener":void 0,children:t.children})});p.Main=t=>r("div",{className:"Layout__main",children:t.children});p.Bottom=()=>r("div",{className:"Layout__bottom"});export{nt as a,me as b,p as c};
1
+ import{a as Vt}from"./chunk-AAHM6RYJ.js";import{d as Y,e as N}from"./chunk-WASID5UU.js";import{Bc as Ht,C as dt,Cc as Rt,D as j,E as ut,Fa as Et,G as U,Ga as r,Gc as zt,H as mt,I as gt,Jb as Bt,Jc as Wt,K as ft,O as ht,P as _t,Q as vt,S as Q,Sb as It,T as yt,Xb as Tt,Y as S,Z as bt,_ as Ct,_a as Pt,a as x,aa as xt,c as O,e as pt,fa as wt,ha as St,ia as kt,ib as At,ic as Mt,j as je,ja as Lt,ka as Ot,qa as Z,sb as Nt,tc as Dt,ua as jt,v as n,y as w}from"./chunk-WRA24P66.js";import{d as V,j as ct}from"./chunk-KUCVLANF.js";var tt={name:"@blinkk/root-cms",version:"3.1.6",author:"s@blinkk.com",license:"MIT",engines:{node:">=22.0.0"},repository:{type:"git",url:"git+https://github.com/blinkk/rootjs.git",directory:"packages/root-cms"},files:["dist/**/*"],bin:{"root-cms":"./bin/root-cms.js"},type:"module",module:"./dist/core.js",types:"./dist/core/core.d.ts",exports:{".":{types:"./dist/core/core.d.ts",import:"./dist/core.js"},"./browser-client":{types:"./dist/browser-client/browser-client.d.ts",import:"./dist/browser-client.js"},"./client":{types:"./dist/core/client.d.ts",import:"./dist/client.js"},"./core":{types:"./dist/core/core.d.ts",import:"./dist/core.js"},"./functions":{types:"./dist/core/functions.d.ts",import:"./dist/functions.js"},"./plugin":{types:"./dist/core/plugin.d.ts",import:"./dist/plugin.js"},"./project":{types:"./dist/core/project.d.ts",import:"./dist/project.js"},"./richtext":{types:"./dist/core/richtext.d.ts",import:"./dist/richtext.js"}},scripts:{build:'rm -rf dist && concurrently -n "core,signin,ui" npm:build:core npm:build:signin npm:build:ui',"build:core":"node ../../scripts/build-esbuild.mjs ./esbuild.config.json","build:ui":"pnpm build:ui:bundle && pnpm build:ui:clean","build:ui:bundle":"esbuild ui/ui.tsx --bundle --minify --alias:react=@preact/compat --alias:react-dom=@preact/compat --tsconfig=ui/tsconfig.json --outdir=dist/ui --legal-comments=external --splitting --format=esm","build:ui:clean":"rm -f dist/ui/*-*.css","build:signin":"esbuild signin/signin.tsx --bundle --minify --tsconfig=signin/tsconfig.json --outdir=dist/ui --legal-comments=external",dev:'rm -rf dist && concurrently -k -n "core,ui" npm:dev:core npm:dev:signin npm:dev:ui',"dev:core":"pnpm build:core --watch","dev:signin":"pnpm build:signin --watch","dev:ui":"pnpm build:ui:bundle --watch",test:"pnpm build && firebase emulators:exec 'vitest run --exclude=**/*.visual.test.tsx'","test:visual":"vitest run --config=vitest.config.visual.ts","test:watch":"pnpm build && firebase emulators:exec 'vitest'"},dependencies:{"@ag-grid-community/client-side-row-model":"32.3.9","@ag-grid-community/core":"32.3.9","@ag-grid-community/react":"32.3.9","@ag-grid-community/styles":"32.3.9","@ai-sdk/anthropic":"3.0.74","@ai-sdk/google":"3.0.67","@ai-sdk/openai":"3.0.60","@ai-sdk/openai-compatible":"2.0.46","@ai-sdk/react":"3.0.177","@google-cloud/firestore":"7.11.3","@hello-pangea/dnd":"18.0.1","@mantine/spotlight":"4.2.12","@types/cli-progress":"3.11.6",ai:"6.0.175","body-parser":"1.20.2","cli-progress":"3.12.0",commander:"11.0.0","csv-parse":"5.5.2","csv-stringify":"6.4.4","date-fns":"4.1.0","date-fns-tz":"3.2.0",diff:"8.0.2","dts-dom":"3.7.0","fnv-plus":"1.3.1",jsonwebtoken:"9.0.2",kleur:"4.1.5",minisearch:"7.2.0","sanitize-html":"2.13.1",sirv:"2.0.3","tiny-glob":"0.2.9",zod:"4.4.3"},"//":"NOTE(stevenle): due to compat issues with mantine and preact, mantine is pinned to v4.2.12",devDependencies:{"@babel/core":"7.17.9","@blinkk/root":"workspace:*","@editorjs/editorjs":"2.30.8","@editorjs/header":"2.8.8","@editorjs/image":"2.10.2","@editorjs/list":"2.0.6","@editorjs/nested-list":"1.4.3","@editorjs/raw":"2.5.1","@editorjs/table":"2.4.4","@editorjs/underline":"1.2.1","@emotion/react":"11.10.5","@firebase/app-compat":"0.5.2","@firebase/app-types":"0.9.3","@firebase/rules-unit-testing":"5.0.0","@lexical/code":"0.33.1","@lexical/html":"0.33.1","@lexical/link":"0.33.1","@lexical/list":"0.33.1","@lexical/markdown":"0.33.1","@lexical/react":"0.33.1","@lexical/rich-text":"0.33.1","@lexical/selection":"0.33.1","@lexical/table":"0.33.1","@lexical/utils":"0.33.1","@mantine/core":"4.2.12","@mantine/hooks":"4.2.12","@mantine/modals":"4.2.12","@mantine/notifications":"4.2.12","@preact/compat":"18.3.1","@tabler/icons-preact":"3.35.0","@testing-library/preact":"3.2.4","@testing-library/user-event":"14.6.1","@types/body-parser":"1.19.3","@types/fnv-plus":"1.3.2","@types/gapi":"0.0.47","@types/gapi.client.drive-v3":"0.0.4","@types/gapi.client.sheets-v4":"0.0.4","@types/google.accounts":"0.0.14","@types/jsonwebtoken":"9.0.1","@types/node":"24.3.1","@types/sanitize-html":"2.13.0","@vitest/browser":"4.1.8","@vitest/browser-playwright":"4.1.8",concurrently:"7.6.0",esbuild:"0.28.0",firebase:"12.2.1","firebase-admin":"13.5.0","firebase-functions":"6.4.0","firebase-tools":"14.15.2","highlight.js":"11.6.0",jsdom:"27.2.0","json-diff-kit":"1.0.29",lexical:"0.33.1",marked:"9.1.1","mdast-util-from-markdown":"2.0.1","mdast-util-gfm":"3.0.0","micromark-extension-gfm":"3.0.0",playwright:"1.60.0",preact:"10.27.1","preact-iso":"2.11.1","preact-render-to-string":"6.6.7",react:"npm:@preact/compat@18.3.1","react-dom":"npm:@preact/compat@18.3.1","react-easy-crop":"5.5.6","react-json-view-compare":"2.0.2",typescript:"6.0.3",vite:"8.0.13",vitest:"4.1.6",yjs:"13.6.27"},peerDependencies:{"@blinkk/root":"3.1.6","firebase-admin":">=11","firebase-functions":">=4"},peerDependenciesMeta:{"firebase-functions":{optional:!0}}};function Ut(){return r("svg",{width:"100",height:"23",viewBox:"0 0 100 23",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r("g",{"clip-path":"url(#clip0_1_318)",children:[r("path",{d:"M7.82998 5.01802C3.12925 5.6479 0.833937 18.1194 2.62578 19.6731C5.64773 22.2934 16.6441 14.1722 15.6786 9.46913C15.3009 6.61371 11.2717 4.28377 7.82998 5.01802Z",fill:"black"}),r("path",{d:"M13.9782 0.720147C12.6553 0.896474 12.0093 4.38767 12.5136 4.8226C13.364 5.55611 16.4587 3.28271 16.187 1.96616C16.0807 1.16683 14.9468 0.514607 13.9782 0.720147Z",fill:"black"}),r("path",{d:"M92.7383 17.6275C90.9681 17.6275 89.3816 17.0263 88.3796 16.0744C87.9955 15.7237 87.8953 15.3396 88.246 14.9555L88.8305 14.2541C89.1645 13.87 89.5486 13.7865 89.9327 14.1205C90.6007 14.6883 91.7029 15.1726 92.5713 15.1726C93.5232 15.1726 94.1244 14.8219 94.1244 14.2875C94.1244 13.5193 93.2059 13.4358 91.9868 13.0684C90.417 12.6008 88.5132 11.7324 88.5132 9.64493C88.5132 7.70773 90.25 6.37173 92.7383 6.37173C94.2413 6.37173 95.5272 6.87273 96.4123 7.57413C96.8131 7.90813 96.9467 8.27553 96.596 8.67633L96.0282 9.37773C95.7109 9.76183 95.3435 9.82863 94.926 9.51133C94.3916 9.09383 93.6568 8.69303 92.7884 8.69303C92.0202 8.69303 91.5192 9.01033 91.5192 9.51133C91.5192 10.1292 92.3041 10.4131 93.1224 10.6636C94.9761 11.2314 97.1304 11.8326 97.1304 14.2708C97.1304 16.4585 95.1264 17.6275 92.7383 17.6275Z",fill:"black"}),r("path",{d:"M87.0008 16.6756C87.0843 17.1766 86.8171 17.4271 86.2994 17.4271H85.097C84.596 17.4271 84.3789 17.1766 84.3121 16.6756L83.7443 11.9161L81.757 16.7424C81.5399 17.2434 81.1892 17.5106 80.6882 17.5106H80.5212C80.0202 17.5106 79.6695 17.2434 79.4524 16.7424L77.4651 11.8994L76.8973 16.6756C76.8472 17.1766 76.6301 17.4271 76.1291 17.4271H74.7263C74.2086 17.4271 73.9414 17.1766 74.0082 16.6756L75.4945 7.24013C75.5613 6.75583 75.8786 6.48863 76.3796 6.48863H76.5466C77.0476 6.48863 77.3315 6.75583 77.5486 7.24013L80.6047 13.8032L83.4938 7.24013C83.7109 6.75583 84.0115 6.48863 84.4958 6.48863H84.6795C85.1638 6.48863 85.4811 6.75583 85.5646 7.24013L87.0008 16.6756Z",fill:"black"}),r("path",{d:"M68.6496 17.6275C65.3096 17.6275 62.7211 15.2227 62.7211 11.9996C62.7211 8.77653 65.3096 6.37173 68.683 6.37173C70.3029 6.37173 71.7558 6.97293 72.7745 7.99163C73.1419 8.34233 73.1419 8.77653 72.7745 9.09383L71.9228 9.81193C71.5554 10.1292 71.2047 10.1125 70.8206 9.79523C70.2361 9.31093 69.5013 9.01033 68.683 9.01033C67.013 9.01033 65.7104 10.2628 65.7104 11.9996C65.7104 13.7364 67.013 14.9889 68.683 14.9889C69.5013 14.9889 70.2528 14.6883 70.8206 14.204C71.2047 13.8867 71.5554 13.87 71.9228 14.1873L72.7745 14.9054C73.1419 15.2227 73.1419 15.6569 72.7745 16.0076C71.7558 17.0263 70.3029 17.6275 68.6496 17.6275Z",fill:"black"}),r("path",{d:"M58.575 16.2915C58.7587 16.6923 58.4581 16.8927 58.241 17.0597C57.7233 17.4271 56.9384 17.6442 56.1201 17.6442C54.4501 17.6442 52.8469 16.6923 52.8469 14.4044V11.0978H52.1121C51.6111 11.0978 51.3439 10.8139 51.3439 10.3296V9.76183C51.3439 9.26083 51.6111 8.99363 52.1121 8.99363H52.8469V7.05643C52.8469 6.57213 53.1308 6.38843 53.6151 6.28823L54.9511 6.05443C55.4521 5.95423 55.7193 6.30493 55.7193 6.80593V8.99363H57.3726C57.8569 8.99363 58.1408 9.26083 58.1408 9.76183V10.3296C58.1408 10.8139 57.8569 11.0978 57.3726 11.0978H55.7193V14.1038C55.7193 14.9221 56.1368 15.1893 56.6545 15.1893C56.905 15.1893 57.1555 15.0724 57.3392 14.9555C57.7567 14.6883 57.9571 14.8887 58.1074 15.206L58.575 16.2915Z",fill:"black"}),r("path",{d:"M46.2592 17.6442C43.5538 17.6442 41.5999 15.7738 41.5999 13.2521C41.5999 10.7304 43.5538 8.86003 46.2592 8.86003C48.9646 8.86003 50.9185 10.7304 50.9185 13.2521C50.9185 15.7738 48.9646 17.6442 46.2592 17.6442ZM46.2592 15.1726C47.3113 15.1726 48.0628 14.3543 48.0628 13.2521C48.0628 12.1499 47.3113 11.3316 46.2592 11.3316C45.2071 11.3316 44.4389 12.1499 44.4389 13.2521C44.4389 14.3543 45.2071 15.1726 46.2592 15.1726Z",fill:"black"}),r("path",{d:"M36.052 17.6442C33.3466 17.6442 31.3927 15.7738 31.3927 13.2521C31.3927 10.7304 33.3466 8.86003 36.052 8.86003C38.7574 8.86003 40.7113 10.7304 40.7113 13.2521C40.7113 15.7738 38.7574 17.6442 36.052 17.6442ZM36.052 15.1726C37.1041 15.1726 37.8556 14.3543 37.8556 13.2521C37.8556 12.1499 37.1041 11.3316 36.052 11.3316C34.9999 11.3316 34.2317 12.1499 34.2317 13.2521C34.2317 14.3543 34.9999 15.1726 36.052 15.1726Z",fill:"black"}),r("path",{d:"M28.7099 13.0851L30.6805 16.6422C30.9644 17.1599 30.6638 17.4271 30.1628 17.4271H28.4594C27.9417 17.4271 27.8081 17.1766 27.5242 16.6589L25.7707 13.4859H24.6351V16.6422C24.6351 17.1432 24.3512 17.4271 23.8502 17.4271H22.4808C21.9798 17.4271 21.6959 17.1432 21.6959 16.6422V7.35703C21.6959 6.85603 21.9798 6.57213 22.4808 6.57213H26.5222C29.3111 6.57213 30.8141 7.92483 30.8141 10.1125C30.8141 11.5654 29.9791 12.5841 28.7099 13.0851ZM24.6351 8.96023V11.5153H26.4721C27.2236 11.5153 27.8248 11.0644 27.8248 10.2628C27.8248 9.44453 27.2236 8.96023 26.4721 8.96023H24.6351Z",fill:"black"})]}),r("defs",{children:r("clipPath",{id:"clip0_1_318",children:r("rect",{width:"99",height:"22",fill:"white",transform:"translate(0.0175781 0.177246)"})})})]})}w();var Qt=ct(null);w();w();var Pe=Object.defineProperty,Ae=Object.defineProperties,Ne=Object.getOwnPropertyDescriptors,Zt=Object.getOwnPropertySymbols,Be=Object.prototype.hasOwnProperty,Ie=Object.prototype.propertyIsEnumerable,Gt=(t,e,o)=>e in t?Pe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,Te=(t,e)=>{for(var o in e||(e={}))Be.call(e,o)&&Gt(t,o,e[o]);if(Zt)for(var o of Zt(e))Ie.call(e,o)&&Gt(t,o,e[o]);return t},Me=(t,e)=>Ae(t,Ne(e));function De(t){return Me(Te({},t),{id:t.id||ft()})}function He(t){let e=[];return t.reduceRight((o,i)=>(e.includes(i.id)||(e.push(i.id),o.push(i)),o),[]).reverse()}function G(t){return He(t.map(e=>De(e)))}function Ft(t,e){let[o,i]=x(G(typeof t=="function"?t(e):t));return O(()=>{typeof t=="function"&&i(G(t(e)))},[e]),[o,{registerActions:s=>i(a=>G([...a,...s])),updateActions:s=>i(G(typeof s=="function"?s(e):s)),removeActions:s=>i(a=>a.filter(d=>!s.includes(d.id))),triggerAction:s=>{var a;let d=o.find(g=>g.id===s);(a=d?.onTrigger)==null||a.call(d,d)}}]}function Re(t,e){return t===null?[]:Array.isArray(t)?t.map(o=>[o,e]):[[t,e]]}function Kt(t,e){_t(Re(t,e))}w();w();var ze=j((t,{radius:e})=>({action:{position:"relative",display:"block",width:"100%",padding:"10px 12px",borderRadius:t.fn.radius(e)},actionHovered:{backgroundColor:t.colorScheme==="dark"?t.colors.dark[4]:t.colors.gray[1]},actionIcon:{color:t.colorScheme==="dark"?t.colors.dark[2]:t.colors.gray[6]},actionBody:{flex:1}})),$t=ze;var We=Object.defineProperty,F=Object.getOwnPropertySymbols,qt=Object.prototype.hasOwnProperty,Jt=Object.prototype.propertyIsEnumerable,Xt=(t,e,o)=>e in t?We(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,Ve=(t,e)=>{for(var o in e||(e={}))qt.call(e,o)&&Xt(t,o,e[o]);if(F)for(var o of F(e))Jt.call(e,o)&&Xt(t,o,e[o]);return t},Ue=(t,e)=>{var o={};for(var i in t)qt.call(t,i)&&e.indexOf(i)<0&&(o[i]=t[i]);if(t!=null&&F)for(var i of F(t))e.indexOf(i)<0&&Jt.call(t,i)&&(o[i]=t[i]);return o};function et(t){var e=t,{action:o,styles:i,classNames:l,hovered:c,onTrigger:m,highlightQuery:_,highlightColor:s,query:a,radius:d}=e,g=Ue(e,["action","styles","classNames","hovered","onTrigger","highlightQuery","highlightColor","query","radius"]);let{classes:u,cx:h}=$t({radius:d},{styles:i,classNames:l,name:"Spotlight"});return n.createElement(Q,Ve({className:h(u.action,{[u.actionHovered]:c}),tabIndex:-1,onMouseDown:b=>b.preventDefault(),onClick:m},g),n.createElement(wt,{noWrap:!0},o.icon&&n.createElement(yt,{className:u.actionIcon},o.icon),n.createElement("div",{className:u.actionBody},n.createElement(Ot,{highlightColor:s,highlight:_?a:null},o.title),o.description&&n.createElement(S,{color:"dimmed",size:"xs"},o.description))))}et.displayName="@mantine/spotlight/DefaultAction";w();var Qe=j(t=>({nothingFound:{},actions:{padding:t.spacing.xs/2,borderTop:`1px solid ${t.colorScheme==="dark"?t.colors.dark[4]:t.colors.gray[2]}`},actionsGroup:{textTransform:"uppercase",fontSize:t.spacing.xs,fontWeight:700,padding:"10px 12px",paddingBottom:0,paddingTop:15}})),Yt=Qe;function ot({actions:t,styles:e,classNames:o,actionComponent:i,hovered:l,onActionHover:c,onActionTrigger:m,query:_,nothingFoundMessage:s,highlightQuery:a,highlightColor:d,radius:g}){let{classes:u}=Yt(null,{classNames:o,styles:e,name:"Spotlight"}),h=t.map(v=>v.type==="item"?n.createElement(i,{query:_,key:v.item.id,action:v.item,hovered:v.index===l,onMouseEnter:()=>c(v.index),classNames:o,styles:e,radius:g,onTrigger:()=>m(v.item),highlightQuery:a,highlightColor:d}):n.createElement(S,{className:u.actionsGroup,color:"dimmed",key:v.label},v.label)),b=h.length>0||!!s&&_.trim().length>0;return n.createElement(n.Fragment,null,b&&n.createElement("div",{className:u.actions},h.length>0?h:n.createElement(S,{color:"dimmed",className:u.nothingFound,align:"center",size:"lg",py:"md"},s)))}ot.displayName="@mantine/spotlight/ActionsList";function Ze(t){return Array.isArray(t)?t.map(e=>e.trim()).join(",").toLowerCase().trim():typeof t=="string"?t.toLowerCase().trim():""}function te(t,e){let o=t.trim().toLowerCase(),i=[[],[]];return e.forEach(l=>{var c,m;(c=l.title)!=null&&c.toLowerCase().includes(o)?i[0].push(l):((m=l.description)!=null&&m.toLowerCase().includes(o)||Ze(l.keywords).includes(o))&&i[1].push(l)}),i.flat()}var Ge=Object.defineProperty,Fe=Object.defineProperties,Ke=Object.getOwnPropertyDescriptors,ee=Object.getOwnPropertySymbols,$e=Object.prototype.hasOwnProperty,Xe=Object.prototype.propertyIsEnumerable,oe=(t,e,o)=>e in t?Ge(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,re=(t,e)=>{for(var o in e||(e={}))$e.call(e,o)&&oe(t,o,e[o]);if(ee)for(var o of ee(e))Xe.call(e,o)&&oe(t,o,e[o]);return t},ie=(t,e)=>Fe(t,Ke(e)),qe=j((t,{centered:e,maxWidth:o,topOffset:i,radius:l})=>({root:ie(re({},t.fn.cover()),{position:"fixed"}),spotlight:{position:"relative",zIndex:2,backgroundColor:t.colorScheme==="dark"?t.colors.dark[6]:t.white,borderRadius:t.fn.radius(l),width:"100%",maxWidth:o,overflow:"hidden",marginLeft:"calc(var(--removed-scroll-width, 0px) * -1)"},overlay:ie(re({},t.fn.cover()),{position:"fixed"}),inner:{height:"100vh",display:"flex",flexDirection:"column",paddingTop:e?t.spacing.md:i,justifyContent:e?"center":"flex-start",alignItems:"center"},searchInput:{border:0,borderBottomRightRadius:0,borderBottomLeftRadius:0,backgroundColor:t.colorScheme==="dark"?t.colors.dark[6]:t.white}})),ne=qe;var Je=Object.defineProperty,K=Object.getOwnPropertySymbols,se=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable,ae=(t,e,o)=>e in t?Je(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,Ye=(t,e)=>{for(var o in e||(e={}))se.call(e,o)&&ae(t,o,e[o]);if(K)for(var o of K(e))le.call(e,o)&&ae(t,o,e[o]);return t},to=(t,e)=>{var o={};for(var i in t)se.call(t,i)&&e.indexOf(i)<0&&(o[i]=t[i]);if(t!=null&&K)for(var i of K(t))e.indexOf(i)<0&&le.call(t,i)&&(o[i]=t[i]);return o};function rt(t){var e=t,{query:o,onQueryChange:i,actions:l,onClose:c,opened:m,withinPortal:_,transition:s="pop",transitionDuration:a,classNames:d,styles:g,overlayColor:u="#000",overlayOpacity:h=.25,overlayBlur:b=3,shadow:v="md",radius:E="sm",centered:X=!1,closeOnActionTrigger:B=!0,highlightQuery:I=!1,highlightColor:T,maxWidth:M=600,topOffset:D=120,className:q,searchPlaceholder:H,searchIcon:R,filter:fe=te,nothingFoundMessage:he,limit:_e=10,actionComponent:ve=et,actionsWrapperComponent:ye="div",zIndex:be=dt("modal")}=e,Ce=to(e,["query","onQueryChange","actions","onClose","opened","withinPortal","transition","transitionDuration","classNames","styles","overlayColor","overlayOpacity","overlayBlur","shadow","radius","centered","closeOnActionTrigger","highlightQuery","highlightColor","maxWidth","topOffset","className","searchPlaceholder","searchIcon","filter","nothingFoundMessage","limit","actionComponent","actionsWrapperComponent","zIndex"]);let[z,k]=x(-1),[xe,at]=x(!1),{classes:P,cx:we}=ne({centered:X,maxWidth:M,topOffset:D,radius:E},{classNames:d,styles:g,name:"Spotlight"}),[,st]=ht(),Se=gt(m),J=()=>k(-1),W=()=>{J(),c()};mt({transitionDuration:0,opened:m});let ke=fe(o,l).slice(0,_e),lt=ut(ke).items,L=lt.map(f=>f.type==="item"?f.item:void 0).filter(f=>f);U(()=>{L.length-1<z&&k(L.length-1)},[L.length]);let Le=f=>{var A;if(!xe)switch(f.code){case"ArrowDown":{f.preventDefault(),k(y=>y<L.length-1?y+1:0);break}case"ArrowUp":{f.preventDefault(),k(y=>y>0?y-1:L.length-1);break}case"Enter":{f.preventDefault();let y=L[z];(A=y?.onTrigger)==null||A.call(y,y),B&&y?.onTrigger&&W();break}case"Escape":f.preventDefault(),W()}},Oe=f=>{i(f.currentTarget.value),z===-1&&k(0)};return n.createElement(St,{withinPortal:_,zIndex:be},n.createElement(kt,{onExited:()=>st(!1),onEntered:()=>st(!0),mounted:m,transitions:{spotlight:{duration:a,transition:s,timingFunction:"ease"},overlay:{duration:a/2,transition:"fade",timingFunction:"ease"}}},f=>n.createElement("div",Ye({className:we(P.root,q)},Ce),n.createElement("div",{className:P.inner,ref:Se},n.createElement(bt,{style:f.spotlight,className:P.spotlight,shadow:v,radius:E,onMouseLeave:J},n.createElement(jt,{value:o,onChange:Oe,onKeyDown:Le,onCompositionStart:()=>at(!0),onCompositionEnd:()=>at(!1),classNames:{input:P.searchInput},size:"lg",placeholder:H,icon:R,onMouseEnter:J,autoComplete:"chrome-please-just-do-not-show-it-thanks"}),n.createElement(ye,null,n.createElement(ot,{highlightQuery:I,highlightColor:T,actions:lt,actionComponent:ve,hovered:z,query:o,nothingFoundMessage:he,onActionHover:k,onActionTrigger:A=>{A.onTrigger(A),B&&W()},styles:g,classNames:d,radius:E}))),n.createElement("div",{style:f.overlay},n.createElement(Lt,{className:P.overlay,zIndex:1,onMouseDown:W,color:u,opacity:h,blur:b}))))))}rt.displayName="@mantine/spotlight/Spotlight";w();var it={open:"mantine:open-spotlight",close:"mantine:close-spotlight",toggle:"mantine:toggle-spotlight",triggerAction:"mantine:trigger-spotlight-action",registerActions:"mantine:register-spotlight-actions",removeActions:"mantine:remove-spotlight-actions"};function eo(t,e){return new CustomEvent(t,{detail:e})}function nt(){window.dispatchEvent(eo(it.open))}function ce(t){let e={registerActions:o=>t.registerActions(o.detail),removeActions:o=>t.removeActions(o.detail),triggerAction:o=>t.triggerAction(o.detail),open:t.openSpotlight,close:t.closeSpotlight,toggle:t.toggleSpotlight};O(()=>(Object.keys(e).forEach(o=>{window.addEventListener(it[o],e[o])}),()=>{Object.keys(e).forEach(o=>{window.removeEventListener(it[o],e[o])})}),[])}var oo=Object.defineProperty,$=Object.getOwnPropertySymbols,de=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable,pe=(t,e,o)=>e in t?oo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,ro=(t,e)=>{for(var o in e||(e={}))de.call(e,o)&&pe(t,o,e[o]);if($)for(var o of $(e))ue.call(e,o)&&pe(t,o,e[o]);return t},io=(t,e)=>{var o={};for(var i in t)de.call(t,i)&&e.indexOf(i)<0&&(o[i]=t[i]);if(t!=null&&$)for(var i of $(t))e.indexOf(i)<0&&ue.call(t,i)&&(o[i]=t[i]);return o};function me(t){var e=t,{actions:o,children:i,shortcut:l="mod + K",onSpotlightClose:c,onSpotlightOpen:m,onQueryChange:_,cleanQueryOnClose:s=!0,transitionDuration:a=150}=e,d=io(e,["actions","children","shortcut","onSpotlightClose","onSpotlightOpen","onQueryChange","cleanQueryOnClose","transitionDuration"]);let g=pt(-1),[u,h]=x(""),[b,{registerActions:v,updateActions:E,removeActions:X,triggerAction:B}]=Ft(o,u);U(()=>{E(o)},[o]);let I=R=>{h(R),_?.(R)},[T,{open:M,close:D,toggle:q}]=vt(!1,{onClose:()=>{c?.(),s&&(g.current=window.setTimeout(()=>{I("")},a))},onOpen:()=>{m?.(),window.clearTimeout(g.current)}}),H={openSpotlight:M,closeSpotlight:D,toggleSpotlight:q,registerActions:v,removeActions:X,triggerAction:B,opened:T,actions:b,query:u};return Kt(l,M),ce(H),n.createElement(Qt.Provider,{value:H},n.createElement(rt,ro({actions:b,onClose:D,opened:T,query:u,onQueryChange:I,transitionDuration:a},d)),i)}me.displayName="@mantine/spotlight/SpotlightProvider";je();function ge(t){let[e,o]=x(!1);O(()=>{let l=navigator.userAgentData?.platform??navigator.platform;o(/mac/i.test(l||""))},[]);let i=()=>{nt()};return r("button",{type:"button",className:N("SearchBar",t.className),onClick:i,"aria-label":"Open search",children:[r(zt,{className:"SearchBar__icon",size:16,stroke:1.5}),r("span",{className:"SearchBar__placeholder",children:"Search"}),r("span",{className:"SearchBar__shortcut","aria-hidden":"true",children:e?"\u2318 + K":"Ctrl + K"})]})}var C="1.5";function p(t){return r("div",{className:"Layout",children:[r(p.Top,{}),r(p.Side,{}),r(p.Main,{...t,children:t.children}),r(p.Bottom,{})]})}function no(t){let o=t.split("?")[0].replace(/\/+$/g,"").split("/").filter(Boolean);return o.length===4&&o[0]==="cms"&&o[1]==="content"}p.Top=()=>{let t=window.__ROOT_CTX.rootConfig,e=t.projectName||t.projectId,o=t.minimalBranding,{url:i}=Y(),l=!no(i);return r("div",{className:"Layout__top",children:[o?r(V,{children:[r("a",{className:"Layout__top__logo",href:"/cms",children:e}),r("a",{className:"Layout__top__version",href:"https://github.com/blinkk/rootjs/blob/main/packages/root-cms/CHANGELOG.md",target:"_blank",rel:"noreferrer noopener",children:["v",tt.version]})]}):r(V,{children:[r("a",{className:"Layout__top__logo",href:"/cms",children:r(Ut,{})}),r("a",{className:"Layout__top__version",href:"https://github.com/blinkk/rootjs/blob/main/packages/root-cms/CHANGELOG.md",target:"_blank",rel:"noreferrer noopener",children:["v",tt.version]}),r("div",{className:"Layout__top__project",children:e})]}),l&&r("div",{className:"Layout__top__search",children:r(ge,{})})]})};p.Side=()=>{let{url:t}=Y(),e=t.replace(/\/*$/g,""),o=window.firebase.user,i=window.__ROOT_CTX.sidebar?.tools,l=new Set(window.__ROOT_CTX.sidebar?.hiddenBuiltInTools||[]),c=s=>l.has(s),m=window.__ROOT_CTX.experiments||{},_=async()=>{await window.firebase.auth.signOut(),window.location.href="/cms/login"};return r("div",{className:"Layout__side",children:[r("div",{className:"Layout__side__buttons",children:[!c("home")&&r(p.SideButton,{label:"Home",url:"/cms",active:e==="/cms",children:r(It,{stroke:C})}),!c("content")&&r(p.SideButton,{label:"Content",url:"/cms/content",active:e.startsWith("/cms/content"),children:r(Bt,{stroke:C})}),m.taskManager&&r(p.SideButton,{label:"Tasks",url:"/cms/tasks",active:e.startsWith("/cms/tasks"),children:r(At,{stroke:C})}),!c("releases")&&r(p.SideButton,{label:"Releases",url:"/cms/releases",active:e.startsWith("/cms/releases"),children:r(Rt,{stroke:C})}),!c("data")&&r(p.SideButton,{label:"Data",url:"/cms/data",active:e.startsWith("/cms/data"),children:r(Nt,{stroke:C})}),!c("assets")&&r(p.SideButton,{label:"Asset Library",url:"/cms/assets",active:e.startsWith("/cms/assets"),children:r(Dt,{stroke:C})}),!c("translations")&&r(p.SideButton,{label:"Translations",url:"/cms/translations",active:e.startsWith("/cms/translations"),children:r(Tt,{stroke:C})}),Vt()&&!c("ai")&&r(p.SideButton,{label:"Root AI",url:"/cms/ai",active:e.startsWith("/cms/ai"),children:r(Ht,{stroke:C})}),i&&r(V,{children:[r("div",{className:"Layout__side__divider"}),Object.entries(i).map(([s,a])=>{let d=a.cmsUrl?.startsWith("/cms/")?a.cmsUrl:void 0,g=a.externalUrl,u=g??d??`/cms/tools/${s}`,h=g?void 0:u.replace(/\/*$/g,""),b=!g&&!!h&&(e===h||e.startsWith(`${h}/`));return r(p.SideButton,{className:"Layout__side__tool",label:a.label||"",url:u,active:b,external:!!g,children:a.icon?r("img",{className:"Layout__side__tool__icon",src:a.icon,alt:a.label||""}):r(Pt,{stroke:C})},s)}),r("div",{className:"Layout__side__divider"})]}),!c("settings")&&r(p.SideButton,{label:"Settings",url:"/cms/settings",active:e.startsWith("/cms/settings"),children:r(Wt,{stroke:C})})]}),r("div",{className:"Layout__side__user",children:r(Z,{shadow:"md",position:"right",control:r(Q,{children:r(xt,{src:o.photoURL,alt:o.email,size:30,radius:"xl"})}),children:[r(Z.Label,{children:r(S,{size:"xs",color:"dimmed",truncate:!0,children:["Signed in as ",o.email]})}),r(Ct,{}),r(Z.Item,{color:"red",icon:r(Mt,{style:{width:14,height:14}}),onClick:_,children:"Sign out"})]})})]})};p.SideButton=t=>r(Et,{className:N("Layout__side__button",t.className),label:t.label,position:"right",withArrow:!0,children:r("a",{className:N(t.active&&"active"),href:t.url,target:t.external?"_blank":void 0,rel:t.external?"noreferrer noopener":void 0,children:t.children})});p.Main=t=>r("div",{className:"Layout__main",children:t.children});p.Bottom=()=>r("div",{className:"Layout__bottom"});export{nt as a,me as b,p as c};
@@ -1 +1 @@
1
- import{a as m}from"./chunk-F7RQT4XN.js";import{b as _}from"./chunk-RN4XVVWD.js";import{a as S,c as u}from"./chunk-QRAFYIAW.js";import{Ga as e,V as d,a as c,c as s,da as l,j as h}from"./chunk-WRA24P66.js";h();var r="DataSourceSelectModal";function T(){let a=S(),t=u();return{open:i=>{a.openContextModal(r,{...t,innerProps:i,size:"600px",overflow:"inside"})},close:()=>{a.closeModal(r)}}}function N(a){let{innerProps:t}=a,[i,p]=c(!0),[n,D]=c([]),f=t.selectedDataSourceIds||[];s(()=>{async function o(){let g=await _();D(g.filter(x=>!x.archivedAt)),p(!1)}o()},[]);function M(o){t.onChange&&t.onChange(o,!0)}function v(o){t.onChange&&t.onChange(o,!1)}return e("div",{className:"DataSourceSelectModal",children:i?e("div",{className:"DataSourceSelectModal__loading",children:e(d,{color:"gray",size:"xl"})}):n.length===0?e("div",{className:"DataSourceSelectModal__empty",children:"No data sources."}):e("div",{className:"DataSourceSelectModal__list",children:n.map(o=>e("div",{className:"DataSourceSelectModal__item",children:[e(m,{className:"DataSourceSelectModal__item__icon",type:o.type}),e("div",{className:"DataSourceSelectModal__item__info",children:[e("div",{className:"DataSourceSelectModal__item__id",children:o.id}),o.description&&e("div",{className:"DataSourceSelectModal__item__description",children:o.description})]}),e("div",{className:"DataSourceSelectModal__item__action",children:f.includes(o.id)?e(l,{variant:"light",color:"blue",size:"xs",onClick:()=>v(o.id),children:"Unselect"}):e(l,{variant:"filled",color:"blue",size:"xs",onClick:()=>M(o.id),children:"Select"})})]},o.id))})})}N.id=r;export{T as a,N as b};
1
+ import{a as m}from"./chunk-F7RQT4XN.js";import{b as _}from"./chunk-Z2CRNO3I.js";import{a as S,c as u}from"./chunk-QRAFYIAW.js";import{Ga as e,V as d,a as c,c as s,da as l,j as h}from"./chunk-WRA24P66.js";h();var r="DataSourceSelectModal";function T(){let a=S(),t=u();return{open:i=>{a.openContextModal(r,{...t,innerProps:i,size:"600px",overflow:"inside"})},close:()=>{a.closeModal(r)}}}function N(a){let{innerProps:t}=a,[i,p]=c(!0),[n,D]=c([]),f=t.selectedDataSourceIds||[];s(()=>{async function o(){let g=await _();D(g.filter(x=>!x.archivedAt)),p(!1)}o()},[]);function M(o){t.onChange&&t.onChange(o,!0)}function v(o){t.onChange&&t.onChange(o,!1)}return e("div",{className:"DataSourceSelectModal",children:i?e("div",{className:"DataSourceSelectModal__loading",children:e(d,{color:"gray",size:"xl"})}):n.length===0?e("div",{className:"DataSourceSelectModal__empty",children:"No data sources."}):e("div",{className:"DataSourceSelectModal__list",children:n.map(o=>e("div",{className:"DataSourceSelectModal__item",children:[e(m,{className:"DataSourceSelectModal__item__icon",type:o.type}),e("div",{className:"DataSourceSelectModal__item__info",children:[e("div",{className:"DataSourceSelectModal__item__id",children:o.id}),o.description&&e("div",{className:"DataSourceSelectModal__item__description",children:o.description})]}),e("div",{className:"DataSourceSelectModal__item__action",children:f.includes(o.id)?e(l,{variant:"light",color:"blue",size:"xs",onClick:()=>v(o.id),children:"Unselect"}):e(l,{variant:"filled",color:"blue",size:"xs",onClick:()=>M(o.id),children:"Select"})})]},o.id))})})}N.id=r;export{T as a,N as b};
@@ -1 +1 @@
1
- import{b as le}from"./chunk-HV3JJ5UT.js";import{a as oe}from"./chunk-FVWSVOOY.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
+ import{b as le}from"./chunk-HV3JJ5UT.js";import{a as oe}from"./chunk-VJRMR2JM.js";import{a as ee,b as A,c as T}from"./chunk-JDW4UORS.js";import{a as ie}from"./chunk-YDO2EDVY.js";import{a as M}from"./chunk-5MV6XVGA.js";import{b as te}from"./chunk-2PTLQRTU.js";import{a as U}from"./chunk-PIJ3E47R.js";import{a as j}from"./chunk-NCZD5IWS.js";import{P as re,c as ne}from"./chunk-ISUGBMXC.js";import{b as K,f as R,g as C,i as v,o as Y}from"./chunk-XOWWPE7X.js";import{d as Z,e as se}from"./chunk-WASID5UU.js";import{A as G,Ga as g,a as S,c as y,da as $,e as _,g as B,h as I,i as W,j as O,ra as Q,ua as q,za as J}from"./chunk-WRA24P66.js";import{j as X,k as Se}from"./chunk-KUCVLANF.js";function F(e){let t=window.__ROOT_CTX.collections[e.collectionId];if(!t)throw new Error(`collection not found: ${e.collectionId}`);if(!t.url)return"";let n=t.domain||window.__ROOT_CTX.rootConfig.domain||"https://example.com",r=Ee(e);return`${n}${r}`}function Ee(e){let o=window.__ROOT_CTX.collections,{collectionId:t,slug:n,locale:r}=e,i=o[t];if(!i)throw new Error(`collection not found: ${t}`);if(!i.url)return"";let l=window.__ROOT_CTX.rootConfig,m=l.base||"/",u="/[base]/[path]";r&&(u=l.i18n.urlFormat||"/[locale]/[base]/[path]");let f="",a=i?.url;if(a)if(n){let c=a.replace(/\[.*slug\]/,n).replaceAll("--","/").replace(/\/+/g,"/");c==="/index"&&(c="/"),f=c}else f=a;return ce(u,{base:m,path:f,locale:r||"",slug:n})}function be(e){let o=window.__ROOT_CTX.collections,{collectionId:t,slug:n,locale:r}=e,i=o[t];if(!i)throw new Error(`collection not found: ${t}`);let l=window.__ROOT_CTX.rootConfig,m=l.base||"/",u="/[base]/[path]";r&&(u=l.i18n.urlFormat||"/[locale]/[base]/[path]");let f="",a=i?.previewUrl||i?.url;if(a)if(n){let c=a.replace(/\[.*slug\]/,n).replaceAll("--","/").replace(/\/+/g,"/");c==="/index"&&(c="/"),f=c}else f=a;return ce(u,{base:m,path:f,locale:r||"",slug:n})}function ce(e,o){let t=e.replaceAll(/\[\[?(\.\.\.)?([\w\-_]*)\]?\]/g,(n,r,i)=>o[i]??n);return Ce(t,{trailingSlash:window.__ROOT_CTX.rootConfig.server.trailingSlash})}function Ce(e,o){return e=e.replace(/\/+/g,"/"),o?.trailingSlash===!1&&e!=="/"&&e.endsWith("/")&&(e=e.replace(/\/*$/g,"")),(e.endsWith("/index")||e.endsWith("/index/"))&&(e=e.slice(0,-6)),e.startsWith("/")||(e=`/${e}`),o?.trailingSlash&&!e.endsWith("/")&&(e=`${e}/`),e}O();function Ae(e,o){let[t,n]=S([]),[r,i]=S(!0),m=le().db,u=window.__ROOT_CTX.rootConfig.projectId||"default",f=o.includeArchived??!1,a=async()=>{i(!0);let c=K(m,"Projects",u,"Collections",e,"Drafts"),s=c,d=o.orderBy;if(d==="modifiedAt")s=C(c,v("sys.modifiedAt","desc"));else if(d==="modifiedAtAsc")s=C(c,v("sys.modifiedAt"));else if(d==="newest")s=C(c,v("sys.createdAt","desc"));else if(d==="oldest")s=C(c,v("sys.createdAt"));else if(d==="slug")s=C(c,v(R()));else if(d==="slugDesc")s=C(c,v(R(),"desc"));else if(d==="title"||d==="titleDesc"){let p=d==="titleDesc"?"desc":"asc",h=ve(e);s=h?C(c,v(h,p)):C(c,v(R(),p))}else{let h=window.__ROOT_CTX.collections[e]?.sortOptions?.find(w=>w.id===d);h&&(s=h.direction==="desc"?C(c,v(h.field,"desc")):C(c,v(h.field)))}await te(async()=>{let p=await Y(s),h=[];p.docs.forEach(w=>{let P=w.data(),E=w.id,b=`${e}/${E}`,x={...P,id:b,slug:E};ne(b,x),!(!f&&x?.sys?.archivedAt)&&h.push(x)}),n(h)}),i(!1)};return y(()=>{i(!0),a()},[e,o.orderBy,f]),[r,a,t]}function ve(e){let t=window.__ROOT_CTX.collections[e]?.preview?.title??"meta.title";return Array.isArray(t)&&(t=t[0]),typeof t!="string"||!t||t.includes("{")?"":`fields.${t}`}Se();O();var D={CONNECTED:"connected",SCHEMA_CHANGED:"schemaChanged"};function ae(e){let t=new URLSearchParams(window.location.search).get("e");return t?t.split(",").includes(e):!1}var we="/cms/api/sse.connect",L=ae("EnableVerboseLogging"),ue=window.location.hostname==="localhost",z=class{constructor(){this.map=new Map}on(o,t){return this.map.has(o)||this.map.set(o,new Set),this.map.get(o).add(t),()=>{this.map.get(o)?.delete(t)}}emit(o,t,n){this.map.get(o)?.forEach(r=>r(t,n)),this.map.get("*")?.forEach(r=>r({type:o,data:t},n))}},fe=X(null);function He(e){let t=_(new z).current,n=_(null),r=_(!1),i=_({attempt:0,timer:0}),l=_(""),m=()=>{n.current&&(n.current.close(),n.current=null)},u=I(()=>{L&&console.log("[sse] connecting..."),m();let a=new EventSource(we);n.current=a,a.addEventListener(D.CONNECTED,s=>{if(L&&console.log("[sse] connected"),r.current=!1,i.current.attempt=0,ue){let p=de(s.data)?.serverVersion||"";l.current?l.current!==p&&(console.log(`server version changed: ${l.current} -> ${p}`),console.log("reloading..."),window.location.reload()):l.current=p}});let c=s=>{if(!s||!s.type)return;let d=de(s.data);L&&console.log("[sse] event:",s.type,d),t.emit(s.type,d,s)};Object.values(D).forEach(s=>{a.addEventListener(s,c)}),a.addEventListener("error",()=>{L&&console.log("[sse] disconnected"),a.readyState===EventSource.CLOSED&&!r.current&&(r.current=!0,(()=>{let d=++i.current.attempt,p=Math.min(3e4,Math.pow(2,d)*500),h=Math.random()*.3*p,w=p+h;window.clearTimeout(i.current.timer),i.current.timer=window.setTimeout(()=>{r.current=!1,u()},w)})())})},[t]);y(()=>{if(!ue)return;u();let a=()=>{document.visibilityState==="visible"&&n.current?.readyState!==EventSource.OPEN&&u()};return document.addEventListener("visibilitychange",a),()=>{document.removeEventListener("visibilitychange",a),window.clearTimeout(i.current.timer),m()}},[u]);let f=B(()=>({emitter:t}),[t]);return g(fe.Provider,{value:f,children:e.children})}function de(e){try{return JSON.parse(e)}catch{return e}}function ge(e,o){let t=W(fe);if(!t)throw new Error("useSSE() must be used within an <SSEProvider>");let n=_(o);y(()=>{n.current=o},[o]),y(()=>t.emitter.on(e,(r,i)=>n.current(r,i)),[t,e])}O();O();function me(e){let[o,t]=S(!0),[n,r]=S(null),i=I(async()=>{try{let l=await ie(e);r(l)}catch(l){console.error(l),U({title:`Failed to load collection: ${e}`,message:String(l),color:"red",autoClose:!1})}t(!1)},[e]);return y(()=>{i()},[e]),ge(D.SCHEMA_CHANGED,async l=>{await i();let m=l.file?`Applied updates from changes to ${l.file}.`:"Applied updates from changes to a .schema.ts file.";U({title:"Updated schema!",message:m})}),{loading:o,schema:n}}function H(e){let o={_array:[]};return e.forEach(t=>{let n=_e();o._array.push(n),o[n]=t}),o}function _e(){let e=[],o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=o.length;for(let n=0;n<6;n++)e.push(o.charAt(Math.floor(Math.random()*t)));return e.join("")}function V(e){let o={};return e.fields.forEach(t=>{t.id&&(t.type==="array"&&t.default&&Array.isArray(t.default)?o[t.id]=H(t.default):t.default?o[t.id]=t.default:t.type==="object"&&(o[t.id]=V(t)))}),o}function k(e,o,t){let n={...o};return e.fields.forEach(r=>{if(!r.id)return;let i=n[r.id];if(i!=null){if(r.type==="array"&&Array.isArray(i)){let l=i.map(m=>ye(r.of,m,t));n[r.id]=H(l)}else if(r.type==="object"&&M(i))n[r.id]=k(r,i,t);else if(r.type==="oneof"&&M(i)&&typeof i._type=="string"&&t){let l=t[i._type];l&&(n[r.id]=k(l,i,t))}}}),n}function ye(e,o,t){if(!M(o))return o;if(e.type==="object")return k(e,o,t);if(e.type==="oneof"&&typeof o._type=="string"&&t){let n=t[o._type];if(n)return k(n,o,t)}return o}O();function pe(e){let[o,t]=S(e.collectionId||""),n=_(null),[r,i]=S(e.initialSlug||""),l=window.__ROOT_CTX.collections[o],m=[];e.collectionId&&e.collectionDisabled?m.push({value:e.collectionId,label:e.collectionId}):Object.keys(window.__ROOT_CTX.collections).forEach(s=>{m.push({value:s,label:s})});let u="",f="";if(l?.url){if(r){let s=T(r),d=l?.slugRegex;ee(s,d)?u=F({collectionId:o,slug:s}):f=A(s,d)}else u=F({collectionId:o,slug:"[slug]"});u.endsWith("/index")&&(u=u.replace(/\/index$/,"/"))}function a(s){t(s),e.onChange&&e.onChange({collectionId:s,slug:r})}function c(s){i(s),e.onChange&&e.onChange({collectionId:o,slug:s})}return g("div",{className:se(e.className,"SlugInput"),children:[g("div",{className:"SlugInput__inputs",children:[g(J,{className:"SlugInput__collection",placeholder:"Collection",size:"xs",data:m,onChange:s=>a(s),value:o,disabled:!!e.collectionDisabled}),g("div",{className:"SlugInput__divider",children:"/"}),g(q,{className:"SlugInput__slug",name:"slug",ref:n,value:r,onChange:s=>{c(s.currentTarget.value)},placeholder:"slug",autoComplete:"off",size:"xs"})]}),u&&g(j,{className:"SlugInput__urlHelp",size:"body-sm",children:u}),f&&g(j,{className:"SlugInput__slugError",size:"body-sm",children:f})]})}function xt(e){let{route:o}=Z(),t=G(),n=e.collection,r=window.__ROOT_CTX.collections[n];if(!r)throw new Error(`collection not found: ${n}`);let[i]=S(()=>r.autoSlug?oe(r.autoSlug):""),[l,m]=S(i),[u,f]=S(!1),[a,c]=S(()=>h(i)),[s,d]=S(""),p=me(n);function h(E){let b=T(E);return b?A(b,r.slugRegex):""}function w(){e.onClose&&e.onClose()}async function P(E){if(E.preventDefault(),f(!0),c(""),h(l)){f(!1);return}let x=T(l),he=`${n}/${x}`;try{let N={};!p.loading&&p.schema&&(N=await V(p.schema)),await re(he,{fields:N})}catch(N){d(String(N)),f(!1);return}f(!1),e.skipNavigation?w():o(`/cms/content/${e.collection}/${x}`)}return g(Q,{className:"NewDocModal",opened:e.opened||!1,onClose:()=>w(),title:"New",size:"500px",overlayColor:t.colorScheme==="dark"?t.colors.dark[9]:t.colors.gray[2],children:[g("div",{className:"NewDocModal__body",children:"Enter a slug for the new doc. The slug is the ID of the page and is what's used in the URL. Use only lowercase letters, numbers, and dashes."}),g("form",{onSubmit:E=>P(E),children:[g(pe,{className:"NewDocModal__slug",collectionId:n,initialSlug:i,onChange:E=>{m(E.slug),c(h(E.slug)),d("")}}),s&&g("div",{className:"NewDocModal__slugError",children:s}),g("div",{className:"NewDocModal__buttons",children:[g($,{variant:"outline",onClick:()=>w(),type:"button",size:"xs",color:"dark",children:"Cancel"}),g($,{variant:"filled",type:"submit",size:"xs",color:"dark",loading:p.loading||u,disabled:!!a||!!s,children:"Submit"})]})]})]})}export{F as a,Ee as b,be as c,pe as d,Ae as e,He as f,me as g,V as h,k as i,xt as j};
@@ -1 +1 @@
1
- import{c as F}from"./chunk-FVWSVOOY.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
+ 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};