import{r as Mg,a as Eg,b as N,u as Ds,L as K0,R as Tg,c as nl,N as Os,O as ws,d as ks,B as Ag}from"./vendor-BI0H_s0W.js";import{s as Us,e as Hs,a as Ba,b as Un,c as J0,i as W0,d as ui,f as Oe,p as tt,g as _l,h as $0,j as F0,k as ai,l as I0,m as P0,n as Cg,o as _g,q as Dg}from"./date-huy51PAD.js";(function(){const j=document.createElement("link").relList;if(j&&j.supports&&j.supports("modulepreload"))return;for(const M of document.querySelectorAll('link[rel="modulepreload"]'))r(M);new MutationObserver(M=>{for(const _ of M)if(_.type==="childList")for(const H of _.addedNodes)H.tagName==="LINK"&&H.rel==="modulepreload"&&r(H)}).observe(document,{childList:!0,subtree:!0});function O(M){const _={};return M.integrity&&(_.integrity=M.integrity),M.referrerPolicy&&(_.referrerPolicy=M.referrerPolicy),M.crossOrigin==="use-credentials"?_.credentials="include":M.crossOrigin==="anonymous"?_.credentials="omit":_.credentials="same-origin",_}function r(M){if(M.ep)return;M.ep=!0;const _=O(M);fetch(M.href,_)}})();var zs={exports:{}},On={};/** * @license React * react-jsx-runtime.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var q0;function Og(){if(q0)return On;q0=1;var f=Symbol.for("react.transitional.element"),j=Symbol.for("react.fragment");function O(r,M,_){var H=null;if(_!==void 0&&(H=""+_),M.key!==void 0&&(H=""+M.key),"key"in M){_={};for(var Y in M)Y!=="key"&&(_[Y]=M[Y])}else _=M;return M=_.ref,{$$typeof:f,type:r,key:H,ref:M!==void 0?M:null,props:_}}return On.Fragment=j,On.jsx=O,On.jsxs=O,On}var Y0;function wg(){return Y0||(Y0=1,zs.exports=Og()),zs.exports}var i=wg(),Ms={exports:{}},wn={},Es={exports:{}},Ts={};/** * @license React * scheduler.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var L0;function Ug(){return L0||(L0=1,(function(f){function j(b,C){var Q=b.length;b.push(C);e:for(;0>>1,ie=b[se];if(0>>1;seM(z,Q))EM(me,z)?(b[se]=me,b[E]=Q,se=E):(b[se]=z,b[te]=Q,se=te);else if(EM(me,Q))b[se]=me,b[E]=Q,se=E;else break e}}return C}function M(b,C){var Q=b.sortIndex-C.sortIndex;return Q!==0?Q:b.id-C.id}if(f.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var _=performance;f.unstable_now=function(){return _.now()}}else{var H=Date,Y=H.now();f.unstable_now=function(){return H.now()-Y}}var R=[],B=[],Z=1,A=null,k=3,D=!1,w=!1,T=!1,U=!1,J=typeof setTimeout=="function"?setTimeout:null,P=typeof clearTimeout=="function"?clearTimeout:null,ee=typeof setImmediate<"u"?setImmediate:null;function $(b){for(var C=O(B);C!==null;){if(C.callback===null)r(B);else if(C.startTime<=b)r(B),C.sortIndex=C.expirationTime,j(R,C);else break;C=O(B)}}function xe(b){if(T=!1,$(b),!w)if(O(R)!==null)w=!0,ge||(ge=!0,ke());else{var C=O(B);C!==null&&Re(xe,C.startTime-b)}}var ge=!1,Ne=-1,Te=5,W=-1;function Ae(){return U?!0:!(f.unstable_now()-Wb&&Ae());){var se=A.callback;if(typeof se=="function"){A.callback=null,k=A.priorityLevel;var ie=se(A.expirationTime<=b);if(b=f.unstable_now(),typeof ie=="function"){A.callback=ie,$(b),C=!0;break t}A===O(R)&&r(R),$(b)}else r(R);A=O(R)}if(A!==null)C=!0;else{var G=O(B);G!==null&&Re(xe,G.startTime-b),C=!1}}break e}finally{A=null,k=Q,D=!1}C=void 0}}finally{C?ke():ge=!1}}}var ke;if(typeof ee=="function")ke=function(){ee(He)};else if(typeof MessageChannel<"u"){var Qe=new MessageChannel,Ve=Qe.port2;Qe.port1.onmessage=He,ke=function(){Ve.postMessage(null)}}else ke=function(){J(He,0)};function Re(b,C){Ne=J(function(){b(f.unstable_now())},C)}f.unstable_IdlePriority=5,f.unstable_ImmediatePriority=1,f.unstable_LowPriority=4,f.unstable_NormalPriority=3,f.unstable_Profiling=null,f.unstable_UserBlockingPriority=2,f.unstable_cancelCallback=function(b){b.callback=null},f.unstable_forceFrameRate=function(b){0>b||125se?(b.sortIndex=Q,j(B,b),O(R)===null&&b===O(B)&&(T?(P(Ne),Ne=-1):T=!0,Re(xe,Q-se))):(b.sortIndex=ie,j(R,b),w||D||(w=!0,ge||(ge=!0,ke()))),b},f.unstable_shouldYield=Ae,f.unstable_wrapCallback=function(b){var C=k;return function(){var Q=k;k=C;try{return b.apply(this,arguments)}finally{k=Q}}}})(Ts)),Ts}var R0;function Hg(){return R0||(R0=1,Es.exports=Ug()),Es.exports}/** * @license React * react-dom-client.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var G0;function Bg(){if(G0)return wn;G0=1;var f=Hg(),j=Mg(),O=Eg();function r(e){var t="https://react.dev/errors/"+e;if(1ie||(e.current=se[ie],se[ie]=null,ie--)}function z(e,t){ie++,se[ie]=e.current,e.current=t}var E=G(null),me=G(null),Ke=G(null),ul=G(null);function qt(e,t){switch(z(Ke,t),z(me,e),z(E,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?c0(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=c0(t),e=s0(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}te(E),z(E,e)}function Ct(){te(E),te(me),te(Ke)}function V(e){e.memoizedState!==null&&z(ul,e);var t=E.current,l=s0(t,e.type);t!==l&&(z(me,e),z(E,l))}function ze(e){me.current===e&&(te(E),te(me)),ul.current===e&&(te(ul),An._currentValue=Q)}var Pe,Yt;function lt(e){if(Pe===void 0)try{throw Error()}catch(l){var t=l.stack.trim().match(/\n( *(at )?)/);Pe=t&&t[1]||"",Yt=-1)":-1n||d[a]!==h[n]){var v=` `+d[a].replace(" at new "," at ");return e.displayName&&v.includes("")&&(v=v.replace("",e.displayName)),v}while(1<=a&&0<=n);break}}}finally{ci=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?lt(l):""}function lo(e,t){switch(e.tag){case 26:case 27:case 5:return lt(e.type);case 16:return lt("Lazy");case 13:return e.child!==t&&t!==null?lt("Suspense Fallback"):lt("Suspense");case 19:return lt("SuspenseList");case 0:case 15:return si(e.type,!1);case 11:return si(e.type.render,!1);case 1:return si(e.type,!0);case 31:return lt("Activity");default:return""}}function Bs(e){try{var t="",l=null;do t+=lo(e,l),l=e,e=e.return;while(e);return t}catch(a){return` Error generating stack: `+a.message+` `+a.stack}}var ri=Object.prototype.hasOwnProperty,fi=f.unstable_scheduleCallback,di=f.unstable_cancelCallback,ao=f.unstable_shouldYield,no=f.unstable_requestPaint,ft=f.unstable_now,uo=f.unstable_getCurrentPriorityLevel,qs=f.unstable_ImmediatePriority,Ys=f.unstable_UserBlockingPriority,Bn=f.unstable_NormalPriority,io=f.unstable_LowPriority,Ls=f.unstable_IdlePriority,co=f.log,so=f.unstable_setDisableYieldValue,La=null,dt=null;function il(e){if(typeof co=="function"&&so(e),dt&&typeof dt.setStrictMode=="function")try{dt.setStrictMode(La,e)}catch{}}var ot=Math.clz32?Math.clz32:oo,ro=Math.log,fo=Math.LN2;function oo(e){return e>>>=0,e===0?32:31-(ro(e)/fo|0)|0}var qn=256,Yn=262144,Ln=4194304;function Ol(e){var t=e&42;if(t!==0)return t;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:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Rn(e,t,l){var a=e.pendingLanes;if(a===0)return 0;var n=0,u=e.suspendedLanes,c=e.pingedLanes;e=e.warmLanes;var s=a&134217727;return s!==0?(a=s&~u,a!==0?n=Ol(a):(c&=s,c!==0?n=Ol(c):l||(l=s&~e,l!==0&&(n=Ol(l))))):(s=a&~u,s!==0?n=Ol(s):c!==0?n=Ol(c):l||(l=a&~e,l!==0&&(n=Ol(l)))),n===0?0:t!==0&&t!==n&&(t&u)===0&&(u=n&-n,l=t&-t,u>=l||u===32&&(l&4194048)!==0)?t:n}function Ra(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function mo(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32: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 t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Rs(){var e=Ln;return Ln<<=1,(Ln&62914560)===0&&(Ln=4194304),e}function oi(e){for(var t=[],l=0;31>l;l++)t.push(e);return t}function Ga(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function go(e,t,l,a,n,u){var c=e.pendingLanes;e.pendingLanes=l,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=l,e.entangledLanes&=l,e.errorRecoveryDisabledLanes&=l,e.shellSuspendCounter=0;var s=e.entanglements,d=e.expirationTimes,h=e.hiddenUpdates;for(l=c&~l;0"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var po=/[\n"\\]/g;function St(e){return e.replace(po,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function bi(e,t,l,a,n,u,c,s){e.name="",c!=null&&typeof c!="function"&&typeof c!="symbol"&&typeof c!="boolean"?e.type=c:e.removeAttribute("type"),t!=null?c==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+pt(t)):e.value!==""+pt(t)&&(e.value=""+pt(t)):c!=="submit"&&c!=="reset"||e.removeAttribute("value"),t!=null?vi(e,c,pt(t)):l!=null?vi(e,c,pt(l)):a!=null&&e.removeAttribute("value"),n==null&&u!=null&&(e.defaultChecked=!!u),n!=null&&(e.checked=n&&typeof n!="function"&&typeof n!="symbol"),s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"?e.name=""+pt(s):e.removeAttribute("name")}function er(e,t,l,a,n,u,c,s){if(u!=null&&typeof u!="function"&&typeof u!="symbol"&&typeof u!="boolean"&&(e.type=u),t!=null||l!=null){if(!(u!=="submit"&&u!=="reset"||t!=null)){xi(e);return}l=l!=null?""+pt(l):"",t=t!=null?""+pt(t):l,s||t===e.value||(e.value=t),e.defaultValue=t}a=a??n,a=typeof a!="function"&&typeof a!="symbol"&&!!a,e.checked=s?e.checked:!!a,e.defaultChecked=!!a,c!=null&&typeof c!="function"&&typeof c!="symbol"&&typeof c!="boolean"&&(e.name=c),xi(e)}function vi(e,t,l){t==="number"&&Xn(e.ownerDocument)===e||e.defaultValue===""+l||(e.defaultValue=""+l)}function aa(e,t,l,a){if(e=e.options,t){t={};for(var n=0;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ki=!1;if(Gt)try{var Va={};Object.defineProperty(Va,"passive",{get:function(){ki=!0}}),window.addEventListener("test",Va,Va),window.removeEventListener("test",Va,Va)}catch{ki=!1}var sl=null,zi=null,Vn=null;function cr(){if(Vn)return Vn;var e,t=zi,l=t.length,a,n="value"in sl?sl.value:sl.textContent,u=n.length;for(e=0;e=Wa),mr=" ",gr=!1;function hr(e,t){switch(e){case"keyup":return Jo.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function yr(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ca=!1;function $o(e,t){switch(e){case"compositionend":return yr(t);case"keypress":return t.which!==32?null:(gr=!0,mr);case"textInput":return e=t.data,e===mr&&gr?null:e;default:return null}}function Fo(e,t){if(ca)return e==="compositionend"||!Ci&&hr(e,t)?(e=cr(),Vn=zi=sl=null,ca=!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:l,offset:t-e};e=a}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=kr(l)}}function Mr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Mr(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Er(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Xn(e.document);t instanceof e.HTMLIFrameElement;){try{var l=typeof t.contentWindow.location.href=="string"}catch{l=!1}if(l)e=t.contentWindow;else break;t=Xn(e.document)}return t}function Oi(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")}var um=Gt&&"documentMode"in document&&11>=document.documentMode,sa=null,wi=null,Pa=null,Ui=!1;function Tr(e,t,l){var a=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Ui||sa==null||sa!==Xn(a)||(a=sa,"selectionStart"in a&&Oi(a)?a={start:a.selectionStart,end:a.selectionEnd}:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection(),a={anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),Pa&&Ia(Pa,a)||(Pa=a,a=Yu(wi,"onSelect"),0>=c,n-=c,wt=1<<32-ot(t)+n|l<I?(ue=L,L=null):ue=L.sibling;var de=y(m,L,g[I],p);if(de===null){L===null&&(L=ue);break}e&&L&&de.alternate===null&&t(m,L),o=u(de,o,I),fe===null?X=de:fe.sibling=de,fe=de,L=ue}if(I===g.length)return l(m,L),ce&&Xt(m,I),X;if(L===null){for(;II?(ue=L,L=null):ue=L.sibling;var Cl=y(m,L,de.value,p);if(Cl===null){L===null&&(L=ue);break}e&&L&&Cl.alternate===null&&t(m,L),o=u(Cl,o,I),fe===null?X=Cl:fe.sibling=Cl,fe=Cl,L=ue}if(de.done)return l(m,L),ce&&Xt(m,I),X;if(L===null){for(;!de.done;I++,de=g.next())de=S(m,de.value,p),de!==null&&(o=u(de,o,I),fe===null?X=de:fe.sibling=de,fe=de);return ce&&Xt(m,I),X}for(L=a(L);!de.done;I++,de=g.next())de=x(L,m,I,de.value,p),de!==null&&(e&&de.alternate!==null&&L.delete(de.key===null?I:de.key),o=u(de,o,I),fe===null?X=de:fe.sibling=de,fe=de);return e&&L.forEach(function(zg){return t(m,zg)}),ce&&Xt(m,I),X}function pe(m,o,g,p){if(typeof g=="object"&&g!==null&&g.type===T&&g.key===null&&(g=g.props.children),typeof g=="object"&&g!==null){switch(g.$$typeof){case D:e:{for(var X=g.key;o!==null;){if(o.key===X){if(X=g.type,X===T){if(o.tag===7){l(m,o.sibling),p=n(o,g.props.children),p.return=m,m=p;break e}}else if(o.elementType===X||typeof X=="object"&&X!==null&&X.$$typeof===Te&&Xl(X)===o.type){l(m,o.sibling),p=n(o,g.props),un(p,g),p.return=m,m=p;break e}l(m,o);break}else t(m,o);o=o.sibling}g.type===T?(p=Yl(g.props.children,m.mode,p,g.key),p.return=m,m=p):(p=lu(g.type,g.key,g.props,null,m.mode,p),un(p,g),p.return=m,m=p)}return c(m);case w:e:{for(X=g.key;o!==null;){if(o.key===X)if(o.tag===4&&o.stateNode.containerInfo===g.containerInfo&&o.stateNode.implementation===g.implementation){l(m,o.sibling),p=n(o,g.children||[]),p.return=m,m=p;break e}else{l(m,o);break}else t(m,o);o=o.sibling}p=Gi(g,m.mode,p),p.return=m,m=p}return c(m);case Te:return g=Xl(g),pe(m,o,g,p)}if(Re(g))return q(m,o,g,p);if(ke(g)){if(X=ke(g),typeof X!="function")throw Error(r(150));return g=X.call(g),K(m,o,g,p)}if(typeof g.then=="function")return pe(m,o,ru(g),p);if(g.$$typeof===ee)return pe(m,o,uu(m,g),p);fu(m,g)}return typeof g=="string"&&g!==""||typeof g=="number"||typeof g=="bigint"?(g=""+g,o!==null&&o.tag===6?(l(m,o.sibling),p=n(o,g),p.return=m,m=p):(l(m,o),p=Ri(g,m.mode,p),p.return=m,m=p),c(m)):l(m,o)}return function(m,o,g,p){try{nn=0;var X=pe(m,o,g,p);return va=null,X}catch(L){if(L===ba||L===cu)throw L;var fe=gt(29,L,null,m.mode);return fe.lanes=p,fe.return=m,fe}finally{}}}var Vl=Fr(!0),Ir=Fr(!1),ml=!1;function ec(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function tc(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function gl(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function hl(e,t,l){var a=e.updateQueue;if(a===null)return null;if(a=a.shared,(oe&2)!==0){var n=a.pending;return n===null?t.next=t:(t.next=n.next,n.next=t),a.pending=t,t=tu(e),Ur(e,null,l),t}return eu(e,a,t,l),tu(e)}function cn(e,t,l){if(t=t.updateQueue,t!==null&&(t=t.shared,(l&4194048)!==0)){var a=t.lanes;a&=e.pendingLanes,l|=a,t.lanes=l,Qs(e,l)}}function lc(e,t){var l=e.updateQueue,a=e.alternate;if(a!==null&&(a=a.updateQueue,l===a)){var n=null,u=null;if(l=l.firstBaseUpdate,l!==null){do{var c={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};u===null?n=u=c:u=u.next=c,l=l.next}while(l!==null);u===null?n=u=t:u=u.next=t}else n=u=t;l={baseState:a.baseState,firstBaseUpdate:n,lastBaseUpdate:u,shared:a.shared,callbacks:a.callbacks},e.updateQueue=l;return}e=l.lastBaseUpdate,e===null?l.firstBaseUpdate=t:e.next=t,l.lastBaseUpdate=t}var ac=!1;function sn(){if(ac){var e=xa;if(e!==null)throw e}}function rn(e,t,l,a){ac=!1;var n=e.updateQueue;ml=!1;var u=n.firstBaseUpdate,c=n.lastBaseUpdate,s=n.shared.pending;if(s!==null){n.shared.pending=null;var d=s,h=d.next;d.next=null,c===null?u=h:c.next=h,c=d;var v=e.alternate;v!==null&&(v=v.updateQueue,s=v.lastBaseUpdate,s!==c&&(s===null?v.firstBaseUpdate=h:s.next=h,v.lastBaseUpdate=d))}if(u!==null){var S=n.baseState;c=0,v=h=d=null,s=u;do{var y=s.lane&-536870913,x=y!==s.lane;if(x?(ne&y)===y:(a&y)===y){y!==0&&y===ya&&(ac=!0),v!==null&&(v=v.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});e:{var q=e,K=s;y=t;var pe=l;switch(K.tag){case 1:if(q=K.payload,typeof q=="function"){S=q.call(pe,S,y);break e}S=q;break e;case 3:q.flags=q.flags&-65537|128;case 0:if(q=K.payload,y=typeof q=="function"?q.call(pe,S,y):q,y==null)break e;S=A({},S,y);break e;case 2:ml=!0}}y=s.callback,y!==null&&(e.flags|=64,x&&(e.flags|=8192),x=n.callbacks,x===null?n.callbacks=[y]:x.push(y))}else x={lane:y,tag:s.tag,payload:s.payload,callback:s.callback,next:null},v===null?(h=v=x,d=S):v=v.next=x,c|=y;if(s=s.next,s===null){if(s=n.shared.pending,s===null)break;x=s,s=x.next,x.next=null,n.lastBaseUpdate=x,n.shared.pending=null}}while(!0);v===null&&(d=S),n.baseState=d,n.firstBaseUpdate=h,n.lastBaseUpdate=v,u===null&&(n.shared.lanes=0),pl|=c,e.lanes=c,e.memoizedState=S}}function Pr(e,t){if(typeof e!="function")throw Error(r(191,e));e.call(t)}function ef(e,t){var l=e.callbacks;if(l!==null)for(e.callbacks=null,e=0;eu?u:8;var c=b.T,s={};b.T=s,jc(e,!1,t,l);try{var d=n(),h=b.S;if(h!==null&&h(s,d),d!==null&&typeof d=="object"&&typeof d.then=="function"){var v=gm(d,a);on(e,t,v,vt(e))}else on(e,t,a,vt(e))}catch(S){on(e,t,{then:function(){},status:"rejected",reason:S},vt())}finally{C.p=u,c!==null&&s.types!==null&&(c.types=s.types),b.T=c}}function pm(){}function pc(e,t,l,a){if(e.tag!==5)throw Error(r(476));var n=Of(e).queue;Df(e,n,t,Q,l===null?pm:function(){return wf(e),l(a)})}function Of(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:Q,baseState:Q,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Jt,lastRenderedState:Q},next:null};var l={};return t.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Jt,lastRenderedState:l},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function wf(e){var t=Of(e);t.next===null&&(t=e.alternate.memoizedState),on(e,t.next.queue,{},vt())}function Sc(){return $e(An)}function Uf(){return Ue().memoizedState}function Hf(){return Ue().memoizedState}function Sm(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var l=vt();e=gl(l);var a=hl(t,e,l);a!==null&&(rt(a,t,l),cn(a,t,l)),t={cache:$i()},e.payload=t;return}t=t.return}}function jm(e,t,l){var a=vt();l={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},pu(e)?qf(t,l):(l=Yi(e,t,l,a),l!==null&&(rt(l,e,a),Yf(l,t,a)))}function Bf(e,t,l){var a=vt();on(e,t,l,a)}function on(e,t,l,a){var n={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(pu(e))qf(t,n);else{var u=e.alternate;if(e.lanes===0&&(u===null||u.lanes===0)&&(u=t.lastRenderedReducer,u!==null))try{var c=t.lastRenderedState,s=u(c,l);if(n.hasEagerState=!0,n.eagerState=s,mt(s,c))return eu(e,t,n,0),je===null&&Pn(),!1}catch{}finally{}if(l=Yi(e,t,n,a),l!==null)return rt(l,e,a),Yf(l,t,a),!0}return!1}function jc(e,t,l,a){if(a={lane:2,revertLane:es(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},pu(e)){if(t)throw Error(r(479))}else t=Yi(e,l,a,2),t!==null&&rt(t,e,2)}function pu(e){var t=e.alternate;return e===F||t!==null&&t===F}function qf(e,t){Sa=mu=!0;var l=e.pending;l===null?t.next=t:(t.next=l.next,l.next=t),e.pending=t}function Yf(e,t,l){if((l&4194048)!==0){var a=t.lanes;a&=e.pendingLanes,l|=a,t.lanes=l,Qs(e,l)}}var mn={readContext:$e,use:yu,useCallback:_e,useContext:_e,useEffect:_e,useImperativeHandle:_e,useLayoutEffect:_e,useInsertionEffect:_e,useMemo:_e,useReducer:_e,useRef:_e,useState:_e,useDebugValue:_e,useDeferredValue:_e,useTransition:_e,useSyncExternalStore:_e,useId:_e,useHostTransitionStatus:_e,useFormState:_e,useActionState:_e,useOptimistic:_e,useMemoCache:_e,useCacheRefresh:_e};mn.useEffectEvent=_e;var Lf={readContext:$e,use:yu,useCallback:function(e,t){return et().memoizedState=[e,t===void 0?null:t],e},useContext:$e,useEffect:Nf,useImperativeHandle:function(e,t,l){l=l!=null?l.concat([e]):null,bu(4194308,4,Ef.bind(null,t,e),l)},useLayoutEffect:function(e,t){return bu(4194308,4,e,t)},useInsertionEffect:function(e,t){bu(4,2,e,t)},useMemo:function(e,t){var l=et();t=t===void 0?null:t;var a=e();if(Kl){il(!0);try{e()}finally{il(!1)}}return l.memoizedState=[a,t],a},useReducer:function(e,t,l){var a=et();if(l!==void 0){var n=l(t);if(Kl){il(!0);try{l(t)}finally{il(!1)}}}else n=t;return a.memoizedState=a.baseState=n,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},a.queue=e,e=e.dispatch=jm.bind(null,F,e),[a.memoizedState,e]},useRef:function(e){var t=et();return e={current:e},t.memoizedState=e},useState:function(e){e=hc(e);var t=e.queue,l=Bf.bind(null,F,t);return t.dispatch=l,[e.memoizedState,l]},useDebugValue:bc,useDeferredValue:function(e,t){var l=et();return vc(l,e,t)},useTransition:function(){var e=hc(!1);return e=Df.bind(null,F,e.queue,!0,!1),et().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,l){var a=F,n=et();if(ce){if(l===void 0)throw Error(r(407));l=l()}else{if(l=t(),je===null)throw Error(r(349));(ne&127)!==0||cf(a,t,l)}n.memoizedState=l;var u={value:l,getSnapshot:t};return n.queue=u,Nf(rf.bind(null,a,u,e),[e]),a.flags|=2048,Na(9,{destroy:void 0},sf.bind(null,a,u,l,t),null),l},useId:function(){var e=et(),t=je.identifierPrefix;if(ce){var l=Ut,a=wt;l=(a&~(1<<32-ot(a)-1)).toString(32)+l,t="_"+t+"R_"+l,l=gu++,0<\/script>",u=u.removeChild(u.firstChild);break;case"select":u=typeof a.is=="string"?c.createElement("select",{is:a.is}):c.createElement("select"),a.multiple?u.multiple=!0:a.size&&(u.size=a.size);break;default:u=typeof a.is=="string"?c.createElement(n,{is:a.is}):c.createElement(n)}}u[Je]=t,u[at]=a;e:for(c=t.child;c!==null;){if(c.tag===5||c.tag===6)u.appendChild(c.stateNode);else if(c.tag!==4&&c.tag!==27&&c.child!==null){c.child.return=c,c=c.child;continue}if(c===t)break e;for(;c.sibling===null;){if(c.return===null||c.return===t)break e;c=c.return}c.sibling.return=c.return,c=c.sibling}t.stateNode=u;e:switch(Ie(u,n,a),n){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break e;case"img":a=!0;break e;default:a=!1}a&&$t(t)}}return Ee(t),Hc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,l),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==a&&$t(t);else{if(typeof a!="string"&&t.stateNode===null)throw Error(r(166));if(e=Ke.current,ga(t)){if(e=t.stateNode,l=t.memoizedProps,a=null,n=We,n!==null)switch(n.tag){case 27:case 5:a=n.memoizedProps}e[Je]=t,e=!!(e.nodeValue===l||a!==null&&a.suppressHydrationWarning===!0||u0(e.nodeValue,l)),e||dl(t,!0)}else e=Lu(e).createTextNode(a),e[Je]=t,t.stateNode=e}return Ee(t),null;case 31:if(l=t.memoizedState,e===null||e.memoizedState!==null){if(a=ga(t),l!==null){if(e===null){if(!a)throw Error(r(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(r(557));e[Je]=t}else Ll(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Ee(t),e=!1}else l=Vi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=l),e=!0;if(!e)return t.flags&256?(yt(t),t):(yt(t),null);if((t.flags&128)!==0)throw Error(r(558))}return Ee(t),null;case 13:if(a=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(n=ga(t),a!==null&&a.dehydrated!==null){if(e===null){if(!n)throw Error(r(318));if(n=t.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(r(317));n[Je]=t}else Ll(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Ee(t),n=!1}else n=Vi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),n=!0;if(!n)return t.flags&256?(yt(t),t):(yt(t),null)}return yt(t),(t.flags&128)!==0?(t.lanes=l,t):(l=a!==null,e=e!==null&&e.memoizedState!==null,l&&(a=t.child,n=null,a.alternate!==null&&a.alternate.memoizedState!==null&&a.alternate.memoizedState.cachePool!==null&&(n=a.alternate.memoizedState.cachePool.pool),u=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(u=a.memoizedState.cachePool.pool),u!==n&&(a.flags|=2048)),l!==e&&l&&(t.child.flags|=8192),zu(t,t.updateQueue),Ee(t),null);case 4:return Ct(),e===null&&ns(t.stateNode.containerInfo),Ee(t),null;case 10:return Vt(t.type),Ee(t),null;case 19:if(te(we),a=t.memoizedState,a===null)return Ee(t),null;if(n=(t.flags&128)!==0,u=a.rendering,u===null)if(n)hn(a,!1);else{if(De!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(u=ou(e),u!==null){for(t.flags|=128,hn(a,!1),e=u.updateQueue,t.updateQueue=e,zu(t,e),t.subtreeFlags=0,e=l,l=t.child;l!==null;)Hr(l,e),l=l.sibling;return z(we,we.current&1|2),ce&&Xt(t,a.treeForkCount),t.child}e=e.sibling}a.tail!==null&&ft()>Cu&&(t.flags|=128,n=!0,hn(a,!1),t.lanes=4194304)}else{if(!n)if(e=ou(u),e!==null){if(t.flags|=128,n=!0,e=e.updateQueue,t.updateQueue=e,zu(t,e),hn(a,!0),a.tail===null&&a.tailMode==="hidden"&&!u.alternate&&!ce)return Ee(t),null}else 2*ft()-a.renderingStartTime>Cu&&l!==536870912&&(t.flags|=128,n=!0,hn(a,!1),t.lanes=4194304);a.isBackwards?(u.sibling=t.child,t.child=u):(e=a.last,e!==null?e.sibling=u:t.child=u,a.last=u)}return a.tail!==null?(e=a.tail,a.rendering=e,a.tail=e.sibling,a.renderingStartTime=ft(),e.sibling=null,l=we.current,z(we,n?l&1|2:l&1),ce&&Xt(t,a.treeForkCount),e):(Ee(t),null);case 22:case 23:return yt(t),uc(),a=t.memoizedState!==null,e!==null?e.memoizedState!==null!==a&&(t.flags|=8192):a&&(t.flags|=8192),a?(l&536870912)!==0&&(t.flags&128)===0&&(Ee(t),t.subtreeFlags&6&&(t.flags|=8192)):Ee(t),l=t.updateQueue,l!==null&&zu(t,l.retryQueue),l=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),a=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(a=t.memoizedState.cachePool.pool),a!==l&&(t.flags|=2048),e!==null&&te(Ql),null;case 24:return l=null,e!==null&&(l=e.memoizedState.cache),t.memoizedState.cache!==l&&(t.flags|=2048),Vt(Be),Ee(t),null;case 25:return null;case 30:return null}throw Error(r(156,t.tag))}function Em(e,t){switch(Xi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Vt(Be),Ct(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ze(t),null;case 31:if(t.memoizedState!==null){if(yt(t),t.alternate===null)throw Error(r(340));Ll()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(yt(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));Ll()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return te(we),null;case 4:return Ct(),null;case 10:return Vt(t.type),null;case 22:case 23:return yt(t),uc(),e!==null&&te(Ql),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Vt(Be),null;case 25:return null;default:return null}}function fd(e,t){switch(Xi(t),t.tag){case 3:Vt(Be),Ct();break;case 26:case 27:case 5:ze(t);break;case 4:Ct();break;case 31:t.memoizedState!==null&&yt(t);break;case 13:yt(t);break;case 19:te(we);break;case 10:Vt(t.type);break;case 22:case 23:yt(t),uc(),e!==null&&te(Ql);break;case 24:Vt(Be)}}function yn(e,t){try{var l=t.updateQueue,a=l!==null?l.lastEffect:null;if(a!==null){var n=a.next;l=n;do{if((l.tag&e)===e){a=void 0;var u=l.create,c=l.inst;a=u(),c.destroy=a}l=l.next}while(l!==n)}}catch(s){ye(t,t.return,s)}}function bl(e,t,l){try{var a=t.updateQueue,n=a!==null?a.lastEffect:null;if(n!==null){var u=n.next;a=u;do{if((a.tag&e)===e){var c=a.inst,s=c.destroy;if(s!==void 0){c.destroy=void 0,n=t;var d=l,h=s;try{h()}catch(v){ye(n,d,v)}}}a=a.next}while(a!==u)}}catch(v){ye(t,t.return,v)}}function dd(e){var t=e.updateQueue;if(t!==null){var l=e.stateNode;try{ef(t,l)}catch(a){ye(e,e.return,a)}}}function od(e,t,l){l.props=Jl(e.type,e.memoizedProps),l.state=e.memoizedState;try{l.componentWillUnmount()}catch(a){ye(e,t,a)}}function xn(e,t){try{var l=e.ref;if(l!==null){switch(e.tag){case 26:case 27:case 5:var a=e.stateNode;break;case 30:a=e.stateNode;break;default:a=e.stateNode}typeof l=="function"?e.refCleanup=l(a):l.current=a}}catch(n){ye(e,t,n)}}function Ht(e,t){var l=e.ref,a=e.refCleanup;if(l!==null)if(typeof a=="function")try{a()}catch(n){ye(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(n){ye(e,t,n)}else l.current=null}function md(e){var t=e.type,l=e.memoizedProps,a=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":l.autoFocus&&a.focus();break e;case"img":l.src?a.src=l.src:l.srcSet&&(a.srcset=l.srcSet)}}catch(n){ye(e,e.return,n)}}function Bc(e,t,l){try{var a=e.stateNode;Wm(a,e.type,l,t),a[at]=t}catch(n){ye(e,e.return,n)}}function gd(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&zl(e.type)||e.tag===4}function qc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||gd(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.tag===27&&zl(e.type)||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 Yc(e,t,l){var a=e.tag;if(a===5||a===6)e=e.stateNode,t?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(e,t):(t=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,t.appendChild(e),l=l._reactRootContainer,l!=null||t.onclick!==null||(t.onclick=Rt));else if(a!==4&&(a===27&&zl(e.type)&&(l=e.stateNode,t=null),e=e.child,e!==null))for(Yc(e,t,l),e=e.sibling;e!==null;)Yc(e,t,l),e=e.sibling}function Mu(e,t,l){var a=e.tag;if(a===5||a===6)e=e.stateNode,t?l.insertBefore(e,t):l.appendChild(e);else if(a!==4&&(a===27&&zl(e.type)&&(l=e.stateNode),e=e.child,e!==null))for(Mu(e,t,l),e=e.sibling;e!==null;)Mu(e,t,l),e=e.sibling}function hd(e){var t=e.stateNode,l=e.memoizedProps;try{for(var a=e.type,n=t.attributes;n.length;)t.removeAttributeNode(n[0]);Ie(t,a,l),t[Je]=e,t[at]=l}catch(u){ye(e,e.return,u)}}var Ft=!1,Le=!1,Lc=!1,yd=typeof WeakSet=="function"?WeakSet:Set,Ze=null;function Tm(e,t){if(e=e.containerInfo,cs=Ku,e=Er(e),Oi(e)){if("selectionStart"in e)var l={start:e.selectionStart,end:e.selectionEnd};else e:{l=(l=e.ownerDocument)&&l.defaultView||window;var a=l.getSelection&&l.getSelection();if(a&&a.rangeCount!==0){l=a.anchorNode;var n=a.anchorOffset,u=a.focusNode;a=a.focusOffset;try{l.nodeType,u.nodeType}catch{l=null;break e}var c=0,s=-1,d=-1,h=0,v=0,S=e,y=null;t:for(;;){for(var x;S!==l||n!==0&&S.nodeType!==3||(s=c+n),S!==u||a!==0&&S.nodeType!==3||(d=c+a),S.nodeType===3&&(c+=S.nodeValue.length),(x=S.firstChild)!==null;)y=S,S=x;for(;;){if(S===e)break t;if(y===l&&++h===n&&(s=c),y===u&&++v===a&&(d=c),(x=S.nextSibling)!==null)break;S=y,y=S.parentNode}S=x}l=s===-1||d===-1?null:{start:s,end:d}}else l=null}l=l||{start:0,end:0}}else l=null;for(ss={focusedElem:e,selectionRange:l},Ku=!1,Ze=t;Ze!==null;)if(t=Ze,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Ze=e;else for(;Ze!==null;){switch(t=Ze,u=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(l=0;l title"))),Ie(u,a,l),u[Je]=e,Xe(u),a=u;break e;case"link":var c=j0("link","href",n).get(a+(l.href||""));if(c){for(var s=0;spe&&(c=pe,pe=K,K=c);var m=zr(s,K),o=zr(s,pe);if(m&&o&&(x.rangeCount!==1||x.anchorNode!==m.node||x.anchorOffset!==m.offset||x.focusNode!==o.node||x.focusOffset!==o.offset)){var g=S.createRange();g.setStart(m.node,m.offset),x.removeAllRanges(),K>pe?(x.addRange(g),x.extend(o.node,o.offset)):(g.setEnd(o.node,o.offset),x.addRange(g))}}}}for(S=[],x=s;x=x.parentNode;)x.nodeType===1&&S.push({element:x,left:x.scrollLeft,top:x.scrollTop});for(typeof s.focus=="function"&&s.focus(),s=0;sl?32:l,b.T=null,l=Kc,Kc=null;var u=jl,c=ll;if(Ge=0,Ta=jl=null,ll=0,(oe&6)!==0)throw Error(r(331));var s=oe;if(oe|=4,Ed(u.current),kd(u,u.current,c,l),oe=s,Nn(0,!1),dt&&typeof dt.onPostCommitFiberRoot=="function")try{dt.onPostCommitFiberRoot(La,u)}catch{}return!0}finally{C.p=n,b.T=a,Zd(e,t)}}function Kd(e,t,l){t=Nt(l,t),t=Mc(e.stateNode,t,2),e=hl(e,t,2),e!==null&&(Ga(e,2),Bt(e))}function ye(e,t,l){if(e.tag===3)Kd(e,e,l);else for(;t!==null;){if(t.tag===3){Kd(t,e,l);break}else if(t.tag===1){var a=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(Sl===null||!Sl.has(a))){e=Nt(l,e),l=Jf(2),a=hl(t,l,2),a!==null&&(Wf(l,a,t,e),Ga(a,2),Bt(a));break}}t=t.return}}function Fc(e,t,l){var a=e.pingCache;if(a===null){a=e.pingCache=new _m;var n=new Set;a.set(t,n)}else n=a.get(t),n===void 0&&(n=new Set,a.set(t,n));n.has(l)||(Qc=!0,n.add(l),e=Hm.bind(null,e,t,l),t.then(e,e))}function Hm(e,t,l){var a=e.pingCache;a!==null&&a.delete(t),e.pingedLanes|=e.suspendedLanes&l,e.warmLanes&=~l,je===e&&(ne&l)===l&&(De===4||De===3&&(ne&62914560)===ne&&300>ft()-Au?(oe&2)===0&&Aa(e,0):Xc|=l,Ea===ne&&(Ea=0)),Bt(e)}function Jd(e,t){t===0&&(t=Rs()),e=ql(e,t),e!==null&&(Ga(e,t),Bt(e))}function Bm(e){var t=e.memoizedState,l=0;t!==null&&(l=t.retryLane),Jd(e,l)}function qm(e,t){var l=0;switch(e.tag){case 31:case 13:var a=e.stateNode,n=e.memoizedState;n!==null&&(l=n.retryLane);break;case 19:a=e.stateNode;break;case 22:a=e.stateNode._retryCache;break;default:throw Error(r(314))}a!==null&&a.delete(t),Jd(e,l)}function Ym(e,t){return fi(e,t)}var Hu=null,_a=null,Ic=!1,Bu=!1,Pc=!1,kl=0;function Bt(e){e!==_a&&e.next===null&&(_a===null?Hu=_a=e:_a=_a.next=e),Bu=!0,Ic||(Ic=!0,Rm())}function Nn(e,t){if(!Pc&&Bu){Pc=!0;do for(var l=!1,a=Hu;a!==null;){if(e!==0){var n=a.pendingLanes;if(n===0)var u=0;else{var c=a.suspendedLanes,s=a.pingedLanes;u=(1<<31-ot(42|e)+1)-1,u&=n&~(c&~s),u=u&201326741?u&201326741|1:u?u|2:0}u!==0&&(l=!0,Id(a,u))}else u=ne,u=Rn(a,a===je?u:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),(u&3)===0||Ra(a,u)||(l=!0,Id(a,u));a=a.next}while(l);Pc=!1}}function Lm(){Wd()}function Wd(){Bu=Ic=!1;var e=0;kl!==0&&Fm()&&(e=kl);for(var t=ft(),l=null,a=Hu;a!==null;){var n=a.next,u=$d(a,t);u===0?(a.next=null,l===null?Hu=n:l.next=n,n===null&&(_a=l)):(l=a,(e!==0||(u&3)!==0)&&(Bu=!0)),a=n}Ge!==0&&Ge!==5||Nn(e),kl!==0&&(kl=0)}function $d(e,t){for(var l=e.suspendedLanes,a=e.pingedLanes,n=e.expirationTimes,u=e.pendingLanes&-62914561;0s)break;var v=d.transferSize,S=d.initiatorType;v&&i0(S)&&(d=d.responseEnd,c+=v*(d"u"?null:document;function b0(e,t,l){var a=Da;if(a&&typeof t=="string"&&t){var n=St(t);n='link[rel="'+e+'"][href="'+n+'"]',typeof l=="string"&&(n+='[crossorigin="'+l+'"]'),x0.has(n)||(x0.add(n),e={rel:e,crossOrigin:l,href:t},a.querySelector(n)===null&&(t=a.createElement("link"),Ie(t,"link",e),Xe(t),a.head.appendChild(t)))}}function ig(e){al.D(e),b0("dns-prefetch",e,null)}function cg(e,t){al.C(e,t),b0("preconnect",e,t)}function sg(e,t,l){al.L(e,t,l);var a=Da;if(a&&e&&t){var n='link[rel="preload"][as="'+St(t)+'"]';t==="image"&&l&&l.imageSrcSet?(n+='[imagesrcset="'+St(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(n+='[imagesizes="'+St(l.imageSizes)+'"]')):n+='[href="'+St(e)+'"]';var u=n;switch(t){case"style":u=Oa(e);break;case"script":u=wa(e)}At.has(u)||(e=A({rel:"preload",href:t==="image"&&l&&l.imageSrcSet?void 0:e,as:t},l),At.set(u,e),a.querySelector(n)!==null||t==="style"&&a.querySelector(En(u))||t==="script"&&a.querySelector(Tn(u))||(t=a.createElement("link"),Ie(t,"link",e),Xe(t),a.head.appendChild(t)))}}function rg(e,t){al.m(e,t);var l=Da;if(l&&e){var a=t&&typeof t.as=="string"?t.as:"script",n='link[rel="modulepreload"][as="'+St(a)+'"][href="'+St(e)+'"]',u=n;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":u=wa(e)}if(!At.has(u)&&(e=A({rel:"modulepreload",href:e},t),At.set(u,e),l.querySelector(n)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Tn(u)))return}a=l.createElement("link"),Ie(a,"link",e),Xe(a),l.head.appendChild(a)}}}function fg(e,t,l){al.S(e,t,l);var a=Da;if(a&&e){var n=ta(a).hoistableStyles,u=Oa(e);t=t||"default";var c=n.get(u);if(!c){var s={loading:0,preload:null};if(c=a.querySelector(En(u)))s.loading=5;else{e=A({rel:"stylesheet",href:e,"data-precedence":t},l),(l=At.get(u))&&hs(e,l);var d=c=a.createElement("link");Xe(d),Ie(d,"link",e),d._p=new Promise(function(h,v){d.onload=h,d.onerror=v}),d.addEventListener("load",function(){s.loading|=1}),d.addEventListener("error",function(){s.loading|=2}),s.loading|=4,Gu(c,t,a)}c={type:"stylesheet",instance:c,count:1,state:s},n.set(u,c)}}}function dg(e,t){al.X(e,t);var l=Da;if(l&&e){var a=ta(l).hoistableScripts,n=wa(e),u=a.get(n);u||(u=l.querySelector(Tn(n)),u||(e=A({src:e,async:!0},t),(t=At.get(n))&&ys(e,t),u=l.createElement("script"),Xe(u),Ie(u,"link",e),l.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},a.set(n,u))}}function og(e,t){al.M(e,t);var l=Da;if(l&&e){var a=ta(l).hoistableScripts,n=wa(e),u=a.get(n);u||(u=l.querySelector(Tn(n)),u||(e=A({src:e,async:!0,type:"module"},t),(t=At.get(n))&&ys(e,t),u=l.createElement("script"),Xe(u),Ie(u,"link",e),l.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},a.set(n,u))}}function v0(e,t,l,a){var n=(n=Ke.current)?Ru(n):null;if(!n)throw Error(r(446));switch(e){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(t=Oa(l.href),l=ta(n).hoistableStyles,a=l.get(t),a||(a={type:"style",instance:null,count:0,state:null},l.set(t,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){e=Oa(l.href);var u=ta(n).hoistableStyles,c=u.get(e);if(c||(n=n.ownerDocument||n,c={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(e,c),(u=n.querySelector(En(e)))&&!u._p&&(c.instance=u,c.state.loading=5),At.has(e)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},At.set(e,l),u||mg(n,e,l,c.state))),t&&a===null)throw Error(r(528,""));return c}if(t&&a!==null)throw Error(r(529,""));return null;case"script":return t=l.async,l=l.src,typeof l=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=wa(l),l=ta(n).hoistableScripts,a=l.get(t),a||(a={type:"script",instance:null,count:0,state:null},l.set(t,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,e))}}function Oa(e){return'href="'+St(e)+'"'}function En(e){return'link[rel="stylesheet"]['+e+"]"}function p0(e){return A({},e,{"data-precedence":e.precedence,precedence:null})}function mg(e,t,l,a){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?a.loading=1:(t=e.createElement("link"),a.preload=t,t.addEventListener("load",function(){return a.loading|=1}),t.addEventListener("error",function(){return a.loading|=2}),Ie(t,"link",l),Xe(t),e.head.appendChild(t))}function wa(e){return'[src="'+St(e)+'"]'}function Tn(e){return"script[async]"+e}function S0(e,t,l){if(t.count++,t.instance===null)switch(t.type){case"style":var a=e.querySelector('style[data-href~="'+St(l.href)+'"]');if(a)return t.instance=a,Xe(a),a;var n=A({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return a=(e.ownerDocument||e).createElement("style"),Xe(a),Ie(a,"style",n),Gu(a,l.precedence,e),t.instance=a;case"stylesheet":n=Oa(l.href);var u=e.querySelector(En(n));if(u)return t.state.loading|=4,t.instance=u,Xe(u),u;a=p0(l),(n=At.get(n))&&hs(a,n),u=(e.ownerDocument||e).createElement("link"),Xe(u);var c=u;return c._p=new Promise(function(s,d){c.onload=s,c.onerror=d}),Ie(u,"link",a),t.state.loading|=4,Gu(u,l.precedence,e),t.instance=u;case"script":return u=wa(l.src),(n=e.querySelector(Tn(u)))?(t.instance=n,Xe(n),n):(a=l,(n=At.get(u))&&(a=A({},l),ys(a,n)),e=e.ownerDocument||e,n=e.createElement("script"),Xe(n),Ie(n,"link",a),e.head.appendChild(n),t.instance=n);case"void":return null;default:throw Error(r(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(a=t.instance,t.state.loading|=4,Gu(a,l.precedence,e));return t.instance}function Gu(e,t,l){for(var a=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),n=a.length?a[a.length-1]:null,u=n,c=0;c title"):null)}function gg(e,t,l){if(l===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return e=t.disabled,typeof t.precedence=="string"&&e==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function k0(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function hg(e,t,l,a){if(l.type==="stylesheet"&&(typeof a.media!="string"||matchMedia(a.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var n=Oa(a.href),u=t.querySelector(En(n));if(u){t=u._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Xu.bind(e),t.then(e,e)),l.state.loading|=4,l.instance=u,Xe(u);return}u=t.ownerDocument||t,a=p0(a),(n=At.get(n))&&hs(a,n),u=u.createElement("link"),Xe(u);var c=u;c._p=new Promise(function(s,d){c.onload=s,c.onerror=d}),Ie(u,"link",a),l.instance=u}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(l,t),(t=l.state.preload)&&(l.state.loading&3)===0&&(e.count++,l=Xu.bind(e),t.addEventListener("load",l),t.addEventListener("error",l))}}var xs=0;function yg(e,t){return e.stylesheets&&e.count===0&&Vu(e,e.stylesheets),0xs?50:800)+t);return e.unsuspend=l,function(){e.unsuspend=null,clearTimeout(a),clearTimeout(n)}}:null}function Xu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Vu(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Zu=null;function Vu(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Zu=new Map,t.forEach(xg,e),Zu=null,Xu.call(e))}function xg(e,t){if(!(t.state.loading&4)){var l=Zu.get(e);if(l)var a=l.get(null);else{l=new Map,Zu.set(e,l);for(var n=e.querySelectorAll("link[data-precedence],style[data-precedence]"),u=0;u"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(f)}catch(j){console.error(j)}}return f(),Ms.exports=Bg(),Ms.exports}var Yg=qg();const X0="".replace(/\/$/,"");let Hn=localStorage.getItem("access_token"),Fl=localStorage.getItem("refresh_token"),ei=null;function As(f){return X0?`${X0}${f.startsWith("/")?f:`/${f}`}`:f}function Cs(f,j){Hn=f,Fl=j,localStorage.setItem("access_token",f),localStorage.setItem("refresh_token",j)}function _s(){Hn=null,Fl=null,localStorage.removeItem("access_token"),localStorage.removeItem("refresh_token")}function Lg(){return Fl}async function Rg(){if(!Fl)throw new Error("No refresh token");const f=await fetch(As("/auth/refresh"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh_token:Fl})});if(!f.ok)throw _s(),window.dispatchEvent(new CustomEvent("auth:logout")),new Error("Refresh failed");const j=await f.json();Cs(j.access_token,j.refresh_token)}async function re(f,j={}){var M;const O={...j.headers};Hn&&(O.Authorization=`Bearer ${Hn}`),j.body instanceof FormData||(O["Content-Type"]="application/json");let r=await fetch(As(f),{...j,headers:O});if(r.status===401&&Fl&&(ei||(ei=Rg().finally(()=>{ei=null})),await ei,O.Authorization=`Bearer ${Hn}`,r=await fetch(As(f),{...j,headers:O})),!r.ok){const _=await r.json().catch(()=>({}));throw{status:r.status,..._}}return(M=r.headers.get("content-type"))!=null&&M.includes("text/calendar")?await r.text():r.json()}const Se={register:(f,j,O)=>re("/auth/register",{method:"POST",body:JSON.stringify({email:f,password:j,timezone:O})}),login:(f,j)=>re("/auth/login",{method:"POST",body:JSON.stringify({email:f,password:j})}),logout:()=>re("/auth/logout",{method:"POST",body:JSON.stringify({refresh_token:Fl})}),me:()=>re("/auth/me"),updateMe:f=>re("/users/me",{method:"PUT",body:JSON.stringify(f)}),deleteMe:()=>re("/users/me",{method:"DELETE"}),listApiKeys:()=>re("/api-keys"),createApiKey:f=>re("/api-keys",{method:"POST",body:JSON.stringify(f)}),revokeApiKey:f=>re(`/api-keys/${f}`,{method:"DELETE"}),listCalendars:()=>re("/calendars?limit=100"),createCalendar:f=>re("/calendars",{method:"POST",body:JSON.stringify(f)}),getCalendar:f=>re(`/calendars/${f}`),updateCalendar:(f,j)=>re(`/calendars/${f}`,{method:"PUT",body:JSON.stringify(j)}),deleteCalendar:f=>re(`/calendars/${f}`,{method:"DELETE"}),shareCalendar:(f,j)=>re(`/calendars/${f}/share`,{method:"POST",body:JSON.stringify(j)}),listMembers:f=>re(`/calendars/${f}/members`),removeMember:(f,j)=>re(`/calendars/${f}/members/${j}`,{method:"DELETE"}),addCalendarFromUrl:f=>re("/calendars/add-from-url",{method:"POST",body:JSON.stringify(f)}),importCalendarUrl:f=>re("/calendars/import-url",{method:"POST",body:JSON.stringify(f)}),listSubscriptions:f=>re(`/calendars/${f}/subscriptions`),addSubscription:(f,j)=>re(`/calendars/${f}/subscriptions`,{method:"POST",body:JSON.stringify(j)}),deleteSubscription:(f,j)=>re(`/calendars/${f}/subscriptions/${j}`,{method:"DELETE"}),syncSubscription:(f,j)=>re(`/calendars/${f}/subscriptions/${j}/sync`,{method:"POST"}),listEvents:f=>{const j=new URLSearchParams({start:f.start,end:f.end});return f.calendar_id&&j.set("calendar_id",f.calendar_id),f.search&&j.set("search",f.search),j.set("limit","500"),re(`/events?${j}`)},createEvent:f=>re("/events",{method:"POST",body:JSON.stringify(f)}),getEvent:f=>re(`/events/${f}`),updateEvent:(f,j)=>re(`/events/${f}`,{method:"PUT",body:JSON.stringify(j)}),deleteEvent:f=>re(`/events/${f}`,{method:"DELETE"}),listContacts:f=>{const j=new URLSearchParams({limit:"200"});return f&&j.set("search",f),re(`/contacts?${j}`)},createContact:f=>re("/contacts",{method:"POST",body:JSON.stringify(f)}),getContact:f=>re(`/contacts/${f}`),updateContact:(f,j)=>re(`/contacts/${f}`,{method:"PUT",body:JSON.stringify(j)}),deleteContact:f=>re(`/contacts/${f}`,{method:"DELETE"})},eo=N.createContext(null);function Gg({children:f}){const[j,O]=N.useState(null),[r,M]=N.useState(!0);N.useEffect(()=>{localStorage.getItem("access_token")?Se.me().then(A=>O(A.user)).catch(()=>{_s(),O(null)}).finally(()=>M(!1)):M(!1);const Z=()=>{O(null)};return window.addEventListener("auth:logout",Z),()=>window.removeEventListener("auth:logout",Z)},[]);const _=N.useCallback(async(B,Z)=>{const A=await Se.login(B,Z);Cs(A.access_token,A.refresh_token),O(A.user)},[]),H=N.useCallback(async(B,Z,A)=>{const k=await Se.register(B,Z,A);Cs(k.access_token,k.refresh_token),O(k.user)},[]),Y=N.useCallback(async()=>{try{Lg()&&await Se.logout()}finally{_s(),O(null)}},[]),R=N.useCallback(async()=>{const B=await Se.me();O(B.user)},[]);return i.jsx(eo.Provider,{value:{user:j,loading:r,login:_,register:H,logout:Y,refreshUser:R},children:f})}function Ya(){const f=N.useContext(eo);if(!f)throw new Error("useAuth must be used within AuthProvider");return f}const to=N.createContext(null);function Qg(){const f=localStorage.getItem("theme");return f||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")}function Xg({children:f}){const[j,O]=N.useState(Qg);N.useEffect(()=>{document.documentElement.classList.toggle("dark",j==="dark"),localStorage.setItem("theme",j)},[j]);const r=N.useCallback(()=>{O(M=>M==="light"?"dark":"light")},[]);return i.jsx(to.Provider,{value:{theme:j,toggle:r},children:f})}function ii(){const f=N.useContext(to);if(!f)throw new Error("useTheme must be used within ThemeProvider");return f}class Zg extends N.Component{constructor(j){super(j),this.state={hasError:!1}}static getDerivedStateFromError(j){return{hasError:!0,error:j}}render(){return this.state.hasError?this.props.fallback?this.props.fallback:i.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900 p-4",children:i.jsxs("div",{className:"max-w-md w-full text-center",children:[i.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:i.jsx("svg",{className:"w-8 h-8 text-red-600 dark:text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),i.jsx("h1",{className:"text-xl font-semibold text-gray-900 dark:text-white mb-2",children:"Something went wrong"}),i.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:"An unexpected error occurred. Please refresh the page to try again."}),i.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white text-sm font-medium rounded-lg transition-colors",children:"Refresh page"})]})}):this.props.children}}function Vg(){const{login:f}=Ya(),{theme:j,toggle:O}=ii(),r=Ds(),[M,_]=N.useState(""),[H,Y]=N.useState(""),[R,B]=N.useState(""),[Z,A]=N.useState(!1),k=async D=>{D.preventDefault(),B(""),A(!0);try{await f(M,H),r("/")}catch(w){B(w.error||"Invalid credentials")}finally{A(!1)}};return i.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900 px-4 transition-colors",children:[i.jsx("div",{className:"absolute top-4 right-4",children:i.jsx("button",{onClick:O,className:"p-2 rounded-xl bg-white dark:bg-gray-800 shadow-sm border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors",children:j==="dark"?i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"})}):i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"})})})}),i.jsxs("div",{className:"w-full max-w-sm",children:[i.jsxs("div",{className:"text-center mb-8",children:[i.jsx("div",{className:"inline-flex items-center justify-center w-14 h-14 bg-blue-600 rounded-2xl mb-4 shadow-lg shadow-blue-600/20",children:i.jsx("svg",{className:"w-8 h-8 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),i.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Welcome back"}),i.jsx("p",{className:"text-gray-500 dark:text-gray-400 mt-1 text-sm",children:"Sign in to your calendar"})]}),i.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-2xl shadow-xl shadow-gray-200/50 dark:shadow-black/20 border border-gray-100 dark:border-gray-700 p-6",children:i.jsxs("form",{onSubmit:k,className:"space-y-4",children:[R&&i.jsx("div",{className:"text-sm text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/20 px-3 py-2.5 rounded-xl",children:R}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5",children:"Email"}),i.jsx("input",{type:"email",value:M,onChange:D=>_(D.target.value),className:"w-full px-3.5 py-2.5 rounded-xl border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700/50 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent outline-none transition-all text-sm",placeholder:"you@example.com",required:!0,autoFocus:!0})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5",children:"Password"}),i.jsx("input",{type:"password",value:H,onChange:D=>Y(D.target.value),className:"w-full px-3.5 py-2.5 rounded-xl border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700/50 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent outline-none transition-all text-sm",placeholder:"Min. 10 characters",required:!0,minLength:10})]}),i.jsx("button",{type:"submit",disabled:Z,className:"w-full py-2.5 bg-blue-600 hover:bg-blue-700 disabled:opacity-50 text-white rounded-xl font-medium transition-colors text-sm",children:Z?"Signing in...":"Sign in"})]})}),i.jsxs("p",{className:"text-center mt-6 text-sm text-gray-500 dark:text-gray-400",children:["Don't have an account?"," ",i.jsx(K0,{to:"/register",className:"text-blue-600 dark:text-blue-400 hover:underline font-medium",children:"Create one"})]})]})]})}function Kg(){const{register:f}=Ya(),{theme:j,toggle:O}=ii(),r=Ds(),[M,_]=N.useState(""),[H,Y]=N.useState(""),[R,B]=N.useState(""),[Z,A]=N.useState(""),[k,D]=N.useState(!1),w=async T=>{if(T.preventDefault(),A(""),H!==R){A("Passwords don't match");return}D(!0);try{const U=Intl.DateTimeFormat().resolvedOptions().timeZone;await f(M,H,U),r("/")}catch(U){A(U.error||"Registration failed")}finally{D(!1)}};return i.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900 px-4 transition-colors",children:[i.jsx("div",{className:"absolute top-4 right-4",children:i.jsx("button",{onClick:O,className:"p-2 rounded-xl bg-white dark:bg-gray-800 shadow-sm border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors",children:j==="dark"?i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"})}):i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"})})})}),i.jsxs("div",{className:"w-full max-w-sm",children:[i.jsxs("div",{className:"text-center mb-8",children:[i.jsx("div",{className:"inline-flex items-center justify-center w-14 h-14 bg-blue-600 rounded-2xl mb-4 shadow-lg shadow-blue-600/20",children:i.jsx("svg",{className:"w-8 h-8 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),i.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Create account"}),i.jsx("p",{className:"text-gray-500 dark:text-gray-400 mt-1 text-sm",children:"Get started with your calendar"})]}),i.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-2xl shadow-xl shadow-gray-200/50 dark:shadow-black/20 border border-gray-100 dark:border-gray-700 p-6",children:i.jsxs("form",{onSubmit:w,className:"space-y-4",children:[Z&&i.jsx("div",{className:"text-sm text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/20 px-3 py-2.5 rounded-xl",children:Z}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5",children:"Email"}),i.jsx("input",{type:"email",value:M,onChange:T=>_(T.target.value),className:"w-full px-3.5 py-2.5 rounded-xl border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700/50 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent outline-none transition-all text-sm",placeholder:"you@example.com",required:!0,autoFocus:!0})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5",children:"Password"}),i.jsx("input",{type:"password",value:H,onChange:T=>Y(T.target.value),className:"w-full px-3.5 py-2.5 rounded-xl border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700/50 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent outline-none transition-all text-sm",placeholder:"Min. 10 characters",required:!0,minLength:10})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5",children:"Confirm password"}),i.jsx("input",{type:"password",value:R,onChange:T=>B(T.target.value),className:"w-full px-3.5 py-2.5 rounded-xl border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700/50 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent outline-none transition-all text-sm",placeholder:"Repeat your password",required:!0,minLength:10})]}),i.jsx("button",{type:"submit",disabled:k,className:"w-full py-2.5 bg-blue-600 hover:bg-blue-700 disabled:opacity-50 text-white rounded-xl font-medium transition-colors text-sm",children:k?"Creating account...":"Create account"})]})}),i.jsxs("p",{className:"text-center mt-6 text-sm text-gray-500 dark:text-gray-400",children:["Already have an account?"," ",i.jsx(K0,{to:"/login",className:"text-blue-600 dark:text-blue-400 hover:underline font-medium",children:"Sign in"})]})]})]})}function Dl(f){return f.is_occurrence&&f.occurrence_start_time?f.occurrence_start_time:f.start_time}function ni(f){return f.is_occurrence&&f.occurrence_end_time?f.occurrence_end_time:f.end_time}function Jg({currentDate:f,events:j,calendars:O,visibleCalendarIds:r,onDateClick:M,onEventClick:_}){const H=Us(f),Y=Hs(f),R=Ba(H),B=Un(Y),Z=J0({start:R,end:B}),A=new Map(O.map(w=>[w.id,w.color])),k=j.filter(w=>r.has(w.calendar_id)),D=w=>k.filter(T=>{const U=tt(Dl(T)),J=tt(ni(T));return _l(U,w)||_l(J,w)||Uw});return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsx("div",{className:"grid grid-cols-7 border-b border-gray-200 dark:border-gray-700",children:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(w=>i.jsx("div",{className:"py-2 text-center text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:w},w))}),i.jsx("div",{className:"grid grid-cols-7 flex-1 auto-rows-fr",children:Z.map((w,T)=>{const U=W0(w,f),J=ui(w),P=D(w);return i.jsxs("div",{className:`min-h-[80px] border-b border-r border-gray-100 dark:border-gray-700/50 p-1 cursor-pointer transition-colors hover:bg-gray-50 dark:hover:bg-gray-800/50 ${T%7===0?"border-l":""} ${U?"":"bg-gray-50/50 dark:bg-gray-900/30"}`,onClick:()=>M(w),children:[i.jsx("div",{className:"flex justify-center mb-1",children:i.jsx("span",{className:`text-xs w-6 h-6 flex items-center justify-center rounded-full font-medium ${J?"bg-blue-600 text-white":""} ${!J&&U?"text-gray-700 dark:text-gray-300":""} ${!J&&!U?"text-gray-400 dark:text-gray-600":""}`,children:Oe(w,"d")})}),i.jsxs("div",{className:"space-y-0.5 overflow-hidden",children:[P.slice(0,3).map(ee=>i.jsxs("button",{onClick:$=>{$.stopPropagation(),_(ee)},className:"w-full text-left text-[10px] leading-tight px-1.5 py-0.5 rounded truncate text-white font-medium transition-opacity hover:opacity-80",style:{backgroundColor:A.get(ee.calendar_id)||"#3B82F6"},children:[!ee.all_day&&i.jsxs("span",{className:"opacity-80",children:[Oe(tt(Dl(ee)),"h:mm")," "]}),ee.title]},ee.id+w.toISOString())),P.length>3&&i.jsxs("div",{className:"text-[10px] text-gray-500 dark:text-gray-400 text-center font-medium",children:["+",P.length-3," more"]})]})]},w.toISOString())})})]})}const Z0=Array.from({length:24},(f,j)=>j),ti=60;function Wg({currentDate:f,events:j,calendars:O,visibleCalendarIds:r,onTimeClick:M,onEventClick:_}){const H=Ba(f),Y=Array.from({length:7},(T,U)=>$0(H,U)),R=new Map(O.map(T=>[T.id,T.color])),B=j.filter(T=>r.has(T.calendar_id)),Z=B.filter(T=>T.all_day),A=B.filter(T=>!T.all_day),k=T=>A.filter(U=>_l(tt(Dl(U)),T)),D=T=>Z.filter(U=>{const J=tt(Dl(U)),P=tt(ni(U));return _l(J,T)||_l(P,T)||JT}),w=T=>{const U=tt(Dl(T)),J=F0(U),P=ai(U,J),ee=tt(ni(T)),$=Math.max(ai(ee,U),15);return{top:`${P}px`,height:`${$}px`,minHeight:"20px"}};return i.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[i.jsxs("div",{className:"flex border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:[i.jsx("div",{className:"w-16 flex-shrink-0"}),Y.map(T=>{const U=ui(T);return i.jsxs("div",{className:"flex-1 text-center py-2 border-l border-gray-100 dark:border-gray-700/50",children:[i.jsx("div",{className:"text-[10px] font-semibold text-gray-500 dark:text-gray-400 uppercase",children:Oe(T,"EEE")}),i.jsx("div",{className:`text-lg font-semibold mt-0.5 ${U?"bg-blue-600 text-white w-8 h-8 rounded-full flex items-center justify-center mx-auto":"text-gray-700 dark:text-gray-300"}`,children:Oe(T,"d")})]},T.toISOString())})]}),Z.length>0&&i.jsxs("div",{className:"flex border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:[i.jsx("div",{className:"w-16 flex-shrink-0 text-[10px] text-gray-400 dark:text-gray-500 text-right pr-2 py-1",children:"all-day"}),Y.map(T=>i.jsx("div",{className:"flex-1 border-l border-gray-100 dark:border-gray-700/50 p-0.5 space-y-0.5",children:D(T).map(U=>i.jsx("button",{onClick:()=>_(U),className:"w-full text-left text-[10px] px-1.5 py-0.5 rounded text-white font-medium truncate hover:opacity-80",style:{backgroundColor:R.get(U.calendar_id)||"#3B82F6"},children:U.title},U.id))},T.toISOString()))]}),i.jsx("div",{className:"flex-1 overflow-y-auto",children:i.jsxs("div",{className:"flex relative",style:{height:`${24*ti}px`},children:[i.jsx("div",{className:"w-16 flex-shrink-0 relative",children:Z0.map(T=>i.jsx("div",{className:"absolute w-full text-right pr-2 text-[10px] text-gray-400 dark:text-gray-500 -mt-2",style:{top:`${T*ti}px`},children:T===0?"":Oe(new Date(2e3,0,1,T),"h a")},T))}),Y.map(T=>i.jsxs("div",{className:"flex-1 relative border-l border-gray-100 dark:border-gray-700/50",children:[Z0.map(U=>i.jsx("div",{className:"absolute w-full border-t border-gray-100 dark:border-gray-700/30 cursor-pointer hover:bg-blue-50/50 dark:hover:bg-blue-900/10",style:{top:`${U*ti}px`,height:`${ti}px`},onClick:()=>{const J=new Date(T);J.setHours(U,0,0,0),M(J)}},U)),k(T).map(U=>{const J=w(U);return i.jsxs("button",{onClick:P=>{P.stopPropagation(),_(U)},className:"absolute left-0.5 right-1 rounded-md px-1.5 py-0.5 text-[11px] text-white font-medium overflow-hidden hover:opacity-90 z-10 shadow-sm",style:{...J,backgroundColor:R.get(U.calendar_id)||"#3B82F6"},children:[i.jsx("div",{className:"truncate",children:U.title}),i.jsx("div",{className:"opacity-75 truncate text-[10px]",children:Oe(tt(U.start_time),"h:mm a")})]},U.id)})]},T.toISOString()))]})})]})}const V0=Array.from({length:24},(f,j)=>j),Ha=64;function $g({currentDate:f,events:j,calendars:O,visibleCalendarIds:r,onTimeClick:M,onEventClick:_}){const H=new Map(O.map(k=>[k.id,k.color])),Y=j.filter(k=>r.has(k.calendar_id)),R=Y.filter(k=>k.all_day&&_l(tt(Dl(k)),f)),B=Y.filter(k=>!k.all_day&&_l(tt(Dl(k)),f)),Z=ui(f),A=k=>{const D=tt(Dl(k)),w=F0(D),T=ai(D,w),U=tt(ni(k)),J=Math.max(ai(U,D),15);return{top:`${T*(Ha/60)}px`,height:`${J*(Ha/60)}px`,minHeight:"24px"}};return i.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[i.jsxs("div",{className:"text-center py-3 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:[i.jsx("div",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase",children:Oe(f,"EEEE")}),i.jsx("div",{className:`text-2xl font-bold mt-1 ${Z?"bg-blue-600 text-white w-10 h-10 rounded-full flex items-center justify-center mx-auto":"text-gray-800 dark:text-gray-200"}`,children:Oe(f,"d")})]}),R.length>0&&i.jsx("div",{className:"px-4 py-2 border-b border-gray-200 dark:border-gray-700 space-y-1 flex-shrink-0",children:R.map(k=>i.jsx("button",{onClick:()=>_(k),className:"block w-full text-left text-sm px-3 py-1.5 rounded-lg text-white font-medium hover:opacity-80",style:{backgroundColor:H.get(k.calendar_id)||"#3B82F6"},children:k.title},k.id))}),i.jsx("div",{className:"flex-1 overflow-y-auto",children:i.jsxs("div",{className:"flex relative",style:{height:`${24*Ha}px`},children:[i.jsx("div",{className:"w-20 flex-shrink-0 relative",children:V0.map(k=>i.jsx("div",{className:"absolute w-full text-right pr-3 text-xs text-gray-400 dark:text-gray-500 -mt-2",style:{top:`${k*Ha}px`},children:k===0?"":Oe(new Date(2e3,0,1,k),"h a")},k))}),i.jsxs("div",{className:"flex-1 relative border-l border-gray-200 dark:border-gray-700",children:[V0.map(k=>i.jsx("div",{className:"absolute w-full border-t border-gray-100 dark:border-gray-700/30 cursor-pointer hover:bg-blue-50/50 dark:hover:bg-blue-900/10",style:{top:`${k*Ha}px`,height:`${Ha}px`},onClick:()=>{const D=new Date(f);D.setHours(k,0,0,0),M(D)}},k)),B.map(k=>{const D=A(k);return i.jsxs("button",{onClick:w=>{w.stopPropagation(),_(k)},className:"absolute left-1 right-4 rounded-lg px-3 py-1.5 text-white font-medium overflow-hidden hover:opacity-90 z-10 shadow-sm",style:{...D,backgroundColor:H.get(k.calendar_id)||"#3B82F6"},children:[i.jsx("div",{className:"text-sm truncate",children:k.title}),i.jsxs("div",{className:"text-xs opacity-80",children:[Oe(tt(k.start_time),"h:mm a")," -"," ",Oe(tt(k.end_time),"h:mm a")]}),k.location&&i.jsx("div",{className:"text-xs opacity-70 truncate",children:k.location})]},k.id)})]})]})})]})}function qa({open:f,onClose:j,title:O,children:r,wide:M}){return N.useEffect(()=>{if(!f)return;const _=H=>{H.key==="Escape"&&j()};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[f,j]),f?i.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center animate-fade-in",onClick:j,children:[i.jsx("div",{className:"absolute inset-0 bg-black/40 dark:bg-black/60"}),i.jsxs("div",{className:`relative bg-white dark:bg-gray-800 rounded-2xl shadow-2xl animate-slide-up ${M?"w-full max-w-2xl":"w-full max-w-md"} max-h-[90vh] overflow-y-auto mx-4`,onClick:_=>_.stopPropagation(),children:[i.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-100 dark:border-gray-700",children:[i.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:O}),i.jsx("button",{onClick:j,className:"p-1 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",children:i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),i.jsx("div",{className:"p-6",children:r})]})]}):null}function Fg({open:f,onClose:j,onSaved:O,event:r,calendars:M,defaultDate:_,defaultCalendarId:H}){var ie;const Y=!!r,R=M.filter(G=>G.role!=="viewer"),[B,Z]=N.useState(""),[A,k]=N.useState(""),[D,w]=N.useState(""),[T,U]=N.useState(""),[J,P]=N.useState(""),[ee,$]=N.useState("09:00"),[xe,ge]=N.useState(""),[Ne,Te]=N.useState("10:00"),[W,Ae]=N.useState(!1),[He,ke]=N.useState(!1),[Qe,Ve]=N.useState(""),[Re,b]=N.useState(!1);N.useEffect(()=>{var G;if(f)if(Ve(""),b(!1),r){Z(r.title),k(r.description||""),w(r.location||""),U(r.calendar_id),Ae(r.all_day);const te=new Date(r.start_time),z=new Date(r.end_time);P(Oe(te,"yyyy-MM-dd")),$(Oe(te,"HH:mm")),ge(Oe(z,"yyyy-MM-dd")),Te(Oe(z,"HH:mm"))}else{Z(""),k(""),w(""),U(H||((G=R[0])==null?void 0:G.id)||""),Ae(!1);const z=Oe(_||new Date,"yyyy-MM-dd");P(z),ge(z),$("09:00"),Te("10:00")}},[f,r,_,H]);const C=async G=>{if(G.preventDefault(),!(!B.trim()||!T)){ke(!0),Ve("");try{const te=Intl.DateTimeFormat().resolvedOptions().timeZone,z=W?`${J}T00:00:00`:`${J}T${ee}:00`,E=W?`${xe}T23:59:59`:`${xe}T${Ne}:00`,me={title:B.trim(),description:A.trim()||void 0,location:D.trim()||void 0,start_time:new Date(z).toISOString(),end_time:new Date(E).toISOString(),timezone:te,all_day:W};Y?await Se.updateEvent(r.id,me):await Se.createEvent({...me,calendar_id:T}),O(),j()}catch(te){Ve(te.error||"Failed to save event")}finally{ke(!1)}}},Q=async()=>{if(r){ke(!0);try{await Se.deleteEvent(r.id),O(),j()}catch(G){Ve(G.error||"Failed to delete event")}finally{ke(!1)}}},se=((ie=M.find(G=>G.id===T))==null?void 0:ie.color)||"#3B82F6";return i.jsx(qa,{open:f,onClose:j,title:Y?"Edit Event":"New Event",children:i.jsxs("form",{onSubmit:C,className:"space-y-4",children:[Qe&&i.jsx("div",{className:"text-sm text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/20 px-3 py-2 rounded-lg",children:Qe}),i.jsx("div",{children:i.jsx("input",{type:"text",placeholder:"Event title",value:B,onChange:G=>Z(G.target.value),className:"w-full text-lg font-medium bg-transparent border-0 border-b-2 border-gray-200 dark:border-gray-600 focus:border-blue-500 dark:focus:border-blue-400 focus:ring-0 px-0 py-2 text-gray-900 dark:text-white placeholder-gray-400 outline-none transition-colors",autoFocus:!0,required:!0})}),!Y&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Calendar"}),i.jsxs("div",{className:"relative",children:[i.jsx("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3 h-3 rounded-full",style:{backgroundColor:se}}),i.jsx("select",{value:T,onChange:G=>U(G.target.value),className:"w-full pl-8 pr-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none",children:R.map(G=>i.jsx("option",{value:G.id,children:G.name},G.id))})]})]}),i.jsx("div",{className:"flex items-center gap-3",children:i.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-700 dark:text-gray-300 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:W,onChange:G=>Ae(G.target.checked),className:"rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"}),"All day"]})}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Start"}),i.jsx("input",{type:"date",value:J,onChange:G=>{P(G.target.value),G.target.value>xe&&ge(G.target.value)},className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none",required:!0}),!W&&i.jsx("input",{type:"time",value:ee,onChange:G=>$(G.target.value),className:"w-full mt-2 px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none",required:!0})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"End"}),i.jsx("input",{type:"date",value:xe,onChange:G=>ge(G.target.value),min:J,className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none",required:!0}),!W&&i.jsx("input",{type:"time",value:Ne,onChange:G=>Te(G.target.value),className:"w-full mt-2 px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none",required:!0})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Location"}),i.jsx("input",{type:"text",placeholder:"Add location",value:D,onChange:G=>w(G.target.value),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none placeholder-gray-400"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Description"}),i.jsx("textarea",{placeholder:"Add description",value:A,onChange:G=>k(G.target.value),rows:3,className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none resize-none placeholder-gray-400"})]}),i.jsxs("div",{className:"flex items-center justify-between pt-2",children:[i.jsxs("div",{children:[Y&&!Re&&i.jsx("button",{type:"button",onClick:()=>b(!0),className:"text-sm text-red-500 hover:text-red-700 dark:hover:text-red-400 transition-colors",children:"Delete event"}),Y&&Re&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm text-red-500",children:"Delete?"}),i.jsx("button",{type:"button",onClick:Q,className:"text-sm text-white bg-red-500 hover:bg-red-600 px-3 py-1 rounded-lg transition-colors",disabled:He,children:"Yes"}),i.jsx("button",{type:"button",onClick:()=>b(!1),className:"text-sm text-gray-500 hover:text-gray-700 dark:text-gray-400 transition-colors",children:"No"})]})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{type:"button",onClick:j,className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:"Cancel"}),i.jsx("button",{type:"submit",disabled:He||!B.trim(),className:"px-4 py-2 text-sm text-white bg-blue-600 hover:bg-blue-700 disabled:opacity-50 rounded-lg transition-colors font-medium",children:He?"Saving...":Y?"Update":"Create"})]})]})]})})}const li=["#3B82F6","#EF4444","#10B981","#F59E0B","#8B5CF6","#EC4899","#06B6D4","#F97316","#6366F1","#14B8A6","#84CC16","#A855F7"];function Ig(f){navigator.clipboard.writeText(f)}function Pg({open:f,onClose:j,onSaved:O,calendar:r}){const M=!!r,[_,H]=N.useState(""),[Y,R]=N.useState(li[0]),[B,Z]=N.useState(!0),[A,k]=N.useState(10),[D,w]=N.useState(0),[T,U]=N.useState(!1),[J,P]=N.useState(""),[ee,$]=N.useState(!1),[xe,ge]=N.useState([]),[Ne,Te]=N.useState(!1),[W,Ae]=N.useState(""),[He,ke]=N.useState(!1),[Qe,Ve]=N.useState(null),[Re,b]=N.useState(!1),C=N.useCallback(async()=>{if(r!=null&&r.id){Te(!0);try{const E=await Se.listSubscriptions(r.id);ge(E.items||[])}catch{ge([])}finally{Te(!1)}}},[r==null?void 0:r.id]);N.useEffect(()=>{f&&(P(""),$(!1),Ae(""),r?(H(r.name),R(r.color),Z(r.count_for_availability??!0),k(r.default_reminder_minutes??10),w(r.sort_order??0),C()):(H(""),R(li[Math.floor(Math.random()*li.length)]),Z(!0),k(10),w(0),ge([])))},[f,r,C]);const Q=async E=>{if(E.preventDefault(),!!_.trim()){U(!0),P("");try{M?await Se.updateCalendar(r.id,{name:_.trim(),color:Y,count_for_availability:B,default_reminder_minutes:A===""?void 0:A,sort_order:D===""?void 0:D}):await Se.createCalendar({name:_.trim(),color:Y}),O(),j()}catch(me){P(me.error||"Failed to save calendar")}finally{U(!1)}}},se=async()=>{if(r){U(!0);try{await Se.deleteCalendar(r.id),O(),j()}catch(E){P(E.error||"Failed to delete calendar")}finally{U(!1)}}},ie=async E=>{if(E.preventDefault(),!(!(r!=null&&r.id)||!W.trim())){ke(!0);try{await Se.addSubscription(r.id,{url:W.trim()}),Ae(""),C(),O()}catch(me){P(me.error||"Failed to add subscription")}finally{ke(!1)}}},G=async E=>{if(r!=null&&r.id)try{await Se.deleteSubscription(r.id,E),C(),O()}catch(me){P(me.error||"Failed to remove subscription")}},te=async E=>{if(r!=null&&r.id){Ve(E);try{await Se.syncSubscription(r.id,E),C(),O()}catch(me){P(me.error||"Failed to sync")}finally{Ve(null)}}},z=E=>{Ig(E),b(!0),setTimeout(()=>b(!1),1500)};return i.jsx(qa,{open:f,onClose:j,title:M?"Edit Calendar":"New Calendar",children:i.jsxs("form",{onSubmit:Q,className:"space-y-5",children:[J&&i.jsx("div",{className:"text-sm text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/20 px-3 py-2 rounded-lg",children:J}),i.jsx("div",{children:i.jsx("input",{type:"text",placeholder:"Calendar name",value:_,onChange:E=>H(E.target.value),className:"w-full text-lg font-medium bg-transparent border-0 border-b-2 border-gray-200 dark:border-gray-600 focus:border-blue-500 dark:focus:border-blue-400 focus:ring-0 px-0 py-2 text-gray-900 dark:text-white placeholder-gray-400 outline-none transition-colors",autoFocus:!0,required:!0,maxLength:80})}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-2",children:"Color"}),i.jsx("div",{className:"flex flex-wrap gap-2",children:li.map(E=>i.jsx("button",{type:"button",onClick:()=>R(E),className:`w-8 h-8 rounded-full transition-all ${Y===E?"ring-2 ring-offset-2 ring-offset-white dark:ring-offset-gray-800 scale-110":"hover:scale-110"}`,style:{backgroundColor:E,outlineColor:Y===E?E:void 0}},E))})]}),M&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"checkbox",id:"count_for_availability",checked:B,onChange:E=>Z(E.target.checked),className:"rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"}),i.jsx("label",{htmlFor:"count_for_availability",className:"text-sm text-gray-700 dark:text-gray-300",children:"Include in availability / Count as busy"})]}),(r==null?void 0:r.availability_url)&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Availability URL"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"text",readOnly:!0,value:r.availability_url,className:"flex-1 px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-sm text-gray-600 dark:text-gray-400 truncate"}),i.jsx("button",{type:"button",onClick:()=>z(r.availability_url),className:"px-3 py-2 text-sm text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded-lg transition-colors",children:Re?"Copied!":"Copy"})]}),i.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"Share with Calendly, Cal.com, etc. to block busy times"})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Default reminder (min)"}),i.jsx("input",{type:"number",min:0,max:10080,value:A,onChange:E=>k(E.target.value===""?"":parseInt(E.target.value,10)||0),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Sort order"}),i.jsx("input",{type:"number",value:D,onChange:E=>w(E.target.value===""?"":parseInt(E.target.value,10)||0),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"})]})]}),(r==null?void 0:r.role)==="owner"||(r==null?void 0:r.role)==="editor"?i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-2",children:"Subscribed URLs"}),Ne?i.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Loading..."}):xe.length===0?i.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No subscriptions. Add a URL to import events from an external calendar."}):i.jsx("ul",{className:"space-y-2 mb-2",children:xe.map(E=>i.jsxs("li",{className:"flex items-center justify-between gap-2 p-2 rounded-lg bg-gray-50 dark:bg-gray-800 text-sm",children:[i.jsx("span",{className:"truncate text-gray-700 dark:text-gray-300",title:E.source_url,children:E.source_url}),i.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[i.jsx("button",{type:"button",onClick:()=>te(E.id),disabled:Qe===E.id,className:"px-2 py-1 text-xs text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded transition-colors disabled:opacity-50",children:Qe===E.id?"Syncing...":"Sync"}),i.jsx("button",{type:"button",onClick:()=>G(E.id),className:"px-2 py-1 text-xs text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors",children:"Remove"})]})]},E.id))}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"url",placeholder:"https://... or webcal://...",value:W,onChange:E=>Ae(E.target.value),onKeyDown:E=>{E.key==="Enter"&&(E.preventDefault(),ie(E))},className:"flex-1 px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none placeholder-gray-400"}),i.jsx("button",{type:"button",onClick:ie,disabled:He||!W.trim(),className:"px-3 py-2 text-sm text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded-lg transition-colors font-medium disabled:opacity-50",children:He?"Adding...":"Add"})]})]}):null]}),i.jsxs("div",{className:"flex items-center justify-between pt-2",children:[i.jsxs("div",{children:[M&&(r==null?void 0:r.role)==="owner"&&!ee&&i.jsx("button",{type:"button",onClick:()=>$(!0),className:"text-sm text-red-500 hover:text-red-700 dark:hover:text-red-400 transition-colors",children:"Delete calendar"}),M&&ee&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm text-red-500",children:"Delete?"}),i.jsx("button",{type:"button",onClick:se,className:"text-sm text-white bg-red-500 hover:bg-red-600 px-3 py-1 rounded-lg transition-colors",disabled:T,children:"Yes"}),i.jsx("button",{type:"button",onClick:()=>$(!1),className:"text-sm text-gray-500 hover:text-gray-700 dark:text-gray-400 transition-colors",children:"No"})]})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{type:"button",onClick:j,className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:"Cancel"}),i.jsx("button",{type:"submit",disabled:T||!_.trim(),className:"px-4 py-2 text-sm text-white bg-blue-600 hover:bg-blue-700 disabled:opacity-50 rounded-lg transition-colors font-medium",children:T?"Saving...":M?"Update":"Create"})]})]})]})})}function eh({open:f,onClose:j,onSaved:O,targetCalendarId:r,calendars:M}){var ee;const _=!r,[H,Y]=N.useState(""),[R,B]=N.useState(""),[Z,A]=N.useState("#3B82F6"),[k,D]=N.useState(r||((ee=M[0])==null?void 0:ee.id)||""),[w,T]=N.useState(!1),[U,J]=N.useState(""),P=async $=>{if($.preventDefault(),!!H.trim()){T(!0),J("");try{_?await Se.addCalendarFromUrl({url:H.trim(),name:R.trim()||void 0,color:Z||void 0}):await Se.importCalendarUrl({calendar_id:k,url:H.trim()}),O(),j(),Y(""),B("")}catch(xe){J(xe.error||"Failed to add calendar")}finally{T(!1)}}};return i.jsx(qa,{open:f,onClose:j,title:_?"Add calendar from URL":"Import from URL",children:i.jsxs("form",{onSubmit:P,className:"space-y-4",children:[U&&i.jsx("div",{className:"text-sm text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/20 px-3 py-2 rounded-lg break-words",children:U}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Calendar URL"}),i.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1.5",children:'Google Calendar: Settings → your calendar → Integrate calendar → copy "Secret address in iCal format"'}),i.jsx("input",{type:"text",placeholder:"https://... or webcal://...",value:H,onChange:$=>Y($.target.value),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none placeholder-gray-400",required:!0})]}),_&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Calendar name"}),i.jsx("input",{type:"text",placeholder:"Imported Calendar",value:R,onChange:$=>B($.target.value),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none placeholder-gray-400"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Color"}),i.jsx("input",{type:"color",value:Z,onChange:$=>A($.target.value),className:"w-full h-10 rounded-lg border border-gray-200 dark:border-gray-600 cursor-pointer"})]})]}),!_&&M.length>1&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Import into"}),i.jsx("select",{value:k,onChange:$=>D($.target.value),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none",children:M.map($=>i.jsx("option",{value:$.id,children:$.name},$.id))})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[i.jsx("button",{type:"button",onClick:j,className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:"Cancel"}),i.jsx("button",{type:"submit",disabled:w||!H.trim(),className:"px-4 py-2 text-sm text-white bg-blue-600 hover:bg-blue-700 disabled:opacity-50 rounded-lg transition-colors font-medium",children:w?"Adding...":_?"Create calendar":"Import"})]})]})})}function th({selectedDate:f,onDateSelect:j}){const[O,r]=N.useState(f),M=Us(O),_=Hs(O),H=Ba(M),Y=Un(_),R=J0({start:H,end:Y});return i.jsxs("div",{className:"select-none",children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("button",{onClick:()=>r(B=>I0(B)),className:"p-1 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-500 dark:text-gray-400 transition-colors",children:i.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),i.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:Oe(O,"MMMM yyyy")}),i.jsx("button",{onClick:()=>r(B=>P0(B,1)),className:"p-1 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-500 dark:text-gray-400 transition-colors",children:i.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]}),i.jsxs("div",{className:"grid grid-cols-7 gap-0",children:[["Su","Mo","Tu","We","Th","Fr","Sa"].map(B=>i.jsx("div",{className:"text-center text-[10px] font-medium text-gray-400 dark:text-gray-500 py-1",children:B},B)),R.map(B=>{const Z=W0(B,O),A=_l(B,f),k=ui(B);return i.jsx("button",{onClick:()=>j(B),className:`text-[11px] w-7 h-7 rounded-full flex items-center justify-center mx-auto transition-colors ${Z?"text-gray-700 dark:text-gray-300":"text-gray-300 dark:text-gray-600"} ${A?"bg-blue-600 text-white! font-semibold":""} ${k&&!A?"bg-blue-100 dark:bg-blue-900/40 text-blue-600 dark:text-blue-400 font-semibold":""} ${A?"":"hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:Oe(B,"d")},B.toISOString())})]})]})}function lh(){var ul,qt,Ct;const{user:f,logout:j}=Ya(),{theme:O,toggle:r}=ii(),[M,_]=N.useState(new Date),[H,Y]=N.useState("month"),[R,B]=N.useState([]),[Z,A]=N.useState([]),[k,D]=N.useState(new Set),[w,T]=N.useState(!0),[U,J]=N.useState(!1),[P,ee]=N.useState(!1),[$,xe]=N.useState(!1),[ge,Ne]=N.useState(null),[Te,W]=N.useState(null),[Ae,He]=N.useState(),[ke,Qe]=N.useState(!1),[Ve,Re]=N.useState(!0),b=N.useCallback(async()=>{try{const ze=(await Se.listCalendars()).items||[];B(ze),D(Pe=>{if(Pe.size===0)return new Set(ze.map(lt=>lt.id));const Yt=new Set(Pe);for(const lt of ze)Pe.has(lt.id)||Yt.add(lt.id);return Yt})}catch{}},[]),C=N.useCallback(async()=>{const V=H==="month"?Ba(Us(M)):H==="week"?Ba(M):M,ze=H==="month"?Un(Hs(M)):H==="week"?Un(M):M,Pe=new Date(V);Pe.setDate(Pe.getDate()-1);const Yt=new Date(ze);Yt.setDate(Yt.getDate()+1);try{const lt=await Se.listEvents({start:Pe.toISOString(),end:Yt.toISOString()});A(lt.items||[])}catch{}Re(!1)},[M,H]);N.useEffect(()=>{b()},[b]),N.useEffect(()=>{R.length>0&&C()},[C,R]);const Q=V=>{_(H==="month"?ze=>V===1?P0(ze,1):I0(ze):H==="week"?ze=>V===1?Cg(ze,1):_g(ze):ze=>V===1?$0(ze,1):Dg(ze))},se=()=>_(new Date),ie=V=>{D(ze=>{const Pe=new Set(ze);return Pe.has(V)?Pe.delete(V):Pe.add(V),Pe})},G=V=>{H==="month"?(_(V),Y("day")):(He(V),Ne(null),J(!0))},te=V=>{He(V),Ne(null),J(!0)},z=V=>{Ne(V),J(!0)},E=()=>{C()},me=()=>{b().then(C)},Ke=H==="month"?Oe(M,"MMMM yyyy"):H==="week"?`${Oe(Ba(M),"MMM d")} - ${Oe(Un(M),"MMM d, yyyy")}`:Oe(M,"EEEE, MMMM d, yyyy");return i.jsxs("div",{className:"h-full flex flex-col bg-white dark:bg-gray-900 transition-colors",children:[i.jsxs("header",{className:"flex items-center justify-between px-4 py-2.5 border-b border-gray-200 dark:border-gray-700 flex-shrink-0 bg-white dark:bg-gray-900",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("button",{onClick:()=>T(V=>!V),className:"p-2 rounded-xl hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-600 dark:text-gray-400 transition-colors lg:hidden",children:i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),i.jsx("button",{onClick:()=>T(V=>!V),className:"p-2 rounded-xl hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-600 dark:text-gray-400 transition-colors hidden lg:block",children:i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"w-8 h-8 bg-blue-600 rounded-lg flex items-center justify-center",children:i.jsx("svg",{className:"w-5 h-5 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),i.jsx("span",{className:"text-lg font-bold text-gray-900 dark:text-white hidden sm:block",children:"Calendar"})]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:se,className:"px-3 py-1.5 text-sm font-medium border border-gray-300 dark:border-gray-600 rounded-lg text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:"Today"}),i.jsxs("div",{className:"flex items-center",children:[i.jsx("button",{onClick:()=>Q(-1),className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-600 dark:text-gray-400 transition-colors",children:i.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),i.jsx("button",{onClick:()=>Q(1),className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-600 dark:text-gray-400 transition-colors",children:i.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]}),i.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-white min-w-[180px] text-center hidden sm:block",children:Ke})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"hidden sm:flex items-center bg-gray-100 dark:bg-gray-800 rounded-lg p-0.5",children:["month","week","day"].map(V=>i.jsx("button",{onClick:()=>Y(V),className:`px-3 py-1 text-xs font-medium rounded-md transition-colors capitalize ${H===V?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,children:V},V))}),i.jsx("button",{onClick:r,className:"p-2 rounded-xl hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-600 dark:text-gray-400 transition-colors",children:O==="dark"?i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"})}):i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"})})}),i.jsxs("div",{className:"relative",children:[i.jsx("button",{onClick:()=>Qe(V=>!V),className:"w-8 h-8 rounded-full bg-gradient-to-br from-blue-500 to-purple-600 flex items-center justify-center text-white text-sm font-semibold",children:((qt=(ul=f==null?void 0:f.email)==null?void 0:ul[0])==null?void 0:qt.toUpperCase())||"U"}),ke&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>Qe(!1)}),i.jsxs("div",{className:"absolute right-0 mt-2 w-56 bg-white dark:bg-gray-800 rounded-xl shadow-lg border border-gray-200 dark:border-gray-700 py-1 z-50 animate-scale-in",children:[i.jsxs("div",{className:"px-4 py-2.5 border-b border-gray-100 dark:border-gray-700",children:[i.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:f==null?void 0:f.email}),i.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:f==null?void 0:f.timezone})]}),i.jsx("button",{onClick:()=>{Qe(!1),j()},className:"w-full text-left px-4 py-2 text-sm text-red-600 dark:text-red-400 hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:"Sign out"})]})]})]})]})]}),i.jsxs("div",{className:"sm:hidden text-center py-2 border-b border-gray-100 dark:border-gray-800 flex-shrink-0",children:[i.jsx("span",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:Ke}),i.jsx("div",{className:"flex items-center justify-center gap-1 mt-1",children:["month","week","day"].map(V=>i.jsx("button",{onClick:()=>Y(V),className:`px-2.5 py-0.5 text-xs font-medium rounded-md transition-colors capitalize ${H===V?"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400":"text-gray-500 dark:text-gray-400"}`,children:V},V))})]}),i.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[w&&i.jsxs("aside",{className:"w-64 border-r border-gray-200 dark:border-gray-700 flex-shrink-0 overflow-y-auto bg-white dark:bg-gray-900 flex flex-col",children:[i.jsx("div",{className:"p-4",children:i.jsxs("button",{onClick:()=>{Ne(null),He(new Date),J(!0)},className:"w-full flex items-center justify-center gap-2 px-4 py-2.5 bg-blue-600 hover:bg-blue-700 text-white rounded-xl font-medium text-sm shadow-lg shadow-blue-600/20 transition-all hover:shadow-blue-600/30",children:[i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"New Event"]})}),i.jsx("div",{className:"px-4 pb-4",children:i.jsx(th,{selectedDate:M,onDateSelect:V=>_(V)})}),i.jsxs("div",{className:"px-4 pb-4 flex-1",children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("h3",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"My Calendars"}),i.jsxs("div",{className:"flex gap-0.5",children:[i.jsx("button",{onClick:()=>xe(!0),className:"p-1 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",title:"Add from URL",children:i.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})})}),i.jsx("button",{onClick:()=>{W(null),ee(!0)},className:"p-1 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",title:"New calendar",children:i.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]})]}),i.jsx("div",{className:"space-y-0.5",children:R.map(V=>i.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-1 rounded-lg group hover:bg-gray-50 dark:hover:bg-gray-800/50",children:[i.jsx("button",{onClick:()=>ie(V.id),className:"flex-shrink-0",children:i.jsx("div",{className:"w-4 h-4 rounded border-2 transition-colors flex items-center justify-center",style:{borderColor:V.color,backgroundColor:k.has(V.id)?V.color:"transparent"},children:k.has(V.id)&&i.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:3,d:"M5 13l4 4L19 7"})})})}),i.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300 flex-1 truncate",children:V.name}),V.role==="owner"&&i.jsx("button",{onClick:()=>{W(V),ee(!0)},className:"p-0.5 rounded opacity-0 group-hover:opacity-100 hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-400 transition-all",children:i.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 5v.01M12 12v.01M12 19v.01M12 6a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2z"})})})]},V.id))})]})]}),i.jsx("main",{className:"flex-1 overflow-hidden",children:Ve?i.jsx("div",{className:"flex items-center justify-center h-full",children:i.jsx("div",{className:"w-8 h-8 border-2 border-blue-600 border-t-transparent rounded-full animate-spin"})}):H==="month"?i.jsx(Jg,{currentDate:M,events:Z,calendars:R,visibleCalendarIds:k,onDateClick:G,onEventClick:z}):H==="week"?i.jsx(Wg,{currentDate:M,events:Z,calendars:R,visibleCalendarIds:k,onTimeClick:te,onEventClick:z}):i.jsx($g,{currentDate:M,events:Z,calendars:R,visibleCalendarIds:k,onTimeClick:te,onEventClick:z})})]}),i.jsx(Fg,{open:U,onClose:()=>J(!1),onSaved:E,event:ge,calendars:R,defaultDate:Ae,defaultCalendarId:(Ct=R.find(V=>V.role==="owner"))==null?void 0:Ct.id}),i.jsx(Pg,{open:P,onClose:()=>ee(!1),onSaved:me,calendar:Te}),i.jsx(eh,{open:$,onClose:()=>xe(!1),onSaved:me,targetCalendarId:null,calendars:R})]})}function ah(){const[f,j]=N.useState([]),[O,r]=N.useState(""),[M,_]=N.useState(!0),[H,Y]=N.useState(!1),[R,B]=N.useState(null),Z=N.useCallback(async()=>{try{const D=await Se.listContacts(O||void 0);j(D.items||[])}finally{_(!1)}},[O]);N.useEffect(()=>{Z()},[Z]);const A=()=>{B(null),Y(!0)},k=D=>{B(D),Y(!0)};return i.jsxs("div",{className:"h-full flex flex-col",children:[i.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:[i.jsx("h1",{className:"text-xl font-bold text-gray-900 dark:text-white",children:"Contacts"}),i.jsxs("button",{onClick:A,className:"flex items-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white text-sm font-medium rounded-xl transition-colors",children:[i.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"Add contact"]})]}),i.jsx("div",{className:"px-6 py-3 border-b border-gray-100 dark:border-gray-700/50 flex-shrink-0",children:i.jsxs("div",{className:"relative",children:[i.jsx("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),i.jsx("input",{type:"text",placeholder:"Search contacts...",value:O,onChange:D=>r(D.target.value),className:"w-full pl-10 pr-4 py-2 rounded-xl border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700/50 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"})]})}),i.jsx("div",{className:"flex-1 overflow-y-auto",children:M?i.jsx("div",{className:"flex items-center justify-center h-40",children:i.jsx("div",{className:"w-6 h-6 border-2 border-blue-600 border-t-transparent rounded-full animate-spin"})}):f.length===0?i.jsxs("div",{className:"flex flex-col items-center justify-center h-40 text-gray-400 dark:text-gray-500",children:[i.jsx("svg",{className:"w-12 h-12 mb-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0z"})}),i.jsx("span",{className:"text-sm",children:"No contacts yet"})]}):i.jsx("div",{className:"divide-y divide-gray-100 dark:divide-gray-700/50",children:f.map(D=>{var w,T;return i.jsxs("button",{onClick:()=>k(D),className:"w-full flex items-center gap-4 px-6 py-3.5 hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors text-left",children:[i.jsx("div",{className:"w-10 h-10 rounded-full bg-gradient-to-br from-blue-500 to-purple-600 flex items-center justify-center text-white font-semibold text-sm flex-shrink-0",children:(((w=D.first_name)==null?void 0:w[0])||((T=D.email)==null?void 0:T[0])||"?").toUpperCase()}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:[D.first_name,D.last_name].filter(Boolean).join(" ")||D.email||"Unnamed"}),i.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:[D.email,D.company].filter(Boolean).join(" - ")})]}),D.phone&&i.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500 flex-shrink-0",children:D.phone})]},D.id)})})}),i.jsx(nh,{open:H,onClose:()=>Y(!1),onSaved:Z,contact:R})]})}function nh({open:f,onClose:j,onSaved:O,contact:r}){const M=!!r,[_,H]=N.useState(""),[Y,R]=N.useState(""),[B,Z]=N.useState(""),[A,k]=N.useState(""),[D,w]=N.useState(""),[T,U]=N.useState(""),[J,P]=N.useState(!1),[ee,$]=N.useState(""),[xe,ge]=N.useState(!1);N.useEffect(()=>{f&&($(""),ge(!1),r?(H(r.first_name||""),R(r.last_name||""),Z(r.email||""),k(r.phone||""),w(r.company||""),U(r.notes||"")):(H(""),R(""),Z(""),k(""),w(""),U("")))},[f,r]);const Ne=async W=>{W.preventDefault(),P(!0),$("");try{const Ae={first_name:_.trim()||void 0,last_name:Y.trim()||void 0,email:B.trim()||void 0,phone:A.trim()||void 0,company:D.trim()||void 0,notes:T.trim()||void 0};M?await Se.updateContact(r.id,Ae):await Se.createContact(Ae),O(),j()}catch(Ae){$(Ae.error||"Failed to save contact")}finally{P(!1)}},Te=async()=>{if(r){P(!0);try{await Se.deleteContact(r.id),O(),j()}catch(W){$(W.error||"Failed to delete")}finally{P(!1)}}};return i.jsx(qa,{open:f,onClose:j,title:M?"Edit Contact":"New Contact",children:i.jsxs("form",{onSubmit:Ne,className:"space-y-4",children:[ee&&i.jsx("div",{className:"text-sm text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/20 px-3 py-2 rounded-lg",children:ee}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"First name"}),i.jsx("input",{type:"text",value:_,onChange:W=>H(W.target.value),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none",autoFocus:!0})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Last name"}),i.jsx("input",{type:"text",value:Y,onChange:W=>R(W.target.value),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Email"}),i.jsx("input",{type:"email",value:B,onChange:W=>Z(W.target.value),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Phone"}),i.jsx("input",{type:"tel",value:A,onChange:W=>k(W.target.value),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Company"}),i.jsx("input",{type:"text",value:D,onChange:W=>w(W.target.value),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Notes"}),i.jsx("textarea",{value:T,onChange:W=>U(W.target.value),rows:2,className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none resize-none"})]}),i.jsxs("div",{className:"flex items-center justify-between pt-2",children:[i.jsxs("div",{children:[M&&!xe&&i.jsx("button",{type:"button",onClick:()=>ge(!0),className:"text-sm text-red-500 hover:text-red-700 dark:hover:text-red-400 transition-colors",children:"Delete"}),M&&xe&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm text-red-500",children:"Delete?"}),i.jsx("button",{type:"button",onClick:Te,className:"text-sm text-white bg-red-500 hover:bg-red-600 px-3 py-1 rounded-lg transition-colors",disabled:J,children:"Yes"}),i.jsx("button",{type:"button",onClick:()=>ge(!1),className:"text-sm text-gray-500 hover:text-gray-700 dark:text-gray-400 transition-colors",children:"No"})]})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{type:"button",onClick:j,className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:"Cancel"}),i.jsx("button",{type:"submit",disabled:J,className:"px-4 py-2 text-sm text-white bg-blue-600 hover:bg-blue-700 disabled:opacity-50 rounded-lg transition-colors font-medium",children:J?"Saving...":M?"Update":"Create"})]})]})]})})}const uh=[{key:"calendars",label:"Calendars",permissions:["read","write"]},{key:"events",label:"Events",permissions:["read","write"]},{key:"contacts",label:"Contacts",permissions:["read","write"]},{key:"availability",label:"Availability",permissions:["read"]},{key:"booking",label:"Booking",permissions:["write"]}];function ih(){const{user:f,loading:j,refreshUser:O,logout:r}=Ya(),{theme:M,toggle:_}=ii(),H=Ds(),[Y,R]=N.useState("general"),[B,Z]=N.useState(!1),[A,k]=N.useState(""),[D,w]=N.useState({}),[T,U]=N.useState([]),[J,P]=N.useState(!1),[ee,$]=N.useState(!1),[xe,ge]=N.useState(""),[Ne,Te]=N.useState({calendars:["read","write"],events:["read","write"],contacts:["read","write"],availability:["read"],booking:["write"]}),[W,Ae]=N.useState(null),[He,ke]=N.useState(null),[Qe,Ve]=N.useState(""),[Re,b]=N.useState(!1);N.useEffect(()=>{f&&w({timezone:f.timezone,week_start_day:f.week_start_day,date_format:f.date_format,time_format:f.time_format,default_event_duration_minutes:f.default_event_duration_minutes,default_reminder_minutes:f.default_reminder_minutes,show_weekends:f.show_weekends,working_hours_start:f.working_hours_start,working_hours_end:f.working_hours_end,notifications_email:f.notifications_email})},[f]),N.useEffect(()=>{Y==="api-keys"&&(P(!0),Se.listApiKeys().then(z=>U(z.items)).catch(()=>k("Failed to load API keys")).finally(()=>P(!1)))},[Y]);const C=async()=>{Z(!0),k("");try{const z=await Se.updateMe(D);await O(),k("Settings saved"),setTimeout(()=>k(""),2e3)}catch(z){k(z.error||"Failed to save")}finally{Z(!1)}},Q=async()=>{if(!xe.trim()){k("Name is required");return}Z(!0),k("");try{const z=await Se.createApiKey({name:xe.trim(),scopes:Ne});Ae(z),U(E=>[z,...E]),$(!1),ge("")}catch(z){k(z.error||"Failed to create API key")}finally{Z(!1)}},se=async z=>{ke(z);try{await Se.revokeApiKey(z),U(E=>E.map(me=>me.id===z?{...me,revoked_at:new Date().toISOString()}:me))}catch(E){k(E.error||"Failed to revoke")}finally{ke(null)}},ie=async()=>{if(Qe==="delete"){b(!0),k("");try{await Se.deleteMe(),await r(),H("/login")}catch(z){k(z.error||"Failed to delete account")}finally{b(!1)}}},G=()=>{W!=null&&W.token&&(navigator.clipboard.writeText(W.token),k("Token copied to clipboard"),setTimeout(()=>k(""),2e3))};if(j||!f)return null;const te=[{id:"general",label:"General"},{id:"calendars",label:"Calendars"},{id:"notifications",label:"Notifications"},{id:"api-keys",label:"API Keys"},{id:"account",label:"Account"}];return i.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[i.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[i.jsx("h1",{className:"text-xl font-bold text-gray-900 dark:text-white",children:"Settings"}),i.jsx("button",{onClick:_,className:"p-2 rounded-xl hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-400 transition-colors",children:M==="dark"?i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"})}):i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"})})})]}),i.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[i.jsx("nav",{className:"w-48 border-r border-gray-200 dark:border-gray-700 p-4 flex-shrink-0",children:te.map(z=>i.jsx("button",{onClick:()=>R(z.id),className:`block w-full text-left px-3 py-2 rounded-lg text-sm font-medium transition-colors ${Y===z.id?"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400":"text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800"}`,children:z.label},z.id))}),i.jsxs("main",{className:"flex-1 overflow-y-auto p-6",children:[A&&i.jsx("div",{className:`mb-4 px-4 py-2 rounded-lg text-sm ${A==="Settings saved"||A==="Token copied to clipboard"?"bg-green-50 dark:bg-green-900/20 text-green-700 dark:text-green-400":"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400"}`,children:A}),Y==="general"&&i.jsxs("div",{className:"space-y-6 max-w-xl",children:[i.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"General"}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Timezone"}),i.jsx("input",{type:"text",value:D.timezone||"",onChange:z=>w(E=>({...E,timezone:z.target.value})),placeholder:"America/New_York",className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Week starts on"}),i.jsxs("select",{value:D.week_start_day??0,onChange:z=>w(E=>({...E,week_start_day:parseInt(z.target.value,10)})),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none",children:[i.jsx("option",{value:0,children:"Sunday"}),i.jsx("option",{value:1,children:"Monday"})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Date format"}),i.jsxs("select",{value:D.date_format||"MM/dd/yyyy",onChange:z=>w(E=>({...E,date_format:z.target.value})),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none",children:[i.jsx("option",{value:"MM/dd/yyyy",children:"MM/DD/YYYY"}),i.jsx("option",{value:"dd/MM/yyyy",children:"DD/MM/YYYY"}),i.jsx("option",{value:"yyyy-MM-dd",children:"YYYY-MM-DD"})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Time format"}),i.jsxs("select",{value:D.time_format||"12h",onChange:z=>w(E=>({...E,time_format:z.target.value})),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none",children:[i.jsx("option",{value:"12h",children:"12-hour"}),i.jsx("option",{value:"24h",children:"24-hour"})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Default event duration (minutes)"}),i.jsx("input",{type:"number",min:15,max:480,value:D.default_event_duration_minutes??60,onChange:z=>w(E=>({...E,default_event_duration_minutes:parseInt(z.target.value,10)||60})),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Default reminder (minutes before)"}),i.jsx("input",{type:"number",min:0,max:10080,value:D.default_reminder_minutes??10,onChange:z=>w(E=>({...E,default_reminder_minutes:parseInt(z.target.value,10)||10})),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"checkbox",id:"show_weekends",checked:D.show_weekends??!0,onChange:z=>w(E=>({...E,show_weekends:z.target.checked})),className:"rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"}),i.jsx("label",{htmlFor:"show_weekends",className:"text-sm text-gray-700 dark:text-gray-300",children:"Show weekends"})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Working hours start"}),i.jsx("input",{type:"time",value:D.working_hours_start||"09:00",onChange:z=>w(E=>({...E,working_hours_start:z.target.value})),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Working hours end"}),i.jsx("input",{type:"time",value:D.working_hours_end||"17:00",onChange:z=>w(E=>({...E,working_hours_end:z.target.value})),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"})]})]})]}),Y==="calendars"&&i.jsxs("div",{className:"space-y-4",children:[i.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Calendars"}),i.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Manage your calendars from the main calendar view. Use the sidebar to add new calendars or add from URL."})]}),Y==="notifications"&&i.jsxs("div",{className:"space-y-6 max-w-xl",children:[i.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Notifications"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"checkbox",id:"notifications_email",checked:D.notifications_email??!0,onChange:z=>w(E=>({...E,notifications_email:z.target.checked})),className:"rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"}),i.jsx("label",{htmlFor:"notifications_email",className:"text-sm text-gray-700 dark:text-gray-300",children:"Email reminders for events"})]})]}),Y==="api-keys"&&i.jsxs("div",{className:"space-y-6 max-w-2xl",children:[i.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"API Keys"}),i.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"API keys allow programmatic access to your calendar. Use them for integrations, scripts, or AI agents. Keep keys secure and never share them."}),i.jsxs("div",{className:"flex justify-between items-center",children:[i.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:[T.length," key",T.length!==1?"s":""]}),i.jsx("button",{onClick:()=>{$(!0),Ae(null),k("")},className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white text-sm font-medium rounded-lg transition-colors",children:"Create API key"})]}),J?i.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[i.jsx("span",{className:"w-4 h-4 border-2 border-gray-400 border-t-transparent rounded-full animate-spin"}),"Loading..."]}):i.jsx("div",{className:"space-y-6 max-w-2xl",children:T.length===0?i.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 py-4",children:"No API keys yet. Create one to get started."}):i.jsx("ul",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:T.map(z=>i.jsxs("li",{className:"py-4 flex items-center justify-between gap-4",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("p",{className:"font-medium text-gray-900 dark:text-white truncate",children:z.name}),i.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:["Created ",new Date(z.created_at).toLocaleDateString(),z.revoked_at&&i.jsx("span",{className:"ml-2 text-amber-600 dark:text-amber-400",children:"• Revoked"})]})]}),!z.revoked_at&&i.jsx("button",{onClick:()=>se(z.id),disabled:He===z.id,className:"px-3 py-1.5 text-sm text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg transition-colors disabled:opacity-50",children:He===z.id?"Revoking...":"Revoke"})]},z.id))})})]}),Y==="account"&&i.jsxs("div",{className:"space-y-6 max-w-xl",children:[i.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Account"}),i.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-600 p-4 dark:bg-gray-800/50",children:[i.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-2",children:["Signed in as ",i.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:f.email})]}),i.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Account created ",new Date(f.created_at).toLocaleDateString()]})]}),i.jsxs("div",{className:"pt-6 border-t border-gray-200 dark:border-gray-700",children:[i.jsx("h3",{className:"text-sm font-medium text-red-600 dark:text-red-400 mb-2",children:"Danger zone"}),i.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:"Deleting your account will permanently remove all your calendars, events, contacts, and revoke all API keys. This action cannot be undone."}),i.jsxs("div",{className:"flex flex-wrap items-end gap-4",children:[i.jsxs("div",{className:"flex-1 min-w-[200px]",children:[i.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Type ",i.jsx("span",{className:"font-mono text-red-600 dark:text-red-400",children:"delete"})," to confirm"]}),i.jsx("input",{type:"text",value:Qe,onChange:z=>Ve(z.target.value),placeholder:"delete",className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-red-500 outline-none placeholder:text-gray-400"})]}),i.jsx("button",{onClick:ie,disabled:Qe!=="delete"||Re,className:"px-4 py-2 bg-red-600 hover:bg-red-700 disabled:opacity-50 disabled:cursor-not-allowed text-white text-sm font-medium rounded-lg transition-colors",children:Re?"Deleting...":"Delete account"})]})]})]}),(Y==="general"||Y==="notifications")&&i.jsx("div",{className:"mt-8",children:i.jsx("button",{onClick:C,disabled:B,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 disabled:opacity-50 text-white text-sm font-medium rounded-lg transition-colors",children:B?"Saving...":"Save changes"})})]})]}),i.jsx(qa,{open:ee,onClose:()=>{$(!1),ge("")},title:"Create API key",wide:!0,children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Name"}),i.jsx("input",{type:"text",value:xe,onChange:z=>ge(z.target.value),placeholder:"e.g. My integration",className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Scopes"}),i.jsx("div",{className:"space-y-3",children:uh.map(({key:z,label:E,permissions:me})=>i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx("span",{className:"w-28 text-sm text-gray-600 dark:text-gray-400",children:E}),i.jsx("div",{className:"flex gap-4",children:me.map(Ke=>{const qt=(Ne[z]||[]).includes(Ke);return i.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:qt,onChange:Ct=>{const V=Ct.target.checked?[...Ne[z]||[],Ke]:(Ne[z]||[]).filter(ze=>ze!==Ke);Te(ze=>({...ze,[z]:V}))},className:"rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"}),i.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300 capitalize",children:Ke})]},Ke)})})]},z))})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[i.jsx("button",{onClick:()=>$(!1),className:"px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:"Cancel"}),i.jsx("button",{onClick:Q,disabled:B||!xe.trim(),className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 disabled:opacity-50 text-white text-sm font-medium rounded-lg transition-colors",children:B?"Creating...":"Create"})]})]})}),i.jsx(qa,{open:!!(W!=null&&W.token),onClose:()=>Ae(null),title:"API key created",children:i.jsxs("div",{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-amber-600 dark:text-amber-400",children:"Copy this token now. It will not be shown again."}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"text",readOnly:!0,value:(W==null?void 0:W.token)||"",className:"flex-1 px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-100 dark:bg-gray-700 text-sm font-mono text-gray-900 dark:text-white"}),i.jsx("button",{onClick:G,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white text-sm font-medium rounded-lg transition-colors",children:"Copy"})]}),i.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Use in requests: ",i.jsx("code",{className:"bg-gray-100 dark:bg-gray-700 px-1 rounded",children:"X-API-Key: "})]}),i.jsx("div",{className:"flex justify-end",children:i.jsx("button",{onClick:()=>Ae(null),className:"px-4 py-2 bg-gray-200 dark:bg-gray-600 hover:bg-gray-300 dark:hover:bg-gray-500 text-gray-900 dark:text-white text-sm font-medium rounded-lg transition-colors",children:"Done"})})]})})]})}function ch(){const{user:f,loading:j}=Ya();return j?i.jsx("div",{className:"h-screen flex items-center justify-center bg-white dark:bg-gray-900",children:i.jsx("div",{className:"w-8 h-8 border-2 border-blue-600 border-t-transparent rounded-full animate-spin"})}):f?i.jsx(ws,{}):i.jsx(Os,{to:"/login",replace:!0})}function sh(){const{user:f,loading:j}=Ya();return j?i.jsx("div",{className:"h-screen flex items-center justify-center bg-white dark:bg-gray-900",children:i.jsx("div",{className:"w-8 h-8 border-2 border-blue-600 border-t-transparent rounded-full animate-spin"})}):f?i.jsx(Os,{to:"/",replace:!0}):i.jsx(ws,{})}function rh(){return i.jsxs("div",{className:"h-screen flex bg-white dark:bg-gray-900 transition-colors",children:[i.jsxs("nav",{className:"w-14 flex-shrink-0 flex flex-col items-center py-4 gap-1 border-r border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",children:[i.jsx(ks,{to:"/",end:!0,className:({isActive:f})=>`p-2.5 rounded-xl transition-colors ${f?"bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400":"text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 hover:text-gray-700 dark:hover:text-gray-300"}`,title:"Calendar",children:i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),i.jsx(ks,{to:"/contacts",className:({isActive:f})=>`p-2.5 rounded-xl transition-colors ${f?"bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400":"text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 hover:text-gray-700 dark:hover:text-gray-300"}`,title:"Contacts",children:i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0z"})})}),i.jsx(ks,{to:"/settings",className:({isActive:f})=>`p-2.5 rounded-xl transition-colors ${f?"bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400":"text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 hover:text-gray-700 dark:hover:text-gray-300"}`,title:"Settings",children:i.jsxs("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})]}),i.jsx("div",{className:"flex-1 overflow-hidden",children:i.jsx(ws,{})})]})}function fh(){return i.jsxs(Tg,{children:[i.jsxs(nl,{element:i.jsx(sh,{}),children:[i.jsx(nl,{path:"/login",element:i.jsx(Vg,{})}),i.jsx(nl,{path:"/register",element:i.jsx(Kg,{})})]}),i.jsx(nl,{element:i.jsx(ch,{}),children:i.jsxs(nl,{element:i.jsx(rh,{}),children:[i.jsx(nl,{path:"/",element:i.jsx(lh,{})}),i.jsx(nl,{path:"/contacts",element:i.jsx(ah,{})}),i.jsx(nl,{path:"/settings",element:i.jsx(ih,{})})]})}),i.jsx(nl,{path:"*",element:i.jsx(Os,{to:"/",replace:!0})})]})}Yg.createRoot(document.getElementById("root")).render(i.jsx(N.StrictMode,{children:i.jsx(Zg,{children:i.jsx(Ag,{children:i.jsx(Xg,{children:i.jsx(Gg,{children:i.jsx(fh,{})})})})})}));