texlite 0.7.0 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/dist/client/assets/{BinaryModule-Aj1vLnwf-wCY0vy1F.js → BinaryModule-Aj1vLnwf-_qIOaefD.js} +1 -1
  2. package/dist/client/assets/GitDialog-BmRzMv-C.js +3 -0
  3. package/dist/client/assets/{HistoryDialog-qZKt59En.js → HistoryDialog-V0IkSDtJ.js} +1 -1
  4. package/dist/client/assets/LatexEditor-CokkLLxi.js +59 -0
  5. package/dist/client/assets/PdfPreview-Cs1WYPsC.js +1 -0
  6. package/dist/client/assets/{ProjectNavigationDialogs-CcHy9xt5.js → ProjectNavigationDialogs-BVQb4qdD.js} +1 -1
  7. package/dist/client/assets/{SystemMetricsDialog-BSiZRWs4.js → SystemMetricsDialog-DBrendnp.js} +1 -1
  8. package/dist/client/assets/binary-BQKEW09b.js +1 -0
  9. package/dist/client/assets/index-BS1IMOaB.js +62 -0
  10. package/dist/client/assets/index-Lw53KTaT.css +1 -0
  11. package/dist/client/assets/{index-BM28jYXo.js → index-QyVe7I1s.js} +1 -1
  12. package/dist/client/assets/minus-yEV4SLvG.js +1 -0
  13. package/dist/client/assets/{spellCheck-Cs5UpEXV.js → spellCheck-OZGa6ljx.js} +3 -3
  14. package/dist/client/index.html +2 -2
  15. package/dist/server/app.js +315 -2
  16. package/dist/server/citationLibrary.js +174 -0
  17. package/dist/server/db.js +37 -0
  18. package/package.json +2 -1
  19. package/dist/client/assets/GitDialog-BNzmjKSK.js +0 -3
  20. package/dist/client/assets/LatexEditor-CpK2QB28.js +0 -59
  21. package/dist/client/assets/PdfPreview-Deo1bzQ7.js +0 -1
  22. package/dist/client/assets/binary-DEDGh9yV.js +0 -1
  23. package/dist/client/assets/index-DJzyhcDQ.js +0 -17
  24. package/dist/client/assets/index-DdrajKQB.css +0 -1
  25. package/dist/client/assets/plus-BmrCa7ds.js +0 -1
