@blinkk/root-cms 2.2.13 → 2.3.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.2.13",
86
+ version: "2.3.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.2.13",
235
+ "@blinkk/root": "2.3.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.2.13",
2555
+ version: "2.3.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.2.13",
2704
+ "@blinkk/root": "2.3.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}Ee();function Oe(...t){return t.filter(e=>!!e).join(" ")||void 0}ao();ao();var uMe=0,fNt=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:--uMe,__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 GQ(t){let{oldCode:e,newCode:r,className:o=""}=t,n=ge(()=>qM(e,r),[e,r]),i=W(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,u)=>{let d=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:Oe("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:d}),p("span",{children:m||" "})]})]},`${u}-${h}`))})}),s};return p("div",{className:Oe("JsDiff__container",o),children:p("div",{className:"JsDiff__content",ref:i,children:a()})})}var Qee=zp(Jee(),1);var lL=Qee.default;var p2e={};function cL(t,e){let r=e||p2e,o=typeof r.includeImageAlt=="boolean"?r.includeImageAlt:!0,n=typeof r.includeHtml=="boolean"?r.includeHtml:!0;return ete(t,o,n)}function ete(t,e,r){if(m2e(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 Zee(t.children,e,r)}return Array.isArray(t)?Zee(t,e,r):""}function Zee(t,e,r){let o=[],n=-1;for(;++n<t.length;)o[n]=ete(t[n],e,r);return o.join("")}function m2e(t){return!!(t&&typeof t=="object")}var tte=document.createElement("i");function Eh(t){let e="&"+t+";";tte.innerHTML=e;let r=tte.textContent;return r.charCodeAt(r.length-1)===59&&t!=="semi"||r===e?!1:r}function Po(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 ci(t,e){return t.length>0?(Po(t,t.length,0,e),t):e}var rte={}.hasOwnProperty;function GS(t){let e={},r=-1;for(;++r<t.length;)h2e(e,t[r]);return e}function h2e(t,e){let r;for(r in e){let n=(rte.call(t,r)?t[r]:void 0)||(t[r]={}),i=e[r],a;if(i)for(a in i){rte.call(n,a)||(n[a]=[]);let s=i[a];g2e(n[a],Array.isArray(s)?s:s?[s]:[])}}}function g2e(t,e){let r=-1,o=[];for(;++r<e.length;)(e[r].add==="after"?t:o).push(e[r]);Po(t,0,0,o)}function WS(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 jn(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}var Uo=ku(/[A-Za-z]/),Vo=ku(/[\dA-Za-z]/),ote=ku(/[#-'*+\--9=?A-Z^-~]/);function Af(t){return t!==null&&(t<32||t===127)}var Wb=ku(/\d/),nte=ku(/[\dA-Fa-f]/),ite=ku(/[!-/:-@[-`{-~]/);function Pe(t){return t!==null&&t<-2}function At(t){return t!==null&&(t<0||t===32)}function lt(t){return t===-2||t===-1||t===32}var Df=ku(/\p{P}|\p{S}/u),ll=ku(/\s/);function ku(t){return e;function e(r){return r!==null&&r>-1&&t.test(String.fromCharCode(r))}}function nt(t,e,r,o){let n=o?o-1:Number.POSITIVE_INFINITY,i=0;return a;function a(l){return lt(l)?(t.enter(r),s(l)):e(l)}function s(l){return lt(l)&&i++<n?(t.consume(l),s):(t.exit(r),e(l))}}var ate={tokenize:_2e};function _2e(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"),nt(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 Pe(s)?(t.consume(s),t.exit("chunkText"),i):(t.consume(s),a)}}var lte={tokenize:x2e},ste={tokenize:b2e};function x2e(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,I;for(;N--;)if(e.events[N][0]==="exit"&&e.events[N][1].type==="chunkFlow"){I=e.events[N][1].end;break}b(o);let E=S;for(;E<e.events.length;)e.events[E][1].end=Object.assign({},I),E++;return Po(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(ste,u,d)(v)}function u(v){return n&&y(),b(o),f(v)}function d(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(ste,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 Pe(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 I=n.events.length;for(;I--;)if(n.events[I][1].start.offset<a&&(!n.events[I][1].end||n.events[I][1].end.offset>a))return;let E=e.events.length,w=E,C,T;for(;w--;)if(e.events[w][0]==="exit"&&e.events[w][1].type==="chunkFlow"){if(C){T=e.events[w][1].end;break}C=!0}for(b(o),I=E;I<e.events.length;)e.events[I][1].end=Object.assign({},T),I++;Po(e.events,w+1,0,e.events.slice(E)),e.events.length=I}}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 b2e(t,e,r){return nt(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||At(t)||ll(t))return 1;if(Df(t))return 2}function Nu(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 qb={name:"attention",tokenize:v2e,resolveAll:y2e};function y2e(t,e){let r=-1,o,n,i,a,s,l,c,u;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 d=Object.assign({},t[o][1].end),f=Object.assign({},t[r][1].start);cte(d,-l),cte(f,l),a={type:l>1?"strongSequence":"emphasisSequence",start:d,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=ci(c,[["enter",t[o][1],e],["exit",t[o][1],e]])),c=ci(c,[["enter",n,e],["enter",a,e],["exit",a,e],["enter",i,e]]),c=ci(c,Nu(e.parser.constructs.insideSpan.null,t.slice(o+1,r),e)),c=ci(c,[["exit",i,e],["enter",s,e],["exit",s,e],["exit",n,e]]),t[r][1].end.offset-t[r][1].start.offset?(u=2,c=ci(c,[["enter",t[r][1],e],["exit",t[r][1],e]])):u=0,Po(t,o-1,r-o+3,c),r=o+c.length-u-2;break}}for(r=-1;++r<t.length;)t[r][1].type==="attentionSequence"&&(t[r][1].type="data");return t}function v2e(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"),u=Sh(l),d=!u||u===2&&n||r.includes(l),f=!n||n===2&&u||r.includes(o);return c._open=!!(i===42?d:d&&(n||!f)),c._close=!!(i===42?f:f&&(u||!d)),e(l)}}function cte(t,e){t.column+=e,t.offset+=e,t._bufferIndex+=e}var uL={name:"autolink",tokenize:I2e};function I2e(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 Uo(m)?(t.consume(m),a):m===64?r(m):c(m)}function a(m){return m===43||m===45||m===46||Vo(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||Vo(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||Af(m)?r(m):(t.consume(m),l)}function c(m){return m===64?(t.consume(m),u):ote(m)?(t.consume(m),c):r(m)}function u(m){return Vo(m)?d(m):r(m)}function d(m){return m===46?(t.consume(m),o=0,u):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||Vo(m))&&o++<63){let h=m===45?f:d;return t.consume(m),h}return r(m)}}var cl={tokenize:w2e,partial:!0};function w2e(t,e,r){return o;function o(i){return lt(i)?nt(t,n,"linePrefix")(i):n(i)}function n(i){return i===null||Pe(i)?e(i):r(i)}}var qS={name:"blockQuote",tokenize:E2e,continuation:{tokenize:S2e},exit:C2e};function E2e(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 lt(a)?(t.enter("blockQuotePrefixWhitespace"),t.consume(a),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),e):(t.exit("blockQuotePrefix"),e(a))}}function S2e(t,e,r){let o=this;return n;function n(a){return lt(a)?nt(t,i,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):i(a)}function i(a){return t.attempt(qS,e,r)(a)}}function C2e(t){t.exit("blockQuote")}var KS={name:"characterEscape",tokenize:T2e};function T2e(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 ite(i)?(t.enter("characterEscapeValue"),t.consume(i),t.exit("characterEscapeValue"),t.exit("characterEscape"),e):r(i)}}var YS={name:"characterReference",tokenize:k2e};function k2e(t,e,r){let o=this,n=0,i,a;return s;function s(d){return t.enter("characterReference"),t.enter("characterReferenceMarker"),t.consume(d),t.exit("characterReferenceMarker"),l}function l(d){return d===35?(t.enter("characterReferenceMarkerNumeric"),t.consume(d),t.exit("characterReferenceMarkerNumeric"),c):(t.enter("characterReferenceValue"),i=31,a=Vo,u(d))}function c(d){return d===88||d===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(d),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),i=6,a=nte,u):(t.enter("characterReferenceValue"),i=7,a=Wb,u(d))}function u(d){if(d===59&&n){let f=t.exit("characterReferenceValue");return a===Vo&&!Eh(o.sliceSerialize(f))?r(d):(t.enter("characterReferenceMarker"),t.consume(d),t.exit("characterReferenceMarker"),t.exit("characterReference"),e)}return a(d)&&n++<i?(t.consume(d),u):r(d)}}var ute={tokenize:P2e,partial:!0},XS={name:"codeFenced",tokenize:N2e,concrete:!0};function N2e(t,e,r){let o=this,n={tokenize:N,partial:!0},i=0,a=0,s;return l;function l(I){return c(I)}function c(I){let E=o.events[o.events.length-1];return i=E&&E[1].type==="linePrefix"?E[2].sliceSerialize(E[1],!0).length:0,s=I,t.enter("codeFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),u(I)}function u(I){return I===s?(a++,t.consume(I),u):a<3?r(I):(t.exit("codeFencedFenceSequence"),lt(I)?nt(t,d,"whitespace")(I):d(I))}function d(I){return I===null||Pe(I)?(t.exit("codeFencedFence"),o.interrupt?e(I):t.check(ute,g,S)(I)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),f(I))}function f(I){return I===null||Pe(I)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),d(I)):lt(I)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),nt(t,m,"whitespace")(I)):I===96&&I===s?r(I):(t.consume(I),f)}function m(I){return I===null||Pe(I)?d(I):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),h(I))}function h(I){return I===null||Pe(I)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),d(I)):I===96&&I===s?r(I):(t.consume(I),h)}function g(I){return t.attempt(n,S,_)(I)}function _(I){return t.enter("lineEnding"),t.consume(I),t.exit("lineEnding"),b}function b(I){return i>0&&lt(I)?nt(t,y,"linePrefix",i+1)(I):y(I)}function y(I){return I===null||Pe(I)?t.check(ute,g,S)(I):(t.enter("codeFlowValue"),v(I))}function v(I){return I===null||Pe(I)?(t.exit("codeFlowValue"),y(I)):(t.consume(I),v)}function S(I){return t.exit("codeFenced"),e(I)}function N(I,E,w){let C=0;return T;function T($){return I.enter("lineEnding"),I.consume($),I.exit("lineEnding"),A}function A($){return I.enter("codeFencedFence"),lt($)?nt(I,R,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)($):R($)}function R($){return $===s?(I.enter("codeFencedFenceSequence"),P($)):w($)}function P($){return $===s?(C++,I.consume($),P):C>=a?(I.exit("codeFencedFenceSequence"),lt($)?nt(I,B,"whitespace")($):B($)):w($)}function B($){return $===null||Pe($)?(I.exit("codeFencedFence"),E($)):w($)}}}function P2e(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 Kb={name:"codeIndented",tokenize:A2e},O2e={tokenize:D2e,partial:!0};function A2e(t,e,r){let o=this;return n;function n(c){return t.enter("codeIndented"),nt(t,i,"linePrefix",5)(c)}function i(c){let u=o.events[o.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?a(c):r(c)}function a(c){return c===null?l(c):Pe(c)?t.attempt(O2e,a,l)(c):(t.enter("codeFlowValue"),s(c))}function s(c){return c===null||Pe(c)?(t.exit("codeFlowValue"),a(c)):(t.consume(c),s)}function l(c){return t.exit("codeIndented"),e(c)}}function D2e(t,e,r){let o=this;return n;function n(a){return o.parser.lazy[o.now().line]?r(a):Pe(a)?(t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),n):nt(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):Pe(a)?n(a):r(a)}}var dL={name:"codeText",tokenize:L2e,resolve:R2e,previous:M2e};function R2e(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 M2e(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function L2e(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,d(f)):Pe(f)?(t.enter("lineEnding"),t.consume(f),t.exit("lineEnding"),c):(t.enter("codeTextData"),u(f))}function u(f){return f===null||f===32||f===96||Pe(f)?(t.exit("codeTextData"),c(f)):(t.consume(f),u)}function d(f){return f===96?(t.consume(f),i++,d):i===n?(t.exit("codeTextSequence"),t.exit("codeText"),e(f)):(a.type="codeTextData",u(f))}}var JS=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&&Yb(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),Yb(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Yb(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);Yb(this.right,r.reverse())}else{let r=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);Yb(this.left,r.reverse())}}};function Yb(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 QS(t){let e={},r=-1,o,n,i,a,s,l,c,u=new JS(t);for(;++r<u.length;){for(;r in e;)r=e[r];if(o=u.get(r),r&&o[1].type==="chunkFlow"&&u.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,F2e(u,r)),r=e[r],c=!0);else if(o[1]._container){for(i=r,n=void 0;i--&&(a=u.get(i),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank");)a[0]==="enter"&&(n&&(u.get(n)[1].type="lineEndingBlank"),a[1].type="lineEnding",n=i);n&&(o[1].end=Object.assign({},u.get(n)[1].start),s=u.slice(n,r),s.unshift(o),u.splice(n,r-n+1,s))}}return Po(t,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function F2e(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={},u,d,f=-1,m=r,h=0,g=0,_=[g];for(;m;){for(;t.get(++n)[1]!==m;);i.push(n),m._tokenizer||(u=o.sliceStream(m),m.next||u.push(null),d&&a.defineSkip(m.start),m._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(u),m._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),d=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 fL={tokenize:z2e,resolve:$2e},B2e={tokenize:U2e,partial:!0};function $2e(t){return QS(t),t}function z2e(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):Pe(s)?t.check(B2e,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 U2e(t,e,r){let o=this;return n;function n(a){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),nt(t,i,"linePrefix")}function i(a){if(a===null||Pe(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 ZS(t,e,r,o,n,i,a,s,l){let c=l||Number.POSITIVE_INFINITY,u=0;return d;function d(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||Af(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||Pe(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!u&&(b===null||b===41||At(b))?(t.exit("chunkString"),t.exit(s),t.exit(a),t.exit(o),e(b)):u<c&&b===40?(t.consume(b),u++,g):b===41?(t.consume(b),u--,g):b===null||b===32||b===40||Af(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 eC(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),u}function u(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):Pe(m)?(t.enter("lineEnding"),t.consume(m),t.exit("lineEnding"),u):(t.enter("chunkString",{contentType:"string"}),d(m))}function d(m){return m===null||m===91||m===93||Pe(m)||s++>999?(t.exit("chunkString"),u(m)):(t.consume(m),l||(l=!lt(m)),m===92?f:d)}function f(m){return m===91||m===92||m===93?(t.consume(m),s++,d):d(m)}}function tC(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):Pe(f)?(t.enter("lineEnding"),t.consume(f),t.exit("lineEnding"),nt(t,c,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),u(f))}function u(f){return f===a||f===null||Pe(f)?(t.exit("chunkString"),c(f)):(t.consume(f),f===92?d:u)}function d(f){return f===a||f===92?(t.consume(f),u):u(f)}}function Rf(t,e){let r;return o;function o(n){return Pe(n)?(t.enter("lineEnding"),t.consume(n),t.exit("lineEnding"),r=!0,o):lt(n)?nt(t,o,r?"linePrefix":"lineSuffix")(n):e(n)}}var pL={name:"definition",tokenize:H2e},V2e={tokenize:j2e,partial:!0};function H2e(t,e,r){let o=this,n;return i;function i(m){return t.enter("definition"),a(m)}function a(m){return eC.call(o,t,s,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(m)}function s(m){return n=jn(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 At(m)?Rf(t,c)(m):c(m)}function c(m){return ZS(t,u,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(m)}function u(m){return t.attempt(V2e,d,d)(m)}function d(m){return lt(m)?nt(t,f,"whitespace")(m):f(m)}function f(m){return m===null||Pe(m)?(t.exit("definition"),o.parser.defined.push(n),e(m)):r(m)}}function j2e(t,e,r){return o;function o(s){return At(s)?Rf(t,n)(s):r(s)}function n(s){return tC(t,i,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(s)}function i(s){return lt(s)?nt(t,a,"whitespace")(s):a(s)}function a(s){return s===null||Pe(s)?e(s):r(s)}}var mL={name:"hardBreakEscape",tokenize:G2e};function G2e(t,e,r){return o;function o(i){return t.enter("hardBreakEscape"),t.consume(i),n}function n(i){return Pe(i)?(t.exit("hardBreakEscape"),e(i)):r(i)}}var hL={name:"headingAtx",tokenize:q2e,resolve:W2e};function W2e(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"},Po(t,o,r-o+1,[["enter",n,e],["enter",i,e],["exit",i,e],["exit",n,e]])),t}function q2e(t,e,r){let o=0;return n;function n(u){return t.enter("atxHeading"),i(u)}function i(u){return t.enter("atxHeadingSequence"),a(u)}function a(u){return u===35&&o++<6?(t.consume(u),a):u===null||At(u)?(t.exit("atxHeadingSequence"),s(u)):r(u)}function s(u){return u===35?(t.enter("atxHeadingSequence"),l(u)):u===null||Pe(u)?(t.exit("atxHeading"),e(u)):lt(u)?nt(t,s,"whitespace")(u):(t.enter("atxHeadingText"),c(u))}function l(u){return u===35?(t.consume(u),l):(t.exit("atxHeadingSequence"),s(u))}function c(u){return u===null||u===35||At(u)?(t.exit("atxHeadingText"),s(u)):(t.consume(u),c)}}var dte=["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"],gL=["pre","script","style","textarea"];var _L={name:"htmlFlow",tokenize:J2e,resolveTo:X2e,concrete:!0},K2e={tokenize:Z2e,partial:!0},Y2e={tokenize:Q2e,partial:!0};function X2e(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 J2e(t,e,r){let o=this,n,i,a,s,l;return c;function c(U){return u(U)}function u(U){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(U),d}function d(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):Uo(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):Uo(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 _e="CDATA[";return U===_e.charCodeAt(s++)?(t.consume(U),s===_e.length?o.interrupt?e:R:h):r(U)}function g(U){return Uo(U)?(t.consume(U),a=String.fromCharCode(U),_):r(U)}function _(U){if(U===null||U===47||U===62||At(U)){let _e=U===47,Te=a.toLowerCase();return!_e&&!i&&gL.includes(Te)?(n=1,o.interrupt?e(U):R(U)):dte.includes(a.toLowerCase())?(n=6,_e?(t.consume(U),b):o.interrupt?e(U):R(U)):(n=7,o.interrupt&&!o.parser.lazy[o.now().line]?r(U):i?y(U):v(U))}return U===45||Vo(U)?(t.consume(U),a+=String.fromCharCode(U),_):r(U)}function b(U){return U===62?(t.consume(U),o.interrupt?e:R):r(U)}function y(U){return lt(U)?(t.consume(U),y):T(U)}function v(U){return U===47?(t.consume(U),T):U===58||U===95||Uo(U)?(t.consume(U),S):lt(U)?(t.consume(U),v):T(U)}function S(U){return U===45||U===46||U===58||U===95||Vo(U)?(t.consume(U),S):N(U)}function N(U){return U===61?(t.consume(U),I):lt(U)?(t.consume(U),N):v(U)}function I(U){return U===null||U===60||U===61||U===62||U===96?r(U):U===34||U===39?(t.consume(U),l=U,E):lt(U)?(t.consume(U),I):w(U)}function E(U){return U===l?(t.consume(U),l=null,C):U===null||Pe(U)?r(U):(t.consume(U),E)}function w(U){return U===null||U===34||U===39||U===47||U===60||U===61||U===62||U===96||At(U)?N(U):(t.consume(U),w)}function C(U){return U===47||U===62||lt(U)?v(U):r(U)}function T(U){return U===62?(t.consume(U),A):r(U)}function A(U){return U===null||Pe(U)?R(U):lt(U)?(t.consume(U),A):r(U)}function R(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):Pe(U)&&(n===6||n===7)?(t.exit("htmlFlowData"),t.check(K2e,ae,P)(U)):U===null||Pe(U)?(t.exit("htmlFlowData"),P(U)):(t.consume(U),R)}function P(U){return t.check(Y2e,B,ae)(U)}function B(U){return t.enter("lineEnding"),t.consume(U),t.exit("lineEnding"),$}function $(U){return U===null||Pe(U)?P(U):(t.enter("htmlFlowData"),R(U))}function z(U){return U===45?(t.consume(U),L):R(U)}function H(U){return U===47?(t.consume(U),a="",G):R(U)}function G(U){if(U===62){let _e=a.toLowerCase();return gL.includes(_e)?(t.consume(U),ne):R(U)}return Uo(U)&&a.length<8?(t.consume(U),a+=String.fromCharCode(U),G):R(U)}function Y(U){return U===93?(t.consume(U),L):R(U)}function L(U){return U===62?(t.consume(U),ne):U===45&&n===2?(t.consume(U),L):R(U)}function ne(U){return U===null||Pe(U)?(t.exit("htmlFlowData"),ae(U)):(t.consume(U),ne)}function ae(U){return t.exit("htmlFlow"),e(U)}}function Q2e(t,e,r){let o=this;return n;function n(a){return Pe(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 Z2e(t,e,r){return o;function o(n){return t.enter("lineEnding"),t.consume(n),t.exit("lineEnding"),t.attempt(cl,e,r)}}var xL={name:"htmlText",tokenize:eFe};function eFe(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):Uo(L)?(t.consume(L),w):r(L)}function c(L){return L===45?(t.consume(L),u):L===91?(t.consume(L),i=0,h):Uo(L)?(t.consume(L),y):r(L)}function u(L){return L===45?(t.consume(L),m):r(L)}function d(L){return L===null?r(L):L===45?(t.consume(L),f):Pe(L)?(a=d,H(L)):(t.consume(L),d)}function f(L){return L===45?(t.consume(L),m):d(L)}function m(L){return L===62?z(L):L===45?f(L):d(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),_):Pe(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):Pe(L)?(a=y,H(L)):(t.consume(L),y)}function v(L){return L===null?r(L):L===63?(t.consume(L),S):Pe(L)?(a=v,H(L)):(t.consume(L),v)}function S(L){return L===62?z(L):v(L)}function N(L){return Uo(L)?(t.consume(L),I):r(L)}function I(L){return L===45||Vo(L)?(t.consume(L),I):E(L)}function E(L){return Pe(L)?(a=E,H(L)):lt(L)?(t.consume(L),E):z(L)}function w(L){return L===45||Vo(L)?(t.consume(L),w):L===47||L===62||At(L)?C(L):r(L)}function C(L){return L===47?(t.consume(L),z):L===58||L===95||Uo(L)?(t.consume(L),T):Pe(L)?(a=C,H(L)):lt(L)?(t.consume(L),C):z(L)}function T(L){return L===45||L===46||L===58||L===95||Vo(L)?(t.consume(L),T):A(L)}function A(L){return L===61?(t.consume(L),R):Pe(L)?(a=A,H(L)):lt(L)?(t.consume(L),A):C(L)}function R(L){return L===null||L===60||L===61||L===62||L===96?r(L):L===34||L===39?(t.consume(L),n=L,P):Pe(L)?(a=R,H(L)):lt(L)?(t.consume(L),R):(t.consume(L),B)}function P(L){return L===n?(t.consume(L),n=void 0,$):L===null?r(L):Pe(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||At(L)?C(L):(t.consume(L),B)}function $(L){return L===47||L===62||At(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"),G}function G(L){return lt(L)?nt(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 Mf={name:"labelEnd",tokenize:aFe,resolveTo:iFe,resolveAll:nFe},tFe={tokenize:sFe},rFe={tokenize:lFe},oFe={tokenize:cFe};function nFe(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 iFe(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)},u={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=ci(s,t.slice(i+1,i+o+3)),s=ci(s,[["enter",u,e]]),s=ci(s,Nu(e.parser.constructs.insideSpan.null,t.slice(i+o+4,a-3),e)),s=ci(s,[["exit",u,e],t[a-2],t[a-1],["exit",c,e]]),s=ci(s,t.slice(a+1)),s=ci(s,[["exit",l,e]]),Po(t,i,t.length,s),t}function aFe(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?d(f):(a=o.parser.defined.includes(jn(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(tFe,u,a?u:d)(f):f===91?t.attempt(rFe,u,a?c:d)(f):a?u(f):d(f)}function c(f){return t.attempt(oFe,u,d)(f)}function u(f){return e(f)}function d(f){return i._balanced=!0,r(f)}}function sFe(t,e,r){return o;function o(d){return t.enter("resource"),t.enter("resourceMarker"),t.consume(d),t.exit("resourceMarker"),n}function n(d){return At(d)?Rf(t,i)(d):i(d)}function i(d){return d===41?u(d):ZS(t,a,s,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function a(d){return At(d)?Rf(t,l)(d):u(d)}function s(d){return r(d)}function l(d){return d===34||d===39||d===40?tC(t,c,r,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):u(d)}function c(d){return At(d)?Rf(t,u)(d):u(d)}function u(d){return d===41?(t.enter("resourceMarker"),t.consume(d),t.exit("resourceMarker"),t.exit("resource"),e):r(d)}}function lFe(t,e,r){let o=this;return n;function n(s){return eC.call(o,t,i,a,"reference","referenceMarker","referenceString")(s)}function i(s){return o.parser.defined.includes(jn(o.sliceSerialize(o.events[o.events.length-1][1]).slice(1,-1)))?e(s):r(s)}function a(s){return r(s)}}function cFe(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 bL={name:"labelStartImage",tokenize:uFe,resolveAll:Mf.resolveAll};function uFe(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 yL={name:"labelStartLink",tokenize:dFe,resolveAll:Mf.resolveAll};function dFe(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 Xb={name:"lineEnding",tokenize:fFe};function fFe(t,e){return r;function r(o){return t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),nt(t,e,"linePrefix")}}var Lf={name:"thematicBreak",tokenize:pFe};function pFe(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||Pe(c))?(t.exit("thematicBreak"),e(c)):r(c)}function l(c){return c===n?(t.consume(c),o++,l):(t.exit("thematicBreakSequence"),lt(c)?nt(t,s,"whitespace")(c):s(c))}}var Gn={name:"list",tokenize:gFe,continuation:{tokenize:_Fe},exit:bFe},mFe={tokenize:yFe,partial:!0},hFe={tokenize:xFe,partial:!0};function gFe(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:Wb(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(Lf,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 Wb(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(cl,o.interrupt?r:u,t.attempt(mFe,f,d))}function u(m){return o.containerState.initialBlankLine=!0,i++,f(m)}function d(m){return lt(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 _Fe(t,e,r){let o=this;return o.containerState._closeFlow=void 0,t.check(cl,n,i);function n(s){return o.containerState.furtherBlankLines=o.containerState.furtherBlankLines||o.containerState.initialBlankLine,nt(t,e,"listItemIndent",o.containerState.size+1)(s)}function i(s){return o.containerState.furtherBlankLines||!lt(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(hFe,e,a)(s))}function a(s){return o.containerState._closeFlow=!0,o.interrupt=void 0,nt(t,t.attempt(Gn,e,r),"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s)}}function xFe(t,e,r){let o=this;return nt(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 bFe(t){t.exit(this.containerState.type)}function yFe(t,e,r){let o=this;return nt(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!lt(i)&&a&&a[1].type==="listItemPrefixWhitespace"?e(i):r(i)}}var rC={name:"setextUnderline",tokenize:IFe,resolveTo:vFe};function vFe(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 IFe(t,e,r){let o=this,n;return i;function i(c){let u=o.events.length,d;for(;u--;)if(o.events[u][1].type!=="lineEnding"&&o.events[u][1].type!=="linePrefix"&&o.events[u][1].type!=="content"){d=o.events[u][1].type==="paragraph";break}return!o.parser.lazy[o.now().line]&&(o.interrupt||d)?(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"),lt(c)?nt(t,l,"lineSuffix")(c):l(c))}function l(c){return c===null||Pe(c)?(t.exit("setextHeadingLine"),e(c)):r(c)}}var fte={tokenize:wFe};function wFe(t){let e=this,r=t.attempt(cl,o,t.attempt(this.parser.constructs.flowInitial,n,nt(t,t.attempt(this.parser.constructs.flow,n,t.attempt(fL,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 pte={resolveAll:_te()},mte=gte("string"),hte=gte("text");function gte(t){return{tokenize:e,resolveAll:_te(t==="text"?EFe:void 0)};function e(r){let o=this,n=this.parser.constructs[t],i=r.attempt(n,a,s);return a;function a(u){return c(u)?i(u):s(u)}function s(u){if(u===null){r.consume(u);return}return r.enter("data"),r.consume(u),l}function l(u){return c(u)?(r.exit("data"),i(u)):(r.consume(u),l)}function c(u){if(u===null)return!0;let d=n[u],f=-1;if(d)for(;++f<d.length;){let m=d[f];if(!m.previous||m.previous.call(o,o.previous))return!0}return!1}}}function _te(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 EFe(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 xte(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:I,attempt:C(E),check:C(w),interrupt:C(w,{interrupt:!0})},u={previous:null,code:null,containerState:{},events:[],parser:t,sliceStream:g,sliceSerialize:h,now:_,defineSkip:b,write:m},d=e.tokenize.call(u,c),f;return e.resolveAll&&i.push(e),u;function m(P){return a=ci(a,P),y(),a[a.length-1]!==null?[]:(T(e,0),u.events=Nu(i,u.events,u),u.events)}function h(P,B){return CFe(g(P),B)}function g(P){return SFe(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,R()}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,d=d(P)}function S(P){Pe(P)?(o.line++,o.column=1,o.offset+=P===-3?2:1,R()):P!==-1&&(o.column++,o.offset++),o._bufferIndex<0?o._index++:(o._bufferIndex++,o._bufferIndex===a[o._index].length&&(o._bufferIndex=-1,o._index++)),u.previous=P,l=!0}function N(P,B){let $=B||{};return $.type=P,$.start=_(),u.events.push(["enter",$,u]),s.push($),$}function I(P){let B=s.pop();return B.end=_(),u.events.push(["exit",B,u]),B}function E(P,B){T(P,B.from)}function w(P,B){B.restore()}function C(P,B){return $;function $(z,H,G){let Y,L,ne,ae;return Array.isArray(z)?_e(z):"tokenize"in z?_e([z]):U(z);function U(Me){return Ne;function Ne(st){let Rt=st!==null&&Me[st],dt=st!==null&&Me.null,ht=[...Array.isArray(Rt)?Rt:Rt?[Rt]:[],...Array.isArray(dt)?dt:dt?[dt]:[]];return _e(ht)(st)}}function _e(Me){return Y=Me,L=0,Me.length===0?G:Te(Me[L])}function Te(Me){return Ne;function Ne(st){return ae=A(),ne=Me,Me.partial||(u.currentConstruct=Me),Me.name&&u.parser.constructs.disable.null.includes(Me.name)?Qe(st):Me.tokenize.call(B?Object.assign(Object.create(u),B):u,c,je,Qe)(st)}}function je(Me){return l=!0,P(ne,ae),H}function Qe(Me){return l=!0,ae.restore(),++L<Y.length?Te(Y[L]):G}}}function T(P,B){P.resolveAll&&!i.includes(P)&&i.push(P),P.resolve&&Po(u.events,B,u.events.length-B,P.resolve(u.events.slice(B),u)),P.resolveTo&&(u.events=P.resolveTo(u.events,u))}function A(){let P=_(),B=u.previous,$=u.currentConstruct,z=u.events.length,H=Array.from(s);return{restore:G,from:z};function G(){o=P,u.previous=B,u.currentConstruct=$,u.events.length=z,s=H,R()}}function R(){o.line in n&&o.column<2&&(o.column=n[o.line],o.offset+=n[o.line]-1)}}function SFe(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 CFe(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 vL={};nr(vL,{attentionMarkers:()=>RFe,contentInitial:()=>kFe,disable:()=>MFe,document:()=>TFe,flow:()=>PFe,flowInitial:()=>NFe,insideSpan:()=>DFe,string:()=>OFe,text:()=>AFe});var TFe={42:Gn,43:Gn,45:Gn,48:Gn,49:Gn,50:Gn,51:Gn,52:Gn,53:Gn,54:Gn,55:Gn,56:Gn,57:Gn,62:qS},kFe={91:pL},NFe={[-2]:Kb,[-1]:Kb,32:Kb},PFe={35:hL,42:Lf,45:[rC,Lf],60:_L,61:rC,95:Lf,96:XS,126:XS},OFe={38:YS,92:KS},AFe={[-5]:Xb,[-4]:Xb,[-3]:Xb,33:bL,38:YS,42:qb,60:[uL,xL],91:yL,92:[mL,KS],93:Mf,95:qb,96:dL},DFe={null:[qb,pte]},RFe={null:[42,95]},MFe={null:[]};function IL(t){let r=GS([vL,...(t||{}).extensions||[]]),o={defined:[],lazy:{},constructs:r,content:n(ate),document:n(lte),flow:n(fte),string:n(mte),text:n(hte)};return o;function n(i){return a;function a(s){return xte(o,i,s)}}}function wL(t){for(;!QS(t););return t}var bte=/[\0\t\n\r]/g;function EL(){let t=1,e="",r=!0,o;return n;function n(i,a,s){let l=[],c,u,d,f,m;for(i=e+(typeof i=="string"?i.toString():new TextDecoder(a||void 0).decode(i)),d=0,e="",r&&(i.charCodeAt(0)===65279&&d++,r=void 0);d<i.length;){if(bte.lastIndex=d,c=bte.exec(i),f=c&&c.index!==void 0?c.index:i.length,m=i.charCodeAt(f),!c){e=i.slice(d);break}if(m===10&&d===f&&o)l.push(-3),o=void 0;else switch(o&&(l.push(-5),o=void 0),d<f&&(l.push(i.slice(d,f)),t+=f-d),m){case 0:{l.push(65533),t++;break}case 9:{for(u=Math.ceil(t/4)*4,l.push(-2);t++<u;)l.push(-1);break}case 10:{l.push(-4),t=1;break}default:o=!0,t=1}d=f+1}return s&&(o&&l.push(-5),e&&l.push(e),l.push(null)),l}}var LFe=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function yte(t){return t.replace(LFe,FFe)}function FFe(t,e,r){if(e)return e;if(r.charCodeAt(0)===35){let n=r.charCodeAt(1),i=n===120||n===88;return WS(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?vte(t.position):"start"in t||"end"in t?vte(t):"line"in t||"column"in t?SL(t):""}function SL(t){return Ite(t&&t.line)+":"+Ite(t&&t.column)}function vte(t){return SL(t&&t.start)+"-"+SL(t&&t.end)}function Ite(t){return t&&typeof t=="number"?t:1}var Ete={}.hasOwnProperty;function CL(t,e,r){return typeof e!="string"&&(r=e,e=void 0),BFe(r)(wL(IL(r).document().write(EL()(t,e,!0))))}function BFe(t){let e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(Ut),autolinkProtocol:C,autolinkEmail:C,atxHeading:i(Xr),blockQuote:i(st),characterEscape:C,characterReference:C,codeFenced:i(Rt),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:i(Rt,a),codeText:i(dt,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(dn),label:a,link:i(Ut),listItem:i(Vr),listItemValue:f,listOrdered:i(pt,d),listUnordered:i(pt),paragraph:i(Hr),reference:U,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:i(Xr),strong:i(Ro),thematicBreak:i(ie)},exit:{atxHeading:l(),atxHeadingSequence:N,autolink:l(),autolinkEmail:Ne,autolinkProtocol:Me,blockQuote:l(),characterEscapeValue:T,characterReferenceMarkerHexadecimal:Te,characterReferenceMarkerNumeric:Te,characterReferenceValue:je,characterReference:Qe,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(R),hardBreakTrailing:l(R),htmlFlow:l(P),htmlFlowData:T,htmlText:l(B),htmlTextData:T,image:l(H),label:Y,labelText:G,lineEnding:A,link:l(z),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:_e,resourceDestinationString:L,resourceTitleString:ne,resource:ae,setextHeading:l(w),setextHeadingLineSequence:E,setextHeadingText:I,strong:l(),thematicBreak:l()}};Ste(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:u,data:r},He=[],yt=-1;for(;++yt<j.length;)if(j[yt][1].type==="listOrdered"||j[yt][1].type==="listUnordered")if(j[yt][0]==="enter")He.push(yt);else{let Nt=He.pop();yt=n(j,Nt,yt)}for(yt=-1;++yt<j.length;){let Nt=e[j[yt][0]];Ete.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]||wte).call(se,void 0,Nt[0])}for(Q.position={start:Pu(j.length>0?j[0][1].start:{line:1,column:1,offset:0}),end:Pu(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 He=Q-1,yt=-1,Nt=!1,Mn,xr,Nr,Xn;for(;++He<=se;){let io=j[He];switch(io[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{io[0]==="enter"?yt++:yt--,Xn=void 0;break}case"lineEndingBlank":{io[0]==="enter"&&(Mn&&!Xn&&!yt&&!Nr&&(Nr=He),Xn=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Xn=void 0}if(!yt&&io[0]==="enter"&&io[1].type==="listItemPrefix"||yt===-1&&io[0]==="exit"&&(io[1].type==="listUnordered"||io[1].type==="listOrdered")){if(Mn){let fn=He;for(xr=void 0;fn--;){let pn=j[fn];if(pn[1].type==="lineEnding"||pn[1].type==="lineEndingBlank"){if(pn[0]==="exit")continue;xr&&(j[xr][1].type="lineEndingBlank",Nt=!0),pn[1].type="lineEnding",xr=fn}else if(!(pn[1].type==="linePrefix"||pn[1].type==="blockQuotePrefix"||pn[1].type==="blockQuotePrefixWhitespace"||pn[1].type==="blockQuoteMarker"||pn[1].type==="listItemIndent"))break}Nr&&(!xr||Nr<xr)&&(Mn._spread=!0),Mn.end=Object.assign({},xr?j[xr][1].start:io[1].end),j.splice(xr||He,0,["exit",Mn,io[2]]),He++,se++}if(io[1].type==="listItemPrefix"){let fn={type:"listItem",_spread:!1,start:Object.assign({},io[1].start),end:void 0};Mn=fn,j.splice(He,0,["enter",fn,io[2]]),He++,se++,Nr=void 0,Xn=!0}}}return j[Q][1]._spread=Nt,se}function i(j,Q){return se;function se(He){s.call(this,j(He),He),Q&&Q.call(this,He)}}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:Pu(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(),He=this.tokenStack.pop();if(He)He[0].type!==j.type&&(Q?Q.call(this,j,He[0]):(He[1]||wte).call(this,j,He[0]));else throw new Error("Cannot close `"+j.type+"` ("+Ch({start:j.start,end:j.end})+"): it\u2019s not open");se.position.end=Pu(j.end)}function u(){return cL(this.stack.pop())}function d(){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=jn(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 I(){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 w(){this.data.setextHeadingSlurpLineEnding=void 0}function C(j){let se=this.stack[this.stack.length-1].children,He=se[se.length-1];(!He||He.type!=="text")&&(He=Be(),He.position={start:Pu(j.start),end:void 0},se.push(He)),this.stack.push(He)}function T(j){let Q=this.stack.pop();Q.value+=this.sliceSerialize(j),Q.position.end=Pu(j.end)}function A(j){let Q=this.stack[this.stack.length-1];if(this.data.atHardBreak){let se=Q.children[Q.children.length-1];se.position.end=Pu(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 R(){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 G(j){let Q=this.sliceSerialize(j),se=this.stack[this.stack.length-2];se.label=yte(Q),se.identifier=jn(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 He=j.children;se.children=He}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 _e(j){let Q=this.resume(),se=this.stack[this.stack.length-1];se.label=Q,se.identifier=jn(this.sliceSerialize(j)).toLowerCase(),this.data.referenceType="full"}function Te(j){this.data.characterReferenceType=j.type}function je(j){let Q=this.sliceSerialize(j),se=this.data.characterReferenceType,He;se?(He=WS(Q,se==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):He=Eh(Q);let yt=this.stack[this.stack.length-1];yt.value+=He}function Qe(j){let Q=this.stack.pop();Q.position.end=Pu(j.end)}function Me(j){T.call(this,j);let Q=this.stack[this.stack.length-1];Q.url=this.sliceSerialize(j)}function Ne(j){T.call(this,j);let Q=this.stack[this.stack.length-1];Q.url="mailto:"+this.sliceSerialize(j)}function st(){return{type:"blockquote",children:[]}}function Rt(){return{type:"code",lang:null,meta:null,value:""}}function dt(){return{type:"inlineCode",value:""}}function ht(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function bt(){return{type:"emphasis",children:[]}}function Xr(){return{type:"heading",depth:0,children:[]}}function Mt(){return{type:"break"}}function ve(){return{type:"html",value:""}}function dn(){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 Vr(j){return{type:"listItem",spread:j._spread,checked:null,children:[]}}function Hr(){return{type:"paragraph",children:[]}}function Ro(){return{type:"strong",children:[]}}function Be(){return{type:"text",value:""}}function ie(){return{type:"thematicBreak"}}}function Pu(t){return{line:t.line,column:t.column,offset:t.offset}}function Ste(t,e){let r=-1;for(;++r<e.length;){let o=e[r];Array.isArray(o)?Ste(t,o):$Fe(t,o)}}function $Fe(t,e){let r;for(r in e)if(Ete.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 wte(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 TL(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 kL(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 HFe;if(typeof t=="function")return oC(t);if(typeof t=="object")return Array.isArray(t)?zFe(t):UFe(t);if(typeof t=="string")return VFe(t);throw new Error("Expected function, string, or object as test")});function zFe(t){let e=[],r=-1;for(;++r<t.length;)e[r]=Th(t[r]);return oC(o);function o(...n){let i=-1;for(;++i<e.length;)if(e[i].apply(this,n))return!0;return!1}}function UFe(t){let e=t;return oC(r);function r(o){let n=o,i;for(i in t)if(n[i]!==e[i])return!1;return!0}}function VFe(t){return oC(e);function e(r){return r&&r.type===t}}function oC(t){return e;function e(r,o,n){return!!(jFe(r)&&t.call(this,r,typeof o=="number"?o:void 0,n||void 0))}}function HFe(){return!0}function jFe(t){return t!==null&&typeof t=="object"&&"type"in t}var Cte=[],Tte=!0,NL=!1,kte="skip";function PL(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,u){let d=l&&typeof l=="object"?l:{};if(typeof d.type=="string"){let m=typeof d.tagName=="string"?d.tagName:typeof d.name=="string"?d.name:void 0;Object.defineProperty(f,"name",{value:"node ("+(l.type+(m?"<"+m+">":""))+")"})}return f;function f(){let m=Cte,h,g,_;if((!e||i(l,c,u[u.length-1]||void 0))&&(m=GFe(r(l,u)),m[0]===NL))return m;if("children"in l&&l.children){let b=l;if(b.children&&m[0]!==kte)for(g=(o?b.children.length:-1)+a,_=u.concat(b);g>-1&&g<b.children.length;){let y=b.children[g];if(h=s(y,g,_)(),h[0]===NL)return h;g=typeof h[1]=="number"?h[1]:g+a}}return m}}}function GFe(t){return Array.isArray(t)?t:typeof t=="number"?[Tte,t]:t==null?Cte:[t]}function OL(t,e,r){let n=Th((r||{}).ignore||[]),i=WFe(e),a=-1;for(;++a<i.length;)PL(t,"text",s);function s(c,u){let d=-1,f;for(;++d<u.length;){let m=u[d],h=f?f.children:void 0;if(n(m,h?h.indexOf(m):void 0,f))return;f=m}if(f)return l(c,u)}function l(c,u){let d=u[u.length-1],f=i[a][0],m=i[a][1],h=0,_=d.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:[...u,c]},I=m(...v,N);if(typeof I=="string"&&(I=I.length>0?{type:"text",value:I}:void 0),I===!1?f.lastIndex=S+1:(h!==S&&y.push({type:"text",value:c.value.slice(h,S)}),Array.isArray(I)?y.push(...I):I&&y.push(I),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)}),d.children.splice(_,1,...y)):y=[c],_+y.length}}function WFe(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([qFe(n[0]),KFe(n[1])])}return e}function qFe(t){return typeof t=="string"?new RegExp(kL(t),"g"):t}function KFe(t){return typeof t=="function"?t:function(){return t}}function DL(){return{transforms:[eBe],enter:{literalAutolink:YFe,literalAutolinkEmail:AL,literalAutolinkHttp:AL,literalAutolinkWww:AL},exit:{literalAutolink:ZFe,literalAutolinkEmail:QFe,literalAutolinkHttp:XFe,literalAutolinkWww:JFe}}}function YFe(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function AL(t){this.config.enter.autolinkProtocol.call(this,t)}function XFe(t){this.config.exit.autolinkProtocol.call(this,t)}function JFe(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 QFe(t){this.config.exit.autolinkEmail.call(this,t)}function ZFe(t){this.exit(t)}function eBe(t){OL(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,tBe],[/([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/g,rBe]],{ignore:["link","linkReference"]})}function tBe(t,e,r,o,n){let i="";if(!Nte(n)||(/^w/i.test(e)&&(r=e+r,e="",i="http://"),!oBe(r)))return!1;let a=nBe(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 rBe(t,e,r,o){return!Nte(o,!0)||/[-\d_]$/.test(r)?!1:{type:"link",title:null,url:"mailto:"+e+"@"+r,children:[{type:"text",value:e+"@"+r}]}}function oBe(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 nBe(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=TL(t,"("),i=TL(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 Nte(t,e){let r=t.input.charCodeAt(t.index-1);return(t.index===0||ll(r)||Df(r))&&(!e||r!==47)}mBe.peek=hBe;function RL(){return{enter:{gfmFootnoteDefinition:aBe,gfmFootnoteDefinitionLabelString:sBe,gfmFootnoteCall:uBe,gfmFootnoteCallString:dBe},exit:{gfmFootnoteDefinition:cBe,gfmFootnoteDefinitionLabelString:lBe,gfmFootnoteCall:pBe,gfmFootnoteCallString:fBe}}}function aBe(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function sBe(){this.buffer()}function lBe(t){let e=this.resume(),r=this.stack[this.stack.length-1];r.type,r.label=e,r.identifier=jn(this.sliceSerialize(t)).toLowerCase()}function cBe(t){this.exit(t)}function uBe(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function dBe(){this.buffer()}function fBe(t){let e=this.resume(),r=this.stack[this.stack.length-1];r.type,r.label=e,r.identifier=jn(this.sliceSerialize(t)).toLowerCase()}function pBe(t){this.exit(t)}function mBe(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 hBe(){return"["}bBe.peek=yBe;function ML(){return{canContainEols:["delete"],enter:{strikethrough:_Be},exit:{strikethrough:xBe}}}function _Be(t){this.enter({type:"delete",children:[]},t)}function xBe(t){this.exit(t)}function bBe(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 yBe(){return"~"}function FL(){return{enter:{table:IBe,tableData:Pte,tableHeader:Pte,tableRow:EBe},exit:{codeText:SBe,table:wBe,tableData:LL,tableHeader:LL,tableRow:LL}}}function IBe(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 wBe(t){this.exit(t),this.data.inTable=void 0}function EBe(t){this.enter({type:"tableRow",children:[]},t)}function LL(t){this.exit(t)}function Pte(t){this.enter({type:"tableCell",children:[]},t)}function SBe(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,CBe));let r=this.stack[this.stack.length-1];r.type,r.value=e,this.exit(t)}function CBe(t,e){return e==="|"?e:t}function BL(){return{exit:{taskListCheckValueChecked:Ote,taskListCheckValueUnchecked:Ote,paragraph:kBe}}}function Ote(t){let e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function kBe(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 $L(){return[DL(),RL(),ML(),FL(),BL()]}var PBe={tokenize:MBe,partial:!0},Ate={tokenize:LBe,partial:!0},Dte={tokenize:FBe,partial:!0},Rte={tokenize:BBe,partial:!0},OBe={tokenize:$Be,partial:!0},Mte={tokenize:DBe,previous:Fte},Lte={tokenize:RBe,previous:Bte},dc={tokenize:ABe,previous:$te},ul={};function UL(){return{text:ul}}var Ff=48;for(;Ff<123;)ul[Ff]=dc,Ff++,Ff===58?Ff=65:Ff===91&&(Ff=97);ul[43]=dc;ul[45]=dc;ul[46]=dc;ul[95]=dc;ul[72]=[dc,Lte];ul[104]=[dc,Lte];ul[87]=[dc,Mte];ul[119]=[dc,Mte];function ABe(t,e,r){let o=this,n,i;return a;function a(d){return!zL(d)||!$te.call(o,o.previous)||VL(o.events)?r(d):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),s(d))}function s(d){return zL(d)?(t.consume(d),s):d===64?(t.consume(d),l):r(d)}function l(d){return d===46?t.check(OBe,u,c)(d):d===45||d===95||Vo(d)?(i=!0,t.consume(d),l):u(d)}function c(d){return t.consume(d),n=!0,l}function u(d){return i&&n&&Uo(o.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(d)):r(d)}}function DBe(t,e,r){let o=this;return n;function n(a){return a!==87&&a!==119||!Fte.call(o,o.previous)||VL(o.events)?r(a):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(PBe,t.attempt(Ate,t.attempt(Dte,i),r),r)(a))}function i(a){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(a)}}function RBe(t,e,r){let o=this,n="",i=!1;return a;function a(d){return(d===72||d===104)&&Bte.call(o,o.previous)&&!VL(o.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),n+=String.fromCodePoint(d),t.consume(d),s):r(d)}function s(d){if(Uo(d)&&n.length<5)return n+=String.fromCodePoint(d),t.consume(d),s;if(d===58){let f=n.toLowerCase();if(f==="http"||f==="https")return t.consume(d),l}return r(d)}function l(d){return d===47?(t.consume(d),i?c:(i=!0,l)):r(d)}function c(d){return d===null||Af(d)||At(d)||ll(d)||Df(d)?r(d):t.attempt(Ate,t.attempt(Dte,u),r)(d)}function u(d){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(d)}}function MBe(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 LBe(t,e,r){let o,n,i;return a;function a(c){return c===46||c===95?t.check(Rte,l,s)(c):c===null||At(c)||ll(c)||c!==45&&Df(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 FBe(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(Rte,e,i)(a):a===null||At(a)||ll(a)?e(a):(t.consume(a),n)}function i(a){return a===41&&o++,t.consume(a),n}}function BBe(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||At(s)||ll(s)?e(s):r(s)}function n(s){return s===null||s===40||s===91||At(s)||ll(s)?e(s):o(s)}function i(s){return Uo(s)?a(s):r(s)}function a(s){return s===59?(t.consume(s),o):Uo(s)?(t.consume(s),a):r(s)}}function $Be(t,e,r){return o;function o(i){return t.consume(i),n}function n(i){return Vo(i)?r(i):e(i)}}function Fte(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||At(t)}function Bte(t){return!Uo(t)}function $te(t){return!(t===47||zL(t))}function zL(t){return t===43||t===45||t===46||t===95||Vo(t)}function VL(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 zBe={tokenize:qBe,partial:!0};function HL(){return{document:{91:{tokenize:jBe,continuation:{tokenize:GBe},exit:WBe}},text:{91:{tokenize:HBe},93:{add:"after",tokenize:UBe,resolveTo:VBe}}}}function UBe(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=jn(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 VBe(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 HBe(t,e,r){let o=this,n=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]),i=0,a;return s;function s(d){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(d),t.exit("gfmFootnoteCallLabelMarker"),l}function l(d){return d!==94?r(d):(t.enter("gfmFootnoteCallMarker"),t.consume(d),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",c)}function c(d){if(i>999||d===93&&!a||d===null||d===91||At(d))return r(d);if(d===93){t.exit("chunkString");let f=t.exit("gfmFootnoteCallString");return n.includes(jn(o.sliceSerialize(f)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(d),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):r(d)}return At(d)||(a=!0),i++,t.consume(d),d===92?u:c}function u(d){return d===91||d===92||d===93?(t.consume(d),i++,c):c(d)}}function jBe(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",u):r(h)}function u(h){if(a>999||h===93&&!s||h===null||h===91||At(h))return r(h);if(h===93){t.exit("chunkString");let g=t.exit("gfmFootnoteDefinitionLabelString");return i=jn(o.sliceSerialize(g)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(h),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),f}return At(h)||(s=!0),a++,t.consume(h),h===92?d:u}function d(h){return h===91||h===92||h===93?(t.consume(h),a++,u):u(h)}function f(h){return h===58?(t.enter("definitionMarker"),t.consume(h),t.exit("definitionMarker"),n.includes(i)||n.push(i),nt(t,m,"gfmFootnoteDefinitionWhitespace")):r(h)}function m(h){return e(h)}}function GBe(t,e,r){return t.check(cl,e,t.attempt(zBe,e,r))}function WBe(t){t.exit("gfmFootnoteDefinition")}function qBe(t,e,r){let o=this;return nt(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 jL(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 u={type:"strikethrough",start:Object.assign({},a[c][1].start),end:Object.assign({},a[l][1].end)},d={type:"strikethroughText",start:Object.assign({},a[c][1].end),end:Object.assign({},a[l][1].start)},f=[["enter",u,s],["enter",a[c][1],s],["exit",a[c][1],s],["enter",d,s]],m=s.parser.constructs.insideSpan.null;m&&Po(f,f.length,0,Nu(m,a.slice(c+1,l),s)),Po(f,f.length,0,[["exit",d,s],["enter",a[l][1],s],["exit",a[l][1],s],["exit",u,s]]),Po(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,u=this.events,d=0;return f;function f(h){return c===126&&u[u.length-1][1].type!=="characterEscape"?l(h):(a.enter("strikethroughSequenceTemporary"),m(h))}function m(h){let g=Sh(c);if(h===126)return d>1?l(h):(a.consume(h),d++,m);if(d<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 nC=class{constructor(){this.map=[]}add(e,r,o){KBe(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 KBe(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 zte(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 GL(){return{flow:{null:{tokenize:YBe,resolveAll:XBe}}}}function YBe(t,e,r){let o=this,n=0,i=0,a;return s;function s(T){let A=o.events.length-1;for(;A>-1;){let B=o.events[A][1].type;if(B==="lineEnding"||B==="linePrefix")A--;else break}let R=A>-1?o.events[A][1].type:null,P=R==="tableHead"||R==="tableRow"?I:l;return P===I&&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),u(T)}function u(T){return T===null?r(T):Pe(T)?i>1?(i=0,o.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(T),t.exit("lineEnding"),m):r(T):lt(T)?nt(t,u,"whitespace")(T):(i+=1,a&&(a=!1,n+=1),T===124?(t.enter("tableCellDivider"),t.consume(T),t.exit("tableCellDivider"),a=!0,u):(t.enter("data"),d(T)))}function d(T){return T===null||T===124||At(T)?(t.exit("data"),u(T)):(t.consume(T),T===92?f:d)}function f(T){return T===92||T===124?(t.consume(T),d):d(T)}function m(T){return o.interrupt=!1,o.parser.lazy[o.now().line]?r(T):(t.enter("tableDelimiterRow"),a=!1,lt(T)?nt(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 lt(T)?nt(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||Pe(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 lt(T)?nt(t,S,"whitespace")(T):S(T)}function S(T){return T===124?h(T):T===null||Pe(T)?!a||n!==i?N(T):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(T)):N(T)}function N(T){return r(T)}function I(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||Pe(T)?(t.exit("tableRow"),e(T)):lt(T)?nt(t,E,"whitespace")(T):(t.enter("data"),w(T))}function w(T){return T===null||T===124||At(T)?(t.exit("data"),E(T)):(t.consume(T),T===92?C:w)}function C(T){return T===92||T===124?(t.consume(T),w):w(T)}}function XBe(t,e){let r=-1,o=!0,n=0,i=[0,0,0,0],a=[0,0,0,0],s=!1,l=0,c,u,d,f=new nC;for(;++r<t.length;){let m=t[r],h=m[1];m[0]==="enter"?h.type==="tableHead"?(s=!1,l!==0&&(Ute(f,e,l,c,u),u=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,d=void 0,i=[0,0,0,0],a=[0,r+1,0,0],s&&(s=!1,u={type:"tableBody",start:Object.assign({},h.start),end:Object.assign({},h.end)},f.add(r,0,[["enter",u,e]])),n=h.type==="tableDelimiterRow"?2:u?3:1):n&&(h.type==="data"||h.type==="tableDelimiterMarker"||h.type==="tableDelimiterFiller")?(o=!1,a[2]===0&&(i[1]!==0&&(a[0]=a[1],d=iC(f,e,i,n,void 0,d),i=[0,0,0,0]),a[2]=r)):h.type==="tableCellDivider"&&(o?o=!1:(i[1]!==0&&(a[0]=a[1],d=iC(f,e,i,n,void 0,d)),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],d=iC(f,e,i,n,r,d)):a[1]!==0&&(d=iC(f,e,a,n,r,d)),n=0):n&&(h.type==="data"||h.type==="tableDelimiterMarker"||h.type==="tableDelimiterFiller")&&(a[3]=r)}for(l!==0&&Ute(f,e,l,c,u),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=zte(e.events,r))}return t}function iC(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]),u=kh(e.events,r[3]),d={type:s,start:Object.assign({},c),end:Object.assign({},u)};if(t.add(r[2],0,[["enter",d,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",d,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 Ute(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 JBe={tokenize:QBe};function WL(){return{text:{91:JBe}}}function QBe(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 At(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 Pe(l)?e(l):lt(l)?t.check({tokenize:ZBe},e,r)(l):r(l)}}function ZBe(t,e,r){return nt(t,o,"whitespace");function o(n){return n===null?r(n):e(n)}}function Vte(t){return GS([UL(),HL(),jL(t),GL(),WL()])}Ee();Ee();var Hte=["bmp","gif","ico","jpeg","jpg","png","tiff","webp"],jte=[...Hte,"svg"],Gte=["mp4","webm"],e4e="https://lh3.googleusercontent.com/";async function Ou(t,e){let r=window.__ROOT_CTX.rootConfig.projectId,o=await a4e(t),n=Nh(t.name),i=e?.preserveFilename?`${o}/${t.name}`:`${o}.${n}`,a=`${r}/uploads/${i}`,s=pQ(window.firebase.storage,a),l=dQ(s,t),c=-1,u=Date.now();return await new Promise((d,f)=>{let m=setInterval(()=>{Date.now()-u>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,u=Date.now())},h=>{clearInterval(m),f(h)},()=>{console.log(`uploaded ${a}`),clearInterval(m),d(l.snapshot)})}),t4e(s,t,n,e)}async function t4e(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(jte.includes(r)){let l=await n4e(e);if(n.width=l.width,n.height=l.height,!o?.disableGci&&Hte.includes(r)){let c=await o4e(i);c&&(n.gcsPath=i,a=c)}n.canvasBgColor=await l4e(e)?"dark":"light"}else if(Gte.includes(r)){let l=await i4e(a);n.width=l.width,n.height=l.height,console.log("video dimensions:",l)}let s=o?.cacheControl||"public, max-age=31536000";return await fQ(t,{cacheControl:s,customMetadata:s4e(n)}),console.log("updated meta data: ",n),{...n,src:a}}function Nh(t){return r4e(t.split(".").at(-1)||"")}function r4e(t){let e=String(t).toLowerCase();return e==="jpeg"&&(e="jpg"),e}async function o4e(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 n4e(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 i4e(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 a4e(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 s4e(t){let e={};return Object.entries(t).forEach(([r,o])=>{t[r]=String(o).trim()}),e}function Jb(t){if(!t)return!1;if(aC(t)||t.startsWith("data:image/"))return!0;let e=Nh(t);return jte.includes(e)}function aC(t){return t?t.startsWith(e4e):!1}function qL(t){if(!t)return!1;let e=Nh(t);return Gte.includes(e)}function Wte(t){return aC(t)?t.split("=")[0]+"=s0-d":t}function l4e(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,u=0,d=0;for(let m=0;m<s.length;m+=400)l+=s[m],c+=s[m+1],u+=s[m+2],d++;let f=.299*(l/d)+.587*(c/d)+.114*(u/d);e(f<128)},o.onerror=r,n.onerror=r,n.readAsDataURL(t)})}function sC(t){let[e,r]=M(""),o=W(null),n=W(null),[i,a]=M(null),[s,l]=M(!1),c=!e;function u(b){return b.endsWith(".jpg")?"image/jpeg":"image/png"}async function d(){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:u(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(),d();return}}async function h(b){try{l(!0),f();let y=await Ou(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:Oe("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(Ce,{label:"Upload image",children:p(Je,{component:"div",className:"AIPage__ChatBar__prompt__imageUpload__icon",radius:"xl",children:p(Ab,{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(Ze,{size:"sm"}):p(Ce,{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(Bb,{size:24,color:"white"})})]})})}),p(Je,{className:"AIPage__ChatBar__prompt__submit",variant:"filled",color:"dark",radius:"xl",onClick:()=>d(),disabled:c,children:p(FM,{size:18})})]}),p("div",{className:"AIPage__ChatBar__disclaimer",children:"Root AI is experimental and makes mistakes. Check all info."})]})}var qte={name:"@blinkk/root-cms",version:"2.2.13",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":"2.47.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.2.13","firebase-admin":">=11","firebase-functions":">=4",preact:">=10","preact-render-to-string":">=5"},peerDependenciesMeta:{"firebase-functions":{optional:!0}}};function Kte(){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 fc="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(Kte,{})}),p("div",{className:"Layout__top__version",children:["v",qte.version]}),p("div",{className:"Layout__top__project",children:t})]})};Fe.Side=()=>{let[t]=_Q(),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(EM,{stroke:fc})}),!i("content")&&p(Fe.SideButton,{label:"Content",url:"/cms/content",active:e.startsWith("/cms/content"),children:p(wf,{stroke:fc})}),!i("releases")&&p(Fe.SideButton,{label:"Releases",url:"/cms/releases",active:e.startsWith("/cms/releases"),children:p(_h,{stroke:fc})}),!i("data")&&p(Fe.SideButton,{label:"Data",url:"/cms/data",active:e.startsWith("/cms/data"),children:p(pM,{stroke:fc})}),!i("assets")&&p(Fe.SideButton,{label:"Assets",url:"/cms/assets",active:e.startsWith("/cms/assets"),children:p(RM,{stroke:fc})}),!i("translations")&&p(Fe.SideButton,{label:"Translations",url:"/cms/translations",active:e.startsWith("/cms/translations"),children:p(Su,{stroke:fc})}),a.ai&&!i("ai")&&p(Fe.SideButton,{label:"Root AI (experimental)",url:"/cms/ai",active:e.startsWith("/cms/ai"),children:p(Sf,{stroke:fc})}),o&&p(ke,{children:[p("div",{className:"Layout__side__divider"}),Object.entries(o).map(([s,l])=>{let c=l.cmsUrl?.startsWith("/cms/")?l.cmsUrl:void 0,u=l.externalUrl,d=u??c??`/cms/tools/${s}`,f=u?void 0:d.replace(/\/*$/g,""),m=!u&&!!f&&(e===f||e.startsWith(`${f}/`));return p(Fe.SideButton,{className:"Layout__side__tool",label:l.label||"",url:d,active:m,external:!!u,children:l.icon?p("img",{className:"Layout__side__tool__icon",src:l.icon,alt:l.label||""}):p(sM,{stroke:fc})},s)}),p("div",{className:"Layout__side__divider"})]}),!i("settings")&&p(Fe.SideButton,{label:"Settings",url:"/cms/settings",active:e.startsWith("/cms/settings"),children:p(Cf,{stroke:fc})})]}),p("div",{className:"Layout__side__user",children:p(Ce,{label:r.email,position:"right",withArrow:!0,children:p(ka,{src:r.photoURL,alt:r.email,size:30,radius:"xl"})})})]})};Fe.SideButton=t=>p(Ce,{className:Oe("Layout__side__button",t.className),label:t.label,position:"right",withArrow:!0,children:p("a",{className:Oe(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 oa(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 Yte(t,e){return Math.random()*(e-t)+t}var u4e=[20,40];lL.configure({ignoreUnescapedHTML:!0});function Xte(){return Yte(...u4e)}function Qb(){let[t,e]=M([]),[r,o]=M(""),n=s=>{let l=0;return e(c=>{let u={sender:"bot",blocks:[{type:"pending"}],key:oa()},d=[...c,{...s,key:oa()},u];return l=d.length-1,d}),l},i=(s,l)=>{e(c=>{let u=[...c];return u[s]={...l,key:oa()},u})};return{chatId:r,messages:t,addMessage:n,updateMessage:i,sendPrompt:async(s,l,c)=>{let u="/cms/api/ai.chat";typeof window.__ROOT_CTX.experiments?.ai=="object"&&window.__ROOT_CTX.experiments.ai.endpoint&&(u=window.__ROOT_CTX.experiments.ai.endpoint);let d={prompt:l,chatId:r,options:c},f=await window.fetch(u,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(d)});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 vL={};nr(vL,{attentionMarkers:()=>RFe,contentInitial:()=>kFe,disable:()=>MFe,document:()=>TFe,flow:()=>PFe,flowInitial:()=>NFe,insideSpan:()=>DFe,string:()=>OFe,text:()=>AFe});var TFe={42:Gn,43:Gn,45:Gn,48:Gn,49:Gn,50:Gn,51:Gn,52:Gn,53:Gn,54:Gn,55:Gn,56:Gn,57:Gn,62:qS},kFe={91:pL},NFe={[-2]:Kb,[-1]:Kb,32:Kb},PFe={35:hL,42:Lf,45:[rC,Lf],60:_L,61:rC,95:Lf,96:XS,126:XS},OFe={38:YS,92:KS},AFe={[-5]:Xb,[-4]:Xb,[-3]:Xb,33:bL,38:YS,42:qb,60:[uL,xL],91:yL,92:[mL,KS],93:Mf,95:qb,96:dL},DFe={null:[qb,pte]},RFe={null:[42,95]},MFe={null:[]};function IL(t){let r=GS([vL,...(t||{}).extensions||[]]),o={defined:[],lazy:{},constructs:r,content:n(ate),document:n(lte),flow:n(fte),string:n(mte),text:n(hte)};return o;function n(i){return a;function a(s){return xte(o,i,s)}}}function wL(t){for(;!QS(t););return t}var bte=/[\0\t\n\r]/g;function EL(){let t=1,e="",r=!0,o;return n;function n(i,a,s){let l=[],c,u,d,f,m;for(i=e+(typeof i=="string"?i.toString():new TextDecoder(a||void 0).decode(i)),d=0,e="",r&&(i.charCodeAt(0)===65279&&d++,r=void 0);d<i.length;){if(bte.lastIndex=d,c=bte.exec(i),f=c&&c.index!==void 0?c.index:i.length,m=i.charCodeAt(f),!c){e=i.slice(d);break}if(m===10&&d===f&&o)l.push(-3),o=void 0;else switch(o&&(l.push(-5),o=void 0),d<f&&(l.push(i.slice(d,f)),t+=f-d),m){case 0:{l.push(65533),t++;break}case 9:{for(u=Math.ceil(t/4)*4,l.push(-2);t++<u;)l.push(-1);break}case 10:{l.push(-4),t=1;break}default:o=!0,t=1}d=f+1}return s&&(o&&l.push(-5),e&&l.push(e),l.push(null)),l}}var LFe=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function yte(t){return t.replace(LFe,FFe)}function FFe(t,e,r){if(e)return e;if(r.charCodeAt(0)===35){let n=r.charCodeAt(1),i=n===120||n===88;return WS(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?vte(t.position):"start"in t||"end"in t?vte(t):"line"in t||"column"in t?SL(t):""}function SL(t){return Ite(t&&t.line)+":"+Ite(t&&t.column)}function vte(t){return SL(t&&t.start)+"-"+SL(t&&t.end)}function Ite(t){return t&&typeof t=="number"?t:1}var Ete={}.hasOwnProperty;function CL(t,e,r){return typeof e!="string"&&(r=e,e=void 0),BFe(r)(wL(IL(r).document().write(EL()(t,e,!0))))}function BFe(t){let e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(Ut),autolinkProtocol:C,autolinkEmail:C,atxHeading:i(Xr),blockQuote:i(st),characterEscape:C,characterReference:C,codeFenced:i(Rt),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:i(Rt,a),codeText:i(dt,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(dn),label:a,link:i(Ut),listItem:i(Vr),listItemValue:f,listOrdered:i(pt,d),listUnordered:i(pt),paragraph:i(Hr),reference:U,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:i(Xr),strong:i(Ro),thematicBreak:i(ie)},exit:{atxHeading:l(),atxHeadingSequence:N,autolink:l(),autolinkEmail:Ne,autolinkProtocol:Me,blockQuote:l(),characterEscapeValue:T,characterReferenceMarkerHexadecimal:Te,characterReferenceMarkerNumeric:Te,characterReferenceValue:je,characterReference:Qe,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(R),hardBreakTrailing:l(R),htmlFlow:l(P),htmlFlowData:T,htmlText:l(B),htmlTextData:T,image:l(H),label:Y,labelText:G,lineEnding:A,link:l(z),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:_e,resourceDestinationString:L,resourceTitleString:ne,resource:ae,setextHeading:l(w),setextHeadingLineSequence:E,setextHeadingText:I,strong:l(),thematicBreak:l()}};Ste(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:u,data:r},He=[],yt=-1;for(;++yt<j.length;)if(j[yt][1].type==="listOrdered"||j[yt][1].type==="listUnordered")if(j[yt][0]==="enter")He.push(yt);else{let Nt=He.pop();yt=n(j,Nt,yt)}for(yt=-1;++yt<j.length;){let Nt=e[j[yt][0]];Ete.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]||wte).call(se,void 0,Nt[0])}for(Q.position={start:Pu(j.length>0?j[0][1].start:{line:1,column:1,offset:0}),end:Pu(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 He=Q-1,yt=-1,Nt=!1,Mn,xr,Nr,Xn;for(;++He<=se;){let io=j[He];switch(io[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{io[0]==="enter"?yt++:yt--,Xn=void 0;break}case"lineEndingBlank":{io[0]==="enter"&&(Mn&&!Xn&&!yt&&!Nr&&(Nr=He),Xn=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Xn=void 0}if(!yt&&io[0]==="enter"&&io[1].type==="listItemPrefix"||yt===-1&&io[0]==="exit"&&(io[1].type==="listUnordered"||io[1].type==="listOrdered")){if(Mn){let fn=He;for(xr=void 0;fn--;){let pn=j[fn];if(pn[1].type==="lineEnding"||pn[1].type==="lineEndingBlank"){if(pn[0]==="exit")continue;xr&&(j[xr][1].type="lineEndingBlank",Nt=!0),pn[1].type="lineEnding",xr=fn}else if(!(pn[1].type==="linePrefix"||pn[1].type==="blockQuotePrefix"||pn[1].type==="blockQuotePrefixWhitespace"||pn[1].type==="blockQuoteMarker"||pn[1].type==="listItemIndent"))break}Nr&&(!xr||Nr<xr)&&(Mn._spread=!0),Mn.end=Object.assign({},xr?j[xr][1].start:io[1].end),j.splice(xr||He,0,["exit",Mn,io[2]]),He++,se++}if(io[1].type==="listItemPrefix"){let fn={type:"listItem",_spread:!1,start:Object.assign({},io[1].start),end:void 0};Mn=fn,j.splice(He,0,["enter",fn,io[2]]),He++,se++,Nr=void 0,Xn=!0}}}return j[Q][1]._spread=Nt,se}function i(j,Q){return se;function se(He){s.call(this,j(He),He),Q&&Q.call(this,He)}}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:Pu(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(),He=this.tokenStack.pop();if(He)He[0].type!==j.type&&(Q?Q.call(this,j,He[0]):(He[1]||wte).call(this,j,He[0]));else throw new Error("Cannot close `"+j.type+"` ("+Ch({start:j.start,end:j.end})+"): it\u2019s not open");se.position.end=Pu(j.end)}function u(){return cL(this.stack.pop())}function d(){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=jn(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 I(){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 w(){this.data.setextHeadingSlurpLineEnding=void 0}function C(j){let se=this.stack[this.stack.length-1].children,He=se[se.length-1];(!He||He.type!=="text")&&(He=Be(),He.position={start:Pu(j.start),end:void 0},se.push(He)),this.stack.push(He)}function T(j){let Q=this.stack.pop();Q.value+=this.sliceSerialize(j),Q.position.end=Pu(j.end)}function A(j){let Q=this.stack[this.stack.length-1];if(this.data.atHardBreak){let se=Q.children[Q.children.length-1];se.position.end=Pu(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 R(){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 G(j){let Q=this.sliceSerialize(j),se=this.stack[this.stack.length-2];se.label=yte(Q),se.identifier=jn(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 He=j.children;se.children=He}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 _e(j){let Q=this.resume(),se=this.stack[this.stack.length-1];se.label=Q,se.identifier=jn(this.sliceSerialize(j)).toLowerCase(),this.data.referenceType="full"}function Te(j){this.data.characterReferenceType=j.type}function je(j){let Q=this.sliceSerialize(j),se=this.data.characterReferenceType,He;se?(He=WS(Q,se==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):He=Eh(Q);let yt=this.stack[this.stack.length-1];yt.value+=He}function Qe(j){let Q=this.stack.pop();Q.position.end=Pu(j.end)}function Me(j){T.call(this,j);let Q=this.stack[this.stack.length-1];Q.url=this.sliceSerialize(j)}function Ne(j){T.call(this,j);let Q=this.stack[this.stack.length-1];Q.url="mailto:"+this.sliceSerialize(j)}function st(){return{type:"blockquote",children:[]}}function Rt(){return{type:"code",lang:null,meta:null,value:""}}function dt(){return{type:"inlineCode",value:""}}function ht(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function bt(){return{type:"emphasis",children:[]}}function Xr(){return{type:"heading",depth:0,children:[]}}function Mt(){return{type:"break"}}function ve(){return{type:"html",value:""}}function dn(){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 Vr(j){return{type:"listItem",spread:j._spread,checked:null,children:[]}}function Hr(){return{type:"paragraph",children:[]}}function Ro(){return{type:"strong",children:[]}}function Be(){return{type:"text",value:""}}function ie(){return{type:"thematicBreak"}}}function Pu(t){return{line:t.line,column:t.column,offset:t.offset}}function Ste(t,e){let r=-1;for(;++r<e.length;){let o=e[r];Array.isArray(o)?Ste(t,o):$Fe(t,o)}}function $Fe(t,e){let r;for(r in e)if(Ete.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 wte(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 TL(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 kL(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 HFe;if(typeof t=="function")return oC(t);if(typeof t=="object")return Array.isArray(t)?zFe(t):UFe(t);if(typeof t=="string")return VFe(t);throw new Error("Expected function, string, or object as test")});function zFe(t){let e=[],r=-1;for(;++r<t.length;)e[r]=Th(t[r]);return oC(o);function o(...n){let i=-1;for(;++i<e.length;)if(e[i].apply(this,n))return!0;return!1}}function UFe(t){let e=t;return oC(r);function r(o){let n=o,i;for(i in t)if(n[i]!==e[i])return!1;return!0}}function VFe(t){return oC(e);function e(r){return r&&r.type===t}}function oC(t){return e;function e(r,o,n){return!!(jFe(r)&&t.call(this,r,typeof o=="number"?o:void 0,n||void 0))}}function HFe(){return!0}function jFe(t){return t!==null&&typeof t=="object"&&"type"in t}var Cte=[],Tte=!0,NL=!1,kte="skip";function PL(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,u){let d=l&&typeof l=="object"?l:{};if(typeof d.type=="string"){let m=typeof d.tagName=="string"?d.tagName:typeof d.name=="string"?d.name:void 0;Object.defineProperty(f,"name",{value:"node ("+(l.type+(m?"<"+m+">":""))+")"})}return f;function f(){let m=Cte,h,g,_;if((!e||i(l,c,u[u.length-1]||void 0))&&(m=GFe(r(l,u)),m[0]===NL))return m;if("children"in l&&l.children){let b=l;if(b.children&&m[0]!==kte)for(g=(o?b.children.length:-1)+a,_=u.concat(b);g>-1&&g<b.children.length;){let y=b.children[g];if(h=s(y,g,_)(),h[0]===NL)return h;g=typeof h[1]=="number"?h[1]:g+a}}return m}}}function GFe(t){return Array.isArray(t)?t:typeof t=="number"?[Tte,t]:t==null?Cte:[t]}function OL(t,e,r){let n=Th((r||{}).ignore||[]),i=WFe(e),a=-1;for(;++a<i.length;)PL(t,"text",s);function s(c,u){let d=-1,f;for(;++d<u.length;){let m=u[d],h=f?f.children:void 0;if(n(m,h?h.indexOf(m):void 0,f))return;f=m}if(f)return l(c,u)}function l(c,u){let d=u[u.length-1],f=i[a][0],m=i[a][1],h=0,_=d.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:[...u,c]},I=m(...v,N);if(typeof I=="string"&&(I=I.length>0?{type:"text",value:I}:void 0),I===!1?f.lastIndex=S+1:(h!==S&&y.push({type:"text",value:c.value.slice(h,S)}),Array.isArray(I)?y.push(...I):I&&y.push(I),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)}),d.children.splice(_,1,...y)):y=[c],_+y.length}}function WFe(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([qFe(n[0]),KFe(n[1])])}return e}function qFe(t){return typeof t=="string"?new RegExp(kL(t),"g"):t}function KFe(t){return typeof t=="function"?t:function(){return t}}function DL(){return{transforms:[eBe],enter:{literalAutolink:YFe,literalAutolinkEmail:AL,literalAutolinkHttp:AL,literalAutolinkWww:AL},exit:{literalAutolink:ZFe,literalAutolinkEmail:QFe,literalAutolinkHttp:XFe,literalAutolinkWww:JFe}}}function YFe(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function AL(t){this.config.enter.autolinkProtocol.call(this,t)}function XFe(t){this.config.exit.autolinkProtocol.call(this,t)}function JFe(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 QFe(t){this.config.exit.autolinkEmail.call(this,t)}function ZFe(t){this.exit(t)}function eBe(t){OL(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,tBe],[/([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/g,rBe]],{ignore:["link","linkReference"]})}function tBe(t,e,r,o,n){let i="";if(!Nte(n)||(/^w/i.test(e)&&(r=e+r,e="",i="http://"),!oBe(r)))return!1;let a=nBe(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 rBe(t,e,r,o){return!Nte(o,!0)||/[-\d_]$/.test(r)?!1:{type:"link",title:null,url:"mailto:"+e+"@"+r,children:[{type:"text",value:e+"@"+r}]}}function oBe(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 nBe(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=TL(t,"("),i=TL(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 Nte(t,e){let r=t.input.charCodeAt(t.index-1);return(t.index===0||ll(r)||Df(r))&&(!e||r!==47)}mBe.peek=hBe;function RL(){return{enter:{gfmFootnoteDefinition:aBe,gfmFootnoteDefinitionLabelString:sBe,gfmFootnoteCall:uBe,gfmFootnoteCallString:dBe},exit:{gfmFootnoteDefinition:cBe,gfmFootnoteDefinitionLabelString:lBe,gfmFootnoteCall:pBe,gfmFootnoteCallString:fBe}}}function aBe(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function sBe(){this.buffer()}function lBe(t){let e=this.resume(),r=this.stack[this.stack.length-1];r.type,r.label=e,r.identifier=jn(this.sliceSerialize(t)).toLowerCase()}function cBe(t){this.exit(t)}function uBe(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function dBe(){this.buffer()}function fBe(t){let e=this.resume(),r=this.stack[this.stack.length-1];r.type,r.label=e,r.identifier=jn(this.sliceSerialize(t)).toLowerCase()}function pBe(t){this.exit(t)}function mBe(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 hBe(){return"["}bBe.peek=yBe;function ML(){return{canContainEols:["delete"],enter:{strikethrough:_Be},exit:{strikethrough:xBe}}}function _Be(t){this.enter({type:"delete",children:[]},t)}function xBe(t){this.exit(t)}function bBe(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 yBe(){return"~"}function FL(){return{enter:{table:IBe,tableData:Pte,tableHeader:Pte,tableRow:EBe},exit:{codeText:SBe,table:wBe,tableData:LL,tableHeader:LL,tableRow:LL}}}function IBe(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 wBe(t){this.exit(t),this.data.inTable=void 0}function EBe(t){this.enter({type:"tableRow",children:[]},t)}function LL(t){this.exit(t)}function Pte(t){this.enter({type:"tableCell",children:[]},t)}function SBe(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,CBe));let r=this.stack[this.stack.length-1];r.type,r.value=e,this.exit(t)}function CBe(t,e){return e==="|"?e:t}function BL(){return{exit:{taskListCheckValueChecked:Ote,taskListCheckValueUnchecked:Ote,paragraph:kBe}}}function Ote(t){let e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function kBe(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 $L(){return[DL(),RL(),ML(),FL(),BL()]}var PBe={tokenize:MBe,partial:!0},Ate={tokenize:LBe,partial:!0},Dte={tokenize:FBe,partial:!0},Rte={tokenize:BBe,partial:!0},OBe={tokenize:$Be,partial:!0},Mte={tokenize:DBe,previous:Fte},Lte={tokenize:RBe,previous:Bte},dc={tokenize:ABe,previous:$te},ul={};function UL(){return{text:ul}}var Ff=48;for(;Ff<123;)ul[Ff]=dc,Ff++,Ff===58?Ff=65:Ff===91&&(Ff=97);ul[43]=dc;ul[45]=dc;ul[46]=dc;ul[95]=dc;ul[72]=[dc,Lte];ul[104]=[dc,Lte];ul[87]=[dc,Mte];ul[119]=[dc,Mte];function ABe(t,e,r){let o=this,n,i;return a;function a(d){return!zL(d)||!$te.call(o,o.previous)||VL(o.events)?r(d):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),s(d))}function s(d){return zL(d)?(t.consume(d),s):d===64?(t.consume(d),l):r(d)}function l(d){return d===46?t.check(OBe,u,c)(d):d===45||d===95||Vo(d)?(i=!0,t.consume(d),l):u(d)}function c(d){return t.consume(d),n=!0,l}function u(d){return i&&n&&Uo(o.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(d)):r(d)}}function DBe(t,e,r){let o=this;return n;function n(a){return a!==87&&a!==119||!Fte.call(o,o.previous)||VL(o.events)?r(a):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(PBe,t.attempt(Ate,t.attempt(Dte,i),r),r)(a))}function i(a){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(a)}}function RBe(t,e,r){let o=this,n="",i=!1;return a;function a(d){return(d===72||d===104)&&Bte.call(o,o.previous)&&!VL(o.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),n+=String.fromCodePoint(d),t.consume(d),s):r(d)}function s(d){if(Uo(d)&&n.length<5)return n+=String.fromCodePoint(d),t.consume(d),s;if(d===58){let f=n.toLowerCase();if(f==="http"||f==="https")return t.consume(d),l}return r(d)}function l(d){return d===47?(t.consume(d),i?c:(i=!0,l)):r(d)}function c(d){return d===null||Af(d)||At(d)||ll(d)||Df(d)?r(d):t.attempt(Ate,t.attempt(Dte,u),r)(d)}function u(d){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(d)}}function MBe(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 LBe(t,e,r){let o,n,i;return a;function a(c){return c===46||c===95?t.check(Rte,l,s)(c):c===null||At(c)||ll(c)||c!==45&&Df(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 FBe(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(Rte,e,i)(a):a===null||At(a)||ll(a)?e(a):(t.consume(a),n)}function i(a){return a===41&&o++,t.consume(a),n}}function BBe(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||At(s)||ll(s)?e(s):r(s)}function n(s){return s===null||s===40||s===91||At(s)||ll(s)?e(s):o(s)}function i(s){return Uo(s)?a(s):r(s)}function a(s){return s===59?(t.consume(s),o):Uo(s)?(t.consume(s),a):r(s)}}function $Be(t,e,r){return o;function o(i){return t.consume(i),n}function n(i){return Vo(i)?r(i):e(i)}}function Fte(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||At(t)}function Bte(t){return!Uo(t)}function $te(t){return!(t===47||zL(t))}function zL(t){return t===43||t===45||t===46||t===95||Vo(t)}function VL(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 zBe={tokenize:qBe,partial:!0};function HL(){return{document:{91:{tokenize:jBe,continuation:{tokenize:GBe},exit:WBe}},text:{91:{tokenize:HBe},93:{add:"after",tokenize:UBe,resolveTo:VBe}}}}function UBe(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=jn(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 VBe(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 HBe(t,e,r){let o=this,n=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]),i=0,a;return s;function s(d){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(d),t.exit("gfmFootnoteCallLabelMarker"),l}function l(d){return d!==94?r(d):(t.enter("gfmFootnoteCallMarker"),t.consume(d),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",c)}function c(d){if(i>999||d===93&&!a||d===null||d===91||At(d))return r(d);if(d===93){t.exit("chunkString");let f=t.exit("gfmFootnoteCallString");return n.includes(jn(o.sliceSerialize(f)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(d),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):r(d)}return At(d)||(a=!0),i++,t.consume(d),d===92?u:c}function u(d){return d===91||d===92||d===93?(t.consume(d),i++,c):c(d)}}function jBe(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",u):r(h)}function u(h){if(a>999||h===93&&!s||h===null||h===91||At(h))return r(h);if(h===93){t.exit("chunkString");let g=t.exit("gfmFootnoteDefinitionLabelString");return i=jn(o.sliceSerialize(g)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(h),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),f}return At(h)||(s=!0),a++,t.consume(h),h===92?d:u}function d(h){return h===91||h===92||h===93?(t.consume(h),a++,u):u(h)}function f(h){return h===58?(t.enter("definitionMarker"),t.consume(h),t.exit("definitionMarker"),n.includes(i)||n.push(i),nt(t,m,"gfmFootnoteDefinitionWhitespace")):r(h)}function m(h){return e(h)}}function GBe(t,e,r){return t.check(cl,e,t.attempt(zBe,e,r))}function WBe(t){t.exit("gfmFootnoteDefinition")}function qBe(t,e,r){let o=this;return nt(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 jL(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 u={type:"strikethrough",start:Object.assign({},a[c][1].start),end:Object.assign({},a[l][1].end)},d={type:"strikethroughText",start:Object.assign({},a[c][1].end),end:Object.assign({},a[l][1].start)},f=[["enter",u,s],["enter",a[c][1],s],["exit",a[c][1],s],["enter",d,s]],m=s.parser.constructs.insideSpan.null;m&&Po(f,f.length,0,Nu(m,a.slice(c+1,l),s)),Po(f,f.length,0,[["exit",d,s],["enter",a[l][1],s],["exit",a[l][1],s],["exit",u,s]]),Po(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,u=this.events,d=0;return f;function f(h){return c===126&&u[u.length-1][1].type!=="characterEscape"?l(h):(a.enter("strikethroughSequenceTemporary"),m(h))}function m(h){let g=Sh(c);if(h===126)return d>1?l(h):(a.consume(h),d++,m);if(d<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 nC=class{constructor(){this.map=[]}add(e,r,o){KBe(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 KBe(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 zte(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 GL(){return{flow:{null:{tokenize:YBe,resolveAll:XBe}}}}function YBe(t,e,r){let o=this,n=0,i=0,a;return s;function s(T){let A=o.events.length-1;for(;A>-1;){let B=o.events[A][1].type;if(B==="lineEnding"||B==="linePrefix")A--;else break}let R=A>-1?o.events[A][1].type:null,P=R==="tableHead"||R==="tableRow"?I:l;return P===I&&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),u(T)}function u(T){return T===null?r(T):Pe(T)?i>1?(i=0,o.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(T),t.exit("lineEnding"),m):r(T):lt(T)?nt(t,u,"whitespace")(T):(i+=1,a&&(a=!1,n+=1),T===124?(t.enter("tableCellDivider"),t.consume(T),t.exit("tableCellDivider"),a=!0,u):(t.enter("data"),d(T)))}function d(T){return T===null||T===124||At(T)?(t.exit("data"),u(T)):(t.consume(T),T===92?f:d)}function f(T){return T===92||T===124?(t.consume(T),d):d(T)}function m(T){return o.interrupt=!1,o.parser.lazy[o.now().line]?r(T):(t.enter("tableDelimiterRow"),a=!1,lt(T)?nt(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 lt(T)?nt(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||Pe(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 lt(T)?nt(t,S,"whitespace")(T):S(T)}function S(T){return T===124?h(T):T===null||Pe(T)?!a||n!==i?N(T):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(T)):N(T)}function N(T){return r(T)}function I(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||Pe(T)?(t.exit("tableRow"),e(T)):lt(T)?nt(t,E,"whitespace")(T):(t.enter("data"),w(T))}function w(T){return T===null||T===124||At(T)?(t.exit("data"),E(T)):(t.consume(T),T===92?C:w)}function C(T){return T===92||T===124?(t.consume(T),w):w(T)}}function XBe(t,e){let r=-1,o=!0,n=0,i=[0,0,0,0],a=[0,0,0,0],s=!1,l=0,c,u,d,f=new nC;for(;++r<t.length;){let m=t[r],h=m[1];m[0]==="enter"?h.type==="tableHead"?(s=!1,l!==0&&(Ute(f,e,l,c,u),u=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,d=void 0,i=[0,0,0,0],a=[0,r+1,0,0],s&&(s=!1,u={type:"tableBody",start:Object.assign({},h.start),end:Object.assign({},h.end)},f.add(r,0,[["enter",u,e]])),n=h.type==="tableDelimiterRow"?2:u?3:1):n&&(h.type==="data"||h.type==="tableDelimiterMarker"||h.type==="tableDelimiterFiller")?(o=!1,a[2]===0&&(i[1]!==0&&(a[0]=a[1],d=iC(f,e,i,n,void 0,d),i=[0,0,0,0]),a[2]=r)):h.type==="tableCellDivider"&&(o?o=!1:(i[1]!==0&&(a[0]=a[1],d=iC(f,e,i,n,void 0,d)),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],d=iC(f,e,i,n,r,d)):a[1]!==0&&(d=iC(f,e,a,n,r,d)),n=0):n&&(h.type==="data"||h.type==="tableDelimiterMarker"||h.type==="tableDelimiterFiller")&&(a[3]=r)}for(l!==0&&Ute(f,e,l,c,u),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=zte(e.events,r))}return t}function iC(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]),u=kh(e.events,r[3]),d={type:s,start:Object.assign({},c),end:Object.assign({},u)};if(t.add(r[2],0,[["enter",d,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",d,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 Ute(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 JBe={tokenize:QBe};function WL(){return{text:{91:JBe}}}function QBe(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 At(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 Pe(l)?e(l):lt(l)?t.check({tokenize:ZBe},e,r)(l):r(l)}}function ZBe(t,e,r){return nt(t,o,"whitespace");function o(n){return n===null?r(n):e(n)}}function Vte(t){return GS([UL(),HL(),jL(t),GL(),WL()])}Ee();Ee();var Hte=["bmp","gif","ico","jpeg","jpg","png","tiff","webp"],jte=[...Hte,"svg"],Gte=["mp4","webm"],e4e="https://lh3.googleusercontent.com/";async function Ou(t,e){let r=window.__ROOT_CTX.rootConfig.projectId,o=await a4e(t),n=Nh(t.name),i=e?.preserveFilename?`${o}/${t.name}`:`${o}.${n}`,a=`${r}/uploads/${i}`,s=pQ(window.firebase.storage,a),l=dQ(s,t),c=-1,u=Date.now();return await new Promise((d,f)=>{let m=setInterval(()=>{Date.now()-u>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,u=Date.now())},h=>{clearInterval(m),f(h)},()=>{console.log(`uploaded ${a}`),clearInterval(m),d(l.snapshot)})}),t4e(s,t,n,e)}async function t4e(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(jte.includes(r)){let l=await n4e(e);if(n.width=l.width,n.height=l.height,!o?.disableGci&&Hte.includes(r)){let c=await o4e(i);c&&(n.gcsPath=i,a=c)}n.canvasBgColor=await l4e(e)?"dark":"light"}else if(Gte.includes(r)){let l=await i4e(a);n.width=l.width,n.height=l.height,console.log("video dimensions:",l)}let s=o?.cacheControl||"public, max-age=31536000";return await fQ(t,{cacheControl:s,customMetadata:s4e(n)}),console.log("updated meta data: ",n),{...n,src:a}}function Nh(t){return r4e(t.split(".").at(-1)||"")}function r4e(t){let e=String(t).toLowerCase();return e==="jpeg"&&(e="jpg"),e}async function o4e(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 n4e(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 i4e(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 a4e(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 s4e(t){let e={};return Object.entries(t).forEach(([r,o])=>{t[r]=String(o).trim()}),e}function Jb(t){if(!t)return!1;if(aC(t)||t.startsWith("data:image/"))return!0;let e=Nh(t);return jte.includes(e)}function aC(t){return t?t.startsWith(e4e):!1}function qL(t){if(!t)return!1;let e=Nh(t);return Gte.includes(e)}function Wte(t){return aC(t)?t.split("=")[0]+"=s0-d":t}function l4e(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,u=0,d=0;for(let m=0;m<s.length;m+=400)l+=s[m],c+=s[m+1],u+=s[m+2],d++;let f=.299*(l/d)+.587*(c/d)+.114*(u/d);e(f<128)},o.onerror=r,n.onerror=r,n.readAsDataURL(t)})}function sC(t){let[e,r]=M(""),o=W(null),n=W(null),[i,a]=M(null),[s,l]=M(!1),c=!e;function u(b){return b.endsWith(".jpg")?"image/jpeg":"image/png"}async function d(){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:u(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(),d();return}}async function h(b){try{l(!0),f();let y=await Ou(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:Oe("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(Ce,{label:"Upload image",children:p(Je,{component:"div",className:"AIPage__ChatBar__prompt__imageUpload__icon",radius:"xl",children:p(Ab,{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(Ze,{size:"sm"}):p(Ce,{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(Bb,{size:24,color:"white"})})]})})}),p(Je,{className:"AIPage__ChatBar__prompt__submit",variant:"filled",color:"dark",radius:"xl",onClick:()=>d(),disabled:c,children:p(FM,{size:18})})]}),p("div",{className:"AIPage__ChatBar__disclaimer",children:"Root AI is experimental and makes mistakes. Check all info."})]})}var qte={name:"@blinkk/root-cms",version:"2.3.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":"2.47.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.1","firebase-admin":">=11","firebase-functions":">=4",preact:">=10","preact-render-to-string":">=5"},peerDependenciesMeta:{"firebase-functions":{optional:!0}}};function Kte(){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 fc="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(Kte,{})}),p("div",{className:"Layout__top__version",children:["v",qte.version]}),p("div",{className:"Layout__top__project",children:t})]})};Fe.Side=()=>{let[t]=_Q(),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(EM,{stroke:fc})}),!i("content")&&p(Fe.SideButton,{label:"Content",url:"/cms/content",active:e.startsWith("/cms/content"),children:p(wf,{stroke:fc})}),!i("releases")&&p(Fe.SideButton,{label:"Releases",url:"/cms/releases",active:e.startsWith("/cms/releases"),children:p(_h,{stroke:fc})}),!i("data")&&p(Fe.SideButton,{label:"Data",url:"/cms/data",active:e.startsWith("/cms/data"),children:p(pM,{stroke:fc})}),!i("assets")&&p(Fe.SideButton,{label:"Assets",url:"/cms/assets",active:e.startsWith("/cms/assets"),children:p(RM,{stroke:fc})}),!i("translations")&&p(Fe.SideButton,{label:"Translations",url:"/cms/translations",active:e.startsWith("/cms/translations"),children:p(Su,{stroke:fc})}),a.ai&&!i("ai")&&p(Fe.SideButton,{label:"Root AI (experimental)",url:"/cms/ai",active:e.startsWith("/cms/ai"),children:p(Sf,{stroke:fc})}),o&&p(ke,{children:[p("div",{className:"Layout__side__divider"}),Object.entries(o).map(([s,l])=>{let c=l.cmsUrl?.startsWith("/cms/")?l.cmsUrl:void 0,u=l.externalUrl,d=u??c??`/cms/tools/${s}`,f=u?void 0:d.replace(/\/*$/g,""),m=!u&&!!f&&(e===f||e.startsWith(`${f}/`));return p(Fe.SideButton,{className:"Layout__side__tool",label:l.label||"",url:d,active:m,external:!!u,children:l.icon?p("img",{className:"Layout__side__tool__icon",src:l.icon,alt:l.label||""}):p(sM,{stroke:fc})},s)}),p("div",{className:"Layout__side__divider"})]}),!i("settings")&&p(Fe.SideButton,{label:"Settings",url:"/cms/settings",active:e.startsWith("/cms/settings"),children:p(Cf,{stroke:fc})})]}),p("div",{className:"Layout__side__user",children:p(Ce,{label:r.email,position:"right",withArrow:!0,children:p(ka,{src:r.photoURL,alt:r.email,size:30,radius:"xl"})})})]})};Fe.SideButton=t=>p(Ce,{className:Oe("Layout__side__button",t.className),label:t.label,position:"right",withArrow:!0,children:p("a",{className:Oe(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 oa(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 Yte(t,e){return Math.random()*(e-t)+t}var u4e=[20,40];lL.configure({ignoreUnescapedHTML:!0});function Xte(){return Yte(...u4e)}function Qb(){let[t,e]=M([]),[r,o]=M(""),n=s=>{let l=0;return e(c=>{let u={sender:"bot",blocks:[{type:"pending"}],key:oa()},d=[...c,{...s,key:oa()},u];return l=d.length-1,d}),l},i=(s,l)=>{e(c=>{let u=[...c];return u[s]={...l,key:oa()},u})};return{chatId:r,messages:t,addMessage:n,updateMessage:i,sendPrompt:async(s,l,c)=>{let u="/cms/api/ai.chat";typeof window.__ROOT_CTX.experiments?.ai=="object"&&window.__ROOT_CTX.experiments.ai.endpoint&&(u=window.__ROOT_CTX.experiments.ai.endpoint);let d={prompt:l,chatId:r,options:c},f=await window.fetch(u,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(d)});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 Jte(){let t=Qb(),e=window.__ROOT_CTX.experiments?.ai||!1;return p(Fe,{children:p("div",{className:"AIPage",children:e?p(ke,{children:[p(KL,{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(sC,{chat:t})]}):p("div",{className:"AIPage__notEnabled",children:[p("div",{className:"AIPage__notEnabled__icon",children:p(Sf,{size:36})}),p("div",{className:"AIPage__notEnabled__title",children:"Root AI is not enabled for this project."})]})})})}function KL(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(d4e,{message:r},r.key||o))}):p("div",{className:"AIPage__ChatWindow__welcome",children:[p("div",{className:"AIPage__ChatWindow__welcome__icon",children:p(Sf,{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 d4e(t){let e=t.message,r=e.sender==="user"?"You":"Root AI",o=window.firebase.user,n=e.sender==="bot",i=W(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(ka,{src:o.photoURL,alt:o.email,size:28,radius:"xl"}):p(Sf,{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(f4e,{message:e,animated:n})})]})]})}function f4e(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(g4e,{block:i,animated:t.animated,onAnimationComplete:()=>n()},s):i.type==="pending"?p(h4e,{block:i,animated:t.animated,onAnimationComplete:()=>n()},s):i.type==="text"?p(p4e,{block:i,animated:t.animated,onAnimationComplete:()=>n()},s):p("div",{children:["unknown block type: ",i.type]})})})}function Qte(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(),Xte())};return V(()=>{t.animated&&n()},[]),{nodes:e,next:i,complete:o}}function p4e(t){let e=ge(()=>CL(t.block.text,{extensions:[Vte()],mdastExtensions:[$L()]}),[t.block.text]),{nodes:r,next:o}=Qte({nodes:e.children,animated:t.animated,onAnimationComplete:t.onAnimationComplete});return p("div",{className:"AIPage__ChatMessageTextBlock",children:r.map((n,i)=>p(Zte,{node:n,animated:t.animated,onAnimationComplete:o},i))})}function Zte(t){let e=t.node;if(e.type==="code")return p(m4e,{text:e.value,language:e.lang,animated:t.animated,onAnimationComplete:t.onAnimationComplete});if(e.type==="heading"){let r=`h${e.depth||2}`;return p(Bf,{as:r,nodes:e.children,animated:t.animated,onAnimationComplete:t.onAnimationComplete})}if(e.type==="inlineCode")return p(Bf,{as:"code",nodes:[{type:"text",value:e.value}],animated:t.animated,onAnimationComplete:t.onAnimationComplete});if(e.type==="link")return p(Bf,{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(Bf,{as:r,nodes:e.children,animated:t.animated,onAnimationComplete:t.onAnimationComplete})}return e.type==="listItem"?p(Bf,{as:"li",nodes:e.children,animated:t.animated,onAnimationComplete:t.onAnimationComplete}):e.type==="paragraph"?p(Bf,{as:"p",nodes:e.children,animated:t.animated,onAnimationComplete:t.onAnimationComplete}):e.type==="strong"?p(Bf,{as:"b",nodes:e.children,animated:t.animated,onAnimationComplete:t.onAnimationComplete}):e.type==="text"?p(ere,{text:e.value,animated:t.animated,onAnimationComplete:t.onAnimationComplete}):p("div",{children:JSON.stringify(t.node)})}function Bf(t){let{nodes:e,next:r}=Qte({nodes:t.nodes,animated:t.animated,onAnimationComplete:t.onAnimationComplete}),o=t.as;return p(o,{...t.attrs,children:e.map((n,i)=>p(Zte,{node:n,animated:t.animated,onAnimationComplete:()=>r()},i))})}function ere(t){let e=t.sep||" ",r=ge(()=>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)},Xte());return()=>window.clearTimeout(a)},[t.text,o]),V(()=>{i&&t.animated&&t.onAnimationComplete()},[i]),p(ke,{children:[r.slice(0,o).join(e),!i&&p(tre,{})]})}function m4e(t){let e=W(null),[r,o]=M(!1);function n(){let s=e.current;lL.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(Ce,{label:"Copy code",position:"bottom",transition:"pop",children:p(Je,{onClick:()=>i(),size:"xs",children:r?p(uM,{color:"#80868b","stroke-width":1.5,size:16}):p(wb,{color:"#80868b","stroke-width":1.5,size:16})})})]}),p("pre",{ref:e,class:`language-${t.language||"unknown"}`,children:p(ere,{text:t.text,sep:`
67
67
  `,animated:t.animated,onAnimationComplete:a})})]})}function h4e(t){return V(()=>{t.animated&&t.onAnimationComplete()},[]),p("div",{className:"AIPage__PendingMessageBlock",children:p(tre,{})})}function tre(){return p("div",{className:"AIPage__CursorDot"})}function g4e(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 rre(t){let e=Qb();return p(ke,{children:[p(KL,{chat:e,children:t.children}),p(sC,{chat:e,options:{mode:"edit",editData:t.editModeData},onData:t.onEditModeResponse})]})}var YL="AiEditModal";function ore(){let t=Ct(),e=Vt();return{open:r=>{t.openContextModal(YL,{...e,title:r.title||"Edit with AI (Experimental)",innerProps:r,size:"calc(min(1920px, calc(100% - 96px)))",centered:!0})},close:()=>{t.closeModal(YL)}}}function lC(t){let{innerProps:e,context:r,id:o}=t,n=W(null),i=ge(()=>JSON.stringify(e.data||{},null,2),[e.data]),[a,s]=M(i),l=ge(()=>{if(!a)return null;try{return JSON.parse(a)}catch{return null}},[a]),c=ge(()=>a!==i,[a,i]),u=qe(()=>{if(!l)return;let f=yh(l);e.onSave&&e.onSave(f)},[l]),d=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(rre,{editModeData:l,onEditModeResponse:d,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(Ys,{className:"AiEditModal__Tabs",grow:!0,children:[p(Ys.Tab,{label:"JSON",icon:p(CM,{size:20}),children:p("div",{className:"AiEditModal__JsonEditor",children:p(ou,{value:a,onChange:f=>s(f),formatOnBlur:!0,height:"100%",className:"AiEditModal__JsonInput"})})}),p(Ys.Tab,{ref:n,label:"Diff",icon:p(xM,{size:20}),children:p("div",{className:"AiEditModal__JsonDiffViewer",children:e.data&&a&&p(GQ,{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(bb,{size:16}),disabled:!c,onClick:()=>s(i),children:"Reset"}),p(ee,{leftIcon:p(Ib,{size:16}),variant:"filled",size:"xs",color:"green",disabled:!l||!c,onClick:u,children:"Accept changes"})]})]})}lC.id=YL;Ee();var _4e=/^[a-z0-9_]+(?:--?[a-z0-9_]+)*$/;function dl(t,e){e||(e=_4e);let r=typeof e=="string"?new RegExp(e):e;return!!(t&&r.test(t))}function Au(t){return t.replace(/^[\s/]*/g,"").replace(/[\s/]*$/g,"").replace(/^\/+|\/+$/g,"").replaceAll("/","--")}Ee();function Ye(t){let{className:e,as:r,size:o,weight:n,color:i,children:a,...s}=t;return p(r||"div",{...s,className:Oe(e,"text",o&&`size:${o}`,n&&`weight:${n}`,i&&`color:${i}`),children:a})}function hs(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=XL(t);return`${o}${n}`}function XL(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="",u=i?.url;if(u)if(o){let d=u.replace(/\[.*slug\]/,o).replaceAll("--","/").replace(/\/+/g,"/");d==="/index"&&(d="/"),c=d}else c=u;return nre(l,{base:s,path:c,locale:n||"",slug:o})}function cC(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="",u=i?.previewUrl||i?.url;if(u)if(o){let d=u.replace(/\[.*slug\]/,o).replaceAll("--","/").replace(/\/+/g,"/");d==="/index"&&(d="/"),c=d}else c=u;return nre(l,{base:s,path:c,locale:n||"",slug:o})}function nre(t,e){let r=t.replaceAll(/\[\[?(\.\.\.)?([\w\-_]*)\]?\]/g,(o,n,i)=>e[i]??o);return x4e(r,{trailingSlash:window.__ROOT_CTX.rootConfig.server.trailingSlash})}function x4e(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 uC(t){let[e,r]=M(t.collectionId||""),o=W(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(d=>{s.push({value:d,label:d})});let l="";if(a?.url){if(n){let d=Au(n),f=a?.slugRegex;dl(d,f)?l=hs({collectionId:e,slug:d}):l="INVALID SLUG"}else l=hs({collectionId:e,slug:"[slug]"});l.endsWith("/index")&&(l=l.replace(/\/index$/,"/"))}function c(d){r(d),t.onChange&&t.onChange({collectionId:d,slug:n})}function u(d){i(d),t.onChange&&t.onChange({collectionId:e,slug:d})}return p("div",{className:Oe(t.className,"SlugInput"),children:[p("div",{className:"SlugInput__inputs",children:[p(Er,{className:"SlugInput__collection",placeholder:"Collection",size:"xs",data:s,onChange:d=>c(d),value:e,disabled:!!t.collectionDisabled}),p("div",{className:"SlugInput__divider",children:"/"}),p(ir,{className:"SlugInput__slug",name:"slug",ref:o,value:n,onChange:d=>{u(d.currentTarget.value)},placeholder:"slug",autoComplete:"off",size:"xs"})]}),l&&p(Ye,{className:"SlugInput__urlHelp",size:"body-sm",children:l})]})}var ire="CopyDocModal";function dC(t){let e=Ct(),r=Vt();return{open:o=>{e.openContextModal(ire,{...r,innerProps:{...t,...o}})}}}function fC(t){let{innerProps:e,context:r,id:o}=t,[n,i]=M(""),[a,s]=M(""),[l,c]=M(""),[u,d]=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=Au(a),S=window.__ROOT_CTX.collections[n]?.slugRegex;if(!dl(v,S)){c('Please enter a valid slug (e.g. "foo-bar-123").'),m(!1);return}let N=`${n}/${v}`;try{e.fields?await Ub(N,{fields:e.fields,overwrite:u}):await BQ(h,N,{overwrite:u}),r.closeModal(o),De({title:"Copied!",message:`Succesfully copied ${_} to ${N}.`,autoClose:5e3}),e.onSuccess&&e.onSuccess(N)}catch(I){let E=String(I);c(E),E.includes("already exists")&&d(!0),m(!1);return}m(!1),ho(`/cms/content/${n}/${v}`)}return p("div",{className:"CopyDocModal",children:p("form",{onSubmit:y=>b(y),children:[p("div",{className:"CopyDocModal__from",children:[p(Ye,{className:"CopyDocModal__from__label",size:"body",weight:"bold",children:"From:"}),p(Ye,{className:"CopyDocModal__from__value",size:"body-sm",children:p("code",{children:_})})]}),p("div",{className:"CopyDocModal__to",children:[p(Ye,{className:"CopyDocModal__to__label",size:"body",weight:"bold",children:"To:"}),p(uC,{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:u?"Overwrite?":"Submit"})]})]})})}fC.id=ire;Ee();async function are(){let t=window.firebase.db,e=window.__ROOT_CTX.rootConfig.projectId||"default",r=$e(t,"Projects",e),o=await ko(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 fl=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 are();return await a.share(s,"writer"),a}getUrl(){return Fa({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 pC(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 pC(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"})}))}},pC=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,u=new Set;l.push(i.map((v,S)=>(v===o&&(c=S),n.includes(v)&&u.add(S),{hasChanges:!1,value:v})));function d(v){l[0].push({hasChanges:!0,value:v}),s.push(v)}c===-1&&d(o);let f={};a.forEach((v,S)=>{let N=S+1;l.push(v.map((I,E)=>(E===c&&I&&(I in f?console.warn(`multiple rows keyed by "${I}"`):f[I]=N),{hasChanges:!1,value:I})))});function m(v){for(let N in v)s.includes(N)||d(N);return s.map(N=>v[N]??null)}e.forEach(v=>{let S=m(v),N=v[o],I=f[N];if(I){let E=l[I];S.map((w,C)=>{C>=E.length?E.push({hasChanges:!0,value:w||""}):w!==null&&E[C].value!==w&&(!u.has(C)||!E[C].value)&&(E[C]={hasChanges:!0,value:w})})}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,I)=>{if(N.hasChanges){let E=sre(I);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=sre(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 Fa({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 Fa(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 Du(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 sre(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 JL(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 lre(t){let e=JL(t);return e?`https://drive.google.com/drive/folders/${e}`:"https://drive.google.com/drive"}async function cre(t,e){if(!t)throw new Error("missing data source id");let r=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,n=$e(o,"Projects",r,"DataSources",t);await yu(n,{...e,id:t,createdAt:Cr(),createdBy:window.firebase.user.email}),Ot("datasource.create",{metadata:{datasourceId:t}})}async function mC(){let t=window.__ROOT_CTX.rootConfig.projectId,e=window.firebase.db,r=ea(e,"Projects",t,"DataSources"),o=mo(r),n=await ta(o),i=[];return n.forEach(a=>{i.push(a.data())}),i}async function $f(t){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,o=$e(r,"Projects",e,"DataSources",t),n=await ko(o);return n.exists()?n.data():null}async function hC(t,e){let r=e?.mode||"draft",o=window.__ROOT_CTX.rootConfig.projectId,n=window.firebase.db,i=$e(n,"Projects",o,"DataSources",t,"Data",r),a=await ko(i);return a.exists()?a.data():null}async function ure(t,e){let r=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,n=$e(o,"Projects",r,"DataSources",t);await Lr(n,e),Ot("datasource.save",{metadata:{datasourceId:t}})}async function dre(t){let e=await $f(t);if(!e)throw new Error(`data source not found: ${t}`);if(e.type==="http"&&e.url&&!hre(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 b4e(e),n=window.__ROOT_CTX.rootConfig.projectId,i=window.firebase.db,a=$e(i,"Projects",n,"DataSources",t),s=$e(i,"Projects",n,"DataSources",t,"Data","draft"),l={...e,syncedAt:Tt.now(),syncedBy:window.firebase.user.email},c=Ci(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 fre(t){let e=await $f(t);if(!e)throw new Error(`data source not found: ${t}`);let r=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,n=$e(o,"Projects",r,"DataSources",t),i=$e(o,"Projects",r,"DataSources",t,"Data","draft"),a=$e(o,"Projects",r,"DataSources",t,"Data","published"),s=await hC(t,{mode:"draft"}),l={...e,publishedAt:Tt.now(),publishedBy:window.firebase.user.email},c=Ci(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 pre(t,e){if(t.length===0)return;let r=window.firebase.db,o=window.__ROOT_CTX.rootConfig.projectId,n=e?.batch||Ci(r);for(let i of t){let a=await $f(i);if(!a)throw new Error(`data source not found: ${i}`);let s=await hC(i,{mode:"draft"}),l=$e(r,"Projects",o,"DataSources",i),c=$e(r,"Projects",o,"DataSources",i,"Data","draft"),u=$e(r,"Projects",o,"DataSources",i,"Data","published"),d={...a,publishedAt:Cr(),publishedBy:window.firebase.user.email};n.set(u,{dataSource:d,data:s?.data||null,...s?.headers?{headers:s.headers}:{}}),n.update(c,{dataSource:d}),n.update(l,{publishedAt:Cr(),publishedBy:window.firebase.user.email}),Ot("datasource.publish",{metadata:{datasourceId:i}})}(!e?.batch||e?.commitBatch)&&await n.commit()}async function mre(t){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,o=$e(r,"Projects",e,"DataSources",t),n=$e(r,"Projects",e,"DataSources",t,"Data","draft"),i=$e(r,"Projects",e,"DataSources",t,"Data","published"),a=Ci(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 b4e(t){if(t.type==="http")return{data:await v4e(t)};if(t.type==="gsheet")return await y4e(t);throw new Error(`unsupported data source: ${t.type}`)}async function y4e(t){let e=Du(t.url);if(!e?.spreadsheetId)throw new Error(`failed to parse google sheet url: ${t.url}`);let o=await new fl(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((u,d)=>{let f=i[d];f&&(c[f]=String(u||""))}),c}),headers:i}}async function v4e(t){if(!hre(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 hre(t){return t&&t.startsWith("/")}var QL="DataSourceSelectModal";function gre(){let t=Ct(),e=Vt();return{open:r=>{t.openContextModal(QL,{...e,innerProps:r,size:"600px",overflow:"inside"})},close:()=>{t.closeModal(QL)}}}function gC(t){let{innerProps:e}=t,[r,o]=M(!0),[n,i]=M([]),a=e.selectedDataSourceIds||[];V(()=>{async function c(){let u=await mC();i(u),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(Ze,{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))})})}gC.id=QL;Ee();Ee();async function rr(t){try{await t()}catch(e){console.error(e);let r;typeof e=="object"&&e.body?r=String(e.body):r=String(e),De({title:"Error",message:r,color:"red",autoClose:!1})}}ao();Ee();var ZL=ct(null);function Ph(){let t=it(ZL);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 u=ea(s,"Projects",l,"Collections",t,"Drafts"),d=u,f=e.orderBy;if(f==="modifiedAt")d=mo(u,Si("sys.modifiedAt","desc"));else if(f==="newest")d=mo(u,Si("sys.createdAt","desc"));else if(f==="oldest")d=mo(u,Si("sys.createdAt"));else if(f==="slug")d=mo(u,Si(cb()));else if(f==="slugDesc")d=mo(u,Si(cb(),"desc"));else{let h=window.__ROOT_CTX.collections[t]?.sortOptions?.find(g=>g.id===f);h&&(d=h.direction==="desc"?mo(u,Si(h.field,"desc")):mo(u,Si(h.field)))}await rr(async()=>{let m=await ta(d),h=[];m.docs.forEach(g=>{let _=g.data(),b=g.id,y=`${t}/${b}`,v={..._,id:y,slug:b};h.push(v),zb(y,v)}),o(h)}),i(!1)};return V(()=>{i(!0),c()},[t,e.orderBy]),[n,c,r]}function Ba(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function Oo(t,e){if(Array.isArray(e)){for(let n of e){let i=Oo(t,n);if(i!=null)return i}return}let r=e.split("."),o=t;for(let n of r){if(o==null)return;o=I4e(o,n)}return o}function I4e(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(Ba(o)&&Array.isArray(o._array)){let l=o._array[s];if(l===void 0)return;o=o[l];continue}if(Ba(o)&&Object.prototype.hasOwnProperty.call(o,String(s))){o=o[String(s)];continue}return}return o}function _re(t,e){return t.sort((r,o)=>{let n=r[e],i=o[e];return n<i?-1:n>i?1:0})}function Zb(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(!Zb(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(!Zb(t[n],e[n]))return!1;return!0}function $a(t){return t==null?t:typeof globalThis.structuredClone=="function"?globalThis.structuredClone(t):JSON.parse(JSON.stringify(t))}var e2="DocPickerModal";function xre(){let t=Ct(),e=Vt();return{open:r=>{t.openContextModal(e2,{...e,innerProps:r,size:"700px",overflow:"inside"})},close:()=>{t.closeModal(e2)}}}function Ru(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(Er,{data:o,value:n,placeholder:"Select",onChange:s=>{i(s||"")},size:"xs",radius:0,dropdownComponent:"div"})]}),n&&p(Ru.DocsList,{collection:n,onDocSelected:a})]})}Ru.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(Ze,{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(Ru.DocCard,{doc:o,onDocSelected:t.onDocSelected},o.id))})})};Ru.DocCard=t=>{let e=t.doc,[r,o]=e.id.split("/"),n=e.fields||{},i=window.__ROOT_CTX.collections[r],a=hs({collectionId:r,slug:o}),s=Oo(n,i.preview?.title||"meta.title"),l=Oo(n,i.preview?.image||"meta.image")||i.preview?.defaultImage;return p("div",{className:"DocPickerModal__DocCard",children:[p("div",{className:"DocPickerModal__DocCard__image",children:p(ru,{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"})})]})};Ru.id=e2;Ee();function Ah(t){let{file:e,width:r,height:o,withPlaceholder:n,className:i,alt:a}=t,s=typeof e=="string"?e:e?.src;return w4e(e)?p(E4e,{className:i,src:s,width:r,height:o}):p(ru,{className:i,src:s,width:r,height:o,withPlaceholder:n,alt:a})}function w4e(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 E4e(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 t2="DocSelectModal";function _C(){let t=Ct(),e=Vt();return{open:r=>{t.openContextModal(t2,{...e,innerProps:r,size:"700px",overflow:"inside"})},close:()=>{t.closeModal(t2)}}}function Mu(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(Er,{data:o,value:n,placeholder:"Select",onChange:l=>{i(l||"")},size:"xs",radius:0,dropdownComponent:"div"})]}),n&&p(Mu.DocsList,{collection:n,onDocSelected:a,onDocUnselected:s,selectedDocIds:e.selectedDocIds})]})}Mu.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(Ze,{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(Mu.DocCard,{doc:n,onDocSelected:t.onDocSelected,onDocUnselected:t.onDocUnselected,selected:o.includes(n.id)},n.id))})})};Mu.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=hs({collectionId:n,slug:i}),c=Oo(a,s.preview?.title||"meta.title"),u=Oo(a,s.preview?.image||"meta.image")||s.preview?.defaultImage;return p("div",{className:"DocSelectModal__DocCard",children:[p("div",{className:"DocSelectModal__DocCard__image",children:p(Ah,{file:u,width:120,height:90,withPlaceholder:!u?.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"})})]})};Mu.id=t2;Ee();var r2="EditJsonModal";function xC(){let t=Ct(),e=Vt();return{open:r=>{t.openContextModal(r2,{...e,title:r.title||"Edit JSON",innerProps:r,size:"680px",centered:!0})},close:()=>{t.closeModal(r2)}}}function bC(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,u]=M(!1),[d,f]=M(!1);function m(_){a(_),u(!1);try{JSON.parse(_),l(!0)}catch{l(!1)}f(_!==n)}function h(){navigator.clipboard.writeText(i).then(()=>u(!0))}function g(){let _=JSON.parse(i),b=yh(_);e.onSave&&e.onSave(b)}return p("div",{className:"EditJsonModal",children:[p(ou,{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(wb,{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(bb,{size:16}),disabled:!d,onClick:()=>{a(n),l(!0),f(!1)},children:"Reset"}),p(ee,{leftIcon:p(Eb,{size:16}),variant:"filled",size:"xs",color:"blue",disabled:!s||!d,onClick:g,children:"Save"})]})]})}bC.id=r2;Ee();function et(t){let{className:e,as:r,size:o,weight:n,color:i,children:a,...s}=t;return p(r||"h2",{...s,className:Oe(e,"heading",o&&`size:${o}`,n&&`weight:${n}`,i&&`color:${i}`),children:a})}var o2="EditTranslationsModal";function bre(){let t=Ct(),e=Vt();return{open:r=>{t.openContextModal(o2,{...e,innerProps:r,size:"900px",title:"Edit translations",overflow:"inside",className:"EditTranslationsModalWrap"})},close:()=>{t.closeModal(o2)}}}function Dh(t){let{innerProps:e,context:r,id:o}=t,n=e.strings||[],a=(window.__ROOT_CTX.rootConfig.i18n||{}).locales||["en"],[s,l]=M({}),[c,u]=M([]),[d,f]=M(!1),[m,h]=M(!1),[g,_]=M(!0);V(()=>{Cu({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 rr(async()=>{console.log("EditTranslationsModal.onSave()");let v=`edit-translations-${e.docId}`;De({id:v,loading:!0,title:"Saving translations",message:`Updating for ${e.docId}...`,autoClose:!1,disallowClose:!0});let S=[];c.forEach(N=>{let I=s[N];S.push(I)}),await Nf(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}),u(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(Ze,{}):p("table",{className:"EditTranslationsModal__table",children:[p("thead",{children:p("tr",{children:[p("th",{children:p(et,{size:"h4",weight:"semi-bold",children:"SOURCE"})}),p("th",{children:p(et,{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(Dh.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:Fa(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:!d,loading:m,children:"Save"})]})]})]})}Dh.StringsEditor=t=>{let e=t.locales,[r,o]=M(t.translations||{}),[n,i]=M(!1);function a(s,l){i(!0),o(c=>{let u={...c,source:t.source};return u[s]=l,u})}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:Oe("EditTranslationsModal__StringsEditor__row__translation",r[s]?"hasValue":"empty"),children:p(vr,{size:"xs",radius:0,autosize:!0,minRows:1,maxRows:10,value:r[s],onChange:l=>{a(s,l.currentTarget.value)}})})]}))})};Dh.id=o2;Fl();Ee();Ee();var s2=["https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/spreadsheets"],S4e=["https://www.googleapis.com/discovery/v1/apis/drive/v3/rest","https://sheets.googleapis.com/$discovery/rest?version=v4"];function Lu(){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]=GN({key:`root-cms::${t}::gapi-user-consent`,defaultValue:{}});async function l(){await Promise.all([T4e(),k4e()]),o(!1)}V(()=>{e&&l()},[]);function c(){return new Promise(d=>{let f=window.__ROOT_CTX.gapi.clientId,m=google.accounts.oauth2.initTokenClient({client_id:f,scope:s2.join(" "),callback:async h=>{let g=n2()+parseInt(h.expires_in);i(g),s({at:n2(),clientId:f,scopes:s2}),d()}});a&&C4e(a)?(console.log("requesting token without prompt"),m.requestAccessToken({prompt:""})):(console.log("requesting token with prompt"),m.requestAccessToken({prompt:"consent"}))})}function u(){return n2()<n}return{enabled:e,loading:r,isLoggedIn:u,login:c}}function C4e(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 s2.every(o=>r.includes(o))}function n2(){return Math.floor(new Date().getTime()/1e3)}var i2=null;async function T4e(){return i2||(i2=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(S4e.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)})),i2}var a2=null;async function k4e(){return a2||(a2=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)})),a2}ao();Ee();var yre=[{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(Sb,{size:16}),onClick:()=>{t&&window.open(t,lre(t))},children:"Open"})}],vre=ct(null);function Ire(t){let{db:e,user:r}=Ph(),o=window.__ROOT_CTX.rootConfig.projectId,[n,i]=M({});V(()=>{let s=$e(e,"Projects",o),l=vu(s,c=>{if(c.exists()){let u=c.data()||{};i(u.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=$e(e,"Projects",o);try{await Lr(c,new Pn("settings",s),l)}catch(u){console.error("Failed to set setting",s,u)}},[e,o,r.uid]);return p(vre.Provider,{value:{settings:n,setSettings:a},children:t.children})}function yC(){let t=it(vre);if(!t)throw new Error("useSiteSettings must be used within a <SiteSettingsProvider>");return t}var wre="ExportSheetModal";function Ere(){let t=Ct(),e=Vt();return{open:r=>{t.openContextModal(wre,{...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(""),[u,d]=M(!1),f=Lu(),m=yC(),h=W(),g=JL(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&&Du(l)?.spreadsheetId&&(b=!1));async function y(E,w){let C=w?.isNew||!1,{headers:T,rows:A}=e.csvData;C?(await E.replaceSheet(T,A),await E.applyL10nTheme()):await E.updateValuesMap(A,{keyedBy:"source",preserveColumns:e.locales})}async function v(){f.isLoggedIn()||await f.login();let E=window.__ROOT_CTX.rootConfig,w=E.projectName||E.projectId||"Root CMS",C,T,A="create-google-sheet";try{if(De({id:A,loading:!0,title:"Creating Google Sheet...",message:"Creating Google Sheet for localization.",autoClose:!1,disallowClose:!0}),C=await fl.create({title:`${w} 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(R){console.error(R);let P=R;typeof R=="object"&&R.body&&(P=String(R.body)),jt({id:A,title:"Failed to create Google Sheet",message:String(P),color:"red",autoClose:!1});return}try{jt({id:A,loading:!0,title:"Created Google Sheet!",message:`Linking sheet to ${e.docId}...`,autoClose:!1,disallowClose:!0});let R={spreadsheetId:C.spreadsheetId,gid:0};await OS(e.docId,R)}catch(R){console.error(R),jt({id:A,title:"Failed to link Google Sheet",message:String(R),color:"red",autoClose:!1});return}try{jt({id:A,loading:!0,title:"Linked Google Sheet!",message:"Exporting strings to sheet...",autoClose:!1,disallowClose:!0}),await y(T,{isNew:!0})}catch(R){console.error(R);let P=R;typeof R=="object"&&R.body&&(P=String(R.body)),jt({id:A,title:"Failed to export strings to Google Sheet",message:P,color:"red",autoClose:!1});return}c(T.getUrl()),d(!0),jt({id:A,title:"Done! Exported strings to Google Sheet.",message:C.getUrl(),autoClose:!1})}async function S(){f.isLoggedIn()||await f.login();let E=Du(l);if(!E?.spreadsheetId)throw new Error("failed to parse spreadsheet id");let w=new fl(E.spreadsheetId),C,T="add-tab-google-sheet";try{De({id:T,loading:!0,title:"Creating tab in Google Sheet...",message:"Adding tab in existing Google Sheet",autoClose:!1,disallowClose:!0}),C=await w.createSheet({title:e.docId})}catch(A){console.error(A);let R=A;typeof A=="object"&&A.body&&(R=String(A.body)),jt({id:T,title:"Failed to create Google Sheet",message:String(R),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 A={spreadsheetId:w.spreadsheetId,gid:C.gid};await OS(e.docId,A)}catch(A){console.error(A),jt({id:T,title:"Failed to link Google Sheet",message:String(A),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(A){console.error(A);let R=A;typeof A=="object"&&A.body&&(R=String(A.body)),jt({id:T,title:"Failed to export strings to Google Sheet",message:R,color:"red",autoClose:!1});return}d(!0),jt({id:T,title:"Done! Exported strings to Google Sheet.",message:C.getUrl(),autoClose:!1})}async function N(){let E="link-google-sheet",w=Du(l);if(!w?.spreadsheetId)throw new Error("failed to parse spreadsheet id");try{De({id:E,loading:!0,title:"Link Google Sheet",message:`Linking sheet to ${e.docId}...`,autoClose:!1,disallowClose:!0}),await OS(e.docId,w)}catch(C){console.error(C),jt({id:E,title:"Failed to link Google Sheet",message:String(C),color:"red",autoClose:!1});return}d(!0),jt({id:E,title:`Done! Linked ${e.docId} to Google Sheet.`,message:Fa(w),autoClose:!1})}async function I(){console.log(a),i(!0),a==="new-sheet"?await rr(v):a==="add-tab"?await rr(S):a==="link-sheet"&&await rr(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(Er,{disabled:u||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(ir,{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(ir,{placeholder:"https://docs.google.com/spreadsheets/d/...",value:l,disabled:u||n,onChange:E=>c(E.currentTarget.value)})]}),a==="new-sheet"&&p("div",{className:"ExportSheetModal__form__section",children:p(Ce,{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(eu,{disabled:u||n,ref:h,name:"share",value:"true",label:"Share Google Sheet with collaborators",checked:!g})})}),p("div",{className:"ExportSheetModal__form__buttons",children:u?p(ke,{children:[p(ee,{component:"a",target:"_blank",rel:"noopener noreferrer",href:l,variant:"default",size:"xs",color:"dark",rightIcon:p(Sb,{size:16}),children:"Open Google Sheet"}),p(ee,{variant:"filled",onClick:()=>r.closeModal(o),type:"button",size:"xs",color:"primary",children:"Done"})]}):p(ke,{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:()=>I(),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(Ye,{className:"ExportSheetModal__SelectItem__label",size:"body",children:e}),p(Ye,{className:"ExportSheetModal__SelectItem__help",size:"body-sm",children:r})]})});Rh.id=wre;Ee();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 vC(t){let e=window.firebase.db,r=window.__ROOT_CTX.rootConfig.projectId,[o,n]=t.split("/",2),i=await Mh(o),a=$e(e,"Projects",r,"Collections",o,"Drafts",n),l=(await ko(a)).data()||{},c=new Set;return ey(c,i.fields,l.fields||{},i.types||{}),Array.from(c)}function ey(t,e,r,o={}){e.forEach(n=>{if(!n.id)return;let i=r[n.id];IC(t,n,i,o)})}function IC(t,e,r,o={}){if(!r)return;function n(i){let a=cc(i);a&&t.add(a)}if(e.type==="object")ey(t,e.fields||[],r,o);else if(e.type==="array"){let i=r._array||[];for(let a of i)IC(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&&ey(t,a.fields||[],r,o)}else e.type==="richtext"?e.translate&&N4e(t,r):console.log(`extract: ignoring field, id=${e.id}, type=${e.type}`)}function N4e(t,e){(e?.blocks||[]).forEach(o=>{P4e(t,o)})}function P4e(t,e){if(!e?.type)return;function r(n){if(!n)return;let i=cc(n);i&&t.add(i)}function o(n){n&&n.forEach(i=>{r(i.content),o(i.items)})}e.type==="heading"||e.type==="paragraph"?r(e.data?.text):e.type==="orderedList"||e.type==="unorderedList"?o(e.data?.items):e.type==="html"&&r(e.data?.html)}var Sre="LocalizationModal";function Cre(){let t=Ct(),e=Vt();return{open:r=>{t.openContextModal(Sre,{...e,innerProps:r,size:"clamp(80%, 1024px, 1280px)",onClose:()=>{r.draft.flush()}})}}}function na(t){let e=t.innerProps;return p("div",{className:"LocalizationModal",children:p("div",{className:"LocalizationModal__layout",children:[p(na.ConfigLocales,{...e}),p(na.Translations,{...e})]})})}na.id=Sre;na.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(u=>(i[c].locales||[]).includes(u))}function s(c,u){let d=new Set(e),f=i[c].locales||[];for(let h of f)u.includes(h)?d.add(h):d.delete(h);let m=Array.from(d.values()).sort();l(m)}function l(c){r(c),t.draft.setLocales(c)}return p("div",{className:"LocalizationModal__locales",children:p(Ks,{spacing:30,children:[p(Ki,{children:[p(et,{className:"LocalizationModal__iconTitle LocalizationModal__locales__title",size:"h2",children:[p(AM,{strokeWidth:1.5}),p("span",{children:"Locales"})]}),p(na.AllNoneButtons,{onAllClicked:()=>l(n),onNoneClicked:()=>l([])})]}),p(Ks,{spacing:40,children:Object.keys(i).map(c=>{let u=i[c],d=a(c);return p(na.LocaleGroup,{group:u,groupEnabledLocales:d,allEnabledLocales:e,onChange:f=>s(c,f)})})})]})})};na.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(Ks,{spacing:16,children:[t.group.label&&p(Ki,{position:"apart",children:[p(et,{size:"h4",weight:"semi-bold",children:t.group.label}),p(na.AllNoneButtons,{onAllClicked:()=>n(r),onNoneClicked:()=>n([])})]}),p(Ki,{children:r.map(a=>{let s=e.includes(a),l=o.length<=1&&s;return p(eu,{value:a,checked:s,disabled:l,label:Tre(a),onChange:()=>i(a),size:"xs"})})})]})};na.AllNoneButtons=t=>p(Ki,{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"})]});na.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,u]=M({}),[d,f]=M({}),m=Lu(),[h,g]=M(null),_=Ere(),b=ge(()=>{let P={};return Object.values(d).forEach(B=>{P[B.source]=B}),P},[d]),y=i.map(P=>({value:P,label:Tre(P)}));V(()=>{r(!0),Promise.all([vC(t.docId),Cu(),AS(t.docId)]).then(([P,B,$])=>{n(P),f(B),g($),r(!1)})},[t.docId]),V(()=>{if(!s){u({});return}let P={};Object.values(d).forEach(B=>{P[B.source]=B[s]||""}),u(P)},[s,d]);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(G=>{H[G]=v(z,G)}),$.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 G=await $.text();console.error(G)}let z=await $.blob(),H=window.URL.createObjectURL(z);window.location.assign(H),window.URL.revokeObjectURL(H)}async function I(){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,G=await Nf(t.docId,H);f(Y=>Object.assign({},Y,G)),De({title:"Saved!",message:`Imported translations for ${t.docId}.`,autoClose:5e3})}catch(z){console.error(z),De({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 fl(h.spreadsheetId).getSheet(h.gid??0);if(!B)throw new Error(`sheet not found: ${JSON.stringify(h)}`);await w(B),De({title:"Exported strings to Google Sheet",message:B.getUrl(),autoClose:!1})}async function w(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 fl(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 Nf(t.docId,$);f(H=>Object.assign({},H,z)),De({title:"Saved!",message:`Imported translations for ${t.docId}.`,autoClose:5e3})}async function T(){await UQ(t.docId),g(null),De({title:"Unlinked Google Sheet",message:`${t.docId} is no longer connected to a Google Sheet.`,autoClose:5e3})}async function A(P){try{await P()}catch(B){console.error(B);let $;typeof B=="object"&&B.body?$=String(B.body):$=String(B),De({title:"Error",message:$,color:"red",autoClose:!1})}}function R(P){switch(P){case"EXPORT_DOWNLOAD_CSV":{A(N);return}case"EXPORT_GOOGLE_SHEET_LINKED":{A(E);return}case"EXPORT_GOOGLE_SHEET_SHOW_OPTIONS":{_.open({docId:t.docId,csvData:S(),locales:i});return}case"IMPORT_CSV":{A(I);return}case"IMPORT_GOOGLE_SHEET_LINKED":{A(C);return}case"UNLINK_GOOGLE_SHEET":{A(T);return}default:console.log("unhandled action: "+P)}}return e?p("div",{className:"LocalizationModal__translations__loading",children:p(Ze,{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(et,{className:"LocalizationModal__translations__title LocalizationModal__iconTitle",size:"h2",children:[p(Su,{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(Ce,{label:"Open Google Sheet",children:p(Je,{component:"a",href:Fa(h),target:"_blank",variant:"filled",color:"green",size:"sm",children:p(Tf,{size:16,strokeWidth:2.25})})}),p(O4e,{onAction:R,gapiClient:m,linkedSheet:h}),p(A4e,{onAction:R,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(et,{size:"h4",weight:"semi-bold",children:"SOURCE STRING"})}),p("th",{className:"LocalizationModal__translations__table__header",children:p(et,{className:"LocalizationModal__translations__localeSelect",size:"h4",weight:"semi-bold",children:[p("span",{children:"LOCALE: "})," ",p(Er,{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(Dr,{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(Dr,{size:"xs",sx:{whiteSpace:"pre-wrap"},children:c[P]||" "})})})]},B))]})]})};function O4e(t){function e(o){t.onAction&&t.onAction(o)}let r=t.linkedSheet;return p(Ue,{className:"LocalizationModal__translations__menu",position:"bottom",placement:"end",control:p(ee,{variant:"default",color:"dark",size:"xs",leftIcon:p(sl,{size:16,strokeWidth:1.75}),rightIcon:p(sc,{size:16,strokeWidth:1.75}),children:"Import"}),children:[t.gapiClient.enabled&&p(ke,{children:[p(Ue.Label,{children:"Google Sheets"}),p(Ue.Item,{className:"LocalizationModal__translations__menu__item",disabled:!r?.spreadsheetId,onClick:()=>e("IMPORT_GOOGLE_SHEET_LINKED"),children:"Import Google Sheet"}),p(Ca,{})]}),p(Ue.Label,{children:"File"}),p(Ue.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("IMPORT_CSV"),children:"Import .csv"})]})}function A4e(t){async function e(n){t.onAction&&t.onAction(n)}let o=!!t.linkedSheet?.spreadsheetId;return p(Ue,{className:"LocalizationModal__translations__menu",position:"bottom",placement:"start",control:p(ee,{variant:"default",color:"dark",size:"xs",leftIcon:p(If,{size:16,strokeWidth:1.75}),rightIcon:p(sc,{size:16,strokeWidth:1.75}),children:"Export"}),children:[t.gapiClient.enabled&&p(ke,{children:[p(Ue.Label,{children:"Google Sheets"}),o?p(ke,{children:p(Ue.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("EXPORT_GOOGLE_SHEET_LINKED"),children:"Export to Google Sheet"})}):p(ke,{children:p(Ue.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("EXPORT_GOOGLE_SHEET_SHOW_OPTIONS"),children:"Export to Google Sheet"})}),p(Ca,{})]}),p(Ue.Label,{children:"File"}),p(Ue.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("EXPORT_DOWNLOAD_CSV"),children:"Download .csv"}),o&&p(ke,{children:[p(Ca,{}),p(Ue.Label,{children:"Danger zone"}),p(Ue.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("UNLINK_GOOGLE_SHEET"),color:"red",children:"Unlink Google Sheet"})]})]})}function Tre(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})`}Ee();var kre="LockPublishingModal";function Nre(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(kre,{...r,title:i,innerProps:{...t,...o},size:"600px"})}}}function Fu(t){let{innerProps:e}=t;return e.unlock?p(Fu.Unlock,{...t}):p(Fu.Lock,{...t})}Fu.Lock=t=>{let{innerProps:e,context:r,id:o}=t,[n,i]=M(""),[a,s]=M(0),[l,c]=M(!1),u=Ct();function d(m){return m?Math.floor(new Date(m).getTime()):0}async function f(m){m.preventDefault(),c(!0),await rr(async()=>{await LQ(e.docId,{reason:n,until:a}),De({title:"Locked!",message:`Publishing is locked for ${e.docId}.`,autoClose:1e4}),u.closeModal(o),e.onChange&&e.onChange("locked")})}return p("div",{className:"LockPublishingModal LockPublishingModal--lock",children:[p(Ye,{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(ir,{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(kn,{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(d(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(Ef,{size:14}),disabled:!n,type:"submit",loading:l,children:"Lock"})]})]})]})};Fu.Unlock=t=>{let{innerProps:e,context:r,id:o}=t,[n,i]=M(!1),a=Ct();async function s(){i(!0),await rr(async()=>{await FQ(e.docId),De({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(Ye,{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(Pb,{size:14}),loading:n,onClick:()=>s(),children:"Unlock"})]})]})};Fu.id=kre;Ee();var d2=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(d2).filter(r=>typeof r<"u");let e={};for(let[r,o]of Object.entries(t)){let n=d2(o);typeof n<"u"&&(e[r]=n)}return e},Pre=d2,D4e=(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},kr=D4e,f2=(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(f2(t[r],e))return!0;return!1}for(let r in t)if(f2(t[r],e))return!0;return!1},R4e=f2,p2=(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 oy.throw:throw new Error(`Value is not valid in JSON, got ${String(t)}`);case oy.stringify:return M4e(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=>p2(a,e,r,o-1,n)).join(",")}]`:`{${Object.keys(t).map(a=>`"${a}": ${p2(t[a],e,r,o-1,n)}`).join(", ")}}`;return JSON.stringify(JSON.parse(i),e,r)},M4e=t=>t===void 0?"undefined":t===1/0?"Infinity":t===-1/0?"-Infinity":Number.isNaN(t)?"NaN":typeof t=="bigint"?`${t}n`:String(t),Zo=p2,L4e=(t,e=1/0,r=!1,o=oy.stringify)=>t===null?"null":Array.isArray(t)||typeof t=="object"?Zo(t,void 0,r?1:void 0,e,o):Zo(t,void 0,void 0,void 0,o),za=L4e,Ore=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,F4e=(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=Ore(t),a=Ore(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))},ny=F4e,B4e=t=>Array.isArray(t)?"array":t===null?"null":typeof t,gs=B4e,$4e=(t,e,r,o,n,i,a,s)=>{let l={ignoreCase:s.ignoreCase},c=za(n,s.maxDepth,!0,s.undefinedBehavior).split(`
68
68
  `),u=za(i,s.maxDepth,!0,s.undefinedBehavior).split(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blinkk/root-cms",
3
- "version": "2.2.13",
3
+ "version": "2.3.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.2.13"
136
+ "@blinkk/root": "2.3.1"
137
137
  },
138
138
  "peerDependencies": {
139
- "@blinkk/root": "2.2.13",
139
+ "@blinkk/root": "2.3.1",
140
140
  "firebase-admin": ">=11",
141
141
  "firebase-functions": ">=4",
142
142
  "preact": ">=10",