texlite 0.5.5 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/client/assets/{BinaryModule-Aj1vLnwf-BsIXahIW.js → BinaryModule-Aj1vLnwf-hZ2K_uyt.js} +1 -1
- package/dist/client/assets/{GitDialog-CFzsF7ys.js → GitDialog-s54eAFX6.js} +1 -1
- package/dist/client/assets/{HistoryDialog-YPiAOGU_.js → HistoryDialog-DrUnIy0a.js} +1 -1
- package/dist/client/assets/{LatexEditor-BX4WLdhS.js → LatexEditor-Y5KfVqQI.js} +20 -20
- package/dist/client/assets/PdfPreview-BPKX-qpr.js +1 -0
- package/dist/client/assets/{ProjectNavigationDialogs-BZanedGt.js → ProjectNavigationDialogs-CjZX0g7O.js} +1 -1
- package/dist/client/assets/{SystemMetricsDialog-DnH4c7Se.js → SystemMetricsDialog-B97Og0La.js} +1 -1
- package/dist/client/assets/binary-DCBFVo4B.js +1 -0
- package/dist/client/assets/index-5ajAy27z.css +1 -0
- package/dist/client/assets/index-CCitTPyj.js +17 -0
- package/dist/client/assets/{index-B5iMrEn5.js → index-CQG_gpuU.js} +1 -1
- package/dist/client/assets/{plus-B-DG5h4y.js → plus-Bp4_lUor.js} +1 -1
- package/dist/client/assets/{spellCheck-4xuNPF_M.js → spellCheck-0f5ZG5IV.js} +3 -3
- package/dist/client/index.html +2 -2
- package/dist/server/app.js +889 -337
- package/dist/server/archive.js +20 -3
- package/dist/server/auth.js +13 -2
- package/dist/server/collaboration.js +815 -124
- package/dist/server/compileArtifacts.js +37 -9
- package/dist/server/compiler.js +69 -20
- package/dist/server/db.js +6 -0
- package/dist/server/environment.js +4 -2
- package/dist/server/files.js +172 -25
- package/dist/server/git.js +152 -124
- package/dist/server/history.js +86 -18
- package/dist/server/http.js +26 -0
- package/dist/server/index.js +39 -26
- package/dist/server/instanceLock.js +137 -0
- package/dist/server/latexCompletion.js +23 -1
- package/dist/server/latexFormatter.js +4 -2
- package/dist/server/processTree.js +31 -0
- package/dist/server/projectMutations.js +255 -0
- package/dist/server/projectOutline.js +113 -1
- package/dist/server/projectSearch.js +6 -0
- package/dist/server/routes/compile.js +535 -132
- package/dist/server/security.js +61 -1
- package/dist/server/synctex.js +11 -2
- package/dist/server/zip.js +2 -1
- package/package.json +1 -1
- package/dist/client/assets/PdfPreview-FQ8oxyUx.js +0 -1
- package/dist/client/assets/binary-MtJxbY5b.js +0 -1
- package/dist/client/assets/index-CUa7L47p.css +0 -1
- package/dist/client/assets/index-DdFlmXqA.js +0 -17
|
@@ -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-0f5ZG5IV.js","assets/PdfPreview-BPKX-qpr.js","assets/pdf-DPnwNQHb.js","assets/plus-Bp4_lUor.js","assets/LatexEditor-Y5KfVqQI.js","assets/editor-DMLs-XWi.js","assets/GitDialog-s54eAFX6.js","assets/HistoryDialog-DrUnIy0a.js","assets/ProjectNavigationDialogs-CjZX0g7O.js","assets/SystemMetricsDialog-B97Og0La.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as Qh,r as h,j as o,R as rr,a as Tl,b as ef,u as Le,P as tf,c as Nr,d as zi,e as nf}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 sf="modulepreload",rf=function(t){return"/"+t},lc={},on=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=rf(d),d in lc)return;lc[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":sf,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)})},of="0.6.5";var Bi={};const X=t=>typeof t=="string",Ms=()=>{let t,e;const n=new Promise((s,r)=>{t=s,e=r});return n.resolve=t,n.reject=e,n},dc=t=>t==null?"":""+t,af=(t,e,n)=>{t.forEach(s=>{e[s]&&(n[s]=e[s])})},cf=/###/g,uc=t=>t&&t.indexOf("###")>-1?t.replace(cf,"."):t,hc=t=>!t||X(t),zs=(t,e,n)=>{const s=X(e)?e.split("."):e;let r=0;for(;r<s.length-1;){if(hc(t))return{};const i=uc(s[r]);!t[i]&&n&&(t[i]=new n),Object.prototype.hasOwnProperty.call(t,i)?t=t[i]:t={},++r}return hc(t)?{}:{obj:t,k:uc(s[r])}},fc=(t,e,n)=>{const{obj:s,k:r}=zs(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=zs(t,a,Object);for(;c.obj===void 0&&a.length;)i=`${a[a.length-1]}.${i}`,a=a.slice(0,a.length-1),c=zs(t,a,Object),c?.obj&&typeof c.obj[`${c.k}.${i}`]<"u"&&(c.obj=void 0);c.obj[`${c.k}.${i}`]=n},lf=(t,e,n,s)=>{const{obj:r,k:i}=zs(t,e,Object);r[i]=r[i]||[],r[i].push(n)},qr=(t,e)=>{const{obj:n,k:s}=zs(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,s))return n[s]},df=(t,e,n)=>{const s=qr(t,n);return s!==void 0?s:qr(e,n)},Nl=(t,e,n)=>{for(const s in e)s!=="__proto__"&&s!=="constructor"&&(s in t?X(t[s])||t[s]instanceof String||X(e[s])||e[s]instanceof String?n&&(t[s]=e[s]):Nl(t[s],e[s],n):t[s]=e[s]);return t},jn=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var uf={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const hf=t=>X(t)?t.replace(/[&<>"'\/]/g,e=>uf[e]):t;class ff{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 pf=[" ",",","?","!",";"],mf=new ff(20),gf=(t,e,n)=>{e=e||"",n=n||"";const s=pf.filter(a=>e.indexOf(a)<0&&n.indexOf(a)<0);if(s.length===0)return!0;const r=mf.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},mo=(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},Hs=t=>t?.replace(/_/g,"-"),yf={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 Wr{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||yf,this.options=n,this.debug=n.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,s,r){return r&&!this.debug?null:(X(e[0])&&(e[0]=`${s}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new Wr(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new Wr(this.logger,e)}}var $t=new Wr;class fi{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 pc extends fi{constructor(e,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,s,r={}){const i=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator,a=r.ignoreJSONStructure!==void 0?r.ignoreJSONStructure:this.options.ignoreJSONStructure;let c;e.indexOf(".")>-1?c=e.split("."):(c=[e,n],s&&(Array.isArray(s)?c.push(...s):X(s)&&i?c.push(...s.split(i)):c.push(s)));const l=qr(this.data,c);return!l&&!n&&!s&&e.indexOf(".")>-1&&(e=c[0],n=c[1],s=c.slice(2).join(".")),l||!a||!X(s)?l:mo(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),fc(this.data,c,r),i.silent||this.emit("added",e,n,s,r)}addResources(e,n,s,r={silent:!1}){for(const i in s)(X(s[i])||Array.isArray(s[i]))&&this.addResource(e,n,i,s[i],{silent:!0});r.silent||this.emit("added",e,n,s)}addResourceBundle(e,n,s,r,i,a={silent:!1,skipCopy:!1}){let c=[e,n];e.indexOf(".")>-1&&(c=e.split("."),r=s,s=n,n=c[1]),this.addNamespaces(n);let l=qr(this.data,c)||{};a.skipCopy||(s=JSON.parse(JSON.stringify(s))),r?Nl(l,s,i):l={...l,...s},fc(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 Ol={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 Pl=Symbol("i18next/PATH_KEY");function wf(){const t=[],e=Object.create(null);let n;return e.get=(s,r)=>(n?.revoke?.(),r===Pl?t:(t.push(r),n=Proxy.revocable(s,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function ts(t,e){const{[Pl]:n}=t(wf()),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 mc={},Vi=t=>!X(t)&&typeof t!="boolean"&&typeof t!="number";class Kr extends fi{constructor(e,n={}){super(),af(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=$t.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=Vi(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&&!gf(e,s,r);if(a&&!c){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:X(i)?[i]:i};const d=e.split(s);(s!==r||s===r&&this.options.ns.indexOf(d[0])>-1)&&(i=d.shift()),e=d.join(r)}return{key:e,namespaces:X(i)?[i]:i}}translate(e,n,s){let r=typeof n=="object"?{...n}:n;if(typeof r!="object"&&this.options.overloadTranslationOptionHandler&&(r=this.options.overloadTranslationOptionHandler(arguments)),typeof r=="object"&&(r={...r}),r||(r={}),e==null)return"";typeof e=="function"&&(e=ts(e,{...this.options,...r})),Array.isArray(e)||(e=[String(e)]),e=e.map(_=>typeof _=="function"?ts(_,{...this.options,...r}):String(_));const i=r.returnDetails!==void 0?r.returnDetails:this.options.returnDetails,a=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator,{key:c,namespaces:l}=this.extractFromKey(e[e.length-1],r),d=l[l.length-1];let f=r.nsSeparator!==void 0?r.nsSeparator:this.options.nsSeparator;f===void 0&&(f=":");const u=r.lng||this.language,p=r.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u?.toLowerCase()==="cimode")return p?i?{res:`${d}${f}${c}`,usedKey:c,exactUsedKey:c,usedLng:u,usedNS:d,usedParams:this.getUsedParamsDetails(r)}:`${d}${f}${c}`:i?{res:c,usedKey:c,exactUsedKey:c,usedLng:u,usedNS:d,usedParams:this.getUsedParamsDetails(r)}:c;const m=this.resolve(e,r);let g=m?.res;const w=m?.usedKey||c,b=m?.exactUsedKey||c,v=["[object Number]","[object Function]","[object RegExp]"],k=r.joinArrays!==void 0?r.joinArrays:this.options.joinArrays,P=!this.i18nFormat||this.i18nFormat.handleAsObject,N=r.count!==void 0&&!X(r.count),O=Kr.hasDefaultValue(r),W=N?this.pluralResolver.getSuffix(u,r.count,r):"",E=r.ordinal&&N?this.pluralResolver.getSuffix(u,r.count,{ordinal:!1}):"",G=N&&!r.ordinal&&r.count===0,C=G&&r[`defaultValue${this.options.pluralSeparator}zero`]||r[`defaultValue${W}`]||r[`defaultValue${E}`]||r.defaultValue;let V=g;P&&!g&&O&&(V=C);const Z=Vi(V),R=Object.prototype.toString.apply(V);if(P&&V&&Z&&v.indexOf(R)<0&&!(X(k)&&Array.isArray(V))){if(!r.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const _=this.options.returnedObjectHandler?this.options.returnedObjectHandler(w,V,{...r,ns:l}):`key '${c} (${this.language})' returned an object instead of string.`;return i?(m.res=_,m.usedParams=this.getUsedParamsDetails(r),m):_}if(a){const _=Array.isArray(V),L=_?[]:{},j=_?b:w;for(const H in V)if(Object.prototype.hasOwnProperty.call(V,H)){const he=`${j}${a}${H}`;O&&!g?L[H]=this.translate(he,{...r,defaultValue:Vi(C)?C[H]:void 0,joinArrays:!1,ns:l}):L[H]=this.translate(he,{...r,joinArrays:!1,ns:l}),L[H]===he&&(L[H]=V[H])}g=L}}else if(P&&X(k)&&Array.isArray(g))g=g.join(k),g&&(g=this.extendTranslation(g,e,r,s));else{let _=!1,L=!1;!this.isValidLookup(g)&&O&&(_=!0,g=C),this.isValidLookup(g)||(L=!0,g=c);const H=(r.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&L?void 0:g,he=O&&C!==g&&this.options.updateMissing;if(L||_||he){if(this.logger.log(he?"updateKey":"missingKey",u,d,c,he?C:g),a){const J=this.resolve(c,{...r,keySeparator:!1});J&&J.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 de=this.languageUtils.getFallbackCodes(this.options.fallbackLng,r.lng||this.language);if(this.options.saveMissingTo==="fallback"&&de&&de[0])for(let J=0;J<de.length;J++)Ce.push(de[J]);else this.options.saveMissingTo==="all"?Ce=this.languageUtils.toResolveHierarchy(r.lng||this.language):Ce.push(r.lng||this.language);const we=(J,K,me)=>{const ue=O&&me!==g?me:H;this.options.missingKeyHandler?this.options.missingKeyHandler(J,d,K,ue,he,r):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(J,d,K,ue,he,r),this.emit("missingKey",J,d,K,g)};this.options.saveMissing&&(this.options.saveMissingPlurals&&N?Ce.forEach(J=>{const K=this.pluralResolver.getSuffixes(J,r);G&&r[`defaultValue${this.options.pluralSeparator}zero`]&&K.indexOf(`${this.options.pluralSeparator}zero`)<0&&K.push(`${this.options.pluralSeparator}zero`),K.forEach(me=>{we([J],c+me,r[`defaultValue${me}`]||C)})}):we(Ce,c,C))}g=this.extendTranslation(g,e,r,m,s),L&&g===c&&this.options.appendNamespaceToMissingKey&&(g=`${d}${f}${c}`),(L||_)&&this.options.parseMissingKeyHandler&&(g=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${d}${f}${c}`:c,_?g:void 0,r))}return i?(m.res=g,m.usedParams=this.getUsedParamsDetails(r),m):g}extendTranslation(e,n,s,r,i){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...s},s.lng||this.language||r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!s.skipInterpolation){s.interpolation&&this.interpolator.init({...s,interpolation:{...this.options.interpolation,...s.interpolation}});const l=X(e)&&(s?.interpolation?.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let d;if(l){const u=e.match(this.interpolator.nestingRegexp);d=u&&u.length}let f=s.replace&&!X(s.replace)?s.replace:s;if(this.options.interpolation.defaultVariables&&(f={...this.options.interpolation.defaultVariables,...f}),e=this.interpolator.interpolate(e,f,s.lng||this.language||r.usedLng,s),l){const u=e.match(this.interpolator.nestingRegexp),p=u&&u.length;d<p&&(s.nest=!1)}!s.lng&&r&&r.res&&(s.lng=this.language||r.usedLng),s.nest!==!1&&(e=this.interpolator.nest(e,(...u)=>i?.[0]===u[0]&&!s.context?(this.logger.warn(`It seems you are nesting recursively key: ${u[0]} in key: ${n[0]}`),null):this.translate(...u,n),s)),s.interpolation&&this.interpolator.reset()}const a=s.postProcess||this.options.postProcess,c=X(a)?[a]:a;return e!=null&&c?.length&&s.applyPostProcessor!==!1&&(e=Ol.handle(c,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...r,usedParams:this.getUsedParamsDetails(s)},...s}:s,this)),e}resolve(e,n={}){let s,r,i,a,c;return X(e)&&(e=[e]),Array.isArray(e)&&(e=e.map(l=>typeof l=="function"?ts(l,{...this.options,...n}):l)),e.forEach(l=>{if(this.isValidLookup(s))return;const d=this.extractFromKey(l,n),f=d.key;r=f;let u=d.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));const p=n.count!==void 0&&!X(n.count),m=p&&!n.ordinal&&n.count===0,g=n.context!==void 0&&(X(n.context)||typeof n.context=="number")&&n.context!=="",w=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);u.forEach(b=>{this.isValidLookup(s)||(c=b,!mc[`${w[0]}-${b}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(c)&&(mc[`${w[0]}-${b}`]=!0,this.logger.warn(`key "${r}" for languages "${w.join(", ")}" won't get resolved as namespace "${c}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),w.forEach(v=>{if(this.isValidLookup(s))return;a=v;const k=[f];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(k,f,v,b,n);else{let N;p&&(N=this.pluralResolver.getSuffix(v,n.count,n));const O=`${this.options.pluralSeparator}zero`,W=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(n.ordinal&&N.indexOf(W)===0&&k.push(f+N.replace(W,this.options.pluralSeparator)),k.push(f+N),m&&k.push(f+O)),g){const E=`${f}${this.options.contextSeparator||"_"}${n.context}`;k.push(E),p&&(n.ordinal&&N.indexOf(W)===0&&k.push(E+N.replace(W,this.options.pluralSeparator)),k.push(E+N),m&&k.push(E+O))}}let P;for(;P=k.pop();)this.isValidLookup(s)||(i=P,s=this.getResource(v,b,P,n))}))})}),{res:s,usedKey:r,exactUsedKey:i,usedLng:a,usedNS:c}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,s,r={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,s,r):this.resourceStore.getResource(e,n,s,r)}getUsedParamsDetails(e={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],s=e.replace&&!X(e.replace);let r=s?e.replace:e;if(s&&typeof e.count<"u"&&(r.count=e.count),this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),!s){r={...r};for(const i of n)delete r[i]}return r}static hasDefaultValue(e){const n="defaultValue";for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)&&n===s.substring(0,n.length)&&e[s]!==void 0)return!0;return!1}}class gc{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=$t.create("languageUtils")}getScriptPartFromCode(e){if(e=Hs(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=Hs(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(X(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let n;return e.forEach(s=>{if(n)return;const r=this.formatLanguageCode(s);(!this.options.supportedLngs||this.isSupportedCode(r))&&(n=r)}),!n&&this.options.supportedLngs&&e.forEach(s=>{if(n)return;const r=this.getScriptPartFromCode(s);if(this.isSupportedCode(r))return n=r;const i=this.getLanguagePartFromCode(s);if(this.isSupportedCode(i))return n=i;n=this.options.supportedLngs.find(a=>{if(a===i)return a;if(!(a.indexOf("-")<0&&i.indexOf("-")<0)&&(a.indexOf("-")>0&&i.indexOf("-")<0&&a.substring(0,a.indexOf("-"))===i||a.indexOf(i)===0&&i.length>1))return a})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),X(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let s=e[n];return s||(s=e[this.getScriptPartFromCode(n)]),s||(s=e[this.formatLanguageCode(n)]),s||(s=e[this.getLanguagePartFromCode(n)]),s||(s=e.default),s||[]}toResolveHierarchy(e,n){const s=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],e),r=[],i=a=>{a&&(this.isSupportedCode(a)?r.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return X(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&i(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&i(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&i(this.getLanguagePartFromCode(e))):X(e)&&i(this.formatLanguageCode(e)),s.forEach(a=>{r.indexOf(a)<0&&i(this.formatLanguageCode(a))}),r}}const yc={zero:0,one:1,two:2,few:3,many:4,other:5},wc={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class xf{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=$t.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const s=Hs(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!"),wc;if(!e.match(/-|_/))return wc;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)=>yc[r]-yc[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 xc=(t,e,n,s=".",r=!0)=>{let i=df(t,e,n);return!i&&r&&X(n)&&(i=mo(t,n,s),i===void 0&&(i=mo(e,n,s))),i},Hi=t=>t.replace(/\$/g,"$$$$");class bc{constructor(e={}){this.logger=$t.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(n=>n),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:n,escapeValue:s,useRawValueToEscape:r,prefix:i,prefixEscaped:a,suffix:c,suffixEscaped:l,formatSeparator:d,unescapeSuffix:f,unescapePrefix:u,nestingPrefix:p,nestingPrefixEscaped:m,nestingSuffix:g,nestingSuffixEscaped:w,nestingOptionsSeparator:b,maxReplaces:v,alwaysFormat:k}=e.interpolation;this.escape=n!==void 0?n:hf,this.escapeValue=s!==void 0?s:!0,this.useRawValueToEscape=r!==void 0?r:!1,this.prefix=i?jn(i):a||"{{",this.suffix=c?jn(c):l||"}}",this.formatSeparator=d||",",this.unescapePrefix=f?"":u||"-",this.unescapeSuffix=this.unescapePrefix?"":f||"",this.nestingPrefix=p?jn(p):m||jn("$t("),this.nestingSuffix=g?jn(g):w||jn(")"),this.nestingOptionsSeparator=b||",",this.maxReplaces=v||1e3,this.alwaysFormat=k!==void 0?k:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,s)=>n?.source===s?(n.lastIndex=0,n):new RegExp(s,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,s,r){let i,a,c;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},d=m=>{if(m.indexOf(this.formatSeparator)<0){const v=xc(n,l,m,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(v,void 0,s,{...r,...n,interpolationkey:m}):v}const g=m.split(this.formatSeparator),w=g.shift().trim(),b=g.join(this.formatSeparator).trim();return this.format(xc(n,l,w,this.options.keySeparator,this.options.ignoreJSONStructure),b,s,{...r,...n,interpolationkey:w})};this.resetRegExp();const f=r?.missingInterpolationHandler||this.options.missingInterpolationHandler,u=r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:m=>Hi(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?Hi(this.escape(m)):Hi(m)}].forEach(m=>{for(c=0;i=m.regex.exec(e);){const g=i[1].trim();if(a=d(g),a===void 0)if(typeof f=="function"){const b=f(e,i,r);a=X(b)?b:""}else if(r&&Object.prototype.hasOwnProperty.call(r,g))a="";else if(u){a=i[0];continue}else this.logger.warn(`missed to pass in variable ${g} for interpolating ${e}`),a="";else!X(a)&&!this.useRawValueToEscape&&(a=dc(a));const w=m.safeValue(a);if(e=e.replace(i[0],w),u?(m.regex.lastIndex+=a.length,m.regex.lastIndex-=i[0].length):m.regex.lastIndex=0,c++,c>=this.maxReplaces)break}}),e}nest(e,n,s={}){let r,i,a;const c=(l,d)=>{const f=this.nestingOptionsSeparator;if(l.indexOf(f)<0)return l;const u=l.split(new RegExp(`${jn(f)}[ ]*{`));let p=`{${u[1]}`;l=u[0],p=this.interpolate(p,a);const m=p.match(/'/g),g=p.match(/"/g);((m?.length??0)%2===0&&!g||(g?.length??0)%2!==0)&&(p=p.replace(/'/g,'"'));try{a=JSON.parse(p),d&&(a={...d,...a})}catch(w){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,w),`${l}${f}${p}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,l};for(;r=this.nestingRegexp.exec(e);){let l=[];a={...s},a=a.replace&&!X(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;const d=/{.*}/.test(r[1])?r[1].lastIndexOf("}")+1:r[1].indexOf(this.formatSeparator);if(d!==-1&&(l=r[1].slice(d).split(this.formatSeparator).map(f=>f.trim()).filter(Boolean),r[1]=r[1].slice(0,d)),i=n(c.call(this,r[1].trim(),a),a),i&&r[0]===e&&!X(i))return i;X(i)||(i=dc(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 bf=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}},vc=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(Hs(s),r),e[a]=c),c(n)}},vf=t=>(e,n,s)=>t(Hs(n),s)(e);class Sf{constructor(e={}){this.logger=$t.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const s=n.cacheInBuiltFormats?vc:vf;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()]=vc(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}=bf(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 Cf=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class jf extends fi{constructor(e,n,s,r={}){super(),this.backend=e,this.store=n,this.services=s,this.languageUtils=s.languageUtils,this.options=r,this.logger=$t.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=>{lf(l.loaded,[i],a),Cf(l,e),n&&l.errors.push(n),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(d=>{c[d]||(c[d]={});const f=l.loaded[d];f.length&&f.forEach(u=>{c[d][u]===void 0&&(c[d][u]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",c),this.queue=this.queue.filter(l=>!l.done)}read(e,n,s,r=0,i=this.retryTimeout,a){if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:s,tried:r,wait:i,callback:a});return}this.readingCalls++;const c=(d,f)=>{if(this.readingCalls--,this.waitingReads.length>0){const u=this.waitingReads.shift();this.read(u.lng,u.ns,u.fcName,u.tried,u.wait,u.callback)}if(d&&f&&r<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,s,r+1,i*2,a)},i);return}a(d,f)},l=this.backend[s].bind(this.backend);if(l.length===2){try{const d=l(e,n);d&&typeof d.then=="function"?d.then(f=>c(null,f)).catch(c):c(null,d)}catch(d){c(d)}return}return l(e,n,c)}prepareLoading(e,n,s={},r){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),r&&r();X(e)&&(e=this.languageUtils.toResolveHierarchy(e)),X(n)&&(n=[n]);const i=this.queueLoad(e,n,s,r);if(!i.toLoad.length)return i.pending.length||r(),null;i.toLoad.forEach(a=>{this.loadOne(a)})}load(e,n,s){this.prepareLoading(e,n,{},s)}reload(e,n,s){this.prepareLoading(e,n,{reload:!0},s)}loadOne(e,n=""){const s=e.split("|"),r=s[0],i=s[1];this.read(r,i,"read",void 0,void 0,(a,c)=>{a&&this.logger.warn(`${n}loading namespace ${i} for language ${r} failed`,a),!a&&c&&this.logger.log(`${n}loaded namespace ${i} for language ${r}`,c),this.loaded(e,a,c)})}saveMissing(e,n,s,r,i,a={},c=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${s}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(s==null||s==="")){if(this.backend?.create){const l={...a,isUpdate:i},d=this.backend.create.bind(this.backend);if(d.length<6)try{let f;d.length===5?f=d(e,n,s,r,l):f=d(e,n,s,r),f&&typeof f.then=="function"?f.then(u=>c(null,u)).catch(c):c(null,f)}catch(f){c(f)}else d(e,n,s,r,c,l)}!e||!e[0]||this.store.addResource(e[0],n,s,r)}}}const qi=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if(typeof t[1]=="object"&&(e=t[1]),X(t[1])&&(e.defaultValue=t[1]),X(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const n=t[3]||t[2];Object.keys(n).forEach(s=>{e[s]=n[s]})}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),Sc=t=>(X(t.ns)&&(t.ns=[t.ns]),X(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),X(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs?.indexOf?.("cimode")<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),typeof t.initImmediate=="boolean"&&(t.initAsync=t.initImmediate),t),Or=()=>{},kf=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})},_l="__i18next_supportNoticeShown",Ef=()=>!!(typeof globalThis<"u"&&globalThis[_l]||typeof process<"u"&&Bi&&Bi.I18NEXT_NO_SUPPORT_NOTICE||typeof process<"u"&&Bi),Df=()=>{typeof globalThis<"u"&&(globalThis[_l]=!0)},Tf=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 Bs extends fi{constructor(e={},n){if(super(),this.options=Sc(e),this.services={},this.logger=$t,this.modules={external:[]},kf(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(e={},n){this.isInitializing=!0,typeof e=="function"&&(n=e,e={}),e.defaultNS==null&&e.ns&&(X(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const s=qi();this.options={...s,...this.options,...Sc(e)},this.options.interpolation={...s.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator),typeof this.options.overloadTranslationOptionHandler!="function"&&(this.options.overloadTranslationOptionHandler=s.overloadTranslationOptionHandler),this.options.showSupportNotice!==!1&&!Tf(this)&&!Ef()&&(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 💙"),Df());const r=d=>d?typeof d=="function"?new d:d:null;if(!this.options.isClone){this.modules.logger?$t.init(r(this.modules.logger),this.options):$t.init(null,this.options);let d;this.modules.formatter?d=this.modules.formatter:d=Sf;const f=new gc(this.options);this.store=new pc(this.options.resources,this.options);const u=this.services;u.logger=$t,u.resourceStore=this.store,u.languageUtils=f,u.pluralResolver=new xf(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 bc(this.options),u.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},u.backendConnector=new jf(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 Kr(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=Or),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=Ms(),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=Or){let s=n;const r=X(e)?e:this.language;if(typeof e=="function"&&(s=e),!this.options.resources||this.options.partialBundledLanguages){if(r?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return s();const i=[],a=c=>{if(!c||c==="cimode")return;this.services.languageUtils.toResolveHierarchy(c).forEach(d=>{d!=="cimode"&&i.indexOf(d)<0&&i.push(d)})};r?a(r):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(l=>a(l)),this.options.preload?.forEach?.(c=>a(c)),this.services.backendConnector.load(i,this.options.ns,c=>{!c&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),s(c)})}else s(null)}reloadResources(e,n,s){const r=Ms();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=Or),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"&&Ol.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=Ms();this.emit("languageChanging",e);const r=c=>{this.language=c,this.languages=this.services.languageUtils.toResolveHierarchy(c),this.resolvedLanguage=void 0,this.setResolvedLanguage(c)},i=(c,l)=>{l?this.isLanguageChangingTo===e&&(r(l),this.translator.changeLanguage(l),this.isLanguageChangingTo=void 0,this.emit("languageChanged",l),this.logger.log("languageChanged",l)):this.isLanguageChangingTo=void 0,s.resolve((...d)=>this.t(...d)),n&&n(c,(...d)=>this.t(...d))},a=c=>{!e&&!c&&this.services.languageDetector&&(c=[]);const l=X(c)?c:c&&c[0],d=this.store.hasLanguageSomeTranslations(l)?l:this.services.languageUtils.getBestMatchFromCodes(X(c)?[c]:c);d&&(this.language||r(d),this.translator.language||this.translator.changeLanguage(d),this.services.languageDetector?.cacheUserLanguage?.(d)),this.loadResources(d,f=>{i(f,d)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?a(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(e),s}getFixedT(e,n,s){const r=(i,a,...c)=>{let l;typeof a!="object"?l=this.options.overloadTranslationOptionHandler([i,a].concat(c)):l={...a},l.lng=l.lng||r.lng,l.lngs=l.lngs||r.lngs,l.ns=l.ns||r.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||s||r.keyPrefix);const d={...this.options,...l};typeof l.keyPrefix=="function"&&(l.keyPrefix=ts(l.keyPrefix,d));const f=this.options.keySeparator||".";let u;return l.keyPrefix&&Array.isArray(i)?u=i.map(p=>(typeof p=="function"&&(p=ts(p,d)),`${l.keyPrefix}${f}${p}`)):(typeof i=="function"&&(i=ts(i,d)),u=l.keyPrefix?`${l.keyPrefix}${f}${i}`:i),this.t(u,l)};return X(e)?r.lng=e:r.lngs=e,r.ns=n,r.keyPrefix=s,r}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const s=n.lng||this.resolvedLanguage||this.languages[0],r=this.options?this.options.fallbackLng:!1,i=this.languages[this.languages.length-1];if(s.toLowerCase()==="cimode")return!0;const a=(c,l)=>{const d=this.services.backendConnector.state[`${c}|${l}`];return d===-1||d===0||d===2};if(n.precheck){const c=n.precheck(this,a);if(c!==void 0)return c}return!!(this.hasResourceBundle(s,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(s,e)&&(!r||a(i,e)))}loadNamespaces(e,n){const s=Ms();return this.options.ns?(X(e)&&(e=[e]),e.forEach(r=>{this.options.ns.indexOf(r)<0&&this.options.ns.push(r)}),this.loadResources(r=>{s.resolve(),n&&n(r)}),s):(n&&n(),Promise.resolve())}loadLanguages(e,n){const s=Ms();X(e)&&(e=[e]);const r=this.options.preload||[],i=e.filter(a=>r.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return i.length?(this.options.preload=r.concat(i),this.loadResources(a=>{s.resolve(),n&&n(a)}),s):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{const r=new Intl.Locale(e);if(r&&r.getTextInfo){const i=r.getTextInfo();if(i&&i.direction)return i.direction}}catch{}const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],s=this.services?.languageUtils||new gc(qi());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 Bs(e,n);return s.createInstance=Bs.createInstance,s}cloneInstance(e={},n=Or){const s=e.forkResourceStore;s&&delete e.forkResourceStore;const r={...this.options,...e,isClone:!0},i=new Bs(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 pc(c,r),i.services.resourceStore=i.store}if(e.interpolation){const l={...qi().interpolation,...this.options.interpolation,...e.interpolation},d={...r,interpolation:l};i.services.interpolator=new bc(d)}return i.translator=new Kr(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 pe=Bs.createInstance();pe.createInstance;pe.dir;pe.init;pe.loadResources;pe.reloadResources;pe.use;pe.changeLanguage;pe.getFixedT;pe.t;pe.exists;pe.setDefaultNamespace;pe.hasLoadedNamespace;pe.loadNamespaces;pe.loadLanguages;const{slice:Nf,forEach:Of}=[];function Pf(t){return Of.call(Nf.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function _f(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 Cc=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Rf=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(!Cc.test(s.domain))throw new TypeError("option domain is invalid");i+=`; Domain=${s.domain}`}if(s.path){if(!Cc.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},jc={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=Rf(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 Lf={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return jc.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:s,cookieDomain:r,cookieOptions:i}=e;n&&typeof document<"u"&&jc.create(n,t,s,r,i)}},Af={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}},Ff={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 Hn=null;const kc=()=>{if(Hn!==null)return Hn;try{if(Hn=typeof window<"u"&&window.localStorage!==null,!Hn)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Hn=!1}return Hn};var If={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&kc())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&kc()&&window.localStorage.setItem(n,t)}};let qn=null;const Ec=()=>{if(qn!==null)return qn;try{if(qn=typeof window<"u"&&window.sessionStorage!==null,!qn)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{qn=!1}return qn};var Mf={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&Ec())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&Ec()&&window.sessionStorage.setItem(n,t)}},$f={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}},Uf={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}},zf={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}},Bf={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 Rl=!1;try{document.cookie,Rl=!0}catch{}const Ll=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];Rl||Ll.splice(1,1);const Vf=()=>({order:Ll,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class Al{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=Pf(n,this.options||{},Vf()),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(Lf),this.addDetector(Af),this.addDetector(If),this.addDetector(Mf),this.addDetector($f),this.addDetector(Uf),this.addDetector(zf),this.addDetector(Bf),this.addDetector(Ff)}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&&!_f(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)}))}}Al.type="languageDetector";const Hf={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:"中文"},qf={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"},Wf={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",comments:"Comments",unresolvedComments:"{{count}} unresolved comments",unresolvedCommentsTooltip:"{{unresolved}} unresolved / {{total}} total comments",allResolved:"All resolved ({{count}})",allCommentsResolvedTooltip:"All {{count}} comments resolved",noComments:"No comments",unresolvedCount:"{{count}} unresolved",modifiedBy:"Modified by",byUser:"By {{user}}",modifiedByUser:"{{time}} · By {{user}}",deletedUser:"Deleted user",filterTags:"Filter by tag",rename:"Rename",renameTitle:"Rename project",duplicate:"Duplicate",duplicating:"Duplicating…",duplicateTitle:"Duplicate project",duplicateDescription:"Create an independent copy of {{project}}. Files and project settings are copied; members, comments, Git history and compile output are not.",transfer:"Transfer",transferOwnership:"Transfer ownership",transferDescription:"Choose a new owner for {{project}}.",newOwner:"New owner",chooseNewOwner:"Choose a user",noTransferUsers:"No other active users",transferWarning:"You will keep read/write access. Source files, history, comments and members remain; the saved GitHub token is removed so the new owner can add their own credential.",transferForbidden:"Only the current project owner can transfer ownership.",transferTargetInvalid:"Choose a new project owner.",transferSelf:"You already own this project.",download:"Download",deleteTitle:"Delete project",deleteDescription:"Permanently delete {{project}} and all of its files? This cannot be undone.",chooseZip:"Choose a ZIP project",dropZip:"Drag and drop a ZIP archive here",browse:"Browse files",selectedFileSize:"Selected · {{size}}",clearFile:"Clear selected file"},Kf={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"},Gf={saved:"Saved",savedAt:"Saved to server at {{time}}",loading:"Loading",pending:"Waiting to save",saving:"Saving to server",saveFailed:"Save failed",offlineDraft:"Offline · local draft retained",compile:"Compile · {{engine}}",compiling:"Compiling…",compileQueued:"Compile queued…",compileFailedRetained:"Compilation failed; showing the last successful PDF from {{time}}.",compileFailedNoPdf:"Compilation failed and no successful PDF is available.",upToDate:"Files are up to date; no compilation was needed.",compileSnapshotStale:"PDF compiled from a consistent earlier snapshot; newer source changes are not included.",addComment:"Add comment",sourceComments:"Source comments",projectSettings:"Project settings",uploadAttachment:"Upload attachment",newFile:"New text file",binary:"The binary attachment is stored but cannot be opened in the text editor.",noOutline:"No sections in this file",preview:"PDF preview",previewHint:"Compile to generate the document",loadingPdf:"Loading PDF…",pdfCompiledAt:"Compiled successfully at {{time}}",pdfCompiledAtFor:"{{file}} compiled successfully at {{time}}",currentMainDocument:"Current document compiled as the root: {{path}}",mainDocumentCandidate:"LaTeX root document candidate: {{path}}",currentMainShort:"root",deletedUser:"Deleted User",orphaned:"Anchor lost",line:"Line {{line}}",reopen:"Reopen",resolve:"Mark resolved",noComments:"No comments in this file",newFileDescription:"Directories are allowed, for example chapters/introduction.tex.",filePath:"File path",commentDescription:"Selected {{count}} characters",pointComment:"No text selected; the comment will be anchored at the cursor.",commentContent:"Comment",backToProjects:"Back to projects",outputTabs:"Compile output",log:"Log",warnings:"Warnings",errors:"Errors",artifacts:"Artifacts",clean:"Recovery",noLog:"Compile to see the log.",noWarnings:"No warnings in the latest compile.",noErrors:"No errors in the latest compile.",projectRoot:"Project root",uploadTo:"Upload to {{folder}}",dropFiles:"Drop files to upload",newFolder:"New folder",folderName:"Folder name",noArtifacts:"Compile to see generated artifacts.",selectArtifact:"Select a text artifact to preview it.",viewArtifact:"View artifact",downloadArtifact:"Download artifact",downloadToView:"Download this artifact to view it",cleanTitle:"Compilation recovery",cleanDescription:"Use these advanced actions only when compilation is stuck, a previous error is left behind, or generated output is inconsistent. They do not change source files, project settings, comments, history, or Git data.",cleanCache:"Force a clean rebuild",cleanCacheDescription:"Use after a compilation failure or stale latexmk state. Removes the incremental cache while keeping the current successful PDF.",cleanArtifacts:"Remove generated output",cleanArtifactsDescription:"Use when generated files are inconsistent. Removes the PDF, SyncTeX, logs, and intermediate files for this root document.",cleanCacheConfirmTitle:"Force a clean rebuild?",cleanCacheConfirmDescription:"This recovery action removes the incremental latexmk cache. The current PDF remains visible, and the next compilation starts from a clean cache.",cleanArtifactsConfirmTitle:"Remove generated output?",cleanArtifactsConfirmDescription:"This recovery action removes the current PDF and all generated files for this root document. Source files are not affected.",cleanConfirm:"Run recovery",cleanCacheComplete:"Recovery cache cleared. The next compilation will be a full rebuild.",cleanArtifactsComplete:"Generated compilation output removed.",cleanBusy:"This root document is compiling. Try recovery again after it finishes.",folderDestination:"The folder will be created in {{folder}}.",uploadOverwriteTitle:"File already exists",uploadOverwriteDescription:"These files already exist: {{files}}. Replace them?",uploadOverwrite:"Replace files",collapseFiles:"Collapse file panel",move:"Move",moveTitle:"Move {{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",syncTexOnlyForTex:"PDF sync is only available for TeX (.tex) files",syncTexOnlyForMain:"PDF sync is only available for the current main TeX document",openFiles:"Open files",pdfLoadFailed:"The PDF preview could not be loaded",pdfZoomControls:"PDF zoom controls",downloadPdf:"Download PDF",downloadResource:"Download file",resourceTooLarge:"This file is {{size}} and exceeds the direct preview limit of {{limit}}.",resourceTooLargeTitle:"File is too large to preview",resourceTooLargeDescription:"Download the file to open it locally.",resourceUnsupportedTitle:"Preview unavailable",resourceUnsupportedDescription:"This file type cannot be rendered in the browser. Download it to open it locally.",resourcePreview:{image:"Image preview",pdf:"PDF preview",text:"Text preview",unsupported:"File preview"},pdfZoomOut:"Zoom out",pdfZoomIn:"Zoom in",pdfFitWidth:"Fit width",pdfLink:"PDF link",pdfLinks:"PDF links",layout:{label:"Layout",choose:"Choose layout",current:"Current layout: {{layout}}","editor-pdf":{name:"Editor & PDF",description:"Show the source editor and PDF preview side by side"},"editor-only":{name:"Editor only",description:"Use the workspace for source editing"},"pdf-only":{name:"PDF only",description:"Use the workspace for the PDF and compile output"}},collaboration:{connecting:"Connecting collaboration…",connected:"Live collaboration connected",disconnected:"Collaboration disconnected",editing:"Editing",viewing:"Viewing",joining:"Joining project",reconnect:"Reconnect",activeSessions:"{{count}} active sessions",showMoreSessions:"Show {{count}} more sessions",showFewerSessions:"Collapse session list",sessionTooltip:"{{name}} (@{{username}}) · {{file}} · {{activity}} · {{permission}}"},search:{button:"Find",title:"Find and replace (Ctrl+F / Cmd+F)",find:"Find",replace:"Replace",next:"Next",previous:"Previous",all:"Select all",matchCase:"Match case",regexp:"Regular expression",wholeWord:"Whole word",replaceNext:"Replace",replaceAll:"Replace all",currentMatch:"Current match",onLine:"on line",replacedMatchOnLine:"replaced match on line $",replacedMatches:"replaced $ matches",goToLine:"Go to line",go:"Go",matchCount:"{{count}} matches",noMatches:"No matches",invalidQuery:"Invalid regular expression"}},Jf={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."},Yf={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"}},Xf={mainFile:"Main document",engine:"Compiler",latexmkrc:"Project latexmkrc",save:"Save project settings",members:"Shared members",recentLog:"Latest compile log",share:"Share project",shareDescription:"Projects can only be shared with users created by an administrator.",chooseUser:"Choose a user",latexmkrcPlaceholder:`# Empty disables the project rc file
|
|
3
|
+
$pdf_mode = 1;`,addMember:"Add member",noMembers:"This project has not been shared with anyone.",removeTitle:"Remove shared member",removeDescription:"Remove {{username}}? Their account and other projects are unaffected.",editorTab:"Editor appearance",compilerTab:"LaTeX compiler",compilerDescription:"Choose the main document and compiler options shared by everyone in this project.",editorAppearance:"Editor appearance",editorAppearanceDescription:"These preferences are private to this user and project on this browser. The project dictionary is shared.",saveAppearance:"Save appearance",saveCompiler:"Save compiler settings",writingCheckDescription:"Harper runs locally in a worker. Spelling issues use a red wavy underline; grammar issues use yellow. Right-click an issue for suggestions.",projectConfiguration:"Project configuration",fontFamily:"English font",fontSize:"Font size",lineHeight:"Line spacing",dictionary:"Project dictionary",dictionaryDescription:"Words added here are imported into Harper's custom dictionary and ignored by spelling checks for this project. Editors can maintain this list.",dictionaryPlaceholder:"Add a custom word",addWord:"Add word",dictionaryEmpty:"No custom words yet.",lineWrapping:"Wrap long lines",spellCheck:"Spelling and grammar checking",vimMode:"Vim keybindings",vimModeDescription:"Use Vim normal/insert/visual modes in this editor.",vimHelp:"View help",formatOnCompile:"Format LaTeX before compiling",formatOnCompileDescription:"Off by default. Formatting runs on the server immediately before compilation.",formatRequiresWrite:"Formatting requires permission to edit this project.",formatterDescription:"Formatting uses the optional host-side tex-fmt command.",formatterInstall:"Install or view tex-fmt documentation",openFilesInTabs:"Open LaTeX files in editor tabs",openFilesInTabsDescription:"Open .tex, .bib, .sty and other source files in tabs at the top of the editor.",writingIssues:"{{count}} writing issues ({{uniqueCount}} unique)",noWritingIssues:"No spelling or grammar issues found.",spellCheckFirst:"First writing issue",spellCheckPrevious:"Previous writing issue",spellCheckNext:"Next writing issue",spellCheckLast:"Last writing issue",spellCheckPosition:"{{current}}/{{total}}",fontJetBrains:"JetBrains Mono",fontSourceCode:"Source Code Pro",fontIbmPlex:"IBM Plex Mono",fontFiraCode:"Fira Code",fontIosevka:"Iosevka",lineHeightCompact:"Compact",lineHeightNormal:"Normal",lineHeightRelaxed:"Relaxed"},Zf={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"},Qf={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"}}},ep={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"},tp={generic:"Operation failed",request:"Request failed ({{status}})",upload:"Upload failed",boundaryTitle:"Something went wrong",boundaryDescription:"An unexpected error occurred while rendering the page. You can try recovering, or reload the page.",boundaryRetry:"Retry",boundaryReload:"Reload page",fileExists:"A file or folder with this name already exists.",pathConflict:"The destination path is already used by a folder or file.",duplicateUploadNames:"The selected files contain duplicate names: {{files}}.",fileTooLarge:"The file exceeds the {{size}} MB limit.",zipOnly:"Please choose a ZIP archive.",collaborationUnavailable:"Live collaboration is not connected. Reconnect before saving or compiling.",codes:{AUTH_INVALID:"The username or password is incorrect.",CURRENT_PASSWORD_INVALID:"The current password is incorrect.",USER_NOT_FOUND:"The user no longer exists.",LAST_ADMIN:"At least one administrator must remain active.",SELF_DELETE_FORBIDDEN:"You cannot delete the currently signed-in administrator.",PROJECT_CREATE_FORBIDDEN:"You do not have permission to create projects.",PROJECT_NOT_FOUND:"The project does not exist or is no longer accessible.",PROJECT_OWNER_ONLY:"Only the project owner can change this setting.",PROJECT_EDIT_FORBIDDEN:"You do not have edit permission for this project.",DICTIONARY_EDIT_FORBIDDEN:"You do not have permission to maintain this project's dictionary.",TAG_NOT_FOUND:"The selected tag does not exist.",GIT_TOKEN_INVALID:"Enter a GitHub token.",GIT_REPOSITORY_NAME_INVALID:"Enter a GitHub repository name.",GIT_REVISION_INVALID:"Choose a Git revision to check out.",PROJECT_DELETE_FORBIDDEN:"Only the project owner can delete this project.",MEMBERS_MANAGE_FORBIDDEN:"Only the project owner can manage project members.",OWNER_MEMBER_FORBIDDEN:"The project owner cannot be added as a member.",INVALID_PATH:"The file path is invalid.",RESERVED_PATH:"This path is reserved by TexLite.",PATH_EXISTS:"The destination path is already used by a file or folder.",FILE_EXISTS:"A file with this name already exists.",PATH_NOT_FOUND:"The file or folder does not exist.",FILE_NOT_FOUND:"The file does not exist.",DIRECTORY_NOT_FOUND:"The destination folder does not exist.",MOVE_INTO_SELF:"A folder cannot be moved into itself.",MAIN_FILE_DELETE_FORBIDDEN:"The main document cannot be deleted.",FILE_TOO_LARGE:"This file is too large to open or upload.",UPLOAD_EMPTY:"No file was selected for upload.",COMMENT_FILE_NOT_FOUND:"The file for this comment does not exist.",COMMENT_RANGE_INVALID:"The comment source range is invalid.",COMMENT_NOT_FOUND:"The comment does not exist.",COMMENT_EDIT_FORBIDDEN:"You can only edit your own comments.",COMMENT_DELETE_FORBIDDEN:"You can only delete your own comments.",REPLY_NOT_FOUND:"The reply does not exist.",REPLY_EDIT_FORBIDDEN:"You can only edit your own replies.",REPLY_DELETE_FORBIDDEN:"You can only delete your own replies.",COMMENT_UPDATE_EMPTY:"There is no comment content to update.",MAIN_FILE_NOT_FOUND:"The selected main document does not exist.",LATEXMKRC_DISABLED:"Project latexmkrc files are disabled by the administrator.",LATEXMKRC_NOT_FOUND:"The selected latexmkrc file does not exist.",COMPILE_ARTIFACTS_NOT_FOUND:"No compiled artifacts are available yet.",COMPILE_ARTIFACT_NOT_FOUND:"The compiled artifact does not exist.",ARTIFACT_PREVIEW_UNSUPPORTED:"This artifact cannot be previewed as text; download it instead.",SYNC_SOURCE_INVALID:"The source location is invalid.",SOURCE_FILE_NOT_FOUND:"The source file does not exist.",SYNCTEX_NOT_AVAILABLE:"No SyncTeX data is available. Compile the project again.",SYNC_PDF_INVALID:"The PDF location is invalid.",SYNCTEX_EXTERNAL_PATH:"SyncTeX returned a source path outside the project.",COMPILE_FORBIDDEN:"You do not have permission to compile this project.",PDF_NOT_FOUND:"No PDF has been generated yet.",API_NOT_FOUND:"The API endpoint does not exist.",SERVER_ERROR:"The server could not complete the request.",REQUEST_INVALID:"The request is invalid."}},np={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.",compileSnapshotBusy:"The source has not finished saving durably. Wait a moment and try compiling again."},sp={copyright:"© {{year}}",credit:"Designed and developed by CHEN Zhongpu"},rp={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"},ip={common:Hf,auth:qf,projects:Wf,users:Kf,editor:Gf,navigation:Jf,history:Yf,projectSettings:Xf,git:Zf,metrics:Qf,tags:ep,errors:tp,apiErrors:np,footer:sp,completions:rp},op={cancel:"取消",create:"创建",add:"添加",remove:"移除",delete:"删除",close:"关闭",user:"用户",permission:"权限",readOnly:"只读",readWrite:"读写",settings:"设置",comments:"批注",files:"文件",outline:"大纲",loading:"正在载入…",enabled:"允许",disabled:"禁止",normal:"正常",admin:"管理员",language:"语言",languageEnglish:"English",languageChinese:"中文"},ap={tagline:"轻量 LaTeX 写作环境",username:"用户名",password:"密码",login:"登录",contact:"需要账号?请联系 {{email}}",firstLogin:"首次登录,请修改初始密码",currentPassword:"当前密码",newPassword:"新密码",confirmPassword:"确认新密码",updatePassword:"更新密码",mismatch:"两次输入的新密码不一致",passwordMinimum:"至少 {{count}} 位",sessionExpired:"登录状态已过期,请重新登录。",logout:"退出"},cp={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:"已删除用户",comments:"批注",unresolvedComments:"{{count}} 条未解决批注",unresolvedCommentsTooltip:"{{unresolved}} 条未解决批注 / 共 {{total}} 条",allResolved:"全部已解决 ({{count}})",allCommentsResolvedTooltip:"全部 {{count}} 条批注已解决",noComments:"暂无批注",unresolvedCount:"{{count}} 条待解决",filterTags:"按标签过滤",rename:"重命名",renameTitle:"重命名项目",duplicate:"复制项目",duplicating:"正在复制…",duplicateTitle:"复制项目",duplicateDescription:"创建“{{project}}”的独立副本。会复制文件和项目设置,但不会复制成员、批注、Git 历史和编译产物。",download:"下载",transfer:"转让",transferOwnership:"转让项目",transferDescription:"为“{{project}}”选择新的所有者。",newOwner:"新所有者",chooseNewOwner:"请选择用户",noTransferUsers:"没有其他可用用户",transferWarning:"转让后你仍保留读写权限。源码、历史、批注和成员不会改变;已保存的 GitHub token 会被移除,由新所有者配置自己的凭据。",transferForbidden:"只有当前项目所有者可以转让项目。",transferTargetInvalid:"请选择新的项目所有者。",transferSelf:"你已经是该项目的所有者。",deleteTitle:"删除项目",deleteDescription:"确定永久删除“{{project}}”及其全部文件吗?此操作不可撤销。",chooseZip:"选择 ZIP 项目",dropZip:"将 ZIP 压缩包拖放到这里",browse:"浏览文件",selectedFileSize:"已选择 · {{size}}",clearFile:"清除已选文件"},lp={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:"永久删除项目及全部文件"},dp={saved:"已保存",savedAt:"已于 {{time}} 保存到服务器",loading:"载入中",pending:"等待保存",saving:"正在保存到服务器",saveFailed:"保存失败",offlineDraft:"离线 · 本地草稿已保留",compile:"编译 · {{engine}}",compiling:"编译中…",compileQueued:"编译已排队…",compileFailedRetained:"编译失败,当前显示上一次成功生成的 PDF({{time}})。",compileFailedNoPdf:"编译失败,且没有可用的成功 PDF。",upToDate:"文件已是最新,无需重新编译。",compileSnapshotStale:"PDF 基于较早的一致快照编译,未包含之后的源码修改。",addComment:"添加批注",sourceComments:"源码批注",projectSettings:"项目设置",uploadAttachment:"上传附件",newFile:"新建文本文件",binary:"二进制附件已保存,但不能在文本编辑器中打开。",noOutline:"当前文件没有章节",preview:"PDF 预览",previewHint:"点击“编译”生成文档",loadingPdf:"正在加载 PDF…",pdfCompiledAt:"成功编译于 {{time}}",pdfCompiledAtFor:"{{file}} 成功编译于 {{time}}",currentMainDocument:"当前作为主文档编译:{{path}}",mainDocumentCandidate:"LaTeX 主文档候选:{{path}}",currentMainShort:"主文档",deletedUser:"已删除用户",orphaned:"锚点已丢失",line:"第 {{line}} 行",reopen:"重新打开",resolve:"标记为已解决",noComments:"当前文件没有批注",newFileDescription:"可以包含目录,例如 chapters/introduction.tex。",filePath:"文件路径",commentDescription:"已选择 {{count}} 个字符",pointComment:"未选择文本,将在当前光标位置添加批注。",commentContent:"批注内容",backToProjects:"返回项目列表",outputTabs:"编译输出",log:"日志",warnings:"警告",errors:"错误",artifacts:"产物",clean:"故障恢复",noLog:"编译后将在此显示日志。",noWarnings:"最近一次编译没有警告。",noErrors:"最近一次编译没有错误。",projectRoot:"项目根目录",uploadTo:"上传到 {{folder}}",dropFiles:"拖放文件以上传",newFolder:"新建文件夹",folderName:"文件夹名称",folderDestination:"文件夹将创建在 {{folder}} 中。",uploadOverwriteTitle:"文件已存在",uploadOverwriteDescription:"以下文件已经存在:{{files}}。要覆盖它们吗?",uploadOverwrite:"覆盖文件",noArtifacts:"编译后将在此显示输出产物。",selectArtifact:"选择一个文本产物进行预览。",viewArtifact:"查看产物",downloadArtifact:"下载产物",downloadToView:"该产物需要下载后查看",cleanTitle:"编译故障恢复",cleanDescription:"这里只提供高级故障恢复操作:仅在编译卡住、历史错误状态残留或生成产物异常时使用。不会修改源码、项目设置、批注、历史或 Git 数据。",cleanCache:"强制完整重编译",cleanCacheDescription:"仅在编译失败或 latexmk 缓存状态异常时使用。删除增量缓存,但保留当前成功的 PDF。",cleanArtifacts:"删除生成输出",cleanArtifactsDescription:"仅在生成产物状态异常时使用。删除该主文档的 PDF、SyncTeX、日志和中间文件。",cleanCacheConfirmTitle:"强制完整重编译?",cleanCacheConfirmDescription:"此故障恢复操作会删除 latexmk 增量缓存。当前 PDF 会保留,下一次编译将从干净缓存开始。",cleanArtifactsConfirmTitle:"删除生成输出?",cleanArtifactsConfirmDescription:"此故障恢复操作会删除当前 PDF 以及该主文档的全部生成文件,但不会影响源码。",cleanConfirm:"执行恢复",cleanCacheComplete:"故障恢复缓存已清理,下一次编译将完整执行。",cleanArtifactsComplete:"编译生成输出已删除。",cleanBusy:"当前主文档正在编译,请完成后再执行故障恢复。",collapseFiles:"折叠文件面板",move:"移动",moveTitle:"移动 {{name}}",moveDescription:"选择目标文件夹;源码、批注和项目路径会保持关联。",destinationFolder:"目标文件夹",deletePath:"删除文件或文件夹",deletePathTitle:"删除 {{name}}",deletePathDescription:"确定删除 {{path}}?此操作不可撤销。",deletePathActiveDescription:"确定删除 {{path}}?{{users}} 当前正在打开它,删除后这些会话将关闭该文件。",deletePathWillClose:"系统会拒绝该路径上迟到的修改,避免内容被静默丢失。",fileDeletedByCollaborator:"{{path}} 已在其他会话中删除,现已打开安全的备用文件。",compileShortcut:"保存并编译(Ctrl+S / Cmd+S)",compilingBy:"{{name}} 正在编译",formatSelection:"格式化选区",formatting:"正在格式化…",formatSelectionHint:"选择一段 LaTeX 源码后格式化",formatSelectionRequired:"请先选择 LaTeX 源码,再进行格式化。",formatSelectionComplete:"所选 LaTeX 源码已格式化。",formatFailedContinue:"格式化失败,仍将继续编译:{{message}}",formatFailed:"无法格式化选区:{{message}}",formatSourceChanged:"格式化期间源码已发生变化,已跳过本次格式化。",formatSelectionChanged:"格式化期间所选源码已发生变化,请重新选择后再试。",writingSuggestions:"写作建议",noWritingSuggestions:"没有可用的修改建议",removeText:"删除文本",replaceWith:"替换为 {{word}}",spellCheckReadOnly:"当前为只读,需要编辑权限才能替换。",spellCheckSourceChanged:"源码在应用写作修正前发生了变化。",vimOn:"Vim 已开启",vimOnHint:"当前编辑器已启用 Vim 键位。",reply:"回复",replyPlaceholder:"输入回复内容…",sendReply:"发送回复",editComment:"编辑批注",deleteComment:"删除批注",saveChanges:"保存修改",deleteCommentTitle:"删除批注",deleteCommentDescription:"确定删除这条批注及其 {{count}} 条回复吗?此操作不可撤销。",editReply:"编辑回复",deleteReply:"删除回复",deleteReplyTitle:"删除回复",deleteReplyDescription:"确定删除这条回复吗?此操作不可撤销。",editedAt:"编辑于 {{time}}",outlineJump:"跳转到源码第 {{line}} 行并定位 PDF",lineNumber:"第 {{line}} 行",showInSource:"在源码中显示当前 PDF 位置",showInPdf:"在 PDF 中显示当前源码光标位置",syncTexOnlyForTex:"PDF 跳转仅支持 TeX 源文件(.tex)",syncTexOnlyForMain:"PDF 跳转仅支持当前主 TeX 文档",openFiles:"打开的文件",pdfLoadFailed:"无法载入 PDF 预览",pdfZoomControls:"PDF 缩放控件",downloadPdf:"下载 PDF",downloadResource:"下载文件",resourceTooLarge:"该文件大小为 {{size}},超过 {{limit}} 的直接预览上限。",resourceTooLargeTitle:"文件过大,无法直接预览",resourceTooLargeDescription:"请下载文件后在本地打开。",resourceUnsupportedTitle:"无法预览",resourceUnsupportedDescription:"浏览器不能直接渲染此文件类型,请下载后在本地打开。",resourcePreview:{image:"图片预览",pdf:"PDF 预览",text:"文本预览",unsupported:"文件预览"},pdfZoomOut:"缩小",pdfZoomIn:"放大",pdfFitWidth:"适合宽度",pdfLink:"PDF 链接",pdfLinks:"PDF 链接",layout:{label:"布局",choose:"选择布局",current:"当前布局:{{layout}}","editor-pdf":{name:"编辑器与 PDF",description:"并排显示源码编辑器和 PDF 预览"},"editor-only":{name:"仅编辑器",description:"将工作区用于源码编辑"},"pdf-only":{name:"仅 PDF",description:"将工作区用于 PDF 和编译输出"}},collaboration:{connecting:"正在连接协作服务…",connected:"实时协作已连接",disconnected:"实时协作连接已断开",editing:"正在编辑",viewing:"正在查看",joining:"正在进入项目",reconnect:"重新连接",activeSessions:"{{count}} 个活跃会话",showMoreSessions:"展开另外 {{count}} 个会话",showFewerSessions:"收起会话列表",sessionTooltip:"{{name}}(@{{username}})· {{file}} · {{activity}} · {{permission}}"},search:{button:"查找",title:"查找和替换(Ctrl+F / Cmd+F)",find:"查找",replace:"替换为",next:"下一个",previous:"上一个",all:"选择全部",matchCase:"区分大小写",regexp:"正则表达式",wholeWord:"全字匹配",replaceNext:"替换",replaceAll:"全部替换",currentMatch:"当前匹配",onLine:"位于行",replacedMatchOnLine:"已替换第 $ 行的匹配项",replacedMatches:"已替换 $ 个匹配项",goToLine:"跳转到行",go:"跳转",matchCount:"共 {{count}} 个匹配",noMatches:"没有匹配项",invalidQuery:"正则表达式无效"}},up={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}} 项。"},hp={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:"安全检查点"}},fp={mainFile:"主文档",engine:"编译引擎",latexmkrc:"项目 latexmkrc",save:"保存项目设置",members:"共享成员",recentLog:"最近编译日志",share:"共享项目",shareDescription:"仅可共享给管理员已创建的用户。",chooseUser:"请选择用户",latexmkrcPlaceholder:`# 留空表示不使用项目 rc 文件
|
|
4
|
+
$pdf_mode = 1;`,addMember:"添加成员",noMembers:"该项目尚未分享给其他成员。",removeTitle:"移除共享成员",removeDescription:"确认移除 {{username}}?其账号和其他项目不会受到影响。",editorTab:"编辑器外观",compilerTab:"LaTeX 编译器",compilerDescription:"选择本项目所有成员共享的主文档和 LaTeX 编译选项。",editorAppearance:"编辑器外观",editorAppearanceDescription:"这些偏好仅作用于当前浏览器中的当前用户和项目;项目词典是共享的。",saveAppearance:"保存外观设置",saveCompiler:"保存编译器设置",writingCheckDescription:"Harper 在浏览器本地 worker 中运行。拼写问题使用红色波浪线,语法问题使用黄色波浪线;右键问题可以查看修改建议。",projectConfiguration:"项目配置",fontFamily:"英文字体",fontSize:"字体大小",lineHeight:"行间距",dictionary:"项目词典",dictionaryDescription:"添加到这里的词会导入 Harper 的自定义词典,并在本项目的拼写检查中忽略;具有编辑权限的用户可以维护此列表。",dictionaryPlaceholder:"添加自定义词",addWord:"添加词",dictionaryEmpty:"暂未添加自定义词。",lineWrapping:"自动换行",spellCheck:"拼写和语法检查",vimMode:"Vim 键位",vimModeDescription:"在当前编辑器中使用 Vim 的普通、插入和可视模式。",vimHelp:"查看帮助",formatOnCompile:"编译前自动格式化 LaTeX",formatOnCompileDescription:"默认关闭;格式化会在服务器编译前执行。",formatRequiresWrite:"需要项目编辑权限才能使用格式化。",formatterDescription:"格式化使用宿主机上的可选 tex-fmt 命令。",formatterInstall:"安装或查看 tex-fmt 文档",openFilesInTabs:"使用新 Tab 打开 LaTeX 文件",openFilesInTabsDescription:"在编辑器顶部通过标签页管理打开的 .tex、.bib、.sty 等源码文件。",writingIssues:"发现 {{count}} 个写作问题(去重后 {{uniqueCount}} 个)",noWritingIssues:"未发现拼写或语法问题。",spellCheckFirst:"第一个写作问题",spellCheckPrevious:"上一个写作问题",spellCheckNext:"下一个写作问题",spellCheckLast:"最后一个写作问题",spellCheckPosition:"第 {{current}}/{{total}} 个",fontJetBrains:"JetBrains Mono",fontSourceCode:"Source Code Pro",fontIbmPlex:"IBM Plex Mono",fontFiraCode:"Fira Code",fontIosevka:"Iosevka",lineHeightCompact:"紧凑",lineHeightNormal:"标准",lineHeightRelaxed:"宽松"},pp={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:"确认撤销"},mp={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:"生成补全索引"}}},gp={title:"标签",add:"添加标签",create:"新建标签",createDescription:"创建仅自己可见的可复用彩色标签,用于整理项目。",assign:"标签",assignTitle:"“{{project}}”的标签",assignDescription:"勾选你为此项目设置的私有标签;其他用户拥有各自的标签。",empty:"请先创建标签。",allAssigned:"所有可用标签均已添加。",name:"标签名称",color:"颜色",filter:"筛选",red:"红色",orange:"橙色",yellow:"黄色",green:"绿色",blue:"蓝色",purple:"紫色",gray:"灰色"},yp={generic:"操作失败",request:"请求失败({{status}})",upload:"上传失败",boundaryTitle:"页面遇到问题",boundaryDescription:"渲染组件时发生异常。你可以尝试恢复,或刷新页面重新载入。",boundaryRetry:"重试",boundaryReload:"刷新页面",fileExists:"同名文件或文件夹已经存在。",pathConflict:"目标路径已经被文件或文件夹占用。",duplicateUploadNames:"所选文件中存在重复名称:{{files}}。",fileTooLarge:"文件超过 {{size}} MB 限制。",zipOnly:"请选择 ZIP 压缩包。",collaborationUnavailable:"实时协作尚未连接,请在重新连接后保存或编译。",codes:{AUTH_INVALID:"用户名或密码错误。",CURRENT_PASSWORD_INVALID:"当前密码错误。",USER_NOT_FOUND:"用户不存在或已被删除。",LAST_ADMIN:"系统必须保留至少一名可用管理员。",SELF_DELETE_FORBIDDEN:"不能删除当前登录的管理员。",PROJECT_CREATE_FORBIDDEN:"管理员尚未授予你创建项目的权限。",PROJECT_NOT_FOUND:"项目不存在或你已无法访问。",PROJECT_OWNER_ONLY:"只有项目所有者可以修改此设置。",PROJECT_EDIT_FORBIDDEN:"你没有此项目的编辑权限。",DICTIONARY_EDIT_FORBIDDEN:"你没有维护本项目词典的权限。",TAG_NOT_FOUND:"所选标签不存在。",GIT_TOKEN_INVALID:"请输入 GitHub token。",GIT_REPOSITORY_NAME_INVALID:"请输入 GitHub 仓库名称。",GIT_REVISION_INVALID:"请选择要 checkout 的 Git 版本。",PROJECT_DELETE_FORBIDDEN:"只有项目所有者可以删除项目。",MEMBERS_MANAGE_FORBIDDEN:"只有项目所有者可以管理项目成员。",OWNER_MEMBER_FORBIDDEN:"项目所有者不能作为成员添加。",INVALID_PATH:"文件路径无效。",RESERVED_PATH:"此路径由 TexLite 保留。",PATH_EXISTS:"目标路径已被文件或文件夹占用。",FILE_EXISTS:"同名文件已经存在。",PATH_NOT_FOUND:"文件或文件夹不存在。",FILE_NOT_FOUND:"文件不存在。",DIRECTORY_NOT_FOUND:"目标文件夹不存在。",MOVE_INTO_SELF:"不能把文件夹移动到自身内部。",MAIN_FILE_DELETE_FORBIDDEN:"不能删除主文档。",FILE_TOO_LARGE:"文件过大,无法打开或上传。",UPLOAD_EMPTY:"没有选择要上传的文件。",COMMENT_FILE_NOT_FOUND:"批注对应的文件不存在。",COMMENT_RANGE_INVALID:"批注的源码区间无效。",COMMENT_NOT_FOUND:"批注不存在。",COMMENT_EDIT_FORBIDDEN:"只能编辑自己的批注。",COMMENT_DELETE_FORBIDDEN:"只能删除自己的批注。",REPLY_NOT_FOUND:"回复不存在。",REPLY_EDIT_FORBIDDEN:"只能编辑自己的回复。",REPLY_DELETE_FORBIDDEN:"只能删除自己的回复。",COMMENT_UPDATE_EMPTY:"没有可更新的批注内容。",MAIN_FILE_NOT_FOUND:"所选主文档不存在。",LATEXMKRC_DISABLED:"管理员已禁用项目级 latexmkrc。",LATEXMKRC_NOT_FOUND:"所选 latexmkrc 文件不存在。",COMPILE_ARTIFACTS_NOT_FOUND:"尚无可用的编译产物。",COMPILE_ARTIFACT_NOT_FOUND:"编译产物不存在。",ARTIFACT_PREVIEW_UNSUPPORTED:"该产物不能作为文本预览,请下载后查看。",SYNC_SOURCE_INVALID:"源码位置无效。",SOURCE_FILE_NOT_FOUND:"源码文件不存在。",SYNCTEX_NOT_AVAILABLE:"尚无可用的 SyncTeX 数据,请重新编译。",SYNC_PDF_INVALID:"PDF 位置无效。",SYNCTEX_EXTERNAL_PATH:"SyncTeX 返回了项目外部的源码路径。",COMPILE_FORBIDDEN:"你没有编译此项目的权限。",PDF_NOT_FOUND:"尚未生成 PDF。",API_NOT_FOUND:"接口不存在。",SERVER_ERROR:"服务器无法完成请求。",REQUEST_INVALID:"请求格式无效。"}},wp={historyVersionNotFound:"所选历史版本已不存在。",historyFileNotFound:"所选历史版本中没有这个文件。",historyPreviewUnsupported:"这个历史文件不能作为文本比较。",searchInvalid:"请输入有效的搜索内容。",gitUnavailable:"Git 集成功能不可用。请在宿主机安装 Git,或修正配置中的 git.binary 后重试。",formatterUnavailable:"宿主机未安装 tex-fmt。请访问 https://github.com/wgunderwood/tex-fmt 安装后重启 TexLite。",formatFailed:"tex-fmt 无法格式化这段源码。",mainDocumentInvalid:"所选文件不是有效的 LaTeX 主文档。",compileSnapshotBusy:"源码尚未完成稳定保存,请稍后再试编译。"},xp={copyright:"© {{year}}",credit:"Designed and developed by CHEN Zhongpu"},bp={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 命令"},vp={common:op,auth:ap,projects:cp,users:lp,editor:dp,navigation:up,history:hp,projectSettings:fp,git:pp,metrics:mp,tags:gp,errors:yp,apiErrors:wp,footer:xp,completions:bp};pe.use(Al).use(Qh).init({resources:{en:{translation:ip},zh:{translation:vp}},fallbackLng:"en",supportedLngs:["en","zh"],nonExplicitSupportedLngs:!0,interpolation:{escapeValue:!1},detection:{order:["localStorage","navigator"],caches:["localStorage"]}});class qo extends Error{constructor(e,n,s=null){super(e),this.status=n,this.code=s}status;code}async function F(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 qo(Wo(r,n.status),n.status,Fl(r));return r}function Wo(t,e,n="errors.request"){const s=typeof t=="object"&&t!==null&&"error"in t&&typeof t.error=="string"?t.error:"",r=Fl(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_SNAPSHOT_BUSY:"apiErrors.compileSnapshotBusy",COMPILE_CLEAN_BUSY:"editor.cleanBusy"}[r]??`errors.codes.${r}`;if(pe.exists(i))return pe.t(i,{status:e,...typeof t=="object"&&t!==null?t:{}})}return pe.resolvedLanguage?.startsWith("zh")&&s?s:pe.t(n,{status:e})}function Fl(t){return typeof t!="object"||t===null||!("code"in t)||typeof t.code!="string"?null:t.code}var Sp=Object.defineProperty,Ss=(t,e)=>Sp(t,"name",{value:e,configurable:!0}),Il=!!(typeof window<"u"&&window.document&&window.document.createElement);function pn(t,e,{checkForDefaultPrevented:n=!0}={}){return Ss(function(r){if(t?.(r),n===!1||!r||!r.defaultPrevented)return e?.(r)},"handleEvent")}Ss(pn,"composeEventHandlers");function Cp(t){if(!Il)throw new Error("Cannot access window outside of the DOM");return t?.ownerDocument?.defaultView??window}Ss(Cp,"getOwnerWindow");function go(t){if(!Il)throw new Error("Cannot access document outside of the DOM");return t?.ownerDocument??document}Ss(go,"getOwnerDocument");function Ml(t,e=!1){const{activeElement:n}=go(t);if(!n?.nodeName)return null;if($l(n)&&n.contentDocument)return Ml(n.contentDocument.body,e);if(e){const s=n.getAttribute("aria-activedescendant");if(s){const r=go(n).getElementById(s);if(r)return r}}return n}Ss(Ml,"getActiveElement");function $l(t){return t.tagName==="IFRAME"}Ss($l,"isFrame");var jp=Object.defineProperty,Ko=(t,e)=>jp(t,"name",{value:e,configurable:!0});function yo(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}Ko(yo,"setRef");function Ul(...t){return e=>{let n=!1;const s=t.map(r=>{const i=yo(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():yo(t[r],null)}}}}Ko(Ul,"composeRefs");function Cs(...t){return h.useCallback(Ul(...t),t)}Ko(Cs,"useComposedRefs");var kp=Object.defineProperty,bt=(t,e)=>kp(t,"name",{value:e,configurable:!0});function Ep(t,e){const n=h.createContext(e);n.displayName=t+"Context";const s=bt(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 bt(r,"useContext"),[s,r]}bt(Ep,"createContext");function zl(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=bt(u=>{const{scope:p,children:m,...g}=u,w=p?.[t]?.[l]||c,b=h.useMemo(()=>g,Object.values(g));return o.jsx(w.Provider,{value:b,children:m})},"Provider");d.displayName=i+"Provider";function f(u,p,m={}){const{optional:g=!1}=m,w=p?.[t]?.[l]||c,b=h.useContext(w);if(b)return b;if(a!==void 0)return a;if(!g)throw new Error(`\`${u}\` must be used within \`${i}\``)}return bt(f,"useContext"),[d,f]}bt(s,"createContext");const r=bt(()=>{const i=n.map(a=>h.createContext(a));return bt(function(c){const l=c?.[t]||i;return h.useMemo(()=>({[`__scope${t}`]:{...c,[t]:l}}),[c,l])},"useScope")},"createScope");return r.scopeName=t,[s,Bl(r,...e)]}bt(zl,"createContextScope");function Bl(...t){const e=t[0];if(t.length===1)return e;const n=bt(()=>{const s=t.map(r=>({useScope:r(),scopeName:r.scopeName}));return bt(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}bt(Bl,"composeContextScopes");var mn=globalThis?.document?h.useLayoutEffect:()=>{},Dp=Object.defineProperty,Tp=(t,e)=>Dp(t,"name",{value:e,configurable:!0}),Np=rr[" useId ".trim().toString()]||(()=>{}),Op=0;function $r(t){const[e,n]=h.useState(Np());return mn(()=>{t||n(s=>s??String(Op++))},[t]),t||(e?`radix-${e}`:"")}Tp($r,"useId");var Pp=Object.defineProperty,_p=(t,e)=>Pp(t,"name",{value:e,configurable:!0}),Dc=rr[" useEffectEvent ".trim().toString()],Tc=rr[" useInsertionEffect ".trim().toString()];function Vl(t){if(typeof Dc=="function")return Dc(t);const e=h.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof Tc=="function"?Tc(()=>{e.current=t}):mn(()=>{e.current=t}),h.useMemo(()=>((...n)=>e.current?.(...n)),[])}_p(Vl,"useEffectEvent");var Rp=Object.defineProperty,ir=(t,e)=>Rp(t,"name",{value:e,configurable:!0}),Lp=rr[" useInsertionEffect ".trim().toString()]||mn;function Hl({prop:t,defaultProp:e,onChange:n=ir(()=>{},"onChange"),caller:s}){const[r,i,a]=ql({defaultProp:e,onChange:n}),c=t!==void 0,l=c?t:r,d=h.useCallback(f=>{if(c){const u=Wl(f)?f(t):f;u!==t&&a.current?.(u)}else i(f)},[c,t,i,a]);return[l,d]}ir(Hl,"useControllableState");function ql({defaultProp:t,onChange:e}){const[n,s]=h.useState(t),r=h.useRef(n),i=h.useRef(e);return Lp(()=>{i.current=e},[e]),h.useEffect(()=>{r.current!==n&&(i.current?.(n),r.current=n)},[n,r]),[n,s,i]}ir(ql,"useUncontrolledState");function Wl(t){return typeof t=="function"}ir(Wl,"isFunction");var Nc=Symbol("RADIX:SYNC_STATE");function Ap(t,e,n,s){const{prop:r,defaultProp:i,onChange:a,caller:c}=e,l=r!==void 0,d=Vl(a),f=[{...n,state:i}];s&&f.push(s);const[u,p]=h.useReducer((b,v)=>{if(v.type===Nc)return{...b,state:v.state};const k=t(b,v);return l&&!Object.is(k.state,b.state)&&d(k.state),k},...f),m=u.state,g=h.useRef(m);h.useEffect(()=>{g.current!==m&&(g.current=m,l||d(m))},[m,g,l]);const w=h.useMemo(()=>r!==void 0?{...u,state:r}:u,[u,r]);return h.useEffect(()=>{l&&!Object.is(r,u.state)&&p({type:Nc,state:r})},[r,u.state,l]),[w,p]}ir(Ap,"useControllableStateReducer");var Fp=Object.defineProperty,Pt=(t,e)=>Fp(t,"name",{value:e,configurable:!0});function Go(t){const e=h.forwardRef((n,s)=>{let{children:r,...i}=n,a=null,c=!1;const l=[];wo(r)&&typeof Pr=="function"&&(r=Pr(r._payload)),h.Children.forEach(r,p=>{if(Yl(p)){c=!0;const m=p;let g="child"in m.props?m.props.child:m.props.children;wo(g)&&typeof Pr=="function"&&(g=Pr(g._payload)),a=Mp(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?Jl(a):void 0,f=Cs(s,d);if(!a){if(r||r===0)throw new Error(c?zp(t):Up(t));return r}const u=Gl(i,a.props??{});return a.type!==h.Fragment&&(u.ref=s?f:d),h.cloneElement(a,u)});return e.displayName=`${t}.Slot`,e}Pt(Go,"createSlot");var Kl=Symbol.for("radix.slottable");function Ip(t){const e=Pt(n=>"child"in n?n.children(n.child):n.children,"Slottable");return e.displayName=`${t}.Slottable`,e.__radixId=Kl,e}Pt(Ip,"createSlottable");var Mp=Pt((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 Gl(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}}Pt(Gl,"mergeProps");function Jl(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)}Pt(Jl,"getElementRef");function Yl(t){return h.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Kl}Pt(Yl,"isSlottable");var $p=Symbol.for("react.lazy");function wo(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===$p&&"_payload"in t&&Xl(t._payload)}Pt(wo,"isLazyComponent");function Xl(t){return typeof t=="object"&&t!==null&&"then"in t}Pt(Xl,"isPromiseLike");var Up=Pt(t=>`${t} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),zp=Pt(t=>`${t} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),Pr=rr[" use ".trim().toString()],Bp=Object.defineProperty,Vp=(t,e)=>Bp(t,"name",{value:e,configurable:!0}),Hp=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],_n=Hp.reduce((t,e)=>{const n=Go(`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 Zl(t,e){t&&Tl.flushSync(()=>t.dispatchEvent(e))}Vp(Zl,"dispatchDiscreteCustomEvent");var qp=Object.defineProperty,Wp=(t,e)=>qp(t,"name",{value:e,configurable:!0});function ds(t){const e=h.useRef(t);return h.useEffect(()=>{e.current=t}),h.useMemo(()=>((...n)=>e.current?.(...n)),[])}Wp(ds,"useCallbackRef");var Kp=Object.defineProperty,Ve=(t,e)=>Kp(t,"name",{value:e,configurable:!0}),xo="dismissableLayer.update",Gp="dismissableLayer.pointerDownOutside",Jp="dismissableLayer.focusOutside",Oc,Ql=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Yp=h.forwardRef(Ve(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,[,w]=h.useState({}),b=Cs(n,m),v=Array.from(u.layers),[k]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),P=k?v.indexOf(k):-1,N=p?v.indexOf(p):-1,O=u.layersWithOutsidePointerEventsDisabled.size>0,W=N>=P,E=h.useRef(!1),G=td(R=>{a?.(R),l?.(R),R.defaultPrevented||d?.()},{ownerDocument:g,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:E,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:h.useCallback(R=>{if(!(R instanceof Node))return!1;const _=[...u.branches].some(L=>L.contains(R));return W&&!_},[u.branches,W])}),C=nd(R=>{if(r&&E.current)return;const _=R.target;[...u.branches].some(j=>j.contains(_))||(c?.(R),l?.(R),R.defaultPrevented||d?.())},g),V=p?N===v.length-1:!1,Z=ds(R=>{R.key==="Escape"&&(i?.(R),!R.defaultPrevented&&d&&(R.preventDefault(),d()))});return h.useEffect(()=>{if(V)return g.addEventListener("keydown",Z,{capture:!0}),()=>g.removeEventListener("keydown",Z,{capture:!0})},[g,V,Z]),h.useEffect(()=>{if(p)return s&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Oc=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),bo(),()=>{s&&(u.layersWithOutsidePointerEventsDisabled.delete(p),u.layersWithOutsidePointerEventsDisabled.size===0&&(g.body.style.pointerEvents=Oc))}},[p,g,s,u]),h.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),bo())},[p,u]),h.useEffect(()=>{const R=Ve(()=>w({}),"handleUpdate");return document.addEventListener(xo,R),()=>document.removeEventListener(xo,R)},[]),o.jsx(_n.div,{...f,ref:b,style:{pointerEvents:O?W?"auto":"none":void 0,...e.style},onFocusCapture:pn(e.onFocusCapture,C.onFocusCapture),onBlurCapture:pn(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:pn(e.onPointerDownCapture,G.onPointerDownCapture)})},"DismissableLayer"));function ed(){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}Ve(ed,"useDismissableLayerSurface");var Xp=Ve(()=>!0,"IS_TRUE");function td(t,e){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:s=!1,isDeferredPointerDownOutsideRef:r,dismissableSurfaces:i,shouldHandlePointerDownOutside:a=Xp}=e,c=ds(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()}Ve(p,"resetOutsideInteraction");function m(){return Array.from(f.current.values()).some(Boolean)}Ve(m,"isOutsideInteractionIntercepted");function g(P){if(!d.current)return;const N=P.target;N instanceof Node&&[...i].some(W=>W.contains(N))||f.current.set(P.type,!0),P.type==="click"&&window.setTimeout(()=>{d.current&&u.current()},0)}Ve(g,"handleInteractionCapture");function w(P){d.current&&f.current.set(P.type,!1)}Ve(w,"handleInteractionBubble");const b=Ve(P=>{if(P.target&&!l.current){let N=function(){n.removeEventListener("click",u.current);const W=m();p(),W||Jo(Gp,c,O,{discrete:!0})};if(Ve(N,"handleAndDispatchPointerDownOutsideEvent"),!a(P.target)){n.removeEventListener("click",u.current),p(),l.current=!1;return}const O={originalEvent:P};d.current=!0,r.current=s&&P.button===0,f.current.clear(),!s||P.button!==0?N():(n.removeEventListener("click",u.current),u.current=N,n.addEventListener("click",u.current,{once:!0}))}else n.removeEventListener("click",u.current),p();l.current=!1},"handlePointerDown"),v=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const P of v)n.addEventListener(P,g,!0),n.addEventListener(P,w);const k=window.setTimeout(()=>{n.addEventListener("pointerdown",b)},0);return()=>{window.clearTimeout(k),n.removeEventListener("pointerdown",b),n.removeEventListener("click",u.current);for(const P of v)n.removeEventListener(P,g,!0),n.removeEventListener(P,w)}},[n,c,s,r,i,a]),{onPointerDownCapture:Ve(()=>l.current=!0,"onPointerDownCapture")}}Ve(td,"usePointerDownOutside");function nd(t,e=globalThis?.document){const n=ds(t),s=h.useRef(!1);return h.useEffect(()=>{const r=Ve(i=>{i.target&&!s.current&&Jo(Jp,n,{originalEvent:i},{discrete:!1})},"handleFocus");return e.addEventListener("focusin",r),()=>e.removeEventListener("focusin",r)},[e,n]),{onFocusCapture:Ve(()=>s.current=!0,"onFocusCapture"),onBlurCapture:Ve(()=>s.current=!1,"onBlurCapture")}}Ve(nd,"useFocusOutside");function bo(){const t=new CustomEvent(xo);document.dispatchEvent(t)}Ve(bo,"dispatchUpdate");function Jo(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?Zl(r,i):r.dispatchEvent(i)}Ve(Jo,"handleAndDispatchCustomEvent");var Zp=Object.defineProperty,nt=(t,e)=>Zp(t,"name",{value:e,configurable:!0}),Wi="focusScope.autoFocusOnMount",Ki="focusScope.autoFocusOnUnmount",Pc={bubbles:!1,cancelable:!0},Qp=h.forwardRef(nt(function(e,n){const{loop:s=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...c}=e,[l,d]=h.useState(null),f=ds(i),u=ds(a),p=h.useRef(null),m=Cs(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:en(p.current,{select:!0})},v=function(N){if(g.paused||!l)return;const O=N.relatedTarget;O!==null&&(l.contains(O)||en(p.current,{select:!0}))},k=function(N){if(document.activeElement===document.body)for(const W of N)W.removedNodes.length>0&&en(l)};nt(b,"handleFocusIn"),nt(v,"handleFocusOut"),nt(k,"handleMutations"),document.addEventListener("focusin",b),document.addEventListener("focusout",v);const P=new MutationObserver(k);return l&&P.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",b),document.removeEventListener("focusout",v),P.disconnect()}}},[r,l,g.paused]),h.useEffect(()=>{if(l){_c.add(g);const b=document.activeElement;if(!l.contains(b)){const k=new CustomEvent(Wi,Pc);l.addEventListener(Wi,f),l.dispatchEvent(k),k.defaultPrevented||(sd(cd(Yo(l)),{select:!0}),document.activeElement===b&&en(l))}return()=>{l.removeEventListener(Wi,f),setTimeout(()=>{const k=new CustomEvent(Ki,Pc);l.addEventListener(Ki,u),l.dispatchEvent(k),k.defaultPrevented||en(b??document.body,{select:!0}),l.removeEventListener(Ki,u),_c.remove(g)},0)}}},[l,f,u,g]);const w=h.useCallback(b=>{if(!s&&!r||g.paused)return;const v=b.key==="Tab"&&!b.altKey&&!b.ctrlKey&&!b.metaKey,k=document.activeElement;if(v&&k){const P=b.currentTarget,[N,O]=rd(P);N&&O?!b.shiftKey&&k===O?(b.preventDefault(),s&&en(N,{select:!0})):b.shiftKey&&k===N&&(b.preventDefault(),s&&en(O,{select:!0})):k===P&&b.preventDefault()}},[s,r,g.paused]);return o.jsx(_n.div,{tabIndex:-1,...c,ref:m,onKeyDown:w})},"FocusScope"));function sd(t,{select:e=!1}={}){const n=document.activeElement;for(const s of t)if(en(s,{select:e}),document.activeElement!==n)return}nt(sd,"focusFirst");function rd(t){const e=Yo(t),n=vo(e,t),s=vo(e.reverse(),t);return[n,s]}nt(rd,"getTabbableEdges");function Yo(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:nt(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}nt(Yo,"getTabbableCandidates");function vo(t,e){const n=typeof e.checkVisibility=="function"&&e.checkVisibility({checkVisibilityCSS:!0});for(const s of t)if(!(n?!s.checkVisibility({checkVisibilityCSS:!0}):id(s,{upTo:e})))return s}nt(vo,"findVisible");function id(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}nt(id,"isHidden");function od(t){return t instanceof HTMLInputElement&&"select"in t}nt(od,"isSelectableInput");function en(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&od(t)&&e&&t.select()}}nt(en,"focus");var _c=ad();function ad(){let t=[];return{add(e){const n=t[0];e!==n&&n?.pause(),t=So(t,e),t.unshift(e)},remove(e){t=So(t,e),t[0]?.resume()}}}nt(ad,"createFocusScopesStack");function So(t,e){const n=[...t],s=n.indexOf(e);return s!==-1&&n.splice(s,1),n}nt(So,"arrayRemove");function cd(t){return t.filter(e=>e.tagName!=="A")}nt(cd,"removeLinks");var em=Object.defineProperty,tm=(t,e)=>em(t,"name",{value:e,configurable:!0}),nm=h.forwardRef(tm(function(e,n){const{container:s,...r}=e,[i,a]=h.useState(!1);mn(()=>a(!0),[]);const c=s||i&&globalThis?.document?.body;return c?Tl.createPortal(o.jsx(_n.div,{...r,ref:n}),c):null},"Portal")),sm=Object.defineProperty,sn=(t,e)=>sm(t,"name",{value:e,configurable:!0});function ld(t,e){return h.useReducer((n,s)=>e[n][s]??n,t)}sn(ld,"useStateMachine");var Xo=sn(t=>{const{present:e,children:n}=t,s=dd(e),r=typeof n=="function"?n({present:s.isPresent}):h.Children.only(n),i=ud(s.ref,hd(r));return typeof n=="function"||s.isPresent?h.cloneElement(r,{ref:i}):null},"Presence");function dd(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]=ld(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??Yn(s.current),a.current=void 0):i.current="none"},[l]),mn(()=>{const f=s.current,u=r.current;if(u!==t){const m=i.current,g=Yn(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]),mn(()=>{if(e){let f;const u=e.ownerDocument.defaultView??window,p=sn(g=>{const b=Yn(s.current).includes(CSS.escape(g.animationName));if(g.target===e&&b&&(d("ANIMATION_END"),!r.current)){const v=e.style.animationFillMode;e.style.animationFillMode="forwards",f=u.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=v)})}},"handleAnimationEnd"),m=sn(g=>{g.target===e&&(i.current=Yn(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=Yn(u)}else s.current=null;n(f)},[])}}sn(dd,"usePresence");function Co(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}sn(Co,"setRef");function ud(...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=Co(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():Co(s[a],null)}}},[])}sn(ud,"useStableComposedRefs");function Yn(t){return t?.animationName||"none"}sn(Yn,"getAnimationName");function hd(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)}sn(hd,"getElementRef");var rm=Object.defineProperty,Zo=(t,e)=>rm(t,"name",{value:e,configurable:!0}),_r=0,Wn=null;function im(t){return Qo(),t.children}Zo(im,"FocusGuards");function Qo(){h.useEffect(()=>{Wn||(Wn={start:jo(),end:jo()});const{start:t,end:e}=Wn;return document.body.firstElementChild!==t&&document.body.insertAdjacentElement("afterbegin",t),document.body.lastElementChild!==e&&document.body.insertAdjacentElement("beforeend",e),_r++,()=>{_r===1&&(Wn?.start.remove(),Wn?.end.remove(),Wn=null),_r=Math.max(0,_r-1)}},[])}Zo(Qo,"useFocusGuards");function jo(){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}Zo(jo,"createFocusGuard");var om=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Kn=new WeakMap,Rr=new WeakMap,Lr={},Gi=0,fd=function(t){return t&&(t.host||fd(t.parentNode))},am=function(t,e){return e.map(function(n){if(t.contains(n))return n;var s=fd(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})},cm=function(t,e,n,s){var r=am(e,Array.isArray(t)?t:[t]);Lr[n]||(Lr[n]=new WeakMap);var i=Lr[n],a=[],c=new Set,l=new Set(r),d=function(u){!u||c.has(u)||(c.add(u),d(u.parentNode))};r.forEach(d);var f=function(u){!u||l.has(u)||Array.prototype.forEach.call(u.children,function(p){if(c.has(p))f(p);else try{var m=p.getAttribute(s),g=m!==null&&m!=="false",w=(Kn.get(p)||0)+1,b=(i.get(p)||0)+1;Kn.set(p,w),i.set(p,b),a.push(p),w===1&&g&&Rr.set(p,!0),b===1&&p.setAttribute(n,"true"),g||p.setAttribute(s,"true")}catch(v){console.error("aria-hidden: cannot operate on ",p,v)}})};return f(e),c.clear(),Gi++,function(){a.forEach(function(u){var p=Kn.get(u)-1,m=i.get(u)-1;Kn.set(u,p),i.set(u,m),p||(Rr.has(u)||u.removeAttribute(s),Rr.delete(u)),m||u.removeAttribute(n)}),Gi--,Gi||(Kn=new WeakMap,Kn=new WeakMap,Rr=new WeakMap,Lr={})}},lm=function(t,e,n){n===void 0&&(n="data-aria-hidden");var s=Array.from(Array.isArray(t)?t:[t]),r=om(t);return r?(s.push.apply(s,Array.from(r.querySelectorAll("[aria-live], script"))),cm(s,r,n,"aria-hidden")):function(){return null}},dm=Object.defineProperty,Ct=(t,e)=>dm(t,"name",{value:e,configurable:!0}),ea="Dialog",[pd,hv]=zl(ea),[um,Bt]=pd(ea),hm=Ct(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]=Hl({prop:s,defaultProp:r??!1,onChange:i,caller:ea}),[u,p]=h.useState(0),[m,g]=h.useState(0);return o.jsx(um,{scope:e,triggerRef:c,contentRef:l,contentId:$r(),titleId:$r(),descriptionId:$r(),titlePresent:u>0,descriptionPresent:m>0,setTitleCount:p,setDescriptionCount:g,open:d,onOpenChange:f,onOpenToggle:h.useCallback(()=>f(w=>!w),[f]),modal:a,children:n})},"Dialog"),md="DialogPortal",[fm,gd]=pd(md,{forceMount:void 0}),pm=Ct(t=>{const{__scopeDialog:e,forceMount:n,children:s,container:r}=t,i=Bt(md,e);return o.jsx(fm,{scope:e,forceMount:n,children:h.Children.map(s,a=>o.jsx(Xo,{present:n||i.open,children:o.jsx(nm,{asChild:!0,container:r,children:a})}))})},"DialogPortal"),ko="DialogOverlay",mm=h.forwardRef(Ct(function(e,n){const s=gd(ko,e.__scopeDialog),{forceMount:r=s.forceMount,...i}=e,a=Bt(ko,e.__scopeDialog);return a.modal?o.jsx(Xo,{present:r||a.open,children:o.jsx(ym,{...i,ref:n})}):null},"DialogOverlay")),gm=Go("DialogOverlay.RemoveScroll"),ym=h.forwardRef(Ct(function(e,n){const{__scopeDialog:s,...r}=e,i=Bt(ko,s),a=ed(),c=Cs(n,a);return o.jsx(ef,{as:gm,allowPinchZoom:!0,shards:[i.contentRef],children:o.jsx(_n.div,{"data-state":ta(i.open),...r,ref:c,style:{pointerEvents:"auto",...r.style}})})},"DialogOverlayImpl")),qs="DialogContent",wm=h.forwardRef(Ct(function(e,n){const s=gd(qs,e.__scopeDialog),{forceMount:r=s.forceMount,...i}=e,a=Bt(qs,e.__scopeDialog);return o.jsx(Xo,{present:r||a.open,children:a.modal?o.jsx(xm,{...i,ref:n}):o.jsx(bm,{...i,ref:n})})},"DialogContent")),xm=h.forwardRef(Ct(function(e,n){const s=Bt(qs,e.__scopeDialog),r=h.useRef(null),i=Cs(n,s.contentRef,r);return h.useEffect(()=>{const a=r.current;if(a)return lm(a)},[]),o.jsx(yd,{...e,ref:i,trapFocus:s.open,disableOutsidePointerEvents:s.open,onCloseAutoFocus:pn(e.onCloseAutoFocus,a=>{a.preventDefault(),s.triggerRef.current?.focus()}),onPointerDownOutside:pn(e.onPointerDownOutside,a=>{const c=a.detail.originalEvent,l=c.button===0&&c.ctrlKey===!0;(c.button===2||l)&&a.preventDefault()}),onFocusOutside:pn(e.onFocusOutside,a=>a.preventDefault())})},"DialogContentModal")),bm=h.forwardRef(Ct(function(e,n){const s=Bt(qs,e.__scopeDialog),r=h.useRef(!1),i=h.useRef(!1);return o.jsx(yd,{...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")),yd=h.forwardRef(Ct(function(e,n){const{__scopeDialog:s,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...c}=e,l=Bt(qs,s);return Qo(),o.jsx(o.Fragment,{children:o.jsx(Qp,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:o.jsx(Yp,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionPresent?l.descriptionId:void 0,"aria-labelledby":l.titlePresent?l.titleId:void 0,"data-state":ta(l.open),...c,ref:n,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1)})})})},"DialogContentImpl")),vm="DialogTitle",Sm=h.forwardRef(Ct(function(e,n){const{__scopeDialog:s,...r}=e,i=Bt(vm,s),{setTitleCount:a}=i;return mn(()=>(a(c=>c+1),()=>a(c=>c-1)),[a]),o.jsx(_n.h2,{id:i.titleId,...r,ref:n})},"DialogTitle")),Cm="DialogDescription",jm=h.forwardRef(Ct(function(e,n){const{__scopeDialog:s,...r}=e,i=Bt(Cm,s),{setDescriptionCount:a}=i;return mn(()=>(a(c=>c+1),()=>a(c=>c-1)),[a]),o.jsx(_n.p,{id:i.descriptionId,...r,ref:n})},"DialogDescription")),km="DialogClose",Em=h.forwardRef(Ct(function(e,n){const{__scopeDialog:s,...r}=e,i=Bt(km,s);return o.jsx(_n.button,{type:"button",...r,ref:n,onClick:pn(e.onClick,()=>i.onOpenChange(!1))})},"DialogClose"));function ta(t){return t?"open":"closed"}Ct(ta,"getState");function He({open:t,title:e,description:n,onOpenChange:s,children:r,footer:i,wide:a,extraWide:c,className:l}){const{t:d}=Le();return o.jsx(hm,{open:t,onOpenChange:s,children:o.jsxs(pm,{children:[o.jsx(mm,{className:"dialog-overlay"}),o.jsxs(wm,{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(Sm,{children:e}),n&&o.jsx(jm,{children:n})]}),o.jsx(Em,{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 us({open:t,title:e,description:n,confirmLabel:s,danger:r,onCancel:i,onConfirm:a}){const{t:c}=Le();return o.jsx(He,{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 na({compact:t=!1}){const{i18n:e,t:n}=Le(),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 Dm=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),wd=(...t)=>t.filter((e,n,s)=>!!e&&e.trim()!==""&&s.indexOf(e)===n).join(" ").trim();var Tm={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 Nm=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,...Tm,width:e,height:e,stroke:t,strokeWidth:s?Number(n)*24/Number(e):n,className:wd("lucide",r),...c},[...a.map(([d,f])=>h.createElement(d,f)),...Array.isArray(i)?i:[i]]));const I=(t,e)=>{const n=h.forwardRef(({className:s,...r},i)=>h.createElement(Nm,{ref:i,iconNode:e,className:wd(`lucide-${Dm(t)}`,s),...r}));return n.displayName=`${t}`,n};const Om=I("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 xd=I("AlignLeft",[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);const Pm=I("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 Rc=I("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 _m=I("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 bd=I("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const Ji=I("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 Eo=I("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 Rm=I("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 Lm=I("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const vd=I("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const Sd=I("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);const sa=I("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Am=I("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);const Fm=I("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);const Im=I("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const ra=I("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 Lc=I("Columns2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]);const Mm=I("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 $m=I("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 Ws=I("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 Do=I("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 To=I("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 Um=I("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 zm=I("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 En=I("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 Gr=I("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 Cd=I("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 Bm=I("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 Vm=I("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 Yi=I("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 jd=I("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 Hm=I("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 qm=I("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 Dt=I("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const Wm=I("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 No=I("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 Ac=I("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 kd=I("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 Fc=I("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 Km=I("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 Gm=I("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);const Jm=I("PanelRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);const Ym=I("PanelsTopLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]]);const Oo=I("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 Xm=I("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const Zm=I("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 Qm=I("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 Jr=I("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 Po=I("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 eg=I("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);const tg=I("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 Ur=I("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 ng=I("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 sg=I("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 Ic=I("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 gn=I("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 hs=I("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 Mc=I("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 Yr=I("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 Ed=I("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 Ks=I("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 rg=I("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 Xr=I("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Zr=[{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'}],Zt={font:"jetbrains",fontSize:14,lineHeight:1.65,lineWrapping:!0,spellCheck:!0,vimMode:!1,formatOnCompile:!1,openFilesInTabs:!1},ig="texlite-editor-preferences";function Dd(t,e){return`${ig}:${encodeURIComponent(t)}:${encodeURIComponent(e)}`}function fv(t){return Zr.find(e=>e.id===t)?.stack??Zr[0].stack}function $c(t,e){try{const n=JSON.parse(localStorage.getItem(Dd(t,e))??"{}");return{font:Zr.some(s=>s.id===n.font)?n.font:Zt.font,fontSize:[12,13,14,15,16,18,20].includes(Number(n.fontSize))?Number(n.fontSize):Zt.fontSize,lineHeight:[1.45,1.65,1.85].includes(Number(n.lineHeight))?Number(n.lineHeight):Zt.lineHeight,lineWrapping:typeof n.lineWrapping=="boolean"?n.lineWrapping:Zt.lineWrapping,spellCheck:typeof n.spellCheck=="boolean"?n.spellCheck:Zt.spellCheck,vimMode:typeof n.vimMode=="boolean"?n.vimMode:Zt.vimMode,formatOnCompile:typeof n.formatOnCompile=="boolean"?n.formatOnCompile:Zt.formatOnCompile,openFilesInTabs:typeof n.openFilesInTabs=="boolean"?n.openFilesInTabs:Zt.openFilesInTabs}}catch{return Zt}}function og(t,e,n){localStorage.setItem(Dd(t,e),JSON.stringify(n))}const ag=/\.(?:tex|bib|cls|sty)$/i;function Xi(t){return ag.test(t)}function cg(t){return t.match(/(?:\r?\n)+$/)?.[0]??""}function lg(t,e){const n=cg(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 Uc(t,e,n=0){if(t===e)return[];const{default:s}=await on(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 dg(t,e=null){const n=zc(t),r=e==="succeeded"||e===null&&hg(t)?[]:Bc(n.filter(Vc)),i=zc(ug(t));return{warnings:Bc(i.filter(c=>!Vc(c)&&fg(c))),errors:r}}function zc(t){return t.split(`
|
|
7
|
+
`).map(e=>e.trim()).filter(Boolean)}function Bc(t){return[...new Set(t)]}function ug(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 hg(t){return/Latexmk: All targets .* are up-to-date/i.test(t)&&/Output written on .*\.pdf/i.test(t)}function Vc(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 fg(t){return/\bwarnings?\b|overfull|underfull|badness/i.test(t)}const pg=/^\/projects?\/([^/]+)\/?$/;function Zi(t){return`/project/${encodeURIComponent(t)}`}function Ar(t){const e=pg.exec(t);if(!e)return null;try{const n=decodeURIComponent(e[1]);return n&&!n.includes("/")?n:null}catch{return null}}function mg(t){if(!t||typeof t!="object")return!1;const e=t;return e.texliteRoute==="project"&&typeof e.projectId=="string"&&typeof e.fromDashboard=="boolean"}function q(t){return t instanceof Error?t.message:pe.t("errors.generic")}const ct=()=>new Map,_o=t=>{const e=ct();return t.forEach((n,s)=>{e.set(s,n)}),e},Vt=(t,e,n)=>{let s=t.get(e);return s===void 0&&t.set(e,s=n()),s},gg=(t,e)=>{const n=[];for(const[s,r]of t)n.push(e(r,s));return n},yg=(t,e)=>{for(const[n,s]of t)if(e(s,n))return!0;return!1},yn=()=>new Set,Qi=t=>t[t.length-1],wg=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},rn=Array.from,ia=(t,e)=>{for(let n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0},oa=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1},xg=(t,e)=>{const n=new Array(t);for(let s=0;s<t;s++)n[s]=e(s,n);return n},fs=Array.isArray;class aa{constructor(){this._observers=ct()}on(e,n){return Vt(this._observers,e,yn).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 rn((this._observers.get(e)||ct()).values()).forEach(s=>s(...n))}destroy(){this._observers=ct()}}class Td{constructor(){this._observers=ct()}on(e,n){Vt(this._observers,e,yn).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 rn((this._observers.get(e)||ct()).values()).forEach(s=>s(...n))}destroy(){this._observers=ct()}}const Nt=Math.floor,zr=Math.abs,ca=(t,e)=>t<e?t:e,Rn=(t,e)=>t>e?t:e,bg=Math.pow,Nd=t=>t!==0?t<0:1/t<0,Hc=1,qc=2,eo=4,to=8,Gs=32,tn=64,ft=128,pi=31,Ro=63,Tn=127,vg=2147483647,Qr=Number.MAX_SAFE_INTEGER,Wc=Number.MIN_SAFE_INTEGER,Sg=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&Nt(t)===t),Od=String.fromCharCode,Cg=t=>t.toLowerCase(),jg=/^\s*/g,kg=t=>t.replace(jg,""),Eg=/([A-Z])/g,Kc=(t,e)=>kg(t.replace(Eg,n=>`${e}${Cg(n)}`)),Dg=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},Js=typeof TextEncoder<"u"?new TextEncoder:null,Tg=t=>Js.encode(t),Ng=Js?Tg:Dg;let Vs=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Vs&&Vs.decode(new Uint8Array).length===1&&(Vs=null);const Og=(t,e)=>xg(e,()=>t).join("");class or{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Re=()=>new or,la=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},xe=t=>{const e=new Uint8Array(la(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},Pg=(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(Rn(n,e)*2),t.cpos=0)},Be=(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},Lo=Be,z=(t,e)=>{for(;e>Tn;)Be(t,ft|Tn&e),e=Nt(e/128);Be(t,Tn&e)},da=(t,e)=>{const n=Nd(e);for(n&&(e=-e),Be(t,(e>Ro?ft:0)|(n?tn:0)|Ro&e),e=Nt(e/64);e>0;)Be(t,(e>Tn?ft:0)|Tn&e),e=Nt(e/128)},Ao=new Uint8Array(3e4),_g=Ao.length/3,Rg=(t,e)=>{if(e.length<_g){const n=Js.encodeInto(e,Ao).written||0;z(t,n);for(let s=0;s<n;s++)Be(t,Ao[s])}else Te(t,Ng(e))},Lg=(t,e)=>{const n=unescape(encodeURIComponent(e)),s=n.length;z(t,s);for(let r=0;r<s;r++)Be(t,n.codePointAt(r))},nn=Js&&Js.encodeInto?Rg:Lg,mi=(t,e)=>{const n=t.cbuf.length,s=t.cpos,r=ca(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(Rn(n*2,i)),t.cbuf.set(e.subarray(r)),t.cpos=i)},Te=(t,e)=>{z(t,e.byteLength),mi(t,e)},ua=(t,e)=>{Pg(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},Ag=(t,e)=>ua(t,4).setFloat32(0,e,!1),Fg=(t,e)=>ua(t,8).setFloat64(0,e,!1),Ig=(t,e)=>ua(t,8).setBigInt64(0,e,!1),Gc=new DataView(new ArrayBuffer(4)),Mg=t=>(Gc.setFloat32(0,t),Gc.getFloat32(0)===t),Ys=(t,e)=>{switch(typeof e){case"string":Be(t,119),nn(t,e);break;case"number":Sg(e)&&zr(e)<=vg?(Be(t,125),da(t,e)):Mg(e)?(Be(t,124),Ag(t,e)):(Be(t,123),Fg(t,e));break;case"bigint":Be(t,122),Ig(t,e);break;case"object":if(e===null)Be(t,126);else if(fs(e)){Be(t,117),z(t,e.length);for(let n=0;n<e.length;n++)Ys(t,e[n])}else if(e instanceof Uint8Array)Be(t,116),Te(t,e);else{Be(t,118);const n=Object.keys(e);z(t,n.length);for(let s=0;s<n.length;s++){const r=n[s];nn(t,r),Ys(t,e[r])}}break;case"boolean":Be(t,e?120:121);break;default:Be(t,127)}};class Jc extends or{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&z(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const Yc=t=>{t.count>0&&(da(t.encoder,t.count===1?t.s:-t.s),t.count>1&&z(t.encoder,t.count-2))};class Br{constructor(){this.encoder=new or,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Yc(this),this.count=1,this.s=e)}toUint8Array(){return Yc(this),xe(this.encoder)}}const Xc=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);da(t.encoder,e),t.count>1&&z(t.encoder,t.count-2)}};class no{constructor(){this.encoder=new or,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Xc(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Xc(this),xe(this.encoder)}}class $g{constructor(){this.sarr=[],this.s="",this.lensE=new Br}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 or;return this.sarr.push(this.s),this.s="",nn(e,this.sarr.join("")),mi(e,this.lensE.toUint8Array()),xe(e)}}const Ot=t=>new Error(t),Tt=()=>{throw Ot("Method unimplemented")},pt=()=>{throw Ot("Unexpected case")},Pd=Ot("Unexpected end of array"),_d=Ot("Integer out of Range");class gi{constructor(e){this.arr=e,this.pos=0}}const bn=t=>new gi(t),Ug=t=>t.pos!==t.arr.length,zg=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},Xe=t=>zg(t,Y(t)),ps=t=>t.arr[t.pos++],Y=t=>{let e=0,n=1;const s=t.arr.length;for(;t.pos<s;){const r=t.arr[t.pos++];if(e=e+(r&Tn)*n,n*=128,r<ft)return e;if(e>Qr)throw _d}throw Pd},ha=t=>{let e=t.arr[t.pos++],n=e&Ro,s=64;const r=(e&tn)>0?-1:1;if((e&ft)===0)return r*n;const i=t.arr.length;for(;t.pos<i;){if(e=t.arr[t.pos++],n=n+(e&Tn)*s,s*=128,e<ft)return r*n;if(n>Qr)throw _d}throw Pd},Bg=t=>{let e=Y(t);if(e===0)return"";{let n=String.fromCodePoint(ps(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(ps(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))}},Vg=t=>Vs.decode(Xe(t)),Ze=Vs?Vg:Bg,fa=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},Hg=t=>fa(t,4).getFloat32(0,!1),qg=t=>fa(t,8).getFloat64(0,!1),Wg=t=>fa(t,8).getBigInt64(0,!1),Kg=[t=>{},t=>null,ha,Hg,qg,Wg,t=>!1,t=>!0,Ze,t=>{const e=Y(t),n={};for(let s=0;s<e;s++){const r=Ze(t);n[r]=Xs(t)}return n},t=>{const e=Y(t),n=[];for(let s=0;s<e;s++)n.push(Xs(t));return n},Xe],Xs=t=>Kg[127-ps(t)](t);class Zc extends gi{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Ug(this)?this.count=Y(this)+1:this.count=-1),this.count--,this.s}}class Vr extends gi{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=ha(this);const e=Nd(this.s);this.count=1,e&&(this.s=-this.s,this.count=Y(this)+2)}return this.count--,this.s}}class so extends gi{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=ha(this),n=e&1;this.diff=Nt(e/2),this.count=1,n&&(this.count=Y(this)+2)}return this.s+=this.diff,this.count--,this.s}}class Gg{constructor(e){this.decoder=new Vr(e),this.str=Ze(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),n=this.str.slice(this.spos,e);return this.spos=e,n}}const Jg=crypto.getRandomValues.bind(crypto),Rd=()=>Jg(new Uint32Array(1))[0],Yg="10000000-1000-4000-8000"+-1e11,Xg=()=>Yg.replace(/[018]/g,t=>(t^Rd()&15>>t/4).toString(16)),wn=Date.now,ms=t=>new Promise(t);Promise.all.bind(Promise);const Qc=t=>t===void 0?null:t;class Zg{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let Ld=new Zg,pa=!0;try{typeof localStorage<"u"&&localStorage&&(Ld=localStorage,pa=!1)}catch{}const Ad=Ld,Qg=t=>pa||addEventListener("storage",t),ey=t=>pa||removeEventListener("storage",t),Zs=Symbol("Equality"),Fd=(t,e)=>t===e||!!t?.[Zs]?.(e)||!1,ty=t=>typeof t=="object",ny=Object.assign,sy=Object.keys,ry=(t,e)=>{for(const n in t)e(t[n],n)},iy=(t,e)=>{const n=[];for(const s in t)n.push(e(t[s],s));return n},ei=t=>sy(t).length,oy=t=>{for(const e in t)return!1;return!0},ar=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},ma=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),ay=(t,e)=>t===e||ei(t)===ei(e)&&ar(t,(n,s)=>(n!==void 0||ma(e,s))&&Fd(e[s],n)),cy=Object.freeze,Id=t=>{for(const e in t){const n=t[e];(typeof n=="object"||typeof n=="function")&&Id(t[e])}return cy(t)},ga=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&ga(t,e,n+1)}},ly=t=>t,ns=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(t[Zs]!=null)return t[Zs](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;break}case Set:{if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;break}case Map:{if(t.size!==e.size)return!1;for(const n of t.keys())if(!e.has(n)||!ns(t.get(n),e.get(n)))return!1;break}case void 0:case Object:if(ei(t)!==ei(e))return!1;for(const n in t)if(!ma(t,n)||!ns(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(!ns(t[n],e[n]))return!1;break;default:return!1}return!0},dy=(t,e)=>e.includes(t);var Md={};const xn=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"&&!xn;let Mt;const uy=()=>{if(Mt===void 0)if(xn){Mt=ct();const t=process.argv;let e=null;for(let n=0;n<t.length;n++){const s=t[n];s[0]==="-"?(e!==null&&Mt.set(e,""),e=s):e!==null&&(Mt.set(e,s),e=null)}e!==null&&Mt.set(e,"")}else typeof location=="object"?(Mt=ct(),(location.search||"?").slice(1).split("&").forEach(t=>{if(t.length!==0){const[e,n]=t.split("=");Mt.set(`--${Kc(e,"-")}`,n),Mt.set(`-${Kc(e,"-")}`,n)}})):Mt=ct();return Mt},Fo=t=>uy().has(t),ti=t=>Qc(xn?Md[t.toUpperCase().replaceAll("-","_")]:Ad.getItem(t)),Ud=t=>Fo("--"+t)||ti(t)!==null,hy=Ud("production"),fy=xn&&dy(Md.FORCE_COLOR,["true","1","2"]),py=fy||!Fo("--no-colors")&&!Ud("no-color")&&(!xn||process.stdout.isTTY)&&(!xn||Fo("--color")||ti("COLORTERM")!==null||(ti("TERM")||"").includes("color")),zd=t=>new Uint8Array(t),my=(t,e,n)=>new Uint8Array(t,e,n),gy=t=>new Uint8Array(t),yy=t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=Od(t[n]);return btoa(e)},wy=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),xy=t=>{const e=atob(t),n=zd(e.length);for(let s=0;s<e.length;s++)n[s]=e.charCodeAt(s);return n},by=t=>{const e=Buffer.from(t,"base64");return my(e.buffer,e.byteOffset,e.byteLength)},vy=$d?yy:wy,Sy=$d?xy:by,Cy=t=>{const e=zd(t.byteLength);return e.set(t),e};class jy{constructor(e,n){this.left=e,this.right=n}}const Qt=(t,e)=>new jy(t,e),ky=(t,e)=>t.forEach(n=>e(n.left,n.right)),el=t=>t.next()>=.5,ro=(t,e,n)=>Nt(t.next()*(n+1-e)+e),Bd=(t,e,n)=>Nt(t.next()*(n+1-e)+e),ya=(t,e,n)=>Bd(t,e,n),Ey=t=>Od(ya(t,97,122)),Dy=(t,e=0,n=20)=>{const s=ya(t,e,n);let r="";for(let i=0;i<s;i++)r+=Ey(t);return r},io=(t,e)=>e[ya(t,0,e.length-1)],Ty=Symbol("0schema");class Ny{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(Og(" ",(this._rerrs.length-n)*2)+`${s.path!=null?`[${s.path}] `:""}${s.has} doesn't match ${s.expected}. ${s.message}`)}return e.join(`
|
|
8
|
+
`)}}const Io=(t,e)=>t===e?!0:t==null||e==null||t.constructor!==e.constructor?!1:t[Zs]?Fd(t,e):fs(t)?ia(t,n=>oa(e,s=>Io(n,s))):ty(t)?ar(t,(n,s)=>Io(n,e[s])):!1;class st{static _dilutes=!1;extends(e){let[n,s]=[this.shape,e.shape];return this.constructor._dilutes&&([s,n]=[n,s]),Io(n,s)}equals(e){return this.constructor===e.constructor&&ns(this.shape,e.shape)}[Ty](){return!0}[Zs](e){return this.equals(e)}validate(e){return this.check(e)}check(e,n){Tt()}get nullable(){return js(this,vi)}get optional(){return new qd(this)}cast(e){return tl(e,this),e}expect(e){return tl(e,this),e}}class wa extends st{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 Ae=(t,e=null)=>new wa(t,e);Ae(wa);class xa extends st{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 We=t=>new xa(t);Ae(xa);class yi extends st{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 wi=(...t)=>new yi(t),Vd=Ae(yi),Oy=RegExp.escape||(t=>t.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),Hd=t=>{if(gs.check(t))return[Oy(t)];if(Vd.check(t))return t.shape.map(e=>e+"");if(eu.check(t))return["[+-]?\\d+.?\\d*"];if(tu.check(t))return[".*"];if(ni.check(t))return t.shape.map(Hd).flat(1);pt()};class Py extends st{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(Hd).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}}Ae(Py);const _y=Symbol("optional");class qd extends st{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[_y](){return!0}}const Ry=Ae(qd);class Ly extends st{check(e,n){return n?.extend(null,"never",typeof e),!1}}Ae(Ly);class xi extends st{constructor(e,n=!1){super(),this.shape=e,this._isPartial=n}static _dilutes=!0;get partial(){return new xi(this.shape,!0)}check(e,n){return e==null?(n?.extend(null,"object","null"),!1):ar(this.shape,(s,r)=>{const i=this._isPartial&&!ma(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 Ay=t=>new xi(t),Fy=Ae(xi),Iy=We(t=>t!=null&&(t.constructor===Object||t.constructor==null));class Wd extends st{constructor(e,n){super(),this.shape={keys:e,values:n}}check(e,n){return e!=null&&ar(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 Kd=(t,e)=>new Wd(t,e),My=Ae(Wd);class Gd extends st{constructor(e){super(),this.shape=e}check(e,n){return e!=null&&ar(this.shape,(s,r)=>{const i=s.check(e[r],n);return!i&&n?.extend(r.toString(),"Tuple",typeof s),i})}}const $y=(...t)=>new Gd(t);Ae(Gd);class Jd extends st{constructor(e){super(),this.shape=e.length===1?e[0]:new ba(e)}check(e,n){const s=fs(e)&&ia(e,r=>this.shape.check(r));return!s&&n?.extend(null,"Array",""),s}}const Yd=(...t)=>new Jd(t),Uy=Ae(Jd),zy=We(t=>fs(t));class Xd extends st{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 By=(t,e=null)=>new Xd(t,e);Ae(Xd);const Vy=By(st);class Hy extends st{constructor(e){super(),this.len=e.length-1,this.args=$y(...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 qy=Ae(Hy),Wy=We(t=>typeof t=="function");class Ky extends st{constructor(e){super(),this.shape=e}check(e,n){const s=ia(this.shape,r=>r.check(e,n));return!s&&n?.extend(null,"Intersectinon",typeof e),s}}Ae(Ky,t=>t.shape.length>0);class ba extends st{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,n){const s=oa(this.shape,r=>r.check(e,n));return n?.extend(null,"Union",typeof e),s}}const js=(...t)=>t.findIndex(e=>ni.check(e))>=0?js(...t.map(e=>Qs(e)).map(e=>ni.check(e)?e.shape:[e]).flat(1)):t.length===1?t[0]:new ba(t),ni=Ae(ba),Zd=()=>!0,si=We(Zd),Gy=Ae(xa,t=>t.shape===Zd),va=We(t=>typeof t=="bigint"),Jy=We(t=>t===va),Qd=We(t=>typeof t=="symbol");We(t=>t===Qd);const ss=We(t=>typeof t=="number"),eu=We(t=>t===ss),gs=We(t=>typeof t=="string"),tu=We(t=>t===gs),bi=We(t=>typeof t=="boolean"),Yy=We(t=>t===bi),nu=wi(void 0);Ae(yi,t=>t.shape.length===1&&t.shape[0]===void 0);wi(void 0);const vi=wi(null),Xy=Ae(yi,t=>t.shape.length===1&&t.shape[0]===null);Ae(Uint8Array);Ae(wa,t=>t.shape===Uint8Array);const Zy=js(ss,gs,vi,nu,va,bi,Qd);(()=>{const t=Yd(si),e=Kd(gs,si),n=js(ss,gs,vi,bi,t,e);return t.shape=n,e.shape.values=n,n})();const Qs=t=>{if(Vy.check(t))return t;if(Iy.check(t)){const e={};for(const n in t)e[n]=Qs(t[n]);return Ay(e)}else{if(zy.check(t))return js(...t.map(Qs));if(Zy.check(t))return wi(t);if(Wy.check(t))return Ae(t)}pt()},tl=hy?()=>{}:(t,e)=>{const n=new Ny;if(!e.check(t,n))throw Ot(`Expected value to be of type ${e.constructor.name}.
|
|
9
|
+
${n.toString()}`)};class Qy{constructor(e){this.patterns=[],this.$state=e}if(e,n){return this.patterns.push({if:Qs(e),h:n}),this}else(e){return this.if(si,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 Ot("Unhandled pattern")}}}const ew=t=>new Qy(t),su=ew(si).if(eu,(t,e)=>ro(e,Wc,Qr)).if(tu,(t,e)=>Dy(e)).if(Yy,(t,e)=>el(e)).if(Jy,(t,e)=>BigInt(ro(e,Wc,Qr))).if(ni,(t,e)=>Gn(e,io(e,t.shape))).if(Fy,(t,e)=>{const n={};for(const s in t.shape){let r=t.shape[s];if(Ry.check(r)){if(el(e))continue;r=r.shape}n[s]=su(r,e)}return n}).if(Uy,(t,e)=>{const n=[],s=Bd(e,0,42);for(let r=0;r<s;r++)n.push(Gn(e,t.shape));return n}).if(Vd,(t,e)=>io(e,t.shape)).if(Xy,(t,e)=>null).if(qy,(t,e)=>{const n=Gn(e,t.res);return()=>n}).if(Gy,(t,e)=>Gn(e,io(e,[ss,gs,vi,nu,va,bi,Yd(ss),Kd(js("a","b","c"),ss)]))).if(My,(t,e)=>{const n={},s=ro(e,0,3);for(let r=0;r<s;r++){const i=Gn(e,t.shape.keys),a=Gn(e,t.shape.values);n[i]=a}return n}).done(),Gn=(t,e)=>su(Qs(e),t),Ht=typeof document<"u"?document:{},tw=t=>Ht.createElement(t),nw=()=>Ht.createDocumentFragment();We(t=>t.nodeType===uw);const sw=t=>Ht.createTextNode(t);typeof DOMParser<"u"&&new DOMParser;const rw=(t,e)=>(ky(e,(n,s)=>{s===!1?t.removeAttribute(n):s===!0?t.setAttribute(n,""):t.setAttribute(n,s)}),t),iw=t=>{const e=nw();for(let n=0;n<t.length;n++)ru(e,t[n]);return e},ow=(t,e)=>(ru(t,iw(e)),t),pv=(t,e=[],n=[])=>ow(rw(tw(t),e),n);We(t=>t.nodeType===cw);const mv=sw;We(t=>t.nodeType===lw);const aw=t=>gg(t,(e,n)=>`${n}:${e};`).join(""),ru=(t,e)=>t.appendChild(e),cw=Ht.ELEMENT_NODE,lw=Ht.TEXT_NODE;Ht.CDATA_SECTION_NODE;Ht.COMMENT_NODE;const dw=Ht.DOCUMENT_NODE;Ht.DOCUMENT_TYPE_NODE;const uw=Ht.DOCUMENT_FRAGMENT_NODE;We(t=>t.nodeType===dw);const an=Symbol,iu=an(),ou=an(),hw=an(),fw=an(),pw=an(),au=an(),mw=an(),Sa=an(),gw=an(),yw=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},ww={[iu]:Qt("font-weight","bold"),[ou]:Qt("font-weight","normal"),[hw]:Qt("color","blue"),[pw]:Qt("color","green"),[fw]:Qt("color","grey"),[au]:Qt("color","red"),[mw]:Qt("color","purple"),[Sa]:Qt("color","orange"),[gw]:Qt("color","black")},xw=t=>{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());const e=[],n=[],s=ct();let r=[],i=0;for(;i<t.length;i++){const a=t[i],c=ww[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=aw(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},cu=py?xw:yw,bw=(...t)=>{console.log(...cu(t)),du.forEach(e=>e.print(t))},lu=(...t)=>{console.warn(...cu(t)),t.unshift(Sa),du.forEach(e=>e.print(t))},du=yn(),uu=t=>({[Symbol.iterator](){return this},next:t}),vw=(t,e)=>uu(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),oo=(t,e)=>uu(()=>{const{done:n,value:s}=t.next();return{done:n,value:n?void 0:e(s)}});class Si{constructor(e,n){this.clock=e,this.len=n}}class ks{constructor(){this.clients=new Map}}const ys=(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])Eu(t,i,d.clock,d.len,n)}}),Sw=(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},cr=(t,e)=>{const n=t.clients.get(e.client);return n!==void 0&&Sw(n,e.clock)!==null},Ca=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 Si(r.clock,Rn(r.len,i.clock+i.len-r.clock)):(s<n&&(e[s]=i),s++)}e.length=s})},Mo=t=>{const e=new ks;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++)wg(i,t[a].clients.get(r)||[]);e.clients.set(r,i)}});return Ca(e),e},er=(t,e,n,s)=>{Vt(t.clients,e,()=>[]).push(new Si(n,s))},Cw=()=>new ks,jw=t=>{const e=Cw();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 Si(c,l))}}r.length>0&&e.clients.set(s,r)}),e},Es=(t,e)=>{z(t.restEncoder,e.clients.size),rn(e.clients.entries()).sort((n,s)=>s[0]-n[0]).forEach(([n,s])=>{t.resetDsCurVal(),z(t.restEncoder,n);const r=s.length;z(t.restEncoder,r);for(let i=0;i<r;i++){const a=s[i];t.writeDsClock(a.clock),t.writeDsLen(a.len)}})},ja=t=>{const e=new ks,n=Y(t.restDecoder);for(let s=0;s<n;s++){t.resetDsCurVal();const r=Y(t.restDecoder),i=Y(t.restDecoder);if(i>0){const a=Vt(e.clients,r,()=>[]);for(let c=0;c<i;c++)a.push(new Si(t.readDsClock(),t.readDsLen()))}}return e},nl=(t,e,n)=>{const s=new ks,r=Y(t.restDecoder);for(let i=0;i<r;i++){t.resetDsCurVal();const a=Y(t.restDecoder),c=Y(t.restDecoder),l=n.clients.get(a)||[],d=Ne(n,a);for(let f=0;f<c;f++){const u=t.readDsClock(),p=u+t.readDsLen();if(u<d){d<p&&er(s,a,d,p-d);let m=Ut(l,u),g=l[m];for(!g.deleted&&g.id.clock<u&&(l.splice(m+1,0,ui(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,ui(e,g,p-g.id.clock)),g.delete(e))}else er(s,a,u,p-u)}}if(s.clients.size>0){const i=new Nn;return z(i.restEncoder,0),Es(i,s),i.toUint8Array()}return null},hu=Rd;class Ln extends aa{constructor({guid:e=Xg(),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=hu(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new ju,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=ms(d=>{this.on("load",()=>{this.isLoaded=!0,d(this)})});const l=()=>ms(d=>{const f=u=>{(u===void 0||u===!0)&&(this.off("sync",f),d())};this.on("sync",f)});this.on("sync",d=>{d===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=d===void 0||d===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){const e=this._item;e!==null&&!this.shouldLoad&&ye(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(rn(this.subdocs).map(e=>e.guid))}transact(e,n=null){return ye(this,e,n)}get(e,n=qe){const s=Vt(this.share,e,()=>{const i=new n;return i._integrate(this,null),i}),r=s.constructor;if(n!==qe&&r!==n)if(r===qe){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,os)}getText(e=""){return this.get(e,bs)}getMap(e=""){return this.get(e,xs)}getXmlElement(e=""){return this.get(e,vs)}getXmlFragment(e=""){return this.get(e,On)}toJSON(){const e={};return this.share.forEach((n,s)=>{e[s]=n.toJSON()}),e}destroy(){this.isDestroyed=!0,rn(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new Ln({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,ye(e.parent.doc,s=>{const r=n.doc;e.deleted||s.subdocsAdded.add(r),s.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class fu{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return Y(this.restDecoder)}readDsLen(){return Y(this.restDecoder)}}class pu extends fu{readLeftID(){return Q(Y(this.restDecoder),Y(this.restDecoder))}readRightID(){return Q(Y(this.restDecoder),Y(this.restDecoder))}readClient(){return Y(this.restDecoder)}readInfo(){return ps(this.restDecoder)}readString(){return Ze(this.restDecoder)}readParentInfo(){return Y(this.restDecoder)===1}readTypeRef(){return Y(this.restDecoder)}readLen(){return Y(this.restDecoder)}readAny(){return Xs(this.restDecoder)}readBuf(){return Cy(Xe(this.restDecoder))}readJSON(){return JSON.parse(Ze(this.restDecoder))}readKey(){return Ze(this.restDecoder)}}class kw{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Y(this.restDecoder),this.dsCurrVal}readDsLen(){const e=Y(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class ws extends kw{constructor(e){super(e),this.keys=[],Y(e),this.keyClockDecoder=new so(Xe(e)),this.clientDecoder=new Vr(Xe(e)),this.leftClockDecoder=new so(Xe(e)),this.rightClockDecoder=new so(Xe(e)),this.infoDecoder=new Zc(Xe(e),ps),this.stringDecoder=new Gg(Xe(e)),this.parentInfoDecoder=new Zc(Xe(e),ps),this.typeRefDecoder=new Vr(Xe(e)),this.lenDecoder=new Vr(Xe(e))}readLeftID(){return new rs(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new rs(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 Xs(this.restDecoder)}readBuf(){return Xe(this.restDecoder)}readJSON(){return Xs(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 mu{constructor(){this.restEncoder=Re()}toUint8Array(){return xe(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){z(this.restEncoder,e)}writeDsLen(e){z(this.restEncoder,e)}}class lr extends mu{writeLeftID(e){z(this.restEncoder,e.client),z(this.restEncoder,e.clock)}writeRightID(e){z(this.restEncoder,e.client),z(this.restEncoder,e.clock)}writeClient(e){z(this.restEncoder,e)}writeInfo(e){Lo(this.restEncoder,e)}writeString(e){nn(this.restEncoder,e)}writeParentInfo(e){z(this.restEncoder,e?1:0)}writeTypeRef(e){z(this.restEncoder,e)}writeLen(e){z(this.restEncoder,e)}writeAny(e){Ys(this.restEncoder,e)}writeBuf(e){Te(this.restEncoder,e)}writeJSON(e){nn(this.restEncoder,JSON.stringify(e))}writeKey(e){nn(this.restEncoder,e)}}class gu{constructor(){this.restEncoder=Re(),this.dsCurrVal=0}toUint8Array(){return xe(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const n=e-this.dsCurrVal;this.dsCurrVal=e,z(this.restEncoder,n)}writeDsLen(e){e===0&&pt(),z(this.restEncoder,e-1),this.dsCurrVal+=e}}class Nn extends gu{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new no,this.clientEncoder=new Br,this.leftClockEncoder=new no,this.rightClockEncoder=new no,this.infoEncoder=new Jc(Lo),this.stringEncoder=new $g,this.parentInfoEncoder=new Jc(Lo),this.typeRefEncoder=new Br,this.lenEncoder=new Br}toUint8Array(){const e=Re();return z(e,0),Te(e,this.keyClockEncoder.toUint8Array()),Te(e,this.clientEncoder.toUint8Array()),Te(e,this.leftClockEncoder.toUint8Array()),Te(e,this.rightClockEncoder.toUint8Array()),Te(e,xe(this.infoEncoder)),Te(e,this.stringEncoder.toUint8Array()),Te(e,xe(this.parentInfoEncoder)),Te(e,this.typeRefEncoder.toUint8Array()),Te(e,this.lenEncoder.toUint8Array()),mi(e,xe(this.restEncoder)),xe(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){Ys(this.restEncoder,e)}writeBuf(e){Te(this.restEncoder,e)}writeJSON(e){Ys(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 Ew=(t,e,n,s)=>{s=Rn(s,e[0].id.clock);const r=Ut(e,s);z(t.restEncoder,e.length-r),t.writeClient(n),z(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)},ka=(t,e,n)=>{const s=new Map;n.forEach((r,i)=>{Ne(e,i)>r&&s.set(i,r)}),Ci(e).forEach((r,i)=>{n.has(i)||s.set(i,0)}),z(t.restEncoder,s.size),rn(s.entries()).sort((r,i)=>i[0]-r[0]).forEach(([r,i])=>{Ew(t,e.clients.get(r),r,i)})},Dw=(t,e)=>{const n=ct(),s=Y(t.restDecoder);for(let r=0;r<s;r++){const i=Y(t.restDecoder),a=new Array(i),c=t.readClient();let l=Y(t.restDecoder);n.set(c,{i:0,refs:a});for(let d=0;d<i;d++){const f=t.readInfo();switch(pi&f){case 0:{const u=t.readLen();a[d]=new vt(Q(c,l),u),l+=u;break}case 10:{const u=Y(t.restDecoder);a[d]=new St(Q(c,l),u),l+=u;break}default:{const u=(f&(tn|ft))===0,p=new be(Q(c,l),null,(f&ft)===ft?t.readLeftID():null,null,(f&tn)===tn?t.readRightID():null,u?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,u&&(f&Gs)===Gs?t.readString():null,Wu(t,f));a[d]=p,l+=p.length}}}}return n},Tw=(t,e,n)=>{const s=[];let r=rn(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 ju,l=new Map,d=(m,g)=>{const w=l.get(m);(w==null||w>g)&&l.set(m,g)};let f=a.refs[a.i++];const u=new Map,p=()=>{for(const m of s){const g=m.id.client,w=n.get(g);w?(w.i--,c.clients.set(g,w.refs.slice(w.i)),n.delete(g),w.i=0,w.refs=[]):c.clients.set(g,[m]),r=r.filter(b=>b!==g)}s.length=0};for(;;){if(f.constructor!==St){const g=Vt(u,f.id.client,()=>Ne(e,f.id.client))-f.id.clock;if(g<0)s.push(f),d(f.id.client,f.id.clock-1),p();else{const w=f.getMissing(t,e);if(w!==null){s.push(f);const b=n.get(w)||{refs:[],i:0};if(b.refs.length===b.i)d(w,Ne(e,w)),p();else{f=b.refs[b.i++];continue}}else(g===0||g<f.length)&&(f.integrate(t,g),u.set(f.id.client,f.id.clock+f.length))}}if(s.length>0)f=s.pop();else if(a!==null&&a.i<a.refs.length)f=a.refs[a.i++];else{if(a=i(),a===null)break;f=a.refs[a.i++]}}if(c.clients.size>0){const m=new Nn;return ka(m,c,new Map),z(m.restEncoder,0),{missing:l,update:m.toUint8Array()}}return null},Nw=(t,e)=>ka(t,e.doc.store,e.beforeState),Ow=(t,e,n,s=new ws(t))=>ye(e,r=>{r.local=!1;let i=!1;const a=r.doc,c=a.store,l=Dw(s,a),d=Tw(r,c,l),f=c.pendingStructs;if(f){for(const[p,m]of f.missing)if(m<Ne(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=ii([f.update,d.update])}}else c.pendingStructs=d;const u=nl(s,r,c);if(c.pendingDs){const p=new ws(bn(c.pendingDs));Y(p.restDecoder);const m=nl(p,r,c);u&&m?c.pendingDs=ii([u,m]):c.pendingDs=u||m}else c.pendingDs=u;if(i){const p=c.pendingStructs.update;c.pendingStructs=null,yu(r.doc,p)}},n,!1),yu=(t,e,n,s=ws)=>{const r=bn(e);Ow(r,t,n,new s(r))},wu=(t,e,n)=>yu(t,e,n,pu),Pw=(t,e,n=new Map)=>{ka(t,e.store,n),Es(t,jw(e.store))},_w=(t,e=new Uint8Array([0]),n=new Nn)=>{const s=xu(e);Pw(n,t,s);const r=[n.toUint8Array()];if(t.store.pendingDs&&r.push(t.store.pendingDs),t.store.pendingStructs&&r.push(Xw(t.store.pendingStructs.update,e)),r.length>1){if(n.constructor===lr)return Jw(r.map((i,a)=>a===0?i:Qw(i)));if(n.constructor===Nn)return ii(r)}return r[0]},Ea=(t,e)=>_w(t,e,new lr),Rw=t=>{const e=new Map,n=Y(t.restDecoder);for(let s=0;s<n;s++){const r=Y(t.restDecoder),i=Y(t.restDecoder);e.set(r,i)}return e},xu=t=>Rw(new fu(bn(t))),bu=(t,e)=>(z(t.restEncoder,e.size),rn(e.entries()).sort((n,s)=>s[0]-n[0]).forEach(([n,s])=>{z(t.restEncoder,n),z(t.restEncoder,s)}),t),Lw=(t,e)=>bu(t,Ci(e.store)),Aw=(t,e=new gu)=>(t instanceof Map?bu(e,t):Lw(e,t),e.toUint8Array()),Fw=t=>Aw(t,new mu);class Iw{constructor(){this.l=[]}}const sl=()=>new Iw,rl=(t,e)=>t.l.push(e),il=(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.")},vu=(t,e,n)=>ga(t.l,[e,n]);class rs{constructor(e,n){this.client=e,this.clock=n}}const es=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,Q=(t,e)=>new rs(t,e),Su=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw pt()},ri=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class Cu{constructor(e,n,s,r=0){this.type=e,this.tname=n,this.item=s,this.assoc=r}}const gv=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},yv=t=>new Cu(t.type==null?null:Q(t.type.client,t.type.clock),t.tname??null,t.item==null?null:Q(t.item.client,t.item.clock),t.assoc==null?0:t.assoc);class Mw{constructor(e,n,s=0){this.type=e,this.index=n,this.assoc=s}}const $w=(t,e,n=0)=>new Mw(t,e,n),Fr=(t,e,n)=>{let s=null,r=null;return t._item===null?r=Su(t):s=Q(t._item.id.client,t._item.id.clock),new Cu(s,r,e,n)},wv=(t,e,n=0)=>{let s=t._start;if(n<0){if(e===0)return Fr(t,null,n);e--}for(;s!==null;){if(!s.deleted&&s.countable){if(s.length>e)return Fr(t,Q(s.id.client,s.id.clock+e),n);e-=s.length}if(s.right===null&&n<0)return Fr(t,s.lastId,n);s=s.right}return Fr(t,null,n)},Uw=(t,e)=>{const n=is(t,e),s=e.clock-n.id.clock;return{item:n,diff:s}},xv=(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(Ne(s,r.client)<=r.clock)return null;const f=n?Bo(s,r):Uw(s,r),u=f.item;if(!(u instanceof be))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(Ne(s,i.client)<=i.clock)return null;const{item:f}=n?Bo(s,i):{item:is(s,i)};if(f instanceof be&&f.content instanceof qt)l=f.content.type;else return null}else throw pt();c>=0?d=l._length:d=0}return $w(l,d,t.assoc)},bv=(t,e)=>t===e||t!==null&&e!==null&&t.tname===e.tname&&es(t.item,e.item)&&es(t.type,e.type)&&t.assoc===e.assoc,Xn=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!cr(e.ds,t.id),$o=(t,e)=>{const n=Vt(t.meta,$o,yn),s=t.doc.store;n.has(e)||(e.sv.forEach((r,i)=>{r<Ne(s,i)&&at(t,Q(i,r))}),ys(t,e.ds,r=>{}),n.add(e))};class ju{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const Ci=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},Ne=(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},ku=(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 pt()}n.push(e)},Ut=(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 pt()},zw=(t,e)=>{const n=t.clients.get(e.client);return n[Ut(n,e.clock)]},is=zw,Uo=(t,e,n)=>{const s=Ut(e,n),r=e[s];return r.id.clock<n&&r instanceof be?(e.splice(s+1,0,ui(t,r,n-r.id.clock)),s+1):s},at=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[Uo(t,n,e.clock)]},ol=(t,e,n)=>{const s=e.clients.get(n.client),r=Ut(s,n.clock),i=s[r];return n.clock!==i.id.clock+i.length-1&&i.constructor!==vt&&s.splice(r+1,0,ui(t,i,n.clock-i.id.clock+1)),i},Bw=(t,e,n)=>{const s=t.clients.get(e.id.client);s[Ut(s,e.id.clock)]=n},Eu=(t,e,n,s,r)=>{if(s===0)return;const i=n+s;let a=Uo(t,e,n),c;do c=e[a++],i<c.id.clock+c.length&&Uo(t,e,i),r(c);while(a<e.length&&e[a].id.clock<i)};class Vw{constructor(e,n,s){this.doc=e,this.deleteSet=new ks,this.beforeState=Ci(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 al=(t,e)=>e.deleteSet.clients.size===0&&!yg(e.afterState,(n,s)=>e.beforeState.get(s)!==n)?!1:(Ca(e.deleteSet),Nw(t,e),Es(t,e.deleteSet),!0),cl=(t,e,n)=>{const s=e._item;(s===null||s.id.clock<(t.beforeState.get(s.id.client)||0)&&!s.deleted)&&Vt(t.changed,e,yn).add(n)},Hr=(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 be&&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},Hw=(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=Ut(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 be&&u.deleted&&!u.keep&&n(u)&&u.gc(e,!1)}}}},qw=(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=ca(r.length-1,1+Ut(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+Hr(r,l)}})},Du=(t,e)=>{if(e<t.length){const n=t[e],s=n.doc,r=s.store,i=n.deleteSet,a=n._mergeStructs;try{Ca(i),n.afterState=Ci(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(()=>{vu(d._dEH,l,n)}))}),c.push(()=>s.emit("afterTransaction",[n,s])),c.push(()=>{n._needFormattingCleanup&&fx(n)})}),ga(c,[])}finally{s.gc&&Hw(i,r,s.gcFilter),qw(i,r),n.afterState.forEach((f,u)=>{const p=n.beforeState.get(u)||0;if(p!==f){const m=r.clients.get(u),g=Rn(Ut(m,p),1);for(let w=m.length-1;w>=g;)w-=1+Hr(m,w)}});for(let f=a.length-1;f>=0;f--){const{client:u,clock:p}=a[f].id,m=r.clients.get(u),g=Ut(m,p);g+1<m.length&&Hr(m,g+1)>1||g>0&&Hr(m,g)}if(!n.local&&n.afterState.get(s.clientID)!==n.beforeState.get(s.clientID)&&(bw(Sa,iu,"[yjs] ",ou,au,"Changed the client-id because another client seems to be using it."),s.clientID=hu()),s.emit("afterTransactionCleanup",[n,s]),s._observers.has("update")){const f=new lr;al(f,n)&&s.emit("update",[f.toUint8Array(),n.origin,s,n])}if(s._observers.has("updateV2")){const f=new Nn;al(f,n)&&s.emit("updateV2",[f.toUint8Array(),n.origin,s,n])}const{subdocsAdded:c,subdocsLoaded:l,subdocsRemoved:d}=n;(c.size>0||d.size>0||l.size>0)&&(c.forEach(f=>{f.clientID=s.clientID,f.collectionid==null&&(f.collectionid=s.collectionid),s.subdocs.add(f)}),d.forEach(f=>s.subdocs.delete(f)),s.emit("subdocs",[{loaded:l,added:c,removed:d},s,n]),d.forEach(f=>f.destroy())),t.length<=e+1?(s._transactionCleanups=[],s.emit("afterAllTransactions",[s,t])):Du(t,e+1)}}},ye=(t,e,n=null,s=!0)=>{const r=t._transactionCleanups;let i=!1,a=null;t._transaction===null&&(i=!0,t._transaction=new Vw(t,n,s),r.push(t._transaction),r.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{a=e(t._transaction)}finally{if(i){const c=t._transaction===r[0];t._transaction=null,c&&Du(r,0)}}return a};class Ww{constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const ll=(t,e,n)=>{ys(t,n.deletions,s=>{s instanceof be&&e.scope.some(r=>r===t.doc||ri(r,s))&&La(s,!1)})},dl=(t,e,n)=>{let s=null;const r=t.doc,i=t.scope;ye(r,c=>{for(;e.length>0&&t.currStackItem===null;){const l=r.store,d=e.pop(),f=new Set,u=[];let p=!1;ys(c,d.insertions,m=>{if(m instanceof be){if(m.redone!==null){let{item:g,diff:w}=Bo(l,m.id);w>0&&(g=at(c,Q(g.id.client,g.id.clock+w))),m=g}!m.deleted&&i.some(g=>g===c.doc||ri(g,m))&&u.push(m)}}),ys(c,d.deletions,m=>{m instanceof be&&i.some(g=>g===c.doc||ri(g,m))&&!cr(d.insertions,m.id)&&f.add(m)}),f.forEach(m=>{p=qu(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 Kw extends aa{constructor(e,{captureTimeout:n=500,captureTransaction:s=l=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:c=fs(e)?e[0].doc:e instanceof Ln?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 ks;l.afterState.forEach((b,v)=>{const k=l.beforeState.get(v)||0,P=b-k;P>0&&er(p,v,k,P)});const m=wn();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=Mo([b.deletions,l.deleteSet]),b.insertions=Mo([b.insertions,p])}else u.push(new Ww(l.deleteSet,p)),g=!0;!d&&!f&&(this.lastChange=m),ys(l,l.deleteSet,b=>{b instanceof be&&this.scope.some(v=>v===l.doc||ri(v,b))&&La(b,!0)});const w=[{stackItem:u[u.length-1],origin:l.origin,type:d?"redo":"undo",changedParentTypes:l.changedParentTypes},this];g?this.emit("stack-item-added",w):this.emit("stack-item-updated",w)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){const n=new Set(this.scope);e=fs(e)?e:[e],e.forEach(s=>{n.has(s)||(n.add(s),(s instanceof qe?s.doc!==this.doc:s!==this.doc)&&lu("[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=>ll(s,this,r)),this.undoStack=[]),n&&(this.redoStack.forEach(r=>ll(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=dl(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=dl(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*Gw(t){const e=Y(t.restDecoder);for(let n=0;n<e;n++){const s=Y(t.restDecoder),r=t.readClient();let i=Y(t.restDecoder);for(let a=0;a<s;a++){const c=t.readInfo();if(c===10){const l=Y(t.restDecoder);yield new St(Q(r,i),l),i+=l}else if((pi&c)!==0){const l=(c&(tn|ft))===0,d=new be(Q(r,i),null,(c&ft)===ft?t.readLeftID():null,null,(c&tn)===tn?t.readRightID():null,l?t.readParentInfo()?t.readString():t.readLeftID():null,l&&(c&Gs)===Gs?t.readString():null,Wu(t,c));yield d,i+=d.length}else{const l=t.readLen();yield new vt(Q(r,i),l),i+=l}}}}class Da{constructor(e,n){this.gen=Gw(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===St);return this.curr}}class Ta{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const Jw=t=>ii(t,pu,lr),Yw=(t,e)=>{if(t.constructor===vt){const{client:n,clock:s}=t.id;return new vt(Q(n,s+e),t.length-e)}else if(t.constructor===St){const{client:n,clock:s}=t.id;return new St(Q(n,s+e),t.length-e)}else{const n=t,{client:s,clock:r}=n.id;return new be(Q(s,r+e),null,Q(s,r+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},ii=(t,e=ws,n=Nn)=>{if(t.length===1)return t[0];const s=t.map(f=>new e(bn(f)));let r=s.map(f=>new Da(f,!0)),i=null;const a=new n,c=new Ta(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===St?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)hn(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===St)i.struct.length=p.id.clock+p.length-i.struct.id.clock;else{hn(c,i.struct,i.offset);const g=p.id.clock-i.struct.id.clock-i.struct.length;i={struct:new St(Q(u,i.struct.id.clock+i.struct.length),g),offset:0}}else{const g=i.struct.id.clock+i.struct.length-p.id.clock;g>0&&(i.struct.constructor===St?i.struct.length-=g:p=Yw(p,g)),i.struct.mergeWith(p)||(hn(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!==St;p=f.next())hn(c,i.struct,i.offset),i={struct:p,offset:0}}i!==null&&(hn(c,i.struct,i.offset),i=null),Na(c);const l=s.map(f=>ja(f)),d=Mo(l);return Es(a,d),a.toUint8Array()},Xw=(t,e,n=ws,s=Nn)=>{const r=xu(e),i=new s,a=new Ta(i),c=new n(bn(t)),l=new Da(c,!1);for(;l.curr;){const f=l.curr,u=f.id.client,p=r.get(u)||0;if(l.curr.constructor===St){l.next();continue}if(f.id.clock+f.length>p)for(hn(a,f,Rn(p-f.id.clock,0)),l.next();l.curr&&l.curr.id.client===u;)hn(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()}Na(a);const d=ja(c);return Es(i,d),i.toUint8Array()},Tu=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:xe(t.encoder.restEncoder)}),t.encoder.restEncoder=Re(),t.written=0)},hn=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&Tu(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),z(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},Na=t=>{Tu(t);const e=t.encoder.restEncoder;z(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const s=t.clientStructs[n];z(e,s.written),mi(e,s.restEncoder)}},Zw=(t,e,n,s)=>{const r=new n(bn(t)),i=new Da(r,!1),a=new s,c=new Ta(a);for(let d=i.curr;d!==null;d=i.next())hn(c,e(d),0);Na(c);const l=ja(r);return Es(a,l),a.toUint8Array()},Qw=t=>Zw(t,ly,ws,lr),ul="You must not compute changes after the event-handler fired.";class ji{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=ex(this.currentTarget,this.target))}deletes(e){return cr(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Ot(ul);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=Qi(l.content.getContent());else return;else l!==null&&this.deletes(l)?(a="update",c=Qi(l.content.getContent())):(a="add",c=void 0)}else if(this.deletes(i))a="delete",c=Qi(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 Ot(ul);const n=this.target,s=yn(),r=yn(),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 ex=(t,e)=>{const n=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let s=0,r=e._item.parent._start;for(;r!==e._item&&r!==null;)!r.deleted&&r.countable&&(s+=r.length),r=r.right;n.unshift(s)}e=e._item.parent}return n},Qe=()=>{lu("Invalid access: Add Yjs type to a document before reading data.")},Nu=80;let Oa=0;class tx{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=Oa++}}const nx=t=>{t.timestamp=Oa++},Ou=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=Oa++},sx=(t,e,n)=>{if(t.length>=Nu){const s=t.reduce((r,i)=>r.timestamp<i.timestamp?r:i);return Ou(s,e,n),s}else{const s=new tx(e,n);return t.push(s),s}},ki=(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)=>zr(e-i.index)<zr(e-a.index)?i:a);let s=t._start,r=0;for(n!==null&&(s=n.p,r=n.index,nx(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&&zr(n.index-r)<s.parent.length/Nu?(Ou(n,s,r),n):sx(t._searchMarker,s,r)},tr=(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=Rn(e,r.index+n))}},Ei=(t,e,n)=>{const s=t,r=e.changedParentTypes;for(;Vt(r,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;vu(s._eH,n,e)};class qe{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=sl(),this._dEH=sl(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw Tt()}clone(){throw Tt()}_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){rl(this._eH,e)}observeDeep(e){rl(this._dEH,e)}unobserve(e){il(this._eH,e)}unobserveDeep(e){il(this._dEH,e)}toJSON(){}}const Pu=(t,e,n)=>{t.doc??Qe(),e<0&&(e=t._length+e),n<0&&(n=t._length+n);let s=n-e;const r=[];let i=t._start;for(;i!==null&&s>0;){if(i.countable&&!i.deleted){const a=i.content.getContent();if(a.length<=e)e-=a.length;else{for(let c=e;c<a.length&&s>0;c++)r.push(a[c]),s--;e=0}}i=i.right}return r},_u=t=>{t.doc??Qe();const e=[];let n=t._start;for(;n!==null;){if(n.countable&&!n.deleted){const s=n.content.getContent();for(let r=0;r<s.length;r++)e.push(s[r])}n=n.right}return e},nr=(t,e)=>{let n=0,s=t._start;for(t.doc??Qe();s!==null;){if(s.countable&&!s.deleted){const r=s.content.getContent();for(let i=0;i<r.length;i++)e(r[i],n++,t)}s=s.right}},Ru=(t,e)=>{const n=[];return nr(t,(s,r)=>{n.push(e(s,r,t))}),n},rx=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}}}},Lu=(t,e)=>{t.doc??Qe();const n=ki(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}},oi=(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 be(Q(a,Ne(c,a)),r,r&&r.lastId,l,l&&l.id,e,null,new Pn(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 be(Q(a,Ne(c,a)),r,r&&r.lastId,l,l&&l.id,e,null,new dr(new Uint8Array(u))),r.integrate(t,0);break;case Ln:r=new be(Q(a,Ne(c,a)),r,r&&r.lastId,l,l&&l.id,e,null,new ur(u)),r.integrate(t,0);break;default:if(u instanceof qe)r=new be(Q(a,Ne(c,a)),r,r&&r.lastId,l,l&&l.id,e,null,new qt(u)),r.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),f()},Au=()=>Ot("Length exceeded!"),Fu=(t,e,n,s)=>{if(n>e._length)throw Au();if(n===0)return e._searchMarker&&tr(e._searchMarker,n,s.length),oi(t,e,null,s);const r=n,i=ki(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&&at(t,Q(a.id.client,a.id.clock+n));break}n-=a.length}return e._searchMarker&&tr(e._searchMarker,r,s.length),oi(t,e,a,s)},ix=(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 oi(t,e,r,n)},Iu=(t,e,n,s)=>{if(s===0)return;const r=n,i=s,a=ki(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&&at(t,Q(c.id.client,c.id.clock+n)),n-=c.length);for(;s>0&&c!==null;)c.deleted||(s<c.length&&at(t,Q(c.id.client,c.id.clock+s)),c.delete(t),s-=c.length),c=c.right;if(s>0)throw Au();e._searchMarker&&tr(e._searchMarker,r,-i+s)},ai=(t,e,n)=>{const s=e._map.get(n);s!==void 0&&s.delete(t)},Pa=(t,e,n,s)=>{const r=e._map.get(n)||null,i=t.doc,a=i.clientID;let c;if(s==null)c=new Pn([s]);else switch(s.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:c=new Pn([s]);break;case Uint8Array:c=new dr(s);break;case Ln:c=new ur(s);break;default:if(s instanceof qe)c=new qt(s);else throw new Error("Unexpected content type")}new be(Q(a,Ne(i.store,a)),r,r&&r.lastId,null,null,e,n,c).integrate(t,0)},_a=(t,e)=>{t.doc??Qe();const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Mu=t=>{const e={};return t.doc??Qe(),t._map.forEach((n,s)=>{n.deleted||(e[s]=n.content.getContent()[n.length-1])}),e},$u=(t,e)=>{t.doc??Qe();const n=t._map.get(e);return n!==void 0&&!n.deleted},ox=(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&&Xn(i,e)&&(n[r]=i.content.getContent()[i.length-1])}),n},Ir=t=>(t.doc??Qe(),vw(t._map.entries(),e=>!e[1].deleted));class ax extends ji{}class os extends qe{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new os;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new os}clone(){const e=new os;return e.insert(0,this.toArray().map(n=>n instanceof qe?n.clone():n)),e}get length(){return this.doc??Qe(),this._length}_callObserver(e,n){super._callObserver(e,n),Ei(this,e,new ax(this,e))}insert(e,n){this.doc!==null?ye(this.doc,s=>{Fu(s,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?ye(this.doc,n=>{ix(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?ye(this.doc,s=>{Iu(s,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return Lu(this,e)}toArray(){return _u(this)}slice(e=0,n=this.length){return Pu(this,e,n)}toJSON(){return this.map(e=>e instanceof qe?e.toJSON():e)}map(e){return Ru(this,e)}forEach(e){nr(this,e)}[Symbol.iterator](){return rx(this)}_write(e){e.writeTypeRef(_x)}}const cx=t=>new os;class lx extends ji{constructor(e,n,s){super(e,n),this.keysChanged=s}}class xs extends qe{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 xs}clone(){const e=new xs;return this.forEach((n,s)=>{e.set(s,n instanceof qe?n.clone():n)}),e}_callObserver(e,n){Ei(this,e,new lx(this,e,n))}toJSON(){this.doc??Qe();const e={};return this._map.forEach((n,s)=>{if(!n.deleted){const r=n.content.getContent()[n.length-1];e[s]=r instanceof qe?r.toJSON():r}}),e}get size(){return[...Ir(this)].length}keys(){return oo(Ir(this),e=>e[0])}values(){return oo(Ir(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return oo(Ir(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??Qe(),this._map.forEach((n,s)=>{n.deleted||e(n.content.getContent()[n.length-1],s,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?ye(this.doc,n=>{ai(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?ye(this.doc,s=>{Pa(s,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return _a(this,e)}has(e){return $u(this,e)}clear(){this.doc!==null?ye(this.doc,e=>{this.forEach(function(n,s,r){ai(e,r,s)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(Rx)}}const dx=t=>new xs,fn=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&ay(t,e);class zo{constructor(e,n,s,r){this.left=e,this.right=n,this.index=s,this.currentAttributes=r}forward(){this.right===null&&pt(),this.right.content.constructor===$e?this.right.deleted||Ds(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}}const hl=(t,e,n)=>{for(;e.right!==null&&n>0;)e.right.content.constructor===$e?e.right.deleted||Ds(e.currentAttributes,e.right.content):e.right.deleted||(n<e.right.length&&at(t,Q(e.right.id.client,e.right.id.clock+n)),e.index+=e.right.length,n-=e.right.length),e.left=e.right,e.right=e.right.right;return e},Mr=(t,e,n,s)=>{const r=new Map,i=s?ki(e,n):null;if(i){const a=new zo(i.p.left,i.p,i.index,r);return hl(t,a,n-i.index)}else{const a=new zo(null,e._start,0,r);return hl(t,a,n)}},Uu=(t,e,n,s)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===$e&&fn(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 be(Q(i,Ne(r.store,i)),l,l&&l.lastId,d,d&&d.id,e,null,new $e(c,a));f.integrate(t,0),n.right=f,n.forward()})},Ds=(t,e)=>{const{key:n,value:s}=e;s===null?t.delete(n):t.set(n,s)},zu=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===$e&&fn(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},Bu=(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(!fn(d,l)){a.set(c,d);const{left:f,right:u}=n;n.right=new be(Q(i,Ne(r.store,i)),f,f&&f.lastId,u,u&&u.id,e,null,new $e(c,l)),n.right.integrate(t,0),n.forward()}}return a},ao=(t,e,n,s,r)=>{n.currentAttributes.forEach((p,m)=>{r[m]===void 0&&(r[m]=null)});const i=t.doc,a=i.clientID;zu(n,r);const c=Bu(t,e,n,r),l=s.constructor===String?new zt(s):s instanceof qe?new qt(s):new An(s);let{left:d,right:f,index:u}=n;e._searchMarker&&tr(e._searchMarker,n.index,l.getLength()),f=new be(Q(a,Ne(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(),Uu(t,e,n,c)},fl=(t,e,n,s,r)=>{const i=t.doc,a=i.clientID;zu(n,r);const c=Bu(t,e,n,r);e:for(;n.right!==null&&(s>0||c.size>0&&(n.right.deleted||n.right.content.constructor===$e));){if(!n.right.deleted)switch(n.right.content.constructor){case $e:{const{key:l,value:d}=n.right.content,f=r[l];if(f!==void 0){if(fn(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&&at(t,Q(n.right.id.client,n.right.id.clock+s)),s-=n.right.length;break}n.forward()}if(s>0){let l="";for(;s>0;s--)l+=`
|
|
10
|
+
`;n.right=new be(Q(a,Ne(i.store,a)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new zt(l)),n.right.integrate(t,0),n.forward()}Uu(t,e,n,c)},Vu=(t,e,n,s,r)=>{let i=e;const a=ct();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===$e){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===$e){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&&Ds(r,d)}}e=e.right}return c},ux=(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===$e){const s=e.content.key;n.has(s)?e.delete(t):n.add(s)}e=e.left}},hx=t=>{let e=0;return ye(t.doc,n=>{let s=t._start,r=t._start,i=ct();const a=_o(i);for(;r;)r.deleted===!1&&(r.content.constructor===$e?Ds(a,r.content):(e+=Vu(n,s,r,i,a),i=_o(a),s=r)),r=r.right}),e},fx=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&&Eu(t,n.store.clients.get(s),i,r,a=>{!a.deleted&&a.content.constructor===$e&&a.constructor!==vt&&e.add(a.parent)})}ye(n,s=>{ys(t,t.deleteSet,r=>{if(r instanceof vt||!r.parent._hasFormatting||e.has(r.parent))return;const i=r.parent;r.content.constructor===$e?e.add(i):ux(s,r)});for(const r of e)hx(r)})},pl=(t,e,n)=>{const s=n,r=_o(e.currentAttributes),i=e.right;for(;n>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case qt:case An:case zt:n<e.right.length&&at(t,Q(e.right.id.client,e.right.id.clock+n)),n-=e.right.length,e.right.delete(t);break}e.forward()}i&&Vu(t,i,e.right,r,e.currentAttributes);const a=(e.left||e.right).parent;return a._searchMarker&&tr(a._searchMarker,e.index,-s+n),e};class px extends ji{constructor(e,n,s){super(e,n),this.childListChanged=!1,this.keysChanged=new Set,s.forEach(r=>{r===null?this.childListChanged=!0:this.keysChanged.add(r)})}get changes(){if(this._changes===null){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){const e=this.target.doc,n=[];ye(e,s=>{const r=new Map,i=new Map;let a=this.target._start,c=null;const l={};let d="",f=0,u=0;const p=()=>{if(c!==null){let m=null;switch(c){case"delete":u>0&&(m={delete:u}),u=0;break;case"insert":(typeof d=="object"||d.length>0)&&(m={insert:d},r.size>0&&(m.attributes={},r.forEach((g,w)=>{g!==null&&(m.attributes[w]=g)}))),d="";break;case"retain":f>0&&(m={retain:f},oy(l)||(m.attributes=ny({},l))),f=0;break}m&&n.push(m),c=null}};for(;a!==null;){switch(a.content.constructor){case qt:case An: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 zt: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 $e:{const{key:m,value:g}=a.content;if(this.adds(a)){if(!this.deletes(a)){const w=r.get(m)??null;fn(w,g)?g!==null&&a.delete(s):(c==="retain"&&p(),fn(g,i.get(m)??null)?delete l[m]:l[m]=g)}}else if(this.deletes(a)){i.set(m,g);const w=r.get(m)??null;fn(w,g)||(c==="retain"&&p(),l[m]=w)}else if(!a.deleted){i.set(m,g);const w=l[m];w!==void 0&&(fn(w,g)?w!==null&&a.delete(s):(c==="retain"&&p(),g===null?delete l[m]:l[m]=g))}a.deleted||(c==="insert"&&p(),Ds(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 bs extends qe{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??Qe(),this._length}_integrate(e,n){super._integrate(e,n);try{this._pending.forEach(s=>s())}catch(s){console.error(s)}this._pending=null}_copy(){return new bs}clone(){const e=new bs;return e.applyDelta(this.toDelta()),e}_callObserver(e,n){super._callObserver(e,n);const s=new px(this,e,n);Ei(this,e,s),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??Qe();let e="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===zt&&(e+=n.content.str),n=n.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:n=!0}={}){this.doc!==null?ye(this.doc,s=>{const r=new zo(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)&&ao(s,this,r,c,a.attributes||{})}else a.retain!==void 0?fl(s,this,r,a.retain,a.attributes||{}):a.delete!==void 0&&pl(s,r,a.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,s){this.doc??Qe();const r=[],i=new Map,a=this.doc;let c="",l=this._start;function d(){if(c.length>0){const u={};let p=!1;i.forEach((g,w)=>{p=!0,u[w]=g});const m={insert:c};p&&(m.attributes=u),r.push(m),c=""}}const f=()=>{for(;l!==null;){if(Xn(l,e)||n!==void 0&&Xn(l,n))switch(l.content.constructor){case zt:{const u=i.get("ychange");e!==void 0&&!Xn(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&&!Xn(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 qt:case An:{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 $e:Xn(l,e)&&(d(),Ds(i,l.content));break}l=l.right}d()};return e||n?ye(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?ye(r,i=>{const a=Mr(i,this,e,!s);s||(s={},a.currentAttributes.forEach((c,l)=>{s[l]=c})),ao(i,this,a,n,s)}):this._pending.push(()=>this.insert(e,n,s))}insertEmbed(e,n,s){const r=this.doc;r!==null?ye(r,i=>{const a=Mr(i,this,e,!s);ao(i,this,a,n,s||{})}):this._pending.push(()=>this.insertEmbed(e,n,s||{}))}delete(e,n){if(n===0)return;const s=this.doc;s!==null?ye(s,r=>{pl(r,Mr(r,this,e,!0),n)}):this._pending.push(()=>this.delete(e,n))}format(e,n,s){if(n===0)return;const r=this.doc;r!==null?ye(r,i=>{const a=Mr(i,this,e,!1);a.right!==null&&fl(i,this,a,n,s)}):this._pending.push(()=>this.format(e,n,s))}removeAttribute(e){this.doc!==null?ye(this.doc,n=>{ai(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?ye(this.doc,s=>{Pa(s,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return _a(this,e)}getAttributes(){return Mu(this)}_write(e){e.writeTypeRef(Lx)}}const mx=t=>new bs;class co{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??Qe()}[Symbol.iterator](){return this}next(){let e=this._currentNode,n=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(n)))do if(n=e.content.type,!e.deleted&&(n.constructor===vs||n.constructor===On)&&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 On extends qe{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 On}clone(){const e=new On;return e.insert(0,this.toArray().map(n=>n instanceof qe?n.clone():n)),e}get length(){return this.doc??Qe(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new co(this,e)}querySelector(e){e=e.toUpperCase();const s=new co(this,r=>r.nodeName&&r.nodeName.toUpperCase()===e).next();return s.done?null:s.value}querySelectorAll(e){return e=e.toUpperCase(),rn(new co(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){Ei(this,e,new wx(this,n,e))}toString(){return Ru(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),nr(this,i=>{r.insertBefore(i.toDOM(e,n,s),null)}),r}insert(e,n){this.doc!==null?ye(this.doc,s=>{Fu(s,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)ye(this.doc,s=>{const r=e&&e instanceof qe?e._item:e;oi(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 Ot("Reference item not found");s.splice(r,0,...n)}}delete(e,n=1){this.doc!==null?ye(this.doc,s=>{Iu(s,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return _u(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Lu(this,e)}slice(e=0,n=this.length){return Pu(this,e,n)}forEach(e){nr(this,e)}_write(e){e.writeTypeRef(Fx)}}const gx=t=>new On;class vs extends On{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 vs(this.nodeName)}clone(){const e=new vs(this.nodeName),n=this.getAttributes();return ry(n,(s,r)=>{e.setAttribute(r,s)}),e.insert(0,this.toArray().map(s=>s instanceof qe?s.clone():s)),e}toString(){const e=this.getAttributes(),n=[],s=[];for(const c in e)s.push(c);s.sort();const r=s.length;for(let c=0;c<r;c++){const l=s[c];n.push(l+'="'+e[l]+'"')}const i=this.nodeName.toLocaleLowerCase(),a=n.length>0?" "+n.join(" "):"";return`<${i}${a}>${super.toString()}</${i}>`}removeAttribute(e){this.doc!==null?ye(this.doc,n=>{ai(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?ye(this.doc,s=>{Pa(s,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return _a(this,e)}hasAttribute(e){return $u(this,e)}getAttributes(e){return e?ox(this,e):Mu(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 nr(this,a=>{r.appendChild(a.toDOM(e,n,s))}),s!==void 0&&s._createAssociation(r,this),r}_write(e){e.writeTypeRef(Ax),e.writeKey(this.nodeName)}}const yx=t=>new vs(t.readKey());class wx extends ji{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 ci extends xs{constructor(e){super(),this.hookName=e}_copy(){return new ci(this.hookName)}clone(){const e=new ci(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(Ix),e.writeKey(this.hookName)}}const xx=t=>new ci(t.readKey());class li extends bs{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 li}clone(){const e=new li;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(Mx)}}const bx=t=>new li;class Ra{constructor(e,n){this.id=e,this.length=n}get deleted(){throw Tt()}mergeWith(e){return!1}write(e,n,s){throw Tt()}integrate(e,n){throw Tt()}}const vx=0;class vt extends Ra{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),ku(e.doc.store,this)}write(e,n){e.writeInfo(vx),e.writeLen(this.length-n)}getMissing(e,n){return null}}class dr{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new dr(this.content)}splice(e){throw Tt()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}}const Sx=t=>new dr(t.readBuf());class sr{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new sr(this.len)}splice(e){const n=new sr(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){er(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 Cx=t=>new sr(t.readLen()),Hu=(t,e)=>new Ln({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class ur{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 ur(Hu(this.doc.guid,this.opts))}splice(e){throw Tt()}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 jx=t=>new ur(Hu(t.readString(),t.readAny()));class An{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new An(this.embed)}splice(e){throw Tt()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}}const kx=t=>new An(t.readJSON());class $e{constructor(e,n){this.key=e,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new $e(this.key,this.value)}splice(e){throw Tt()}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 Ex=t=>new $e(t.readKey(),t.readJSON());class di{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new di(this.arr)}splice(e){const n=new di(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 Dx=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 di(n)},Tx=ti("node_env")==="development";class Pn{constructor(e){this.arr=e,Tx&&Id(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Pn(this.arr)}splice(e){const n=new Pn(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 Nx=t=>{const e=t.readLen(),n=[];for(let s=0;s<e;s++)n.push(t.readAny());return new Pn(n)};class zt{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new zt(this.str)}splice(e){const n=new zt(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 Ox=t=>new zt(t.readString()),Px=[cx,dx,mx,yx,gx,xx,bx],_x=0,Rx=1,Lx=2,Ax=3,Fx=4,Ix=5,Mx=6;class qt{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new qt(this.type._copy())}splice(e){throw Tt()}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 $x=t=>new qt(Px[t.readTypeRef()](t)),Bo=(t,e)=>{let n=e,s=0,r;do s>0&&(n=Q(n.client,n.clock+s)),r=is(t,n),s=n.clock-r.id.clock,n=r.redone;while(n!==null&&r instanceof be);return{item:r,diff:s}},La=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},ui=(t,e,n)=>{const{client:s,clock:r}=e.id,i=new be(Q(s,r+n),e,Q(s,r+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&i.markDeleted(),e.keep&&(i.keep=!0),e.redone!==null&&(i.redone=Q(e.redone.client,e.redone.clock+n)),e.right=i,i.right!==null&&(i.right.left=i),t._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),e.length=n,i},ml=(t,e)=>oa(t,n=>cr(n.deletions,e)),qu=(t,e,n,s,r,i)=>{const a=t.doc,c=a.store,l=a.clientID,d=e.redone;if(d!==null)return at(t,d);let f=e.parent._item,u=null,p;if(f!==null&&f.deleted===!0){if(f.redone===null&&(!n.has(f)||qu(t,f,n,s,r,i)===null))return null;for(;f.redone!==null;)f=at(t,f.redone)}const m=f===null?e.parent:f.content.type;if(e.parentSub===null){for(u=e.left,p=e;u!==null;){let v=u;for(;v!==null&&v.parent._item!==f;)v=v.redone===null?null:at(t,v.redone);if(v!==null&&v.parent._item===f){u=v;break}u=u.left}for(;p!==null;){let v=p;for(;v!==null&&v.parent._item!==f;)v=v.redone===null?null:at(t,v.redone);if(v!==null&&v.parent._item===f){p=v;break}p=p.right}}else{if(p=null,e.right&&!r){for(u=e;u!==null&&u.right!==null&&(u.right.redone||cr(s,u.right.id)||ml(i.undoStack,u.right.id)||ml(i.redoStack,u.right.id));)for(u=u.right;u.redone;)u=at(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=Ne(c,l),w=Q(l,g),b=new be(w,u,u&&u.lastId,p,p&&p.id,m,e.parentSub,e.content.copy());return e.redone=w,La(b,!0),b.integrate(t,0),b};class be extends Ra{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()?qc:0}set marker(e){(this.info&to)>0!==e&&(this.info^=to)}get marker(){return(this.info&to)>0}get keep(){return(this.info&Hc)>0}set keep(e){this.keep!==e&&(this.info^=Hc)}get countable(){return(this.info&qc)>0}get deleted(){return(this.info&eo)>0}set deleted(e){this.deleted!==e&&(this.info^=eo)}markDeleted(){this.info|=eo}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=Ne(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Ne(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===rs&&this.id.client!==this.parent.client&&this.parent.clock>=Ne(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=ol(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=at(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===vt||this.right&&this.right.constructor===vt)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===be?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===be&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===rs){const s=is(n,this.parent);s.constructor===vt?this.parent=null:this.parent=s.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=ol(e,e.doc.store,Q(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let s=this.left,r;if(s!==null)r=s.right;else if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start;const i=new Set,a=new Set;for(;r!==null&&r!==this.right;){if(a.add(r),i.add(r),es(this.origin,r.origin)){if(r.id.client<this.id.client)s=r,i.clear();else if(es(this.rightOrigin,r.rightOrigin))break}else if(r.origin!==null&&a.has(is(e.doc.store,r.origin)))i.has(is(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),ku(e.doc.store,this),this.content.integrate(e,this),cl(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new vt(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:Q(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&es(e.origin,this.lastId)&&this.right===e&&es(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(),er(e.deleteSet,this.id.client,this.id.clock,this.length),cl(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw pt();this.content.gc(e),n?Bw(e,this,new vt(this.id,this.length)):this.content=new sr(this.length)}write(e,n){const s=n>0?Q(this.id.client,this.id.clock+n-1):this.origin,r=this.rightOrigin,i=this.parentSub,a=this.content.getRef()&pi|(s===null?0:ft)|(r===null?0:tn)|(i===null?0:Gs);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=Su(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===rs?(e.writeParentInfo(!1),e.writeLeftID(c)):pt();i!==null&&e.writeString(i)}this.content.write(e,n)}}const Wu=(t,e)=>Ux[e&pi](t),Ux=[()=>{pt()},Cx,Dx,Sx,Ox,kx,Ex,$x,Nx,jx,()=>{pt()}],zx=10;class St extends Ra{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){pt()}write(e,n){e.writeInfo(zx),z(e.restEncoder,this.length-n)}getMissing(e,n){return null}}const Ku=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Gu="__ $YJS$ __";Ku[Gu]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Ku[Gu]=!0;const Ju=new Map;class Bx{constructor(e){this.room=e,this.onmessage=null,this._onChange=n=>n.key===e&&this.onmessage!==null&&this.onmessage({data:Sy(n.newValue||"")}),Qg(this._onChange)}postMessage(e){Ad.setItem(this.room,vy(gy(e)))}close(){ey(this._onChange)}}const Vx=typeof BroadcastChannel>"u"?Bx:BroadcastChannel,Aa=t=>Vt(Ju,t,()=>{const e=yn(),n=new Vx(t);return n.onmessage=s=>e.forEach(r=>r(s.data,"broadcastchannel")),{bc:n,subs:e}}),Hx=(t,e)=>(Aa(t).subs.add(e),e),qx=(t,e)=>{const n=Aa(t),s=n.subs.delete(e);return s&&n.subs.size===0&&(n.bc.close(),Ju.delete(t)),s},Zn=(t,e,n=null)=>{const s=Aa(t);s.bc.postMessage(e),s.subs.forEach(r=>r(e,n))},Yu=0,Fa=1,Xu=2,hi=(t,e)=>{z(t,Yu);const n=Fw(e);Te(t,n)},Zu=(t,e,n)=>{z(t,Fa),Te(t,Ea(e,n))},Wx=(t,e,n)=>Zu(e,n,Xe(t)),Qu=(t,e,n,s)=>{try{wu(e,Xe(t),n)}catch(r){s?.(r),console.error("Caught error while handling a Yjs update",r)}},Kx=(t,e)=>{z(t,Xu),Te(t,e)},Gx=Qu,Jx=(t,e,n,s,r)=>{const i=Y(t);switch(i){case Yu:Wx(t,e,n);break;case Fa:Qu(t,n,s,r);break;case Xu:Gx(t,n,s,r);break;default:throw new Error("Unknown message type")}return i},Yx=0,Xx=(t,e,n)=>{Y(t)===Yx&&n(e,Ze(t))},lo=3e4;class Zx extends Td{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const n=wn();this.getLocalState()!==null&&lo/2<=n-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const s=[];this.meta.forEach((r,i)=>{i!==this.clientID&&lo<=n-r.lastUpdated&&this.states.has(i)&&s.push(i)}),s.length>0&&Ia(this,s,"timeout")},Nt(lo/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:wn()});const a=[],c=[],l=[],d=[];e===null?d.push(n):i==null?e!=null&&a.push(n):(c.push(n),ns(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 Ia=(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:wn()})}s.push(i)}}s.length>0&&(t.emit("change",[{added:[],updated:[],removed:s},n]),t.emit("update",[{added:[],updated:[],removed:s},n]))},as=(t,e,n=t.states)=>{const s=e.length,r=Re();z(r,s);for(let i=0;i<s;i++){const a=e[i],c=n.get(a)||null,l=t.meta.get(a).clock;z(r,a),z(r,l),nn(r,JSON.stringify(c))}return xe(r)},Qx=(t,e,n)=>{const s=bn(e),r=wn(),i=[],a=[],c=[],l=[],d=Y(s);for(let f=0;f<d;f++){const u=Y(s);let p=Y(s);const m=JSON.parse(Ze(s)),g=t.meta.get(u),w=t.states.get(u),b=g===void 0?0:g.clock;(b<p||b===p&&m===null&&t.states.has(u))&&(m===null?u===t.clientID&&t.getLocalState()!=null?p++:t.states.delete(u):t.states.set(u,m),t.meta.set(u,{clock:p,lastUpdated:r}),g===void 0&&m!==null?i.push(u):g!==void 0&&m===null?l.push(u):m!==null&&(ns(m,w)||c.push(u),a.push(u)))}(i.length>0||c.length>0||l.length>0)&&t.emit("change",[{added:i,updated:c,removed:l},n]),(i.length>0||a.length>0||l.length>0)&&t.emit("update",[{added:i,updated:a,removed:l},n])},eb=t=>iy(t,(e,n)=>`${encodeURIComponent(n)}=${encodeURIComponent(e)}`).join("&"),Dn=0,eh=3,cs=1,tb=2,hr=[];hr[Dn]=(t,e,n,s,r)=>{z(t,Dn);const i=Jx(e,t,n.doc,n);s&&i===Fa&&!n.synced&&(n.synced=!0)};hr[eh]=(t,e,n,s,r)=>{z(t,cs),Te(t,as(n.awareness,Array.from(n.awareness.getStates().keys())))};hr[cs]=(t,e,n,s,r)=>{Qx(n.awareness,Xe(e),n)};hr[tb]=(t,e,n,s,r)=>{Xx(e,n.doc,(i,a)=>nb(n,a))};const gl=3e4,nb=(t,e)=>console.warn(`Permission denied to access ${t.url}.
|
|
12
|
+
${e}`),th=(t,e,n)=>{const s=bn(e),r=Re(),i=Y(s),a=t.messageHandlers[i];return a?a(r,s,t,n,i):console.error("Unable to compute message"),r},Vo=(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,Ia(t.awareness,Array.from(t.awareness.getStates().keys()).filter(s=>s!==t.doc.clientID),t),t.emit("status",[{status:"disconnected"}])):t.wsUnsuccessfulReconnects++,setTimeout(nh,ca(bg(2,t.wsUnsuccessfulReconnects)*100,t.maxBackoffTime),t))},nh=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=wn();const s=th(t,new Uint8Array(n.data),!0);la(s)>1&&e.send(xe(s))},e.onerror=n=>{t.emit("connection-error",[n,t])},e.onclose=n=>{Vo(t,e,n)},e.onopen=()=>{t.wsLastMessageReceived=wn(),t.wsconnecting=!1,t.wsconnected=!0,t.wsUnsuccessfulReconnects=0,t.emit("status",[{status:"connected"}]);const n=Re();if(z(n,Dn),hi(n,t.doc),e.send(xe(n)),t.awareness.getLocalState()!==null){const s=Re();z(s,cs),Te(s,as(t.awareness,[t.doc.clientID])),e.send(xe(s))}},t.emit("status",[{status:"connecting"}])}},uo=(t,e)=>{const n=t.ws;t.wsconnected&&n&&n.readyState===n.OPEN&&n.send(e),t.bcconnected&&Zn(t.bcChannel,e,t)};class sb extends aa{constructor(e,n,s,{connect:r=!0,awareness:i=new Zx(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=hr.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=Re();z(p,Dn),hi(p,s),this.ws.send(xe(p))}},d)),this._bcSubscriber=(p,m)=>{if(m!==this){const g=th(this,new Uint8Array(p),!1);la(g)>1&&Zn(this.bcChannel,xe(g),this)}},this._updateHandler=(p,m)=>{if(m!==this){const g=Re();z(g,Dn),Kx(g,p),uo(this,xe(g))}},this.doc.on("update",this._updateHandler),this._awarenessUpdateHandler=({added:p,updated:m,removed:g},w)=>{const b=p.concat(m).concat(g),v=Re();z(v,cs),Te(v,as(i,b)),uo(this,xe(v))},this._exitHandler=()=>{Ia(this.awareness,[s.clientID],"app closed")},xn&&typeof process<"u"&&process.on("exit",this._exitHandler),i.on("update",this._awarenessUpdateHandler),this._checkInterval=setInterval(()=>{this.wsconnected&&gl<wn()-this.wsLastMessageReceived&&Vo(this,this.ws,null)},gl/10),r&&this.connect()}get url(){const e=eb(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(),xn&&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||(Hx(this.bcChannel,this._bcSubscriber),this.bcconnected=!0);const e=Re();z(e,Dn),hi(e,this.doc),Zn(this.bcChannel,xe(e),this);const n=Re();z(n,Dn),Zu(n,this.doc),Zn(this.bcChannel,xe(n),this);const s=Re();z(s,eh),Zn(this.bcChannel,xe(s),this);const r=Re();z(r,cs),Te(r,as(this.awareness,[this.doc.clientID])),Zn(this.bcChannel,xe(r),this)}disconnectBc(){const e=Re();z(e,cs),Te(e,as(this.awareness,[this.doc.clientID],new Map)),uo(this,xe(e)),this.bcconnected&&(qx(this.bcChannel,this._bcSubscriber),this.bcconnected=!1)}disconnect(){this.shouldConnect=!1,this.disconnectBc(),this.ws!==null&&Vo(this,this.ws,null)}connect(){this.shouldConnect=!0,!this.wsconnected&&this.ws===null&&(nh(this),this.connectBc())}}const Fn=t=>ms((e,n)=>{t.onerror=s=>n(new Error(s.target.error)),t.onsuccess=s=>e(s.target.result)}),rb=(t,e)=>ms((n,s)=>{const r=indexedDB.open(t);r.onupgradeneeded=i=>e(i.target.result),r.onerror=i=>s(Ot(i.target.error)),r.onsuccess=i=>{const a=i.target.result;a.onversionchange=()=>{a.close()},n(a)}}),ib=t=>Fn(indexedDB.deleteDatabase(t)),ob=(t,e)=>e.forEach(n=>t.createObjectStore.apply(t,n)),$s=(t,e,n="readwrite")=>{const s=t.transaction(e,n);return e.map(r=>pb(s,r))},sh=(t,e)=>Fn(t.count(e)),ab=(t,e)=>Fn(t.get(e)),rh=(t,e)=>Fn(t.delete(e)),cb=(t,e,n)=>Fn(t.put(e,n)),Ho=(t,e)=>Fn(t.add(e)),lb=(t,e,n)=>Fn(t.getAll(e,n)),db=(t,e,n)=>{let s=null;return fb(t,e,r=>(s=r,!1),n).then(()=>s)},ub=(t,e=null)=>db(t,e,"prev"),hb=(t,e)=>ms((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()}}),fb=(t,e,n,s="next")=>hb(t.openKeyCursor(e,s),r=>n(r.key)),pb=(t,e)=>t.objectStore(e),mb=(t,e)=>IDBKeyRange.upperBound(t,e),gb=(t,e)=>IDBKeyRange.lowerBound(t,e),ho="custom",ih="updates",oh=500,ah=(t,e=()=>{},n=()=>{})=>{const[s]=$s(t.db,[ih]);return lb(s,gb(t._dbref,!1)).then(r=>{t._destroyed||(e(s),ye(t.doc,()=>{r.forEach(i=>wu(t.doc,i))},t,!1),n(s))}).then(()=>ub(s).then(r=>{t._dbref=r+1})).then(()=>sh(s).then(r=>{t._dbsize=r})).then(()=>s)},yb=(t,e=!0)=>ah(t).then(n=>{(e||t._dbsize>=oh)&&Ho(n,Ea(t.doc)).then(()=>rh(n,mb(t._dbref,!0))).then(()=>sh(n).then(s=>{t._dbsize=s}))});class wb extends Td{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=rb(e,s=>ob(s,[["updates",{autoIncrement:!0}],["custom"]])),this.whenSynced=ms(s=>this.on("synced",()=>s(this))),this._db.then(s=>{this.db=s,ah(this,a=>Ho(a,Ea(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]=$s(this.db,[ih]);Ho(i,s),++this._dbsize>=oh&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{yb(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(()=>{ib(this.name)})}get(e){return this._db.then(n=>{const[s]=$s(n,[ho],"readonly");return ab(s,e)})}set(e,n){return this._db.then(s=>{const[r]=$s(s,[ho]);return cb(r,n,e)})}del(e){return this._db.then(n=>{const[s]=$s(n,[ho]);return rh(s,e)})}}const yl=[["#1677c8","#1677c833"],["#d65745","#d6574533"],["#16866a","#16866a33"],["#9a58b5","#9a58b533"],["#d27b18","#d27b1833"],["#3f7d20","#3f7d2033"],["#be3e7b","#be3e7b33"],["#4964c6","#4964c633"],["#8a6a14","#8a6a1433"],["#087f8c","#087f8c33"]],wl=4,xl=5,xb=6,bb=7,vb=8,Sb=2;function Cb(t){if(!t||typeof t!="object")return null;const e=t,n=e.requestedBy;return typeof e.mainFile!="string"||typeof e.runId!="string"||!["queued","running","succeeded","failed","cleaned"].includes(e.status??"")||e.status==="cleaned"&&e.cleanMode!=="cache"&&e.cleanMode!=="artifacts"||e.stale!==void 0&&typeof e.stale!="boolean"||typeof e.updatedAt!="string"||!n||typeof n.id!="string"||typeof n.username!="string"||typeof n.name!="string"?null:e}function bl(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[n,s]of Object.entries(t)){const r=Cb(s);r&&r.mainFile===n&&(e[n]=r)}return e}class jb{constructor(e,n){this.projectId=e,this.user=n;const s=window.location.protocol==="https:"?"wss:":"ws:";this.persistence=new wb(`texlite:${n.id}:${e}`,this.doc),this.persistence.on("synced",()=>{this.localDraftReady=!0;for(const i of this.draftListeners)i()}),this.provider=new sb(`${s}//${window.location.host}/api/collaboration`,e,this.doc,{connect:!1,disableBc:!0,maxBackoffTime:2500}),this.awareness=this.provider.awareness;const r=this.doc.getMap("texlite:meta");this.metaObserver=(i,a)=>{a.origin===this.provider&&i.keysChanged.has("compileStates")&&(this.authoritativeCompileStates=null,this.notifyCompileStateListeners())},r.observe(this.metaObserver),this.provider.messageHandlers[wl]=(i,a)=>{const c=Ze(a),l=this.flushRequests.get(c);if(!l)return;const d=Y(a)===1,f=Y(a),u=Ze(a),p=Y(a),m=[];for(let g=0;g<p;g++)m.push(Ze(a));if(window.clearTimeout(l.timer),this.flushRequests.delete(c),d)l.resolve({revision:f,persistedAt:u,ok:!0,failedPaths:[]});else{const g=Object.assign(new Error(m.length?`保存失败:${m.join(", ")}`:"源码保存到服务器磁盘失败"),{failedPaths:m});l.reject(g)}},this.provider.messageHandlers[xl]=(i,a)=>{const c=Ze(a),l=this.epochStorageKey(),d=kb(l);if(this.epoch&&this.epoch!==c||d&&d!==c){this.provider.disconnect(),this.rejectFlushes(new Error("Collaboration state changed"));const g=/^([0-9]+):/.exec(c)?.[1]??null,w=d?/^([0-9]+):/.exec(d)?.[1]??null:null,b=c.endsWith(":reload")||g!==null&&g!==w,v=()=>{vl(l,c.replace(/:reload$/,"")),window.location.reload()};b?v():this.persistence.clearData().then(v);return}this.epoch=c,vl(l,c);const f=this.provider.ws;if(!f||f.readyState!==WebSocket.OPEN)return;const u=Re();z(u,xl),nn(u,c),z(u,Sb),f.send(xe(u));const p=Re();z(p,0),hi(p,this.doc),f.send(xe(p));const m=Re();z(m,1),Te(m,as(this.awareness,[this.doc.clientID])),f.send(xe(m))},this.provider.messageHandlers[bb]=(i,a)=>{const c=Ze(a),l=Ze(a);if(c!==this.user.id)return;if(l==="revoked"){this.rejectFlushes(new Error("Project access revoked")),this.provider.disconnect();for(const f of this.permissionListeners)f("revoked");return}if(l!=="read"&&l!=="edit"&&l!=="owner")return;const d=this.permission;this.setPermission(l,!0),d!==l&&l==="read"&&this.persistence.clearData().finally(()=>window.location.reload())},this.provider.messageHandlers[xb]=(i,a)=>{Ze(a)},this.provider.messageHandlers[vb]=(i,a)=>{let c={};try{c=bl(JSON.parse(Ze(a)))}catch{}this.authoritativeCompileStates=c,this.notifyCompileStateListeners()},this.provider.on("status",({status:i})=>{i==="disconnected"&&(this.authoritativeCompileStates=null,this.notifyCompileStateListeners(),this.rejectFlushes(new Error("Collaboration connection closed")))}),this.updateLocalAwareness()}projectId;user;doc=new Ln;provider;awareness;persistence;permission="read";activeFile="";epoch=null;destroyed=!1;localDraftReady=!1;draftListeners=new Set;permissionListeners=new Set;compileStateListeners=new Set;flushRequests=new Map;undoManagers=new Map;authoritativeCompileStates=null;metaObserver;connect(){this.destroyed||(this.provider.connect(),this.updateLocalAwareness())}getText(e){return this.doc.getText(`source:${e}`)}getUndoManager(e){const n=this.undoManagers.get(e);if(n)return n;const s=new Kw(this.getText(e));return this.undoManagers.set(e,s),s}applyTextEdits(e,n){if(this.permission==="read")throw new Error("Read-only collaborators cannot edit source files");const s=this.getText(e);let r=0;for(const i of n){if(!Number.isInteger(i.from)||!Number.isInteger(i.to)||i.from<r||i.to<i.from||i.to>s.length)throw new RangeError("Invalid collaborative text edits");r=i.to}this.doc.transact(()=>{for(let i=n.length-1;i>=0;i-=1){const a=n[i];a.to>a.from&&s.delete(a.from,a.to-a.from),a.replacement&&s.insert(a.from,a.replacement)}})}get meta(){return this.doc.getMap("texlite:meta")}compileStates(){return this.authoritativeCompileStates??bl(this.meta.get("compileStates"))}onCompileStates(e){return this.compileStateListeners.add(e),()=>this.compileStateListeners.delete(e)}get synced(){return this.provider.synced}get connected(){return this.provider.wsconnected}get draftReady(){return this.localDraftReady}get currentPermission(){return this.permission}onDraftReady(e){return this.draftListeners.add(e),this.localDraftReady&&e(),()=>this.draftListeners.delete(e)}onPermissionChanged(e){return this.permissionListeners.add(e),()=>this.permissionListeners.delete(e)}setPermission(e,n=!1){if(this.permission=e,e==="read"&&this.destroyUndoManagers(),this.updateLocalAwareness(),n)for(const s of this.permissionListeners)s(e)}setActiveFile(e){this.activeFile!==e&&(this.activeFile=e,this.awareness.setLocalStateField("cursor",null),this.updateLocalAwareness())}sessions(){const e=[];return this.awareness.getStates().forEach((n,s)=>{const r=n?.user;!r||typeof r.id!="string"||typeof r.name!="string"||e.push({clientId:s,userId:r.id,username:typeof r.username=="string"?r.username:r.name,name:r.name,color:typeof r.color=="string"?r.color:"#1677c8",colorLight:typeof r.colorLight=="string"?r.colorLight:"#1677c833",permission:r.permission==="owner"||r.permission==="edit"?r.permission:"read",filePath:typeof n.filePath=="string"?n.filePath:"",editing:!!n.cursor,local:s===this.doc.clientID})}),e.sort((n,s)=>Number(s.local)-Number(n.local)||n.name.localeCompare(s.name))}flush(){const e=this.provider.ws;if(!this.provider.synced||!e||e.readyState!==WebSocket.OPEN)return Promise.reject(new Error("Collaboration connection is unavailable"));const n=crypto.randomUUID(),s=Re();return z(s,wl),nn(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(xe(s))})}reconnect(){this.destroyed||(this.rejectFlushes(new Error("Collaboration connection reset")),this.provider.disconnect(),this.provider.connect(),this.updateLocalAwareness())}destroy(){this.destroyed=!0,this.rejectFlushes(new Error("Collaboration connection closed")),this.provider.destroy(),this.persistence.destroy(),this.draftListeners.clear(),this.compileStateListeners.clear(),this.meta.unobserve(this.metaObserver),this.destroyUndoManagers(),this.doc.destroy()}destroyUndoManagers(){for(const e of this.undoManagers.values())e.destroy();this.undoManagers.clear()}notifyCompileStateListeners(){for(const e of this.compileStateListeners)e()}rejectFlushes(e){for(const n of this.flushRequests.values())window.clearTimeout(n.timer),n.reject(e);this.flushRequests.clear()}updateLocalAwareness(){const[e,n]=yl[Math.abs(this.doc.clientID)%yl.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 kb(t){try{return window.localStorage.getItem(t)}catch{return null}}function vl(t,e){try{window.localStorage.setItem(t,e)}catch{}}function Eb(t,e){return Array.from(t.trim()||e.trim()||"?")[0]?.toLocaleUpperCase()??"?"}function Db({sessions:t,status:e}){const{t:n}=Le(),[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:[Eb(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 Tb({value:t,onChange:e}){const{t:n}=Le(),[s,r]=h.useState(!1),i=h.useRef(null),a=[{value:"editor-pdf",icon:Lc},{value:"editor-only",icon:Gm},{value:"pdf-only",icon:Jm}];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(Lc,{size:15}),o.jsxs("span",{children:[o.jsx("small",{children:n("editor.layout.label")}),n(`editor.layout.${t}.name`)]}),o.jsx(vd,{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(Lm,{size:16})]},c.value)})]})]})}function Nb({comment:t,currentUserId:e,onFocus:n,onToggle:s,onReply:r,onEdit:i,onDelete:a,onEditReply:c,onDeleteReply:l}){const{t:d}=Le(),[f,u]=h.useState(!1),[p,m]=h.useState(""),[g,w]=h.useState(!1),[b,v]=h.useState(t.content),[k,P]=h.useState(!1),[N,O]=h.useState(null),[W,E]=h.useState(""),[G,C]=h.useState(null),V=async j=>{j.preventDefault(),p.trim()&&await r(p)&&(m(""),u(!1))},Z=async j=>{j.preventDefault(),b.trim()&&await i(b)&&w(!1)},R=async j=>{j.preventDefault(),!(!N||!W.trim())&&await c(N,W)&&O(null)},_=t.authorUsername,L=j=>new Date(j).toLocaleString(pe.resolvedLanguage);return o.jsxs(o.Fragment,{children:[o.jsxs("article",{className:`comment-thread${t.resolved?" resolved":""}${t.orphaned?" orphaned":""}`,onClick:()=>{window.getSelection()?.toString()||n()},children:[o.jsxs("header",{className:"comment-header",children:[o.jsxs("span",{className:"comment-author",children:[o.jsx("strong",{children:t.authorDisplayName??_??d("editor.deletedUser")}),_&&o.jsxs("small",{children:["@",_]})]}),o.jsxs("span",{className:"comment-times",children:[o.jsx("time",{dateTime:t.createdAt,title:new Date(t.createdAt).toISOString(),children:L(t.createdAt)}),t.editedAt&&o.jsx("small",{children:d("editor.editedAt",{time:L(t.editedAt)})})]})]}),o.jsx("div",{className:"comment-location",children:t.orphaned?d("editor.orphaned"):d("editor.line",{line:t.startLine})}),t.selectedText&&o.jsx("blockquote",{className:"comment-selected-text",children:t.selectedText}),g?o.jsxs("form",{className:"comment-reply-form comment-edit-form",onSubmit:j=>{Z(j)},onClick:j=>j.stopPropagation(),children:[o.jsx("textarea",{autoFocus:!0,rows:4,value:b,onChange:j=>v(j.target.value)}),o.jsxs("div",{children:[o.jsx("button",{type:"button",onClick:()=>w(!1),children:d("common.cancel")}),o.jsxs("button",{className:"primary",type:"submit",disabled:!b.trim(),children:[o.jsx(Jr,{size:13}),d("editor.saveChanges")]})]})]}):o.jsx("p",{className:"comment-content",children:t.content}),t.replies.length>0&&o.jsx("div",{className:"comment-replies",children:t.replies.map(j=>o.jsxs("div",{className:"comment-reply",children:[o.jsxs("header",{children:[o.jsxs("span",{className:"comment-author",children:[o.jsx("strong",{children:j.authorDisplayName??j.authorUsername??d("editor.deletedUser")}),j.authorUsername&&o.jsxs("small",{children:["@",j.authorUsername]})]}),o.jsxs("span",{className:"comment-times",children:[o.jsx("time",{dateTime:j.createdAt,title:new Date(j.createdAt).toISOString(),children:L(j.createdAt)}),j.editedAt&&o.jsx("small",{children:d("editor.editedAt",{time:L(j.editedAt)})})]})]}),N===j.id?o.jsxs("form",{className:"comment-reply-form comment-edit-form",onSubmit:H=>{R(H)},onClick:H=>H.stopPropagation(),children:[o.jsx("textarea",{autoFocus:!0,rows:3,value:W,onChange:H=>E(H.target.value)}),o.jsxs("div",{children:[o.jsx("button",{type:"button",onClick:()=>O(null),children:d("common.cancel")}),o.jsxs("button",{className:"primary",type:"submit",disabled:!W.trim(),children:[o.jsx(Jr,{size:13}),d("editor.saveChanges")]})]})]}):o.jsx("p",{className:"comment-content",children:j.content}),j.authorId===e&&N!==j.id&&o.jsxs("div",{className:"comment-owner-actions",children:[o.jsx("button",{title:d("editor.editReply"),"aria-label":d("editor.editReply"),onClick:H=>{H.stopPropagation(),O(j.id),E(j.content)},children:o.jsx(Oo,{size:12})}),o.jsx("button",{className:"danger-text",title:d("editor.deleteReply"),"aria-label":d("editor.deleteReply"),onClick:H=>{H.stopPropagation(),C(j.id)},children:o.jsx(gn,{size:12})})]})]},j.id))}),o.jsxs("div",{className:"comment-actions",children:[o.jsxs("button",{className:"resolve",onClick:j=>{j.stopPropagation(),s()},children:[t.resolved?o.jsx(Qm,{size:13}):o.jsx(Im,{size:13}),t.resolved?d("editor.reopen"):d("editor.resolve")]}),o.jsxs("button",{className:"reply-action",onClick:j=>{j.stopPropagation(),u(H=>!H)},children:[o.jsx(Zm,{size:13}),d("editor.reply")]}),t.authorId===e&&!g&&o.jsxs("span",{className:"comment-owner-actions",children:[o.jsx("button",{title:d("editor.editComment"),"aria-label":d("editor.editComment"),onClick:j=>{j.stopPropagation(),v(t.content),w(!0)},children:o.jsx(Oo,{size:13})}),o.jsx("button",{className:"danger-text",title:d("editor.deleteComment"),"aria-label":d("editor.deleteComment"),onClick:j=>{j.stopPropagation(),P(!0)},children:o.jsx(gn,{size:13})})]})]}),f&&o.jsxs("form",{className:"comment-reply-form",onSubmit:j=>{V(j)},onClick:j=>j.stopPropagation(),children:[o.jsx("textarea",{autoFocus:!0,rows:3,value:p,placeholder:d("editor.replyPlaceholder"),onChange:j=>m(j.target.value)}),o.jsxs("div",{children:[o.jsx("button",{type:"button",onClick:()=>{u(!1),m("")},children:d("common.cancel")}),o.jsxs("button",{className:"primary",type:"submit",disabled:!p.trim(),children:[o.jsx(tg,{size:13}),d("editor.sendReply")]})]})]})]}),o.jsx(us,{open:k,title:d("editor.deleteCommentTitle"),description:d("editor.deleteCommentDescription",{count:t.replies.length}),confirmLabel:d("common.delete"),danger:!0,onCancel:()=>P(!1),onConfirm:()=>{a().then(j=>{j&&P(!1)})}}),o.jsx(us,{open:!!G,title:d("editor.deleteReplyTitle"),description:d("editor.deleteReplyDescription"),confirmLabel:d("common.delete"),danger:!0,onCancel:()=>C(null),onConfirm:()=>{G&&l(G).then(j=>{j&&C(null)})}})]})}function Ob({open:t,onOpenChange:e,project:n,projectId:s}){const{t:r}=Le(),[i,a]=h.useState([]),[c,l]=h.useState([]),[d,f]=h.useState(""),[u,p]=h.useState("read"),[m,g]=h.useState(null),[w,b]=h.useState(""),v=n.permission==="owner",k=async()=>{try{const[E,G]=await Promise.all([F(`/api/projects/${s}/members`),F("/api/users")]);a(E.members),l(G.users.filter(C=>C.id!==n.ownerId))}catch(E){b(q(E))}};h.useEffect(()=>{t&&k()},[t,s]);const P=async()=>{if(d)try{await F(`/api/projects/${s}/members/${d}`,{method:"PUT",body:JSON.stringify({permission:u})}),f(""),p("read"),await k()}catch(E){b(q(E))}},N=async(E,G)=>{try{await F(`/api/projects/${s}/members/${E.id}`,{method:"PUT",body:JSON.stringify({permission:G})}),await k()}catch(C){b(q(C))}},O=async()=>{if(m)try{await F(`/api/projects/${s}/members/${m.id}`,{method:"DELETE"}),g(null),await k()}catch(E){b(q(E))}},W=c.filter(E=>!i.some(G=>G.id===E.id));return o.jsxs(o.Fragment,{children:[o.jsx(He,{open:t,wide:!0,title:r("projectSettings.share"),description:r("projectSettings.shareDescription"),onOpenChange:e,footer:o.jsx("button",{onClick:()=>e(!1),children:r("common.close")}),children:o.jsxs("div",{className:"share-dialog",children:[w&&o.jsx("p",{className:"error",children:w}),o.jsxs("div",{className:"share-owner",children:[o.jsx(Ks,{size:17}),o.jsxs("span",{children:[o.jsx("small",{children:r("projects.owner")}),o.jsx("strong",{children:n.ownerDisplayName??n.ownerUsername})]})]}),v&&o.jsxs("div",{className:"share-add",children:[o.jsxs("label",{className:"form-field",children:[r("common.user"),o.jsxs("select",{value:d,onChange:E=>f(E.target.value),children:[o.jsx("option",{value:"",children:r("projectSettings.chooseUser")}),W.map(E=>o.jsx("option",{value:E.id,children:E.displayName??E.username},E.id))]})]}),o.jsxs("label",{className:"form-field",children:[r("common.permission"),o.jsxs("select",{value:u,onChange:E=>p(E.target.value),children:[o.jsx("option",{value:"read",children:r("common.readOnly")}),o.jsx("option",{value:"edit",children:r("common.readWrite")})]})]}),o.jsxs("button",{className:"primary icon-button",disabled:!d,onClick:()=>{P()},children:[o.jsx(Ed,{size:15}),r("projectSettings.addMember")]})]}),o.jsxs("div",{className:"shared-members-heading",children:[o.jsx("strong",{children:r("projectSettings.members")}),o.jsx("span",{children:i.length})]}),o.jsxs("div",{className:"shared-members",children:[i.map(E=>o.jsxs("div",{className:"shared-member",children:[o.jsxs("span",{className:"member-identity",children:[o.jsx("span",{className:"member-avatar",children:(E.displayName??E.username).slice(0,1).toLocaleUpperCase()}),o.jsxs("span",{children:[o.jsx("strong",{children:E.displayName??E.username}),o.jsxs("small",{children:["@",E.username]})]})]}),o.jsxs("span",{className:"member-controls",children:[o.jsxs("select",{"aria-label":r("common.permission"),disabled:!v,value:E.permission,onChange:G=>{N(E,G.target.value)},children:[o.jsx("option",{value:"read",children:r("common.readOnly")}),o.jsx("option",{value:"edit",children:r("common.readWrite")})]}),v&&o.jsx("button",{className:"icon-only danger-text",title:r("common.remove"),"aria-label":r("common.remove"),onClick:()=>g(E),children:o.jsx(gn,{size:15})})]})]},E.id)),i.length===0&&o.jsxs("div",{className:"share-empty",children:[o.jsx(Ks,{size:24}),o.jsx("span",{children:r("projectSettings.noMembers")})]})]})]})}),o.jsx(us,{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 Pb({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}=Le(),[g,w]=h.useState(t.engine),[b,v]=h.useState(""),[k,P]=h.useState(t.name),[N,O]=h.useState(t.mainFile),[W,E]=h.useState(""),[G,C]=h.useState(""),[V,Z]=h.useState(""),[R,_]=h.useState("appearance"),[L,j]=h.useState(a),H=t.permission==="owner",he=t.permission!=="read",Ce=t.permission!=="read";h.useEffect(()=>j(a),[a]),h.useEffect(()=>{if(!t.latexmkrc)return v("");F(`/api/projects/${e}/file?path=${encodeURIComponent(t.latexmkrc)}`).then(({content:D})=>v(D)).catch(D=>E(q(D)))},[t.latexmkrc]);const de=s.filter(D=>D.type==="file"&&/\.tex$/i.test(D.path)).map(D=>D.path),we=[...new Set(t.mainFile&&t.mainFile.toLowerCase().endsWith(".tex")?[...de,t.mainFile]:de)].sort((D,re)=>D.localeCompare(re)),J=async()=>{try{const D=b.trim()&&n.allowProjectLatexmkrc!==!1?".latexmkrc":null;D&&await F(`/api/projects/${e}/file`,{method:"PUT",body:JSON.stringify({path:D,content:b})});const re=await F(`/api/projects/${e}`,{method:"PATCH",body:JSON.stringify({name:k,mainFile:N,engine:g,latexmkrc:D})});p(re.project)}catch(D){E(q(D))}},K=()=>c(L),me=async()=>{const D=G.trim();if(D)try{const re=await F(`/api/projects/${e}/dictionary`,{method:"POST",body:JSON.stringify({word:D})});i(re.words),C(""),Z("")}catch(re){Z(q(re))}},ue=async D=>{try{const re=await F(`/api/projects/${e}/dictionary/${encodeURIComponent(D)}`,{method:"DELETE"});i(re.words),Z("")}catch(re){Z(q(re))}};return o.jsxs("div",{className:"settings padded",children:[W&&o.jsx("p",{className:"error",children:W}),o.jsxs("div",{className:"settings-tabs",role:"tablist","aria-label":m("common.settings"),children:[o.jsxs("button",{id:"settings-tab-appearance",type:"button",role:"tab","aria-selected":R==="appearance","aria-controls":"settings-panel-appearance",className:`settings-tab${R==="appearance"?" active":""}`,onClick:()=>_("appearance"),children:[o.jsx(Mc,{size:15}),m("projectSettings.editorTab")]}),o.jsxs("button",{id:"settings-tab-compiler",type:"button",role:"tab","aria-selected":R==="compiler","aria-controls":"settings-panel-compiler",className:`settings-tab${R==="compiler"?" active":""}`,onClick:()=>_("compiler"),children:[o.jsx(Ur,{size:15}),m("projectSettings.compilerTab")]})]}),R==="appearance"?o.jsxs("section",{id:"settings-panel-appearance",role:"tabpanel","aria-labelledby":"settings-tab-appearance",children:[o.jsxs("div",{className:"settings-section-title",children:[o.jsx(Mc,{size:15}),o.jsx("strong",{children:m("projectSettings.editorAppearance")})]}),o.jsx("p",{className:"settings-description appearance-description",children:m("projectSettings.editorAppearanceDescription")}),o.jsxs("label",{children:[m("projectSettings.fontFamily"),o.jsx("select",{value:L.font,onChange:D=>j({...L,font:D.target.value}),children:Zr.map(D=>o.jsx("option",{value:D.id,children:m(D.labelKey)},D.id))})]}),o.jsxs("label",{children:[m("projectSettings.fontSize"),o.jsx("select",{value:L.fontSize,onChange:D=>j({...L,fontSize:Number(D.target.value)}),children:[12,13,14,15,16,18,20].map(D=>o.jsxs("option",{value:D,children:[D," px"]},D))})]}),o.jsxs("label",{children:[m("projectSettings.lineHeight"),o.jsxs("select",{value:L.lineHeight,onChange:D=>j({...L,lineHeight:Number(D.target.value)}),children:[o.jsx("option",{value:1.45,children:m("projectSettings.lineHeightCompact")}),o.jsx("option",{value:1.65,children:m("projectSettings.lineHeightNormal")}),o.jsx("option",{value:1.85,children:m("projectSettings.lineHeightRelaxed")})]})]}),o.jsxs("label",{className:"editor-checkbox",children:[o.jsx("input",{type:"checkbox",checked:L.lineWrapping,onChange:D=>j({...L,lineWrapping:D.target.checked})}),o.jsx(rg,{size:15}),o.jsx("span",{children:m("projectSettings.lineWrapping")})]}),o.jsxs("label",{className:"editor-checkbox",children:[o.jsx("input",{type:"checkbox",checked:L.spellCheck,onChange:D=>j({...L,spellCheck:D.target.checked})}),o.jsx("span",{children:m("projectSettings.spellCheck")})]}),o.jsxs("p",{className:"field-hint",children:[m("projectSettings.writingCheckDescription")," ",o.jsx("a",{href:"https://writewithharper.com/docs/harperjs/introduction",target:"_blank",rel:"noreferrer",children:"Harper.js"})]}),o.jsxs("label",{className:"editor-checkbox",children:[o.jsx("input",{type:"checkbox",checked:L.vimMode,onChange:D=>j({...L,vimMode:D.target.checked})}),o.jsx("span",{children:m("projectSettings.vimMode")})]}),o.jsxs("p",{className:"field-hint",children:[m("projectSettings.vimModeDescription")," ",o.jsx("a",{href:"https://replit-codemirror-vim.mintlify.app/",target:"_blank",rel:"noreferrer",children:m("projectSettings.vimHelp")})]}),o.jsxs("label",{className:"editor-checkbox",children:[o.jsx("input",{type:"checkbox",checked:L.openFilesInTabs,onChange:D=>j({...L,openFilesInTabs:D.target.checked})}),o.jsx(Ym,{size:15}),o.jsx("span",{children:m("projectSettings.openFilesInTabs")})]}),o.jsx("p",{className:"field-hint",children:m("projectSettings.openFilesInTabsDescription")}),o.jsxs("label",{className:"editor-checkbox",children:[o.jsx("input",{type:"checkbox",disabled:!he,checked:L.formatOnCompile,onChange:D=>j({...L,formatOnCompile:D.target.checked})}),o.jsx(xd,{size:15}),o.jsx("span",{children:m("projectSettings.formatOnCompile")})]}),o.jsxs("p",{className:"field-hint",children:[m(he?"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(sg,{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(Am,{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(Sd,{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(sa,{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(Fm,{size:14})})]})]}),o.jsxs("div",{className:"settings-section-title",children:[o.jsx(Eo,{size:15}),o.jsx("strong",{children:m("projectSettings.dictionary")})]}),o.jsx("p",{className:"settings-description",children:m("projectSettings.dictionaryDescription")}),V&&o.jsx("p",{className:"error dictionary-error",children:V}),Ce&&o.jsxs("div",{className:"dictionary-add",children:[o.jsx("input",{value:G,placeholder:m("projectSettings.dictionaryPlaceholder"),onChange:D=>C(D.target.value),onKeyDown:D=>{D.key==="Enter"&&(D.preventDefault(),me())}}),o.jsx("button",{type:"button",disabled:!G.trim(),onClick:()=>{me()},children:m("projectSettings.addWord")})]}),o.jsxs("div",{className:"dictionary-words",children:[r.map(D=>o.jsxs("span",{className:"dictionary-word",children:[o.jsx("code",{children:D}),Ce&&o.jsx("button",{type:"button",title:m("common.delete"),"aria-label":`${m("common.delete")} ${D}`,onClick:()=>{ue(D)},children:o.jsx(Xr,{size:13})})]},D)),r.length===0&&o.jsx("span",{className:"dictionary-empty",children:m("projectSettings.dictionaryEmpty")})]}),o.jsx("div",{className:"settings-actions",children:o.jsxs("button",{className:"settings-save",onClick:K,children:[o.jsx(Jr,{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(Ur,{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(Ur,{size:15}),o.jsx("strong",{children:m("projectSettings.projectConfiguration")})]}),o.jsxs("label",{children:[m("projects.name"),o.jsx("input",{disabled:!H,value:k,onChange:D=>P(D.target.value)})]}),o.jsxs("label",{children:[m("projectSettings.mainFile"),o.jsx("select",{disabled:!H||we.length===0,value:N,onChange:D=>O(D.target.value),children:we.map(D=>o.jsx("option",{value:D,children:D},D))})]}),o.jsxs("label",{children:[m("projectSettings.engine"),o.jsx("select",{disabled:!H,value:g,onChange:D=>w(D.target.value),children:(n.allowedEngines??["pdflatex","xelatex","lualatex"]).map(D=>o.jsx("option",{children:D},D))})]}),o.jsxs("label",{children:[m("projectSettings.latexmkrc"),o.jsx("textarea",{className:"latexmkrc-editor",rows:10,spellCheck:!1,disabled:!H||n.allowProjectLatexmkrc===!1,value:b,placeholder:m("projectSettings.latexmkrcPlaceholder"),onChange:D=>v(D.target.value)})]}),o.jsx("div",{className:"settings-actions",children:H&&o.jsxs("button",{className:"settings-save",onClick:()=>{J()},children:[o.jsx(Jr,{size:15}),m("projectSettings.saveCompiler")]})})]})]})}function Sl({diagnostics:t,files:e,empty:n,tone:s,onJump:r}){const{t:i}=Le(),a=s==="error"?ra:hs;return t.length?o.jsx("div",{className:`compile-diagnostic-list compile-${s}`,children:t.map((c,l)=>{const d=Lb(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 fo({lines:t,empty:e,tone:n="log"}){const s=n==="error"?ra:n==="warning"?hs:Po;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 _b({projectId:t,mainFile:e,artifacts:n,preview:s,loading:r,onView:i}){const{t:a}=Le(),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(En,{size:14}),o.jsxs("span",{children:[o.jsx("strong",{children:l.path}),o.jsx("small",{children:Ab(l.size)})]})]}),o.jsx("a",{href:c(l.path),title:a("editor.downloadArtifact"),"aria-label":a("editor.downloadArtifact"),children:o.jsx(Ws,{size:14})})]},l.path))}),o.jsx("div",{className:"artifact-preview",children:r?o.jsxs("div",{className:"compile-empty",children:[o.jsx(Dt,{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(Ws,{size:13}),a("projects.download")]})]}),o.jsx("pre",{children:s.content})]}):o.jsxs("div",{className:"compile-empty",children:[o.jsx(En,{size:24}),o.jsx("span",{children:a("editor.selectArtifact")})]})})]}):o.jsxs("div",{className:"compile-empty",children:[o.jsx(kd,{size:26}),o.jsx("span",{children:a("editor.noArtifacts")})]})}function Rb({mainFile:t,disabled:e,cleaning:n,onCleanCache:s,onCleanArtifacts:r}){const{t:i}=Le();return o.jsxs("div",{className:"compile-clean-panel",children:[o.jsxs("div",{className:"compile-clean-intro",children:[o.jsx(hs,{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(Do,{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(Dt,{className:"spin",size:14}):o.jsx(Do,{size:14}),i("editor.cleanCache")]})]})]}),o.jsxs("article",{className:"danger",children:[o.jsx("div",{className:"compile-clean-action-icon",children:o.jsx(gn,{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(Dt,{className:"spin",size:14}):o.jsx(gn,{size:14}),i("editor.cleanArtifacts")]})]})]})]})]})}function Lb(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 Ab(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`}function Fb(t){return t instanceof Error&&t.name==="AbortError"}function Ib({projectId:t,activeFile:e,permission:n,revision:s,selection:r,save:i,onError:a,onAdded:c}){const[l,d]=h.useState([]),[f,u]=h.useState(null),[p,m]=h.useState(!1),[g,w]=h.useState(""),b=h.useRef(null),v=h.useRef(e),k=h.useRef(i),P=h.useRef(a),N=h.useRef(c);v.current=e,k.current=i,P.current=a,N.current=c;const O=async _=>{b.current?.abort();const L=new AbortController;b.current=L;try{const j=await F(`/api/projects/${t}/comments?path=${encodeURIComponent(_)}`,{signal:L.signal});v.current===_&&d(j.comments)}catch(j){!Fb(j)&&v.current===_&&d([])}finally{b.current===L&&(b.current=null)}};return h.useEffect(()=>{u(null)},[t,e]),h.useEffect(()=>(e?O(e):d([]),()=>{b.current?.abort(),b.current=null}),[t,e,s]),{comments:l,focusComment:f,setFocusComment:u,commentOpen:p,setCommentOpen:m,commentText:g,setCommentText:w,addComment:async()=>{if(!(!g.trim()||!e))try{if(n!=="read"&&!await k.current())return;await F(`/api/projects/${t}/comments`,{method:"POST",body:JSON.stringify({path:e,content:g,...r})}),await O(e),m(!1),w(""),N.current()}catch(_){P.current(q(_))}},toggleComment:async _=>{try{await F(`/api/projects/${t}/comments/${_.id}`,{method:"PATCH",body:JSON.stringify({resolved:!_.resolved})}),await O(e)}catch(L){P.current(q(L))}},replyToComment:async(_,L)=>{try{return await F(`/api/projects/${t}/comments/${_.id}/replies`,{method:"POST",body:JSON.stringify({content:L})}),await O(e),!0}catch(j){return P.current(q(j)),!1}},editComment:async(_,L)=>{try{return await F(`/api/projects/${t}/comments/${_.id}`,{method:"PATCH",body:JSON.stringify({content:L})}),await O(e),!0}catch(j){return P.current(q(j)),!1}},deleteComment:async _=>{try{return await F(`/api/projects/${t}/comments/${_.id}`,{method:"DELETE"}),await O(e),u(L=>L?.id===_.id?null:L),!0}catch(L){return P.current(q(L)),!1}},editCommentReply:async(_,L,j)=>{try{return await F(`/api/projects/${t}/comments/${_.id}/replies/${L}`,{method:"PATCH",body:JSON.stringify({content:j})}),await O(e),!0}catch(H){return P.current(q(H)),!1}},deleteCommentReply:async(_,L)=>{try{return await F(`/api/projects/${t}/comments/${_.id}/replies/${L}`,{method:"DELETE"}),await O(e),!0}catch(j){return P.current(q(j)),!1}}}}function Mb(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 $b(t,e,n,s,r,i){const[a]=h.useState(()=>new jb(t,e)),[c,l]=h.useState("connecting"),[d,f]=h.useState(!1),[u,p]=h.useState([]),[m,g]=h.useState(null),[w,b]=h.useState(null),[v,k]=h.useState(""),[P,N]=h.useState(""),[O,W]=h.useState(!1),[E,G]=h.useState(s),C=h.useRef(n),V=h.useRef(i);return C.current=n,V.current=i,h.useEffect(()=>{const R=a.compileStates();g(R[n]??null)},[n,a]),h.useEffect(()=>{const R=()=>p(a.sessions()),_=()=>{f(!1),p([]),g(null),b(null),k(""),N(""),V.current()},L=({status:K})=>{l(K),K!=="connected"&&_()},j=K=>{f(K),K||_()},H=()=>{l("disconnected"),_()},he=()=>{const K=a.meta.get("filesEvent");Mb(K)&&b(K);const me=a.meta.get("commentsRevision");typeof me=="string"&&k(me);const ue=a.meta.get("dictionaryRevision");typeof ue=="string"&&N(ue);const D=a.compileStates();g(D[C.current]??null)},Ce=()=>{const K=a.compileStates();g(K[C.current]??null)};a.awareness.on("change",R),a.provider.on("status",L),a.provider.on("sync",j),a.provider.on("connection-close",H),a.provider.on("connection-error",H),a.meta.observe(he);const de=a.onCompileStates(Ce),we=a.onDraftReady(()=>W(!0)),J=a.onPermissionChanged(K=>{if(K==="revoked"){l("disconnected"),f(!1),V.current();return}G(K)});return R(),he(),l(a.connected?"connected":"connecting"),f(a.synced),()=>{a.awareness.off("change",R),a.provider.off("status",L),a.provider.off("sync",j),a.provider.off("connection-close",H),a.provider.off("connection-error",H),a.meta.unobserve(he),de(),we(),J(),a.destroy()}},[a]),h.useEffect(()=>{r&&a.connect()},[a,r]),h.useEffect(()=>{a.setPermission(s),G(s)},[a,s]),{collaboration:a,status:c,synced:d,activeSessions:u,compileState:m,setCompileState:g,filesEvent:w,commentsRevision:v,dictionaryRevision:P,localDraftReady:O,permission:E,reconnect:()=>{l("connecting"),f(!1),p([]),g(null),a.reconnect()}}}function Jn(t){return t instanceof Error&&t.name==="AbortError"}function Ub({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}=Le(),[g,w]=h.useState(""),[b,v]=h.useState(!0),[k,P]=h.useState(null),[N,O]=h.useState(""),[W,E]=h.useState(null),[G,C]=h.useState(null),[V,Z]=h.useState([]),[R,_]=h.useState(null),[L,j]=h.useState(!1),[H,he]=h.useState(!1),[Ce,de]=h.useState(()=>new Set),[we,J]=h.useState(""),K=h.useRef(n),me=h.useRef(""),ue=h.useRef(null),D=h.useRef(null),re=h.useRef(null),te=h.useRef(new Set),je=h.useRef(new Map),Oe=h.useRef(null),Pe=h.useRef(()=>{}),oe=h.useRef({onSharedState:i,save:a,loadOutline:c,onPreviewTab:l,onError:d,onCompileStart:f,onCompileSuccess:u,onPdfChanged:p});K.current=n,oe.current={onSharedState:i,save:a,loadOutline:c,onPreviewTab:l,onError:d,onCompileStart:f,onCompileSuccess:u,onPdfChanged:p};const mt=B=>{Oe.current!==B&&(Oe.current=B,oe.current.onCompileSuccess())},gt=async(B,ee)=>{ee||(D.current?.abort(),D.current=new AbortController,ee=D.current.signal);try{const M=B?`?mainFile=${encodeURIComponent(B)}`:"",A=await F(`/api/projects/${t}/compile/artifacts${M}`,{signal:ee});K.current===B&&(Z(A.artifacts),_(null))}catch(M){!Jn(M)&&K.current===B&&(Z([]),_(null))}finally{D.current?.signal===ee&&(D.current=null)}};h.useEffect(()=>{if(ue.current?.abort(),!n){v(!1),w(""),P(null),O(""),E(null),C(null),Z([]),_(null),oe.current.onPdfChanged();return}const B=new AbortController;ue.current=B,v(!0),O(""),E(null),C(null),g&&n&&me.current===n||(w(""),P(null)),Z([]),_(null),oe.current.onPdfChanged();let M=null;const A=`?mainFile=${encodeURIComponent(n)}`,se=F(`/api/projects/${t}/compile/latest${A}`,{signal:B.signal});let ge=!1;const Ge=()=>{if(ge||B.signal.aborted||!n)return;ge=!0;const $=new AbortController;te.current.add($),gt(n,$.signal).finally(()=>{te.current.delete($)}),oe.current.loadOutline(B.signal,n).catch(()=>{})};return se.then($=>{B.signal.aborted||n&&$.mainFile!==K.current||(O($.latestRun?.log??""),E($.latestRun?.diagnostics??null),C($.latestRun?.status==="succeeded"||$.latestRun?.status==="failed"?$.latestRun.status:null),n&&$.latestRun?.requestedBy&&($.latestRun.status==="queued"||$.latestRun.status==="running")&&oe.current.onSharedState({mainFile:n,runId:$.latestRun.id,status:$.latestRun.status,requestedBy:$.latestRun.requestedBy,updatedAt:new Date().toISOString()}),$.pdfUrl&&(me.current=$.mainFile,w($.pdfUrl),P($.pdfCompiledAt),oe.current.onPreviewTab("pdf")))}).catch($=>{!Jn($)&&K.current===n&&oe.current.onError(q($))}).finally(()=>{ue.current===B&&(ue.current=null),B.signal.aborted||(v(!1),M=window.setTimeout(Ge,0))}),()=>{M!==null&&window.clearTimeout(M),B.abort(),re.current?.abort();for(const $ of te.current)$.abort();te.current.clear()}},[t,n]),h.useEffect(()=>{if(!(!r||r.mainFile!==n||r.status!=="cleaned"||!r.cleanMode)){ue.current?.abort(),D.current?.abort(),re.current?.abort();for(const B of te.current)B.abort();te.current.clear(),r.cleanMode==="artifacts"?(O(""),E(null),C(null),w(""),P(null),Z([]),_(null),oe.current.onPdfChanged(),oe.current.onPreviewTab("pdf"),J(m("editor.cleanArtifactsComplete"))):J(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 B=!1;ue.current?.abort(),re.current?.abort();const ee=new AbortController;return ue.current=ee,v(!0),F(`/api/projects/${t}/compile/latest?mainFile=${encodeURIComponent(n)}`,{signal:ee.signal}).then(M=>{B||M.mainFile!==K.current||M.latestRun?.id!==r.runId||(O(M.latestRun.log),E(M.latestRun.diagnostics),C(r.status==="succeeded"?"succeeded":"failed"),r.status==="succeeded"&&r.stale&&J(m("editor.compileSnapshotStale")),r.status==="succeeded"&&M.pdfUrl?(oe.current.onPdfChanged(),w(M.pdfUrl),P(M.pdfCompiledAt),oe.current.onPreviewTab("pdf"),mt(r.runId),gt(n)):r.status==="failed"&&oe.current.onPreviewTab(M.latestRun.diagnostics.errors.length?"errors":"log"))}).catch(M=>{!Jn(M)&&!B&&oe.current.onError(q(M))}).finally(()=>{B||v(!1)}),()=>{B=!0,ee.abort(),ue.current===ee&&(ue.current=null)}},[r?.runId,r?.status,r?.mainFile,r?.stale,n,t,m]);const Ke=async()=>{if(!e||!n||e.permission==="read"||!s||je.current.has(n)||r?.mainFile===n&&(r.status==="queued"||r.status==="running"))return;const B=n;de(M=>new Set([...M,B])),oe.current.onCompileStart(),J(""),re.current?.abort(),re.current=null,O(""),E(null),C(null),oe.current.onPreviewTab(g?"pdf":"log");const ee=new AbortController;je.current.set(B,ee);try{if(!await oe.current.save())return;const M=await F(`/api/projects/${t}/compile`,{method:"POST",signal:ee.signal,body:JSON.stringify({mainFile:B})});if(M.mainFile!==K.current)return;O(M.log),E(M.diagnostics),C(M.ok?"succeeded":"failed"),M.skipped&&J(m("editor.upToDate")),M.ok&&M.stale&&J(m("editor.compileSnapshotStale")),M.pdfUrl?(oe.current.onPdfChanged(),w(M.pdfUrl),P(M.pdfCompiledAt),oe.current.onPreviewTab("pdf"),M.ok&&(M.skipped?oe.current.onCompileSuccess():mt(M.runId))):oe.current.onPreviewTab(M.diagnostics.errors.length?"errors":"log")}catch(M){!Jn(M)&&K.current===B&&oe.current.onError(q(M))}finally{je.current.get(B)===ee&&(je.current.delete(B),de(M=>{const A=new Set(M);return A.delete(B),A}))}},lt=async B=>{if(!e||!n||e.permission==="read"||!s||H||je.current.has(n)||r?.mainFile===n&&(r.status==="queued"||r.status==="running"))return;const ee=n;he(!0),ue.current?.abort(),D.current?.abort(),re.current?.abort();try{if((await F(`/api/projects/${t}/compile/clean`,{method:"POST",body:JSON.stringify({mainFile:ee,mode:B})})).mainFile!==K.current)return;oe.current.onSharedState(null),B==="artifacts"&&(O(""),E(null),C(null),w(""),P(null),Z([]),_(null),oe.current.onPdfChanged()),J(m(B==="cache"?"editor.cleanCacheComplete":"editor.cleanArtifactsComplete"))}catch(M){!Jn(M)&&K.current===ee&&oe.current.onError(q(M))}finally{he(!1)}};Pe.current=()=>{Ke()},h.useEffect(()=>{if(!we)return;const B=window.setTimeout(()=>J(""),3e3);return()=>window.clearTimeout(B)},[we]),h.useEffect(()=>{const B=ee=>{!(ee.ctrlKey||ee.metaKey)||ee.key.toLocaleLowerCase()!=="s"||(ee.preventDefault(),ee.stopPropagation(),ee.repeat||Pe.current())};return window.addEventListener("keydown",B,!0),()=>window.removeEventListener("keydown",B,!0)},[]),h.useEffect(()=>()=>{ue.current?.abort(),D.current?.abort(),re.current?.abort();for(const B of te.current)B.abort();te.current.clear();for(const B of je.current.values())B.abort();je.current.clear()},[]);const jt=async B=>{if(!B.viewable)return;re.current?.abort();const ee=new AbortController;re.current=ee,j(!0);try{const M=await F(`/api/projects/${t}/compile/artifacts?mainFile=${encodeURIComponent(n)}&path=${encodeURIComponent(B.path)}`,{signal:ee.signal});!ee.signal.aborted&&re.current===ee&&K.current===n&&_(M)}catch(M){Jn(M)||oe.current.onError(q(M))}finally{re.current===ee&&(re.current=null,j(!1))}};return{pdfUrl:g,pdfCompiledAt:k,pdfLoading:b,compileLog:N,compileDiagnostics:W,compileOutcome:G,artifacts:V,artifactPreview:R,artifactLoading:L,editorNotice:we,localCompiling:Ce.has(n),cleaning:H,compile:Ke,cleanCompile:lt,viewArtifact:jt}}const Cl=10*1024*1024,zb=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 jl(t){return t instanceof Error&&t.name==="AbortError"}function Us(t){const e=t.split("/").filter(Boolean);return e.pop(),e.map((n,s)=>e.slice(0,s+1).join("/"))}function kn(t,e){return!!(t&&e)&&(e===t||e.startsWith(`${t}/`))}function Bb(t){const e=`.${t.split(".").at(-1)?.toLocaleLowerCase()??""}`;return!zb.has(e)}function ls(t){return/(?:\.(?:tex|bib|sty|cls|txt|md)|latexmkrc)$/i.test(t)}function kl(t){const e=t.split(".").at(-1)?.toLocaleLowerCase()??"";return e==="pdf"?"pdf":["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif"].includes(e)?"image":Bb(t)?"text":"unsupported"}function Vb(t,e){return`/api/projects/${t}/file/raw?path=${encodeURIComponent(e)}`}function Hb({projectId:t,site:e,activeFile:n,dirty:s,save:r,onError:i,onProject:a,onActiveFile:c,onActiveMainFile:l,onRootDocuments:d}){const{t:f}=Le(),[u,p]=h.useState([]),[m,g]=h.useState(!1),[w,b]=h.useState(""),[v,k]=h.useState(null),[P,N]=h.useState(!1),[O,W]=h.useState(!1),[E,G]=h.useState(""),[C,V]=h.useState(""),[Z,R]=h.useState(""),[_,L]=h.useState(new Set),[j,H]=h.useState(null),[he,Ce]=h.useState(""),[de,we]=h.useState(null),[J,K]=h.useState(!1),[me,ue]=h.useState(null),[D,re]=h.useState(!1),te=h.useRef(null),je=h.useRef(null),Oe=async(A={})=>{te.current?.abort(),te.current=null;const se=A.signal?null:new AbortController;se&&(te.current=se);try{const ge=await F(`/api/projects/${t}/files`,{signal:A.signal??se?.signal});return(!A.isCurrent||A.isCurrent())&&p(ge.files),ge.files}catch(ge){if(!jl(ge))throw ge;return}finally{se&&te.current===se&&(te.current=null)}},Pe=async()=>{if(!(!w.trim()||w.trim().endsWith("/"))){V("");try{await F(`/api/projects/${t}/file`,{method:"POST",body:JSON.stringify({path:w,content:""})}),await Oe(),c(w),L(A=>new Set([...A,...Us(w)])),g(!1),b("")}catch(A){V(q(A))}}},oe=async()=>{if(!E.trim())return;V("");const A=Z?`${Z}/${E.trim()}`:E.trim();try{const se=await F(`/api/projects/${t}/folders`,{method:"POST",body:JSON.stringify({path:A})});await Oe(),L(ge=>new Set([...ge,...Us(se.path),se.path])),R(se.path),W(!1),G("")}catch(se){V(q(se))}},mt=async(A,se=new Set,ge=Z)=>{if(!A.length)return;const Ge=e.maxUploadSizeMB??50;if(A.find(le=>le.size>Ge*1024*1024))return i(f("errors.fileTooLarge",{size:Ge}));const Fe=ge,dt=A.map(le=>Fe?`${Fe}/${le.name}`:le.name),_t=new Map;for(const le of dt)_t.set(le,(_t.get(le)??0)+1);const Wt=[..._t.entries()].filter(([,le])=>le>1).map(([le])=>le);if(Wt.length)return i(f("errors.duplicateUploadNames",{files:Wt.join(", ")}));const kt=new Set(u.map(le=>le.path)),rt=[...new Set(dt.filter(le=>kt.has(le)&&!se.has(le)))];if(rt.length){ue({files:A,directory:Fe,collisions:rt});return}ue(null),re(!0);try{const le=new URLSearchParams;Fe&&le.set("directory",Fe);let Ue="";for(const[ut,et]of A.entries()){const Rt=dt[ut];le.delete("overwrite"),se.has(Rt)&&le.set("overwrite","1");const Ie=le.toString()?`?${le.toString()}`:"",vn=new FormData;vn.append("file",et);const ae=await fetch(`/api/projects/${t}/upload${Ie}`,{method:"POST",body:vn}),it=await ae.json().catch(()=>({}));if(!ae.ok){if(ae.status===409&&!se.has(Rt)&&it.code==="FILE_EXISTS"){ut>0&&await Oe(),ue({files:A.slice(ut),directory:Fe,collisions:[typeof it.path=="string"?it.path:Rt]});return}throw new Error(ae.status===409?f("errors.pathConflict"):Wo(it,ae.status,"errors.upload"))}typeof it.path=="string"&&ls(it.path)&&(Ue=it.path)}await Oe(),Ue&&c(Ue)}catch(le){i(q(le))}finally{re(!1)}},gt=async A=>{await mt(Array.from(A.target.files??[])),A.target.value=""},Ke=async A=>{je.current?.abort(),je.current=null,N(!1);const se=Vb(t,A.path);if((A.size??0)>Cl){k({path:A.path,kind:"large",size:A.size??0,url:se});return}const ge=kl(A.path);if(ge!=="text"){k({path:A.path,kind:ge,size:A.size??0,url:se});return}k({path:A.path,kind:ge,size:A.size??0,url:se,content:""}),N(!0);const Ge=new AbortController;je.current=Ge;try{const $=await fetch(se,{signal:Ge.signal}),Fe=await $.text();if(!$.ok)throw new Error(Fe||f("errors.request",{status:$.status}));k(dt=>dt?.path===A.path?{...dt,content:Fe}:dt)}catch($){jl($)||(k(null),i(q($)))}finally{je.current===Ge&&(je.current=null,N(!1))}},lt=A=>{const se=kl(A.path),ge=(e.maxCollaborativeFileSizeMB??5)*1024*1024;(A.size??0)>Cl||ls(A.path)&&(A.size??0)>ge||se!=="text"||!ls(A.path)?Ke(A):c(A.path)},jt=async()=>{if(j){V("");try{if(!await r())return;const A=await F(`/api/projects/${t}/path`,{method:"PATCH",body:JSON.stringify({source:j.path,destinationDirectory:he})}),se=$=>$===j.path?A.path:$.startsWith(`${j.path}/`)?`${A.path}${$.slice(j.path.length)}`:$;c($=>se($)),l($=>se($)),d($=>new Set([...$].map(se))),R($=>$&&se($));const[ge,Ge]=await Promise.all([F(`/api/projects/${t}/files`),F(`/api/projects/${t}`)]);p(ge.files),a(Ge.project),L($=>new Set([...$,...Us(A.path),he].filter(Boolean))),H(null),Ce("")}catch(A){V(q(A))}}},B=async()=>{if(de){V("");try{if(s&&!await r())return;await F(`/api/projects/${t}/file?path=${encodeURIComponent(de.path)}`,{method:"DELETE"}),we(null)}catch(A){V(q(A))}}};h.useEffect(()=>()=>{te.current?.abort(),je.current?.abort()},[]),h.useEffect(()=>{je.current?.abort(),je.current=null,N(!1)},[n]);const ee=u.filter(A=>A.type==="directory"),M=u.filter(A=>Us(A.path).every(se=>_.has(se)));return{files:u,setFiles:p,loadFiles:Oe,newFileOpen:m,setNewFileOpen:g,newFilePath:w,setNewFilePath:b,resourcePreview:v,setResourcePreview:k,resourcePreviewLoading:P,setResourcePreviewLoading:N,newFolderOpen:O,setNewFolderOpen:W,newFolderName:E,setNewFolderName:G,fileDialogError:C,setFileDialogError:V,selectedFolder:Z,setSelectedFolder:R,expandedFolders:_,setExpandedFolders:L,moveEntry:j,setMoveEntry:H,moveDestination:he,setMoveDestination:Ce,deleteEntry:de,setDeleteEntry:we,fileDragActive:J,setFileDragActive:K,uploadConflict:me,setUploadConflict:ue,uploadingFiles:D,directoryEntries:ee,visibleEntries:M,createFile:Pe,createFolder:oe,uploadFiles:mt,upload:gt,openFile:lt,movePath:jt,removePath:B}}function qb({active:t,activeFile:e,content:n,dictionaryWords:s}){const[r,i]=h.useState([]),[a,c]=h.useState(""),[l,d]=h.useState(""),[f,u]=h.useState(0),[p,m]=h.useState(null),g=h.useRef(0),w=h.useRef(n),b=h.useRef(e),v=h.useRef(0);w.current=n,b.current=e,h.useEffect(()=>{i([]),c(""),d(""),m(null)},[e,s]),h.useEffect(()=>{u(O=>r.length?Math.min(O,r.length-1):0)},[r]),h.useEffect(()=>{const O=++g.current;if(!t||!e){i([]),c(""),d(""),m(null);return}const W=n,E=e,G=window.setTimeout(()=>{on(async()=>{const{lintLatex:C}=await import("./spellCheck-0f5ZG5IV.js");return{lintLatex:C}},__vite__mapDeps([2,1])).then(({lintLatex:C})=>{if(!(O!==g.current||w.current!==W||b.current!==E))return C(W,s).then(V=>{O!==g.current||w.current!==W||b.current!==E||(i(V),c(W),d(E),u(0),m(null))})}).catch(()=>{})},700);return()=>window.clearTimeout(G)},[t,e,n,s]);const k=l===e&&a===n,P=h.useMemo(()=>k?{total:r.length,unique:new Set(r.map(O=>`${O.kind}:${O.word.toLocaleLowerCase("en-US")}`)).size}:null,[k,r]);return{issues:k?r:[],jump:k?p:null,index:f,summary:P,jumpToIssue:O=>{if(!r.length)return;const W=Math.max(0,Math.min(O,r.length-1)),E=r[W];u(W),m({from:E.from,to:E.to,nonce:++v.current})}}}function El(t){return t instanceof Error&&t.name==="AbortError"}function Wb({projectId:t,mainFile:e,activeFile:n,onActiveFile:s,onError:r,onShowPdf:i}){const[a,c]=h.useState(null),[l,d]=h.useState(null),[f,u]=h.useState(null),p=h.useRef(null),m=h.useRef(0),g=h.useRef(n),w=h.useRef(s),b=h.useRef(r),v=h.useRef(i),k=E=>E===e&&/\.tex$/i.test(E);g.current=n,w.current=s,b.current=r,v.current=i,h.useEffect(()=>(p.current?.abort(),p.current=null,c(null),d(null),u(null),()=>p.current?.abort()),[t,e]);const P=(E,G,C)=>{u({path:E,line:G,column:C,nonce:++m.current}),g.current!==E&&w.current(E)},N=async(E,G,C,V={})=>{if(!k(E))return;p.current?.abort();const Z=new AbortController;p.current=Z;try{const R=await F(`/api/projects/${t}/sync/pdf?mainFile=${encodeURIComponent(e)}&path=${encodeURIComponent(E)}&line=${G}&column=${C}`,{signal:Z.signal});if(p.current!==Z||!R)return;c({...R,nonce:++m.current}),v.current()}catch(R){!El(R)&&!V.silent&&b.current(q(R))}finally{p.current===Z&&(p.current=null)}},O=async(E,G,C)=>{if(!k(g.current))return;const V=g.current;p.current?.abort();const Z=new AbortController;p.current=Z;try{const R=await F(`/api/projects/${t}/sync/source?mainFile=${encodeURIComponent(e)}&page=${E}&x=${G}&y=${C}`,{signal:Z.signal});if(p.current!==Z||g.current!==V||!k(g.current))return;P(R.path,R.line,R.column)}catch(R){El(R)||b.current(q(R))}finally{p.current===Z&&(p.current=null)}};return{pdfTarget:a,pdfViewport:l,sourceJump:f,setPdfViewport:d,clearPdfViewport:()=>d(null),jumpToSource:P,syncSourceToPdf:N,syncPdfToSource:O,syncVisiblePdfToSource:()=>{l&&O(l.page,l.x,l.y)}}}function ch(t,e){return`texlite.workspaceLayout:${encodeURIComponent(t)}:${encodeURIComponent(e)}`}function Dl(t,e){try{const n=window.localStorage.getItem(ch(t,e));if(n==="editor-pdf"||n==="editor-only"||n==="pdf-only")return n}catch{}return"editor-pdf"}function Kb(t,e){const[n,s]=h.useState(()=>Dl(t,e));return h.useEffect(()=>{s(Dl(t,e))},[t,e]),{workspaceLayout:n,setWorkspaceLayout:i=>{s(i);try{window.localStorage.setItem(ch(t,e),i)}catch{}}}}const lh=()=>on(()=>import("./PdfPreview-BPKX-qpr.js"),__vite__mapDeps([3,1,4,5])),Gb=h.lazy(()=>lh().then(t=>({default:t.PdfPreview}))),Jb=h.lazy(()=>on(()=>import("./LatexEditor-Y5KfVqQI.js"),__vite__mapDeps([6,1,7])).then(t=>({default:t.LatexEditor}))),Yb=h.lazy(()=>on(()=>import("./GitDialog-s54eAFX6.js"),__vite__mapDeps([8,1,5])).then(t=>({default:t.GitDialog}))),Xb=h.lazy(()=>on(()=>import("./HistoryDialog-DrUnIy0a.js"),__vite__mapDeps([9,1,0])).then(t=>({default:t.HistoryDialog}))),Zb=h.lazy(()=>on(()=>import("./ProjectNavigationDialogs-CjZX0g7O.js"),__vite__mapDeps([10,1])).then(t=>({default:t.ProjectSearchDialog}))),Qb=h.lazy(()=>on(()=>import("./ProjectNavigationDialogs-CjZX0g7O.js"),__vite__mapDeps([10,1])).then(t=>({default:t.QuickOpenDialog}))),ev=h.lazy(()=>on(()=>import("./SystemMetricsDialog-B97Og0La.js"),__vite__mapDeps([11,1])).then(t=>({default:t.SystemMetricsDialog}))),tt=8;function Qn(t){return t instanceof Error&&t.name==="AbortError"}function tv(){const{t}=Le(),[e,n]=h.useState({siteName:"TexLite",adminEmail:""}),[s,r]=h.useState(),[i,a]=h.useState(()=>typeof window>"u"?null:Ar(window.location.pathname)),[c,l]=h.useState(null);h.useEffect(()=>{const p=Ar(window.location.pathname);if(p&&window.location.pathname!==Zi(p)){const w={texliteRoute:"project",projectId:p,fromDashboard:!1};window.history.replaceState(w,"",Zi(p))}const m=()=>a(Ar(window.location.pathname)),g=()=>{if(l(null),r(null),Ar(window.location.pathname)){const w={texliteRoute:"dashboard"};window.history.replaceState(w,"","/"),a(null)}};return window.addEventListener("popstate",m),window.addEventListener("texlite:session-expired",g),()=>{window.removeEventListener("popstate",m),window.removeEventListener("texlite:session-expired",g)}},[]);const d=p=>{const m=Zi(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(mg(p)&&p.fromDashboard){window.history.back();return}const m={texliteRoute:"dashboard"};window.history.replaceState(m,"","/"),a(null)};if(h.useEffect(()=>{F("/api/config").then(p=>{n(p),document.title=p.siteName}),F("/api/me").then(({user:p})=>r(p)).catch(p=>{p instanceof qo&&p.status,r(null)})},[]),s===void 0)return o.jsx("div",{className:"center-card",children:t("common.loading")});if(!s)return o.jsx(sv,{site:e,onLogin:r});if(s.mustChangePassword)return o.jsx(nv,{site:e,user:s,onChanged:p=>r(p)});if(i)return o.jsx(av,{site:e,user:s,projectId:i,onBack:f},i);const u=c?.userId===s.id?c:null;return o.jsx(rv,{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 Di({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 Ma(){const{t}=Le();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",of]})]}),o.jsx("span",{children:t("footer.credit")})]})}function nv({site:t,user:e,onChanged:n}){const{t:s}=Le(),[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<tt)return u(s("auth.passwordMinimum",{count:tt}));try{await F("/api/me/password",{method:"PUT",body:JSON.stringify({currentPassword:r,newPassword:a})}),n({...e,mustChangePassword:!1})}catch(g){u(q(g))}};return o.jsxs("main",{className:"login-page",children:[o.jsx(na,{}),o.jsxs("form",{className:"login-card",onSubmit:p,children:[o.jsx(Di,{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:tt,autoComplete:"new-password",value:a,onChange:m=>c(m.target.value)}),o.jsx("small",{className:"field-hint",children:s("auth.passwordMinimum",{count:tt})})]}),o.jsxs("label",{children:[s("auth.confirmPassword"),o.jsx("input",{type:"password",minLength:tt,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(Ma,{})]})}function sv({site:t,onLogin:e}){const{t:n}=Le(),[s,r]=h.useState(""),[i,a]=h.useState(""),[c,l]=h.useState(""),d=async f=>{f.preventDefault(),l("");try{const u=await F("/api/auth/login",{method:"POST",body:JSON.stringify({username:s,password:i})});e(u.user)}catch(u){l(q(u))}};return o.jsxs("main",{className:"login-page",children:[o.jsx(na,{}),o.jsxs("form",{className:"login-card",onSubmit:d,children:[o.jsx(Di,{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(Ma,{})]})}function rv({site:t,user:e,initialData:n,onDataChange:s,onUser:r,onOpenProject:i}){const{t:a}=Le(),[c,l]=h.useState(()=>n?.projects??[]),[d,f]=h.useState(()=>n?.tags??[]),[u,p]=h.useState(()=>n?.pagination??{page:1,pageSize:20,total:n?.projects.length??0,totalPages:n?.projects.length?1:0}),[m,g]=h.useState(!!n),[w,b]=h.useState(!1),[v,k]=h.useState(!1),[P,N]=h.useState(""),[O,W]=h.useState(!1),[E,G]=h.useState(""),[C,V]=h.useState(!1),[Z,R]=h.useState(""),[_,L]=h.useState(null),[j,H]=h.useState(""),he=h.useRef(null),[Ce,de]=h.useState(!1),[we,J]=h.useState(""),[K,me]=h.useState(""),[ue,D]=h.useState(!1),[re,te]=h.useState(""),[je,Oe]=h.useState("blue"),[Pe,oe]=h.useState(null),[mt,gt]=h.useState(null),[Ke,lt]=h.useState(""),[jt,B]=h.useState(null),[ee,M]=h.useState(""),[A,se]=h.useState(!1),[ge,Ge]=h.useState(null),[$,Fe]=h.useState(null),[dt,_t]=h.useState([]),[Wt,kt]=h.useState(""),[rt,le]=h.useState(!1),[Ue,ut]=h.useState(""),[et,Rt]=h.useState(()=>localStorage.getItem("texlite-project-view")==="list"?"list":"grid"),[Ie,vn]=h.useState(()=>localStorage.getItem("texlite-project-sort")==="created"?"created":"updated"),[ae,it]=h.useState(!1),[Ts,fr]=h.useState(""),[ve,ot]=h.useState(1),[In,pr]=h.useState(""),Et=h.useRef(0),ht=h.useRef(null),Lt=(x,ie,ne,Se,Me)=>`${x?"archived":"active"}|${ie}|${ne}|${Se}|${Me}`,Kt=Lt(ae,ve,we,K,Ie),yt=(x,ie,ne,Se,Me)=>{const ze=new URLSearchParams({page:String(ie),pageSize:"20",sort:Me});x&&ze.set("archived","1"),ne.trim()&&ze.set("search",ne.trim()),Se&&ze.set("tag",Se);const Jt=Lt(x,ie,ne,Se,Me),wt=++Et.current;ht.current?.abort();const ln=new AbortController;return ht.current=ln,Promise.all([F(`/api/projects?${ze.toString()}`,{signal:ln.signal}),F("/api/tags",{signal:ln.signal})]).then(([Ft,Ls])=>{wt===Et.current&&(l(Ft.projects),f(Ls.tags),p(Ft.pagination),ot(Ft.pagination.page),g(!0),pr(Jt))}).catch(Ft=>{!Qn(Ft)&&wt===Et.current&&N(q(Ft))}).finally(()=>{ht.current===ln&&(ht.current=null)})};h.useEffect(()=>(yt(ae,ve,we,K,Ie),()=>ht.current?.abort()),[ae,ve,we,K,Ie]),h.useEffect(()=>{m&&!ae&&In===Kt&&s(c,d,u)},[c,d,u,m,In,Kt,ae]);const cn=x=>{Rt(x),localStorage.setItem("texlite-project-view",x)},mr=x=>{vn(x),ot(1),localStorage.setItem("texlite-project-sort",x)},gr=x=>{it(x),ot(1)},Sn=x=>{me(x),ot(1)},Ns=async()=>{if(E.trim())try{const{project:x}=await F("/api/projects",{method:"POST",body:JSON.stringify({name:E})});W(!1),G("");const ie=ae||ve!==1?c:[x,...c].slice(0,u.pageSize),ne=ae?u:{...u,total:u.total+1,totalPages:Math.ceil((u.total+1)/u.pageSize)};l(ie),p(ne),ae||s(ie,d,ne),i(x.id)}catch(x){N(q(x))}},Je=async()=>{if(!_)return;const x=t.maxUploadSizeMB??50;if(_.size>x*1024*1024)return H(a("errors.fileTooLarge",{size:x}));de(!0),H("");const ie=new FormData;ie.append("file",_);try{const ne=await fetch(`/api/projects/import?name=${encodeURIComponent(Z.trim())}`,{method:"POST",body:ie}),Se=await ne.json();if(!ne.ok)throw new Error(Wo(Se,ne.status,"errors.upload"));const Me=Se.project,ze=ae||ve!==1?c:[Me,...c].slice(0,u.pageSize),Jt=ae?u:{...u,total:u.total+1,totalPages:Math.ceil((u.total+1)/u.pageSize)};l(ze),p(Jt),ae||s(ze,d,Jt),V(!1),L(null),R(""),i(Me.id)}catch(ne){H(q(ne))}finally{de(!1)}},Gt=x=>{if(x&&!x.name.toLocaleLowerCase().endsWith(".zip")){H(a("errors.zipOnly"));return}H(""),L(x),x&&!Z&&R(x.name.replace(/\.zip$/i,""))},Ye=async()=>{await F("/api/auth/logout",{method:"POST"}),r(null)},yr=async()=>{if(re.trim())try{const x=await F("/api/tags",{method:"POST",body:JSON.stringify({name:re,color:je})});f(ie=>[...ie,x.tag].sort((ne,Se)=>ne.name.localeCompare(Se.name))),D(!1),te(""),Oe("blue")}catch(x){N(q(x))}},At=async x=>{if(!Pe)return;const ie=Pe.tags.some(ne=>ne.id===x.id);try{const Se=(await F(ie?`/api/projects/${Pe.id}/tags/${x.id}`:`/api/projects/${Pe.id}/tags`,ie?{method:"DELETE"}:{method:"POST",body:JSON.stringify({tagId:x.id})})).project;oe(Se),l(Me=>Me.map(ze=>ze.id===Se.id?Se:ze))}catch(ne){N(q(ne))}},Os=async()=>{if(!(!mt||!Ke.trim()))try{const x=await F(`/api/projects/${mt.id}`,{method:"PATCH",body:JSON.stringify({name:Ke})});l(ie=>ie.map(ne=>ne.id===x.project.id?x.project:ne)),gt(null),lt("")}catch(x){N(q(x))}},ke=async()=>{if(!(!jt||!ee.trim())){se(!0),N("");try{await F(`/api/projects/${jt.id}/duplicate`,{method:"POST",body:JSON.stringify({name:ee})}),B(null),M(""),yt(ae,ve,we,K,Ie)}catch(x){N(q(x))}finally{se(!1)}}},Ti=async()=>{if(ge)try{await F(`/api/projects/${ge.id}`,{method:"DELETE"}),l(Me=>Me.filter(ze=>ze.id!==ge.id));const x=Math.max(0,u.total-1),ie=Math.ceil(x/u.pageSize),ne=ie===0?1:Math.min(ve,ie),Se={...u,page:ne,total:x,totalPages:ie};p(Se),Ge(null),ne!==ve?ot(ne):yt(ae,ve,we,K,Ie)}catch(x){N(q(x))}},Ps=async x=>{Fe(x),kt(""),_t([]),ut(""),le(!0);try{const ie=await F("/api/users");_t(ie.users.filter(ne=>ne.id!==x.ownerId))}catch(ie){ut(q(ie))}finally{le(!1)}},wr=async()=>{if(!(!$||!Wt)){le(!0),ut("");try{await F(`/api/projects/${$.id}/owner`,{method:"PUT",body:JSON.stringify({userId:Wt})}),Fe(null),kt(""),yt(ae,ve,we,K,Ie)}catch(x){ut(q(x))}finally{le(!1)}}},_s=async x=>{const ie=!ae;fr(x.id),N("");try{await F(`/api/projects/${x.id}/archive`,{method:ie?"PUT":"DELETE"});const ne=c.filter(wt=>wt.id!==x.id);l(ne);const Se=Math.max(0,u.total-1),Me=Math.ceil(Se/u.pageSize),ze=Me===0?1:Math.min(ve,Me),Jt={...u,page:ze,total:Se,totalPages:Me};p(Jt),ae||s(ne,d,Jt),ze!==ve?ot(ze):yt(ae,ve,we,K,Ie)}catch(ne){N(q(ne))}finally{fr("")}},xr=c,Ni=["red","orange","yellow","green","blue","purple","gray"],Rs=x=>new Date(x).toLocaleString(pe.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(Di,{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(Om,{"aria-hidden":!0,size:14}),a("metrics.title")]}),o.jsxs("button",{className:"ghost",onClick:()=>b(!w),children:[w?o.jsx(bd,{"aria-hidden":!0,size:14}):o.jsx(Ks,{"aria-hidden":!0,size:14}),a(w?"users.back":"users.manage")]})]}),o.jsx(na,{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:Ye,children:a("auth.logout")})]})]}),w?o.jsx(ov,{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(Gr,{"aria-hidden":!0,size:25}),a("projects.title")]}),o.jsx("p",{className:"muted",children:e.canCreateProjects?a("projects.subtitle"):a("projects.restricted")})]}),o.jsxs("div",{className:"section-actions",children:[o.jsxs("button",{onClick:()=>D(!0),children:[o.jsx(Ic,{"aria-hidden":!0,size:15}),a("tags.create")]}),e.canCreateProjects&&o.jsxs(o.Fragment,{children:[o.jsxs("button",{onClick:()=>{H(""),V(!0)},children:[o.jsx(Yr,{"aria-hidden":!0,size:15}),a("projects.upload")]}),o.jsxs("button",{className:"primary",onClick:()=>W(!0),children:[o.jsx(Cd,{"aria-hidden":!0,size:15}),a("projects.new")]})]})]})]}),P&&o.jsx("p",{className:"error",children:P}),o.jsxs("div",{className:"project-toolbar",children:[o.jsx("input",{type:"search",placeholder:a("projects.search"),value:we,onChange:x=>{J(x.target.value),ot(1)}}),o.jsxs("div",{className:"project-scope",role:"tablist","aria-label":a("projects.scope"),children:[o.jsxs("button",{className:ae?"":"active",onClick:()=>gr(!1),role:"tab","aria-selected":!ae,children:[o.jsx(Gr,{size:14}),a("projects.active")]}),o.jsxs("button",{className:ae?"active":"",onClick:()=>gr(!0),role:"tab","aria-selected":ae,children:[o.jsx(Rc,{size:14}),a("projects.archived")]})]}),o.jsxs("div",{className:"tag-filters",children:[o.jsx("button",{className:K?"":"active",onClick:()=>Sn(""),children:a("projects.allTags")}),d.map(x=>o.jsxs("button",{className:K===x.id?"active":"",onClick:()=>Sn(K===x.id?"":x.id),children:[o.jsx(po,{color:x.color}),x.name]},x.id))]}),o.jsxs("label",{className:"project-sort",children:[o.jsx(_m,{size:14}),o.jsx("span",{children:a("projects.sortBy")}),o.jsxs("select",{value:Ie,onChange:x=>mr(x.target.value),children:[o.jsx("option",{value:"updated",children:a("projects.sortModified")}),o.jsx("option",{value:"created",children:a("projects.sortCreated")})]})]}),o.jsxs("div",{className:"view-toggle",children:[o.jsx("button",{className:et==="grid"?"active":"",onClick:()=>cn("grid"),title:a("projects.grid"),children:"▦"}),o.jsx("button",{className:et==="list"?"active":"",onClick:()=>cn("list"),title:a("projects.list"),children:"☷"})]})]}),o.jsxs("div",{className:`project-grid ${et==="list"?"list-view":""}`,children:[xr.map(x=>o.jsxs("article",{className:`project-card${x.ownerId===e.id?" owned-project":""}`,children:[et==="grid"&&x.ownerId===e.id&&o.jsxs("button",{className:"project-transfer-action",title:a("projects.transferOwnership"),onClick:()=>{Ps(x)},children:[o.jsx(Ji,{"aria-hidden":!0,size:13}),a("projects.transfer")]}),o.jsxs("button",{className:"project-card-open",onClick:()=>i(x.id),children:[o.jsx("span",{className:"owner-badge",title:x.ownerDisplayName??x.ownerUsername,children:x.ownerDisplayName??x.ownerUsername}),o.jsxs("span",{className:"project-card-main",children:[o.jsx("strong",{children:x.name}),o.jsxs("span",{className:"project-tags",children:[x.tags?.map(ie=>o.jsx("span",{className:`tag tag-${ie.color}`,children:ie.name},ie.id)),!!(x.unresolvedCommentCount&&x.unresolvedCommentCount>0)&&o.jsxs("span",{className:"project-comments-badge unresolved",title:a("projects.unresolvedCommentsTooltip",{unresolved:x.unresolvedCommentCount,total:x.commentCount??x.unresolvedCommentCount}),children:[o.jsx(No,{"aria-hidden":!0,size:10}),o.jsx("span",{children:a("projects.unresolvedCount",{count:x.unresolvedCommentCount})})]})]})]}),o.jsxs("dl",{className:"project-meta",children:[o.jsxs("div",{children:[o.jsxs("dt",{children:[o.jsx(Rm,{"aria-hidden":!0,size:13}),a("projects.created")]}),o.jsx("dd",{children:o.jsx("time",{dateTime:x.createdAt,children:Rs(x.createdAt)})})]}),o.jsxs("div",{children:[o.jsxs("dt",{children:[o.jsx(jd,{"aria-hidden":!0,size:13}),a("projects.modified")]}),o.jsxs("dd",{title:a("projects.modifiedByUser",{time:Rs(x.updatedAt),user:x.lastModifiedDisplayName??x.lastModifiedUsername??a("projects.deletedUser")}),children:[o.jsx("time",{dateTime:x.updatedAt,children:Rs(x.updatedAt)}),o.jsxs("span",{className:"project-modified-by",children:[" · ",a("projects.byUser",{user:x.lastModifiedDisplayName??x.lastModifiedUsername??a("projects.deletedUser")})]})]})]}),o.jsxs("div",{children:[o.jsxs("dt",{children:[o.jsx(No,{"aria-hidden":!0,size:13}),a("projects.comments")]}),o.jsx("dd",{children:x.unresolvedCommentCount?o.jsx("span",{className:"comment-count-unresolved",title:a("projects.unresolvedCommentsTooltip",{unresolved:x.unresolvedCommentCount,total:x.commentCount??x.unresolvedCommentCount}),children:a("projects.unresolvedComments",{count:x.unresolvedCommentCount})}):x.commentCount?o.jsx("span",{className:"comment-count-all-resolved",title:a("projects.allCommentsResolvedTooltip",{count:x.commentCount}),children:a("projects.allResolved",{count:x.commentCount})}):o.jsx("span",{className:"comment-count-none",children:a("projects.noComments")})})]})]})]}),o.jsxs("div",{className:"project-card-actions",children:[o.jsxs("button",{onClick:()=>oe(x),children:[o.jsx(Ic,{"aria-hidden":!0,size:14}),a("tags.assign")]}),x.permission==="owner"&&o.jsxs("button",{onClick:()=>{gt(x),lt(x.name)},children:[o.jsx(Oo,{"aria-hidden":!0,size:14}),a("projects.rename")]}),(e.role==="admin"||e.canCreateProjects)&&o.jsxs("button",{onClick:()=>{B(x),M(`${x.name} (1)`)},children:[o.jsx(Mm,{"aria-hidden":!0,size:14}),a("projects.duplicate")]}),o.jsxs("a",{href:`/api/projects/${x.id}/download`,download:!0,children:[o.jsx(Ws,{"aria-hidden":!0,size:14}),a("projects.download")]}),o.jsxs("button",{disabled:Ts===x.id,onClick:()=>{_s(x)},children:[ae?o.jsx(Pm,{"aria-hidden":!0,size:14}):o.jsx(Rc,{"aria-hidden":!0,size:14}),a(ae?"projects.unarchive":"projects.archive")]}),et==="list"&&x.ownerId===e.id&&o.jsxs("button",{onClick:()=>{Ps(x)},children:[o.jsx(Ji,{"aria-hidden":!0,size:14}),a("projects.transfer")]}),x.permission==="owner"&&o.jsxs("button",{className:"danger-text",onClick:()=>Ge(x),children:[o.jsx(gn,{"aria-hidden":!0,size:14}),a("common.delete")]})]})]},x.id)),xr.length===0&&(c.length===0?ae?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(ng,{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:()=>ot(x=>Math.max(1,x-1)),title:a("projects.previousPage"),children:[o.jsx(Sd,{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:()=>ot(x=>Math.min(u.totalPages,x+1)),title:a("projects.nextPage"),children:[o.jsx(sa,{size:15}),a("projects.nextPage")]})]}),o.jsx(He,{open:O,title:a("projects.new"),description:a("projects.newDescription"),onOpenChange:W,footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>W(!1),children:a("common.cancel")}),o.jsx("button",{className:"primary",onClick:()=>{Ns()},children:a("common.create")})]}),children:o.jsxs("label",{className:"form-field",children:[a("projects.name"),o.jsx("input",{autoFocus:!0,value:E,onChange:x=>G(x.target.value),onKeyDown:x=>{x.key==="Enter"&&Ns()}})]})}),o.jsx(He,{open:C,title:a("projects.upload"),description:a("projects.uploadDescription",{size:t.maxUploadSizeMB??50}),onOpenChange:x=>{V(x),x||H("")},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>{V(!1),H("")},children:a("common.cancel")}),o.jsx("button",{className:"primary",disabled:!_||Ce,onClick:()=>{Je()},children:a(Ce?"projects.importing":"projects.import")})]}),children:o.jsxs("div",{className:"form-stack",children:[j&&o.jsx("p",{className:"error import-error",children:j}),o.jsxs("div",{className:`upload-picker${_?" has-file":""}`,onDragOver:x=>{x.preventDefault(),x.dataTransfer.dropEffect="copy"},onDrop:x=>{x.preventDefault(),Gt(x.dataTransfer.files[0]??null)},children:[o.jsx("input",{ref:he,className:"sr-only",type:"file",accept:".zip,application/zip",onChange:x=>Gt(x.target.files?.[0]??null)}),o.jsx(To,{size:34}),o.jsxs("div",{className:"upload-picker-copy",children:[o.jsx("strong",{children:_?.name??a("projects.chooseZip")}),o.jsx("span",{children:_?a("projects.selectedFileSize",{size:dh(_.size)}):a("projects.dropZip")})]}),o.jsxs("button",{type:"button",onClick:()=>he.current?.click(),children:[o.jsx(Yr,{size:15}),a("projects.browse")]}),_&&o.jsx("button",{className:"upload-clear",type:"button",title:a("projects.clearFile"),"aria-label":a("projects.clearFile"),onClick:()=>{Gt(null),he.current&&(he.current.value="")},children:o.jsx(Xr,{size:14})})]}),o.jsxs("label",{className:"form-field",children:[a("projects.name"),o.jsx("input",{value:Z,onChange:x=>R(x.target.value)})]})]})}),o.jsx(He,{open:ue,title:a("tags.create"),description:a("tags.createDescription"),onOpenChange:D,footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>D(!1),children:a("common.cancel")}),o.jsx("button",{className:"primary",onClick:()=>{yr()},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:re,onChange:x=>te(x.target.value)})]}),o.jsxs("fieldset",{className:"color-picker",children:[o.jsx("legend",{children:a("tags.color")}),Ni.map(x=>o.jsxs("label",{className:je===x?"active":"",children:[o.jsx("input",{type:"radio",name:"dashboard-tag-color",checked:je===x,onChange:()=>Oe(x)}),o.jsx(po,{color:x}),a(`tags.${x}`)]},x))]})]})}),o.jsx(He,{open:!!Pe,title:a("tags.assignTitle",{project:Pe?.name??""}),description:a("tags.assignDescription"),onOpenChange:x=>{x||oe(null)},footer:o.jsx("button",{onClick:()=>oe(null),children:a("common.close")}),children:o.jsxs("div",{className:"tag-assignment-list",children:[d.map(x=>o.jsxs("label",{children:[o.jsx("input",{type:"checkbox",checked:!!Pe?.tags.some(ie=>ie.id===x.id),onChange:()=>{At(x)}}),o.jsx(po,{color:x.color}),o.jsx("span",{children:x.name})]},x.id)),d.length===0&&o.jsx("p",{className:"muted",children:a("tags.empty")})]})}),o.jsx(He,{open:!!mt,title:a("projects.renameTitle"),onOpenChange:x=>{x||gt(null)},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>gt(null),children:a("common.cancel")}),o.jsx("button",{className:"primary",onClick:()=>{Os()},children:a("projects.rename")})]}),children:o.jsxs("label",{className:"form-field",children:[a("projects.name"),o.jsx("input",{autoFocus:!0,value:Ke,onChange:x=>lt(x.target.value),onKeyDown:x=>{x.key==="Enter"&&Os()}})]})}),o.jsx(He,{open:!!jt,title:a("projects.duplicateTitle"),description:a("projects.duplicateDescription",{project:jt?.name??""}),onOpenChange:x=>{!x&&!A&&(B(null),M(""))},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{disabled:A,onClick:()=>{B(null),M("")},children:a("common.cancel")}),o.jsx("button",{className:"primary",disabled:A||!ee.trim(),onClick:()=>{ke()},children:a(A?"projects.duplicating":"projects.duplicate")})]}),children:o.jsxs("label",{className:"form-field",children:[a("projects.name"),o.jsx("input",{autoFocus:!0,value:ee,onChange:x=>M(x.target.value),onKeyDown:x=>{x.key==="Enter"&&ke()}})]})}),o.jsx(He,{open:!!$,title:a("projects.transferOwnership"),description:a("projects.transferDescription",{project:$?.name??""}),onOpenChange:x=>{!x&&!rt&&(Fe(null),kt(""),ut(""))},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{disabled:rt,onClick:()=>{Fe(null),kt(""),ut("")},children:a("common.cancel")}),o.jsxs("button",{className:"primary",disabled:rt||!Wt,onClick:()=>{wr()},children:[rt?o.jsx(Dt,{className:"spin",size:14}):o.jsx(Ji,{size:14}),a("projects.transfer")]})]}),children:o.jsxs("div",{className:"form-stack",children:[Ue&&o.jsx("p",{className:"error dialog-error",children:Ue}),o.jsxs("label",{className:"form-field",children:[a("projects.newOwner"),o.jsxs("select",{disabled:rt||dt.length===0,value:Wt,onChange:x=>kt(x.target.value),children:[o.jsx("option",{value:"",children:rt?a("common.loading"):dt.length>0?a("projects.chooseNewOwner"):a("projects.noTransferUsers")}),dt.map(x=>o.jsxs("option",{value:x.id,children:[x.displayName??x.username," (@",x.username,")"]},x.id))]})]}),o.jsxs("p",{className:"warning",children:[o.jsx(hs,{size:15}),a("projects.transferWarning")]})]})}),o.jsx(us,{open:!!ge,title:a("projects.deleteTitle"),description:a("projects.deleteDescription",{project:ge?.name??""}),confirmLabel:a("common.delete"),danger:!0,onCancel:()=>Ge(null),onConfirm:()=>{Ti()}})]}),v&&o.jsx(h.Suspense,{fallback:null,children:o.jsx(ev,{open:!0,onOpenChange:k})}),o.jsx(Ma,{})]})}function po({color:t}){return o.jsx("span",{className:`tag-dot tag-${t}`})}function iv(t=10){const e="ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789!@#$%",n=crypto.getRandomValues(new Uint8Array(t));return Array.from(n,s=>e[s%e.length]).join("")}function ov({currentUser:t}){const{t:e}=Le(),[n,s]=h.useState([]),[r,i]=h.useState(""),[a,c]=h.useState(!1),[l,d]=h.useState({username:"",displayName:"",password:"",role:"user",canCreateProjects:!1}),[f,u]=h.useState(null),[p,m]=h.useState(""),[g,w]=h.useState(null),[b,v]=h.useState(!1),k=()=>F("/api/admin/users").then(({users:C})=>s(C)).catch(C=>i(q(C)));h.useEffect(()=>{k()},[]);const P=async()=>{if(l.password.length<tt)return i(e("auth.passwordMinimum",{count:tt}));try{await F("/api/admin/users",{method:"POST",body:JSON.stringify({username:l.username,displayName:l.displayName||l.username,password:l.password,role:l.role,canCreateProjects:l.canCreateProjects})}),c(!1),d({username:"",displayName:"",password:"",role:"user",canCreateProjects:!1}),await k()}catch(C){i(q(C))}},N=async C=>{try{await F(`/api/admin/users/${C.id}`,{method:"PATCH",body:JSON.stringify({disabled:!C.disabled})}),await k()}catch(V){i(q(V))}},O=async C=>{try{await F(`/api/admin/users/${C.id}`,{method:"PATCH",body:JSON.stringify({role:C.role==="admin"?"user":"admin"})}),await k()}catch(V){i(q(V))}},W=async C=>{try{await F(`/api/admin/users/${C.id}`,{method:"PATCH",body:JSON.stringify({canCreateProjects:!C.canCreateProjects})}),await k()}catch(V){i(q(V))}},E=async()=>{if(!(!f||!p)){if(p.length<tt)return i(e("auth.passwordMinimum",{count:tt}));try{await F(`/api/admin/users/${f.id}`,{method:"PATCH",body:JSON.stringify({password:p})}),u(null),m("")}catch(C){i(q(C))}}},G=async()=>{if(g)try{await F(`/api/admin/users/${g.id}`,{method:"DELETE",body:JSON.stringify({deleteProjects:b})}),w(null),v(!1),await k()}catch(C){i(q(C))}};return o.jsxs("main",{className:"dashboard",children:[o.jsxs("div",{className:"section-title",children:[o.jsxs("div",{children:[o.jsxs("h1",{children:[o.jsx(Ks,{"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(Ed,{"aria-hidden":!0,size:15}),e("users.add")]})]}),r&&o.jsx("p",{className:"error",children:r}),o.jsx("div",{className:"table-card",children:o.jsxs("table",{children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{children:e("common.user")}),o.jsx("th",{children:e("users.role")}),o.jsx("th",{children:e("users.createProjects")}),o.jsx("th",{children:e("users.ownedProjects")}),o.jsx("th",{children:e("users.status")}),o.jsx("th",{children:e("users.actions")})]})}),o.jsx("tbody",{children:n.map(C=>o.jsxs("tr",{children:[o.jsxs("td",{children:[o.jsx("strong",{children:C.displayName}),o.jsxs("small",{children:["@",C.username]})]}),o.jsx("td",{children:C.role==="admin"?e("common.admin"):e("common.user")}),o.jsx("td",{children:C.canCreateProjects?e("users.allow"):e("users.deny")}),o.jsx("td",{children:C.ownedProjects}),o.jsx("td",{children:C.disabled?e("common.disabled"):e("common.normal")}),o.jsxs("td",{children:[o.jsx("button",{disabled:C.id===t.id,onClick:()=>N(C),children:C.disabled?e("users.enable"):e("users.disable")}),o.jsx("button",{disabled:C.id===t.id,onClick:()=>O(C),children:C.role==="admin"?e("users.demote"):e("users.promote")}),o.jsx("button",{disabled:C.role==="admin",onClick:()=>W(C),children:C.canCreateProjects?e("users.denyCreate"):e("users.allowCreate")}),o.jsx("button",{onClick:()=>{u(C),m("")},children:e("users.resetPassword")}),o.jsx("button",{className:"danger-text",disabled:C.id===t.id,onClick:()=>{w(C),v(!1)},children:e("common.delete")})]})]},C.id))})]})}),o.jsx(He,{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<tt,onClick:()=>{P()},children:e("users.createUser")})]}),children:o.jsxs("div",{className:"form-stack",children:[o.jsxs("label",{className:"form-field",children:[e("auth.username"),o.jsx("input",{value:l.username,onChange:C=>d({...l,username:C.target.value})})]}),o.jsxs("label",{className:"form-field",children:[e("users.displayName"),o.jsx("input",{value:l.displayName,onChange:C=>d({...l,displayName:C.target.value})})]}),o.jsxs("label",{className:"form-field",children:[e("users.initialPassword"),o.jsxs("span",{className:"password-generator",children:[o.jsx("input",{minLength:tt,autoComplete:"new-password",value:l.password,onChange:C=>d({...l,password:C.target.value})}),o.jsxs("button",{type:"button",title:e("users.generatePassword"),onClick:()=>d({...l,password:iv()}),children:[o.jsx($m,{size:15}),e("users.randomPassword")]})]}),o.jsx("small",{className:"field-hint",children:e("auth.passwordMinimum",{count:tt})})]}),o.jsxs("label",{className:"form-field",children:[e("users.role"),o.jsxs("select",{value:l.role,onChange:C=>d({...l,role:C.target.value}),children:[o.jsx("option",{value:"user",children:e("common.user")}),o.jsx("option",{value:"admin",children:e("common.admin")})]})]}),o.jsxs("label",{className:"checkbox-field",children:[o.jsx("input",{type:"checkbox",checked:l.canCreateProjects||l.role==="admin",disabled:l.role==="admin",onChange:C=>d({...l,canCreateProjects:C.target.checked})})," ",e("users.allowCreate")]})]})}),o.jsx(He,{open:!!f,title:e("users.resetPassword"),description:e("users.resetDescription",{username:f?.username??""}),onOpenChange:C=>{C||u(null)},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>u(null),children:e("common.cancel")}),o.jsx("button",{className:"primary",disabled:p.length<tt,onClick:()=>{E()},children:e("users.reset")})]}),children:o.jsxs("label",{className:"form-field",children:[e("auth.newPassword"),o.jsx("input",{autoFocus:!0,type:"password",minLength:tt,autoComplete:"new-password",value:p,onChange:C=>m(C.target.value)}),o.jsx("small",{className:"field-hint",children:e("auth.passwordMinimum",{count:tt})})]})}),o.jsx(He,{open:!!g,title:e("users.deleteTitle"),description:e("users.deleteDescription",{username:g?.username??""}),onOpenChange:C=>{C||w(null)},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>w(null),children:e("common.cancel")}),o.jsx("button",{className:"danger",onClick:()=>{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:()=>v(!1)})," ",e("users.transferProjects")]}),o.jsxs("label",{children:[o.jsx("input",{type:"radio",checked:b,onChange:()=>v(!0)})," ",e("users.deleteProjects")]})]})})]})}function av({site:t,user:e,projectId:n,onBack:s}){const{t:r}=Le(),[i,a]=h.useState(null),[c,l]=h.useState(!1),[d,f]=h.useState([]),[u,p]=h.useState(null),[m,g]=h.useState([]),[w,b]=h.useState(""),[v,k]=h.useState(""),[P,N]=h.useState(new Set),[O,W]=h.useState(""),[E,G]=h.useState(""),[C,V]=h.useState(!1),[Z,R]=h.useState("editor.saved"),[_,L]=h.useState(null),j=h.useRef(_);j.current=_;const[H,he]=h.useState({line:1,column:1}),Ce=h.useRef(H),[de,we]=h.useState("pdf"),[J,K]=h.useState("log"),me=y=>{if(y==="pdf"){we("pdf");return}K(y),we("diagnostics")},{workspaceLayout:ue,setWorkspaceLayout:D}=Kb(e.id,n),[re,te]=h.useState(""),[je,Oe]=h.useState(""),[Pe,oe]=h.useState({selectedText:"",startOffset:0,endOffset:0}),mt=h.useRef({selectedText:"",startOffset:0,endOffset:0}),gt=y=>{mt.current=y,oe(y)},[Ke,lt]=h.useState(null),[jt,B]=h.useState(!1),[ee,M]=h.useState(!1),[A,se]=h.useState(!1),[ge,Ge]=h.useState(!1),[$,Fe]=h.useState(null),[dt,_t]=h.useState(!1),[Wt,kt]=h.useState(!1),[rt,le]=h.useState(!1),[Ue,ut]=h.useState(()=>$c(e.id,n)),[et,Rt]=h.useState([]),Ie=h.useRef([]);Ie.current=et;const vn=h.useRef(null),ae=h.useRef(null),it=h.useRef(0),Ts=h.useRef(0),fr=h.useRef(""),ve=h.useRef(""),ot=h.useRef(""),In=h.useRef(""),pr=h.useRef(0),Et=h.useRef(null),ht=h.useRef(null),Lt=h.useRef(null),Kt=h.useRef(null),yt=h.useRef(!1),cn=h.useRef(null),mr=h.useRef(s);mr.current=s,ot.current=v;const gr=(y,S)=>{const T={line:y,column:S};Ce.current=T,he(T)},Sn=y=>{const S=Ie.current,T=y(S);T!==S&&(Ie.current=T,Rt(T))};h.useEffect(()=>{Ie.current=[],Rt([])},[n]);const Ns=y=>{const S=Ie.current,T=S.indexOf(y);if(T<0)return;const U=S.filter(Ee=>Ee!==y);if(Ie.current=U,Rt(U),ve.current!==y)return;const ce=U.length>0?U[Math.min(T,U.length-1)]:i?.mainFile??"";b(ce)},{collaboration:Je,status:Gt,synced:Ye,activeSessions:yr,compileState:At,setCompileState:Os,filesEvent:ke,commentsRevision:Ti,dictionaryRevision:Ps,localDraftReady:wr,permission:_s,reconnect:xr}=$b(n,e,v,i?.permission??"read",c,()=>R("editor.offlineDraft")),{pdfTarget:Ni,pdfViewport:Rs,sourceJump:x,setPdfViewport:ie,clearPdfViewport:ne,jumpToSource:Se,syncSourceToPdf:Me,syncPdfToSource:ze,syncVisiblePdfToSource:Jt}=Wb({projectId:n,mainFile:v,activeFile:w,onActiveFile:b,onError:te,onShowPdf:()=>me("pdf")}),wt=qb({active:!!(i&&w&&Ye&&Ue.spellCheck),activeFile:w,content:O,dictionaryWords:d});h.useEffect(()=>{ut($c(e.id,n))},[e.id,n]);const ln=y=>{fr.current=y,W(y)};h.useEffect(()=>{if(ve.current=w,Ce.current={line:1,column:1},he({line:1,column:1}),gt({selectedText:"",startOffset:0,endOffset:0}),!Ue.openFilesInTabs){Ie.current.length>0&&(Ie.current=[],Rt([]));return}w&&Sn(y=>y.includes(w)?y:[...y,w])},[w,Ue.openFilesInTabs,n]),h.useEffect(()=>{if(!C)return;const y=S=>{S.preventDefault(),S.returnValue=""};return window.addEventListener("beforeunload",y),()=>window.removeEventListener("beforeunload",y)},[C]),h.useEffect(()=>{if(Gt!=="disconnected")return;const y=new AbortController;return F(`/api/projects/${n}`,{signal:y.signal}).then(({project:S})=>{y.signal.aborted||(a(S),te(""))}).catch(S=>{if(!Qn(S)){if(S instanceof qo&&[401,403,404].includes(S.status)){te(q(S)),mr.current();return}te(r("errors.collaborationUnavailable"))}}),()=>y.abort()},[Gt,n,r]);const Ft=async(y={})=>{Et.current?.abort(),Et.current=null;const S=y.signal?null:new AbortController;S&&(Et.current=S);try{const T=await F(`/api/projects/${n}/completions`,{signal:y.signal??S?.signal});(!y.isCurrent||y.isCurrent())&&p(T.index)}catch(T){if(Qn(T))return;(!y.isCurrent||y.isCurrent())&&p(null)}finally{S&&Et.current===S&&(Et.current=null)}},Ls=async(y={},S=ot.current)=>{ht.current?.abort(),ht.current=null;const T=y.signal?null:new AbortController;T&&(ht.current=T);try{const U=S?`?mainFile=${encodeURIComponent(S)}`:"",ce=await F(`/api/projects/${n}/outline${U}`,{signal:y.signal??T?.signal});(!y.isCurrent||y.isCurrent())&&g(ce.outline)}catch(U){!Qn(U)&&(!y.isCurrent||y.isCurrent())&&g([])}finally{T&&ht.current===T&&(ht.current=null)}},$a=async(y={})=>{Lt.current?.abort(),Lt.current=null;const S=y.signal?null:new AbortController;S&&(Lt.current=S);try{const T=await F(`/api/projects/${n}/dictionary`,{signal:y.signal??S?.signal});(!y.isCurrent||y.isCurrent())&&f(T.words)}catch(T){if(Qn(T))return;(!y.isCurrent||y.isCurrent())&&f([])}finally{S&&Lt.current===S&&(Lt.current=null)}};h.useEffect(()=>{let y=!1;const S=++pr.current,T=new AbortController,U=()=>!y&&pr.current===S;let ce=!1;In.current="",a(null),Ba([]),g([]),b(""),k(""),N(new Set),W(""),G(""),Os(null),ne(),p(null),f([]),lh();const Ee=F(`/api/projects/${n}`,{signal:T.signal}).then(De=>{U()&&(ce=!0,a(De.project),b(De.project.mainFile),k(De.project.mainFile),N(new Set([De.project.mainFile])),Wa(new Set(Us(De.project.mainFile))))}).catch(De=>{U()&&te(q(De))}),fe=F(`/api/projects/${n}/files`,{signal:T.signal}).then(De=>{U()&&Ba(De.files)}).catch(De=>{U()&&te(q(De))});let un=null;return Promise.allSettled([Ee,fe]).then(()=>{!U()||!ce||(un=window.setTimeout(()=>{U()&&Promise.all([Ft({signal:T.signal,isCurrent:U}),$a({signal:T.signal,isCurrent:U})])},0))}),()=>{y=!0,un!==null&&window.clearTimeout(un),T.abort(),Et.current?.abort(),Et.current=null,ht.current?.abort(),ht.current=null,Lt.current?.abort(),Lt.current=null,Kt.current?.abort(),Kt.current=null}},[n]),h.useEffect(()=>{Ps&&$a()},[Ps,n]),h.useEffect(()=>{!i||Gt!=="connected"||_s===i.permission||a(y=>y&&{...y,permission:_s})},[_s,i?.permission]),h.useEffect(()=>{if(!ke)return;const y=ke.kind==="delete"&&!!ke.path&&kn(ke.path,ve.current),S=ke.kind==="delete"&&!!ke.path&&kn(ke.path,ot.current);if(ke.kind==="move"&&ke.source&&ke.destination){const U=ke.source,ce=ke.destination,Ee=fe=>fe===U?ce:fe.startsWith(`${U}/`)?`${ce}${fe.slice(U.length)}`:fe;b(fe=>Ee(fe)),k(fe=>Ee(fe)),N(fe=>new Set([...fe].map(Ee))),br(fe=>fe&&Ee(fe)),Sn(fe=>fe.map(Ee))}y&&(b(""),G(""),ln(""),Oe(r("editor.fileDeletedByCollaborator",{path:ke.path}))),ke.kind==="delete"&&ke.path&&(N(U=>new Set([...U].filter(ce=>!kn(ke.path,ce)))),br(U=>kn(ke.path,U)?"":U),Ha(U=>U&&kn(ke.path,U.path)?null:U),Sn(U=>U.filter(ce=>!kn(ke.path,ce)))),Kt.current?.abort();const T=new AbortController;Kt.current=T,Promise.all([ph({signal:T.signal}),F(`/api/projects/${n}`,{signal:T.signal})]).then(([U,ce])=>{if(a(ce.project),S&&k(ce.project.mainFile),y&&U){const Ee=U.find(fe=>fe.type==="file"&&fe.path===ce.project.mainFile)??U.find(fe=>fe.type==="file"&&ls(fe.path));b(Ee?.path??"")}Ft({signal:T.signal}),Ls({signal:T.signal},S?ce.project.mainFile:ot.current)}).catch(U=>{Qn(U)}).finally(()=>{Kt.current===T&&(Kt.current=null)})},[ke?.revision]),h.useEffect(()=>{if(Je.setActiveFile(w),!w)return;G(""),R("editor.loading");const y=Je.getText(w),S=(T,U)=>{ln(y.toString()),G(w),U?.local&&i?.permission!=="read"?(it.current+=1,V(!0),R("editor.pending")):it.current<=Ts.current&&R(j.current?"editor.savedAt":"editor.saved")};return y.observe(S),(Ye||wr)&&S(),()=>{y.unobserve(S)}},[w,Je,Ye,wr,i?.permission]),h.useEffect(()=>{!w||E!==w||In.current===w||(In.current=w,!(!w.toLocaleLowerCase().endsWith(".tex")||!cv(O))&&(N(y=>new Set([...y,w])),k(w)))},[w,E,O]);const Ua=async()=>{if(!Ye)throw new Error("Collaboration is not synchronized");const y=it.current,S=await Je.flush();return Ts.current=Math.max(Ts.current,y),L(S.persistedAt),/\.tex$/i.test(ve.current)&&Ls(),it.current===y?(V(!1),R("editor.savedAt")):R("editor.pending"),S};h.useEffect(()=>{if(!C||!w)return;if(!Ye){R("editor.offlineDraft");return}R("editor.pending");const y=window.setTimeout(()=>{R("editor.saving"),Ua().catch(()=>{R(Je.connected?"editor.saveFailed":"editor.offlineDraft")})},750);return()=>window.clearTimeout(y)},[O,C,w,Ye]);const As=async()=>{if(!i||i.permission==="read"||!Ye||!w)return!1;R("editor.saving");try{return await Ua(),Ft(),!0}catch(y){return R("editor.saveFailed"),te(q(y)||r("errors.collaborationUnavailable")),!1}},za=async(y,S)=>(await F(`/api/projects/${n}/format`,{method:"POST",body:JSON.stringify({path:y,source:S})})).formatted,uh=async()=>{if(!Ue.formatOnCompile||!i||i.permission==="read"||!Ye||!Xi(ve.current)||yt.current)return;const y=ve.current,S=Je.getText(y),T=S.toString();yt.current=!0,le(!0);try{const U=await za(y,T),ce=await Uc(T,U);if(ve.current!==y||S.toString()!==T)throw new Error(r("editor.formatSourceChanged"));ce.length&&Je.applyTextEdits(y,ce)}catch(U){te(r("editor.formatFailedContinue",{message:q(U)}))}finally{yt.current=!1,le(!1)}},hh=async()=>(cn.current&&await cn.current,await uh(),As()),fh=async()=>{if(!i||i.permission==="read"||!Ye||yt.current||!Xi(ve.current))return;const y=mt.current;if(!y.selectedText.trim()){Oe(r("editor.formatSelectionRequired"));return}const S=ve.current,{startOffset:T,endOffset:U,selectedText:ce}=y,Ee=Je.getText(S);if(Ee.toString().slice(T,U)!==ce){te(r("editor.formatSelectionChanged"));return}yt.current=!0,le(!0);let fe=()=>{};const un=new Promise(De=>{fe=De});cn.current=un;try{const De=lg(ce,await za(S,ce)),cc=await Uc(ce,De,T);if(ve.current!==S||Ee.toString().slice(T,U)!==ce){te(r("editor.formatSelectionChanged"));return}cc.length&&Je.applyTextEdits(S,cc),te(""),Oe(r("editor.formatSelectionComplete"))}catch(De){te(r("editor.formatFailed",{message:q(De)}))}finally{yt.current=!1,le(!1),fe(),cn.current===un&&(cn.current=null)}},{files:Yt,setFiles:Ba,loadFiles:ph,newFileOpen:mh,setNewFileOpen:Oi,newFilePath:gh,setNewFilePath:Va,resourcePreview:_e,setResourcePreview:Ha,resourcePreviewLoading:yh,setResourcePreviewLoading:wh,newFolderOpen:xh,setNewFolderOpen:Pi,newFolderName:bh,setNewFolderName:qa,fileDialogError:dn,setFileDialogError:Mn,selectedFolder:Xt,setSelectedFolder:br,expandedFolders:vh,setExpandedFolders:Wa,moveEntry:Fs,setMoveEntry:vr,moveDestination:Sh,setMoveDestination:_i,deleteEntry:$n,setDeleteEntry:Sr,fileDragActive:Ka,setFileDragActive:Ri,uploadConflict:Li,setUploadConflict:Ga,uploadingFiles:Cr,directoryEntries:Ch,visibleEntries:jh,createFile:kh,createFolder:Ja,uploadFiles:Ya,upload:Eh,openFile:Ai,movePath:Dh,removePath:Th}=Hb({projectId:n,site:t,activeFile:w,dirty:C,save:As,onError:te,onProject:a,onActiveFile:b,onActiveMainFile:k,onRootDocuments:N});h.useEffect(()=>{if(!Ue.openFilesInTabs||Yt.length===0)return;const y=new Set(Yt.filter(S=>S.type==="file"&&ls(S.path)).map(S=>S.path));Sn(S=>{const T=S.filter(U=>y.has(U));return T.length===S.length?S:T})},[Yt,Ue.openFilesInTabs]);const{comments:Is,focusComment:Nh,setFocusComment:Xa,commentOpen:Oh,setCommentOpen:Fi,commentText:Ph,setCommentText:_h,addComment:Rh,toggleComment:Lh,replyToComment:Ah,editComment:Fh,deleteComment:Ih,editCommentReply:Mh,deleteCommentReply:$h}=Ib({projectId:n,activeFile:w,permission:i?.permission,revision:Ti,selection:Pe,save:As,onError:te,onAdded:()=>lt("comments")}),{pdfUrl:It,pdfCompiledAt:Un,pdfLoading:Ii,compileLog:jr,compileDiagnostics:kr,compileOutcome:Er,artifacts:Mi,artifactPreview:Uh,artifactLoading:zh,editorNotice:Za,localCompiling:$i,cleaning:Qa,compile:Bh,cleanCompile:Vh,viewArtifact:Hh}=Ub({projectId:n,project:i,mainFile:v,collaborationSynced:Ye,sharedState:At,onSharedState:Os,save:hh,loadOutline:(y,S)=>Ls({signal:y},S),onPreviewTab:me,onError:te,onCompileStart:()=>{te(""),Oe("")},onCompileSuccess:()=>{const y=ve.current;y&&Me(y,Ce.current.line,Ce.current.column,{silent:!0})},onPdfChanged:ne});h.useEffect(()=>{if(!i||!v||!It&&Ii)return;const y=window.setTimeout(()=>l(!0),It?150:0);return()=>window.clearTimeout(y)},[i,Ii,It]),h.useEffect(()=>{const y=S=>{(S.ctrlKey||S.metaKey)&&(!S.shiftKey&&S.key.toLocaleLowerCase()==="p"?(S.preventDefault(),_t(!0)):S.shiftKey&&S.key.toLocaleLowerCase()==="f"&&(S.preventDefault(),kt(!0)))};return window.addEventListener("keydown",y,!0),()=>window.removeEventListener("keydown",y,!0)},[]);const qh=y=>{ut(y),og(e.id,n,y)},ec=()=>{ae.current?.isCollapsed()?ae.current.expand():ae.current?.collapse()},tc=h.useMemo(()=>m.length?m:lv(O).map(y=>({...y,path:w})),[m,O,w]),zn=h.useMemo(()=>dg(jr,Er),[jr,Er]),Bn=ue!=="pdf-only",nc=ue!=="editor-only",Dr=y=>{D(y),y==="pdf-only"&&me("pdf")},Ui=$n?yr.filter(y=>y.filePath&&kn($n.path,y.filePath)):[];if(!i)return o.jsxs("div",{className:"center-card",children:[o.jsx("p",{children:re||r("common.loading")}),re&&o.jsx("button",{className:"primary",onClick:s,children:r("editor.backToProjects")})]});const xt=i.permission==="read"||!Ye,Wh=(y,S)=>{if(xt)return;const T=ve.current;if(!T)return;if(Je.getText(T).toString().slice(y.from,y.to)!==y.word){te(r("editor.spellCheckSourceChanged"));return}try{Je.applyTextEdits(T,[{from:y.from,to:y.to,replacement:S}])}catch(Ee){te(q(Ee))}},Tr=At?.mainFile===v&&(At.status==="queued"||At.status==="running"),Vn=$i||Tr||Qa,sc=w?Je.getText(w):null,rc=Un?new Date(Un).toLocaleString(pe.resolvedLanguage,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"",Kh=v.split("/").at(-1)??v,Gh=zn.warnings.length+zn.errors.length+Mi.length,ic=It?`${It}${It.includes("?")?"&":"?"}download=1`:"",Jh=v||i.mainFile,Cn=!!(w&&w===Jh&&/\.tex$/i.test(w)),oc=y=>{const S=Yt.find(T=>T.path===y);S&&ls(S.path)?Ai(S):Ns(y)},Yh=y=>{document.getElementById(`editor-tab-${encodeURIComponent(y)}`)?.focus()},Xh=(y,S)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(y.key))return;y.preventDefault();const T=y.key==="Home"?0:y.key==="End"?et.length-1:(S+(y.key==="ArrowLeft"?-1:1)+et.length)%et.length,U=et[T];U&&(oc(U),window.requestAnimationFrame(()=>Yh(U)))},ac=Vn?Tr?At?.status==="queued"?r("editor.compileQueued"):r("editor.compilingBy",{name:At?.requestedBy.name??r("common.user")}):r("editor.compiling"):Er==="failed"?It&&Un?r("editor.compileFailedRetained",{time:new Date(Un).toLocaleString(pe.resolvedLanguage)}):r("editor.compileFailedNoPdf"):"",Zh=Z==="editor.savedAt"&&_?r("editor.savedAt",{time:new Date(_).toLocaleTimeString(pe.resolvedLanguage,{hour:"2-digit",minute:"2-digit",second:"2-digit"})}):r(Z);return o.jsxs("div",{className:"workspace",children:[o.jsxs("header",{className:"editor-topbar",children:[o.jsx("button",{className:"back",title:r("editor.backToProjects"),"aria-label":r("editor.backToProjects"),onClick:s,children:o.jsx(bd,{size:18})}),o.jsx(Di,{siteName:t.siteName,compact:!0}),o.jsxs("div",{className:"project-heading",children:[o.jsx("strong",{children:i.name}),o.jsxs("small",{children:[w," · ",Zh]})]}),Ue.vimMode&&o.jsxs("span",{className:"vim-status-badge",title:r("editor.vimOnHint"),children:[o.jsx(Hm,{size:14}),r("editor.vimOn")]}),o.jsx(Db,{sessions:yr,status:Gt}),Gt==="disconnected"&&o.jsxs("div",{className:"collaboration-recovery",role:"status",children:[o.jsx("span",{children:r("editor.collaboration.disconnected")}),o.jsx("button",{type:"button",onClick:xr,children:r("editor.collaboration.reconnect")})]}),o.jsxs("div",{className:"editor-actions",children:[Bn&&o.jsxs("button",{className:jt?"":"active",onClick:ec,children:[jt?o.jsx(Km,{size:15}):o.jsx(Fc,{size:15}),r("common.files")]}),o.jsx(Tb,{value:ue,onChange:Dr}),o.jsxs("button",{onClick:()=>Ge(!0),children:[o.jsx(jd,{size:15}),r("history.title")]}),o.jsxs("button",{onClick:()=>M(!0),children:[o.jsx(Ks,{size:15}),r("projectSettings.share")]}),i.ownerId===e.id&&o.jsxs("button",{onClick:()=>se(!0),children:[o.jsx(Vm,{size:15}),"Git"]}),Bn&&i.permission!=="read"&&Xi(w)&&o.jsxs("button",{title:Pe.selectedText.trim()?r("editor.formatSelection"):r("editor.formatSelectionHint"),onMouseDown:y=>y.preventDefault(),onClick:()=>{fh()},disabled:xt||rt||!Ye,children:[rt?o.jsx(Dt,{className:"spin",size:15}):o.jsx(xd,{size:15}),r(rt?"editor.formatting":"editor.formatSelection")]}),o.jsxs("button",{onClick:()=>Fi(!0),disabled:!w,children:[o.jsx(Wm,{size:15}),r("editor.addComment")]}),o.jsxs("button",{className:Ke==="comments"?"active":"",onClick:()=>lt(Ke==="comments"?null:"comments"),children:[o.jsx(No,{size:15}),r("common.comments")," ",Is.filter(y=>!y.resolved).length||""]}),o.jsxs("button",{className:Ke==="settings"?"active":"",onClick:()=>lt(Ke==="settings"?null:"settings"),children:[o.jsx(Ur,{size:15}),r("common.settings")]}),o.jsxs("button",{className:"compile",title:Tr?r("editor.compilingBy",{name:At?.requestedBy.name??""}):r("editor.compileShortcut"),onClick:Bh,disabled:Vn||rt||xt||!Ye,children:[Vn?o.jsx(Dt,{className:"spin",size:15}):o.jsx(Xm,{size:15}),Tr?r("editor.compilingBy",{name:At?.requestedBy.name??""}):$i?r("editor.compiling"):r("editor.compile",{engine:i.engine})]})]})]}),ac&&o.jsxs("div",{className:`compile-status-strip${Er==="failed"?" failed":""}`,role:"status","aria-live":"polite",children:[o.jsx(Dt,{className:Vn?"spin":"",size:14}),o.jsx("span",{children:ac})]}),re&&o.jsx("div",{className:"toast",onClick:()=>te(""),children:re}),je&&o.jsx("div",{className:"toast success",onClick:()=>Oe(""),children:je}),o.jsxs(tf,{autoSaveId:"texlite-workspace-layout",direction:"horizontal",className:"work-grid",children:[Bn&&o.jsx(Nr,{id:"files",order:1,ref:ae,defaultSize:16,minSize:12,maxSize:30,collapsible:!0,collapsedSize:0,onCollapse:()=>B(!0),onExpand:()=>B(!1),children:o.jsxs("aside",{className:"left-panel",children:[o.jsxs("section",{className:`files-panel${Ka?" drop-active":""}`,onDragEnter:y=>{y.dataTransfer.types.includes("Files")&&(y.preventDefault(),!xt&&!Cr&&Ri(!0))},onDragOver:y=>{y.dataTransfer.types.includes("Files")&&(y.preventDefault(),y.dataTransfer.dropEffect=xt||Cr?"none":"copy")},onDragLeave:y=>{y.currentTarget.contains(y.relatedTarget)||Ri(!1)},onDrop:y=>{y.preventDefault(),Ri(!1),!xt&&!Cr&&Ya(Array.from(y.dataTransfer.files))},children:[o.jsxs("div",{className:"panel-title",children:[o.jsxs("span",{children:[o.jsx(En,{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:()=>_t(!0),children:o.jsx(zm,{size:15})}),o.jsx("button",{"aria-label":r("navigation.projectSearch"),title:`${r("navigation.projectSearch")} (Ctrl/Cmd+Shift+F)`,onClick:()=>kt(!0),children:o.jsx(eg,{size:15})}),!xt&&o.jsxs(o.Fragment,{children:[o.jsx("button",{disabled:Cr,"aria-label":r("editor.uploadAttachment"),title:r("editor.uploadTo",{folder:Xt||r("editor.projectRoot")}),onClick:()=>vn.current?.click(),children:o.jsx(Yr,{size:15})}),o.jsx("button",{"aria-label":r("editor.newFolder"),title:r("editor.newFolder"),onClick:()=>{qa(""),Pi(!0)},children:o.jsx(Cd,{size:15})}),o.jsx("button",{"aria-label":r("editor.newFile"),title:r("editor.newFile"),onClick:()=>{Va(Xt?`${Xt}/`:""),Oi(!0)},children:o.jsx(Um,{size:15})}),o.jsx("input",{ref:vn,type:"file",multiple:!0,hidden:!0,onChange:y=>{Eh(y)}})]}),o.jsx("button",{"aria-label":r("editor.collapseFiles"),title:r("editor.collapseFiles"),onClick:ec,children:o.jsx(Fc,{size:15})})]})]}),Ka&&o.jsxs("div",{className:"file-drop-overlay",children:[o.jsx(Yr,{size:24}),o.jsx("strong",{children:r("editor.dropFiles")}),o.jsx("span",{children:r("editor.uploadTo",{folder:Xt||r("editor.projectRoot")})})]}),o.jsxs("div",{className:"folder-target",title:Xt||r("editor.projectRoot"),children:[o.jsx(Gr,{size:13}),o.jsx("span",{children:Xt||r("editor.projectRoot")})]}),o.jsxs("div",{className:"file-list",style:{fontSize:`${Ue.fontSize}px`},children:[o.jsx("div",{className:`file-entry folder-entry root-entry${Xt===""?" selected":""}`,children:o.jsxs("button",{className:"file-entry-main",onClick:()=>br(""),children:[o.jsx(Gr,{size:15}),o.jsx("span",{children:r("editor.projectRoot")})]})}),jh.map(y=>{const S=y.path.split("/").length-1,T=y.path.split("/").at(-1),U=vh.has(y.path),ce=P.has(y.path),Ee=v===y.path,fe=y.path!==i.mainFile&&!i.mainFile.startsWith(`${y.path}/`);return y.type==="directory"?o.jsxs("div",{className:`file-entry folder-entry${Xt===y.path?" selected":""}`,style:{paddingLeft:`${S*13+5}px`},children:[o.jsxs("button",{className:"file-entry-main",title:y.path,onClick:()=>{br(y.path),Wa(un=>{const De=new Set(un);return De.has(y.path)?De.delete(y.path):De.add(y.path),De})},children:[U?o.jsx(vd,{size:13}):o.jsx(sa,{size:13}),o.jsx(Bm,{size:14}),o.jsx("span",{children:T})]}),!xt&&o.jsxs(o.Fragment,{children:[o.jsx("button",{className:"file-entry-action",title:r("editor.move"),"aria-label":r("editor.move"),onClick:()=>{vr(y),_i("")},children:o.jsx(Ac,{size:13})}),fe&&o.jsx("button",{className:"file-entry-action danger-text",title:r("editor.deletePath"),"aria-label":r("editor.deletePath"),onClick:()=>{Sr(y),Mn("")},children:o.jsx(gn,{size:13})})]})]},y.path):o.jsxs("div",{className:`file-entry${w===y.path?" active":""}${ce?" root-document":""}${Ee?" compile-target":""}`,style:{paddingLeft:`${S*13+18}px`},children:[o.jsxs("button",{className:"file-entry-main",title:Ee?r("editor.currentMainDocument",{path:y.path}):ce?r("editor.mainDocumentCandidate",{path:y.path}):y.path,onClick:()=>Ai(y),children:[ce?o.jsx(Eo,{size:13}):o.jsx(En,{size:13}),o.jsx("span",{children:T}),Ee&&o.jsx("small",{children:r("editor.currentMainShort")})]}),!xt&&o.jsxs(o.Fragment,{children:[o.jsx("button",{className:"file-entry-action",title:r("editor.move"),"aria-label":r("editor.move"),onClick:()=>{vr(y),_i("")},children:o.jsx(Ac,{size:13})}),fe&&o.jsx("button",{className:"file-entry-action danger-text",title:r("editor.deletePath"),"aria-label":r("editor.deletePath"),onClick:()=>{Sr(y),Mn("")},children:o.jsx(gn,{size:13})})]})]},y.path)})]})]}),o.jsxs("section",{className:"outline-panel",children:[o.jsx("div",{className:"panel-title",children:o.jsxs("span",{children:[o.jsx(qm,{size:14}),r("common.outline")]})}),o.jsxs("div",{className:"outline",children:[tc.map((y,S)=>o.jsxs("button",{className:`outline-item${w===y.path&&H.line===y.line?" current":""}`,title:`${y.path}:${y.line}`,onClick:()=>{Se(y.path,y.line,1),Me(y.path,y.line,1)},children:[o.jsx("span",{className:"outline-guides","aria-hidden":!0,style:{width:`${y.level*12}px`}}),o.jsx("small",{children:y.path===w?y.line:y.path.split("/").at(-1)}),o.jsx("span",{className:"outline-title",children:y.title})]},`${y.path}-${y.line}-${S}`)),tc.length===0&&o.jsx("p",{className:"muted padded",children:r("editor.noOutline")})]})]})]})}),Bn&&o.jsx(zi,{className:"resize-handle",children:o.jsx(Yi,{size:12})}),Bn&&o.jsx(Nr,{id:"source",order:2,defaultSize:42,minSize:22,children:o.jsxs("main",{className:"source-panel",children:[Ue.openFilesInTabs&&et.length>0&&o.jsx("div",{className:"editor-tabs-bar",role:"tablist","aria-label":r("editor.openFiles"),children:o.jsx("div",{className:"editor-tabs-scroll",children:et.map((y,S)=>{const T=y===w,U=y===(v||i.mainFile),ce=y.split("/").at(-1)||y;return o.jsxs("div",{className:`editor-tab-item${T?" active":""}`,role:"presentation",children:[o.jsxs("button",{id:`editor-tab-${encodeURIComponent(y)}`,type:"button",role:"tab","aria-selected":T,"aria-controls":"editor-source-content",tabIndex:T?0:-1,className:`editor-tab${T?" active":""}${U?" main-tab":""}`,onClick:()=>oc(y),onKeyDown:Ee=>Xh(Ee,S),title:y,children:[o.jsx("span",{className:"editor-tab-icon",children:U?o.jsx(Eo,{size:13}):o.jsx(En,{size:13})}),o.jsx("span",{className:"editor-tab-title",children:ce}),U&&o.jsx("small",{className:"editor-tab-badge",children:r("editor.currentMainShort")})]}),o.jsx("button",{type:"button",className:"editor-tab-close",title:r("common.close"),"aria-label":`${r("common.close")} ${ce}`,onClick:()=>Ns(y),children:o.jsx(Xr,{size:12})})]},y)})})}),o.jsxs("div",{id:"editor-source-content",className:"editor-content-container",children:[o.jsx(h.Suspense,{fallback:o.jsxs("div",{className:"preview-empty",children:[o.jsx(Dt,{className:"spin",size:22}),o.jsx("span",{children:r("common.loading")})]}),children:o.jsx(Jb,{value:O,readOnly:xt,comments:Is,focusComment:Nh,preferences:Ue,completionIndex:u,spellCheckIssues:wt.issues,spellCheckJump:wt.jump,jumpTo:E===w&&x?.path===w?x:null,searchRequest:0,collaboration:sc?{text:sc,awareness:Je.awareness,undoManager:xt?void 0:Je.getUndoManager(w)}:void 0,onChange:ln,onSelection:(y,S,T)=>gt({selectedText:y,startOffset:S,endOffset:T}),onCommentClick:y=>{const S=Is.find(T=>T.id===y);S&&(Xa({...S}),lt("comments"))},onSpellCheckReplace:Wh,onCursor:gr},w)}),Za&&o.jsx("div",{className:"editor-centered-notice",role:"status","aria-live":"polite",children:Za})]})]})}),Bn&&nc&&o.jsxs(zi,{className:"resize-handle sync-resize-handle",children:[o.jsx(Yi,{className:"resize-grip",size:12}),o.jsxs("span",{className:"sync-direction-buttons",onPointerDown:y=>y.stopPropagation(),children:[o.jsx("button",{disabled:!Rs||!Cn,title:r(Cn?"editor.showInSource":"editor.syncTexOnlyForMain"),"aria-label":r("editor.showInSource"),onClick:()=>{if(!Cn){Oe(r("editor.syncTexOnlyForMain"));return}Jt()},children:o.jsx("span",{"aria-hidden":!0,children:"←"})}),o.jsx("button",{disabled:!w||!It||!Cn,title:r(Cn?"editor.showInPdf":"editor.syncTexOnlyForMain"),"aria-label":r("editor.showInPdf"),onClick:()=>{if(!Cn){Oe(r("editor.syncTexOnlyForMain"));return}Me(w,H.line,H.column)},children:o.jsx("span",{"aria-hidden":!0,children:"→"})})]})]}),nc&&o.jsx(Nr,{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":de==="pdf",className:`pdf-tab${de==="pdf"?" active":""}`,onClick:()=>me("pdf"),title:Un?r("editor.pdfCompiledAtFor",{file:v,time:new Date(Un).toLocaleString(pe.resolvedLanguage)}):r("editor.currentMainDocument",{path:v}),children:[o.jsx(En,{size:16}),o.jsxs("span",{className:"pdf-tab-label",children:["PDF · ",Kh,rc&&o.jsx("small",{children:rc})]})]}),o.jsxs("button",{role:"tab","aria-selected":de==="diagnostics",className:`diagnostics-tab${de==="diagnostics"?" active":""}`,onClick:()=>we("diagnostics"),children:[o.jsx(Po,{size:14}),r("editor.outputTabs"),o.jsx("span",{children:Gh})]})]}),ic&&o.jsxs("a",{className:"pdf-download-top",href:ic,download:!0,title:r("editor.downloadPdf"),"aria-label":r("editor.downloadPdf"),children:[o.jsx(Ws,{size:15}),o.jsx("span",{children:r("editor.downloadPdf")})]})]}),de==="diagnostics"&&o.jsxs("div",{className:"preview-subtabs",role:"tablist","aria-label":r("editor.outputTabs"),children:[o.jsxs("button",{role:"tab","aria-selected":J==="log",className:J==="log"?"active":"",onClick:()=>me("log"),children:[o.jsx(Po,{size:13}),r("editor.log")]}),o.jsxs("button",{role:"tab","aria-selected":J==="warnings",className:J==="warnings"?"active":"",onClick:()=>me("warnings"),children:[o.jsx(hs,{size:13}),r("editor.warnings"),o.jsx("span",{children:zn.warnings.length})]}),o.jsxs("button",{role:"tab","aria-selected":J==="errors",className:J==="errors"?"active":"",onClick:()=>me("errors"),children:[o.jsx(ra,{size:13}),r("editor.errors"),o.jsx("span",{children:zn.errors.length})]}),o.jsxs("button",{role:"tab","aria-selected":J==="artifacts",className:J==="artifacts"?"active":"",onClick:()=>me("artifacts"),children:[o.jsx(kd,{size:13}),r("editor.artifacts"),o.jsx("span",{children:Mi.length})]}),o.jsxs("button",{role:"tab","aria-selected":J==="clean",className:J==="clean"?"active":"",onClick:()=>me("clean"),children:[o.jsx(Do,{size:13}),r("editor.clean")]})]}),o.jsxs("div",{className:`preview-content preview-${de} ${de==="diagnostics"?`preview-${J}`:""}`,children:[de==="pdf"&&(It?o.jsx(h.Suspense,{fallback:o.jsxs("div",{className:"pdf-loading-state",role:"status","aria-live":"polite",children:[o.jsx(Dt,{className:"spin",size:24}),o.jsx("span",{children:r("editor.loadingPdf")})]}),children:o.jsx(Gb,{url:It,target:Ni,compiling:Vn,onViewportLocation:(y,S,T)=>ie({page:y,x:S,y:T}),onDoubleClickLocation:(y,S,T)=>{if(ie({page:y,x:S,y:T}),!Cn){Oe(r("editor.syncTexOnlyForMain"));return}ze(y,S,T)}})}):Ii?o.jsxs("div",{className:"pdf-loading-state",role:"status","aria-live":"polite",children:[o.jsx(Dt,{className:"spin",size:24}),o.jsx("span",{children:r("editor.loadingPdf")})]}):o.jsxs("div",{className:"preview-empty",children:[o.jsx(En,{size:28}),o.jsx("strong",{children:r("editor.preview")}),o.jsx("span",{children:r("editor.previewHint")})]})),de==="diagnostics"&&J==="log"&&o.jsx(fo,{lines:jr?jr.split(`
|
|
14
|
+
`):[],empty:r($i?"editor.compiling":"editor.noLog")}),de==="diagnostics"&&J==="warnings"&&(kr?o.jsx(Sl,{tone:"warning",diagnostics:kr.warnings,files:Yt,empty:r("editor.noWarnings"),onJump:(y,S,T)=>{ue==="pdf-only"&&Dr("editor-pdf"),Se(y,S,T)}}):o.jsx(fo,{tone:"warning",lines:zn.warnings,empty:r("editor.noWarnings")})),de==="diagnostics"&&J==="errors"&&(kr?o.jsx(Sl,{tone:"error",diagnostics:kr.errors,files:Yt,empty:r("editor.noErrors"),onJump:(y,S,T)=>{ue==="pdf-only"&&Dr("editor-pdf"),Se(y,S,T)}}):o.jsx(fo,{tone:"error",lines:zn.errors,empty:r("editor.noErrors")})),de==="diagnostics"&&J==="artifacts"&&o.jsx(_b,{projectId:n,mainFile:v,artifacts:Mi,preview:Uh,loading:zh,onView:y=>{Hh(y)}}),de==="diagnostics"&&J==="clean"&&o.jsx(Rb,{mainFile:v,disabled:xt||!Ye||Vn,cleaning:Qa,onCleanCache:()=>Fe("cache"),onCleanArtifacts:()=>Fe("artifacts")})]})]})}),Ke&&o.jsxs(o.Fragment,{children:[o.jsx(zi,{className:"resize-handle",children:o.jsx(Yi,{size:12})}),o.jsx(Nr,{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(Ke==="comments"?"editor.sourceComments":"editor.projectSettings")}),o.jsx("button",{"aria-label":r("common.close"),onClick:()=>lt(null),children:o.jsx(Xr,{size:17})})]}),Ke==="comments"&&o.jsxs("div",{className:"comments",children:[Is.map(y=>o.jsx(Nb,{comment:y,currentUserId:e.id,onFocus:()=>Xa({...y}),onToggle:()=>{Lh(y)},onReply:S=>Ah(y,S),onEdit:S=>Fh(y,S),onDelete:()=>Ih(y),onEditReply:(S,T)=>Mh(y,S,T),onDeleteReply:S=>$h(y,S)},y.id)),Is.length===0&&o.jsx("p",{className:"muted padded",children:r("editor.noComments")})]}),Ke==="settings"&&o.jsx(Pb,{project:i,projectId:n,site:t,files:Yt,dictionaryWords:d,onDictionaryChange:f,editorPreferences:Ue,onEditorPreferences:qh,spellCheckCount:wt.summary?.total??null,spellCheckUniqueCount:wt.summary?.unique??null,spellCheckIndex:wt.summary?wt.index:-1,onSpellCheckNavigate:wt.jumpToIssue,onProject:a})]})})]})]}),o.jsxs(He,{open:!!_e,extraWide:_e?.kind==="image"||_e?.kind==="pdf"||_e?.kind==="text",title:_e?.path??"",description:_e?.kind==="large"?r("editor.resourceTooLarge",{size:dh(_e.size),limit:"10 MB"}):r(`editor.resourcePreview.${_e?.kind??"text"}`),onOpenChange:y=>{y||(Ha(null),wh(!1))},footer:_e&&o.jsxs("a",{className:"primary resource-download",href:`${_e.url}&download=1`,download:!0,children:[o.jsx(Ws,{size:14}),r("editor.downloadResource")]}),children:[_e?.kind==="large"&&o.jsxs("div",{className:"resource-preview-message",children:[o.jsx(To,{size:34}),o.jsx("strong",{children:r("editor.resourceTooLargeTitle")}),o.jsx("span",{children:r("editor.resourceTooLargeDescription")})]}),_e?.kind==="unsupported"&&o.jsxs("div",{className:"resource-preview-message",children:[o.jsx(To,{size:34}),o.jsx("strong",{children:r("editor.resourceUnsupportedTitle")}),o.jsx("span",{children:r("editor.resourceUnsupportedDescription")})]}),_e?.kind==="image"&&o.jsx("div",{className:"resource-image-wrap",children:o.jsx("img",{className:"resource-image",src:_e.url,alt:_e.path})}),_e?.kind==="pdf"&&o.jsx("iframe",{className:"resource-pdf",src:_e.url,title:_e.path}),_e?.kind==="text"&&(yh?o.jsxs("div",{className:"resource-preview-message",children:[o.jsx(Dt,{className:"spin",size:24}),o.jsx("span",{children:r("common.loading")})]}):o.jsx("pre",{className:"resource-text",children:_e.content}))]}),o.jsx(us,{open:!!Li,title:r("editor.uploadOverwriteTitle"),description:r("editor.uploadOverwriteDescription",{files:Li?.collisions.join(", ")??""}),confirmLabel:r("editor.uploadOverwrite"),danger:!0,onCancel:()=>Ga(null),onConfirm:()=>{const y=Li;Ga(null),y&&Ya(y.files,new Set(y.collisions),y.directory)}}),o.jsx(us,{open:!!$,title:r($==="cache"?"editor.cleanCacheConfirmTitle":"editor.cleanArtifactsConfirmTitle"),description:r($==="cache"?"editor.cleanCacheConfirmDescription":"editor.cleanArtifactsConfirmDescription"),confirmLabel:r("editor.cleanConfirm"),danger:$==="artifacts",onCancel:()=>Fe(null),onConfirm:()=>{const y=$;Fe(null),y&&Vh(y)}}),o.jsx(He,{open:mh,title:r("editor.newFile"),description:r("editor.newFileDescription"),onOpenChange:y=>{Oi(y),y||Mn("")},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>Oi(!1),children:r("common.cancel")}),o.jsx("button",{className:"primary",onClick:()=>{kh()},children:r("common.create")})]}),children:o.jsxs(o.Fragment,{children:[dn&&o.jsx("p",{className:"error dialog-error",children:dn}),o.jsxs("label",{className:"form-field",children:[r("editor.filePath"),o.jsx("input",{autoFocus:!0,value:gh,onChange:y=>Va(y.target.value)})]})]})}),o.jsx(He,{open:xh,title:r("editor.newFolder"),description:r("editor.folderDestination",{folder:Xt||r("editor.projectRoot")}),onOpenChange:y=>{Pi(y),y||Mn("")},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>Pi(!1),children:r("common.cancel")}),o.jsx("button",{className:"primary",onClick:()=>{Ja()},children:r("common.create")})]}),children:o.jsxs(o.Fragment,{children:[dn&&o.jsx("p",{className:"error dialog-error",children:dn}),o.jsxs("label",{className:"form-field",children:[r("editor.folderName"),o.jsx("input",{autoFocus:!0,value:bh,onChange:y=>qa(y.target.value),onKeyDown:y=>{y.key==="Enter"&&Ja()}})]})]})}),o.jsx(He,{open:!!Fs,title:r("editor.moveTitle",{name:Fs?.path.split("/").at(-1)??""}),description:r("editor.moveDescription"),onOpenChange:y=>{y||(vr(null),Mn(""))},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>vr(null),children:r("common.cancel")}),o.jsx("button",{className:"primary",onClick:()=>{Dh()},children:r("editor.move")})]}),children:o.jsxs(o.Fragment,{children:[dn&&o.jsx("p",{className:"error dialog-error",children:dn}),o.jsxs("label",{className:"form-field",children:[r("editor.destinationFolder"),o.jsxs("select",{value:Sh,onChange:y=>_i(y.target.value),children:[o.jsx("option",{value:"",children:r("editor.projectRoot")}),Ch.filter(y=>Fs?.type!=="directory"||y.path!==Fs.path&&!y.path.startsWith(`${Fs.path}/`)).map(y=>o.jsx("option",{value:y.path,children:y.path},y.path))]})]})]})}),o.jsx(He,{open:!!$n,title:r("editor.deletePathTitle",{name:$n?.path.split("/").at(-1)??""}),description:Ui.length?r("editor.deletePathActiveDescription",{path:$n?.path??"",users:[...new Set(Ui.map(y=>y.name))].join(", ")}):r("editor.deletePathDescription",{path:$n?.path??""}),onOpenChange:y=>{y||(Sr(null),Mn(""))},footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>Sr(null),children:r("common.cancel")}),o.jsx("button",{className:"danger",onClick:()=>{Th()},children:r("common.delete")})]}),children:o.jsxs(o.Fragment,{children:[dn&&o.jsx("p",{className:"error dialog-error",children:dn}),Ui.length>0&&o.jsxs("p",{className:"warning",children:[o.jsx(hs,{size:15}),r("editor.deletePathWillClose")]})]})}),o.jsxs(He,{open:Oh,title:r("editor.addComment"),description:Pe.selectedText?r("editor.commentDescription",{count:Pe.endOffset-Pe.startOffset}):r("editor.pointComment"),onOpenChange:Fi,footer:o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>Fi(!1),children:r("common.cancel")}),o.jsx("button",{className:"primary",onClick:()=>{Rh()},children:r("editor.addComment")})]}),children:[o.jsxs("label",{className:"form-field",children:[r("editor.commentContent"),o.jsx("textarea",{autoFocus:!0,rows:5,value:Ph,onChange:y=>_h(y.target.value)})]}),Pe.selectedText&&o.jsx("blockquote",{className:"selection-preview",children:Pe.selectedText})]}),o.jsx(Ob,{open:ee,onOpenChange:M,project:i,projectId:n}),dt&&o.jsx(h.Suspense,{fallback:null,children:o.jsx(Qb,{open:!0,files:Yt,onOpenChange:_t,onOpenFile:y=>{const S=Yt.find(T=>T.path===y);S&&Ai(S)}})}),Wt&&o.jsx(h.Suspense,{fallback:null,children:o.jsx(Zb,{open:!0,project:i,onOpenChange:kt,onJump:(y,S,T)=>{ue==="pdf-only"&&Dr("editor-pdf"),Se(y,S,T)}})}),ge&&o.jsx(h.Suspense,{fallback:null,children:o.jsx(Xb,{open:!0,onOpenChange:Ge,project:i,onBeforeMutation:i.permission==="read"?async()=>!0:As})}),i.ownerId===e.id&&A&&o.jsx(h.Suspense,{fallback:null,children:o.jsx(Yb,{open:!0,onOpenChange:se,project:i,onBeforeMutation:As})})]})}function cv(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 dh(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`}function lv(t){const e=[],n=/^\s*\\(part|chapter|section|subsection|subsubsection)\*?(?:\[[^\]]*\])?\{([^}]*)\}/,s={part:0,chapter:0,section:1,subsection:2,subsubsection:3};return t.split(`
|
|
17
|
+
`).forEach((r,i)=>{const a=r.match(n);a&&e.push({level:s[a[1]],title:a[2],line:i+1})}),e}class dv extends h.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,n){console.error("Uncaught error in component tree:",e,n)}handleReset=()=>{this.setState({hasError:!1,error:null}),this.props.onReset?.()};render(){return this.state.hasError?typeof this.props.fallback=="function"?this.props.fallback(this.state.error??new Error("Unknown error"),this.handleReset):this.props.fallback?this.props.fallback:o.jsxs("div",{role:"alert",style:{padding:"2rem",margin:"1rem",borderRadius:"8px",backgroundColor:"var(--bg-secondary, #f8f9fa)",border:"1px solid var(--border-color, #e9ecef)",color:"var(--text-primary, #212529)",fontFamily:"system-ui, -apple-system, sans-serif"},children:[o.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:600,marginBottom:"0.5rem",color:"#dc3545"},children:this.props.title??pe.t("errors.boundaryTitle")}),o.jsx("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary, #6c757d)",marginBottom:"1rem"},children:pe.t("errors.boundaryDescription")}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[o.jsx("button",{type:"button",onClick:this.handleReset,className:"primary",style:{padding:"0.4rem 0.8rem",borderRadius:"4px",cursor:"pointer"},children:pe.t("errors.boundaryRetry")}),o.jsx("button",{type:"button",onClick:()=>window.location.reload(),style:{padding:"0.4rem 0.8rem",borderRadius:"4px",cursor:"pointer"},children:pe.t("errors.boundaryReload")})]})]}):this.props.children}}nf.createRoot(document.getElementById("root")).render(o.jsx(h.StrictMode,{children:o.jsx(dv,{children:o.jsx(tv,{})})}));export{Om as A,vd as C,En as F,Vm as G,Dt as L,He as M,Qm as R,Jr as S,gn as T,Kw as U,on as _,wv as a,xv as b,yv as c,bv as d,Rn as e,pv as f,Qt as g,fv as h,I as i,sa as j,F as k,us as l,ca as m,eg as n,zm as o,Lm as p,gv as r,mv as t};
|