@@ -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-Cs5UpEXV.js","assets/PdfPreview-Deo1bzQ7.js","assets/pdf-DPnwNQHb.js","assets/plus-BmrCa7ds.js","assets/LatexEditor-CpK2QB28.js","assets/editor-DMLs-XWi.js","assets/GitDialog-BNzmjKSK.js","assets/HistoryDialog-qZKt59En.js","assets/ProjectNavigationDialogs-CcHy9xt5.js","assets/SystemMetricsDialog-BSiZRWs4.js"])))=>i.map(i=>d[i]);
2
- import{i as tf,r as h,j as o,R as ir,a as Ol,b as nf,u as Ae,P as sf,c as _r,d as Bi,e as rf}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 of="modulepreload",af=function(t){return"/"+t},uc={},rn=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=af(d),d in uc)return;uc[d]=!0;const f=d.endsWith(".css"),u=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${u}`))return;const p=document.createElement("link");if(p.rel=f?"stylesheet":of,f||(p.as="script"),p.crossOrigin="",p.href=d,c&&p.setAttribute("nonce",c),document.head.appendChild(p),f)return new Promise((m,g)=>{p.addEventListener("load",m),p.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)})},cf="0.7.0";var Vi={};const X=t=>typeof t=="string",$s=()=>{let t,e;const n=new Promise((s,r)=>{t=s,e=r});return n.resolve=t,n.reject=e,n},hc=t=>t==null?"":""+t,lf=(t,e,n)=>{t.forEach(s=>{e[s]&&(n[s]=e[s])})},df=/###/g,fc=t=>t&&t.indexOf("###")>-1?t.replace(df,"."):t,pc=t=>!t||X(t),Bs=(t,e,n)=>{const s=X(e)?e.split("."):e;let r=0;for(;r<s.length-1;){if(pc(t))return{};const i=fc(s[r]);!t[i]&&n&&(t[i]=new n),Object.prototype.hasOwnProperty.call(t,i)?t=t[i]:t={},++r}return pc(t)?{}:{obj:t,k:fc(s[r])}},mc=(t,e,n)=>{const{obj:s,k:r}=Bs(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=Bs(t,a,Object);for(;c.obj===void 0&&a.length;)i=`${a[a.length-1]}.${i}`,a=a.slice(0,a.length-1),c=Bs(t,a,Object),c?.obj&&typeof c.obj[`${c.k}.${i}`]<"u"&&(c.obj=void 0);c.obj[`${c.k}.${i}`]=n},uf=(t,e,n,s)=>{const{obj:r,k:i}=Bs(t,e,Object);r[i]=r[i]||[],r[i].push(n)},Kr=(t,e)=>{const{obj:n,k:s}=Bs(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,s))return n[s]},hf=(t,e,n)=>{const s=Kr(t,n);return s!==void 0?s:Kr(e,n)},Pl=(t,e,n)=>{for(const s in e)s!=="__proto__"&&s!=="constructor"&&(s in t?X(t[s])||t[s]instanceof String||X(e[s])||e[s]instanceof String?n&&(t[s]=e[s]):Pl(t[s],e[s],n):t[s]=e[s]);return t},Dn=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var ff={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const pf=t=>X(t)?t.replace(/[&<>"'\/]/g,e=>ff[e]):t;class mf{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 gf=[" ",",","?","!",";"],yf=new mf(20),wf=(t,e,n)=>{e=e||"",n=n||"";const s=gf.filter(a=>e.indexOf(a)<0&&n.indexOf(a)<0);if(s.length===0)return!0;const r=yf.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},go=(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},qs=t=>t?.replace(/_/g,"-"),xf={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 Gr{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||xf,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:(X(e[0])&&(e[0]=`${s}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new Gr(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new Gr(this.logger,e)}}var Mt=new Gr;class pi{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 gc extends pi{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):X(s)&&i?c.push(...s.split(i)):c.push(s)));const l=Kr(this.data,c);return!l&&!n&&!s&&e.indexOf(".")>-1&&(e=c[0],n=c[1],s=c.slice(2).join(".")),l||!a||!X(s)?l:go(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),mc(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)(X(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=Kr(this.data,c)||{};a.skipCopy||(s=JSON.parse(JSON.stringify(s))),r?Pl(l,s,i):l={...l,...s},mc(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 _l={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 Rl=Symbol("i18next/PATH_KEY");function bf(){const t=[],e=Object.create(null);let n;return e.get=(s,r)=>(n?.revoke?.(),r===Rl?t:(t.push(r),n=Proxy.revocable(s,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function os(t,e){const{[Rl]:n}=t(bf()),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 yc={},Hi=t=>!X(t)&&typeof t!="boolean"&&typeof t!="number";class Jr extends pi{constructor(e,n={}){super(),lf(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Mt.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=Hi(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&&!wf(e,s,r);if(a&&!c){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:X(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:X(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=os(e,{...this.options,...r})),Array.isArray(e)||(e=[String(e)]),e=e.map(_=>typeof _=="function"?os(_,{...this.options,...r}):String(_));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,p=r.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u?.toLowerCase()==="cimode")return p?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 m=this.resolve(e,r);let g=m?.res;const w=m?.usedKey||c,b=m?.exactUsedKey||c,v=["[object Number]","[object Function]","[object RegExp]"],k=r.joinArrays!==void 0?r.joinArrays:this.options.joinArrays,P=!this.i18nFormat||this.i18nFormat.handleAsObject,N=r.count!==void 0&&!X(r.count),O=Jr.hasDefaultValue(r),W=N?this.pluralResolver.getSuffix(u,r.count,r):"",E=r.ordinal&&N?this.pluralResolver.getSuffix(u,r.count,{ordinal:!1}):"",J=N&&!r.ordinal&&r.count===0,C=J&&r[`defaultValue${this.options.pluralSeparator}zero`]||r[`defaultValue${W}`]||r[`defaultValue${E}`]||r.defaultValue;let V=g;P&&!g&&O&&(V=C);const Z=Hi(V),R=Object.prototype.toString.apply(V);if(P&&V&&Z&&v.indexOf(R)<0&&!(X(k)&&Array.isArray(V))){if(!r.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const _=this.options.returnedObjectHandler?this.options.returnedObjectHandler(w,V,{...r,ns:l}):`key '${c} (${this.language})' returned an object instead of string.`;return i?(m.res=_,m.usedParams=this.getUsedParamsDetails(r),m):_}if(a){const _=Array.isArray(V),L=_?[]:{},j=_?b:w;for(const H in V)if(Object.prototype.hasOwnProperty.call(V,H)){const fe=`${j}${a}${H}`;O&&!g?L[H]=this.translate(fe,{...r,defaultValue:Hi(C)?C[H]:void 0,joinArrays:!1,ns:l}):L[H]=this.translate(fe,{...r,joinArrays:!1,ns:l}),L[H]===fe&&(L[H]=V[H])}g=L}}else if(P&&X(k)&&Array.isArray(g))g=g.join(k),g&&(g=this.extendTranslation(g,e,r,s));else{let _=!1,L=!1;!this.isValidLookup(g)&&O&&(_=!0,g=C),this.isValidLookup(g)||(L=!0,g=c);const H=(r.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&L?void 0:g,fe=O&&C!==g&&this.options.updateMissing;if(L||_||fe){if(this.logger.log(fe?"updateKey":"missingKey",u,d,c,fe?C:g),a){const G=this.resolve(c,{...r,keySeparator:!1});G&&G.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 ce=this.languageUtils.getFallbackCodes(this.options.fallbackLng,r.lng||this.language);if(this.options.saveMissingTo==="fallback"&&ce&&ce[0])for(let G=0;G<ce.length;G++)Ce.push(ce[G]);else this.options.saveMissingTo==="all"?Ce=this.languageUtils.toResolveHierarchy(r.lng||this.language):Ce.push(r.lng||this.language);const we=(G,K,ge)=>{const pe=O&&ge!==g?ge:H;this.options.missingKeyHandler?this.options.missingKeyHandler(G,d,K,pe,fe,r):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(G,d,K,pe,fe,r),this.emit("missingKey",G,d,K,g)};this.options.saveMissing&&(this.options.saveMissingPlurals&&N?Ce.forEach(G=>{const K=this.pluralResolver.getSuffixes(G,r);J&&r[`defaultValue${this.options.pluralSeparator}zero`]&&K.indexOf(`${this.options.pluralSeparator}zero`)<0&&K.push(`${this.options.pluralSeparator}zero`),K.forEach(ge=>{we([G],c+ge,r[`defaultValue${ge}`]||C)})}):we(Ce,c,C))}g=this.extendTranslation(g,e,r,m,s),L&&g===c&&this.options.appendNamespaceToMissingKey&&(g=`${d}${f}${c}`),(L||_)&&this.options.parseMissingKeyHandler&&(g=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${d}${f}${c}`:c,_?g:void 0,r))}return i?(m.res=g,m.usedParams=this.getUsedParamsDetails(r),m):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=X(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&&!X(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),p=u&&u.length;d<p&&(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=X(a)?[a]:a;return e!=null&&c?.length&&s.applyPostProcessor!==!1&&(e=_l.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 X(e)&&(e=[e]),Array.isArray(e)&&(e=e.map(l=>typeof l=="function"?os(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 p=n.count!==void 0&&!X(n.count),m=p&&!n.ordinal&&n.count===0,g=n.context!==void 0&&(X(n.context)||typeof n.context=="number")&&n.context!=="",w=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);u.forEach(b=>{this.isValidLookup(s)||(c=b,!yc[`${w[0]}-${b}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(c)&&(yc[`${w[0]}-${b}`]=!0,this.logger.warn(`key "${r}" for languages "${w.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!!!")),w.forEach(v=>{if(this.isValidLookup(s))return;a=v;const k=[f];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(k,f,v,b,n);else{let N;p&&(N=this.pluralResolver.getSuffix(v,n.count,n));const O=`${this.options.pluralSeparator}zero`,W=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(n.ordinal&&N.indexOf(W)===0&&k.push(f+N.replace(W,this.options.pluralSeparator)),k.push(f+N),m&&k.push(f+O)),g){const E=`${f}${this.options.contextSeparator||"_"}${n.context}`;k.push(E),p&&(n.ordinal&&N.indexOf(W)===0&&k.push(E+N.replace(W,this.options.pluralSeparator)),k.push(E+N),m&&k.push(E+O))}}let P;for(;P=k.pop();)this.isValidLookup(s)||(i=P,s=this.getResource(v,b,P,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&&!X(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 wc{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Mt.create("languageUtils")}getScriptPartFromCode(e){if(e=qs(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=qs(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(X(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)),X(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 X(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))):X(e)&&i(this.formatLanguageCode(e)),s.forEach(a=>{r.indexOf(a)<0&&i(this.formatLanguageCode(a))}),r}}const xc={zero:0,one:1,two:2,few:3,many:4,other:5},bc={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class vf{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=Mt.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const s=qs(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!"),bc;if(!e.match(/-|_/))return bc;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)=>xc[r]-xc[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 vc=(t,e,n,s=".",r=!0)=>{let i=hf(t,e,n);return!i&&r&&X(n)&&(i=go(t,n,s),i===void 0&&(i=go(e,n,s))),i},qi=t=>t.replace(/\$/g,"$$$$");class Sc{constructor(e={}){this.logger=Mt.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:p,nestingPrefixEscaped:m,nestingSuffix:g,nestingSuffixEscaped:w,nestingOptionsSeparator:b,maxReplaces:v,alwaysFormat:k}=e.interpolation;this.escape=n!==void 0?n:pf,this.escapeValue=s!==void 0?s:!0,this.useRawValueToEscape=r!==void 0?r:!1,this.prefix=i?Dn(i):a||"{{",this.suffix=c?Dn(c):l||"}}",this.formatSeparator=d||",",this.unescapePrefix=f?"":u||"-",this.unescapeSuffix=this.unescapePrefix?"":f||"",this.nestingPrefix=p?Dn(p):m||Dn("$t("),this.nestingSuffix=g?Dn(g):w||Dn(")"),this.nestingOptionsSeparator=b||",",this.maxReplaces=v||1e3,this.alwaysFormat=k!==void 0?k:!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=m=>{if(m.indexOf(this.formatSeparator)<0){const v=vc(n,l,m,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(v,void 0,s,{...r,...n,interpolationkey:m}):v}const g=m.split(this.formatSeparator),w=g.shift().trim(),b=g.join(this.formatSeparator).trim();return this.format(vc(n,l,w,this.options.keySeparator,this.options.ignoreJSONStructure),b,s,{...r,...n,interpolationkey:w})};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:m=>qi(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?qi(this.escape(m)):qi(m)}].forEach(m=>{for(c=0;i=m.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=X(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!X(a)&&!this.useRawValueToEscape&&(a=hc(a));const w=m.safeValue(a);if(e=e.replace(i[0],w),u?(m.regex.lastIndex+=a.length,m.regex.lastIndex-=i[0].length):m.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(`${Dn(f)}[ ]*{`));let p=`{${u[1]}`;l=u[0],p=this.interpolate(p,a);const m=p.match(/'/g),g=p.match(/"/g);((m?.length??0)%2===0&&!g||(g?.length??0)%2!==0)&&(p=p.replace(/'/g,'"'));try{a=JSON.parse(p),d&&(a={...d,...a})}catch(w){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,w),`${l}${f}${p}`}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&&!X(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&&!X(i))return i;X(i)||(i=hc(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 Sf=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}},Cc=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(qs(s),r),e[a]=c),c(n)}},Cf=t=>(e,n,s)=>t(qs(n),s)(e);class jf{constructor(e={}){this.logger=Mt.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const s=n.cacheInBuiltFormats?Cc:Cf;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()]=Cc(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}=Sf(l);if(this.formats[d]){let u=c;try{const p=r?.formatParams?.[r.interpolationkey]||{},m=p.locale||p.lng||r.locale||r.lng||s;u=this.formats[d](c,m,{...f,...r,...p})}catch(p){this.logger.warn(p)}return u}else this.logger.warn(`there was no format function for ${d}`);return c},e)}}const kf=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class Ef extends pi{constructor(e,n,s,r={}){super(),this.backend=e,this.store=n,this.services=s,this.languageUtils=s.languageUtils,this.options=r,this.logger=Mt.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 p=`${d}|${u}`;!s.reload&&this.store.hasResourceBundle(d,u)?this.state[p]=2:this.state[p]<0||(this.state[p]===1?a[p]===void 0&&(a[p]=!0):(this.state[p]=1,f=!1,a[p]===void 0&&(a[p]=!0),i[p]===void 0&&(i[p]=!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=>{uf(l.loaded,[i],a),kf(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();X(e)&&(e=this.languageUtils.toResolveHierarchy(e)),X(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 Wi=()=>({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]),X(t[1])&&(e.defaultValue=t[1]),X(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}),jc=t=>(X(t.ns)&&(t.ns=[t.ns]),X(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),X(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),Rr=()=>{},Df=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})},Ll="__i18next_supportNoticeShown",Tf=()=>!!(typeof globalThis<"u"&&globalThis[Ll]||typeof process<"u"&&Vi&&Vi.I18NEXT_NO_SUPPORT_NOTICE||typeof process<"u"&&Vi),Nf=()=>{typeof globalThis<"u"&&(globalThis[Ll]=!0)},Of=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 Vs extends pi{constructor(e={},n){if(super(),this.options=jc(e),this.services={},this.logger=Mt,this.modules={external:[]},Df(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&&(X(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const s=Wi();this.options={...s,...this.options,...jc(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&&!Of(this)&&!Tf()&&(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 💙"),Nf());const r=d=>d?typeof d=="function"?new d:d:null;if(!this.options.isClone){this.modules.logger?Mt.init(r(this.modules.logger),this.options):Mt.init(null,this.options);let d;this.modules.formatter?d=this.modules.formatter:d=jf;const f=new wc(this.options);this.store=new gc(this.options.resources,this.options);const u=this.services;u.logger=Mt,u.resourceStore=this.store,u.languageUtils=f,u.pluralResolver=new vf(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 Sc(this.options),u.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},u.backendConnector=new Ef(r(this.modules.backend),u.resourceStore,u,this.options),u.backendConnector.on("*",(m,...g)=>{this.emit(m,...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 Jr(this.services,this.options),this.translator.on("*",(m,...g)=>{this.emit(m,...g)}),this.modules.external.forEach(m=>{m.init&&m.init(this)})}if(this.format=this.options.interpolation.format,n||(n=Rr),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=$s(),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=Rr){let s=n;const r=X(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=$s();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=Rr),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"&&_l.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=$s();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=X(c)?c:c&&c[0],d=this.store.hasLanguageSomeTranslations(l)?l:this.services.languageUtils.getBestMatchFromCodes(X(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=os(l.keyPrefix,d));const f=this.options.keySeparator||".";let u;return l.keyPrefix&&Array.isArray(i)?u=i.map(p=>(typeof p=="function"&&(p=os(p,d)),`${l.keyPrefix}${f}${p}`)):(typeof i=="function"&&(i=os(i,d)),u=l.keyPrefix?`${l.keyPrefix}${f}${i}`:i),this.t(u,l)};return X(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=$s();return this.options.ns?(X(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=$s();X(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 wc(Wi());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 Vs(e,n);return s.createInstance=Vs.createInstance,s}cloneInstance(e={},n=Rr){const s=e.forkResourceStore;s&&delete e.forkResourceStore;const r={...this.options,...e,isClone:!0},i=new Vs(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 gc(c,r),i.services.resourceStore=i.store}if(e.interpolation){const l={...Wi().interpolation,...this.options.interpolation,...e.interpolation},d={...r,interpolation:l};i.services.interpolator=new Sc(d)}return i.translator=new Jr(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 he=Vs.createInstance();he.createInstance;he.dir;he.init;he.loadResources;he.reloadResources;he.use;he.changeLanguage;he.getFixedT;he.t;he.exists;he.setDefaultNamespace;he.hasLoadedNamespace;he.loadNamespaces;he.loadLanguages;const{slice:Pf,forEach:_f}=[];function Rf(t){return _f.call(Pf.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function Lf(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 kc=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Af=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(!kc.test(s.domain))throw new TypeError("option domain is invalid");i+=`; Domain=${s.domain}`}if(s.path){if(!kc.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},Ec={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=Af(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 Ff={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return Ec.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:s,cookieDomain:r,cookieOptions:i}=e;n&&typeof document<"u"&&Ec.create(n,t,s,r,i)}},If={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}},Mf={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 Gn=null;const Dc=()=>{if(Gn!==null)return Gn;try{if(Gn=typeof window<"u"&&window.localStorage!==null,!Gn)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Gn=!1}return Gn};var $f={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&Dc())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&Dc()&&window.localStorage.setItem(n,t)}};let Jn=null;const Tc=()=>{if(Jn!==null)return Jn;try{if(Jn=typeof window<"u"&&window.sessionStorage!==null,!Jn)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Jn=!1}return Jn};var Uf={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&Tc())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&Tc()&&window.sessionStorage.setItem(n,t)}},zf={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}},Bf={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}},Vf={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 Al=!1;try{document.cookie,Al=!0}catch{}const Fl=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];Al||Fl.splice(1,1);const qf=()=>({order:Fl,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class Il{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=Rf(n,this.options||{},qf()),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(Ff),this.addDetector(If),this.addDetector($f),this.addDetector(Uf),this.addDetector(zf),this.addDetector(Bf),this.addDetector(Vf),this.addDetector(Hf),this.addDetector(Mf)}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&&!Lf(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)}))}}Il.type="languageDetector";const Wf={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:"中文"},Kf={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",relativeHoursPast:"{{hours}}h ago",relativeHoursMinutesPast:"{{hours}}h {{minutes}}m ago",relativeHoursFuture:"in {{hours}}h",relativeHoursMinutesFuture:"in {{hours}}h {{minutes}}m",relativeDaysPast:"{{days}}d ago",relativeDaysHoursPast:"{{days}}d {{hours}}h ago",relativeDaysFuture:"in {{days}}d",relativeDaysHoursFuture:"in {{days}}d {{hours}}h",comments:"Comments",unresolvedComments:"{{count}} unresolved comments",unresolvedCommentsTooltip:"{{unresolved}} unresolved / {{total}} total comments",allResolved:"All resolved ({{count}})",allCommentsResolvedTooltip:"All {{count}} comments resolved",noComments:"No comments",unresolvedCount:"{{count}} unresolved",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"},Jf={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"},Yf={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.",compileSnapshotStale:"PDF compiled from a consistent earlier snapshot; newer source changes are not included.",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",loadingPdf:"Loading PDF…",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",clean:"Recovery",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",cleanTitle:"Compilation recovery",cleanDescription:"Use these advanced actions only when compilation is stuck, a previous error is left behind, or generated output is inconsistent. They do not change source files, project settings, comments, history, or Git data.",cleanCache:"Force a clean rebuild",cleanCacheDescription:"Use after a compilation failure or stale latexmk state. Removes the incremental cache while keeping the current successful PDF.",cleanArtifacts:"Remove generated output",cleanArtifactsDescription:"Use when generated files are inconsistent. Removes the PDF, SyncTeX, logs, and intermediate files for this root document.",cleanCacheConfirmTitle:"Force a clean rebuild?",cleanCacheConfirmDescription:"This recovery action removes the incremental latexmk cache. The current PDF remains visible, and the next compilation starts from a clean cache.",cleanArtifactsConfirmTitle:"Remove generated output?",cleanArtifactsConfirmDescription:"This recovery action removes the current PDF and all generated files for this root document. Source files are not affected.",cleanConfirm:"Run recovery",cleanCacheComplete:"Recovery cache cleared. The next compilation will be a full rebuild.",cleanArtifactsComplete:"Generated compilation output removed.",cleanBusy:"This root document is compiling. Try recovery again after it finishes.",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 or rename {{name}}",moveDescription:"Choose a destination folder and name. Files, comments and project paths stay linked.",pathName:"Name",moveApply:"Move / rename",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.",writingSuggestions:"Writing suggestions",noWritingSuggestions:"No suggestions available",removeText:"Remove text",replaceWith:"Replace with {{word}}",spellCheckReadOnly:"Read-only: choose a suggestion in an editor with write permission.",spellCheckSourceChanged:"The source changed before the writing correction could be applied.",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",syncTexOnlyForTex:"PDF sync is only available for TeX (.tex) files",syncTexOnlyForMain:"PDF sync is only available for the current main TeX document",openFiles:"Open files",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",pdfLink:"PDF link",pdfLinks:"PDF links",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."},Zf={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"}},Qf={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",writingCheckDescription:"Harper runs locally in a worker. Spelling issues use a red wavy underline; grammar issues use yellow. Right-click an issue for suggestions.",projectConfiguration:"Project configuration",fontFamily:"English font",fontSize:"Font size",lineHeight:"Line spacing",dictionary:"Project dictionary",dictionaryDescription:"Words added here are imported into Harper's custom dictionary and ignored by spelling checks 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:"Spelling and grammar 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",openFilesInTabs:"Open LaTeX files in editor tabs",openFilesInTabsDescription:"Open .tex, .bib, .sty and other source files in tabs at the top of the editor.",writingIssues:"{{count}} writing issues ({{uniqueCount}} unique)",noWritingIssues:"No spelling or grammar issues found.",spellCheckFirst:"First writing issue",spellCheckPrevious:"Previous writing issue",spellCheckNext:"Next writing issue",spellCheckLast:"Last writing 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"},ep={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"},tp={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"}}},np={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"},sp={generic:"Operation failed",request:"Request failed ({{status}})",upload:"Upload failed",boundaryTitle:"Something went wrong",boundaryDescription:"An unexpected error occurred while rendering the page. You can try recovering, or reload the page.",boundaryRetry:"Retry",boundaryReload:"Reload page",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."}},rp={historyVersionNotFound:"The selected history version no longer exists.",historyFileNotFound:"This file does not exist in the selected history version.",historyTargetConflict:"The current restore target is a directory or another non-file path.",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.",compileSnapshotBusy:"The source has not finished saving durably. Wait a moment and try compiling again."},ip={copyright:"© {{year}}",credit:"Designed and developed by CHEN Zhongpu"},op={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"},ap={common:Wf,auth:Kf,projects:Gf,users:Jf,editor:Yf,navigation:Xf,history:Zf,projectSettings:Qf,git:ep,metrics:tp,tags:np,errors:sp,apiErrors:rp,footer:ip,completions:op},cp={cancel:"取消",create:"创建",add:"添加",remove:"移除",delete:"删除",close:"关闭",user:"用户",permission:"权限",readOnly:"只读",readWrite:"读写",settings:"设置",comments:"批注",files:"文件",outline:"大纲",loading:"正在载入…",enabled:"允许",disabled:"禁止",normal:"正常",admin:"管理员",language:"语言",languageEnglish:"English",languageChinese:"中文"},lp={tagline:"轻量 LaTeX 写作环境",username:"用户名",password:"密码",login:"登录",contact:"需要账号?请联系 {{email}}",firstLogin:"首次登录,请修改初始密码",currentPassword:"当前密码",newPassword:"新密码",confirmPassword:"确认新密码",updatePassword:"更新密码",mismatch:"两次输入的新密码不一致",passwordMinimum:"至少 {{count}} 位",sessionExpired:"登录状态已过期,请重新登录。",logout:"退出"},dp={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:"最后修改",relativeHoursPast:"{{hours}}小时前",relativeHoursMinutesPast:"{{hours}}小时{{minutes}}分钟前",relativeHoursFuture:"{{hours}}小时后",relativeHoursMinutesFuture:"{{hours}}小时{{minutes}}分钟后",relativeDaysPast:"{{days}}天前",relativeDaysHoursPast:"{{days}}天{{hours}}小时前",relativeDaysFuture:"{{days}}天后",relativeDaysHoursFuture:"{{days}}天{{hours}}小时后",modifiedBy:"最后修改人",byUser:"由 {{user}} 修改",modifiedByUser:"{{time}} · 由 {{user}} 修改",deletedUser:"已删除用户",comments:"批注",unresolvedComments:"{{count}} 条未解决批注",unresolvedCommentsTooltip:"{{unresolved}} 条未解决批注 / 共 {{total}} 条",allResolved:"全部已解决 ({{count}})",allCommentsResolvedTooltip:"全部 {{count}} 条批注已解决",noComments:"暂无批注",unresolvedCount:"{{count}} 条待解决",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:"清除已选文件"},up={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:"永久删除项目及全部文件"},hp={saved:"已保存",savedAt:"已于 {{time}} 保存到服务器",loading:"载入中",pending:"等待保存",saving:"正在保存到服务器",saveFailed:"保存失败",offlineDraft:"离线 · 本地草稿已保留",compile:"编译 · {{engine}}",compiling:"编译中…",compileQueued:"编译已排队…",compileFailedRetained:"编译失败,当前显示上一次成功生成的 PDF({{time}})。",compileFailedNoPdf:"编译失败,且没有可用的成功 PDF。",upToDate:"文件已是最新,无需重新编译。",compileSnapshotStale:"PDF 基于较早的一致快照编译,未包含之后的源码修改。",addComment:"添加批注",sourceComments:"源码批注",projectSettings:"项目设置",uploadAttachment:"上传附件",newFile:"新建文本文件",binary:"二进制附件已保存,但不能在文本编辑器中打开。",noOutline:"当前文件没有章节",preview:"PDF 预览",previewHint:"点击“编译”生成文档",loadingPdf:"正在加载 PDF…",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:"产物",clean:"故障恢复",noLog:"编译后将在此显示日志。",noWarnings:"最近一次编译没有警告。",noErrors:"最近一次编译没有错误。",projectRoot:"项目根目录",uploadTo:"上传到 {{folder}}",dropFiles:"拖放文件以上传",newFolder:"新建文件夹",folderName:"文件夹名称",folderDestination:"文件夹将创建在 {{folder}} 中。",uploadOverwriteTitle:"文件已存在",uploadOverwriteDescription:"以下文件已经存在:{{files}}。要覆盖它们吗?",uploadOverwrite:"覆盖文件",noArtifacts:"编译后将在此显示输出产物。",selectArtifact:"选择一个文本产物进行预览。",viewArtifact:"查看产物",downloadArtifact:"下载产物",downloadToView:"该产物需要下载后查看",cleanTitle:"编译故障恢复",cleanDescription:"这里只提供高级故障恢复操作:仅在编译卡住、历史错误状态残留或生成产物异常时使用。不会修改源码、项目设置、批注、历史或 Git 数据。",cleanCache:"强制完整重编译",cleanCacheDescription:"仅在编译失败或 latexmk 缓存状态异常时使用。删除增量缓存,但保留当前成功的 PDF。",cleanArtifacts:"删除生成输出",cleanArtifactsDescription:"仅在生成产物状态异常时使用。删除该主文档的 PDF、SyncTeX、日志和中间文件。",cleanCacheConfirmTitle:"强制完整重编译?",cleanCacheConfirmDescription:"此故障恢复操作会删除 latexmk 增量缓存。当前 PDF 会保留,下一次编译将从干净缓存开始。",cleanArtifactsConfirmTitle:"删除生成输出?",cleanArtifactsConfirmDescription:"此故障恢复操作会删除当前 PDF 以及该主文档的全部生成文件,但不会影响源码。",cleanConfirm:"执行恢复",cleanCacheComplete:"故障恢复缓存已清理,下一次编译将完整执行。",cleanArtifactsComplete:"编译生成输出已删除。",cleanBusy:"当前主文档正在编译,请完成后再执行故障恢复。",collapseFiles:"折叠文件面板",move:"移动",moveTitle:"移动或重命名 {{name}}",moveDescription:"选择目标文件夹和名称;源码、批注和项目路径会保持关联。",pathName:"名称",moveApply:"移动/重命名",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:"格式化期间所选源码已发生变化,请重新选择后再试。",writingSuggestions:"写作建议",noWritingSuggestions:"没有可用的修改建议",removeText:"删除文本",replaceWith:"替换为 {{word}}",spellCheckReadOnly:"当前为只读,需要编辑权限才能替换。",spellCheckSourceChanged:"源码在应用写作修正前发生了变化。",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 中显示当前源码光标位置",syncTexOnlyForTex:"PDF 跳转仅支持 TeX 源文件(.tex)",syncTexOnlyForMain:"PDF 跳转仅支持当前主 TeX 文档",openFiles:"打开的文件",pdfLoadFailed:"无法载入 PDF 预览",pdfZoomControls:"PDF 缩放控件",downloadPdf:"下载 PDF",downloadResource:"下载文件",resourceTooLarge:"该文件大小为 {{size}},超过 {{limit}} 的直接预览上限。",resourceTooLargeTitle:"文件过大,无法直接预览",resourceTooLargeDescription:"请下载文件后在本地打开。",resourceUnsupportedTitle:"无法预览",resourceUnsupportedDescription:"浏览器不能直接渲染此文件类型,请下载后在本地打开。",resourcePreview:{image:"图片预览",pdf:"PDF 预览",text:"文本预览",unsupported:"文件预览"},pdfZoomOut:"缩小",pdfZoomIn:"放大",pdfFitWidth:"适合宽度",pdfLink:"PDF 链接",pdfLinks:"PDF 链接",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:"正则表达式无效"}},fp={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}} 项。"},pp={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:"安全检查点"}},mp={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:"保存编译器设置",writingCheckDescription:"Harper 在浏览器本地 worker 中运行。拼写问题使用红色波浪线,语法问题使用黄色波浪线;右键问题可以查看修改建议。",projectConfiguration:"项目配置",fontFamily:"英文字体",fontSize:"字体大小",lineHeight:"行间距",dictionary:"项目词典",dictionaryDescription:"添加到这里的词会导入 Harper 的自定义词典,并在本项目的拼写检查中忽略;具有编辑权限的用户可以维护此列表。",dictionaryPlaceholder:"添加自定义词",addWord:"添加词",dictionaryEmpty:"暂未添加自定义词。",lineWrapping:"自动换行",spellCheck:"拼写和语法检查",vimMode:"Vim 键位",vimModeDescription:"在当前编辑器中使用 Vim 的普通、插入和可视模式。",vimHelp:"查看帮助",formatOnCompile:"编译前自动格式化 LaTeX",formatOnCompileDescription:"默认关闭;格式化会在服务器编译前执行。",formatRequiresWrite:"需要项目编辑权限才能使用格式化。",formatterDescription:"格式化使用宿主机上的可选 tex-fmt 命令。",formatterInstall:"安装或查看 tex-fmt 文档",openFilesInTabs:"使用新 Tab 打开 LaTeX 文件",openFilesInTabsDescription:"在编辑器顶部通过标签页管理打开的 .tex、.bib、.sty 等源码文件。",writingIssues:"发现 {{count}} 个写作问题(去重后 {{uniqueCount}} 个)",noWritingIssues:"未发现拼写或语法问题。",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:"宽松"},gp={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:"确认撤销"},yp={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:"生成补全索引"}}},wp={title:"标签",add:"添加标签",create:"新建标签",createDescription:"创建仅自己可见的可复用彩色标签,用于整理项目。",assign:"标签",assignTitle:"“{{project}}”的标签",assignDescription:"勾选你为此项目设置的私有标签;其他用户拥有各自的标签。",empty:"请先创建标签。",allAssigned:"所有可用标签均已添加。",name:"标签名称",color:"颜色",filter:"筛选",red:"红色",orange:"橙色",yellow:"黄色",green:"绿色",blue:"蓝色",purple:"紫色",gray:"灰色"},xp={generic:"操作失败",request:"请求失败({{status}})",upload:"上传失败",boundaryTitle:"页面遇到问题",boundaryDescription:"渲染组件时发生异常。你可以尝试恢复,或刷新页面重新载入。",boundaryRetry:"重试",boundaryReload:"刷新页面",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:"请求格式无效。"}},bp={historyVersionNotFound:"所选历史版本已不存在。",historyFileNotFound:"所选历史版本中没有这个文件。",historyTargetConflict:"当前恢复目标是目录或其他非普通文件路径。",historyPreviewUnsupported:"这个历史文件不能作为文本比较。",searchInvalid:"请输入有效的搜索内容。",gitUnavailable:"Git 集成功能不可用。请在宿主机安装 Git,或修正配置中的 git.binary 后重试。",formatterUnavailable:"宿主机未安装 tex-fmt。请访问 https://github.com/wgunderwood/tex-fmt 安装后重启 TexLite。",formatFailed:"tex-fmt 无法格式化这段源码。",mainDocumentInvalid:"所选文件不是有效的 LaTeX 主文档。",compileSnapshotBusy:"源码尚未完成稳定保存,请稍后再试编译。"},vp={copyright:"© {{year}}",credit:"Designed and developed by CHEN Zhongpu"},Sp={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 命令"},Cp={common:cp,auth:lp,projects:dp,users:up,editor:hp,navigation:fp,history:pp,projectSettings:mp,git:gp,metrics:yp,tags:wp,errors:xp,apiErrors:bp,footer:vp,completions:Sp};he.use(Il).use(tf).init({resources:{en:{translation:ap},zh:{translation:Cp}},fallbackLng:"en",supportedLngs:["en","zh"],nonExplicitSupportedLngs:!0,interpolation:{escapeValue:!1},detection:{order:["localStorage","navigator"],caches:["localStorage"]}});class Ko 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 Ko(Go(r,n.status),n.status,Ml(r));return r}function Go(t,e,n="errors.request"){const s=typeof t=="object"&&t!==null&&"error"in t&&typeof t.error=="string"?t.error:"",r=Ml(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_TARGET_CONFLICT:"apiErrors.historyTargetConflict",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",COMPILE_SNAPSHOT_BUSY:"apiErrors.compileSnapshotBusy",COMPILE_CLEAN_BUSY:"editor.cleanBusy"}[r]??`errors.codes.${r}`;if(he.exists(i))return he.t(i,{status:e,...typeof t=="object"&&t!==null?t:{}})}return he.resolvedLanguage?.startsWith("zh")&&s?s:he.t(n,{status:e})}function Ml(t){return typeof t!="object"||t===null||!("code"in t)||typeof t.code!="string"?null:t.code}var jp=Object.defineProperty,Ds=(t,e)=>jp(t,"name",{value:e,configurable:!0}),$l=!!(typeof window<"u"&&window.document&&window.document.createElement);function gn(t,e,{checkForDefaultPrevented:n=!0}={}){return Ds(function(r){if(t?.(r),n===!1||!r||!r.defaultPrevented)return e?.(r)},"handleEvent")}Ds(gn,"composeEventHandlers");function kp(t){if(!$l)throw new Error("Cannot access window outside of the DOM");return t?.ownerDocument?.defaultView??window}Ds(kp,"getOwnerWindow");function yo(t){if(!$l)throw new Error("Cannot access document outside of the DOM");return t?.ownerDocument??document}Ds(yo,"getOwnerDocument");function Ul(t,e=!1){const{activeElement:n}=yo(t);if(!n?.nodeName)return null;if(zl(n)&&n.contentDocument)return Ul(n.contentDocument.body,e);if(e){const s=n.getAttribute("aria-activedescendant");if(s){const r=yo(n).getElementById(s);if(r)return r}}return n}Ds(Ul,"getActiveElement");function zl(t){return t.tagName==="IFRAME"}Ds(zl,"isFrame");var Ep=Object.defineProperty,Jo=(t,e)=>Ep(t,"name",{value:e,configurable:!0});function wo(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}Jo(wo,"setRef");function Bl(...t){return e=>{let n=!1;const s=t.map(r=>{const i=wo(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():wo(t[r],null)}}}}Jo(Bl,"composeRefs");function Ts(...t){return h.useCallback(Bl(...t),t)}Jo(Ts,"useComposedRefs");var Dp=Object.defineProperty,wt=(t,e)=>Dp(t,"name",{value:e,configurable:!0});function Tp(t,e){const n=h.createContext(e);n.displayName=t+"Context";const s=wt(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 wt(r,"useContext"),[s,r]}wt(Tp,"createContext");function Vl(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=wt(u=>{const{scope:p,children:m,...g}=u,w=p?.[t]?.[l]||c,b=h.useMemo(()=>g,Object.values(g));return o.jsx(w.Provider,{value:b,children:m})},"Provider");d.displayName=i+"Provider";function f(u,p,m={}){const{optional:g=!1}=m,w=p?.[t]?.[l]||c,b=h.useContext(w);if(b)return b;if(a!==void 0)return a;if(!g)throw new Error(`\`${u}\` must be used within \`${i}\``)}return wt(f,"useContext"),[d,f]}wt(s,"createContext");const r=wt(()=>{const i=n.map(a=>h.createContext(a));return wt(function(c){const l=c?.[t]||i;return h.useMemo(()=>({[`__scope${t}`]:{...c,[t]:l}}),[c,l])},"useScope")},"createScope");return r.scopeName=t,[s,Hl(r,...e)]}wt(Vl,"createContextScope");function Hl(...t){const e=t[0];if(t.length===1)return e;const n=wt(()=>{const s=t.map(r=>({useScope:r(),scopeName:r.scopeName}));return wt(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}wt(Hl,"composeContextScopes");var yn=globalThis?.document?h.useLayoutEffect:()=>{},Np=Object.defineProperty,Op=(t,e)=>Np(t,"name",{value:e,configurable:!0}),Pp=ir[" useId ".trim().toString()]||(()=>{}),_p=0;function Br(t){const[e,n]=h.useState(Pp());return yn(()=>{t||n(s=>s??String(_p++))},[t]),t||(e?`radix-${e}`:"")}Op(Br,"useId");var Rp=Object.defineProperty,Lp=(t,e)=>Rp(t,"name",{value:e,configurable:!0}),Nc=ir[" useEffectEvent ".trim().toString()],Oc=ir[" useInsertionEffect ".trim().toString()];function ql(t){if(typeof Nc=="function")return Nc(t);const e=h.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof Oc=="function"?Oc(()=>{e.current=t}):yn(()=>{e.current=t}),h.useMemo(()=>((...n)=>e.current?.(...n)),[])}Lp(ql,"useEffectEvent");var Ap=Object.defineProperty,or=(t,e)=>Ap(t,"name",{value:e,configurable:!0}),Fp=ir[" useInsertionEffect ".trim().toString()]||yn;function Wl({prop:t,defaultProp:e,onChange:n=or(()=>{},"onChange"),caller:s}){const[r,i,a]=Kl({defaultProp:e,onChange:n}),c=t!==void 0,l=c?t:r,d=h.useCallback(f=>{if(c){const u=Gl(f)?f(t):f;u!==t&&a.current?.(u)}else i(f)},[c,t,i,a]);return[l,d]}or(Wl,"useControllableState");function Kl({defaultProp:t,onChange:e}){const[n,s]=h.useState(t),r=h.useRef(n),i=h.useRef(e);return Fp(()=>{i.current=e},[e]),h.useEffect(()=>{r.current!==n&&(i.current?.(n),r.current=n)},[n,r]),[n,s,i]}or(Kl,"useUncontrolledState");function Gl(t){return typeof t=="function"}or(Gl,"isFunction");var Pc=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=ql(a),f=[{...n,state:i}];s&&f.push(s);const[u,p]=h.useReducer((b,v)=>{if(v.type===Pc)return{...b,state:v.state};const k=t(b,v);return l&&!Object.is(k.state,b.state)&&d(k.state),k},...f),m=u.state,g=h.useRef(m);h.useEffect(()=>{g.current!==m&&(g.current=m,l||d(m))},[m,g,l]);const w=h.useMemo(()=>r!==void 0?{...u,state:r}:u,[u,r]);return h.useEffect(()=>{l&&!Object.is(r,u.state)&&p({type:Pc,state:r})},[r,u.state,l]),[w,p]}or(Ip,"useControllableStateReducer");var Mp=Object.defineProperty,_t=(t,e)=>Mp(t,"name",{value:e,configurable:!0});function Yo(t){const e=h.forwardRef((n,s)=>{let{children:r,...i}=n,a=null,c=!1;const l=[];xo(r)&&typeof Lr=="function"&&(r=Lr(r._payload)),h.Children.forEach(r,p=>{if(Zl(p)){c=!0;const m=p;let g="child"in m.props?m.props.child:m.props.children;xo(g)&&typeof Lr=="function"&&(g=Lr(g._payload)),a=Up(m,g),l.push(a?.props?.children)}else l.push(p)}),a?a=h.cloneElement(a,void 0,l):!c&&h.Children.count(r)===1&&h.isValidElement(r)&&(a=r);const d=a?Xl(a):void 0,f=Ts(s,d);if(!a){if(r||r===0)throw new Error(c?Vp(t):Bp(t));return r}const u=Yl(i,a.props??{});return a.type!==h.Fragment&&(u.ref=s?f:d),h.cloneElement(a,u)});return e.displayName=`${t}.Slot`,e}_t(Yo,"createSlot");var Jl=Symbol.for("radix.slottable");function $p(t){const e=_t(n=>"child"in n?n.children(n.child):n.children,"Slottable");return e.displayName=`${t}.Slottable`,e.__radixId=Jl,e}_t($p,"createSlottable");var Up=_t((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 Yl(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}}_t(Yl,"mergeProps");function Xl(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)}_t(Xl,"getElementRef");function Zl(t){return h.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Jl}_t(Zl,"isSlottable");var zp=Symbol.for("react.lazy");function xo(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===zp&&"_payload"in t&&Ql(t._payload)}_t(xo,"isLazyComponent");function Ql(t){return typeof t=="object"&&t!==null&&"then"in t}_t(Ql,"isPromiseLike");var Bp=_t(t=>`${t} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),Vp=_t(t=>`${t} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),Lr=ir[" use ".trim().toString()],Hp=Object.defineProperty,qp=(t,e)=>Hp(t,"name",{value:e,configurable:!0}),Wp=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ln=Wp.reduce((t,e)=>{const n=Yo(`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 ed(t,e){t&&Ol.flushSync(()=>t.dispatchEvent(e))}qp(ed,"dispatchDiscreteCustomEvent");var Kp=Object.defineProperty,Gp=(t,e)=>Kp(t,"name",{value:e,configurable:!0});function ms(t){const e=h.useRef(t);return h.useEffect(()=>{e.current=t}),h.useMemo(()=>((...n)=>e.current?.(...n)),[])}Gp(ms,"useCallbackRef");var Jp=Object.defineProperty,Be=(t,e)=>Jp(t,"name",{value:e,configurable:!0}),bo="dismissableLayer.update",Yp="dismissableLayer.pointerDownOutside",Xp="dismissableLayer.focusOutside",_c,td=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Zp=h.forwardRef(Be(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(td),[p,m]=h.useState(null),g=p?.ownerDocument??globalThis?.document,[,w]=h.useState({}),b=Ts(n,m),v=Array.from(u.layers),[k]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),P=k?v.indexOf(k):-1,N=p?v.indexOf(p):-1,O=u.layersWithOutsidePointerEventsDisabled.size>0,W=N>=P,E=h.useRef(!1),J=sd(R=>{a?.(R),l?.(R),R.defaultPrevented||d?.()},{ownerDocument:g,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:E,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:h.useCallback(R=>{if(!(R instanceof Node))return!1;const _=[...u.branches].some(L=>L.contains(R));return W&&!_},[u.branches,W])}),C=rd(R=>{if(r&&E.current)return;const _=R.target;[...u.branches].some(j=>j.contains(_))||(c?.(R),l?.(R),R.defaultPrevented||d?.())},g),V=p?N===v.length-1:!1,Z=ms(R=>{R.key==="Escape"&&(i?.(R),!R.defaultPrevented&&d&&(R.preventDefault(),d()))});return h.useEffect(()=>{if(V)return g.addEventListener("keydown",Z,{capture:!0}),()=>g.removeEventListener("keydown",Z,{capture:!0})},[g,V,Z]),h.useEffect(()=>{if(p)return s&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(_c=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),vo(),()=>{s&&(u.layersWithOutsidePointerEventsDisabled.delete(p),u.layersWithOutsidePointerEventsDisabled.size===0&&(g.body.style.pointerEvents=_c))}},[p,g,s,u]),h.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),vo())},[p,u]),h.useEffect(()=>{const R=Be(()=>w({}),"handleUpdate");return document.addEventListener(bo,R),()=>document.removeEventListener(bo,R)},[]),o.jsx(Ln.div,{...f,ref:b,style:{pointerEvents:O?W?"auto":"none":void 0,...e.style},onFocusCapture:gn(e.onFocusCapture,C.onFocusCapture),onBlurCapture:gn(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:gn(e.onPointerDownCapture,J.onPointerDownCapture)})},"DismissableLayer"));function nd(){const t=h.useContext(td),[e,n]=h.useState(null);return h.useEffect(()=>{if(e)return t.dismissableSurfaces.add(e),()=>{t.dismissableSurfaces.delete(e)}},[e,t.dismissableSurfaces]),n}Be(nd,"useDismissableLayerSurface");var Qp=Be(()=>!0,"IS_TRUE");function sd(t,e){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:s=!1,isDeferredPointerDownOutsideRef:r,dismissableSurfaces:i,shouldHandlePointerDownOutside:a=Qp}=e,c=ms(t),l=h.useRef(!1),d=h.useRef(!1),f=h.useRef(new Map),u=h.useRef(()=>{});return h.useEffect(()=>{function p(){d.current=!1,r.current=!1,f.current.clear()}Be(p,"resetOutsideInteraction");function m(){return Array.from(f.current.values()).some(Boolean)}Be(m,"isOutsideInteractionIntercepted");function g(P){if(!d.current)return;const N=P.target;N instanceof Node&&[...i].some(W=>W.contains(N))||f.current.set(P.type,!0),P.type==="click"&&window.setTimeout(()=>{d.current&&u.current()},0)}Be(g,"handleInteractionCapture");function w(P){d.current&&f.current.set(P.type,!1)}Be(w,"handleInteractionBubble");const b=Be(P=>{if(P.target&&!l.current){let N=function(){n.removeEventListener("click",u.current);const W=m();p(),W||Xo(Yp,c,O,{discrete:!0})};if(Be(N,"handleAndDispatchPointerDownOutsideEvent"),!a(P.target)){n.removeEventListener("click",u.current),p(),l.current=!1;return}const O={originalEvent:P};d.current=!0,r.current=s&&P.button===0,f.current.clear(),!s||P.button!==0?N():(n.removeEventListener("click",u.current),u.current=N,n.addEventListener("click",u.current,{once:!0}))}else n.removeEventListener("click",u.current),p();l.current=!1},"handlePointerDown"),v=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const P of v)n.addEventListener(P,g,!0),n.addEventListener(P,w);const k=window.setTimeout(()=>{n.addEventListener("pointerdown",b)},0);return()=>{window.clearTimeout(k),n.removeEventListener("pointerdown",b),n.removeEventListener("click",u.current);for(const P of v)n.removeEventListener(P,g,!0),n.removeEventListener(P,w)}},[n,c,s,r,i,a]),{onPointerDownCapture:Be(()=>l.current=!0,"onPointerDownCapture")}}Be(sd,"usePointerDownOutside");function rd(t,e=globalThis?.document){const n=ms(t),s=h.useRef(!1);return h.useEffect(()=>{const r=Be(i=>{i.target&&!s.current&&Xo(Xp,n,{originalEvent:i},{discrete:!1})},"handleFocus");return e.addEventListener("focusin",r),()=>e.removeEventListener("focusin",r)},[e,n]),{onFocusCapture:Be(()=>s.current=!0,"onFocusCapture"),onBlurCapture:Be(()=>s.current=!1,"onBlurCapture")}}Be(rd,"useFocusOutside");function vo(){const t=new CustomEvent(bo);document.dispatchEvent(t)}Be(vo,"dispatchUpdate");function Xo(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?ed(r,i):r.dispatchEvent(i)}Be(Xo,"handleAndDispatchCustomEvent");var em=Object.defineProperty,st=(t,e)=>em(t,"name",{value:e,configurable:!0}),Ki="focusScope.autoFocusOnMount",Gi="focusScope.autoFocusOnUnmount",Rc={bubbles:!1,cancelable:!0},tm=h.forwardRef(st(function(e,n){const{loop:s=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...c}=e,[l,d]=h.useState(null),f=ms(i),u=ms(a),p=h.useRef(null),m=Ts(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 O=N.target;l.contains(O)?p.current=O:Qt(p.current,{select:!0})},v=function(N){if(g.paused||!l)return;const O=N.relatedTarget;O!==null&&(l.contains(O)||Qt(p.current,{select:!0}))},k=function(N){if(document.activeElement===document.body)for(const W of N)W.removedNodes.length>0&&Qt(l)};st(b,"handleFocusIn"),st(v,"handleFocusOut"),st(k,"handleMutations"),document.addEventListener("focusin",b),document.addEventListener("focusout",v);const P=new MutationObserver(k);return l&&P.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",b),document.removeEventListener("focusout",v),P.disconnect()}}},[r,l,g.paused]),h.useEffect(()=>{if(l){Lc.add(g);const b=document.activeElement;if(!l.contains(b)){const k=new CustomEvent(Ki,Rc);l.addEventListener(Ki,f),l.dispatchEvent(k),k.defaultPrevented||(id(dd(Zo(l)),{select:!0}),document.activeElement===b&&Qt(l))}return()=>{l.removeEventListener(Ki,f),setTimeout(()=>{const k=new CustomEvent(Gi,Rc);l.addEventListener(Gi,u),l.dispatchEvent(k),k.defaultPrevented||Qt(b??document.body,{select:!0}),l.removeEventListener(Gi,u),Lc.remove(g)},0)}}},[l,f,u,g]);const w=h.useCallback(b=>{if(!s&&!r||g.paused)return;const v=b.key==="Tab"&&!b.altKey&&!b.ctrlKey&&!b.metaKey,k=document.activeElement;if(v&&k){const P=b.currentTarget,[N,O]=od(P);N&&O?!b.shiftKey&&k===O?(b.preventDefault(),s&&Qt(N,{select:!0})):b.shiftKey&&k===N&&(b.preventDefault(),s&&Qt(O,{select:!0})):k===P&&b.preventDefault()}},[s,r,g.paused]);return o.jsx(Ln.div,{tabIndex:-1,...c,ref:m,onKeyDown:w})},"FocusScope"));function id(t,{select:e=!1}={}){const n=document.activeElement;for(const s of t)if(Qt(s,{select:e}),document.activeElement!==n)return}st(id,"focusFirst");function od(t){const e=Zo(t),n=So(e,t),s=So(e.reverse(),t);return[n,s]}st(od,"getTabbableEdges");function Zo(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:st(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}st(Zo,"getTabbableCandidates");function So(t,e){const n=typeof e.checkVisibility=="function"&&e.checkVisibility({checkVisibilityCSS:!0});for(const s of t)if(!(n?!s.checkVisibility({checkVisibilityCSS:!0}):ad(s,{upTo:e})))return s}st(So,"findVisible");function ad(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}st(ad,"isHidden");function cd(t){return t instanceof HTMLInputElement&&"select"in t}st(cd,"isSelectableInput");function Qt(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&cd(t)&&e&&t.select()}}st(Qt,"focus");var Lc=ld();function ld(){let t=[];return{add(e){const n=t[0];e!==n&&n?.pause(),t=Co(t,e),t.unshift(e)},remove(e){t=Co(t,e),t[0]?.resume()}}}st(ld,"createFocusScopesStack");function Co(t,e){const n=[...t],s=n.indexOf(e);return s!==-1&&n.splice(s,1),n}st(Co,"arrayRemove");function dd(t){return t.filter(e=>e.tagName!=="A")}st(dd,"removeLinks");var nm=Object.defineProperty,sm=(t,e)=>nm(t,"name",{value:e,configurable:!0}),rm=h.forwardRef(sm(function(e,n){const{container:s,...r}=e,[i,a]=h.useState(!1);yn(()=>a(!0),[]);const c=s||i&&globalThis?.document?.body;return c?Ol.createPortal(o.jsx(Ln.div,{...r,ref:n}),c):null},"Portal")),im=Object.defineProperty,nn=(t,e)=>im(t,"name",{value:e,configurable:!0});function ud(t,e){return h.useReducer((n,s)=>e[n][s]??n,t)}nn(ud,"useStateMachine");var Qo=nn(t=>{const{present:e,children:n}=t,s=hd(e),r=typeof n=="function"?n({present:s.isPresent}):h.Children.only(n),i=fd(s.ref,pd(r));return typeof n=="function"||s.isPresent?h.cloneElement(r,{ref:i}):null},"Presence");function hd(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]=ud(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??es(s.current),a.current=void 0):i.current="none"},[l]),yn(()=>{const f=s.current,u=r.current;if(u!==t){const m=i.current,g=es(f);t?(a.current=g,d("MOUNT")):g==="none"||f?.display==="none"?d("UNMOUNT"):d(u&&m!==g?"ANIMATION_OUT":"UNMOUNT"),r.current=t}},[t,d]),yn(()=>{if(e){let f;const u=e.ownerDocument.defaultView??window,p=nn(g=>{const b=es(s.current).includes(CSS.escape(g.animationName));if(g.target===e&&b&&(d("ANIMATION_END"),!r.current)){const v=e.style.animationFillMode;e.style.animationFillMode="forwards",f=u.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=v)})}},"handleAnimationEnd"),m=nn(g=>{g.target===e&&(i.current=es(s.current))},"handleAnimationStart");return e.addEventListener("animationstart",m),e.addEventListener("animationcancel",p),e.addEventListener("animationend",p),()=>{u.clearTimeout(f),e.removeEventListener("animationstart",m),e.removeEventListener("animationcancel",p),e.removeEventListener("animationend",p)}}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=es(u)}else s.current=null;n(f)},[])}}nn(hd,"usePresence");function jo(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}nn(jo,"setRef");function fd(...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=jo(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():jo(s[a],null)}}},[])}nn(fd,"useStableComposedRefs");function es(t){return t?.animationName||"none"}nn(es,"getAnimationName");function pd(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)}nn(pd,"getElementRef");var om=Object.defineProperty,ea=(t,e)=>om(t,"name",{value:e,configurable:!0}),Ar=0,Yn=null;function am(t){return ta(),t.children}ea(am,"FocusGuards");function ta(){h.useEffect(()=>{Yn||(Yn={start:ko(),end:ko()});const{start:t,end:e}=Yn;return document.body.firstElementChild!==t&&document.body.insertAdjacentElement("afterbegin",t),document.body.lastElementChild!==e&&document.body.insertAdjacentElement("beforeend",e),Ar++,()=>{Ar===1&&(Yn?.start.remove(),Yn?.end.remove(),Yn=null),Ar=Math.max(0,Ar-1)}},[])}ea(ta,"useFocusGuards");function ko(){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}ea(ko,"createFocusGuard");var cm=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Xn=new WeakMap,Fr=new WeakMap,Ir={},Ji=0,md=function(t){return t&&(t.host||md(t.parentNode))},lm=function(t,e){return e.map(function(n){if(t.contains(n))return n;var s=md(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})},dm=function(t,e,n,s){var r=lm(e,Array.isArray(t)?t:[t]);Ir[n]||(Ir[n]=new WeakMap);var i=Ir[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(p){if(c.has(p))f(p);else try{var m=p.getAttribute(s),g=m!==null&&m!=="false",w=(Xn.get(p)||0)+1,b=(i.get(p)||0)+1;Xn.set(p,w),i.set(p,b),a.push(p),w===1&&g&&Fr.set(p,!0),b===1&&p.setAttribute(n,"true"),g||p.setAttribute(s,"true")}catch(v){console.error("aria-hidden: cannot operate on ",p,v)}})};return f(e),c.clear(),Ji++,function(){a.forEach(function(u){var p=Xn.get(u)-1,m=i.get(u)-1;Xn.set(u,p),i.set(u,m),p||(Fr.has(u)||u.removeAttribute(s),Fr.delete(u)),m||u.removeAttribute(n)}),Ji--,Ji||(Xn=new WeakMap,Xn=new WeakMap,Fr=new WeakMap,Ir={})}},um=function(t,e,n){n===void 0&&(n="data-aria-hidden");var s=Array.from(Array.isArray(t)?t:[t]),r=cm(t);return r?(s.push.apply(s,Array.from(r.querySelectorAll("[aria-live], script"))),dm(s,r,n,"aria-hidden")):function(){return null}},hm=Object.defineProperty,vt=(t,e)=>hm(t,"name",{value:e,configurable:!0}),na="Dialog",[gd,mv]=Vl(na),[fm,zt]=gd(na),pm=vt(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]=Wl({prop:s,defaultProp:r??!1,onChange:i,caller:na}),[u,p]=h.useState(0),[m,g]=h.useState(0);return o.jsx(fm,{scope:e,triggerRef:c,contentRef:l,contentId:Br(),titleId:Br(),descriptionId:Br(),titlePresent:u>0,descriptionPresent:m>0,setTitleCount:p,setDescriptionCount:g,open:d,onOpenChange:f,onOpenToggle:h.useCallback(()=>f(w=>!w),[f]),modal:a,children:n})},"Dialog"),yd="DialogPortal",[mm,wd]=gd(yd,{forceMount:void 0}),gm=vt(t=>{const{__scopeDialog:e,forceMount:n,children:s,container:r}=t,i=zt(yd,e);return o.jsx(mm,{scope:e,forceMount:n,children:h.Children.map(s,a=>o.jsx(Qo,{present:n||i.open,children:o.jsx(rm,{asChild:!0,container:r,children:a})}))})},"DialogPortal"),Eo="DialogOverlay",ym=h.forwardRef(vt(function(e,n){const s=wd(Eo,e.__scopeDialog),{forceMount:r=s.forceMount,...i}=e,a=zt(Eo,e.__scopeDialog);return a.modal?o.jsx(Qo,{present:r||a.open,children:o.jsx(xm,{...i,ref:n})}):null},"DialogOverlay")),wm=Yo("DialogOverlay.RemoveScroll"),xm=h.forwardRef(vt(function(e,n){const{__scopeDialog:s,...r}=e,i=zt(Eo,s),a=nd(),c=Ts(n,a);return o.jsx(nf,{as:wm,allowPinchZoom:!0,shards:[i.contentRef],children:o.jsx(Ln.div,{"data-state":sa(i.open),...r,ref:c,style:{pointerEvents:"auto",...r.style}})})},"DialogOverlayImpl")),Ws="DialogContent",bm=h.forwardRef(vt(function(e,n){const s=wd(Ws,e.__scopeDialog),{forceMount:r=s.forceMount,...i}=e,a=zt(Ws,e.__scopeDialog);return o.jsx(Qo,{present:r||a.open,children:a.modal?o.jsx(vm,{...i,ref:n}):o.jsx(Sm,{...i,ref:n})})},"DialogContent")),vm=h.forwardRef(vt(function(e,n){const s=zt(Ws,e.__scopeDialog),r=h.useRef(null),i=Ts(n,s.contentRef,r);return h.useEffect(()=>{const a=r.current;if(a)return um(a)},[]),o.jsx(xd,{...e,ref:i,trapFocus:s.open,disableOutsidePointerEvents:s.open,onCloseAutoFocus:gn(e.onCloseAutoFocus,a=>{a.preventDefault(),s.triggerRef.current?.focus()}),onPointerDownOutside:gn(e.onPointerDownOutside,a=>{const c=a.detail.originalEvent,l=c.button===0&&c.ctrlKey===!0;(c.button===2||l)&&a.preventDefault()}),onFocusOutside:gn(e.onFocusOutside,a=>a.preventDefault())})},"DialogContentModal")),Sm=h.forwardRef(vt(function(e,n){const s=zt(Ws,e.__scopeDialog),r=h.useRef(!1),i=h.useRef(!1);return o.jsx(xd,{...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")),xd=h.forwardRef(vt(function(e,n){const{__scopeDialog:s,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...c}=e,l=zt(Ws,s);return ta(),o.jsx(o.Fragment,{children:o.jsx(tm,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:o.jsx(Zp,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionPresent?l.descriptionId:void 0,"aria-labelledby":l.titlePresent?l.titleId:void 0,"data-state":sa(l.open),...c,ref:n,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1)})})})},"DialogContentImpl")),Cm="DialogTitle",jm=h.forwardRef(vt(function(e,n){const{__scopeDialog:s,...r}=e,i=zt(Cm,s),{setTitleCount:a}=i;return yn(()=>(a(c=>c+1),()=>a(c=>c-1)),[a]),o.jsx(Ln.h2,{id:i.titleId,...r,ref:n})},"DialogTitle")),km="DialogDescription",Em=h.forwardRef(vt(function(e,n){const{__scopeDialog:s,...r}=e,i=zt(km,s),{setDescriptionCount:a}=i;return yn(()=>(a(c=>c+1),()=>a(c=>c-1)),[a]),o.jsx(Ln.p,{id:i.descriptionId,...r,ref:n})},"DialogDescription")),Dm="DialogClose",Tm=h.forwardRef(vt(function(e,n){const{__scopeDialog:s,...r}=e,i=zt(Dm,s);return o.jsx(Ln.button,{type:"button",...r,ref:n,onClick:gn(e.onClick,()=>i.onOpenChange(!1))})},"DialogClose"));function sa(t){return t?"open":"closed"}vt(sa,"getState");function Ve({open:t,title:e,description:n,onOpenChange:s,children:r,footer:i,wide:a,extraWide:c,className:l}){const{t:d}=Ae();return o.jsx(pm,{open:t,onOpenChange:s,children:o.jsxs(gm,{children:[o.jsx(ym,{className:"dialog-overlay"}),o.jsxs(bm,{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(jm,{children:e}),n&&o.jsx(Em,{children:n})]}),o.jsx(Tm,{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 gs({open:t,title:e,description:n,confirmLabel:s,danger:r,onCancel:i,onConfirm:a}){const{t:c}=Ae();return o.jsx(Ve,{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 ra({compact:t=!1}){const{i18n:e,t:n}=Ae(),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 Nm=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),bd=(...t)=>t.filter((e,n,s)=>!!e&&e.trim()!==""&&s.indexOf(e)===n).join(" ").trim();var Om={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 Pm=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,...Om,width:e,height:e,stroke:t,strokeWidth:s?Number(n)*24/Number(e):n,className:bd("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(Pm,{ref:i,iconNode:e,className:bd(`lucide-${Nm(t)}`,s),...r}));return n.displayName=`${t}`,n};const _m=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 vd=F("AlignLeft",[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);const Rm=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 Ac=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 Lm=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 Sd=F("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const Yi=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 Do=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 Am=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 Fm=F("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Cd=F("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const jd=F("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);const ia=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 Mm=F("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);const $m=F("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const oa=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 Fc=F("Columns2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]);const Um=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 zm=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 Ks=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 To=F("Eraser",[["path",{d:"m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21",key:"182aya"}],["path",{d:"M22 21H7",key:"t4ddhn"}],["path",{d:"m5 11 9 9",key:"1mo9qw"}]]);const No=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 Bm=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 Vm=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 rs=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 Oo=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 kd=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 qm=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 Xi=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 Ed=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 Wm=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 Km=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 Tt=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 Dd=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 Ic=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 Td=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 Mc=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 Jm=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 Ym=F("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);const Xm=F("PanelRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);const Zm=F("PanelsTopLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]]);const Po=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 Qm=F("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const eg=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 tg=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 Yr=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 _o=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 ng=F("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);const sg=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 Ro=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 rg=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 ig=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 $c=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 wn=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 ys=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 Uc=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 Xr=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 Nd=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 Gs=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 og=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 Zr=F("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Qr=[{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'}],Xt={font:"jetbrains",fontSize:14,lineHeight:1.65,lineWrapping:!0,spellCheck:!0,vimMode:!1,formatOnCompile:!1,openFilesInTabs:!1},ag="texlite-editor-preferences";function Od(t,e){return`${ag}:${encodeURIComponent(t)}:${encodeURIComponent(e)}`}function gv(t){return Qr.find(e=>e.id===t)?.stack??Qr[0].stack}function zc(t,e){try{const n=JSON.parse(localStorage.getItem(Od(t,e))??"{}");return{font:Qr.some(s=>s.id===n.font)?n.font:Xt.font,fontSize:[12,13,14,15,16,18,20].includes(Number(n.fontSize))?Number(n.fontSize):Xt.fontSize,lineHeight:[1.45,1.65,1.85].includes(Number(n.lineHeight))?Number(n.lineHeight):Xt.lineHeight,lineWrapping:typeof n.lineWrapping=="boolean"?n.lineWrapping:Xt.lineWrapping,spellCheck:typeof n.spellCheck=="boolean"?n.spellCheck:Xt.spellCheck,vimMode:typeof n.vimMode=="boolean"?n.vimMode:Xt.vimMode,formatOnCompile:typeof n.formatOnCompile=="boolean"?n.formatOnCompile:Xt.formatOnCompile,openFilesInTabs:typeof n.openFilesInTabs=="boolean"?n.openFilesInTabs:Xt.openFilesInTabs}}catch{return Xt}}function cg(t,e,n){localStorage.setItem(Od(t,e),JSON.stringify(n))}const lg=/\.(?:tex|bib|cls|sty)$/i;function Zi(t){return lg.test(t)}function dg(t){return t.match(/(?:\r?\n)+$/)?.[0]??""}function ug(t,e){const n=dg(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 Bc(t,e,n=0){if(t===e)return[];const{default:s}=await rn(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 hg(t,e=null){const n=Vc(t),r=e==="succeeded"||e===null&&pg(t)?[]:Hc(n.filter(qc)),i=Vc(fg(t));return{warnings:Hc(i.filter(c=>!qc(c)&&mg(c))),errors:r}}function Vc(t){return t.split(`
7
- `).map(e=>e.trim()).filter(Boolean)}function Hc(t){return[...new Set(t)]}function fg(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 pg(t){return/Latexmk: All targets .* are up-to-date/i.test(t)&&/Output written on .*\.pdf/i.test(t)}function qc(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 mg(t){return/\bwarnings?\b|overfull|underfull|badness/i.test(t)}const gg=/^\/projects?\/([^/]+)\/?$/;function Qi(t){return`/project/${encodeURIComponent(t)}`}function Mr(t){const e=gg.exec(t);if(!e)return null;try{const n=decodeURIComponent(e[1]);return n&&!n.includes("/")?n:null}catch{return null}}function yg(t){if(!t||typeof t!="object")return!1;const e=t;return e.texliteRoute==="project"&&typeof e.projectId=="string"&&typeof e.fromDashboard=="boolean"}function q(t){return t instanceof Error?t.message:he.t("errors.generic")}const lt=()=>new Map,Lo=t=>{const e=lt();return t.forEach((n,s)=>{e.set(s,n)}),e},Bt=(t,e,n)=>{let s=t.get(e);return s===void 0&&t.set(e,s=n()),s},wg=(t,e)=>{const n=[];for(const[s,r]of t)n.push(e(r,s));return n},xg=(t,e)=>{for(const[n,s]of t)if(e(s,n))return!0;return!1},xn=()=>new Set,eo=t=>t[t.length-1],bg=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},sn=Array.from,aa=(t,e)=>{for(let n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0},ca=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1},vg=(t,e)=>{const n=new Array(t);for(let s=0;s<t;s++)n[s]=e(s,n);return n},ws=Array.isArray;class la{constructor(){this._observers=lt()}on(e,n){return Bt(this._observers,e,xn).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 sn((this._observers.get(e)||lt()).values()).forEach(s=>s(...n))}destroy(){this._observers=lt()}}class Pd{constructor(){this._observers=lt()}on(e,n){Bt(this._observers,e,xn).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 sn((this._observers.get(e)||lt()).values()).forEach(s=>s(...n))}destroy(){this._observers=lt()}}const Ot=Math.floor,Vr=Math.abs,da=(t,e)=>t<e?t:e,An=(t,e)=>t>e?t:e,Sg=Math.pow,_d=t=>t!==0?t<0:1/t<0,Wc=1,Kc=2,to=4,no=8,Js=32,en=64,ht=128,mi=31,Ao=63,On=127,Cg=2147483647,ei=Number.MAX_SAFE_INTEGER,Gc=Number.MIN_SAFE_INTEGER,jg=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&Ot(t)===t),Rd=String.fromCharCode,kg=t=>t.toLowerCase(),Eg=/^\s*/g,Dg=t=>t.replace(Eg,""),Tg=/([A-Z])/g,Jc=(t,e)=>Dg(t.replace(Tg,n=>`${e}${kg(n)}`)),Ng=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},Ys=typeof TextEncoder<"u"?new TextEncoder:null,Og=t=>Ys.encode(t),Pg=Ys?Og:Ng;let Hs=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Hs&&Hs.decode(new Uint8Array).length===1&&(Hs=null);const _g=(t,e)=>vg(e,()=>t).join("");class ar{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Le=()=>new ar,ua=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},be=t=>{const e=new Uint8Array(ua(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},Rg=(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(An(n,e)*2),t.cpos=0)},ze=(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},Fo=ze,U=(t,e)=>{for(;e>On;)ze(t,ht|On&e),e=Ot(e/128);ze(t,On&e)},ha=(t,e)=>{const n=_d(e);for(n&&(e=-e),ze(t,(e>Ao?ht:0)|(n?en:0)|Ao&e),e=Ot(e/64);e>0;)ze(t,(e>On?ht:0)|On&e),e=Ot(e/128)},Io=new Uint8Array(3e4),Lg=Io.length/3,Ag=(t,e)=>{if(e.length<Lg){const n=Ys.encodeInto(e,Io).written||0;U(t,n);for(let s=0;s<n;s++)ze(t,Io[s])}else Te(t,Pg(e))},Fg=(t,e)=>{const n=unescape(encodeURIComponent(e)),s=n.length;U(t,s);for(let r=0;r<s;r++)ze(t,n.codePointAt(r))},tn=Ys&&Ys.encodeInto?Ag:Fg,gi=(t,e)=>{const n=t.cbuf.length,s=t.cpos,r=da(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(An(n*2,i)),t.cbuf.set(e.subarray(r)),t.cpos=i)},Te=(t,e)=>{U(t,e.byteLength),gi(t,e)},fa=(t,e)=>{Rg(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},Ig=(t,e)=>fa(t,4).setFloat32(0,e,!1),Mg=(t,e)=>fa(t,8).setFloat64(0,e,!1),$g=(t,e)=>fa(t,8).setBigInt64(0,e,!1),Yc=new DataView(new ArrayBuffer(4)),Ug=t=>(Yc.setFloat32(0,t),Yc.getFloat32(0)===t),Xs=(t,e)=>{switch(typeof e){case"string":ze(t,119),tn(t,e);break;case"number":jg(e)&&Vr(e)<=Cg?(ze(t,125),ha(t,e)):Ug(e)?(ze(t,124),Ig(t,e)):(ze(t,123),Mg(t,e));break;case"bigint":ze(t,122),$g(t,e);break;case"object":if(e===null)ze(t,126);else if(ws(e)){ze(t,117),U(t,e.length);for(let n=0;n<e.length;n++)Xs(t,e[n])}else if(e instanceof Uint8Array)ze(t,116),Te(t,e);else{ze(t,118);const n=Object.keys(e);U(t,n.length);for(let s=0;s<n.length;s++){const r=n[s];tn(t,r),Xs(t,e[r])}}break;case"boolean":ze(t,e?120:121);break;default:ze(t,127)}};class Xc extends ar{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&U(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const Zc=t=>{t.count>0&&(ha(t.encoder,t.count===1?t.s:-t.s),t.count>1&&U(t.encoder,t.count-2))};class Hr{constructor(){this.encoder=new ar,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Zc(this),this.count=1,this.s=e)}toUint8Array(){return Zc(this),be(this.encoder)}}const Qc=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);ha(t.encoder,e),t.count>1&&U(t.encoder,t.count-2)}};class so{constructor(){this.encoder=new ar,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Qc(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Qc(this),be(this.encoder)}}class zg{constructor(){this.sarr=[],this.s="",this.lensE=new Hr}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 ar;return this.sarr.push(this.s),this.s="",tn(e,this.sarr.join("")),gi(e,this.lensE.toUint8Array()),be(e)}}const Pt=t=>new Error(t),Nt=()=>{throw Pt("Method unimplemented")},ft=()=>{throw Pt("Unexpected case")},Ld=Pt("Unexpected end of array"),Ad=Pt("Integer out of Range");class yi{constructor(e){this.arr=e,this.pos=0}}const Sn=t=>new yi(t),Bg=t=>t.pos!==t.arr.length,Vg=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},Xe=t=>Vg(t,Y(t)),xs=t=>t.arr[t.pos++],Y=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&On)*n,n*=128,r<ht)return e;if(e>ei)throw Ad}throw Ld},pa=t=>{let e=t.arr[t.pos++],n=e&Ao,s=64;const r=(e&en)>0?-1:1;if((e&ht)===0)return r*n;const i=t.arr.length;for(;t.pos<i;){if(e=t.arr[t.pos++],n=n+(e&On)*s,s*=128,e<ht)return r*n;if(n>ei)throw Ad}throw Ld},Hg=t=>{let e=Y(t);if(e===0)return"";{let n=String.fromCodePoint(xs(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(xs(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))}},qg=t=>Hs.decode(Xe(t)),Ze=Hs?qg:Hg,ma=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},Wg=t=>ma(t,4).getFloat32(0,!1),Kg=t=>ma(t,8).getFloat64(0,!1),Gg=t=>ma(t,8).getBigInt64(0,!1),Jg=[t=>{},t=>null,pa,Wg,Kg,Gg,t=>!1,t=>!0,Ze,t=>{const e=Y(t),n={};for(let s=0;s<e;s++){const r=Ze(t);n[r]=Zs(t)}return n},t=>{const e=Y(t),n=[];for(let s=0;s<e;s++)n.push(Zs(t));return n},Xe],Zs=t=>Jg[127-xs(t)](t);class el extends yi{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Bg(this)?this.count=Y(this)+1:this.count=-1),this.count--,this.s}}class qr extends yi{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=pa(this);const e=_d(this.s);this.count=1,e&&(this.s=-this.s,this.count=Y(this)+2)}return this.count--,this.s}}class ro extends yi{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=pa(this),n=e&1;this.diff=Ot(e/2),this.count=1,n&&(this.count=Y(this)+2)}return this.s+=this.diff,this.count--,this.s}}class Yg{constructor(e){this.decoder=new qr(e),this.str=Ze(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),Fd=()=>Xg(new Uint32Array(1))[0],Zg="10000000-1000-4000-8000"+-1e11,Qg=()=>Zg.replace(/[018]/g,t=>(t^Fd()&15>>t/4).toString(16)),bn=Date.now,bs=t=>new Promise(t);Promise.all.bind(Promise);const tl=t=>t===void 0?null:t;class ey{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let Id=new ey,ga=!0;try{typeof localStorage<"u"&&localStorage&&(Id=localStorage,ga=!1)}catch{}const Md=Id,ty=t=>ga||addEventListener("storage",t),ny=t=>ga||removeEventListener("storage",t),Qs=Symbol("Equality"),$d=(t,e)=>t===e||!!t?.[Qs]?.(e)||!1,sy=t=>typeof t=="object",ry=Object.assign,iy=Object.keys,oy=(t,e)=>{for(const n in t)e(t[n],n)},ay=(t,e)=>{const n=[];for(const s in t)n.push(e(t[s],s));return n},ti=t=>iy(t).length,cy=t=>{for(const e in t)return!1;return!0},cr=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},ya=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),ly=(t,e)=>t===e||ti(t)===ti(e)&&cr(t,(n,s)=>(n!==void 0||ya(e,s))&&$d(e[s],n)),dy=Object.freeze,Ud=t=>{for(const e in t){const n=t[e];(typeof n=="object"||typeof n=="function")&&Ud(t[e])}return dy(t)},wa=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&wa(t,e,n+1)}},uy=t=>t,as=(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[Qs]!=null)return t[Qs](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)||!as(t.get(n),e.get(n)))return!1;break}case void 0:case Object:if(ti(t)!==ti(e))return!1;for(const n in t)if(!ya(t,n)||!as(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(!as(t[n],e[n]))return!1;break;default:return!1}return!0},hy=(t,e)=>e.includes(t);var zd={};const vn=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",Bd=typeof window<"u"&&typeof document<"u"&&!vn;let It;const fy=()=>{if(It===void 0)if(vn){It=lt();const t=process.argv;let e=null;for(let n=0;n<t.length;n++){const s=t[n];s[0]==="-"?(e!==null&&It.set(e,""),e=s):e!==null&&(It.set(e,s),e=null)}e!==null&&It.set(e,"")}else typeof location=="object"?(It=lt(),(location.search||"?").slice(1).split("&").forEach(t=>{if(t.length!==0){const[e,n]=t.split("=");It.set(`--${Jc(e,"-")}`,n),It.set(`-${Jc(e,"-")}`,n)}})):It=lt();return It},Mo=t=>fy().has(t),ni=t=>tl(vn?zd[t.toUpperCase().replaceAll("-","_")]:Md.getItem(t)),Vd=t=>Mo("--"+t)||ni(t)!==null,py=Vd("production"),my=vn&&hy(zd.FORCE_COLOR,["true","1","2"]),gy=my||!Mo("--no-colors")&&!Vd("no-color")&&(!vn||process.stdout.isTTY)&&(!vn||Mo("--color")||ni("COLORTERM")!==null||(ni("TERM")||"").includes("color")),Hd=t=>new Uint8Array(t),yy=(t,e,n)=>new Uint8Array(t,e,n),wy=t=>new Uint8Array(t),xy=t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=Rd(t[n]);return btoa(e)},by=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),vy=t=>{const e=atob(t),n=Hd(e.length);for(let s=0;s<e.length;s++)n[s]=e.charCodeAt(s);return n},Sy=t=>{const e=Buffer.from(t,"base64");return yy(e.buffer,e.byteOffset,e.byteLength)},Cy=Bd?xy:by,jy=Bd?vy:Sy,ky=t=>{const e=Hd(t.byteLength);return e.set(t),e};class Ey{constructor(e,n){this.left=e,this.right=n}}const Zt=(t,e)=>new Ey(t,e),Dy=(t,e)=>t.forEach(n=>e(n.left,n.right)),nl=t=>t.next()>=.5,io=(t,e,n)=>Ot(t.next()*(n+1-e)+e),qd=(t,e,n)=>Ot(t.next()*(n+1-e)+e),xa=(t,e,n)=>qd(t,e,n),Ty=t=>Rd(xa(t,97,122)),Ny=(t,e=0,n=20)=>{const s=xa(t,e,n);let r="";for(let i=0;i<s;i++)r+=Ty(t);return r},oo=(t,e)=>e[xa(t,0,e.length-1)],Oy=Symbol("0schema");class Py{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(_g(" ",(this._rerrs.length-n)*2)+`${s.path!=null?`[${s.path}] `:""}${s.has} doesn't match ${s.expected}. ${s.message}`)}return e.join(`
8
- `)}}const $o=(t,e)=>t===e?!0:t==null||e==null||t.constructor!==e.constructor?!1:t[Qs]?$d(t,e):ws(t)?aa(t,n=>ca(e,s=>$o(n,s))):sy(t)?cr(t,(n,s)=>$o(n,e[s])):!1;class rt{static _dilutes=!1;extends(e){let[n,s]=[this.shape,e.shape];return this.constructor._dilutes&&([s,n]=[n,s]),$o(n,s)}equals(e){return this.constructor===e.constructor&&as(this.shape,e.shape)}[Oy](){return!0}[Qs](e){return this.equals(e)}validate(e){return this.check(e)}check(e,n){Nt()}get nullable(){return Ns(this,Si)}get optional(){return new Gd(this)}cast(e){return sl(e,this),e}expect(e){return sl(e,this),e}}class ba extends rt{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 Fe=(t,e=null)=>new ba(t,e);Fe(ba);class va extends rt{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 qe=t=>new va(t);Fe(va);class wi extends rt{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 xi=(...t)=>new wi(t),Wd=Fe(wi),_y=RegExp.escape||(t=>t.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),Kd=t=>{if(vs.check(t))return[_y(t)];if(Wd.check(t))return t.shape.map(e=>e+"");if(su.check(t))return["[+-]?\\d+.?\\d*"];if(ru.check(t))return[".*"];if(si.check(t))return t.shape.map(Kd).flat(1);ft()};class Ry extends rt{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(Kd).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}}Fe(Ry);const Ly=Symbol("optional");class Gd extends rt{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[Ly](){return!0}}const Ay=Fe(Gd);class Fy extends rt{check(e,n){return n?.extend(null,"never",typeof e),!1}}Fe(Fy);class bi extends rt{constructor(e,n=!1){super(),this.shape=e,this._isPartial=n}static _dilutes=!0;get partial(){return new bi(this.shape,!0)}check(e,n){return e==null?(n?.extend(null,"object","null"),!1):cr(this.shape,(s,r)=>{const i=this._isPartial&&!ya(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 bi(t),My=Fe(bi),$y=qe(t=>t!=null&&(t.constructor===Object||t.constructor==null));class Jd extends rt{constructor(e,n){super(),this.shape={keys:e,values:n}}check(e,n){return e!=null&&cr(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 Yd=(t,e)=>new Jd(t,e),Uy=Fe(Jd);class Xd extends rt{constructor(e){super(),this.shape=e}check(e,n){return e!=null&&cr(this.shape,(s,r)=>{const i=s.check(e[r],n);return!i&&n?.extend(r.toString(),"Tuple",typeof s),i})}}const zy=(...t)=>new Xd(t);Fe(Xd);class Zd extends rt{constructor(e){super(),this.shape=e.length===1?e[0]:new Sa(e)}check(e,n){const s=ws(e)&&aa(e,r=>this.shape.check(r));return!s&&n?.extend(null,"Array",""),s}}const Qd=(...t)=>new Zd(t),By=Fe(Zd),Vy=qe(t=>ws(t));class eu extends rt{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 eu(t,e);Fe(eu);const qy=Hy(rt);class Wy extends rt{constructor(e){super(),this.len=e.length-1,this.args=zy(...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 Ky=Fe(Wy),Gy=qe(t=>typeof t=="function");class Jy extends rt{constructor(e){super(),this.shape=e}check(e,n){const s=aa(this.shape,r=>r.check(e,n));return!s&&n?.extend(null,"Intersectinon",typeof e),s}}Fe(Jy,t=>t.shape.length>0);class Sa extends rt{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,n){const s=ca(this.shape,r=>r.check(e,n));return n?.extend(null,"Union",typeof e),s}}const Ns=(...t)=>t.findIndex(e=>si.check(e))>=0?Ns(...t.map(e=>er(e)).map(e=>si.check(e)?e.shape:[e]).flat(1)):t.length===1?t[0]:new Sa(t),si=Fe(Sa),tu=()=>!0,ri=qe(tu),Yy=Fe(va,t=>t.shape===tu),Ca=qe(t=>typeof t=="bigint"),Xy=qe(t=>t===Ca),nu=qe(t=>typeof t=="symbol");qe(t=>t===nu);const cs=qe(t=>typeof t=="number"),su=qe(t=>t===cs),vs=qe(t=>typeof t=="string"),ru=qe(t=>t===vs),vi=qe(t=>typeof t=="boolean"),Zy=qe(t=>t===vi),iu=xi(void 0);Fe(wi,t=>t.shape.length===1&&t.shape[0]===void 0);xi(void 0);const Si=xi(null),Qy=Fe(wi,t=>t.shape.length===1&&t.shape[0]===null);Fe(Uint8Array);Fe(ba,t=>t.shape===Uint8Array);const ew=Ns(cs,vs,Si,iu,Ca,vi,nu);(()=>{const t=Qd(ri),e=Yd(vs,ri),n=Ns(cs,vs,Si,vi,t,e);return t.shape=n,e.shape.values=n,n})();const er=t=>{if(qy.check(t))return t;if($y.check(t)){const e={};for(const n in t)e[n]=er(t[n]);return Iy(e)}else{if(Vy.check(t))return Ns(...t.map(er));if(ew.check(t))return xi(t);if(Gy.check(t))return Fe(t)}ft()},sl=py?()=>{}:(t,e)=>{const n=new Py;if(!e.check(t,n))throw Pt(`Expected value to be of type ${e.constructor.name}.
9
- ${n.toString()}`)};class tw{constructor(e){this.patterns=[],this.$state=e}if(e,n){return this.patterns.push({if:er(e),h:n}),this}else(e){return this.if(ri,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 Pt("Unhandled pattern")}}}const nw=t=>new tw(t),ou=nw(ri).if(su,(t,e)=>io(e,Gc,ei)).if(ru,(t,e)=>Ny(e)).if(Zy,(t,e)=>nl(e)).if(Xy,(t,e)=>BigInt(io(e,Gc,ei))).if(si,(t,e)=>Zn(e,oo(e,t.shape))).if(My,(t,e)=>{const n={};for(const s in t.shape){let r=t.shape[s];if(Ay.check(r)){if(nl(e))continue;r=r.shape}n[s]=ou(r,e)}return n}).if(By,(t,e)=>{const n=[],s=qd(e,0,42);for(let r=0;r<s;r++)n.push(Zn(e,t.shape));return n}).if(Wd,(t,e)=>oo(e,t.shape)).if(Qy,(t,e)=>null).if(Ky,(t,e)=>{const n=Zn(e,t.res);return()=>n}).if(Yy,(t,e)=>Zn(e,oo(e,[cs,vs,Si,iu,Ca,vi,Qd(cs),Yd(Ns("a","b","c"),cs)]))).if(Uy,(t,e)=>{const n={},s=io(e,0,3);for(let r=0;r<s;r++){const i=Zn(e,t.shape.keys),a=Zn(e,t.shape.values);n[i]=a}return n}).done(),Zn=(t,e)=>ou(er(e),t),Vt=typeof document<"u"?document:{},sw=t=>Vt.createElement(t),rw=()=>Vt.createDocumentFragment();qe(t=>t.nodeType===fw);const iw=t=>Vt.createTextNode(t);typeof DOMParser<"u"&&new DOMParser;const ow=(t,e)=>(Dy(e,(n,s)=>{s===!1?t.removeAttribute(n):s===!0?t.setAttribute(n,""):t.setAttribute(n,s)}),t),aw=t=>{const e=rw();for(let n=0;n<t.length;n++)au(e,t[n]);return e},cw=(t,e)=>(au(t,aw(e)),t),yv=(t,e=[],n=[])=>cw(ow(sw(t),e),n);qe(t=>t.nodeType===dw);const wv=iw;qe(t=>t.nodeType===uw);const lw=t=>wg(t,(e,n)=>`${n}:${e};`).join(""),au=(t,e)=>t.appendChild(e),dw=Vt.ELEMENT_NODE,uw=Vt.TEXT_NODE;Vt.CDATA_SECTION_NODE;Vt.COMMENT_NODE;const hw=Vt.DOCUMENT_NODE;Vt.DOCUMENT_TYPE_NODE;const fw=Vt.DOCUMENT_FRAGMENT_NODE;qe(t=>t.nodeType===hw);const on=Symbol,cu=on(),lu=on(),pw=on(),mw=on(),gw=on(),du=on(),yw=on(),ja=on(),ww=on(),xw=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},bw={[cu]:Zt("font-weight","bold"),[lu]:Zt("font-weight","normal"),[pw]:Zt("color","blue"),[gw]:Zt("color","green"),[mw]:Zt("color","grey"),[du]:Zt("color","red"),[yw]:Zt("color","purple"),[ja]:Zt("color","orange"),[ww]:Zt("color","black")},vw=t=>{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());const e=[],n=[],s=lt();let r=[],i=0;for(;i<t.length;i++){const a=t[i],c=bw[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=lw(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},uu=gy?vw:xw,Sw=(...t)=>{console.log(...uu(t)),fu.forEach(e=>e.print(t))},hu=(...t)=>{console.warn(...uu(t)),t.unshift(ja),fu.forEach(e=>e.print(t))},fu=xn(),pu=t=>({[Symbol.iterator](){return this},next:t}),Cw=(t,e)=>pu(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),ao=(t,e)=>pu(()=>{const{done:n,value:s}=t.next();return{done:n,value:n?void 0:e(s)}});class Ci{constructor(e,n){this.clock=e,this.len=n}}class Os{constructor(){this.clients=new Map}}const Ss=(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])Nu(t,i,d.clock,d.len,n)}}),jw=(t,e)=>{let n=0,s=t.length-1;for(;n<=s;){const r=Ot((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},lr=(t,e)=>{const n=t.clients.get(e.client);return n!==void 0&&jw(n,e.clock)!==null},ka=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 Ci(r.clock,An(r.len,i.clock+i.len-r.clock)):(s<n&&(e[s]=i),s++)}e.length=s})},Uo=t=>{const e=new Os;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++)bg(i,t[a].clients.get(r)||[]);e.clients.set(r,i)}});return ka(e),e},tr=(t,e,n,s)=>{Bt(t.clients,e,()=>[]).push(new Ci(n,s))},kw=()=>new Os,Ew=t=>{const e=kw();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 Ci(c,l))}}r.length>0&&e.clients.set(s,r)}),e},Ps=(t,e)=>{U(t.restEncoder,e.clients.size),sn(e.clients.entries()).sort((n,s)=>s[0]-n[0]).forEach(([n,s])=>{t.resetDsCurVal(),U(t.restEncoder,n);const r=s.length;U(t.restEncoder,r);for(let i=0;i<r;i++){const a=s[i];t.writeDsClock(a.clock),t.writeDsLen(a.len)}})},Ea=t=>{const e=new Os,n=Y(t.restDecoder);for(let s=0;s<n;s++){t.resetDsCurVal();const r=Y(t.restDecoder),i=Y(t.restDecoder);if(i>0){const a=Bt(e.clients,r,()=>[]);for(let c=0;c<i;c++)a.push(new Ci(t.readDsClock(),t.readDsLen()))}}return e},rl=(t,e,n)=>{const s=new Os,r=Y(t.restDecoder);for(let i=0;i<r;i++){t.resetDsCurVal();const a=Y(t.restDecoder),c=Y(t.restDecoder),l=n.clients.get(a)||[],d=Pe(n,a);for(let f=0;f<c;f++){const u=t.readDsClock(),p=u+t.readDsLen();if(u<d){d<p&&tr(s,a,d,p-d);let m=$t(l,u),g=l[m];for(!g.deleted&&g.id.clock<u&&(l.splice(m+1,0,hi(e,g,u-g.id.clock)),m++);m<l.length&&(g=l[m++],g.id.clock<p);)g.deleted||(p<g.id.clock+g.length&&l.splice(m,0,hi(e,g,p-g.id.clock)),g.delete(e))}else tr(s,a,u,p-u)}}if(s.clients.size>0){const i=new Pn;return U(i.restEncoder,0),Ps(i,s),i.toUint8Array()}return null},mu=Fd;class Fn extends la{constructor({guid:e=Qg(),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=mu(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new Du,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=bs(d=>{this.on("load",()=>{this.isLoaded=!0,d(this)})});const l=()=>bs(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&&ye(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(sn(this.subdocs).map(e=>e.guid))}transact(e,n=null){return ye(this,e,n)}get(e,n=He){const s=Bt(this.share,e,()=>{const i=new n;return i._integrate(this,null),i}),r=s.constructor;if(n!==He&&r!==n)if(r===He){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,us)}getText(e=""){return this.get(e,ks)}getMap(e=""){return this.get(e,js)}getXmlElement(e=""){return this.get(e,Es)}getXmlFragment(e=""){return this.get(e,_n)}toJSON(){const e={};return this.share.forEach((n,s)=>{e[s]=n.toJSON()}),e}destroy(){this.isDestroyed=!0,sn(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new Fn({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,ye(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 gu{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return Y(this.restDecoder)}readDsLen(){return Y(this.restDecoder)}}class yu extends gu{readLeftID(){return Q(Y(this.restDecoder),Y(this.restDecoder))}readRightID(){return Q(Y(this.restDecoder),Y(this.restDecoder))}readClient(){return Y(this.restDecoder)}readInfo(){return xs(this.restDecoder)}readString(){return Ze(this.restDecoder)}readParentInfo(){return Y(this.restDecoder)===1}readTypeRef(){return Y(this.restDecoder)}readLen(){return Y(this.restDecoder)}readAny(){return Zs(this.restDecoder)}readBuf(){return ky(Xe(this.restDecoder))}readJSON(){return JSON.parse(Ze(this.restDecoder))}readKey(){return Ze(this.restDecoder)}}class Dw{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Y(this.restDecoder),this.dsCurrVal}readDsLen(){const e=Y(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Cs extends Dw{constructor(e){super(e),this.keys=[],Y(e),this.keyClockDecoder=new ro(Xe(e)),this.clientDecoder=new qr(Xe(e)),this.leftClockDecoder=new ro(Xe(e)),this.rightClockDecoder=new ro(Xe(e)),this.infoDecoder=new el(Xe(e),xs),this.stringDecoder=new Yg(Xe(e)),this.parentInfoDecoder=new el(Xe(e),xs),this.typeRefDecoder=new qr(Xe(e)),this.lenDecoder=new qr(Xe(e))}readLeftID(){return new ls(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ls(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 Zs(this.restDecoder)}readBuf(){return Xe(this.restDecoder)}readJSON(){return Zs(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 wu{constructor(){this.restEncoder=Le()}toUint8Array(){return be(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){U(this.restEncoder,e)}writeDsLen(e){U(this.restEncoder,e)}}class dr extends wu{writeLeftID(e){U(this.restEncoder,e.client),U(this.restEncoder,e.clock)}writeRightID(e){U(this.restEncoder,e.client),U(this.restEncoder,e.clock)}writeClient(e){U(this.restEncoder,e)}writeInfo(e){Fo(this.restEncoder,e)}writeString(e){tn(this.restEncoder,e)}writeParentInfo(e){U(this.restEncoder,e?1:0)}writeTypeRef(e){U(this.restEncoder,e)}writeLen(e){U(this.restEncoder,e)}writeAny(e){Xs(this.restEncoder,e)}writeBuf(e){Te(this.restEncoder,e)}writeJSON(e){tn(this.restEncoder,JSON.stringify(e))}writeKey(e){tn(this.restEncoder,e)}}class xu{constructor(){this.restEncoder=Le(),this.dsCurrVal=0}toUint8Array(){return be(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const n=e-this.dsCurrVal;this.dsCurrVal=e,U(this.restEncoder,n)}writeDsLen(e){e===0&&ft(),U(this.restEncoder,e-1),this.dsCurrVal+=e}}class Pn extends xu{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new so,this.clientEncoder=new Hr,this.leftClockEncoder=new so,this.rightClockEncoder=new so,this.infoEncoder=new Xc(Fo),this.stringEncoder=new zg,this.parentInfoEncoder=new Xc(Fo),this.typeRefEncoder=new Hr,this.lenEncoder=new Hr}toUint8Array(){const e=Le();return U(e,0),Te(e,this.keyClockEncoder.toUint8Array()),Te(e,this.clientEncoder.toUint8Array()),Te(e,this.leftClockEncoder.toUint8Array()),Te(e,this.rightClockEncoder.toUint8Array()),Te(e,be(this.infoEncoder)),Te(e,this.stringEncoder.toUint8Array()),Te(e,be(this.parentInfoEncoder)),Te(e,this.typeRefEncoder.toUint8Array()),Te(e,this.lenEncoder.toUint8Array()),gi(e,be(this.restEncoder)),be(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){Xs(this.restEncoder,e)}writeBuf(e){Te(this.restEncoder,e)}writeJSON(e){Xs(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 Tw=(t,e,n,s)=>{s=An(s,e[0].id.clock);const r=$t(e,s);U(t.restEncoder,e.length-r),t.writeClient(n),U(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)},Da=(t,e,n)=>{const s=new Map;n.forEach((r,i)=>{Pe(e,i)>r&&s.set(i,r)}),ji(e).forEach((r,i)=>{n.has(i)||s.set(i,0)}),U(t.restEncoder,s.size),sn(s.entries()).sort((r,i)=>i[0]-r[0]).forEach(([r,i])=>{Tw(t,e.clients.get(r),r,i)})},Nw=(t,e)=>{const n=lt(),s=Y(t.restDecoder);for(let r=0;r<s;r++){const i=Y(t.restDecoder),a=new Array(i),c=t.readClient();let l=Y(t.restDecoder);n.set(c,{i:0,refs:a});for(let d=0;d<i;d++){const f=t.readInfo();switch(mi&f){case 0:{const u=t.readLen();a[d]=new xt(Q(c,l),u),l+=u;break}case 10:{const u=Y(t.restDecoder);a[d]=new bt(Q(c,l),u),l+=u;break}default:{const u=(f&(en|ht))===0,p=new ve(Q(c,l),null,(f&ht)===ht?t.readLeftID():null,null,(f&en)===en?t.readRightID():null,u?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,u&&(f&Js)===Js?t.readString():null,Ju(t,f));a[d]=p,l+=p.length}}}}return n},Ow=(t,e,n)=>{const s=[];let r=sn(n.keys()).sort((m,g)=>m-g);if(r.length===0)return null;const i=()=>{if(r.length===0)return null;let m=n.get(r[r.length-1]);for(;m.refs.length===m.i;)if(r.pop(),r.length>0)m=n.get(r[r.length-1]);else return null;return m};let a=i();if(a===null)return null;const c=new Du,l=new Map,d=(m,g)=>{const w=l.get(m);(w==null||w>g)&&l.set(m,g)};let f=a.refs[a.i++];const u=new Map,p=()=>{for(const m of s){const g=m.id.client,w=n.get(g);w?(w.i--,c.clients.set(g,w.refs.slice(w.i)),n.delete(g),w.i=0,w.refs=[]):c.clients.set(g,[m]),r=r.filter(b=>b!==g)}s.length=0};for(;;){if(f.constructor!==bt){const g=Bt(u,f.id.client,()=>Pe(e,f.id.client))-f.id.clock;if(g<0)s.push(f),d(f.id.client,f.id.clock-1),p();else{const w=f.getMissing(t,e);if(w!==null){s.push(f);const b=n.get(w)||{refs:[],i:0};if(b.refs.length===b.i)d(w,Pe(e,w)),p();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 m=new Pn;return Da(m,c,new Map),U(m.restEncoder,0),{missing:l,update:m.toUint8Array()}}return null},Pw=(t,e)=>Da(t,e.doc.store,e.beforeState),_w=(t,e,n,s=new Cs(t))=>ye(e,r=>{r.local=!1;let i=!1;const a=r.doc,c=a.store,l=Nw(s,a),d=Ow(r,c,l),f=c.pendingStructs;if(f){for(const[p,m]of f.missing)if(m<Pe(c,p)){i=!0;break}if(d){for(const[p,m]of d.missing){const g=f.missing.get(p);(g==null||g>m)&&f.missing.set(p,m)}f.update=oi([f.update,d.update])}}else c.pendingStructs=d;const u=rl(s,r,c);if(c.pendingDs){const p=new Cs(Sn(c.pendingDs));Y(p.restDecoder);const m=rl(p,r,c);u&&m?c.pendingDs=oi([u,m]):c.pendingDs=u||m}else c.pendingDs=u;if(i){const p=c.pendingStructs.update;c.pendingStructs=null,bu(r.doc,p)}},n,!1),bu=(t,e,n,s=Cs)=>{const r=Sn(e);_w(r,t,n,new s(r))},vu=(t,e,n)=>bu(t,e,n,yu),Rw=(t,e,n=new Map)=>{Da(t,e.store,n),Ps(t,Ew(e.store))},Lw=(t,e=new Uint8Array([0]),n=new Pn)=>{const s=Su(e);Rw(n,t,s);const r=[n.toUint8Array()];if(t.store.pendingDs&&r.push(t.store.pendingDs),t.store.pendingStructs&&r.push(Qw(t.store.pendingStructs.update,e)),r.length>1){if(n.constructor===dr)return Xw(r.map((i,a)=>a===0?i:tx(i)));if(n.constructor===Pn)return oi(r)}return r[0]},Ta=(t,e)=>Lw(t,e,new dr),Aw=t=>{const e=new Map,n=Y(t.restDecoder);for(let s=0;s<n;s++){const r=Y(t.restDecoder),i=Y(t.restDecoder);e.set(r,i)}return e},Su=t=>Aw(new gu(Sn(t))),Cu=(t,e)=>(U(t.restEncoder,e.size),sn(e.entries()).sort((n,s)=>s[0]-n[0]).forEach(([n,s])=>{U(t.restEncoder,n),U(t.restEncoder,s)}),t),Fw=(t,e)=>Cu(t,ji(e.store)),Iw=(t,e=new xu)=>(t instanceof Map?Cu(e,t):Fw(e,t),e.toUint8Array()),Mw=t=>Iw(t,new wu);class $w{constructor(){this.l=[]}}const il=()=>new $w,ol=(t,e)=>t.l.push(e),al=(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.")},ju=(t,e,n)=>wa(t.l,[e,n]);class ls{constructor(e,n){this.client=e,this.clock=n}}const is=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,Q=(t,e)=>new ls(t,e),ku=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw ft()},ii=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class Eu{constructor(e,n,s,r=0){this.type=e,this.tname=n,this.item=s,this.assoc=r}}const xv=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},bv=t=>new Eu(t.type==null?null:Q(t.type.client,t.type.clock),t.tname??null,t.item==null?null:Q(t.item.client,t.item.clock),t.assoc==null?0:t.assoc);class Uw{constructor(e,n,s=0){this.type=e,this.index=n,this.assoc=s}}const zw=(t,e,n=0)=>new Uw(t,e,n),$r=(t,e,n)=>{let s=null,r=null;return t._item===null?r=ku(t):s=Q(t._item.id.client,t._item.id.clock),new Eu(s,r,e,n)},vv=(t,e,n=0)=>{let s=t._start;if(n<0){if(e===0)return $r(t,null,n);e--}for(;s!==null;){if(!s.deleted&&s.countable){if(s.length>e)return $r(t,Q(s.id.client,s.id.clock+e),n);e-=s.length}if(s.right===null&&n<0)return $r(t,s.lastId,n);s=s.right}return $r(t,null,n)},Bw=(t,e)=>{const n=ds(t,e),s=e.clock-n.id.clock;return{item:n,diff:s}},Sv=(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(Pe(s,r.client)<=r.clock)return null;const f=n?Ho(s,r):Bw(s,r),u=f.item;if(!(u instanceof ve))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 p=u.left;for(;p!==null;)!p.deleted&&p.countable&&(d+=p.length),p=p.left}}else{if(a!==null)l=e.get(a);else if(i!==null){if(Pe(s,i.client)<=i.clock)return null;const{item:f}=n?Ho(s,i):{item:ds(s,i)};if(f instanceof ve&&f.content instanceof Ht)l=f.content.type;else return null}else throw ft();c>=0?d=l._length:d=0}return zw(l,d,t.assoc)},Cv=(t,e)=>t===e||t!==null&&e!==null&&t.tname===e.tname&&is(t.item,e.item)&&is(t.type,e.type)&&t.assoc===e.assoc,ts=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!lr(e.ds,t.id),zo=(t,e)=>{const n=Bt(t.meta,zo,xn),s=t.doc.store;n.has(e)||(e.sv.forEach((r,i)=>{r<Pe(s,i)&&ct(t,Q(i,r))}),Ss(t,e.ds,r=>{}),n.add(e))};class Du{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const ji=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},Pe=(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},Tu=(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 ft()}n.push(e)},$t=(t,e)=>{let n=0,s=t.length-1,r=t[s],i=r.id.clock;if(i===e)return s;let a=Ot(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=Ot((n+s)/2)}throw ft()},Vw=(t,e)=>{const n=t.clients.get(e.client);return n[$t(n,e.clock)]},ds=Vw,Bo=(t,e,n)=>{const s=$t(e,n),r=e[s];return r.id.clock<n&&r instanceof ve?(e.splice(s+1,0,hi(t,r,n-r.id.clock)),s+1):s},ct=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[Bo(t,n,e.clock)]},cl=(t,e,n)=>{const s=e.clients.get(n.client),r=$t(s,n.clock),i=s[r];return n.clock!==i.id.clock+i.length-1&&i.constructor!==xt&&s.splice(r+1,0,hi(t,i,n.clock-i.id.clock+1)),i},Hw=(t,e,n)=>{const s=t.clients.get(e.id.client);s[$t(s,e.id.clock)]=n},Nu=(t,e,n,s,r)=>{if(s===0)return;const i=n+s;let a=Bo(t,e,n),c;do c=e[a++],i<c.id.clock+c.length&&Bo(t,e,i),r(c);while(a<e.length&&e[a].id.clock<i)};class qw{constructor(e,n,s){this.doc=e,this.deleteSet=new Os,this.beforeState=ji(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 ll=(t,e)=>e.deleteSet.clients.size===0&&!xg(e.afterState,(n,s)=>e.beforeState.get(s)!==n)?!1:(ka(e.deleteSet),Pw(t,e),Ps(t,e.deleteSet),!0),dl=(t,e,n)=>{const s=e._item;(s===null||s.id.clock<(t.beforeState.get(s.id.client)||0)&&!s.deleted)&&Bt(t.changed,e,xn).add(n)},Wr=(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 ve&&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},Ww=(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=$t(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 ve&&u.deleted&&!u.keep&&n(u)&&u.gc(e,!1)}}}},Kw=(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=da(r.length-1,1+$t(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+Wr(r,l)}})},Ou=(t,e)=>{if(e<t.length){const n=t[e],s=n.doc,r=s.store,i=n.deleteSet,a=n._mergeStructs;try{ka(i),n.afterState=ji(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(()=>{ju(d._dEH,l,n)}))}),c.push(()=>s.emit("afterTransaction",[n,s])),c.push(()=>{n._needFormattingCleanup&&mx(n)})}),wa(c,[])}finally{s.gc&&Ww(i,r,s.gcFilter),Kw(i,r),n.afterState.forEach((f,u)=>{const p=n.beforeState.get(u)||0;if(p!==f){const m=r.clients.get(u),g=An($t(m,p),1);for(let w=m.length-1;w>=g;)w-=1+Wr(m,w)}});for(let f=a.length-1;f>=0;f--){const{client:u,clock:p}=a[f].id,m=r.clients.get(u),g=$t(m,p);g+1<m.length&&Wr(m,g+1)>1||g>0&&Wr(m,g)}if(!n.local&&n.afterState.get(s.clientID)!==n.beforeState.get(s.clientID)&&(Sw(ja,cu,"[yjs] ",lu,du,"Changed the client-id because another client seems to be using it."),s.clientID=mu()),s.emit("afterTransactionCleanup",[n,s]),s._observers.has("update")){const f=new dr;ll(f,n)&&s.emit("update",[f.toUint8Array(),n.origin,s,n])}if(s._observers.has("updateV2")){const f=new Pn;ll(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])):Ou(t,e+1)}}},ye=(t,e,n=null,s=!0)=>{const r=t._transactionCleanups;let i=!1,a=null;t._transaction===null&&(i=!0,t._transaction=new qw(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&&Ou(r,0)}}return a};class Gw{constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const ul=(t,e,n)=>{Ss(t,n.deletions,s=>{s instanceof ve&&e.scope.some(r=>r===t.doc||ii(r,s))&&Fa(s,!1)})},hl=(t,e,n)=>{let s=null;const r=t.doc,i=t.scope;ye(r,c=>{for(;e.length>0&&t.currStackItem===null;){const l=r.store,d=e.pop(),f=new Set,u=[];let p=!1;Ss(c,d.insertions,m=>{if(m instanceof ve){if(m.redone!==null){let{item:g,diff:w}=Ho(l,m.id);w>0&&(g=ct(c,Q(g.id.client,g.id.clock+w))),m=g}!m.deleted&&i.some(g=>g===c.doc||ii(g,m))&&u.push(m)}}),Ss(c,d.deletions,m=>{m instanceof ve&&i.some(g=>g===c.doc||ii(g,m))&&!lr(d.insertions,m.id)&&f.add(m)}),f.forEach(m=>{p=Gu(c,m,f,d.insertions,t.ignoreRemoteMapChanges,t)!==null||p});for(let m=u.length-1;m>=0;m--){const g=u[m];t.deleteFilter(g)&&(g.delete(c),p=!0)}t.currStackItem=p?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 Jw extends la{constructor(e,{captureTimeout:n=500,captureTransaction:s=l=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:c=ws(e)?e[0].doc:e instanceof Fn?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 p=new Os;l.afterState.forEach((b,v)=>{const k=l.beforeState.get(v)||0,P=b-k;P>0&&tr(p,v,k,P)});const m=bn();let g=!1;if(this.lastChange>0&&m-this.lastChange<this.captureTimeout&&u.length>0&&!d&&!f){const b=u[u.length-1];b.deletions=Uo([b.deletions,l.deleteSet]),b.insertions=Uo([b.insertions,p])}else u.push(new Gw(l.deleteSet,p)),g=!0;!d&&!f&&(this.lastChange=m),Ss(l,l.deleteSet,b=>{b instanceof ve&&this.scope.some(v=>v===l.doc||ii(v,b))&&Fa(b,!0)});const w=[{stackItem:u[u.length-1],origin:l.origin,type:d?"redo":"undo",changedParentTypes:l.changedParentTypes},this];g?this.emit("stack-item-added",w):this.emit("stack-item-updated",w)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){const n=new Set(this.scope);e=ws(e)?e:[e],e.forEach(s=>{n.has(s)||(n.add(s),(s instanceof He?s.doc!==this.doc:s!==this.doc)&&hu("[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=>ul(s,this,r)),this.undoStack=[]),n&&(this.redoStack.forEach(r=>ul(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=hl(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=hl(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=Y(t.restDecoder);for(let n=0;n<e;n++){const s=Y(t.restDecoder),r=t.readClient();let i=Y(t.restDecoder);for(let a=0;a<s;a++){const c=t.readInfo();if(c===10){const l=Y(t.restDecoder);yield new bt(Q(r,i),l),i+=l}else if((mi&c)!==0){const l=(c&(en|ht))===0,d=new ve(Q(r,i),null,(c&ht)===ht?t.readLeftID():null,null,(c&en)===en?t.readRightID():null,l?t.readParentInfo()?t.readString():t.readLeftID():null,l&&(c&Js)===Js?t.readString():null,Ju(t,c));yield d,i+=d.length}else{const l=t.readLen();yield new xt(Q(r,i),l),i+=l}}}}class Na{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===bt);return this.curr}}class Oa{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const Xw=t=>oi(t,yu,dr),Zw=(t,e)=>{if(t.constructor===xt){const{client:n,clock:s}=t.id;return new xt(Q(n,s+e),t.length-e)}else if(t.constructor===bt){const{client:n,clock:s}=t.id;return new bt(Q(n,s+e),t.length-e)}else{const n=t,{client:s,clock:r}=n.id;return new ve(Q(s,r+e),null,Q(s,r+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},oi=(t,e=Cs,n=Pn)=>{if(t.length===1)return t[0];const s=t.map(f=>new e(Sn(f)));let r=s.map(f=>new Na(f,!0)),i=null;const a=new n,c=new Oa(a);for(;r=r.filter(p=>p.curr!==null),r.sort((p,m)=>{if(p.curr.id.client===m.curr.id.client){const g=p.curr.id.clock-m.curr.id.clock;return g===0?p.curr.constructor===m.curr.constructor?0:p.curr.constructor===bt?1:-1:g}else return m.curr.id.client-p.curr.id.client}),r.length!==0;){const f=r[0],u=f.curr.id.client;if(i!==null){let p=f.curr,m=!1;for(;p!==null&&p.id.clock+p.length<=i.struct.id.clock+i.struct.length&&p.id.client>=i.struct.id.client;)p=f.next(),m=!0;if(p===null||p.id.client!==u||m&&p.id.clock>i.struct.id.clock+i.struct.length)continue;if(u!==i.struct.id.client)pn(c,i.struct,i.offset),i={struct:p,offset:0},f.next();else if(i.struct.id.clock+i.struct.length<p.id.clock)if(i.struct.constructor===bt)i.struct.length=p.id.clock+p.length-i.struct.id.clock;else{pn(c,i.struct,i.offset);const g=p.id.clock-i.struct.id.clock-i.struct.length;i={struct:new bt(Q(u,i.struct.id.clock+i.struct.length),g),offset:0}}else{const g=i.struct.id.clock+i.struct.length-p.id.clock;g>0&&(i.struct.constructor===bt?i.struct.length-=g:p=Zw(p,g)),i.struct.mergeWith(p)||(pn(c,i.struct,i.offset),i={struct:p,offset:0},f.next())}}else i={struct:f.curr,offset:0},f.next();for(let p=f.curr;p!==null&&p.id.client===u&&p.id.clock===i.struct.id.clock+i.struct.length&&p.constructor!==bt;p=f.next())pn(c,i.struct,i.offset),i={struct:p,offset:0}}i!==null&&(pn(c,i.struct,i.offset),i=null),Pa(c);const l=s.map(f=>Ea(f)),d=Uo(l);return Ps(a,d),a.toUint8Array()},Qw=(t,e,n=Cs,s=Pn)=>{const r=Su(e),i=new s,a=new Oa(i),c=new n(Sn(t)),l=new Na(c,!1);for(;l.curr;){const f=l.curr,u=f.id.client,p=r.get(u)||0;if(l.curr.constructor===bt){l.next();continue}if(f.id.clock+f.length>p)for(pn(a,f,An(p-f.id.clock,0)),l.next();l.curr&&l.curr.id.client===u;)pn(a,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===u&&l.curr.id.clock+l.curr.length<=p;)l.next()}Pa(a);const d=Ea(c);return Ps(i,d),i.toUint8Array()},Pu=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:be(t.encoder.restEncoder)}),t.encoder.restEncoder=Le(),t.written=0)},pn=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&Pu(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),U(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},Pa=t=>{Pu(t);const e=t.encoder.restEncoder;U(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const s=t.clientStructs[n];U(e,s.written),gi(e,s.restEncoder)}},ex=(t,e,n,s)=>{const r=new n(Sn(t)),i=new Na(r,!1),a=new s,c=new Oa(a);for(let d=i.curr;d!==null;d=i.next())pn(c,e(d),0);Pa(c);const l=Ea(r);return Ps(a,l),a.toUint8Array()},tx=t=>ex(t,uy,Cs,dr),fl="You must not compute changes after the event-handler fired.";class ki{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=nx(this.currentTarget,this.target))}deletes(e){return lr(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Pt(fl);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=eo(l.content.getContent());else return;else l!==null&&this.deletes(l)?(a="update",c=eo(l.content.getContent())):(a="add",c=void 0)}else if(this.deletes(i))a="delete",c=eo(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 Pt(fl);const n=this.target,s=xn(),r=xn(),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 nx=(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},Qe=()=>{hu("Invalid access: Add Yjs type to a document before reading data.")},_u=80;let _a=0;class sx{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=_a++}}const rx=t=>{t.timestamp=_a++},Ru=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=_a++},ix=(t,e,n)=>{if(t.length>=_u){const s=t.reduce((r,i)=>r.timestamp<i.timestamp?r:i);return Ru(s,e,n),s}else{const s=new sx(e,n);return t.push(s),s}},Ei=(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)=>Vr(e-i.index)<Vr(e-a.index)?i:a);let s=t._start,r=0;for(n!==null&&(s=n.p,r=n.index,rx(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&&Vr(n.index-r)<s.parent.length/_u?(Ru(n,s,r),n):ix(t._searchMarker,s,r)},nr=(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=An(e,r.index+n))}},Di=(t,e,n)=>{const s=t,r=e.changedParentTypes;for(;Bt(r,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;ju(s._eH,n,e)};class He{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=il(),this._dEH=il(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw Nt()}clone(){throw Nt()}_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){ol(this._eH,e)}observeDeep(e){ol(this._dEH,e)}unobserve(e){al(this._eH,e)}unobserveDeep(e){al(this._dEH,e)}toJSON(){}}const Lu=(t,e,n)=>{t.doc??Qe(),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},Au=t=>{t.doc??Qe();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},sr=(t,e)=>{let n=0,s=t._start;for(t.doc??Qe();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}},Fu=(t,e)=>{const n=[];return sr(t,(s,r)=>{n.push(e(s,r,t))}),n},ox=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}}}},Iu=(t,e)=>{t.doc??Qe();const n=Ei(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}},ai=(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 ve(Q(a,Pe(c,a)),r,r&&r.lastId,l,l&&l.id,e,null,new Rn(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 ve(Q(a,Pe(c,a)),r,r&&r.lastId,l,l&&l.id,e,null,new ur(new Uint8Array(u))),r.integrate(t,0);break;case Fn:r=new ve(Q(a,Pe(c,a)),r,r&&r.lastId,l,l&&l.id,e,null,new hr(u)),r.integrate(t,0);break;default:if(u instanceof He)r=new ve(Q(a,Pe(c,a)),r,r&&r.lastId,l,l&&l.id,e,null,new Ht(u)),r.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),f()},Mu=()=>Pt("Length exceeded!"),$u=(t,e,n,s)=>{if(n>e._length)throw Mu();if(n===0)return e._searchMarker&&nr(e._searchMarker,n,s.length),ai(t,e,null,s);const r=n,i=Ei(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&&ct(t,Q(a.id.client,a.id.clock+n));break}n-=a.length}return e._searchMarker&&nr(e._searchMarker,r,s.length),ai(t,e,a,s)},ax=(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 ai(t,e,r,n)},Uu=(t,e,n,s)=>{if(s===0)return;const r=n,i=s,a=Ei(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&&ct(t,Q(c.id.client,c.id.clock+n)),n-=c.length);for(;s>0&&c!==null;)c.deleted||(s<c.length&&ct(t,Q(c.id.client,c.id.clock+s)),c.delete(t),s-=c.length),c=c.right;if(s>0)throw Mu();e._searchMarker&&nr(e._searchMarker,r,-i+s)},ci=(t,e,n)=>{const s=e._map.get(n);s!==void 0&&s.delete(t)},Ra=(t,e,n,s)=>{const r=e._map.get(n)||null,i=t.doc,a=i.clientID;let c;if(s==null)c=new Rn([s]);else switch(s.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:c=new Rn([s]);break;case Uint8Array:c=new ur(s);break;case Fn:c=new hr(s);break;default:if(s instanceof He)c=new Ht(s);else throw new Error("Unexpected content type")}new ve(Q(a,Pe(i.store,a)),r,r&&r.lastId,null,null,e,n,c).integrate(t,0)},La=(t,e)=>{t.doc??Qe();const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},zu=t=>{const e={};return t.doc??Qe(),t._map.forEach((n,s)=>{n.deleted||(e[s]=n.content.getContent()[n.length-1])}),e},Bu=(t,e)=>{t.doc??Qe();const n=t._map.get(e);return n!==void 0&&!n.deleted},cx=(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&&ts(i,e)&&(n[r]=i.content.getContent()[i.length-1])}),n},Ur=t=>(t.doc??Qe(),Cw(t._map.entries(),e=>!e[1].deleted));class lx extends ki{}class us extends He{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new us;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new us}clone(){const e=new us;return e.insert(0,this.toArray().map(n=>n instanceof He?n.clone():n)),e}get length(){return this.doc??Qe(),this._length}_callObserver(e,n){super._callObserver(e,n),Di(this,e,new lx(this,e))}insert(e,n){this.doc!==null?ye(this.doc,s=>{$u(s,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?ye(this.doc,n=>{ax(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?ye(this.doc,s=>{Uu(s,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return Iu(this,e)}toArray(){return Au(this)}slice(e=0,n=this.length){return Lu(this,e,n)}toJSON(){return this.map(e=>e instanceof He?e.toJSON():e)}map(e){return Fu(this,e)}forEach(e){sr(this,e)}[Symbol.iterator](){return ox(this)}_write(e){e.writeTypeRef(Lx)}}const dx=t=>new us;class ux extends ki{constructor(e,n,s){super(e,n),this.keysChanged=s}}class js extends He{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 js}clone(){const e=new js;return this.forEach((n,s)=>{e.set(s,n instanceof He?n.clone():n)}),e}_callObserver(e,n){Di(this,e,new ux(this,e,n))}toJSON(){this.doc??Qe();const e={};return this._map.forEach((n,s)=>{if(!n.deleted){const r=n.content.getContent()[n.length-1];e[s]=r instanceof He?r.toJSON():r}}),e}get size(){return[...Ur(this)].length}keys(){return ao(Ur(this),e=>e[0])}values(){return ao(Ur(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return ao(Ur(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??Qe(),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?ye(this.doc,n=>{ci(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?ye(this.doc,s=>{Ra(s,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return La(this,e)}has(e){return Bu(this,e)}clear(){this.doc!==null?ye(this.doc,e=>{this.forEach(function(n,s,r){ci(e,r,s)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(Ax)}}const hx=t=>new js,mn=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&ly(t,e);class Vo{constructor(e,n,s,r){this.left=e,this.right=n,this.index=s,this.currentAttributes=r}forward(){this.right===null&&ft(),this.right.content.constructor===Me?this.right.deleted||_s(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}}const pl=(t,e,n)=>{for(;e.right!==null&&n>0;)e.right.content.constructor===Me?e.right.deleted||_s(e.currentAttributes,e.right.content):e.right.deleted||(n<e.right.length&&ct(t,Q(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},zr=(t,e,n,s)=>{const r=new Map,i=s?Ei(e,n):null;if(i){const a=new Vo(i.p.left,i.p,i.index,r);return pl(t,a,n-i.index)}else{const a=new Vo(null,e._start,0,r);return pl(t,a,n)}},Vu=(t,e,n,s)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===Me&&mn(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 ve(Q(i,Pe(r.store,i)),l,l&&l.lastId,d,d&&d.id,e,null,new Me(c,a));f.integrate(t,0),n.right=f,n.forward()})},_s=(t,e)=>{const{key:n,value:s}=e;s===null?t.delete(n):t.set(n,s)},Hu=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===Me&&mn(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},qu=(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(!mn(d,l)){a.set(c,d);const{left:f,right:u}=n;n.right=new ve(Q(i,Pe(r.store,i)),f,f&&f.lastId,u,u&&u.id,e,null,new Me(c,l)),n.right.integrate(t,0),n.forward()}}return a},co=(t,e,n,s,r)=>{n.currentAttributes.forEach((p,m)=>{r[m]===void 0&&(r[m]=null)});const i=t.doc,a=i.clientID;Hu(n,r);const c=qu(t,e,n,r),l=s.constructor===String?new Ut(s):s instanceof He?new Ht(s):new In(s);let{left:d,right:f,index:u}=n;e._searchMarker&&nr(e._searchMarker,n.index,l.getLength()),f=new ve(Q(a,Pe(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(),Vu(t,e,n,c)},ml=(t,e,n,s,r)=>{const i=t.doc,a=i.clientID;Hu(n,r);const c=qu(t,e,n,r);e:for(;n.right!==null&&(s>0||c.size>0&&(n.right.deleted||n.right.content.constructor===Me));){if(!n.right.deleted)switch(n.right.content.constructor){case Me:{const{key:l,value:d}=n.right.content,f=r[l];if(f!==void 0){if(mn(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&&ct(t,Q(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 ve(Q(a,Pe(i.store,a)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new Ut(l)),n.right.integrate(t,0),n.forward()}Vu(t,e,n,c)},Wu=(t,e,n,s,r)=>{let i=e;const a=lt();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===Me){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===Me){const{key:f,value:u}=d,p=s.get(f)??null;(a.get(f)!==d||p===u)&&(e.delete(t),c++,!l&&(r.get(f)??null)===u&&p!==u&&(p===null?r.delete(f):r.set(f,p))),!l&&!e.deleted&&_s(r,d)}}e=e.right}return c},fx=(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===Me){const s=e.content.key;n.has(s)?e.delete(t):n.add(s)}e=e.left}},px=t=>{let e=0;return ye(t.doc,n=>{let s=t._start,r=t._start,i=lt();const a=Lo(i);for(;r;)r.deleted===!1&&(r.content.constructor===Me?_s(a,r.content):(e+=Wu(n,s,r,i,a),i=Lo(a),s=r)),r=r.right}),e},mx=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&&Nu(t,n.store.clients.get(s),i,r,a=>{!a.deleted&&a.content.constructor===Me&&a.constructor!==xt&&e.add(a.parent)})}ye(n,s=>{Ss(t,t.deleteSet,r=>{if(r instanceof xt||!r.parent._hasFormatting||e.has(r.parent))return;const i=r.parent;r.content.constructor===Me?e.add(i):fx(s,r)});for(const r of e)px(r)})},gl=(t,e,n)=>{const s=n,r=Lo(e.currentAttributes),i=e.right;for(;n>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case Ht:case In:case Ut:n<e.right.length&&ct(t,Q(e.right.id.client,e.right.id.clock+n)),n-=e.right.length,e.right.delete(t);break}e.forward()}i&&Wu(t,i,e.right,r,e.currentAttributes);const a=(e.left||e.right).parent;return a._searchMarker&&nr(a._searchMarker,e.index,-s+n),e};class gx extends ki{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=[];ye(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 p=()=>{if(c!==null){let m=null;switch(c){case"delete":u>0&&(m={delete:u}),u=0;break;case"insert":(typeof d=="object"||d.length>0)&&(m={insert:d},r.size>0&&(m.attributes={},r.forEach((g,w)=>{g!==null&&(m.attributes[w]=g)}))),d="";break;case"retain":f>0&&(m={retain:f},cy(l)||(m.attributes=ry({},l))),f=0;break}m&&n.push(m),c=null}};for(;a!==null;){switch(a.content.constructor){case Ht:case In:this.adds(a)?this.deletes(a)||(p(),c="insert",d=a.content.getContent()[0],p()):this.deletes(a)?(c!=="delete"&&(p(),c="delete"),u+=1):a.deleted||(c!=="retain"&&(p(),c="retain"),f+=1);break;case Ut:this.adds(a)?this.deletes(a)||(c!=="insert"&&(p(),c="insert"),d+=a.content.str):this.deletes(a)?(c!=="delete"&&(p(),c="delete"),u+=a.length):a.deleted||(c!=="retain"&&(p(),c="retain"),f+=a.length);break;case Me:{const{key:m,value:g}=a.content;if(this.adds(a)){if(!this.deletes(a)){const w=r.get(m)??null;mn(w,g)?g!==null&&a.delete(s):(c==="retain"&&p(),mn(g,i.get(m)??null)?delete l[m]:l[m]=g)}}else if(this.deletes(a)){i.set(m,g);const w=r.get(m)??null;mn(w,g)||(c==="retain"&&p(),l[m]=w)}else if(!a.deleted){i.set(m,g);const w=l[m];w!==void 0&&(mn(w,g)?w!==null&&a.delete(s):(c==="retain"&&p(),g===null?delete l[m]:l[m]=g))}a.deleted||(c==="insert"&&p(),_s(r,a.content));break}}a=a.right}for(p();n.length>0;){const m=n[n.length-1];if(m.retain!==void 0&&m.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}}class ks extends He{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??Qe(),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 ks}clone(){const e=new ks;return e.applyDelta(this.toDelta()),e}_callObserver(e,n){super._callObserver(e,n);const s=new gx(this,e,n);Di(this,e,s),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??Qe();let e="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===Ut&&(e+=n.content.str),n=n.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:n=!0}={}){this.doc!==null?ye(this.doc,s=>{const r=new Vo(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)&&co(s,this,r,c,a.attributes||{})}else a.retain!==void 0?ml(s,this,r,a.retain,a.attributes||{}):a.delete!==void 0&&gl(s,r,a.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,s){this.doc??Qe();const r=[],i=new Map,a=this.doc;let c="",l=this._start;function d(){if(c.length>0){const u={};let p=!1;i.forEach((g,w)=>{p=!0,u[w]=g});const m={insert:c};p&&(m.attributes=u),r.push(m),c=""}}const f=()=>{for(;l!==null;){if(ts(l,e)||n!==void 0&&ts(l,n))switch(l.content.constructor){case Ut:{const u=i.get("ychange");e!==void 0&&!ts(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&&!ts(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 Ht:case In:{d();const u={insert:l.content.getContent()[0]};if(i.size>0){const p={};u.attributes=p,i.forEach((m,g)=>{p[g]=m})}r.push(u);break}case Me:ts(l,e)&&(d(),_s(i,l.content));break}l=l.right}d()};return e||n?ye(a,u=>{e&&zo(u,e),n&&zo(u,n),f()},"cleanup"):f(),r}insert(e,n,s){if(n.length<=0)return;const r=this.doc;r!==null?ye(r,i=>{const a=zr(i,this,e,!s);s||(s={},a.currentAttributes.forEach((c,l)=>{s[l]=c})),co(i,this,a,n,s)}):this._pending.push(()=>this.insert(e,n,s))}insertEmbed(e,n,s){const r=this.doc;r!==null?ye(r,i=>{const a=zr(i,this,e,!s);co(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?ye(s,r=>{gl(r,zr(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?ye(r,i=>{const a=zr(i,this,e,!1);a.right!==null&&ml(i,this,a,n,s)}):this._pending.push(()=>this.format(e,n,s))}removeAttribute(e){this.doc!==null?ye(this.doc,n=>{ci(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?ye(this.doc,s=>{Ra(s,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return La(this,e)}getAttributes(){return zu(this)}_write(e){e.writeTypeRef(Fx)}}const yx=t=>new ks;class lo{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??Qe()}[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===Es||n.constructor===_n)&&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 _n extends He{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 _n}clone(){const e=new _n;return e.insert(0,this.toArray().map(n=>n instanceof He?n.clone():n)),e}get length(){return this.doc??Qe(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new lo(this,e)}querySelector(e){e=e.toUpperCase();const s=new lo(this,r=>r.nodeName&&r.nodeName.toUpperCase()===e).next();return s.done?null:s.value}querySelectorAll(e){return e=e.toUpperCase(),sn(new lo(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){Di(this,e,new bx(this,n,e))}toString(){return Fu(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),sr(this,i=>{r.insertBefore(i.toDOM(e,n,s),null)}),r}insert(e,n){this.doc!==null?ye(this.doc,s=>{$u(s,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)ye(this.doc,s=>{const r=e&&e instanceof He?e._item:e;ai(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 Pt("Reference item not found");s.splice(r,0,...n)}}delete(e,n=1){this.doc!==null?ye(this.doc,s=>{Uu(s,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return Au(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Iu(this,e)}slice(e=0,n=this.length){return Lu(this,e,n)}forEach(e){sr(this,e)}_write(e){e.writeTypeRef(Mx)}}const wx=t=>new _n;class Es extends _n{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 Es(this.nodeName)}clone(){const e=new Es(this.nodeName),n=this.getAttributes();return oy(n,(s,r)=>{e.setAttribute(r,s)}),e.insert(0,this.toArray().map(s=>s instanceof He?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?ye(this.doc,n=>{ci(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?ye(this.doc,s=>{Ra(s,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return La(this,e)}hasAttribute(e){return Bu(this,e)}getAttributes(e){return e?cx(this,e):zu(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 sr(this,a=>{r.appendChild(a.toDOM(e,n,s))}),s!==void 0&&s._createAssociation(r,this),r}_write(e){e.writeTypeRef(Ix),e.writeKey(this.nodeName)}}const xx=t=>new Es(t.readKey());class bx extends ki{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 li extends js{constructor(e){super(),this.hookName=e}_copy(){return new li(this.hookName)}clone(){const e=new li(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($x),e.writeKey(this.hookName)}}const vx=t=>new li(t.readKey());class di extends ks{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 di}clone(){const e=new di;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(Ux)}}const Sx=t=>new di;class Aa{constructor(e,n){this.id=e,this.length=n}get deleted(){throw Nt()}mergeWith(e){return!1}write(e,n,s){throw Nt()}integrate(e,n){throw Nt()}}const Cx=0;class xt extends Aa{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),Tu(e.doc.store,this)}write(e,n){e.writeInfo(Cx),e.writeLen(this.length-n)}getMissing(e,n){return null}}class ur{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new ur(this.content)}splice(e){throw Nt()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}}const jx=t=>new ur(t.readBuf());class rr{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new rr(this.len)}splice(e){const n=new rr(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){tr(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 kx=t=>new rr(t.readLen()),Ku=(t,e)=>new Fn({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class hr{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 hr(Ku(this.doc.guid,this.opts))}splice(e){throw Nt()}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 Ex=t=>new hr(Ku(t.readString(),t.readAny()));class In{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new In(this.embed)}splice(e){throw Nt()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}}const Dx=t=>new In(t.readJSON());class Me{constructor(e,n){this.key=e,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new Me(this.key,this.value)}splice(e){throw Nt()}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 Tx=t=>new Me(t.readKey(),t.readJSON());class ui{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new ui(this.arr)}splice(e){const n=new ui(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 Nx=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 ui(n)},Ox=ni("node_env")==="development";class Rn{constructor(e){this.arr=e,Ox&&Ud(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Rn(this.arr)}splice(e){const n=new Rn(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 Px=t=>{const e=t.readLen(),n=[];for(let s=0;s<e;s++)n.push(t.readAny());return new Rn(n)};class Ut{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new Ut(this.str)}splice(e){const n=new Ut(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 _x=t=>new Ut(t.readString()),Rx=[dx,hx,yx,xx,wx,vx,Sx],Lx=0,Ax=1,Fx=2,Ix=3,Mx=4,$x=5,Ux=6;class Ht{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Ht(this.type._copy())}splice(e){throw Nt()}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 zx=t=>new Ht(Rx[t.readTypeRef()](t)),Ho=(t,e)=>{let n=e,s=0,r;do s>0&&(n=Q(n.client,n.clock+s)),r=ds(t,n),s=n.clock-r.id.clock,n=r.redone;while(n!==null&&r instanceof ve);return{item:r,diff:s}},Fa=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},hi=(t,e,n)=>{const{client:s,clock:r}=e.id,i=new ve(Q(s,r+n),e,Q(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=Q(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},yl=(t,e)=>ca(t,n=>lr(n.deletions,e)),Gu=(t,e,n,s,r,i)=>{const a=t.doc,c=a.store,l=a.clientID,d=e.redone;if(d!==null)return ct(t,d);let f=e.parent._item,u=null,p;if(f!==null&&f.deleted===!0){if(f.redone===null&&(!n.has(f)||Gu(t,f,n,s,r,i)===null))return null;for(;f.redone!==null;)f=ct(t,f.redone)}const m=f===null?e.parent:f.content.type;if(e.parentSub===null){for(u=e.left,p=e;u!==null;){let v=u;for(;v!==null&&v.parent._item!==f;)v=v.redone===null?null:ct(t,v.redone);if(v!==null&&v.parent._item===f){u=v;break}u=u.left}for(;p!==null;){let v=p;for(;v!==null&&v.parent._item!==f;)v=v.redone===null?null:ct(t,v.redone);if(v!==null&&v.parent._item===f){p=v;break}p=p.right}}else{if(p=null,e.right&&!r){for(u=e;u!==null&&u.right!==null&&(u.right.redone||lr(s,u.right.id)||yl(i.undoStack,u.right.id)||yl(i.redoStack,u.right.id));)for(u=u.right;u.redone;)u=ct(t,u.redone);if(u&&u.right!==null)return null}else u=m._map.get(e.parentSub)||null;u!==null&&u.parent._item!==f&&(u=m._map.get(e.parentSub)||null)}const g=Pe(c,l),w=Q(l,g),b=new ve(w,u,u&&u.lastId,p,p&&p.id,m,e.parentSub,e.content.copy());return e.redone=w,Fa(b,!0),b.integrate(t,0),b};class ve extends Aa{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()?Kc:0}set marker(e){(this.info&no)>0!==e&&(this.info^=no)}get marker(){return(this.info&no)>0}get keep(){return(this.info&Wc)>0}set keep(e){this.keep!==e&&(this.info^=Wc)}get countable(){return(this.info&Kc)>0}get deleted(){return(this.info&to)>0}set deleted(e){this.deleted!==e&&(this.info^=to)}markDeleted(){this.info|=to}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=Pe(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Pe(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===ls&&this.id.client!==this.parent.client&&this.parent.clock>=Pe(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=cl(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=ct(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===xt||this.right&&this.right.constructor===xt)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===ve?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===ve&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===ls){const s=ds(n,this.parent);s.constructor===xt?this.parent=null:this.parent=s.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=cl(e,e.doc.store,Q(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),is(this.origin,r.origin)){if(r.id.client<this.id.client)s=r,i.clear();else if(is(this.rightOrigin,r.rightOrigin))break}else if(r.origin!==null&&a.has(ds(e.doc.store,r.origin)))i.has(ds(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),Tu(e.doc.store,this),this.content.integrate(e,this),dl(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new xt(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:Q(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&is(e.origin,this.lastId)&&this.right===e&&is(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(),tr(e.deleteSet,this.id.client,this.id.clock,this.length),dl(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw ft();this.content.gc(e),n?Hw(e,this,new xt(this.id,this.length)):this.content=new rr(this.length)}write(e,n){const s=n>0?Q(this.id.client,this.id.clock+n-1):this.origin,r=this.rightOrigin,i=this.parentSub,a=this.content.getRef()&mi|(s===null?0:ht)|(r===null?0:en)|(i===null?0:Js);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=ku(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===ls?(e.writeParentInfo(!1),e.writeLeftID(c)):ft();i!==null&&e.writeString(i)}this.content.write(e,n)}}const Ju=(t,e)=>Bx[e&mi](t),Bx=[()=>{ft()},kx,Nx,jx,_x,Dx,Tx,zx,Px,Ex,()=>{ft()}],Vx=10;class bt extends Aa{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){ft()}write(e,n){e.writeInfo(Vx),U(e.restEncoder,this.length-n)}getMissing(e,n){return null}}const Yu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Xu="__ $YJS$ __";Yu[Xu]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Yu[Xu]=!0;const Zu=new Map;class Hx{constructor(e){this.room=e,this.onmessage=null,this._onChange=n=>n.key===e&&this.onmessage!==null&&this.onmessage({data:jy(n.newValue||"")}),ty(this._onChange)}postMessage(e){Md.setItem(this.room,Cy(wy(e)))}close(){ny(this._onChange)}}const qx=typeof BroadcastChannel>"u"?Hx:BroadcastChannel,Ia=t=>Bt(Zu,t,()=>{const e=xn(),n=new qx(t);return n.onmessage=s=>e.forEach(r=>r(s.data,"broadcastchannel")),{bc:n,subs:e}}),Wx=(t,e)=>(Ia(t).subs.add(e),e),Kx=(t,e)=>{const n=Ia(t),s=n.subs.delete(e);return s&&n.subs.size===0&&(n.bc.close(),Zu.delete(t)),s},ns=(t,e,n=null)=>{const s=Ia(t);s.bc.postMessage(e),s.subs.forEach(r=>r(e,n))},Qu=0,Ma=1,eh=2,fi=(t,e)=>{U(t,Qu);const n=Mw(e);Te(t,n)},th=(t,e,n)=>{U(t,Ma),Te(t,Ta(e,n))},Gx=(t,e,n)=>th(e,n,Xe(t)),nh=(t,e,n,s)=>{try{vu(e,Xe(t),n)}catch(r){s?.(r),console.error("Caught error while handling a Yjs update",r)}},Jx=(t,e)=>{U(t,eh),Te(t,e)},Yx=nh,Xx=(t,e,n,s,r)=>{const i=Y(t);switch(i){case Qu:Gx(t,e,n);break;case Ma:nh(t,n,s,r);break;case eh:Yx(t,n,s,r);break;default:throw new Error("Unknown message type")}return i},Zx=0,Qx=(t,e,n)=>{Y(t)===Zx&&n(e,Ze(t))},uo=3e4;class eb extends Pd{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const n=bn();this.getLocalState()!==null&&uo/2<=n-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const s=[];this.meta.forEach((r,i)=>{i!==this.clientID&&uo<=n-r.lastUpdated&&this.states.has(i)&&s.push(i)}),s.length>0&&$a(this,s,"timeout")},Ot(uo/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:bn()});const a=[],c=[],l=[],d=[];e===null?d.push(n):i==null?e!=null&&a.push(n):(c.push(n),as(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 $a=(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:bn()})}s.push(i)}}s.length>0&&(t.emit("change",[{added:[],updated:[],removed:s},n]),t.emit("update",[{added:[],updated:[],removed:s},n]))},hs=(t,e,n=t.states)=>{const s=e.length,r=Le();U(r,s);for(let i=0;i<s;i++){const a=e[i],c=n.get(a)||null,l=t.meta.get(a).clock;U(r,a),U(r,l),tn(r,JSON.stringify(c))}return be(r)},tb=(t,e,n)=>{const s=Sn(e),r=bn(),i=[],a=[],c=[],l=[],d=Y(s);for(let f=0;f<d;f++){const u=Y(s);let p=Y(s);const m=JSON.parse(Ze(s)),g=t.meta.get(u),w=t.states.get(u),b=g===void 0?0:g.clock;(b<p||b===p&&m===null&&t.states.has(u))&&(m===null?u===t.clientID&&t.getLocalState()!=null?p++:t.states.delete(u):t.states.set(u,m),t.meta.set(u,{clock:p,lastUpdated:r}),g===void 0&&m!==null?i.push(u):g!==void 0&&m===null?l.push(u):m!==null&&(as(m,w)||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])},nb=t=>ay(t,(e,n)=>`${encodeURIComponent(n)}=${encodeURIComponent(e)}`).join("&"),Nn=0,sh=3,fs=1,sb=2,fr=[];fr[Nn]=(t,e,n,s,r)=>{U(t,Nn);const i=Xx(e,t,n.doc,n);s&&i===Ma&&!n.synced&&(n.synced=!0)};fr[sh]=(t,e,n,s,r)=>{U(t,fs),Te(t,hs(n.awareness,Array.from(n.awareness.getStates().keys())))};fr[fs]=(t,e,n,s,r)=>{tb(n.awareness,Xe(e),n)};fr[sb]=(t,e,n,s,r)=>{Qx(e,n.doc,(i,a)=>rb(n,a))};const wl=3e4,rb=(t,e)=>console.warn(`Permission denied to access ${t.url}.
12
- ${e}`),rh=(t,e,n)=>{const s=Sn(e),r=Le(),i=Y(s),a=t.messageHandlers[i];return a?a(r,s,t,n,i):console.error("Unable to compute message"),r},qo=(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,$a(t.awareness,Array.from(t.awareness.getStates().keys()).filter(s=>s!==t.doc.clientID),t),t.emit("status",[{status:"disconnected"}])):t.wsUnsuccessfulReconnects++,setTimeout(ih,da(Sg(2,t.wsUnsuccessfulReconnects)*100,t.maxBackoffTime),t))},ih=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=bn();const s=rh(t,new Uint8Array(n.data),!0);ua(s)>1&&e.send(be(s))},e.onerror=n=>{t.emit("connection-error",[n,t])},e.onclose=n=>{qo(t,e,n)},e.onopen=()=>{t.wsLastMessageReceived=bn(),t.wsconnecting=!1,t.wsconnected=!0,t.wsUnsuccessfulReconnects=0,t.emit("status",[{status:"connected"}]);const n=Le();if(U(n,Nn),fi(n,t.doc),e.send(be(n)),t.awareness.getLocalState()!==null){const s=Le();U(s,fs),Te(s,hs(t.awareness,[t.doc.clientID])),e.send(be(s))}},t.emit("status",[{status:"connecting"}])}},ho=(t,e)=>{const n=t.ws;t.wsconnected&&n&&n.readyState===n.OPEN&&n.send(e),t.bcconnected&&ns(t.bcChannel,e,t)};class ib extends la{constructor(e,n,s,{connect:r=!0,awareness:i=new eb(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=fr.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 p=Le();U(p,Nn),fi(p,s),this.ws.send(be(p))}},d)),this._bcSubscriber=(p,m)=>{if(m!==this){const g=rh(this,new Uint8Array(p),!1);ua(g)>1&&ns(this.bcChannel,be(g),this)}},this._updateHandler=(p,m)=>{if(m!==this){const g=Le();U(g,Nn),Jx(g,p),ho(this,be(g))}},this.doc.on("update",this._updateHandler),this._awarenessUpdateHandler=({added:p,updated:m,removed:g},w)=>{const b=p.concat(m).concat(g),v=Le();U(v,fs),Te(v,hs(i,b)),ho(this,be(v))},this._exitHandler=()=>{$a(this.awareness,[s.clientID],"app closed")},vn&&typeof process<"u"&&process.on("exit",this._exitHandler),i.on("update",this._awarenessUpdateHandler),this._checkInterval=setInterval(()=>{this.wsconnected&&wl<bn()-this.wsLastMessageReceived&&qo(this,this.ws,null)},wl/10),r&&this.connect()}get url(){const e=nb(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(),vn&&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||(Wx(this.bcChannel,this._bcSubscriber),this.bcconnected=!0);const e=Le();U(e,Nn),fi(e,this.doc),ns(this.bcChannel,be(e),this);const n=Le();U(n,Nn),th(n,this.doc),ns(this.bcChannel,be(n),this);const s=Le();U(s,sh),ns(this.bcChannel,be(s),this);const r=Le();U(r,fs),Te(r,hs(this.awareness,[this.doc.clientID])),ns(this.bcChannel,be(r),this)}disconnectBc(){const e=Le();U(e,fs),Te(e,hs(this.awareness,[this.doc.clientID],new Map)),ho(this,be(e)),this.bcconnected&&(Kx(this.bcChannel,this._bcSubscriber),this.bcconnected=!1)}disconnect(){this.shouldConnect=!1,this.disconnectBc(),this.ws!==null&&qo(this,this.ws,null)}connect(){this.shouldConnect=!0,!this.wsconnected&&this.ws===null&&(ih(this),this.connectBc())}}const Mn=t=>bs((e,n)=>{t.onerror=s=>n(new Error(s.target.error)),t.onsuccess=s=>e(s.target.result)}),ob=(t,e)=>bs((n,s)=>{const r=indexedDB.open(t);r.onupgradeneeded=i=>e(i.target.result),r.onerror=i=>s(Pt(i.target.error)),r.onsuccess=i=>{const a=i.target.result;a.onversionchange=()=>{a.close()},n(a)}}),ab=t=>Mn(indexedDB.deleteDatabase(t)),cb=(t,e)=>e.forEach(n=>t.createObjectStore.apply(t,n)),Us=(t,e,n="readwrite")=>{const s=t.transaction(e,n);return e.map(r=>gb(s,r))},oh=(t,e)=>Mn(t.count(e)),lb=(t,e)=>Mn(t.get(e)),ah=(t,e)=>Mn(t.delete(e)),db=(t,e,n)=>Mn(t.put(e,n)),Wo=(t,e)=>Mn(t.add(e)),ub=(t,e,n)=>Mn(t.getAll(e,n)),hb=(t,e,n)=>{let s=null;return mb(t,e,r=>(s=r,!1),n).then(()=>s)},fb=(t,e=null)=>hb(t,e,"prev"),pb=(t,e)=>bs((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()}}),mb=(t,e,n,s="next")=>pb(t.openKeyCursor(e,s),r=>n(r.key)),gb=(t,e)=>t.objectStore(e),yb=(t,e)=>IDBKeyRange.upperBound(t,e),wb=(t,e)=>IDBKeyRange.lowerBound(t,e),fo="custom",ch="updates",lh=500,dh=(t,e=()=>{},n=()=>{})=>{const[s]=Us(t.db,[ch]);return ub(s,wb(t._dbref,!1)).then(r=>{t._destroyed||(e(s),ye(t.doc,()=>{r.forEach(i=>vu(t.doc,i))},t,!1),n(s))}).then(()=>fb(s).then(r=>{t._dbref=r+1})).then(()=>oh(s).then(r=>{t._dbsize=r})).then(()=>s)},xb=(t,e=!0)=>dh(t).then(n=>{(e||t._dbsize>=lh)&&Wo(n,Ta(t.doc)).then(()=>ah(n,yb(t._dbref,!0))).then(()=>oh(n).then(s=>{t._dbsize=s}))});class bb extends Pd{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=ob(e,s=>cb(s,[["updates",{autoIncrement:!0}],["custom"]])),this.whenSynced=bs(s=>this.on("synced",()=>s(this))),this._db.then(s=>{this.db=s,dh(this,a=>Wo(a,Ta(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]=Us(this.db,[ch]);Wo(i,s),++this._dbsize>=lh&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{xb(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(()=>{ab(this.name)})}get(e){return this._db.then(n=>{const[s]=Us(n,[fo],"readonly");return lb(s,e)})}set(e,n){return this._db.then(s=>{const[r]=Us(s,[fo]);return db(r,n,e)})}del(e){return this._db.then(n=>{const[s]=Us(n,[fo]);return ah(s,e)})}}const xl=[["#1677c8","#1677c833"],["#d65745","#d6574533"],["#16866a","#16866a33"],["#9a58b5","#9a58b533"],["#d27b18","#d27b1833"],["#3f7d20","#3f7d2033"],["#be3e7b","#be3e7b33"],["#4964c6","#4964c633"],["#8a6a14","#8a6a1433"],["#087f8c","#087f8c33"]],bl=4,vl=5,vb=6,Sb=7,Cb=8,jb=2;function kb(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","cleaned"].includes(e.status??"")||e.status==="cleaned"&&e.cleanMode!=="cache"&&e.cleanMode!=="artifacts"||e.stale!==void 0&&typeof e.stale!="boolean"||typeof e.updatedAt!="string"||!n||typeof n.id!="string"||typeof n.username!="string"||typeof n.name!="string"?null:e}function Sl(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[n,s]of Object.entries(t)){const r=kb(s);r&&r.mainFile===n&&(e[n]=r)}return e}class Eb{constructor(e,n){this.projectId=e,this.user=n;const s=window.location.protocol==="https:"?"wss:":"ws:";this.persistence=new bb(`texlite:${n.id}:${e}`,this.doc),this.persistence.on("synced",()=>{this.localDraftReady=!0;for(const i of this.draftListeners)i()}),this.provider=new ib(`${s}//${window.location.host}/api/collaboration`,e,this.doc,{connect:!1,disableBc:!0,maxBackoffTime:2500}),this.awareness=this.provider.awareness;const r=this.doc.getMap("texlite:meta");this.metaObserver=(i,a)=>{a.origin===this.provider&&i.keysChanged.has("compileStates")&&(this.authoritativeCompileStates=null,this.notifyCompileStateListeners())},r.observe(this.metaObserver),this.provider.messageHandlers[bl]=(i,a)=>{const c=Ze(a),l=this.flushRequests.get(c);if(!l)return;const d=Y(a)===1,f=Y(a),u=Ze(a),p=Y(a),m=[];for(let g=0;g<p;g++)m.push(Ze(a));if(window.clearTimeout(l.timer),this.flushRequests.delete(c),d)l.resolve({revision:f,persistedAt:u,ok:!0,failedPaths:[]});else{const g=Object.assign(new Error(m.length?`保存失败:${m.join(", ")}`:"源码保存到服务器磁盘失败"),{failedPaths:m});l.reject(g)}},this.provider.messageHandlers[vl]=(i,a)=>{const c=Ze(a),l=this.epochStorageKey(),d=Db(l);if(this.epoch&&this.epoch!==c||d&&d!==c){this.provider.disconnect(),this.rejectFlushes(new Error("Collaboration state changed"));const g=/^([0-9]+):/.exec(c)?.[1]??null,w=d?/^([0-9]+):/.exec(d)?.[1]??null:null,b=c.endsWith(":reload")||g!==null&&g!==w,v=()=>{Cl(l,c.replace(/:reload$/,"")),window.location.reload()};b?v():this.persistence.clearData().then(v);return}this.epoch=c,Cl(l,c);const f=this.provider.ws;if(!f||f.readyState!==WebSocket.OPEN)return;const u=Le();U(u,vl),tn(u,c),U(u,jb),f.send(be(u));const p=Le();U(p,0),fi(p,this.doc),f.send(be(p));const m=Le();U(m,1),Te(m,hs(this.awareness,[this.doc.clientID])),f.send(be(m))},this.provider.messageHandlers[Sb]=(i,a)=>{const c=Ze(a),l=Ze(a);if(c!==this.user.id)return;if(l==="revoked"){this.rejectFlushes(new Error("Project access revoked")),this.provider.disconnect();for(const f of this.permissionListeners)f("revoked");return}if(l!=="read"&&l!=="edit"&&l!=="owner")return;const d=this.permission;this.setPermission(l,!0),d!==l&&l==="read"&&this.persistence.clearData().finally(()=>window.location.reload())},this.provider.messageHandlers[vb]=(i,a)=>{Ze(a)},this.provider.messageHandlers[Cb]=(i,a)=>{let c={};try{c=Sl(JSON.parse(Ze(a)))}catch{}this.authoritativeCompileStates=c,this.notifyCompileStateListeners()},this.provider.on("status",({status:i})=>{i==="disconnected"&&(this.authoritativeCompileStates=null,this.notifyCompileStateListeners(),this.rejectFlushes(new Error("Collaboration connection closed")))}),this.updateLocalAwareness()}projectId;user;doc=new Fn;provider;awareness;persistence;permission="read";activeFile="";epoch=null;destroyed=!1;localDraftReady=!1;draftListeners=new Set;permissionListeners=new Set;compileStateListeners=new Set;flushRequests=new Map;undoManagers=new Map;authoritativeCompileStates=null;metaObserver;connect(){this.destroyed||(this.provider.connect(),this.updateLocalAwareness())}getText(e){return this.doc.getText(`source:${e}`)}getUndoManager(e){const n=this.undoManagers.get(e);if(n)return n;const s=new Jw(this.getText(e));return this.undoManagers.set(e,s),s}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")}compileStates(){return this.authoritativeCompileStates??Sl(this.meta.get("compileStates"))}onCompileStates(e){return this.compileStateListeners.add(e),()=>this.compileStateListeners.delete(e)}get synced(){return this.provider.synced}get connected(){return this.provider.wsconnected}get draftReady(){return this.localDraftReady}get currentPermission(){return this.permission}onDraftReady(e){return this.draftListeners.add(e),this.localDraftReady&&e(),()=>this.draftListeners.delete(e)}onPermissionChanged(e){return this.permissionListeners.add(e),()=>this.permissionListeners.delete(e)}setPermission(e,n=!1){if(this.permission=e,e==="read"&&this.destroyUndoManagers(),this.updateLocalAwareness(),n)for(const s of this.permissionListeners)s(e)}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=Le();return U(s,bl),tn(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(be(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.compileStateListeners.clear(),this.meta.unobserve(this.metaObserver),this.destroyUndoManagers(),this.doc.destroy()}destroyUndoManagers(){for(const e of this.undoManagers.values())e.destroy();this.undoManagers.clear()}notifyCompileStateListeners(){for(const e of this.compileStateListeners)e()}rejectFlushes(e){for(const n of this.flushRequests.values())window.clearTimeout(n.timer),n.reject(e);this.flushRequests.clear()}updateLocalAwareness(){const[e,n]=xl[Math.abs(this.doc.clientID)%xl.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 Db(t){try{return window.localStorage.getItem(t)}catch{return null}}function Cl(t,e){try{window.localStorage.setItem(t,e)}catch{}}function Tb(t,e){return Array.from(t.trim()||e.trim()||"?")[0]?.toLocaleUpperCase()??"?"}function Nb({sessions:t,status:e}){const{t:n}=Ae(),[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:[Tb(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 Ob({value:t,onChange:e}){const{t:n}=Ae(),[s,r]=h.useState(!1),i=h.useRef(null),a=[{value:"editor-pdf",icon:Fc},{value:"editor-only",icon:Ym},{value:"pdf-only",icon:Xm}];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(Fc,{size:15}),o.jsxs("span",{children:[o.jsx("small",{children:n("editor.layout.label")}),n(`editor.layout.${t}.name`)]}),o.jsx(Cd,{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(Fm,{size:16})]},c.value)})]})]})}function Pb({comment:t,currentUserId:e,onFocus:n,onToggle:s,onReply:r,onEdit:i,onDelete:a,onEditReply:c,onDeleteReply:l}){const{t:d}=Ae(),[f,u]=h.useState(!1),[p,m]=h.useState(""),[g,w]=h.useState(!1),[b,v]=h.useState(t.content),[k,P]=h.useState(!1),[N,O]=h.useState(null),[W,E]=h.useState(""),[J,C]=h.useState(null),V=async j=>{j.preventDefault(),p.trim()&&await r(p)&&(m(""),u(!1))},Z=async j=>{j.preventDefault(),b.trim()&&await i(b)&&w(!1)},R=async j=>{j.preventDefault(),!(!N||!W.trim())&&await c(N,W)&&O(null)},_=t.authorUsername,L=j=>new Date(j).toLocaleString(he.resolvedLanguage);return o.jsxs(o.Fragment,{children:[o.jsxs("article",{className:`comment-thread${t.resolved?" resolved":""}${t.orphaned?" orphaned":""}`,onClick:()=>{window.getSelection()?.toString()||n()},children:[o.jsxs("header",{className:"comment-header",children:[o.jsxs("span",{className:"comment-author",children:[o.jsx("strong",{children:t.authorDisplayName??_??d("editor.deletedUser")}),_&&o.jsxs("small",{children:["@",_]})]}),o.jsxs("span",{className:"comment-times",children:[o.jsx("time",{dateTime:t.createdAt,title:new Date(t.createdAt).toISOString(),children:L(t.createdAt)}),t.editedAt&&o.jsx("small",{children:d("editor.editedAt",{time:L(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",{className:"comment-selected-text",children:t.selectedText}),g?o.jsxs("form",{className:"comment-reply-form comment-edit-form",onSubmit:j=>{Z(j)},onClick:j=>j.stopPropagation(),children:[o.jsx("textarea",{autoFocus:!0,rows:4,value:b,onChange:j=>v(j.target.value)}),o.jsxs("div",{children:[o.jsx("button",{type:"button",onClick:()=>w(!1),children:d("common.cancel")}),o.jsxs("button",{className:"primary",type:"submit",disabled:!b.trim(),children:[o.jsx(Yr,{size:13}),d("editor.saveChanges")]})]})]}):o.jsx("p",{className:"comment-content",children:t.content}),t.replies.length>0&&o.jsx("div",{className:"comment-replies",children:t.replies.map(j=>o.jsxs("div",{className:"comment-reply",children:[o.jsxs("header",{children:[o.jsxs("span",{className:"comment-author",children:[o.jsx("strong",{children:j.authorDisplayName??j.authorUsername??d("editor.deletedUser")}),j.authorUsername&&o.jsxs("small",{children:["@",j.authorUsername]})]}),o.jsxs("span",{className:"comment-times",children:[o.jsx("time",{dateTime:j.createdAt,title:new Date(j.createdAt).toISOString(),children:L(j.createdAt)}),j.editedAt&&o.jsx("small",{children:d("editor.editedAt",{time:L(j.editedAt)})})]})]}),N===j.id?o.jsxs("form",{className:"comment-reply-form comment-edit-form",onSubmit:H=>{R(H)},onClick:H=>H.stopPropagation(),children:[o.jsx("textarea",{autoFocus:!0,rows:3,value:W,onChange:H=>E(H.target.value)}),o.jsxs("div",{children:[o.jsx("button",{type:"button",onClick:()=>O(null),children:d("common.cancel")}),o.jsxs("button",{className:"primary",type:"submit",disabled:!W.trim(),children:[o.jsx(Yr,{size:13}),d("editor.saveChanges")]})]})]}):o.jsx("p",{className:"comment-content",children:j.content}),j.authorId===e&&N!==j.id&&o.jsxs("div",{className:"comment-owner-actions",children:[o.jsx("button",{title:d("editor.editReply"),"aria-label":d("editor.editReply"),onClick:H=>{H.stopPropagation(),O(j.id),E(j.content)},children:o.jsx(Po,{size:12})}),o.jsx("button",{className:"danger-text",title:d("editor.deleteReply"),"aria-label":d("editor.deleteReply"),onClick:H=>{H.stopPropagation(),C(j.id)},children:o.jsx(wn,{size:12})})]})]},j.id))}),o.jsxs("div",{className:"comment-actions",children:[o.jsxs("button",{className:"resolve",onClick:j=>{j.stopPropagation(),s()},children:[t.resolved?o.jsx(tg,{size:13}):o.jsx($m,{size:13}),t.resolved?d("editor.reopen"):d("editor.resolve")]}),o.jsxs("button",{className:"reply-action",onClick:j=>{j.stopPropagation(),u(H=>!H)},children:[o.jsx(eg,{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:j=>{j.stopPropagation(),v(t.content),w(!0)},children:o.jsx(Po,{size:13})}),o.jsx("button",{className:"danger-text",title:d("editor.deleteComment"),"aria-label":d("editor.deleteComment"),onClick:j=>{j.stopPropagation(),P(!0)},children:o.jsx(wn,{size:13})})]})]}),f&&o.jsxs("form",{className:"comment-reply-form",onSubmit:j=>{V(j)},onClick:j=>j.stopPropagation(),children:[o.jsx("textarea",{autoFocus:!0,rows:3,value:p,placeholder:d("editor.replyPlaceholder"),onChange:j=>m(j.target.value)}),o.jsxs("div",{children:[o.jsx("button",{type:"button",onClick:()=>{u(!1),m("")},children:d("common.cancel")}),o.jsxs("button",{className:"primary",type:"submit",disabled:!p.trim(),children:[o.jsx(sg,{size:13}),d("editor.sendReply")]})]})]})]}),o.jsx(gs,{open:k,title:d("editor.deleteCommentTitle"),description:d("editor.deleteCommentDescription",{count:t.replies.length}),confirmLabel:d("common.delete"),danger:!0,onCancel:()=>P(!1),onConfirm:()=>{a().then(j=>{j&&P(!1)})}}),o.jsx(gs,{open:!!J,title:d("editor.deleteReplyTitle"),description:d("editor.deleteReplyDescription"),confirmLabel:d("common.delete"),danger:!0,onCancel:()=>C(null),onConfirm:()=>{J&&l(J).then(j=>{j&&C(null)})}})]})}function _b({open:t,onOpenChange:e,project:n,projectId:s}){const{t:r}=Ae(),[i,a]=h.useState([]),[c,l]=h.useState([]),[d,f]=h.useState(""),[u,p]=h.useState("read"),[m,g]=h.useState(null),[w,b]=h.useState(""),v=n.permission==="owner",k=async()=>{try{const[E,J]=await Promise.all([A(`/api/projects/${s}/members`),A("/api/users")]);a(E.members),l(J.users.filter(C=>C.id!==n.ownerId))}catch(E){b(q(E))}};h.useEffect(()=>{t&&k()},[t,s]);const P=async()=>{if(d)try{await A(`/api/projects/${s}/members/${d}`,{method:"PUT",body:JSON.stringify({permission:u})}),f(""),p("read"),await k()}catch(E){b(q(E))}},N=async(E,J)=>{try{await A(`/api/projects/${s}/members/${E.id}`,{method:"PUT",body:JSON.stringify({permission:J})}),await k()}catch(C){b(q(C))}},O=async()=>{if(m)try{await A(`/api/projects/${s}/members/${m.id}`,{method:"DELETE"}),g(null),await k()}catch(E){b(q(E))}},W=c.filter(E=>!i.some(J=>J.id===E.id));return o.jsxs(o.Fragment,{children:[o.jsx(Ve,{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:[w&&o.jsx("p",{className:"error",children:w}),o.jsxs("div",{className:"share-owner",children:[o.jsx(Gs,{size:17}),o.jsxs("span",{children:[o.jsx("small",{children:r("projects.owner")}),o.jsx("strong",{children:n.ownerDisplayName??n.ownerUsername})]})]}),v&&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")}),W.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=>p(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:()=>{P()},children:[o.jsx(Nd,{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:!v,value:E.permission,onChange:J=>{N(E,J.target.value)},children:[o.jsx("option",{value:"read",children:r("common.readOnly")}),o.jsx("option",{value:"edit",children:r("common.readWrite")})]}),v&&o.jsx("button",{className:"icon-only danger-text",title:r("common.remove"),"aria-label":r("common.remove"),onClick:()=>g(E),children:o.jsx(wn,{size:15})})]})]},E.id)),i.length===0&&o.jsxs("div",{className:"share-empty",children:[o.jsx(Gs,{size:24}),o.jsx("span",{children:r("projectSettings.noMembers")})]})]})]})}),o.jsx(gs,{open:!!m,title:r("projectSettings.removeTitle"),description:r("projectSettings.removeDescription",{username:m?.username??""}),confirmLabel:r("common.remove"),danger:!0,onCancel:()=>g(null),onConfirm:()=>{O()}})]})}function Rb({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:p}){const{t:m}=Ae(),[g,w]=h.useState(t.engine),[b,v]=h.useState(""),[k,P]=h.useState(t.name),[N,O]=h.useState(t.mainFile),[W,E]=h.useState(""),[J,C]=h.useState(""),[V,Z]=h.useState(""),[R,_]=h.useState("appearance"),[L,j]=h.useState(a),H=t.permission==="owner",fe=t.permission!=="read",Ce=t.permission!=="read";h.useEffect(()=>j(a),[a]),h.useEffect(()=>{if(!t.latexmkrc)return v("");A(`/api/projects/${e}/file?path=${encodeURIComponent(t.latexmkrc)}`).then(({content:D})=>v(D)).catch(D=>E(q(D)))},[t.latexmkrc]);const ce=s.filter(D=>D.type==="file"&&/\.tex$/i.test(D.path)).map(D=>D.path),we=[...new Set(t.mainFile&&t.mainFile.toLowerCase().endsWith(".tex")?[...ce,t.mainFile]:ce)].sort((D,ie)=>D.localeCompare(ie)),G=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 ie=await A(`/api/projects/${e}`,{method:"PATCH",body:JSON.stringify({name:k,mainFile:N,engine:g,latexmkrc:D})});p(ie.project)}catch(D){E(q(D))}},K=()=>c(L),ge=async()=>{const D=J.trim();if(D)try{const ie=await A(`/api/projects/${e}/dictionary`,{method:"POST",body:JSON.stringify({word:D})});i(ie.words),C(""),Z("")}catch(ie){Z(q(ie))}},pe=async D=>{try{const ie=await A(`/api/projects/${e}/dictionary/${encodeURIComponent(D)}`,{method:"DELETE"});i(ie.words),Z("")}catch(ie){Z(q(ie))}};return o.jsxs("div",{className:"settings padded",children:[W&&o.jsx("p",{className:"error",children:W}),o.jsxs("div",{className:"settings-tabs",role:"tablist","aria-label":m("common.settings"),children:[o.jsxs("button",{id:"settings-tab-appearance",type:"button",role:"tab","aria-selected":R==="appearance","aria-controls":"settings-panel-appearance",className:`settings-tab${R==="appearance"?" active":""}`,onClick:()=>_("appearance"),children:[o.jsx(Uc,{size:15}),m("projectSettings.editorTab")]}),o.jsxs("button",{id:"settings-tab-compiler",type:"button",role:"tab","aria-selected":R==="compiler","aria-controls":"settings-panel-compiler",className:`settings-tab${R==="compiler"?" active":""}`,onClick:()=>_("compiler"),children:[o.jsx(Ro,{size:15}),m("projectSettings.compilerTab")]})]}),R==="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(Uc,{size:15}),o.jsx("strong",{children:m("projectSettings.editorAppearance")})]}),o.jsx("p",{className:"settings-description appearance-description",children:m("projectSettings.editorAppearanceDescription")}),o.jsxs("label",{children:[m("projectSettings.fontFamily"),o.jsx("select",{value:L.font,onChange:D=>j({...L,font:D.target.value}),children:Qr.map(D=>o.jsx("option",{value:D.id,children:m(D.labelKey)},D.id))})]}),o.jsxs("label",{children:[m("projectSettings.fontSize"),o.jsx("select",{value:L.fontSize,onChange:D=>j({...L,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:[m("projectSettings.lineHeight"),o.jsxs("select",{value:L.lineHeight,onChange:D=>j({...L,lineHeight:Number(D.target.value)}),children:[o.jsx("option",{value:1.45,children:m("projectSettings.lineHeightCompact")}),o.jsx("option",{value:1.65,children:m("projectSettings.lineHeightNormal")}),o.jsx("option",{value:1.85,children:m("projectSettings.lineHeightRelaxed")})]})]}),o.jsxs("label",{className:"editor-checkbox",children:[o.jsx("input",{type:"checkbox",checked:L.lineWrapping,onChange:D=>j({...L,lineWrapping:D.target.checked})}),o.jsx(og,{size:15}),o.jsx("span",{children:m("projectSettings.lineWrapping")})]}),o.jsxs("div",{className:"editor-preference",children:[o.jsxs("label",{className:"editor-checkbox",children:[o.jsx("input",{type:"checkbox",checked:L.spellCheck,onChange:D=>j({...L,spellCheck:D.target.checked})}),o.jsx("span",{children:m("projectSettings.spellCheck")})]}),o.jsxs("p",{className:"field-hint",children:[m("projectSettings.writingCheckDescription")," ",o.jsx("a",{href:"https://writewithharper.com/docs/harperjs/introduction",target:"_blank",rel:"noreferrer",children:"Harper.js"})]})]}),o.jsxs("div",{className:"editor-preference",children:[o.jsxs("label",{className:"editor-checkbox",children:[o.jsx("input",{type:"checkbox",checked:L.vimMode,onChange:D=>j({...L,vimMode:D.target.checked})}),o.jsx("span",{children:m("projectSettings.vimMode")})]}),o.jsxs("p",{className:"field-hint",children:[m("projectSettings.vimModeDescription")," ",o.jsx("a",{href:"https://replit-codemirror-vim.mintlify.app/",target:"_blank",rel:"noreferrer",children:m("projectSettings.vimHelp")})]})]}),o.jsxs("div",{className:"editor-preference",children:[o.jsxs("label",{className:"editor-checkbox",children:[o.jsx("input",{type:"checkbox",checked:L.openFilesInTabs,onChange:D=>j({...L,openFilesInTabs:D.target.checked})}),o.jsx(Zm,{size:15}),o.jsx("span",{children:m("projectSettings.openFilesInTabs")})]}),o.jsx("p",{className:"field-hint",children:m("projectSettings.openFilesInTabsDescription")})]}),o.jsxs("div",{className:"editor-preference",children:[o.jsxs("label",{className:"editor-checkbox",children:[o.jsx("input",{type:"checkbox",disabled:!fe,checked:L.formatOnCompile,onChange:D=>j({...L,formatOnCompile:D.target.checked})}),o.jsx(vd,{size:15}),o.jsx("span",{children:m("projectSettings.formatOnCompile")})]}),o.jsxs("p",{className:"field-hint",children:[m(fe?"projectSettings.formatOnCompileDescription":"projectSettings.formatRequiresWrite")," ",m("projectSettings.formatterDescription")," ",o.jsx("a",{href:"https://github.com/wgunderwood/tex-fmt",target:"_blank",rel:"noreferrer",children:m("projectSettings.formatterInstall")})]})]}),l!==null&&o.jsxs("div",{className:`spell-check-result${l?" has-issues":""}`,role:"status","aria-live":"polite",children:[o.jsx(ig,{size:14}),o.jsx("span",{children:l?m("projectSettings.writingIssues",{count:l,uniqueCount:d??0}):m("projectSettings.noWritingIssues")}),l>0&&o.jsxs("span",{className:"spell-check-controls",children:[o.jsx("button",{type:"button",title:m("projectSettings.spellCheckFirst"),"aria-label":m("projectSettings.spellCheckFirst"),disabled:f<=0,onClick:()=>u(0),children:o.jsx(Im,{size:14})}),o.jsx("button",{type:"button",title:m("projectSettings.spellCheckPrevious"),"aria-label":m("projectSettings.spellCheckPrevious"),disabled:f<=0,onClick:()=>u(f-1),children:o.jsx(jd,{size:14})}),o.jsx("span",{className:"spell-check-position",children:m("projectSettings.spellCheckPosition",{current:Math.min(f+1,l),total:l})}),o.jsx("button",{type:"button",title:m("projectSettings.spellCheckNext"),"aria-label":m("projectSettings.spellCheckNext"),disabled:f>=l-1,onClick:()=>u(f+1),children:o.jsx(ia,{size:14})}),o.jsx("button",{type:"button",title:m("projectSettings.spellCheckLast"),"aria-label":m("projectSettings.spellCheckLast"),disabled:f>=l-1,onClick:()=>u(l-1),children:o.jsx(Mm,{size:14})})]})]}),o.jsxs("div",{className:"settings-section-title",children:[o.jsx(Do,{size:15}),o.jsx("strong",{children:m("projectSettings.dictionary")})]}),o.jsx("p",{className:"settings-description",children:m("projectSettings.dictionaryDescription")}),V&&o.jsx("p",{className:"error dictionary-error",children:V}),Ce&&o.jsxs("div",{className:"dictionary-add",children:[o.jsx("input",{value:J,placeholder:m("projectSettings.dictionaryPlaceholder"),onChange:D=>C(D.target.value),onKeyDown:D=>{D.key==="Enter"&&(D.preventDefault(),ge())}}),o.jsx("button",{type:"button",disabled:!J.trim(),onClick:()=>{ge()},children:m("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:m("common.delete"),"aria-label":`${m("common.delete")} ${D}`,onClick:()=>{pe(D)},children:o.jsx(Zr,{size:13})})]},D)),r.length===0&&o.jsx("span",{className:"dictionary-empty",children:m("projectSettings.dictionaryEmpty")})]}),o.jsx("div",{className:"settings-actions",children:o.jsxs("button",{className:"settings-save",onClick:K,children:[o.jsx(Yr,{size:15}),m("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(Ro,{size:15}),o.jsx("strong",{children:m("projectSettings.compilerTab")})]}),o.jsx("p",{className:"settings-description compiler-description",children:m("projectSettings.compilerDescription")}),o.jsxs("label",{children:[m("projects.name"),o.jsx("input",{disabled:!H,value:k,onChange:D=>P(D.target.value)})]}),o.jsxs("label",{children:[m("projectSettings.mainFile"),o.jsx("select",{disabled:!H||we.length===0,value:N,onChange:D=>O(D.target.value),children:we.map(D=>o.jsx("option",{value:D,children:D},D))})]}),o.jsxs("label",{children:[m("projectSettings.engine"),o.jsx("select",{disabled:!H,value:g,onChange:D=>w(D.target.value),children:(n.allowedEngines??["pdflatex","xelatex","lualatex"]).map(D=>o.jsx("option",{children:D},D))})]}),o.jsxs("label",{children:[m("projectSettings.latexmkrc"),o.jsx("textarea",{className:"latexmkrc-editor",rows:10,spellCheck:!1,disabled:!H||n.allowProjectLatexmkrc===!1,value:b,placeholder:m("projectSettings.latexmkrcPlaceholder"),onChange:D=>v(D.target.value)})]}),o.jsx("div",{className:"settings-actions",children:H&&o.jsxs("button",{className:"settings-save",onClick:()=>{G()},children:[o.jsx(Yr,{size:15}),m("projectSettings.saveCompiler")]})})]})]})}function jl({diagnostics:t,files:e,empty:n,tone:s,onJump:r}){const{t:i}=Ae(),a=s==="error"?oa:ys;return t.length?o.jsx("div",{className:`compile-diagnostic-list compile-${s}`,children:t.map((c,l)=>{const d=Fb(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 po({lines:t,empty:e,tone:n="log"}){const s=n==="error"?oa:n==="warning"?ys:_o;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 Lb({projectId:t,mainFile:e,artifacts:n,preview:s,loading:r,onView:i}){const{t:a}=Ae(),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(rs,{size:14}),o.jsxs("span",{children:[o.jsx("strong",{children:l.path}),o.jsx("small",{children:Ib(l.size)})]})]}),o.jsx("a",{href:c(l.path),title:a("editor.downloadArtifact"),"aria-label":a("editor.downloadArtifact"),children:o.jsx(Ks,{size:14})})]},l.path))}),o.jsx("div",{className:"artifact-preview",children:r?o.jsxs("div",{className:"compile-empty",children:[o.jsx(Tt,{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(Ks,{size:13}),a("projects.download")]})]}),o.jsx("pre",{children:s.content})]}):o.jsxs("div",{className:"compile-empty",children:[o.jsx(rs,{size:24}),o.jsx("span",{children:a("editor.selectArtifact")})]})})]}):o.jsxs("div",{className:"compile-empty",children:[o.jsx(Td,{size:26}),o.jsx("span",{children:a("editor.noArtifacts")})]})}function Ab({mainFile:t,disabled:e,cleaning:n,onCleanCache:s,onCleanArtifacts:r}){const{t:i}=Ae();return o.jsxs("div",{className:"compile-clean-panel",children:[o.jsxs("div",{className:"compile-clean-intro",children:[o.jsx(ys,{size:28}),o.jsxs("div",{children:[o.jsx("strong",{children:i("editor.cleanTitle")}),o.jsx("p",{children:i("editor.cleanDescription",{file:t})})]})]}),o.jsxs("div",{className:"compile-clean-actions",children:[o.jsxs("article",{children:[o.jsx("div",{className:"compile-clean-action-icon",children:o.jsx(To,{size:19})}),o.jsxs("div",{children:[o.jsx("strong",{children:i("editor.cleanCache")}),o.jsx("p",{children:i("editor.cleanCacheDescription")}),o.jsxs("button",{type:"button",disabled:e||n,onClick:s,children:[n?o.jsx(Tt,{className:"spin",size:14}):o.jsx(To,{size:14}),i("editor.cleanCache")]})]})]}),o.jsxs("article",{className:"danger",children:[o.jsx("div",{className:"compile-clean-action-icon",children:o.jsx(wn,{size:19})}),o.jsxs("div",{children:[o.jsx("strong",{children:i("editor.cleanArtifacts")}),o.jsx("p",{children:i("editor.cleanArtifactsDescription")}),o.jsxs("button",{type:"button",className:"danger",disabled:e||n,onClick:r,children:[n?o.jsx(Tt,{className:"spin",size:14}):o.jsx(wn,{size:14}),i("editor.cleanArtifacts")]})]})]})]})]})}function Fb(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 Ib(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`}function Mb(t){return t instanceof Error&&t.name==="AbortError"}function $b({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),[p,m]=h.useState(!1),[g,w]=h.useState(""),b=h.useRef(null),v=h.useRef(e),k=h.useRef(i),P=h.useRef(a),N=h.useRef(c);v.current=e,k.current=i,P.current=a,N.current=c;const O=async _=>{b.current?.abort();const L=new AbortController;b.current=L;try{const j=await A(`/api/projects/${t}/comments?path=${encodeURIComponent(_)}`,{signal:L.signal});v.current===_&&d(j.comments)}catch(j){!Mb(j)&&v.current===_&&d([])}finally{b.current===L&&(b.current=null)}};return h.useEffect(()=>{u(null)},[t,e]),h.useEffect(()=>(e?O(e):d([]),()=>{b.current?.abort(),b.current=null}),[t,e,s]),{comments:l,focusComment:f,setFocusComment:u,commentOpen:p,setCommentOpen:m,commentText:g,setCommentText:w,addComment:async()=>{if(!(!g.trim()||!e))try{if(n!=="read"&&!await k.current())return;await A(`/api/projects/${t}/comments`,{method:"POST",body:JSON.stringify({path:e,content:g,...r})}),await O(e),m(!1),w(""),N.current()}catch(_){P.current(q(_))}},toggleComment:async _=>{try{await A(`/api/projects/${t}/comments/${_.id}`,{method:"PATCH",body:JSON.stringify({resolved:!_.resolved})}),await O(e)}catch(L){P.current(q(L))}},replyToComment:async(_,L)=>{try{return await A(`/api/projects/${t}/comments/${_.id}/replies`,{method:"POST",body:JSON.stringify({content:L})}),await O(e),!0}catch(j){return P.current(q(j)),!1}},editComment:async(_,L)=>{try{return await A(`/api/projects/${t}/comments/${_.id}`,{method:"PATCH",body:JSON.stringify({content:L})}),await O(e),!0}catch(j){return P.current(q(j)),!1}},deleteComment:async _=>{try{return await A(`/api/projects/${t}/comments/${_.id}`,{method:"DELETE"}),await O(e),u(L=>L?.id===_.id?null:L),!0}catch(L){return P.current(q(L)),!1}},editCommentReply:async(_,L,j)=>{try{return await A(`/api/projects/${t}/comments/${_.id}/replies/${L}`,{method:"PATCH",body:JSON.stringify({content:j})}),await O(e),!0}catch(H){return P.current(q(H)),!1}},deleteCommentReply:async(_,L)=>{try{return await A(`/api/projects/${t}/comments/${_.id}/replies/${L}`,{method:"DELETE"}),await O(e),!0}catch(j){return P.current(q(j)),!1}}}}function Ub(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 zb(t,e,n,s,r,i){const[a]=h.useState(()=>new Eb(t,e)),[c,l]=h.useState("connecting"),[d,f]=h.useState(!1),[u,p]=h.useState([]),[m,g]=h.useState(null),[w,b]=h.useState(null),[v,k]=h.useState(""),[P,N]=h.useState(""),[O,W]=h.useState(!1),[E,J]=h.useState(s),C=h.useRef(n),V=h.useRef(i);return C.current=n,V.current=i,h.useEffect(()=>{const R=a.compileStates();g(R[n]??null)},[n,a]),h.useEffect(()=>{const R=()=>p(a.sessions()),_=()=>{f(!1),p([]),g(null),b(null),k(""),N(""),V.current()},L=({status:K})=>{l(K),K!=="connected"&&_()},j=K=>{f(K),K||_()},H=()=>{l("disconnected"),_()},fe=()=>{const K=a.meta.get("filesEvent");Ub(K)&&b(K);const ge=a.meta.get("commentsRevision");typeof ge=="string"&&k(ge);const pe=a.meta.get("dictionaryRevision");typeof pe=="string"&&N(pe);const D=a.compileStates();g(D[C.current]??null)},Ce=()=>{const K=a.compileStates();g(K[C.current]??null)};a.awareness.on("change",R),a.provider.on("status",L),a.provider.on("sync",j),a.provider.on("connection-close",H),a.provider.on("connection-error",H),a.meta.observe(fe);const ce=a.onCompileStates(Ce),we=a.onDraftReady(()=>W(!0)),G=a.onPermissionChanged(K=>{if(K==="revoked"){l("disconnected"),f(!1),V.current();return}J(K)});return R(),fe(),l(a.connected?"connected":"connecting"),f(a.synced),()=>{a.awareness.off("change",R),a.provider.off("status",L),a.provider.off("sync",j),a.provider.off("connection-close",H),a.provider.off("connection-error",H),a.meta.unobserve(fe),ce(),we(),G(),a.destroy()}},[a]),h.useEffect(()=>{r&&a.connect()},[a,r]),h.useEffect(()=>{a.setPermission(s),J(s)},[a,s]),{collaboration:a,status:c,synced:d,activeSessions:u,compileState:m,setCompileState:g,filesEvent:w,commentsRevision:v,dictionaryRevision:P,localDraftReady:O,permission:E,reconnect:()=>{l("connecting"),f(!1),p([]),g(null),a.reconnect()}}}function Qn(t){return t instanceof Error&&t.name==="AbortError"}function Bb({projectId:t,project:e,mainFile:n,collaborationSynced:s,sharedState:r,onSharedState:i,save:a,loadOutline:c,onPreviewTab:l,onError:d,onCompileStart:f,onCompileSuccess:u,onPdfChanged:p}){const{t:m}=Ae(),[g,w]=h.useState(""),[b,v]=h.useState(!0),[k,P]=h.useState(null),[N,O]=h.useState(""),[W,E]=h.useState(null),[J,C]=h.useState(null),[V,Z]=h.useState([]),[R,_]=h.useState(null),[L,j]=h.useState(!1),[H,fe]=h.useState(!1),[Ce,ce]=h.useState(()=>new Set),[we,G]=h.useState(""),K=h.useRef(n),ge=h.useRef(""),pe=h.useRef(null),D=h.useRef(null),ie=h.useRef(null),le=h.useRef(new Set),We=h.useRef(new Map),Ne=h.useRef(null),xe=h.useRef(()=>{}),ee=h.useRef({onSharedState:i,save:a,loadOutline:c,onPreviewTab:l,onError:d,onCompileStart:f,onCompileSuccess:u,onPdfChanged:p});K.current=n,ee.current={onSharedState:i,save:a,loadOutline:c,onPreviewTab:l,onError:d,onCompileStart:f,onCompileSuccess:u,onPdfChanged:p};const St=z=>{Ne.current!==z&&(Ne.current=z,ee.current.onCompileSuccess())},pt=async(z,te)=>{te||(D.current?.abort(),D.current=new AbortController,te=D.current.signal);try{const I=z?`?mainFile=${encodeURIComponent(z)}`:"",et=await A(`/api/projects/${t}/compile/artifacts${I}`,{signal:te});K.current===z&&(Z(et.artifacts),_(null))}catch(I){!Qn(I)&&K.current===z&&(Z([]),_(null))}finally{D.current?.signal===te&&(D.current=null)}};h.useEffect(()=>{if(pe.current?.abort(),!n){v(!1),w(""),P(null),O(""),E(null),C(null),Z([]),_(null),ee.current.onPdfChanged();return}const z=new AbortController;pe.current=z,v(!0),O(""),E(null),C(null),g&&n&&ge.current===n||(w(""),P(null)),Z([]),_(null),ee.current.onPdfChanged();let I=null;const et=`?mainFile=${encodeURIComponent(n)}`,qt=A(`/api/projects/${t}/compile/latest${et}`,{signal:z.signal});let $=!1;const ne=()=>{if($||z.signal.aborted||!n)return;$=!0;const B=new AbortController;le.current.add(B),pt(n,B.signal).finally(()=>{le.current.delete(B)}),ee.current.loadOutline(z.signal,n).catch(()=>{})};return qt.then(B=>{z.signal.aborted||n&&B.mainFile!==K.current||(O(B.latestRun?.log??""),E(B.latestRun?.diagnostics??null),C(B.latestRun?.status==="succeeded"||B.latestRun?.status==="failed"?B.latestRun.status:null),n&&B.latestRun?.requestedBy&&(B.latestRun.status==="queued"||B.latestRun.status==="running")&&ee.current.onSharedState({mainFile:n,runId:B.latestRun.id,status:B.latestRun.status,requestedBy:B.latestRun.requestedBy,updatedAt:new Date().toISOString()}),B.pdfUrl&&(ge.current=B.mainFile,w(B.pdfUrl),P(B.pdfCompiledAt),ee.current.onPreviewTab("pdf")))}).catch(B=>{!Qn(B)&&K.current===n&&ee.current.onError(q(B))}).finally(()=>{pe.current===z&&(pe.current=null),z.signal.aborted||(v(!1),I=window.setTimeout(ne,0))}),()=>{I!==null&&window.clearTimeout(I),z.abort(),ie.current?.abort();for(const B of le.current)B.abort();le.current.clear()}},[t,n]),h.useEffect(()=>{if(!(!r||r.mainFile!==n||r.status!=="cleaned"||!r.cleanMode)){pe.current?.abort(),D.current?.abort(),ie.current?.abort();for(const z of le.current)z.abort();le.current.clear(),r.cleanMode==="artifacts"?(O(""),E(null),C(null),w(""),P(null),Z([]),_(null),ee.current.onPdfChanged(),ee.current.onPreviewTab("pdf"),G(m("editor.cleanArtifactsComplete"))):G(m("editor.cleanCacheComplete"))}},[r?.runId,r?.status,r?.cleanMode,r?.mainFile,n,m]),h.useEffect(()=>{if(!r||r.mainFile!==n||r.status!=="succeeded"&&r.status!=="failed")return;let z=!1;pe.current?.abort(),ie.current?.abort();const te=new AbortController;return pe.current=te,v(!0),A(`/api/projects/${t}/compile/latest?mainFile=${encodeURIComponent(n)}`,{signal:te.signal}).then(I=>{z||I.mainFile!==K.current||I.latestRun?.id!==r.runId||(O(I.latestRun.log),E(I.latestRun.diagnostics),C(r.status==="succeeded"?"succeeded":"failed"),r.status==="succeeded"&&r.stale&&G(m("editor.compileSnapshotStale")),r.status==="succeeded"&&I.pdfUrl?(ee.current.onPdfChanged(),w(I.pdfUrl),P(I.pdfCompiledAt),ee.current.onPreviewTab("pdf"),St(r.runId),pt(n)):r.status==="failed"&&ee.current.onPreviewTab(I.latestRun.diagnostics.errors.length?"errors":"log"))}).catch(I=>{!Qn(I)&&!z&&ee.current.onError(q(I))}).finally(()=>{z||v(!1)}),()=>{z=!0,te.abort(),pe.current===te&&(pe.current=null)}},[r?.runId,r?.status,r?.mainFile,r?.stale,n,t,m]);const $e=async()=>{if(!e||!n||e.permission==="read"||!s||We.current.has(n)||r?.mainFile===n&&(r.status==="queued"||r.status==="running"))return;const z=n;ce(I=>new Set([...I,z])),ee.current.onCompileStart(),G(""),ie.current?.abort(),ie.current=null,O(""),E(null),C(null),ee.current.onPreviewTab(g?"pdf":"log");const te=new AbortController;We.current.set(z,te);try{if(!await ee.current.save())return;const I=await A(`/api/projects/${t}/compile`,{method:"POST",signal:te.signal,body:JSON.stringify({mainFile:z})});if(I.mainFile!==K.current)return;O(I.log),E(I.diagnostics),C(I.ok?"succeeded":"failed"),I.skipped&&G(m("editor.upToDate")),I.ok&&I.stale&&G(m("editor.compileSnapshotStale")),I.pdfUrl?(ee.current.onPdfChanged(),w(I.pdfUrl),P(I.pdfCompiledAt),ee.current.onPreviewTab("pdf"),I.ok&&(I.skipped?ee.current.onCompileSuccess():St(I.runId))):ee.current.onPreviewTab(I.diagnostics.errors.length?"errors":"log")}catch(I){!Qn(I)&&K.current===z&&ee.current.onError(q(I))}finally{We.current.get(z)===te&&(We.current.delete(z),ce(I=>{const et=new Set(I);return et.delete(z),et}))}},dt=async z=>{if(!e||!n||e.permission==="read"||!s||H||We.current.has(n)||r?.mainFile===n&&(r.status==="queued"||r.status==="running"))return;const te=n;fe(!0),pe.current?.abort(),D.current?.abort(),ie.current?.abort();try{if((await A(`/api/projects/${t}/compile/clean`,{method:"POST",body:JSON.stringify({mainFile:te,mode:z})})).mainFile!==K.current)return;ee.current.onSharedState(null),z==="artifacts"&&(O(""),E(null),C(null),w(""),P(null),Z([]),_(null),ee.current.onPdfChanged()),G(m(z==="cache"?"editor.cleanCacheComplete":"editor.cleanArtifactsComplete"))}catch(I){!Qn(I)&&K.current===te&&ee.current.onError(q(I))}finally{fe(!1)}};xe.current=()=>{$e()},h.useEffect(()=>{if(!we)return;const z=window.setTimeout(()=>G(""),3e3);return()=>window.clearTimeout(z)},[we]),h.useEffect(()=>{const z=te=>{!(te.ctrlKey||te.metaKey)||te.key.toLocaleLowerCase()!=="s"||(te.preventDefault(),te.stopPropagation(),te.repeat||xe.current())};return window.addEventListener("keydown",z,!0),()=>window.removeEventListener("keydown",z,!0)},[]),h.useEffect(()=>()=>{pe.current?.abort(),D.current?.abort(),ie.current?.abort();for(const z of le.current)z.abort();le.current.clear();for(const z of We.current.values())z.abort();We.current.clear()},[]);const Ct=async z=>{if(!z.viewable)return;ie.current?.abort();const te=new AbortController;ie.current=te,j(!0);try{const I=await A(`/api/projects/${t}/compile/artifacts?mainFile=${encodeURIComponent(n)}&path=${encodeURIComponent(z.path)}`,{signal:te.signal});!te.signal.aborted&&ie.current===te&&K.current===n&&_(I)}catch(I){Qn(I)||ee.current.onError(q(I))}finally{ie.current===te&&(ie.current=null,j(!1))}};return{pdfUrl:g,pdfCompiledAt:k,pdfLoading:b,compileLog:N,compileDiagnostics:W,compileOutcome:J,artifacts:V,artifactPreview:R,artifactLoading:L,editorNotice:we,localCompiling:Ce.has(n),cleaning:H,compile:$e,cleanCompile:dt,viewArtifact:Ct}}const kl=10*1024*1024,Vb=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 El(t){return t instanceof Error&&t.name==="AbortError"}function zs(t){const e=t.split("/").filter(Boolean);return e.pop(),e.map((n,s)=>e.slice(0,s+1).join("/"))}function Tn(t,e){return!!(t&&e)&&(e===t||e.startsWith(`${t}/`))}function Hb(t){const e=`.${t.split(".").at(-1)?.toLocaleLowerCase()??""}`;return!Vb.has(e)}function ps(t){return/(?:\.(?:tex|bib|sty|cls|txt|md)|latexmkrc)$/i.test(t)}function Dl(t){const e=t.split(".").at(-1)?.toLocaleLowerCase()??"";return e==="pdf"?"pdf":["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif"].includes(e)?"image":Hb(t)?"text":"unsupported"}function qb(t,e){return`/api/projects/${t}/file/raw?path=${encodeURIComponent(e)}`}function Wb({projectId:t,site:e,activeFile:n,dirty:s,save:r,onError:i,onProject:a,onActiveFile:c,onActiveMainFile:l,onRootDocuments:d}){const{t:f}=Ae(),[u,p]=h.useState([]),[m,g]=h.useState(!1),[w,b]=h.useState(""),[v,k]=h.useState(null),[P,N]=h.useState(!1),[O,W]=h.useState(!1),[E,J]=h.useState(""),[C,V]=h.useState(""),[Z,R]=h.useState(""),[_,L]=h.useState(new Set),[j,H]=h.useState(null),[fe,Ce]=h.useState(""),[ce,we]=h.useState(""),[G,K]=h.useState(null),[ge,pe]=h.useState(!1),[D,ie]=h.useState(null),[le,We]=h.useState(!1),Ne=h.useRef(null),xe=h.useRef(null),ee=async($={})=>{Ne.current?.abort(),Ne.current=null;const ne=$.signal?null:new AbortController;ne&&(Ne.current=ne);try{const B=await A(`/api/projects/${t}/files`,{signal:$.signal??ne?.signal});return(!$.isCurrent||$.isCurrent())&&p(B.files),B.files}catch(B){if(!El(B))throw B;return}finally{ne&&Ne.current===ne&&(Ne.current=null)}},St=async()=>{if(!(!w.trim()||w.trim().endsWith("/"))){V("");try{await A(`/api/projects/${t}/file`,{method:"POST",body:JSON.stringify({path:w,content:""})}),await ee(),c(w),L($=>new Set([...$,...zs(w)])),g(!1),b("")}catch($){V(q($))}}},pt=async()=>{if(!E.trim())return;V("");const $=Z?`${Z}/${E.trim()}`:E.trim();try{const ne=await A(`/api/projects/${t}/folders`,{method:"POST",body:JSON.stringify({path:$})});await ee(),L(B=>new Set([...B,...zs(ne.path),ne.path])),R(ne.path),W(!1),J("")}catch(ne){V(q(ne))}},$e=async($,ne=new Set,B=Z)=>{if(!$.length)return;const Ue=e.maxUploadSizeMB??50;if($.find(ae=>ae.size>Ue*1024*1024))return i(f("errors.fileTooLarge",{size:Ue}));const de=B,it=$.map(ae=>de?`${de}/${ae.name}`:ae.name),ut=new Map;for(const ae of it)ut.set(ae,(ut.get(ae)??0)+1);const ot=[...ut.entries()].filter(([,ae])=>ae>1).map(([ae])=>ae);if(ot.length)return i(f("errors.duplicateUploadNames",{files:ot.join(", ")}));const jt=new Set(u.map(ae=>ae.path)),Ke=[...new Set(it.filter(ae=>jt.has(ae)&&!ne.has(ae)))];if(Ke.length){ie({files:$,directory:de,collisions:Ke});return}ie(null),We(!0);try{const ae=new URLSearchParams;de&&ae.set("directory",de);let Ge="";for(const[Rt,Ie]of $.entries()){const an=it[Rt];ae.delete("overwrite"),ne.has(an)&&ae.set("overwrite","1");const ue=ae.toString()?`?${ae.toString()}`:"",Wt=new FormData;Wt.append("file",Ie);const kt=await fetch(`/api/projects/${t}/upload${ue}`,{method:"POST",body:Wt}),mt=await kt.json().catch(()=>({}));if(!kt.ok){if(kt.status===409&&!ne.has(an)&&mt.code==="FILE_EXISTS"){Rt>0&&await ee(),ie({files:$.slice(Rt),directory:de,collisions:[typeof mt.path=="string"?mt.path:an]});return}throw new Error(kt.status===409?f("errors.pathConflict"):Go(mt,kt.status,"errors.upload"))}typeof mt.path=="string"&&ps(mt.path)&&(Ge=mt.path)}await ee(),Ge&&c(Ge)}catch(ae){i(q(ae))}finally{We(!1)}},dt=async $=>{await $e(Array.from($.target.files??[])),$.target.value=""},Ct=async $=>{xe.current?.abort(),xe.current=null,N(!1);const ne=qb(t,$.path);if(($.size??0)>kl){k({path:$.path,kind:"large",size:$.size??0,url:ne});return}const B=Dl($.path);if(B!=="text"){k({path:$.path,kind:B,size:$.size??0,url:ne});return}k({path:$.path,kind:B,size:$.size??0,url:ne,content:""}),N(!0);const Ue=new AbortController;xe.current=Ue;try{const tt=await fetch(ne,{signal:Ue.signal}),de=await tt.text();if(!tt.ok)throw new Error(de||f("errors.request",{status:tt.status}));k(it=>it?.path===$.path?{...it,content:de}:it)}catch(tt){El(tt)||(k(null),i(q(tt)))}finally{xe.current===Ue&&(xe.current=null,N(!1))}},z=$=>{const ne=Dl($.path),B=(e.maxCollaborativeFileSizeMB??5)*1024*1024;($.size??0)>kl||ps($.path)&&($.size??0)>B||ne!=="text"||!ps($.path)?Ct($):c($.path)},te=async()=>{if(!j)return;const $=fe.trim();if($){V("");try{if(!await r())return;const ne=await A(`/api/projects/${t}/path`,{method:"PATCH",body:JSON.stringify({source:j.path,destinationDirectory:ce,destinationName:$})}),B=de=>de===j.path?ne.path:de.startsWith(`${j.path}/`)?`${ne.path}${de.slice(j.path.length)}`:de;c(de=>B(de)),l(de=>B(de)),d(de=>new Set([...de].map(B))),R(de=>de&&B(de));const[Ue,tt]=await Promise.all([A(`/api/projects/${t}/files`),A(`/api/projects/${t}`)]);p(Ue.files),a(tt.project),L(de=>new Set([...de,...zs(ne.path),ce].filter(Boolean))),H(null),Ce(""),we("")}catch(ne){V(q(ne))}}},I=async()=>{if(G){V("");try{if(s&&!await r())return;await A(`/api/projects/${t}/file?path=${encodeURIComponent(G.path)}`,{method:"DELETE"}),K(null)}catch($){V(q($))}}};h.useEffect(()=>()=>{Ne.current?.abort(),xe.current?.abort()},[]),h.useEffect(()=>{xe.current?.abort(),xe.current=null,N(!1)},[n]);const et=u.filter($=>$.type==="directory"),qt=u.filter($=>zs($.path).every(ne=>_.has(ne)));return{files:u,setFiles:p,loadFiles:ee,newFileOpen:m,setNewFileOpen:g,newFilePath:w,setNewFilePath:b,resourcePreview:v,setResourcePreview:k,resourcePreviewLoading:P,setResourcePreviewLoading:N,newFolderOpen:O,setNewFolderOpen:W,newFolderName:E,setNewFolderName:J,fileDialogError:C,setFileDialogError:V,selectedFolder:Z,setSelectedFolder:R,expandedFolders:_,setExpandedFolders:L,moveEntry:j,setMoveEntry:H,moveName:fe,setMoveName:Ce,moveDestination:ce,setMoveDestination:we,deleteEntry:G,setDeleteEntry:K,fileDragActive:ge,setFileDragActive:pe,uploadConflict:D,setUploadConflict:ie,uploadingFiles:le,directoryEntries:et,visibleEntries:qt,createFile:St,createFolder:pt,uploadFiles:$e,upload:dt,openFile:z,movePath:te,removePath:I}}function Kb({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),[p,m]=h.useState(null),g=h.useRef(0),w=h.useRef(n),b=h.useRef(e),v=h.useRef(0);w.current=n,b.current=e,h.useEffect(()=>{i([]),c(""),d(""),m(null)},[e,s]),h.useEffect(()=>{u(O=>r.length?Math.min(O,r.length-1):0)},[r]),h.useEffect(()=>{const O=++g.current;if(!t||!e){i([]),c(""),d(""),m(null);return}const W=n,E=e,J=window.setTimeout(()=>{rn(async()=>{const{lintLatex:C}=await import("./spellCheck-Cs5UpEXV.js");return{lintLatex:C}},__vite__mapDeps([2,1])).then(({lintLatex:C})=>{if(!(O!==g.current||w.current!==W||b.current!==E))return C(W,s).then(V=>{O!==g.current||w.current!==W||b.current!==E||(i(V),c(W),d(E),u(0),m(null))})}).catch(()=>{})},700);return()=>window.clearTimeout(J)},[t,e,n,s]);const k=l===e&&a===n,P=h.useMemo(()=>k?{total:r.length,unique:new Set(r.map(O=>`${O.kind}:${O.word.toLocaleLowerCase("en-US")}`)).size}:null,[k,r]);return{issues:k?r:[],jump:k?p:null,index:f,summary:P,jumpToIssue:O=>{if(!r.length)return;const W=Math.max(0,Math.min(O,r.length-1)),E=r[W];u(W),m({from:E.from,to:E.to,nonce:++v.current})}}}function Tl(t){return t instanceof Error&&t.name==="AbortError"}function Gb({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),p=h.useRef(null),m=h.useRef(0),g=h.useRef(n),w=h.useRef(s),b=h.useRef(r),v=h.useRef(i),k=E=>E===e&&/\.tex$/i.test(E);g.current=n,w.current=s,b.current=r,v.current=i,h.useEffect(()=>(p.current?.abort(),p.current=null,c(null),d(null),u(null),()=>p.current?.abort()),[t,e]);const P=(E,J,C)=>{u({path:E,line:J,column:C,nonce:++m.current}),g.current!==E&&w.current(E)},N=async(E,J,C,V={})=>{if(!k(E))return;p.current?.abort();const Z=new AbortController;p.current=Z;try{const R=await A(`/api/projects/${t}/sync/pdf?mainFile=${encodeURIComponent(e)}&path=${encodeURIComponent(E)}&line=${J}&column=${C}`,{signal:Z.signal});if(p.current!==Z||!R)return;c({...R,nonce:++m.current}),v.current()}catch(R){!Tl(R)&&!V.silent&&b.current(q(R))}finally{p.current===Z&&(p.current=null)}},O=async(E,J,C)=>{if(!k(g.current))return;const V=g.current;p.current?.abort();const Z=new AbortController;p.current=Z;try{const R=await A(`/api/projects/${t}/sync/source?mainFile=${encodeURIComponent(e)}&page=${E}&x=${J}&y=${C}`,{signal:Z.signal});if(p.current!==Z||g.current!==V||!k(g.current))return;P(R.path,R.line,R.column)}catch(R){Tl(R)||b.current(q(R))}finally{p.current===Z&&(p.current=null)}};return{pdfTarget:a,pdfViewport:l,sourceJump:f,setPdfViewport:d,clearPdfViewport:()=>d(null),jumpToSource:P,syncSourceToPdf:N,syncPdfToSource:O,syncVisiblePdfToSource:()=>{l&&O(l.page,l.x,l.y)}}}function uh(t,e){return`texlite.workspaceLayout:${encodeURIComponent(t)}:${encodeURIComponent(e)}`}function Nl(t,e){try{const n=window.localStorage.getItem(uh(t,e));if(n==="editor-pdf"||n==="editor-only"||n==="pdf-only")return n}catch{}return"editor-pdf"}function Jb(t,e){const[n,s]=h.useState(()=>Nl(t,e));return h.useEffect(()=>{s(Nl(t,e))},[t,e]),{workspaceLayout:n,setWorkspaceLayout:i=>{s(i);try{window.localStorage.setItem(uh(t,e),i)}catch{}}}}const hh=()=>rn(()=>import("./PdfPreview-Deo1bzQ7.js"),__vite__mapDeps([3,1,4,5])),Yb=h.lazy(()=>hh().then(t=>({default:t.PdfPreview}))),Xb=h.lazy(()=>rn(()=>import("./LatexEditor-CpK2QB28.js"),__vite__mapDeps([6,1,7])).then(t=>({default:t.LatexEditor}))),Zb=h.lazy(()=>rn(()=>import("./GitDialog-BNzmjKSK.js"),__vite__mapDeps([8,1,5])).then(t=>({default:t.GitDialog}))),Qb=h.lazy(()=>rn(()=>import("./HistoryDialog-qZKt59En.js"),__vite__mapDeps([9,1,0])).then(t=>({default:t.HistoryDialog}))),ev=h.lazy(()=>rn(()=>import("./ProjectNavigationDialogs-CcHy9xt5.js"),__vite__mapDeps([10,1])).then(t=>({default:t.ProjectSearchDialog}))),tv=h.lazy(()=>rn(()=>import("./ProjectNavigationDialogs-CcHy9xt5.js"),__vite__mapDeps([10,1])).then(t=>({default:t.QuickOpenDialog}))),nv=h.lazy(()=>rn(()=>import("./SystemMetricsDialog-BSiZRWs4.js"),__vite__mapDeps([11,1])).then(t=>({default:t.SystemMetricsDialog}))),nt=8;function ss(t){return t instanceof Error&&t.name==="AbortError"}function sv(t,e,n,s){const r=new Date(t).getTime();if(!Number.isFinite(r))return t;const i=r-n,a=Math.abs(i),c=60*1e3,l=60*c,d=24*l,f=3*d;if(a>f){const g=Math.floor(a/d),w=i<0?"Past":"Future";return s(`projects.relativeDays${w}`,{days:g,hours:0,minutes:0})}if(a>=d){const g=Math.floor(a/d),w=Math.floor(a%d/l),b=i<0?"Past":"Future",v=w>0?"DaysHours":"Days";return s(`projects.relative${v}${b}`,{days:g,hours:w,minutes:0})}if(a>=l){const g=Math.floor(a/l),w=Math.floor(a%l/c),b=i<0?"Past":"Future",v=w>0?"HoursMinutes":"Hours";return s(`projects.relative${v}${b}`,{days:0,hours:g,minutes:w})}let u="minute",p=c;const m=Math.sign(i)*Math.max(1,Math.floor(a/p));return new Intl.RelativeTimeFormat(e,{numeric:"always"}).format(m,u)}function rv(){const{t}=Ae(),[e,n]=h.useState({siteName:"TexLite",adminEmail:""}),[s,r]=h.useState(),[i,a]=h.useState(()=>typeof window>"u"?null:Mr(window.location.pathname)),[c,l]=h.useState(null);h.useEffect(()=>{const p=Mr(window.location.pathname);if(p&&window.location.pathname!==Qi(p)){const w={texliteRoute:"project",projectId:p,fromDashboard:!1};window.history.replaceState(w,"",Qi(p))}const m=()=>a(Mr(window.location.pathname)),g=()=>{if(l(null),r(null),Mr(window.location.pathname)){const w={texliteRoute:"dashboard"};window.history.replaceState(w,"","/"),a(null)}};return window.addEventListener("popstate",m),window.addEventListener("texlite:session-expired",g),()=>{window.removeEventListener("popstate",m),window.removeEventListener("texlite:session-expired",g)}},[]);const d=p=>{const m=Qi(p);if(window.location.pathname!==m){const g={texliteRoute:"project",projectId:p,fromDashboard:!0};window.history.pushState(g,"",m)}a(p)},f=()=>{const p=window.history.state;if(yg(p)&&p.fromDashboard){window.history.back();return}const m={texliteRoute:"dashboard"};window.history.replaceState(m,"","/"),a(null)};if(h.useEffect(()=>{A("/api/config").then(p=>{n(p),document.title=p.siteName}),A("/api/me").then(({user:p})=>r(p)).catch(p=>{p instanceof Ko&&p.status,r(null)})},[]),s===void 0)return o.jsx("div",{className:"center-card",children:t("common.loading")});if(!s)return o.jsx(ov,{site:e,onLogin:r});if(s.mustChangePassword)return o.jsx(iv,{site:e,user:s,onChanged:p=>r(p)});if(i)return o.jsx(dv,{site:e,user:s,projectId:i,onBack:f},i);const u=c?.userId===s.id?c:null;return o.jsx(av,{site:e,user:s,initialData:u?{projects:u.projects,tags:u.tags,pagination:u.pagination}:null,onDataChange:(p,m,g)=>l({userId:s.id,projects:p,tags:m,pagination:g}),onUser:p=>{(!p||p.id!==s.id)&&l(null),r(p),p||f()},onOpenProject:d})}function Ti({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 Ua(){const{t}=Ae();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",cf]})]}),o.jsx("span",{children:t("footer.credit")})]})}function iv({site:t,user:e,onChanged:n}){const{t:s}=Ae(),[r,i]=h.useState(""),[a,c]=h.useState(""),[l,d]=h.useState(""),[f,u]=h.useState(""),p=async m=>{if(m.preventDefault(),a!==l)return u(s("auth.mismatch"));if(a.length<nt)return u(s("auth.passwordMinimum",{count:nt}));try{await A("/api/me/password",{method:"PUT",body:JSON.stringify({currentPassword:r,newPassword:a})}),n({...e,mustChangePassword:!1})}catch(g){u(q(g))}};return o.jsxs("main",{className:"login-page",children:[o.jsx(ra,{}),o.jsxs("form",{className:"login-card",onSubmit:p,children:[o.jsx(Ti,{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:m=>i(m.target.value)})]}),o.jsxs("label",{children:[s("auth.newPassword"),o.jsx("input",{type:"password",minLength:nt,autoComplete:"new-password",value:a,onChange:m=>c(m.target.value)}),o.jsx("small",{className:"field-hint",children:s("auth.passwordMinimum",{count:nt})})]}),o.jsxs("label",{children:[s("auth.confirmPassword"),o.jsx("input",{type:"password",minLength:nt,autoComplete:"new-password",value:l,onChange:m=>d(m.target.value)})]}),f&&o.jsx("p",{className:"error",children:f}),o.jsx("button",{className:"primary",children:s("auth.updatePassword")})]}),o.jsx(Ua,{})]})}function ov({site:t,onLogin:e}){const{t:n}=Ae(),[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(q(u))}};return o.jsxs("main",{className:"login-page",children:[o.jsx(ra,{}),o.jsxs("form",{className:"login-card",onSubmit:d,children:[o.jsx(Ti,{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(Ua,{})]})}function av({site:t,user:e,initialData:n,onDataChange:s,onUser:r,onOpenProject:i}){const{t:a}=Ae(),[c,l]=h.useState(()=>n?.projects??[]),[d,f]=h.useState(()=>n?.tags??[]),[u,p]=h.useState(()=>n?.pagination??{page:1,pageSize:20,total:n?.projects.length??0,totalPages:n?.projects.length?1:0}),[m,g]=h.useState(!!n),[w,b]=h.useState(!1),[v,k]=h.useState(!1),[P,N]=h.useState(""),[O,W]=h.useState(!1),[E,J]=h.useState(""),[C,V]=h.useState(!1),[Z,R]=h.useState(""),[_,L]=h.useState(null),[j,H]=h.useState(""),fe=h.useRef(null),[Ce,ce]=h.useState(!1),[we,G]=h.useState(""),[K,ge]=h.useState(""),[pe,D]=h.useState(!1),[ie,le]=h.useState(""),[We,Ne]=h.useState("blue"),[xe,ee]=h.useState(null),[St,pt]=h.useState(null),[$e,dt]=h.useState(""),[Ct,z]=h.useState(null),[te,I]=h.useState(""),[et,qt]=h.useState(!1),[$,ne]=h.useState(null),[B,Ue]=h.useState(null),[tt,de]=h.useState([]),[it,ut]=h.useState(""),[ot,jt]=h.useState(!1),[Ke,ae]=h.useState(""),[Ge,Rt]=h.useState(()=>localStorage.getItem("texlite-project-view")==="list"?"list":"grid"),[Ie,an]=h.useState(()=>localStorage.getItem("texlite-project-sort")==="created"?"created":"updated"),[ue,Wt]=h.useState(!1),[kt,mt]=h.useState(""),[Se,at]=h.useState(1),[Rs,pr]=h.useState(()=>Date.now()),[Lt,Kt]=h.useState(""),Et=h.useRef(0),gt=h.useRef(null),Gt=(x,se,re,Oe,je)=>`${x?"archived":"active"}|${se}|${re}|${Oe}|${je}`,cn=Gt(ue,Se,we,K,Ie),ln=(x,se,re,Oe,je)=>{const _e=new URLSearchParams({page:String(se),pageSize:"20",sort:je});x&&_e.set("archived","1"),re.trim()&&_e.set("search",re.trim()),Oe&&_e.set("tag",Oe);const Dt=Gt(x,se,re,Oe,je),un=++Et.current;gt.current?.abort();const Cn=new AbortController;return gt.current=Cn,Promise.all([A(`/api/projects?${_e.toString()}`,{signal:Cn.signal}),A("/api/tags",{signal:Cn.signal})]).then(([Jt,jn])=>{un===Et.current&&(l(Jt.projects),f(jn.tags),p(Jt.pagination),at(Jt.pagination.page),g(!0),Kt(Dt))}).catch(Jt=>{!ss(Jt)&&un===Et.current&&N(q(Jt))}).finally(()=>{gt.current===Cn&&(gt.current=null)})};h.useEffect(()=>(ln(ue,Se,we,K,Ie),()=>gt.current?.abort()),[ue,Se,we,K,Ie]),h.useEffect(()=>{m&&!ue&&Lt===cn&&s(c,d,u)},[c,d,u,m,Lt,cn,ue]),h.useEffect(()=>{const x=window.setInterval(()=>pr(Date.now()),6e4);return()=>window.clearInterval(x)},[]);const mr=x=>{Rt(x),localStorage.setItem("texlite-project-view",x)},$n=x=>{an(x),at(1),localStorage.setItem("texlite-project-sort",x)},Ls=x=>{Wt(x),at(1)},Je=x=>{ge(x),at(1)},dn=async()=>{if(E.trim())try{const{project:x}=await A("/api/projects",{method:"POST",body:JSON.stringify({name:E})});W(!1),J("");const se=ue||Se!==1?c:[x,...c].slice(0,u.pageSize),re=ue?u:{...u,total:u.total+1,totalPages:Math.ceil((u.total+1)/u.pageSize)};l(se),p(re),ue||s(se,d,re),i(x.id)}catch(x){N(q(x))}},Ye=async()=>{if(!_)return;const x=t.maxUploadSizeMB??50;if(_.size>x*1024*1024)return H(a("errors.fileTooLarge",{size:x}));ce(!0),H("");const se=new FormData;se.append("file",_);try{const re=await fetch(`/api/projects/import?name=${encodeURIComponent(Z.trim())}`,{method:"POST",body:se}),Oe=await re.json();if(!re.ok)throw new Error(Go(Oe,re.status,"errors.upload"));const je=Oe.project,_e=ue||Se!==1?c:[je,...c].slice(0,u.pageSize),Dt=ue?u:{...u,total:u.total+1,totalPages:Math.ceil((u.total+1)/u.pageSize)};l(_e),p(Dt),ue||s(_e,d,Dt),V(!1),L(null),R(""),i(je.id)}catch(re){H(q(re))}finally{ce(!1)}},Un=x=>{if(x&&!x.name.toLocaleLowerCase().endsWith(".zip")){H(a("errors.zipOnly"));return}H(""),L(x),x&&!Z&&R(x.name.replace(/\.zip$/i,""))},At=async()=>{await A("/api/auth/logout",{method:"POST"}),r(null)},gr=async()=>{if(ie.trim())try{const x=await A("/api/tags",{method:"POST",body:JSON.stringify({name:ie,color:We})});f(se=>[...se,x.tag].sort((re,Oe)=>re.name.localeCompare(Oe.name))),D(!1),le(""),Ne("blue")}catch(x){N(q(x))}},ke=async x=>{if(!xe)return;const se=xe.tags.some(re=>re.id===x.id);try{const Oe=(await A(se?`/api/projects/${xe.id}/tags/${x.id}`:`/api/projects/${xe.id}/tags`,se?{method:"DELETE"}:{method:"POST",body:JSON.stringify({tagId:x.id})})).project;ee(Oe),l(je=>je.map(_e=>_e.id===Oe.id?Oe:_e))}catch(re){N(q(re))}},yr=async()=>{if(!(!St||!$e.trim()))try{const x=await A(`/api/projects/${St.id}`,{method:"PATCH",body:JSON.stringify({name:$e})});l(se=>se.map(re=>re.id===x.project.id?x.project:re)),pt(null),dt("")}catch(x){N(q(x))}},As=async()=>{if(!(!Ct||!te.trim())){qt(!0),N("");try{await A(`/api/projects/${Ct.id}/duplicate`,{method:"POST",body:JSON.stringify({name:te})}),z(null),I(""),ln(ue,Se,we,K,Ie)}catch(x){N(q(x))}finally{qt(!1)}}},wr=async()=>{if($)try{await A(`/api/projects/${$.id}`,{method:"DELETE"}),l(je=>je.filter(_e=>_e.id!==$.id));const x=Math.max(0,u.total-1),se=Math.ceil(x/u.pageSize),re=se===0?1:Math.min(Se,se),Oe={...u,page:re,total:x,totalPages:se};p(Oe),ne(null),re!==Se?at(re):ln(ue,Se,we,K,Ie)}catch(x){N(q(x))}},zn=async x=>{Ue(x),ut(""),de([]),ae(""),jt(!0);try{const se=await A("/api/users");de(se.users.filter(re=>re.id!==x.ownerId))}catch(se){ae(q(se))}finally{jt(!1)}},Ni=async()=>{if(!(!B||!it)){jt(!0),ae("");try{await A(`/api/projects/${B.id}/owner`,{method:"PUT",body:JSON.stringify({userId:it})}),Ue(null),ut(""),ln(ue,Se,we,K,Ie)}catch(x){ae(q(x))}finally{jt(!1)}}},Oi=async x=>{const se=!ue;mt(x.id),N("");try{await A(`/api/projects/${x.id}/archive`,{method:se?"PUT":"DELETE"});const re=c.filter(un=>un.id!==x.id);l(re);const Oe=Math.max(0,u.total-1),je=Math.ceil(Oe/u.pageSize),_e=je===0?1:Math.min(Se,je),Dt={...u,page:_e,total:Oe,totalPages:je};p(Dt),ue||s(re,d,Dt),_e!==Se?at(_e):ln(ue,Se,we,K,Ie)}catch(re){N(q(re))}finally{mt("")}},xr=c,br=["red","orange","yellow","green","blue","purple","gray"],Fs=x=>new Date(x).toLocaleString(he.resolvedLanguage),vr=x=>sv(x,he.resolvedLanguage??"en",Rs,(se,re)=>a(se,re));return o.jsxs("div",{className:"page",children:[o.jsxs("header",{className:"topbar",children:[o.jsx("span",{className:"site-title",children:t.siteName}),o.jsx(Ti,{siteName:t.siteName}),o.jsxs("div",{className:"top-actions",children:[e.role==="admin"&&o.jsxs(o.Fragment,{children:[o.jsxs("button",{className:"ghost",onClick:()=>k(!0),children:[o.jsx(_m,{"aria-hidden":!0,size:14}),a("metrics.title")]}),o.jsxs("button",{className:"ghost",onClick:()=>b(!w),children:[w?o.jsx(Sd,{"aria-hidden":!0,size:14}):o.jsx(Gs,{"aria-hidden":!0,size:14}),a(w?"users.back":"users.manage")]})]}),o.jsx(ra,{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:At,children:a("auth.logout")})]})]}),w?o.jsx(lv,{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(Oo,{"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($c,{"aria-hidden":!0,size:15}),a("tags.create")]}),e.canCreateProjects&&o.jsxs(o.Fragment,{children:[o.jsxs("button",{onClick:()=>{H(""),V(!0)},children:[o.jsx(Xr,{"aria-hidden":!0,size:15}),a("projects.upload")]}),o.jsxs("button",{className:"primary",onClick:()=>W(!0),children:[o.jsx(kd,{"aria-hidden":!0,size:15}),a("projects.new")]})]})]})]}),P&&o.jsx("p",{className:"error",children:P}),o.jsxs("div",{className:"project-toolbar",children:[o.jsx("input",{type:"search",placeholder:a("projects.search"),value:we,onChange:x=>{G(x.target.value),at(1)}}),o.jsxs("div",{className:"project-scope",role:"tablist","aria-label":a("projects.scope"),children:[o.jsxs("button",{className:ue?"":"active",onClick:()=>Ls(!1),role:"tab","aria-selected":!ue,children:[o.jsx(Oo,{size:14}),a("projects.active")]}),o.jsxs("button",{className:ue?"active":"",onClick:()=>Ls(!0),role:"tab","aria-selected":ue,children:[o.jsx(Ac,{size:14}),a("projects.archived")]})]}),o.jsxs("div",{className:"tag-filters",children:[o.jsx("button",{className:K?"":"active",onClick:()=>Je(""),children:a("projects.allTags")}),d.map(x=>o.jsxs("button",{className:K===x.id?"active":"",onClick:()=>Je(K===x.id?"":x.id),children:[o.jsx(mo,{color:x.color}),x.name]},x.id))]}),o.jsxs("label",{className:"project-sort",children:[o.jsx(Lm,{size:14}),o.jsx("span",{children:a("projects.sortBy")}),o.jsxs("select",{value:Ie,onChange:x=>$n(x.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:Ge==="grid"?"active":"",onClick:()=>mr("grid"),title:a("projects.grid"),children:"▦"}),o.jsx("button",{className:Ge==="list"?"active":"",onClick:()=>mr("list"),title:a("projects.list"),children:"☷"})]})]}),o.jsxs("div",{className:`project-grid ${Ge==="list"?"list-view":""}`,children:[xr.map(x=>o.jsxs("article",{className:`project-card${x.ownerId===e.id?" owned-project":""}`,children:[Ge==="grid"&&x.ownerId===e.id&&o.jsxs("button",{className:"project-transfer-action",title:a("projects.transferOwnership"),onClick:()=>{zn(x)},children:[o.jsx(Yi,{"aria-hidden":!0,size:13}),a("projects.transfer")]}),o.jsxs("button",{className:"project-card-open",onClick:()=>i(x.id),children:[o.jsx("span",{className:"owner-badge",title:x.ownerDisplayName??x.ownerUsername,children:x.ownerDisplayName??x.ownerUsername}),o.jsxs("span",{className:"project-card-main",children:[o.jsx("strong",{children:x.name}),o.jsxs("span",{className:"project-tags",children:[x.tags?.map(se=>o.jsx("span",{className:`tag tag-${se.color}`,children:se.name},se.id)),!!(x.unresolvedCommentCount&&x.unresolvedCommentCount>0)&&o.jsxs("span",{className:"project-comments-badge unresolved",title:a("projects.unresolvedCommentsTooltip",{unresolved:x.unresolvedCommentCount,total:x.commentCount??x.unresolvedCommentCount}),children:[o.jsx(Dd,{"aria-hidden":!0,size:10}),o.jsx("span",{children:a("projects.unresolvedCount",{count:x.unresolvedCommentCount})})]})]})]}),o.jsxs("dl",{className:"project-meta",children:[o.jsxs("div",{children:[o.jsxs("dt",{children:[o.jsx(Am,{"aria-hidden":!0,size:13}),a("projects.created")]}),o.jsx("dd",{children:o.jsx("time",{dateTime:x.createdAt,children:Fs(x.createdAt)})})]}),o.jsxs("div",{children:[o.jsxs("dt",{children:[o.jsx(Ed,{"aria-hidden":!0,size:13}),a("projects.modified")]}),o.jsxs("dd",{title:a("projects.modifiedByUser",{time:Fs(x.updatedAt),user:x.lastModifiedDisplayName??x.lastModifiedUsername??a("projects.deletedUser")}),children:[o.jsx("time",{dateTime:x.updatedAt,children:vr(x.updatedAt)}),o.jsxs("span",{className:"project-modified-by",children:[" · ",a("projects.byUser",{user:x.lastModifiedDisplayName??x.lastModifiedUsername??a("projects.deletedUser")})]})]})]})]})]}),o.jsxs("div",{className:"project-card-actions",children:[o.jsxs("button",{onClick:()=>ee(x),children:[o.jsx($c,{"aria-hidden":!0,size:14}),a("tags.assign")]}),x.permission==="owner"&&o.jsxs("button",{onClick:()=>{pt(x),dt(x.name)},children:[o.jsx(Po,{"aria-hidden":!0,size:14}),a("projects.rename")]}),(e.role==="admin"||e.canCreateProjects)&&o.jsxs("button",{onClick:()=>{z(x),I(`${x.name} (1)`)},children:[o.jsx(Um,{"aria-hidden":!0,size:14}),a("projects.duplicate")]}),o.jsxs("a",{href:`/api/projects/${x.id}/download`,download:!0,children:[o.jsx(Ks,{"aria-hidden":!0,size:14}),a("projects.download")]}),o.jsxs("button",{disabled:kt===x.id,onClick:()=>{Oi(x)},children:[ue?o.jsx(Rm,{"aria-hidden":!0,size:14}):o.jsx(Ac,{"aria-hidden":!0,size:14}),a(ue?"projects.unarchive":"projects.archive")]}),Ge==="list"&&x.ownerId===e.id&&o.jsxs("button",{onClick:()=>{zn(x)},children:[o.jsx(Yi,{"aria-hidden":!0,size:14}),a("projects.transfer")]}),x.permission==="owner"&&o.jsxs("button",{className:"danger-text",onClick:()=>ne(x),children:[o.jsx(wn,{"aria-hidden":!0,size:14}),a("common.delete")]})]})]},x.id)),xr.length===0&&(c.length===0?ue?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(rg,{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:()=>at(x=>Math.max(1,x-1)),title:a("projects.previousPage"),children:[o.jsx(jd,{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:()=>at(x=>Math.min(u.totalPages,x+1)),title:a("projects.nextPage"),children:[o.jsx(ia,{size:15}),a("projects.nextPage")]})]}),o.jsx(Ve,{open:O,title:a("projects.new"),description:a("projects.newDescription"),onOpenChange:W,footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>W(!1),children:a("common.cancel")}),o.jsx("button",{className:"primary",onClick:()=>{dn()},children:a("common.create")})]}),children:o.jsxs("label",{className:"form-field",children:[a("projects.name"),o.jsx("input",{autoFocus:!0,value:E,onChange:x=>J(x.target.value),onKeyDown:x=>{x.key==="Enter"&&dn()}})]})}),o.jsx(Ve,{open:C,title:a("projects.upload"),description:a("projects.uploadDescription",{size:t.maxUploadSizeMB??50}),onOpenChange:x=>{V(x),x||H("")},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>{V(!1),H("")},children:a("common.cancel")}),o.jsx("button",{className:"primary",disabled:!_||Ce,onClick:()=>{Ye()},children:a(Ce?"projects.importing":"projects.import")})]}),children:o.jsxs("div",{className:"form-stack",children:[j&&o.jsx("p",{className:"error import-error",children:j}),o.jsxs("div",{className:`upload-picker${_?" has-file":""}`,onDragOver:x=>{x.preventDefault(),x.dataTransfer.dropEffect="copy"},onDrop:x=>{x.preventDefault(),Un(x.dataTransfer.files[0]??null)},children:[o.jsx("input",{ref:fe,className:"sr-only",type:"file",accept:".zip,application/zip",onChange:x=>Un(x.target.files?.[0]??null)}),o.jsx(No,{size:34}),o.jsxs("div",{className:"upload-picker-copy",children:[o.jsx("strong",{children:_?.name??a("projects.chooseZip")}),o.jsx("span",{children:_?a("projects.selectedFileSize",{size:fh(_.size)}):a("projects.dropZip")})]}),o.jsxs("button",{type:"button",onClick:()=>fe.current?.click(),children:[o.jsx(Xr,{size:15}),a("projects.browse")]}),_&&o.jsx("button",{className:"upload-clear",type:"button",title:a("projects.clearFile"),"aria-label":a("projects.clearFile"),onClick:()=>{Un(null),fe.current&&(fe.current.value="")},children:o.jsx(Zr,{size:14})})]}),o.jsxs("label",{className:"form-field",children:[a("projects.name"),o.jsx("input",{value:Z,onChange:x=>R(x.target.value)})]})]})}),o.jsx(Ve,{open:pe,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:()=>{gr()},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:ie,onChange:x=>le(x.target.value)})]}),o.jsxs("fieldset",{className:"color-picker",children:[o.jsx("legend",{children:a("tags.color")}),br.map(x=>o.jsxs("label",{className:We===x?"active":"",children:[o.jsx("input",{type:"radio",name:"dashboard-tag-color",checked:We===x,onChange:()=>Ne(x)}),o.jsx(mo,{color:x}),a(`tags.${x}`)]},x))]})]})}),o.jsx(Ve,{open:!!xe,title:a("tags.assignTitle",{project:xe?.name??""}),description:a("tags.assignDescription"),onOpenChange:x=>{x||ee(null)},footer:o.jsx("button",{onClick:()=>ee(null),children:a("common.close")}),children:o.jsxs("div",{className:"tag-assignment-list",children:[d.map(x=>o.jsxs("label",{children:[o.jsx("input",{type:"checkbox",checked:!!xe?.tags.some(se=>se.id===x.id),onChange:()=>{ke(x)}}),o.jsx(mo,{color:x.color}),o.jsx("span",{children:x.name})]},x.id)),d.length===0&&o.jsx("p",{className:"muted",children:a("tags.empty")})]})}),o.jsx(Ve,{open:!!St,title:a("projects.renameTitle"),onOpenChange:x=>{x||pt(null)},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>pt(null),children:a("common.cancel")}),o.jsx("button",{className:"primary",onClick:()=>{yr()},children:a("projects.rename")})]}),children:o.jsxs("label",{className:"form-field",children:[a("projects.name"),o.jsx("input",{autoFocus:!0,value:$e,onChange:x=>dt(x.target.value),onKeyDown:x=>{x.key==="Enter"&&yr()}})]})}),o.jsx(Ve,{open:!!Ct,title:a("projects.duplicateTitle"),description:a("projects.duplicateDescription",{project:Ct?.name??""}),onOpenChange:x=>{!x&&!et&&(z(null),I(""))},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{disabled:et,onClick:()=>{z(null),I("")},children:a("common.cancel")}),o.jsx("button",{className:"primary",disabled:et||!te.trim(),onClick:()=>{As()},children:a(et?"projects.duplicating":"projects.duplicate")})]}),children:o.jsxs("label",{className:"form-field",children:[a("projects.name"),o.jsx("input",{autoFocus:!0,value:te,onChange:x=>I(x.target.value),onKeyDown:x=>{x.key==="Enter"&&As()}})]})}),o.jsx(Ve,{open:!!B,title:a("projects.transferOwnership"),description:a("projects.transferDescription",{project:B?.name??""}),onOpenChange:x=>{!x&&!ot&&(Ue(null),ut(""),ae(""))},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{disabled:ot,onClick:()=>{Ue(null),ut(""),ae("")},children:a("common.cancel")}),o.jsxs("button",{className:"primary",disabled:ot||!it,onClick:()=>{Ni()},children:[ot?o.jsx(Tt,{className:"spin",size:14}):o.jsx(Yi,{size:14}),a("projects.transfer")]})]}),children:o.jsxs("div",{className:"form-stack",children:[Ke&&o.jsx("p",{className:"error dialog-error",children:Ke}),o.jsxs("label",{className:"form-field",children:[a("projects.newOwner"),o.jsxs("select",{disabled:ot||tt.length===0,value:it,onChange:x=>ut(x.target.value),children:[o.jsx("option",{value:"",children:ot?a("common.loading"):tt.length>0?a("projects.chooseNewOwner"):a("projects.noTransferUsers")}),tt.map(x=>o.jsxs("option",{value:x.id,children:[x.displayName??x.username," (@",x.username,")"]},x.id))]})]}),o.jsxs("p",{className:"warning",children:[o.jsx(ys,{size:15}),a("projects.transferWarning")]})]})}),o.jsx(gs,{open:!!$,title:a("projects.deleteTitle"),description:a("projects.deleteDescription",{project:$?.name??""}),confirmLabel:a("common.delete"),danger:!0,onCancel:()=>ne(null),onConfirm:()=>{wr()}})]}),v&&o.jsx(h.Suspense,{fallback:null,children:o.jsx(nv,{open:!0,onOpenChange:k})}),o.jsx(Ua,{})]})}function mo({color:t}){return o.jsx("span",{className:`tag-dot tag-${t}`})}function cv(t=10){const e="ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789!@#$%",n=crypto.getRandomValues(new Uint8Array(t));return Array.from(n,s=>e[s%e.length]).join("")}function lv({currentUser:t}){const{t:e}=Ae(),[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),[p,m]=h.useState(""),[g,w]=h.useState(null),[b,v]=h.useState(!1),k=()=>A("/api/admin/users").then(({users:C})=>s(C)).catch(C=>i(q(C)));h.useEffect(()=>{k()},[]);const P=async()=>{if(l.password.length<nt)return i(e("auth.passwordMinimum",{count:nt}));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 k()}catch(C){i(q(C))}},N=async C=>{try{await A(`/api/admin/users/${C.id}`,{method:"PATCH",body:JSON.stringify({disabled:!C.disabled})}),await k()}catch(V){i(q(V))}},O=async C=>{try{await A(`/api/admin/users/${C.id}`,{method:"PATCH",body:JSON.stringify({role:C.role==="admin"?"user":"admin"})}),await k()}catch(V){i(q(V))}},W=async C=>{try{await A(`/api/admin/users/${C.id}`,{method:"PATCH",body:JSON.stringify({canCreateProjects:!C.canCreateProjects})}),await k()}catch(V){i(q(V))}},E=async()=>{if(!(!f||!p)){if(p.length<nt)return i(e("auth.passwordMinimum",{count:nt}));try{await A(`/api/admin/users/${f.id}`,{method:"PATCH",body:JSON.stringify({password:p})}),u(null),m("")}catch(C){i(q(C))}}},J=async()=>{if(g)try{await A(`/api/admin/users/${g.id}`,{method:"DELETE",body:JSON.stringify({deleteProjects:b})}),w(null),v(!1),await k()}catch(C){i(q(C))}};return o.jsxs("main",{className:"dashboard",children:[o.jsxs("div",{className:"section-title",children:[o.jsxs("div",{children:[o.jsxs("h1",{children:[o.jsx(Gs,{"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(Nd,{"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(C=>o.jsxs("tr",{children:[o.jsxs("td",{children:[o.jsx("strong",{children:C.displayName}),o.jsxs("small",{children:["@",C.username]})]}),o.jsx("td",{children:C.role==="admin"?e("common.admin"):e("common.user")}),o.jsx("td",{children:C.canCreateProjects?e("users.allow"):e("users.deny")}),o.jsx("td",{children:C.ownedProjects}),o.jsx("td",{children:C.disabled?e("common.disabled"):e("common.normal")}),o.jsxs("td",{children:[o.jsx("button",{disabled:C.id===t.id,onClick:()=>N(C),children:C.disabled?e("users.enable"):e("users.disable")}),o.jsx("button",{disabled:C.id===t.id,onClick:()=>O(C),children:C.role==="admin"?e("users.demote"):e("users.promote")}),o.jsx("button",{disabled:C.role==="admin",onClick:()=>W(C),children:C.canCreateProjects?e("users.denyCreate"):e("users.allowCreate")}),o.jsx("button",{onClick:()=>{u(C),m("")},children:e("users.resetPassword")}),o.jsx("button",{className:"danger-text",disabled:C.id===t.id,onClick:()=>{w(C),v(!1)},children:e("common.delete")})]})]},C.id))})]})}),o.jsx(Ve,{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<nt,onClick:()=>{P()},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:C=>d({...l,username:C.target.value})})]}),o.jsxs("label",{className:"form-field",children:[e("users.displayName"),o.jsx("input",{value:l.displayName,onChange:C=>d({...l,displayName:C.target.value})})]}),o.jsxs("label",{className:"form-field",children:[e("users.initialPassword"),o.jsxs("span",{className:"password-generator",children:[o.jsx("input",{minLength:nt,autoComplete:"new-password",value:l.password,onChange:C=>d({...l,password:C.target.value})}),o.jsxs("button",{type:"button",title:e("users.generatePassword"),onClick:()=>d({...l,password:cv()}),children:[o.jsx(zm,{size:15}),e("users.randomPassword")]})]}),o.jsx("small",{className:"field-hint",children:e("auth.passwordMinimum",{count:nt})})]}),o.jsxs("label",{className:"form-field",children:[e("users.role"),o.jsxs("select",{value:l.role,onChange:C=>d({...l,role:C.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:C=>d({...l,canCreateProjects:C.target.checked})})," ",e("users.allowCreate")]})]})}),o.jsx(Ve,{open:!!f,title:e("users.resetPassword"),description:e("users.resetDescription",{username:f?.username??""}),onOpenChange:C=>{C||u(null)},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>u(null),children:e("common.cancel")}),o.jsx("button",{className:"primary",disabled:p.length<nt,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:nt,autoComplete:"new-password",value:p,onChange:C=>m(C.target.value)}),o.jsx("small",{className:"field-hint",children:e("auth.passwordMinimum",{count:nt})})]})}),o.jsx(Ve,{open:!!g,title:e("users.deleteTitle"),description:e("users.deleteDescription",{username:g?.username??""}),onOpenChange:C=>{C||w(null)},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>w(null),children:e("common.cancel")}),o.jsx("button",{className:"danger",onClick:()=>{J()},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:()=>v(!1)})," ",e("users.transferProjects")]}),o.jsxs("label",{children:[o.jsx("input",{type:"radio",checked:b,onChange:()=>v(!0)})," ",e("users.deleteProjects")]})]})})]})}function dv({site:t,user:e,projectId:n,onBack:s}){const{t:r}=Ae(),[i,a]=h.useState(null),[c,l]=h.useState(!1),[d,f]=h.useState([]),[u,p]=h.useState(null),[m,g]=h.useState([]),[w,b]=h.useState(""),[v,k]=h.useState(""),[P,N]=h.useState(new Set),[O,W]=h.useState(""),[E,J]=h.useState(""),[C,V]=h.useState(!1),[Z,R]=h.useState("editor.saved"),[_,L]=h.useState(null),j=h.useRef(_);j.current=_;const[H,fe]=h.useState({line:1,column:1}),Ce=h.useRef(H),[ce,we]=h.useState("pdf"),[G,K]=h.useState("log"),ge=y=>{if(y==="pdf"){we("pdf");return}K(y),we("diagnostics")},{workspaceLayout:pe,setWorkspaceLayout:D}=Jb(e.id,n),[ie,le]=h.useState(""),[We,Ne]=h.useState(""),[xe,ee]=h.useState({selectedText:"",startOffset:0,endOffset:0}),St=h.useRef({selectedText:"",startOffset:0,endOffset:0}),pt=y=>{St.current=y,ee(y)},[$e,dt]=h.useState(null),[Ct,z]=h.useState(!1),[te,I]=h.useState(!1),[et,qt]=h.useState(!1),[$,ne]=h.useState(!1),[B,Ue]=h.useState(null),[tt,de]=h.useState(!1),[it,ut]=h.useState(!1),[ot,jt]=h.useState(!1),[Ke,ae]=h.useState(()=>zc(e.id,n)),[Ge,Rt]=h.useState([]),Ie=h.useRef([]);Ie.current=Ge;const an=h.useRef(null),ue=h.useRef(null),Wt=h.useRef(0),kt=h.useRef(0),mt=h.useRef(""),Se=h.useRef(""),at=h.useRef(""),Rs=h.useRef(""),pr=h.useRef(0),Lt=h.useRef(null),Kt=h.useRef(null),Et=h.useRef(null),gt=h.useRef(null),Gt=h.useRef(!1),cn=h.useRef(null),ln=h.useRef(s);ln.current=s,at.current=v;const mr=(y,S)=>{const T={line:y,column:S};Ce.current=T,fe(T)},$n=y=>{const S=Ie.current,T=y(S);T!==S&&(Ie.current=T,Rt(T))};h.useEffect(()=>{Ie.current=[],Rt([])},[n]);const Ls=y=>{const S=Ie.current,T=S.indexOf(y);if(T<0)return;const M=S.filter(Ee=>Ee!==y);if(Ie.current=M,Rt(M),Se.current!==y)return;const oe=M.length>0?M[Math.min(T,M.length-1)]:i?.mainFile??"";b(oe)},{collaboration:Je,status:dn,synced:Ye,activeSessions:Un,compileState:At,setCompileState:gr,filesEvent:ke,commentsRevision:yr,dictionaryRevision:As,localDraftReady:wr,permission:zn,reconnect:Ni}=zb(n,e,v,i?.permission??"read",c,()=>R("editor.offlineDraft")),{pdfTarget:Oi,pdfViewport:xr,sourceJump:br,setPdfViewport:Fs,clearPdfViewport:vr,jumpToSource:x,syncSourceToPdf:se,syncPdfToSource:re,syncVisiblePdfToSource:Oe}=Gb({projectId:n,mainFile:v,activeFile:w,onActiveFile:b,onError:le,onShowPdf:()=>ge("pdf")}),je=Kb({active:!!(i&&w&&Ye&&Ke.spellCheck),activeFile:w,content:O,dictionaryWords:d});h.useEffect(()=>{ae(zc(e.id,n))},[e.id,n]);const _e=y=>{mt.current=y,W(y)};h.useEffect(()=>{if(Se.current=w,Ce.current={line:1,column:1},fe({line:1,column:1}),pt({selectedText:"",startOffset:0,endOffset:0}),!Ke.openFilesInTabs){Ie.current.length>0&&(Ie.current=[],Rt([]));return}w&&$n(y=>y.includes(w)?y:[...y,w])},[w,Ke.openFilesInTabs,n]),h.useEffect(()=>{if(!C)return;const y=S=>{S.preventDefault(),S.returnValue=""};return window.addEventListener("beforeunload",y),()=>window.removeEventListener("beforeunload",y)},[C]),h.useEffect(()=>{if(dn!=="disconnected")return;const y=new AbortController;return A(`/api/projects/${n}`,{signal:y.signal}).then(({project:S})=>{y.signal.aborted||(a(S),le(""))}).catch(S=>{if(!ss(S)){if(S instanceof Ko&&[401,403,404].includes(S.status)){le(q(S)),ln.current();return}le(r("errors.collaborationUnavailable"))}}),()=>y.abort()},[dn,n,r]);const Dt=async(y={})=>{Lt.current?.abort(),Lt.current=null;const S=y.signal?null:new AbortController;S&&(Lt.current=S);try{const T=await A(`/api/projects/${n}/completions`,{signal:y.signal??S?.signal});(!y.isCurrent||y.isCurrent())&&p(T.index)}catch(T){if(ss(T))return;(!y.isCurrent||y.isCurrent())&&p(null)}finally{S&&Lt.current===S&&(Lt.current=null)}},un=async(y={},S=at.current)=>{Kt.current?.abort(),Kt.current=null;const T=y.signal?null:new AbortController;T&&(Kt.current=T);try{const M=S?`?mainFile=${encodeURIComponent(S)}`:"",oe=await A(`/api/projects/${n}/outline${M}`,{signal:y.signal??T?.signal});(!y.isCurrent||y.isCurrent())&&g(oe.outline)}catch(M){!ss(M)&&(!y.isCurrent||y.isCurrent())&&g([])}finally{T&&Kt.current===T&&(Kt.current=null)}},Cn=async(y={})=>{Et.current?.abort(),Et.current=null;const S=y.signal?null:new AbortController;S&&(Et.current=S);try{const T=await A(`/api/projects/${n}/dictionary`,{signal:y.signal??S?.signal});(!y.isCurrent||y.isCurrent())&&f(T.words)}catch(T){if(ss(T))return;(!y.isCurrent||y.isCurrent())&&f([])}finally{S&&Et.current===S&&(Et.current=null)}};h.useEffect(()=>{let y=!1;const S=++pr.current,T=new AbortController,M=()=>!y&&pr.current===S;let oe=!1;Rs.current="",a(null),Ba([]),g([]),b(""),k(""),N(new Set),W(""),J(""),gr(null),vr(),p(null),f([]),hh();const Ee=A(`/api/projects/${n}`,{signal:T.signal}).then(De=>{M()&&(oe=!0,a(De.project),b(De.project.mainFile),k(De.project.mainFile),N(new Set([De.project.mainFile])),Wa(new Set(zs(De.project.mainFile))))}).catch(De=>{M()&&le(q(De))}),me=A(`/api/projects/${n}/files`,{signal:T.signal}).then(De=>{M()&&Ba(De.files)}).catch(De=>{M()&&le(q(De))});let fn=null;return Promise.allSettled([Ee,me]).then(()=>{!M()||!oe||(fn=window.setTimeout(()=>{M()&&Promise.all([Dt({signal:T.signal,isCurrent:M}),Cn({signal:T.signal,isCurrent:M})])},0))}),()=>{y=!0,fn!==null&&window.clearTimeout(fn),T.abort(),Lt.current?.abort(),Lt.current=null,Kt.current?.abort(),Kt.current=null,Et.current?.abort(),Et.current=null,gt.current?.abort(),gt.current=null}},[n]),h.useEffect(()=>{As&&Cn()},[As,n]),h.useEffect(()=>{!i||dn!=="connected"||zn===i.permission||a(y=>y&&{...y,permission:zn})},[zn,i?.permission]),h.useEffect(()=>{if(!ke)return;const y=ke.kind==="delete"&&!!ke.path&&Tn(ke.path,Se.current),S=ke.kind==="delete"&&!!ke.path&&Tn(ke.path,at.current);if(ke.kind==="move"&&ke.source&&ke.destination){const M=ke.source,oe=ke.destination,Ee=me=>me===M?oe:me.startsWith(`${M}/`)?`${oe}${me.slice(M.length)}`:me;b(me=>Ee(me)),k(me=>Ee(me)),N(me=>new Set([...me].map(Ee))),Sr(me=>me&&Ee(me)),$n(me=>me.map(Ee))}y&&(b(""),J(""),_e(""),Ne(r("editor.fileDeletedByCollaborator",{path:ke.path}))),ke.kind==="delete"&&ke.path&&(N(M=>new Set([...M].filter(oe=>!Tn(ke.path,oe)))),Sr(M=>Tn(ke.path,M)?"":M),Ha(M=>M&&Tn(ke.path,M.path)?null:M),$n(M=>M.filter(oe=>!Tn(ke.path,oe)))),gt.current?.abort();const T=new AbortController;gt.current=T,Promise.all([yh({signal:T.signal}),A(`/api/projects/${n}`,{signal:T.signal})]).then(([M,oe])=>{if(a(oe.project),S&&k(oe.project.mainFile),y&&M){const Ee=M.find(me=>me.type==="file"&&me.path===oe.project.mainFile)??M.find(me=>me.type==="file"&&ps(me.path));b(Ee?.path??"")}Dt({signal:T.signal}),un({signal:T.signal},S?oe.project.mainFile:at.current)}).catch(M=>{ss(M)}).finally(()=>{gt.current===T&&(gt.current=null)})},[ke?.revision]),h.useEffect(()=>{if(Je.setActiveFile(w),!w)return;J(""),R("editor.loading");const y=Je.getText(w),S=(T,M)=>{_e(y.toString()),J(w),M?.local&&i?.permission!=="read"?(Wt.current+=1,V(!0),R("editor.pending")):Wt.current<=kt.current&&R(j.current?"editor.savedAt":"editor.saved")};return y.observe(S),(Ye||wr)&&S(),()=>{y.unobserve(S)}},[w,Je,Ye,wr,i?.permission]),h.useEffect(()=>{!w||E!==w||Rs.current===w||(Rs.current=w,!(!w.toLocaleLowerCase().endsWith(".tex")||!uv(O))&&(N(y=>new Set([...y,w])),k(w)))},[w,E,O]);const Jt=async()=>{if(!Ye)throw new Error("Collaboration is not synchronized");const y=Wt.current,S=await Je.flush();return kt.current=Math.max(kt.current,y),L(S.persistedAt),/\.tex$/i.test(Se.current)&&un(),Wt.current===y?(V(!1),R("editor.savedAt")):R("editor.pending"),S};h.useEffect(()=>{if(!C||!w)return;if(!Ye){R("editor.offlineDraft");return}R("editor.pending");const y=window.setTimeout(()=>{R("editor.saving"),Jt().catch(()=>{R(Je.connected?"editor.saveFailed":"editor.offlineDraft")})},750);return()=>window.clearTimeout(y)},[O,C,w,Ye]);const jn=async()=>{if(!i||i.permission==="read"||!Ye||!w)return!1;R("editor.saving");try{return await Jt(),Dt(),!0}catch(y){return R("editor.saveFailed"),le(q(y)||r("errors.collaborationUnavailable")),!1}},za=async(y,S)=>(await A(`/api/projects/${n}/format`,{method:"POST",body:JSON.stringify({path:y,source:S})})).formatted,ph=async()=>{if(!Ke.formatOnCompile||!i||i.permission==="read"||!Ye||!Zi(Se.current)||Gt.current)return;const y=Se.current,S=Je.getText(y),T=S.toString();Gt.current=!0,jt(!0);try{const M=await za(y,T),oe=await Bc(T,M);if(Se.current!==y||S.toString()!==T)throw new Error(r("editor.formatSourceChanged"));oe.length&&Je.applyTextEdits(y,oe)}catch(M){le(r("editor.formatFailedContinue",{message:q(M)}))}finally{Gt.current=!1,jt(!1)}},mh=async()=>(cn.current&&await cn.current,await ph(),jn()),gh=async()=>{if(!i||i.permission==="read"||!Ye||Gt.current||!Zi(Se.current))return;const y=St.current;if(!y.selectedText.trim()){Ne(r("editor.formatSelectionRequired"));return}const S=Se.current,{startOffset:T,endOffset:M,selectedText:oe}=y,Ee=Je.getText(S);if(Ee.toString().slice(T,M)!==oe){le(r("editor.formatSelectionChanged"));return}Gt.current=!0,jt(!0);let me=()=>{};const fn=new Promise(De=>{me=De});cn.current=fn;try{const De=ug(oe,await za(S,oe)),dc=await Bc(oe,De,T);if(Se.current!==S||Ee.toString().slice(T,M)!==oe){le(r("editor.formatSelectionChanged"));return}dc.length&&Je.applyTextEdits(S,dc),le(""),Ne(r("editor.formatSelectionComplete"))}catch(De){le(r("editor.formatFailed",{message:q(De)}))}finally{Gt.current=!1,jt(!1),me(),cn.current===fn&&(cn.current=null)}},{files:Yt,setFiles:Ba,loadFiles:yh,newFileOpen:wh,setNewFileOpen:Pi,newFilePath:xh,setNewFilePath:Va,resourcePreview:Re,setResourcePreview:Ha,resourcePreviewLoading:bh,setResourcePreviewLoading:vh,newFolderOpen:Sh,setNewFolderOpen:_i,newFolderName:Ch,setNewFolderName:qa,fileDialogError:hn,setFileDialogError:Bn,selectedFolder:kn,setSelectedFolder:Sr,expandedFolders:jh,setExpandedFolders:Wa,moveEntry:Is,setMoveEntry:Cr,moveName:Ka,setMoveName:jr,moveDestination:kh,setMoveDestination:Ri,deleteEntry:Vn,setDeleteEntry:kr,fileDragActive:Ga,setFileDragActive:Li,uploadConflict:Ai,setUploadConflict:Ja,uploadingFiles:Er,directoryEntries:Eh,visibleEntries:Dh,createFile:Th,createFolder:Ya,uploadFiles:Xa,upload:Nh,openFile:Fi,movePath:Za,removePath:Oh}=Wb({projectId:n,site:t,activeFile:w,dirty:C,save:jn,onError:le,onProject:a,onActiveFile:b,onActiveMainFile:k,onRootDocuments:N});h.useEffect(()=>{if(!Ke.openFilesInTabs||Yt.length===0)return;const y=new Set(Yt.filter(S=>S.type==="file"&&ps(S.path)).map(S=>S.path));$n(S=>{const T=S.filter(M=>y.has(M));return T.length===S.length?S:T})},[Yt,Ke.openFilesInTabs]);const{comments:Ms,focusComment:Ph,setFocusComment:Qa,commentOpen:_h,setCommentOpen:Ii,commentText:Rh,setCommentText:Lh,addComment:Ah,toggleComment:Fh,replyToComment:Ih,editComment:Mh,deleteComment:$h,editCommentReply:Uh,deleteCommentReply:zh}=$b({projectId:n,activeFile:w,permission:i?.permission,revision:yr,selection:xe,save:jn,onError:le,onAdded:()=>dt("comments")}),{pdfUrl:Ft,pdfCompiledAt:Hn,pdfLoading:Mi,compileLog:Dr,compileDiagnostics:Tr,compileOutcome:Nr,artifacts:$i,artifactPreview:Bh,artifactLoading:Vh,editorNotice:ec,localCompiling:Ui,cleaning:tc,compile:Hh,cleanCompile:qh,viewArtifact:Wh}=Bb({projectId:n,project:i,mainFile:v,collaborationSynced:Ye,sharedState:At,onSharedState:gr,save:mh,loadOutline:(y,S)=>un({signal:y},S),onPreviewTab:ge,onError:le,onCompileStart:()=>{le(""),Ne("")},onCompileSuccess:()=>{const y=Se.current;y&&se(y,Ce.current.line,Ce.current.column,{silent:!0})},onPdfChanged:vr});h.useEffect(()=>{if(!i||!v||!Ft&&Mi)return;const y=window.setTimeout(()=>l(!0),Ft?150:0);return()=>window.clearTimeout(y)},[i,Mi,Ft]),h.useEffect(()=>{const y=S=>{(S.ctrlKey||S.metaKey)&&(!S.shiftKey&&S.key.toLocaleLowerCase()==="p"?(S.preventDefault(),de(!0)):S.shiftKey&&S.key.toLocaleLowerCase()==="f"&&(S.preventDefault(),ut(!0)))};return window.addEventListener("keydown",y,!0),()=>window.removeEventListener("keydown",y,!0)},[]);const Kh=y=>{ae(y),cg(e.id,n,y)},nc=()=>{ue.current?.isCollapsed()?ue.current.expand():ue.current?.collapse()},sc=h.useMemo(()=>m.length?m:hv(O).map(y=>({...y,path:w})),[m,O,w]),qn=h.useMemo(()=>hg(Dr,Nr),[Dr,Nr]),Wn=pe!=="pdf-only",rc=pe!=="editor-only",Or=y=>{D(y),y==="pdf-only"&&ge("pdf")},zi=Vn?Un.filter(y=>y.filePath&&Tn(Vn.path,y.filePath)):[];if(!i)return o.jsxs("div",{className:"center-card",children:[o.jsx("p",{children:ie||r("common.loading")}),ie&&o.jsx("button",{className:"primary",onClick:s,children:r("editor.backToProjects")})]});const yt=i.permission==="read"||!Ye,Gh=(y,S)=>{if(yt)return;const T=Se.current;if(!T)return;if(Je.getText(T).toString().slice(y.from,y.to)!==y.word){le(r("editor.spellCheckSourceChanged"));return}try{Je.applyTextEdits(T,[{from:y.from,to:y.to,replacement:S}])}catch(Ee){le(q(Ee))}},Pr=At?.mainFile===v&&(At.status==="queued"||At.status==="running"),Kn=Ui||Pr||tc,ic=w?Je.getText(w):null,oc=Hn?new Date(Hn).toLocaleString(he.resolvedLanguage,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"",Jh=v.split("/").at(-1)??v,Yh=qn.warnings.length+qn.errors.length+$i.length,ac=Ft?`${Ft}${Ft.includes("?")?"&":"?"}download=1`:"",Xh=v||i.mainFile,En=!!(w&&w===Xh&&/\.tex$/i.test(w)),cc=y=>{const S=Yt.find(T=>T.path===y);S&&ps(S.path)?Fi(S):Ls(y)},Zh=y=>{document.getElementById(`editor-tab-${encodeURIComponent(y)}`)?.focus()},Qh=(y,S)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(y.key))return;y.preventDefault();const T=y.key==="Home"?0:y.key==="End"?Ge.length-1:(S+(y.key==="ArrowLeft"?-1:1)+Ge.length)%Ge.length,M=Ge[T];M&&(cc(M),window.requestAnimationFrame(()=>Zh(M)))},lc=Kn?Pr?At?.status==="queued"?r("editor.compileQueued"):r("editor.compilingBy",{name:At?.requestedBy.name??r("common.user")}):r("editor.compiling"):Nr==="failed"?Ft&&Hn?r("editor.compileFailedRetained",{time:new Date(Hn).toLocaleString(he.resolvedLanguage)}):r("editor.compileFailedNoPdf"):"",ef=Z==="editor.savedAt"&&_?r("editor.savedAt",{time:new Date(_).toLocaleTimeString(he.resolvedLanguage,{hour:"2-digit",minute:"2-digit",second:"2-digit"})}):r(Z);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(Sd,{size:18})}),o.jsx(Ti,{siteName:t.siteName,compact:!0}),o.jsxs("div",{className:"project-heading",children:[o.jsx("strong",{children:i.name}),o.jsxs("small",{children:[w," · ",ef]})]}),Ke.vimMode&&o.jsxs("span",{className:"vim-status-badge",title:r("editor.vimOnHint"),children:[o.jsx(Wm,{size:14}),r("editor.vimOn")]}),o.jsx(Nb,{sessions:Un,status:dn}),dn==="disconnected"&&o.jsxs("div",{className:"collaboration-recovery",role:"status",children:[o.jsx("span",{children:r("editor.collaboration.disconnected")}),o.jsx("button",{type:"button",onClick:Ni,children:r("editor.collaboration.reconnect")})]}),o.jsxs("div",{className:"editor-actions",children:[Wn&&o.jsxs("button",{className:Ct?"":"active",onClick:nc,children:[Ct?o.jsx(Jm,{size:15}):o.jsx(Mc,{size:15}),r("common.files")]}),o.jsx(Ob,{value:pe,onChange:Or}),o.jsxs("button",{onClick:()=>ne(!0),children:[o.jsx(Ed,{size:15}),r("history.title")]}),o.jsxs("button",{onClick:()=>I(!0),children:[o.jsx(Gs,{size:15}),r("projectSettings.share")]}),i.ownerId===e.id&&o.jsxs("button",{onClick:()=>qt(!0),children:[o.jsx(qm,{size:15}),"Git"]}),Wn&&i.permission!=="read"&&Zi(w)&&o.jsxs("button",{title:xe.selectedText.trim()?r("editor.formatSelection"):r("editor.formatSelectionHint"),onMouseDown:y=>y.preventDefault(),onClick:()=>{gh()},disabled:yt||ot||!Ye,children:[ot?o.jsx(Tt,{className:"spin",size:15}):o.jsx(vd,{size:15}),r(ot?"editor.formatting":"editor.formatSelection")]}),o.jsxs("button",{onClick:()=>Ii(!0),disabled:!w,children:[o.jsx(Gm,{size:15}),r("editor.addComment")]}),o.jsxs("button",{className:$e==="comments"?"active":"",onClick:()=>dt($e==="comments"?null:"comments"),children:[o.jsx(Dd,{size:15}),r("common.comments")," ",Ms.filter(y=>!y.resolved).length||""]}),o.jsxs("button",{className:$e==="settings"?"active":"",onClick:()=>dt($e==="settings"?null:"settings"),children:[o.jsx(Ro,{size:15}),r("common.settings")]}),o.jsxs("button",{className:"compile",title:Pr?r("editor.compilingBy",{name:At?.requestedBy.name??""}):r("editor.compileShortcut"),onClick:Hh,disabled:Kn||ot||yt||!Ye,children:[Kn?o.jsx(Tt,{className:"spin",size:15}):o.jsx(Qm,{size:15}),Pr?r("editor.compilingBy",{name:At?.requestedBy.name??""}):Ui?r("editor.compiling"):r("editor.compile",{engine:i.engine})]})]})]}),lc&&o.jsxs("div",{className:`compile-status-strip${Nr==="failed"?" failed":""}`,role:"status","aria-live":"polite",children:[o.jsx(Tt,{className:Kn?"spin":"",size:14}),o.jsx("span",{children:lc})]}),ie&&o.jsx("div",{className:"toast",onClick:()=>le(""),children:ie}),We&&o.jsx("div",{className:"toast success",onClick:()=>Ne(""),children:We}),o.jsxs(sf,{autoSaveId:"texlite-workspace-layout",direction:"horizontal",className:"work-grid",children:[Wn&&o.jsx(_r,{id:"files",order:1,ref:ue,defaultSize:16,minSize:12,maxSize:30,collapsible:!0,collapsedSize:0,onCollapse:()=>z(!0),onExpand:()=>z(!1),children:o.jsxs("aside",{className:"left-panel",children:[o.jsxs("section",{className:`files-panel${Ga?" drop-active":""}`,onDragEnter:y=>{y.dataTransfer.types.includes("Files")&&(y.preventDefault(),!yt&&!Er&&Li(!0))},onDragOver:y=>{y.dataTransfer.types.includes("Files")&&(y.preventDefault(),y.dataTransfer.dropEffect=yt||Er?"none":"copy")},onDragLeave:y=>{y.currentTarget.contains(y.relatedTarget)||Li(!1)},onDrop:y=>{y.preventDefault(),Li(!1),!yt&&!Er&&Xa(Array.from(y.dataTransfer.files))},children:[o.jsxs("div",{className:"panel-title",children:[o.jsx("span",{children: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:()=>de(!0),children:o.jsx(Vm,{size:15})}),o.jsx("button",{"aria-label":r("navigation.projectSearch"),title:`${r("navigation.projectSearch")} (Ctrl/Cmd+Shift+F)`,onClick:()=>ut(!0),children:o.jsx(ng,{size:15})}),!yt&&o.jsxs(o.Fragment,{children:[o.jsx("button",{disabled:Er,"aria-label":r("editor.uploadAttachment"),title:r("editor.uploadTo",{folder:kn||r("editor.projectRoot")}),onClick:()=>an.current?.click(),children:o.jsx(Xr,{size:15})}),o.jsx("button",{"aria-label":r("editor.newFolder"),title:r("editor.newFolder"),onClick:()=>{qa(""),_i(!0)},children:o.jsx(kd,{size:15})}),o.jsx("button",{"aria-label":r("editor.newFile"),title:r("editor.newFile"),onClick:()=>{Va(kn?`${kn}/`:""),Pi(!0)},children:o.jsx(Bm,{size:15})}),o.jsx("input",{ref:an,type:"file",multiple:!0,hidden:!0,onChange:y=>{Nh(y)}})]}),o.jsx("button",{"aria-label":r("editor.collapseFiles"),title:r("editor.collapseFiles"),onClick:nc,children:o.jsx(Mc,{size:15})})]})]}),Ga&&o.jsxs("div",{className:"file-drop-overlay",children:[o.jsx(Xr,{size:24}),o.jsx("strong",{children:r("editor.dropFiles")}),o.jsx("span",{children:r("editor.uploadTo",{folder:kn||r("editor.projectRoot")})})]}),o.jsxs("div",{className:"file-list",style:{fontSize:`${Ke.fontSize}px`},children:[o.jsx("div",{className:`file-entry folder-entry root-entry${kn===""?" selected":""}`,children:o.jsxs("button",{className:"file-entry-main",onClick:()=>Sr(""),children:[o.jsx(Oo,{size:15}),o.jsx("span",{children:r("editor.projectRoot")})]})}),Dh.map(y=>{const S=y.path.split("/").length-1,T=y.path.split("/").at(-1),M=jh.has(y.path),oe=P.has(y.path),Ee=v===y.path,me=y.path!==i.mainFile&&!i.mainFile.startsWith(`${y.path}/`);return y.type==="directory"?o.jsxs("div",{className:`file-entry folder-entry${kn===y.path?" selected":""}`,style:{paddingLeft:`${S*13+5}px`},children:[o.jsxs("button",{className:"file-entry-main",title:y.path,onClick:()=>{Sr(y.path),Wa(fn=>{const De=new Set(fn);return De.has(y.path)?De.delete(y.path):De.add(y.path),De})},children:[M?o.jsx(Cd,{size:13}):o.jsx(ia,{size:13}),o.jsx(Hm,{size:14}),o.jsx("span",{children:T})]}),!yt&&o.jsxs(o.Fragment,{children:[o.jsx("button",{className:"file-entry-action",title:r("editor.move"),"aria-label":r("editor.move"),onClick:()=>{Cr(y),jr(T??""),Ri("")},children:o.jsx(Ic,{size:13})}),me&&o.jsx("button",{className:"file-entry-action danger-text",title:r("editor.deletePath"),"aria-label":r("editor.deletePath"),onClick:()=>{kr(y),Bn("")},children:o.jsx(wn,{size:13})})]})]},y.path):o.jsxs("div",{className:`file-entry${w===y.path?" active":""}${oe?" root-document":""}${Ee?" compile-target":""}`,style:{paddingLeft:`${S*13+18}px`},children:[o.jsxs("button",{className:"file-entry-main",title:Ee?r("editor.currentMainDocument",{path:y.path}):oe?r("editor.mainDocumentCandidate",{path:y.path}):y.path,onClick:()=>Fi(y),children:[oe?o.jsx(Do,{size:13}):o.jsx(rs,{size:13}),o.jsx("span",{children:T}),Ee&&o.jsx("small",{children:r("editor.currentMainShort")})]}),!yt&&o.jsxs(o.Fragment,{children:[o.jsx("button",{className:"file-entry-action",title:r("editor.move"),"aria-label":r("editor.move"),onClick:()=>{Cr(y),jr(T??""),Ri("")},children:o.jsx(Ic,{size:13})}),me&&o.jsx("button",{className:"file-entry-action danger-text",title:r("editor.deletePath"),"aria-label":r("editor.deletePath"),onClick:()=>{kr(y),Bn("")},children:o.jsx(wn,{size:13})})]})]},y.path)})]})]}),o.jsxs("section",{className:"outline-panel",children:[o.jsx("div",{className:"panel-title",children:o.jsxs("span",{children:[o.jsx(Km,{size:14}),r("common.outline")]})}),o.jsxs("div",{className:"outline",children:[sc.map((y,S)=>o.jsxs("button",{className:`outline-item${w===y.path&&H.line===y.line?" current":""}`,title:`${y.path}:${y.line}`,onClick:()=>{x(y.path,y.line,1),se(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===w?y.line:y.path.split("/").at(-1)}),o.jsx("span",{className:"outline-title",children:y.title})]},`${y.path}-${y.line}-${S}`)),sc.length===0&&o.jsx("p",{className:"muted padded",children:r("editor.noOutline")})]})]})]})}),Wn&&o.jsx(Bi,{className:"resize-handle",children:o.jsx(Xi,{size:12})}),Wn&&o.jsx(_r,{id:"source",order:2,defaultSize:42,minSize:22,children:o.jsxs("main",{className:"source-panel",children:[Ke.openFilesInTabs&&Ge.length>0&&o.jsx("div",{className:"editor-tabs-bar",role:"tablist","aria-label":r("editor.openFiles"),children:o.jsx("div",{className:"editor-tabs-scroll",children:Ge.map((y,S)=>{const T=y===w,M=y===(v||i.mainFile),oe=y.split("/").at(-1)||y;return o.jsxs("div",{className:`editor-tab-item${T?" active":""}`,role:"presentation",children:[o.jsxs("button",{id:`editor-tab-${encodeURIComponent(y)}`,type:"button",role:"tab","aria-selected":T,"aria-controls":"editor-source-content",tabIndex:T?0:-1,className:`editor-tab${T?" active":""}${M?" main-tab":""}`,onClick:()=>cc(y),onKeyDown:Ee=>Qh(Ee,S),title:y,children:[o.jsx("span",{className:"editor-tab-icon",children:M?o.jsx(Do,{size:13}):o.jsx(rs,{size:13})}),o.jsx("span",{className:"editor-tab-title",children:oe}),M&&o.jsx("small",{className:"editor-tab-badge",children:r("editor.currentMainShort")})]}),o.jsx("button",{type:"button",className:"editor-tab-close",title:r("common.close"),"aria-label":`${r("common.close")} ${oe}`,onClick:()=>Ls(y),children:o.jsx(Zr,{size:12})})]},y)})})}),o.jsxs("div",{id:"editor-source-content",className:"editor-content-container",children:[o.jsx(h.Suspense,{fallback:o.jsxs("div",{className:"preview-empty",children:[o.jsx(Tt,{className:"spin",size:22}),o.jsx("span",{children:r("common.loading")})]}),children:o.jsx(Xb,{value:O,readOnly:yt,comments:Ms,focusComment:Ph,preferences:Ke,completionIndex:u,spellCheckIssues:je.issues,spellCheckJump:je.jump,jumpTo:E===w&&br?.path===w?br:null,searchRequest:0,collaboration:ic?{text:ic,awareness:Je.awareness,undoManager:yt?void 0:Je.getUndoManager(w)}:void 0,onChange:_e,onSelection:(y,S,T)=>pt({selectedText:y,startOffset:S,endOffset:T}),onCommentClick:y=>{const S=Ms.find(T=>T.id===y);S&&(Qa({...S}),dt("comments"))},onSpellCheckReplace:Gh,onCursor:mr},w)}),ec&&o.jsx("div",{className:"editor-centered-notice",role:"status","aria-live":"polite",children:ec})]})]})}),Wn&&rc&&o.jsxs(Bi,{className:"resize-handle sync-resize-handle",children:[o.jsx(Xi,{className:"resize-grip",size:12}),o.jsxs("span",{className:"sync-direction-buttons",onPointerDown:y=>y.stopPropagation(),children:[o.jsx("button",{disabled:!xr||!En,title:r(En?"editor.showInSource":"editor.syncTexOnlyForMain"),"aria-label":r("editor.showInSource"),onClick:()=>{if(!En){Ne(r("editor.syncTexOnlyForMain"));return}Oe()},children:o.jsx("span",{"aria-hidden":!0,children:"←"})}),o.jsx("button",{disabled:!w||!Ft||!En,title:r(En?"editor.showInPdf":"editor.syncTexOnlyForMain"),"aria-label":r("editor.showInPdf"),onClick:()=>{if(!En){Ne(r("editor.syncTexOnlyForMain"));return}se(w,H.line,H.column)},children:o.jsx("span",{"aria-hidden":!0,children:"→"})})]})]}),rc&&o.jsx(_r,{id:"preview",order:3,defaultSize:42,minSize:22,children:o.jsxs("section",{className:"preview-panel",children:[o.jsxs("div",{className:"preview-tabs",children:[o.jsxs("div",{className:"preview-tab-list",role:"tablist","aria-label":r("editor.outputTabs"),children:[o.jsxs("button",{role:"tab","aria-selected":ce==="pdf",className:`pdf-tab${ce==="pdf"?" active":""}`,onClick:()=>ge("pdf"),title:Hn?r("editor.pdfCompiledAtFor",{file:v,time:new Date(Hn).toLocaleString(he.resolvedLanguage)}):r("editor.currentMainDocument",{path:v}),children:[o.jsx(rs,{size:16}),o.jsxs("span",{className:"pdf-tab-label",children:["PDF · ",Jh,oc&&o.jsx("small",{children:oc})]})]}),o.jsxs("button",{role:"tab","aria-selected":ce==="diagnostics",className:`diagnostics-tab${ce==="diagnostics"?" active":""}`,onClick:()=>we("diagnostics"),children:[o.jsx(_o,{size:14}),r("editor.outputTabs"),o.jsx("span",{children:Yh})]})]}),ac&&o.jsxs("a",{className:"pdf-download-top",href:ac,download:!0,title:r("editor.downloadPdf"),"aria-label":r("editor.downloadPdf"),children:[o.jsx(Ks,{size:15}),o.jsx("span",{children:r("editor.downloadPdf")})]})]}),ce==="diagnostics"&&o.jsxs("div",{className:"preview-subtabs",role:"tablist","aria-label":r("editor.outputTabs"),children:[o.jsxs("button",{role:"tab","aria-selected":G==="log",className:G==="log"?"active":"",onClick:()=>ge("log"),children:[o.jsx(_o,{size:13}),r("editor.log")]}),o.jsxs("button",{role:"tab","aria-selected":G==="warnings",className:G==="warnings"?"active":"",onClick:()=>ge("warnings"),children:[o.jsx(ys,{size:13}),r("editor.warnings"),o.jsx("span",{children:qn.warnings.length})]}),o.jsxs("button",{role:"tab","aria-selected":G==="errors",className:G==="errors"?"active":"",onClick:()=>ge("errors"),children:[o.jsx(oa,{size:13}),r("editor.errors"),o.jsx("span",{children:qn.errors.length})]}),o.jsxs("button",{role:"tab","aria-selected":G==="artifacts",className:G==="artifacts"?"active":"",onClick:()=>ge("artifacts"),children:[o.jsx(Td,{size:13}),r("editor.artifacts"),o.jsx("span",{children:$i.length})]}),o.jsxs("button",{role:"tab","aria-selected":G==="clean",className:G==="clean"?"active":"",onClick:()=>ge("clean"),children:[o.jsx(To,{size:13}),r("editor.clean")]})]}),o.jsxs("div",{className:`preview-content preview-${ce} ${ce==="diagnostics"?`preview-${G}`:""}`,children:[ce==="pdf"&&(Ft?o.jsx(h.Suspense,{fallback:o.jsxs("div",{className:"pdf-loading-state",role:"status","aria-live":"polite",children:[o.jsx(Tt,{className:"spin",size:24}),o.jsx("span",{children:r("editor.loadingPdf")})]}),children:o.jsx(Yb,{url:Ft,target:Oi,compiling:Kn,onViewportLocation:(y,S,T)=>Fs({page:y,x:S,y:T}),onDoubleClickLocation:(y,S,T)=>{if(Fs({page:y,x:S,y:T}),!En){Ne(r("editor.syncTexOnlyForMain"));return}re(y,S,T)}})}):Mi?o.jsxs("div",{className:"pdf-loading-state",role:"status","aria-live":"polite",children:[o.jsx(Tt,{className:"spin",size:24}),o.jsx("span",{children:r("editor.loadingPdf")})]}):o.jsxs("div",{className:"preview-empty",children:[o.jsx(rs,{size:28}),o.jsx("strong",{children:r("editor.preview")}),o.jsx("span",{children:r("editor.previewHint")})]})),ce==="diagnostics"&&G==="log"&&o.jsx(po,{lines:Dr?Dr.split(`
14
- `):[],empty:r(Ui?"editor.compiling":"editor.noLog")}),ce==="diagnostics"&&G==="warnings"&&(Tr?o.jsx(jl,{tone:"warning",diagnostics:Tr.warnings,files:Yt,empty:r("editor.noWarnings"),onJump:(y,S,T)=>{pe==="pdf-only"&&Or("editor-pdf"),x(y,S,T)}}):o.jsx(po,{tone:"warning",lines:qn.warnings,empty:r("editor.noWarnings")})),ce==="diagnostics"&&G==="errors"&&(Tr?o.jsx(jl,{tone:"error",diagnostics:Tr.errors,files:Yt,empty:r("editor.noErrors"),onJump:(y,S,T)=>{pe==="pdf-only"&&Or("editor-pdf"),x(y,S,T)}}):o.jsx(po,{tone:"error",lines:qn.errors,empty:r("editor.noErrors")})),ce==="diagnostics"&&G==="artifacts"&&o.jsx(Lb,{projectId:n,mainFile:v,artifacts:$i,preview:Bh,loading:Vh,onView:y=>{Wh(y)}}),ce==="diagnostics"&&G==="clean"&&o.jsx(Ab,{mainFile:v,disabled:yt||!Ye||Kn,cleaning:tc,onCleanCache:()=>Ue("cache"),onCleanArtifacts:()=>Ue("artifacts")})]})]})}),$e&&o.jsxs(o.Fragment,{children:[o.jsx(Bi,{className:"resize-handle",children:o.jsx(Xi,{size:12})}),o.jsx(_r,{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($e==="comments"?"editor.sourceComments":"editor.projectSettings")}),o.jsx("button",{"aria-label":r("common.close"),onClick:()=>dt(null),children:o.jsx(Zr,{size:17})})]}),$e==="comments"&&o.jsxs("div",{className:"comments",children:[Ms.map(y=>o.jsx(Pb,{comment:y,currentUserId:e.id,onFocus:()=>Qa({...y}),onToggle:()=>{Fh(y)},onReply:S=>Ih(y,S),onEdit:S=>Mh(y,S),onDelete:()=>$h(y),onEditReply:(S,T)=>Uh(y,S,T),onDeleteReply:S=>zh(y,S)},y.id)),Ms.length===0&&o.jsx("p",{className:"muted padded",children:r("editor.noComments")})]}),$e==="settings"&&o.jsx(Rb,{project:i,projectId:n,site:t,files:Yt,dictionaryWords:d,onDictionaryChange:f,editorPreferences:Ke,onEditorPreferences:Kh,spellCheckCount:je.summary?.total??null,spellCheckUniqueCount:je.summary?.unique??null,spellCheckIndex:je.summary?je.index:-1,onSpellCheckNavigate:je.jumpToIssue,onProject:a})]})})]})]}),o.jsxs(Ve,{open:!!Re,extraWide:Re?.kind==="image"||Re?.kind==="pdf"||Re?.kind==="text",title:Re?.path??"",description:Re?.kind==="large"?r("editor.resourceTooLarge",{size:fh(Re.size),limit:"10 MB"}):r(`editor.resourcePreview.${Re?.kind??"text"}`),onOpenChange:y=>{y||(Ha(null),vh(!1))},footer:Re&&o.jsxs("a",{className:"primary resource-download",href:`${Re.url}&download=1`,download:!0,children:[o.jsx(Ks,{size:14}),r("editor.downloadResource")]}),children:[Re?.kind==="large"&&o.jsxs("div",{className:"resource-preview-message",children:[o.jsx(No,{size:34}),o.jsx("strong",{children:r("editor.resourceTooLargeTitle")}),o.jsx("span",{children:r("editor.resourceTooLargeDescription")})]}),Re?.kind==="unsupported"&&o.jsxs("div",{className:"resource-preview-message",children:[o.jsx(No,{size:34}),o.jsx("strong",{children:r("editor.resourceUnsupportedTitle")}),o.jsx("span",{children:r("editor.resourceUnsupportedDescription")})]}),Re?.kind==="image"&&o.jsx("div",{className:"resource-image-wrap",children:o.jsx("img",{className:"resource-image",src:Re.url,alt:Re.path})}),Re?.kind==="pdf"&&o.jsx("iframe",{className:"resource-pdf",src:Re.url,title:Re.path}),Re?.kind==="text"&&(bh?o.jsxs("div",{className:"resource-preview-message",children:[o.jsx(Tt,{className:"spin",size:24}),o.jsx("span",{children:r("common.loading")})]}):o.jsx("pre",{className:"resource-text",children:Re.content}))]}),o.jsx(gs,{open:!!Ai,title:r("editor.uploadOverwriteTitle"),description:r("editor.uploadOverwriteDescription",{files:Ai?.collisions.join(", ")??""}),confirmLabel:r("editor.uploadOverwrite"),danger:!0,onCancel:()=>Ja(null),onConfirm:()=>{const y=Ai;Ja(null),y&&Xa(y.files,new Set(y.collisions),y.directory)}}),o.jsx(gs,{open:!!B,title:r(B==="cache"?"editor.cleanCacheConfirmTitle":"editor.cleanArtifactsConfirmTitle"),description:r(B==="cache"?"editor.cleanCacheConfirmDescription":"editor.cleanArtifactsConfirmDescription"),confirmLabel:r("editor.cleanConfirm"),danger:B==="artifacts",onCancel:()=>Ue(null),onConfirm:()=>{const y=B;Ue(null),y&&qh(y)}}),o.jsx(Ve,{open:wh,title:r("editor.newFile"),description:r("editor.newFileDescription"),onOpenChange:y=>{Pi(y),y||Bn("")},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>Pi(!1),children:r("common.cancel")}),o.jsx("button",{className:"primary",onClick:()=>{Th()},children:r("common.create")})]}),children:o.jsxs(o.Fragment,{children:[hn&&o.jsx("p",{className:"error dialog-error",children:hn}),o.jsxs("label",{className:"form-field",children:[r("editor.filePath"),o.jsx("input",{autoFocus:!0,value:xh,onChange:y=>Va(y.target.value)})]})]})}),o.jsx(Ve,{open:Sh,title:r("editor.newFolder"),description:r("editor.folderDestination",{folder:kn||r("editor.projectRoot")}),onOpenChange:y=>{_i(y),y||Bn("")},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>_i(!1),children:r("common.cancel")}),o.jsx("button",{className:"primary",onClick:()=>{Ya()},children:r("common.create")})]}),children:o.jsxs(o.Fragment,{children:[hn&&o.jsx("p",{className:"error dialog-error",children:hn}),o.jsxs("label",{className:"form-field",children:[r("editor.folderName"),o.jsx("input",{autoFocus:!0,value:Ch,onChange:y=>qa(y.target.value),onKeyDown:y=>{y.key==="Enter"&&Ya()}})]})]})}),o.jsx(Ve,{open:!!Is,title:r("editor.moveTitle",{name:Is?.path.split("/").at(-1)??""}),description:r("editor.moveDescription"),onOpenChange:y=>{y||(Cr(null),jr(""),Bn(""))},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>Cr(null),children:r("common.cancel")}),o.jsx("button",{className:"primary",disabled:!Ka.trim(),onClick:()=>{Za()},children:r("editor.moveApply")})]}),children:o.jsxs(o.Fragment,{children:[hn&&o.jsx("p",{className:"error dialog-error",children:hn}),o.jsxs("label",{className:"form-field",children:[r("editor.pathName"),o.jsx("input",{autoFocus:!0,value:Ka,onChange:y=>jr(y.target.value),onKeyDown:y=>{y.key==="Enter"&&Za()}})]}),o.jsxs("label",{className:"form-field",children:[r("editor.destinationFolder"),o.jsxs("select",{value:kh,onChange:y=>Ri(y.target.value),children:[o.jsx("option",{value:"",children:r("editor.projectRoot")}),Eh.filter(y=>Is?.type!=="directory"||y.path!==Is.path&&!y.path.startsWith(`${Is.path}/`)).map(y=>o.jsx("option",{value:y.path,children:y.path},y.path))]})]})]})}),o.jsx(Ve,{open:!!Vn,title:r("editor.deletePathTitle",{name:Vn?.path.split("/").at(-1)??""}),description:zi.length?r("editor.deletePathActiveDescription",{path:Vn?.path??"",users:[...new Set(zi.map(y=>y.name))].join(", ")}):r("editor.deletePathDescription",{path:Vn?.path??""}),onOpenChange:y=>{y||(kr(null),Bn(""))},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>kr(null),children:r("common.cancel")}),o.jsx("button",{className:"danger",onClick:()=>{Oh()},children:r("common.delete")})]}),children:o.jsxs(o.Fragment,{children:[hn&&o.jsx("p",{className:"error dialog-error",children:hn}),zi.length>0&&o.jsxs("p",{className:"warning",children:[o.jsx(ys,{size:15}),r("editor.deletePathWillClose")]})]})}),o.jsxs(Ve,{open:_h,title:r("editor.addComment"),description:xe.selectedText?r("editor.commentDescription",{count:xe.endOffset-xe.startOffset}):r("editor.pointComment"),onOpenChange:Ii,footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>Ii(!1),children:r("common.cancel")}),o.jsx("button",{className:"primary",onClick:()=>{Ah()},children:r("editor.addComment")})]}),children:[o.jsxs("label",{className:"form-field",children:[r("editor.commentContent"),o.jsx("textarea",{autoFocus:!0,rows:5,value:Rh,onChange:y=>Lh(y.target.value)})]}),xe.selectedText&&o.jsx("blockquote",{className:"selection-preview",children:xe.selectedText})]}),o.jsx(_b,{open:te,onOpenChange:I,project:i,projectId:n}),tt&&o.jsx(h.Suspense,{fallback:null,children:o.jsx(tv,{open:!0,files:Yt,onOpenChange:de,onOpenFile:y=>{const S=Yt.find(T=>T.path===y);S&&Fi(S)}})}),it&&o.jsx(h.Suspense,{fallback:null,children:o.jsx(ev,{open:!0,project:i,onOpenChange:ut,onJump:(y,S,T)=>{pe==="pdf-only"&&Or("editor-pdf"),x(y,S,T)}})}),$&&o.jsx(h.Suspense,{fallback:null,children:o.jsx(Qb,{open:!0,onOpenChange:ne,project:i,onBeforeMutation:i.permission==="read"?async()=>!0:jn})}),i.ownerId===e.id&&et&&o.jsx(h.Suspense,{fallback:null,children:o.jsx(Zb,{open:!0,onOpenChange:qt,project:i,onBeforeMutation:jn})})]})}function uv(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 fh(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`}function hv(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}class fv extends h.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,n){console.error("Uncaught error in component tree:",e,n)}handleReset=()=>{this.setState({hasError:!1,error:null}),this.props.onReset?.()};render(){return this.state.hasError?typeof this.props.fallback=="function"?this.props.fallback(this.state.error??new Error("Unknown error"),this.handleReset):this.props.fallback?this.props.fallback:o.jsxs("div",{role:"alert",style:{padding:"2rem",margin:"1rem",borderRadius:"8px",backgroundColor:"var(--bg-secondary, #f8f9fa)",border:"1px solid var(--border-color, #e9ecef)",color:"var(--text-primary, #212529)",fontFamily:"system-ui, -apple-system, sans-serif"},children:[o.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:600,marginBottom:"0.5rem",color:"#dc3545"},children:this.props.title??he.t("errors.boundaryTitle")}),o.jsx("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary, #6c757d)",marginBottom:"1rem"},children:he.t("errors.boundaryDescription")}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[o.jsx("button",{type:"button",onClick:this.handleReset,className:"primary",style:{padding:"0.4rem 0.8rem",borderRadius:"4px",cursor:"pointer"},children:he.t("errors.boundaryRetry")}),o.jsx("button",{type:"button",onClick:()=>window.location.reload(),style:{padding:"0.4rem 0.8rem",borderRadius:"4px",cursor:"pointer"},children:he.t("errors.boundaryReload")})]})]}):this.props.children}}rf.createRoot(document.getElementById("root")).render(o.jsx(h.StrictMode,{children:o.jsx(fv,{children:o.jsx(rv,{})})}));export{_m as A,Cd as C,rs as F,qm as G,Tt as L,Ve as M,tg as R,Yr as S,wn as T,Jw as U,rn as _,vv as a,Sv as b,bv as c,Cv as d,An as e,yv as f,Zt as g,gv as h,F as i,ia as j,A as k,gs as l,da as m,ng as n,Vm as o,Fm as p,xv as r,wv as t};