@blinkk/root-cms 2.3.3 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/app.js CHANGED
@@ -83,7 +83,7 @@ function convertOneOfTypes(collection) {
83
83
  // package.json
84
84
  var package_default = {
85
85
  name: "@blinkk/root-cms",
86
- version: "2.3.3",
86
+ version: "2.4.1",
87
87
  author: "s@blinkk.com",
88
88
  license: "MIT",
89
89
  engines: {
@@ -232,7 +232,7 @@ var package_default = {
232
232
  yjs: "13.6.27"
233
233
  },
234
234
  peerDependencies: {
235
- "@blinkk/root": "2.3.3",
235
+ "@blinkk/root": "2.4.1",
236
236
  "firebase-admin": ">=11",
237
237
  "firebase-functions": ">=4",
238
238
  preact: ">=10",
package/dist/plugin.js CHANGED
@@ -2552,7 +2552,7 @@ function api(server, options) {
2552
2552
  // package.json
2553
2553
  var package_default = {
2554
2554
  name: "@blinkk/root-cms",
2555
- version: "2.3.3",
2555
+ version: "2.4.1",
2556
2556
  author: "s@blinkk.com",
2557
2557
  license: "MIT",
2558
2558
  engines: {
@@ -2701,7 +2701,7 @@ var package_default = {
2701
2701
  yjs: "13.6.27"
2702
2702
  },
2703
2703
  peerDependencies: {
2704
- "@blinkk/root": "2.3.3",
2704
+ "@blinkk/root": "2.4.1",
2705
2705
  "firebase-admin": ">=11",
2706
2706
  "firebase-functions": ">=4",
2707
2707
  preact: ">=10",
package/dist/ui/ui.js CHANGED
@@ -62,7 +62,7 @@ Content-Type: `+c.contentType+`\r
62
62
  `));let r=[],o=t.split(/(\n|\r\n)/);o[o.length-1]||o.pop();for(let n=0;n<o.length;n++){let i=o[n];n%2&&!e.newlineIsToken?r[r.length-1]+=i:r.push(i)}return r}we();function Ne(...t){return t.filter(e=>!!e).join(" ")||void 0}Zr();Zr();var mMe=0,ENt=Array.isArray;function p(t,e,r,o,n,i){e||(e={});var a,s,l=e;if("ref"in l)for(s in l={},e)s=="ref"?a=e[s]:l[s]=e[s];var c={type:t,props:l,key:r,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--mMe,__i:-1,__u:0,__source:n,__self:i};if(typeof t=="function"&&(a=t.defaultProps))for(s in a)l[s]===void 0&&(l[s]=a[s]);return wt.vnode&&wt.vnode(c),c}function KQ(t){let{oldCode:e,newCode:r,className:o=""}=t,n=pe(()=>ZM(e,r),[e,r]),i=G(null);V(()=>{if(i.current){let s=i.current.querySelector(".JsDiff__diffLine--added, .JsDiff__diffLine--removed");s&&s.scrollIntoView({behavior:"smooth",block:"center"})}},[e,r]);let a=()=>{let s=[],l=0;return n.forEach((c,d)=>{let u=c.added?"+":c.removed?"-":" ",f=c.value.split(`
63
63
  `);f.forEach((m,h)=>{(m.length>0||h<f.length-1)&&s.push(p("div",{className:Ne("JsDiff__diffLine",c.added&&"JsDiff__diffLine--added",c.removed&&"JsDiff__diffLine--removed",!c.added&&!c.removed&&"JsDiff__diffLine--unchanged"),children:[p("span",{className:"JsDiff__lineNumber",children:++l}),p("span",{className:"JsDiff__lineContent",children:[p("span",{className:"JsDiff__sign",children:u}),p("span",{children:m||" "})]})]},`${d}-${h}`))})}),s};return p("div",{className:Ne("JsDiff__container",o),children:p("div",{className:"JsDiff__content",ref:i,children:a()})})}var tte=zp(ete(),1);var mL=tte.default;var _2e={};function hL(t,e){let r=e||_2e,o=typeof r.includeImageAlt=="boolean"?r.includeImageAlt:!0,n=typeof r.includeHtml=="boolean"?r.includeHtml:!0;return ote(t,o,n)}function ote(t,e,r){if(x2e(t)){if("value"in t)return t.type==="html"&&!r?"":t.value;if(e&&"alt"in t&&t.alt)return t.alt;if("children"in t)return rte(t.children,e,r)}return Array.isArray(t)?rte(t,e,r):""}function rte(t,e,r){let o=[],n=-1;for(;++n<t.length;)o[n]=ote(t[n],e,r);return o.join("")}function x2e(t){return!!(t&&typeof t=="object")}var nte=document.createElement("i");function Eh(t){let e="&"+t+";";nte.innerHTML=e;let r=nte.textContent;return r.charCodeAt(r.length-1)===59&&t!=="semi"||r===e?!1:r}function Oo(t,e,r,o){let n=t.length,i=0,a;if(e<0?e=-e>n?0:n+e:e=e>n?n:e,r=r>0?r:0,o.length<1e4)a=Array.from(o),a.unshift(e,r),t.splice(...a);else for(r&&t.splice(e,r);i<o.length;)a=o.slice(i,i+1e4),a.unshift(e,0),t.splice(...a),i+=1e4,e+=1e4}function fi(t,e){return t.length>0?(Oo(t,t.length,0,e),t):e}var ite={}.hasOwnProperty;function KS(t){let e={},r=-1;for(;++r<t.length;)b2e(e,t[r]);return e}function b2e(t,e){let r;for(r in e){let n=(ite.call(t,r)?t[r]:void 0)||(t[r]={}),i=e[r],a;if(i)for(a in i){ite.call(n,a)||(n[a]=[]);let s=i[a];y2e(n[a],Array.isArray(s)?s:s?[s]:[])}}}function y2e(t,e){let r=-1,o=[];for(;++r<e.length;)(e[r].add==="after"?t:o).push(e[r]);Oo(t,0,0,o)}function YS(t,e){let r=Number.parseInt(t,e);return r<9||r===11||r>13&&r<32||r>126&&r<160||r>55295&&r<57344||r>64975&&r<65008||(r&65535)===65535||(r&65535)===65534||r>1114111?"\uFFFD":String.fromCodePoint(r)}function Gn(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}var Vo=Nd(/[A-Za-z]/),Ho=Nd(/[\dA-Za-z]/),ate=Nd(/[#-'*+\--9=?A-Z^-~]/);function Mf(t){return t!==null&&(t<32||t===127)}var Kb=Nd(/\d/),ste=Nd(/[\dA-Fa-f]/),lte=Nd(/[!-/:-@[-`{-~]/);function Oe(t){return t!==null&&t<-2}function Dt(t){return t!==null&&(t<0||t===32)}function ct(t){return t===-2||t===-1||t===32}var Lf=Nd(/\p{P}|\p{S}/u),dl=Nd(/\s/);function Nd(t){return e;function e(r){return r!==null&&r>-1&&t.test(String.fromCharCode(r))}}function it(t,e,r,o){let n=o?o-1:Number.POSITIVE_INFINITY,i=0;return a;function a(l){return ct(l)?(t.enter(r),s(l)):e(l)}function s(l){return ct(l)&&i++<n?(t.consume(l),s):(t.exit(r),e(l))}}var cte={tokenize:v2e};function v2e(t){let e=t.attempt(this.parser.constructs.contentInitial,o,n),r;return e;function o(s){if(s===null){t.consume(s);return}return t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),it(t,e,"linePrefix")}function n(s){return t.enter("paragraph"),i(s)}function i(s){let l=t.enter("chunkText",{contentType:"text",previous:r});return r&&(r.next=l),r=l,a(s)}function a(s){if(s===null){t.exit("chunkText"),t.exit("paragraph"),t.consume(s);return}return Oe(s)?(t.consume(s),t.exit("chunkText"),i):(t.consume(s),a)}}var ute={tokenize:I2e},dte={tokenize:w2e};function I2e(t){let e=this,r=[],o=0,n,i,a;return s;function s(v){if(o<r.length){let S=r[o];return e.containerState=S[1],t.attempt(S[0].continuation,l,c)(v)}return c(v)}function l(v){if(o++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,n&&y();let S=e.events.length,N=S,w;for(;N--;)if(e.events[N][0]==="exit"&&e.events[N][1].type==="chunkFlow"){w=e.events[N][1].end;break}b(o);let E=S;for(;E<e.events.length;)e.events[E][1].end=Object.assign({},w),E++;return Oo(e.events,N+1,0,e.events.slice(S)),e.events.length=E,c(v)}return s(v)}function c(v){if(o===r.length){if(!n)return f(v);if(n.currentConstruct&&n.currentConstruct.concrete)return h(v);e.interrupt=!!(n.currentConstruct&&!n._gfmTableDynamicInterruptHack)}return e.containerState={},t.check(dte,d,u)(v)}function d(v){return n&&y(),b(o),f(v)}function u(v){return e.parser.lazy[e.now().line]=o!==r.length,a=e.now().offset,h(v)}function f(v){return e.containerState={},t.attempt(dte,m,h)(v)}function m(v){return o++,r.push([e.currentConstruct,e.containerState]),f(v)}function h(v){if(v===null){n&&y(),b(0),t.consume(v);return}return n=n||e.parser.flow(e.now()),t.enter("chunkFlow",{contentType:"flow",previous:i,_tokenizer:n}),g(v)}function g(v){if(v===null){_(t.exit("chunkFlow"),!0),b(0),t.consume(v);return}return Oe(v)?(t.consume(v),_(t.exit("chunkFlow")),o=0,e.interrupt=void 0,s):(t.consume(v),g)}function _(v,S){let N=e.sliceStream(v);if(S&&N.push(null),v.previous=i,i&&(i.next=v),i=v,n.defineSkip(v.start),n.write(N),e.parser.lazy[v.start.line]){let w=n.events.length;for(;w--;)if(n.events[w][1].start.offset<a&&(!n.events[w][1].end||n.events[w][1].end.offset>a))return;let E=e.events.length,I=E,C,T;for(;I--;)if(e.events[I][0]==="exit"&&e.events[I][1].type==="chunkFlow"){if(C){T=e.events[I][1].end;break}C=!0}for(b(o),w=E;w<e.events.length;)e.events[w][1].end=Object.assign({},T),w++;Oo(e.events,I+1,0,e.events.slice(E)),e.events.length=w}}function b(v){let S=r.length;for(;S-- >v;){let N=r[S];e.containerState=N[1],N[0].exit.call(e,t)}r.length=v}function y(){n.write([null]),i=void 0,n=void 0,e.containerState._closeFlow=void 0}}function w2e(t,e,r){return it(t,t.attempt(this.parser.constructs.document,e,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Sh(t){if(t===null||Dt(t)||dl(t))return 1;if(Lf(t))return 2}function Pd(t,e,r){let o=[],n=-1;for(;++n<t.length;){let i=t[n].resolveAll;i&&!o.includes(i)&&(e=i(e,r),o.push(i))}return e}var Yb={name:"attention",tokenize:S2e,resolveAll:E2e};function E2e(t,e){let r=-1,o,n,i,a,s,l,c,d;for(;++r<t.length;)if(t[r][0]==="enter"&&t[r][1].type==="attentionSequence"&&t[r][1]._close){for(o=r;o--;)if(t[o][0]==="exit"&&t[o][1].type==="attentionSequence"&&t[o][1]._open&&e.sliceSerialize(t[o][1]).charCodeAt(0)===e.sliceSerialize(t[r][1]).charCodeAt(0)){if((t[o][1]._close||t[r][1]._open)&&(t[r][1].end.offset-t[r][1].start.offset)%3&&!((t[o][1].end.offset-t[o][1].start.offset+t[r][1].end.offset-t[r][1].start.offset)%3))continue;l=t[o][1].end.offset-t[o][1].start.offset>1&&t[r][1].end.offset-t[r][1].start.offset>1?2:1;let u=Object.assign({},t[o][1].end),f=Object.assign({},t[r][1].start);fte(u,-l),fte(f,l),a={type:l>1?"strongSequence":"emphasisSequence",start:u,end:Object.assign({},t[o][1].end)},s={type:l>1?"strongSequence":"emphasisSequence",start:Object.assign({},t[r][1].start),end:f},i={type:l>1?"strongText":"emphasisText",start:Object.assign({},t[o][1].end),end:Object.assign({},t[r][1].start)},n={type:l>1?"strong":"emphasis",start:Object.assign({},a.start),end:Object.assign({},s.end)},t[o][1].end=Object.assign({},a.start),t[r][1].start=Object.assign({},s.end),c=[],t[o][1].end.offset-t[o][1].start.offset&&(c=fi(c,[["enter",t[o][1],e],["exit",t[o][1],e]])),c=fi(c,[["enter",n,e],["enter",a,e],["exit",a,e],["enter",i,e]]),c=fi(c,Pd(e.parser.constructs.insideSpan.null,t.slice(o+1,r),e)),c=fi(c,[["exit",i,e],["enter",s,e],["exit",s,e],["exit",n,e]]),t[r][1].end.offset-t[r][1].start.offset?(d=2,c=fi(c,[["enter",t[r][1],e],["exit",t[r][1],e]])):d=0,Oo(t,o-1,r-o+3,c),r=o+c.length-d-2;break}}for(r=-1;++r<t.length;)t[r][1].type==="attentionSequence"&&(t[r][1].type="data");return t}function S2e(t,e){let r=this.parser.constructs.attentionMarkers.null,o=this.previous,n=Sh(o),i;return a;function a(l){return i=l,t.enter("attentionSequence"),s(l)}function s(l){if(l===i)return t.consume(l),s;let c=t.exit("attentionSequence"),d=Sh(l),u=!d||d===2&&n||r.includes(l),f=!n||n===2&&d||r.includes(o);return c._open=!!(i===42?u:u&&(n||!f)),c._close=!!(i===42?f:f&&(d||!u)),e(l)}}function fte(t,e){t.column+=e,t.offset+=e,t._bufferIndex+=e}var gL={name:"autolink",tokenize:C2e};function C2e(t,e,r){let o=0;return n;function n(m){return t.enter("autolink"),t.enter("autolinkMarker"),t.consume(m),t.exit("autolinkMarker"),t.enter("autolinkProtocol"),i}function i(m){return Vo(m)?(t.consume(m),a):m===64?r(m):c(m)}function a(m){return m===43||m===45||m===46||Ho(m)?(o=1,s(m)):c(m)}function s(m){return m===58?(t.consume(m),o=0,l):(m===43||m===45||m===46||Ho(m))&&o++<32?(t.consume(m),s):(o=0,c(m))}function l(m){return m===62?(t.exit("autolinkProtocol"),t.enter("autolinkMarker"),t.consume(m),t.exit("autolinkMarker"),t.exit("autolink"),e):m===null||m===32||m===60||Mf(m)?r(m):(t.consume(m),l)}function c(m){return m===64?(t.consume(m),d):ate(m)?(t.consume(m),c):r(m)}function d(m){return Ho(m)?u(m):r(m)}function u(m){return m===46?(t.consume(m),o=0,d):m===62?(t.exit("autolinkProtocol").type="autolinkEmail",t.enter("autolinkMarker"),t.consume(m),t.exit("autolinkMarker"),t.exit("autolink"),e):f(m)}function f(m){if((m===45||Ho(m))&&o++<63){let h=m===45?f:u;return t.consume(m),h}return r(m)}}var ul={tokenize:T2e,partial:!0};function T2e(t,e,r){return o;function o(i){return ct(i)?it(t,n,"linePrefix")(i):n(i)}function n(i){return i===null||Oe(i)?e(i):r(i)}}var XS={name:"blockQuote",tokenize:k2e,continuation:{tokenize:N2e},exit:P2e};function k2e(t,e,r){let o=this;return n;function n(a){if(a===62){let s=o.containerState;return s.open||(t.enter("blockQuote",{_container:!0}),s.open=!0),t.enter("blockQuotePrefix"),t.enter("blockQuoteMarker"),t.consume(a),t.exit("blockQuoteMarker"),i}return r(a)}function i(a){return ct(a)?(t.enter("blockQuotePrefixWhitespace"),t.consume(a),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),e):(t.exit("blockQuotePrefix"),e(a))}}function N2e(t,e,r){let o=this;return n;function n(a){return ct(a)?it(t,i,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):i(a)}function i(a){return t.attempt(XS,e,r)(a)}}function P2e(t){t.exit("blockQuote")}var JS={name:"characterEscape",tokenize:O2e};function O2e(t,e,r){return o;function o(i){return t.enter("characterEscape"),t.enter("escapeMarker"),t.consume(i),t.exit("escapeMarker"),n}function n(i){return lte(i)?(t.enter("characterEscapeValue"),t.consume(i),t.exit("characterEscapeValue"),t.exit("characterEscape"),e):r(i)}}var QS={name:"characterReference",tokenize:D2e};function D2e(t,e,r){let o=this,n=0,i,a;return s;function s(u){return t.enter("characterReference"),t.enter("characterReferenceMarker"),t.consume(u),t.exit("characterReferenceMarker"),l}function l(u){return u===35?(t.enter("characterReferenceMarkerNumeric"),t.consume(u),t.exit("characterReferenceMarkerNumeric"),c):(t.enter("characterReferenceValue"),i=31,a=Ho,d(u))}function c(u){return u===88||u===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(u),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),i=6,a=ste,d):(t.enter("characterReferenceValue"),i=7,a=Kb,d(u))}function d(u){if(u===59&&n){let f=t.exit("characterReferenceValue");return a===Ho&&!Eh(o.sliceSerialize(f))?r(u):(t.enter("characterReferenceMarker"),t.consume(u),t.exit("characterReferenceMarker"),t.exit("characterReference"),e)}return a(u)&&n++<i?(t.consume(u),d):r(u)}}var pte={tokenize:R2e,partial:!0},ZS={name:"codeFenced",tokenize:A2e,concrete:!0};function A2e(t,e,r){let o=this,n={tokenize:N,partial:!0},i=0,a=0,s;return l;function l(w){return c(w)}function c(w){let E=o.events[o.events.length-1];return i=E&&E[1].type==="linePrefix"?E[2].sliceSerialize(E[1],!0).length:0,s=w,t.enter("codeFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),d(w)}function d(w){return w===s?(a++,t.consume(w),d):a<3?r(w):(t.exit("codeFencedFenceSequence"),ct(w)?it(t,u,"whitespace")(w):u(w))}function u(w){return w===null||Oe(w)?(t.exit("codeFencedFence"),o.interrupt?e(w):t.check(pte,g,S)(w)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),f(w))}function f(w){return w===null||Oe(w)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),u(w)):ct(w)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),it(t,m,"whitespace")(w)):w===96&&w===s?r(w):(t.consume(w),f)}function m(w){return w===null||Oe(w)?u(w):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),h(w))}function h(w){return w===null||Oe(w)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),u(w)):w===96&&w===s?r(w):(t.consume(w),h)}function g(w){return t.attempt(n,S,_)(w)}function _(w){return t.enter("lineEnding"),t.consume(w),t.exit("lineEnding"),b}function b(w){return i>0&&ct(w)?it(t,y,"linePrefix",i+1)(w):y(w)}function y(w){return w===null||Oe(w)?t.check(pte,g,S)(w):(t.enter("codeFlowValue"),v(w))}function v(w){return w===null||Oe(w)?(t.exit("codeFlowValue"),y(w)):(t.consume(w),v)}function S(w){return t.exit("codeFenced"),e(w)}function N(w,E,I){let C=0;return T;function T($){return w.enter("lineEnding"),w.consume($),w.exit("lineEnding"),O}function O($){return w.enter("codeFencedFence"),ct($)?it(w,A,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)($):A($)}function A($){return $===s?(w.enter("codeFencedFenceSequence"),P($)):I($)}function P($){return $===s?(C++,w.consume($),P):C>=a?(w.exit("codeFencedFenceSequence"),ct($)?it(w,B,"whitespace")($):B($)):I($)}function B($){return $===null||Oe($)?(w.exit("codeFencedFence"),E($)):I($)}}}function R2e(t,e,r){let o=this;return n;function n(a){return a===null?r(a):(t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),i)}function i(a){return o.parser.lazy[o.now().line]?r(a):e(a)}}var Xb={name:"codeIndented",tokenize:L2e},M2e={tokenize:F2e,partial:!0};function L2e(t,e,r){let o=this;return n;function n(c){return t.enter("codeIndented"),it(t,i,"linePrefix",5)(c)}function i(c){let d=o.events[o.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?a(c):r(c)}function a(c){return c===null?l(c):Oe(c)?t.attempt(M2e,a,l)(c):(t.enter("codeFlowValue"),s(c))}function s(c){return c===null||Oe(c)?(t.exit("codeFlowValue"),a(c)):(t.consume(c),s)}function l(c){return t.exit("codeIndented"),e(c)}}function F2e(t,e,r){let o=this;return n;function n(a){return o.parser.lazy[o.now().line]?r(a):Oe(a)?(t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),n):it(t,i,"linePrefix",5)(a)}function i(a){let s=o.events[o.events.length-1];return s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?e(a):Oe(a)?n(a):r(a)}}var _L={name:"codeText",tokenize:z2e,resolve:B2e,previous:$2e};function B2e(t){let e=t.length-4,r=3,o,n;if((t[r][1].type==="lineEnding"||t[r][1].type==="space")&&(t[e][1].type==="lineEnding"||t[e][1].type==="space")){for(o=r;++o<e;)if(t[o][1].type==="codeTextData"){t[r][1].type="codeTextPadding",t[e][1].type="codeTextPadding",r+=2,e-=2;break}}for(o=r-1,e++;++o<=e;)n===void 0?o!==e&&t[o][1].type!=="lineEnding"&&(n=o):(o===e||t[o][1].type==="lineEnding")&&(t[n][1].type="codeTextData",o!==n+2&&(t[n][1].end=t[o-1][1].end,t.splice(n+2,o-n-2),e-=o-n-2,o=n+2),n=void 0);return t}function $2e(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function z2e(t,e,r){let o=this,n=0,i,a;return s;function s(f){return t.enter("codeText"),t.enter("codeTextSequence"),l(f)}function l(f){return f===96?(t.consume(f),n++,l):(t.exit("codeTextSequence"),c(f))}function c(f){return f===null?r(f):f===32?(t.enter("space"),t.consume(f),t.exit("space"),c):f===96?(a=t.enter("codeTextSequence"),i=0,u(f)):Oe(f)?(t.enter("lineEnding"),t.consume(f),t.exit("lineEnding"),c):(t.enter("codeTextData"),d(f))}function d(f){return f===null||f===32||f===96||Oe(f)?(t.exit("codeTextData"),c(f)):(t.consume(f),d)}function u(f){return f===96?(t.consume(f),i++,u):i===n?(t.exit("codeTextSequence"),t.exit("codeText"),e(f)):(a.type="codeTextData",d(f))}}var eC=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,r){let o=r??Number.POSITIVE_INFINITY;return o<this.left.length?this.left.slice(e,o):e>this.left.length?this.right.slice(this.right.length-o+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-o+this.left.length).reverse())}splice(e,r,o){let n=r||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-n,Number.POSITIVE_INFINITY);return o&&Jb(this.left,o),i.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),Jb(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Jb(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let r=this.left.splice(e,Number.POSITIVE_INFINITY);Jb(this.right,r.reverse())}else{let r=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);Jb(this.left,r.reverse())}}};function Jb(t,e){let r=0;if(e.length<1e4)t.push(...e);else for(;r<e.length;)t.push(...e.slice(r,r+1e4)),r+=1e4}function tC(t){let e={},r=-1,o,n,i,a,s,l,c,d=new eC(t);for(;++r<d.length;){for(;r in e;)r=e[r];if(o=d.get(r),r&&o[1].type==="chunkFlow"&&d.get(r-1)[1].type==="listItemPrefix"&&(l=o[1]._tokenizer.events,i=0,i<l.length&&l[i][1].type==="lineEndingBlank"&&(i+=2),i<l.length&&l[i][1].type==="content"))for(;++i<l.length&&l[i][1].type!=="content";)l[i][1].type==="chunkText"&&(l[i][1]._isInFirstContentOfListItem=!0,i++);if(o[0]==="enter")o[1].contentType&&(Object.assign(e,U2e(d,r)),r=e[r],c=!0);else if(o[1]._container){for(i=r,n=void 0;i--&&(a=d.get(i),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank");)a[0]==="enter"&&(n&&(d.get(n)[1].type="lineEndingBlank"),a[1].type="lineEnding",n=i);n&&(o[1].end=Object.assign({},d.get(n)[1].start),s=d.slice(n,r),s.unshift(o),d.splice(n,r-n+1,s))}}return Oo(t,0,Number.POSITIVE_INFINITY,d.slice(0)),!c}function U2e(t,e){let r=t.get(e)[1],o=t.get(e)[2],n=e-1,i=[],a=r._tokenizer||o.parser[r.contentType](r.start),s=a.events,l=[],c={},d,u,f=-1,m=r,h=0,g=0,_=[g];for(;m;){for(;t.get(++n)[1]!==m;);i.push(n),m._tokenizer||(d=o.sliceStream(m),m.next||d.push(null),u&&a.defineSkip(m.start),m._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(d),m._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),u=m,m=m.next}for(m=r;++f<s.length;)s[f][0]==="exit"&&s[f-1][0]==="enter"&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(g=f+1,_.push(g),m._tokenizer=void 0,m.previous=void 0,m=m.next);for(a.events=[],m?(m._tokenizer=void 0,m.previous=void 0):_.pop(),f=_.length;f--;){let b=s.slice(_[f],_[f+1]),y=i.pop();l.push([y,y+b.length-1]),t.splice(y,2,b)}for(l.reverse(),f=-1;++f<l.length;)c[h+l[f][0]]=h+l[f][1],h+=l[f][1]-l[f][0]-1;return c}var xL={tokenize:j2e,resolve:H2e},V2e={tokenize:q2e,partial:!0};function H2e(t){return tC(t),t}function j2e(t,e){let r;return o;function o(s){return t.enter("content"),r=t.enter("chunkContent",{contentType:"content"}),n(s)}function n(s){return s===null?i(s):Oe(s)?t.check(V2e,a,i)(s):(t.consume(s),n)}function i(s){return t.exit("chunkContent"),t.exit("content"),e(s)}function a(s){return t.consume(s),t.exit("chunkContent"),r.next=t.enter("chunkContent",{contentType:"content",previous:r}),r=r.next,n}}function q2e(t,e,r){let o=this;return n;function n(a){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),it(t,i,"linePrefix")}function i(a){if(a===null||Oe(a))return r(a);let s=o.events[o.events.length-1];return!o.parser.constructs.disable.null.includes("codeIndented")&&s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?e(a):t.interrupt(o.parser.constructs.flow,r,e)(a)}}function rC(t,e,r,o,n,i,a,s,l){let c=l||Number.POSITIVE_INFINITY,d=0;return u;function u(b){return b===60?(t.enter(o),t.enter(n),t.enter(i),t.consume(b),t.exit(i),f):b===null||b===32||b===41||Mf(b)?r(b):(t.enter(o),t.enter(a),t.enter(s),t.enter("chunkString",{contentType:"string"}),g(b))}function f(b){return b===62?(t.enter(i),t.consume(b),t.exit(i),t.exit(n),t.exit(o),e):(t.enter(s),t.enter("chunkString",{contentType:"string"}),m(b))}function m(b){return b===62?(t.exit("chunkString"),t.exit(s),f(b)):b===null||b===60||Oe(b)?r(b):(t.consume(b),b===92?h:m)}function h(b){return b===60||b===62||b===92?(t.consume(b),m):m(b)}function g(b){return!d&&(b===null||b===41||Dt(b))?(t.exit("chunkString"),t.exit(s),t.exit(a),t.exit(o),e(b)):d<c&&b===40?(t.consume(b),d++,g):b===41?(t.consume(b),d--,g):b===null||b===32||b===40||Mf(b)?r(b):(t.consume(b),b===92?_:g)}function _(b){return b===40||b===41||b===92?(t.consume(b),g):g(b)}}function oC(t,e,r,o,n,i){let a=this,s=0,l;return c;function c(m){return t.enter(o),t.enter(n),t.consume(m),t.exit(n),t.enter(i),d}function d(m){return s>999||m===null||m===91||m===93&&!l||m===94&&!s&&"_hiddenFootnoteSupport"in a.parser.constructs?r(m):m===93?(t.exit(i),t.enter(n),t.consume(m),t.exit(n),t.exit(o),e):Oe(m)?(t.enter("lineEnding"),t.consume(m),t.exit("lineEnding"),d):(t.enter("chunkString",{contentType:"string"}),u(m))}function u(m){return m===null||m===91||m===93||Oe(m)||s++>999?(t.exit("chunkString"),d(m)):(t.consume(m),l||(l=!ct(m)),m===92?f:u)}function f(m){return m===91||m===92||m===93?(t.consume(m),s++,u):u(m)}}function nC(t,e,r,o,n,i){let a;return s;function s(f){return f===34||f===39||f===40?(t.enter(o),t.enter(n),t.consume(f),t.exit(n),a=f===40?41:f,l):r(f)}function l(f){return f===a?(t.enter(n),t.consume(f),t.exit(n),t.exit(o),e):(t.enter(i),c(f))}function c(f){return f===a?(t.exit(i),l(a)):f===null?r(f):Oe(f)?(t.enter("lineEnding"),t.consume(f),t.exit("lineEnding"),it(t,c,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),d(f))}function d(f){return f===a||f===null||Oe(f)?(t.exit("chunkString"),c(f)):(t.consume(f),f===92?u:d)}function u(f){return f===a||f===92?(t.consume(f),d):d(f)}}function Ff(t,e){let r;return o;function o(n){return Oe(n)?(t.enter("lineEnding"),t.consume(n),t.exit("lineEnding"),r=!0,o):ct(n)?it(t,o,r?"linePrefix":"lineSuffix")(n):e(n)}}var bL={name:"definition",tokenize:W2e},G2e={tokenize:K2e,partial:!0};function W2e(t,e,r){let o=this,n;return i;function i(m){return t.enter("definition"),a(m)}function a(m){return oC.call(o,t,s,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(m)}function s(m){return n=Gn(o.sliceSerialize(o.events[o.events.length-1][1]).slice(1,-1)),m===58?(t.enter("definitionMarker"),t.consume(m),t.exit("definitionMarker"),l):r(m)}function l(m){return Dt(m)?Ff(t,c)(m):c(m)}function c(m){return rC(t,d,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(m)}function d(m){return t.attempt(G2e,u,u)(m)}function u(m){return ct(m)?it(t,f,"whitespace")(m):f(m)}function f(m){return m===null||Oe(m)?(t.exit("definition"),o.parser.defined.push(n),e(m)):r(m)}}function K2e(t,e,r){return o;function o(s){return Dt(s)?Ff(t,n)(s):r(s)}function n(s){return nC(t,i,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(s)}function i(s){return ct(s)?it(t,a,"whitespace")(s):a(s)}function a(s){return s===null||Oe(s)?e(s):r(s)}}var yL={name:"hardBreakEscape",tokenize:Y2e};function Y2e(t,e,r){return o;function o(i){return t.enter("hardBreakEscape"),t.consume(i),n}function n(i){return Oe(i)?(t.exit("hardBreakEscape"),e(i)):r(i)}}var vL={name:"headingAtx",tokenize:J2e,resolve:X2e};function X2e(t,e){let r=t.length-2,o=3,n,i;return t[o][1].type==="whitespace"&&(o+=2),r-2>o&&t[r][1].type==="whitespace"&&(r-=2),t[r][1].type==="atxHeadingSequence"&&(o===r-1||r-4>o&&t[r-2][1].type==="whitespace")&&(r-=o+1===r?2:4),r>o&&(n={type:"atxHeadingText",start:t[o][1].start,end:t[r][1].end},i={type:"chunkText",start:t[o][1].start,end:t[r][1].end,contentType:"text"},Oo(t,o,r-o+1,[["enter",n,e],["enter",i,e],["exit",i,e],["exit",n,e]])),t}function J2e(t,e,r){let o=0;return n;function n(d){return t.enter("atxHeading"),i(d)}function i(d){return t.enter("atxHeadingSequence"),a(d)}function a(d){return d===35&&o++<6?(t.consume(d),a):d===null||Dt(d)?(t.exit("atxHeadingSequence"),s(d)):r(d)}function s(d){return d===35?(t.enter("atxHeadingSequence"),l(d)):d===null||Oe(d)?(t.exit("atxHeading"),e(d)):ct(d)?it(t,s,"whitespace")(d):(t.enter("atxHeadingText"),c(d))}function l(d){return d===35?(t.consume(d),l):(t.exit("atxHeadingSequence"),s(d))}function c(d){return d===null||d===35||Dt(d)?(t.exit("atxHeadingText"),s(d)):(t.consume(d),c)}}var mte=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],IL=["pre","script","style","textarea"];var wL={name:"htmlFlow",tokenize:tFe,resolveTo:eFe,concrete:!0},Q2e={tokenize:oFe,partial:!0},Z2e={tokenize:rFe,partial:!0};function eFe(t){let e=t.length;for(;e--&&!(t[e][0]==="enter"&&t[e][1].type==="htmlFlow"););return e>1&&t[e-2][1].type==="linePrefix"&&(t[e][1].start=t[e-2][1].start,t[e+1][1].start=t[e-2][1].start,t.splice(e-2,2)),t}function tFe(t,e,r){let o=this,n,i,a,s,l;return c;function c(U){return d(U)}function d(U){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(U),u}function u(U){return U===33?(t.consume(U),f):U===47?(t.consume(U),i=!0,g):U===63?(t.consume(U),n=3,o.interrupt?e:L):Vo(U)?(t.consume(U),a=String.fromCharCode(U),_):r(U)}function f(U){return U===45?(t.consume(U),n=2,m):U===91?(t.consume(U),n=5,s=0,h):Vo(U)?(t.consume(U),n=4,o.interrupt?e:L):r(U)}function m(U){return U===45?(t.consume(U),o.interrupt?e:L):r(U)}function h(U){let ge="CDATA[";return U===ge.charCodeAt(s++)?(t.consume(U),s===ge.length?o.interrupt?e:A:h):r(U)}function g(U){return Vo(U)?(t.consume(U),a=String.fromCharCode(U),_):r(U)}function _(U){if(U===null||U===47||U===62||Dt(U)){let ge=U===47,Ee=a.toLowerCase();return!ge&&!i&&IL.includes(Ee)?(n=1,o.interrupt?e(U):A(U)):mte.includes(a.toLowerCase())?(n=6,ge?(t.consume(U),b):o.interrupt?e(U):A(U)):(n=7,o.interrupt&&!o.parser.lazy[o.now().line]?r(U):i?y(U):v(U))}return U===45||Ho(U)?(t.consume(U),a+=String.fromCharCode(U),_):r(U)}function b(U){return U===62?(t.consume(U),o.interrupt?e:A):r(U)}function y(U){return ct(U)?(t.consume(U),y):T(U)}function v(U){return U===47?(t.consume(U),T):U===58||U===95||Vo(U)?(t.consume(U),S):ct(U)?(t.consume(U),v):T(U)}function S(U){return U===45||U===46||U===58||U===95||Ho(U)?(t.consume(U),S):N(U)}function N(U){return U===61?(t.consume(U),w):ct(U)?(t.consume(U),N):v(U)}function w(U){return U===null||U===60||U===61||U===62||U===96?r(U):U===34||U===39?(t.consume(U),l=U,E):ct(U)?(t.consume(U),w):I(U)}function E(U){return U===l?(t.consume(U),l=null,C):U===null||Oe(U)?r(U):(t.consume(U),E)}function I(U){return U===null||U===34||U===39||U===47||U===60||U===61||U===62||U===96||Dt(U)?N(U):(t.consume(U),I)}function C(U){return U===47||U===62||ct(U)?v(U):r(U)}function T(U){return U===62?(t.consume(U),O):r(U)}function O(U){return U===null||Oe(U)?A(U):ct(U)?(t.consume(U),O):r(U)}function A(U){return U===45&&n===2?(t.consume(U),z):U===60&&n===1?(t.consume(U),H):U===62&&n===4?(t.consume(U),ne):U===63&&n===3?(t.consume(U),L):U===93&&n===5?(t.consume(U),Y):Oe(U)&&(n===6||n===7)?(t.exit("htmlFlowData"),t.check(Q2e,ae,P)(U)):U===null||Oe(U)?(t.exit("htmlFlowData"),P(U)):(t.consume(U),A)}function P(U){return t.check(Z2e,B,ae)(U)}function B(U){return t.enter("lineEnding"),t.consume(U),t.exit("lineEnding"),$}function $(U){return U===null||Oe(U)?P(U):(t.enter("htmlFlowData"),A(U))}function z(U){return U===45?(t.consume(U),L):A(U)}function H(U){return U===47?(t.consume(U),a="",q):A(U)}function q(U){if(U===62){let ge=a.toLowerCase();return IL.includes(ge)?(t.consume(U),ne):A(U)}return Vo(U)&&a.length<8?(t.consume(U),a+=String.fromCharCode(U),q):A(U)}function Y(U){return U===93?(t.consume(U),L):A(U)}function L(U){return U===62?(t.consume(U),ne):U===45&&n===2?(t.consume(U),L):A(U)}function ne(U){return U===null||Oe(U)?(t.exit("htmlFlowData"),ae(U)):(t.consume(U),ne)}function ae(U){return t.exit("htmlFlow"),e(U)}}function rFe(t,e,r){let o=this;return n;function n(a){return Oe(a)?(t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),i):r(a)}function i(a){return o.parser.lazy[o.now().line]?r(a):e(a)}}function oFe(t,e,r){return o;function o(n){return t.enter("lineEnding"),t.consume(n),t.exit("lineEnding"),t.attempt(ul,e,r)}}var EL={name:"htmlText",tokenize:nFe};function nFe(t,e,r){let o=this,n,i,a;return s;function s(L){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(L),l}function l(L){return L===33?(t.consume(L),c):L===47?(t.consume(L),N):L===63?(t.consume(L),v):Vo(L)?(t.consume(L),I):r(L)}function c(L){return L===45?(t.consume(L),d):L===91?(t.consume(L),i=0,h):Vo(L)?(t.consume(L),y):r(L)}function d(L){return L===45?(t.consume(L),m):r(L)}function u(L){return L===null?r(L):L===45?(t.consume(L),f):Oe(L)?(a=u,H(L)):(t.consume(L),u)}function f(L){return L===45?(t.consume(L),m):u(L)}function m(L){return L===62?z(L):L===45?f(L):u(L)}function h(L){let ne="CDATA[";return L===ne.charCodeAt(i++)?(t.consume(L),i===ne.length?g:h):r(L)}function g(L){return L===null?r(L):L===93?(t.consume(L),_):Oe(L)?(a=g,H(L)):(t.consume(L),g)}function _(L){return L===93?(t.consume(L),b):g(L)}function b(L){return L===62?z(L):L===93?(t.consume(L),b):g(L)}function y(L){return L===null||L===62?z(L):Oe(L)?(a=y,H(L)):(t.consume(L),y)}function v(L){return L===null?r(L):L===63?(t.consume(L),S):Oe(L)?(a=v,H(L)):(t.consume(L),v)}function S(L){return L===62?z(L):v(L)}function N(L){return Vo(L)?(t.consume(L),w):r(L)}function w(L){return L===45||Ho(L)?(t.consume(L),w):E(L)}function E(L){return Oe(L)?(a=E,H(L)):ct(L)?(t.consume(L),E):z(L)}function I(L){return L===45||Ho(L)?(t.consume(L),I):L===47||L===62||Dt(L)?C(L):r(L)}function C(L){return L===47?(t.consume(L),z):L===58||L===95||Vo(L)?(t.consume(L),T):Oe(L)?(a=C,H(L)):ct(L)?(t.consume(L),C):z(L)}function T(L){return L===45||L===46||L===58||L===95||Ho(L)?(t.consume(L),T):O(L)}function O(L){return L===61?(t.consume(L),A):Oe(L)?(a=O,H(L)):ct(L)?(t.consume(L),O):C(L)}function A(L){return L===null||L===60||L===61||L===62||L===96?r(L):L===34||L===39?(t.consume(L),n=L,P):Oe(L)?(a=A,H(L)):ct(L)?(t.consume(L),A):(t.consume(L),B)}function P(L){return L===n?(t.consume(L),n=void 0,$):L===null?r(L):Oe(L)?(a=P,H(L)):(t.consume(L),P)}function B(L){return L===null||L===34||L===39||L===60||L===61||L===96?r(L):L===47||L===62||Dt(L)?C(L):(t.consume(L),B)}function $(L){return L===47||L===62||Dt(L)?C(L):r(L)}function z(L){return L===62?(t.consume(L),t.exit("htmlTextData"),t.exit("htmlText"),e):r(L)}function H(L){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(L),t.exit("lineEnding"),q}function q(L){return ct(L)?it(t,Y,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):Y(L)}function Y(L){return t.enter("htmlTextData"),a(L)}}var Bf={name:"labelEnd",tokenize:dFe,resolveTo:cFe,resolveAll:lFe},iFe={tokenize:uFe},aFe={tokenize:fFe},sFe={tokenize:pFe};function lFe(t){let e=-1;for(;++e<t.length;){let r=t[e][1];(r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd")&&(t.splice(e+1,r.type==="labelImage"?4:2),r.type="data",e++)}return t}function cFe(t,e){let r=t.length,o=0,n,i,a,s;for(;r--;)if(n=t[r][1],i){if(n.type==="link"||n.type==="labelLink"&&n._inactive)break;t[r][0]==="enter"&&n.type==="labelLink"&&(n._inactive=!0)}else if(a){if(t[r][0]==="enter"&&(n.type==="labelImage"||n.type==="labelLink")&&!n._balanced&&(i=r,n.type!=="labelLink")){o=2;break}}else n.type==="labelEnd"&&(a=r);let l={type:t[i][1].type==="labelLink"?"link":"image",start:Object.assign({},t[i][1].start),end:Object.assign({},t[t.length-1][1].end)},c={type:"label",start:Object.assign({},t[i][1].start),end:Object.assign({},t[a][1].end)},d={type:"labelText",start:Object.assign({},t[i+o+2][1].end),end:Object.assign({},t[a-2][1].start)};return s=[["enter",l,e],["enter",c,e]],s=fi(s,t.slice(i+1,i+o+3)),s=fi(s,[["enter",d,e]]),s=fi(s,Pd(e.parser.constructs.insideSpan.null,t.slice(i+o+4,a-3),e)),s=fi(s,[["exit",d,e],t[a-2],t[a-1],["exit",c,e]]),s=fi(s,t.slice(a+1)),s=fi(s,[["exit",l,e]]),Oo(t,i,t.length,s),t}function dFe(t,e,r){let o=this,n=o.events.length,i,a;for(;n--;)if((o.events[n][1].type==="labelImage"||o.events[n][1].type==="labelLink")&&!o.events[n][1]._balanced){i=o.events[n][1];break}return s;function s(f){return i?i._inactive?u(f):(a=o.parser.defined.includes(Gn(o.sliceSerialize({start:i.end,end:o.now()}))),t.enter("labelEnd"),t.enter("labelMarker"),t.consume(f),t.exit("labelMarker"),t.exit("labelEnd"),l):r(f)}function l(f){return f===40?t.attempt(iFe,d,a?d:u)(f):f===91?t.attempt(aFe,d,a?c:u)(f):a?d(f):u(f)}function c(f){return t.attempt(sFe,d,u)(f)}function d(f){return e(f)}function u(f){return i._balanced=!0,r(f)}}function uFe(t,e,r){return o;function o(u){return t.enter("resource"),t.enter("resourceMarker"),t.consume(u),t.exit("resourceMarker"),n}function n(u){return Dt(u)?Ff(t,i)(u):i(u)}function i(u){return u===41?d(u):rC(t,a,s,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(u)}function a(u){return Dt(u)?Ff(t,l)(u):d(u)}function s(u){return r(u)}function l(u){return u===34||u===39||u===40?nC(t,c,r,"resourceTitle","resourceTitleMarker","resourceTitleString")(u):d(u)}function c(u){return Dt(u)?Ff(t,d)(u):d(u)}function d(u){return u===41?(t.enter("resourceMarker"),t.consume(u),t.exit("resourceMarker"),t.exit("resource"),e):r(u)}}function fFe(t,e,r){let o=this;return n;function n(s){return oC.call(o,t,i,a,"reference","referenceMarker","referenceString")(s)}function i(s){return o.parser.defined.includes(Gn(o.sliceSerialize(o.events[o.events.length-1][1]).slice(1,-1)))?e(s):r(s)}function a(s){return r(s)}}function pFe(t,e,r){return o;function o(i){return t.enter("reference"),t.enter("referenceMarker"),t.consume(i),t.exit("referenceMarker"),n}function n(i){return i===93?(t.enter("referenceMarker"),t.consume(i),t.exit("referenceMarker"),t.exit("reference"),e):r(i)}}var SL={name:"labelStartImage",tokenize:mFe,resolveAll:Bf.resolveAll};function mFe(t,e,r){let o=this;return n;function n(s){return t.enter("labelImage"),t.enter("labelImageMarker"),t.consume(s),t.exit("labelImageMarker"),i}function i(s){return s===91?(t.enter("labelMarker"),t.consume(s),t.exit("labelMarker"),t.exit("labelImage"),a):r(s)}function a(s){return s===94&&"_hiddenFootnoteSupport"in o.parser.constructs?r(s):e(s)}}var CL={name:"labelStartLink",tokenize:hFe,resolveAll:Bf.resolveAll};function hFe(t,e,r){let o=this;return n;function n(a){return t.enter("labelLink"),t.enter("labelMarker"),t.consume(a),t.exit("labelMarker"),t.exit("labelLink"),i}function i(a){return a===94&&"_hiddenFootnoteSupport"in o.parser.constructs?r(a):e(a)}}var Qb={name:"lineEnding",tokenize:gFe};function gFe(t,e){return r;function r(o){return t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),it(t,e,"linePrefix")}}var $f={name:"thematicBreak",tokenize:_Fe};function _Fe(t,e,r){let o=0,n;return i;function i(c){return t.enter("thematicBreak"),a(c)}function a(c){return n=c,s(c)}function s(c){return c===n?(t.enter("thematicBreakSequence"),l(c)):o>=3&&(c===null||Oe(c))?(t.exit("thematicBreak"),e(c)):r(c)}function l(c){return c===n?(t.consume(c),o++,l):(t.exit("thematicBreakSequence"),ct(c)?it(t,s,"whitespace")(c):s(c))}}var Wn={name:"list",tokenize:yFe,continuation:{tokenize:vFe},exit:wFe},xFe={tokenize:EFe,partial:!0},bFe={tokenize:IFe,partial:!0};function yFe(t,e,r){let o=this,n=o.events[o.events.length-1],i=n&&n[1].type==="linePrefix"?n[2].sliceSerialize(n[1],!0).length:0,a=0;return s;function s(m){let h=o.containerState.type||(m===42||m===43||m===45?"listUnordered":"listOrdered");if(h==="listUnordered"?!o.containerState.marker||m===o.containerState.marker:Kb(m)){if(o.containerState.type||(o.containerState.type=h,t.enter(h,{_container:!0})),h==="listUnordered")return t.enter("listItemPrefix"),m===42||m===45?t.check($f,r,c)(m):c(m);if(!o.interrupt||m===49)return t.enter("listItemPrefix"),t.enter("listItemValue"),l(m)}return r(m)}function l(m){return Kb(m)&&++a<10?(t.consume(m),l):(!o.interrupt||a<2)&&(o.containerState.marker?m===o.containerState.marker:m===41||m===46)?(t.exit("listItemValue"),c(m)):r(m)}function c(m){return t.enter("listItemMarker"),t.consume(m),t.exit("listItemMarker"),o.containerState.marker=o.containerState.marker||m,t.check(ul,o.interrupt?r:d,t.attempt(xFe,f,u))}function d(m){return o.containerState.initialBlankLine=!0,i++,f(m)}function u(m){return ct(m)?(t.enter("listItemPrefixWhitespace"),t.consume(m),t.exit("listItemPrefixWhitespace"),f):r(m)}function f(m){return o.containerState.size=i+o.sliceSerialize(t.exit("listItemPrefix"),!0).length,e(m)}}function vFe(t,e,r){let o=this;return o.containerState._closeFlow=void 0,t.check(ul,n,i);function n(s){return o.containerState.furtherBlankLines=o.containerState.furtherBlankLines||o.containerState.initialBlankLine,it(t,e,"listItemIndent",o.containerState.size+1)(s)}function i(s){return o.containerState.furtherBlankLines||!ct(s)?(o.containerState.furtherBlankLines=void 0,o.containerState.initialBlankLine=void 0,a(s)):(o.containerState.furtherBlankLines=void 0,o.containerState.initialBlankLine=void 0,t.attempt(bFe,e,a)(s))}function a(s){return o.containerState._closeFlow=!0,o.interrupt=void 0,it(t,t.attempt(Wn,e,r),"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s)}}function IFe(t,e,r){let o=this;return it(t,n,"listItemIndent",o.containerState.size+1);function n(i){let a=o.events[o.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===o.containerState.size?e(i):r(i)}}function wFe(t){t.exit(this.containerState.type)}function EFe(t,e,r){let o=this;return it(t,n,"listItemPrefixWhitespace",o.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function n(i){let a=o.events[o.events.length-1];return!ct(i)&&a&&a[1].type==="listItemPrefixWhitespace"?e(i):r(i)}}var iC={name:"setextUnderline",tokenize:CFe,resolveTo:SFe};function SFe(t,e){let r=t.length,o,n,i;for(;r--;)if(t[r][0]==="enter"){if(t[r][1].type==="content"){o=r;break}t[r][1].type==="paragraph"&&(n=r)}else t[r][1].type==="content"&&t.splice(r,1),!i&&t[r][1].type==="definition"&&(i=r);let a={type:"setextHeading",start:Object.assign({},t[n][1].start),end:Object.assign({},t[t.length-1][1].end)};return t[n][1].type="setextHeadingText",i?(t.splice(n,0,["enter",a,e]),t.splice(i+1,0,["exit",t[o][1],e]),t[o][1].end=Object.assign({},t[i][1].end)):t[o][1]=a,t.push(["exit",a,e]),t}function CFe(t,e,r){let o=this,n;return i;function i(c){let d=o.events.length,u;for(;d--;)if(o.events[d][1].type!=="lineEnding"&&o.events[d][1].type!=="linePrefix"&&o.events[d][1].type!=="content"){u=o.events[d][1].type==="paragraph";break}return!o.parser.lazy[o.now().line]&&(o.interrupt||u)?(t.enter("setextHeadingLine"),n=c,a(c)):r(c)}function a(c){return t.enter("setextHeadingLineSequence"),s(c)}function s(c){return c===n?(t.consume(c),s):(t.exit("setextHeadingLineSequence"),ct(c)?it(t,l,"lineSuffix")(c):l(c))}function l(c){return c===null||Oe(c)?(t.exit("setextHeadingLine"),e(c)):r(c)}}var hte={tokenize:TFe};function TFe(t){let e=this,r=t.attempt(ul,o,t.attempt(this.parser.constructs.flowInitial,n,it(t,t.attempt(this.parser.constructs.flow,n,t.attempt(xL,n)),"linePrefix")));return r;function o(i){if(i===null){t.consume(i);return}return t.enter("lineEndingBlank"),t.consume(i),t.exit("lineEndingBlank"),e.currentConstruct=void 0,r}function n(i){if(i===null){t.consume(i);return}return t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),e.currentConstruct=void 0,r}}var gte={resolveAll:yte()},_te=bte("string"),xte=bte("text");function bte(t){return{tokenize:e,resolveAll:yte(t==="text"?kFe:void 0)};function e(r){let o=this,n=this.parser.constructs[t],i=r.attempt(n,a,s);return a;function a(d){return c(d)?i(d):s(d)}function s(d){if(d===null){r.consume(d);return}return r.enter("data"),r.consume(d),l}function l(d){return c(d)?(r.exit("data"),i(d)):(r.consume(d),l)}function c(d){if(d===null)return!0;let u=n[d],f=-1;if(u)for(;++f<u.length;){let m=u[f];if(!m.previous||m.previous.call(o,o.previous))return!0}return!1}}}function yte(t){return e;function e(r,o){let n=-1,i;for(;++n<=r.length;)i===void 0?r[n]&&r[n][1].type==="data"&&(i=n,n++):(!r[n]||r[n][1].type!=="data")&&(n!==i+2&&(r[i][1].end=r[n-1][1].end,r.splice(i+2,n-i-2),n=i+2),i=void 0);return t?t(r,o):r}}function kFe(t,e){let r=0;for(;++r<=t.length;)if((r===t.length||t[r][1].type==="lineEnding")&&t[r-1][1].type==="data"){let o=t[r-1][1],n=e.sliceStream(o),i=n.length,a=-1,s=0,l;for(;i--;){let c=n[i];if(typeof c=="string"){for(a=c.length;c.charCodeAt(a-1)===32;)s++,a--;if(a)break;a=-1}else if(c===-2)l=!0,s++;else if(c!==-1){i++;break}}if(s){let c={type:r===t.length||l||s<2?"lineSuffix":"hardBreakTrailing",start:{line:o.end.line,column:o.end.column-s,offset:o.end.offset-s,_index:o.start._index+i,_bufferIndex:i?a:o.start._bufferIndex+a},end:Object.assign({},o.end)};o.end=Object.assign({},c.start),o.start.offset===o.end.offset?Object.assign(o,c):(t.splice(r,0,["enter",c,e],["exit",c,e]),r+=2)}r++}return t}function vte(t,e,r){let o=Object.assign(r?Object.assign({},r):{line:1,column:1,offset:0},{_index:0,_bufferIndex:-1}),n={},i=[],a=[],s=[],l=!0,c={consume:S,enter:N,exit:w,attempt:C(E),check:C(I),interrupt:C(I,{interrupt:!0})},d={previous:null,code:null,containerState:{},events:[],parser:t,sliceStream:g,sliceSerialize:h,now:_,defineSkip:b,write:m},u=e.tokenize.call(d,c),f;return e.resolveAll&&i.push(e),d;function m(P){return a=fi(a,P),y(),a[a.length-1]!==null?[]:(T(e,0),d.events=Pd(i,d.events,d),d.events)}function h(P,B){return PFe(g(P),B)}function g(P){return NFe(a,P)}function _(){let{line:P,column:B,offset:$,_index:z,_bufferIndex:H}=o;return{line:P,column:B,offset:$,_index:z,_bufferIndex:H}}function b(P){n[P.line]=P.column,A()}function y(){let P;for(;o._index<a.length;){let B=a[o._index];if(typeof B=="string")for(P=o._index,o._bufferIndex<0&&(o._bufferIndex=0);o._index===P&&o._bufferIndex<B.length;)v(B.charCodeAt(o._bufferIndex));else v(B)}}function v(P){l=void 0,f=P,u=u(P)}function S(P){Oe(P)?(o.line++,o.column=1,o.offset+=P===-3?2:1,A()):P!==-1&&(o.column++,o.offset++),o._bufferIndex<0?o._index++:(o._bufferIndex++,o._bufferIndex===a[o._index].length&&(o._bufferIndex=-1,o._index++)),d.previous=P,l=!0}function N(P,B){let $=B||{};return $.type=P,$.start=_(),d.events.push(["enter",$,d]),s.push($),$}function w(P){let B=s.pop();return B.end=_(),d.events.push(["exit",B,d]),B}function E(P,B){T(P,B.from)}function I(P,B){B.restore()}function C(P,B){return $;function $(z,H,q){let Y,L,ne,ae;return Array.isArray(z)?ge(z):"tokenize"in z?ge([z]):U(z);function U(Ae){return Pe;function Pe(lt){let Rt=lt!==null&&Ae[lt],ut=lt!==null&&Ae.null,ht=[...Array.isArray(Rt)?Rt:Rt?[Rt]:[],...Array.isArray(ut)?ut:ut?[ut]:[]];return ge(ht)(lt)}}function ge(Ae){return Y=Ae,L=0,Ae.length===0?q:Ee(Ae[L])}function Ee(Ae){return Pe;function Pe(lt){return ae=O(),ne=Ae,Ae.partial||(d.currentConstruct=Ae),Ae.name&&d.parser.constructs.disable.null.includes(Ae.name)?Ye(lt):Ae.tokenize.call(B?Object.assign(Object.create(d),B):d,c,Ve,Ye)(lt)}}function Ve(Ae){return l=!0,P(ne,ae),H}function Ye(Ae){return l=!0,ae.restore(),++L<Y.length?Ee(Y[L]):q}}}function T(P,B){P.resolveAll&&!i.includes(P)&&i.push(P),P.resolve&&Oo(d.events,B,d.events.length-B,P.resolve(d.events.slice(B),d)),P.resolveTo&&(d.events=P.resolveTo(d.events,d))}function O(){let P=_(),B=d.previous,$=d.currentConstruct,z=d.events.length,H=Array.from(s);return{restore:q,from:z};function q(){o=P,d.previous=B,d.currentConstruct=$,d.events.length=z,s=H,A()}}function A(){o.line in n&&o.column<2&&(o.column=n[o.line],o.offset+=n[o.line]-1)}}function NFe(t,e){let r=e.start._index,o=e.start._bufferIndex,n=e.end._index,i=e.end._bufferIndex,a;if(r===n)a=[t[r].slice(o,i)];else{if(a=t.slice(r,n),o>-1){let s=a[0];typeof s=="string"?a[0]=s.slice(o):a.shift()}i>0&&a.push(t[n].slice(0,i))}return a}function PFe(t,e){let r=-1,o=[],n;for(;++r<t.length;){let i=t[r],a;if(typeof i=="string")a=i;else switch(i){case-5:{a="\r";break}case-4:{a=`
64
64
  `;break}case-3:{a=`\r
65
- `;break}case-2:{a=e?" ":" ";break}case-1:{if(!e&&n)continue;a=" ";break}default:a=String.fromCharCode(i)}n=i===-2,o.push(a)}return o.join("")}var TL={};ar(TL,{attentionMarkers:()=>BFe,contentInitial:()=>DFe,disable:()=>$Fe,document:()=>OFe,flow:()=>RFe,flowInitial:()=>AFe,insideSpan:()=>FFe,string:()=>MFe,text:()=>LFe});var OFe={42:Wn,43:Wn,45:Wn,48:Wn,49:Wn,50:Wn,51:Wn,52:Wn,53:Wn,54:Wn,55:Wn,56:Wn,57:Wn,62:XS},DFe={91:bL},AFe={[-2]:Xb,[-1]:Xb,32:Xb},RFe={35:vL,42:$f,45:[iC,$f],60:wL,61:iC,95:$f,96:ZS,126:ZS},MFe={38:QS,92:JS},LFe={[-5]:Qb,[-4]:Qb,[-3]:Qb,33:SL,38:QS,42:Yb,60:[gL,EL],91:CL,92:[yL,JS],93:Bf,95:Yb,96:_L},FFe={null:[Yb,gte]},BFe={null:[42,95]},$Fe={null:[]};function kL(t){let r=KS([TL,...(t||{}).extensions||[]]),o={defined:[],lazy:{},constructs:r,content:n(cte),document:n(ute),flow:n(hte),string:n(_te),text:n(xte)};return o;function n(i){return a;function a(s){return vte(o,i,s)}}}function NL(t){for(;!tC(t););return t}var Ite=/[\0\t\n\r]/g;function PL(){let t=1,e="",r=!0,o;return n;function n(i,a,s){let l=[],c,d,u,f,m;for(i=e+(typeof i=="string"?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,e="",r&&(i.charCodeAt(0)===65279&&u++,r=void 0);u<i.length;){if(Ite.lastIndex=u,c=Ite.exec(i),f=c&&c.index!==void 0?c.index:i.length,m=i.charCodeAt(f),!c){e=i.slice(u);break}if(m===10&&u===f&&o)l.push(-3),o=void 0;else switch(o&&(l.push(-5),o=void 0),u<f&&(l.push(i.slice(u,f)),t+=f-u),m){case 0:{l.push(65533),t++;break}case 9:{for(d=Math.ceil(t/4)*4,l.push(-2);t++<d;)l.push(-1);break}case 10:{l.push(-4),t=1;break}default:o=!0,t=1}u=f+1}return s&&(o&&l.push(-5),e&&l.push(e),l.push(null)),l}}var zFe=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function wte(t){return t.replace(zFe,UFe)}function UFe(t,e,r){if(e)return e;if(r.charCodeAt(0)===35){let n=r.charCodeAt(1),i=n===120||n===88;return YS(r.slice(i?2:1),i?16:10)}return Eh(r)||t}function Ch(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?Ete(t.position):"start"in t||"end"in t?Ete(t):"line"in t||"column"in t?OL(t):""}function OL(t){return Ste(t&&t.line)+":"+Ste(t&&t.column)}function Ete(t){return OL(t&&t.start)+"-"+OL(t&&t.end)}function Ste(t){return t&&typeof t=="number"?t:1}var Tte={}.hasOwnProperty;function DL(t,e,r){return typeof e!="string"&&(r=e,e=void 0),VFe(r)(NL(kL(r).document().write(PL()(t,e,!0))))}function VFe(t){let e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(Ut),autolinkProtocol:C,autolinkEmail:C,atxHeading:i(Jr),blockQuote:i(lt),characterEscape:C,characterReference:C,codeFenced:i(Rt),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:i(Rt,a),codeText:i(ut,a),codeTextData:C,data:C,codeFlowValue:C,definition:i(ht),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:i(bt),hardBreakEscape:i(Mt),hardBreakTrailing:i(Mt),htmlFlow:i(ve,a),htmlFlowData:C,htmlText:i(ve,a),htmlTextData:C,image:i(fn),label:a,link:i(Ut),listItem:i(Hr),listItemValue:f,listOrdered:i(pt,u),listUnordered:i(pt),paragraph:i(jr),reference:U,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:i(Jr),strong:i(Mo),thematicBreak:i(ie)},exit:{atxHeading:l(),atxHeadingSequence:N,autolink:l(),autolinkEmail:Pe,autolinkProtocol:Ae,blockQuote:l(),characterEscapeValue:T,characterReferenceMarkerHexadecimal:Ee,characterReferenceMarkerNumeric:Ee,characterReferenceValue:Ve,characterReference:Ye,codeFenced:l(_),codeFencedFence:g,codeFencedFenceInfo:m,codeFencedFenceMeta:h,codeFlowValue:T,codeIndented:l(b),codeText:l($),codeTextData:T,data:T,definition:l(),definitionDestinationString:S,definitionLabelString:y,definitionTitleString:v,emphasis:l(),hardBreakEscape:l(A),hardBreakTrailing:l(A),htmlFlow:l(P),htmlFlowData:T,htmlText:l(B),htmlTextData:T,image:l(H),label:Y,labelText:q,lineEnding:O,link:l(z),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:ge,resourceDestinationString:L,resourceTitleString:ne,resource:ae,setextHeading:l(I),setextHeadingLineSequence:E,setextHeadingText:w,strong:l(),thematicBreak:l()}};kte(e,(t||{}).mdastExtensions||[]);let r={};return o;function o(j){let Q={type:"root",children:[]},se={stack:[Q],tokenStack:[],config:e,enter:s,exit:c,buffer:a,resume:d,data:r},je=[],yt=-1;for(;++yt<j.length;)if(j[yt][1].type==="listOrdered"||j[yt][1].type==="listUnordered")if(j[yt][0]==="enter")je.push(yt);else{let Nt=je.pop();yt=n(j,Nt,yt)}for(yt=-1;++yt<j.length;){let Nt=e[j[yt][0]];Tte.call(Nt,j[yt][1].type)&&Nt[j[yt][1].type].call(Object.assign({sliceSerialize:j[yt][2].sliceSerialize},se),j[yt][1])}if(se.tokenStack.length>0){let Nt=se.tokenStack[se.tokenStack.length-1];(Nt[1]||Cte).call(se,void 0,Nt[0])}for(Q.position={start:Od(j.length>0?j[0][1].start:{line:1,column:1,offset:0}),end:Od(j.length>0?j[j.length-2][1].end:{line:1,column:1,offset:0})},yt=-1;++yt<e.transforms.length;)Q=e.transforms[yt](Q)||Q;return Q}function n(j,Q,se){let je=Q-1,yt=-1,Nt=!1,Fn,br,Pr,Qn;for(;++je<=se;){let lo=j[je];switch(lo[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{lo[0]==="enter"?yt++:yt--,Qn=void 0;break}case"lineEndingBlank":{lo[0]==="enter"&&(Fn&&!Qn&&!yt&&!Pr&&(Pr=je),Qn=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Qn=void 0}if(!yt&&lo[0]==="enter"&&lo[1].type==="listItemPrefix"||yt===-1&&lo[0]==="exit"&&(lo[1].type==="listUnordered"||lo[1].type==="listOrdered")){if(Fn){let pn=je;for(br=void 0;pn--;){let mn=j[pn];if(mn[1].type==="lineEnding"||mn[1].type==="lineEndingBlank"){if(mn[0]==="exit")continue;br&&(j[br][1].type="lineEndingBlank",Nt=!0),mn[1].type="lineEnding",br=pn}else if(!(mn[1].type==="linePrefix"||mn[1].type==="blockQuotePrefix"||mn[1].type==="blockQuotePrefixWhitespace"||mn[1].type==="blockQuoteMarker"||mn[1].type==="listItemIndent"))break}Pr&&(!br||Pr<br)&&(Fn._spread=!0),Fn.end=Object.assign({},br?j[br][1].start:lo[1].end),j.splice(br||je,0,["exit",Fn,lo[2]]),je++,se++}if(lo[1].type==="listItemPrefix"){let pn={type:"listItem",_spread:!1,start:Object.assign({},lo[1].start),end:void 0};Fn=pn,j.splice(je,0,["enter",pn,lo[2]]),je++,se++,Pr=void 0,Qn=!0}}}return j[Q][1]._spread=Nt,se}function i(j,Q){return se;function se(je){s.call(this,j(je),je),Q&&Q.call(this,je)}}function a(){this.stack.push({type:"fragment",children:[]})}function s(j,Q,se){this.stack[this.stack.length-1].children.push(j),this.stack.push(j),this.tokenStack.push([Q,se]),j.position={start:Od(Q.start),end:void 0}}function l(j){return Q;function Q(se){j&&j.call(this,se),c.call(this,se)}}function c(j,Q){let se=this.stack.pop(),je=this.tokenStack.pop();if(je)je[0].type!==j.type&&(Q?Q.call(this,j,je[0]):(je[1]||Cte).call(this,j,je[0]));else throw new Error("Cannot close `"+j.type+"` ("+Ch({start:j.start,end:j.end})+"): it\u2019s not open");se.position.end=Od(j.end)}function d(){return hL(this.stack.pop())}function u(){this.data.expectingFirstListItemValue=!0}function f(j){if(this.data.expectingFirstListItemValue){let Q=this.stack[this.stack.length-2];Q.start=Number.parseInt(this.sliceSerialize(j),10),this.data.expectingFirstListItemValue=void 0}}function m(){let j=this.resume(),Q=this.stack[this.stack.length-1];Q.lang=j}function h(){let j=this.resume(),Q=this.stack[this.stack.length-1];Q.meta=j}function g(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function _(){let j=this.resume(),Q=this.stack[this.stack.length-1];Q.value=j.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function b(){let j=this.resume(),Q=this.stack[this.stack.length-1];Q.value=j.replace(/(\r?\n|\r)$/g,"")}function y(j){let Q=this.resume(),se=this.stack[this.stack.length-1];se.label=Q,se.identifier=Gn(this.sliceSerialize(j)).toLowerCase()}function v(){let j=this.resume(),Q=this.stack[this.stack.length-1];Q.title=j}function S(){let j=this.resume(),Q=this.stack[this.stack.length-1];Q.url=j}function N(j){let Q=this.stack[this.stack.length-1];if(!Q.depth){let se=this.sliceSerialize(j).length;Q.depth=se}}function w(){this.data.setextHeadingSlurpLineEnding=!0}function E(j){let Q=this.stack[this.stack.length-1];Q.depth=this.sliceSerialize(j).codePointAt(0)===61?1:2}function I(){this.data.setextHeadingSlurpLineEnding=void 0}function C(j){let se=this.stack[this.stack.length-1].children,je=se[se.length-1];(!je||je.type!=="text")&&(je=$e(),je.position={start:Od(j.start),end:void 0},se.push(je)),this.stack.push(je)}function T(j){let Q=this.stack.pop();Q.value+=this.sliceSerialize(j),Q.position.end=Od(j.end)}function O(j){let Q=this.stack[this.stack.length-1];if(this.data.atHardBreak){let se=Q.children[Q.children.length-1];se.position.end=Od(j.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes(Q.type)&&(C.call(this,j),T.call(this,j))}function A(){this.data.atHardBreak=!0}function P(){let j=this.resume(),Q=this.stack[this.stack.length-1];Q.value=j}function B(){let j=this.resume(),Q=this.stack[this.stack.length-1];Q.value=j}function $(){let j=this.resume(),Q=this.stack[this.stack.length-1];Q.value=j}function z(){let j=this.stack[this.stack.length-1];if(this.data.inReference){let Q=this.data.referenceType||"shortcut";j.type+="Reference",j.referenceType=Q,delete j.url,delete j.title}else delete j.identifier,delete j.label;this.data.referenceType=void 0}function H(){let j=this.stack[this.stack.length-1];if(this.data.inReference){let Q=this.data.referenceType||"shortcut";j.type+="Reference",j.referenceType=Q,delete j.url,delete j.title}else delete j.identifier,delete j.label;this.data.referenceType=void 0}function q(j){let Q=this.sliceSerialize(j),se=this.stack[this.stack.length-2];se.label=wte(Q),se.identifier=Gn(Q).toLowerCase()}function Y(){let j=this.stack[this.stack.length-1],Q=this.resume(),se=this.stack[this.stack.length-1];if(this.data.inReference=!0,se.type==="link"){let je=j.children;se.children=je}else se.alt=Q}function L(){let j=this.resume(),Q=this.stack[this.stack.length-1];Q.url=j}function ne(){let j=this.resume(),Q=this.stack[this.stack.length-1];Q.title=j}function ae(){this.data.inReference=void 0}function U(){this.data.referenceType="collapsed"}function ge(j){let Q=this.resume(),se=this.stack[this.stack.length-1];se.label=Q,se.identifier=Gn(this.sliceSerialize(j)).toLowerCase(),this.data.referenceType="full"}function Ee(j){this.data.characterReferenceType=j.type}function Ve(j){let Q=this.sliceSerialize(j),se=this.data.characterReferenceType,je;se?(je=YS(Q,se==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):je=Eh(Q);let yt=this.stack[this.stack.length-1];yt.value+=je}function Ye(j){let Q=this.stack.pop();Q.position.end=Od(j.end)}function Ae(j){T.call(this,j);let Q=this.stack[this.stack.length-1];Q.url=this.sliceSerialize(j)}function Pe(j){T.call(this,j);let Q=this.stack[this.stack.length-1];Q.url="mailto:"+this.sliceSerialize(j)}function lt(){return{type:"blockquote",children:[]}}function Rt(){return{type:"code",lang:null,meta:null,value:""}}function ut(){return{type:"inlineCode",value:""}}function ht(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function bt(){return{type:"emphasis",children:[]}}function Jr(){return{type:"heading",depth:0,children:[]}}function Mt(){return{type:"break"}}function ve(){return{type:"html",value:""}}function fn(){return{type:"image",title:null,url:"",alt:null}}function Ut(){return{type:"link",title:null,url:"",children:[]}}function pt(j){return{type:"list",ordered:j.type==="listOrdered",start:null,spread:j._spread,children:[]}}function Hr(j){return{type:"listItem",spread:j._spread,checked:null,children:[]}}function jr(){return{type:"paragraph",children:[]}}function Mo(){return{type:"strong",children:[]}}function $e(){return{type:"text",value:""}}function ie(){return{type:"thematicBreak"}}}function Od(t){return{line:t.line,column:t.column,offset:t.offset}}function kte(t,e){let r=-1;for(;++r<e.length;){let o=e[r];Array.isArray(o)?kte(t,o):HFe(t,o)}}function HFe(t,e){let r;for(r in e)if(Tte.call(e,r))switch(r){case"canContainEols":{let o=e[r];o&&t[r].push(...o);break}case"transforms":{let o=e[r];o&&t[r].push(...o);break}case"enter":case"exit":{let o=e[r];o&&Object.assign(t[r],o);break}}}function Cte(t,e){throw t?new Error("Cannot close `"+t.type+"` ("+Ch({start:t.start,end:t.end})+"): a different token (`"+e.type+"`, "+Ch({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+Ch({start:e.start,end:e.end})+") is still open")}function AL(t,e){let r=String(t);if(typeof e!="string")throw new TypeError("Expected character");let o=0,n=r.indexOf(e);for(;n!==-1;)o++,n=r.indexOf(e,n+e.length);return o}function RL(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var Th=(function(t){if(t==null)return WFe;if(typeof t=="function")return aC(t);if(typeof t=="object")return Array.isArray(t)?jFe(t):qFe(t);if(typeof t=="string")return GFe(t);throw new Error("Expected function, string, or object as test")});function jFe(t){let e=[],r=-1;for(;++r<t.length;)e[r]=Th(t[r]);return aC(o);function o(...n){let i=-1;for(;++i<e.length;)if(e[i].apply(this,n))return!0;return!1}}function qFe(t){let e=t;return aC(r);function r(o){let n=o,i;for(i in t)if(n[i]!==e[i])return!1;return!0}}function GFe(t){return aC(e);function e(r){return r&&r.type===t}}function aC(t){return e;function e(r,o,n){return!!(KFe(r)&&t.call(this,r,typeof o=="number"?o:void 0,n||void 0))}}function WFe(){return!0}function KFe(t){return t!==null&&typeof t=="object"&&"type"in t}var Nte=[],Pte=!0,ML=!1,Ote="skip";function LL(t,e,r,o){let n;typeof e=="function"&&typeof r!="function"?(o=r,r=e):n=e;let i=Th(n),a=o?-1:1;s(t,void 0,[])();function s(l,c,d){let u=l&&typeof l=="object"?l:{};if(typeof u.type=="string"){let m=typeof u.tagName=="string"?u.tagName:typeof u.name=="string"?u.name:void 0;Object.defineProperty(f,"name",{value:"node ("+(l.type+(m?"<"+m+">":""))+")"})}return f;function f(){let m=Nte,h,g,_;if((!e||i(l,c,d[d.length-1]||void 0))&&(m=YFe(r(l,d)),m[0]===ML))return m;if("children"in l&&l.children){let b=l;if(b.children&&m[0]!==Ote)for(g=(o?b.children.length:-1)+a,_=d.concat(b);g>-1&&g<b.children.length;){let y=b.children[g];if(h=s(y,g,_)(),h[0]===ML)return h;g=typeof h[1]=="number"?h[1]:g+a}}return m}}}function YFe(t){return Array.isArray(t)?t:typeof t=="number"?[Pte,t]:t==null?Nte:[t]}function FL(t,e,r){let n=Th((r||{}).ignore||[]),i=XFe(e),a=-1;for(;++a<i.length;)LL(t,"text",s);function s(c,d){let u=-1,f;for(;++u<d.length;){let m=d[u],h=f?f.children:void 0;if(n(m,h?h.indexOf(m):void 0,f))return;f=m}if(f)return l(c,d)}function l(c,d){let u=d[d.length-1],f=i[a][0],m=i[a][1],h=0,_=u.children.indexOf(c),b=!1,y=[];f.lastIndex=0;let v=f.exec(c.value);for(;v;){let S=v.index,N={index:v.index,input:v.input,stack:[...d,c]},w=m(...v,N);if(typeof w=="string"&&(w=w.length>0?{type:"text",value:w}:void 0),w===!1?f.lastIndex=S+1:(h!==S&&y.push({type:"text",value:c.value.slice(h,S)}),Array.isArray(w)?y.push(...w):w&&y.push(w),h=S+v[0].length,b=!0),!f.global)break;v=f.exec(c.value)}return b?(h<c.value.length&&y.push({type:"text",value:c.value.slice(h)}),u.children.splice(_,1,...y)):y=[c],_+y.length}}function XFe(t){let e=[];if(!Array.isArray(t))throw new TypeError("Expected find and replace tuple or list of tuples");let r=!t[0]||Array.isArray(t[0])?t:[t],o=-1;for(;++o<r.length;){let n=r[o];e.push([JFe(n[0]),QFe(n[1])])}return e}function JFe(t){return typeof t=="string"?new RegExp(RL(t),"g"):t}function QFe(t){return typeof t=="function"?t:function(){return t}}function $L(){return{transforms:[nBe],enter:{literalAutolink:ZFe,literalAutolinkEmail:BL,literalAutolinkHttp:BL,literalAutolinkWww:BL},exit:{literalAutolink:oBe,literalAutolinkEmail:rBe,literalAutolinkHttp:eBe,literalAutolinkWww:tBe}}}function ZFe(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function BL(t){this.config.enter.autolinkProtocol.call(this,t)}function eBe(t){this.config.exit.autolinkProtocol.call(this,t)}function tBe(t){this.config.exit.data.call(this,t);let e=this.stack[this.stack.length-1];e.type,e.url="http://"+this.sliceSerialize(t)}function rBe(t){this.config.exit.autolinkEmail.call(this,t)}function oBe(t){this.exit(t)}function nBe(t){FL(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,iBe],[/([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/g,aBe]],{ignore:["link","linkReference"]})}function iBe(t,e,r,o,n){let i="";if(!Dte(n)||(/^w/i.test(e)&&(r=e+r,e="",i="http://"),!sBe(r)))return!1;let a=lBe(r+o);if(!a[0])return!1;let s={type:"link",title:null,url:i+e+a[0],children:[{type:"text",value:e+a[0]}]};return a[1]?[s,{type:"text",value:a[1]}]:s}function aBe(t,e,r,o){return!Dte(o,!0)||/[-\d_]$/.test(r)?!1:{type:"link",title:null,url:"mailto:"+e+"@"+r,children:[{type:"text",value:e+"@"+r}]}}function sBe(t){let e=t.split(".");return!(e.length<2||e[e.length-1]&&(/_/.test(e[e.length-1])||!/[a-zA-Z\d]/.test(e[e.length-1]))||e[e.length-2]&&(/_/.test(e[e.length-2])||!/[a-zA-Z\d]/.test(e[e.length-2])))}function lBe(t){let e=/[!"&'),.:;<>?\]}]+$/.exec(t);if(!e)return[t,void 0];t=t.slice(0,e.index);let r=e[0],o=r.indexOf(")"),n=AL(t,"("),i=AL(t,")");for(;o!==-1&&n>i;)t+=r.slice(0,o+1),r=r.slice(o+1),o=r.indexOf(")"),i++;return[t,r]}function Dte(t,e){let r=t.input.charCodeAt(t.index-1);return(t.index===0||dl(r)||Lf(r))&&(!e||r!==47)}xBe.peek=bBe;function zL(){return{enter:{gfmFootnoteDefinition:dBe,gfmFootnoteDefinitionLabelString:uBe,gfmFootnoteCall:mBe,gfmFootnoteCallString:hBe},exit:{gfmFootnoteDefinition:pBe,gfmFootnoteDefinitionLabelString:fBe,gfmFootnoteCall:_Be,gfmFootnoteCallString:gBe}}}function dBe(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function uBe(){this.buffer()}function fBe(t){let e=this.resume(),r=this.stack[this.stack.length-1];r.type,r.label=e,r.identifier=Gn(this.sliceSerialize(t)).toLowerCase()}function pBe(t){this.exit(t)}function mBe(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function hBe(){this.buffer()}function gBe(t){let e=this.resume(),r=this.stack[this.stack.length-1];r.type,r.label=e,r.identifier=Gn(this.sliceSerialize(t)).toLowerCase()}function _Be(t){this.exit(t)}function xBe(t,e,r,o){let n=r.createTracker(o),i=n.move("[^"),a=r.enter("footnoteReference"),s=r.enter("reference");return i+=n.move(r.safe(r.associationId(t),{...n.current(),before:i,after:"]"})),s(),a(),i+=n.move("]"),i}function bBe(){return"["}wBe.peek=EBe;function UL(){return{canContainEols:["delete"],enter:{strikethrough:vBe},exit:{strikethrough:IBe}}}function vBe(t){this.enter({type:"delete",children:[]},t)}function IBe(t){this.exit(t)}function wBe(t,e,r,o){let n=r.createTracker(o),i=r.enter("strikethrough"),a=n.move("~~");return a+=r.containerPhrasing(t,{...n.current(),before:a,after:"~"}),a+=n.move("~~"),i(),a}function EBe(){return"~"}function HL(){return{enter:{table:CBe,tableData:Ate,tableHeader:Ate,tableRow:kBe},exit:{codeText:NBe,table:TBe,tableData:VL,tableHeader:VL,tableRow:VL}}}function CBe(t){let e=t._align;this.enter({type:"table",align:e.map(function(r){return r==="none"?null:r}),children:[]},t),this.data.inTable=!0}function TBe(t){this.exit(t),this.data.inTable=void 0}function kBe(t){this.enter({type:"tableRow",children:[]},t)}function VL(t){this.exit(t)}function Ate(t){this.enter({type:"tableCell",children:[]},t)}function NBe(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,PBe));let r=this.stack[this.stack.length-1];r.type,r.value=e,this.exit(t)}function PBe(t,e){return e==="|"?e:t}function jL(){return{exit:{taskListCheckValueChecked:Rte,taskListCheckValueUnchecked:Rte,paragraph:DBe}}}function Rte(t){let e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function DBe(t){let e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){let r=this.stack[this.stack.length-1];r.type;let o=r.children[0];if(o&&o.type==="text"){let n=e.children,i=-1,a;for(;++i<n.length;){let s=n[i];if(s.type==="paragraph"){a=s;break}}a===r&&(o.value=o.value.slice(1),o.value.length===0?r.children.shift():r.position&&o.position&&typeof o.position.start.offset=="number"&&(o.position.start.column++,o.position.start.offset++,r.position.start=Object.assign({},o.position.start)))}}this.exit(t)}function qL(){return[$L(),zL(),UL(),HL(),jL()]}var RBe={tokenize:$Be,partial:!0},Mte={tokenize:zBe,partial:!0},Lte={tokenize:UBe,partial:!0},Fte={tokenize:VBe,partial:!0},MBe={tokenize:HBe,partial:!0},Bte={tokenize:FBe,previous:zte},$te={tokenize:BBe,previous:Ute},fc={tokenize:LBe,previous:Vte},fl={};function WL(){return{text:fl}}var zf=48;for(;zf<123;)fl[zf]=fc,zf++,zf===58?zf=65:zf===91&&(zf=97);fl[43]=fc;fl[45]=fc;fl[46]=fc;fl[95]=fc;fl[72]=[fc,$te];fl[104]=[fc,$te];fl[87]=[fc,Bte];fl[119]=[fc,Bte];function LBe(t,e,r){let o=this,n,i;return a;function a(u){return!GL(u)||!Vte.call(o,o.previous)||KL(o.events)?r(u):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),s(u))}function s(u){return GL(u)?(t.consume(u),s):u===64?(t.consume(u),l):r(u)}function l(u){return u===46?t.check(MBe,d,c)(u):u===45||u===95||Ho(u)?(i=!0,t.consume(u),l):d(u)}function c(u){return t.consume(u),n=!0,l}function d(u){return i&&n&&Vo(o.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(u)):r(u)}}function FBe(t,e,r){let o=this;return n;function n(a){return a!==87&&a!==119||!zte.call(o,o.previous)||KL(o.events)?r(a):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(RBe,t.attempt(Mte,t.attempt(Lte,i),r),r)(a))}function i(a){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(a)}}function BBe(t,e,r){let o=this,n="",i=!1;return a;function a(u){return(u===72||u===104)&&Ute.call(o,o.previous)&&!KL(o.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),n+=String.fromCodePoint(u),t.consume(u),s):r(u)}function s(u){if(Vo(u)&&n.length<5)return n+=String.fromCodePoint(u),t.consume(u),s;if(u===58){let f=n.toLowerCase();if(f==="http"||f==="https")return t.consume(u),l}return r(u)}function l(u){return u===47?(t.consume(u),i?c:(i=!0,l)):r(u)}function c(u){return u===null||Mf(u)||Dt(u)||dl(u)||Lf(u)?r(u):t.attempt(Mte,t.attempt(Lte,d),r)(u)}function d(u){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(u)}}function $Be(t,e,r){let o=0;return n;function n(a){return(a===87||a===119)&&o<3?(o++,t.consume(a),n):a===46&&o===3?(t.consume(a),i):r(a)}function i(a){return a===null?r(a):e(a)}}function zBe(t,e,r){let o,n,i;return a;function a(c){return c===46||c===95?t.check(Fte,l,s)(c):c===null||Dt(c)||dl(c)||c!==45&&Lf(c)?l(c):(i=!0,t.consume(c),a)}function s(c){return c===95?o=!0:(n=o,o=void 0),t.consume(c),a}function l(c){return n||o||!i?r(c):e(c)}}function UBe(t,e){let r=0,o=0;return n;function n(a){return a===40?(r++,t.consume(a),n):a===41&&o<r?i(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?t.check(Fte,e,i)(a):a===null||Dt(a)||dl(a)?e(a):(t.consume(a),n)}function i(a){return a===41&&o++,t.consume(a),n}}function VBe(t,e,r){return o;function o(s){return s===33||s===34||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===63||s===95||s===126?(t.consume(s),o):s===38?(t.consume(s),i):s===93?(t.consume(s),n):s===60||s===null||Dt(s)||dl(s)?e(s):r(s)}function n(s){return s===null||s===40||s===91||Dt(s)||dl(s)?e(s):o(s)}function i(s){return Vo(s)?a(s):r(s)}function a(s){return s===59?(t.consume(s),o):Vo(s)?(t.consume(s),a):r(s)}}function HBe(t,e,r){return o;function o(i){return t.consume(i),n}function n(i){return Ho(i)?r(i):e(i)}}function zte(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Dt(t)}function Ute(t){return!Vo(t)}function Vte(t){return!(t===47||GL(t))}function GL(t){return t===43||t===45||t===46||t===95||Ho(t)}function KL(t){let e=t.length,r=!1;for(;e--;){let o=t[e][1];if((o.type==="labelLink"||o.type==="labelImage")&&!o._balanced){r=!0;break}if(o._gfmAutolinkLiteralWalkedInto){r=!1;break}}return t.length>0&&!r&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),r}var jBe={tokenize:JBe,partial:!0};function YL(){return{document:{91:{tokenize:KBe,continuation:{tokenize:YBe},exit:XBe}},text:{91:{tokenize:WBe},93:{add:"after",tokenize:qBe,resolveTo:GBe}}}}function qBe(t,e,r){let o=this,n=o.events.length,i=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]),a;for(;n--;){let l=o.events[n][1];if(l.type==="labelImage"){a=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return s;function s(l){if(!a||!a._balanced)return r(l);let c=Gn(o.sliceSerialize({start:a.end,end:o.now()}));return c.codePointAt(0)!==94||!i.includes(c.slice(1))?r(l):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(l),t.exit("gfmFootnoteCallLabelMarker"),e(l))}}function GBe(t,e){let r=t.length,o;for(;r--;)if(t[r][1].type==="labelImage"&&t[r][0]==="enter"){o=t[r][1];break}t[r+1][1].type="data",t[r+3][1].type="gfmFootnoteCallLabelMarker";let n={type:"gfmFootnoteCall",start:Object.assign({},t[r+3][1].start),end:Object.assign({},t[t.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},t[r+3][1].end),end:Object.assign({},t[r+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},t[t.length-1][1].start)},s={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},l=[t[r+1],t[r+2],["enter",n,e],t[r+3],t[r+4],["enter",i,e],["exit",i,e],["enter",a,e],["enter",s,e],["exit",s,e],["exit",a,e],t[t.length-2],t[t.length-1],["exit",n,e]];return t.splice(r,t.length-r+1,...l),t}function WBe(t,e,r){let o=this,n=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]),i=0,a;return s;function s(u){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(u),t.exit("gfmFootnoteCallLabelMarker"),l}function l(u){return u!==94?r(u):(t.enter("gfmFootnoteCallMarker"),t.consume(u),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",c)}function c(u){if(i>999||u===93&&!a||u===null||u===91||Dt(u))return r(u);if(u===93){t.exit("chunkString");let f=t.exit("gfmFootnoteCallString");return n.includes(Gn(o.sliceSerialize(f)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(u),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):r(u)}return Dt(u)||(a=!0),i++,t.consume(u),u===92?d:c}function d(u){return u===91||u===92||u===93?(t.consume(u),i++,c):c(u)}}function KBe(t,e,r){let o=this,n=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]),i,a=0,s;return l;function l(h){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(h),t.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(h){return h===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(h),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",d):r(h)}function d(h){if(a>999||h===93&&!s||h===null||h===91||Dt(h))return r(h);if(h===93){t.exit("chunkString");let g=t.exit("gfmFootnoteDefinitionLabelString");return i=Gn(o.sliceSerialize(g)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(h),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),f}return Dt(h)||(s=!0),a++,t.consume(h),h===92?u:d}function u(h){return h===91||h===92||h===93?(t.consume(h),a++,d):d(h)}function f(h){return h===58?(t.enter("definitionMarker"),t.consume(h),t.exit("definitionMarker"),n.includes(i)||n.push(i),it(t,m,"gfmFootnoteDefinitionWhitespace")):r(h)}function m(h){return e(h)}}function YBe(t,e,r){return t.check(ul,e,t.attempt(jBe,e,r))}function XBe(t){t.exit("gfmFootnoteDefinition")}function JBe(t,e,r){let o=this;return it(t,n,"gfmFootnoteDefinitionIndent",5);function n(i){let a=o.events[o.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?e(i):r(i)}}function XL(t){let r=(t||{}).singleTilde,o={tokenize:i,resolveAll:n};return r==null&&(r=!0),{text:{126:o},insideSpan:{null:[o]},attentionMarkers:{null:[126]}};function n(a,s){let l=-1;for(;++l<a.length;)if(a[l][0]==="enter"&&a[l][1].type==="strikethroughSequenceTemporary"&&a[l][1]._close){let c=l;for(;c--;)if(a[c][0]==="exit"&&a[c][1].type==="strikethroughSequenceTemporary"&&a[c][1]._open&&a[l][1].end.offset-a[l][1].start.offset===a[c][1].end.offset-a[c][1].start.offset){a[l][1].type="strikethroughSequence",a[c][1].type="strikethroughSequence";let d={type:"strikethrough",start:Object.assign({},a[c][1].start),end:Object.assign({},a[l][1].end)},u={type:"strikethroughText",start:Object.assign({},a[c][1].end),end:Object.assign({},a[l][1].start)},f=[["enter",d,s],["enter",a[c][1],s],["exit",a[c][1],s],["enter",u,s]],m=s.parser.constructs.insideSpan.null;m&&Oo(f,f.length,0,Pd(m,a.slice(c+1,l),s)),Oo(f,f.length,0,[["exit",u,s],["enter",a[l][1],s],["exit",a[l][1],s],["exit",d,s]]),Oo(a,c-1,l-c+3,f),l=c+f.length-2;break}}for(l=-1;++l<a.length;)a[l][1].type==="strikethroughSequenceTemporary"&&(a[l][1].type="data");return a}function i(a,s,l){let c=this.previous,d=this.events,u=0;return f;function f(h){return c===126&&d[d.length-1][1].type!=="characterEscape"?l(h):(a.enter("strikethroughSequenceTemporary"),m(h))}function m(h){let g=Sh(c);if(h===126)return u>1?l(h):(a.consume(h),u++,m);if(u<2&&!r)return l(h);let _=a.exit("strikethroughSequenceTemporary"),b=Sh(h);return _._open=!b||b===2&&!!g,_._close=!g||g===2&&!!b,s(h)}}}var sC=class{constructor(){this.map=[]}add(e,r,o){QBe(this,e,r,o)}consume(e){if(this.map.sort(function(i,a){return i[0]-a[0]}),this.map.length===0)return;let r=this.map.length,o=[];for(;r>0;)r-=1,o.push(e.slice(this.map[r][0]+this.map[r][1]),this.map[r][2]),e.length=this.map[r][0];o.push([...e]),e.length=0;let n=o.pop();for(;n;)e.push(...n),n=o.pop();this.map.length=0}};function QBe(t,e,r,o){let n=0;if(!(r===0&&o.length===0)){for(;n<t.map.length;){if(t.map[n][0]===e){t.map[n][1]+=r,t.map[n][2].push(...o);return}n+=1}t.map.push([e,r,o])}}function Hte(t,e){let r=!1,o=[];for(;e<t.length;){let n=t[e];if(r){if(n[0]==="enter")n[1].type==="tableContent"&&o.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(n[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){let i=o.length-1;o[i]=o[i]==="left"?"center":"right"}}else if(n[1].type==="tableDelimiterRow")break}else n[0]==="enter"&&n[1].type==="tableDelimiterRow"&&(r=!0);e+=1}return o}function JL(){return{flow:{null:{tokenize:ZBe,resolveAll:e4e}}}}function ZBe(t,e,r){let o=this,n=0,i=0,a;return s;function s(T){let O=o.events.length-1;for(;O>-1;){let B=o.events[O][1].type;if(B==="lineEnding"||B==="linePrefix")O--;else break}let A=O>-1?o.events[O][1].type:null,P=A==="tableHead"||A==="tableRow"?w:l;return P===w&&o.parser.lazy[o.now().line]?r(T):P(T)}function l(T){return t.enter("tableHead"),t.enter("tableRow"),c(T)}function c(T){return T===124||(a=!0,i+=1),d(T)}function d(T){return T===null?r(T):Oe(T)?i>1?(i=0,o.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(T),t.exit("lineEnding"),m):r(T):ct(T)?it(t,d,"whitespace")(T):(i+=1,a&&(a=!1,n+=1),T===124?(t.enter("tableCellDivider"),t.consume(T),t.exit("tableCellDivider"),a=!0,d):(t.enter("data"),u(T)))}function u(T){return T===null||T===124||Dt(T)?(t.exit("data"),d(T)):(t.consume(T),T===92?f:u)}function f(T){return T===92||T===124?(t.consume(T),u):u(T)}function m(T){return o.interrupt=!1,o.parser.lazy[o.now().line]?r(T):(t.enter("tableDelimiterRow"),a=!1,ct(T)?it(t,h,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(T):h(T))}function h(T){return T===45||T===58?_(T):T===124?(a=!0,t.enter("tableCellDivider"),t.consume(T),t.exit("tableCellDivider"),g):N(T)}function g(T){return ct(T)?it(t,_,"whitespace")(T):_(T)}function _(T){return T===58?(i+=1,a=!0,t.enter("tableDelimiterMarker"),t.consume(T),t.exit("tableDelimiterMarker"),b):T===45?(i+=1,b(T)):T===null||Oe(T)?S(T):N(T)}function b(T){return T===45?(t.enter("tableDelimiterFiller"),y(T)):N(T)}function y(T){return T===45?(t.consume(T),y):T===58?(a=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(T),t.exit("tableDelimiterMarker"),v):(t.exit("tableDelimiterFiller"),v(T))}function v(T){return ct(T)?it(t,S,"whitespace")(T):S(T)}function S(T){return T===124?h(T):T===null||Oe(T)?!a||n!==i?N(T):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(T)):N(T)}function N(T){return r(T)}function w(T){return t.enter("tableRow"),E(T)}function E(T){return T===124?(t.enter("tableCellDivider"),t.consume(T),t.exit("tableCellDivider"),E):T===null||Oe(T)?(t.exit("tableRow"),e(T)):ct(T)?it(t,E,"whitespace")(T):(t.enter("data"),I(T))}function I(T){return T===null||T===124||Dt(T)?(t.exit("data"),E(T)):(t.consume(T),T===92?C:I)}function C(T){return T===92||T===124?(t.consume(T),I):I(T)}}function e4e(t,e){let r=-1,o=!0,n=0,i=[0,0,0,0],a=[0,0,0,0],s=!1,l=0,c,d,u,f=new sC;for(;++r<t.length;){let m=t[r],h=m[1];m[0]==="enter"?h.type==="tableHead"?(s=!1,l!==0&&(jte(f,e,l,c,d),d=void 0,l=0),c={type:"table",start:Object.assign({},h.start),end:Object.assign({},h.end)},f.add(r,0,[["enter",c,e]])):h.type==="tableRow"||h.type==="tableDelimiterRow"?(o=!0,u=void 0,i=[0,0,0,0],a=[0,r+1,0,0],s&&(s=!1,d={type:"tableBody",start:Object.assign({},h.start),end:Object.assign({},h.end)},f.add(r,0,[["enter",d,e]])),n=h.type==="tableDelimiterRow"?2:d?3:1):n&&(h.type==="data"||h.type==="tableDelimiterMarker"||h.type==="tableDelimiterFiller")?(o=!1,a[2]===0&&(i[1]!==0&&(a[0]=a[1],u=lC(f,e,i,n,void 0,u),i=[0,0,0,0]),a[2]=r)):h.type==="tableCellDivider"&&(o?o=!1:(i[1]!==0&&(a[0]=a[1],u=lC(f,e,i,n,void 0,u)),i=a,a=[i[1],r,0,0])):h.type==="tableHead"?(s=!0,l=r):h.type==="tableRow"||h.type==="tableDelimiterRow"?(l=r,i[1]!==0?(a[0]=a[1],u=lC(f,e,i,n,r,u)):a[1]!==0&&(u=lC(f,e,a,n,r,u)),n=0):n&&(h.type==="data"||h.type==="tableDelimiterMarker"||h.type==="tableDelimiterFiller")&&(a[3]=r)}for(l!==0&&jte(f,e,l,c,d),f.consume(e.events),r=-1;++r<e.events.length;){let m=e.events[r];m[0]==="enter"&&m[1].type==="table"&&(m[1]._align=Hte(e.events,r))}return t}function lC(t,e,r,o,n,i){let a=o===1?"tableHeader":o===2?"tableDelimiter":"tableData",s="tableContent";r[0]!==0&&(i.end=Object.assign({},kh(e.events,r[0])),t.add(r[0],0,[["exit",i,e]]));let l=kh(e.events,r[1]);if(i={type:a,start:Object.assign({},l),end:Object.assign({},l)},t.add(r[1],0,[["enter",i,e]]),r[2]!==0){let c=kh(e.events,r[2]),d=kh(e.events,r[3]),u={type:s,start:Object.assign({},c),end:Object.assign({},d)};if(t.add(r[2],0,[["enter",u,e]]),o!==2){let f=e.events[r[2]],m=e.events[r[3]];if(f[1].end=Object.assign({},m[1].end),f[1].type="chunkText",f[1].contentType="text",r[3]>r[2]+1){let h=r[2]+1,g=r[3]-r[2]-1;t.add(h,g,[])}}t.add(r[3]+1,0,[["exit",u,e]])}return n!==void 0&&(i.end=Object.assign({},kh(e.events,n)),t.add(n,0,[["exit",i,e]]),i=void 0),i}function jte(t,e,r,o,n){let i=[],a=kh(e.events,r);n&&(n.end=Object.assign({},a),i.push(["exit",n,e])),o.end=Object.assign({},a),i.push(["exit",o,e]),t.add(r+1,0,i)}function kh(t,e){let r=t[e],o=r[0]==="enter"?"start":"end";return r[1][o]}var t4e={tokenize:r4e};function QL(){return{text:{91:t4e}}}function r4e(t,e,r){let o=this;return n;function n(l){return o.previous!==null||!o._gfmTasklistFirstContentOfListItem?r(l):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),i)}function i(l){return Dt(l)?(t.enter("taskListCheckValueUnchecked"),t.consume(l),t.exit("taskListCheckValueUnchecked"),a):l===88||l===120?(t.enter("taskListCheckValueChecked"),t.consume(l),t.exit("taskListCheckValueChecked"),a):r(l)}function a(l){return l===93?(t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),s):r(l)}function s(l){return Oe(l)?e(l):ct(l)?t.check({tokenize:o4e},e,r)(l):r(l)}}function o4e(t,e,r){return it(t,o,"whitespace");function o(n){return n===null?r(n):e(n)}}function qte(t){return KS([WL(),YL(),XL(t),JL(),QL()])}we();we();var Gte=["bmp","gif","ico","jpeg","jpg","png","tiff","webp"],Wte=[...Gte,"svg"],Kte=["mp4","webm"],n4e="https://lh3.googleusercontent.com/";async function Dd(t,e){let r=window.__ROOT_CTX.rootConfig.projectId,o=await d4e(t),n=Nh(t.name),i=e?.preserveFilename?`${o}/${t.name}`:`${o}.${n}`,a=`${r}/uploads/${i}`,s=yQ(window.firebase.storage,a),l=xQ(s,t),c=-1,d=Date.now();return await new Promise((u,f)=>{let m=setInterval(()=>{Date.now()-d>1e4&&(clearInterval(m),f(new Error("Upload stalled: no progress for 10 seconds")))},1e3);l.on("state_changed",h=>{h.bytesTransferred>0&&clearInterval(m),console.log(`uploading ${t.name}: ${h.bytesTransferred} / ${h.totalBytes} bytes`),h.bytesTransferred!==c&&(c=h.bytesTransferred,d=Date.now())},h=>{clearInterval(m),f(h)},()=>{console.log(`uploaded ${a}`),clearInterval(m),u(l.snapshot)})}),i4e(s,t,n,e)}async function i4e(t,e,r,o){let n={};n.filename=e.name,n.uploadedBy=window.firebase.user.email||"unknown",n.uploadedAt=String(Math.floor(new Date().getTime()));let i=`/${t.bucket}/${t.fullPath}`,a=`https://storage.googleapis.com${i}`;if(Wte.includes(r)){let l=await l4e(e);if(n.width=l.width,n.height=l.height,!o?.disableGci&&Gte.includes(r)){let c=await s4e(i);c&&(n.gcsPath=i,a=c)}n.canvasBgColor=await f4e(e)?"dark":"light"}else if(Kte.includes(r)){let l=await c4e(a);n.width=l.width,n.height=l.height,console.log("video dimensions:",l)}let s=o?.cacheControl||"public, max-age=31536000";return await bQ(t,{cacheControl:s,customMetadata:u4e(n)}),console.log("updated meta data: ",n),{...n,src:a}}function Nh(t){return a4e(t.split(".").at(-1)||"")}function a4e(t){let e=String(t).toLowerCase();return e==="jpeg"&&(e="jpg"),e}async function s4e(t){let e=window.__ROOT_CTX.rootConfig.gci;if(!e)return"";let r=new URLSearchParams({gcs:t}),o=`${e}/_/serving_url?${r.toString()}`,n=await window.fetch(o);if(n.status!==200){let a=await n.text();throw console.error(`failed to get gci url: ${o}`),console.error(a),new Error("failed to get gci url")}return(await n.json()).servingUrl}async function l4e(t){return new Promise((e,r)=>{let o=new FileReader;o.onload=()=>{let n=new Image;n.onload=()=>{e({width:n.width,height:n.height})},n.onerror=r,n.src=String(o.result)},o.onerror=r,o.readAsDataURL(t)})}async function c4e(t){return new Promise((e,r)=>{let o=document.createElement("video");o.addEventListener("loadedmetadata",()=>{let n={width:o.videoWidth,height:o.videoHeight};e(n),document.body.removeChild(o)},!1),o.addEventListener("error",()=>{r(new Error("Failed to load video metadata")),document.body.removeChild(o)},!1),o.className="sr-only",o.src=t,o.preload="metadata",document.body.appendChild(o)})}async function d4e(t){let e=await t.arrayBuffer(),r=await crypto.subtle.digest("SHA-1",e);return Array.from(new Uint8Array(r)).map(i=>i.toString(16).padStart(2,"0")).join("")}function u4e(t){let e={};return Object.entries(t).forEach(([r,o])=>{t[r]=String(o).trim()}),e}function Zb(t){if(!t)return!1;if(cC(t)||t.startsWith("data:image/"))return!0;let e=Nh(t);return Wte.includes(e)}function cC(t){return t?t.startsWith(n4e):!1}function ZL(t){if(!t)return!1;let e=Nh(t);return Kte.includes(e)}function Yte(t){return cC(t)?t.split("=")[0]+"=s0-d":t}function f4e(t){return new Promise((e,r)=>{let o=new Image,n=new FileReader;n.onload=()=>{o.src=n.result},o.onload=()=>{let i=document.createElement("canvas"),a=i.getContext("2d");i.width=o.width,i.height=o.height,a.drawImage(o,0,0,i.width,i.height);let{data:s}=a.getImageData(0,0,i.width,i.height),l=0,c=0,d=0,u=0;for(let m=0;m<s.length;m+=400)l+=s[m],c+=s[m+1],d+=s[m+2],u++;let f=.299*(l/u)+.587*(c/u)+.114*(d/u);e(f<128)},o.onerror=r,n.onerror=r,n.readAsDataURL(t)})}function dC(t){let[e,r]=M(""),o=G(null),n=G(null),[i,a]=M(null),[s,l]=M(!1),c=!e;function d(b){return b.endsWith(".jpg")?"image/jpeg":"image/png"}async function u(){if(!e)return;let b=[{type:"text",text:e}];i&&b.push({type:"image",image:{src:i.src,width:i.width,height:i.height,alt:i.filename}});let y=t.chat.addMessage({sender:"user",blocks:b});r(""),a(null),f();let v=[{text:e}];i&&v.push({media:{url:i.src,contentType:d(i.filename)}});let S=await t.chat.sendPrompt(y,v,t.options);t.onData&&S&&t.onData(S)}function f(){window.requestAnimationFrame(()=>{let b=o.current;b.style.height="auto",b.style.height=`${b.scrollHeight}px`})}function m(b){if(b.key==="Enter"&&!b.shiftKey){b.preventDefault(),u();return}}async function h(b){try{l(!0),f();let y=await Dd(b,{disableGci:!0});a({src:y.src,width:y.width,height:y.height,filename:y.filename}),l(!1)}catch{l(!1)}if(n.current){let y=n.current;y.value=""}}function g(b){let S=(b.target.files||[])[0];S&&h(S)}function _(){a(null),f()}return V(()=>{f()},[e]),p("div",{className:"AIPage__ChatBar",children:[p("div",{className:Ne("AIPage__ChatBar__prompt",(s||i)&&"AIPage__ChatBar__prompt--hasImage"),children:[p("label",{className:"AIPage__ChatBar__prompt__imageUpload",children:[p("input",{className:"AIPage__ChatBar__prompt__imageUpload__input",type:"file",accept:"image/png, image/jpeg, image/webp",onChange:g,ref:n}),p(Te,{label:"Upload image",children:p(Xe,{component:"div",className:"AIPage__ChatBar__prompt__imageUpload__icon",radius:"xl",children:p(Rb,{size:18})})})]}),p("textarea",{className:"AIPage__ChatBar__prompt__textInput",ref:o,placeholder:"Enter prompt...",rows:1,onKeyDown:m,onPaste:b=>{let y=b.clipboardData?.items||[];for(let v of y)if(v.kind==="file"&&v.type.startsWith("image/")){let S=v.getAsFile();S&&h(S)}},onChange:b=>{r(b.target.value)},value:e,autofocus:!0}),(s||i)&&p("div",{className:"AIPage__ChatBar__prompt__imagePreview",children:s?p(et,{size:"sm"}):p(Te,{label:i.filename,transition:"pop",position:"right",withArrow:!0,children:p("button",{className:"AIPage__ChatBar__prompt__imagePreview__closeButton",onClick:()=>_(),children:[p("img",{src:i.src,width:i.width,height:i.height,alt:"attachment"}),p("div",{className:"AIPage__ChatBar__prompt__imagePreview__closeButton__icon",children:p($b,{size:24,color:"white"})})]})})}),p(Xe,{className:"AIPage__ChatBar__prompt__submit",variant:"filled",color:"dark",radius:"xl",onClick:()=>u(),disabled:c,children:p(HM,{size:18})})]}),p("div",{className:"AIPage__ChatBar__disclaimer",children:"Root AI is experimental and makes mistakes. Check all info."})]})}var Xte={name:"@blinkk/root-cms",version:"2.3.3",author:"s@blinkk.com",license:"MIT",engines:{node:">=16.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/index.js",types:"./dist/index.d.ts",exports:{".":{types:"./dist/core.d.ts",import:"./dist/core.js"},"./client":{types:"./dist/client.d.ts",import:"./dist/client.js"},"./core":{types:"./dist/core.d.ts",import:"./dist/core.js"},"./functions":{types:"./dist/functions.d.ts",import:"./dist/functions.js"},"./plugin":{types:"./dist/plugin.d.ts",import:"./dist/plugin.js"},"./project":{types:"./dist/project.d.ts",import:"./dist/project.js"},"./richtext":{types:"./dist/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":"tsup-node --config=./core/tsup.config.ts","//":"NOTE: esbuild is used here because tsup doesn't currently support aliases.","build:ui":"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","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 --watch",test:"pnpm build && firebase emulators:exec 'vitest run'","test:watch":"pnpm build && firebase emulators:exec 'vitest'"},dependencies:{"@genkit-ai/ai":"1.18.0","@genkit-ai/core":"1.18.0","@genkit-ai/vertexai":"1.18.0","@google-cloud/firestore":"7.11.3","@hello-pangea/dnd":"18.0.1","body-parser":"1.20.2",commander:"11.0.0","csv-parse":"5.5.2","csv-stringify":"6.4.4",diff:"8.0.2","dts-dom":"3.7.0","fnv-plus":"1.3.1",genkit:"1.18.0",jsonwebtoken:"9.0.2",kleur:"4.1.5",sirv:"2.0.3","tiny-glob":"0.2.9",zod:"3.23.8"},"//":"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/utils":"0.33.1","@mantine/core":"4.2.12","@mantine/hooks":"4.2.12","@mantine/modals":"4.2.12","@mantine/notifications":"4.2.12","@mantine/spotlight":"4.2.12","@preact/compat":"18.3.1","@tabler/icons-preact":"3.35.0","@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",concurrently:"7.6.0",esbuild:"0.25.9",firebase:"12.2.1","firebase-admin":"13.5.0","firebase-functions":"6.4.0","firebase-tools":"14.15.2","highlight.js":"11.6.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",preact:"10.27.1","preact-render-to-string":"6.6.1","preact-router":"4.1.2",react:"npm:@preact/compat@18.3.1","react-dom":"npm:@preact/compat@18.3.1","react-json-view-compare":"2.0.2",tsup:"8.5.0",typescript:"5.9.2",vite:"7.1.4",vitest:"3.2.4",yjs:"13.6.27"},peerDependencies:{"@blinkk/root":"2.3.3","firebase-admin":">=11","firebase-functions":">=4",preact:">=10","preact-render-to-string":">=5"},peerDependenciesMeta:{"firebase-functions":{optional:!0}}};function Jte(){return p("svg",{width:"100",height:"23",viewBox:"0 0 100 23",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p("g",{"clip-path":"url(#clip0_1_318)",children:[p("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"}),p("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"}),p("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"}),p("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"}),p("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"}),p("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"}),p("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"}),p("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"}),p("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"})]}),p("defs",{children:p("clipPath",{id:"clip0_1_318",children:p("rect",{width:"99",height:"22",fill:"white",transform:"translate(0.0175781 0.177246)"})})})]})}var pc="1.5";function Fe(t){return p("div",{className:"Layout",children:[p(Fe.Top,{}),p(Fe.Side,{}),p(Fe.Main,{...t,children:t.children}),p(Fe.Bottom,{})]})}Fe.Top=()=>{let t=window.__ROOT_CTX.rootConfig.projectName||window.__ROOT_CTX.rootConfig.projectId;return p("div",{className:"Layout__top",children:[p("a",{className:"Layout__top__logo",href:"/cms",children:p(Jte,{})}),p("div",{className:"Layout__top__version",children:["v",Xte.version]}),p("div",{className:"Layout__top__project",children:t})]})};Fe.Side=()=>{let[t]=EQ(),e=t.url.replace(/\/*$/g,""),r=window.firebase.user,o=window.__ROOT_CTX.sidebar?.tools,n=new Set(window.__ROOT_CTX.sidebar?.hiddenBuiltInTools||[]),i=s=>n.has(s),a=window.__ROOT_CTX.experiments||{};return p("div",{className:"Layout__side",children:[p("div",{className:"Layout__side__buttons",children:[!i("home")&&p(Fe.SideButton,{label:"Home",url:"/cms",active:e==="/cms",children:p(PM,{stroke:pc})}),!i("content")&&p(Fe.SideButton,{label:"Content",url:"/cms/content",active:e.startsWith("/cms/content"),children:p(Cf,{stroke:pc})}),!i("releases")&&p(Fe.SideButton,{label:"Releases",url:"/cms/releases",active:e.startsWith("/cms/releases"),children:p(_h,{stroke:pc})}),!i("data")&&p(Fe.SideButton,{label:"Data",url:"/cms/data",active:e.startsWith("/cms/data"),children:p(bM,{stroke:pc})}),!i("assets")&&p(Fe.SideButton,{label:"Assets",url:"/cms/assets",active:e.startsWith("/cms/assets"),children:p($M,{stroke:pc})}),!i("translations")&&p(Fe.SideButton,{label:"Translations",url:"/cms/translations",active:e.startsWith("/cms/translations"),children:p(Cd,{stroke:pc})}),a.ai&&!i("ai")&&p(Fe.SideButton,{label:"Root AI (experimental)",url:"/cms/ai",active:e.startsWith("/cms/ai"),children:p(kf,{stroke:pc})}),o&&p(Ce,{children:[p("div",{className:"Layout__side__divider"}),Object.entries(o).map(([s,l])=>{let c=l.cmsUrl?.startsWith("/cms/")?l.cmsUrl:void 0,d=l.externalUrl,u=d??c??`/cms/tools/${s}`,f=d?void 0:u.replace(/\/*$/g,""),m=!d&&!!f&&(e===f||e.startsWith(`${f}/`));return p(Fe.SideButton,{className:"Layout__side__tool",label:l.label||"",url:u,active:m,external:!!d,children:l.icon?p("img",{className:"Layout__side__tool__icon",src:l.icon,alt:l.label||""}):p(pM,{stroke:pc})},s)}),p("div",{className:"Layout__side__divider"})]}),!i("settings")&&p(Fe.SideButton,{label:"Settings",url:"/cms/settings",active:e.startsWith("/cms/settings"),children:p(Nf,{stroke:pc})})]}),p("div",{className:"Layout__side__user",children:p(Te,{label:r.email,position:"right",withArrow:!0,children:p(Aa,{src:r.photoURL,alt:r.email,size:30,radius:"xl"})})})]})};Fe.SideButton=t=>p(Te,{className:Ne("Layout__side__button",t.className),label:t.label,position:"right",withArrow:!0,children:p("a",{className:Ne(t.active&&"active"),href:t.url,target:t.external?"_blank":void 0,rel:t.external?"noreferrer noopener":void 0,children:t.children})});Fe.Main=t=>p("div",{className:"Layout__main",children:t.children});Fe.Bottom=()=>p("div",{className:"Layout__bottom"});function pi(t){t||(t=6);let e=[],r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",o=r.length;for(let n=0;n<t;n++)e.push(r.charAt(Math.floor(Math.random()*o)));return e.join("")}function Qte(t,e){return Math.random()*(e-t)+t}var m4e=[20,40];mL.configure({ignoreUnescapedHTML:!0});function Zte(){return Qte(...m4e)}function ey(){let[t,e]=M([]),[r,o]=M(""),n=s=>{let l=0;return e(c=>{let d={sender:"bot",blocks:[{type:"pending"}],key:pi()},u=[...c,{...s,key:pi()},d];return l=u.length-1,u}),l},i=(s,l)=>{e(c=>{let d=[...c];return d[s]={...l,key:pi()},d})};return{chatId:r,messages:t,addMessage:n,updateMessage:i,sendPrompt:async(s,l,c)=>{let d="/cms/api/ai.chat";typeof window.__ROOT_CTX.experiments?.ai=="object"&&window.__ROOT_CTX.experiments.ai.endpoint&&(d=window.__ROOT_CTX.experiments.ai.endpoint);let u={prompt:l,chatId:r,options:c},f=await window.fetch(d,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(u)});if(f.status!==200){let h=await f.text();console.error("chat failed",h);let g=["Something went wrong:","```",h,"```"].join(`
65
+ `;break}case-2:{a=e?" ":" ";break}case-1:{if(!e&&n)continue;a=" ";break}default:a=String.fromCharCode(i)}n=i===-2,o.push(a)}return o.join("")}var TL={};ar(TL,{attentionMarkers:()=>BFe,contentInitial:()=>DFe,disable:()=>$Fe,document:()=>OFe,flow:()=>RFe,flowInitial:()=>AFe,insideSpan:()=>FFe,string:()=>MFe,text:()=>LFe});var OFe={42:Wn,43:Wn,45:Wn,48:Wn,49:Wn,50:Wn,51:Wn,52:Wn,53:Wn,54:Wn,55:Wn,56:Wn,57:Wn,62:XS},DFe={91:bL},AFe={[-2]:Xb,[-1]:Xb,32:Xb},RFe={35:vL,42:$f,45:[iC,$f],60:wL,61:iC,95:$f,96:ZS,126:ZS},MFe={38:QS,92:JS},LFe={[-5]:Qb,[-4]:Qb,[-3]:Qb,33:SL,38:QS,42:Yb,60:[gL,EL],91:CL,92:[yL,JS],93:Bf,95:Yb,96:_L},FFe={null:[Yb,gte]},BFe={null:[42,95]},$Fe={null:[]};function kL(t){let r=KS([TL,...(t||{}).extensions||[]]),o={defined:[],lazy:{},constructs:r,content:n(cte),document:n(ute),flow:n(hte),string:n(_te),text:n(xte)};return o;function n(i){return a;function a(s){return vte(o,i,s)}}}function NL(t){for(;!tC(t););return t}var Ite=/[\0\t\n\r]/g;function PL(){let t=1,e="",r=!0,o;return n;function n(i,a,s){let l=[],c,d,u,f,m;for(i=e+(typeof i=="string"?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,e="",r&&(i.charCodeAt(0)===65279&&u++,r=void 0);u<i.length;){if(Ite.lastIndex=u,c=Ite.exec(i),f=c&&c.index!==void 0?c.index:i.length,m=i.charCodeAt(f),!c){e=i.slice(u);break}if(m===10&&u===f&&o)l.push(-3),o=void 0;else switch(o&&(l.push(-5),o=void 0),u<f&&(l.push(i.slice(u,f)),t+=f-u),m){case 0:{l.push(65533),t++;break}case 9:{for(d=Math.ceil(t/4)*4,l.push(-2);t++<d;)l.push(-1);break}case 10:{l.push(-4),t=1;break}default:o=!0,t=1}u=f+1}return s&&(o&&l.push(-5),e&&l.push(e),l.push(null)),l}}var zFe=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function wte(t){return t.replace(zFe,UFe)}function UFe(t,e,r){if(e)return e;if(r.charCodeAt(0)===35){let n=r.charCodeAt(1),i=n===120||n===88;return YS(r.slice(i?2:1),i?16:10)}return Eh(r)||t}function Ch(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?Ete(t.position):"start"in t||"end"in t?Ete(t):"line"in t||"column"in t?OL(t):""}function OL(t){return Ste(t&&t.line)+":"+Ste(t&&t.column)}function Ete(t){return OL(t&&t.start)+"-"+OL(t&&t.end)}function Ste(t){return t&&typeof t=="number"?t:1}var Tte={}.hasOwnProperty;function DL(t,e,r){return typeof e!="string"&&(r=e,e=void 0),VFe(r)(NL(kL(r).document().write(PL()(t,e,!0))))}function VFe(t){let e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(Ut),autolinkProtocol:C,autolinkEmail:C,atxHeading:i(Jr),blockQuote:i(lt),characterEscape:C,characterReference:C,codeFenced:i(Rt),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:i(Rt,a),codeText:i(ut,a),codeTextData:C,data:C,codeFlowValue:C,definition:i(ht),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:i(bt),hardBreakEscape:i(Mt),hardBreakTrailing:i(Mt),htmlFlow:i(ve,a),htmlFlowData:C,htmlText:i(ve,a),htmlTextData:C,image:i(fn),label:a,link:i(Ut),listItem:i(Hr),listItemValue:f,listOrdered:i(pt,u),listUnordered:i(pt),paragraph:i(jr),reference:U,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:i(Jr),strong:i(Mo),thematicBreak:i(ie)},exit:{atxHeading:l(),atxHeadingSequence:N,autolink:l(),autolinkEmail:Pe,autolinkProtocol:Ae,blockQuote:l(),characterEscapeValue:T,characterReferenceMarkerHexadecimal:Ee,characterReferenceMarkerNumeric:Ee,characterReferenceValue:Ve,characterReference:Ye,codeFenced:l(_),codeFencedFence:g,codeFencedFenceInfo:m,codeFencedFenceMeta:h,codeFlowValue:T,codeIndented:l(b),codeText:l($),codeTextData:T,data:T,definition:l(),definitionDestinationString:S,definitionLabelString:y,definitionTitleString:v,emphasis:l(),hardBreakEscape:l(A),hardBreakTrailing:l(A),htmlFlow:l(P),htmlFlowData:T,htmlText:l(B),htmlTextData:T,image:l(H),label:Y,labelText:q,lineEnding:O,link:l(z),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:ge,resourceDestinationString:L,resourceTitleString:ne,resource:ae,setextHeading:l(I),setextHeadingLineSequence:E,setextHeadingText:w,strong:l(),thematicBreak:l()}};kte(e,(t||{}).mdastExtensions||[]);let r={};return o;function o(j){let Q={type:"root",children:[]},se={stack:[Q],tokenStack:[],config:e,enter:s,exit:c,buffer:a,resume:d,data:r},je=[],yt=-1;for(;++yt<j.length;)if(j[yt][1].type==="listOrdered"||j[yt][1].type==="listUnordered")if(j[yt][0]==="enter")je.push(yt);else{let Nt=je.pop();yt=n(j,Nt,yt)}for(yt=-1;++yt<j.length;){let Nt=e[j[yt][0]];Tte.call(Nt,j[yt][1].type)&&Nt[j[yt][1].type].call(Object.assign({sliceSerialize:j[yt][2].sliceSerialize},se),j[yt][1])}if(se.tokenStack.length>0){let Nt=se.tokenStack[se.tokenStack.length-1];(Nt[1]||Cte).call(se,void 0,Nt[0])}for(Q.position={start:Od(j.length>0?j[0][1].start:{line:1,column:1,offset:0}),end:Od(j.length>0?j[j.length-2][1].end:{line:1,column:1,offset:0})},yt=-1;++yt<e.transforms.length;)Q=e.transforms[yt](Q)||Q;return Q}function n(j,Q,se){let je=Q-1,yt=-1,Nt=!1,Fn,br,Pr,Qn;for(;++je<=se;){let lo=j[je];switch(lo[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{lo[0]==="enter"?yt++:yt--,Qn=void 0;break}case"lineEndingBlank":{lo[0]==="enter"&&(Fn&&!Qn&&!yt&&!Pr&&(Pr=je),Qn=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Qn=void 0}if(!yt&&lo[0]==="enter"&&lo[1].type==="listItemPrefix"||yt===-1&&lo[0]==="exit"&&(lo[1].type==="listUnordered"||lo[1].type==="listOrdered")){if(Fn){let pn=je;for(br=void 0;pn--;){let mn=j[pn];if(mn[1].type==="lineEnding"||mn[1].type==="lineEndingBlank"){if(mn[0]==="exit")continue;br&&(j[br][1].type="lineEndingBlank",Nt=!0),mn[1].type="lineEnding",br=pn}else if(!(mn[1].type==="linePrefix"||mn[1].type==="blockQuotePrefix"||mn[1].type==="blockQuotePrefixWhitespace"||mn[1].type==="blockQuoteMarker"||mn[1].type==="listItemIndent"))break}Pr&&(!br||Pr<br)&&(Fn._spread=!0),Fn.end=Object.assign({},br?j[br][1].start:lo[1].end),j.splice(br||je,0,["exit",Fn,lo[2]]),je++,se++}if(lo[1].type==="listItemPrefix"){let pn={type:"listItem",_spread:!1,start:Object.assign({},lo[1].start),end:void 0};Fn=pn,j.splice(je,0,["enter",pn,lo[2]]),je++,se++,Pr=void 0,Qn=!0}}}return j[Q][1]._spread=Nt,se}function i(j,Q){return se;function se(je){s.call(this,j(je),je),Q&&Q.call(this,je)}}function a(){this.stack.push({type:"fragment",children:[]})}function s(j,Q,se){this.stack[this.stack.length-1].children.push(j),this.stack.push(j),this.tokenStack.push([Q,se]),j.position={start:Od(Q.start),end:void 0}}function l(j){return Q;function Q(se){j&&j.call(this,se),c.call(this,se)}}function c(j,Q){let se=this.stack.pop(),je=this.tokenStack.pop();if(je)je[0].type!==j.type&&(Q?Q.call(this,j,je[0]):(je[1]||Cte).call(this,j,je[0]));else throw new Error("Cannot close `"+j.type+"` ("+Ch({start:j.start,end:j.end})+"): it\u2019s not open");se.position.end=Od(j.end)}function d(){return hL(this.stack.pop())}function u(){this.data.expectingFirstListItemValue=!0}function f(j){if(this.data.expectingFirstListItemValue){let Q=this.stack[this.stack.length-2];Q.start=Number.parseInt(this.sliceSerialize(j),10),this.data.expectingFirstListItemValue=void 0}}function m(){let j=this.resume(),Q=this.stack[this.stack.length-1];Q.lang=j}function h(){let j=this.resume(),Q=this.stack[this.stack.length-1];Q.meta=j}function g(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function _(){let j=this.resume(),Q=this.stack[this.stack.length-1];Q.value=j.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function b(){let j=this.resume(),Q=this.stack[this.stack.length-1];Q.value=j.replace(/(\r?\n|\r)$/g,"")}function y(j){let Q=this.resume(),se=this.stack[this.stack.length-1];se.label=Q,se.identifier=Gn(this.sliceSerialize(j)).toLowerCase()}function v(){let j=this.resume(),Q=this.stack[this.stack.length-1];Q.title=j}function S(){let j=this.resume(),Q=this.stack[this.stack.length-1];Q.url=j}function N(j){let Q=this.stack[this.stack.length-1];if(!Q.depth){let se=this.sliceSerialize(j).length;Q.depth=se}}function w(){this.data.setextHeadingSlurpLineEnding=!0}function E(j){let Q=this.stack[this.stack.length-1];Q.depth=this.sliceSerialize(j).codePointAt(0)===61?1:2}function I(){this.data.setextHeadingSlurpLineEnding=void 0}function C(j){let se=this.stack[this.stack.length-1].children,je=se[se.length-1];(!je||je.type!=="text")&&(je=$e(),je.position={start:Od(j.start),end:void 0},se.push(je)),this.stack.push(je)}function T(j){let Q=this.stack.pop();Q.value+=this.sliceSerialize(j),Q.position.end=Od(j.end)}function O(j){let Q=this.stack[this.stack.length-1];if(this.data.atHardBreak){let se=Q.children[Q.children.length-1];se.position.end=Od(j.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes(Q.type)&&(C.call(this,j),T.call(this,j))}function A(){this.data.atHardBreak=!0}function P(){let j=this.resume(),Q=this.stack[this.stack.length-1];Q.value=j}function B(){let j=this.resume(),Q=this.stack[this.stack.length-1];Q.value=j}function $(){let j=this.resume(),Q=this.stack[this.stack.length-1];Q.value=j}function z(){let j=this.stack[this.stack.length-1];if(this.data.inReference){let Q=this.data.referenceType||"shortcut";j.type+="Reference",j.referenceType=Q,delete j.url,delete j.title}else delete j.identifier,delete j.label;this.data.referenceType=void 0}function H(){let j=this.stack[this.stack.length-1];if(this.data.inReference){let Q=this.data.referenceType||"shortcut";j.type+="Reference",j.referenceType=Q,delete j.url,delete j.title}else delete j.identifier,delete j.label;this.data.referenceType=void 0}function q(j){let Q=this.sliceSerialize(j),se=this.stack[this.stack.length-2];se.label=wte(Q),se.identifier=Gn(Q).toLowerCase()}function Y(){let j=this.stack[this.stack.length-1],Q=this.resume(),se=this.stack[this.stack.length-1];if(this.data.inReference=!0,se.type==="link"){let je=j.children;se.children=je}else se.alt=Q}function L(){let j=this.resume(),Q=this.stack[this.stack.length-1];Q.url=j}function ne(){let j=this.resume(),Q=this.stack[this.stack.length-1];Q.title=j}function ae(){this.data.inReference=void 0}function U(){this.data.referenceType="collapsed"}function ge(j){let Q=this.resume(),se=this.stack[this.stack.length-1];se.label=Q,se.identifier=Gn(this.sliceSerialize(j)).toLowerCase(),this.data.referenceType="full"}function Ee(j){this.data.characterReferenceType=j.type}function Ve(j){let Q=this.sliceSerialize(j),se=this.data.characterReferenceType,je;se?(je=YS(Q,se==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):je=Eh(Q);let yt=this.stack[this.stack.length-1];yt.value+=je}function Ye(j){let Q=this.stack.pop();Q.position.end=Od(j.end)}function Ae(j){T.call(this,j);let Q=this.stack[this.stack.length-1];Q.url=this.sliceSerialize(j)}function Pe(j){T.call(this,j);let Q=this.stack[this.stack.length-1];Q.url="mailto:"+this.sliceSerialize(j)}function lt(){return{type:"blockquote",children:[]}}function Rt(){return{type:"code",lang:null,meta:null,value:""}}function ut(){return{type:"inlineCode",value:""}}function ht(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function bt(){return{type:"emphasis",children:[]}}function Jr(){return{type:"heading",depth:0,children:[]}}function Mt(){return{type:"break"}}function ve(){return{type:"html",value:""}}function fn(){return{type:"image",title:null,url:"",alt:null}}function Ut(){return{type:"link",title:null,url:"",children:[]}}function pt(j){return{type:"list",ordered:j.type==="listOrdered",start:null,spread:j._spread,children:[]}}function Hr(j){return{type:"listItem",spread:j._spread,checked:null,children:[]}}function jr(){return{type:"paragraph",children:[]}}function Mo(){return{type:"strong",children:[]}}function $e(){return{type:"text",value:""}}function ie(){return{type:"thematicBreak"}}}function Od(t){return{line:t.line,column:t.column,offset:t.offset}}function kte(t,e){let r=-1;for(;++r<e.length;){let o=e[r];Array.isArray(o)?kte(t,o):HFe(t,o)}}function HFe(t,e){let r;for(r in e)if(Tte.call(e,r))switch(r){case"canContainEols":{let o=e[r];o&&t[r].push(...o);break}case"transforms":{let o=e[r];o&&t[r].push(...o);break}case"enter":case"exit":{let o=e[r];o&&Object.assign(t[r],o);break}}}function Cte(t,e){throw t?new Error("Cannot close `"+t.type+"` ("+Ch({start:t.start,end:t.end})+"): a different token (`"+e.type+"`, "+Ch({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+Ch({start:e.start,end:e.end})+") is still open")}function AL(t,e){let r=String(t);if(typeof e!="string")throw new TypeError("Expected character");let o=0,n=r.indexOf(e);for(;n!==-1;)o++,n=r.indexOf(e,n+e.length);return o}function RL(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var Th=(function(t){if(t==null)return WFe;if(typeof t=="function")return aC(t);if(typeof t=="object")return Array.isArray(t)?jFe(t):qFe(t);if(typeof t=="string")return GFe(t);throw new Error("Expected function, string, or object as test")});function jFe(t){let e=[],r=-1;for(;++r<t.length;)e[r]=Th(t[r]);return aC(o);function o(...n){let i=-1;for(;++i<e.length;)if(e[i].apply(this,n))return!0;return!1}}function qFe(t){let e=t;return aC(r);function r(o){let n=o,i;for(i in t)if(n[i]!==e[i])return!1;return!0}}function GFe(t){return aC(e);function e(r){return r&&r.type===t}}function aC(t){return e;function e(r,o,n){return!!(KFe(r)&&t.call(this,r,typeof o=="number"?o:void 0,n||void 0))}}function WFe(){return!0}function KFe(t){return t!==null&&typeof t=="object"&&"type"in t}var Nte=[],Pte=!0,ML=!1,Ote="skip";function LL(t,e,r,o){let n;typeof e=="function"&&typeof r!="function"?(o=r,r=e):n=e;let i=Th(n),a=o?-1:1;s(t,void 0,[])();function s(l,c,d){let u=l&&typeof l=="object"?l:{};if(typeof u.type=="string"){let m=typeof u.tagName=="string"?u.tagName:typeof u.name=="string"?u.name:void 0;Object.defineProperty(f,"name",{value:"node ("+(l.type+(m?"<"+m+">":""))+")"})}return f;function f(){let m=Nte,h,g,_;if((!e||i(l,c,d[d.length-1]||void 0))&&(m=YFe(r(l,d)),m[0]===ML))return m;if("children"in l&&l.children){let b=l;if(b.children&&m[0]!==Ote)for(g=(o?b.children.length:-1)+a,_=d.concat(b);g>-1&&g<b.children.length;){let y=b.children[g];if(h=s(y,g,_)(),h[0]===ML)return h;g=typeof h[1]=="number"?h[1]:g+a}}return m}}}function YFe(t){return Array.isArray(t)?t:typeof t=="number"?[Pte,t]:t==null?Nte:[t]}function FL(t,e,r){let n=Th((r||{}).ignore||[]),i=XFe(e),a=-1;for(;++a<i.length;)LL(t,"text",s);function s(c,d){let u=-1,f;for(;++u<d.length;){let m=d[u],h=f?f.children:void 0;if(n(m,h?h.indexOf(m):void 0,f))return;f=m}if(f)return l(c,d)}function l(c,d){let u=d[d.length-1],f=i[a][0],m=i[a][1],h=0,_=u.children.indexOf(c),b=!1,y=[];f.lastIndex=0;let v=f.exec(c.value);for(;v;){let S=v.index,N={index:v.index,input:v.input,stack:[...d,c]},w=m(...v,N);if(typeof w=="string"&&(w=w.length>0?{type:"text",value:w}:void 0),w===!1?f.lastIndex=S+1:(h!==S&&y.push({type:"text",value:c.value.slice(h,S)}),Array.isArray(w)?y.push(...w):w&&y.push(w),h=S+v[0].length,b=!0),!f.global)break;v=f.exec(c.value)}return b?(h<c.value.length&&y.push({type:"text",value:c.value.slice(h)}),u.children.splice(_,1,...y)):y=[c],_+y.length}}function XFe(t){let e=[];if(!Array.isArray(t))throw new TypeError("Expected find and replace tuple or list of tuples");let r=!t[0]||Array.isArray(t[0])?t:[t],o=-1;for(;++o<r.length;){let n=r[o];e.push([JFe(n[0]),QFe(n[1])])}return e}function JFe(t){return typeof t=="string"?new RegExp(RL(t),"g"):t}function QFe(t){return typeof t=="function"?t:function(){return t}}function $L(){return{transforms:[nBe],enter:{literalAutolink:ZFe,literalAutolinkEmail:BL,literalAutolinkHttp:BL,literalAutolinkWww:BL},exit:{literalAutolink:oBe,literalAutolinkEmail:rBe,literalAutolinkHttp:eBe,literalAutolinkWww:tBe}}}function ZFe(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function BL(t){this.config.enter.autolinkProtocol.call(this,t)}function eBe(t){this.config.exit.autolinkProtocol.call(this,t)}function tBe(t){this.config.exit.data.call(this,t);let e=this.stack[this.stack.length-1];e.type,e.url="http://"+this.sliceSerialize(t)}function rBe(t){this.config.exit.autolinkEmail.call(this,t)}function oBe(t){this.exit(t)}function nBe(t){FL(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,iBe],[/([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/g,aBe]],{ignore:["link","linkReference"]})}function iBe(t,e,r,o,n){let i="";if(!Dte(n)||(/^w/i.test(e)&&(r=e+r,e="",i="http://"),!sBe(r)))return!1;let a=lBe(r+o);if(!a[0])return!1;let s={type:"link",title:null,url:i+e+a[0],children:[{type:"text",value:e+a[0]}]};return a[1]?[s,{type:"text",value:a[1]}]:s}function aBe(t,e,r,o){return!Dte(o,!0)||/[-\d_]$/.test(r)?!1:{type:"link",title:null,url:"mailto:"+e+"@"+r,children:[{type:"text",value:e+"@"+r}]}}function sBe(t){let e=t.split(".");return!(e.length<2||e[e.length-1]&&(/_/.test(e[e.length-1])||!/[a-zA-Z\d]/.test(e[e.length-1]))||e[e.length-2]&&(/_/.test(e[e.length-2])||!/[a-zA-Z\d]/.test(e[e.length-2])))}function lBe(t){let e=/[!"&'),.:;<>?\]}]+$/.exec(t);if(!e)return[t,void 0];t=t.slice(0,e.index);let r=e[0],o=r.indexOf(")"),n=AL(t,"("),i=AL(t,")");for(;o!==-1&&n>i;)t+=r.slice(0,o+1),r=r.slice(o+1),o=r.indexOf(")"),i++;return[t,r]}function Dte(t,e){let r=t.input.charCodeAt(t.index-1);return(t.index===0||dl(r)||Lf(r))&&(!e||r!==47)}xBe.peek=bBe;function zL(){return{enter:{gfmFootnoteDefinition:dBe,gfmFootnoteDefinitionLabelString:uBe,gfmFootnoteCall:mBe,gfmFootnoteCallString:hBe},exit:{gfmFootnoteDefinition:pBe,gfmFootnoteDefinitionLabelString:fBe,gfmFootnoteCall:_Be,gfmFootnoteCallString:gBe}}}function dBe(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function uBe(){this.buffer()}function fBe(t){let e=this.resume(),r=this.stack[this.stack.length-1];r.type,r.label=e,r.identifier=Gn(this.sliceSerialize(t)).toLowerCase()}function pBe(t){this.exit(t)}function mBe(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function hBe(){this.buffer()}function gBe(t){let e=this.resume(),r=this.stack[this.stack.length-1];r.type,r.label=e,r.identifier=Gn(this.sliceSerialize(t)).toLowerCase()}function _Be(t){this.exit(t)}function xBe(t,e,r,o){let n=r.createTracker(o),i=n.move("[^"),a=r.enter("footnoteReference"),s=r.enter("reference");return i+=n.move(r.safe(r.associationId(t),{...n.current(),before:i,after:"]"})),s(),a(),i+=n.move("]"),i}function bBe(){return"["}wBe.peek=EBe;function UL(){return{canContainEols:["delete"],enter:{strikethrough:vBe},exit:{strikethrough:IBe}}}function vBe(t){this.enter({type:"delete",children:[]},t)}function IBe(t){this.exit(t)}function wBe(t,e,r,o){let n=r.createTracker(o),i=r.enter("strikethrough"),a=n.move("~~");return a+=r.containerPhrasing(t,{...n.current(),before:a,after:"~"}),a+=n.move("~~"),i(),a}function EBe(){return"~"}function HL(){return{enter:{table:CBe,tableData:Ate,tableHeader:Ate,tableRow:kBe},exit:{codeText:NBe,table:TBe,tableData:VL,tableHeader:VL,tableRow:VL}}}function CBe(t){let e=t._align;this.enter({type:"table",align:e.map(function(r){return r==="none"?null:r}),children:[]},t),this.data.inTable=!0}function TBe(t){this.exit(t),this.data.inTable=void 0}function kBe(t){this.enter({type:"tableRow",children:[]},t)}function VL(t){this.exit(t)}function Ate(t){this.enter({type:"tableCell",children:[]},t)}function NBe(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,PBe));let r=this.stack[this.stack.length-1];r.type,r.value=e,this.exit(t)}function PBe(t,e){return e==="|"?e:t}function jL(){return{exit:{taskListCheckValueChecked:Rte,taskListCheckValueUnchecked:Rte,paragraph:DBe}}}function Rte(t){let e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function DBe(t){let e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){let r=this.stack[this.stack.length-1];r.type;let o=r.children[0];if(o&&o.type==="text"){let n=e.children,i=-1,a;for(;++i<n.length;){let s=n[i];if(s.type==="paragraph"){a=s;break}}a===r&&(o.value=o.value.slice(1),o.value.length===0?r.children.shift():r.position&&o.position&&typeof o.position.start.offset=="number"&&(o.position.start.column++,o.position.start.offset++,r.position.start=Object.assign({},o.position.start)))}}this.exit(t)}function qL(){return[$L(),zL(),UL(),HL(),jL()]}var RBe={tokenize:$Be,partial:!0},Mte={tokenize:zBe,partial:!0},Lte={tokenize:UBe,partial:!0},Fte={tokenize:VBe,partial:!0},MBe={tokenize:HBe,partial:!0},Bte={tokenize:FBe,previous:zte},$te={tokenize:BBe,previous:Ute},fc={tokenize:LBe,previous:Vte},fl={};function WL(){return{text:fl}}var zf=48;for(;zf<123;)fl[zf]=fc,zf++,zf===58?zf=65:zf===91&&(zf=97);fl[43]=fc;fl[45]=fc;fl[46]=fc;fl[95]=fc;fl[72]=[fc,$te];fl[104]=[fc,$te];fl[87]=[fc,Bte];fl[119]=[fc,Bte];function LBe(t,e,r){let o=this,n,i;return a;function a(u){return!GL(u)||!Vte.call(o,o.previous)||KL(o.events)?r(u):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),s(u))}function s(u){return GL(u)?(t.consume(u),s):u===64?(t.consume(u),l):r(u)}function l(u){return u===46?t.check(MBe,d,c)(u):u===45||u===95||Ho(u)?(i=!0,t.consume(u),l):d(u)}function c(u){return t.consume(u),n=!0,l}function d(u){return i&&n&&Vo(o.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(u)):r(u)}}function FBe(t,e,r){let o=this;return n;function n(a){return a!==87&&a!==119||!zte.call(o,o.previous)||KL(o.events)?r(a):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(RBe,t.attempt(Mte,t.attempt(Lte,i),r),r)(a))}function i(a){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(a)}}function BBe(t,e,r){let o=this,n="",i=!1;return a;function a(u){return(u===72||u===104)&&Ute.call(o,o.previous)&&!KL(o.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),n+=String.fromCodePoint(u),t.consume(u),s):r(u)}function s(u){if(Vo(u)&&n.length<5)return n+=String.fromCodePoint(u),t.consume(u),s;if(u===58){let f=n.toLowerCase();if(f==="http"||f==="https")return t.consume(u),l}return r(u)}function l(u){return u===47?(t.consume(u),i?c:(i=!0,l)):r(u)}function c(u){return u===null||Mf(u)||Dt(u)||dl(u)||Lf(u)?r(u):t.attempt(Mte,t.attempt(Lte,d),r)(u)}function d(u){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(u)}}function $Be(t,e,r){let o=0;return n;function n(a){return(a===87||a===119)&&o<3?(o++,t.consume(a),n):a===46&&o===3?(t.consume(a),i):r(a)}function i(a){return a===null?r(a):e(a)}}function zBe(t,e,r){let o,n,i;return a;function a(c){return c===46||c===95?t.check(Fte,l,s)(c):c===null||Dt(c)||dl(c)||c!==45&&Lf(c)?l(c):(i=!0,t.consume(c),a)}function s(c){return c===95?o=!0:(n=o,o=void 0),t.consume(c),a}function l(c){return n||o||!i?r(c):e(c)}}function UBe(t,e){let r=0,o=0;return n;function n(a){return a===40?(r++,t.consume(a),n):a===41&&o<r?i(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?t.check(Fte,e,i)(a):a===null||Dt(a)||dl(a)?e(a):(t.consume(a),n)}function i(a){return a===41&&o++,t.consume(a),n}}function VBe(t,e,r){return o;function o(s){return s===33||s===34||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===63||s===95||s===126?(t.consume(s),o):s===38?(t.consume(s),i):s===93?(t.consume(s),n):s===60||s===null||Dt(s)||dl(s)?e(s):r(s)}function n(s){return s===null||s===40||s===91||Dt(s)||dl(s)?e(s):o(s)}function i(s){return Vo(s)?a(s):r(s)}function a(s){return s===59?(t.consume(s),o):Vo(s)?(t.consume(s),a):r(s)}}function HBe(t,e,r){return o;function o(i){return t.consume(i),n}function n(i){return Ho(i)?r(i):e(i)}}function zte(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Dt(t)}function Ute(t){return!Vo(t)}function Vte(t){return!(t===47||GL(t))}function GL(t){return t===43||t===45||t===46||t===95||Ho(t)}function KL(t){let e=t.length,r=!1;for(;e--;){let o=t[e][1];if((o.type==="labelLink"||o.type==="labelImage")&&!o._balanced){r=!0;break}if(o._gfmAutolinkLiteralWalkedInto){r=!1;break}}return t.length>0&&!r&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),r}var jBe={tokenize:JBe,partial:!0};function YL(){return{document:{91:{tokenize:KBe,continuation:{tokenize:YBe},exit:XBe}},text:{91:{tokenize:WBe},93:{add:"after",tokenize:qBe,resolveTo:GBe}}}}function qBe(t,e,r){let o=this,n=o.events.length,i=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]),a;for(;n--;){let l=o.events[n][1];if(l.type==="labelImage"){a=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return s;function s(l){if(!a||!a._balanced)return r(l);let c=Gn(o.sliceSerialize({start:a.end,end:o.now()}));return c.codePointAt(0)!==94||!i.includes(c.slice(1))?r(l):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(l),t.exit("gfmFootnoteCallLabelMarker"),e(l))}}function GBe(t,e){let r=t.length,o;for(;r--;)if(t[r][1].type==="labelImage"&&t[r][0]==="enter"){o=t[r][1];break}t[r+1][1].type="data",t[r+3][1].type="gfmFootnoteCallLabelMarker";let n={type:"gfmFootnoteCall",start:Object.assign({},t[r+3][1].start),end:Object.assign({},t[t.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},t[r+3][1].end),end:Object.assign({},t[r+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},t[t.length-1][1].start)},s={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},l=[t[r+1],t[r+2],["enter",n,e],t[r+3],t[r+4],["enter",i,e],["exit",i,e],["enter",a,e],["enter",s,e],["exit",s,e],["exit",a,e],t[t.length-2],t[t.length-1],["exit",n,e]];return t.splice(r,t.length-r+1,...l),t}function WBe(t,e,r){let o=this,n=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]),i=0,a;return s;function s(u){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(u),t.exit("gfmFootnoteCallLabelMarker"),l}function l(u){return u!==94?r(u):(t.enter("gfmFootnoteCallMarker"),t.consume(u),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",c)}function c(u){if(i>999||u===93&&!a||u===null||u===91||Dt(u))return r(u);if(u===93){t.exit("chunkString");let f=t.exit("gfmFootnoteCallString");return n.includes(Gn(o.sliceSerialize(f)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(u),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):r(u)}return Dt(u)||(a=!0),i++,t.consume(u),u===92?d:c}function d(u){return u===91||u===92||u===93?(t.consume(u),i++,c):c(u)}}function KBe(t,e,r){let o=this,n=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]),i,a=0,s;return l;function l(h){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(h),t.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(h){return h===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(h),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",d):r(h)}function d(h){if(a>999||h===93&&!s||h===null||h===91||Dt(h))return r(h);if(h===93){t.exit("chunkString");let g=t.exit("gfmFootnoteDefinitionLabelString");return i=Gn(o.sliceSerialize(g)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(h),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),f}return Dt(h)||(s=!0),a++,t.consume(h),h===92?u:d}function u(h){return h===91||h===92||h===93?(t.consume(h),a++,d):d(h)}function f(h){return h===58?(t.enter("definitionMarker"),t.consume(h),t.exit("definitionMarker"),n.includes(i)||n.push(i),it(t,m,"gfmFootnoteDefinitionWhitespace")):r(h)}function m(h){return e(h)}}function YBe(t,e,r){return t.check(ul,e,t.attempt(jBe,e,r))}function XBe(t){t.exit("gfmFootnoteDefinition")}function JBe(t,e,r){let o=this;return it(t,n,"gfmFootnoteDefinitionIndent",5);function n(i){let a=o.events[o.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?e(i):r(i)}}function XL(t){let r=(t||{}).singleTilde,o={tokenize:i,resolveAll:n};return r==null&&(r=!0),{text:{126:o},insideSpan:{null:[o]},attentionMarkers:{null:[126]}};function n(a,s){let l=-1;for(;++l<a.length;)if(a[l][0]==="enter"&&a[l][1].type==="strikethroughSequenceTemporary"&&a[l][1]._close){let c=l;for(;c--;)if(a[c][0]==="exit"&&a[c][1].type==="strikethroughSequenceTemporary"&&a[c][1]._open&&a[l][1].end.offset-a[l][1].start.offset===a[c][1].end.offset-a[c][1].start.offset){a[l][1].type="strikethroughSequence",a[c][1].type="strikethroughSequence";let d={type:"strikethrough",start:Object.assign({},a[c][1].start),end:Object.assign({},a[l][1].end)},u={type:"strikethroughText",start:Object.assign({},a[c][1].end),end:Object.assign({},a[l][1].start)},f=[["enter",d,s],["enter",a[c][1],s],["exit",a[c][1],s],["enter",u,s]],m=s.parser.constructs.insideSpan.null;m&&Oo(f,f.length,0,Pd(m,a.slice(c+1,l),s)),Oo(f,f.length,0,[["exit",u,s],["enter",a[l][1],s],["exit",a[l][1],s],["exit",d,s]]),Oo(a,c-1,l-c+3,f),l=c+f.length-2;break}}for(l=-1;++l<a.length;)a[l][1].type==="strikethroughSequenceTemporary"&&(a[l][1].type="data");return a}function i(a,s,l){let c=this.previous,d=this.events,u=0;return f;function f(h){return c===126&&d[d.length-1][1].type!=="characterEscape"?l(h):(a.enter("strikethroughSequenceTemporary"),m(h))}function m(h){let g=Sh(c);if(h===126)return u>1?l(h):(a.consume(h),u++,m);if(u<2&&!r)return l(h);let _=a.exit("strikethroughSequenceTemporary"),b=Sh(h);return _._open=!b||b===2&&!!g,_._close=!g||g===2&&!!b,s(h)}}}var sC=class{constructor(){this.map=[]}add(e,r,o){QBe(this,e,r,o)}consume(e){if(this.map.sort(function(i,a){return i[0]-a[0]}),this.map.length===0)return;let r=this.map.length,o=[];for(;r>0;)r-=1,o.push(e.slice(this.map[r][0]+this.map[r][1]),this.map[r][2]),e.length=this.map[r][0];o.push([...e]),e.length=0;let n=o.pop();for(;n;)e.push(...n),n=o.pop();this.map.length=0}};function QBe(t,e,r,o){let n=0;if(!(r===0&&o.length===0)){for(;n<t.map.length;){if(t.map[n][0]===e){t.map[n][1]+=r,t.map[n][2].push(...o);return}n+=1}t.map.push([e,r,o])}}function Hte(t,e){let r=!1,o=[];for(;e<t.length;){let n=t[e];if(r){if(n[0]==="enter")n[1].type==="tableContent"&&o.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(n[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){let i=o.length-1;o[i]=o[i]==="left"?"center":"right"}}else if(n[1].type==="tableDelimiterRow")break}else n[0]==="enter"&&n[1].type==="tableDelimiterRow"&&(r=!0);e+=1}return o}function JL(){return{flow:{null:{tokenize:ZBe,resolveAll:e4e}}}}function ZBe(t,e,r){let o=this,n=0,i=0,a;return s;function s(T){let O=o.events.length-1;for(;O>-1;){let B=o.events[O][1].type;if(B==="lineEnding"||B==="linePrefix")O--;else break}let A=O>-1?o.events[O][1].type:null,P=A==="tableHead"||A==="tableRow"?w:l;return P===w&&o.parser.lazy[o.now().line]?r(T):P(T)}function l(T){return t.enter("tableHead"),t.enter("tableRow"),c(T)}function c(T){return T===124||(a=!0,i+=1),d(T)}function d(T){return T===null?r(T):Oe(T)?i>1?(i=0,o.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(T),t.exit("lineEnding"),m):r(T):ct(T)?it(t,d,"whitespace")(T):(i+=1,a&&(a=!1,n+=1),T===124?(t.enter("tableCellDivider"),t.consume(T),t.exit("tableCellDivider"),a=!0,d):(t.enter("data"),u(T)))}function u(T){return T===null||T===124||Dt(T)?(t.exit("data"),d(T)):(t.consume(T),T===92?f:u)}function f(T){return T===92||T===124?(t.consume(T),u):u(T)}function m(T){return o.interrupt=!1,o.parser.lazy[o.now().line]?r(T):(t.enter("tableDelimiterRow"),a=!1,ct(T)?it(t,h,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(T):h(T))}function h(T){return T===45||T===58?_(T):T===124?(a=!0,t.enter("tableCellDivider"),t.consume(T),t.exit("tableCellDivider"),g):N(T)}function g(T){return ct(T)?it(t,_,"whitespace")(T):_(T)}function _(T){return T===58?(i+=1,a=!0,t.enter("tableDelimiterMarker"),t.consume(T),t.exit("tableDelimiterMarker"),b):T===45?(i+=1,b(T)):T===null||Oe(T)?S(T):N(T)}function b(T){return T===45?(t.enter("tableDelimiterFiller"),y(T)):N(T)}function y(T){return T===45?(t.consume(T),y):T===58?(a=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(T),t.exit("tableDelimiterMarker"),v):(t.exit("tableDelimiterFiller"),v(T))}function v(T){return ct(T)?it(t,S,"whitespace")(T):S(T)}function S(T){return T===124?h(T):T===null||Oe(T)?!a||n!==i?N(T):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(T)):N(T)}function N(T){return r(T)}function w(T){return t.enter("tableRow"),E(T)}function E(T){return T===124?(t.enter("tableCellDivider"),t.consume(T),t.exit("tableCellDivider"),E):T===null||Oe(T)?(t.exit("tableRow"),e(T)):ct(T)?it(t,E,"whitespace")(T):(t.enter("data"),I(T))}function I(T){return T===null||T===124||Dt(T)?(t.exit("data"),E(T)):(t.consume(T),T===92?C:I)}function C(T){return T===92||T===124?(t.consume(T),I):I(T)}}function e4e(t,e){let r=-1,o=!0,n=0,i=[0,0,0,0],a=[0,0,0,0],s=!1,l=0,c,d,u,f=new sC;for(;++r<t.length;){let m=t[r],h=m[1];m[0]==="enter"?h.type==="tableHead"?(s=!1,l!==0&&(jte(f,e,l,c,d),d=void 0,l=0),c={type:"table",start:Object.assign({},h.start),end:Object.assign({},h.end)},f.add(r,0,[["enter",c,e]])):h.type==="tableRow"||h.type==="tableDelimiterRow"?(o=!0,u=void 0,i=[0,0,0,0],a=[0,r+1,0,0],s&&(s=!1,d={type:"tableBody",start:Object.assign({},h.start),end:Object.assign({},h.end)},f.add(r,0,[["enter",d,e]])),n=h.type==="tableDelimiterRow"?2:d?3:1):n&&(h.type==="data"||h.type==="tableDelimiterMarker"||h.type==="tableDelimiterFiller")?(o=!1,a[2]===0&&(i[1]!==0&&(a[0]=a[1],u=lC(f,e,i,n,void 0,u),i=[0,0,0,0]),a[2]=r)):h.type==="tableCellDivider"&&(o?o=!1:(i[1]!==0&&(a[0]=a[1],u=lC(f,e,i,n,void 0,u)),i=a,a=[i[1],r,0,0])):h.type==="tableHead"?(s=!0,l=r):h.type==="tableRow"||h.type==="tableDelimiterRow"?(l=r,i[1]!==0?(a[0]=a[1],u=lC(f,e,i,n,r,u)):a[1]!==0&&(u=lC(f,e,a,n,r,u)),n=0):n&&(h.type==="data"||h.type==="tableDelimiterMarker"||h.type==="tableDelimiterFiller")&&(a[3]=r)}for(l!==0&&jte(f,e,l,c,d),f.consume(e.events),r=-1;++r<e.events.length;){let m=e.events[r];m[0]==="enter"&&m[1].type==="table"&&(m[1]._align=Hte(e.events,r))}return t}function lC(t,e,r,o,n,i){let a=o===1?"tableHeader":o===2?"tableDelimiter":"tableData",s="tableContent";r[0]!==0&&(i.end=Object.assign({},kh(e.events,r[0])),t.add(r[0],0,[["exit",i,e]]));let l=kh(e.events,r[1]);if(i={type:a,start:Object.assign({},l),end:Object.assign({},l)},t.add(r[1],0,[["enter",i,e]]),r[2]!==0){let c=kh(e.events,r[2]),d=kh(e.events,r[3]),u={type:s,start:Object.assign({},c),end:Object.assign({},d)};if(t.add(r[2],0,[["enter",u,e]]),o!==2){let f=e.events[r[2]],m=e.events[r[3]];if(f[1].end=Object.assign({},m[1].end),f[1].type="chunkText",f[1].contentType="text",r[3]>r[2]+1){let h=r[2]+1,g=r[3]-r[2]-1;t.add(h,g,[])}}t.add(r[3]+1,0,[["exit",u,e]])}return n!==void 0&&(i.end=Object.assign({},kh(e.events,n)),t.add(n,0,[["exit",i,e]]),i=void 0),i}function jte(t,e,r,o,n){let i=[],a=kh(e.events,r);n&&(n.end=Object.assign({},a),i.push(["exit",n,e])),o.end=Object.assign({},a),i.push(["exit",o,e]),t.add(r+1,0,i)}function kh(t,e){let r=t[e],o=r[0]==="enter"?"start":"end";return r[1][o]}var t4e={tokenize:r4e};function QL(){return{text:{91:t4e}}}function r4e(t,e,r){let o=this;return n;function n(l){return o.previous!==null||!o._gfmTasklistFirstContentOfListItem?r(l):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),i)}function i(l){return Dt(l)?(t.enter("taskListCheckValueUnchecked"),t.consume(l),t.exit("taskListCheckValueUnchecked"),a):l===88||l===120?(t.enter("taskListCheckValueChecked"),t.consume(l),t.exit("taskListCheckValueChecked"),a):r(l)}function a(l){return l===93?(t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),s):r(l)}function s(l){return Oe(l)?e(l):ct(l)?t.check({tokenize:o4e},e,r)(l):r(l)}}function o4e(t,e,r){return it(t,o,"whitespace");function o(n){return n===null?r(n):e(n)}}function qte(t){return KS([WL(),YL(),XL(t),JL(),QL()])}we();we();var Gte=["bmp","gif","ico","jpeg","jpg","png","tiff","webp"],Wte=[...Gte,"svg"],Kte=["mp4","webm"],n4e="https://lh3.googleusercontent.com/";async function Dd(t,e){let r=window.__ROOT_CTX.rootConfig.projectId,o=await d4e(t),n=Nh(t.name),i=e?.preserveFilename?`${o}/${t.name}`:`${o}.${n}`,a=`${r}/uploads/${i}`,s=yQ(window.firebase.storage,a),l=xQ(s,t),c=-1,d=Date.now();return await new Promise((u,f)=>{let m=setInterval(()=>{Date.now()-d>1e4&&(clearInterval(m),f(new Error("Upload stalled: no progress for 10 seconds")))},1e3);l.on("state_changed",h=>{h.bytesTransferred>0&&clearInterval(m),console.log(`uploading ${t.name}: ${h.bytesTransferred} / ${h.totalBytes} bytes`),h.bytesTransferred!==c&&(c=h.bytesTransferred,d=Date.now())},h=>{clearInterval(m),f(h)},()=>{console.log(`uploaded ${a}`),clearInterval(m),u(l.snapshot)})}),i4e(s,t,n,e)}async function i4e(t,e,r,o){let n={};n.filename=e.name,n.uploadedBy=window.firebase.user.email||"unknown",n.uploadedAt=String(Math.floor(new Date().getTime()));let i=`/${t.bucket}/${t.fullPath}`,a=`https://storage.googleapis.com${i}`;if(Wte.includes(r)){let l=await l4e(e);if(n.width=l.width,n.height=l.height,!o?.disableGci&&Gte.includes(r)){let c=await s4e(i);c&&(n.gcsPath=i,a=c)}n.canvasBgColor=await f4e(e)?"dark":"light"}else if(Kte.includes(r)){let l=await c4e(a);n.width=l.width,n.height=l.height,console.log("video dimensions:",l)}let s=o?.cacheControl||"public, max-age=31536000";return await bQ(t,{cacheControl:s,customMetadata:u4e(n)}),console.log("updated meta data: ",n),{...n,src:a}}function Nh(t){return a4e(t.split(".").at(-1)||"")}function a4e(t){let e=String(t).toLowerCase();return e==="jpeg"&&(e="jpg"),e}async function s4e(t){let e=window.__ROOT_CTX.rootConfig.gci;if(!e)return"";let r=new URLSearchParams({gcs:t}),o=`${e}/_/serving_url?${r.toString()}`,n=await window.fetch(o);if(n.status!==200){let a=await n.text();throw console.error(`failed to get gci url: ${o}`),console.error(a),new Error("failed to get gci url")}return(await n.json()).servingUrl}async function l4e(t){return new Promise((e,r)=>{let o=new FileReader;o.onload=()=>{let n=new Image;n.onload=()=>{e({width:n.width,height:n.height})},n.onerror=r,n.src=String(o.result)},o.onerror=r,o.readAsDataURL(t)})}async function c4e(t){return new Promise((e,r)=>{let o=document.createElement("video");o.addEventListener("loadedmetadata",()=>{let n={width:o.videoWidth,height:o.videoHeight};e(n),document.body.removeChild(o)},!1),o.addEventListener("error",()=>{r(new Error("Failed to load video metadata")),document.body.removeChild(o)},!1),o.className="sr-only",o.src=t,o.preload="metadata",document.body.appendChild(o)})}async function d4e(t){let e=await t.arrayBuffer(),r=await crypto.subtle.digest("SHA-1",e);return Array.from(new Uint8Array(r)).map(i=>i.toString(16).padStart(2,"0")).join("")}function u4e(t){let e={};return Object.entries(t).forEach(([r,o])=>{t[r]=String(o).trim()}),e}function Zb(t){if(!t)return!1;if(cC(t)||t.startsWith("data:image/"))return!0;let e=Nh(t);return Wte.includes(e)}function cC(t){return t?t.startsWith(n4e):!1}function ZL(t){if(!t)return!1;let e=Nh(t);return Kte.includes(e)}function Yte(t){return cC(t)?t.split("=")[0]+"=s0-d":t}function f4e(t){return new Promise((e,r)=>{let o=new Image,n=new FileReader;n.onload=()=>{o.src=n.result},o.onload=()=>{let i=document.createElement("canvas"),a=i.getContext("2d");i.width=o.width,i.height=o.height,a.drawImage(o,0,0,i.width,i.height);let{data:s}=a.getImageData(0,0,i.width,i.height),l=0,c=0,d=0,u=0;for(let m=0;m<s.length;m+=400)l+=s[m],c+=s[m+1],d+=s[m+2],u++;let f=.299*(l/u)+.587*(c/u)+.114*(d/u);e(f<128)},o.onerror=r,n.onerror=r,n.readAsDataURL(t)})}function dC(t){let[e,r]=M(""),o=G(null),n=G(null),[i,a]=M(null),[s,l]=M(!1),c=!e;function d(b){return b.endsWith(".jpg")?"image/jpeg":"image/png"}async function u(){if(!e)return;let b=[{type:"text",text:e}];i&&b.push({type:"image",image:{src:i.src,width:i.width,height:i.height,alt:i.filename}});let y=t.chat.addMessage({sender:"user",blocks:b});r(""),a(null),f();let v=[{text:e}];i&&v.push({media:{url:i.src,contentType:d(i.filename)}});let S=await t.chat.sendPrompt(y,v,t.options);t.onData&&S&&t.onData(S)}function f(){window.requestAnimationFrame(()=>{let b=o.current;b.style.height="auto",b.style.height=`${b.scrollHeight}px`})}function m(b){if(b.key==="Enter"&&!b.shiftKey){b.preventDefault(),u();return}}async function h(b){try{l(!0),f();let y=await Dd(b,{disableGci:!0});a({src:y.src,width:y.width,height:y.height,filename:y.filename}),l(!1)}catch{l(!1)}if(n.current){let y=n.current;y.value=""}}function g(b){let S=(b.target.files||[])[0];S&&h(S)}function _(){a(null),f()}return V(()=>{f()},[e]),p("div",{className:"AIPage__ChatBar",children:[p("div",{className:Ne("AIPage__ChatBar__prompt",(s||i)&&"AIPage__ChatBar__prompt--hasImage"),children:[p("label",{className:"AIPage__ChatBar__prompt__imageUpload",children:[p("input",{className:"AIPage__ChatBar__prompt__imageUpload__input",type:"file",accept:"image/png, image/jpeg, image/webp",onChange:g,ref:n}),p(Te,{label:"Upload image",children:p(Xe,{component:"div",className:"AIPage__ChatBar__prompt__imageUpload__icon",radius:"xl",children:p(Rb,{size:18})})})]}),p("textarea",{className:"AIPage__ChatBar__prompt__textInput",ref:o,placeholder:"Enter prompt...",rows:1,onKeyDown:m,onPaste:b=>{let y=b.clipboardData?.items||[];for(let v of y)if(v.kind==="file"&&v.type.startsWith("image/")){let S=v.getAsFile();S&&h(S)}},onChange:b=>{r(b.target.value)},value:e,autofocus:!0}),(s||i)&&p("div",{className:"AIPage__ChatBar__prompt__imagePreview",children:s?p(et,{size:"sm"}):p(Te,{label:i.filename,transition:"pop",position:"right",withArrow:!0,children:p("button",{className:"AIPage__ChatBar__prompt__imagePreview__closeButton",onClick:()=>_(),children:[p("img",{src:i.src,width:i.width,height:i.height,alt:"attachment"}),p("div",{className:"AIPage__ChatBar__prompt__imagePreview__closeButton__icon",children:p($b,{size:24,color:"white"})})]})})}),p(Xe,{className:"AIPage__ChatBar__prompt__submit",variant:"filled",color:"dark",radius:"xl",onClick:()=>u(),disabled:c,children:p(HM,{size:18})})]}),p("div",{className:"AIPage__ChatBar__disclaimer",children:"Root AI is experimental and makes mistakes. Check all info."})]})}var Xte={name:"@blinkk/root-cms",version:"2.4.1",author:"s@blinkk.com",license:"MIT",engines:{node:">=16.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/index.js",types:"./dist/index.d.ts",exports:{".":{types:"./dist/core.d.ts",import:"./dist/core.js"},"./client":{types:"./dist/client.d.ts",import:"./dist/client.js"},"./core":{types:"./dist/core.d.ts",import:"./dist/core.js"},"./functions":{types:"./dist/functions.d.ts",import:"./dist/functions.js"},"./plugin":{types:"./dist/plugin.d.ts",import:"./dist/plugin.js"},"./project":{types:"./dist/project.d.ts",import:"./dist/project.js"},"./richtext":{types:"./dist/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":"tsup-node --config=./core/tsup.config.ts","//":"NOTE: esbuild is used here because tsup doesn't currently support aliases.","build:ui":"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","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 --watch",test:"pnpm build && firebase emulators:exec 'vitest run'","test:watch":"pnpm build && firebase emulators:exec 'vitest'"},dependencies:{"@genkit-ai/ai":"1.18.0","@genkit-ai/core":"1.18.0","@genkit-ai/vertexai":"1.18.0","@google-cloud/firestore":"7.11.3","@hello-pangea/dnd":"18.0.1","body-parser":"1.20.2",commander:"11.0.0","csv-parse":"5.5.2","csv-stringify":"6.4.4",diff:"8.0.2","dts-dom":"3.7.0","fnv-plus":"1.3.1",genkit:"1.18.0",jsonwebtoken:"9.0.2",kleur:"4.1.5",sirv:"2.0.3","tiny-glob":"0.2.9",zod:"3.23.8"},"//":"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/utils":"0.33.1","@mantine/core":"4.2.12","@mantine/hooks":"4.2.12","@mantine/modals":"4.2.12","@mantine/notifications":"4.2.12","@mantine/spotlight":"4.2.12","@preact/compat":"18.3.1","@tabler/icons-preact":"3.35.0","@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",concurrently:"7.6.0",esbuild:"0.25.9",firebase:"12.2.1","firebase-admin":"13.5.0","firebase-functions":"6.4.0","firebase-tools":"14.15.2","highlight.js":"11.6.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",preact:"10.27.1","preact-render-to-string":"6.6.1","preact-router":"4.1.2",react:"npm:@preact/compat@18.3.1","react-dom":"npm:@preact/compat@18.3.1","react-json-view-compare":"2.0.2",tsup:"8.5.0",typescript:"5.9.2",vite:"7.1.4",vitest:"3.2.4",yjs:"13.6.27"},peerDependencies:{"@blinkk/root":"2.4.1","firebase-admin":">=11","firebase-functions":">=4",preact:">=10","preact-render-to-string":">=5"},peerDependenciesMeta:{"firebase-functions":{optional:!0}}};function Jte(){return p("svg",{width:"100",height:"23",viewBox:"0 0 100 23",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p("g",{"clip-path":"url(#clip0_1_318)",children:[p("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"}),p("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"}),p("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"}),p("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"}),p("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"}),p("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"}),p("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"}),p("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"}),p("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"})]}),p("defs",{children:p("clipPath",{id:"clip0_1_318",children:p("rect",{width:"99",height:"22",fill:"white",transform:"translate(0.0175781 0.177246)"})})})]})}var pc="1.5";function Fe(t){return p("div",{className:"Layout",children:[p(Fe.Top,{}),p(Fe.Side,{}),p(Fe.Main,{...t,children:t.children}),p(Fe.Bottom,{})]})}Fe.Top=()=>{let t=window.__ROOT_CTX.rootConfig.projectName||window.__ROOT_CTX.rootConfig.projectId;return p("div",{className:"Layout__top",children:[p("a",{className:"Layout__top__logo",href:"/cms",children:p(Jte,{})}),p("div",{className:"Layout__top__version",children:["v",Xte.version]}),p("div",{className:"Layout__top__project",children:t})]})};Fe.Side=()=>{let[t]=EQ(),e=t.url.replace(/\/*$/g,""),r=window.firebase.user,o=window.__ROOT_CTX.sidebar?.tools,n=new Set(window.__ROOT_CTX.sidebar?.hiddenBuiltInTools||[]),i=s=>n.has(s),a=window.__ROOT_CTX.experiments||{};return p("div",{className:"Layout__side",children:[p("div",{className:"Layout__side__buttons",children:[!i("home")&&p(Fe.SideButton,{label:"Home",url:"/cms",active:e==="/cms",children:p(PM,{stroke:pc})}),!i("content")&&p(Fe.SideButton,{label:"Content",url:"/cms/content",active:e.startsWith("/cms/content"),children:p(Cf,{stroke:pc})}),!i("releases")&&p(Fe.SideButton,{label:"Releases",url:"/cms/releases",active:e.startsWith("/cms/releases"),children:p(_h,{stroke:pc})}),!i("data")&&p(Fe.SideButton,{label:"Data",url:"/cms/data",active:e.startsWith("/cms/data"),children:p(bM,{stroke:pc})}),!i("assets")&&p(Fe.SideButton,{label:"Assets",url:"/cms/assets",active:e.startsWith("/cms/assets"),children:p($M,{stroke:pc})}),!i("translations")&&p(Fe.SideButton,{label:"Translations",url:"/cms/translations",active:e.startsWith("/cms/translations"),children:p(Cd,{stroke:pc})}),a.ai&&!i("ai")&&p(Fe.SideButton,{label:"Root AI (experimental)",url:"/cms/ai",active:e.startsWith("/cms/ai"),children:p(kf,{stroke:pc})}),o&&p(Ce,{children:[p("div",{className:"Layout__side__divider"}),Object.entries(o).map(([s,l])=>{let c=l.cmsUrl?.startsWith("/cms/")?l.cmsUrl:void 0,d=l.externalUrl,u=d??c??`/cms/tools/${s}`,f=d?void 0:u.replace(/\/*$/g,""),m=!d&&!!f&&(e===f||e.startsWith(`${f}/`));return p(Fe.SideButton,{className:"Layout__side__tool",label:l.label||"",url:u,active:m,external:!!d,children:l.icon?p("img",{className:"Layout__side__tool__icon",src:l.icon,alt:l.label||""}):p(pM,{stroke:pc})},s)}),p("div",{className:"Layout__side__divider"})]}),!i("settings")&&p(Fe.SideButton,{label:"Settings",url:"/cms/settings",active:e.startsWith("/cms/settings"),children:p(Nf,{stroke:pc})})]}),p("div",{className:"Layout__side__user",children:p(Te,{label:r.email,position:"right",withArrow:!0,children:p(Aa,{src:r.photoURL,alt:r.email,size:30,radius:"xl"})})})]})};Fe.SideButton=t=>p(Te,{className:Ne("Layout__side__button",t.className),label:t.label,position:"right",withArrow:!0,children:p("a",{className:Ne(t.active&&"active"),href:t.url,target:t.external?"_blank":void 0,rel:t.external?"noreferrer noopener":void 0,children:t.children})});Fe.Main=t=>p("div",{className:"Layout__main",children:t.children});Fe.Bottom=()=>p("div",{className:"Layout__bottom"});function pi(t){t||(t=6);let e=[],r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",o=r.length;for(let n=0;n<t;n++)e.push(r.charAt(Math.floor(Math.random()*o)));return e.join("")}function Qte(t,e){return Math.random()*(e-t)+t}var m4e=[20,40];mL.configure({ignoreUnescapedHTML:!0});function Zte(){return Qte(...m4e)}function ey(){let[t,e]=M([]),[r,o]=M(""),n=s=>{let l=0;return e(c=>{let d={sender:"bot",blocks:[{type:"pending"}],key:pi()},u=[...c,{...s,key:pi()},d];return l=u.length-1,u}),l},i=(s,l)=>{e(c=>{let d=[...c];return d[s]={...l,key:pi()},d})};return{chatId:r,messages:t,addMessage:n,updateMessage:i,sendPrompt:async(s,l,c)=>{let d="/cms/api/ai.chat";typeof window.__ROOT_CTX.experiments?.ai=="object"&&window.__ROOT_CTX.experiments.ai.endpoint&&(d=window.__ROOT_CTX.experiments.ai.endpoint);let u={prompt:l,chatId:r,options:c},f=await window.fetch(d,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(u)});if(f.status!==200){let h=await f.text();console.error("chat failed",h);let g=["Something went wrong:","```",h,"```"].join(`
66
66
  `);return i(s,{sender:"bot",blocks:[{type:"text",text:g}]}),{message:g,data:{},error:h}}let m=await f.json();return m.success&&m.chatId?(o(m.chatId),i(s,{sender:"bot",data:m.response?.data||{},blocks:[{type:"text",text:m.response?.message||""}]}),m.response):{message:"Sorry. Something went wrong. An unknown error occurred.",data:{},error:"Unknown error"}}}}function ere(){let t=ey(),e=window.__ROOT_CTX.experiments?.ai||!1;return p(Fe,{children:p("div",{className:"AIPage",children:e?p(Ce,{children:[p(e2,{chat:t,children:p("p",{children:"Chat with me about your website. Ask questions about the content and I can tell you about it."})}),p(dC,{chat:t})]}):p("div",{className:"AIPage__notEnabled",children:[p("div",{className:"AIPage__notEnabled__icon",children:p(kf,{size:36})}),p("div",{className:"AIPage__notEnabled__title",children:"Root AI is not enabled for this project."})]})})})}function e2(t){let e=t.chat.messages;return p("div",{className:"AIPage__ChatWindow",children:e.length>0?p("div",{className:"AIPage__ChatWindow__messages",children:t.chat.messages.map((r,o)=>p(h4e,{message:r},r.key||o))}):p("div",{className:"AIPage__ChatWindow__welcome",children:[p("div",{className:"AIPage__ChatWindow__welcome__icon",children:p(kf,{size:36})}),p("div",{className:"AIPage__ChatWindow__welcome__title",children:"Root AI is ready"}),t.children&&p("div",{className:"AIPage__ChatWindow__welcome__body",children:t.children})]})})}function h4e(t){let e=t.message,r=e.sender==="user"?"You":"Root AI",o=window.firebase.user,n=e.sender==="bot",i=G(null);return V(()=>{e.sender==="user"&&i.current.scrollIntoView({behavior:"smooth",block:"start"})},[]),p("div",{className:"AIPage__ChatMessage",ref:i,children:[p("div",{className:"AIPage__ChatMessage__side",children:p("div",{className:"AIPage__ChatMessage__side__avatar",children:e.sender==="user"?p(Aa,{src:o.photoURL,alt:o.email,size:28,radius:"xl"}):p(kf,{size:28})})}),p("div",{className:"AIPage__ChatMessage__main",children:[p("div",{className:"AIPage__ChatMessage__main__username",children:r}),p("div",{className:"AIPage__ChatMessage__main__blocks",children:p(g4e,{message:e,animated:n})})]})]})}function g4e(t){let e=t.message,[r,o]=M(t.animated?[]:e.blocks);function n(){if(r.length>=e.blocks.length)return;let i=[...r,e.blocks[r.length]];o(i)}return V(()=>{t.animated&&n()},[t.animated]),p("div",{className:"AIPage__ChatMessageBlocks",children:r.map((i,a)=>{let s=`${a}-${i.type}`;return i.type==="image"?p(y4e,{block:i,animated:t.animated,onAnimationComplete:()=>n()},s):i.type==="pending"?p(b4e,{block:i,animated:t.animated,onAnimationComplete:()=>n()},s):i.type==="text"?p(_4e,{block:i,animated:t.animated,onAnimationComplete:()=>n()},s):p("div",{children:["unknown block type: ",i.type]})})})}function tre(t){let[e,r]=M(t.animated?[]:t.nodes),o=e.length>=t.nodes.length,n=()=>{r(a=>a.length>=t.nodes.length?t.nodes:[...a,t.nodes[a.length]])},i=()=>{if(e.length>=t.nodes.length){t.onAnimationComplete&&t.onAnimationComplete();return}window.setTimeout(()=>n(),Zte())};return V(()=>{t.animated&&n()},[]),{nodes:e,next:i,complete:o}}function _4e(t){let e=pe(()=>DL(t.block.text,{extensions:[qte()],mdastExtensions:[qL()]}),[t.block.text]),{nodes:r,next:o}=tre({nodes:e.children,animated:t.animated,onAnimationComplete:t.onAnimationComplete});return p("div",{className:"AIPage__ChatMessageTextBlock",children:r.map((n,i)=>p(rre,{node:n,animated:t.animated,onAnimationComplete:o},i))})}function rre(t){let e=t.node;if(e.type==="code")return p(x4e,{text:e.value,language:e.lang,animated:t.animated,onAnimationComplete:t.onAnimationComplete});if(e.type==="heading"){let r=`h${e.depth||2}`;return p(Uf,{as:r,nodes:e.children,animated:t.animated,onAnimationComplete:t.onAnimationComplete})}if(e.type==="inlineCode")return p(Uf,{as:"code",nodes:[{type:"text",value:e.value}],animated:t.animated,onAnimationComplete:t.onAnimationComplete});if(e.type==="link")return p(Uf,{as:"a",attrs:{href:e.url,target:"_blank"},nodes:e.children,animated:t.animated,onAnimationComplete:t.onAnimationComplete});if(e.type==="list"){let r=e.ordered?"ol":"ul";return p(Uf,{as:r,nodes:e.children,animated:t.animated,onAnimationComplete:t.onAnimationComplete})}return e.type==="listItem"?p(Uf,{as:"li",nodes:e.children,animated:t.animated,onAnimationComplete:t.onAnimationComplete}):e.type==="paragraph"?p(Uf,{as:"p",nodes:e.children,animated:t.animated,onAnimationComplete:t.onAnimationComplete}):e.type==="strong"?p(Uf,{as:"b",nodes:e.children,animated:t.animated,onAnimationComplete:t.onAnimationComplete}):e.type==="text"?p(ore,{text:e.value,animated:t.animated,onAnimationComplete:t.onAnimationComplete}):p("div",{children:JSON.stringify(t.node)})}function Uf(t){let{nodes:e,next:r}=tre({nodes:t.nodes,animated:t.animated,onAnimationComplete:t.onAnimationComplete}),o=t.as;return p(o,{...t.attrs,children:e.map((n,i)=>p(rre,{node:n,animated:t.animated,onAnimationComplete:()=>r()},i))})}function ore(t){let e=t.sep||" ",r=pe(()=>t.text.split(e),[t.text]),[o,n]=M(t.animated?0:r.length),i=o>=r.length;return V(()=>{if(!t.animated||o>=r.length)return;let a=window.setTimeout(()=>{n(o+1)},Zte());return()=>window.clearTimeout(a)},[t.text,o]),V(()=>{i&&t.animated&&t.onAnimationComplete()},[i]),p(Ce,{children:[r.slice(0,o).join(e),!i&&p(nre,{})]})}function x4e(t){let e=G(null),[r,o]=M(!1);function n(){let s=e.current;mL.highlightElement(s),console.log("highlight:",s)}async function i(){try{await navigator.clipboard.writeText(t.text),o(!0),window.setTimeout(()=>{o(!1)},2e3)}catch(s){console.error("failed to copy to clipboard:",s)}}function a(){n(),t.onAnimationComplete()}return V(()=>{t.animated||n()},[t.animated]),p("div",{className:"AIPage__CodeBlockNode",children:[p("div",{className:"AIPage__CodeBlockNode__header",children:[t.language&&p("div",{className:"AIPage__CodeBlockNode__language",children:t.language}),p(Te,{label:"Copy code",position:"bottom",transition:"pop",children:p(Xe,{onClick:()=>i(),size:"xs",children:r?p(gM,{color:"#80868b","stroke-width":1.5,size:16}):p(Sb,{color:"#80868b","stroke-width":1.5,size:16})})})]}),p("pre",{ref:e,class:`language-${t.language||"unknown"}`,children:p(ore,{text:t.text,sep:`
67
67
  `,animated:t.animated,onAnimationComplete:a})})]})}function b4e(t){return V(()=>{t.animated&&t.onAnimationComplete()},[]),p("div",{className:"AIPage__PendingMessageBlock",children:p(nre,{})})}function nre(){return p("div",{className:"AIPage__CursorDot"})}function y4e(t){let e=t.block.image;return V(()=>{t.animated&&t.onAnimationComplete()},[]),p("div",{className:"AIPage__ImageMessageBlock",children:p("img",{src:e.src,width:e.width,height:e.height,alt:e.alt})})}function ire(t){let e=ey();return p(Ce,{children:[p(e2,{chat:e,children:t.children}),p(dC,{chat:e,options:{mode:"edit",editData:t.editModeData},onData:t.onEditModeResponse})]})}var t2="AiEditModal";function are(){let t=Ct(),e=Vt();return{open:r=>{t.openContextModal(t2,{...e,title:r.title||"Edit with AI (Experimental)",innerProps:r,size:"calc(min(1920px, calc(100% - 96px)))",centered:!0})},close:()=>{t.closeModal(t2)}}}function uC(t){let{innerProps:e,context:r,id:o}=t,n=G(null),i=pe(()=>JSON.stringify(e.data||{},null,2),[e.data]),[a,s]=M(i),l=pe(()=>{if(!a)return null;try{return JSON.parse(a)}catch{return null}},[a]),c=pe(()=>a!==i,[a,i]),d=qe(()=>{if(!l)return;let f=yh(l);e.onSave&&e.onSave(f)},[l]),u=qe(f=>{if(f?.data){let m=JSON.stringify(f.data,null,2);s(m),n.current?.click()}},[]);return p("div",{className:"AiEditModal",children:[p("div",{className:"AiEditModal__SplitPanel",children:[p("div",{className:"AiEditModal__SplitPanel__ChatPanel",children:p(ire,{editModeData:l,onEditModeResponse:u,children:[p("p",{children:"Tell me what you want to change. I can make simple text edits, replace content within a module, or answer questions about the content."}),p("p",{children:"Just enter simple instructions, or attach a screenshot and ask me to use it as reference."})]})}),p("div",{className:"AiEditModal__SplitPanel__JsonPanel",children:p(Js,{className:"AiEditModal__Tabs",grow:!0,children:[p(Js.Tab,{label:"JSON",icon:p(DM,{size:20}),children:p("div",{className:"AiEditModal__JsonEditor",children:p(nd,{value:a,onChange:f=>s(f),formatOnBlur:!0,height:"100%",className:"AiEditModal__JsonInput"})})}),p(Js.Tab,{ref:n,label:"Diff",icon:p(EM,{size:20}),children:p("div",{className:"AiEditModal__JsonDiffViewer",children:e.data&&a&&p(KQ,{oldCode:i,newCode:a})})})]})})]}),p("div",{className:"AiEditModal__buttons",children:[p(ee,{variant:"default",size:"xs",color:"dark",type:"button",onClick:()=>r.closeModal(o),children:"Cancel"}),p(ee,{variant:"default",size:"xs",type:"button",leftIcon:p(vb,{size:16}),disabled:!c,onClick:()=>s(i),children:"Reset"}),p(ee,{leftIcon:p(Eb,{size:16}),variant:"filled",size:"xs",color:"green",disabled:!l||!c,onClick:d,children:"Accept changes"})]})]})}uC.id=t2;we();var v4e=/^[a-z0-9_]+(?:--?[a-z0-9_]+)*$/;function pl(t,e){e||(e=v4e);let r=typeof e=="string"?new RegExp(e):e;return!!(t&&r.test(t))}function Ad(t){return t.replace(/^[\s/]*/g,"").replace(/[\s/]*$/g,"").replace(/^\/+|\/+$/g,"").replaceAll("/","--")}we();function Je(t){let{className:e,as:r,size:o,weight:n,color:i,children:a,...s}=t;return p(r||"div",{...s,className:Ne(e,"text",o&&`size:${o}`,n&&`weight:${n}`,i&&`color:${i}`),children:a})}function xs(t){let r=window.__ROOT_CTX.collections[t.collectionId];if(!r)throw new Error(`collection not found: ${t.collectionId}`);let o=r.domain||window.__ROOT_CTX.rootConfig.domain||"https://example.com",n=r2(t);return`${o}${n}`}function r2(t){let e=window.__ROOT_CTX.collections,{collectionId:r,slug:o,locale:n}=t,i=e[r];if(!i)throw new Error(`collection not found: ${r}`);let a=window.__ROOT_CTX.rootConfig,s=a.base||"/",l="/[base]/[path]";n&&(l=a.i18n.urlFormat||"/[locale]/[base]/[path]");let c="",d=i?.url;if(d)if(o){let u=d.replace(/\[.*slug\]/,o).replaceAll("--","/").replace(/\/+/g,"/");u==="/index"&&(u="/"),c=u}else c=d;return sre(l,{base:s,path:c,locale:n||"",slug:o})}function fC(t){let e=window.__ROOT_CTX.collections,{collectionId:r,slug:o,locale:n}=t,i=e[r];if(!i)throw new Error(`collection not found: ${r}`);let a=window.__ROOT_CTX.rootConfig,s=a.base||"/",l="/[base]/[path]";n&&(l=a.i18n.urlFormat||"/[locale]/[base]/[path]");let c="",d=i?.previewUrl||i?.url;if(d)if(o){let u=d.replace(/\[.*slug\]/,o).replaceAll("--","/").replace(/\/+/g,"/");u==="/index"&&(u="/"),c=u}else c=d;return sre(l,{base:s,path:c,locale:n||"",slug:o})}function sre(t,e){let r=t.replaceAll(/\[\[?(\.\.\.)?([\w\-_]*)\]?\]/g,(o,n,i)=>e[i]??o);return I4e(r,{trailingSlash:window.__ROOT_CTX.rootConfig.server.trailingSlash})}function I4e(t,e){return t=t.replace(/\/+/g,"/"),e?.trailingSlash===!1&&t!=="/"&&t.endsWith("/")&&(t=t.replace(/\/*$/g,"")),(t.endsWith("/index")||t.endsWith("/index/"))&&(t=t.slice(0,-6)),t.startsWith("/")||(t=`/${t}`),e?.trailingSlash&&!t.endsWith("/")&&(t=`${t}/`),t}function pC(t){let[e,r]=M(t.collectionId||""),o=G(null),[n,i]=M(""),a=window.__ROOT_CTX.collections[e],s=[];t.collectionId&&t.collectionDisabled?s.push({value:t.collectionId,label:t.collectionId}):Object.keys(window.__ROOT_CTX.collections).forEach(u=>{s.push({value:u,label:u})});let l="";if(a?.url){if(n){let u=Ad(n),f=a?.slugRegex;pl(u,f)?l=xs({collectionId:e,slug:u}):l="INVALID SLUG"}else l=xs({collectionId:e,slug:"[slug]"});l.endsWith("/index")&&(l=l.replace(/\/index$/,"/"))}function c(u){r(u),t.onChange&&t.onChange({collectionId:u,slug:n})}function d(u){i(u),t.onChange&&t.onChange({collectionId:e,slug:u})}return p("div",{className:Ne(t.className,"SlugInput"),children:[p("div",{className:"SlugInput__inputs",children:[p(Sr,{className:"SlugInput__collection",placeholder:"Collection",size:"xs",data:s,onChange:u=>c(u),value:e,disabled:!!t.collectionDisabled}),p("div",{className:"SlugInput__divider",children:"/"}),p(tr,{className:"SlugInput__slug",name:"slug",ref:o,value:n,onChange:u=>{d(u.currentTarget.value)},placeholder:"slug",autoComplete:"off",size:"xs"})]}),l&&p(Je,{className:"SlugInput__urlHelp",size:"body-sm",children:l})]})}var lre="CopyDocModal";function mC(t){let e=Ct(),r=Vt();return{open:o=>{e.openContextModal(lre,{...r,innerProps:{...t,...o}})}}}function hC(t){let{innerProps:e,context:r,id:o}=t,[n,i]=M(""),[a,s]=M(""),[l,c]=M(""),[d,u]=M(!1),[f,m]=M(!1),h=e.fromDocId,g=h.split("/")[0],_=e.fromLabel||h;async function b(y){if(y.preventDefault(),m(!0),c(""),!g){c("Please select a collection."),m(!1);return}let v=Ad(a),S=window.__ROOT_CTX.collections[n]?.slugRegex;if(!pl(v,S)){c('Please enter a valid slug (e.g. "foo-bar-123").'),m(!1);return}let N=`${n}/${v}`;try{e.fields?await Hb(N,{fields:e.fields,overwrite:d}):await UQ(h,N,{overwrite:d}),r.closeModal(o),Re({title:"Copied!",message:`Succesfully copied ${_} to ${N}.`,autoClose:5e3}),e.onSuccess&&e.onSuccess(N)}catch(w){let E=String(w);c(E),E.includes("already exists")&&u(!0),m(!1);return}m(!1),_o(`/cms/content/${n}/${v}`)}return p("div",{className:"CopyDocModal",children:p("form",{onSubmit:y=>b(y),children:[p("div",{className:"CopyDocModal__from",children:[p(Je,{className:"CopyDocModal__from__label",size:"body",weight:"bold",children:"From:"}),p(Je,{className:"CopyDocModal__from__value",size:"body-sm",children:p("code",{children:_})})]}),p("div",{className:"CopyDocModal__to",children:[p(Je,{className:"CopyDocModal__to__label",size:"body",weight:"bold",children:"To:"}),p(pC,{className:"CopyDocModal__slug",collectionId:g,onChange:y=>{i(y.collectionId),s(y.slug)}})]}),l&&p("div",{className:"CopyDocModal__error",children:l}),p("div",{className:"CopyDocModal__buttons",children:[p(ee,{variant:"outline",onClick:()=>r.closeModal(o),type:"button",size:"xs",color:"dark",children:"Cancel"}),p(ee,{variant:"filled",type:"submit",size:"xs",color:"dark",loading:f,children:d?"Overwrite?":"Submit"})]})]})})}hC.id=lre;we();async function cre(){let t=window.firebase.db,e=window.__ROOT_CTX.rootConfig.projectId||"default",r=ze(t,"Projects",e),o=await No(r);if(!o.exists)return[];let i=(o.data()||{}).roles||{},a=[];return Object.entries(i).forEach(([s,l])=>{(l==="ADMIN"||l==="EDITOR")&&a.push(s)}),a}var ml=class t{constructor(e){this.spreadsheetId=e}static async create(e){let r=e.share??!1,o={fields:"spreadsheetId"};e?.title&&(o.resource={properties:{title:e.title}});let i=(await gapi.client.sheets.spreadsheets.create(o)).result,a=new t(i.spreadsheetId);if(a.setSpreadsheet(i),e?.parent&&await gapi.client.drive.files.update({fileId:a.spreadsheetId,addParents:e.parent,removeParents:"root",fields:"id, parents",resource:{}}),!r)return a;let s=await cre();return await a.share(s,"writer"),a}getUrl(){return ja({spreadsheetId:this.spreadsheetId})}async getSheet(e){if(this.sheets||await this.fetchSheets(),this.sheets){for(let r=0;r<this.sheets.length;r++)if(this.sheets[r].gid===e)return this.sheets[r]}return null}async createSheet(e){console.log("createSheet",this.spreadsheetId);let r=await gapi.client.sheets.spreadsheets.batchUpdate({spreadsheetId:this.spreadsheetId,resource:{requests:[{addSheet:{properties:{title:e.title}}}]}}),o=r.result.replies||[];if(o&&o.length>0){let n=o[0].addSheet?.properties?.sheetId;if(typeof n=="number")return new gC(this,n,e.title)}throw console.error(r),new Error("failed to get gid of new tab")}async fetchSheets(){let r=(await gapi.client.sheets.spreadsheets.get({spreadsheetId:this.spreadsheetId,fields:"sheets.properties"})).result;this.setSpreadsheet(r)}setSpreadsheet(e){this.spreadsheet=e,this.spreadsheet.sheets&&this.setSheets(this.spreadsheet.sheets)}setSheets(e){let r=[];e.forEach(o=>{let n=o.properties?.sheetId,i=o.properties?.title,a=new gC(this,n??0,i);r.push(a)}),this.sheets=r}async share(e,r){await Promise.all(e.map(async o=>{let n;o.startsWith("*@")?n={type:"domain",domain:o.slice(2),role:r}:n={type:"user",emailAddress:o,role:r},await gapi.client.drive.permissions.create({fileId:this.spreadsheetId,resource:n,sendNotificationEmail:!1,fields:"id"})}))}},gC=class{constructor(e,r,o){this.spreadsheet=e,this.gid=r,this.title=o}async updateValuesMap(e,r){let o=r.keyedBy,n=r.preserveColumns||[];if(!o)throw new Error('missing "keyedBy" argument');let[i,a]=await this.getValues(),s=[...i],l=[],c=-1,d=new Set;l.push(i.map((v,S)=>(v===o&&(c=S),n.includes(v)&&d.add(S),{hasChanges:!1,value:v})));function u(v){l[0].push({hasChanges:!0,value:v}),s.push(v)}c===-1&&u(o);let f={};a.forEach((v,S)=>{let N=S+1;l.push(v.map((w,E)=>(E===c&&w&&(w in f?console.warn(`multiple rows keyed by "${w}"`):f[w]=N),{hasChanges:!1,value:w})))});function m(v){for(let N in v)s.includes(N)||u(N);return s.map(N=>v[N]??null)}e.forEach(v=>{let S=m(v),N=v[o],w=f[N];if(w){let E=l[w];S.map((I,C)=>{C>=E.length?E.push({hasChanges:!0,value:I||""}):I!==null&&E[C].value!==I&&(!d.has(C)||!E[C].value)&&(E[C]={hasChanges:!0,value:I})})}else l.push(S.map(E=>({hasChanges:!!E,value:E||""})))});let h=s.length,g=l.length,_=i.length,b=a.length+1;(h>_||g>b)&&await this.resizeSheet({numCols:h+2,numRows:g+20});let y=[];l.forEach((v,S)=>{for(;v.length>0&&v.at(-1)?.hasChanges===!1;)v.pop();if(v.length!==0){if(v.every(N=>N.hasChanges)){y.push({range:`${this.title}!A${S+1}`,majorDimension:"ROWS",values:[v.map(N=>N.value||"")]});return}v.forEach((N,w)=>{if(N.hasChanges){let E=dre(w);y.push({range:`${this.title}!${E}${S+1}`,majorDimension:"ROWS",values:[[N.value||""]]})}})}}),y.length>0&&await gapi.client.sheets.spreadsheets.values.batchUpdate({spreadsheetId:this.spreadsheet.spreadsheetId,resource:{data:y,valueInputOption:"RAW"}})}async replaceSheet(e,r){let o=e.length,n=r.length+1,i=[];i.push(e),i.push(...r.map(s=>e.map(l=>s[l]||""))),await this.resizeSheet({numCols:o+2,numRows:n+20}),console.log("updating cell values");let a=dre(o-1);await gapi.client.sheets.spreadsheets.values.update({spreadsheetId:this.spreadsheet.spreadsheetId,range:`${this.title}!A1:${a}${n}`,valueInputOption:"RAW",resource:{range:`${this.title}!A1:${a}${n}`,majorDimension:"ROWS",values:i}})}async resizeSheet(e){let r=[];e.numCols&&r.push({updateSheetProperties:{properties:{sheetId:this.gid,gridProperties:{columnCount:e.numCols}},fields:"gridProperties.columnCount"}}),e.numRows&&r.push({updateSheetProperties:{properties:{sheetId:this.gid,gridProperties:{rowCount:e.numRows}},fields:"gridProperties.rowCount"}}),r.length>0&&(console.log("resizing sheet"),await gapi.client.sheets.spreadsheets.batchUpdate({spreadsheetId:this.spreadsheet.spreadsheetId,resource:{requests:r}}))}async getValues(){let r=(await gapi.client.sheets.spreadsheets.values.get({spreadsheetId:this.spreadsheet.spreadsheetId,range:this.title})).result.values;if(!r||r.length===0)return[[],[]];let o=r[0],n=r.slice(1);return[o,n]}async getValuesMap(){let[e,r]=await this.getValues();return r.map(n=>{let i={};return n.forEach((a,s)=>{let l=e[s];l&&(i[l]=String(a||""))}),i})}async setTitle(e){await gapi.client.sheets.spreadsheets.batchUpdate({spreadsheetId:this.spreadsheet.spreadsheetId,resource:{requests:[{updateSheetProperties:{properties:{title:e,sheetId:this.gid},fields:"title"}}]}}),this.title=e}getUrl(){return ja({spreadsheetId:this.spreadsheet.spreadsheetId,gid:this.gid})}async applyL10nTheme(){await gapi.client.sheets.spreadsheets.batchUpdate({spreadsheetId:this.spreadsheet.spreadsheetId,resource:{requests:[{repeatCell:{range:{sheetId:this.gid,startRowIndex:0},cell:{userEnteredFormat:{textFormat:{fontFamily:"Ubuntu",fontSize:10}}},fields:"userEnteredFormat(textFormat)"}},{repeatCell:{range:{sheetId:this.gid,startRowIndex:0,endRowIndex:1},cell:{userEnteredFormat:{textFormat:{bold:!0,fontFamily:"Ubuntu",fontSize:10}}},fields:"userEnteredFormat(textFormat)"}},{updateSheetProperties:{properties:{sheetId:this.gid,gridProperties:{frozenRowCount:1}},fields:"gridProperties.frozenRowCount"}},{updateDimensionProperties:{range:{sheetId:this.gid,dimension:"COLUMNS",startIndex:0,endIndex:1},properties:{pixelSize:320},fields:"pixelSize"}},{updateDimensionProperties:{range:{sheetId:this.gid,dimension:"COLUMNS",startIndex:1},properties:{pixelSize:320},fields:"pixelSize"}},{repeatCell:{range:{sheetId:this.gid,startRowIndex:1,startColumnIndex:0},cell:{userEnteredFormat:{wrapStrategy:"WRAP"}},fields:"userEnteredFormat(wrapStrategy)"}}]}})}};function ja(t){let r=[`https://docs.google.com/spreadsheets/d/${t.spreadsheetId}/edit`];return typeof t.gid=="number"&&r.push(`#gid=${t.gid}`),r.join("")}function Rd(t){if(!t.startsWith("https://docs.google.com/spreadsheets/d/"))return null;let e=t.split("/"),r=e[e.length-2],n=t.slice(t.indexOf("#")).match(/gid=(\d+)/),i=0;return n&&n[1]&&(i=parseInt(n[1])),{spreadsheetId:r,gid:i}}function dre(t){let e=[];for(;t>=0;){let r=t%26;e.push(String.fromCharCode(r+65)),t=(t-r-1)/26}return e.reverse().join("")}function o2(t){if(!t)return;if(!t.startsWith("https://drive.google.com/drive/folders/")){let o=t.trim();if(o.length===33&&/^[a-zA-Z0-9_-]+$/.test(o))return o}let e=t.trim().split("/");return e[e.length-1]||void 0}function ure(t){let e=o2(t);return e?`https://drive.google.com/drive/folders/${e}`:"https://drive.google.com/drive"}async function fre(t,e){if(!t)throw new Error("missing data source id");let r=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,n=ze(o,"Projects",r,"DataSources",t);await vd(n,{...e,id:t,createdAt:Tr(),createdBy:window.firebase.user.email}),Ot("datasource.create",{metadata:{datasourceId:t}})}async function _C(){let t=window.__ROOT_CTX.rootConfig.projectId,e=window.firebase.db,r=na(e,"Projects",t,"DataSources"),o=go(r),n=await ia(o),i=[];return n.forEach(a=>{i.push(a.data())}),i}async function Vf(t){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,o=ze(r,"Projects",e,"DataSources",t),n=await No(o);return n.exists()?n.data():null}async function xC(t,e){let r=e?.mode||"draft",o=window.__ROOT_CTX.rootConfig.projectId,n=window.firebase.db,i=ze(n,"Projects",o,"DataSources",t,"Data",r),a=await No(i);return a.exists()?a.data():null}async function pre(t,e){let r=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,n=ze(o,"Projects",r,"DataSources",t);await Lr(n,e),Ot("datasource.save",{metadata:{datasourceId:t}})}async function mre(t){let e=await Vf(t);if(!e)throw new Error(`data source not found: ${t}`);if(e.type==="http"&&e.url&&!xre(e.url)){let r=await fetch("/cms/api/data.sync",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({id:e.id})});if(r.status!==200){let o=await r.text();throw new Error(`sync failed: ${o}`)}}else{let{data:r,headers:o}=await w4e(e),n=window.__ROOT_CTX.rootConfig.projectId,i=window.firebase.db,a=ze(i,"Projects",n,"DataSources",t),s=ze(i,"Projects",n,"DataSources",t,"Data","draft"),l={...e,syncedAt:Tt.now(),syncedBy:window.firebase.user.email},c=Pi(i);c.set(s,{dataSource:l,data:r,...o?{headers:o}:{}}),c.update(a,{syncedAt:Tt.now(),syncedBy:window.firebase.user.email}),await c.commit()}console.log(`synced data source: ${t}`),Ot("datasource.sync",{metadata:{datasourceId:t}})}async function hre(t){let e=await Vf(t);if(!e)throw new Error(`data source not found: ${t}`);let r=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,n=ze(o,"Projects",r,"DataSources",t),i=ze(o,"Projects",r,"DataSources",t,"Data","draft"),a=ze(o,"Projects",r,"DataSources",t,"Data","published"),s=await xC(t,{mode:"draft"}),l={...e,publishedAt:Tt.now(),publishedBy:window.firebase.user.email},c=Pi(o);c.set(a,{dataSource:l,data:s?.data||null,...s?.headers?{headers:s.headers}:{}}),c.update(i,{dataSource:l}),c.update(n,{publishedAt:Tt.now(),publishedBy:window.firebase.user.email}),await c.commit(),console.log(`published data ${t}`),Ot("datasource.publish",{metadata:{datasourceId:t}})}async function gre(t,e){if(t.length===0)return;let r=window.firebase.db,o=window.__ROOT_CTX.rootConfig.projectId,n=e?.batch||Pi(r);for(let i of t){let a=await Vf(i);if(!a)throw new Error(`data source not found: ${i}`);let s=await xC(i,{mode:"draft"}),l=ze(r,"Projects",o,"DataSources",i),c=ze(r,"Projects",o,"DataSources",i,"Data","draft"),d=ze(r,"Projects",o,"DataSources",i,"Data","published"),u={...a,publishedAt:Tr(),publishedBy:window.firebase.user.email};n.set(d,{dataSource:u,data:s?.data||null,...s?.headers?{headers:s.headers}:{}}),n.update(c,{dataSource:u}),n.update(l,{publishedAt:Tr(),publishedBy:window.firebase.user.email}),Ot("datasource.publish",{metadata:{datasourceId:i}})}(!e?.batch||e?.commitBatch)&&await n.commit()}async function _re(t){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,o=ze(r,"Projects",e,"DataSources",t),n=ze(r,"Projects",e,"DataSources",t,"Data","draft"),i=ze(r,"Projects",e,"DataSources",t,"Data","published"),a=Pi(r);a.delete(n),a.delete(i),a.delete(o),await a.commit(),console.log(`deleted data source ${t}`),Ot("datasource.delete",{metadata:{datasourceId:t}})}async function w4e(t){if(t.type==="http")return{data:await S4e(t)};if(t.type==="gsheet")return await E4e(t);throw new Error(`unsupported data source: ${t.type}`)}async function E4e(t){let e=Rd(t.url);if(!e?.spreadsheetId)throw new Error(`failed to parse google sheet url: ${t.url}`);let o=await new ml(e.spreadsheetId).getSheet(e.gid??0);if(!o)throw new Error(`could not find sheet: ${t.url}`);let n=t.dataFormat||"map",[i,a]=await o.getValues();return n==="array"?{data:[i,a],headers:i}:{data:a.map(l=>{let c={};return l.forEach((d,u)=>{let f=i[u];f&&(c[f]=String(d||""))}),c}),headers:i}}async function S4e(t){if(!xre(t.url))throw new Error(`unsupported url: ${t.url}`);let e=await fetch(t.url,{method:t.httpOptions?.method||"GET",headers:t.httpOptions?.headers||[],body:t.httpOptions?.body||void 0});if(e.status!==200){let o=await e.text();throw new Error(`req failed: ${o}`)}return String(e.headers.get("content-type")).includes("application/json")?await e.json():e.text()}function xre(t){return t&&t.startsWith("/")}var n2="DataSourceSelectModal";function bre(){let t=Ct(),e=Vt();return{open:r=>{t.openContextModal(n2,{...e,innerProps:r,size:"600px",overflow:"inside"})},close:()=>{t.closeModal(n2)}}}function bC(t){let{innerProps:e}=t,[r,o]=M(!0),[n,i]=M([]),a=e.selectedDataSourceIds||[];V(()=>{async function c(){let d=await _C();i(d),o(!1)}c()},[]);function s(c){e.onChange&&e.onChange(c,!0)}function l(c){e.onChange&&e.onChange(c,!1)}return p("div",{className:"DataSourceSelectModal",children:r?p("div",{className:"DataSourceSelectModal__loading",children:p(et,{color:"gray",size:"xl"})}):n.length===0?p("div",{className:"DataSourceSelectModal__empty",children:"No data sources."}):p("div",{className:"DataSourceSelectModal__list",children:n.map(c=>p("div",{className:"DataSourceSelectModal__item",children:[p("div",{className:"DataSourceSelectModal__item__info",children:[p("div",{className:"DataSourceSelectModal__item__id",children:c.id}),p("div",{className:"DataSourceSelectModal__item__description",children:c.description||""})]}),p("div",{className:"DataSourceSelectModal__item__action",children:a.includes(c.id)?p(ee,{variant:"light",color:"blue",size:"xs",onClick:()=>l(c.id),children:"Unselect"}):p(ee,{variant:"filled",color:"blue",size:"xs",onClick:()=>s(c.id),children:"Select"})})]},c.id))})})}bC.id=n2;we();we();async function or(t){try{await t()}catch(e){console.error(e);let r;typeof e=="object"&&e.body?r=String(e.body):r=String(e),Re({title:"Error",message:r,color:"red",autoClose:!1})}}Zr();we();var i2=at(null);function Ph(){let t=Ze(i2);if(!t)throw new Error("useFirebase() should be called within a <FirebaseProvider>");return t}function Oh(t,e){let[r,o]=M([]),[n,i]=M(!0),s=Ph().db,l=window.__ROOT_CTX.rootConfig.projectId||"default",c=async()=>{i(!0);let d=na(s,"Projects",l,"Collections",t,"Drafts"),u=d,f=e.orderBy;if(f==="modifiedAt")u=go(d,Ni("sys.modifiedAt","desc"));else if(f==="newest")u=go(d,Ni("sys.createdAt","desc"));else if(f==="oldest")u=go(d,Ni("sys.createdAt"));else if(f==="slug")u=go(d,Ni(ub()));else if(f==="slugDesc")u=go(d,Ni(ub(),"desc"));else{let h=window.__ROOT_CTX.collections[t]?.sortOptions?.find(g=>g.id===f);h&&(u=h.direction==="desc"?go(d,Ni(h.field,"desc")):go(d,Ni(h.field)))}await or(async()=>{let m=await ia(u),h=[];m.docs.forEach(g=>{let _=g.data(),b=g.id,y=`${t}/${b}`,v={..._,id:y,slug:b};h.push(v),Vb(y,v)}),o(h)}),i(!1)};return V(()=>{i(!0),c()},[t,e.orderBy]),[n,c,r]}function Ai(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function Do(t,e){if(Array.isArray(e)){for(let n of e){let i=Do(t,n);if(i!=null)return i}return}let r=e.split("."),o=t;for(let n of r){if(o==null)return;o=C4e(o,n)}return o}function C4e(t,e){if(!e)return t;let r=/([^\[\]]+)|\[(\d+)\]/g,o=t,n;for(;n=r.exec(e);){if(o==null)return;let i=n[1],a=n[2];if(i!==void 0){o=o[i];continue}if(a===void 0)return;let s=Number(a);if(Array.isArray(o)){o=o[s];continue}if(Ai(o)&&Array.isArray(o._array)){let l=o._array[s];if(l===void 0)return;o=o[l];continue}if(Ai(o)&&Object.prototype.hasOwnProperty.call(o,String(s))){o=o[String(s)];continue}return}return o}function yre(t,e){return t.sort((r,o)=>{let n=r[e],i=o[e];return n<i?-1:n>i?1:0})}function ty(t,e){if(t===e)return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!ty(t[n],e[n]))return!1;return!0}let r=Object.keys(t),o=Object.keys(e);if(r.length!==o.length)return!1;for(let n of r)if(!ty(t[n],e[n]))return!1;return!0}function Kr(t){return t==null?t:typeof globalThis.structuredClone=="function"?globalThis.structuredClone(t):JSON.parse(JSON.stringify(t))}var a2="DocPickerModal";function vre(){let t=Ct(),e=Vt();return{open:r=>{t.openContextModal(a2,{...e,innerProps:r,size:"700px",overflow:"inside"})},close:()=>{t.closeModal(a2)}}}function Md(t){let{innerProps:e}=t,r=Object.keys(window.__ROOT_CTX.collections);e.collections?.length&&(r=r.filter(s=>e.collections?.includes(s)));let o=[{value:"",label:"Select"}];r.forEach(s=>{o.push({value:s,label:s})});let[n,i]=M(e.initialCollection||(r.length===1?r[0]:""));function a(s){e.onChange&&e.onChange(s.id)}return p("div",{className:"DocPickerModal",children:[r.length===0&&p("div",{className:"DocPickerModal__noCollections",children:"No collections matching schema field definition."}),r.length>1&&p("div",{className:"DocPickerModal__collection__select",children:[p("div",{className:"DocPickerModal__collection__select__label",children:"Content Type:"}),p(Sr,{data:o,value:n,placeholder:"Select",onChange:s=>{i(s||"")},size:"xs",radius:0,dropdownComponent:"div"})]}),n&&p(Md.DocsList,{collection:n,onDocSelected:a})]})}Md.DocsList=t=>{let[e,,r]=Oh(t.collection,{orderBy:"slug"});return p("div",{className:"DocPickerModal__DocsList",children:e?p("div",{className:"DocPickerModal__DocsList__loading",children:p(et,{color:"gray",size:"xl"})}):r.length===0?p("div",{className:"DocPickerModal__DocsList__empty",children:"Collection is empty."}):p("div",{className:"DocPickerModal__DocsList__docs",children:r.map(o=>p(Md.DocCard,{doc:o,onDocSelected:t.onDocSelected},o.id))})})};Md.DocCard=t=>{let e=t.doc,[r,o]=e.id.split("/"),n=e.fields||{},i=window.__ROOT_CTX.collections[r],a=xs({collectionId:r,slug:o}),s=Do(n,i.preview?.title||"meta.title"),l=Do(n,i.preview?.image||"meta.image")||i.preview?.defaultImage;return p("div",{className:"DocPickerModal__DocCard",children:[p("div",{className:"DocPickerModal__DocCard__image",children:p(od,{src:l?.src,width:120,height:90,withPlaceholder:!l?.src})}),p("div",{className:"DocPickerModal__DocCard__content",children:[p("div",{className:"DocPickerModal__DocCard__content__header",children:p("div",{className:"DocPickerModal__DocCard__content__header__docId",children:e.id})}),p("div",{className:"DocPickerModal__DocCard__content__title",children:s||"[UNTITLED]"}),p("div",{className:"DocPickerModal__DocCard__content__url",children:a})]}),p("div",{className:"DocPickerModal__DocCard__controls",children:p(ee,{color:"blue",size:"xs",onClick:()=>t.onDocSelected(t.doc),children:"Select"})})]})};Md.id=a2;we();function Dh(t){let{file:e,width:r,height:o,withPlaceholder:n,className:i,alt:a}=t,s=typeof e=="string"?e:e?.src;return T4e(e)?p(k4e,{className:i,src:s,width:r,height:o}):p(od,{className:i,src:s,width:r,height:o,withPlaceholder:n,alt:a})}function T4e(t){if(!t)return!1;if(typeof t=="string")return/\.mp4($|\?)/i.test(t);if(typeof t.mimeType=="string")return t.mimeType.toLowerCase()==="video/mp4";let e=t.src;return typeof e!="string"?!1:/\.mp4($|\?)/i.test(e)}function k4e(t){return p("video",{className:t.className,src:t.src,width:t.width,height:t.height,muted:!0,playsInline:!0,preload:"metadata",style:{width:`${t.width}px`,height:`${t.height}px`,backgroundColor:"#f1f3f5",objectFit:"cover",display:"block"}})}var s2="DocSelectModal";function yC(){let t=Ct(),e=Vt();return{open:r=>{t.openContextModal(s2,{...e,innerProps:r,size:"700px",overflow:"inside"})},close:()=>{t.closeModal(s2)}}}function Ld(t){let{innerProps:e}=t,r=Object.keys(window.__ROOT_CTX.collections);e.collections?.length&&(r=r.filter(l=>e.collections?.includes(l)));let o=[{value:"",label:"Select"}];r.forEach(l=>{o.push({value:l,label:l})});let[n,i]=M(e.initialCollection||(r.length===1?r[0]:""));function a(l){e.onChange&&e.onChange(l.id,!0)}function s(l){e.onChange&&e.onChange(l.id,!1)}return p("div",{className:"DocSelectModal",children:[r.length===0&&p("div",{className:"DocSelectModal__noCollections",children:"No collections matching schema field definition."}),r.length>1&&p("div",{className:"DocSelectModal__collection__select",children:[p("div",{className:"DocSelectModal__collection__select__label",children:"Content Type:"}),p(Sr,{data:o,value:n,placeholder:"Select",onChange:l=>{i(l||"")},size:"xs",radius:0,dropdownComponent:"div"})]}),n&&p(Ld.DocsList,{collection:n,onDocSelected:a,onDocUnselected:s,selectedDocIds:e.selectedDocIds})]})}Ld.DocsList=t=>{let[e,,r]=Oh(t.collection,{orderBy:"slug"}),o=t.selectedDocIds||[];return p("div",{className:"DocSelectModal__DocsList",children:e?p("div",{className:"DocSelectModal__DocsList__loading",children:p(et,{color:"gray",size:"xl"})}):r.length===0?p("div",{className:"DocSelectModal__DocsList__empty",children:"Collection is empty."}):p("div",{className:"DocSelectModal__DocsList__docs",children:r.map(n=>p(Ld.DocCard,{doc:n,onDocSelected:t.onDocSelected,onDocUnselected:t.onDocUnselected,selected:o.includes(n.id)},n.id))})})};Ld.DocCard=t=>{let[e,r]=M(!!t.selected),o=t.doc,[n,i]=o.id.split("/"),a=o.fields||{},s=window.__ROOT_CTX.collections[n],l=xs({collectionId:n,slug:i}),c=Do(a,s.preview?.title||"meta.title"),d=Do(a,s.preview?.image||"meta.image")||s.preview?.defaultImage;return p("div",{className:"DocSelectModal__DocCard",children:[p("div",{className:"DocSelectModal__DocCard__image",children:p(Dh,{file:d,width:120,height:90,withPlaceholder:!d?.src})}),p("div",{className:"DocSelectModal__DocCard__content",children:[p("div",{className:"DocSelectModal__DocCard__content__header",children:p("div",{className:"DocSelectModal__DocCard__content__header__docId",children:o.id})}),p("div",{className:"DocSelectModal__DocCard__content__title",children:c||"[UNTITLED]"}),p("div",{className:"DocSelectModal__DocCard__content__url",children:l})]}),p("div",{className:"DocSelectModal__DocCard__controls",children:e?p(ee,{variant:"light",color:"blue",size:"xs",onClick:()=>{r(!1),t.onDocUnselected(t.doc)},children:"Unselect"}):p(ee,{variant:"filled",color:"blue",size:"xs",onClick:()=>{r(!0),t.onDocSelected(t.doc)},children:"Select"})})]})};Ld.id=s2;we();var l2="EditJsonModal";function vC(){let t=Ct(),e=Vt();return{open:r=>{t.openContextModal(l2,{...e,title:r.title||"Edit JSON",innerProps:r,size:"680px",centered:!0})},close:()=>{t.closeModal(l2)}}}function IC(t){let{innerProps:e,context:r,id:o}=t,n=JSON.stringify(e.data||{},null,2),[i,a]=M(n),[s,l]=M(!0),[c,d]=M(!1),[u,f]=M(!1);function m(_){a(_),d(!1);try{JSON.parse(_),l(!0)}catch{l(!1)}f(_!==n)}function h(){navigator.clipboard.writeText(i).then(()=>d(!0))}function g(){let _=JSON.parse(i),b=yh(_);e.onSave&&e.onSave(b)}return p("div",{className:"EditJsonModal",children:[p(nd,{value:i,onChange:m,formatOnBlur:!0,autosize:!0,minRows:4,maxRows:25}),p("div",{className:"EditJsonModal__buttons",children:[p(ee,{variant:"default",size:"xs",color:"dark",type:"button",onClick:()=>r.closeModal(o),children:"Cancel"}),p(ee,{leftIcon:p(Sb,{size:16}),variant:"filled",size:"xs",color:"dark",disabled:!s,type:"button",onClick:h,children:c?"Copied!":"Copy"}),p(ee,{variant:"default",size:"xs",type:"button",leftIcon:p(vb,{size:16}),disabled:!u,onClick:()=>{a(n),l(!0),f(!1)},children:"Reset"}),p(ee,{leftIcon:p(Cb,{size:16}),variant:"filled",size:"xs",color:"blue",disabled:!s||!u,onClick:g,children:"Save"})]})]})}IC.id=l2;we();function tt(t){let{className:e,as:r,size:o,weight:n,color:i,children:a,...s}=t;return p(r||"h2",{...s,className:Ne(e,"heading",o&&`size:${o}`,n&&`weight:${n}`,i&&`color:${i}`),children:a})}var c2="EditTranslationsModal";function Ire(){let t=Ct(),e=Vt();return{open:r=>{t.openContextModal(c2,{...e,innerProps:r,size:"900px",title:"Edit translations",overflow:"inside",className:"EditTranslationsModalWrap"})},close:()=>{t.closeModal(c2)}}}function Ah(t){let{innerProps:e,context:r,id:o}=t,n=e.strings||[],a=(window.__ROOT_CTX.rootConfig.i18n||{}).locales||["en"],[s,l]=M({}),[c,d]=M([]),[u,f]=M(!1),[m,h]=M(!1),[g,_]=M(!0);V(()=>{Td({tags:[e.docId]}).then(v=>{let S={};Object.values(v).forEach(N=>{S[N.source]=N}),l(S),_(!1)})},[e.docId]);async function b(){h(!0),await or(async()=>{console.log("EditTranslationsModal.onSave()");let v=`edit-translations-${e.docId}`;Re({id:v,loading:!0,title:"Saving translations",message:`Updating for ${e.docId}...`,autoClose:!1,disallowClose:!0});let S=[];c.forEach(N=>{let w=s[N];S.push(w)}),await Df(e.docId,S),jt({id:v,title:"Saved translations",message:`Updated translations for ${e.docId}!`,autoClose:!1})}),h(!1)}function y(v){l(S=>{let N={...S};return N[v.source]=v,N}),d(S=>{let N=new Set(S);return N.add(v.source),Array.from(N)}),f(!0)}return p("div",{className:"EditTranslationsModal",children:[p("div",{className:"EditTranslationsModal__header",children:p(ee,{component:"a",href:`/cms/translations/${e.docId}`,target:"_blank",variant:"default",size:"xs",children:"Open Translations Editor"})}),g?p(et,{}):p("table",{className:"EditTranslationsModal__table",children:[p("thead",{children:p("tr",{children:[p("th",{children:p(tt,{size:"h4",weight:"semi-bold",children:"SOURCE"})}),p("th",{children:p(tt,{size:"h4",weight:"semi-bold",children:"TRANSLATIONS"})})]})}),p("tbody",{children:n.map(v=>p("tr",{children:[p("td",{children:p("div",{className:"EditTranslationsModal__table__source",children:v})}),p("td",{children:p(Ah.StringsEditor,{source:v,locales:a,translations:s[v]||{},onChange:y})})]}))})]}),p("div",{className:"EditTranslationsModal__footer",children:[e.l10nSheet&&p("div",{className:"EditTranslationsModal__footer__gsheet",children:[p("strong",{children:"NOTE:"})," Translations for this doc are managed in"," ",p("a",{href:ja(e.l10nSheet),target:"_blank",rel:"noopener noreferrer",children:"Google Sheets"})]}),p("div",{className:"EditTranslationsModal__footer__buttons",children:[p(ee,{variant:"default",size:"xs",color:"dark",type:"button",onClick:()=>r.closeModal(o),children:"Cancel"}),p(ee,{variant:"filled",size:"xs",color:"dark",onClick:()=>b(),disabled:!u,loading:m,children:"Save"})]})]})]})}Ah.StringsEditor=t=>{let e=t.locales,[r,o]=M(t.translations||{}),[n,i]=M(!1);function a(s,l){i(!0),o(c=>{let d={...c,source:t.source};return d[s]=l,d})}return V(()=>{n&&t.onChange(r)},[n,r]),p("div",{className:"EditTranslationsModal__StringsEditor",children:e.map(s=>p("div",{className:"EditTranslationsModal__StringsEditor__row",children:[p("div",{className:"EditTranslationsModal__StringsEditor__row__locale",children:s}),p("div",{className:Ne("EditTranslationsModal__StringsEditor__row__translation",r[s]?"hasValue":"empty"),children:p(hr,{size:"xs",radius:0,autosize:!0,minRows:1,maxRows:10,value:r[s],onChange:l=>{a(s,l.currentTarget.value)}})})]}))})};Ah.id=c2;Ws();we();we();var p2=["https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/spreadsheets"],N4e=["https://www.googleapis.com/discovery/v1/apis/drive/v3/rest","https://sheets.googleapis.com/$discovery/rest?version=v4"];function Fd(){let t=window.__ROOT_CTX.rootConfig.projectId,e=!!(window.__ROOT_CTX.gapi?.apiKey&&window.__ROOT_CTX.gapi?.clientId),[r,o]=M(e),[n,i]=M(0),[a,s]=XN({key:`root-cms::${t}::gapi-user-consent`,defaultValue:{}});async function l(){await Promise.all([O4e(),D4e()]),o(!1)}V(()=>{e&&l()},[]);function c(){return new Promise(u=>{let f=window.__ROOT_CTX.gapi.clientId,m=google.accounts.oauth2.initTokenClient({client_id:f,scope:p2.join(" "),callback:async h=>{let g=d2()+parseInt(h.expires_in);i(g),s({at:d2(),clientId:f,scopes:p2}),u()}});a&&P4e(a)?(console.log("requesting token without prompt"),m.requestAccessToken({prompt:""})):(console.log("requesting token with prompt"),m.requestAccessToken({prompt:"consent"}))})}function d(){return d2()<n}return{enabled:e,loading:r,isLoggedIn:d,login:c}}function P4e(t){if(!t||!t.at)return!1;let e=window.__ROOT_CTX.gapi?.clientId;if(t.clientId!==e)return!1;let r=t.scopes||[];return p2.every(o=>r.includes(o))}function d2(){return Math.floor(new Date().getTime()/1e3)}var u2=null;async function O4e(){return u2||(u2=new Promise((t,e)=>{let r=document.createElement("script");r.src="https://apis.google.com/js/api.js",r.onload=()=>{gapi.load("client",async()=>{try{await gapi.client.init({}),await Promise.all(N4e.map(o=>gapi.client.load(o))),console.log("gapi loaded"),t()}catch(o){console.error("Error initializing gapi:",o),e(o)}})},r.onerror=()=>{console.error("gapi script failed to load"),e(new Error("gapi script failed to load"))},document.head.appendChild(r)})),u2}var f2=null;async function D4e(){return f2||(f2=new Promise((t,e)=>{let r=document.createElement("script");r.src="https://accounts.google.com/gsi/client",r.onload=()=>{t()},r.onerror=()=>{console.error("gis script failed to load"),e(new Error("gis script failed to load"))},document.head.appendChild(r)})),f2}Zr();we();var wre=[{name:"Google Drive Folder",key:"googleDriveFolder",placeholder:"https://drive.google.com/drive/folders/...",description:`Where Google Sheets created by Root CMS's localization process are stored. If unspecified, they will be created in your "My Drive".`,ui:t=>p(ee,{disabled:!t,variant:"outline",size:"compact-sm",color:"dark",rightIcon:p(Tb,{size:16}),onClick:()=>{t&&window.open(t,ure(t))},children:"Open"})}],Ere=at(null);function Sre(t){let{db:e,user:r}=Ph(),o=window.__ROOT_CTX.rootConfig.projectId,[n,i]=M({});V(()=>{let s=ze(e,"Projects",o),l=Id(s,c=>{if(c.exists()){let d=c.data()||{};i(d.settings||{})}else i({})},c=>{console.error("Failed to subscribe to site settings:",c)});return()=>l()},[e,o,r.uid]);let a=qe(async(s,l)=>{let c=ze(e,"Projects",o);try{await Lr(c,new On("settings",s),l)}catch(d){console.error("Failed to set setting",s,d)}},[e,o,r.uid]);return p(Ere.Provider,{value:{settings:n,setSettings:a},children:t.children})}function wC(){let t=Ze(Ere);if(!t)throw new Error("useSiteSettings must be used within a <SiteSettingsProvider>");return t}var Cre="ExportSheetModal";function Tre(){let t=Ct(),e=Vt();return{open:r=>{t.openContextModal(Cre,{...e,title:"Export to Google Sheet",innerProps:r,size:"650px"})}}}function Rh(t){let{innerProps:e,context:r,id:o}=t,[n,i]=M(!1),[a,s]=M("new-sheet"),[l,c]=M(""),[d,u]=M(!1),f=Fd(),m=wC(),h=G(),g=o2(m.settings.googleDriveFolder),_=[{value:"new-sheet",label:"Create Google Sheet",help:"Creates a new Google Sheet and exports strings to the sheet."},{value:"add-tab",label:"Add tab in Google Sheet",help:"Adds a new tab in an existing Google Sheet and exports strings to the sheet."},{value:"link-sheet",label:"Link Google Sheet",help:"Links an existing Google Sheet without exporting strings."}],b=!1;(a==="add-tab"||a==="link-sheet")&&(b=!0,l&&Rd(l)?.spreadsheetId&&(b=!1));async function y(E,I){let C=I?.isNew||!1,{headers:T,rows:O}=e.csvData;C?(await E.replaceSheet(T,O),await E.applyL10nTheme()):await E.updateValuesMap(O,{keyedBy:"source",preserveColumns:e.locales})}async function v(){f.isLoggedIn()||await f.login();let E=window.__ROOT_CTX.rootConfig,I=E.projectName||E.projectId||"Root CMS",C,T,O="create-google-sheet";try{if(Re({id:O,loading:!0,title:"Creating Google Sheet...",message:"Creating Google Sheet for localization.",autoClose:!1,disallowClose:!0}),C=await ml.create({title:`${I} Localization`,parent:g,share:h.current?.checked}),T=await C.getSheet(0),!T)throw new Error("could not find sheet gid=0");T.setTitle(e.docId)}catch(A){console.error(A);let P=A;typeof A=="object"&&A.body&&(P=String(A.body)),jt({id:O,title:"Failed to create Google Sheet",message:String(P),color:"red",autoClose:!1});return}try{jt({id:O,loading:!0,title:"Created Google Sheet!",message:`Linking sheet to ${e.docId}...`,autoClose:!1,disallowClose:!0});let A={spreadsheetId:C.spreadsheetId,gid:0};await RS(e.docId,A)}catch(A){console.error(A),jt({id:O,title:"Failed to link Google Sheet",message:String(A),color:"red",autoClose:!1});return}try{jt({id:O,loading:!0,title:"Linked Google Sheet!",message:"Exporting strings to sheet...",autoClose:!1,disallowClose:!0}),await y(T,{isNew:!0})}catch(A){console.error(A);let P=A;typeof A=="object"&&A.body&&(P=String(A.body)),jt({id:O,title:"Failed to export strings to Google Sheet",message:P,color:"red",autoClose:!1});return}c(T.getUrl()),u(!0),jt({id:O,title:"Done! Exported strings to Google Sheet.",message:C.getUrl(),autoClose:!1})}async function S(){f.isLoggedIn()||await f.login();let E=Rd(l);if(!E?.spreadsheetId)throw new Error("failed to parse spreadsheet id");let I=new ml(E.spreadsheetId),C,T="add-tab-google-sheet";try{Re({id:T,loading:!0,title:"Creating tab in Google Sheet...",message:"Adding tab in existing Google Sheet",autoClose:!1,disallowClose:!0}),C=await I.createSheet({title:e.docId})}catch(O){console.error(O);let A=O;typeof O=="object"&&O.body&&(A=String(O.body)),jt({id:T,title:"Failed to create Google Sheet",message:String(A),color:"red",autoClose:!1});return}try{jt({id:T,loading:!0,title:"Created Google Sheet!",message:`Linking sheet to ${e.docId}...`,autoClose:!1,disallowClose:!0});let O={spreadsheetId:I.spreadsheetId,gid:C.gid};await RS(e.docId,O)}catch(O){console.error(O),jt({id:T,title:"Failed to link Google Sheet",message:String(O),color:"red",autoClose:!1});return}try{jt({id:T,loading:!0,title:"Linked Google Sheet!",message:"Exporting strings to sheet...",autoClose:!1,disallowClose:!0}),await y(C,{isNew:!0})}catch(O){console.error(O);let A=O;typeof O=="object"&&O.body&&(A=String(O.body)),jt({id:T,title:"Failed to export strings to Google Sheet",message:A,color:"red",autoClose:!1});return}u(!0),jt({id:T,title:"Done! Exported strings to Google Sheet.",message:C.getUrl(),autoClose:!1})}async function N(){let E="link-google-sheet",I=Rd(l);if(!I?.spreadsheetId)throw new Error("failed to parse spreadsheet id");try{Re({id:E,loading:!0,title:"Link Google Sheet",message:`Linking sheet to ${e.docId}...`,autoClose:!1,disallowClose:!0}),await RS(e.docId,I)}catch(C){console.error(C),jt({id:E,title:"Failed to link Google Sheet",message:String(C),color:"red",autoClose:!1});return}u(!0),jt({id:E,title:`Done! Linked ${e.docId} to Google Sheet.`,message:ja(I),autoClose:!1})}async function w(){console.log(a),i(!0),a==="new-sheet"?await or(v):a==="add-tab"?await or(S):a==="link-sheet"&&await or(N),i(!1)}return p("div",{className:"ExportSheetModal",children:p("div",{className:"ExportSheetModal__content",children:[p("div",{className:"ExportSheetModal__content__body",children:"Export strings to Google Sheet or link an existing Google Sheet for managing translations."}),p("form",{className:"ExportSheetModal__form",children:[p("div",{className:"ExportSheetModal__form__section",children:[p("div",{className:"ExportSheetModal__form__description",children:"Export options:"}),p(Sr,{disabled:d||n,itemComponent:Rh.SelectItem,data:_,onChange:E=>{s(E),E==="new-sheet"&&c("")},value:a})]}),p("div",{className:"ExportSheetModal__form__section",children:[p("div",{className:"ExportSheetModal__form__description",children:"Google Sheet URL:"}),a==="new-sheet"?p(tr,{disabled:!0,placeholder:m.settings.googleDriveFolder?"A new Google Sheet will be created in the project's Google Drive folder.":'A new Google Sheet will be created in your "My Drive" folder.'}):p(tr,{placeholder:"https://docs.google.com/spreadsheets/d/...",value:l,disabled:d||n,onChange:E=>c(E.currentTarget.value)})]}),a==="new-sheet"&&p("div",{className:"ExportSheetModal__form__section",children:p(Te,{label:"Whether to share the Google Sheet with Admins and Editors upon creation. If your site has a Google Drive folder configured, the sheet will be created within it and inherit its permissions.",wrapLines:!0,width:320,withArrow:!0,position:"bottom",children:p(td,{disabled:d||n,ref:h,name:"share",value:"true",label:"Share Google Sheet with collaborators",checked:!g})})}),p("div",{className:"ExportSheetModal__form__buttons",children:d?p(Ce,{children:[p(ee,{component:"a",target:"_blank",rel:"noopener noreferrer",href:l,variant:"default",size:"xs",color:"dark",rightIcon:p(Tb,{size:16}),children:"Open Google Sheet"}),p(ee,{variant:"filled",onClick:()=>r.closeModal(o),type:"button",size:"xs",color:"primary",children:"Done"})]}):p(Ce,{children:[p(ee,{variant:"outline",onClick:()=>r.closeModal(o),type:"button",size:"xs",color:"dark",children:"Cancel"}),p(ee,{variant:"filled",size:"xs",color:"primary",loading:n,disabled:b,onClick:()=>w(),children:a==="link-sheet"?"Link Google Sheet":"Export to Google Sheet"})]})})]})]})})}Rh.SelectItem=te(t=>{let{label:e,help:r,...o}=t;return p("div",{className:"ExportSheetModal__SelectItem",...o,children:[p(Je,{className:"ExportSheetModal__SelectItem__label",size:"body",children:e}),p(Je,{className:"ExportSheetModal__SelectItem__help",size:"body-sm",children:r})]})});Rh.id=Cre;we();async function Mh(t){if(!window.__ROOT_CTX.collections[t])throw new Error(`collection not found: ${t}`);let r=await window.fetch("/cms/api/collection.get",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({collectionId:t})});if(r.status!==200){let n=await r.text();throw new Error(n)}return(await r.json()).data}async function EC(t){let e=window.firebase.db,r=window.__ROOT_CTX.rootConfig.projectId,[o,n]=t.split("/",2),i=await Mh(o),a=ze(e,"Projects",r,"Collections",o,"Drafts",n),l=(await No(a)).data()||{},c=new Set;return ry(c,i.fields,l.fields||{},i.types||{}),Array.from(c)}function ry(t,e,r,o={}){e.forEach(n=>{if(!n.id)return;let i=r[n.id];SC(t,n,i,o)})}function SC(t,e,r,o={}){if(!r)return;function n(i){let a=dc(i);a&&t.add(a)}if(e.type==="object")ry(t,e.fields||[],r,o);else if(e.type==="array"){let i=r._array||[];for(let a of i)SC(t,e.of,r[a],o)}else if(e.type==="string"||e.type==="select")e.translate&&n(r);else if(e.type==="image")e.translate&&r&&r.alt&&e.alt!==!1&&n(r.alt);else if(e.type==="multiselect"){if(e.translate&&Array.isArray(r))for(let i of r)n(i)}else if(e.type==="oneof"){let i=e.types||[],a;typeof i[0]=="string"?i.includes(r._type)&&(a=o[r._type]):a=i.find(s=>s.name===r._type),a&&ry(t,a.fields||[],r,o)}else e.type==="richtext"?e.translate&&A4e(t,r):console.log(`extract: ignoring field, id=${e.id}, type=${e.type}`)}function A4e(t,e){(e?.blocks||[]).forEach(o=>{R4e(t,o)})}function R4e(t,e){if(!e?.type)return;function r(a){if(!a)return;let s=dc(a);s&&t.add(s)}function o(a){a&&Object.values(a).forEach(s=>{n(s)})}function n(a){if(typeof a=="string"){r(a);return}if(Array.isArray(a)){a.forEach(s=>n(s));return}Ai(a)&&Object.values(a).forEach(s=>n(s))}function i(a){a&&a.forEach(s=>{r(s.content),o(s.components),i(s.items)})}e.type==="heading"||e.type==="paragraph"?(r(e.data?.text),o(e.data?.components)):e.type==="orderedList"||e.type==="unorderedList"?i(e.data?.items):e.type==="html"&&r(e.data?.html)}var kre="LocalizationModal";function Nre(){let t=Ct(),e=Vt();return{open:r=>{t.openContextModal(kre,{...e,innerProps:r,size:"clamp(80%, 1024px, 1280px)",onClose:()=>{r.draft.flush()}})}}}function sa(t){let e=t.innerProps;return p("div",{className:"LocalizationModal",children:p("div",{className:"LocalizationModal__layout",children:[p(sa.ConfigLocales,{...e}),p(sa.Translations,{...e})]})})}sa.id=kre;sa.ConfigLocales=t=>{let[e,r]=M(()=>t.draft?t.draft.getLocales():["en"]),o=window.__ROOT_CTX.rootConfig.i18n||{},n=o.locales||["en"],i=o.groups||{default:{label:"",locales:n}};function a(c){return e.filter(d=>(i[c].locales||[]).includes(d))}function s(c,d){let u=new Set(e),f=i[c].locales||[];for(let h of f)d.includes(h)?u.add(h):u.delete(h);let m=Array.from(u.values()).sort();l(m)}function l(c){r(c),t.draft.setLocales(c)}return p("div",{className:"LocalizationModal__locales",children:p(Fa,{spacing:30,children:[p(di,{children:[p(tt,{className:"LocalizationModal__iconTitle LocalizationModal__locales__title",size:"h2",children:[p(FM,{strokeWidth:1.5}),p("span",{children:"Locales"})]}),p(sa.AllNoneButtons,{onAllClicked:()=>l(n),onNoneClicked:()=>l([])})]}),p(Fa,{spacing:40,children:Object.keys(i).map(c=>{let d=i[c],u=a(c);return p(sa.LocaleGroup,{group:d,groupEnabledLocales:u,allEnabledLocales:e,onChange:f=>s(c,f)})})})]})})};sa.LocaleGroup=t=>{let e=t.groupEnabledLocales||[],r=t.group.locales||[],o=t.allEnabledLocales||[];function n(a){t.onChange&&t.onChange(a)}function i(a){let s=e.indexOf(a);s===-1?e.push(a):e.splice(s,1),n(e)}return p(Fa,{spacing:16,children:[t.group.label&&p(di,{position:"apart",children:[p(tt,{size:"h4",weight:"semi-bold",children:t.group.label}),p(sa.AllNoneButtons,{onAllClicked:()=>n(r),onNoneClicked:()=>n([])})]}),p(di,{children:r.map(a=>{let s=e.includes(a),l=o.length<=1&&s;return p(td,{value:a,checked:s,disabled:l,label:Pre(a),onChange:()=>i(a),size:"xs"})})})]})};sa.AllNoneButtons=t=>p(di,{spacing:"8px",children:[p(ee,{variant:"subtle",size:"xs",compact:!0,onClick:t.onAllClicked,sx:e=>({"&:hover":{backgroundColor:e.colors.gray[0]}}),children:"All"}),"/",p(ee,{variant:"subtle",size:"xs",compact:!0,onClick:t.onNoneClicked,sx:e=>({"&:hover":{backgroundColor:e.colors.gray[0]}}),children:"None"})]});sa.Translations=t=>{let[e,r]=M(!0),[o,n]=M([]),i=window.__ROOT_CTX.rootConfig.i18n?.locales||[],a=i.find(P=>P!=="en")||"en",[s,l]=M(a),[c,d]=M({}),[u,f]=M({}),m=Fd(),[h,g]=M(null),_=Tre(),b=pe(()=>{let P={};return Object.values(u).forEach(B=>{P[B.source]=B}),P},[u]),y=i.map(P=>({value:P,label:Pre(P)}));V(()=>{r(!0),Promise.all([EC(t.docId),Td(),MS(t.docId)]).then(([P,B,$])=>{n(P),f(B),g($),r(!1)})},[t.docId]),V(()=>{if(!s){d({});return}let P={};Object.values(u).forEach(B=>{P[B.source]=B[s]||""}),d(P)},[s,u]);function v(P,B){let $=b[P];return $&&$[B]||""}function S(){let P=i.filter(z=>z!=="en"),B=["source","en",...P],$=[];return o.forEach(z=>{let H={source:z,en:v(z,"en")||z};P.forEach(q=>{H[q]=v(z,q)}),$.push(H)}),{headers:B,rows:$}}async function N(){let{headers:P,rows:B}=S(),$=await window.fetch("/cms/api/csv.download",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({headers:P,rows:B})});if($.status!==200){console.error("csv.download failed:");let q=await $.text();console.error(q)}let z=await $.blob(),H=window.URL.createObjectURL(z);window.location.assign(H),window.URL.revokeObjectURL(H)}async function w(){let P=document.createElement("input");P.type="file",P.accept=".csv",P.addEventListener("change",async()=>{let B=P.files?.[0];if(B){let $=new FormData;$.append("file",B);try{let z=await fetch("/cms/api/csv.import",{method:"POST",body:$});if(z.status!==200){let Y=await z.text();throw new Error(`RPCError: ${Y}`)}let H=(await z.json()).data,q=await Df(t.docId,H);f(Y=>Object.assign({},Y,q)),Re({title:"Saved!",message:`Imported translations for ${t.docId}.`,autoClose:5e3})}catch(z){console.error(z),Re({title:"Failed to import CSV",message:String(z),color:"red",autoClose:!1})}}}),P.click()}async function E(){if(m.isLoggedIn()||await m.login(),!h?.spreadsheetId)throw new Error("no sheet linked");let B=await new ml(h.spreadsheetId).getSheet(h.gid??0);if(!B)throw new Error(`sheet not found: ${JSON.stringify(h)}`);await I(B),Re({title:"Exported strings to Google Sheet",message:B.getUrl(),autoClose:!1})}async function I(P,B){let $=B?.isNew||!1,{headers:z,rows:H}=S();$?(await P.replaceSheet(z,H),await P.applyL10nTheme()):await P.updateValuesMap(H,{keyedBy:"source",preserveColumns:i}),Ot("doc.export_to_sheet",{metadata:{docId:t.docId,sheetId:{spreadsheetId:P.spreadsheet.spreadsheetId,gid:P.gid}}})}async function C(){if(m.isLoggedIn()||await m.login(),!h?.spreadsheetId)throw new Error("no sheet linked");let B=await new ml(h.spreadsheetId).getSheet(h.gid??0);if(!B)throw new Error(`sheet not found: ${JSON.stringify(h)}`);console.log("importing google sheet");let $=await B.getValuesMap(),z=await Df(t.docId,$);f(H=>Object.assign({},H,z)),Re({title:"Saved!",message:`Imported translations for ${t.docId}.`,autoClose:5e3})}async function T(){await jQ(t.docId),g(null),Re({title:"Unlinked Google Sheet",message:`${t.docId} is no longer connected to a Google Sheet.`,autoClose:5e3})}async function O(P){try{await P()}catch(B){console.error(B);let $;typeof B=="object"&&B.body?$=String(B.body):$=String(B),Re({title:"Error",message:$,color:"red",autoClose:!1})}}function A(P){switch(P){case"EXPORT_DOWNLOAD_CSV":{O(N);return}case"EXPORT_GOOGLE_SHEET_LINKED":{O(E);return}case"EXPORT_GOOGLE_SHEET_SHOW_OPTIONS":{_.open({docId:t.docId,csvData:S(),locales:i});return}case"IMPORT_CSV":{O(w);return}case"IMPORT_GOOGLE_SHEET_LINKED":{O(C);return}case"UNLINK_GOOGLE_SHEET":{O(T);return}default:console.log("unhandled action: "+P)}}return e?p("div",{className:"LocalizationModal__translations__loading",children:p(et,{color:"gray",size:"xl"})}):p("div",{className:"LocalizationModal__translations",children:[p("div",{className:"LocalizationModal__translations__header",children:[p("div",{className:"LocalizationModal__translations__titleWrap",children:[p(tt,{className:"LocalizationModal__translations__title LocalizationModal__iconTitle",size:"h2",children:[p(Cd,{strokeWidth:1.5})," ",p("span",{children:"Translations"})]}),p(ee,{component:"a",href:`/cms/translations/${t.docId}`,target:"_blank",variant:"default",size:"xs",children:"Open Translations Editor"})]}),p("div",{className:"LocalizationModal__translations__header__buttons",children:[m.enabled&&h?.spreadsheetId&&p(Te,{label:"Open Google Sheet",children:p(Xe,{component:"a",href:ja(h),target:"_blank",variant:"filled",color:"green",size:"sm",children:p(Pf,{size:16,strokeWidth:2.25})})}),p(M4e,{onAction:A,gapiClient:m,linkedSheet:h}),p(L4e,{onAction:A,gapiClient:m,linkedSheet:h})]})]}),p("table",{className:"LocalizationModal__translations__table",children:[p("tr",{className:"LocalizationModal__translations__table__row LocalizationModal__translations__table__row--header",children:[p("th",{className:"LocalizationModal__translations__table__header",children:p(tt,{size:"h4",weight:"semi-bold",children:"SOURCE STRING"})}),p("th",{className:"LocalizationModal__translations__table__header",children:p(tt,{className:"LocalizationModal__translations__localeSelect",size:"h4",weight:"semi-bold",children:[p("span",{children:"LOCALE: "})," ",p(Sr,{data:y,size:"xs",placeholder:"select locale",allowDeselect:!0,value:s,onChange:P=>l(P)})]})})]}),o.map((P,B)=>p("tr",{className:"LocalizationModal__translations__table__row",children:[p("td",{className:"LocalizationModal__translations__table__col",children:p(xe,{sx:$=>({backgroundColor:$.colors.gray[0],border:`1px solid ${$.colors.gray[3]}`,padding:"10px 20px",borderRadius:4,height:"100%"}),children:p(Ir,{size:"xs",sx:{whiteSpace:"pre-wrap"},children:P})})}),p("td",{className:"LocalizationModal__translations__table__col",children:p(xe,{sx:$=>({backgroundColor:$.colors.gray[0],border:`1px solid ${$.colors.gray[3]}`,padding:"10px 20px",borderRadius:4,height:"100%"}),children:p(Ir,{size:"xs",sx:{whiteSpace:"pre-wrap"},children:c[P]||" "})})})]},B))]})]})};function M4e(t){function e(o){t.onAction&&t.onAction(o)}let r=t.linkedSheet;return p(Be,{className:"LocalizationModal__translations__menu",position:"bottom",placement:"end",control:p(ee,{variant:"default",color:"dark",size:"xs",leftIcon:p(cl,{size:16,strokeWidth:1.75}),rightIcon:p(lc,{size:16,strokeWidth:1.75}),children:"Import"}),children:[t.gapiClient.enabled&&p(Ce,{children:[p(Be.Label,{children:"Google Sheets"}),p(Be.Item,{className:"LocalizationModal__translations__menu__item",disabled:!r?.spreadsheetId,onClick:()=>e("IMPORT_GOOGLE_SHEET_LINKED"),children:"Import Google Sheet"}),p(Oa,{})]}),p(Be.Label,{children:"File"}),p(Be.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("IMPORT_CSV"),children:"Import .csv"})]})}function L4e(t){async function e(n){t.onAction&&t.onAction(n)}let o=!!t.linkedSheet?.spreadsheetId;return p(Be,{className:"LocalizationModal__translations__menu",position:"bottom",placement:"start",control:p(ee,{variant:"default",color:"dark",size:"xs",leftIcon:p(Sf,{size:16,strokeWidth:1.75}),rightIcon:p(lc,{size:16,strokeWidth:1.75}),children:"Export"}),children:[t.gapiClient.enabled&&p(Ce,{children:[p(Be.Label,{children:"Google Sheets"}),o?p(Ce,{children:p(Be.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("EXPORT_GOOGLE_SHEET_LINKED"),children:"Export to Google Sheet"})}):p(Ce,{children:p(Be.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("EXPORT_GOOGLE_SHEET_SHOW_OPTIONS"),children:"Export to Google Sheet"})}),p(Oa,{})]}),p(Be.Label,{children:"File"}),p(Be.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("EXPORT_DOWNLOAD_CSV"),children:"Download .csv"}),o&&p(Ce,{children:[p(Oa,{}),p(Be.Label,{children:"Danger zone"}),p(Be.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("UNLINK_GOOGLE_SHEET"),color:"red",children:"Unlink Google Sheet"})]})]})}function Pre(t){let e=t.split("_"),r=e[0];if(r==="ALL"){let i=String(e[1]).toUpperCase();return`${new Intl.DisplayNames(["en"],{type:"region"}).of(i)||t} (${t})`}return`${new Intl.DisplayNames(["en"],{type:"language"}).of(r)||t} (${t})`}we();var Ore="LockPublishingModal";function Dre(t){let e=Ct(),r=Vt();return{open:o=>{let i={...t,...o}.unlock?`Unlock publishing for ${t.docId}`:`Lock publishing for ${t.docId}`;e.openContextModal(Ore,{...r,title:i,innerProps:{...t,...o},size:"600px"})}}}function Bd(t){let{innerProps:e}=t;return e.unlock?p(Bd.Unlock,{...t}):p(Bd.Lock,{...t})}Bd.Lock=t=>{let{innerProps:e,context:r,id:o}=t,[n,i]=M(""),[a,s]=M(0),[l,c]=M(!1),d=Ct();function u(m){return m?Math.floor(new Date(m).getTime()):0}async function f(m){m.preventDefault(),c(!0),await or(async()=>{await $Q(e.docId,{reason:n,until:a}),Re({title:"Locked!",message:`Publishing is locked for ${e.docId}.`,autoClose:1e4}),d.closeModal(o),e.onChange&&e.onChange("locked")})}return p("div",{className:"LockPublishingModal LockPublishingModal--lock",children:[p(Je,{className:"LockPublishingModal__body",children:"Are you sure you want to lock publishing? Content editors will not be able to publish until publishing is unlocked."}),p("form",{className:"LockPublishingModal__form",onSubmit:m=>f(m),children:[p("div",{className:"LockPublishingModal__form__section",children:p(tr,{name:"reason",label:"Reason",description:"Specify a short reason so other content editors know why publishing is locked.",size:"xs",radius:0,onChange:m=>{i(m.currentTarget.value)}})}),p("div",{className:"LockPublishingModal__form__section",children:p(Nn,{label:"Lock until",description:"Optional. Publishing is unlocked at the specified time. If not provided, publishing will be locked indefinitely.",size:"xs",children:p("div",{className:"DocEditor__DateTimeField",children:[p("input",{name:"until",type:"datetime-local",min:bh(),onChange:m=>{let g=m.target.value;s(u(g))}}),p("div",{className:"DocEditor__DateTimeField__timezone",children:["timezone: ",Intl.DateTimeFormat().resolvedOptions().timeZone]})]})})}),p("div",{className:"LockPublishingModal__buttons",children:[p(ee,{variant:"outline",onClick:()=>r.closeModal(o),type:"button",size:"xs",color:"dark",children:"Cancel"}),p(ee,{variant:"filled",size:"xs",color:"dark",leftIcon:p(Tf,{size:14}),disabled:!n,type:"submit",loading:l,children:"Lock"})]})]})]})};Bd.Unlock=t=>{let{innerProps:e,context:r,id:o}=t,[n,i]=M(!1),a=Ct();async function s(){i(!0),await or(async()=>{await zQ(e.docId),Re({title:"Unlocked!",message:`Publishing is unlocked for ${e.docId}.`,autoClose:1e4}),a.closeModal(o),e.onChange&&e.onChange("unlocked")})}return p("div",{className:"LockPublishingModal LockPublishingModal--unlock",children:[p(Je,{className:"LockPublishingModal__body",children:["Are you sure you want to unlock publishing for ",e.docId,"? This will re-enable content editors to publish the doc."]}),p("div",{className:"LockPublishingModal__buttons",children:[p(ee,{variant:"outline",onClick:()=>r.closeModal(o),type:"button",size:"xs",color:"dark",children:"Cancel"}),p(ee,{variant:"filled",size:"xs",color:"dark",leftIcon:p(Db,{size:14}),loading:n,onClick:()=>s(),children:"Unlock"})]})]})};Bd.id=Ore;we();var _2=t=>{if(typeof t>"u"||t===null||typeof t=="bigint"||Number.isNaN(t)||t===1/0||t===-1/0)return;if(["string","number","boolean"].includes(typeof t))return t;if(Array.isArray(t))return t.map(_2).filter(r=>typeof r<"u");let e={};for(let[r,o]of Object.entries(t)){let n=_2(o);typeof n<"u"&&(e[r]=n)}return e},Are=_2,F4e=(t,e,r=!1)=>{if(!Array.isArray(t)||!Array.isArray(e))throw new Error("Both arguments should be arrays.");let o=t.length,n=e.length,i=o+n,a=new Array(i);if(r){for(let s=0;s<n;s++)a[s]=e[n-s-1];for(let s=0;s<o;s++)a[s+n]=t[s];return a}for(let s=0;s<o;s++)a[s]=t[s];for(let s=0;s<n;s++)a[s+o]=e[s];return a},Nr=F4e,x2=(t,e=new Map)=>{if(typeof t!="object"||t===null)return!1;if(e.has(t))return!0;if(e.set(t,!0),Array.isArray(t)){for(let r=0;r<t.length;r++)if(x2(t[r],e))return!0;return!1}for(let r in t)if(x2(t[r],e))return!0;return!1},B4e=x2,b2=(t,e,r,o=1/0,n)=>{if(!t||typeof t!="object"){let a;if(!Number.isNaN(t)&&t!==1/0&&t!==-1/0&&typeof t!="bigint"&&(a=JSON.stringify(t,e,r)),a===void 0)switch(n){case iy.throw:throw new Error(`Value is not valid in JSON, got ${String(t)}`);case iy.stringify:return $4e(t);default:throw new Error("Should not reach here, please report this bug.")}return a}let i=o<1?'"..."':Array.isArray(t)?`[${t.map(a=>b2(a,e,r,o-1,n)).join(",")}]`:`{${Object.keys(t).map(a=>`"${a}": ${b2(t[a],e,r,o-1,n)}`).join(", ")}}`;return JSON.stringify(JSON.parse(i),e,r)},$4e=t=>t===void 0?"undefined":t===1/0?"Infinity":t===-1/0?"-Infinity":Number.isNaN(t)?"NaN":typeof t=="bigint"?`${t}n`:String(t),en=b2,z4e=(t,e=1/0,r=!1,o=iy.stringify)=>t===null?"null":Array.isArray(t)||typeof t=="object"?en(t,void 0,r?1:void 0,e,o):en(t,void 0,void 0,void 0,o),qa=z4e,Rre=t=>typeof t=="boolean"?0:typeof t=="number"?1:typeof t=="string"?2:t===null?3:Array.isArray(t)?4:typeof t=="object"?5:typeof t=="symbol"?6:typeof t=="function"?7:typeof t=="bigint"?8:-1,U4e=(t,e,r)=>{let o=r.keyOrdersMap?.get(t),n=r.keyOrdersMap?.get(e);if(o!==void 0&&n!==void 0)return o-n;let i=Rre(t),a=Rre(e);if(i!==a)return i-a;if(t===null&&e===null||Array.isArray(t)&&Array.isArray(e)||i===5&&a===5)return 0;switch(typeof t){case"number":return Number.isNaN(t)&&Number.isNaN(e)||t===1/0&&e===1/0||t===-1/0&&e===-1/0?0:t-e;case"string":return r.ignoreCase&&(t=t.toLowerCase(),e=e.toLowerCase()),t<e?-1:t>e?1:0;case"boolean":return+t-+e;case"symbol":case"function":return String(t).localeCompare(String(e))}if(typeof t=="bigint"&&typeof e=="bigint"){let s=BigInt(t)-BigInt(e);return s<0?-1:s>0?1:0}return String(t).localeCompare(String(e))},ay=U4e,V4e=t=>Array.isArray(t)?"array":t===null?"null":typeof t,bs=V4e,H4e=(t,e,r,o,n,i,a,s)=>{let l={ignoreCase:s.ignoreCase},c=qa(n,s.maxDepth,!0,s.undefinedBehavior).split(`
68
68
  `),d=qa(i,s.maxDepth,!0,s.undefinedBehavior).split(`
@@ -242,7 +242,7 @@ ${Ve.current.stack}
242
242
  `)})(t,n);return set(e,o)(i,r)}function xet(t=Fk,e,r=!1){return(function(n,i=!1){let a=W3(n),s=[...a.multilineElement,...a.element],l=!i,c=a.textFormat.filter((d=>d.format.length===1)).sort(((d,u)=>Number(d.format.includes("code"))-Number(u.format.includes("code"))));return d=>{let u=[],f=(d||zr()).getChildren();for(let m=0;m<f.length;m++){let h=f[m],g=iet(h,s,c,a.textMatch);g!=null&&u.push(l&&m>0&&!q3(h)&&!q3(f[m-1])?`
243
243
  `.concat(g):g)}return u.join(`
244
244
  `)}})(t,r)(e)}var Vr=Y3,jYt=Vr.$convertFromMarkdownString,qYt=Vr.$convertToMarkdownString,GYt=Vr.BOLD_ITALIC_STAR,WYt=Vr.BOLD_ITALIC_UNDERSCORE,KYt=Vr.BOLD_STAR,YYt=Vr.BOLD_UNDERSCORE,XYt=Vr.CHECK_LIST,JYt=Vr.CODE,QYt=Vr.ELEMENT_TRANSFORMERS,xhe=Vr.HEADING,ZYt=Vr.HIGHLIGHT,eXt=Vr.INLINE_CODE,tXt=Vr.ITALIC_STAR,rXt=Vr.ITALIC_UNDERSCORE,oXt=Vr.LINK,nXt=Vr.MULTILINE_ELEMENT_TRANSFORMERS,bhe=Vr.ORDERED_LIST,iXt=Vr.QUOTE,aXt=Vr.STRIKETHROUGH,sXt=Vr.TEXT_FORMAT_TRANSFORMERS,lXt=Vr.TEXT_MATCH_TRANSFORMERS,yhe=Vr.TRANSFORMERS,vhe=Vr.UNORDERED_LIST,Ihe=Vr.registerMarkdownShortcuts;var J3={};ar(J3,{$createHorizontalRuleNode:()=>X3,$isHorizontalRuleNode:()=>Iet,HorizontalRuleNode:()=>zv,INSERT_HORIZONTAL_RULE_COMMAND:()=>bet});X();var bet=ns("INSERT_HORIZONTAL_RULE_COMMAND");function yet({nodeKey:t}){let[e]=Ht(),[r,o,n]=vk(t);return V((()=>fr(e.registerCommand(fu,(i=>{let a=e.getElementByKey(t);return i.target===a&&(i.shiftKey||n(),o(!r),!0)}),Jt))),[n,e,r,t,o]),V((()=>{let i=e.getElementByKey(t),a=e._config.theme.hrSelected??"selected";i!==null&&(r?Jn(i,a):Cp(i,a))}),[e,r,t]),null}var zv=class t extends zg{static getType(){return"horizontalrule"}static clone(e){return new t(e.__key)}static importJSON(e){return X3().updateFromJSON(e)}static importDOM(){return{hr:()=>({conversion:vet,priority:0})}}exportDOM(){return{element:document.createElement("hr")}}createDOM(e){let r=document.createElement("hr");return Jn(r,e.theme.hr),r}getTextContent(){return`
245
- `}isInline(){return!1}updateDOM(){return!1}decorate(){return p(yet,{nodeKey:this.__key})}};function vet(){return{node:X3()}}function X3(){return Xn(new zv)}function Iet(t){return t instanceof zv}var Bk=J3,whe=Bk.$createHorizontalRuleNode,Ehe=Bk.$isHorizontalRuleNode,She=Bk.HorizontalRuleNode,gXt=Bk.INSERT_HORIZONTAL_RULE_COMMAND;var Q3={};ar(Q3,{DEFAULT_TRANSFORMERS:()=>Che,MarkdownShortcutPlugin:()=>wet});X();var Che=[{dependencies:[She],export:t=>Ehe(t)?"***":null,regExp:/^(---|\*\*\*|___)\s?$/,replace:(t,e,r,o)=>{let n=whe();o||t.getNextSibling()!=null?t.replace(n):t.insertBefore(n),n.selectNext()},type:"element"},...yhe];function wet({transformers:t=Che}){let[e]=Ht();return V((()=>Ihe(e,t)),[e,t]),null}var The=Q3,IXt=The.DEFAULT_TRANSFORMERS,khe=The.MarkdownShortcutPlugin;function Nhe(){return p(khe,{transformers:[xhe,vhe,bhe]})}var Z3={};ar(Z3,{OnChangePlugin:()=>Cet});X();var Eet=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?Ft:V;function Cet({ignoreHistoryMergeTagChange:t=!0,ignoreSelectionChange:e=!1,onChange:r}){let[o]=Ht();return Eet((()=>{if(r)return o.registerUpdateListener((({editorState:n,dirtyElements:i,dirtyLeaves:a,prevEditorState:s,tags:l})=>{e&&i.size===0&&a.size===0||t&&l.has(Vg)||s.isEmpty()||r(n,o,l)}))}),[o,t,e,r]),null}var Tet=Z3,Phe=Tet.OnChangePlugin;we();function ket(){return{text:"",components:{}}}var Net=[{tag:"s",format:"strikethrough"},{tag:"u",format:"underline"},{tag:"i",format:"italic"},{tag:"b",format:"bold"},{tag:"sup",format:"superscript"}];function Dhe(t){let e=[];return Net.forEach(({tag:r,format:o})=>{t.hasFormat(o)&&e.push(r)}),e}function e$(t,e){t.text+=e.text,Object.assign(t.components,e.components)}function Pet(t,e,r){for(let o=t.length-1;o>=0;o-=1){let n=t[o];e.includes(n)||(r.text+=`</${n}>`,t.splice(o,1))}e.forEach(o=>{t.includes(o)||(r.text+=`<${o}>`,t.push(o))})}function Ohe(t,e){for(let r=t.length-1;r>=0;r-=1)e.text+=`</${t[r]}>`;t.length=0}function Ahe(t,e){let r=t.getChildren();for(let o of r)if(Ke(o)){let n=Dhe(o);if(n.length!==e.length)return!1;for(let i=0;i<n.length;i+=1)if(n[i]!==e[i])return!1}else{if(Ur(o)||Fv(o))continue;if(o instanceof Ii){if(!Ahe(o,e))return!1}else return!1}return!0}function Oet(t){let e=t.getComponentId(),r=t.getComponentName(),o=Kr(t.getComponentData()),n={[e]:{type:r,data:o}};return{text:`{${r}:${e}}`,components:n}}function Det(t){let e=so(t)&&t.getURL()||"",r=Uv(t);return{text:`<a href="${e}">${r.text}</a>`,components:r.components}}function Uv(t){let e=ket(),r=[];return t.getChildren().forEach(n=>{if(Ur(n)){e.text+="<br>";return}if(Fv(n)){e$(e,Oet(n));return}if(Ke(n)){let i=Dhe(n);Pet(r,i,e);let a=n.getTextContent();a&&(e.text+=Met(a));return}if(so(n)){r.length>0&&!Ahe(n,r)&&Ohe(r,e),e$(e,Det(n));return}if(n instanceof Ii){e$(e,Uv(n));return}console.log("unhandled node"),console.log(n)}),r.length>0&&Ohe(r,e),e}function Rhe(t){let e=[];return t.getChildren().forEach(r=>{Av(r)&&e.push(Aet(r))}),Let(e)}function Aet(t){let e=t.getFirstChild();if(e&&ji(e))return{itemsType:e.getTag()==="ol"?"orderedList":"unorderedList",items:Rhe(e)};let r=Uv(t),o={content:r.text};return $k(r.components)&&(o.components=r.components),o}function Mhe(){let t=[];for(zr().getChildren().forEach(o=>{if(_a(o)){let n=Uv(o),i={type:"paragraph",data:{text:n.text}};$k(n.components)&&(i.data.components=n.components),t.push(i)}else if(_u(o)){let n=o.getTag().slice(1),i=Uv(o),a={type:"heading",data:{text:i.text,level:parseInt(n)}};$k(i.components)&&(a.data.components=i.components),t.push(a)}else if(ji(o)){let n=o.getTag(),i={type:n==="ol"?"orderedList":"unorderedList",data:{style:n==="ol"?"ordered":"unordered",items:Rhe(o)}};t.push(i)}else if(wk(o)){let n={type:o.getBlockName(),data:Kr(o.getBlockData())};t.push(n)}});Ret(t);)t.pop();return t.length===0?null:{time:Date.now(),blocks:t,version:"lexical-0.31.2"}}function Ret(t){let e=t.length>0&&t.at(-1);return!!(e&&e.type==="paragraph"&&!e.data?.text&&!$k(e.data?.components||{}))}function $k(t){return t?Object.keys(t).length>0:!1}function Met(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function Let(t){let e=[];return t.forEach(r=>{r.itemsType&&r.items&&e.length>0?(e.at(-1).itemsType=r.itemsType,e.at(-1).items=r.items):e.push(r)}),e}function Lhe(t){let e=zr();e.clear();let r=t?.blocks||[];for(let o of r)if(o.type==="paragraph"){let n=ur();if(o.data.text){let i=t$(o.data.text,o.data.components);n.append(...i)}e.append(n)}else if(o.type==="heading"){let n=`h${o.data?.level||2}`,i=t_(n);if(o.data.text){let a=t$(o.data.text,o.data.components);i.append(...a)}e.append(i)}else if(o.type==="orderedList"||o.type==="unorderedList"){let n=o.data.style==="ordered"?"number":"bullet",i=Dv(n);for(let a of o.data.items)i.append(...Fhe(a,n));e.append(i)}else if(o.type){let n=Ik(o.type,o.data||{});e.append(n)}}function t$(t,e){let r=document.createElement("template");r.innerHTML=t;let o=r.content,n=[];function i(a){if(a.nodeType===Node.TEXT_NODE)return Fet(a.textContent||"",e);if(a.nodeType===Node.ELEMENT_NODE){let s=a,l=Array.from(s.childNodes).map(i).filter(c=>!!c).flat();switch(s.tagName.toLowerCase()){case"b":case"strong":return l.map(c=>(c instanceof ba&&c.toggleFormat("bold"),c));case"i":case"em":return l.map(c=>(c instanceof ba&&c.toggleFormat("italic"),c));case"u":return l.map(c=>(c instanceof ba&&c.toggleFormat("underline"),c));case"s":return l.map(c=>(c instanceof ba&&c.toggleFormat("strikethrough"),c));case"sup":return l.map(c=>(c instanceof ba&&c.toggleFormat("superscript"),c));case"a":return[Xn(Wg(s.getAttribute("href")||"").append(...l))];default:return console.log("unhandled tag: "+s.tagName),console.log(l),l}}return null}return o.childNodes.forEach(a=>{let s=i(a);Array.isArray(s)?n.push(...s):s&&n.push(s)}),n}function Fet(t,e){let r=[];if(!t)return r;let o=/\{([^:{}]+):([^}]+)\}/g,n=0,i;for(;(i=o.exec(t))!==null;){let s=t.slice(n,i.index);s&&r.push(Mn(s));let l=i[1],c=i[2],d=e?.[c];d?r.push(Ek(l||d.type,c,d.data?Kr(d.data):{})):r.push(Mn(i[0])),n=o.lastIndex}let a=t.slice(n);return a&&r.push(Mn(a)),r}function Fhe(t,e){let r=[];if(t.content){let o=Bet(t,e);r.push(o)}if(t.items&&t.items.length>0){let o=$et(t,e);r.push(o)}return r}function Bet(t,e){let r=Ov();if(t.content){let o=t$(t.content,t.components);r.append(...o)}return r}function $et(t,e){let r=Ov();if(t.items&&t.items.length>0){let o=e;t.itemsType==="orderedList"?o="number":t.itemsType==="unorderedList"&&(o="bullet");let n=Dv(o);for(let i of t.items)n.append(...Fhe(i,o));r.append(n)}return r}function Bhe(t){let[e]=Ht(),r=G(0),o=G(!1);return V(()=>{let i=t.value?.time||0;i>r.current&&(r.current=i,e.update(()=>{o.current=!0,Lhe(t.value)}))},[e,t.value]),p(Phe,{onChange:i=>{if(o.current){o.current=!1;return}i.read(()=>{let a=Mhe();r.current=a?.time||0,t.onChange&&t.onChange(a)})},ignoreSelectionChange:!0})}we();function $he(t){let{editor:e,setIsLinkEditMode:r}=t,{toolbarState:o}=bk();return V(()=>{let n=i=>{if(zi(i,{}))return!1;if(kme(i))s_(e);else if(Nme(i)){let{code:a}=i,s=`h${a[a.length-1]}`;yu(e,o.blockType,s)}else if(Ome(i))Ok(e,o.blockType);else if(Pme(i))Dk(e,o.blockType);else if(Dme(i))e.dispatchCommand(un,"strikethrough");else if(Ame(i))e.dispatchCommand($i,void 0);else if(Rme(i))e.dispatchCommand(os,void 0);else if(Mme(i))e.dispatchCommand(un,"subscript");else if(Lme(i))e.dispatchCommand(un,"superscript");else if(Fme(i))$me(e);else if(Bme(i)){let a=o.isLink?null:"";r(!o.isLink),e.dispatchCommand(Vi,a)}else return!1;return i.preventDefault(),!0};return e.registerCommand(_ue,n,nue)},[e,o.isLink,o.blockType,r]),null}we();function zhe(){let[t]=Ht();return V(()=>t.registerNodeTransform(Iue,e=>{let r=e.getLastChild();_a(r)||e.append(ur())}),[t]),null}var zet={namespace:"RootCMS",theme:Qpe,nodes:[bfe,_k,Yg,kl,gu,n_,i_],onError:t=>{throw console.error("[LexicalEditor] error:",t),t}};function Vhe(t){return p(qfe,{initialConfig:zet,children:p(Kpe,{children:p(Jpe,{children:p("div",{className:Ne(t.className,"LexicalEditor",!t.autosize&&"LexicalEditor--withMaxHeight"),children:p(jet,{placeholder:t.placeholder,value:t.value,onChange:t.onChange,onFocus:t.onFocus,onBlur:t.onBlur,customBlocks:t.customBlocks,inlineComponents:t.inlineComponents})})})})})}var Uet=k3({name:"image",label:"Image Embed",preview:{title:"{file.alt}",image:"{file.src}"},fields:[zpe({id:"file",label:"Image"})]}),Vet=k3({name:"html",label:"HTML Code",preview:{title:"{html}"},fields:[$pe({id:"html",label:"HTML",help:"HTML code to embed. Please use caution when inserting HTML.",variant:"textarea"})]}),Het=[Uet,Vet];function jet(t){let{historyState:e}=Ype(),[r]=Ht(),[o,n]=M(r),[i,a]=M(!1),[s,l]=M(null),c=pe(()=>{let A=new Map;return Het.forEach(P=>{A.set(P.name,P)}),t.customBlocks?.forEach(P=>{A.set(P.name,P)}),A},[t.customBlocks]),d=Array.from(c.values()),[u,f]=M(null),m=pe(()=>{let A=new Map;return t.inlineComponents?.forEach(P=>{A.set(P.name,P)}),A},[t.inlineComponents]),h=Array.from(m.values()),[g,_]=M(null),b=A=>{A&&l(A)},y=(A,P)=>{let B=c.get(A);if(!B)return;let $=P?.initialValue?Kr(P.initialValue):Ud(B);f({schema:B,mode:P?.mode??"create",initialValue:$,nodeKey:P?.nodeKey})},v=(A,P)=>{r.update(()=>{let B=Ik(A,P);_p([B]),B.selectNext()})},S=(A,P)=>{r.update(()=>{let B=ga(A);wk(B)&&B.setBlockData(P)})},N=()=>{f(null)},w=A=>{u&&(u.mode==="edit"&&u.nodeKey?S(u.nodeKey,A):v(u.schema.name,A),N())},E=(A,P)=>{let B=m.get(A);if(!B)return;let $=P?.initialValue?Kr(P.initialValue):Ud(B);_({schema:B,componentName:A,componentId:P?.componentId||pi(),mode:P?.mode??"create",initialValue:$,nodeKey:P?.nodeKey})},I=(A,P,B)=>{r.update(()=>{let $=Ek(A,P,B);_p([$]),$.selectNext()})},C=(A,P,B,$)=>{r.update(()=>{let z=ga(A);Fv(z)&&(z.setComponentName(P),z.setComponentId(B),z.setComponentData($))})},T=()=>{_(null)},O=A=>{if(!g)return;let{componentName:P,mode:B,nodeKey:$}=g;B==="edit"&&$?C($,P,A.componentId,A.data):I(P,A.componentId,A.data),T()};return p(qpe,{components:m,onEditComponent:(A,P)=>E(A,{mode:P?.mode??"edit",initialValue:P?.initialValue,componentId:P?.componentId,nodeKey:P?.nodeKey}),children:p(Vpe,{blocks:c,onEditBlock:y,children:[p(Bhe,{value:t.value,onChange:t.onChange,customBlocks:c}),p(zme,{editor:r,activeEditor:o,setActiveEditor:n,setIsLinkEditMode:a,blockComponents:d,inlineComponents:h,onInsertBlockComponent:A=>y(A,{mode:"create"}),onInsertInlineComponent:A=>E(A,{mode:"create"})}),p($he,{editor:o,setIsLinkEditMode:a}),p(ape,{externalHistoryState:e}),p(Mpe,{contentEditable:p("div",{className:"LexicalEditor__scroller",children:p("div",{className:"LexicalEditor__root",ref:b,children:p(Qfe,{className:"LexicalEditor__editor",placeholder:p(Get,{placeholder:t.placeholder})})})}),ErrorBoundary:epe}),p(lpe,{}),p(cpe,{}),p(Bpe,{maxIndent:7}),p(Nhe,{}),p(zhe,{}),s&&p(Ce,{children:[p(Ume,{anchorElem:s,setIsLinkEditMode:a}),p(lme,{anchorElem:s,isLinkEditMode:i,setIsLinkEditMode:a})]}),u&&p(eme,{schema:u.schema,opened:!0,initialValue:u.initialValue,mode:u.mode,onClose:N,onSubmit:w}),g&&p(ime,{schema:g.schema,opened:!0,componentId:g.componentId,initialValue:g.initialValue,mode:g.mode,onClose:T,onSubmit:O})]})})}var Uhe=["Once upon a placeholder...","Start writing something legendary...","Words go here. Preferably brilliant ones...","Compose like nobody\u2019s watching...","Your masterpiece begins here...","Add text that makes Hemingway jealous...","Here lies your unwritten brilliance..."];function qet(){let t=Math.floor(Math.random()*Uhe.length);return Uhe[t]}function Get(t){let e=pe(()=>t.placeholder||qet(),[]);return p("div",{className:"LexicalEditor__placeholder",children:e})}function Hhe(t){return KC().preferences.EnableLexicalEditor?p(Vhe,{...t}):p(ule,{...t})}function jhe(t){let e=t.field,[r,o]=M(null),n=Kn().controller,i=a=>{o(s=>(s?.time!==a?.time&&n.updateKey(t.deepKey,a),a))};return gl(t.deepKey,a=>{o(a)}),p(Hhe,{value:r,placeholder:e.placeholder,blockComponents:e.blockComponents,inlineComponents:e.inlineComponents,onChange:i,onFocus:t.onFocus,onBlur:t.onBlur,autosize:e.autosize})}we();function qhe(t){let e=t.field,[r,o]=on(t.deepKey,""),n=pe(()=>(e.options||[]).map(i=>typeof i=="string"?{label:i,value:i}:{label:i.label??i.value??"",value:i.value??i.label??""}),[e.options]);return p("div",{className:"DocEditor__SelectField",children:p(Sr,{data:n,placeholder:e.placeholder,value:r,onChange:i=>o(i||""),size:"xs",radius:0,searchable:e.searchable??!0,dropdownComponent:"div"})})}function Ghe(t){let e=t.field,[r,o]=on(t.deepKey,""),n=s=>{o(s.currentTarget.value)},i=s=>{t.onFocus?.(s),Xa(t.deepKey,{scroll:!0})},a=s=>{t.onBlur?.(s),Xa(null)};return e.variant==="textarea"?p(hr,{size:"xs",radius:0,autosize:!1,minRows:4,maxRows:e.maxRows||12,value:r,onChange:n,onFocus:i,onBlur:a}):p(tr,{size:"xs",radius:0,value:r,onChange:n,onFocus:i,onBlur:a})}var Khe=at({});function zk(){return Ze(Khe)}function ir(t){let e=t.docId.split("/")[0],r=XC(e),o=Kn(),n=r.loading||o.loading,i=r.schema?.fields||[];return p(Khe.Provider,{value:r?.schema?.types||{},children:p(yae,{children:p("div",{className:"DocEditor",children:[p(Ma,{visible:n,loaderProps:{color:"gray",size:"xl"}}),!n&&p(ir.StatusBar,{...t,draft:o,collection:r.schema}),p("div",{className:"DocEditor__fields",children:i.map(a=>p(ir.Field,{field:a,deepKey:`fields.${a.id}`},a.id))})]})})})}ir.StatusBar=t=>{let e=t.draft,[r,o]=M(e.controller.getData());gl("sys",l=>{o({sys:l})});let n=qe(l=>{if(l.action==="delete"){let c=t.docId.split("/")[0];_o(`/cms/content/${c}`)}else l.action==="unlocked"&&e.controller.removePublishingLock()},[t.docId]),i=joe({docId:t.docId}),a=Nre(),s=!r?.sys;return s?null:p("div",{className:"DocEditor__statusBar",children:[p("div",{className:"DocEditor__statusBar__viewers",children:p(Dae,{id:`doc/${t.docId}`})}),p(ir.SaveState,{}),r?.sys&&p("div",{className:"DocEditor__statusBar__statusBadges",children:p(Gh,{doc:r})}),p("div",{className:"DocEditor__statusBar__i18n",children:p(ee,{variant:"default",color:"dark",size:"xs",leftIcon:p(zM,{size:16}),onClick:()=>a.open({docId:t.docId,collection:t.collection,draft:e.controller}),children:"Localization"})}),p("div",{className:"DocEditor__statusBar__publishButton",children:s?p(ee,{color:"dark",size:"xs",onClick:()=>i.open(),loading:!0,disabled:!0,children:"Publish"}):AS(r)?p(Te,{label:`Scheduled ${NS(r.sys.scheduledAt)} by ${r.sys.scheduledBy}`,transition:"pop",children:p(ee,{color:"dark",size:"xs",leftIcon:p(_h,{size:16}),disabled:!0,children:"Publish"})}):Of(r)?p(Te,{label:`Locked by ${r.sys.publishingLocked.lockedBy}: "${r.sys.publishingLocked.reason}"`,transition:"pop",children:p(ee,{color:"dark",size:"xs",leftIcon:p(Tf,{size:16}),disabled:!0,children:"Publish"})}):p(ee,{color:"dark",size:"xs",leftIcon:p(_h,{size:16}),onClick:()=>i.open(),children:"Publish"})}),p("div",{className:"DocEditor__statusBar__actionsMenu",children:p(YC,{docId:t.docId,data:r,onAction:n})})]})};ir.SaveState=()=>{let[t,e]=M("NO_CHANGES");return Sae(r=>{e(r)}),p("div",{className:"DocEditor__statusBar__saveState",children:[t==="SAVED"&&"saved!",t==="SAVING"&&"saving...",t==="UPDATE_PENDING"&&"saving...",t==="ERROR"&&"error saving"]})};ir.Field=t=>{let e=t.field,r=t.level??0,n=Py().value===t.deepKey,i=G(null),[a,s]=M(!0),l=zk(),c=pe(()=>e.type==="object"&&(e.variant||"drawer")==="drawer"?!1:!t.hideHeader&&!e.hideLabel,[t.hideHeader,e]);return gl(t.deepKey,d=>{s(og(e,d,l))}),V(()=>{n&&LF(i.current)},[n]),e.deprecated&&a?null:p("div",{className:Ne("DocEditor__field",e.deprecated&&"DocEditor__field--deprecated",n&&"deeplink-target"),"data-type":e.type,"data-level":r,id:t.deepKey,ref:i,children:[c&&p(ir.FieldHeader,{...t}),p("div",{className:"DocEditor__field__input",children:e.type==="array"?p(ir.ArrayField,{...t}):e.type==="boolean"?p(Aae,{...t}):e.type==="date"?p(Rae,{...t}):e.type==="datetime"?p(Mae,{...t}):e.type==="file"?p(gi,{...t}):e.type==="image"?p($ae,{...t}):e.type==="multiselect"?p(zae,{...t}):e.type==="number"?p(Uae,{...t}):e.type==="object"?p(ir.ObjectField,{...t}):e.type==="oneof"?p(ir.OneOfField,{...t}):e.type==="reference"?p(ng,{...t}):e.type==="references"?p(Vae,{...t}):e.type==="richtext"?p(jhe,{...t}):e.type==="select"?p(qhe,{...t}):e.type==="string"?p(Ghe,{...t}):p("div",{className:"DocEditor__field__input__unknown",children:["Unknown field type: ",e.type]})})]})};ir.FieldHeader=t=>{let e=t.field,r=e.label||e.id,[o,n]=M(null),i=Py(),a=pe(()=>vae(t.deepKey||""),[t.deepKey]);return gl(t.deepKey,s=>{n(s)}),p("div",{className:Ne(t.className,"DocEditor__FieldHeader"),children:[e.deprecated?p("div",{className:"DocEditor__FieldHeader__label",children:["DEPRECATED: ",r]}):p("div",{className:"DocEditor__FieldHeader__label",children:[p("span",{children:r}),t.deepKey&&p("a",{className:"DocEditor__FieldHeader__label__deeplink",href:a,title:"Link to field",onClick:s=>{s.preventDefault(),window.history.replaceState({},"",a),i.setValue(t.deepKey)},children:"#"})]}),e.help&&p("div",{className:"DocEditor__FieldHeader__help",children:e.help}),p(ir.FieldHeaderTranslationsActionIcon,{field:e,value:o})]})};ir.FieldHeaderTranslationsActionIcon=t=>{let e=t.field,r=t.value,o=!!e.translate,i=(window.__ROOT_CTX.rootConfig.i18n||{}).locales||["en"],a=Ire(),s=Kn(),l=zk(),c=pe(()=>!o||og(e,r,l),[e,r]);return!o||i.length<=1?null:p("div",{className:"DocEditor__FieldHeader__translate",children:c?p("div",{className:"DocEditor__FieldHeader__translate__iconDisabled",children:p(Cd,{size:16})}):p(Te,{label:"Show translations",children:p(Xe,{size:"xs",onClick:()=>{let d=s.controller.getData();if(!d)return;let u=new Set;SC(u,e,r,l);let f=Array.from(u);a.open({docId:s.controller.docId,strings:f,l10nSheet:d?.sys?.l10nSheet})},children:p(Cd,{size:16})})})})};ir.ObjectField=t=>{let e=t.field,r=e.variant;return r||(t.isArrayChild?r="inline":r="drawer"),r==="drawer"?p(ir.ObjectFieldDrawer,{...t}):p("div",{className:"DocEditor__ObjectField",children:p("div",{className:"DocEditor__ObjectField__fields",children:e.fields.map(o=>p(ir.Field,{field:o,deepKey:`${t.deepKey}.${o.id}`},o.id))})})};ir.ObjectFieldDrawer=t=>{let e=t.field,r=e.drawerOptions?.collapsed||!1,o=e.drawerOptions?.inline||!1,n=o?"left":"right",i=Py(),a=!r||i.value.includes(t.deepKey);return p("div",{className:Ne("DocEditor__ObjectFieldDrawer",o&&"DocEditor__ObjectFieldDrawer--inline"),children:p("details",{className:"DocEditor__ObjectFieldDrawer__drawer",open:a,children:[p("summary",{className:Ne("DocEditor__ObjectFieldDrawer__drawer__toggle",`DocEditor__ObjectFieldDrawer__drawer__toggle--icon-${n}`),children:[p(ir.FieldHeader,{className:"DocEditor__ObjectFieldDrawer__drawer__toggle__header",field:e,deepKey:t.deepKey}),p("div",{className:"DocEditor__ObjectFieldDrawer__drawer__toggle__icon",children:p(lc,{size:16})})]}),p("div",{className:"DocEditor__ObjectFieldDrawer__drawer__content DocEditor__ObjectFieldDrawer__fields",children:e.fields.map(s=>p(ir.Field,{field:s,deepKey:`${t.deepKey}.${s.id}`},s.id))})]})})};function Wet(t,e){switch(e.type){case"update":{let r=t._new||[];return{...e.newValue,_new:r}}case"updateItem":{let r=t??{},n=[...r._array||[]][e.index],i=e.newValue??{};return e.draft.updateKey(`${e.deepKey}.${n}`,i),{...r,[n]:i}}case"add":{let r=t??{},o=pi(),n=[...r._array||[],o];e.draft.updateKeys({[`${e.deepKey}._array`]:n,[`${e.deepKey}.${o}`]:{}});let i=t._new||[];return{...r,[o]:{},_array:n,_new:[...i,o]}}case"insertBefore":{let r=t??{},o=[...r._array||[]],n=pi();o.splice(e.index,0,n),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${n}`]:{}});let i=t._new||[];return{...r,[n]:{},_array:o,_new:[...i,n]}}case"insertAfter":{let r=t??{},o=[...r._array||[]],n=pi();o.splice(e.index+1,0,n),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${n}`]:{}});let i=t._new||[];return{...r,[n]:{},_array:o,_new:[...i,n]}}case"duplicate":{let r=t??{},o=[...r._array||[]],n=pi(),i=structuredClone(e.value);o.splice(e.index+1,0,n),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${n}`]:i});let a=t._new||[];return{...r,[n]:i,_array:o,_new:[...a,n]}}case"moveUp":{if(e.index===0)return t;let r=t??{},o=[...r._array||[]];return Whe(o,e.index,e.index-1),e.draft.updateKeys({[`${e.deepKey}._array`]:o}),{...r,_array:o,_moved:o[e.index-1]}}case"moveDown":{let r=t??{},o=[...r._array||[]];return e.index>=o.length-1?t:(Whe(o,e.index,e.index+1),e.draft.updateKeys({[`${e.deepKey}._array`]:o}),{...r,_array:o,_moved:o[e.index+1]})}case"moveTo":{let r=t??{},o=[...r._array||[]];if(e.fromIndex<0||e.fromIndex>=o.length||e.toIndex<0||e.toIndex>=o.length)return console.error("Invalid moveTo index",e),t;let n=o[e.fromIndex];return Ket(o,e.fromIndex,e.toIndex),e.draft.updateKeys({[`${e.deepKey}._array`]:o}),{...r,_array:o,_moved:n}}case"removeAt":{let r={...t??{}},n=[...r._array||[]],i=n[e.index];return delete r[i],n.splice(e.index,1),e.draft.updateKeys({[`${e.deepKey}._array`]:n}),e.draft.removeKey(`${e.deepKey}.${i}`),{...r,_array:n}}case"pasteAfter":{let r=t??{},o=[...r._array||[]],n=pi(),i=e.data;if(!i)return Re({title:"Skipped",message:"Nothing to paste.",autoClose:!0}),t;o.splice(e.index+1,0,n),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${n}`]:i});let a=t._new||[];return{...r,[n]:i,_array:o,_new:[...a,n]}}case"pasteBefore":{let r=t??{},o=[...r._array||[]],n=pi(),i=e.data;if(!i)return Re({title:"Skipped",message:"Nothing to paste.",autoClose:!0}),t;o.splice(e.index,0,n),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${n}`]:i});let a=t._new||[];return{...r,[n]:i,_array:o,_new:[...a,n]}}default:return console.error("unknown action",e),t}}ir.ArrayField=t=>{let e=Kn().controller,r=t.field,[o,n]=ei(Wet,{_array:[]}),i=Py(),a=Cae(),s=window.__ROOT_CTX.experiments||{},c=(o??{})._array||[],d=o._new||[];gl(t.deepKey,B=>{n({type:"update",newValue:B})}),V(()=>{o._moved&&v(t.deepKey,c.indexOf(o._moved))},[o]);let u=B=>{let $=c[B],z=`${t.deepKey}.${$}`;return e.getValue(z)||{}},f=()=>{n({type:"add",draft:e,deepKey:t.deepKey})},m=(B,$)=>{n({type:"pasteBefore",draft:e,deepKey:t.deepKey,index:B,data:$})},h=(B,$)=>{n({type:"pasteAfter",draft:e,deepKey:t.deepKey,index:B,data:$})},g=B=>{n({type:"insertBefore",draft:e,deepKey:t.deepKey,index:B})},_=B=>{n({type:"insertAfter",draft:e,deepKey:t.deepKey,index:B})},b=B=>{n({type:"duplicate",draft:e,deepKey:t.deepKey,index:B,value:u(B)})},y=B=>{n({type:"removeAt",draft:e,deepKey:t.deepKey,index:B})},v=(B,$)=>{document.getElementById(`summary-for-${B}.${c[$]}`)?.focus()},S=B=>{B>0&&n({type:"moveUp",draft:e,deepKey:t.deepKey,index:B})},N=B=>{B<c.length-1&&n({type:"moveDown",draft:e,deepKey:t.deepKey,index:B})},w=B=>{let $=u(B);a.set($)},E=vC(),I=are(),C=B=>{let $=u(B);E.open({data:$,onSave:z=>{console.log("[edit json] onSave()",z),n({type:"updateItem",draft:e,index:B,newValue:z,deepKey:t.deepKey}),E.close()}})},T=B=>{let $=u(B);I.open({data:$,onSave:z=>{console.log("[ai edit] onSave()",z),n({type:"updateItem",draft:e,index:B,newValue:z,deepKey:t.deepKey}),I.close()}})};function O(B){return!!i.value.startsWith(`${t.deepKey}.${B}`)}let A=qe((B,$)=>{B.target&&(B.key==="ArrowUp"?(B.preventDefault(),S(c.indexOf($))):B.key==="ArrowDown"?(B.preventDefault(),N(c.indexOf($))):B.key==="ArrowLeft"?B.target.closest("details").open=!1:B.key==="ArrowRight"&&(B.target.closest("details").open=!0))},[t.deepKey]),P=p("div",{className:"DocEditor__ArrayField__add",children:p(ee,{color:"dark",size:"xs",leftIcon:p(gh,{size:16}),onClick:()=>f(),children:r.buttonLabel||"Add"})});return c.length===0&&!o._new?p("div",{className:"DocEditor__ArrayField",children:[p("div",{className:"DocEditor__ArrayField__items",children:p("div",{className:"DocEditor__ArrayField__items__empty",children:"No items"})}),P]}):p("div",{className:"DocEditor__ArrayField",children:[p(hT,{onDragEnd:B=>{let{source:$,destination:z}=B;z&&n({type:"moveTo",fromIndex:$.index,toIndex:z.index,draft:e,deepKey:t.deepKey})},children:p(_T,{droppableId:"dnd-list",direction:"vertical",children:B=>p("div",{...B.droppableProps,ref:B.innerRef,className:"DocEditor__ArrayField__items",children:[c.map(($,z)=>p(gT,{index:z,draggableId:$,children:(H,q)=>p("div",{ref:H.innerRef,...H.draggableProps,className:Ne("DocEditor__ArrayField__item__wrapper",q.isDragging&&"DocEditor__ArrayField__item__wrapper--dragging"),children:[p("div",{className:"DocEditor__ArrayField__item__handle",...H.dragHandleProps,children:p(kb,{size:18,stroke:"1.5"})}),p("details",{className:"DocEditor__ArrayField__item",open:d.includes($)||O($),onToggle:Y=>{Y.target.open?Xa(`${t.deepKey}.${c[z]}`,{scroll:!0}):Xa(null)},onMouseEnter:()=>{Xa(`${t.deepKey}.${c[z]}`)},onMouseLeave:()=>{Xa(null)},children:[p("summary",{id:`summary-for-${t.deepKey}.${c[z]}`,className:"DocEditor__ArrayField__item__header",onKeyDown:Y=>A(Y,$),tabIndex:0,children:[p("div",{className:"DocEditor__ArrayField__item__header__icon",children:p(qM,{size:6})}),p(ir.ArrayFieldPreview,{field:r,deepKey:`${t.deepKey}.${$}`,index:z}),p("div",{className:"DocEditor__ArrayField__item__header__controls",children:[p("div",{className:"DocEditor__ArrayField__item__header__controls__arrows",children:[p("button",{className:"DocEditor__ArrayField__item__header__controls__arrow DocEditor__ArrayField__item__header__controls__arrows--up",onClick:()=>S(z),children:p(hM,{size:20,strokeWidth:1.75})}),p("button",{className:"DocEditor__ArrayField__item__header__controls__arrow DocEditor__ArrayField__item__header__controls__arrows--down",onClick:()=>N(z),children:p(mM,{size:20,strokeWidth:1.75})})]}),p(Be,{className:"DocEditor__ArrayField__item__header__controls__menu",position:"bottom",transitionDuration:0,control:p(Xe,{className:"DocEditor__ArrayField__item__header__controls__dots",children:p(Ef,{size:16})}),children:[p(Be.Label,{children:"INSERT"}),p(Be.Item,{className:"DocEditor__ArrayField__item__header__controls__menu__item",icon:p(kS,{size:18}),onClick:()=>g(z),children:"Add before"}),p(Be.Item,{className:"DocEditor__ArrayField__item__header__controls__menu__item",icon:p(TS,{size:18}),onClick:()=>_(z),children:"Add after"}),p(Be.Item,{className:"DocEditor__ArrayField__item__header__controls__menu__item",icon:p(cc,{size:18}),onClick:()=>b(z),children:"Duplicate"}),p(Be.Label,{children:"CLIPBOARD"}),p(Be.Item,{className:"DocEditor__ArrayField__item__header__controls__menu__item",icon:p(_M,{size:18}),onClick:()=>w(z),children:"Copy"}),p(Be.Item,{className:"DocEditor__ArrayField__item__header__controls__menu__item",icon:p(kS,{size:18}),onClick:async()=>m(z,await a.get()),children:"Paste before"}),p(Be.Item,{className:"DocEditor__ArrayField__item__header__controls__menu__item",icon:p(TS,{size:18}),onClick:async()=>h(z,await a.get()),children:"Paste after"}),p(Be.Label,{children:"CODE"}),p(Be.Item,{className:"DocEditor__ArrayField__item__header__controls__menu__item",icon:p(wb,{size:18}),onClick:()=>C(z),children:"Edit JSON"}),s.ai&&p(Be.Item,{className:"DocEditor__ArrayField__item__header__controls__menu__item",icon:p(Mb,{size:18,stroke:"1.75"}),onClick:()=>T(z),children:"Edit with AI"}),p(Be.Label,{children:"REMOVE"}),p(Be.Item,{className:"DocEditor__ArrayField__item__header__controls__menu__item",icon:p(qn,{size:18}),onClick:()=>y(z),children:"Remove"})]})]})]}),p("div",{className:"DocEditor__ArrayField__item__body",children:p(ir.Field,{field:r.of,deepKey:`${t.deepKey}.${$}`,hideHeader:!0,isArrayChild:!0,onFocus:()=>{Xa(`${t.deepKey}.${$}`,{scroll:!0})},onBlur:()=>{Xa(null)}},`${t.deepKey}.${$}`)})]},$)]})},$)),B.placeholder]})})}),P]})};ir.ArrayFieldPreview=t=>{let e=Kn().controller,[r,o]=M(e.getValue(t.deepKey)),n=pe(()=>Yet(t.field,r),[r]),i=pe(()=>Xet(t.field,r,t.index),[r,t.index]),a=qe(xT(()=>{let s=e.getValue(t.deepKey);o({...s})},250),[t.deepKey,e]);return V(()=>e.on("VALUE_CHANGE",(s,l)=>{s===t.deepKey?o(l):s.startsWith(t.deepKey)&&a()}),[t.deepKey,e]),p("div",{className:"DocEditor__ArrayField__item__header__preview",children:[n&&p("div",{className:"DocEditor__ArrayField__item__header__preview__image",children:p("img",{src:n,alt:"",className:"DocEditor__ArrayField__item__header__preview__image__img",loading:"lazy"})}),p("div",{className:"DocEditor__ArrayField__item__header__preview__title",children:i})]})};ir.OneOfField=t=>{let e=t.field,[r,o]=M(""),n=zk(),i={},a=[{value:"",label:e.placeholder||"Select type"}];e.types.forEach(f=>{typeof f=="string"?(i[f]=n[f],a.push({value:f,label:f})):(i[f.name]=f,a.push({value:f.name,label:f.name}))});let s=i[r||""],l=Kn().controller,c=pe(()=>({}),[]);async function d(f){let m={};if(f){if(f in c){let h=c[f];Object.assign(m,h)}else if(f in i){let h=Ud(i[f]);Object.assign(m,h)}}m._type=f,await l.updateKey(t.deepKey,m),o(f)}gl(t.deepKey,f=>{f?._type&&(o(f._type||""),c[f._type]=f)});function u(f){let m=f.target;m&&m.select&&m.select()}return p("div",{className:"DocEditor__OneOfField",children:[p("div",{className:"DocEditor__OneOfField__select",children:[p("div",{className:"DocEditor__OneOfField__select__label",children:"Type:"}),p(Sr,{data:a,value:r,placeholder:e.placeholder,onChange:f=>d(f||""),onFocus:u,size:"xs",radius:0,searchable:!0,dropdownComponent:"div"})]}),s&&p("div",{className:"DocEditor__OneOfField__fields",children:s.fields.map(f=>p(ir.Field,{field:f,deepKey:`${t.deepKey}.${f.id}`,onBlur:()=>{Xa(null)},onFocus:()=>{Xa(`${t.deepKey}.${f.id}`,{scroll:!0})}},`${r}::${f.id}`))})]})};function Whe(t,e,r){if(t.length<=1)return t;let o=t[e];return t[e]=t[r],t[r]=o,t}function Ket(t,e,r){let[o]=t.splice(e,1);t.splice(r,0,o)}function Yhe(t,e,r="title"){let o=zk();if(t.type==="oneof"){let n=t,i=e?._type;if(i){let a,s=n.types||[];return typeof s[0]=="string"?a=o[i]:a=s.find(l=>l.name===i),a?.preview?.[r]||null}}return null}function Yet(t,e){let r=Yhe(t.of,e,"image");if(r)return rg(r,e)}function Xet(t,e,r){let o=Yhe(t.of,e,"title");if(o){let n=rg(o,e,{index:r});if(n)return n}return t.preview?rg(t.preview,e,{index:r})??`item ${r}`:`item ${r}`}function Uk(t,e,r=""){let o=fC({collectionId:t,slug:e}),n=new URLSearchParams(window.location.search);n.set("preview","true"),n.has("locale")&&n.delete("locale");let i=`${n.toString()}${window.location.hash}`;return r?`${fC({collectionId:t,slug:e,locale:r})}?${i}`:`${o}?${i}`}function Vk(t){let e=t.collection,r=t.slug,o=`${e}/${r}`;return p(Eae,{docId:o,children:p(Jet,{...t})})}function Jet(t){let e=t.collection,r=t.slug,o=`${e}/${r}`,n=window.__ROOT_CTX.collections[e],i=Kn(),[a,s]=Vd(`root::DocumentPage::previewVisible::${e}`,!0);if(!n)return p("div",{children:"Could not find collection."});function l(){let f=Uk(e,r),m=window.open(f,"_blank","noopener,noreferrer");m&&m.focus()}let c=qe(()=>{i.controller&&i.controller.flush()},[i.controller]),d=vC(),u=qe(()=>{let f=i.controller?.getData()?.fields||{};d.open({data:f,onSave:m=>{i.controller&&m&&typeof m=="object"&&(i.controller.updateKey("fields",m),i.controller.flush()),d.close()}})},[i.controller]);return ZN([["mod+S",c]]),p(Fe,{children:p(_c,{className:"DocumentPage",localStorageId:"DocumentPage",children:[p(_c.Item,{className:Ne("DocumentPage__side",!a&&"DocumentPage__side--expanded"),children:[p("div",{className:"DocumentPage__side__header",children:[p("div",{className:"DocumentPage__side__header__nav",children:[p("a",{href:`/cms/content/${e}`,children:p(Xe,{className:"DocumentPage__side__header__back",children:p(dM,{size:16})})}),p("div",{className:"DocumentPage__side__header__docId",children:o})]}),p("div",{className:"DocumentPage__side__header__buttons",children:[p(ee,{className:"DocumentPage__side__header__saveButton",variant:"filled",color:"dark",size:"xs",compact:!0,leftIcon:p(Cb,{size:16}),onClick:()=>c(),children:"Save"}),p(Te,{label:"Edit JSON",children:p(Xe,{className:"DocumentPage__side__header__editJson",onClick:()=>u(),children:p(wb,{size:14})})}),p(Te,{label:a?"Hide preview":"Show preview",children:p(Xe,{className:"DocumentPage__side__header__previewToggle",onClick:()=>s(!a),children:a?p(AM,{size:16}):p(RM,{size:16})})}),!a&&p(Te,{label:"Open preview in new tab",children:p(Xe,{className:"DocumentPage__side__header__openNewTab",onClick:l,children:p(Sd,{size:16})})})]})]}),p("div",{className:Ne("DocumentPage__side__editor",!a&&"DocumentPage__side__editor--centered"),children:p(ir,{docId:o})})]}),p(_c.Item,{className:Ne("DocumentPage__main",!a&&"DocumentPage__main--hidden"),fluid:!0,children:a&&p(Vk.Preview,{docId:o},o)})]})})}var Xhe={mobile:[360,800],tablet:[768,1024],desktop:[1440,800]};function Qet(t){let e=new Intl.DisplayNames(["en"],{type:"language"}),o=t.split("_")[0];return`${e.of(o)||t} (${t})`}Vk.Preview=t=>{let e=Kn();if(e.loading)return null;let[r,o]=t.docId.split("/"),i=window.__ROOT_CTX.collections[r];if(!i)throw new Error(`collection not found: ${r}`);let a=i.domain||window.__ROOT_CTX.rootConfig.domain||"https://example.com",s=r2({collectionId:r,slug:o}),l=fC({collectionId:r,slug:o}),c=`${a}${s}`,[d,u]=M(c),[f,m]=Vd("root::DocumentPage::preview::device",""),[h,g]=Vd("root::DocumentPage::preview::expandVertically",!1),[_,b]=M({"--iframe-width":"100%","--iframe-height":"100%","--iframe-scale":"1"}),[y,v]=yne("locale",""),S=G(null),N=e.controller.getLocales()||[],w=hne(),E=Uk(r,o),I=Uk(r,o,y),C=[{value:"",label:"Select locale"},...N.map(z=>({value:z,label:Qet(z)}))];function T(){let z=S.current;z.src="about:blank",window.setTimeout(()=>{z.src!==I?z.src=I:z.contentWindow.location.reload()},30)}V(()=>{let z=S.current;function H(){let Y=z.contentWindow;if(Y&&l===s&&!Y.location.href.startsWith("about:blank")){let L=Y.location.pathname;u(`${a}${L}`)}}z.addEventListener("load",H);let q=e.controller?.onFlush(()=>{T()});return()=>{q(),z.removeEventListener("load",H)}},[]),V(()=>{let z=S.current;z.src=I},[y]);function O(z){m(H=>{let q=H===z?"":z;return q===""&&g(!1),q})}function A(){f&&g(z=>!z)}function P(){e.controller&&e.controller.flush().then(()=>T())}function B(){let z=Uk(r,o,y),H=window.open(z,"_blank","noopener,noreferrer");H&&H.focus()}function $(){if(f===""){b({"--iframe-width":"100%","--iframe-height":"100%","--iframe-scale":"1"});return}let q=S.current.parentElement.parentElement.getBoundingClientRect(),[Y,L]=Xhe[f],ne=20,ae=Math.max(q.width-2*ne,0),U=Math.max(q.height-2*ne,0),ge=ae>0&&Y>0?ae/Y:1,Ee=U>0&&L>0?U/L:1,Ve=Math.min(ge,Ee,1),Ye=Number(Ve.toFixed(4))||1,Ae=h?`${U/Ye}px`:`${L}px`;b({"--iframe-width":`${Y}px`,"--iframe-height":Ae,"--iframe-scale":String(Ye)})}return V(()=>{$();let z=w.onResize($);return window.addEventListener("resize",$),()=>{z(),window.removeEventListener("resize",$)}},[f,w,h]),p("div",{className:"DocumentPage__main__preview",children:[p("div",{className:"DocumentPage__main__previewBar",children:[p("div",{className:"DocumentPage__main__previewBar__devices",children:[p(Te,{label:"Mobile",children:p(Xe,{className:Ne("DocumentPage__main__previewBar__device",f==="mobile"&&"active"),onClick:()=>O("mobile"),children:p(IM,{size:16})})}),p(Te,{label:"Tablet",children:p(Xe,{className:Ne("DocumentPage__main__previewBar__device",f==="tablet"&&"active"),onClick:()=>O("tablet"),children:p(vM,{size:16})})}),p(Te,{label:"Desktop",children:p(Xe,{className:Ne("DocumentPage__main__previewBar__device",f==="desktop"&&"active"),onClick:()=>O("desktop"),children:p(yM,{size:16})})}),p(Te,{label:"Expand",children:p(Xe,{className:Ne("DocumentPage__main__previewBar__device",h&&"active"),"aria-pressed":h,disabled:f==="",onClick:A,children:p(fM,{size:16})})})]}),p("div",{className:"DocumentPage__main__previewBar__navbar",children:p("div",{className:"DocumentPage__main__previewBar__navbar__url",children:d})}),p("div",{className:"DocumentPage__main__previewBar__locales",children:p(Sr,{data:C,placeholder:"Locale",radius:"xl",size:"xs",required:!0,icon:p(jM,{size:16,strokeWidth:1.5}),value:y,onChange:z=>{v(z)}})}),p("div",{className:"DocumentPage__main__previewBar__buttons",children:[p(Te,{label:"Reload",children:p(Xe,{className:"DocumentPage__main__previewBar__button DocumentPage__main__previewBar__button--reload",onClick:()=>P(),children:p(VM,{size:16})})}),p(Te,{label:"Open new tab",children:p(Xe,{className:"DocumentPage__main__previewBar__button DocumentPage__main__previewBar__button--openNewTab",onClick:()=>B(),children:p(Sd,{size:16})})})]})]}),p("div",{className:"DocumentPage__main__previewFrame","data-device":f||"full",style:_,children:[f&&p("div",{className:"DocumentPage__main__previewFrame__deviceLabel",children:`${f}: ${Xhe[f].join("x")}`}),p("div",{className:"DocumentPage__main__previewFrame__iframeWrap",children:p("iframe",{ref:S,src:E,title:"iframe preview"})})]})]})};we();var Zet="Enter the URL to make the HTTP request.",ett="Enter the URL of the Google Sheet, e.g. https://docs.google.com/spreadsheets/d/SPREADSHEET_ID/edit#gid=SHEET_ID";function Hk(t){let e=G(null),r=Fd(),[o,n]=M(!1),[i,a]=M(r.enabled?"gsheet":"http"),[s,l]=M("map"),[c,d]=M("GET"),[u,f]=M(""),[m,h]=M(!!t.dataSourceId),[g,_]=M(null),b="";i==="http"?b=Zet:i==="gsheet"&&(b=ett);async function y(N){await or(async()=>{let w=await Vf(N);_(w),a(w?.type||"http"),l(w?.dataFormat||"map")}),h(!1)}V(()=>{t.dataSourceId&&(h(!0),y(t.dataSourceId))},[t.dataSourceId]);async function v(){f("");let N=e.current;function w(T){let O=N.elements[T];return O?O.value.trim():""}let E=t.dataSourceId||w("id");if(!E){f("missing id");return}if(!pl(E)){f("id is invalid (alphanumeric characters and dashes only)");return}let I=w("url");if(!I){f("missing url");return}let C={id:E,description:w("description"),type:i,url:I,previewUrl:w("previewUrl")};if(i==="http"){if(!ttt(I)){f("invalid url");return}C.httpOptions={method:c};let T=w("httpHeaders");if(T&&(C.httpOptions.headers=rtt(T)),c==="POST"){let O=w("httpBody");O&&(C.httpOptions.body=O)}}else if(i==="gsheet"){if(!Rd(I)?.spreadsheetId){f("failed to parse spreadsheet url");return}C.dataFormat=s||"map"}try{_(C),n(!0),t.dataSourceId?(await pre(t.dataSourceId,C),Re({title:"Saved data source",message:`Successfully updated ${E}`,autoClose:5e3}),n(!1)):(await fre(E,C),Re({title:"Added data source",message:`Successfully added ${E}`,autoClose:5e3}),n(!1),_o(`/cms/data/${E}`))}catch(T){console.error(T),Re({title:"Failed to save data source",message:String(T),color:"red",autoClose:!1}),n(!1)}}let S=[{value:"http",label:"HTTP"}];return(r.enabled||i==="gsheet")&&S.push({value:"gsheet",label:"Google Sheet"}),p("form",{className:"DataSourceForm",ref:e,onSubmit:N=>{N.preventDefault(),v()},children:[p(Ma,{visible:m}),p("div",{className:"DataSourceForm__input",children:p(Sr,{name:"type",label:"Type",data:S,value:i,onChange:N=>a(N),size:"xs",radius:0,dropdownComponent:"div"})}),p(tr,{className:"DataSourceForm__input",name:"id",label:"ID",description:"Unique identifier for the data source. Use alphanumeric characters and dashes only, e.g. grogus-favorite-meals",size:"xs",radius:0,value:t.dataSourceId,disabled:!!t.dataSourceId}),p(hr,{className:"DataSourceForm__input",name:"description",label:"Description",description:"Optional.",size:"xs",radius:0,value:g?.description}),p(tr,{className:"DataSourceForm__input",name:"url",label:"URL",description:b,size:"xs",radius:0,value:g?.url}),i==="http"&&p(Ce,{children:[p("div",{className:"DataSourceForm__input",children:p(Sr,{name:"httpMethod",label:"HTTP Request Method",data:[{value:"GET",label:"GET"},{value:"POST",label:"POST"}],value:c,onChange:N=>d(N),size:"xs",radius:0,dropdownComponent:"div"})}),p(hr,{className:"DataSourceForm__input",name:"httpHeaders",label:"HTTP Request Headers",description:"Format as `HeaderName: Value`, each value on its own line.",size:"xs",radius:0,value:ott(g?.httpOptions?.headers||{})}),c==="POST"&&p(hr,{className:"DataSourceForm__input",name:"httpRequestBody",label:"HTTP Request Body",size:"xs",radius:0,value:g?.httpOptions?.body})]}),i==="gsheet"&&p("div",{className:"DataSourceForm__input",children:[p(Sr,{name:"dataFormat",label:"Data Format",data:[{value:"map",label:"map"}],value:s,onChange:N=>l(N),size:"xs",radius:0,dropdownComponent:"div"}),s==="array"&&p("div",{className:"DataSourceForm__input__example",children:["Data is stored as an array of arrays, e.g.",p("code",{children:"[[header1, header2], [foo, bar]]"})]}),s==="map"&&p("div",{className:"DataSourceForm__input__example",children:["Data is stored as an array of maps, e.g.",p("code",{children:["[","{","header1: foo, header2: bar","}","]"]})]})]}),p(tr,{className:"DataSourceForm__input",name:"previewUrl",label:"Preview URL",description:"URL where users can preview the data source.",size:"xs",radius:0,value:g?.previewUrl}),p(ee,{className:"DataSourceForm__submit",color:"blue",size:"xs",type:"submit",loading:o,children:t.buttonLabel||"Save"}),u&&p("div",{className:"DataSourceForm__error",children:["Error: ",u]})]})}function ttt(t){let e,r=t.startsWith("/")?"http://localhost":void 0;try{e=new URL(t,r)}catch(o){return console.error(o),!1}return e.protocol==="http:"||e.protocol==="https:"}function rtt(t){let e={};return t.split(`
245
+ `}isInline(){return!1}updateDOM(){return!1}decorate(){return p(yet,{nodeKey:this.__key})}};function vet(){return{node:X3()}}function X3(){return Xn(new zv)}function Iet(t){return t instanceof zv}var Bk=J3,whe=Bk.$createHorizontalRuleNode,Ehe=Bk.$isHorizontalRuleNode,She=Bk.HorizontalRuleNode,gXt=Bk.INSERT_HORIZONTAL_RULE_COMMAND;var Q3={};ar(Q3,{DEFAULT_TRANSFORMERS:()=>Che,MarkdownShortcutPlugin:()=>wet});X();var Che=[{dependencies:[She],export:t=>Ehe(t)?"***":null,regExp:/^(---|\*\*\*|___)\s?$/,replace:(t,e,r,o)=>{let n=whe();o||t.getNextSibling()!=null?t.replace(n):t.insertBefore(n),n.selectNext()},type:"element"},...yhe];function wet({transformers:t=Che}){let[e]=Ht();return V((()=>Ihe(e,t)),[e,t]),null}var The=Q3,IXt=The.DEFAULT_TRANSFORMERS,khe=The.MarkdownShortcutPlugin;function Nhe(){return p(khe,{transformers:[xhe,vhe,bhe]})}var Z3={};ar(Z3,{OnChangePlugin:()=>Cet});X();var Eet=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?Ft:V;function Cet({ignoreHistoryMergeTagChange:t=!0,ignoreSelectionChange:e=!1,onChange:r}){let[o]=Ht();return Eet((()=>{if(r)return o.registerUpdateListener((({editorState:n,dirtyElements:i,dirtyLeaves:a,prevEditorState:s,tags:l})=>{e&&i.size===0&&a.size===0||t&&l.has(Vg)||s.isEmpty()||r(n,o,l)}))}),[o,t,e,r]),null}var Tet=Z3,Phe=Tet.OnChangePlugin;we();function ket(){return{text:"",components:{}}}var Net=[{tag:"s",format:"strikethrough"},{tag:"u",format:"underline"},{tag:"i",format:"italic"},{tag:"b",format:"bold"},{tag:"sup",format:"superscript"}];function Dhe(t){let e=[];return Net.forEach(({tag:r,format:o})=>{t.hasFormat(o)&&e.push(r)}),e}function e$(t,e){t.text+=e.text,Object.assign(t.components,e.components)}function Pet(t,e,r){for(let o=t.length-1;o>=0;o-=1){let n=t[o];e.includes(n)||(r.text+=`</${n}>`,t.splice(o,1))}e.forEach(o=>{t.includes(o)||(r.text+=`<${o}>`,t.push(o))})}function Ohe(t,e){for(let r=t.length-1;r>=0;r-=1)e.text+=`</${t[r]}>`;t.length=0}function Ahe(t,e){let r=t.getChildren();for(let o of r)if(Ke(o)){let n=Dhe(o);if(n.length!==e.length)return!1;for(let i=0;i<n.length;i+=1)if(n[i]!==e[i])return!1}else{if(Ur(o)||Fv(o))continue;if(o instanceof Ii){if(!Ahe(o,e))return!1}else return!1}return!0}function Oet(t){let e=t.getComponentId(),r=t.getComponentName(),o=Kr(t.getComponentData()),n={[e]:{type:r,data:o}};return{text:`{${r}:${e}}`,components:n}}function Det(t){let e=so(t)&&t.getURL()||"",r=Uv(t);return{text:`<a href="${e}">${r.text}</a>`,components:r.components}}function Uv(t){let e=ket(),r=[];return t.getChildren().forEach(n=>{if(Ur(n)){e.text+="<br>";return}if(Fv(n)){e$(e,Oet(n));return}if(Ke(n)){let i=Dhe(n);Pet(r,i,e);let a=n.getTextContent();a&&(e.text+=Met(a));return}if(so(n)){r.length>0&&!Ahe(n,r)&&Ohe(r,e),e$(e,Det(n));return}if(n instanceof Ii){e$(e,Uv(n));return}console.log("unhandled node"),console.log(n)}),r.length>0&&Ohe(r,e),e}function Rhe(t){let e=[];return t.getChildren().forEach(r=>{Av(r)&&e.push(Aet(r))}),Let(e)}function Aet(t){let e=t.getFirstChild();if(e&&ji(e))return{itemsType:e.getTag()==="ol"?"orderedList":"unorderedList",items:Rhe(e)};let r=Uv(t),o={content:r.text};return $k(r.components)&&(o.components=r.components),o}function Mhe(){let t=[];for(zr().getChildren().forEach(o=>{if(_a(o)){let n=Uv(o),i={type:"paragraph",data:{text:n.text}};$k(n.components)&&(i.data.components=n.components),t.push(i)}else if(_u(o)){let n=o.getTag().slice(1),i=Uv(o),a={type:"heading",data:{text:i.text,level:parseInt(n)}};$k(i.components)&&(a.data.components=i.components),t.push(a)}else if(ji(o)){let n=o.getTag(),i={type:n==="ol"?"orderedList":"unorderedList",data:{style:n==="ol"?"ordered":"unordered",items:Rhe(o)}};t.push(i)}else if(wk(o)){let n={type:o.getBlockName(),data:Kr(o.getBlockData())};t.push(n)}});Ret(t);)t.pop();return t.length===0?null:{time:Date.now(),blocks:t,version:"lexical-0.31.2"}}function Ret(t){let e=t.length>0&&t.at(-1);return!!(e&&e.type==="paragraph"&&!e.data?.text&&!$k(e.data?.components||{}))}function $k(t){return t?Object.keys(t).length>0:!1}function Met(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function Let(t){let e=[];return t.forEach(r=>{r.itemsType&&r.items&&e.length>0?(e.at(-1).itemsType=r.itemsType,e.at(-1).items=r.items):e.push(r)}),e}function Lhe(t){let e=zr();e.clear();let r=t?.blocks||[];for(let o of r)if(o.type==="paragraph"){let n=ur();if(o.data.text){let i=t$(o.data.text,o.data.components);n.append(...i)}e.append(n)}else if(o.type==="heading"){let n=`h${o.data?.level||2}`,i=t_(n);if(o.data.text){let a=t$(o.data.text,o.data.components);i.append(...a)}e.append(i)}else if(o.type==="orderedList"||o.type==="unorderedList"){let n=o.data.style==="ordered"?"number":"bullet",i=Dv(n);for(let a of o.data.items)i.append(...Fhe(a,n));e.append(i)}else if(o.type){let n=Ik(o.type,o.data||{});e.append(n)}}function t$(t,e){let r=document.createElement("template");r.innerHTML=t;let o=r.content,n=[];function i(a){if(a.nodeType===Node.TEXT_NODE)return Fet(a.textContent||"",e);if(a.nodeType===Node.ELEMENT_NODE){let s=a,l=Array.from(s.childNodes).map(i).filter(c=>!!c).flat();switch(s.tagName.toLowerCase()){case"b":case"strong":return l.map(c=>(c instanceof ba&&c.toggleFormat("bold"),c));case"i":case"em":return l.map(c=>(c instanceof ba&&c.toggleFormat("italic"),c));case"u":return l.map(c=>(c instanceof ba&&c.toggleFormat("underline"),c));case"s":return l.map(c=>(c instanceof ba&&c.toggleFormat("strikethrough"),c));case"sup":return l.map(c=>(c instanceof ba&&c.toggleFormat("superscript"),c));case"a":return[Xn(Wg(s.getAttribute("href")||"").append(...l))];default:return console.log("unhandled tag: "+s.tagName),console.log(l),l}}return null}return o.childNodes.forEach(a=>{let s=i(a);Array.isArray(s)?n.push(...s):s&&n.push(s)}),n}function Fet(t,e){let r=[];if(!t)return r;let o=/\{([^:{}]+):([^}]+)\}/g,n=0,i;for(;(i=o.exec(t))!==null;){let s=t.slice(n,i.index);s&&r.push(Mn(s));let l=i[1],c=i[2],d=e?.[c];d?r.push(Ek(l||d.type,c,d.data?Kr(d.data):{})):r.push(Mn(i[0])),n=o.lastIndex}let a=t.slice(n);return a&&r.push(Mn(a)),r}function Fhe(t,e){let r=[];if(t.content){let o=Bet(t,e);r.push(o)}if(t.items&&t.items.length>0){let o=$et(t,e);r.push(o)}return r}function Bet(t,e){let r=Ov();if(t.content){let o=t$(t.content,t.components);r.append(...o)}return r}function $et(t,e){let r=Ov();if(t.items&&t.items.length>0){let o=e;t.itemsType==="orderedList"?o="number":t.itemsType==="unorderedList"&&(o="bullet");let n=Dv(o);for(let i of t.items)n.append(...Fhe(i,o));r.append(n)}return r}function Bhe(t){let[e]=Ht(),r=G(0),o=G(!1);return V(()=>{let i=t.value?.time||0;i>r.current&&(r.current=i,e.update(()=>{o.current=!0,Lhe(t.value)}))},[e,t.value]),p(Phe,{onChange:i=>{if(o.current){o.current=!1;return}i.read(()=>{let a=Mhe();r.current=a?.time||0,t.onChange&&t.onChange(a)})},ignoreSelectionChange:!0})}we();function $he(t){let{editor:e,setIsLinkEditMode:r}=t,{toolbarState:o}=bk();return V(()=>{let n=i=>{if(zi(i,{}))return!1;if(kme(i))s_(e);else if(Nme(i)){let{code:a}=i,s=`h${a[a.length-1]}`;yu(e,o.blockType,s)}else if(Ome(i))Ok(e,o.blockType);else if(Pme(i))Dk(e,o.blockType);else if(Dme(i))e.dispatchCommand(un,"strikethrough");else if(Ame(i))e.dispatchCommand($i,void 0);else if(Rme(i))e.dispatchCommand(os,void 0);else if(Mme(i))e.dispatchCommand(un,"subscript");else if(Lme(i))e.dispatchCommand(un,"superscript");else if(Fme(i))$me(e);else if(Bme(i)){let a=o.isLink?null:"";r(!o.isLink),e.dispatchCommand(Vi,a)}else return!1;return i.preventDefault(),!0};return e.registerCommand(_ue,n,nue)},[e,o.isLink,o.blockType,r]),null}we();function zhe(){let[t]=Ht();return V(()=>t.registerNodeTransform(Iue,e=>{let r=e.getLastChild();_a(r)||e.append(ur())}),[t]),null}var zet={namespace:"RootCMS",theme:Qpe,nodes:[bfe,_k,Yg,kl,gu,n_,i_],onError:t=>{throw console.error("[LexicalEditor] error:",t),t}};function Vhe(t){return p(qfe,{initialConfig:zet,children:p(Kpe,{children:p(Jpe,{children:p("div",{className:Ne(t.className,"LexicalEditor",!t.autosize&&"LexicalEditor--withMaxHeight"),children:p(jet,{placeholder:t.placeholder,value:t.value,onChange:t.onChange,onFocus:t.onFocus,onBlur:t.onBlur,customBlocks:t.customBlocks,inlineComponents:t.inlineComponents})})})})})}var Uet=k3({name:"image",label:"Image Embed",preview:{title:"{file.alt}",image:"{file.src}"},fields:[zpe({id:"file",label:"Image"})]}),Vet=k3({name:"html",label:"HTML Code",preview:{title:"{html}"},fields:[$pe({id:"html",label:"HTML",help:"HTML code to embed. Please use caution when inserting HTML.",variant:"textarea"})]}),Het=[Uet,Vet];function jet(t){let{historyState:e}=Ype(),[r]=Ht(),[o,n]=M(r),[i,a]=M(!1),[s,l]=M(null),c=pe(()=>{let A=new Map;return Het.forEach(P=>{A.set(P.name,P)}),t.customBlocks?.forEach(P=>{A.set(P.name,P)}),A},[t.customBlocks]),d=Array.from(c.values()),[u,f]=M(null),m=pe(()=>{let A=new Map;return t.inlineComponents?.forEach(P=>{A.set(P.name,P)}),A},[t.inlineComponents]),h=Array.from(m.values()),[g,_]=M(null),b=A=>{A&&l(A)},y=(A,P)=>{let B=c.get(A);if(!B)return;let $=P?.initialValue?Kr(P.initialValue):Ud(B);f({schema:B,mode:P?.mode??"create",initialValue:$,nodeKey:P?.nodeKey})},v=(A,P)=>{r.update(()=>{let B=Ik(A,P);_p([B]),B.selectNext()})},S=(A,P)=>{r.update(()=>{let B=ga(A);wk(B)&&B.setBlockData(P)})},N=()=>{f(null)},w=A=>{u&&(u.mode==="edit"&&u.nodeKey?S(u.nodeKey,A):v(u.schema.name,A),N())},E=(A,P)=>{let B=m.get(A);if(!B)return;let $=P?.initialValue?Kr(P.initialValue):Ud(B);_({schema:B,componentName:A,componentId:P?.componentId||pi(),mode:P?.mode??"create",initialValue:$,nodeKey:P?.nodeKey})},I=(A,P,B)=>{r.update(()=>{let $=Ek(A,P,B);_p([$]),$.selectNext()})},C=(A,P,B,$)=>{r.update(()=>{let z=ga(A);Fv(z)&&(z.setComponentName(P),z.setComponentId(B),z.setComponentData($))})},T=()=>{_(null)},O=A=>{if(!g)return;let{componentName:P,mode:B,nodeKey:$}=g;B==="edit"&&$?C($,P,A.componentId,A.data):I(P,A.componentId,A.data),T()};return p(qpe,{components:m,onEditComponent:(A,P)=>E(A,{mode:P?.mode??"edit",initialValue:P?.initialValue,componentId:P?.componentId,nodeKey:P?.nodeKey}),children:p(Vpe,{blocks:c,onEditBlock:y,children:[p(Bhe,{value:t.value,onChange:t.onChange,customBlocks:c}),p(zme,{editor:r,activeEditor:o,setActiveEditor:n,setIsLinkEditMode:a,blockComponents:d,inlineComponents:h,onInsertBlockComponent:A=>y(A,{mode:"create"}),onInsertInlineComponent:A=>E(A,{mode:"create"})}),p($he,{editor:o,setIsLinkEditMode:a}),p(ape,{externalHistoryState:e}),p(Mpe,{contentEditable:p("div",{className:"LexicalEditor__scroller",children:p("div",{className:"LexicalEditor__root",ref:b,children:p(Qfe,{className:"LexicalEditor__editor",placeholder:p(Get,{placeholder:t.placeholder})})})}),ErrorBoundary:epe}),p(lpe,{}),p(cpe,{}),p(Bpe,{maxIndent:7}),p(Nhe,{}),p(zhe,{}),s&&p(Ce,{children:[p(Ume,{anchorElem:s,setIsLinkEditMode:a}),p(lme,{anchorElem:s,isLinkEditMode:i,setIsLinkEditMode:a})]}),u&&p(eme,{schema:u.schema,opened:!0,initialValue:u.initialValue,mode:u.mode,onClose:N,onSubmit:w}),g&&p(ime,{schema:g.schema,opened:!0,componentId:g.componentId,initialValue:g.initialValue,mode:g.mode,onClose:T,onSubmit:O})]})})}var Uhe=["Once upon a placeholder...","Start writing something legendary...","Words go here. Preferably brilliant ones...","Compose like nobody\u2019s watching...","Your masterpiece begins here...","Add text that makes Hemingway jealous...","Here lies your unwritten brilliance..."];function qet(){let t=Math.floor(Math.random()*Uhe.length);return Uhe[t]}function Get(t){let e=pe(()=>t.placeholder||qet(),[]);return p("div",{className:"LexicalEditor__placeholder",children:e})}function Hhe(t){return KC().preferences.EnableEditorJSEditor?p(ule,{...t}):p(Vhe,{...t})}function jhe(t){let e=t.field,[r,o]=M(null),n=Kn().controller,i=a=>{o(s=>(s?.time!==a?.time&&n.updateKey(t.deepKey,a),a))};return gl(t.deepKey,a=>{o(a)}),p(Hhe,{value:r,placeholder:e.placeholder,blockComponents:e.blockComponents,inlineComponents:e.inlineComponents,onChange:i,onFocus:t.onFocus,onBlur:t.onBlur,autosize:e.autosize})}we();function qhe(t){let e=t.field,[r,o]=on(t.deepKey,""),n=pe(()=>(e.options||[]).map(i=>typeof i=="string"?{label:i,value:i}:{label:i.label??i.value??"",value:i.value??i.label??""}),[e.options]);return p("div",{className:"DocEditor__SelectField",children:p(Sr,{data:n,placeholder:e.placeholder,value:r,onChange:i=>o(i||""),size:"xs",radius:0,searchable:e.searchable??!0,dropdownComponent:"div"})})}function Ghe(t){let e=t.field,[r,o]=on(t.deepKey,""),n=s=>{o(s.currentTarget.value)},i=s=>{t.onFocus?.(s),Xa(t.deepKey,{scroll:!0})},a=s=>{t.onBlur?.(s),Xa(null)};return e.variant==="textarea"?p(hr,{size:"xs",radius:0,autosize:!1,minRows:4,maxRows:e.maxRows||12,value:r,onChange:n,onFocus:i,onBlur:a}):p(tr,{size:"xs",radius:0,value:r,onChange:n,onFocus:i,onBlur:a})}var Khe=at({});function zk(){return Ze(Khe)}function ir(t){let e=t.docId.split("/")[0],r=XC(e),o=Kn(),n=r.loading||o.loading,i=r.schema?.fields||[];return p(Khe.Provider,{value:r?.schema?.types||{},children:p(yae,{children:p("div",{className:"DocEditor",children:[p(Ma,{visible:n,loaderProps:{color:"gray",size:"xl"}}),!n&&p(ir.StatusBar,{...t,draft:o,collection:r.schema}),p("div",{className:"DocEditor__fields",children:i.map(a=>p(ir.Field,{field:a,deepKey:`fields.${a.id}`},a.id))})]})})})}ir.StatusBar=t=>{let e=t.draft,[r,o]=M(e.controller.getData());gl("sys",l=>{o({sys:l})});let n=qe(l=>{if(l.action==="delete"){let c=t.docId.split("/")[0];_o(`/cms/content/${c}`)}else l.action==="unlocked"&&e.controller.removePublishingLock()},[t.docId]),i=joe({docId:t.docId}),a=Nre(),s=!r?.sys;return s?null:p("div",{className:"DocEditor__statusBar",children:[p("div",{className:"DocEditor__statusBar__viewers",children:p(Dae,{id:`doc/${t.docId}`})}),p(ir.SaveState,{}),r?.sys&&p("div",{className:"DocEditor__statusBar__statusBadges",children:p(Gh,{doc:r})}),p("div",{className:"DocEditor__statusBar__i18n",children:p(ee,{variant:"default",color:"dark",size:"xs",leftIcon:p(zM,{size:16}),onClick:()=>a.open({docId:t.docId,collection:t.collection,draft:e.controller}),children:"Localization"})}),p("div",{className:"DocEditor__statusBar__publishButton",children:s?p(ee,{color:"dark",size:"xs",onClick:()=>i.open(),loading:!0,disabled:!0,children:"Publish"}):AS(r)?p(Te,{label:`Scheduled ${NS(r.sys.scheduledAt)} by ${r.sys.scheduledBy}`,transition:"pop",children:p(ee,{color:"dark",size:"xs",leftIcon:p(_h,{size:16}),disabled:!0,children:"Publish"})}):Of(r)?p(Te,{label:`Locked by ${r.sys.publishingLocked.lockedBy}: "${r.sys.publishingLocked.reason}"`,transition:"pop",children:p(ee,{color:"dark",size:"xs",leftIcon:p(Tf,{size:16}),disabled:!0,children:"Publish"})}):p(ee,{color:"dark",size:"xs",leftIcon:p(_h,{size:16}),onClick:()=>i.open(),children:"Publish"})}),p("div",{className:"DocEditor__statusBar__actionsMenu",children:p(YC,{docId:t.docId,data:r,onAction:n})})]})};ir.SaveState=()=>{let[t,e]=M("NO_CHANGES");return Sae(r=>{e(r)}),p("div",{className:"DocEditor__statusBar__saveState",children:[t==="SAVED"&&"saved!",t==="SAVING"&&"saving...",t==="UPDATE_PENDING"&&"saving...",t==="ERROR"&&"error saving"]})};ir.Field=t=>{let e=t.field,r=t.level??0,n=Py().value===t.deepKey,i=G(null),[a,s]=M(!0),l=zk(),c=pe(()=>e.type==="object"&&(e.variant||"drawer")==="drawer"?!1:!t.hideHeader&&!e.hideLabel,[t.hideHeader,e]);return gl(t.deepKey,d=>{s(og(e,d,l))}),V(()=>{n&&LF(i.current)},[n]),e.deprecated&&a?null:p("div",{className:Ne("DocEditor__field",e.deprecated&&"DocEditor__field--deprecated",n&&"deeplink-target"),"data-type":e.type,"data-level":r,id:t.deepKey,ref:i,children:[c&&p(ir.FieldHeader,{...t}),p("div",{className:"DocEditor__field__input",children:e.type==="array"?p(ir.ArrayField,{...t}):e.type==="boolean"?p(Aae,{...t}):e.type==="date"?p(Rae,{...t}):e.type==="datetime"?p(Mae,{...t}):e.type==="file"?p(gi,{...t}):e.type==="image"?p($ae,{...t}):e.type==="multiselect"?p(zae,{...t}):e.type==="number"?p(Uae,{...t}):e.type==="object"?p(ir.ObjectField,{...t}):e.type==="oneof"?p(ir.OneOfField,{...t}):e.type==="reference"?p(ng,{...t}):e.type==="references"?p(Vae,{...t}):e.type==="richtext"?p(jhe,{...t}):e.type==="select"?p(qhe,{...t}):e.type==="string"?p(Ghe,{...t}):p("div",{className:"DocEditor__field__input__unknown",children:["Unknown field type: ",e.type]})})]})};ir.FieldHeader=t=>{let e=t.field,r=e.label||e.id,[o,n]=M(null),i=Py(),a=pe(()=>vae(t.deepKey||""),[t.deepKey]);return gl(t.deepKey,s=>{n(s)}),p("div",{className:Ne(t.className,"DocEditor__FieldHeader"),children:[e.deprecated?p("div",{className:"DocEditor__FieldHeader__label",children:["DEPRECATED: ",r]}):p("div",{className:"DocEditor__FieldHeader__label",children:[p("span",{children:r}),t.deepKey&&p("a",{className:"DocEditor__FieldHeader__label__deeplink",href:a,title:"Link to field",onClick:s=>{s.preventDefault(),window.history.replaceState({},"",a),i.setValue(t.deepKey)},children:"#"})]}),e.help&&p("div",{className:"DocEditor__FieldHeader__help",children:e.help}),p(ir.FieldHeaderTranslationsActionIcon,{field:e,value:o})]})};ir.FieldHeaderTranslationsActionIcon=t=>{let e=t.field,r=t.value,o=!!e.translate,i=(window.__ROOT_CTX.rootConfig.i18n||{}).locales||["en"],a=Ire(),s=Kn(),l=zk(),c=pe(()=>!o||og(e,r,l),[e,r]);return!o||i.length<=1?null:p("div",{className:"DocEditor__FieldHeader__translate",children:c?p("div",{className:"DocEditor__FieldHeader__translate__iconDisabled",children:p(Cd,{size:16})}):p(Te,{label:"Show translations",children:p(Xe,{size:"xs",onClick:()=>{let d=s.controller.getData();if(!d)return;let u=new Set;SC(u,e,r,l);let f=Array.from(u);a.open({docId:s.controller.docId,strings:f,l10nSheet:d?.sys?.l10nSheet})},children:p(Cd,{size:16})})})})};ir.ObjectField=t=>{let e=t.field,r=e.variant;return r||(t.isArrayChild?r="inline":r="drawer"),r==="drawer"?p(ir.ObjectFieldDrawer,{...t}):p("div",{className:"DocEditor__ObjectField",children:p("div",{className:"DocEditor__ObjectField__fields",children:e.fields.map(o=>p(ir.Field,{field:o,deepKey:`${t.deepKey}.${o.id}`},o.id))})})};ir.ObjectFieldDrawer=t=>{let e=t.field,r=e.drawerOptions?.collapsed||!1,o=e.drawerOptions?.inline||!1,n=o?"left":"right",i=Py(),a=!r||i.value.includes(t.deepKey);return p("div",{className:Ne("DocEditor__ObjectFieldDrawer",o&&"DocEditor__ObjectFieldDrawer--inline"),children:p("details",{className:"DocEditor__ObjectFieldDrawer__drawer",open:a,children:[p("summary",{className:Ne("DocEditor__ObjectFieldDrawer__drawer__toggle",`DocEditor__ObjectFieldDrawer__drawer__toggle--icon-${n}`),children:[p(ir.FieldHeader,{className:"DocEditor__ObjectFieldDrawer__drawer__toggle__header",field:e,deepKey:t.deepKey}),p("div",{className:"DocEditor__ObjectFieldDrawer__drawer__toggle__icon",children:p(lc,{size:16})})]}),p("div",{className:"DocEditor__ObjectFieldDrawer__drawer__content DocEditor__ObjectFieldDrawer__fields",children:e.fields.map(s=>p(ir.Field,{field:s,deepKey:`${t.deepKey}.${s.id}`},s.id))})]})})};function Wet(t,e){switch(e.type){case"update":{let r=t._new||[];return{...e.newValue,_new:r}}case"updateItem":{let r=t??{},n=[...r._array||[]][e.index],i=e.newValue??{};return e.draft.updateKey(`${e.deepKey}.${n}`,i),{...r,[n]:i}}case"add":{let r=t??{},o=pi(),n=[...r._array||[],o];e.draft.updateKeys({[`${e.deepKey}._array`]:n,[`${e.deepKey}.${o}`]:{}});let i=t._new||[];return{...r,[o]:{},_array:n,_new:[...i,o]}}case"insertBefore":{let r=t??{},o=[...r._array||[]],n=pi();o.splice(e.index,0,n),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${n}`]:{}});let i=t._new||[];return{...r,[n]:{},_array:o,_new:[...i,n]}}case"insertAfter":{let r=t??{},o=[...r._array||[]],n=pi();o.splice(e.index+1,0,n),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${n}`]:{}});let i=t._new||[];return{...r,[n]:{},_array:o,_new:[...i,n]}}case"duplicate":{let r=t??{},o=[...r._array||[]],n=pi(),i=structuredClone(e.value);o.splice(e.index+1,0,n),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${n}`]:i});let a=t._new||[];return{...r,[n]:i,_array:o,_new:[...a,n]}}case"moveUp":{if(e.index===0)return t;let r=t??{},o=[...r._array||[]];return Whe(o,e.index,e.index-1),e.draft.updateKeys({[`${e.deepKey}._array`]:o}),{...r,_array:o,_moved:o[e.index-1]}}case"moveDown":{let r=t??{},o=[...r._array||[]];return e.index>=o.length-1?t:(Whe(o,e.index,e.index+1),e.draft.updateKeys({[`${e.deepKey}._array`]:o}),{...r,_array:o,_moved:o[e.index+1]})}case"moveTo":{let r=t??{},o=[...r._array||[]];if(e.fromIndex<0||e.fromIndex>=o.length||e.toIndex<0||e.toIndex>=o.length)return console.error("Invalid moveTo index",e),t;let n=o[e.fromIndex];return Ket(o,e.fromIndex,e.toIndex),e.draft.updateKeys({[`${e.deepKey}._array`]:o}),{...r,_array:o,_moved:n}}case"removeAt":{let r={...t??{}},n=[...r._array||[]],i=n[e.index];return delete r[i],n.splice(e.index,1),e.draft.updateKeys({[`${e.deepKey}._array`]:n}),e.draft.removeKey(`${e.deepKey}.${i}`),{...r,_array:n}}case"pasteAfter":{let r=t??{},o=[...r._array||[]],n=pi(),i=e.data;if(!i)return Re({title:"Skipped",message:"Nothing to paste.",autoClose:!0}),t;o.splice(e.index+1,0,n),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${n}`]:i});let a=t._new||[];return{...r,[n]:i,_array:o,_new:[...a,n]}}case"pasteBefore":{let r=t??{},o=[...r._array||[]],n=pi(),i=e.data;if(!i)return Re({title:"Skipped",message:"Nothing to paste.",autoClose:!0}),t;o.splice(e.index,0,n),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${n}`]:i});let a=t._new||[];return{...r,[n]:i,_array:o,_new:[...a,n]}}default:return console.error("unknown action",e),t}}ir.ArrayField=t=>{let e=Kn().controller,r=t.field,[o,n]=ei(Wet,{_array:[]}),i=Py(),a=Cae(),s=window.__ROOT_CTX.experiments||{},c=(o??{})._array||[],d=o._new||[];gl(t.deepKey,B=>{n({type:"update",newValue:B})}),V(()=>{o._moved&&v(t.deepKey,c.indexOf(o._moved))},[o]);let u=B=>{let $=c[B],z=`${t.deepKey}.${$}`;return e.getValue(z)||{}},f=()=>{n({type:"add",draft:e,deepKey:t.deepKey})},m=(B,$)=>{n({type:"pasteBefore",draft:e,deepKey:t.deepKey,index:B,data:$})},h=(B,$)=>{n({type:"pasteAfter",draft:e,deepKey:t.deepKey,index:B,data:$})},g=B=>{n({type:"insertBefore",draft:e,deepKey:t.deepKey,index:B})},_=B=>{n({type:"insertAfter",draft:e,deepKey:t.deepKey,index:B})},b=B=>{n({type:"duplicate",draft:e,deepKey:t.deepKey,index:B,value:u(B)})},y=B=>{n({type:"removeAt",draft:e,deepKey:t.deepKey,index:B})},v=(B,$)=>{document.getElementById(`summary-for-${B}.${c[$]}`)?.focus()},S=B=>{B>0&&n({type:"moveUp",draft:e,deepKey:t.deepKey,index:B})},N=B=>{B<c.length-1&&n({type:"moveDown",draft:e,deepKey:t.deepKey,index:B})},w=B=>{let $=u(B);a.set($)},E=vC(),I=are(),C=B=>{let $=u(B);E.open({data:$,onSave:z=>{console.log("[edit json] onSave()",z),n({type:"updateItem",draft:e,index:B,newValue:z,deepKey:t.deepKey}),E.close()}})},T=B=>{let $=u(B);I.open({data:$,onSave:z=>{console.log("[ai edit] onSave()",z),n({type:"updateItem",draft:e,index:B,newValue:z,deepKey:t.deepKey}),I.close()}})};function O(B){return!!i.value.startsWith(`${t.deepKey}.${B}`)}let A=qe((B,$)=>{B.target&&(B.key==="ArrowUp"?(B.preventDefault(),S(c.indexOf($))):B.key==="ArrowDown"?(B.preventDefault(),N(c.indexOf($))):B.key==="ArrowLeft"?B.target.closest("details").open=!1:B.key==="ArrowRight"&&(B.target.closest("details").open=!0))},[t.deepKey]),P=p("div",{className:"DocEditor__ArrayField__add",children:p(ee,{color:"dark",size:"xs",leftIcon:p(gh,{size:16}),onClick:()=>f(),children:r.buttonLabel||"Add"})});return c.length===0&&!o._new?p("div",{className:"DocEditor__ArrayField",children:[p("div",{className:"DocEditor__ArrayField__items",children:p("div",{className:"DocEditor__ArrayField__items__empty",children:"No items"})}),P]}):p("div",{className:"DocEditor__ArrayField",children:[p(hT,{onDragEnd:B=>{let{source:$,destination:z}=B;z&&n({type:"moveTo",fromIndex:$.index,toIndex:z.index,draft:e,deepKey:t.deepKey})},children:p(_T,{droppableId:"dnd-list",direction:"vertical",children:B=>p("div",{...B.droppableProps,ref:B.innerRef,className:"DocEditor__ArrayField__items",children:[c.map(($,z)=>p(gT,{index:z,draggableId:$,children:(H,q)=>p("div",{ref:H.innerRef,...H.draggableProps,className:Ne("DocEditor__ArrayField__item__wrapper",q.isDragging&&"DocEditor__ArrayField__item__wrapper--dragging"),children:[p("div",{className:"DocEditor__ArrayField__item__handle",...H.dragHandleProps,children:p(kb,{size:18,stroke:"1.5"})}),p("details",{className:"DocEditor__ArrayField__item",open:d.includes($)||O($),onToggle:Y=>{Y.target.open?Xa(`${t.deepKey}.${c[z]}`,{scroll:!0}):Xa(null)},onMouseEnter:()=>{Xa(`${t.deepKey}.${c[z]}`)},onMouseLeave:()=>{Xa(null)},children:[p("summary",{id:`summary-for-${t.deepKey}.${c[z]}`,className:"DocEditor__ArrayField__item__header",onKeyDown:Y=>A(Y,$),tabIndex:0,children:[p("div",{className:"DocEditor__ArrayField__item__header__icon",children:p(qM,{size:6})}),p(ir.ArrayFieldPreview,{field:r,deepKey:`${t.deepKey}.${$}`,index:z}),p("div",{className:"DocEditor__ArrayField__item__header__controls",children:[p("div",{className:"DocEditor__ArrayField__item__header__controls__arrows",children:[p("button",{className:"DocEditor__ArrayField__item__header__controls__arrow DocEditor__ArrayField__item__header__controls__arrows--up",onClick:()=>S(z),children:p(hM,{size:20,strokeWidth:1.75})}),p("button",{className:"DocEditor__ArrayField__item__header__controls__arrow DocEditor__ArrayField__item__header__controls__arrows--down",onClick:()=>N(z),children:p(mM,{size:20,strokeWidth:1.75})})]}),p(Be,{className:"DocEditor__ArrayField__item__header__controls__menu",position:"bottom",transitionDuration:0,control:p(Xe,{className:"DocEditor__ArrayField__item__header__controls__dots",children:p(Ef,{size:16})}),children:[p(Be.Label,{children:"INSERT"}),p(Be.Item,{className:"DocEditor__ArrayField__item__header__controls__menu__item",icon:p(kS,{size:18}),onClick:()=>g(z),children:"Add before"}),p(Be.Item,{className:"DocEditor__ArrayField__item__header__controls__menu__item",icon:p(TS,{size:18}),onClick:()=>_(z),children:"Add after"}),p(Be.Item,{className:"DocEditor__ArrayField__item__header__controls__menu__item",icon:p(cc,{size:18}),onClick:()=>b(z),children:"Duplicate"}),p(Be.Label,{children:"CLIPBOARD"}),p(Be.Item,{className:"DocEditor__ArrayField__item__header__controls__menu__item",icon:p(_M,{size:18}),onClick:()=>w(z),children:"Copy"}),p(Be.Item,{className:"DocEditor__ArrayField__item__header__controls__menu__item",icon:p(kS,{size:18}),onClick:async()=>m(z,await a.get()),children:"Paste before"}),p(Be.Item,{className:"DocEditor__ArrayField__item__header__controls__menu__item",icon:p(TS,{size:18}),onClick:async()=>h(z,await a.get()),children:"Paste after"}),p(Be.Label,{children:"CODE"}),p(Be.Item,{className:"DocEditor__ArrayField__item__header__controls__menu__item",icon:p(wb,{size:18}),onClick:()=>C(z),children:"Edit JSON"}),s.ai&&p(Be.Item,{className:"DocEditor__ArrayField__item__header__controls__menu__item",icon:p(Mb,{size:18,stroke:"1.75"}),onClick:()=>T(z),children:"Edit with AI"}),p(Be.Label,{children:"REMOVE"}),p(Be.Item,{className:"DocEditor__ArrayField__item__header__controls__menu__item",icon:p(qn,{size:18}),onClick:()=>y(z),children:"Remove"})]})]})]}),p("div",{className:"DocEditor__ArrayField__item__body",children:p(ir.Field,{field:r.of,deepKey:`${t.deepKey}.${$}`,hideHeader:!0,isArrayChild:!0,onFocus:()=>{Xa(`${t.deepKey}.${$}`,{scroll:!0})},onBlur:()=>{Xa(null)}},`${t.deepKey}.${$}`)})]},$)]})},$)),B.placeholder]})})}),P]})};ir.ArrayFieldPreview=t=>{let e=Kn().controller,[r,o]=M(e.getValue(t.deepKey)),n=pe(()=>Yet(t.field,r),[r]),i=pe(()=>Xet(t.field,r,t.index),[r,t.index]),a=qe(xT(()=>{let s=e.getValue(t.deepKey);o({...s})},250),[t.deepKey,e]);return V(()=>e.on("VALUE_CHANGE",(s,l)=>{s===t.deepKey?o(l):s.startsWith(t.deepKey)&&a()}),[t.deepKey,e]),p("div",{className:"DocEditor__ArrayField__item__header__preview",children:[n&&p("div",{className:"DocEditor__ArrayField__item__header__preview__image",children:p("img",{src:n,alt:"",className:"DocEditor__ArrayField__item__header__preview__image__img",loading:"lazy"})}),p("div",{className:"DocEditor__ArrayField__item__header__preview__title",children:i})]})};ir.OneOfField=t=>{let e=t.field,[r,o]=M(""),n=zk(),i={},a=[{value:"",label:e.placeholder||"Select type"}];e.types.forEach(f=>{typeof f=="string"?(i[f]=n[f],a.push({value:f,label:f})):(i[f.name]=f,a.push({value:f.name,label:f.name}))});let s=i[r||""],l=Kn().controller,c=pe(()=>({}),[]);async function d(f){let m={};if(f){if(f in c){let h=c[f];Object.assign(m,h)}else if(f in i){let h=Ud(i[f]);Object.assign(m,h)}}m._type=f,await l.updateKey(t.deepKey,m),o(f)}gl(t.deepKey,f=>{f?._type&&(o(f._type||""),c[f._type]=f)});function u(f){let m=f.target;m&&m.select&&m.select()}return p("div",{className:"DocEditor__OneOfField",children:[p("div",{className:"DocEditor__OneOfField__select",children:[p("div",{className:"DocEditor__OneOfField__select__label",children:"Type:"}),p(Sr,{data:a,value:r,placeholder:e.placeholder,onChange:f=>d(f||""),onFocus:u,size:"xs",radius:0,searchable:!0,dropdownComponent:"div"})]}),s&&p("div",{className:"DocEditor__OneOfField__fields",children:s.fields.map(f=>p(ir.Field,{field:f,deepKey:`${t.deepKey}.${f.id}`,onBlur:()=>{Xa(null)},onFocus:()=>{Xa(`${t.deepKey}.${f.id}`,{scroll:!0})}},`${r}::${f.id}`))})]})};function Whe(t,e,r){if(t.length<=1)return t;let o=t[e];return t[e]=t[r],t[r]=o,t}function Ket(t,e,r){let[o]=t.splice(e,1);t.splice(r,0,o)}function Yhe(t,e,r="title"){let o=zk();if(t.type==="oneof"){let n=t,i=e?._type;if(i){let a,s=n.types||[];return typeof s[0]=="string"?a=o[i]:a=s.find(l=>l.name===i),a?.preview?.[r]||null}}return null}function Yet(t,e){let r=Yhe(t.of,e,"image");if(r)return rg(r,e)}function Xet(t,e,r){let o=Yhe(t.of,e,"title");if(o){let n=rg(o,e,{index:r});if(n)return n}return t.preview?rg(t.preview,e,{index:r})??`item ${r}`:`item ${r}`}function Uk(t,e,r=""){let o=fC({collectionId:t,slug:e}),n=new URLSearchParams(window.location.search);n.set("preview","true"),n.has("locale")&&n.delete("locale");let i=`${n.toString()}${window.location.hash}`;return r?`${fC({collectionId:t,slug:e,locale:r})}?${i}`:`${o}?${i}`}function Vk(t){let e=t.collection,r=t.slug,o=`${e}/${r}`;return p(Eae,{docId:o,children:p(Jet,{...t})})}function Jet(t){let e=t.collection,r=t.slug,o=`${e}/${r}`,n=window.__ROOT_CTX.collections[e],i=Kn(),[a,s]=Vd(`root::DocumentPage::previewVisible::${e}`,!0);if(!n)return p("div",{children:"Could not find collection."});function l(){let f=Uk(e,r),m=window.open(f,"_blank","noopener,noreferrer");m&&m.focus()}let c=qe(()=>{i.controller&&i.controller.flush()},[i.controller]),d=vC(),u=qe(()=>{let f=i.controller?.getData()?.fields||{};d.open({data:f,onSave:m=>{i.controller&&m&&typeof m=="object"&&(i.controller.updateKey("fields",m),i.controller.flush()),d.close()}})},[i.controller]);return ZN([["mod+S",c]]),p(Fe,{children:p(_c,{className:"DocumentPage",localStorageId:"DocumentPage",children:[p(_c.Item,{className:Ne("DocumentPage__side",!a&&"DocumentPage__side--expanded"),children:[p("div",{className:"DocumentPage__side__header",children:[p("div",{className:"DocumentPage__side__header__nav",children:[p("a",{href:`/cms/content/${e}`,children:p(Xe,{className:"DocumentPage__side__header__back",children:p(dM,{size:16})})}),p("div",{className:"DocumentPage__side__header__docId",children:o})]}),p("div",{className:"DocumentPage__side__header__buttons",children:[p(ee,{className:"DocumentPage__side__header__saveButton",variant:"filled",color:"dark",size:"xs",compact:!0,leftIcon:p(Cb,{size:16}),onClick:()=>c(),children:"Save"}),p(Te,{label:"Edit JSON",children:p(Xe,{className:"DocumentPage__side__header__editJson",onClick:()=>u(),children:p(wb,{size:14})})}),p(Te,{label:a?"Hide preview":"Show preview",children:p(Xe,{className:"DocumentPage__side__header__previewToggle",onClick:()=>s(!a),children:a?p(AM,{size:16}):p(RM,{size:16})})}),!a&&p(Te,{label:"Open preview in new tab",children:p(Xe,{className:"DocumentPage__side__header__openNewTab",onClick:l,children:p(Sd,{size:16})})})]})]}),p("div",{className:Ne("DocumentPage__side__editor",!a&&"DocumentPage__side__editor--centered"),children:p(ir,{docId:o})})]}),p(_c.Item,{className:Ne("DocumentPage__main",!a&&"DocumentPage__main--hidden"),fluid:!0,children:a&&p(Vk.Preview,{docId:o},o)})]})})}var Xhe={mobile:[360,800],tablet:[768,1024],desktop:[1440,800]};function Qet(t){let e=new Intl.DisplayNames(["en"],{type:"language"}),o=t.split("_")[0];return`${e.of(o)||t} (${t})`}Vk.Preview=t=>{let e=Kn();if(e.loading)return null;let[r,o]=t.docId.split("/"),i=window.__ROOT_CTX.collections[r];if(!i)throw new Error(`collection not found: ${r}`);let a=i.domain||window.__ROOT_CTX.rootConfig.domain||"https://example.com",s=r2({collectionId:r,slug:o}),l=fC({collectionId:r,slug:o}),c=`${a}${s}`,[d,u]=M(c),[f,m]=Vd("root::DocumentPage::preview::device",""),[h,g]=Vd("root::DocumentPage::preview::expandVertically",!1),[_,b]=M({"--iframe-width":"100%","--iframe-height":"100%","--iframe-scale":"1"}),[y,v]=yne("locale",""),S=G(null),N=e.controller.getLocales()||[],w=hne(),E=Uk(r,o),I=Uk(r,o,y),C=[{value:"",label:"Select locale"},...N.map(z=>({value:z,label:Qet(z)}))];function T(){let z=S.current;z.src="about:blank",window.setTimeout(()=>{z.src!==I?z.src=I:z.contentWindow.location.reload()},30)}V(()=>{let z=S.current;function H(){let Y=z.contentWindow;if(Y&&l===s&&!Y.location.href.startsWith("about:blank")){let L=Y.location.pathname;u(`${a}${L}`)}}z.addEventListener("load",H);let q=e.controller?.onFlush(()=>{T()});return()=>{q(),z.removeEventListener("load",H)}},[]),V(()=>{let z=S.current;z.src=I},[y]);function O(z){m(H=>{let q=H===z?"":z;return q===""&&g(!1),q})}function A(){f&&g(z=>!z)}function P(){e.controller&&e.controller.flush().then(()=>T())}function B(){let z=Uk(r,o,y),H=window.open(z,"_blank","noopener,noreferrer");H&&H.focus()}function $(){if(f===""){b({"--iframe-width":"100%","--iframe-height":"100%","--iframe-scale":"1"});return}let q=S.current.parentElement.parentElement.getBoundingClientRect(),[Y,L]=Xhe[f],ne=20,ae=Math.max(q.width-2*ne,0),U=Math.max(q.height-2*ne,0),ge=ae>0&&Y>0?ae/Y:1,Ee=U>0&&L>0?U/L:1,Ve=Math.min(ge,Ee,1),Ye=Number(Ve.toFixed(4))||1,Ae=h?`${U/Ye}px`:`${L}px`;b({"--iframe-width":`${Y}px`,"--iframe-height":Ae,"--iframe-scale":String(Ye)})}return V(()=>{$();let z=w.onResize($);return window.addEventListener("resize",$),()=>{z(),window.removeEventListener("resize",$)}},[f,w,h]),p("div",{className:"DocumentPage__main__preview",children:[p("div",{className:"DocumentPage__main__previewBar",children:[p("div",{className:"DocumentPage__main__previewBar__devices",children:[p(Te,{label:"Mobile",children:p(Xe,{className:Ne("DocumentPage__main__previewBar__device",f==="mobile"&&"active"),onClick:()=>O("mobile"),children:p(IM,{size:16})})}),p(Te,{label:"Tablet",children:p(Xe,{className:Ne("DocumentPage__main__previewBar__device",f==="tablet"&&"active"),onClick:()=>O("tablet"),children:p(vM,{size:16})})}),p(Te,{label:"Desktop",children:p(Xe,{className:Ne("DocumentPage__main__previewBar__device",f==="desktop"&&"active"),onClick:()=>O("desktop"),children:p(yM,{size:16})})}),p(Te,{label:"Expand",children:p(Xe,{className:Ne("DocumentPage__main__previewBar__device",h&&"active"),"aria-pressed":h,disabled:f==="",onClick:A,children:p(fM,{size:16})})})]}),p("div",{className:"DocumentPage__main__previewBar__navbar",children:p("div",{className:"DocumentPage__main__previewBar__navbar__url",children:d})}),p("div",{className:"DocumentPage__main__previewBar__locales",children:p(Sr,{data:C,placeholder:"Locale",radius:"xl",size:"xs",required:!0,icon:p(jM,{size:16,strokeWidth:1.5}),value:y,onChange:z=>{v(z)}})}),p("div",{className:"DocumentPage__main__previewBar__buttons",children:[p(Te,{label:"Reload",children:p(Xe,{className:"DocumentPage__main__previewBar__button DocumentPage__main__previewBar__button--reload",onClick:()=>P(),children:p(VM,{size:16})})}),p(Te,{label:"Open new tab",children:p(Xe,{className:"DocumentPage__main__previewBar__button DocumentPage__main__previewBar__button--openNewTab",onClick:()=>B(),children:p(Sd,{size:16})})})]})]}),p("div",{className:"DocumentPage__main__previewFrame","data-device":f||"full",style:_,children:[f&&p("div",{className:"DocumentPage__main__previewFrame__deviceLabel",children:`${f}: ${Xhe[f].join("x")}`}),p("div",{className:"DocumentPage__main__previewFrame__iframeWrap",children:p("iframe",{ref:S,src:E,title:"iframe preview"})})]})]})};we();var Zet="Enter the URL to make the HTTP request.",ett="Enter the URL of the Google Sheet, e.g. https://docs.google.com/spreadsheets/d/SPREADSHEET_ID/edit#gid=SHEET_ID";function Hk(t){let e=G(null),r=Fd(),[o,n]=M(!1),[i,a]=M(r.enabled?"gsheet":"http"),[s,l]=M("map"),[c,d]=M("GET"),[u,f]=M(""),[m,h]=M(!!t.dataSourceId),[g,_]=M(null),b="";i==="http"?b=Zet:i==="gsheet"&&(b=ett);async function y(N){await or(async()=>{let w=await Vf(N);_(w),a(w?.type||"http"),l(w?.dataFormat||"map")}),h(!1)}V(()=>{t.dataSourceId&&(h(!0),y(t.dataSourceId))},[t.dataSourceId]);async function v(){f("");let N=e.current;function w(T){let O=N.elements[T];return O?O.value.trim():""}let E=t.dataSourceId||w("id");if(!E){f("missing id");return}if(!pl(E)){f("id is invalid (alphanumeric characters and dashes only)");return}let I=w("url");if(!I){f("missing url");return}let C={id:E,description:w("description"),type:i,url:I,previewUrl:w("previewUrl")};if(i==="http"){if(!ttt(I)){f("invalid url");return}C.httpOptions={method:c};let T=w("httpHeaders");if(T&&(C.httpOptions.headers=rtt(T)),c==="POST"){let O=w("httpBody");O&&(C.httpOptions.body=O)}}else if(i==="gsheet"){if(!Rd(I)?.spreadsheetId){f("failed to parse spreadsheet url");return}C.dataFormat=s||"map"}try{_(C),n(!0),t.dataSourceId?(await pre(t.dataSourceId,C),Re({title:"Saved data source",message:`Successfully updated ${E}`,autoClose:5e3}),n(!1)):(await fre(E,C),Re({title:"Added data source",message:`Successfully added ${E}`,autoClose:5e3}),n(!1),_o(`/cms/data/${E}`))}catch(T){console.error(T),Re({title:"Failed to save data source",message:String(T),color:"red",autoClose:!1}),n(!1)}}let S=[{value:"http",label:"HTTP"}];return(r.enabled||i==="gsheet")&&S.push({value:"gsheet",label:"Google Sheet"}),p("form",{className:"DataSourceForm",ref:e,onSubmit:N=>{N.preventDefault(),v()},children:[p(Ma,{visible:m}),p("div",{className:"DataSourceForm__input",children:p(Sr,{name:"type",label:"Type",data:S,value:i,onChange:N=>a(N),size:"xs",radius:0,dropdownComponent:"div"})}),p(tr,{className:"DataSourceForm__input",name:"id",label:"ID",description:"Unique identifier for the data source. Use alphanumeric characters and dashes only, e.g. grogus-favorite-meals",size:"xs",radius:0,value:t.dataSourceId,disabled:!!t.dataSourceId}),p(hr,{className:"DataSourceForm__input",name:"description",label:"Description",description:"Optional.",size:"xs",radius:0,value:g?.description}),p(tr,{className:"DataSourceForm__input",name:"url",label:"URL",description:b,size:"xs",radius:0,value:g?.url}),i==="http"&&p(Ce,{children:[p("div",{className:"DataSourceForm__input",children:p(Sr,{name:"httpMethod",label:"HTTP Request Method",data:[{value:"GET",label:"GET"},{value:"POST",label:"POST"}],value:c,onChange:N=>d(N),size:"xs",radius:0,dropdownComponent:"div"})}),p(hr,{className:"DataSourceForm__input",name:"httpHeaders",label:"HTTP Request Headers",description:"Format as `HeaderName: Value`, each value on its own line.",size:"xs",radius:0,value:ott(g?.httpOptions?.headers||{})}),c==="POST"&&p(hr,{className:"DataSourceForm__input",name:"httpRequestBody",label:"HTTP Request Body",size:"xs",radius:0,value:g?.httpOptions?.body})]}),i==="gsheet"&&p("div",{className:"DataSourceForm__input",children:[p(Sr,{name:"dataFormat",label:"Data Format",data:[{value:"map",label:"map"}],value:s,onChange:N=>l(N),size:"xs",radius:0,dropdownComponent:"div"}),s==="array"&&p("div",{className:"DataSourceForm__input__example",children:["Data is stored as an array of arrays, e.g.",p("code",{children:"[[header1, header2], [foo, bar]]"})]}),s==="map"&&p("div",{className:"DataSourceForm__input__example",children:["Data is stored as an array of maps, e.g.",p("code",{children:["[","{","header1: foo, header2: bar","}","]"]})]})]}),p(tr,{className:"DataSourceForm__input",name:"previewUrl",label:"Preview URL",description:"URL where users can preview the data source.",size:"xs",radius:0,value:g?.previewUrl}),p(ee,{className:"DataSourceForm__submit",color:"blue",size:"xs",type:"submit",loading:o,children:t.buttonLabel||"Save"}),u&&p("div",{className:"DataSourceForm__error",children:["Error: ",u]})]})}function ttt(t){let e,r=t.startsWith("/")?"http://localhost":void 0;try{e=new URL(t,r)}catch(o){return console.error(o),!1}return e.protocol==="http:"||e.protocol==="https:"}function rtt(t){let e={};return t.split(`
246
246
  `).forEach(o=>{let n=o.indexOf(":");if(n===-1)return;let i=o.slice(0,n).trim(),a=o.slice(n+1).trim();i&&a&&(e[i]=a)}),e}function ott(t){let e=[];for(let r in t){let o=t[r];e.push(`${r}: ${o}`)}return e.join(`
247
- `)}function Jhe(t){let e=Ct(),r=Vt();function o(){let n=`delete-data-source-${t.id}`,i=e.openConfirmModal({...r,title:"Delete data source",children:p(Je,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to delete data source ",p("code",{children:t.id}),"? All previously synced data will be deleted. There is no undo."]}),labels:{confirm:"Delete",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{Re({id:n,title:"Deleting data source",message:`Deleting ${t.id} and synced data...`,loading:!0,autoClose:!1}),await _re(t.id),jt({id:n,title:"Deleted data source",message:`Successfully deleted ${t.id}`,loading:!1,autoClose:5e3}),e.closeModal(i),_o("/cms/data")}})}return p(Fe,{children:p("div",{className:"EditDataSourcePage",children:[p("div",{className:"EditDataSourcePage__header",children:[p(wo,{className:"EditDataSourcePage__header__breadcrumbs",children:[p("a",{href:"/cms/data",children:"Data Sources"}),p("a",{href:`/cms/data/${t.id}`,children:t.id}),p("div",{children:"Edit"})]}),p("div",{className:"EditDataSourcePage__header__titleWrap",children:[p(tt,{size:"h1",children:["Edit Data Source: ",t.id]}),p("div",{className:"EditDataSourcePage__header__controls",children:p(Te,{label:"Delete",children:p(Xe,{onClick:o,children:p(zb,{size:20,stroke:"1.5"})})})})]})]}),p(Hk,{dataSourceId:t.id})]})})}we();function Iu(t){let e=G(null),[r,o]=M(!1),[n,i]=M(""),[a,s]=M(!!t.releaseId),[l,c]=M(null),[d,u]=M([]),[f,m]=M([]),h=yC(),g=bre();async function _(w){console.log(w),await or(async()=>{let E=await Wf(w);c(E),u(E?.docIds||[]),m(E?.dataSourceIds||[])}),s(!1)}V(()=>{t.releaseId&&(s(!0),_(t.releaseId))},[t.releaseId]);async function b(){i("");let w=e.current;function E(T){let O=w.elements[T];return O?O.value.trim():""}let I=t.releaseId||E("id");if(!I){i("missing id");return}if(!pl(I)){i("id is invalid (alphanumeric characters and dashes only)");return}let C={id:I,description:E("description"),docIds:d,dataSourceIds:f};try{c(C),o(!0),t.releaseId?(await Woe(t.releaseId,C),Re({title:"Saved release",message:`Updated ${I}`,autoClose:5e3}),o(!1)):(await qoe(I,C),Re({title:"Added release",message:`Successfully added ${I}`,autoClose:5e3}),o(!1)),_o(`/cms/releases/${I}`)}catch(T){console.error(T),Re({title:"Failed to save release",message:String(T),color:"red",autoClose:!1}),o(!1)}}function y(){h.open({selectedDocIds:d,onChange:(w,E)=>{u(I=>{let C=[...I];if(E)C.push(w);else{let T=C.findIndex(O=>O===w);T>-1&&C.splice(T,1)}return console.log(C),C.sort()})}})}function v(){g.open({selectedDataSourceIds:f,onChange:(w,E)=>{m(I=>{let C=[...I];if(E)C.push(w);else{let T=C.indexOf(w);T>-1&&C.splice(T,1)}return C.sort()})}})}function S(w){console.log("onRemoveDoc()",w),u(E=>{let I=[...E],C=I.indexOf(w);return C!==-1&&I.splice(C,1),console.log(I),I})}function N(w){m(E=>{let I=[...E],C=I.indexOf(w);return C!==-1&&I.splice(C,1),I})}return p("form",{className:"ReleaseForm",ref:e,onSubmit:w=>{w.preventDefault(),b()},children:[p(Ma,{visible:a}),p(tr,{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,value:t.releaseId,disabled:!!t.releaseId}),p(hr,{className:"ReleaseForm__input",name:"description",label:"Description",description:"Optional.",size:"xs",radius:0,value:l?.description}),p(Nn,{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:[d.length>0&&p(Iu.DocPreviewCards,{docIds:d,onRemoveDoc:S}),p(ee,{className:"ReleaseForm__docSelectButton",color:"dark",size:"xs",onClick:()=>y(),children:"Select"})]}),p(Nn,{className:"ReleaseForm__input",label:"Data Sources",description:"Optional. Data sources to publish with the release.",size:"xs",children:[f.length>0&&p(Iu.DataSourceIds,{ids:f,onRemove:N}),p(ee,{className:"ReleaseForm__docSelectButton",color:"dark",size:"xs",onClick:()=>v(),children:"Select"})]}),p("div",{className:"ReleaseForm__submit__buttons",children:p(ee,{className:"ReleaseForm__submit",color:"blue",size:"xs",type:"submit",loading:r,children:t.buttonLabel||"Save"})}),n&&p("div",{className:"ReleaseForm__error",children:["Error: ",n]})]})}Iu.DocPreviewCards=t=>p("div",{className:"ReleaseForm__DocPreviewCards",children:t.docIds.map(e=>p("div",{className:"ReleaseForm__DocPreviewCards__card",children:[p(ig,{className:"ReleaseForm__DocPreviewCards__card__preview",docId:e}),p("div",{className:"ReleaseForm__DocPreviewCards__card__controls",children:[p("div",{className:"ReleaseForm__DocPreviewCards__card__controls__remove",children:p(Te,{label:"Remove",children:p(Xe,{className:"ReleaseForm__DocPreviewCards__card__controls__remove__icon",onClick:()=>t.onRemoveDoc(e),children:p(qn,{size:16})})})}),p("div",{className:"ReleaseForm__DocPreviewCards__card__controls__open",children:p(Te,{label:"Open",children:p(Xe,{component:"a",className:"ReleaseForm__DocPreviewCards__card__controls__open__icon",href:`/cms/content/${e}`,target:"_blank",children:p(Sd,{size:16})})})})]})]},e))});Iu.DataSourceIds=t=>p("div",{className:"ReleaseForm__DataSourceIds",children:t.ids.map(e=>p("div",{className:"ReleaseForm__DataSourceIds__item",children:[p("span",{className:"ReleaseForm__DataSourceIds__item__id",children:e}),p(Xe,{className:"ReleaseForm__DataSourceIds__item__remove",onClick:()=>t.onRemove(e),children:p(qn,{size:16})})]},e))});function Qhe(t){let e=Ct(),r=Vt();function o(){let n=`delete-release-${t.id}`,i=e.openConfirmModal({...r,title:"Delete release",children:p(Je,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to delete release ",p("code",{children:t.id}),"? There is no undo. This will only delete the release; the docs in the release will remain unchanged."]}),labels:{confirm:"Delete",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{Re({id:n,title:"Deleting release",message:`Deleting ${t.id}...`,loading:!0,autoClose:!1}),await Koe(t.id),jt({id:n,title:"Deleted release",message:`Successfully deleted ${t.id}`,loading:!1,autoClose:5e3}),e.closeModal(i),_o("/cms/releases")}})}return p(Fe,{children:p("div",{className:"EditReleasePage",children:[p("div",{className:"EditReleasePage__header",children:[p(wo,{className:"EditReleasePage__header__breadcrumbs",children:[p("a",{href:"/cms/releases",children:"Releases"}),p("a",{href:`/cms/releases/${t.id}`,children:t.id}),p("div",{children:"Edit"})]}),p("div",{className:"EditReleasePage__header__titleWrap",children:[p(tt,{size:"h1",children:["Edit Release: ",t.id]}),p("div",{className:"EditReleasePage__header__controls",children:p(Te,{label:"Delete",children:p(Xe,{onClick:o,children:p(zb,{size:20,stroke:"1.5"})})})})]})]}),p(Iu,{releaseId:t.id})]})})}we();function jk(t){let e=t.limit||40,[r,o]=M(!0),[n,i]=M([]);async function a(){let s=await NQ({limit:e});i(s),o(!1)}return V(()=>{a()},[]),r?p("div",{className:"ActionsLog ActionsLog--loading",children:p(et,{color:"gray",size:"xl"})}):p("div",{className:"ActionsLog",children:p(ho,{className:"ActionsLog__table",children:[p("thead",{children:p("tr",{className:"ActionsLogs__table__row ActionsLogs__table__row--header",children:[p("th",{className:"ActionsLogs__table__header",children:"timestamp"}),p("th",{className:"ActionsLogs__table__header",children:"user"}),p("th",{className:"ActionsLogs__table__header",children:"action"}),p("th",{className:"ActionsLogs__table__header",children:"quick links"})]})}),p("tbody",{children:n.map(s=>p("tr",{className:"ActionsLogs__table__row",children:[p("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--nowrap",children:ntt(s.timestamp)}),p("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--nowrap",children:s.by}),p("td",{className:"ActionsLogs__table__col",children:[s.action," ",itt(s.metadata)]}),p("td",{className:"ActionsLogs__table__col",children:p("div",{className:"ActionsLogs__table__buttons",children:[s.action!=="doc.delete"&&s.metadata?.docId&&p(Te,{transition:"pop",label:s.metadata.docId,children:p(ee,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/content/${s.metadata?.docId}`,children:"Open doc"})}),s.action!=="datasource.delete"&&s.metadata?.datasourceId&&p(Te,{transition:"pop",label:s.metadata.datasourceId,children:p(ee,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/data/${s.metadata?.datasourceId}`,children:"Open release"})}),s.action!=="release.delete"&&s.metadata?.releaseId&&p(Te,{transition:"pop",label:s.metadata.releaseId,children:p(ee,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/releases/${s.metadata?.releaseId}`,children:"Open release"})}),s.metadata?.sheetId&&p(ee,{component:"a",variant:"default",size:"xs",compact:!0,href:ja(s.metadata.sheetId),target:"_blank",children:"Open sheet"}),s.action.startsWith("acls.")&&p(ee,{component:"a",variant:"default",size:"xs",compact:!0,href:"/cms/settings",children:"Open settings"})]})})]}))})]})})}function ntt(t){return t.toDate().toLocaleString("sv-SE",{dateStyle:"short",timeStyle:"medium"})}function itt(t){function e(r){return r===null?"null":typeof r>"u"?"undefined":typeof r=="string"?`"${r.replaceAll('"','\\"')}"`:typeof r!="object"?String(r):Array.isArray(r)?`[${r.map(e).join(", ")}]`:`{${Object.entries(r).map(([n,i])=>`${n}: ${e(i)}`).join(", ")}}`}return e(t)}var Zhe=250;function ege(){return p(Fe,{children:p("div",{className:"LogsPage",children:[p("div",{className:"LogsPage__header",children:[p(tt,{size:"h1",children:"Action Logs"}),p(Je,{as:"p",children:["The latest ",Zhe," actions are displayed here. View all past actions in the"," ",p("a",{href:att(),target:"_blank",children:"Firebase Console"}),"."]})]}),p(jk,{limit:Zhe})]})})}function att(){let t=window.__ROOT_CTX.firebaseConfig,e=t.projectId,r=window.__ROOT_CTX.rootConfig.projectId,o=t.databaseId||"-default-",n=`/Projects/${r}/ActionLogs`.replaceAll("/","~2F");return`https://console.firebase.google.com/project/${e}/firestore/databases/${o}/data/${n}`}function tge(){return p(Fe,{children:p("div",{className:"NewDataSourcePage",children:[p("div",{className:"NewDataSourcePage__header",children:[p(wo,{className:"NewDataSourcePage__header__breadcrumbs",children:[p("a",{href:"/cms/data",children:"Data Sources"}),p("div",{children:"New"})]}),p(tt,{size:"h1",children:"Add Data Source"})]}),p(Hk,{buttonLabel:"Create data source"})]})})}function rge(){return p(Fe,{children:p("div",{className:"NewReleasePage",children:[p("div",{className:"NewReleasePage__header",children:[p(wo,{className:"NewReleasePage__header__breadcrumbs",children:[p("a",{href:"/cms/releases",children:"Releases"}),p("div",{children:"New"})]}),p(tt,{size:"h1",children:"Add Release"})]}),p(Iu,{buttonLabel:"Create release"})]})})}function oge(){return p(Fe,{children:p("div",{className:"NotFoundPage",children:[p("div",{className:"NotFoundPage__icon",children:p(Ab,{size:60})}),p("h2",{className:"NotFoundPage__title",children:"Not Found"}),p("p",{className:"NotFoundPage__body",children:["Double-check the URL and try again or ",p("a",{href:"/cms",children:"go home"}),"."]})]})})}function qk(){let t=window.__ROOT_CTX.rootConfig.projectName||"Root CMS";return p(Fe,{children:p("div",{className:"ProjectPage",children:[p("div",{className:"ProjectPage__headline",children:p(tt,{className:"ProjectPage__title",size:"h1",children:t})}),p("div",{className:"ProjectPage__section",children:[p(tt,{className:"ProjectPage__section__title",size:"h2",children:"Content"}),p(qk.CollectionList,{})]}),p("div",{className:"ProjectPage__section",children:[p(tt,{className:"ProjectPage__section__title ProjectPage__section__title--flex",size:"h2",children:[p("div",{children:"Recent actions"}),p("div",{children:p(ee,{component:"a",variant:"default",size:"xs",compact:!0,href:"/cms/logs",children:"Show all"})})]}),p(jk,{limit:20})]})]})})}qk.CollectionList=()=>{let t=Object.keys(window.__ROOT_CTX.collections).map(e=>({...window.__ROOT_CTX.collections[e],id:e}));return p("div",{className:"ProjectPage__collectionList",children:[t.map(e=>p("a",{className:"ProjectPage__collectionList__collection",href:`/cms/content/${e.id}`,children:[p("div",{className:"ProjectPage__collectionList__collection__icon",children:p(Cf,{size:20,strokeWidth:"1.75"})}),p("div",{className:"ProjectPage__collectionList__collection__name",children:e.name||e.id}),e.description&&p("div",{className:"ProjectPage__collectionList__collection__desc",children:e.description})]},e.id)),t.length===0&&p("div",{className:"ProjectPage__collectionList__collections__empty",children:"No collections match your query."})]})};we();var nge={transition:"pop"};function Gk(t){let e=t.release;return e.scheduledAt?p(Te,{...nge,label:`Scheduled ${ltt(e.scheduledAt)} by ${e.scheduledBy}`,wrapLines:!0,width:240,children:p(fs,{size:"xs",variant:"gradient",gradient:{from:"grape",to:"pink",deg:35},children:"Scheduled"})}):e.publishedAt?p(Te,{...nge,label:`Published ${stt(e.publishedAt)} by ${e.publishedBy}`,children:p(fs,{size:"xs",variant:"gradient",gradient:{from:"teal",to:"lime",deg:105},children:"Published"})}):p(fs,{size:"xs",variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:"Unpublished"})}function stt(t){return t?Va(t.toMillis()):Va(new Date().getTime())}function ltt(t){return new Date(t.toMillis()).toLocaleDateString("en",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function wu(t){let[e,r]=M(!0),[o,n]=M(null),[i,a]=M(0),s=t.id;async function l(){r(!0),await or(async()=>{let d=await Wf(s);n(d),a(Ub())}),r(!1)}V(()=>{l()},[]);function c(d){console.log("onAction()",d),l()}return p(Fe,{children:p("div",{className:"ReleasePage",children:[p("div",{className:"ReleasePage__header",children:[p(wo,{className:"ReleasePage__header__breadcrumbs",children:[p("a",{href:"/cms/releases",children:"Releases"}),p("div",{children:s})]}),p("div",{className:"ReleasePage__header__titleWrap",children:[p(tt,{size:"h1",children:["Release: ",s]}),p("div",{className:"ReleasePage__header__controls",children:p(Te,{label:"Configure",children:p(Xe,{component:"a",href:`/cms/releases/${t.id}/edit`,children:p(Nf,{size:24,stroke:"1.5"})})})})]}),o?.description&&p(Je,{as:"p",children:o.description})]}),e?p(et,{color:"gray",size:"xl"}):p(Ce,{children:[o&&p(wu.PublishStatus,{release:o,onAction:c}),o&&o.docIds&&o.docIds.length>0&&p(wu.DocsList,{release:o},`docs-list-${i}`),o&&o.dataSourceIds&&o.dataSourceIds.length>0&&p(wu.DataSourcesList,{release:o},`data-sources-${i}`)]})]})})}wu.PublishStatus=t=>{let e=t.release,[r,o]=M(!1),n=Ct(),i=Vt(),a=Zoe({releaseId:e.id,onScheduled:()=>{t.onAction("scheduled")}});function s(){let u=e.docIds||[],f=e.dataSourceIds||[],m=u.length+f.length;if(m===0){Re({title:"Cannot publish release",message:"Error: nothing in the release to publish.",color:"red",autoClose:!1});return}n.openConfirmModal({...i,title:`Publish release: ${e.id}`,children:p(Je,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to publish this release? The ",m," items in the release will go live immediately."]}),labels:{confirm:"Publish",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"dark",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!0,onConfirm:()=>{l()}})}async function l(){o(!0),await or(async()=>{let u=`publish-release-${e.id}`,f=e.docIds?.length||0,m=e.dataSourceIds?.length||0,h=f+m;Re({id:u,title:"Publishing release",message:`Publishing ${h} items...`,loading:!0,autoClose:!1}),await Yoe(e.id),jt({id:u,title:"Published release!",message:`Successfully published ${h} items!`,loading:!1,autoClose:5e3}),t.onAction&&t.onAction("publish")}),o(!1)}function c(){a.open()}async function d(){await Joe(e.id),t.onAction("cancel-schedule")}return p("div",{className:"ReleasePage__PublishStatus",children:[p(tt,{size:"h2",children:"Status"}),p(ho,{verticalSpacing:"xs",striped:!0,fontSize:"xs",children:[p("thead",{children:p("tr",{children:[p("th",{children:"status"}),p("th",{children:"actions"})]})}),p("tbody",{children:p("tr",{children:[p("td",{children:p(Gk,{release:e})}),p("td",{children:p("div",{className:"ReleasePage__PublishStatus__actions",children:[!e.scheduledAt&&p(Te,{label:"Publish the release immediately",position:"bottom",withArrow:!0,children:p(ee,{variant:"default",size:"xs",compact:!0,onClick:()=>s(),loading:r,children:e.publishedAt?"Re-publish":"Publish"})}),e.scheduledAt?p(Te,{label:"Cancel the scheduled release",position:"bottom",withArrow:!0,children:p(ee,{variant:"default",size:"xs",compact:!0,onClick:()=>d(),children:"Cancel Schedule"})}):p(Te,{label:"Schedule the release to be published at a future date",position:"bottom",withArrow:!0,wrapLines:!0,width:180,children:p(ee,{variant:"default",size:"xs",compact:!0,onClick:()=>c(),children:"Schedule"})})]})})]})})]})]})};wu.DocsList=t=>{let e=t.release,r=e.docIds||[];return p("div",{className:"ReleasePage__DocsList",children:[p("div",{className:"ReleasePage__DocsList__header",children:[p(tt,{size:"h2",children:"Docs"}),p(ee,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/releases/${e.id}/edit`,children:"Edit"})]}),p("div",{className:"ReleasePage__DocsList__cards",children:r.map(o=>p("div",{className:"ReleasePage__DocsList__card",children:p("a",{href:`/cms/content/${o}`,children:p(ig,{docId:o,statusBadges:!0})})},o))})]})};wu.DataSourcesList=t=>{let e=t.release,r=e.dataSourceIds||[];return p("div",{className:"ReleasePage__DataSourcesList",children:[p("div",{className:"ReleasePage__DataSourcesList__header",children:[p(tt,{size:"h2",children:"Data Sources"}),p(ee,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/releases/${e.id}/edit`,children:"Edit"})]}),p("div",{className:"ReleasePage__DataSourcesList__items",children:r.map(o=>p("div",{className:"ReleasePage__DataSourcesList__item",children:p("a",{href:`/cms/data/${o}`,children:o})},o))})]})};we();function Wk(){return p(Fe,{children:p("div",{className:"ReleasesPage",children:[p("div",{className:"ReleasesPage__header",children:[p(tt,{size:"h1",children:"Releases"}),p(Je,{as:"p",children:"Create a release for publishing content in a batch."}),p("div",{className:"ReleasesPage__header__buttons",children:p(ee,{component:"a",color:"blue",size:"xs",href:"/cms/releases/new",children:"New release"})})]}),p(Wk.ReleasesTable,{})]})})}Wk.ReleasesTable=()=>{let[t,e]=M(!0),[r,o]=M([]);async function n(){let i=await Goe();o(i),e(!1)}return V(()=>{n()},[]),p("div",{className:"ReleasesPage__ReleasesTable",children:[t&&p(et,{color:"gray",size:"xl"}),r.length>0&&p(ho,{verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[p("thead",{children:p("tr",{children:[p("th",{children:"id"}),p("th",{children:"description"}),p("th",{children:"content"}),p("th",{children:"status"})]})}),p("tbody",{children:r.map(i=>p("tr",{children:[p("td",{children:p("a",{href:`/cms/releases/${i.id}`,children:i.id})}),p("td",{children:i.description||""}),p("td",{children:(i.docIds||[]).map(a=>p("div",{children:p("a",{href:`/cms/content/${a}`,children:a})}))}),p("td",{children:p("div",{className:"ReleasesPage__ReleasesTable__publishStatus",children:p(Gk,{release:i})})})]},i.id))})]})]})};we();function ctt(t){let e=window.firebase.user.email;if(!e)return null;if(e in t)return t[e];let o=`*@${e.split("@").at(-1)}`;return o in t?t[o]:null}function dtt(t){return ctt(t)==="ADMIN"}function Kk(t){let[e,r]=M(!0),[o,n]=M({}),[i,a]=M(""),s=window.firebase.db,l=window.__ROOT_CTX.rootConfig.projectId||"default",c=ze(s,"Projects",l),d=dtt(o);V(()=>{No(c).then(h=>{let g=h.data()||{};n(g.roles||{}),r(!1)})},[]);async function u(h,g){r(!0),await or(async()=>{g==="REMOVE"?(await Lr(c,new On("roles",h),Uo()),n(_=>{let b={..._};return delete b[h],b}),Ot("acls.remove_user",{metadata:{user:h}})):(await Lr(c,new On("roles",h),g),n(_=>({..._,[h]:g})),Ot("acls.update_user",{metadata:{user:h,role:g}}))}),r(!1)}async function f(h){a(""),r(!0),await or(async()=>{await Lr(c,new On("roles",h),"EDITOR"),n(g=>({...g,[h]:"VIEWER"}))}),Ot("acls.add_user",{metadata:{user:h,role:"VIEWER"}}),r(!1)}let m=yre(Object.keys(o).map(h=>({email:h,role:o[h]})),"email");return p("div",{className:Ne(t.className,"ShareBox"),children:[e&&p(Ma,{visible:!0,loaderProps:{color:"gray",size:"xl"}}),p("form",{className:"ShareBox__addUser",onSubmit:h=>{h.preventDefault(),f(i)},children:[p(tr,{className:"ShareBox__addUser__email",placeholder:"grogu@example.com",type:"email",value:i,onChange:h=>a(h.target.value),radius:0,size:"xs"}),p(ee,{className:"ShareBox__addUser__button",size:"xs",radius:0,color:"dark",type:"submit",disabled:!d,children:"Add user"})]}),p("div",{className:"ShareBox__users",children:m.map(h=>p(Kk.User,{...h,currentUserIsAdmin:d,onChange:u},h.email))})]})}Kk.User=t=>{let e=t.email===window.firebase.user.email;return p("div",{className:"ShareBox__user",children:[p(Je,{className:"ShareBox__user__email",size:"body-sm",weight:"semi-bold",color:"gray",children:[t.email,e&&" (you)"]}),p("div",{className:"ShareBox__user__roleSelect",children:p(Sr,{data:[{value:"ADMIN",label:"ADMIN"},{value:"EDITOR",label:"EDITOR"},{value:"VIEWER",label:"VIEWER"},{value:"REMOVE",label:"REMOVE"}],value:t.role,radius:0,size:"xs",disabled:e||!t.currentUserIsAdmin,onChange:r=>{t.onChange(t.email,r)}})})]})};function ige(){let t=KC(),e=wC();return p(Fe,{children:p("div",{className:"SettingsPage",children:[p("div",{className:"SettingsPage__section SettingsPage__section__users",children:[p("div",{className:"SettingsPage__section__left",children:[p(tt,{className:"SettingsPage__section__left__title",children:"Share"}),p(Je,{className:"SettingsPage__section__body",size:"body-sm",weight:"semi-bold",color:"gray",children:[p("p",{children:"Share access to the CMS. To share with everyone in a domain, use *@example.com."}),p("ul",{children:[p("li",{children:"VIEWER: view docs but not edit"}),p("li",{children:"EDITOR: view and edit docs"}),p("li",{children:"ADMIN: all of the above and change sharing settings"})]})]})]}),p("div",{className:"SettingsPage__section__right",children:[p(tt,{className:"SettingsPage__section__right__title",size:"h3",children:"Users"}),p(Kk,{className:"SettingsPage__section__users__sharebox"})]})]}),p("div",{className:"SettingsPage__section",children:[p("div",{className:"SettingsPage__section__left",children:[p(tt,{className:"SettingsPage__section__left__title",children:"Site Settings"}),p(Je,{className:"SettingsPage__section__body",size:"body-sm",weight:"semi-bold",color:"gray",children:p("p",{children:"These settings apply to the project. Only admins can change them."})})]}),p("div",{className:"SettingsPage__section__right",children:wre.map(r=>p("div",{className:"SettingsPage__section__setting",children:[p(Je,{size:"body",weight:"semi-bold",children:r.name}),p(Je,{size:"body-sm",weight:"semi-bold",color:"gray",children:p("p",{children:r.description})}),p(hr,{autosize:!0,minRows:2,maxRows:4,value:e.settings[r.key]||"",placeholder:r.placeholder,onChange:o=>e.setSettings(r.key,o.currentTarget.value)}),r.ui&&p("div",{children:r.ui(e.settings[r.key])})]},r.key))})]}),p("div",{className:"SettingsPage__section",children:[p("div",{className:"SettingsPage__section__left",children:[p(tt,{className:"SettingsPage__section__left__title",children:"User Preferences"}),p(Je,{className:"SettingsPage__section__body",size:"body-sm",weight:"semi-bold",color:"gray",children:p("p",{children:"These settings are for you only."})})]}),p("div",{className:"SettingsPage__section__right",children:p("div",{className:"SettingsPage__section__userPref",children:[p("div",{className:"SettingsPage__section__userPref__description",children:[p(Je,{className:"SettingsPage__section__userPref__description__title",size:"body",weight:"semi-bold",children:"Enable Lexical Editor (experimental)"}),p(Je,{className:"SettingsPage__section__userPref__description__body",size:"body-sm",weight:"semi-bold",color:"gray",children:p("p",{children:["Replaces the"," ",p("a",{href:"https://editorjs.io/",target:"_blank",rel:"noopener noreferrer nofollow",children:"EditorJS"})," ","rich text editor with the"," ",p("a",{href:"https://lexical.dev/",target:"_blank",rel:"noopener noreferrer nofollow",children:"Lexical"})," ","version. The data saved by the Lexical version is backwards compatible but the editor may be missing a few features."]})})]}),p("div",{className:"SettingsPage__section__userPref__input",children:p(wE,{color:"dark",checked:t.preferences.EnableLexicalEditor,onChange:r=>{let o=r.currentTarget.checked;t.setPreference("EnableLexicalEditor",o)}})})]})})]})]})})}we();function age(t){let r=(window.__ROOT_CTX.sidebar?.tools||{})[t.id],o=r?.cmsUrl,n=r?.externalUrl;return V(()=>{o?.startsWith("/cms/")&&window.location.replace(o)},[o]),V(()=>{n&&window.open(n,"_blank","noopener,noreferrer")?.focus()},[n]),r?n?p(Fe,{children:p("div",{className:"SidebarToolsPage SidebarToolsPage--message",children:p("a",{href:n,target:"_blank",rel:"noreferrer noopener",children:["Open ",r.label||t.id," in a new tab"]})})}):o?.startsWith("/cms/")?p(Fe,{children:p("div",{className:"SidebarToolsPage",children:"redirecting..."})}):o?p(Fe,{children:p("div",{className:"SidebarToolsPage SidebarToolsPage--error",children:["invalid cmsUrl (must start with /cms/): ",t.id]})}):r.iframeUrl?p(Fe,{children:p("div",{className:"SidebarToolsPage",children:p("iframe",{src:r.iframeUrl})})}):p(Fe,{children:p("div",{className:"SidebarToolsPage SidebarToolsPage--error",children:["missing iframeUrl: ",t.id]})}):p(Fe,{children:p("div",{className:"SidebarToolsPage SidebarToolsPage--error",children:["not found: ",t.id]})})}Ws();var Yk=class{constructor(){this.data={}}setMeta(e){Object.entries(e).forEach(([r,o])=>{r.startsWith("@@")||(r=`@@${r}`),this.data[r]=o})}add(e,r,o){this.data[e]=r,o&&(this.data[`@${e}`]=o)}get(e){let r=this.data[e];return r?{source:r,meta:this.data[`@${e}`]}:null}list(){let e=[];return Object.entries(this.data).forEach(([r])=>{if(r.startsWith("@@"))return;let o=this.data[r],n=this.data[`@${r}`];e.push({key:r,source:o,meta:n})}),e}toJson(){return{...this.data}}toString(){return JSON.stringify(this.toJson(),null,2)}};function l_(){return p(Fe,{children:p("div",{className:"TranslationsArbPage",children:[p("div",{className:"TranslationsArbPage__header",children:[p(wo,{className:"TranslationsArbPage__header__breadcrumbs",children:[p("a",{href:"/cms/translations",children:"Translations"}),p("div",{children:"ARB"})]}),p(tt,{size:"h1",children:"ARB Translations"}),p(Je,{as:"p",children:"Enter doc ids below (separated by newlines) to include in an ARB file."})]}),p(l_.RequestForm,{})]})})}l_.RequestForm=()=>{let[t,e]=M(""),[r,o]=M(!1),[n,i]=M(""),[a,s]=M(null);async function l(u){let f=await XM(u),m=new Yk,h=window.__ROOT_CTX.rootConfig,g=[h.domain];h.base&&h.base!=="/"&&g.push(h.base);let _=g.join("");m.setMeta({locale:"en",context:_,last_modified:new Date().toISOString()}),console.log(f);for(let b in f){let y=f[b],v=new Set,S=b.split("/")[0],N=await Mh(S);ry(v,N.fields,y.fields||{},N.types||{});for(let w of v){let E=await OS(w),I=m.get(E)?.meta;if(I){let C=I.context.split(", ");C.push(b),C.sort(),I.context=C.join(", ")}else I={context:b};m.add(E,w,I)}}return m}async function c(){try{let u=sge(t),f=await l(u);s(f)}catch(u){console.error(u),i(`failed to preview arb: ${u}`)}}async function d(){try{o(!0),console.log("download arb");let u=sge(t),m=(await l(u)).toString(),g=await new Response(m).blob(),_=document.createElement("a");_.href=window.URL.createObjectURL(g),_.download=ftt(u),document.body.appendChild(_),_.click(),document.body.removeChild(_),window.URL.revokeObjectURL(_.href),o(!1)}catch(u){console.error(u),i(`failed to download arb: ${u}`)}}return p("form",{className:"TranslationsArbPage__RequestForm",onSubmit:u=>{u.preventDefault(),d()},children:[p("div",{className:"TranslationsArbPage__RequestForm__textareaWrapper",children:p(hr,{required:!0,size:"xs",radius:0,autosize:!0,minRows:8,maxRows:20,value:t,placeholder:"Pages/index",onChange:u=>{e(u.currentTarget.value||"")}})}),p("div",{className:"TranslationsArbPage__RequestForm__submit",children:[p(ee,{variant:"default",color:"dark",size:"xs",onClick:c,children:"Preview"}),p(ee,{color:"blue",size:"xs",loading:r,type:"submit",leftIcon:p(Sf,{size:16,strokeWidth:1.75}),children:"Download ARB"})]}),n&&p(Je,{as:"p",className:"TranslationsArbPage__RequestForm__error",children:n}),a&&p(l_.Preview,{arb:a})]})};l_.Preview=t=>{let e=t.arb.list().filter(r=>!!r.meta);return console.log(e),p(ho,{verticalSpacing:"xs",highlightOnHover:!0,fontSize:"xs",children:[p("thead",{children:p("tr",{children:[p("th",{children:"source"}),p("th",{children:"context"})]})}),p("tbody",{children:e.map(r=>p("tr",{class:"TranslationsArbPage__Preview__Table__row",children:[p("td",{children:r.source}),p("td",{children:[r.meta?.context,r.meta?.description&&p(Ce,{children:["/ ",r.meta.description]})]})]},r.source))})]})};function sge(t){return t.split(`
247
+ `)}function Jhe(t){let e=Ct(),r=Vt();function o(){let n=`delete-data-source-${t.id}`,i=e.openConfirmModal({...r,title:"Delete data source",children:p(Je,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to delete data source ",p("code",{children:t.id}),"? All previously synced data will be deleted. There is no undo."]}),labels:{confirm:"Delete",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{Re({id:n,title:"Deleting data source",message:`Deleting ${t.id} and synced data...`,loading:!0,autoClose:!1}),await _re(t.id),jt({id:n,title:"Deleted data source",message:`Successfully deleted ${t.id}`,loading:!1,autoClose:5e3}),e.closeModal(i),_o("/cms/data")}})}return p(Fe,{children:p("div",{className:"EditDataSourcePage",children:[p("div",{className:"EditDataSourcePage__header",children:[p(wo,{className:"EditDataSourcePage__header__breadcrumbs",children:[p("a",{href:"/cms/data",children:"Data Sources"}),p("a",{href:`/cms/data/${t.id}`,children:t.id}),p("div",{children:"Edit"})]}),p("div",{className:"EditDataSourcePage__header__titleWrap",children:[p(tt,{size:"h1",children:["Edit Data Source: ",t.id]}),p("div",{className:"EditDataSourcePage__header__controls",children:p(Te,{label:"Delete",children:p(Xe,{onClick:o,children:p(zb,{size:20,stroke:"1.5"})})})})]})]}),p(Hk,{dataSourceId:t.id})]})})}we();function Iu(t){let e=G(null),[r,o]=M(!1),[n,i]=M(""),[a,s]=M(!!t.releaseId),[l,c]=M(null),[d,u]=M([]),[f,m]=M([]),h=yC(),g=bre();async function _(w){console.log(w),await or(async()=>{let E=await Wf(w);c(E),u(E?.docIds||[]),m(E?.dataSourceIds||[])}),s(!1)}V(()=>{t.releaseId&&(s(!0),_(t.releaseId))},[t.releaseId]);async function b(){i("");let w=e.current;function E(T){let O=w.elements[T];return O?O.value.trim():""}let I=t.releaseId||E("id");if(!I){i("missing id");return}if(!pl(I)){i("id is invalid (alphanumeric characters and dashes only)");return}let C={id:I,description:E("description"),docIds:d,dataSourceIds:f};try{c(C),o(!0),t.releaseId?(await Woe(t.releaseId,C),Re({title:"Saved release",message:`Updated ${I}`,autoClose:5e3}),o(!1)):(await qoe(I,C),Re({title:"Added release",message:`Successfully added ${I}`,autoClose:5e3}),o(!1)),_o(`/cms/releases/${I}`)}catch(T){console.error(T),Re({title:"Failed to save release",message:String(T),color:"red",autoClose:!1}),o(!1)}}function y(){h.open({selectedDocIds:d,onChange:(w,E)=>{u(I=>{let C=[...I];if(E)C.push(w);else{let T=C.findIndex(O=>O===w);T>-1&&C.splice(T,1)}return console.log(C),C.sort()})}})}function v(){g.open({selectedDataSourceIds:f,onChange:(w,E)=>{m(I=>{let C=[...I];if(E)C.push(w);else{let T=C.indexOf(w);T>-1&&C.splice(T,1)}return C.sort()})}})}function S(w){console.log("onRemoveDoc()",w),u(E=>{let I=[...E],C=I.indexOf(w);return C!==-1&&I.splice(C,1),console.log(I),I})}function N(w){m(E=>{let I=[...E],C=I.indexOf(w);return C!==-1&&I.splice(C,1),I})}return p("form",{className:"ReleaseForm",ref:e,onSubmit:w=>{w.preventDefault(),b()},children:[p(Ma,{visible:a}),p(tr,{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,value:t.releaseId,disabled:!!t.releaseId}),p(hr,{className:"ReleaseForm__input",name:"description",label:"Description",description:"Optional.",size:"xs",radius:0,value:l?.description}),p(Nn,{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:[d.length>0&&p(Iu.DocPreviewCards,{docIds:d,onRemoveDoc:S}),p(ee,{className:"ReleaseForm__docSelectButton",color:"dark",size:"xs",onClick:()=>y(),children:"Select"})]}),p(Nn,{className:"ReleaseForm__input",label:"Data Sources",description:"Optional. Data sources to publish with the release.",size:"xs",children:[f.length>0&&p(Iu.DataSourceIds,{ids:f,onRemove:N}),p(ee,{className:"ReleaseForm__docSelectButton",color:"dark",size:"xs",onClick:()=>v(),children:"Select"})]}),p("div",{className:"ReleaseForm__submit__buttons",children:p(ee,{className:"ReleaseForm__submit",color:"blue",size:"xs",type:"submit",loading:r,children:t.buttonLabel||"Save"})}),n&&p("div",{className:"ReleaseForm__error",children:["Error: ",n]})]})}Iu.DocPreviewCards=t=>p("div",{className:"ReleaseForm__DocPreviewCards",children:t.docIds.map(e=>p("div",{className:"ReleaseForm__DocPreviewCards__card",children:[p(ig,{className:"ReleaseForm__DocPreviewCards__card__preview",docId:e}),p("div",{className:"ReleaseForm__DocPreviewCards__card__controls",children:[p("div",{className:"ReleaseForm__DocPreviewCards__card__controls__remove",children:p(Te,{label:"Remove",children:p(Xe,{className:"ReleaseForm__DocPreviewCards__card__controls__remove__icon",onClick:()=>t.onRemoveDoc(e),children:p(qn,{size:16})})})}),p("div",{className:"ReleaseForm__DocPreviewCards__card__controls__open",children:p(Te,{label:"Open",children:p(Xe,{component:"a",className:"ReleaseForm__DocPreviewCards__card__controls__open__icon",href:`/cms/content/${e}`,target:"_blank",children:p(Sd,{size:16})})})})]})]},e))});Iu.DataSourceIds=t=>p("div",{className:"ReleaseForm__DataSourceIds",children:t.ids.map(e=>p("div",{className:"ReleaseForm__DataSourceIds__item",children:[p("span",{className:"ReleaseForm__DataSourceIds__item__id",children:e}),p(Xe,{className:"ReleaseForm__DataSourceIds__item__remove",onClick:()=>t.onRemove(e),children:p(qn,{size:16})})]},e))});function Qhe(t){let e=Ct(),r=Vt();function o(){let n=`delete-release-${t.id}`,i=e.openConfirmModal({...r,title:"Delete release",children:p(Je,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to delete release ",p("code",{children:t.id}),"? There is no undo. This will only delete the release; the docs in the release will remain unchanged."]}),labels:{confirm:"Delete",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{Re({id:n,title:"Deleting release",message:`Deleting ${t.id}...`,loading:!0,autoClose:!1}),await Koe(t.id),jt({id:n,title:"Deleted release",message:`Successfully deleted ${t.id}`,loading:!1,autoClose:5e3}),e.closeModal(i),_o("/cms/releases")}})}return p(Fe,{children:p("div",{className:"EditReleasePage",children:[p("div",{className:"EditReleasePage__header",children:[p(wo,{className:"EditReleasePage__header__breadcrumbs",children:[p("a",{href:"/cms/releases",children:"Releases"}),p("a",{href:`/cms/releases/${t.id}`,children:t.id}),p("div",{children:"Edit"})]}),p("div",{className:"EditReleasePage__header__titleWrap",children:[p(tt,{size:"h1",children:["Edit Release: ",t.id]}),p("div",{className:"EditReleasePage__header__controls",children:p(Te,{label:"Delete",children:p(Xe,{onClick:o,children:p(zb,{size:20,stroke:"1.5"})})})})]})]}),p(Iu,{releaseId:t.id})]})})}we();function jk(t){let e=t.limit||40,[r,o]=M(!0),[n,i]=M([]);async function a(){let s=await NQ({limit:e});i(s),o(!1)}return V(()=>{a()},[]),r?p("div",{className:"ActionsLog ActionsLog--loading",children:p(et,{color:"gray",size:"xl"})}):p("div",{className:"ActionsLog",children:p(ho,{className:"ActionsLog__table",children:[p("thead",{children:p("tr",{className:"ActionsLogs__table__row ActionsLogs__table__row--header",children:[p("th",{className:"ActionsLogs__table__header",children:"timestamp"}),p("th",{className:"ActionsLogs__table__header",children:"user"}),p("th",{className:"ActionsLogs__table__header",children:"action"}),p("th",{className:"ActionsLogs__table__header",children:"quick links"})]})}),p("tbody",{children:n.map(s=>p("tr",{className:"ActionsLogs__table__row",children:[p("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--nowrap",children:ntt(s.timestamp)}),p("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--nowrap",children:s.by}),p("td",{className:"ActionsLogs__table__col",children:[s.action," ",itt(s.metadata)]}),p("td",{className:"ActionsLogs__table__col",children:p("div",{className:"ActionsLogs__table__buttons",children:[s.action!=="doc.delete"&&s.metadata?.docId&&p(Te,{transition:"pop",label:s.metadata.docId,children:p(ee,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/content/${s.metadata?.docId}`,children:"Open doc"})}),s.action!=="datasource.delete"&&s.metadata?.datasourceId&&p(Te,{transition:"pop",label:s.metadata.datasourceId,children:p(ee,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/data/${s.metadata?.datasourceId}`,children:"Open release"})}),s.action!=="release.delete"&&s.metadata?.releaseId&&p(Te,{transition:"pop",label:s.metadata.releaseId,children:p(ee,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/releases/${s.metadata?.releaseId}`,children:"Open release"})}),s.metadata?.sheetId&&p(ee,{component:"a",variant:"default",size:"xs",compact:!0,href:ja(s.metadata.sheetId),target:"_blank",children:"Open sheet"}),s.action.startsWith("acls.")&&p(ee,{component:"a",variant:"default",size:"xs",compact:!0,href:"/cms/settings",children:"Open settings"})]})})]}))})]})})}function ntt(t){return t.toDate().toLocaleString("sv-SE",{dateStyle:"short",timeStyle:"medium"})}function itt(t){function e(r){return r===null?"null":typeof r>"u"?"undefined":typeof r=="string"?`"${r.replaceAll('"','\\"')}"`:typeof r!="object"?String(r):Array.isArray(r)?`[${r.map(e).join(", ")}]`:`{${Object.entries(r).map(([n,i])=>`${n}: ${e(i)}`).join(", ")}}`}return e(t)}var Zhe=250;function ege(){return p(Fe,{children:p("div",{className:"LogsPage",children:[p("div",{className:"LogsPage__header",children:[p(tt,{size:"h1",children:"Action Logs"}),p(Je,{as:"p",children:["The latest ",Zhe," actions are displayed here. View all past actions in the"," ",p("a",{href:att(),target:"_blank",children:"Firebase Console"}),"."]})]}),p(jk,{limit:Zhe})]})})}function att(){let t=window.__ROOT_CTX.firebaseConfig,e=t.projectId,r=window.__ROOT_CTX.rootConfig.projectId,o=t.databaseId||"-default-",n=`/Projects/${r}/ActionLogs`.replaceAll("/","~2F");return`https://console.firebase.google.com/project/${e}/firestore/databases/${o}/data/${n}`}function tge(){return p(Fe,{children:p("div",{className:"NewDataSourcePage",children:[p("div",{className:"NewDataSourcePage__header",children:[p(wo,{className:"NewDataSourcePage__header__breadcrumbs",children:[p("a",{href:"/cms/data",children:"Data Sources"}),p("div",{children:"New"})]}),p(tt,{size:"h1",children:"Add Data Source"})]}),p(Hk,{buttonLabel:"Create data source"})]})})}function rge(){return p(Fe,{children:p("div",{className:"NewReleasePage",children:[p("div",{className:"NewReleasePage__header",children:[p(wo,{className:"NewReleasePage__header__breadcrumbs",children:[p("a",{href:"/cms/releases",children:"Releases"}),p("div",{children:"New"})]}),p(tt,{size:"h1",children:"Add Release"})]}),p(Iu,{buttonLabel:"Create release"})]})})}function oge(){return p(Fe,{children:p("div",{className:"NotFoundPage",children:[p("div",{className:"NotFoundPage__icon",children:p(Ab,{size:60})}),p("h2",{className:"NotFoundPage__title",children:"Not Found"}),p("p",{className:"NotFoundPage__body",children:["Double-check the URL and try again or ",p("a",{href:"/cms",children:"go home"}),"."]})]})})}function qk(){let t=window.__ROOT_CTX.rootConfig.projectName||"Root CMS";return p(Fe,{children:p("div",{className:"ProjectPage",children:[p("div",{className:"ProjectPage__headline",children:p(tt,{className:"ProjectPage__title",size:"h1",children:t})}),p("div",{className:"ProjectPage__section",children:[p(tt,{className:"ProjectPage__section__title",size:"h2",children:"Content"}),p(qk.CollectionList,{})]}),p("div",{className:"ProjectPage__section",children:[p(tt,{className:"ProjectPage__section__title ProjectPage__section__title--flex",size:"h2",children:[p("div",{children:"Recent actions"}),p("div",{children:p(ee,{component:"a",variant:"default",size:"xs",compact:!0,href:"/cms/logs",children:"Show all"})})]}),p(jk,{limit:20})]})]})})}qk.CollectionList=()=>{let t=Object.keys(window.__ROOT_CTX.collections).map(e=>({...window.__ROOT_CTX.collections[e],id:e}));return p("div",{className:"ProjectPage__collectionList",children:[t.map(e=>p("a",{className:"ProjectPage__collectionList__collection",href:`/cms/content/${e.id}`,children:[p("div",{className:"ProjectPage__collectionList__collection__icon",children:p(Cf,{size:20,strokeWidth:"1.75"})}),p("div",{className:"ProjectPage__collectionList__collection__name",children:e.name||e.id}),e.description&&p("div",{className:"ProjectPage__collectionList__collection__desc",children:e.description})]},e.id)),t.length===0&&p("div",{className:"ProjectPage__collectionList__collections__empty",children:"No collections match your query."})]})};we();var nge={transition:"pop"};function Gk(t){let e=t.release;return e.scheduledAt?p(Te,{...nge,label:`Scheduled ${ltt(e.scheduledAt)} by ${e.scheduledBy}`,wrapLines:!0,width:240,children:p(fs,{size:"xs",variant:"gradient",gradient:{from:"grape",to:"pink",deg:35},children:"Scheduled"})}):e.publishedAt?p(Te,{...nge,label:`Published ${stt(e.publishedAt)} by ${e.publishedBy}`,children:p(fs,{size:"xs",variant:"gradient",gradient:{from:"teal",to:"lime",deg:105},children:"Published"})}):p(fs,{size:"xs",variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:"Unpublished"})}function stt(t){return t?Va(t.toMillis()):Va(new Date().getTime())}function ltt(t){return new Date(t.toMillis()).toLocaleDateString("en",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function wu(t){let[e,r]=M(!0),[o,n]=M(null),[i,a]=M(0),s=t.id;async function l(){r(!0),await or(async()=>{let d=await Wf(s);n(d),a(Ub())}),r(!1)}V(()=>{l()},[]);function c(d){console.log("onAction()",d),l()}return p(Fe,{children:p("div",{className:"ReleasePage",children:[p("div",{className:"ReleasePage__header",children:[p(wo,{className:"ReleasePage__header__breadcrumbs",children:[p("a",{href:"/cms/releases",children:"Releases"}),p("div",{children:s})]}),p("div",{className:"ReleasePage__header__titleWrap",children:[p(tt,{size:"h1",children:["Release: ",s]}),p("div",{className:"ReleasePage__header__controls",children:p(Te,{label:"Configure",children:p(Xe,{component:"a",href:`/cms/releases/${t.id}/edit`,children:p(Nf,{size:24,stroke:"1.5"})})})})]}),o?.description&&p(Je,{as:"p",children:o.description})]}),e?p(et,{color:"gray",size:"xl"}):p(Ce,{children:[o&&p(wu.PublishStatus,{release:o,onAction:c}),o&&o.docIds&&o.docIds.length>0&&p(wu.DocsList,{release:o},`docs-list-${i}`),o&&o.dataSourceIds&&o.dataSourceIds.length>0&&p(wu.DataSourcesList,{release:o},`data-sources-${i}`)]})]})})}wu.PublishStatus=t=>{let e=t.release,[r,o]=M(!1),n=Ct(),i=Vt(),a=Zoe({releaseId:e.id,onScheduled:()=>{t.onAction("scheduled")}});function s(){let u=e.docIds||[],f=e.dataSourceIds||[],m=u.length+f.length;if(m===0){Re({title:"Cannot publish release",message:"Error: nothing in the release to publish.",color:"red",autoClose:!1});return}n.openConfirmModal({...i,title:`Publish release: ${e.id}`,children:p(Je,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to publish this release? The ",m," items in the release will go live immediately."]}),labels:{confirm:"Publish",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"dark",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!0,onConfirm:()=>{l()}})}async function l(){o(!0),await or(async()=>{let u=`publish-release-${e.id}`,f=e.docIds?.length||0,m=e.dataSourceIds?.length||0,h=f+m;Re({id:u,title:"Publishing release",message:`Publishing ${h} items...`,loading:!0,autoClose:!1}),await Yoe(e.id),jt({id:u,title:"Published release!",message:`Successfully published ${h} items!`,loading:!1,autoClose:5e3}),t.onAction&&t.onAction("publish")}),o(!1)}function c(){a.open()}async function d(){await Joe(e.id),t.onAction("cancel-schedule")}return p("div",{className:"ReleasePage__PublishStatus",children:[p(tt,{size:"h2",children:"Status"}),p(ho,{verticalSpacing:"xs",striped:!0,fontSize:"xs",children:[p("thead",{children:p("tr",{children:[p("th",{children:"status"}),p("th",{children:"actions"})]})}),p("tbody",{children:p("tr",{children:[p("td",{children:p(Gk,{release:e})}),p("td",{children:p("div",{className:"ReleasePage__PublishStatus__actions",children:[!e.scheduledAt&&p(Te,{label:"Publish the release immediately",position:"bottom",withArrow:!0,children:p(ee,{variant:"default",size:"xs",compact:!0,onClick:()=>s(),loading:r,children:e.publishedAt?"Re-publish":"Publish"})}),e.scheduledAt?p(Te,{label:"Cancel the scheduled release",position:"bottom",withArrow:!0,children:p(ee,{variant:"default",size:"xs",compact:!0,onClick:()=>d(),children:"Cancel Schedule"})}):p(Te,{label:"Schedule the release to be published at a future date",position:"bottom",withArrow:!0,wrapLines:!0,width:180,children:p(ee,{variant:"default",size:"xs",compact:!0,onClick:()=>c(),children:"Schedule"})})]})})]})})]})]})};wu.DocsList=t=>{let e=t.release,r=e.docIds||[];return p("div",{className:"ReleasePage__DocsList",children:[p("div",{className:"ReleasePage__DocsList__header",children:[p(tt,{size:"h2",children:"Docs"}),p(ee,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/releases/${e.id}/edit`,children:"Edit"})]}),p("div",{className:"ReleasePage__DocsList__cards",children:r.map(o=>p("div",{className:"ReleasePage__DocsList__card",children:p("a",{href:`/cms/content/${o}`,children:p(ig,{docId:o,statusBadges:!0})})},o))})]})};wu.DataSourcesList=t=>{let e=t.release,r=e.dataSourceIds||[];return p("div",{className:"ReleasePage__DataSourcesList",children:[p("div",{className:"ReleasePage__DataSourcesList__header",children:[p(tt,{size:"h2",children:"Data Sources"}),p(ee,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/releases/${e.id}/edit`,children:"Edit"})]}),p("div",{className:"ReleasePage__DataSourcesList__items",children:r.map(o=>p("div",{className:"ReleasePage__DataSourcesList__item",children:p("a",{href:`/cms/data/${o}`,children:o})},o))})]})};we();function Wk(){return p(Fe,{children:p("div",{className:"ReleasesPage",children:[p("div",{className:"ReleasesPage__header",children:[p(tt,{size:"h1",children:"Releases"}),p(Je,{as:"p",children:"Create a release for publishing content in a batch."}),p("div",{className:"ReleasesPage__header__buttons",children:p(ee,{component:"a",color:"blue",size:"xs",href:"/cms/releases/new",children:"New release"})})]}),p(Wk.ReleasesTable,{})]})})}Wk.ReleasesTable=()=>{let[t,e]=M(!0),[r,o]=M([]);async function n(){let i=await Goe();o(i),e(!1)}return V(()=>{n()},[]),p("div",{className:"ReleasesPage__ReleasesTable",children:[t&&p(et,{color:"gray",size:"xl"}),r.length>0&&p(ho,{verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[p("thead",{children:p("tr",{children:[p("th",{children:"id"}),p("th",{children:"description"}),p("th",{children:"content"}),p("th",{children:"status"})]})}),p("tbody",{children:r.map(i=>p("tr",{children:[p("td",{children:p("a",{href:`/cms/releases/${i.id}`,children:i.id})}),p("td",{children:i.description||""}),p("td",{children:(i.docIds||[]).map(a=>p("div",{children:p("a",{href:`/cms/content/${a}`,children:a})}))}),p("td",{children:p("div",{className:"ReleasesPage__ReleasesTable__publishStatus",children:p(Gk,{release:i})})})]},i.id))})]})]})};we();function ctt(t){let e=window.firebase.user.email;if(!e)return null;if(e in t)return t[e];let o=`*@${e.split("@").at(-1)}`;return o in t?t[o]:null}function dtt(t){return ctt(t)==="ADMIN"}function Kk(t){let[e,r]=M(!0),[o,n]=M({}),[i,a]=M(""),s=window.firebase.db,l=window.__ROOT_CTX.rootConfig.projectId||"default",c=ze(s,"Projects",l),d=dtt(o);V(()=>{No(c).then(h=>{let g=h.data()||{};n(g.roles||{}),r(!1)})},[]);async function u(h,g){r(!0),await or(async()=>{g==="REMOVE"?(await Lr(c,new On("roles",h),Uo()),n(_=>{let b={..._};return delete b[h],b}),Ot("acls.remove_user",{metadata:{user:h}})):(await Lr(c,new On("roles",h),g),n(_=>({..._,[h]:g})),Ot("acls.update_user",{metadata:{user:h,role:g}}))}),r(!1)}async function f(h){a(""),r(!0),await or(async()=>{await Lr(c,new On("roles",h),"EDITOR"),n(g=>({...g,[h]:"VIEWER"}))}),Ot("acls.add_user",{metadata:{user:h,role:"VIEWER"}}),r(!1)}let m=yre(Object.keys(o).map(h=>({email:h,role:o[h]})),"email");return p("div",{className:Ne(t.className,"ShareBox"),children:[e&&p(Ma,{visible:!0,loaderProps:{color:"gray",size:"xl"}}),p("form",{className:"ShareBox__addUser",onSubmit:h=>{h.preventDefault(),f(i)},children:[p(tr,{className:"ShareBox__addUser__email",placeholder:"grogu@example.com",type:"email",value:i,onChange:h=>a(h.target.value),radius:0,size:"xs"}),p(ee,{className:"ShareBox__addUser__button",size:"xs",radius:0,color:"dark",type:"submit",disabled:!d,children:"Add user"})]}),p("div",{className:"ShareBox__users",children:m.map(h=>p(Kk.User,{...h,currentUserIsAdmin:d,onChange:u},h.email))})]})}Kk.User=t=>{let e=t.email===window.firebase.user.email;return p("div",{className:"ShareBox__user",children:[p(Je,{className:"ShareBox__user__email",size:"body-sm",weight:"semi-bold",color:"gray",children:[t.email,e&&" (you)"]}),p("div",{className:"ShareBox__user__roleSelect",children:p(Sr,{data:[{value:"ADMIN",label:"ADMIN"},{value:"EDITOR",label:"EDITOR"},{value:"VIEWER",label:"VIEWER"},{value:"REMOVE",label:"REMOVE"}],value:t.role,radius:0,size:"xs",disabled:e||!t.currentUserIsAdmin,onChange:r=>{t.onChange(t.email,r)}})})]})};function ige(){let t=KC(),e=wC();return p(Fe,{children:p("div",{className:"SettingsPage",children:[p("div",{className:"SettingsPage__section SettingsPage__section__users",children:[p("div",{className:"SettingsPage__section__left",children:[p(tt,{className:"SettingsPage__section__left__title",children:"Share"}),p(Je,{className:"SettingsPage__section__body",size:"body-sm",weight:"semi-bold",color:"gray",children:[p("p",{children:"Share access to the CMS. To share with everyone in a domain, use *@example.com."}),p("ul",{children:[p("li",{children:"VIEWER: view docs but not edit"}),p("li",{children:"EDITOR: view and edit docs"}),p("li",{children:"ADMIN: all of the above and change sharing settings"})]})]})]}),p("div",{className:"SettingsPage__section__right",children:[p(tt,{className:"SettingsPage__section__right__title",size:"h3",children:"Users"}),p(Kk,{className:"SettingsPage__section__users__sharebox"})]})]}),p("div",{className:"SettingsPage__section",children:[p("div",{className:"SettingsPage__section__left",children:[p(tt,{className:"SettingsPage__section__left__title",children:"Site Settings"}),p(Je,{className:"SettingsPage__section__body",size:"body-sm",weight:"semi-bold",color:"gray",children:p("p",{children:"These settings apply to the project. Only admins can change them."})})]}),p("div",{className:"SettingsPage__section__right",children:wre.map(r=>p("div",{className:"SettingsPage__section__setting",children:[p(Je,{size:"body",weight:"semi-bold",children:r.name}),p(Je,{size:"body-sm",weight:"semi-bold",color:"gray",children:p("p",{children:r.description})}),p(hr,{autosize:!0,minRows:2,maxRows:4,value:e.settings[r.key]||"",placeholder:r.placeholder,onChange:o=>e.setSettings(r.key,o.currentTarget.value)}),r.ui&&p("div",{children:r.ui(e.settings[r.key])})]},r.key))})]}),p("div",{className:"SettingsPage__section",children:[p("div",{className:"SettingsPage__section__left",children:[p(tt,{className:"SettingsPage__section__left__title",children:"User Preferences"}),p(Je,{className:"SettingsPage__section__body",size:"body-sm",weight:"semi-bold",color:"gray",children:p("p",{children:"These settings are for you only."})})]}),p("div",{className:"SettingsPage__section__right",children:p("div",{className:"SettingsPage__section__userPref",children:[p("div",{className:"SettingsPage__section__userPref__description",children:[p(Je,{className:"SettingsPage__section__userPref__description__title",size:"body",weight:"semi-bold",children:"Enable EditorJS Editor (legacy)"}),p(Je,{className:"SettingsPage__section__userPref__description__body",size:"body-sm",weight:"semi-bold",color:"gray",children:p("p",{children:["Replaces the"," ",p("a",{href:"https://lexical.dev/",target:"_blank",rel:"noopener noreferrer nofollow",children:"Lexical"})," ","(default) rich text editor with the"," ",p("a",{href:"https://editorjs.io/",target:"_blank",rel:"noopener noreferrer nofollow",children:"EditorJS"})," ","(legacy) version."]})})]}),p("div",{className:"SettingsPage__section__userPref__input",children:p(wE,{color:"dark",checked:t.preferences.EnableEditorJSEditor,onChange:r=>{let o=r.currentTarget.checked;t.setPreference("EnableEditorJSEditor",o)}})})]})})]})]})})}we();function age(t){let r=(window.__ROOT_CTX.sidebar?.tools||{})[t.id],o=r?.cmsUrl,n=r?.externalUrl;return V(()=>{o?.startsWith("/cms/")&&window.location.replace(o)},[o]),V(()=>{n&&window.open(n,"_blank","noopener,noreferrer")?.focus()},[n]),r?n?p(Fe,{children:p("div",{className:"SidebarToolsPage SidebarToolsPage--message",children:p("a",{href:n,target:"_blank",rel:"noreferrer noopener",children:["Open ",r.label||t.id," in a new tab"]})})}):o?.startsWith("/cms/")?p(Fe,{children:p("div",{className:"SidebarToolsPage",children:"redirecting..."})}):o?p(Fe,{children:p("div",{className:"SidebarToolsPage SidebarToolsPage--error",children:["invalid cmsUrl (must start with /cms/): ",t.id]})}):r.iframeUrl?p(Fe,{children:p("div",{className:"SidebarToolsPage",children:p("iframe",{src:r.iframeUrl})})}):p(Fe,{children:p("div",{className:"SidebarToolsPage SidebarToolsPage--error",children:["missing iframeUrl: ",t.id]})}):p(Fe,{children:p("div",{className:"SidebarToolsPage SidebarToolsPage--error",children:["not found: ",t.id]})})}Ws();var Yk=class{constructor(){this.data={}}setMeta(e){Object.entries(e).forEach(([r,o])=>{r.startsWith("@@")||(r=`@@${r}`),this.data[r]=o})}add(e,r,o){this.data[e]=r,o&&(this.data[`@${e}`]=o)}get(e){let r=this.data[e];return r?{source:r,meta:this.data[`@${e}`]}:null}list(){let e=[];return Object.entries(this.data).forEach(([r])=>{if(r.startsWith("@@"))return;let o=this.data[r],n=this.data[`@${r}`];e.push({key:r,source:o,meta:n})}),e}toJson(){return{...this.data}}toString(){return JSON.stringify(this.toJson(),null,2)}};function l_(){return p(Fe,{children:p("div",{className:"TranslationsArbPage",children:[p("div",{className:"TranslationsArbPage__header",children:[p(wo,{className:"TranslationsArbPage__header__breadcrumbs",children:[p("a",{href:"/cms/translations",children:"Translations"}),p("div",{children:"ARB"})]}),p(tt,{size:"h1",children:"ARB Translations"}),p(Je,{as:"p",children:"Enter doc ids below (separated by newlines) to include in an ARB file."})]}),p(l_.RequestForm,{})]})})}l_.RequestForm=()=>{let[t,e]=M(""),[r,o]=M(!1),[n,i]=M(""),[a,s]=M(null);async function l(u){let f=await XM(u),m=new Yk,h=window.__ROOT_CTX.rootConfig,g=[h.domain];h.base&&h.base!=="/"&&g.push(h.base);let _=g.join("");m.setMeta({locale:"en",context:_,last_modified:new Date().toISOString()}),console.log(f);for(let b in f){let y=f[b],v=new Set,S=b.split("/")[0],N=await Mh(S);ry(v,N.fields,y.fields||{},N.types||{});for(let w of v){let E=await OS(w),I=m.get(E)?.meta;if(I){let C=I.context.split(", ");C.push(b),C.sort(),I.context=C.join(", ")}else I={context:b};m.add(E,w,I)}}return m}async function c(){try{let u=sge(t),f=await l(u);s(f)}catch(u){console.error(u),i(`failed to preview arb: ${u}`)}}async function d(){try{o(!0),console.log("download arb");let u=sge(t),m=(await l(u)).toString(),g=await new Response(m).blob(),_=document.createElement("a");_.href=window.URL.createObjectURL(g),_.download=ftt(u),document.body.appendChild(_),_.click(),document.body.removeChild(_),window.URL.revokeObjectURL(_.href),o(!1)}catch(u){console.error(u),i(`failed to download arb: ${u}`)}}return p("form",{className:"TranslationsArbPage__RequestForm",onSubmit:u=>{u.preventDefault(),d()},children:[p("div",{className:"TranslationsArbPage__RequestForm__textareaWrapper",children:p(hr,{required:!0,size:"xs",radius:0,autosize:!0,minRows:8,maxRows:20,value:t,placeholder:"Pages/index",onChange:u=>{e(u.currentTarget.value||"")}})}),p("div",{className:"TranslationsArbPage__RequestForm__submit",children:[p(ee,{variant:"default",color:"dark",size:"xs",onClick:c,children:"Preview"}),p(ee,{color:"blue",size:"xs",loading:r,type:"submit",leftIcon:p(Sf,{size:16,strokeWidth:1.75}),children:"Download ARB"})]}),n&&p(Je,{as:"p",className:"TranslationsArbPage__RequestForm__error",children:n}),a&&p(l_.Preview,{arb:a})]})};l_.Preview=t=>{let e=t.arb.list().filter(r=>!!r.meta);return console.log(e),p(ho,{verticalSpacing:"xs",highlightOnHover:!0,fontSize:"xs",children:[p("thead",{children:p("tr",{children:[p("th",{children:"source"}),p("th",{children:"context"})]})}),p("tbody",{children:e.map(r=>p("tr",{class:"TranslationsArbPage__Preview__Table__row",children:[p("td",{children:r.source}),p("td",{children:[r.meta?.context,r.meta?.description&&p(Ce,{children:["/ ",r.meta.description]})]})]},r.source))})]})};function sge(t){return t.split(`
248
248
  `).map(e=>e.trim()).filter(e=>utt(e))}function utt(t){return!!t&&t.includes("/")&&t.split("/").length===2}function ftt(t){let e=new Date,r=a=>a.toString().padStart(2,"0"),o=`${e.getFullYear()}${r(e.getMonth()+1)}${r(e.getDate())}t${r(e.getHours())}${r(e.getMinutes())}`,n=window.__ROOT_CTX.rootConfig.projectName||window.__ROOT_CTX.rootConfig.projectId,i=[lge(n)];return t.length===1&&i.push(lge(t[0])),i.push(o),`${i.join("_")}.arb`}function lge(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}we();function Xk(t){let e=t.hash,[r,o]=M(!1),[n,i]=M(!1),[a,s]=M({source:""});async function l(){o(!0);let d=await OQ(e);if(o(!1),!d?.source){i(!0);return}s(d)}async function c(d){console.log(d),o(!0),await DQ(e,d),s(u=>({...u,...d})),o(!1),Re({title:"Saved translations",message:`Updated translations for ${e}.`,autoClose:5e3})}return V(()=>{l()},[t.hash]),p(Fe,{children:p("div",{className:"TranslationsEditPage",children:[p("div",{className:"TranslationsEditPage__header",children:[p(wo,{className:"TranslationsEditPage__header__breadcrumbs",children:[p("a",{href:"/cms/translations",children:"Translations"}),p("div",{children:t.hash})]}),p(tt,{size:"h1",children:"Edit Translations"})]}),r?p(et,{color:"gray",size:"xl"}):n?p("div",{className:"TranslationsEditPage__notFound",children:"Not Found"}):p(Xk.Form,{hash:t.hash,translations:a,onChange:c})]})})}Xk.Form=t=>{let e=t.translations,o=(window.__ROOT_CTX.rootConfig.i18n.locales||[]).filter(n=>n!=="en");return p("form",{className:"TranslationsEditPage__Form",onSubmit:n=>{n.preventDefault();let i=n.currentTarget,a=["en",...o],s={};a.forEach(l=>{let c=i.elements[l].value;s[l]=dc(c)}),t.onChange(s)},children:[p(tr,{className:"TranslationsEditPage__Form__input",size:"xs",radius:0,name:"hash",label:"hash",value:t.hash,disabled:!0}),p(hr,{className:"TranslationsEditPage__Form__input",size:"xs",radius:0,name:"source",label:"source",value:e.source,disabled:!0}),p(hr,{className:"TranslationsEditPage__Form__input",size:"xs",radius:0,name:"en",label:"en",value:e.en}),o.map(n=>p(hr,{className:"TranslationsEditPage__Form__input",size:"xs",radius:0,name:n,label:n,value:e[n]||""},n)),p(ee,{className:"TranslationsEditPage__Form__input__submit",color:"blue",size:"xs",type:"submit",children:"Save"})]})};we();function Jk(){return p(Fe,{children:p("div",{className:"TranslationsPage",children:[p("div",{className:"TranslationsPage__header",children:[p(tt,{size:"h1",children:"Translations"}),p("div",{className:"TranslationsPage__header__buttons",children:p(ee,{component:"a",color:"blue",size:"xs",href:"/cms/translations/arb",children:"Download ARB"})})]}),p(Jk.TranslationsTable,{})]})})}function ptt(t){return t?Array.isArray(t)?t.sort():[t]:[]}Jk.TranslationsTable=()=>{let[t,e]=M(!0),[r,o]=M([]),[n,i]=M({}),a=window.__ROOT_CTX.rootConfig.i18n?.locales||[],s=["en",...a.filter(b=>b!=="en").sort()],[l,c]=QC("locale",s),d=window.__ROOT_CTX.collections;async function u(){e(!0),await or(async()=>{i(await Td())}),e(!1)}async function f(){let b=[];Object.entries(n).forEach(([y,v])=>{b.push({hash:y,source:v.source,locales:l.map(S=>v[S]||""),tags:v.tags})}),b.sort((y,v)=>y.source.toLowerCase().localeCompare(v.source.toLowerCase())),o(b)}V(()=>{u()},[]),V(()=>{f()},[n,l]);function m(b){l.length===a.length?c([b]):c(a)}if(t)return p(et,{color:"gray",size:"xl"});if(r.length===0)return p("div",{className:"TranslationsPage__TranslationsTable",children:p("div",{className:"TranslationsPage__TranslationsTable__empty",children:"No translations in the system yet."})});let _=["hash","source",...r[0].locales.map((b,y)=>l[y]),"tags"];return p("div",{className:"TranslationsPage__TranslationsTable",children:p(ho,{verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[p("thead",{children:p("tr",{children:_.map((b,y)=>{let v=b;return p("th",{"data-col":_[y],className:"TranslationsPage__TranslationsTable__cell",children:p(Te,{className:"TranslationsPage__TranslationsTable__headerTooltip",placement:"start",withArrow:!0,label:l.length===s.length?`Show only ${v}`:"Show all locales",children:p("div",{className:"TranslationsPage__TranslationsTable__localeHeader",onClick:()=>{m(v)},children:v})})},_[y])})})}),p("tbody",{children:r.map(b=>p("tr",{children:[p("td",{"data-col":"hash","data-string-cell":!1,class:"TranslationsPage__TranslationsTable__cell",children:p("a",{href:`/cms/translations/${b.hash}`,children:b.hash})},"hash"),p("td",{"data-col":"source","data-string-cell":!0,class:"TranslationsPage__TranslationsTable__cell",children:b.source},"source"),b.locales.map((y,v)=>p("td",{"data-col":l[v],"data-string-cell":!0,class:"TranslationsPage__TranslationsTable__cell",children:y},l[v])),p("td",{"data-col":"tags","data-string-cell":!1,class:"TranslationsPage__TranslationsTable__cell",children:p(Ce,{children:ptt(b.tags).map(y=>{let v={},S="div";if(y.includes("/")){let[N,w]=y.split("/");d[N]&&(S="a",Object.assign(v,{target:"_blank",href:`/cms/content/${N}/${w}`}))}else d[y]&&(S="a",Object.assign(v,{target:"_blank",href:`/cms/content/${y}`}));return p("div",{children:p(S,{...v,className:"TranslationsPage__TranslationsTable__Tag",children:y})},y)})})},"tags")]},b.hash))})]})})};function mtt(){return p(OI,{theme:{fontFamily:"Inter, sans-serif",fontSizes:{xs:12,sm:14,md:16,lg:18,xl:20}},children:p(RE,{children:p(i2.Provider,{value:window.firebase,children:p(ane,{children:p(Sre,{children:p(cne,{children:p(sO,{modals:{[uC.id]:uC,[hC.id]:hC,[Md.id]:Md,[Ld.id]:Ld,[bC.id]:bC,[IC.id]:IC,[Ah.id]:Ah,[Rh.id]:Rh,[sa.id]:sa,[Bd.id]:Bd,[jC.id]:jC,[qC.id]:qC,[GC.id]:GC},children:p(aM,{children:[p(Wr,{path:"/cms",component:qk}),p(Wr,{path:"/cms/ai",component:ere}),p(Wr,{path:"/cms/assets",component:dne}),p(Wr,{path:"/cms/compare",component:_ne}),p(Wr,{path:"/cms/content/:collection?",component:Wh}),p(Wr,{path:"/cms/content/:collection/:slug",component:Vk}),p(Wr,{path:"/cms/data",component:JC}),p(Wr,{path:"/cms/data/new",component:tge}),p(Wr,{path:"/cms/data/:id",component:ca}),p(Wr,{path:"/cms/data/:id/edit",component:Jhe}),p(Wr,{path:"/cms/logs",component:ege}),p(Wr,{path:"/cms/releases",component:Wk}),p(Wr,{path:"/cms/releases/new",component:rge}),p(Wr,{path:"/cms/releases/:id",component:wu}),p(Wr,{path:"/cms/releases/:id/edit",component:Qhe}),p(Wr,{path:"/cms/settings",component:ige}),p(Wr,{path:"/cms/tools/:id",component:age}),p(Wr,{path:"/cms/translations",component:Jk}),p(Wr,{path:"/cms/translations/arb",component:l_}),p(Wr,{path:"/cms/translations/:hash",component:Xk}),p(Wr,{path:"/cms/translations/:collection/:slug",component:Hd}),p(Wr,{default:!0,component:oge})]})})})})})})})})}function htt(){let t=window.location.pathname;window.location.search&&(t=`${t}?${window.location.search}`);let e=new URLSearchParams({continue:t});window.location.replace(`/cms/login?${e.toString()}`)}var Qk=$O(window.__ROOT_CTX.firebaseConfig),gtt=window.__ROOT_CTX.firebaseConfig.databaseId||"(default)",_tt=$J(Qk,{experimentalForceLongPolling:!0,useFetchStreams:!1},gtt),cge=gD(Qk),xtt=vQ(Qk);cge.onAuthStateChanged(t=>{if(!t){htt();return}window.firebase={app:Qk,auth:cge,db:_tt,storage:xtt,user:t};let e=document.getElementById("root");e.innerHTML="",jc(p(mtt,{}),e),btt(t)});async function btt(t){let e=await t.getIdToken(),r=await fetch("/cms/login",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({idToken:e})});if(r.status!==200){console.error("login failed"),console.log(r);return}if(!(await r.json()).success){console.error("login failed"),console.log(r);return}}})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blinkk/root-cms",
3
- "version": "2.3.3",
3
+ "version": "2.4.1",
4
4
  "author": "s@blinkk.com",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -133,10 +133,10 @@
133
133
  "vite": "7.1.4",
134
134
  "vitest": "3.2.4",
135
135
  "yjs": "13.6.27",
136
- "@blinkk/root": "2.3.3"
136
+ "@blinkk/root": "2.4.1"
137
137
  },
138
138
  "peerDependencies": {
139
- "@blinkk/root": "2.3.3",
139
+ "@blinkk/root": "2.4.1",
140
140
  "firebase-admin": ">=11",
141
141
  "firebase-functions": ">=4",
142
142
  "preact": ">=10",