10 lines
60 KiB
JavaScript
10 lines
60 KiB
JavaScript
import{j as e,P as I,B as k,G as j,D as we,L as H,T as E,E as Mt,a as $,b as ot,c as _,C as K,S as re,A as at,M as qe,d as z,e as it,f as ct,g as lt,u as pe,h as oe,i as se,k as W,l as ut,m as ge,n as xe,o as Ut,p as Xe,I as Z,q as Nt,r as ee,s as te,t as Ht,v as $t,w as dt,x as qt,y as ht,z as mt,F as Bt,H as zt,J as Wt,K as Gt,N as Qt,O as Jt,Q as Kt,R as Yt,U as Xt,V as Ae,W as Vt,X as Zt}from"./mui-BnAUJOoN.js";import{u as Be,a as ae,b as en,L as Q,c as tn,O as nn,d as ie,e as Y,f as ce,g as rn,h as sn,q as ze,i as Pe,j as We,r as Le,k as on,R as an,Q as cn,l as ln}from"./tanstack-BqkrhB-y.js";import{d as un,r as b,g as Ge,b as he}from"./react-C9_qfvjK.js";import{c as dn}from"./zustand-DKxXQGKw.js";import{i as de,B as hn,a as mn,b as fn,u as F,t as A,T as pn}from"./i18n-Be01V9yD.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))o(r);new MutationObserver(r=>{for(const a of r)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&o(l)}).observe(document,{childList:!0,subtree:!0});function s(r){const a={};return r.integrity&&(a.integrity=r.integrity),r.referrerPolicy&&(a.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?a.credentials="include":r.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function o(r){if(r.ep)return;r.ep=!0;const a=s(r);fetch(r.href,a)}})();var Fe={},Ve=un;Fe.createRoot=Ve.createRoot,Fe.hydrateRoot=Ve.hydrateRoot;const ke=15,gn=3;var Te={BASE_URL:"/phpCourse/exam/dist",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const Me=new Map,je=n=>{const t=Me.get(n);return t?Object.fromEntries(Object.entries(t.stores).map(([s,o])=>[s,o.getState()])):{}},xn=(n,t,s)=>{if(n===void 0)return{type:"untracked",connection:t.connect(s)};const o=Me.get(s.name);if(o)return{type:"tracked",store:n,...o};const r={connection:t.connect(s),stores:{}};return Me.set(s.name,r),{type:"tracked",store:n,...r}},vn=(n,t={})=>(s,o,r)=>{const{enabled:a,anonymousActionType:l,store:c,...d}=t;let h;try{h=(a??(Te?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!h)return(Te?"production":void 0)!=="production"&&a&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),n(s,o,r);const{connection:u,...i}=xn(c,h,d);let m=!0;r.setState=(g,x,y)=>{const v=s(g,x);if(!m)return v;const P=y===void 0?{type:l||"anonymous"}:typeof y=="string"?{type:y}:y;return c===void 0?(u==null||u.send(P,o()),v):(u==null||u.send({...P,type:`${c}/${P.type}`},{...je(d.name),[c]:r.getState()}),v)};const f=(...g)=>{const x=m;m=!1,s(...g),m=x},p=n(r.setState,o,r);if(i.type==="untracked"?u==null||u.init(p):(i.stores[i.store]=r,u==null||u.init(Object.fromEntries(Object.entries(i.stores).map(([g,x])=>[g,g===i.store?p:x.getState()])))),r.dispatchFromDevtools&&typeof r.dispatch=="function"){let g=!1;const x=r.dispatch;r.dispatch=(...y)=>{(Te?"production":void 0)!=="production"&&y[0].type==="__setState"&&!g&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),g=!0),x(...y)}}return u.subscribe(g=>{var x;switch(g.type){case"ACTION":if(typeof g.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return _e(g.payload,y=>{if(y.type==="__setState"){if(c===void 0){f(y.state);return}Object.keys(y.state).length!==1&&console.error(`
|
|
[zustand devtools middleware] Unsupported __setState action format.
|
|
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
|
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|
|
`);const v=y.state[c];if(v==null)return;JSON.stringify(r.getState())!==JSON.stringify(v)&&f(v);return}r.dispatchFromDevtools&&typeof r.dispatch=="function"&&r.dispatch(y)});case"DISPATCH":switch(g.payload.type){case"RESET":return f(p),c===void 0?u==null?void 0:u.init(r.getState()):u==null?void 0:u.init(je(d.name));case"COMMIT":if(c===void 0){u==null||u.init(r.getState());return}return u==null?void 0:u.init(je(d.name));case"ROLLBACK":return _e(g.state,y=>{if(c===void 0){f(y),u==null||u.init(r.getState());return}f(y[c]),u==null||u.init(je(d.name))});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return _e(g.state,y=>{if(c===void 0){f(y);return}JSON.stringify(r.getState())!==JSON.stringify(y[c])&&f(y[c])});case"IMPORT_STATE":{const{nextLiftedState:y}=g.payload,v=(x=y.computedStates.slice(-1)[0])==null?void 0:x.state;if(!v)return;f(c===void 0?v:v[c]),u==null||u.send(null,y);return}case"PAUSE_RECORDING":return m=!m}return}}),p},yn=vn,_e=(n,t)=>{let s;try{s=JSON.parse(n)}catch(o){console.error("[zustand devtools middleware] Could not parse the received json",o)}s!==void 0&&t(s)};function jn(n,t){let s;try{s=n()}catch{return}return{getItem:r=>{var a;const l=d=>d===null?null:JSON.parse(d,void 0),c=(a=s.getItem(r))!=null?a:null;return c instanceof Promise?c.then(l):l(c)},setItem:(r,a)=>s.setItem(r,JSON.stringify(a,void 0)),removeItem:r=>s.removeItem(r)}}const me=n=>t=>{try{const s=n(t);return s instanceof Promise?s:{then(o){return me(o)(s)},catch(o){return this}}}catch(s){return{then(o){return this},catch(o){return me(o)(s)}}}},Tn=(n,t)=>(s,o,r)=>{let a={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:x=>x,version:0,merge:(x,y)=>({...y,...x}),...t},l=!1;const c=new Set,d=new Set;let h;try{h=a.getStorage()}catch{}if(!h)return n((...x)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),s(...x)},o,r);const u=me(a.serialize),i=()=>{const x=a.partialize({...o()});let y;const v=u({state:x,version:a.version}).then(P=>h.setItem(a.name,P)).catch(P=>{y=P});if(y)throw y;return v},m=r.setState;r.setState=(x,y)=>{m(x,y),i()};const f=n((...x)=>{s(...x),i()},o,r);let p;const g=()=>{var x;if(!h)return;l=!1,c.forEach(v=>v(o()));const y=((x=a.onRehydrateStorage)==null?void 0:x.call(a,o()))||void 0;return me(h.getItem.bind(h))(a.name).then(v=>{if(v)return a.deserialize(v)}).then(v=>{if(v)if(typeof v.version=="number"&&v.version!==a.version){if(a.migrate)return a.migrate(v.state,v.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return v.state}).then(v=>{var P;return p=a.merge(v,(P=o())!=null?P:f),s(p,!0),i()}).then(()=>{y==null||y(p,void 0),l=!0,d.forEach(v=>v(p))}).catch(v=>{y==null||y(void 0,v)})};return r.persist={setOptions:x=>{a={...a,...x},x.getStorage&&(h=x.getStorage())},clearStorage:()=>{h==null||h.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>g(),hasHydrated:()=>l,onHydrate:x=>(c.add(x),()=>{c.delete(x)}),onFinishHydration:x=>(d.add(x),()=>{d.delete(x)})},g(),p||f},Cn=(n,t)=>(s,o,r)=>{let a={storage:jn(()=>localStorage),partialize:g=>g,version:0,merge:(g,x)=>({...x,...g}),...t},l=!1;const c=new Set,d=new Set;let h=a.storage;if(!h)return n((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),s(...g)},o,r);const u=()=>{const g=a.partialize({...o()});return h.setItem(a.name,{state:g,version:a.version})},i=r.setState;r.setState=(g,x)=>{i(g,x),u()};const m=n((...g)=>{s(...g),u()},o,r);r.getInitialState=()=>m;let f;const p=()=>{var g,x;if(!h)return;l=!1,c.forEach(v=>{var P;return v((P=o())!=null?P:m)});const y=((x=a.onRehydrateStorage)==null?void 0:x.call(a,(g=o())!=null?g:m))||void 0;return me(h.getItem.bind(h))(a.name).then(v=>{if(v)if(typeof v.version=="number"&&v.version!==a.version){if(a.migrate)return a.migrate(v.state,v.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return v.state}).then(v=>{var P;return f=a.merge(v,(P=o())!=null?P:m),s(f,!0),u()}).then(()=>{y==null||y(f,void 0),f=o(),l=!0,d.forEach(v=>v(f))}).catch(v=>{y==null||y(void 0,v)})};return r.persist={setOptions:g=>{a={...a,...g},g.storage&&(h=g.storage)},clearStorage:()=>{h==null||h.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>p(),hasHydrated:()=>l,onHydrate:g=>(c.add(g),()=>{c.delete(g)}),onFinishHydration:g=>(d.add(g),()=>{d.delete(g)})},a.skipHydration||p(),f||m},Sn=(n,t)=>"getStorage"in t||"serialize"in t||"deserialize"in t?((Te?"production":void 0)!=="production"&&console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."),Tn(n,t)):Cn(n,t),En=Sn,Oe=dn()(yn(En(n=>({theme:void 0,currentSession:[void 0,void 0],setTheme:t=>n(()=>({theme:t})),setCurrentSession:t=>n(()=>({currentSession:t}))}),{name:"guestbook-storage"}))),G="https://khofmann.userpage.fu-berlin.de/phpCourse/exam/api/",ft=b.createContext({hasAuth:!1,currentSession:[void 0,void 0]}),M=()=>{const{hasAuth:n,authenticatedUser:t,currentSession:s,logIn:o,logOut:r,posts:a,newPost:l,updatePost:c,deletePost:d,user:h,createUser:u,confirmUser:i,updateUser:m,updateUserImage:f,userPosts:p}=b.useContext(ft);if(o&&r&&a&&l&&c&&d&&h&&u&&i&&m&&f&&p)return{hasAuth:n,authenticatedUser:t,currentSession:s,logIn:o,logOut:r,posts:a,newPost:l,updatePost:c,deletePost:d,user:h,createUser:u,confirmUser:i,updateUser:m,updateUserImage:f,userPosts:p};throw new Error("Couldn't find context. Is your component inside an ApiProvider?")},bn=({children:n})=>{const[t,s]=b.useState(!1),[o,r]=b.useState(),[a,l]=Oe(T=>[T.currentSession,T.setCurrentSession]),c=b.useRef();b.useEffect(()=>{a[0]&&!c.current&&(c.current=a[0],Ye())},[a]);const d=async(T,S)=>{const{user:w,token:O,refreshToken:Ft}=await(await ye("login",{email:T,password:S})).json();r(w),l([O,Ft]),s(!0),c.current=O},h=async()=>{try{return c.current?await(await q(()=>Ie("logout"))).json():!0}catch{return!1}finally{r(void 0),l([void 0,void 0]),s(!1),c.current=void 0}},u=async T=>{const S=`posts?p=${T??0}&l=${ke}`;return t?await(await q(()=>Re(S))).json():await(await _t(S)).json()},i=async T=>await(await q(()=>Ie(`posts?l=${ke}`,T))).json(),m=async(T,S)=>await(await q(()=>Ke(`posts/${S}`,T))).json(),f=async T=>await(await q(()=>Dt(`posts/${T}?l=${ke}`))).json(),p=async T=>await(await q(()=>Re(`users/${T??(o==null?void 0:o.id)}`))).json(),g=async T=>await(await ye("register",T)).json(),x=async T=>await(await Lt("register",{code:T})).json(),y=async(T,S)=>{const w=await(await q(()=>Ke(`users/${S??"self"}`,T))).json();return r(w),w},v=async(T,S)=>{const w=new FormData;T.image&&w.append("image",T.image),!T.image&&T.predefined&&w.append("predefined",T.predefined);const O=await(await q(()=>kt(`users/${S??"self"}/image`,w))).json();return r(O),O},P=async T=>await(await q(()=>Re(`users/${T}/posts?l=${gn}&s=desc`))).json(),ye=async(T,S,w)=>{const O=await fetch(`${G}${T}`,{mode:"cors",method:"post",headers:w,body:JSON.stringify(S)});if(O.ok)return O;throw await O.json()},Ie=async(T,S,w)=>{const O=await fetch(`${G}${T}`,{mode:"cors",method:"post",headers:{token:c.current??"",...w},body:JSON.stringify(S)});if(O.ok)return O;throw await O.json()},kt=async(T,S,w)=>{const O=await fetch(`${G}${T}`,{mode:"cors",method:"post",headers:{token:c.current??"",...w},body:S});if(O.ok)return O;throw await O.json()},_t=async(T,S)=>{const w=await fetch(`${G}${T}`,{mode:"cors",method:"get",headers:S});if(w.ok)return w;throw await w.json()},Re=async(T,S)=>{const w=await fetch(`${G}${T}`,{mode:"cors",method:"get",headers:{token:c.current??"",...S}});if(w.ok)return w;throw await w.json()},Dt=async(T,S)=>{const w=await fetch(`${G}${T}`,{mode:"cors",method:"delete",headers:{token:c.current??"",...S}});if(w.ok)return w;throw await w.json()},Lt=async(T,S,w)=>{const O=await fetch(`${G}${T}`,{mode:"cors",method:"patch",headers:w,body:JSON.stringify(S)});if(O.ok)return O;throw await O.json()},Ke=async(T,S,w)=>{const O=await fetch(`${G}${T}`,{mode:"cors",method:"patch",headers:{token:c.current??"",...w},body:JSON.stringify(S)});if(O.ok)return O;throw await O.json()},q=async T=>{try{return console.log("[REAUTH] fetching"),await T()}catch{try{return console.log("[REAUTH] fail, refreshing"),await Ye(),console.log("[REAUTH] refreshed, fetching again"),await T()}catch(S){throw console.log("[REAUTH] terminating session",S),r(void 0),s(!1),l([void 0,void 0]),c.current=void 0,S}}},Ye=async()=>{const{user:T,token:S,refreshToken:w}=await(await Ie("refresh",{refreshToken:a[1]??"INVALID DEFAULT"})).json();r(T),l([S,w]),s(!0),c.current=S};return e.jsx(ft.Provider,{value:{hasAuth:t,authenticatedUser:o,currentSession:a,logIn:d,logOut:h,posts:u,newPost:i,updatePost:m,deletePost:f,user:p,createUser:g,confirmUser:x,updateUser:y,updateUserImage:v,userPosts:P},children:n})};de.use(hn).use(mn).use(fn).init({fallbackLng:"en",debug:!1,interpolation:{escapeValue:!1},backend:{loadPath:"/phpCourse/exam/dist/locales/{{lng}}/{{ns}}.json"}});function wn(n){return n&&typeof n=="object"&&"default"in n?n.default:n}var pt=b,An=wn(pt);function Ze(n,t,s){return t in n?Object.defineProperty(n,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):n[t]=s,n}function Pn(n,t){n.prototype=Object.create(t.prototype),n.prototype.constructor=n,n.__proto__=t}var On=!!(typeof window<"u"&&window.document&&window.document.createElement);function In(n,t,s){if(typeof n!="function")throw new Error("Expected reducePropsToState to be a function.");if(typeof t!="function")throw new Error("Expected handleStateChangeOnClient to be a function.");if(typeof s<"u"&&typeof s!="function")throw new Error("Expected mapStateOnServer to either be undefined or a function.");function o(r){return r.displayName||r.name||"Component"}return function(a){if(typeof a!="function")throw new Error("Expected WrappedComponent to be a React component.");var l=[],c;function d(){c=n(l.map(function(u){return u.props})),h.canUseDOM?t(c):s&&(c=s(c))}var h=function(u){Pn(i,u);function i(){return u.apply(this,arguments)||this}i.peek=function(){return c},i.rewind=function(){if(i.canUseDOM)throw new Error("You may only call rewind() on the server. Call peek() to read the current state.");var p=c;return c=void 0,l=[],p};var m=i.prototype;return m.UNSAFE_componentWillMount=function(){l.push(this),d()},m.componentDidUpdate=function(){d()},m.componentWillUnmount=function(){var p=l.indexOf(this);l.splice(p,1),d()},m.render=function(){return An.createElement(a,this.props)},i}(pt.PureComponent);return Ze(h,"displayName","SideEffect("+o(a)+")"),Ze(h,"canUseDOM",On),h}}var Rn=In;const kn=Ge(Rn);var _n=typeof Element<"u",Dn=typeof Map=="function",Ln=typeof Set=="function",Fn=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function Ce(n,t){if(n===t)return!0;if(n&&t&&typeof n=="object"&&typeof t=="object"){if(n.constructor!==t.constructor)return!1;var s,o,r;if(Array.isArray(n)){if(s=n.length,s!=t.length)return!1;for(o=s;o--!==0;)if(!Ce(n[o],t[o]))return!1;return!0}var a;if(Dn&&n instanceof Map&&t instanceof Map){if(n.size!==t.size)return!1;for(a=n.entries();!(o=a.next()).done;)if(!t.has(o.value[0]))return!1;for(a=n.entries();!(o=a.next()).done;)if(!Ce(o.value[1],t.get(o.value[0])))return!1;return!0}if(Ln&&n instanceof Set&&t instanceof Set){if(n.size!==t.size)return!1;for(a=n.entries();!(o=a.next()).done;)if(!t.has(o.value[0]))return!1;return!0}if(Fn&&ArrayBuffer.isView(n)&&ArrayBuffer.isView(t)){if(s=n.length,s!=t.length)return!1;for(o=s;o--!==0;)if(n[o]!==t[o])return!1;return!0}if(n.constructor===RegExp)return n.source===t.source&&n.flags===t.flags;if(n.valueOf!==Object.prototype.valueOf&&typeof n.valueOf=="function"&&typeof t.valueOf=="function")return n.valueOf()===t.valueOf();if(n.toString!==Object.prototype.toString&&typeof n.toString=="function"&&typeof t.toString=="function")return n.toString()===t.toString();if(r=Object.keys(n),s=r.length,s!==Object.keys(t).length)return!1;for(o=s;o--!==0;)if(!Object.prototype.hasOwnProperty.call(t,r[o]))return!1;if(_n&&n instanceof Element)return!1;for(o=s;o--!==0;)if(!((r[o]==="_owner"||r[o]==="__v"||r[o]==="__o")&&n.$$typeof)&&!Ce(n[r[o]],t[r[o]]))return!1;return!0}return n!==n&&t!==t}var Mn=function(t,s){try{return Ce(t,s)}catch(o){if((o.message||"").match(/stack|recursion/i))return console.warn("react-fast-compare cannot handle circular refs"),!1;throw o}};const Un=Ge(Mn);/*
|
|
object-assign
|
|
(c) Sindre Sorhus
|
|
@license MIT
|
|
*/var et=Object.getOwnPropertySymbols,Nn=Object.prototype.hasOwnProperty,Hn=Object.prototype.propertyIsEnumerable;function $n(n){if(n==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(n)}function qn(){try{if(!Object.assign)return!1;var n=new String("abc");if(n[5]="de",Object.getOwnPropertyNames(n)[0]==="5")return!1;for(var t={},s=0;s<10;s++)t["_"+String.fromCharCode(s)]=s;var o=Object.getOwnPropertyNames(t).map(function(a){return t[a]});if(o.join("")!=="0123456789")return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(a){r[a]=a}),Object.keys(Object.assign({},r)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}var Bn=qn()?Object.assign:function(n,t){for(var s,o=$n(n),r,a=1;a<arguments.length;a++){s=Object(arguments[a]);for(var l in s)Nn.call(s,l)&&(o[l]=s[l]);if(et){r=et(s);for(var c=0;c<r.length;c++)Hn.call(s,r[c])&&(o[r[c]]=s[r[c]])}}return o};const zn=Ge(Bn);var J={BODY:"bodyAttributes",HTML:"htmlAttributes",TITLE:"titleAttributes"},C={BASE:"base",BODY:"body",HEAD:"head",HTML:"html",LINK:"link",META:"meta",NOSCRIPT:"noscript",SCRIPT:"script",STYLE:"style",TITLE:"title"};Object.keys(C).map(function(n){return C[n]});var R={CHARSET:"charset",CSS_TEXT:"cssText",HREF:"href",HTTPEQUIV:"http-equiv",INNER_HTML:"innerHTML",ITEM_PROP:"itemprop",NAME:"name",PROPERTY:"property",REL:"rel",SRC:"src",TARGET:"target"},be={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},fe={DEFAULT_TITLE:"defaultTitle",DEFER:"defer",ENCODE_SPECIAL_CHARACTERS:"encodeSpecialCharacters",ON_CHANGE_CLIENT_STATE:"onChangeClientState",TITLE_TEMPLATE:"titleTemplate"},Wn=Object.keys(be).reduce(function(n,t){return n[be[t]]=t,n},{}),Gn=[C.NOSCRIPT,C.SCRIPT,C.STYLE],U="data-react-helmet",Qn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Jn=function(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function")},Kn=function(){function n(t,s){for(var o=0;o<s.length;o++){var r=s[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(t,s,o){return s&&n(t.prototype,s),o&&n(t,o),t}}(),D=Object.assign||function(n){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(n[o]=s[o])}return n},Yn=function(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof t);n.prototype=Object.create(t&&t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(n,t):n.__proto__=t)},tt=function(n,t){var s={};for(var o in n)t.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(n,o)&&(s[o]=n[o]);return s},Xn=function(n,t){if(!n)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t&&(typeof t=="object"||typeof t=="function")?t:n},Ue=function(t){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return s===!1?String(t):String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")},Vn=function(t){var s=ne(t,C.TITLE),o=ne(t,fe.TITLE_TEMPLATE);if(o&&s)return o.replace(/%s/g,function(){return Array.isArray(s)?s.join(""):s});var r=ne(t,fe.DEFAULT_TITLE);return s||r||void 0},Zn=function(t){return ne(t,fe.ON_CHANGE_CLIENT_STATE)||function(){}},De=function(t,s){return s.filter(function(o){return typeof o[t]<"u"}).map(function(o){return o[t]}).reduce(function(o,r){return D({},o,r)},{})},er=function(t,s){return s.filter(function(o){return typeof o[C.BASE]<"u"}).map(function(o){return o[C.BASE]}).reverse().reduce(function(o,r){if(!o.length)for(var a=Object.keys(r),l=0;l<a.length;l++){var c=a[l],d=c.toLowerCase();if(t.indexOf(d)!==-1&&r[d])return o.concat(r)}return o},[])},le=function(t,s,o){var r={};return o.filter(function(a){return Array.isArray(a[t])?!0:(typeof a[t]<"u"&&sr("Helmet: "+t+' should be of type "Array". Instead found type "'+Qn(a[t])+'"'),!1)}).map(function(a){return a[t]}).reverse().reduce(function(a,l){var c={};l.filter(function(m){for(var f=void 0,p=Object.keys(m),g=0;g<p.length;g++){var x=p[g],y=x.toLowerCase();s.indexOf(y)!==-1&&!(f===R.REL&&m[f].toLowerCase()==="canonical")&&!(y===R.REL&&m[y].toLowerCase()==="stylesheet")&&(f=y),s.indexOf(x)!==-1&&(x===R.INNER_HTML||x===R.CSS_TEXT||x===R.ITEM_PROP)&&(f=x)}if(!f||!m[f])return!1;var v=m[f].toLowerCase();return r[f]||(r[f]={}),c[f]||(c[f]={}),r[f][v]?!1:(c[f][v]=!0,!0)}).reverse().forEach(function(m){return a.push(m)});for(var d=Object.keys(c),h=0;h<d.length;h++){var u=d[h],i=zn({},r[u],c[u]);r[u]=i}return a},[]).reverse()},ne=function(t,s){for(var o=t.length-1;o>=0;o--){var r=t[o];if(r.hasOwnProperty(s))return r[s]}return null},tr=function(t){return{baseTag:er([R.HREF,R.TARGET],t),bodyAttributes:De(J.BODY,t),defer:ne(t,fe.DEFER),encode:ne(t,fe.ENCODE_SPECIAL_CHARACTERS),htmlAttributes:De(J.HTML,t),linkTags:le(C.LINK,[R.REL,R.HREF],t),metaTags:le(C.META,[R.NAME,R.CHARSET,R.HTTPEQUIV,R.PROPERTY,R.ITEM_PROP],t),noscriptTags:le(C.NOSCRIPT,[R.INNER_HTML],t),onChangeClientState:Zn(t),scriptTags:le(C.SCRIPT,[R.SRC,R.INNER_HTML],t),styleTags:le(C.STYLE,[R.CSS_TEXT],t),title:Vn(t),titleAttributes:De(J.TITLE,t)}},Ne=function(){var n=Date.now();return function(t){var s=Date.now();s-n>16?(n=s,t(s)):setTimeout(function(){Ne(t)},0)}}(),nt=function(t){return clearTimeout(t)},nr=typeof window<"u"?window.requestAnimationFrame&&window.requestAnimationFrame.bind(window)||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||Ne:global.requestAnimationFrame||Ne,rr=typeof window<"u"?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||nt:global.cancelAnimationFrame||nt,sr=function(t){return console&&typeof console.warn=="function"&&console.warn(t)},ue=null,or=function(t){ue&&rr(ue),t.defer?ue=nr(function(){rt(t,function(){ue=null})}):(rt(t),ue=null)},rt=function(t,s){var o=t.baseTag,r=t.bodyAttributes,a=t.htmlAttributes,l=t.linkTags,c=t.metaTags,d=t.noscriptTags,h=t.onChangeClientState,u=t.scriptTags,i=t.styleTags,m=t.title,f=t.titleAttributes;He(C.BODY,r),He(C.HTML,a),ar(m,f);var p={baseTag:V(C.BASE,o),linkTags:V(C.LINK,l),metaTags:V(C.META,c),noscriptTags:V(C.NOSCRIPT,d),scriptTags:V(C.SCRIPT,u),styleTags:V(C.STYLE,i)},g={},x={};Object.keys(p).forEach(function(y){var v=p[y],P=v.newTags,ye=v.oldTags;P.length&&(g[y]=P),ye.length&&(x[y]=p[y].oldTags)}),s&&s(),h(t,g,x)},gt=function(t){return Array.isArray(t)?t.join(""):t},ar=function(t,s){typeof t<"u"&&document.title!==t&&(document.title=gt(t)),He(C.TITLE,s)},He=function(t,s){var o=document.getElementsByTagName(t)[0];if(o){for(var r=o.getAttribute(U),a=r?r.split(","):[],l=[].concat(a),c=Object.keys(s),d=0;d<c.length;d++){var h=c[d],u=s[h]||"";o.getAttribute(h)!==u&&o.setAttribute(h,u),a.indexOf(h)===-1&&a.push(h);var i=l.indexOf(h);i!==-1&&l.splice(i,1)}for(var m=l.length-1;m>=0;m--)o.removeAttribute(l[m]);a.length===l.length?o.removeAttribute(U):o.getAttribute(U)!==c.join(",")&&o.setAttribute(U,c.join(","))}},V=function(t,s){var o=document.head||document.querySelector(C.HEAD),r=o.querySelectorAll(t+"["+U+"]"),a=Array.prototype.slice.call(r),l=[],c=void 0;return s&&s.length&&s.forEach(function(d){var h=document.createElement(t);for(var u in d)if(d.hasOwnProperty(u))if(u===R.INNER_HTML)h.innerHTML=d.innerHTML;else if(u===R.CSS_TEXT)h.styleSheet?h.styleSheet.cssText=d.cssText:h.appendChild(document.createTextNode(d.cssText));else{var i=typeof d[u]>"u"?"":d[u];h.setAttribute(u,i)}h.setAttribute(U,"true"),a.some(function(m,f){return c=f,h.isEqualNode(m)})?a.splice(c,1):l.push(h)}),a.forEach(function(d){return d.parentNode.removeChild(d)}),l.forEach(function(d){return o.appendChild(d)}),{oldTags:a,newTags:l}},xt=function(t){return Object.keys(t).reduce(function(s,o){var r=typeof t[o]<"u"?o+'="'+t[o]+'"':""+o;return s?s+" "+r:r},"")},ir=function(t,s,o,r){var a=xt(o),l=gt(s);return a?"<"+t+" "+U+'="true" '+a+">"+Ue(l,r)+"</"+t+">":"<"+t+" "+U+'="true">'+Ue(l,r)+"</"+t+">"},cr=function(t,s,o){return s.reduce(function(r,a){var l=Object.keys(a).filter(function(h){return!(h===R.INNER_HTML||h===R.CSS_TEXT)}).reduce(function(h,u){var i=typeof a[u]>"u"?u:u+'="'+Ue(a[u],o)+'"';return h?h+" "+i:i},""),c=a.innerHTML||a.cssText||"",d=Gn.indexOf(t)===-1;return r+"<"+t+" "+U+'="true" '+l+(d?"/>":">"+c+"</"+t+">")},"")},vt=function(t){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Object.keys(t).reduce(function(o,r){return o[be[r]||r]=t[r],o},s)},lr=function(t){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Object.keys(t).reduce(function(o,r){return o[Wn[r]||r]=t[r],o},s)},ur=function(t,s,o){var r,a=(r={key:s},r[U]=!0,r),l=vt(o,a);return[he.createElement(C.TITLE,l,s)]},dr=function(t,s){return s.map(function(o,r){var a,l=(a={key:r},a[U]=!0,a);return Object.keys(o).forEach(function(c){var d=be[c]||c;if(d===R.INNER_HTML||d===R.CSS_TEXT){var h=o.innerHTML||o.cssText;l.dangerouslySetInnerHTML={__html:h}}else l[d]=o[c]}),he.createElement(t,l)})},B=function(t,s,o){switch(t){case C.TITLE:return{toComponent:function(){return ur(t,s.title,s.titleAttributes)},toString:function(){return ir(t,s.title,s.titleAttributes,o)}};case J.BODY:case J.HTML:return{toComponent:function(){return vt(s)},toString:function(){return xt(s)}};default:return{toComponent:function(){return dr(t,s)},toString:function(){return cr(t,s,o)}}}},yt=function(t){var s=t.baseTag,o=t.bodyAttributes,r=t.encode,a=t.htmlAttributes,l=t.linkTags,c=t.metaTags,d=t.noscriptTags,h=t.scriptTags,u=t.styleTags,i=t.title,m=i===void 0?"":i,f=t.titleAttributes;return{base:B(C.BASE,s,r),bodyAttributes:B(J.BODY,o,r),htmlAttributes:B(J.HTML,a,r),link:B(C.LINK,l,r),meta:B(C.META,c,r),noscript:B(C.NOSCRIPT,d,r),script:B(C.SCRIPT,h,r),style:B(C.STYLE,u,r),title:B(C.TITLE,{title:m,titleAttributes:f},r)}},hr=function(t){var s,o;return o=s=function(r){Yn(a,r);function a(){return Jn(this,a),Xn(this,r.apply(this,arguments))}return a.prototype.shouldComponentUpdate=function(c){return!Un(this.props,c)},a.prototype.mapNestedChildrenToProps=function(c,d){if(!d)return null;switch(c.type){case C.SCRIPT:case C.NOSCRIPT:return{innerHTML:d};case C.STYLE:return{cssText:d}}throw new Error("<"+c.type+" /> elements are self-closing and can not contain children. Refer to our API for more information.")},a.prototype.flattenArrayTypeChildren=function(c){var d,h=c.child,u=c.arrayTypeChildren,i=c.newChildProps,m=c.nestedChildren;return D({},u,(d={},d[h.type]=[].concat(u[h.type]||[],[D({},i,this.mapNestedChildrenToProps(h,m))]),d))},a.prototype.mapObjectTypeChildren=function(c){var d,h,u=c.child,i=c.newProps,m=c.newChildProps,f=c.nestedChildren;switch(u.type){case C.TITLE:return D({},i,(d={},d[u.type]=f,d.titleAttributes=D({},m),d));case C.BODY:return D({},i,{bodyAttributes:D({},m)});case C.HTML:return D({},i,{htmlAttributes:D({},m)})}return D({},i,(h={},h[u.type]=D({},m),h))},a.prototype.mapArrayTypeChildrenToProps=function(c,d){var h=D({},d);return Object.keys(c).forEach(function(u){var i;h=D({},h,(i={},i[u]=c[u],i))}),h},a.prototype.warnOnInvalidChildren=function(c,d){return!0},a.prototype.mapChildrenToProps=function(c,d){var h=this,u={};return he.Children.forEach(c,function(i){if(!(!i||!i.props)){var m=i.props,f=m.children,p=tt(m,["children"]),g=lr(p);switch(h.warnOnInvalidChildren(i,f),i.type){case C.LINK:case C.META:case C.NOSCRIPT:case C.SCRIPT:case C.STYLE:u=h.flattenArrayTypeChildren({child:i,arrayTypeChildren:u,newChildProps:g,nestedChildren:f});break;default:d=h.mapObjectTypeChildren({child:i,newProps:d,newChildProps:g,nestedChildren:f});break}}}),d=this.mapArrayTypeChildrenToProps(u,d),d},a.prototype.render=function(){var c=this.props,d=c.children,h=tt(c,["children"]),u=D({},h);return d&&(u=this.mapChildrenToProps(d,u)),he.createElement(t,u)},Kn(a,null,[{key:"canUseDOM",set:function(c){t.canUseDOM=c}}]),a}(he.Component),s.propTypes={base:I.object,bodyAttributes:I.object,children:I.oneOfType([I.arrayOf(I.node),I.node]),defaultTitle:I.string,defer:I.bool,encodeSpecialCharacters:I.bool,htmlAttributes:I.object,link:I.arrayOf(I.object),meta:I.arrayOf(I.object),noscript:I.arrayOf(I.object),onChangeClientState:I.func,script:I.arrayOf(I.object),style:I.arrayOf(I.object),title:I.string,titleAttributes:I.object,titleTemplate:I.string},s.defaultProps={defer:!0,encodeSpecialCharacters:!0},s.peek=t.peek,s.rewind=function(){var r=t.rewind();return r||(r=yt({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}})),r},o},mr=function(){return null},fr=kn(tr,or,yt)(mr),$e=hr(fr);$e.renderStatic=$e.rewind;const jt=()=>{const{t:n}=F();return e.jsx(k,{sx:{marginTop:2,display:"flex",justifyContent:"center"},children:e.jsx(k,{sx:{maxWidth:"800px",flexGrow:1},children:e.jsxs(j,{container:!0,spacing:2,children:[e.jsx(j,{item:!0,xs:12,sx:{height:"50px"}}),e.jsx(j,{item:!0,xs:12,children:e.jsx(we,{})}),e.jsx(j,{item:!0,xs:12,sx:{display:"flex",justifyContent:"center"},children:e.jsx(H,{href:"https://www.flaticon.com/free-icons/guests-book",title:"guests book icons",children:e.jsx(E,{variant:"caption",children:n("Favicon")})})}),e.jsx(j,{item:!0,xs:12,sx:{display:"flex",justifyContent:"center"},children:e.jsxs(E,{variant:"caption",children:["© 2024 Kilian Kurt Hofmann | Build ","1.0.2"]})})]})})})},Qe=({children:n})=>e.jsxs(e.Fragment,{children:[e.jsx(k,{sx:{flexGrow:1}}),e.jsx(k,{sx:{display:"flex",justifyContent:"center"},children:e.jsx(k,{sx:{maxWidth:"800px",flexGrow:1},children:n})}),e.jsx(k,{sx:{flexGrow:1}}),e.jsx(jt,{})]});var N=(n=>(n.INDEX="/",n.PROFILE="/profile",n.CONFIRM="/confirm",n))(N||{}),L=(n=>(n.NOT_FOUND="NotFound",n.UNAUTHORIZED="Unauthorized",n.NOT_ALLOWED="NotAllowed",n.FAILED_UPDATE="FailedUpdate",n.MISSING_FIELD="MissingField",n.DUPLICATE="Duplicate",n))(L||{});const pr=({error:n})=>{const{t}=F(),s=Be(),o=ae(),r=en();return b.useEffect(()=>{console.log(r.isReset()),r.reset()},[r]),e.jsx(Qe,{children:e.jsxs(j,{container:!0,spacing:2,sx:{marginTop:0},children:[e.jsx(j,{item:!0,xs:12,sx:{display:"flex",justifyContent:"center"},children:e.jsx(Mt,{sx:{fontSize:"200px"}})}),e.jsx(j,{item:!0,xs:12,sx:{display:"flex",justifyContent:"center"},children:e.jsx(E,{variant:"h4",sx:{textAlign:"center"},children:t("code"in n&&n.code===L.UNAUTHORIZED?"Session expired":"General error")})}),e.jsx(j,{item:!0,xs:12,sx:{display:"flex",justifyContent:"center"},children:e.jsx(H,{variant:"h6",underline:"hover",sx:{cursor:"pointer"},onClick:()=>{console.log("CLICK AS WELL"),s.invalidate(),o({to:N.INDEX})},children:t("Back to main")})})]})})},gr=()=>{const{t:n}=F();return e.jsx(Qe,{children:e.jsxs(j,{container:!0,spacing:2,sx:{marginTop:0},children:[e.jsx(j,{item:!0,xs:12,sx:{display:"flex",justifyContent:"center"},children:e.jsx(E,{variant:"404",children:"404"})}),e.jsx(j,{item:!0,xs:12,sx:{display:"flex",justifyContent:"center"},children:e.jsx(E,{variant:"h4",sx:{textAlign:"center"},children:n("Page not found")})}),e.jsx(j,{item:!0,xs:12,sx:{display:"flex",justifyContent:"center"},children:e.jsx(H,{component:Q,to:"/",variant:"h6",underline:"none",children:n("Back to main")})})]})})},xr=()=>e.jsxs(k,{sx:{minHeight:"100vh",display:"flex",flexDirection:"column"},children:[e.jsx(nn,{}),!1]}),ve=tn()({component:xr,notFoundComponent:gr,errorComponent:pr}),X=({error:n,context:t,color:s="error.main"})=>{const{t:o}=F();if(!n)return null;if(n.code)switch(n.code){case L.NOT_FOUND:return e.jsx(E,{color:s,children:o(n.code,{context:`${n.entity}:${t}`})});case L.NOT_ALLOWED:case L.UNAUTHORIZED:return e.jsx(E,{color:s,children:o(n.code,{context:t})});case L.FAILED_UPDATE:return n.fields.map((r,a)=>e.jsx(E,{color:s,children:o(n.code,{context:`${n.reasons[a]}:${r}:${t}`})},`error_${r}`));case L.MISSING_FIELD:return n.fields.map(r=>e.jsx(E,{color:s,children:o(n.code,{context:`${r}:${t}`})},`error_${r}`));case L.DUPLICATE:return e.jsx(E,{color:s,children:o(n.code,{context:`${n.entity}:${t}`})})}return e.jsx(E,{color:s,children:o((n==null?void 0:n.message)??"Unknown",{context:t})})},vr=()=>{const[n,t]=b.useState(),[s,o]=b.useState(0),{t:r}=F(),a=ie(),l=ae(),c=M(),d=Y({mutationFn:({data:u})=>c.newPost(u)}),h=ce({defaultValues:{content:""},onSubmit:async({value:u})=>{try{d.mutate({data:u},{onSuccess:async i=>{h.reset(),o(0),await a.invalidateQueries({queryKey:["posts"]}),l({to:"/",search:{page:i.pages-1}})},onError:t})}catch(i){t(i)}}});return e.jsx("form",{onSubmit:u=>{u.preventDefault(),u.stopPropagation(),h.handleSubmit()},onKeyDown:u=>{u.key==="Tab"&&u.stopPropagation()},noValidate:!0,children:e.jsxs(k,{sx:{display:"grid",gap:2,padding:1},children:[e.jsx(h.Field,{name:"content",validators:{onChange:({value:u})=>u?void 0:r("Content required"),onChangeAsyncDebounceMs:250,onChangeAsync:async({value:u})=>!u&&r("Content required")},children:u=>e.jsxs(e.Fragment,{children:[e.jsx($,{variant:"outlined",multiline:!0,minRows:3,name:u.name,value:u.state.value,onBlur:u.handleBlur,onChange:i=>{i.target.value.length<=250&&(o(i.target.value.length),u.handleChange(i.target.value))},size:"small",label:r("Comment"),required:!0,error:u.state.meta.isTouched&&u.state.meta.errors.length>0,helperText:u.state.meta.isTouched?u.state.meta.errors.join(","):"",autoComplete:"off",fullWidth:!0}),e.jsx(ot,{variant:"determinate",value:s/250*100,color:s===250?"error":s>=200?"warning":"primary"})]})}),e.jsx(h.Subscribe,{selector:u=>[u.canSubmit,u.isSubmitting],children:([u])=>e.jsx(e.Fragment,{children:e.jsx(_,{type:"submit",disabled:!u||d.isPending,variant:"contained",endIcon:d.isPending&&e.jsx(K,{color:"inherit",size:"20px"}),children:r("Post comment")})})}),e.jsx(re,{open:d.isError,autoHideDuration:2e3,onClose:()=>{d.reset()},TransitionProps:{onExited:()=>t(void 0)},children:e.jsx(at,{severity:"error",variant:"filled",sx:{width:"100%"},children:n&&e.jsx(X,{error:n,context:"newPost",color:"white"})})})]})})},yr="/phpCourse/exam/dist/assets/guests-book-TdSsJC37.png",jr=({anchorEl:n,handleClose:t})=>e.jsxs(qe,{anchorEl:n,anchorOrigin:{vertical:"bottom",horizontal:"right"},keepMounted:!0,transformOrigin:{vertical:"top",horizontal:"right"},open:!!n,onClose:t,sx:{"& .MuiMenu-paper":{minWidth:"240px"}},children:[e.jsx(z,{selected:de.language==="en",onClick:()=>{de.changeLanguage("en"),t()},children:"English"},"de"),e.jsx(z,{selected:de.language==="de",onClick:()=>{de.changeLanguage("de"),t()},children:"Deutsch"},"en")]}),Tr=({anchorEl:n,handleClose:t})=>{const[s,o]=Oe(a=>[a.theme,a.setTheme]),{t:r}=F();return e.jsxs(qe,{anchorEl:n,anchorOrigin:{vertical:"bottom",horizontal:"right"},keepMounted:!0,transformOrigin:{vertical:"top",horizontal:"right"},open:!!n,onClose:t,sx:{"& .MuiMenu-paper":{minWidth:"240px"}},children:[e.jsx(z,{selected:s==="dark",onClick:()=>{o("dark")},children:e.jsxs(j,{container:!0,spacing:2,children:[e.jsx(j,{item:!0,xs:2,children:e.jsx(it,{})}),e.jsx(j,{item:!0,xs:10,children:e.jsx(E,{children:r("Dark")})})]})},"dark"),e.jsx(z,{selected:s==="light",onClick:()=>{o("light")},children:e.jsxs(j,{container:!0,spacing:2,children:[e.jsx(j,{item:!0,xs:2,children:e.jsx(ct,{})}),e.jsx(j,{item:!0,xs:10,children:e.jsx(E,{children:r("Light")})})]})},"light"),e.jsx(z,{selected:!s,onClick:()=>{o(void 0)},children:e.jsxs(j,{container:!0,spacing:2,children:[e.jsx(j,{item:!0,xs:2,children:e.jsx(lt,{})}),e.jsx(j,{item:!0,xs:10,children:e.jsx(E,{children:r("System")})})]})},"system")]})},Cr=({open:n,onClose:t})=>{const[s,o]=b.useState(),{t:r}=F(),a=pe(),l=oe(a.breakpoints.only("xs"),{noSsr:!0}),c=M(),d=Y({mutationFn:({data:i})=>c.createUser(i)}),h=ce({defaultValues:{username:"",email:"",password:""},onSubmit:async({value:i})=>{try{d.mutate({data:i},{onSuccess:()=>o(void 0),onError:o})}catch(m){o(m)}}}),u=()=>{h.reset(),o(void 0),t()};return d.isSuccess?e.jsxs(se,{open:n,onClose:u,fullWidth:!0,fullScreen:l,children:[e.jsx(W,{children:e.jsxs(j,{container:!0,spacing:2,children:[e.jsx(j,{item:!0,xs:12,sx:{display:"flex",justifyContent:"center"},children:e.jsx(ut,{color:"action",sx:{fontSize:"200px"}})}),e.jsx(j,{item:!0,xs:12,sx:{display:"flex",justifyContent:"center"},children:e.jsx(E,{variant:"h5",children:r("Confirm header")})}),e.jsx(j,{item:!0,xs:12,sx:{display:"flex",justifyContent:"center"},children:e.jsx(E,{children:r("Confirm mail")})})]})}),e.jsx(ge,{children:e.jsx(_,{onClick:u,children:r("Close")})})]}):e.jsxs(se,{open:n,onClose:u,fullWidth:!0,fullScreen:l,PaperProps:{component:"form",encType:"multipart/form-data",onSubmit:i=>{i.preventDefault(),i.stopPropagation(),h.handleSubmit()},onKeyDown:i=>{i.key==="Tab"&&i.stopPropagation()},noValidate:!0},children:[e.jsx(xe,{children:r("Register")}),e.jsx(W,{sx:{gap:2},children:e.jsxs(j,{container:!0,spacing:2,children:[e.jsx(j,{item:!0,xs:12,children:e.jsx(h.Field,{name:"username",validators:{onChange:({value:i})=>i?void 0:r("Username required"),onChangeAsyncDebounceMs:250,onChangeAsync:async({value:i})=>!i&&r("Username required")},children:i=>e.jsx(e.Fragment,{children:e.jsx($,{variant:"outlined",name:i.name,value:i.state.value,onBlur:i.handleBlur,onChange:m=>i.handleChange(m.target.value),size:"small",label:r("Username"),required:!0,error:i.state.meta.isTouched&&i.state.meta.errors.length>0,helperText:i.state.meta.isTouched?i.state.meta.errors.join(","):"",autoComplete:"new-username",fullWidth:!0,margin:"dense"})})})}),e.jsx(j,{item:!0,xs:12,children:e.jsx(h.Field,{name:"email",validators:{onChange:({value:i})=>i?void 0:r("Email required"),onChangeAsyncDebounceMs:250,onChangeAsync:async({value:i})=>!i&&r("Email required")},children:i=>e.jsx(e.Fragment,{children:e.jsx($,{variant:"outlined",name:i.name,value:i.state.value,onBlur:i.handleBlur,onChange:m=>i.handleChange(m.target.value),size:"small",label:r("Email"),required:!0,error:i.state.meta.isTouched&&i.state.meta.errors.length>0,helperText:i.state.meta.isTouched?i.state.meta.errors.join(","):"",type:"email",autoComplete:"new-email",inputMode:"email",fullWidth:!0})})})}),e.jsx(j,{item:!0,xs:12,children:e.jsx(h.Field,{name:"password",validators:{onChange:({value:i})=>i?void 0:r("Password required"),onChangeAsyncDebounceMs:250,onChangeAsync:async({value:i})=>!i&&r("Password required")},children:i=>e.jsx(e.Fragment,{children:e.jsx($,{variant:"outlined",name:i.name,value:i.state.value,onBlur:i.handleBlur,onChange:m=>i.handleChange(m.target.value),size:"small",label:r("Password"),required:!0,error:i.state.meta.isTouched&&i.state.meta.errors.length>0,helperText:i.state.meta.isTouched?i.state.meta.errors.join(","):"",type:"password",autoComplete:"new-password",fullWidth:!0})})})}),e.jsx(j,{item:!0,xs:12,children:e.jsx(h.Subscribe,{selector:i=>[i.canSubmit,i.isSubmitting],children:([i])=>e.jsx(e.Fragment,{children:e.jsx(_,{type:"submit",disabled:!i||d.isPending,variant:"contained",endIcon:d.isPending&&e.jsx(K,{color:"inherit",size:"20px"}),children:r("Register")})})})}),e.jsx(j,{item:!0,xs:12,children:s&&e.jsx(X,{error:s,context:"register"})})]})})]})},Sr=()=>{const[n,t]=b.useState(),{t:s}=F(),o=Be(),r=M(),a=ce({defaultValues:{email:"",password:""},onSubmit:async({value:l})=>{try{await r.logIn(l.email,l.password),o.invalidate()}catch(c){t(c)}}});return e.jsx("form",{onSubmit:l=>{l.preventDefault(),l.stopPropagation(),a.handleSubmit()},onKeyDown:l=>{l.key==="Tab"&&l.stopPropagation()},noValidate:!0,children:e.jsxs(k,{sx:{display:"grid",gap:2,padding:1},children:[e.jsx(a.Field,{name:"email",validators:{onChange:({value:l})=>l?void 0:s("Email required"),onChangeAsyncDebounceMs:250,onChangeAsync:async({value:l})=>!l&&s("Email required")},children:l=>e.jsx(e.Fragment,{children:e.jsx($,{variant:"outlined",name:l.name,value:l.state.value,onBlur:l.handleBlur,onChange:c=>l.handleChange(c.target.value),size:"small",label:s("Email"),required:!0,error:l.state.meta.isTouched&&l.state.meta.errors.length>0,helperText:l.state.meta.isTouched?l.state.meta.errors.join(","):"",type:"email",autoComplete:"email",inputMode:"email",fullWidth:!0})})}),e.jsx(a.Field,{name:"password",validators:{onChange:({value:l})=>l?void 0:s("Password required"),onChangeAsyncDebounceMs:250,onChangeAsync:async({value:l})=>!l&&s("Password required")},children:l=>e.jsx(e.Fragment,{children:e.jsx($,{variant:"outlined",name:l.name,value:l.state.value,onBlur:l.handleBlur,onChange:c=>l.handleChange(c.target.value),size:"small",label:s("Password"),required:!0,error:l.state.meta.isTouched&&l.state.meta.errors.length>0,helperText:l.state.meta.isTouched?l.state.meta.errors.join(","):"",type:"password",autoComplete:"current-password",fullWidth:!0})})}),e.jsx(a.Subscribe,{selector:l=>[l.canSubmit,l.isSubmitting],children:([l])=>e.jsx(e.Fragment,{children:e.jsx(_,{type:"submit",disabled:!l,variant:"contained",children:s("Log in")})})}),n&&e.jsx(X,{error:n,context:"login"})]})})},Er=({anchorEl:n,handleClose:t})=>{const[s,o]=b.useState(!1),r=ae(),a=Be(),l=rn({from:"/profile/",strict:!0,shouldThrow:!1}),c=M(),d=()=>{o(!1),t()};return e.jsx(qe,{anchorEl:n,anchorOrigin:{vertical:"bottom",horizontal:"right"},keepMounted:!0,transformOrigin:{vertical:"top",horizontal:"right"},open:!!n,onClose:d,sx:{"& .MuiMenu-paper":{minWidth:"240px"}},children:c.authenticatedUser?[e.jsx(z,{selected:!!l,onClick:()=>{r({to:N.PROFILE}),d()},children:A("Profile")},"profile"),e.jsx(z,{onClick:async()=>{await c.logOut(),a.invalidate(),r({to:N.INDEX})},children:A("Log out")},"logout")]:s?e.jsx(Cr,{open:s,onClose:()=>o(!1)}):e.jsxs(k,{children:[e.jsx(Sr,{}),e.jsx(k,{sx:{padding:1},children:e.jsxs(pn,{i18nKey:"Register prompt",children:[e.jsx(E,{component:"span"}),e.jsx(H,{sx:{cursor:"pointer"},variant:"body1",underline:"hover",color:"secondary.main",onClick:()=>{o(!0),t()}}),e.jsx(E,{component:"span"})]})})]})})},br=({children:n})=>{const t=$t({disableHysteresis:!0,threshold:0});return b.cloneElement(n,{elevation:t?4:0})},wr=()=>{const[n,t]=b.useState(null),[s,o]=b.useState(null),[r,a]=b.useState(null),{t:l}=F(),c=sn({select:i=>i.status==="pending"}),d=M(),[h]=Oe(i=>[i.theme,i.setTheme]),u=()=>{t(null),o(null),a(null)};return e.jsx(br,{children:e.jsxs(e.Fragment,{children:[e.jsx(Ut,{children:e.jsxs(Xe,{children:[e.jsxs(k,{sx:{flexGrow:1,alignItems:"center",display:"flex",gap:1},children:[e.jsxs(H,{component:Q,to:"/",color:"white",variant:"h6",underline:"none",sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx("img",{src:yr,width:"24px",height:"24px",alt:l("GuestBook")})," ",l("GuestBook")]}),c&&e.jsx(K,{size:16,thickness:10,sx:{color:"white"}})]}),e.jsxs(k,{sx:{display:"flex",gap:1},children:[e.jsx(Z,{size:"large",onClick:i=>o(i.currentTarget),children:e.jsx(Nt,{sx:{color:"white"}})}),e.jsxs(Z,{size:"large",onClick:i=>a(i.currentTarget),children:[h==="dark"&&e.jsx(it,{}),h==="light"&&e.jsx(ct,{sx:{color:"white"}}),!h&&e.jsx(lt,{sx:{color:"white"}})]}),d.authenticatedUser?e.jsx(Z,{onClick:i=>t(i.currentTarget),sx:{p:0},children:e.jsx(ee,{alt:d.authenticatedUser.username,src:`${d.authenticatedUser.image}`,children:e.jsx(te,{})})}):e.jsx(Z,{size:"large",onClick:i=>t(i.currentTarget),color:"inherit",children:e.jsx(Ht,{})})]}),e.jsx(jr,{anchorEl:s,handleClose:u}),e.jsx(Er,{anchorEl:n,handleClose:u}),e.jsx(Tr,{anchorEl:r,handleClose:u})]})}),e.jsx(Xe,{})]})})},Je=({children:n})=>e.jsxs(e.Fragment,{children:[e.jsx(wr,{}),e.jsx(k,{sx:{display:"flex",justifyContent:"center"},children:e.jsx(k,{sx:{maxWidth:"800px",flexGrow:1},children:n})}),e.jsx(k,{sx:{flexGrow:1}}),e.jsx(jt,{})]}),Tt=n=>new Date(n.date).toLocaleString(navigator.languages[0]??"de-DE",{timeZone:n.timezone,day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",hour12:!1,minute:"2-digit"}),Ar=({post:n,open:t,onClose:s})=>{const[o,r]=b.useState(),[a,l]=b.useState(n.content.length),c=pe(),d=oe(c.breakpoints.only("xs"),{noSsr:!0}),h=ie(),u=M(),i=Y({mutationFn:({data:p,id:g})=>u.updatePost(p,g)}),m=ce({defaultValues:{content:n.content.replaceAll("<br />","")},onSubmit:async({value:p})=>{try{i.mutate({data:p,id:n.id},{onSuccess:()=>{f(),h.invalidateQueries({queryKey:["posts"]})},onError:r})}catch(g){r(g)}}}),f=()=>{m.reset(),r(void 0),s()};return b.useEffect(()=>{u.hasAuth||f()},[u.hasAuth]),e.jsxs(se,{open:t,onClose:f,fullWidth:!0,fullScreen:d,PaperProps:{component:"form",onSubmit:p=>{p.preventDefault(),p.stopPropagation(),m.handleSubmit()},onKeyDown:p=>{p.key==="Tab"&&p.stopPropagation()},noValidate:!0},children:[e.jsx(xe,{children:A("Edit post")}),e.jsx(W,{children:e.jsx(m.Field,{name:"content",validators:{onChange:({value:p})=>p?void 0:A("Content required"),onChangeAsyncDebounceMs:250,onChangeAsync:async({value:p})=>!p&&A("Content required")},children:p=>e.jsxs(e.Fragment,{children:[e.jsx($,{variant:"outlined",multiline:!0,minRows:3,name:p.name,value:p.state.value,onBlur:p.handleBlur,onChange:g=>{g.target.value.length<=250&&(l(g.target.value.length),p.handleChange(g.target.value))},size:"small",label:A("Comment"),required:!0,error:p.state.meta.isTouched&&p.state.meta.errors.length>0,helperText:p.state.meta.isTouched?p.state.meta.errors.join(","):"",autoComplete:"off",margin:"dense",fullWidth:!0}),e.jsx(ot,{variant:"determinate",value:a/250*100,color:a===250?"error":a>=200?"warning":"primary"})]})})}),e.jsx(ge,{children:e.jsx(m.Subscribe,{selector:p=>[p.canSubmit,p.isSubmitting],children:([p])=>e.jsxs(e.Fragment,{children:[e.jsx(_,{variant:"outlined",onClick:()=>{f()},children:A("Cancel")}),e.jsx(_,{type:"submit",disabled:!p||i.isPending,autoFocus:!0,variant:"contained",endIcon:i.isPending&&e.jsx(K,{color:"inherit",size:"20px"}),children:A("Save")})]})})}),o&&e.jsx(W,{children:e.jsx(X,{error:o,context:"postUpdate"})})]})},Ct=({page:n=0,post:t,disableActions:s})=>{var p,g,x,y,v;const[o,r]=b.useState(!1),[a,l]=b.useState(!1),[c,d]=b.useState(),{t:h}=F(),u=ie(),i=ae(),m=M(),f=Y({mutationFn:P=>m.deletePost(P)});return e.jsxs(dt,{children:[e.jsx(qt,{avatar:!s&&"id"in t.user?t.user.id!==((p=m.authenticatedUser)==null?void 0:p.id)?e.jsx(H,{component:Q,to:"/profile/$id",params:{id:t.user.id},children:e.jsx(ee,{alt:t.user.username,src:`${t.user.image}`,children:e.jsx(te,{})})}):e.jsx(H,{component:Q,to:"/profile",children:e.jsx(ee,{alt:t.user.username,src:`${t.user.image}`,children:e.jsx(te,{})})}):e.jsx(ee,{alt:t.user.username,src:`${t.user.image}`,children:e.jsx(te,{})}),title:!s&&"id"in t.user?t.user.id!==((g=m.authenticatedUser)==null?void 0:g.id)?e.jsx(H,{component:Q,to:"/profile/$id",params:{id:t.user.id},children:t.user.username}):e.jsx(H,{component:Q,to:"/profile",children:t.user.username}):t.user.username,subheader:Tt(t.postedAt)}),e.jsx(ht,{children:e.jsx(E,{children:e.jsx("span",{dangerouslySetInnerHTML:{__html:t.content}})})}),e.jsxs(mt,{children:[!s&&(((x=m.authenticatedUser)==null?void 0:x.isAdmin)||"id"in t.user&&t.user.id===((y=m.authenticatedUser)==null?void 0:y.id))&&e.jsxs(e.Fragment,{children:[e.jsx(_,{size:"small",onClick:()=>l(!0),children:h("Edit")}),e.jsx(Ar,{post:t,open:a,onClose:()=>l(!1)})]}),!s&&((v=m.authenticatedUser)==null?void 0:v.isAdmin)&&e.jsxs(e.Fragment,{children:[e.jsx(_,{size:"small",color:"error",onClick:()=>r(!0),children:h("Delete")}),e.jsxs(se,{open:o,onClose:()=>r(!1),children:[e.jsx(xe,{children:h("Confirm post delete title")}),e.jsx(W,{children:e.jsx(Bt,{children:h("Confirm post delete body",{name:t.user.username})})}),e.jsxs(ge,{children:[e.jsx(_,{onClick:()=>r(!1),autoFocus:!0,variant:"contained",children:h("No")}),e.jsx(_,{variant:"outlined",color:"error",onClick:()=>{f.mutate(t.id,{onSuccess:async P=>{await u.invalidateQueries({queryKey:["posts"]}),n>=P.pages&&i({to:"/",search:{page:P.pages-1}})},onError:d}),r(!1)},children:h("Yes")})]})]})]})]}),e.jsx(re,{open:f.isError,autoHideDuration:2e3,onClose:()=>{f.reset()},TransitionProps:{onExited:()=>d(void 0)},children:e.jsx(at,{severity:"error",variant:"filled",sx:{width:"100%"},children:c&&e.jsx(X,{error:c,context:"deletePost",color:"white"})})}),e.jsx(re,{open:f.isPending,message:h("Deleting")})]})},St=(n,t)=>ze({queryKey:["posts",{page:t??0,hasAuth:n.hasAuth}],queryFn:async()=>await n.posts(t)}),Pr=()=>{const n=M(),{page:t}=Et.useSearch(),{data:s,isFetching:o}=We(St(n,t)),{t:r}=F(),a=ae(),l=pe(),c=oe(l.breakpoints.not("xs"),{noSsr:!0});return b.useEffect(()=>{(t??0)>=s.pages&&a({to:"/",search:{page:s.pages-1}})},[t]),e.jsxs(Je,{children:[e.jsx(re,{open:o,message:r("Updating")}),e.jsxs(j,{container:!0,spacing:2,sx:{marginTop:0},children:[s.data.map(d=>e.jsx(j,{item:!0,xs:12,children:e.jsx(Ct,{page:t,post:d})},d.id)),e.jsx(j,{item:!0,xs:12,children:e.jsx(we,{variant:"middle"})}),e.jsx(j,{item:!0,xs:12,sx:{display:"flex",justifyContent:"center"},children:e.jsx(zt,{page:(t??0)+1,count:s.pages,siblingCount:c?1:0,color:"primary",renderItem:d=>e.jsx(Wt,{...d,component:Q,to:"/",search:{page:(d.page??0)>0?(d.page??1)-1:void 0},onClick:h=>d.onClick(h)})})}),n.hasAuth?e.jsx(j,{item:!0,xs:12,children:e.jsx(vr,{})}):e.jsxs(j,{item:!0,xs:12,children:[e.jsx(E,{variant:"h5",children:r("Leave comment header")}),e.jsx(E,{children:r("Leave comment action")})]})]})]})},Et=Pe(N.INDEX)({loaderDeps:({search:{page:n}})=>({page:n}),loader:({context:{queryClient:n,Api:t},deps:{page:s}})=>n.ensureQueryData(St(t,s)),validateSearch:n=>({page:(n==null?void 0:n.page)!==void 0?Number((n==null?void 0:n.page)??0):void 0}),component:Pr}),Or=({user:n,open:t,onClose:s})=>{const[o,r]=b.useState(),a=pe(),l=oe(a.breakpoints.only("xs"),{noSsr:!0}),c=ie(),d=M(),h=Y({mutationFn:({data:m,id:f})=>d.updateUser(m,f)}),u=ce({defaultValues:{username:n.username,email:n.email},onSubmit:async({value:m})=>{var f;try{h.mutate({data:m,id:((f=d.authenticatedUser)==null?void 0:f.id)===n.id?void 0:n.id},{onSuccess:()=>{var g;i();const p=((g=d.authenticatedUser)==null?void 0:g.id)===n.id?["profile"]:["profile",{id:n.id}];c.invalidateQueries({queryKey:p})},onError:r})}catch(p){r(p)}}}),i=()=>{u.reset(),r(void 0),s()};return b.useEffect(()=>{d.hasAuth||i()},[d.hasAuth]),e.jsxs(se,{open:t,onClose:i,fullWidth:!0,fullScreen:l,PaperProps:{component:"form",onSubmit:m=>{m.preventDefault(),m.stopPropagation(),u.handleSubmit()},onKeyDown:m=>{m.key==="Tab"&&m.stopPropagation()},noValidate:!0},children:[e.jsx(xe,{children:A("Edit data")}),e.jsxs(W,{children:[e.jsx(u.Field,{name:"username",validators:{onChange:({value:m})=>m?void 0:A("Username required"),onChangeAsyncDebounceMs:250,onChangeAsync:async({value:m})=>!m&&A("Username required")},children:m=>e.jsx(e.Fragment,{children:e.jsx($,{name:m.name,value:m.state.value,onBlur:m.handleBlur,onChange:f=>m.handleChange(f.target.value),size:"small",label:A("Username"),required:!0,margin:"dense",autoComplete:"new-username",fullWidth:!0,error:m.state.meta.isTouched&&m.state.meta.errors.length>0,helperText:m.state.meta.isTouched?m.state.meta.errors.join(","):""})})}),e.jsx(u.Field,{name:"email",validators:{onChange:({value:m})=>m?void 0:A("Email required"),onChangeAsyncDebounceMs:250,onChangeAsync:async({value:m})=>!m&&A("Email required")},children:m=>e.jsx(e.Fragment,{children:e.jsx($,{name:m.name,value:m.state.value,onBlur:m.handleBlur,onChange:f=>m.handleChange(f.target.value),size:"small",label:A("Email"),required:!0,margin:"dense",autoComplete:"new-email",fullWidth:!0,error:m.state.meta.isTouched&&m.state.meta.errors.length>0,helperText:m.state.meta.isTouched?m.state.meta.errors.join(","):""})})})]}),e.jsx(ge,{children:e.jsx(u.Subscribe,{selector:m=>[m.canSubmit,m.isSubmitting],children:([m])=>e.jsxs(e.Fragment,{children:[e.jsx(_,{variant:"outlined",onClick:()=>{i()},children:A("Cancel")}),e.jsx(_,{type:"submit",disabled:!m||h.isPending,autoFocus:!0,variant:"contained",endIcon:h.isPending&&e.jsx(K,{color:"inherit",size:"20px"}),children:A("Save")})]})})}),o&&e.jsx(W,{children:e.jsx(X,{error:o,context:"userUpdate"})})]})},Ir=({user:n,open:t,onClose:s})=>{const[o,r]=b.useState(),a=pe(),l=oe(a.breakpoints.only("xs"),{noSsr:!0}),c=ie(),d=M(),h=Y({mutationFn:({data:f,id:p})=>d.updateUserImage(f,p)}),u=ce({onSubmit:async({value:f})=>{var p;try{h.mutate({data:f,id:((p=d.authenticatedUser)==null?void 0:p.id)===n.id?void 0:n.id},{onSuccess:()=>{var x;m();const g=((x=d.authenticatedUser)==null?void 0:x.id)===n.id?["profile"]:["profile",{id:n.id}];c.invalidateQueries({queryKey:g})},onError:r})}catch(g){r(g)}}}),i=u.useStore(f=>({image:f.values.image,predefined:f.values.predefined})),m=()=>{u.reset(),r(void 0),s()};return b.useEffect(()=>{d.hasAuth||m()},[d.hasAuth]),e.jsxs(se,{open:t,onClose:m,fullWidth:!0,fullScreen:l,PaperProps:{component:"form",encType:"multipart/form-data",onSubmit:f=>{f.preventDefault(),f.stopPropagation(),u.handleSubmit()},onKeyDown:f=>{f.key==="Tab"&&f.stopPropagation()},noValidate:!0},children:[e.jsx(xe,{children:A("Edit image")}),e.jsx(W,{sx:{gap:2},children:e.jsxs(j,{container:!0,spacing:2,children:[e.jsx(j,{item:!0,xs:12,sx:{display:"flex",justifyContent:"center"},children:e.jsx(ee,{alt:n.username,src:i.image?URL.createObjectURL(i.image):i.predefined?`storage/profilbilder/default/${i.predefined}.svg`:`${n.image}`,sx:{width:"100px",height:"100px"},children:e.jsx(te,{sx:{width:"60px",height:"60px"}})})}),e.jsx(j,{item:!0,xs:12,children:e.jsxs(k,{sx:{display:"flex",gap:2},children:[e.jsx(_,{component:"label",role:void 0,variant:"contained",tabIndex:-1,startIcon:e.jsx(Gt,{}),fullWidth:!0,children:e.jsx(u.Field,{name:"image",children:f=>{var p;return e.jsxs(e.Fragment,{children:[e.jsx(k,{sx:{textOverflow:"ellipsis",textWrap:"nowrap",overflow:"hidden"},children:f.state.value?A("Upload named",{name:(p=f.state.value)==null?void 0:p.name}):A("Upload image")}),e.jsx($,{name:f.name,onBlur:f.handleBlur,value:f.state.value?void 0:"",onChange:g=>f.handleChange(g.target.files[0]),size:"small",type:"file",required:!0,sx:{display:"none"},autoComplete:"off"})]})}})}),e.jsx(Z,{color:"error",onClick:()=>u.setFieldValue("image",void 0),children:e.jsx(Qt,{})})]})}),e.jsx(j,{item:!0,xs:12,children:e.jsx(we,{variant:"middle",children:e.jsx(E,{sx:{opacity:.36},children:A("or")})})}),e.jsx(j,{item:!0,xs:12,children:e.jsx(u.Field,{name:"predefined",children:f=>e.jsxs(Jt,{fullWidth:!0,children:[e.jsx(Kt,{size:"small",children:A("Predefined")}),e.jsxs(Yt,{name:f.name,value:f.state.value??"",onBlur:f.handleBlur,onChange:p=>f.handleChange(p.target.value),size:"small",label:A("Predefined"),autoComplete:"off",fullWidth:!0,children:[e.jsx(z,{value:"",selected:!0,children:"Keine Auswahl"}),[...Array(10).keys()].map(p=>e.jsx(z,{value:`avatar-${p+1}`,children:A("Avatar",{name:p+1})},`avatar-${p+1}`))]})]})})})]})}),e.jsx(ge,{children:e.jsx(u.Subscribe,{selector:f=>[f.canSubmit,f.isSubmitting],children:([f])=>e.jsxs(e.Fragment,{children:[e.jsx(_,{variant:"outlined",onClick:()=>{m()},children:A("Cancel")}),e.jsx(_,{type:"submit",disabled:!f||h.isPending,autoFocus:!0,variant:"contained",endIcon:h.isPending&&e.jsx(K,{color:"inherit",size:"20px"}),children:A("Save")})]})})}),o&&e.jsx(W,{children:e.jsx(X,{error:o,context:"userUpdate"})})]})},bt=({user:n,posts:t,canEdit:s})=>{const[o,r]=b.useState(!1),[a,l]=b.useState(!1),{t:c}=F();return e.jsxs(j,{container:!0,sx:{justifyContent:"center",marginTop:0},spacing:2,children:[e.jsx(j,{item:!0,children:e.jsxs(dt,{children:[e.jsx(ht,{children:e.jsxs(j,{container:!0,spacing:2,children:[e.jsx(j,{item:!0,sx:{display:"flex",flexGrow:1,justifyContent:"center"},children:e.jsx(Z,{onClick:()=>l(!0),children:e.jsx(ee,{alt:n.username,src:`${n.image}`,sx:{width:"100px",height:"100px"},children:e.jsx(te,{sx:{width:"60px",height:"60px"}})})})}),e.jsx(j,{item:!0,sx:{display:"flex",alignItems:"center"},children:e.jsxs(k,{sx:{display:"grid",gridTemplateColumns:"120px 1fr",columnGap:1},children:[e.jsxs(E,{fontWeight:"bold",children:[c("Username"),":"]}),e.jsx(E,{children:n.username}),e.jsxs(E,{fontWeight:"bold",children:[c("Email"),":"]}),e.jsx(E,{children:n.email}),e.jsxs(E,{fontWeight:"bold",children:[c("Member since"),":"]}),e.jsx(E,{children:Tt(n.memberSince)}),e.jsxs(E,{fontWeight:"bold",children:[c("Post count"),":"]}),e.jsx(E,{children:n.postCount})]})})]})}),e.jsx(mt,{children:s&&e.jsxs(e.Fragment,{children:[e.jsx(_,{size:"small",onClick:()=>r(!0),children:c("Edit")}),e.jsx(Or,{user:n,open:o,onClose:()=>r(!1)}),e.jsx(Ir,{user:n,open:a,onClose:()=>l(!1)})]})})]})}),e.jsx(j,{item:!0,xs:12,children:e.jsx(we,{variant:"middle",children:e.jsx(E,{sx:{opacity:.36},children:c("Recent posts")})})}),t.map(d=>e.jsx(j,{item:!0,xs:12,children:e.jsx(Ct,{post:d,disableActions:!0})},`post_${d.id}`))]})},wt=n=>{var t;return ze({queryKey:["profile",{id:(t=n.authenticatedUser)==null?void 0:t.id}],queryFn:async()=>{var s;return{user:await n.user(),posts:await n.userPosts(((s=n.authenticatedUser)==null?void 0:s.id)??0)}},retry:(s,o)=>"code"in o&&o.code!==L.UNAUTHORIZED?s<3:!1})},At=(n,t)=>ze({queryKey:["profile",{id:t}],queryFn:async()=>({user:await n.user(t),posts:await n.userPosts(t)}),retry:(s,o)=>"code"in o&&o.code!==L.UNAUTHORIZED?s<3:!1}),Rr=()=>{const n=M(),{data:{user:t,posts:s},isFetching:o,error:r,failureReason:a}=We(wt(n));if(a&&"code"in a&&a.code===L.UNAUTHORIZED)throw a;if(r&&"code"in r&&r.code===L.UNAUTHORIZED)throw r;return e.jsxs(Je,{children:[e.jsx(re,{open:o,message:A("Updating")}),e.jsx(bt,{user:t,posts:s.data,canEdit:!0})]})},kr=Pe(`${N.PROFILE}/`)({loader:({context:{queryClient:n,Api:t}})=>{n.ensureQueryData(wt(t))},beforeLoad:({context:{Api:n}})=>{if(!n.hasAuth)throw Le({to:N.INDEX})},component:Rr}),_r=()=>{const n=M(),{code:t}=Pt.useSearch(),{t:s}=F(),o=ae(),r=Y({mutationFn:({code:a})=>n.confirmUser(a)});return b.useEffect(()=>{t&&setTimeout(()=>r.mutate({code:t}),1e3)},[]),b.useEffect(()=>{t||o({to:"/"})},[t]),e.jsx(Qe,{children:e.jsxs(j,{container:!0,spacing:2,sx:{marginTop:0},children:[e.jsxs(j,{item:!0,xs:12,sx:{display:"flex",justifyContent:"center"},children:[r.isSuccess&&e.jsx(ut,{color:"action",sx:{fontSize:"200px"}}),r.isError&&e.jsx(Xt,{color:"action",sx:{fontSize:"200px"}}),(r.isPending||r.isIdle)&&e.jsx(K,{size:200})]}),e.jsxs(j,{item:!0,xs:12,sx:{display:"flex",justifyContent:"center"},children:[r.isSuccess&&e.jsx(E,{variant:"h5",children:s("Confirm success header")}),r.isError&&e.jsx(E,{variant:"h5",color:"error",children:s("Confirm error header")}),(r.isPending||r.isIdle)&&e.jsx(E,{variant:"h5",children:s("Confirm pending header")})]}),!r.isPending&&!r.isIdle&&e.jsx(j,{item:!0,xs:12,sx:{display:"flex",justifyContent:"center"},children:e.jsx(H,{component:Q,to:"/",variant:"h6",underline:"none",children:s("Back to main")})})]})})},Pt=Pe(`${N.CONFIRM}/`)({validateSearch:n=>({code:(n==null?void 0:n.code)!==void 0?n==null?void 0:n.code:void 0}),component:_r}),Dr=()=>{var c;const n=M(),{id:t}=Ot.useParams(),{data:{user:s,posts:o},isFetching:r,error:a,failureReason:l}=We(At(n,t));if(l&&"code"in l&&l.code===L.UNAUTHORIZED)throw l;if(a&&"code"in a&&a.code===L.UNAUTHORIZED)throw a;return e.jsxs(Je,{children:[e.jsx(re,{open:r,message:A("Updating")}),e.jsx(bt,{user:s,posts:o.data,canEdit:(c=n.authenticatedUser)==null?void 0:c.isAdmin})]})},Ot=Pe(`${N.PROFILE}/$id`)({params:{parse:({id:n})=>({id:parseInt(n)}),stringify:({id:n})=>({id:n.toString()})},loader:({context:{queryClient:n,Api:t},params:{id:s}})=>{n.ensureQueryData(At(t,s))},beforeLoad:({params:{id:n},context:{Api:t}})=>{var s;if(!t.hasAuth)throw Le({to:N.INDEX});if(n===((s=t.authenticatedUser)==null?void 0:s.id))throw Le({to:N.PROFILE})},component:Dr}),Lr=Et.update({path:"/",getParentRoute:()=>ve}),Fr=kr.update({path:"/profile/",getParentRoute:()=>ve}),Mr=Pt.update({path:"/confirm/",getParentRoute:()=>ve}),Ur=Ot.update({path:"/profile/$id",getParentRoute:()=>ve}),Nr=ve.addChildren({IndexRoute:Lr,ProfileIdRoute:Ur,ConfirmIndexRoute:Mr,ProfileIndexRoute:Fr}),Hr=on({routeTree:Nr,context:{queryClient:void 0,Api:void 0},defaultPreload:"intent",defaultPreloadStaleTime:0,basepath:"/phpCourse/exam"}),$r=()=>{const n=M(),t=ie();return e.jsx(an,{router:Hr,context:{queryClient:t,Api:n}})},It=n=>({404:{fontSize:"6rem",[n.breakpoints.up("sm")]:{fontSize:"12rem"},[n.breakpoints.up("md")]:{fontSize:"18rem"}}}),Rt={styleOverrides:{root:{backgroundColor:void 0,color:"text.primary"}}};let Se=Ae({palette:{mode:"dark",primary:{main:"#b8e1ff"},secondary:{main:"#f990ca"},warning:{main:"#f9bf90"},error:{main:"#ffada7"},info:{main:"#2ea8ff"},success:{main:"#caf990"},background:{default:"#0f1115",paper:"#0d1019"}}});Se=Ae(Se,{typography:{...It(Se)},components:{...Rt}});const qr=Se;let Ee=Ae({palette:{mode:"light",primary:{main:"#000b29"},secondary:{main:"#9d002a"},error:{main:"#d10000"},warning:{main:"#ff9800"},info:{main:"#2196f3"},success:{main:"#4caf50"},background:{default:"#fafafa",paper:"#ffffff"}}});Ee=Ae(Ee,{typography:{...It(Ee)},components:{...Rt}});const Br=Ee,zr=()=>{const n=oe("(prefers-color-scheme: dark)"),t=Oe(r=>r.theme),{t:s}=F(),o=b.useMemo(()=>t==="dark"||n?qr:Br,[t,n]);return e.jsxs(Vt,{theme:o,children:[e.jsx($e,{children:e.jsx("title",{children:s("GuestBook")})}),e.jsx(Zt,{}),e.jsx($r,{})]})},Wr=new cn,st=document.getElementById("root");st.innerHTML||Fe.createRoot(st).render(e.jsx(b.StrictMode,{children:e.jsxs(ln,{client:Wr,children:[e.jsx(bn,{children:e.jsx(zr,{})}),!1]})}));
|