texlite 0.3.0 → 0.3.5
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/README.md +4 -100
- package/README.zh-CN.md +3 -42
- package/dist/client/assets/{GitDialog-BRIGO4No.js → GitDialog-BgrOdlfK.js} +1 -1
- package/dist/client/assets/{HistoryDialog-ClN5gb3K.js → HistoryDialog-CG_Zzb6A.js} +1 -1
- package/dist/client/assets/{LatexEditor-CbYL1NGq.js → LatexEditor-Dwh0-y5c.js} +1 -1
- package/dist/client/assets/PdfPreview-CNcTjaa2.js +1 -0
- package/dist/client/assets/{ProjectNavigationDialogs-BK3E3V9t.js → ProjectNavigationDialogs-RqNAi86R.js} +1 -1
- package/dist/client/assets/{SystemMetricsDialog-vrmlRA2s.js → SystemMetricsDialog-DU--pQgz.js} +1 -1
- package/dist/client/assets/index-Ddch-kkF.css +1 -0
- package/dist/client/assets/index-rcWmMadt.js +17 -0
- package/dist/client/assets/{plus-CBJCSqRG.js → plus-D9N7Jm3V.js} +1 -1
- package/dist/client/index.html +2 -2
- package/package.json +1 -1
- package/dist/client/assets/PdfPreview-BXV75mRa.js +0 -1
- package/dist/client/assets/index-CtVAEMSo.css +0 -1
- package/dist/client/assets/index-DvWbA6GV.js +0 -17
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-rBWMBTI-.js","assets/react-CsO_xvbl.js","assets/spellCheck-R6fUM9oA.js","assets/PdfPreview-BXV75mRa.js","assets/pdf-DPnwNQHb.js","assets/plus-CBJCSqRG.js","assets/LatexEditor-CbYL1NGq.js","assets/editor-JxT6uSYX.js","assets/GitDialog-BRIGO4No.js","assets/HistoryDialog-ClN5gb3K.js","assets/ProjectNavigationDialogs-BK3E3V9t.js","assets/SystemMetricsDialog-vrmlRA2s.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{i as jh,r as h,j as o,R as Ks,a as ll,b as Ch,u as _e,P as kh,c as vr,d as _i,e as Eh}from"./react-CsO_xvbl.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&s(a)}).observe(document,{childList:!0,subtree:!0});function n(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(r){if(r.ep)return;r.ep=!0;const i=n(r);fetch(r.href,i)}})();const Dh="modulepreload",Nh=function(t){return"/"+t},Ha={},qt=function(e,n,s){let r=Promise.resolve();if(n&&n.length>0){let l=function(d){return Promise.all(d.map(f=>Promise.resolve(f).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),c=a?.nonce||a?.getAttribute("nonce");r=l(n.map(d=>{if(d=Nh(d),d in Ha)return;Ha[d]=!0;const f=d.endsWith(".css"),u=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${u}`))return;const m=document.createElement("link");if(m.rel=f?"stylesheet":Dh,f||(m.as="script"),m.crossOrigin="",m.href=d,c&&m.setAttribute("nonce",c),document.head.appendChild(m),f)return new Promise((p,g)=>{m.addEventListener("load",p),m.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${d}`)))})}))}function i(a){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=a,window.dispatchEvent(c),!c.defaultPrevented)throw a}return r.then(a=>{for(const c of a||[])c.status==="rejected"&&i(c.reason);return e().catch(i)})},Th="0.3.0";var Pi={};const G=t=>typeof t=="string",ks=()=>{let t,e;const n=new Promise((s,r)=>{t=s,e=r});return n.resolve=t,n.reject=e,n},qa=t=>t==null?"":""+t,Oh=(t,e,n)=>{t.forEach(s=>{e[s]&&(n[s]=e[s])})},_h=/###/g,Wa=t=>t&&t.indexOf("###")>-1?t.replace(_h,"."):t,Ka=t=>!t||G(t),Ts=(t,e,n)=>{const s=G(e)?e.split("."):e;let r=0;for(;r<s.length-1;){if(Ka(t))return{};const i=Wa(s[r]);!t[i]&&n&&(t[i]=new n),Object.prototype.hasOwnProperty.call(t,i)?t=t[i]:t={},++r}return Ka(t)?{}:{obj:t,k:Wa(s[r])}},Ga=(t,e,n)=>{const{obj:s,k:r}=Ts(t,e,Object);if(s!==void 0||e.length===1){s[r]=n;return}let i=e[e.length-1],a=e.slice(0,e.length-1),c=Ts(t,a,Object);for(;c.obj===void 0&&a.length;)i=`${a[a.length-1]}.${i}`,a=a.slice(0,a.length-1),c=Ts(t,a,Object),c?.obj&&typeof c.obj[`${c.k}.${i}`]<"u"&&(c.obj=void 0);c.obj[`${c.k}.${i}`]=n},Ph=(t,e,n,s)=>{const{obj:r,k:i}=Ts(t,e,Object);r[i]=r[i]||[],r[i].push(n)},Ir=(t,e)=>{const{obj:n,k:s}=Ts(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,s))return n[s]},Rh=(t,e,n)=>{const s=Ir(t,n);return s!==void 0?s:Ir(e,n)},dl=(t,e,n)=>{for(const s in e)s!=="__proto__"&&s!=="constructor"&&(s in t?G(t[s])||t[s]instanceof String||G(e[s])||e[s]instanceof String?n&&(t[s]=e[s]):dl(t[s],e[s],n):t[s]=e[s]);return t},fn=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Lh={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const Ah=t=>G(t)?t.replace(/[&<>"'\/]/g,e=>Lh[e]):t;class Fh{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const n=this.regExpMap.get(e);if(n!==void 0)return n;const s=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,s),this.regExpQueue.push(e),s}}const Ih=[" ",",","?","!",";"],Mh=new Fh(20),$h=(t,e,n)=>{e=e||"",n=n||"";const s=Ih.filter(a=>e.indexOf(a)<0&&n.indexOf(a)<0);if(s.length===0)return!0;const r=Mh.getRegExp(`(${s.map(a=>a==="?"?"\\?":a).join("|")})`);let i=!r.test(t);if(!i){const a=t.indexOf(n);a>0&&!r.test(t.substring(0,a))&&(i=!0)}return i},ro=(t,e,n=".")=>{if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const s=e.split(n);let r=t;for(let i=0;i<s.length;){if(!r||typeof r!="object")return;let a,c="";for(let l=i;l<s.length;++l)if(l!==i&&(c+=n),c+=s[l],a=r[c],a!==void 0){if(["string","number","boolean"].indexOf(typeof a)>-1&&l<s.length-1)continue;i+=l-i+1;break}r=a}return r},Ps=t=>t?.replace(/_/g,"-"),Uh={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,e){console?.[t]?.apply?.(console,e)}};class Mr{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||Uh,this.options=n,this.debug=n.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,s,r){return r&&!this.debug?null:(G(e[0])&&(e[0]=`${s}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new Mr(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new Mr(this.logger,e)}}var jt=new Mr;class ii{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(s=>{this.observers[s]||(this.observers[s]=new Map);const r=this.observers[s].get(n)||0;this.observers[s].set(n,r+1)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e].delete(n)}}emit(e,...n){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([r,i])=>{for(let a=0;a<i;a++)r(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([r,i])=>{for(let a=0;a<i;a++)r.apply(r,[e,...n])})}}class Ja extends ii{constructor(e,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,s,r={}){const i=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator,a=r.ignoreJSONStructure!==void 0?r.ignoreJSONStructure:this.options.ignoreJSONStructure;let c;e.indexOf(".")>-1?c=e.split("."):(c=[e,n],s&&(Array.isArray(s)?c.push(...s):G(s)&&i?c.push(...s.split(i)):c.push(s)));const l=Ir(this.data,c);return!l&&!n&&!s&&e.indexOf(".")>-1&&(e=c[0],n=c[1],s=c.slice(2).join(".")),l||!a||!G(s)?l:ro(this.data?.[e]?.[n],s,i)}addResource(e,n,s,r,i={silent:!1}){const a=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator;let c=[e,n];s&&(c=c.concat(a?s.split(a):s)),e.indexOf(".")>-1&&(c=e.split("."),r=n,n=c[1]),this.addNamespaces(n),Ga(this.data,c,r),i.silent||this.emit("added",e,n,s,r)}addResources(e,n,s,r={silent:!1}){for(const i in s)(G(s[i])||Array.isArray(s[i]))&&this.addResource(e,n,i,s[i],{silent:!0});r.silent||this.emit("added",e,n,s)}addResourceBundle(e,n,s,r,i,a={silent:!1,skipCopy:!1}){let c=[e,n];e.indexOf(".")>-1&&(c=e.split("."),r=s,s=n,n=c[1]),this.addNamespaces(n);let l=Ir(this.data,c)||{};a.skipCopy||(s=JSON.parse(JSON.stringify(s))),r?dl(l,s,i):l={...l,...s},Ga(this.data,c,l),a.silent||this.emit("added",e,n,s)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return this.getResource(e,n)!==void 0}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(r=>n[r]&&Object.keys(n[r]).length>0)}toJSON(){return this.data}}var ul={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,s,r){return t.forEach(i=>{e=this.processors[i]?.process(e,n,s,r)??e}),e}};const hl=Symbol("i18next/PATH_KEY");function zh(){const t=[],e=Object.create(null);let n;return e.get=(s,r)=>(n?.revoke?.(),r===hl?t:(t.push(r),n=Proxy.revocable(s,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function Hn(t,e){const{[hl]:n}=t(zh()),s=e?.keySeparator??".",r=e?.nsSeparator??":";if(n.length>1&&r){const i=e?.ns,a=Array.isArray(i)?i:null;if(a&&a.length>1&&a.slice(1).includes(n[0]))return`${n[0]}${r}${n.slice(1).join(s)}`}return n.join(s)}const Ya={},Ri=t=>!G(t)&&typeof t!="boolean"&&typeof t!="number";class $r extends ii{constructor(e,n={}){super(),Oh(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=jt.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){const s={...n};if(e==null)return!1;const r=this.resolve(e,s);if(r?.res===void 0)return!1;const i=Ri(r.res);return!(s.returnObjects===!1&&i)}extractFromKey(e,n){let s=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;s===void 0&&(s=":");const r=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let i=n.ns||this.options.defaultNS||[];const a=s&&e.indexOf(s)>-1,c=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!$h(e,s,r);if(a&&!c){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:G(i)?[i]:i};const d=e.split(s);(s!==r||s===r&&this.options.ns.indexOf(d[0])>-1)&&(i=d.shift()),e=d.join(r)}return{key:e,namespaces:G(i)?[i]:i}}translate(e,n,s){let r=typeof n=="object"?{...n}:n;if(typeof r!="object"&&this.options.overloadTranslationOptionHandler&&(r=this.options.overloadTranslationOptionHandler(arguments)),typeof r=="object"&&(r={...r}),r||(r={}),e==null)return"";typeof e=="function"&&(e=Hn(e,{...this.options,...r})),Array.isArray(e)||(e=[String(e)]),e=e.map(R=>typeof R=="function"?Hn(R,{...this.options,...r}):String(R));const i=r.returnDetails!==void 0?r.returnDetails:this.options.returnDetails,a=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator,{key:c,namespaces:l}=this.extractFromKey(e[e.length-1],r),d=l[l.length-1];let f=r.nsSeparator!==void 0?r.nsSeparator:this.options.nsSeparator;f===void 0&&(f=":");const u=r.lng||this.language,m=r.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u?.toLowerCase()==="cimode")return m?i?{res:`${d}${f}${c}`,usedKey:c,exactUsedKey:c,usedLng:u,usedNS:d,usedParams:this.getUsedParamsDetails(r)}:`${d}${f}${c}`:i?{res:c,usedKey:c,exactUsedKey:c,usedLng:u,usedNS:d,usedParams:this.getUsedParamsDetails(r)}:c;const p=this.resolve(e,r);let g=p?.res;const x=p?.usedKey||c,b=p?.exactUsedKey||c,j=["[object Number]","[object Function]","[object RegExp]"],C=r.joinArrays!==void 0?r.joinArrays:this.options.joinArrays,T=!this.i18nFormat||this.i18nFormat.handleAsObject,N=r.count!==void 0&&!G(r.count),L=$r.hasDefaultValue(r),P=N?this.pluralResolver.getSuffix(u,r.count,r):"",E=r.ordinal&&N?this.pluralResolver.getSuffix(u,r.count,{ordinal:!1}):"",H=N&&!r.ordinal&&r.count===0,S=H&&r[`defaultValue${this.options.pluralSeparator}zero`]||r[`defaultValue${P}`]||r[`defaultValue${E}`]||r.defaultValue;let O=g;T&&!g&&L&&(O=S);const ae=Ri(O),q=Object.prototype.toString.apply(O);if(T&&O&&ae&&j.indexOf(q)<0&&!(G(C)&&Array.isArray(O))){if(!r.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const R=this.options.returnedObjectHandler?this.options.returnedObjectHandler(x,O,{...r,ns:l}):`key '${c} (${this.language})' returned an object instead of string.`;return i?(p.res=R,p.usedParams=this.getUsedParamsDetails(r),p):R}if(a){const R=Array.isArray(O),_=R?[]:{},v=R?b:x;for(const I in O)if(Object.prototype.hasOwnProperty.call(O,I)){const Q=`${v}${a}${I}`;L&&!g?_[I]=this.translate(Q,{...r,defaultValue:Ri(S)?S[I]:void 0,joinArrays:!1,ns:l}):_[I]=this.translate(Q,{...r,joinArrays:!1,ns:l}),_[I]===Q&&(_[I]=O[I])}g=_}}else if(T&&G(C)&&Array.isArray(g))g=g.join(C),g&&(g=this.extendTranslation(g,e,r,s));else{let R=!1,_=!1;!this.isValidLookup(g)&&L&&(R=!0,g=S),this.isValidLookup(g)||(_=!0,g=c);const I=(r.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&_?void 0:g,Q=L&&S!==g&&this.options.updateMissing;if(_||R||Q){if(this.logger.log(Q?"updateKey":"missingKey",u,d,c,Q?S:g),a){const ye=this.resolve(c,{...r,keySeparator:!1});ye&&ye.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let ce=[];const pe=this.languageUtils.getFallbackCodes(this.options.fallbackLng,r.lng||this.language);if(this.options.saveMissingTo==="fallback"&&pe&&pe[0])for(let ye=0;ye<pe.length;ye++)ce.push(pe[ye]);else this.options.saveMissingTo==="all"?ce=this.languageUtils.toResolveHierarchy(r.lng||this.language):ce.push(r.lng||this.language);const Y=(ye,W,ve)=>{const ze=L&&ve!==g?ve:I;this.options.missingKeyHandler?this.options.missingKeyHandler(ye,d,W,ze,Q,r):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(ye,d,W,ze,Q,r),this.emit("missingKey",ye,d,W,g)};this.options.saveMissing&&(this.options.saveMissingPlurals&&N?ce.forEach(ye=>{const W=this.pluralResolver.getSuffixes(ye,r);H&&r[`defaultValue${this.options.pluralSeparator}zero`]&&W.indexOf(`${this.options.pluralSeparator}zero`)<0&&W.push(`${this.options.pluralSeparator}zero`),W.forEach(ve=>{Y([ye],c+ve,r[`defaultValue${ve}`]||S)})}):Y(ce,c,S))}g=this.extendTranslation(g,e,r,p,s),_&&g===c&&this.options.appendNamespaceToMissingKey&&(g=`${d}${f}${c}`),(_||R)&&this.options.parseMissingKeyHandler&&(g=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${d}${f}${c}`:c,R?g:void 0,r))}return i?(p.res=g,p.usedParams=this.getUsedParamsDetails(r),p):g}extendTranslation(e,n,s,r,i){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...s},s.lng||this.language||r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!s.skipInterpolation){s.interpolation&&this.interpolator.init({...s,interpolation:{...this.options.interpolation,...s.interpolation}});const l=G(e)&&(s?.interpolation?.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let d;if(l){const u=e.match(this.interpolator.nestingRegexp);d=u&&u.length}let f=s.replace&&!G(s.replace)?s.replace:s;if(this.options.interpolation.defaultVariables&&(f={...this.options.interpolation.defaultVariables,...f}),e=this.interpolator.interpolate(e,f,s.lng||this.language||r.usedLng,s),l){const u=e.match(this.interpolator.nestingRegexp),m=u&&u.length;d<m&&(s.nest=!1)}!s.lng&&r&&r.res&&(s.lng=this.language||r.usedLng),s.nest!==!1&&(e=this.interpolator.nest(e,(...u)=>i?.[0]===u[0]&&!s.context?(this.logger.warn(`It seems you are nesting recursively key: ${u[0]} in key: ${n[0]}`),null):this.translate(...u,n),s)),s.interpolation&&this.interpolator.reset()}const a=s.postProcess||this.options.postProcess,c=G(a)?[a]:a;return e!=null&&c?.length&&s.applyPostProcessor!==!1&&(e=ul.handle(c,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...r,usedParams:this.getUsedParamsDetails(s)},...s}:s,this)),e}resolve(e,n={}){let s,r,i,a,c;return G(e)&&(e=[e]),Array.isArray(e)&&(e=e.map(l=>typeof l=="function"?Hn(l,{...this.options,...n}):l)),e.forEach(l=>{if(this.isValidLookup(s))return;const d=this.extractFromKey(l,n),f=d.key;r=f;let u=d.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));const m=n.count!==void 0&&!G(n.count),p=m&&!n.ordinal&&n.count===0,g=n.context!==void 0&&(G(n.context)||typeof n.context=="number")&&n.context!=="",x=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);u.forEach(b=>{this.isValidLookup(s)||(c=b,!Ya[`${x[0]}-${b}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(c)&&(Ya[`${x[0]}-${b}`]=!0,this.logger.warn(`key "${r}" for languages "${x.join(", ")}" won't get resolved as namespace "${c}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),x.forEach(j=>{if(this.isValidLookup(s))return;a=j;const C=[f];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(C,f,j,b,n);else{let N;m&&(N=this.pluralResolver.getSuffix(j,n.count,n));const L=`${this.options.pluralSeparator}zero`,P=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(n.ordinal&&N.indexOf(P)===0&&C.push(f+N.replace(P,this.options.pluralSeparator)),C.push(f+N),p&&C.push(f+L)),g){const E=`${f}${this.options.contextSeparator||"_"}${n.context}`;C.push(E),m&&(n.ordinal&&N.indexOf(P)===0&&C.push(E+N.replace(P,this.options.pluralSeparator)),C.push(E+N),p&&C.push(E+L))}}let T;for(;T=C.pop();)this.isValidLookup(s)||(i=T,s=this.getResource(j,b,T,n))}))})}),{res:s,usedKey:r,exactUsedKey:i,usedLng:a,usedNS:c}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,s,r={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,s,r):this.resourceStore.getResource(e,n,s,r)}getUsedParamsDetails(e={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],s=e.replace&&!G(e.replace);let r=s?e.replace:e;if(s&&typeof e.count<"u"&&(r.count=e.count),this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),!s){r={...r};for(const i of n)delete r[i]}return r}static hasDefaultValue(e){const n="defaultValue";for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)&&n===s.substring(0,n.length)&&e[s]!==void 0)return!0;return!1}}class Xa{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=jt.create("languageUtils")}getScriptPartFromCode(e){if(e=Ps(e),!e||e.indexOf("-")<0)return null;const n=e.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(e=Ps(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(G(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let n;return e.forEach(s=>{if(n)return;const r=this.formatLanguageCode(s);(!this.options.supportedLngs||this.isSupportedCode(r))&&(n=r)}),!n&&this.options.supportedLngs&&e.forEach(s=>{if(n)return;const r=this.getScriptPartFromCode(s);if(this.isSupportedCode(r))return n=r;const i=this.getLanguagePartFromCode(s);if(this.isSupportedCode(i))return n=i;n=this.options.supportedLngs.find(a=>{if(a===i)return a;if(!(a.indexOf("-")<0&&i.indexOf("-")<0)&&(a.indexOf("-")>0&&i.indexOf("-")<0&&a.substring(0,a.indexOf("-"))===i||a.indexOf(i)===0&&i.length>1))return a})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),G(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let s=e[n];return s||(s=e[this.getScriptPartFromCode(n)]),s||(s=e[this.formatLanguageCode(n)]),s||(s=e[this.getLanguagePartFromCode(n)]),s||(s=e.default),s||[]}toResolveHierarchy(e,n){const s=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],e),r=[],i=a=>{a&&(this.isSupportedCode(a)?r.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return G(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&i(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&i(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&i(this.getLanguagePartFromCode(e))):G(e)&&i(this.formatLanguageCode(e)),s.forEach(a=>{r.indexOf(a)<0&&i(this.formatLanguageCode(a))}),r}}const Za={zero:0,one:1,two:2,few:3,many:4,other:5},Qa={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Vh{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=jt.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const s=Ps(e==="dev"?"en":e),r=n.ordinal?"ordinal":"cardinal",i=JSON.stringify({cleanedCode:s,type:r});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];let a;try{a=new Intl.PluralRules(s,{type:r})}catch{if(typeof Intl>"u")return this.logger.error("No Intl support, please use an Intl polyfill!"),Qa;if(!e.match(/-|_/))return Qa;const l=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(l,n)}return this.pluralRulesCache[i]=a,a}needsPlural(e,n={}){let s=this.getRule(e,n);return s||(s=this.getRule("dev",n)),s?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,n,s={}){return this.getSuffixes(e,s).map(r=>`${n}${r}`)}getSuffixes(e,n={}){let s=this.getRule(e,n);return s||(s=this.getRule("dev",n)),s?s.resolvedOptions().pluralCategories.sort((r,i)=>Za[r]-Za[i]).map(r=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${r}`):[]}getSuffix(e,n,s={}){const r=this.getRule(e,s);return r?`${this.options.prepend}${s.ordinal?`ordinal${this.options.prepend}`:""}${r.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,s))}}const ec=(t,e,n,s=".",r=!0)=>{let i=Rh(t,e,n);return!i&&r&&G(n)&&(i=ro(t,n,s),i===void 0&&(i=ro(e,n,s))),i},Li=t=>t.replace(/\$/g,"$$$$");class tc{constructor(e={}){this.logger=jt.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(n=>n),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:n,escapeValue:s,useRawValueToEscape:r,prefix:i,prefixEscaped:a,suffix:c,suffixEscaped:l,formatSeparator:d,unescapeSuffix:f,unescapePrefix:u,nestingPrefix:m,nestingPrefixEscaped:p,nestingSuffix:g,nestingSuffixEscaped:x,nestingOptionsSeparator:b,maxReplaces:j,alwaysFormat:C}=e.interpolation;this.escape=n!==void 0?n:Ah,this.escapeValue=s!==void 0?s:!0,this.useRawValueToEscape=r!==void 0?r:!1,this.prefix=i?fn(i):a||"{{",this.suffix=c?fn(c):l||"}}",this.formatSeparator=d||",",this.unescapePrefix=f?"":u||"-",this.unescapeSuffix=this.unescapePrefix?"":f||"",this.nestingPrefix=m?fn(m):p||fn("$t("),this.nestingSuffix=g?fn(g):x||fn(")"),this.nestingOptionsSeparator=b||",",this.maxReplaces=j||1e3,this.alwaysFormat=C!==void 0?C:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,s)=>n?.source===s?(n.lastIndex=0,n):new RegExp(s,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,s,r){let i,a,c;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},d=p=>{if(p.indexOf(this.formatSeparator)<0){const j=ec(n,l,p,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(j,void 0,s,{...r,...n,interpolationkey:p}):j}const g=p.split(this.formatSeparator),x=g.shift().trim(),b=g.join(this.formatSeparator).trim();return this.format(ec(n,l,x,this.options.keySeparator,this.options.ignoreJSONStructure),b,s,{...r,...n,interpolationkey:x})};this.resetRegExp();const f=r?.missingInterpolationHandler||this.options.missingInterpolationHandler,u=r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:p=>Li(p)},{regex:this.regexp,safeValue:p=>this.escapeValue?Li(this.escape(p)):Li(p)}].forEach(p=>{for(c=0;i=p.regex.exec(e);){const g=i[1].trim();if(a=d(g),a===void 0)if(typeof f=="function"){const b=f(e,i,r);a=G(b)?b:""}else if(r&&Object.prototype.hasOwnProperty.call(r,g))a="";else if(u){a=i[0];continue}else this.logger.warn(`missed to pass in variable ${g} for interpolating ${e}`),a="";else!G(a)&&!this.useRawValueToEscape&&(a=qa(a));const x=p.safeValue(a);if(e=e.replace(i[0],x),u?(p.regex.lastIndex+=a.length,p.regex.lastIndex-=i[0].length):p.regex.lastIndex=0,c++,c>=this.maxReplaces)break}}),e}nest(e,n,s={}){let r,i,a;const c=(l,d)=>{const f=this.nestingOptionsSeparator;if(l.indexOf(f)<0)return l;const u=l.split(new RegExp(`${fn(f)}[ ]*{`));let m=`{${u[1]}`;l=u[0],m=this.interpolate(m,a);const p=m.match(/'/g),g=m.match(/"/g);((p?.length??0)%2===0&&!g||(g?.length??0)%2!==0)&&(m=m.replace(/'/g,'"'));try{a=JSON.parse(m),d&&(a={...d,...a})}catch(x){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,x),`${l}${f}${m}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,l};for(;r=this.nestingRegexp.exec(e);){let l=[];a={...s},a=a.replace&&!G(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;const d=/{.*}/.test(r[1])?r[1].lastIndexOf("}")+1:r[1].indexOf(this.formatSeparator);if(d!==-1&&(l=r[1].slice(d).split(this.formatSeparator).map(f=>f.trim()).filter(Boolean),r[1]=r[1].slice(0,d)),i=n(c.call(this,r[1].trim(),a),a),i&&r[0]===e&&!G(i))return i;G(i)||(i=qa(i)),i||(this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`),i=""),l.length&&(i=l.reduce((f,u)=>this.format(f,u,s.lng,{...s,interpolationkey:r[1].trim()}),i.trim())),e=e.replace(r[0],i),this.regexp.lastIndex=0}return e}}const Bh=t=>{let e=t.toLowerCase().trim();const n={};if(t.indexOf("(")>-1){const s=t.split("(");e=s[0].toLowerCase().trim();const r=s[1].substring(0,s[1].length-1);e==="currency"&&r.indexOf(":")<0?n.currency||(n.currency=r.trim()):e==="relativetime"&&r.indexOf(":")<0?n.range||(n.range=r.trim()):r.split(";").forEach(a=>{if(a){const[c,...l]=a.split(":"),d=l.join(":").trim().replace(/^'+|'+$/g,""),f=c.trim();n[f]||(n[f]=d),d==="false"&&(n[f]=!1),d==="true"&&(n[f]=!0),isNaN(d)||(n[f]=parseInt(d,10))}})}return{formatName:e,formatOptions:n}},nc=t=>{const e={};return(n,s,r)=>{let i=r;r&&r.interpolationkey&&r.formatParams&&r.formatParams[r.interpolationkey]&&r[r.interpolationkey]&&(i={...i,[r.interpolationkey]:void 0});const a=s+JSON.stringify(i);let c=e[a];return c||(c=t(Ps(s),r),e[a]=c),c(n)}},Hh=t=>(e,n,s)=>t(Ps(n),s)(e);class qh{constructor(e={}){this.logger=jt.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const s=n.cacheInBuiltFormats?nc:Hh;this.formats={number:s((r,i)=>{const a=new Intl.NumberFormat(r,{...i});return c=>a.format(c)}),currency:s((r,i)=>{const a=new Intl.NumberFormat(r,{...i,style:"currency"});return c=>a.format(c)}),datetime:s((r,i)=>{const a=new Intl.DateTimeFormat(r,{...i});return c=>a.format(c)}),relativetime:s((r,i)=>{const a=new Intl.RelativeTimeFormat(r,{...i});return c=>a.format(c,i.range||"day")}),list:s((r,i)=>{const a=new Intl.ListFormat(r,{...i});return c=>a.format(c)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=nc(n)}format(e,n,s,r={}){const i=n.split(this.formatSeparator);if(i.length>1&&i[0].indexOf("(")>1&&i[0].indexOf(")")<0&&i.find(c=>c.indexOf(")")>-1)){const c=i.findIndex(l=>l.indexOf(")")>-1);i[0]=[i[0],...i.splice(1,c)].join(this.formatSeparator)}return i.reduce((c,l)=>{const{formatName:d,formatOptions:f}=Bh(l);if(this.formats[d]){let u=c;try{const m=r?.formatParams?.[r.interpolationkey]||{},p=m.locale||m.lng||r.locale||r.lng||s;u=this.formats[d](c,p,{...f,...r,...m})}catch(m){this.logger.warn(m)}return u}else this.logger.warn(`there was no format function for ${d}`);return c},e)}}const Wh=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class Kh extends ii{constructor(e,n,s,r={}){super(),this.backend=e,this.store=n,this.services=s,this.languageUtils=s.languageUtils,this.options=r,this.logger=jt.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(s,r.backend,r)}queueLoad(e,n,s,r){const i={},a={},c={},l={};return e.forEach(d=>{let f=!0;n.forEach(u=>{const m=`${d}|${u}`;!s.reload&&this.store.hasResourceBundle(d,u)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?a[m]===void 0&&(a[m]=!0):(this.state[m]=1,f=!1,a[m]===void 0&&(a[m]=!0),i[m]===void 0&&(i[m]=!0),l[u]===void 0&&(l[u]=!0)))}),f||(c[d]=!0)}),(Object.keys(i).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(i),pending:Object.keys(a),toLoadLanguages:Object.keys(c),toLoadNamespaces:Object.keys(l)}}loaded(e,n,s){const r=e.split("|"),i=r[0],a=r[1];n&&this.emit("failedLoading",i,a,n),!n&&s&&this.store.addResourceBundle(i,a,s,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&s&&(this.state[e]=0);const c={};this.queue.forEach(l=>{Ph(l.loaded,[i],a),Wh(l,e),n&&l.errors.push(n),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(d=>{c[d]||(c[d]={});const f=l.loaded[d];f.length&&f.forEach(u=>{c[d][u]===void 0&&(c[d][u]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",c),this.queue=this.queue.filter(l=>!l.done)}read(e,n,s,r=0,i=this.retryTimeout,a){if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:s,tried:r,wait:i,callback:a});return}this.readingCalls++;const c=(d,f)=>{if(this.readingCalls--,this.waitingReads.length>0){const u=this.waitingReads.shift();this.read(u.lng,u.ns,u.fcName,u.tried,u.wait,u.callback)}if(d&&f&&r<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,s,r+1,i*2,a)},i);return}a(d,f)},l=this.backend[s].bind(this.backend);if(l.length===2){try{const d=l(e,n);d&&typeof d.then=="function"?d.then(f=>c(null,f)).catch(c):c(null,d)}catch(d){c(d)}return}return l(e,n,c)}prepareLoading(e,n,s={},r){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),r&&r();G(e)&&(e=this.languageUtils.toResolveHierarchy(e)),G(n)&&(n=[n]);const i=this.queueLoad(e,n,s,r);if(!i.toLoad.length)return i.pending.length||r(),null;i.toLoad.forEach(a=>{this.loadOne(a)})}load(e,n,s){this.prepareLoading(e,n,{},s)}reload(e,n,s){this.prepareLoading(e,n,{reload:!0},s)}loadOne(e,n=""){const s=e.split("|"),r=s[0],i=s[1];this.read(r,i,"read",void 0,void 0,(a,c)=>{a&&this.logger.warn(`${n}loading namespace ${i} for language ${r} failed`,a),!a&&c&&this.logger.log(`${n}loaded namespace ${i} for language ${r}`,c),this.loaded(e,a,c)})}saveMissing(e,n,s,r,i,a={},c=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${s}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(s==null||s==="")){if(this.backend?.create){const l={...a,isUpdate:i},d=this.backend.create.bind(this.backend);if(d.length<6)try{let f;d.length===5?f=d(e,n,s,r,l):f=d(e,n,s,r),f&&typeof f.then=="function"?f.then(u=>c(null,u)).catch(c):c(null,f)}catch(f){c(f)}else d(e,n,s,r,c,l)}!e||!e[0]||this.store.addResource(e[0],n,s,r)}}}const Ai=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if(typeof t[1]=="object"&&(e=t[1]),G(t[1])&&(e.defaultValue=t[1]),G(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const n=t[3]||t[2];Object.keys(n).forEach(s=>{e[s]=n[s]})}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),sc=t=>(G(t.ns)&&(t.ns=[t.ns]),G(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),G(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs?.indexOf?.("cimode")<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),typeof t.initImmediate=="boolean"&&(t.initAsync=t.initImmediate),t),Sr=()=>{},Gh=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})},fl="__i18next_supportNoticeShown",Jh=()=>!!(typeof globalThis<"u"&&globalThis[fl]||typeof process<"u"&&Pi&&Pi.I18NEXT_NO_SUPPORT_NOTICE||typeof process<"u"&&Pi),Yh=()=>{typeof globalThis<"u"&&(globalThis[fl]=!0)},Xh=t=>!!(t?.modules?.backend?.name?.indexOf("Locize")>0||t?.modules?.backend?.constructor?.name?.indexOf("Locize")>0||t?.options?.backend?.backends&&t.options.backend.backends.some(e=>e?.name?.indexOf("Locize")>0||e?.constructor?.name?.indexOf("Locize")>0)||t?.options?.backend?.projectId||t?.options?.backend?.backendOptions&&t.options.backend.backendOptions.some(e=>e?.projectId));class Os extends ii{constructor(e={},n){if(super(),this.options=sc(e),this.services={},this.logger=jt,this.modules={external:[]},Gh(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(e={},n){this.isInitializing=!0,typeof e=="function"&&(n=e,e={}),e.defaultNS==null&&e.ns&&(G(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const s=Ai();this.options={...s,...this.options,...sc(e)},this.options.interpolation={...s.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator),typeof this.options.overloadTranslationOptionHandler!="function"&&(this.options.overloadTranslationOptionHandler=s.overloadTranslationOptionHandler),this.options.showSupportNotice!==!1&&!Xh(this)&&!Jh()&&(typeof console<"u"&&typeof console.info<"u"&&console.info("🌐 i18next is made possible by our own product, Locize — consider powering your project with managed localization (AI, CDN, integrations): https://locize.com 💙"),Yh());const r=d=>d?typeof d=="function"?new d:d:null;if(!this.options.isClone){this.modules.logger?jt.init(r(this.modules.logger),this.options):jt.init(null,this.options);let d;this.modules.formatter?d=this.modules.formatter:d=qh;const f=new Xa(this.options);this.store=new Ja(this.options.resources,this.options);const u=this.services;u.logger=jt,u.resourceStore=this.store,u.languageUtils=f,u.pluralResolver=new Vh(f,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==s.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),d&&(!this.options.interpolation.format||this.options.interpolation.format===s.interpolation.format)&&(u.formatter=r(d),u.formatter.init&&u.formatter.init(u,this.options),this.options.interpolation.format=u.formatter.format.bind(u.formatter)),u.interpolator=new tc(this.options),u.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},u.backendConnector=new Kh(r(this.modules.backend),u.resourceStore,u,this.options),u.backendConnector.on("*",(p,...g)=>{this.emit(p,...g)}),this.modules.languageDetector&&(u.languageDetector=r(this.modules.languageDetector),u.languageDetector.init&&u.languageDetector.init(u,this.options.detection,this.options)),this.modules.i18nFormat&&(u.i18nFormat=r(this.modules.i18nFormat),u.i18nFormat.init&&u.i18nFormat.init(this)),this.translator=new $r(this.services,this.options),this.translator.on("*",(p,...g)=>{this.emit(p,...g)}),this.modules.external.forEach(p=>{p.init&&p.init(this)})}if(this.format=this.options.interpolation.format,n||(n=Sr),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const d=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);d.length>0&&d[0]!=="dev"&&(this.options.lng=d[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(d=>{this[d]=(...f)=>this.store[d](...f)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(d=>{this[d]=(...f)=>(this.store[d](...f),this)});const c=ks(),l=()=>{const d=(f,u)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),c.resolve(u),n(f,u)};if(this.languages&&!this.isInitialized)return d(null,this.t.bind(this));this.changeLanguage(this.options.lng,d)};return this.options.resources||!this.options.initAsync?l():setTimeout(l,0),c}loadResources(e,n=Sr){let s=n;const r=G(e)?e:this.language;if(typeof e=="function"&&(s=e),!this.options.resources||this.options.partialBundledLanguages){if(r?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return s();const i=[],a=c=>{if(!c||c==="cimode")return;this.services.languageUtils.toResolveHierarchy(c).forEach(d=>{d!=="cimode"&&i.indexOf(d)<0&&i.push(d)})};r?a(r):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(l=>a(l)),this.options.preload?.forEach?.(c=>a(c)),this.services.backendConnector.load(i,this.options.ns,c=>{!c&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),s(c)})}else s(null)}reloadResources(e,n,s){const r=ks();return typeof e=="function"&&(s=e,e=void 0),typeof n=="function"&&(s=n,n=void 0),e||(e=this.languages),n||(n=this.options.ns),s||(s=Sr),this.services.backendConnector.reload(e,n,i=>{r.resolve(),s(i)}),r}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&ul.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1)){for(let n=0;n<this.languages.length;n++){const s=this.languages[n];if(!(["cimode","dev"].indexOf(s)>-1)&&this.store.hasLanguageSomeTranslations(s)){this.resolvedLanguage=s;break}}!this.resolvedLanguage&&this.languages.indexOf(e)<0&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,n){this.isLanguageChangingTo=e;const s=ks();this.emit("languageChanging",e);const r=c=>{this.language=c,this.languages=this.services.languageUtils.toResolveHierarchy(c),this.resolvedLanguage=void 0,this.setResolvedLanguage(c)},i=(c,l)=>{l?this.isLanguageChangingTo===e&&(r(l),this.translator.changeLanguage(l),this.isLanguageChangingTo=void 0,this.emit("languageChanged",l),this.logger.log("languageChanged",l)):this.isLanguageChangingTo=void 0,s.resolve((...d)=>this.t(...d)),n&&n(c,(...d)=>this.t(...d))},a=c=>{!e&&!c&&this.services.languageDetector&&(c=[]);const l=G(c)?c:c&&c[0],d=this.store.hasLanguageSomeTranslations(l)?l:this.services.languageUtils.getBestMatchFromCodes(G(c)?[c]:c);d&&(this.language||r(d),this.translator.language||this.translator.changeLanguage(d),this.services.languageDetector?.cacheUserLanguage?.(d)),this.loadResources(d,f=>{i(f,d)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?a(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(e),s}getFixedT(e,n,s){const r=(i,a,...c)=>{let l;typeof a!="object"?l=this.options.overloadTranslationOptionHandler([i,a].concat(c)):l={...a},l.lng=l.lng||r.lng,l.lngs=l.lngs||r.lngs,l.ns=l.ns||r.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||s||r.keyPrefix);const d={...this.options,...l};typeof l.keyPrefix=="function"&&(l.keyPrefix=Hn(l.keyPrefix,d));const f=this.options.keySeparator||".";let u;return l.keyPrefix&&Array.isArray(i)?u=i.map(m=>(typeof m=="function"&&(m=Hn(m,d)),`${l.keyPrefix}${f}${m}`)):(typeof i=="function"&&(i=Hn(i,d)),u=l.keyPrefix?`${l.keyPrefix}${f}${i}`:i),this.t(u,l)};return G(e)?r.lng=e:r.lngs=e,r.ns=n,r.keyPrefix=s,r}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const s=n.lng||this.resolvedLanguage||this.languages[0],r=this.options?this.options.fallbackLng:!1,i=this.languages[this.languages.length-1];if(s.toLowerCase()==="cimode")return!0;const a=(c,l)=>{const d=this.services.backendConnector.state[`${c}|${l}`];return d===-1||d===0||d===2};if(n.precheck){const c=n.precheck(this,a);if(c!==void 0)return c}return!!(this.hasResourceBundle(s,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(s,e)&&(!r||a(i,e)))}loadNamespaces(e,n){const s=ks();return this.options.ns?(G(e)&&(e=[e]),e.forEach(r=>{this.options.ns.indexOf(r)<0&&this.options.ns.push(r)}),this.loadResources(r=>{s.resolve(),n&&n(r)}),s):(n&&n(),Promise.resolve())}loadLanguages(e,n){const s=ks();G(e)&&(e=[e]);const r=this.options.preload||[],i=e.filter(a=>r.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return i.length?(this.options.preload=r.concat(i),this.loadResources(a=>{s.resolve(),n&&n(a)}),s):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{const r=new Intl.Locale(e);if(r&&r.getTextInfo){const i=r.getTextInfo();if(i&&i.direction)return i.direction}}catch{}const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],s=this.services?.languageUtils||new Xa(Ai());return e.toLowerCase().indexOf("-latn")>1?"ltr":n.indexOf(s.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},n){const s=new Os(e,n);return s.createInstance=Os.createInstance,s}cloneInstance(e={},n=Sr){const s=e.forkResourceStore;s&&delete e.forkResourceStore;const r={...this.options,...e,isClone:!0},i=new Os(r);if((e.debug!==void 0||e.prefix!==void 0)&&(i.logger=i.logger.clone(e)),["store","services","language"].forEach(c=>{i[c]=this[c]}),i.services={...this.services},i.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},s){const c=Object.keys(this.store.data).reduce((l,d)=>(l[d]={...this.store.data[d]},l[d]=Object.keys(l[d]).reduce((f,u)=>(f[u]={...l[d][u]},f),l[d]),l),{});i.store=new Ja(c,r),i.services.resourceStore=i.store}if(e.interpolation){const l={...Ai().interpolation,...this.options.interpolation,...e.interpolation},d={...r,interpolation:l};i.services.interpolator=new tc(d)}return i.translator=new $r(i.services,r),i.translator.on("*",(c,...l)=>{i.emit(c,...l)}),i.init(r,n),i.translator.options=r,i.translator.backendConnector.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},i}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const ge=Os.createInstance();ge.createInstance;ge.dir;ge.init;ge.loadResources;ge.reloadResources;ge.use;ge.changeLanguage;ge.getFixedT;ge.t;ge.exists;ge.setDefaultNamespace;ge.hasLoadedNamespace;ge.loadNamespaces;ge.loadLanguages;const{slice:Zh,forEach:Qh}=[];function ef(t){return Qh.call(Zh.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function tf(t){return typeof t!="string"?!1:[/<\s*script.*?>/i,/<\s*\/\s*script\s*>/i,/<\s*img.*?on\w+\s*=/i,/<\s*\w+\s*on\w+\s*=.*?>/i,/javascript\s*:/i,/vbscript\s*:/i,/expression\s*\(/i,/eval\s*\(/i,/alert\s*\(/i,/document\.cookie/i,/document\.write\s*\(/i,/window\.location/i,/innerHTML/i].some(n=>n.test(t))}const rc=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,nf=function(t,e){const s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},r=encodeURIComponent(e);let i=`${t}=${r}`;if(s.maxAge>0){const a=s.maxAge-0;if(Number.isNaN(a))throw new Error("maxAge should be a Number");i+=`; Max-Age=${Math.floor(a)}`}if(s.domain){if(!rc.test(s.domain))throw new TypeError("option domain is invalid");i+=`; Domain=${s.domain}`}if(s.path){if(!rc.test(s.path))throw new TypeError("option path is invalid");i+=`; Path=${s.path}`}if(s.expires){if(typeof s.expires.toUTCString!="function")throw new TypeError("option expires is invalid");i+=`; Expires=${s.expires.toUTCString()}`}if(s.httpOnly&&(i+="; HttpOnly"),s.secure&&(i+="; Secure"),s.sameSite)switch(typeof s.sameSite=="string"?s.sameSite.toLowerCase():s.sameSite){case!0:i+="; SameSite=Strict";break;case"lax":i+="; SameSite=Lax";break;case"strict":i+="; SameSite=Strict";break;case"none":i+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return s.partitioned&&(i+="; Partitioned"),i},ic={create(t,e,n,s){let r=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};n&&(r.expires=new Date,r.expires.setTime(r.expires.getTime()+n*60*1e3)),s&&(r.domain=s),document.cookie=nf(t,e,r)},read(t){const e=`${t}=`,n=document.cookie.split(";");for(let s=0;s<n.length;s++){let r=n[s];for(;r.charAt(0)===" ";)r=r.substring(1,r.length);if(r.indexOf(e)===0)return r.substring(e.length,r.length)}return null},remove(t,e){this.create(t,"",-1,e)}};var sf={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return ic.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:s,cookieDomain:r,cookieOptions:i}=e;n&&typeof document<"u"&&ic.create(n,t,s,r,i)}},rf={name:"querystring",lookup(t){let{lookupQuerystring:e}=t,n;if(typeof window<"u"){let{search:s}=window.location;!window.location.search&&window.location.hash?.indexOf("?")>-1&&(s=window.location.hash.substring(window.location.hash.indexOf("?")));const i=s.substring(1).split("&");for(let a=0;a<i.length;a++){const c=i[a].indexOf("=");c>0&&i[a].substring(0,c)===e&&(n=i[a].substring(c+1))}}return n}},of={name:"hash",lookup(t){let{lookupHash:e,lookupFromHashIndex:n}=t,s;if(typeof window<"u"){const{hash:r}=window.location;if(r&&r.length>2){const i=r.substring(1);if(e){const a=i.split("&");for(let c=0;c<a.length;c++){const l=a[c].indexOf("=");l>0&&a[c].substring(0,l)===e&&(s=a[c].substring(l+1))}}if(s)return s;if(!s&&n>-1){const a=r.match(/\/([a-zA-Z-]*)/g);return Array.isArray(a)?a[typeof n=="number"?n:0]?.replace("/",""):void 0}}}return s}};let Pn=null;const oc=()=>{if(Pn!==null)return Pn;try{if(Pn=typeof window<"u"&&window.localStorage!==null,!Pn)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Pn=!1}return Pn};var af={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&oc())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&oc()&&window.localStorage.setItem(n,t)}};let Rn=null;const ac=()=>{if(Rn!==null)return Rn;try{if(Rn=typeof window<"u"&&window.sessionStorage!==null,!Rn)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Rn=!1}return Rn};var cf={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&ac())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&ac()&&window.sessionStorage.setItem(n,t)}},lf={name:"navigator",lookup(t){const e=[];if(typeof navigator<"u"){const{languages:n,userLanguage:s,language:r}=navigator;if(n)for(let i=0;i<n.length;i++)e.push(n[i]);s&&e.push(s),r&&e.push(r)}return e.length>0?e:void 0}},df={name:"htmlTag",lookup(t){let{htmlTag:e}=t,n;const s=e||(typeof document<"u"?document.documentElement:null);return s&&typeof s.getAttribute=="function"&&(n=s.getAttribute("lang")),n}},uf={name:"path",lookup(t){let{lookupFromPathIndex:e}=t;if(typeof window>"u")return;const n=window.location.pathname.match(/\/([a-zA-Z-]*)/g);return Array.isArray(n)?n[typeof e=="number"?e:0]?.replace("/",""):void 0}},hf={name:"subdomain",lookup(t){let{lookupFromSubdomainIndex:e}=t;const n=typeof e=="number"?e+1:1,s=typeof window<"u"&&window.location?.hostname?.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(s)return s[n]}};let pl=!1;try{document.cookie,pl=!0}catch{}const ml=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];pl||ml.splice(1,1);const ff=()=>({order:ml,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class gl{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.type="languageDetector",this.detectors={},this.init(e,n)}init(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{languageUtils:{}},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=e,this.options=ef(n,this.options||{},ff()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=r=>r.replace("-","_")),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=s,this.addDetector(sf),this.addDetector(rf),this.addDetector(af),this.addDetector(cf),this.addDetector(lf),this.addDetector(df),this.addDetector(uf),this.addDetector(hf),this.addDetector(of)}addDetector(e){return this.detectors[e.name]=e,this}detect(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.order,n=[];return e.forEach(s=>{if(this.detectors[s]){let r=this.detectors[s].lookup(this.options);r&&typeof r=="string"&&(r=[r]),r&&(n=n.concat(r))}}),n=n.filter(s=>s!=null&&!tf(s)).map(s=>this.options.convertDetectedLanguage(s)),this.services&&this.services.languageUtils&&this.services.languageUtils.getBestMatchFromCodes?n:n.length>0?n[0]:null}cacheUserLanguage(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.options.caches;n&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(e)>-1||n.forEach(s=>{this.detectors[s]&&this.detectors[s].cacheUserLanguage(e,this.options)}))}}gl.type="languageDetector";const pf={cancel:"Cancel",create:"Create",add:"Add",remove:"Remove",delete:"Delete",close:"Close",user:"User",permission:"Permission",readOnly:"Read only",readWrite:"Read & write",settings:"Settings",comments:"Comments",files:"Files",outline:"Outline",loading:"Loading…",enabled:"Enabled",disabled:"Disabled",normal:"Active",admin:"Administrator",language:"Language",languageEnglish:"English",languageChinese:"中文"},mf={tagline:"A lightweight LaTeX writing environment",username:"Username",password:"Password",login:"Sign in",contact:"Need an account? Contact {{email}}",firstLogin:"Change your temporary password to continue",currentPassword:"Current password",newPassword:"New password",confirmPassword:"Confirm new password",updatePassword:"Update password",mismatch:"The new passwords do not match",passwordMinimum:"At least {{count}} characters",sessionExpired:"Your session has expired. Please sign in again.",logout:"Sign out"},gf={title:"Projects",subtitle:"Create, edit and share LaTeX documents",restricted:"You can access projects shared with you. Project creation requires administrator permission.",new:"New project",newDescription:"The project will use the configured default LaTeX engine.",name:"Project name",emptyTitle:"Let’s build something great",emptyDescription:"Create a project or upload an existing LaTeX archive to get started.",emptyRestricted:"Projects shared with you will appear here.",noMatches:"No projects match the current search or tag filter.",upload:"Upload project",uploadDescription:"Upload a ZIP archive. A single top-level folder is removed automatically. Maximum file size: {{size}} MB.",zipFile:"ZIP archive",import:"Import project",importing:"Importing…",search:"Search projects…",grid:"Grid",list:"List",scope:"Project status",active:"Active",archived:"Archived",archive:"Archive",unarchive:"Restore",noArchived:"No archived projects.",allTags:"All tags",sortBy:"Sort",sortModified:"Last modified",sortCreated:"Created",pagination:"Project pages",pageOf:"Page {{page}} of {{totalPages}} · {{count}} projects",previousPage:"Previous",nextPage:"Next",owner:"Owner",created:"Created",modified:"Last modified",modifiedBy:"Modified by",byUser:"By {{user}}",modifiedByUser:"{{time}} · By {{user}}",deletedUser:"Deleted user",filterTags:"Filter by tag",rename:"Rename",renameTitle:"Rename project",duplicate:"Duplicate",duplicating:"Duplicating…",duplicateTitle:"Duplicate project",duplicateDescription:"Create an independent copy of {{project}}. Files and project settings are copied; members, comments, Git history and compile output are not.",transfer:"Transfer",transferOwnership:"Transfer ownership",transferDescription:"Choose a new owner for {{project}}.",newOwner:"New owner",chooseNewOwner:"Choose a user",noTransferUsers:"No other active users",transferWarning:"You will keep read/write access. Source files, history, comments and members remain; the saved GitHub token is removed so the new owner can add their own credential.",transferForbidden:"Only the current project owner can transfer ownership.",transferTargetInvalid:"Choose a new project owner.",transferSelf:"You already own this project.",download:"Download",deleteTitle:"Delete project",deleteDescription:"Permanently delete {{project}} and all of its files? This cannot be undone.",chooseZip:"Choose a ZIP project",dropZip:"Drag and drop a ZIP archive here",browse:"Browse files",selectedFileSize:"Selected · {{size}}",clearFile:"Clear selected file"},yf={manage:"User management",back:"Back to projects",onlyAdmin:"Only administrators can create users",add:"Add user",role:"Role",createProjects:"Create projects",ownedProjects:"Owned projects",status:"Status",actions:"Actions",adminRequired:"Administrator permission is required.",allow:"Allow",deny:"Deny",enable:"Enable",disable:"Disable",promote:"Make administrator",demote:"Make user",allowCreate:"Allow creation",denyCreate:"Deny creation",resetPassword:"Reset password",initialPassword:"Login password",displayName:"Display name",addDescription:"Set a login password or generate a secure random one.",createUser:"Create user",randomPassword:"Random password",generatePassword:"Generate a random password",resetDescription:"Set a temporary password for {{username}}. Existing sessions will be signed out.",reset:"Reset",deleteTitle:"Delete user",deleteDescription:"Delete {{username}}? This cannot be undone.",ownedChoice:"{{count}} owned projects",transferProjects:"Transfer them to the current administrator",deleteProjects:"Permanently delete projects and files"},wf={saved:"Saved",savedAt:"Saved to server at {{time}}",loading:"Loading",pending:"Waiting to save",saving:"Saving to server",saveFailed:"Save failed",offlineDraft:"Offline · local draft retained",compile:"Compile · {{engine}}",compiling:"Compiling…",compileQueued:"Compile queued…",compileFailedRetained:"Compilation failed; showing the last successful PDF from {{time}}.",compileFailedNoPdf:"Compilation failed and no successful PDF is available.",upToDate:"Files are up to date; no compilation was needed.",addComment:"Add comment",sourceComments:"Source comments",projectSettings:"Project settings",uploadAttachment:"Upload attachment",newFile:"New text file",binary:"The binary attachment is stored but cannot be opened in the text editor.",noOutline:"No sections in this file",preview:"PDF preview",previewHint:"Compile to generate the document",pdfCompiledAt:"Compiled successfully at {{time}}",pdfCompiledAtFor:"{{file}} compiled successfully at {{time}}",currentMainDocument:"Current document compiled as the root: {{path}}",mainDocumentCandidate:"LaTeX root document candidate: {{path}}",currentMainShort:"root",deletedUser:"Deleted User",orphaned:"Anchor lost",line:"Line {{line}}",reopen:"Reopen",resolve:"Mark resolved",noComments:"No comments in this file",newFileDescription:"Directories are allowed, for example chapters/introduction.tex.",filePath:"File path",commentDescription:"Selected {{count}} characters",pointComment:"No text selected; the comment will be anchored at the cursor.",commentContent:"Comment",backToProjects:"Back to projects",outputTabs:"Compile output",log:"Log",warnings:"Warnings",errors:"Errors",artifacts:"Artifacts",noLog:"Compile to see the log.",noWarnings:"No warnings in the latest compile.",noErrors:"No errors in the latest compile.",projectRoot:"Project root",uploadTo:"Upload to {{folder}}",dropFiles:"Drop files to upload",newFolder:"New folder",folderName:"Folder name",noArtifacts:"Compile to see generated artifacts.",selectArtifact:"Select a text artifact to preview it.",viewArtifact:"View artifact",downloadArtifact:"Download artifact",downloadToView:"Download this artifact to view it",folderDestination:"The folder will be created in {{folder}}.",uploadOverwriteTitle:"File already exists",uploadOverwriteDescription:"These files already exist: {{files}}. Replace them?",uploadOverwrite:"Replace files",collapseFiles:"Collapse file panel",move:"Move",moveTitle:"Move {{name}}",moveDescription:"Choose a destination folder. Files, comments and project paths stay linked.",deletePath:"Delete file or folder",deletePathTitle:"Delete {{name}}",deletePathDescription:"Delete {{path}}? This cannot be undone.",deletePathActiveDescription:"Delete {{path}}? It is currently open for {{users}} and will close in those sessions.",deletePathWillClose:"Any late edits to this path will be rejected to prevent silent data loss.",fileDeletedByCollaborator:"{{path}} was deleted in another session. A safe fallback file has been opened.",destinationFolder:"Destination folder",compileShortcut:"Save and compile (Ctrl+S / Cmd+S)",compilingBy:"{{name}} is compiling",formatSelection:"Format selection",formatting:"Formatting…",formatSelectionHint:"Select LaTeX source to format",formatSelectionRequired:"Select LaTeX source before formatting.",formatSelectionComplete:"Selected LaTeX source formatted.",formatFailedContinue:"Formatting failed; compilation will continue: {{message}}",formatFailed:"Unable to format the selection: {{message}}",formatSourceChanged:"The source changed during formatting, so formatting was skipped.",formatSelectionChanged:"The selected source changed during formatting. Select it again and retry.",vimOn:"Vim ON",vimOnHint:"Vim keybindings are enabled for this editor.",reply:"Reply",replyPlaceholder:"Write a reply…",sendReply:"Send reply",editComment:"Edit comment",deleteComment:"Delete comment",saveChanges:"Save changes",deleteCommentTitle:"Delete comment",deleteCommentDescription:"Delete this comment and its {{count}} replies? This cannot be undone.",editReply:"Edit reply",deleteReply:"Delete reply",deleteReplyTitle:"Delete reply",deleteReplyDescription:"Delete this reply? This cannot be undone.",editedAt:"Edited {{time}}",outlineJump:"Go to source line {{line}} and locate it in the PDF",lineNumber:"line {{line}}",showInSource:"Show the visible PDF location in source",showInPdf:"Show the source cursor location in PDF",pdfLoadFailed:"The PDF preview could not be loaded",pdfZoomControls:"PDF zoom controls",downloadPdf:"Download PDF",downloadResource:"Download file",resourceTooLarge:"This file is {{size}} and exceeds the direct preview limit of {{limit}}.",resourceTooLargeTitle:"File is too large to preview",resourceTooLargeDescription:"Download the file to open it locally.",resourceUnsupportedTitle:"Preview unavailable",resourceUnsupportedDescription:"This file type cannot be rendered in the browser. Download it to open it locally.",resourcePreview:{image:"Image preview",pdf:"PDF preview",text:"Text preview",unsupported:"File preview"},pdfZoomOut:"Zoom out",pdfZoomIn:"Zoom in",pdfFitWidth:"Fit width",layout:{label:"Layout",choose:"Choose layout",current:"Current layout: {{layout}}","editor-pdf":{name:"Editor & PDF",description:"Show the source editor and PDF preview side by side"},"editor-only":{name:"Editor only",description:"Use the workspace for source editing"},"pdf-only":{name:"PDF only",description:"Use the workspace for the PDF and compile output"}},collaboration:{connecting:"Connecting collaboration…",connected:"Live collaboration connected",disconnected:"Collaboration disconnected",editing:"Editing",viewing:"Viewing",joining:"Joining project",reconnect:"Reconnect",activeSessions:"{{count}} active sessions",showMoreSessions:"Show {{count}} more sessions",showFewerSessions:"Collapse session list",sessionTooltip:"{{name}} (@{{username}}) · {{file}} · {{activity}} · {{permission}}"},search:{button:"Find",title:"Find and replace (Ctrl+F / Cmd+F)",find:"Find",replace:"Replace",next:"Next",previous:"Previous",all:"Select all",matchCase:"Match case",regexp:"Regular expression",wholeWord:"Whole word",replaceNext:"Replace",replaceAll:"Replace all",currentMatch:"Current match",onLine:"on line",replacedMatchOnLine:"replaced match on line $",replacedMatches:"replaced $ matches",goToLine:"Go to line",go:"Go",matchCount:"{{count}} matches",noMatches:"No matches",invalidQuery:"Invalid regular expression"}},xf={quickOpen:"Quick open",quickOpenDescription:"Open a project file by name (Ctrl/Cmd+P).",filePlaceholder:"Type a file name…",noFiles:"No matching files.",projectSearch:"Project search",projectSearchDescription:"Search and replace across project source files (Ctrl/Cmd+Shift+F).",searchPlaceholder:"Search all source files…",replacePlaceholder:"Replace with…",matchSummary:"{{count}} matches",truncated:"Showing the first {{count}} matches.",replaceAll:"Replace all {{count}}",replaceConfirmTitle:"Replace across the project",replaceConfirmDescription:"Replace all {{count}} matches? Automatic history records every changed file first.",replaced:"Replaced {{count}} matches in {{files}} files."},bf={title:"History",description:"Browse automatic project versions, compare files and safely restore earlier work.",empty:"No history versions yet.",changedCount:"{{count}} changed files",fileCount:"{{count}} files",changed:"changed",labelPlaceholder:"Name this version",saveLabel:"Save label",compareCurrent:"Compare with current",comparingCurrent:"Earlier version compared with the current file",chooseFile:"Choose a file, then compare it with the current source.",restore:"Restore",restoreFile:"Restore file",restoreProject:"Restore project",restoreFileTitle:"Restore this file",restoreProjectTitle:"Restore this project version",restoreFileDescription:"Restore {{path}} from this version? The current project is checkpointed first.",restoreProjectDescription:"Restore all source files and compiler settings from this version? The current project is checkpointed first.",storage:"History storage",storageUsage:"{{used}} of {{limit}}",versionUsage:"{{count}} of {{limit}} ordinary versions",protectedVersions:"{{count}} labeled",storageExceeded:"Protected or current data exceeds the soft storage limit.",deleteVersion:"Delete version",deleteVersionTitle:"Delete this history version",deleteVersionDescription:"Permanently delete {{name}}? Current project files are not changed.",clearAll:"Clear history",clearAllTitle:"Clear all project history",clearAllDescription:"Permanently delete every history version and its unreferenced stored data? Current project files are not changed.",reasons:{initial:"Project created",autosave:"Automatic save",file:"File operation",settings:"Compiler settings",git:"Git operation",restore:"Restored version",checkpoint:"Safety checkpoint"}},vf={mainFile:"Main document",engine:"Compiler",latexmkrc:"Project latexmkrc",save:"Save project settings",members:"Shared members",recentLog:"Latest compile log",share:"Share project",shareDescription:"Projects can only be shared with users created by an administrator.",chooseUser:"Choose a user",latexmkrcPlaceholder:`# Empty disables the project rc file
|
|
3
|
-
$pdf_mode = 1;`,addMember:"Add member",noMembers:"This project has not been shared with anyone.",removeTitle:"Remove shared member",removeDescription:"Remove {{username}}? Their account and other projects are unaffected.",editorTab:"Editor appearance",compilerTab:"LaTeX compiler",compilerDescription:"Choose the main document and compiler options shared by everyone in this project.",editorAppearance:"Editor appearance",editorAppearanceDescription:"These preferences are private to this user and project on this browser. The project dictionary is shared.",saveAppearance:"Save appearance",saveCompiler:"Save compiler settings",projectConfiguration:"Project configuration",fontFamily:"English font",fontSize:"Font size",lineHeight:"Line spacing",dictionary:"Project dictionary",dictionaryDescription:"Words added here are ignored by spell checking for this project. Editors can maintain this list.",dictionaryPlaceholder:"Add a custom word",addWord:"Add word",dictionaryEmpty:"No custom words yet.",lineWrapping:"Wrap long lines",spellCheck:"Spell checking",vimMode:"Vim keybindings",vimModeDescription:"Use Vim normal/insert/visual modes in this editor.",vimHelp:"View help",formatOnCompile:"Format LaTeX before compiling",formatOnCompileDescription:"Off by default. Formatting runs on the server immediately before compilation.",formatRequiresWrite:"Formatting requires permission to edit this project.",formatterDescription:"Formatting uses the optional host-side tex-fmt command.",formatterInstall:"Install or view tex-fmt documentation",spellingIssues:"{{count}} spelling issues ({{uniqueCount}} unique words)",noSpellingIssues:"No spelling issues found.",spellCheckFirst:"First spelling issue",spellCheckPrevious:"Previous spelling issue",spellCheckNext:"Next spelling issue",spellCheckLast:"Last spelling issue",spellCheckPosition:"{{current}}/{{total}}",fontJetBrains:"JetBrains Mono",fontSourceCode:"Source Code Pro",fontIbmPlex:"IBM Plex Mono",fontFiraCode:"Fira Code",fontIosevka:"Iosevka",lineHeightCompact:"Compact",lineHeightNormal:"Normal",lineHeightRelaxed:"Relaxed"},Sf={title:"Git backup",description:"Manage the local Git history and its GitHub backup. Only the project owner can use these actions.",authentication:"GitHub authentication",authenticationHint:"Use a token with repository Administration and Contents write access. It is encrypted at rest and never written to the repository or remote URL.",recommendedAccessTitle:"Recommended repository access: All repositories",recommendedAccess:"texLite is intended for trusted users. Select All repositories so this token can create a repository and access repositories created later. Grant Administration and Contents read and write permissions.",token:"Personal access token",tokenPlaceholder:"Paste your GitHub token",replaceToken:"Replace personal access token",saveToken:"Save and verify token",createToken:"Create a fine-grained token",connectedAs:"Connected as @{{login}}",removeToken:"Remove token",tokenSaved:"GitHub token saved; the local repository is ready.",tokenRemoved:"GitHub token removed.",repository:"Repository",localReady:"The project source is managed by a local Git repository.",localPending:"Saving a valid token initializes the local Git repository.",repositoryName:"GitHub repository name",privateRepository:"Create as a private repository",createRepository:"Create GitHub repository",repositoryCreated:"GitHub repository created.",origin:"origin",openGitHub:"Open GitHub",clean:"Working tree clean",changedFiles:"{{count}} changed files",commitAndPush:"Commit and push",identity:"Commits use {{username}} <{{username}}@texlite.com> for this command only.",detachedHead:"Detached HEAD: return to the default branch before committing or pushing.",detachedAt:"detached at {{revision}}",commitMessage:"Commit message",commitPlaceholder:"Describe this backup…",commit:"Commit",committed:"Changes committed.",noChangesToCommit:"There are no new changes to commit.",push:"Push",pushed:"Push succeeded. The backup is up to date on GitHub.",pushFailed:"Push failed",workingDiff:"Working diff",refresh:"Refresh",diffTitle:"Diff",diffTruncated:"output truncated",diffFontSize:"Diff font size",diffFontDecrease:"Decrease diff font size",diffFontIncrease:"Increase diff font size",fullscreenDiff:"View diff full screen",exitFullscreenDiff:"Exit full screen",noChanges:"No differences to display.",history:"History",historyHint:"Up to 100 recent commits",noCommits:"No commits yet.",viewCommitDiff:"View this commit's diff",checkoutVersion:"Checkout this version",checkoutTitle:"Checkout version",checkout:"Checkout",checkoutDescription:"Checkout {{revision}} — {{message}}. By default Git preserves compatible uncommitted changes and refuses conflicts.",forceCheckout:"Force overwrite",forceCheckoutDescription:"Explicitly discard tracked and untracked working changes before checkout. This cannot be undone.",returnToBranch:"Return to {{branch}}",returnTitle:"Return to default branch",returnDescription:"Checkout {{branch}}. By default Git preserves compatible uncommitted changes and refuses conflicts.",discardChanges:"Discard changes",noChangesToDiscard:"There are no changes to discard.",discardTitle:"Discard uncommitted changes",discardDescription:"Restore all tracked files to the current HEAD commit. Untracked files are unaffected.",discardConfirm:"Discard changes"},jf={title:"System status",description:"Live server health and recent operation latency. Values refresh every five seconds.",refresh:"Refresh",uptime:"Uptime",memory:"Memory",heap:"heap",compileQueue:"Compile jobs",pending:"{{count}} pending",collaboration:"Collaboration",sessions:"{{count}} sessions",roomsAndDirty:"{{rooms}} rooms · {{dirty}} dirty files",eventLoop:"Event-loop latency",latencySummary:"P50 {{p50Ms}} ms · P95 {{p95Ms}} ms · max {{maxMs}} ms",operationDurations:"Recent operation durations",noSamples:"No operation samples have been collected yet.",operation:"Operation",samples:"Samples",last:"Last",max:"Max",operations:{collaboration:{connect:"Open collaboration room",persist:"Save collaboration changes"},workspace:{project:"Load project metadata",files:"Load project files",compileState:"Load retained PDF state"},compile:{snapshot:"Prepare compile snapshot",request:"Compile request total",cacheSync:"Update compiler cache",latexmk:"Run latexmk",artifactCopy:"Publish compile artifacts"},outline:{build:"Build project outline"},search:{project:"Search project"},completions:{build:"Build completion index"}}},Cf={title:"Tags",add:"Add tag",create:"Create tag",createDescription:"Create a private reusable colored tag for organizing your projects.",assign:"Tags",assignTitle:"Tags for {{project}}",assignDescription:"Select your private tags for this project. Other users have their own tags.",empty:"Create a tag first.",allAssigned:"All available tags are already assigned.",name:"Tag name",color:"Color",filter:"Filter",red:"Red",orange:"Orange",yellow:"Yellow",green:"Green",blue:"Blue",purple:"Purple",gray:"Gray"},kf={generic:"Operation failed",request:"Request failed ({{status}})",upload:"Upload failed",fileExists:"A file or folder with this name already exists.",pathConflict:"The destination path is already used by a folder or file.",duplicateUploadNames:"The selected files contain duplicate names: {{files}}.",fileTooLarge:"The file exceeds the {{size}} MB limit.",zipOnly:"Please choose a ZIP archive.",collaborationUnavailable:"Live collaboration is not connected. Reconnect before saving or compiling.",codes:{AUTH_INVALID:"The username or password is incorrect.",CURRENT_PASSWORD_INVALID:"The current password is incorrect.",USER_NOT_FOUND:"The user no longer exists.",LAST_ADMIN:"At least one administrator must remain active.",SELF_DELETE_FORBIDDEN:"You cannot delete the currently signed-in administrator.",PROJECT_CREATE_FORBIDDEN:"You do not have permission to create projects.",PROJECT_NOT_FOUND:"The project does not exist or is no longer accessible.",PROJECT_OWNER_ONLY:"Only the project owner can change this setting.",PROJECT_EDIT_FORBIDDEN:"You do not have edit permission for this project.",DICTIONARY_EDIT_FORBIDDEN:"You do not have permission to maintain this project's dictionary.",TAG_NOT_FOUND:"The selected tag does not exist.",GIT_TOKEN_INVALID:"Enter a GitHub token.",GIT_REPOSITORY_NAME_INVALID:"Enter a GitHub repository name.",GIT_REVISION_INVALID:"Choose a Git revision to check out.",PROJECT_DELETE_FORBIDDEN:"Only the project owner can delete this project.",MEMBERS_MANAGE_FORBIDDEN:"Only the project owner can manage project members.",OWNER_MEMBER_FORBIDDEN:"The project owner cannot be added as a member.",INVALID_PATH:"The file path is invalid.",RESERVED_PATH:"This path is reserved by TexLite.",PATH_EXISTS:"The destination path is already used by a file or folder.",FILE_EXISTS:"A file with this name already exists.",PATH_NOT_FOUND:"The file or folder does not exist.",FILE_NOT_FOUND:"The file does not exist.",DIRECTORY_NOT_FOUND:"The destination folder does not exist.",MOVE_INTO_SELF:"A folder cannot be moved into itself.",MAIN_FILE_DELETE_FORBIDDEN:"The main document cannot be deleted.",FILE_TOO_LARGE:"This file is too large to open or upload.",UPLOAD_EMPTY:"No file was selected for upload.",COMMENT_FILE_NOT_FOUND:"The file for this comment does not exist.",COMMENT_RANGE_INVALID:"The comment source range is invalid.",COMMENT_NOT_FOUND:"The comment does not exist.",COMMENT_EDIT_FORBIDDEN:"You can only edit your own comments.",COMMENT_DELETE_FORBIDDEN:"You can only delete your own comments.",REPLY_NOT_FOUND:"The reply does not exist.",REPLY_EDIT_FORBIDDEN:"You can only edit your own replies.",REPLY_DELETE_FORBIDDEN:"You can only delete your own replies.",COMMENT_UPDATE_EMPTY:"There is no comment content to update.",MAIN_FILE_NOT_FOUND:"The selected main document does not exist.",LATEXMKRC_DISABLED:"Project latexmkrc files are disabled by the administrator.",LATEXMKRC_NOT_FOUND:"The selected latexmkrc file does not exist.",COMPILE_ARTIFACTS_NOT_FOUND:"No compiled artifacts are available yet.",COMPILE_ARTIFACT_NOT_FOUND:"The compiled artifact does not exist.",ARTIFACT_PREVIEW_UNSUPPORTED:"This artifact cannot be previewed as text; download it instead.",SYNC_SOURCE_INVALID:"The source location is invalid.",SOURCE_FILE_NOT_FOUND:"The source file does not exist.",SYNCTEX_NOT_AVAILABLE:"No SyncTeX data is available. Compile the project again.",SYNC_PDF_INVALID:"The PDF location is invalid.",SYNCTEX_EXTERNAL_PATH:"SyncTeX returned a source path outside the project.",COMPILE_FORBIDDEN:"You do not have permission to compile this project.",PDF_NOT_FOUND:"No PDF has been generated yet.",API_NOT_FOUND:"The API endpoint does not exist.",SERVER_ERROR:"The server could not complete the request.",REQUEST_INVALID:"The request is invalid."}},Ef={historyVersionNotFound:"The selected history version no longer exists.",historyFileNotFound:"This file does not exist in the selected history version.",historyPreviewUnsupported:"This historical file cannot be compared as text.",searchInvalid:"Enter valid text to search for.",gitUnavailable:"Git integration is unavailable. Install Git on the host or correct git.binary in the configuration, then try again.",formatterUnavailable:"tex-fmt is not installed on the host. Install it from https://github.com/wgunderwood/tex-fmt and restart TexLite.",formatFailed:"tex-fmt could not format this source.",mainDocumentInvalid:"The selected file is not a valid LaTeX root document."},Df={copyright:"© {{year}}",credit:"Designed and developed by CHEN Zhongpu"},Nf={section:"Section",subsection:"Subsection",bold:"Bold",emphasis:"Emphasis",citation:"Citation",reference:"Cross-reference",label:"Label",image:"Image",unordered:"Unordered list",ordered:"Ordered list",equation:"Equation",figure:"Figure",projectCommand:"Project command",projectCommandArgs:"Project command ({{count}} arguments)",projectMacro:"Project macro",expl3Command:"Expl3 project command",mathOperator:"Project math operator",mathDelimiter:"Project math delimiter",projectEnvironment:"Project environment",projectFile:"Project file",package:"Package",documentClass:"Document class",currentFile:"Current file",project:"Project",latex:"LaTeX",standard:"LaTeX command"},Tf={common:pf,auth:mf,projects:gf,users:yf,editor:wf,navigation:xf,history:bf,projectSettings:vf,git:Sf,metrics:jf,tags:Cf,errors:kf,apiErrors:Ef,footer:Df,completions:Nf},Of={cancel:"取消",create:"创建",add:"添加",remove:"移除",delete:"删除",close:"关闭",user:"用户",permission:"权限",readOnly:"只读",readWrite:"读写",settings:"设置",comments:"批注",files:"文件",outline:"大纲",loading:"正在载入…",enabled:"允许",disabled:"禁止",normal:"正常",admin:"管理员",language:"语言",languageEnglish:"English",languageChinese:"中文"},_f={tagline:"轻量 LaTeX 写作环境",username:"用户名",password:"密码",login:"登录",contact:"需要账号?请联系 {{email}}",firstLogin:"首次登录,请修改初始密码",currentPassword:"当前密码",newPassword:"新密码",confirmPassword:"确认新密码",updatePassword:"更新密码",mismatch:"两次输入的新密码不一致",passwordMinimum:"至少 {{count}} 位",sessionExpired:"登录状态已过期,请重新登录。",logout:"退出"},Pf={title:"项目",subtitle:"创建、编辑和分享 LaTeX 文档",restricted:"你可以访问别人共享给你的项目;创建权限由管理员授予",new:"新建项目",newDescription:"项目会使用配置文件中的默认 LaTeX 引擎。",name:"项目名称",emptyTitle:"一起创造出色的作品",emptyDescription:"创建新项目,或上传已有的 LaTeX 压缩包开始写作。",emptyRestricted:"共享给你的项目会显示在这里。",noMatches:"没有符合当前搜索或标签筛选条件的项目。",upload:"上传项目",uploadDescription:"上传 ZIP 压缩包;若只有一个顶层目录会自动去除。单文件最大 {{size}} MB。",zipFile:"ZIP 压缩包",import:"导入项目",importing:"正在导入…",search:"搜索项目…",grid:"网格",list:"列表",allTags:"全部标签",sortBy:"排序",sortModified:"最后修改时间",sortCreated:"创建时间",scope:"项目状态",active:"活跃项目",archived:"已归档",archive:"归档",unarchive:"取消归档",noArchived:"还没有归档项目。",pagination:"项目分页",pageOf:"第 {{page}} / {{totalPages}} 页 · 共 {{count}} 个项目",previousPage:"上一页",nextPage:"下一页",owner:"所有者",created:"创建时间",modified:"最后修改",modifiedBy:"最后修改人",byUser:"由 {{user}} 修改",modifiedByUser:"{{time}} · 由 {{user}} 修改",deletedUser:"已删除用户",filterTags:"按标签过滤",rename:"重命名",renameTitle:"重命名项目",duplicate:"复制项目",duplicating:"正在复制…",duplicateTitle:"复制项目",duplicateDescription:"创建“{{project}}”的独立副本。会复制文件和项目设置,但不会复制成员、批注、Git 历史和编译产物。",download:"下载",transfer:"转让",transferOwnership:"转让项目",transferDescription:"为“{{project}}”选择新的所有者。",newOwner:"新所有者",chooseNewOwner:"请选择用户",noTransferUsers:"没有其他可用用户",transferWarning:"转让后你仍保留读写权限。源码、历史、批注和成员不会改变;已保存的 GitHub token 会被移除,由新所有者配置自己的凭据。",transferForbidden:"只有当前项目所有者可以转让项目。",transferTargetInvalid:"请选择新的项目所有者。",transferSelf:"你已经是该项目的所有者。",deleteTitle:"删除项目",deleteDescription:"确定永久删除“{{project}}”及其全部文件吗?此操作不可撤销。",chooseZip:"选择 ZIP 项目",dropZip:"将 ZIP 压缩包拖放到这里",browse:"浏览文件",selectedFileSize:"已选择 · {{size}}",clearFile:"清除已选文件"},Rf={manage:"用户管理",back:"返回项目",onlyAdmin:"仅管理员可以创建用户",add:"添加用户",role:"角色",createProjects:"创建项目",ownedProjects:"拥有项目",status:"状态",actions:"操作",adminRequired:"需要管理员权限。",allow:"允许",deny:"禁止",enable:"启用",disable:"禁用",promote:"设为管理员",demote:"降为用户",allowCreate:"允许创建",denyCreate:"禁止创建",resetPassword:"重置密码",initialPassword:"登录密码",displayName:"显示名称",addDescription:"设置登录密码,或生成一个安全的随机密码。",createUser:"创建用户",randomPassword:"随机密码",generatePassword:"生成随机密码",resetDescription:"为 {{username}} 设置初始密码;其现有会话会被注销。",reset:"重置",deleteTitle:"删除用户",deleteDescription:"确认删除 {{username}}?此操作不可撤销。",ownedChoice:"其拥有的 {{count}} 个项目",transferProjects:"转移给当前管理员",deleteProjects:"永久删除项目及全部文件"},Lf={saved:"已保存",savedAt:"已于 {{time}} 保存到服务器",loading:"载入中",pending:"等待保存",saving:"正在保存到服务器",saveFailed:"保存失败",offlineDraft:"离线 · 本地草稿已保留",compile:"编译 · {{engine}}",compiling:"编译中…",compileQueued:"编译已排队…",compileFailedRetained:"编译失败,当前显示上一次成功生成的 PDF({{time}})。",compileFailedNoPdf:"编译失败,且没有可用的成功 PDF。",upToDate:"文件已是最新,无需重新编译。",addComment:"添加批注",sourceComments:"源码批注",projectSettings:"项目设置",uploadAttachment:"上传附件",newFile:"新建文本文件",binary:"二进制附件已保存,但不能在文本编辑器中打开。",noOutline:"当前文件没有章节",preview:"PDF 预览",previewHint:"点击“编译”生成文档",pdfCompiledAt:"成功编译于 {{time}}",pdfCompiledAtFor:"{{file}} 成功编译于 {{time}}",currentMainDocument:"当前作为主文档编译:{{path}}",mainDocumentCandidate:"LaTeX 主文档候选:{{path}}",currentMainShort:"主文档",deletedUser:"已删除用户",orphaned:"锚点已丢失",line:"第 {{line}} 行",reopen:"重新打开",resolve:"标记为已解决",noComments:"当前文件没有批注",newFileDescription:"可以包含目录,例如 chapters/introduction.tex。",filePath:"文件路径",commentDescription:"已选择 {{count}} 个字符",pointComment:"未选择文本,将在当前光标位置添加批注。",commentContent:"批注内容",backToProjects:"返回项目列表",outputTabs:"编译输出",log:"日志",warnings:"警告",errors:"错误",artifacts:"产物",noLog:"编译后将在此显示日志。",noWarnings:"最近一次编译没有警告。",noErrors:"最近一次编译没有错误。",projectRoot:"项目根目录",uploadTo:"上传到 {{folder}}",dropFiles:"拖放文件以上传",newFolder:"新建文件夹",folderName:"文件夹名称",folderDestination:"文件夹将创建在 {{folder}} 中。",uploadOverwriteTitle:"文件已存在",uploadOverwriteDescription:"以下文件已经存在:{{files}}。要覆盖它们吗?",uploadOverwrite:"覆盖文件",noArtifacts:"编译后将在此显示输出产物。",selectArtifact:"选择一个文本产物进行预览。",viewArtifact:"查看产物",downloadArtifact:"下载产物",downloadToView:"该产物需要下载后查看",collapseFiles:"折叠文件面板",move:"移动",moveTitle:"移动 {{name}}",moveDescription:"选择目标文件夹;源码、批注和项目路径会保持关联。",destinationFolder:"目标文件夹",deletePath:"删除文件或文件夹",deletePathTitle:"删除 {{name}}",deletePathDescription:"确定删除 {{path}}?此操作不可撤销。",deletePathActiveDescription:"确定删除 {{path}}?{{users}} 当前正在打开它,删除后这些会话将关闭该文件。",deletePathWillClose:"系统会拒绝该路径上迟到的修改,避免内容被静默丢失。",fileDeletedByCollaborator:"{{path}} 已在其他会话中删除,现已打开安全的备用文件。",compileShortcut:"保存并编译(Ctrl+S / Cmd+S)",compilingBy:"{{name}} 正在编译",formatSelection:"格式化选区",formatting:"正在格式化…",formatSelectionHint:"选择一段 LaTeX 源码后格式化",formatSelectionRequired:"请先选择 LaTeX 源码,再进行格式化。",formatSelectionComplete:"所选 LaTeX 源码已格式化。",formatFailedContinue:"格式化失败,仍将继续编译:{{message}}",formatFailed:"无法格式化选区:{{message}}",formatSourceChanged:"格式化期间源码已发生变化,已跳过本次格式化。",formatSelectionChanged:"格式化期间所选源码已发生变化,请重新选择后再试。",vimOn:"Vim 已开启",vimOnHint:"当前编辑器已启用 Vim 键位。",reply:"回复",replyPlaceholder:"输入回复内容…",sendReply:"发送回复",editComment:"编辑批注",deleteComment:"删除批注",saveChanges:"保存修改",deleteCommentTitle:"删除批注",deleteCommentDescription:"确定删除这条批注及其 {{count}} 条回复吗?此操作不可撤销。",editReply:"编辑回复",deleteReply:"删除回复",deleteReplyTitle:"删除回复",deleteReplyDescription:"确定删除这条回复吗?此操作不可撤销。",editedAt:"编辑于 {{time}}",outlineJump:"跳转到源码第 {{line}} 行并定位 PDF",lineNumber:"第 {{line}} 行",showInSource:"在源码中显示当前 PDF 位置",showInPdf:"在 PDF 中显示当前源码光标位置",pdfLoadFailed:"无法载入 PDF 预览",pdfZoomControls:"PDF 缩放控件",downloadPdf:"下载 PDF",downloadResource:"下载文件",resourceTooLarge:"该文件大小为 {{size}},超过 {{limit}} 的直接预览上限。",resourceTooLargeTitle:"文件过大,无法直接预览",resourceTooLargeDescription:"请下载文件后在本地打开。",resourceUnsupportedTitle:"无法预览",resourceUnsupportedDescription:"浏览器不能直接渲染此文件类型,请下载后在本地打开。",resourcePreview:{image:"图片预览",pdf:"PDF 预览",text:"文本预览",unsupported:"文件预览"},pdfZoomOut:"缩小",pdfZoomIn:"放大",pdfFitWidth:"适合宽度",layout:{label:"布局",choose:"选择布局",current:"当前布局:{{layout}}","editor-pdf":{name:"编辑器与 PDF",description:"并排显示源码编辑器和 PDF 预览"},"editor-only":{name:"仅编辑器",description:"将工作区用于源码编辑"},"pdf-only":{name:"仅 PDF",description:"将工作区用于 PDF 和编译输出"}},collaboration:{connecting:"正在连接协作服务…",connected:"实时协作已连接",disconnected:"实时协作连接已断开",editing:"正在编辑",viewing:"正在查看",joining:"正在进入项目",reconnect:"重新连接",activeSessions:"{{count}} 个活跃会话",showMoreSessions:"展开另外 {{count}} 个会话",showFewerSessions:"收起会话列表",sessionTooltip:"{{name}}(@{{username}})· {{file}} · {{activity}} · {{permission}}"},search:{button:"查找",title:"查找和替换(Ctrl+F / Cmd+F)",find:"查找",replace:"替换为",next:"下一个",previous:"上一个",all:"选择全部",matchCase:"区分大小写",regexp:"正则表达式",wholeWord:"全字匹配",replaceNext:"替换",replaceAll:"全部替换",currentMatch:"当前匹配",onLine:"位于行",replacedMatchOnLine:"已替换第 $ 行的匹配项",replacedMatches:"已替换 $ 个匹配项",goToLine:"跳转到行",go:"跳转",matchCount:"共 {{count}} 个匹配",noMatches:"没有匹配项",invalidQuery:"正则表达式无效"}},Af={quickOpen:"快速打开",quickOpenDescription:"按名称打开项目文件(Ctrl/Cmd+P)。",filePlaceholder:"输入文件名…",noFiles:"没有匹配的文件。",projectSearch:"项目搜索",projectSearchDescription:"在项目源码文件中搜索和替换(Ctrl/Cmd+Shift+F)。",searchPlaceholder:"搜索全部源码文件…",replacePlaceholder:"替换为…",matchSummary:"共 {{count}} 个匹配",truncated:"仅显示前 {{count}} 个匹配。",replaceAll:"替换全部 {{count}} 项",replaceConfirmTitle:"在项目中批量替换",replaceConfirmDescription:"确定替换全部 {{count}} 个匹配?自动历史会记录所有修改文件。",replaced:"已在 {{files}} 个文件中替换 {{count}} 项。"},Ff={title:"历史",description:"浏览自动项目版本、比较文件,并安全恢复较早的工作。",empty:"尚无历史版本。",changedCount:"{{count}} 个文件有变化",fileCount:"{{count}} 个文件",changed:"有修改",labelPlaceholder:"为此版本命名",saveLabel:"保存标签",compareCurrent:"与当前版本比较",comparingCurrent:"历史版本与当前文件的比较",chooseFile:"选择文件后,可与当前源码进行比较。",restore:"恢复",restoreFile:"恢复文件",restoreProject:"恢复项目",restoreFileTitle:"恢复此文件",restoreProjectTitle:"恢复此项目版本",restoreFileDescription:"从此版本恢复 {{path}}?系统会先为当前项目创建安全检查点。",restoreProjectDescription:"恢复此版本的全部源码和编译器设置?系统会先为当前项目创建安全检查点。",storage:"历史存储",storageUsage:"已使用 {{used}},上限 {{limit}}",versionUsage:"普通版本 {{count}} / {{limit}}",protectedVersions:"{{count}} 个已标记版本",storageExceeded:"受保护版本或当前基线已超过存储软上限。",deleteVersion:"删除版本",deleteVersionTitle:"删除此历史版本",deleteVersionDescription:"永久删除“{{name}}”?当前项目文件不会改变。",clearAll:"清空历史",clearAllTitle:"清空全部项目历史",clearAllDescription:"永久删除全部历史版本及不再引用的存储数据?当前项目文件不会改变。",reasons:{initial:"项目创建",autosave:"自动保存",file:"文件操作",settings:"编译器设置",git:"Git 操作",restore:"恢复版本",checkpoint:"安全检查点"}},If={mainFile:"主文档",engine:"编译引擎",latexmkrc:"项目 latexmkrc",save:"保存项目设置",members:"共享成员",recentLog:"最近编译日志",share:"共享项目",shareDescription:"仅可共享给管理员已创建的用户。",chooseUser:"请选择用户",latexmkrcPlaceholder:`# 留空表示不使用项目 rc 文件
|
|
4
|
-
$pdf_mode = 1;`,addMember:"添加成员",noMembers:"该项目尚未分享给其他成员。",removeTitle:"移除共享成员",removeDescription:"确认移除 {{username}}?其账号和其他项目不会受到影响。",editorTab:"编辑器外观",compilerTab:"LaTeX 编译器",compilerDescription:"选择本项目所有成员共享的主文档和 LaTeX 编译选项。",editorAppearance:"编辑器外观",editorAppearanceDescription:"这些偏好仅作用于当前浏览器中的当前用户和项目;项目词典是共享的。",saveAppearance:"保存外观设置",saveCompiler:"保存编译器设置",projectConfiguration:"项目配置",fontFamily:"英文字体",fontSize:"字体大小",lineHeight:"行间距",dictionary:"项目词典",dictionaryDescription:"添加到这里的词不会在本项目的拼写检查中标记;具有编辑权限的用户可以维护此列表。",dictionaryPlaceholder:"添加自定义词",addWord:"添加词",dictionaryEmpty:"暂未添加自定义词。",lineWrapping:"自动换行",spellCheck:"单词拼写检查",vimMode:"Vim 键位",vimModeDescription:"在当前编辑器中使用 Vim 的普通、插入和可视模式。",vimHelp:"查看帮助",formatOnCompile:"编译前自动格式化 LaTeX",formatOnCompileDescription:"默认关闭;格式化会在编译前由服务器执行。",formatRequiresWrite:"需要项目编辑权限才能使用格式化。",formatterDescription:"格式化使用宿主机上的可选 tex-fmt 命令。",formatterInstall:"安装或查看 tex-fmt 文档",spellingIssues:"发现 {{count}} 个拼写问题(去重后 {{uniqueCount}} 个)",noSpellingIssues:"未发现拼写问题。",spellCheckFirst:"第一个拼写问题",spellCheckPrevious:"上一个拼写问题",spellCheckNext:"下一个拼写问题",spellCheckLast:"最后一个拼写问题",spellCheckPosition:"第 {{current}}/{{total}} 个",fontJetBrains:"JetBrains Mono",fontSourceCode:"Source Code Pro",fontIbmPlex:"IBM Plex Mono",fontFiraCode:"Fira Code",fontIosevka:"Iosevka",lineHeightCompact:"紧凑",lineHeightNormal:"标准",lineHeightRelaxed:"宽松"},Mf={title:"Git 备份",description:"管理本地 Git 历史及 GitHub 备份;只有项目创建者可以执行这些操作。",authentication:"GitHub 身份验证",authenticationHint:"token 需要仓库 Administration 与 Contents 写权限;它会加密保存,不会写入项目仓库或远程地址。",recommendedAccessTitle:"建议的仓库访问范围:All repositories(所有仓库)",recommendedAccess:"texLite 面向相互信任的用户。请选择 All repositories,使该 token 能创建仓库,并访问之后新建的仓库;同时授予 Administration 和 Contents 的 Read and write 权限。",token:"个人访问 token",tokenPlaceholder:"在此粘贴 GitHub token",replaceToken:"替换个人访问 token",saveToken:"保存并验证 token",createToken:"创建细粒度 token",connectedAs:"已连接为 @{{login}}",removeToken:"移除 token",tokenSaved:"GitHub token 已保存,本地仓库已就绪。",tokenRemoved:"GitHub token 已移除。",repository:"仓库",localReady:"项目源码已由本地 Git 仓库管理。",localPending:"保存有效 token 后将自动初始化本地 Git 仓库。",repositoryName:"GitHub 仓库名称",privateRepository:"创建为私有仓库",createRepository:"创建 GitHub 仓库",repositoryCreated:"GitHub 仓库创建成功。",origin:"远程仓库",openGitHub:"打开 GitHub",clean:"工作区干净",changedFiles:"{{count}} 个文件有修改",commitAndPush:"提交与推送",identity:"本次提交临时使用 {{username}} <{{username}}@texlite.com>,不会写入 Git 配置。",detachedHead:"当前处于 detached HEAD;请先返回默认分支再提交或推送。",detachedAt:"detached 于 {{revision}}",commitMessage:"提交说明",commitPlaceholder:"说明本次备份的内容…",commit:"提交",committed:"修改已提交。",noChangesToCommit:"当前没有新的修改可以提交。",push:"推送",pushed:"推送成功,GitHub 备份已是最新。",pushFailed:"推送失败",workingDiff:"当前差异",refresh:"刷新",diffTitle:"差异",diffTruncated:"输出已截断",diffFontSize:"差异字体大小",diffFontDecrease:"减小差异字体",diffFontIncrease:"增大差异字体",fullscreenDiff:"全屏查看差异",exitFullscreenDiff:"退出全屏",noChanges:"没有可显示的差异。",history:"提交历史",historyHint:"最多显示最近 100 次提交",noCommits:"尚无提交。",viewCommitDiff:"查看该提交的差异",checkoutVersion:"checkout 到该版本",checkoutTitle:"Checkout 版本",checkout:"Checkout",checkoutDescription:"将 checkout 到 {{revision}} — {{message}}。默认由 Git 保留兼容的未提交修改,发生冲突时拒绝操作。",forceCheckout:"强制覆盖",forceCheckoutDescription:"明确丢弃所有已跟踪及未跟踪的工作区修改后再 checkout;此操作不可撤销。",returnToBranch:"返回 {{branch}}",returnTitle:"返回默认分支",returnDescription:"将 checkout 到 {{branch}}。默认由 Git 保留兼容的未提交修改,发生冲突时拒绝操作。",discardChanges:"撤销修改",noChangesToDiscard:"当前没有可以撤销的修改。",discardTitle:"撤销未提交修改",discardDescription:"把所有已跟踪文件恢复到当前 HEAD(上次 commit)。未跟踪文件不受影响。",discardConfirm:"确认撤销"},$f={title:"系统状态",description:"服务器实时健康状态和近期操作耗时,每五秒自动刷新。",refresh:"刷新",uptime:"运行时间",memory:"内存",heap:"堆内存",compileQueue:"编译任务",pending:"{{count}} 个等待中",collaboration:"协作",sessions:"{{count}} 个会话",roomsAndDirty:"{{rooms}} 个房间 · {{dirty}} 个待保存文件",eventLoop:"事件循环延迟",latencySummary:"P50 {{p50Ms}} ms · P95 {{p95Ms}} ms · 最大 {{maxMs}} ms",operationDurations:"近期操作耗时",noSamples:"尚未采集到操作样本。",operation:"操作",samples:"样本",last:"最近",max:"最大",operations:{collaboration:{connect:"打开协作房间",persist:"保存协作修改"},workspace:{project:"加载项目元数据",files:"加载项目文件",compileState:"加载保留的 PDF 状态"},compile:{snapshot:"准备编译快照",request:"编译请求总耗时",cacheSync:"更新编译缓存",latexmk:"运行 latexmk",artifactCopy:"发布编译产物"},outline:{build:"生成项目大纲"},search:{project:"项目内搜索"},completions:{build:"生成补全索引"}}},Uf={title:"标签",add:"添加标签",create:"新建标签",createDescription:"创建仅自己可见的可复用彩色标签,用于整理项目。",assign:"标签",assignTitle:"“{{project}}”的标签",assignDescription:"勾选你为此项目设置的私有标签;其他用户拥有各自的标签。",empty:"请先创建标签。",allAssigned:"所有可用标签均已添加。",name:"标签名称",color:"颜色",filter:"筛选",red:"红色",orange:"橙色",yellow:"黄色",green:"绿色",blue:"蓝色",purple:"紫色",gray:"灰色"},zf={generic:"操作失败",request:"请求失败({{status}})",upload:"上传失败",fileExists:"同名文件或文件夹已经存在。",pathConflict:"目标路径已经被文件或文件夹占用。",duplicateUploadNames:"所选文件中存在重复名称:{{files}}。",fileTooLarge:"文件超过 {{size}} MB 限制。",zipOnly:"请选择 ZIP 压缩包。",collaborationUnavailable:"实时协作尚未连接,请在重新连接后保存或编译。",codes:{AUTH_INVALID:"用户名或密码错误。",CURRENT_PASSWORD_INVALID:"当前密码错误。",USER_NOT_FOUND:"用户不存在或已被删除。",LAST_ADMIN:"系统必须保留至少一名可用管理员。",SELF_DELETE_FORBIDDEN:"不能删除当前登录的管理员。",PROJECT_CREATE_FORBIDDEN:"管理员尚未授予你创建项目的权限。",PROJECT_NOT_FOUND:"项目不存在或你已无法访问。",PROJECT_OWNER_ONLY:"只有项目所有者可以修改此设置。",PROJECT_EDIT_FORBIDDEN:"你没有此项目的编辑权限。",DICTIONARY_EDIT_FORBIDDEN:"你没有维护本项目词典的权限。",TAG_NOT_FOUND:"所选标签不存在。",GIT_TOKEN_INVALID:"请输入 GitHub token。",GIT_REPOSITORY_NAME_INVALID:"请输入 GitHub 仓库名称。",GIT_REVISION_INVALID:"请选择要 checkout 的 Git 版本。",PROJECT_DELETE_FORBIDDEN:"只有项目所有者可以删除项目。",MEMBERS_MANAGE_FORBIDDEN:"只有项目所有者可以管理项目成员。",OWNER_MEMBER_FORBIDDEN:"项目所有者不能作为成员添加。",INVALID_PATH:"文件路径无效。",RESERVED_PATH:"此路径由 TexLite 保留。",PATH_EXISTS:"目标路径已被文件或文件夹占用。",FILE_EXISTS:"同名文件已经存在。",PATH_NOT_FOUND:"文件或文件夹不存在。",FILE_NOT_FOUND:"文件不存在。",DIRECTORY_NOT_FOUND:"目标文件夹不存在。",MOVE_INTO_SELF:"不能把文件夹移动到自身内部。",MAIN_FILE_DELETE_FORBIDDEN:"不能删除主文档。",FILE_TOO_LARGE:"文件过大,无法打开或上传。",UPLOAD_EMPTY:"没有选择要上传的文件。",COMMENT_FILE_NOT_FOUND:"批注对应的文件不存在。",COMMENT_RANGE_INVALID:"批注的源码区间无效。",COMMENT_NOT_FOUND:"批注不存在。",COMMENT_EDIT_FORBIDDEN:"只能编辑自己的批注。",COMMENT_DELETE_FORBIDDEN:"只能删除自己的批注。",REPLY_NOT_FOUND:"回复不存在。",REPLY_EDIT_FORBIDDEN:"只能编辑自己的回复。",REPLY_DELETE_FORBIDDEN:"只能删除自己的回复。",COMMENT_UPDATE_EMPTY:"没有可更新的批注内容。",MAIN_FILE_NOT_FOUND:"所选主文档不存在。",LATEXMKRC_DISABLED:"管理员已禁用项目级 latexmkrc。",LATEXMKRC_NOT_FOUND:"所选 latexmkrc 文件不存在。",COMPILE_ARTIFACTS_NOT_FOUND:"尚无可用的编译产物。",COMPILE_ARTIFACT_NOT_FOUND:"编译产物不存在。",ARTIFACT_PREVIEW_UNSUPPORTED:"该产物不能作为文本预览,请下载后查看。",SYNC_SOURCE_INVALID:"源码位置无效。",SOURCE_FILE_NOT_FOUND:"源码文件不存在。",SYNCTEX_NOT_AVAILABLE:"尚无可用的 SyncTeX 数据,请重新编译。",SYNC_PDF_INVALID:"PDF 位置无效。",SYNCTEX_EXTERNAL_PATH:"SyncTeX 返回了项目外部的源码路径。",COMPILE_FORBIDDEN:"你没有编译此项目的权限。",PDF_NOT_FOUND:"尚未生成 PDF。",API_NOT_FOUND:"接口不存在。",SERVER_ERROR:"服务器无法完成请求。",REQUEST_INVALID:"请求格式无效。"}},Vf={historyVersionNotFound:"所选历史版本已不存在。",historyFileNotFound:"所选历史版本中没有这个文件。",historyPreviewUnsupported:"这个历史文件不能作为文本比较。",searchInvalid:"请输入有效的搜索内容。",gitUnavailable:"Git 集成功能不可用。请在宿主机安装 Git,或修正配置中的 git.binary 后重试。",formatterUnavailable:"宿主机未安装 tex-fmt。请访问 https://github.com/wgunderwood/tex-fmt 安装后重启 TexLite。",formatFailed:"tex-fmt 无法格式化这段源码。",mainDocumentInvalid:"所选文件不是有效的 LaTeX 主文档。"},Bf={copyright:"© {{year}}",credit:"Designed and developed by CHEN Zhongpu"},Hf={section:"章节",subsection:"小节",bold:"粗体",emphasis:"强调",citation:"引用文献",reference:"交叉引用",label:"标签",image:"插入图片",unordered:"无序列表",ordered:"有序列表",equation:"公式",figure:"图片环境",projectCommand:"项目命令",projectCommandArgs:"项目命令({{count}} 个参数)",projectMacro:"项目宏",expl3Command:"Expl3 项目命令",mathOperator:"项目数学算子",mathDelimiter:"项目数学定界符",projectEnvironment:"项目环境",projectFile:"项目文件",package:"宏包",documentClass:"文档类",currentFile:"当前文件",project:"项目",latex:"LaTeX",standard:"LaTeX 命令"},qf={common:Of,auth:_f,projects:Pf,users:Rf,editor:Lf,navigation:Af,history:Ff,projectSettings:If,git:Mf,metrics:$f,tags:Uf,errors:zf,apiErrors:Vf,footer:Bf,completions:Hf};ge.use(gl).use(jh).init({resources:{en:{translation:Tf},zh:{translation:qf}},fallbackLng:"en",supportedLngs:["en","zh"],nonExplicitSupportedLngs:!0,interpolation:{escapeValue:!1},detection:{order:["localStorage","navigator"],caches:["localStorage"]}});class Po extends Error{constructor(e,n,s=null){super(e),this.status=n,this.code=s}status;code}async function A(t,e={}){const n=await fetch(t,{...e,headers:e.body?{"Content-Type":"application/json",...e.headers}:e.headers}),r=(n.headers.get("content-type")??"").includes("application/json")?await n.json():null;if(!n.ok)throw n.status===401&&typeof window<"u"&&window.dispatchEvent(new Event("texlite:session-expired")),new Po(Ro(r,n.status),n.status,yl(r));return r}function Ro(t,e,n="errors.request"){const s=typeof t=="object"&&t!==null&&"error"in t&&typeof t.error=="string"?t.error:"",r=yl(t);if(r){const i={AUTH_REQUIRED:"auth.sessionExpired",ADMIN_REQUIRED:"users.adminRequired",HISTORY_VERSION_NOT_FOUND:"apiErrors.historyVersionNotFound",HISTORY_FILE_NOT_FOUND:"apiErrors.historyFileNotFound",HISTORY_FILE_PREVIEW_UNSUPPORTED:"apiErrors.historyPreviewUnsupported",SEARCH_QUERY_INVALID:"apiErrors.searchInvalid",GIT_UNAVAILABLE:"apiErrors.gitUnavailable",FORMATTER_UNAVAILABLE:"apiErrors.formatterUnavailable",FORMAT_FAILED:"apiErrors.formatFailed",PROJECT_TRANSFER_FORBIDDEN:"projects.transferForbidden",PROJECT_TRANSFER_TARGET_INVALID:"projects.transferTargetInvalid",PROJECT_TRANSFER_SELF:"projects.transferSelf",MAIN_DOCUMENT_INVALID:"apiErrors.mainDocumentInvalid"}[r]??`errors.codes.${r}`;if(ge.exists(i))return ge.t(i,{status:e,...typeof t=="object"&&t!==null?t:{}})}return ge.resolvedLanguage?.startsWith("zh")&&s?s:ge.t(n,{status:e})}function yl(t){return typeof t!="object"||t===null||!("code"in t)||typeof t.code!="string"?null:t.code}var Wf=Object.defineProperty,ls=(t,e)=>Wf(t,"name",{value:e,configurable:!0}),wl=!!(typeof window<"u"&&window.document&&window.document.createElement);function sn(t,e,{checkForDefaultPrevented:n=!0}={}){return ls(function(r){if(t?.(r),n===!1||!r||!r.defaultPrevented)return e?.(r)},"handleEvent")}ls(sn,"composeEventHandlers");function Kf(t){if(!wl)throw new Error("Cannot access window outside of the DOM");return t?.ownerDocument?.defaultView??window}ls(Kf,"getOwnerWindow");function io(t){if(!wl)throw new Error("Cannot access document outside of the DOM");return t?.ownerDocument??document}ls(io,"getOwnerDocument");function xl(t,e=!1){const{activeElement:n}=io(t);if(!n?.nodeName)return null;if(bl(n)&&n.contentDocument)return xl(n.contentDocument.body,e);if(e){const s=n.getAttribute("aria-activedescendant");if(s){const r=io(n).getElementById(s);if(r)return r}}return n}ls(xl,"getActiveElement");function bl(t){return t.tagName==="IFRAME"}ls(bl,"isFrame");var Gf=Object.defineProperty,Lo=(t,e)=>Gf(t,"name",{value:e,configurable:!0});function oo(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}Lo(oo,"setRef");function vl(...t){return e=>{let n=!1;const s=t.map(r=>{const i=oo(r,e);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let r=0;r<s.length;r++){const i=s[r];typeof i=="function"?i():oo(t[r],null)}}}}Lo(vl,"composeRefs");function ds(...t){return h.useCallback(vl(...t),t)}Lo(ds,"useComposedRefs");var Jf=Object.defineProperty,ot=(t,e)=>Jf(t,"name",{value:e,configurable:!0});function Yf(t,e){const n=h.createContext(e);n.displayName=t+"Context";const s=ot(i=>{const{children:a,...c}=i,l=h.useMemo(()=>c,Object.values(c));return o.jsx(n.Provider,{value:l,children:a})},"Provider");s.displayName=t+"Provider";function r(i,a={}){const{optional:c=!1}=a,l=h.useContext(n);if(l)return l;if(e!==void 0)return e;if(!c)throw new Error(`\`${i}\` must be used within \`${t}\``)}return ot(r,"useContext"),[s,r]}ot(Yf,"createContext");function Sl(t,e=[]){let n=[];function s(i,a){const c=h.createContext(a);c.displayName=i+"Context";const l=n.length;n=[...n,a];const d=ot(u=>{const{scope:m,children:p,...g}=u,x=m?.[t]?.[l]||c,b=h.useMemo(()=>g,Object.values(g));return o.jsx(x.Provider,{value:b,children:p})},"Provider");d.displayName=i+"Provider";function f(u,m,p={}){const{optional:g=!1}=p,x=m?.[t]?.[l]||c,b=h.useContext(x);if(b)return b;if(a!==void 0)return a;if(!g)throw new Error(`\`${u}\` must be used within \`${i}\``)}return ot(f,"useContext"),[d,f]}ot(s,"createContext");const r=ot(()=>{const i=n.map(a=>h.createContext(a));return ot(function(c){const l=c?.[t]||i;return h.useMemo(()=>({[`__scope${t}`]:{...c,[t]:l}}),[c,l])},"useScope")},"createScope");return r.scopeName=t,[s,jl(r,...e)]}ot(Sl,"createContextScope");function jl(...t){const e=t[0];if(t.length===1)return e;const n=ot(()=>{const s=t.map(r=>({useScope:r(),scopeName:r.scopeName}));return ot(function(i){const a=s.reduce((c,{useScope:l,scopeName:d})=>{const u=l(i)[`__scope${d}`];return{...c,...u}},{});return h.useMemo(()=>({[`__scope${e.scopeName}`]:a}),[a])},"useComposedScopes")},"createScope");return n.scopeName=e.scopeName,n}ot(jl,"composeContextScopes");var rn=globalThis?.document?h.useLayoutEffect:()=>{},Xf=Object.defineProperty,Zf=(t,e)=>Xf(t,"name",{value:e,configurable:!0}),Qf=Ks[" useId ".trim().toString()]||(()=>{}),ep=0;function _r(t){const[e,n]=h.useState(Qf());return rn(()=>{t||n(s=>s??String(ep++))},[t]),t||(e?`radix-${e}`:"")}Zf(_r,"useId");var tp=Object.defineProperty,np=(t,e)=>tp(t,"name",{value:e,configurable:!0}),cc=Ks[" useEffectEvent ".trim().toString()],lc=Ks[" useInsertionEffect ".trim().toString()];function Cl(t){if(typeof cc=="function")return cc(t);const e=h.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof lc=="function"?lc(()=>{e.current=t}):rn(()=>{e.current=t}),h.useMemo(()=>((...n)=>e.current?.(...n)),[])}np(Cl,"useEffectEvent");var sp=Object.defineProperty,Gs=(t,e)=>sp(t,"name",{value:e,configurable:!0}),rp=Ks[" useInsertionEffect ".trim().toString()]||rn;function kl({prop:t,defaultProp:e,onChange:n=Gs(()=>{},"onChange"),caller:s}){const[r,i,a]=El({defaultProp:e,onChange:n}),c=t!==void 0,l=c?t:r,d=h.useCallback(f=>{if(c){const u=Dl(f)?f(t):f;u!==t&&a.current?.(u)}else i(f)},[c,t,i,a]);return[l,d]}Gs(kl,"useControllableState");function El({defaultProp:t,onChange:e}){const[n,s]=h.useState(t),r=h.useRef(n),i=h.useRef(e);return rp(()=>{i.current=e},[e]),h.useEffect(()=>{r.current!==n&&(i.current?.(n),r.current=n)},[n,r]),[n,s,i]}Gs(El,"useUncontrolledState");function Dl(t){return typeof t=="function"}Gs(Dl,"isFunction");var dc=Symbol("RADIX:SYNC_STATE");function ip(t,e,n,s){const{prop:r,defaultProp:i,onChange:a,caller:c}=e,l=r!==void 0,d=Cl(a),f=[{...n,state:i}];s&&f.push(s);const[u,m]=h.useReducer((b,j)=>{if(j.type===dc)return{...b,state:j.state};const C=t(b,j);return l&&!Object.is(C.state,b.state)&&d(C.state),C},...f),p=u.state,g=h.useRef(p);h.useEffect(()=>{g.current!==p&&(g.current=p,l||d(p))},[p,g,l]);const x=h.useMemo(()=>r!==void 0?{...u,state:r}:u,[u,r]);return h.useEffect(()=>{l&&!Object.is(r,u.state)&&m({type:dc,state:r})},[r,u.state,l]),[x,m]}Gs(ip,"useControllableStateReducer");var op=Object.defineProperty,yt=(t,e)=>op(t,"name",{value:e,configurable:!0});function Ao(t){const e=h.forwardRef((n,s)=>{let{children:r,...i}=n,a=null,c=!1;const l=[];ao(r)&&typeof jr=="function"&&(r=jr(r._payload)),h.Children.forEach(r,m=>{if(_l(m)){c=!0;const p=m;let g="child"in p.props?p.props.child:p.props.children;ao(g)&&typeof jr=="function"&&(g=jr(g._payload)),a=cp(p,g),l.push(a?.props?.children)}else l.push(m)}),a?a=h.cloneElement(a,void 0,l):!c&&h.Children.count(r)===1&&h.isValidElement(r)&&(a=r);const d=a?Ol(a):void 0,f=ds(s,d);if(!a){if(r||r===0)throw new Error(c?up(t):dp(t));return r}const u=Tl(i,a.props??{});return a.type!==h.Fragment&&(u.ref=s?f:d),h.cloneElement(a,u)});return e.displayName=`${t}.Slot`,e}yt(Ao,"createSlot");var Nl=Symbol.for("radix.slottable");function ap(t){const e=yt(n=>"child"in n?n.children(n.child):n.children,"Slottable");return e.displayName=`${t}.Slottable`,e.__radixId=Nl,e}yt(ap,"createSlottable");var cp=yt((t,e)=>{if("child"in t.props){const n=t.props.child;return h.isValidElement(n)?h.cloneElement(n,void 0,t.props.children(n.props.children)):null}return h.isValidElement(e)?e:null},"getSlottableElementFromSlottable");function Tl(t,e){const n={...e};for(const s in e){const r=t[s],i=e[s];/^on[A-Z]/.test(s)?r&&i?n[s]=(...c)=>{const l=i(...c);return r(...c),l}:r&&(n[s]=r):s==="style"?n[s]={...r,...i}:s==="className"&&(n[s]=[r,i].filter(Boolean).join(" "))}return{...t,...n}}yt(Tl,"mergeProps");function Ol(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}yt(Ol,"getElementRef");function _l(t){return h.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Nl}yt(_l,"isSlottable");var lp=Symbol.for("react.lazy");function ao(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===lp&&"_payload"in t&&Pl(t._payload)}yt(ao,"isLazyComponent");function Pl(t){return typeof t=="object"&&t!==null&&"then"in t}yt(Pl,"isPromiseLike");var dp=yt(t=>`${t} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),up=yt(t=>`${t} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),jr=Ks[" use ".trim().toString()],hp=Object.defineProperty,fp=(t,e)=>hp(t,"name",{value:e,configurable:!0}),pp=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],bn=pp.reduce((t,e)=>{const n=Ao(`Primitive.${e}`),s=h.forwardRef((r,i)=>{const{asChild:a,...c}=r,l=a?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(l,{...c,ref:i})});return s.displayName=`Primitive.${e}`,{...t,[e]:s}},{});function Rl(t,e){t&&ll.flushSync(()=>t.dispatchEvent(e))}fp(Rl,"dispatchDiscreteCustomEvent");var mp=Object.defineProperty,gp=(t,e)=>mp(t,"name",{value:e,configurable:!0});function Zn(t){const e=h.useRef(t);return h.useEffect(()=>{e.current=t}),h.useMemo(()=>((...n)=>e.current?.(...n)),[])}gp(Zn,"useCallbackRef");var yp=Object.defineProperty,Ae=(t,e)=>yp(t,"name",{value:e,configurable:!0}),co="dismissableLayer.update",wp="dismissableLayer.pointerDownOutside",xp="dismissableLayer.focusOutside",uc,Ll=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),bp=h.forwardRef(Ae(function(e,n){const{disableOutsidePointerEvents:s=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:c,onInteractOutside:l,onDismiss:d,...f}=e,u=h.useContext(Ll),[m,p]=h.useState(null),g=m?.ownerDocument??globalThis?.document,[,x]=h.useState({}),b=ds(n,p),j=Array.from(u.layers),[C]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),T=C?j.indexOf(C):-1,N=m?j.indexOf(m):-1,L=u.layersWithOutsidePointerEventsDisabled.size>0,P=N>=T,E=h.useRef(!1),H=Fl(q=>{a?.(q),l?.(q),q.defaultPrevented||d?.()},{ownerDocument:g,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:E,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:h.useCallback(q=>{if(!(q instanceof Node))return!1;const R=[...u.branches].some(_=>_.contains(q));return P&&!R},[u.branches,P])}),S=Il(q=>{if(r&&E.current)return;const R=q.target;[...u.branches].some(v=>v.contains(R))||(c?.(q),l?.(q),q.defaultPrevented||d?.())},g),O=m?N===j.length-1:!1,ae=Zn(q=>{q.key==="Escape"&&(i?.(q),!q.defaultPrevented&&d&&(q.preventDefault(),d()))});return h.useEffect(()=>{if(O)return g.addEventListener("keydown",ae,{capture:!0}),()=>g.removeEventListener("keydown",ae,{capture:!0})},[g,O,ae]),h.useEffect(()=>{if(m)return s&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(uc=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(m)),u.layers.add(m),lo(),()=>{s&&(u.layersWithOutsidePointerEventsDisabled.delete(m),u.layersWithOutsidePointerEventsDisabled.size===0&&(g.body.style.pointerEvents=uc))}},[m,g,s,u]),h.useEffect(()=>()=>{m&&(u.layers.delete(m),u.layersWithOutsidePointerEventsDisabled.delete(m),lo())},[m,u]),h.useEffect(()=>{const q=Ae(()=>x({}),"handleUpdate");return document.addEventListener(co,q),()=>document.removeEventListener(co,q)},[]),o.jsx(bn.div,{...f,ref:b,style:{pointerEvents:L?P?"auto":"none":void 0,...e.style},onFocusCapture:sn(e.onFocusCapture,S.onFocusCapture),onBlurCapture:sn(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:sn(e.onPointerDownCapture,H.onPointerDownCapture)})},"DismissableLayer"));function Al(){const t=h.useContext(Ll),[e,n]=h.useState(null);return h.useEffect(()=>{if(e)return t.dismissableSurfaces.add(e),()=>{t.dismissableSurfaces.delete(e)}},[e,t.dismissableSurfaces]),n}Ae(Al,"useDismissableLayerSurface");var vp=Ae(()=>!0,"IS_TRUE");function Fl(t,e){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:s=!1,isDeferredPointerDownOutsideRef:r,dismissableSurfaces:i,shouldHandlePointerDownOutside:a=vp}=e,c=Zn(t),l=h.useRef(!1),d=h.useRef(!1),f=h.useRef(new Map),u=h.useRef(()=>{});return h.useEffect(()=>{function m(){d.current=!1,r.current=!1,f.current.clear()}Ae(m,"resetOutsideInteraction");function p(){return Array.from(f.current.values()).some(Boolean)}Ae(p,"isOutsideInteractionIntercepted");function g(T){if(!d.current)return;const N=T.target;N instanceof Node&&[...i].some(P=>P.contains(N))||f.current.set(T.type,!0),T.type==="click"&&window.setTimeout(()=>{d.current&&u.current()},0)}Ae(g,"handleInteractionCapture");function x(T){d.current&&f.current.set(T.type,!1)}Ae(x,"handleInteractionBubble");const b=Ae(T=>{if(T.target&&!l.current){let N=function(){n.removeEventListener("click",u.current);const P=p();m(),P||Fo(wp,c,L,{discrete:!0})};if(Ae(N,"handleAndDispatchPointerDownOutsideEvent"),!a(T.target)){n.removeEventListener("click",u.current),m(),l.current=!1;return}const L={originalEvent:T};d.current=!0,r.current=s&&T.button===0,f.current.clear(),!s||T.button!==0?N():(n.removeEventListener("click",u.current),u.current=N,n.addEventListener("click",u.current,{once:!0}))}else n.removeEventListener("click",u.current),m();l.current=!1},"handlePointerDown"),j=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const T of j)n.addEventListener(T,g,!0),n.addEventListener(T,x);const C=window.setTimeout(()=>{n.addEventListener("pointerdown",b)},0);return()=>{window.clearTimeout(C),n.removeEventListener("pointerdown",b),n.removeEventListener("click",u.current);for(const T of j)n.removeEventListener(T,g,!0),n.removeEventListener(T,x)}},[n,c,s,r,i,a]),{onPointerDownCapture:Ae(()=>l.current=!0,"onPointerDownCapture")}}Ae(Fl,"usePointerDownOutside");function Il(t,e=globalThis?.document){const n=Zn(t),s=h.useRef(!1);return h.useEffect(()=>{const r=Ae(i=>{i.target&&!s.current&&Fo(xp,n,{originalEvent:i},{discrete:!1})},"handleFocus");return e.addEventListener("focusin",r),()=>e.removeEventListener("focusin",r)},[e,n]),{onFocusCapture:Ae(()=>s.current=!0,"onFocusCapture"),onBlurCapture:Ae(()=>s.current=!1,"onBlurCapture")}}Ae(Il,"useFocusOutside");function lo(){const t=new CustomEvent(co);document.dispatchEvent(t)}Ae(lo,"dispatchUpdate");function Fo(t,e,n,{discrete:s}){const r=n.originalEvent.target,i=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&r.addEventListener(t,e,{once:!0}),s?Rl(r,i):r.dispatchEvent(i)}Ae(Fo,"handleAndDispatchCustomEvent");var Sp=Object.defineProperty,Xe=(t,e)=>Sp(t,"name",{value:e,configurable:!0}),Fi="focusScope.autoFocusOnMount",Ii="focusScope.autoFocusOnUnmount",hc={bubbles:!1,cancelable:!0},jp=h.forwardRef(Xe(function(e,n){const{loop:s=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...c}=e,[l,d]=h.useState(null),f=Zn(i),u=Zn(a),m=h.useRef(null),p=ds(n,d),g=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(r){let b=function(N){if(g.paused||!l)return;const L=N.target;l.contains(L)?m.current=L:Ut(m.current,{select:!0})},j=function(N){if(g.paused||!l)return;const L=N.relatedTarget;L!==null&&(l.contains(L)||Ut(m.current,{select:!0}))},C=function(N){if(document.activeElement===document.body)for(const P of N)P.removedNodes.length>0&&Ut(l)};Xe(b,"handleFocusIn"),Xe(j,"handleFocusOut"),Xe(C,"handleMutations"),document.addEventListener("focusin",b),document.addEventListener("focusout",j);const T=new MutationObserver(C);return l&&T.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",b),document.removeEventListener("focusout",j),T.disconnect()}}},[r,l,g.paused]),h.useEffect(()=>{if(l){fc.add(g);const b=document.activeElement;if(!l.contains(b)){const C=new CustomEvent(Fi,hc);l.addEventListener(Fi,f),l.dispatchEvent(C),C.defaultPrevented||(Ml(Bl(Io(l)),{select:!0}),document.activeElement===b&&Ut(l))}return()=>{l.removeEventListener(Fi,f),setTimeout(()=>{const C=new CustomEvent(Ii,hc);l.addEventListener(Ii,u),l.dispatchEvent(C),C.defaultPrevented||Ut(b??document.body,{select:!0}),l.removeEventListener(Ii,u),fc.remove(g)},0)}}},[l,f,u,g]);const x=h.useCallback(b=>{if(!s&&!r||g.paused)return;const j=b.key==="Tab"&&!b.altKey&&!b.ctrlKey&&!b.metaKey,C=document.activeElement;if(j&&C){const T=b.currentTarget,[N,L]=$l(T);N&&L?!b.shiftKey&&C===L?(b.preventDefault(),s&&Ut(N,{select:!0})):b.shiftKey&&C===N&&(b.preventDefault(),s&&Ut(L,{select:!0})):C===T&&b.preventDefault()}},[s,r,g.paused]);return o.jsx(bn.div,{tabIndex:-1,...c,ref:p,onKeyDown:x})},"FocusScope"));function Ml(t,{select:e=!1}={}){const n=document.activeElement;for(const s of t)if(Ut(s,{select:e}),document.activeElement!==n)return}Xe(Ml,"focusFirst");function $l(t){const e=Io(t),n=uo(e,t),s=uo(e.reverse(),t);return[n,s]}Xe($l,"getTabbableEdges");function Io(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:Xe(s=>{const r=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||r?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)e.push(n.currentNode);return e}Xe(Io,"getTabbableCandidates");function uo(t,e){const n=typeof e.checkVisibility=="function"&&e.checkVisibility({checkVisibilityCSS:!0});for(const s of t)if(!(n?!s.checkVisibility({checkVisibilityCSS:!0}):Ul(s,{upTo:e})))return s}Xe(uo,"findVisible");function Ul(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}Xe(Ul,"isHidden");function zl(t){return t instanceof HTMLInputElement&&"select"in t}Xe(zl,"isSelectableInput");function Ut(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&zl(t)&&e&&t.select()}}Xe(Ut,"focus");var fc=Vl();function Vl(){let t=[];return{add(e){const n=t[0];e!==n&&n?.pause(),t=ho(t,e),t.unshift(e)},remove(e){t=ho(t,e),t[0]?.resume()}}}Xe(Vl,"createFocusScopesStack");function ho(t,e){const n=[...t],s=n.indexOf(e);return s!==-1&&n.splice(s,1),n}Xe(ho,"arrayRemove");function Bl(t){return t.filter(e=>e.tagName!=="A")}Xe(Bl,"removeLinks");var Cp=Object.defineProperty,kp=(t,e)=>Cp(t,"name",{value:e,configurable:!0}),Ep=h.forwardRef(kp(function(e,n){const{container:s,...r}=e,[i,a]=h.useState(!1);rn(()=>a(!0),[]);const c=s||i&&globalThis?.document?.body;return c?ll.createPortal(o.jsx(bn.div,{...r,ref:n}),c):null},"Portal")),Dp=Object.defineProperty,Bt=(t,e)=>Dp(t,"name",{value:e,configurable:!0});function Hl(t,e){return h.useReducer((n,s)=>e[n][s]??n,t)}Bt(Hl,"useStateMachine");var Mo=Bt(t=>{const{present:e,children:n}=t,s=ql(e),r=typeof n=="function"?n({present:s.isPresent}):h.Children.only(n),i=Wl(s.ref,Kl(r));return typeof n=="function"||s.isPresent?h.cloneElement(r,{ref:i}):null},"Presence");function ql(t){const[e,n]=h.useState(),s=h.useRef(null),r=h.useRef(t),i=h.useRef("none"),a=h.useRef(void 0),c=t?"mounted":"unmounted",[l,d]=Hl(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return h.useEffect(()=>{l==="mounted"?(i.current=a.current??Mn(s.current),a.current=void 0):i.current="none"},[l]),rn(()=>{const f=s.current,u=r.current;if(u!==t){const p=i.current,g=Mn(f);t?(a.current=g,d("MOUNT")):g==="none"||f?.display==="none"?d("UNMOUNT"):d(u&&p!==g?"ANIMATION_OUT":"UNMOUNT"),r.current=t}},[t,d]),rn(()=>{if(e){let f;const u=e.ownerDocument.defaultView??window,m=Bt(g=>{const b=Mn(s.current).includes(CSS.escape(g.animationName));if(g.target===e&&b&&(d("ANIMATION_END"),!r.current)){const j=e.style.animationFillMode;e.style.animationFillMode="forwards",f=u.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=j)})}},"handleAnimationEnd"),p=Bt(g=>{g.target===e&&(i.current=Mn(s.current))},"handleAnimationStart");return e.addEventListener("animationstart",p),e.addEventListener("animationcancel",m),e.addEventListener("animationend",m),()=>{u.clearTimeout(f),e.removeEventListener("animationstart",p),e.removeEventListener("animationcancel",m),e.removeEventListener("animationend",m)}}else d("ANIMATION_END")},[e,d]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:h.useCallback(f=>{if(f){const u=getComputedStyle(f);s.current=u,a.current=Mn(u)}else s.current=null;n(f)},[])}}Bt(ql,"usePresence");function fo(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}Bt(fo,"setRef");function Wl(...t){const e=h.useRef(t);return e.current=t,h.useCallback(n=>{const s=e.current;let r=!1;const i=s.map(a=>{const c=fo(a,n);return!r&&typeof c=="function"&&(r=!0),c});if(r)return()=>{for(let a=0;a<i.length;a++){const c=i[a];typeof c=="function"?c():fo(s[a],null)}}},[])}Bt(Wl,"useStableComposedRefs");function Mn(t){return t?.animationName||"none"}Bt(Mn,"getAnimationName");function Kl(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}Bt(Kl,"getElementRef");var Np=Object.defineProperty,$o=(t,e)=>Np(t,"name",{value:e,configurable:!0}),Cr=0,Ln=null;function Tp(t){return Uo(),t.children}$o(Tp,"FocusGuards");function Uo(){h.useEffect(()=>{Ln||(Ln={start:po(),end:po()});const{start:t,end:e}=Ln;return document.body.firstElementChild!==t&&document.body.insertAdjacentElement("afterbegin",t),document.body.lastElementChild!==e&&document.body.insertAdjacentElement("beforeend",e),Cr++,()=>{Cr===1&&(Ln?.start.remove(),Ln?.end.remove(),Ln=null),Cr=Math.max(0,Cr-1)}},[])}$o(Uo,"useFocusGuards");function po(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}$o(po,"createFocusGuard");var Op=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},An=new WeakMap,kr=new WeakMap,Er={},Mi=0,Gl=function(t){return t&&(t.host||Gl(t.parentNode))},_p=function(t,e){return e.map(function(n){if(t.contains(n))return n;var s=Gl(n);return s&&t.contains(s)?s:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},Pp=function(t,e,n,s){var r=_p(e,Array.isArray(t)?t:[t]);Er[n]||(Er[n]=new WeakMap);var i=Er[n],a=[],c=new Set,l=new Set(r),d=function(u){!u||c.has(u)||(c.add(u),d(u.parentNode))};r.forEach(d);var f=function(u){!u||l.has(u)||Array.prototype.forEach.call(u.children,function(m){if(c.has(m))f(m);else try{var p=m.getAttribute(s),g=p!==null&&p!=="false",x=(An.get(m)||0)+1,b=(i.get(m)||0)+1;An.set(m,x),i.set(m,b),a.push(m),x===1&&g&&kr.set(m,!0),b===1&&m.setAttribute(n,"true"),g||m.setAttribute(s,"true")}catch(j){console.error("aria-hidden: cannot operate on ",m,j)}})};return f(e),c.clear(),Mi++,function(){a.forEach(function(u){var m=An.get(u)-1,p=i.get(u)-1;An.set(u,m),i.set(u,p),m||(kr.has(u)||u.removeAttribute(s),kr.delete(u)),p||u.removeAttribute(n)}),Mi--,Mi||(An=new WeakMap,An=new WeakMap,kr=new WeakMap,Er={})}},Rp=function(t,e,n){n===void 0&&(n="data-aria-hidden");var s=Array.from(Array.isArray(t)?t:[t]),r=Op(t);return r?(s.push.apply(s,Array.from(r.querySelectorAll("[aria-live], script"))),Pp(s,r,n,"aria-hidden")):function(){return null}},Lp=Object.defineProperty,lt=(t,e)=>Lp(t,"name",{value:e,configurable:!0}),zo="Dialog",[Jl,Tb]=Sl(zo),[Ap,Et]=Jl(zo),Fp=lt(t=>{const{__scopeDialog:e,children:n,open:s,defaultOpen:r,onOpenChange:i,modal:a=!0}=t,c=h.useRef(null),l=h.useRef(null),[d,f]=kl({prop:s,defaultProp:r??!1,onChange:i,caller:zo}),[u,m]=h.useState(0),[p,g]=h.useState(0);return o.jsx(Ap,{scope:e,triggerRef:c,contentRef:l,contentId:_r(),titleId:_r(),descriptionId:_r(),titlePresent:u>0,descriptionPresent:p>0,setTitleCount:m,setDescriptionCount:g,open:d,onOpenChange:f,onOpenToggle:h.useCallback(()=>f(x=>!x),[f]),modal:a,children:n})},"Dialog"),Yl="DialogPortal",[Ip,Xl]=Jl(Yl,{forceMount:void 0}),Mp=lt(t=>{const{__scopeDialog:e,forceMount:n,children:s,container:r}=t,i=Et(Yl,e);return o.jsx(Ip,{scope:e,forceMount:n,children:h.Children.map(s,a=>o.jsx(Mo,{present:n||i.open,children:o.jsx(Ep,{asChild:!0,container:r,children:a})}))})},"DialogPortal"),mo="DialogOverlay",$p=h.forwardRef(lt(function(e,n){const s=Xl(mo,e.__scopeDialog),{forceMount:r=s.forceMount,...i}=e,a=Et(mo,e.__scopeDialog);return a.modal?o.jsx(Mo,{present:r||a.open,children:o.jsx(zp,{...i,ref:n})}):null},"DialogOverlay")),Up=Ao("DialogOverlay.RemoveScroll"),zp=h.forwardRef(lt(function(e,n){const{__scopeDialog:s,...r}=e,i=Et(mo,s),a=Al(),c=ds(n,a);return o.jsx(Ch,{as:Up,allowPinchZoom:!0,shards:[i.contentRef],children:o.jsx(bn.div,{"data-state":Vo(i.open),...r,ref:c,style:{pointerEvents:"auto",...r.style}})})},"DialogOverlayImpl")),Rs="DialogContent",Vp=h.forwardRef(lt(function(e,n){const s=Xl(Rs,e.__scopeDialog),{forceMount:r=s.forceMount,...i}=e,a=Et(Rs,e.__scopeDialog);return o.jsx(Mo,{present:r||a.open,children:a.modal?o.jsx(Bp,{...i,ref:n}):o.jsx(Hp,{...i,ref:n})})},"DialogContent")),Bp=h.forwardRef(lt(function(e,n){const s=Et(Rs,e.__scopeDialog),r=h.useRef(null),i=ds(n,s.contentRef,r);return h.useEffect(()=>{const a=r.current;if(a)return Rp(a)},[]),o.jsx(Zl,{...e,ref:i,trapFocus:s.open,disableOutsidePointerEvents:s.open,onCloseAutoFocus:sn(e.onCloseAutoFocus,a=>{a.preventDefault(),s.triggerRef.current?.focus()}),onPointerDownOutside:sn(e.onPointerDownOutside,a=>{const c=a.detail.originalEvent,l=c.button===0&&c.ctrlKey===!0;(c.button===2||l)&&a.preventDefault()}),onFocusOutside:sn(e.onFocusOutside,a=>a.preventDefault())})},"DialogContentModal")),Hp=h.forwardRef(lt(function(e,n){const s=Et(Rs,e.__scopeDialog),r=h.useRef(!1),i=h.useRef(!1);return o.jsx(Zl,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{e.onCloseAutoFocus?.(a),a.defaultPrevented||(r.current||s.triggerRef.current?.focus(),a.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:a=>{e.onInteractOutside?.(a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const c=a.target;s.triggerRef.current?.contains(c)&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&i.current&&a.preventDefault()}})},"DialogContentNonModal")),Zl=h.forwardRef(lt(function(e,n){const{__scopeDialog:s,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...c}=e,l=Et(Rs,s);return Uo(),o.jsx(o.Fragment,{children:o.jsx(jp,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:o.jsx(bp,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionPresent?l.descriptionId:void 0,"aria-labelledby":l.titlePresent?l.titleId:void 0,"data-state":Vo(l.open),...c,ref:n,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1)})})})},"DialogContentImpl")),qp="DialogTitle",Wp=h.forwardRef(lt(function(e,n){const{__scopeDialog:s,...r}=e,i=Et(qp,s),{setTitleCount:a}=i;return rn(()=>(a(c=>c+1),()=>a(c=>c-1)),[a]),o.jsx(bn.h2,{id:i.titleId,...r,ref:n})},"DialogTitle")),Kp="DialogDescription",Gp=h.forwardRef(lt(function(e,n){const{__scopeDialog:s,...r}=e,i=Et(Kp,s),{setDescriptionCount:a}=i;return rn(()=>(a(c=>c+1),()=>a(c=>c-1)),[a]),o.jsx(bn.p,{id:i.descriptionId,...r,ref:n})},"DialogDescription")),Jp="DialogClose",Yp=h.forwardRef(lt(function(e,n){const{__scopeDialog:s,...r}=e,i=Et(Jp,s);return o.jsx(bn.button,{type:"button",...r,ref:n,onClick:sn(e.onClick,()=>i.onOpenChange(!1))})},"DialogClose"));function Vo(t){return t?"open":"closed"}lt(Vo,"getState");function Fe({open:t,title:e,description:n,onOpenChange:s,children:r,footer:i,wide:a,extraWide:c,className:l}){const{t:d}=_e();return o.jsx(Fp,{open:t,onOpenChange:s,children:o.jsxs(Mp,{children:[o.jsx($p,{className:"dialog-overlay"}),o.jsxs(Vp,{className:`dialog-content${a?" dialog-wide":""}${c?" dialog-extra-wide":""}${l?` ${l}`:""}`,children:[o.jsxs("div",{className:"dialog-header",children:[o.jsxs("div",{children:[o.jsx(Wp,{children:e}),n&&o.jsx(Gp,{children:n})]}),o.jsx(Yp,{className:"dialog-close","aria-label":d("common.close"),children:"×"})]}),o.jsx("div",{className:"dialog-body",children:r}),i&&o.jsx("div",{className:"dialog-footer",children:i})]})]})})}function Ls({open:t,title:e,description:n,confirmLabel:s,danger:r,onCancel:i,onConfirm:a}){const{t:c}=_e();return o.jsx(Fe,{open:t,title:e,description:n,onOpenChange:l=>{l||i()},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:i,children:c("common.cancel")}),o.jsx("button",{className:r?"danger":"primary",onClick:a,children:s??c("common.remove")})]}),children:o.jsx("div",{})})}function Bo({compact:t=!1}){const{i18n:e,t:n}=_e(),s=e.resolvedLanguage?.startsWith("zh")?"zh":"en";return o.jsxs("label",{className:`language-switcher${t?" compact":""}`,title:n("common.language"),children:[o.jsx("span",{children:"文/A"}),o.jsxs("select",{value:s,"aria-label":n("common.language"),onChange:r=>{e.changeLanguage(r.target.value)},children:[o.jsx("option",{value:"en",children:n("common.languageEnglish")}),o.jsx("option",{value:"zh",children:n("common.languageChinese")})]})]})}const Xp=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Ql=(...t)=>t.filter((e,n,s)=>!!e&&e.trim()!==""&&s.indexOf(e)===n).join(" ").trim();var Zp={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Qp=h.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:s,className:r="",children:i,iconNode:a,...c},l)=>h.createElement("svg",{ref:l,...Zp,width:e,height:e,stroke:t,strokeWidth:s?Number(n)*24/Number(e):n,className:Ql("lucide",r),...c},[...a.map(([d,f])=>h.createElement(d,f)),...Array.isArray(i)?i:[i]]));const F=(t,e)=>{const n=h.forwardRef(({className:s,...r},i)=>h.createElement(Qp,{ref:i,iconNode:e,className:Ql(`lucide-${Xp(t)}`,s),...r}));return n.displayName=`${t}`,n};const em=F("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const ed=F("AlignLeft",[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);const tm=F("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);const pc=F("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);const nm=F("ArrowDownUp",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"m21 8-4-4-4 4",key:"1c9v7m"}],["path",{d:"M17 4v16",key:"7dpous"}]]);const td=F("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const $i=F("ArrowRightLeft",[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]);const nd=F("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);const sm=F("CalendarDays",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]]);const rm=F("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const sd=F("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const rd=F("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);const Ho=F("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const im=F("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);const om=F("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);const am=F("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const qo=F("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const mc=F("Columns2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]);const cm=F("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const lm=F("Dices",[["rect",{width:"12",height:"12",x:"2",y:"10",rx:"2",ry:"2",key:"6agr2n"}],["path",{d:"m17.92 14 3.5-3.5a2.24 2.24 0 0 0 0-3l-5-4.92a2.24 2.24 0 0 0-3 0L10 6",key:"1o487t"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 14h.01",key:"ssrbsk"}],["path",{d:"M15 6h.01",key:"cblpky"}],["path",{d:"M18 9h.01",key:"2061c0"}]]);const Ur=F("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);const go=F("FileArchive",[["path",{d:"M10 12v-1",key:"v7bkov"}],["path",{d:"M10 18v-2",key:"1cjy8d"}],["path",{d:"M10 7V6",key:"dljcrl"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 .274 1.01",key:"gkbcor"}],["circle",{cx:"10",cy:"20",r:"2",key:"1xzdoj"}]]);const dm=F("FilePlus2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]]);const um=F("FileSearch",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4.268 21a2 2 0 0 0 1.727 1H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"ms7g94"}],["path",{d:"m9 18-1.5-1.5",key:"1j6qii"}],["circle",{cx:"5",cy:"14",r:"3",key:"ufru5t"}]]);const Vn=F("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const zr=F("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);const id=F("FolderPlus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const hm=F("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const fm=F("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);const Ui=F("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);const od=F("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const pm=F("Keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]);const mm=F("ListTree",[["path",{d:"M21 12h-8",key:"1bmf0i"}],["path",{d:"M21 6H8",key:"1pqkrb"}],["path",{d:"M21 18h-8",key:"1tm79t"}],["path",{d:"M3 6v4c0 1.1.9 2 2 2h3",key:"1ywdgy"}],["path",{d:"M3 10v6c0 1.1.9 2 2 2h3",key:"2wc746"}]]);const pn=F("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const gm=F("MessageSquarePlus",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);const ym=F("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);const gc=F("Move",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]);const ad=F("PackageOpen",[["path",{d:"M12 22v-9",key:"x3hkom"}],["path",{d:"M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z",key:"2ntwy6"}],["path",{d:"M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13",key:"1pmm1c"}],["path",{d:"M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z",key:"12ttoo"}]]);const yc=F("PanelLeftClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const wm=F("PanelLeftOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const xm=F("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);const bm=F("PanelRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);const yo=F("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);const vm=F("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const Sm=F("Reply",[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]]);const jm=F("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const Vr=F("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const cd=F("ScrollText",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]);const Cm=F("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);const km=F("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);const Pr=F("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const Em=F("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);const Dm=F("SpellCheck2",[["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M4 21c1.1 0 1.1-1 2.3-1s1.1 1 2.3 1c1.1 0 1.1-1 2.3-1 1.1 0 1.1 1 2.3 1 1.1 0 1.1-1 2.3-1 1.1 0 1.1 1 2.3 1 1.1 0 1.1-1 2.3-1",key:"8mdmtu"}]]);const wc=F("Tags",[["path",{d:"m15 5 6.3 6.3a2.4 2.4 0 0 1 0 3.4L17 19",key:"1cbfv1"}],["path",{d:"M9.586 5.586A2 2 0 0 0 8.172 5H3a1 1 0 0 0-1 1v5.172a2 2 0 0 0 .586 1.414L8.29 18.29a2.426 2.426 0 0 0 3.42 0l3.58-3.58a2.426 2.426 0 0 0 0-3.42z",key:"135mg7"}],["circle",{cx:"6.5",cy:"9.5",r:".5",fill:"currentColor",key:"5pm5xn"}]]);const Qn=F("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const As=F("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const xc=F("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);const Br=F("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);const ld=F("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);const Fs=F("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);const Nm=F("WrapText",[["line",{x1:"3",x2:"21",y1:"6",y2:"6",key:"4m8b97"}],["path",{d:"M3 12h15a3 3 0 1 1 0 6h-4",key:"1cl7v7"}],["polyline",{points:"16 16 14 18 16 20",key:"1jznyi"}],["line",{x1:"3",x2:"10",y1:"18",y2:"18",key:"1h33wv"}]]);const Wo=F("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Hr=[{id:"jetbrains",labelKey:"projectSettings.fontJetBrains",stack:'"JetBrains Mono", ui-monospace, monospace'},{id:"source-code",labelKey:"projectSettings.fontSourceCode",stack:'"Source Code Pro", ui-monospace, monospace'},{id:"ibm-plex",labelKey:"projectSettings.fontIbmPlex",stack:'"IBM Plex Mono", ui-monospace, monospace'},{id:"fira-code",labelKey:"projectSettings.fontFiraCode",stack:'"Fira Code", ui-monospace, monospace'},{id:"iosevka",labelKey:"projectSettings.fontIosevka",stack:'"Iosevka", ui-monospace, monospace'}],en={font:"jetbrains",fontSize:14,lineHeight:1.65,lineWrapping:!0,spellCheck:!0,vimMode:!1,formatOnCompile:!1},Tm="texlite-editor-preferences";function dd(t,e){return`${Tm}:${encodeURIComponent(t)}:${encodeURIComponent(e)}`}function Ob(t){return Hr.find(e=>e.id===t)?.stack??Hr[0].stack}function bc(t,e){try{const n=JSON.parse(localStorage.getItem(dd(t,e))??"{}");return{font:Hr.some(s=>s.id===n.font)?n.font:en.font,fontSize:[12,13,14,15,16,18,20].includes(Number(n.fontSize))?Number(n.fontSize):en.fontSize,lineHeight:[1.45,1.65,1.85].includes(Number(n.lineHeight))?Number(n.lineHeight):en.lineHeight,lineWrapping:typeof n.lineWrapping=="boolean"?n.lineWrapping:en.lineWrapping,spellCheck:typeof n.spellCheck=="boolean"?n.spellCheck:en.spellCheck,vimMode:typeof n.vimMode=="boolean"?n.vimMode:en.vimMode,formatOnCompile:typeof n.formatOnCompile=="boolean"?n.formatOnCompile:en.formatOnCompile}}catch{return en}}function Om(t,e,n){localStorage.setItem(dd(t,e),JSON.stringify(n))}const _m=/\.(?:tex|bib|cls|sty)$/i;function zi(t){return _m.test(t)}function Pm(t){return t.match(/(?:\r?\n)+$/)?.[0]??""}function Rm(t,e){const n=Pm(t),a=(n?t.slice(0,-n.length):t).split(/\r?\n/).find(d=>d.trim())?.match(/^[\t ]*/)?.[0]??"",c=e.replace(/(?:\r?\n)+$/,"");return`${a?c.split(`
|
|
5
|
-
`).map(d=>d&&`${a}${d}`).join(`
|
|
6
|
-
`):c}${n}`}async function vc(t,e,n=0){if(t===e)return[];const{default:s}=await qt(async()=>{const{default:f}=await import("./index-rBWMBTI-.js").then(u=>u.i);return{default:f}},__vite__mapDeps([0,1])),r=new s,i=r.diff_main(t,e,!0);r.diff_cleanupEfficiency(i);const a=[];let c=n,l=null;const d=()=>{l&&a.push(l),l=null};for(const[f,u]of i)f===s.DIFF_EQUAL?(d(),c+=u.length):f===s.DIFF_DELETE?(l??={from:c,to:c,replacement:""},l.to+=u.length,c+=u.length):(l??={from:c,to:c,replacement:""},l.replacement+=u);return d(),a}function Lm(t,e=null){const n=Sc(t),r=e==="succeeded"||e===null&&Fm(t)?[]:jc(n.filter(Cc)),i=Sc(Am(t));return{warnings:jc(i.filter(c=>!Cc(c)&&Im(c))),errors:r}}function Sc(t){return t.split(`
|
|
7
|
-
`).map(e=>e.trim()).filter(Boolean)}function jc(t){return[...new Set(t)]}function Am(t){const e=/^Running ['"][^\n]*(?:pdf|xe|lua)latex(?:\s|['"])[^\n]*$/gim;let n=-1;for(const s of t.matchAll(e))n=s.index;return n>=0?t.slice(n):t}function Fm(t){return/Latexmk: All targets .* are up-to-date/i.test(t)&&/Output written on .*\.pdf/i.test(t)}function Cc(t){return/^!\s/.test(t)||/(?:^|:\s)(?:LaTeX|Package|Class|pdfTeX|XeTeX|LuaTeX)?\s*Error:/i.test(t)||/^Latexmk:.*(?:\bErrors?,|did not complete making targets|failure)/i.test(t)||/^Collected error summary/i.test(t)||/\b(?:fatal error|emergency stop|undefined control sequence|no output pdf|no pages of output)\b/i.test(t)||/\b(?:bibtex|biber) errors?:/i.test(t)||/^error, and then rerun latexmk/i.test(t)}function Im(t){return/\bwarnings?\b|overfull|underfull|badness/i.test(t)}const Mm=/^\/projects?\/([^/]+)\/?$/;function Vi(t){return`/project/${encodeURIComponent(t)}`}function Dr(t){const e=Mm.exec(t);if(!e)return null;try{const n=decodeURIComponent(e[1]);return n&&!n.includes("/")?n:null}catch{return null}}function $m(t){if(!t||typeof t!="object")return!1;const e=t;return e.texliteRoute==="project"&&typeof e.projectId=="string"&&typeof e.fromDashboard=="boolean"}function B(t){return t instanceof Error?t.message:ge.t("errors.generic")}const tt=()=>new Map,wo=t=>{const e=tt();return t.forEach((n,s)=>{e.set(s,n)}),e},Dt=(t,e,n)=>{let s=t.get(e);return s===void 0&&t.set(e,s=n()),s},Um=(t,e)=>{const n=[];for(const[s,r]of t)n.push(e(r,s));return n},zm=(t,e)=>{for(const[n,s]of t)if(e(s,n))return!0;return!1},on=()=>new Set,Bi=t=>t[t.length-1],Vm=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},Ht=Array.from,Ko=(t,e)=>{for(let n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0},Go=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1},Bm=(t,e)=>{const n=new Array(t);for(let s=0;s<t;s++)n[s]=e(s,n);return n},es=Array.isArray;class Jo{constructor(){this._observers=tt()}on(e,n){return Dt(this._observers,e,on).add(n),n}once(e,n){const s=(...r)=>{this.off(e,s),n(...r)};this.on(e,s)}off(e,n){const s=this._observers.get(e);s!==void 0&&(s.delete(n),s.size===0&&this._observers.delete(e))}emit(e,n){return Ht((this._observers.get(e)||tt()).values()).forEach(s=>s(...n))}destroy(){this._observers=tt()}}class ud{constructor(){this._observers=tt()}on(e,n){Dt(this._observers,e,on).add(n)}once(e,n){const s=(...r)=>{this.off(e,s),n(...r)};this.on(e,s)}off(e,n){const s=this._observers.get(e);s!==void 0&&(s.delete(n),s.size===0&&this._observers.delete(e))}emit(e,n){return Ht((this._observers.get(e)||tt()).values()).forEach(s=>s(...n))}destroy(){this._observers=tt()}}const mt=Math.floor,Rr=Math.abs,Yo=(t,e)=>t<e?t:e,vn=(t,e)=>t>e?t:e,Hm=Math.pow,hd=t=>t!==0?t<0:1/t<0,kc=1,Ec=2,Hi=4,qi=8,Is=32,zt=64,rt=128,oi=31,xo=63,gn=127,qm=2147483647,qr=Number.MAX_SAFE_INTEGER,Dc=Number.MIN_SAFE_INTEGER,Wm=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&mt(t)===t),fd=String.fromCharCode,Km=t=>t.toLowerCase(),Gm=/^\s*/g,Jm=t=>t.replace(Gm,""),Ym=/([A-Z])/g,Nc=(t,e)=>Jm(t.replace(Ym,n=>`${e}${Km(n)}`)),Xm=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,s=new Uint8Array(n);for(let r=0;r<n;r++)s[r]=e.codePointAt(r);return s},Ms=typeof TextEncoder<"u"?new TextEncoder:null,Zm=t=>Ms.encode(t),Qm=Ms?Zm:Xm;let _s=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});_s&&_s.decode(new Uint8Array).length===1&&(_s=null);const eg=(t,e)=>Bm(e,()=>t).join("");class Js{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Ee=()=>new Js,Xo=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},he=t=>{const e=new Uint8Array(Xo(t));let n=0;for(let s=0;s<t.bufs.length;s++){const r=t.bufs[s];e.set(r,n),n+=r.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},tg=(t,e)=>{const n=t.cbuf.length;n-t.cpos<e&&(t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(vn(n,e)*2),t.cpos=0)},Le=(t,e)=>{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},bo=Le,$=(t,e)=>{for(;e>gn;)Le(t,rt|gn&e),e=mt(e/128);Le(t,gn&e)},Zo=(t,e)=>{const n=hd(e);for(n&&(e=-e),Le(t,(e>xo?rt:0)|(n?zt:0)|xo&e),e=mt(e/64);e>0;)Le(t,(e>gn?rt:0)|gn&e),e=mt(e/128)},vo=new Uint8Array(3e4),ng=vo.length/3,sg=(t,e)=>{if(e.length<ng){const n=Ms.encodeInto(e,vo).written||0;$(t,n);for(let s=0;s<n;s++)Le(t,vo[s])}else Se(t,Qm(e))},rg=(t,e)=>{const n=unescape(encodeURIComponent(e)),s=n.length;$(t,s);for(let r=0;r<s;r++)Le(t,n.codePointAt(r))},Vt=Ms&&Ms.encodeInto?sg:rg,ai=(t,e)=>{const n=t.cbuf.length,s=t.cpos,r=Yo(n-s,e.length),i=e.length-r;t.cbuf.set(e.subarray(0,r),s),t.cpos+=r,i>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(vn(n*2,i)),t.cbuf.set(e.subarray(r)),t.cpos=i)},Se=(t,e)=>{$(t,e.byteLength),ai(t,e)},Qo=(t,e)=>{tg(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},ig=(t,e)=>Qo(t,4).setFloat32(0,e,!1),og=(t,e)=>Qo(t,8).setFloat64(0,e,!1),ag=(t,e)=>Qo(t,8).setBigInt64(0,e,!1),Tc=new DataView(new ArrayBuffer(4)),cg=t=>(Tc.setFloat32(0,t),Tc.getFloat32(0)===t),$s=(t,e)=>{switch(typeof e){case"string":Le(t,119),Vt(t,e);break;case"number":Wm(e)&&Rr(e)<=qm?(Le(t,125),Zo(t,e)):cg(e)?(Le(t,124),ig(t,e)):(Le(t,123),og(t,e));break;case"bigint":Le(t,122),ag(t,e);break;case"object":if(e===null)Le(t,126);else if(es(e)){Le(t,117),$(t,e.length);for(let n=0;n<e.length;n++)$s(t,e[n])}else if(e instanceof Uint8Array)Le(t,116),Se(t,e);else{Le(t,118);const n=Object.keys(e);$(t,n.length);for(let s=0;s<n.length;s++){const r=n[s];Vt(t,r),$s(t,e[r])}}break;case"boolean":Le(t,e?120:121);break;default:Le(t,127)}};class Oc extends Js{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&$(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const _c=t=>{t.count>0&&(Zo(t.encoder,t.count===1?t.s:-t.s),t.count>1&&$(t.encoder,t.count-2))};class Lr{constructor(){this.encoder=new Js,this.s=0,this.count=0}write(e){this.s===e?this.count++:(_c(this),this.count=1,this.s=e)}toUint8Array(){return _c(this),he(this.encoder)}}const Pc=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);Zo(t.encoder,e),t.count>1&&$(t.encoder,t.count-2)}};class Wi{constructor(){this.encoder=new Js,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Pc(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Pc(this),he(this.encoder)}}class lg{constructor(){this.sarr=[],this.s="",this.lensE=new Lr}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new Js;return this.sarr.push(this.s),this.s="",Vt(e,this.sarr.join("")),ai(e,this.lensE.toUint8Array()),he(e)}}const gt=t=>new Error(t),ft=()=>{throw gt("Method unimplemented")},it=()=>{throw gt("Unexpected case")},pd=gt("Unexpected end of array"),md=gt("Integer out of Range");class ci{constructor(e){this.arr=e,this.pos=0}}const ln=t=>new ci(t),dg=t=>t.pos!==t.arr.length,ug=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},qe=t=>ug(t,J(t)),ts=t=>t.arr[t.pos++],J=t=>{let e=0,n=1;const s=t.arr.length;for(;t.pos<s;){const r=t.arr[t.pos++];if(e=e+(r&gn)*n,n*=128,r<rt)return e;if(e>qr)throw md}throw pd},ea=t=>{let e=t.arr[t.pos++],n=e&xo,s=64;const r=(e&zt)>0?-1:1;if((e&rt)===0)return r*n;const i=t.arr.length;for(;t.pos<i;){if(e=t.arr[t.pos++],n=n+(e&gn)*s,s*=128,e<rt)return r*n;if(n>qr)throw md}throw pd},hg=t=>{let e=J(t);if(e===0)return"";{let n=String.fromCodePoint(ts(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(ts(t));else for(;e>0;){const s=e<1e4?e:1e4,r=t.arr.subarray(t.pos,t.pos+s);t.pos+=s,n+=String.fromCodePoint.apply(null,r),e-=s}return decodeURIComponent(escape(n))}},fg=t=>_s.decode(qe(t)),pt=_s?fg:hg,ta=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},pg=t=>ta(t,4).getFloat32(0,!1),mg=t=>ta(t,8).getFloat64(0,!1),gg=t=>ta(t,8).getBigInt64(0,!1),yg=[t=>{},t=>null,ea,pg,mg,gg,t=>!1,t=>!0,pt,t=>{const e=J(t),n={};for(let s=0;s<e;s++){const r=pt(t);n[r]=Us(t)}return n},t=>{const e=J(t),n=[];for(let s=0;s<e;s++)n.push(Us(t));return n},qe],Us=t=>yg[127-ts(t)](t);class Rc extends ci{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),dg(this)?this.count=J(this)+1:this.count=-1),this.count--,this.s}}class Ar extends ci{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=ea(this);const e=hd(this.s);this.count=1,e&&(this.s=-this.s,this.count=J(this)+2)}return this.count--,this.s}}class Ki extends ci{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=ea(this),n=e&1;this.diff=mt(e/2),this.count=1,n&&(this.count=J(this)+2)}return this.s+=this.diff,this.count--,this.s}}class wg{constructor(e){this.decoder=new Ar(e),this.str=pt(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),n=this.str.slice(this.spos,e);return this.spos=e,n}}const xg=crypto.getRandomValues.bind(crypto),gd=()=>xg(new Uint32Array(1))[0],bg="10000000-1000-4000-8000"+-1e11,vg=()=>bg.replace(/[018]/g,t=>(t^gd()&15>>t/4).toString(16)),an=Date.now,ns=t=>new Promise(t);Promise.all.bind(Promise);const Lc=t=>t===void 0?null:t;class Sg{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let yd=new Sg,na=!0;try{typeof localStorage<"u"&&localStorage&&(yd=localStorage,na=!1)}catch{}const wd=yd,jg=t=>na||addEventListener("storage",t),Cg=t=>na||removeEventListener("storage",t),zs=Symbol("Equality"),xd=(t,e)=>t===e||!!t?.[zs]?.(e)||!1,kg=t=>typeof t=="object",Eg=Object.assign,Dg=Object.keys,Ng=(t,e)=>{for(const n in t)e(t[n],n)},Tg=(t,e)=>{const n=[];for(const s in t)n.push(e(t[s],s));return n},Wr=t=>Dg(t).length,Og=t=>{for(const e in t)return!1;return!0},Ys=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},sa=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),_g=(t,e)=>t===e||Wr(t)===Wr(e)&&Ys(t,(n,s)=>(n!==void 0||sa(e,s))&&xd(e[s],n)),Pg=Object.freeze,bd=t=>{for(const e in t){const n=t[e];(typeof n=="object"||typeof n=="function")&&bd(t[e])}return Pg(t)},ra=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&ra(t,e,n+1)}},Rg=t=>t,qn=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(t[zs]!=null)return t[zs](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;break}case Set:{if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;break}case Map:{if(t.size!==e.size)return!1;for(const n of t.keys())if(!e.has(n)||!qn(t.get(n),e.get(n)))return!1;break}case void 0:case Object:if(Wr(t)!==Wr(e))return!1;for(const n in t)if(!sa(t,n)||!qn(t[n],e[n]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!qn(t[n],e[n]))return!1;break;default:return!1}return!0},Lg=(t,e)=>e.includes(t);var vd={};const cn=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",Sd=typeof window<"u"&&typeof document<"u"&&!cn;let St;const Ag=()=>{if(St===void 0)if(cn){St=tt();const t=process.argv;let e=null;for(let n=0;n<t.length;n++){const s=t[n];s[0]==="-"?(e!==null&&St.set(e,""),e=s):e!==null&&(St.set(e,s),e=null)}e!==null&&St.set(e,"")}else typeof location=="object"?(St=tt(),(location.search||"?").slice(1).split("&").forEach(t=>{if(t.length!==0){const[e,n]=t.split("=");St.set(`--${Nc(e,"-")}`,n),St.set(`-${Nc(e,"-")}`,n)}})):St=tt();return St},So=t=>Ag().has(t),Kr=t=>Lc(cn?vd[t.toUpperCase().replaceAll("-","_")]:wd.getItem(t)),jd=t=>So("--"+t)||Kr(t)!==null,Fg=jd("production"),Ig=cn&&Lg(vd.FORCE_COLOR,["true","1","2"]),Mg=Ig||!So("--no-colors")&&!jd("no-color")&&(!cn||process.stdout.isTTY)&&(!cn||So("--color")||Kr("COLORTERM")!==null||(Kr("TERM")||"").includes("color")),Cd=t=>new Uint8Array(t),$g=(t,e,n)=>new Uint8Array(t,e,n),Ug=t=>new Uint8Array(t),zg=t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=fd(t[n]);return btoa(e)},Vg=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),Bg=t=>{const e=atob(t),n=Cd(e.length);for(let s=0;s<e.length;s++)n[s]=e.charCodeAt(s);return n},Hg=t=>{const e=Buffer.from(t,"base64");return $g(e.buffer,e.byteOffset,e.byteLength)},qg=Sd?zg:Vg,Wg=Sd?Bg:Hg,Kg=t=>{const e=Cd(t.byteLength);return e.set(t),e};class Gg{constructor(e,n){this.left=e,this.right=n}}const $t=(t,e)=>new Gg(t,e),Jg=(t,e)=>t.forEach(n=>e(n.left,n.right)),Ac=t=>t.next()>=.5,Gi=(t,e,n)=>mt(t.next()*(n+1-e)+e),kd=(t,e,n)=>mt(t.next()*(n+1-e)+e),ia=(t,e,n)=>kd(t,e,n),Yg=t=>fd(ia(t,97,122)),Xg=(t,e=0,n=20)=>{const s=ia(t,e,n);let r="";for(let i=0;i<s;i++)r+=Yg(t);return r},Ji=(t,e)=>e[ia(t,0,e.length-1)],Zg=Symbol("0schema");class Qg{constructor(){this._rerrs=[]}extend(e,n,s,r=null){this._rerrs.push({path:e,expected:n,has:s,message:r})}toString(){const e=[];for(let n=this._rerrs.length-1;n>0;n--){const s=this._rerrs[n];e.push(eg(" ",(this._rerrs.length-n)*2)+`${s.path!=null?`[${s.path}] `:""}${s.has} doesn't match ${s.expected}. ${s.message}`)}return e.join(`
|
|
8
|
-
`)}}const jo=(t,e)=>t===e?!0:t==null||e==null||t.constructor!==e.constructor?!1:t[zs]?xd(t,e):es(t)?Ko(t,n=>Go(e,s=>jo(n,s))):kg(t)?Ys(t,(n,s)=>jo(n,e[s])):!1;class Ze{static _dilutes=!1;extends(e){let[n,s]=[this.shape,e.shape];return this.constructor._dilutes&&([s,n]=[n,s]),jo(n,s)}equals(e){return this.constructor===e.constructor&&qn(this.shape,e.shape)}[Zg](){return!0}[zs](e){return this.equals(e)}validate(e){return this.check(e)}check(e,n){ft()}get nullable(){return us(this,fi)}get optional(){return new Nd(this)}cast(e){return Fc(e,this),e}expect(e){return Fc(e,this),e}}class oa extends Ze{constructor(e,n){super(),this.shape=e,this._c=n}check(e,n=void 0){const s=e?.constructor===this.shape&&(this._c==null||this._c(e));return!s&&n?.extend(null,this.shape.name,e?.constructor.name,e?.constructor!==this.shape?"Constructor match failed":"Check failed"),s}}const De=(t,e=null)=>new oa(t,e);De(oa);class aa extends Ze{constructor(e){super(),this.shape=e}check(e,n){const s=this.shape(e);return!s&&n?.extend(null,"custom prop",e?.constructor.name,"failed to check custom prop"),s}}const Me=t=>new aa(t);De(aa);class li extends Ze{constructor(e){super(),this.shape=e}check(e,n){const s=this.shape.some(r=>r===e);return!s&&n?.extend(null,this.shape.join(" | "),e.toString()),s}}const di=(...t)=>new li(t),Ed=De(li),ey=RegExp.escape||(t=>t.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),Dd=t=>{if(ss.check(t))return[ey(t)];if(Ed.check(t))return t.shape.map(e=>e+"");if(Id.check(t))return["[+-]?\\d+.?\\d*"];if(Md.check(t))return[".*"];if(Gr.check(t))return t.shape.map(Dd).flat(1);it()};class ty extends Ze{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(Dd).map(n=>`(${n.join("|")})`).join("")+"$")}check(e,n){const s=this._r.exec(e)!=null;return!s&&n?.extend(null,this._r.toString(),e.toString(),"String doesn't match string template."),s}}De(ty);const ny=Symbol("optional");class Nd extends Ze{constructor(e){super(),this.shape=e}check(e,n){const s=e===void 0||this.shape.check(e);return!s&&n?.extend(null,"undefined (optional)","()"),s}get[ny](){return!0}}const sy=De(Nd);class ry extends Ze{check(e,n){return n?.extend(null,"never",typeof e),!1}}De(ry);class ui extends Ze{constructor(e,n=!1){super(),this.shape=e,this._isPartial=n}static _dilutes=!0;get partial(){return new ui(this.shape,!0)}check(e,n){return e==null?(n?.extend(null,"object","null"),!1):Ys(this.shape,(s,r)=>{const i=this._isPartial&&!sa(e,r)||s.check(e[r],n);return!i&&n?.extend(r.toString(),s.toString(),typeof e[r],"Object property does not match"),i})}}const iy=t=>new ui(t),oy=De(ui),ay=Me(t=>t!=null&&(t.constructor===Object||t.constructor==null));class Td extends Ze{constructor(e,n){super(),this.shape={keys:e,values:n}}check(e,n){return e!=null&&Ys(e,(s,r)=>{const i=this.shape.keys.check(r,n);return!i&&n?.extend(r+"","Record",typeof e,i?"Key doesn't match schema":"Value doesn't match value"),i&&this.shape.values.check(s,n)})}}const Od=(t,e)=>new Td(t,e),cy=De(Td);class _d extends Ze{constructor(e){super(),this.shape=e}check(e,n){return e!=null&&Ys(this.shape,(s,r)=>{const i=s.check(e[r],n);return!i&&n?.extend(r.toString(),"Tuple",typeof s),i})}}const ly=(...t)=>new _d(t);De(_d);class Pd extends Ze{constructor(e){super(),this.shape=e.length===1?e[0]:new ca(e)}check(e,n){const s=es(e)&&Ko(e,r=>this.shape.check(r));return!s&&n?.extend(null,"Array",""),s}}const Rd=(...t)=>new Pd(t),dy=De(Pd),uy=Me(t=>es(t));class Ld extends Ze{constructor(e,n){super(),this.shape=e,this._c=n}check(e,n){const s=e instanceof this.shape&&(this._c==null||this._c(e));return!s&&n?.extend(null,this.shape.name,e?.constructor.name),s}}const hy=(t,e=null)=>new Ld(t,e);De(Ld);const fy=hy(Ze);class py extends Ze{constructor(e){super(),this.len=e.length-1,this.args=ly(...e.slice(-1)),this.res=e[this.len]}check(e,n){const s=e.constructor===Function&&e.length<=this.len;return!s&&n?.extend(null,"function",typeof e),s}}const my=De(py),gy=Me(t=>typeof t=="function");class yy extends Ze{constructor(e){super(),this.shape=e}check(e,n){const s=Ko(this.shape,r=>r.check(e,n));return!s&&n?.extend(null,"Intersectinon",typeof e),s}}De(yy,t=>t.shape.length>0);class ca extends Ze{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,n){const s=Go(this.shape,r=>r.check(e,n));return n?.extend(null,"Union",typeof e),s}}const us=(...t)=>t.findIndex(e=>Gr.check(e))>=0?us(...t.map(e=>Vs(e)).map(e=>Gr.check(e)?e.shape:[e]).flat(1)):t.length===1?t[0]:new ca(t),Gr=De(ca),Ad=()=>!0,Jr=Me(Ad),wy=De(aa,t=>t.shape===Ad),la=Me(t=>typeof t=="bigint"),xy=Me(t=>t===la),Fd=Me(t=>typeof t=="symbol");Me(t=>t===Fd);const Wn=Me(t=>typeof t=="number"),Id=Me(t=>t===Wn),ss=Me(t=>typeof t=="string"),Md=Me(t=>t===ss),hi=Me(t=>typeof t=="boolean"),by=Me(t=>t===hi),$d=di(void 0);De(li,t=>t.shape.length===1&&t.shape[0]===void 0);di(void 0);const fi=di(null),vy=De(li,t=>t.shape.length===1&&t.shape[0]===null);De(Uint8Array);De(oa,t=>t.shape===Uint8Array);const Sy=us(Wn,ss,fi,$d,la,hi,Fd);(()=>{const t=Rd(Jr),e=Od(ss,Jr),n=us(Wn,ss,fi,hi,t,e);return t.shape=n,e.shape.values=n,n})();const Vs=t=>{if(fy.check(t))return t;if(ay.check(t)){const e={};for(const n in t)e[n]=Vs(t[n]);return iy(e)}else{if(uy.check(t))return us(...t.map(Vs));if(Sy.check(t))return di(t);if(gy.check(t))return De(t)}it()},Fc=Fg?()=>{}:(t,e)=>{const n=new Qg;if(!e.check(t,n))throw gt(`Expected value to be of type ${e.constructor.name}.
|
|
9
|
-
${n.toString()}`)};class jy{constructor(e){this.patterns=[],this.$state=e}if(e,n){return this.patterns.push({if:Vs(e),h:n}),this}else(e){return this.if(Jr,e)}done(){return(e,n)=>{for(let s=0;s<this.patterns.length;s++){const r=this.patterns[s];if(r.if.check(e))return r.h(e,n)}throw gt("Unhandled pattern")}}}const Cy=t=>new jy(t),Ud=Cy(Jr).if(Id,(t,e)=>Gi(e,Dc,qr)).if(Md,(t,e)=>Xg(e)).if(by,(t,e)=>Ac(e)).if(xy,(t,e)=>BigInt(Gi(e,Dc,qr))).if(Gr,(t,e)=>Fn(e,Ji(e,t.shape))).if(oy,(t,e)=>{const n={};for(const s in t.shape){let r=t.shape[s];if(sy.check(r)){if(Ac(e))continue;r=r.shape}n[s]=Ud(r,e)}return n}).if(dy,(t,e)=>{const n=[],s=kd(e,0,42);for(let r=0;r<s;r++)n.push(Fn(e,t.shape));return n}).if(Ed,(t,e)=>Ji(e,t.shape)).if(vy,(t,e)=>null).if(my,(t,e)=>{const n=Fn(e,t.res);return()=>n}).if(wy,(t,e)=>Fn(e,Ji(e,[Wn,ss,fi,$d,la,hi,Rd(Wn),Od(us("a","b","c"),Wn)]))).if(cy,(t,e)=>{const n={},s=Gi(e,0,3);for(let r=0;r<s;r++){const i=Fn(e,t.shape.keys),a=Fn(e,t.shape.values);n[i]=a}return n}).done(),Fn=(t,e)=>Ud(Vs(e),t),Nt=typeof document<"u"?document:{},ky=t=>Nt.createElement(t),Ey=()=>Nt.createDocumentFragment();Me(t=>t.nodeType===Ay);const Dy=t=>Nt.createTextNode(t);typeof DOMParser<"u"&&new DOMParser;const Ny=(t,e)=>(Jg(e,(n,s)=>{s===!1?t.removeAttribute(n):s===!0?t.setAttribute(n,""):t.setAttribute(n,s)}),t),Ty=t=>{const e=Ey();for(let n=0;n<t.length;n++)zd(e,t[n]);return e},Oy=(t,e)=>(zd(t,Ty(e)),t),_b=(t,e=[],n=[])=>Oy(Ny(ky(t),e),n);Me(t=>t.nodeType===Py);const Pb=Dy;Me(t=>t.nodeType===Ry);const _y=t=>Um(t,(e,n)=>`${n}:${e};`).join(""),zd=(t,e)=>t.appendChild(e),Py=Nt.ELEMENT_NODE,Ry=Nt.TEXT_NODE;Nt.CDATA_SECTION_NODE;Nt.COMMENT_NODE;const Ly=Nt.DOCUMENT_NODE;Nt.DOCUMENT_TYPE_NODE;const Ay=Nt.DOCUMENT_FRAGMENT_NODE;Me(t=>t.nodeType===Ly);const Wt=Symbol,Vd=Wt(),Bd=Wt(),Fy=Wt(),Iy=Wt(),My=Wt(),Hd=Wt(),$y=Wt(),da=Wt(),Uy=Wt(),zy=t=>{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());const e=[],n=[];let s=0;for(;s<t.length;s++){const r=t[s];if(r===void 0)break;if(r.constructor===String||r.constructor===Number)e.push(r);else if(r.constructor===Object)break}for(s>0&&n.push(e.join(""));s<t.length;s++){const r=t[s];r instanceof Symbol||n.push(r)}return n},Vy={[Vd]:$t("font-weight","bold"),[Bd]:$t("font-weight","normal"),[Fy]:$t("color","blue"),[My]:$t("color","green"),[Iy]:$t("color","grey"),[Hd]:$t("color","red"),[$y]:$t("color","purple"),[da]:$t("color","orange"),[Uy]:$t("color","black")},By=t=>{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());const e=[],n=[],s=tt();let r=[],i=0;for(;i<t.length;i++){const a=t[i],c=Vy[a];if(c!==void 0)s.set(c.left,c.right);else{if(a===void 0)break;if(a.constructor===String||a.constructor===Number){const l=_y(s);i>0||l.length>0?(e.push("%c"+a),n.push(l)):e.push(a)}else break}}for(i>0&&(r=n,r.unshift(e.join("")));i<t.length;i++){const a=t[i];a instanceof Symbol||r.push(a)}return r},qd=Mg?By:zy,Hy=(...t)=>{console.log(...qd(t)),Kd.forEach(e=>e.print(t))},Wd=(...t)=>{console.warn(...qd(t)),t.unshift(da),Kd.forEach(e=>e.print(t))},Kd=on(),Gd=t=>({[Symbol.iterator](){return this},next:t}),qy=(t,e)=>Gd(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),Yi=(t,e)=>Gd(()=>{const{done:n,value:s}=t.next();return{done:n,value:n?void 0:e(s)}});class pi{constructor(e,n){this.clock=e,this.len=n}}class hs{constructor(){this.clients=new Map}}const rs=(t,e,n)=>e.clients.forEach((s,r)=>{const i=t.doc.store.clients.get(r);if(i!=null){const a=i[i.length-1],c=a.id.clock+a.length;for(let l=0,d=s[l];l<s.length&&d.clock<c;d=s[++l])lu(t,i,d.clock,d.len,n)}}),Wy=(t,e)=>{let n=0,s=t.length-1;for(;n<=s;){const r=mt((n+s)/2),i=t[r],a=i.clock;if(a<=e){if(e<a+i.len)return r;n=r+1}else s=r-1}return null},Xs=(t,e)=>{const n=t.clients.get(e.client);return n!==void 0&&Wy(n,e.clock)!==null},ua=t=>{t.clients.forEach(e=>{e.sort((r,i)=>r.clock-i.clock);let n,s;for(n=1,s=1;n<e.length;n++){const r=e[s-1],i=e[n];r.clock+r.len>=i.clock?e[s-1]=new pi(r.clock,vn(r.len,i.clock+i.len-r.clock)):(s<n&&(e[s]=i),s++)}e.length=s})},Co=t=>{const e=new hs;for(let n=0;n<t.length;n++)t[n].clients.forEach((s,r)=>{if(!e.clients.has(r)){const i=s.slice();for(let a=n+1;a<t.length;a++)Vm(i,t[a].clients.get(r)||[]);e.clients.set(r,i)}});return ua(e),e},Bs=(t,e,n,s)=>{Dt(t.clients,e,()=>[]).push(new pi(n,s))},Ky=()=>new hs,Gy=t=>{const e=Ky();return t.clients.forEach((n,s)=>{const r=[];for(let i=0;i<n.length;i++){const a=n[i];if(a.deleted){const c=a.id.clock;let l=a.length;if(i+1<n.length)for(let d=n[i+1];i+1<n.length&&d.deleted;d=n[++i+1])l+=d.length;r.push(new pi(c,l))}}r.length>0&&e.clients.set(s,r)}),e},fs=(t,e)=>{$(t.restEncoder,e.clients.size),Ht(e.clients.entries()).sort((n,s)=>s[0]-n[0]).forEach(([n,s])=>{t.resetDsCurVal(),$(t.restEncoder,n);const r=s.length;$(t.restEncoder,r);for(let i=0;i<r;i++){const a=s[i];t.writeDsClock(a.clock),t.writeDsLen(a.len)}})},ha=t=>{const e=new hs,n=J(t.restDecoder);for(let s=0;s<n;s++){t.resetDsCurVal();const r=J(t.restDecoder),i=J(t.restDecoder);if(i>0){const a=Dt(e.clients,r,()=>[]);for(let c=0;c<i;c++)a.push(new pi(t.readDsClock(),t.readDsLen()))}}return e},Ic=(t,e,n)=>{const s=new hs,r=J(t.restDecoder);for(let i=0;i<r;i++){t.resetDsCurVal();const a=J(t.restDecoder),c=J(t.restDecoder),l=n.clients.get(a)||[],d=Ce(n,a);for(let f=0;f<c;f++){const u=t.readDsClock(),m=u+t.readDsLen();if(u<d){d<m&&Bs(s,a,d,m-d);let p=Ct(l,u),g=l[p];for(!g.deleted&&g.id.clock<u&&(l.splice(p+1,0,si(e,g,u-g.id.clock)),p++);p<l.length&&(g=l[p++],g.id.clock<m);)g.deleted||(m<g.id.clock+g.length&&l.splice(p,0,si(e,g,m-g.id.clock)),g.delete(e))}else Bs(s,a,u,m-u)}}if(s.clients.size>0){const i=new yn;return $(i.restEncoder,0),fs(i,s),i.toUint8Array()}return null},Jd=gd;class Sn extends Jo{constructor({guid:e=vg(),collectionid:n=null,gc:s=!0,gcFilter:r=()=>!0,meta:i=null,autoLoad:a=!1,shouldLoad:c=!0}={}){super(),this.gc=s,this.gcFilter=r,this.clientID=Jd(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new au,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=c,this.autoLoad=a,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=ns(d=>{this.on("load",()=>{this.isLoaded=!0,d(this)})});const l=()=>ns(d=>{const f=u=>{(u===void 0||u===!0)&&(this.off("sync",f),d())};this.on("sync",f)});this.on("sync",d=>{d===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=d===void 0||d===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){const e=this._item;e!==null&&!this.shouldLoad&&de(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Ht(this.subdocs).map(e=>e.guid))}transact(e,n=null){return de(this,e,n)}get(e,n=Ie){const s=Dt(this.share,e,()=>{const i=new n;return i._integrate(this,null),i}),r=s.constructor;if(n!==Ie&&r!==n)if(r===Ie){const i=new n;i._map=s._map,s._map.forEach(a=>{for(;a!==null;a=a.left)a.parent=i}),i._start=s._start;for(let a=i._start;a!==null;a=a.right)a.parent=i;return i._length=s._length,this.share.set(e,i),i._integrate(this,null),i}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return s}getArray(e=""){return this.get(e,Jn)}getText(e=""){return this.get(e,as)}getMap(e=""){return this.get(e,os)}getXmlElement(e=""){return this.get(e,cs)}getXmlFragment(e=""){return this.get(e,wn)}toJSON(){const e={};return this.share.forEach((n,s)=>{e[s]=n.toJSON()}),e}destroy(){this.isDestroyed=!0,Ht(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new Sn({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,de(e.parent.doc,s=>{const r=n.doc;e.deleted||s.subdocsAdded.add(r),s.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class Yd{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return J(this.restDecoder)}readDsLen(){return J(this.restDecoder)}}class Xd extends Yd{readLeftID(){return Z(J(this.restDecoder),J(this.restDecoder))}readRightID(){return Z(J(this.restDecoder),J(this.restDecoder))}readClient(){return J(this.restDecoder)}readInfo(){return ts(this.restDecoder)}readString(){return pt(this.restDecoder)}readParentInfo(){return J(this.restDecoder)===1}readTypeRef(){return J(this.restDecoder)}readLen(){return J(this.restDecoder)}readAny(){return Us(this.restDecoder)}readBuf(){return Kg(qe(this.restDecoder))}readJSON(){return JSON.parse(pt(this.restDecoder))}readKey(){return pt(this.restDecoder)}}class Jy{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=J(this.restDecoder),this.dsCurrVal}readDsLen(){const e=J(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class is extends Jy{constructor(e){super(e),this.keys=[],J(e),this.keyClockDecoder=new Ki(qe(e)),this.clientDecoder=new Ar(qe(e)),this.leftClockDecoder=new Ki(qe(e)),this.rightClockDecoder=new Ki(qe(e)),this.infoDecoder=new Rc(qe(e),ts),this.stringDecoder=new wg(qe(e)),this.parentInfoDecoder=new Rc(qe(e),ts),this.typeRefDecoder=new Ar(qe(e)),this.lenDecoder=new Ar(qe(e))}readLeftID(){return new Kn(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Kn(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Us(this.restDecoder)}readBuf(){return qe(this.restDecoder)}readJSON(){return Us(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const n=this.stringDecoder.read();return this.keys.push(n),n}}}class Zd{constructor(){this.restEncoder=Ee()}toUint8Array(){return he(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){$(this.restEncoder,e)}writeDsLen(e){$(this.restEncoder,e)}}class Zs extends Zd{writeLeftID(e){$(this.restEncoder,e.client),$(this.restEncoder,e.clock)}writeRightID(e){$(this.restEncoder,e.client),$(this.restEncoder,e.clock)}writeClient(e){$(this.restEncoder,e)}writeInfo(e){bo(this.restEncoder,e)}writeString(e){Vt(this.restEncoder,e)}writeParentInfo(e){$(this.restEncoder,e?1:0)}writeTypeRef(e){$(this.restEncoder,e)}writeLen(e){$(this.restEncoder,e)}writeAny(e){$s(this.restEncoder,e)}writeBuf(e){Se(this.restEncoder,e)}writeJSON(e){Vt(this.restEncoder,JSON.stringify(e))}writeKey(e){Vt(this.restEncoder,e)}}class Qd{constructor(){this.restEncoder=Ee(),this.dsCurrVal=0}toUint8Array(){return he(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const n=e-this.dsCurrVal;this.dsCurrVal=e,$(this.restEncoder,n)}writeDsLen(e){e===0&&it(),$(this.restEncoder,e-1),this.dsCurrVal+=e}}class yn extends Qd{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Wi,this.clientEncoder=new Lr,this.leftClockEncoder=new Wi,this.rightClockEncoder=new Wi,this.infoEncoder=new Oc(bo),this.stringEncoder=new lg,this.parentInfoEncoder=new Oc(bo),this.typeRefEncoder=new Lr,this.lenEncoder=new Lr}toUint8Array(){const e=Ee();return $(e,0),Se(e,this.keyClockEncoder.toUint8Array()),Se(e,this.clientEncoder.toUint8Array()),Se(e,this.leftClockEncoder.toUint8Array()),Se(e,this.rightClockEncoder.toUint8Array()),Se(e,he(this.infoEncoder)),Se(e,this.stringEncoder.toUint8Array()),Se(e,he(this.parentInfoEncoder)),Se(e,this.typeRefEncoder.toUint8Array()),Se(e,this.lenEncoder.toUint8Array()),ai(e,he(this.restEncoder)),he(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){$s(this.restEncoder,e)}writeBuf(e){Se(this.restEncoder,e)}writeJSON(e){$s(this.restEncoder,e)}writeKey(e){const n=this.keyMap.get(e);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(n)}}const Yy=(t,e,n,s)=>{s=vn(s,e[0].id.clock);const r=Ct(e,s);$(t.restEncoder,e.length-r),t.writeClient(n),$(t.restEncoder,s);const i=e[r];i.write(t,s-i.id.clock);for(let a=r+1;a<e.length;a++)e[a].write(t,0)},fa=(t,e,n)=>{const s=new Map;n.forEach((r,i)=>{Ce(e,i)>r&&s.set(i,r)}),mi(e).forEach((r,i)=>{n.has(i)||s.set(i,0)}),$(t.restEncoder,s.size),Ht(s.entries()).sort((r,i)=>i[0]-r[0]).forEach(([r,i])=>{Yy(t,e.clients.get(r),r,i)})},Xy=(t,e)=>{const n=tt(),s=J(t.restDecoder);for(let r=0;r<s;r++){const i=J(t.restDecoder),a=new Array(i),c=t.readClient();let l=J(t.restDecoder);n.set(c,{i:0,refs:a});for(let d=0;d<i;d++){const f=t.readInfo();switch(oi&f){case 0:{const u=t.readLen();a[d]=new at(Z(c,l),u),l+=u;break}case 10:{const u=J(t.restDecoder);a[d]=new ct(Z(c,l),u),l+=u;break}default:{const u=(f&(zt|rt))===0,m=new fe(Z(c,l),null,(f&rt)===rt?t.readLeftID():null,null,(f&zt)===zt?t.readRightID():null,u?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,u&&(f&Is)===Is?t.readString():null,Tu(t,f));a[d]=m,l+=m.length}}}}return n},Zy=(t,e,n)=>{const s=[];let r=Ht(n.keys()).sort((p,g)=>p-g);if(r.length===0)return null;const i=()=>{if(r.length===0)return null;let p=n.get(r[r.length-1]);for(;p.refs.length===p.i;)if(r.pop(),r.length>0)p=n.get(r[r.length-1]);else return null;return p};let a=i();if(a===null)return null;const c=new au,l=new Map,d=(p,g)=>{const x=l.get(p);(x==null||x>g)&&l.set(p,g)};let f=a.refs[a.i++];const u=new Map,m=()=>{for(const p of s){const g=p.id.client,x=n.get(g);x?(x.i--,c.clients.set(g,x.refs.slice(x.i)),n.delete(g),x.i=0,x.refs=[]):c.clients.set(g,[p]),r=r.filter(b=>b!==g)}s.length=0};for(;;){if(f.constructor!==ct){const g=Dt(u,f.id.client,()=>Ce(e,f.id.client))-f.id.clock;if(g<0)s.push(f),d(f.id.client,f.id.clock-1),m();else{const x=f.getMissing(t,e);if(x!==null){s.push(f);const b=n.get(x)||{refs:[],i:0};if(b.refs.length===b.i)d(x,Ce(e,x)),m();else{f=b.refs[b.i++];continue}}else(g===0||g<f.length)&&(f.integrate(t,g),u.set(f.id.client,f.id.clock+f.length))}}if(s.length>0)f=s.pop();else if(a!==null&&a.i<a.refs.length)f=a.refs[a.i++];else{if(a=i(),a===null)break;f=a.refs[a.i++]}}if(c.clients.size>0){const p=new yn;return fa(p,c,new Map),$(p.restEncoder,0),{missing:l,update:p.toUint8Array()}}return null},Qy=(t,e)=>fa(t,e.doc.store,e.beforeState),ew=(t,e,n,s=new is(t))=>de(e,r=>{r.local=!1;let i=!1;const a=r.doc,c=a.store,l=Xy(s,a),d=Zy(r,c,l),f=c.pendingStructs;if(f){for(const[m,p]of f.missing)if(p<Ce(c,m)){i=!0;break}if(d){for(const[m,p]of d.missing){const g=f.missing.get(m);(g==null||g>p)&&f.missing.set(m,p)}f.update=Xr([f.update,d.update])}}else c.pendingStructs=d;const u=Ic(s,r,c);if(c.pendingDs){const m=new is(ln(c.pendingDs));J(m.restDecoder);const p=Ic(m,r,c);u&&p?c.pendingDs=Xr([u,p]):c.pendingDs=u||p}else c.pendingDs=u;if(i){const m=c.pendingStructs.update;c.pendingStructs=null,eu(r.doc,m)}},n,!1),eu=(t,e,n,s=is)=>{const r=ln(e);ew(r,t,n,new s(r))},tu=(t,e,n)=>eu(t,e,n,Xd),tw=(t,e,n=new Map)=>{fa(t,e.store,n),fs(t,Gy(e.store))},nw=(t,e=new Uint8Array([0]),n=new yn)=>{const s=nu(e);tw(n,t,s);const r=[n.toUint8Array()];if(t.store.pendingDs&&r.push(t.store.pendingDs),t.store.pendingStructs&&r.push(bw(t.store.pendingStructs.update,e)),r.length>1){if(n.constructor===Zs)return ww(r.map((i,a)=>a===0?i:Sw(i)));if(n.constructor===yn)return Xr(r)}return r[0]},pa=(t,e)=>nw(t,e,new Zs),sw=t=>{const e=new Map,n=J(t.restDecoder);for(let s=0;s<n;s++){const r=J(t.restDecoder),i=J(t.restDecoder);e.set(r,i)}return e},nu=t=>sw(new Yd(ln(t))),su=(t,e)=>($(t.restEncoder,e.size),Ht(e.entries()).sort((n,s)=>s[0]-n[0]).forEach(([n,s])=>{$(t.restEncoder,n),$(t.restEncoder,s)}),t),rw=(t,e)=>su(t,mi(e.store)),iw=(t,e=new Qd)=>(t instanceof Map?su(e,t):rw(e,t),e.toUint8Array()),ow=t=>iw(t,new Zd);class aw{constructor(){this.l=[]}}const Mc=()=>new aw,$c=(t,e)=>t.l.push(e),Uc=(t,e)=>{const n=t.l,s=n.length;t.l=n.filter(r=>e!==r),s===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},ru=(t,e,n)=>ra(t.l,[e,n]);class Kn{constructor(e,n){this.client=e,this.clock=n}}const Bn=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,Z=(t,e)=>new Kn(t,e),iu=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw it()},Yr=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class ou{constructor(e,n,s,r=0){this.type=e,this.tname=n,this.item=s,this.assoc=r}}const Rb=t=>{const e={};return t.type&&(e.type=t.type),t.tname&&(e.tname=t.tname),t.item&&(e.item=t.item),t.assoc!=null&&(e.assoc=t.assoc),e},Lb=t=>new ou(t.type==null?null:Z(t.type.client,t.type.clock),t.tname??null,t.item==null?null:Z(t.item.client,t.item.clock),t.assoc==null?0:t.assoc);class cw{constructor(e,n,s=0){this.type=e,this.index=n,this.assoc=s}}const lw=(t,e,n=0)=>new cw(t,e,n),Nr=(t,e,n)=>{let s=null,r=null;return t._item===null?r=iu(t):s=Z(t._item.id.client,t._item.id.clock),new ou(s,r,e,n)},Ab=(t,e,n=0)=>{let s=t._start;if(n<0){if(e===0)return Nr(t,null,n);e--}for(;s!==null;){if(!s.deleted&&s.countable){if(s.length>e)return Nr(t,Z(s.id.client,s.id.clock+e),n);e-=s.length}if(s.right===null&&n<0)return Nr(t,s.lastId,n);s=s.right}return Nr(t,null,n)},dw=(t,e)=>{const n=Gn(t,e),s=e.clock-n.id.clock;return{item:n,diff:s}},Fb=(t,e,n=!0)=>{const s=e.store,r=t.item,i=t.type,a=t.tname,c=t.assoc;let l=null,d=0;if(r!==null){if(Ce(s,r.client)<=r.clock)return null;const f=n?No(s,r):dw(s,r),u=f.item;if(!(u instanceof fe))return null;if(l=u.parent,l._item===null||!l._item.deleted){d=u.deleted||!u.countable?0:f.diff+(c>=0?0:1);let m=u.left;for(;m!==null;)!m.deleted&&m.countable&&(d+=m.length),m=m.left}}else{if(a!==null)l=e.get(a);else if(i!==null){if(Ce(s,i.client)<=i.clock)return null;const{item:f}=n?No(s,i):{item:Gn(s,i)};if(f instanceof fe&&f.content instanceof Tt)l=f.content.type;else return null}else throw it();c>=0?d=l._length:d=0}return lw(l,d,t.assoc)},Ib=(t,e)=>t===e||t!==null&&e!==null&&t.tname===e.tname&&Bn(t.item,e.item)&&Bn(t.type,e.type)&&t.assoc===e.assoc,$n=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!Xs(e.ds,t.id),ko=(t,e)=>{const n=Dt(t.meta,ko,on),s=t.doc.store;n.has(e)||(e.sv.forEach((r,i)=>{r<Ce(s,i)&&et(t,Z(i,r))}),rs(t,e.ds,r=>{}),n.add(e))};class au{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const mi=t=>{const e=new Map;return t.clients.forEach((n,s)=>{const r=n[n.length-1];e.set(s,r.id.clock+r.length)}),e},Ce=(t,e)=>{const n=t.clients.get(e);if(n===void 0)return 0;const s=n[n.length-1];return s.id.clock+s.length},cu=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{const s=n[n.length-1];if(s.id.clock+s.length!==e.id.clock)throw it()}n.push(e)},Ct=(t,e)=>{let n=0,s=t.length-1,r=t[s],i=r.id.clock;if(i===e)return s;let a=mt(e/(i+r.length-1)*s);for(;n<=s;){if(r=t[a],i=r.id.clock,i<=e){if(e<i+r.length)return a;n=a+1}else s=a-1;a=mt((n+s)/2)}throw it()},uw=(t,e)=>{const n=t.clients.get(e.client);return n[Ct(n,e.clock)]},Gn=uw,Eo=(t,e,n)=>{const s=Ct(e,n),r=e[s];return r.id.clock<n&&r instanceof fe?(e.splice(s+1,0,si(t,r,n-r.id.clock)),s+1):s},et=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[Eo(t,n,e.clock)]},zc=(t,e,n)=>{const s=e.clients.get(n.client),r=Ct(s,n.clock),i=s[r];return n.clock!==i.id.clock+i.length-1&&i.constructor!==at&&s.splice(r+1,0,si(t,i,n.clock-i.id.clock+1)),i},hw=(t,e,n)=>{const s=t.clients.get(e.id.client);s[Ct(s,e.id.clock)]=n},lu=(t,e,n,s,r)=>{if(s===0)return;const i=n+s;let a=Eo(t,e,n),c;do c=e[a++],i<c.id.clock+c.length&&Eo(t,e,i),r(c);while(a<e.length&&e[a].id.clock<i)};class fw{constructor(e,n,s){this.doc=e,this.deleteSet=new hs,this.beforeState=mi(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=s,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const Vc=(t,e)=>e.deleteSet.clients.size===0&&!zm(e.afterState,(n,s)=>e.beforeState.get(s)!==n)?!1:(ua(e.deleteSet),Qy(t,e),fs(t,e.deleteSet),!0),Bc=(t,e,n)=>{const s=e._item;(s===null||s.id.clock<(t.beforeState.get(s.id.client)||0)&&!s.deleted)&&Dt(t.changed,e,on).add(n)},Fr=(t,e)=>{let n=t[e],s=t[e-1],r=e;for(;r>0;n=s,s=t[--r-1]){if(s.deleted===n.deleted&&s.constructor===n.constructor&&s.mergeWith(n)){n instanceof fe&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,s);continue}break}const i=e-r;return i&&t.splice(e+1-i,i),i},pw=(t,e,n)=>{for(const[s,r]of t.clients.entries()){const i=e.clients.get(s);for(let a=r.length-1;a>=0;a--){const c=r[a],l=c.clock+c.len;for(let d=Ct(i,c.clock),f=i[d];d<i.length&&f.id.clock<l;f=i[++d]){const u=i[d];if(c.clock+c.len<=u.id.clock)break;u instanceof fe&&u.deleted&&!u.keep&&n(u)&&u.gc(e,!1)}}}},mw=(t,e)=>{t.clients.forEach((n,s)=>{const r=e.clients.get(s);for(let i=n.length-1;i>=0;i--){const a=n[i],c=Yo(r.length-1,1+Ct(r,a.clock+a.len-1));for(let l=c,d=r[l];l>0&&d.id.clock>=a.clock;d=r[l])l-=1+Fr(r,l)}})},du=(t,e)=>{if(e<t.length){const n=t[e],s=n.doc,r=s.store,i=n.deleteSet,a=n._mergeStructs;try{ua(i),n.afterState=mi(n.doc.store),s.emit("beforeObserverCalls",[n,s]);const c=[];n.changed.forEach((l,d)=>c.push(()=>{(d._item===null||!d._item.deleted)&&d._callObserver(n,l)})),c.push(()=>{n.changedParentTypes.forEach((l,d)=>{d._dEH.l.length>0&&(d._item===null||!d._item.deleted)&&(l=l.filter(f=>f.target._item===null||!f.target._item.deleted),l.forEach(f=>{f.currentTarget=d,f._path=null}),l.sort((f,u)=>f.path.length-u.path.length),c.push(()=>{ru(d._dEH,l,n)}))}),c.push(()=>s.emit("afterTransaction",[n,s])),c.push(()=>{n._needFormattingCleanup&&Fw(n)})}),ra(c,[])}finally{s.gc&&pw(i,r,s.gcFilter),mw(i,r),n.afterState.forEach((f,u)=>{const m=n.beforeState.get(u)||0;if(m!==f){const p=r.clients.get(u),g=vn(Ct(p,m),1);for(let x=p.length-1;x>=g;)x-=1+Fr(p,x)}});for(let f=a.length-1;f>=0;f--){const{client:u,clock:m}=a[f].id,p=r.clients.get(u),g=Ct(p,m);g+1<p.length&&Fr(p,g+1)>1||g>0&&Fr(p,g)}if(!n.local&&n.afterState.get(s.clientID)!==n.beforeState.get(s.clientID)&&(Hy(da,Vd,"[yjs] ",Bd,Hd,"Changed the client-id because another client seems to be using it."),s.clientID=Jd()),s.emit("afterTransactionCleanup",[n,s]),s._observers.has("update")){const f=new Zs;Vc(f,n)&&s.emit("update",[f.toUint8Array(),n.origin,s,n])}if(s._observers.has("updateV2")){const f=new yn;Vc(f,n)&&s.emit("updateV2",[f.toUint8Array(),n.origin,s,n])}const{subdocsAdded:c,subdocsLoaded:l,subdocsRemoved:d}=n;(c.size>0||d.size>0||l.size>0)&&(c.forEach(f=>{f.clientID=s.clientID,f.collectionid==null&&(f.collectionid=s.collectionid),s.subdocs.add(f)}),d.forEach(f=>s.subdocs.delete(f)),s.emit("subdocs",[{loaded:l,added:c,removed:d},s,n]),d.forEach(f=>f.destroy())),t.length<=e+1?(s._transactionCleanups=[],s.emit("afterAllTransactions",[s,t])):du(t,e+1)}}},de=(t,e,n=null,s=!0)=>{const r=t._transactionCleanups;let i=!1,a=null;t._transaction===null&&(i=!0,t._transaction=new fw(t,n,s),r.push(t._transaction),r.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{a=e(t._transaction)}finally{if(i){const c=t._transaction===r[0];t._transaction=null,c&&du(r,0)}}return a};class gw{constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const Hc=(t,e,n)=>{rs(t,n.deletions,s=>{s instanceof fe&&e.scope.some(r=>r===t.doc||Yr(r,s))&&Sa(s,!1)})},qc=(t,e,n)=>{let s=null;const r=t.doc,i=t.scope;de(r,c=>{for(;e.length>0&&t.currStackItem===null;){const l=r.store,d=e.pop(),f=new Set,u=[];let m=!1;rs(c,d.insertions,p=>{if(p instanceof fe){if(p.redone!==null){let{item:g,diff:x}=No(l,p.id);x>0&&(g=et(c,Z(g.id.client,g.id.clock+x))),p=g}!p.deleted&&i.some(g=>g===c.doc||Yr(g,p))&&u.push(p)}}),rs(c,d.deletions,p=>{p instanceof fe&&i.some(g=>g===c.doc||Yr(g,p))&&!Xs(d.insertions,p.id)&&f.add(p)}),f.forEach(p=>{m=Nu(c,p,f,d.insertions,t.ignoreRemoteMapChanges,t)!==null||m});for(let p=u.length-1;p>=0;p--){const g=u[p];t.deleteFilter(g)&&(g.delete(c),m=!0)}t.currStackItem=m?d:null}c.changed.forEach((l,d)=>{l.has(null)&&d._searchMarker&&(d._searchMarker.length=0)}),s=c},t);const a=t.currStackItem;if(a!=null){const c=s.changedParentTypes;t.emit("stack-item-popped",[{stackItem:a,type:n,changedParentTypes:c,origin:t},t]),t.currStackItem=null}return a};class Mb extends Jo{constructor(e,{captureTimeout:n=500,captureTransaction:s=l=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:c=es(e)?e[0].doc:e instanceof Sn?e:e.doc}={}){super(),this.scope=[],this.doc=c,this.addToScope(e),this.deleteFilter=r,i.add(this),this.trackedOrigins=i,this.captureTransaction=s,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=a,this.captureTimeout=n,this.afterTransactionHandler=l=>{if(!this.captureTransaction(l)||!this.scope.some(b=>l.changedParentTypes.has(b)||b===this.doc)||!this.trackedOrigins.has(l.origin)&&(!l.origin||!this.trackedOrigins.has(l.origin.constructor)))return;const d=this.undoing,f=this.redoing,u=d?this.redoStack:this.undoStack;d?this.stopCapturing():f||this.clear(!1,!0);const m=new hs;l.afterState.forEach((b,j)=>{const C=l.beforeState.get(j)||0,T=b-C;T>0&&Bs(m,j,C,T)});const p=an();let g=!1;if(this.lastChange>0&&p-this.lastChange<this.captureTimeout&&u.length>0&&!d&&!f){const b=u[u.length-1];b.deletions=Co([b.deletions,l.deleteSet]),b.insertions=Co([b.insertions,m])}else u.push(new gw(l.deleteSet,m)),g=!0;!d&&!f&&(this.lastChange=p),rs(l,l.deleteSet,b=>{b instanceof fe&&this.scope.some(j=>j===l.doc||Yr(j,b))&&Sa(b,!0)});const x=[{stackItem:u[u.length-1],origin:l.origin,type:d?"redo":"undo",changedParentTypes:l.changedParentTypes},this];g?this.emit("stack-item-added",x):this.emit("stack-item-updated",x)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){const n=new Set(this.scope);e=es(e)?e:[e],e.forEach(s=>{n.has(s)||(n.add(s),(s instanceof Ie?s.doc!==this.doc:s!==this.doc)&&Wd("[yjs#509] Not same Y.Doc"),this.scope.push(s))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,n=!0){(e&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(s=>{e&&(this.undoStack.forEach(r=>Hc(s,this,r)),this.undoStack=[]),n&&(this.redoStack.forEach(r=>Hc(s,this,r)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=qc(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=qc(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}}function*yw(t){const e=J(t.restDecoder);for(let n=0;n<e;n++){const s=J(t.restDecoder),r=t.readClient();let i=J(t.restDecoder);for(let a=0;a<s;a++){const c=t.readInfo();if(c===10){const l=J(t.restDecoder);yield new ct(Z(r,i),l),i+=l}else if((oi&c)!==0){const l=(c&(zt|rt))===0,d=new fe(Z(r,i),null,(c&rt)===rt?t.readLeftID():null,null,(c&zt)===zt?t.readRightID():null,l?t.readParentInfo()?t.readString():t.readLeftID():null,l&&(c&Is)===Is?t.readString():null,Tu(t,c));yield d,i+=d.length}else{const l=t.readLen();yield new at(Z(r,i),l),i+=l}}}}class ma{constructor(e,n){this.gen=yw(e),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===ct);return this.curr}}class ga{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const ww=t=>Xr(t,Xd,Zs),xw=(t,e)=>{if(t.constructor===at){const{client:n,clock:s}=t.id;return new at(Z(n,s+e),t.length-e)}else if(t.constructor===ct){const{client:n,clock:s}=t.id;return new ct(Z(n,s+e),t.length-e)}else{const n=t,{client:s,clock:r}=n.id;return new fe(Z(s,r+e),null,Z(s,r+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},Xr=(t,e=is,n=yn)=>{if(t.length===1)return t[0];const s=t.map(f=>new e(ln(f)));let r=s.map(f=>new ma(f,!0)),i=null;const a=new n,c=new ga(a);for(;r=r.filter(m=>m.curr!==null),r.sort((m,p)=>{if(m.curr.id.client===p.curr.id.client){const g=m.curr.id.clock-p.curr.id.clock;return g===0?m.curr.constructor===p.curr.constructor?0:m.curr.constructor===ct?1:-1:g}else return p.curr.id.client-m.curr.id.client}),r.length!==0;){const f=r[0],u=f.curr.id.client;if(i!==null){let m=f.curr,p=!1;for(;m!==null&&m.id.clock+m.length<=i.struct.id.clock+i.struct.length&&m.id.client>=i.struct.id.client;)m=f.next(),p=!0;if(m===null||m.id.client!==u||p&&m.id.clock>i.struct.id.clock+i.struct.length)continue;if(u!==i.struct.id.client)tn(c,i.struct,i.offset),i={struct:m,offset:0},f.next();else if(i.struct.id.clock+i.struct.length<m.id.clock)if(i.struct.constructor===ct)i.struct.length=m.id.clock+m.length-i.struct.id.clock;else{tn(c,i.struct,i.offset);const g=m.id.clock-i.struct.id.clock-i.struct.length;i={struct:new ct(Z(u,i.struct.id.clock+i.struct.length),g),offset:0}}else{const g=i.struct.id.clock+i.struct.length-m.id.clock;g>0&&(i.struct.constructor===ct?i.struct.length-=g:m=xw(m,g)),i.struct.mergeWith(m)||(tn(c,i.struct,i.offset),i={struct:m,offset:0},f.next())}}else i={struct:f.curr,offset:0},f.next();for(let m=f.curr;m!==null&&m.id.client===u&&m.id.clock===i.struct.id.clock+i.struct.length&&m.constructor!==ct;m=f.next())tn(c,i.struct,i.offset),i={struct:m,offset:0}}i!==null&&(tn(c,i.struct,i.offset),i=null),ya(c);const l=s.map(f=>ha(f)),d=Co(l);return fs(a,d),a.toUint8Array()},bw=(t,e,n=is,s=yn)=>{const r=nu(e),i=new s,a=new ga(i),c=new n(ln(t)),l=new ma(c,!1);for(;l.curr;){const f=l.curr,u=f.id.client,m=r.get(u)||0;if(l.curr.constructor===ct){l.next();continue}if(f.id.clock+f.length>m)for(tn(a,f,vn(m-f.id.clock,0)),l.next();l.curr&&l.curr.id.client===u;)tn(a,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===u&&l.curr.id.clock+l.curr.length<=m;)l.next()}ya(a);const d=ha(c);return fs(i,d),i.toUint8Array()},uu=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:he(t.encoder.restEncoder)}),t.encoder.restEncoder=Ee(),t.written=0)},tn=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&uu(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),$(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},ya=t=>{uu(t);const e=t.encoder.restEncoder;$(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const s=t.clientStructs[n];$(e,s.written),ai(e,s.restEncoder)}},vw=(t,e,n,s)=>{const r=new n(ln(t)),i=new ma(r,!1),a=new s,c=new ga(a);for(let d=i.curr;d!==null;d=i.next())tn(c,e(d),0);ya(c);const l=ha(r);return fs(a,l),a.toUint8Array()},Sw=t=>vw(t,Rg,is,Zs),Wc="You must not compute changes after the event-handler fired.";class gi{constructor(e,n){this.target=e,this.currentTarget=e,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=jw(this.currentTarget,this.target))}deletes(e){return Xs(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw gt(Wc);const e=new Map,n=this.target;this.transaction.changed.get(n).forEach(r=>{if(r!==null){const i=n._map.get(r);let a,c;if(this.adds(i)){let l=i.left;for(;l!==null&&this.adds(l);)l=l.left;if(this.deletes(i))if(l!==null&&this.deletes(l))a="delete",c=Bi(l.content.getContent());else return;else l!==null&&this.deletes(l)?(a="update",c=Bi(l.content.getContent())):(a="add",c=void 0)}else if(this.deletes(i))a="delete",c=Bi(i.content.getContent());else return;e.set(r,{action:a,oldValue:c})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw gt(Wc);const n=this.target,s=on(),r=on(),i=[];if(e={added:s,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(n).has(null)){let c=null;const l=()=>{c&&i.push(c)};for(let d=n._start;d!==null;d=d.right)d.deleted?this.deletes(d)&&!this.adds(d)&&((c===null||c.delete===void 0)&&(l(),c={delete:0}),c.delete+=d.length,r.add(d)):this.adds(d)?((c===null||c.insert===void 0)&&(l(),c={insert:[]}),c.insert=c.insert.concat(d.content.getContent()),s.add(d)):((c===null||c.retain===void 0)&&(l(),c={retain:0}),c.retain+=d.length);c!==null&&c.retain===void 0&&l()}this._changes=e}return e}}const jw=(t,e)=>{const n=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let s=0,r=e._item.parent._start;for(;r!==e._item&&r!==null;)!r.deleted&&r.countable&&(s+=r.length),r=r.right;n.unshift(s)}e=e._item.parent}return n},We=()=>{Wd("Invalid access: Add Yjs type to a document before reading data.")},hu=80;let wa=0;class Cw{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=wa++}}const kw=t=>{t.timestamp=wa++},fu=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=wa++},Ew=(t,e,n)=>{if(t.length>=hu){const s=t.reduce((r,i)=>r.timestamp<i.timestamp?r:i);return fu(s,e,n),s}else{const s=new Cw(e,n);return t.push(s),s}},yi=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;const n=t._searchMarker.length===0?null:t._searchMarker.reduce((i,a)=>Rr(e-i.index)<Rr(e-a.index)?i:a);let s=t._start,r=0;for(n!==null&&(s=n.p,r=n.index,kw(n));s.right!==null&&r<e;){if(!s.deleted&&s.countable){if(e<r+s.length)break;r+=s.length}s=s.right}for(;s.left!==null&&r>e;)s=s.left,!s.deleted&&s.countable&&(r-=s.length);for(;s.left!==null&&s.left.id.client===s.id.client&&s.left.id.clock+s.left.length===s.id.clock;)s=s.left,!s.deleted&&s.countable&&(r-=s.length);return n!==null&&Rr(n.index-r)<s.parent.length/hu?(fu(n,s,r),n):Ew(t._searchMarker,s,r)},Hs=(t,e,n)=>{for(let s=t.length-1;s>=0;s--){const r=t[s];if(n>0){let i=r.p;for(i.marker=!1;i&&(i.deleted||!i.countable);)i=i.left,i&&!i.deleted&&i.countable&&(r.index-=i.length);if(i===null||i.marker===!0){t.splice(s,1);continue}r.p=i,i.marker=!0}(e<r.index||n>0&&e===r.index)&&(r.index=vn(e,r.index+n))}},wi=(t,e,n)=>{const s=t,r=e.changedParentTypes;for(;Dt(r,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;ru(s._eH,n,e)};class Ie{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Mc(),this._dEH=Mc(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw ft()}clone(){throw ft()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,n){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){$c(this._eH,e)}observeDeep(e){$c(this._dEH,e)}unobserve(e){Uc(this._eH,e)}unobserveDeep(e){Uc(this._dEH,e)}toJSON(){}}const pu=(t,e,n)=>{t.doc??We(),e<0&&(e=t._length+e),n<0&&(n=t._length+n);let s=n-e;const r=[];let i=t._start;for(;i!==null&&s>0;){if(i.countable&&!i.deleted){const a=i.content.getContent();if(a.length<=e)e-=a.length;else{for(let c=e;c<a.length&&s>0;c++)r.push(a[c]),s--;e=0}}i=i.right}return r},mu=t=>{t.doc??We();const e=[];let n=t._start;for(;n!==null;){if(n.countable&&!n.deleted){const s=n.content.getContent();for(let r=0;r<s.length;r++)e.push(s[r])}n=n.right}return e},qs=(t,e)=>{let n=0,s=t._start;for(t.doc??We();s!==null;){if(s.countable&&!s.deleted){const r=s.content.getContent();for(let i=0;i<r.length;i++)e(r[i],n++,t)}s=s.right}},gu=(t,e)=>{const n=[];return qs(t,(s,r)=>{n.push(e(s,r,t))}),n},Dw=t=>{let e=t._start,n=null,s=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),s=0,e=e.right}const r=n[s++];return n.length<=s&&(n=null),{done:!1,value:r}}}},yu=(t,e)=>{t.doc??We();const n=yi(t,e);let s=t._start;for(n!==null&&(s=n.p,e-=n.index);s!==null;s=s.right)if(!s.deleted&&s.countable){if(e<s.length)return s.content.getContent()[e];e-=s.length}},Zr=(t,e,n,s)=>{let r=n;const i=t.doc,a=i.clientID,c=i.store,l=n===null?e._start:n.right;let d=[];const f=()=>{d.length>0&&(r=new fe(Z(a,Ce(c,a)),r,r&&r.lastId,l,l&&l.id,e,null,new xn(d)),r.integrate(t,0),d=[])};s.forEach(u=>{if(u===null)d.push(u);else switch(u.constructor){case Number:case Object:case Boolean:case Array:case String:d.push(u);break;default:switch(f(),u.constructor){case Uint8Array:case ArrayBuffer:r=new fe(Z(a,Ce(c,a)),r,r&&r.lastId,l,l&&l.id,e,null,new Qs(new Uint8Array(u))),r.integrate(t,0);break;case Sn:r=new fe(Z(a,Ce(c,a)),r,r&&r.lastId,l,l&&l.id,e,null,new er(u)),r.integrate(t,0);break;default:if(u instanceof Ie)r=new fe(Z(a,Ce(c,a)),r,r&&r.lastId,l,l&&l.id,e,null,new Tt(u)),r.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),f()},wu=()=>gt("Length exceeded!"),xu=(t,e,n,s)=>{if(n>e._length)throw wu();if(n===0)return e._searchMarker&&Hs(e._searchMarker,n,s.length),Zr(t,e,null,s);const r=n,i=yi(e,n);let a=e._start;for(i!==null&&(a=i.p,n-=i.index,n===0&&(a=a.prev,n+=a&&a.countable&&!a.deleted?a.length:0));a!==null;a=a.right)if(!a.deleted&&a.countable){if(n<=a.length){n<a.length&&et(t,Z(a.id.client,a.id.clock+n));break}n-=a.length}return e._searchMarker&&Hs(e._searchMarker,r,s.length),Zr(t,e,a,s)},Nw=(t,e,n)=>{let r=(e._searchMarker||[]).reduce((i,a)=>a.index>i.index?a:i,{index:0,p:e._start}).p;if(r)for(;r.right;)r=r.right;return Zr(t,e,r,n)},bu=(t,e,n,s)=>{if(s===0)return;const r=n,i=s,a=yi(e,n);let c=e._start;for(a!==null&&(c=a.p,n-=a.index);c!==null&&n>0;c=c.right)!c.deleted&&c.countable&&(n<c.length&&et(t,Z(c.id.client,c.id.clock+n)),n-=c.length);for(;s>0&&c!==null;)c.deleted||(s<c.length&&et(t,Z(c.id.client,c.id.clock+s)),c.delete(t),s-=c.length),c=c.right;if(s>0)throw wu();e._searchMarker&&Hs(e._searchMarker,r,-i+s)},Qr=(t,e,n)=>{const s=e._map.get(n);s!==void 0&&s.delete(t)},xa=(t,e,n,s)=>{const r=e._map.get(n)||null,i=t.doc,a=i.clientID;let c;if(s==null)c=new xn([s]);else switch(s.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:c=new xn([s]);break;case Uint8Array:c=new Qs(s);break;case Sn:c=new er(s);break;default:if(s instanceof Ie)c=new Tt(s);else throw new Error("Unexpected content type")}new fe(Z(a,Ce(i.store,a)),r,r&&r.lastId,null,null,e,n,c).integrate(t,0)},ba=(t,e)=>{t.doc??We();const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},vu=t=>{const e={};return t.doc??We(),t._map.forEach((n,s)=>{n.deleted||(e[s]=n.content.getContent()[n.length-1])}),e},Su=(t,e)=>{t.doc??We();const n=t._map.get(e);return n!==void 0&&!n.deleted},Tw=(t,e)=>{const n={};return t._map.forEach((s,r)=>{let i=s;for(;i!==null&&(!e.sv.has(i.id.client)||i.id.clock>=(e.sv.get(i.id.client)||0));)i=i.left;i!==null&&$n(i,e)&&(n[r]=i.content.getContent()[i.length-1])}),n},Tr=t=>(t.doc??We(),qy(t._map.entries(),e=>!e[1].deleted));class Ow extends gi{}class Jn extends Ie{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new Jn;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Jn}clone(){const e=new Jn;return e.insert(0,this.toArray().map(n=>n instanceof Ie?n.clone():n)),e}get length(){return this.doc??We(),this._length}_callObserver(e,n){super._callObserver(e,n),wi(this,e,new Ow(this,e))}insert(e,n){this.doc!==null?de(this.doc,s=>{xu(s,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?de(this.doc,n=>{Nw(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?de(this.doc,s=>{bu(s,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return yu(this,e)}toArray(){return mu(this)}slice(e=0,n=this.length){return pu(this,e,n)}toJSON(){return this.map(e=>e instanceof Ie?e.toJSON():e)}map(e){return gu(this,e)}forEach(e){qs(this,e)}[Symbol.iterator](){return Dw(this)}_write(e){e.writeTypeRef(tx)}}const _w=t=>new Jn;class Pw extends gi{constructor(e,n,s){super(e,n),this.keysChanged=s}}class os extends Ie{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,n){super._integrate(e,n),this._prelimContent.forEach((s,r)=>{this.set(r,s)}),this._prelimContent=null}_copy(){return new os}clone(){const e=new os;return this.forEach((n,s)=>{e.set(s,n instanceof Ie?n.clone():n)}),e}_callObserver(e,n){wi(this,e,new Pw(this,e,n))}toJSON(){this.doc??We();const e={};return this._map.forEach((n,s)=>{if(!n.deleted){const r=n.content.getContent()[n.length-1];e[s]=r instanceof Ie?r.toJSON():r}}),e}get size(){return[...Tr(this)].length}keys(){return Yi(Tr(this),e=>e[0])}values(){return Yi(Tr(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Yi(Tr(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??We(),this._map.forEach((n,s)=>{n.deleted||e(n.content.getContent()[n.length-1],s,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?de(this.doc,n=>{Qr(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?de(this.doc,s=>{xa(s,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return ba(this,e)}has(e){return Su(this,e)}clear(){this.doc!==null?de(this.doc,e=>{this.forEach(function(n,s,r){Qr(e,r,s)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(nx)}}const Rw=t=>new os,nn=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&_g(t,e);class Do{constructor(e,n,s,r){this.left=e,this.right=n,this.index=s,this.currentAttributes=r}forward(){this.right===null&&it(),this.right.content.constructor===Oe?this.right.deleted||ps(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}}const Kc=(t,e,n)=>{for(;e.right!==null&&n>0;)e.right.content.constructor===Oe?e.right.deleted||ps(e.currentAttributes,e.right.content):e.right.deleted||(n<e.right.length&&et(t,Z(e.right.id.client,e.right.id.clock+n)),e.index+=e.right.length,n-=e.right.length),e.left=e.right,e.right=e.right.right;return e},Or=(t,e,n,s)=>{const r=new Map,i=s?yi(e,n):null;if(i){const a=new Do(i.p.left,i.p,i.index,r);return Kc(t,a,n-i.index)}else{const a=new Do(null,e._start,0,r);return Kc(t,a,n)}},ju=(t,e,n,s)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===Oe&&nn(s.get(n.right.content.key),n.right.content.value));)n.right.deleted||s.delete(n.right.content.key),n.forward();const r=t.doc,i=r.clientID;s.forEach((a,c)=>{const l=n.left,d=n.right,f=new fe(Z(i,Ce(r.store,i)),l,l&&l.lastId,d,d&&d.id,e,null,new Oe(c,a));f.integrate(t,0),n.right=f,n.forward()})},ps=(t,e)=>{const{key:n,value:s}=e;s===null?t.delete(n):t.set(n,s)},Cu=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===Oe&&nn(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},ku=(t,e,n,s)=>{const r=t.doc,i=r.clientID,a=new Map;for(const c in s){const l=s[c],d=n.currentAttributes.get(c)??null;if(!nn(d,l)){a.set(c,d);const{left:f,right:u}=n;n.right=new fe(Z(i,Ce(r.store,i)),f,f&&f.lastId,u,u&&u.id,e,null,new Oe(c,l)),n.right.integrate(t,0),n.forward()}}return a},Xi=(t,e,n,s,r)=>{n.currentAttributes.forEach((m,p)=>{r[p]===void 0&&(r[p]=null)});const i=t.doc,a=i.clientID;Cu(n,r);const c=ku(t,e,n,r),l=s.constructor===String?new kt(s):s instanceof Ie?new Tt(s):new jn(s);let{left:d,right:f,index:u}=n;e._searchMarker&&Hs(e._searchMarker,n.index,l.getLength()),f=new fe(Z(a,Ce(i.store,a)),d,d&&d.lastId,f,f&&f.id,e,null,l),f.integrate(t,0),n.right=f,n.index=u,n.forward(),ju(t,e,n,c)},Gc=(t,e,n,s,r)=>{const i=t.doc,a=i.clientID;Cu(n,r);const c=ku(t,e,n,r);e:for(;n.right!==null&&(s>0||c.size>0&&(n.right.deleted||n.right.content.constructor===Oe));){if(!n.right.deleted)switch(n.right.content.constructor){case Oe:{const{key:l,value:d}=n.right.content,f=r[l];if(f!==void 0){if(nn(f,d))c.delete(l);else{if(s===0)break e;c.set(l,d)}n.right.delete(t)}else n.currentAttributes.set(l,d);break}default:s<n.right.length&&et(t,Z(n.right.id.client,n.right.id.clock+s)),s-=n.right.length;break}n.forward()}if(s>0){let l="";for(;s>0;s--)l+=`
|
|
10
|
-
`;n.right=new fe(Z(a,Ce(i.store,a)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new kt(l)),n.right.integrate(t,0),n.forward()}ju(t,e,n,c)},Eu=(t,e,n,s,r)=>{let i=e;const a=tt();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===Oe){const d=i.content;a.set(d.key,d)}i=i.right}let c=0,l=!1;for(;e!==i;){if(n===e&&(l=!0),!e.deleted){const d=e.content;if(d.constructor===Oe){const{key:f,value:u}=d,m=s.get(f)??null;(a.get(f)!==d||m===u)&&(e.delete(t),c++,!l&&(r.get(f)??null)===u&&m!==u&&(m===null?r.delete(f):r.set(f,m))),!l&&!e.deleted&&ps(r,d)}}e=e.right}return c},Lw=(t,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const n=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===Oe){const s=e.content.key;n.has(s)?e.delete(t):n.add(s)}e=e.left}},Aw=t=>{let e=0;return de(t.doc,n=>{let s=t._start,r=t._start,i=tt();const a=wo(i);for(;r;)r.deleted===!1&&(r.content.constructor===Oe?ps(a,r.content):(e+=Eu(n,s,r,i,a),i=wo(a),s=r)),r=r.right}),e},Fw=t=>{const e=new Set,n=t.doc;for(const[s,r]of t.afterState.entries()){const i=t.beforeState.get(s)||0;r!==i&&lu(t,n.store.clients.get(s),i,r,a=>{!a.deleted&&a.content.constructor===Oe&&a.constructor!==at&&e.add(a.parent)})}de(n,s=>{rs(t,t.deleteSet,r=>{if(r instanceof at||!r.parent._hasFormatting||e.has(r.parent))return;const i=r.parent;r.content.constructor===Oe?e.add(i):Lw(s,r)});for(const r of e)Aw(r)})},Jc=(t,e,n)=>{const s=n,r=wo(e.currentAttributes),i=e.right;for(;n>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case Tt:case jn:case kt:n<e.right.length&&et(t,Z(e.right.id.client,e.right.id.clock+n)),n-=e.right.length,e.right.delete(t);break}e.forward()}i&&Eu(t,i,e.right,r,e.currentAttributes);const a=(e.left||e.right).parent;return a._searchMarker&&Hs(a._searchMarker,e.index,-s+n),e};class Iw extends gi{constructor(e,n,s){super(e,n),this.childListChanged=!1,this.keysChanged=new Set,s.forEach(r=>{r===null?this.childListChanged=!0:this.keysChanged.add(r)})}get changes(){if(this._changes===null){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){const e=this.target.doc,n=[];de(e,s=>{const r=new Map,i=new Map;let a=this.target._start,c=null;const l={};let d="",f=0,u=0;const m=()=>{if(c!==null){let p=null;switch(c){case"delete":u>0&&(p={delete:u}),u=0;break;case"insert":(typeof d=="object"||d.length>0)&&(p={insert:d},r.size>0&&(p.attributes={},r.forEach((g,x)=>{g!==null&&(p.attributes[x]=g)}))),d="";break;case"retain":f>0&&(p={retain:f},Og(l)||(p.attributes=Eg({},l))),f=0;break}p&&n.push(p),c=null}};for(;a!==null;){switch(a.content.constructor){case Tt:case jn:this.adds(a)?this.deletes(a)||(m(),c="insert",d=a.content.getContent()[0],m()):this.deletes(a)?(c!=="delete"&&(m(),c="delete"),u+=1):a.deleted||(c!=="retain"&&(m(),c="retain"),f+=1);break;case kt:this.adds(a)?this.deletes(a)||(c!=="insert"&&(m(),c="insert"),d+=a.content.str):this.deletes(a)?(c!=="delete"&&(m(),c="delete"),u+=a.length):a.deleted||(c!=="retain"&&(m(),c="retain"),f+=a.length);break;case Oe:{const{key:p,value:g}=a.content;if(this.adds(a)){if(!this.deletes(a)){const x=r.get(p)??null;nn(x,g)?g!==null&&a.delete(s):(c==="retain"&&m(),nn(g,i.get(p)??null)?delete l[p]:l[p]=g)}}else if(this.deletes(a)){i.set(p,g);const x=r.get(p)??null;nn(x,g)||(c==="retain"&&m(),l[p]=x)}else if(!a.deleted){i.set(p,g);const x=l[p];x!==void 0&&(nn(x,g)?x!==null&&a.delete(s):(c==="retain"&&m(),g===null?delete l[p]:l[p]=g))}a.deleted||(c==="insert"&&m(),ps(r,a.content));break}}a=a.right}for(m();n.length>0;){const p=n[n.length-1];if(p.retain!==void 0&&p.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}}class as extends Ie{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??We(),this._length}_integrate(e,n){super._integrate(e,n);try{this._pending.forEach(s=>s())}catch(s){console.error(s)}this._pending=null}_copy(){return new as}clone(){const e=new as;return e.applyDelta(this.toDelta()),e}_callObserver(e,n){super._callObserver(e,n);const s=new Iw(this,e,n);wi(this,e,s),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??We();let e="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===kt&&(e+=n.content.str),n=n.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:n=!0}={}){this.doc!==null?de(this.doc,s=>{const r=new Do(null,this._start,0,new Map);for(let i=0;i<e.length;i++){const a=e[i];if(a.insert!==void 0){const c=!n&&typeof a.insert=="string"&&i===e.length-1&&r.right===null&&a.insert.slice(-1)===`
|
|
11
|
-
`?a.insert.slice(0,-1):a.insert;(typeof c!="string"||c.length>0)&&Xi(s,this,r,c,a.attributes||{})}else a.retain!==void 0?Gc(s,this,r,a.retain,a.attributes||{}):a.delete!==void 0&&Jc(s,r,a.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,s){this.doc??We();const r=[],i=new Map,a=this.doc;let c="",l=this._start;function d(){if(c.length>0){const u={};let m=!1;i.forEach((g,x)=>{m=!0,u[x]=g});const p={insert:c};m&&(p.attributes=u),r.push(p),c=""}}const f=()=>{for(;l!==null;){if($n(l,e)||n!==void 0&&$n(l,n))switch(l.content.constructor){case kt:{const u=i.get("ychange");e!==void 0&&!$n(l,e)?(u===void 0||u.user!==l.id.client||u.type!=="removed")&&(d(),i.set("ychange",s?s("removed",l.id):{type:"removed"})):n!==void 0&&!$n(l,n)?(u===void 0||u.user!==l.id.client||u.type!=="added")&&(d(),i.set("ychange",s?s("added",l.id):{type:"added"})):u!==void 0&&(d(),i.delete("ychange")),c+=l.content.str;break}case Tt:case jn:{d();const u={insert:l.content.getContent()[0]};if(i.size>0){const m={};u.attributes=m,i.forEach((p,g)=>{m[g]=p})}r.push(u);break}case Oe:$n(l,e)&&(d(),ps(i,l.content));break}l=l.right}d()};return e||n?de(a,u=>{e&&ko(u,e),n&&ko(u,n),f()},"cleanup"):f(),r}insert(e,n,s){if(n.length<=0)return;const r=this.doc;r!==null?de(r,i=>{const a=Or(i,this,e,!s);s||(s={},a.currentAttributes.forEach((c,l)=>{s[l]=c})),Xi(i,this,a,n,s)}):this._pending.push(()=>this.insert(e,n,s))}insertEmbed(e,n,s){const r=this.doc;r!==null?de(r,i=>{const a=Or(i,this,e,!s);Xi(i,this,a,n,s||{})}):this._pending.push(()=>this.insertEmbed(e,n,s||{}))}delete(e,n){if(n===0)return;const s=this.doc;s!==null?de(s,r=>{Jc(r,Or(r,this,e,!0),n)}):this._pending.push(()=>this.delete(e,n))}format(e,n,s){if(n===0)return;const r=this.doc;r!==null?de(r,i=>{const a=Or(i,this,e,!1);a.right!==null&&Gc(i,this,a,n,s)}):this._pending.push(()=>this.format(e,n,s))}removeAttribute(e){this.doc!==null?de(this.doc,n=>{Qr(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?de(this.doc,s=>{xa(s,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return ba(this,e)}getAttributes(){return vu(this)}_write(e){e.writeTypeRef(sx)}}const Mw=t=>new as;class Zi{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??We()}[Symbol.iterator](){return this}next(){let e=this._currentNode,n=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(n)))do if(n=e.content.type,!e.deleted&&(n.constructor===cs||n.constructor===wn)&&n._start!==null)e=n._start;else for(;e!==null;){const s=e.next;if(s!==null){e=s;break}else e.parent===this._root?e=null:e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class wn extends Ie{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new wn}clone(){const e=new wn;return e.insert(0,this.toArray().map(n=>n instanceof Ie?n.clone():n)),e}get length(){return this.doc??We(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new Zi(this,e)}querySelector(e){e=e.toUpperCase();const s=new Zi(this,r=>r.nodeName&&r.nodeName.toUpperCase()===e).next();return s.done?null:s.value}querySelectorAll(e){return e=e.toUpperCase(),Ht(new Zi(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){wi(this,e,new zw(this,n,e))}toString(){return gu(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,n={},s){const r=e.createDocumentFragment();return s!==void 0&&s._createAssociation(r,this),qs(this,i=>{r.insertBefore(i.toDOM(e,n,s),null)}),r}insert(e,n){this.doc!==null?de(this.doc,s=>{xu(s,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)de(this.doc,s=>{const r=e&&e instanceof Ie?e._item:e;Zr(s,this,r,n)});else{const s=this._prelimContent,r=e===null?0:s.findIndex(i=>i===e)+1;if(r===0&&e!==null)throw gt("Reference item not found");s.splice(r,0,...n)}}delete(e,n=1){this.doc!==null?de(this.doc,s=>{bu(s,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return mu(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return yu(this,e)}slice(e=0,n=this.length){return pu(this,e,n)}forEach(e){qs(this,e)}_write(e){e.writeTypeRef(ix)}}const $w=t=>new wn;class cs extends wn{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,n){super._integrate(e,n),this._prelimAttrs.forEach((s,r)=>{this.setAttribute(r,s)}),this._prelimAttrs=null}_copy(){return new cs(this.nodeName)}clone(){const e=new cs(this.nodeName),n=this.getAttributes();return Ng(n,(s,r)=>{e.setAttribute(r,s)}),e.insert(0,this.toArray().map(s=>s instanceof Ie?s.clone():s)),e}toString(){const e=this.getAttributes(),n=[],s=[];for(const c in e)s.push(c);s.sort();const r=s.length;for(let c=0;c<r;c++){const l=s[c];n.push(l+'="'+e[l]+'"')}const i=this.nodeName.toLocaleLowerCase(),a=n.length>0?" "+n.join(" "):"";return`<${i}${a}>${super.toString()}</${i}>`}removeAttribute(e){this.doc!==null?de(this.doc,n=>{Qr(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?de(this.doc,s=>{xa(s,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return ba(this,e)}hasAttribute(e){return Su(this,e)}getAttributes(e){return e?Tw(this,e):vu(this)}toDOM(e=document,n={},s){const r=e.createElement(this.nodeName),i=this.getAttributes();for(const a in i){const c=i[a];typeof c=="string"&&r.setAttribute(a,c)}return qs(this,a=>{r.appendChild(a.toDOM(e,n,s))}),s!==void 0&&s._createAssociation(r,this),r}_write(e){e.writeTypeRef(rx),e.writeKey(this.nodeName)}}const Uw=t=>new cs(t.readKey());class zw extends gi{constructor(e,n,s){super(e,s),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(r=>{r===null?this.childListChanged=!0:this.attributesChanged.add(r)})}}class ei extends os{constructor(e){super(),this.hookName=e}_copy(){return new ei(this.hookName)}clone(){const e=new ei(this.hookName);return this.forEach((n,s)=>{e.set(s,n)}),e}toDOM(e=document,n={},s){const r=n[this.hookName];let i;return r!==void 0?i=r.createDom(this):i=document.createElement(this.hookName),i.setAttribute("data-yjs-hook",this.hookName),s!==void 0&&s._createAssociation(i,this),i}_write(e){e.writeTypeRef(ox),e.writeKey(this.hookName)}}const Vw=t=>new ei(t.readKey());class ti extends as{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new ti}clone(){const e=new ti;return e.applyDelta(this.toDelta()),e}toDOM(e=document,n,s){const r=e.createTextNode(this.toString());return s!==void 0&&s._createAssociation(r,this),r}toString(){return this.toDelta().map(e=>{const n=[];for(const r in e.attributes){const i=[];for(const a in e.attributes[r])i.push({key:a,value:e.attributes[r][a]});i.sort((a,c)=>a.key<c.key?-1:1),n.push({nodeName:r,attrs:i})}n.sort((r,i)=>r.nodeName<i.nodeName?-1:1);let s="";for(let r=0;r<n.length;r++){const i=n[r];s+=`<${i.nodeName}`;for(let a=0;a<i.attrs.length;a++){const c=i.attrs[a];s+=` ${c.key}="${c.value}"`}s+=">"}s+=e.insert;for(let r=n.length-1;r>=0;r--)s+=`</${n[r].nodeName}>`;return s}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(ax)}}const Bw=t=>new ti;class va{constructor(e,n){this.id=e,this.length=n}get deleted(){throw ft()}mergeWith(e){return!1}write(e,n,s){throw ft()}integrate(e,n){throw ft()}}const Hw=0;class at extends va{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){n>0&&(this.id.clock+=n,this.length-=n),cu(e.doc.store,this)}write(e,n){e.writeInfo(Hw),e.writeLen(this.length-n)}getMissing(e,n){return null}}class Qs{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Qs(this.content)}splice(e){throw ft()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}}const qw=t=>new Qs(t.readBuf());class Ws{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Ws(this.len)}splice(e){const n=new Ws(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){Bs(e.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(e){}gc(e){}write(e,n){e.writeLen(this.len-n)}getRef(){return 1}}const Ww=t=>new Ws(t.readLen()),Du=(t,e)=>new Sn({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class er{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;const n={};this.opts=n,e.gc||(n.gc=!1),e.autoLoad&&(n.autoLoad=!0),e.meta!==null&&(n.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new er(Du(this.doc.guid,this.opts))}splice(e){throw ft()}mergeWith(e){return!1}integrate(e,n){this.doc._item=n,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,n){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const Kw=t=>new er(Du(t.readString(),t.readAny()));class jn{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new jn(this.embed)}splice(e){throw ft()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}}const Gw=t=>new jn(t.readJSON());class Oe{constructor(e,n){this.key=e,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new Oe(this.key,this.value)}splice(e){throw ft()}mergeWith(e){return!1}integrate(e,n){const s=n.parent;s._searchMarker=null,s._hasFormatting=!0}delete(e){}gc(e){}write(e,n){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const Jw=t=>new Oe(t.readKey(),t.readJSON());class ni{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new ni(this.arr)}splice(e){const n=new ni(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const s=this.arr.length;e.writeLen(s-n);for(let r=n;r<s;r++){const i=this.arr[r];e.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}}const Yw=t=>{const e=t.readLen(),n=[];for(let s=0;s<e;s++){const r=t.readString();r==="undefined"?n.push(void 0):n.push(JSON.parse(r))}return new ni(n)},Xw=Kr("node_env")==="development";class xn{constructor(e){this.arr=e,Xw&&bd(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new xn(this.arr)}splice(e){const n=new xn(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const s=this.arr.length;e.writeLen(s-n);for(let r=n;r<s;r++){const i=this.arr[r];e.writeAny(i)}}getRef(){return 8}}const Zw=t=>{const e=t.readLen(),n=[];for(let s=0;s<e;s++)n.push(t.readAny());return new xn(n)};class kt{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new kt(this.str)}splice(e){const n=new kt(this.str.slice(e));this.str=this.str.slice(0,e);const s=this.str.charCodeAt(e-1);return s>=55296&&s<=56319&&(this.str=this.str.slice(0,e-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}}const Qw=t=>new kt(t.readString()),ex=[_w,Rw,Mw,Uw,$w,Vw,Bw],tx=0,nx=1,sx=2,rx=3,ix=4,ox=5,ax=6;class Tt{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Tt(this.type._copy())}splice(e){throw ft()}mergeWith(e){return!1}integrate(e,n){this.type._integrate(e.doc,n)}delete(e){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(e.beforeState.get(n.id.client)||0)&&e._mergeStructs.push(n):n.delete(e),n=n.right;this.type._map.forEach(s=>{s.deleted?s.id.clock<(e.beforeState.get(s.id.client)||0)&&e._mergeStructs.push(s):s.delete(e)}),e.changed.delete(this.type)}gc(e){let n=this.type._start;for(;n!==null;)n.gc(e,!0),n=n.right;this.type._start=null,this.type._map.forEach(s=>{for(;s!==null;)s.gc(e,!0),s=s.left}),this.type._map=new Map}write(e,n){this.type._write(e)}getRef(){return 7}}const cx=t=>new Tt(ex[t.readTypeRef()](t)),No=(t,e)=>{let n=e,s=0,r;do s>0&&(n=Z(n.client,n.clock+s)),r=Gn(t,n),s=n.clock-r.id.clock,n=r.redone;while(n!==null&&r instanceof fe);return{item:r,diff:s}},Sa=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},si=(t,e,n)=>{const{client:s,clock:r}=e.id,i=new fe(Z(s,r+n),e,Z(s,r+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&i.markDeleted(),e.keep&&(i.keep=!0),e.redone!==null&&(i.redone=Z(e.redone.client,e.redone.clock+n)),e.right=i,i.right!==null&&(i.right.left=i),t._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),e.length=n,i},Yc=(t,e)=>Go(t,n=>Xs(n.deletions,e)),Nu=(t,e,n,s,r,i)=>{const a=t.doc,c=a.store,l=a.clientID,d=e.redone;if(d!==null)return et(t,d);let f=e.parent._item,u=null,m;if(f!==null&&f.deleted===!0){if(f.redone===null&&(!n.has(f)||Nu(t,f,n,s,r,i)===null))return null;for(;f.redone!==null;)f=et(t,f.redone)}const p=f===null?e.parent:f.content.type;if(e.parentSub===null){for(u=e.left,m=e;u!==null;){let j=u;for(;j!==null&&j.parent._item!==f;)j=j.redone===null?null:et(t,j.redone);if(j!==null&&j.parent._item===f){u=j;break}u=u.left}for(;m!==null;){let j=m;for(;j!==null&&j.parent._item!==f;)j=j.redone===null?null:et(t,j.redone);if(j!==null&&j.parent._item===f){m=j;break}m=m.right}}else{if(m=null,e.right&&!r){for(u=e;u!==null&&u.right!==null&&(u.right.redone||Xs(s,u.right.id)||Yc(i.undoStack,u.right.id)||Yc(i.redoStack,u.right.id));)for(u=u.right;u.redone;)u=et(t,u.redone);if(u&&u.right!==null)return null}else u=p._map.get(e.parentSub)||null;u!==null&&u.parent._item!==f&&(u=p._map.get(e.parentSub)||null)}const g=Ce(c,l),x=Z(l,g),b=new fe(x,u,u&&u.lastId,m,m&&m.id,p,e.parentSub,e.content.copy());return e.redone=x,Sa(b,!0),b.integrate(t,0),b};class fe extends va{constructor(e,n,s,r,i,a,c,l){super(e,l.getLength()),this.origin=s,this.left=n,this.right=r,this.rightOrigin=i,this.parent=a,this.parentSub=c,this.redone=null,this.content=l,this.info=this.content.isCountable()?Ec:0}set marker(e){(this.info&qi)>0!==e&&(this.info^=qi)}get marker(){return(this.info&qi)>0}get keep(){return(this.info&kc)>0}set keep(e){this.keep!==e&&(this.info^=kc)}get countable(){return(this.info&Ec)>0}get deleted(){return(this.info&Hi)>0}set deleted(e){this.deleted!==e&&(this.info^=Hi)}markDeleted(){this.info|=Hi}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=Ce(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Ce(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Kn&&this.id.client!==this.parent.client&&this.parent.clock>=Ce(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=zc(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=et(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===at||this.right&&this.right.constructor===at)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===fe?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===fe&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Kn){const s=Gn(n,this.parent);s.constructor===at?this.parent=null:this.parent=s.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=zc(e,e.doc.store,Z(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let s=this.left,r;if(s!==null)r=s.right;else if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start;const i=new Set,a=new Set;for(;r!==null&&r!==this.right;){if(a.add(r),i.add(r),Bn(this.origin,r.origin)){if(r.id.client<this.id.client)s=r,i.clear();else if(Bn(this.rightOrigin,r.rightOrigin))break}else if(r.origin!==null&&a.has(Gn(e.doc.store,r.origin)))i.has(Gn(e.doc.store,r.origin))||(s=r,i.clear());else break;r=r.right}this.left=s}if(this.left!==null){const s=this.left.right;this.right=s,this.left.right=this}else{let s;if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start,this.parent._start=this;this.right=s}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),cu(e.doc.store,this),this.content.integrate(e,this),Bc(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new at(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:Z(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Bn(e.origin,this.lastId)&&this.right===e&&Bn(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){const n=this.parent._searchMarker;return n&&n.forEach(s=>{s.p===e&&(s.p=this,!this.deleted&&this.countable&&(s.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),Bs(e.deleteSet,this.id.client,this.id.clock,this.length),Bc(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw it();this.content.gc(e),n?hw(e,this,new at(this.id,this.length)):this.content=new Ws(this.length)}write(e,n){const s=n>0?Z(this.id.client,this.id.clock+n-1):this.origin,r=this.rightOrigin,i=this.parentSub,a=this.content.getRef()&oi|(s===null?0:rt)|(r===null?0:zt)|(i===null?0:Is);if(e.writeInfo(a),s!==null&&e.writeLeftID(s),r!==null&&e.writeRightID(r),s===null&&r===null){const c=this.parent;if(c._item!==void 0){const l=c._item;if(l===null){const d=iu(c);e.writeParentInfo(!0),e.writeString(d)}else e.writeParentInfo(!1),e.writeLeftID(l.id)}else c.constructor===String?(e.writeParentInfo(!0),e.writeString(c)):c.constructor===Kn?(e.writeParentInfo(!1),e.writeLeftID(c)):it();i!==null&&e.writeString(i)}this.content.write(e,n)}}const Tu=(t,e)=>lx[e&oi](t),lx=[()=>{it()},Ww,Yw,qw,Qw,Gw,Jw,cx,Zw,Kw,()=>{it()}],dx=10;class ct extends va{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){it()}write(e,n){e.writeInfo(dx),$(e.restEncoder,this.length-n)}getMissing(e,n){return null}}const Ou=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},_u="__ $YJS$ __";Ou[_u]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Ou[_u]=!0;const Pu=new Map;class ux{constructor(e){this.room=e,this.onmessage=null,this._onChange=n=>n.key===e&&this.onmessage!==null&&this.onmessage({data:Wg(n.newValue||"")}),jg(this._onChange)}postMessage(e){wd.setItem(this.room,qg(Ug(e)))}close(){Cg(this._onChange)}}const hx=typeof BroadcastChannel>"u"?ux:BroadcastChannel,ja=t=>Dt(Pu,t,()=>{const e=on(),n=new hx(t);return n.onmessage=s=>e.forEach(r=>r(s.data,"broadcastchannel")),{bc:n,subs:e}}),fx=(t,e)=>(ja(t).subs.add(e),e),px=(t,e)=>{const n=ja(t),s=n.subs.delete(e);return s&&n.subs.size===0&&(n.bc.close(),Pu.delete(t)),s},Un=(t,e,n=null)=>{const s=ja(t);s.bc.postMessage(e),s.subs.forEach(r=>r(e,n))},Ru=0,Ca=1,Lu=2,ri=(t,e)=>{$(t,Ru);const n=ow(e);Se(t,n)},Au=(t,e,n)=>{$(t,Ca),Se(t,pa(e,n))},mx=(t,e,n)=>Au(e,n,qe(t)),Fu=(t,e,n,s)=>{try{tu(e,qe(t),n)}catch(r){s?.(r),console.error("Caught error while handling a Yjs update",r)}},gx=(t,e)=>{$(t,Lu),Se(t,e)},yx=Fu,wx=(t,e,n,s,r)=>{const i=J(t);switch(i){case Ru:mx(t,e,n);break;case Ca:Fu(t,n,s,r);break;case Lu:yx(t,n,s,r);break;default:throw new Error("Unknown message type")}return i},xx=0,bx=(t,e,n)=>{J(t)===xx&&n(e,pt(t))},Qi=3e4;class vx extends ud{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const n=an();this.getLocalState()!==null&&Qi/2<=n-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const s=[];this.meta.forEach((r,i)=>{i!==this.clientID&&Qi<=n-r.lastUpdated&&this.states.has(i)&&s.push(i)}),s.length>0&&ka(this,s,"timeout")},mt(Qi/10)),e.on("destroy",()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){const n=this.clientID,s=this.meta.get(n),r=s===void 0?0:s.clock+1,i=this.states.get(n);e===null?this.states.delete(n):this.states.set(n,e),this.meta.set(n,{clock:r,lastUpdated:an()});const a=[],c=[],l=[],d=[];e===null?d.push(n):i==null?e!=null&&a.push(n):(c.push(n),qn(i,e)||l.push(n)),(a.length>0||l.length>0||d.length>0)&&this.emit("change",[{added:a,updated:l,removed:d},"local"]),this.emit("update",[{added:a,updated:c,removed:d},"local"])}setLocalStateField(e,n){const s=this.getLocalState();s!==null&&this.setLocalState({...s,[e]:n})}getStates(){return this.states}}const ka=(t,e,n)=>{const s=[];for(let r=0;r<e.length;r++){const i=e[r];if(t.states.has(i)){if(t.states.delete(i),i===t.clientID){const a=t.meta.get(i);t.meta.set(i,{clock:a.clock+1,lastUpdated:an()})}s.push(i)}}s.length>0&&(t.emit("change",[{added:[],updated:[],removed:s},n]),t.emit("update",[{added:[],updated:[],removed:s},n]))},Yn=(t,e,n=t.states)=>{const s=e.length,r=Ee();$(r,s);for(let i=0;i<s;i++){const a=e[i],c=n.get(a)||null,l=t.meta.get(a).clock;$(r,a),$(r,l),Vt(r,JSON.stringify(c))}return he(r)},Sx=(t,e,n)=>{const s=ln(e),r=an(),i=[],a=[],c=[],l=[],d=J(s);for(let f=0;f<d;f++){const u=J(s);let m=J(s);const p=JSON.parse(pt(s)),g=t.meta.get(u),x=t.states.get(u),b=g===void 0?0:g.clock;(b<m||b===m&&p===null&&t.states.has(u))&&(p===null?u===t.clientID&&t.getLocalState()!=null?m++:t.states.delete(u):t.states.set(u,p),t.meta.set(u,{clock:m,lastUpdated:r}),g===void 0&&p!==null?i.push(u):g!==void 0&&p===null?l.push(u):p!==null&&(qn(p,x)||c.push(u),a.push(u)))}(i.length>0||c.length>0||l.length>0)&&t.emit("change",[{added:i,updated:c,removed:l},n]),(i.length>0||a.length>0||l.length>0)&&t.emit("update",[{added:i,updated:a,removed:l},n])},jx=t=>Tg(t,(e,n)=>`${encodeURIComponent(n)}=${encodeURIComponent(e)}`).join("&"),mn=0,Iu=3,Xn=1,Cx=2,tr=[];tr[mn]=(t,e,n,s,r)=>{$(t,mn);const i=wx(e,t,n.doc,n);s&&i===Ca&&!n.synced&&(n.synced=!0)};tr[Iu]=(t,e,n,s,r)=>{$(t,Xn),Se(t,Yn(n.awareness,Array.from(n.awareness.getStates().keys())))};tr[Xn]=(t,e,n,s,r)=>{Sx(n.awareness,qe(e),n)};tr[Cx]=(t,e,n,s,r)=>{bx(e,n.doc,(i,a)=>kx(n,a))};const Xc=3e4,kx=(t,e)=>console.warn(`Permission denied to access ${t.url}.
|
|
12
|
-
${e}`),Mu=(t,e,n)=>{const s=ln(e),r=Ee(),i=J(s),a=t.messageHandlers[i];return a?a(r,s,t,n,i):console.error("Unable to compute message"),r},To=(t,e,n)=>{e===t.ws&&(t.emit("connection-close",[n,t]),t.ws=null,e.close(),t.wsconnecting=!1,t.wsconnected?(t.wsconnected=!1,t.synced=!1,ka(t.awareness,Array.from(t.awareness.getStates().keys()).filter(s=>s!==t.doc.clientID),t),t.emit("status",[{status:"disconnected"}])):t.wsUnsuccessfulReconnects++,setTimeout($u,Yo(Hm(2,t.wsUnsuccessfulReconnects)*100,t.maxBackoffTime),t))},$u=t=>{if(t.shouldConnect&&t.ws===null){const e=new t._WS(t.url,t.protocols);e.binaryType="arraybuffer",t.ws=e,t.wsconnecting=!0,t.wsconnected=!1,t.synced=!1,e.onmessage=n=>{t.wsLastMessageReceived=an();const s=Mu(t,new Uint8Array(n.data),!0);Xo(s)>1&&e.send(he(s))},e.onerror=n=>{t.emit("connection-error",[n,t])},e.onclose=n=>{To(t,e,n)},e.onopen=()=>{t.wsLastMessageReceived=an(),t.wsconnecting=!1,t.wsconnected=!0,t.wsUnsuccessfulReconnects=0,t.emit("status",[{status:"connected"}]);const n=Ee();if($(n,mn),ri(n,t.doc),e.send(he(n)),t.awareness.getLocalState()!==null){const s=Ee();$(s,Xn),Se(s,Yn(t.awareness,[t.doc.clientID])),e.send(he(s))}},t.emit("status",[{status:"connecting"}])}},eo=(t,e)=>{const n=t.ws;t.wsconnected&&n&&n.readyState===n.OPEN&&n.send(e),t.bcconnected&&Un(t.bcChannel,e,t)};class Ex extends Jo{constructor(e,n,s,{connect:r=!0,awareness:i=new vx(s),params:a={},protocols:c=[],WebSocketPolyfill:l=WebSocket,resyncInterval:d=-1,maxBackoffTime:f=2500,disableBc:u=!1}={}){for(super();e[e.length-1]==="/";)e=e.slice(0,e.length-1);this.serverUrl=e,this.bcChannel=e+"/"+n,this.maxBackoffTime=f,this.params=a,this.protocols=c,this.roomname=n,this.doc=s,this._WS=l,this.awareness=i,this.wsconnected=!1,this.wsconnecting=!1,this.bcconnected=!1,this.disableBc=u,this.wsUnsuccessfulReconnects=0,this.messageHandlers=tr.slice(),this._synced=!1,this.ws=null,this.wsLastMessageReceived=0,this.shouldConnect=r,this._resyncInterval=0,d>0&&(this._resyncInterval=setInterval(()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){const m=Ee();$(m,mn),ri(m,s),this.ws.send(he(m))}},d)),this._bcSubscriber=(m,p)=>{if(p!==this){const g=Mu(this,new Uint8Array(m),!1);Xo(g)>1&&Un(this.bcChannel,he(g),this)}},this._updateHandler=(m,p)=>{if(p!==this){const g=Ee();$(g,mn),gx(g,m),eo(this,he(g))}},this.doc.on("update",this._updateHandler),this._awarenessUpdateHandler=({added:m,updated:p,removed:g},x)=>{const b=m.concat(p).concat(g),j=Ee();$(j,Xn),Se(j,Yn(i,b)),eo(this,he(j))},this._exitHandler=()=>{ka(this.awareness,[s.clientID],"app closed")},cn&&typeof process<"u"&&process.on("exit",this._exitHandler),i.on("update",this._awarenessUpdateHandler),this._checkInterval=setInterval(()=>{this.wsconnected&&Xc<an()-this.wsLastMessageReceived&&To(this,this.ws,null)},Xc/10),r&&this.connect()}get url(){const e=jx(this.params);return this.serverUrl+"/"+this.roomname+(e.length===0?"":"?"+e)}get synced(){return this._synced}set synced(e){this._synced!==e&&(this._synced=e,this.emit("synced",[e]),this.emit("sync",[e]))}destroy(){this._resyncInterval!==0&&clearInterval(this._resyncInterval),clearInterval(this._checkInterval),this.disconnect(),cn&&typeof process<"u"&&process.off("exit",this._exitHandler),this.awareness.off("update",this._awarenessUpdateHandler),this.doc.off("update",this._updateHandler),super.destroy()}connectBc(){if(this.disableBc)return;this.bcconnected||(fx(this.bcChannel,this._bcSubscriber),this.bcconnected=!0);const e=Ee();$(e,mn),ri(e,this.doc),Un(this.bcChannel,he(e),this);const n=Ee();$(n,mn),Au(n,this.doc),Un(this.bcChannel,he(n),this);const s=Ee();$(s,Iu),Un(this.bcChannel,he(s),this);const r=Ee();$(r,Xn),Se(r,Yn(this.awareness,[this.doc.clientID])),Un(this.bcChannel,he(r),this)}disconnectBc(){const e=Ee();$(e,Xn),Se(e,Yn(this.awareness,[this.doc.clientID],new Map)),eo(this,he(e)),this.bcconnected&&(px(this.bcChannel,this._bcSubscriber),this.bcconnected=!1)}disconnect(){this.shouldConnect=!1,this.disconnectBc(),this.ws!==null&&To(this,this.ws,null)}connect(){this.shouldConnect=!0,!this.wsconnected&&this.ws===null&&($u(this),this.connectBc())}}const Cn=t=>ns((e,n)=>{t.onerror=s=>n(new Error(s.target.error)),t.onsuccess=s=>e(s.target.result)}),Dx=(t,e)=>ns((n,s)=>{const r=indexedDB.open(t);r.onupgradeneeded=i=>e(i.target.result),r.onerror=i=>s(gt(i.target.error)),r.onsuccess=i=>{const a=i.target.result;a.onversionchange=()=>{a.close()},n(a)}}),Nx=t=>Cn(indexedDB.deleteDatabase(t)),Tx=(t,e)=>e.forEach(n=>t.createObjectStore.apply(t,n)),Ds=(t,e,n="readwrite")=>{const s=t.transaction(e,n);return e.map(r=>Ix(s,r))},Uu=(t,e)=>Cn(t.count(e)),Ox=(t,e)=>Cn(t.get(e)),zu=(t,e)=>Cn(t.delete(e)),_x=(t,e,n)=>Cn(t.put(e,n)),Oo=(t,e)=>Cn(t.add(e)),Px=(t,e,n)=>Cn(t.getAll(e,n)),Rx=(t,e,n)=>{let s=null;return Fx(t,e,r=>(s=r,!1),n).then(()=>s)},Lx=(t,e=null)=>Rx(t,e,"prev"),Ax=(t,e)=>ns((n,s)=>{t.onerror=s,t.onsuccess=async r=>{const i=r.target.result;if(i===null||await e(i)===!1)return n();i.continue()}}),Fx=(t,e,n,s="next")=>Ax(t.openKeyCursor(e,s),r=>n(r.key)),Ix=(t,e)=>t.objectStore(e),Mx=(t,e)=>IDBKeyRange.upperBound(t,e),$x=(t,e)=>IDBKeyRange.lowerBound(t,e),to="custom",Vu="updates",Bu=500,Hu=(t,e=()=>{},n=()=>{})=>{const[s]=Ds(t.db,[Vu]);return Px(s,$x(t._dbref,!1)).then(r=>{t._destroyed||(e(s),de(t.doc,()=>{r.forEach(i=>tu(t.doc,i))},t,!1),n(s))}).then(()=>Lx(s).then(r=>{t._dbref=r+1})).then(()=>Uu(s).then(r=>{t._dbsize=r})).then(()=>s)},Ux=(t,e=!0)=>Hu(t).then(n=>{(e||t._dbsize>=Bu)&&Oo(n,pa(t.doc)).then(()=>zu(n,Mx(t._dbref,!0))).then(()=>Uu(n).then(s=>{t._dbsize=s}))});class zx extends ud{constructor(e,n){super(),this.doc=n,this.name=e,this._dbref=0,this._dbsize=0,this._destroyed=!1,this.db=null,this.synced=!1,this._db=Dx(e,s=>Tx(s,[["updates",{autoIncrement:!0}],["custom"]])),this.whenSynced=ns(s=>this.on("synced",()=>s(this))),this._db.then(s=>{this.db=s,Hu(this,a=>Oo(a,pa(n)),()=>{if(this._destroyed)return this;this.synced=!0,this.emit("synced",[this])})}),this._storeTimeout=1e3,this._storeTimeoutId=null,this._storeUpdate=(s,r)=>{if(this.db&&r!==this){const[i]=Ds(this.db,[Vu]);Oo(i,s),++this._dbsize>=Bu&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{Ux(this,!1),this._storeTimeoutId=null},this._storeTimeout))}},n.on("update",this._storeUpdate),this.destroy=this.destroy.bind(this),n.on("destroy",this.destroy)}destroy(){return this._storeTimeoutId&&clearTimeout(this._storeTimeoutId),this.doc.off("update",this._storeUpdate),this.doc.off("destroy",this.destroy),this._destroyed=!0,this._db.then(e=>{e.close()})}clearData(){return this.destroy().then(()=>{Nx(this.name)})}get(e){return this._db.then(n=>{const[s]=Ds(n,[to],"readonly");return Ox(s,e)})}set(e,n){return this._db.then(s=>{const[r]=Ds(s,[to]);return _x(r,n,e)})}del(e){return this._db.then(n=>{const[s]=Ds(n,[to]);return zu(s,e)})}}const Zc=[["#1677c8","#1677c833"],["#d65745","#d6574533"],["#16866a","#16866a33"],["#9a58b5","#9a58b533"],["#d27b18","#d27b1833"],["#3f7d20","#3f7d2033"],["#be3e7b","#be3e7b33"],["#4964c6","#4964c633"],["#8a6a14","#8a6a1433"],["#087f8c","#087f8c33"]],Qc=4,el=5;function Vx(t){if(!t||typeof t!="object")return null;const e=t,n=e.requestedBy;return typeof e.mainFile!="string"||typeof e.runId!="string"||!["queued","running","succeeded","failed"].includes(e.status??"")||typeof e.updatedAt!="string"||!n||typeof n.id!="string"||typeof n.username!="string"||typeof n.name!="string"?null:e}function tl(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[n,s]of Object.entries(t)){const r=Vx(s);r&&r.mainFile===n&&(e[n]=r)}return e}class Bx{constructor(e,n){this.projectId=e,this.user=n;const s=window.location.protocol==="https:"?"wss:":"ws:";this.persistence=new zx(`texlite:${n.id}:${e}`,this.doc),this.persistence.on("synced",()=>{this.localDraftReady=!0;for(const r of this.draftListeners)r()}),this.provider=new Ex(`${s}//${window.location.host}/api/collaboration`,e,this.doc,{disableBc:!0,maxBackoffTime:2500}),this.awareness=this.provider.awareness,this.provider.messageHandlers[Qc]=(r,i)=>{const a=pt(i),c=this.flushRequests.get(a);if(!c)return;const l=J(i),d=pt(i);window.clearTimeout(c.timer),this.flushRequests.delete(a),c.resolve({revision:l,persistedAt:d})},this.provider.messageHandlers[el]=(r,i)=>{const a=pt(i),c=this.epochStorageKey(),l=Hx(c);if(this.epoch&&this.epoch!==a||l&&l!==a){this.provider.disconnect(),this.rejectFlushes(new Error("Collaboration state changed")),this.persistence.clearData().then(()=>{nl(c,a),window.location.reload()});return}this.epoch=a,nl(c,a);const d=this.provider.ws;if(!d||d.readyState!==WebSocket.OPEN)return;const f=Ee();$(f,el),Vt(f,a),d.send(he(f));const u=Ee();$(u,0),ri(u,this.doc),d.send(he(u));const m=Ee();$(m,1),Se(m,Yn(this.awareness,[this.doc.clientID])),d.send(he(m))},this.provider.on("status",({status:r})=>{r==="disconnected"&&this.rejectFlushes(new Error("Collaboration connection closed"))}),this.updateLocalAwareness()}projectId;user;doc=new Sn;provider;awareness;persistence;permission="read";activeFile="";epoch=null;destroyed=!1;localDraftReady=!1;draftListeners=new Set;flushRequests=new Map;getText(e){return this.doc.getText(`source:${e}`)}applyTextEdits(e,n){if(this.permission==="read")throw new Error("Read-only collaborators cannot edit source files");const s=this.getText(e);let r=0;for(const i of n){if(!Number.isInteger(i.from)||!Number.isInteger(i.to)||i.from<r||i.to<i.from||i.to>s.length)throw new RangeError("Invalid collaborative text edits");r=i.to}this.doc.transact(()=>{for(let i=n.length-1;i>=0;i-=1){const a=n[i];a.to>a.from&&s.delete(a.from,a.to-a.from),a.replacement&&s.insert(a.from,a.replacement)}})}get meta(){return this.doc.getMap("texlite:meta")}get synced(){return this.provider.synced}get connected(){return this.provider.wsconnected}get draftReady(){return this.localDraftReady}onDraftReady(e){return this.draftListeners.add(e),this.localDraftReady&&e(),()=>this.draftListeners.delete(e)}setPermission(e){this.permission=e,this.updateLocalAwareness()}setActiveFile(e){this.activeFile!==e&&(this.activeFile=e,this.awareness.setLocalStateField("cursor",null),this.updateLocalAwareness())}sessions(){const e=[];return this.awareness.getStates().forEach((n,s)=>{const r=n?.user;!r||typeof r.id!="string"||typeof r.name!="string"||e.push({clientId:s,userId:r.id,username:typeof r.username=="string"?r.username:r.name,name:r.name,color:typeof r.color=="string"?r.color:"#1677c8",colorLight:typeof r.colorLight=="string"?r.colorLight:"#1677c833",permission:r.permission==="owner"||r.permission==="edit"?r.permission:"read",filePath:typeof n.filePath=="string"?n.filePath:"",editing:!!n.cursor,local:s===this.doc.clientID})}),e.sort((n,s)=>Number(s.local)-Number(n.local)||n.name.localeCompare(s.name))}flush(){const e=this.provider.ws;if(!this.provider.synced||!e||e.readyState!==WebSocket.OPEN)return Promise.reject(new Error("Collaboration connection is unavailable"));const n=crypto.randomUUID(),s=Ee();return $(s,Qc),Vt(s,n),new Promise((r,i)=>{const a=window.setTimeout(()=>{this.flushRequests.delete(n),i(new Error("Collaboration save timed out"))},5e3);this.flushRequests.set(n,{resolve:r,reject:i,timer:a}),e.send(he(s))})}reconnect(){this.destroyed||(this.rejectFlushes(new Error("Collaboration connection reset")),this.provider.disconnect(),this.provider.connect(),this.updateLocalAwareness())}destroy(){this.destroyed=!0,this.rejectFlushes(new Error("Collaboration connection closed")),this.provider.destroy(),this.persistence.destroy(),this.draftListeners.clear(),this.doc.destroy()}rejectFlushes(e){for(const n of this.flushRequests.values())window.clearTimeout(n.timer),n.reject(e);this.flushRequests.clear()}updateLocalAwareness(){const[e,n]=Zc[Math.abs(this.doc.clientID)%Zc.length];this.awareness.setLocalStateField("user",{id:this.user.id,username:this.user.username,name:this.user.displayName,color:e,colorLight:n,permission:this.permission,sessionId:String(this.doc.clientID)}),this.awareness.setLocalStateField("filePath",this.activeFile)}epochStorageKey(){return`texlite:collaboration-epoch:${this.user.id}:${this.projectId}`}}function Hx(t){try{return window.localStorage.getItem(t)}catch{return null}}function nl(t,e){try{window.localStorage.setItem(t,e)}catch{}}function qx(t,e){return Array.from(t.trim()||e.trim()||"?")[0]?.toLocaleUpperCase()??"?"}function Wx({sessions:t,status:e}){const{t:n}=_e(),[s,r]=h.useState(!1),i=Math.max(0,t.length-5),a=s&&i>0,c=a?t:t.slice(0,5);return h.useEffect(()=>{t.length<=5&&r(!1)},[t.length]),t.length<=1?null:o.jsxs("div",{className:`collaboration-presence collaboration-${e}`,title:n(`editor.collaboration.${e}`),children:[o.jsx("span",{className:"collaboration-status-dot","aria-label":n(`editor.collaboration.${e}`)}),o.jsxs("div",{className:"collaboration-avatars","aria-label":n("editor.collaboration.activeSessions",{count:t.length}),children:[c.map(l=>{const d=l.editing?n("editor.collaboration.editing"):n("editor.collaboration.viewing"),f=l.permission==="read"?n("common.readOnly"):n("common.readWrite"),u=n("editor.collaboration.sessionTooltip",{name:l.name,username:l.username,file:l.filePath||n("editor.collaboration.joining"),activity:d,permission:f});return o.jsxs("span",{className:`collaboration-avatar${l.editing?" editing":""}${l.local?" local":""}`,style:{"--session-color":l.color},title:u,"aria-label":u,tabIndex:0,children:[qx(l.name,l.username),o.jsxs("span",{className:"collaboration-avatar-tooltip",role:"tooltip",children:[o.jsx("strong",{children:l.name}),o.jsxs("span",{children:["@",l.username]}),o.jsxs("small",{children:[l.filePath||n("editor.collaboration.joining")," · ",d," · ",f]})]})]},l.clientId)}),i>0&&o.jsx("button",{type:"button",className:"collaboration-avatar collaboration-avatar-overflow","aria-expanded":a,"aria-label":a?n("editor.collaboration.showFewerSessions"):n("editor.collaboration.showMoreSessions",{count:i}),title:a?n("editor.collaboration.showFewerSessions"):n("editor.collaboration.showMoreSessions",{count:i}),onClick:()=>r(l=>!l),children:a?"−":`+${i}`})]})]})}function Kx({value:t,onChange:e}){const{t:n}=_e(),[s,r]=h.useState(!1),i=h.useRef(null),a=[{value:"editor-pdf",icon:mc},{value:"editor-only",icon:xm},{value:"pdf-only",icon:bm}];return h.useEffect(()=>{if(!s)return;const c=d=>{i.current?.contains(d.target)||r(!1)},l=d=>{d.key==="Escape"&&r(!1)};return document.addEventListener("pointerdown",c),document.addEventListener("keydown",l),()=>{document.removeEventListener("pointerdown",c),document.removeEventListener("keydown",l)}},[s]),o.jsxs("div",{className:"layout-menu",ref:i,children:[o.jsxs("button",{type:"button",className:`layout-trigger${s?" active":""}`,"aria-haspopup":"menu","aria-expanded":s,title:n("editor.layout.current",{layout:n(`editor.layout.${t}.name`)}),onClick:()=>r(c=>!c),children:[o.jsx(mc,{size:15}),o.jsxs("span",{children:[o.jsx("small",{children:n("editor.layout.label")}),n(`editor.layout.${t}.name`)]}),o.jsx(sd,{size:13})]}),s&&o.jsxs("div",{className:"layout-popover",role:"menu","aria-label":n("editor.layout.label"),children:[o.jsx("div",{className:"layout-popover-title",children:n("editor.layout.choose")}),a.map(c=>{const l=c.icon,d=c.value===t;return o.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":d,className:`layout-option${d?" selected":""}`,onClick:()=>{e(c.value),r(!1)},children:[o.jsx(l,{size:19}),o.jsxs("span",{children:[o.jsx("strong",{children:n(`editor.layout.${c.value}.name`)}),o.jsx("small",{children:n(`editor.layout.${c.value}.description`)})]}),d&&o.jsx(rm,{size:16})]},c.value)})]})]})}function Gx({comment:t,currentUserId:e,onFocus:n,onToggle:s,onReply:r,onEdit:i,onDelete:a,onEditReply:c,onDeleteReply:l}){const{t:d}=_e(),[f,u]=h.useState(!1),[m,p]=h.useState(""),[g,x]=h.useState(!1),[b,j]=h.useState(t.content),[C,T]=h.useState(!1),[N,L]=h.useState(null),[P,E]=h.useState(""),[H,S]=h.useState(null),O=async v=>{v.preventDefault(),m.trim()&&await r(m)&&(p(""),u(!1))},ae=async v=>{v.preventDefault(),b.trim()&&await i(b)&&x(!1)},q=async v=>{v.preventDefault(),!(!N||!P.trim())&&await c(N,P)&&L(null)},R=t.authorUsername,_=v=>new Date(v).toLocaleString(ge.resolvedLanguage);return o.jsxs(o.Fragment,{children:[o.jsxs("article",{className:`comment-thread${t.resolved?" resolved":""}${t.orphaned?" orphaned":""}`,onClick:n,children:[o.jsxs("header",{className:"comment-header",children:[o.jsxs("span",{className:"comment-author",children:[o.jsx("strong",{children:t.authorDisplayName??R??d("editor.deletedUser")}),R&&o.jsxs("small",{children:["@",R]})]}),o.jsxs("span",{className:"comment-times",children:[o.jsx("time",{dateTime:t.createdAt,title:new Date(t.createdAt).toISOString(),children:_(t.createdAt)}),t.editedAt&&o.jsx("small",{children:d("editor.editedAt",{time:_(t.editedAt)})})]})]}),o.jsx("div",{className:"comment-location",children:t.orphaned?d("editor.orphaned"):d("editor.line",{line:t.startLine})}),t.selectedText&&o.jsx("blockquote",{children:t.selectedText}),g?o.jsxs("form",{className:"comment-reply-form comment-edit-form",onSubmit:v=>{ae(v)},onClick:v=>v.stopPropagation(),children:[o.jsx("textarea",{autoFocus:!0,rows:4,value:b,onChange:v=>j(v.target.value)}),o.jsxs("div",{children:[o.jsx("button",{type:"button",onClick:()=>x(!1),children:d("common.cancel")}),o.jsxs("button",{className:"primary",type:"submit",disabled:!b.trim(),children:[o.jsx(Vr,{size:13}),d("editor.saveChanges")]})]})]}):o.jsx("p",{children:t.content}),t.replies.length>0&&o.jsx("div",{className:"comment-replies",children:t.replies.map(v=>o.jsxs("div",{className:"comment-reply",children:[o.jsxs("header",{children:[o.jsxs("span",{className:"comment-author",children:[o.jsx("strong",{children:v.authorDisplayName??v.authorUsername??d("editor.deletedUser")}),v.authorUsername&&o.jsxs("small",{children:["@",v.authorUsername]})]}),o.jsxs("span",{className:"comment-times",children:[o.jsx("time",{dateTime:v.createdAt,title:new Date(v.createdAt).toISOString(),children:_(v.createdAt)}),v.editedAt&&o.jsx("small",{children:d("editor.editedAt",{time:_(v.editedAt)})})]})]}),N===v.id?o.jsxs("form",{className:"comment-reply-form comment-edit-form",onSubmit:I=>{q(I)},onClick:I=>I.stopPropagation(),children:[o.jsx("textarea",{autoFocus:!0,rows:3,value:P,onChange:I=>E(I.target.value)}),o.jsxs("div",{children:[o.jsx("button",{type:"button",onClick:()=>L(null),children:d("common.cancel")}),o.jsxs("button",{className:"primary",type:"submit",disabled:!P.trim(),children:[o.jsx(Vr,{size:13}),d("editor.saveChanges")]})]})]}):o.jsx("p",{children:v.content}),v.authorId===e&&N!==v.id&&o.jsxs("div",{className:"comment-owner-actions",children:[o.jsx("button",{title:d("editor.editReply"),"aria-label":d("editor.editReply"),onClick:I=>{I.stopPropagation(),L(v.id),E(v.content)},children:o.jsx(yo,{size:12})}),o.jsx("button",{className:"danger-text",title:d("editor.deleteReply"),"aria-label":d("editor.deleteReply"),onClick:I=>{I.stopPropagation(),S(v.id)},children:o.jsx(Qn,{size:12})})]})]},v.id))}),o.jsxs("div",{className:"comment-actions",children:[o.jsxs("button",{className:"resolve",onClick:v=>{v.stopPropagation(),s()},children:[t.resolved?o.jsx(jm,{size:13}):o.jsx(am,{size:13}),t.resolved?d("editor.reopen"):d("editor.resolve")]}),o.jsxs("button",{className:"reply-action",onClick:v=>{v.stopPropagation(),u(I=>!I)},children:[o.jsx(Sm,{size:13}),d("editor.reply")]}),t.authorId===e&&!g&&o.jsxs("span",{className:"comment-owner-actions",children:[o.jsx("button",{title:d("editor.editComment"),"aria-label":d("editor.editComment"),onClick:v=>{v.stopPropagation(),j(t.content),x(!0)},children:o.jsx(yo,{size:13})}),o.jsx("button",{className:"danger-text",title:d("editor.deleteComment"),"aria-label":d("editor.deleteComment"),onClick:v=>{v.stopPropagation(),T(!0)},children:o.jsx(Qn,{size:13})})]})]}),f&&o.jsxs("form",{className:"comment-reply-form",onSubmit:v=>{O(v)},onClick:v=>v.stopPropagation(),children:[o.jsx("textarea",{autoFocus:!0,rows:3,value:m,placeholder:d("editor.replyPlaceholder"),onChange:v=>p(v.target.value)}),o.jsxs("div",{children:[o.jsx("button",{type:"button",onClick:()=>{u(!1),p("")},children:d("common.cancel")}),o.jsxs("button",{className:"primary",type:"submit",disabled:!m.trim(),children:[o.jsx(km,{size:13}),d("editor.sendReply")]})]})]})]}),o.jsx(Ls,{open:C,title:d("editor.deleteCommentTitle"),description:d("editor.deleteCommentDescription",{count:t.replies.length}),confirmLabel:d("common.delete"),danger:!0,onCancel:()=>T(!1),onConfirm:()=>{a().then(v=>{v&&T(!1)})}}),o.jsx(Ls,{open:!!H,title:d("editor.deleteReplyTitle"),description:d("editor.deleteReplyDescription"),confirmLabel:d("common.delete"),danger:!0,onCancel:()=>S(null),onConfirm:()=>{H&&l(H).then(v=>{v&&S(null)})}})]})}function Jx({open:t,onOpenChange:e,project:n,projectId:s}){const{t:r}=_e(),[i,a]=h.useState([]),[c,l]=h.useState([]),[d,f]=h.useState(""),[u,m]=h.useState("read"),[p,g]=h.useState(null),[x,b]=h.useState(""),j=n.permission==="owner",C=async()=>{try{const[E,H]=await Promise.all([A(`/api/projects/${s}/members`),A("/api/users")]);a(E.members),l(H.users.filter(S=>S.id!==n.ownerId))}catch(E){b(B(E))}};h.useEffect(()=>{t&&C()},[t,s]);const T=async()=>{if(d)try{await A(`/api/projects/${s}/members/${d}`,{method:"PUT",body:JSON.stringify({permission:u})}),f(""),m("read"),await C()}catch(E){b(B(E))}},N=async(E,H)=>{try{await A(`/api/projects/${s}/members/${E.id}`,{method:"PUT",body:JSON.stringify({permission:H})}),await C()}catch(S){b(B(S))}},L=async()=>{if(p)try{await A(`/api/projects/${s}/members/${p.id}`,{method:"DELETE"}),g(null),await C()}catch(E){b(B(E))}},P=c.filter(E=>!i.some(H=>H.id===E.id));return o.jsxs(o.Fragment,{children:[o.jsx(Fe,{open:t,wide:!0,title:r("projectSettings.share"),description:r("projectSettings.shareDescription"),onOpenChange:e,footer:o.jsx("button",{onClick:()=>e(!1),children:r("common.close")}),children:o.jsxs("div",{className:"share-dialog",children:[x&&o.jsx("p",{className:"error",children:x}),o.jsxs("div",{className:"share-owner",children:[o.jsx(Fs,{size:17}),o.jsxs("span",{children:[o.jsx("small",{children:r("projects.owner")}),o.jsx("strong",{children:n.ownerDisplayName??n.ownerUsername})]})]}),j&&o.jsxs("div",{className:"share-add",children:[o.jsxs("label",{className:"form-field",children:[r("common.user"),o.jsxs("select",{value:d,onChange:E=>f(E.target.value),children:[o.jsx("option",{value:"",children:r("projectSettings.chooseUser")}),P.map(E=>o.jsx("option",{value:E.id,children:E.displayName??E.username},E.id))]})]}),o.jsxs("label",{className:"form-field",children:[r("common.permission"),o.jsxs("select",{value:u,onChange:E=>m(E.target.value),children:[o.jsx("option",{value:"read",children:r("common.readOnly")}),o.jsx("option",{value:"edit",children:r("common.readWrite")})]})]}),o.jsxs("button",{className:"primary icon-button",disabled:!d,onClick:()=>{T()},children:[o.jsx(ld,{size:15}),r("projectSettings.addMember")]})]}),o.jsxs("div",{className:"shared-members-heading",children:[o.jsx("strong",{children:r("projectSettings.members")}),o.jsx("span",{children:i.length})]}),o.jsxs("div",{className:"shared-members",children:[i.map(E=>o.jsxs("div",{className:"shared-member",children:[o.jsxs("span",{className:"member-identity",children:[o.jsx("span",{className:"member-avatar",children:(E.displayName??E.username).slice(0,1).toLocaleUpperCase()}),o.jsxs("span",{children:[o.jsx("strong",{children:E.displayName??E.username}),o.jsxs("small",{children:["@",E.username]})]})]}),o.jsxs("span",{className:"member-controls",children:[o.jsxs("select",{"aria-label":r("common.permission"),disabled:!j,value:E.permission,onChange:H=>{N(E,H.target.value)},children:[o.jsx("option",{value:"read",children:r("common.readOnly")}),o.jsx("option",{value:"edit",children:r("common.readWrite")})]}),j&&o.jsx("button",{className:"icon-only danger-text",title:r("common.remove"),"aria-label":r("common.remove"),onClick:()=>g(E),children:o.jsx(Qn,{size:15})})]})]},E.id)),i.length===0&&o.jsxs("div",{className:"share-empty",children:[o.jsx(Fs,{size:24}),o.jsx("span",{children:r("projectSettings.noMembers")})]})]})]})}),o.jsx(Ls,{open:!!p,title:r("projectSettings.removeTitle"),description:r("projectSettings.removeDescription",{username:p?.username??""}),confirmLabel:r("common.remove"),danger:!0,onCancel:()=>g(null),onConfirm:()=>{L()}})]})}function Yx({project:t,projectId:e,site:n,files:s,dictionaryWords:r,onDictionaryChange:i,editorPreferences:a,onEditorPreferences:c,spellCheckCount:l,spellCheckUniqueCount:d,spellCheckIndex:f,onSpellCheckNavigate:u,onProject:m}){const{t:p}=_e(),[g,x]=h.useState(t.engine),[b,j]=h.useState(""),[C,T]=h.useState(t.name),[N,L]=h.useState(t.mainFile),[P,E]=h.useState(""),[H,S]=h.useState(""),[O,ae]=h.useState(""),[q,R]=h.useState("appearance"),[_,v]=h.useState(a),I=t.permission==="owner",Q=t.permission!=="read",ce=t.permission!=="read";h.useEffect(()=>v(a),[a]),h.useEffect(()=>{if(!t.latexmkrc)return j("");A(`/api/projects/${e}/file?path=${encodeURIComponent(t.latexmkrc)}`).then(({content:D})=>j(D)).catch(D=>E(B(D)))},[t.latexmkrc]);const pe=s.filter(D=>D.type==="file"&&/\.tex$/i.test(D.path)).map(D=>D.path),Y=[...new Set(t.mainFile.toLowerCase().endsWith(".tex")?[...pe,t.mainFile]:pe)].sort((D,U)=>D.localeCompare(U)),ye=async()=>{try{const D=b.trim()&&n.allowProjectLatexmkrc!==!1?".latexmkrc":null;D&&await A(`/api/projects/${e}/file`,{method:"PUT",body:JSON.stringify({path:D,content:b})});const U=await A(`/api/projects/${e}`,{method:"PATCH",body:JSON.stringify({name:C,mainFile:N,engine:g,latexmkrc:D})});m(U.project)}catch(D){E(B(D))}},W=()=>c(_),ve=async()=>{const D=H.trim();if(D)try{const U=await A(`/api/projects/${e}/dictionary`,{method:"POST",body:JSON.stringify({word:D})});i(U.words),S(""),ae("")}catch(U){ae(B(U))}},ze=async D=>{try{const U=await A(`/api/projects/${e}/dictionary/${encodeURIComponent(D)}`,{method:"DELETE"});i(U.words),ae("")}catch(U){ae(B(U))}};return o.jsxs("div",{className:"settings padded",children:[P&&o.jsx("p",{className:"error",children:P}),o.jsxs("div",{className:"settings-tabs",role:"tablist","aria-label":p("common.settings"),children:[o.jsxs("button",{id:"settings-tab-appearance",type:"button",role:"tab","aria-selected":q==="appearance","aria-controls":"settings-panel-appearance",className:`settings-tab${q==="appearance"?" active":""}`,onClick:()=>R("appearance"),children:[o.jsx(xc,{size:15}),p("projectSettings.editorTab")]}),o.jsxs("button",{id:"settings-tab-compiler",type:"button",role:"tab","aria-selected":q==="compiler","aria-controls":"settings-panel-compiler",className:`settings-tab${q==="compiler"?" active":""}`,onClick:()=>R("compiler"),children:[o.jsx(Pr,{size:15}),p("projectSettings.compilerTab")]})]}),q==="appearance"?o.jsxs("section",{id:"settings-panel-appearance",role:"tabpanel","aria-labelledby":"settings-tab-appearance",children:[o.jsxs("div",{className:"settings-section-title",children:[o.jsx(xc,{size:15}),o.jsx("strong",{children:p("projectSettings.editorAppearance")})]}),o.jsx("p",{className:"settings-description appearance-description",children:p("projectSettings.editorAppearanceDescription")}),o.jsxs("label",{children:[p("projectSettings.fontFamily"),o.jsx("select",{value:_.font,onChange:D=>v({..._,font:D.target.value}),children:Hr.map(D=>o.jsx("option",{value:D.id,children:p(D.labelKey)},D.id))})]}),o.jsxs("label",{children:[p("projectSettings.fontSize"),o.jsx("select",{value:_.fontSize,onChange:D=>v({..._,fontSize:Number(D.target.value)}),children:[12,13,14,15,16,18,20].map(D=>o.jsxs("option",{value:D,children:[D," px"]},D))})]}),o.jsxs("label",{children:[p("projectSettings.lineHeight"),o.jsxs("select",{value:_.lineHeight,onChange:D=>v({..._,lineHeight:Number(D.target.value)}),children:[o.jsx("option",{value:1.45,children:p("projectSettings.lineHeightCompact")}),o.jsx("option",{value:1.65,children:p("projectSettings.lineHeightNormal")}),o.jsx("option",{value:1.85,children:p("projectSettings.lineHeightRelaxed")})]})]}),o.jsxs("label",{className:"editor-checkbox",children:[o.jsx("input",{type:"checkbox",checked:_.lineWrapping,onChange:D=>v({..._,lineWrapping:D.target.checked})}),o.jsx(Nm,{size:15}),o.jsx("span",{children:p("projectSettings.lineWrapping")})]}),o.jsxs("label",{className:"editor-checkbox",children:[o.jsx("input",{type:"checkbox",checked:_.spellCheck,onChange:D=>v({..._,spellCheck:D.target.checked})}),o.jsx("span",{children:p("projectSettings.spellCheck")})]}),o.jsxs("label",{className:"editor-checkbox",children:[o.jsx("input",{type:"checkbox",checked:_.vimMode,onChange:D=>v({..._,vimMode:D.target.checked})}),o.jsx("span",{children:p("projectSettings.vimMode")})]}),o.jsxs("p",{className:"field-hint",children:[p("projectSettings.vimModeDescription")," ",o.jsx("a",{href:"https://replit-codemirror-vim.mintlify.app/",target:"_blank",rel:"noreferrer",children:p("projectSettings.vimHelp")})]}),o.jsxs("label",{className:"editor-checkbox",children:[o.jsx("input",{type:"checkbox",disabled:!Q,checked:_.formatOnCompile,onChange:D=>v({..._,formatOnCompile:D.target.checked})}),o.jsx(ed,{size:15}),o.jsx("span",{children:p("projectSettings.formatOnCompile")})]}),o.jsxs("p",{className:"field-hint",children:[p(Q?"projectSettings.formatOnCompileDescription":"projectSettings.formatRequiresWrite")," ",p("projectSettings.formatterDescription")," ",o.jsx("a",{href:"https://github.com/wgunderwood/tex-fmt",target:"_blank",rel:"noreferrer",children:p("projectSettings.formatterInstall")})]}),l!==null&&o.jsxs("div",{className:`spell-check-result${l?" has-issues":""}`,role:"status","aria-live":"polite",children:[o.jsx(Dm,{size:14}),o.jsx("span",{children:l?p("projectSettings.spellingIssues",{count:l,uniqueCount:d??0}):p("projectSettings.noSpellingIssues")}),l>0&&o.jsxs("span",{className:"spell-check-controls",children:[o.jsx("button",{type:"button",title:p("projectSettings.spellCheckFirst"),"aria-label":p("projectSettings.spellCheckFirst"),disabled:f<=0,onClick:()=>u(0),children:o.jsx(im,{size:14})}),o.jsx("button",{type:"button",title:p("projectSettings.spellCheckPrevious"),"aria-label":p("projectSettings.spellCheckPrevious"),disabled:f<=0,onClick:()=>u(f-1),children:o.jsx(rd,{size:14})}),o.jsx("span",{className:"spell-check-position",children:p("projectSettings.spellCheckPosition",{current:Math.min(f+1,l),total:l})}),o.jsx("button",{type:"button",title:p("projectSettings.spellCheckNext"),"aria-label":p("projectSettings.spellCheckNext"),disabled:f>=l-1,onClick:()=>u(f+1),children:o.jsx(Ho,{size:14})}),o.jsx("button",{type:"button",title:p("projectSettings.spellCheckLast"),"aria-label":p("projectSettings.spellCheckLast"),disabled:f>=l-1,onClick:()=>u(l-1),children:o.jsx(om,{size:14})})]})]}),o.jsxs("div",{className:"settings-section-title",children:[o.jsx(nd,{size:15}),o.jsx("strong",{children:p("projectSettings.dictionary")})]}),o.jsx("p",{className:"settings-description",children:p("projectSettings.dictionaryDescription")}),O&&o.jsx("p",{className:"error dictionary-error",children:O}),ce&&o.jsxs("div",{className:"dictionary-add",children:[o.jsx("input",{value:H,placeholder:p("projectSettings.dictionaryPlaceholder"),onChange:D=>S(D.target.value),onKeyDown:D=>{D.key==="Enter"&&(D.preventDefault(),ve())}}),o.jsx("button",{type:"button",disabled:!H.trim(),onClick:()=>{ve()},children:p("projectSettings.addWord")})]}),o.jsxs("div",{className:"dictionary-words",children:[r.map(D=>o.jsxs("span",{className:"dictionary-word",children:[o.jsx("code",{children:D}),ce&&o.jsx("button",{type:"button",title:p("common.delete"),"aria-label":`${p("common.delete")} ${D}`,onClick:()=>{ze(D)},children:o.jsx(Wo,{size:13})})]},D)),r.length===0&&o.jsx("span",{className:"dictionary-empty",children:p("projectSettings.dictionaryEmpty")})]}),o.jsx("div",{className:"settings-actions",children:o.jsxs("button",{className:"settings-save",onClick:W,children:[o.jsx(Vr,{size:15}),p("projectSettings.saveAppearance")]})})]}):o.jsxs("section",{id:"settings-panel-compiler",role:"tabpanel","aria-labelledby":"settings-tab-compiler",children:[o.jsxs("div",{className:"settings-section-title",children:[o.jsx(Pr,{size:15}),o.jsx("strong",{children:p("projectSettings.compilerTab")})]}),o.jsx("p",{className:"settings-description compiler-description",children:p("projectSettings.compilerDescription")}),o.jsxs("div",{className:"settings-section-title project-configuration",children:[o.jsx(Pr,{size:15}),o.jsx("strong",{children:p("projectSettings.projectConfiguration")})]}),o.jsxs("label",{children:[p("projects.name"),o.jsx("input",{disabled:!I,value:C,onChange:D=>T(D.target.value)})]}),o.jsxs("label",{children:[p("projectSettings.mainFile"),o.jsx("select",{disabled:!I||Y.length===0,value:N,onChange:D=>L(D.target.value),children:Y.map(D=>o.jsx("option",{value:D,children:D},D))})]}),o.jsxs("label",{children:[p("projectSettings.engine"),o.jsx("select",{disabled:!I,value:g,onChange:D=>x(D.target.value),children:(n.allowedEngines??["pdflatex","xelatex","lualatex"]).map(D=>o.jsx("option",{children:D},D))})]}),o.jsxs("label",{children:[p("projectSettings.latexmkrc"),o.jsx("textarea",{className:"latexmkrc-editor",rows:10,spellCheck:!1,disabled:!I||n.allowProjectLatexmkrc===!1,value:b,placeholder:p("projectSettings.latexmkrcPlaceholder"),onChange:D=>j(D.target.value)})]}),o.jsx("div",{className:"settings-actions",children:I&&o.jsxs("button",{className:"settings-save",onClick:()=>{ye()},children:[o.jsx(Vr,{size:15}),p("projectSettings.saveCompiler")]})})]})]})}function sl({diagnostics:t,files:e,empty:n,tone:s,onJump:r}){const{t:i}=_e(),a=s==="error"?qo:As;return t.length?o.jsx("div",{className:`compile-diagnostic-list compile-${s}`,children:t.map((c,l)=>{const d=Zx(c.file,e),f=!!(d&&c.line);return o.jsxs("button",{type:"button",disabled:!f,className:"compile-diagnostic-row",onClick:()=>{d&&c.line&&r(d,c.line,c.column??1)},children:[o.jsx(a,{size:15}),o.jsxs("span",{children:[o.jsx("strong",{children:c.message}),o.jsxs("small",{children:[c.phase,d?` · ${d}${c.line?`:${c.line}`:""}`:c.line?` · ${i("editor.lineNumber",{line:c.line})}`:""]})]})]},`${c.phase}-${c.file??""}-${c.line??0}-${l}`)})}):o.jsxs("div",{className:`compile-empty compile-${s}`,children:[o.jsx(a,{size:26}),o.jsx("span",{children:n})]})}function no({lines:t,empty:e,tone:n="log"}){const s=n==="error"?qo:n==="warning"?As:cd;return t.length?o.jsx("pre",{className:`compile-output compile-${n}`,children:t.join(`
|
|
13
|
-
`)}):o.jsxs("div",{className:`compile-empty compile-${n}`,children:[o.jsx(s,{size:26}),o.jsx("span",{children:e})]})}function Xx({projectId:t,mainFile:e,artifacts:n,preview:s,loading:r,onView:i}){const{t:a}=_e(),c=l=>`/api/projects/${t}/compile/artifacts?mainFile=${encodeURIComponent(e)}&path=${encodeURIComponent(l)}&download=1`;return n.length?o.jsxs("div",{className:"artifact-browser",children:[o.jsx("div",{className:"artifact-list",children:n.map(l=>o.jsxs("div",{className:`artifact-row${s?.path===l.path?" active":""}`,children:[o.jsxs("button",{type:"button",disabled:!l.viewable,title:l.viewable?a("editor.viewArtifact"):a("editor.downloadToView"),onClick:()=>i(l),children:[o.jsx(Vn,{size:14}),o.jsxs("span",{children:[o.jsx("strong",{children:l.path}),o.jsx("small",{children:Qx(l.size)})]})]}),o.jsx("a",{href:c(l.path),title:a("editor.downloadArtifact"),"aria-label":a("editor.downloadArtifact"),children:o.jsx(Ur,{size:14})})]},l.path))}),o.jsx("div",{className:"artifact-preview",children:r?o.jsxs("div",{className:"compile-empty",children:[o.jsx(pn,{className:"spin",size:24}),o.jsx("span",{children:a("common.loading")})]}):s?o.jsxs(o.Fragment,{children:[o.jsxs("header",{children:[o.jsx("strong",{children:s.path}),o.jsxs("a",{href:c(s.path),children:[o.jsx(Ur,{size:13}),a("projects.download")]})]}),o.jsx("pre",{children:s.content})]}):o.jsxs("div",{className:"compile-empty",children:[o.jsx(Vn,{size:24}),o.jsx("span",{children:a("editor.selectArtifact")})]})})]}):o.jsxs("div",{className:"compile-empty",children:[o.jsx(ad,{size:26}),o.jsx("span",{children:a("editor.noArtifacts")})]})}function Zx(t,e){if(!t)return null;const n=e.filter(c=>c.type==="file").map(c=>c.path),s=t.replaceAll("\\","/").replace(/^\.\//,"");if(n.includes(s))return s;const r=n.filter(c=>s.endsWith(`/${c}`));if(r.length===1)return r[0];const i=s.split("/").at(-1),a=n.filter(c=>c.split("/").at(-1)===i);return a.length===1?a[0]:null}function Qx(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`}function eb(t){return t instanceof Error&&t.name==="AbortError"}function tb({projectId:t,activeFile:e,permission:n,revision:s,selection:r,save:i,onError:a,onAdded:c}){const[l,d]=h.useState([]),[f,u]=h.useState(null),[m,p]=h.useState(!1),[g,x]=h.useState(""),b=h.useRef(null),j=h.useRef(e),C=h.useRef(i),T=h.useRef(a),N=h.useRef(c);j.current=e,C.current=i,T.current=a,N.current=c;const L=async R=>{b.current?.abort();const _=new AbortController;b.current=_;try{const v=await A(`/api/projects/${t}/comments?path=${encodeURIComponent(R)}`,{signal:_.signal});j.current===R&&d(v.comments)}catch(v){!eb(v)&&j.current===R&&d([])}finally{b.current===_&&(b.current=null)}};return h.useEffect(()=>{u(null)},[t,e]),h.useEffect(()=>(e?L(e):d([]),()=>{b.current?.abort(),b.current=null}),[t,e,s]),{comments:l,focusComment:f,setFocusComment:u,commentOpen:m,setCommentOpen:p,commentText:g,setCommentText:x,addComment:async()=>{if(!(!g.trim()||!e))try{if(n!=="read"&&!await C.current())return;await A(`/api/projects/${t}/comments`,{method:"POST",body:JSON.stringify({path:e,content:g,...r})}),await L(e),p(!1),x(""),N.current()}catch(R){T.current(B(R))}},toggleComment:async R=>{try{await A(`/api/projects/${t}/comments/${R.id}`,{method:"PATCH",body:JSON.stringify({resolved:!R.resolved})}),await L(e)}catch(_){T.current(B(_))}},replyToComment:async(R,_)=>{try{return await A(`/api/projects/${t}/comments/${R.id}/replies`,{method:"POST",body:JSON.stringify({content:_})}),await L(e),!0}catch(v){return T.current(B(v)),!1}},editComment:async(R,_)=>{try{return await A(`/api/projects/${t}/comments/${R.id}`,{method:"PATCH",body:JSON.stringify({content:_})}),await L(e),!0}catch(v){return T.current(B(v)),!1}},deleteComment:async R=>{try{return await A(`/api/projects/${t}/comments/${R.id}`,{method:"DELETE"}),await L(e),u(_=>_?.id===R.id?null:_),!0}catch(_){return T.current(B(_)),!1}},editCommentReply:async(R,_,v)=>{try{return await A(`/api/projects/${t}/comments/${R.id}/replies/${_}`,{method:"PATCH",body:JSON.stringify({content:v})}),await L(e),!0}catch(I){return T.current(B(I)),!1}},deleteCommentReply:async(R,_)=>{try{return await A(`/api/projects/${t}/comments/${R.id}/replies/${_}`,{method:"DELETE"}),await L(e),!0}catch(v){return T.current(B(v)),!1}}}}function nb(t){if(!t||typeof t!="object")return!1;const e=t;return(e.kind==="update"||e.kind==="move"||e.kind==="delete")&&typeof e.revision=="string"}function sb(t,e,n,s){const[r]=h.useState(()=>new Bx(t,e)),[i,a]=h.useState("connecting"),[c,l]=h.useState(!1),[d,f]=h.useState([]),[u,m]=h.useState(null),[p,g]=h.useState(null),[x,b]=h.useState(""),[j,C]=h.useState(""),[T,N]=h.useState(!1),L=h.useRef(n),P=h.useRef(s);return L.current=n,P.current=s,h.useEffect(()=>{const H=tl(r.meta.get("compileStates"));m(H[n]??null)},[n,r]),h.useEffect(()=>{const H=()=>f(r.sessions()),S=()=>{l(!1),f([]),m(null),g(null),b(""),C(""),P.current()},O=({status:v})=>{a(v),v!=="connected"&&S()},ae=v=>{l(v),v||S()},q=()=>{a("disconnected"),S()},R=()=>{const v=r.meta.get("filesEvent");nb(v)&&g(v);const I=r.meta.get("commentsRevision");typeof I=="string"&&b(I);const Q=r.meta.get("dictionaryRevision");typeof Q=="string"&&C(Q);const ce=tl(r.meta.get("compileStates"));m(ce[L.current]??null)};r.awareness.on("change",H),r.provider.on("status",O),r.provider.on("sync",ae),r.provider.on("connection-close",q),r.provider.on("connection-error",q),r.meta.observe(R);const _=r.onDraftReady(()=>N(!0));return H(),R(),a(r.connected?"connected":"connecting"),l(r.synced),()=>{r.awareness.off("change",H),r.provider.off("status",O),r.provider.off("sync",ae),r.provider.off("connection-close",q),r.provider.off("connection-error",q),r.meta.unobserve(R),_(),r.destroy()}},[r]),{collaboration:r,status:i,synced:c,activeSessions:d,compileState:u,setCompileState:m,filesEvent:p,commentsRevision:x,dictionaryRevision:j,localDraftReady:T,reconnect:()=>{a("connecting"),l(!1),f([]),m(null),r.reconnect()}}}function Es(t){return t instanceof Error&&t.name==="AbortError"}function rb({projectId:t,project:e,mainFile:n,collaborationSynced:s,sharedState:r,onSharedState:i,save:a,loadOutline:c,onPreviewTab:l,onError:d,onCompileStart:f,onPdfChanged:u}){const{t:m}=_e(),[p,g]=h.useState(""),[x,b]=h.useState(null),[j,C]=h.useState(""),[T,N]=h.useState(null),[L,P]=h.useState(null),[E,H]=h.useState([]),[S,O]=h.useState(null),[ae,q]=h.useState(!1),[R,_]=h.useState(()=>new Set),[v,I]=h.useState(""),Q=h.useRef(n),ce=h.useRef(null),pe=h.useRef(null),Y=h.useRef(new Map),ye=h.useRef(()=>{}),W=h.useRef({onSharedState:i,save:a,loadOutline:c,onPreviewTab:l,onError:d,onCompileStart:f,onPdfChanged:u});Q.current=n,W.current={onSharedState:i,save:a,loadOutline:c,onPreviewTab:l,onError:d,onCompileStart:f,onPdfChanged:u};const ve=async(U,K)=>{K||(pe.current?.abort(),pe.current=new AbortController,K=pe.current.signal);try{const V=U?`?mainFile=${encodeURIComponent(U)}`:"",te=await A(`/api/projects/${t}/compile/artifacts${V}`,{signal:K});Q.current===U&&(H(te.artifacts),O(null))}catch(V){!Es(V)&&Q.current===U&&(H([]),O(null))}finally{pe.current?.signal===K&&(pe.current=null)}};h.useEffect(()=>{ce.current?.abort();const U=new AbortController;if(ce.current=U,C(""),N(null),P(null),g(""),b(null),H([]),O(null),W.current.onPdfChanged(),!e||!n)return()=>U.abort();const K=`?mainFile=${encodeURIComponent(n)}`,V=A(`/api/projects/${t}/compile/artifacts${K}`,{signal:U.signal}).catch(te=>{if(Es(te))throw te;return{artifacts:[]}});return Promise.all([A(`/api/projects/${t}/compile/latest${K}`,{signal:U.signal}),V,W.current.loadOutline(U.signal,n)]).then(([te,Qe])=>{U.signal.aborted||te.mainFile!==Q.current||(H(Qe.artifacts),C(te.latestRun?.log??""),N(te.latestRun?.diagnostics??null),P(te.latestRun?.status==="succeeded"||te.latestRun?.status==="failed"?te.latestRun.status:null),te.latestRun?.requestedBy&&(te.latestRun.status==="queued"||te.latestRun.status==="running")&&W.current.onSharedState({mainFile:n,runId:te.latestRun.id,status:te.latestRun.status,requestedBy:te.latestRun.requestedBy,updatedAt:new Date().toISOString()}),te.pdfUrl&&(g(te.pdfUrl),b(te.pdfCompiledAt),W.current.onPreviewTab("pdf")))}).catch(te=>{!Es(te)&&Q.current===n&&W.current.onError(B(te))}).finally(()=>{ce.current===U&&(ce.current=null)}),()=>U.abort()},[e?.id,t,n]),h.useEffect(()=>{if(!r||r.mainFile!==n||r.status!=="succeeded"&&r.status!=="failed")return;let U=!1;ce.current?.abort();const K=new AbortController;return ce.current=K,A(`/api/projects/${t}/compile/latest?mainFile=${encodeURIComponent(n)}`,{signal:K.signal}).then(V=>{U||V.mainFile!==Q.current||V.latestRun?.id!==r.runId||(C(V.latestRun.log),N(V.latestRun.diagnostics),P(r.status==="succeeded"?"succeeded":"failed"),r.status==="succeeded"&&V.pdfUrl?(W.current.onPdfChanged(),g(V.pdfUrl),b(V.pdfCompiledAt),W.current.onPreviewTab("pdf"),ve(n)):r.status==="failed"&&W.current.onPreviewTab(V.latestRun.diagnostics.errors.length?"errors":"log"))}).catch(V=>{!Es(V)&&!U&&W.current.onError(B(V))}),()=>{U=!0,K.abort(),ce.current===K&&(ce.current=null)}},[r?.runId,r?.status,r?.mainFile,n,t]);const ze=async()=>{if(!e||!n||e.permission==="read"||!s||Y.current.has(n)||r?.mainFile===n&&(r.status==="queued"||r.status==="running"))return;const U=n;_(V=>new Set([...V,U])),W.current.onCompileStart(),I(""),C(""),N(null),P(null),W.current.onPreviewTab(p?"pdf":"log");const K=new AbortController;Y.current.set(U,K);try{if(!await W.current.save())return;const V=await A(`/api/projects/${t}/compile`,{method:"POST",signal:K.signal,body:JSON.stringify({mainFile:U})});if(V.mainFile!==Q.current)return;C(V.log),N(V.diagnostics),P(V.ok?"succeeded":"failed"),V.skipped&&I(m("editor.upToDate")),V.pdfUrl?(W.current.onPdfChanged(),g(V.pdfUrl),b(V.pdfCompiledAt),W.current.onPreviewTab("pdf")):W.current.onPreviewTab(V.diagnostics.errors.length?"errors":"log")}catch(V){!Es(V)&&Q.current===U&&W.current.onError(B(V))}finally{Y.current.get(U)===K&&(Y.current.delete(U),_(V=>{const te=new Set(V);return te.delete(U),te}))}};ye.current=()=>{ze()},h.useEffect(()=>{if(!v)return;const U=window.setTimeout(()=>I(""),3e3);return()=>window.clearTimeout(U)},[v]),h.useEffect(()=>{const U=K=>{!(K.ctrlKey||K.metaKey)||K.key.toLocaleLowerCase()!=="s"||(K.preventDefault(),K.stopPropagation(),K.repeat||ye.current())};return window.addEventListener("keydown",U,!0),()=>window.removeEventListener("keydown",U,!0)},[]),h.useEffect(()=>()=>{ce.current?.abort(),pe.current?.abort();for(const U of Y.current.values())U.abort();Y.current.clear()},[]);const D=async U=>{if(U.viewable){q(!0);try{const K=await A(`/api/projects/${t}/compile/artifacts?mainFile=${encodeURIComponent(n)}&path=${encodeURIComponent(U.path)}`);O(K)}catch(K){W.current.onError(B(K))}finally{q(!1)}}};return{pdfUrl:p,pdfCompiledAt:x,compileLog:j,compileDiagnostics:T,compileOutcome:L,artifacts:E,artifactPreview:S,artifactLoading:ae,editorNotice:v,localCompiling:R.has(n),compile:ze,viewArtifact:D}}const rl=10*1024*1024,ib=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp",".ico",".avif",".pdf",".zip",".gz",".bz2",".xz",".tar",".rar",".7z",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".odt",".ods",".odp",".mp3",".mp4",".wav",".ogg",".webm",".mov",".avi",".wasm",".exe",".bin",".so",".dll",".class",".jar"]);function il(t){return t instanceof Error&&t.name==="AbortError"}function Ns(t){const e=t.split("/").filter(Boolean);return e.pop(),e.map((n,s)=>e.slice(0,s+1).join("/"))}function In(t,e){return!!(t&&e)&&(e===t||e.startsWith(`${t}/`))}function ob(t){const e=`.${t.split(".").at(-1)?.toLocaleLowerCase()??""}`;return!ib.has(e)}function _o(t){return/(?:\.(?:tex|bib|sty|cls|txt|md)|latexmkrc)$/i.test(t)}function ol(t){const e=t.split(".").at(-1)?.toLocaleLowerCase()??"";return e==="pdf"?"pdf":["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif"].includes(e)?"image":ob(t)?"text":"unsupported"}function ab(t,e){return`/api/projects/${t}/file/raw?path=${encodeURIComponent(e)}`}function cb({projectId:t,site:e,activeFile:n,dirty:s,save:r,onError:i,onProject:a,onActiveFile:c,onActiveMainFile:l,onRootDocuments:d}){const{t:f}=_e(),[u,m]=h.useState([]),[p,g]=h.useState(!1),[x,b]=h.useState(""),[j,C]=h.useState(null),[T,N]=h.useState(!1),[L,P]=h.useState(!1),[E,H]=h.useState(""),[S,O]=h.useState(""),[ae,q]=h.useState(""),[R,_]=h.useState(new Set),[v,I]=h.useState(null),[Q,ce]=h.useState(""),[pe,Y]=h.useState(null),[ye,W]=h.useState(!1),[ve,ze]=h.useState(null),[D,U]=h.useState(!1),K=h.useRef(null),V=h.useRef(null),te=async(M={})=>{K.current?.abort(),K.current=null;const se=M.signal?null:new AbortController;se&&(K.current=se);try{const me=await A(`/api/projects/${t}/files`,{signal:M.signal??se?.signal});return(!M.isCurrent||M.isCurrent())&&m(me.files),me.files}catch(me){if(!il(me))throw me;return}finally{se&&K.current===se&&(K.current=null)}},Qe=async()=>{if(!(!x.trim()||x.trim().endsWith("/"))){O("");try{await A(`/api/projects/${t}/file`,{method:"POST",body:JSON.stringify({path:x,content:""})}),await te(),c(x),_(M=>new Set([...M,...Ns(x)])),g(!1),b("")}catch(M){O(B(M))}}},Kt=async()=>{if(!E.trim())return;O("");const M=ae?`${ae}/${E.trim()}`:E.trim();try{const se=await A(`/api/projects/${t}/folders`,{method:"POST",body:JSON.stringify({path:M})});await te(),_(me=>new Set([...me,...Ns(se.path),se.path])),q(se.path),P(!1),H("")}catch(se){O(B(se))}},Ot=async(M,se=new Set,me=ae)=>{if(!M.length)return;const Ne=e.maxUploadSizeMB??50;if(M.find(ie=>ie.size>Ne*1024*1024))return i(f("errors.fileTooLarge",{size:Ne}));const $e=me,Ve=M.map(ie=>$e?`${$e}/${ie.name}`:ie.name),dt=new Map;for(const ie of Ve)dt.set(ie,(dt.get(ie)??0)+1);const ut=[...dt.entries()].filter(([,ie])=>ie>1).map(([ie])=>ie);if(ut.length)return i(f("errors.duplicateUploadNames",{files:ut.join(", ")}));const Rt=new Set(u.map(ie=>ie.path)),Te=[...new Set(Ve.filter(ie=>Rt.has(ie)&&!se.has(ie)))];if(Te.length){ze({files:M,directory:$e,collisions:Te});return}ze(null),U(!0);try{const ie=new URLSearchParams;$e&&ie.set("directory",$e);let xt="";for(const[nt,Ke]of M.entries()){const st=Ve[nt];ie.delete("overwrite"),se.has(st)&&ie.set("overwrite","1");const Pe=ie.toString()?`?${ie.toString()}`:"",ht=new FormData;ht.append("file",Ke);const re=await fetch(`/api/projects/${t}/upload${Pe}`,{method:"POST",body:ht}),Ge=await re.json().catch(()=>({}));if(!re.ok){if(re.status===409&&!se.has(st)&&Ge.code==="FILE_EXISTS"){nt>0&&await te(),ze({files:M.slice(nt),directory:$e,collisions:[typeof Ge.path=="string"?Ge.path:st]});return}throw new Error(re.status===409?f("errors.pathConflict"):Ro(Ge,re.status,"errors.upload"))}typeof Ge.path=="string"&&_o(Ge.path)&&(xt=Ge.path)}await te(),xt&&c(xt)}catch(ie){i(B(ie))}finally{U(!1)}},Gt=async M=>{await Ot(Array.from(M.target.files??[])),M.target.value=""},Jt=async M=>{V.current?.abort(),V.current=null,N(!1);const se=ab(t,M.path);if((M.size??0)>rl){C({path:M.path,kind:"large",size:M.size??0,url:se});return}const me=ol(M.path);if(me!=="text"){C({path:M.path,kind:me,size:M.size??0,url:se});return}C({path:M.path,kind:me,size:M.size??0,url:se,content:""}),N(!0);const Ne=new AbortController;V.current=Ne;try{const oe=await fetch(se,{signal:Ne.signal}),$e=await oe.text();if(!oe.ok)throw new Error($e||f("errors.request",{status:oe.status}));C(Ve=>Ve?.path===M.path?{...Ve,content:$e}:Ve)}catch(oe){il(oe)||(C(null),i(B(oe)))}finally{V.current===Ne&&(V.current=null,N(!1))}},dn=M=>{const se=ol(M.path);(M.size??0)>rl||se!=="text"||!_o(M.path)?Jt(M):c(M.path)},_t=async()=>{if(v){O("");try{if(!await r())return;const M=await A(`/api/projects/${t}/path`,{method:"PATCH",body:JSON.stringify({source:v.path,destinationDirectory:Q})}),se=oe=>oe===v.path?M.path:oe.startsWith(`${v.path}/`)?`${M.path}${oe.slice(v.path.length)}`:oe;c(oe=>se(oe)),l(oe=>se(oe)),d(oe=>new Set([...oe].map(se))),q(oe=>oe&&se(oe));const[me,Ne]=await Promise.all([A(`/api/projects/${t}/files`),A(`/api/projects/${t}`)]);m(me.files),a(Ne.project),_(oe=>new Set([...oe,...Ns(M.path),Q].filter(Boolean))),I(null),ce("")}catch(M){O(B(M))}}},Yt=async()=>{if(pe){O("");try{if(s&&!await r())return;await A(`/api/projects/${t}/file?path=${encodeURIComponent(pe.path)}`,{method:"DELETE"}),Y(null)}catch(M){O(B(M))}}};h.useEffect(()=>()=>{K.current?.abort(),V.current?.abort()},[]),h.useEffect(()=>{V.current?.abort(),V.current=null,N(!1)},[n]);const wt=u.filter(M=>M.type==="directory"),Pt=u.filter(M=>Ns(M.path).every(se=>R.has(se)));return{files:u,setFiles:m,loadFiles:te,newFileOpen:p,setNewFileOpen:g,newFilePath:x,setNewFilePath:b,resourcePreview:j,setResourcePreview:C,resourcePreviewLoading:T,setResourcePreviewLoading:N,newFolderOpen:L,setNewFolderOpen:P,newFolderName:E,setNewFolderName:H,fileDialogError:S,setFileDialogError:O,selectedFolder:ae,setSelectedFolder:q,expandedFolders:R,setExpandedFolders:_,moveEntry:v,setMoveEntry:I,moveDestination:Q,setMoveDestination:ce,deleteEntry:pe,setDeleteEntry:Y,fileDragActive:ye,setFileDragActive:W,uploadConflict:ve,setUploadConflict:ze,uploadingFiles:D,directoryEntries:wt,visibleEntries:Pt,createFile:Qe,createFolder:Kt,uploadFiles:Ot,upload:Gt,openFile:dn,movePath:_t,removePath:Yt}}function lb({active:t,activeFile:e,content:n,dictionaryWords:s}){const[r,i]=h.useState([]),[a,c]=h.useState(""),[l,d]=h.useState(""),[f,u]=h.useState(0),[m,p]=h.useState(null),g=h.useRef(0),x=h.useRef(n),b=h.useRef(e),j=h.useRef(0);x.current=n,b.current=e,h.useEffect(()=>{i([]),c(""),d(""),p(null)},[e,s]),h.useEffect(()=>{u(L=>r.length?Math.min(L,r.length-1):0)},[r]),h.useEffect(()=>{const L=++g.current;if(!t||!e){i([]),c(""),d(""),p(null);return}const P=n,E=e,H=window.setTimeout(()=>{qt(async()=>{const{checkSpelling:S}=await import("./spellCheck-R6fUM9oA.js");return{checkSpelling:S}},__vite__mapDeps([2,1])).then(({checkSpelling:S})=>{if(L!==g.current||x.current!==P||b.current!==E)return;const O=S(P,s);L!==g.current||x.current!==P||b.current!==E||(i(O),c(P),d(E),u(0),p(null))}).catch(()=>{})},700);return()=>window.clearTimeout(H)},[t,e,n,s]);const C=l===e&&a===n,T=h.useMemo(()=>C?{total:r.length,unique:new Set(r.map(L=>L.word.toLocaleLowerCase("en-US"))).size}:null,[C,r]);return{issues:C?r:[],jump:C?m:null,index:f,summary:T,jumpToIssue:L=>{if(!r.length)return;const P=Math.max(0,Math.min(L,r.length-1)),E=r[P];u(P),p({from:E.from,to:E.to,nonce:++j.current})}}}function al(t){return t instanceof Error&&t.name==="AbortError"}function db({projectId:t,mainFile:e,activeFile:n,onActiveFile:s,onError:r,onShowPdf:i}){const[a,c]=h.useState(null),[l,d]=h.useState(null),[f,u]=h.useState(null),m=h.useRef(null),p=h.useRef(0),g=h.useRef(n),x=h.useRef(s),b=h.useRef(r),j=h.useRef(i);g.current=n,x.current=s,b.current=r,j.current=i,h.useEffect(()=>(m.current?.abort(),m.current=null,c(null),d(null),u(null),()=>m.current?.abort()),[t,e]);const C=(P,E,H)=>{u({path:P,line:E,column:H,nonce:++p.current}),g.current!==P&&x.current(P)},T=async(P,E,H)=>{m.current?.abort();const S=new AbortController;m.current=S;try{const O=await A(`/api/projects/${t}/sync/pdf?mainFile=${encodeURIComponent(e)}&path=${encodeURIComponent(P)}&line=${E}&column=${H}`,{signal:S.signal});if(m.current!==S)return;c({...O,nonce:++p.current}),j.current()}catch(O){al(O)||b.current(B(O))}finally{m.current===S&&(m.current=null)}},N=async(P,E,H)=>{m.current?.abort();const S=new AbortController;m.current=S;try{const O=await A(`/api/projects/${t}/sync/source?mainFile=${encodeURIComponent(e)}&page=${P}&x=${E}&y=${H}`,{signal:S.signal});if(m.current!==S)return;C(O.path,O.line,O.column)}catch(O){al(O)||b.current(B(O))}finally{m.current===S&&(m.current=null)}};return{pdfTarget:a,pdfViewport:l,sourceJump:f,setPdfViewport:d,clearPdfViewport:()=>d(null),jumpToSource:C,syncSourceToPdf:T,syncPdfToSource:N,syncVisiblePdfToSource:()=>{l&&N(l.page,l.x,l.y)}}}function qu(t,e){return`texlite.workspaceLayout:${encodeURIComponent(t)}:${encodeURIComponent(e)}`}function cl(t,e){try{const n=window.localStorage.getItem(qu(t,e));if(n==="editor-pdf"||n==="editor-only"||n==="pdf-only")return n}catch{}return"editor-pdf"}function ub(t,e){const[n,s]=h.useState(()=>cl(t,e));return h.useEffect(()=>{s(cl(t,e))},[t,e]),{workspaceLayout:n,setWorkspaceLayout:i=>{s(i);try{window.localStorage.setItem(qu(t,e),i)}catch{}}}}const Wu=()=>qt(()=>import("./PdfPreview-BXV75mRa.js"),__vite__mapDeps([3,1,4,5])),hb=h.lazy(()=>Wu().then(t=>({default:t.PdfPreview}))),fb=h.lazy(()=>qt(()=>import("./LatexEditor-CbYL1NGq.js"),__vite__mapDeps([6,1,7])).then(t=>({default:t.LatexEditor}))),pb=h.lazy(()=>qt(()=>import("./GitDialog-BRIGO4No.js"),__vite__mapDeps([8,1,5])).then(t=>({default:t.GitDialog}))),mb=h.lazy(()=>qt(()=>import("./HistoryDialog-ClN5gb3K.js"),__vite__mapDeps([9,1,0])).then(t=>({default:t.HistoryDialog}))),gb=h.lazy(()=>qt(()=>import("./ProjectNavigationDialogs-BK3E3V9t.js"),__vite__mapDeps([10,1])).then(t=>({default:t.ProjectSearchDialog}))),yb=h.lazy(()=>qt(()=>import("./ProjectNavigationDialogs-BK3E3V9t.js"),__vite__mapDeps([10,1])).then(t=>({default:t.QuickOpenDialog}))),wb=h.lazy(()=>qt(()=>import("./SystemMetricsDialog-vrmlRA2s.js"),__vite__mapDeps([11,1])).then(t=>({default:t.SystemMetricsDialog}))),Ye=8;function zn(t){return t instanceof Error&&t.name==="AbortError"}function xb(){const{t}=_e(),[e,n]=h.useState({siteName:"TexLite",adminEmail:""}),[s,r]=h.useState(),[i,a]=h.useState(()=>typeof window>"u"?null:Dr(window.location.pathname)),[c,l]=h.useState(null);h.useEffect(()=>{const m=Dr(window.location.pathname);if(m&&window.location.pathname!==Vi(m)){const x={texliteRoute:"project",projectId:m,fromDashboard:!1};window.history.replaceState(x,"",Vi(m))}const p=()=>a(Dr(window.location.pathname)),g=()=>{if(l(null),r(null),Dr(window.location.pathname)){const x={texliteRoute:"dashboard"};window.history.replaceState(x,"","/"),a(null)}};return window.addEventListener("popstate",p),window.addEventListener("texlite:session-expired",g),()=>{window.removeEventListener("popstate",p),window.removeEventListener("texlite:session-expired",g)}},[]);const d=m=>{const p=Vi(m);if(window.location.pathname!==p){const g={texliteRoute:"project",projectId:m,fromDashboard:!0};window.history.pushState(g,"",p)}a(m)},f=()=>{const m=window.history.state;if($m(m)&&m.fromDashboard){window.history.back();return}const p={texliteRoute:"dashboard"};window.history.replaceState(p,"","/"),a(null)};if(h.useEffect(()=>{A("/api/config").then(m=>{n(m),document.title=m.siteName}),A("/api/me").then(({user:m})=>r(m)).catch(m=>{m instanceof Po&&m.status,r(null)})},[]),s===void 0)return o.jsx("div",{className:"center-card",children:t("common.loading")});if(!s)return o.jsx(vb,{site:e,onLogin:r});if(s.mustChangePassword)return o.jsx(bb,{site:e,user:s,onChanged:m=>r(m)});if(i)return o.jsx(kb,{site:e,user:s,projectId:i,onBack:f},i);const u=c?.userId===s.id?c:null;return o.jsx(Sb,{site:e,user:s,initialData:u?{projects:u.projects,tags:u.tags,pagination:u.pagination}:null,onDataChange:(m,p,g)=>l({userId:s.id,projects:m,tags:p,pagination:g}),onUser:m=>{(!m||m.id!==s.id)&&l(null),r(m),m||f()},onOpenProject:d})}function xi({siteName:t,compact:e=!1,auth:n=!1}){return o.jsx("span",{className:`site-logo${e?" compact":""}${n?" auth-logo":""}`,children:o.jsx("img",{src:"/logo.svg",alt:t})})}function Ea(){const{t}=_e();return o.jsxs("footer",{className:"site-footer",children:[o.jsxs("span",{children:[t("footer.copyright",{year:new Date().getFullYear()})," ",o.jsxs("a",{href:"https://github.com/SWUFE-DB-Group/TexLite",target:"_blank",rel:"noreferrer",children:["TexLite v",Th]})]}),o.jsx("span",{children:t("footer.credit")})]})}function bb({site:t,user:e,onChanged:n}){const{t:s}=_e(),[r,i]=h.useState(""),[a,c]=h.useState(""),[l,d]=h.useState(""),[f,u]=h.useState(""),m=async p=>{if(p.preventDefault(),a!==l)return u(s("auth.mismatch"));if(a.length<Ye)return u(s("auth.passwordMinimum",{count:Ye}));try{await A("/api/me/password",{method:"PUT",body:JSON.stringify({currentPassword:r,newPassword:a})}),n({...e,mustChangePassword:!1})}catch(g){u(B(g))}};return o.jsxs("main",{className:"login-page",children:[o.jsx(Bo,{}),o.jsxs("form",{className:"login-card",onSubmit:m,children:[o.jsx(xi,{siteName:t.siteName,auth:!0}),o.jsx("h1",{className:"sr-only",children:t.siteName}),o.jsx("p",{className:"muted",children:s("auth.firstLogin")}),o.jsxs("label",{children:[s("auth.currentPassword"),o.jsx("input",{type:"password",value:r,onChange:p=>i(p.target.value)})]}),o.jsxs("label",{children:[s("auth.newPassword"),o.jsx("input",{type:"password",minLength:Ye,autoComplete:"new-password",value:a,onChange:p=>c(p.target.value)}),o.jsx("small",{className:"field-hint",children:s("auth.passwordMinimum",{count:Ye})})]}),o.jsxs("label",{children:[s("auth.confirmPassword"),o.jsx("input",{type:"password",minLength:Ye,autoComplete:"new-password",value:l,onChange:p=>d(p.target.value)})]}),f&&o.jsx("p",{className:"error",children:f}),o.jsx("button",{className:"primary",children:s("auth.updatePassword")})]}),o.jsx(Ea,{})]})}function vb({site:t,onLogin:e}){const{t:n}=_e(),[s,r]=h.useState(""),[i,a]=h.useState(""),[c,l]=h.useState(""),d=async f=>{f.preventDefault(),l("");try{const u=await A("/api/auth/login",{method:"POST",body:JSON.stringify({username:s,password:i})});e(u.user)}catch(u){l(B(u))}};return o.jsxs("main",{className:"login-page",children:[o.jsx(Bo,{}),o.jsxs("form",{className:"login-card",onSubmit:d,children:[o.jsx(xi,{siteName:t.siteName,auth:!0}),o.jsx("h1",{className:"sr-only",children:t.siteName}),o.jsx("p",{className:"muted",children:n("auth.tagline")}),o.jsxs("label",{children:[n("auth.username"),o.jsx("input",{autoFocus:!0,value:s,onChange:f=>r(f.target.value)})]}),o.jsxs("label",{children:[n("auth.password"),o.jsx("input",{type:"password",value:i,onChange:f=>a(f.target.value)})]}),c&&o.jsx("p",{className:"error",children:c}),o.jsx("button",{className:"primary",type:"submit",children:n("auth.login")}),t.adminEmail&&o.jsx("small",{className:"support",children:n("auth.contact",{email:t.adminEmail})})]}),o.jsx(Ea,{})]})}function Sb({site:t,user:e,initialData:n,onDataChange:s,onUser:r,onOpenProject:i}){const{t:a}=_e(),[c,l]=h.useState(()=>n?.projects??[]),[d,f]=h.useState(()=>n?.tags??[]),[u,m]=h.useState(()=>n?.pagination??{page:1,pageSize:20,total:n?.projects.length??0,totalPages:n?.projects.length?1:0}),[p,g]=h.useState(!!n),[x,b]=h.useState(!1),[j,C]=h.useState(!1),[T,N]=h.useState(""),[L,P]=h.useState(!1),[E,H]=h.useState(""),[S,O]=h.useState(!1),[ae,q]=h.useState(""),[R,_]=h.useState(null),[v,I]=h.useState(""),Q=h.useRef(null),[ce,pe]=h.useState(!1),[Y,ye]=h.useState(""),[W,ve]=h.useState(""),[ze,D]=h.useState(!1),[U,K]=h.useState(""),[V,te]=h.useState("blue"),[Qe,Kt]=h.useState(null),[Ot,Gt]=h.useState(null),[Jt,dn]=h.useState(""),[_t,Yt]=h.useState(null),[wt,Pt]=h.useState(""),[M,se]=h.useState(!1),[me,Ne]=h.useState(null),[oe,$e]=h.useState(null),[Ve,dt]=h.useState([]),[ut,Rt]=h.useState(""),[Te,ie]=h.useState(!1),[xt,nt]=h.useState(""),[Ke,st]=h.useState(()=>localStorage.getItem("texlite-project-view")==="list"?"list":"grid"),[Pe,ht]=h.useState(()=>localStorage.getItem("texlite-project-sort")==="created"?"created":"updated"),[re,Ge]=h.useState(!1),[nr,Be]=h.useState(""),[Re,be]=h.useState(1),[ms,bt]=h.useState(""),kn=h.useRef(0),we=h.useRef(null),sr=(w,ee,ne,je,Ue)=>`${w?"archived":"active"}|${ee}|${ne}|${je}|${Ue}`,gs=sr(re,Re,Y,W,Pe),Xt=(w,ee,ne,je,Ue)=>{const ke=new URLSearchParams({page:String(ee),pageSize:"20",sort:Ue});w&&ke.set("archived","1"),ne.trim()&&ke.set("search",ne.trim()),je&&ke.set("tag",je);const At=sr(w,ee,ne,je,Ue),hn=++kn.current;we.current?.abort();const xe=new AbortController;return we.current=xe,Promise.all([A(`/api/projects?${ke.toString()}`,{signal:xe.signal}),A("/api/tags",{signal:xe.signal})]).then(([Ft,ji])=>{hn===kn.current&&(l(Ft.projects),f(ji.tags),m(Ft.pagination),be(Ft.pagination.page),g(!0),bt(At))}).catch(Ft=>{!zn(Ft)&&hn===kn.current&&N(B(Ft))}).finally(()=>{we.current===xe&&(we.current=null)})};h.useEffect(()=>(Xt(re,Re,Y,W,Pe),()=>we.current?.abort()),[re,Re,Y,W,Pe]),h.useEffect(()=>{p&&!re&&ms===gs&&s(c,d,u)},[c,d,u,p,ms,gs,re]);const rr=w=>{st(w),localStorage.setItem("texlite-project-view",w)},bi=w=>{ht(w),be(1),localStorage.setItem("texlite-project-sort",w)},ir=w=>{Ge(w),be(1)},ys=w=>{ve(w),be(1)},or=async()=>{if(E.trim())try{const{project:w}=await A("/api/projects",{method:"POST",body:JSON.stringify({name:E})});P(!1),H("");const ee=re||Re!==1?c:[w,...c].slice(0,u.pageSize),ne=re?u:{...u,total:u.total+1,totalPages:Math.ceil((u.total+1)/u.pageSize)};l(ee),m(ne),re||s(ee,d,ne),i(w.id)}catch(w){N(B(w))}},ar=async()=>{if(!R)return;const w=t.maxUploadSizeMB??50;if(R.size>w*1024*1024)return I(a("errors.fileTooLarge",{size:w}));pe(!0),I("");const ee=new FormData;ee.append("file",R);try{const ne=await fetch(`/api/projects/import?name=${encodeURIComponent(ae.trim())}`,{method:"POST",body:ee}),je=await ne.json();if(!ne.ok)throw new Error(Ro(je,ne.status,"errors.upload"));const Ue=je.project,ke=re||Re!==1?c:[Ue,...c].slice(0,u.pageSize),At=re?u:{...u,total:u.total+1,totalPages:Math.ceil((u.total+1)/u.pageSize)};l(ke),m(At),re||s(ke,d,At),O(!1),_(null),q(""),i(Ue.id)}catch(ne){I(B(ne))}finally{pe(!1)}},Zt=w=>{if(w&&!w.name.toLocaleLowerCase().endsWith(".zip")){I(a("errors.zipOnly"));return}I(""),_(w),w&&!ae&&q(w.name.replace(/\.zip$/i,""))},cr=async()=>{await A("/api/auth/logout",{method:"POST"}),r(null)},vi=async()=>{if(U.trim())try{const w=await A("/api/tags",{method:"POST",body:JSON.stringify({name:U,color:V})});f(ee=>[...ee,w.tag].sort((ne,je)=>ne.name.localeCompare(je.name))),D(!1),K(""),te("blue")}catch(w){N(B(w))}},Lt=async w=>{if(!Qe)return;const ee=Qe.tags.some(ne=>ne.id===w.id);try{const je=(await A(ee?`/api/projects/${Qe.id}/tags/${w.id}`:`/api/projects/${Qe.id}/tags`,ee?{method:"DELETE"}:{method:"POST",body:JSON.stringify({tagId:w.id})})).project;Kt(je),l(Ue=>Ue.map(ke=>ke.id===je.id?je:ke))}catch(ne){N(B(ne))}},En=async()=>{if(!(!Ot||!Jt.trim()))try{const w=await A(`/api/projects/${Ot.id}`,{method:"PATCH",body:JSON.stringify({name:Jt})});l(ee=>ee.map(ne=>ne.id===w.project.id?w.project:ne)),Gt(null),dn("")}catch(w){N(B(w))}},Dn=async()=>{if(!(!_t||!wt.trim())){se(!0),N("");try{await A(`/api/projects/${_t.id}/duplicate`,{method:"POST",body:JSON.stringify({name:wt})}),Yt(null),Pt(""),Xt(re,Re,Y,W,Pe)}catch(w){N(B(w))}finally{se(!1)}}},ws=async()=>{if(me)try{await A(`/api/projects/${me.id}`,{method:"DELETE"}),l(Ue=>Ue.filter(ke=>ke.id!==me.id));const w=Math.max(0,u.total-1),ee=Math.ceil(w/u.pageSize),ne=ee===0?1:Math.min(Re,ee),je={...u,page:ne,total:w,totalPages:ee};m(je),Ne(null),ne!==Re?be(ne):Xt(re,Re,Y,W,Pe)}catch(w){N(B(w))}},xs=async w=>{$e(w),Rt(""),dt([]),nt(""),ie(!0);try{const ee=await A("/api/users");dt(ee.users.filter(ne=>ne.id!==w.ownerId))}catch(ee){nt(B(ee))}finally{ie(!1)}},lr=async()=>{if(!(!oe||!ut)){ie(!0),nt("");try{await A(`/api/projects/${oe.id}/owner`,{method:"PUT",body:JSON.stringify({userId:ut})}),$e(null),Rt(""),Xt(re,Re,Y,W,Pe)}catch(w){nt(B(w))}finally{ie(!1)}}},un=async w=>{const ee=!re;Be(w.id),N("");try{await A(`/api/projects/${w.id}/archive`,{method:ee?"PUT":"DELETE"});const ne=c.filter(hn=>hn.id!==w.id);l(ne);const je=Math.max(0,u.total-1),Ue=Math.ceil(je/u.pageSize),ke=Ue===0?1:Math.min(Re,Ue),At={...u,page:ke,total:je,totalPages:Ue};m(At),re||s(ne,d,At),ke!==Re?be(ke):Xt(re,Re,Y,W,Pe)}catch(ne){N(B(ne))}finally{Be("")}},bs=c,Si=["red","orange","yellow","green","blue","purple","gray"],vs=w=>new Date(w).toLocaleString(ge.resolvedLanguage);return o.jsxs("div",{className:"page",children:[o.jsxs("header",{className:"topbar",children:[o.jsx("span",{className:"site-title",children:t.siteName}),o.jsx(xi,{siteName:t.siteName}),o.jsxs("div",{className:"top-actions",children:[e.role==="admin"&&o.jsxs(o.Fragment,{children:[o.jsxs("button",{className:"ghost",onClick:()=>C(!0),children:[o.jsx(em,{"aria-hidden":!0,size:14}),a("metrics.title")]}),o.jsxs("button",{className:"ghost",onClick:()=>b(!x),children:[x?o.jsx(td,{"aria-hidden":!0,size:14}):o.jsx(Fs,{"aria-hidden":!0,size:14}),a(x?"users.back":"users.manage")]})]}),o.jsx(Bo,{compact:!0}),o.jsxs("span",{className:"top-user-identity",children:[o.jsx("strong",{children:e.displayName}),o.jsxs("small",{children:["@",e.username]})]}),o.jsx("button",{className:"ghost",onClick:cr,children:a("auth.logout")})]})]}),x?o.jsx(Cb,{currentUser:e}):o.jsxs("main",{className:"dashboard",children:[o.jsxs("div",{className:"section-title",children:[o.jsxs("div",{children:[o.jsxs("h1",{children:[o.jsx(zr,{"aria-hidden":!0,size:25}),a("projects.title")]}),o.jsx("p",{className:"muted",children:e.canCreateProjects?a("projects.subtitle"):a("projects.restricted")})]}),o.jsxs("div",{className:"section-actions",children:[o.jsxs("button",{onClick:()=>D(!0),children:[o.jsx(wc,{"aria-hidden":!0,size:15}),a("tags.create")]}),e.canCreateProjects&&o.jsxs(o.Fragment,{children:[o.jsxs("button",{onClick:()=>{I(""),O(!0)},children:[o.jsx(Br,{"aria-hidden":!0,size:15}),a("projects.upload")]}),o.jsxs("button",{className:"primary",onClick:()=>P(!0),children:[o.jsx(id,{"aria-hidden":!0,size:15}),a("projects.new")]})]})]})]}),T&&o.jsx("p",{className:"error",children:T}),o.jsxs("div",{className:"project-toolbar",children:[o.jsx("input",{type:"search",placeholder:a("projects.search"),value:Y,onChange:w=>{ye(w.target.value),be(1)}}),o.jsxs("div",{className:"project-scope",role:"tablist","aria-label":a("projects.scope"),children:[o.jsxs("button",{className:re?"":"active",onClick:()=>ir(!1),role:"tab","aria-selected":!re,children:[o.jsx(zr,{size:14}),a("projects.active")]}),o.jsxs("button",{className:re?"active":"",onClick:()=>ir(!0),role:"tab","aria-selected":re,children:[o.jsx(pc,{size:14}),a("projects.archived")]})]}),o.jsxs("div",{className:"tag-filters",children:[o.jsx("button",{className:W?"":"active",onClick:()=>ys(""),children:a("projects.allTags")}),d.map(w=>o.jsxs("button",{className:W===w.id?"active":"",onClick:()=>ys(W===w.id?"":w.id),children:[o.jsx(so,{color:w.color}),w.name]},w.id))]}),o.jsxs("label",{className:"project-sort",children:[o.jsx(nm,{size:14}),o.jsx("span",{children:a("projects.sortBy")}),o.jsxs("select",{value:Pe,onChange:w=>bi(w.target.value),children:[o.jsx("option",{value:"updated",children:a("projects.sortModified")}),o.jsx("option",{value:"created",children:a("projects.sortCreated")})]})]}),o.jsxs("div",{className:"view-toggle",children:[o.jsx("button",{className:Ke==="grid"?"active":"",onClick:()=>rr("grid"),title:a("projects.grid"),children:"▦"}),o.jsx("button",{className:Ke==="list"?"active":"",onClick:()=>rr("list"),title:a("projects.list"),children:"☷"})]})]}),o.jsxs("div",{className:`project-grid ${Ke==="list"?"list-view":""}`,children:[bs.map(w=>o.jsxs("article",{className:`project-card${w.ownerId===e.id?" owned-project":""}`,children:[Ke==="grid"&&w.ownerId===e.id&&o.jsxs("button",{className:"project-transfer-action",title:a("projects.transferOwnership"),onClick:()=>{xs(w)},children:[o.jsx($i,{"aria-hidden":!0,size:13}),a("projects.transfer")]}),o.jsxs("button",{className:"project-card-open",onClick:()=>i(w.id),children:[o.jsx("span",{className:"owner-badge",title:w.ownerDisplayName??w.ownerUsername,children:w.ownerDisplayName??w.ownerUsername}),o.jsxs("span",{className:"project-card-main",children:[o.jsx("strong",{children:w.name}),o.jsx("span",{className:"project-tags",children:w.tags?.map(ee=>o.jsx("span",{className:`tag tag-${ee.color}`,children:ee.name},ee.id))})]}),o.jsxs("dl",{className:"project-meta",children:[o.jsxs("div",{children:[o.jsxs("dt",{children:[o.jsx(sm,{"aria-hidden":!0,size:13}),a("projects.created")]}),o.jsx("dd",{children:o.jsx("time",{dateTime:w.createdAt,children:vs(w.createdAt)})})]}),o.jsxs("div",{children:[o.jsxs("dt",{children:[o.jsx(od,{"aria-hidden":!0,size:13}),a("projects.modified")]}),o.jsxs("dd",{title:a("projects.modifiedByUser",{time:vs(w.updatedAt),user:w.lastModifiedDisplayName??w.lastModifiedUsername??a("projects.deletedUser")}),children:[o.jsx("time",{dateTime:w.updatedAt,children:vs(w.updatedAt)}),o.jsxs("span",{className:"project-modified-by",children:[" · ",a("projects.byUser",{user:w.lastModifiedDisplayName??w.lastModifiedUsername??a("projects.deletedUser")})]})]})]})]})]}),o.jsxs("div",{className:"project-card-actions",children:[o.jsxs("button",{onClick:()=>Kt(w),children:[o.jsx(wc,{"aria-hidden":!0,size:14}),a("tags.assign")]}),w.permission==="owner"&&o.jsxs("button",{onClick:()=>{Gt(w),dn(w.name)},children:[o.jsx(yo,{"aria-hidden":!0,size:14}),a("projects.rename")]}),(e.role==="admin"||e.canCreateProjects)&&o.jsxs("button",{onClick:()=>{Yt(w),Pt(`${w.name} (1)`)},children:[o.jsx(cm,{"aria-hidden":!0,size:14}),a("projects.duplicate")]}),o.jsxs("a",{href:`/api/projects/${w.id}/download`,download:!0,children:[o.jsx(Ur,{"aria-hidden":!0,size:14}),a("projects.download")]}),o.jsxs("button",{disabled:nr===w.id,onClick:()=>{un(w)},children:[re?o.jsx(tm,{"aria-hidden":!0,size:14}):o.jsx(pc,{"aria-hidden":!0,size:14}),a(re?"projects.unarchive":"projects.archive")]}),Ke==="list"&&w.ownerId===e.id&&o.jsxs("button",{onClick:()=>{xs(w)},children:[o.jsx($i,{"aria-hidden":!0,size:14}),a("projects.transfer")]}),w.permission==="owner"&&o.jsxs("button",{className:"danger-text",onClick:()=>Ne(w),children:[o.jsx(Qn,{"aria-hidden":!0,size:14}),a("common.delete")]})]})]},w.id)),bs.length===0&&(c.length===0?re?o.jsx("div",{className:"empty",children:a("projects.noArchived")}):o.jsxs("div",{className:"project-empty",children:[o.jsx("span",{className:"project-empty-icon",children:o.jsx(Em,{size:28})}),o.jsx("h2",{children:a("projects.emptyTitle")}),o.jsx("p",{children:e.canCreateProjects?a("projects.emptyDescription"):a("projects.emptyRestricted")})]}):o.jsx("div",{className:"empty",children:a("projects.noMatches")}))]}),u.totalPages>1&&o.jsxs("nav",{className:"project-pagination","aria-label":a("projects.pagination"),children:[o.jsxs("button",{disabled:u.page<=1,onClick:()=>be(w=>Math.max(1,w-1)),title:a("projects.previousPage"),children:[o.jsx(rd,{size:15}),a("projects.previousPage")]}),o.jsx("span",{children:a("projects.pageOf",{page:u.page,totalPages:u.totalPages,count:u.total})}),o.jsxs("button",{disabled:u.page>=u.totalPages,onClick:()=>be(w=>Math.min(u.totalPages,w+1)),title:a("projects.nextPage"),children:[o.jsx(Ho,{size:15}),a("projects.nextPage")]})]}),o.jsx(Fe,{open:L,title:a("projects.new"),description:a("projects.newDescription"),onOpenChange:P,footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>P(!1),children:a("common.cancel")}),o.jsx("button",{className:"primary",onClick:()=>{or()},children:a("common.create")})]}),children:o.jsxs("label",{className:"form-field",children:[a("projects.name"),o.jsx("input",{autoFocus:!0,value:E,onChange:w=>H(w.target.value),onKeyDown:w=>{w.key==="Enter"&&or()}})]})}),o.jsx(Fe,{open:S,title:a("projects.upload"),description:a("projects.uploadDescription",{size:t.maxUploadSizeMB??50}),onOpenChange:w=>{O(w),w||I("")},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>{O(!1),I("")},children:a("common.cancel")}),o.jsx("button",{className:"primary",disabled:!R||ce,onClick:()=>{ar()},children:a(ce?"projects.importing":"projects.import")})]}),children:o.jsxs("div",{className:"form-stack",children:[v&&o.jsx("p",{className:"error import-error",children:v}),o.jsxs("div",{className:`upload-picker${R?" has-file":""}`,onDragOver:w=>{w.preventDefault(),w.dataTransfer.dropEffect="copy"},onDrop:w=>{w.preventDefault(),Zt(w.dataTransfer.files[0]??null)},children:[o.jsx("input",{ref:Q,className:"sr-only",type:"file",accept:".zip,application/zip",onChange:w=>Zt(w.target.files?.[0]??null)}),o.jsx(go,{size:34}),o.jsxs("div",{className:"upload-picker-copy",children:[o.jsx("strong",{children:R?.name??a("projects.chooseZip")}),o.jsx("span",{children:R?a("projects.selectedFileSize",{size:Ku(R.size)}):a("projects.dropZip")})]}),o.jsxs("button",{type:"button",onClick:()=>Q.current?.click(),children:[o.jsx(Br,{size:15}),a("projects.browse")]}),R&&o.jsx("button",{className:"upload-clear",type:"button",title:a("projects.clearFile"),"aria-label":a("projects.clearFile"),onClick:()=>{Zt(null),Q.current&&(Q.current.value="")},children:o.jsx(Wo,{size:14})})]}),o.jsxs("label",{className:"form-field",children:[a("projects.name"),o.jsx("input",{value:ae,onChange:w=>q(w.target.value)})]})]})}),o.jsx(Fe,{open:ze,title:a("tags.create"),description:a("tags.createDescription"),onOpenChange:D,footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>D(!1),children:a("common.cancel")}),o.jsx("button",{className:"primary",onClick:()=>{vi()},children:a("common.create")})]}),children:o.jsxs("div",{className:"form-stack",children:[o.jsxs("label",{className:"form-field",children:[a("tags.name"),o.jsx("input",{autoFocus:!0,value:U,onChange:w=>K(w.target.value)})]}),o.jsxs("fieldset",{className:"color-picker",children:[o.jsx("legend",{children:a("tags.color")}),Si.map(w=>o.jsxs("label",{className:V===w?"active":"",children:[o.jsx("input",{type:"radio",name:"dashboard-tag-color",checked:V===w,onChange:()=>te(w)}),o.jsx(so,{color:w}),a(`tags.${w}`)]},w))]})]})}),o.jsx(Fe,{open:!!Qe,title:a("tags.assignTitle",{project:Qe?.name??""}),description:a("tags.assignDescription"),onOpenChange:w=>{w||Kt(null)},footer:o.jsx("button",{onClick:()=>Kt(null),children:a("common.close")}),children:o.jsxs("div",{className:"tag-assignment-list",children:[d.map(w=>o.jsxs("label",{children:[o.jsx("input",{type:"checkbox",checked:!!Qe?.tags.some(ee=>ee.id===w.id),onChange:()=>{Lt(w)}}),o.jsx(so,{color:w.color}),o.jsx("span",{children:w.name})]},w.id)),d.length===0&&o.jsx("p",{className:"muted",children:a("tags.empty")})]})}),o.jsx(Fe,{open:!!Ot,title:a("projects.renameTitle"),onOpenChange:w=>{w||Gt(null)},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>Gt(null),children:a("common.cancel")}),o.jsx("button",{className:"primary",onClick:()=>{En()},children:a("projects.rename")})]}),children:o.jsxs("label",{className:"form-field",children:[a("projects.name"),o.jsx("input",{autoFocus:!0,value:Jt,onChange:w=>dn(w.target.value),onKeyDown:w=>{w.key==="Enter"&&En()}})]})}),o.jsx(Fe,{open:!!_t,title:a("projects.duplicateTitle"),description:a("projects.duplicateDescription",{project:_t?.name??""}),onOpenChange:w=>{!w&&!M&&(Yt(null),Pt(""))},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{disabled:M,onClick:()=>{Yt(null),Pt("")},children:a("common.cancel")}),o.jsx("button",{className:"primary",disabled:M||!wt.trim(),onClick:()=>{Dn()},children:a(M?"projects.duplicating":"projects.duplicate")})]}),children:o.jsxs("label",{className:"form-field",children:[a("projects.name"),o.jsx("input",{autoFocus:!0,value:wt,onChange:w=>Pt(w.target.value),onKeyDown:w=>{w.key==="Enter"&&Dn()}})]})}),o.jsx(Fe,{open:!!oe,title:a("projects.transferOwnership"),description:a("projects.transferDescription",{project:oe?.name??""}),onOpenChange:w=>{!w&&!Te&&($e(null),Rt(""),nt(""))},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{disabled:Te,onClick:()=>{$e(null),Rt(""),nt("")},children:a("common.cancel")}),o.jsxs("button",{className:"primary",disabled:Te||!ut,onClick:()=>{lr()},children:[Te?o.jsx(pn,{className:"spin",size:14}):o.jsx($i,{size:14}),a("projects.transfer")]})]}),children:o.jsxs("div",{className:"form-stack",children:[xt&&o.jsx("p",{className:"error dialog-error",children:xt}),o.jsxs("label",{className:"form-field",children:[a("projects.newOwner"),o.jsxs("select",{disabled:Te||Ve.length===0,value:ut,onChange:w=>Rt(w.target.value),children:[o.jsx("option",{value:"",children:Te?a("common.loading"):Ve.length>0?a("projects.chooseNewOwner"):a("projects.noTransferUsers")}),Ve.map(w=>o.jsxs("option",{value:w.id,children:[w.displayName??w.username," (@",w.username,")"]},w.id))]})]}),o.jsxs("p",{className:"warning",children:[o.jsx(As,{size:15}),a("projects.transferWarning")]})]})}),o.jsx(Ls,{open:!!me,title:a("projects.deleteTitle"),description:a("projects.deleteDescription",{project:me?.name??""}),confirmLabel:a("common.delete"),danger:!0,onCancel:()=>Ne(null),onConfirm:()=>{ws()}})]}),j&&o.jsx(h.Suspense,{fallback:null,children:o.jsx(wb,{open:!0,onOpenChange:C})}),o.jsx(Ea,{})]})}function so({color:t}){return o.jsx("span",{className:`tag-dot tag-${t}`})}function jb(t=10){const e="ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789!@#$%",n=crypto.getRandomValues(new Uint8Array(t));return Array.from(n,s=>e[s%e.length]).join("")}function Cb({currentUser:t}){const{t:e}=_e(),[n,s]=h.useState([]),[r,i]=h.useState(""),[a,c]=h.useState(!1),[l,d]=h.useState({username:"",displayName:"",password:"",role:"user",canCreateProjects:!1}),[f,u]=h.useState(null),[m,p]=h.useState(""),[g,x]=h.useState(null),[b,j]=h.useState(!1),C=()=>A("/api/admin/users").then(({users:S})=>s(S)).catch(S=>i(B(S)));h.useEffect(()=>{C()},[]);const T=async()=>{if(l.password.length<Ye)return i(e("auth.passwordMinimum",{count:Ye}));try{await A("/api/admin/users",{method:"POST",body:JSON.stringify({username:l.username,displayName:l.displayName||l.username,password:l.password,role:l.role,canCreateProjects:l.canCreateProjects})}),c(!1),d({username:"",displayName:"",password:"",role:"user",canCreateProjects:!1}),await C()}catch(S){i(B(S))}},N=async S=>{try{await A(`/api/admin/users/${S.id}`,{method:"PATCH",body:JSON.stringify({disabled:!S.disabled})}),await C()}catch(O){i(B(O))}},L=async S=>{try{await A(`/api/admin/users/${S.id}`,{method:"PATCH",body:JSON.stringify({role:S.role==="admin"?"user":"admin"})}),await C()}catch(O){i(B(O))}},P=async S=>{try{await A(`/api/admin/users/${S.id}`,{method:"PATCH",body:JSON.stringify({canCreateProjects:!S.canCreateProjects})}),await C()}catch(O){i(B(O))}},E=async()=>{if(!(!f||!m)){if(m.length<Ye)return i(e("auth.passwordMinimum",{count:Ye}));try{await A(`/api/admin/users/${f.id}`,{method:"PATCH",body:JSON.stringify({password:m})}),u(null),p("")}catch(S){i(B(S))}}},H=async()=>{if(g)try{await A(`/api/admin/users/${g.id}`,{method:"DELETE",body:JSON.stringify({deleteProjects:b})}),x(null),j(!1),await C()}catch(S){i(B(S))}};return o.jsxs("main",{className:"dashboard",children:[o.jsxs("div",{className:"section-title",children:[o.jsxs("div",{children:[o.jsxs("h1",{children:[o.jsx(Fs,{"aria-hidden":!0,size:25}),e("users.manage")]}),o.jsx("p",{className:"muted",children:e("users.onlyAdmin")})]}),o.jsxs("button",{className:"primary icon-button",onClick:()=>c(!0),children:[o.jsx(ld,{"aria-hidden":!0,size:15}),e("users.add")]})]}),r&&o.jsx("p",{className:"error",children:r}),o.jsx("div",{className:"table-card",children:o.jsxs("table",{children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{children:e("common.user")}),o.jsx("th",{children:e("users.role")}),o.jsx("th",{children:e("users.createProjects")}),o.jsx("th",{children:e("users.ownedProjects")}),o.jsx("th",{children:e("users.status")}),o.jsx("th",{children:e("users.actions")})]})}),o.jsx("tbody",{children:n.map(S=>o.jsxs("tr",{children:[o.jsxs("td",{children:[o.jsx("strong",{children:S.displayName}),o.jsxs("small",{children:["@",S.username]})]}),o.jsx("td",{children:S.role==="admin"?e("common.admin"):e("common.user")}),o.jsx("td",{children:S.canCreateProjects?e("users.allow"):e("users.deny")}),o.jsx("td",{children:S.ownedProjects}),o.jsx("td",{children:S.disabled?e("common.disabled"):e("common.normal")}),o.jsxs("td",{children:[o.jsx("button",{disabled:S.id===t.id,onClick:()=>N(S),children:S.disabled?e("users.enable"):e("users.disable")}),o.jsx("button",{disabled:S.id===t.id,onClick:()=>L(S),children:S.role==="admin"?e("users.demote"):e("users.promote")}),o.jsx("button",{disabled:S.role==="admin",onClick:()=>P(S),children:S.canCreateProjects?e("users.denyCreate"):e("users.allowCreate")}),o.jsx("button",{onClick:()=>{u(S),p("")},children:e("users.resetPassword")}),o.jsx("button",{className:"danger-text",disabled:S.id===t.id,onClick:()=>{x(S),j(!1)},children:e("common.delete")})]})]},S.id))})]})}),o.jsx(Fe,{open:a,title:e("users.add"),description:e("users.addDescription"),onOpenChange:c,footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>c(!1),children:e("common.cancel")}),o.jsx("button",{className:"primary",disabled:l.password.length<Ye,onClick:()=>{T()},children:e("users.createUser")})]}),children:o.jsxs("div",{className:"form-stack",children:[o.jsxs("label",{className:"form-field",children:[e("auth.username"),o.jsx("input",{value:l.username,onChange:S=>d({...l,username:S.target.value})})]}),o.jsxs("label",{className:"form-field",children:[e("users.displayName"),o.jsx("input",{value:l.displayName,onChange:S=>d({...l,displayName:S.target.value})})]}),o.jsxs("label",{className:"form-field",children:[e("users.initialPassword"),o.jsxs("span",{className:"password-generator",children:[o.jsx("input",{minLength:Ye,autoComplete:"new-password",value:l.password,onChange:S=>d({...l,password:S.target.value})}),o.jsxs("button",{type:"button",title:e("users.generatePassword"),onClick:()=>d({...l,password:jb()}),children:[o.jsx(lm,{size:15}),e("users.randomPassword")]})]}),o.jsx("small",{className:"field-hint",children:e("auth.passwordMinimum",{count:Ye})})]}),o.jsxs("label",{className:"form-field",children:[e("users.role"),o.jsxs("select",{value:l.role,onChange:S=>d({...l,role:S.target.value}),children:[o.jsx("option",{value:"user",children:e("common.user")}),o.jsx("option",{value:"admin",children:e("common.admin")})]})]}),o.jsxs("label",{className:"checkbox-field",children:[o.jsx("input",{type:"checkbox",checked:l.canCreateProjects||l.role==="admin",disabled:l.role==="admin",onChange:S=>d({...l,canCreateProjects:S.target.checked})})," ",e("users.allowCreate")]})]})}),o.jsx(Fe,{open:!!f,title:e("users.resetPassword"),description:e("users.resetDescription",{username:f?.username??""}),onOpenChange:S=>{S||u(null)},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>u(null),children:e("common.cancel")}),o.jsx("button",{className:"primary",disabled:m.length<Ye,onClick:()=>{E()},children:e("users.reset")})]}),children:o.jsxs("label",{className:"form-field",children:[e("auth.newPassword"),o.jsx("input",{autoFocus:!0,type:"password",minLength:Ye,autoComplete:"new-password",value:m,onChange:S=>p(S.target.value)}),o.jsx("small",{className:"field-hint",children:e("auth.passwordMinimum",{count:Ye})})]})}),o.jsx(Fe,{open:!!g,title:e("users.deleteTitle"),description:e("users.deleteDescription",{username:g?.username??""}),onOpenChange:S=>{S||x(null)},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>x(null),children:e("common.cancel")}),o.jsx("button",{className:"danger",onClick:()=>{H()},children:e("users.deleteTitle")})]}),children:o.jsxs("fieldset",{className:"choice-group",children:[o.jsx("legend",{children:e("users.ownedChoice",{count:g?.ownedProjects??0})}),o.jsxs("label",{children:[o.jsx("input",{type:"radio",checked:!b,onChange:()=>j(!1)})," ",e("users.transferProjects")]}),o.jsxs("label",{children:[o.jsx("input",{type:"radio",checked:b,onChange:()=>j(!0)})," ",e("users.deleteProjects")]})]})})]})}function kb({site:t,user:e,projectId:n,onBack:s}){const{t:r}=_e(),[i,a]=h.useState(null),[c,l]=h.useState([]),[d,f]=h.useState(null),[u,m]=h.useState([]),[p,g]=h.useState(""),[x,b]=h.useState(""),[j,C]=h.useState(new Set),[T,N]=h.useState(""),[L,P]=h.useState(""),[E,H]=h.useState(!1),[S,O]=h.useState("editor.saved"),[ae,q]=h.useState(null),[R,_]=h.useState({line:1,column:1}),[v,I]=h.useState("pdf"),{workspaceLayout:Q,setWorkspaceLayout:ce}=ub(e.id,n),[pe,Y]=h.useState(""),[ye,W]=h.useState(""),[ve,ze]=h.useState({selectedText:"",startOffset:0,endOffset:0}),D=h.useRef({selectedText:"",startOffset:0,endOffset:0}),U=y=>{D.current=y,ze(y)},[K,V]=h.useState(null),[te,Qe]=h.useState(!1),[Kt,Ot]=h.useState(!1),[Gt,Jt]=h.useState(!1),[dn,_t]=h.useState(!1),[Yt,wt]=h.useState(!1),[Pt,M]=h.useState(!1),[se,me]=h.useState(!1),[Ne,oe]=h.useState(()=>bc(e.id,n)),$e=h.useRef(null),Ve=h.useRef(null),dt=h.useRef(0),ut=h.useRef(0),Rt=h.useRef(""),Te=h.useRef(""),ie=h.useRef(""),xt=h.useRef(""),nt=h.useRef(0),Ke=h.useRef(null),st=h.useRef(null),Pe=h.useRef(null),ht=h.useRef(null),re=h.useRef(!1),Ge=h.useRef(null),nr=h.useRef(s);nr.current=s,ie.current=x;const{collaboration:Be,status:Re,synced:be,activeSessions:ms,compileState:bt,setCompileState:kn,filesEvent:we,commentsRevision:sr,dictionaryRevision:gs,localDraftReady:Xt,reconnect:rr}=sb(n,e,x,()=>O("editor.offlineDraft")),{pdfTarget:bi,pdfViewport:ir,sourceJump:ys,setPdfViewport:or,clearPdfViewport:ar,jumpToSource:Zt,syncSourceToPdf:cr,syncVisiblePdfToSource:vi}=db({projectId:n,mainFile:x,activeFile:p,onActiveFile:g,onError:Y,onShowPdf:()=>I("pdf")}),Lt=lb({active:!!(i&&p&&be&&Ne.spellCheck),activeFile:p,content:T,dictionaryWords:c});h.useEffect(()=>{oe(bc(e.id,n))},[e.id,n]);const En=y=>{Rt.current=y,N(y)};h.useEffect(()=>{Te.current=p,U({selectedText:"",startOffset:0,endOffset:0})},[p]),h.useEffect(()=>{if(!E)return;const y=k=>{k.preventDefault(),k.returnValue=""};return window.addEventListener("beforeunload",y),()=>window.removeEventListener("beforeunload",y)},[E]),h.useEffect(()=>{if(Re!=="disconnected")return;const y=new AbortController;return A(`/api/projects/${n}`,{signal:y.signal}).then(({project:k})=>{y.signal.aborted||(a(k),Y(""))}).catch(k=>{if(!zn(k)){if(k instanceof Po&&[401,403,404].includes(k.status)){Y(B(k)),nr.current();return}Y(r("errors.collaborationUnavailable"))}}),()=>y.abort()},[Re,n,r]);const Dn=async(y={})=>{Ke.current?.abort(),Ke.current=null;const k=y.signal?null:new AbortController;k&&(Ke.current=k);try{const z=await A(`/api/projects/${n}/completions`,{signal:y.signal??k?.signal});(!y.isCurrent||y.isCurrent())&&f(z.index)}catch(z){if(zn(z))return;(!y.isCurrent||y.isCurrent())&&f(null)}finally{k&&Ke.current===k&&(Ke.current=null)}},ws=async(y={},k=ie.current)=>{st.current?.abort(),st.current=null;const z=y.signal?null:new AbortController;z&&(st.current=z);try{const X=k?`?mainFile=${encodeURIComponent(k)}`:"",ue=await A(`/api/projects/${n}/outline${X}`,{signal:y.signal??z?.signal});(!y.isCurrent||y.isCurrent())&&m(ue.outline)}catch(X){!zn(X)&&(!y.isCurrent||y.isCurrent())&&m([])}finally{z&&st.current===z&&(st.current=null)}},xs=async(y={})=>{Pe.current?.abort(),Pe.current=null;const k=y.signal?null:new AbortController;k&&(Pe.current=k);try{const z=await A(`/api/projects/${n}/dictionary`,{signal:y.signal??k?.signal});(!y.isCurrent||y.isCurrent())&&l(z.words)}catch(z){if(zn(z))return;(!y.isCurrent||y.isCurrent())&&l([])}finally{k&&Pe.current===k&&(Pe.current=null)}};h.useEffect(()=>{let y=!1;const k=++nt.current,z=new AbortController,X=()=>!y&&nt.current===k;let ue=!1;xt.current="",a(null),ne([]),m([]),g(""),b(""),C(new Set),N(""),P(""),kn(null),ar(),f(null),l([]),Wu();const Je=A(`/api/projects/${n}`,{signal:z.signal}).then(He=>{X()&&(ue=!0,a(He.project),g(He.project.mainFile),b(He.project.mainFile),C(new Set([He.project.mainFile])),Na(new Set(Ns(He.project.mainFile))))}).catch(He=>{X()&&Y(B(He))}),le=A(`/api/projects/${n}/files`,{signal:z.signal}).then(He=>{X()&&ne(He.files)}).catch(He=>{X()&&Y(B(He))});return Promise.allSettled([Je,le]).then(()=>{!X()||!ue||window.setTimeout(()=>{X()&&Promise.all([Dn({signal:z.signal,isCurrent:X}),xs({signal:z.signal,isCurrent:X})])},0)}),()=>{y=!0,z.abort(),Ke.current?.abort(),Ke.current=null,st.current?.abort(),st.current=null,Pe.current?.abort(),Pe.current=null,ht.current?.abort(),ht.current=null}},[n]),h.useEffect(()=>{gs&&xs()},[gs,n]),h.useEffect(()=>{i&&Be.setPermission(i.permission)},[Be,i?.permission]),h.useEffect(()=>{if(!we)return;const y=we.kind==="delete"&&!!we.path&&In(we.path,Te.current),k=we.kind==="delete"&&!!we.path&&In(we.path,ie.current);if(we.kind==="move"&&we.source&&we.destination){const X=we.source,ue=we.destination,Je=le=>le===X?ue:le.startsWith(`${X}/`)?`${ue}${le.slice(X.length)}`:le;g(le=>Je(le)),b(le=>Je(le)),C(le=>new Set([...le].map(Je))),dr(le=>le&&Je(le))}y&&(g(""),P(""),En(""),W(r("editor.fileDeletedByCollaborator",{path:we.path}))),we.kind==="delete"&&we.path&&(C(X=>new Set([...X].filter(ue=>!In(we.path,ue)))),dr(X=>In(we.path,X)?"":X),Ft(X=>X&&In(we.path,X.path)?null:X)),ht.current?.abort();const z=new AbortController;ht.current=z,Promise.all([je({signal:z.signal}),A(`/api/projects/${n}`,{signal:z.signal})]).then(([X,ue])=>{if(a(ue.project),k&&b(ue.project.mainFile),y&&X){const Je=X.find(le=>le.type==="file"&&le.path===ue.project.mainFile)??X.find(le=>le.type==="file"&&_o(le.path));g(Je?.path??"")}Dn({signal:z.signal}),ws({signal:z.signal},k?ue.project.mainFile:ie.current)}).catch(X=>{zn(X)}).finally(()=>{ht.current===z&&(ht.current=null)})},[we?.revision]),h.useEffect(()=>{if(Be.setActiveFile(p),!p)return;P(""),O("editor.loading");const y=Be.getText(p),k=(z,X)=>{En(y.toString()),P(p),X?.local&&i?.permission!=="read"?(dt.current+=1,H(!0),O("editor.pending")):dt.current<=ut.current&&O(ae?"editor.savedAt":"editor.saved")};return y.observe(k),(be||Xt)&&k(),()=>{y.unobserve(k)}},[p,Be,be,Xt,i?.permission]),h.useEffect(()=>{!p||L!==p||xt.current===p||(xt.current=p,!(!p.toLocaleLowerCase().endsWith(".tex")||!Eb(T))&&(C(y=>new Set([...y,p])),b(p)))},[p,L,T]);const lr=async()=>{if(!be)throw new Error("Collaboration is not synchronized");const y=dt.current,k=await Be.flush();return ut.current=Math.max(ut.current,y),q(k.persistedAt),/\.tex$/i.test(Te.current)&&ws(),dt.current===y?(H(!1),O("editor.savedAt")):O("editor.pending"),k};h.useEffect(()=>{if(!E||!p)return;if(!be){O("editor.offlineDraft");return}O("editor.pending");const y=window.setTimeout(()=>{O("editor.saving"),lr().catch(()=>{O(Be.connected?"editor.saveFailed":"editor.offlineDraft")})},750);return()=>window.clearTimeout(y)},[T,E,p,be]);const un=async()=>{if(!i||i.permission==="read"||!be||!p)return!1;O("editor.saving");try{return await lr(),Dn(),!0}catch{return O("editor.saveFailed"),Y(r("errors.collaborationUnavailable")),!1}},bs=async(y,k)=>(await A(`/api/projects/${n}/format`,{method:"POST",body:JSON.stringify({path:y,source:k})})).formatted,Si=async()=>{if(!Ne.formatOnCompile||!i||i.permission==="read"||!be||!zi(Te.current)||re.current)return;const y=Te.current,k=Be.getText(y),z=k.toString();re.current=!0,me(!0);try{const X=await bs(y,z),ue=await vc(z,X);if(Te.current!==y||k.toString()!==z)throw new Error(r("editor.formatSourceChanged"));ue.length&&Be.applyTextEdits(y,ue)}catch(X){Y(r("editor.formatFailedContinue",{message:B(X)}))}finally{re.current=!1,me(!1)}},vs=async()=>(Ge.current&&await Ge.current,await Si(),un()),w=async()=>{if(!i||i.permission==="read"||!be||re.current||!zi(Te.current))return;const y=D.current;if(!y.selectedText.trim()){W(r("editor.formatSelectionRequired"));return}const k=Te.current,{startOffset:z,endOffset:X,selectedText:ue}=y,Je=Be.getText(k);if(Je.toString().slice(z,X)!==ue){Y(r("editor.formatSelectionChanged"));return}re.current=!0,me(!0);let le=()=>{};const He=new Promise(vt=>{le=vt});Ge.current=He;try{const vt=Rm(ue,await bs(k,ue)),Ba=await vc(ue,vt,z);if(Te.current!==k||Je.toString().slice(z,X)!==ue){Y(r("editor.formatSelectionChanged"));return}Ba.length&&Be.applyTextEdits(k,Ba),Y(""),W(r("editor.formatSelectionComplete"))}catch(vt){Y(r("editor.formatFailed",{message:B(vt)}))}finally{re.current=!1,me(!1),le(),Ge.current===He&&(Ge.current=null)}},{files:ee,setFiles:ne,loadFiles:je,newFileOpen:Ue,setNewFileOpen:ke,newFilePath:At,setNewFilePath:hn,resourcePreview:xe,setResourcePreview:Ft,resourcePreviewLoading:ji,setResourcePreviewLoading:Gu,newFolderOpen:Ju,setNewFolderOpen:Ci,newFolderName:Yu,setNewFolderName:Da,fileDialogError:Qt,setFileDialogError:Nn,selectedFolder:It,setSelectedFolder:dr,expandedFolders:Xu,setExpandedFolders:Na,moveEntry:Ss,setMoveEntry:ur,moveDestination:Zu,setMoveDestination:ki,deleteEntry:Tn,setDeleteEntry:hr,fileDragActive:Ta,setFileDragActive:Ei,uploadConflict:Di,setUploadConflict:Oa,uploadingFiles:fr,directoryEntries:Qu,visibleEntries:eh,createFile:th,createFolder:_a,uploadFiles:Pa,upload:nh,openFile:Ra,movePath:sh,removePath:rh}=cb({projectId:n,site:t,activeFile:p,dirty:E,save:un,onError:Y,onProject:a,onActiveFile:g,onActiveMainFile:b,onRootDocuments:C}),{comments:js,focusComment:ih,setFocusComment:La,commentOpen:oh,setCommentOpen:Ni,commentText:ah,setCommentText:ch,addComment:lh,toggleComment:dh,replyToComment:uh,editComment:hh,deleteComment:fh,editCommentReply:ph,deleteCommentReply:mh}=tb({projectId:n,activeFile:p,permission:i?.permission,revision:sr,selection:ve,save:un,onError:Y,onAdded:()=>V("comments")}),{pdfUrl:pr,pdfCompiledAt:On,compileLog:mr,compileDiagnostics:gr,compileOutcome:yr,artifacts:Aa,artifactPreview:gh,artifactLoading:yh,editorNotice:Fa,localCompiling:Ti,compile:wh,viewArtifact:xh}=rb({projectId:n,project:i,mainFile:x,collaborationSynced:be,sharedState:bt,onSharedState:kn,save:vs,loadOutline:(y,k)=>ws({signal:y},k),onPreviewTab:I,onError:Y,onCompileStart:()=>{Y(""),W("")},onPdfChanged:ar});h.useEffect(()=>{const y=k=>{(k.ctrlKey||k.metaKey)&&(!k.shiftKey&&k.key.toLocaleLowerCase()==="p"?(k.preventDefault(),wt(!0)):k.shiftKey&&k.key.toLocaleLowerCase()==="f"&&(k.preventDefault(),M(!0)))};return window.addEventListener("keydown",y,!0),()=>window.removeEventListener("keydown",y,!0)},[]);const bh=y=>{oe(y),Om(e.id,n,y)},Ia=()=>{Ve.current?.isCollapsed()?Ve.current.expand():Ve.current?.collapse()},Ma=h.useMemo(()=>u.length?u:Db(T).map(y=>({...y,path:p})),[u,T,p]),wr=h.useMemo(()=>Lm(mr,yr),[mr,yr]),_n=Q!=="pdf-only",$a=Q!=="editor-only",xr=y=>{ce(y),y==="pdf-only"&&I("pdf")},Oi=Tn?ms.filter(y=>y.filePath&&In(Tn.path,y.filePath)):[];if(!i)return o.jsxs("div",{className:"center-card",children:[o.jsx("p",{children:pe||r("common.loading")}),pe&&o.jsx("button",{className:"primary",onClick:s,children:r("editor.backToProjects")})]});const Mt=i.permission==="read"||!be,br=bt?.mainFile===x&&(bt.status==="queued"||bt.status==="running"),Cs=Ti||br,Ua=p?Be.getText(p):null,za=On?new Date(On).toLocaleString(ge.resolvedLanguage,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"",vh=x.split("/").at(-1)??x,Va=Cs?br?bt?.status==="queued"?r("editor.compileQueued"):r("editor.compilingBy",{name:bt?.requestedBy.name??r("common.user")}):r("editor.compiling"):yr==="failed"?pr&&On?r("editor.compileFailedRetained",{time:new Date(On).toLocaleString(ge.resolvedLanguage)}):r("editor.compileFailedNoPdf"):"",Sh=S==="editor.savedAt"&&ae?r("editor.savedAt",{time:new Date(ae).toLocaleTimeString(ge.resolvedLanguage,{hour:"2-digit",minute:"2-digit",second:"2-digit"})}):r(S);return o.jsxs("div",{className:"workspace",children:[o.jsxs("header",{className:"editor-topbar",children:[o.jsx("button",{className:"back",title:r("editor.backToProjects"),"aria-label":r("editor.backToProjects"),onClick:s,children:o.jsx(td,{size:18})}),o.jsx(xi,{siteName:t.siteName,compact:!0}),o.jsxs("div",{className:"project-heading",children:[o.jsx("strong",{children:i.name}),o.jsxs("small",{children:[p," · ",Sh]})]}),Ne.vimMode&&o.jsxs("span",{className:"vim-status-badge",title:r("editor.vimOnHint"),children:[o.jsx(pm,{size:14}),r("editor.vimOn")]}),o.jsx(Wx,{sessions:ms,status:Re}),Re==="disconnected"&&o.jsxs("div",{className:"collaboration-recovery",role:"status",children:[o.jsx("span",{children:r("editor.collaboration.disconnected")}),o.jsx("button",{type:"button",onClick:rr,children:r("editor.collaboration.reconnect")})]}),o.jsxs("div",{className:"editor-actions",children:[_n&&o.jsxs("button",{className:te?"":"active",onClick:Ia,children:[te?o.jsx(wm,{size:15}):o.jsx(yc,{size:15}),r("common.files")]}),o.jsx(Kx,{value:Q,onChange:xr}),o.jsxs("button",{onClick:()=>_t(!0),children:[o.jsx(od,{size:15}),r("history.title")]}),o.jsxs("button",{onClick:()=>Ot(!0),children:[o.jsx(Fs,{size:15}),r("projectSettings.share")]}),i.ownerId===e.id&&o.jsxs("button",{onClick:()=>Jt(!0),children:[o.jsx(fm,{size:15}),"Git"]}),_n&&i.permission!=="read"&&zi(p)&&o.jsxs("button",{title:ve.selectedText.trim()?r("editor.formatSelection"):r("editor.formatSelectionHint"),onMouseDown:y=>y.preventDefault(),onClick:()=>{w()},disabled:Mt||se||!be,children:[se?o.jsx(pn,{className:"spin",size:15}):o.jsx(ed,{size:15}),r(se?"editor.formatting":"editor.formatSelection")]}),o.jsxs("button",{onClick:()=>Ni(!0),disabled:!p,children:[o.jsx(gm,{size:15}),r("editor.addComment")]}),o.jsxs("button",{className:K==="comments"?"active":"",onClick:()=>V(K==="comments"?null:"comments"),children:[o.jsx(ym,{size:15}),r("common.comments")," ",js.filter(y=>!y.resolved).length||""]}),o.jsxs("button",{className:K==="settings"?"active":"",onClick:()=>V(K==="settings"?null:"settings"),children:[o.jsx(Pr,{size:15}),r("common.settings")]}),o.jsxs("button",{className:"compile",title:br?r("editor.compilingBy",{name:bt?.requestedBy.name??""}):r("editor.compileShortcut"),onClick:wh,disabled:Cs||se||Mt||!be,children:[Cs?o.jsx(pn,{className:"spin",size:15}):o.jsx(vm,{size:15}),br?r("editor.compilingBy",{name:bt?.requestedBy.name??""}):Ti?r("editor.compiling"):r("editor.compile",{engine:i.engine})]})]})]}),Va&&o.jsxs("div",{className:`compile-status-strip${yr==="failed"?" failed":""}`,role:"status","aria-live":"polite",children:[o.jsx(pn,{className:Cs?"spin":"",size:14}),o.jsx("span",{children:Va})]}),pe&&o.jsx("div",{className:"toast",onClick:()=>Y(""),children:pe}),ye&&o.jsx("div",{className:"toast success",onClick:()=>W(""),children:ye}),o.jsxs(kh,{autoSaveId:"texlite-workspace-layout",direction:"horizontal",className:"work-grid",children:[_n&&o.jsx(vr,{id:"files",order:1,ref:Ve,defaultSize:16,minSize:12,maxSize:30,collapsible:!0,collapsedSize:0,onCollapse:()=>Qe(!0),onExpand:()=>Qe(!1),children:o.jsxs("aside",{className:"left-panel",children:[o.jsxs("section",{className:`files-panel${Ta?" drop-active":""}`,onDragEnter:y=>{y.dataTransfer.types.includes("Files")&&(y.preventDefault(),!Mt&&!fr&&Ei(!0))},onDragOver:y=>{y.dataTransfer.types.includes("Files")&&(y.preventDefault(),y.dataTransfer.dropEffect=Mt||fr?"none":"copy")},onDragLeave:y=>{y.currentTarget.contains(y.relatedTarget)||Ei(!1)},onDrop:y=>{y.preventDefault(),Ei(!1),!Mt&&!fr&&Pa(Array.from(y.dataTransfer.files))},children:[o.jsxs("div",{className:"panel-title",children:[o.jsxs("span",{children:[o.jsx(Vn,{size:14}),r("common.files")]}),o.jsxs("span",{className:"file-tools",children:[o.jsx("button",{"aria-label":r("navigation.quickOpen"),title:`${r("navigation.quickOpen")} (Ctrl/Cmd+P)`,onClick:()=>wt(!0),children:o.jsx(um,{size:15})}),o.jsx("button",{"aria-label":r("navigation.projectSearch"),title:`${r("navigation.projectSearch")} (Ctrl/Cmd+Shift+F)`,onClick:()=>M(!0),children:o.jsx(Cm,{size:15})}),!Mt&&o.jsxs(o.Fragment,{children:[o.jsx("button",{disabled:fr,"aria-label":r("editor.uploadAttachment"),title:r("editor.uploadTo",{folder:It||r("editor.projectRoot")}),onClick:()=>$e.current?.click(),children:o.jsx(Br,{size:15})}),o.jsx("button",{"aria-label":r("editor.newFolder"),title:r("editor.newFolder"),onClick:()=>{Da(""),Ci(!0)},children:o.jsx(id,{size:15})}),o.jsx("button",{"aria-label":r("editor.newFile"),title:r("editor.newFile"),onClick:()=>{hn(It?`${It}/`:""),ke(!0)},children:o.jsx(dm,{size:15})}),o.jsx("input",{ref:$e,type:"file",multiple:!0,hidden:!0,onChange:y=>{nh(y)}})]}),o.jsx("button",{"aria-label":r("editor.collapseFiles"),title:r("editor.collapseFiles"),onClick:Ia,children:o.jsx(yc,{size:15})})]})]}),Ta&&o.jsxs("div",{className:"file-drop-overlay",children:[o.jsx(Br,{size:24}),o.jsx("strong",{children:r("editor.dropFiles")}),o.jsx("span",{children:r("editor.uploadTo",{folder:It||r("editor.projectRoot")})})]}),o.jsxs("div",{className:"folder-target",title:It||r("editor.projectRoot"),children:[o.jsx(zr,{size:13}),o.jsx("span",{children:It||r("editor.projectRoot")})]}),o.jsxs("div",{className:"file-list",style:{fontSize:`${Ne.fontSize}px`},children:[o.jsx("div",{className:`file-entry folder-entry root-entry${It===""?" selected":""}`,children:o.jsxs("button",{className:"file-entry-main",onClick:()=>dr(""),children:[o.jsx(zr,{size:15}),o.jsx("span",{children:r("editor.projectRoot")})]})}),eh.map(y=>{const k=y.path.split("/").length-1,z=y.path.split("/").at(-1),X=Xu.has(y.path),ue=j.has(y.path),Je=x===y.path,le=y.path!==i.mainFile&&!i.mainFile.startsWith(`${y.path}/`);return y.type==="directory"?o.jsxs("div",{className:`file-entry folder-entry${It===y.path?" selected":""}`,style:{paddingLeft:`${k*13+5}px`},children:[o.jsxs("button",{className:"file-entry-main",title:y.path,onClick:()=>{dr(y.path),Na(He=>{const vt=new Set(He);return vt.has(y.path)?vt.delete(y.path):vt.add(y.path),vt})},children:[X?o.jsx(sd,{size:13}):o.jsx(Ho,{size:13}),o.jsx(hm,{size:14}),o.jsx("span",{children:z})]}),!Mt&&o.jsxs(o.Fragment,{children:[o.jsx("button",{className:"file-entry-action",title:r("editor.move"),"aria-label":r("editor.move"),onClick:()=>{ur(y),ki("")},children:o.jsx(gc,{size:13})}),le&&o.jsx("button",{className:"file-entry-action danger-text",title:r("editor.deletePath"),"aria-label":r("editor.deletePath"),onClick:()=>{hr(y),Nn("")},children:o.jsx(Qn,{size:13})})]})]},y.path):o.jsxs("div",{className:`file-entry${p===y.path?" active":""}${ue?" root-document":""}${Je?" compile-target":""}`,style:{paddingLeft:`${k*13+18}px`},children:[o.jsxs("button",{className:"file-entry-main",title:Je?r("editor.currentMainDocument",{path:y.path}):ue?r("editor.mainDocumentCandidate",{path:y.path}):y.path,onClick:()=>Ra(y),children:[ue?o.jsx(nd,{size:13}):o.jsx(Vn,{size:13}),o.jsx("span",{children:z}),Je&&o.jsx("small",{children:r("editor.currentMainShort")})]}),!Mt&&o.jsxs(o.Fragment,{children:[o.jsx("button",{className:"file-entry-action",title:r("editor.move"),"aria-label":r("editor.move"),onClick:()=>{ur(y),ki("")},children:o.jsx(gc,{size:13})}),le&&o.jsx("button",{className:"file-entry-action danger-text",title:r("editor.deletePath"),"aria-label":r("editor.deletePath"),onClick:()=>{hr(y),Nn("")},children:o.jsx(Qn,{size:13})})]})]},y.path)})]})]}),o.jsxs("section",{className:"outline-panel",children:[o.jsx("div",{className:"panel-title",children:o.jsxs("span",{children:[o.jsx(mm,{size:14}),r("common.outline")]})}),o.jsxs("div",{className:"outline",children:[Ma.map((y,k)=>o.jsxs("button",{className:`outline-item${p===y.path&&R.line===y.line?" current":""}`,title:`${y.path}:${y.line}`,onClick:()=>{Zt(y.path,y.line,1),cr(y.path,y.line,1)},children:[o.jsx("span",{className:"outline-guides","aria-hidden":!0,style:{width:`${y.level*12}px`}}),o.jsx("small",{children:y.path===p?y.line:y.path.split("/").at(-1)}),o.jsx("span",{className:"outline-title",children:y.title})]},`${y.path}-${y.line}-${k}`)),Ma.length===0&&o.jsx("p",{className:"muted padded",children:r("editor.noOutline")})]})]})]})}),_n&&o.jsx(_i,{className:"resize-handle",children:o.jsx(Ui,{size:12})}),_n&&o.jsx(vr,{id:"source",order:2,defaultSize:42,minSize:22,children:o.jsxs("main",{className:"source-panel",children:[o.jsx(h.Suspense,{fallback:o.jsxs("div",{className:"preview-empty",children:[o.jsx(pn,{className:"spin",size:22}),o.jsx("span",{children:r("common.loading")})]}),children:o.jsx(fb,{value:T,readOnly:Mt,comments:js,focusComment:ih,preferences:Ne,completionIndex:d,spellCheckWords:c,spellCheckIssues:Lt.issues,spellCheckJump:Lt.jump,jumpTo:L===p&&ys?.path===p?ys:null,searchRequest:0,collaboration:Ua?{text:Ua,awareness:Be.awareness}:void 0,onChange:En,onSelection:(y,k,z)=>U({selectedText:y,startOffset:k,endOffset:z}),onCommentClick:y=>{const k=js.find(z=>z.id===y);k&&(La({...k}),V("comments"))},onCursor:(y,k)=>_({line:y,column:k})},p)}),Fa&&o.jsx("div",{className:"editor-centered-notice",role:"status","aria-live":"polite",children:Fa})]})}),_n&&$a&&o.jsxs(_i,{className:"resize-handle sync-resize-handle",children:[o.jsx(Ui,{className:"resize-grip",size:12}),o.jsxs("span",{className:"sync-direction-buttons",onPointerDown:y=>y.stopPropagation(),children:[o.jsx("button",{disabled:!ir,title:r("editor.showInSource"),"aria-label":r("editor.showInSource"),onClick:vi,children:o.jsx("span",{"aria-hidden":!0,children:"←"})}),o.jsx("button",{disabled:!p||!pr,title:r("editor.showInPdf"),"aria-label":r("editor.showInPdf"),onClick:()=>{cr(p,R.line,R.column)},children:o.jsx("span",{"aria-hidden":!0,children:"→"})})]})]}),$a&&o.jsx(vr,{id:"preview",order:3,defaultSize:42,minSize:22,children:o.jsxs("section",{className:"preview-panel",children:[o.jsxs("div",{className:"preview-tabs",role:"tablist","aria-label":r("editor.outputTabs"),children:[o.jsxs("button",{className:`pdf-tab${v==="pdf"?" active":""}`,onClick:()=>I("pdf"),title:On?r("editor.pdfCompiledAtFor",{file:x,time:new Date(On).toLocaleString(ge.resolvedLanguage)}):r("editor.currentMainDocument",{path:x}),children:[o.jsx(Vn,{size:14}),o.jsxs("span",{className:"pdf-tab-label",children:["PDF · ",vh,za&&o.jsx("small",{children:za})]})]}),o.jsxs("button",{className:v==="log"?"active":"",onClick:()=>I("log"),children:[o.jsx(cd,{size:14}),r("editor.log")]}),o.jsxs("button",{className:v==="warnings"?"active":"",onClick:()=>I("warnings"),children:[o.jsx(As,{size:14}),r("editor.warnings"),o.jsx("span",{children:wr.warnings.length})]}),o.jsxs("button",{className:v==="errors"?"active":"",onClick:()=>I("errors"),children:[o.jsx(qo,{size:14}),r("editor.errors"),o.jsx("span",{children:wr.errors.length})]}),o.jsxs("button",{className:v==="artifacts"?"active":"",onClick:()=>I("artifacts"),children:[o.jsx(ad,{size:14}),r("editor.artifacts"),o.jsx("span",{children:Aa.length})]})]}),o.jsxs("div",{className:`preview-content preview-${v}`,children:[v==="pdf"&&(pr?o.jsx(h.Suspense,{fallback:o.jsx("div",{className:"preview-empty",children:o.jsx("span",{children:r("common.loading")})}),children:o.jsx(hb,{url:pr,target:bi,compiling:Cs,onViewportLocation:(y,k,z)=>or({page:y,x:k,y:z})})}):o.jsxs("div",{className:"preview-empty",children:[o.jsx(Vn,{size:28}),o.jsx("strong",{children:r("editor.preview")}),o.jsx("span",{children:r("editor.previewHint")})]})),v==="log"&&o.jsx(no,{lines:mr?mr.split(`
|
|
14
|
-
`):[],empty:r(Ti?"editor.compiling":"editor.noLog")}),v==="warnings"&&(gr?o.jsx(sl,{tone:"warning",diagnostics:gr.warnings,files:ee,empty:r("editor.noWarnings"),onJump:(y,k,z)=>{Q==="pdf-only"&&xr("editor-pdf"),Zt(y,k,z)}}):o.jsx(no,{tone:"warning",lines:wr.warnings,empty:r("editor.noWarnings")})),v==="errors"&&(gr?o.jsx(sl,{tone:"error",diagnostics:gr.errors,files:ee,empty:r("editor.noErrors"),onJump:(y,k,z)=>{Q==="pdf-only"&&xr("editor-pdf"),Zt(y,k,z)}}):o.jsx(no,{tone:"error",lines:wr.errors,empty:r("editor.noErrors")})),v==="artifacts"&&o.jsx(Xx,{projectId:n,mainFile:x,artifacts:Aa,preview:gh,loading:yh,onView:y=>{xh(y)}})]})]})}),K&&o.jsxs(o.Fragment,{children:[o.jsx(_i,{className:"resize-handle",children:o.jsx(Ui,{size:12})}),o.jsx(vr,{id:"context",order:4,defaultSize:20,minSize:15,maxSize:38,children:o.jsxs("aside",{className:"context-panel",children:[o.jsxs("div",{className:"drawer-title",children:[o.jsx("strong",{children:r(K==="comments"?"editor.sourceComments":"editor.projectSettings")}),o.jsx("button",{"aria-label":r("common.close"),onClick:()=>V(null),children:o.jsx(Wo,{size:17})})]}),K==="comments"&&o.jsxs("div",{className:"comments",children:[js.map(y=>o.jsx(Gx,{comment:y,currentUserId:e.id,onFocus:()=>La({...y}),onToggle:()=>{dh(y)},onReply:k=>uh(y,k),onEdit:k=>hh(y,k),onDelete:()=>fh(y),onEditReply:(k,z)=>ph(y,k,z),onDeleteReply:k=>mh(y,k)},y.id)),js.length===0&&o.jsx("p",{className:"muted padded",children:r("editor.noComments")})]}),K==="settings"&&o.jsx(Yx,{project:i,projectId:n,site:t,files:ee,dictionaryWords:c,onDictionaryChange:l,editorPreferences:Ne,onEditorPreferences:bh,spellCheckCount:Lt.summary?.total??null,spellCheckUniqueCount:Lt.summary?.unique??null,spellCheckIndex:Lt.summary?Lt.index:-1,onSpellCheckNavigate:Lt.jumpToIssue,onProject:a})]})})]})]}),o.jsxs(Fe,{open:!!xe,extraWide:xe?.kind==="image"||xe?.kind==="pdf"||xe?.kind==="text",title:xe?.path??"",description:xe?.kind==="large"?r("editor.resourceTooLarge",{size:Ku(xe.size),limit:"10 MB"}):r(`editor.resourcePreview.${xe?.kind??"text"}`),onOpenChange:y=>{y||(Ft(null),Gu(!1))},footer:xe&&o.jsxs("a",{className:"primary resource-download",href:`${xe.url}&download=1`,download:!0,children:[o.jsx(Ur,{size:14}),r("editor.downloadResource")]}),children:[xe?.kind==="large"&&o.jsxs("div",{className:"resource-preview-message",children:[o.jsx(go,{size:34}),o.jsx("strong",{children:r("editor.resourceTooLargeTitle")}),o.jsx("span",{children:r("editor.resourceTooLargeDescription")})]}),xe?.kind==="unsupported"&&o.jsxs("div",{className:"resource-preview-message",children:[o.jsx(go,{size:34}),o.jsx("strong",{children:r("editor.resourceUnsupportedTitle")}),o.jsx("span",{children:r("editor.resourceUnsupportedDescription")})]}),xe?.kind==="image"&&o.jsx("div",{className:"resource-image-wrap",children:o.jsx("img",{className:"resource-image",src:xe.url,alt:xe.path})}),xe?.kind==="pdf"&&o.jsx("iframe",{className:"resource-pdf",src:xe.url,title:xe.path}),xe?.kind==="text"&&(ji?o.jsxs("div",{className:"resource-preview-message",children:[o.jsx(pn,{className:"spin",size:24}),o.jsx("span",{children:r("common.loading")})]}):o.jsx("pre",{className:"resource-text",children:xe.content}))]}),o.jsx(Ls,{open:!!Di,title:r("editor.uploadOverwriteTitle"),description:r("editor.uploadOverwriteDescription",{files:Di?.collisions.join(", ")??""}),confirmLabel:r("editor.uploadOverwrite"),danger:!0,onCancel:()=>Oa(null),onConfirm:()=>{const y=Di;Oa(null),y&&Pa(y.files,new Set(y.collisions),y.directory)}}),o.jsx(Fe,{open:Ue,title:r("editor.newFile"),description:r("editor.newFileDescription"),onOpenChange:y=>{ke(y),y||Nn("")},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>ke(!1),children:r("common.cancel")}),o.jsx("button",{className:"primary",onClick:()=>{th()},children:r("common.create")})]}),children:o.jsxs(o.Fragment,{children:[Qt&&o.jsx("p",{className:"error dialog-error",children:Qt}),o.jsxs("label",{className:"form-field",children:[r("editor.filePath"),o.jsx("input",{autoFocus:!0,value:At,onChange:y=>hn(y.target.value)})]})]})}),o.jsx(Fe,{open:Ju,title:r("editor.newFolder"),description:r("editor.folderDestination",{folder:It||r("editor.projectRoot")}),onOpenChange:y=>{Ci(y),y||Nn("")},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>Ci(!1),children:r("common.cancel")}),o.jsx("button",{className:"primary",onClick:()=>{_a()},children:r("common.create")})]}),children:o.jsxs(o.Fragment,{children:[Qt&&o.jsx("p",{className:"error dialog-error",children:Qt}),o.jsxs("label",{className:"form-field",children:[r("editor.folderName"),o.jsx("input",{autoFocus:!0,value:Yu,onChange:y=>Da(y.target.value),onKeyDown:y=>{y.key==="Enter"&&_a()}})]})]})}),o.jsx(Fe,{open:!!Ss,title:r("editor.moveTitle",{name:Ss?.path.split("/").at(-1)??""}),description:r("editor.moveDescription"),onOpenChange:y=>{y||(ur(null),Nn(""))},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>ur(null),children:r("common.cancel")}),o.jsx("button",{className:"primary",onClick:()=>{sh()},children:r("editor.move")})]}),children:o.jsxs(o.Fragment,{children:[Qt&&o.jsx("p",{className:"error dialog-error",children:Qt}),o.jsxs("label",{className:"form-field",children:[r("editor.destinationFolder"),o.jsxs("select",{value:Zu,onChange:y=>ki(y.target.value),children:[o.jsx("option",{value:"",children:r("editor.projectRoot")}),Qu.filter(y=>Ss?.type!=="directory"||y.path!==Ss.path&&!y.path.startsWith(`${Ss.path}/`)).map(y=>o.jsx("option",{value:y.path,children:y.path},y.path))]})]})]})}),o.jsx(Fe,{open:!!Tn,title:r("editor.deletePathTitle",{name:Tn?.path.split("/").at(-1)??""}),description:Oi.length?r("editor.deletePathActiveDescription",{path:Tn?.path??"",users:[...new Set(Oi.map(y=>y.name))].join(", ")}):r("editor.deletePathDescription",{path:Tn?.path??""}),onOpenChange:y=>{y||(hr(null),Nn(""))},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>hr(null),children:r("common.cancel")}),o.jsx("button",{className:"danger",onClick:()=>{rh()},children:r("common.delete")})]}),children:o.jsxs(o.Fragment,{children:[Qt&&o.jsx("p",{className:"error dialog-error",children:Qt}),Oi.length>0&&o.jsxs("p",{className:"warning",children:[o.jsx(As,{size:15}),r("editor.deletePathWillClose")]})]})}),o.jsxs(Fe,{open:oh,title:r("editor.addComment"),description:ve.selectedText?r("editor.commentDescription",{count:ve.endOffset-ve.startOffset}):r("editor.pointComment"),onOpenChange:Ni,footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>Ni(!1),children:r("common.cancel")}),o.jsx("button",{className:"primary",onClick:()=>{lh()},children:r("editor.addComment")})]}),children:[o.jsxs("label",{className:"form-field",children:[r("editor.commentContent"),o.jsx("textarea",{autoFocus:!0,rows:5,value:ah,onChange:y=>ch(y.target.value)})]}),ve.selectedText&&o.jsx("blockquote",{className:"selection-preview",children:ve.selectedText})]}),o.jsx(Jx,{open:Kt,onOpenChange:Ot,project:i,projectId:n}),Yt&&o.jsx(h.Suspense,{fallback:null,children:o.jsx(yb,{open:!0,files:ee,onOpenChange:wt,onOpenFile:y=>{const k=ee.find(z=>z.path===y);k&&Ra(k)}})}),Pt&&o.jsx(h.Suspense,{fallback:null,children:o.jsx(gb,{open:!0,project:i,onOpenChange:M,onJump:(y,k,z)=>{Q==="pdf-only"&&xr("editor-pdf"),Zt(y,k,z)}})}),dn&&o.jsx(h.Suspense,{fallback:null,children:o.jsx(mb,{open:!0,onOpenChange:_t,project:i,onBeforeMutation:i.permission==="read"?async()=>!0:un})}),i.ownerId===e.id&&Gt&&o.jsx(h.Suspense,{fallback:null,children:o.jsx(pb,{open:!0,onOpenChange:Jt,project:i,onBeforeMutation:un})})]})}function Eb(t){const n=t.split(new RegExp("(?<=\\n)")).map(s=>{for(let r=0;r<s.length;r+=1){if(s[r]!=="%")continue;let i=0;for(let a=r-1;a>=0&&s[a]==="\\";a-=1)i+=1;if(i%2===0)return`${s.slice(0,r)}${s.endsWith(`
|
|
15
|
-
`)?`
|
|
16
|
-
`:""}`}return s}).join("").replace(/\\verb\*?([^\s]).*?\1/g,"").replace(/\\begin\{(?:verbatim\*?|Verbatim|lstlisting|minted)\}[\s\S]*?\\end\{(?:verbatim\*?|Verbatim|lstlisting|minted)\}/g,"");return/\\documentclass\s*(?:\[[^\]]*\]\s*)?\{/.test(n)}function Ku(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`}function Db(t){const e=[],n=/^\s*\\(part|chapter|section|subsection|subsubsection)\*?(?:\[[^\]]*\])?\{([^}]*)\}/,s={part:0,chapter:0,section:1,subsection:2,subsubsection:3};return t.split(`
|
|
17
|
-
`).forEach((r,i)=>{const a=r.match(n);a&&e.push({level:s[a[1]],title:a[2],line:i+1})}),e}Eh.createRoot(document.getElementById("root")).render(o.jsx(h.StrictMode,{children:o.jsx(xb,{})}));export{em as A,sd as C,Ur as D,Vn as F,fm as G,pn as L,Fe as M,jm as R,Vr as S,Qn as T,Mb as U,Ab as a,Fb as b,Lb as c,Ib as d,vn as e,_b as f,$t as g,Ob as h,F as i,Ho as j,A as k,Ls as l,Yo as m,Cm as n,um as o,rm as p,Rb as r,Pb as t};
|