diff --git a/reader/dist/assets/index-BM-0-Di-.js b/reader/dist/assets/index-CZd2EwCp.js
similarity index 99%
rename from reader/dist/assets/index-BM-0-Di-.js
rename to reader/dist/assets/index-CZd2EwCp.js
index 04d15c5..d155ada 100644
--- a/reader/dist/assets/index-BM-0-Di-.js
+++ b/reader/dist/assets/index-CZd2EwCp.js
@@ -117,7 +117,7 @@ Please report this to https://github.com/markedjs/marked.`,a){const r="
An err
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(u){return u instanceof this?u:new this(u)}static concat(u,...s){const r=new this(u);return s.forEach(o=>r.set(o)),r}static accessor(u){const r=(this[wp]=this[wp]={accessors:{}}).accessors,o=this.prototype;function f(p){const m=lu(p);r[m]||(Bv(o,p),r[m]=!0)}return M.isArray(u)?u.forEach(f):f(u),this}};ot.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);M.reduceDescriptors(ot.prototype,({value:a},u)=>{let s=u[0].toUpperCase()+u.slice(1);return{get:()=>a,set(r){this[s]=r}}});M.freezeMethods(ot);function Tc(a,u){const s=this||du,r=u||s,o=ot.from(r.headers);let f=r.data;return M.forEach(a,function(m){f=m.call(s,f,o.normalize(),u?u.status:void 0)}),o.normalize(),f}function Rm(a){return!!(a&&a.__CANCEL__)}function Il(a,u,s){ae.call(this,a??"canceled",ae.ERR_CANCELED,u,s),this.name="CanceledError"}M.inherits(Il,ae,{__CANCEL__:!0});function Am(a,u,s){const r=s.config.validateStatus;!s.status||!r||r(s.status)?a(s):u(new ae("Request failed with status code "+s.status,[ae.ERR_BAD_REQUEST,ae.ERR_BAD_RESPONSE][Math.floor(s.status/100)-4],s.config,s.request,s))}function Lv(a){const u=/^([-+\w]{1,25})(:?\/\/|:)/.exec(a);return u&&u[1]||""}function Hv(a,u){a=a||10;const s=new Array(a),r=new Array(a);let o=0,f=0,p;return u=u!==void 0?u:1e3,function(b){const h=Date.now(),g=r[f];p||(p=h),s[o]=b,r[o]=h;let w=f,E=0;for(;w!==o;)E+=s[w++],w=w%a;if(o=(o+1)%a,o===f&&(f=(f+1)%a),h-p{s=g,o=null,f&&(clearTimeout(f),f=null),a.apply(null,h)};return[(...h)=>{const g=Date.now(),w=g-s;w>=r?p(h,g):(o=h,f||(f=setTimeout(()=>{f=null,p(o)},r-w)))},()=>o&&p(o)]}const qi=(a,u,s=3)=>{let r=0;const o=Hv(50,250);return qv(f=>{const p=f.loaded,m=f.lengthComputable?f.total:void 0,b=p-r,h=o(b),g=p<=m;r=p;const w={loaded:p,total:m,progress:m?p/m:void 0,bytes:b,rate:h||void 0,estimated:h&&m&&g?(m-p)/h:void 0,event:f,lengthComputable:m!=null,[u?"download":"upload"]:!0};a(w)},s)},Rp=(a,u)=>{const s=a!=null;return[r=>u[0]({lengthComputable:s,total:a,loaded:r}),u[1]]},Ap=a=>(...u)=>M.asap(()=>a(...u)),Yv=et.hasStandardBrowserEnv?((a,u)=>s=>(s=new URL(s,et.origin),a.protocol===s.protocol&&a.host===s.host&&(u||a.port===s.port)))(new URL(et.origin),et.navigator&&/(msie|trident)/i.test(et.navigator.userAgent)):()=>!0,Gv=et.hasStandardBrowserEnv?{write(a,u,s,r,o,f){const p=[a+"="+encodeURIComponent(u)];M.isNumber(s)&&p.push("expires="+new Date(s).toGMTString()),M.isString(r)&&p.push("path="+r),M.isString(o)&&p.push("domain="+o),f===!0&&p.push("secure"),document.cookie=p.join("; ")},read(a){const u=document.cookie.match(new RegExp("(^|;\\s*)("+a+")=([^;]*)"));return u?decodeURIComponent(u[3]):null},remove(a){this.write(a,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Zv(a){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(a)}function Xv(a,u){return u?a.replace(/\/?\/$/,"")+"/"+u.replace(/^\/+/,""):a}function Om(a,u,s){let r=!Zv(u);return a&&(r||s==!1)?Xv(a,u):u}const Op=a=>a instanceof ot?{...a}:a;function sl(a,u){u=u||{};const s={};function r(h,g,w,E){return M.isPlainObject(h)&&M.isPlainObject(g)?M.merge.call({caseless:E},h,g):M.isPlainObject(g)?M.merge({},g):M.isArray(g)?g.slice():g}function o(h,g,w,E){if(M.isUndefined(g)){if(!M.isUndefined(h))return r(void 0,h,w,E)}else return r(h,g,w,E)}function f(h,g){if(!M.isUndefined(g))return r(void 0,g)}function p(h,g){if(M.isUndefined(g)){if(!M.isUndefined(h))return r(void 0,h)}else return r(void 0,g)}function m(h,g,w){if(w in u)return r(h,g);if(w in a)return r(void 0,h)}const b={url:f,method:f,data:f,baseURL:p,transformRequest:p,transformResponse:p,paramsSerializer:p,timeout:p,timeoutMessage:p,withCredentials:p,withXSRFToken:p,adapter:p,responseType:p,xsrfCookieName:p,xsrfHeaderName:p,onUploadProgress:p,onDownloadProgress:p,decompress:p,maxContentLength:p,maxBodyLength:p,beforeRedirect:p,transport:p,httpAgent:p,httpsAgent:p,cancelToken:p,socketPath:p,responseEncoding:p,validateStatus:m,headers:(h,g,w)=>o(Op(h),Op(g),w,!0)};return M.forEach(Object.keys(Object.assign({},a,u)),function(g){const w=b[g]||o,E=w(a[g],u[g],g);M.isUndefined(E)&&w!==m||(s[g]=E)}),s}const zm=a=>{const u=sl({},a);let{data:s,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:f,headers:p,auth:m}=u;u.headers=p=ot.from(p),u.url=Em(Om(u.baseURL,u.url,u.allowAbsoluteUrls),a.params,a.paramsSerializer),m&&p.set("Authorization","Basic "+btoa((m.username||"")+":"+(m.password?unescape(encodeURIComponent(m.password)):"")));let b;if(M.isFormData(s)){if(et.hasStandardBrowserEnv||et.hasStandardBrowserWebWorkerEnv)p.setContentType(void 0);else if((b=p.getContentType())!==!1){const[h,...g]=b?b.split(";").map(w=>w.trim()).filter(Boolean):[];p.setContentType([h||"multipart/form-data",...g].join("; "))}}if(et.hasStandardBrowserEnv&&(r&&M.isFunction(r)&&(r=r(u)),r||r!==!1&&Yv(u.url))){const h=o&&f&&Gv.read(f);h&&p.set(o,h)}return u},Vv=typeof XMLHttpRequest<"u",Qv=Vv&&function(a){return new Promise(function(s,r){const o=zm(a);let f=o.data;const p=ot.from(o.headers).normalize();let{responseType:m,onUploadProgress:b,onDownloadProgress:h}=o,g,w,E,U,T;function k(){U&&U(),T&&T(),o.cancelToken&&o.cancelToken.unsubscribe(g),o.signal&&o.signal.removeEventListener("abort",g)}let D=new XMLHttpRequest;D.open(o.method.toUpperCase(),o.url,!0),D.timeout=o.timeout;function q(){if(!D)return;const G=ot.from("getAllResponseHeaders"in D&&D.getAllResponseHeaders()),$={data:!m||m==="text"||m==="json"?D.responseText:D.response,status:D.status,statusText:D.statusText,headers:G,config:a,request:D};Am(function(F){s(F),k()},function(F){r(F),k()},$),D=null}"onloadend"in D?D.onloadend=q:D.onreadystatechange=function(){!D||D.readyState!==4||D.status===0&&!(D.responseURL&&D.responseURL.indexOf("file:")===0)||setTimeout(q)},D.onabort=function(){D&&(r(new ae("Request aborted",ae.ECONNABORTED,a,D)),D=null)},D.onerror=function(){r(new ae("Network Error",ae.ERR_NETWORK,a,D)),D=null},D.ontimeout=function(){let te=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const $=o.transitional||Tm;o.timeoutErrorMessage&&(te=o.timeoutErrorMessage),r(new ae(te,$.clarifyTimeoutError?ae.ETIMEDOUT:ae.ECONNABORTED,a,D)),D=null},f===void 0&&p.setContentType(null),"setRequestHeader"in D&&M.forEach(p.toJSON(),function(te,$){D.setRequestHeader($,te)}),M.isUndefined(o.withCredentials)||(D.withCredentials=!!o.withCredentials),m&&m!=="json"&&(D.responseType=o.responseType),h&&([E,T]=qi(h,!0),D.addEventListener("progress",E)),b&&D.upload&&([w,U]=qi(b),D.upload.addEventListener("progress",w),D.upload.addEventListener("loadend",U)),(o.cancelToken||o.signal)&&(g=G=>{D&&(r(!G||G.type?new Il(null,a,D):G),D.abort(),D=null)},o.cancelToken&&o.cancelToken.subscribe(g),o.signal&&(o.signal.aborted?g():o.signal.addEventListener("abort",g)));const Z=Lv(o.url);if(Z&&et.protocols.indexOf(Z)===-1){r(new ae("Unsupported protocol "+Z+":",ae.ERR_BAD_REQUEST,a));return}D.send(f||null)})},$v=(a,u)=>{const{length:s}=a=a?a.filter(Boolean):[];if(u||s){let r=new AbortController,o;const f=function(h){if(!o){o=!0,m();const g=h instanceof Error?h:this.reason;r.abort(g instanceof ae?g:new Il(g instanceof Error?g.message:g))}};let p=u&&setTimeout(()=>{p=null,f(new ae(`timeout ${u} of ms exceeded`,ae.ETIMEDOUT))},u);const m=()=>{a&&(p&&clearTimeout(p),p=null,a.forEach(h=>{h.unsubscribe?h.unsubscribe(f):h.removeEventListener("abort",f)}),a=null)};a.forEach(h=>h.addEventListener("abort",f));const{signal:b}=r;return b.unsubscribe=()=>M.asap(m),b}},Kv=function*(a,u){let s=a.byteLength;if(s{const o=Jv(a,u);let f=0,p,m=b=>{p||(p=!0,r&&r(b))};return new ReadableStream({async pull(b){try{const{done:h,value:g}=await o.next();if(h){m(),b.close();return}let w=g.byteLength;if(s){let E=f+=w;s(E)}b.enqueue(new Uint8Array(g))}catch(h){throw m(h),h}},cancel(b){return m(b),o.return()}},{highWaterMark:2})},Wi=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",_m=Wi&&typeof ReadableStream=="function",Wv=Wi&&(typeof TextEncoder=="function"?(a=>u=>a.encode(u))(new TextEncoder):async a=>new Uint8Array(await new Response(a).arrayBuffer())),Nm=(a,...u)=>{try{return!!a(...u)}catch{return!1}},Pv=_m&&Nm(()=>{let a=!1;const u=new Request(et.origin,{body:new ReadableStream,method:"POST",get duplex(){return a=!0,"half"}}).headers.has("Content-Type");return a&&!u}),_p=64*1024,Uc=_m&&Nm(()=>M.isReadableStream(new Response("").body)),Yi={stream:Uc&&(a=>a.body)};Wi&&(a=>{["text","arrayBuffer","blob","formData","stream"].forEach(u=>{!Yi[u]&&(Yi[u]=M.isFunction(a[u])?s=>s[u]():(s,r)=>{throw new ae(`Response type '${u}' is not supported`,ae.ERR_NOT_SUPPORT,r)})})})(new Response);const Iv=async a=>{if(a==null)return 0;if(M.isBlob(a))return a.size;if(M.isSpecCompliantForm(a))return(await new Request(et.origin,{method:"POST",body:a}).arrayBuffer()).byteLength;if(M.isArrayBufferView(a)||M.isArrayBuffer(a))return a.byteLength;if(M.isURLSearchParams(a)&&(a=a+""),M.isString(a))return(await Wv(a)).byteLength},ex=async(a,u)=>{const s=M.toFiniteNumber(a.getContentLength());return s??Iv(u)},tx=Wi&&(async a=>{let{url:u,method:s,data:r,signal:o,cancelToken:f,timeout:p,onDownloadProgress:m,onUploadProgress:b,responseType:h,headers:g,withCredentials:w="same-origin",fetchOptions:E}=zm(a);h=h?(h+"").toLowerCase():"text";let U=$v([o,f&&f.toAbortSignal()],p),T;const k=U&&U.unsubscribe&&(()=>{U.unsubscribe()});let D;try{if(b&&Pv&&s!=="get"&&s!=="head"&&(D=await ex(g,r))!==0){let $=new Request(u,{method:"POST",body:r,duplex:"half"}),oe;if(M.isFormData(r)&&(oe=$.headers.get("content-type"))&&g.setContentType(oe),$.body){const[F,Ae]=Rp(D,qi(Ap(b)));r=zp($.body,_p,F,Ae)}}M.isString(w)||(w=w?"include":"omit");const q="credentials"in Request.prototype;T=new Request(u,{...E,signal:U,method:s.toUpperCase(),headers:g.normalize().toJSON(),body:r,duplex:"half",credentials:q?w:void 0});let Z=await fetch(T,E);const G=Uc&&(h==="stream"||h==="response");if(Uc&&(m||G&&k)){const $={};["status","statusText","headers"].forEach(Ee=>{$[Ee]=Z[Ee]});const oe=M.toFiniteNumber(Z.headers.get("content-length")),[F,Ae]=m&&Rp(oe,qi(Ap(m),!0))||[];Z=new Response(zp(Z.body,_p,F,()=>{Ae&&Ae(),k&&k()}),$)}h=h||"text";let te=await Yi[M.findKey(Yi,h)||"text"](Z,a);return!G&&k&&k(),await new Promise(($,oe)=>{Am($,oe,{data:te,headers:ot.from(Z.headers),status:Z.status,statusText:Z.statusText,config:a,request:T})})}catch(q){throw k&&k(),q&&q.name==="TypeError"&&/Load failed|fetch/i.test(q.message)?Object.assign(new ae("Network Error",ae.ERR_NETWORK,a,T),{cause:q.cause||q}):ae.from(q,q&&q.code,a,T)}}),kc={http:gv,xhr:Qv,fetch:tx};M.forEach(kc,(a,u)=>{if(a){try{Object.defineProperty(a,"name",{value:u})}catch{}Object.defineProperty(a,"adapterName",{value:u})}});const Np=a=>`- ${a}`,nx=a=>M.isFunction(a)||a===null||a===!1,Cm={getAdapter:a=>{a=M.isArray(a)?a:[a];const{length:u}=a;let s,r;const o={};for(let f=0;f`adapter ${m} `+(b===!1?"is not supported by the environment":"is not available in the build"));let p=u?f.length>1?`since :
`+f.map(Np).join(`
`):" "+Np(f[0]):"as no adapter specified";throw new ae("There is no suitable adapter to dispatch the request "+p,"ERR_NOT_SUPPORT")}return r},adapters:kc};function wc(a){if(a.cancelToken&&a.cancelToken.throwIfRequested(),a.signal&&a.signal.aborted)throw new Il(null,a)}function Cp(a){return wc(a),a.headers=ot.from(a.headers),a.data=Tc.call(a,a.transformRequest),["post","put","patch"].indexOf(a.method)!==-1&&a.headers.setContentType("application/x-www-form-urlencoded",!1),Cm.getAdapter(a.adapter||du.adapter)(a).then(function(r){return wc(a),r.data=Tc.call(a,a.transformResponse,r),r.headers=ot.from(r.headers),r},function(r){return Rm(r)||(wc(a),r&&r.response&&(r.response.data=Tc.call(a,a.transformResponse,r.response),r.response.headers=ot.from(r.response.headers))),Promise.reject(r)})}const Mm="1.10.0",Pi={};["object","boolean","number","function","string","symbol"].forEach((a,u)=>{Pi[a]=function(r){return typeof r===a||"a"+(u<1?"n ":" ")+a}});const Mp={};Pi.transitional=function(u,s,r){function o(f,p){return"[Axios v"+Mm+"] Transitional option '"+f+"'"+p+(r?". "+r:"")}return(f,p,m)=>{if(u===!1)throw new ae(o(p," has been removed"+(s?" in "+s:"")),ae.ERR_DEPRECATED);return s&&!Mp[p]&&(Mp[p]=!0,console.warn(o(p," has been deprecated since v"+s+" and will be removed in the near future"))),u?u(f,p,m):!0}};Pi.spelling=function(u){return(s,r)=>(console.warn(`${r} is likely a misspelling of ${u}`),!0)};function lx(a,u,s){if(typeof a!="object")throw new ae("options must be an object",ae.ERR_BAD_OPTION_VALUE);const r=Object.keys(a);let o=r.length;for(;o-- >0;){const f=r[o],p=u[f];if(p){const m=a[f],b=m===void 0||p(m,f,a);if(b!==!0)throw new ae("option "+f+" must be "+b,ae.ERR_BAD_OPTION_VALUE);continue}if(s!==!0)throw new ae("Unknown option "+f,ae.ERR_BAD_OPTION)}}const Ui={assertOptions:lx,validators:Pi},Xt=Ui.validators;let il=class{constructor(u){this.defaults=u||{},this.interceptors={request:new Tp,response:new Tp}}async request(u,s){try{return await this._request(u,s)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const f=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?f&&!String(r.stack).endsWith(f.replace(/^.+\n.+\n/,""))&&(r.stack+=`
-`+f):r.stack=f}catch{}}throw r}}_request(u,s){typeof u=="string"?(s=s||{},s.url=u):s=u||{},s=sl(this.defaults,s);const{transitional:r,paramsSerializer:o,headers:f}=s;r!==void 0&&Ui.assertOptions(r,{silentJSONParsing:Xt.transitional(Xt.boolean),forcedJSONParsing:Xt.transitional(Xt.boolean),clarifyTimeoutError:Xt.transitional(Xt.boolean)},!1),o!=null&&(M.isFunction(o)?s.paramsSerializer={serialize:o}:Ui.assertOptions(o,{encode:Xt.function,serialize:Xt.function},!0)),s.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?s.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:s.allowAbsoluteUrls=!0),Ui.assertOptions(s,{baseUrl:Xt.spelling("baseURL"),withXsrfToken:Xt.spelling("withXSRFToken")},!0),s.method=(s.method||this.defaults.method||"get").toLowerCase();let p=f&&M.merge(f.common,f[s.method]);f&&M.forEach(["delete","get","head","post","put","patch","common"],T=>{delete f[T]}),s.headers=ot.concat(p,f);const m=[];let b=!0;this.interceptors.request.forEach(function(k){typeof k.runWhen=="function"&&k.runWhen(s)===!1||(b=b&&k.synchronous,m.unshift(k.fulfilled,k.rejected))});const h=[];this.interceptors.response.forEach(function(k){h.push(k.fulfilled,k.rejected)});let g,w=0,E;if(!b){const T=[Cp.bind(this),void 0];for(T.unshift.apply(T,m),T.push.apply(T,h),E=T.length,g=Promise.resolve(s);w{if(!r._listeners)return;let f=r._listeners.length;for(;f-- >0;)r._listeners[f](o);r._listeners=null}),this.promise.then=o=>{let f;const p=new Promise(m=>{r.subscribe(m),f=m}).then(o);return p.cancel=function(){r.unsubscribe(f)},p},u(function(f,p,m){r.reason||(r.reason=new Il(f,p,m),s(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(u){if(this.reason){u(this.reason);return}this._listeners?this._listeners.push(u):this._listeners=[u]}unsubscribe(u){if(!this._listeners)return;const s=this._listeners.indexOf(u);s!==-1&&this._listeners.splice(s,1)}toAbortSignal(){const u=new AbortController,s=r=>{u.abort(r)};return this.subscribe(s),u.signal.unsubscribe=()=>this.unsubscribe(s),u.signal}static source(){let u;return{token:new Dm(function(o){u=o}),cancel:u}}};function ux(a){return function(s){return a.apply(null,s)}}function ix(a){return M.isObject(a)&&a.isAxiosError===!0}const Bc={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Bc).forEach(([a,u])=>{Bc[u]=a});function jm(a){const u=new il(a),s=om(il.prototype.request,u);return M.extend(s,il.prototype,u,{allOwnKeys:!0}),M.extend(s,u,null,{allOwnKeys:!0}),s.create=function(o){return jm(sl(a,o))},s}const Ue=jm(du);Ue.Axios=il;Ue.CanceledError=Il;Ue.CancelToken=ax;Ue.isCancel=Rm;Ue.VERSION=Mm;Ue.toFormData=Fi;Ue.AxiosError=ae;Ue.Cancel=Ue.CanceledError;Ue.all=function(u){return Promise.all(u)};Ue.spread=ux;Ue.isAxiosError=ix;Ue.mergeConfig=sl;Ue.AxiosHeaders=ot;Ue.formToJSON=a=>wm(M.isHTMLForm(a)?new FormData(a):a);Ue.getAdapter=Cm.getAdapter;Ue.HttpStatusCode=Bc;Ue.default=Ue;const{Axios:Qx,AxiosError:$x,CanceledError:Kx,isCancel:Jx,CancelToken:Fx,VERSION:Wx,all:Px,Cancel:Ix,isAxiosError:eS,spread:tS,toFormData:nS,AxiosHeaders:lS,HttpStatusCode:aS,formToJSON:uS,getAdapter:iS,mergeConfig:rS}=Ue,rx="https://api.med.tomastm.com",sx="https://resources.med.tomastm.com",Um=Ue.create({baseURL:rx,timeout:1e3}),km=Ue.create({baseURL:sx,timeout:1e3}),Dp=a=>{let u;const s=new Set,r=(h,g)=>{const w=typeof h=="function"?h(u):h;if(!Object.is(w,u)){const E=u;u=g??(typeof w!="object"||w===null)?w:Object.assign({},u,w),s.forEach(U=>U(u,E))}},o=()=>u,m={setState:r,getState:o,getInitialState:()=>b,subscribe:h=>(s.add(h),()=>s.delete(h))},b=u=a(r,o,m);return m},cx=a=>a?Dp(a):Dp,ox=a=>a;function fx(a,u=ox){const s=Ac.useSyncExternalStore(a.subscribe,()=>u(a.getState()),()=>u(a.getInitialState()));return Ac.useDebugValue(s),s}const jp=a=>{const u=cx(a),s=r=>fx(u,r);return Object.assign(s,u),s},dx=a=>a?jp(a):jp;function hx(){let a=localStorage.getItem("subject");return typeof a>"u"&&(a=0),a=parseInt(a),Math.max(0,a)}const Me=dx((a,u)=>({isLoading:!0,subjects:[],subjectIdx:null,topicIdx:null,resourceIdx:null,selectSubject:s=>{a({subjectIdx:s,topicIdx:null,resourceIdx:null}),localStorage.setItem("subject",s)},selectTopic:s=>{s===null&&a({topicIdx:s,resourceIdx:null});const{subjects:r,subjectIdx:o}=u(),p=r[o].topics[s].resources.length-1;a({topicIdx:s,resourceIdx:p})},selectResource:s=>{a({resourceIdx:s})},getStructure:async()=>{const{data:s}=await Um("/structure"),r=u().subjectIdx??hx();a({isLoading:!1,subjects:s,subjectIdx:r})},config:px(),changeConfig:s=>{const r={...u().config,...s};"contentZoomLevel"in s&&(r.contentZoomFactor=s.contentZoomLevel/100),a({config:r}),localStorage.setItem("config",JSON.stringify(r))}}));Me.getState().getStructure().catch(console.error);function px(){const a={displayTitle:!0,wrapTopicTitles:!1,narrowMode:!0,justifyText:!1,contentZoomLevel:100},u=localStorage.getItem("config"),s=u?JSON.parse(u):{};return{...a,...s}}const Up=a=>Symbol.iterator in a,kp=a=>"entries"in a,Bp=(a,u)=>{const s=a instanceof Map?a:new Map(a.entries()),r=u instanceof Map?u:new Map(u.entries());if(s.size!==r.size)return!1;for(const[o,f]of s)if(!Object.is(f,r.get(o)))return!1;return!0},mx=(a,u)=>{const s=a[Symbol.iterator](),r=u[Symbol.iterator]();let o=s.next(),f=r.next();for(;!o.done&&!f.done;){if(!Object.is(o.value,f.value))return!1;o=s.next(),f=r.next()}return!!o.done&&!!f.done};function gx(a,u){return Object.is(a,u)?!0:typeof a!="object"||a===null||typeof u!="object"||u===null?!1:!Up(a)||!Up(u)?Bp({entries:()=>Object.entries(a)},{entries:()=>Object.entries(u)}):kp(a)&&kp(u)?Bp(a,u):mx(a,u)}function ao(a){const u=Ac.useRef(void 0);return s=>{const r=a(s);return gx(u.current,r)?u.current:u.current=r}}function yx(a){const u=a==null?void 0:a.match(/^S(\d+)_T(\d+)$/);return u?[parseInt(u[1])-1,parseInt(u[2])-1]:(console.warn(`Invalid topic id: ${a}`),null)}function Bm(){return Me(ao(a=>({index:a.subjectIdx,...a.subjects[a.subjectIdx]})))}function Lm(){return Me(ao(a=>{if(a.topicIdx===null)return null;const{topicIdx:u,subjectIdx:s}=a;return{index:u,subjectIdx:s,...a.subjects[s].topics[u]}}))}function bx(){const{topicId:a}=Iy(),u=Me(m=>m.subjects),s=Me(m=>m.selectSubject),r=Me(m=>m.selectTopic),o=Me(m=>m.topicIdx),f=Me(m=>m.subjectIdx),p=C.useMemo(()=>{var w;if(!a)return null;const m=yx(a);if(!m)return null;const[b,h]=m,g=(w=u[b])==null?void 0:w.topics[h];return g?{...g,index:h,subjectIdx:b}:null},[a,u]);return C.useEffect(()=>{p&&(s(p.subjectIdx),r(p.index))},[s,r,p]),p&&(o===null||f===null)?{isLoading:!0}:p}function vx(){return Me(ao(a=>{const{subjects:u,subjectIdx:s,topicIdx:r}=a,{topics:o}=u[s],f=r===0?null:o[r-1],p=r===o.length-1?null:o[r+1];return{prevTopic:f,nextTopic:p}}))}function xx({className:a}){return R.jsxs("svg",{className:a,xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"inherit",children:[R.jsx("path",{d:"M0 0h24v24H0V0z",fill:"none"}),R.jsx("path",{d:"M12 8c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm8.94 3c-.46-4.17-3.77-7.48-7.94-7.94V1h-2v2.06C6.83 3.52 3.52 6.83 3.06 11H1v2h2.06c.46 4.17 3.77 7.48 7.94 7.94V23h2v-2.06c4.17-.46 7.48-3.77 7.94-7.94H23v-2h-2.06zM12 19c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z"})]})}function Hm({className:a}){return R.jsxs("svg",{className:a,xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"inherit",children:[R.jsx("path",{d:"M0 0h24v24H0V0z",fill:"none"}),R.jsx("path",{d:"M5 4v3h5.5v12h3V7H19V4H5z"})]})}function Sx({className:a}){return R.jsxs("svg",{className:a,xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"inherit",children:[R.jsx("path",{d:"M0 0h24v24H0V0z",fill:"none"}),R.jsx("path",{d:"M14 17H4v2h10v-2zm6-8H4v2h16V9zM4 15h16v-2H4v2zM4 5v2h16V5H4z"})]})}function Ex({className:a}){return R.jsxs("svg",{className:a,xmlns:"http://www.w3.org/2000/svg",enableBackground:"new 0 0 24 24",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"inherit",children:[R.jsx("rect",{fill:"none",height:"24",width:"24"}),R.jsx("path",{d:"M0.99,19h2.42l1.27-3.58h5.65L11.59,19h2.42L8.75,5h-2.5L0.99,19z M5.41,13.39L7.44,7.6h0.12l2.03,5.79H5.41z M20,11h3v2h-3 v3h-2v-3h-3v-2h3V8h2V11z"})]})}function Tx({className:a}){return R.jsxs("svg",{className:a,xmlns:"http://www.w3.org/2000/svg",enableBackground:"new 0 0 24 24",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"inherit",children:[R.jsx("rect",{fill:"none",height:"24",width:"24"}),R.jsx("path",{d:"M0.99,19h2.42l1.27-3.58h5.65L11.59,19h2.42L8.75,5h-2.5L0.99,19z M5.41,13.39L7.44,7.6h0.12l2.03,5.79H5.41z M23,11v2h-8 v-2H23z"})]})}function wx({className:a=""}){return R.jsx("svg",{className:`rotate-90 ${a}`,xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 8 24",width:"8px",fill:"inherit",children:R.jsx("rect",{fillRule:"evenodd",height:"2",width:"8",x:"0",y:"11"})})}function Rx({className:a=""}){return R.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"inherit",viewBox:"0 0 24 24",strokeWidth:2,className:"size-6 "+a,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6.75 12a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0ZM12.75 12a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0ZM18.75 12a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0Z"})})}function qm({className:a=""}){return R.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"inherit",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"size-6 "+a,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18 18 6M6 6l12 12"})})}function Ax({className:a}){return R.jsxs("svg",{className:a,xmlns:"http://www.w3.org/2000/svg",enableBackground:"new 0 0 24 24",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"inherit",children:[R.jsx("g",{children:R.jsx("rect",{fill:"none",height:"24",width:"24"})}),R.jsx("g",{children:R.jsx("path",{d:"M20,4H4C2.9,4,2,4.9,2,6v12c0,1.1,0.9,2,2,2h16c1.1,0,2-0.9,2-2V6C22,4.9,21.1,4,20,4z M4,18V6h2v12H4z M8,18V6h8v12H8z M20,18h-2V6h2V18z"})})]})}function Ox({className:a}){return R.jsxs("svg",{className:a,xmlns:"http://www.w3.org/2000/svg",enableBackground:"new 0 0 24 24",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"inherit",children:[R.jsx("g",{children:R.jsx("rect",{fill:"none",height:"24",width:"24"})}),R.jsxs("g",{children:[R.jsx("g",{}),R.jsxs("g",{children:[R.jsx("path",{d:"M21,5c-1.11-0.35-2.33-0.5-3.5-0.5c-1.95,0-4.05,0.4-5.5,1.5c-1.45-1.1-3.55-1.5-5.5-1.5S2.45,4.9,1,6v14.65 c0,0.25,0.25,0.5,0.5,0.5c0.1,0,0.15-0.05,0.25-0.05C3.1,20.45,5.05,20,6.5,20c1.95,0,4.05,0.4,5.5,1.5c1.35-0.85,3.8-1.5,5.5-1.5 c1.65,0,3.35,0.3,4.75,1.05c0.1,0.05,0.15,0.05,0.25,0.05c0.25,0,0.5-0.25,0.5-0.5V6C22.4,5.55,21.75,5.25,21,5z M21,18.5 c-1.1-0.35-2.3-0.5-3.5-0.5c-1.7,0-4.15,0.65-5.5,1.5V8c1.35-0.85,3.8-1.5,5.5-1.5c1.2,0,2.4,0.15,3.5,0.5V18.5z"}),R.jsxs("g",{children:[R.jsx("path",{d:"M17.5,10.5c0.88,0,1.73,0.09,2.5,0.26V9.24C19.21,9.09,18.36,9,17.5,9c-1.7,0-3.24,0.29-4.5,0.83v1.66 C14.13,10.85,15.7,10.5,17.5,10.5z"}),R.jsx("path",{d:"M13,12.49v1.66c1.13-0.64,2.7-0.99,4.5-0.99c0.88,0,1.73,0.09,2.5,0.26V11.9c-0.79-0.15-1.64-0.24-2.5-0.24 C15.8,11.66,14.26,11.96,13,12.49z"}),R.jsx("path",{d:"M17.5,14.33c-1.7,0-3.24,0.29-4.5,0.83v1.66c1.13-0.64,2.7-0.99,4.5-0.99c0.88,0,1.73,0.09,2.5,0.26v-1.52 C19.21,14.41,18.36,14.33,17.5,14.33z"})]})]})]})]})}function zx({className:a}){return R.jsxs("svg",{className:a,xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"inherit",children:[R.jsx("path",{d:"M0 0h24v24H0V0z",fill:"none"}),R.jsx("path",{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"})]})}function _x({className:a}){return R.jsxs("svg",{className:a,xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"inherit",children:[R.jsx("path",{d:"M0 0h24v24H0V0z",fill:"none"}),R.jsx("path",{d:"M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8-8-8z"})]})}function Nx(){return Me(u=>u.isLoading)?"Loading...":R.jsx(Mx,{})}function Cx({onChange:a}){const u=Me(m=>m.subjects),[s,r]=C.useState(-1),[o,f]=C.useState(-1);function p(m,b){if(r(m),f(b),m===-1||b===-1){a(null);return}const h=u[m],g=h.topics[b],w=g.resources.at(-1);a({subjectName:h.name,topic:g,resource:w})}return R.jsx("div",{children:R.jsxs("div",{className:"bg-white border-b border-gray-200 p-4 flex space-x-6",children:[R.jsxs("div",{children:[R.jsx("label",{htmlFor:"subjectSelect",className:"block text-sm font-medium text-gray-700 mb-2",children:"Избери раздел:"}),R.jsxs("select",{id:"subjectSelect",value:s,onChange:m=>{p(parseInt(m.target.value),-1)},className:"px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white min-w-64",children:[R.jsx("option",{value:"-1",disabled:!0,children:"Избери раздел..."}),u.map((m,b)=>R.jsxs("option",{value:b,children:[m.sequence,". ",m.name]},m.id))]})]}),R.jsxs("div",{children:[R.jsx("label",{htmlFor:"topicSelect",className:"block text-sm font-medium text-gray-700 mb-2",children:"Избери тема:"}),R.jsxs("select",{id:"topicSelect",value:o,onChange:m=>{p(s,parseInt(m.target.value))},className:"px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white",children:[R.jsx("option",{value:"-1",disabled:!0,children:s===-1?"Първо избери раздел":"Избери тема..."}),s!==-1&&u[s].topics.map((m,b)=>R.jsxs("option",{value:b,children:[m.sequence,"."," ",m.title.length>60?m.title.substring(0,60)+"...":m.title]},m.id))]})]})]})})}function Mx(){return R.jsx(jx,{token:"aaaaaa",initialContent:"# hola",subjectName:"asdasd",topicTitle:"tiilte"})}function Dx(a){const[u,s]=C.useState(null),[r,o]=C.useState(!0);return C.useEffect(()=>{if(!a)return;let f=!1;return o(!0),s(null),km.get(`/${a.filename}`).then(p=>{f||(s(p.data),o(!1))}),()=>{f=!0}},[a]),{content:u,isLoading:r}}const jx=()=>{const a=Me(F=>F.config.token),u=Me(F=>F.changeConfig),s=F=>u({token:F}),[r,o]=C.useState(null),{isLoading:f,content:p}=Dx(r==null?void 0:r.resource),[m,b]=C.useState(p),[h,g]=C.useState(""),[w,E]=C.useState(!1),[U,T]=C.useState(null),[k,D]=C.useState(p);k!==p&&(D(p),b(p));const q=()=>{h.trim()&&s(h)},Z=async()=>{E(!0);try{const F=await Um.post("/resources",{topicId:r.topic.id,content:m.trim()},{headers:{token:a}});T(`Success! New filename: ${F.data.filename}`)}catch(F){console.log(F),T("Something failed :("),F.response.status===401&&s(null)}finally{setTimeout(()=>{T(null)},8e3),E(!1),b(""),o(null)}},G=()=>{window.confirm("Сигурни ли сте, че искате да затворите страницата?")&&window.close()},te=async()=>{try{await navigator.clipboard.writeText(m),alert("Съдържанието е копирано в клипборда!")}catch(F){console.error("Грешка при копиране:",F),alert("Грешка при копиране на съдържанието")}};function $(){b(p)}const oe=()=>{window.confirm("Сигурни ли сте, че искате да изтриете цялото съдържание?")&&b("")};return a?R.jsxs("div",{className:"min-h-screen bg-gray-50 flex flex-col",children:[R.jsx(Cx,{onChange:F=>o(F)}),U&&R.jsx("div",{className:"text-lg p-12 text-green-600 bg-gray-200",children:U}),r&&!f&&R.jsxs(R.Fragment,{children:[R.jsxs("div",{className:"bg-white border-b border-gray-200 p-4",children:[R.jsx("div",{className:"text-2xl font-bold text-gray-800",children:r.subjectName}),R.jsxs("div",{className:"text-2xl/7 mt-2 text-gray-800 line-",children:["Тема: ",r.topic.sequence,". ",r.topic.title]}),R.jsxs("div",{className:"text-sm text-gray-400 mt-6",children:["Topic Id: ",R.jsx("span",{className:"font-bold",children:r.topic.id})," - ","Original Filename: ",R.jsx("span",{className:"font-bold",children:r.resource.filename})," - ","Current Version: ",R.jsx("span",{className:"font-bold",children:r.resource.version})," - ","New Version: ",R.jsx("span",{className:"font-bold",children:r.resource.version+1})]})]}),R.jsx("div",{className:"bg-white border-b border-gray-200 p-4",children:R.jsxs("div",{className:"flex flex-wrap gap-3",children:[R.jsx("button",{onClick:te,className:"bg-green-600 text-white px-4 py-2 rounded-md hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-green-500 focus:ring-offset-2 transition-colors",children:"Копирай съдържанието"}),R.jsx("button",{onClick:oe,className:"bg-red-600 text-white px-4 py-2 rounded-md hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 transition-colors",children:"Изтрий всичко"}),R.jsx("button",{onClick:$,className:"bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors",children:"Възстанови оригинал"})]})}),R.jsxs("div",{className:"flex-1 bg-white p-4 flex flex-col",children:[R.jsx("label",{htmlFor:"content",className:"block text-sm font-medium text-gray-700 mb-2",children:"Markdown съдържание:"}),R.jsx("div",{className:"flex-1",children:R.jsx("textarea",{id:"content",value:m,onChange:F=>b(F.target.value),className:"w-full h-full resize-none px-3 py-2 bg-gray-100 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent font-mono text-sm",placeholder:"Въведете вашето Markdown съдържание тук..."})})]}),R.jsxs("div",{className:"bg-white border-t border-gray-200 p-4",children:[w&&R.jsx("span",{className:"flex justify-end mr-8",children:"Saving..."}),R.jsxs("div",{className:`flex justify-end gap-3 ${w?"invisible":""}`,children:[R.jsx("button",{onClick:G,className:"bg-gray-600 text-white px-6 py-2 rounded-md hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 transition-colors",children:"Отказ"}),R.jsx("button",{onClick:Z,className:"bg-blue-600 text-white px-6 py-2 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors",children:"Запази"})]})]})]})]}):R.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center p-8",children:R.jsxs("div",{className:"bg-white rounded-lg shadow-md p-8 w-full max-w-md",children:[R.jsx("h2",{className:"text-2xl font-bold text-gray-800 mb-6 text-center",children:"Въведете токен за достъп"}),R.jsxs("div",{className:"space-y-4",children:[R.jsxs("div",{children:[R.jsx("label",{htmlFor:"token",className:"block text-sm font-medium text-gray-700 mb-2",children:"Токен:"}),R.jsx("input",{type:"text",id:"token",value:h,onChange:F=>g(F.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"Въведете вашия токен..."})]}),R.jsx("button",{onClick:q,className:"w-full bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors",children:"Влизане"})]})]})})};function Ux(){return R.jsx(Hb,{children:R.jsxs(gb,{children:[R.jsxs(au,{path:"/",element:R.jsx(kx,{children:R.jsx(Bx,{})}),children:[R.jsx(au,{index:!0,element:R.jsx(Lx,{})}),R.jsx(au,{path:":topicId",element:R.jsx(Hx,{})})]}),R.jsx(au,{path:"/edit",element:R.jsx(Nx,{})})]})})}function kx({children:a}){return Me(s=>s.isLoading)?null:a}function Bx(){const a=Me(r=>r.config),u=Bm(),s=Lm();return R.jsxs("div",{className:"max-w-7xl mx-auto h-full relative flex flex-col",children:[a.displayTitle&&R.jsxs("div",{className:"w-full px-4 py-2 font-medium text-large text-white bg-blue-600",style:{lineHeight:1.2},children:[R.jsx("div",{className:"text-sm font-normal",children:u.name}),R.jsx("span",{children:s?`${s.sequence}: ${s.title}`:"Конспект за Държавен Изпит"})]}),R.jsx(pb,{})]})}function Lx(){const a=C.useRef({}),u=Me(g=>g.subjects),s=Bm(),r=Me(g=>g.selectSubject),[o,f]=C.useState(!1),p=Lm(),m=Me(g=>g.selectTopic),b=Me(g=>g.config),h=Me(g=>g.changeConfig);return C.useLayoutEffect(()=>{var g;p&&((g=a.current)==null||g[Math.max(p.index-3,0)].scrollIntoView())},[p]),R.jsxs(R.Fragment,{children:[R.jsx("div",{className:`flex-1 overflow-y-scroll ${p===null?"pb-[92px]":"pb-[156px]"}`,children:s.topics.map((g,w)=>R.jsxs(ul,{ref:E=>{a.current[w]=E},to:`/${g.id}`,onClick:()=>m(w),className:`flex px-2 py-1 rounded-md cursor-pointer border-l-4 ${g.id===(p==null?void 0:p.id)?"bg-blue-100 border-blue-500":"border-transparent hover:bg-gray-100"}`,children:[R.jsx("div",{className:`w-6 flex-shrink-0 flex font-medium justify-end ${g.id===(p==null?void 0:p.id)?"text-blue-600":"text-blue-800"}`,children:g.sequence}),R.jsx("span",{className:`ml-2 leading-5 ${g.id===(p==null?void 0:p.id)?"font-medium":"font-normal"} ${b.wrapTopicTitles?"truncate":""}`,children:g.title})]},g.id))}),R.jsxs("div",{className:"absolute bottom-0 sm:p-4 px-2 py-0 w-full flex flex-col",children:[R.jsxs("div",{className:"ml-auto p-2 flex space-x-1 h-[60px]",children:[R.jsx("button",{className:`cursor-pointer p-2 rounded-full text-white border ${b.displayTitle?"bg-blue-100 border-blue-400":"bg-gray-100 border-gray-400"}`,onClick:()=>h({displayTitle:!b.displayTitle}),children:R.jsx(Hm,{className:"fill-gray-600"})}),R.jsx("button",{className:`cursor-pointer p-2 rounded-full text-white border ${b.wrapTopicTitles?"bg-blue-100 border-blue-400":"bg-gray-100 border-gray-400"}`,onClick:()=>h({wrapTopicTitles:!b.wrapTopicTitles}),children:R.jsx(Rx,{className:"fill-gray-600"})}),p&&R.jsx("button",{className:"px-3 py-3 bg-teal-500 hover:bg-teal-300 cursor-pointer rounded-full flex items-center justify-center shadow-md transition-colors",onClick:()=>{var g;(g=a.current)==null||g[Math.max(p.index-3,0)].scrollIntoView({behavior:"smooth"})},children:R.jsx(xx,{className:"h-5 w-5"})}),R.jsxs("div",{className:"relative flex ml-2",children:[R.jsx("button",{className:`${o?"invisible":""} flex-1 shadow-xl cursor-pointer px-2 py-1 rounded-md text-xs text-blue-800 font-medium whitespace-nowrap bg-blue-100/50 backdrop-blur hover:bg-blue-200/50 border border-blue-100`,onClick:()=>f(!0),children:s.name}),o&&R.jsxs(R.Fragment,{children:[R.jsx("button",{className:"absolute w-full h-full flex-1 flex justify-center items-center cursor-pointer rounded-md backdrop-blur bg-blue-100/40 hover:bg-blue-100/80",onClick:()=>f(!1),children:R.jsx(qm,{className:"fill-gray-600"})}),R.jsx("div",{className:"absolute bottom-full right-0 p-2 flex space-x-1",children:u.map((g,w)=>R.jsx("button",{className:`flex-1 shadow-xl cursor-pointer px-2 py-1 rounded-md text-xs whitespace-nowrap h-[44px] ${s.id===g.id?"bg-blue-100 text-blue-800 font-medium border border-blue-400":"bg-gray-100 hover:bg-gray-200 border border-gray-400"}`,onClick:()=>{r(w),f(!1)},children:g.name},g.id))})]})]})]}),p&&R.jsxs(ul,{to:`/${p.id}`,className:"w-full p-2 mb-2 bg-blue-600 hover:bg-blue-700 cursor-pointer truncate rounded-md text-sm text-white text-center shadow-md transition-colors",children:[R.jsx("span",{children:"Продължи четенето:"}),R.jsx("br",{}),R.jsxs("span",{className:"font-medium",children:[p.sequence,". ",p.title]})]})]})]})}function Hx(){const a=bx();return a&&a.isLoading?null:a?R.jsx(qx,{topic:a},a.id):R.jsx(hb,{to:"/",replace:!0})}function qx({topic:a}){const u=Me(g=>g.config),s=Me(g=>g.changeConfig),{prevTopic:r,nextTopic:o}=vx(),[f,p]=C.useState(!1),[m,b]=C.useState(a.resources.length-1),h=a.resources[m];return m===-1?R.jsx("div",{className:"text-sm font-medium p-4",children:"No data"}):R.jsxs(R.Fragment,{children:[R.jsxs("div",{className:"flex-1",children:[R.jsx(Yx,{file:a.resources[m],compact:u.narrowMode,justifyText:u.justifyText,zoomFactor:u.contentZoomFactor}),R.jsxs("div",{className:"absolute bottom-10 flex justify-between px-4 py-2 w-full z-999",children:[R.jsx("div",{className:"flex w-full space-x-2",children:R.jsx(ul,{to:"/",className:"cursor-pointer p-2 rounded-full bg-blue-600 text-white mr-auto",children:R.jsx(Ox,{className:"fill-gray-100"})})}),R.jsxs("div",{className:"flex items-center",children:[R.jsxs("div",{className:"text-sm text-gray-600 rounded bg-gray-300/30 backdrop-blur px-2",children:[u.contentZoomLevel,"%"]}),R.jsx("button",{className:"cursor-pointer p-2 mx-1 rounded-full text-white bg-gray-100/30 backdrop-blur",onClick:()=>s({contentZoomLevel:Math.max(50,u.contentZoomLevel-10)}),children:R.jsx(Tx,{className:"fill-gray-600"})}),R.jsx("button",{className:"cursor-pointer p-2 rounded-full text-white bg-gray-100/30 backdrop-blur",onClick:()=>{s({contentZoomLevel:Math.min(150,u.contentZoomLevel+10)})},children:R.jsx(Ex,{className:"fill-gray-600"})}),R.jsx(wx,{className:"fill-gray-300"}),R.jsx("button",{className:`cursor-pointer p-2 mr-1 rounded-full text-white border ${u.displayTitle?"bg-blue-100 border-blue-400":"bg-gray-100 border-gray-400"}`,onClick:()=>s({displayTitle:!u.displayTitle}),children:R.jsx(Hm,{className:"fill-gray-600"})}),R.jsx("button",{className:`cursor-pointer p-2 mr-1 rounded-full text-white border ${u.justifyText?"bg-blue-100 border-blue-400":"bg-gray-100 border-gray-400"}`,onClick:()=>s({justifyText:!u.justifyText}),children:R.jsx(Sx,{className:"fill-gray-600"})}),window.innerWidth>576&&R.jsx("button",{className:`cursor-pointer p-2 mr-1 rounded-full text-white border ${u.narrowMode?"bg-blue-100 border-blue-400":"bg-gray-100 border-gray-400"}`,onClick:()=>s({narrowMode:!u.narrowMode}),children:R.jsx(Ax,{className:"fill-gray-600"})}),a.resources.length>1&&R.jsxs("div",{className:"relative h-full flex ml-2",children:[R.jsxs("button",{className:`${f?"invisible":""} flex-1 shadow-xl cursor-pointer px-2 py-1 rounded-md text-xs text-blue-800 font-medium whitespace-nowrap bg-blue-100/50 backdrop-blur hover:bg-blue-200/50 border border-blue-100`,onClick:()=>p(!0),children:["Версия ",h.version]}),f&&R.jsx("button",{className:"absolute w-full h-full flex-1 flex justify-center items-center cursor-pointer rounded-md hover:backdrop-blur hover:bg-blue-100/30",onClick:()=>p(!1),children:R.jsx(qm,{className:"fill-gray-600"})})]})]}),f&&R.jsx("div",{className:"absolute bottom-full right-0 px-4 flex space-x-1 h-10",children:a.resources.map((g,w)=>R.jsxs("button",{className:`flex-1 shadow-xl cursor-pointer px-2 py-1 rounded-md text-xs whitespace-nowrap ${h.id===g.id?"bg-blue-100 text-blue-800 font-medium border border-blue-400":"bg-gray-100 hover:bg-gray-200 border border-gray-400"}`,onClick:()=>{b(w),p(!1)},children:["Версия ",g.version]},g.id))})]})]}),R.jsx("div",{className:"w-full flex flex-col space-y-2",children:R.jsxs("div",{className:"flex bg-gray-100 border-t border-blue-200 text-center",children:[r===null?R.jsx("div",{className:"flex-1 border-r border-blue-200"}):R.jsxs(ul,{to:`/${r.id}`,className:"border-r border-blue-200 w-1/2 flex-1 px-4 py-2 hover:bg-blue-200 cursor-pointer flex align-center justify-start",children:[R.jsx(zx,{}),R.jsxs("span",{className:"ml-2 truncate w-full ",children:[r.sequence,": ",r.title]})]}),o===null?R.jsx("div",{className:"flex-1"}):R.jsxs(ul,{to:`/${o.id}`,className:"flex-1 px-4 py-2 hover:bg-blue-200 w-1/2 cursor-pointer flex align-center justify-end",children:[R.jsxs("span",{className:"mr-2 w-full truncate",children:[o.sequence,": ",o.title]}),R.jsx(_x,{})]})]})})]})}function Yx({file:a,compact:u,zoomFactor:s,justifyText:r}){const o=C.useRef(null),[f,p]=C.useState(null),m=C.useMemo(()=>`
+`+f):r.stack=f}catch{}}throw r}}_request(u,s){typeof u=="string"?(s=s||{},s.url=u):s=u||{},s=sl(this.defaults,s);const{transitional:r,paramsSerializer:o,headers:f}=s;r!==void 0&&Ui.assertOptions(r,{silentJSONParsing:Xt.transitional(Xt.boolean),forcedJSONParsing:Xt.transitional(Xt.boolean),clarifyTimeoutError:Xt.transitional(Xt.boolean)},!1),o!=null&&(M.isFunction(o)?s.paramsSerializer={serialize:o}:Ui.assertOptions(o,{encode:Xt.function,serialize:Xt.function},!0)),s.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?s.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:s.allowAbsoluteUrls=!0),Ui.assertOptions(s,{baseUrl:Xt.spelling("baseURL"),withXsrfToken:Xt.spelling("withXSRFToken")},!0),s.method=(s.method||this.defaults.method||"get").toLowerCase();let p=f&&M.merge(f.common,f[s.method]);f&&M.forEach(["delete","get","head","post","put","patch","common"],T=>{delete f[T]}),s.headers=ot.concat(p,f);const m=[];let b=!0;this.interceptors.request.forEach(function(k){typeof k.runWhen=="function"&&k.runWhen(s)===!1||(b=b&&k.synchronous,m.unshift(k.fulfilled,k.rejected))});const h=[];this.interceptors.response.forEach(function(k){h.push(k.fulfilled,k.rejected)});let g,w=0,E;if(!b){const T=[Cp.bind(this),void 0];for(T.unshift.apply(T,m),T.push.apply(T,h),E=T.length,g=Promise.resolve(s);w{if(!r._listeners)return;let f=r._listeners.length;for(;f-- >0;)r._listeners[f](o);r._listeners=null}),this.promise.then=o=>{let f;const p=new Promise(m=>{r.subscribe(m),f=m}).then(o);return p.cancel=function(){r.unsubscribe(f)},p},u(function(f,p,m){r.reason||(r.reason=new Il(f,p,m),s(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(u){if(this.reason){u(this.reason);return}this._listeners?this._listeners.push(u):this._listeners=[u]}unsubscribe(u){if(!this._listeners)return;const s=this._listeners.indexOf(u);s!==-1&&this._listeners.splice(s,1)}toAbortSignal(){const u=new AbortController,s=r=>{u.abort(r)};return this.subscribe(s),u.signal.unsubscribe=()=>this.unsubscribe(s),u.signal}static source(){let u;return{token:new Dm(function(o){u=o}),cancel:u}}};function ux(a){return function(s){return a.apply(null,s)}}function ix(a){return M.isObject(a)&&a.isAxiosError===!0}const Bc={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Bc).forEach(([a,u])=>{Bc[u]=a});function jm(a){const u=new il(a),s=om(il.prototype.request,u);return M.extend(s,il.prototype,u,{allOwnKeys:!0}),M.extend(s,u,null,{allOwnKeys:!0}),s.create=function(o){return jm(sl(a,o))},s}const Ue=jm(du);Ue.Axios=il;Ue.CanceledError=Il;Ue.CancelToken=ax;Ue.isCancel=Rm;Ue.VERSION=Mm;Ue.toFormData=Fi;Ue.AxiosError=ae;Ue.Cancel=Ue.CanceledError;Ue.all=function(u){return Promise.all(u)};Ue.spread=ux;Ue.isAxiosError=ix;Ue.mergeConfig=sl;Ue.AxiosHeaders=ot;Ue.formToJSON=a=>wm(M.isHTMLForm(a)?new FormData(a):a);Ue.getAdapter=Cm.getAdapter;Ue.HttpStatusCode=Bc;Ue.default=Ue;const{Axios:Qx,AxiosError:$x,CanceledError:Kx,isCancel:Jx,CancelToken:Fx,VERSION:Wx,all:Px,Cancel:Ix,isAxiosError:eS,spread:tS,toFormData:nS,AxiosHeaders:lS,HttpStatusCode:aS,formToJSON:uS,getAdapter:iS,mergeConfig:rS}=Ue,rx="https://api.med.tomastm.com",sx="https://resources.med.tomastm.com",Um=Ue.create({baseURL:rx,timeout:1e3}),km=Ue.create({baseURL:sx,timeout:1e3}),Dp=a=>{let u;const s=new Set,r=(h,g)=>{const w=typeof h=="function"?h(u):h;if(!Object.is(w,u)){const E=u;u=g??(typeof w!="object"||w===null)?w:Object.assign({},u,w),s.forEach(U=>U(u,E))}},o=()=>u,m={setState:r,getState:o,getInitialState:()=>b,subscribe:h=>(s.add(h),()=>s.delete(h))},b=u=a(r,o,m);return m},cx=a=>a?Dp(a):Dp,ox=a=>a;function fx(a,u=ox){const s=Ac.useSyncExternalStore(a.subscribe,()=>u(a.getState()),()=>u(a.getInitialState()));return Ac.useDebugValue(s),s}const jp=a=>{const u=cx(a),s=r=>fx(u,r);return Object.assign(s,u),s},dx=a=>a?jp(a):jp;function hx(){let a=localStorage.getItem("subject");return typeof a>"u"&&(a=0),a=parseInt(a),Math.max(0,a)}const Me=dx((a,u)=>({isLoading:!0,subjects:[],subjectIdx:null,topicIdx:null,resourceIdx:null,selectSubject:s=>{a({subjectIdx:s,topicIdx:null,resourceIdx:null}),localStorage.setItem("subject",s)},selectTopic:s=>{s===null&&a({topicIdx:s,resourceIdx:null});const{subjects:r,subjectIdx:o}=u(),p=r[o].topics[s].resources.length-1;a({topicIdx:s,resourceIdx:p})},selectResource:s=>{a({resourceIdx:s})},getStructure:async()=>{const{data:s}=await Um("/structure"),r=u().subjectIdx??hx();a({isLoading:!1,subjects:s,subjectIdx:r})},config:px(),changeConfig:s=>{const r={...u().config,...s};"contentZoomLevel"in s&&(r.contentZoomFactor=s.contentZoomLevel/100),a({config:r}),localStorage.setItem("config",JSON.stringify(r))}}));Me.getState().getStructure().catch(console.error);function px(){const a={displayTitle:!0,wrapTopicTitles:!1,narrowMode:!0,justifyText:!1,contentZoomLevel:100},u=localStorage.getItem("config"),s=u?JSON.parse(u):{};return{...a,...s}}const Up=a=>Symbol.iterator in a,kp=a=>"entries"in a,Bp=(a,u)=>{const s=a instanceof Map?a:new Map(a.entries()),r=u instanceof Map?u:new Map(u.entries());if(s.size!==r.size)return!1;for(const[o,f]of s)if(!Object.is(f,r.get(o)))return!1;return!0},mx=(a,u)=>{const s=a[Symbol.iterator](),r=u[Symbol.iterator]();let o=s.next(),f=r.next();for(;!o.done&&!f.done;){if(!Object.is(o.value,f.value))return!1;o=s.next(),f=r.next()}return!!o.done&&!!f.done};function gx(a,u){return Object.is(a,u)?!0:typeof a!="object"||a===null||typeof u!="object"||u===null?!1:!Up(a)||!Up(u)?Bp({entries:()=>Object.entries(a)},{entries:()=>Object.entries(u)}):kp(a)&&kp(u)?Bp(a,u):mx(a,u)}function ao(a){const u=Ac.useRef(void 0);return s=>{const r=a(s);return gx(u.current,r)?u.current:u.current=r}}function yx(a){const u=a==null?void 0:a.match(/^S(\d+)_T(\d+)$/);return u?[parseInt(u[1])-1,parseInt(u[2])-1]:(console.warn(`Invalid topic id: ${a}`),null)}function Bm(){return Me(ao(a=>({index:a.subjectIdx,...a.subjects[a.subjectIdx]})))}function Lm(){return Me(ao(a=>{if(a.topicIdx===null)return null;const{topicIdx:u,subjectIdx:s}=a;return{index:u,subjectIdx:s,...a.subjects[s].topics[u]}}))}function bx(){const{topicId:a}=Iy(),u=Me(m=>m.subjects),s=Me(m=>m.selectSubject),r=Me(m=>m.selectTopic),o=Me(m=>m.topicIdx),f=Me(m=>m.subjectIdx),p=C.useMemo(()=>{var w;if(!a)return null;const m=yx(a);if(!m)return null;const[b,h]=m,g=(w=u[b])==null?void 0:w.topics[h];return g?{...g,index:h,subjectIdx:b}:null},[a,u]);return C.useEffect(()=>{p&&(s(p.subjectIdx),r(p.index))},[s,r,p]),p&&(o===null||f===null)?{isLoading:!0}:p}function vx(){return Me(ao(a=>{const{subjects:u,subjectIdx:s,topicIdx:r}=a,{topics:o}=u[s],f=r===0?null:o[r-1],p=r===o.length-1?null:o[r+1];return{prevTopic:f,nextTopic:p}}))}function xx({className:a}){return R.jsxs("svg",{className:a,xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"inherit",children:[R.jsx("path",{d:"M0 0h24v24H0V0z",fill:"none"}),R.jsx("path",{d:"M12 8c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm8.94 3c-.46-4.17-3.77-7.48-7.94-7.94V1h-2v2.06C6.83 3.52 3.52 6.83 3.06 11H1v2h2.06c.46 4.17 3.77 7.48 7.94 7.94V23h2v-2.06c4.17-.46 7.48-3.77 7.94-7.94H23v-2h-2.06zM12 19c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z"})]})}function Hm({className:a}){return R.jsxs("svg",{className:a,xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"inherit",children:[R.jsx("path",{d:"M0 0h24v24H0V0z",fill:"none"}),R.jsx("path",{d:"M5 4v3h5.5v12h3V7H19V4H5z"})]})}function Sx({className:a}){return R.jsxs("svg",{className:a,xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"inherit",children:[R.jsx("path",{d:"M0 0h24v24H0V0z",fill:"none"}),R.jsx("path",{d:"M14 17H4v2h10v-2zm6-8H4v2h16V9zM4 15h16v-2H4v2zM4 5v2h16V5H4z"})]})}function Ex({className:a}){return R.jsxs("svg",{className:a,xmlns:"http://www.w3.org/2000/svg",enableBackground:"new 0 0 24 24",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"inherit",children:[R.jsx("rect",{fill:"none",height:"24",width:"24"}),R.jsx("path",{d:"M0.99,19h2.42l1.27-3.58h5.65L11.59,19h2.42L8.75,5h-2.5L0.99,19z M5.41,13.39L7.44,7.6h0.12l2.03,5.79H5.41z M20,11h3v2h-3 v3h-2v-3h-3v-2h3V8h2V11z"})]})}function Tx({className:a}){return R.jsxs("svg",{className:a,xmlns:"http://www.w3.org/2000/svg",enableBackground:"new 0 0 24 24",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"inherit",children:[R.jsx("rect",{fill:"none",height:"24",width:"24"}),R.jsx("path",{d:"M0.99,19h2.42l1.27-3.58h5.65L11.59,19h2.42L8.75,5h-2.5L0.99,19z M5.41,13.39L7.44,7.6h0.12l2.03,5.79H5.41z M23,11v2h-8 v-2H23z"})]})}function wx({className:a=""}){return R.jsx("svg",{className:`rotate-90 ${a}`,xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 8 24",width:"8px",fill:"inherit",children:R.jsx("rect",{fillRule:"evenodd",height:"2",width:"8",x:"0",y:"11"})})}function Rx({className:a=""}){return R.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"inherit",viewBox:"0 0 24 24",strokeWidth:2,className:"size-6 "+a,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6.75 12a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0ZM12.75 12a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0ZM18.75 12a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0Z"})})}function qm({className:a=""}){return R.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"inherit",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"size-6 "+a,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18 18 6M6 6l12 12"})})}function Ax({className:a}){return R.jsxs("svg",{className:a,xmlns:"http://www.w3.org/2000/svg",enableBackground:"new 0 0 24 24",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"inherit",children:[R.jsx("g",{children:R.jsx("rect",{fill:"none",height:"24",width:"24"})}),R.jsx("g",{children:R.jsx("path",{d:"M20,4H4C2.9,4,2,4.9,2,6v12c0,1.1,0.9,2,2,2h16c1.1,0,2-0.9,2-2V6C22,4.9,21.1,4,20,4z M4,18V6h2v12H4z M8,18V6h8v12H8z M20,18h-2V6h2V18z"})})]})}function Ox({className:a}){return R.jsxs("svg",{className:a,xmlns:"http://www.w3.org/2000/svg",enableBackground:"new 0 0 24 24",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"inherit",children:[R.jsx("g",{children:R.jsx("rect",{fill:"none",height:"24",width:"24"})}),R.jsxs("g",{children:[R.jsx("g",{}),R.jsxs("g",{children:[R.jsx("path",{d:"M21,5c-1.11-0.35-2.33-0.5-3.5-0.5c-1.95,0-4.05,0.4-5.5,1.5c-1.45-1.1-3.55-1.5-5.5-1.5S2.45,4.9,1,6v14.65 c0,0.25,0.25,0.5,0.5,0.5c0.1,0,0.15-0.05,0.25-0.05C3.1,20.45,5.05,20,6.5,20c1.95,0,4.05,0.4,5.5,1.5c1.35-0.85,3.8-1.5,5.5-1.5 c1.65,0,3.35,0.3,4.75,1.05c0.1,0.05,0.15,0.05,0.25,0.05c0.25,0,0.5-0.25,0.5-0.5V6C22.4,5.55,21.75,5.25,21,5z M21,18.5 c-1.1-0.35-2.3-0.5-3.5-0.5c-1.7,0-4.15,0.65-5.5,1.5V8c1.35-0.85,3.8-1.5,5.5-1.5c1.2,0,2.4,0.15,3.5,0.5V18.5z"}),R.jsxs("g",{children:[R.jsx("path",{d:"M17.5,10.5c0.88,0,1.73,0.09,2.5,0.26V9.24C19.21,9.09,18.36,9,17.5,9c-1.7,0-3.24,0.29-4.5,0.83v1.66 C14.13,10.85,15.7,10.5,17.5,10.5z"}),R.jsx("path",{d:"M13,12.49v1.66c1.13-0.64,2.7-0.99,4.5-0.99c0.88,0,1.73,0.09,2.5,0.26V11.9c-0.79-0.15-1.64-0.24-2.5-0.24 C15.8,11.66,14.26,11.96,13,12.49z"}),R.jsx("path",{d:"M17.5,14.33c-1.7,0-3.24,0.29-4.5,0.83v1.66c1.13-0.64,2.7-0.99,4.5-0.99c0.88,0,1.73,0.09,2.5,0.26v-1.52 C19.21,14.41,18.36,14.33,17.5,14.33z"})]})]})]})]})}function zx({className:a}){return R.jsxs("svg",{className:a,xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"inherit",children:[R.jsx("path",{d:"M0 0h24v24H0V0z",fill:"none"}),R.jsx("path",{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"})]})}function _x({className:a}){return R.jsxs("svg",{className:a,xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"inherit",children:[R.jsx("path",{d:"M0 0h24v24H0V0z",fill:"none"}),R.jsx("path",{d:"M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8-8-8z"})]})}function Nx(){return Me(u=>u.isLoading)?"Loading...":R.jsx(Mx,{})}function Cx({onChange:a}){const u=Me(m=>m.subjects),[s,r]=C.useState(-1),[o,f]=C.useState(-1);function p(m,b){if(r(m),f(b),m===-1||b===-1){a(null);return}const h=u[m],g=h.topics[b],w=g.resources.at(-1);a({subjectName:h.name,topic:g,resource:w})}return R.jsx("div",{children:R.jsxs("div",{className:"bg-white border-b border-gray-200 p-4 flex space-x-6",children:[R.jsxs("div",{children:[R.jsx("label",{htmlFor:"subjectSelect",className:"block text-sm font-medium text-gray-700 mb-2",children:"Избери раздел:"}),R.jsxs("select",{id:"subjectSelect",value:s,onChange:m=>{p(parseInt(m.target.value),-1)},className:"px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white min-w-64",children:[R.jsx("option",{value:"-1",disabled:!0,children:"Избери раздел..."}),u.map((m,b)=>R.jsxs("option",{value:b,children:[m.sequence,". ",m.name]},m.id))]})]}),R.jsxs("div",{children:[R.jsx("label",{htmlFor:"topicSelect",className:"block text-sm font-medium text-gray-700 mb-2",children:"Избери тема:"}),R.jsxs("select",{id:"topicSelect",value:o,onChange:m=>{p(s,parseInt(m.target.value))},className:"px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white",children:[R.jsx("option",{value:"-1",disabled:!0,children:s===-1?"Първо избери раздел":"Избери тема..."}),s!==-1&&u[s].topics.map((m,b)=>R.jsxs("option",{value:b,children:[m.sequence,"."," ",m.title.length>60?m.title.substring(0,60)+"...":m.title]},m.id))]})]})]})})}function Mx(){return R.jsx(jx,{token:"aaaaaa",initialContent:"# hola",subjectName:"asdasd",topicTitle:"tiilte"})}function Dx(a){const[u,s]=C.useState(null),[r,o]=C.useState(!0);return C.useEffect(()=>{if(!a)return;let f=!1;return o(!0),s(null),km.get(`/${a.filename}`).then(p=>{f||(s(p.data),o(!1))}),()=>{f=!0}},[a]),{content:u,isLoading:r}}const jx=()=>{const a=Me(F=>F.config.token),u=Me(F=>F.changeConfig),s=F=>u({token:F}),[r,o]=C.useState(null),{isLoading:f,content:p}=Dx(r==null?void 0:r.resource),[m,b]=C.useState(p),[h,g]=C.useState(""),[w,E]=C.useState(!1),[U,T]=C.useState(null),[k,D]=C.useState(p);k!==p&&(D(p),b(p));const q=()=>{h.trim()&&s(h)},Z=async()=>{E(!0);try{const F=await Um.post("/resources",{topicId:r.topic.id,content:m.trim()},{headers:{token:a}});T(`Success! New filename: ${F.data.filename}`)}catch(F){console.log(F),T("Something failed :("),F.response.status===401&&s(null)}finally{setTimeout(()=>{T(null)},8e3),E(!1),b(""),o(null)}},G=()=>{window.confirm("Сигурни ли сте, че искате да затворите страницата?")&&window.close()},te=async()=>{try{await navigator.clipboard.writeText(m),alert("Съдържанието е копирано в клипборда!")}catch(F){console.error("Грешка при копиране:",F),alert("Грешка при копиране на съдържанието")}};function $(){b(p)}const oe=()=>{window.confirm("Сигурни ли сте, че искате да изтриете цялото съдържание?")&&b("")};return a?R.jsxs("div",{className:"min-h-screen bg-gray-50 flex flex-col",children:[R.jsx(Cx,{onChange:F=>o(F)}),U&&R.jsx("div",{className:"text-lg p-12 text-green-600 bg-gray-200",children:U}),r&&!f&&R.jsxs(R.Fragment,{children:[R.jsxs("div",{className:"bg-white border-b border-gray-200 p-4",children:[R.jsx("div",{className:"text-2xl font-bold text-gray-800",children:r.subjectName}),R.jsxs("div",{className:"text-2xl/7 mt-2 text-gray-800 line-",children:["Тема: ",r.topic.sequence,". ",r.topic.title]}),R.jsxs("div",{className:"text-sm text-gray-400 mt-6",children:["Topic Id: ",R.jsx("span",{className:"font-bold",children:r.topic.id})," - ","Original Filename: ",R.jsx("span",{className:"font-bold",children:r.resource.filename})," - ","Current Version: ",R.jsx("span",{className:"font-bold",children:r.resource.version})," - ","New Version: ",R.jsx("span",{className:"font-bold",children:r.resource.version+1})]})]}),R.jsx("div",{className:"bg-white border-b border-gray-200 p-4",children:R.jsxs("div",{className:"flex flex-wrap gap-3",children:[R.jsx("button",{onClick:te,className:"bg-green-600 text-white px-4 py-2 rounded-md hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-green-500 focus:ring-offset-2 transition-colors",children:"Копирай съдържанието"}),R.jsx("button",{onClick:oe,className:"bg-red-600 text-white px-4 py-2 rounded-md hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 transition-colors",children:"Изтрий всичко"}),R.jsx("button",{onClick:$,className:"bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors",children:"Възстанови оригинал"})]})}),R.jsxs("div",{className:"flex-1 bg-white p-4 flex flex-col",children:[R.jsx("label",{htmlFor:"content",className:"block text-sm font-medium text-gray-700 mb-2",children:"Markdown съдържание:"}),R.jsx("div",{className:"flex-1",children:R.jsx("textarea",{id:"content",value:m,onChange:F=>b(F.target.value),className:"w-full h-full resize-none px-3 py-2 bg-gray-100 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent font-mono text-sm",placeholder:"Въведете вашето Markdown съдържание тук..."})})]}),R.jsxs("div",{className:"bg-white border-t border-gray-200 p-4",children:[w&&R.jsx("span",{className:"flex justify-end mr-8",children:"Saving..."}),R.jsxs("div",{className:`flex justify-end gap-3 ${w?"invisible":""}`,children:[R.jsx("button",{onClick:G,className:"bg-gray-600 text-white px-6 py-2 rounded-md hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 transition-colors",children:"Отказ"}),R.jsx("button",{onClick:Z,className:"bg-blue-600 text-white px-6 py-2 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors",children:"Запази"})]})]})]})]}):R.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center p-8",children:R.jsxs("div",{className:"bg-white rounded-lg shadow-md p-8 w-full max-w-md",children:[R.jsx("h2",{className:"text-2xl font-bold text-gray-800 mb-6 text-center",children:"Въведете токен за достъп"}),R.jsxs("div",{className:"space-y-4",children:[R.jsxs("div",{children:[R.jsx("label",{htmlFor:"token",className:"block text-sm font-medium text-gray-700 mb-2",children:"Токен:"}),R.jsx("input",{type:"text",id:"token",value:h,onChange:F=>g(F.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"Въведете вашия токен..."})]}),R.jsx("button",{onClick:q,className:"w-full bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors",children:"Влизане"})]})]})})};function Ux(){return R.jsx(Hb,{children:R.jsxs(gb,{children:[R.jsxs(au,{path:"/",element:R.jsx(kx,{children:R.jsx(Bx,{})}),children:[R.jsx(au,{index:!0,element:R.jsx(Lx,{})}),R.jsx(au,{path:":topicId",element:R.jsx(Hx,{})})]}),R.jsx(au,{path:"/edit",element:R.jsx(Nx,{})})]})})}function kx({children:a}){return Me(s=>s.isLoading)?null:a}function Bx(){const a=Me(r=>r.config),u=Bm(),s=Lm();return R.jsxs("div",{className:"max-w-7xl mx-auto h-full relative flex flex-col",children:[a.displayTitle&&R.jsxs("div",{className:"w-full px-4 py-2 font-medium text-large text-white bg-blue-600",style:{lineHeight:1.2},children:[R.jsx("div",{className:"text-sm font-normal",children:u.name}),R.jsx("span",{children:s?`${s.sequence}: ${s.title}`:"Конспект за Държавен Изпит"})]}),R.jsx(pb,{})]})}function Lx(){const a=C.useRef({}),u=Me(g=>g.subjects),s=Bm(),r=Me(g=>g.selectSubject),[o,f]=C.useState(!1),p=Lm(),m=Me(g=>g.selectTopic),b=Me(g=>g.config),h=Me(g=>g.changeConfig);return C.useLayoutEffect(()=>{var g;p&&((g=a.current)==null||g[Math.max(p.index-3,0)].scrollIntoView())},[p]),R.jsxs(R.Fragment,{children:[R.jsx("div",{className:`flex-1 overflow-y-scroll ${p===null?"pb-[92px]":"pb-[156px]"}`,children:s.topics.map((g,w)=>R.jsxs(ul,{ref:E=>{a.current[w]=E},to:`/${g.id}`,onClick:()=>m(w),className:`flex px-2 py-1 rounded-md cursor-pointer border-l-4 ${g.id===(p==null?void 0:p.id)?"bg-blue-100 border-blue-500":"border-transparent hover:bg-gray-100"}`,children:[R.jsx("div",{className:`w-6 flex-shrink-0 flex font-medium justify-end ${g.id===(p==null?void 0:p.id)?"text-blue-600":"text-blue-800"}`,children:g.sequence}),R.jsx("span",{className:`ml-2 leading-5 ${g.id===(p==null?void 0:p.id)?"font-medium":"font-normal"} ${b.wrapTopicTitles?"truncate":""}`,children:g.title})]},g.id))}),R.jsxs("div",{className:"absolute bottom-0 sm:p-4 px-2 py-0 w-full flex flex-col",children:[R.jsxs("div",{className:"ml-auto p-2 flex space-x-1 h-[60px]",children:[R.jsx("button",{className:`cursor-pointer p-2 rounded-full text-white border ${b.displayTitle?"bg-blue-100 border-blue-400":"bg-gray-100 border-gray-400"}`,onClick:()=>h({displayTitle:!b.displayTitle}),children:R.jsx(Hm,{className:"fill-gray-600"})}),R.jsx("button",{className:`cursor-pointer p-2 rounded-full text-white border ${b.wrapTopicTitles?"bg-blue-100 border-blue-400":"bg-gray-100 border-gray-400"}`,onClick:()=>h({wrapTopicTitles:!b.wrapTopicTitles}),children:R.jsx(Rx,{className:"fill-gray-600"})}),p&&R.jsx("button",{className:"px-3 py-3 bg-teal-500 hover:bg-teal-300 cursor-pointer rounded-full flex items-center justify-center shadow-md transition-colors",onClick:()=>{var g;(g=a.current)==null||g[Math.max(p.index-3,0)].scrollIntoView({behavior:"smooth"})},children:R.jsx(xx,{className:"h-5 w-5"})}),R.jsxs("div",{className:"relative flex ml-2",children:[R.jsx("button",{className:`${o?"invisible":""} flex-1 shadow-xl cursor-pointer px-2 py-1 rounded-md text-xs text-blue-800 font-medium whitespace-nowrap bg-blue-100/50 backdrop-blur hover:bg-blue-200/50 border border-blue-100`,onClick:()=>f(!0),children:s.name}),o&&R.jsxs(R.Fragment,{children:[R.jsx("button",{className:"absolute w-full h-full flex-1 flex justify-center items-center cursor-pointer rounded-md backdrop-blur bg-blue-100/40 hover:bg-blue-100/80",onClick:()=>f(!1),children:R.jsx(qm,{className:"fill-gray-600"})}),R.jsx("div",{className:"absolute bottom-full right-0 p-2 flex space-x-1",children:u.map((g,w)=>R.jsx("button",{className:`flex-1 shadow-xl cursor-pointer px-2 py-1 rounded-md text-xs whitespace-nowrap h-[44px] ${s.id===g.id?"bg-blue-100 text-blue-800 font-medium border border-blue-400":"bg-gray-100 hover:bg-gray-200 border border-gray-400"}`,onClick:()=>{r(w),f(!1)},children:g.name},g.id))})]})]})]}),p&&R.jsxs(ul,{to:`/${p.id}`,className:"w-full p-2 mb-2 bg-blue-600 hover:bg-blue-700 cursor-pointer truncate rounded-md text-sm text-white text-center shadow-md transition-colors",children:[R.jsx("span",{children:"Продължи четенето:"}),R.jsx("br",{}),R.jsxs("span",{className:"font-medium",children:[p.sequence,". ",p.title]})]})]})]})}function Hx(){const a=bx();return a&&a.isLoading?null:a?R.jsx(qx,{topic:a},a.id):R.jsx(hb,{to:"/",replace:!0})}function qx({topic:a}){const u=Me(g=>g.config),s=Me(g=>g.changeConfig),{prevTopic:r,nextTopic:o}=vx(),[f,p]=C.useState(!1),[m,b]=C.useState(a.resources.length-1),h=a.resources[m];return R.jsxs(R.Fragment,{children:[R.jsxs("div",{className:"flex-1",children:[m===-1?R.jsx("div",{className:"text-sm font-medium p-4",children:"No data"}):R.jsx(Yx,{file:a.resources[m],compact:u.narrowMode,justifyText:u.justifyText,zoomFactor:u.contentZoomFactor}),R.jsxs("div",{className:"absolute bottom-10 flex justify-between px-4 py-2 w-full z-999",children:[R.jsx("div",{className:"flex w-full space-x-2",children:R.jsx(ul,{to:"/",className:"cursor-pointer p-2 rounded-full bg-blue-600 text-white mr-auto",children:R.jsx(Ox,{className:"fill-gray-100"})})}),R.jsxs("div",{className:"flex items-center",children:[R.jsxs("div",{className:"text-sm text-gray-600 rounded bg-gray-300/30 backdrop-blur px-2",children:[u.contentZoomLevel,"%"]}),R.jsx("button",{className:"cursor-pointer p-2 mx-1 rounded-full text-white bg-gray-100/30 backdrop-blur",onClick:()=>s({contentZoomLevel:Math.max(50,u.contentZoomLevel-10)}),children:R.jsx(Tx,{className:"fill-gray-600"})}),R.jsx("button",{className:"cursor-pointer p-2 rounded-full text-white bg-gray-100/30 backdrop-blur",onClick:()=>{s({contentZoomLevel:Math.min(150,u.contentZoomLevel+10)})},children:R.jsx(Ex,{className:"fill-gray-600"})}),R.jsx(wx,{className:"fill-gray-300"}),R.jsx("button",{className:`cursor-pointer p-2 mr-1 rounded-full text-white border ${u.displayTitle?"bg-blue-100 border-blue-400":"bg-gray-100 border-gray-400"}`,onClick:()=>s({displayTitle:!u.displayTitle}),children:R.jsx(Hm,{className:"fill-gray-600"})}),R.jsx("button",{className:`cursor-pointer p-2 mr-1 rounded-full text-white border ${u.justifyText?"bg-blue-100 border-blue-400":"bg-gray-100 border-gray-400"}`,onClick:()=>s({justifyText:!u.justifyText}),children:R.jsx(Sx,{className:"fill-gray-600"})}),window.innerWidth>576&&R.jsx("button",{className:`cursor-pointer p-2 mr-1 rounded-full text-white border ${u.narrowMode?"bg-blue-100 border-blue-400":"bg-gray-100 border-gray-400"}`,onClick:()=>s({narrowMode:!u.narrowMode}),children:R.jsx(Ax,{className:"fill-gray-600"})}),a.resources.length>1&&R.jsxs("div",{className:"relative h-full flex ml-2",children:[R.jsxs("button",{className:`${f?"invisible":""} flex-1 shadow-xl cursor-pointer px-2 py-1 rounded-md text-xs text-blue-800 font-medium whitespace-nowrap bg-blue-100/50 backdrop-blur hover:bg-blue-200/50 border border-blue-100`,onClick:()=>p(!0),children:["Версия ",h.version]}),f&&R.jsx("button",{className:"absolute w-full h-full flex-1 flex justify-center items-center cursor-pointer rounded-md hover:backdrop-blur hover:bg-blue-100/30",onClick:()=>p(!1),children:R.jsx(qm,{className:"fill-gray-600"})})]})]}),f&&R.jsx("div",{className:"absolute bottom-full right-0 px-4 flex space-x-1 h-10",children:a.resources.map((g,w)=>R.jsxs("button",{className:`flex-1 shadow-xl cursor-pointer px-2 py-1 rounded-md text-xs whitespace-nowrap ${h.id===g.id?"bg-blue-100 text-blue-800 font-medium border border-blue-400":"bg-gray-100 hover:bg-gray-200 border border-gray-400"}`,onClick:()=>{b(w),p(!1)},children:["Версия ",g.version]},g.id))})]})]}),R.jsx("div",{className:"w-full flex flex-col space-y-2",children:R.jsxs("div",{className:"flex bg-gray-100 border-t border-blue-200 text-center",children:[r===null?R.jsx("div",{className:"flex-1 border-r border-blue-200"}):R.jsxs(ul,{to:`/${r.id}`,className:"border-r border-blue-200 w-1/2 flex-1 px-4 py-2 hover:bg-blue-200 cursor-pointer flex align-center justify-start",children:[R.jsx(zx,{}),R.jsxs("span",{className:"ml-2 truncate w-full ",children:[r.sequence,": ",r.title]})]}),o===null?R.jsx("div",{className:"flex-1"}):R.jsxs(ul,{to:`/${o.id}`,className:"flex-1 px-4 py-2 hover:bg-blue-200 w-1/2 cursor-pointer flex align-center justify-end",children:[R.jsxs("span",{className:"mr-2 w-full truncate",children:[o.sequence,": ",o.title]}),R.jsx(_x,{})]})]})})]})}function Yx({file:a,compact:u,zoomFactor:s,justifyText:r}){const o=C.useRef(null),[f,p]=C.useState(null),m=C.useMemo(()=>`
diff --git a/reader/dist/index.html b/reader/dist/index.html
index 5ed984f..9fb3bca 100644
--- a/reader/dist/index.html
+++ b/reader/dist/index.html
@@ -7,7 +7,7 @@
Конспект
-
+
diff --git a/reader/src/App.jsx b/reader/src/App.jsx
index ea358d8..d2b50e1 100644
--- a/reader/src/App.jsx
+++ b/reader/src/App.jsx
@@ -230,19 +230,19 @@ export function Reader({ topic }) {
const selectedResource = topic.resources[resourceIdx];
- if (resourceIdx === -1) {
- return No data
;
- }
-
return (
<>
-
+ {resourceIdx === -1 ? (
+
No data
+ ) : (
+
+ )}