texlite 0.5.4 → 0.6.0

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.
@@ -0,0 +1,17 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-rBWMBTI-.js","assets/react-CsO_xvbl.js","assets/spellCheck-BHW5bumN.js","assets/PdfPreview-IfkmLMSU.js","assets/pdf-DPnwNQHb.js","assets/plus-Bup73Wq6.js","assets/LatexEditor-Dp8EoZBP.js","assets/editor-DMLs-XWi.js","assets/GitDialog-9mNxx8oX.js","assets/HistoryDialog-CmoD9Cvf.js","assets/ProjectNavigationDialogs-veKVnRxc.js","assets/SystemMetricsDialog-D_oiVmBC.js"])))=>i.map(i=>d[i]);
2
+ import{i as Uh,r as h,j as o,R as er,a as bl,b as zh,u as Oe,P as Bh,c as kr,d as Fi,e as Vh}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 Hh="modulepreload",qh=function(t){return"/"+t},tc={},Zt=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=qh(d),d in tc)return;tc[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":Hh,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)})},Wh="0.6.0";var Ii={};const K=t=>typeof t=="string",Rs=()=>{let t,e;const n=new Promise((s,r)=>{t=s,e=r});return n.resolve=t,n.reject=e,n},nc=t=>t==null?"":""+t,Kh=(t,e,n)=>{t.forEach(s=>{e[s]&&(n[s]=e[s])})},Gh=/###/g,sc=t=>t&&t.indexOf("###")>-1?t.replace(Gh,"."):t,rc=t=>!t||K(t),Is=(t,e,n)=>{const s=K(e)?e.split("."):e;let r=0;for(;r<s.length-1;){if(rc(t))return{};const i=sc(s[r]);!t[i]&&n&&(t[i]=new n),Object.prototype.hasOwnProperty.call(t,i)?t=t[i]:t={},++r}return rc(t)?{}:{obj:t,k:sc(s[r])}},ic=(t,e,n)=>{const{obj:s,k:r}=Is(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=Is(t,a,Object);for(;c.obj===void 0&&a.length;)i=`${a[a.length-1]}.${i}`,a=a.slice(0,a.length-1),c=Is(t,a,Object),c?.obj&&typeof c.obj[`${c.k}.${i}`]<"u"&&(c.obj=void 0);c.obj[`${c.k}.${i}`]=n},Jh=(t,e,n,s)=>{const{obj:r,k:i}=Is(t,e,Object);r[i]=r[i]||[],r[i].push(n)},zr=(t,e)=>{const{obj:n,k:s}=Is(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,s))return n[s]},Yh=(t,e,n)=>{const s=zr(t,n);return s!==void 0?s:zr(e,n)},vl=(t,e,n)=>{for(const s in e)s!=="__proto__"&&s!=="constructor"&&(s in t?K(t[s])||t[s]instanceof String||K(e[s])||e[s]instanceof String?n&&(t[s]=e[s]):vl(t[s],e[s],n):t[s]=e[s]);return t},yn=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Xh={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const Zh=t=>K(t)?t.replace(/[&<>"'\/]/g,e=>Xh[e]):t;class Qh{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 ef=[" ",",","?","!",";"],tf=new Qh(20),nf=(t,e,n)=>{e=e||"",n=n||"";const s=ef.filter(a=>e.indexOf(a)<0&&n.indexOf(a)<0);if(s.length===0)return!0;const r=tf.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},lo=(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},Us=t=>t?.replace(/_/g,"-"),sf={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 Br{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||sf,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:(K(e[0])&&(e[0]=`${s}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new Br(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new Br(this.logger,e)}}var It=new Br;class ci{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 oc extends ci{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):K(s)&&i?c.push(...s.split(i)):c.push(s)));const l=zr(this.data,c);return!l&&!n&&!s&&e.indexOf(".")>-1&&(e=c[0],n=c[1],s=c.slice(2).join(".")),l||!a||!K(s)?l:lo(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),ic(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)(K(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=zr(this.data,c)||{};a.skipCopy||(s=JSON.parse(JSON.stringify(s))),r?vl(l,s,i):l={...l,...s},ic(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 Sl={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 Cl=Symbol("i18next/PATH_KEY");function rf(){const t=[],e=Object.create(null);let n;return e.get=(s,r)=>(n?.revoke?.(),r===Cl?t:(t.push(r),n=Proxy.revocable(s,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function Yn(t,e){const{[Cl]:n}=t(rf()),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 ac={},Mi=t=>!K(t)&&typeof t!="boolean"&&typeof t!="number";class Vr extends ci{constructor(e,n={}){super(),Kh(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=It.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=Mi(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&&!nf(e,s,r);if(a&&!c){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:K(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:K(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=Yn(e,{...this.options,...r})),Array.isArray(e)||(e=[String(e)]),e=e.map(P=>typeof P=="function"?Yn(P,{...this.options,...r}):String(P));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 x=m?.usedKey||c,b=m?.exactUsedKey||c,S=["[object Number]","[object Function]","[object RegExp]"],k=r.joinArrays!==void 0?r.joinArrays:this.options.joinArrays,T=!this.i18nFormat||this.i18nFormat.handleAsObject,N=r.count!==void 0&&!K(r.count),O=Vr.hasDefaultValue(r),I=N?this.pluralResolver.getSuffix(u,r.count,r):"",D=r.ordinal&&N?this.pluralResolver.getSuffix(u,r.count,{ordinal:!1}):"",G=N&&!r.ordinal&&r.count===0,v=G&&r[`defaultValue${this.options.pluralSeparator}zero`]||r[`defaultValue${I}`]||r[`defaultValue${D}`]||r.defaultValue;let A=g;T&&!g&&O&&(A=v);const te=Mi(A),z=Object.prototype.toString.apply(A);if(T&&A&&te&&S.indexOf(z)<0&&!(K(k)&&Array.isArray(A))){if(!r.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const P=this.options.returnedObjectHandler?this.options.returnedObjectHandler(x,A,{...r,ns:l}):`key '${c} (${this.language})' returned an object instead of string.`;return i?(m.res=P,m.usedParams=this.getUsedParamsDetails(r),m):P}if(a){const P=Array.isArray(A),_=P?[]:{},C=P?b:x;for(const U in A)if(Object.prototype.hasOwnProperty.call(A,U)){const le=`${C}${a}${U}`;O&&!g?_[U]=this.translate(le,{...r,defaultValue:Mi(v)?v[U]:void 0,joinArrays:!1,ns:l}):_[U]=this.translate(le,{...r,joinArrays:!1,ns:l}),_[U]===le&&(_[U]=A[U])}g=_}}else if(T&&K(k)&&Array.isArray(g))g=g.join(k),g&&(g=this.extendTranslation(g,e,r,s));else{let P=!1,_=!1;!this.isValidLookup(g)&&O&&(P=!0,g=v),this.isValidLookup(g)||(_=!0,g=c);const U=(r.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&_?void 0:g,le=O&&v!==g&&this.options.updateMissing;if(_||P||le){if(this.logger.log(le?"updateKey":"missingKey",u,d,c,le?v:g),a){const de=this.resolve(c,{...r,keySeparator:!1});de&&de.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 xe=this.languageUtils.getFallbackCodes(this.options.fallbackLng,r.lng||this.language);if(this.options.saveMissingTo==="fallback"&&xe&&xe[0])for(let de=0;de<xe.length;de++)ce.push(xe[de]);else this.options.saveMissingTo==="all"?ce=this.languageUtils.toResolveHierarchy(r.lng||this.language):ce.push(r.lng||this.language);const se=(de,Y,ve)=>{const ye=O&&ve!==g?ve:U;this.options.missingKeyHandler?this.options.missingKeyHandler(de,d,Y,ye,le,r):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(de,d,Y,ye,le,r),this.emit("missingKey",de,d,Y,g)};this.options.saveMissing&&(this.options.saveMissingPlurals&&N?ce.forEach(de=>{const Y=this.pluralResolver.getSuffixes(de,r);G&&r[`defaultValue${this.options.pluralSeparator}zero`]&&Y.indexOf(`${this.options.pluralSeparator}zero`)<0&&Y.push(`${this.options.pluralSeparator}zero`),Y.forEach(ve=>{se([de],c+ve,r[`defaultValue${ve}`]||v)})}):se(ce,c,v))}g=this.extendTranslation(g,e,r,m,s),_&&g===c&&this.options.appendNamespaceToMissingKey&&(g=`${d}${f}${c}`),(_||P)&&this.options.parseMissingKeyHandler&&(g=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${d}${f}${c}`:c,P?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=K(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&&!K(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=K(a)?[a]:a;return e!=null&&c?.length&&s.applyPostProcessor!==!1&&(e=Sl.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 K(e)&&(e=[e]),Array.isArray(e)&&(e=e.map(l=>typeof l=="function"?Yn(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&&!K(n.count),m=p&&!n.ordinal&&n.count===0,g=n.context!==void 0&&(K(n.context)||typeof n.context=="number")&&n.context!=="",x=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);u.forEach(b=>{this.isValidLookup(s)||(c=b,!ac[`${x[0]}-${b}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(c)&&(ac[`${x[0]}-${b}`]=!0,this.logger.warn(`key "${r}" for languages "${x.join(", ")}" won't get resolved as namespace "${c}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),x.forEach(S=>{if(this.isValidLookup(s))return;a=S;const k=[f];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(k,f,S,b,n);else{let N;p&&(N=this.pluralResolver.getSuffix(S,n.count,n));const O=`${this.options.pluralSeparator}zero`,I=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(n.ordinal&&N.indexOf(I)===0&&k.push(f+N.replace(I,this.options.pluralSeparator)),k.push(f+N),m&&k.push(f+O)),g){const D=`${f}${this.options.contextSeparator||"_"}${n.context}`;k.push(D),p&&(n.ordinal&&N.indexOf(I)===0&&k.push(D+N.replace(I,this.options.pluralSeparator)),k.push(D+N),m&&k.push(D+O))}}let T;for(;T=k.pop();)this.isValidLookup(s)||(i=T,s=this.getResource(S,b,T,n))}))})}),{res:s,usedKey:r,exactUsedKey:i,usedLng:a,usedNS:c}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,s,r={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,s,r):this.resourceStore.getResource(e,n,s,r)}getUsedParamsDetails(e={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],s=e.replace&&!K(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 cc{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=It.create("languageUtils")}getScriptPartFromCode(e){if(e=Us(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=Us(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(K(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)),K(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 K(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))):K(e)&&i(this.formatLanguageCode(e)),s.forEach(a=>{r.indexOf(a)<0&&i(this.formatLanguageCode(a))}),r}}const lc={zero:0,one:1,two:2,few:3,many:4,other:5},dc={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class of{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=It.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const s=Us(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!"),dc;if(!e.match(/-|_/))return dc;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)=>lc[r]-lc[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 uc=(t,e,n,s=".",r=!0)=>{let i=Yh(t,e,n);return!i&&r&&K(n)&&(i=lo(t,n,s),i===void 0&&(i=lo(e,n,s))),i},$i=t=>t.replace(/\$/g,"$$$$");class hc{constructor(e={}){this.logger=It.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:x,nestingOptionsSeparator:b,maxReplaces:S,alwaysFormat:k}=e.interpolation;this.escape=n!==void 0?n:Zh,this.escapeValue=s!==void 0?s:!0,this.useRawValueToEscape=r!==void 0?r:!1,this.prefix=i?yn(i):a||"{{",this.suffix=c?yn(c):l||"}}",this.formatSeparator=d||",",this.unescapePrefix=f?"":u||"-",this.unescapeSuffix=this.unescapePrefix?"":f||"",this.nestingPrefix=p?yn(p):m||yn("$t("),this.nestingSuffix=g?yn(g):x||yn(")"),this.nestingOptionsSeparator=b||",",this.maxReplaces=S||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 S=uc(n,l,m,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(S,void 0,s,{...r,...n,interpolationkey:m}):S}const g=m.split(this.formatSeparator),x=g.shift().trim(),b=g.join(this.formatSeparator).trim();return this.format(uc(n,l,x,this.options.keySeparator,this.options.ignoreJSONStructure),b,s,{...r,...n,interpolationkey:x})};this.resetRegExp();const f=r?.missingInterpolationHandler||this.options.missingInterpolationHandler,u=r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:m=>$i(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?$i(this.escape(m)):$i(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=K(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!K(a)&&!this.useRawValueToEscape&&(a=nc(a));const x=m.safeValue(a);if(e=e.replace(i[0],x),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(`${yn(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(x){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,x),`${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&&!K(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&&!K(i))return i;K(i)||(i=nc(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 af=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}},fc=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(Us(s),r),e[a]=c),c(n)}},cf=t=>(e,n,s)=>t(Us(n),s)(e);class lf{constructor(e={}){this.logger=It.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const s=n.cacheInBuiltFormats?fc: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()]=fc(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}=af(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 df=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class uf extends ci{constructor(e,n,s,r={}){super(),this.backend=e,this.store=n,this.services=s,this.languageUtils=s.languageUtils,this.options=r,this.logger=It.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=>{Jh(l.loaded,[i],a),df(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();K(e)&&(e=this.languageUtils.toResolveHierarchy(e)),K(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 Ui=()=>({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]),K(t[1])&&(e.defaultValue=t[1]),K(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}),pc=t=>(K(t.ns)&&(t.ns=[t.ns]),K(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),K(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),Er=()=>{},hf=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})},jl="__i18next_supportNoticeShown",ff=()=>!!(typeof globalThis<"u"&&globalThis[jl]||typeof process<"u"&&Ii&&Ii.I18NEXT_NO_SUPPORT_NOTICE||typeof process<"u"&&Ii),pf=()=>{typeof globalThis<"u"&&(globalThis[jl]=!0)},mf=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 Ms extends ci{constructor(e={},n){if(super(),this.options=pc(e),this.services={},this.logger=It,this.modules={external:[]},hf(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&&(K(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const s=Ui();this.options={...s,...this.options,...pc(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&&!mf(this)&&!ff()&&(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 💙"),pf());const r=d=>d?typeof d=="function"?new d:d:null;if(!this.options.isClone){this.modules.logger?It.init(r(this.modules.logger),this.options):It.init(null,this.options);let d;this.modules.formatter?d=this.modules.formatter:d=lf;const f=new cc(this.options);this.store=new oc(this.options.resources,this.options);const u=this.services;u.logger=It,u.resourceStore=this.store,u.languageUtils=f,u.pluralResolver=new of(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 hc(this.options),u.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},u.backendConnector=new uf(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 Vr(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=Er),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=Rs(),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=Er){let s=n;const r=K(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=Rs();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=Er),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"&&Sl.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=Rs();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=K(c)?c:c&&c[0],d=this.store.hasLanguageSomeTranslations(l)?l:this.services.languageUtils.getBestMatchFromCodes(K(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=Yn(l.keyPrefix,d));const f=this.options.keySeparator||".";let u;return l.keyPrefix&&Array.isArray(i)?u=i.map(p=>(typeof p=="function"&&(p=Yn(p,d)),`${l.keyPrefix}${f}${p}`)):(typeof i=="function"&&(i=Yn(i,d)),u=l.keyPrefix?`${l.keyPrefix}${f}${i}`:i),this.t(u,l)};return K(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=Rs();return this.options.ns?(K(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=Rs();K(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 cc(Ui());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 Ms(e,n);return s.createInstance=Ms.createInstance,s}cloneInstance(e={},n=Er){const s=e.forkResourceStore;s&&delete e.forkResourceStore;const r={...this.options,...e,isClone:!0},i=new Ms(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 oc(c,r),i.services.resourceStore=i.store}if(e.interpolation){const l={...Ui().interpolation,...this.options.interpolation,...e.interpolation},d={...r,interpolation:l};i.services.interpolator=new hc(d)}return i.translator=new Vr(i.services,r),i.translator.on("*",(c,...l)=>{i.emit(c,...l)}),i.init(r,n),i.translator.options=r,i.translator.backendConnector.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},i}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const ge=Ms.createInstance();ge.createInstance;ge.dir;ge.init;ge.loadResources;ge.reloadResources;ge.use;ge.changeLanguage;ge.getFixedT;ge.t;ge.exists;ge.setDefaultNamespace;ge.hasLoadedNamespace;ge.loadNamespaces;ge.loadLanguages;const{slice:gf,forEach:yf}=[];function wf(t){return yf.call(gf.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function xf(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 mc=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,bf=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(!mc.test(s.domain))throw new TypeError("option domain is invalid");i+=`; Domain=${s.domain}`}if(s.path){if(!mc.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},gc={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=bf(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 vf={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return gc.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:s,cookieDomain:r,cookieOptions:i}=e;n&&typeof document<"u"&&gc.create(n,t,s,r,i)}},Sf={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}},Cf={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 Mn=null;const yc=()=>{if(Mn!==null)return Mn;try{if(Mn=typeof window<"u"&&window.localStorage!==null,!Mn)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Mn=!1}return Mn};var jf={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&yc())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&yc()&&window.localStorage.setItem(n,t)}};let $n=null;const wc=()=>{if($n!==null)return $n;try{if($n=typeof window<"u"&&window.sessionStorage!==null,!$n)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{$n=!1}return $n};var kf={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&wc())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&wc()&&window.sessionStorage.setItem(n,t)}},Ef={name:"navigator",lookup(t){const e=[];if(typeof navigator<"u"){const{languages:n,userLanguage:s,language:r}=navigator;if(n)for(let i=0;i<n.length;i++)e.push(n[i]);s&&e.push(s),r&&e.push(r)}return e.length>0?e:void 0}},Df={name:"htmlTag",lookup(t){let{htmlTag:e}=t,n;const s=e||(typeof document<"u"?document.documentElement:null);return s&&typeof s.getAttribute=="function"&&(n=s.getAttribute("lang")),n}},Nf={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}},Tf={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 kl=!1;try{document.cookie,kl=!0}catch{}const El=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];kl||El.splice(1,1);const Of=()=>({order:El,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class Dl{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=wf(n,this.options||{},Of()),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(vf),this.addDetector(Sf),this.addDetector(jf),this.addDetector(kf),this.addDetector(Ef),this.addDetector(Df),this.addDetector(Nf),this.addDetector(Tf),this.addDetector(Cf)}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&&!xf(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)}))}}Dl.type="languageDetector";const Pf={cancel:"Cancel",create:"Create",add:"Add",remove:"Remove",delete:"Delete",close:"Close",user:"User",permission:"Permission",readOnly:"Read only",readWrite:"Read & write",settings:"Settings",comments:"Comments",files:"Files",outline:"Outline",loading:"Loading…",enabled:"Enabled",disabled:"Disabled",normal:"Active",admin:"Administrator",language:"Language",languageEnglish:"English",languageChinese:"中文"},_f={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"},Rf={title:"Projects",subtitle:"Create, edit and share LaTeX documents",restricted:"You can access projects shared with you. Project creation requires administrator permission.",new:"New project",newDescription:"The project will use the configured default LaTeX engine.",name:"Project name",emptyTitle:"Let’s build something great",emptyDescription:"Create a project or upload an existing LaTeX archive to get started.",emptyRestricted:"Projects shared with you will appear here.",noMatches:"No projects match the current search or tag filter.",upload:"Upload project",uploadDescription:"Upload a ZIP archive. A single top-level folder is removed automatically. Maximum file size: {{size}} MB.",zipFile:"ZIP archive",import:"Import project",importing:"Importing…",search:"Search projects…",grid:"Grid",list:"List",scope:"Project status",active:"Active",archived:"Archived",archive:"Archive",unarchive:"Restore",noArchived:"No archived projects.",allTags:"All tags",sortBy:"Sort",sortModified:"Last modified",sortCreated:"Created",pagination:"Project pages",pageOf:"Page {{page}} of {{totalPages}} · {{count}} projects",previousPage:"Previous",nextPage:"Next",owner:"Owner",created:"Created",modified:"Last modified",modifiedBy:"Modified by",byUser:"By {{user}}",modifiedByUser:"{{time}} · By {{user}}",deletedUser:"Deleted user",filterTags:"Filter by tag",rename:"Rename",renameTitle:"Rename project",duplicate:"Duplicate",duplicating:"Duplicating…",duplicateTitle:"Duplicate project",duplicateDescription:"Create an independent copy of {{project}}. Files and project settings are copied; members, comments, Git history and compile output are not.",transfer:"Transfer",transferOwnership:"Transfer ownership",transferDescription:"Choose a new owner for {{project}}.",newOwner:"New owner",chooseNewOwner:"Choose a user",noTransferUsers:"No other active users",transferWarning:"You will keep read/write access. Source files, history, comments and members remain; the saved GitHub token is removed so the new owner can add their own credential.",transferForbidden:"Only the current project owner can transfer ownership.",transferTargetInvalid:"Choose a new project owner.",transferSelf:"You already own this project.",download:"Download",deleteTitle:"Delete project",deleteDescription:"Permanently delete {{project}} and all of its files? This cannot be undone.",chooseZip:"Choose a ZIP project",dropZip:"Drag and drop a ZIP archive here",browse:"Browse files",selectedFileSize:"Selected · {{size}}",clearFile:"Clear selected file"},Lf={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"},Af={saved:"Saved",savedAt:"Saved to server at {{time}}",loading:"Loading",pending:"Waiting to save",saving:"Saving to server",saveFailed:"Save failed",offlineDraft:"Offline · local draft retained",compile:"Compile · {{engine}}",compiling:"Compiling…",compileQueued:"Compile queued…",compileFailedRetained:"Compilation failed; showing the last successful PDF from {{time}}.",compileFailedNoPdf:"Compilation failed and no successful PDF is available.",upToDate:"Files are up to date; no compilation was needed.",addComment:"Add comment",sourceComments:"Source comments",projectSettings:"Project settings",uploadAttachment:"Upload attachment",newFile:"New text file",binary:"The binary attachment is stored but cannot be opened in the text editor.",noOutline:"No sections in this file",preview:"PDF preview",previewHint:"Compile to generate the document",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 {{name}}",moveDescription:"Choose a destination folder. Files, comments and project paths stay linked.",deletePath:"Delete file or folder",deletePathTitle:"Delete {{name}}",deletePathDescription:"Delete {{path}}? This cannot be undone.",deletePathActiveDescription:"Delete {{path}}? It is currently open for {{users}} and will close in those sessions.",deletePathWillClose:"Any late edits to this path will be rejected to prevent silent data loss.",fileDeletedByCollaborator:"{{path}} was deleted in another session. A safe fallback file has been opened.",destinationFolder:"Destination folder",compileShortcut:"Save and compile (Ctrl+S / Cmd+S)",compilingBy:"{{name}} is compiling",formatSelection:"Format selection",formatting:"Formatting…",formatSelectionHint:"Select LaTeX source to format",formatSelectionRequired:"Select LaTeX source before formatting.",formatSelectionComplete:"Selected LaTeX source formatted.",formatFailedContinue:"Formatting failed; compilation will continue: {{message}}",formatFailed:"Unable to format the selection: {{message}}",formatSourceChanged:"The source changed during formatting, so formatting was skipped.",formatSelectionChanged:"The selected source changed during formatting. Select it again and retry.",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",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"}},Ff={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."},If={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"}},Mf={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",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"},$f={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"},Uf={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"}}},zf={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"},Bf={generic:"Operation failed",request:"Request failed ({{status}})",upload:"Upload failed",fileExists:"A file or folder with this name already exists.",pathConflict:"The destination path is already used by a folder or file.",duplicateUploadNames:"The selected files contain duplicate names: {{files}}.",fileTooLarge:"The file exceeds the {{size}} MB limit.",zipOnly:"Please choose a ZIP archive.",collaborationUnavailable:"Live collaboration is not connected. Reconnect before saving or compiling.",codes:{AUTH_INVALID:"The username or password is incorrect.",CURRENT_PASSWORD_INVALID:"The current password is incorrect.",USER_NOT_FOUND:"The user no longer exists.",LAST_ADMIN:"At least one administrator must remain active.",SELF_DELETE_FORBIDDEN:"You cannot delete the currently signed-in administrator.",PROJECT_CREATE_FORBIDDEN:"You do not have permission to create projects.",PROJECT_NOT_FOUND:"The project does not exist or is no longer accessible.",PROJECT_OWNER_ONLY:"Only the project owner can change this setting.",PROJECT_EDIT_FORBIDDEN:"You do not have edit permission for this project.",DICTIONARY_EDIT_FORBIDDEN:"You do not have permission to maintain this project's dictionary.",TAG_NOT_FOUND:"The selected tag does not exist.",GIT_TOKEN_INVALID:"Enter a GitHub token.",GIT_REPOSITORY_NAME_INVALID:"Enter a GitHub repository name.",GIT_REVISION_INVALID:"Choose a Git revision to check out.",PROJECT_DELETE_FORBIDDEN:"Only the project owner can delete this project.",MEMBERS_MANAGE_FORBIDDEN:"Only the project owner can manage project members.",OWNER_MEMBER_FORBIDDEN:"The project owner cannot be added as a member.",INVALID_PATH:"The file path is invalid.",RESERVED_PATH:"This path is reserved by TexLite.",PATH_EXISTS:"The destination path is already used by a file or folder.",FILE_EXISTS:"A file with this name already exists.",PATH_NOT_FOUND:"The file or folder does not exist.",FILE_NOT_FOUND:"The file does not exist.",DIRECTORY_NOT_FOUND:"The destination folder does not exist.",MOVE_INTO_SELF:"A folder cannot be moved into itself.",MAIN_FILE_DELETE_FORBIDDEN:"The main document cannot be deleted.",FILE_TOO_LARGE:"This file is too large to open or upload.",UPLOAD_EMPTY:"No file was selected for upload.",COMMENT_FILE_NOT_FOUND:"The file for this comment does not exist.",COMMENT_RANGE_INVALID:"The comment source range is invalid.",COMMENT_NOT_FOUND:"The comment does not exist.",COMMENT_EDIT_FORBIDDEN:"You can only edit your own comments.",COMMENT_DELETE_FORBIDDEN:"You can only delete your own comments.",REPLY_NOT_FOUND:"The reply does not exist.",REPLY_EDIT_FORBIDDEN:"You can only edit your own replies.",REPLY_DELETE_FORBIDDEN:"You can only delete your own replies.",COMMENT_UPDATE_EMPTY:"There is no comment content to update.",MAIN_FILE_NOT_FOUND:"The selected main document does not exist.",LATEXMKRC_DISABLED:"Project latexmkrc files are disabled by the administrator.",LATEXMKRC_NOT_FOUND:"The selected latexmkrc file does not exist.",COMPILE_ARTIFACTS_NOT_FOUND:"No compiled artifacts are available yet.",COMPILE_ARTIFACT_NOT_FOUND:"The compiled artifact does not exist.",ARTIFACT_PREVIEW_UNSUPPORTED:"This artifact cannot be previewed as text; download it instead.",SYNC_SOURCE_INVALID:"The source location is invalid.",SOURCE_FILE_NOT_FOUND:"The source file does not exist.",SYNCTEX_NOT_AVAILABLE:"No SyncTeX data is available. Compile the project again.",SYNC_PDF_INVALID:"The PDF location is invalid.",SYNCTEX_EXTERNAL_PATH:"SyncTeX returned a source path outside the project.",COMPILE_FORBIDDEN:"You do not have permission to compile this project.",PDF_NOT_FOUND:"No PDF has been generated yet.",API_NOT_FOUND:"The API endpoint does not exist.",SERVER_ERROR:"The server could not complete the request.",REQUEST_INVALID:"The request is invalid."}},Vf={historyVersionNotFound:"The selected history version no longer exists.",historyFileNotFound:"This file does not exist in the selected history version.",historyPreviewUnsupported:"This historical file cannot be compared as text.",searchInvalid:"Enter valid text to search for.",gitUnavailable:"Git integration is unavailable. Install Git on the host or correct git.binary in the configuration, then try again.",formatterUnavailable:"tex-fmt is not installed on the host. Install it from https://github.com/wgunderwood/tex-fmt and restart TexLite.",formatFailed:"tex-fmt could not format this source.",mainDocumentInvalid:"The selected file is not a valid LaTeX root document."},Hf={copyright:"© {{year}}",credit:"Designed and developed by CHEN Zhongpu"},qf={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"},Wf={common:Pf,auth:_f,projects:Rf,users:Lf,editor:Af,navigation:Ff,history:If,projectSettings:Mf,git:$f,metrics:Uf,tags:zf,errors:Bf,apiErrors:Vf,footer:Hf,completions:qf},Kf={cancel:"取消",create:"创建",add:"添加",remove:"移除",delete:"删除",close:"关闭",user:"用户",permission:"权限",readOnly:"只读",readWrite:"读写",settings:"设置",comments:"批注",files:"文件",outline:"大纲",loading:"正在载入…",enabled:"允许",disabled:"禁止",normal:"正常",admin:"管理员",language:"语言",languageEnglish:"English",languageChinese:"中文"},Gf={tagline:"轻量 LaTeX 写作环境",username:"用户名",password:"密码",login:"登录",contact:"需要账号?请联系 {{email}}",firstLogin:"首次登录,请修改初始密码",currentPassword:"当前密码",newPassword:"新密码",confirmPassword:"确认新密码",updatePassword:"更新密码",mismatch:"两次输入的新密码不一致",passwordMinimum:"至少 {{count}} 位",sessionExpired:"登录状态已过期,请重新登录。",logout:"退出"},Jf={title:"项目",subtitle:"创建、编辑和分享 LaTeX 文档",restricted:"你可以访问别人共享给你的项目;创建权限由管理员授予",new:"新建项目",newDescription:"项目会使用配置文件中的默认 LaTeX 引擎。",name:"项目名称",emptyTitle:"一起创造出色的作品",emptyDescription:"创建新项目,或上传已有的 LaTeX 压缩包开始写作。",emptyRestricted:"共享给你的项目会显示在这里。",noMatches:"没有符合当前搜索或标签筛选条件的项目。",upload:"上传项目",uploadDescription:"上传 ZIP 压缩包;若只有一个顶层目录会自动去除。单文件最大 {{size}} MB。",zipFile:"ZIP 压缩包",import:"导入项目",importing:"正在导入…",search:"搜索项目…",grid:"网格",list:"列表",allTags:"全部标签",sortBy:"排序",sortModified:"最后修改时间",sortCreated:"创建时间",scope:"项目状态",active:"活跃项目",archived:"已归档",archive:"归档",unarchive:"取消归档",noArchived:"还没有归档项目。",pagination:"项目分页",pageOf:"第 {{page}} / {{totalPages}} 页 · 共 {{count}} 个项目",previousPage:"上一页",nextPage:"下一页",owner:"所有者",created:"创建时间",modified:"最后修改",modifiedBy:"最后修改人",byUser:"由 {{user}} 修改",modifiedByUser:"{{time}} · 由 {{user}} 修改",deletedUser:"已删除用户",filterTags:"按标签过滤",rename:"重命名",renameTitle:"重命名项目",duplicate:"复制项目",duplicating:"正在复制…",duplicateTitle:"复制项目",duplicateDescription:"创建“{{project}}”的独立副本。会复制文件和项目设置,但不会复制成员、批注、Git 历史和编译产物。",download:"下载",transfer:"转让",transferOwnership:"转让项目",transferDescription:"为“{{project}}”选择新的所有者。",newOwner:"新所有者",chooseNewOwner:"请选择用户",noTransferUsers:"没有其他可用用户",transferWarning:"转让后你仍保留读写权限。源码、历史、批注和成员不会改变;已保存的 GitHub token 会被移除,由新所有者配置自己的凭据。",transferForbidden:"只有当前项目所有者可以转让项目。",transferTargetInvalid:"请选择新的项目所有者。",transferSelf:"你已经是该项目的所有者。",deleteTitle:"删除项目",deleteDescription:"确定永久删除“{{project}}”及其全部文件吗?此操作不可撤销。",chooseZip:"选择 ZIP 项目",dropZip:"将 ZIP 压缩包拖放到这里",browse:"浏览文件",selectedFileSize:"已选择 · {{size}}",clearFile:"清除已选文件"},Yf={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:"永久删除项目及全部文件"},Xf={saved:"已保存",savedAt:"已于 {{time}} 保存到服务器",loading:"载入中",pending:"等待保存",saving:"正在保存到服务器",saveFailed:"保存失败",offlineDraft:"离线 · 本地草稿已保留",compile:"编译 · {{engine}}",compiling:"编译中…",compileQueued:"编译已排队…",compileFailedRetained:"编译失败,当前显示上一次成功生成的 PDF({{time}})。",compileFailedNoPdf:"编译失败,且没有可用的成功 PDF。",upToDate:"文件已是最新,无需重新编译。",addComment:"添加批注",sourceComments:"源码批注",projectSettings:"项目设置",uploadAttachment:"上传附件",newFile:"新建文本文件",binary:"二进制附件已保存,但不能在文本编辑器中打开。",noOutline:"当前文件没有章节",preview:"PDF 预览",previewHint:"点击“编译”生成文档",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:"选择目标文件夹;源码、批注和项目路径会保持关联。",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 中显示当前源码光标位置",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:"正则表达式无效"}},Zf={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}} 项。"},Qf={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:"安全检查点"}},ep={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 文档",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:"宽松"},tp={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:"确认撤销"},np={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:"生成补全索引"}}},sp={title:"标签",add:"添加标签",create:"新建标签",createDescription:"创建仅自己可见的可复用彩色标签,用于整理项目。",assign:"标签",assignTitle:"“{{project}}”的标签",assignDescription:"勾选你为此项目设置的私有标签;其他用户拥有各自的标签。",empty:"请先创建标签。",allAssigned:"所有可用标签均已添加。",name:"标签名称",color:"颜色",filter:"筛选",red:"红色",orange:"橙色",yellow:"黄色",green:"绿色",blue:"蓝色",purple:"紫色",gray:"灰色"},rp={generic:"操作失败",request:"请求失败({{status}})",upload:"上传失败",fileExists:"同名文件或文件夹已经存在。",pathConflict:"目标路径已经被文件或文件夹占用。",duplicateUploadNames:"所选文件中存在重复名称:{{files}}。",fileTooLarge:"文件超过 {{size}} MB 限制。",zipOnly:"请选择 ZIP 压缩包。",collaborationUnavailable:"实时协作尚未连接,请在重新连接后保存或编译。",codes:{AUTH_INVALID:"用户名或密码错误。",CURRENT_PASSWORD_INVALID:"当前密码错误。",USER_NOT_FOUND:"用户不存在或已被删除。",LAST_ADMIN:"系统必须保留至少一名可用管理员。",SELF_DELETE_FORBIDDEN:"不能删除当前登录的管理员。",PROJECT_CREATE_FORBIDDEN:"管理员尚未授予你创建项目的权限。",PROJECT_NOT_FOUND:"项目不存在或你已无法访问。",PROJECT_OWNER_ONLY:"只有项目所有者可以修改此设置。",PROJECT_EDIT_FORBIDDEN:"你没有此项目的编辑权限。",DICTIONARY_EDIT_FORBIDDEN:"你没有维护本项目词典的权限。",TAG_NOT_FOUND:"所选标签不存在。",GIT_TOKEN_INVALID:"请输入 GitHub token。",GIT_REPOSITORY_NAME_INVALID:"请输入 GitHub 仓库名称。",GIT_REVISION_INVALID:"请选择要 checkout 的 Git 版本。",PROJECT_DELETE_FORBIDDEN:"只有项目所有者可以删除项目。",MEMBERS_MANAGE_FORBIDDEN:"只有项目所有者可以管理项目成员。",OWNER_MEMBER_FORBIDDEN:"项目所有者不能作为成员添加。",INVALID_PATH:"文件路径无效。",RESERVED_PATH:"此路径由 TexLite 保留。",PATH_EXISTS:"目标路径已被文件或文件夹占用。",FILE_EXISTS:"同名文件已经存在。",PATH_NOT_FOUND:"文件或文件夹不存在。",FILE_NOT_FOUND:"文件不存在。",DIRECTORY_NOT_FOUND:"目标文件夹不存在。",MOVE_INTO_SELF:"不能把文件夹移动到自身内部。",MAIN_FILE_DELETE_FORBIDDEN:"不能删除主文档。",FILE_TOO_LARGE:"文件过大,无法打开或上传。",UPLOAD_EMPTY:"没有选择要上传的文件。",COMMENT_FILE_NOT_FOUND:"批注对应的文件不存在。",COMMENT_RANGE_INVALID:"批注的源码区间无效。",COMMENT_NOT_FOUND:"批注不存在。",COMMENT_EDIT_FORBIDDEN:"只能编辑自己的批注。",COMMENT_DELETE_FORBIDDEN:"只能删除自己的批注。",REPLY_NOT_FOUND:"回复不存在。",REPLY_EDIT_FORBIDDEN:"只能编辑自己的回复。",REPLY_DELETE_FORBIDDEN:"只能删除自己的回复。",COMMENT_UPDATE_EMPTY:"没有可更新的批注内容。",MAIN_FILE_NOT_FOUND:"所选主文档不存在。",LATEXMKRC_DISABLED:"管理员已禁用项目级 latexmkrc。",LATEXMKRC_NOT_FOUND:"所选 latexmkrc 文件不存在。",COMPILE_ARTIFACTS_NOT_FOUND:"尚无可用的编译产物。",COMPILE_ARTIFACT_NOT_FOUND:"编译产物不存在。",ARTIFACT_PREVIEW_UNSUPPORTED:"该产物不能作为文本预览,请下载后查看。",SYNC_SOURCE_INVALID:"源码位置无效。",SOURCE_FILE_NOT_FOUND:"源码文件不存在。",SYNCTEX_NOT_AVAILABLE:"尚无可用的 SyncTeX 数据,请重新编译。",SYNC_PDF_INVALID:"PDF 位置无效。",SYNCTEX_EXTERNAL_PATH:"SyncTeX 返回了项目外部的源码路径。",COMPILE_FORBIDDEN:"你没有编译此项目的权限。",PDF_NOT_FOUND:"尚未生成 PDF。",API_NOT_FOUND:"接口不存在。",SERVER_ERROR:"服务器无法完成请求。",REQUEST_INVALID:"请求格式无效。"}},ip={historyVersionNotFound:"所选历史版本已不存在。",historyFileNotFound:"所选历史版本中没有这个文件。",historyPreviewUnsupported:"这个历史文件不能作为文本比较。",searchInvalid:"请输入有效的搜索内容。",gitUnavailable:"Git 集成功能不可用。请在宿主机安装 Git,或修正配置中的 git.binary 后重试。",formatterUnavailable:"宿主机未安装 tex-fmt。请访问 https://github.com/wgunderwood/tex-fmt 安装后重启 TexLite。",formatFailed:"tex-fmt 无法格式化这段源码。",mainDocumentInvalid:"所选文件不是有效的 LaTeX 主文档。"},op={copyright:"© {{year}}",credit:"Designed and developed by CHEN Zhongpu"},ap={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:Kf,auth:Gf,projects:Jf,users:Yf,editor:Xf,navigation:Zf,history:Qf,projectSettings:ep,git:tp,metrics:np,tags:sp,errors:rp,apiErrors:ip,footer:op,completions:ap};ge.use(Dl).use(Uh).init({resources:{en:{translation:Wf},zh:{translation:cp}},fallbackLng:"en",supportedLngs:["en","zh"],nonExplicitSupportedLngs:!0,interpolation:{escapeValue:!1},detection:{order:["localStorage","navigator"],caches:["localStorage"]}});class $o extends Error{constructor(e,n,s=null){super(e),this.status=n,this.code=s}status;code}async function L(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 $o(Uo(r,n.status),n.status,Nl(r));return r}function Uo(t,e,n="errors.request"){const s=typeof t=="object"&&t!==null&&"error"in t&&typeof t.error=="string"?t.error:"",r=Nl(t);if(r){const i={AUTH_REQUIRED:"auth.sessionExpired",ADMIN_REQUIRED:"users.adminRequired",HISTORY_VERSION_NOT_FOUND:"apiErrors.historyVersionNotFound",HISTORY_FILE_NOT_FOUND:"apiErrors.historyFileNotFound",HISTORY_FILE_PREVIEW_UNSUPPORTED:"apiErrors.historyPreviewUnsupported",SEARCH_QUERY_INVALID:"apiErrors.searchInvalid",GIT_UNAVAILABLE:"apiErrors.gitUnavailable",FORMATTER_UNAVAILABLE:"apiErrors.formatterUnavailable",FORMAT_FAILED:"apiErrors.formatFailed",PROJECT_TRANSFER_FORBIDDEN:"projects.transferForbidden",PROJECT_TRANSFER_TARGET_INVALID:"projects.transferTargetInvalid",PROJECT_TRANSFER_SELF:"projects.transferSelf",MAIN_DOCUMENT_INVALID:"apiErrors.mainDocumentInvalid",COMPILE_CLEAN_BUSY:"editor.cleanBusy"}[r]??`errors.codes.${r}`;if(ge.exists(i))return ge.t(i,{status:e,...typeof t=="object"&&t!==null?t:{}})}return ge.resolvedLanguage?.startsWith("zh")&&s?s:ge.t(n,{status:e})}function Nl(t){return typeof t!="object"||t===null||!("code"in t)||typeof t.code!="string"?null:t.code}var lp=Object.defineProperty,gs=(t,e)=>lp(t,"name",{value:e,configurable:!0}),Tl=!!(typeof window<"u"&&window.document&&window.document.createElement);function cn(t,e,{checkForDefaultPrevented:n=!0}={}){return gs(function(r){if(t?.(r),n===!1||!r||!r.defaultPrevented)return e?.(r)},"handleEvent")}gs(cn,"composeEventHandlers");function dp(t){if(!Tl)throw new Error("Cannot access window outside of the DOM");return t?.ownerDocument?.defaultView??window}gs(dp,"getOwnerWindow");function uo(t){if(!Tl)throw new Error("Cannot access document outside of the DOM");return t?.ownerDocument??document}gs(uo,"getOwnerDocument");function Ol(t,e=!1){const{activeElement:n}=uo(t);if(!n?.nodeName)return null;if(Pl(n)&&n.contentDocument)return Ol(n.contentDocument.body,e);if(e){const s=n.getAttribute("aria-activedescendant");if(s){const r=uo(n).getElementById(s);if(r)return r}}return n}gs(Ol,"getActiveElement");function Pl(t){return t.tagName==="IFRAME"}gs(Pl,"isFrame");var up=Object.defineProperty,zo=(t,e)=>up(t,"name",{value:e,configurable:!0});function ho(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}zo(ho,"setRef");function _l(...t){return e=>{let n=!1;const s=t.map(r=>{const i=ho(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():ho(t[r],null)}}}}zo(_l,"composeRefs");function ys(...t){return h.useCallback(_l(...t),t)}zo(ys,"useComposedRefs");var hp=Object.defineProperty,yt=(t,e)=>hp(t,"name",{value:e,configurable:!0});function fp(t,e){const n=h.createContext(e);n.displayName=t+"Context";const s=yt(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 yt(r,"useContext"),[s,r]}yt(fp,"createContext");function Rl(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=yt(u=>{const{scope:p,children:m,...g}=u,x=p?.[t]?.[l]||c,b=h.useMemo(()=>g,Object.values(g));return o.jsx(x.Provider,{value:b,children:m})},"Provider");d.displayName=i+"Provider";function f(u,p,m={}){const{optional:g=!1}=m,x=p?.[t]?.[l]||c,b=h.useContext(x);if(b)return b;if(a!==void 0)return a;if(!g)throw new Error(`\`${u}\` must be used within \`${i}\``)}return yt(f,"useContext"),[d,f]}yt(s,"createContext");const r=yt(()=>{const i=n.map(a=>h.createContext(a));return yt(function(c){const l=c?.[t]||i;return h.useMemo(()=>({[`__scope${t}`]:{...c,[t]:l}}),[c,l])},"useScope")},"createScope");return r.scopeName=t,[s,Ll(r,...e)]}yt(Rl,"createContextScope");function Ll(...t){const e=t[0];if(t.length===1)return e;const n=yt(()=>{const s=t.map(r=>({useScope:r(),scopeName:r.scopeName}));return yt(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}yt(Ll,"composeContextScopes");var ln=globalThis?.document?h.useLayoutEffect:()=>{},pp=Object.defineProperty,mp=(t,e)=>pp(t,"name",{value:e,configurable:!0}),gp=er[" useId ".trim().toString()]||(()=>{}),yp=0;function Ar(t){const[e,n]=h.useState(gp());return ln(()=>{t||n(s=>s??String(yp++))},[t]),t||(e?`radix-${e}`:"")}mp(Ar,"useId");var wp=Object.defineProperty,xp=(t,e)=>wp(t,"name",{value:e,configurable:!0}),xc=er[" useEffectEvent ".trim().toString()],bc=er[" useInsertionEffect ".trim().toString()];function Al(t){if(typeof xc=="function")return xc(t);const e=h.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof bc=="function"?bc(()=>{e.current=t}):ln(()=>{e.current=t}),h.useMemo(()=>((...n)=>e.current?.(...n)),[])}xp(Al,"useEffectEvent");var bp=Object.defineProperty,tr=(t,e)=>bp(t,"name",{value:e,configurable:!0}),vp=er[" useInsertionEffect ".trim().toString()]||ln;function Fl({prop:t,defaultProp:e,onChange:n=tr(()=>{},"onChange"),caller:s}){const[r,i,a]=Il({defaultProp:e,onChange:n}),c=t!==void 0,l=c?t:r,d=h.useCallback(f=>{if(c){const u=Ml(f)?f(t):f;u!==t&&a.current?.(u)}else i(f)},[c,t,i,a]);return[l,d]}tr(Fl,"useControllableState");function Il({defaultProp:t,onChange:e}){const[n,s]=h.useState(t),r=h.useRef(n),i=h.useRef(e);return vp(()=>{i.current=e},[e]),h.useEffect(()=>{r.current!==n&&(i.current?.(n),r.current=n)},[n,r]),[n,s,i]}tr(Il,"useUncontrolledState");function Ml(t){return typeof t=="function"}tr(Ml,"isFunction");var vc=Symbol("RADIX:SYNC_STATE");function Sp(t,e,n,s){const{prop:r,defaultProp:i,onChange:a,caller:c}=e,l=r!==void 0,d=Al(a),f=[{...n,state:i}];s&&f.push(s);const[u,p]=h.useReducer((b,S)=>{if(S.type===vc)return{...b,state:S.state};const k=t(b,S);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 x=h.useMemo(()=>r!==void 0?{...u,state:r}:u,[u,r]);return h.useEffect(()=>{l&&!Object.is(r,u.state)&&p({type:vc,state:r})},[r,u.state,l]),[x,p]}tr(Sp,"useControllableStateReducer");var Cp=Object.defineProperty,Ot=(t,e)=>Cp(t,"name",{value:e,configurable:!0});function Bo(t){const e=h.forwardRef((n,s)=>{let{children:r,...i}=n,a=null,c=!1;const l=[];fo(r)&&typeof Dr=="function"&&(r=Dr(r._payload)),h.Children.forEach(r,p=>{if(Bl(p)){c=!0;const m=p;let g="child"in m.props?m.props.child:m.props.children;fo(g)&&typeof Dr=="function"&&(g=Dr(g._payload)),a=kp(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?zl(a):void 0,f=ys(s,d);if(!a){if(r||r===0)throw new Error(c?Np(t):Dp(t));return r}const u=Ul(i,a.props??{});return a.type!==h.Fragment&&(u.ref=s?f:d),h.cloneElement(a,u)});return e.displayName=`${t}.Slot`,e}Ot(Bo,"createSlot");var $l=Symbol.for("radix.slottable");function jp(t){const e=Ot(n=>"child"in n?n.children(n.child):n.children,"Slottable");return e.displayName=`${t}.Slottable`,e.__radixId=$l,e}Ot(jp,"createSlottable");var kp=Ot((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 Ul(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}}Ot(Ul,"mergeProps");function zl(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)}Ot(zl,"getElementRef");function Bl(t){return h.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===$l}Ot(Bl,"isSlottable");var Ep=Symbol.for("react.lazy");function fo(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===Ep&&"_payload"in t&&Vl(t._payload)}Ot(fo,"isLazyComponent");function Vl(t){return typeof t=="object"&&t!==null&&"then"in t}Ot(Vl,"isPromiseLike");var Dp=Ot(t=>`${t} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),Np=Ot(t=>`${t} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),Dr=er[" use ".trim().toString()],Tp=Object.defineProperty,Op=(t,e)=>Tp(t,"name",{value:e,configurable:!0}),Pp=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Cn=Pp.reduce((t,e)=>{const n=Bo(`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 Hl(t,e){t&&bl.flushSync(()=>t.dispatchEvent(e))}Op(Hl,"dispatchDiscreteCustomEvent");var _p=Object.defineProperty,Rp=(t,e)=>_p(t,"name",{value:e,configurable:!0});function rs(t){const e=h.useRef(t);return h.useEffect(()=>{e.current=t}),h.useMemo(()=>((...n)=>e.current?.(...n)),[])}Rp(rs,"useCallbackRef");var Lp=Object.defineProperty,Ie=(t,e)=>Lp(t,"name",{value:e,configurable:!0}),po="dismissableLayer.update",Ap="dismissableLayer.pointerDownOutside",Fp="dismissableLayer.focusOutside",Sc,ql=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Ip=h.forwardRef(Ie(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(ql),[p,m]=h.useState(null),g=p?.ownerDocument??globalThis?.document,[,x]=h.useState({}),b=ys(n,m),S=Array.from(u.layers),[k]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),T=k?S.indexOf(k):-1,N=p?S.indexOf(p):-1,O=u.layersWithOutsidePointerEventsDisabled.size>0,I=N>=T,D=h.useRef(!1),G=Kl(z=>{a?.(z),l?.(z),z.defaultPrevented||d?.()},{ownerDocument:g,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:D,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:h.useCallback(z=>{if(!(z instanceof Node))return!1;const P=[...u.branches].some(_=>_.contains(z));return I&&!P},[u.branches,I])}),v=Gl(z=>{if(r&&D.current)return;const P=z.target;[...u.branches].some(C=>C.contains(P))||(c?.(z),l?.(z),z.defaultPrevented||d?.())},g),A=p?N===S.length-1:!1,te=rs(z=>{z.key==="Escape"&&(i?.(z),!z.defaultPrevented&&d&&(z.preventDefault(),d()))});return h.useEffect(()=>{if(A)return g.addEventListener("keydown",te,{capture:!0}),()=>g.removeEventListener("keydown",te,{capture:!0})},[g,A,te]),h.useEffect(()=>{if(p)return s&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Sc=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),mo(),()=>{s&&(u.layersWithOutsidePointerEventsDisabled.delete(p),u.layersWithOutsidePointerEventsDisabled.size===0&&(g.body.style.pointerEvents=Sc))}},[p,g,s,u]),h.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),mo())},[p,u]),h.useEffect(()=>{const z=Ie(()=>x({}),"handleUpdate");return document.addEventListener(po,z),()=>document.removeEventListener(po,z)},[]),o.jsx(Cn.div,{...f,ref:b,style:{pointerEvents:O?I?"auto":"none":void 0,...e.style},onFocusCapture:cn(e.onFocusCapture,v.onFocusCapture),onBlurCapture:cn(e.onBlurCapture,v.onBlurCapture),onPointerDownCapture:cn(e.onPointerDownCapture,G.onPointerDownCapture)})},"DismissableLayer"));function Wl(){const t=h.useContext(ql),[e,n]=h.useState(null);return h.useEffect(()=>{if(e)return t.dismissableSurfaces.add(e),()=>{t.dismissableSurfaces.delete(e)}},[e,t.dismissableSurfaces]),n}Ie(Wl,"useDismissableLayerSurface");var Mp=Ie(()=>!0,"IS_TRUE");function Kl(t,e){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:s=!1,isDeferredPointerDownOutsideRef:r,dismissableSurfaces:i,shouldHandlePointerDownOutside:a=Mp}=e,c=rs(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()}Ie(p,"resetOutsideInteraction");function m(){return Array.from(f.current.values()).some(Boolean)}Ie(m,"isOutsideInteractionIntercepted");function g(T){if(!d.current)return;const N=T.target;N instanceof Node&&[...i].some(I=>I.contains(N))||f.current.set(T.type,!0),T.type==="click"&&window.setTimeout(()=>{d.current&&u.current()},0)}Ie(g,"handleInteractionCapture");function x(T){d.current&&f.current.set(T.type,!1)}Ie(x,"handleInteractionBubble");const b=Ie(T=>{if(T.target&&!l.current){let N=function(){n.removeEventListener("click",u.current);const I=m();p(),I||Vo(Ap,c,O,{discrete:!0})};if(Ie(N,"handleAndDispatchPointerDownOutsideEvent"),!a(T.target)){n.removeEventListener("click",u.current),p(),l.current=!1;return}const O={originalEvent:T};d.current=!0,r.current=s&&T.button===0,f.current.clear(),!s||T.button!==0?N():(n.removeEventListener("click",u.current),u.current=N,n.addEventListener("click",u.current,{once:!0}))}else n.removeEventListener("click",u.current),p();l.current=!1},"handlePointerDown"),S=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const T of S)n.addEventListener(T,g,!0),n.addEventListener(T,x);const k=window.setTimeout(()=>{n.addEventListener("pointerdown",b)},0);return()=>{window.clearTimeout(k),n.removeEventListener("pointerdown",b),n.removeEventListener("click",u.current);for(const T of S)n.removeEventListener(T,g,!0),n.removeEventListener(T,x)}},[n,c,s,r,i,a]),{onPointerDownCapture:Ie(()=>l.current=!0,"onPointerDownCapture")}}Ie(Kl,"usePointerDownOutside");function Gl(t,e=globalThis?.document){const n=rs(t),s=h.useRef(!1);return h.useEffect(()=>{const r=Ie(i=>{i.target&&!s.current&&Vo(Fp,n,{originalEvent:i},{discrete:!1})},"handleFocus");return e.addEventListener("focusin",r),()=>e.removeEventListener("focusin",r)},[e,n]),{onFocusCapture:Ie(()=>s.current=!0,"onFocusCapture"),onBlurCapture:Ie(()=>s.current=!1,"onBlurCapture")}}Ie(Gl,"useFocusOutside");function mo(){const t=new CustomEvent(po);document.dispatchEvent(t)}Ie(mo,"dispatchUpdate");function Vo(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?Hl(r,i):r.dispatchEvent(i)}Ie(Vo,"handleAndDispatchCustomEvent");var $p=Object.defineProperty,Qe=(t,e)=>$p(t,"name",{value:e,configurable:!0}),zi="focusScope.autoFocusOnMount",Bi="focusScope.autoFocusOnUnmount",Cc={bubbles:!1,cancelable:!0},Up=h.forwardRef(Qe(function(e,n){const{loop:s=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...c}=e,[l,d]=h.useState(null),f=rs(i),u=rs(a),p=h.useRef(null),m=ys(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:Kt(p.current,{select:!0})},S=function(N){if(g.paused||!l)return;const O=N.relatedTarget;O!==null&&(l.contains(O)||Kt(p.current,{select:!0}))},k=function(N){if(document.activeElement===document.body)for(const I of N)I.removedNodes.length>0&&Kt(l)};Qe(b,"handleFocusIn"),Qe(S,"handleFocusOut"),Qe(k,"handleMutations"),document.addEventListener("focusin",b),document.addEventListener("focusout",S);const T=new MutationObserver(k);return l&&T.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",b),document.removeEventListener("focusout",S),T.disconnect()}}},[r,l,g.paused]),h.useEffect(()=>{if(l){jc.add(g);const b=document.activeElement;if(!l.contains(b)){const k=new CustomEvent(zi,Cc);l.addEventListener(zi,f),l.dispatchEvent(k),k.defaultPrevented||(Jl(ed(Ho(l)),{select:!0}),document.activeElement===b&&Kt(l))}return()=>{l.removeEventListener(zi,f),setTimeout(()=>{const k=new CustomEvent(Bi,Cc);l.addEventListener(Bi,u),l.dispatchEvent(k),k.defaultPrevented||Kt(b??document.body,{select:!0}),l.removeEventListener(Bi,u),jc.remove(g)},0)}}},[l,f,u,g]);const x=h.useCallback(b=>{if(!s&&!r||g.paused)return;const S=b.key==="Tab"&&!b.altKey&&!b.ctrlKey&&!b.metaKey,k=document.activeElement;if(S&&k){const T=b.currentTarget,[N,O]=Yl(T);N&&O?!b.shiftKey&&k===O?(b.preventDefault(),s&&Kt(N,{select:!0})):b.shiftKey&&k===N&&(b.preventDefault(),s&&Kt(O,{select:!0})):k===T&&b.preventDefault()}},[s,r,g.paused]);return o.jsx(Cn.div,{tabIndex:-1,...c,ref:m,onKeyDown:x})},"FocusScope"));function Jl(t,{select:e=!1}={}){const n=document.activeElement;for(const s of t)if(Kt(s,{select:e}),document.activeElement!==n)return}Qe(Jl,"focusFirst");function Yl(t){const e=Ho(t),n=go(e,t),s=go(e.reverse(),t);return[n,s]}Qe(Yl,"getTabbableEdges");function Ho(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:Qe(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}Qe(Ho,"getTabbableCandidates");function go(t,e){const n=typeof e.checkVisibility=="function"&&e.checkVisibility({checkVisibilityCSS:!0});for(const s of t)if(!(n?!s.checkVisibility({checkVisibilityCSS:!0}):Xl(s,{upTo:e})))return s}Qe(go,"findVisible");function Xl(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}Qe(Xl,"isHidden");function Zl(t){return t instanceof HTMLInputElement&&"select"in t}Qe(Zl,"isSelectableInput");function Kt(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&Zl(t)&&e&&t.select()}}Qe(Kt,"focus");var jc=Ql();function Ql(){let t=[];return{add(e){const n=t[0];e!==n&&n?.pause(),t=yo(t,e),t.unshift(e)},remove(e){t=yo(t,e),t[0]?.resume()}}}Qe(Ql,"createFocusScopesStack");function yo(t,e){const n=[...t],s=n.indexOf(e);return s!==-1&&n.splice(s,1),n}Qe(yo,"arrayRemove");function ed(t){return t.filter(e=>e.tagName!=="A")}Qe(ed,"removeLinks");var zp=Object.defineProperty,Bp=(t,e)=>zp(t,"name",{value:e,configurable:!0}),Vp=h.forwardRef(Bp(function(e,n){const{container:s,...r}=e,[i,a]=h.useState(!1);ln(()=>a(!0),[]);const c=s||i&&globalThis?.document?.body;return c?bl.createPortal(o.jsx(Cn.div,{...r,ref:n}),c):null},"Portal")),Hp=Object.defineProperty,Yt=(t,e)=>Hp(t,"name",{value:e,configurable:!0});function td(t,e){return h.useReducer((n,s)=>e[n][s]??n,t)}Yt(td,"useStateMachine");var qo=Yt(t=>{const{present:e,children:n}=t,s=nd(e),r=typeof n=="function"?n({present:s.isPresent}):h.Children.only(n),i=sd(s.ref,rd(r));return typeof n=="function"||s.isPresent?h.cloneElement(r,{ref:i}):null},"Presence");function nd(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]=td(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??Hn(s.current),a.current=void 0):i.current="none"},[l]),ln(()=>{const f=s.current,u=r.current;if(u!==t){const m=i.current,g=Hn(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]),ln(()=>{if(e){let f;const u=e.ownerDocument.defaultView??window,p=Yt(g=>{const b=Hn(s.current).includes(CSS.escape(g.animationName));if(g.target===e&&b&&(d("ANIMATION_END"),!r.current)){const S=e.style.animationFillMode;e.style.animationFillMode="forwards",f=u.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=S)})}},"handleAnimationEnd"),m=Yt(g=>{g.target===e&&(i.current=Hn(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=Hn(u)}else s.current=null;n(f)},[])}}Yt(nd,"usePresence");function wo(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}Yt(wo,"setRef");function sd(...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=wo(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():wo(s[a],null)}}},[])}Yt(sd,"useStableComposedRefs");function Hn(t){return t?.animationName||"none"}Yt(Hn,"getAnimationName");function rd(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}Yt(rd,"getElementRef");var qp=Object.defineProperty,Wo=(t,e)=>qp(t,"name",{value:e,configurable:!0}),Nr=0,Un=null;function Wp(t){return Ko(),t.children}Wo(Wp,"FocusGuards");function Ko(){h.useEffect(()=>{Un||(Un={start:xo(),end:xo()});const{start:t,end:e}=Un;return document.body.firstElementChild!==t&&document.body.insertAdjacentElement("afterbegin",t),document.body.lastElementChild!==e&&document.body.insertAdjacentElement("beforeend",e),Nr++,()=>{Nr===1&&(Un?.start.remove(),Un?.end.remove(),Un=null),Nr=Math.max(0,Nr-1)}},[])}Wo(Ko,"useFocusGuards");function xo(){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}Wo(xo,"createFocusGuard");var Kp=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},zn=new WeakMap,Tr=new WeakMap,Or={},Vi=0,id=function(t){return t&&(t.host||id(t.parentNode))},Gp=function(t,e){return e.map(function(n){if(t.contains(n))return n;var s=id(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})},Jp=function(t,e,n,s){var r=Gp(e,Array.isArray(t)?t:[t]);Or[n]||(Or[n]=new WeakMap);var i=Or[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",x=(zn.get(p)||0)+1,b=(i.get(p)||0)+1;zn.set(p,x),i.set(p,b),a.push(p),x===1&&g&&Tr.set(p,!0),b===1&&p.setAttribute(n,"true"),g||p.setAttribute(s,"true")}catch(S){console.error("aria-hidden: cannot operate on ",p,S)}})};return f(e),c.clear(),Vi++,function(){a.forEach(function(u){var p=zn.get(u)-1,m=i.get(u)-1;zn.set(u,p),i.set(u,m),p||(Tr.has(u)||u.removeAttribute(s),Tr.delete(u)),m||u.removeAttribute(n)}),Vi--,Vi||(zn=new WeakMap,zn=new WeakMap,Tr=new WeakMap,Or={})}},Yp=function(t,e,n){n===void 0&&(n="data-aria-hidden");var s=Array.from(Array.isArray(t)?t:[t]),r=Kp(t);return r?(s.push.apply(s,Array.from(r.querySelectorAll("[aria-live], script"))),Jp(s,r,n,"aria-hidden")):function(){return null}},Xp=Object.defineProperty,bt=(t,e)=>Xp(t,"name",{value:e,configurable:!0}),Go="Dialog",[od,Gb]=Rl(Go),[Zp,Ut]=od(Go),Qp=bt(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]=Fl({prop:s,defaultProp:r??!1,onChange:i,caller:Go}),[u,p]=h.useState(0),[m,g]=h.useState(0);return o.jsx(Zp,{scope:e,triggerRef:c,contentRef:l,contentId:Ar(),titleId:Ar(),descriptionId:Ar(),titlePresent:u>0,descriptionPresent:m>0,setTitleCount:p,setDescriptionCount:g,open:d,onOpenChange:f,onOpenToggle:h.useCallback(()=>f(x=>!x),[f]),modal:a,children:n})},"Dialog"),ad="DialogPortal",[em,cd]=od(ad,{forceMount:void 0}),tm=bt(t=>{const{__scopeDialog:e,forceMount:n,children:s,container:r}=t,i=Ut(ad,e);return o.jsx(em,{scope:e,forceMount:n,children:h.Children.map(s,a=>o.jsx(qo,{present:n||i.open,children:o.jsx(Vp,{asChild:!0,container:r,children:a})}))})},"DialogPortal"),bo="DialogOverlay",nm=h.forwardRef(bt(function(e,n){const s=cd(bo,e.__scopeDialog),{forceMount:r=s.forceMount,...i}=e,a=Ut(bo,e.__scopeDialog);return a.modal?o.jsx(qo,{present:r||a.open,children:o.jsx(rm,{...i,ref:n})}):null},"DialogOverlay")),sm=Bo("DialogOverlay.RemoveScroll"),rm=h.forwardRef(bt(function(e,n){const{__scopeDialog:s,...r}=e,i=Ut(bo,s),a=Wl(),c=ys(n,a);return o.jsx(zh,{as:sm,allowPinchZoom:!0,shards:[i.contentRef],children:o.jsx(Cn.div,{"data-state":Jo(i.open),...r,ref:c,style:{pointerEvents:"auto",...r.style}})})},"DialogOverlayImpl")),zs="DialogContent",im=h.forwardRef(bt(function(e,n){const s=cd(zs,e.__scopeDialog),{forceMount:r=s.forceMount,...i}=e,a=Ut(zs,e.__scopeDialog);return o.jsx(qo,{present:r||a.open,children:a.modal?o.jsx(om,{...i,ref:n}):o.jsx(am,{...i,ref:n})})},"DialogContent")),om=h.forwardRef(bt(function(e,n){const s=Ut(zs,e.__scopeDialog),r=h.useRef(null),i=ys(n,s.contentRef,r);return h.useEffect(()=>{const a=r.current;if(a)return Yp(a)},[]),o.jsx(ld,{...e,ref:i,trapFocus:s.open,disableOutsidePointerEvents:s.open,onCloseAutoFocus:cn(e.onCloseAutoFocus,a=>{a.preventDefault(),s.triggerRef.current?.focus()}),onPointerDownOutside:cn(e.onPointerDownOutside,a=>{const c=a.detail.originalEvent,l=c.button===0&&c.ctrlKey===!0;(c.button===2||l)&&a.preventDefault()}),onFocusOutside:cn(e.onFocusOutside,a=>a.preventDefault())})},"DialogContentModal")),am=h.forwardRef(bt(function(e,n){const s=Ut(zs,e.__scopeDialog),r=h.useRef(!1),i=h.useRef(!1);return o.jsx(ld,{...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")),ld=h.forwardRef(bt(function(e,n){const{__scopeDialog:s,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...c}=e,l=Ut(zs,s);return Ko(),o.jsx(o.Fragment,{children:o.jsx(Up,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:o.jsx(Ip,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionPresent?l.descriptionId:void 0,"aria-labelledby":l.titlePresent?l.titleId:void 0,"data-state":Jo(l.open),...c,ref:n,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1)})})})},"DialogContentImpl")),cm="DialogTitle",lm=h.forwardRef(bt(function(e,n){const{__scopeDialog:s,...r}=e,i=Ut(cm,s),{setTitleCount:a}=i;return ln(()=>(a(c=>c+1),()=>a(c=>c-1)),[a]),o.jsx(Cn.h2,{id:i.titleId,...r,ref:n})},"DialogTitle")),dm="DialogDescription",um=h.forwardRef(bt(function(e,n){const{__scopeDialog:s,...r}=e,i=Ut(dm,s),{setDescriptionCount:a}=i;return ln(()=>(a(c=>c+1),()=>a(c=>c-1)),[a]),o.jsx(Cn.p,{id:i.descriptionId,...r,ref:n})},"DialogDescription")),hm="DialogClose",fm=h.forwardRef(bt(function(e,n){const{__scopeDialog:s,...r}=e,i=Ut(hm,s);return o.jsx(Cn.button,{type:"button",...r,ref:n,onClick:cn(e.onClick,()=>i.onOpenChange(!1))})},"DialogClose"));function Jo(t){return t?"open":"closed"}bt(Jo,"getState");function Me({open:t,title:e,description:n,onOpenChange:s,children:r,footer:i,wide:a,extraWide:c,className:l}){const{t:d}=Oe();return o.jsx(Qp,{open:t,onOpenChange:s,children:o.jsxs(tm,{children:[o.jsx(nm,{className:"dialog-overlay"}),o.jsxs(im,{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(lm,{children:e}),n&&o.jsx(um,{children:n})]}),o.jsx(fm,{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 is({open:t,title:e,description:n,confirmLabel:s,danger:r,onCancel:i,onConfirm:a}){const{t:c}=Oe();return o.jsx(Me,{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 Yo({compact:t=!1}){const{i18n:e,t:n}=Oe(),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 pm=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),dd=(...t)=>t.filter((e,n,s)=>!!e&&e.trim()!==""&&s.indexOf(e)===n).join(" ").trim();var mm={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 gm=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,...mm,width:e,height:e,stroke:t,strokeWidth:s?Number(n)*24/Number(e):n,className:dd("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(gm,{ref:i,iconNode:e,className:dd(`lucide-${pm(t)}`,s),...r}));return n.displayName=`${t}`,n};const ym=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 ud=F("AlignLeft",[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);const wm=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 kc=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 xm=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 hd=F("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const Hi=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 fd=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 bm=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 vm=F("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const pd=F("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const md=F("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);const Xo=F("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Sm=F("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);const Cm=F("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);const jm=F("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const Zo=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 Ec=F("Columns2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]);const km=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 Em=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 Bs=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 vo=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 So=F("FileArchive",[["path",{d:"M10 12v-1",key:"v7bkov"}],["path",{d:"M10 18v-2",key:"1cjy8d"}],["path",{d:"M10 7V6",key:"dljcrl"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 .274 1.01",key:"gkbcor"}],["circle",{cx:"10",cy:"20",r:"2",key:"1xzdoj"}]]);const Dm=F("FilePlus2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]]);const Nm=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 Gn=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 Hr=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 gd=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 Tm=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 Om=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 qi=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 yd=F("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const Pm=F("Keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]);const _m=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 kt=F("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const Rm=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 Lm=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 Dc=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 wd=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 Nc=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 Am=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 Fm=F("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);const Im=F("PanelRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);const Co=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 Mm=F("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const $m=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 Um=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 qr=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 jo=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 zm=F("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);const Bm=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 Fr=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 Vm=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 Hm=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 Tc=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 dn=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 os=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 Oc=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 Wr=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 xd=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 Vs=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 qm=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 Qo=F("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Kr=[{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'}],rn={font:"jetbrains",fontSize:14,lineHeight:1.65,lineWrapping:!0,spellCheck:!0,vimMode:!1,formatOnCompile:!1},Wm="texlite-editor-preferences";function bd(t,e){return`${Wm}:${encodeURIComponent(t)}:${encodeURIComponent(e)}`}function Jb(t){return Kr.find(e=>e.id===t)?.stack??Kr[0].stack}function Pc(t,e){try{const n=JSON.parse(localStorage.getItem(bd(t,e))??"{}");return{font:Kr.some(s=>s.id===n.font)?n.font:rn.font,fontSize:[12,13,14,15,16,18,20].includes(Number(n.fontSize))?Number(n.fontSize):rn.fontSize,lineHeight:[1.45,1.65,1.85].includes(Number(n.lineHeight))?Number(n.lineHeight):rn.lineHeight,lineWrapping:typeof n.lineWrapping=="boolean"?n.lineWrapping:rn.lineWrapping,spellCheck:typeof n.spellCheck=="boolean"?n.spellCheck:rn.spellCheck,vimMode:typeof n.vimMode=="boolean"?n.vimMode:rn.vimMode,formatOnCompile:typeof n.formatOnCompile=="boolean"?n.formatOnCompile:rn.formatOnCompile}}catch{return rn}}function Km(t,e,n){localStorage.setItem(bd(t,e),JSON.stringify(n))}const Gm=/\.(?:tex|bib|cls|sty)$/i;function Wi(t){return Gm.test(t)}function Jm(t){return t.match(/(?:\r?\n)+$/)?.[0]??""}function Ym(t,e){const n=Jm(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 _c(t,e,n=0){if(t===e)return[];const{default:s}=await Zt(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 Xm(t,e=null){const n=Rc(t),r=e==="succeeded"||e===null&&Qm(t)?[]:Lc(n.filter(Ac)),i=Rc(Zm(t));return{warnings:Lc(i.filter(c=>!Ac(c)&&eg(c))),errors:r}}function Rc(t){return t.split(`
7
+ `).map(e=>e.trim()).filter(Boolean)}function Lc(t){return[...new Set(t)]}function Zm(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 Qm(t){return/Latexmk: All targets .* are up-to-date/i.test(t)&&/Output written on .*\.pdf/i.test(t)}function Ac(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 eg(t){return/\bwarnings?\b|overfull|underfull|badness/i.test(t)}const tg=/^\/projects?\/([^/]+)\/?$/;function Ki(t){return`/project/${encodeURIComponent(t)}`}function Pr(t){const e=tg.exec(t);if(!e)return null;try{const n=decodeURIComponent(e[1]);return n&&!n.includes("/")?n:null}catch{return null}}function ng(t){if(!t||typeof t!="object")return!1;const e=t;return e.texliteRoute==="project"&&typeof e.projectId=="string"&&typeof e.fromDashboard=="boolean"}function V(t){return t instanceof Error?t.message:ge.t("errors.generic")}const ot=()=>new Map,ko=t=>{const e=ot();return t.forEach((n,s)=>{e.set(s,n)}),e},zt=(t,e,n)=>{let s=t.get(e);return s===void 0&&t.set(e,s=n()),s},sg=(t,e)=>{const n=[];for(const[s,r]of t)n.push(e(r,s));return n},rg=(t,e)=>{for(const[n,s]of t)if(e(s,n))return!0;return!1},un=()=>new Set,Gi=t=>t[t.length-1],ig=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},Xt=Array.from,ea=(t,e)=>{for(let n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0},ta=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1},og=(t,e)=>{const n=new Array(t);for(let s=0;s<t;s++)n[s]=e(s,n);return n},as=Array.isArray;class na{constructor(){this._observers=ot()}on(e,n){return zt(this._observers,e,un).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 Xt((this._observers.get(e)||ot()).values()).forEach(s=>s(...n))}destroy(){this._observers=ot()}}class vd{constructor(){this._observers=ot()}on(e,n){zt(this._observers,e,un).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 Xt((this._observers.get(e)||ot()).values()).forEach(s=>s(...n))}destroy(){this._observers=ot()}}const Nt=Math.floor,Ir=Math.abs,sa=(t,e)=>t<e?t:e,jn=(t,e)=>t>e?t:e,ag=Math.pow,Sd=t=>t!==0?t<0:1/t<0,Fc=1,Ic=2,Ji=4,Yi=8,Hs=32,Gt=64,dt=128,li=31,Eo=63,xn=127,cg=2147483647,Gr=Number.MAX_SAFE_INTEGER,Mc=Number.MIN_SAFE_INTEGER,lg=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&Nt(t)===t),Cd=String.fromCharCode,dg=t=>t.toLowerCase(),ug=/^\s*/g,hg=t=>t.replace(ug,""),fg=/([A-Z])/g,$c=(t,e)=>hg(t.replace(fg,n=>`${e}${dg(n)}`)),pg=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},qs=typeof TextEncoder<"u"?new TextEncoder:null,mg=t=>qs.encode(t),gg=qs?mg:pg;let $s=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});$s&&$s.decode(new Uint8Array).length===1&&($s=null);const yg=(t,e)=>og(e,()=>t).join("");class nr{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Te=()=>new nr,ra=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},pe=t=>{const e=new Uint8Array(ra(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},wg=(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(jn(n,e)*2),t.cpos=0)},Fe=(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},Do=Fe,$=(t,e)=>{for(;e>xn;)Fe(t,dt|xn&e),e=Nt(e/128);Fe(t,xn&e)},ia=(t,e)=>{const n=Sd(e);for(n&&(e=-e),Fe(t,(e>Eo?dt:0)|(n?Gt:0)|Eo&e),e=Nt(e/64);e>0;)Fe(t,(e>xn?dt:0)|xn&e),e=Nt(e/128)},No=new Uint8Array(3e4),xg=No.length/3,bg=(t,e)=>{if(e.length<xg){const n=qs.encodeInto(e,No).written||0;$(t,n);for(let s=0;s<n;s++)Fe(t,No[s])}else Se(t,gg(e))},vg=(t,e)=>{const n=unescape(encodeURIComponent(e)),s=n.length;$(t,s);for(let r=0;r<s;r++)Fe(t,n.codePointAt(r))},Jt=qs&&qs.encodeInto?bg:vg,di=(t,e)=>{const n=t.cbuf.length,s=t.cpos,r=sa(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(jn(n*2,i)),t.cbuf.set(e.subarray(r)),t.cpos=i)},Se=(t,e)=>{$(t,e.byteLength),di(t,e)},oa=(t,e)=>{wg(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},Sg=(t,e)=>oa(t,4).setFloat32(0,e,!1),Cg=(t,e)=>oa(t,8).setFloat64(0,e,!1),jg=(t,e)=>oa(t,8).setBigInt64(0,e,!1),Uc=new DataView(new ArrayBuffer(4)),kg=t=>(Uc.setFloat32(0,t),Uc.getFloat32(0)===t),Ws=(t,e)=>{switch(typeof e){case"string":Fe(t,119),Jt(t,e);break;case"number":lg(e)&&Ir(e)<=cg?(Fe(t,125),ia(t,e)):kg(e)?(Fe(t,124),Sg(t,e)):(Fe(t,123),Cg(t,e));break;case"bigint":Fe(t,122),jg(t,e);break;case"object":if(e===null)Fe(t,126);else if(as(e)){Fe(t,117),$(t,e.length);for(let n=0;n<e.length;n++)Ws(t,e[n])}else if(e instanceof Uint8Array)Fe(t,116),Se(t,e);else{Fe(t,118);const n=Object.keys(e);$(t,n.length);for(let s=0;s<n.length;s++){const r=n[s];Jt(t,r),Ws(t,e[r])}}break;case"boolean":Fe(t,e?120:121);break;default:Fe(t,127)}};class zc extends nr{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&$(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const Bc=t=>{t.count>0&&(ia(t.encoder,t.count===1?t.s:-t.s),t.count>1&&$(t.encoder,t.count-2))};class Mr{constructor(){this.encoder=new nr,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Bc(this),this.count=1,this.s=e)}toUint8Array(){return Bc(this),pe(this.encoder)}}const Vc=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);ia(t.encoder,e),t.count>1&&$(t.encoder,t.count-2)}};class Xi{constructor(){this.encoder=new nr,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Vc(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Vc(this),pe(this.encoder)}}class Eg{constructor(){this.sarr=[],this.s="",this.lensE=new Mr}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 nr;return this.sarr.push(this.s),this.s="",Jt(e,this.sarr.join("")),di(e,this.lensE.toUint8Array()),pe(e)}}const Tt=t=>new Error(t),Et=()=>{throw Tt("Method unimplemented")},ut=()=>{throw Tt("Unexpected case")},jd=Tt("Unexpected end of array"),kd=Tt("Integer out of Range");class ui{constructor(e){this.arr=e,this.pos=0}}const pn=t=>new ui(t),Dg=t=>t.pos!==t.arr.length,Ng=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},Ge=t=>Ng(t,J(t)),cs=t=>t.arr[t.pos++],J=t=>{let e=0,n=1;const s=t.arr.length;for(;t.pos<s;){const r=t.arr[t.pos++];if(e=e+(r&xn)*n,n*=128,r<dt)return e;if(e>Gr)throw kd}throw jd},aa=t=>{let e=t.arr[t.pos++],n=e&Eo,s=64;const r=(e&Gt)>0?-1:1;if((e&dt)===0)return r*n;const i=t.arr.length;for(;t.pos<i;){if(e=t.arr[t.pos++],n=n+(e&xn)*s,s*=128,e<dt)return r*n;if(n>Gr)throw kd}throw jd},Tg=t=>{let e=J(t);if(e===0)return"";{let n=String.fromCodePoint(cs(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(cs(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))}},Og=t=>$s.decode(Ge(t)),Dt=$s?Og:Tg,ca=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},Pg=t=>ca(t,4).getFloat32(0,!1),_g=t=>ca(t,8).getFloat64(0,!1),Rg=t=>ca(t,8).getBigInt64(0,!1),Lg=[t=>{},t=>null,aa,Pg,_g,Rg,t=>!1,t=>!0,Dt,t=>{const e=J(t),n={};for(let s=0;s<e;s++){const r=Dt(t);n[r]=Ks(t)}return n},t=>{const e=J(t),n=[];for(let s=0;s<e;s++)n.push(Ks(t));return n},Ge],Ks=t=>Lg[127-cs(t)](t);class Hc extends ui{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Dg(this)?this.count=J(this)+1:this.count=-1),this.count--,this.s}}class $r extends ui{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=aa(this);const e=Sd(this.s);this.count=1,e&&(this.s=-this.s,this.count=J(this)+2)}return this.count--,this.s}}class Zi extends ui{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=aa(this),n=e&1;this.diff=Nt(e/2),this.count=1,n&&(this.count=J(this)+2)}return this.s+=this.diff,this.count--,this.s}}class Ag{constructor(e){this.decoder=new $r(e),this.str=Dt(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 Fg=crypto.getRandomValues.bind(crypto),Ed=()=>Fg(new Uint32Array(1))[0],Ig="10000000-1000-4000-8000"+-1e11,Mg=()=>Ig.replace(/[018]/g,t=>(t^Ed()&15>>t/4).toString(16)),hn=Date.now,ls=t=>new Promise(t);Promise.all.bind(Promise);const qc=t=>t===void 0?null:t;class $g{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let Dd=new $g,la=!0;try{typeof localStorage<"u"&&localStorage&&(Dd=localStorage,la=!1)}catch{}const Nd=Dd,Ug=t=>la||addEventListener("storage",t),zg=t=>la||removeEventListener("storage",t),Gs=Symbol("Equality"),Td=(t,e)=>t===e||!!t?.[Gs]?.(e)||!1,Bg=t=>typeof t=="object",Vg=Object.assign,Hg=Object.keys,qg=(t,e)=>{for(const n in t)e(t[n],n)},Wg=(t,e)=>{const n=[];for(const s in t)n.push(e(t[s],s));return n},Jr=t=>Hg(t).length,Kg=t=>{for(const e in t)return!1;return!0},sr=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},da=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Gg=(t,e)=>t===e||Jr(t)===Jr(e)&&sr(t,(n,s)=>(n!==void 0||da(e,s))&&Td(e[s],n)),Jg=Object.freeze,Od=t=>{for(const e in t){const n=t[e];(typeof n=="object"||typeof n=="function")&&Od(t[e])}return Jg(t)},ua=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&ua(t,e,n+1)}},Yg=t=>t,Xn=(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[Gs]!=null)return t[Gs](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)||!Xn(t.get(n),e.get(n)))return!1;break}case void 0:case Object:if(Jr(t)!==Jr(e))return!1;for(const n in t)if(!da(t,n)||!Xn(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(!Xn(t[n],e[n]))return!1;break;default:return!1}return!0},Xg=(t,e)=>e.includes(t);var Pd={};const fn=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",_d=typeof window<"u"&&typeof document<"u"&&!fn;let Ft;const Zg=()=>{if(Ft===void 0)if(fn){Ft=ot();const t=process.argv;let e=null;for(let n=0;n<t.length;n++){const s=t[n];s[0]==="-"?(e!==null&&Ft.set(e,""),e=s):e!==null&&(Ft.set(e,s),e=null)}e!==null&&Ft.set(e,"")}else typeof location=="object"?(Ft=ot(),(location.search||"?").slice(1).split("&").forEach(t=>{if(t.length!==0){const[e,n]=t.split("=");Ft.set(`--${$c(e,"-")}`,n),Ft.set(`-${$c(e,"-")}`,n)}})):Ft=ot();return Ft},To=t=>Zg().has(t),Yr=t=>qc(fn?Pd[t.toUpperCase().replaceAll("-","_")]:Nd.getItem(t)),Rd=t=>To("--"+t)||Yr(t)!==null,Qg=Rd("production"),ey=fn&&Xg(Pd.FORCE_COLOR,["true","1","2"]),ty=ey||!To("--no-colors")&&!Rd("no-color")&&(!fn||process.stdout.isTTY)&&(!fn||To("--color")||Yr("COLORTERM")!==null||(Yr("TERM")||"").includes("color")),Ld=t=>new Uint8Array(t),ny=(t,e,n)=>new Uint8Array(t,e,n),sy=t=>new Uint8Array(t),ry=t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=Cd(t[n]);return btoa(e)},iy=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),oy=t=>{const e=atob(t),n=Ld(e.length);for(let s=0;s<e.length;s++)n[s]=e.charCodeAt(s);return n},ay=t=>{const e=Buffer.from(t,"base64");return ny(e.buffer,e.byteOffset,e.byteLength)},cy=_d?ry:iy,ly=_d?oy:ay,dy=t=>{const e=Ld(t.byteLength);return e.set(t),e};class uy{constructor(e,n){this.left=e,this.right=n}}const Wt=(t,e)=>new uy(t,e),hy=(t,e)=>t.forEach(n=>e(n.left,n.right)),Wc=t=>t.next()>=.5,Qi=(t,e,n)=>Nt(t.next()*(n+1-e)+e),Ad=(t,e,n)=>Nt(t.next()*(n+1-e)+e),ha=(t,e,n)=>Ad(t,e,n),fy=t=>Cd(ha(t,97,122)),py=(t,e=0,n=20)=>{const s=ha(t,e,n);let r="";for(let i=0;i<s;i++)r+=fy(t);return r},eo=(t,e)=>e[ha(t,0,e.length-1)],my=Symbol("0schema");class gy{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(yg(" ",(this._rerrs.length-n)*2)+`${s.path!=null?`[${s.path}] `:""}${s.has} doesn't match ${s.expected}. ${s.message}`)}return e.join(`
8
+ `)}}const Oo=(t,e)=>t===e?!0:t==null||e==null||t.constructor!==e.constructor?!1:t[Gs]?Td(t,e):as(t)?ea(t,n=>ta(e,s=>Oo(n,s))):Bg(t)?sr(t,(n,s)=>Oo(n,e[s])):!1;class et{static _dilutes=!1;extends(e){let[n,s]=[this.shape,e.shape];return this.constructor._dilutes&&([s,n]=[n,s]),Oo(n,s)}equals(e){return this.constructor===e.constructor&&Xn(this.shape,e.shape)}[my](){return!0}[Gs](e){return this.equals(e)}validate(e){return this.check(e)}check(e,n){Et()}get nullable(){return ws(this,gi)}get optional(){return new Md(this)}cast(e){return Kc(e,this),e}expect(e){return Kc(e,this),e}}class fa extends et{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 Pe=(t,e=null)=>new fa(t,e);Pe(fa);class pa extends et{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 Ue=t=>new pa(t);Pe(pa);class hi extends et{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 fi=(...t)=>new hi(t),Fd=Pe(hi),yy=RegExp.escape||(t=>t.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),Id=t=>{if(ds.check(t))return[yy(t)];if(Fd.check(t))return t.shape.map(e=>e+"");if(Kd.check(t))return["[+-]?\\d+.?\\d*"];if(Gd.check(t))return[".*"];if(Xr.check(t))return t.shape.map(Id).flat(1);ut()};class wy extends et{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(Id).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}}Pe(wy);const xy=Symbol("optional");class Md extends et{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[xy](){return!0}}const by=Pe(Md);class vy extends et{check(e,n){return n?.extend(null,"never",typeof e),!1}}Pe(vy);class pi extends et{constructor(e,n=!1){super(),this.shape=e,this._isPartial=n}static _dilutes=!0;get partial(){return new pi(this.shape,!0)}check(e,n){return e==null?(n?.extend(null,"object","null"),!1):sr(this.shape,(s,r)=>{const i=this._isPartial&&!da(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 Sy=t=>new pi(t),Cy=Pe(pi),jy=Ue(t=>t!=null&&(t.constructor===Object||t.constructor==null));class $d extends et{constructor(e,n){super(),this.shape={keys:e,values:n}}check(e,n){return e!=null&&sr(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 Ud=(t,e)=>new $d(t,e),ky=Pe($d);class zd extends et{constructor(e){super(),this.shape=e}check(e,n){return e!=null&&sr(this.shape,(s,r)=>{const i=s.check(e[r],n);return!i&&n?.extend(r.toString(),"Tuple",typeof s),i})}}const Ey=(...t)=>new zd(t);Pe(zd);class Bd extends et{constructor(e){super(),this.shape=e.length===1?e[0]:new ma(e)}check(e,n){const s=as(e)&&ea(e,r=>this.shape.check(r));return!s&&n?.extend(null,"Array",""),s}}const Vd=(...t)=>new Bd(t),Dy=Pe(Bd),Ny=Ue(t=>as(t));class Hd extends et{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 Ty=(t,e=null)=>new Hd(t,e);Pe(Hd);const Oy=Ty(et);class Py extends et{constructor(e){super(),this.len=e.length-1,this.args=Ey(...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 _y=Pe(Py),Ry=Ue(t=>typeof t=="function");class Ly extends et{constructor(e){super(),this.shape=e}check(e,n){const s=ea(this.shape,r=>r.check(e,n));return!s&&n?.extend(null,"Intersectinon",typeof e),s}}Pe(Ly,t=>t.shape.length>0);class ma extends et{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,n){const s=ta(this.shape,r=>r.check(e,n));return n?.extend(null,"Union",typeof e),s}}const ws=(...t)=>t.findIndex(e=>Xr.check(e))>=0?ws(...t.map(e=>Js(e)).map(e=>Xr.check(e)?e.shape:[e]).flat(1)):t.length===1?t[0]:new ma(t),Xr=Pe(ma),qd=()=>!0,Zr=Ue(qd),Ay=Pe(pa,t=>t.shape===qd),ga=Ue(t=>typeof t=="bigint"),Fy=Ue(t=>t===ga),Wd=Ue(t=>typeof t=="symbol");Ue(t=>t===Wd);const Zn=Ue(t=>typeof t=="number"),Kd=Ue(t=>t===Zn),ds=Ue(t=>typeof t=="string"),Gd=Ue(t=>t===ds),mi=Ue(t=>typeof t=="boolean"),Iy=Ue(t=>t===mi),Jd=fi(void 0);Pe(hi,t=>t.shape.length===1&&t.shape[0]===void 0);fi(void 0);const gi=fi(null),My=Pe(hi,t=>t.shape.length===1&&t.shape[0]===null);Pe(Uint8Array);Pe(fa,t=>t.shape===Uint8Array);const $y=ws(Zn,ds,gi,Jd,ga,mi,Wd);(()=>{const t=Vd(Zr),e=Ud(ds,Zr),n=ws(Zn,ds,gi,mi,t,e);return t.shape=n,e.shape.values=n,n})();const Js=t=>{if(Oy.check(t))return t;if(jy.check(t)){const e={};for(const n in t)e[n]=Js(t[n]);return Sy(e)}else{if(Ny.check(t))return ws(...t.map(Js));if($y.check(t))return fi(t);if(Ry.check(t))return Pe(t)}ut()},Kc=Qg?()=>{}:(t,e)=>{const n=new gy;if(!e.check(t,n))throw Tt(`Expected value to be of type ${e.constructor.name}.
9
+ ${n.toString()}`)};class Uy{constructor(e){this.patterns=[],this.$state=e}if(e,n){return this.patterns.push({if:Js(e),h:n}),this}else(e){return this.if(Zr,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 Tt("Unhandled pattern")}}}const zy=t=>new Uy(t),Yd=zy(Zr).if(Kd,(t,e)=>Qi(e,Mc,Gr)).if(Gd,(t,e)=>py(e)).if(Iy,(t,e)=>Wc(e)).if(Fy,(t,e)=>BigInt(Qi(e,Mc,Gr))).if(Xr,(t,e)=>Bn(e,eo(e,t.shape))).if(Cy,(t,e)=>{const n={};for(const s in t.shape){let r=t.shape[s];if(by.check(r)){if(Wc(e))continue;r=r.shape}n[s]=Yd(r,e)}return n}).if(Dy,(t,e)=>{const n=[],s=Ad(e,0,42);for(let r=0;r<s;r++)n.push(Bn(e,t.shape));return n}).if(Fd,(t,e)=>eo(e,t.shape)).if(My,(t,e)=>null).if(_y,(t,e)=>{const n=Bn(e,t.res);return()=>n}).if(Ay,(t,e)=>Bn(e,eo(e,[Zn,ds,gi,Jd,ga,mi,Vd(Zn),Ud(ws("a","b","c"),Zn)]))).if(ky,(t,e)=>{const n={},s=Qi(e,0,3);for(let r=0;r<s;r++){const i=Bn(e,t.shape.keys),a=Bn(e,t.shape.values);n[i]=a}return n}).done(),Bn=(t,e)=>Yd(Js(e),t),Bt=typeof document<"u"?document:{},By=t=>Bt.createElement(t),Vy=()=>Bt.createDocumentFragment();Ue(t=>t.nodeType===Zy);const Hy=t=>Bt.createTextNode(t);typeof DOMParser<"u"&&new DOMParser;const qy=(t,e)=>(hy(e,(n,s)=>{s===!1?t.removeAttribute(n):s===!0?t.setAttribute(n,""):t.setAttribute(n,s)}),t),Wy=t=>{const e=Vy();for(let n=0;n<t.length;n++)Xd(e,t[n]);return e},Ky=(t,e)=>(Xd(t,Wy(e)),t),Yb=(t,e=[],n=[])=>Ky(qy(By(t),e),n);Ue(t=>t.nodeType===Jy);const Xb=Hy;Ue(t=>t.nodeType===Yy);const Gy=t=>sg(t,(e,n)=>`${n}:${e};`).join(""),Xd=(t,e)=>t.appendChild(e),Jy=Bt.ELEMENT_NODE,Yy=Bt.TEXT_NODE;Bt.CDATA_SECTION_NODE;Bt.COMMENT_NODE;const Xy=Bt.DOCUMENT_NODE;Bt.DOCUMENT_TYPE_NODE;const Zy=Bt.DOCUMENT_FRAGMENT_NODE;Ue(t=>t.nodeType===Xy);const Qt=Symbol,Zd=Qt(),Qd=Qt(),Qy=Qt(),ew=Qt(),tw=Qt(),eu=Qt(),nw=Qt(),ya=Qt(),sw=Qt(),rw=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},iw={[Zd]:Wt("font-weight","bold"),[Qd]:Wt("font-weight","normal"),[Qy]:Wt("color","blue"),[tw]:Wt("color","green"),[ew]:Wt("color","grey"),[eu]:Wt("color","red"),[nw]:Wt("color","purple"),[ya]:Wt("color","orange"),[sw]:Wt("color","black")},ow=t=>{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());const e=[],n=[],s=ot();let r=[],i=0;for(;i<t.length;i++){const a=t[i],c=iw[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=Gy(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},tu=ty?ow:rw,aw=(...t)=>{console.log(...tu(t)),su.forEach(e=>e.print(t))},nu=(...t)=>{console.warn(...tu(t)),t.unshift(ya),su.forEach(e=>e.print(t))},su=un(),ru=t=>({[Symbol.iterator](){return this},next:t}),cw=(t,e)=>ru(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),to=(t,e)=>ru(()=>{const{done:n,value:s}=t.next();return{done:n,value:n?void 0:e(s)}});class yi{constructor(e,n){this.clock=e,this.len=n}}class xs{constructor(){this.clients=new Map}}const us=(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])xu(t,i,d.clock,d.len,n)}}),lw=(t,e)=>{let n=0,s=t.length-1;for(;n<=s;){const r=Nt((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},rr=(t,e)=>{const n=t.clients.get(e.client);return n!==void 0&&lw(n,e.clock)!==null},wa=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 yi(r.clock,jn(r.len,i.clock+i.len-r.clock)):(s<n&&(e[s]=i),s++)}e.length=s})},Po=t=>{const e=new xs;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++)ig(i,t[a].clients.get(r)||[]);e.clients.set(r,i)}});return wa(e),e},Ys=(t,e,n,s)=>{zt(t.clients,e,()=>[]).push(new yi(n,s))},dw=()=>new xs,uw=t=>{const e=dw();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 yi(c,l))}}r.length>0&&e.clients.set(s,r)}),e},bs=(t,e)=>{$(t.restEncoder,e.clients.size),Xt(e.clients.entries()).sort((n,s)=>s[0]-n[0]).forEach(([n,s])=>{t.resetDsCurVal(),$(t.restEncoder,n);const r=s.length;$(t.restEncoder,r);for(let i=0;i<r;i++){const a=s[i];t.writeDsClock(a.clock),t.writeDsLen(a.len)}})},xa=t=>{const e=new xs,n=J(t.restDecoder);for(let s=0;s<n;s++){t.resetDsCurVal();const r=J(t.restDecoder),i=J(t.restDecoder);if(i>0){const a=zt(e.clients,r,()=>[]);for(let c=0;c<i;c++)a.push(new yi(t.readDsClock(),t.readDsLen()))}}return e},Gc=(t,e,n)=>{const s=new xs,r=J(t.restDecoder);for(let i=0;i<r;i++){t.resetDsCurVal();const a=J(t.restDecoder),c=J(t.restDecoder),l=n.clients.get(a)||[],d=De(n,a);for(let f=0;f<c;f++){const u=t.readDsClock(),p=u+t.readDsLen();if(u<d){d<p&&Ys(s,a,d,p-d);let m=Mt(l,u),g=l[m];for(!g.deleted&&g.id.clock<u&&(l.splice(m+1,0,oi(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,oi(e,g,p-g.id.clock)),g.delete(e))}else Ys(s,a,u,p-u)}}if(s.clients.size>0){const i=new bn;return $(i.restEncoder,0),bs(i,s),i.toUint8Array()}return null},iu=Ed;class kn extends na{constructor({guid:e=Mg(),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=iu(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new yu,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=ls(d=>{this.on("load",()=>{this.isLoaded=!0,d(this)})});const l=()=>ls(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&&fe(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Xt(this.subdocs).map(e=>e.guid))}transact(e,n=null){return fe(this,e,n)}get(e,n=$e){const s=zt(this.share,e,()=>{const i=new n;return i._integrate(this,null),i}),r=s.constructor;if(n!==$e&&r!==n)if(r===$e){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,ts)}getText(e=""){return this.get(e,ps)}getMap(e=""){return this.get(e,fs)}getXmlElement(e=""){return this.get(e,ms)}getXmlFragment(e=""){return this.get(e,vn)}toJSON(){const e={};return this.share.forEach((n,s)=>{e[s]=n.toJSON()}),e}destroy(){this.isDestroyed=!0,Xt(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new kn({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,fe(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 ou{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return J(this.restDecoder)}readDsLen(){return J(this.restDecoder)}}class au extends ou{readLeftID(){return ee(J(this.restDecoder),J(this.restDecoder))}readRightID(){return ee(J(this.restDecoder),J(this.restDecoder))}readClient(){return J(this.restDecoder)}readInfo(){return cs(this.restDecoder)}readString(){return Dt(this.restDecoder)}readParentInfo(){return J(this.restDecoder)===1}readTypeRef(){return J(this.restDecoder)}readLen(){return J(this.restDecoder)}readAny(){return Ks(this.restDecoder)}readBuf(){return dy(Ge(this.restDecoder))}readJSON(){return JSON.parse(Dt(this.restDecoder))}readKey(){return Dt(this.restDecoder)}}class hw{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=J(this.restDecoder),this.dsCurrVal}readDsLen(){const e=J(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class hs extends hw{constructor(e){super(e),this.keys=[],J(e),this.keyClockDecoder=new Zi(Ge(e)),this.clientDecoder=new $r(Ge(e)),this.leftClockDecoder=new Zi(Ge(e)),this.rightClockDecoder=new Zi(Ge(e)),this.infoDecoder=new Hc(Ge(e),cs),this.stringDecoder=new Ag(Ge(e)),this.parentInfoDecoder=new Hc(Ge(e),cs),this.typeRefDecoder=new $r(Ge(e)),this.lenDecoder=new $r(Ge(e))}readLeftID(){return new Qn(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Qn(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 Ks(this.restDecoder)}readBuf(){return Ge(this.restDecoder)}readJSON(){return Ks(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 cu{constructor(){this.restEncoder=Te()}toUint8Array(){return pe(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){$(this.restEncoder,e)}writeDsLen(e){$(this.restEncoder,e)}}class ir extends cu{writeLeftID(e){$(this.restEncoder,e.client),$(this.restEncoder,e.clock)}writeRightID(e){$(this.restEncoder,e.client),$(this.restEncoder,e.clock)}writeClient(e){$(this.restEncoder,e)}writeInfo(e){Do(this.restEncoder,e)}writeString(e){Jt(this.restEncoder,e)}writeParentInfo(e){$(this.restEncoder,e?1:0)}writeTypeRef(e){$(this.restEncoder,e)}writeLen(e){$(this.restEncoder,e)}writeAny(e){Ws(this.restEncoder,e)}writeBuf(e){Se(this.restEncoder,e)}writeJSON(e){Jt(this.restEncoder,JSON.stringify(e))}writeKey(e){Jt(this.restEncoder,e)}}class lu{constructor(){this.restEncoder=Te(),this.dsCurrVal=0}toUint8Array(){return pe(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const n=e-this.dsCurrVal;this.dsCurrVal=e,$(this.restEncoder,n)}writeDsLen(e){e===0&&ut(),$(this.restEncoder,e-1),this.dsCurrVal+=e}}class bn extends lu{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Xi,this.clientEncoder=new Mr,this.leftClockEncoder=new Xi,this.rightClockEncoder=new Xi,this.infoEncoder=new zc(Do),this.stringEncoder=new Eg,this.parentInfoEncoder=new zc(Do),this.typeRefEncoder=new Mr,this.lenEncoder=new Mr}toUint8Array(){const e=Te();return $(e,0),Se(e,this.keyClockEncoder.toUint8Array()),Se(e,this.clientEncoder.toUint8Array()),Se(e,this.leftClockEncoder.toUint8Array()),Se(e,this.rightClockEncoder.toUint8Array()),Se(e,pe(this.infoEncoder)),Se(e,this.stringEncoder.toUint8Array()),Se(e,pe(this.parentInfoEncoder)),Se(e,this.typeRefEncoder.toUint8Array()),Se(e,this.lenEncoder.toUint8Array()),di(e,pe(this.restEncoder)),pe(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){Ws(this.restEncoder,e)}writeBuf(e){Se(this.restEncoder,e)}writeJSON(e){Ws(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 fw=(t,e,n,s)=>{s=jn(s,e[0].id.clock);const r=Mt(e,s);$(t.restEncoder,e.length-r),t.writeClient(n),$(t.restEncoder,s);const i=e[r];i.write(t,s-i.id.clock);for(let a=r+1;a<e.length;a++)e[a].write(t,0)},ba=(t,e,n)=>{const s=new Map;n.forEach((r,i)=>{De(e,i)>r&&s.set(i,r)}),wi(e).forEach((r,i)=>{n.has(i)||s.set(i,0)}),$(t.restEncoder,s.size),Xt(s.entries()).sort((r,i)=>i[0]-r[0]).forEach(([r,i])=>{fw(t,e.clients.get(r),r,i)})},pw=(t,e)=>{const n=ot(),s=J(t.restDecoder);for(let r=0;r<s;r++){const i=J(t.restDecoder),a=new Array(i),c=t.readClient();let l=J(t.restDecoder);n.set(c,{i:0,refs:a});for(let d=0;d<i;d++){const f=t.readInfo();switch(li&f){case 0:{const u=t.readLen();a[d]=new wt(ee(c,l),u),l+=u;break}case 10:{const u=J(t.restDecoder);a[d]=new xt(ee(c,l),u),l+=u;break}default:{const u=(f&(Gt|dt))===0,p=new me(ee(c,l),null,(f&dt)===dt?t.readLeftID():null,null,(f&Gt)===Gt?t.readRightID():null,u?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,u&&(f&Hs)===Hs?t.readString():null,$u(t,f));a[d]=p,l+=p.length}}}}return n},mw=(t,e,n)=>{const s=[];let r=Xt(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 yu,l=new Map,d=(m,g)=>{const x=l.get(m);(x==null||x>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,x=n.get(g);x?(x.i--,c.clients.set(g,x.refs.slice(x.i)),n.delete(g),x.i=0,x.refs=[]):c.clients.set(g,[m]),r=r.filter(b=>b!==g)}s.length=0};for(;;){if(f.constructor!==xt){const g=zt(u,f.id.client,()=>De(e,f.id.client))-f.id.clock;if(g<0)s.push(f),d(f.id.client,f.id.clock-1),p();else{const x=f.getMissing(t,e);if(x!==null){s.push(f);const b=n.get(x)||{refs:[],i:0};if(b.refs.length===b.i)d(x,De(e,x)),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 bn;return ba(m,c,new Map),$(m.restEncoder,0),{missing:l,update:m.toUint8Array()}}return null},gw=(t,e)=>ba(t,e.doc.store,e.beforeState),yw=(t,e,n,s=new hs(t))=>fe(e,r=>{r.local=!1;let i=!1;const a=r.doc,c=a.store,l=pw(s,a),d=mw(r,c,l),f=c.pendingStructs;if(f){for(const[p,m]of f.missing)if(m<De(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=ei([f.update,d.update])}}else c.pendingStructs=d;const u=Gc(s,r,c);if(c.pendingDs){const p=new hs(pn(c.pendingDs));J(p.restDecoder);const m=Gc(p,r,c);u&&m?c.pendingDs=ei([u,m]):c.pendingDs=u||m}else c.pendingDs=u;if(i){const p=c.pendingStructs.update;c.pendingStructs=null,du(r.doc,p)}},n,!1),du=(t,e,n,s=hs)=>{const r=pn(e);yw(r,t,n,new s(r))},uu=(t,e,n)=>du(t,e,n,au),ww=(t,e,n=new Map)=>{ba(t,e.store,n),bs(t,uw(e.store))},xw=(t,e=new Uint8Array([0]),n=new bn)=>{const s=hu(e);ww(n,t,s);const r=[n.toUint8Array()];if(t.store.pendingDs&&r.push(t.store.pendingDs),t.store.pendingStructs&&r.push(Iw(t.store.pendingStructs.update,e)),r.length>1){if(n.constructor===ir)return Aw(r.map((i,a)=>a===0?i:$w(i)));if(n.constructor===bn)return ei(r)}return r[0]},va=(t,e)=>xw(t,e,new ir),bw=t=>{const e=new Map,n=J(t.restDecoder);for(let s=0;s<n;s++){const r=J(t.restDecoder),i=J(t.restDecoder);e.set(r,i)}return e},hu=t=>bw(new ou(pn(t))),fu=(t,e)=>($(t.restEncoder,e.size),Xt(e.entries()).sort((n,s)=>s[0]-n[0]).forEach(([n,s])=>{$(t.restEncoder,n),$(t.restEncoder,s)}),t),vw=(t,e)=>fu(t,wi(e.store)),Sw=(t,e=new lu)=>(t instanceof Map?fu(e,t):vw(e,t),e.toUint8Array()),Cw=t=>Sw(t,new cu);class jw{constructor(){this.l=[]}}const Jc=()=>new jw,Yc=(t,e)=>t.l.push(e),Xc=(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.")},pu=(t,e,n)=>ua(t.l,[e,n]);class Qn{constructor(e,n){this.client=e,this.clock=n}}const Jn=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,ee=(t,e)=>new Qn(t,e),mu=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw ut()},Qr=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class gu{constructor(e,n,s,r=0){this.type=e,this.tname=n,this.item=s,this.assoc=r}}const Zb=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},Qb=t=>new gu(t.type==null?null:ee(t.type.client,t.type.clock),t.tname??null,t.item==null?null:ee(t.item.client,t.item.clock),t.assoc==null?0:t.assoc);class kw{constructor(e,n,s=0){this.type=e,this.index=n,this.assoc=s}}const Ew=(t,e,n=0)=>new kw(t,e,n),_r=(t,e,n)=>{let s=null,r=null;return t._item===null?r=mu(t):s=ee(t._item.id.client,t._item.id.clock),new gu(s,r,e,n)},ev=(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,ee(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)},Dw=(t,e)=>{const n=es(t,e),s=e.clock-n.id.clock;return{item:n,diff:s}},tv=(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(De(s,r.client)<=r.clock)return null;const f=n?Ao(s,r):Dw(s,r),u=f.item;if(!(u instanceof me))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(De(s,i.client)<=i.clock)return null;const{item:f}=n?Ao(s,i):{item:es(s,i)};if(f instanceof me&&f.content instanceof Vt)l=f.content.type;else return null}else throw ut();c>=0?d=l._length:d=0}return Ew(l,d,t.assoc)},nv=(t,e)=>t===e||t!==null&&e!==null&&t.tname===e.tname&&Jn(t.item,e.item)&&Jn(t.type,e.type)&&t.assoc===e.assoc,qn=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!rr(e.ds,t.id),_o=(t,e)=>{const n=zt(t.meta,_o,un),s=t.doc.store;n.has(e)||(e.sv.forEach((r,i)=>{r<De(s,i)&&it(t,ee(i,r))}),us(t,e.ds,r=>{}),n.add(e))};class yu{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const wi=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},De=(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},wu=(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 ut()}n.push(e)},Mt=(t,e)=>{let n=0,s=t.length-1,r=t[s],i=r.id.clock;if(i===e)return s;let a=Nt(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=Nt((n+s)/2)}throw ut()},Nw=(t,e)=>{const n=t.clients.get(e.client);return n[Mt(n,e.clock)]},es=Nw,Ro=(t,e,n)=>{const s=Mt(e,n),r=e[s];return r.id.clock<n&&r instanceof me?(e.splice(s+1,0,oi(t,r,n-r.id.clock)),s+1):s},it=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[Ro(t,n,e.clock)]},Zc=(t,e,n)=>{const s=e.clients.get(n.client),r=Mt(s,n.clock),i=s[r];return n.clock!==i.id.clock+i.length-1&&i.constructor!==wt&&s.splice(r+1,0,oi(t,i,n.clock-i.id.clock+1)),i},Tw=(t,e,n)=>{const s=t.clients.get(e.id.client);s[Mt(s,e.id.clock)]=n},xu=(t,e,n,s,r)=>{if(s===0)return;const i=n+s;let a=Ro(t,e,n),c;do c=e[a++],i<c.id.clock+c.length&&Ro(t,e,i),r(c);while(a<e.length&&e[a].id.clock<i)};class Ow{constructor(e,n,s){this.doc=e,this.deleteSet=new xs,this.beforeState=wi(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 Qc=(t,e)=>e.deleteSet.clients.size===0&&!rg(e.afterState,(n,s)=>e.beforeState.get(s)!==n)?!1:(wa(e.deleteSet),gw(t,e),bs(t,e.deleteSet),!0),el=(t,e,n)=>{const s=e._item;(s===null||s.id.clock<(t.beforeState.get(s.id.client)||0)&&!s.deleted)&&zt(t.changed,e,un).add(n)},Ur=(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 me&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,s);continue}break}const i=e-r;return i&&t.splice(e+1-i,i),i},Pw=(t,e,n)=>{for(const[s,r]of t.clients.entries()){const i=e.clients.get(s);for(let a=r.length-1;a>=0;a--){const c=r[a],l=c.clock+c.len;for(let d=Mt(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 me&&u.deleted&&!u.keep&&n(u)&&u.gc(e,!1)}}}},_w=(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=sa(r.length-1,1+Mt(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+Ur(r,l)}})},bu=(t,e)=>{if(e<t.length){const n=t[e],s=n.doc,r=s.store,i=n.deleteSet,a=n._mergeStructs;try{wa(i),n.afterState=wi(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(()=>{pu(d._dEH,l,n)}))}),c.push(()=>s.emit("afterTransaction",[n,s])),c.push(()=>{n._needFormattingCleanup&&Qw(n)})}),ua(c,[])}finally{s.gc&&Pw(i,r,s.gcFilter),_w(i,r),n.afterState.forEach((f,u)=>{const p=n.beforeState.get(u)||0;if(p!==f){const m=r.clients.get(u),g=jn(Mt(m,p),1);for(let x=m.length-1;x>=g;)x-=1+Ur(m,x)}});for(let f=a.length-1;f>=0;f--){const{client:u,clock:p}=a[f].id,m=r.clients.get(u),g=Mt(m,p);g+1<m.length&&Ur(m,g+1)>1||g>0&&Ur(m,g)}if(!n.local&&n.afterState.get(s.clientID)!==n.beforeState.get(s.clientID)&&(aw(ya,Zd,"[yjs] ",Qd,eu,"Changed the client-id because another client seems to be using it."),s.clientID=iu()),s.emit("afterTransactionCleanup",[n,s]),s._observers.has("update")){const f=new ir;Qc(f,n)&&s.emit("update",[f.toUint8Array(),n.origin,s,n])}if(s._observers.has("updateV2")){const f=new bn;Qc(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])):bu(t,e+1)}}},fe=(t,e,n=null,s=!0)=>{const r=t._transactionCleanups;let i=!1,a=null;t._transaction===null&&(i=!0,t._transaction=new Ow(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&&bu(r,0)}}return a};class Rw{constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const tl=(t,e,n)=>{us(t,n.deletions,s=>{s instanceof me&&e.scope.some(r=>r===t.doc||Qr(r,s))&&Ta(s,!1)})},nl=(t,e,n)=>{let s=null;const r=t.doc,i=t.scope;fe(r,c=>{for(;e.length>0&&t.currStackItem===null;){const l=r.store,d=e.pop(),f=new Set,u=[];let p=!1;us(c,d.insertions,m=>{if(m instanceof me){if(m.redone!==null){let{item:g,diff:x}=Ao(l,m.id);x>0&&(g=it(c,ee(g.id.client,g.id.clock+x))),m=g}!m.deleted&&i.some(g=>g===c.doc||Qr(g,m))&&u.push(m)}}),us(c,d.deletions,m=>{m instanceof me&&i.some(g=>g===c.doc||Qr(g,m))&&!rr(d.insertions,m.id)&&f.add(m)}),f.forEach(m=>{p=Mu(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 sv extends na{constructor(e,{captureTimeout:n=500,captureTransaction:s=l=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:c=as(e)?e[0].doc:e instanceof kn?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 xs;l.afterState.forEach((b,S)=>{const k=l.beforeState.get(S)||0,T=b-k;T>0&&Ys(p,S,k,T)});const m=hn();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=Po([b.deletions,l.deleteSet]),b.insertions=Po([b.insertions,p])}else u.push(new Rw(l.deleteSet,p)),g=!0;!d&&!f&&(this.lastChange=m),us(l,l.deleteSet,b=>{b instanceof me&&this.scope.some(S=>S===l.doc||Qr(S,b))&&Ta(b,!0)});const x=[{stackItem:u[u.length-1],origin:l.origin,type:d?"redo":"undo",changedParentTypes:l.changedParentTypes},this];g?this.emit("stack-item-added",x):this.emit("stack-item-updated",x)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){const n=new Set(this.scope);e=as(e)?e:[e],e.forEach(s=>{n.has(s)||(n.add(s),(s instanceof $e?s.doc!==this.doc:s!==this.doc)&&nu("[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=>tl(s,this,r)),this.undoStack=[]),n&&(this.redoStack.forEach(r=>tl(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=nl(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=nl(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*Lw(t){const e=J(t.restDecoder);for(let n=0;n<e;n++){const s=J(t.restDecoder),r=t.readClient();let i=J(t.restDecoder);for(let a=0;a<s;a++){const c=t.readInfo();if(c===10){const l=J(t.restDecoder);yield new xt(ee(r,i),l),i+=l}else if((li&c)!==0){const l=(c&(Gt|dt))===0,d=new me(ee(r,i),null,(c&dt)===dt?t.readLeftID():null,null,(c&Gt)===Gt?t.readRightID():null,l?t.readParentInfo()?t.readString():t.readLeftID():null,l&&(c&Hs)===Hs?t.readString():null,$u(t,c));yield d,i+=d.length}else{const l=t.readLen();yield new wt(ee(r,i),l),i+=l}}}}class Sa{constructor(e,n){this.gen=Lw(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===xt);return this.curr}}class Ca{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const Aw=t=>ei(t,au,ir),Fw=(t,e)=>{if(t.constructor===wt){const{client:n,clock:s}=t.id;return new wt(ee(n,s+e),t.length-e)}else if(t.constructor===xt){const{client:n,clock:s}=t.id;return new xt(ee(n,s+e),t.length-e)}else{const n=t,{client:s,clock:r}=n.id;return new me(ee(s,r+e),null,ee(s,r+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},ei=(t,e=hs,n=bn)=>{if(t.length===1)return t[0];const s=t.map(f=>new e(pn(f)));let r=s.map(f=>new Sa(f,!0)),i=null;const a=new n,c=new Ca(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===xt?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)on(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===xt)i.struct.length=p.id.clock+p.length-i.struct.id.clock;else{on(c,i.struct,i.offset);const g=p.id.clock-i.struct.id.clock-i.struct.length;i={struct:new xt(ee(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===xt?i.struct.length-=g:p=Fw(p,g)),i.struct.mergeWith(p)||(on(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!==xt;p=f.next())on(c,i.struct,i.offset),i={struct:p,offset:0}}i!==null&&(on(c,i.struct,i.offset),i=null),ja(c);const l=s.map(f=>xa(f)),d=Po(l);return bs(a,d),a.toUint8Array()},Iw=(t,e,n=hs,s=bn)=>{const r=hu(e),i=new s,a=new Ca(i),c=new n(pn(t)),l=new Sa(c,!1);for(;l.curr;){const f=l.curr,u=f.id.client,p=r.get(u)||0;if(l.curr.constructor===xt){l.next();continue}if(f.id.clock+f.length>p)for(on(a,f,jn(p-f.id.clock,0)),l.next();l.curr&&l.curr.id.client===u;)on(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()}ja(a);const d=xa(c);return bs(i,d),i.toUint8Array()},vu=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:pe(t.encoder.restEncoder)}),t.encoder.restEncoder=Te(),t.written=0)},on=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&vu(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),$(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},ja=t=>{vu(t);const e=t.encoder.restEncoder;$(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const s=t.clientStructs[n];$(e,s.written),di(e,s.restEncoder)}},Mw=(t,e,n,s)=>{const r=new n(pn(t)),i=new Sa(r,!1),a=new s,c=new Ca(a);for(let d=i.curr;d!==null;d=i.next())on(c,e(d),0);ja(c);const l=xa(r);return bs(a,l),a.toUint8Array()},$w=t=>Mw(t,Yg,hs,ir),sl="You must not compute changes after the event-handler fired.";class xi{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=Uw(this.currentTarget,this.target))}deletes(e){return rr(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Tt(sl);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=Gi(l.content.getContent());else return;else l!==null&&this.deletes(l)?(a="update",c=Gi(l.content.getContent())):(a="add",c=void 0)}else if(this.deletes(i))a="delete",c=Gi(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 Tt(sl);const n=this.target,s=un(),r=un(),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 Uw=(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},Je=()=>{nu("Invalid access: Add Yjs type to a document before reading data.")},Su=80;let ka=0;class zw{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=ka++}}const Bw=t=>{t.timestamp=ka++},Cu=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=ka++},Vw=(t,e,n)=>{if(t.length>=Su){const s=t.reduce((r,i)=>r.timestamp<i.timestamp?r:i);return Cu(s,e,n),s}else{const s=new zw(e,n);return t.push(s),s}},bi=(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)=>Ir(e-i.index)<Ir(e-a.index)?i:a);let s=t._start,r=0;for(n!==null&&(s=n.p,r=n.index,Bw(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&&Ir(n.index-r)<s.parent.length/Su?(Cu(n,s,r),n):Vw(t._searchMarker,s,r)},Xs=(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=jn(e,r.index+n))}},vi=(t,e,n)=>{const s=t,r=e.changedParentTypes;for(;zt(r,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;pu(s._eH,n,e)};class $e{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Jc(),this._dEH=Jc(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw Et()}clone(){throw Et()}_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){Yc(this._eH,e)}observeDeep(e){Yc(this._dEH,e)}unobserve(e){Xc(this._eH,e)}unobserveDeep(e){Xc(this._dEH,e)}toJSON(){}}const ju=(t,e,n)=>{t.doc??Je(),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},ku=t=>{t.doc??Je();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},Zs=(t,e)=>{let n=0,s=t._start;for(t.doc??Je();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}},Eu=(t,e)=>{const n=[];return Zs(t,(s,r)=>{n.push(e(s,r,t))}),n},Hw=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}}}},Du=(t,e)=>{t.doc??Je();const n=bi(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}},ti=(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 me(ee(a,De(c,a)),r,r&&r.lastId,l,l&&l.id,e,null,new Sn(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 me(ee(a,De(c,a)),r,r&&r.lastId,l,l&&l.id,e,null,new or(new Uint8Array(u))),r.integrate(t,0);break;case kn:r=new me(ee(a,De(c,a)),r,r&&r.lastId,l,l&&l.id,e,null,new ar(u)),r.integrate(t,0);break;default:if(u instanceof $e)r=new me(ee(a,De(c,a)),r,r&&r.lastId,l,l&&l.id,e,null,new Vt(u)),r.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),f()},Nu=()=>Tt("Length exceeded!"),Tu=(t,e,n,s)=>{if(n>e._length)throw Nu();if(n===0)return e._searchMarker&&Xs(e._searchMarker,n,s.length),ti(t,e,null,s);const r=n,i=bi(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&&it(t,ee(a.id.client,a.id.clock+n));break}n-=a.length}return e._searchMarker&&Xs(e._searchMarker,r,s.length),ti(t,e,a,s)},qw=(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 ti(t,e,r,n)},Ou=(t,e,n,s)=>{if(s===0)return;const r=n,i=s,a=bi(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&&it(t,ee(c.id.client,c.id.clock+n)),n-=c.length);for(;s>0&&c!==null;)c.deleted||(s<c.length&&it(t,ee(c.id.client,c.id.clock+s)),c.delete(t),s-=c.length),c=c.right;if(s>0)throw Nu();e._searchMarker&&Xs(e._searchMarker,r,-i+s)},ni=(t,e,n)=>{const s=e._map.get(n);s!==void 0&&s.delete(t)},Ea=(t,e,n,s)=>{const r=e._map.get(n)||null,i=t.doc,a=i.clientID;let c;if(s==null)c=new Sn([s]);else switch(s.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:c=new Sn([s]);break;case Uint8Array:c=new or(s);break;case kn:c=new ar(s);break;default:if(s instanceof $e)c=new Vt(s);else throw new Error("Unexpected content type")}new me(ee(a,De(i.store,a)),r,r&&r.lastId,null,null,e,n,c).integrate(t,0)},Da=(t,e)=>{t.doc??Je();const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Pu=t=>{const e={};return t.doc??Je(),t._map.forEach((n,s)=>{n.deleted||(e[s]=n.content.getContent()[n.length-1])}),e},_u=(t,e)=>{t.doc??Je();const n=t._map.get(e);return n!==void 0&&!n.deleted},Ww=(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&&qn(i,e)&&(n[r]=i.content.getContent()[i.length-1])}),n},Rr=t=>(t.doc??Je(),cw(t._map.entries(),e=>!e[1].deleted));class Kw extends xi{}class ts extends $e{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new ts;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new ts}clone(){const e=new ts;return e.insert(0,this.toArray().map(n=>n instanceof $e?n.clone():n)),e}get length(){return this.doc??Je(),this._length}_callObserver(e,n){super._callObserver(e,n),vi(this,e,new Kw(this,e))}insert(e,n){this.doc!==null?fe(this.doc,s=>{Tu(s,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?fe(this.doc,n=>{qw(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?fe(this.doc,s=>{Ou(s,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return Du(this,e)}toArray(){return ku(this)}slice(e=0,n=this.length){return ju(this,e,n)}toJSON(){return this.map(e=>e instanceof $e?e.toJSON():e)}map(e){return Eu(this,e)}forEach(e){Zs(this,e)}[Symbol.iterator](){return Hw(this)}_write(e){e.writeTypeRef(wx)}}const Gw=t=>new ts;class Jw extends xi{constructor(e,n,s){super(e,n),this.keysChanged=s}}class fs extends $e{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 fs}clone(){const e=new fs;return this.forEach((n,s)=>{e.set(s,n instanceof $e?n.clone():n)}),e}_callObserver(e,n){vi(this,e,new Jw(this,e,n))}toJSON(){this.doc??Je();const e={};return this._map.forEach((n,s)=>{if(!n.deleted){const r=n.content.getContent()[n.length-1];e[s]=r instanceof $e?r.toJSON():r}}),e}get size(){return[...Rr(this)].length}keys(){return to(Rr(this),e=>e[0])}values(){return to(Rr(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return to(Rr(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??Je(),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?fe(this.doc,n=>{ni(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?fe(this.doc,s=>{Ea(s,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return Da(this,e)}has(e){return _u(this,e)}clear(){this.doc!==null?fe(this.doc,e=>{this.forEach(function(n,s,r){ni(e,r,s)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(xx)}}const Yw=t=>new fs,an=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&Gg(t,e);class Lo{constructor(e,n,s,r){this.left=e,this.right=n,this.index=s,this.currentAttributes=r}forward(){this.right===null&&ut(),this.right.content.constructor===Re?this.right.deleted||vs(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}}const rl=(t,e,n)=>{for(;e.right!==null&&n>0;)e.right.content.constructor===Re?e.right.deleted||vs(e.currentAttributes,e.right.content):e.right.deleted||(n<e.right.length&&it(t,ee(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},Lr=(t,e,n,s)=>{const r=new Map,i=s?bi(e,n):null;if(i){const a=new Lo(i.p.left,i.p,i.index,r);return rl(t,a,n-i.index)}else{const a=new Lo(null,e._start,0,r);return rl(t,a,n)}},Ru=(t,e,n,s)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===Re&&an(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 me(ee(i,De(r.store,i)),l,l&&l.lastId,d,d&&d.id,e,null,new Re(c,a));f.integrate(t,0),n.right=f,n.forward()})},vs=(t,e)=>{const{key:n,value:s}=e;s===null?t.delete(n):t.set(n,s)},Lu=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===Re&&an(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},Au=(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(!an(d,l)){a.set(c,d);const{left:f,right:u}=n;n.right=new me(ee(i,De(r.store,i)),f,f&&f.lastId,u,u&&u.id,e,null,new Re(c,l)),n.right.integrate(t,0),n.forward()}}return a},no=(t,e,n,s,r)=>{n.currentAttributes.forEach((p,m)=>{r[m]===void 0&&(r[m]=null)});const i=t.doc,a=i.clientID;Lu(n,r);const c=Au(t,e,n,r),l=s.constructor===String?new $t(s):s instanceof $e?new Vt(s):new En(s);let{left:d,right:f,index:u}=n;e._searchMarker&&Xs(e._searchMarker,n.index,l.getLength()),f=new me(ee(a,De(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(),Ru(t,e,n,c)},il=(t,e,n,s,r)=>{const i=t.doc,a=i.clientID;Lu(n,r);const c=Au(t,e,n,r);e:for(;n.right!==null&&(s>0||c.size>0&&(n.right.deleted||n.right.content.constructor===Re));){if(!n.right.deleted)switch(n.right.content.constructor){case Re:{const{key:l,value:d}=n.right.content,f=r[l];if(f!==void 0){if(an(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&&it(t,ee(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 me(ee(a,De(i.store,a)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new $t(l)),n.right.integrate(t,0),n.forward()}Ru(t,e,n,c)},Fu=(t,e,n,s,r)=>{let i=e;const a=ot();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===Re){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===Re){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&&vs(r,d)}}e=e.right}return c},Xw=(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===Re){const s=e.content.key;n.has(s)?e.delete(t):n.add(s)}e=e.left}},Zw=t=>{let e=0;return fe(t.doc,n=>{let s=t._start,r=t._start,i=ot();const a=ko(i);for(;r;)r.deleted===!1&&(r.content.constructor===Re?vs(a,r.content):(e+=Fu(n,s,r,i,a),i=ko(a),s=r)),r=r.right}),e},Qw=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&&xu(t,n.store.clients.get(s),i,r,a=>{!a.deleted&&a.content.constructor===Re&&a.constructor!==wt&&e.add(a.parent)})}fe(n,s=>{us(t,t.deleteSet,r=>{if(r instanceof wt||!r.parent._hasFormatting||e.has(r.parent))return;const i=r.parent;r.content.constructor===Re?e.add(i):Xw(s,r)});for(const r of e)Zw(r)})},ol=(t,e,n)=>{const s=n,r=ko(e.currentAttributes),i=e.right;for(;n>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case Vt:case En:case $t:n<e.right.length&&it(t,ee(e.right.id.client,e.right.id.clock+n)),n-=e.right.length,e.right.delete(t);break}e.forward()}i&&Fu(t,i,e.right,r,e.currentAttributes);const a=(e.left||e.right).parent;return a._searchMarker&&Xs(a._searchMarker,e.index,-s+n),e};class ex extends xi{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=[];fe(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,x)=>{g!==null&&(m.attributes[x]=g)}))),d="";break;case"retain":f>0&&(m={retain:f},Kg(l)||(m.attributes=Vg({},l))),f=0;break}m&&n.push(m),c=null}};for(;a!==null;){switch(a.content.constructor){case Vt:case En: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 $t: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 Re:{const{key:m,value:g}=a.content;if(this.adds(a)){if(!this.deletes(a)){const x=r.get(m)??null;an(x,g)?g!==null&&a.delete(s):(c==="retain"&&p(),an(g,i.get(m)??null)?delete l[m]:l[m]=g)}}else if(this.deletes(a)){i.set(m,g);const x=r.get(m)??null;an(x,g)||(c==="retain"&&p(),l[m]=x)}else if(!a.deleted){i.set(m,g);const x=l[m];x!==void 0&&(an(x,g)?x!==null&&a.delete(s):(c==="retain"&&p(),g===null?delete l[m]:l[m]=g))}a.deleted||(c==="insert"&&p(),vs(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 ps extends $e{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??Je(),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 ps}clone(){const e=new ps;return e.applyDelta(this.toDelta()),e}_callObserver(e,n){super._callObserver(e,n);const s=new ex(this,e,n);vi(this,e,s),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??Je();let e="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===$t&&(e+=n.content.str),n=n.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:n=!0}={}){this.doc!==null?fe(this.doc,s=>{const r=new Lo(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)&&no(s,this,r,c,a.attributes||{})}else a.retain!==void 0?il(s,this,r,a.retain,a.attributes||{}):a.delete!==void 0&&ol(s,r,a.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,s){this.doc??Je();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,x)=>{p=!0,u[x]=g});const m={insert:c};p&&(m.attributes=u),r.push(m),c=""}}const f=()=>{for(;l!==null;){if(qn(l,e)||n!==void 0&&qn(l,n))switch(l.content.constructor){case $t:{const u=i.get("ychange");e!==void 0&&!qn(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&&!qn(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 Vt:case En:{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 Re:qn(l,e)&&(d(),vs(i,l.content));break}l=l.right}d()};return e||n?fe(a,u=>{e&&_o(u,e),n&&_o(u,n),f()},"cleanup"):f(),r}insert(e,n,s){if(n.length<=0)return;const r=this.doc;r!==null?fe(r,i=>{const a=Lr(i,this,e,!s);s||(s={},a.currentAttributes.forEach((c,l)=>{s[l]=c})),no(i,this,a,n,s)}):this._pending.push(()=>this.insert(e,n,s))}insertEmbed(e,n,s){const r=this.doc;r!==null?fe(r,i=>{const a=Lr(i,this,e,!s);no(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?fe(s,r=>{ol(r,Lr(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?fe(r,i=>{const a=Lr(i,this,e,!1);a.right!==null&&il(i,this,a,n,s)}):this._pending.push(()=>this.format(e,n,s))}removeAttribute(e){this.doc!==null?fe(this.doc,n=>{ni(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?fe(this.doc,s=>{Ea(s,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return Da(this,e)}getAttributes(){return Pu(this)}_write(e){e.writeTypeRef(bx)}}const tx=t=>new ps;class so{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??Je()}[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===ms||n.constructor===vn)&&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 vn extends $e{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 vn}clone(){const e=new vn;return e.insert(0,this.toArray().map(n=>n instanceof $e?n.clone():n)),e}get length(){return this.doc??Je(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new so(this,e)}querySelector(e){e=e.toUpperCase();const s=new so(this,r=>r.nodeName&&r.nodeName.toUpperCase()===e).next();return s.done?null:s.value}querySelectorAll(e){return e=e.toUpperCase(),Xt(new so(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){vi(this,e,new rx(this,n,e))}toString(){return Eu(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),Zs(this,i=>{r.insertBefore(i.toDOM(e,n,s),null)}),r}insert(e,n){this.doc!==null?fe(this.doc,s=>{Tu(s,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)fe(this.doc,s=>{const r=e&&e instanceof $e?e._item:e;ti(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 Tt("Reference item not found");s.splice(r,0,...n)}}delete(e,n=1){this.doc!==null?fe(this.doc,s=>{Ou(s,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return ku(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Du(this,e)}slice(e=0,n=this.length){return ju(this,e,n)}forEach(e){Zs(this,e)}_write(e){e.writeTypeRef(Sx)}}const nx=t=>new vn;class ms extends vn{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 ms(this.nodeName)}clone(){const e=new ms(this.nodeName),n=this.getAttributes();return qg(n,(s,r)=>{e.setAttribute(r,s)}),e.insert(0,this.toArray().map(s=>s instanceof $e?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?fe(this.doc,n=>{ni(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?fe(this.doc,s=>{Ea(s,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return Da(this,e)}hasAttribute(e){return _u(this,e)}getAttributes(e){return e?Ww(this,e):Pu(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 Zs(this,a=>{r.appendChild(a.toDOM(e,n,s))}),s!==void 0&&s._createAssociation(r,this),r}_write(e){e.writeTypeRef(vx),e.writeKey(this.nodeName)}}const sx=t=>new ms(t.readKey());class rx extends xi{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 si extends fs{constructor(e){super(),this.hookName=e}_copy(){return new si(this.hookName)}clone(){const e=new si(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(Cx),e.writeKey(this.hookName)}}const ix=t=>new si(t.readKey());class ri extends ps{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 ri}clone(){const e=new ri;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(jx)}}const ox=t=>new ri;class Na{constructor(e,n){this.id=e,this.length=n}get deleted(){throw Et()}mergeWith(e){return!1}write(e,n,s){throw Et()}integrate(e,n){throw Et()}}const ax=0;class wt extends Na{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),wu(e.doc.store,this)}write(e,n){e.writeInfo(ax),e.writeLen(this.length-n)}getMissing(e,n){return null}}class or{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new or(this.content)}splice(e){throw Et()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}}const cx=t=>new or(t.readBuf());class Qs{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Qs(this.len)}splice(e){const n=new Qs(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){Ys(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 lx=t=>new Qs(t.readLen()),Iu=(t,e)=>new kn({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class ar{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 ar(Iu(this.doc.guid,this.opts))}splice(e){throw Et()}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 dx=t=>new ar(Iu(t.readString(),t.readAny()));class En{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new En(this.embed)}splice(e){throw Et()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}}const ux=t=>new En(t.readJSON());class Re{constructor(e,n){this.key=e,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new Re(this.key,this.value)}splice(e){throw Et()}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 hx=t=>new Re(t.readKey(),t.readJSON());class ii{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new ii(this.arr)}splice(e){const n=new ii(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 fx=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 ii(n)},px=Yr("node_env")==="development";class Sn{constructor(e){this.arr=e,px&&Od(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Sn(this.arr)}splice(e){const n=new Sn(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 mx=t=>{const e=t.readLen(),n=[];for(let s=0;s<e;s++)n.push(t.readAny());return new Sn(n)};class $t{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new $t(this.str)}splice(e){const n=new $t(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 gx=t=>new $t(t.readString()),yx=[Gw,Yw,tx,sx,nx,ix,ox],wx=0,xx=1,bx=2,vx=3,Sx=4,Cx=5,jx=6;class Vt{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Vt(this.type._copy())}splice(e){throw Et()}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 kx=t=>new Vt(yx[t.readTypeRef()](t)),Ao=(t,e)=>{let n=e,s=0,r;do s>0&&(n=ee(n.client,n.clock+s)),r=es(t,n),s=n.clock-r.id.clock,n=r.redone;while(n!==null&&r instanceof me);return{item:r,diff:s}},Ta=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},oi=(t,e,n)=>{const{client:s,clock:r}=e.id,i=new me(ee(s,r+n),e,ee(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=ee(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},al=(t,e)=>ta(t,n=>rr(n.deletions,e)),Mu=(t,e,n,s,r,i)=>{const a=t.doc,c=a.store,l=a.clientID,d=e.redone;if(d!==null)return it(t,d);let f=e.parent._item,u=null,p;if(f!==null&&f.deleted===!0){if(f.redone===null&&(!n.has(f)||Mu(t,f,n,s,r,i)===null))return null;for(;f.redone!==null;)f=it(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 S=u;for(;S!==null&&S.parent._item!==f;)S=S.redone===null?null:it(t,S.redone);if(S!==null&&S.parent._item===f){u=S;break}u=u.left}for(;p!==null;){let S=p;for(;S!==null&&S.parent._item!==f;)S=S.redone===null?null:it(t,S.redone);if(S!==null&&S.parent._item===f){p=S;break}p=p.right}}else{if(p=null,e.right&&!r){for(u=e;u!==null&&u.right!==null&&(u.right.redone||rr(s,u.right.id)||al(i.undoStack,u.right.id)||al(i.redoStack,u.right.id));)for(u=u.right;u.redone;)u=it(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=De(c,l),x=ee(l,g),b=new me(x,u,u&&u.lastId,p,p&&p.id,m,e.parentSub,e.content.copy());return e.redone=x,Ta(b,!0),b.integrate(t,0),b};class me extends Na{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()?Ic:0}set marker(e){(this.info&Yi)>0!==e&&(this.info^=Yi)}get marker(){return(this.info&Yi)>0}get keep(){return(this.info&Fc)>0}set keep(e){this.keep!==e&&(this.info^=Fc)}get countable(){return(this.info&Ic)>0}get deleted(){return(this.info&Ji)>0}set deleted(e){this.deleted!==e&&(this.info^=Ji)}markDeleted(){this.info|=Ji}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=De(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=De(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Qn&&this.id.client!==this.parent.client&&this.parent.clock>=De(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=Zc(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=it(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===wt||this.right&&this.right.constructor===wt)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===me?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===me&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Qn){const s=es(n,this.parent);s.constructor===wt?this.parent=null:this.parent=s.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=Zc(e,e.doc.store,ee(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),Jn(this.origin,r.origin)){if(r.id.client<this.id.client)s=r,i.clear();else if(Jn(this.rightOrigin,r.rightOrigin))break}else if(r.origin!==null&&a.has(es(e.doc.store,r.origin)))i.has(es(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),wu(e.doc.store,this),this.content.integrate(e,this),el(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new wt(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:ee(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Jn(e.origin,this.lastId)&&this.right===e&&Jn(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(),Ys(e.deleteSet,this.id.client,this.id.clock,this.length),el(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw ut();this.content.gc(e),n?Tw(e,this,new wt(this.id,this.length)):this.content=new Qs(this.length)}write(e,n){const s=n>0?ee(this.id.client,this.id.clock+n-1):this.origin,r=this.rightOrigin,i=this.parentSub,a=this.content.getRef()&li|(s===null?0:dt)|(r===null?0:Gt)|(i===null?0:Hs);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=mu(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===Qn?(e.writeParentInfo(!1),e.writeLeftID(c)):ut();i!==null&&e.writeString(i)}this.content.write(e,n)}}const $u=(t,e)=>Ex[e&li](t),Ex=[()=>{ut()},lx,fx,cx,gx,ux,hx,kx,mx,dx,()=>{ut()}],Dx=10;class xt extends Na{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){ut()}write(e,n){e.writeInfo(Dx),$(e.restEncoder,this.length-n)}getMissing(e,n){return null}}const Uu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},zu="__ $YJS$ __";Uu[zu]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Uu[zu]=!0;const Bu=new Map;class Nx{constructor(e){this.room=e,this.onmessage=null,this._onChange=n=>n.key===e&&this.onmessage!==null&&this.onmessage({data:ly(n.newValue||"")}),Ug(this._onChange)}postMessage(e){Nd.setItem(this.room,cy(sy(e)))}close(){zg(this._onChange)}}const Tx=typeof BroadcastChannel>"u"?Nx:BroadcastChannel,Oa=t=>zt(Bu,t,()=>{const e=un(),n=new Tx(t);return n.onmessage=s=>e.forEach(r=>r(s.data,"broadcastchannel")),{bc:n,subs:e}}),Ox=(t,e)=>(Oa(t).subs.add(e),e),Px=(t,e)=>{const n=Oa(t),s=n.subs.delete(e);return s&&n.subs.size===0&&(n.bc.close(),Bu.delete(t)),s},Wn=(t,e,n=null)=>{const s=Oa(t);s.bc.postMessage(e),s.subs.forEach(r=>r(e,n))},Vu=0,Pa=1,Hu=2,ai=(t,e)=>{$(t,Vu);const n=Cw(e);Se(t,n)},qu=(t,e,n)=>{$(t,Pa),Se(t,va(e,n))},_x=(t,e,n)=>qu(e,n,Ge(t)),Wu=(t,e,n,s)=>{try{uu(e,Ge(t),n)}catch(r){s?.(r),console.error("Caught error while handling a Yjs update",r)}},Rx=(t,e)=>{$(t,Hu),Se(t,e)},Lx=Wu,Ax=(t,e,n,s,r)=>{const i=J(t);switch(i){case Vu:_x(t,e,n);break;case Pa:Wu(t,n,s,r);break;case Hu:Lx(t,n,s,r);break;default:throw new Error("Unknown message type")}return i},Fx=0,Ix=(t,e,n)=>{J(t)===Fx&&n(e,Dt(t))},ro=3e4;class Mx extends vd{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const n=hn();this.getLocalState()!==null&&ro/2<=n-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const s=[];this.meta.forEach((r,i)=>{i!==this.clientID&&ro<=n-r.lastUpdated&&this.states.has(i)&&s.push(i)}),s.length>0&&_a(this,s,"timeout")},Nt(ro/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:hn()});const a=[],c=[],l=[],d=[];e===null?d.push(n):i==null?e!=null&&a.push(n):(c.push(n),Xn(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:hn()})}s.push(i)}}s.length>0&&(t.emit("change",[{added:[],updated:[],removed:s},n]),t.emit("update",[{added:[],updated:[],removed:s},n]))},ns=(t,e,n=t.states)=>{const s=e.length,r=Te();$(r,s);for(let i=0;i<s;i++){const a=e[i],c=n.get(a)||null,l=t.meta.get(a).clock;$(r,a),$(r,l),Jt(r,JSON.stringify(c))}return pe(r)},$x=(t,e,n)=>{const s=pn(e),r=hn(),i=[],a=[],c=[],l=[],d=J(s);for(let f=0;f<d;f++){const u=J(s);let p=J(s);const m=JSON.parse(Dt(s)),g=t.meta.get(u),x=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&&(Xn(m,x)||c.push(u),a.push(u)))}(i.length>0||c.length>0||l.length>0)&&t.emit("change",[{added:i,updated:c,removed:l},n]),(i.length>0||a.length>0||l.length>0)&&t.emit("update",[{added:i,updated:a,removed:l},n])},Ux=t=>Wg(t,(e,n)=>`${encodeURIComponent(n)}=${encodeURIComponent(e)}`).join("&"),wn=0,Ku=3,ss=1,zx=2,cr=[];cr[wn]=(t,e,n,s,r)=>{$(t,wn);const i=Ax(e,t,n.doc,n);s&&i===Pa&&!n.synced&&(n.synced=!0)};cr[Ku]=(t,e,n,s,r)=>{$(t,ss),Se(t,ns(n.awareness,Array.from(n.awareness.getStates().keys())))};cr[ss]=(t,e,n,s,r)=>{$x(n.awareness,Ge(e),n)};cr[zx]=(t,e,n,s,r)=>{Ix(e,n.doc,(i,a)=>Bx(n,a))};const cl=3e4,Bx=(t,e)=>console.warn(`Permission denied to access ${t.url}.
12
+ ${e}`),Gu=(t,e,n)=>{const s=pn(e),r=Te(),i=J(s),a=t.messageHandlers[i];return a?a(r,s,t,n,i):console.error("Unable to compute message"),r},Fo=(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(Ju,sa(ag(2,t.wsUnsuccessfulReconnects)*100,t.maxBackoffTime),t))},Ju=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=hn();const s=Gu(t,new Uint8Array(n.data),!0);ra(s)>1&&e.send(pe(s))},e.onerror=n=>{t.emit("connection-error",[n,t])},e.onclose=n=>{Fo(t,e,n)},e.onopen=()=>{t.wsLastMessageReceived=hn(),t.wsconnecting=!1,t.wsconnected=!0,t.wsUnsuccessfulReconnects=0,t.emit("status",[{status:"connected"}]);const n=Te();if($(n,wn),ai(n,t.doc),e.send(pe(n)),t.awareness.getLocalState()!==null){const s=Te();$(s,ss),Se(s,ns(t.awareness,[t.doc.clientID])),e.send(pe(s))}},t.emit("status",[{status:"connecting"}])}},io=(t,e)=>{const n=t.ws;t.wsconnected&&n&&n.readyState===n.OPEN&&n.send(e),t.bcconnected&&Wn(t.bcChannel,e,t)};class Vx extends na{constructor(e,n,s,{connect:r=!0,awareness:i=new Mx(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=cr.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=Te();$(p,wn),ai(p,s),this.ws.send(pe(p))}},d)),this._bcSubscriber=(p,m)=>{if(m!==this){const g=Gu(this,new Uint8Array(p),!1);ra(g)>1&&Wn(this.bcChannel,pe(g),this)}},this._updateHandler=(p,m)=>{if(m!==this){const g=Te();$(g,wn),Rx(g,p),io(this,pe(g))}},this.doc.on("update",this._updateHandler),this._awarenessUpdateHandler=({added:p,updated:m,removed:g},x)=>{const b=p.concat(m).concat(g),S=Te();$(S,ss),Se(S,ns(i,b)),io(this,pe(S))},this._exitHandler=()=>{_a(this.awareness,[s.clientID],"app closed")},fn&&typeof process<"u"&&process.on("exit",this._exitHandler),i.on("update",this._awarenessUpdateHandler),this._checkInterval=setInterval(()=>{this.wsconnected&&cl<hn()-this.wsLastMessageReceived&&Fo(this,this.ws,null)},cl/10),r&&this.connect()}get url(){const e=Ux(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(),fn&&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||(Ox(this.bcChannel,this._bcSubscriber),this.bcconnected=!0);const e=Te();$(e,wn),ai(e,this.doc),Wn(this.bcChannel,pe(e),this);const n=Te();$(n,wn),qu(n,this.doc),Wn(this.bcChannel,pe(n),this);const s=Te();$(s,Ku),Wn(this.bcChannel,pe(s),this);const r=Te();$(r,ss),Se(r,ns(this.awareness,[this.doc.clientID])),Wn(this.bcChannel,pe(r),this)}disconnectBc(){const e=Te();$(e,ss),Se(e,ns(this.awareness,[this.doc.clientID],new Map)),io(this,pe(e)),this.bcconnected&&(Px(this.bcChannel,this._bcSubscriber),this.bcconnected=!1)}disconnect(){this.shouldConnect=!1,this.disconnectBc(),this.ws!==null&&Fo(this,this.ws,null)}connect(){this.shouldConnect=!0,!this.wsconnected&&this.ws===null&&(Ju(this),this.connectBc())}}const Dn=t=>ls((e,n)=>{t.onerror=s=>n(new Error(s.target.error)),t.onsuccess=s=>e(s.target.result)}),Hx=(t,e)=>ls((n,s)=>{const r=indexedDB.open(t);r.onupgradeneeded=i=>e(i.target.result),r.onerror=i=>s(Tt(i.target.error)),r.onsuccess=i=>{const a=i.target.result;a.onversionchange=()=>{a.close()},n(a)}}),qx=t=>Dn(indexedDB.deleteDatabase(t)),Wx=(t,e)=>e.forEach(n=>t.createObjectStore.apply(t,n)),As=(t,e,n="readwrite")=>{const s=t.transaction(e,n);return e.map(r=>eb(s,r))},Yu=(t,e)=>Dn(t.count(e)),Kx=(t,e)=>Dn(t.get(e)),Xu=(t,e)=>Dn(t.delete(e)),Gx=(t,e,n)=>Dn(t.put(e,n)),Io=(t,e)=>Dn(t.add(e)),Jx=(t,e,n)=>Dn(t.getAll(e,n)),Yx=(t,e,n)=>{let s=null;return Qx(t,e,r=>(s=r,!1),n).then(()=>s)},Xx=(t,e=null)=>Yx(t,e,"prev"),Zx=(t,e)=>ls((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()}}),Qx=(t,e,n,s="next")=>Zx(t.openKeyCursor(e,s),r=>n(r.key)),eb=(t,e)=>t.objectStore(e),tb=(t,e)=>IDBKeyRange.upperBound(t,e),nb=(t,e)=>IDBKeyRange.lowerBound(t,e),oo="custom",Zu="updates",Qu=500,eh=(t,e=()=>{},n=()=>{})=>{const[s]=As(t.db,[Zu]);return Jx(s,nb(t._dbref,!1)).then(r=>{t._destroyed||(e(s),fe(t.doc,()=>{r.forEach(i=>uu(t.doc,i))},t,!1),n(s))}).then(()=>Xx(s).then(r=>{t._dbref=r+1})).then(()=>Yu(s).then(r=>{t._dbsize=r})).then(()=>s)},sb=(t,e=!0)=>eh(t).then(n=>{(e||t._dbsize>=Qu)&&Io(n,va(t.doc)).then(()=>Xu(n,tb(t._dbref,!0))).then(()=>Yu(n).then(s=>{t._dbsize=s}))});class rb extends vd{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=Hx(e,s=>Wx(s,[["updates",{autoIncrement:!0}],["custom"]])),this.whenSynced=ls(s=>this.on("synced",()=>s(this))),this._db.then(s=>{this.db=s,eh(this,a=>Io(a,va(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]=As(this.db,[Zu]);Io(i,s),++this._dbsize>=Qu&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{sb(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(()=>{qx(this.name)})}get(e){return this._db.then(n=>{const[s]=As(n,[oo],"readonly");return Kx(s,e)})}set(e,n){return this._db.then(s=>{const[r]=As(s,[oo]);return Gx(r,n,e)})}del(e){return this._db.then(n=>{const[s]=As(n,[oo]);return Xu(s,e)})}}const ll=[["#1677c8","#1677c833"],["#d65745","#d6574533"],["#16866a","#16866a33"],["#9a58b5","#9a58b533"],["#d27b18","#d27b1833"],["#3f7d20","#3f7d2033"],["#be3e7b","#be3e7b33"],["#4964c6","#4964c633"],["#8a6a14","#8a6a1433"],["#087f8c","#087f8c33"]],dl=4,ul=5;function ib(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"||typeof e.updatedAt!="string"||!n||typeof n.id!="string"||typeof n.username!="string"||typeof n.name!="string"?null:e}function hl(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[n,s]of Object.entries(t)){const r=ib(s);r&&r.mainFile===n&&(e[n]=r)}return e}class ob{constructor(e,n){this.projectId=e,this.user=n;const s=window.location.protocol==="https:"?"wss:":"ws:";this.persistence=new rb(`texlite:${n.id}:${e}`,this.doc),this.persistence.on("synced",()=>{this.localDraftReady=!0;for(const r of this.draftListeners)r()}),this.provider=new Vx(`${s}//${window.location.host}/api/collaboration`,e,this.doc,{connect:!1,disableBc:!0,maxBackoffTime:2500}),this.awareness=this.provider.awareness,this.provider.messageHandlers[dl]=(r,i)=>{const a=Dt(i),c=this.flushRequests.get(a);if(!c)return;const l=J(i),d=Dt(i);window.clearTimeout(c.timer),this.flushRequests.delete(a),c.resolve({revision:l,persistedAt:d})},this.provider.messageHandlers[ul]=(r,i)=>{const a=Dt(i),c=this.epochStorageKey(),l=ab(c);if(this.epoch&&this.epoch!==a||l&&l!==a){this.provider.disconnect(),this.rejectFlushes(new Error("Collaboration state changed")),this.persistence.clearData().then(()=>{fl(c,a),window.location.reload()});return}this.epoch=a,fl(c,a);const d=this.provider.ws;if(!d||d.readyState!==WebSocket.OPEN)return;const f=Te();$(f,ul),Jt(f,a),d.send(pe(f));const u=Te();$(u,0),ai(u,this.doc),d.send(pe(u));const p=Te();$(p,1),Se(p,ns(this.awareness,[this.doc.clientID])),d.send(pe(p))},this.provider.on("status",({status:r})=>{r==="disconnected"&&this.rejectFlushes(new Error("Collaboration connection closed"))}),this.updateLocalAwareness()}projectId;user;doc=new kn;provider;awareness;persistence;permission="read";activeFile="";epoch=null;destroyed=!1;localDraftReady=!1;draftListeners=new Set;flushRequests=new Map;connect(){this.destroyed||(this.provider.connect(),this.updateLocalAwareness())}getText(e){return this.doc.getText(`source:${e}`)}applyTextEdits(e,n){if(this.permission==="read")throw new Error("Read-only collaborators cannot edit source files");const s=this.getText(e);let r=0;for(const i of n){if(!Number.isInteger(i.from)||!Number.isInteger(i.to)||i.from<r||i.to<i.from||i.to>s.length)throw new RangeError("Invalid collaborative text edits");r=i.to}this.doc.transact(()=>{for(let i=n.length-1;i>=0;i-=1){const a=n[i];a.to>a.from&&s.delete(a.from,a.to-a.from),a.replacement&&s.insert(a.from,a.replacement)}})}get meta(){return this.doc.getMap("texlite:meta")}get synced(){return this.provider.synced}get connected(){return this.provider.wsconnected}get draftReady(){return this.localDraftReady}onDraftReady(e){return this.draftListeners.add(e),this.localDraftReady&&e(),()=>this.draftListeners.delete(e)}setPermission(e){this.permission=e,this.updateLocalAwareness()}setActiveFile(e){this.activeFile!==e&&(this.activeFile=e,this.awareness.setLocalStateField("cursor",null),this.updateLocalAwareness())}sessions(){const e=[];return this.awareness.getStates().forEach((n,s)=>{const r=n?.user;!r||typeof r.id!="string"||typeof r.name!="string"||e.push({clientId:s,userId:r.id,username:typeof r.username=="string"?r.username:r.name,name:r.name,color:typeof r.color=="string"?r.color:"#1677c8",colorLight:typeof r.colorLight=="string"?r.colorLight:"#1677c833",permission:r.permission==="owner"||r.permission==="edit"?r.permission:"read",filePath:typeof n.filePath=="string"?n.filePath:"",editing:!!n.cursor,local:s===this.doc.clientID})}),e.sort((n,s)=>Number(s.local)-Number(n.local)||n.name.localeCompare(s.name))}flush(){const e=this.provider.ws;if(!this.provider.synced||!e||e.readyState!==WebSocket.OPEN)return Promise.reject(new Error("Collaboration connection is unavailable"));const n=crypto.randomUUID(),s=Te();return $(s,dl),Jt(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(pe(s))})}reconnect(){this.destroyed||(this.rejectFlushes(new Error("Collaboration connection reset")),this.provider.disconnect(),this.provider.connect(),this.updateLocalAwareness())}destroy(){this.destroyed=!0,this.rejectFlushes(new Error("Collaboration connection closed")),this.provider.destroy(),this.persistence.destroy(),this.draftListeners.clear(),this.doc.destroy()}rejectFlushes(e){for(const n of this.flushRequests.values())window.clearTimeout(n.timer),n.reject(e);this.flushRequests.clear()}updateLocalAwareness(){const[e,n]=ll[Math.abs(this.doc.clientID)%ll.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 ab(t){try{return window.localStorage.getItem(t)}catch{return null}}function fl(t,e){try{window.localStorage.setItem(t,e)}catch{}}function cb(t,e){return Array.from(t.trim()||e.trim()||"?")[0]?.toLocaleUpperCase()??"?"}function lb({sessions:t,status:e}){const{t:n}=Oe(),[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:[cb(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 db({value:t,onChange:e}){const{t:n}=Oe(),[s,r]=h.useState(!1),i=h.useRef(null),a=[{value:"editor-pdf",icon:Ec},{value:"editor-only",icon:Fm},{value:"pdf-only",icon:Im}];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(Ec,{size:15}),o.jsxs("span",{children:[o.jsx("small",{children:n("editor.layout.label")}),n(`editor.layout.${t}.name`)]}),o.jsx(pd,{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(vm,{size:16})]},c.value)})]})]})}function ub({comment:t,currentUserId:e,onFocus:n,onToggle:s,onReply:r,onEdit:i,onDelete:a,onEditReply:c,onDeleteReply:l}){const{t:d}=Oe(),[f,u]=h.useState(!1),[p,m]=h.useState(""),[g,x]=h.useState(!1),[b,S]=h.useState(t.content),[k,T]=h.useState(!1),[N,O]=h.useState(null),[I,D]=h.useState(""),[G,v]=h.useState(null),A=async C=>{C.preventDefault(),p.trim()&&await r(p)&&(m(""),u(!1))},te=async C=>{C.preventDefault(),b.trim()&&await i(b)&&x(!1)},z=async C=>{C.preventDefault(),!(!N||!I.trim())&&await c(N,I)&&O(null)},P=t.authorUsername,_=C=>new Date(C).toLocaleString(ge.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??P??d("editor.deletedUser")}),P&&o.jsxs("small",{children:["@",P]})]}),o.jsxs("span",{className:"comment-times",children:[o.jsx("time",{dateTime:t.createdAt,title:new Date(t.createdAt).toISOString(),children:_(t.createdAt)}),t.editedAt&&o.jsx("small",{children:d("editor.editedAt",{time:_(t.editedAt)})})]})]}),o.jsx("div",{className:"comment-location",children:t.orphaned?d("editor.orphaned"):d("editor.line",{line:t.startLine})}),t.selectedText&&o.jsx("blockquote",{className:"comment-selected-text",children:t.selectedText}),g?o.jsxs("form",{className:"comment-reply-form comment-edit-form",onSubmit:C=>{te(C)},onClick:C=>C.stopPropagation(),children:[o.jsx("textarea",{autoFocus:!0,rows:4,value:b,onChange:C=>S(C.target.value)}),o.jsxs("div",{children:[o.jsx("button",{type:"button",onClick:()=>x(!1),children:d("common.cancel")}),o.jsxs("button",{className:"primary",type:"submit",disabled:!b.trim(),children:[o.jsx(qr,{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(C=>o.jsxs("div",{className:"comment-reply",children:[o.jsxs("header",{children:[o.jsxs("span",{className:"comment-author",children:[o.jsx("strong",{children:C.authorDisplayName??C.authorUsername??d("editor.deletedUser")}),C.authorUsername&&o.jsxs("small",{children:["@",C.authorUsername]})]}),o.jsxs("span",{className:"comment-times",children:[o.jsx("time",{dateTime:C.createdAt,title:new Date(C.createdAt).toISOString(),children:_(C.createdAt)}),C.editedAt&&o.jsx("small",{children:d("editor.editedAt",{time:_(C.editedAt)})})]})]}),N===C.id?o.jsxs("form",{className:"comment-reply-form comment-edit-form",onSubmit:U=>{z(U)},onClick:U=>U.stopPropagation(),children:[o.jsx("textarea",{autoFocus:!0,rows:3,value:I,onChange:U=>D(U.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:!I.trim(),children:[o.jsx(qr,{size:13}),d("editor.saveChanges")]})]})]}):o.jsx("p",{className:"comment-content",children:C.content}),C.authorId===e&&N!==C.id&&o.jsxs("div",{className:"comment-owner-actions",children:[o.jsx("button",{title:d("editor.editReply"),"aria-label":d("editor.editReply"),onClick:U=>{U.stopPropagation(),O(C.id),D(C.content)},children:o.jsx(Co,{size:12})}),o.jsx("button",{className:"danger-text",title:d("editor.deleteReply"),"aria-label":d("editor.deleteReply"),onClick:U=>{U.stopPropagation(),v(C.id)},children:o.jsx(dn,{size:12})})]})]},C.id))}),o.jsxs("div",{className:"comment-actions",children:[o.jsxs("button",{className:"resolve",onClick:C=>{C.stopPropagation(),s()},children:[t.resolved?o.jsx(Um,{size:13}):o.jsx(jm,{size:13}),t.resolved?d("editor.reopen"):d("editor.resolve")]}),o.jsxs("button",{className:"reply-action",onClick:C=>{C.stopPropagation(),u(U=>!U)},children:[o.jsx($m,{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:C=>{C.stopPropagation(),S(t.content),x(!0)},children:o.jsx(Co,{size:13})}),o.jsx("button",{className:"danger-text",title:d("editor.deleteComment"),"aria-label":d("editor.deleteComment"),onClick:C=>{C.stopPropagation(),T(!0)},children:o.jsx(dn,{size:13})})]})]}),f&&o.jsxs("form",{className:"comment-reply-form",onSubmit:C=>{A(C)},onClick:C=>C.stopPropagation(),children:[o.jsx("textarea",{autoFocus:!0,rows:3,value:p,placeholder:d("editor.replyPlaceholder"),onChange:C=>m(C.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(Bm,{size:13}),d("editor.sendReply")]})]})]})]}),o.jsx(is,{open:k,title:d("editor.deleteCommentTitle"),description:d("editor.deleteCommentDescription",{count:t.replies.length}),confirmLabel:d("common.delete"),danger:!0,onCancel:()=>T(!1),onConfirm:()=>{a().then(C=>{C&&T(!1)})}}),o.jsx(is,{open:!!G,title:d("editor.deleteReplyTitle"),description:d("editor.deleteReplyDescription"),confirmLabel:d("common.delete"),danger:!0,onCancel:()=>v(null),onConfirm:()=>{G&&l(G).then(C=>{C&&v(null)})}})]})}function hb({open:t,onOpenChange:e,project:n,projectId:s}){const{t:r}=Oe(),[i,a]=h.useState([]),[c,l]=h.useState([]),[d,f]=h.useState(""),[u,p]=h.useState("read"),[m,g]=h.useState(null),[x,b]=h.useState(""),S=n.permission==="owner",k=async()=>{try{const[D,G]=await Promise.all([L(`/api/projects/${s}/members`),L("/api/users")]);a(D.members),l(G.users.filter(v=>v.id!==n.ownerId))}catch(D){b(V(D))}};h.useEffect(()=>{t&&k()},[t,s]);const T=async()=>{if(d)try{await L(`/api/projects/${s}/members/${d}`,{method:"PUT",body:JSON.stringify({permission:u})}),f(""),p("read"),await k()}catch(D){b(V(D))}},N=async(D,G)=>{try{await L(`/api/projects/${s}/members/${D.id}`,{method:"PUT",body:JSON.stringify({permission:G})}),await k()}catch(v){b(V(v))}},O=async()=>{if(m)try{await L(`/api/projects/${s}/members/${m.id}`,{method:"DELETE"}),g(null),await k()}catch(D){b(V(D))}},I=c.filter(D=>!i.some(G=>G.id===D.id));return o.jsxs(o.Fragment,{children:[o.jsx(Me,{open:t,wide:!0,title:r("projectSettings.share"),description:r("projectSettings.shareDescription"),onOpenChange:e,footer:o.jsx("button",{onClick:()=>e(!1),children:r("common.close")}),children:o.jsxs("div",{className:"share-dialog",children:[x&&o.jsx("p",{className:"error",children:x}),o.jsxs("div",{className:"share-owner",children:[o.jsx(Vs,{size:17}),o.jsxs("span",{children:[o.jsx("small",{children:r("projects.owner")}),o.jsx("strong",{children:n.ownerDisplayName??n.ownerUsername})]})]}),S&&o.jsxs("div",{className:"share-add",children:[o.jsxs("label",{className:"form-field",children:[r("common.user"),o.jsxs("select",{value:d,onChange:D=>f(D.target.value),children:[o.jsx("option",{value:"",children:r("projectSettings.chooseUser")}),I.map(D=>o.jsx("option",{value:D.id,children:D.displayName??D.username},D.id))]})]}),o.jsxs("label",{className:"form-field",children:[r("common.permission"),o.jsxs("select",{value:u,onChange:D=>p(D.target.value),children:[o.jsx("option",{value:"read",children:r("common.readOnly")}),o.jsx("option",{value:"edit",children:r("common.readWrite")})]})]}),o.jsxs("button",{className:"primary icon-button",disabled:!d,onClick:()=>{T()},children:[o.jsx(xd,{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(D=>o.jsxs("div",{className:"shared-member",children:[o.jsxs("span",{className:"member-identity",children:[o.jsx("span",{className:"member-avatar",children:(D.displayName??D.username).slice(0,1).toLocaleUpperCase()}),o.jsxs("span",{children:[o.jsx("strong",{children:D.displayName??D.username}),o.jsxs("small",{children:["@",D.username]})]})]}),o.jsxs("span",{className:"member-controls",children:[o.jsxs("select",{"aria-label":r("common.permission"),disabled:!S,value:D.permission,onChange:G=>{N(D,G.target.value)},children:[o.jsx("option",{value:"read",children:r("common.readOnly")}),o.jsx("option",{value:"edit",children:r("common.readWrite")})]}),S&&o.jsx("button",{className:"icon-only danger-text",title:r("common.remove"),"aria-label":r("common.remove"),onClick:()=>g(D),children:o.jsx(dn,{size:15})})]})]},D.id)),i.length===0&&o.jsxs("div",{className:"share-empty",children:[o.jsx(Vs,{size:24}),o.jsx("span",{children:r("projectSettings.noMembers")})]})]})]})}),o.jsx(is,{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 fb({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}=Oe(),[g,x]=h.useState(t.engine),[b,S]=h.useState(""),[k,T]=h.useState(t.name),[N,O]=h.useState(t.mainFile),[I,D]=h.useState(""),[G,v]=h.useState(""),[A,te]=h.useState(""),[z,P]=h.useState("appearance"),[_,C]=h.useState(a),U=t.permission==="owner",le=t.permission!=="read",ce=t.permission!=="read";h.useEffect(()=>C(a),[a]),h.useEffect(()=>{if(!t.latexmkrc)return S("");L(`/api/projects/${e}/file?path=${encodeURIComponent(t.latexmkrc)}`).then(({content:E})=>S(E)).catch(E=>D(V(E)))},[t.latexmkrc]);const xe=s.filter(E=>E.type==="file"&&/\.tex$/i.test(E.path)).map(E=>E.path),se=[...new Set(t.mainFile.toLowerCase().endsWith(".tex")?[...xe,t.mainFile]:xe)].sort((E,W)=>E.localeCompare(W)),de=async()=>{try{const E=b.trim()&&n.allowProjectLatexmkrc!==!1?".latexmkrc":null;E&&await L(`/api/projects/${e}/file`,{method:"PUT",body:JSON.stringify({path:E,content:b})});const W=await L(`/api/projects/${e}`,{method:"PATCH",body:JSON.stringify({name:k,mainFile:N,engine:g,latexmkrc:E})});p(W.project)}catch(E){D(V(E))}},Y=()=>c(_),ve=async()=>{const E=G.trim();if(E)try{const W=await L(`/api/projects/${e}/dictionary`,{method:"POST",body:JSON.stringify({word:E})});i(W.words),v(""),te("")}catch(W){te(V(W))}},ye=async E=>{try{const W=await L(`/api/projects/${e}/dictionary/${encodeURIComponent(E)}`,{method:"DELETE"});i(W.words),te("")}catch(W){te(V(W))}};return o.jsxs("div",{className:"settings padded",children:[I&&o.jsx("p",{className:"error",children:I}),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":z==="appearance","aria-controls":"settings-panel-appearance",className:`settings-tab${z==="appearance"?" active":""}`,onClick:()=>P("appearance"),children:[o.jsx(Oc,{size:15}),m("projectSettings.editorTab")]}),o.jsxs("button",{id:"settings-tab-compiler",type:"button",role:"tab","aria-selected":z==="compiler","aria-controls":"settings-panel-compiler",className:`settings-tab${z==="compiler"?" active":""}`,onClick:()=>P("compiler"),children:[o.jsx(Fr,{size:15}),m("projectSettings.compilerTab")]})]}),z==="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(Oc,{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:_.font,onChange:E=>C({..._,font:E.target.value}),children:Kr.map(E=>o.jsx("option",{value:E.id,children:m(E.labelKey)},E.id))})]}),o.jsxs("label",{children:[m("projectSettings.fontSize"),o.jsx("select",{value:_.fontSize,onChange:E=>C({..._,fontSize:Number(E.target.value)}),children:[12,13,14,15,16,18,20].map(E=>o.jsxs("option",{value:E,children:[E," px"]},E))})]}),o.jsxs("label",{children:[m("projectSettings.lineHeight"),o.jsxs("select",{value:_.lineHeight,onChange:E=>C({..._,lineHeight:Number(E.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:_.lineWrapping,onChange:E=>C({..._,lineWrapping:E.target.checked})}),o.jsx(qm,{size:15}),o.jsx("span",{children:m("projectSettings.lineWrapping")})]}),o.jsxs("label",{className:"editor-checkbox",children:[o.jsx("input",{type:"checkbox",checked:_.spellCheck,onChange:E=>C({..._,spellCheck:E.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("label",{className:"editor-checkbox",children:[o.jsx("input",{type:"checkbox",checked:_.vimMode,onChange:E=>C({..._,vimMode:E.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("label",{className:"editor-checkbox",children:[o.jsx("input",{type:"checkbox",disabled:!le,checked:_.formatOnCompile,onChange:E=>C({..._,formatOnCompile:E.target.checked})}),o.jsx(ud,{size:15}),o.jsx("span",{children:m("projectSettings.formatOnCompile")})]}),o.jsxs("p",{className:"field-hint",children:[m(le?"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(Hm,{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(Sm,{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(md,{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(Xo,{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(Cm,{size:14})})]})]}),o.jsxs("div",{className:"settings-section-title",children:[o.jsx(fd,{size:15}),o.jsx("strong",{children:m("projectSettings.dictionary")})]}),o.jsx("p",{className:"settings-description",children:m("projectSettings.dictionaryDescription")}),A&&o.jsx("p",{className:"error dictionary-error",children:A}),ce&&o.jsxs("div",{className:"dictionary-add",children:[o.jsx("input",{value:G,placeholder:m("projectSettings.dictionaryPlaceholder"),onChange:E=>v(E.target.value),onKeyDown:E=>{E.key==="Enter"&&(E.preventDefault(),ve())}}),o.jsx("button",{type:"button",disabled:!G.trim(),onClick:()=>{ve()},children:m("projectSettings.addWord")})]}),o.jsxs("div",{className:"dictionary-words",children:[r.map(E=>o.jsxs("span",{className:"dictionary-word",children:[o.jsx("code",{children:E}),ce&&o.jsx("button",{type:"button",title:m("common.delete"),"aria-label":`${m("common.delete")} ${E}`,onClick:()=>{ye(E)},children:o.jsx(Qo,{size:13})})]},E)),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:Y,children:[o.jsx(qr,{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(Fr,{size:15}),o.jsx("strong",{children:m("projectSettings.compilerTab")})]}),o.jsx("p",{className:"settings-description compiler-description",children:m("projectSettings.compilerDescription")}),o.jsxs("div",{className:"settings-section-title project-configuration",children:[o.jsx(Fr,{size:15}),o.jsx("strong",{children:m("projectSettings.projectConfiguration")})]}),o.jsxs("label",{children:[m("projects.name"),o.jsx("input",{disabled:!U,value:k,onChange:E=>T(E.target.value)})]}),o.jsxs("label",{children:[m("projectSettings.mainFile"),o.jsx("select",{disabled:!U||se.length===0,value:N,onChange:E=>O(E.target.value),children:se.map(E=>o.jsx("option",{value:E,children:E},E))})]}),o.jsxs("label",{children:[m("projectSettings.engine"),o.jsx("select",{disabled:!U,value:g,onChange:E=>x(E.target.value),children:(n.allowedEngines??["pdflatex","xelatex","lualatex"]).map(E=>o.jsx("option",{children:E},E))})]}),o.jsxs("label",{children:[m("projectSettings.latexmkrc"),o.jsx("textarea",{className:"latexmkrc-editor",rows:10,spellCheck:!1,disabled:!U||n.allowProjectLatexmkrc===!1,value:b,placeholder:m("projectSettings.latexmkrcPlaceholder"),onChange:E=>S(E.target.value)})]}),o.jsx("div",{className:"settings-actions",children:U&&o.jsxs("button",{className:"settings-save",onClick:()=>{de()},children:[o.jsx(qr,{size:15}),m("projectSettings.saveCompiler")]})})]})]})}function pl({diagnostics:t,files:e,empty:n,tone:s,onJump:r}){const{t:i}=Oe(),a=s==="error"?Zo:os;return t.length?o.jsx("div",{className:`compile-diagnostic-list compile-${s}`,children:t.map((c,l)=>{const d=gb(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 ao({lines:t,empty:e,tone:n="log"}){const s=n==="error"?Zo:n==="warning"?os:jo;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 pb({projectId:t,mainFile:e,artifacts:n,preview:s,loading:r,onView:i}){const{t:a}=Oe(),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(Gn,{size:14}),o.jsxs("span",{children:[o.jsx("strong",{children:l.path}),o.jsx("small",{children:yb(l.size)})]})]}),o.jsx("a",{href:c(l.path),title:a("editor.downloadArtifact"),"aria-label":a("editor.downloadArtifact"),children:o.jsx(Bs,{size:14})})]},l.path))}),o.jsx("div",{className:"artifact-preview",children:r?o.jsxs("div",{className:"compile-empty",children:[o.jsx(kt,{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(Bs,{size:13}),a("projects.download")]})]}),o.jsx("pre",{children:s.content})]}):o.jsxs("div",{className:"compile-empty",children:[o.jsx(Gn,{size:24}),o.jsx("span",{children:a("editor.selectArtifact")})]})})]}):o.jsxs("div",{className:"compile-empty",children:[o.jsx(wd,{size:26}),o.jsx("span",{children:a("editor.noArtifacts")})]})}function mb({mainFile:t,disabled:e,cleaning:n,onCleanCache:s,onCleanArtifacts:r}){const{t:i}=Oe();return o.jsxs("div",{className:"compile-clean-panel",children:[o.jsxs("div",{className:"compile-clean-intro",children:[o.jsx(os,{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(vo,{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(kt,{className:"spin",size:14}):o.jsx(vo,{size:14}),i("editor.cleanCache")]})]})]}),o.jsxs("article",{className:"danger",children:[o.jsx("div",{className:"compile-clean-action-icon",children:o.jsx(dn,{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(kt,{className:"spin",size:14}):o.jsx(dn,{size:14}),i("editor.cleanArtifacts")]})]})]})]})]})}function gb(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 yb(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`}function wb(t){return t instanceof Error&&t.name==="AbortError"}function xb({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,x]=h.useState(""),b=h.useRef(null),S=h.useRef(e),k=h.useRef(i),T=h.useRef(a),N=h.useRef(c);S.current=e,k.current=i,T.current=a,N.current=c;const O=async P=>{b.current?.abort();const _=new AbortController;b.current=_;try{const C=await L(`/api/projects/${t}/comments?path=${encodeURIComponent(P)}`,{signal:_.signal});S.current===P&&d(C.comments)}catch(C){!wb(C)&&S.current===P&&d([])}finally{b.current===_&&(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:x,addComment:async()=>{if(!(!g.trim()||!e))try{if(n!=="read"&&!await k.current())return;await L(`/api/projects/${t}/comments`,{method:"POST",body:JSON.stringify({path:e,content:g,...r})}),await O(e),m(!1),x(""),N.current()}catch(P){T.current(V(P))}},toggleComment:async P=>{try{await L(`/api/projects/${t}/comments/${P.id}`,{method:"PATCH",body:JSON.stringify({resolved:!P.resolved})}),await O(e)}catch(_){T.current(V(_))}},replyToComment:async(P,_)=>{try{return await L(`/api/projects/${t}/comments/${P.id}/replies`,{method:"POST",body:JSON.stringify({content:_})}),await O(e),!0}catch(C){return T.current(V(C)),!1}},editComment:async(P,_)=>{try{return await L(`/api/projects/${t}/comments/${P.id}`,{method:"PATCH",body:JSON.stringify({content:_})}),await O(e),!0}catch(C){return T.current(V(C)),!1}},deleteComment:async P=>{try{return await L(`/api/projects/${t}/comments/${P.id}`,{method:"DELETE"}),await O(e),u(_=>_?.id===P.id?null:_),!0}catch(_){return T.current(V(_)),!1}},editCommentReply:async(P,_,C)=>{try{return await L(`/api/projects/${t}/comments/${P.id}/replies/${_}`,{method:"PATCH",body:JSON.stringify({content:C})}),await O(e),!0}catch(U){return T.current(V(U)),!1}},deleteCommentReply:async(P,_)=>{try{return await L(`/api/projects/${t}/comments/${P.id}/replies/${_}`,{method:"DELETE"}),await O(e),!0}catch(C){return T.current(V(C)),!1}}}}function bb(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 vb(t,e,n,s,r){const[i]=h.useState(()=>new ob(t,e)),[a,c]=h.useState("connecting"),[l,d]=h.useState(!1),[f,u]=h.useState([]),[p,m]=h.useState(null),[g,x]=h.useState(null),[b,S]=h.useState(""),[k,T]=h.useState(""),[N,O]=h.useState(!1),I=h.useRef(n),D=h.useRef(r);return I.current=n,D.current=r,h.useEffect(()=>{const v=hl(i.meta.get("compileStates"));m(v[n]??null)},[n,i]),h.useEffect(()=>{const v=()=>u(i.sessions()),A=()=>{d(!1),u([]),m(null),x(null),S(""),T(""),D.current()},te=({status:U})=>{c(U),U!=="connected"&&A()},z=U=>{d(U),U||A()},P=()=>{c("disconnected"),A()},_=()=>{const U=i.meta.get("filesEvent");bb(U)&&x(U);const le=i.meta.get("commentsRevision");typeof le=="string"&&S(le);const ce=i.meta.get("dictionaryRevision");typeof ce=="string"&&T(ce);const xe=hl(i.meta.get("compileStates"));m(xe[I.current]??null)};i.awareness.on("change",v),i.provider.on("status",te),i.provider.on("sync",z),i.provider.on("connection-close",P),i.provider.on("connection-error",P),i.meta.observe(_);const C=i.onDraftReady(()=>O(!0));return v(),_(),c(i.connected?"connected":"connecting"),d(i.synced),()=>{i.awareness.off("change",v),i.provider.off("status",te),i.provider.off("sync",z),i.provider.off("connection-close",P),i.provider.off("connection-error",P),i.meta.unobserve(_),C(),i.destroy()}},[i]),h.useEffect(()=>{s&&i.connect()},[i,s]),{collaboration:i,status:a,synced:l,activeSessions:f,compileState:p,setCompileState:m,filesEvent:g,commentsRevision:b,dictionaryRevision:k,localDraftReady:N,reconnect:()=>{c("connecting"),d(!1),u([]),m(null),i.reconnect()}}}function Ls(t){return t instanceof Error&&t.name==="AbortError"}function Sb(t){fetch(t,{credentials:"same-origin",cache:"force-cache"}).then(e=>e.ok?e.arrayBuffer():void 0).catch(()=>{})}function Cb({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}=Oe(),[g,x]=h.useState(""),[b,S]=h.useState(!0),[k,T]=h.useState(null),[N,O]=h.useState(""),[I,D]=h.useState(null),[G,v]=h.useState(null),[A,te]=h.useState([]),[z,P]=h.useState(null),[_,C]=h.useState(!1),[U,le]=h.useState(!1),[ce,xe]=h.useState(()=>new Set),[se,de]=h.useState(""),Y=h.useRef(n),ve=h.useRef(""),ye=h.useRef(null),E=h.useRef(null),W=h.useRef(new Map),Ye=h.useRef(null),Ce=h.useRef(()=>{}),Z=h.useRef({onSharedState:i,save:a,loadOutline:c,onPreviewTab:l,onError:d,onCompileStart:f,onCompileSuccess:u,onPdfChanged:p});Y.current=n,Z.current={onSharedState:i,save:a,loadOutline:c,onPreviewTab:l,onError:d,onCompileStart:f,onCompileSuccess:u,onPdfChanged:p};const tt=H=>{Ye.current!==H&&(Ye.current=H,Z.current.onCompileSuccess())},ht=async(H,re)=>{re||(E.current?.abort(),E.current=new AbortController,re=E.current.signal);try{const q=H?`?mainFile=${encodeURIComponent(H)}`:"",He=await L(`/api/projects/${t}/compile/artifacts${q}`,{signal:re});Y.current===H&&(te(He.artifacts),P(null))}catch(q){!Ls(q)&&Y.current===H&&(te([]),P(null))}finally{E.current?.signal===re&&(E.current=null)}};h.useEffect(()=>{ye.current?.abort();const H=new AbortController;ye.current=H,S(!0),O(""),D(null),v(null),g&&n&&ve.current===n||(x(""),T(null)),te([]),P(null),Z.current.onPdfChanged();const q=n?`?mainFile=${encodeURIComponent(n)}`:"",He=L(`/api/projects/${t}/compile/latest${q}`,{signal:H.signal});let pt=!1;const M=()=>{pt||H.signal.aborted||!n||(pt=!0,ht(n,H.signal),Z.current.loadOutline(H.signal,n).catch(()=>{}))};return He.then(B=>{H.signal.aborted||n&&B.mainFile!==Y.current||(O(B.latestRun?.log??""),D(B.latestRun?.diagnostics??null),v(B.latestRun?.status==="succeeded"||B.latestRun?.status==="failed"?B.latestRun.status:null),n&&B.latestRun?.requestedBy&&(B.latestRun.status==="queued"||B.latestRun.status==="running")&&Z.current.onSharedState({mainFile:n,runId:B.latestRun.id,status:B.latestRun.status,requestedBy:B.latestRun.requestedBy,updatedAt:new Date().toISOString()}),B.pdfUrl&&(ve.current=B.mainFile,x(B.pdfUrl),T(B.pdfCompiledAt),Z.current.onPreviewTab("pdf"),e||Sb(B.pdfUrl)))}).catch(B=>{!Ls(B)&&Y.current===n&&Z.current.onError(V(B))}).finally(()=>{ye.current===H&&(ye.current=null),H.signal.aborted||S(!1),window.setTimeout(M,0)}),()=>H.abort()},[e?.id,t,n]),h.useEffect(()=>{!r||r.mainFile!==n||r.status!=="cleaned"||!r.cleanMode||(ye.current?.abort(),E.current?.abort(),r.cleanMode==="artifacts"?(O(""),D(null),v(null),x(""),T(null),te([]),P(null),Z.current.onPdfChanged(),Z.current.onPreviewTab("pdf"),de(m("editor.cleanArtifactsComplete"))):de(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 H=!1;ye.current?.abort();const re=new AbortController;return ye.current=re,S(!0),L(`/api/projects/${t}/compile/latest?mainFile=${encodeURIComponent(n)}`,{signal:re.signal}).then(q=>{H||q.mainFile!==Y.current||q.latestRun?.id!==r.runId||(O(q.latestRun.log),D(q.latestRun.diagnostics),v(r.status==="succeeded"?"succeeded":"failed"),r.status==="succeeded"&&q.pdfUrl?(Z.current.onPdfChanged(),x(q.pdfUrl),T(q.pdfCompiledAt),Z.current.onPreviewTab("pdf"),tt(r.runId),ht(n)):r.status==="failed"&&Z.current.onPreviewTab(q.latestRun.diagnostics.errors.length?"errors":"log"))}).catch(q=>{!Ls(q)&&!H&&Z.current.onError(V(q))}).finally(()=>{H||S(!1)}),()=>{H=!0,re.abort(),ye.current===re&&(ye.current=null)}},[r?.runId,r?.status,r?.mainFile,n,t]);const ft=async()=>{if(!e||!n||e.permission==="read"||!s||W.current.has(n)||r?.mainFile===n&&(r.status==="queued"||r.status==="running"))return;const H=n;xe(q=>new Set([...q,H])),Z.current.onCompileStart(),de(""),O(""),D(null),v(null),Z.current.onPreviewTab(g?"pdf":"log");const re=new AbortController;W.current.set(H,re);try{if(!await Z.current.save())return;const q=await L(`/api/projects/${t}/compile`,{method:"POST",signal:re.signal,body:JSON.stringify({mainFile:H})});if(q.mainFile!==Y.current)return;O(q.log),D(q.diagnostics),v(q.ok?"succeeded":"failed"),q.skipped&&de(m("editor.upToDate")),q.pdfUrl?(Z.current.onPdfChanged(),x(q.pdfUrl),T(q.pdfCompiledAt),Z.current.onPreviewTab("pdf"),q.ok&&(q.skipped?Z.current.onCompileSuccess():tt(q.runId))):Z.current.onPreviewTab(q.diagnostics.errors.length?"errors":"log")}catch(q){!Ls(q)&&Y.current===H&&Z.current.onError(V(q))}finally{W.current.get(H)===re&&(W.current.delete(H),xe(q=>{const He=new Set(q);return He.delete(H),He}))}},ze=async H=>{if(!e||!n||e.permission==="read"||!s||U||W.current.has(n)||r?.mainFile===n&&(r.status==="queued"||r.status==="running"))return;const re=n;le(!0),ye.current?.abort(),E.current?.abort();try{if((await L(`/api/projects/${t}/compile/clean`,{method:"POST",body:JSON.stringify({mainFile:re,mode:H})})).mainFile!==Y.current)return;Z.current.onSharedState(null),H==="artifacts"&&(O(""),D(null),v(null),x(""),T(null),te([]),P(null),Z.current.onPdfChanged()),de(m(H==="cache"?"editor.cleanCacheComplete":"editor.cleanArtifactsComplete"))}catch(q){!Ls(q)&&Y.current===re&&Z.current.onError(V(q))}finally{le(!1)}};Ce.current=()=>{ft()},h.useEffect(()=>{if(!se)return;const H=window.setTimeout(()=>de(""),3e3);return()=>window.clearTimeout(H)},[se]),h.useEffect(()=>{const H=re=>{!(re.ctrlKey||re.metaKey)||re.key.toLocaleLowerCase()!=="s"||(re.preventDefault(),re.stopPropagation(),re.repeat||Ce.current())};return window.addEventListener("keydown",H,!0),()=>window.removeEventListener("keydown",H,!0)},[]),h.useEffect(()=>()=>{ye.current?.abort(),E.current?.abort();for(const H of W.current.values())H.abort();W.current.clear()},[]);const at=async H=>{if(H.viewable){C(!0);try{const re=await L(`/api/projects/${t}/compile/artifacts?mainFile=${encodeURIComponent(n)}&path=${encodeURIComponent(H.path)}`);P(re)}catch(re){Z.current.onError(V(re))}finally{C(!1)}}};return{pdfUrl:g,pdfCompiledAt:k,pdfLoading:b,compileLog:N,compileDiagnostics:I,compileOutcome:G,artifacts:A,artifactPreview:z,artifactLoading:_,editorNotice:se,localCompiling:ce.has(n),cleaning:U,compile:ft,cleanCompile:ze,viewArtifact:at}}const ml=10*1024*1024,jb=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 gl(t){return t instanceof Error&&t.name==="AbortError"}function Fs(t){const e=t.split("/").filter(Boolean);return e.pop(),e.map((n,s)=>e.slice(0,s+1).join("/"))}function Vn(t,e){return!!(t&&e)&&(e===t||e.startsWith(`${t}/`))}function kb(t){const e=`.${t.split(".").at(-1)?.toLocaleLowerCase()??""}`;return!jb.has(e)}function Mo(t){return/(?:\.(?:tex|bib|sty|cls|txt|md)|latexmkrc)$/i.test(t)}function yl(t){const e=t.split(".").at(-1)?.toLocaleLowerCase()??"";return e==="pdf"?"pdf":["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif"].includes(e)?"image":kb(t)?"text":"unsupported"}function Eb(t,e){return`/api/projects/${t}/file/raw?path=${encodeURIComponent(e)}`}function Db({projectId:t,site:e,activeFile:n,dirty:s,save:r,onError:i,onProject:a,onActiveFile:c,onActiveMainFile:l,onRootDocuments:d}){const{t:f}=Oe(),[u,p]=h.useState([]),[m,g]=h.useState(!1),[x,b]=h.useState(""),[S,k]=h.useState(null),[T,N]=h.useState(!1),[O,I]=h.useState(!1),[D,G]=h.useState(""),[v,A]=h.useState(""),[te,z]=h.useState(""),[P,_]=h.useState(new Set),[C,U]=h.useState(null),[le,ce]=h.useState(""),[xe,se]=h.useState(null),[de,Y]=h.useState(!1),[ve,ye]=h.useState(null),[E,W]=h.useState(!1),Ye=h.useRef(null),Ce=h.useRef(null),Z=async(M={})=>{Ye.current?.abort(),Ye.current=null;const B=M.signal?null:new AbortController;B&&(Ye.current=B);try{const we=await L(`/api/projects/${t}/files`,{signal:M.signal??B?.signal});return(!M.isCurrent||M.isCurrent())&&p(we.files),we.files}catch(we){if(!gl(we))throw we;return}finally{B&&Ye.current===B&&(Ye.current=null)}},tt=async()=>{if(!(!x.trim()||x.trim().endsWith("/"))){A("");try{await L(`/api/projects/${t}/file`,{method:"POST",body:JSON.stringify({path:x,content:""})}),await Z(),c(x),_(M=>new Set([...M,...Fs(x)])),g(!1),b("")}catch(M){A(V(M))}}},ht=async()=>{if(!D.trim())return;A("");const M=te?`${te}/${D.trim()}`:D.trim();try{const B=await L(`/api/projects/${t}/folders`,{method:"POST",body:JSON.stringify({path:M})});await Z(),_(we=>new Set([...we,...Fs(B.path),B.path])),z(B.path),I(!1),G("")}catch(B){A(V(B))}},ft=async(M,B=new Set,we=te)=>{if(!M.length)return;const Le=e.maxUploadSizeMB??50;if(M.find(oe=>oe.size>Le*1024*1024))return i(f("errors.fileTooLarge",{size:Le}));const qe=we,Xe=M.map(oe=>qe?`${qe}/${oe.name}`:oe.name),en=new Map;for(const oe of Xe)en.set(oe,(en.get(oe)??0)+1);const vt=[...en.entries()].filter(([,oe])=>oe>1).map(([oe])=>oe);if(vt.length)return i(f("errors.duplicateUploadNames",{files:vt.join(", ")}));const mt=new Set(u.map(oe=>oe.path)),nt=[...new Set(Xe.filter(oe=>mt.has(oe)&&!B.has(oe)))];if(nt.length){ye({files:M,directory:qe,collisions:nt});return}ye(null),W(!0);try{const oe=new URLSearchParams;qe&&oe.set("directory",qe);let Ht="";for(const[ct,gt]of M.entries()){const Pt=Xe[ct];oe.delete("overwrite"),B.has(Pt)&&oe.set("overwrite","1");const st=oe.toString()?`?${oe.toString()}`:"",Nn=new FormData;Nn.append("file",gt);const Q=await fetch(`/api/projects/${t}/upload${st}`,{method:"POST",body:Nn}),rt=await Q.json().catch(()=>({}));if(!Q.ok){if(Q.status===409&&!B.has(Pt)&&rt.code==="FILE_EXISTS"){ct>0&&await Z(),ye({files:M.slice(ct),directory:qe,collisions:[typeof rt.path=="string"?rt.path:Pt]});return}throw new Error(Q.status===409?f("errors.pathConflict"):Uo(rt,Q.status,"errors.upload"))}typeof rt.path=="string"&&Mo(rt.path)&&(Ht=rt.path)}await Z(),Ht&&c(Ht)}catch(oe){i(V(oe))}finally{W(!1)}},ze=async M=>{await ft(Array.from(M.target.files??[])),M.target.value=""},at=async M=>{Ce.current?.abort(),Ce.current=null,N(!1);const B=Eb(t,M.path);if((M.size??0)>ml){k({path:M.path,kind:"large",size:M.size??0,url:B});return}const we=yl(M.path);if(we!=="text"){k({path:M.path,kind:we,size:M.size??0,url:B});return}k({path:M.path,kind:we,size:M.size??0,url:B,content:""}),N(!0);const Le=new AbortController;Ce.current=Le;try{const ae=await fetch(B,{signal:Le.signal}),qe=await ae.text();if(!ae.ok)throw new Error(qe||f("errors.request",{status:ae.status}));k(Xe=>Xe?.path===M.path?{...Xe,content:qe}:Xe)}catch(ae){gl(ae)||(k(null),i(V(ae)))}finally{Ce.current===Le&&(Ce.current=null,N(!1))}},H=M=>{const B=yl(M.path);(M.size??0)>ml||B!=="text"||!Mo(M.path)?at(M):c(M.path)},re=async()=>{if(C){A("");try{if(!await r())return;const M=await L(`/api/projects/${t}/path`,{method:"PATCH",body:JSON.stringify({source:C.path,destinationDirectory:le})}),B=ae=>ae===C.path?M.path:ae.startsWith(`${C.path}/`)?`${M.path}${ae.slice(C.path.length)}`:ae;c(ae=>B(ae)),l(ae=>B(ae)),d(ae=>new Set([...ae].map(B))),z(ae=>ae&&B(ae));const[we,Le]=await Promise.all([L(`/api/projects/${t}/files`),L(`/api/projects/${t}`)]);p(we.files),a(Le.project),_(ae=>new Set([...ae,...Fs(M.path),le].filter(Boolean))),U(null),ce("")}catch(M){A(V(M))}}},q=async()=>{if(xe){A("");try{if(s&&!await r())return;await L(`/api/projects/${t}/file?path=${encodeURIComponent(xe.path)}`,{method:"DELETE"}),se(null)}catch(M){A(V(M))}}};h.useEffect(()=>()=>{Ye.current?.abort(),Ce.current?.abort()},[]),h.useEffect(()=>{Ce.current?.abort(),Ce.current=null,N(!1)},[n]);const He=u.filter(M=>M.type==="directory"),pt=u.filter(M=>Fs(M.path).every(B=>P.has(B)));return{files:u,setFiles:p,loadFiles:Z,newFileOpen:m,setNewFileOpen:g,newFilePath:x,setNewFilePath:b,resourcePreview:S,setResourcePreview:k,resourcePreviewLoading:T,setResourcePreviewLoading:N,newFolderOpen:O,setNewFolderOpen:I,newFolderName:D,setNewFolderName:G,fileDialogError:v,setFileDialogError:A,selectedFolder:te,setSelectedFolder:z,expandedFolders:P,setExpandedFolders:_,moveEntry:C,setMoveEntry:U,moveDestination:le,setMoveDestination:ce,deleteEntry:xe,setDeleteEntry:se,fileDragActive:de,setFileDragActive:Y,uploadConflict:ve,setUploadConflict:ye,uploadingFiles:E,directoryEntries:He,visibleEntries:pt,createFile:tt,createFolder:ht,uploadFiles:ft,upload:ze,openFile:H,movePath:re,removePath:q}}function Nb({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),x=h.useRef(n),b=h.useRef(e),S=h.useRef(0);x.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 I=n,D=e,G=window.setTimeout(()=>{Zt(async()=>{const{lintLatex:v}=await import("./spellCheck-BHW5bumN.js");return{lintLatex:v}},__vite__mapDeps([2,1])).then(({lintLatex:v})=>{if(!(O!==g.current||x.current!==I||b.current!==D))return v(I,s).then(A=>{O!==g.current||x.current!==I||b.current!==D||(i(A),c(I),d(D),u(0),m(null))})}).catch(()=>{})},700);return()=>window.clearTimeout(G)},[t,e,n,s]);const k=l===e&&a===n,T=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:T,jumpToIssue:O=>{if(!r.length)return;const I=Math.max(0,Math.min(O,r.length-1)),D=r[I];u(I),m({from:D.from,to:D.to,nonce:++S.current})}}}function wl(t){return t instanceof Error&&t.name==="AbortError"}function Tb({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),x=h.useRef(s),b=h.useRef(r),S=h.useRef(i);g.current=n,x.current=s,b.current=r,S.current=i,h.useEffect(()=>(p.current?.abort(),p.current=null,c(null),d(null),u(null),()=>p.current?.abort()),[t,e]);const k=(I,D,G)=>{u({path:I,line:D,column:G,nonce:++m.current}),g.current!==I&&x.current(I)},T=async(I,D,G,v={})=>{p.current?.abort();const A=new AbortController;p.current=A;try{const te=await L(`/api/projects/${t}/sync/pdf?mainFile=${encodeURIComponent(e)}&path=${encodeURIComponent(I)}&line=${D}&column=${G}`,{signal:A.signal});if(p.current!==A||!te)return;c({...te,nonce:++m.current}),S.current()}catch(te){!wl(te)&&!v.silent&&b.current(V(te))}finally{p.current===A&&(p.current=null)}},N=async(I,D,G)=>{p.current?.abort();const v=new AbortController;p.current=v;try{const A=await L(`/api/projects/${t}/sync/source?mainFile=${encodeURIComponent(e)}&page=${I}&x=${D}&y=${G}`,{signal:v.signal});if(p.current!==v)return;k(A.path,A.line,A.column)}catch(A){wl(A)||b.current(V(A))}finally{p.current===v&&(p.current=null)}};return{pdfTarget:a,pdfViewport:l,sourceJump:f,setPdfViewport:d,clearPdfViewport:()=>d(null),jumpToSource:k,syncSourceToPdf:T,syncPdfToSource:N,syncVisiblePdfToSource:()=>{l&&N(l.page,l.x,l.y)}}}function th(t,e){return`texlite.workspaceLayout:${encodeURIComponent(t)}:${encodeURIComponent(e)}`}function xl(t,e){try{const n=window.localStorage.getItem(th(t,e));if(n==="editor-pdf"||n==="editor-only"||n==="pdf-only")return n}catch{}return"editor-pdf"}function Ob(t,e){const[n,s]=h.useState(()=>xl(t,e));return h.useEffect(()=>{s(xl(t,e))},[t,e]),{workspaceLayout:n,setWorkspaceLayout:i=>{s(i);try{window.localStorage.setItem(th(t,e),i)}catch{}}}}const nh=()=>Zt(()=>import("./PdfPreview-IfkmLMSU.js"),__vite__mapDeps([3,1,4,5])),Pb=h.lazy(()=>nh().then(t=>({default:t.PdfPreview}))),_b=h.lazy(()=>Zt(()=>import("./LatexEditor-Dp8EoZBP.js"),__vite__mapDeps([6,1,7])).then(t=>({default:t.LatexEditor}))),Rb=h.lazy(()=>Zt(()=>import("./GitDialog-9mNxx8oX.js"),__vite__mapDeps([8,1,5])).then(t=>({default:t.GitDialog}))),Lb=h.lazy(()=>Zt(()=>import("./HistoryDialog-CmoD9Cvf.js"),__vite__mapDeps([9,1,0])).then(t=>({default:t.HistoryDialog}))),Ab=h.lazy(()=>Zt(()=>import("./ProjectNavigationDialogs-veKVnRxc.js"),__vite__mapDeps([10,1])).then(t=>({default:t.ProjectSearchDialog}))),Fb=h.lazy(()=>Zt(()=>import("./ProjectNavigationDialogs-veKVnRxc.js"),__vite__mapDeps([10,1])).then(t=>({default:t.QuickOpenDialog}))),Ib=h.lazy(()=>Zt(()=>import("./SystemMetricsDialog-D_oiVmBC.js"),__vite__mapDeps([11,1])).then(t=>({default:t.SystemMetricsDialog}))),Ze=8;function Kn(t){return t instanceof Error&&t.name==="AbortError"}function Mb(){const{t}=Oe(),[e,n]=h.useState({siteName:"TexLite",adminEmail:""}),[s,r]=h.useState(),[i,a]=h.useState(()=>typeof window>"u"?null:Pr(window.location.pathname)),[c,l]=h.useState(null);h.useEffect(()=>{const p=Pr(window.location.pathname);if(p&&window.location.pathname!==Ki(p)){const x={texliteRoute:"project",projectId:p,fromDashboard:!1};window.history.replaceState(x,"",Ki(p))}const m=()=>a(Pr(window.location.pathname)),g=()=>{if(l(null),r(null),Pr(window.location.pathname)){const x={texliteRoute:"dashboard"};window.history.replaceState(x,"","/"),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=Ki(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(ng(p)&&p.fromDashboard){window.history.back();return}const m={texliteRoute:"dashboard"};window.history.replaceState(m,"","/"),a(null)};if(h.useEffect(()=>{L("/api/config").then(p=>{n(p),document.title=p.siteName}),L("/api/me").then(({user:p})=>r(p)).catch(p=>{p instanceof $o&&p.status,r(null)})},[]),s===void 0)return o.jsx("div",{className:"center-card",children:t("common.loading")});if(!s)return o.jsx(Ub,{site:e,onLogin:r});if(s.mustChangePassword)return o.jsx($b,{site:e,user:s,onChanged:p=>r(p)});if(i)return o.jsx(Hb,{site:e,user:s,projectId:i,onBack:f},i);const u=c?.userId===s.id?c:null;return o.jsx(zb,{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 Si({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 Ra(){const{t}=Oe();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",Wh]})]}),o.jsx("span",{children:t("footer.credit")})]})}function $b({site:t,user:e,onChanged:n}){const{t:s}=Oe(),[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<Ze)return u(s("auth.passwordMinimum",{count:Ze}));try{await L("/api/me/password",{method:"PUT",body:JSON.stringify({currentPassword:r,newPassword:a})}),n({...e,mustChangePassword:!1})}catch(g){u(V(g))}};return o.jsxs("main",{className:"login-page",children:[o.jsx(Yo,{}),o.jsxs("form",{className:"login-card",onSubmit:p,children:[o.jsx(Si,{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:Ze,autoComplete:"new-password",value:a,onChange:m=>c(m.target.value)}),o.jsx("small",{className:"field-hint",children:s("auth.passwordMinimum",{count:Ze})})]}),o.jsxs("label",{children:[s("auth.confirmPassword"),o.jsx("input",{type:"password",minLength:Ze,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(Ra,{})]})}function Ub({site:t,onLogin:e}){const{t:n}=Oe(),[s,r]=h.useState(""),[i,a]=h.useState(""),[c,l]=h.useState(""),d=async f=>{f.preventDefault(),l("");try{const u=await L("/api/auth/login",{method:"POST",body:JSON.stringify({username:s,password:i})});e(u.user)}catch(u){l(V(u))}};return o.jsxs("main",{className:"login-page",children:[o.jsx(Yo,{}),o.jsxs("form",{className:"login-card",onSubmit:d,children:[o.jsx(Si,{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(Ra,{})]})}function zb({site:t,user:e,initialData:n,onDataChange:s,onUser:r,onOpenProject:i}){const{t:a}=Oe(),[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),[x,b]=h.useState(!1),[S,k]=h.useState(!1),[T,N]=h.useState(""),[O,I]=h.useState(!1),[D,G]=h.useState(""),[v,A]=h.useState(!1),[te,z]=h.useState(""),[P,_]=h.useState(null),[C,U]=h.useState(""),le=h.useRef(null),[ce,xe]=h.useState(!1),[se,de]=h.useState(""),[Y,ve]=h.useState(""),[ye,E]=h.useState(!1),[W,Ye]=h.useState(""),[Ce,Z]=h.useState("blue"),[tt,ht]=h.useState(null),[ft,ze]=h.useState(null),[at,H]=h.useState(""),[re,q]=h.useState(null),[He,pt]=h.useState(""),[M,B]=h.useState(!1),[we,Le]=h.useState(null),[ae,qe]=h.useState(null),[Xe,en]=h.useState([]),[vt,mt]=h.useState(""),[nt,oe]=h.useState(!1),[Ht,ct]=h.useState(""),[gt,Pt]=h.useState(()=>localStorage.getItem("texlite-project-view")==="list"?"list":"grid"),[st,Nn]=h.useState(()=>localStorage.getItem("texlite-project-sort")==="created"?"created":"updated"),[Q,rt]=h.useState(!1),[Ss,Cs]=h.useState(""),[je,Be]=h.useState(1),[_t,tn]=h.useState(""),Rt=h.useRef(0),St=h.useRef(null),js=(w,ie,ne,be,Ae)=>`${w?"archived":"active"}|${ie}|${ne}|${be}|${Ae}`,lr=js(Q,je,se,Y,st),ke=(w,ie,ne,be,Ae)=>{const _e=new URLSearchParams({page:String(ie),pageSize:"20",sort:Ae});w&&_e.set("archived","1"),ne.trim()&&_e.set("search",ne.trim()),be&&_e.set("tag",be);const lt=js(w,ie,ne,be,Ae),gn=++Rt.current;St.current?.abort();const Pn=new AbortController;return St.current=Pn,Promise.all([L(`/api/projects?${_e.toString()}`,{signal:Pn.signal}),L("/api/tags",{signal:Pn.signal})]).then(([nn,ki])=>{gn===Rt.current&&(l(nn.projects),f(ki.tags),p(nn.pagination),Be(nn.pagination.page),g(!0),tn(lt))}).catch(nn=>{!Kn(nn)&&gn===Rt.current&&N(V(nn))}).finally(()=>{St.current===Pn&&(St.current=null)})};h.useEffect(()=>(ke(Q,je,se,Y,st),()=>St.current?.abort()),[Q,je,se,Y,st]),h.useEffect(()=>{m&&!Q&&_t===lr&&s(c,d,u)},[c,d,u,m,_t,lr,Q]);const mn=w=>{Pt(w),localStorage.setItem("texlite-project-view",w)},We=w=>{Nn(w),Be(1),localStorage.setItem("texlite-project-sort",w)},ks=w=>{rt(w),Be(1)},Ct=w=>{ve(w),Be(1)},Es=async()=>{if(D.trim())try{const{project:w}=await L("/api/projects",{method:"POST",body:JSON.stringify({name:D})});I(!1),G("");const ie=Q||je!==1?c:[w,...c].slice(0,u.pageSize),ne=Q?u:{...u,total:u.total+1,totalPages:Math.ceil((u.total+1)/u.pageSize)};l(ie),p(ne),Q||s(ie,d,ne),i(w.id)}catch(w){N(V(w))}},Ee=async()=>{if(!P)return;const w=t.maxUploadSizeMB??50;if(P.size>w*1024*1024)return U(a("errors.fileTooLarge",{size:w}));xe(!0),U("");const ie=new FormData;ie.append("file",P);try{const ne=await fetch(`/api/projects/import?name=${encodeURIComponent(te.trim())}`,{method:"POST",body:ie}),be=await ne.json();if(!ne.ok)throw new Error(Uo(be,ne.status,"errors.upload"));const Ae=be.project,_e=Q||je!==1?c:[Ae,...c].slice(0,u.pageSize),lt=Q?u:{...u,total:u.total+1,totalPages:Math.ceil((u.total+1)/u.pageSize)};l(_e),p(lt),Q||s(_e,d,lt),A(!1),_(null),z(""),i(Ae.id)}catch(ne){U(V(ne))}finally{xe(!1)}},Ds=w=>{if(w&&!w.name.toLocaleLowerCase().endsWith(".zip")){U(a("errors.zipOnly"));return}U(""),_(w),w&&!te&&z(w.name.replace(/\.zip$/i,""))},dr=async()=>{await L("/api/auth/logout",{method:"POST"}),r(null)},ur=async()=>{if(W.trim())try{const w=await L("/api/tags",{method:"POST",body:JSON.stringify({name:W,color:Ce})});f(ie=>[...ie,w.tag].sort((ne,be)=>ne.name.localeCompare(be.name))),E(!1),Ye(""),Z("blue")}catch(w){N(V(w))}},Ci=async w=>{if(!tt)return;const ie=tt.tags.some(ne=>ne.id===w.id);try{const be=(await L(ie?`/api/projects/${tt.id}/tags/${w.id}`:`/api/projects/${tt.id}/tags`,ie?{method:"DELETE"}:{method:"POST",body:JSON.stringify({tagId:w.id})})).project;ht(be),l(Ae=>Ae.map(_e=>_e.id===be.id?be:_e))}catch(ne){N(V(ne))}},hr=async()=>{if(!(!ft||!at.trim()))try{const w=await L(`/api/projects/${ft.id}`,{method:"PATCH",body:JSON.stringify({name:at})});l(ie=>ie.map(ne=>ne.id===w.project.id?w.project:ne)),ze(null),H("")}catch(w){N(V(w))}},fr=async()=>{if(!(!re||!He.trim())){B(!0),N("");try{await L(`/api/projects/${re.id}/duplicate`,{method:"POST",body:JSON.stringify({name:He})}),q(null),pt(""),ke(Q,je,se,Y,st)}catch(w){N(V(w))}finally{B(!1)}}},pr=async()=>{if(we)try{await L(`/api/projects/${we.id}`,{method:"DELETE"}),l(Ae=>Ae.filter(_e=>_e.id!==we.id));const w=Math.max(0,u.total-1),ie=Math.ceil(w/u.pageSize),ne=ie===0?1:Math.min(je,ie),be={...u,page:ne,total:w,totalPages:ie};p(be),Le(null),ne!==je?Be(ne):ke(Q,je,se,Y,st)}catch(w){N(V(w))}},Ns=async w=>{qe(w),mt(""),en([]),ct(""),oe(!0);try{const ie=await L("/api/users");en(ie.users.filter(ne=>ne.id!==w.ownerId))}catch(ie){ct(V(ie))}finally{oe(!1)}},mr=async()=>{if(!(!ae||!vt)){oe(!0),ct("");try{await L(`/api/projects/${ae.id}/owner`,{method:"PUT",body:JSON.stringify({userId:vt})}),qe(null),mt(""),ke(Q,je,se,Y,st)}catch(w){ct(V(w))}finally{oe(!1)}}},Tn=async w=>{const ie=!Q;Cs(w.id),N("");try{await L(`/api/projects/${w.id}/archive`,{method:ie?"PUT":"DELETE"});const ne=c.filter(gn=>gn.id!==w.id);l(ne);const be=Math.max(0,u.total-1),Ae=Math.ceil(be/u.pageSize),_e=Ae===0?1:Math.min(je,Ae),lt={...u,page:_e,total:be,totalPages:Ae};p(lt),Q||s(ne,d,lt),_e!==je?Be(_e):ke(Q,je,se,Y,st)}catch(ne){N(V(ne))}finally{Cs("")}},On=c,ji=["red","orange","yellow","green","blue","purple","gray"],Ts=w=>new Date(w).toLocaleString(ge.resolvedLanguage);return o.jsxs("div",{className:"page",children:[o.jsxs("header",{className:"topbar",children:[o.jsx("span",{className:"site-title",children:t.siteName}),o.jsx(Si,{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(ym,{"aria-hidden":!0,size:14}),a("metrics.title")]}),o.jsxs("button",{className:"ghost",onClick:()=>b(!x),children:[x?o.jsx(hd,{"aria-hidden":!0,size:14}):o.jsx(Vs,{"aria-hidden":!0,size:14}),a(x?"users.back":"users.manage")]})]}),o.jsx(Yo,{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:dr,children:a("auth.logout")})]})]}),x?o.jsx(Vb,{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(Hr,{"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:()=>E(!0),children:[o.jsx(Tc,{"aria-hidden":!0,size:15}),a("tags.create")]}),e.canCreateProjects&&o.jsxs(o.Fragment,{children:[o.jsxs("button",{onClick:()=>{U(""),A(!0)},children:[o.jsx(Wr,{"aria-hidden":!0,size:15}),a("projects.upload")]}),o.jsxs("button",{className:"primary",onClick:()=>I(!0),children:[o.jsx(gd,{"aria-hidden":!0,size:15}),a("projects.new")]})]})]})]}),T&&o.jsx("p",{className:"error",children:T}),o.jsxs("div",{className:"project-toolbar",children:[o.jsx("input",{type:"search",placeholder:a("projects.search"),value:se,onChange:w=>{de(w.target.value),Be(1)}}),o.jsxs("div",{className:"project-scope",role:"tablist","aria-label":a("projects.scope"),children:[o.jsxs("button",{className:Q?"":"active",onClick:()=>ks(!1),role:"tab","aria-selected":!Q,children:[o.jsx(Hr,{size:14}),a("projects.active")]}),o.jsxs("button",{className:Q?"active":"",onClick:()=>ks(!0),role:"tab","aria-selected":Q,children:[o.jsx(kc,{size:14}),a("projects.archived")]})]}),o.jsxs("div",{className:"tag-filters",children:[o.jsx("button",{className:Y?"":"active",onClick:()=>Ct(""),children:a("projects.allTags")}),d.map(w=>o.jsxs("button",{className:Y===w.id?"active":"",onClick:()=>Ct(Y===w.id?"":w.id),children:[o.jsx(co,{color:w.color}),w.name]},w.id))]}),o.jsxs("label",{className:"project-sort",children:[o.jsx(xm,{size:14}),o.jsx("span",{children:a("projects.sortBy")}),o.jsxs("select",{value:st,onChange:w=>We(w.target.value),children:[o.jsx("option",{value:"updated",children:a("projects.sortModified")}),o.jsx("option",{value:"created",children:a("projects.sortCreated")})]})]}),o.jsxs("div",{className:"view-toggle",children:[o.jsx("button",{className:gt==="grid"?"active":"",onClick:()=>mn("grid"),title:a("projects.grid"),children:"▦"}),o.jsx("button",{className:gt==="list"?"active":"",onClick:()=>mn("list"),title:a("projects.list"),children:"☷"})]})]}),o.jsxs("div",{className:`project-grid ${gt==="list"?"list-view":""}`,children:[On.map(w=>o.jsxs("article",{className:`project-card${w.ownerId===e.id?" owned-project":""}`,children:[gt==="grid"&&w.ownerId===e.id&&o.jsxs("button",{className:"project-transfer-action",title:a("projects.transferOwnership"),onClick:()=>{Ns(w)},children:[o.jsx(Hi,{"aria-hidden":!0,size:13}),a("projects.transfer")]}),o.jsxs("button",{className:"project-card-open",onClick:()=>i(w.id),children:[o.jsx("span",{className:"owner-badge",title:w.ownerDisplayName??w.ownerUsername,children:w.ownerDisplayName??w.ownerUsername}),o.jsxs("span",{className:"project-card-main",children:[o.jsx("strong",{children:w.name}),o.jsx("span",{className:"project-tags",children:w.tags?.map(ie=>o.jsx("span",{className:`tag tag-${ie.color}`,children:ie.name},ie.id))})]}),o.jsxs("dl",{className:"project-meta",children:[o.jsxs("div",{children:[o.jsxs("dt",{children:[o.jsx(bm,{"aria-hidden":!0,size:13}),a("projects.created")]}),o.jsx("dd",{children:o.jsx("time",{dateTime:w.createdAt,children:Ts(w.createdAt)})})]}),o.jsxs("div",{children:[o.jsxs("dt",{children:[o.jsx(yd,{"aria-hidden":!0,size:13}),a("projects.modified")]}),o.jsxs("dd",{title:a("projects.modifiedByUser",{time:Ts(w.updatedAt),user:w.lastModifiedDisplayName??w.lastModifiedUsername??a("projects.deletedUser")}),children:[o.jsx("time",{dateTime:w.updatedAt,children:Ts(w.updatedAt)}),o.jsxs("span",{className:"project-modified-by",children:[" · ",a("projects.byUser",{user:w.lastModifiedDisplayName??w.lastModifiedUsername??a("projects.deletedUser")})]})]})]})]})]}),o.jsxs("div",{className:"project-card-actions",children:[o.jsxs("button",{onClick:()=>ht(w),children:[o.jsx(Tc,{"aria-hidden":!0,size:14}),a("tags.assign")]}),w.permission==="owner"&&o.jsxs("button",{onClick:()=>{ze(w),H(w.name)},children:[o.jsx(Co,{"aria-hidden":!0,size:14}),a("projects.rename")]}),(e.role==="admin"||e.canCreateProjects)&&o.jsxs("button",{onClick:()=>{q(w),pt(`${w.name} (1)`)},children:[o.jsx(km,{"aria-hidden":!0,size:14}),a("projects.duplicate")]}),o.jsxs("a",{href:`/api/projects/${w.id}/download`,download:!0,children:[o.jsx(Bs,{"aria-hidden":!0,size:14}),a("projects.download")]}),o.jsxs("button",{disabled:Ss===w.id,onClick:()=>{Tn(w)},children:[Q?o.jsx(wm,{"aria-hidden":!0,size:14}):o.jsx(kc,{"aria-hidden":!0,size:14}),a(Q?"projects.unarchive":"projects.archive")]}),gt==="list"&&w.ownerId===e.id&&o.jsxs("button",{onClick:()=>{Ns(w)},children:[o.jsx(Hi,{"aria-hidden":!0,size:14}),a("projects.transfer")]}),w.permission==="owner"&&o.jsxs("button",{className:"danger-text",onClick:()=>Le(w),children:[o.jsx(dn,{"aria-hidden":!0,size:14}),a("common.delete")]})]})]},w.id)),On.length===0&&(c.length===0?Q?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(Vm,{size:28})}),o.jsx("h2",{children:a("projects.emptyTitle")}),o.jsx("p",{children:e.canCreateProjects?a("projects.emptyDescription"):a("projects.emptyRestricted")})]}):o.jsx("div",{className:"empty",children:a("projects.noMatches")}))]}),u.totalPages>1&&o.jsxs("nav",{className:"project-pagination","aria-label":a("projects.pagination"),children:[o.jsxs("button",{disabled:u.page<=1,onClick:()=>Be(w=>Math.max(1,w-1)),title:a("projects.previousPage"),children:[o.jsx(md,{size:15}),a("projects.previousPage")]}),o.jsx("span",{children:a("projects.pageOf",{page:u.page,totalPages:u.totalPages,count:u.total})}),o.jsxs("button",{disabled:u.page>=u.totalPages,onClick:()=>Be(w=>Math.min(u.totalPages,w+1)),title:a("projects.nextPage"),children:[o.jsx(Xo,{size:15}),a("projects.nextPage")]})]}),o.jsx(Me,{open:O,title:a("projects.new"),description:a("projects.newDescription"),onOpenChange:I,footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>I(!1),children:a("common.cancel")}),o.jsx("button",{className:"primary",onClick:()=>{Es()},children:a("common.create")})]}),children:o.jsxs("label",{className:"form-field",children:[a("projects.name"),o.jsx("input",{autoFocus:!0,value:D,onChange:w=>G(w.target.value),onKeyDown:w=>{w.key==="Enter"&&Es()}})]})}),o.jsx(Me,{open:v,title:a("projects.upload"),description:a("projects.uploadDescription",{size:t.maxUploadSizeMB??50}),onOpenChange:w=>{A(w),w||U("")},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>{A(!1),U("")},children:a("common.cancel")}),o.jsx("button",{className:"primary",disabled:!P||ce,onClick:()=>{Ee()},children:a(ce?"projects.importing":"projects.import")})]}),children:o.jsxs("div",{className:"form-stack",children:[C&&o.jsx("p",{className:"error import-error",children:C}),o.jsxs("div",{className:`upload-picker${P?" has-file":""}`,onDragOver:w=>{w.preventDefault(),w.dataTransfer.dropEffect="copy"},onDrop:w=>{w.preventDefault(),Ds(w.dataTransfer.files[0]??null)},children:[o.jsx("input",{ref:le,className:"sr-only",type:"file",accept:".zip,application/zip",onChange:w=>Ds(w.target.files?.[0]??null)}),o.jsx(So,{size:34}),o.jsxs("div",{className:"upload-picker-copy",children:[o.jsx("strong",{children:P?.name??a("projects.chooseZip")}),o.jsx("span",{children:P?a("projects.selectedFileSize",{size:sh(P.size)}):a("projects.dropZip")})]}),o.jsxs("button",{type:"button",onClick:()=>le.current?.click(),children:[o.jsx(Wr,{size:15}),a("projects.browse")]}),P&&o.jsx("button",{className:"upload-clear",type:"button",title:a("projects.clearFile"),"aria-label":a("projects.clearFile"),onClick:()=>{Ds(null),le.current&&(le.current.value="")},children:o.jsx(Qo,{size:14})})]}),o.jsxs("label",{className:"form-field",children:[a("projects.name"),o.jsx("input",{value:te,onChange:w=>z(w.target.value)})]})]})}),o.jsx(Me,{open:ye,title:a("tags.create"),description:a("tags.createDescription"),onOpenChange:E,footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>E(!1),children:a("common.cancel")}),o.jsx("button",{className:"primary",onClick:()=>{ur()},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:W,onChange:w=>Ye(w.target.value)})]}),o.jsxs("fieldset",{className:"color-picker",children:[o.jsx("legend",{children:a("tags.color")}),ji.map(w=>o.jsxs("label",{className:Ce===w?"active":"",children:[o.jsx("input",{type:"radio",name:"dashboard-tag-color",checked:Ce===w,onChange:()=>Z(w)}),o.jsx(co,{color:w}),a(`tags.${w}`)]},w))]})]})}),o.jsx(Me,{open:!!tt,title:a("tags.assignTitle",{project:tt?.name??""}),description:a("tags.assignDescription"),onOpenChange:w=>{w||ht(null)},footer:o.jsx("button",{onClick:()=>ht(null),children:a("common.close")}),children:o.jsxs("div",{className:"tag-assignment-list",children:[d.map(w=>o.jsxs("label",{children:[o.jsx("input",{type:"checkbox",checked:!!tt?.tags.some(ie=>ie.id===w.id),onChange:()=>{Ci(w)}}),o.jsx(co,{color:w.color}),o.jsx("span",{children:w.name})]},w.id)),d.length===0&&o.jsx("p",{className:"muted",children:a("tags.empty")})]})}),o.jsx(Me,{open:!!ft,title:a("projects.renameTitle"),onOpenChange:w=>{w||ze(null)},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>ze(null),children:a("common.cancel")}),o.jsx("button",{className:"primary",onClick:()=>{hr()},children:a("projects.rename")})]}),children:o.jsxs("label",{className:"form-field",children:[a("projects.name"),o.jsx("input",{autoFocus:!0,value:at,onChange:w=>H(w.target.value),onKeyDown:w=>{w.key==="Enter"&&hr()}})]})}),o.jsx(Me,{open:!!re,title:a("projects.duplicateTitle"),description:a("projects.duplicateDescription",{project:re?.name??""}),onOpenChange:w=>{!w&&!M&&(q(null),pt(""))},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{disabled:M,onClick:()=>{q(null),pt("")},children:a("common.cancel")}),o.jsx("button",{className:"primary",disabled:M||!He.trim(),onClick:()=>{fr()},children:a(M?"projects.duplicating":"projects.duplicate")})]}),children:o.jsxs("label",{className:"form-field",children:[a("projects.name"),o.jsx("input",{autoFocus:!0,value:He,onChange:w=>pt(w.target.value),onKeyDown:w=>{w.key==="Enter"&&fr()}})]})}),o.jsx(Me,{open:!!ae,title:a("projects.transferOwnership"),description:a("projects.transferDescription",{project:ae?.name??""}),onOpenChange:w=>{!w&&!nt&&(qe(null),mt(""),ct(""))},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{disabled:nt,onClick:()=>{qe(null),mt(""),ct("")},children:a("common.cancel")}),o.jsxs("button",{className:"primary",disabled:nt||!vt,onClick:()=>{mr()},children:[nt?o.jsx(kt,{className:"spin",size:14}):o.jsx(Hi,{size:14}),a("projects.transfer")]})]}),children:o.jsxs("div",{className:"form-stack",children:[Ht&&o.jsx("p",{className:"error dialog-error",children:Ht}),o.jsxs("label",{className:"form-field",children:[a("projects.newOwner"),o.jsxs("select",{disabled:nt||Xe.length===0,value:vt,onChange:w=>mt(w.target.value),children:[o.jsx("option",{value:"",children:nt?a("common.loading"):Xe.length>0?a("projects.chooseNewOwner"):a("projects.noTransferUsers")}),Xe.map(w=>o.jsxs("option",{value:w.id,children:[w.displayName??w.username," (@",w.username,")"]},w.id))]})]}),o.jsxs("p",{className:"warning",children:[o.jsx(os,{size:15}),a("projects.transferWarning")]})]})}),o.jsx(is,{open:!!we,title:a("projects.deleteTitle"),description:a("projects.deleteDescription",{project:we?.name??""}),confirmLabel:a("common.delete"),danger:!0,onCancel:()=>Le(null),onConfirm:()=>{pr()}})]}),S&&o.jsx(h.Suspense,{fallback:null,children:o.jsx(Ib,{open:!0,onOpenChange:k})}),o.jsx(Ra,{})]})}function co({color:t}){return o.jsx("span",{className:`tag-dot tag-${t}`})}function Bb(t=10){const e="ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789!@#$%",n=crypto.getRandomValues(new Uint8Array(t));return Array.from(n,s=>e[s%e.length]).join("")}function Vb({currentUser:t}){const{t:e}=Oe(),[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,x]=h.useState(null),[b,S]=h.useState(!1),k=()=>L("/api/admin/users").then(({users:v})=>s(v)).catch(v=>i(V(v)));h.useEffect(()=>{k()},[]);const T=async()=>{if(l.password.length<Ze)return i(e("auth.passwordMinimum",{count:Ze}));try{await L("/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(v){i(V(v))}},N=async v=>{try{await L(`/api/admin/users/${v.id}`,{method:"PATCH",body:JSON.stringify({disabled:!v.disabled})}),await k()}catch(A){i(V(A))}},O=async v=>{try{await L(`/api/admin/users/${v.id}`,{method:"PATCH",body:JSON.stringify({role:v.role==="admin"?"user":"admin"})}),await k()}catch(A){i(V(A))}},I=async v=>{try{await L(`/api/admin/users/${v.id}`,{method:"PATCH",body:JSON.stringify({canCreateProjects:!v.canCreateProjects})}),await k()}catch(A){i(V(A))}},D=async()=>{if(!(!f||!p)){if(p.length<Ze)return i(e("auth.passwordMinimum",{count:Ze}));try{await L(`/api/admin/users/${f.id}`,{method:"PATCH",body:JSON.stringify({password:p})}),u(null),m("")}catch(v){i(V(v))}}},G=async()=>{if(g)try{await L(`/api/admin/users/${g.id}`,{method:"DELETE",body:JSON.stringify({deleteProjects:b})}),x(null),S(!1),await k()}catch(v){i(V(v))}};return o.jsxs("main",{className:"dashboard",children:[o.jsxs("div",{className:"section-title",children:[o.jsxs("div",{children:[o.jsxs("h1",{children:[o.jsx(Vs,{"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(xd,{"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(v=>o.jsxs("tr",{children:[o.jsxs("td",{children:[o.jsx("strong",{children:v.displayName}),o.jsxs("small",{children:["@",v.username]})]}),o.jsx("td",{children:v.role==="admin"?e("common.admin"):e("common.user")}),o.jsx("td",{children:v.canCreateProjects?e("users.allow"):e("users.deny")}),o.jsx("td",{children:v.ownedProjects}),o.jsx("td",{children:v.disabled?e("common.disabled"):e("common.normal")}),o.jsxs("td",{children:[o.jsx("button",{disabled:v.id===t.id,onClick:()=>N(v),children:v.disabled?e("users.enable"):e("users.disable")}),o.jsx("button",{disabled:v.id===t.id,onClick:()=>O(v),children:v.role==="admin"?e("users.demote"):e("users.promote")}),o.jsx("button",{disabled:v.role==="admin",onClick:()=>I(v),children:v.canCreateProjects?e("users.denyCreate"):e("users.allowCreate")}),o.jsx("button",{onClick:()=>{u(v),m("")},children:e("users.resetPassword")}),o.jsx("button",{className:"danger-text",disabled:v.id===t.id,onClick:()=>{x(v),S(!1)},children:e("common.delete")})]})]},v.id))})]})}),o.jsx(Me,{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<Ze,onClick:()=>{T()},children:e("users.createUser")})]}),children:o.jsxs("div",{className:"form-stack",children:[o.jsxs("label",{className:"form-field",children:[e("auth.username"),o.jsx("input",{value:l.username,onChange:v=>d({...l,username:v.target.value})})]}),o.jsxs("label",{className:"form-field",children:[e("users.displayName"),o.jsx("input",{value:l.displayName,onChange:v=>d({...l,displayName:v.target.value})})]}),o.jsxs("label",{className:"form-field",children:[e("users.initialPassword"),o.jsxs("span",{className:"password-generator",children:[o.jsx("input",{minLength:Ze,autoComplete:"new-password",value:l.password,onChange:v=>d({...l,password:v.target.value})}),o.jsxs("button",{type:"button",title:e("users.generatePassword"),onClick:()=>d({...l,password:Bb()}),children:[o.jsx(Em,{size:15}),e("users.randomPassword")]})]}),o.jsx("small",{className:"field-hint",children:e("auth.passwordMinimum",{count:Ze})})]}),o.jsxs("label",{className:"form-field",children:[e("users.role"),o.jsxs("select",{value:l.role,onChange:v=>d({...l,role:v.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:v=>d({...l,canCreateProjects:v.target.checked})})," ",e("users.allowCreate")]})]})}),o.jsx(Me,{open:!!f,title:e("users.resetPassword"),description:e("users.resetDescription",{username:f?.username??""}),onOpenChange:v=>{v||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<Ze,onClick:()=>{D()},children:e("users.reset")})]}),children:o.jsxs("label",{className:"form-field",children:[e("auth.newPassword"),o.jsx("input",{autoFocus:!0,type:"password",minLength:Ze,autoComplete:"new-password",value:p,onChange:v=>m(v.target.value)}),o.jsx("small",{className:"field-hint",children:e("auth.passwordMinimum",{count:Ze})})]})}),o.jsx(Me,{open:!!g,title:e("users.deleteTitle"),description:e("users.deleteDescription",{username:g?.username??""}),onOpenChange:v=>{v||x(null)},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>x(null),children:e("common.cancel")}),o.jsx("button",{className:"danger",onClick:()=>{G()},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:()=>S(!1)})," ",e("users.transferProjects")]}),o.jsxs("label",{children:[o.jsx("input",{type:"radio",checked:b,onChange:()=>S(!0)})," ",e("users.deleteProjects")]})]})})]})}function Hb({site:t,user:e,projectId:n,onBack:s}){const{t:r}=Oe(),[i,a]=h.useState(null),[c,l]=h.useState(!1),[d,f]=h.useState([]),[u,p]=h.useState(null),[m,g]=h.useState([]),[x,b]=h.useState(""),[S,k]=h.useState(""),[T,N]=h.useState(new Set),[O,I]=h.useState(""),[D,G]=h.useState(""),[v,A]=h.useState(!1),[te,z]=h.useState("editor.saved"),[P,_]=h.useState(null),[C,U]=h.useState({line:1,column:1}),le=h.useRef(C),[ce,xe]=h.useState("pdf"),[se,de]=h.useState("log"),Y=y=>{if(y==="pdf"){xe("pdf");return}de(y),xe("diagnostics")},{workspaceLayout:ve,setWorkspaceLayout:ye}=Ob(e.id,n),[E,W]=h.useState(""),[Ye,Ce]=h.useState(""),[Z,tt]=h.useState({selectedText:"",startOffset:0,endOffset:0}),ht=h.useRef({selectedText:"",startOffset:0,endOffset:0}),ft=y=>{ht.current=y,tt(y)},[ze,at]=h.useState(null),[H,re]=h.useState(!1),[q,He]=h.useState(!1),[pt,M]=h.useState(!1),[B,we]=h.useState(!1),[Le,ae]=h.useState(null),[qe,Xe]=h.useState(!1),[en,vt]=h.useState(!1),[mt,nt]=h.useState(!1),[oe,Ht]=h.useState(()=>Pc(e.id,n)),ct=h.useRef(null),gt=h.useRef(null),Pt=h.useRef(0),st=h.useRef(0),Nn=h.useRef(""),Q=h.useRef(""),rt=h.useRef(""),Ss=h.useRef(""),Cs=h.useRef(0),je=h.useRef(null),Be=h.useRef(null),_t=h.useRef(null),tn=h.useRef(null),Rt=h.useRef(!1),St=h.useRef(null),js=h.useRef(s);js.current=s,rt.current=S;const lr=(y,j)=>{const R={line:y,column:j};le.current=R,U(R)},{collaboration:ke,status:mn,synced:We,activeSessions:ks,compileState:Ct,setCompileState:Es,filesEvent:Ee,commentsRevision:Ds,dictionaryRevision:dr,localDraftReady:ur,reconnect:Ci}=vb(n,e,S,c,()=>z("editor.offlineDraft")),{pdfTarget:hr,pdfViewport:fr,sourceJump:pr,setPdfViewport:Ns,clearPdfViewport:mr,jumpToSource:Tn,syncSourceToPdf:On,syncPdfToSource:ji,syncVisiblePdfToSource:Ts}=Tb({projectId:n,mainFile:S,activeFile:x,onActiveFile:b,onError:W,onShowPdf:()=>Y("pdf")}),w=Nb({active:!!(i&&x&&We&&oe.spellCheck),activeFile:x,content:O,dictionaryWords:d});h.useEffect(()=>{Ht(Pc(e.id,n))},[e.id,n]);const ie=y=>{Nn.current=y,I(y)};h.useEffect(()=>{Q.current=x,le.current={line:1,column:1},U({line:1,column:1}),ft({selectedText:"",startOffset:0,endOffset:0})},[x]),h.useEffect(()=>{if(!v)return;const y=j=>{j.preventDefault(),j.returnValue=""};return window.addEventListener("beforeunload",y),()=>window.removeEventListener("beforeunload",y)},[v]),h.useEffect(()=>{if(mn!=="disconnected")return;const y=new AbortController;return L(`/api/projects/${n}`,{signal:y.signal}).then(({project:j})=>{y.signal.aborted||(a(j),W(""))}).catch(j=>{if(!Kn(j)){if(j instanceof $o&&[401,403,404].includes(j.status)){W(V(j)),js.current();return}W(r("errors.collaborationUnavailable"))}}),()=>y.abort()},[mn,n,r]);const ne=async(y={})=>{je.current?.abort(),je.current=null;const j=y.signal?null:new AbortController;j&&(je.current=j);try{const R=await L(`/api/projects/${n}/completions`,{signal:y.signal??j?.signal});(!y.isCurrent||y.isCurrent())&&p(R.index)}catch(R){if(Kn(R))return;(!y.isCurrent||y.isCurrent())&&p(null)}finally{j&&je.current===j&&(je.current=null)}},be=async(y={},j=rt.current)=>{Be.current?.abort(),Be.current=null;const R=y.signal?null:new AbortController;R&&(Be.current=R);try{const X=j?`?mainFile=${encodeURIComponent(j)}`:"",ue=await L(`/api/projects/${n}/outline${X}`,{signal:y.signal??R?.signal});(!y.isCurrent||y.isCurrent())&&g(ue.outline)}catch(X){!Kn(X)&&(!y.isCurrent||y.isCurrent())&&g([])}finally{R&&Be.current===R&&(Be.current=null)}},Ae=async(y={})=>{_t.current?.abort(),_t.current=null;const j=y.signal?null:new AbortController;j&&(_t.current=j);try{const R=await L(`/api/projects/${n}/dictionary`,{signal:y.signal??j?.signal});(!y.isCurrent||y.isCurrent())&&f(R.words)}catch(R){if(Kn(R))return;(!y.isCurrent||y.isCurrent())&&f([])}finally{j&&_t.current===j&&(_t.current=null)}};h.useEffect(()=>{let y=!1;const j=++Cs.current,R=new AbortController,X=()=>!y&&Cs.current===j;let ue=!1;Ss.current="",a(null),La([]),g([]),b(""),k(""),N(new Set),I(""),G(""),Es(null),mr(),p(null),f([]),nh();const Ve=L(`/api/projects/${n}`,{signal:R.signal}).then(Ke=>{X()&&(ue=!0,a(Ke.project),b(Ke.project.mainFile),k(Ke.project.mainFile),N(new Set([Ke.project.mainFile])),Ma(new Set(Fs(Ke.project.mainFile))))}).catch(Ke=>{X()&&W(V(Ke))}),he=L(`/api/projects/${n}/files`,{signal:R.signal}).then(Ke=>{X()&&La(Ke.files)}).catch(Ke=>{X()&&W(V(Ke))});return Promise.allSettled([Ve,he]).then(()=>{!X()||!ue||window.setTimeout(()=>{X()&&Promise.all([ne({signal:R.signal,isCurrent:X}),Ae({signal:R.signal,isCurrent:X})])},0)}),()=>{y=!0,R.abort(),je.current?.abort(),je.current=null,Be.current?.abort(),Be.current=null,_t.current?.abort(),_t.current=null,tn.current?.abort(),tn.current=null}},[n]),h.useEffect(()=>{dr&&Ae()},[dr,n]),h.useEffect(()=>{i&&ke.setPermission(i.permission)},[ke,i?.permission]),h.useEffect(()=>{if(!Ee)return;const y=Ee.kind==="delete"&&!!Ee.path&&Vn(Ee.path,Q.current),j=Ee.kind==="delete"&&!!Ee.path&&Vn(Ee.path,rt.current);if(Ee.kind==="move"&&Ee.source&&Ee.destination){const X=Ee.source,ue=Ee.destination,Ve=he=>he===X?ue:he.startsWith(`${X}/`)?`${ue}${he.slice(X.length)}`:he;b(he=>Ve(he)),k(he=>Ve(he)),N(he=>new Set([...he].map(Ve))),gr(he=>he&&Ve(he))}y&&(b(""),G(""),ie(""),Ce(r("editor.fileDeletedByCollaborator",{path:Ee.path}))),Ee.kind==="delete"&&Ee.path&&(N(X=>new Set([...X].filter(ue=>!Vn(Ee.path,ue)))),gr(X=>Vn(Ee.path,X)?"":X),Fa(X=>X&&Vn(Ee.path,X.path)?null:X)),tn.current?.abort();const R=new AbortController;tn.current=R,Promise.all([rh({signal:R.signal}),L(`/api/projects/${n}`,{signal:R.signal})]).then(([X,ue])=>{if(a(ue.project),j&&k(ue.project.mainFile),y&&X){const Ve=X.find(he=>he.type==="file"&&he.path===ue.project.mainFile)??X.find(he=>he.type==="file"&&Mo(he.path));b(Ve?.path??"")}ne({signal:R.signal}),be({signal:R.signal},j?ue.project.mainFile:rt.current)}).catch(X=>{Kn(X)}).finally(()=>{tn.current===R&&(tn.current=null)})},[Ee?.revision]),h.useEffect(()=>{if(ke.setActiveFile(x),!x)return;G(""),z("editor.loading");const y=ke.getText(x),j=(R,X)=>{ie(y.toString()),G(x),X?.local&&i?.permission!=="read"?(Pt.current+=1,A(!0),z("editor.pending")):Pt.current<=st.current&&z(P?"editor.savedAt":"editor.saved")};return y.observe(j),(We||ur)&&j(),()=>{y.unobserve(j)}},[x,ke,We,ur,i?.permission]),h.useEffect(()=>{!x||D!==x||Ss.current===x||(Ss.current=x,!(!x.toLocaleLowerCase().endsWith(".tex")||!qb(O))&&(N(y=>new Set([...y,x])),k(x)))},[x,D,O]);const _e=async()=>{if(!We)throw new Error("Collaboration is not synchronized");const y=Pt.current,j=await ke.flush();return st.current=Math.max(st.current,y),_(j.persistedAt),/\.tex$/i.test(Q.current)&&be(),Pt.current===y?(A(!1),z("editor.savedAt")):z("editor.pending"),j};h.useEffect(()=>{if(!v||!x)return;if(!We){z("editor.offlineDraft");return}z("editor.pending");const y=window.setTimeout(()=>{z("editor.saving"),_e().catch(()=>{z(ke.connected?"editor.saveFailed":"editor.offlineDraft")})},750);return()=>window.clearTimeout(y)},[O,v,x,We]);const lt=async()=>{if(!i||i.permission==="read"||!We||!x)return!1;z("editor.saving");try{return await _e(),ne(),!0}catch{return z("editor.saveFailed"),W(r("errors.collaborationUnavailable")),!1}},gn=async(y,j)=>(await L(`/api/projects/${n}/format`,{method:"POST",body:JSON.stringify({path:y,source:j})})).formatted,Pn=async()=>{if(!oe.formatOnCompile||!i||i.permission==="read"||!We||!Wi(Q.current)||Rt.current)return;const y=Q.current,j=ke.getText(y),R=j.toString();Rt.current=!0,nt(!0);try{const X=await gn(y,R),ue=await _c(R,X);if(Q.current!==y||j.toString()!==R)throw new Error(r("editor.formatSourceChanged"));ue.length&&ke.applyTextEdits(y,ue)}catch(X){W(r("editor.formatFailedContinue",{message:V(X)}))}finally{Rt.current=!1,nt(!1)}},nn=async()=>(St.current&&await St.current,await Pn(),lt()),ki=async()=>{if(!i||i.permission==="read"||!We||Rt.current||!Wi(Q.current))return;const y=ht.current;if(!y.selectedText.trim()){Ce(r("editor.formatSelectionRequired"));return}const j=Q.current,{startOffset:R,endOffset:X,selectedText:ue}=y,Ve=ke.getText(j);if(Ve.toString().slice(R,X)!==ue){W(r("editor.formatSelectionChanged"));return}Rt.current=!0,nt(!0);let he=()=>{};const Ke=new Promise(At=>{he=At});St.current=Ke;try{const At=Ym(ue,await gn(j,ue)),ec=await _c(ue,At,R);if(Q.current!==j||Ve.toString().slice(R,X)!==ue){W(r("editor.formatSelectionChanged"));return}ec.length&&ke.applyTextEdits(j,ec),W(""),Ce(r("editor.formatSelectionComplete"))}catch(At){W(r("editor.formatFailed",{message:V(At)}))}finally{Rt.current=!1,nt(!1),he(),St.current===Ke&&(St.current=null)}},{files:Os,setFiles:La,loadFiles:rh,newFileOpen:ih,setNewFileOpen:Ei,newFilePath:oh,setNewFilePath:Aa,resourcePreview:Ne,setResourcePreview:Fa,resourcePreviewLoading:ah,setResourcePreviewLoading:ch,newFolderOpen:lh,setNewFolderOpen:Di,newFolderName:dh,setNewFolderName:Ia,fileDialogError:sn,setFileDialogError:_n,selectedFolder:qt,setSelectedFolder:gr,expandedFolders:uh,setExpandedFolders:Ma,moveEntry:Ps,setMoveEntry:yr,moveDestination:hh,setMoveDestination:Ni,deleteEntry:Rn,setDeleteEntry:wr,fileDragActive:$a,setFileDragActive:Ti,uploadConflict:Oi,setUploadConflict:Ua,uploadingFiles:xr,directoryEntries:fh,visibleEntries:ph,createFile:mh,createFolder:za,uploadFiles:Ba,upload:gh,openFile:Va,movePath:yh,removePath:wh}=Db({projectId:n,site:t,activeFile:x,dirty:v,save:lt,onError:W,onProject:a,onActiveFile:b,onActiveMainFile:k,onRootDocuments:N}),{comments:_s,focusComment:xh,setFocusComment:Ha,commentOpen:bh,setCommentOpen:Pi,commentText:vh,setCommentText:Sh,addComment:Ch,toggleComment:jh,replyToComment:kh,editComment:Eh,deleteComment:Dh,editCommentReply:Nh,deleteCommentReply:Th}=xb({projectId:n,activeFile:x,permission:i?.permission,revision:Ds,selection:Z,save:lt,onError:W,onAdded:()=>at("comments")}),{pdfUrl:Lt,pdfCompiledAt:Ln,pdfLoading:_i,compileLog:br,compileDiagnostics:vr,compileOutcome:Sr,artifacts:Ri,artifactPreview:Oh,artifactLoading:Ph,editorNotice:qa,localCompiling:Li,cleaning:Wa,compile:_h,cleanCompile:Rh,viewArtifact:Lh}=Cb({projectId:n,project:i,mainFile:S,collaborationSynced:We,sharedState:Ct,onSharedState:Es,save:nn,loadOutline:(y,j)=>be({signal:y},j),onPreviewTab:Y,onError:W,onCompileStart:()=>{W(""),Ce("")},onCompileSuccess:()=>{const y=Q.current;y&&On(y,le.current.line,le.current.column,{silent:!0})},onPdfChanged:mr});h.useEffect(()=>{if(!i||!Lt&&_i)return;const y=window.setTimeout(()=>l(!0),Lt?150:0);return()=>window.clearTimeout(y)},[i,_i,Lt]),h.useEffect(()=>{const y=j=>{(j.ctrlKey||j.metaKey)&&(!j.shiftKey&&j.key.toLocaleLowerCase()==="p"?(j.preventDefault(),Xe(!0)):j.shiftKey&&j.key.toLocaleLowerCase()==="f"&&(j.preventDefault(),vt(!0)))};return window.addEventListener("keydown",y,!0),()=>window.removeEventListener("keydown",y,!0)},[]);const Ah=y=>{Ht(y),Km(e.id,n,y)},Ka=()=>{gt.current?.isCollapsed()?gt.current.expand():gt.current?.collapse()},Ga=h.useMemo(()=>m.length?m:Wb(O).map(y=>({...y,path:x})),[m,O,x]),An=h.useMemo(()=>Xm(br,Sr),[br,Sr]),Fn=ve!=="pdf-only",Ja=ve!=="editor-only",Cr=y=>{ye(y),y==="pdf-only"&&Y("pdf")},Ai=Rn?ks.filter(y=>y.filePath&&Vn(Rn.path,y.filePath)):[];if(!i)return o.jsxs("div",{className:"center-card",children:[o.jsx("p",{children:E||r("common.loading")}),E&&o.jsx("button",{className:"primary",onClick:s,children:r("editor.backToProjects")})]});const jt=i.permission==="read"||!We,Fh=(y,j)=>{if(jt)return;const R=Q.current;if(!R)return;if(ke.getText(R).toString().slice(y.from,y.to)!==y.word){W(r("editor.spellCheckSourceChanged"));return}try{ke.applyTextEdits(R,[{from:y.from,to:y.to,replacement:j}])}catch(Ve){W(V(Ve))}},jr=Ct?.mainFile===S&&(Ct.status==="queued"||Ct.status==="running"),In=Li||jr||Wa,Ya=x?ke.getText(x):null,Xa=Ln?new Date(Ln).toLocaleString(ge.resolvedLanguage,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"",Ih=S.split("/").at(-1)??S,Mh=An.warnings.length+An.errors.length+Ri.length,Za=Lt?`${Lt}${Lt.includes("?")?"&":"?"}download=1`:"",Qa=In?jr?Ct?.status==="queued"?r("editor.compileQueued"):r("editor.compilingBy",{name:Ct?.requestedBy.name??r("common.user")}):r("editor.compiling"):Sr==="failed"?Lt&&Ln?r("editor.compileFailedRetained",{time:new Date(Ln).toLocaleString(ge.resolvedLanguage)}):r("editor.compileFailedNoPdf"):"",$h=te==="editor.savedAt"&&P?r("editor.savedAt",{time:new Date(P).toLocaleTimeString(ge.resolvedLanguage,{hour:"2-digit",minute:"2-digit",second:"2-digit"})}):r(te);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(hd,{size:18})}),o.jsx(Si,{siteName:t.siteName,compact:!0}),o.jsxs("div",{className:"project-heading",children:[o.jsx("strong",{children:i.name}),o.jsxs("small",{children:[x," · ",$h]})]}),oe.vimMode&&o.jsxs("span",{className:"vim-status-badge",title:r("editor.vimOnHint"),children:[o.jsx(Pm,{size:14}),r("editor.vimOn")]}),o.jsx(lb,{sessions:ks,status:mn}),mn==="disconnected"&&o.jsxs("div",{className:"collaboration-recovery",role:"status",children:[o.jsx("span",{children:r("editor.collaboration.disconnected")}),o.jsx("button",{type:"button",onClick:Ci,children:r("editor.collaboration.reconnect")})]}),o.jsxs("div",{className:"editor-actions",children:[Fn&&o.jsxs("button",{className:H?"":"active",onClick:Ka,children:[H?o.jsx(Am,{size:15}):o.jsx(Nc,{size:15}),r("common.files")]}),o.jsx(db,{value:ve,onChange:Cr}),o.jsxs("button",{onClick:()=>we(!0),children:[o.jsx(yd,{size:15}),r("history.title")]}),o.jsxs("button",{onClick:()=>He(!0),children:[o.jsx(Vs,{size:15}),r("projectSettings.share")]}),i.ownerId===e.id&&o.jsxs("button",{onClick:()=>M(!0),children:[o.jsx(Om,{size:15}),"Git"]}),Fn&&i.permission!=="read"&&Wi(x)&&o.jsxs("button",{title:Z.selectedText.trim()?r("editor.formatSelection"):r("editor.formatSelectionHint"),onMouseDown:y=>y.preventDefault(),onClick:()=>{ki()},disabled:jt||mt||!We,children:[mt?o.jsx(kt,{className:"spin",size:15}):o.jsx(ud,{size:15}),r(mt?"editor.formatting":"editor.formatSelection")]}),o.jsxs("button",{onClick:()=>Pi(!0),disabled:!x,children:[o.jsx(Rm,{size:15}),r("editor.addComment")]}),o.jsxs("button",{className:ze==="comments"?"active":"",onClick:()=>at(ze==="comments"?null:"comments"),children:[o.jsx(Lm,{size:15}),r("common.comments")," ",_s.filter(y=>!y.resolved).length||""]}),o.jsxs("button",{className:ze==="settings"?"active":"",onClick:()=>at(ze==="settings"?null:"settings"),children:[o.jsx(Fr,{size:15}),r("common.settings")]}),o.jsxs("button",{className:"compile",title:jr?r("editor.compilingBy",{name:Ct?.requestedBy.name??""}):r("editor.compileShortcut"),onClick:_h,disabled:In||mt||jt||!We,children:[In?o.jsx(kt,{className:"spin",size:15}):o.jsx(Mm,{size:15}),jr?r("editor.compilingBy",{name:Ct?.requestedBy.name??""}):Li?r("editor.compiling"):r("editor.compile",{engine:i.engine})]})]})]}),Qa&&o.jsxs("div",{className:`compile-status-strip${Sr==="failed"?" failed":""}`,role:"status","aria-live":"polite",children:[o.jsx(kt,{className:In?"spin":"",size:14}),o.jsx("span",{children:Qa})]}),E&&o.jsx("div",{className:"toast",onClick:()=>W(""),children:E}),Ye&&o.jsx("div",{className:"toast success",onClick:()=>Ce(""),children:Ye}),o.jsxs(Bh,{autoSaveId:"texlite-workspace-layout",direction:"horizontal",className:"work-grid",children:[Fn&&o.jsx(kr,{id:"files",order:1,ref:gt,defaultSize:16,minSize:12,maxSize:30,collapsible:!0,collapsedSize:0,onCollapse:()=>re(!0),onExpand:()=>re(!1),children:o.jsxs("aside",{className:"left-panel",children:[o.jsxs("section",{className:`files-panel${$a?" drop-active":""}`,onDragEnter:y=>{y.dataTransfer.types.includes("Files")&&(y.preventDefault(),!jt&&!xr&&Ti(!0))},onDragOver:y=>{y.dataTransfer.types.includes("Files")&&(y.preventDefault(),y.dataTransfer.dropEffect=jt||xr?"none":"copy")},onDragLeave:y=>{y.currentTarget.contains(y.relatedTarget)||Ti(!1)},onDrop:y=>{y.preventDefault(),Ti(!1),!jt&&!xr&&Ba(Array.from(y.dataTransfer.files))},children:[o.jsxs("div",{className:"panel-title",children:[o.jsxs("span",{children:[o.jsx(Gn,{size:14}),r("common.files")]}),o.jsxs("span",{className:"file-tools",children:[o.jsx("button",{"aria-label":r("navigation.quickOpen"),title:`${r("navigation.quickOpen")} (Ctrl/Cmd+P)`,onClick:()=>Xe(!0),children:o.jsx(Nm,{size:15})}),o.jsx("button",{"aria-label":r("navigation.projectSearch"),title:`${r("navigation.projectSearch")} (Ctrl/Cmd+Shift+F)`,onClick:()=>vt(!0),children:o.jsx(zm,{size:15})}),!jt&&o.jsxs(o.Fragment,{children:[o.jsx("button",{disabled:xr,"aria-label":r("editor.uploadAttachment"),title:r("editor.uploadTo",{folder:qt||r("editor.projectRoot")}),onClick:()=>ct.current?.click(),children:o.jsx(Wr,{size:15})}),o.jsx("button",{"aria-label":r("editor.newFolder"),title:r("editor.newFolder"),onClick:()=>{Ia(""),Di(!0)},children:o.jsx(gd,{size:15})}),o.jsx("button",{"aria-label":r("editor.newFile"),title:r("editor.newFile"),onClick:()=>{Aa(qt?`${qt}/`:""),Ei(!0)},children:o.jsx(Dm,{size:15})}),o.jsx("input",{ref:ct,type:"file",multiple:!0,hidden:!0,onChange:y=>{gh(y)}})]}),o.jsx("button",{"aria-label":r("editor.collapseFiles"),title:r("editor.collapseFiles"),onClick:Ka,children:o.jsx(Nc,{size:15})})]})]}),$a&&o.jsxs("div",{className:"file-drop-overlay",children:[o.jsx(Wr,{size:24}),o.jsx("strong",{children:r("editor.dropFiles")}),o.jsx("span",{children:r("editor.uploadTo",{folder:qt||r("editor.projectRoot")})})]}),o.jsxs("div",{className:"folder-target",title:qt||r("editor.projectRoot"),children:[o.jsx(Hr,{size:13}),o.jsx("span",{children:qt||r("editor.projectRoot")})]}),o.jsxs("div",{className:"file-list",style:{fontSize:`${oe.fontSize}px`},children:[o.jsx("div",{className:`file-entry folder-entry root-entry${qt===""?" selected":""}`,children:o.jsxs("button",{className:"file-entry-main",onClick:()=>gr(""),children:[o.jsx(Hr,{size:15}),o.jsx("span",{children:r("editor.projectRoot")})]})}),ph.map(y=>{const j=y.path.split("/").length-1,R=y.path.split("/").at(-1),X=uh.has(y.path),ue=T.has(y.path),Ve=S===y.path,he=y.path!==i.mainFile&&!i.mainFile.startsWith(`${y.path}/`);return y.type==="directory"?o.jsxs("div",{className:`file-entry folder-entry${qt===y.path?" selected":""}`,style:{paddingLeft:`${j*13+5}px`},children:[o.jsxs("button",{className:"file-entry-main",title:y.path,onClick:()=>{gr(y.path),Ma(Ke=>{const At=new Set(Ke);return At.has(y.path)?At.delete(y.path):At.add(y.path),At})},children:[X?o.jsx(pd,{size:13}):o.jsx(Xo,{size:13}),o.jsx(Tm,{size:14}),o.jsx("span",{children:R})]}),!jt&&o.jsxs(o.Fragment,{children:[o.jsx("button",{className:"file-entry-action",title:r("editor.move"),"aria-label":r("editor.move"),onClick:()=>{yr(y),Ni("")},children:o.jsx(Dc,{size:13})}),he&&o.jsx("button",{className:"file-entry-action danger-text",title:r("editor.deletePath"),"aria-label":r("editor.deletePath"),onClick:()=>{wr(y),_n("")},children:o.jsx(dn,{size:13})})]})]},y.path):o.jsxs("div",{className:`file-entry${x===y.path?" active":""}${ue?" root-document":""}${Ve?" compile-target":""}`,style:{paddingLeft:`${j*13+18}px`},children:[o.jsxs("button",{className:"file-entry-main",title:Ve?r("editor.currentMainDocument",{path:y.path}):ue?r("editor.mainDocumentCandidate",{path:y.path}):y.path,onClick:()=>Va(y),children:[ue?o.jsx(fd,{size:13}):o.jsx(Gn,{size:13}),o.jsx("span",{children:R}),Ve&&o.jsx("small",{children:r("editor.currentMainShort")})]}),!jt&&o.jsxs(o.Fragment,{children:[o.jsx("button",{className:"file-entry-action",title:r("editor.move"),"aria-label":r("editor.move"),onClick:()=>{yr(y),Ni("")},children:o.jsx(Dc,{size:13})}),he&&o.jsx("button",{className:"file-entry-action danger-text",title:r("editor.deletePath"),"aria-label":r("editor.deletePath"),onClick:()=>{wr(y),_n("")},children:o.jsx(dn,{size:13})})]})]},y.path)})]})]}),o.jsxs("section",{className:"outline-panel",children:[o.jsx("div",{className:"panel-title",children:o.jsxs("span",{children:[o.jsx(_m,{size:14}),r("common.outline")]})}),o.jsxs("div",{className:"outline",children:[Ga.map((y,j)=>o.jsxs("button",{className:`outline-item${x===y.path&&C.line===y.line?" current":""}`,title:`${y.path}:${y.line}`,onClick:()=>{Tn(y.path,y.line,1),On(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===x?y.line:y.path.split("/").at(-1)}),o.jsx("span",{className:"outline-title",children:y.title})]},`${y.path}-${y.line}-${j}`)),Ga.length===0&&o.jsx("p",{className:"muted padded",children:r("editor.noOutline")})]})]})]})}),Fn&&o.jsx(Fi,{className:"resize-handle",children:o.jsx(qi,{size:12})}),Fn&&o.jsx(kr,{id:"source",order:2,defaultSize:42,minSize:22,children:o.jsxs("main",{className:"source-panel",children:[o.jsx(h.Suspense,{fallback:o.jsxs("div",{className:"preview-empty",children:[o.jsx(kt,{className:"spin",size:22}),o.jsx("span",{children:r("common.loading")})]}),children:o.jsx(_b,{value:O,readOnly:jt,comments:_s,focusComment:xh,preferences:oe,completionIndex:u,spellCheckIssues:w.issues,spellCheckJump:w.jump,jumpTo:D===x&&pr?.path===x?pr:null,searchRequest:0,collaboration:Ya?{text:Ya,awareness:ke.awareness}:void 0,onChange:ie,onSelection:(y,j,R)=>ft({selectedText:y,startOffset:j,endOffset:R}),onCommentClick:y=>{const j=_s.find(R=>R.id===y);j&&(Ha({...j}),at("comments"))},onSpellCheckReplace:Fh,onCursor:lr},x)}),qa&&o.jsx("div",{className:"editor-centered-notice",role:"status","aria-live":"polite",children:qa})]})}),Fn&&Ja&&o.jsxs(Fi,{className:"resize-handle sync-resize-handle",children:[o.jsx(qi,{className:"resize-grip",size:12}),o.jsxs("span",{className:"sync-direction-buttons",onPointerDown:y=>y.stopPropagation(),children:[o.jsx("button",{disabled:!fr,title:r("editor.showInSource"),"aria-label":r("editor.showInSource"),onClick:Ts,children:o.jsx("span",{"aria-hidden":!0,children:"←"})}),o.jsx("button",{disabled:!x||!Lt,title:r("editor.showInPdf"),"aria-label":r("editor.showInPdf"),onClick:()=>{On(x,C.line,C.column)},children:o.jsx("span",{"aria-hidden":!0,children:"→"})})]})]}),Ja&&o.jsx(kr,{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:()=>Y("pdf"),title:Ln?r("editor.pdfCompiledAtFor",{file:S,time:new Date(Ln).toLocaleString(ge.resolvedLanguage)}):r("editor.currentMainDocument",{path:S}),children:[o.jsx(Gn,{size:16}),o.jsxs("span",{className:"pdf-tab-label",children:["PDF · ",Ih,Xa&&o.jsx("small",{children:Xa})]})]}),o.jsxs("button",{role:"tab","aria-selected":ce==="diagnostics",className:`diagnostics-tab${ce==="diagnostics"?" active":""}`,onClick:()=>xe("diagnostics"),children:[o.jsx(jo,{size:14}),r("editor.outputTabs"),o.jsx("span",{children:Mh})]})]}),Za&&o.jsxs("a",{className:"pdf-download-top",href:Za,download:!0,title:r("editor.downloadPdf"),"aria-label":r("editor.downloadPdf"),children:[o.jsx(Bs,{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":se==="log",className:se==="log"?"active":"",onClick:()=>Y("log"),children:[o.jsx(jo,{size:13}),r("editor.log")]}),o.jsxs("button",{role:"tab","aria-selected":se==="warnings",className:se==="warnings"?"active":"",onClick:()=>Y("warnings"),children:[o.jsx(os,{size:13}),r("editor.warnings"),o.jsx("span",{children:An.warnings.length})]}),o.jsxs("button",{role:"tab","aria-selected":se==="errors",className:se==="errors"?"active":"",onClick:()=>Y("errors"),children:[o.jsx(Zo,{size:13}),r("editor.errors"),o.jsx("span",{children:An.errors.length})]}),o.jsxs("button",{role:"tab","aria-selected":se==="artifacts",className:se==="artifacts"?"active":"",onClick:()=>Y("artifacts"),children:[o.jsx(wd,{size:13}),r("editor.artifacts"),o.jsx("span",{children:Ri.length})]}),o.jsxs("button",{role:"tab","aria-selected":se==="clean",className:se==="clean"?"active":"",onClick:()=>Y("clean"),children:[o.jsx(vo,{size:13}),r("editor.clean")]})]}),o.jsxs("div",{className:`preview-content preview-${ce} ${ce==="diagnostics"?`preview-${se}`:""}`,children:[ce==="pdf"&&(Lt?o.jsx(h.Suspense,{fallback:o.jsxs("div",{className:"pdf-loading-state",role:"status","aria-live":"polite",children:[o.jsx(kt,{className:"spin",size:24}),o.jsx("span",{children:r("editor.loadingPdf")})]}),children:o.jsx(Pb,{url:Lt,target:hr,compiling:In,onViewportLocation:(y,j,R)=>Ns({page:y,x:j,y:R}),onDoubleClickLocation:(y,j,R)=>{Ns({page:y,x:j,y:R}),ji(y,j,R)}})}):_i?o.jsxs("div",{className:"pdf-loading-state",role:"status","aria-live":"polite",children:[o.jsx(kt,{className:"spin",size:24}),o.jsx("span",{children:r("editor.loadingPdf")})]}):o.jsxs("div",{className:"preview-empty",children:[o.jsx(Gn,{size:28}),o.jsx("strong",{children:r("editor.preview")}),o.jsx("span",{children:r("editor.previewHint")})]})),ce==="diagnostics"&&se==="log"&&o.jsx(ao,{lines:br?br.split(`
14
+ `):[],empty:r(Li?"editor.compiling":"editor.noLog")}),ce==="diagnostics"&&se==="warnings"&&(vr?o.jsx(pl,{tone:"warning",diagnostics:vr.warnings,files:Os,empty:r("editor.noWarnings"),onJump:(y,j,R)=>{ve==="pdf-only"&&Cr("editor-pdf"),Tn(y,j,R)}}):o.jsx(ao,{tone:"warning",lines:An.warnings,empty:r("editor.noWarnings")})),ce==="diagnostics"&&se==="errors"&&(vr?o.jsx(pl,{tone:"error",diagnostics:vr.errors,files:Os,empty:r("editor.noErrors"),onJump:(y,j,R)=>{ve==="pdf-only"&&Cr("editor-pdf"),Tn(y,j,R)}}):o.jsx(ao,{tone:"error",lines:An.errors,empty:r("editor.noErrors")})),ce==="diagnostics"&&se==="artifacts"&&o.jsx(pb,{projectId:n,mainFile:S,artifacts:Ri,preview:Oh,loading:Ph,onView:y=>{Lh(y)}}),ce==="diagnostics"&&se==="clean"&&o.jsx(mb,{mainFile:S,disabled:jt||!We||In,cleaning:Wa,onCleanCache:()=>ae("cache"),onCleanArtifacts:()=>ae("artifacts")})]})]})}),ze&&o.jsxs(o.Fragment,{children:[o.jsx(Fi,{className:"resize-handle",children:o.jsx(qi,{size:12})}),o.jsx(kr,{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(ze==="comments"?"editor.sourceComments":"editor.projectSettings")}),o.jsx("button",{"aria-label":r("common.close"),onClick:()=>at(null),children:o.jsx(Qo,{size:17})})]}),ze==="comments"&&o.jsxs("div",{className:"comments",children:[_s.map(y=>o.jsx(ub,{comment:y,currentUserId:e.id,onFocus:()=>Ha({...y}),onToggle:()=>{jh(y)},onReply:j=>kh(y,j),onEdit:j=>Eh(y,j),onDelete:()=>Dh(y),onEditReply:(j,R)=>Nh(y,j,R),onDeleteReply:j=>Th(y,j)},y.id)),_s.length===0&&o.jsx("p",{className:"muted padded",children:r("editor.noComments")})]}),ze==="settings"&&o.jsx(fb,{project:i,projectId:n,site:t,files:Os,dictionaryWords:d,onDictionaryChange:f,editorPreferences:oe,onEditorPreferences:Ah,spellCheckCount:w.summary?.total??null,spellCheckUniqueCount:w.summary?.unique??null,spellCheckIndex:w.summary?w.index:-1,onSpellCheckNavigate:w.jumpToIssue,onProject:a})]})})]})]}),o.jsxs(Me,{open:!!Ne,extraWide:Ne?.kind==="image"||Ne?.kind==="pdf"||Ne?.kind==="text",title:Ne?.path??"",description:Ne?.kind==="large"?r("editor.resourceTooLarge",{size:sh(Ne.size),limit:"10 MB"}):r(`editor.resourcePreview.${Ne?.kind??"text"}`),onOpenChange:y=>{y||(Fa(null),ch(!1))},footer:Ne&&o.jsxs("a",{className:"primary resource-download",href:`${Ne.url}&download=1`,download:!0,children:[o.jsx(Bs,{size:14}),r("editor.downloadResource")]}),children:[Ne?.kind==="large"&&o.jsxs("div",{className:"resource-preview-message",children:[o.jsx(So,{size:34}),o.jsx("strong",{children:r("editor.resourceTooLargeTitle")}),o.jsx("span",{children:r("editor.resourceTooLargeDescription")})]}),Ne?.kind==="unsupported"&&o.jsxs("div",{className:"resource-preview-message",children:[o.jsx(So,{size:34}),o.jsx("strong",{children:r("editor.resourceUnsupportedTitle")}),o.jsx("span",{children:r("editor.resourceUnsupportedDescription")})]}),Ne?.kind==="image"&&o.jsx("div",{className:"resource-image-wrap",children:o.jsx("img",{className:"resource-image",src:Ne.url,alt:Ne.path})}),Ne?.kind==="pdf"&&o.jsx("iframe",{className:"resource-pdf",src:Ne.url,title:Ne.path}),Ne?.kind==="text"&&(ah?o.jsxs("div",{className:"resource-preview-message",children:[o.jsx(kt,{className:"spin",size:24}),o.jsx("span",{children:r("common.loading")})]}):o.jsx("pre",{className:"resource-text",children:Ne.content}))]}),o.jsx(is,{open:!!Oi,title:r("editor.uploadOverwriteTitle"),description:r("editor.uploadOverwriteDescription",{files:Oi?.collisions.join(", ")??""}),confirmLabel:r("editor.uploadOverwrite"),danger:!0,onCancel:()=>Ua(null),onConfirm:()=>{const y=Oi;Ua(null),y&&Ba(y.files,new Set(y.collisions),y.directory)}}),o.jsx(is,{open:!!Le,title:r(Le==="cache"?"editor.cleanCacheConfirmTitle":"editor.cleanArtifactsConfirmTitle"),description:r(Le==="cache"?"editor.cleanCacheConfirmDescription":"editor.cleanArtifactsConfirmDescription"),confirmLabel:r("editor.cleanConfirm"),danger:Le==="artifacts",onCancel:()=>ae(null),onConfirm:()=>{const y=Le;ae(null),y&&Rh(y)}}),o.jsx(Me,{open:ih,title:r("editor.newFile"),description:r("editor.newFileDescription"),onOpenChange:y=>{Ei(y),y||_n("")},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>Ei(!1),children:r("common.cancel")}),o.jsx("button",{className:"primary",onClick:()=>{mh()},children:r("common.create")})]}),children:o.jsxs(o.Fragment,{children:[sn&&o.jsx("p",{className:"error dialog-error",children:sn}),o.jsxs("label",{className:"form-field",children:[r("editor.filePath"),o.jsx("input",{autoFocus:!0,value:oh,onChange:y=>Aa(y.target.value)})]})]})}),o.jsx(Me,{open:lh,title:r("editor.newFolder"),description:r("editor.folderDestination",{folder:qt||r("editor.projectRoot")}),onOpenChange:y=>{Di(y),y||_n("")},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>Di(!1),children:r("common.cancel")}),o.jsx("button",{className:"primary",onClick:()=>{za()},children:r("common.create")})]}),children:o.jsxs(o.Fragment,{children:[sn&&o.jsx("p",{className:"error dialog-error",children:sn}),o.jsxs("label",{className:"form-field",children:[r("editor.folderName"),o.jsx("input",{autoFocus:!0,value:dh,onChange:y=>Ia(y.target.value),onKeyDown:y=>{y.key==="Enter"&&za()}})]})]})}),o.jsx(Me,{open:!!Ps,title:r("editor.moveTitle",{name:Ps?.path.split("/").at(-1)??""}),description:r("editor.moveDescription"),onOpenChange:y=>{y||(yr(null),_n(""))},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>yr(null),children:r("common.cancel")}),o.jsx("button",{className:"primary",onClick:()=>{yh()},children:r("editor.move")})]}),children:o.jsxs(o.Fragment,{children:[sn&&o.jsx("p",{className:"error dialog-error",children:sn}),o.jsxs("label",{className:"form-field",children:[r("editor.destinationFolder"),o.jsxs("select",{value:hh,onChange:y=>Ni(y.target.value),children:[o.jsx("option",{value:"",children:r("editor.projectRoot")}),fh.filter(y=>Ps?.type!=="directory"||y.path!==Ps.path&&!y.path.startsWith(`${Ps.path}/`)).map(y=>o.jsx("option",{value:y.path,children:y.path},y.path))]})]})]})}),o.jsx(Me,{open:!!Rn,title:r("editor.deletePathTitle",{name:Rn?.path.split("/").at(-1)??""}),description:Ai.length?r("editor.deletePathActiveDescription",{path:Rn?.path??"",users:[...new Set(Ai.map(y=>y.name))].join(", ")}):r("editor.deletePathDescription",{path:Rn?.path??""}),onOpenChange:y=>{y||(wr(null),_n(""))},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>wr(null),children:r("common.cancel")}),o.jsx("button",{className:"danger",onClick:()=>{wh()},children:r("common.delete")})]}),children:o.jsxs(o.Fragment,{children:[sn&&o.jsx("p",{className:"error dialog-error",children:sn}),Ai.length>0&&o.jsxs("p",{className:"warning",children:[o.jsx(os,{size:15}),r("editor.deletePathWillClose")]})]})}),o.jsxs(Me,{open:bh,title:r("editor.addComment"),description:Z.selectedText?r("editor.commentDescription",{count:Z.endOffset-Z.startOffset}):r("editor.pointComment"),onOpenChange:Pi,footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>Pi(!1),children:r("common.cancel")}),o.jsx("button",{className:"primary",onClick:()=>{Ch()},children:r("editor.addComment")})]}),children:[o.jsxs("label",{className:"form-field",children:[r("editor.commentContent"),o.jsx("textarea",{autoFocus:!0,rows:5,value:vh,onChange:y=>Sh(y.target.value)})]}),Z.selectedText&&o.jsx("blockquote",{className:"selection-preview",children:Z.selectedText})]}),o.jsx(hb,{open:q,onOpenChange:He,project:i,projectId:n}),qe&&o.jsx(h.Suspense,{fallback:null,children:o.jsx(Fb,{open:!0,files:Os,onOpenChange:Xe,onOpenFile:y=>{const j=Os.find(R=>R.path===y);j&&Va(j)}})}),en&&o.jsx(h.Suspense,{fallback:null,children:o.jsx(Ab,{open:!0,project:i,onOpenChange:vt,onJump:(y,j,R)=>{ve==="pdf-only"&&Cr("editor-pdf"),Tn(y,j,R)}})}),B&&o.jsx(h.Suspense,{fallback:null,children:o.jsx(Lb,{open:!0,onOpenChange:we,project:i,onBeforeMutation:i.permission==="read"?async()=>!0:lt})}),i.ownerId===e.id&&pt&&o.jsx(h.Suspense,{fallback:null,children:o.jsx(Rb,{open:!0,onOpenChange:M,project:i,onBeforeMutation:lt})})]})}function qb(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 sh(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`}function Wb(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}Vh.createRoot(document.getElementById("root")).render(o.jsx(h.StrictMode,{children:o.jsx(Mb,{})}));export{ym as A,pd as C,Gn as F,Om as G,kt as L,Me as M,Um as R,qr as S,dn as T,sv as U,Zt as _,ev as a,tv as b,Qb as c,nv as d,jn as e,Yb as f,Wt as g,Jb as h,F as i,Xo as j,L as k,is as l,sa as m,zm as n,Nm as o,vm as p,Zb as r,Xb as t};