function Sd(e,t){for(var n=0;nr[l]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const s of l)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(l){const s={};return l.integrity&&(s.integrity=l.integrity),l.referrerPolicy&&(s.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?s.credentials="include":l.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(l){if(l.ep)return;l.ep=!0;const s=n(l);fetch(l.href,s)}})();function Nd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var qa={exports:{}},Il={},ba={exports:{}},B={};/** * @license React * react.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Nr=Symbol.for("react.element"),Cd=Symbol.for("react.portal"),_d=Symbol.for("react.fragment"),Ed=Symbol.for("react.strict_mode"),Ld=Symbol.for("react.profiler"),Pd=Symbol.for("react.provider"),Md=Symbol.for("react.context"),zd=Symbol.for("react.forward_ref"),Td=Symbol.for("react.suspense"),Rd=Symbol.for("react.memo"),Od=Symbol.for("react.lazy"),No=Symbol.iterator;function Id(e){return e===null||typeof e!="object"?null:(e=No&&e[No]||e["@@iterator"],typeof e=="function"?e:null)}var eu={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},tu=Object.assign,nu={};function Pn(e,t,n){this.props=e,this.context=t,this.refs=nu,this.updater=n||eu}Pn.prototype.isReactComponent={};Pn.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};Pn.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function ru(){}ru.prototype=Pn.prototype;function Si(e,t,n){this.props=e,this.context=t,this.refs=nu,this.updater=n||eu}var Ni=Si.prototype=new ru;Ni.constructor=Si;tu(Ni,Pn.prototype);Ni.isPureReactComponent=!0;var Co=Array.isArray,lu=Object.prototype.hasOwnProperty,Ci={current:null},su={key:!0,ref:!0,__self:!0,__source:!0};function iu(e,t,n){var r,l={},s=null,o=null;if(t!=null)for(r in t.ref!==void 0&&(o=t.ref),t.key!==void 0&&(s=""+t.key),t)lu.call(t,r)&&!su.hasOwnProperty(r)&&(l[r]=t[r]);var a=arguments.length-2;if(a===1)l.children=n;else if(1>>1,G=z[V];if(0>>1;Vl(mt,I))Vel(vt,mt)?(z[V]=vt,z[Ve]=I,V=Ve):(z[V]=mt,z[Ne]=I,V=Ne);else if(Vel(vt,I))z[V]=vt,z[Ve]=I,V=Ve;else break e}}return O}function l(z,O){var I=z.sortIndex-O.sortIndex;return I!==0?I:z.id-O.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();e.unstable_now=function(){return o.now()-a}}var u=[],d=[],m=1,f=null,v=3,w=!1,j=!1,g=!1,x=typeof setTimeout=="function"?setTimeout:null,p=typeof clearTimeout=="function"?clearTimeout:null,c=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function h(z){for(var O=n(d);O!==null;){if(O.callback===null)r(d);else if(O.startTime<=z)r(d),O.sortIndex=O.expirationTime,t(u,O);else break;O=n(d)}}function k(z){if(g=!1,h(z),!j)if(n(u)!==null)j=!0,ht(_);else{var O=n(d);O!==null&&At(k,O.startTime-z)}}function _(z,O){j=!1,g&&(g=!1,p(C),C=-1),w=!0;var I=v;try{for(h(O),f=n(u);f!==null&&(!(f.expirationTime>O)||z&&!D());){var V=f.callback;if(typeof V=="function"){f.callback=null,v=f.priorityLevel;var G=V(f.expirationTime<=O);O=e.unstable_now(),typeof G=="function"?f.callback=G:f===n(u)&&r(u),h(O)}else r(u);f=n(u)}if(f!==null)var Ze=!0;else{var Ne=n(d);Ne!==null&&At(k,Ne.startTime-O),Ze=!1}return Ze}finally{f=null,v=I,w=!1}}var S=!1,E=null,C=-1,P=5,M=-1;function D(){return!(e.unstable_now()-Mz||125V?(z.sortIndex=I,t(d,z),n(u)===null&&z===n(d)&&(g?(p(C),C=-1):g=!0,At(k,I-V))):(z.sortIndex=G,t(u,z),j||w||(j=!0,ht(_))),z},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(z){var O=v;return function(){var I=v;v=O;try{return z.apply(this,arguments)}finally{v=I}}}})(fu);du.exports=fu;var Gd=du.exports;/** * @license React * react-dom.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Yd=y,Oe=Gd;function L(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ls=Object.prototype.hasOwnProperty,Xd=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,Eo={},Lo={};function Jd(e){return Ls.call(Lo,e)?!0:Ls.call(Eo,e)?!1:Xd.test(e)?Lo[e]=!0:(Eo[e]=!0,!1)}function Zd(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function qd(e,t,n,r){if(t===null||typeof t>"u"||Zd(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Se(e,t,n,r,l,s,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=s,this.removeEmptyString=o}var he={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){he[e]=new Se(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];he[t]=new Se(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){he[e]=new Se(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){he[e]=new Se(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){he[e]=new Se(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){he[e]=new Se(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){he[e]=new Se(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){he[e]=new Se(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){he[e]=new Se(e,5,!1,e.toLowerCase(),null,!1,!1)});var Ei=/[\-:]([a-z])/g;function Li(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Ei,Li);he[t]=new Se(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Ei,Li);he[t]=new Se(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Ei,Li);he[t]=new Se(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){he[e]=new Se(e,1,!1,e.toLowerCase(),null,!1,!1)});he.xlinkHref=new Se("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){he[e]=new Se(e,1,!1,e.toLowerCase(),null,!0,!0)});function Pi(e,t,n,r){var l=he.hasOwnProperty(t)?he[t]:null;(l!==null?l.type!==0:r||!(2a||l[o]!==s[a]){var u=` `+l[o].replace(" at new "," at ");return e.displayName&&u.includes("")&&(u=u.replace("",e.displayName)),u}while(1<=o&&0<=a);break}}}finally{ts=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Qn(e):""}function bd(e){switch(e.tag){case 5:return Qn(e.type);case 16:return Qn("Lazy");case 13:return Qn("Suspense");case 19:return Qn("SuspenseList");case 0:case 2:case 15:return e=ns(e.type,!1),e;case 11:return e=ns(e.type.render,!1),e;case 1:return e=ns(e.type,!0),e;default:return""}}function Ts(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case ln:return"Fragment";case rn:return"Portal";case Ps:return"Profiler";case Mi:return"StrictMode";case Ms:return"Suspense";case zs:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case mu:return(e.displayName||"Context")+".Consumer";case hu:return(e._context.displayName||"Context")+".Provider";case zi:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Ti:return t=e.displayName||null,t!==null?t:Ts(e.type)||"Memo";case yt:t=e._payload,e=e._init;try{return Ts(e(t))}catch{}}return null}function ef(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Ts(t);case 8:return t===Mi?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function Ot(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function gu(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function tf(e){var t=gu(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var l=n.get,s=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Rr(e){e._valueTracker||(e._valueTracker=tf(e))}function yu(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=gu(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function ul(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Rs(e,t){var n=t.checked;return ne({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Mo(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Ot(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function xu(e,t){t=t.checked,t!=null&&Pi(e,"checked",t,!1)}function Os(e,t){xu(e,t);var n=Ot(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Is(e,t.type,n):t.hasOwnProperty("defaultValue")&&Is(e,t.type,Ot(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function zo(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Is(e,t,n){(t!=="number"||ul(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Kn=Array.isArray;function vn(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=Or.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function ir(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Jn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},nf=["Webkit","ms","Moz","O"];Object.keys(Jn).forEach(function(e){nf.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Jn[t]=Jn[e]})});function Su(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Jn.hasOwnProperty(e)&&Jn[e]?(""+t).trim():t+"px"}function Nu(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=Su(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var rf=ne({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Fs(e,t){if(t){if(rf[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(L(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(L(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(L(61))}if(t.style!=null&&typeof t.style!="object")throw Error(L(62))}}function Bs(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Us=null;function Ri(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var As=null,gn=null,yn=null;function Oo(e){if(e=Er(e)){if(typeof As!="function")throw Error(L(280));var t=e.stateNode;t&&(t=Ul(t),As(e.stateNode,e.type,t))}}function Cu(e){gn?yn?yn.push(e):yn=[e]:gn=e}function _u(){if(gn){var e=gn,t=yn;if(yn=gn=null,Oo(e),t)for(e=0;e>>=0,e===0?32:31-(mf(e)/vf|0)|0}var Ir=64,Dr=4194304;function Gn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function pl(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,s=e.pingedLanes,o=n&268435455;if(o!==0){var a=o&~l;a!==0?r=Gn(a):(s&=o,s!==0&&(r=Gn(s)))}else o=n&~l,o!==0?r=Gn(o):s!==0&&(r=Gn(s));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,s=t&-t,l>=s||l===16&&(s&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Cr(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Ye(t),e[t]=n}function kf(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=qn),Vo=" ",Ho=!1;function Ku(e,t){switch(e){case"keyup":return Yf.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Gu(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var sn=!1;function Jf(e,t){switch(e){case"compositionend":return Gu(t);case"keypress":return t.which!==32?null:(Ho=!0,Vo);case"textInput":return e=t.data,e===Vo&&Ho?null:e;default:return null}}function Zf(e,t){if(sn)return e==="compositionend"||!Ai&&Ku(e,t)?(e=Hu(),br=Fi=jt=null,sn=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Yo(n)}}function Zu(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Zu(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function qu(){for(var e=window,t=ul();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=ul(e.document)}return t}function Wi(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function ip(e){var t=qu(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Zu(n.ownerDocument.documentElement,n)){if(r!==null&&Wi(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var l=n.textContent.length,s=Math.min(r.start,l);r=r.end===void 0?s:Math.min(r.end,l),!e.extend&&s>r&&(l=r,r=s,s=l),l=Xo(n,s);var o=Xo(n,r);l&&o&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),s>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,on=null,Gs=null,er=null,Ys=!1;function Jo(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Ys||on==null||on!==ul(r)||(r=on,"selectionStart"in r&&Wi(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),er&&fr(er,r)||(er=r,r=vl(Gs,"onSelect"),0cn||(e.current=ei[cn],ei[cn]=null,cn--)}function Y(e,t){cn++,ei[cn]=e.current,e.current=t}var It={},xe=$t(It),Le=$t(!1),Xt=It;function Sn(e,t){var n=e.type.contextTypes;if(!n)return It;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},s;for(s in n)l[s]=t[s];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function Pe(e){return e=e.childContextTypes,e!=null}function yl(){q(Le),q(xe)}function ra(e,t,n){if(xe.current!==It)throw Error(L(168));Y(xe,t),Y(Le,n)}function oc(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(L(108,ef(e)||"Unknown",l));return ne({},n,r)}function xl(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||It,Xt=xe.current,Y(xe,e),Y(Le,Le.current),!0}function la(e,t,n){var r=e.stateNode;if(!r)throw Error(L(169));n?(e=oc(e,t,Xt),r.__reactInternalMemoizedMergedChildContext=e,q(Le),q(xe),Y(xe,e)):q(Le),Y(Le,n)}var lt=null,Al=!1,vs=!1;function ac(e){lt===null?lt=[e]:lt.push(e)}function yp(e){Al=!0,ac(e)}function Ft(){if(!vs&<!==null){vs=!0;var e=0,t=Q;try{var n=lt;for(Q=1;e>=o,l-=o,st=1<<32-Ye(t)+l|n<C?(P=E,E=null):P=E.sibling;var M=v(p,E,h[C],k);if(M===null){E===null&&(E=P);break}e&&E&&M.alternate===null&&t(p,E),c=s(M,c,C),S===null?_=M:S.sibling=M,S=M,E=P}if(C===h.length)return n(p,E),b&&Wt(p,C),_;if(E===null){for(;CC?(P=E,E=null):P=E.sibling;var D=v(p,E,M.value,k);if(D===null){E===null&&(E=P);break}e&&E&&D.alternate===null&&t(p,E),c=s(D,c,C),S===null?_=D:S.sibling=D,S=D,E=P}if(M.done)return n(p,E),b&&Wt(p,C),_;if(E===null){for(;!M.done;C++,M=h.next())M=f(p,M.value,k),M!==null&&(c=s(M,c,C),S===null?_=M:S.sibling=M,S=M);return b&&Wt(p,C),_}for(E=r(p,E);!M.done;C++,M=h.next())M=w(E,p,C,M.value,k),M!==null&&(e&&M.alternate!==null&&E.delete(M.key===null?C:M.key),c=s(M,c,C),S===null?_=M:S.sibling=M,S=M);return e&&E.forEach(function(X){return t(p,X)}),b&&Wt(p,C),_}function x(p,c,h,k){if(typeof h=="object"&&h!==null&&h.type===ln&&h.key===null&&(h=h.props.children),typeof h=="object"&&h!==null){switch(h.$$typeof){case Tr:e:{for(var _=h.key,S=c;S!==null;){if(S.key===_){if(_=h.type,_===ln){if(S.tag===7){n(p,S.sibling),c=l(S,h.props.children),c.return=p,p=c;break e}}else if(S.elementType===_||typeof _=="object"&&_!==null&&_.$$typeof===yt&&oa(_)===S.type){n(p,S.sibling),c=l(S,h.props),c.ref=Bn(p,S,h),c.return=p,p=c;break e}n(p,S);break}else t(p,S);S=S.sibling}h.type===ln?(c=Yt(h.props.children,p.mode,k,h.key),c.return=p,p=c):(k=ol(h.type,h.key,h.props,null,p.mode,k),k.ref=Bn(p,c,h),k.return=p,p=k)}return o(p);case rn:e:{for(S=h.key;c!==null;){if(c.key===S)if(c.tag===4&&c.stateNode.containerInfo===h.containerInfo&&c.stateNode.implementation===h.implementation){n(p,c.sibling),c=l(c,h.children||[]),c.return=p,p=c;break e}else{n(p,c);break}else t(p,c);c=c.sibling}c=Ns(h,p.mode,k),c.return=p,p=c}return o(p);case yt:return S=h._init,x(p,c,S(h._payload),k)}if(Kn(h))return j(p,c,h,k);if(On(h))return g(p,c,h,k);Vr(p,h)}return typeof h=="string"&&h!==""||typeof h=="number"?(h=""+h,c!==null&&c.tag===6?(n(p,c.sibling),c=l(c,h),c.return=p,p=c):(n(p,c),c=Ss(h,p.mode,k),c.return=p,p=c),o(p)):n(p,c)}return x}var Cn=fc(!0),pc=fc(!1),jl=$t(null),Sl=null,pn=null,Ki=null;function Gi(){Ki=pn=Sl=null}function Yi(e){var t=jl.current;q(jl),e._currentValue=t}function ri(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function kn(e,t){Sl=e,Ki=pn=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Ee=!0),e.firstContext=null)}function Ae(e){var t=e._currentValue;if(Ki!==e)if(e={context:e,memoizedValue:t,next:null},pn===null){if(Sl===null)throw Error(L(308));pn=e,Sl.dependencies={lanes:0,firstContext:e}}else pn=pn.next=e;return t}var Qt=null;function Xi(e){Qt===null?Qt=[e]:Qt.push(e)}function hc(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,Xi(t)):(n.next=l.next,l.next=n),t.interleaved=n,ct(e,r)}function ct(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var xt=!1;function Ji(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function mc(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function ot(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Pt(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,U&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,ct(e,n)}return l=r.interleaved,l===null?(t.next=t,Xi(r)):(t.next=l.next,l.next=t),r.interleaved=t,ct(e,n)}function tl(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ii(e,n)}}function aa(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?l=s=o:s=s.next=o,n=n.next}while(n!==null);s===null?l=s=t:s=s.next=t}else l=s=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:s,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Nl(e,t,n,r){var l=e.updateQueue;xt=!1;var s=l.firstBaseUpdate,o=l.lastBaseUpdate,a=l.shared.pending;if(a!==null){l.shared.pending=null;var u=a,d=u.next;u.next=null,o===null?s=d:o.next=d,o=u;var m=e.alternate;m!==null&&(m=m.updateQueue,a=m.lastBaseUpdate,a!==o&&(a===null?m.firstBaseUpdate=d:a.next=d,m.lastBaseUpdate=u))}if(s!==null){var f=l.baseState;o=0,m=d=u=null,a=s;do{var v=a.lane,w=a.eventTime;if((r&v)===v){m!==null&&(m=m.next={eventTime:w,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var j=e,g=a;switch(v=t,w=n,g.tag){case 1:if(j=g.payload,typeof j=="function"){f=j.call(w,f,v);break e}f=j;break e;case 3:j.flags=j.flags&-65537|128;case 0:if(j=g.payload,v=typeof j=="function"?j.call(w,f,v):j,v==null)break e;f=ne({},f,v);break e;case 2:xt=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,v=l.effects,v===null?l.effects=[a]:v.push(a))}else w={eventTime:w,lane:v,tag:a.tag,payload:a.payload,callback:a.callback,next:null},m===null?(d=m=w,u=f):m=m.next=w,o|=v;if(a=a.next,a===null){if(a=l.shared.pending,a===null)break;v=a,a=v.next,v.next=null,l.lastBaseUpdate=v,l.shared.pending=null}}while(!0);if(m===null&&(u=f),l.baseState=u,l.firstBaseUpdate=d,l.lastBaseUpdate=m,t=l.shared.interleaved,t!==null){l=t;do o|=l.lane,l=l.next;while(l!==t)}else s===null&&(l.shared.lanes=0);qt|=o,e.lanes=o,e.memoizedState=f}}function ua(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=ys.transition;ys.transition={};try{e(!1),t()}finally{Q=n,ys.transition=r}}function Tc(){return We().memoizedState}function jp(e,t,n){var r=zt(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Rc(e))Oc(t,n);else if(n=hc(e,t,n,r),n!==null){var l=we();Xe(n,e,r,l),Ic(n,t,r)}}function Sp(e,t,n){var r=zt(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Rc(e))Oc(t,l);else{var s=e.alternate;if(e.lanes===0&&(s===null||s.lanes===0)&&(s=t.lastRenderedReducer,s!==null))try{var o=t.lastRenderedState,a=s(o,n);if(l.hasEagerState=!0,l.eagerState=a,Je(a,o)){var u=t.interleaved;u===null?(l.next=l,Xi(t)):(l.next=u.next,u.next=l),t.interleaved=l;return}}catch{}finally{}n=hc(e,t,l,r),n!==null&&(l=we(),Xe(n,e,r,l),Ic(n,t,r))}}function Rc(e){var t=e.alternate;return e===te||t!==null&&t===te}function Oc(e,t){tr=_l=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Ic(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ii(e,n)}}var El={readContext:Ae,useCallback:ve,useContext:ve,useEffect:ve,useImperativeHandle:ve,useInsertionEffect:ve,useLayoutEffect:ve,useMemo:ve,useReducer:ve,useRef:ve,useState:ve,useDebugValue:ve,useDeferredValue:ve,useTransition:ve,useMutableSource:ve,useSyncExternalStore:ve,useId:ve,unstable_isNewReconciler:!1},Np={readContext:Ae,useCallback:function(e,t){return be().memoizedState=[e,t===void 0?null:t],e},useContext:Ae,useEffect:da,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,rl(4194308,4,Ec.bind(null,t,e),n)},useLayoutEffect:function(e,t){return rl(4194308,4,e,t)},useInsertionEffect:function(e,t){return rl(4,2,e,t)},useMemo:function(e,t){var n=be();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=be();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=jp.bind(null,te,e),[r.memoizedState,e]},useRef:function(e){var t=be();return e={current:e},t.memoizedState=e},useState:ca,useDebugValue:lo,useDeferredValue:function(e){return be().memoizedState=e},useTransition:function(){var e=ca(!1),t=e[0];return e=wp.bind(null,e[1]),be().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=te,l=be();if(b){if(n===void 0)throw Error(L(407));n=n()}else{if(n=t(),ce===null)throw Error(L(349));Zt&30||xc(r,t,n)}l.memoizedState=n;var s={value:n,getSnapshot:t};return l.queue=s,da(wc.bind(null,r,s,e),[e]),r.flags|=2048,kr(9,kc.bind(null,r,s,n,t),void 0,null),n},useId:function(){var e=be(),t=ce.identifierPrefix;if(b){var n=it,r=st;n=(r&~(1<<32-Ye(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=yr++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=o.createElement(n,{is:r.is}):(e=o.createElement(n),n==="select"&&(o=e,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):e=o.createElementNS(e,n),e[et]=t,e[mr]=r,Qc(e,t,!1,!1),t.stateNode=e;e:{switch(o=Bs(n,r),n){case"dialog":J("cancel",e),J("close",e),l=r;break;case"iframe":case"object":case"embed":J("load",e),l=r;break;case"video":case"audio":for(l=0;lLn&&(t.flags|=128,r=!0,Un(s,!1),t.lanes=4194304)}else{if(!r)if(e=Cl(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Un(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!b)return ge(t),null}else 2*le()-s.renderingStartTime>Ln&&n!==1073741824&&(t.flags|=128,r=!0,Un(s,!1),t.lanes=4194304);s.isBackwards?(o.sibling=t.child,t.child=o):(n=s.last,n!==null?n.sibling=o:t.child=o,s.last=o)}return s.tail!==null?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=le(),t.sibling=null,n=ee.current,Y(ee,r?n&1|2:n&1),t):(ge(t),null);case 22:case 23:return co(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?ze&1073741824&&(ge(t),t.subtreeFlags&6&&(t.flags|=8192)):ge(t),null;case 24:return null;case 25:return null}throw Error(L(156,t.tag))}function Tp(e,t){switch(Hi(t),t.tag){case 1:return Pe(t.type)&&yl(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return _n(),q(Le),q(xe),bi(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return qi(t),null;case 13:if(q(ee),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(L(340));Nn()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return q(ee),null;case 4:return _n(),null;case 10:return Yi(t.type._context),null;case 22:case 23:return co(),null;case 24:return null;default:return null}}var Qr=!1,ye=!1,Rp=typeof WeakSet=="function"?WeakSet:Set,R=null;function hn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){re(e,t,r)}else n.current=null}function fi(e,t,n){try{n()}catch(r){re(e,t,r)}}var ja=!1;function Op(e,t){if(Xs=hl,e=qu(),Wi(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var l=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var o=0,a=-1,u=-1,d=0,m=0,f=e,v=null;t:for(;;){for(var w;f!==n||l!==0&&f.nodeType!==3||(a=o+l),f!==s||r!==0&&f.nodeType!==3||(u=o+r),f.nodeType===3&&(o+=f.nodeValue.length),(w=f.firstChild)!==null;)v=f,f=w;for(;;){if(f===e)break t;if(v===n&&++d===l&&(a=o),v===s&&++m===r&&(u=o),(w=f.nextSibling)!==null)break;f=v,v=f.parentNode}f=w}n=a===-1||u===-1?null:{start:a,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(Js={focusedElem:e,selectionRange:n},hl=!1,R=t;R!==null;)if(t=R,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,R=e;else for(;R!==null;){t=R;try{var j=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(j!==null){var g=j.memoizedProps,x=j.memoizedState,p=t.stateNode,c=p.getSnapshotBeforeUpdate(t.elementType===t.type?g:Qe(t.type,g),x);p.__reactInternalSnapshotBeforeUpdate=c}break;case 3:var h=t.stateNode.containerInfo;h.nodeType===1?h.textContent="":h.nodeType===9&&h.documentElement&&h.removeChild(h.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(L(163))}}catch(k){re(t,t.return,k)}if(e=t.sibling,e!==null){e.return=t.return,R=e;break}R=t.return}return j=ja,ja=!1,j}function nr(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var s=l.destroy;l.destroy=void 0,s!==void 0&&fi(t,n,s)}l=l.next}while(l!==r)}}function Hl(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function pi(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Yc(e){var t=e.alternate;t!==null&&(e.alternate=null,Yc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[et],delete t[mr],delete t[bs],delete t[vp],delete t[gp])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Xc(e){return e.tag===5||e.tag===3||e.tag===4}function Sa(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Xc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function hi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=gl));else if(r!==4&&(e=e.child,e!==null))for(hi(e,t,n),e=e.sibling;e!==null;)hi(e,t,n),e=e.sibling}function mi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(mi(e,t,n),e=e.sibling;e!==null;)mi(e,t,n),e=e.sibling}var fe=null,Ke=!1;function gt(e,t,n){for(n=n.child;n!==null;)Jc(e,t,n),n=n.sibling}function Jc(e,t,n){if(tt&&typeof tt.onCommitFiberUnmount=="function")try{tt.onCommitFiberUnmount(Dl,n)}catch{}switch(n.tag){case 5:ye||hn(n,t);case 6:var r=fe,l=Ke;fe=null,gt(e,t,n),fe=r,Ke=l,fe!==null&&(Ke?(e=fe,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):fe.removeChild(n.stateNode));break;case 18:fe!==null&&(Ke?(e=fe,n=n.stateNode,e.nodeType===8?ms(e.parentNode,n):e.nodeType===1&&ms(e,n),cr(e)):ms(fe,n.stateNode));break;case 4:r=fe,l=Ke,fe=n.stateNode.containerInfo,Ke=!0,gt(e,t,n),fe=r,Ke=l;break;case 0:case 11:case 14:case 15:if(!ye&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var s=l,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&fi(n,t,o),l=l.next}while(l!==r)}gt(e,t,n);break;case 1:if(!ye&&(hn(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){re(n,t,a)}gt(e,t,n);break;case 21:gt(e,t,n);break;case 22:n.mode&1?(ye=(r=ye)||n.memoizedState!==null,gt(e,t,n),ye=r):gt(e,t,n);break;default:gt(e,t,n)}}function Na(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Rp),t.forEach(function(r){var l=Vp.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function He(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=o),r&=~s}if(r=l,r=le()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Dp(r/1960))-r,10e?16:e,St===null)var r=!1;else{if(e=St,St=null,Ml=0,U&6)throw Error(L(331));var l=U;for(U|=4,R=e.current;R!==null;){var s=R,o=s.child;if(R.flags&16){var a=s.deletions;if(a!==null){for(var u=0;ule()-ao?Gt(e,0):oo|=n),Me(e,t)}function ld(e,t){t===0&&(e.mode&1?(t=Dr,Dr<<=1,!(Dr&130023424)&&(Dr=4194304)):t=1);var n=we();e=ct(e,t),e!==null&&(Cr(e,t,n),Me(e,n))}function Wp(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),ld(e,n)}function Vp(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(n=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(L(314))}r!==null&&r.delete(t),ld(e,n)}var sd;sd=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Le.current)Ee=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Ee=!1,Mp(e,t,n);Ee=!!(e.flags&131072)}else Ee=!1,b&&t.flags&1048576&&uc(t,wl,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;ll(e,t),e=t.pendingProps;var l=Sn(t,xe.current);kn(t,n),l=to(null,t,r,e,l,n);var s=no();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Pe(r)?(s=!0,xl(t)):s=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,Ji(t),l.updater=Vl,t.stateNode=l,l._reactInternals=t,si(t,r,e,n),t=ai(null,t,r,!0,s,n)):(t.tag=0,b&&s&&Vi(t),ke(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(ll(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=Qp(r),e=Qe(r,e),l){case 0:t=oi(null,t,r,e,n);break e;case 1:t=xa(null,t,r,e,n);break e;case 11:t=ga(null,t,r,e,n);break e;case 14:t=ya(null,t,r,Qe(r.type,e),n);break e}throw Error(L(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Qe(r,l),oi(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Qe(r,l),xa(e,t,r,l,n);case 3:e:{if(Wc(t),e===null)throw Error(L(387));r=t.pendingProps,s=t.memoizedState,l=s.element,mc(e,t),Nl(t,r,null,n);var o=t.memoizedState;if(r=o.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=s,t.memoizedState=s,t.flags&256){l=En(Error(L(423)),t),t=ka(e,t,r,n,l);break e}else if(r!==l){l=En(Error(L(424)),t),t=ka(e,t,r,n,l);break e}else for(Te=Lt(t.stateNode.containerInfo.firstChild),Re=t,b=!0,Ge=null,n=pc(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Nn(),r===l){t=dt(e,t,n);break e}ke(e,t,r,n)}t=t.child}return t;case 5:return vc(t),e===null&&ni(t),r=t.type,l=t.pendingProps,s=e!==null?e.memoizedProps:null,o=l.children,Zs(r,l)?o=null:s!==null&&Zs(r,s)&&(t.flags|=32),Ac(e,t),ke(e,t,o,n),t.child;case 6:return e===null&&ni(t),null;case 13:return Vc(e,t,n);case 4:return Zi(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Cn(t,null,r,n):ke(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Qe(r,l),ga(e,t,r,l,n);case 7:return ke(e,t,t.pendingProps,n),t.child;case 8:return ke(e,t,t.pendingProps.children,n),t.child;case 12:return ke(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,s=t.memoizedProps,o=l.value,Y(jl,r._currentValue),r._currentValue=o,s!==null)if(Je(s.value,o)){if(s.children===l.children&&!Le.current){t=dt(e,t,n);break e}}else for(s=t.child,s!==null&&(s.return=t);s!==null;){var a=s.dependencies;if(a!==null){o=s.child;for(var u=a.firstContext;u!==null;){if(u.context===r){if(s.tag===1){u=ot(-1,n&-n),u.tag=2;var d=s.updateQueue;if(d!==null){d=d.shared;var m=d.pending;m===null?u.next=u:(u.next=m.next,m.next=u),d.pending=u}}s.lanes|=n,u=s.alternate,u!==null&&(u.lanes|=n),ri(s.return,n,t),a.lanes|=n;break}u=u.next}}else if(s.tag===10)o=s.type===t.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(L(341));o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),ri(o,n,t),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===t){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}ke(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,kn(t,n),l=Ae(l),r=r(l),t.flags|=1,ke(e,t,r,n),t.child;case 14:return r=t.type,l=Qe(r,t.pendingProps),l=Qe(r.type,l),ya(e,t,r,l,n);case 15:return Bc(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Qe(r,l),ll(e,t),t.tag=1,Pe(r)?(e=!0,xl(t)):e=!1,kn(t,n),Dc(t,r,l),si(t,r,l,n),ai(null,t,r,!0,e,n);case 19:return Hc(e,t,n);case 22:return Uc(e,t,n)}throw Error(L(156,t.tag))};function id(e,t){return Ru(e,t)}function Hp(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Be(e,t,n,r){return new Hp(e,t,n,r)}function po(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Qp(e){if(typeof e=="function")return po(e)?1:0;if(e!=null){if(e=e.$$typeof,e===zi)return 11;if(e===Ti)return 14}return 2}function Tt(e,t){var n=e.alternate;return n===null?(n=Be(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function ol(e,t,n,r,l,s){var o=2;if(r=e,typeof e=="function")po(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case ln:return Yt(n.children,l,s,t);case Mi:o=8,l|=8;break;case Ps:return e=Be(12,n,t,l|2),e.elementType=Ps,e.lanes=s,e;case Ms:return e=Be(13,n,t,l),e.elementType=Ms,e.lanes=s,e;case zs:return e=Be(19,n,t,l),e.elementType=zs,e.lanes=s,e;case vu:return Kl(n,l,s,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case hu:o=10;break e;case mu:o=9;break e;case zi:o=11;break e;case Ti:o=14;break e;case yt:o=16,r=null;break e}throw Error(L(130,e==null?e:typeof e,""))}return t=Be(o,n,t,l),t.elementType=e,t.type=r,t.lanes=s,t}function Yt(e,t,n,r){return e=Be(7,e,r,t),e.lanes=n,e}function Kl(e,t,n,r){return e=Be(22,e,r,t),e.elementType=vu,e.lanes=n,e.stateNode={isHidden:!1},e}function Ss(e,t,n){return e=Be(6,e,null,t),e.lanes=n,e}function Ns(e,t,n){return t=Be(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Kp(e,t,n,r,l){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=ls(0),this.expirationTimes=ls(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ls(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function ho(e,t,n,r,l,s,o,a,u){return e=new Kp(e,t,n,a,u),t===1?(t=1,s===!0&&(t|=8)):t=0,s=Be(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ji(s),e}function Gp(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(cd)}catch(e){console.error(e)}}cd(),cu.exports=Ie;var qp=cu.exports,Ta=qp;Es.createRoot=Ta.createRoot,Es.hydrateRoot=Ta.hydrateRoot;/** * @remix-run/router v1.23.2 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function jr(){return jr=Object.assign?Object.assign.bind():function(e){for(var t=1;t"u")throw new Error(t)}function yo(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function eh(){return Math.random().toString(36).substr(2,8)}function Oa(e,t){return{usr:e.state,key:e.key,idx:t}}function ki(e,t,n,r){return n===void 0&&(n=null),jr({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?Tn(t):t,{state:n,key:t&&t.key||r||eh()})}function Rl(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function Tn(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function th(e,t,n,r){r===void 0&&(r={});let{window:l=document.defaultView,v5Compat:s=!1}=r,o=l.history,a=Nt.Pop,u=null,d=m();d==null&&(d=0,o.replaceState(jr({},o.state,{idx:d}),""));function m(){return(o.state||{idx:null}).idx}function f(){a=Nt.Pop;let x=m(),p=x==null?null:x-d;d=x,u&&u({action:a,location:g.location,delta:p})}function v(x,p){a=Nt.Push;let c=ki(g.location,x,p);d=m()+1;let h=Oa(c,d),k=g.createHref(c);try{o.pushState(h,"",k)}catch(_){if(_ instanceof DOMException&&_.name==="DataCloneError")throw _;l.location.assign(k)}s&&u&&u({action:a,location:g.location,delta:1})}function w(x,p){a=Nt.Replace;let c=ki(g.location,x,p);d=m();let h=Oa(c,d),k=g.createHref(c);o.replaceState(h,"",k),s&&u&&u({action:a,location:g.location,delta:0})}function j(x){let p=l.location.origin!=="null"?l.location.origin:l.location.href,c=typeof x=="string"?x:Rl(x);return c=c.replace(/ $/,"%20"),se(p,"No window.location.(origin|href) available to create URL for href: "+c),new URL(c,p)}let g={get action(){return a},get location(){return e(l,o)},listen(x){if(u)throw new Error("A history only accepts one active listener");return l.addEventListener(Ra,f),u=x,()=>{l.removeEventListener(Ra,f),u=null}},createHref(x){return t(l,x)},createURL:j,encodeLocation(x){let p=j(x);return{pathname:p.pathname,search:p.search,hash:p.hash}},push:v,replace:w,go(x){return o.go(x)}};return g}var Ia;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(Ia||(Ia={}));function nh(e,t,n){return n===void 0&&(n="/"),rh(e,t,n)}function rh(e,t,n,r){let l=typeof t=="string"?Tn(t):t,s=xo(l.pathname||"/",n);if(s==null)return null;let o=dd(e);lh(o);let a=null;for(let u=0;a==null&&u{let u={relativePath:a===void 0?s.path||"":a,caseSensitive:s.caseSensitive===!0,childrenIndex:o,route:s};u.relativePath.startsWith("/")&&(se(u.relativePath.startsWith(r),'Absolute route path "'+u.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),u.relativePath=u.relativePath.slice(r.length));let d=Rt([r,u.relativePath]),m=n.concat(u);s.children&&s.children.length>0&&(se(s.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+d+'".')),dd(s.children,t,m,d)),!(s.path==null&&!s.index)&&t.push({path:d,score:dh(d,s.index),routesMeta:m})};return e.forEach((s,o)=>{var a;if(s.path===""||!((a=s.path)!=null&&a.includes("?")))l(s,o);else for(let u of fd(s.path))l(s,o,u)}),t}function fd(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,l=n.endsWith("?"),s=n.replace(/\?$/,"");if(r.length===0)return l?[s,""]:[s];let o=fd(r.join("/")),a=[];return a.push(...o.map(u=>u===""?s:[s,u].join("/"))),l&&a.push(...o),a.map(u=>e.startsWith("/")&&u===""?"/":u)}function lh(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:fh(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const sh=/^:[\w-]+$/,ih=3,oh=2,ah=1,uh=10,ch=-2,Da=e=>e==="*";function dh(e,t){let n=e.split("/"),r=n.length;return n.some(Da)&&(r+=ch),t&&(r+=oh),n.filter(l=>!Da(l)).reduce((l,s)=>l+(sh.test(s)?ih:s===""?ah:uh),r)}function fh(e,t){return e.length===t.length&&e.slice(0,-1).every((r,l)=>r===t[l])?e[e.length-1]-t[t.length-1]:0}function ph(e,t,n){let{routesMeta:r}=e,l={},s="/",o=[];for(let a=0;a{let{paramName:v,isOptional:w}=m;if(v==="*"){let g=a[f]||"";o=s.slice(0,s.length-g.length).replace(/(.)\/+$/,"$1")}const j=a[f];return w&&!j?d[v]=void 0:d[v]=(j||"").replace(/%2F/g,"/"),d},{}),pathname:s,pathnameBase:o,pattern:e}}function mh(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),yo(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let r=[],l="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,a,u)=>(r.push({paramName:a,isOptional:u!=null}),u?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(r.push({paramName:"*"}),l+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?l+="\\/*$":e!==""&&e!=="/"&&(l+="(?:(?=\\/|$))"),[new RegExp(l,t?void 0:"i"),r]}function vh(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return yo(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function xo(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}const gh=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,yh=e=>gh.test(e);function xh(e,t){t===void 0&&(t="/");let{pathname:n,search:r="",hash:l=""}=typeof e=="string"?Tn(e):e,s;if(n)if(yh(n))s=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),yo(!1,"Pathnames cannot have embedded double slashes - normalizing "+(o+" -> "+n))}n.startsWith("/")?s=$a(n.substring(1),"/"):s=$a(n,t)}else s=t;return{pathname:s,search:jh(r),hash:Sh(l)}}function $a(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(l=>{l===".."?n.length>1&&n.pop():l!=="."&&n.push(l)}),n.length>1?n.join("/"):"/"}function Cs(e,t,n,r){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function kh(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function ko(e,t){let n=kh(e);return t?n.map((r,l)=>l===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function wo(e,t,n,r){r===void 0&&(r=!1);let l;typeof e=="string"?l=Tn(e):(l=jr({},e),se(!l.pathname||!l.pathname.includes("?"),Cs("?","pathname","search",l)),se(!l.pathname||!l.pathname.includes("#"),Cs("#","pathname","hash",l)),se(!l.search||!l.search.includes("#"),Cs("#","search","hash",l)));let s=e===""||l.pathname==="",o=s?"/":l.pathname,a;if(o==null)a=n;else{let f=t.length-1;if(!r&&o.startsWith("..")){let v=o.split("/");for(;v[0]==="..";)v.shift(),f-=1;l.pathname=v.join("/")}a=f>=0?t[f]:"/"}let u=xh(l,a),d=o&&o!=="/"&&o.endsWith("/"),m=(s||o===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(d||m)&&(u.pathname+="/"),u}const Rt=e=>e.join("/").replace(/\/\/+/g,"/"),wh=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),jh=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Sh=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function Nh(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const pd=["post","put","patch","delete"];new Set(pd);const Ch=["get",...pd];new Set(Ch);/** * React Router v6.30.3 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function Sr(){return Sr=Object.assign?Object.assign.bind():function(e){for(var t=1;t{a.current=!0}),y.useCallback(function(d,m){if(m===void 0&&(m={}),!a.current)return;if(typeof d=="number"){r.go(d);return}let f=wo(d,JSON.parse(o),s,m.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:Rt([t,f.pathname])),(m.replace?r.replace:r.push)(f,m.state,m)},[t,r,o,s,e])}function vd(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=y.useContext(Bt),{matches:l}=y.useContext(Ut),{pathname:s}=Pr(),o=JSON.stringify(ko(l,r.v7_relativeSplatPath));return y.useMemo(()=>wo(e,JSON.parse(o),s,n==="path"),[e,o,s,n])}function Ph(e,t){return Mh(e,t)}function Mh(e,t,n,r){Rn()||se(!1);let{navigator:l}=y.useContext(Bt),{matches:s}=y.useContext(Ut),o=s[s.length-1],a=o?o.params:{};o&&o.pathname;let u=o?o.pathnameBase:"/";o&&o.route;let d=Pr(),m;if(t){var f;let x=typeof t=="string"?Tn(t):t;u==="/"||(f=x.pathname)!=null&&f.startsWith(u)||se(!1),m=x}else m=d;let v=m.pathname||"/",w=v;if(u!=="/"){let x=u.replace(/^\//,"").split("/");w="/"+v.replace(/^\//,"").split("/").slice(x.length).join("/")}let j=nh(e,{pathname:w}),g=Ih(j&&j.map(x=>Object.assign({},x,{params:Object.assign({},a,x.params),pathname:Rt([u,l.encodeLocation?l.encodeLocation(x.pathname).pathname:x.pathname]),pathnameBase:x.pathnameBase==="/"?u:Rt([u,l.encodeLocation?l.encodeLocation(x.pathnameBase).pathname:x.pathnameBase])})),s,n,r);return t&&g?y.createElement(Zl.Provider,{value:{location:Sr({pathname:"/",search:"",hash:"",state:null,key:"default"},m),navigationType:Nt.Pop}},g):g}function zh(){let e=Bh(),t=Nh(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,l={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return y.createElement(y.Fragment,null,y.createElement("h2",null,"Unexpected Application Error!"),y.createElement("h3",{style:{fontStyle:"italic"}},t),n?y.createElement("pre",{style:l},n):null,null)}const Th=y.createElement(zh,null);class Rh extends y.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?y.createElement(Ut.Provider,{value:this.props.routeContext},y.createElement(hd.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Oh(e){let{routeContext:t,match:n,children:r}=e,l=y.useContext(jo);return l&&l.static&&l.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(l.staticContext._deepestRenderedBoundaryId=n.route.id),y.createElement(Ut.Provider,{value:t},r)}function Ih(e,t,n,r){var l;if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var s;if(!n)return null;if(n.errors)e=n.matches;else if((s=r)!=null&&s.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let o=e,a=(l=n)==null?void 0:l.errors;if(a!=null){let m=o.findIndex(f=>f.route.id&&(a==null?void 0:a[f.route.id])!==void 0);m>=0||se(!1),o=o.slice(0,Math.min(o.length,m+1))}let u=!1,d=-1;if(n&&r&&r.v7_partialHydration)for(let m=0;m=0?o=o.slice(0,d+1):o=[o[0]];break}}}return o.reduceRight((m,f,v)=>{let w,j=!1,g=null,x=null;n&&(w=a&&f.route.id?a[f.route.id]:void 0,g=f.route.errorElement||Th,u&&(d<0&&v===0?(Ah("route-fallback"),j=!0,x=null):d===v&&(j=!0,x=f.route.hydrateFallbackElement||null)));let p=t.concat(o.slice(0,v+1)),c=()=>{let h;return w?h=g:j?h=x:f.route.Component?h=y.createElement(f.route.Component,null):f.route.element?h=f.route.element:h=m,y.createElement(Oh,{match:f,routeContext:{outlet:m,matches:p,isDataRoute:n!=null},children:h})};return n&&(f.route.ErrorBoundary||f.route.errorElement||v===0)?y.createElement(Rh,{location:n.location,revalidation:n.revalidation,component:g,error:w,children:c(),routeContext:{outlet:null,matches:p,isDataRoute:!0}}):c()},null)}var gd=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(gd||{}),yd=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(yd||{});function Dh(e){let t=y.useContext(jo);return t||se(!1),t}function $h(e){let t=y.useContext(_h);return t||se(!1),t}function Fh(e){let t=y.useContext(Ut);return t||se(!1),t}function xd(e){let t=Fh(),n=t.matches[t.matches.length-1];return n.route.id||se(!1),n.route.id}function Bh(){var e;let t=y.useContext(hd),n=$h(),r=xd();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function Uh(){let{router:e}=Dh(gd.UseNavigateStable),t=xd(yd.UseNavigateStable),n=y.useRef(!1);return md(()=>{n.current=!0}),y.useCallback(function(l,s){s===void 0&&(s={}),n.current&&(typeof l=="number"?e.navigate(l):e.navigate(l,Sr({fromRouteId:t},s)))},[e,t])}const Fa={};function Ah(e,t,n){Fa[e]||(Fa[e]=!0)}function Wh(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function Ol(e){let{to:t,replace:n,state:r,relative:l}=e;Rn()||se(!1);let{future:s,static:o}=y.useContext(Bt),{matches:a}=y.useContext(Ut),{pathname:u}=Pr(),d=Mr(),m=wo(t,ko(a,s.v7_relativeSplatPath),u,l==="path"),f=JSON.stringify(m);return y.useEffect(()=>d(JSON.parse(f),{replace:n,state:r,relative:l}),[d,f,l,n,r]),null}function Xn(e){se(!1)}function Vh(e){let{basename:t="/",children:n=null,location:r,navigationType:l=Nt.Pop,navigator:s,static:o=!1,future:a}=e;Rn()&&se(!1);let u=t.replace(/^\/*/,"/"),d=y.useMemo(()=>({basename:u,navigator:s,static:o,future:Sr({v7_relativeSplatPath:!1},a)}),[u,a,s,o]);typeof r=="string"&&(r=Tn(r));let{pathname:m="/",search:f="",hash:v="",state:w=null,key:j="default"}=r,g=y.useMemo(()=>{let x=xo(m,u);return x==null?null:{location:{pathname:x,search:f,hash:v,state:w,key:j},navigationType:l}},[u,m,f,v,w,j,l]);return g==null?null:y.createElement(Bt.Provider,{value:d},y.createElement(Zl.Provider,{children:n,value:g}))}function Hh(e){let{children:t,location:n}=e;return Ph(wi(t),n)}new Promise(()=>{});function wi(e,t){t===void 0&&(t=[]);let n=[];return y.Children.forEach(e,(r,l)=>{if(!y.isValidElement(r))return;let s=[...t,l];if(r.type===y.Fragment){n.push.apply(n,wi(r.props.children,s));return}r.type!==Xn&&se(!1),!r.props.index||!r.props.children||se(!1);let o={id:r.props.id||s.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=wi(r.props.children,s)),n.push(o)}),n}/** * React Router DOM v6.30.3 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function ji(){return ji=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&(n[l]=e[l]);return n}function Kh(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Gh(e,t){return e.button===0&&(!t||t==="_self")&&!Kh(e)}const Yh=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],Xh="6";try{window.__reactRouterVersion=Xh}catch{}const Jh="startTransition",Ba=Ud[Jh];function Zh(e){let{basename:t,children:n,future:r,window:l}=e,s=y.useRef();s.current==null&&(s.current=bp({window:l,v5Compat:!0}));let o=s.current,[a,u]=y.useState({action:o.action,location:o.location}),{v7_startTransition:d}=r||{},m=y.useCallback(f=>{d&&Ba?Ba(()=>u(f)):u(f)},[u,d]);return y.useLayoutEffect(()=>o.listen(m),[o,m]),y.useEffect(()=>Wh(r),[r]),y.createElement(Vh,{basename:t,children:n,location:a.location,navigationType:a.action,navigator:o,future:r})}const qh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",bh=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,kd=y.forwardRef(function(t,n){let{onClick:r,relative:l,reloadDocument:s,replace:o,state:a,target:u,to:d,preventScrollReset:m,viewTransition:f}=t,v=Qh(t,Yh),{basename:w}=y.useContext(Bt),j,g=!1;if(typeof d=="string"&&bh.test(d)&&(j=d,qh))try{let h=new URL(window.location.href),k=d.startsWith("//")?new URL(h.protocol+d):new URL(d),_=xo(k.pathname,w);k.origin===h.origin&&_!=null?d=_+k.search+k.hash:g=!0}catch{}let x=Eh(d,{relative:l}),p=em(d,{replace:o,state:a,target:u,preventScrollReset:m,relative:l,viewTransition:f});function c(h){r&&r(h),h.defaultPrevented||p(h)}return y.createElement("a",ji({},v,{href:j||x,onClick:g||s?r:c,ref:n,target:u}))});var Ua;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(Ua||(Ua={}));var Aa;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Aa||(Aa={}));function em(e,t){let{target:n,replace:r,state:l,preventScrollReset:s,relative:o,viewTransition:a}=t===void 0?{}:t,u=Mr(),d=Pr(),m=vd(e,{relative:o});return y.useCallback(f=>{if(Gh(f,n)){f.preventDefault();let v=r!==void 0?r:Rl(d)===Rl(m);u(e,{replace:v,state:l,preventScrollReset:s,relative:o,viewTransition:a})}},[d,u,m,r,l,n,e,s,o,a])}const Yr="/api",wd=y.createContext(null);function tm({children:e}){const[t,n]=y.useState(null),[r,l]=y.useState(localStorage.getItem("token")),[s,o]=y.useState(!0);y.useEffect(()=>{r?a():o(!1)},[r]);const a=async()=>{try{const w=await fetch(`${Yr}/user/profile`,{headers:{Authorization:`Bearer ${r}`}});w.ok?n(await w.json()):f()}catch{f()}o(!1)},u=async(w,j)=>{const g=await fetch(`${Yr}/auth/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:w,password:j})}),x=await g.json();if(!g.ok)throw new Error(x.error);return localStorage.setItem("token",x.token),l(x.token),n(x.user),x},d=async(w,j)=>{const g=await fetch(`${Yr}/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:w,password:j})}),x=await g.json();if(!g.ok)throw new Error(x.error);return localStorage.setItem("token",x.token),l(x.token),n(x.user),x},m=async w=>{const j=await fetch(`${Yr}/user/profile`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify(w)}),g=await j.json();if(!j.ok)throw new Error(g.error);return n(g),g},f=()=>{localStorage.removeItem("token"),l(null),n(null)},v=()=>a();return i.jsx(wd.Provider,{value:{user:t,token:r,loading:s,register:u,login:d,logout:f,updateProfile:m,refreshProfile:v},children:e})}const pt=()=>y.useContext(wd),nm={home:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),i.jsx("polyline",{points:"9 22 9 12 15 12 15 22"})]}),chart:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("line",{x1:"18",y1:"20",x2:"18",y2:"10"}),i.jsx("line",{x1:"12",y1:"20",x2:"12",y2:"4"}),i.jsx("line",{x1:"6",y1:"20",x2:"6",y2:"14"})]}),user:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),i.jsx("circle",{cx:"12",cy:"7",r:"4"})]}),logout:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),i.jsx("polyline",{points:"16 17 21 12 16 7"}),i.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]}),arrowLeft:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("line",{x1:"19",y1:"12",x2:"5",y2:"12"}),i.jsx("polyline",{points:"12 19 5 12 12 5"})]}),arrowRight:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),i.jsx("polyline",{points:"12 5 19 12 12 19"})]}),chevronLeft:i.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("polyline",{points:"15 18 9 12 15 6"})}),chevronRight:i.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("polyline",{points:"9 18 15 12 9 6"})}),chevronDown:i.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("polyline",{points:"6 9 12 15 18 9"})}),plus:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),i.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),swap:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("polyline",{points:"7 7 3 11 7 15"}),i.jsx("polyline",{points:"17 9 21 13 17 17"}),i.jsx("line",{x1:"3",y1:"11",x2:"21",y2:"11"}),i.jsx("line",{x1:"3",y1:"13",x2:"21",y2:"13"})]}),check:i.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("polyline",{points:"20 6 9 17 4 12"})}),dumbbell:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M6.5 6.5a2 2 0 0 0-3 0L2 8l6 6 1.5-1.5a2 2 0 0 0 0-3L6.5 6.5z"}),i.jsx("path",{d:"M17.5 17.5a2 2 0 0 0 3 0L22 16l-6-6-1.5 1.5a2 2 0 0 0 0 3l3 3z"}),i.jsx("line",{x1:"8",y1:"8",x2:"16",y2:"16"})]}),arm:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M12 3c-1.5 0-2.5 1-3 2.5-.5 1.5-.5 3 0 4.5.5 1.5 1 3 1 4.5 0 1.5-.5 3-1.5 4.5"}),i.jsx("path",{d:"M8 8c0-1 .5-2 1.5-2.5"}),i.jsx("path",{d:"M16 8c0-1-.5-2-1.5-2.5"}),i.jsx("path",{d:"M9 14c1.5 0 3 .5 4.5 1.5s3 1.5 4.5 1.5"})]}),leg:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M12 3v7"}),i.jsx("path",{d:"M9 10c0 2-.5 4-1.5 5.5S5 18 5 20v1"}),i.jsx("path",{d:"M15 10c0 2 .5 4 1.5 5.5S19 18 19 20v1"}),i.jsx("ellipse",{cx:"12",cy:"4",rx:"3",ry:"1"})]}),back:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M12 2v6"}),i.jsx("path",{d:"M6 8c0 3 2 6 6 8 4-2 6-5 6-8"}),i.jsx("path",{d:"M6 8c0-2 2.5-4 6-4s6 2 6 4"}),i.jsx("path",{d:"M9 16v4a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-4"})]}),chest:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M6 8c0-3 2.5-5 6-5s6 2 6 5c0 4-3 8-6 10-3-2-6-6-6-10z"}),i.jsx("path",{d:"M12 8v5"}),i.jsx("path",{d:"M9 9.5h6"})]}),shoulder:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("circle",{cx:"12",cy:"6",r:"3"}),i.jsx("path",{d:"M5 17c0-4 3-7 7-7s7 3 7 7"}),i.jsx("path",{d:"M8 12l-3 5"}),i.jsx("path",{d:"M16 12l3 5"})]}),core:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("rect",{x:"6",y:"4",width:"12",height:"16",rx:"2"}),i.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"16"}),i.jsx("line",{x1:"9",y1:"10",x2:"15",y2:"10"}),i.jsx("line",{x1:"9",y1:"14",x2:"15",y2:"14"})]}),fullBody:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("circle",{cx:"12",cy:"4",r:"2"}),i.jsx("path",{d:"M12 6v5"}),i.jsx("path",{d:"M8 8l-3 3"}),i.jsx("path",{d:"M16 8l3 3"}),i.jsx("path",{d:"M12 11l-3 9"}),i.jsx("path",{d:"M12 11l3 9"})]}),walking:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("circle",{cx:"12",cy:"4",r:"2"}),i.jsx("path",{d:"M14 10l2 7-3 3"}),i.jsx("path",{d:"M10 10l-2 7 3 3"}),i.jsx("path",{d:"M10 10h4l2-2"}),i.jsx("path",{d:"M10 10l-2-2"})]}),yoga:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("circle",{cx:"12",cy:"4",r:"2"}),i.jsx("path",{d:"M12 6v5"}),i.jsx("path",{d:"M4 14l8-3 8 3"}),i.jsx("path",{d:"M9 20l3-9 3 9"})]}),swimming:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("circle",{cx:"8",cy:"6",r:"2"}),i.jsx("path",{d:"M10 6h8"}),i.jsx("path",{d:"M4 18c2-2 4-2 6 0s4 2 6 0 4-2 6 0"}),i.jsx("path",{d:"M4 14c2-2 4-2 6 0s4 2 6 0 4-2 6 0"})]}),cycling:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("circle",{cx:"6",cy:"17",r:"3"}),i.jsx("circle",{cx:"18",cy:"17",r:"3"}),i.jsx("path",{d:"M6 17l4-7h4l3 5"}),i.jsx("circle",{cx:"12",cy:"7",r:"2"})]}),sleep:i.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}),fire:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M12 22c4-2 7-6 7-10 0-3-2-5-4-7l-3 4-3-4c-2 2-4 4-4 7 0 4 3 8 7 10z"}),i.jsx("path",{d:"M12 22c-2-1-3-3-3-5 0-1.5.5-2.5 1.5-3.5l1.5 2 1.5-2c1 1 1.5 2 1.5 3.5 0 2-1 4-3 5z"})]}),calendar:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),i.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),i.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),i.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]}),target:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("circle",{cx:"12",cy:"12",r:"10"}),i.jsx("circle",{cx:"12",cy:"12",r:"6"}),i.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),trophy:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M6 9H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h2"}),i.jsx("path",{d:"M18 9h2a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2h-2"}),i.jsx("path",{d:"M6 3v6a6 6 0 0 0 12 0V3"}),i.jsx("path",{d:"M12 15v4"}),i.jsx("path",{d:"M8 21h8"})]}),coach:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:[i.jsx("circle",{cx:"12",cy:"7",r:"4",opacity:"0.9"}),i.jsx("path",{d:"M12 13c-5 0-8 2.5-8 5v2h16v-2c0-2.5-3-5-8-5z",opacity:"0.7"}),i.jsx("circle",{cx:"17",cy:"5",r:"1.5",opacity:"0.5"}),i.jsx("path",{d:"M18 4l1.5-1.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",opacity:"0.5"})]}),trash:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("polyline",{points:"3 6 5 6 21 6"}),i.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),i.jsx("path",{d:"M10 11v6"}),i.jsx("path",{d:"M14 11v6"}),i.jsx("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"})]}),edit:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),i.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),search:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("circle",{cx:"11",cy:"11",r:"8"}),i.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),x:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),i.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),gravl:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M6.5 6.5a2 2 0 0 0-3 0L2 8l6 6 1.5-1.5a2 2 0 0 0 0-3L6.5 6.5z"}),i.jsx("path",{d:"M17.5 17.5a2 2 0 0 0 3 0L22 16l-6-6-1.5 1.5a2 2 0 0 0 0 3l3 3z"}),i.jsx("line",{x1:"8",y1:"8",x2:"16",y2:"16"})]})};function Z({name:e,size:t=24,className:n="",style:r={}}){const l=nm[e];return l?i.jsx("span",{className:`icon ${n}`,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:t,height:t,...r},children:l}):null}function rm(e){const t=e.toLowerCase();return t.includes("push")||t.includes("bröst")||t.includes("chest")?"chest":t.includes("pull")||t.includes("rygg")||t.includes("back")?"back":t.includes("ben")||t.includes("leg")||t.includes("lower")?"leg":t.includes("axlar")||t.includes("shoulder")?"shoulder":t.includes("arm")?"arm":t.includes("core")||t.includes("mage")?"core":t.includes("helkropp")||t.includes("full")?"fullBody":t.includes("överkropp")||t.includes("upper")?"chest":t.includes("underkropp")?"leg":"dumbbell"}function So(){return i.jsxs("svg",{viewBox:"0 0 48 48",className:"logo-mark","aria-hidden":"true",children:[i.jsx("path",{d:"M12 16h4v16h-4zM20 12h8v24h-8zM32 16h4v16h-4z",fill:"currentColor"}),i.jsx("rect",{x:"8",y:"20",width:"4",height:"8",fill:"currentColor"}),i.jsx("rect",{x:"36",y:"20",width:"4",height:"8",fill:"currentColor"})]})}const lm="/api",sm=(e,t)=>{var l;const n=new Date().getHours(),r=((l=e==null?void 0:e.name)==null?void 0:l.split(" ")[0])||"du";return t?n<10?`Godmorgon ${r}! Idag kör vi ${t.name.toLowerCase()}. Redo?`:n<14?`${t.name} står på schemat idag. Dags att köra!`:n<18?`Eftermiddagspass? ${t.name} väntar på dig.`:`Kvällspass ${r}? ${t.name} – perfekt för att avsluta dagen.`:n<10?`Godmorgon ${r}! Vilodag idag – perfekt för återhämtning.`:n<14?"Ingen träning schemalagd. Ta en promenad eller stretcha lite?":n<18?"Vila är också träning! Lätt rörelse eller mobilitet idag?":`Lugn kväll ${r}. Ladda batterierna till nästa pass!`},im=[{iconName:"walking",text:"Promenad"},{iconName:"yoga",text:"Stretching"},{iconName:"swimming",text:"Simning"},{iconName:"cycling",text:"Cykling"}],om=["Mån","Tis","Ons","Tor","Fre","Lör","Sön"];function am({onStartWorkout:e,onNavigate:t}){var j,g;const{user:n,logout:r}=pt(),[l,s]=y.useState(null),[o,a]=y.useState(null),[u,d]=y.useState(!0),[m,f]=y.useState(um(new Date));y.useEffect(()=>{v()},[]);const v=async()=>{var x;try{const c=await(await fetch(`${lm}/programs/1`)).json();s(c);const h=new Date().getDay(),k=h===0?7:h,_=(x=c.days)==null?void 0:x.find(S=>S.day_number===k);a(_||null),d(!1)}catch(p){console.error("Failed to fetch data:",p),d(!1)}};if(u)return i.jsxs("div",{className:"dashboard loading",children:[i.jsx("div",{className:"spinner"}),i.jsx("p",{children:"Laddar..."})]});const w=((j=l==null?void 0:l.days)==null?void 0:j.map(x=>x.day_number))||[];return i.jsxs("div",{className:"dashboard",children:[i.jsx("header",{className:"dashboard-header",children:i.jsxs("div",{className:"header-top",children:[i.jsxs("h1",{className:"brand-title",children:[i.jsx(So,{}),i.jsx("span",{className:"brand-name",children:"Gravl"})]}),i.jsxs("nav",{className:"nav-menu",children:[i.jsx("button",{className:"nav-btn active",children:i.jsx(Z,{name:"home",size:18})}),i.jsx("button",{className:"nav-btn",onClick:()=>t("progress"),children:i.jsx(Z,{name:"chart",size:18})}),i.jsx("button",{className:"nav-btn",onClick:()=>t("profile"),children:i.jsx(Z,{name:"user",size:18})}),i.jsx("button",{className:"nav-btn logout",onClick:r,children:i.jsx(Z,{name:"logout",size:18})})]})]})}),i.jsxs("main",{className:"dashboard-main",children:[i.jsxs("section",{className:"week-calendar",children:[i.jsxs("div",{className:"calendar-header",children:[i.jsx("button",{className:"calendar-nav",onClick:()=>f(al(m,-7)),children:i.jsx(Z,{name:"chevronLeft",size:16})}),i.jsx("span",{className:"calendar-title",children:dm(m)}),i.jsx("button",{className:"calendar-nav",onClick:()=>f(al(m,7)),children:i.jsx(Z,{name:"chevronRight",size:16})})]}),i.jsx("div",{className:"calendar-days",children:om.map((x,p)=>{var E;const c=al(m,p),h=p+1,k=cm(c,new Date),_=w.includes(h),S=(E=l==null?void 0:l.days)==null?void 0:E.find(C=>C.day_number===h);return i.jsxs("div",{className:`calendar-day ${k?"today":""} ${_?"has-workout":""}`,onClick:()=>_&&S&&e(S),children:[i.jsx("span",{className:"day-name",children:x}),i.jsx("span",{className:"day-date",children:c.getDate()}),_&&i.jsx("span",{className:"day-dot"})]},p)})})]}),i.jsxs("section",{className:"coach-section",children:[i.jsxs("div",{className:"coach-greeting",children:[i.jsx("div",{className:"coach-avatar",children:i.jsx(Z,{name:"coach",size:36})}),i.jsx("div",{className:"coach-message",children:i.jsx("p",{children:sm(n,o)})})]}),i.jsx("div",{className:"today-action",children:o?i.jsxs("div",{className:"today-workout-card",onClick:()=>e(o),children:[i.jsxs("div",{className:"workout-info",children:[i.jsx("h3",{children:o.name}),i.jsxs("span",{className:"workout-meta",children:[(g=o.exercises)==null?void 0:g.filter(x=>x.name).length," övningar • ~45 min"]})]}),i.jsx("div",{className:"workout-action",children:i.jsx(Z,{name:"arrowRight",size:24})})]}):i.jsxs("div",{className:"rest-day-section",children:[i.jsx("div",{className:"rest-tips",children:im.map((x,p)=>i.jsxs("span",{className:"tip-badge",children:[i.jsx(Z,{name:x.iconName,size:16}),x.text]},p))}),i.jsxs("button",{className:"add-workout-btn",onClick:()=>t("select-workout"),children:[i.jsx(Z,{name:"plus",size:20}),i.jsx("span",{children:"Lägg till pass"})]})]})})]}),i.jsxs("section",{className:"quick-stats",children:[i.jsxs("div",{className:"stat-card",children:[i.jsx("span",{className:"stat-value",children:w.length}),i.jsx("span",{className:"stat-label",children:"Pass/vecka"})]}),i.jsxs("div",{className:"stat-card",children:[i.jsx("span",{className:"stat-value",children:"2"}),i.jsx("span",{className:"stat-label",children:"Denna vecka"})]}),i.jsxs("div",{className:"stat-card",children:[i.jsx("span",{className:"stat-value stat-icon",children:i.jsx(Z,{name:"fire",size:28})}),i.jsx("span",{className:"stat-label",children:"Streak: 5"})]})]})]})]})}function um(e){const t=new Date(e),n=t.getDay(),r=t.getDate()-n+(n===0?-6:1);return new Date(t.setDate(r))}function al(e,t){const n=new Date(e);return n.setDate(n.getDate()+t),n}function cm(e,t){return e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}function dm(e){const t=al(e,6),n=e.toLocaleDateString("sv-SE",{month:"short"}),r=t.toLocaleDateString("sv-SE",{month:"short"});return n===r?`${e.getDate()} - ${t.getDate()} ${n}`:`${e.getDate()} ${n} - ${t.getDate()} ${r}`}const Xr="/api";function fm({onBack:e}){const{user:t,logout:n}=pt(),[r,l]=y.useState(null),[s,o]=y.useState(null),[a,u]=y.useState(null),[d,m]=y.useState(!1),[f,v]=y.useState(!0),[w,j]=y.useState(!1),[g,x]=y.useState({});y.useEffect(()=>{p()},[]);const p=async()=>{try{const[S,E,C]=await Promise.all([fetch(`${Xr}/user/profile/${(t==null?void 0:t.id)||1}`),fetch(`${Xr}/user/measurements/${(t==null?void 0:t.id)||1}`),fetch(`${Xr}/user/strength/${(t==null?void 0:t.id)||1}`)]),P=await S.json(),M=await E.json(),D=await C.json();l(P),o(M),u(D),x(P),v(!1)}catch(S){console.error("Failed to fetch profile:",S),v(!1)}},c=async()=>{j(!0);try{const E=await(await fetch(`${Xr}/user/profile/${(t==null?void 0:t.id)||1}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)})).json();l(E),m(!1)}catch(S){console.error("Failed to save profile:",S)}j(!1)},h=(S,E)=>{x(C=>({...C,[S]:E}))};if(f)return i.jsxs("div",{className:"profile-page loading",children:[i.jsx("div",{className:"spinner"}),i.jsx("p",{children:"Laddar profil..."})]});const k=s==null?void 0:s[0],_=a==null?void 0:a[0];return i.jsxs("div",{className:"profile-page",children:[i.jsxs("header",{className:"page-header",children:[i.jsx("button",{className:"back-btn",onClick:e,children:"← Tillbaka"}),i.jsx("h1",{children:"Min profil"}),i.jsx("button",{className:"logout-btn",onClick:n,children:"↪"})]}),i.jsxs("main",{className:"page-main",children:[i.jsxs("section",{className:"profile-section",children:[i.jsxs("div",{className:"section-header",children:[i.jsx("h2",{children:"Personuppgifter"}),!d&&i.jsx("button",{className:"edit-btn",onClick:()=>m(!0),children:"✏️ Redigera"})]}),d?i.jsxs("div",{className:"edit-form",children:[i.jsxs("div",{className:"form-group",children:[i.jsx("label",{children:"Namn"}),i.jsx("input",{type:"text",value:g.name||"",onChange:S=>h("name",S.target.value)})]}),i.jsxs("div",{className:"form-row",children:[i.jsxs("div",{className:"form-group",children:[i.jsx("label",{children:"Ålder"}),i.jsx("input",{type:"number",value:g.age||"",onChange:S=>h("age",parseInt(S.target.value))})]}),i.jsxs("div",{className:"form-group",children:[i.jsx("label",{children:"Kön"}),i.jsxs("select",{value:g.gender||"",onChange:S=>h("gender",S.target.value),children:[i.jsx("option",{value:"male",children:"Man"}),i.jsx("option",{value:"female",children:"Kvinna"})]})]})]}),i.jsxs("div",{className:"form-row",children:[i.jsxs("div",{className:"form-group",children:[i.jsx("label",{children:"Längd (cm)"}),i.jsx("input",{type:"number",value:g.height_cm||"",onChange:S=>h("height_cm",parseFloat(S.target.value))})]}),i.jsxs("div",{className:"form-group",children:[i.jsx("label",{children:"Pass/vecka"}),i.jsx("input",{type:"number",min:"1",max:"7",value:g.workouts_per_week||"",onChange:S=>h("workouts_per_week",parseInt(S.target.value))})]})]}),i.jsxs("div",{className:"form-group",children:[i.jsx("label",{children:"Mål"}),i.jsxs("select",{value:g.goal||"",onChange:S=>h("goal",S.target.value),children:[i.jsx("option",{value:"muscle",children:"Bygga muskler"}),i.jsx("option",{value:"strength",children:"Öka styrka"}),i.jsx("option",{value:"fat_loss",children:"Fettförbränning"}),i.jsx("option",{value:"general",children:"Allmän fitness"})]})]}),i.jsxs("div",{className:"form-group",children:[i.jsx("label",{children:"Erfarenhetsnivå"}),i.jsxs("select",{value:g.experience_level||"",onChange:S=>h("experience_level",S.target.value),children:[i.jsx("option",{value:"beginner",children:"Nybörjare"}),i.jsx("option",{value:"intermediate",children:"Medel"}),i.jsx("option",{value:"advanced",children:"Avancerad"})]})]}),i.jsxs("div",{className:"form-actions",children:[i.jsx("button",{className:"cancel-btn",onClick:()=>{m(!1),x(r)},children:"Avbryt"}),i.jsx("button",{className:"save-btn",onClick:c,disabled:w,children:w?"Sparar...":"Spara"})]})]}):i.jsx("div",{className:"profile-info",children:i.jsxs("div",{className:"info-grid",children:[i.jsxs("div",{className:"info-item",children:[i.jsx("span",{className:"info-label",children:"Namn"}),i.jsx("span",{className:"info-value",children:(r==null?void 0:r.name)||"-"})]}),i.jsxs("div",{className:"info-item",children:[i.jsx("span",{className:"info-label",children:"Ålder"}),i.jsxs("span",{className:"info-value",children:[(r==null?void 0:r.age)||"-"," år"]})]}),i.jsxs("div",{className:"info-item",children:[i.jsx("span",{className:"info-label",children:"Längd"}),i.jsxs("span",{className:"info-value",children:[(r==null?void 0:r.height_cm)||"-"," cm"]})]}),i.jsxs("div",{className:"info-item",children:[i.jsx("span",{className:"info-label",children:"Kön"}),i.jsx("span",{className:"info-value",children:(r==null?void 0:r.gender)==="male"?"Man":"Kvinna"})]}),i.jsxs("div",{className:"info-item",children:[i.jsx("span",{className:"info-label",children:"Mål"}),i.jsx("span",{className:"info-value",children:pm(r==null?void 0:r.goal)})]}),i.jsxs("div",{className:"info-item",children:[i.jsx("span",{className:"info-label",children:"Nivå"}),i.jsx("span",{className:"info-value",children:hm(r==null?void 0:r.experience_level)})]}),i.jsxs("div",{className:"info-item",children:[i.jsx("span",{className:"info-label",children:"Pass/vecka"}),i.jsx("span",{className:"info-value",children:(r==null?void 0:r.workouts_per_week)||"-"})]})]})})]}),i.jsxs("section",{className:"profile-section",children:[i.jsx("h2",{children:"Aktuella mätningar"}),k?i.jsxs("div",{className:"measurements-grid",children:[i.jsxs("div",{className:"measurement-card",children:[i.jsx("span",{className:"measurement-icon",children:"⚖️"}),i.jsxs("span",{className:"measurement-value",children:[k.weight," kg"]}),i.jsx("span",{className:"measurement-label",children:"Vikt"})]}),k.body_fat_pct&&i.jsxs("div",{className:"measurement-card",children:[i.jsx("span",{className:"measurement-icon",children:"📊"}),i.jsxs("span",{className:"measurement-value",children:[k.body_fat_pct,"%"]}),i.jsx("span",{className:"measurement-label",children:"Kroppsfett"})]}),k.waist_cm&&i.jsxs("div",{className:"measurement-card",children:[i.jsx("span",{className:"measurement-icon",children:"📏"}),i.jsxs("span",{className:"measurement-value",children:[k.waist_cm," cm"]}),i.jsx("span",{className:"measurement-label",children:"Midja"})]}),k.neck_cm&&i.jsxs("div",{className:"measurement-card",children:[i.jsx("span",{className:"measurement-icon",children:"📏"}),i.jsxs("span",{className:"measurement-value",children:[k.neck_cm," cm"]}),i.jsx("span",{className:"measurement-label",children:"Nacke"})]})]}):i.jsx("p",{className:"no-data",children:"Inga mätningar registrerade"})]}),i.jsxs("section",{className:"profile-section",children:[i.jsx("h2",{children:"Styrkerekord (1RM)"}),_?i.jsxs("div",{className:"strength-grid",children:[i.jsxs("div",{className:"strength-card",children:[i.jsx("span",{className:"strength-exercise",children:"Bänkpress"}),i.jsxs("span",{className:"strength-value",children:[_.bench_1rm||"-"," kg"]})]}),i.jsxs("div",{className:"strength-card",children:[i.jsx("span",{className:"strength-exercise",children:"Knäböj"}),i.jsxs("span",{className:"strength-value",children:[_.squat_1rm||"-"," kg"]})]}),i.jsxs("div",{className:"strength-card",children:[i.jsx("span",{className:"strength-exercise",children:"Marklyft"}),i.jsxs("span",{className:"strength-value",children:[_.deadlift_1rm||"-"," kg"]})]})]}):i.jsx("p",{className:"no-data",children:"Inga styrkerekord registrerade"})]})]})]})}function pm(e){return{muscle:"Bygga muskler",strength:"Öka styrka",fat_loss:"Fettförbränning",general:"Allmän fitness"}[e]||e||"-"}function hm(e){return{beginner:"Nybörjare",intermediate:"Medel",advanced:"Avancerad"}[e]||e||"-"}const Wa="/api";function mm({onBack:e}){const{user:t}=pt(),[n,r]=y.useState([]),[l,s]=y.useState([]),[o,a]=y.useState(!0),[u,d]=y.useState("weight");y.useEffect(()=>{m()},[]);const m=async()=>{try{const[f,v]=await Promise.all([fetch(`${Wa}/user/measurements/${(t==null?void 0:t.id)||1}`),fetch(`${Wa}/user/strength/${(t==null?void 0:t.id)||1}`)]),w=await f.json(),j=await v.json();r([...w].reverse()),s([...j].reverse()),a(!1)}catch(f){console.error("Failed to fetch progress:",f),a(!1)}};return o?i.jsxs("div",{className:"progress-page loading",children:[i.jsx("div",{className:"spinner"}),i.jsx("p",{children:"Laddar progress..."})]}):i.jsxs("div",{className:"progress-page",children:[i.jsxs("header",{className:"page-header",children:[i.jsx("button",{className:"back-btn",onClick:e,children:"← Tillbaka"}),i.jsx("h1",{children:"Min progress"}),i.jsx("div",{style:{width:40}})]}),i.jsxs("main",{className:"page-main",children:[i.jsxs("div",{className:"progress-tabs",children:[i.jsx("button",{className:`tab-btn ${u==="weight"?"active":""}`,onClick:()=>d("weight"),children:"⚖️ Vikt"}),i.jsx("button",{className:`tab-btn ${u==="bodyfat"?"active":""}`,onClick:()=>d("bodyfat"),children:"📊 Kroppsfett"}),i.jsx("button",{className:`tab-btn ${u==="strength"?"active":""}`,onClick:()=>d("strength"),children:"💪 Styrka"})]}),u==="weight"&&i.jsxs("section",{className:"chart-section",children:[i.jsx("h2",{children:"Viktutveckling"}),n.length>0?i.jsxs(i.Fragment,{children:[i.jsx(Wn,{data:n,valueKey:"weight",unit:"kg",color:"var(--accent)"}),i.jsx(Vn,{data:n,valueKey:"weight",unit:"kg",label:"Vikt"})]}):i.jsx(_s,{message:"Inga viktmätningar registrerade"})]}),u==="bodyfat"&&i.jsxs("section",{className:"chart-section",children:[i.jsx("h2",{children:"Kroppsfett"}),n.filter(f=>f.body_fat_pct).length>0?i.jsxs(i.Fragment,{children:[i.jsx(Wn,{data:n.filter(f=>f.body_fat_pct),valueKey:"body_fat_pct",unit:"%",color:"#10b981"}),i.jsx(Vn,{data:n.filter(f=>f.body_fat_pct),valueKey:"body_fat_pct",unit:"%",label:"Kroppsfett"})]}):i.jsx(_s,{message:"Inga kroppsfettmätningar registrerade"})]}),u==="strength"&&i.jsxs("section",{className:"chart-section",children:[i.jsx("h2",{children:"Styrkerekord (1RM)"}),l.length>0?i.jsxs("div",{className:"strength-charts",children:[i.jsxs("div",{className:"strength-chart-item",children:[i.jsx("h3",{children:"🏋️ Bänkpress"}),i.jsx(Wn,{data:l.filter(f=>f.bench_1rm),valueKey:"bench_1rm",unit:"kg",color:"#f59e0b"}),i.jsx(Vn,{data:l.filter(f=>f.bench_1rm),valueKey:"bench_1rm",unit:"kg",label:"Bänkpress"})]}),i.jsxs("div",{className:"strength-chart-item",children:[i.jsx("h3",{children:"🦵 Knäböj"}),i.jsx(Wn,{data:l.filter(f=>f.squat_1rm),valueKey:"squat_1rm",unit:"kg",color:"#8b5cf6"}),i.jsx(Vn,{data:l.filter(f=>f.squat_1rm),valueKey:"squat_1rm",unit:"kg",label:"Knäböj"})]}),i.jsxs("div",{className:"strength-chart-item",children:[i.jsx("h3",{children:"💀 Marklyft"}),i.jsx(Wn,{data:l.filter(f=>f.deadlift_1rm),valueKey:"deadlift_1rm",unit:"kg",color:"#ef4444"}),i.jsx(Vn,{data:l.filter(f=>f.deadlift_1rm),valueKey:"deadlift_1rm",unit:"kg",label:"Marklyft"})]})]}):i.jsx(_s,{message:"Inga styrkerekord registrerade"})]})]})]})}function Wn({data:e,valueKey:t,unit:n,color:r}){var x,p;if(!e||e.length===0)return null;const l=e.map(c=>c[t]).filter(c=>c!=null);if(l.length===0)return null;const s=Math.min(...l)*.95,o=Math.max(...l)*1.05,a=o-s||1,u=320,d=160,m={top:20,right:20,bottom:30,left:50},f=u-m.left-m.right,v=d-m.top-m.bottom,w=e.map((c,h)=>{const k=m.left+h/Math.max(e.length-1,1)*f,_=m.top+v-(c[t]-s)/a*v;return{x:k,y:_,value:c[t],date:c.created_at}}).filter(c=>c.value!=null),j=w.map((c,h)=>`${h===0?"M":"L"} ${c.x} ${c.y}`).join(" "),g=[s,(s+o)/2,o].map(c=>c.toFixed(1));return i.jsxs("div",{className:"chart-container",children:[i.jsxs("svg",{viewBox:`0 0 ${u} ${d}`,className:"line-chart",children:[[0,.5,1].map((c,h)=>i.jsx("line",{x1:m.left,y1:m.top+v*(1-c),x2:u-m.right,y2:m.top+v*(1-c),stroke:"var(--border)",strokeDasharray:"4"},h)),g.map((c,h)=>i.jsx("text",{x:m.left-8,y:m.top+v*(1-h*.5)+4,textAnchor:"end",fontSize:"10",fill:"var(--text-muted)",children:c},h)),i.jsx("path",{d:j,fill:"none",stroke:r,strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),w.map((c,h)=>i.jsx("circle",{cx:c.x,cy:c.y,r:"4",fill:r},h))]}),i.jsxs("div",{className:"chart-labels",children:[i.jsx("span",{children:Va((x=e[0])==null?void 0:x.created_at)}),i.jsx("span",{children:Va((p=e[e.length-1])==null?void 0:p.created_at)})]})]})}function Vn({data:e,valueKey:t,unit:n,label:r}){if(!e||e.length===0)return null;const l=e.map(f=>f[t]).filter(f=>f!=null);if(l.length===0)return null;const s=l[l.length-1],o=l[0],a=s-o,u=(a/o*100).toFixed(1),d=a>0?"↑":a<0?"↓":"→",m=a>0?"up":a<0?"down":"neutral";return i.jsxs("div",{className:"progress-stats",children:[i.jsxs("div",{className:"stat-item",children:[i.jsx("span",{className:"stat-label",children:"Nuvarande"}),i.jsxs("span",{className:"stat-value",children:[s," ",n]})]}),i.jsxs("div",{className:"stat-item",children:[i.jsx("span",{className:"stat-label",children:"Första"}),i.jsxs("span",{className:"stat-value",children:[o," ",n]})]}),i.jsxs("div",{className:"stat-item",children:[i.jsx("span",{className:"stat-label",children:"Förändring"}),i.jsxs("span",{className:`stat-value trend-${m}`,children:[d," ",Math.abs(a).toFixed(1)," ",n," (",u,"%)"]})]})]})}function _s({message:e}){return i.jsxs("div",{className:"empty-state",children:[i.jsx("span",{className:"empty-icon",children:"📊"}),i.jsx("p",{children:e}),i.jsx("p",{className:"empty-hint",children:"Logga mätningar för att se din progress"})]})}function Va(e){return e?new Date(e).toLocaleDateString("sv-SE",{month:"short",day:"numeric"}):"-"}function vm({exercise:e,alternatives:t,loading:n,error:r,onSelect:l,onClose:s}){return e?i.jsx("div",{className:"alternative-modal-overlay",onClick:s,children:i.jsxs("div",{className:"alternative-modal",onClick:o=>o.stopPropagation(),children:[i.jsxs("div",{className:"alternative-modal-header",children:[i.jsxs("div",{children:[i.jsx("h3",{children:"Alternativa övningar"}),i.jsxs("p",{children:["För ",e.name]})]}),i.jsx("button",{className:"alternative-modal-close",onClick:s,"aria-label":"Stäng",children:i.jsx(Z,{name:"chevronDown",size:18})})]}),n&&i.jsx("div",{className:"alternative-modal-state",children:"Laddar alternativ..."}),!n&&r&&i.jsx("div",{className:"alternative-modal-state error",children:r}),!n&&!r&&t.length===0&&i.jsx("div",{className:"alternative-modal-state",children:"Inga alternativ hittades."}),!n&&!r&&t.length>0&&i.jsx("div",{className:"alternative-list",children:t.map(o=>i.jsxs("div",{className:"alternative-item",children:[i.jsxs("div",{className:"alternative-info",children:[i.jsx("strong",{children:o.name}),i.jsx("span",{children:o.description||"Ingen beskrivning tillgänglig."})]}),i.jsx("button",{className:"alternative-select-btn",onClick:()=>l(o),children:"Välj"})]},o.id))})]})}):null}const gm="/api",Ha={general:[{name:"Cykel eller roddmaskin",duration:"5 min"},{name:"Armcirklar",duration:"30 sek/riktning"},{name:"Bensvingar (framåt/bakåt)",duration:"10 per ben"},{name:"Bensvingar (sidled)",duration:"10 per ben"},{name:"Höftcirklar",duration:"10 per riktning"}],specific:{Bröst:[{name:"Lätta armhävningar",reps:"10-15"},{name:"Band pull-aparts",reps:"15-20"}],Rygg:[{name:"Lat stretch",reps:"30 sek/sida"},{name:"Lätta rodd-drag",reps:"15-20"}],Ben:[{name:"Bodyweight squats",reps:"15-20"},{name:"Utfallssteg",reps:"10/ben"}],Axlar:[{name:"Axelrotationer",reps:"10/riktning"},{name:"Band dislocates",reps:"10-15"}],Armar:[{name:"Handledscirklar",reps:"10/riktning"},{name:"Lätta bicepscurls",reps:"15-20"}]}};function ym(e){const t=new Set;return e.forEach(n=>{n.muscle_group&&t.add(n.muscle_group)}),Array.from(t)}function xm({day:e,week:t,logs:n,onLogSet:r,onDeleteSet:l,onBack:s,fetchProgression:o}){var H;const[a,u]=y.useState({}),[d,m]=y.useState(null),[f,v]=y.useState(!1),[w,j]=y.useState(!0),[g,x]=y.useState(new Set),[p,c]=y.useState(null),[h,k]=y.useState([]),[_,S]=y.useState(!1),[E,C]=y.useState(""),[P,M]=y.useState({}),D=90,[X,K]=y.useState(D),[A,me]=y.useState(!1);y.useEffect(()=>{ht()},[e]),y.useEffect(()=>{if(!A)return;const T=setInterval(()=>{K($=>$<=1?(me(!1),0):$-1)},1e3);return()=>clearInterval(T)},[A]);const ht=async()=>{const T={};for(const $ of e.exercises)$.id&&(T[$.id]=await o($.id));u(T)},At=async T=>{if(!(T!=null&&T.exercise_id)){C("Saknar övningsdata för alternativa val."),c(T);return}c(T),k([]),C(""),S(!0);try{const $=await fetch(`${gm}/exercises/${T.exercise_id}/alternatives`);if(!$.ok)throw new Error("Failed to fetch alternatives");const de=await $.json();k(de)}catch($){console.error("Failed to fetch alternatives:",$),C("Kunde inte hämta alternativ.")}finally{S(!1)}},z=T=>{p&&(M($=>({...$,[p.id]:T})),c(null))},O=((H=e.exercises)==null?void 0:H.filter(T=>T.name))||[],I=ym(O),V=O.filter(T=>(n[T.id]||[]).filter(ql=>ql.completed).length>=T.sets).length,G=T=>{const $=new Set(g);$.has(T)?$.delete(T):$.add(T),x($)},Ze=Ha.general,Ne=I.flatMap(T=>Ha.specific[T]||[]),mt=Ze.length+Ne.length,Ve=g.size,vt=T=>{const $=Math.floor(T/60),de=T%60;return`${$}:${de.toString().padStart(2,"0")}`},N=(T=D)=>{K(T),me(!0)},F=()=>{me(T=>!T)},W=()=>{me(!1),K(D)};return i.jsxs("div",{className:"workout-page",children:[i.jsxs("header",{className:"page-header",children:[i.jsxs("button",{className:"back-btn",onClick:s,children:[i.jsx(Z,{name:"arrowLeft",size:16})," Tillbaka"]}),i.jsxs("div",{className:"header-center",children:[i.jsx("h1",{children:e.name}),i.jsxs("span",{className:"header-subtitle",children:["Vecka ",t," • Dag ",e.day_number]})]}),i.jsx("div",{className:"header-progress",children:i.jsxs("span",{className:"progress-text",children:[V,"/",O.length]})})]}),i.jsxs("main",{className:"page-main workout-main",children:[i.jsxs("section",{className:"rest-timer-card",children:[i.jsxs("div",{className:"rest-timer-header",children:[i.jsx("div",{className:"rest-timer-label",children:"Vilotimer"}),i.jsx("div",{className:`rest-timer-time ${A?"running":""}`,children:vt(X)})]}),i.jsxs("div",{className:"rest-timer-actions",children:[i.jsx("button",{className:"rest-timer-btn primary",onClick:F,children:A?"Pausa":"Starta vila"}),i.jsx("button",{className:"rest-timer-btn secondary",onClick:W,children:"Återställ"})]}),i.jsxs("div",{className:"rest-timer-presets",children:[i.jsx("button",{className:"rest-timer-chip",onClick:()=>N(60),children:"1:00"}),i.jsx("button",{className:"rest-timer-chip",onClick:()=>N(90),children:"1:30"}),i.jsx("button",{className:"rest-timer-chip",onClick:()=>N(120),children:"2:00"})]})]}),i.jsx("div",{className:"workout-progress-bar",children:i.jsx("div",{className:"workout-progress-fill",style:{width:`${V/O.length*100}%`}})}),i.jsxs("section",{className:`warmup-section ${f?"completed":""}`,children:[i.jsxs("div",{className:"warmup-header",onClick:()=>j(!w),children:[i.jsxs("div",{className:"warmup-title",children:[i.jsx("span",{className:"warmup-icon",children:i.jsx(Z,{name:"fire",size:20})}),i.jsx("h2",{children:"Uppvärmning"}),i.jsxs("span",{className:"warmup-progress",children:[Ve,"/",mt]})]}),i.jsx("span",{className:`expand-icon ${w?"expanded":""}`,children:i.jsx(Z,{name:"chevronDown",size:16})})]}),w&&i.jsxs("div",{className:"warmup-content",children:[i.jsxs("div",{className:"warmup-category",children:[i.jsx("h3",{children:"Generell uppvärmning (5-10 min)"}),i.jsx("div",{className:"warmup-list",children:Ze.map((T,$)=>i.jsxs("div",{className:`warmup-item ${g.has($)?"done":""}`,onClick:()=>G($),children:[i.jsx("span",{className:"warmup-check",children:g.has($)?i.jsx(Z,{name:"check",size:14}):""}),i.jsx("span",{className:"warmup-name",children:T.name}),i.jsx("span",{className:"warmup-duration",children:T.duration||T.reps})]},$))})]}),Ne.length>0&&i.jsxs("div",{className:"warmup-category",children:[i.jsxs("h3",{children:["Specifik för ",I.join(", ")]}),i.jsx("div",{className:"warmup-list",children:Ne.map((T,$)=>{const de=Ze.length+$;return i.jsxs("div",{className:`warmup-item ${g.has(de)?"done":""}`,onClick:()=>G(de),children:[i.jsx("span",{className:"warmup-check",children:g.has(de)?i.jsx(Z,{name:"check",size:14}):""}),i.jsx("span",{className:"warmup-name",children:T.name}),i.jsx("span",{className:"warmup-duration",children:T.reps})]},de)})})]}),O[0]&&i.jsxs("div",{className:"warmup-category",children:[i.jsx("h3",{children:"Förberedande set"}),i.jsx("div",{className:"warmup-list",children:i.jsxs("div",{className:`warmup-item ${g.has("prep")?"done":""}`,onClick:()=>{const T=new Set(g);T.has("prep")?T.delete("prep"):T.add("prep"),x(T)},children:[i.jsx("span",{className:"warmup-check",children:g.has("prep")?i.jsx(Z,{name:"check",size:14}):""}),i.jsxs("span",{className:"warmup-name",children:["Lätta set ",O[0].name]}),i.jsx("span",{className:"warmup-duration",children:"2x10 @ 50%"})]})})]}),i.jsx("button",{className:`warmup-done-btn ${f?"completed":""}`,onClick:()=>v(!f),children:f?i.jsxs(i.Fragment,{children:[i.jsx(Z,{name:"check",size:18})," Uppvärmning klar"]}):"Markera uppvärmning som klar"})]})]}),i.jsxs("section",{className:"exercises-section",children:[i.jsx("h2",{children:"Övningar"}),O.map((T,$)=>{const de=P[T.id],ql=de?{...T,name:de.name,muscle_group:de.muscle_group,description:de.description}:T;return i.jsx(km,{exercise:ql,isSwapped:!!de,logs:n[T.id]||[],progression:a[T.id],expanded:d===T.id,onToggle:()=>m(d===T.id?null:T.id),onLogSet:r,onDeleteSet:l,onStartRest:N,onSwap:()=>At(T)},T.id||$)})]}),i.jsx("button",{className:`finish-workout-btn ${V===O.length?"ready":""}`,onClick:s,children:V===O.length?"Avsluta pass":`Avsluta pass (${V}/${O.length} klara)`})]}),i.jsx(vm,{exercise:p,alternatives:h,loading:_,error:E,onSelect:z,onClose:()=>c(null)})]})}function km({exercise:e,logs:t,progression:n,expanded:r,onToggle:l,onLogSet:s,onDeleteSet:o,onSwap:a,isSwapped:u,onStartRest:d}){const[m,f]=y.useState([]),[v,w]=y.useState(!1),j=2.5,g=1;y.useEffect(()=>{var M,D,X;const P=[];for(let K=1;K<=e.sets;K++){const A=t.find(me=>me.set_number===K);P.push({weight:((M=A==null?void 0:A.weight)==null?void 0:M.toString())||((D=n==null?void 0:n.suggestedWeight)==null?void 0:D.toString())||"",reps:((X=A==null?void 0:A.reps)==null?void 0:X.toString())||"",completed:(A==null?void 0:A.completed)||!1})}f(P)},[e,t,n]);const x=(P,M,D)=>{f(X=>X.map((K,A)=>A===P?{...K,[M]:D}:K))},p=P=>{const M=parseFloat(P);return Number.isFinite(M)?M:0},c=P=>(Number.isInteger(P)?String(P):P.toFixed(1)).replace(/\.0$/,""),h=(P,M,D,X=0)=>{var me;const K=p((me=m[P])==null?void 0:me[M]),A=Math.max(X,K+D);M==="weight"?x(P,M,c(A)):x(P,M,String(Math.round(A)))},k=P=>{const M=m[P],D=!M.completed;f(X=>X.map((K,A)=>A===P?{...K,completed:D}:K)),s(e.id,P+1,M.weight,M.reps,D),D&&(d==null||d())},_=()=>{const P=m[m.length-1]||{weight:"",reps:""};f(M=>[...M,{weight:P.weight,reps:P.reps,completed:!1}]),w(!1)},S=()=>{const P=m[m.length-1]||{weight:"0"},M=parseFloat(P.weight)||0,D=Math.round(M*.8/2.5)*2.5,X=Math.round(M*.6/2.5)*2.5,K=[{weight:P.weight,reps:"10",completed:!1},{weight:D.toString(),reps:"10",completed:!1},{weight:X.toString(),reps:"10",completed:!1}];f(A=>[...A,...K]),w(!1)},E=P=>{m.length<=1||(f(M=>M.filter((D,X)=>X!==P)),o&&o(e.id,P+1))},C=m.filter(P=>P.completed).length;return i.jsxs("div",{className:`exercise-card ${r?"expanded":""} ${C===m.length&&m.length>0?"all-done":""}`,children:[i.jsxs("div",{className:"exercise-header",onClick:l,children:[i.jsxs("div",{className:"exercise-info",children:[i.jsx("h3",{children:e.name}),i.jsx("span",{className:"muscle-group",children:e.muscle_group}),u&&i.jsx("span",{className:"swap-badge",children:"Alternativ"})]}),i.jsxs("div",{className:"exercise-actions",children:[i.jsxs("div",{className:"exercise-meta",children:[i.jsxs("span",{className:"sets-info",children:[e.sets,"×",e.reps_min,"-",e.reps_max]}),i.jsxs("span",{className:`progress-badge ${C===m.length?"complete":""}`,children:[C,"/",m.length]})]}),i.jsx("button",{className:"swap-btn",onClick:P=>{P.stopPropagation(),a==null||a()},"aria-label":"Byt övning",children:i.jsx(Z,{name:"swap",size:16})})]})]}),r&&i.jsxs("div",{className:"exercise-body",children:[n&&i.jsxs("div",{className:"progression-hint",children:[n.reason,n.suggestedWeight&&i.jsxs("strong",{children:[" ",n.suggestedWeight," kg"]})]}),i.jsx("div",{className:"sets-list",children:m.map((P,M)=>i.jsxs("div",{className:`set-row ${P.completed?"completed":""}`,children:[i.jsxs("div",{className:"set-row-top",children:[i.jsxs("span",{className:"set-number",children:["Set ",M+1]}),i.jsx("button",{className:`delete-set-btn ${m.length<=1?"disabled":""}`,onClick:()=>E(M),disabled:m.length<=1,"aria-label":`Ta bort set ${M+1}`,children:i.jsx(Z,{name:"trash",size:16})})]}),i.jsxs("div",{className:"set-controls",children:[i.jsxs("div",{className:"set-metric",children:[i.jsx("span",{className:"metric-label",children:"Vikt"}),i.jsxs("div",{className:"metric-controls",children:[i.jsx("button",{type:"button",className:"metric-btn",onClick:()=>h(M,"weight",-j),"aria-label":"Minska vikt",children:"−"}),i.jsxs("div",{className:"metric-value",children:[i.jsx("span",{className:"metric-number",children:P.weight===""?"0":P.weight}),i.jsx("span",{className:"metric-suffix",children:"kg"})]}),i.jsx("button",{type:"button",className:"metric-btn",onClick:()=>h(M,"weight",j),"aria-label":"Öka vikt",children:"+"})]})]}),i.jsxs("div",{className:"set-metric",children:[i.jsx("span",{className:"metric-label",children:"Reps"}),i.jsxs("div",{className:"metric-controls",children:[i.jsx("button",{type:"button",className:"metric-btn",onClick:()=>h(M,"reps",-g),"aria-label":"Minska reps",children:"−"}),i.jsx("div",{className:"metric-value",children:i.jsx("span",{className:"metric-number",children:P.reps===""?"0":P.reps})}),i.jsx("button",{type:"button",className:"metric-btn",onClick:()=>h(M,"reps",g),"aria-label":"Öka reps",children:"+"})]})]})]}),i.jsxs("button",{className:`klart-btn ${P.completed?"done":""}`,onClick:()=>k(M),children:[P.completed?i.jsx(Z,{name:"check",size:18}):null,"KLART"]})]},M))}),i.jsx("button",{className:"add-set-btn",onClick:()=>w(!0),children:"+ Lägg till set"}),v&&i.jsx("div",{className:"set-type-modal-overlay",onClick:()=>w(!1),children:i.jsxs("div",{className:"set-type-modal",onClick:P=>P.stopPropagation(),children:[i.jsx("h3",{children:"Välj settyp"}),i.jsxs("button",{className:"set-type-option",onClick:_,children:[i.jsx("strong",{children:"Vanligt set"}),i.jsx("span",{children:"Lägg till ett set"})]}),i.jsxs("button",{className:"set-type-option dropset",onClick:S,children:[i.jsx("strong",{children:"Dropset"}),i.jsx("span",{children:"3 set med viktnedtrappning (20% per steg)"})]}),i.jsx("button",{className:"set-type-cancel",onClick:()=>w(!1),children:"Avbryt"})]})})]})]})}const Qa="/api",wm=e=>{const t=e.toLowerCase();return t.includes("push")||t.includes("bröst")?"var(--workout-push)":t.includes("pull")||t.includes("rygg")?"var(--workout-pull)":t.includes("ben")||t.includes("leg")?"var(--workout-legs)":t.includes("axlar")?"var(--workout-shoulders)":t.includes("överkropp")||t.includes("upper")?"var(--workout-upper)":t.includes("underkropp")||t.includes("lower")?"var(--workout-lower)":"var(--workout-default)"};function jm({onBack:e,onSelectWorkout:t}){var g;const[n,r]=y.useState(null),[l,s]=y.useState([]),[o,a]=y.useState(!0),[u,d]=y.useState(null);y.useEffect(()=>{m(),f()},[]);const m=async()=>{try{const p=await(await fetch(`${Qa}/programs/1`)).json();r(p),a(!1)}catch(x){console.error("Failed to fetch program:",x),a(!1)}},f=async()=>{try{const x=localStorage.getItem("token");if(!x)return;const c=await(await fetch(`${Qa}/custom-workouts`,{headers:{Authorization:`Bearer ${x}`}})).json();s(c||[])}catch(x){console.error("Failed to fetch custom workouts:",x)}},v=x=>l.some(p=>p.source_program_day_id===x),w=x=>{d(x)},j=()=>{u&&t(u)};return o?i.jsxs("div",{className:"select-page loading",children:[i.jsx("div",{className:"spinner"}),i.jsx("p",{children:"Laddar pass..."})]}):i.jsxs("div",{className:"select-page",children:[i.jsxs("header",{className:"page-header",children:[i.jsxs("button",{className:"back-btn",onClick:e,children:[i.jsx(Z,{name:"arrowLeft",size:18})," Tillbaka"]}),i.jsx("h1",{children:"Välj pass"}),i.jsx("div",{style:{width:40}})]}),i.jsxs("main",{className:"select-main",children:[i.jsx("p",{className:"select-intro",children:"Vilken träning vill du köra idag?"}),i.jsx("div",{className:"workout-grid",children:(g=n==null?void 0:n.days)==null?void 0:g.map(x=>{var S,E;const p=rm(x.name),c=wm(x.name),h=(u==null?void 0:u.id)===x.id,k=((S=x.exercises)==null?void 0:S.filter(C=>C.name).length)||0,_=v(x.id);return i.jsxs("div",{className:`workout-select-card ${h?"selected":""}`,style:{"--workout-color":c},onClick:()=>w(x),children:[i.jsxs("div",{className:"workout-badge-container",children:[i.jsx("div",{className:"workout-icon",style:{background:c},children:i.jsx(Z,{name:p,size:28})}),i.jsx("span",{className:`workout-badge ${_?"custom":"program"}`,children:_?"Anpassad":"Program"})]}),i.jsxs("div",{className:"workout-details",children:[i.jsx("h3",{children:x.name}),i.jsxs("p",{className:"workout-exercises-count",children:[k," övningar"]}),i.jsxs("div",{className:"workout-preview",children:[(E=x.exercises)==null?void 0:E.filter(C=>C.name).slice(0,2).map((C,P)=>i.jsx("span",{className:"preview-exercise",children:C.name},P)),k>2&&i.jsxs("span",{className:"preview-more",children:["+",k-2," till"]})]})]}),h&&i.jsx("div",{className:"selected-indicator",children:i.jsx(Z,{name:"check",size:16})})]},x.id)})}),u&&i.jsx("div",{className:"select-action",children:i.jsxs("button",{className:"start-btn",onClick:j,children:["Starta ",u.name," →"]})})]})]})}function Ka({text:e,typing:t=!1}){return i.jsxs("div",{className:`chat-message coach ${t?"typing":""}`,children:[i.jsx("div",{className:"chat-avatar",children:"C"}),i.jsx("div",{className:"chat-bubble",children:t?i.jsxs("div",{className:"typing-indicator","aria-label":"Coach skriver",children:[i.jsx("span",{}),i.jsx("span",{}),i.jsx("span",{})]}):e})]})}function Sm({text:e}){return i.jsx("div",{className:"chat-message user",children:i.jsx("div",{className:"chat-bubble",children:e})})}function Ga({options:e=[],onSelect:t,disabled:n=!1}){return e.length?i.jsx("div",{className:"quick-replies",children:e.map(r=>i.jsx("button",{type:"button",className:`quick-reply ${r.variant||""}`.trim(),onClick:()=>t(r),disabled:n||r.disabled,children:r.label},`${r.label}-${r.value}`))}):null}const Ya="/api",Xa={name:"",gender:"",age:"",height_cm:"",weight:"",neck_cm:"",waist_cm:"",hip_cm:"",experience_level:"",bench_1rm:"",squat_1rm:"",deadlift_1rm:"",goal:"",workouts_per_week:""},Nm=(e,t,n,r,l)=>!t||!n||!l||e==="female"&&!r?null:e==="male"?Math.max(0,495/(1.0324-.19077*Math.log10(t-n)+.15456*Math.log10(l))-450).toFixed(1):Math.max(0,495/(1.29579-.35004*Math.log10(t+r-n)+.221*Math.log10(l))-450).toFixed(1),Ce=e=>{if(e===""||e===null||e===void 0)return null;const t=Number(e);return Number.isNaN(t)?null:t};function jd(){const{token:e,updateProfile:t,refreshProfile:n}=pt(),r=Mr(),[l,s]=y.useState(Xa),[o,a]=y.useState([]),[u,d]=y.useState(0),[m,f]=y.useState([]),[v,w]=y.useState(""),[j,g]=y.useState(""),[x,p]=y.useState(!1),[c,h]=y.useState(!1),k=y.useRef(null),_=y.useRef(0),S=y.useRef(null),E=y.useMemo(()=>[{id:"name",field:"name",type:"text",prompt:"Hej! Jag är din coach. Vad heter du?",placeholder:"Ditt namn",inputType:"text"},{id:"goal",field:"goal",type:"options",prompt:N=>`Kul att träffas${N.name?` ${N.name}`:""}! Vad är ditt största mål?`,options:[{label:"Bygga muskler",value:"muscle"},{label:"Styrka",value:"strength"},{label:"Gå ner i vikt",value:"fat_loss"},{label:"Hälsa",value:"general"}]},{id:"experience_level",field:"experience_level",type:"options",prompt:"Hur länge har du tränat?",options:[{label:"Ny",value:"beginner"},{label:"< 1 år",value:"beginner"},{label:"1-3 år",value:"intermediate"},{label:"3+ år",value:"advanced"}]},{id:"workouts_per_week",field:"workouts_per_week",type:"options",prompt:"Hur många pass kan du köra per vecka?",options:[2,3,4,5,6].map(N=>({label:`${N}`,value:N}))},{id:"gender",field:"gender",type:"options",prompt:"Super! Vi tar några snabba basfrågor. Vilket kön identifierar du dig som?",options:[{label:"Man",value:"male"},{label:"Kvinna",value:"female"}]},{id:"age",field:"age",type:"text",prompt:"Hur gammal är du?",placeholder:"Ålder",inputType:"number",validate:N=>N>0&&N<120?"":"Skriv in en giltig ålder."},{id:"height_cm",field:"height_cm",type:"text",prompt:"Hur lång är du? (cm)",placeholder:"175",inputType:"number",unit:"cm",validate:N=>N>50&&N<260?"":"Skriv in din längd i cm."},{id:"weight",field:"weight",type:"text",prompt:"Vad väger du just nu? (kg)",placeholder:"75",inputType:"number",unit:"kg",validate:N=>N>20&&N<300?"":"Skriv in din vikt i kg."},{id:"neck_cm",field:"neck_cm",type:"text",prompt:"Om du vet: halsmått i cm?",placeholder:"38",inputType:"number",unit:"cm",optional:!0},{id:"waist_cm",field:"waist_cm",type:"text",prompt:"Midjemått i cm?",placeholder:"85",inputType:"number",unit:"cm",optional:!0},{id:"hip_cm",field:"hip_cm",type:"text",prompt:"Höftmått i cm?",placeholder:"95",inputType:"number",unit:"cm",optional:!0,shouldAsk:N=>N.gender==="female"},{id:"bench_1rm",field:"bench_1rm",type:"text",prompt:"Har du en uppskattad 1RM i bänkpress? (valfritt, kg)",placeholder:"100",inputType:"number",unit:"kg",optional:!0,shouldAsk:N=>N.experience_level&&N.experience_level!=="beginner"},{id:"squat_1rm",field:"squat_1rm",type:"text",prompt:"1RM i knäböj? (valfritt, kg)",placeholder:"140",inputType:"number",unit:"kg",optional:!0,shouldAsk:N=>N.experience_level&&N.experience_level!=="beginner"},{id:"deadlift_1rm",field:"deadlift_1rm",type:"text",prompt:"1RM i marklyft? (valfritt, kg)",placeholder:"160",inputType:"number",unit:"kg",optional:!0,shouldAsk:N=>N.experience_level&&N.experience_level!=="beginner"}],[]),C=E[u],P=N=>{_.current+=1,a(F=>[...F,{id:_.current,...N}])},M=()=>{k.current&&k.current.scrollIntoView({behavior:"smooth",block:"end"})};y.useEffect(()=>{M()},[o,x]);const D=(N,F)=>N?typeof N.prompt=="function"?N.prompt(F):N.prompt:"";y.useEffect(()=>(o.length===0&&C&&P({sender:"coach",text:D(C,l),questionIndex:u}),()=>{S.current&&clearTimeout(S.current)}),[o.length,C,u,l]);const X=(N,F,W)=>F.field?{...N,[F.field]:W}:N,K=N=>N.reduce((F,W)=>{const H=E[W.questionIndex];return H?X(F,H,W.value):F},{...Xa}),A=(N,F)=>{for(let W=N+1;W["weight","neck_cm","waist_cm","hip_cm"].includes(N),ht=N=>["bench_1rm","squat_1rm","deadlift_1rm"].includes(N),At=N=>["gender","age","height_cm","experience_level","goal","workouts_per_week"].includes(N),z=async(N,F=!1)=>{const W={gender:N.gender||null,age:Ce(N.age),height_cm:Ce(N.height_cm),experience_level:N.experience_level||null,goal:N.goal||null,workouts_per_week:Ce(N.workouts_per_week),onboarding_complete:F};await t(W)},O=async N=>{const F=Nm(N.gender,Ce(N.waist_cm),Ce(N.neck_cm),Ce(N.hip_cm),Ce(N.height_cm));!N.weight&&!N.neck_cm&&!N.waist_cm&&!N.hip_cm||await fetch(`${Ya}/user/measurements`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify({weight:Ce(N.weight),neck_cm:Ce(N.neck_cm),waist_cm:Ce(N.waist_cm),hip_cm:Ce(N.hip_cm),body_fat_pct:F})})},I=async N=>{!N.bench_1rm&&!N.squat_1rm&&!N.deadlift_1rm||await fetch(`${Ya}/user/strength`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify({bench_1rm:Ce(N.bench_1rm),squat_1rm:Ce(N.squat_1rm),deadlift_1rm:Ce(N.deadlift_1rm)})})},V=async(N,F,W)=>{if(At(N)&&await z(F,!1),me(N)){const H=W!==null?E[W]:null;(!H||!me(H.id))&&await O(F)}if(ht(N)){const H=W!==null?E[W]:null;(!H||!ht(H.id))&&await I(F)}},G=async(N,F=null)=>{if(!C)return;const W=F??`${N}`;g("");const H=X(l,C,N),T=A(u,H);P({sender:"user",text:W,questionIndex:u}),f($=>[...$,{questionIndex:u,value:N,label:W}]),s(H),w("");try{await V(C.id,H,T)}catch($){console.error("Autosave error:",$)}if(T===null){p(!0),S.current=setTimeout(async()=>{P({sender:"coach",text:"Perfekt! Jag har allt jag behöver. Låt mig bygga ditt program...",questionIndex:u+1}),p(!1),await Ze(H)},700);return}p(!0),S.current=setTimeout(()=>{P({sender:"coach",text:D(E[T],H),questionIndex:T}),d(T),p(!1)},600)},Ze=async N=>{h(!0);try{await z(N,!0),await O(N),await I(N),n&&await n(),r("/")}catch(F){console.error("Onboarding error:",F),h(!1)}},Ne=()=>{if(!C)return;const N=v.trim();if(!N&&!C.optional){g("Skriv ett svar för att gå vidare.");return}let F=N;if(C.inputType==="number"&&N){const H=Number(N);if(Number.isNaN(H)){g("Skriv ett giltigt nummer.");return}const T=C.validate?C.validate(H):"";if(T){g(T);return}F=H}if(!N&&C.optional){G("","Hoppar");return}const W=C.unit?`${N} ${C.unit}`:N;G(F,W)},mt=N=>{if(N.action==="back"){Ve();return}if(N.action==="skip"){G("","Hoppar");return}G(N.value,N.label)},Ve=()=>{if(!m.length)return;const F=m[m.length-1].questionIndex,W=[...o],H=W.map(($,de)=>$.sender==="coach"&&$.questionIndex===F?de:-1).filter($=>$!==-1).pop();H!==void 0&&W.splice(H+1);const T=m.slice(0,-1);f(T),a(W),d(F),s(K(T)),p(!1),w(""),g("")},vt=()=>{if(!C)return null;if(C.type==="options"){const F=[...C.options],W=[];return C.optional&&W.push({label:"Hoppa över",action:"skip",variant:"ghost"}),m.length&&W.push({label:"Ändra senaste",action:"back",variant:"ghost"}),i.jsx(i.Fragment,{children:i.jsx(Ga,{options:[...F,...W],onSelect:mt,disabled:x||c})})}const N=[];return C.optional&&N.push({label:"Hoppa över",action:"skip",variant:"ghost"}),m.length&&N.push({label:"Ändra senaste",action:"back",variant:"ghost"}),i.jsxs("div",{className:"chat-input-area",children:[i.jsxs("div",{className:"chat-input-row",children:[i.jsx("input",{type:C.inputType||"text",inputMode:C.inputType==="number"?"numeric":"text",placeholder:C.placeholder,value:v,onChange:F=>w(F.target.value),onKeyDown:F=>{F.key==="Enter"&&Ne()},disabled:x||c}),i.jsx("button",{type:"button",className:"send-btn",onClick:Ne,disabled:x||c,children:"Skicka"})]}),j&&i.jsx("div",{className:"chat-error",children:j}),i.jsx(Ga,{options:N,onSelect:mt,disabled:x||c})]})};return i.jsx("div",{className:"chat-onboarding",children:i.jsxs("div",{className:"chat-shell",children:[i.jsxs("header",{className:"chat-header",children:[i.jsxs("div",{children:[i.jsx("p",{className:"chat-subtitle",children:"Coach"}),i.jsx("h1",{children:"Personlig onboarding"})]}),i.jsx("span",{className:`chat-status ${c?"saving":""}`,children:c?"Sparar...":"Redo"})]}),i.jsxs("div",{className:"chat-messages",children:[o.map(N=>N.sender==="coach"?i.jsx(Ka,{text:N.text},N.id):i.jsx(Sm,{text:N.text},N.id)),x&&i.jsx(Ka,{typing:!0}),i.jsx("div",{ref:k})]}),i.jsx("div",{className:"chat-actions",children:vt()})]})})}const Hn="/api";function Cm(){const{user:e,logout:t}=pt(),[n,r]=y.useState("dashboard"),[l,s]=y.useState(null),[o,a]=y.useState(null),[u,d]=y.useState(1),[m,f]=y.useState({}),[v,w]=y.useState(!1),j=(e==null?void 0:e.id)||1,g=new Date().toISOString().split("T")[0];if(e&&!e.onboarding_complete)return i.jsx(jd,{});const x=async()=>{if(!l)try{const E=await(await fetch(`${Hn}/programs/1`)).json();s(E)}catch(S){console.error("Failed to fetch program:",S)}},p=async S=>{try{const E=l.days.find(P=>P.id===S);if(!E)return;const C={};for(const P of E.exercises){if(!P.id)continue;const D=await(await fetch(`${Hn}/logs?user_id=${j}&date=${g}&program_exercise_id=${P.id}`)).json();C[P.id]=D}f(C)}catch(E){console.error("Failed to fetch logs:",E)}},c=async S=>{try{return await(await fetch(`${Hn}/progression/${S}?user_id=${j}`)).json()}catch(E){return console.error("Failed to fetch progression:",E),null}},h=async(S,E,C,P,M)=>{try{const X=await(await fetch(`${Hn}/logs`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user_id:j,program_exercise_id:S,date:g,set_number:E,weight:parseFloat(C)||0,reps:parseInt(P)||0,completed:M})})).json();f(K=>({...K,[S]:[...(K[S]||[]).filter(A=>A.set_number!==E),X].sort((A,me)=>A.set_number-me.set_number)}))}catch(D){console.error("Failed to log set:",D)}},k=async(S,E)=>{try{await fetch(`${Hn}/logs`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({user_id:j,program_exercise_id:S,date:g,set_number:E})}),f(C=>({...C,[S]:(C[S]||[]).filter(P=>P.set_number!==E)}))}catch(C){console.error("Failed to delete log:",C)}},_=async S=>{await x(),a(S),r("workout"),p(S.id)};return n==="dashboard"?i.jsx(am,{onStartWorkout:_,onNavigate:r}):n==="profile"?i.jsx(fm,{onBack:()=>r("dashboard")}):n==="progress"?i.jsx(mm,{onBack:()=>r("dashboard")}):n==="select-workout"?i.jsx(jm,{onBack:()=>r("dashboard"),onSelectWorkout:_}):n==="workout"&&o?i.jsx(xm,{day:o,week:u,logs:m,onLogSet:h,onDeleteSet:k,onBack:()=>r("dashboard"),fetchProgression:c}):i.jsxs("div",{className:"app loading",children:[i.jsx("div",{className:"spinner"}),i.jsx("p",{children:"Laddar..."})]})}function _m(){const[e,t]=y.useState(""),[n,r]=y.useState(""),[l,s]=y.useState(""),[o,a]=y.useState(!1),{register:u}=pt(),d=Mr(),m=async f=>{f.preventDefault(),s(""),a(!0);try{await u(e,n),d("/onboarding")}catch(v){s(v.message)}a(!1)};return i.jsx("div",{className:"auth-page",children:i.jsxs("div",{className:"auth-card",children:[i.jsx(So,{}),i.jsx("h1",{className:"auth-title",children:"Skapa konto"}),i.jsx("p",{className:"auth-tagline",children:"Börja din träningsresa"}),l&&i.jsx("div",{className:"error auth-error",children:l}),i.jsxs("form",{onSubmit:m,children:[i.jsx("input",{type:"email",placeholder:"E-post",value:e,onChange:f=>t(f.target.value),required:!0}),i.jsx("input",{type:"password",placeholder:"Lösenord",value:n,onChange:f=>r(f.target.value),required:!0,minLength:6}),i.jsx("button",{type:"submit",disabled:o,children:o?"Skapar...":"Skapa konto"})]}),i.jsxs("p",{className:"auth-link",children:["Har redan konto? ",i.jsx(kd,{to:"/login",children:"Logga in"})]})]})})}function Em(){const[e,t]=y.useState(""),[n,r]=y.useState(""),[l,s]=y.useState(""),[o,a]=y.useState(!1),{login:u}=pt(),d=Mr(),m=async f=>{f.preventDefault(),s(""),a(!0);try{const{user:v}=await u(e,n);d(v.onboarding_complete?"/":"/onboarding")}catch(v){s(v.message)}a(!1)};return i.jsx("div",{className:"auth-page",children:i.jsxs("div",{className:"auth-card",children:[i.jsx(So,{}),i.jsx("h1",{className:"auth-title",children:"Logga in"}),i.jsx("p",{className:"auth-tagline",children:"Din personliga träningspartner"}),l&&i.jsx("div",{className:"error auth-error",children:l}),i.jsxs("form",{onSubmit:m,children:[i.jsx("input",{type:"email",placeholder:"E-post",value:e,onChange:f=>t(f.target.value),required:!0}),i.jsx("input",{type:"password",placeholder:"Lösenord",value:n,onChange:f=>r(f.target.value),required:!0}),i.jsx("button",{type:"submit",disabled:o,children:o?"Loggar in...":"Logga in"})]}),i.jsxs("p",{className:"auth-link",children:["Inget konto? ",i.jsx(kd,{to:"/register",children:"Skapa konto"})]})]})})}function Ja({children:e,requireOnboarding:t=!0}){const{user:n,loading:r}=pt();return r?i.jsx("div",{className:"app loading",children:i.jsx("div",{className:"spinner"})}):n?t&&!n.onboarding_complete?i.jsx(Ol,{to:"/onboarding"}):e:i.jsx(Ol,{to:"/login"})}function Za({children:e}){const{user:t,loading:n}=pt();return n?i.jsx("div",{className:"app loading",children:i.jsx("div",{className:"spinner"})}):t!=null&&t.onboarding_complete?i.jsx(Ol,{to:"/"}):t?i.jsx(Ol,{to:"/onboarding"}):e}Es.createRoot(document.getElementById("root")).render(i.jsx(au.StrictMode,{children:i.jsx(Zh,{children:i.jsx(tm,{children:i.jsxs(Hh,{children:[i.jsx(Xn,{path:"/register",element:i.jsx(Za,{children:i.jsx(_m,{})})}),i.jsx(Xn,{path:"/login",element:i.jsx(Za,{children:i.jsx(Em,{})})}),i.jsx(Xn,{path:"/onboarding",element:i.jsx(Ja,{requireOnboarding:!1,children:i.jsx(jd,{})})}),i.jsx(Xn,{path:"/*",element:i.jsx(Ja,{children:i.jsx(Cm,{})})})]})})})}));