@blinkk/root-cms 1.4.7 → 1.4.8
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 +2 -2
- package/dist/{client-vS0mO6Nw.d.ts → client-AE0BYn69.d.ts} +145 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +283 -2
- package/dist/core.d.ts +3 -3
- package/dist/core.js +283 -2
- package/dist/functions.js +281 -2
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.js +281 -2
- package/dist/project.d.ts +1 -1
- package/dist/{schema-hlZc-G1f.d.ts → schema-NuZy-PDV.d.ts} +4 -0
- package/dist/ui/ui.js +3 -3
- package/package.json +3 -3
package/dist/ui/ui.js
CHANGED
|
@@ -34,7 +34,7 @@ Content-Type: `+c.contentType+`\r
|
|
|
34
34
|
`,p=`\r
|
|
35
35
|
--`+l+"--",m=ab.getBlob(d,o,p);if(m===null)throw Wce();let h={name:c.fullPath},g=H9(a,t.host,t._protocol),_="POST",x=t.maxUploadRetryTime,b=new ib(g,_,K9(t,r),x);return b.urlParams=h,b.headers=i,b.body=m.uploadData(),b.errorHandler=X9(e),b}var z7e=256*1024;var N9=null,hS=class{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=pl.NO_ERROR,this.sendPromise_=new Promise(e=>{this.xhr_.addEventListener("abort",()=>{this.errorCode_=pl.ABORT,e()}),this.xhr_.addEventListener("error",()=>{this.errorCode_=pl.NETWORK_ERROR,e()}),this.xhr_.addEventListener("load",()=>{e()})})}send(e,r,o,n){if(this.sent_)throw Op("cannot .send() more than once");if(this.sent_=!0,this.xhr_.open(r,e,!0),n!==void 0)for(let a in n)n.hasOwnProperty(a)&&this.xhr_.setRequestHeader(a,n[a].toString());return o!==void 0?this.xhr_.send(o):this.xhr_.send(),this.sendPromise_}getErrorCode(){if(!this.sent_)throw Op("cannot .getErrorCode() before sending");return this.errorCode_}getStatus(){if(!this.sent_)throw Op("cannot .getStatus() before sending");try{return this.xhr_.status}catch{return-1}}getResponse(){if(!this.sent_)throw Op("cannot .getResponse() before sending");return this.xhr_.response}getErrorText(){if(!this.sent_)throw Op("cannot .getErrorText() before sending");return this.xhr_.statusText}abort(){this.xhr_.abort()}getResponseHeader(e){return this.xhr_.getResponseHeader(e)}addUploadProgressListener(e){this.xhr_.upload!=null&&this.xhr_.upload.addEventListener("progress",e)}removeUploadProgressListener(e){this.xhr_.upload!=null&&this.xhr_.upload.removeEventListener("progress",e)}},gS=class extends hS{initXhr(){this.xhr_.responseType="text"}};function Y9(){return N9?N9():new gS}var wu=class t{constructor(e,r){this._service=e,r instanceof Zn?this._location=r:this._location=Zn.makeFromUrl(r,e.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(e,r){return new t(e,r)}get root(){let e=new Zn(this._location.bucket,"");return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return q9(this._location.path)}get storage(){return this._service}get parent(){let e=_ue(this._location.path);if(e===null)return null;let r=new Zn(this._location.bucket,e);return new t(this._service,r)}_throwIfRoot(e){if(this._location.path==="")throw Xce(e)}};function Oue(t,e,r){t._throwIfRoot("uploadBytes");let o=Pue(t.storage,t._location,G9(),new ab(e,!0),r);return t.storage.makeRequestWithTokens(o,Y9).then(n=>({metadata:n,ref:t}))}function Aue(t,e){t._throwIfRoot("updateMetadata");let r=Cue(t.storage,t._location,e,G9());return t.storage.makeRequestWithTokens(r,Y9)}function Due(t,e){let r=xue(t._location.path,e),o=new Zn(t._location.bucket,r);return new wu(t.storage,o)}function Rue(t){return/^[A-Za-z]+:\/\//.test(t)}function Nue(t,e){return new wu(t,e)}function Q9(t,e){if(t instanceof Rp){let r=t;if(r._bucket==null)throw Gce();let o=new wu(r,r._bucket);return e!=null?Q9(o,e):o}else return e!==void 0?Due(t,e):t}function Mue(t,e){if(e&&Rue(e)){if(t instanceof Rp)return Nue(t,e);throw fS("To use ref(service, url), the first argument must be a Storage instance.")}else return Q9(t,e)}function M9(t,e){let r=e?.[z9];return r==null?null:Zn.makeFromBucketSpec(r,t)}function Lue(t,e,r,o={}){t.host=`${e}:${r}`,t._protocol="http";let{mockUserToken:n}=o;n&&(t._overrideAuthToken=typeof n=="string"?n:kw(n,t.app.options.projectId))}var Rp=class{constructor(e,r,o,n,a){this.app=e,this._authProvider=r,this._appCheckProvider=o,this._url=n,this._firebaseVersion=a,this._bucket=null,this._host=F9,this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=Mce,this._maxUploadRetryTime=Lce,this._requests=new Set,n!=null?this._bucket=Zn.makeFromBucketSpec(n,this._host):this._bucket=M9(this._host,this.app.options)}get host(){return this._host}set host(e){this._host=e,this._url!=null?this._bucket=Zn.makeFromBucketSpec(this._url,e):this._bucket=M9(e,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){R9("time",0,Number.POSITIVE_INFINITY,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){R9("time",0,Number.POSITIVE_INFINITY,e),this._maxOperationRetryTime=e}async _getAuthToken(){if(this._overrideAuthToken)return this._overrideAuthToken;let e=this._authProvider.getImmediate({optional:!0});if(e){let r=await e.getToken();if(r!==null)return r.accessToken}return null}async _getAppCheckToken(){let e=this._appCheckProvider.getImmediate({optional:!0});return e?(await e.getToken()).token:null}_delete(){return this._deleted||(this._deleted=!0,this._requests.forEach(e=>e.cancel()),this._requests.clear()),Promise.resolve()}_makeStorageReference(e){return new wu(this,e)}_makeRequest(e,r,o,n,a=!0){if(this._deleted)return new pS(U9());{let i=iue(e,this._appId,o,n,r,this._firebaseVersion,a);return this._requests.add(i),i.getPromise().then(()=>this._requests.delete(i),()=>this._requests.delete(i)),i}}async makeRequestWithTokens(e,r){let[o,n]=await Promise.all([this._getAuthToken(),this._getAppCheckToken()]);return this._makeRequest(e,r,o,n).getPromise()}},L9="@firebase/storage",B9="0.11.2";var Z9="storage";function J9(t,e,r){return t=kt(t),Oue(t,e,r)}function ez(t,e){return t=kt(t),Aue(t,e)}function tz(t,e){return t=kt(t),Mue(t,e)}function rz(t=pf(),e){t=kt(t);let o=Hs(t,Z9).getImmediate({identifier:e}),n=Ew("storage");return n&&Bue(o,...n),o}function Bue(t,e,r,o={}){Lue(t,e,r,o)}function Fue(t,{instanceIdentifier:e}){let r=t.getProvider("app").getImmediate(),o=t.getProvider("auth-internal"),n=t.getProvider("app-check-internal");return new Rp(r,o,n,e,pa)}function zue(){fa(new $o(Z9,Fue,"PUBLIC").setMultipleInstances(!0)),jo(L9,B9,""),jo(L9,B9,"esm2017")}zue();var Uue={};function sb(t,e){for(var r in e)t[r]=e[r];return t}function Vue(t,e,r){var o,n=/(?:\?([^#]*))?(#.*)?$/,a=t.match(n),i={};if(a&&a[1])for(var s=a[1].split("&"),l=0;l<s.length;l++){var c=s[l].split("=");i[decodeURIComponent(c[0])]=decodeURIComponent(c.slice(1).join("="))}t=bS(t.replace(n,"")),e=bS(e||"");for(var u=Math.max(t.length,e.length),d=0;d<u;d++)if(e[d]&&e[d].charAt(0)===":"){var p=e[d].replace(/(^:|[+*?]+$)/g,""),m=(e[d].match(/[+*?]+$/)||Uue)[0]||"",h=~m.indexOf("+"),g=~m.indexOf("*"),_=t[d]||"";if(!_&&!g&&(m.indexOf("?")<0||h)){o=!1;break}if(i[p]=decodeURIComponent(_),h||g){i[p]=t.slice(d).map(decodeURIComponent).join("/");break}}else if(e[d]!==t[d]){o=!1;break}return(r.default===!0||o!==!1)&&i}function Hue(t,e){return t.rank<e.rank?1:t.rank>e.rank?-1:t.index-e.index}function $ue(t,e){return t.index=e,t.rank=function(r){return r.props.default?0:bS(r.props.path).map(jue).join("")}(t),t.props}function bS(t){return t.replace(/(^\/+|\/+$)/g,"").split("/")}function jue(t){return t.charAt(0)==":"?1+"*+?".indexOf(t.charAt(t.length-1))||4:5}var que={},ml=[],Np=[],ln=null,yS={url:vS()},nz=Rt(yS);function az(){var t=Mt(nz);if(t===yS){var e=P()[1];L(function(){return Np.push(e),function(){return Np.splice(Np.indexOf(e),1)}},[])}return[t,ur]}function vS(){var t;return""+((t=ln&&ln.location?ln.location:ln&&ln.getCurrentLocation?ln.getCurrentLocation():typeof location<"u"?location:que).pathname||"")+(t.search||"")}function ur(t,e){return e===void 0&&(e=!1),typeof t!="string"&&t.url&&(e=t.replace,t=t.url),function(r){for(var o=ml.length;o--;)if(ml[o].canRoute(r))return!0;return!1}(t)&&function(r,o){o===void 0&&(o="push"),ln&&ln[o]?ln[o](r):typeof history<"u"&&history[o+"State"]&&history[o+"State"](null,null,r)}(t,e?"replace":"push"),iz(t)}function iz(t){for(var e=!1,r=0;r<ml.length;r++)ml[r].routeTo(t)&&(e=!0);return e}function Gue(t){if(t&&t.getAttribute){var e=t.getAttribute("href"),r=t.getAttribute("target");if(e&&e.match(/^\//g)&&(!r||r.match(/^_?self$/i)))return ur(e)}}function Wue(t){return t.stopImmediatePropagation&&t.stopImmediatePropagation(),t.stopPropagation&&t.stopPropagation(),t.preventDefault(),!1}function Kue(t){if(!(t.ctrlKey||t.metaKey||t.altKey||t.shiftKey||t.button)){var e=t.target;do if(e.localName==="a"&&e.getAttribute("href")){if(e.hasAttribute("data-native")||e.hasAttribute("native"))return;if(Gue(e))return Wue(t)}while(e=e.parentNode)}}var oz=!1;function IS(t){t.history&&(ln=t.history),this.state={url:t.url||vS()}}sb(IS.prototype=new Vo,{shouldComponentUpdate:function(t){return t.static!==!0||t.url!==this.props.url||t.onChange!==this.props.onChange},canRoute:function(t){var e=yo(this.props.children);return this.g(e,t)!==void 0},routeTo:function(t){this.setState({url:t});var e=this.canRoute(t);return this.p||this.forceUpdate(),e},componentWillMount:function(){this.p=!0},componentDidMount:function(){var t=this;oz||(oz=!0,ln||addEventListener("popstate",function(){iz(vS())}),addEventListener("click",Kue)),ml.push(this),ln&&(this.u=ln.listen(function(e){var r=e.location||e;t.routeTo(""+(r.pathname||"")+(r.search||""))})),this.p=!1},componentWillUnmount:function(){typeof this.u=="function"&&this.u(),ml.splice(ml.indexOf(this),1)},componentWillUpdate:function(){this.p=!0},componentDidUpdate:function(){this.p=!1},g:function(t,e){t=t.filter($ue).sort(Hue);for(var r=0;r<t.length;r++){var o=t[r],n=Vue(e,o.props.path,o.props);if(n)return[o,n]}},render:function(t,e){var r,o,n=t.onChange,a=e.url,i=this.c,s=this.g(yo(t.children),a);if(s&&(o=Mm(s[0],sb(sb({url:a,matches:r=s[1]},r),{key:void 0,ref:void 0}))),a!==(i&&i.url)){sb(yS,i=this.c={url:a,previous:i&&i.url,current:o,path:o?o.props.path:null,matches:r}),i.router=this,i.active=o?[o]:[];for(var l=Np.length;l--;)Np[l]({});typeof n=="function"&&n(i)}return Q(nz.Provider,{value:i},o)}});var Gt=function(t){return Q(t.component,t)};var Xue=/^[a-z0-9_]+(?:--?[a-z0-9_]+)*$/;function Ca(t,e){e||(e=Xue);let r=typeof e=="string"?new RegExp(e):e;return!!(t&&r.test(t))}function $i(t){return t.replace(/^[\s/]*/g,"").replace(/[\s/]*$/g,"").replace(/^\/+|\/+$/g,"").replaceAll("/","--")}function xt(){let t=Lt();return{overlayColor:t.colorScheme==="dark"?t.colors.dark[9]:t.colors.gray[2],overlayOpacity:.55,overlayBlur:3}}var Tr={year:31536e6,month:2628e6,week:6048e5,day:864e5,hour:36e5,minute:6e4,second:1e3};function Rn(t,e){let r=Math.abs(t-new Date().getTime());if(r<Tr.second)return"just now";let o=e||{numeric:"auto"},n=new Intl.RelativeTimeFormat("en",o);return r<Tr.minute?n.format(Math.round(-r/Tr.second),"second"):r<Tr.hour?n.format(Math.round(-r/Tr.minute),"minute"):r<Tr.day?n.format(Math.round(-r/Tr.hour),"hour"):r<Tr.week?n.format(Math.round(-r/Tr.day),"day"):new Date(t).toLocaleDateString("en",{year:"numeric",month:"short",day:"numeric"})}function Mp(){return Math.floor(new Date().getTime())}function lb(t){return new Date(t.toMillis()).toLocaleDateString("en",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Eu(){let t=s=>s<10?"0"+s:s,e=new Date,r=e.getFullYear(),o=t(e.getMonth()+1),n=t(e.getDate()),a=t(e.getHours()),i=t(e.getMinutes());return`${r}-${o}-${n}T${a}:${i}`}var sz={};async function Je(t,e){let r=e?.throttle||0,o=e?.throttleId?`${t}::${e.throttleId}`:t;if(Yue(o,r))return;let n=await fetch("/cms/api/actions.log",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:t,metadata:e?.metadata||{}})});if(n.status!==200){let a=await n.text();console.error(`failed to log action "${t}":`,a);return}sz[o]=Mp()}async function lz(t){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,o=nn(r,"Projects",e,"ActionLogs"),n=t?.limit||40,a=Math.ceil(n*1.5),i=to(o,Qn("timestamp","desc"),k9(a)),s=await an(i),l=[];function c(d){if(l.length===0)return!1;let p=l.at(-1);return d.action==="doc.save"&&p.action==="doc.save"&&d.by===p.by&&d.metadata.docId===p.metadata.docId&&d.timestamp.toMillis()-p.timestamp.toMillis()<60*Tr.minute}let u=0;for(let d of s.docs){if(u>=n)break;let p=d.data();c(p)||(l.push(p),u+=1)}return l}function Yue(t,e){if(e===0)return!1;let r=sz[t];return r?Mp()-r<e:!1}var wS=new Map;function Que(t){return wS.get(t)||null}async function cb(t){let e=Que(t);if(e)return e;let r=Nn(t),n=(await vr(r)).data();return Lp(t,n),n}function Lp(t,e){wS.set(t,e)}function ES(t){wS.delete(t)}function cz(t){for(let e of t)ES(e)}function SS(){let t=window.__ROOT_CTX.rootConfig.projectId,e=window.firebase.db;return nn(e,"Projects",t,"Translations")}async function ji(t){let e=SS(),r=t?.tags?to(e,eb("tags","array-contains-any",t.tags)):to(e),o=await an(r),n={};return o.forEach(a=>{let i=a.id;n[i]=a.data()}),n}async function uz(t){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,o=we(r,"Projects",e,"Translations",t);return(await vr(o)).data()}async function dz(t,e){let r=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,n=we(o,"Projects",r,"Translations",t),a={};for(let i in e){let s=ede(i);s&&(a[s]=e[i])}console.log("updating translations: ",a),await rr(n,a),Je("translations.save",{metadata:{hash:t},throttle:5*Tr.minute,throttleId:t})}async function ub(t){return Zue(ei(t))}async function Zue(t){let r=new TextEncoder().encode(t),o=await crypto.subtle.digest("SHA-1",r);return Array.from(new Uint8Array(o)).map(i=>i.toString(16).padStart(2,"0")).join("")}function ei(t){return String(t).trim().split(`
|
|
36
36
|
`).map(r=>Jue(r)).join(`
|
|
37
|
-
`)}function Jue(t){return String(t).trimEnd().replace(/ $/,"")}function ede(t){let r=(window.__ROOT_CTX.rootConfig.i18n||{}).locales||["en"];for(let o of r)if(String(o).toLowerCase()===t.toLowerCase())return o;return null}async function fz(t){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,[o,n]=t.split("/"),a=we(r,"Projects",e,"Collections",o,"Drafts",n),i=we(r,"Projects",e,"Collections",o,"Published",n),s=we(r,"Projects",e,"Collections",o,"Scheduled",n),l=sn(r);l.delete(a),l.delete(i),l.delete(s),await l.commit(),console.log(`deleted doc: ${t}`),Je("doc.delete",{metadata:{docId:t}})}async function pz(t){await CS([t])}async function CS(t,e){if(t.length===0){console.log("no docs to publish");return}let r=window.firebase.db;if(t.length>100)throw new Error("publish docs exceeds limit of 100 docs. break up your request into multiple calls.");let o=await TS(t),n=e?.batch||sn(r);t.forEach(a=>{let i=o[a];if(!i)throw new Error(`doc does not exist: ${a}`);tde(n,a,i)}),await n.commit(),t.length===1?console.log(`published ${t[0]}`):console.log(`published ${t.length} docs: ${t.join(", ")}`);for(let a of t)Je("doc.publish",{metadata:{docId:a}});cz(t)}function tde(t,e,r){if(hl(r))throw new Error(`publishing is locked for doc: ${r.id}`);let o=window.__ROOT_CTX.rootConfig.projectId,n=window.firebase.db,[a,i]=e.split("/"),s=we(n,"Projects",o,"Collections",a,"Drafts",i),l=we(n,"Projects",o,"Collections",a,"Scheduled",i),c=we(n,"Projects",o,"Collections",a,"Published",i),u={...r},d=u.sys??{};d.modifiedAt=Ut(),d.modifiedBy=window.firebase.user.email,d.publishedAt=Ut(),d.publishedBy=window.firebase.user.email,d.firstPublishedAt??=Ut(),d.firstPublishedBy??=window.firebase.user.email,delete d.scheduledAt,delete d.scheduledBy,t.update(s,{sys:d}),t.set(c,{...u,sys:d}),t.delete(l)}async function mz(t,e){let r=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,[n,a]=t.split("/"),i=we(o,"Projects",r,"Collections",n,"Drafts",a),s=we(o,"Projects",r,"Collections",n,"Scheduled",a);await Pp(o,async l=>{let c=await l.get(i);if(!c.exists())throw new Error(`${i.id} does not exist`);let u={...c.data()},d=u.sys??{};d.modifiedAt=Ut(),d.modifiedBy=window.firebase.user.email,d.scheduledAt=Ze.fromMillis(e),d.scheduledBy=window.firebase.user.email,l.update(i,{sys:d}),l.set(s,{...u,sys:d})}),console.log(`saved ${s.id}`),Je("doc.schedule",{metadata:{docId:t,scheduledAt:e}})}async function hz(t){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,[o,n]=t.split("/"),a=we(r,"Projects",e,"Collections",o,"Drafts",n),i=we(r,"Projects",e,"Collections",o,"Scheduled",n),s=we(r,"Projects",e,"Collections",o,"Published",n),l=sn(r);l.update(a,{"sys.modifiedAt":Ut(),"sys.modifiedBy":window.firebase.user.email,"sys.publishedAt":zr(),"sys.publishedBy":zr(),"sys.firstPublishedAt":zr(),"sys.firstPublishedBy":zr()}),l.delete(i),l.delete(s),await l.commit(),console.log(`unpublished ${t}`),Je("doc.unpublish",{metadata:{docId:t}}),ES(t)}async function gz(t){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,[o,n]=t.split("/"),a=we(r,"Projects",e,"Collections",o,"Drafts",n),i=we(r,"Projects",e,"Collections",o,"Published",n);await Pp(r,async s=>{let l=await s.get(i);if(!l.exists())throw new Error(`${i.id} does not exist`);let c=l.data();s.set(a,c)}),console.log(`reverted draft ${t}`),Je("doc.revert",{metadata:{docId:t}})}async function _z(t){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,[o,n]=t.split("/"),a=we(r,"Projects",e,"Collections",o,"Drafts",n),i=we(r,"Projects",e,"Collections",o,"Scheduled",n),s=sn(r);s.update(a,{"sys.modifiedAt":Ut(),"sys.modifiedBy":window.firebase.user.email,"sys.scheduledAt":zr(),"sys.scheduledBy":zr()}),s.delete(i),await s.commit(),console.log(`unscheduled ${t}`),Je("doc.unschedule",{metadata:{docId:t}})}async function xz(t,e){let r={lockedAt:Ut(),lockedBy:window.firebase.user.email,reason:e.reason||`Locked by ${window.firebase.user.email}.`};e.until&&(r.until=Ze.fromMillis(e.until));let o=Nn(t);await rr(o,{"sys.publishingLocked":r});let a={docId:t,reason:e.reason};e.until&&(a.until=e.until),Je("doc.lock_publishing",{metadata:a})}async function bz(t){let e=Nn(t),r={"sys.publishingLocked":zr()};await rr(e,r),Je("doc.unlock_publishing",{metadata:{docId:t}})}function fb(t){let e=Ze.now().toMillis();return(t?.sys?.scheduledAt?.toMillis()||0)>e}function hl(t){if(t?.sys?.publishingLocked){if(t.sys.publishingLocked.until){let e=Ze.now().toMillis(),r=t.sys.publishingLocked.until.toMillis();return e<r}return!0}return!1}async function yz(t,e,r){let o=Nn(t),n=await vr(o);if(!n.exists())throw new Error(`doc ${t} does not exist`);let a=n.data().fields??{};await kS(e,{fields:a,overwrite:r?.overwrite})}async function kS(t,e){let[r,o]=t.split("/"),n=Nn(t),a=await vr(n);if(a.exists()&&!e?.overwrite)throw new Error(`${t} already exists`);let i={id:t,collection:r,slug:o,sys:{createdAt:Ut(),createdBy:window.firebase.user.email,modifiedAt:Ut(),modifiedBy:window.firebase.user.email,locales:["en"]},fields:e?.fields??{}};if(a.exists()&&e?.overwrite){let s=a.data();i.sys={...s.sys,modifiedAt:Ut(),modifiedBy:window.firebase.user.email}}await vu(n,i),Je("doc.create",{metadata:{docId:t}})}async function gl(t,e,r){let n=(window.__ROOT_CTX.rootConfig.i18n||{}).locales||["en"];function a(m){for(let h of n)if(String(h).toLowerCase()===m.toLowerCase())return h;return null}let i={};for(let m of e){if(!m.source)continue;let h={source:ei(m.source)};Object.entries(m).forEach(([_,x])=>{if(_==="source")return;let b=a(_);b&&(h[b]=ei(x||""))});let g=await ub(h.source);i[g]=h}let l=[t.split("/")[0],t];r?.tags&&l.push(...r.tags);let c=SS(),u=window.firebase.db,d=sn(u),p=0;for(let m in i){let h=i[m],g=we(c,m);d.set(g,{...h,tags:A9(...l)},{merge:!0}),p+=1,p>=500&&(await d.commit(),d=sn(u),console.log(`saved ${p} strings`),p=0)}return p>0&&(await d.commit(),console.log(`saved ${p} strings`)),Je("doc.import_translations",{metadata:{docId:t}}),i}function Nn(t){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,[o,n]=t.split("/");return we(r,"Projects",e,"Collections",o,"Drafts",n)}function rde(t){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,[o,n]=t.split("/");return we(r,"Projects",e,"Collections",o,"Published",n)}function ode(t,e){let r=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,[n,a]=t.split("/");return we(o,"Projects",r,"Collections",n,"Drafts",a,"Versions",e)}async function TS(t){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,o={};t.forEach(a=>{let[i,s]=a.split("/");i in o?o[i].push(s):o[i]=[s]});let n={};return await Promise.all(Object.entries(o).map(async([a,i])=>{let s=nn(r,"Projects",e,"Collections",a,"Drafts"),l=to(s,eb(Zx(),"in",i));(await an(l)).forEach(u=>{let d=`${a}/${u.id}`;n[d]=u.data()})})),n}async function vz(t){let e=window.firebase.db,r=Nn(t),o=nn(e,r.path,"Versions"),n=to(o,Qn("sys.modifiedAt","desc")),a=await an(n),i=[];return a.forEach(s=>{let l={...s.data(),_versionId:s.id};i.push(l)}),i}async function Iz(t,e){let r=Nn(t),o={"sys.modifiedAt":Ut(),"sys.modifiedBy":window.firebase.user.email,fields:e.fields||{}};await rr(r,o),Je("doc.restore_version",{metadata:{docId:t,versionModifiedAt:e.sys?.modifiedAt,versionModifiedBy:e.sys?.modifiedBy}})}async function PS(t,e){let r;e==="draft"?r=Nn(t):e==="published"?r=rde(t):r=ode(t,e);let o=await vr(r);return o.exists()?o.data():null}async function pb(t,e){if(!e?.spreadsheetId)throw new Error("no spreadsheet id");let r=Nn(t),o={"sys.l10nSheet":{spreadsheetId:e.spreadsheetId,gid:e.gid||0,linkedAt:Ut(),linkedBy:window.firebase.user.email}};await rr(r,o),Je("doc.link_sheet",{metadata:{docId:t,sheetId:e}})}async function wz(t){let e=Nn(t),r={"sys.l10nSheet":zr()};await rr(e,r),Je("doc.unlink_sheet",{metadata:{docId:t}})}async function mb(t){let e=Nn(t),n=(await vr(e)).data()?.sys?.l10nSheet||{};return n?.spreadsheetId?{spreadsheetId:n.spreadsheetId,gid:n.gid||0}:null}function db(t,e){let r={};for(let o in t){let n=t[o];if(nde(n))if(n.toMillis)r[o]=n.toMillis();else if(Object.hasOwn(n,"_array")&&Array.isArray(n._array)){let a=n._array.map(i=>{let s={...db(n[i]||{},e),_arrayKey:i};return e?.removeArrayKey&&delete s._arrayKey,s});r[o]=a}else r[o]=db(n,e);else r[o]=n}return r}function nde(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function ke(...t){return t.filter(e=>!!e).join(" ")||void 0}var ade=0,xVe=Array.isArray;function f(t,e,r,o,n,a){var i,s,l={};for(s in e)s=="ref"?i=e[s]:l[s]=e[s];var c={type:t,props:l,key:r,ref:i,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--ade,__i:-1,__u:0,__source:n,__self:a};if(typeof t=="function"&&(i=t.defaultProps))for(s in i)l[s]===void 0&&(l[s]=i[s]);return he.vnode&&he.vnode(c),c}function Me(t){let{className:e,as:r,size:o,weight:n,color:a,children:i,...s}=t;return f(r||"div",{...s,className:ke(e,"text",o&&`size:${o}`,n&&`weight:${n}`,a&&`color:${a}`),children:i})}function Jn(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=OS(t);return`${o}${n}`}function OS(t){let e=window.__ROOT_CTX.collections,{collectionId:r,slug:o,locale:n}=t,a=e[r];if(!a)throw new Error(`collection not found: ${r}`);let i=window.__ROOT_CTX.rootConfig,s=i.base||"/",l="/[base]/[path]";n&&(l=i.i18n.urlFormat||"/[locale]/[base]/[path]");let c="",u=a?.url;if(u)if(o){let d=u.replace(/\[.*slug\]/,o).replaceAll("--","/").replace(/\/+/g,"/");d==="/index"&&(d="/"),c=d}else c=u;return Ez(l,{base:s,path:c,locale:n||"",slug:o})}function AS(t){let e=window.__ROOT_CTX.collections,{collectionId:r,slug:o,locale:n}=t,a=e[r];if(!a)throw new Error(`collection not found: ${r}`);let i=window.__ROOT_CTX.rootConfig,s=i.base||"/",l="/[base]/[path]";n&&(l=i.i18n.urlFormat||"/[locale]/[base]/[path]");let c="",u=a?.previewUrl||a?.url;if(u)if(o){let d=u.replace(/\[.*slug\]/,o).replaceAll("--","/").replace(/\/+/g,"/");d==="/index"&&(d="/"),c=d}else c=u;return Ez(l,{base:s,path:c,locale:n||"",slug:o})}function Ez(t,e){let r=t.replaceAll(/\[\[?(\.\.\.)?([\w\-_]*)\]?\]/g,(o,n,a)=>e[a]??o);return ide(r,{trailingSlash:window.__ROOT_CTX.rootConfig.server.trailingSlash})}function ide(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 hb(t){let[e,r]=P(t.collectionId||""),o=H(null),[n,a]=P(""),i=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(i?.url){if(n){let d=$i(n),p=i?.slugRegex;Ca(d,p)?l=Jn({collectionId:e,slug:d}):l="INVALID SLUG"}else l=Jn({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){a(d),t.onChange&&t.onChange({collectionId:e,slug:d})}return f("div",{className:ke(t.className,"SlugInput"),children:[f("div",{className:"SlugInput__inputs",children:[f(Pt,{className:"SlugInput__collection",placeholder:"Collection",size:"xs",data:s,onChange:d=>c(d),value:e,disabled:!!t.collectionDisabled}),f("div",{className:"SlugInput__divider",children:"/"}),f(gt,{className:"SlugInput__slug",name:"slug",ref:o,value:n,onChange:d=>{u(d.currentTarget.value)},placeholder:"slug",autoComplete:"off",size:"xs"})]}),l&&f(Me,{className:"SlugInput__urlHelp",size:"body-sm",children:l})]})}var Sz="CopyDocModal";function Cz(t){let e=Ye(),r=xt();return{open:()=>{e.openContextModal(Sz,{...r,innerProps:t})}}}function gb(t){let{innerProps:e,context:r,id:o}=t,[n,a]=P(""),[i,s]=P(""),[l,c]=P(""),[u,d]=P(!1),[p,m]=P(!1),h=e.fromDocId,g=h.split("/")[0];async function _(x){if(x.preventDefault(),m(!0),c(""),!g){c("Please select a collection."),m(!1);return}let b=$i(i),y=window.__ROOT_CTX.collections[n]?.slugRegex;if(!Ca(b,y)){c('Please enter a valid slug (e.g. "foo-bar-123").'),m(!1);return}let I=`${n}/${b}`;try{await yz(h,I,{overwrite:u}),r.closeModal(o),pe({title:"Copied!",message:`Succesfully copied ${h} to ${I}.`,autoClose:5e3})}catch(w){let v=String(w);c(v),v.includes("already exists")&&d(!0),m(!1);return}m(!1),ur(`/cms/content/${n}/${b}`)}return f("div",{className:"CopyDocModal",children:f("form",{onSubmit:x=>_(x),children:[f("div",{className:"CopyDocModal__from",children:[f(Me,{className:"CopyDocModal__from__label",size:"body",weight:"bold",children:"From:"}),f(Me,{className:"CopyDocModal__from__value",size:"body-sm",children:f("code",{children:e.fromDocId})})]}),f("div",{className:"CopyDocModal__to",children:[f(Me,{className:"CopyDocModal__to__label",size:"body",weight:"bold",children:"To:"}),f(hb,{className:"CopyDocModal__slug",collectionId:g,onChange:x=>{a(x.collectionId),s(x.slug)}})]}),l&&f("div",{className:"CopyDocModal__error",children:l}),f("div",{className:"CopyDocModal__buttons",children:[f(X,{variant:"outline",onClick:()=>r.closeModal(o),type:"button",size:"xs",color:"dark",children:"Cancel"}),f(X,{variant:"filled",type:"submit",size:"xs",color:"dark",loading:p,children:u?"Overwrite?":"Submit"})]})]})})}gb.id=Sz;async function bt(t){try{await t()}catch(e){console.error(e);let r;typeof e=="object"&&e.body?r=String(e.body):r=String(e),pe({title:"Error",message:r,color:"red",autoClose:!1})}}var DS=Rt(null);function kz(){let t=Mt(DS);if(!t)throw new Error("useFirebase() should be called within a <FirebaseProvider>");return t}function Su(t,e){let[r,o]=P([]),[n,a]=P(!0),s=kz().db,l=window.__ROOT_CTX.rootConfig.projectId||"default",c=async()=>{a(!0);let u=nn(s,"Projects",l,"Collections",t,"Drafts"),d=u,p=e.orderBy;p==="modifiedAt"?d=to(u,Qn("sys.modifiedAt","desc")):p==="newest"?d=to(u,Qn("sys.createdAt","desc")):p==="oldest"?d=to(u,Qn("sys.createdAt")):p==="slug"&&(d=to(u,Qn(Zx()))),await bt(async()=>{let m=await an(d),h=[];m.docs.forEach(g=>{let _=g.data(),x=g.id,b=`${t}/${x}`,y={..._,id:b,slug:x};h.push(y),Lp(b,y)}),o(h)}),a(!1)};return L(()=>{a(!0),c()},[t,e.orderBy]),[n,c,r]}function Bp(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function oo(t,e){let r=e.split("."),o=t;for(let n of r)o||(o={}),o=o[n];return o}function RS(t){let e={};for(let r in t)if(Bp(t[r])){let o=t[r],n=RS(o);for(let a in n)e[`${r}.${a}`]=n[a]}else e[r]=t[r];return e}function Tz(t,e){return t.sort((r,o)=>{let n=r[e],a=o[e];return n<a?-1:n>a?1:0})}function _b(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(!_b(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(!_b(t[n],e[n]))return!1;return!0}var NS="DocPickerModal";function Pz(){let t=Ye(),e=xt();return{open:r=>{t.openContextModal(NS,{...e,innerProps:r,size:"700px",overflow:"inside"})},close:()=>{t.closeModal(NS)}}}function qi(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,a]=P(e.initialCollection||(r.length===1?r[0]:""));function i(s){e.onChange&&e.onChange(s.id)}return f("div",{className:"DocPickerModal",children:[r.length===0&&f("div",{className:"DocPickerModal__noCollections",children:"No collections matching schema field definition."}),r.length>1&&f("div",{className:"DocPickerModal__collection__select",children:[f("div",{className:"DocPickerModal__collection__select__label",children:"Content Type:"}),f(Pt,{data:o,value:n,placeholder:"Select",onChange:s=>{a(s||"")},size:"xs",radius:0,dropdownComponent:"div"})]}),n&&f(qi.DocsList,{collection:n,onDocSelected:i})]})}qi.DocsList=t=>{let[e,,r]=Su(t.collection,{orderBy:"slug"});return f("div",{className:"DocPickerModal__DocsList",children:e?f("div",{className:"DocPickerModal__DocsList__loading",children:f(Re,{color:"gray",size:"xl"})}):r.length===0?f("div",{className:"DocPickerModal__DocsList__empty",children:"Collection is empty."}):f("div",{className:"DocPickerModal__DocsList__docs",children:r.map(o=>f(qi.DocCard,{doc:o,onDocSelected:t.onDocSelected},o.id))})})};qi.DocCard=t=>{let e=t.doc,[r,o]=e.id.split("/"),n=e.fields||{},a=window.__ROOT_CTX.collections[r],i=Jn({collectionId:r,slug:o}),s=oo(n,a.preview?.title||"meta.title"),l=oo(n,a.preview?.image||"meta.image")||a.preview?.defaultImage;return f("div",{className:"DocPickerModal__DocCard",children:[f("div",{className:"DocPickerModal__DocCard__image",children:f(Tn,{src:l?.src,width:120,height:90,withPlaceholder:!l?.src})}),f("div",{className:"DocPickerModal__DocCard__content",children:[f("div",{className:"DocPickerModal__DocCard__content__header",children:f("div",{className:"DocPickerModal__DocCard__content__header__docId",children:e.id})}),f("div",{className:"DocPickerModal__DocCard__content__title",children:s||"[UNTITLED]"}),f("div",{className:"DocPickerModal__DocCard__content__url",children:i})]}),f("div",{className:"DocPickerModal__DocCard__controls",children:f(X,{color:"blue",size:"xs",onClick:()=>t.onDocSelected(t.doc),children:"Select"})})]})};qi.id=NS;var MS="DocSelectModal";function Oz(){let t=Ye(),e=xt();return{open:r=>{t.openContextModal(MS,{...e,innerProps:r,size:"700px",overflow:"inside"})},close:()=>{t.closeModal(MS)}}}function Gi(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,a]=P(e.initialCollection||(r.length===1?r[0]:""));function i(l){e.onChange&&e.onChange(l.id,!0)}function s(l){e.onChange&&e.onChange(l.id,!1)}return console.log("selected docs:",e.selectedDocIds),f("div",{className:"DocSelectModal",children:[r.length===0&&f("div",{className:"DocSelectModal__noCollections",children:"No collections matching schema field definition."}),r.length>1&&f("div",{className:"DocSelectModal__collection__select",children:[f("div",{className:"DocSelectModal__collection__select__label",children:"Content Type:"}),f(Pt,{data:o,value:n,placeholder:"Select",onChange:l=>{a(l||"")},size:"xs",radius:0,dropdownComponent:"div"})]}),n&&f(Gi.DocsList,{collection:n,onDocSelected:i,onDocUnselected:s,selectedDocIds:e.selectedDocIds})]})}Gi.DocsList=t=>{let[e,,r]=Su(t.collection,{orderBy:"slug"}),o=t.selectedDocIds||[];return f("div",{className:"DocSelectModal__DocsList",children:e?f("div",{className:"DocSelectModal__DocsList__loading",children:f(Re,{color:"gray",size:"xl"})}):r.length===0?f("div",{className:"DocSelectModal__DocsList__empty",children:"Collection is empty."}):f("div",{className:"DocSelectModal__DocsList__docs",children:r.map(n=>f(Gi.DocCard,{doc:n,onDocSelected:t.onDocSelected,onDocUnselected:t.onDocUnselected,selected:o.includes(n.id)},n.id))})})};Gi.DocCard=t=>{let[e,r]=P(!!t.selected),o=t.doc,[n,a]=o.id.split("/"),i=o.fields||{},s=window.__ROOT_CTX.collections[n],l=Jn({collectionId:n,slug:a}),c=oo(i,s.preview?.title||"meta.title"),u=oo(i,s.preview?.image||"meta.image")||s.preview?.defaultImage;return f("div",{className:"DocSelectModal__DocCard",children:[f("div",{className:"DocSelectModal__DocCard__image",children:f(Tn,{src:u?.src,width:120,height:90,withPlaceholder:!u?.src})}),f("div",{className:"DocSelectModal__DocCard__content",children:[f("div",{className:"DocSelectModal__DocCard__content__header",children:f("div",{className:"DocSelectModal__DocCard__content__header__docId",children:o.id})}),f("div",{className:"DocSelectModal__DocCard__content__title",children:c||"[UNTITLED]"}),f("div",{className:"DocSelectModal__DocCard__content__url",children:l})]}),f("div",{className:"DocSelectModal__DocCard__controls",children:e?f(X,{variant:"light",color:"blue",size:"xs",onClick:()=>{r(!1),t.onDocUnselected(t.doc)},children:"Unselect"}):f(X,{variant:"filled",color:"blue",size:"xs",onClick:()=>{r(!0),t.onDocSelected(t.doc)},children:"Select"})})]})};Gi.id=MS;var Az={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};var sde=Object.defineProperty,lde=Object.defineProperties,cde=Object.getOwnPropertyDescriptors,xb=Object.getOwnPropertySymbols,Nz=Object.prototype.hasOwnProperty,Mz=Object.prototype.propertyIsEnumerable,Dz=(t,e,r)=>e in t?sde(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Rz=(t,e)=>{for(var r in e||(e={}))Nz.call(e,r)&&Dz(t,r,e[r]);if(xb)for(var r of xb(e))Mz.call(e,r)&&Dz(t,r,e[r]);return t},ude=(t,e)=>lde(t,cde(e)),dde=(t,e)=>{var r={};for(var o in t)Nz.call(t,o)&&e.indexOf(o)<0&&(r[o]=t[o]);if(t!=null&&xb)for(var o of xb(t))e.indexOf(o)<0&&Mz.call(t,o)&&(r[o]=t[o]);return r},Y=(t,e,r)=>{let o=n=>{var a=n,{color:i="currentColor",size:s=24,stroke:l=2,children:c}=a,u=dde(a,["color","size","stroke","children"]);return Q("svg",Rz(ude(Rz({},Az),{width:s,height:s,stroke:i,"stroke-width":l,class:`tabler-icon tabler-icon-${t}`}),u),[...r.map(([d,p])=>Q(d,p)),...yo(c)])};return o.displayName=`${e}`,o};var LS=Y("alarm-off","IconAlarmOff",[["path",{d:"M7.587 7.566a7 7 0 1 0 9.833 9.864m1.35 -2.645a7 7 0 0 0 -8.536 -8.56",key:"svg-0"}],["path",{d:"M12 12v1h1",key:"svg-1"}],["path",{d:"M5.261 5.265l-1.011 .735",key:"svg-2"}],["path",{d:"M17 4l2.75 2",key:"svg-3"}],["path",{d:"M3 3l18 18",key:"svg-4"}]]);var BS=Y("arrow-back","IconArrowBack",[["path",{d:"M9 11l-4 4l4 4m-4 -4h11a4 4 0 0 0 0 -8h-1",key:"svg-0"}]]);var FS=Y("arrow-left","IconArrowLeft",[["path",{d:"M5 12l14 0",key:"svg-0"}],["path",{d:"M5 12l6 6",key:"svg-1"}],["path",{d:"M5 12l6 -6",key:"svg-2"}]]);var zS=Y("arrow-roundabout-right","IconArrowRoundaboutRight",[["path",{d:"M21 9h-8a5 5 0 1 0 -5 5v7",key:"svg-0"}],["path",{d:"M17 5l4 4l-4 4",key:"svg-1"}]]);var _l=Y("arrow-up-right","IconArrowUpRight",[["path",{d:"M17 7l-10 10",key:"svg-0"}],["path",{d:"M8 7l9 0l0 9",key:"svg-1"}]]);var Fp=Y("braces","IconBraces",[["path",{d:"M7 4a2 2 0 0 0 -2 2v3a2 3 0 0 1 -2 3a2 3 0 0 1 2 3v3a2 2 0 0 0 2 2",key:"svg-0"}],["path",{d:"M17 4a2 2 0 0 1 2 2v3a2 3 0 0 0 2 3a2 3 0 0 0 -2 3v3a2 2 0 0 1 -2 2",key:"svg-1"}]]);var US=Y("carrot","IconCarrot",[["path",{d:"M3 21s9.834 -3.489 12.684 -6.34a4.487 4.487 0 0 0 0 -6.344a4.483 4.483 0 0 0 -6.342 0c-2.86 2.861 -6.347 12.689 -6.347 12.689z",key:"svg-0"}],["path",{d:"M9 13l-1.5 -1.5",key:"svg-1"}],["path",{d:"M16 14l-2 -2",key:"svg-2"}],["path",{d:"M22 8s-1.14 -2 -3 -2c-1.406 0 -3 2 -3 2s1.14 2 3 2s3 -2 3 -2z",key:"svg-3"}],["path",{d:"M16 2s-2 1.14 -2 3s2 3 2 3s2 -1.577 2 -3c0 -1.86 -2 -3 -2 -3z",key:"svg-4"}]]);var Cu=Y("chevron-down","IconChevronDown",[["path",{d:"M6 9l6 6l6 -6",key:"svg-0"}]]);var VS=Y("circle-arrow-down","IconCircleArrowDown",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M8 12l4 4",key:"svg-1"}],["path",{d:"M12 8v8",key:"svg-2"}],["path",{d:"M16 12l-4 4",key:"svg-3"}]]);var HS=Y("circle-arrow-up","IconCircleArrowUp",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M12 8l-4 4",key:"svg-1"}],["path",{d:"M12 8v8",key:"svg-2"}],["path",{d:"M16 12l-4 -4",key:"svg-3"}]]);var ku=Y("circle-plus","IconCirclePlus",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M9 12h6",key:"svg-1"}],["path",{d:"M12 9v6",key:"svg-2"}]]);var $S=Y("clipboard-check","IconClipboardCheck",[["path",{d:"M9 5h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2h-2",key:"svg-0"}],["path",{d:"M9 3m0 2a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v0a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2z",key:"svg-1"}],["path",{d:"M9 14l2 2l4 -4",key:"svg-2"}]]);var jS=Y("clipboard-copy","IconClipboardCopy",[["path",{d:"M9 5h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h3m9 -9v-5a2 2 0 0 0 -2 -2h-2",key:"svg-0"}],["path",{d:"M13 17v-1a1 1 0 0 1 1 -1h1m3 0h1a1 1 0 0 1 1 1v1m0 3v1a1 1 0 0 1 -1 1h-1m-3 0h-1a1 1 0 0 1 -1 -1v-1",key:"svg-1"}],["path",{d:"M9 3m0 2a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v0a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2z",key:"svg-2"}]]);var zp=Y("clipboard","IconClipboard",[["path",{d:"M9 5h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2h-2",key:"svg-0"}],["path",{d:"M9 3m0 2a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v0a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2z",key:"svg-1"}]]);var qS=Y("cloud-off","IconCloudOff",[["path",{d:"M9.58 5.548c.24 -.11 .492 -.207 .752 -.286c1.88 -.572 3.956 -.193 5.444 1c1.488 1.19 2.162 3.007 1.77 4.769h.99c1.913 0 3.464 1.56 3.464 3.486c0 .957 -.383 1.824 -1.003 2.454m-2.997 1.033h-11.343c-2.572 -.004 -4.657 -2.011 -4.657 -4.487c0 -2.475 2.085 -4.482 4.657 -4.482c.13 -.582 .37 -1.128 .7 -1.62",key:"svg-0"}],["path",{d:"M3 3l18 18",key:"svg-1"}]]);var Up=Y("copy","IconCopy",[["path",{d:"M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z",key:"svg-0"}],["path",{d:"M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1",key:"svg-1"}]]);var GS=Y("database","IconDatabase",[["path",{d:"M12 6m-8 0a8 3 0 1 0 16 0a8 3 0 1 0 -16 0",key:"svg-0"}],["path",{d:"M4 6v6a8 3 0 0 0 16 0v-6",key:"svg-1"}],["path",{d:"M4 12v6a8 3 0 0 0 16 0v-6",key:"svg-2"}]]);var WS=Y("device-desktop","IconDeviceDesktop",[["path",{d:"M3 5a1 1 0 0 1 1 -1h16a1 1 0 0 1 1 1v10a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1v-10z",key:"svg-0"}],["path",{d:"M7 20h10",key:"svg-1"}],["path",{d:"M9 16v4",key:"svg-2"}],["path",{d:"M15 16v4",key:"svg-3"}]]);var Vp=Y("device-floppy","IconDeviceFloppy",[["path",{d:"M6 4h10l4 4v10a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2",key:"svg-0"}],["path",{d:"M12 14m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-1"}],["path",{d:"M14 4l0 4l-6 0l0 -4",key:"svg-2"}]]);var KS=Y("device-ipad","IconDeviceIpad",[["path",{d:"M18 2a3 3 0 0 1 2.995 2.824l.005 .176v14a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-14a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm-3 15h-6l-.117 .007a1 1 0 0 0 0 1.986l.117 .007h6l.117 -.007a1 1 0 0 0 0 -1.986l-.117 -.007z",key:"svg-0"}]]);var XS=Y("device-mobile","IconDeviceMobile",[["path",{d:"M6 5a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2v-14z",key:"svg-0"}],["path",{d:"M11 4h2",key:"svg-1"}],["path",{d:"M12 17v.01",key:"svg-2"}]]);var xl=Y("dots-vertical","IconDotsVertical",[["path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M12 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}]]);var bl=Y("file-download","IconFileDownload",[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z",key:"svg-1"}],["path",{d:"M12 17v-6",key:"svg-2"}],["path",{d:"M9.5 14.5l2.5 2.5l2.5 -2.5",key:"svg-3"}]]);var ti=Y("file-upload","IconFileUpload",[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z",key:"svg-1"}],["path",{d:"M12 11v6",key:"svg-2"}],["path",{d:"M9.5 13.5l2.5 -2.5l2.5 2.5",key:"svg-3"}]]);var yl=Y("folder","IconFolder",[["path",{d:"M5 4h4l3 3h7a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2",key:"svg-0"}]]);var Hp=Y("history","IconHistory",[["path",{d:"M12 8l0 4l2 2",key:"svg-0"}],["path",{d:"M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5",key:"svg-1"}]]);var YS=Y("home","IconHome",[["path",{d:"M5 12l-2 0l9 -9l9 9l-2 0",key:"svg-0"}],["path",{d:"M5 12v7a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-7",key:"svg-1"}],["path",{d:"M9 21v-6a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v6",key:"svg-2"}]]);var Wi=Y("language","IconLanguage",[["path",{d:"M4 5h7",key:"svg-0"}],["path",{d:"M9 3v2c0 4.418 -2.239 8 -5 8",key:"svg-1"}],["path",{d:"M5 9c0 2.144 2.952 3.908 6.7 4",key:"svg-2"}],["path",{d:"M12 20l4 -9l4 9",key:"svg-3"}],["path",{d:"M19.1 18h-6.2",key:"svg-4"}]]);var $p=Y("lock-open","IconLockOpen",[["path",{d:"M5 11m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v6a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z",key:"svg-0"}],["path",{d:"M12 16m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M8 11v-5a4 4 0 0 1 8 0",key:"svg-2"}]]);var vl=Y("lock","IconLock",[["path",{d:"M5 13a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v6a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-6z",key:"svg-0"}],["path",{d:"M11 16a1 1 0 1 0 2 0a1 1 0 0 0 -2 0",key:"svg-1"}],["path",{d:"M8 11v-4a4 4 0 1 1 8 0v4",key:"svg-2"}]]);var QS=Y("map-pin","IconMapPin",[["path",{d:"M9 11a3 3 0 1 0 6 0a3 3 0 0 0 -6 0",key:"svg-0"}],["path",{d:"M17.657 16.657l-4.243 4.243a2 2 0 0 1 -2.827 0l-4.244 -4.243a8 8 0 1 1 11.314 0z",key:"svg-1"}]]);var jp=Y("mood-look-down","IconMoodLookDown",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M9 13h.01",key:"svg-1"}],["path",{d:"M15 13h.01",key:"svg-2"}],["path",{d:"M11 17h2",key:"svg-3"}]]);var ZS=Y("paperclip","IconPaperclip",[["path",{d:"M15 7l-6.5 6.5a1.5 1.5 0 0 0 3 3l6.5 -6.5a3 3 0 0 0 -6 -6l-6.5 6.5a4.5 4.5 0 0 0 9 9l6.5 -6.5",key:"svg-0"}]]);var JS=Y("photo-up","IconPhotoUp",[["path",{d:"M15 8h.01",key:"svg-0"}],["path",{d:"M12.5 21h-6.5a3 3 0 0 1 -3 -3v-12a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v6.5",key:"svg-1"}],["path",{d:"M3 16l5 -5c.928 -.893 2.072 -.893 3 0l3.5 3.5",key:"svg-2"}],["path",{d:"M14 14l1 -1c.679 -.653 1.473 -.829 2.214 -.526",key:"svg-3"}],["path",{d:"M19 22v-6",key:"svg-4"}],["path",{d:"M22 19l-3 -3l-3 3",key:"svg-5"}]]);var eC=Y("photo","IconPhoto",[["path",{d:"M15 8h.01",key:"svg-0"}],["path",{d:"M3 6a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3v-12z",key:"svg-1"}],["path",{d:"M3 16l5 -5c.928 -.893 2.072 -.893 3 0l5 5",key:"svg-2"}],["path",{d:"M14 14l1 -1c.928 -.893 2.072 -.893 3 0l3 3",key:"svg-3"}]]);var tC=Y("planet","IconPlanet",[["path",{d:"M18.816 13.58c2.292 2.138 3.546 4 3.092 4.9c-.745 1.46 -5.783 -.259 -11.255 -3.838c-5.47 -3.579 -9.304 -7.664 -8.56 -9.123c.464 -.91 2.926 -.444 5.803 .805",key:"svg-0"}],["path",{d:"M12 12m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0",key:"svg-1"}]]);var rC=Y("reload","IconReload",[["path",{d:"M19.933 13.041a8 8 0 1 1 -9.925 -8.788c3.899 -1 7.935 1.007 9.425 4.747",key:"svg-0"}],["path",{d:"M20 4v5h-5",key:"svg-1"}]]);var Il=Y("robot","IconRobot",[["path",{d:"M6 4m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v4a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z",key:"svg-0"}],["path",{d:"M12 2v2",key:"svg-1"}],["path",{d:"M9 12v9",key:"svg-2"}],["path",{d:"M15 12v9",key:"svg-3"}],["path",{d:"M5 16l4 -2",key:"svg-4"}],["path",{d:"M15 14l4 2",key:"svg-5"}],["path",{d:"M9 18h6",key:"svg-6"}],["path",{d:"M10 8v.01",key:"svg-7"}],["path",{d:"M14 8v.01",key:"svg-8"}]]);var Tu=Y("rocket","IconRocket",[["path",{d:"M4 13a8 8 0 0 1 7 7a6 6 0 0 0 3 -5a9 9 0 0 0 6 -8a3 3 0 0 0 -3 -3a9 9 0 0 0 -8 6a6 6 0 0 0 -5 3",key:"svg-0"}],["path",{d:"M7 14a6 6 0 0 0 -3 6a6 6 0 0 0 6 -3",key:"svg-1"}],["path",{d:"M15 9m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}]]);var bb=Y("row-insert-bottom","IconRowInsertBottom",[["path",{d:"M20 6v4a1 1 0 0 1 -1 1h-14a1 1 0 0 1 -1 -1v-4a1 1 0 0 1 1 -1h14a1 1 0 0 1 1 1z",key:"svg-0"}],["path",{d:"M12 15l0 4",key:"svg-1"}],["path",{d:"M14 17l-4 0",key:"svg-2"}]]);var yb=Y("row-insert-top","IconRowInsertTop",[["path",{d:"M4 18v-4a1 1 0 0 1 1 -1h14a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-14a1 1 0 0 1 -1 -1z",key:"svg-0"}],["path",{d:"M12 9v-4",key:"svg-1"}],["path",{d:"M10 7l4 0",key:"svg-2"}]]);var oC=Y("send-2","IconSend2",[["path",{d:"M4.698 4.034l16.302 7.966l-16.302 7.966a.503 .503 0 0 1 -.546 -.124a.555 .555 0 0 1 -.12 -.568l2.468 -7.274l-2.468 -7.274a.555 .555 0 0 1 .12 -.568a.503 .503 0 0 1 .546 -.124z",key:"svg-0"}],["path",{d:"M6.5 12h14.5",key:"svg-1"}]]);var wl=Y("settings","IconSettings",[["path",{d:"M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065z",key:"svg-0"}],["path",{d:"M9 12a3 3 0 1 0 6 0a3 3 0 0 0 -6 0",key:"svg-1"}]]);var El=Y("table","IconTable",[["path",{d:"M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14z",key:"svg-0"}],["path",{d:"M3 10h18",key:"svg-1"}],["path",{d:"M10 3v18",key:"svg-2"}]]);var qp=Y("trash-filled","IconTrashFilled",[["path",{d:"M20 6a1 1 0 0 1 .117 1.993l-.117 .007h-.081l-.919 11a3 3 0 0 1 -2.824 2.995l-.176 .005h-8c-1.598 0 -2.904 -1.249 -2.992 -2.75l-.005 -.167l-.923 -11.083h-.08a1 1 0 0 1 -.117 -1.993l.117 -.007h16z",fill:"currentColor",key:"svg-0",strokeWidth:"0"}],["path",{d:"M14 2a2 2 0 0 1 2 2a1 1 0 0 1 -1.993 .117l-.007 -.117h-4l-.007 .117a1 1 0 0 1 -1.993 -.117a2 2 0 0 1 1.85 -1.995l.15 -.005h4z",fill:"currentColor",key:"svg-1",strokeWidth:"0"}]]);var cn=Y("trash","IconTrash",[["path",{d:"M4 7l16 0",key:"svg-0"}],["path",{d:"M10 11l0 6",key:"svg-1"}],["path",{d:"M14 11l0 6",key:"svg-2"}],["path",{d:"M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12",key:"svg-3"}],["path",{d:"M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3",key:"svg-4"}]]);var nC=Y("triangle-filled","IconTriangleFilled",[["path",{d:"M12 1.67a2.914 2.914 0 0 0 -2.492 1.403l-8.11 13.537a2.914 2.914 0 0 0 2.484 4.385h16.225a2.914 2.914 0 0 0 2.503 -4.371l-8.116 -13.546a2.917 2.917 0 0 0 -2.494 -1.408z",fill:"currentColor",key:"svg-0",strokeWidth:"0"}]]);var aC=Y("world","IconWorld",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M3.6 9h16.8",key:"svg-1"}],["path",{d:"M3.6 15h16.8",key:"svg-2"}],["path",{d:"M11.5 3a17 17 0 0 0 0 18",key:"svg-3"}],["path",{d:"M12.5 3a17 17 0 0 1 0 18",key:"svg-4"}]]);var iC=Y("x","IconX",[["path",{d:"M18 6l-12 12",key:"svg-0"}],["path",{d:"M6 6l12 12",key:"svg-1"}]]);var sC="EditJsonModal";function vb(){let t=Ye(),e=xt();return{open:r=>{t.openContextModal(sC,{...e,innerProps:r,size:"680px"})},close:()=>{t.closeModal(sC)}}}function Ib(t){let{innerProps:e,context:r,id:o}=t,[n,a]=P(JSON.stringify(e.data||{},null,2)),[i,s]=P(!0),[l,c]=P(!1);function u(m){a(m),c(!1);try{JSON.parse(m),s(!0)}catch{s(!1)}}function d(){navigator.clipboard.writeText(n).then(()=>c(!0))}function p(){let m=JSON.parse(n);e.onSave&&e.onSave(m)}return f("div",{className:"EditJsonModal",children:[f("h3",{children:"EditJsonModal"}),f(Mc,{value:n,onChange:u,formatOnBlur:!0,autosize:!0,minRows:4,maxRows:25}),f("div",{className:"EditJsonModal__buttons",children:[f(X,{variant:"default",size:"xs",color:"dark",type:"button",onClick:()=>r.closeModal(o),children:"Cancel"}),f(X,{leftIcon:f(zp,{size:16}),variant:"filled",size:"xs",color:"dark",disabled:!i,type:"button",onClick:d,children:l?"Copied!":"Copy"}),f(X,{leftIcon:f(Vp,{size:16}),variant:"filled",size:"xs",color:"blue",disabled:!i,onClick:p,children:"Save"})]})]})}Ib.id=sC;async function Lz(){let t=window.firebase.db,e=window.__ROOT_CTX.rootConfig.projectId||"default",r=we(t,"Projects",e),o=await vr(r);if(!o.exists)return[];let a=(o.data()||{}).roles||{},i=[];return Object.entries(a).forEach(([s,l])=>{(l==="ADMIN"||l==="EDITOR")&&i.push(s)}),i}var ka=class t{constructor(e){this.spreadsheetId=e}static async create(e){let r={fields:"spreadsheetId"};e?.title&&(r.resource={properties:{title:e.title}});let n=(await gapi.client.sheets.spreadsheets.create(r)).result,a=new t(n.spreadsheetId);a.setSpreadsheet(n);let i=await Lz();return await a.share(i,"writer"),a}getUrl(){return Mn({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 wb(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,a=o.properties?.title,i=new wb(this,n??0,a);r.push(i)}),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"})}))}},wb=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[a,i]=await this.getValues(),s=[...a],l=[],c=-1,u=new Set;l.push(a.map((y,I)=>(y===o&&(c=I),n.includes(y)&&u.add(I),{hasChanges:!1,value:y})));function d(y){l[0].push({hasChanges:!0,value:y}),s.push(y)}c===-1&&d(o);let p={};i.forEach((y,I)=>{let w=I+1;l.push(y.map((v,T)=>(T===c&&v&&(v in p?console.warn(`multiple rows keyed by "${v}"`):p[v]=w),{hasChanges:!1,value:v})))});function m(y){for(let w in y)s.includes(w)||d(w);return s.map(w=>y[w]??null)}e.forEach(y=>{let I=m(y),w=y[o],v=p[w];if(v){let T=l[v];I.map((O,S)=>{S>=T.length?T.push({hasChanges:!0,value:O||""}):O!==null&&T[S].value!==O&&(!u.has(S)||!T[S].value)&&(T[S]={hasChanges:!0,value:O})})}else l.push(I.map(T=>({hasChanges:!!T,value:T||""})))});let h=s.length,g=l.length,_=a.length,x=i.length+1;(h>_||g>x)&&await this.resizeSheet({numCols:h+2,numRows:g+20});let b=[];l.forEach((y,I)=>{for(;y.length>0&&y.at(-1)?.hasChanges===!1;)y.pop();if(y.length!==0){if(y.every(w=>w.hasChanges)){b.push({range:`${this.title}!A${I+1}`,majorDimension:"ROWS",values:[y.map(w=>w.value||"")]});return}y.forEach((w,v)=>{if(w.hasChanges){let T=Bz(v);b.push({range:`${this.title}!${T}${I+1}`,majorDimension:"ROWS",values:[[w.value||""]]})}})}}),b.length>0&&await gapi.client.sheets.spreadsheets.values.batchUpdate({spreadsheetId:this.spreadsheet.spreadsheetId,resource:{data:b,valueInputOption:"RAW"}})}async replaceSheet(e,r){let o=e.length,n=r.length+1,a=[];a.push(e),a.push(...r.map(s=>e.map(l=>s[l]||""))),await this.resizeSheet({numCols:o+2,numRows:n+20}),console.log("updating cell values");let i=Bz(o-1);await gapi.client.sheets.spreadsheets.values.update({spreadsheetId:this.spreadsheet.spreadsheetId,range:`${this.title}!A1:${i}${n}`,valueInputOption:"RAW",resource:{range:`${this.title}!A1:${i}${n}`,majorDimension:"ROWS",values:a}})}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 a={};return n.forEach((i,s)=>{let l=e[s];l&&(a[l]=String(i||""))}),a})}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 Mn({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 Mn(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 Ki(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+)/),a=0;return n&&n[1]&&(a=parseInt(n[1])),{spreadsheetId:r,gid:a}}function Bz(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 Te(t){let{className:e,as:r,size:o,weight:n,color:a,children:i,...s}=t;return f(r||"h2",{...s,className:ke(e,"heading",o&&`size:${o}`,n&&`weight:${n}`,a&&`color:${a}`),children:i})}var lC="EditTranslationsModal";function Fz(){let t=Ye(),e=xt();return{open:r=>{t.openContextModal(lC,{...e,innerProps:r,size:"900px",title:"Edit translations",overflow:"inside",className:"EditTranslationsModalWrap"})},close:()=>{t.closeModal(lC)}}}function Pu(t){let{innerProps:e,context:r,id:o}=t,n=e.strings||[],i=(window.__ROOT_CTX.rootConfig.i18n||{}).locales||["en"],[s,l]=P({}),[c,u]=P([]),[d,p]=P(!1),[m,h]=P(!1),[g,_]=P(!0);L(()=>{ji({tags:[e.docId]}).then(y=>{let I={};Object.values(y).forEach(w=>{I[w.source]=w}),l(I),_(!1)})},[e.docId]);async function x(){h(!0),await bt(async()=>{console.log("EditTranslationsModal.onSave()");let y=`edit-translations-${e.docId}`;pe({id:y,loading:!0,title:"Saving translations",message:`Updating for ${e.docId}...`,autoClose:!1,disallowClose:!0});let I=[];c.forEach(w=>{let v=s[w];I.push(v)}),await gl(e.docId,I),at({id:y,title:"Saved translations",message:`Updated translations for ${e.docId}!`,autoClose:!1})}),h(!1)}function b(y){l(I=>{let w={...I};return w[y.source]=y,w}),u(I=>{let w=new Set(I);return w.add(y.source),Array.from(w)}),p(!0)}return f("div",{className:"EditTranslationsModal",children:[f("div",{className:"EditTranslationsModal__header",children:f(X,{component:"a",href:`/cms/translations/${e.docId}`,target:"_blank",variant:"default",size:"xs",children:"Open Translations Editor"})}),g?f(Re,{}):f("table",{className:"EditTranslationsModal__table",children:[f("thead",{children:f("tr",{children:[f("th",{children:f(Te,{size:"h4",weight:"semi-bold",children:"SOURCE"})}),f("th",{children:f(Te,{size:"h4",weight:"semi-bold",children:"TRANSLATIONS"})})]})}),f("tbody",{children:n.map(y=>f("tr",{children:[f("td",{children:f("div",{className:"EditTranslationsModal__table__source",children:y})}),f("td",{children:f(Pu.StringsEditor,{source:y,locales:i,translations:s[y]||{},onChange:b})})]}))})]}),f("div",{className:"EditTranslationsModal__footer",children:[e.l10nSheet&&f("div",{className:"EditTranslationsModal__footer__gsheet",children:[f("strong",{children:"NOTE:"})," Translations for this doc are managed in"," ",f("a",{href:Mn(e.l10nSheet),target:"_blank",rel:"noopener noreferrer",children:"Google Sheets"})]}),f("div",{className:"EditTranslationsModal__footer__buttons",children:[f(X,{variant:"default",size:"xs",color:"dark",type:"button",onClick:()=>r.closeModal(o),children:"Cancel"}),f(X,{variant:"filled",size:"xs",color:"dark",onClick:()=>x(),disabled:!d,loading:m,children:"Save"})]})]})]})}Pu.StringsEditor=t=>{let e=t.locales,[r,o]=P(t.translations||{}),[n,a]=P(!1);function i(s,l){a(!0),o(c=>{let u={...c,source:t.source};return u[s]=l,u})}return L(()=>{n&&t.onChange(r)},[n,r]),f("div",{className:"EditTranslationsModal__StringsEditor",children:e.map(s=>f("div",{className:"EditTranslationsModal__StringsEditor__row",children:[f("div",{className:"EditTranslationsModal__StringsEditor__row__locale",children:s}),f("div",{className:ke("EditTranslationsModal__StringsEditor__row__translation",r[s]?"hasValue":"empty"),children:f(Zt,{size:"xs",radius:0,autosize:!0,minRows:1,maxRows:10,value:r[s],onChange:l=>{i(s,l.currentTarget.value)}})})]}))})};Pu.id=lC;var fC=["https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/spreadsheets"],fde=["https://www.googleapis.com/discovery/v1/apis/drive/v3/rest","https://sheets.googleapis.com/$discovery/rest?version=v4"];function Xi(){let t=window.__ROOT_CTX.rootConfig.projectId,e=!!(window.__ROOT_CTX.gapi?.apiKey&&window.__ROOT_CTX.gapi?.clientId),[r,o]=P(e),[n,a]=P(0),[i,s]=uI({key:`root-cms::${t}::gapi-user-consent`,defaultValue:{}});async function l(){await Promise.all([mde(),hde()]),o(!1)}L(()=>{e&&l()},[]);function c(){return new Promise(d=>{let p=window.__ROOT_CTX.gapi.clientId,m=google.accounts.oauth2.initTokenClient({client_id:p,scope:fC.join(" "),callback:async h=>{let g=cC()+parseInt(h.expires_in);a(g),s({at:cC(),clientId:p,scopes:fC}),d()}});i&&pde(i)?(console.log("requesting token without prompt"),m.requestAccessToken({prompt:""})):(console.log("requesting token with prompt"),m.requestAccessToken({prompt:"consent"}))})}function u(){return cC()<n}return{enabled:e,loading:r,isLoggedIn:u,login:c}}function pde(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 fC.every(o=>r.includes(o))}function cC(){return Math.floor(new Date().getTime()/1e3)}var uC=null;async function mde(){return uC||(uC=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(fde.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)})),uC}var dC=null;async function hde(){return dC||(dC=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)})),dC}var zz="ExportSheetModal";function Uz(){let t=Ye(),e=xt();return{open:r=>{t.openContextModal(zz,{...e,title:"Export to Google Sheet",innerProps:r,size:"650px"})}}}function Ou(t){let{innerProps:e,context:r,id:o}=t,[n,a]=P(!1),[i,s]=P("new-sheet"),[l,c]=P(""),[u,d]=P(!1),p=Xi(),m=[{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."}],h=!1;(i==="add-tab"||i==="link-sheet")&&(h=!0,l&&Ki(l)?.spreadsheetId&&(h=!1));async function g(I,w){let v=w?.isNew||!1,{headers:T,rows:O}=e.csvData;v?(await I.replaceSheet(T,O),await I.applyL10nTheme()):await I.updateValuesMap(O,{keyedBy:"source",preserveColumns:e.locales})}async function _(){p.isLoggedIn()||await p.login();let I=window.__ROOT_CTX.rootConfig,w=I.projectName||I.projectId||"Root CMS",v,T,O="create-google-sheet";try{if(pe({id:O,loading:!0,title:"Creating Google Sheet...",message:"Creating Google Sheet for localization.",autoClose:!1,disallowClose:!0}),v=await ka.create({title:`${w} Localization`}),T=await v.getSheet(0),!T)throw new Error("could not find sheet gid=0");T.setTitle(e.docId)}catch(S){console.error(S);let C=S;typeof S=="object"&&S.body&&(C=String(S.body)),at({id:O,title:"Failed to create Google Sheet",message:String(C),color:"red",autoClose:!1});return}try{at({id:O,loading:!0,title:"Created Google Sheet!",message:`Linking sheet to ${e.docId}...`,autoClose:!1,disallowClose:!0});let S={spreadsheetId:v.spreadsheetId,gid:0};await pb(e.docId,S),c(T.getUrl())}catch(S){console.error(S),at({id:O,title:"Failed to link Google Sheet",message:String(S),color:"red",autoClose:!1});return}try{at({id:O,loading:!0,title:"Linked Google Sheet!",message:"Exporting strings to sheet...",autoClose:!1,disallowClose:!0}),await g(T,{isNew:!0})}catch(S){console.error(S);let C=S;typeof S=="object"&&S.body&&(C=String(S.body)),at({id:O,title:"Failed to export strings to Google Sheet",message:C,color:"red",autoClose:!1});return}d(!0),at({id:O,title:"Done! Exported strings to Google Sheet.",message:v.getUrl(),autoClose:!1})}async function x(){p.isLoggedIn()||await p.login();let I=Ki(l);if(!I?.spreadsheetId)throw new Error("failed to parse spreadsheet id");let w=new ka(I.spreadsheetId),v,T="add-tab-google-sheet";try{pe({id:T,loading:!0,title:"Creating tab in Google Sheet...",message:"Adding tab in existing Google Sheet",autoClose:!1,disallowClose:!0}),v=await w.createSheet({title:e.docId})}catch(O){console.error(O);let S=O;typeof O=="object"&&O.body&&(S=String(O.body)),at({id:T,title:"Failed to create Google Sheet",message:String(S),color:"red",autoClose:!1});return}try{at({id:T,loading:!0,title:"Created Google Sheet!",message:`Linking sheet to ${e.docId}...`,autoClose:!1,disallowClose:!0});let O={spreadsheetId:w.spreadsheetId,gid:v.gid};await pb(e.docId,O)}catch(O){console.error(O),at({id:T,title:"Failed to link Google Sheet",message:String(O),color:"red",autoClose:!1});return}try{at({id:T,loading:!0,title:"Linked Google Sheet!",message:"Exporting strings to sheet...",autoClose:!1,disallowClose:!0}),await g(v,{isNew:!0})}catch(O){console.error(O);let S=O;typeof O=="object"&&O.body&&(S=String(O.body)),at({id:T,title:"Failed to export strings to Google Sheet",message:S,color:"red",autoClose:!1});return}d(!0),at({id:T,title:"Done! Exported strings to Google Sheet.",message:v.getUrl(),autoClose:!1})}async function b(){let I="link-google-sheet",w=Ki(l);if(!w?.spreadsheetId)throw new Error("failed to parse spreadsheet id");try{pe({id:I,loading:!0,title:"Link Google Sheet",message:`Linking sheet to ${e.docId}...`,autoClose:!1,disallowClose:!0}),await pb(e.docId,w)}catch(v){console.error(v),at({id:I,title:"Failed to link Google Sheet",message:String(v),color:"red",autoClose:!1});return}d(!0),at({id:I,title:`Done! Linked ${e.docId} to Google Sheet.`,message:Mn(w),autoClose:!1})}async function y(){console.log(i),a(!0),i==="new-sheet"?await bt(_):i==="add-tab"?await bt(x):i==="link-sheet"&&await bt(b),a(!1)}return f("div",{className:"ExportSheetModal",children:f("div",{className:"ExportSheetModal__content",children:[f("div",{className:"ExportSheetModal__content__body",children:"Export strings to Google Sheet or link an existing Google Sheet for managing translations."}),f("form",{className:"ExportSheetModal__form",children:[f("div",{className:"ExportSheetModal__form__section",children:[f("div",{className:"ExportSheetModal__form__description",children:"Export options:"}),f(Pt,{itemComponent:Ou.SelectItem,data:m,onChange:I=>{s(I),I==="new-sheet"&&c("")},value:i})]}),f("div",{className:"ExportSheetModal__form__section",children:[f("div",{className:"ExportSheetModal__form__description",children:"Google Sheet URL:"}),f(gt,{disabled:i==="new-sheet",value:l,onChange:I=>c(I.currentTarget.value)})]}),f("div",{className:"ExportSheetModal__form__buttons",children:u?f(Ae,{children:[f(X,{component:"a",target:"_blank",rel:"noopener noreferrer",href:l,variant:"default",size:"xs",color:"dark",children:"Open Google Sheet"}),f(X,{variant:"filled",onClick:()=>r.closeModal(o),type:"button",size:"xs",color:"primary",children:"Done"})]}):f(Ae,{children:[f(X,{variant:"outline",onClick:()=>r.closeModal(o),type:"button",size:"xs",color:"dark",children:"Cancel"}),f(X,{variant:"filled",size:"xs",color:"primary",loading:n,disabled:h,onClick:()=>y(),children:i==="link-sheet"?"Link Google Sheet":"Export to Google Sheet"})]})})]})]})})}Ou.SelectItem=K(t=>{let{label:e,help:r,...o}=t;return f("div",{className:"ExportSheetModal__SelectItem",...o,children:[f(Me,{className:"ExportSheetModal__SelectItem__label",size:"body",children:e}),f(Me,{className:"ExportSheetModal__SelectItem__help",size:"body-sm",children:r})]})});Ou.id=zz;async function Au(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 Eb(t){let e=window.firebase.db,r=window.__ROOT_CTX.rootConfig.projectId,[o,n]=t.split("/",2),a=await Au(o),i=we(e,"Projects",r,"Collections",o,"Drafts",n),l=(await vr(i)).data()||{},c=new Set;return Gp(c,a.fields,l.fields||{}),Array.from(c)}function Gp(t,e,r){e.forEach(o=>{if(!o.id)return;let n=r[o.id];Sb(t,o,n)})}function Sb(t,e,r){if(!r)return;function o(n){let a=ei(n);a&&t.add(a)}if(e.type==="object")Gp(t,e.fields||[],r);else if(e.type==="array"){let n=r._array||[];for(let a of n)Sb(t,e.of,r[a])}else if(e.type==="string"||e.type==="select")e.translate&&o(r);else if(e.type==="image")e.translate&&r&&r.alt&&o(r.alt);else if(e.type==="multiselect"){if(e.translate&&Array.isArray(r))for(let n of r)o(n)}else if(e.type==="oneof"){let a=(e.types||[]).find(i=>i.name===r._type);a&&Gp(t,a.fields||[],r)}else e.type==="richtext"?e.translate&&gde(t,r):console.log(`extract: ignoring field, id=${e.id}, type=${e.type}`)}function gde(t,e){(e?.blocks||[]).forEach(o=>{_de(t,o)})}function _de(t,e){if(!e?.type)return;function r(n){if(!n)return;let a=ei(n);a&&t.add(a)}function o(n){n&&n.forEach(a=>{r(a.content),o(a.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 Vz="LocalizationModal";function Hz(t){let e=Ye(),r=xt();return{open:()=>{e.openContextModal(Vz,{...r,innerProps:t,size:"clamp(80%, 1024px, 1280px)",onClose:()=>{t.draft.flush()}})}}}function un(t){let e=t.innerProps;return f("div",{className:"LocalizationModal",children:f("div",{className:"LocalizationModal__layout",children:[f(un.ConfigLocales,{...e}),f(un.Translations,{...e})]})})}un.id=Vz;un.ConfigLocales=t=>{let[e,r]=P(()=>t.draft?t.draft.getLocales():["en"]),o=window.__ROOT_CTX.rootConfig.i18n||{},n=o.locales||["en"],a=o.groups||{default:{label:"",locales:n}};function i(c){return e.filter(u=>(a[c].locales||[]).includes(u))}function s(c,u){let d=new Set(e),p=a[c].locales||[];for(let h of p)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 f("div",{className:"LocalizationModal__locales",children:f(Fc,{spacing:30,children:[f(Gn,{children:[f(Te,{className:"LocalizationModal__iconTitle LocalizationModal__locales__title",size:"h2",children:[f(QS,{strokeWidth:1.5}),f("span",{children:"Locales"})]}),f(un.AllNoneButtons,{onAllClicked:()=>l(n),onNoneClicked:()=>l([])})]}),f(Fc,{spacing:40,children:Object.keys(a).map(c=>{let u=a[c],d=i(c);return f(un.LocaleGroup,{group:u,groupEnabledLocales:d,allEnabledLocales:e,onChange:p=>s(c,p)})})})]})})};un.LocaleGroup=t=>{let e=t.groupEnabledLocales||[],r=t.group.locales||[],o=t.allEnabledLocales||[];function n(i){t.onChange&&t.onChange(i)}function a(i){let s=e.indexOf(i);s===-1?e.push(i):e.splice(s,1),n(e)}return f(Fc,{spacing:16,children:[t.group.label&&f(Gn,{position:"apart",children:[f(Te,{size:"h4",weight:"semi-bold",children:t.group.label}),f(un.AllNoneButtons,{onAllClicked:()=>n(r),onNoneClicked:()=>n([])})]}),f(Gn,{children:r.map(i=>{let s=e.includes(i),l=o.length<=1&&s;return f(Rc,{value:i,checked:s,disabled:l,label:$z(i),onChange:()=>a(i),size:"xs"})})})]})};un.AllNoneButtons=t=>f(Gn,{spacing:"8px",children:[f(X,{variant:"subtle",size:"xs",compact:!0,onClick:t.onAllClicked,sx:e=>({"&:hover":{backgroundColor:e.colors.gray[0]}}),children:"All"}),"/",f(X,{variant:"subtle",size:"xs",compact:!0,onClick:t.onNoneClicked,sx:e=>({"&:hover":{backgroundColor:e.colors.gray[0]}}),children:"None"})]});un.Translations=t=>{let[e,r]=P(!0),[o,n]=P([]),[a,i]=P("en"),[s,l]=P({}),[c,u]=P({}),d=Xi(),[p,m]=P(null),h=Uz(),g=Tt(()=>{let N={};return Object.values(c).forEach(R=>{N[R.source]=R}),N},[c]),_=window.__ROOT_CTX.rootConfig.i18n?.locales||[],x=_.map(N=>({value:N,label:$z(N)}));L(()=>{r(!0),Promise.all([Eb(t.docId),ji(),mb(t.docId)]).then(([N,R,z])=>{n(N),u(R),m(z),r(!1)})},[t.docId]),L(()=>{if(!a){l({});return}let N={};Object.values(c).forEach(R=>{N[R.source]=R[a]||""}),l(N)},[a,c]);function b(N,R){let z=g[N];return z&&z[R]||""}function y(){let N=_.filter(B=>B!=="en"),R=["source","en",...N],z=[];return o.forEach(B=>{let M={source:B,en:b(B,"en")||B};N.forEach(V=>{M[V]=b(B,V)}),z.push(M)}),{headers:R,rows:z}}async function I(){let{headers:N,rows:R}=y(),z=await window.fetch("/cms/api/csv.download",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({headers:N,rows:R})});if(z.status!==200){console.error("csv.download failed:");let V=await z.text();console.error(V)}let B=await z.blob(),M=window.URL.createObjectURL(B);window.location.assign(M),window.URL.revokeObjectURL(M)}async function w(){let N=document.createElement("input");N.type="file",N.accept=".csv",N.addEventListener("change",async()=>{let R=N.files?.[0];if(R){let z=new FormData;z.append("file",R);try{let B=await fetch("/cms/api/csv.import",{method:"POST",body:z});if(B.status!==200){let U=await B.text();throw new Error(`RPCError: ${U}`)}let M=(await B.json()).data,V=await gl(t.docId,M);u(U=>Object.assign({},U,V)),pe({title:"Saved!",message:`Imported translations for ${t.docId}.`,autoClose:5e3})}catch(B){console.error(B),pe({title:"Failed to import CSV",message:String(B),color:"red",autoClose:!1})}}}),N.click()}async function v(){if(d.isLoggedIn()||await d.login(),!p?.spreadsheetId)throw new Error("no sheet linked");let R=await new ka(p.spreadsheetId).getSheet(p.gid??0);if(!R)throw new Error(`sheet not found: ${JSON.stringify(p)}`);await T(R),pe({title:"Exported strings to Google Sheet",message:R.getUrl(),autoClose:!1})}async function T(N,R){let z=R?.isNew||!1,{headers:B,rows:M}=y();z?(await N.replaceSheet(B,M),await N.applyL10nTheme()):await N.updateValuesMap(M,{keyedBy:"source",preserveColumns:_}),Je("doc.export_to_sheet",{metadata:{docId:t.docId,sheetId:{spreadsheetId:N.spreadsheet.spreadsheetId,gid:N.gid}}})}async function O(){if(d.isLoggedIn()||await d.login(),!p?.spreadsheetId)throw new Error("no sheet linked");let R=await new ka(p.spreadsheetId).getSheet(p.gid??0);if(!R)throw new Error(`sheet not found: ${JSON.stringify(p)}`);console.log("importing google sheet");let z=await R.getValuesMap(),B=await gl(t.docId,z);u(M=>Object.assign({},M,B)),pe({title:"Saved!",message:`Imported translations for ${t.docId}.`,autoClose:5e3})}async function S(){await wz(t.docId),m(null),pe({title:"Unlinked Google Sheet",message:`${t.docId} is no longer connected to a Google Sheet.`,autoClose:5e3})}async function C(N){try{await N()}catch(R){console.error(R);let z;typeof R=="object"&&R.body?z=String(R.body):z=String(R),pe({title:"Error",message:z,color:"red",autoClose:!1})}}function F(N){switch(N){case"EXPORT_DOWNLOAD_CSV":{C(I);return}case"EXPORT_GOOGLE_SHEET_LINKED":{C(v);return}case"EXPORT_GOOGLE_SHEET_SHOW_OPTIONS":{h.open({docId:t.docId,csvData:y(),locales:_});return}case"IMPORT_CSV":{C(w);return}case"IMPORT_GOOGLE_SHEET_LINKED":{C(O);return}case"UNLINK_GOOGLE_SHEET":{C(S);return}default:console.log("unhandled action: "+N)}}return e?f("div",{className:"LocalizationModal__translations__loading",children:f(Re,{color:"gray",size:"xl"})}):f("div",{className:"LocalizationModal__translations",children:[f("div",{className:"LocalizationModal__translations__header",children:[f("div",{className:"LocalizationModal__translations__titleWrap",children:[f(Te,{className:"LocalizationModal__translations__title LocalizationModal__iconTitle",size:"h2",children:[f(Wi,{strokeWidth:1.5})," ",f("span",{children:"Translations"})]}),f(X,{component:"a",href:`/cms/translations/${t.docId}`,target:"_blank",variant:"default",size:"xs",children:"Open Translations Editor"})]}),f("div",{className:"LocalizationModal__translations__header__buttons",children:[d.enabled&&p?.spreadsheetId&&f(xe,{label:"Open Google Sheet",children:f(Fe,{component:"a",href:Mn(p),target:"_blank",variant:"filled",color:"green",size:"sm",children:f(El,{size:16,strokeWidth:2.25})})}),f(xde,{onAction:F,gapiClient:d,linkedSheet:p}),f(bde,{onAction:F,gapiClient:d,linkedSheet:p})]})]}),f("table",{className:"LocalizationModal__translations__table",children:[f("tr",{className:"LocalizationModal__translations__table__row LocalizationModal__translations__table__row--header",children:[f("th",{className:"LocalizationModal__translations__table__header",children:f(Te,{size:"h4",weight:"semi-bold",children:"SOURCE STRING"})}),f("th",{className:"LocalizationModal__translations__table__header",children:f(Te,{className:"LocalizationModal__translations__localeSelect",size:"h4",weight:"semi-bold",children:[f("span",{children:"LOCALE: "})," ",f(Pt,{data:x,size:"xs",placeholder:"select locale",allowDeselect:!0,value:a,onChange:N=>i(N)})]})})]}),o.map((N,R)=>f("tr",{className:"LocalizationModal__translations__table__row",children:[f("td",{className:"LocalizationModal__translations__table__col",children:f(ne,{sx:z=>({backgroundColor:z.colors.gray[0],border:`1px solid ${z.colors.gray[3]}`,padding:"10px 20px",borderRadius:4,height:"100%"}),children:f(jt,{size:"xs",sx:{whiteSpace:"pre-wrap"},children:N})})}),f("td",{className:"LocalizationModal__translations__table__col",children:f(ne,{sx:z=>({backgroundColor:z.colors.gray[0],border:`1px solid ${z.colors.gray[3]}`,padding:"10px 20px",borderRadius:4,height:"100%"}),children:f(jt,{size:"xs",sx:{whiteSpace:"pre-wrap"},children:s[N]||" "})})})]},R))]})]})};function xde(t){function e(o){t.onAction&&t.onAction(o)}let r=t.linkedSheet;return f(ze,{className:"LocalizationModal__translations__menu",position:"bottom",placement:"end",control:f(X,{variant:"default",color:"dark",size:"xs",leftIcon:f(ti,{size:16,strokeWidth:1.75}),rightIcon:f(Cu,{size:16,strokeWidth:1.75}),children:"Import"}),children:[t.gapiClient.enabled&&f(Ae,{children:[f(ze.Label,{children:"Google Sheets"}),f(ze.Item,{className:"LocalizationModal__translations__menu__item",disabled:!r?.spreadsheetId,onClick:()=>e("IMPORT_GOOGLE_SHEET_LINKED"),children:"Import Google Sheet"}),f(ja,{})]}),f(ze.Label,{children:"File"}),f(ze.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("IMPORT_CSV"),children:"Import .csv"})]})}function bde(t){async function e(n){t.onAction&&t.onAction(n)}let o=!!t.linkedSheet?.spreadsheetId;return f(ze,{className:"LocalizationModal__translations__menu",position:"bottom",placement:"start",control:f(X,{variant:"default",color:"dark",size:"xs",leftIcon:f(bl,{size:16,strokeWidth:1.75}),rightIcon:f(Cu,{size:16,strokeWidth:1.75}),children:"Export"}),children:[t.gapiClient.enabled&&f(Ae,{children:[f(ze.Label,{children:"Google Sheets"}),o?f(Ae,{children:f(ze.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("EXPORT_GOOGLE_SHEET_LINKED"),children:"Export to Google Sheet"})}):f(Ae,{children:f(ze.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("EXPORT_GOOGLE_SHEET_SHOW_OPTIONS"),children:"Export to Google Sheet"})}),f(ja,{})]}),f(ze.Label,{children:"File"}),f(ze.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("EXPORT_DOWNLOAD_CSV"),children:"Download .csv"}),o&&f(Ae,{children:[f(ja,{}),f(ze.Label,{children:"Danger zone"}),f(ze.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("UNLINK_GOOGLE_SHEET"),color:"red",children:"Unlink Google Sheet"})]})]})}function $z(t){let e=t.split("_"),r=e[0];if(r==="ALL"){let a=String(e[1]).toUpperCase();return`${new Intl.DisplayNames(["en"],{type:"region"}).of(a)||t} (${t})`}return`${new Intl.DisplayNames(["en"],{type:"language"}).of(r)||t} (${t})`}var jz="LockPublishingModal";function qz(t){let e=Ye(),r=xt();return{open:o=>{let a={...t,...o}.unlock?`Unlock publishing for ${t.docId}`:`Lock publishing for ${t.docId}`;e.openContextModal(jz,{...r,title:a,innerProps:{...t,...o},size:"600px"})}}}function Yi(t){let{innerProps:e}=t;return e.unlock?f(Yi.Unlock,{...t}):f(Yi.Lock,{...t})}Yi.Lock=t=>{let{innerProps:e,context:r,id:o}=t,[n,a]=P(""),[i,s]=P(0),[l,c]=P(!1),u=Ye();function d(m){return m?Math.floor(new Date(m).getTime()):0}async function p(m){m.preventDefault(),c(!0),await bt(async()=>{await xz(e.docId,{reason:n,until:i}),pe({title:"Locked!",message:`Publishing is locked for ${e.docId}.`,autoClose:1e4}),u.closeModal(o)})}return f("div",{className:"LockPublishingModal LockPublishingModal--lock",children:[f(Me,{className:"LockPublishingModal__body",children:"Are you sure you want to lock publishing? Content editors will not be able to publish until publishing is unlocked."}),f("form",{className:"LockPublishingModal__form",onSubmit:m=>p(m),children:[f("div",{className:"LockPublishingModal__form__section",children:f(gt,{name:"reason",label:"Reason",description:"Specify a short reason so other content editors know why publishing is locked.",size:"xs",radius:0,onChange:m=>{a(m.currentTarget.value)}})}),f("div",{className:"LockPublishingModal__form__section",children:f(Ho,{label:"Lock until",description:"Optional. Publishing is unlocked at the specified time. If not provided, publishing will be locked indefinitely.",size:"xs",children:f("div",{className:"DocEditor__DateTimeField",children:[f("input",{name:"until",type:"datetime-local",min:Eu(),onChange:m=>{let g=m.target.value;s(d(g))}}),f("div",{className:"DocEditor__DateTimeField__timezone",children:["timezone: ",Intl.DateTimeFormat().resolvedOptions().timeZone]})]})})}),f("div",{className:"LockPublishingModal__buttons",children:[f(X,{variant:"outline",onClick:()=>r.closeModal(o),type:"button",size:"xs",color:"dark",children:"Cancel"}),f(X,{variant:"filled",size:"xs",color:"dark",leftIcon:f(vl,{size:14}),disabled:!n,type:"submit",loading:l,children:"Lock"})]})]})]})};Yi.Unlock=t=>{let{innerProps:e,context:r,id:o}=t,[n,a]=P(!1),i=Ye();async function s(){a(!0),await bt(async()=>{await bz(e.docId),pe({title:"Unlocked!",message:`Publishing is unlocked for ${e.docId}.`,autoClose:1e4}),i.closeModal(o)})}return f("div",{className:"LockPublishingModal LockPublishingModal--unlock",children:[f(Me,{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."]}),f("div",{className:"LockPublishingModal__buttons",children:[f(X,{variant:"outline",onClick:()=>r.closeModal(o),type:"button",size:"xs",color:"dark",children:"Cancel"}),f(X,{variant:"filled",size:"xs",color:"dark",leftIcon:f($p,{size:14}),loading:n,onClick:()=>s(),children:"Unlock"})]})]})};Yi.id=jz;var gC=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(gC).filter(r=>typeof r<"u");let e={};for(let[r,o]of Object.entries(t)){let n=gC(o);typeof n<"u"&&(e[r]=n)}return e},Gz=gC,yde=(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,a=o+n,i=new Array(a);if(r){for(let s=0;s<n;s++)i[s]=e[n-s-1];for(let s=0;s<o;s++)i[s+n]=t[s];return i}for(let s=0;s<o;s++)i[s]=t[s];for(let s=0;s<n;s++)i[s+o]=e[s];return i},Ot=yde,_C=(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(_C(t[r],e))return!0;return!1}for(let r in t)if(_C(t[r],e))return!0;return!1},vde=_C,xC=(t,e,r,o=1/0,n)=>{if(!t||typeof t!="object"){let i;if(!Number.isNaN(t)&&t!==1/0&&t!==-1/0&&typeof t!="bigint"&&(i=JSON.stringify(t,e,r)),i===void 0)switch(n){case Xp.throw:throw new Error(`Value is not valid in JSON, got ${String(t)}`);case Xp.stringify:return Ide(t);default:throw new Error("Should not reach here, please report this bug.")}return i}let a=o<1?'"..."':Array.isArray(t)?`[${t.map(i=>xC(i,e,r,o-1,n)).join(",")}]`:`{${Object.keys(t).map(i=>`"${i}": ${xC(t[i],e,r,o-1,n)}`).join(", ")}}`;return JSON.stringify(JSON.parse(a),e,r)},Ide=t=>t===void 0?"undefined":t===1/0?"Infinity":t===-1/0?"-Infinity":Number.isNaN(t)?"NaN":typeof t=="bigint"?`${t}n`:String(t),Ur=xC,wde=(t,e=1/0,r=!1,o=Xp.stringify)=>t===null?"null":Array.isArray(t)||typeof t=="object"?Ur(t,void 0,r?1:void 0,e,o):Ur(t,void 0,void 0,void 0,o),Ln=wde,Wz=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,Ede=(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 a=Wz(t),i=Wz(e);if(a!==i)return a-i;if(t===null&&e===null||Array.isArray(t)&&Array.isArray(e)||a===5&&i===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))},Yp=Ede,Sde=t=>Array.isArray(t)?"array":t===null?"null":typeof t,ea=Sde,Cde=(t,e,r,o,n,a,i,s)=>{let l={ignoreCase:s.ignoreCase},c=Ln(n,s.maxDepth,!0,s.undefinedBehavior).split(`
|
|
37
|
+
`)}function Jue(t){return String(t).trimEnd().replace(/ $/,"")}function ede(t){let r=(window.__ROOT_CTX.rootConfig.i18n||{}).locales||["en"];for(let o of r)if(String(o).toLowerCase()===t.toLowerCase())return o;return null}async function fz(t){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,[o,n]=t.split("/"),a=we(r,"Projects",e,"Collections",o,"Drafts",n),i=we(r,"Projects",e,"Collections",o,"Published",n),s=we(r,"Projects",e,"Collections",o,"Scheduled",n),l=sn(r);l.delete(a),l.delete(i),l.delete(s),await l.commit(),console.log(`deleted doc: ${t}`),Je("doc.delete",{metadata:{docId:t}})}async function pz(t){await CS([t])}async function CS(t,e){if(t.length===0){console.log("no docs to publish");return}let r=window.firebase.db;if(t.length>100)throw new Error("publish docs exceeds limit of 100 docs. break up your request into multiple calls.");let o=await TS(t),n=e?.batch||sn(r);t.forEach(a=>{let i=o[a];if(!i)throw new Error(`doc does not exist: ${a}`);tde(n,a,i)}),await n.commit(),t.length===1?console.log(`published ${t[0]}`):console.log(`published ${t.length} docs: ${t.join(", ")}`);for(let a of t)Je("doc.publish",{metadata:{docId:a}});cz(t)}function tde(t,e,r){if(hl(r))throw new Error(`publishing is locked for doc: ${r.id}`);let o=window.__ROOT_CTX.rootConfig.projectId,n=window.firebase.db,[a,i]=e.split("/"),s=we(n,"Projects",o,"Collections",a,"Drafts",i),l=we(n,"Projects",o,"Collections",a,"Scheduled",i),c=we(n,"Projects",o,"Collections",a,"Published",i),u={...r},d=u.sys??{};d.modifiedAt=Ut(),d.modifiedBy=window.firebase.user.email,d.publishedAt=Ut(),d.publishedBy=window.firebase.user.email,d.firstPublishedAt??=Ut(),d.firstPublishedBy??=window.firebase.user.email,delete d.scheduledAt,delete d.scheduledBy,t.update(s,{sys:d}),t.set(c,{...u,sys:d}),t.delete(l)}async function mz(t,e){let r=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,[n,a]=t.split("/"),i=we(o,"Projects",r,"Collections",n,"Drafts",a),s=we(o,"Projects",r,"Collections",n,"Scheduled",a);await Pp(o,async l=>{let c=await l.get(i);if(!c.exists())throw new Error(`${i.id} does not exist`);let u={...c.data()},d=u.sys??{};d.modifiedAt=Ut(),d.modifiedBy=window.firebase.user.email,d.scheduledAt=Ze.fromMillis(e),d.scheduledBy=window.firebase.user.email,l.update(i,{sys:d}),l.set(s,{...u,sys:d})}),console.log(`saved ${s.id}`),Je("doc.schedule",{metadata:{docId:t,scheduledAt:e}})}async function hz(t){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,[o,n]=t.split("/"),a=we(r,"Projects",e,"Collections",o,"Drafts",n),i=we(r,"Projects",e,"Collections",o,"Scheduled",n),s=we(r,"Projects",e,"Collections",o,"Published",n),l=sn(r);l.update(a,{"sys.modifiedAt":Ut(),"sys.modifiedBy":window.firebase.user.email,"sys.publishedAt":zr(),"sys.publishedBy":zr(),"sys.firstPublishedAt":zr(),"sys.firstPublishedBy":zr()}),l.delete(i),l.delete(s),await l.commit(),console.log(`unpublished ${t}`),Je("doc.unpublish",{metadata:{docId:t}}),ES(t)}async function gz(t){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,[o,n]=t.split("/"),a=we(r,"Projects",e,"Collections",o,"Drafts",n),i=we(r,"Projects",e,"Collections",o,"Published",n);await Pp(r,async s=>{let l=await s.get(i);if(!l.exists())throw new Error(`${i.id} does not exist`);let c=l.data();s.set(a,c)}),console.log(`reverted draft ${t}`),Je("doc.revert",{metadata:{docId:t}})}async function _z(t){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,[o,n]=t.split("/"),a=we(r,"Projects",e,"Collections",o,"Drafts",n),i=we(r,"Projects",e,"Collections",o,"Scheduled",n),s=sn(r);s.update(a,{"sys.modifiedAt":Ut(),"sys.modifiedBy":window.firebase.user.email,"sys.scheduledAt":zr(),"sys.scheduledBy":zr()}),s.delete(i),await s.commit(),console.log(`unscheduled ${t}`),Je("doc.unschedule",{metadata:{docId:t}})}async function xz(t,e){let r={lockedAt:Ut(),lockedBy:window.firebase.user.email,reason:e.reason||`Locked by ${window.firebase.user.email}.`};e.until&&(r.until=Ze.fromMillis(e.until));let o=Nn(t);await rr(o,{"sys.publishingLocked":r});let a={docId:t,reason:e.reason};e.until&&(a.until=e.until),Je("doc.lock_publishing",{metadata:a})}async function bz(t){let e=Nn(t),r={"sys.publishingLocked":zr()};await rr(e,r),Je("doc.unlock_publishing",{metadata:{docId:t}})}function fb(t){let e=Ze.now().toMillis();return(t?.sys?.scheduledAt?.toMillis()||0)>e}function hl(t){if(t?.sys?.publishingLocked){if(t.sys.publishingLocked.until){let e=Ze.now().toMillis(),r=t.sys.publishingLocked.until.toMillis();return e<r}return!0}return!1}async function yz(t,e,r){let o=Nn(t),n=await vr(o);if(!n.exists())throw new Error(`doc ${t} does not exist`);let a=n.data().fields??{};await kS(e,{fields:a,overwrite:r?.overwrite})}async function kS(t,e){let[r,o]=t.split("/"),n=Nn(t),a=await vr(n);if(a.exists()&&!e?.overwrite)throw new Error(`${t} already exists`);let i={id:t,collection:r,slug:o,sys:{createdAt:Ut(),createdBy:window.firebase.user.email,modifiedAt:Ut(),modifiedBy:window.firebase.user.email,locales:["en"]},fields:e?.fields??{}};if(a.exists()&&e?.overwrite){let s=a.data();i.sys={...s.sys,modifiedAt:Ut(),modifiedBy:window.firebase.user.email}}await vu(n,i),Je("doc.create",{metadata:{docId:t}})}async function gl(t,e,r){let n=(window.__ROOT_CTX.rootConfig.i18n||{}).locales||["en"];function a(m){for(let h of n)if(String(h).toLowerCase()===m.toLowerCase())return h;return null}let i={};for(let m of e){if(!m.source)continue;let h={source:ei(m.source)};Object.entries(m).forEach(([_,x])=>{if(_==="source")return;let b=a(_);b&&(h[b]=ei(x||""))});let g=await ub(h.source);i[g]=h}let l=[t.split("/")[0],t];r?.tags&&l.push(...r.tags);let c=SS(),u=window.firebase.db,d=sn(u),p=0;for(let m in i){let h=i[m],g=we(c,m);d.set(g,{...h,tags:A9(...l)},{merge:!0}),p+=1,p>=500&&(await d.commit(),d=sn(u),console.log(`saved ${p} strings`),p=0)}return p>0&&(await d.commit(),console.log(`saved ${p} strings`)),Je("doc.import_translations",{metadata:{docId:t}}),i}function Nn(t){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,[o,n]=t.split("/");return we(r,"Projects",e,"Collections",o,"Drafts",n)}function rde(t){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,[o,n]=t.split("/");return we(r,"Projects",e,"Collections",o,"Published",n)}function ode(t,e){let r=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,[n,a]=t.split("/");return we(o,"Projects",r,"Collections",n,"Drafts",a,"Versions",e)}async function TS(t){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,o={};t.forEach(a=>{let[i,s]=a.split("/");i in o?o[i].push(s):o[i]=[s]});let n={};return await Promise.all(Object.entries(o).map(async([a,i])=>{let s=nn(r,"Projects",e,"Collections",a,"Drafts"),l=to(s,eb(Zx(),"in",i));(await an(l)).forEach(u=>{let d=`${a}/${u.id}`;n[d]=u.data()})})),n}async function vz(t){let e=window.firebase.db,r=Nn(t),o=nn(e,r.path,"Versions"),n=to(o,Qn("sys.modifiedAt","desc")),a=await an(n),i=[];return a.forEach(s=>{let l={...s.data(),_versionId:s.id};i.push(l)}),i}async function Iz(t,e){let r=Nn(t),o={"sys.modifiedAt":Ut(),"sys.modifiedBy":window.firebase.user.email,fields:e.fields||{}};await rr(r,o),Je("doc.restore_version",{metadata:{docId:t,versionModifiedAt:e.sys?.modifiedAt,versionModifiedBy:e.sys?.modifiedBy}})}async function PS(t,e){let r;e==="draft"?r=Nn(t):e==="published"?r=rde(t):r=ode(t,e);let o=await vr(r);return o.exists()?o.data():null}async function pb(t,e){if(!e?.spreadsheetId)throw new Error("no spreadsheet id");let r=Nn(t),o={"sys.l10nSheet":{spreadsheetId:e.spreadsheetId,gid:e.gid||0,linkedAt:Ut(),linkedBy:window.firebase.user.email}};await rr(r,o),Je("doc.link_sheet",{metadata:{docId:t,sheetId:e}})}async function wz(t){let e=Nn(t),r={"sys.l10nSheet":zr()};await rr(e,r),Je("doc.unlink_sheet",{metadata:{docId:t}})}async function mb(t){let e=Nn(t),n=(await vr(e)).data()?.sys?.l10nSheet||{};return n?.spreadsheetId?{spreadsheetId:n.spreadsheetId,gid:n.gid||0}:null}function db(t,e){let r={};for(let o in t){let n=t[o];if(nde(n))if(n.toMillis)r[o]=n.toMillis();else if(Object.hasOwn(n,"_array")&&Array.isArray(n._array)){let a=n._array.map(i=>{let s={...db(n[i]||{},e),_arrayKey:i};return e?.removeArrayKey&&delete s._arrayKey,s});r[o]=a}else r[o]=db(n,e);else r[o]=n}return r}function nde(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function ke(...t){return t.filter(e=>!!e).join(" ")||void 0}var ade=0,xVe=Array.isArray;function f(t,e,r,o,n,a){var i,s,l={};for(s in e)s=="ref"?i=e[s]:l[s]=e[s];var c={type:t,props:l,key:r,ref:i,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--ade,__i:-1,__u:0,__source:n,__self:a};if(typeof t=="function"&&(i=t.defaultProps))for(s in i)l[s]===void 0&&(l[s]=i[s]);return he.vnode&&he.vnode(c),c}function Me(t){let{className:e,as:r,size:o,weight:n,color:a,children:i,...s}=t;return f(r||"div",{...s,className:ke(e,"text",o&&`size:${o}`,n&&`weight:${n}`,a&&`color:${a}`),children:i})}function Jn(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=OS(t);return`${o}${n}`}function OS(t){let e=window.__ROOT_CTX.collections,{collectionId:r,slug:o,locale:n}=t,a=e[r];if(!a)throw new Error(`collection not found: ${r}`);let i=window.__ROOT_CTX.rootConfig,s=i.base||"/",l="/[base]/[path]";n&&(l=i.i18n.urlFormat||"/[locale]/[base]/[path]");let c="",u=a?.url;if(u)if(o){let d=u.replace(/\[.*slug\]/,o).replaceAll("--","/").replace(/\/+/g,"/");d==="/index"&&(d="/"),c=d}else c=u;return Ez(l,{base:s,path:c,locale:n||"",slug:o})}function AS(t){let e=window.__ROOT_CTX.collections,{collectionId:r,slug:o,locale:n}=t,a=e[r];if(!a)throw new Error(`collection not found: ${r}`);let i=window.__ROOT_CTX.rootConfig,s=i.base||"/",l="/[base]/[path]";n&&(l=i.i18n.urlFormat||"/[locale]/[base]/[path]");let c="",u=a?.previewUrl||a?.url;if(u)if(o){let d=u.replace(/\[.*slug\]/,o).replaceAll("--","/").replace(/\/+/g,"/");d==="/index"&&(d="/"),c=d}else c=u;return Ez(l,{base:s,path:c,locale:n||"",slug:o})}function Ez(t,e){let r=t.replaceAll(/\[\[?(\.\.\.)?([\w\-_]*)\]?\]/g,(o,n,a)=>e[a]??o);return ide(r,{trailingSlash:window.__ROOT_CTX.rootConfig.server.trailingSlash})}function ide(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 hb(t){let[e,r]=P(t.collectionId||""),o=H(null),[n,a]=P(""),i=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(i?.url){if(n){let d=$i(n),p=i?.slugRegex;Ca(d,p)?l=Jn({collectionId:e,slug:d}):l="INVALID SLUG"}else l=Jn({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){a(d),t.onChange&&t.onChange({collectionId:e,slug:d})}return f("div",{className:ke(t.className,"SlugInput"),children:[f("div",{className:"SlugInput__inputs",children:[f(Pt,{className:"SlugInput__collection",placeholder:"Collection",size:"xs",data:s,onChange:d=>c(d),value:e,disabled:!!t.collectionDisabled}),f("div",{className:"SlugInput__divider",children:"/"}),f(gt,{className:"SlugInput__slug",name:"slug",ref:o,value:n,onChange:d=>{u(d.currentTarget.value)},placeholder:"slug",autoComplete:"off",size:"xs"})]}),l&&f(Me,{className:"SlugInput__urlHelp",size:"body-sm",children:l})]})}var Sz="CopyDocModal";function Cz(t){let e=Ye(),r=xt();return{open:()=>{e.openContextModal(Sz,{...r,innerProps:t})}}}function gb(t){let{innerProps:e,context:r,id:o}=t,[n,a]=P(""),[i,s]=P(""),[l,c]=P(""),[u,d]=P(!1),[p,m]=P(!1),h=e.fromDocId,g=h.split("/")[0];async function _(x){if(x.preventDefault(),m(!0),c(""),!g){c("Please select a collection."),m(!1);return}let b=$i(i),y=window.__ROOT_CTX.collections[n]?.slugRegex;if(!Ca(b,y)){c('Please enter a valid slug (e.g. "foo-bar-123").'),m(!1);return}let I=`${n}/${b}`;try{await yz(h,I,{overwrite:u}),r.closeModal(o),pe({title:"Copied!",message:`Succesfully copied ${h} to ${I}.`,autoClose:5e3})}catch(w){let v=String(w);c(v),v.includes("already exists")&&d(!0),m(!1);return}m(!1),ur(`/cms/content/${n}/${b}`)}return f("div",{className:"CopyDocModal",children:f("form",{onSubmit:x=>_(x),children:[f("div",{className:"CopyDocModal__from",children:[f(Me,{className:"CopyDocModal__from__label",size:"body",weight:"bold",children:"From:"}),f(Me,{className:"CopyDocModal__from__value",size:"body-sm",children:f("code",{children:e.fromDocId})})]}),f("div",{className:"CopyDocModal__to",children:[f(Me,{className:"CopyDocModal__to__label",size:"body",weight:"bold",children:"To:"}),f(hb,{className:"CopyDocModal__slug",collectionId:g,onChange:x=>{a(x.collectionId),s(x.slug)}})]}),l&&f("div",{className:"CopyDocModal__error",children:l}),f("div",{className:"CopyDocModal__buttons",children:[f(X,{variant:"outline",onClick:()=>r.closeModal(o),type:"button",size:"xs",color:"dark",children:"Cancel"}),f(X,{variant:"filled",type:"submit",size:"xs",color:"dark",loading:p,children:u?"Overwrite?":"Submit"})]})]})})}gb.id=Sz;async function bt(t){try{await t()}catch(e){console.error(e);let r;typeof e=="object"&&e.body?r=String(e.body):r=String(e),pe({title:"Error",message:r,color:"red",autoClose:!1})}}var DS=Rt(null);function kz(){let t=Mt(DS);if(!t)throw new Error("useFirebase() should be called within a <FirebaseProvider>");return t}function Su(t,e){let[r,o]=P([]),[n,a]=P(!0),s=kz().db,l=window.__ROOT_CTX.rootConfig.projectId||"default",c=async()=>{a(!0);let u=nn(s,"Projects",l,"Collections",t,"Drafts"),d=u,p=e.orderBy;p==="modifiedAt"?d=to(u,Qn("sys.modifiedAt","desc")):p==="newest"?d=to(u,Qn("sys.createdAt","desc")):p==="oldest"?d=to(u,Qn("sys.createdAt")):p==="slug"&&(d=to(u,Qn(Zx()))),await bt(async()=>{let m=await an(d),h=[];m.docs.forEach(g=>{let _=g.data(),x=g.id,b=`${t}/${x}`,y={..._,id:b,slug:x};h.push(y),Lp(b,y)}),o(h)}),a(!1)};return L(()=>{a(!0),c()},[t,e.orderBy]),[n,c,r]}function Bp(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function oo(t,e){let r=e.split("."),o=t;for(let n of r)o||(o={}),o=o[n];return o}function RS(t){let e={};for(let r in t)if(Bp(t[r])){let o=t[r],n=RS(o);for(let a in n)e[`${r}.${a}`]=n[a]}else e[r]=t[r];return e}function Tz(t,e){return t.sort((r,o)=>{let n=r[e],a=o[e];return n<a?-1:n>a?1:0})}function _b(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(!_b(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(!_b(t[n],e[n]))return!1;return!0}var NS="DocPickerModal";function Pz(){let t=Ye(),e=xt();return{open:r=>{t.openContextModal(NS,{...e,innerProps:r,size:"700px",overflow:"inside"})},close:()=>{t.closeModal(NS)}}}function qi(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,a]=P(e.initialCollection||(r.length===1?r[0]:""));function i(s){e.onChange&&e.onChange(s.id)}return f("div",{className:"DocPickerModal",children:[r.length===0&&f("div",{className:"DocPickerModal__noCollections",children:"No collections matching schema field definition."}),r.length>1&&f("div",{className:"DocPickerModal__collection__select",children:[f("div",{className:"DocPickerModal__collection__select__label",children:"Content Type:"}),f(Pt,{data:o,value:n,placeholder:"Select",onChange:s=>{a(s||"")},size:"xs",radius:0,dropdownComponent:"div"})]}),n&&f(qi.DocsList,{collection:n,onDocSelected:i})]})}qi.DocsList=t=>{let[e,,r]=Su(t.collection,{orderBy:"slug"});return f("div",{className:"DocPickerModal__DocsList",children:e?f("div",{className:"DocPickerModal__DocsList__loading",children:f(Re,{color:"gray",size:"xl"})}):r.length===0?f("div",{className:"DocPickerModal__DocsList__empty",children:"Collection is empty."}):f("div",{className:"DocPickerModal__DocsList__docs",children:r.map(o=>f(qi.DocCard,{doc:o,onDocSelected:t.onDocSelected},o.id))})})};qi.DocCard=t=>{let e=t.doc,[r,o]=e.id.split("/"),n=e.fields||{},a=window.__ROOT_CTX.collections[r],i=Jn({collectionId:r,slug:o}),s=oo(n,a.preview?.title||"meta.title"),l=oo(n,a.preview?.image||"meta.image")||a.preview?.defaultImage;return f("div",{className:"DocPickerModal__DocCard",children:[f("div",{className:"DocPickerModal__DocCard__image",children:f(Tn,{src:l?.src,width:120,height:90,withPlaceholder:!l?.src})}),f("div",{className:"DocPickerModal__DocCard__content",children:[f("div",{className:"DocPickerModal__DocCard__content__header",children:f("div",{className:"DocPickerModal__DocCard__content__header__docId",children:e.id})}),f("div",{className:"DocPickerModal__DocCard__content__title",children:s||"[UNTITLED]"}),f("div",{className:"DocPickerModal__DocCard__content__url",children:i})]}),f("div",{className:"DocPickerModal__DocCard__controls",children:f(X,{color:"blue",size:"xs",onClick:()=>t.onDocSelected(t.doc),children:"Select"})})]})};qi.id=NS;var MS="DocSelectModal";function Oz(){let t=Ye(),e=xt();return{open:r=>{t.openContextModal(MS,{...e,innerProps:r,size:"700px",overflow:"inside"})},close:()=>{t.closeModal(MS)}}}function Gi(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,a]=P(e.initialCollection||(r.length===1?r[0]:""));function i(l){e.onChange&&e.onChange(l.id,!0)}function s(l){e.onChange&&e.onChange(l.id,!1)}return console.log("selected docs:",e.selectedDocIds),f("div",{className:"DocSelectModal",children:[r.length===0&&f("div",{className:"DocSelectModal__noCollections",children:"No collections matching schema field definition."}),r.length>1&&f("div",{className:"DocSelectModal__collection__select",children:[f("div",{className:"DocSelectModal__collection__select__label",children:"Content Type:"}),f(Pt,{data:o,value:n,placeholder:"Select",onChange:l=>{a(l||"")},size:"xs",radius:0,dropdownComponent:"div"})]}),n&&f(Gi.DocsList,{collection:n,onDocSelected:i,onDocUnselected:s,selectedDocIds:e.selectedDocIds})]})}Gi.DocsList=t=>{let[e,,r]=Su(t.collection,{orderBy:"slug"}),o=t.selectedDocIds||[];return f("div",{className:"DocSelectModal__DocsList",children:e?f("div",{className:"DocSelectModal__DocsList__loading",children:f(Re,{color:"gray",size:"xl"})}):r.length===0?f("div",{className:"DocSelectModal__DocsList__empty",children:"Collection is empty."}):f("div",{className:"DocSelectModal__DocsList__docs",children:r.map(n=>f(Gi.DocCard,{doc:n,onDocSelected:t.onDocSelected,onDocUnselected:t.onDocUnselected,selected:o.includes(n.id)},n.id))})})};Gi.DocCard=t=>{let[e,r]=P(!!t.selected),o=t.doc,[n,a]=o.id.split("/"),i=o.fields||{},s=window.__ROOT_CTX.collections[n],l=Jn({collectionId:n,slug:a}),c=oo(i,s.preview?.title||"meta.title"),u=oo(i,s.preview?.image||"meta.image")||s.preview?.defaultImage;return f("div",{className:"DocSelectModal__DocCard",children:[f("div",{className:"DocSelectModal__DocCard__image",children:f(Tn,{src:u?.src,width:120,height:90,withPlaceholder:!u?.src})}),f("div",{className:"DocSelectModal__DocCard__content",children:[f("div",{className:"DocSelectModal__DocCard__content__header",children:f("div",{className:"DocSelectModal__DocCard__content__header__docId",children:o.id})}),f("div",{className:"DocSelectModal__DocCard__content__title",children:c||"[UNTITLED]"}),f("div",{className:"DocSelectModal__DocCard__content__url",children:l})]}),f("div",{className:"DocSelectModal__DocCard__controls",children:e?f(X,{variant:"light",color:"blue",size:"xs",onClick:()=>{r(!1),t.onDocUnselected(t.doc)},children:"Unselect"}):f(X,{variant:"filled",color:"blue",size:"xs",onClick:()=>{r(!0),t.onDocSelected(t.doc)},children:"Select"})})]})};Gi.id=MS;var Az={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};var sde=Object.defineProperty,lde=Object.defineProperties,cde=Object.getOwnPropertyDescriptors,xb=Object.getOwnPropertySymbols,Nz=Object.prototype.hasOwnProperty,Mz=Object.prototype.propertyIsEnumerable,Dz=(t,e,r)=>e in t?sde(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Rz=(t,e)=>{for(var r in e||(e={}))Nz.call(e,r)&&Dz(t,r,e[r]);if(xb)for(var r of xb(e))Mz.call(e,r)&&Dz(t,r,e[r]);return t},ude=(t,e)=>lde(t,cde(e)),dde=(t,e)=>{var r={};for(var o in t)Nz.call(t,o)&&e.indexOf(o)<0&&(r[o]=t[o]);if(t!=null&&xb)for(var o of xb(t))e.indexOf(o)<0&&Mz.call(t,o)&&(r[o]=t[o]);return r},Y=(t,e,r)=>{let o=n=>{var a=n,{color:i="currentColor",size:s=24,stroke:l=2,children:c}=a,u=dde(a,["color","size","stroke","children"]);return Q("svg",Rz(ude(Rz({},Az),{width:s,height:s,stroke:i,"stroke-width":l,class:`tabler-icon tabler-icon-${t}`}),u),[...r.map(([d,p])=>Q(d,p)),...yo(c)])};return o.displayName=`${e}`,o};var LS=Y("alarm-off","IconAlarmOff",[["path",{d:"M7.587 7.566a7 7 0 1 0 9.833 9.864m1.35 -2.645a7 7 0 0 0 -8.536 -8.56",key:"svg-0"}],["path",{d:"M12 12v1h1",key:"svg-1"}],["path",{d:"M5.261 5.265l-1.011 .735",key:"svg-2"}],["path",{d:"M17 4l2.75 2",key:"svg-3"}],["path",{d:"M3 3l18 18",key:"svg-4"}]]);var BS=Y("arrow-back","IconArrowBack",[["path",{d:"M9 11l-4 4l4 4m-4 -4h11a4 4 0 0 0 0 -8h-1",key:"svg-0"}]]);var FS=Y("arrow-left","IconArrowLeft",[["path",{d:"M5 12l14 0",key:"svg-0"}],["path",{d:"M5 12l6 6",key:"svg-1"}],["path",{d:"M5 12l6 -6",key:"svg-2"}]]);var zS=Y("arrow-roundabout-right","IconArrowRoundaboutRight",[["path",{d:"M21 9h-8a5 5 0 1 0 -5 5v7",key:"svg-0"}],["path",{d:"M17 5l4 4l-4 4",key:"svg-1"}]]);var _l=Y("arrow-up-right","IconArrowUpRight",[["path",{d:"M17 7l-10 10",key:"svg-0"}],["path",{d:"M8 7l9 0l0 9",key:"svg-1"}]]);var Fp=Y("braces","IconBraces",[["path",{d:"M7 4a2 2 0 0 0 -2 2v3a2 3 0 0 1 -2 3a2 3 0 0 1 2 3v3a2 2 0 0 0 2 2",key:"svg-0"}],["path",{d:"M17 4a2 2 0 0 1 2 2v3a2 3 0 0 0 2 3a2 3 0 0 0 -2 3v3a2 2 0 0 1 -2 2",key:"svg-1"}]]);var US=Y("carrot","IconCarrot",[["path",{d:"M3 21s9.834 -3.489 12.684 -6.34a4.487 4.487 0 0 0 0 -6.344a4.483 4.483 0 0 0 -6.342 0c-2.86 2.861 -6.347 12.689 -6.347 12.689z",key:"svg-0"}],["path",{d:"M9 13l-1.5 -1.5",key:"svg-1"}],["path",{d:"M16 14l-2 -2",key:"svg-2"}],["path",{d:"M22 8s-1.14 -2 -3 -2c-1.406 0 -3 2 -3 2s1.14 2 3 2s3 -2 3 -2z",key:"svg-3"}],["path",{d:"M16 2s-2 1.14 -2 3s2 3 2 3s2 -1.577 2 -3c0 -1.86 -2 -3 -2 -3z",key:"svg-4"}]]);var Cu=Y("chevron-down","IconChevronDown",[["path",{d:"M6 9l6 6l6 -6",key:"svg-0"}]]);var VS=Y("circle-arrow-down","IconCircleArrowDown",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M8 12l4 4",key:"svg-1"}],["path",{d:"M12 8v8",key:"svg-2"}],["path",{d:"M16 12l-4 4",key:"svg-3"}]]);var HS=Y("circle-arrow-up","IconCircleArrowUp",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M12 8l-4 4",key:"svg-1"}],["path",{d:"M12 8v8",key:"svg-2"}],["path",{d:"M16 12l-4 -4",key:"svg-3"}]]);var ku=Y("circle-plus","IconCirclePlus",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M9 12h6",key:"svg-1"}],["path",{d:"M12 9v6",key:"svg-2"}]]);var $S=Y("clipboard-check","IconClipboardCheck",[["path",{d:"M9 5h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2h-2",key:"svg-0"}],["path",{d:"M9 3m0 2a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v0a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2z",key:"svg-1"}],["path",{d:"M9 14l2 2l4 -4",key:"svg-2"}]]);var jS=Y("clipboard-copy","IconClipboardCopy",[["path",{d:"M9 5h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h3m9 -9v-5a2 2 0 0 0 -2 -2h-2",key:"svg-0"}],["path",{d:"M13 17v-1a1 1 0 0 1 1 -1h1m3 0h1a1 1 0 0 1 1 1v1m0 3v1a1 1 0 0 1 -1 1h-1m-3 0h-1a1 1 0 0 1 -1 -1v-1",key:"svg-1"}],["path",{d:"M9 3m0 2a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v0a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2z",key:"svg-2"}]]);var zp=Y("clipboard","IconClipboard",[["path",{d:"M9 5h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2h-2",key:"svg-0"}],["path",{d:"M9 3m0 2a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v0a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2z",key:"svg-1"}]]);var qS=Y("cloud-off","IconCloudOff",[["path",{d:"M9.58 5.548c.24 -.11 .492 -.207 .752 -.286c1.88 -.572 3.956 -.193 5.444 1c1.488 1.19 2.162 3.007 1.77 4.769h.99c1.913 0 3.464 1.56 3.464 3.486c0 .957 -.383 1.824 -1.003 2.454m-2.997 1.033h-11.343c-2.572 -.004 -4.657 -2.011 -4.657 -4.487c0 -2.475 2.085 -4.482 4.657 -4.482c.13 -.582 .37 -1.128 .7 -1.62",key:"svg-0"}],["path",{d:"M3 3l18 18",key:"svg-1"}]]);var Up=Y("copy","IconCopy",[["path",{d:"M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z",key:"svg-0"}],["path",{d:"M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1",key:"svg-1"}]]);var GS=Y("database","IconDatabase",[["path",{d:"M12 6m-8 0a8 3 0 1 0 16 0a8 3 0 1 0 -16 0",key:"svg-0"}],["path",{d:"M4 6v6a8 3 0 0 0 16 0v-6",key:"svg-1"}],["path",{d:"M4 12v6a8 3 0 0 0 16 0v-6",key:"svg-2"}]]);var WS=Y("device-desktop","IconDeviceDesktop",[["path",{d:"M3 5a1 1 0 0 1 1 -1h16a1 1 0 0 1 1 1v10a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1v-10z",key:"svg-0"}],["path",{d:"M7 20h10",key:"svg-1"}],["path",{d:"M9 16v4",key:"svg-2"}],["path",{d:"M15 16v4",key:"svg-3"}]]);var Vp=Y("device-floppy","IconDeviceFloppy",[["path",{d:"M6 4h10l4 4v10a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2",key:"svg-0"}],["path",{d:"M12 14m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-1"}],["path",{d:"M14 4l0 4l-6 0l0 -4",key:"svg-2"}]]);var KS=Y("device-ipad","IconDeviceIpad",[["path",{d:"M18 2a3 3 0 0 1 2.995 2.824l.005 .176v14a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-14a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm-3 15h-6l-.117 .007a1 1 0 0 0 0 1.986l.117 .007h6l.117 -.007a1 1 0 0 0 0 -1.986l-.117 -.007z",key:"svg-0"}]]);var XS=Y("device-mobile","IconDeviceMobile",[["path",{d:"M6 5a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2v-14z",key:"svg-0"}],["path",{d:"M11 4h2",key:"svg-1"}],["path",{d:"M12 17v.01",key:"svg-2"}]]);var xl=Y("dots-vertical","IconDotsVertical",[["path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M12 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}]]);var bl=Y("file-download","IconFileDownload",[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z",key:"svg-1"}],["path",{d:"M12 17v-6",key:"svg-2"}],["path",{d:"M9.5 14.5l2.5 2.5l2.5 -2.5",key:"svg-3"}]]);var ti=Y("file-upload","IconFileUpload",[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z",key:"svg-1"}],["path",{d:"M12 11v6",key:"svg-2"}],["path",{d:"M9.5 13.5l2.5 -2.5l2.5 2.5",key:"svg-3"}]]);var yl=Y("folder","IconFolder",[["path",{d:"M5 4h4l3 3h7a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2",key:"svg-0"}]]);var Hp=Y("history","IconHistory",[["path",{d:"M12 8l0 4l2 2",key:"svg-0"}],["path",{d:"M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5",key:"svg-1"}]]);var YS=Y("home","IconHome",[["path",{d:"M5 12l-2 0l9 -9l9 9l-2 0",key:"svg-0"}],["path",{d:"M5 12v7a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-7",key:"svg-1"}],["path",{d:"M9 21v-6a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v6",key:"svg-2"}]]);var Wi=Y("language","IconLanguage",[["path",{d:"M4 5h7",key:"svg-0"}],["path",{d:"M9 3v2c0 4.418 -2.239 8 -5 8",key:"svg-1"}],["path",{d:"M5 9c0 2.144 2.952 3.908 6.7 4",key:"svg-2"}],["path",{d:"M12 20l4 -9l4 9",key:"svg-3"}],["path",{d:"M19.1 18h-6.2",key:"svg-4"}]]);var $p=Y("lock-open","IconLockOpen",[["path",{d:"M5 11m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v6a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z",key:"svg-0"}],["path",{d:"M12 16m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M8 11v-5a4 4 0 0 1 8 0",key:"svg-2"}]]);var vl=Y("lock","IconLock",[["path",{d:"M5 13a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v6a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-6z",key:"svg-0"}],["path",{d:"M11 16a1 1 0 1 0 2 0a1 1 0 0 0 -2 0",key:"svg-1"}],["path",{d:"M8 11v-4a4 4 0 1 1 8 0v4",key:"svg-2"}]]);var QS=Y("map-pin","IconMapPin",[["path",{d:"M9 11a3 3 0 1 0 6 0a3 3 0 0 0 -6 0",key:"svg-0"}],["path",{d:"M17.657 16.657l-4.243 4.243a2 2 0 0 1 -2.827 0l-4.244 -4.243a8 8 0 1 1 11.314 0z",key:"svg-1"}]]);var jp=Y("mood-look-down","IconMoodLookDown",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M9 13h.01",key:"svg-1"}],["path",{d:"M15 13h.01",key:"svg-2"}],["path",{d:"M11 17h2",key:"svg-3"}]]);var ZS=Y("paperclip","IconPaperclip",[["path",{d:"M15 7l-6.5 6.5a1.5 1.5 0 0 0 3 3l6.5 -6.5a3 3 0 0 0 -6 -6l-6.5 6.5a4.5 4.5 0 0 0 9 9l6.5 -6.5",key:"svg-0"}]]);var JS=Y("photo-up","IconPhotoUp",[["path",{d:"M15 8h.01",key:"svg-0"}],["path",{d:"M12.5 21h-6.5a3 3 0 0 1 -3 -3v-12a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v6.5",key:"svg-1"}],["path",{d:"M3 16l5 -5c.928 -.893 2.072 -.893 3 0l3.5 3.5",key:"svg-2"}],["path",{d:"M14 14l1 -1c.679 -.653 1.473 -.829 2.214 -.526",key:"svg-3"}],["path",{d:"M19 22v-6",key:"svg-4"}],["path",{d:"M22 19l-3 -3l-3 3",key:"svg-5"}]]);var eC=Y("photo","IconPhoto",[["path",{d:"M15 8h.01",key:"svg-0"}],["path",{d:"M3 6a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3v-12z",key:"svg-1"}],["path",{d:"M3 16l5 -5c.928 -.893 2.072 -.893 3 0l5 5",key:"svg-2"}],["path",{d:"M14 14l1 -1c.928 -.893 2.072 -.893 3 0l3 3",key:"svg-3"}]]);var tC=Y("planet","IconPlanet",[["path",{d:"M18.816 13.58c2.292 2.138 3.546 4 3.092 4.9c-.745 1.46 -5.783 -.259 -11.255 -3.838c-5.47 -3.579 -9.304 -7.664 -8.56 -9.123c.464 -.91 2.926 -.444 5.803 .805",key:"svg-0"}],["path",{d:"M12 12m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0",key:"svg-1"}]]);var rC=Y("reload","IconReload",[["path",{d:"M19.933 13.041a8 8 0 1 1 -9.925 -8.788c3.899 -1 7.935 1.007 9.425 4.747",key:"svg-0"}],["path",{d:"M20 4v5h-5",key:"svg-1"}]]);var Il=Y("robot","IconRobot",[["path",{d:"M6 4m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v4a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z",key:"svg-0"}],["path",{d:"M12 2v2",key:"svg-1"}],["path",{d:"M9 12v9",key:"svg-2"}],["path",{d:"M15 12v9",key:"svg-3"}],["path",{d:"M5 16l4 -2",key:"svg-4"}],["path",{d:"M15 14l4 2",key:"svg-5"}],["path",{d:"M9 18h6",key:"svg-6"}],["path",{d:"M10 8v.01",key:"svg-7"}],["path",{d:"M14 8v.01",key:"svg-8"}]]);var Tu=Y("rocket","IconRocket",[["path",{d:"M4 13a8 8 0 0 1 7 7a6 6 0 0 0 3 -5a9 9 0 0 0 6 -8a3 3 0 0 0 -3 -3a9 9 0 0 0 -8 6a6 6 0 0 0 -5 3",key:"svg-0"}],["path",{d:"M7 14a6 6 0 0 0 -3 6a6 6 0 0 0 6 -3",key:"svg-1"}],["path",{d:"M15 9m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}]]);var bb=Y("row-insert-bottom","IconRowInsertBottom",[["path",{d:"M20 6v4a1 1 0 0 1 -1 1h-14a1 1 0 0 1 -1 -1v-4a1 1 0 0 1 1 -1h14a1 1 0 0 1 1 1z",key:"svg-0"}],["path",{d:"M12 15l0 4",key:"svg-1"}],["path",{d:"M14 17l-4 0",key:"svg-2"}]]);var yb=Y("row-insert-top","IconRowInsertTop",[["path",{d:"M4 18v-4a1 1 0 0 1 1 -1h14a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-14a1 1 0 0 1 -1 -1z",key:"svg-0"}],["path",{d:"M12 9v-4",key:"svg-1"}],["path",{d:"M10 7l4 0",key:"svg-2"}]]);var oC=Y("send-2","IconSend2",[["path",{d:"M4.698 4.034l16.302 7.966l-16.302 7.966a.503 .503 0 0 1 -.546 -.124a.555 .555 0 0 1 -.12 -.568l2.468 -7.274l-2.468 -7.274a.555 .555 0 0 1 .12 -.568a.503 .503 0 0 1 .546 -.124z",key:"svg-0"}],["path",{d:"M6.5 12h14.5",key:"svg-1"}]]);var wl=Y("settings","IconSettings",[["path",{d:"M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065z",key:"svg-0"}],["path",{d:"M9 12a3 3 0 1 0 6 0a3 3 0 0 0 -6 0",key:"svg-1"}]]);var El=Y("table","IconTable",[["path",{d:"M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14z",key:"svg-0"}],["path",{d:"M3 10h18",key:"svg-1"}],["path",{d:"M10 3v18",key:"svg-2"}]]);var qp=Y("trash-filled","IconTrashFilled",[["path",{d:"M20 6a1 1 0 0 1 .117 1.993l-.117 .007h-.081l-.919 11a3 3 0 0 1 -2.824 2.995l-.176 .005h-8c-1.598 0 -2.904 -1.249 -2.992 -2.75l-.005 -.167l-.923 -11.083h-.08a1 1 0 0 1 -.117 -1.993l.117 -.007h16z",fill:"currentColor",key:"svg-0",strokeWidth:"0"}],["path",{d:"M14 2a2 2 0 0 1 2 2a1 1 0 0 1 -1.993 .117l-.007 -.117h-4l-.007 .117a1 1 0 0 1 -1.993 -.117a2 2 0 0 1 1.85 -1.995l.15 -.005h4z",fill:"currentColor",key:"svg-1",strokeWidth:"0"}]]);var cn=Y("trash","IconTrash",[["path",{d:"M4 7l16 0",key:"svg-0"}],["path",{d:"M10 11l0 6",key:"svg-1"}],["path",{d:"M14 11l0 6",key:"svg-2"}],["path",{d:"M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12",key:"svg-3"}],["path",{d:"M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3",key:"svg-4"}]]);var nC=Y("triangle-filled","IconTriangleFilled",[["path",{d:"M12 1.67a2.914 2.914 0 0 0 -2.492 1.403l-8.11 13.537a2.914 2.914 0 0 0 2.484 4.385h16.225a2.914 2.914 0 0 0 2.503 -4.371l-8.116 -13.546a2.917 2.917 0 0 0 -2.494 -1.408z",fill:"currentColor",key:"svg-0",strokeWidth:"0"}]]);var aC=Y("world","IconWorld",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M3.6 9h16.8",key:"svg-1"}],["path",{d:"M3.6 15h16.8",key:"svg-2"}],["path",{d:"M11.5 3a17 17 0 0 0 0 18",key:"svg-3"}],["path",{d:"M12.5 3a17 17 0 0 1 0 18",key:"svg-4"}]]);var iC=Y("x","IconX",[["path",{d:"M18 6l-12 12",key:"svg-0"}],["path",{d:"M6 6l12 12",key:"svg-1"}]]);var sC="EditJsonModal";function vb(){let t=Ye(),e=xt();return{open:r=>{t.openContextModal(sC,{...e,innerProps:r,size:"680px"})},close:()=>{t.closeModal(sC)}}}function Ib(t){let{innerProps:e,context:r,id:o}=t,[n,a]=P(JSON.stringify(e.data||{},null,2)),[i,s]=P(!0),[l,c]=P(!1);function u(m){a(m),c(!1);try{JSON.parse(m),s(!0)}catch{s(!1)}}function d(){navigator.clipboard.writeText(n).then(()=>c(!0))}function p(){let m=JSON.parse(n);e.onSave&&e.onSave(m)}return f("div",{className:"EditJsonModal",children:[f("h3",{children:"EditJsonModal"}),f(Mc,{value:n,onChange:u,formatOnBlur:!0,autosize:!0,minRows:4,maxRows:25}),f("div",{className:"EditJsonModal__buttons",children:[f(X,{variant:"default",size:"xs",color:"dark",type:"button",onClick:()=>r.closeModal(o),children:"Cancel"}),f(X,{leftIcon:f(zp,{size:16}),variant:"filled",size:"xs",color:"dark",disabled:!i,type:"button",onClick:d,children:l?"Copied!":"Copy"}),f(X,{leftIcon:f(Vp,{size:16}),variant:"filled",size:"xs",color:"blue",disabled:!i,onClick:p,children:"Save"})]})]})}Ib.id=sC;async function Lz(){let t=window.firebase.db,e=window.__ROOT_CTX.rootConfig.projectId||"default",r=we(t,"Projects",e),o=await vr(r);if(!o.exists)return[];let a=(o.data()||{}).roles||{},i=[];return Object.entries(a).forEach(([s,l])=>{(l==="ADMIN"||l==="EDITOR")&&i.push(s)}),i}var ka=class t{constructor(e){this.spreadsheetId=e}static async create(e){let r={fields:"spreadsheetId"};e?.title&&(r.resource={properties:{title:e.title}});let n=(await gapi.client.sheets.spreadsheets.create(r)).result,a=new t(n.spreadsheetId);a.setSpreadsheet(n);let i=await Lz();return await a.share(i,"writer"),a}getUrl(){return Mn({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 wb(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,a=o.properties?.title,i=new wb(this,n??0,a);r.push(i)}),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"})}))}},wb=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[a,i]=await this.getValues(),s=[...a],l=[],c=-1,u=new Set;l.push(a.map((y,I)=>(y===o&&(c=I),n.includes(y)&&u.add(I),{hasChanges:!1,value:y})));function d(y){l[0].push({hasChanges:!0,value:y}),s.push(y)}c===-1&&d(o);let p={};i.forEach((y,I)=>{let w=I+1;l.push(y.map((v,T)=>(T===c&&v&&(v in p?console.warn(`multiple rows keyed by "${v}"`):p[v]=w),{hasChanges:!1,value:v})))});function m(y){for(let w in y)s.includes(w)||d(w);return s.map(w=>y[w]??null)}e.forEach(y=>{let I=m(y),w=y[o],v=p[w];if(v){let T=l[v];I.map((O,S)=>{S>=T.length?T.push({hasChanges:!0,value:O||""}):O!==null&&T[S].value!==O&&(!u.has(S)||!T[S].value)&&(T[S]={hasChanges:!0,value:O})})}else l.push(I.map(T=>({hasChanges:!!T,value:T||""})))});let h=s.length,g=l.length,_=a.length,x=i.length+1;(h>_||g>x)&&await this.resizeSheet({numCols:h+2,numRows:g+20});let b=[];l.forEach((y,I)=>{for(;y.length>0&&y.at(-1)?.hasChanges===!1;)y.pop();if(y.length!==0){if(y.every(w=>w.hasChanges)){b.push({range:`${this.title}!A${I+1}`,majorDimension:"ROWS",values:[y.map(w=>w.value||"")]});return}y.forEach((w,v)=>{if(w.hasChanges){let T=Bz(v);b.push({range:`${this.title}!${T}${I+1}`,majorDimension:"ROWS",values:[[w.value||""]]})}})}}),b.length>0&&await gapi.client.sheets.spreadsheets.values.batchUpdate({spreadsheetId:this.spreadsheet.spreadsheetId,resource:{data:b,valueInputOption:"RAW"}})}async replaceSheet(e,r){let o=e.length,n=r.length+1,a=[];a.push(e),a.push(...r.map(s=>e.map(l=>s[l]||""))),await this.resizeSheet({numCols:o+2,numRows:n+20}),console.log("updating cell values");let i=Bz(o-1);await gapi.client.sheets.spreadsheets.values.update({spreadsheetId:this.spreadsheet.spreadsheetId,range:`${this.title}!A1:${i}${n}`,valueInputOption:"RAW",resource:{range:`${this.title}!A1:${i}${n}`,majorDimension:"ROWS",values:a}})}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 a={};return n.forEach((i,s)=>{let l=e[s];l&&(a[l]=String(i||""))}),a})}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 Mn({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 Mn(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 Ki(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+)/),a=0;return n&&n[1]&&(a=parseInt(n[1])),{spreadsheetId:r,gid:a}}function Bz(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 Te(t){let{className:e,as:r,size:o,weight:n,color:a,children:i,...s}=t;return f(r||"h2",{...s,className:ke(e,"heading",o&&`size:${o}`,n&&`weight:${n}`,a&&`color:${a}`),children:i})}var lC="EditTranslationsModal";function Fz(){let t=Ye(),e=xt();return{open:r=>{t.openContextModal(lC,{...e,innerProps:r,size:"900px",title:"Edit translations",overflow:"inside",className:"EditTranslationsModalWrap"})},close:()=>{t.closeModal(lC)}}}function Pu(t){let{innerProps:e,context:r,id:o}=t,n=e.strings||[],i=(window.__ROOT_CTX.rootConfig.i18n||{}).locales||["en"],[s,l]=P({}),[c,u]=P([]),[d,p]=P(!1),[m,h]=P(!1),[g,_]=P(!0);L(()=>{ji({tags:[e.docId]}).then(y=>{let I={};Object.values(y).forEach(w=>{I[w.source]=w}),l(I),_(!1)})},[e.docId]);async function x(){h(!0),await bt(async()=>{console.log("EditTranslationsModal.onSave()");let y=`edit-translations-${e.docId}`;pe({id:y,loading:!0,title:"Saving translations",message:`Updating for ${e.docId}...`,autoClose:!1,disallowClose:!0});let I=[];c.forEach(w=>{let v=s[w];I.push(v)}),await gl(e.docId,I),at({id:y,title:"Saved translations",message:`Updated translations for ${e.docId}!`,autoClose:!1})}),h(!1)}function b(y){l(I=>{let w={...I};return w[y.source]=y,w}),u(I=>{let w=new Set(I);return w.add(y.source),Array.from(w)}),p(!0)}return f("div",{className:"EditTranslationsModal",children:[f("div",{className:"EditTranslationsModal__header",children:f(X,{component:"a",href:`/cms/translations/${e.docId}`,target:"_blank",variant:"default",size:"xs",children:"Open Translations Editor"})}),g?f(Re,{}):f("table",{className:"EditTranslationsModal__table",children:[f("thead",{children:f("tr",{children:[f("th",{children:f(Te,{size:"h4",weight:"semi-bold",children:"SOURCE"})}),f("th",{children:f(Te,{size:"h4",weight:"semi-bold",children:"TRANSLATIONS"})})]})}),f("tbody",{children:n.map(y=>f("tr",{children:[f("td",{children:f("div",{className:"EditTranslationsModal__table__source",children:y})}),f("td",{children:f(Pu.StringsEditor,{source:y,locales:i,translations:s[y]||{},onChange:b})})]}))})]}),f("div",{className:"EditTranslationsModal__footer",children:[e.l10nSheet&&f("div",{className:"EditTranslationsModal__footer__gsheet",children:[f("strong",{children:"NOTE:"})," Translations for this doc are managed in"," ",f("a",{href:Mn(e.l10nSheet),target:"_blank",rel:"noopener noreferrer",children:"Google Sheets"})]}),f("div",{className:"EditTranslationsModal__footer__buttons",children:[f(X,{variant:"default",size:"xs",color:"dark",type:"button",onClick:()=>r.closeModal(o),children:"Cancel"}),f(X,{variant:"filled",size:"xs",color:"dark",onClick:()=>x(),disabled:!d,loading:m,children:"Save"})]})]})]})}Pu.StringsEditor=t=>{let e=t.locales,[r,o]=P(t.translations||{}),[n,a]=P(!1);function i(s,l){a(!0),o(c=>{let u={...c,source:t.source};return u[s]=l,u})}return L(()=>{n&&t.onChange(r)},[n,r]),f("div",{className:"EditTranslationsModal__StringsEditor",children:e.map(s=>f("div",{className:"EditTranslationsModal__StringsEditor__row",children:[f("div",{className:"EditTranslationsModal__StringsEditor__row__locale",children:s}),f("div",{className:ke("EditTranslationsModal__StringsEditor__row__translation",r[s]?"hasValue":"empty"),children:f(Zt,{size:"xs",radius:0,autosize:!0,minRows:1,maxRows:10,value:r[s],onChange:l=>{i(s,l.currentTarget.value)}})})]}))})};Pu.id=lC;var fC=["https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/spreadsheets"],fde=["https://www.googleapis.com/discovery/v1/apis/drive/v3/rest","https://sheets.googleapis.com/$discovery/rest?version=v4"];function Xi(){let t=window.__ROOT_CTX.rootConfig.projectId,e=!!(window.__ROOT_CTX.gapi?.apiKey&&window.__ROOT_CTX.gapi?.clientId),[r,o]=P(e),[n,a]=P(0),[i,s]=uI({key:`root-cms::${t}::gapi-user-consent`,defaultValue:{}});async function l(){await Promise.all([mde(),hde()]),o(!1)}L(()=>{e&&l()},[]);function c(){return new Promise(d=>{let p=window.__ROOT_CTX.gapi.clientId,m=google.accounts.oauth2.initTokenClient({client_id:p,scope:fC.join(" "),callback:async h=>{let g=cC()+parseInt(h.expires_in);a(g),s({at:cC(),clientId:p,scopes:fC}),d()}});i&&pde(i)?(console.log("requesting token without prompt"),m.requestAccessToken({prompt:""})):(console.log("requesting token with prompt"),m.requestAccessToken({prompt:"consent"}))})}function u(){return cC()<n}return{enabled:e,loading:r,isLoggedIn:u,login:c}}function pde(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 fC.every(o=>r.includes(o))}function cC(){return Math.floor(new Date().getTime()/1e3)}var uC=null;async function mde(){return uC||(uC=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(fde.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)})),uC}var dC=null;async function hde(){return dC||(dC=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)})),dC}var zz="ExportSheetModal";function Uz(){let t=Ye(),e=xt();return{open:r=>{t.openContextModal(zz,{...e,title:"Export to Google Sheet",innerProps:r,size:"650px"})}}}function Ou(t){let{innerProps:e,context:r,id:o}=t,[n,a]=P(!1),[i,s]=P("new-sheet"),[l,c]=P(""),[u,d]=P(!1),p=Xi(),m=[{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."}],h=!1;(i==="add-tab"||i==="link-sheet")&&(h=!0,l&&Ki(l)?.spreadsheetId&&(h=!1));async function g(I,w){let v=w?.isNew||!1,{headers:T,rows:O}=e.csvData;v?(await I.replaceSheet(T,O),await I.applyL10nTheme()):await I.updateValuesMap(O,{keyedBy:"source",preserveColumns:e.locales})}async function _(){p.isLoggedIn()||await p.login();let I=window.__ROOT_CTX.rootConfig,w=I.projectName||I.projectId||"Root CMS",v,T,O="create-google-sheet";try{if(pe({id:O,loading:!0,title:"Creating Google Sheet...",message:"Creating Google Sheet for localization.",autoClose:!1,disallowClose:!0}),v=await ka.create({title:`${w} Localization`}),T=await v.getSheet(0),!T)throw new Error("could not find sheet gid=0");T.setTitle(e.docId)}catch(S){console.error(S);let C=S;typeof S=="object"&&S.body&&(C=String(S.body)),at({id:O,title:"Failed to create Google Sheet",message:String(C),color:"red",autoClose:!1});return}try{at({id:O,loading:!0,title:"Created Google Sheet!",message:`Linking sheet to ${e.docId}...`,autoClose:!1,disallowClose:!0});let S={spreadsheetId:v.spreadsheetId,gid:0};await pb(e.docId,S),c(T.getUrl())}catch(S){console.error(S),at({id:O,title:"Failed to link Google Sheet",message:String(S),color:"red",autoClose:!1});return}try{at({id:O,loading:!0,title:"Linked Google Sheet!",message:"Exporting strings to sheet...",autoClose:!1,disallowClose:!0}),await g(T,{isNew:!0})}catch(S){console.error(S);let C=S;typeof S=="object"&&S.body&&(C=String(S.body)),at({id:O,title:"Failed to export strings to Google Sheet",message:C,color:"red",autoClose:!1});return}d(!0),at({id:O,title:"Done! Exported strings to Google Sheet.",message:v.getUrl(),autoClose:!1})}async function x(){p.isLoggedIn()||await p.login();let I=Ki(l);if(!I?.spreadsheetId)throw new Error("failed to parse spreadsheet id");let w=new ka(I.spreadsheetId),v,T="add-tab-google-sheet";try{pe({id:T,loading:!0,title:"Creating tab in Google Sheet...",message:"Adding tab in existing Google Sheet",autoClose:!1,disallowClose:!0}),v=await w.createSheet({title:e.docId})}catch(O){console.error(O);let S=O;typeof O=="object"&&O.body&&(S=String(O.body)),at({id:T,title:"Failed to create Google Sheet",message:String(S),color:"red",autoClose:!1});return}try{at({id:T,loading:!0,title:"Created Google Sheet!",message:`Linking sheet to ${e.docId}...`,autoClose:!1,disallowClose:!0});let O={spreadsheetId:w.spreadsheetId,gid:v.gid};await pb(e.docId,O)}catch(O){console.error(O),at({id:T,title:"Failed to link Google Sheet",message:String(O),color:"red",autoClose:!1});return}try{at({id:T,loading:!0,title:"Linked Google Sheet!",message:"Exporting strings to sheet...",autoClose:!1,disallowClose:!0}),await g(v,{isNew:!0})}catch(O){console.error(O);let S=O;typeof O=="object"&&O.body&&(S=String(O.body)),at({id:T,title:"Failed to export strings to Google Sheet",message:S,color:"red",autoClose:!1});return}d(!0),at({id:T,title:"Done! Exported strings to Google Sheet.",message:v.getUrl(),autoClose:!1})}async function b(){let I="link-google-sheet",w=Ki(l);if(!w?.spreadsheetId)throw new Error("failed to parse spreadsheet id");try{pe({id:I,loading:!0,title:"Link Google Sheet",message:`Linking sheet to ${e.docId}...`,autoClose:!1,disallowClose:!0}),await pb(e.docId,w)}catch(v){console.error(v),at({id:I,title:"Failed to link Google Sheet",message:String(v),color:"red",autoClose:!1});return}d(!0),at({id:I,title:`Done! Linked ${e.docId} to Google Sheet.`,message:Mn(w),autoClose:!1})}async function y(){console.log(i),a(!0),i==="new-sheet"?await bt(_):i==="add-tab"?await bt(x):i==="link-sheet"&&await bt(b),a(!1)}return f("div",{className:"ExportSheetModal",children:f("div",{className:"ExportSheetModal__content",children:[f("div",{className:"ExportSheetModal__content__body",children:"Export strings to Google Sheet or link an existing Google Sheet for managing translations."}),f("form",{className:"ExportSheetModal__form",children:[f("div",{className:"ExportSheetModal__form__section",children:[f("div",{className:"ExportSheetModal__form__description",children:"Export options:"}),f(Pt,{itemComponent:Ou.SelectItem,data:m,onChange:I=>{s(I),I==="new-sheet"&&c("")},value:i})]}),f("div",{className:"ExportSheetModal__form__section",children:[f("div",{className:"ExportSheetModal__form__description",children:"Google Sheet URL:"}),f(gt,{disabled:i==="new-sheet",value:l,onChange:I=>c(I.currentTarget.value)})]}),f("div",{className:"ExportSheetModal__form__buttons",children:u?f(Ae,{children:[f(X,{component:"a",target:"_blank",rel:"noopener noreferrer",href:l,variant:"default",size:"xs",color:"dark",children:"Open Google Sheet"}),f(X,{variant:"filled",onClick:()=>r.closeModal(o),type:"button",size:"xs",color:"primary",children:"Done"})]}):f(Ae,{children:[f(X,{variant:"outline",onClick:()=>r.closeModal(o),type:"button",size:"xs",color:"dark",children:"Cancel"}),f(X,{variant:"filled",size:"xs",color:"primary",loading:n,disabled:h,onClick:()=>y(),children:i==="link-sheet"?"Link Google Sheet":"Export to Google Sheet"})]})})]})]})})}Ou.SelectItem=K(t=>{let{label:e,help:r,...o}=t;return f("div",{className:"ExportSheetModal__SelectItem",...o,children:[f(Me,{className:"ExportSheetModal__SelectItem__label",size:"body",children:e}),f(Me,{className:"ExportSheetModal__SelectItem__help",size:"body-sm",children:r})]})});Ou.id=zz;async function Au(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 Eb(t){let e=window.firebase.db,r=window.__ROOT_CTX.rootConfig.projectId,[o,n]=t.split("/",2),a=await Au(o),i=we(e,"Projects",r,"Collections",o,"Drafts",n),l=(await vr(i)).data()||{},c=new Set;return Gp(c,a.fields,l.fields||{}),Array.from(c)}function Gp(t,e,r){e.forEach(o=>{if(!o.id)return;let n=r[o.id];Sb(t,o,n)})}function Sb(t,e,r){if(!r)return;function o(n){let a=ei(n);a&&t.add(a)}if(e.type==="object")Gp(t,e.fields||[],r);else if(e.type==="array"){let n=r._array||[];for(let a of n)Sb(t,e.of,r[a])}else if(e.type==="string"||e.type==="select")e.translate&&o(r);else if(e.type==="image")e.translate&&r&&r.alt&&e.alt!==!1&&o(r.alt);else if(e.type==="multiselect"){if(e.translate&&Array.isArray(r))for(let n of r)o(n)}else if(e.type==="oneof"){let a=(e.types||[]).find(i=>i.name===r._type);a&&Gp(t,a.fields||[],r)}else e.type==="richtext"?e.translate&&gde(t,r):console.log(`extract: ignoring field, id=${e.id}, type=${e.type}`)}function gde(t,e){(e?.blocks||[]).forEach(o=>{_de(t,o)})}function _de(t,e){if(!e?.type)return;function r(n){if(!n)return;let a=ei(n);a&&t.add(a)}function o(n){n&&n.forEach(a=>{r(a.content),o(a.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 Vz="LocalizationModal";function Hz(t){let e=Ye(),r=xt();return{open:()=>{e.openContextModal(Vz,{...r,innerProps:t,size:"clamp(80%, 1024px, 1280px)",onClose:()=>{t.draft.flush()}})}}}function un(t){let e=t.innerProps;return f("div",{className:"LocalizationModal",children:f("div",{className:"LocalizationModal__layout",children:[f(un.ConfigLocales,{...e}),f(un.Translations,{...e})]})})}un.id=Vz;un.ConfigLocales=t=>{let[e,r]=P(()=>t.draft?t.draft.getLocales():["en"]),o=window.__ROOT_CTX.rootConfig.i18n||{},n=o.locales||["en"],a=o.groups||{default:{label:"",locales:n}};function i(c){return e.filter(u=>(a[c].locales||[]).includes(u))}function s(c,u){let d=new Set(e),p=a[c].locales||[];for(let h of p)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 f("div",{className:"LocalizationModal__locales",children:f(Fc,{spacing:30,children:[f(Gn,{children:[f(Te,{className:"LocalizationModal__iconTitle LocalizationModal__locales__title",size:"h2",children:[f(QS,{strokeWidth:1.5}),f("span",{children:"Locales"})]}),f(un.AllNoneButtons,{onAllClicked:()=>l(n),onNoneClicked:()=>l([])})]}),f(Fc,{spacing:40,children:Object.keys(a).map(c=>{let u=a[c],d=i(c);return f(un.LocaleGroup,{group:u,groupEnabledLocales:d,allEnabledLocales:e,onChange:p=>s(c,p)})})})]})})};un.LocaleGroup=t=>{let e=t.groupEnabledLocales||[],r=t.group.locales||[],o=t.allEnabledLocales||[];function n(i){t.onChange&&t.onChange(i)}function a(i){let s=e.indexOf(i);s===-1?e.push(i):e.splice(s,1),n(e)}return f(Fc,{spacing:16,children:[t.group.label&&f(Gn,{position:"apart",children:[f(Te,{size:"h4",weight:"semi-bold",children:t.group.label}),f(un.AllNoneButtons,{onAllClicked:()=>n(r),onNoneClicked:()=>n([])})]}),f(Gn,{children:r.map(i=>{let s=e.includes(i),l=o.length<=1&&s;return f(Rc,{value:i,checked:s,disabled:l,label:$z(i),onChange:()=>a(i),size:"xs"})})})]})};un.AllNoneButtons=t=>f(Gn,{spacing:"8px",children:[f(X,{variant:"subtle",size:"xs",compact:!0,onClick:t.onAllClicked,sx:e=>({"&:hover":{backgroundColor:e.colors.gray[0]}}),children:"All"}),"/",f(X,{variant:"subtle",size:"xs",compact:!0,onClick:t.onNoneClicked,sx:e=>({"&:hover":{backgroundColor:e.colors.gray[0]}}),children:"None"})]});un.Translations=t=>{let[e,r]=P(!0),[o,n]=P([]),[a,i]=P("en"),[s,l]=P({}),[c,u]=P({}),d=Xi(),[p,m]=P(null),h=Uz(),g=Tt(()=>{let N={};return Object.values(c).forEach(R=>{N[R.source]=R}),N},[c]),_=window.__ROOT_CTX.rootConfig.i18n?.locales||[],x=_.map(N=>({value:N,label:$z(N)}));L(()=>{r(!0),Promise.all([Eb(t.docId),ji(),mb(t.docId)]).then(([N,R,z])=>{n(N),u(R),m(z),r(!1)})},[t.docId]),L(()=>{if(!a){l({});return}let N={};Object.values(c).forEach(R=>{N[R.source]=R[a]||""}),l(N)},[a,c]);function b(N,R){let z=g[N];return z&&z[R]||""}function y(){let N=_.filter(B=>B!=="en"),R=["source","en",...N],z=[];return o.forEach(B=>{let M={source:B,en:b(B,"en")||B};N.forEach(V=>{M[V]=b(B,V)}),z.push(M)}),{headers:R,rows:z}}async function I(){let{headers:N,rows:R}=y(),z=await window.fetch("/cms/api/csv.download",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({headers:N,rows:R})});if(z.status!==200){console.error("csv.download failed:");let V=await z.text();console.error(V)}let B=await z.blob(),M=window.URL.createObjectURL(B);window.location.assign(M),window.URL.revokeObjectURL(M)}async function w(){let N=document.createElement("input");N.type="file",N.accept=".csv",N.addEventListener("change",async()=>{let R=N.files?.[0];if(R){let z=new FormData;z.append("file",R);try{let B=await fetch("/cms/api/csv.import",{method:"POST",body:z});if(B.status!==200){let U=await B.text();throw new Error(`RPCError: ${U}`)}let M=(await B.json()).data,V=await gl(t.docId,M);u(U=>Object.assign({},U,V)),pe({title:"Saved!",message:`Imported translations for ${t.docId}.`,autoClose:5e3})}catch(B){console.error(B),pe({title:"Failed to import CSV",message:String(B),color:"red",autoClose:!1})}}}),N.click()}async function v(){if(d.isLoggedIn()||await d.login(),!p?.spreadsheetId)throw new Error("no sheet linked");let R=await new ka(p.spreadsheetId).getSheet(p.gid??0);if(!R)throw new Error(`sheet not found: ${JSON.stringify(p)}`);await T(R),pe({title:"Exported strings to Google Sheet",message:R.getUrl(),autoClose:!1})}async function T(N,R){let z=R?.isNew||!1,{headers:B,rows:M}=y();z?(await N.replaceSheet(B,M),await N.applyL10nTheme()):await N.updateValuesMap(M,{keyedBy:"source",preserveColumns:_}),Je("doc.export_to_sheet",{metadata:{docId:t.docId,sheetId:{spreadsheetId:N.spreadsheet.spreadsheetId,gid:N.gid}}})}async function O(){if(d.isLoggedIn()||await d.login(),!p?.spreadsheetId)throw new Error("no sheet linked");let R=await new ka(p.spreadsheetId).getSheet(p.gid??0);if(!R)throw new Error(`sheet not found: ${JSON.stringify(p)}`);console.log("importing google sheet");let z=await R.getValuesMap(),B=await gl(t.docId,z);u(M=>Object.assign({},M,B)),pe({title:"Saved!",message:`Imported translations for ${t.docId}.`,autoClose:5e3})}async function S(){await wz(t.docId),m(null),pe({title:"Unlinked Google Sheet",message:`${t.docId} is no longer connected to a Google Sheet.`,autoClose:5e3})}async function C(N){try{await N()}catch(R){console.error(R);let z;typeof R=="object"&&R.body?z=String(R.body):z=String(R),pe({title:"Error",message:z,color:"red",autoClose:!1})}}function F(N){switch(N){case"EXPORT_DOWNLOAD_CSV":{C(I);return}case"EXPORT_GOOGLE_SHEET_LINKED":{C(v);return}case"EXPORT_GOOGLE_SHEET_SHOW_OPTIONS":{h.open({docId:t.docId,csvData:y(),locales:_});return}case"IMPORT_CSV":{C(w);return}case"IMPORT_GOOGLE_SHEET_LINKED":{C(O);return}case"UNLINK_GOOGLE_SHEET":{C(S);return}default:console.log("unhandled action: "+N)}}return e?f("div",{className:"LocalizationModal__translations__loading",children:f(Re,{color:"gray",size:"xl"})}):f("div",{className:"LocalizationModal__translations",children:[f("div",{className:"LocalizationModal__translations__header",children:[f("div",{className:"LocalizationModal__translations__titleWrap",children:[f(Te,{className:"LocalizationModal__translations__title LocalizationModal__iconTitle",size:"h2",children:[f(Wi,{strokeWidth:1.5})," ",f("span",{children:"Translations"})]}),f(X,{component:"a",href:`/cms/translations/${t.docId}`,target:"_blank",variant:"default",size:"xs",children:"Open Translations Editor"})]}),f("div",{className:"LocalizationModal__translations__header__buttons",children:[d.enabled&&p?.spreadsheetId&&f(xe,{label:"Open Google Sheet",children:f(Fe,{component:"a",href:Mn(p),target:"_blank",variant:"filled",color:"green",size:"sm",children:f(El,{size:16,strokeWidth:2.25})})}),f(xde,{onAction:F,gapiClient:d,linkedSheet:p}),f(bde,{onAction:F,gapiClient:d,linkedSheet:p})]})]}),f("table",{className:"LocalizationModal__translations__table",children:[f("tr",{className:"LocalizationModal__translations__table__row LocalizationModal__translations__table__row--header",children:[f("th",{className:"LocalizationModal__translations__table__header",children:f(Te,{size:"h4",weight:"semi-bold",children:"SOURCE STRING"})}),f("th",{className:"LocalizationModal__translations__table__header",children:f(Te,{className:"LocalizationModal__translations__localeSelect",size:"h4",weight:"semi-bold",children:[f("span",{children:"LOCALE: "})," ",f(Pt,{data:x,size:"xs",placeholder:"select locale",allowDeselect:!0,value:a,onChange:N=>i(N)})]})})]}),o.map((N,R)=>f("tr",{className:"LocalizationModal__translations__table__row",children:[f("td",{className:"LocalizationModal__translations__table__col",children:f(ne,{sx:z=>({backgroundColor:z.colors.gray[0],border:`1px solid ${z.colors.gray[3]}`,padding:"10px 20px",borderRadius:4,height:"100%"}),children:f(jt,{size:"xs",sx:{whiteSpace:"pre-wrap"},children:N})})}),f("td",{className:"LocalizationModal__translations__table__col",children:f(ne,{sx:z=>({backgroundColor:z.colors.gray[0],border:`1px solid ${z.colors.gray[3]}`,padding:"10px 20px",borderRadius:4,height:"100%"}),children:f(jt,{size:"xs",sx:{whiteSpace:"pre-wrap"},children:s[N]||" "})})})]},R))]})]})};function xde(t){function e(o){t.onAction&&t.onAction(o)}let r=t.linkedSheet;return f(ze,{className:"LocalizationModal__translations__menu",position:"bottom",placement:"end",control:f(X,{variant:"default",color:"dark",size:"xs",leftIcon:f(ti,{size:16,strokeWidth:1.75}),rightIcon:f(Cu,{size:16,strokeWidth:1.75}),children:"Import"}),children:[t.gapiClient.enabled&&f(Ae,{children:[f(ze.Label,{children:"Google Sheets"}),f(ze.Item,{className:"LocalizationModal__translations__menu__item",disabled:!r?.spreadsheetId,onClick:()=>e("IMPORT_GOOGLE_SHEET_LINKED"),children:"Import Google Sheet"}),f(ja,{})]}),f(ze.Label,{children:"File"}),f(ze.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("IMPORT_CSV"),children:"Import .csv"})]})}function bde(t){async function e(n){t.onAction&&t.onAction(n)}let o=!!t.linkedSheet?.spreadsheetId;return f(ze,{className:"LocalizationModal__translations__menu",position:"bottom",placement:"start",control:f(X,{variant:"default",color:"dark",size:"xs",leftIcon:f(bl,{size:16,strokeWidth:1.75}),rightIcon:f(Cu,{size:16,strokeWidth:1.75}),children:"Export"}),children:[t.gapiClient.enabled&&f(Ae,{children:[f(ze.Label,{children:"Google Sheets"}),o?f(Ae,{children:f(ze.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("EXPORT_GOOGLE_SHEET_LINKED"),children:"Export to Google Sheet"})}):f(Ae,{children:f(ze.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("EXPORT_GOOGLE_SHEET_SHOW_OPTIONS"),children:"Export to Google Sheet"})}),f(ja,{})]}),f(ze.Label,{children:"File"}),f(ze.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("EXPORT_DOWNLOAD_CSV"),children:"Download .csv"}),o&&f(Ae,{children:[f(ja,{}),f(ze.Label,{children:"Danger zone"}),f(ze.Item,{className:"LocalizationModal__translations__menu__item",onClick:()=>e("UNLINK_GOOGLE_SHEET"),color:"red",children:"Unlink Google Sheet"})]})]})}function $z(t){let e=t.split("_"),r=e[0];if(r==="ALL"){let a=String(e[1]).toUpperCase();return`${new Intl.DisplayNames(["en"],{type:"region"}).of(a)||t} (${t})`}return`${new Intl.DisplayNames(["en"],{type:"language"}).of(r)||t} (${t})`}var jz="LockPublishingModal";function qz(t){let e=Ye(),r=xt();return{open:o=>{let a={...t,...o}.unlock?`Unlock publishing for ${t.docId}`:`Lock publishing for ${t.docId}`;e.openContextModal(jz,{...r,title:a,innerProps:{...t,...o},size:"600px"})}}}function Yi(t){let{innerProps:e}=t;return e.unlock?f(Yi.Unlock,{...t}):f(Yi.Lock,{...t})}Yi.Lock=t=>{let{innerProps:e,context:r,id:o}=t,[n,a]=P(""),[i,s]=P(0),[l,c]=P(!1),u=Ye();function d(m){return m?Math.floor(new Date(m).getTime()):0}async function p(m){m.preventDefault(),c(!0),await bt(async()=>{await xz(e.docId,{reason:n,until:i}),pe({title:"Locked!",message:`Publishing is locked for ${e.docId}.`,autoClose:1e4}),u.closeModal(o)})}return f("div",{className:"LockPublishingModal LockPublishingModal--lock",children:[f(Me,{className:"LockPublishingModal__body",children:"Are you sure you want to lock publishing? Content editors will not be able to publish until publishing is unlocked."}),f("form",{className:"LockPublishingModal__form",onSubmit:m=>p(m),children:[f("div",{className:"LockPublishingModal__form__section",children:f(gt,{name:"reason",label:"Reason",description:"Specify a short reason so other content editors know why publishing is locked.",size:"xs",radius:0,onChange:m=>{a(m.currentTarget.value)}})}),f("div",{className:"LockPublishingModal__form__section",children:f(Ho,{label:"Lock until",description:"Optional. Publishing is unlocked at the specified time. If not provided, publishing will be locked indefinitely.",size:"xs",children:f("div",{className:"DocEditor__DateTimeField",children:[f("input",{name:"until",type:"datetime-local",min:Eu(),onChange:m=>{let g=m.target.value;s(d(g))}}),f("div",{className:"DocEditor__DateTimeField__timezone",children:["timezone: ",Intl.DateTimeFormat().resolvedOptions().timeZone]})]})})}),f("div",{className:"LockPublishingModal__buttons",children:[f(X,{variant:"outline",onClick:()=>r.closeModal(o),type:"button",size:"xs",color:"dark",children:"Cancel"}),f(X,{variant:"filled",size:"xs",color:"dark",leftIcon:f(vl,{size:14}),disabled:!n,type:"submit",loading:l,children:"Lock"})]})]})]})};Yi.Unlock=t=>{let{innerProps:e,context:r,id:o}=t,[n,a]=P(!1),i=Ye();async function s(){a(!0),await bt(async()=>{await bz(e.docId),pe({title:"Unlocked!",message:`Publishing is unlocked for ${e.docId}.`,autoClose:1e4}),i.closeModal(o)})}return f("div",{className:"LockPublishingModal LockPublishingModal--unlock",children:[f(Me,{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."]}),f("div",{className:"LockPublishingModal__buttons",children:[f(X,{variant:"outline",onClick:()=>r.closeModal(o),type:"button",size:"xs",color:"dark",children:"Cancel"}),f(X,{variant:"filled",size:"xs",color:"dark",leftIcon:f($p,{size:14}),loading:n,onClick:()=>s(),children:"Unlock"})]})]})};Yi.id=jz;var gC=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(gC).filter(r=>typeof r<"u");let e={};for(let[r,o]of Object.entries(t)){let n=gC(o);typeof n<"u"&&(e[r]=n)}return e},Gz=gC,yde=(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,a=o+n,i=new Array(a);if(r){for(let s=0;s<n;s++)i[s]=e[n-s-1];for(let s=0;s<o;s++)i[s+n]=t[s];return i}for(let s=0;s<o;s++)i[s]=t[s];for(let s=0;s<n;s++)i[s+o]=e[s];return i},Ot=yde,_C=(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(_C(t[r],e))return!0;return!1}for(let r in t)if(_C(t[r],e))return!0;return!1},vde=_C,xC=(t,e,r,o=1/0,n)=>{if(!t||typeof t!="object"){let i;if(!Number.isNaN(t)&&t!==1/0&&t!==-1/0&&typeof t!="bigint"&&(i=JSON.stringify(t,e,r)),i===void 0)switch(n){case Xp.throw:throw new Error(`Value is not valid in JSON, got ${String(t)}`);case Xp.stringify:return Ide(t);default:throw new Error("Should not reach here, please report this bug.")}return i}let a=o<1?'"..."':Array.isArray(t)?`[${t.map(i=>xC(i,e,r,o-1,n)).join(",")}]`:`{${Object.keys(t).map(i=>`"${i}": ${xC(t[i],e,r,o-1,n)}`).join(", ")}}`;return JSON.stringify(JSON.parse(a),e,r)},Ide=t=>t===void 0?"undefined":t===1/0?"Infinity":t===-1/0?"-Infinity":Number.isNaN(t)?"NaN":typeof t=="bigint"?`${t}n`:String(t),Ur=xC,wde=(t,e=1/0,r=!1,o=Xp.stringify)=>t===null?"null":Array.isArray(t)||typeof t=="object"?Ur(t,void 0,r?1:void 0,e,o):Ur(t,void 0,void 0,void 0,o),Ln=wde,Wz=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,Ede=(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 a=Wz(t),i=Wz(e);if(a!==i)return a-i;if(t===null&&e===null||Array.isArray(t)&&Array.isArray(e)||a===5&&i===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))},Yp=Ede,Sde=t=>Array.isArray(t)?"array":t===null?"null":typeof t,ea=Sde,Cde=(t,e,r,o,n,a,i,s)=>{let l={ignoreCase:s.ignoreCase},c=Ln(n,s.maxDepth,!0,s.undefinedBehavior).split(`
|
|
38
38
|
`),u=Ln(a,s.maxDepth,!0,s.undefinedBehavior).split(`
|
|
39
39
|
`);if(Yp(n,a,l)!==0)if(s.showModifications){let d=Math.max(c.length,u.length);for(let p=c.length;p<d;p++)c.push("");for(let p=u.length;p<d;p++)u.push("");t.push({level:i,type:"modify",text:r?`"${r}": ${c[0]}`:c[0]});for(let p=1;p<c.length;p++)t.push({level:i+(c[p].match(/^\s+/)?.[0]?.length||0),type:"modify",text:c[p].replace(/^\s+/,"").replace(/,$/g,"")});for(let p=c.length;p<d;p++)t.push({level:i,type:"equal",text:""});e.push({level:i,type:"modify",text:o?`"${o}": ${u[0]}`:u[0]});for(let p=1;p<u.length;p++)e.push({level:i+(u[p].match(/^\s+/)?.[0]?.length||0),type:"modify",text:u[p].replace(/^\s+/,"").replace(/,$/g,"")});for(let p=u.length;p<d;p++)e.push({level:i,type:"equal",text:""})}else{t.push({level:i,type:"remove",text:r?`"${r}": ${c[0]}`:c[0]});for(let d=1;d<c.length;d++)t.push({level:i+(c[d].match(/^\s+/)?.[0]?.length||0),type:"remove",text:c[d].replace(/^\s+/,"").replace(/,$/g,"")});for(let d=0;d<u.length;d++)t.push({level:i,type:"equal",text:""});for(let d=0;d<c.length;d++)e.push({level:i,type:"equal",text:""});e.push({level:i,type:"add",text:o?`"${o}": ${u[0]}`:u[0]});for(let d=1;d<u.length;d++)e.push({level:i+(u[d].match(/^\s+/)?.[0]?.length||0),type:"add",text:u[d].replace(/^\s+/,"").replace(/,$/g,"")})}else{let d=Math.max(c.length,u.length);for(let p=c.length;p<d;p++)c.push("");for(let p=u.length;p<d;p++)u.push("");t.push({level:i,type:"equal",text:r?`"${r}": ${c[0]}`:c[0]});for(let p=1;p<c.length;p++)t.push({level:i+(c[p].match(/^\s+/)?.[0]?.length||0),type:"equal",text:c[p].replace(/^\s+/,"").replace(/,$/g,"")});e.push({level:i,type:"equal",text:o?`"${o}": ${u[0]}`:u[0]});for(let p=1;p<u.length;p++)e.push({level:i+(u[p].match(/^\s+/)?.[0]?.length||0),type:"equal",text:u[p].replace(/^\s+/,"").replace(/,$/g,"")})}},Cl=Cde,kde=(t,e)=>t.sort((r,o)=>Yp(r,o,{ignoreCase:e.ignoreCaseForKey})),Kz=kde,EU=(t,e,r=1,o,n)=>{if(r>(o.maxDepth||1/0))return[[{level:r,type:"equal",text:"..."}],[{level:r,type:"equal",text:"..."}]];let a=[],i=[];if(t===null&&e===null||t===void 0&&e===void 0)return[a,i];if(t==null){let d=Ur(e,void 0,1,void 0,o.undefinedBehavior).split(`
|
|
40
40
|
`);for(let p=0;p<d.length;p++)a.push({level:r,type:"equal",text:""}),i.push({level:r+(d[p].match(/^\s+/)?.[0]?.length||0),type:"add",text:d[p].replace(/^\s+/,"").replace(/,$/g,"")});return[a,i]}else if(e==null){let d=Ur(t,void 0,1,void 0,o.undefinedBehavior).split(`
|
|
@@ -50,7 +50,7 @@ Content-Type: `+c.contentType+`\r
|
|
|
50
50
|
`).map(d=>({level:d.match(/^\s+/)?.[0]?.length||0,type:"remove",text:d.replace(/^\s+/,"").replace(/,$/g,""),comma:d.endsWith(",")})),n=Ur(r,void 0,1,this.options.maxDepth,this.options.undefinedBehavior).split(`
|
|
51
51
|
`).map(d=>({level:d.match(/^\s+/)?.[0]?.length||0,type:"add",text:d.replace(/^\s+/,"").replace(/,$/g,""),comma:d.endsWith(",")}));let c=o.length,u=n.length;o=Ot(o,Array(u).fill(0).map(()=>({...Tb}))),n=Ot(n,Array(c).fill(0).map(()=>({...Tb})),!0)}else a==="object"?([o,n]=Ob(e,r,1,this.options,this.arrayDiffFunc),o.unshift({...IU}),o.push({...wU}),n.unshift({...IU}),n.push({...wU})):a==="array"?[o,n]=this.arrayDiffFunc(e,r,"","",0,this.options):e!==r?this.options.ignoreCase?typeof e=="string"&&typeof r=="string"&&e.toLowerCase()===r.toLowerCase()&&(o=[{level:0,type:"equal",text:e}],n=[{level:0,type:"equal",text:r}]):this.options.showModifications?(o=[{level:0,type:"modify",text:Ur(e,void 0,void 0,this.options.maxDepth,this.options.undefinedBehavior)}],n=[{level:0,type:"modify",text:Ur(r,void 0,void 0,this.options.maxDepth,this.options.undefinedBehavior)}]):(o=[{level:0,type:"remove",text:Ur(e,void 0,void 0,this.options.maxDepth,this.options.undefinedBehavior)},{...Tb}],n=[{...Tb},{level:0,type:"add",text:Ur(r,void 0,void 0,this.options.maxDepth,this.options.undefinedBehavior)}]):(o=[{level:0,type:"equal",text:Ur(e,void 0,void 0,this.options.maxDepth,this.options.undefinedBehavior)}],n=[{level:0,type:"equal",text:Ur(r,void 0,void 0,this.options.maxDepth,this.options.undefinedBehavior)}]);return this.sortResultLines(o,n),this.calculateLineNumbers(o),this.calculateLineNumbers(n),this.calculateCommas(o),this.calculateCommas(n),[o,n]}constructor({detectCircular:e=!0,maxDepth:r=1/0,showModifications:o=!0,arrayDiffMethod:n="normal",ignoreCase:a=!1,ignoreCaseForKey:i=!1,recursiveEqual:s=!1,preserveKeyOrder:l,undefinedBehavior:c="stringify"}={}){this.options={detectCircular:e,maxDepth:r,showModifications:o,arrayDiffMethod:n,ignoreCase:a,ignoreCaseForKey:i,recursiveEqual:s,preserveKeyOrder:l,undefinedBehavior:c},this.arrayDiffFunc=n==="lcs"||n==="unorder-lcs"?nxe:axe}};var Qi=t=>"hasLinesBefore"in t||"hasLinesAfter"in t,ixe=(t,e,r)=>Qi(t)?r:e*(t.end-t.start+1),FU=(t,e)=>{let r=[],o,n;if(t.length&&e.length)for(t=[...t],e=[...e],o={...t.shift()},n={...e.shift()};;){if(o.start===n.start){let a=Math.min(o.end,n.end);r.push({...o,...n,end:a}),o.start=n.start=a}else if(o.start<n.start){let a=Math.min(o.end,n.start);r.push({...n,...o,end:a}),o.start=a}else{let a=Math.min(o.start,n.end);r.push({...o,...n,end:a}),n.start=a}if(!t.length||!e.length)break;o.start===o.end&&(o={...t.shift()}),n.start===n.end&&(n={...e.shift()})}return t.length||r.push(...e.map(a=>({...a,token:o.token||"plain"}))),e.length||r.push(...t),r},sxe=(t,e,r,o,n,a,i,s,l)=>{if(!e.length)return[0,0];let c=0,u=0,d=t[r];Qi(d)?c=e[r]:c=e[r]+(o-d.start)*i;let p=t[n];return Qi(p)?u=l-e[n]-s:u=l-e[n]-(a-p.start)*i,[c,u]},lxe=sxe,cxe=(t,e,r,o,n,a)=>{if(!e.length)return[0,0,0,0];let i=0,s=0,l=0,c=0,u=0,d=t.length-1;for(;;){let h=Math.floor((u+d)/2);if(e[h]+ixe(t[h],n,a)<=r?u=h+1:d=h,u===d){i=u;break}}let p=t[i];for(Qi(p)?l=p.start:l=p.start+Math.floor((r-e[i])/n),u=0,d=t.length-1;;){let h=Math.floor((u+d+1)/2);if(e[h]>=o?d=h-1:u=h,u===d){s=u;break}}let m=t[s];return Qi(m)?c=m.end:c=m.start+Math.ceil((o-e[s])/n),[i,l,s,c]},uxe=cxe,ta={};Object.defineProperty(ta,"__esModule",{value:!0});ta.applyPatch=ta.calcPatch=AC=ta.lcs=ta.diff=ta.diff_core=void 0;function dxe(t,e){let{b:r,eq:o,stack_base:n}=t,{i:a,N:i,j:s,M:l,Z:c,stack_top:u}=t;for(;;)switch(e){case 0:{e:for(;i>0&&l>0;){r.fill(0,0,2*c);let d=i-l,p=i+l,m=p&1,h=a+i-1,g=s+l-1,_=(p+m)/2,x;t:for(let b=0;b<=_;b++){let y=2*Math.max(0,b-l)-b,I=b-2*Math.max(0,b-i);for(let w=y;w<=I;w+=2){let v=r[w-1-c*Math.floor((w-1)/c)],T=r[w+1-c*Math.floor((w+1)/c)],O=w===-b||w!==b&&v<T?T:v+1,S=O-w,C=O,F=S;for(;C<i&&F<l&&o(a+C,s+F);)C++,F++;if(r[w-c*Math.floor(w/c)]=C,m===1&&(x=d-w)>=1-b&&x<b&&C+r[c+x-c*Math.floor(x/c)]>=i)if(b>1||C!==O){n[u++]=a+C,n[u++]=i-C,n[u++]=s+F,n[u++]=l-F,i=O,l=S,c=2*(Math.min(i,l)+1);continue e}else break t}for(let w=y;w<=I;w+=2){let v=r[c+w-1-c*Math.floor((w-1)/c)],T=r[c+w+1-c*Math.floor((w+1)/c)],O=w===-b||w!==b&&v<T?T:v+1,S=O-w,C=O,F=S;for(;C<i&&F<l&&o(h-C,g-F);)C++,F++;if(r[c+w-c*Math.floor(w/c)]=C,m===0&&(x=d-w)>=-b&&x<=b&&C+r[x-c*Math.floor(x/c)]>=i)if(b>0||C!==O){n[u++]=a+i-O,n[u++]=O,n[u++]=s+l-S,n[u++]=S,i=i-C,l=l-F,c=2*(Math.min(i,l)+1);continue e}else break t}}if(i!==l){l>i?(a+=i,s+=i,l-=i,i=0):(a+=l,s+=l,i-=l,l=0);break}}if(i+l!==0)if(t.pxe===a||t.pye===s)t.pxe=a+i,t.pye=s+l;else{let d=t.pxs;if(t.oxs=t.pxs,t.oxe=t.pxe,t.oys=t.pys,t.oye=t.pye,t.pxs=a,t.pxe=a+i,t.pys=s,t.pye=s+l,d>=0)return t.i=a,t.N=i,t.j=s,t.M=l,t.Z=c,t.stack_top=u,1}}case 1:{if(u===0)return 2;l=n[--u],s=n[--u],i=n[--u],a=n[--u],c=2*(Math.min(i,l)+1),e=0}}}var fxe=class{[Symbol.iterator](){return this}next(){let{state:e,result:r}=this;if(this.c>1)return r.done=!0,r.value=void 0,r;let o=dxe(e,this.c);return this.c=o,o===1?(r.value=[e.oxs,e.oxe,e.oys,e.oye],r):e.pxs>=0?(r.value=[e.pxs,e.pxe,e.pys,e.pye],r):(r.done=!0,r.value=void 0,r)}constructor(e){this.state=e,this.c=0,this.result={value:null,done:!1}}};function jU(t,e,r,o,n){let a=(Math.min(e,o)+1)*2,i=e+o,s=new(i<256?Uint8Array:i<65536?Uint16Array:Uint32Array)(2*a);return new fxe({i:t,N:e,j:r,M:o,Z:a,b:s,eq:n,pxs:-1,pxe:-1,pys:-1,pye:-1,oxs:-1,oxe:-1,oys:-1,oye:-1,stack_top:0,stack_base:[]})}ta.diff_core=jU;function DC(t,e){let[r,o,n]=[0,t.length,e.length];for(;r<o&&r<n&&t[r]===e[r];)r++;if(r===o&&r===n)return[][Symbol.iterator]();for(;t[--o]===e[--n]&&o>r&&n>r;);let a=(i,s)=>t[i]===e[s];return jU(r,o+1-r,r,n+1-r,a)}ta.diff=DC;var pxe=class{[Symbol.iterator](){return this}next(){let e=this.diff.next();if(e.done){let{i:l,j:c,N:u}=this;return l<u&&(e.done=!1,e.value=[l,c,u-l],this.i=u),e}let r=e.value,o=r[0],n=r[1],a=r[3],{i,j:s}=this;return i!==o&&(r.length--,r[0]=i,r[1]=s,r[2]=o-i),this.i=n,this.j=a,e}constructor(e,r){this.diff=e,this.N=r,this.i=0,this.j=0}};function mxe(t,e){return new pxe(DC(t,e),t.length)}var AC=ta.lcs=mxe;function*hxe(t,e){let r=ArrayBuffer.isView(t)?Uint8Array.prototype.subarray:t.slice;for(let o of DC(t,e))o[2]=r.call(e,o[2],o[3]),yield o}ta.calcPatch=hxe;function*gxe(t,e){let r=0,o=ArrayBuffer.isView(t)?Uint8Array.prototype.subarray:t.slice;for(let[n,a,i]of e)r<n&&(yield o.call(t,r,n)),i.length>0&&(yield i),r=a;r<t.length&&(yield o.call(t,r))}ta.applyPatch=gxe;var zU=(t,e)=>{let r=[],o=0;for(let n of t)r.push(o),o+=n.length+e;return r.push(o-e),r},zb=t=>t.filter(e=>e.end>e.start),_xe=(t,e,r)=>{let o=[],n=[],a=0,i=0;if(r.mode==="word"){let l=r.wordSeparator||" ",c=t.split(l),u=e.split(l),d=[...AC(c,u)],p=l.length,m=zU(c,p),h=zU(u,p);for(let[g,_,x]of d)g>a&&o.push({type:"remove",start:m[a],end:m[g]}),_>i&&n.push({type:"add",start:h[i],end:h[_]}),a=g+x,i=_+x,o.push({start:m[g],end:m[a]}),n.push({start:h[_],end:h[i]});return t.length>a&&o.push({type:"remove",start:m[a],end:t.length}),e.length>i&&n.push({type:"add",start:h[i],end:e.length}),o=zb(o),n=zb(n),[o,n]}let s=AC(t,e);for(let[l,c,u]of s)l>a&&o.push({type:"remove",start:a,end:l}),c>i&&n.push({type:"add",start:i,end:c}),a=l+u,i=c+u,o.push({start:l,end:a}),n.push({start:c,end:i});return t.length>a&&o.push({type:"remove",start:a,end:t.length}),e.length>i&&n.push({type:"add",start:i,end:e.length}),o=zb(o),n=zb(n),[o,n]},xxe=_xe,qU=(t,e,r)=>{if(!t)return[{token:"plain",start:r,end:e.length+r}];if(e==="undefined"||e==="Infinity"||e==="-Infinity"||e==="NaN"||/^\d+n$/i.test(e)||e.startsWith("Symbol(")||e.startsWith("function")||e.startsWith("("))return[{token:"invalid",start:r,end:e.length+r}];if(!Number.isNaN(Number(e)))return[{token:"number",start:r,end:e.length+r}];if(e==="true"||e==="false")return[{token:"boolean",start:r,end:e.length+r}];if(e==="null")return[{token:"null",start:r,end:e.length+r}];if(e.startsWith('"')){if(e.endsWith(": [")||e.endsWith(": {"))return[{token:"key",start:r,end:e.length-3+r},{token:"punctuation",start:e.length-3,end:e.length-2+r},{token:"plain",start:e.length-2,end:e.length-1+r},{token:"punctuation",start:e.length-1,end:e.length+r}];let o=1;for(;o<e.length&&e[o]!=='"';)e[o]==="\\"&&++o,++o;return o===e.length-1?[{token:"string",start:r,end:e.length+r}]:[{token:"key",start:r,end:o+1+r},{token:"punctuation",start:o+1,end:o+2+r},{token:"plain",start:o+2,end:o+3+r},...qU(t,e.substring(o+3),r+o+3)]}return e==="{"||e==="}"||e==="["||e==="]"?[{token:"punctuation",start:r,end:e.length+r}]:[{token:"plain",start:r,end:e.length+r}]},UU=qU,VU={threshold:8,margin:3},bxe=(t,e,r,o)=>{if(!r||o)return[{start:0,end:t.length,isEqual:!1}];let n=[];for(let c=0;c<t.length;c++)t[c].type==="equal"&&e[c].type==="equal"?n.length&&n[n.length-1].isEqual?n[n.length-1].end++:n.push({start:c,end:c+1,isEqual:!0}):n.length&&!n[n.length-1].isEqual?n[n.length-1].end++:n.push({start:c,end:c+1,isEqual:!1});let a=r===!0?VU:{...VU,...r},{threshold:i,margin:s}=a;i<s*2+1&&console.warn(`Threshold (${i}) is no more than 2 margins + 1 "expand" line (${s} * 2 + 1), it's not necessary to hide unchanged areas which have less than ${s*2+1} lines.`);let l=[];for(let c=0;c<n.length;c++){let u=n[c];if(!u.isEqual||u.end-u.start<i||u.end-u.start<=s*2+1){l.push(u);continue}c?c===n.length-1?(l.push({start:u.start,end:u.start+s,isEqual:!0}),l.push({hasLinesBefore:!1,hasLinesAfter:!0,start:u.start+s,end:t.length,isEqual:!0})):(l.push({start:u.start,end:u.start+s,isEqual:!0}),l.push({hasLinesBefore:!0,hasLinesAfter:!0,start:u.start+s,end:u.end-s,isEqual:!0}),l.push({start:u.end-s,end:u.end,isEqual:!0})):(l.push({hasLinesBefore:!0,hasLinesAfter:!1,start:0,end:u.end-s,isEqual:!0}),l.push({start:u.end-s,end:u.end,isEqual:!0}))}return l},HU=bxe,yxe=2,$U=20,vxe={noChangeDetected:"No change detected"},Ub=t=>{let[e,r]=t.diff,o=Tt(()=>e.length===r.length&&e.every(U=>U.type==="equal")&&r.every(U=>U.type==="equal"),[e,r]),n={...vxe,...t.texts},a=t.lineNumbers?`calc(${String(e.length).length}ch + 16px)`:0,i=t.indent??yxe,s=i==="tab"?" ":" ",l=i==="tab"?1:i,c={mode:t.inlineDiffOptions?.mode||"char",wordSeparator:t.inlineDiffOptions?.wordSeparator||""},u=t.hideUnchangedLines??!1,{scrollContainer:d="body",itemHeight:p=18,expandLineHeight:m=26}=!t.virtual||t.virtual===!0?{}:t.virtual,h=d==="body"?document.body:document.querySelector(d),g=H(e),_=H(r),x=H(HU(e,r,u,o)),b=H([]),y=H(0),I=H(null),[,w]=P({}),v=()=>{if(b.current=[],t.virtual){let U=0;for(let G of x.current)Qi(G)?(b.current.push(U),U+=m):(b.current.push(U),U+=p*(G.end-G.start));y.current=x.current.reduce((G,k)=>Qi(k)?G+m:G+(k.end-k.start)*p,0)}w({})};L(()=>{g.current=e,_.current=r,x.current=HU(e,r,u,o),v()},[u,e,r]),L(()=>{if(!t.virtual||!h)return;let U=()=>w({});return h.addEventListener("scroll",U),()=>{h.removeEventListener("scroll",U)}},[t.virtual,h]);let T=U=>G=>{let k=[...x.current],Z=k[U];k[U]={...Z,end:Math.max(Z.end-G,Z.start)},U+1<x.current.length-1&&(k[U+1]={...k[U+1],start:Math.max(Z.end-G,Z.start)}),x.current=k,v()},O=U=>G=>{let k=[...x.current],Z=k[U];k[U]={...Z,start:Math.min(Z.start+G,Z.end)},U>1&&(k[U-1]={...k[U-1],end:Math.min(Z.start+G,Z.end)}),x.current=k,v()},S=U=>()=>{let G=[...x.current],k=G[U];G[U]={...k,start:k.start,end:k.start},U+1<x.current.length-1?G[U+1]={...G[U+1],start:k.start}:G[U-1]={...G[U-1],end:k.end},x.current=G,v()},C=(U,G=[],k=!1,Z=!1)=>Q(Ae,null,G.map((te,A)=>{let ce=U.slice(te.start,te.end);if(!te.type&&!te.token)return ce;let Se=[te.type?`inline-diff-${te.type}`:"",te.token?`token ${te.token}`:""].filter(Boolean).join(" ");return Q("span",{key:`${A}-${te.type}-${ce}`,className:Se},ce)}),k&&(Z?Q("span",{className:"token punctuation"},","):",")),F=(U,G)=>{let k=g.current[U],Z=_.current[U],[te,A]=t.highlightInlineDiff&&k.type==="modify"&&Z.type==="modify"?xxe(k.text,Z.text,c):[[],[]],ce=UU(G,k.text,0),Se=UU(G,Z.text,0),Ge=FU(ce,te),et=FU(Se,A),Oe=k.type!=="equal"?t.bgColour?.[k.type]??"":"",be=Z.type!=="equal"?t.bgColour?.[Z.type]??"":"";return Q("tr",{key:U},t.lineNumbers&&Q("td",{className:`line-${k.type} line-number`,style:{backgroundColor:Oe}},k.lineNumber),Q("td",{className:`line-${k.type}`,style:{backgroundColor:Oe}},Q("pre",null,k.text&&s.repeat(k.level*l),C(k.text,Ge,k.comma,G))),t.lineNumbers&&Q("td",{className:`line-${Z.type} line-number`,style:{backgroundColor:be}},Z.lineNumber),Q("td",{className:`line-${Z.type}`,style:{backgroundColor:be}},Q("pre",null,Z.text&&s.repeat(Z.level*l),C(Z.text,et,Z.comma,G))))},N=(U,G,k,Z)=>Q(Ae,null,U&&Q("button",{onClick:()=>T(Z)(k)},"\u2B61 Show ",k," lines before"),Q("button",{onClick:()=>S(Z)()},"\u2B65 Show all unchanged lines"),G&&Q("button",{onClick:()=>O(Z)(k)},"\u2B63 Show ",k," lines after")),R=(U,G,k,Z,te)=>{let{start:A,end:ce}=U;if(A=Math.max(A,k),ce=Math.min(ce,Z),A===ce)return null;if(!Qi(U))return Array(ce-A).fill(0).map((Oe,be)=>F(A+be,te));let{hasLinesBefore:Se,hasLinesAfter:Ge}=U,et=typeof u=="boolean"?$U:u.expandMoreLinesLimit||$U;return[Q("tr",{key:`expand-line-${G}`,className:"expand-line"},Q("td",{colSpan:4,className:`${Se?"has-lines-before":""} ${Ge?"has-lines-after":""}`},typeof u!="boolean"&&u.expandLineRenderer?u.expandLineRenderer({hasLinesBefore:Se,hasLinesAfter:Ge,onExpandBefore:T(G),onExpandAfter:O(G),onExpandAll:S(G)}):N(Se,Ge,et,G)))]},z=U=>{if(o&&u)return Q("tr",{key:"message-line",className:"message-line"},Q("td",{colSpan:4},n.noChangeDetected));if(!t.virtual)return x.current.map((zt,ot)=>R(zt,ot,0,g.current.length,U));let G=h?.clientHeight??0,k=h?.scrollTop??0,Z=k+G,te=I.current,A=te?.offsetTop??0;for(;te?.offsetParent&&te?.offsetParent!==h;)te=te.offsetParent,A+=te.offsetTop;if(A>Z||A+y.current<k)return Q("tr",null,Q("td",{colSpan:4,style:{height:`${y.current}px`}}));let ce=k-A,Se=Z-A,[Ge,et,Oe,be]=uxe(x.current,b.current,ce,Se,p,m),[st,wt]=lxe(x.current,b.current,Ge,et,Oe,be,p,m,y.current),mt=x.current.slice(Ge,Oe+1);return mt.length?Q(Ae,null,Q("tr",null,Q("td",{colSpan:4,style:{height:st,padding:0}})),mt.map((zt,ot)=>R(zt,ot,et,be,U)),Q("tr",null,Q("td",{colSpan:4,style:{height:wt,padding:0}}))):Q("tr",null,Q("td",{colSpan:4,style:{height:`${y.current}px`}}))},B=()=>Q("colgroup",{className:"measure-line"},t.lineNumbers&&Q("col",{style:{width:a}}),Q("col",null),t.lineNumbers&&Q("col",{style:{width:a}}),Q("col",null)),M=["json-diff-viewer",t.virtual&&"json-diff-viewer-virtual",t.syntaxHighlight&&`json-diff-viewer-theme-${t.syntaxHighlight.theme||"monokai"}`,t.className].filter(Boolean).join(" "),V=!!t.syntaxHighlight;return Q("table",{className:M,style:t.style},B(),Q("tbody",{ref:I},z(V)))};Ub.displayName="Viewer";function Vb(t){let e=t.left,r=t.right,[o,n]=P(!1),[a,i]=P(null),[s,l]=P(null),c=WU(a?.fields||{}),u=WU(s?.fields||{}),p=new OC({}).diff(c,u),m=`/cms/compare?left=${KU(e)}&right=${KU(r)}`;async function h(){n(!0);let[g,_]=await Promise.all([PS(e.docId,e.versionId),PS(r.docId,r.versionId)]);i(g),l(_),n(!1)}return L(()=>{h()},[]),o?f(Re,{size:"md",color:"gray"}):f("div",{className:ke(t.className,"DocDiffViewer"),children:[t.showExpandButton&&f("div",{className:"DocDiffViewer__expand",children:f(X,{component:"a",variant:"default",size:"xs",compact:!0,href:m,target:"_blank",children:"Open in new tab"})}),f("div",{className:"DocDiffViewer__header",children:[f("div",{className:"DocDiffViewer__header__label",children:[t.left.docId,"@",t.left.versionId," - modified"," ",GU(a)]}),f("div",{className:"DocDiffViewer__header__label",children:[t.right.docId,"@",t.right.versionId," - modified"," ",GU(s)]})]}),f(Ub,{diff:p,syntaxHighlight:{theme:"root-cms"},lineNumbers:!0,highlightInlineDiff:!0,hideUnchangedLines:!0,inlineDiffOptions:{mode:"word",wordSeparator:" "}})]})}function GU(t){return t?.sys?.modifiedAt?Rn(t.sys.modifiedAt.toMillis()):"never"}function WU(t){return db(t,{removeArrayKey:!0})}function KU(t){return encodeURIComponent(`${t.docId}@${t.versionId}`).replaceAll("%2F","/").replaceAll("%40","@")}var XU="PublishDocModal";function YU(t){let e=Ye(),r=xt();return{open:()=>{e.openContextModal(XU,{...r,title:`Publish ${t.docId}`,innerProps:t,size:"850px"})}}}function Hb(t){let{innerProps:e,context:r,id:o}=t,[n,a]=P(""),[i,s]=P(""),[l,c]=P(!1),u=H(null),d=Ye(),p=xt(),m=n==="scheduled"?"Schedule":"Publish";async function h(){try{c(!0),await pz(e.docId),c(!1),pe({title:"Published!",message:`Succesfully published ${e.docId}.`,autoClose:1e4}),d.closeAll()}catch(b){console.error(b),pe({title:"Publish failed",message:`Failed to publish ${e.docId}.`,color:"red",autoClose:!1})}}async function g(){try{c(!0);let b=Math.floor(new Date(i).getTime());await mz(e.docId,b),c(!1),pe({title:"Scheduled!",message:`${e.docId} will go live ${i}.`,autoClose:1e4}),d.closeAll()}catch(b){console.error(b),pe({title:"Schedule failed",message:`Failed to schedule ${e.docId}.`,color:"red",autoClose:!1})}}function _(){d.openConfirmModal({...p,title:`${m} ${e.docId}`,children:f(Me,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to publish ",f("code",{children:e.docId}),"? The doc will go live ",n==="now"?"now":`at ${i}`,"."]}),labels:{confirm:m,cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"dark",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!0,onConfirm:()=>{n==="now"?h():n==="scheduled"&&g()}})}let x=!0;return(n==="now"||n==="scheduled"&&i)&&(x=!1),f("div",{className:"PublishDocModal",children:f("div",{className:"PublishDocModal__content",children:[f("form",{className:"PublishDocModal__form",onSubmit:b=>{b.preventDefault(),_()},children:[f("div",{className:"PublishDocModal__form__publishOptions",children:f("div",{className:"PublishDocModal__form__publishOptions__options",children:[f("label",{className:ke("PublishDocModal__form__publishOptions__option",n==="now"&&"PublishDocModal__form__publishOptions__option--selected",n&&n!=="now"&&"PublishDocModal__form__publishOptions__option--unselected"),children:[f("div",{className:"PublishDocModal__form__publishOptions__option__input",children:[f("input",{type:"radio",name:"publish-option",value:"now",checked:n==="now",onChange:()=>a("now")})," ","Now"]}),f("div",{className:"PublishDocModal__form__publishOptions__option__help",children:"Content will go live immediately."})]}),f("label",{className:ke("PublishDocModal__form__publishOptions__option",n==="scheduled"&&"PublishDocModal__form__publishOptions__option--selected",n&&n!=="scheduled"&&"PublishDocModal__form__publishOptions__option--unselected"),children:[f("div",{className:"PublishDocModal__form__publishOptions__option__input",children:[f("input",{type:"radio",name:"publish-option",value:"scheduled",checked:n==="scheduled",onChange:()=>a("scheduled")}),f("div",{children:"Scheduled"})]}),f("div",{className:"PublishDocModal__form__publishOptions__option__help",children:"Content will go live at the date and time specified below."}),f("div",{className:"PublishDocModal__form__publishOptions__option__input2",children:[f("input",{ref:u,type:"datetime-local",disabled:n!=="scheduled",value:i,min:Eu(),onChange:b=>{let y=b.target;s(y.value)}}),f("div",{className:"PublishDocModal__form__publishOptions__option__input2__help",children:["timezone: ",Intl.DateTimeFormat().resolvedOptions().timeZone]})]})]})]})}),f("div",{className:"PublishDocModal__form__buttons",children:[f(X,{variant:"outline",onClick:()=>r.closeModal(o),type:"button",size:"xs",color:"dark",children:"Cancel"}),f(X,{variant:"filled",size:"xs",color:"dark",disabled:x,loading:l,type:"submit",children:m})]})]}),f(Ixe,{docId:e.docId})]})})}function Ixe(t){let e=t.docId,[r,o]=P(!1);function n(){o(!0)}return f("div",{className:"PublishDocModal__ShowChanges",children:f(Ic,{iconPosition:"right",onChange:()=>n(),children:f(Ic.Item,{label:"Show changes",children:r?f(Vb,{left:{docId:e,versionId:"published"},right:{docId:e,versionId:"draft"},showExpandButton:!0}):f(Re,{})})})})}Hb.id=XU;var Zi="Releases";async function QU(t,e){if(!t)throw new Error("missing data source id");let r=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,n=we(o,"Projects",r,Zi,t);await Pp(o,async a=>{if((await a.get(n)).exists())throw new Error(`release exists: ${t}`);await a.set(n,{...e,id:t,createdAt:Ut(),createdBy:window.firebase.user.email})}),Je("release.create",{metadata:{releaseId:t}})}async function ZU(){let t=window.__ROOT_CTX.rootConfig.projectId,e=window.firebase.db,r=nn(e,"Projects",t,Zi),o=to(r,Qn("createdAt","desc")),n=await an(o),a=[];return n.forEach(i=>{a.push(i.data())}),a}async function kl(t){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,o=we(r,"Projects",e,Zi,t),n=await vr(o);return n.exists()?n.data():null}async function JU(t,e){let r=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,n=we(o,"Projects",r,Zi,t);await rr(n,e),Je("release.save",{metadata:{releaseId:t}})}async function e8(t){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,o=we(r,"Projects",e,Zi,t);await P9(o),console.log(`deleted release ${t}`),Je("release.delete",{metadata:{releaseId:t}})}async function t8(t){let e=await kl(t);if(!e)throw new Error(`release not found: ${t}`);let r=e.docIds||[];if(r.length===0)throw new Error(`no docs to publish for release: ${t}`);let o=window.__ROOT_CTX.rootConfig.projectId,n=window.firebase.db,a=we(n,"Projects",o,Zi,t),i=sn(n);i.update(a,{publishedAt:Ut(),publishedBy:window.firebase.user.email,scheduledAt:zr(),scheduledBy:zr()}),await CS(r,{batch:i}),console.log(`published release: ${t}`),Je("release.publish",{metadata:{releaseId:t,docIds:r}})}async function r8(t,e){if(!await kl(t))throw new Error(`release not found: ${t}`);typeof e=="number"&&(e=Ze.fromMillis(e));let o=window.__ROOT_CTX.rootConfig.projectId,n=window.firebase.db,a=we(n,"Projects",o,Zi,t);await rr(a,{scheduledAt:e,scheduledBy:window.firebase.user.email}),Je("release.publish",{metadata:{releaseId:t,scheduledAt:e.toMillis()}})}async function o8(t){if(!await kl(t))throw new Error(`release not found: ${t}`);let r=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,n=we(o,"Projects",r,Zi,t);await rr(n,{scheduledAt:zr(),scheduledBy:zr()}),Je("release.unschedule",{metadata:{releaseId:t}})}var n8="ScheduleReleaseModal";function a8(t){let e=Ye(),r=xt();return{open:()=>{e.openContextModal(n8,{...r,title:`Schedule release: ${t.releaseId}`,innerProps:t})}}}function $b(t){let{innerProps:e,context:r,id:o}=t,[n,a]=P(""),[i,s]=P(!1),l=H(null),c=Ye();async function u(){s(!0),await bt(async()=>{let d=Math.floor(new Date(n).getTime());if(Math.floor(new Date().getTime())>=d)throw new Error("bad datetime, please choose a date in the future");let m=Ze.fromMillis(d);await r8(e.releaseId,d),pe({title:"Scheduled!",message:`Release ${e.releaseId} will go live ${n}.`,autoClose:1e4}),c.closeAll(),e.onScheduled&&e.onScheduled(m)}),s(!1)}return f("div",{className:"ScheduleReleaseModal",children:f("div",{className:"ScheduleReleaseModal__content",children:f("form",{className:"ScheduleReleaseModal__form",onSubmit:d=>{d.preventDefault(),u()},children:[f("div",{className:"ScheduleReleaseModal__form__description",children:"Content in the release will go live at the datetime specified below."}),f("div",{className:"ScheduleReleaseModal__form__dateInput",children:[f("input",{ref:l,type:"datetime-local",value:n,min:Eu(),onChange:d=>{let p=d.target;a(p.value)}}),f("div",{className:"ScheduleReleaseModal__form__dateInput__help",children:["timezone: ",Intl.DateTimeFormat().resolvedOptions().timeZone]})]}),f("div",{className:"ScheduleReleaseModal__form__buttons",children:[f(X,{variant:"outline",onClick:()=>r.closeModal(o),type:"button",size:"xs",color:"dark",children:"Cancel"}),f(X,{variant:"filled",size:"xs",color:"dark",loading:i,type:"submit",children:"Schedule"})]})]})})})}$b.id=n8;var s8="VersionHistoryModal";function l8(t){let e=Ye(),r=xt();return{open:()=>{e.openContextModal(s8,{...r,innerProps:t,size:"min(calc(100% - 32px), 720px)"})}}}function jb(t){let{innerProps:e}=t,r=e.docId,[o,n]=P(!0),[a,i]=P([]),s=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});async function l(){n(!0);let d=await vz(r);n(!1),i(d)}async function c(d){await Iz(r,d),pe({title:"Saved!",message:`Restored ${r} to ${s.format(d.sys.modifiedAt.toDate())}.`,autoClose:5e3}),e.onRestore&&e.onRestore({version:d})}function u(d){let p=i8(r,d._versionId),m=i8(r,"draft");return`/cms/compare?left=${p}&right=${m}`}return L(()=>{l()},[]),o?f(Re,{}):f("div",{className:"VersionHistoryModal",children:[f(Te,{className:"VersionHistoryModal__title",size:"h2",children:[f(Hp,{strokeWidth:1.5}),f("span",{children:"Version history"})]}),f("div",{className:"VersionHistoryModal__docId",children:f("code",{children:r})}),a.length===0?f(Me,{className:"VersionHistoryModal__versionsEmpty",size:"body",children:[f("p",{children:"No versions found."}),f("p",{className:"VersionHistoryModal__versionsEmpty__developer",children:"For developers: Configure the Root CMS cron job to populate versions."})]}):f(kr,{className:"VersionHistoryModal__versions",children:[f("thead",{children:f("tr",{children:[f("th",{children:"modified at"}),f("th",{children:"modified by"}),f("th",{children:"actions"})]})}),f("tbody",{children:a.map((d,p)=>f("tr",{children:[f("td",{children:f(Me,{size:"body-sm",children:s.format(d.sys.modifiedAt.toDate())})}),f("td",{children:f(Me,{size:"body-sm",children:d.sys.modifiedBy})}),f("td",{children:f("div",{className:"VersionHistoryModal__versions__buttons",children:[f(X,{variant:"default",size:"xs",compact:!0,onClick:()=>c(d),children:"restore"}),f(X,{className:"VersionHistoryModal__versions__buttons__compare",component:"a",variant:"default",size:"xs",compact:!0,href:u(d),target:"_blank",rightIcon:f(_l,{size:12}),children:"compare"})]})})]}))})]})]})}function i8(t,e){return encodeURIComponent(`${t}@${e}`).replaceAll("%2F","/").replaceAll("%40","@")}jb.id=s8;var hV=wv(mV(),1);var WC=hV.default;var Sye={};function KC(t,e){let r=e||Sye,o=typeof r.includeImageAlt=="boolean"?r.includeImageAlt:!0,n=typeof r.includeHtml=="boolean"?r.includeHtml:!0;return _V(t,o,n)}function _V(t,e,r){if(Cye(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 gV(t.children,e,r)}return Array.isArray(t)?gV(t,e,r):""}function gV(t,e,r){let o=[],n=-1;for(;++n<t.length;)o[n]=_V(t[n],e,r);return o.join("")}function Cye(t){return!!(t&&typeof t=="object")}var xV=document.createElement("i");function Vu(t){let e="&"+t+";";xV.innerHTML=e;let r=xV.textContent;return r.charCodeAt(r.length-1)===59&&t!=="semi"||r===e?!1:r}function Ir(t,e,r,o){let n=t.length,a=0,i;if(e<0?e=-e>n?0:n+e:e=e>n?n:e,r=r>0?r:0,o.length<1e4)i=Array.from(o),i.unshift(e,r),t.splice(...i);else for(r&&t.splice(e,r);a<o.length;)i=o.slice(a,a+1e4),i.unshift(e,0),t.splice(...i),a+=1e4,e+=1e4}function Mo(t,e){return t.length>0?(Ir(t,t.length,0,e),t):e}var bV={}.hasOwnProperty;function ry(t){let e={},r=-1;for(;++r<t.length;)kye(e,t[r]);return e}function kye(t,e){let r;for(r in e){let n=(bV.call(t,r)?t[r]:void 0)||(t[r]={}),a=e[r],i;if(a)for(i in a){bV.call(n,i)||(n[i]=[]);let s=a[i];Tye(n[i],Array.isArray(s)?s:s?[s]:[])}}}function Tye(t,e){let r=-1,o=[];for(;++r<e.length;)(e[r].add==="after"?t:o).push(e[r]);Ir(t,0,0,o)}function oy(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 mo(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}var Pr=es(/[A-Za-z]/),Or=es(/[\dA-Za-z]/),yV=es(/[#-'*+\--9=?A-Z^-~]/);function Ol(t){return t!==null&&(t<32||t===127)}var em=es(/\d/),vV=es(/[\dA-Fa-f]/),IV=es(/[!-/:-@[-`{-~]/);function ie(t){return t!==null&&t<-2}function Xe(t){return t!==null&&(t<0||t===32)}function Pe(t){return t===-2||t===-1||t===32}var Al=es(/\p{P}|\p{S}/u),Ta=es(/\s/);function es(t){return e;function e(r){return r!==null&&r>-1&&t.test(String.fromCharCode(r))}}function Ee(t,e,r,o){let n=o?o-1:Number.POSITIVE_INFINITY,a=0;return i;function i(l){return Pe(l)?(t.enter(r),s(l)):e(l)}function s(l){return Pe(l)&&a++<n?(t.consume(l),s):(t.exit(r),e(l))}}var wV={tokenize:Pye};function Pye(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"),Ee(t,e,"linePrefix")}function n(s){return t.enter("paragraph"),a(s)}function a(s){let l=t.enter("chunkText",{contentType:"text",previous:r});return r&&(r.next=l),r=l,i(s)}function i(s){if(s===null){t.exit("chunkText"),t.exit("paragraph"),t.consume(s);return}return ie(s)?(t.consume(s),t.exit("chunkText"),a):(t.consume(s),i)}}var SV={tokenize:Oye},EV={tokenize:Aye};function Oye(t){let e=this,r=[],o=0,n,a,i;return s;function s(y){if(o<r.length){let I=r[o];return e.containerState=I[1],t.attempt(I[0].continuation,l,c)(y)}return c(y)}function l(y){if(o++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,n&&b();let I=e.events.length,w=I,v;for(;w--;)if(e.events[w][0]==="exit"&&e.events[w][1].type==="chunkFlow"){v=e.events[w][1].end;break}x(o);let T=I;for(;T<e.events.length;)e.events[T][1].end=Object.assign({},v),T++;return Ir(e.events,w+1,0,e.events.slice(I)),e.events.length=T,c(y)}return s(y)}function c(y){if(o===r.length){if(!n)return p(y);if(n.currentConstruct&&n.currentConstruct.concrete)return h(y);e.interrupt=!!(n.currentConstruct&&!n._gfmTableDynamicInterruptHack)}return e.containerState={},t.check(EV,u,d)(y)}function u(y){return n&&b(),x(o),p(y)}function d(y){return e.parser.lazy[e.now().line]=o!==r.length,i=e.now().offset,h(y)}function p(y){return e.containerState={},t.attempt(EV,m,h)(y)}function m(y){return o++,r.push([e.currentConstruct,e.containerState]),p(y)}function h(y){if(y===null){n&&b(),x(0),t.consume(y);return}return n=n||e.parser.flow(e.now()),t.enter("chunkFlow",{contentType:"flow",previous:a,_tokenizer:n}),g(y)}function g(y){if(y===null){_(t.exit("chunkFlow"),!0),x(0),t.consume(y);return}return ie(y)?(t.consume(y),_(t.exit("chunkFlow")),o=0,e.interrupt=void 0,s):(t.consume(y),g)}function _(y,I){let w=e.sliceStream(y);if(I&&w.push(null),y.previous=a,a&&(a.next=y),a=y,n.defineSkip(y.start),n.write(w),e.parser.lazy[y.start.line]){let v=n.events.length;for(;v--;)if(n.events[v][1].start.offset<i&&(!n.events[v][1].end||n.events[v][1].end.offset>i))return;let T=e.events.length,O=T,S,C;for(;O--;)if(e.events[O][0]==="exit"&&e.events[O][1].type==="chunkFlow"){if(S){C=e.events[O][1].end;break}S=!0}for(x(o),v=T;v<e.events.length;)e.events[v][1].end=Object.assign({},C),v++;Ir(e.events,O+1,0,e.events.slice(T)),e.events.length=v}}function x(y){let I=r.length;for(;I-- >y;){let w=r[I];e.containerState=w[1],w[0].exit.call(e,t)}r.length=y}function b(){n.write([null]),a=void 0,n=void 0,e.containerState._closeFlow=void 0}}function Aye(t,e,r){return Ee(t,t.attempt(this.parser.constructs.document,e,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Hu(t){if(t===null||Xe(t)||Ta(t))return 1;if(Al(t))return 2}function ts(t,e,r){let o=[],n=-1;for(;++n<t.length;){let a=t[n].resolveAll;a&&!o.includes(a)&&(e=a(e,r),o.push(a))}return e}var tm={name:"attention",tokenize:Rye,resolveAll:Dye};function Dye(t,e){let r=-1,o,n,a,i,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),p=Object.assign({},t[r][1].start);CV(d,-l),CV(p,l),i={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:p},a={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({},i.start),end:Object.assign({},s.end)},t[o][1].end=Object.assign({},i.start),t[r][1].start=Object.assign({},s.end),c=[],t[o][1].end.offset-t[o][1].start.offset&&(c=Mo(c,[["enter",t[o][1],e],["exit",t[o][1],e]])),c=Mo(c,[["enter",n,e],["enter",i,e],["exit",i,e],["enter",a,e]]),c=Mo(c,ts(e.parser.constructs.insideSpan.null,t.slice(o+1,r),e)),c=Mo(c,[["exit",a,e],["enter",s,e],["exit",s,e],["exit",n,e]]),t[r][1].end.offset-t[r][1].start.offset?(u=2,c=Mo(c,[["enter",t[r][1],e],["exit",t[r][1],e]])):u=0,Ir(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 Rye(t,e){let r=this.parser.constructs.attentionMarkers.null,o=this.previous,n=Hu(o),a;return i;function i(l){return a=l,t.enter("attentionSequence"),s(l)}function s(l){if(l===a)return t.consume(l),s;let c=t.exit("attentionSequence"),u=Hu(l),d=!u||u===2&&n||r.includes(l),p=!n||n===2&&u||r.includes(o);return c._open=!!(a===42?d:d&&(n||!p)),c._close=!!(a===42?p:p&&(u||!d)),e(l)}}function CV(t,e){t.column+=e,t.offset+=e,t._bufferIndex+=e}var XC={name:"autolink",tokenize:Nye};function Nye(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"),a}function a(m){return Pr(m)?(t.consume(m),i):m===64?r(m):c(m)}function i(m){return m===43||m===45||m===46||Or(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||Or(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||Ol(m)?r(m):(t.consume(m),l)}function c(m){return m===64?(t.consume(m),u):yV(m)?(t.consume(m),c):r(m)}function u(m){return Or(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):p(m)}function p(m){if((m===45||Or(m))&&o++<63){let h=m===45?p:d;return t.consume(m),h}return r(m)}}var Pa={tokenize:Mye,partial:!0};function Mye(t,e,r){return o;function o(a){return Pe(a)?Ee(t,n,"linePrefix")(a):n(a)}function n(a){return a===null||ie(a)?e(a):r(a)}}var ny={name:"blockQuote",tokenize:Lye,continuation:{tokenize:Bye},exit:Fye};function Lye(t,e,r){let o=this;return n;function n(i){if(i===62){let s=o.containerState;return s.open||(t.enter("blockQuote",{_container:!0}),s.open=!0),t.enter("blockQuotePrefix"),t.enter("blockQuoteMarker"),t.consume(i),t.exit("blockQuoteMarker"),a}return r(i)}function a(i){return Pe(i)?(t.enter("blockQuotePrefixWhitespace"),t.consume(i),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),e):(t.exit("blockQuotePrefix"),e(i))}}function Bye(t,e,r){let o=this;return n;function n(i){return Pe(i)?Ee(t,a,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i):a(i)}function a(i){return t.attempt(ny,e,r)(i)}}function Fye(t){t.exit("blockQuote")}var ay={name:"characterEscape",tokenize:zye};function zye(t,e,r){return o;function o(a){return t.enter("characterEscape"),t.enter("escapeMarker"),t.consume(a),t.exit("escapeMarker"),n}function n(a){return IV(a)?(t.enter("characterEscapeValue"),t.consume(a),t.exit("characterEscapeValue"),t.exit("characterEscape"),e):r(a)}}var iy={name:"characterReference",tokenize:Uye};function Uye(t,e,r){let o=this,n=0,a,i;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"),a=31,i=Or,u(d))}function c(d){return d===88||d===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(d),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),a=6,i=vV,u):(t.enter("characterReferenceValue"),a=7,i=em,u(d))}function u(d){if(d===59&&n){let p=t.exit("characterReferenceValue");return i===Or&&!Vu(o.sliceSerialize(p))?r(d):(t.enter("characterReferenceMarker"),t.consume(d),t.exit("characterReferenceMarker"),t.exit("characterReference"),e)}return i(d)&&n++<a?(t.consume(d),u):r(d)}}var kV={tokenize:Hye,partial:!0},sy={name:"codeFenced",tokenize:Vye,concrete:!0};function Vye(t,e,r){let o=this,n={tokenize:w,partial:!0},a=0,i=0,s;return l;function l(v){return c(v)}function c(v){let T=o.events[o.events.length-1];return a=T&&T[1].type==="linePrefix"?T[2].sliceSerialize(T[1],!0).length:0,s=v,t.enter("codeFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),u(v)}function u(v){return v===s?(i++,t.consume(v),u):i<3?r(v):(t.exit("codeFencedFenceSequence"),Pe(v)?Ee(t,d,"whitespace")(v):d(v))}function d(v){return v===null||ie(v)?(t.exit("codeFencedFence"),o.interrupt?e(v):t.check(kV,g,I)(v)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),p(v))}function p(v){return v===null||ie(v)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),d(v)):Pe(v)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),Ee(t,m,"whitespace")(v)):v===96&&v===s?r(v):(t.consume(v),p)}function m(v){return v===null||ie(v)?d(v):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),h(v))}function h(v){return v===null||ie(v)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),d(v)):v===96&&v===s?r(v):(t.consume(v),h)}function g(v){return t.attempt(n,I,_)(v)}function _(v){return t.enter("lineEnding"),t.consume(v),t.exit("lineEnding"),x}function x(v){return a>0&&Pe(v)?Ee(t,b,"linePrefix",a+1)(v):b(v)}function b(v){return v===null||ie(v)?t.check(kV,g,I)(v):(t.enter("codeFlowValue"),y(v))}function y(v){return v===null||ie(v)?(t.exit("codeFlowValue"),b(v)):(t.consume(v),y)}function I(v){return t.exit("codeFenced"),e(v)}function w(v,T,O){let S=0;return C;function C(B){return v.enter("lineEnding"),v.consume(B),v.exit("lineEnding"),F}function F(B){return v.enter("codeFencedFence"),Pe(B)?Ee(v,N,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(B):N(B)}function N(B){return B===s?(v.enter("codeFencedFenceSequence"),R(B)):O(B)}function R(B){return B===s?(S++,v.consume(B),R):S>=i?(v.exit("codeFencedFenceSequence"),Pe(B)?Ee(v,z,"whitespace")(B):z(B)):O(B)}function z(B){return B===null||ie(B)?(v.exit("codeFencedFence"),T(B)):O(B)}}}function Hye(t,e,r){let o=this;return n;function n(i){return i===null?r(i):(t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),a)}function a(i){return o.parser.lazy[o.now().line]?r(i):e(i)}}var rm={name:"codeIndented",tokenize:jye},$ye={tokenize:qye,partial:!0};function jye(t,e,r){let o=this;return n;function n(c){return t.enter("codeIndented"),Ee(t,a,"linePrefix",5)(c)}function a(c){let u=o.events[o.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?i(c):r(c)}function i(c){return c===null?l(c):ie(c)?t.attempt($ye,i,l)(c):(t.enter("codeFlowValue"),s(c))}function s(c){return c===null||ie(c)?(t.exit("codeFlowValue"),i(c)):(t.consume(c),s)}function l(c){return t.exit("codeIndented"),e(c)}}function qye(t,e,r){let o=this;return n;function n(i){return o.parser.lazy[o.now().line]?r(i):ie(i)?(t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),n):Ee(t,a,"linePrefix",5)(i)}function a(i){let s=o.events[o.events.length-1];return s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?e(i):ie(i)?n(i):r(i)}}var YC={name:"codeText",tokenize:Kye,resolve:Gye,previous:Wye};function Gye(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 Wye(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Kye(t,e,r){let o=this,n=0,a,i;return s;function s(p){return t.enter("codeText"),t.enter("codeTextSequence"),l(p)}function l(p){return p===96?(t.consume(p),n++,l):(t.exit("codeTextSequence"),c(p))}function c(p){return p===null?r(p):p===32?(t.enter("space"),t.consume(p),t.exit("space"),c):p===96?(i=t.enter("codeTextSequence"),a=0,d(p)):ie(p)?(t.enter("lineEnding"),t.consume(p),t.exit("lineEnding"),c):(t.enter("codeTextData"),u(p))}function u(p){return p===null||p===32||p===96||ie(p)?(t.exit("codeTextData"),c(p)):(t.consume(p),u)}function d(p){return p===96?(t.consume(p),a++,d):a===n?(t.exit("codeTextSequence"),t.exit("codeText"),e(p)):(i.type="codeTextData",u(p))}}var ly=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 a=this.right.splice(this.right.length-n,Number.POSITIVE_INFINITY);return o&&om(this.left,o),a.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),om(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),om(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);om(this.right,r.reverse())}else{let r=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);om(this.left,r.reverse())}}};function om(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 cy(t){let e={},r=-1,o,n,a,i,s,l,c,u=new ly(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,a=0,a<l.length&&l[a][1].type==="lineEndingBlank"&&(a+=2),a<l.length&&l[a][1].type==="content"))for(;++a<l.length&&l[a][1].type!=="content";)l[a][1].type==="chunkText"&&(l[a][1]._isInFirstContentOfListItem=!0,a++);if(o[0]==="enter")o[1].contentType&&(Object.assign(e,Xye(u,r)),r=e[r],c=!0);else if(o[1]._container){for(a=r,n=void 0;a--&&(i=u.get(a),i[1].type==="lineEnding"||i[1].type==="lineEndingBlank");)i[0]==="enter"&&(n&&(u.get(n)[1].type="lineEndingBlank"),i[1].type="lineEnding",n=a);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 Ir(t,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function Xye(t,e){let r=t.get(e)[1],o=t.get(e)[2],n=e-1,a=[],i=r._tokenizer||o.parser[r.contentType](r.start),s=i.events,l=[],c={},u,d,p=-1,m=r,h=0,g=0,_=[g];for(;m;){for(;t.get(++n)[1]!==m;);a.push(n),m._tokenizer||(u=o.sliceStream(m),m.next||u.push(null),d&&i.defineSkip(m.start),m._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=!0),i.write(u),m._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=void 0)),d=m,m=m.next}for(m=r;++p<s.length;)s[p][0]==="exit"&&s[p-1][0]==="enter"&&s[p][1].type===s[p-1][1].type&&s[p][1].start.line!==s[p][1].end.line&&(g=p+1,_.push(g),m._tokenizer=void 0,m.previous=void 0,m=m.next);for(i.events=[],m?(m._tokenizer=void 0,m.previous=void 0):_.pop(),p=_.length;p--;){let x=s.slice(_[p],_[p+1]),b=a.pop();l.push([b,b+x.length-1]),t.splice(b,2,x)}for(l.reverse(),p=-1;++p<l.length;)c[h+l[p][0]]=h+l[p][1],h+=l[p][1]-l[p][0]-1;return c}var QC={tokenize:Zye,resolve:Qye},Yye={tokenize:Jye,partial:!0};function Qye(t){return cy(t),t}function Zye(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?a(s):ie(s)?t.check(Yye,i,a)(s):(t.consume(s),n)}function a(s){return t.exit("chunkContent"),t.exit("content"),e(s)}function i(s){return t.consume(s),t.exit("chunkContent"),r.next=t.enter("chunkContent",{contentType:"content",previous:r}),r=r.next,n}}function Jye(t,e,r){let o=this;return n;function n(i){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),Ee(t,a,"linePrefix")}function a(i){if(i===null||ie(i))return r(i);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(i):t.interrupt(o.parser.constructs.flow,r,e)(i)}}function uy(t,e,r,o,n,a,i,s,l){let c=l||Number.POSITIVE_INFINITY,u=0;return d;function d(x){return x===60?(t.enter(o),t.enter(n),t.enter(a),t.consume(x),t.exit(a),p):x===null||x===32||x===41||Ol(x)?r(x):(t.enter(o),t.enter(i),t.enter(s),t.enter("chunkString",{contentType:"string"}),g(x))}function p(x){return x===62?(t.enter(a),t.consume(x),t.exit(a),t.exit(n),t.exit(o),e):(t.enter(s),t.enter("chunkString",{contentType:"string"}),m(x))}function m(x){return x===62?(t.exit("chunkString"),t.exit(s),p(x)):x===null||x===60||ie(x)?r(x):(t.consume(x),x===92?h:m)}function h(x){return x===60||x===62||x===92?(t.consume(x),m):m(x)}function g(x){return!u&&(x===null||x===41||Xe(x))?(t.exit("chunkString"),t.exit(s),t.exit(i),t.exit(o),e(x)):u<c&&x===40?(t.consume(x),u++,g):x===41?(t.consume(x),u--,g):x===null||x===32||x===40||Ol(x)?r(x):(t.consume(x),x===92?_:g)}function _(x){return x===40||x===41||x===92?(t.consume(x),g):g(x)}}function dy(t,e,r,o,n,a){let i=this,s=0,l;return c;function c(m){return t.enter(o),t.enter(n),t.consume(m),t.exit(n),t.enter(a),u}function u(m){return s>999||m===null||m===91||m===93&&!l||m===94&&!s&&"_hiddenFootnoteSupport"in i.parser.constructs?r(m):m===93?(t.exit(a),t.enter(n),t.consume(m),t.exit(n),t.exit(o),e):ie(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||ie(m)||s++>999?(t.exit("chunkString"),u(m)):(t.consume(m),l||(l=!Pe(m)),m===92?p:d)}function p(m){return m===91||m===92||m===93?(t.consume(m),s++,d):d(m)}}function fy(t,e,r,o,n,a){let i;return s;function s(p){return p===34||p===39||p===40?(t.enter(o),t.enter(n),t.consume(p),t.exit(n),i=p===40?41:p,l):r(p)}function l(p){return p===i?(t.enter(n),t.consume(p),t.exit(n),t.exit(o),e):(t.enter(a),c(p))}function c(p){return p===i?(t.exit(a),l(i)):p===null?r(p):ie(p)?(t.enter("lineEnding"),t.consume(p),t.exit("lineEnding"),Ee(t,c,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),u(p))}function u(p){return p===i||p===null||ie(p)?(t.exit("chunkString"),c(p)):(t.consume(p),p===92?d:u)}function d(p){return p===i||p===92?(t.consume(p),u):u(p)}}function Dl(t,e){let r;return o;function o(n){return ie(n)?(t.enter("lineEnding"),t.consume(n),t.exit("lineEnding"),r=!0,o):Pe(n)?Ee(t,o,r?"linePrefix":"lineSuffix")(n):e(n)}}var ZC={name:"definition",tokenize:tve},eve={tokenize:rve,partial:!0};function tve(t,e,r){let o=this,n;return a;function a(m){return t.enter("definition"),i(m)}function i(m){return dy.call(o,t,s,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(m)}function s(m){return n=mo(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 Xe(m)?Dl(t,c)(m):c(m)}function c(m){return uy(t,u,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(m)}function u(m){return t.attempt(eve,d,d)(m)}function d(m){return Pe(m)?Ee(t,p,"whitespace")(m):p(m)}function p(m){return m===null||ie(m)?(t.exit("definition"),o.parser.defined.push(n),e(m)):r(m)}}function rve(t,e,r){return o;function o(s){return Xe(s)?Dl(t,n)(s):r(s)}function n(s){return fy(t,a,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(s)}function a(s){return Pe(s)?Ee(t,i,"whitespace")(s):i(s)}function i(s){return s===null||ie(s)?e(s):r(s)}}var JC={name:"hardBreakEscape",tokenize:ove};function ove(t,e,r){return o;function o(a){return t.enter("hardBreakEscape"),t.consume(a),n}function n(a){return ie(a)?(t.exit("hardBreakEscape"),e(a)):r(a)}}var ek={name:"headingAtx",tokenize:ave,resolve:nve};function nve(t,e){let r=t.length-2,o=3,n,a;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},a={type:"chunkText",start:t[o][1].start,end:t[r][1].end,contentType:"text"},Ir(t,o,r-o+1,[["enter",n,e],["enter",a,e],["exit",a,e],["exit",n,e]])),t}function ave(t,e,r){let o=0;return n;function n(u){return t.enter("atxHeading"),a(u)}function a(u){return t.enter("atxHeadingSequence"),i(u)}function i(u){return u===35&&o++<6?(t.consume(u),i):u===null||Xe(u)?(t.exit("atxHeadingSequence"),s(u)):r(u)}function s(u){return u===35?(t.enter("atxHeadingSequence"),l(u)):u===null||ie(u)?(t.exit("atxHeading"),e(u)):Pe(u)?Ee(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||Xe(u)?(t.exit("atxHeadingText"),s(u)):(t.consume(u),c)}}var TV=["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"],tk=["pre","script","style","textarea"];var rk={name:"htmlFlow",tokenize:cve,resolveTo:lve,concrete:!0},ive={tokenize:dve,partial:!0},sve={tokenize:uve,partial:!0};function lve(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 cve(t,e,r){let o=this,n,a,i,s,l;return c;function c(A){return u(A)}function u(A){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(A),d}function d(A){return A===33?(t.consume(A),p):A===47?(t.consume(A),a=!0,g):A===63?(t.consume(A),n=3,o.interrupt?e:k):Pr(A)?(t.consume(A),i=String.fromCharCode(A),_):r(A)}function p(A){return A===45?(t.consume(A),n=2,m):A===91?(t.consume(A),n=5,s=0,h):Pr(A)?(t.consume(A),n=4,o.interrupt?e:k):r(A)}function m(A){return A===45?(t.consume(A),o.interrupt?e:k):r(A)}function h(A){let ce="CDATA[";return A===ce.charCodeAt(s++)?(t.consume(A),s===ce.length?o.interrupt?e:N:h):r(A)}function g(A){return Pr(A)?(t.consume(A),i=String.fromCharCode(A),_):r(A)}function _(A){if(A===null||A===47||A===62||Xe(A)){let ce=A===47,Se=i.toLowerCase();return!ce&&!a&&tk.includes(Se)?(n=1,o.interrupt?e(A):N(A)):TV.includes(i.toLowerCase())?(n=6,ce?(t.consume(A),x):o.interrupt?e(A):N(A)):(n=7,o.interrupt&&!o.parser.lazy[o.now().line]?r(A):a?b(A):y(A))}return A===45||Or(A)?(t.consume(A),i+=String.fromCharCode(A),_):r(A)}function x(A){return A===62?(t.consume(A),o.interrupt?e:N):r(A)}function b(A){return Pe(A)?(t.consume(A),b):C(A)}function y(A){return A===47?(t.consume(A),C):A===58||A===95||Pr(A)?(t.consume(A),I):Pe(A)?(t.consume(A),y):C(A)}function I(A){return A===45||A===46||A===58||A===95||Or(A)?(t.consume(A),I):w(A)}function w(A){return A===61?(t.consume(A),v):Pe(A)?(t.consume(A),w):y(A)}function v(A){return A===null||A===60||A===61||A===62||A===96?r(A):A===34||A===39?(t.consume(A),l=A,T):Pe(A)?(t.consume(A),v):O(A)}function T(A){return A===l?(t.consume(A),l=null,S):A===null||ie(A)?r(A):(t.consume(A),T)}function O(A){return A===null||A===34||A===39||A===47||A===60||A===61||A===62||A===96||Xe(A)?w(A):(t.consume(A),O)}function S(A){return A===47||A===62||Pe(A)?y(A):r(A)}function C(A){return A===62?(t.consume(A),F):r(A)}function F(A){return A===null||ie(A)?N(A):Pe(A)?(t.consume(A),F):r(A)}function N(A){return A===45&&n===2?(t.consume(A),M):A===60&&n===1?(t.consume(A),V):A===62&&n===4?(t.consume(A),Z):A===63&&n===3?(t.consume(A),k):A===93&&n===5?(t.consume(A),G):ie(A)&&(n===6||n===7)?(t.exit("htmlFlowData"),t.check(ive,te,R)(A)):A===null||ie(A)?(t.exit("htmlFlowData"),R(A)):(t.consume(A),N)}function R(A){return t.check(sve,z,te)(A)}function z(A){return t.enter("lineEnding"),t.consume(A),t.exit("lineEnding"),B}function B(A){return A===null||ie(A)?R(A):(t.enter("htmlFlowData"),N(A))}function M(A){return A===45?(t.consume(A),k):N(A)}function V(A){return A===47?(t.consume(A),i="",U):N(A)}function U(A){if(A===62){let ce=i.toLowerCase();return tk.includes(ce)?(t.consume(A),Z):N(A)}return Pr(A)&&i.length<8?(t.consume(A),i+=String.fromCharCode(A),U):N(A)}function G(A){return A===93?(t.consume(A),k):N(A)}function k(A){return A===62?(t.consume(A),Z):A===45&&n===2?(t.consume(A),k):N(A)}function Z(A){return A===null||ie(A)?(t.exit("htmlFlowData"),te(A)):(t.consume(A),Z)}function te(A){return t.exit("htmlFlow"),e(A)}}function uve(t,e,r){let o=this;return n;function n(i){return ie(i)?(t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),a):r(i)}function a(i){return o.parser.lazy[o.now().line]?r(i):e(i)}}function dve(t,e,r){return o;function o(n){return t.enter("lineEnding"),t.consume(n),t.exit("lineEnding"),t.attempt(Pa,e,r)}}var ok={name:"htmlText",tokenize:fve};function fve(t,e,r){let o=this,n,a,i;return s;function s(k){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(k),l}function l(k){return k===33?(t.consume(k),c):k===47?(t.consume(k),w):k===63?(t.consume(k),y):Pr(k)?(t.consume(k),O):r(k)}function c(k){return k===45?(t.consume(k),u):k===91?(t.consume(k),a=0,h):Pr(k)?(t.consume(k),b):r(k)}function u(k){return k===45?(t.consume(k),m):r(k)}function d(k){return k===null?r(k):k===45?(t.consume(k),p):ie(k)?(i=d,V(k)):(t.consume(k),d)}function p(k){return k===45?(t.consume(k),m):d(k)}function m(k){return k===62?M(k):k===45?p(k):d(k)}function h(k){let Z="CDATA[";return k===Z.charCodeAt(a++)?(t.consume(k),a===Z.length?g:h):r(k)}function g(k){return k===null?r(k):k===93?(t.consume(k),_):ie(k)?(i=g,V(k)):(t.consume(k),g)}function _(k){return k===93?(t.consume(k),x):g(k)}function x(k){return k===62?M(k):k===93?(t.consume(k),x):g(k)}function b(k){return k===null||k===62?M(k):ie(k)?(i=b,V(k)):(t.consume(k),b)}function y(k){return k===null?r(k):k===63?(t.consume(k),I):ie(k)?(i=y,V(k)):(t.consume(k),y)}function I(k){return k===62?M(k):y(k)}function w(k){return Pr(k)?(t.consume(k),v):r(k)}function v(k){return k===45||Or(k)?(t.consume(k),v):T(k)}function T(k){return ie(k)?(i=T,V(k)):Pe(k)?(t.consume(k),T):M(k)}function O(k){return k===45||Or(k)?(t.consume(k),O):k===47||k===62||Xe(k)?S(k):r(k)}function S(k){return k===47?(t.consume(k),M):k===58||k===95||Pr(k)?(t.consume(k),C):ie(k)?(i=S,V(k)):Pe(k)?(t.consume(k),S):M(k)}function C(k){return k===45||k===46||k===58||k===95||Or(k)?(t.consume(k),C):F(k)}function F(k){return k===61?(t.consume(k),N):ie(k)?(i=F,V(k)):Pe(k)?(t.consume(k),F):S(k)}function N(k){return k===null||k===60||k===61||k===62||k===96?r(k):k===34||k===39?(t.consume(k),n=k,R):ie(k)?(i=N,V(k)):Pe(k)?(t.consume(k),N):(t.consume(k),z)}function R(k){return k===n?(t.consume(k),n=void 0,B):k===null?r(k):ie(k)?(i=R,V(k)):(t.consume(k),R)}function z(k){return k===null||k===34||k===39||k===60||k===61||k===96?r(k):k===47||k===62||Xe(k)?S(k):(t.consume(k),z)}function B(k){return k===47||k===62||Xe(k)?S(k):r(k)}function M(k){return k===62?(t.consume(k),t.exit("htmlTextData"),t.exit("htmlText"),e):r(k)}function V(k){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(k),t.exit("lineEnding"),U}function U(k){return Pe(k)?Ee(t,G,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(k):G(k)}function G(k){return t.enter("htmlTextData"),i(k)}}var Rl={name:"labelEnd",tokenize:xve,resolveTo:_ve,resolveAll:gve},pve={tokenize:bve},mve={tokenize:yve},hve={tokenize:vve};function gve(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 _ve(t,e){let r=t.length,o=0,n,a,i,s;for(;r--;)if(n=t[r][1],a){if(n.type==="link"||n.type==="labelLink"&&n._inactive)break;t[r][0]==="enter"&&n.type==="labelLink"&&(n._inactive=!0)}else if(i){if(t[r][0]==="enter"&&(n.type==="labelImage"||n.type==="labelLink")&&!n._balanced&&(a=r,n.type!=="labelLink")){o=2;break}}else n.type==="labelEnd"&&(i=r);let l={type:t[a][1].type==="labelLink"?"link":"image",start:Object.assign({},t[a][1].start),end:Object.assign({},t[t.length-1][1].end)},c={type:"label",start:Object.assign({},t[a][1].start),end:Object.assign({},t[i][1].end)},u={type:"labelText",start:Object.assign({},t[a+o+2][1].end),end:Object.assign({},t[i-2][1].start)};return s=[["enter",l,e],["enter",c,e]],s=Mo(s,t.slice(a+1,a+o+3)),s=Mo(s,[["enter",u,e]]),s=Mo(s,ts(e.parser.constructs.insideSpan.null,t.slice(a+o+4,i-3),e)),s=Mo(s,[["exit",u,e],t[i-2],t[i-1],["exit",c,e]]),s=Mo(s,t.slice(i+1)),s=Mo(s,[["exit",l,e]]),Ir(t,a,t.length,s),t}function xve(t,e,r){let o=this,n=o.events.length,a,i;for(;n--;)if((o.events[n][1].type==="labelImage"||o.events[n][1].type==="labelLink")&&!o.events[n][1]._balanced){a=o.events[n][1];break}return s;function s(p){return a?a._inactive?d(p):(i=o.parser.defined.includes(mo(o.sliceSerialize({start:a.end,end:o.now()}))),t.enter("labelEnd"),t.enter("labelMarker"),t.consume(p),t.exit("labelMarker"),t.exit("labelEnd"),l):r(p)}function l(p){return p===40?t.attempt(pve,u,i?u:d)(p):p===91?t.attempt(mve,u,i?c:d)(p):i?u(p):d(p)}function c(p){return t.attempt(hve,u,d)(p)}function u(p){return e(p)}function d(p){return a._balanced=!0,r(p)}}function bve(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 Xe(d)?Dl(t,a)(d):a(d)}function a(d){return d===41?u(d):uy(t,i,s,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function i(d){return Xe(d)?Dl(t,l)(d):u(d)}function s(d){return r(d)}function l(d){return d===34||d===39||d===40?fy(t,c,r,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):u(d)}function c(d){return Xe(d)?Dl(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 yve(t,e,r){let o=this;return n;function n(s){return dy.call(o,t,a,i,"reference","referenceMarker","referenceString")(s)}function a(s){return o.parser.defined.includes(mo(o.sliceSerialize(o.events[o.events.length-1][1]).slice(1,-1)))?e(s):r(s)}function i(s){return r(s)}}function vve(t,e,r){return o;function o(a){return t.enter("reference"),t.enter("referenceMarker"),t.consume(a),t.exit("referenceMarker"),n}function n(a){return a===93?(t.enter("referenceMarker"),t.consume(a),t.exit("referenceMarker"),t.exit("reference"),e):r(a)}}var nk={name:"labelStartImage",tokenize:Ive,resolveAll:Rl.resolveAll};function Ive(t,e,r){let o=this;return n;function n(s){return t.enter("labelImage"),t.enter("labelImageMarker"),t.consume(s),t.exit("labelImageMarker"),a}function a(s){return s===91?(t.enter("labelMarker"),t.consume(s),t.exit("labelMarker"),t.exit("labelImage"),i):r(s)}function i(s){return s===94&&"_hiddenFootnoteSupport"in o.parser.constructs?r(s):e(s)}}var ak={name:"labelStartLink",tokenize:wve,resolveAll:Rl.resolveAll};function wve(t,e,r){let o=this;return n;function n(i){return t.enter("labelLink"),t.enter("labelMarker"),t.consume(i),t.exit("labelMarker"),t.exit("labelLink"),a}function a(i){return i===94&&"_hiddenFootnoteSupport"in o.parser.constructs?r(i):e(i)}}var nm={name:"lineEnding",tokenize:Eve};function Eve(t,e){return r;function r(o){return t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),Ee(t,e,"linePrefix")}}var Nl={name:"thematicBreak",tokenize:Sve};function Sve(t,e,r){let o=0,n;return a;function a(c){return t.enter("thematicBreak"),i(c)}function i(c){return n=c,s(c)}function s(c){return c===n?(t.enter("thematicBreakSequence"),l(c)):o>=3&&(c===null||ie(c))?(t.exit("thematicBreak"),e(c)):r(c)}function l(c){return c===n?(t.consume(c),o++,l):(t.exit("thematicBreakSequence"),Pe(c)?Ee(t,s,"whitespace")(c):s(c))}}var ho={name:"list",tokenize:Tve,continuation:{tokenize:Pve},exit:Ave},Cve={tokenize:Dve,partial:!0},kve={tokenize:Ove,partial:!0};function Tve(t,e,r){let o=this,n=o.events[o.events.length-1],a=n&&n[1].type==="linePrefix"?n[2].sliceSerialize(n[1],!0).length:0,i=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:em(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(Nl,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 em(m)&&++i<10?(t.consume(m),l):(!o.interrupt||i<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(Pa,o.interrupt?r:u,t.attempt(Cve,p,d))}function u(m){return o.containerState.initialBlankLine=!0,a++,p(m)}function d(m){return Pe(m)?(t.enter("listItemPrefixWhitespace"),t.consume(m),t.exit("listItemPrefixWhitespace"),p):r(m)}function p(m){return o.containerState.size=a+o.sliceSerialize(t.exit("listItemPrefix"),!0).length,e(m)}}function Pve(t,e,r){let o=this;return o.containerState._closeFlow=void 0,t.check(Pa,n,a);function n(s){return o.containerState.furtherBlankLines=o.containerState.furtherBlankLines||o.containerState.initialBlankLine,Ee(t,e,"listItemIndent",o.containerState.size+1)(s)}function a(s){return o.containerState.furtherBlankLines||!Pe(s)?(o.containerState.furtherBlankLines=void 0,o.containerState.initialBlankLine=void 0,i(s)):(o.containerState.furtherBlankLines=void 0,o.containerState.initialBlankLine=void 0,t.attempt(kve,e,i)(s))}function i(s){return o.containerState._closeFlow=!0,o.interrupt=void 0,Ee(t,t.attempt(ho,e,r),"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s)}}function Ove(t,e,r){let o=this;return Ee(t,n,"listItemIndent",o.containerState.size+1);function n(a){let i=o.events[o.events.length-1];return i&&i[1].type==="listItemIndent"&&i[2].sliceSerialize(i[1],!0).length===o.containerState.size?e(a):r(a)}}function Ave(t){t.exit(this.containerState.type)}function Dve(t,e,r){let o=this;return Ee(t,n,"listItemPrefixWhitespace",o.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function n(a){let i=o.events[o.events.length-1];return!Pe(a)&&i&&i[1].type==="listItemPrefixWhitespace"?e(a):r(a)}}var py={name:"setextUnderline",tokenize:Nve,resolveTo:Rve};function Rve(t,e){let r=t.length,o,n,a;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),!a&&t[r][1].type==="definition"&&(a=r);let i={type:"setextHeading",start:Object.assign({},t[n][1].start),end:Object.assign({},t[t.length-1][1].end)};return t[n][1].type="setextHeadingText",a?(t.splice(n,0,["enter",i,e]),t.splice(a+1,0,["exit",t[o][1],e]),t[o][1].end=Object.assign({},t[a][1].end)):t[o][1]=i,t.push(["exit",i,e]),t}function Nve(t,e,r){let o=this,n;return a;function a(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,i(c)):r(c)}function i(c){return t.enter("setextHeadingLineSequence"),s(c)}function s(c){return c===n?(t.consume(c),s):(t.exit("setextHeadingLineSequence"),Pe(c)?Ee(t,l,"lineSuffix")(c):l(c))}function l(c){return c===null||ie(c)?(t.exit("setextHeadingLine"),e(c)):r(c)}}var PV={tokenize:Mve};function Mve(t){let e=this,r=t.attempt(Pa,o,t.attempt(this.parser.constructs.flowInitial,n,Ee(t,t.attempt(this.parser.constructs.flow,n,t.attempt(QC,n)),"linePrefix")));return r;function o(a){if(a===null){t.consume(a);return}return t.enter("lineEndingBlank"),t.consume(a),t.exit("lineEndingBlank"),e.currentConstruct=void 0,r}function n(a){if(a===null){t.consume(a);return}return t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),e.currentConstruct=void 0,r}}var OV={resolveAll:NV()},AV=RV("string"),DV=RV("text");function RV(t){return{tokenize:e,resolveAll:NV(t==="text"?Lve:void 0)};function e(r){let o=this,n=this.parser.constructs[t],a=r.attempt(n,i,s);return i;function i(u){return c(u)?a(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"),a(u)):(r.consume(u),l)}function c(u){if(u===null)return!0;let d=n[u],p=-1;if(d)for(;++p<d.length;){let m=d[p];if(!m.previous||m.previous.call(o,o.previous))return!0}return!1}}}function NV(t){return e;function e(r,o){let n=-1,a;for(;++n<=r.length;)a===void 0?r[n]&&r[n][1].type==="data"&&(a=n,n++):(!r[n]||r[n][1].type!=="data")&&(n!==a+2&&(r[a][1].end=r[n-1][1].end,r.splice(a+2,n-a-2),n=a+2),a=void 0);return t?t(r,o):r}}function Lve(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),a=n.length,i=-1,s=0,l;for(;a--;){let c=n[a];if(typeof c=="string"){for(i=c.length;c.charCodeAt(i-1)===32;)s++,i--;if(i)break;i=-1}else if(c===-2)l=!0,s++;else if(c!==-1){a++;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+a,_bufferIndex:a?i:o.start._bufferIndex+i},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 MV(t,e,r){let o=Object.assign(r?Object.assign({},r):{line:1,column:1,offset:0},{_index:0,_bufferIndex:-1}),n={},a=[],i=[],s=[],l=!0,c={consume:I,enter:w,exit:v,attempt:S(T),check:S(O),interrupt:S(O,{interrupt:!0})},u={previous:null,code:null,containerState:{},events:[],parser:t,sliceStream:g,sliceSerialize:h,now:_,defineSkip:x,write:m},d=e.tokenize.call(u,c),p;return e.resolveAll&&a.push(e),u;function m(R){return i=Mo(i,R),b(),i[i.length-1]!==null?[]:(C(e,0),u.events=ts(a,u.events,u),u.events)}function h(R,z){return Fve(g(R),z)}function g(R){return Bve(i,R)}function _(){let{line:R,column:z,offset:B,_index:M,_bufferIndex:V}=o;return{line:R,column:z,offset:B,_index:M,_bufferIndex:V}}function x(R){n[R.line]=R.column,N()}function b(){let R;for(;o._index<i.length;){let z=i[o._index];if(typeof z=="string")for(R=o._index,o._bufferIndex<0&&(o._bufferIndex=0);o._index===R&&o._bufferIndex<z.length;)y(z.charCodeAt(o._bufferIndex));else y(z)}}function y(R){l=void 0,p=R,d=d(R)}function I(R){ie(R)?(o.line++,o.column=1,o.offset+=R===-3?2:1,N()):R!==-1&&(o.column++,o.offset++),o._bufferIndex<0?o._index++:(o._bufferIndex++,o._bufferIndex===i[o._index].length&&(o._bufferIndex=-1,o._index++)),u.previous=R,l=!0}function w(R,z){let B=z||{};return B.type=R,B.start=_(),u.events.push(["enter",B,u]),s.push(B),B}function v(R){let z=s.pop();return z.end=_(),u.events.push(["exit",z,u]),z}function T(R,z){C(R,z.from)}function O(R,z){z.restore()}function S(R,z){return B;function B(M,V,U){let G,k,Z,te;return Array.isArray(M)?ce(M):"tokenize"in M?ce([M]):A(M);function A(Oe){return be;function be(st){let wt=st!==null&&Oe[st],mt=st!==null&&Oe.null,zt=[...Array.isArray(wt)?wt:wt?[wt]:[],...Array.isArray(mt)?mt:mt?[mt]:[]];return ce(zt)(st)}}function ce(Oe){return G=Oe,k=0,Oe.length===0?U:Se(Oe[k])}function Se(Oe){return be;function be(st){return te=F(),Z=Oe,Oe.partial||(u.currentConstruct=Oe),Oe.name&&u.parser.constructs.disable.null.includes(Oe.name)?et(st):Oe.tokenize.call(z?Object.assign(Object.create(u),z):u,c,Ge,et)(st)}}function Ge(Oe){return l=!0,R(Z,te),V}function et(Oe){return l=!0,te.restore(),++k<G.length?Se(G[k]):U}}}function C(R,z){R.resolveAll&&!a.includes(R)&&a.push(R),R.resolve&&Ir(u.events,z,u.events.length-z,R.resolve(u.events.slice(z),u)),R.resolveTo&&(u.events=R.resolveTo(u.events,u))}function F(){let R=_(),z=u.previous,B=u.currentConstruct,M=u.events.length,V=Array.from(s);return{restore:U,from:M};function U(){o=R,u.previous=z,u.currentConstruct=B,u.events.length=M,s=V,N()}}function N(){o.line in n&&o.column<2&&(o.column=n[o.line],o.offset+=n[o.line]-1)}}function Bve(t,e){let r=e.start._index,o=e.start._bufferIndex,n=e.end._index,a=e.end._bufferIndex,i;if(r===n)i=[t[r].slice(o,a)];else{if(i=t.slice(r,n),o>-1){let s=i[0];typeof s=="string"?i[0]=s.slice(o):i.shift()}a>0&&i.push(t[n].slice(0,a))}return i}function Fve(t,e){let r=-1,o=[],n;for(;++r<t.length;){let a=t[r],i;if(typeof a=="string")i=a;else switch(a){case-5:{i="\r";break}case-4:{i=`
|
|
52
52
|
`;break}case-3:{i=`\r
|
|
53
|
-
`;break}case-2:{i=e?" ":" ";break}case-1:{if(!e&&n)continue;i=" ";break}default:i=String.fromCharCode(a)}n=a===-2,o.push(i)}return o.join("")}var ik={};Qj(ik,{attentionMarkers:()=>Gve,contentInitial:()=>Uve,disable:()=>Wve,document:()=>zve,flow:()=>Hve,flowInitial:()=>Vve,insideSpan:()=>qve,string:()=>$ve,text:()=>jve});var zve={42:ho,43:ho,45:ho,48:ho,49:ho,50:ho,51:ho,52:ho,53:ho,54:ho,55:ho,56:ho,57:ho,62:ny},Uve={91:ZC},Vve={[-2]:rm,[-1]:rm,32:rm},Hve={35:ek,42:Nl,45:[py,Nl],60:rk,61:py,95:Nl,96:sy,126:sy},$ve={38:iy,92:ay},jve={[-5]:nm,[-4]:nm,[-3]:nm,33:nk,38:iy,42:tm,60:[XC,ok],91:ak,92:[JC,ay],93:Rl,95:tm,96:YC},qve={null:[tm,OV]},Gve={null:[42,95]},Wve={null:[]};function sk(t){let r=ry([ik,...(t||{}).extensions||[]]),o={defined:[],lazy:{},constructs:r,content:n(wV),document:n(SV),flow:n(PV),string:n(AV),text:n(DV)};return o;function n(a){return i;function i(s){return MV(o,a,s)}}}function lk(t){for(;!cy(t););return t}var LV=/[\0\t\n\r]/g;function ck(){let t=1,e="",r=!0,o;return n;function n(a,i,s){let l=[],c,u,d,p,m;for(a=e+(typeof a=="string"?a.toString():new TextDecoder(i||void 0).decode(a)),d=0,e="",r&&(a.charCodeAt(0)===65279&&d++,r=void 0);d<a.length;){if(LV.lastIndex=d,c=LV.exec(a),p=c&&c.index!==void 0?c.index:a.length,m=a.charCodeAt(p),!c){e=a.slice(d);break}if(m===10&&d===p&&o)l.push(-3),o=void 0;else switch(o&&(l.push(-5),o=void 0),d<p&&(l.push(a.slice(d,p)),t+=p-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=p+1}return s&&(o&&l.push(-5),e&&l.push(e),l.push(null)),l}}var Kve=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function BV(t){return t.replace(Kve,Xve)}function Xve(t,e,r){if(e)return e;if(r.charCodeAt(0)===35){let n=r.charCodeAt(1),a=n===120||n===88;return oy(r.slice(a?2:1),a?16:10)}return Vu(r)||t}function $u(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?FV(t.position):"start"in t||"end"in t?FV(t):"line"in t||"column"in t?uk(t):""}function uk(t){return zV(t&&t.line)+":"+zV(t&&t.column)}function FV(t){return uk(t&&t.start)+"-"+uk(t&&t.end)}function zV(t){return t&&typeof t=="number"?t:1}var VV={}.hasOwnProperty;function dk(t,e,r){return typeof e!="string"&&(r=e,e=void 0),Yve(r)(lk(sk(r).document().write(ck()(t,e,!0))))}function Yve(t){let e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:a(ft),autolinkProtocol:S,autolinkEmail:S,atxHeading:a(ao),blockQuote:a(st),characterEscape:S,characterReference:S,codeFenced:a(wt),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:a(wt,i),codeText:a(mt,i),codeTextData:S,data:S,codeFlowValue:S,definition:a(zt),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:a(ot),hardBreakEscape:a(dt),hardBreakTrailing:a(dt),htmlFlow:a(fe,i),htmlFlowData:S,htmlText:a(fe,i),htmlTextData:S,image:a(go),label:i,link:a(ft),listItem:a(wr),listItemValue:p,listOrdered:a(Be,d),listUnordered:a(Be),paragraph:a(fr),reference:A,referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:a(ao),strong:a(Vr),thematicBreak:a(W)},exit:{atxHeading:l(),atxHeadingSequence:w,autolink:l(),autolinkEmail:be,autolinkProtocol:Oe,blockQuote:l(),characterEscapeValue:C,characterReferenceMarkerHexadecimal:Se,characterReferenceMarkerNumeric:Se,characterReferenceValue:Ge,characterReference:et,codeFenced:l(_),codeFencedFence:g,codeFencedFenceInfo:m,codeFencedFenceMeta:h,codeFlowValue:C,codeIndented:l(x),codeText:l(B),codeTextData:C,data:C,definition:l(),definitionDestinationString:I,definitionLabelString:b,definitionTitleString:y,emphasis:l(),hardBreakEscape:l(N),hardBreakTrailing:l(N),htmlFlow:l(R),htmlFlowData:C,htmlText:l(z),htmlTextData:C,image:l(V),label:G,labelText:U,lineEnding:F,link:l(M),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:ce,resourceDestinationString:k,resourceTitleString:Z,resource:te,setextHeading:l(O),setextHeadingLineSequence:T,setextHeadingText:v,strong:l(),thematicBreak:l()}};HV(e,(t||{}).mdastExtensions||[]);let r={};return o;function o(D){let $={type:"root",children:[]},J={stack:[$],tokenStack:[],config:e,enter:s,exit:c,buffer:i,resume:u,data:r},ye=[],je=-1;for(;++je<D.length;)if(D[je][1].type==="listOrdered"||D[je][1].type==="listUnordered")if(D[je][0]==="enter")ye.push(je);else{let nt=ye.pop();je=n(D,nt,je)}for(je=-1;++je<D.length;){let nt=e[D[je][0]];VV.call(nt,D[je][1].type)&&nt[D[je][1].type].call(Object.assign({sliceSerialize:D[je][2].sliceSerialize},J),D[je][1])}if(J.tokenStack.length>0){let nt=J.tokenStack[J.tokenStack.length-1];(nt[1]||UV).call(J,void 0,nt[0])}for($.position={start:rs(D.length>0?D[0][1].start:{line:1,column:1,offset:0}),end:rs(D.length>0?D[D.length-2][1].end:{line:1,column:1,offset:0})},je=-1;++je<e.transforms.length;)$=e.transforms[je]($)||$;return $}function n(D,$,J){let ye=$-1,je=-1,nt=!1,Fo,nr,Kt,hn;for(;++ye<=J;){let Hr=D[ye];switch(Hr[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Hr[0]==="enter"?je++:je--,hn=void 0;break}case"lineEndingBlank":{Hr[0]==="enter"&&(Fo&&!hn&&!je&&!Kt&&(Kt=ye),hn=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:hn=void 0}if(!je&&Hr[0]==="enter"&&Hr[1].type==="listItemPrefix"||je===-1&&Hr[0]==="exit"&&(Hr[1].type==="listUnordered"||Hr[1].type==="listOrdered")){if(Fo){let _o=ye;for(nr=void 0;_o--;){let xo=D[_o];if(xo[1].type==="lineEnding"||xo[1].type==="lineEndingBlank"){if(xo[0]==="exit")continue;nr&&(D[nr][1].type="lineEndingBlank",nt=!0),xo[1].type="lineEnding",nr=_o}else if(!(xo[1].type==="linePrefix"||xo[1].type==="blockQuotePrefix"||xo[1].type==="blockQuotePrefixWhitespace"||xo[1].type==="blockQuoteMarker"||xo[1].type==="listItemIndent"))break}Kt&&(!nr||Kt<nr)&&(Fo._spread=!0),Fo.end=Object.assign({},nr?D[nr][1].start:Hr[1].end),D.splice(nr||ye,0,["exit",Fo,Hr[2]]),ye++,J++}if(Hr[1].type==="listItemPrefix"){let _o={type:"listItem",_spread:!1,start:Object.assign({},Hr[1].start),end:void 0};Fo=_o,D.splice(ye,0,["enter",_o,Hr[2]]),ye++,J++,Kt=void 0,hn=!0}}}return D[$][1]._spread=nt,J}function a(D,$){return J;function J(ye){s.call(this,D(ye),ye),$&&$.call(this,ye)}}function i(){this.stack.push({type:"fragment",children:[]})}function s(D,$,J){this.stack[this.stack.length-1].children.push(D),this.stack.push(D),this.tokenStack.push([$,J]),D.position={start:rs($.start),end:void 0}}function l(D){return $;function $(J){D&&D.call(this,J),c.call(this,J)}}function c(D,$){let J=this.stack.pop(),ye=this.tokenStack.pop();if(ye)ye[0].type!==D.type&&($?$.call(this,D,ye[0]):(ye[1]||UV).call(this,D,ye[0]));else throw new Error("Cannot close `"+D.type+"` ("+$u({start:D.start,end:D.end})+"): it\u2019s not open");J.position.end=rs(D.end)}function u(){return KC(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function p(D){if(this.data.expectingFirstListItemValue){let $=this.stack[this.stack.length-2];$.start=Number.parseInt(this.sliceSerialize(D),10),this.data.expectingFirstListItemValue=void 0}}function m(){let D=this.resume(),$=this.stack[this.stack.length-1];$.lang=D}function h(){let D=this.resume(),$=this.stack[this.stack.length-1];$.meta=D}function g(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function _(){let D=this.resume(),$=this.stack[this.stack.length-1];$.value=D.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function x(){let D=this.resume(),$=this.stack[this.stack.length-1];$.value=D.replace(/(\r?\n|\r)$/g,"")}function b(D){let $=this.resume(),J=this.stack[this.stack.length-1];J.label=$,J.identifier=mo(this.sliceSerialize(D)).toLowerCase()}function y(){let D=this.resume(),$=this.stack[this.stack.length-1];$.title=D}function I(){let D=this.resume(),$=this.stack[this.stack.length-1];$.url=D}function w(D){let $=this.stack[this.stack.length-1];if(!$.depth){let J=this.sliceSerialize(D).length;$.depth=J}}function v(){this.data.setextHeadingSlurpLineEnding=!0}function T(D){let $=this.stack[this.stack.length-1];$.depth=this.sliceSerialize(D).codePointAt(0)===61?1:2}function O(){this.data.setextHeadingSlurpLineEnding=void 0}function S(D){let J=this.stack[this.stack.length-1].children,ye=J[J.length-1];(!ye||ye.type!=="text")&&(ye=_e(),ye.position={start:rs(D.start),end:void 0},J.push(ye)),this.stack.push(ye)}function C(D){let $=this.stack.pop();$.value+=this.sliceSerialize(D),$.position.end=rs(D.end)}function F(D){let $=this.stack[this.stack.length-1];if(this.data.atHardBreak){let J=$.children[$.children.length-1];J.position.end=rs(D.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes($.type)&&(S.call(this,D),C.call(this,D))}function N(){this.data.atHardBreak=!0}function R(){let D=this.resume(),$=this.stack[this.stack.length-1];$.value=D}function z(){let D=this.resume(),$=this.stack[this.stack.length-1];$.value=D}function B(){let D=this.resume(),$=this.stack[this.stack.length-1];$.value=D}function M(){let D=this.stack[this.stack.length-1];if(this.data.inReference){let $=this.data.referenceType||"shortcut";D.type+="Reference",D.referenceType=$,delete D.url,delete D.title}else delete D.identifier,delete D.label;this.data.referenceType=void 0}function V(){let D=this.stack[this.stack.length-1];if(this.data.inReference){let $=this.data.referenceType||"shortcut";D.type+="Reference",D.referenceType=$,delete D.url,delete D.title}else delete D.identifier,delete D.label;this.data.referenceType=void 0}function U(D){let $=this.sliceSerialize(D),J=this.stack[this.stack.length-2];J.label=BV($),J.identifier=mo($).toLowerCase()}function G(){let D=this.stack[this.stack.length-1],$=this.resume(),J=this.stack[this.stack.length-1];if(this.data.inReference=!0,J.type==="link"){let ye=D.children;J.children=ye}else J.alt=$}function k(){let D=this.resume(),$=this.stack[this.stack.length-1];$.url=D}function Z(){let D=this.resume(),$=this.stack[this.stack.length-1];$.title=D}function te(){this.data.inReference=void 0}function A(){this.data.referenceType="collapsed"}function ce(D){let $=this.resume(),J=this.stack[this.stack.length-1];J.label=$,J.identifier=mo(this.sliceSerialize(D)).toLowerCase(),this.data.referenceType="full"}function Se(D){this.data.characterReferenceType=D.type}function Ge(D){let $=this.sliceSerialize(D),J=this.data.characterReferenceType,ye;J?(ye=oy($,J==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ye=Vu($);let je=this.stack[this.stack.length-1];je.value+=ye}function et(D){let $=this.stack.pop();$.position.end=rs(D.end)}function Oe(D){C.call(this,D);let $=this.stack[this.stack.length-1];$.url=this.sliceSerialize(D)}function be(D){C.call(this,D);let $=this.stack[this.stack.length-1];$.url="mailto:"+this.sliceSerialize(D)}function st(){return{type:"blockquote",children:[]}}function wt(){return{type:"code",lang:null,meta:null,value:""}}function mt(){return{type:"inlineCode",value:""}}function zt(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ot(){return{type:"emphasis",children:[]}}function ao(){return{type:"heading",depth:0,children:[]}}function dt(){return{type:"break"}}function fe(){return{type:"html",value:""}}function go(){return{type:"image",title:null,url:"",alt:null}}function ft(){return{type:"link",title:null,url:"",children:[]}}function Be(D){return{type:"list",ordered:D.type==="listOrdered",start:null,spread:D._spread,children:[]}}function wr(D){return{type:"listItem",spread:D._spread,checked:null,children:[]}}function fr(){return{type:"paragraph",children:[]}}function Vr(){return{type:"strong",children:[]}}function _e(){return{type:"text",value:""}}function W(){return{type:"thematicBreak"}}}function rs(t){return{line:t.line,column:t.column,offset:t.offset}}function HV(t,e){let r=-1;for(;++r<e.length;){let o=e[r];Array.isArray(o)?HV(t,o):Qve(t,o)}}function Qve(t,e){let r;for(r in e)if(VV.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 UV(t,e){throw t?new Error("Cannot close `"+t.type+"` ("+$u({start:t.start,end:t.end})+"): a different token (`"+e.type+"`, "+$u({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+$u({start:e.start,end:e.end})+") is still open")}function fk(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 pk(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var ju=function(t){if(t==null)return tIe;if(typeof t=="function")return my(t);if(typeof t=="object")return Array.isArray(t)?Zve(t):Jve(t);if(typeof t=="string")return eIe(t);throw new Error("Expected function, string, or object as test")};function Zve(t){let e=[],r=-1;for(;++r<t.length;)e[r]=ju(t[r]);return my(o);function o(...n){let a=-1;for(;++a<e.length;)if(e[a].apply(this,n))return!0;return!1}}function Jve(t){let e=t;return my(r);function r(o){let n=o,a;for(a in t)if(n[a]!==e[a])return!1;return!0}}function eIe(t){return my(e);function e(r){return r&&r.type===t}}function my(t){return e;function e(r,o,n){return!!(rIe(r)&&t.call(this,r,typeof o=="number"?o:void 0,n||void 0))}}function tIe(){return!0}function rIe(t){return t!==null&&typeof t=="object"&&"type"in t}var $V=[],jV=!0,mk=!1,qV="skip";function hk(t,e,r,o){let n;typeof e=="function"&&typeof r!="function"?(o=r,r=e):n=e;let a=ju(n),i=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(p,"name",{value:"node ("+(l.type+(m?"<"+m+">":""))+")"})}return p;function p(){let m=$V,h,g,_;if((!e||a(l,c,u[u.length-1]||void 0))&&(m=oIe(r(l,u)),m[0]===mk))return m;if("children"in l&&l.children){let x=l;if(x.children&&m[0]!==qV)for(g=(o?x.children.length:-1)+i,_=u.concat(x);g>-1&&g<x.children.length;){let b=x.children[g];if(h=s(b,g,_)(),h[0]===mk)return h;g=typeof h[1]=="number"?h[1]:g+i}}return m}}}function oIe(t){return Array.isArray(t)?t:typeof t=="number"?[jV,t]:t==null?$V:[t]}function gk(t,e,r){let n=ju((r||{}).ignore||[]),a=nIe(e),i=-1;for(;++i<a.length;)hk(t,"text",s);function s(c,u){let d=-1,p;for(;++d<u.length;){let m=u[d],h=p?p.children:void 0;if(n(m,h?h.indexOf(m):void 0,p))return;p=m}if(p)return l(c,u)}function l(c,u){let d=u[u.length-1],p=a[i][0],m=a[i][1],h=0,_=d.children.indexOf(c),x=!1,b=[];p.lastIndex=0;let y=p.exec(c.value);for(;y;){let I=y.index,w={index:y.index,input:y.input,stack:[...u,c]},v=m(...y,w);if(typeof v=="string"&&(v=v.length>0?{type:"text",value:v}:void 0),v===!1?p.lastIndex=I+1:(h!==I&&b.push({type:"text",value:c.value.slice(h,I)}),Array.isArray(v)?b.push(...v):v&&b.push(v),h=I+y[0].length,x=!0),!p.global)break;y=p.exec(c.value)}return x?(h<c.value.length&&b.push({type:"text",value:c.value.slice(h)}),d.children.splice(_,1,...b)):b=[c],_+b.length}}function nIe(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([aIe(n[0]),iIe(n[1])])}return e}function aIe(t){return typeof t=="string"?new RegExp(pk(t),"g"):t}function iIe(t){return typeof t=="function"?t:function(){return t}}function xk(){return{transforms:[fIe],enter:{literalAutolink:sIe,literalAutolinkEmail:_k,literalAutolinkHttp:_k,literalAutolinkWww:_k},exit:{literalAutolink:dIe,literalAutolinkEmail:uIe,literalAutolinkHttp:lIe,literalAutolinkWww:cIe}}}function sIe(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function _k(t){this.config.enter.autolinkProtocol.call(this,t)}function lIe(t){this.config.exit.autolinkProtocol.call(this,t)}function cIe(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 uIe(t){this.config.exit.autolinkEmail.call(this,t)}function dIe(t){this.exit(t)}function fIe(t){gk(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,pIe],[/([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/g,mIe]],{ignore:["link","linkReference"]})}function pIe(t,e,r,o,n){let a="";if(!GV(n)||(/^w/i.test(e)&&(r=e+r,e="",a="http://"),!hIe(r)))return!1;let i=gIe(r+o);if(!i[0])return!1;let s={type:"link",title:null,url:a+e+i[0],children:[{type:"text",value:e+i[0]}]};return i[1]?[s,{type:"text",value:i[1]}]:s}function mIe(t,e,r,o){return!GV(o,!0)||/[-\d_]$/.test(r)?!1:{type:"link",title:null,url:"mailto:"+e+"@"+r,children:[{type:"text",value:e+"@"+r}]}}function hIe(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 gIe(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=fk(t,"("),a=fk(t,")");for(;o!==-1&&n>a;)t+=r.slice(0,o+1),r=r.slice(o+1),o=r.indexOf(")"),a++;return[t,r]}function GV(t,e){let r=t.input.charCodeAt(t.index-1);return(t.index===0||Ta(r)||Al(r))&&(!e||r!==47)}CIe.peek=kIe;function bk(){return{enter:{gfmFootnoteDefinition:xIe,gfmFootnoteDefinitionLabelString:bIe,gfmFootnoteCall:IIe,gfmFootnoteCallString:wIe},exit:{gfmFootnoteDefinition:vIe,gfmFootnoteDefinitionLabelString:yIe,gfmFootnoteCall:SIe,gfmFootnoteCallString:EIe}}}function xIe(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function bIe(){this.buffer()}function yIe(t){let e=this.resume(),r=this.stack[this.stack.length-1];r.type,r.label=e,r.identifier=mo(this.sliceSerialize(t)).toLowerCase()}function vIe(t){this.exit(t)}function IIe(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function wIe(){this.buffer()}function EIe(t){let e=this.resume(),r=this.stack[this.stack.length-1];r.type,r.label=e,r.identifier=mo(this.sliceSerialize(t)).toLowerCase()}function SIe(t){this.exit(t)}function CIe(t,e,r,o){let n=r.createTracker(o),a=n.move("[^"),i=r.enter("footnoteReference"),s=r.enter("reference");return a+=n.move(r.safe(r.associationId(t),{...n.current(),before:a,after:"]"})),s(),i(),a+=n.move("]"),a}function kIe(){return"["}AIe.peek=DIe;function yk(){return{canContainEols:["delete"],enter:{strikethrough:PIe},exit:{strikethrough:OIe}}}function PIe(t){this.enter({type:"delete",children:[]},t)}function OIe(t){this.exit(t)}function AIe(t,e,r,o){let n=r.createTracker(o),a=r.enter("strikethrough"),i=n.move("~~");return i+=r.containerPhrasing(t,{...n.current(),before:i,after:"~"}),i+=n.move("~~"),a(),i}function DIe(){return"~"}function Ik(){return{enter:{table:NIe,tableData:WV,tableHeader:WV,tableRow:LIe},exit:{codeText:BIe,table:MIe,tableData:vk,tableHeader:vk,tableRow:vk}}}function NIe(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 MIe(t){this.exit(t),this.data.inTable=void 0}function LIe(t){this.enter({type:"tableRow",children:[]},t)}function vk(t){this.exit(t)}function WV(t){this.enter({type:"tableCell",children:[]},t)}function BIe(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,FIe));let r=this.stack[this.stack.length-1];r.type,r.value=e,this.exit(t)}function FIe(t,e){return e==="|"?e:t}function wk(){return{exit:{taskListCheckValueChecked:KV,taskListCheckValueUnchecked:KV,paragraph:UIe}}}function KV(t){let e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function UIe(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,a=-1,i;for(;++a<n.length;){let s=n[a];if(s.type==="paragraph"){i=s;break}}i===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 Ek(){return[xk(),bk(),yk(),Ik(),wk()]}var HIe={tokenize:WIe,partial:!0},XV={tokenize:KIe,partial:!0},YV={tokenize:XIe,partial:!0},QV={tokenize:YIe,partial:!0},$Ie={tokenize:QIe,partial:!0},ZV={tokenize:qIe,previous:eH},JV={tokenize:GIe,previous:tH},ni={tokenize:jIe,previous:rH},Oa={};function Ck(){return{text:Oa}}var Ml=48;for(;Ml<123;)Oa[Ml]=ni,Ml++,Ml===58?Ml=65:Ml===91&&(Ml=97);Oa[43]=ni;Oa[45]=ni;Oa[46]=ni;Oa[95]=ni;Oa[72]=[ni,JV];Oa[104]=[ni,JV];Oa[87]=[ni,ZV];Oa[119]=[ni,ZV];function jIe(t,e,r){let o=this,n,a;return i;function i(d){return!Sk(d)||!rH.call(o,o.previous)||kk(o.events)?r(d):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),s(d))}function s(d){return Sk(d)?(t.consume(d),s):d===64?(t.consume(d),l):r(d)}function l(d){return d===46?t.check($Ie,u,c)(d):d===45||d===95||Or(d)?(a=!0,t.consume(d),l):u(d)}function c(d){return t.consume(d),n=!0,l}function u(d){return a&&n&&Pr(o.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(d)):r(d)}}function qIe(t,e,r){let o=this;return n;function n(i){return i!==87&&i!==119||!eH.call(o,o.previous)||kk(o.events)?r(i):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(HIe,t.attempt(XV,t.attempt(YV,a),r),r)(i))}function a(i){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(i)}}function GIe(t,e,r){let o=this,n="",a=!1;return i;function i(d){return(d===72||d===104)&&tH.call(o,o.previous)&&!kk(o.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),n+=String.fromCodePoint(d),t.consume(d),s):r(d)}function s(d){if(Pr(d)&&n.length<5)return n+=String.fromCodePoint(d),t.consume(d),s;if(d===58){let p=n.toLowerCase();if(p==="http"||p==="https")return t.consume(d),l}return r(d)}function l(d){return d===47?(t.consume(d),a?c:(a=!0,l)):r(d)}function c(d){return d===null||Ol(d)||Xe(d)||Ta(d)||Al(d)?r(d):t.attempt(XV,t.attempt(YV,u),r)(d)}function u(d){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(d)}}function WIe(t,e,r){let o=0;return n;function n(i){return(i===87||i===119)&&o<3?(o++,t.consume(i),n):i===46&&o===3?(t.consume(i),a):r(i)}function a(i){return i===null?r(i):e(i)}}function KIe(t,e,r){let o,n,a;return i;function i(c){return c===46||c===95?t.check(QV,l,s)(c):c===null||Xe(c)||Ta(c)||c!==45&&Al(c)?l(c):(a=!0,t.consume(c),i)}function s(c){return c===95?o=!0:(n=o,o=void 0),t.consume(c),i}function l(c){return n||o||!a?r(c):e(c)}}function XIe(t,e){let r=0,o=0;return n;function n(i){return i===40?(r++,t.consume(i),n):i===41&&o<r?a(i):i===33||i===34||i===38||i===39||i===41||i===42||i===44||i===46||i===58||i===59||i===60||i===63||i===93||i===95||i===126?t.check(QV,e,a)(i):i===null||Xe(i)||Ta(i)?e(i):(t.consume(i),n)}function a(i){return i===41&&o++,t.consume(i),n}}function YIe(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),a):s===93?(t.consume(s),n):s===60||s===null||Xe(s)||Ta(s)?e(s):r(s)}function n(s){return s===null||s===40||s===91||Xe(s)||Ta(s)?e(s):o(s)}function a(s){return Pr(s)?i(s):r(s)}function i(s){return s===59?(t.consume(s),o):Pr(s)?(t.consume(s),i):r(s)}}function QIe(t,e,r){return o;function o(a){return t.consume(a),n}function n(a){return Or(a)?r(a):e(a)}}function eH(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Xe(t)}function tH(t){return!Pr(t)}function rH(t){return!(t===47||Sk(t))}function Sk(t){return t===43||t===45||t===46||t===95||Or(t)}function kk(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 ZIe={tokenize:awe,partial:!0};function Tk(){return{document:{91:{tokenize:rwe,continuation:{tokenize:owe},exit:nwe}},text:{91:{tokenize:twe},93:{add:"after",tokenize:JIe,resolveTo:ewe}}}}function JIe(t,e,r){let o=this,n=o.events.length,a=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]),i;for(;n--;){let l=o.events[n][1];if(l.type==="labelImage"){i=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(!i||!i._balanced)return r(l);let c=mo(o.sliceSerialize({start:i.end,end:o.now()}));return c.codePointAt(0)!==94||!a.includes(c.slice(1))?r(l):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(l),t.exit("gfmFootnoteCallLabelMarker"),e(l))}}function ewe(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)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},t[r+3][1].end),end:Object.assign({},t[r+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;let i={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},t[t.length-1][1].start)},s={type:"chunkString",contentType:"string",start:Object.assign({},i.start),end:Object.assign({},i.end)},l=[t[r+1],t[r+2],["enter",n,e],t[r+3],t[r+4],["enter",a,e],["exit",a,e],["enter",i,e],["enter",s,e],["exit",s,e],["exit",i,e],t[t.length-2],t[t.length-1],["exit",n,e]];return t.splice(r,t.length-r+1,...l),t}function twe(t,e,r){let o=this,n=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]),a=0,i;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(a>999||d===93&&!i||d===null||d===91||Xe(d))return r(d);if(d===93){t.exit("chunkString");let p=t.exit("gfmFootnoteCallString");return n.includes(mo(o.sliceSerialize(p)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(d),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):r(d)}return Xe(d)||(i=!0),a++,t.consume(d),d===92?u:c}function u(d){return d===91||d===92||d===93?(t.consume(d),a++,c):c(d)}}function rwe(t,e,r){let o=this,n=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]),a,i=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(i>999||h===93&&!s||h===null||h===91||Xe(h))return r(h);if(h===93){t.exit("chunkString");let g=t.exit("gfmFootnoteDefinitionLabelString");return a=mo(o.sliceSerialize(g)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(h),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),p}return Xe(h)||(s=!0),i++,t.consume(h),h===92?d:u}function d(h){return h===91||h===92||h===93?(t.consume(h),i++,u):u(h)}function p(h){return h===58?(t.enter("definitionMarker"),t.consume(h),t.exit("definitionMarker"),n.includes(a)||n.push(a),Ee(t,m,"gfmFootnoteDefinitionWhitespace")):r(h)}function m(h){return e(h)}}function owe(t,e,r){return t.check(Pa,e,t.attempt(ZIe,e,r))}function nwe(t){t.exit("gfmFootnoteDefinition")}function awe(t,e,r){let o=this;return Ee(t,n,"gfmFootnoteDefinitionIndent",5);function n(a){let i=o.events[o.events.length-1];return i&&i[1].type==="gfmFootnoteDefinitionIndent"&&i[2].sliceSerialize(i[1],!0).length===4?e(a):r(a)}}function Pk(t){let r=(t||{}).singleTilde,o={tokenize:a,resolveAll:n};return r==null&&(r=!0),{text:{126:o},insideSpan:{null:[o]},attentionMarkers:{null:[126]}};function n(i,s){let l=-1;for(;++l<i.length;)if(i[l][0]==="enter"&&i[l][1].type==="strikethroughSequenceTemporary"&&i[l][1]._close){let c=l;for(;c--;)if(i[c][0]==="exit"&&i[c][1].type==="strikethroughSequenceTemporary"&&i[c][1]._open&&i[l][1].end.offset-i[l][1].start.offset===i[c][1].end.offset-i[c][1].start.offset){i[l][1].type="strikethroughSequence",i[c][1].type="strikethroughSequence";let u={type:"strikethrough",start:Object.assign({},i[c][1].start),end:Object.assign({},i[l][1].end)},d={type:"strikethroughText",start:Object.assign({},i[c][1].end),end:Object.assign({},i[l][1].start)},p=[["enter",u,s],["enter",i[c][1],s],["exit",i[c][1],s],["enter",d,s]],m=s.parser.constructs.insideSpan.null;m&&Ir(p,p.length,0,ts(m,i.slice(c+1,l),s)),Ir(p,p.length,0,[["exit",d,s],["enter",i[l][1],s],["exit",i[l][1],s],["exit",u,s]]),Ir(i,c-1,l-c+3,p),l=c+p.length-2;break}}for(l=-1;++l<i.length;)i[l][1].type==="strikethroughSequenceTemporary"&&(i[l][1].type="data");return i}function a(i,s,l){let c=this.previous,u=this.events,d=0;return p;function p(h){return c===126&&u[u.length-1][1].type!=="characterEscape"?l(h):(i.enter("strikethroughSequenceTemporary"),m(h))}function m(h){let g=Hu(c);if(h===126)return d>1?l(h):(i.consume(h),d++,m);if(d<2&&!r)return l(h);let _=i.exit("strikethroughSequenceTemporary"),x=Hu(h);return _._open=!x||x===2&&!!g,_._close=!g||g===2&&!!x,s(h)}}}var hy=class{constructor(){this.map=[]}add(e,r,o){iwe(this,e,r,o)}consume(e){if(this.map.sort(function(a,i){return a[0]-i[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 iwe(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 oH(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 a=o.length-1;o[a]=o[a]==="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 Ok(){return{flow:{null:{tokenize:swe,resolveAll:lwe}}}}function swe(t,e,r){let o=this,n=0,a=0,i;return s;function s(C){let F=o.events.length-1;for(;F>-1;){let z=o.events[F][1].type;if(z==="lineEnding"||z==="linePrefix")F--;else break}let N=F>-1?o.events[F][1].type:null,R=N==="tableHead"||N==="tableRow"?v:l;return R===v&&o.parser.lazy[o.now().line]?r(C):R(C)}function l(C){return t.enter("tableHead"),t.enter("tableRow"),c(C)}function c(C){return C===124||(i=!0,a+=1),u(C)}function u(C){return C===null?r(C):ie(C)?a>1?(a=0,o.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(C),t.exit("lineEnding"),m):r(C):Pe(C)?Ee(t,u,"whitespace")(C):(a+=1,i&&(i=!1,n+=1),C===124?(t.enter("tableCellDivider"),t.consume(C),t.exit("tableCellDivider"),i=!0,u):(t.enter("data"),d(C)))}function d(C){return C===null||C===124||Xe(C)?(t.exit("data"),u(C)):(t.consume(C),C===92?p:d)}function p(C){return C===92||C===124?(t.consume(C),d):d(C)}function m(C){return o.interrupt=!1,o.parser.lazy[o.now().line]?r(C):(t.enter("tableDelimiterRow"),i=!1,Pe(C)?Ee(t,h,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(C):h(C))}function h(C){return C===45||C===58?_(C):C===124?(i=!0,t.enter("tableCellDivider"),t.consume(C),t.exit("tableCellDivider"),g):w(C)}function g(C){return Pe(C)?Ee(t,_,"whitespace")(C):_(C)}function _(C){return C===58?(a+=1,i=!0,t.enter("tableDelimiterMarker"),t.consume(C),t.exit("tableDelimiterMarker"),x):C===45?(a+=1,x(C)):C===null||ie(C)?I(C):w(C)}function x(C){return C===45?(t.enter("tableDelimiterFiller"),b(C)):w(C)}function b(C){return C===45?(t.consume(C),b):C===58?(i=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(C),t.exit("tableDelimiterMarker"),y):(t.exit("tableDelimiterFiller"),y(C))}function y(C){return Pe(C)?Ee(t,I,"whitespace")(C):I(C)}function I(C){return C===124?h(C):C===null||ie(C)?!i||n!==a?w(C):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(C)):w(C)}function w(C){return r(C)}function v(C){return t.enter("tableRow"),T(C)}function T(C){return C===124?(t.enter("tableCellDivider"),t.consume(C),t.exit("tableCellDivider"),T):C===null||ie(C)?(t.exit("tableRow"),e(C)):Pe(C)?Ee(t,T,"whitespace")(C):(t.enter("data"),O(C))}function O(C){return C===null||C===124||Xe(C)?(t.exit("data"),T(C)):(t.consume(C),C===92?S:O)}function S(C){return C===92||C===124?(t.consume(C),O):O(C)}}function lwe(t,e){let r=-1,o=!0,n=0,a=[0,0,0,0],i=[0,0,0,0],s=!1,l=0,c,u,d,p=new hy;for(;++r<t.length;){let m=t[r],h=m[1];m[0]==="enter"?h.type==="tableHead"?(s=!1,l!==0&&(nH(p,e,l,c,u),u=void 0,l=0),c={type:"table",start:Object.assign({},h.start),end:Object.assign({},h.end)},p.add(r,0,[["enter",c,e]])):h.type==="tableRow"||h.type==="tableDelimiterRow"?(o=!0,d=void 0,a=[0,0,0,0],i=[0,r+1,0,0],s&&(s=!1,u={type:"tableBody",start:Object.assign({},h.start),end:Object.assign({},h.end)},p.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,i[2]===0&&(a[1]!==0&&(i[0]=i[1],d=gy(p,e,a,n,void 0,d),a=[0,0,0,0]),i[2]=r)):h.type==="tableCellDivider"&&(o?o=!1:(a[1]!==0&&(i[0]=i[1],d=gy(p,e,a,n,void 0,d)),a=i,i=[a[1],r,0,0])):h.type==="tableHead"?(s=!0,l=r):h.type==="tableRow"||h.type==="tableDelimiterRow"?(l=r,a[1]!==0?(i[0]=i[1],d=gy(p,e,a,n,r,d)):i[1]!==0&&(d=gy(p,e,i,n,r,d)),n=0):n&&(h.type==="data"||h.type==="tableDelimiterMarker"||h.type==="tableDelimiterFiller")&&(i[3]=r)}for(l!==0&&nH(p,e,l,c,u),p.consume(e.events),r=-1;++r<e.events.length;){let m=e.events[r];m[0]==="enter"&&m[1].type==="table"&&(m[1]._align=oH(e.events,r))}return t}function gy(t,e,r,o,n,a){let i=o===1?"tableHeader":o===2?"tableDelimiter":"tableData",s="tableContent";r[0]!==0&&(a.end=Object.assign({},qu(e.events,r[0])),t.add(r[0],0,[["exit",a,e]]));let l=qu(e.events,r[1]);if(a={type:i,start:Object.assign({},l),end:Object.assign({},l)},t.add(r[1],0,[["enter",a,e]]),r[2]!==0){let c=qu(e.events,r[2]),u=qu(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 p=e.events[r[2]],m=e.events[r[3]];if(p[1].end=Object.assign({},m[1].end),p[1].type="chunkText",p[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&&(a.end=Object.assign({},qu(e.events,n)),t.add(n,0,[["exit",a,e]]),a=void 0),a}function nH(t,e,r,o,n){let a=[],i=qu(e.events,r);n&&(n.end=Object.assign({},i),a.push(["exit",n,e])),o.end=Object.assign({},i),a.push(["exit",o,e]),t.add(r+1,0,a)}function qu(t,e){let r=t[e],o=r[0]==="enter"?"start":"end";return r[1][o]}var cwe={tokenize:uwe};function Ak(){return{text:{91:cwe}}}function uwe(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"),a)}function a(l){return Xe(l)?(t.enter("taskListCheckValueUnchecked"),t.consume(l),t.exit("taskListCheckValueUnchecked"),i):l===88||l===120?(t.enter("taskListCheckValueChecked"),t.consume(l),t.exit("taskListCheckValueChecked"),i):r(l)}function i(l){return l===93?(t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),s):r(l)}function s(l){return ie(l)?e(l):Pe(l)?t.check({tokenize:dwe},e,r)(l):r(l)}}function dwe(t,e,r){return Ee(t,o,"whitespace");function o(n){return n===null?r(n):e(n)}}function aH(t){return ry([Ck(),Tk(),Pk(t),Ok(),Ak()])}var iH={name:"@blinkk/root-cms",version:"1.4.7",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","build:signin":"esbuild signin/signin.tsx --bundle --minify --tsconfig=signin/tsconfig.json --outdir=dist/ui",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":"0.5.2","@genkit-ai/core":"0.5.2","@genkit-ai/vertexai":"0.5.2","body-parser":"1.20.2",commander:"11.0.0","csv-parse":"5.5.2","csv-stringify":"6.4.4","dts-dom":"3.7.0","fnv-plus":"1.3.1",jsonwebtoken:"9.0.2",kleur:"4.1.5",sirv:"2.0.3","tiny-glob":"0.2.9"},"//":"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.2.19","@firebase/app-types":"0.9.0","@firebase/rules-unit-testing":"3.0.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":"17.1.2","@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":"18.11.8",concurrently:"7.6.0",esbuild:"0.19.9",firebase:"10.5.2","firebase-admin":"11.11.1","firebase-functions":"4.8.0","firebase-tools":"12.9.1","highlight.js":"11.6.0","json-diff-kit":"1.0.29",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.19.3","preact-render-to-string":"6.3.1","preact-router":"4.1.2",react:"npm:@preact/compat@^17.1.2","react-dom":"npm:@preact/compat@^17.1.2","react-json-view-compare":"2.0.2",tsup:"8.0.1",typescript:"5.2.2",vite:"5.0.8",vitest:"0.34.6"},peerDependencies:{"@blinkk/root":"1.4.7","firebase-admin":">=11","firebase-functions":">=4",preact:">=10","preact-render-to-string":">=5"},peerDependenciesMeta:{"firebase-functions":{optional:!0}}};function sH(){return f("svg",{width:"100",height:"23",viewBox:"0 0 100 23",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[f("g",{"clip-path":"url(#clip0_1_318)",children:[f("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"}),f("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"}),f("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"}),f("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"}),f("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"}),f("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"}),f("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"}),f("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"}),f("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"})]}),f("defs",{children:f("clipPath",{id:"clip0_1_318",children:f("rect",{width:"99",height:"22",fill:"white",transform:"translate(0.0175781 0.177246)"})})})]})}var ai="1.5";function me(t){return f("div",{className:"Layout",children:[f(me.Top,{}),f(me.Side,{}),f(me.Main,{...t,children:t.children}),f(me.Bottom,{})]})}me.Top=()=>{let t=window.__ROOT_CTX.rootConfig.projectName||window.__ROOT_CTX.rootConfig.projectId;return f("div",{className:"Layout__top",children:[f("a",{className:"Layout__top__logo",href:"/cms",children:f(sH,{})}),f("div",{className:"Layout__top__version",children:["v",iH.version]}),f("div",{className:"Layout__top__project",children:t})]})};me.Side=()=>{let[t]=az(),e=t.url.replace(/\/*$/g,""),r=window.firebase.user,o=window.__ROOT_CTX.sidebar?.tools,n=window.__ROOT_CTX.experiments||{};return f("div",{className:"Layout__side",children:[f("div",{className:"Layout__side__buttons",children:[f(me.SideButton,{label:"Home",url:"/cms",active:e==="/cms",children:f(YS,{stroke:ai})}),f(me.SideButton,{label:"Content",url:"/cms/content",active:e.startsWith("/cms/content"),children:f(yl,{stroke:ai})}),f(me.SideButton,{label:"Releases",url:"/cms/releases",active:e.startsWith("/cms/releases"),children:f(Tu,{stroke:ai})}),f(me.SideButton,{label:"Data",url:"/cms/data",active:e.startsWith("/cms/data"),children:f(GS,{stroke:ai})}),f(me.SideButton,{label:"Assets",url:"/cms/assets",active:e.startsWith("/cms/assets"),children:f(eC,{stroke:ai})}),f(me.SideButton,{label:"Translations",url:"/cms/translations",active:e.startsWith("/cms/translations"),children:f(Wi,{stroke:ai})}),n.ai&&f(me.SideButton,{label:"Root AI (experimental)",url:"/cms/ai",active:e.startsWith("/cms/ai"),children:f(Il,{stroke:ai})}),o&&f(Ae,{children:[f("div",{className:"Layout__side__divider"}),Object.entries(o).map(([a,i])=>f(me.SideButton,{className:"Layout__side__tool",label:i.label||"",url:`/cms/tools/${a}`,active:e.startsWith(`/cms/tools/${a}`),children:i.icon?f("img",{className:"Layout__side__tool__icon",src:i.icon,alt:i.label||""}):f(US,{stroke:ai})})),f("div",{className:"Layout__side__divider"})]}),f(me.SideButton,{label:"Settings",url:"/cms/settings",active:e.startsWith("/cms/settings"),children:f(wl,{stroke:ai})})]}),f("div",{className:"Layout__side__user",children:f(xe,{label:r.email,position:"right",withArrow:!0,children:f(kn,{src:r.photoURL,alt:r.email,size:30,radius:"xl"})})})]})};me.SideButton=t=>f(xe,{className:ke("Layout__side__button",t.className),label:t.label,position:"right",withArrow:!0,children:f("a",{className:ke(t.active&&"active"),href:t.url,children:t.children})});me.Main=t=>f("div",{className:"Layout__main",children:t.children});me.Bottom=()=>f("div",{className:"Layout__bottom"});var lH=["bmp","gif","ico","jpeg","jpg","png","tiff","webp"],Dk=[...lH,"svg"],Rk=["mp4","webm"],cH="https://lh3.googleusercontent.com/";async function Aa(t,e){let r=window.__ROOT_CTX.rootConfig.projectId,o=await _we(t),n=am(t.name),a=e?.preserveFilename?`${o}/${t.name}`:`${o}.${n}`,i=`${r}/uploads/${a}`,s=tz(window.firebase.storage,i);await J9(s,t),console.log(`uploaded ${i}`);let l={};l.filename=t.name,l.uploadedBy=window.firebase.user.email||"unknown",l.uploadedAt=String(Math.floor(new Date().getTime()));let c=`/${s.bucket}/${s.fullPath}`,u=`https://storage.googleapis.com${c}`;if(Dk.includes(n)){let p=await hwe(t);if(l.width=p.width,l.height=p.height,!e?.disableGci&&lH.includes(n)){let m=await mwe(c);m&&(l.gcsPath=c,u=m)}}else if(Rk.includes(n)){let p=await gwe(u);l.width=p.width,l.height=p.height,console.log("video dimensions:",p)}let d=e?.cacheControl||"public, max-age=3600";return await ez(s,{cacheControl:d,customMetadata:xwe(l)}),console.log("updated meta data: ",l),{...l,src:u}}function am(t){return pwe(t.split(".").at(-1)||"")}function pwe(t){let e=String(t).toLowerCase();return e==="jpeg"&&(e="jpg"),e}async function mwe(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 i=await n.text();throw console.error(`failed to get gci url: ${o}`),console.error(i),new Error("failed to get gci url")}return(await n.json()).servingUrl}async function hwe(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 gwe(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 _we(t){let e=await t.arrayBuffer(),r=await crypto.subtle.digest("SHA-1",e);return Array.from(new Uint8Array(r)).map(a=>a.toString(16).padStart(2,"0")).join("")}function xwe(t){let e={};return Object.entries(t).forEach(([r,o])=>{t[r]=String(o).trim()}),e}function ra(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 uH(t,e){return Math.random()*(e-t)+t}var bwe=!1,ywe=`Lorem ipsum \u{1F955} dolor sit amet.
|
|
53
|
+
`;break}case-2:{i=e?" ":" ";break}case-1:{if(!e&&n)continue;i=" ";break}default:i=String.fromCharCode(a)}n=a===-2,o.push(i)}return o.join("")}var ik={};Qj(ik,{attentionMarkers:()=>Gve,contentInitial:()=>Uve,disable:()=>Wve,document:()=>zve,flow:()=>Hve,flowInitial:()=>Vve,insideSpan:()=>qve,string:()=>$ve,text:()=>jve});var zve={42:ho,43:ho,45:ho,48:ho,49:ho,50:ho,51:ho,52:ho,53:ho,54:ho,55:ho,56:ho,57:ho,62:ny},Uve={91:ZC},Vve={[-2]:rm,[-1]:rm,32:rm},Hve={35:ek,42:Nl,45:[py,Nl],60:rk,61:py,95:Nl,96:sy,126:sy},$ve={38:iy,92:ay},jve={[-5]:nm,[-4]:nm,[-3]:nm,33:nk,38:iy,42:tm,60:[XC,ok],91:ak,92:[JC,ay],93:Rl,95:tm,96:YC},qve={null:[tm,OV]},Gve={null:[42,95]},Wve={null:[]};function sk(t){let r=ry([ik,...(t||{}).extensions||[]]),o={defined:[],lazy:{},constructs:r,content:n(wV),document:n(SV),flow:n(PV),string:n(AV),text:n(DV)};return o;function n(a){return i;function i(s){return MV(o,a,s)}}}function lk(t){for(;!cy(t););return t}var LV=/[\0\t\n\r]/g;function ck(){let t=1,e="",r=!0,o;return n;function n(a,i,s){let l=[],c,u,d,p,m;for(a=e+(typeof a=="string"?a.toString():new TextDecoder(i||void 0).decode(a)),d=0,e="",r&&(a.charCodeAt(0)===65279&&d++,r=void 0);d<a.length;){if(LV.lastIndex=d,c=LV.exec(a),p=c&&c.index!==void 0?c.index:a.length,m=a.charCodeAt(p),!c){e=a.slice(d);break}if(m===10&&d===p&&o)l.push(-3),o=void 0;else switch(o&&(l.push(-5),o=void 0),d<p&&(l.push(a.slice(d,p)),t+=p-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=p+1}return s&&(o&&l.push(-5),e&&l.push(e),l.push(null)),l}}var Kve=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function BV(t){return t.replace(Kve,Xve)}function Xve(t,e,r){if(e)return e;if(r.charCodeAt(0)===35){let n=r.charCodeAt(1),a=n===120||n===88;return oy(r.slice(a?2:1),a?16:10)}return Vu(r)||t}function $u(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?FV(t.position):"start"in t||"end"in t?FV(t):"line"in t||"column"in t?uk(t):""}function uk(t){return zV(t&&t.line)+":"+zV(t&&t.column)}function FV(t){return uk(t&&t.start)+"-"+uk(t&&t.end)}function zV(t){return t&&typeof t=="number"?t:1}var VV={}.hasOwnProperty;function dk(t,e,r){return typeof e!="string"&&(r=e,e=void 0),Yve(r)(lk(sk(r).document().write(ck()(t,e,!0))))}function Yve(t){let e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:a(ft),autolinkProtocol:S,autolinkEmail:S,atxHeading:a(ao),blockQuote:a(st),characterEscape:S,characterReference:S,codeFenced:a(wt),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:a(wt,i),codeText:a(mt,i),codeTextData:S,data:S,codeFlowValue:S,definition:a(zt),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:a(ot),hardBreakEscape:a(dt),hardBreakTrailing:a(dt),htmlFlow:a(fe,i),htmlFlowData:S,htmlText:a(fe,i),htmlTextData:S,image:a(go),label:i,link:a(ft),listItem:a(wr),listItemValue:p,listOrdered:a(Be,d),listUnordered:a(Be),paragraph:a(fr),reference:A,referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:a(ao),strong:a(Vr),thematicBreak:a(W)},exit:{atxHeading:l(),atxHeadingSequence:w,autolink:l(),autolinkEmail:be,autolinkProtocol:Oe,blockQuote:l(),characterEscapeValue:C,characterReferenceMarkerHexadecimal:Se,characterReferenceMarkerNumeric:Se,characterReferenceValue:Ge,characterReference:et,codeFenced:l(_),codeFencedFence:g,codeFencedFenceInfo:m,codeFencedFenceMeta:h,codeFlowValue:C,codeIndented:l(x),codeText:l(B),codeTextData:C,data:C,definition:l(),definitionDestinationString:I,definitionLabelString:b,definitionTitleString:y,emphasis:l(),hardBreakEscape:l(N),hardBreakTrailing:l(N),htmlFlow:l(R),htmlFlowData:C,htmlText:l(z),htmlTextData:C,image:l(V),label:G,labelText:U,lineEnding:F,link:l(M),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:ce,resourceDestinationString:k,resourceTitleString:Z,resource:te,setextHeading:l(O),setextHeadingLineSequence:T,setextHeadingText:v,strong:l(),thematicBreak:l()}};HV(e,(t||{}).mdastExtensions||[]);let r={};return o;function o(D){let $={type:"root",children:[]},J={stack:[$],tokenStack:[],config:e,enter:s,exit:c,buffer:i,resume:u,data:r},ye=[],je=-1;for(;++je<D.length;)if(D[je][1].type==="listOrdered"||D[je][1].type==="listUnordered")if(D[je][0]==="enter")ye.push(je);else{let nt=ye.pop();je=n(D,nt,je)}for(je=-1;++je<D.length;){let nt=e[D[je][0]];VV.call(nt,D[je][1].type)&&nt[D[je][1].type].call(Object.assign({sliceSerialize:D[je][2].sliceSerialize},J),D[je][1])}if(J.tokenStack.length>0){let nt=J.tokenStack[J.tokenStack.length-1];(nt[1]||UV).call(J,void 0,nt[0])}for($.position={start:rs(D.length>0?D[0][1].start:{line:1,column:1,offset:0}),end:rs(D.length>0?D[D.length-2][1].end:{line:1,column:1,offset:0})},je=-1;++je<e.transforms.length;)$=e.transforms[je]($)||$;return $}function n(D,$,J){let ye=$-1,je=-1,nt=!1,Fo,nr,Kt,hn;for(;++ye<=J;){let Hr=D[ye];switch(Hr[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Hr[0]==="enter"?je++:je--,hn=void 0;break}case"lineEndingBlank":{Hr[0]==="enter"&&(Fo&&!hn&&!je&&!Kt&&(Kt=ye),hn=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:hn=void 0}if(!je&&Hr[0]==="enter"&&Hr[1].type==="listItemPrefix"||je===-1&&Hr[0]==="exit"&&(Hr[1].type==="listUnordered"||Hr[1].type==="listOrdered")){if(Fo){let _o=ye;for(nr=void 0;_o--;){let xo=D[_o];if(xo[1].type==="lineEnding"||xo[1].type==="lineEndingBlank"){if(xo[0]==="exit")continue;nr&&(D[nr][1].type="lineEndingBlank",nt=!0),xo[1].type="lineEnding",nr=_o}else if(!(xo[1].type==="linePrefix"||xo[1].type==="blockQuotePrefix"||xo[1].type==="blockQuotePrefixWhitespace"||xo[1].type==="blockQuoteMarker"||xo[1].type==="listItemIndent"))break}Kt&&(!nr||Kt<nr)&&(Fo._spread=!0),Fo.end=Object.assign({},nr?D[nr][1].start:Hr[1].end),D.splice(nr||ye,0,["exit",Fo,Hr[2]]),ye++,J++}if(Hr[1].type==="listItemPrefix"){let _o={type:"listItem",_spread:!1,start:Object.assign({},Hr[1].start),end:void 0};Fo=_o,D.splice(ye,0,["enter",_o,Hr[2]]),ye++,J++,Kt=void 0,hn=!0}}}return D[$][1]._spread=nt,J}function a(D,$){return J;function J(ye){s.call(this,D(ye),ye),$&&$.call(this,ye)}}function i(){this.stack.push({type:"fragment",children:[]})}function s(D,$,J){this.stack[this.stack.length-1].children.push(D),this.stack.push(D),this.tokenStack.push([$,J]),D.position={start:rs($.start),end:void 0}}function l(D){return $;function $(J){D&&D.call(this,J),c.call(this,J)}}function c(D,$){let J=this.stack.pop(),ye=this.tokenStack.pop();if(ye)ye[0].type!==D.type&&($?$.call(this,D,ye[0]):(ye[1]||UV).call(this,D,ye[0]));else throw new Error("Cannot close `"+D.type+"` ("+$u({start:D.start,end:D.end})+"): it\u2019s not open");J.position.end=rs(D.end)}function u(){return KC(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function p(D){if(this.data.expectingFirstListItemValue){let $=this.stack[this.stack.length-2];$.start=Number.parseInt(this.sliceSerialize(D),10),this.data.expectingFirstListItemValue=void 0}}function m(){let D=this.resume(),$=this.stack[this.stack.length-1];$.lang=D}function h(){let D=this.resume(),$=this.stack[this.stack.length-1];$.meta=D}function g(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function _(){let D=this.resume(),$=this.stack[this.stack.length-1];$.value=D.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function x(){let D=this.resume(),$=this.stack[this.stack.length-1];$.value=D.replace(/(\r?\n|\r)$/g,"")}function b(D){let $=this.resume(),J=this.stack[this.stack.length-1];J.label=$,J.identifier=mo(this.sliceSerialize(D)).toLowerCase()}function y(){let D=this.resume(),$=this.stack[this.stack.length-1];$.title=D}function I(){let D=this.resume(),$=this.stack[this.stack.length-1];$.url=D}function w(D){let $=this.stack[this.stack.length-1];if(!$.depth){let J=this.sliceSerialize(D).length;$.depth=J}}function v(){this.data.setextHeadingSlurpLineEnding=!0}function T(D){let $=this.stack[this.stack.length-1];$.depth=this.sliceSerialize(D).codePointAt(0)===61?1:2}function O(){this.data.setextHeadingSlurpLineEnding=void 0}function S(D){let J=this.stack[this.stack.length-1].children,ye=J[J.length-1];(!ye||ye.type!=="text")&&(ye=_e(),ye.position={start:rs(D.start),end:void 0},J.push(ye)),this.stack.push(ye)}function C(D){let $=this.stack.pop();$.value+=this.sliceSerialize(D),$.position.end=rs(D.end)}function F(D){let $=this.stack[this.stack.length-1];if(this.data.atHardBreak){let J=$.children[$.children.length-1];J.position.end=rs(D.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes($.type)&&(S.call(this,D),C.call(this,D))}function N(){this.data.atHardBreak=!0}function R(){let D=this.resume(),$=this.stack[this.stack.length-1];$.value=D}function z(){let D=this.resume(),$=this.stack[this.stack.length-1];$.value=D}function B(){let D=this.resume(),$=this.stack[this.stack.length-1];$.value=D}function M(){let D=this.stack[this.stack.length-1];if(this.data.inReference){let $=this.data.referenceType||"shortcut";D.type+="Reference",D.referenceType=$,delete D.url,delete D.title}else delete D.identifier,delete D.label;this.data.referenceType=void 0}function V(){let D=this.stack[this.stack.length-1];if(this.data.inReference){let $=this.data.referenceType||"shortcut";D.type+="Reference",D.referenceType=$,delete D.url,delete D.title}else delete D.identifier,delete D.label;this.data.referenceType=void 0}function U(D){let $=this.sliceSerialize(D),J=this.stack[this.stack.length-2];J.label=BV($),J.identifier=mo($).toLowerCase()}function G(){let D=this.stack[this.stack.length-1],$=this.resume(),J=this.stack[this.stack.length-1];if(this.data.inReference=!0,J.type==="link"){let ye=D.children;J.children=ye}else J.alt=$}function k(){let D=this.resume(),$=this.stack[this.stack.length-1];$.url=D}function Z(){let D=this.resume(),$=this.stack[this.stack.length-1];$.title=D}function te(){this.data.inReference=void 0}function A(){this.data.referenceType="collapsed"}function ce(D){let $=this.resume(),J=this.stack[this.stack.length-1];J.label=$,J.identifier=mo(this.sliceSerialize(D)).toLowerCase(),this.data.referenceType="full"}function Se(D){this.data.characterReferenceType=D.type}function Ge(D){let $=this.sliceSerialize(D),J=this.data.characterReferenceType,ye;J?(ye=oy($,J==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ye=Vu($);let je=this.stack[this.stack.length-1];je.value+=ye}function et(D){let $=this.stack.pop();$.position.end=rs(D.end)}function Oe(D){C.call(this,D);let $=this.stack[this.stack.length-1];$.url=this.sliceSerialize(D)}function be(D){C.call(this,D);let $=this.stack[this.stack.length-1];$.url="mailto:"+this.sliceSerialize(D)}function st(){return{type:"blockquote",children:[]}}function wt(){return{type:"code",lang:null,meta:null,value:""}}function mt(){return{type:"inlineCode",value:""}}function zt(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ot(){return{type:"emphasis",children:[]}}function ao(){return{type:"heading",depth:0,children:[]}}function dt(){return{type:"break"}}function fe(){return{type:"html",value:""}}function go(){return{type:"image",title:null,url:"",alt:null}}function ft(){return{type:"link",title:null,url:"",children:[]}}function Be(D){return{type:"list",ordered:D.type==="listOrdered",start:null,spread:D._spread,children:[]}}function wr(D){return{type:"listItem",spread:D._spread,checked:null,children:[]}}function fr(){return{type:"paragraph",children:[]}}function Vr(){return{type:"strong",children:[]}}function _e(){return{type:"text",value:""}}function W(){return{type:"thematicBreak"}}}function rs(t){return{line:t.line,column:t.column,offset:t.offset}}function HV(t,e){let r=-1;for(;++r<e.length;){let o=e[r];Array.isArray(o)?HV(t,o):Qve(t,o)}}function Qve(t,e){let r;for(r in e)if(VV.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 UV(t,e){throw t?new Error("Cannot close `"+t.type+"` ("+$u({start:t.start,end:t.end})+"): a different token (`"+e.type+"`, "+$u({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+$u({start:e.start,end:e.end})+") is still open")}function fk(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 pk(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var ju=function(t){if(t==null)return tIe;if(typeof t=="function")return my(t);if(typeof t=="object")return Array.isArray(t)?Zve(t):Jve(t);if(typeof t=="string")return eIe(t);throw new Error("Expected function, string, or object as test")};function Zve(t){let e=[],r=-1;for(;++r<t.length;)e[r]=ju(t[r]);return my(o);function o(...n){let a=-1;for(;++a<e.length;)if(e[a].apply(this,n))return!0;return!1}}function Jve(t){let e=t;return my(r);function r(o){let n=o,a;for(a in t)if(n[a]!==e[a])return!1;return!0}}function eIe(t){return my(e);function e(r){return r&&r.type===t}}function my(t){return e;function e(r,o,n){return!!(rIe(r)&&t.call(this,r,typeof o=="number"?o:void 0,n||void 0))}}function tIe(){return!0}function rIe(t){return t!==null&&typeof t=="object"&&"type"in t}var $V=[],jV=!0,mk=!1,qV="skip";function hk(t,e,r,o){let n;typeof e=="function"&&typeof r!="function"?(o=r,r=e):n=e;let a=ju(n),i=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(p,"name",{value:"node ("+(l.type+(m?"<"+m+">":""))+")"})}return p;function p(){let m=$V,h,g,_;if((!e||a(l,c,u[u.length-1]||void 0))&&(m=oIe(r(l,u)),m[0]===mk))return m;if("children"in l&&l.children){let x=l;if(x.children&&m[0]!==qV)for(g=(o?x.children.length:-1)+i,_=u.concat(x);g>-1&&g<x.children.length;){let b=x.children[g];if(h=s(b,g,_)(),h[0]===mk)return h;g=typeof h[1]=="number"?h[1]:g+i}}return m}}}function oIe(t){return Array.isArray(t)?t:typeof t=="number"?[jV,t]:t==null?$V:[t]}function gk(t,e,r){let n=ju((r||{}).ignore||[]),a=nIe(e),i=-1;for(;++i<a.length;)hk(t,"text",s);function s(c,u){let d=-1,p;for(;++d<u.length;){let m=u[d],h=p?p.children:void 0;if(n(m,h?h.indexOf(m):void 0,p))return;p=m}if(p)return l(c,u)}function l(c,u){let d=u[u.length-1],p=a[i][0],m=a[i][1],h=0,_=d.children.indexOf(c),x=!1,b=[];p.lastIndex=0;let y=p.exec(c.value);for(;y;){let I=y.index,w={index:y.index,input:y.input,stack:[...u,c]},v=m(...y,w);if(typeof v=="string"&&(v=v.length>0?{type:"text",value:v}:void 0),v===!1?p.lastIndex=I+1:(h!==I&&b.push({type:"text",value:c.value.slice(h,I)}),Array.isArray(v)?b.push(...v):v&&b.push(v),h=I+y[0].length,x=!0),!p.global)break;y=p.exec(c.value)}return x?(h<c.value.length&&b.push({type:"text",value:c.value.slice(h)}),d.children.splice(_,1,...b)):b=[c],_+b.length}}function nIe(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([aIe(n[0]),iIe(n[1])])}return e}function aIe(t){return typeof t=="string"?new RegExp(pk(t),"g"):t}function iIe(t){return typeof t=="function"?t:function(){return t}}function xk(){return{transforms:[fIe],enter:{literalAutolink:sIe,literalAutolinkEmail:_k,literalAutolinkHttp:_k,literalAutolinkWww:_k},exit:{literalAutolink:dIe,literalAutolinkEmail:uIe,literalAutolinkHttp:lIe,literalAutolinkWww:cIe}}}function sIe(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function _k(t){this.config.enter.autolinkProtocol.call(this,t)}function lIe(t){this.config.exit.autolinkProtocol.call(this,t)}function cIe(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 uIe(t){this.config.exit.autolinkEmail.call(this,t)}function dIe(t){this.exit(t)}function fIe(t){gk(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,pIe],[/([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/g,mIe]],{ignore:["link","linkReference"]})}function pIe(t,e,r,o,n){let a="";if(!GV(n)||(/^w/i.test(e)&&(r=e+r,e="",a="http://"),!hIe(r)))return!1;let i=gIe(r+o);if(!i[0])return!1;let s={type:"link",title:null,url:a+e+i[0],children:[{type:"text",value:e+i[0]}]};return i[1]?[s,{type:"text",value:i[1]}]:s}function mIe(t,e,r,o){return!GV(o,!0)||/[-\d_]$/.test(r)?!1:{type:"link",title:null,url:"mailto:"+e+"@"+r,children:[{type:"text",value:e+"@"+r}]}}function hIe(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 gIe(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=fk(t,"("),a=fk(t,")");for(;o!==-1&&n>a;)t+=r.slice(0,o+1),r=r.slice(o+1),o=r.indexOf(")"),a++;return[t,r]}function GV(t,e){let r=t.input.charCodeAt(t.index-1);return(t.index===0||Ta(r)||Al(r))&&(!e||r!==47)}CIe.peek=kIe;function bk(){return{enter:{gfmFootnoteDefinition:xIe,gfmFootnoteDefinitionLabelString:bIe,gfmFootnoteCall:IIe,gfmFootnoteCallString:wIe},exit:{gfmFootnoteDefinition:vIe,gfmFootnoteDefinitionLabelString:yIe,gfmFootnoteCall:SIe,gfmFootnoteCallString:EIe}}}function xIe(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function bIe(){this.buffer()}function yIe(t){let e=this.resume(),r=this.stack[this.stack.length-1];r.type,r.label=e,r.identifier=mo(this.sliceSerialize(t)).toLowerCase()}function vIe(t){this.exit(t)}function IIe(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function wIe(){this.buffer()}function EIe(t){let e=this.resume(),r=this.stack[this.stack.length-1];r.type,r.label=e,r.identifier=mo(this.sliceSerialize(t)).toLowerCase()}function SIe(t){this.exit(t)}function CIe(t,e,r,o){let n=r.createTracker(o),a=n.move("[^"),i=r.enter("footnoteReference"),s=r.enter("reference");return a+=n.move(r.safe(r.associationId(t),{...n.current(),before:a,after:"]"})),s(),i(),a+=n.move("]"),a}function kIe(){return"["}AIe.peek=DIe;function yk(){return{canContainEols:["delete"],enter:{strikethrough:PIe},exit:{strikethrough:OIe}}}function PIe(t){this.enter({type:"delete",children:[]},t)}function OIe(t){this.exit(t)}function AIe(t,e,r,o){let n=r.createTracker(o),a=r.enter("strikethrough"),i=n.move("~~");return i+=r.containerPhrasing(t,{...n.current(),before:i,after:"~"}),i+=n.move("~~"),a(),i}function DIe(){return"~"}function Ik(){return{enter:{table:NIe,tableData:WV,tableHeader:WV,tableRow:LIe},exit:{codeText:BIe,table:MIe,tableData:vk,tableHeader:vk,tableRow:vk}}}function NIe(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 MIe(t){this.exit(t),this.data.inTable=void 0}function LIe(t){this.enter({type:"tableRow",children:[]},t)}function vk(t){this.exit(t)}function WV(t){this.enter({type:"tableCell",children:[]},t)}function BIe(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,FIe));let r=this.stack[this.stack.length-1];r.type,r.value=e,this.exit(t)}function FIe(t,e){return e==="|"?e:t}function wk(){return{exit:{taskListCheckValueChecked:KV,taskListCheckValueUnchecked:KV,paragraph:UIe}}}function KV(t){let e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function UIe(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,a=-1,i;for(;++a<n.length;){let s=n[a];if(s.type==="paragraph"){i=s;break}}i===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 Ek(){return[xk(),bk(),yk(),Ik(),wk()]}var HIe={tokenize:WIe,partial:!0},XV={tokenize:KIe,partial:!0},YV={tokenize:XIe,partial:!0},QV={tokenize:YIe,partial:!0},$Ie={tokenize:QIe,partial:!0},ZV={tokenize:qIe,previous:eH},JV={tokenize:GIe,previous:tH},ni={tokenize:jIe,previous:rH},Oa={};function Ck(){return{text:Oa}}var Ml=48;for(;Ml<123;)Oa[Ml]=ni,Ml++,Ml===58?Ml=65:Ml===91&&(Ml=97);Oa[43]=ni;Oa[45]=ni;Oa[46]=ni;Oa[95]=ni;Oa[72]=[ni,JV];Oa[104]=[ni,JV];Oa[87]=[ni,ZV];Oa[119]=[ni,ZV];function jIe(t,e,r){let o=this,n,a;return i;function i(d){return!Sk(d)||!rH.call(o,o.previous)||kk(o.events)?r(d):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),s(d))}function s(d){return Sk(d)?(t.consume(d),s):d===64?(t.consume(d),l):r(d)}function l(d){return d===46?t.check($Ie,u,c)(d):d===45||d===95||Or(d)?(a=!0,t.consume(d),l):u(d)}function c(d){return t.consume(d),n=!0,l}function u(d){return a&&n&&Pr(o.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(d)):r(d)}}function qIe(t,e,r){let o=this;return n;function n(i){return i!==87&&i!==119||!eH.call(o,o.previous)||kk(o.events)?r(i):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(HIe,t.attempt(XV,t.attempt(YV,a),r),r)(i))}function a(i){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(i)}}function GIe(t,e,r){let o=this,n="",a=!1;return i;function i(d){return(d===72||d===104)&&tH.call(o,o.previous)&&!kk(o.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),n+=String.fromCodePoint(d),t.consume(d),s):r(d)}function s(d){if(Pr(d)&&n.length<5)return n+=String.fromCodePoint(d),t.consume(d),s;if(d===58){let p=n.toLowerCase();if(p==="http"||p==="https")return t.consume(d),l}return r(d)}function l(d){return d===47?(t.consume(d),a?c:(a=!0,l)):r(d)}function c(d){return d===null||Ol(d)||Xe(d)||Ta(d)||Al(d)?r(d):t.attempt(XV,t.attempt(YV,u),r)(d)}function u(d){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(d)}}function WIe(t,e,r){let o=0;return n;function n(i){return(i===87||i===119)&&o<3?(o++,t.consume(i),n):i===46&&o===3?(t.consume(i),a):r(i)}function a(i){return i===null?r(i):e(i)}}function KIe(t,e,r){let o,n,a;return i;function i(c){return c===46||c===95?t.check(QV,l,s)(c):c===null||Xe(c)||Ta(c)||c!==45&&Al(c)?l(c):(a=!0,t.consume(c),i)}function s(c){return c===95?o=!0:(n=o,o=void 0),t.consume(c),i}function l(c){return n||o||!a?r(c):e(c)}}function XIe(t,e){let r=0,o=0;return n;function n(i){return i===40?(r++,t.consume(i),n):i===41&&o<r?a(i):i===33||i===34||i===38||i===39||i===41||i===42||i===44||i===46||i===58||i===59||i===60||i===63||i===93||i===95||i===126?t.check(QV,e,a)(i):i===null||Xe(i)||Ta(i)?e(i):(t.consume(i),n)}function a(i){return i===41&&o++,t.consume(i),n}}function YIe(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),a):s===93?(t.consume(s),n):s===60||s===null||Xe(s)||Ta(s)?e(s):r(s)}function n(s){return s===null||s===40||s===91||Xe(s)||Ta(s)?e(s):o(s)}function a(s){return Pr(s)?i(s):r(s)}function i(s){return s===59?(t.consume(s),o):Pr(s)?(t.consume(s),i):r(s)}}function QIe(t,e,r){return o;function o(a){return t.consume(a),n}function n(a){return Or(a)?r(a):e(a)}}function eH(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Xe(t)}function tH(t){return!Pr(t)}function rH(t){return!(t===47||Sk(t))}function Sk(t){return t===43||t===45||t===46||t===95||Or(t)}function kk(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 ZIe={tokenize:awe,partial:!0};function Tk(){return{document:{91:{tokenize:rwe,continuation:{tokenize:owe},exit:nwe}},text:{91:{tokenize:twe},93:{add:"after",tokenize:JIe,resolveTo:ewe}}}}function JIe(t,e,r){let o=this,n=o.events.length,a=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]),i;for(;n--;){let l=o.events[n][1];if(l.type==="labelImage"){i=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(!i||!i._balanced)return r(l);let c=mo(o.sliceSerialize({start:i.end,end:o.now()}));return c.codePointAt(0)!==94||!a.includes(c.slice(1))?r(l):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(l),t.exit("gfmFootnoteCallLabelMarker"),e(l))}}function ewe(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)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},t[r+3][1].end),end:Object.assign({},t[r+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;let i={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},t[t.length-1][1].start)},s={type:"chunkString",contentType:"string",start:Object.assign({},i.start),end:Object.assign({},i.end)},l=[t[r+1],t[r+2],["enter",n,e],t[r+3],t[r+4],["enter",a,e],["exit",a,e],["enter",i,e],["enter",s,e],["exit",s,e],["exit",i,e],t[t.length-2],t[t.length-1],["exit",n,e]];return t.splice(r,t.length-r+1,...l),t}function twe(t,e,r){let o=this,n=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]),a=0,i;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(a>999||d===93&&!i||d===null||d===91||Xe(d))return r(d);if(d===93){t.exit("chunkString");let p=t.exit("gfmFootnoteCallString");return n.includes(mo(o.sliceSerialize(p)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(d),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):r(d)}return Xe(d)||(i=!0),a++,t.consume(d),d===92?u:c}function u(d){return d===91||d===92||d===93?(t.consume(d),a++,c):c(d)}}function rwe(t,e,r){let o=this,n=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]),a,i=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(i>999||h===93&&!s||h===null||h===91||Xe(h))return r(h);if(h===93){t.exit("chunkString");let g=t.exit("gfmFootnoteDefinitionLabelString");return a=mo(o.sliceSerialize(g)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(h),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),p}return Xe(h)||(s=!0),i++,t.consume(h),h===92?d:u}function d(h){return h===91||h===92||h===93?(t.consume(h),i++,u):u(h)}function p(h){return h===58?(t.enter("definitionMarker"),t.consume(h),t.exit("definitionMarker"),n.includes(a)||n.push(a),Ee(t,m,"gfmFootnoteDefinitionWhitespace")):r(h)}function m(h){return e(h)}}function owe(t,e,r){return t.check(Pa,e,t.attempt(ZIe,e,r))}function nwe(t){t.exit("gfmFootnoteDefinition")}function awe(t,e,r){let o=this;return Ee(t,n,"gfmFootnoteDefinitionIndent",5);function n(a){let i=o.events[o.events.length-1];return i&&i[1].type==="gfmFootnoteDefinitionIndent"&&i[2].sliceSerialize(i[1],!0).length===4?e(a):r(a)}}function Pk(t){let r=(t||{}).singleTilde,o={tokenize:a,resolveAll:n};return r==null&&(r=!0),{text:{126:o},insideSpan:{null:[o]},attentionMarkers:{null:[126]}};function n(i,s){let l=-1;for(;++l<i.length;)if(i[l][0]==="enter"&&i[l][1].type==="strikethroughSequenceTemporary"&&i[l][1]._close){let c=l;for(;c--;)if(i[c][0]==="exit"&&i[c][1].type==="strikethroughSequenceTemporary"&&i[c][1]._open&&i[l][1].end.offset-i[l][1].start.offset===i[c][1].end.offset-i[c][1].start.offset){i[l][1].type="strikethroughSequence",i[c][1].type="strikethroughSequence";let u={type:"strikethrough",start:Object.assign({},i[c][1].start),end:Object.assign({},i[l][1].end)},d={type:"strikethroughText",start:Object.assign({},i[c][1].end),end:Object.assign({},i[l][1].start)},p=[["enter",u,s],["enter",i[c][1],s],["exit",i[c][1],s],["enter",d,s]],m=s.parser.constructs.insideSpan.null;m&&Ir(p,p.length,0,ts(m,i.slice(c+1,l),s)),Ir(p,p.length,0,[["exit",d,s],["enter",i[l][1],s],["exit",i[l][1],s],["exit",u,s]]),Ir(i,c-1,l-c+3,p),l=c+p.length-2;break}}for(l=-1;++l<i.length;)i[l][1].type==="strikethroughSequenceTemporary"&&(i[l][1].type="data");return i}function a(i,s,l){let c=this.previous,u=this.events,d=0;return p;function p(h){return c===126&&u[u.length-1][1].type!=="characterEscape"?l(h):(i.enter("strikethroughSequenceTemporary"),m(h))}function m(h){let g=Hu(c);if(h===126)return d>1?l(h):(i.consume(h),d++,m);if(d<2&&!r)return l(h);let _=i.exit("strikethroughSequenceTemporary"),x=Hu(h);return _._open=!x||x===2&&!!g,_._close=!g||g===2&&!!x,s(h)}}}var hy=class{constructor(){this.map=[]}add(e,r,o){iwe(this,e,r,o)}consume(e){if(this.map.sort(function(a,i){return a[0]-i[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 iwe(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 oH(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 a=o.length-1;o[a]=o[a]==="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 Ok(){return{flow:{null:{tokenize:swe,resolveAll:lwe}}}}function swe(t,e,r){let o=this,n=0,a=0,i;return s;function s(C){let F=o.events.length-1;for(;F>-1;){let z=o.events[F][1].type;if(z==="lineEnding"||z==="linePrefix")F--;else break}let N=F>-1?o.events[F][1].type:null,R=N==="tableHead"||N==="tableRow"?v:l;return R===v&&o.parser.lazy[o.now().line]?r(C):R(C)}function l(C){return t.enter("tableHead"),t.enter("tableRow"),c(C)}function c(C){return C===124||(i=!0,a+=1),u(C)}function u(C){return C===null?r(C):ie(C)?a>1?(a=0,o.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(C),t.exit("lineEnding"),m):r(C):Pe(C)?Ee(t,u,"whitespace")(C):(a+=1,i&&(i=!1,n+=1),C===124?(t.enter("tableCellDivider"),t.consume(C),t.exit("tableCellDivider"),i=!0,u):(t.enter("data"),d(C)))}function d(C){return C===null||C===124||Xe(C)?(t.exit("data"),u(C)):(t.consume(C),C===92?p:d)}function p(C){return C===92||C===124?(t.consume(C),d):d(C)}function m(C){return o.interrupt=!1,o.parser.lazy[o.now().line]?r(C):(t.enter("tableDelimiterRow"),i=!1,Pe(C)?Ee(t,h,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(C):h(C))}function h(C){return C===45||C===58?_(C):C===124?(i=!0,t.enter("tableCellDivider"),t.consume(C),t.exit("tableCellDivider"),g):w(C)}function g(C){return Pe(C)?Ee(t,_,"whitespace")(C):_(C)}function _(C){return C===58?(a+=1,i=!0,t.enter("tableDelimiterMarker"),t.consume(C),t.exit("tableDelimiterMarker"),x):C===45?(a+=1,x(C)):C===null||ie(C)?I(C):w(C)}function x(C){return C===45?(t.enter("tableDelimiterFiller"),b(C)):w(C)}function b(C){return C===45?(t.consume(C),b):C===58?(i=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(C),t.exit("tableDelimiterMarker"),y):(t.exit("tableDelimiterFiller"),y(C))}function y(C){return Pe(C)?Ee(t,I,"whitespace")(C):I(C)}function I(C){return C===124?h(C):C===null||ie(C)?!i||n!==a?w(C):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(C)):w(C)}function w(C){return r(C)}function v(C){return t.enter("tableRow"),T(C)}function T(C){return C===124?(t.enter("tableCellDivider"),t.consume(C),t.exit("tableCellDivider"),T):C===null||ie(C)?(t.exit("tableRow"),e(C)):Pe(C)?Ee(t,T,"whitespace")(C):(t.enter("data"),O(C))}function O(C){return C===null||C===124||Xe(C)?(t.exit("data"),T(C)):(t.consume(C),C===92?S:O)}function S(C){return C===92||C===124?(t.consume(C),O):O(C)}}function lwe(t,e){let r=-1,o=!0,n=0,a=[0,0,0,0],i=[0,0,0,0],s=!1,l=0,c,u,d,p=new hy;for(;++r<t.length;){let m=t[r],h=m[1];m[0]==="enter"?h.type==="tableHead"?(s=!1,l!==0&&(nH(p,e,l,c,u),u=void 0,l=0),c={type:"table",start:Object.assign({},h.start),end:Object.assign({},h.end)},p.add(r,0,[["enter",c,e]])):h.type==="tableRow"||h.type==="tableDelimiterRow"?(o=!0,d=void 0,a=[0,0,0,0],i=[0,r+1,0,0],s&&(s=!1,u={type:"tableBody",start:Object.assign({},h.start),end:Object.assign({},h.end)},p.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,i[2]===0&&(a[1]!==0&&(i[0]=i[1],d=gy(p,e,a,n,void 0,d),a=[0,0,0,0]),i[2]=r)):h.type==="tableCellDivider"&&(o?o=!1:(a[1]!==0&&(i[0]=i[1],d=gy(p,e,a,n,void 0,d)),a=i,i=[a[1],r,0,0])):h.type==="tableHead"?(s=!0,l=r):h.type==="tableRow"||h.type==="tableDelimiterRow"?(l=r,a[1]!==0?(i[0]=i[1],d=gy(p,e,a,n,r,d)):i[1]!==0&&(d=gy(p,e,i,n,r,d)),n=0):n&&(h.type==="data"||h.type==="tableDelimiterMarker"||h.type==="tableDelimiterFiller")&&(i[3]=r)}for(l!==0&&nH(p,e,l,c,u),p.consume(e.events),r=-1;++r<e.events.length;){let m=e.events[r];m[0]==="enter"&&m[1].type==="table"&&(m[1]._align=oH(e.events,r))}return t}function gy(t,e,r,o,n,a){let i=o===1?"tableHeader":o===2?"tableDelimiter":"tableData",s="tableContent";r[0]!==0&&(a.end=Object.assign({},qu(e.events,r[0])),t.add(r[0],0,[["exit",a,e]]));let l=qu(e.events,r[1]);if(a={type:i,start:Object.assign({},l),end:Object.assign({},l)},t.add(r[1],0,[["enter",a,e]]),r[2]!==0){let c=qu(e.events,r[2]),u=qu(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 p=e.events[r[2]],m=e.events[r[3]];if(p[1].end=Object.assign({},m[1].end),p[1].type="chunkText",p[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&&(a.end=Object.assign({},qu(e.events,n)),t.add(n,0,[["exit",a,e]]),a=void 0),a}function nH(t,e,r,o,n){let a=[],i=qu(e.events,r);n&&(n.end=Object.assign({},i),a.push(["exit",n,e])),o.end=Object.assign({},i),a.push(["exit",o,e]),t.add(r+1,0,a)}function qu(t,e){let r=t[e],o=r[0]==="enter"?"start":"end";return r[1][o]}var cwe={tokenize:uwe};function Ak(){return{text:{91:cwe}}}function uwe(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"),a)}function a(l){return Xe(l)?(t.enter("taskListCheckValueUnchecked"),t.consume(l),t.exit("taskListCheckValueUnchecked"),i):l===88||l===120?(t.enter("taskListCheckValueChecked"),t.consume(l),t.exit("taskListCheckValueChecked"),i):r(l)}function i(l){return l===93?(t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),s):r(l)}function s(l){return ie(l)?e(l):Pe(l)?t.check({tokenize:dwe},e,r)(l):r(l)}}function dwe(t,e,r){return Ee(t,o,"whitespace");function o(n){return n===null?r(n):e(n)}}function aH(t){return ry([Ck(),Tk(),Pk(t),Ok(),Ak()])}var iH={name:"@blinkk/root-cms",version:"1.4.8",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","build:signin":"esbuild signin/signin.tsx --bundle --minify --tsconfig=signin/tsconfig.json --outdir=dist/ui",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":"0.5.2","@genkit-ai/core":"0.5.2","@genkit-ai/vertexai":"0.5.2","body-parser":"1.20.2",commander:"11.0.0","csv-parse":"5.5.2","csv-stringify":"6.4.4","dts-dom":"3.7.0","fnv-plus":"1.3.1",jsonwebtoken:"9.0.2",kleur:"4.1.5",sirv:"2.0.3","tiny-glob":"0.2.9"},"//":"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.2.19","@firebase/app-types":"0.9.0","@firebase/rules-unit-testing":"3.0.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":"17.1.2","@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":"18.11.8",concurrently:"7.6.0",esbuild:"0.19.9",firebase:"10.5.2","firebase-admin":"11.11.1","firebase-functions":"4.8.0","firebase-tools":"12.9.1","highlight.js":"11.6.0","json-diff-kit":"1.0.29",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.19.3","preact-render-to-string":"6.3.1","preact-router":"4.1.2",react:"npm:@preact/compat@^17.1.2","react-dom":"npm:@preact/compat@^17.1.2","react-json-view-compare":"2.0.2",tsup:"8.0.1",typescript:"5.2.2",vite:"5.0.8",vitest:"0.34.6"},peerDependencies:{"@blinkk/root":"1.4.8","firebase-admin":">=11","firebase-functions":">=4",preact:">=10","preact-render-to-string":">=5"},peerDependenciesMeta:{"firebase-functions":{optional:!0}}};function sH(){return f("svg",{width:"100",height:"23",viewBox:"0 0 100 23",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[f("g",{"clip-path":"url(#clip0_1_318)",children:[f("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"}),f("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"}),f("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"}),f("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"}),f("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"}),f("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"}),f("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"}),f("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"}),f("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"})]}),f("defs",{children:f("clipPath",{id:"clip0_1_318",children:f("rect",{width:"99",height:"22",fill:"white",transform:"translate(0.0175781 0.177246)"})})})]})}var ai="1.5";function me(t){return f("div",{className:"Layout",children:[f(me.Top,{}),f(me.Side,{}),f(me.Main,{...t,children:t.children}),f(me.Bottom,{})]})}me.Top=()=>{let t=window.__ROOT_CTX.rootConfig.projectName||window.__ROOT_CTX.rootConfig.projectId;return f("div",{className:"Layout__top",children:[f("a",{className:"Layout__top__logo",href:"/cms",children:f(sH,{})}),f("div",{className:"Layout__top__version",children:["v",iH.version]}),f("div",{className:"Layout__top__project",children:t})]})};me.Side=()=>{let[t]=az(),e=t.url.replace(/\/*$/g,""),r=window.firebase.user,o=window.__ROOT_CTX.sidebar?.tools,n=window.__ROOT_CTX.experiments||{};return f("div",{className:"Layout__side",children:[f("div",{className:"Layout__side__buttons",children:[f(me.SideButton,{label:"Home",url:"/cms",active:e==="/cms",children:f(YS,{stroke:ai})}),f(me.SideButton,{label:"Content",url:"/cms/content",active:e.startsWith("/cms/content"),children:f(yl,{stroke:ai})}),f(me.SideButton,{label:"Releases",url:"/cms/releases",active:e.startsWith("/cms/releases"),children:f(Tu,{stroke:ai})}),f(me.SideButton,{label:"Data",url:"/cms/data",active:e.startsWith("/cms/data"),children:f(GS,{stroke:ai})}),f(me.SideButton,{label:"Assets",url:"/cms/assets",active:e.startsWith("/cms/assets"),children:f(eC,{stroke:ai})}),f(me.SideButton,{label:"Translations",url:"/cms/translations",active:e.startsWith("/cms/translations"),children:f(Wi,{stroke:ai})}),n.ai&&f(me.SideButton,{label:"Root AI (experimental)",url:"/cms/ai",active:e.startsWith("/cms/ai"),children:f(Il,{stroke:ai})}),o&&f(Ae,{children:[f("div",{className:"Layout__side__divider"}),Object.entries(o).map(([a,i])=>f(me.SideButton,{className:"Layout__side__tool",label:i.label||"",url:`/cms/tools/${a}`,active:e.startsWith(`/cms/tools/${a}`),children:i.icon?f("img",{className:"Layout__side__tool__icon",src:i.icon,alt:i.label||""}):f(US,{stroke:ai})})),f("div",{className:"Layout__side__divider"})]}),f(me.SideButton,{label:"Settings",url:"/cms/settings",active:e.startsWith("/cms/settings"),children:f(wl,{stroke:ai})})]}),f("div",{className:"Layout__side__user",children:f(xe,{label:r.email,position:"right",withArrow:!0,children:f(kn,{src:r.photoURL,alt:r.email,size:30,radius:"xl"})})})]})};me.SideButton=t=>f(xe,{className:ke("Layout__side__button",t.className),label:t.label,position:"right",withArrow:!0,children:f("a",{className:ke(t.active&&"active"),href:t.url,children:t.children})});me.Main=t=>f("div",{className:"Layout__main",children:t.children});me.Bottom=()=>f("div",{className:"Layout__bottom"});var lH=["bmp","gif","ico","jpeg","jpg","png","tiff","webp"],Dk=[...lH,"svg"],Rk=["mp4","webm"],cH="https://lh3.googleusercontent.com/";async function Aa(t,e){let r=window.__ROOT_CTX.rootConfig.projectId,o=await _we(t),n=am(t.name),a=e?.preserveFilename?`${o}/${t.name}`:`${o}.${n}`,i=`${r}/uploads/${a}`,s=tz(window.firebase.storage,i);await J9(s,t),console.log(`uploaded ${i}`);let l={};l.filename=t.name,l.uploadedBy=window.firebase.user.email||"unknown",l.uploadedAt=String(Math.floor(new Date().getTime()));let c=`/${s.bucket}/${s.fullPath}`,u=`https://storage.googleapis.com${c}`;if(Dk.includes(n)){let p=await hwe(t);if(l.width=p.width,l.height=p.height,!e?.disableGci&&lH.includes(n)){let m=await mwe(c);m&&(l.gcsPath=c,u=m)}}else if(Rk.includes(n)){let p=await gwe(u);l.width=p.width,l.height=p.height,console.log("video dimensions:",p)}let d=e?.cacheControl||"public, max-age=3600";return await ez(s,{cacheControl:d,customMetadata:xwe(l)}),console.log("updated meta data: ",l),{...l,src:u}}function am(t){return pwe(t.split(".").at(-1)||"")}function pwe(t){let e=String(t).toLowerCase();return e==="jpeg"&&(e="jpg"),e}async function mwe(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 i=await n.text();throw console.error(`failed to get gci url: ${o}`),console.error(i),new Error("failed to get gci url")}return(await n.json()).servingUrl}async function hwe(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 gwe(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 _we(t){let e=await t.arrayBuffer(),r=await crypto.subtle.digest("SHA-1",e);return Array.from(new Uint8Array(r)).map(a=>a.toString(16).padStart(2,"0")).join("")}function xwe(t){let e={};return Object.entries(t).forEach(([r,o])=>{t[r]=String(o).trim()}),e}function ra(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 uH(t,e){return Math.random()*(e-t)+t}var bwe=!1,ywe=`Lorem ipsum \u{1F955} dolor sit amet.
|
|
54
54
|
|
|
55
55
|
\`\`\`jsx
|
|
56
56
|
import React, { useState, useEffect } from 'react';
|
|
@@ -140,7 +140,7 @@ ${e}</tr>
|
|
|
140
140
|
`}tablecell(e,r){let o=r.header?"th":"td";return(r.align?`<${o} align="${r.align}">`:`<${o}>`)+e+`</${o}>
|
|
141
141
|
`}strong(e){return`<strong>${e}</strong>`}em(e){return`<em>${e}</em>`}codespan(e){return`<code>${e}</code>`}br(){return"<br>"}del(e){return`<del>${e}</del>`}link(e,r,o){let n=yH(e);if(n===null)return o;e=n;let a='<a href="'+e+'"';return r&&(a+=' title="'+r+'"'),a+=">"+o+"</a>",a}image(e,r,o){let n=yH(e);if(n===null)return o;e=n;let a=`<img src="${e}" alt="${o}"`;return r&&(a+=` title="${r}"`),a+=">",a}text(e){return e}},im=class{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,r,o){return""+o}image(e,r,o){return""+o}br(){return""}},si=class t{options;renderer;textRenderer;constructor(e){this.options=e||Fl,this.options.renderer=this.options.renderer||new Yu,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new im}static parse(e,r){return new t(r).parse(e)}static parseInline(e,r){return new t(r).parseInline(e)}parse(e,r=!0){let o="";for(let n=0;n<e.length;n++){let a=e[n];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[a.type]){let i=a,s=this.options.extensions.renderers[i.type].call({parser:this},i);if(s!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(i.type)){o+=s||"";continue}}switch(a.type){case"space":continue;case"hr":{o+=this.renderer.hr();continue}case"heading":{let i=a;o+=this.renderer.heading(this.parseInline(i.tokens),i.depth,Lwe(this.parseInline(i.tokens,this.textRenderer)));continue}case"code":{let i=a;o+=this.renderer.code(i.text,i.lang,!!i.escaped);continue}case"table":{let i=a,s="",l="";for(let u=0;u<i.header.length;u++)l+=this.renderer.tablecell(this.parseInline(i.header[u].tokens),{header:!0,align:i.align[u]});s+=this.renderer.tablerow(l);let c="";for(let u=0;u<i.rows.length;u++){let d=i.rows[u];l="";for(let p=0;p<d.length;p++)l+=this.renderer.tablecell(this.parseInline(d[p].tokens),{header:!1,align:i.align[p]});c+=this.renderer.tablerow(l)}o+=this.renderer.table(s,c);continue}case"blockquote":{let i=a,s=this.parse(i.tokens);o+=this.renderer.blockquote(s);continue}case"list":{let i=a,s=i.ordered,l=i.start,c=i.loose,u="";for(let d=0;d<i.items.length;d++){let p=i.items[d],m=p.checked,h=p.task,g="";if(p.task){let _=this.renderer.checkbox(!!m);c?p.tokens.length>0&&p.tokens[0].type==="paragraph"?(p.tokens[0].text=_+" "+p.tokens[0].text,p.tokens[0].tokens&&p.tokens[0].tokens.length>0&&p.tokens[0].tokens[0].type==="text"&&(p.tokens[0].tokens[0].text=_+" "+p.tokens[0].tokens[0].text)):p.tokens.unshift({type:"text",text:_+" "}):g+=_+" "}g+=this.parse(p.tokens,c),u+=this.renderer.listitem(g,h,!!m)}o+=this.renderer.list(u,s,l);continue}case"html":{let i=a;o+=this.renderer.html(i.text,i.block);continue}case"paragraph":{let i=a;o+=this.renderer.paragraph(this.parseInline(i.tokens));continue}case"text":{let i=a,s=i.tokens?this.parseInline(i.tokens):i.text;for(;n+1<e.length&&e[n+1].type==="text";)i=e[++n],s+=`
|
|
142
142
|
`+(i.tokens?this.parseInline(i.tokens):i.text);o+=r?this.renderer.paragraph(s):s;continue}default:{let i='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(i),"";throw new Error(i)}}}return o}parseInline(e,r){r=r||this.renderer;let o="";for(let n=0;n<e.length;n++){let a=e[n];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[a.type]){let i=this.options.extensions.renderers[a.type].call({parser:this},a);if(i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){o+=i||"";continue}}switch(a.type){case"escape":{let i=a;o+=r.text(i.text);break}case"html":{let i=a;o+=r.html(i.text);break}case"link":{let i=a;o+=r.link(i.href,i.title,this.parseInline(i.tokens,r));break}case"image":{let i=a;o+=r.image(i.href,i.title,i.text);break}case"strong":{let i=a;o+=r.strong(this.parseInline(i.tokens,r));break}case"em":{let i=a;o+=r.em(this.parseInline(i.tokens,r));break}case"codespan":{let i=a;o+=r.codespan(i.text);break}case"br":{o+=r.br();break}case"del":{let i=a;o+=r.del(this.parseInline(i.tokens,r));break}case"text":{let i=a;o+=r.text(i.text);break}default:{let i='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(i),"";throw new Error(i)}}}return o}},Ku=class{options;constructor(e){this.options=e||Fl}static passThroughHooks=new Set(["preprocess","postprocess"]);preprocess(e){return e}postprocess(e){return e}},Mk=class{defaults=Lk();options=this.setOptions;parse=this.#e(ii.lex,si.parse);parseInline=this.#e(ii.lexInline,si.parseInline);Parser=si;parser=si.parse;Renderer=Yu;TextRenderer=im;Lexer=ii;lexer=ii.lex;Tokenizer=Xu;Hooks=Ku;constructor(...e){this.use(...e)}walkTokens(e,r){let o=[];for(let n of e)switch(o=o.concat(r.call(this,n)),n.type){case"table":{let a=n;for(let i of a.header)o=o.concat(this.walkTokens(i.tokens,r));for(let i of a.rows)for(let s of i)o=o.concat(this.walkTokens(s.tokens,r));break}case"list":{let a=n;o=o.concat(this.walkTokens(a.items,r));break}default:{let a=n;this.defaults.extensions?.childTokens?.[a.type]?this.defaults.extensions.childTokens[a.type].forEach(i=>{o=o.concat(this.walkTokens(a[i],r))}):a.tokens&&(o=o.concat(this.walkTokens(a.tokens,r)))}}return o}use(...e){let r=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(o=>{let n={...o};if(n.async=this.defaults.async||n.async||!1,o.extensions&&(o.extensions.forEach(a=>{if(!a.name)throw new Error("extension name required");if("renderer"in a){let i=r.renderers[a.name];i?r.renderers[a.name]=function(...s){let l=a.renderer.apply(this,s);return l===!1&&(l=i.apply(this,s)),l}:r.renderers[a.name]=a.renderer}if("tokenizer"in a){if(!a.level||a.level!=="block"&&a.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=r[a.level];i?i.unshift(a.tokenizer):r[a.level]=[a.tokenizer],a.start&&(a.level==="block"?r.startBlock?r.startBlock.push(a.start):r.startBlock=[a.start]:a.level==="inline"&&(r.startInline?r.startInline.push(a.start):r.startInline=[a.start]))}"childTokens"in a&&a.childTokens&&(r.childTokens[a.name]=a.childTokens)}),n.extensions=r),o.renderer){let a=this.defaults.renderer||new Yu(this.defaults);for(let i in o.renderer){let s=o.renderer[i],l=i,c=a[l];a[l]=(...u)=>{let d=s.apply(a,u);return d===!1&&(d=c.apply(a,u)),d||""}}n.renderer=a}if(o.tokenizer){let a=this.defaults.tokenizer||new Xu(this.defaults);for(let i in o.tokenizer){let s=o.tokenizer[i],l=i,c=a[l];a[l]=(...u)=>{let d=s.apply(a,u);return d===!1&&(d=c.apply(a,u)),d}}n.tokenizer=a}if(o.hooks){let a=this.defaults.hooks||new Ku;for(let i in o.hooks){let s=o.hooks[i],l=i,c=a[l];Ku.passThroughHooks.has(i)?a[l]=u=>{if(this.defaults.async)return Promise.resolve(s.call(a,u)).then(p=>c.call(a,p));let d=s.call(a,u);return c.call(a,d)}:a[l]=(...u)=>{let d=s.apply(a,u);return d===!1&&(d=c.apply(a,u)),d}}n.hooks=a}if(o.walkTokens){let a=this.defaults.walkTokens,i=o.walkTokens;n.walkTokens=function(s){let l=[];return l.push(i.call(this,s)),a&&(l=l.concat(a.call(this,s))),l}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}#e(e,r){return(o,n)=>{let a={...n},i={...this.defaults,...a};this.defaults.async===!0&&a.async===!1&&(i.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),i.async=!0);let s=this.#t(!!i.silent,!!i.async);if(typeof o>"u"||o===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof o!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(o)+", string expected"));if(i.hooks&&(i.hooks.options=i),i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(o):o).then(l=>e(l,i)).then(l=>i.walkTokens?Promise.all(this.walkTokens(l,i.walkTokens)).then(()=>l):l).then(l=>r(l,i)).then(l=>i.hooks?i.hooks.postprocess(l):l).catch(s);try{i.hooks&&(o=i.hooks.preprocess(o));let l=e(o,i);i.walkTokens&&this.walkTokens(l,i.walkTokens);let c=r(l,i);return i.hooks&&(c=i.hooks.postprocess(c)),c}catch(l){return s(l)}}}#t(e,r){return o=>{if(o.message+=`
|
|
143
|
-
Please report this to https://github.com/markedjs/marked.`,e){let n="<p>An error occurred:</p><pre>"+dn(o.message+"",!0)+"</pre>";return r?Promise.resolve(n):n}if(r)return Promise.reject(o);throw o}}},Bl=new Mk;function yt(t,e){return Bl.parse(t,e)}yt.options=yt.setOptions=function(t){return Bl.setOptions(t),yt.defaults=Bl.defaults,wH(yt.defaults),yt};yt.getDefaults=Lk;yt.defaults=Fl;yt.use=function(...t){return Bl.use(...t),yt.defaults=Bl.defaults,wH(yt.defaults),yt};yt.walkTokens=function(t,e){return Bl.walkTokens(t,e)};yt.parseInline=Bl.parseInline;yt.Parser=si;yt.parser=si.parse;yt.Renderer=Yu;yt.TextRenderer=im;yt.Lexer=ii;yt.lexer=ii.lex;yt.Tokenizer=Xu;yt.Hooks=Ku;yt.parse=yt;var trt=yt.options,rrt=yt.setOptions,ort=yt.use,nrt=yt.walkTokens,art=yt.parseInline;var irt=si.parse,srt=ii.lex;function CH(t){let e=t.code||"",r=t.inline?yt.parseInline(e):yt.parse(e);return f("div",{className:ke("Markdown",t.className),dangerouslySetInnerHTML:{__html:r}})}function by(t){let[e,r]=P(!0),[o,n]=P(null),a=Ht(async()=>{try{let i=await Au(t);n(i)}catch(i){console.error(i),pe({title:`Failed to load collection: ${t}`,message:String(i),color:"red",autoClose:!1})}r(!1)},[t]);return L(()=>{a()},[t]),{loading:e,schema:o}}function kH(t){let e={_array:[]};return t.forEach(r=>{let o=Uwe();e._array.push(o),e[o]=r}),e}function Uwe(){let t=[],e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=e.length;for(let o=0;o<6;o++)t.push(e.charAt(Math.floor(Math.random()*r)));return t.join("")}function sm(t){let e={};return t.fields.forEach(r=>{r.id&&(r.type==="array"&&r.default&&Array.isArray(r.default)?e[r.id]=kH(r.default):r.default?e[r.id]=r.default:r.type==="object"&&(e[r.id]=sm(r)))}),e}function TH(t){let[e,r]=P(""),[o,n]=P(!1),[a,i]=P(""),s=Lt(),l=t.collection,c=window.__ROOT_CTX.collections[l];if(!c)throw new Error(`collection not found: ${l}`);let u=by(l);function d(){t.onClose&&t.onClose()}async function p(m){m.preventDefault(),n(!0),i("");let h=$i(e),g=c.slugRegex;if(!Ca(h,g)){i('Please enter a valid slug (e.g. "foo-bar-123").'),n(!1);return}let _=`${l}/${h}`;try{let x={};!u.loading&&u.schema&&(x=await sm(u.schema)),await kS(_,{fields:x})}catch(x){i(String(x)),n(!1);return}n(!1),ur(`/cms/content/${t.collection}/${h}?new=true`)}return f(Lc,{className:"NewDocModal",opened:t.opened||!1,onClose:()=>d(),title:"New",size:"500px",overlayColor:s.colorScheme==="dark"?s.colors.dark[9]:s.colors.gray[2],children:[f("div",{className:"NewDocModal__body",children:"Enter a slug for the new doc. The slug is the ID of the page and is what's used in the URL. Use only lowercase letters, numbers, and dashes."}),f("form",{onSubmit:m=>p(m),children:[f(hb,{className:"NewDocModal__slug",collectionId:l,onChange:m=>{r(m.slug)}}),a&&f("div",{className:"NewDocModal__slugError",children:a}),f("div",{className:"NewDocModal__buttons",children:[f(X,{variant:"outline",onClick:()=>d(),type:"button",size:"xs",color:"dark",children:"Cancel"}),f(X,{variant:"filled",type:"submit",size:"xs",color:"dark",loading:u.loading||o,children:"Submit"})]})]})]})}function Qu(t,e){let[r,o]=P(()=>{try{let a=window.localStorage.getItem(t);return a?JSON.parse(a):e}catch(a){return console.error(a),e}});return[r,a=>{typeof a=="function"&&(a=a(r)),window.localStorage.setItem(t,JSON.stringify(a)),o(a)}]}function li(t){let{className:e,localStorageId:r,children:o}=t,[n,a]=Qu(`root::SplitPanel:${r}`,350),[i,s]=P(!1),[l,c]=P(0),u=H(null),d=H(null);if(L(()=>{let m=()=>s(!1);window.addEventListener("mouseup",m);let h=u.current;return h&&c(h.getBoundingClientRect().left),()=>window.removeEventListener("mouseup",m)},[]),L(()=>{let m=h=>{let g=h.clientX-l;a(g)};return i&&window.addEventListener("mousemove",m),()=>window.removeEventListener("mousemove",m)},[i]),o?.length!==2)throw new Error("SplitPanel should have two <SplitPanel.Item> children.");let p={"--panel-size":`${n}px`};return f("div",{className:ke(e,"SplitPanel",i&&"dragging"),ref:u,style:p,children:[o[0],f("div",{className:"SplitPanel__divider",ref:d,onMouseDown:()=>s(!0)}),o[1]]})}li.Item=t=>f("div",{className:ke("SplitPanel__item",t.className,t.fluid?"fluid":"static"),children:t.children});function Zu(t){let[e,r]=P("");L(()=>{let a=window.__ROOT_CTX.rootConfig.projectId,i=window.__ROOT_CTX.collections,s=`root-cms::${a}::last_collection`;if(t.collection)window.localStorage.setItem(s,t.collection);else{let l=window.localStorage.getItem(s);if(l&&i[l]){ur(`/cms/content/${l}`);return}if(window.__ROOT_CTX.collections.Pages){ur("/cms/content/Pages");return}let c=Object.keys(window.__ROOT_CTX.collections)||[];if(c.length>0){let u=c[0];ur(`/cms/content/${u}`);return}console.warn("no collections")}},[t.collection]);let n=Object.keys(window.__ROOT_CTX.collections).filter(a=>e?a.toLowerCase().includes(e.toLowerCase()):!0).map(a=>({...window.__ROOT_CTX.collections[a],id:a}));return f(me,{children:f(li,{className:"CollectionPage",localStorageId:"CollectionPage",children:[f(li.Item,{className:"CollectionPage__side",children:[f("div",{className:"CollectionPage__side__title",children:"Content"}),f("div",{className:"CollectionPage__side__search",children:f("input",{type:"text",placeholder:"Search",onChange:a=>r(a.target.value)})}),f("div",{className:"CollectionPage__side__collections",children:[n.map(a=>f("a",{className:ke("CollectionPage__side__collection",a.id===t.collection&&"active"),href:`/cms/content/${a.id}`,children:[f("div",{className:"CollectionPage__side__collection__icon",children:f(yl,{size:20,strokeWidth:"1.75"})}),f("div",{className:"CollectionPage__side__collection__name",children:a.name||a.id}),a.description&&f("div",{className:"CollectionPage__side__collection__desc",children:a.description})]},a.id)),n.length===0&&f("div",{className:"CollectionPage__side__collections__empty",children:"No collections match your query."})]})]}),f(li.Item,{className:"CollectionPage__main",fluid:!0,children:t.collection?f(Zu.Collection,{collection:t.collection},t.collection):f("div",{className:"CollectionPage__main__unselected",children:[f(zS,{size:24,strokeWidth:1.75}),f("div",{className:"CollectionPage__main__unselected__title",children:"Select a collection to get started."})]})})]})})}Zu.Collection=t=>{let[e,r]=Qu(`root::CollectionPage:${t.collection}:orderBy`,"modifiedAt"),[o,n]=P(!1),a=window.__ROOT_CTX.collections[t.collection];if(!a)return ur("/cms/content"),f(Ae,{});let[i,s,l]=Su(t.collection,{orderBy:e});return f(Ae,{children:[f(TH,{collection:t.collection,opened:o,onClose:()=>n(!1)}),f("div",{className:"CollectionPage__collection",children:[f("div",{className:"CollectionPage__collection__header",children:[f("div",{className:"CollectionPage__collection__header__title",children:a.name}),a.description&&f(CH,{className:"CollectionPage__collection__header__description",code:a.description})]}),f(zc,{className:"CollectionPage__collection__tabs",active:1,children:f(zc.Tab,{label:"Docs",children:f("div",{className:"CollectionPage__collection__docsTab",children:[!i&&l.length>0&&f("div",{className:"CollectionPage__collection__docsTab__header",children:[f(Te,{className:"CollectionPage__collection__docsTab__header__title",children:a.name||t.collection}),f("div",{className:"CollectionPage__collection__docsTab__controls",children:[f("div",{className:"CollectionPage__collection__docsTab__controls__sort",children:[f("div",{className:"CollectionPage__collection__docsTab__controls__sort__label",children:"Sort:"}),f(Pt,{size:"xs",value:e,onChange:c=>r(c||"modifiedAt"),data:[{value:"slug",label:"A-Z"},{value:"newest",label:"Newest"},{value:"oldest",label:"Oldest"},{value:"modifiedAt",label:"Last modified"}]})]}),f("div",{className:"CollectionPage__collection__docsTab__controls__newDoc",children:f(X,{color:"dark",size:"xs",leftIcon:f(ku,{size:16}),onClick:()=>n(!0),children:"New"})})]})]}),f("div",{className:"CollectionPage__collection__docsTab__content",children:i?f("div",{className:"CollectionPage__collection__docsTab__content__loading",children:f(Re,{color:"gray",size:"xl"})}):l.length===0?f("div",{class:"CollectionPage__collection__docsEmpty",children:[f("div",{class:"CollectionPage__collection__docsEmpty__icon",children:f(Vwe,{})}),f("div",{class:"CollectionPage__collection__docsEmpty__title",children:"Collection is empty."}),f("div",{class:"CollectionPage__collection__docsEmpty__button",children:f(X,{color:"dark",size:"xs",leftIcon:f(ku,{size:16}),onClick:()=>n(!0),children:"New"})})]}):f(Zu.DocsList,{collection:t.collection,docs:l,reloadDocs:()=>s()})})]})})})]})]})};Zu.DocsList=t=>{let e=t.collection,r=window.__ROOT_CTX.collections[t.collection];if(!r)throw new Error(`could not find collection: ${e}`);let o=t.docs||[];function n(a){return Jn({collectionId:e,slug:a})}return f("div",{className:"CollectionPage__collection__docsList",children:o.map(a=>{let i=`/cms/content/${e}/${a.slug}`,s=n(a.slug),l=a.fields||{},c=oo(l,r.preview?.title||"meta.title"),u=oo(l,r.preview?.image||"meta.image")||r.preview?.defaultImage;return f("div",{className:"CollectionPage__collection__docsList__doc",children:[f("div",{className:"CollectionPage__collection__docsList__doc__image",children:f("a",{href:i,children:f(Tn,{src:u?.src,width:120,height:90,withPlaceholder:!u?.src})})}),f("a",{className:"CollectionPage__collection__docsList__doc__content",href:i,children:[f("div",{className:"CollectionPage__collection__docsList__doc__content__header",children:[f("div",{className:"CollectionPage__collection__docsList__doc__content__header__docId",children:a.id}),f(Wu,{doc:a})]}),f("div",{className:"CollectionPage__collection__docsList__doc__content__title",children:c||"[UNTITLED]"}),f("div",{className:"CollectionPage__collection__docsList__doc__content__url",children:s})]}),f("div",{className:"CollectionPage__collection__docsList__doc__controls",children:f(_y,{docId:a.id,data:a,onAction:d=>{(d.action==="delete"||d.action==="unpublish")&&t.reloadDocs()}})})]},a.id)})})};function Vwe(){return f("svg",{width:"165",height:"142",viewBox:"0 0 165 142",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[f("path",{d:"M85.3227 123.613C119.114 123.613 146.509 96.2184 146.509 62.3067C146.509 28.3949 118.993 1 85.3227 1C51.5316 1 24.1367 28.3949 24.1367 62.3067C24.1367 96.2184 51.5316 123.613 85.3227 123.613Z",fill:"#f5f5f5",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10"}),f("path",{d:"M154.276 42.8823C157.009 42.8823 159.224 40.667 159.224 37.9343C159.224 35.2016 157.009 32.9863 154.276 32.9863C151.543 32.9863 149.328 35.2016 149.328 37.9343C149.328 40.667 151.543 42.8823 154.276 42.8823Z",fill:"#f5f5f5"}),f("path",{d:"M161.516 23.5733C163.383 23.5733 164.895 22.0604 164.895 20.1942C164.895 18.3279 163.383 16.8151 161.516 16.8151C159.65 16.8151 158.137 18.3279 158.137 20.1942C158.137 22.0604 159.65 23.5733 161.516 23.5733Z",fill:"#f5f5f5"}),f("path",{d:"M26.9123 22.1192C28.7785 22.1192 30.2914 20.6064 30.2914 18.7401C30.2914 16.8739 28.7785 15.361 26.9123 15.361C25.0461 15.361 23.5332 16.8739 23.5332 18.7401C23.5332 20.6064 25.0461 22.1192 26.9123 22.1192Z",fill:"#f5f5f5"}),f("path",{d:"M6.27549 87.288C9.74134 87.288 12.551 84.4784 12.551 81.0126C12.551 77.5467 9.74134 74.7371 6.27549 74.7371C2.80963 74.7371 0 77.5467 0 81.0126C0 84.4784 2.80963 87.288 6.27549 87.288Z",fill:"#f5f5f5"}),f("path",{d:"M121.099 107.854H138.619C140.82 107.854 142.706 105.969 142.706 103.769V22.0726C142.706 19.873 140.82 17.9877 138.619 17.9877H121.643",fill:"#f5f5f5",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10"}),f("path",{d:"M51.5361 107.854H34.5596C32.3589 107.854 30.4727 105.969 30.4727 103.769V22.0726C30.4727 19.873 32.3589 17.9877 34.5596 17.9877H51.1864",fill:"#f5f5f5",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10"}),f("path",{d:"M42.2832 34.327H50.7714",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10","stroke-linecap":"round"}),f("path",{d:"M42.2832 45.3246H50.7714",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10","stroke-linecap":"round"}),f("path",{d:"M42.2832 56.6365H50.7714",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10","stroke-linecap":"round"}),f("path",{d:"M42.2832 67.9485H50.7714",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10","stroke-linecap":"round"}),f("path",{d:"M42.2832 89.9436H50.7714",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10","stroke-linecap":"round"}),f("path",{d:"M129.816 34.327H121.643",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10"}),f("path",{d:"M129.816 45.3246H121.643",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10","stroke-linecap":"round"}),f("path",{d:"M129.816 56.6365H121.643",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10","stroke-linecap":"round"}),f("path",{d:"M129.816 67.9485H121.643",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10","stroke-linecap":"round"}),f("path",{d:"M129.816 89.9436H121.643",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10","stroke-linecap":"round"}),f("path",{d:"M117.556 114.767H55.3086C53.108 114.767 51.2217 112.881 51.2217 110.682V15.7883C51.2217 13.5888 53.108 11.7035 55.3086 11.7035H117.556C119.756 11.7035 121.643 13.5888 121.643 15.7883V110.682C121.643 112.881 119.756 114.767 117.556 114.767Z",fill:"white",stroke:"#e5e5e5","stroke-width":"2","stroke-miterlimit":"10"}),f("path",{d:"M110.01 42.4468H66.6261C65.683 42.4468 65.0542 41.8773 65.0542 41.0231V37.3217C65.0542 36.4675 65.683 35.898 66.6261 35.898H110.01C110.954 35.898 111.582 36.4675 111.582 37.3217V41.0231C111.582 41.5926 110.954 42.4468 110.01 42.4468Z",fill:"#f5f5f5",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10"}),f("path",{d:"M110.01 59.4146H66.6261C65.683 59.4146 65.0542 58.8451 65.0542 57.9909V54.2894C65.0542 53.4352 65.683 52.8658 66.6261 52.8658H110.01C110.954 52.8658 111.582 53.4352 111.582 54.2894V57.9909C111.582 58.8451 110.954 59.4146 110.01 59.4146Z",fill:"#f5f5f5",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10"}),f("path",{d:"M110.01 76.6964H66.6261C65.683 76.6964 65.0542 76.127 65.0542 75.2728V71.5713C65.0542 70.7171 65.683 70.1476 66.6261 70.1476H110.01C110.954 70.1476 111.582 70.7171 111.582 71.5713V75.2728C111.582 76.127 110.954 76.6964 110.01 76.6964Z",fill:"#f5f5f5",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10"}),f("path",{d:"M110.011 94.2926H92.7198C91.7767 94.2926 91.1479 93.7231 91.1479 92.8689V89.1674C91.1479 88.3132 91.7767 87.7438 92.7198 87.7438H110.011C110.954 87.7438 111.583 88.3132 111.583 89.1674V92.8689C111.583 93.7231 110.954 94.2926 110.011 94.2926Z",fill:"#f5f5f5",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10"}),f("path",{d:"M105.548 125.569C105.155 127.237 104.566 129.003 103.879 130.475C102.015 134.106 99.0712 136.952 95.4405 138.816C91.7116 140.681 87.2959 141.466 82.8801 140.484C72.4786 138.326 65.8059 128.12 67.9647 117.719C70.1235 107.317 80.2307 100.546 90.6322 102.803C94.3611 103.588 97.5993 105.453 100.347 108.004C104.959 112.616 106.921 119.289 105.548 125.569Z",fill:"#d4d4d4",stroke:"#a3a3a3","stroke-width":"2","stroke-miterlimit":"10"}),f("path",{d:"M92.8892 118.976H89.4735V115.56C89.4735 114.163 88.377 112.892 86.8053 112.892C85.4087 112.892 84.1371 113.988 84.1371 115.56V118.976H80.7214C79.3248 118.976 78.0532 120.072 78.0532 121.644C78.0532 122.374 78.3129 123.054 78.8122 123.553C79.3116 124.052 79.9912 124.312 80.7214 124.312H84.1371V127.728C84.1371 129.124 85.2337 130.396 86.8053 130.396C88.2019 130.396 89.4735 129.299 89.4735 127.728V124.312H92.8892C94.2858 124.312 95.5574 123.215 95.5574 121.644C95.5574 120.072 94.2858 118.976 92.8892 118.976Z",fill:"white",stroke:"#a3a3a3","stroke-width":"2"})]})}function OH(){let[t,e]=P(!0),[r,o]=P(null),[n,a]=P(null);return L(()=>{let i=new URLSearchParams(window.location.search),s=PH(i.get("left")||""),l=PH(i.get("right")||"");o(s),a(l),e(!1)},[]),f(me,{children:f("div",{className:"ComparePage",children:t?f(Re,{}):r&&n?f(Vb,{className:"ComparePage__diff",left:r,right:n}):f("div",{className:"ComparePage__error",children:"Invalid params, double check query params."})})})}function PH(t){let[e,r]=String(t).split("@");return e&&r?{docId:e,versionId:r}:null}async function AH(t,e){if(!t)throw new Error("missing data source id");let r=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,n=we(o,"Projects",r,"DataSources",t);await vu(n,{...e,id:t,createdAt:Ut(),createdBy:window.firebase.user.email}),Je("datasource.create",{metadata:{datasourceId:t}})}async function DH(){let t=window.__ROOT_CTX.rootConfig.projectId,e=window.firebase.db,r=nn(e,"Projects",t,"DataSources"),o=to(r),n=await an(o),a=[];return n.forEach(i=>{a.push(i.data())}),a}async function Ju(t){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,o=we(r,"Projects",e,"DataSources",t),n=await vr(o);return n.exists()?n.data():null}async function Bk(t,e){let r=e?.mode||"draft",o=window.__ROOT_CTX.rootConfig.projectId,n=window.firebase.db,a=we(n,"Projects",o,"DataSources",t,"Data",r),i=await vr(a);return i.exists()?i.data():null}async function RH(t,e){let r=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,n=we(o,"Projects",r,"DataSources",t);await rr(n,e),Je("datasource.save",{metadata:{datasourceId:t}})}async function NH(t){let e=await Ju(t);if(!e)throw new Error(`data source not found: ${t}`);if(e.type==="http"&&e.url&&!BH(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 Hwe(e),n=window.__ROOT_CTX.rootConfig.projectId,a=window.firebase.db,i=we(a,"Projects",n,"DataSources",t),s=we(a,"Projects",n,"DataSources",t,"Data","draft"),l={...e,syncedAt:Ze.now(),syncedBy:window.firebase.user.email},c=sn(a);c.set(s,{dataSource:l,data:r,...o?{headers:o}:{}}),c.update(i,{syncedAt:Ze.now(),syncedBy:window.firebase.user.email}),await c.commit()}console.log(`synced data source: ${t}`),Je("datasource.sync",{metadata:{datasourceId:t}})}async function MH(t){let e=await Ju(t);if(!e)throw new Error(`data source not found: ${t}`);let r=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,n=we(o,"Projects",r,"DataSources",t),a=we(o,"Projects",r,"DataSources",t,"Data","draft"),i=we(o,"Projects",r,"DataSources",t,"Data","published"),s=await Bk(t,{mode:"draft"}),l={...e,publishedAt:Ze.now(),publishedBy:window.firebase.user.email},c=sn(o);c.set(i,{dataSource:l,data:s?.data||null,...s?.headers?{headers:s.headers}:{}}),c.update(a,{dataSource:l}),c.update(n,{publishedAt:Ze.now(),publishedBy:window.firebase.user.email}),await c.commit(),console.log(`published data ${t}`),Je("datasource.publish",{metadata:{datasourceId:t}})}async function LH(t){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,o=we(r,"Projects",e,"DataSources",t),n=we(r,"Projects",e,"DataSources",t,"Data","draft"),a=we(r,"Projects",e,"DataSources",t,"Data","published"),i=sn(r);i.delete(n),i.delete(a),i.delete(o),await i.commit(),console.log(`deleted data source ${t}`),Je("datasource.delete",{metadata:{datasourceId:t}})}async function Hwe(t){if(t.type==="http")return{data:await jwe(t)};if(t.type==="gsheet")return await $we(t);throw new Error(`unsupported data source: ${t.type}`)}async function $we(t){let e=Ki(t.url);if(!e?.spreadsheetId)throw new Error(`failed to parse google sheet url: ${t.url}`);let o=await new ka(e.spreadsheetId).getSheet(e.gid??0);if(!o)throw new Error(`could not find sheet: ${t.url}`);let n=t.dataFormat||"map",[a,i]=await o.getValues();return n==="array"?{data:[a,i],headers:a}:{data:i.map(l=>{let c={};return l.forEach((u,d)=>{let p=a[d];p&&(c[p]=String(u||""))}),c}),headers:a}}async function jwe(t){if(!BH(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 BH(t){return t&&t.startsWith("/")}function FH(t){let e=Gwe(t.timestamp),[r,o]=P(t.timestamp?Rn(e,{style:"short"}):"never");return e?(L(()=>{let n=window.setInterval(()=>{o(Rn(e,{style:"short"}))},6e4);return()=>window.clearInterval(n)},[]),f(xe,{transition:"pop",label:`${qwe(e)} by ${t.email}`,children:Rn(e,{style:"short"})})):f("div",{children:r})}function qwe(t){return new Date(t).toLocaleDateString("en",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Gwe(t){return typeof t=="number"?t:t?t.toMillis():0}function ed(t){let e=t.dataSource,[r,o]=P(!1),[n,a]=P(t.action==="sync"?e.syncedAt:e.publishedAt),[i,s]=P(t.action==="sync"?e.syncedBy:e.publishedBy),l=Xi();async function c(){o(!0);let d=`data-source-${t.action}-${e.id}`;pe({id:d,loading:!0,title:`Running Data Source ${t.action}`,message:`Updating ${e.id}...`,autoClose:!1,disallowClose:!0});try{t.action==="sync"?(e.type==="gsheet"&&!l.isLoggedIn()&&await l.login(),await NH(e.id)):t.action==="publish"&&await MH(e.id),a(Ze.now()),s(window.firebase.user.email),o(!1),t.onAction&&t.onAction(),at({id:d,title:"Success",message:`Updated Data Source ${e.id}`,autoClose:!1})}catch(p){console.error(p);let m=p;typeof p=="object"&&p.body&&(m=String(p.body)),o(!1),at({id:d,title:`Data Source ${t.action} failed`,message:String(m),color:"red",autoClose:!1})}}let u="";return t.action==="sync"?u="Sync data to a draft state":t.action==="publish"&&(u="Publish synced data to prod"),f("div",{className:"DataSourceStatusButton",children:[f("div",{className:"DataSourceStatusButton__label",children:!r&&f(FH,{timestamp:n,email:i})}),f("div",{className:"DataSourceStatusButton__button",children:f(xe,{transition:"pop",label:u,children:f(X,{variant:"default",size:"xs",compact:!0,onClick:()=>c(),loading:r,children:t.action})})})]})}function yy(){return f(me,{children:f("div",{className:"DataPage",children:[f("div",{className:"DataPage__header",children:[f(Te,{size:"h1",children:"Data Sources"}),f(Me,{as:"p",children:"Add data sources to sync data from external services, like Google Sheets."}),f("div",{className:"DataPage__header__buttons",children:f(X,{component:"a",color:"blue",size:"xs",href:"/cms/data/new",children:"New data source"})})]}),f(yy.DataSourcesTable,{})]})})}yy.DataSourcesTable=()=>{let[t,e]=P(!0),[r,o]=P([]);async function n(){let a=await DH();o(a),e(!1)}return L(()=>{n()},[]),f("div",{className:"DataPage__DataSourcesTable",children:[t&&f(Re,{color:"gray",size:"xl"}),r.length>0&&f(kr,{verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[f("thead",{children:f("tr",{children:[f("th",{children:"id"}),f("th",{children:"description"}),f("th",{children:"type"}),f("th",{children:"url"}),f("th",{children:"last synced"}),f("th",{children:"last published"})]})}),f("tbody",{children:r.map(a=>f("tr",{children:[f("td",{children:f("a",{href:`/cms/data/${a.id}`,children:a.id})}),f("td",{children:a.description||""}),f("td",{children:a.type}),f("td",{children:a.url}),f("td",{children:f(ed,{dataSource:a,action:"sync"})}),f("td",{children:f(ed,{dataSource:a,action:"publish"})})]},a.id))})]})]})};function fn(t){let[e,r]=P(!0),[o,n]=P(null),[a,i]=P(null),s=t.id;async function l(){let u=await Ju(s);if(n(u),u){let d=await Bk(s,{mode:"draft"});i(d)}r(!1)}L(()=>{l()},[]);function c(u){u==="sync"&&l()}return f(me,{children:f("div",{className:"DataSourcePage",children:[f("div",{className:"DataSourcePage__header",children:[f(_r,{className:"DataSourcePage__header__breadcrumbs",children:[f("a",{href:"/cms/data",children:"Data"}),f("div",{children:s})]}),f("div",{className:"DataSourcePage__header__titleWrap",children:[f(Te,{size:"h1",children:["Data Source: ",s]}),f("div",{className:"DataSourcePage__header__controls",children:f(xe,{label:"Configure",children:f(Fe,{component:"a",href:`/cms/data/${t.id}/edit`,children:f(wl,{size:24,stroke:"1.5"})})})})]}),o?.description&&f(Me,{as:"p",children:o.description})]}),o&&f(fn.SyncStatus,{dataSource:o,onAction:c}),e?f(Re,{color:"gray",size:"xl"}):o?f(fn.DataSection,{dataSource:o,data:a}):f("div",{className:"DataSourcePage__notFound",children:"Not Found"})]})})}fn.SyncStatus=t=>{let e=t.dataSource;return f("div",{className:"DataSourcePage__SyncStatus",children:[f(Te,{size:"h2",children:"Status"}),f(kr,{verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[f("thead",{children:f("tr",{children:[f("th",{children:"last synced"}),f("th",{children:"last published"})]})}),f("tbody",{children:f("tr",{children:[f("td",{children:f(ed,{dataSource:e,action:"sync",onAction:()=>{t.onAction&&t.onAction("sync")}})}),f("td",{children:f(ed,{dataSource:e,action:"publish"})})]})})]})]})};fn.DataSection=t=>{let{data:e,headers:r}=t.data||{},o=t.dataSource;if(!e)return null;let n=o.dataFormat||"map";if(o.type==="gsheet"){let a=r,i=[];if(n==="array")i=e;else if(n==="map"){let s=e;if(!a){let l=new Set;s.forEach(c=>{for(let u in c)u&&l.add(u)}),a=Array.from(l)}s.forEach(l=>{i.push(a.map(c=>l[c]||""))})}return f(fn.DataSectionWrap,{dataSource:o,children:f(fn.DataTable,{headers:a,rows:i})})}return o.type==="http"?f(fn.DataSectionWrap,{dataSource:o,children:f(fn.DefaultDataDisplay,{data:e})}):(console.log(`unsupported data type: ${o.type}`),null)};fn.DataSectionWrap=t=>f("div",{className:"DataSourcePage__DataSection",children:[f("div",{className:"DataSourcePage__DataSection__header",children:[f(Te,{size:"h2",children:"Data"}),f("div",{className:"DataSourcePage__DataSection__header__actions",children:[t.dataSource.url?.startsWith("https://docs.google.com/spreadsheets/")&&f(xe,{label:"Open spreadsheet",children:f(Fe,{component:"a",href:t.dataSource.url,target:"_blank",variant:"filled",color:"green",children:f(El,{size:16,stroke:"2.25"})})}),t.dataSource.previewUrl&&f(X,{component:"a",variant:"default",size:"xs",href:t.dataSource.previewUrl,target:"_blank",children:"Preview"})]})]}),t.children]});fn.DataTable=t=>{let e=t.headers||[],r=t.rows||[];return f("div",{className:"DataSourcePage__DataTable",children:f(kr,{className:"DataSourcePage__DataTable__table",verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[e.length>0&&f("thead",{children:f("tr",{children:e.map(o=>f("th",{children:o},o))})}),f("tbody",{children:r.map((o,n)=>f("tr",{children:o.map((a,i)=>f("td",{children:a},i))},n))})]})})};fn.DefaultDataDisplay=t=>{let e=t.data;return typeof e=="object"?f(Mc,{value:JSON.stringify(e,null,2),minRows:20,maxRows:100}):f(Zt,{value:String(e),minRows:12,maxRows:100})};function os(t){let[e,r]=P(!0),[o,n]=P(!1),[a,i]=P([]),[s,l]=P({}),[c,u]=P(null),[d,p]=P(!1),[m,h]=P({}),[g,_]=P(!1),x=t.collection,b=t.slug,y=`${x}/${b}`,w=(window.__ROOT_CTX.rootConfig.i18n||{}).locales||["en"];async function v(){try{let[S,C,F]=await Promise.all([Eb(y),ji(),mb(y)]);i(S),l(C),u(F),r(!1)}catch(S){console.error(S),r(!1),n(!0)}}if(L(()=>{v()},[]),o)return f(os.NotFound,{docId:y});function T(S,C,F){p(!0),h(N=>{let R={...N},z=R[S]??{};return z.source=S,z[C]=F,R[S]=z,R})}async function O(){_(!0),await bt(async()=>{console.log("EditTranslationsModal.onSave()");let S=`edit-translations-${y}`;pe({id:S,loading:!0,title:"Saving translations",message:`Updating for ${y}...`,autoClose:!1,disallowClose:!0});let C=Object.values(m);console.log(C),await gl(y,C),at({id:S,title:"Saved translations",message:`Updated translations for ${y}!`,autoClose:!0}),h({}),p(!1)}),_(!1)}return f(me,{children:f("div",{className:"DocTranslationsPage",children:[f("div",{className:"DocTranslationsPage__header",children:[f(_r,{className:"DocTranslationsPage__header__breadcrumbs",children:[f("a",{href:`/cms/content/${x}`,children:x}),f("a",{href:`/cms/content/${x}/${b}`,children:b}),f("div",{children:"translations"})]}),f("div",{className:"DocTranslationsPage__header__titleWrap",children:f(Te,{size:"h1",children:["Translations: ",y]})}),c&&f("div",{className:"DocTranslationsPage__header__linkedSheet",children:[f("div",{className:"DocTranslationsPage__header__linkedSheet__label",children:[f("strong",{children:"NOTE:"})," Translations for this doc are managed in Google Sheets."]}),f("div",{className:"DocTranslationsPage__header__linkedSheet__controls",children:[f(xe,{label:"Open Google Sheet",children:f(Fe,{component:"a",href:Mn(c),target:"_blank",variant:"filled",color:"green",size:"sm",children:f(El,{size:16,strokeWidth:2.25})})}),f(X,{variant:"default",size:"xs",leftIcon:f(ti,{size:16,strokeWidth:1.75}),children:"Import from Sheet"}),f(X,{variant:"default",size:"xs",leftIcon:f(bl,{size:16,strokeWidth:1.75}),children:"Export to Sheet"})]})]})]}),f("div",{className:ke("DocTranslationsPage__content",e&&"DocTranslationsPage__content--loading"),children:e?f(Re,{color:"gray",size:"xl"}):f(os.Table,{locales:w,sourceStrings:a,translationsMap:s,onChange:T,changesMap:m})}),f("div",{className:"DocTranslationsPage__footer",children:f("div",{className:"DocTranslationsPage__footer__buttons",children:f(X,{variant:"filled",color:"dark",disabled:!d,loading:g,onClick:()=>O(),children:"Save"})})})]})})}os.NotFound=t=>f(me,{children:f("div",{className:"DocTranslationsPage DocTranslationsPage--error",children:f("div",{className:"DocTranslationsPage__error",children:[f("div",{className:"DocTranslationsPage__error__icon",children:f(jp,{size:60})}),f("div",{className:"DocTranslationsPage__error__title",children:["Not found: ",t.docId]})]})})});os.Table=t=>{let e=Tt(()=>{let o={};return Object.values(t.translationsMap).forEach(n=>{o[n.source]=n}),o},[t.translationsMap]);function r(o,n){return{translation:(e[o]||{})[n]||"",hasChanges:!1}}return f("div",{className:"DocTranslationsPage__TableWrap",children:f("table",{className:"DocTranslationsPage__Table",children:[f("thead",{children:f("tr",{children:[f("th",{children:"source"}),t.locales.map(o=>f("th",{children:o},o))]})}),f("tbody",{children:t.sourceStrings.map(o=>f("tr",{children:[f("td",{className:"DocTranslationsPage__Table__sourceCellWrap",children:f("div",{className:"DocTranslationsPage__Table__sourceCell",children:o})}),t.locales.map(n=>{let a=r(o,n);return f("td",{children:f(os.Textarea,{source:o,locale:n,value:a.translation,onChange:t.onChange,changesMap:t.changesMap})},n)})]},o))})]})})};os.Textarea=t=>{let e=H(null),[r,o]=P(t.value),n=null;t.locale in(t.changesMap[t.source]||{})&&(n=t.changesMap[t.source][t.locale]);let a=n!==null&&n!==t.value;function i(){window.requestAnimationFrame(()=>{let s=e.current;s.style.minHeight="auto";let l=s.scrollHeight;s.style.minHeight=`${l}px`})}return L(()=>{i()},[r]),f("textarea",{ref:e,className:ke("DocTranslationsPage__Textarea",a&&"DocTranslationsPage__Textarea--hasChanges",!r&&"DocTranslationsPage__Textarea--empty"),onFocus:()=>i(),rows:1,onChange:s=>{let l=s.target.value;o(l),t.onChange(t.source,t.locale,l)},value:r})};function zH(t,e){let r;return(...o)=>{window.clearTimeout(r),r=window.setTimeout(()=>{t(...o)},e)}}var ns=class{constructor(){this.events=new Map}on(e,r){let o=this.events.get(e)??[];return this.events.set(e,[...o,r]),()=>{this.off(e,r)}}off(e,r){let o=this.events.get(e)??[],n=o.indexOf(r);n>=0&&o.splice(n,1)}dispatch(e,...r){(this.events.get(e)??[]).forEach(n=>n(...r))}dispose(){this.events.clear()}};var UH=3*Tr.second,Wwe=5*Tr.minute;var Fk=class extends ns{constructor(r){super();this.pendingUpdates=new Map;this.cachedData={};this.subscribers={};this.saveState="NO_CHANGES";this.autolock=!1;this.autolockReason="autolock";this.autolockApplied=!1;this.started=!1;this.queueChanges=zH(()=>this.flush(),UH);this.projectId=window.__ROOT_CTX.rootConfig.projectId;let[o,n]=r.split("/");this.docId=r,this.collectionId=o,this.slug=n,this.db=window.firebase.db,this.docRef=we(this.db,"Projects",this.projectId,"Collections",o,"Drafts",n);let a=window.__ROOT_CTX.collections[o];a&&(this.autolock=!!a.autolock,a.autolockReason&&(this.autolockReason=a.autolockReason))}async start(){this.started||(this.started=!0,this.dbUnsubscribe=tb(this.docRef,r=>{let o=r.data();this.pendingUpdates.size>0&&vy(o,Object.fromEntries(this.pendingUpdates)),this.cachedData=o,this.notifySubscribers()}))}stop(){this.started&&(this.dbUnsubscribe&&this.dbUnsubscribe(),this.flush(),this.started=!1)}onChange(r){return this.on("CHANGE",r)}onSaveStateChange(r){return this.on("SAVE_STATE_CHANGE",r)}onFlush(r){return this.on("FLUSH",r)}subscribe(r,o){return this.subscribers[r]??=new Set,this.subscribers[r].add(o),o(this.getValue(r)),()=>{this.subscribers[r].delete(o),this.subscribers[r].size===0&&delete this.subscribers[r]}}notifySubscribers(){let r=this.cachedData;this.dispatch("CHANGE",r),VH(this.subscribers,r)}getValue(r){return oo(this.cachedData,r)}async updateKey(r,o){await this.updateKeys({[r]:o})}async updateKeys(r){for(let o in r)this.pendingUpdates.set(o,r[o]);vy(this.cachedData,r),this.dispatch("CHANGE",this.cachedData),this.setSaveState("UPDATE_PENDING"),this.queueChanges()}async removeKey(r){this.pendingUpdates.set(r,zr()),vy(this.cachedData,{[r]:void 0}),this.dispatch("CHANGE",this.cachedData),this.setSaveState("UPDATE_PENDING"),this.queueChanges()}setSaveState(r){let o=this.saveState;r==="SAVED"&&o!=="SAVING"||(this.saveState=r,r==="SAVED"&&window.setTimeout(()=>{this.saveState==="SAVED"&&this.setSaveState("NO_CHANGES")},UH),this.dispatch("SAVE_STATE_CHANGE",r))}async flush(){if(this.pendingUpdates.size===0)return;let r=Object.fromEntries(this.pendingUpdates);r["sys.modifiedAt"]=Ut(),r["sys.modifiedBy"]=window.firebase.user.email,this.autolock&&!this.autolockApplied&&!this.cachedData?.sys?.publishingLocked&&(this.autolockApplied=!0,r["sys.publishingLocked"]={lockedAt:Ut(),lockedBy:window.firebase.user.email,reason:this.autolockReason}),this.pendingUpdates.clear();try{this.setSaveState("SAVING"),await rr(this.docRef,r),this.setSaveState("SAVED"),this.dispatch("FLUSH"),Je("doc.save",{metadata:{docId:this.docId},throttle:Wwe,throttleId:this.docId})}catch(o){console.error("failed to update doc"),console.error(o),this.setSaveState("ERROR"),pe({title:"Failed to save",message:`Failed to save changes to ${this.slug}`,color:"red",autoClose:!1});for(let n in r)n.startsWith("sys.")||this.pendingUpdates.has(n)||(this.pendingUpdates.set(n,r[n]),this.queueChanges(),console.log("re-queued updates"))}}getLocales(){return this.cachedData&&this.cachedData.sys?.locales?this.cachedData.sys.locales:["en"]}setLocales(r){this.updateKey("sys.locales",r)}async dispose(){super.dispose(),this.stop()}};function vy(t,e){for(let r in e){let o=e[r];if(r.includes(".")){let[n,a]=Kwe(r);t[n]??={},vy(t[n],{[a]:o})}else typeof o>"u"?delete t[r]:t[r]=o}}function VH(t,e,r){r||(r=[]);for(let o in e){let n=[...r,o],a=n.join("."),i=t[a],s=e[o];i&&Array.from(i).forEach(l=>{l(s)}),Bp(s)&&VH(t,s,n)}}function Kwe(t){let e=t.indexOf("."),r=t.substring(0,e),o=t.substring(e+1);return[r,o]}function HH(t){let[e,r]=P(!0),[o,n]=P({}),a=Tt(()=>new Fk(t),[t]),[i,s]=P("NO_CHANGES");return L(()=>{a.onChange(c=>{n(c),r(!1),Lp(t,c)}),a.onSaveStateChange(c=>s(c)),a.start();let l=()=>{document.hidden||document.visibilityState!=="visible"?a.stop():a.started||(r(!0),a.start())};return document.addEventListener("visibilitychange",l),()=>{a.dispose(),document.removeEventListener("visibilitychange",l)}},[t]),{loading:e,saveState:i,controller:a,data:o}}function $H(t,e){let r=zk(t);for(let o of r)if(e[o]){let n=String(e[o]);t=t.replaceAll(`{${o}}`,n)}return t}function zk(t){return Array.from(t.matchAll(/\{(.+?)\}/g)).map(e=>e[1])}var Uk=class{constructor(){this.value=null}set(e){this.value=e}},Xwe=new Uk;function jH(){return Xwe}function qH(t,e){let r=!1;return(...o)=>{r||(t(...o),r=!0,setTimeout(()=>{r=!1},e))}}var lm=class extends ns{constructor(r){super();this.interval=0;this.timeout=0;this.interval=r}start(){this.timeout=window.setTimeout(()=>{this.tick()},this.interval)}tick(){this.dispatch("tick"),this.start()}reset(){this.stop(),this.start()}stop(){this.timeout&&(window.clearTimeout(this.timeout),this.timeout=0)}};var Ywe=30*Tr.second,GH=5*Tr.minute,Vk=class extends ns{constructor(r){super();this.started=!1;this.timer=new lm(Ywe);this.idleTimer=new lm(GH);this.onUserInteraction=qH(()=>{this.idleTimer.reset()},5e3);this.id=r;let o=window.__ROOT_CTX.rootConfig.projectId,n=window.firebase.db;this.docRef=we(n,"Projects",o,"Viewers",r),this.timer.on("tick",()=>this.onTick()),this.idleTimer.on("tick",()=>this.onIdle()),window.addEventListener("mousemove",this.onUserInteraction),window.addEventListener("keypress",this.onUserInteraction)}async start(){this.started||(this.started=!0,this.dbUnsubscribe=tb(this.docRef,r=>{let o=r.data();this.onData(o)}),this.onTick(),this.timer.start())}onData(r){let o=window.firebase.user,n=Ze.now(),a=Object.values(r).filter(i=>!(i.email===o.email||n.toMillis()-i.lastViewedAt.toMillis()>GH));this.dispatch("change",a)}async onTick(){let r=window.firebase.user;if(!r.email){console.log("no user email:",r);return}console.log(`updating lastViewedAt for ${r.email}`),await vu(this.docRef,{[r.email]:{email:r.email,photoURL:r.photoURL,lastViewedAt:Ut()}},{merge:!0})}async onIdle(){this.stop()}stop(){this.started&&(this.dbUnsubscribe&&this.dbUnsubscribe(),this.timer.stop(),this.idleTimer.stop(),this.onDisconnect(),this.started=!1)}async onDisconnect(){let r=window.firebase.user;if(!r.email){console.log("no user email:",r);return}let o=new No(r.email,"disconnectedAt");await rr(this.docRef,o,Ut())}async dispose(){super.dispose(),this.stop(),this.timer.dispose(),this.idleTimer.dispose()}};function WH(t){let e=$i(t.id),[r,o]=P([]);if(L(()=>{let a=new Vk(e);a.on("change",s=>o(s)),a.start();let i=()=>{document.hidden||document.visibilityState!=="visible"?a.stop():a.started||a.start()};return document.addEventListener("visibilitychange",i),()=>{a.dispose(),document.removeEventListener("visibilitychange",i)}},[e]),r.length===0)return null;function n(a){return a.disconnectedAt?a.disconnectedAt>a.lastViewedAt:!1}return f(ig,{className:"Viewers",limit:3,size:30,children:r.map(a=>{if(!a.photoURL){let i=a.email[0].toUpperCase();return f(kn,{alt:a.email,size:24,radius:"xl",children:i})}return f(kn,{className:ke("Viewers__viewer",n(a)&&"Viewers__viewer--disconnected"),src:a.photoURL,alt:a.email,size:24,radius:"xl"},a.email)})})}function KH(t){let r=t.field.checkboxLabel||"Enabled",[o,n]=P(!1);function a(i){n(i),t.draft.updateKey(t.deepKey,i)}return L(()=>t.draft.subscribe(t.deepKey,s=>{n(s)}),[]),f("div",{className:"DocEditor__BooleanField",children:f(Rc,{label:r,onChange:i=>{let s=i.currentTarget;a(s.checked)},checked:o,size:"xs"})})}function XH(t){let[e,r]=P("");function o(a){if(a){let i=Math.floor(new Date(a).getTime()),s=Ze.fromMillis(i);r(n(s)),t.draft.updateKey(t.deepKey,s)}else r(""),t.draft.removeKey(t.deepKey)}function n(a){let i=a.toDate();return i.setMinutes(i.getMinutes()-i.getTimezoneOffset()),i.toISOString().slice(0,16)}return L(()=>t.draft.subscribe(t.deepKey,i=>{r(i?n(i):"")}),[]),f("div",{className:"DocEditor__DateTimeField",children:[f("input",{type:"datetime-local",value:e,onChange:a=>{let s=a.target.value;o(s)}}),f("div",{className:"DocEditor__DateTimeField__timezone",children:["timezone: ",Intl.DateTimeFormat().resolvedOptions().timeZone]})]})}function QH(t){let e=t.field,[r,o]=P({}),[n,a]=P(!1),[i,s]=P(!1),l=H(null),c=H(null),u;e.exts&&(u=e.exts.join(","));async function d(){o({}),t.draft.removeKey(t.deepKey)}async function p(b){a(!0);try{let y=await Aa(b,{cacheControl:e.cacheControl,preserveFilename:e.preserveFilename});o(I=>{let w={...y};return I?.src&&YH(I.src)&&(w.alt=I?.alt||""),t.draft.updateKey(t.deepKey,w),w}),a(!1)}catch(y){console.error("file upload failed"),console.error(y),a(!1),pe({title:"File upload failed",message:"Failed to upload file: "+String(y),color:"red",autoClose:!1})}if(l.current){let y=l.current;y.value=""}}function m(b){let w=(b.target.files||[])[0];w&&p(w)}function h(b){o(y=>Object.assign({},y,{alt:b})),t.draft.updateKey(`${t.deepKey}.alt`,b)}let g=b=>{b.preventDefault(),s(!0)},_=b=>{b.preventDefault(),s(!1)},x=b=>{b.preventDefault(),s(!1);let I=(b.dataTransfer?.files||[])[0];I&&(console.log(`file dropped ("${t.deepKey}"):`,I),p(I))};return L(()=>{let b=t.draft.subscribe(t.deepKey,I=>{o(I)}),y=c.current;return document.addEventListener("dragenter",g),document.addEventListener("dragover",g),document.addEventListener("dragleave",_),document.addEventListener("drop",_),y&&y.addEventListener("drop",x),()=>{b(),document.removeEventListener("dragenter",g),document.removeEventListener("dragover",g),document.removeEventListener("dragleave",_),document.removeEventListener("drop",_),y&&y.removeEventListener("drop",x)}},[]),f("div",{className:ke("DocEditor__FileField",i&&"dragging"),ref:c,children:[r&&r.src&&f("div",{className:"DocEditor__FileField__controls",children:f(xe,{label:"Remove file",children:f(Fe,{className:"DocEditor__FileField__controls__trash",onClick:()=>d(),children:f(cn,{size:16})})})}),r&&r.src&&ZH(r.src)&&f(Qwe,{...r},r.src),r&&r.src&&JH(r.src)&&f(Zwe,{...r},r.src),r&&r.src?f(Ae,{children:[f("div",{className:"DocEditor__FileField__file",children:f(gt,{className:"DocEditor__FileField__file__url",size:"xs",radius:0,value:r.src,disabled:!0})}),YH(r.src)&&f(gt,{className:"DocEditor__FileField__file__alt",size:"xs",radius:0,value:r.alt||"",onChange:b=>{h(b.currentTarget.value)},label:"Alt text"})]}):f("div",{className:"DocEditor__FileField__noFile",children:"No file"}),f("label",{className:"DocEditor__FileField__uploadButton",role:"button","aria-disabled":n,children:[f("input",{type:"file",accept:u,onChange:m,ref:l}),f("div",{className:"DocEditor__FileField__uploadButton__icon",children:f(ti,{size:16})}),f("div",{className:"DocEditor__FileField__uploadButton__label",children:n?"Uploading...":"Upload file"})]})]})}function Qwe(t){return f("div",{className:"DocEditor__FileField__ImagePreview",children:[f("img",{src:t.src,width:t.width,height:t.height,loading:"lazy"}),t.width&&t.height&&f("div",{className:"DocEditor__FileField__ImagePreview__dimens",children:`${t.width}x${t.height}`})]})}function Zwe(t){let e={};return t.width&&t.height&&(e["--video-aspect-ratio"]=`${t.width} / ${t.height}`),f("div",{className:"DocEditor__FileField__VideoPreview",style:e,children:[f("video",{className:"DocEditor__FileField__VideoPreview__video",controls:!0,preload:"metadata",children:f("source",{src:t.src,type:`video/${am(t.src)}`})}),t.width&&t.height&&f("div",{className:"DocEditor__FileField__VideoPreview__dimens",children:`${t.width}x${t.height}`})]})}function ZH(t){if(!t)return!1;if(t.startsWith(cH))return!0;let e=am(t);return Dk.includes(e)}function JH(t){if(!t)return!1;let e=am(t);return Rk.includes(e)}function YH(t){return ZH(t)||JH(t)}var Jwe=["image/gif","image/jpeg","image/png","image/svg+xml","image/webp"];function e0e(t){return(t??Jwe).join(", ")}function e$(t){let e=t.field,[r,o]=P({}),[n,a]=P(!1),[i,s]=P(!1),l=H(null),c=H(null),u=e0e(e.exts);async function d(b){a(!0);try{let y=await Aa(b,{cacheControl:e.cacheControl});o(I=>{let w=Object.assign({},y,{alt:I?.alt||""});return t.draft.updateKey(t.deepKey,w),w}),a(!1)}catch(y){console.error("image upload failed"),console.error(y),a(!1),pe({title:"Image upload failed",message:"Failed to upload image: "+String(y),color:"red",autoClose:!1})}if(l.current){let y=l.current;y.value=""}}function p(b){let w=(b.target.files||[])[0];w&&d(w)}function m(b){o(y=>Object.assign({},y,{alt:b})),t.draft.updateKey(`${t.deepKey}.alt`,b)}function h(){o({}),t.draft.removeKey(t.deepKey)}let g=b=>{b.preventDefault(),s(!0)},_=b=>{b.preventDefault(),s(!1)},x=b=>{b.preventDefault(),s(!1);let I=(b.dataTransfer?.files||[])[0];I&&(console.log(`file dropped ("${t.deepKey}"):`,I),d(I))};return L(()=>{let b=t.draft.subscribe(t.deepKey,I=>{o(I)}),y=c.current;return document.addEventListener("dragenter",g),document.addEventListener("dragover",g),document.addEventListener("dragleave",_),document.addEventListener("drop",_),y&&y.addEventListener("drop",x),()=>{b(),document.removeEventListener("dragenter",g),document.removeEventListener("dragover",g),document.removeEventListener("dragleave",_),document.removeEventListener("drop",_),y&&y.removeEventListener("drop",x)}},[]),f("div",{className:ke("DocEditor__ImageField",i&&"dragging"),ref:c,children:[r&&r.src?f("div",{className:"DocEditor__ImageField__imagePreview",children:[f("div",{className:"DocEditor__ImageField__imagePreview__controls",children:f(xe,{label:"Remove image",children:f(Fe,{className:"DocEditor__ImageField__imagePreview__controls__trash",onClick:()=>h(),children:f(cn,{size:16})})})}),f("div",{className:"DocEditor__ImageField__imagePreview__image",children:[f("img",{src:r.gciUrl||r.src,width:r.width,height:r.height,loading:"lazy"}),f("div",{className:"DocEditor__ImageField__imagePreview__dimens",children:`${r.width}x${r.height}`})]}),f(gt,{className:"DocEditor__ImageField__imagePreview__image__url",size:"xs",radius:0,value:r.gciUrl||r.src,disabled:!0}),f(gt,{className:"DocEditor__ImageField__imagePreview__image__alt",size:"xs",radius:0,value:r.alt,label:"Alt text",onChange:b=>{m(b.currentTarget.value)}})]}):f("div",{className:"DocEditor__ImageField__noImage",children:"No image"}),f("label",{className:"DocEditor__ImageField__uploadButton",role:"button","aria-disabled":n,children:[f("input",{type:"file",accept:u,onChange:p,ref:l}),f("div",{className:"DocEditor__ImageField__uploadButton__icon",children:f(JS,{size:16})}),f("div",{className:"DocEditor__ImageField__uploadButton__label",children:n?"Uploading...":"Upload image"})]})]})}function t$(t){let e=t.field,[r,o]=P([]),n=(e.options||[]).map(i=>typeof i=="string"?{label:i,value:i}:{label:i.label??i.value??"",value:i.value??i.label??""});function a(i){t.draft.updateKey(t.deepKey,i||[]),o(i)}return L(()=>t.draft.subscribe(t.deepKey,s=>{o(s||[])}),[]),f("div",{className:"DocEditor__MultiSelectField",children:f(Og,{data:n,size:"xs",radius:0,placeholder:e.placeholder,value:r,searchable:!0,creatable:e.creatable||!1,getCreateLabel:i=>`+ Add "${i}"`,onChange:i=>a(i),dropdownComponent:"div"})})}function td(t){let e=t.field,[r,o]=P("");function n(l){if(l){let[c,u]=l.split("/");t.draft.updateKey(t.deepKey,{id:l,collection:c,slug:u})}else t.draft.removeKey(t.deepKey);o(l)}L(()=>t.draft.subscribe(t.deepKey,c=>{o(c?.id||"")}),[]);let a=Pz();function i(){let l=r?r.split("/")[0]:e.initialCollection;a.open({collections:e.collections,initialCollection:l,onChange:c=>{n(c),a.close()}})}function s(){n("")}return f("div",{className:"ReferenceField",children:[r?f("div",{className:"ReferenceField__ref",children:[f(td.Preview,{id:r}),f("div",{className:"ReferenceField__remove",children:f(xe,{label:"Remove",children:f(Fe,{className:"ReferenceField__remove__icon",onClick:()=>s(),children:f(cn,{size:16})})})})]}):f("div",{className:"ReferenceField__none",children:"None selected"}),f(X,{color:"dark",size:"xs",onClick:()=>i(),children:e.buttonLabel||"Select"})]})}td.Preview=t=>{let[e,r]=P(!0),[o,n]=P(null);async function a(){r(!0),await bt(async()=>{let i=await cb(t.id);n(i)}),r(!1)}return L(()=>{a()},[t.id]),f("div",{className:"ReferenceField__Preview",children:e?f("div",{className:"ReferenceField__Preview__loading",children:f(Re,{color:"gray",size:"sm"})}):o?f(td.DocCard,{doc:o}):f("div",{className:"ReferenceField__Preview__notfound",children:['Doc Not found: "',t.id,'" (was it deleted?). Select a new doc or remove using the trash icon to the right.']})})};td.DocCard=t=>{let e=t.doc,r=e.id||e.sys?.id||"";if(!r)return f("div",{className:"ReferenceField__DocCard ReferenceField__DocCard--error",children:JSON.stringify(e)});let o=r.split("/")[0],n=e.fields||{},a=window.__ROOT_CTX.collections[o];if(!a)throw new Error(`could not find collection: ${o}`);let i=oo(n,a.preview?.title||"meta.title"),s=oo(n,a.preview?.image||"meta.image")||a.preview?.defaultImage;return f("a",{className:"ReferenceField__DocCard",href:`/cms/content/${r}`,target:"_blank",children:[f("div",{className:"ReferenceField__DocCard__image",children:f(Tn,{src:s?.src,width:80,height:60,withPlaceholder:!s?.src})}),f("div",{className:"ReferenceField__DocCard__content",children:[f("div",{className:"ReferenceField__DocCard__content__header",children:f("div",{className:"ReferenceField__DocCard__content__header__docId",children:r})}),f("div",{className:"ReferenceField__DocCard__content__title",children:i||"[UNTITLED]"})]})]})};(function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode(".ce-hint--align-start{text-align:left}.ce-hint--align-center{text-align:center}.ce-hint__description{opacity:.6;margin-top:3px}")),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var hm=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Wy(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function t0e(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var r=function o(){return this instanceof o?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(o){var n=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(r,o,n.get?n:{enumerable:!0,get:function(){return t[o]}})}),r}function Hk(){}Object.assign(Hk,{default:Hk,register:Hk,revert:function(){},__esModule:!0});Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(t){let e=(this.document||this.ownerDocument).querySelectorAll(t),r=e.length;for(;--r>=0&&e.item(r)!==this;);return r>-1});Element.prototype.closest||(Element.prototype.closest=function(t){let e=this;if(!document.documentElement.contains(e))return null;do{if(e.matches(t))return e;e=e.parentElement||e.parentNode}while(e!==null);return null});Element.prototype.prepend||(Element.prototype.prepend=function(t){let e=document.createDocumentFragment();Array.isArray(t)||(t=[t]),t.forEach(r=>{let o=r instanceof Node;e.appendChild(o?r:document.createTextNode(r))}),this.insertBefore(e,this.firstChild)});Element.prototype.scrollIntoViewIfNeeded||(Element.prototype.scrollIntoViewIfNeeded=function(t){t=arguments.length===0?!0:!!t;let e=this.parentNode,r=window.getComputedStyle(e,null),o=parseInt(r.getPropertyValue("border-top-width")),n=parseInt(r.getPropertyValue("border-left-width")),a=this.offsetTop-e.offsetTop<e.scrollTop,i=this.offsetTop-e.offsetTop+this.clientHeight-o>e.scrollTop+e.clientHeight,s=this.offsetLeft-e.offsetLeft<e.scrollLeft,l=this.offsetLeft-e.offsetLeft+this.clientWidth-n>e.scrollLeft+e.clientWidth,c=a&&!i;(a||i)&&t&&(e.scrollTop=this.offsetTop-e.offsetTop-e.clientHeight/2-o+this.clientHeight/2),(s||l)&&t&&(e.scrollLeft=this.offsetLeft-e.offsetLeft-e.clientWidth/2-n+this.clientWidth/2),(a||i||s||l)&&!t&&this.scrollIntoView(c)});window.requestIdleCallback=window.requestIdleCallback||function(t){let e=Date.now();return setTimeout(function(){t({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-e))}})},1)};window.cancelIdleCallback=window.cancelIdleCallback||function(t){clearTimeout(t)};var r0e=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,r)=>(r&=63,r<36?e+=r.toString(36):r<62?e+=(r-26).toString(36).toUpperCase():r>62?e+="-":e+="_",e),""),h$=(t=>(t.VERBOSE="VERBOSE",t.INFO="INFO",t.WARN="WARN",t.ERROR="ERROR",t))(h$||{}),He={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,LEFT:37,UP:38,DOWN:40,RIGHT:39,DELETE:46,META:91,SLASH:191},o0e={LEFT:0,WHEEL:1,RIGHT:2,BACKWARD:3,FORWARD:4};function wm(t,e,r="log",o,n="color: inherit"){if(!("console"in window)||!window.console[r])return;let a=["info","log","warn","error"].includes(r),i=[];switch(wm.logLevel){case"ERROR":if(r!=="error")return;break;case"WARN":if(!["error","warn"].includes(r))return;break;case"INFO":if(!a||t)return;break}o&&i.push(o);let s="Editor.js 2.31.0-rc.7",l=`line-height: 1em;
|
|
143
|
+
Please report this to https://github.com/markedjs/marked.`,e){let n="<p>An error occurred:</p><pre>"+dn(o.message+"",!0)+"</pre>";return r?Promise.resolve(n):n}if(r)return Promise.reject(o);throw o}}},Bl=new Mk;function yt(t,e){return Bl.parse(t,e)}yt.options=yt.setOptions=function(t){return Bl.setOptions(t),yt.defaults=Bl.defaults,wH(yt.defaults),yt};yt.getDefaults=Lk;yt.defaults=Fl;yt.use=function(...t){return Bl.use(...t),yt.defaults=Bl.defaults,wH(yt.defaults),yt};yt.walkTokens=function(t,e){return Bl.walkTokens(t,e)};yt.parseInline=Bl.parseInline;yt.Parser=si;yt.parser=si.parse;yt.Renderer=Yu;yt.TextRenderer=im;yt.Lexer=ii;yt.lexer=ii.lex;yt.Tokenizer=Xu;yt.Hooks=Ku;yt.parse=yt;var trt=yt.options,rrt=yt.setOptions,ort=yt.use,nrt=yt.walkTokens,art=yt.parseInline;var irt=si.parse,srt=ii.lex;function CH(t){let e=t.code||"",r=t.inline?yt.parseInline(e):yt.parse(e);return f("div",{className:ke("Markdown",t.className),dangerouslySetInnerHTML:{__html:r}})}function by(t){let[e,r]=P(!0),[o,n]=P(null),a=Ht(async()=>{try{let i=await Au(t);n(i)}catch(i){console.error(i),pe({title:`Failed to load collection: ${t}`,message:String(i),color:"red",autoClose:!1})}r(!1)},[t]);return L(()=>{a()},[t]),{loading:e,schema:o}}function kH(t){let e={_array:[]};return t.forEach(r=>{let o=Uwe();e._array.push(o),e[o]=r}),e}function Uwe(){let t=[],e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=e.length;for(let o=0;o<6;o++)t.push(e.charAt(Math.floor(Math.random()*r)));return t.join("")}function sm(t){let e={};return t.fields.forEach(r=>{r.id&&(r.type==="array"&&r.default&&Array.isArray(r.default)?e[r.id]=kH(r.default):r.default?e[r.id]=r.default:r.type==="object"&&(e[r.id]=sm(r)))}),e}function TH(t){let[e,r]=P(""),[o,n]=P(!1),[a,i]=P(""),s=Lt(),l=t.collection,c=window.__ROOT_CTX.collections[l];if(!c)throw new Error(`collection not found: ${l}`);let u=by(l);function d(){t.onClose&&t.onClose()}async function p(m){m.preventDefault(),n(!0),i("");let h=$i(e),g=c.slugRegex;if(!Ca(h,g)){i('Please enter a valid slug (e.g. "foo-bar-123").'),n(!1);return}let _=`${l}/${h}`;try{let x={};!u.loading&&u.schema&&(x=await sm(u.schema)),await kS(_,{fields:x})}catch(x){i(String(x)),n(!1);return}n(!1),ur(`/cms/content/${t.collection}/${h}?new=true`)}return f(Lc,{className:"NewDocModal",opened:t.opened||!1,onClose:()=>d(),title:"New",size:"500px",overlayColor:s.colorScheme==="dark"?s.colors.dark[9]:s.colors.gray[2],children:[f("div",{className:"NewDocModal__body",children:"Enter a slug for the new doc. The slug is the ID of the page and is what's used in the URL. Use only lowercase letters, numbers, and dashes."}),f("form",{onSubmit:m=>p(m),children:[f(hb,{className:"NewDocModal__slug",collectionId:l,onChange:m=>{r(m.slug)}}),a&&f("div",{className:"NewDocModal__slugError",children:a}),f("div",{className:"NewDocModal__buttons",children:[f(X,{variant:"outline",onClick:()=>d(),type:"button",size:"xs",color:"dark",children:"Cancel"}),f(X,{variant:"filled",type:"submit",size:"xs",color:"dark",loading:u.loading||o,children:"Submit"})]})]})]})}function Qu(t,e){let[r,o]=P(()=>{try{let a=window.localStorage.getItem(t);return a?JSON.parse(a):e}catch(a){return console.error(a),e}});return[r,a=>{typeof a=="function"&&(a=a(r)),window.localStorage.setItem(t,JSON.stringify(a)),o(a)}]}function li(t){let{className:e,localStorageId:r,children:o}=t,[n,a]=Qu(`root::SplitPanel:${r}`,350),[i,s]=P(!1),[l,c]=P(0),u=H(null),d=H(null);if(L(()=>{let m=()=>s(!1);window.addEventListener("mouseup",m);let h=u.current;return h&&c(h.getBoundingClientRect().left),()=>window.removeEventListener("mouseup",m)},[]),L(()=>{let m=h=>{let g=h.clientX-l;a(g)};return i&&window.addEventListener("mousemove",m),()=>window.removeEventListener("mousemove",m)},[i]),o?.length!==2)throw new Error("SplitPanel should have two <SplitPanel.Item> children.");let p={"--panel-size":`${n}px`};return f("div",{className:ke(e,"SplitPanel",i&&"dragging"),ref:u,style:p,children:[o[0],f("div",{className:"SplitPanel__divider",ref:d,onMouseDown:()=>s(!0)}),o[1]]})}li.Item=t=>f("div",{className:ke("SplitPanel__item",t.className,t.fluid?"fluid":"static"),children:t.children});function Zu(t){let[e,r]=P("");L(()=>{let a=window.__ROOT_CTX.rootConfig.projectId,i=window.__ROOT_CTX.collections,s=`root-cms::${a}::last_collection`;if(t.collection)window.localStorage.setItem(s,t.collection);else{let l=window.localStorage.getItem(s);if(l&&i[l]){ur(`/cms/content/${l}`);return}if(window.__ROOT_CTX.collections.Pages){ur("/cms/content/Pages");return}let c=Object.keys(window.__ROOT_CTX.collections)||[];if(c.length>0){let u=c[0];ur(`/cms/content/${u}`);return}console.warn("no collections")}},[t.collection]);let n=Object.keys(window.__ROOT_CTX.collections).filter(a=>e?a.toLowerCase().includes(e.toLowerCase()):!0).map(a=>({...window.__ROOT_CTX.collections[a],id:a}));return f(me,{children:f(li,{className:"CollectionPage",localStorageId:"CollectionPage",children:[f(li.Item,{className:"CollectionPage__side",children:[f("div",{className:"CollectionPage__side__title",children:"Content"}),f("div",{className:"CollectionPage__side__search",children:f("input",{type:"text",placeholder:"Search",onChange:a=>r(a.target.value)})}),f("div",{className:"CollectionPage__side__collections",children:[n.map(a=>f("a",{className:ke("CollectionPage__side__collection",a.id===t.collection&&"active"),href:`/cms/content/${a.id}`,children:[f("div",{className:"CollectionPage__side__collection__icon",children:f(yl,{size:20,strokeWidth:"1.75"})}),f("div",{className:"CollectionPage__side__collection__name",children:a.name||a.id}),a.description&&f("div",{className:"CollectionPage__side__collection__desc",children:a.description})]},a.id)),n.length===0&&f("div",{className:"CollectionPage__side__collections__empty",children:"No collections match your query."})]})]}),f(li.Item,{className:"CollectionPage__main",fluid:!0,children:t.collection?f(Zu.Collection,{collection:t.collection},t.collection):f("div",{className:"CollectionPage__main__unselected",children:[f(zS,{size:24,strokeWidth:1.75}),f("div",{className:"CollectionPage__main__unselected__title",children:"Select a collection to get started."})]})})]})})}Zu.Collection=t=>{let[e,r]=Qu(`root::CollectionPage:${t.collection}:orderBy`,"modifiedAt"),[o,n]=P(!1),a=window.__ROOT_CTX.collections[t.collection];if(!a)return ur("/cms/content"),f(Ae,{});let[i,s,l]=Su(t.collection,{orderBy:e});return f(Ae,{children:[f(TH,{collection:t.collection,opened:o,onClose:()=>n(!1)}),f("div",{className:"CollectionPage__collection",children:[f("div",{className:"CollectionPage__collection__header",children:[f("div",{className:"CollectionPage__collection__header__title",children:a.name}),a.description&&f(CH,{className:"CollectionPage__collection__header__description",code:a.description})]}),f(zc,{className:"CollectionPage__collection__tabs",active:1,children:f(zc.Tab,{label:"Docs",children:f("div",{className:"CollectionPage__collection__docsTab",children:[!i&&l.length>0&&f("div",{className:"CollectionPage__collection__docsTab__header",children:[f(Te,{className:"CollectionPage__collection__docsTab__header__title",children:a.name||t.collection}),f("div",{className:"CollectionPage__collection__docsTab__controls",children:[f("div",{className:"CollectionPage__collection__docsTab__controls__sort",children:[f("div",{className:"CollectionPage__collection__docsTab__controls__sort__label",children:"Sort:"}),f(Pt,{size:"xs",value:e,onChange:c=>r(c||"modifiedAt"),data:[{value:"slug",label:"A-Z"},{value:"newest",label:"Newest"},{value:"oldest",label:"Oldest"},{value:"modifiedAt",label:"Last modified"}]})]}),f("div",{className:"CollectionPage__collection__docsTab__controls__newDoc",children:f(X,{color:"dark",size:"xs",leftIcon:f(ku,{size:16}),onClick:()=>n(!0),children:"New"})})]})]}),f("div",{className:"CollectionPage__collection__docsTab__content",children:i?f("div",{className:"CollectionPage__collection__docsTab__content__loading",children:f(Re,{color:"gray",size:"xl"})}):l.length===0?f("div",{class:"CollectionPage__collection__docsEmpty",children:[f("div",{class:"CollectionPage__collection__docsEmpty__icon",children:f(Vwe,{})}),f("div",{class:"CollectionPage__collection__docsEmpty__title",children:"Collection is empty."}),f("div",{class:"CollectionPage__collection__docsEmpty__button",children:f(X,{color:"dark",size:"xs",leftIcon:f(ku,{size:16}),onClick:()=>n(!0),children:"New"})})]}):f(Zu.DocsList,{collection:t.collection,docs:l,reloadDocs:()=>s()})})]})})})]})]})};Zu.DocsList=t=>{let e=t.collection,r=window.__ROOT_CTX.collections[t.collection];if(!r)throw new Error(`could not find collection: ${e}`);let o=t.docs||[];function n(a){return Jn({collectionId:e,slug:a})}return f("div",{className:"CollectionPage__collection__docsList",children:o.map(a=>{let i=`/cms/content/${e}/${a.slug}`,s=n(a.slug),l=a.fields||{},c=oo(l,r.preview?.title||"meta.title"),u=oo(l,r.preview?.image||"meta.image")||r.preview?.defaultImage;return f("div",{className:"CollectionPage__collection__docsList__doc",children:[f("div",{className:"CollectionPage__collection__docsList__doc__image",children:f("a",{href:i,children:f(Tn,{src:u?.src,width:120,height:90,withPlaceholder:!u?.src})})}),f("a",{className:"CollectionPage__collection__docsList__doc__content",href:i,children:[f("div",{className:"CollectionPage__collection__docsList__doc__content__header",children:[f("div",{className:"CollectionPage__collection__docsList__doc__content__header__docId",children:a.id}),f(Wu,{doc:a})]}),f("div",{className:"CollectionPage__collection__docsList__doc__content__title",children:c||"[UNTITLED]"}),f("div",{className:"CollectionPage__collection__docsList__doc__content__url",children:s})]}),f("div",{className:"CollectionPage__collection__docsList__doc__controls",children:f(_y,{docId:a.id,data:a,onAction:d=>{(d.action==="delete"||d.action==="unpublish")&&t.reloadDocs()}})})]},a.id)})})};function Vwe(){return f("svg",{width:"165",height:"142",viewBox:"0 0 165 142",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[f("path",{d:"M85.3227 123.613C119.114 123.613 146.509 96.2184 146.509 62.3067C146.509 28.3949 118.993 1 85.3227 1C51.5316 1 24.1367 28.3949 24.1367 62.3067C24.1367 96.2184 51.5316 123.613 85.3227 123.613Z",fill:"#f5f5f5",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10"}),f("path",{d:"M154.276 42.8823C157.009 42.8823 159.224 40.667 159.224 37.9343C159.224 35.2016 157.009 32.9863 154.276 32.9863C151.543 32.9863 149.328 35.2016 149.328 37.9343C149.328 40.667 151.543 42.8823 154.276 42.8823Z",fill:"#f5f5f5"}),f("path",{d:"M161.516 23.5733C163.383 23.5733 164.895 22.0604 164.895 20.1942C164.895 18.3279 163.383 16.8151 161.516 16.8151C159.65 16.8151 158.137 18.3279 158.137 20.1942C158.137 22.0604 159.65 23.5733 161.516 23.5733Z",fill:"#f5f5f5"}),f("path",{d:"M26.9123 22.1192C28.7785 22.1192 30.2914 20.6064 30.2914 18.7401C30.2914 16.8739 28.7785 15.361 26.9123 15.361C25.0461 15.361 23.5332 16.8739 23.5332 18.7401C23.5332 20.6064 25.0461 22.1192 26.9123 22.1192Z",fill:"#f5f5f5"}),f("path",{d:"M6.27549 87.288C9.74134 87.288 12.551 84.4784 12.551 81.0126C12.551 77.5467 9.74134 74.7371 6.27549 74.7371C2.80963 74.7371 0 77.5467 0 81.0126C0 84.4784 2.80963 87.288 6.27549 87.288Z",fill:"#f5f5f5"}),f("path",{d:"M121.099 107.854H138.619C140.82 107.854 142.706 105.969 142.706 103.769V22.0726C142.706 19.873 140.82 17.9877 138.619 17.9877H121.643",fill:"#f5f5f5",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10"}),f("path",{d:"M51.5361 107.854H34.5596C32.3589 107.854 30.4727 105.969 30.4727 103.769V22.0726C30.4727 19.873 32.3589 17.9877 34.5596 17.9877H51.1864",fill:"#f5f5f5",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10"}),f("path",{d:"M42.2832 34.327H50.7714",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10","stroke-linecap":"round"}),f("path",{d:"M42.2832 45.3246H50.7714",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10","stroke-linecap":"round"}),f("path",{d:"M42.2832 56.6365H50.7714",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10","stroke-linecap":"round"}),f("path",{d:"M42.2832 67.9485H50.7714",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10","stroke-linecap":"round"}),f("path",{d:"M42.2832 89.9436H50.7714",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10","stroke-linecap":"round"}),f("path",{d:"M129.816 34.327H121.643",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10"}),f("path",{d:"M129.816 45.3246H121.643",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10","stroke-linecap":"round"}),f("path",{d:"M129.816 56.6365H121.643",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10","stroke-linecap":"round"}),f("path",{d:"M129.816 67.9485H121.643",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10","stroke-linecap":"round"}),f("path",{d:"M129.816 89.9436H121.643",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10","stroke-linecap":"round"}),f("path",{d:"M117.556 114.767H55.3086C53.108 114.767 51.2217 112.881 51.2217 110.682V15.7883C51.2217 13.5888 53.108 11.7035 55.3086 11.7035H117.556C119.756 11.7035 121.643 13.5888 121.643 15.7883V110.682C121.643 112.881 119.756 114.767 117.556 114.767Z",fill:"white",stroke:"#e5e5e5","stroke-width":"2","stroke-miterlimit":"10"}),f("path",{d:"M110.01 42.4468H66.6261C65.683 42.4468 65.0542 41.8773 65.0542 41.0231V37.3217C65.0542 36.4675 65.683 35.898 66.6261 35.898H110.01C110.954 35.898 111.582 36.4675 111.582 37.3217V41.0231C111.582 41.5926 110.954 42.4468 110.01 42.4468Z",fill:"#f5f5f5",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10"}),f("path",{d:"M110.01 59.4146H66.6261C65.683 59.4146 65.0542 58.8451 65.0542 57.9909V54.2894C65.0542 53.4352 65.683 52.8658 66.6261 52.8658H110.01C110.954 52.8658 111.582 53.4352 111.582 54.2894V57.9909C111.582 58.8451 110.954 59.4146 110.01 59.4146Z",fill:"#f5f5f5",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10"}),f("path",{d:"M110.01 76.6964H66.6261C65.683 76.6964 65.0542 76.127 65.0542 75.2728V71.5713C65.0542 70.7171 65.683 70.1476 66.6261 70.1476H110.01C110.954 70.1476 111.582 70.7171 111.582 71.5713V75.2728C111.582 76.127 110.954 76.6964 110.01 76.6964Z",fill:"#f5f5f5",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10"}),f("path",{d:"M110.011 94.2926H92.7198C91.7767 94.2926 91.1479 93.7231 91.1479 92.8689V89.1674C91.1479 88.3132 91.7767 87.7438 92.7198 87.7438H110.011C110.954 87.7438 111.583 88.3132 111.583 89.1674V92.8689C111.583 93.7231 110.954 94.2926 110.011 94.2926Z",fill:"#f5f5f5",stroke:"#d4d4d4","stroke-width":"2","stroke-miterlimit":"10"}),f("path",{d:"M105.548 125.569C105.155 127.237 104.566 129.003 103.879 130.475C102.015 134.106 99.0712 136.952 95.4405 138.816C91.7116 140.681 87.2959 141.466 82.8801 140.484C72.4786 138.326 65.8059 128.12 67.9647 117.719C70.1235 107.317 80.2307 100.546 90.6322 102.803C94.3611 103.588 97.5993 105.453 100.347 108.004C104.959 112.616 106.921 119.289 105.548 125.569Z",fill:"#d4d4d4",stroke:"#a3a3a3","stroke-width":"2","stroke-miterlimit":"10"}),f("path",{d:"M92.8892 118.976H89.4735V115.56C89.4735 114.163 88.377 112.892 86.8053 112.892C85.4087 112.892 84.1371 113.988 84.1371 115.56V118.976H80.7214C79.3248 118.976 78.0532 120.072 78.0532 121.644C78.0532 122.374 78.3129 123.054 78.8122 123.553C79.3116 124.052 79.9912 124.312 80.7214 124.312H84.1371V127.728C84.1371 129.124 85.2337 130.396 86.8053 130.396C88.2019 130.396 89.4735 129.299 89.4735 127.728V124.312H92.8892C94.2858 124.312 95.5574 123.215 95.5574 121.644C95.5574 120.072 94.2858 118.976 92.8892 118.976Z",fill:"white",stroke:"#a3a3a3","stroke-width":"2"})]})}function OH(){let[t,e]=P(!0),[r,o]=P(null),[n,a]=P(null);return L(()=>{let i=new URLSearchParams(window.location.search),s=PH(i.get("left")||""),l=PH(i.get("right")||"");o(s),a(l),e(!1)},[]),f(me,{children:f("div",{className:"ComparePage",children:t?f(Re,{}):r&&n?f(Vb,{className:"ComparePage__diff",left:r,right:n}):f("div",{className:"ComparePage__error",children:"Invalid params, double check query params."})})})}function PH(t){let[e,r]=String(t).split("@");return e&&r?{docId:e,versionId:r}:null}async function AH(t,e){if(!t)throw new Error("missing data source id");let r=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,n=we(o,"Projects",r,"DataSources",t);await vu(n,{...e,id:t,createdAt:Ut(),createdBy:window.firebase.user.email}),Je("datasource.create",{metadata:{datasourceId:t}})}async function DH(){let t=window.__ROOT_CTX.rootConfig.projectId,e=window.firebase.db,r=nn(e,"Projects",t,"DataSources"),o=to(r),n=await an(o),a=[];return n.forEach(i=>{a.push(i.data())}),a}async function Ju(t){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,o=we(r,"Projects",e,"DataSources",t),n=await vr(o);return n.exists()?n.data():null}async function Bk(t,e){let r=e?.mode||"draft",o=window.__ROOT_CTX.rootConfig.projectId,n=window.firebase.db,a=we(n,"Projects",o,"DataSources",t,"Data",r),i=await vr(a);return i.exists()?i.data():null}async function RH(t,e){let r=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,n=we(o,"Projects",r,"DataSources",t);await rr(n,e),Je("datasource.save",{metadata:{datasourceId:t}})}async function NH(t){let e=await Ju(t);if(!e)throw new Error(`data source not found: ${t}`);if(e.type==="http"&&e.url&&!BH(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 Hwe(e),n=window.__ROOT_CTX.rootConfig.projectId,a=window.firebase.db,i=we(a,"Projects",n,"DataSources",t),s=we(a,"Projects",n,"DataSources",t,"Data","draft"),l={...e,syncedAt:Ze.now(),syncedBy:window.firebase.user.email},c=sn(a);c.set(s,{dataSource:l,data:r,...o?{headers:o}:{}}),c.update(i,{syncedAt:Ze.now(),syncedBy:window.firebase.user.email}),await c.commit()}console.log(`synced data source: ${t}`),Je("datasource.sync",{metadata:{datasourceId:t}})}async function MH(t){let e=await Ju(t);if(!e)throw new Error(`data source not found: ${t}`);let r=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,n=we(o,"Projects",r,"DataSources",t),a=we(o,"Projects",r,"DataSources",t,"Data","draft"),i=we(o,"Projects",r,"DataSources",t,"Data","published"),s=await Bk(t,{mode:"draft"}),l={...e,publishedAt:Ze.now(),publishedBy:window.firebase.user.email},c=sn(o);c.set(i,{dataSource:l,data:s?.data||null,...s?.headers?{headers:s.headers}:{}}),c.update(a,{dataSource:l}),c.update(n,{publishedAt:Ze.now(),publishedBy:window.firebase.user.email}),await c.commit(),console.log(`published data ${t}`),Je("datasource.publish",{metadata:{datasourceId:t}})}async function LH(t){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,o=we(r,"Projects",e,"DataSources",t),n=we(r,"Projects",e,"DataSources",t,"Data","draft"),a=we(r,"Projects",e,"DataSources",t,"Data","published"),i=sn(r);i.delete(n),i.delete(a),i.delete(o),await i.commit(),console.log(`deleted data source ${t}`),Je("datasource.delete",{metadata:{datasourceId:t}})}async function Hwe(t){if(t.type==="http")return{data:await jwe(t)};if(t.type==="gsheet")return await $we(t);throw new Error(`unsupported data source: ${t.type}`)}async function $we(t){let e=Ki(t.url);if(!e?.spreadsheetId)throw new Error(`failed to parse google sheet url: ${t.url}`);let o=await new ka(e.spreadsheetId).getSheet(e.gid??0);if(!o)throw new Error(`could not find sheet: ${t.url}`);let n=t.dataFormat||"map",[a,i]=await o.getValues();return n==="array"?{data:[a,i],headers:a}:{data:i.map(l=>{let c={};return l.forEach((u,d)=>{let p=a[d];p&&(c[p]=String(u||""))}),c}),headers:a}}async function jwe(t){if(!BH(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 BH(t){return t&&t.startsWith("/")}function FH(t){let e=Gwe(t.timestamp),[r,o]=P(t.timestamp?Rn(e,{style:"short"}):"never");return e?(L(()=>{let n=window.setInterval(()=>{o(Rn(e,{style:"short"}))},6e4);return()=>window.clearInterval(n)},[]),f(xe,{transition:"pop",label:`${qwe(e)} by ${t.email}`,children:Rn(e,{style:"short"})})):f("div",{children:r})}function qwe(t){return new Date(t).toLocaleDateString("en",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Gwe(t){return typeof t=="number"?t:t?t.toMillis():0}function ed(t){let e=t.dataSource,[r,o]=P(!1),[n,a]=P(t.action==="sync"?e.syncedAt:e.publishedAt),[i,s]=P(t.action==="sync"?e.syncedBy:e.publishedBy),l=Xi();async function c(){o(!0);let d=`data-source-${t.action}-${e.id}`;pe({id:d,loading:!0,title:`Running Data Source ${t.action}`,message:`Updating ${e.id}...`,autoClose:!1,disallowClose:!0});try{t.action==="sync"?(e.type==="gsheet"&&!l.isLoggedIn()&&await l.login(),await NH(e.id)):t.action==="publish"&&await MH(e.id),a(Ze.now()),s(window.firebase.user.email),o(!1),t.onAction&&t.onAction(),at({id:d,title:"Success",message:`Updated Data Source ${e.id}`,autoClose:!1})}catch(p){console.error(p);let m=p;typeof p=="object"&&p.body&&(m=String(p.body)),o(!1),at({id:d,title:`Data Source ${t.action} failed`,message:String(m),color:"red",autoClose:!1})}}let u="";return t.action==="sync"?u="Sync data to a draft state":t.action==="publish"&&(u="Publish synced data to prod"),f("div",{className:"DataSourceStatusButton",children:[f("div",{className:"DataSourceStatusButton__label",children:!r&&f(FH,{timestamp:n,email:i})}),f("div",{className:"DataSourceStatusButton__button",children:f(xe,{transition:"pop",label:u,children:f(X,{variant:"default",size:"xs",compact:!0,onClick:()=>c(),loading:r,children:t.action})})})]})}function yy(){return f(me,{children:f("div",{className:"DataPage",children:[f("div",{className:"DataPage__header",children:[f(Te,{size:"h1",children:"Data Sources"}),f(Me,{as:"p",children:"Add data sources to sync data from external services, like Google Sheets."}),f("div",{className:"DataPage__header__buttons",children:f(X,{component:"a",color:"blue",size:"xs",href:"/cms/data/new",children:"New data source"})})]}),f(yy.DataSourcesTable,{})]})})}yy.DataSourcesTable=()=>{let[t,e]=P(!0),[r,o]=P([]);async function n(){let a=await DH();o(a),e(!1)}return L(()=>{n()},[]),f("div",{className:"DataPage__DataSourcesTable",children:[t&&f(Re,{color:"gray",size:"xl"}),r.length>0&&f(kr,{verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[f("thead",{children:f("tr",{children:[f("th",{children:"id"}),f("th",{children:"description"}),f("th",{children:"type"}),f("th",{children:"url"}),f("th",{children:"last synced"}),f("th",{children:"last published"})]})}),f("tbody",{children:r.map(a=>f("tr",{children:[f("td",{children:f("a",{href:`/cms/data/${a.id}`,children:a.id})}),f("td",{children:a.description||""}),f("td",{children:a.type}),f("td",{children:a.url}),f("td",{children:f(ed,{dataSource:a,action:"sync"})}),f("td",{children:f(ed,{dataSource:a,action:"publish"})})]},a.id))})]})]})};function fn(t){let[e,r]=P(!0),[o,n]=P(null),[a,i]=P(null),s=t.id;async function l(){let u=await Ju(s);if(n(u),u){let d=await Bk(s,{mode:"draft"});i(d)}r(!1)}L(()=>{l()},[]);function c(u){u==="sync"&&l()}return f(me,{children:f("div",{className:"DataSourcePage",children:[f("div",{className:"DataSourcePage__header",children:[f(_r,{className:"DataSourcePage__header__breadcrumbs",children:[f("a",{href:"/cms/data",children:"Data"}),f("div",{children:s})]}),f("div",{className:"DataSourcePage__header__titleWrap",children:[f(Te,{size:"h1",children:["Data Source: ",s]}),f("div",{className:"DataSourcePage__header__controls",children:f(xe,{label:"Configure",children:f(Fe,{component:"a",href:`/cms/data/${t.id}/edit`,children:f(wl,{size:24,stroke:"1.5"})})})})]}),o?.description&&f(Me,{as:"p",children:o.description})]}),o&&f(fn.SyncStatus,{dataSource:o,onAction:c}),e?f(Re,{color:"gray",size:"xl"}):o?f(fn.DataSection,{dataSource:o,data:a}):f("div",{className:"DataSourcePage__notFound",children:"Not Found"})]})})}fn.SyncStatus=t=>{let e=t.dataSource;return f("div",{className:"DataSourcePage__SyncStatus",children:[f(Te,{size:"h2",children:"Status"}),f(kr,{verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[f("thead",{children:f("tr",{children:[f("th",{children:"last synced"}),f("th",{children:"last published"})]})}),f("tbody",{children:f("tr",{children:[f("td",{children:f(ed,{dataSource:e,action:"sync",onAction:()=>{t.onAction&&t.onAction("sync")}})}),f("td",{children:f(ed,{dataSource:e,action:"publish"})})]})})]})]})};fn.DataSection=t=>{let{data:e,headers:r}=t.data||{},o=t.dataSource;if(!e)return null;let n=o.dataFormat||"map";if(o.type==="gsheet"){let a=r,i=[];if(n==="array")i=e;else if(n==="map"){let s=e;if(!a){let l=new Set;s.forEach(c=>{for(let u in c)u&&l.add(u)}),a=Array.from(l)}s.forEach(l=>{i.push(a.map(c=>l[c]||""))})}return f(fn.DataSectionWrap,{dataSource:o,children:f(fn.DataTable,{headers:a,rows:i})})}return o.type==="http"?f(fn.DataSectionWrap,{dataSource:o,children:f(fn.DefaultDataDisplay,{data:e})}):(console.log(`unsupported data type: ${o.type}`),null)};fn.DataSectionWrap=t=>f("div",{className:"DataSourcePage__DataSection",children:[f("div",{className:"DataSourcePage__DataSection__header",children:[f(Te,{size:"h2",children:"Data"}),f("div",{className:"DataSourcePage__DataSection__header__actions",children:[t.dataSource.url?.startsWith("https://docs.google.com/spreadsheets/")&&f(xe,{label:"Open spreadsheet",children:f(Fe,{component:"a",href:t.dataSource.url,target:"_blank",variant:"filled",color:"green",children:f(El,{size:16,stroke:"2.25"})})}),t.dataSource.previewUrl&&f(X,{component:"a",variant:"default",size:"xs",href:t.dataSource.previewUrl,target:"_blank",children:"Preview"})]})]}),t.children]});fn.DataTable=t=>{let e=t.headers||[],r=t.rows||[];return f("div",{className:"DataSourcePage__DataTable",children:f(kr,{className:"DataSourcePage__DataTable__table",verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[e.length>0&&f("thead",{children:f("tr",{children:e.map(o=>f("th",{children:o},o))})}),f("tbody",{children:r.map((o,n)=>f("tr",{children:o.map((a,i)=>f("td",{children:a},i))},n))})]})})};fn.DefaultDataDisplay=t=>{let e=t.data;return typeof e=="object"?f(Mc,{value:JSON.stringify(e,null,2),minRows:20,maxRows:100}):f(Zt,{value:String(e),minRows:12,maxRows:100})};function os(t){let[e,r]=P(!0),[o,n]=P(!1),[a,i]=P([]),[s,l]=P({}),[c,u]=P(null),[d,p]=P(!1),[m,h]=P({}),[g,_]=P(!1),x=t.collection,b=t.slug,y=`${x}/${b}`,w=(window.__ROOT_CTX.rootConfig.i18n||{}).locales||["en"];async function v(){try{let[S,C,F]=await Promise.all([Eb(y),ji(),mb(y)]);i(S),l(C),u(F),r(!1)}catch(S){console.error(S),r(!1),n(!0)}}if(L(()=>{v()},[]),o)return f(os.NotFound,{docId:y});function T(S,C,F){p(!0),h(N=>{let R={...N},z=R[S]??{};return z.source=S,z[C]=F,R[S]=z,R})}async function O(){_(!0),await bt(async()=>{console.log("EditTranslationsModal.onSave()");let S=`edit-translations-${y}`;pe({id:S,loading:!0,title:"Saving translations",message:`Updating for ${y}...`,autoClose:!1,disallowClose:!0});let C=Object.values(m);console.log(C),await gl(y,C),at({id:S,title:"Saved translations",message:`Updated translations for ${y}!`,autoClose:!0}),h({}),p(!1)}),_(!1)}return f(me,{children:f("div",{className:"DocTranslationsPage",children:[f("div",{className:"DocTranslationsPage__header",children:[f(_r,{className:"DocTranslationsPage__header__breadcrumbs",children:[f("a",{href:`/cms/content/${x}`,children:x}),f("a",{href:`/cms/content/${x}/${b}`,children:b}),f("div",{children:"translations"})]}),f("div",{className:"DocTranslationsPage__header__titleWrap",children:f(Te,{size:"h1",children:["Translations: ",y]})}),c&&f("div",{className:"DocTranslationsPage__header__linkedSheet",children:[f("div",{className:"DocTranslationsPage__header__linkedSheet__label",children:[f("strong",{children:"NOTE:"})," Translations for this doc are managed in Google Sheets."]}),f("div",{className:"DocTranslationsPage__header__linkedSheet__controls",children:[f(xe,{label:"Open Google Sheet",children:f(Fe,{component:"a",href:Mn(c),target:"_blank",variant:"filled",color:"green",size:"sm",children:f(El,{size:16,strokeWidth:2.25})})}),f(X,{variant:"default",size:"xs",leftIcon:f(ti,{size:16,strokeWidth:1.75}),children:"Import from Sheet"}),f(X,{variant:"default",size:"xs",leftIcon:f(bl,{size:16,strokeWidth:1.75}),children:"Export to Sheet"})]})]})]}),f("div",{className:ke("DocTranslationsPage__content",e&&"DocTranslationsPage__content--loading"),children:e?f(Re,{color:"gray",size:"xl"}):f(os.Table,{locales:w,sourceStrings:a,translationsMap:s,onChange:T,changesMap:m})}),f("div",{className:"DocTranslationsPage__footer",children:f("div",{className:"DocTranslationsPage__footer__buttons",children:f(X,{variant:"filled",color:"dark",disabled:!d,loading:g,onClick:()=>O(),children:"Save"})})})]})})}os.NotFound=t=>f(me,{children:f("div",{className:"DocTranslationsPage DocTranslationsPage--error",children:f("div",{className:"DocTranslationsPage__error",children:[f("div",{className:"DocTranslationsPage__error__icon",children:f(jp,{size:60})}),f("div",{className:"DocTranslationsPage__error__title",children:["Not found: ",t.docId]})]})})});os.Table=t=>{let e=Tt(()=>{let o={};return Object.values(t.translationsMap).forEach(n=>{o[n.source]=n}),o},[t.translationsMap]);function r(o,n){return{translation:(e[o]||{})[n]||"",hasChanges:!1}}return f("div",{className:"DocTranslationsPage__TableWrap",children:f("table",{className:"DocTranslationsPage__Table",children:[f("thead",{children:f("tr",{children:[f("th",{children:"source"}),t.locales.map(o=>f("th",{children:o},o))]})}),f("tbody",{children:t.sourceStrings.map(o=>f("tr",{children:[f("td",{className:"DocTranslationsPage__Table__sourceCellWrap",children:f("div",{className:"DocTranslationsPage__Table__sourceCell",children:o})}),t.locales.map(n=>{let a=r(o,n);return f("td",{children:f(os.Textarea,{source:o,locale:n,value:a.translation,onChange:t.onChange,changesMap:t.changesMap})},n)})]},o))})]})})};os.Textarea=t=>{let e=H(null),[r,o]=P(t.value),n=null;t.locale in(t.changesMap[t.source]||{})&&(n=t.changesMap[t.source][t.locale]);let a=n!==null&&n!==t.value;function i(){window.requestAnimationFrame(()=>{let s=e.current;s.style.minHeight="auto";let l=s.scrollHeight;s.style.minHeight=`${l}px`})}return L(()=>{i()},[r]),f("textarea",{ref:e,className:ke("DocTranslationsPage__Textarea",a&&"DocTranslationsPage__Textarea--hasChanges",!r&&"DocTranslationsPage__Textarea--empty"),onFocus:()=>i(),rows:1,onChange:s=>{let l=s.target.value;o(l),t.onChange(t.source,t.locale,l)},value:r})};function zH(t,e){let r;return(...o)=>{window.clearTimeout(r),r=window.setTimeout(()=>{t(...o)},e)}}var ns=class{constructor(){this.events=new Map}on(e,r){let o=this.events.get(e)??[];return this.events.set(e,[...o,r]),()=>{this.off(e,r)}}off(e,r){let o=this.events.get(e)??[],n=o.indexOf(r);n>=0&&o.splice(n,1)}dispatch(e,...r){(this.events.get(e)??[]).forEach(n=>n(...r))}dispose(){this.events.clear()}};var UH=3*Tr.second,Wwe=5*Tr.minute;var Fk=class extends ns{constructor(r){super();this.pendingUpdates=new Map;this.cachedData={};this.subscribers={};this.saveState="NO_CHANGES";this.autolock=!1;this.autolockReason="autolock";this.autolockApplied=!1;this.started=!1;this.queueChanges=zH(()=>this.flush(),UH);this.projectId=window.__ROOT_CTX.rootConfig.projectId;let[o,n]=r.split("/");this.docId=r,this.collectionId=o,this.slug=n,this.db=window.firebase.db,this.docRef=we(this.db,"Projects",this.projectId,"Collections",o,"Drafts",n);let a=window.__ROOT_CTX.collections[o];a&&(this.autolock=!!a.autolock,a.autolockReason&&(this.autolockReason=a.autolockReason))}async start(){this.started||(this.started=!0,this.dbUnsubscribe=tb(this.docRef,r=>{let o=r.data();this.pendingUpdates.size>0&&vy(o,Object.fromEntries(this.pendingUpdates)),this.cachedData=o,this.notifySubscribers()}))}stop(){this.started&&(this.dbUnsubscribe&&this.dbUnsubscribe(),this.flush(),this.started=!1)}onChange(r){return this.on("CHANGE",r)}onSaveStateChange(r){return this.on("SAVE_STATE_CHANGE",r)}onFlush(r){return this.on("FLUSH",r)}subscribe(r,o){return this.subscribers[r]??=new Set,this.subscribers[r].add(o),o(this.getValue(r)),()=>{this.subscribers[r].delete(o),this.subscribers[r].size===0&&delete this.subscribers[r]}}notifySubscribers(){let r=this.cachedData;this.dispatch("CHANGE",r),VH(this.subscribers,r)}getValue(r){return oo(this.cachedData,r)}async updateKey(r,o){await this.updateKeys({[r]:o})}async updateKeys(r){for(let o in r)this.pendingUpdates.set(o,r[o]);vy(this.cachedData,r),this.dispatch("CHANGE",this.cachedData),this.setSaveState("UPDATE_PENDING"),this.queueChanges()}async removeKey(r){this.pendingUpdates.set(r,zr()),vy(this.cachedData,{[r]:void 0}),this.dispatch("CHANGE",this.cachedData),this.setSaveState("UPDATE_PENDING"),this.queueChanges()}setSaveState(r){let o=this.saveState;r==="SAVED"&&o!=="SAVING"||(this.saveState=r,r==="SAVED"&&window.setTimeout(()=>{this.saveState==="SAVED"&&this.setSaveState("NO_CHANGES")},UH),this.dispatch("SAVE_STATE_CHANGE",r))}async flush(){if(this.pendingUpdates.size===0)return;let r=Object.fromEntries(this.pendingUpdates);r["sys.modifiedAt"]=Ut(),r["sys.modifiedBy"]=window.firebase.user.email,this.autolock&&!this.autolockApplied&&!this.cachedData?.sys?.publishingLocked&&(this.autolockApplied=!0,r["sys.publishingLocked"]={lockedAt:Ut(),lockedBy:window.firebase.user.email,reason:this.autolockReason}),this.pendingUpdates.clear();try{this.setSaveState("SAVING"),await rr(this.docRef,r),this.setSaveState("SAVED"),this.dispatch("FLUSH"),Je("doc.save",{metadata:{docId:this.docId},throttle:Wwe,throttleId:this.docId})}catch(o){console.error("failed to update doc"),console.error(o),this.setSaveState("ERROR"),pe({title:"Failed to save",message:`Failed to save changes to ${this.slug}`,color:"red",autoClose:!1});for(let n in r)n.startsWith("sys.")||this.pendingUpdates.has(n)||(this.pendingUpdates.set(n,r[n]),this.queueChanges(),console.log("re-queued updates"))}}getLocales(){return this.cachedData&&this.cachedData.sys?.locales?this.cachedData.sys.locales:["en"]}setLocales(r){this.updateKey("sys.locales",r)}async dispose(){super.dispose(),this.stop()}};function vy(t,e){for(let r in e){let o=e[r];if(r.includes(".")){let[n,a]=Kwe(r);t[n]??={},vy(t[n],{[a]:o})}else typeof o>"u"?delete t[r]:t[r]=o}}function VH(t,e,r){r||(r=[]);for(let o in e){let n=[...r,o],a=n.join("."),i=t[a],s=e[o];i&&Array.from(i).forEach(l=>{l(s)}),Bp(s)&&VH(t,s,n)}}function Kwe(t){let e=t.indexOf("."),r=t.substring(0,e),o=t.substring(e+1);return[r,o]}function HH(t){let[e,r]=P(!0),[o,n]=P({}),a=Tt(()=>new Fk(t),[t]),[i,s]=P("NO_CHANGES");return L(()=>{a.onChange(c=>{n(c),r(!1),Lp(t,c)}),a.onSaveStateChange(c=>s(c)),a.start();let l=()=>{document.hidden||document.visibilityState!=="visible"?a.stop():a.started||(r(!0),a.start())};return document.addEventListener("visibilitychange",l),()=>{a.dispose(),document.removeEventListener("visibilitychange",l)}},[t]),{loading:e,saveState:i,controller:a,data:o}}function $H(t,e){let r=zk(t);for(let o of r)if(e[o]){let n=String(e[o]);t=t.replaceAll(`{${o}}`,n)}return t}function zk(t){return Array.from(t.matchAll(/\{(.+?)\}/g)).map(e=>e[1])}var Uk=class{constructor(){this.value=null}set(e){this.value=e}},Xwe=new Uk;function jH(){return Xwe}function qH(t,e){let r=!1;return(...o)=>{r||(t(...o),r=!0,setTimeout(()=>{r=!1},e))}}var lm=class extends ns{constructor(r){super();this.interval=0;this.timeout=0;this.interval=r}start(){this.timeout=window.setTimeout(()=>{this.tick()},this.interval)}tick(){this.dispatch("tick"),this.start()}reset(){this.stop(),this.start()}stop(){this.timeout&&(window.clearTimeout(this.timeout),this.timeout=0)}};var Ywe=30*Tr.second,GH=5*Tr.minute,Vk=class extends ns{constructor(r){super();this.started=!1;this.timer=new lm(Ywe);this.idleTimer=new lm(GH);this.onUserInteraction=qH(()=>{this.idleTimer.reset()},5e3);this.id=r;let o=window.__ROOT_CTX.rootConfig.projectId,n=window.firebase.db;this.docRef=we(n,"Projects",o,"Viewers",r),this.timer.on("tick",()=>this.onTick()),this.idleTimer.on("tick",()=>this.onIdle()),window.addEventListener("mousemove",this.onUserInteraction),window.addEventListener("keypress",this.onUserInteraction)}async start(){this.started||(this.started=!0,this.dbUnsubscribe=tb(this.docRef,r=>{let o=r.data();this.onData(o)}),this.onTick(),this.timer.start())}onData(r){let o=window.firebase.user,n=Ze.now(),a=Object.values(r).filter(i=>!(i.email===o.email||n.toMillis()-i.lastViewedAt.toMillis()>GH));this.dispatch("change",a)}async onTick(){let r=window.firebase.user;if(!r.email){console.log("no user email:",r);return}console.log(`updating lastViewedAt for ${r.email}`),await vu(this.docRef,{[r.email]:{email:r.email,photoURL:r.photoURL,lastViewedAt:Ut()}},{merge:!0})}async onIdle(){this.stop()}stop(){this.started&&(this.dbUnsubscribe&&this.dbUnsubscribe(),this.timer.stop(),this.idleTimer.stop(),this.onDisconnect(),this.started=!1)}async onDisconnect(){let r=window.firebase.user;if(!r.email){console.log("no user email:",r);return}let o=new No(r.email,"disconnectedAt");await rr(this.docRef,o,Ut())}async dispose(){super.dispose(),this.stop(),this.timer.dispose(),this.idleTimer.dispose()}};function WH(t){let e=$i(t.id),[r,o]=P([]);if(L(()=>{let a=new Vk(e);a.on("change",s=>o(s)),a.start();let i=()=>{document.hidden||document.visibilityState!=="visible"?a.stop():a.started||a.start()};return document.addEventListener("visibilitychange",i),()=>{a.dispose(),document.removeEventListener("visibilitychange",i)}},[e]),r.length===0)return null;function n(a){return a.disconnectedAt?a.disconnectedAt>a.lastViewedAt:!1}return f(ig,{className:"Viewers",limit:3,size:30,children:r.map(a=>{if(!a.photoURL){let i=a.email[0].toUpperCase();return f(kn,{alt:a.email,size:24,radius:"xl",children:i})}return f(kn,{className:ke("Viewers__viewer",n(a)&&"Viewers__viewer--disconnected"),src:a.photoURL,alt:a.email,size:24,radius:"xl"},a.email)})})}function KH(t){let r=t.field.checkboxLabel||"Enabled",[o,n]=P(!1);function a(i){n(i),t.draft.updateKey(t.deepKey,i)}return L(()=>t.draft.subscribe(t.deepKey,s=>{n(s)}),[]),f("div",{className:"DocEditor__BooleanField",children:f(Rc,{label:r,onChange:i=>{let s=i.currentTarget;a(s.checked)},checked:o,size:"xs"})})}function XH(t){let[e,r]=P("");function o(a){if(a){let i=Math.floor(new Date(a).getTime()),s=Ze.fromMillis(i);r(n(s)),t.draft.updateKey(t.deepKey,s)}else r(""),t.draft.removeKey(t.deepKey)}function n(a){let i=a.toDate();return i.setMinutes(i.getMinutes()-i.getTimezoneOffset()),i.toISOString().slice(0,16)}return L(()=>t.draft.subscribe(t.deepKey,i=>{r(i?n(i):"")}),[]),f("div",{className:"DocEditor__DateTimeField",children:[f("input",{type:"datetime-local",value:e,onChange:a=>{let s=a.target.value;o(s)}}),f("div",{className:"DocEditor__DateTimeField__timezone",children:["timezone: ",Intl.DateTimeFormat().resolvedOptions().timeZone]})]})}function QH(t){let e=t.field,[r,o]=P({}),[n,a]=P(!1),[i,s]=P(!1),l=H(null),c=H(null),u=e.alt!==!1,d;e.exts&&(d=e.exts.join(","));async function p(){o({}),t.draft.removeKey(t.deepKey)}async function m(y){a(!0);try{let I=await Aa(y,{cacheControl:e.cacheControl,preserveFilename:e.preserveFilename});o(w=>{let v={...I};return w?.src&&YH(w.src)&&(v.alt=w?.alt||""),t.draft.updateKey(t.deepKey,v),v}),a(!1)}catch(I){console.error("file upload failed"),console.error(I),a(!1),pe({title:"File upload failed",message:"Failed to upload file: "+String(I),color:"red",autoClose:!1})}if(l.current){let I=l.current;I.value=""}}function h(y){let v=(y.target.files||[])[0];v&&m(v)}function g(y){o(I=>Object.assign({},I,{alt:y})),t.draft.updateKey(`${t.deepKey}.alt`,y)}let _=y=>{y.preventDefault(),s(!0)},x=y=>{y.preventDefault(),s(!1)},b=y=>{y.preventDefault(),s(!1);let w=(y.dataTransfer?.files||[])[0];w&&(console.log(`file dropped ("${t.deepKey}"):`,w),m(w))};return L(()=>{let y=t.draft.subscribe(t.deepKey,w=>{o(w)}),I=c.current;return document.addEventListener("dragenter",_),document.addEventListener("dragover",_),document.addEventListener("dragleave",x),document.addEventListener("drop",x),I&&I.addEventListener("drop",b),()=>{y(),document.removeEventListener("dragenter",_),document.removeEventListener("dragover",_),document.removeEventListener("dragleave",x),document.removeEventListener("drop",x),I&&I.removeEventListener("drop",b)}},[]),f("div",{className:ke("DocEditor__FileField",i&&"dragging"),ref:c,children:[r&&r.src&&f("div",{className:"DocEditor__FileField__controls",children:f(xe,{label:"Remove file",children:f(Fe,{className:"DocEditor__FileField__controls__trash",onClick:()=>p(),children:f(cn,{size:16})})})}),r&&r.src&&ZH(r.src)&&f(Qwe,{...r},r.src),r&&r.src&&JH(r.src)&&f(Zwe,{...r},r.src),r&&r.src?f(Ae,{children:[f("div",{className:"DocEditor__FileField__file",children:f(gt,{className:"DocEditor__FileField__file__url",size:"xs",radius:0,value:r.src,disabled:!0})}),u&&YH(r.src)&&f(gt,{className:"DocEditor__FileField__file__alt",size:"xs",radius:0,value:r.alt||"",onChange:y=>{g(y.currentTarget.value)},label:"Alt text"})]}):f("div",{className:"DocEditor__FileField__noFile",children:"No file"}),f("label",{className:"DocEditor__FileField__uploadButton",role:"button","aria-disabled":n,children:[f("input",{type:"file",accept:d,onChange:h,ref:l}),f("div",{className:"DocEditor__FileField__uploadButton__icon",children:f(ti,{size:16})}),f("div",{className:"DocEditor__FileField__uploadButton__label",children:n?"Uploading...":"Upload file"})]})]})}function Qwe(t){return f("div",{className:"DocEditor__FileField__ImagePreview",children:[f("img",{src:t.src,width:t.width,height:t.height,loading:"lazy"}),t.width&&t.height&&f("div",{className:"DocEditor__FileField__ImagePreview__dimens",children:`${t.width}x${t.height}`})]})}function Zwe(t){let e={};return t.width&&t.height&&(e["--video-aspect-ratio"]=`${t.width} / ${t.height}`),f("div",{className:"DocEditor__FileField__VideoPreview",style:e,children:[f("video",{className:"DocEditor__FileField__VideoPreview__video",controls:!0,preload:"metadata",children:f("source",{src:t.src,type:`video/${am(t.src)}`})}),t.width&&t.height&&f("div",{className:"DocEditor__FileField__VideoPreview__dimens",children:`${t.width}x${t.height}`})]})}function ZH(t){if(!t)return!1;if(t.startsWith(cH))return!0;let e=am(t);return Dk.includes(e)}function JH(t){if(!t)return!1;let e=am(t);return Rk.includes(e)}function YH(t){return ZH(t)||JH(t)}var Jwe=["image/gif","image/jpeg","image/png","image/svg+xml","image/webp"];function e0e(t){return(t??Jwe).join(", ")}function e$(t){let e=t.field,[r,o]=P({}),[n,a]=P(!1),[i,s]=P(!1),l=H(null),c=H(null),u=e0e(e.exts);async function d(y){a(!0);try{let I=await Aa(y,{cacheControl:e.cacheControl});o(w=>{let v=Object.assign({},I,{alt:w?.alt||""});return t.draft.updateKey(t.deepKey,v),v}),a(!1)}catch(I){console.error("image upload failed"),console.error(I),a(!1),pe({title:"Image upload failed",message:"Failed to upload image: "+String(I),color:"red",autoClose:!1})}if(l.current){let I=l.current;I.value=""}}function p(y){let v=(y.target.files||[])[0];v&&d(v)}function m(y){o(I=>Object.assign({},I,{alt:y})),t.draft.updateKey(`${t.deepKey}.alt`,y)}function h(){o({}),t.draft.removeKey(t.deepKey)}let g=y=>{y.preventDefault(),s(!0)},_=y=>{y.preventDefault(),s(!1)},x=y=>{y.preventDefault(),s(!1);let w=(y.dataTransfer?.files||[])[0];w&&(console.log(`file dropped ("${t.deepKey}"):`,w),d(w))};L(()=>{let y=t.draft.subscribe(t.deepKey,w=>{o(w)}),I=c.current;return document.addEventListener("dragenter",g),document.addEventListener("dragover",g),document.addEventListener("dragleave",_),document.addEventListener("drop",_),I&&I.addEventListener("drop",x),()=>{y(),document.removeEventListener("dragenter",g),document.removeEventListener("dragover",g),document.removeEventListener("dragleave",_),document.removeEventListener("drop",_),I&&I.removeEventListener("drop",x)}},[]);let b=e.alt!==!1;return f("div",{className:ke("DocEditor__ImageField",i&&"dragging"),ref:c,children:[r&&r.src?f("div",{className:"DocEditor__ImageField__imagePreview",children:[f("div",{className:"DocEditor__ImageField__imagePreview__controls",children:f(xe,{label:"Remove image",children:f(Fe,{className:"DocEditor__ImageField__imagePreview__controls__trash",onClick:()=>h(),children:f(cn,{size:16})})})}),f("div",{className:"DocEditor__ImageField__imagePreview__image",children:[f("img",{src:r.gciUrl||r.src,width:r.width,height:r.height,loading:"lazy"}),f("div",{className:"DocEditor__ImageField__imagePreview__dimens",children:`${r.width}x${r.height}`})]}),f(gt,{className:"DocEditor__ImageField__imagePreview__image__url",size:"xs",radius:0,value:r.gciUrl||r.src,disabled:!0}),b&&f(gt,{className:"DocEditor__ImageField__imagePreview__image__alt",size:"xs",radius:0,value:r.alt,label:"Alt text",onChange:y=>{m(y.currentTarget.value)}})]}):f("div",{className:"DocEditor__ImageField__noImage",children:"No image"}),f("label",{className:"DocEditor__ImageField__uploadButton",role:"button","aria-disabled":n,children:[f("input",{type:"file",accept:u,onChange:p,ref:l}),f("div",{className:"DocEditor__ImageField__uploadButton__icon",children:f(JS,{size:16})}),f("div",{className:"DocEditor__ImageField__uploadButton__label",children:n?"Uploading...":"Upload image"})]})]})}function t$(t){let e=t.field,[r,o]=P([]),n=(e.options||[]).map(i=>typeof i=="string"?{label:i,value:i}:{label:i.label??i.value??"",value:i.value??i.label??""});function a(i){t.draft.updateKey(t.deepKey,i||[]),o(i)}return L(()=>t.draft.subscribe(t.deepKey,s=>{o(s||[])}),[]),f("div",{className:"DocEditor__MultiSelectField",children:f(Og,{data:n,size:"xs",radius:0,placeholder:e.placeholder,value:r,searchable:!0,creatable:e.creatable||!1,getCreateLabel:i=>`+ Add "${i}"`,onChange:i=>a(i),dropdownComponent:"div"})})}function td(t){let e=t.field,[r,o]=P("");function n(l){if(l){let[c,u]=l.split("/");t.draft.updateKey(t.deepKey,{id:l,collection:c,slug:u})}else t.draft.removeKey(t.deepKey);o(l)}L(()=>t.draft.subscribe(t.deepKey,c=>{o(c?.id||"")}),[]);let a=Pz();function i(){let l=r?r.split("/")[0]:e.initialCollection;a.open({collections:e.collections,initialCollection:l,onChange:c=>{n(c),a.close()}})}function s(){n("")}return f("div",{className:"ReferenceField",children:[r?f("div",{className:"ReferenceField__ref",children:[f(td.Preview,{id:r}),f("div",{className:"ReferenceField__remove",children:f(xe,{label:"Remove",children:f(Fe,{className:"ReferenceField__remove__icon",onClick:()=>s(),children:f(cn,{size:16})})})})]}):f("div",{className:"ReferenceField__none",children:"None selected"}),f(X,{color:"dark",size:"xs",onClick:()=>i(),children:e.buttonLabel||"Select"})]})}td.Preview=t=>{let[e,r]=P(!0),[o,n]=P(null);async function a(){r(!0),await bt(async()=>{let i=await cb(t.id);n(i)}),r(!1)}return L(()=>{a()},[t.id]),f("div",{className:"ReferenceField__Preview",children:e?f("div",{className:"ReferenceField__Preview__loading",children:f(Re,{color:"gray",size:"sm"})}):o?f(td.DocCard,{doc:o}):f("div",{className:"ReferenceField__Preview__notfound",children:['Doc Not found: "',t.id,'" (was it deleted?). Select a new doc or remove using the trash icon to the right.']})})};td.DocCard=t=>{let e=t.doc,r=e.id||e.sys?.id||"";if(!r)return f("div",{className:"ReferenceField__DocCard ReferenceField__DocCard--error",children:JSON.stringify(e)});let o=r.split("/")[0],n=e.fields||{},a=window.__ROOT_CTX.collections[o];if(!a)throw new Error(`could not find collection: ${o}`);let i=oo(n,a.preview?.title||"meta.title"),s=oo(n,a.preview?.image||"meta.image")||a.preview?.defaultImage;return f("a",{className:"ReferenceField__DocCard",href:`/cms/content/${r}`,target:"_blank",children:[f("div",{className:"ReferenceField__DocCard__image",children:f(Tn,{src:s?.src,width:80,height:60,withPlaceholder:!s?.src})}),f("div",{className:"ReferenceField__DocCard__content",children:[f("div",{className:"ReferenceField__DocCard__content__header",children:f("div",{className:"ReferenceField__DocCard__content__header__docId",children:r})}),f("div",{className:"ReferenceField__DocCard__content__title",children:i||"[UNTITLED]"})]})]})};(function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode(".ce-hint--align-start{text-align:left}.ce-hint--align-center{text-align:center}.ce-hint__description{opacity:.6;margin-top:3px}")),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var hm=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Wy(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function t0e(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var r=function o(){return this instanceof o?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(o){var n=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(r,o,n.get?n:{enumerable:!0,get:function(){return t[o]}})}),r}function Hk(){}Object.assign(Hk,{default:Hk,register:Hk,revert:function(){},__esModule:!0});Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(t){let e=(this.document||this.ownerDocument).querySelectorAll(t),r=e.length;for(;--r>=0&&e.item(r)!==this;);return r>-1});Element.prototype.closest||(Element.prototype.closest=function(t){let e=this;if(!document.documentElement.contains(e))return null;do{if(e.matches(t))return e;e=e.parentElement||e.parentNode}while(e!==null);return null});Element.prototype.prepend||(Element.prototype.prepend=function(t){let e=document.createDocumentFragment();Array.isArray(t)||(t=[t]),t.forEach(r=>{let o=r instanceof Node;e.appendChild(o?r:document.createTextNode(r))}),this.insertBefore(e,this.firstChild)});Element.prototype.scrollIntoViewIfNeeded||(Element.prototype.scrollIntoViewIfNeeded=function(t){t=arguments.length===0?!0:!!t;let e=this.parentNode,r=window.getComputedStyle(e,null),o=parseInt(r.getPropertyValue("border-top-width")),n=parseInt(r.getPropertyValue("border-left-width")),a=this.offsetTop-e.offsetTop<e.scrollTop,i=this.offsetTop-e.offsetTop+this.clientHeight-o>e.scrollTop+e.clientHeight,s=this.offsetLeft-e.offsetLeft<e.scrollLeft,l=this.offsetLeft-e.offsetLeft+this.clientWidth-n>e.scrollLeft+e.clientWidth,c=a&&!i;(a||i)&&t&&(e.scrollTop=this.offsetTop-e.offsetTop-e.clientHeight/2-o+this.clientHeight/2),(s||l)&&t&&(e.scrollLeft=this.offsetLeft-e.offsetLeft-e.clientWidth/2-n+this.clientWidth/2),(a||i||s||l)&&!t&&this.scrollIntoView(c)});window.requestIdleCallback=window.requestIdleCallback||function(t){let e=Date.now();return setTimeout(function(){t({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-e))}})},1)};window.cancelIdleCallback=window.cancelIdleCallback||function(t){clearTimeout(t)};var r0e=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,r)=>(r&=63,r<36?e+=r.toString(36):r<62?e+=(r-26).toString(36).toUpperCase():r>62?e+="-":e+="_",e),""),h$=(t=>(t.VERBOSE="VERBOSE",t.INFO="INFO",t.WARN="WARN",t.ERROR="ERROR",t))(h$||{}),He={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,LEFT:37,UP:38,DOWN:40,RIGHT:39,DELETE:46,META:91,SLASH:191},o0e={LEFT:0,WHEEL:1,RIGHT:2,BACKWARD:3,FORWARD:4};function wm(t,e,r="log",o,n="color: inherit"){if(!("console"in window)||!window.console[r])return;let a=["info","log","warn","error"].includes(r),i=[];switch(wm.logLevel){case"ERROR":if(r!=="error")return;break;case"WARN":if(!["error","warn"].includes(r))return;break;case"INFO":if(!a||t)return;break}o&&i.push(o);let s="Editor.js 2.31.0-rc.7",l=`line-height: 1em;
|
|
144
144
|
color: #006FEA;
|
|
145
145
|
display: inline-block;
|
|
146
146
|
font-size: 11px;
|