var By=t=>{throw TypeError(t)};var Zh=(t,e,n)=>e.has(t)||By("Cannot "+n);var z=(t,e,n)=>(Zh(t,e,"read from private field"),n?n.call(t):e.get(t)),Ee=(t,e,n)=>e.has(t)?By("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),pe=(t,e,n,r)=>(Zh(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),Pe=(t,e,n)=>(Zh(t,e,"access private method"),n);var id=(t,e,n,r)=>({set _(i){pe(t,e,i,n)},get _(){return z(t,e,r)}});(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const c of i)if(c.type==="childList")for(const d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&r(d)}).observe(document,{childList:!0,subtree:!0});function n(i){const c={};return i.integrity&&(c.integrity=i.integrity),i.referrerPolicy&&(c.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?c.credentials="include":i.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function r(i){if(i.ep)return;i.ep=!0;const c=n(i);fetch(i.href,c)}})();function RN(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Kh={exports:{}},Yi={};/** * @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 Hy;function Y2(){if(Hy)return Yi;Hy=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,c){var d=null;if(c!==void 0&&(d=""+c),i.key!==void 0&&(d=""+i.key),"key"in i){c={};for(var f in i)f!=="key"&&(c[f]=i[f])}else c=i;return i=c.ref,{$$typeof:t,type:r,key:d,ref:i!==void 0?i:null,props:c}}return Yi.Fragment=e,Yi.jsx=n,Yi.jsxs=n,Yi}var Gy;function Q2(){return Gy||(Gy=1,Kh.exports=Y2()),Kh.exports}var s=Q2(),Jh={exports:{}},De={};/** * @license React * react.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 Vy;function W2(){if(Vy)return De;Vy=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),d=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),m=Symbol.iterator;function v(T){return T===null||typeof T!="object"?null:(T=m&&T[m]||T["@@iterator"],typeof T=="function"?T:null)}var N={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,j={};function R(T,X,ie){this.props=T,this.context=X,this.refs=j,this.updater=ie||N}R.prototype.isReactComponent={},R.prototype.setState=function(T,X){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,X,"setState")},R.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function C(){}C.prototype=R.prototype;function O(T,X,ie){this.props=T,this.context=X,this.refs=j,this.updater=ie||N}var A=O.prototype=new C;A.constructor=O,S(A,R.prototype),A.isPureReactComponent=!0;var k=Array.isArray;function _(){}var B={H:null,A:null,T:null,S:null},F=Object.prototype.hasOwnProperty;function G(T,X,ie){var de=ie.ref;return{$$typeof:t,type:T,key:X,ref:de!==void 0?de:null,props:ie}}function ee(T,X){return G(T.type,X,T.props)}function ne(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function oe(T){var X={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(ie){return X[ie]})}var Q=/\/+/g;function ce(T,X){return typeof T=="object"&&T!==null&&T.key!=null?oe(""+T.key):X.toString(36)}function he(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(_,_):(T.status="pending",T.then(function(X){T.status==="pending"&&(T.status="fulfilled",T.value=X)},function(X){T.status==="pending"&&(T.status="rejected",T.reason=X)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function H(T,X,ie,de,ve){var je=typeof T;(je==="undefined"||je==="boolean")&&(T=null);var Te=!1;if(T===null)Te=!0;else switch(je){case"bigint":case"string":case"number":Te=!0;break;case"object":switch(T.$$typeof){case t:case e:Te=!0;break;case b:return Te=T._init,H(Te(T._payload),X,ie,de,ve)}}if(Te)return ve=ve(T),Te=de===""?"."+ce(T,0):de,k(ve)?(ie="",Te!=null&&(ie=Te.replace(Q,"$&/")+"/"),H(ve,X,ie,"",function(It){return It})):ve!=null&&(ne(ve)&&(ve=ee(ve,ie+(ve.key==null||T&&T.key===ve.key?"":(""+ve.key).replace(Q,"$&/")+"/")+Te)),X.push(ve)),1;Te=0;var bt=de===""?".":de+":";if(k(T))for(var Ue=0;Ue>>1,te=H[W];if(0>>1;Wi(ie,P))dei(ve,ie)?(H[W]=ve,H[de]=P,W=de):(H[W]=ie,H[X]=P,W=X);else if(dei(ve,P))H[W]=ve,H[de]=P,W=de;else break e}}return V}function i(H,V){var P=H.sortIndex-V.sortIndex;return P!==0?P:H.id-V.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;t.unstable_now=function(){return c.now()}}else{var d=Date,f=d.now();t.unstable_now=function(){return d.now()-f}}var h=[],p=[],b=1,y=null,m=3,v=!1,N=!1,S=!1,j=!1,R=typeof setTimeout=="function"?setTimeout:null,C=typeof clearTimeout=="function"?clearTimeout:null,O=typeof setImmediate<"u"?setImmediate:null;function A(H){for(var V=n(p);V!==null;){if(V.callback===null)r(p);else if(V.startTime<=H)r(p),V.sortIndex=V.expirationTime,e(h,V);else break;V=n(p)}}function k(H){if(S=!1,A(H),!N)if(n(h)!==null)N=!0,_||(_=!0,oe());else{var V=n(p);V!==null&&he(k,V.startTime-H)}}var _=!1,B=-1,F=5,G=-1;function ee(){return j?!0:!(t.unstable_now()-GH&&ee());){var W=y.callback;if(typeof W=="function"){y.callback=null,m=y.priorityLevel;var te=W(y.expirationTime<=H);if(H=t.unstable_now(),typeof te=="function"){y.callback=te,A(H),V=!0;break t}y===n(h)&&r(h),A(H)}else r(h);y=n(h)}if(y!==null)V=!0;else{var T=n(p);T!==null&&he(k,T.startTime-H),V=!1}}break e}finally{y=null,m=P,v=!1}V=void 0}}finally{V?oe():_=!1}}}var oe;if(typeof O=="function")oe=function(){O(ne)};else if(typeof MessageChannel<"u"){var Q=new MessageChannel,ce=Q.port2;Q.port1.onmessage=ne,oe=function(){ce.postMessage(null)}}else oe=function(){R(ne,0)};function he(H,V){B=R(function(){H(t.unstable_now())},V)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(H){H.callback=null},t.unstable_forceFrameRate=function(H){0>H||125W?(H.sortIndex=P,e(p,H),n(h)===null&&H===n(p)&&(S?(C(B),B=-1):S=!0,he(k,P-W))):(H.sortIndex=te,e(h,H),N||v||(N=!0,_||(_=!0,oe()))),H},t.unstable_shouldYield=ee,t.unstable_wrapCallback=function(H){var V=m;return function(){var P=m;m=V;try{return H.apply(this,arguments)}finally{m=P}}}})(np)),np}var $y;function Z2(){return $y||($y=1,tp.exports=X2()),tp.exports}var ap={exports:{}},Vt={};/** * @license React * react-dom.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 Yy;function K2(){if(Yy)return Vt;Yy=1;var t=pu();function e(h){var p="https://react.dev/errors/"+h;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),ap.exports=K2(),ap.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 Wy;function J2(){if(Wy)return Qi;Wy=1;var t=Z2(),e=pu(),n=TN();function r(a){var l="https://react.dev/errors/"+a;if(1te||(a.current=W[te],W[te]=null,te--)}function ie(a,l){te++,W[te]=a.current,a.current=l}var de=T(null),ve=T(null),je=T(null),Te=T(null);function bt(a,l){switch(ie(je,l),ie(ve,a),ie(de,null),l.nodeType){case 9:case 11:a=(a=l.documentElement)&&(a=a.namespaceURI)?cy(a):0;break;default:if(a=l.tagName,l=l.namespaceURI)l=cy(l),a=dy(l,a);else switch(a){case"svg":a=1;break;case"math":a=2;break;default:a=0}}X(de),ie(de,a)}function Ue(){X(de),X(ve),X(je)}function It(a){a.memoizedState!==null&&ie(Te,a);var l=de.current,o=dy(l,a.type);l!==o&&(ie(ve,a),ie(de,o))}function Rn(a){ve.current===a&&(X(de),X(ve)),Te.current===a&&(X(Te),Vi._currentValue=P)}var ue,Oe;function Ce(a){if(ue===void 0)try{throw Error()}catch(o){var l=o.stack.trim().match(/\n( *(at )?)/);ue=l&&l[1]||"",Oe=-1)":-1g||M[u]!==$[g]){var ae=` `+M[u].replace(" at new "," at ");return a.displayName&&ae.includes("")&&(ae=ae.replace("",a.displayName)),ae}while(1<=u&&0<=g);break}}}finally{yt=!1,Error.prepareStackTrace=o}return(o=a?a.displayName||a.name:"")?Ce(o):""}function jA(a,l){switch(a.tag){case 26:case 27:case 5:return Ce(a.type);case 16:return Ce("Lazy");case 13:return a.child!==l&&l!==null?Ce("Suspense Fallback"):Ce("Suspense");case 19:return Ce("SuspenseList");case 0:case 15:return Yn(a.type,!1);case 11:return Yn(a.type.render,!1);case 1:return Yn(a.type,!0);case 31:return Ce("Activity");default:return""}}function Bm(a){try{var l="",o=null;do l+=jA(a,o),o=a,a=a.return;while(a);return l}catch(u){return` Error generating stack: `+u.message+` `+u.stack}}var Iu=Object.prototype.hasOwnProperty,Lu=t.unstable_scheduleCallback,zu=t.unstable_cancelCallback,AA=t.unstable_shouldYield,wA=t.unstable_requestPaint,dn=t.unstable_now,CA=t.unstable_getCurrentPriorityLevel,Hm=t.unstable_ImmediatePriority,Gm=t.unstable_UserBlockingPriority,Fo=t.unstable_NormalPriority,DA=t.unstable_LowPriority,Vm=t.unstable_IdlePriority,OA=t.log,RA=t.unstable_setDisableYieldValue,ti=null,un=null;function $a(a){if(typeof OA=="function"&&RA(a),un&&typeof un.setStrictMode=="function")try{un.setStrictMode(ti,a)}catch{}}var fn=Math.clz32?Math.clz32:_A,TA=Math.log,kA=Math.LN2;function _A(a){return a>>>=0,a===0?32:31-(TA(a)/kA|0)|0}var qo=256,$o=262144,Yo=4194304;function Gs(a){var l=a&42;if(l!==0)return l;switch(a&-a){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 a&261888;case 262144:case 524288:case 1048576:case 2097152:return a&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return a&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return a}}function Qo(a,l,o){var u=a.pendingLanes;if(u===0)return 0;var g=0,x=a.suspendedLanes,E=a.pingedLanes;a=a.warmLanes;var D=u&134217727;return D!==0?(u=D&~x,u!==0?g=Gs(u):(E&=D,E!==0?g=Gs(E):o||(o=D&~a,o!==0&&(g=Gs(o))))):(D=u&~x,D!==0?g=Gs(D):E!==0?g=Gs(E):o||(o=u&~a,o!==0&&(g=Gs(o)))),g===0?0:l!==0&&l!==g&&(l&x)===0&&(x=g&-g,o=l&-l,x>=o||x===32&&(o&4194048)!==0)?l:g}function ni(a,l){return(a.pendingLanes&~(a.suspendedLanes&~a.pingedLanes)&l)===0}function MA(a,l){switch(a){case 1:case 2:case 4:case 8:case 64:return l+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 l+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 Fm(){var a=Yo;return Yo<<=1,(Yo&62914560)===0&&(Yo=4194304),a}function Pu(a){for(var l=[],o=0;31>o;o++)l.push(a);return l}function ai(a,l){a.pendingLanes|=l,l!==268435456&&(a.suspendedLanes=0,a.pingedLanes=0,a.warmLanes=0)}function IA(a,l,o,u,g,x){var E=a.pendingLanes;a.pendingLanes=o,a.suspendedLanes=0,a.pingedLanes=0,a.warmLanes=0,a.expiredLanes&=o,a.entangledLanes&=o,a.errorRecoveryDisabledLanes&=o,a.shellSuspendCounter=0;var D=a.entanglements,M=a.expirationTimes,$=a.hiddenUpdates;for(o=E&~o;0"u")return null;try{return a.activeElement||a.body}catch{return a.body}}var HA=/[\n"\\]/g;function kn(a){return a.replace(HA,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function Fu(a,l,o,u,g,x,E,D){a.name="",E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"?a.type=E:a.removeAttribute("type"),l!=null?E==="number"?(l===0&&a.value===""||a.value!=l)&&(a.value=""+Tn(l)):a.value!==""+Tn(l)&&(a.value=""+Tn(l)):E!=="submit"&&E!=="reset"||a.removeAttribute("value"),l!=null?qu(a,E,Tn(l)):o!=null?qu(a,E,Tn(o)):u!=null&&a.removeAttribute("value"),g==null&&x!=null&&(a.defaultChecked=!!x),g!=null&&(a.checked=g&&typeof g!="function"&&typeof g!="symbol"),D!=null&&typeof D!="function"&&typeof D!="symbol"&&typeof D!="boolean"?a.name=""+Tn(D):a.removeAttribute("name")}function ax(a,l,o,u,g,x,E,D){if(x!=null&&typeof x!="function"&&typeof x!="symbol"&&typeof x!="boolean"&&(a.type=x),l!=null||o!=null){if(!(x!=="submit"&&x!=="reset"||l!=null)){Vu(a);return}o=o!=null?""+Tn(o):"",l=l!=null?""+Tn(l):o,D||l===a.value||(a.value=l),a.defaultValue=l}u=u??g,u=typeof u!="function"&&typeof u!="symbol"&&!!u,a.checked=D?a.checked:!!u,a.defaultChecked=!!u,E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"&&(a.name=E),Vu(a)}function qu(a,l,o){l==="number"&&Zo(a.ownerDocument)===a||a.defaultValue===""+o||(a.defaultValue=""+o)}function Ur(a,l,o,u){if(a=a.options,l){l={};for(var g=0;g"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Xu=!1;if(xa)try{var ii={};Object.defineProperty(ii,"passive",{get:function(){Xu=!0}}),window.addEventListener("test",ii,ii),window.removeEventListener("test",ii,ii)}catch{Xu=!1}var Qa=null,Zu=null,Jo=null;function dx(){if(Jo)return Jo;var a,l=Zu,o=l.length,u,g="value"in Qa?Qa.value:Qa.textContent,x=g.length;for(a=0;a=di),mx=" ",xx=!1;function bx(a,l){switch(a){case"keyup":return gw.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function yx(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var Vr=!1;function xw(a,l){switch(a){case"compositionend":return yx(l);case"keypress":return l.which!==32?null:(xx=!0,mx);case"textInput":return a=l.data,a===mx&&xx?null:a;default:return null}}function bw(a,l){if(Vr)return a==="compositionend"||!nf&&bx(a,l)?(a=dx(),Jo=Zu=Qa=null,Vr=!1,a):null;switch(a){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:o,offset:l-a};a=u}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=Cx(o)}}function Ox(a,l){return a&&l?a===l?!0:a&&a.nodeType===3?!1:l&&l.nodeType===3?Ox(a,l.parentNode):"contains"in a?a.contains(l):a.compareDocumentPosition?!!(a.compareDocumentPosition(l)&16):!1:!1}function Rx(a){a=a!=null&&a.ownerDocument!=null&&a.ownerDocument.defaultView!=null?a.ownerDocument.defaultView:window;for(var l=Zo(a.document);l instanceof a.HTMLIFrameElement;){try{var o=typeof l.contentWindow.location.href=="string"}catch{o=!1}if(o)a=l.contentWindow;else break;l=Zo(a.document)}return l}function rf(a){var l=a&&a.nodeName&&a.nodeName.toLowerCase();return l&&(l==="input"&&(a.type==="text"||a.type==="search"||a.type==="tel"||a.type==="url"||a.type==="password")||l==="textarea"||a.contentEditable==="true")}var ww=xa&&"documentMode"in document&&11>=document.documentMode,Fr=null,lf=null,pi=null,of=!1;function Tx(a,l,o){var u=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;of||Fr==null||Fr!==Zo(u)||(u=Fr,"selectionStart"in u&&rf(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),pi&&hi(pi,u)||(pi=u,u=$c(lf,"onSelect"),0>=E,g-=E,na=1<<32-fn(l)+g|o<ke?(ze=xe,xe=null):ze=xe.sibling;var Ye=Y(U,xe,q[ke],se);if(Ye===null){xe===null&&(xe=ze);break}a&&xe&&Ye.alternate===null&&l(U,xe),L=x(Ye,L,ke),$e===null?Ne=Ye:$e.sibling=Ye,$e=Ye,xe=ze}if(ke===q.length)return o(U,xe),Be&&ya(U,ke),Ne;if(xe===null){for(;keke?(ze=xe,xe=null):ze=xe.sibling;var ms=Y(U,xe,Ye.value,se);if(ms===null){xe===null&&(xe=ze);break}a&&xe&&ms.alternate===null&&l(U,xe),L=x(ms,L,ke),$e===null?Ne=ms:$e.sibling=ms,$e=ms,xe=ze}if(Ye.done)return o(U,xe),Be&&ya(U,ke),Ne;if(xe===null){for(;!Ye.done;ke++,Ye=q.next())Ye=re(U,Ye.value,se),Ye!==null&&(L=x(Ye,L,ke),$e===null?Ne=Ye:$e.sibling=Ye,$e=Ye);return Be&&ya(U,ke),Ne}for(xe=u(xe);!Ye.done;ke++,Ye=q.next())Ye=K(xe,U,ke,Ye.value,se),Ye!==null&&(a&&Ye.alternate!==null&&xe.delete(Ye.key===null?ke:Ye.key),L=x(Ye,L,ke),$e===null?Ne=Ye:$e.sibling=Ye,$e=Ye);return a&&xe.forEach(function($2){return l(U,$2)}),Be&&ya(U,ke),Ne}function st(U,L,q,se){if(typeof q=="object"&&q!==null&&q.type===S&&q.key===null&&(q=q.props.children),typeof q=="object"&&q!==null){switch(q.$$typeof){case v:e:{for(var Ne=q.key;L!==null;){if(L.key===Ne){if(Ne=q.type,Ne===S){if(L.tag===7){o(U,L.sibling),se=g(L,q.props.children),se.return=U,U=se;break e}}else if(L.elementType===Ne||typeof Ne=="object"&&Ne!==null&&Ne.$$typeof===F&&Js(Ne)===L.type){o(U,L.sibling),se=g(L,q.props),vi(se,q),se.return=U,U=se;break e}o(U,L);break}else l(U,L);L=L.sibling}q.type===S?(se=Qs(q.props.children,U.mode,se,q.key),se.return=U,U=se):(se=cc(q.type,q.key,q.props,null,U.mode,se),vi(se,q),se.return=U,U=se)}return E(U);case N:e:{for(Ne=q.key;L!==null;){if(L.key===Ne)if(L.tag===4&&L.stateNode.containerInfo===q.containerInfo&&L.stateNode.implementation===q.implementation){o(U,L.sibling),se=g(L,q.children||[]),se.return=U,U=se;break e}else{o(U,L);break}else l(U,L);L=L.sibling}se=gf(q,U.mode,se),se.return=U,U=se}return E(U);case F:return q=Js(q),st(U,L,q,se)}if(he(q))return ge(U,L,q,se);if(oe(q)){if(Ne=oe(q),typeof Ne!="function")throw Error(r(150));return q=Ne.call(q),Ae(U,L,q,se)}if(typeof q.then=="function")return st(U,L,mc(q),se);if(q.$$typeof===O)return st(U,L,fc(U,q),se);xc(U,q)}return typeof q=="string"&&q!==""||typeof q=="number"||typeof q=="bigint"?(q=""+q,L!==null&&L.tag===6?(o(U,L.sibling),se=g(L,q),se.return=U,U=se):(o(U,L),se=pf(q,U.mode,se),se.return=U,U=se),E(U)):o(U,L)}return function(U,L,q,se){try{yi=0;var Ne=st(U,L,q,se);return tl=null,Ne}catch(xe){if(xe===el||xe===pc)throw xe;var $e=pn(29,xe,null,U.mode);return $e.lanes=se,$e.return=U,$e}finally{}}}var tr=e0(!0),t0=e0(!1),Ja=!1;function Cf(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Df(a,l){a=a.updateQueue,l.updateQueue===a&&(l.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,callbacks:null})}function es(a){return{lane:a,tag:0,payload:null,callback:null,next:null}}function ts(a,l,o){var u=a.updateQueue;if(u===null)return null;if(u=u.shared,(We&2)!==0){var g=u.pending;return g===null?l.next=l:(l.next=g.next,g.next=l),u.pending=l,l=oc(a),Px(a,null,o),l}return ic(a,u,l,o),oc(a)}function Ni(a,l,o){if(l=l.updateQueue,l!==null&&(l=l.shared,(o&4194048)!==0)){var u=l.lanes;u&=a.pendingLanes,o|=u,l.lanes=o,$m(a,o)}}function Of(a,l){var o=a.updateQueue,u=a.alternate;if(u!==null&&(u=u.updateQueue,o===u)){var g=null,x=null;if(o=o.firstBaseUpdate,o!==null){do{var E={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};x===null?g=x=E:x=x.next=E,o=o.next}while(o!==null);x===null?g=x=l:x=x.next=l}else g=x=l;o={baseState:u.baseState,firstBaseUpdate:g,lastBaseUpdate:x,shared:u.shared,callbacks:u.callbacks},a.updateQueue=o;return}a=o.lastBaseUpdate,a===null?o.firstBaseUpdate=l:a.next=l,o.lastBaseUpdate=l}var Rf=!1;function Ei(){if(Rf){var a=Jr;if(a!==null)throw a}}function Si(a,l,o,u){Rf=!1;var g=a.updateQueue;Ja=!1;var x=g.firstBaseUpdate,E=g.lastBaseUpdate,D=g.shared.pending;if(D!==null){g.shared.pending=null;var M=D,$=M.next;M.next=null,E===null?x=$:E.next=$,E=M;var ae=a.alternate;ae!==null&&(ae=ae.updateQueue,D=ae.lastBaseUpdate,D!==E&&(D===null?ae.firstBaseUpdate=$:D.next=$,ae.lastBaseUpdate=M))}if(x!==null){var re=g.baseState;E=0,ae=$=M=null,D=x;do{var Y=D.lane&-536870913,K=Y!==D.lane;if(K?(Le&Y)===Y:(u&Y)===Y){Y!==0&&Y===Kr&&(Rf=!0),ae!==null&&(ae=ae.next={lane:0,tag:D.tag,payload:D.payload,callback:null,next:null});e:{var ge=a,Ae=D;Y=l;var st=o;switch(Ae.tag){case 1:if(ge=Ae.payload,typeof ge=="function"){re=ge.call(st,re,Y);break e}re=ge;break e;case 3:ge.flags=ge.flags&-65537|128;case 0:if(ge=Ae.payload,Y=typeof ge=="function"?ge.call(st,re,Y):ge,Y==null)break e;re=y({},re,Y);break e;case 2:Ja=!0}}Y=D.callback,Y!==null&&(a.flags|=64,K&&(a.flags|=8192),K=g.callbacks,K===null?g.callbacks=[Y]:K.push(Y))}else K={lane:Y,tag:D.tag,payload:D.payload,callback:D.callback,next:null},ae===null?($=ae=K,M=re):ae=ae.next=K,E|=Y;if(D=D.next,D===null){if(D=g.shared.pending,D===null)break;K=D,D=K.next,K.next=null,g.lastBaseUpdate=K,g.shared.pending=null}}while(!0);ae===null&&(M=re),g.baseState=M,g.firstBaseUpdate=$,g.lastBaseUpdate=ae,x===null&&(g.shared.lanes=0),ls|=E,a.lanes=E,a.memoizedState=re}}function n0(a,l){if(typeof a!="function")throw Error(r(191,a));a.call(l)}function a0(a,l){var o=a.callbacks;if(o!==null)for(a.callbacks=null,a=0;ax?x:8;var E=H.T,D={};H.T=D,Wf(a,!1,l,o);try{var M=g(),$=H.S;if($!==null&&$(D,M),M!==null&&typeof M=="object"&&typeof M.then=="function"){var ae=Iw(M,u);wi(a,l,ae,yn(a))}else wi(a,l,u,yn(a))}catch(re){wi(a,l,{then:function(){},status:"rejected",reason:re},yn())}finally{V.p=x,E!==null&&D.types!==null&&(E.types=D.types),H.T=E}}function Hw(){}function Yf(a,l,o,u){if(a.tag!==5)throw Error(r(476));var g=I0(a).queue;M0(a,g,l,P,o===null?Hw:function(){return L0(a),o(u)})}function I0(a){var l=a.memoizedState;if(l!==null)return l;l={memoizedState:P,baseState:P,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Sa,lastRenderedState:P},next:null};var o={};return l.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Sa,lastRenderedState:o},next:null},a.memoizedState=l,a=a.alternate,a!==null&&(a.memoizedState=l),l}function L0(a){var l=I0(a);l.next===null&&(l=a.alternate.memoizedState),wi(a,l.next.queue,{},yn())}function Qf(){return Pt(Vi)}function z0(){return Nt().memoizedState}function P0(){return Nt().memoizedState}function Gw(a){for(var l=a.return;l!==null;){switch(l.tag){case 24:case 3:var o=yn();a=es(o);var u=ts(l,a,o);u!==null&&(sn(u,l,o),Ni(u,l,o)),l={cache:Sf()},a.payload=l;return}l=l.return}}function Vw(a,l,o){var u=yn();o={lane:u,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Cc(a)?B0(l,o):(o=ff(a,l,o,u),o!==null&&(sn(o,a,u),H0(o,l,u)))}function U0(a,l,o){var u=yn();wi(a,l,o,u)}function wi(a,l,o,u){var g={lane:u,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Cc(a))B0(l,g);else{var x=a.alternate;if(a.lanes===0&&(x===null||x.lanes===0)&&(x=l.lastRenderedReducer,x!==null))try{var E=l.lastRenderedState,D=x(E,o);if(g.hasEagerState=!0,g.eagerState=D,hn(D,E))return ic(a,l,g,0),rt===null&&lc(),!1}catch{}finally{}if(o=ff(a,l,g,u),o!==null)return sn(o,a,u),H0(o,l,u),!0}return!1}function Wf(a,l,o,u){if(u={lane:2,revertLane:Ch(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},Cc(a)){if(l)throw Error(r(479))}else l=ff(a,o,u,2),l!==null&&sn(l,a,2)}function Cc(a){var l=a.alternate;return a===Re||l!==null&&l===Re}function B0(a,l){al=vc=!0;var o=a.pending;o===null?l.next=l:(l.next=o.next,o.next=l),a.pending=l}function H0(a,l,o){if((o&4194048)!==0){var u=l.lanes;u&=a.pendingLanes,o|=u,l.lanes=o,$m(a,o)}}var Ci={readContext:Pt,use:Sc,useCallback:pt,useContext:pt,useEffect:pt,useImperativeHandle:pt,useLayoutEffect:pt,useInsertionEffect:pt,useMemo:pt,useReducer:pt,useRef:pt,useState:pt,useDebugValue:pt,useDeferredValue:pt,useTransition:pt,useSyncExternalStore:pt,useId:pt,useHostTransitionStatus:pt,useFormState:pt,useActionState:pt,useOptimistic:pt,useMemoCache:pt,useCacheRefresh:pt};Ci.useEffectEvent=pt;var G0={readContext:Pt,use:Sc,useCallback:function(a,l){return Yt().memoizedState=[a,l===void 0?null:l],a},useContext:Pt,useEffect:A0,useImperativeHandle:function(a,l,o){o=o!=null?o.concat([a]):null,Ac(4194308,4,O0.bind(null,l,a),o)},useLayoutEffect:function(a,l){return Ac(4194308,4,a,l)},useInsertionEffect:function(a,l){Ac(4,2,a,l)},useMemo:function(a,l){var o=Yt();l=l===void 0?null:l;var u=a();if(nr){$a(!0);try{a()}finally{$a(!1)}}return o.memoizedState=[u,l],u},useReducer:function(a,l,o){var u=Yt();if(o!==void 0){var g=o(l);if(nr){$a(!0);try{o(l)}finally{$a(!1)}}}else g=l;return u.memoizedState=u.baseState=g,a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:g},u.queue=a,a=a.dispatch=Vw.bind(null,Re,a),[u.memoizedState,a]},useRef:function(a){var l=Yt();return a={current:a},l.memoizedState=a},useState:function(a){a=Gf(a);var l=a.queue,o=U0.bind(null,Re,l);return l.dispatch=o,[a.memoizedState,o]},useDebugValue:qf,useDeferredValue:function(a,l){var o=Yt();return $f(o,a,l)},useTransition:function(){var a=Gf(!1);return a=M0.bind(null,Re,a.queue,!0,!1),Yt().memoizedState=a,[!1,a]},useSyncExternalStore:function(a,l,o){var u=Re,g=Yt();if(Be){if(o===void 0)throw Error(r(407));o=o()}else{if(o=l(),rt===null)throw Error(r(349));(Le&127)!==0||c0(u,l,o)}g.memoizedState=o;var x={value:o,getSnapshot:l};return g.queue=x,A0(u0.bind(null,u,x,a),[a]),u.flags|=2048,rl(9,{destroy:void 0},d0.bind(null,u,x,o,l),null),o},useId:function(){var a=Yt(),l=rt.identifierPrefix;if(Be){var o=aa,u=na;o=(u&~(1<<32-fn(u)-1)).toString(32)+o,l="_"+l+"R_"+o,o=Nc++,0<\/script>",x=x.removeChild(x.firstChild);break;case"select":x=typeof u.is=="string"?E.createElement("select",{is:u.is}):E.createElement("select"),u.multiple?x.multiple=!0:u.size&&(x.size=u.size);break;default:x=typeof u.is=="string"?E.createElement(g,{is:u.is}):E.createElement(g)}}x[Lt]=l,x[Kt]=u;e:for(E=l.child;E!==null;){if(E.tag===5||E.tag===6)x.appendChild(E.stateNode);else if(E.tag!==4&&E.tag!==27&&E.child!==null){E.child.return=E,E=E.child;continue}if(E===l)break e;for(;E.sibling===null;){if(E.return===null||E.return===l)break e;E=E.return}E.sibling.return=E.return,E=E.sibling}l.stateNode=x;e:switch(Bt(x,g,u),g){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&Aa(l)}}return ct(l),ch(l,l.type,a===null?null:a.memoizedProps,l.pendingProps,o),null;case 6:if(a&&l.stateNode!=null)a.memoizedProps!==u&&Aa(l);else{if(typeof u!="string"&&l.stateNode===null)throw Error(r(166));if(a=je.current,Xr(l)){if(a=l.stateNode,o=l.memoizedProps,u=null,g=zt,g!==null)switch(g.tag){case 27:case 5:u=g.memoizedProps}a[Lt]=l,a=!!(a.nodeValue===o||u!==null&&u.suppressHydrationWarning===!0||iy(a.nodeValue,o)),a||Za(l,!0)}else a=Yc(a).createTextNode(u),a[Lt]=l,l.stateNode=a}return ct(l),null;case 31:if(o=l.memoizedState,a===null||a.memoizedState!==null){if(u=Xr(l),o!==null){if(a===null){if(!u)throw Error(r(318));if(a=l.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(r(557));a[Lt]=l}else Ws(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;ct(l),a=!1}else o=yf(),a!==null&&a.memoizedState!==null&&(a.memoizedState.hydrationErrors=o),a=!0;if(!a)return l.flags&256?(mn(l),l):(mn(l),null);if((l.flags&128)!==0)throw Error(r(558))}return ct(l),null;case 13:if(u=l.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(g=Xr(l),u!==null&&u.dehydrated!==null){if(a===null){if(!g)throw Error(r(318));if(g=l.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(r(317));g[Lt]=l}else Ws(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;ct(l),g=!1}else g=yf(),a!==null&&a.memoizedState!==null&&(a.memoizedState.hydrationErrors=g),g=!0;if(!g)return l.flags&256?(mn(l),l):(mn(l),null)}return mn(l),(l.flags&128)!==0?(l.lanes=o,l):(o=u!==null,a=a!==null&&a.memoizedState!==null,o&&(u=l.child,g=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(g=u.alternate.memoizedState.cachePool.pool),x=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(x=u.memoizedState.cachePool.pool),x!==g&&(u.flags|=2048)),o!==a&&o&&(l.child.flags|=8192),kc(l,l.updateQueue),ct(l),null);case 4:return Ue(),a===null&&Th(l.stateNode.containerInfo),ct(l),null;case 10:return Na(l.type),ct(l),null;case 19:if(X(vt),u=l.memoizedState,u===null)return ct(l),null;if(g=(l.flags&128)!==0,x=u.rendering,x===null)if(g)Oi(u,!1);else{if(gt!==0||a!==null&&(a.flags&128)!==0)for(a=l.child;a!==null;){if(x=yc(a),x!==null){for(l.flags|=128,Oi(u,!1),a=x.updateQueue,l.updateQueue=a,kc(l,a),l.subtreeFlags=0,a=o,o=l.child;o!==null;)Ux(o,a),o=o.sibling;return ie(vt,vt.current&1|2),Be&&ya(l,u.treeForkCount),l.child}a=a.sibling}u.tail!==null&&dn()>zc&&(l.flags|=128,g=!0,Oi(u,!1),l.lanes=4194304)}else{if(!g)if(a=yc(x),a!==null){if(l.flags|=128,g=!0,a=a.updateQueue,l.updateQueue=a,kc(l,a),Oi(u,!0),u.tail===null&&u.tailMode==="hidden"&&!x.alternate&&!Be)return ct(l),null}else 2*dn()-u.renderingStartTime>zc&&o!==536870912&&(l.flags|=128,g=!0,Oi(u,!1),l.lanes=4194304);u.isBackwards?(x.sibling=l.child,l.child=x):(a=u.last,a!==null?a.sibling=x:l.child=x,u.last=x)}return u.tail!==null?(a=u.tail,u.rendering=a,u.tail=a.sibling,u.renderingStartTime=dn(),a.sibling=null,o=vt.current,ie(vt,g?o&1|2:o&1),Be&&ya(l,u.treeForkCount),a):(ct(l),null);case 22:case 23:return mn(l),kf(),u=l.memoizedState!==null,a!==null?a.memoizedState!==null!==u&&(l.flags|=8192):u&&(l.flags|=8192),u?(o&536870912)!==0&&(l.flags&128)===0&&(ct(l),l.subtreeFlags&6&&(l.flags|=8192)):ct(l),o=l.updateQueue,o!==null&&kc(l,o.retryQueue),o=null,a!==null&&a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(o=a.memoizedState.cachePool.pool),u=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(u=l.memoizedState.cachePool.pool),u!==o&&(l.flags|=2048),a!==null&&X(Ks),null;case 24:return o=null,a!==null&&(o=a.memoizedState.cache),l.memoizedState.cache!==o&&(l.flags|=2048),Na(St),ct(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function Qw(a,l){switch(xf(l),l.tag){case 1:return a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 3:return Na(St),Ue(),a=l.flags,(a&65536)!==0&&(a&128)===0?(l.flags=a&-65537|128,l):null;case 26:case 27:case 5:return Rn(l),null;case 31:if(l.memoizedState!==null){if(mn(l),l.alternate===null)throw Error(r(340));Ws()}return a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 13:if(mn(l),a=l.memoizedState,a!==null&&a.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Ws()}return a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 19:return X(vt),null;case 4:return Ue(),null;case 10:return Na(l.type),null;case 22:case 23:return mn(l),kf(),a!==null&&X(Ks),a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 24:return Na(St),null;case 25:return null;default:return null}}function fb(a,l){switch(xf(l),l.tag){case 3:Na(St),Ue();break;case 26:case 27:case 5:Rn(l);break;case 4:Ue();break;case 31:l.memoizedState!==null&&mn(l);break;case 13:mn(l);break;case 19:X(vt);break;case 10:Na(l.type);break;case 22:case 23:mn(l),kf(),a!==null&&X(Ks);break;case 24:Na(St)}}function Ri(a,l){try{var o=l.updateQueue,u=o!==null?o.lastEffect:null;if(u!==null){var g=u.next;o=g;do{if((o.tag&a)===a){u=void 0;var x=o.create,E=o.inst;u=x(),E.destroy=u}o=o.next}while(o!==g)}}catch(D){et(l,l.return,D)}}function ss(a,l,o){try{var u=l.updateQueue,g=u!==null?u.lastEffect:null;if(g!==null){var x=g.next;u=x;do{if((u.tag&a)===a){var E=u.inst,D=E.destroy;if(D!==void 0){E.destroy=void 0,g=l;var M=o,$=D;try{$()}catch(ae){et(g,M,ae)}}}u=u.next}while(u!==x)}}catch(ae){et(l,l.return,ae)}}function hb(a){var l=a.updateQueue;if(l!==null){var o=a.stateNode;try{a0(l,o)}catch(u){et(a,a.return,u)}}}function pb(a,l,o){o.props=ar(a.type,a.memoizedProps),o.state=a.memoizedState;try{o.componentWillUnmount()}catch(u){et(a,l,u)}}function Ti(a,l){try{var o=a.ref;if(o!==null){switch(a.tag){case 26:case 27:case 5:var u=a.stateNode;break;case 30:u=a.stateNode;break;default:u=a.stateNode}typeof o=="function"?a.refCleanup=o(u):o.current=u}}catch(g){et(a,l,g)}}function sa(a,l){var o=a.ref,u=a.refCleanup;if(o!==null)if(typeof u=="function")try{u()}catch(g){et(a,l,g)}finally{a.refCleanup=null,a=a.alternate,a!=null&&(a.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(g){et(a,l,g)}else o.current=null}function gb(a){var l=a.type,o=a.memoizedProps,u=a.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":o.autoFocus&&u.focus();break e;case"img":o.src?u.src=o.src:o.srcSet&&(u.srcset=o.srcSet)}}catch(g){et(a,a.return,g)}}function dh(a,l,o){try{var u=a.stateNode;m2(u,a.type,o,l),u[Kt]=l}catch(g){et(a,a.return,g)}}function mb(a){return a.tag===5||a.tag===3||a.tag===26||a.tag===27&&us(a.type)||a.tag===4}function uh(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||mb(a.return))return null;a=a.return}for(a.sibling.return=a.return,a=a.sibling;a.tag!==5&&a.tag!==6&&a.tag!==18;){if(a.tag===27&&us(a.type)||a.flags&2||a.child===null||a.tag===4)continue e;a.child.return=a,a=a.child}if(!(a.flags&2))return a.stateNode}}function fh(a,l,o){var u=a.tag;if(u===5||u===6)a=a.stateNode,l?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(a,l):(l=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,l.appendChild(a),o=o._reactRootContainer,o!=null||l.onclick!==null||(l.onclick=ma));else if(u!==4&&(u===27&&us(a.type)&&(o=a.stateNode,l=null),a=a.child,a!==null))for(fh(a,l,o),a=a.sibling;a!==null;)fh(a,l,o),a=a.sibling}function _c(a,l,o){var u=a.tag;if(u===5||u===6)a=a.stateNode,l?o.insertBefore(a,l):o.appendChild(a);else if(u!==4&&(u===27&&us(a.type)&&(o=a.stateNode),a=a.child,a!==null))for(_c(a,l,o),a=a.sibling;a!==null;)_c(a,l,o),a=a.sibling}function xb(a){var l=a.stateNode,o=a.memoizedProps;try{for(var u=a.type,g=l.attributes;g.length;)l.removeAttributeNode(g[0]);Bt(l,u,o),l[Lt]=a,l[Kt]=o}catch(x){et(a,a.return,x)}}var wa=!1,wt=!1,hh=!1,bb=typeof WeakSet=="function"?WeakSet:Set,Rt=null;function Ww(a,l){if(a=a.containerInfo,Mh=ed,a=Rx(a),rf(a)){if("selectionStart"in a)var o={start:a.selectionStart,end:a.selectionEnd};else e:{o=(o=a.ownerDocument)&&o.defaultView||window;var u=o.getSelection&&o.getSelection();if(u&&u.rangeCount!==0){o=u.anchorNode;var g=u.anchorOffset,x=u.focusNode;u=u.focusOffset;try{o.nodeType,x.nodeType}catch{o=null;break e}var E=0,D=-1,M=-1,$=0,ae=0,re=a,Y=null;t:for(;;){for(var K;re!==o||g!==0&&re.nodeType!==3||(D=E+g),re!==x||u!==0&&re.nodeType!==3||(M=E+u),re.nodeType===3&&(E+=re.nodeValue.length),(K=re.firstChild)!==null;)Y=re,re=K;for(;;){if(re===a)break t;if(Y===o&&++$===g&&(D=E),Y===x&&++ae===u&&(M=E),(K=re.nextSibling)!==null)break;re=Y,Y=re.parentNode}re=K}o=D===-1||M===-1?null:{start:D,end:M}}else o=null}o=o||{start:0,end:0}}else o=null;for(Ih={focusedElem:a,selectionRange:o},ed=!1,Rt=l;Rt!==null;)if(l=Rt,a=l.child,(l.subtreeFlags&1028)!==0&&a!==null)a.return=l,Rt=a;else for(;Rt!==null;){switch(l=Rt,x=l.alternate,a=l.flags,l.tag){case 0:if((a&4)!==0&&(a=l.updateQueue,a=a!==null?a.events:null,a!==null))for(o=0;o title"))),Bt(x,u,o),x[Lt]=a,Ot(x),u=x;break e;case"link":var E=jy("link","href",g).get(u+(o.href||""));if(E){for(var D=0;Dst&&(E=st,st=Ae,Ae=E);var U=Dx(D,Ae),L=Dx(D,st);if(U&&L&&(K.rangeCount!==1||K.anchorNode!==U.node||K.anchorOffset!==U.offset||K.focusNode!==L.node||K.focusOffset!==L.offset)){var q=re.createRange();q.setStart(U.node,U.offset),K.removeAllRanges(),Ae>st?(K.addRange(q),K.extend(L.node,L.offset)):(q.setEnd(L.node,L.offset),K.addRange(q))}}}}for(re=[],K=D;K=K.parentNode;)K.nodeType===1&&re.push({element:K,left:K.scrollLeft,top:K.scrollTop});for(typeof D.focus=="function"&&D.focus(),D=0;Do?32:o,H.T=null,o=vh,vh=null;var x=os,E=Ta;if(Dt=0,dl=os=null,Ta=0,(We&6)!==0)throw Error(r(331));var D=We;if(We|=4,Ob(x.current),wb(x,x.current,E,o),We=D,zi(0,!1),un&&typeof un.onPostCommitFiberRoot=="function")try{un.onPostCommitFiberRoot(ti,x)}catch{}return!0}finally{V.p=g,H.T=u,Yb(a,l)}}function Wb(a,l,o){l=Mn(o,l),l=Jf(a.stateNode,l,2),a=ts(a,l,2),a!==null&&(ai(a,2),ra(a))}function et(a,l,o){if(a.tag===3)Wb(a,a,o);else for(;l!==null;){if(l.tag===3){Wb(l,a,o);break}else if(l.tag===1){var u=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(is===null||!is.has(u))){a=Mn(o,a),o=X0(2),u=ts(l,o,2),u!==null&&(Z0(o,u,l,a),ai(u,2),ra(u));break}}l=l.return}}function jh(a,l,o){var u=a.pingCache;if(u===null){u=a.pingCache=new Kw;var g=new Set;u.set(l,g)}else g=u.get(l),g===void 0&&(g=new Set,u.set(l,g));g.has(o)||(mh=!0,g.add(o),a=a2.bind(null,a,l,o),l.then(a,a))}function a2(a,l,o){var u=a.pingCache;u!==null&&u.delete(l),a.pingedLanes|=a.suspendedLanes&o,a.warmLanes&=~o,rt===a&&(Le&o)===o&&(gt===4||gt===3&&(Le&62914560)===Le&&300>dn()-Lc?(We&2)===0&&ul(a,0):xh|=o,cl===Le&&(cl=0)),ra(a)}function Xb(a,l){l===0&&(l=Fm()),a=Ys(a,l),a!==null&&(ai(a,l),ra(a))}function s2(a){var l=a.memoizedState,o=0;l!==null&&(o=l.retryLane),Xb(a,o)}function r2(a,l){var o=0;switch(a.tag){case 31:case 13:var u=a.stateNode,g=a.memoizedState;g!==null&&(o=g.retryLane);break;case 19:u=a.stateNode;break;case 22:u=a.stateNode._retryCache;break;default:throw Error(r(314))}u!==null&&u.delete(l),Xb(a,o)}function l2(a,l){return Lu(a,l)}var Vc=null,hl=null,Ah=!1,Fc=!1,wh=!1,ds=0;function ra(a){a!==hl&&a.next===null&&(hl===null?Vc=hl=a:hl=hl.next=a),Fc=!0,Ah||(Ah=!0,o2())}function zi(a,l){if(!wh&&Fc){wh=!0;do for(var o=!1,u=Vc;u!==null;){if(a!==0){var g=u.pendingLanes;if(g===0)var x=0;else{var E=u.suspendedLanes,D=u.pingedLanes;x=(1<<31-fn(42|a)+1)-1,x&=g&~(E&~D),x=x&201326741?x&201326741|1:x?x|2:0}x!==0&&(o=!0,ey(u,x))}else x=Le,x=Qo(u,u===rt?x:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(x&3)===0||ni(u,x)||(o=!0,ey(u,x));u=u.next}while(o);wh=!1}}function i2(){Zb()}function Zb(){Fc=Ah=!1;var a=0;ds!==0&&b2()&&(a=ds);for(var l=dn(),o=null,u=Vc;u!==null;){var g=u.next,x=Kb(u,l);x===0?(u.next=null,o===null?Vc=g:o.next=g,g===null&&(hl=o)):(o=u,(a!==0||(x&3)!==0)&&(Fc=!0)),u=g}Dt!==0&&Dt!==5||zi(a),ds!==0&&(ds=0)}function Kb(a,l){for(var o=a.suspendedLanes,u=a.pingedLanes,g=a.expirationTimes,x=a.pendingLanes&-62914561;0D)break;var ae=M.transferSize,re=M.initiatorType;ae&&oy(re)&&(M=M.responseEnd,E+=ae*(M"u"?null:document;function vy(a,l,o){var u=pl;if(u&&typeof l=="string"&&l){var g=kn(l);g='link[rel="'+a+'"][href="'+g+'"]',typeof o=="string"&&(g+='[crossorigin="'+o+'"]'),yy.has(g)||(yy.add(g),a={rel:a,crossOrigin:o,href:l},u.querySelector(g)===null&&(l=u.createElement("link"),Bt(l,"link",a),Ot(l),u.head.appendChild(l)))}}function C2(a){ka.D(a),vy("dns-prefetch",a,null)}function D2(a,l){ka.C(a,l),vy("preconnect",a,l)}function O2(a,l,o){ka.L(a,l,o);var u=pl;if(u&&a&&l){var g='link[rel="preload"][as="'+kn(l)+'"]';l==="image"&&o&&o.imageSrcSet?(g+='[imagesrcset="'+kn(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(g+='[imagesizes="'+kn(o.imageSizes)+'"]')):g+='[href="'+kn(a)+'"]';var x=g;switch(l){case"style":x=gl(a);break;case"script":x=ml(a)}Bn.has(x)||(a=y({rel:"preload",href:l==="image"&&o&&o.imageSrcSet?void 0:a,as:l},o),Bn.set(x,a),u.querySelector(g)!==null||l==="style"&&u.querySelector(Hi(x))||l==="script"&&u.querySelector(Gi(x))||(l=u.createElement("link"),Bt(l,"link",a),Ot(l),u.head.appendChild(l)))}}function R2(a,l){ka.m(a,l);var o=pl;if(o&&a){var u=l&&typeof l.as=="string"?l.as:"script",g='link[rel="modulepreload"][as="'+kn(u)+'"][href="'+kn(a)+'"]',x=g;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":x=ml(a)}if(!Bn.has(x)&&(a=y({rel:"modulepreload",href:a},l),Bn.set(x,a),o.querySelector(g)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(Gi(x)))return}u=o.createElement("link"),Bt(u,"link",a),Ot(u),o.head.appendChild(u)}}}function T2(a,l,o){ka.S(a,l,o);var u=pl;if(u&&a){var g=zr(u).hoistableStyles,x=gl(a);l=l||"default";var E=g.get(x);if(!E){var D={loading:0,preload:null};if(E=u.querySelector(Hi(x)))D.loading=5;else{a=y({rel:"stylesheet",href:a,"data-precedence":l},o),(o=Bn.get(x))&&Gh(a,o);var M=E=u.createElement("link");Ot(M),Bt(M,"link",a),M._p=new Promise(function($,ae){M.onload=$,M.onerror=ae}),M.addEventListener("load",function(){D.loading|=1}),M.addEventListener("error",function(){D.loading|=2}),D.loading|=4,Wc(E,l,u)}E={type:"stylesheet",instance:E,count:1,state:D},g.set(x,E)}}}function k2(a,l){ka.X(a,l);var o=pl;if(o&&a){var u=zr(o).hoistableScripts,g=ml(a),x=u.get(g);x||(x=o.querySelector(Gi(g)),x||(a=y({src:a,async:!0},l),(l=Bn.get(g))&&Vh(a,l),x=o.createElement("script"),Ot(x),Bt(x,"link",a),o.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},u.set(g,x))}}function _2(a,l){ka.M(a,l);var o=pl;if(o&&a){var u=zr(o).hoistableScripts,g=ml(a),x=u.get(g);x||(x=o.querySelector(Gi(g)),x||(a=y({src:a,async:!0,type:"module"},l),(l=Bn.get(g))&&Vh(a,l),x=o.createElement("script"),Ot(x),Bt(x,"link",a),o.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},u.set(g,x))}}function Ny(a,l,o,u){var g=(g=je.current)?Qc(g):null;if(!g)throw Error(r(446));switch(a){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(l=gl(o.href),o=zr(g).hoistableStyles,u=o.get(l),u||(u={type:"style",instance:null,count:0,state:null},o.set(l,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){a=gl(o.href);var x=zr(g).hoistableStyles,E=x.get(a);if(E||(g=g.ownerDocument||g,E={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},x.set(a,E),(x=g.querySelector(Hi(a)))&&!x._p&&(E.instance=x,E.state.loading=5),Bn.has(a)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},Bn.set(a,o),x||M2(g,a,o,E.state))),l&&u===null)throw Error(r(528,""));return E}if(l&&u!==null)throw Error(r(529,""));return null;case"script":return l=o.async,o=o.src,typeof o=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ml(o),o=zr(g).hoistableScripts,u=o.get(l),u||(u={type:"script",instance:null,count:0,state:null},o.set(l,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,a))}}function gl(a){return'href="'+kn(a)+'"'}function Hi(a){return'link[rel="stylesheet"]['+a+"]"}function Ey(a){return y({},a,{"data-precedence":a.precedence,precedence:null})}function M2(a,l,o,u){a.querySelector('link[rel="preload"][as="style"]['+l+"]")?u.loading=1:(l=a.createElement("link"),u.preload=l,l.addEventListener("load",function(){return u.loading|=1}),l.addEventListener("error",function(){return u.loading|=2}),Bt(l,"link",o),Ot(l),a.head.appendChild(l))}function ml(a){return'[src="'+kn(a)+'"]'}function Gi(a){return"script[async]"+a}function Sy(a,l,o){if(l.count++,l.instance===null)switch(l.type){case"style":var u=a.querySelector('style[data-href~="'+kn(o.href)+'"]');if(u)return l.instance=u,Ot(u),u;var g=y({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return u=(a.ownerDocument||a).createElement("style"),Ot(u),Bt(u,"style",g),Wc(u,o.precedence,a),l.instance=u;case"stylesheet":g=gl(o.href);var x=a.querySelector(Hi(g));if(x)return l.state.loading|=4,l.instance=x,Ot(x),x;u=Ey(o),(g=Bn.get(g))&&Gh(u,g),x=(a.ownerDocument||a).createElement("link"),Ot(x);var E=x;return E._p=new Promise(function(D,M){E.onload=D,E.onerror=M}),Bt(x,"link",u),l.state.loading|=4,Wc(x,o.precedence,a),l.instance=x;case"script":return x=ml(o.src),(g=a.querySelector(Gi(x)))?(l.instance=g,Ot(g),g):(u=o,(g=Bn.get(x))&&(u=y({},o),Vh(u,g)),a=a.ownerDocument||a,g=a.createElement("script"),Ot(g),Bt(g,"link",u),a.head.appendChild(g),l.instance=g);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(u=l.instance,l.state.loading|=4,Wc(u,o.precedence,a));return l.instance}function Wc(a,l,o){for(var u=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),g=u.length?u[u.length-1]:null,x=g,E=0;E title"):null)}function I2(a,l,o){if(o===1||l.itemProp!=null)return!1;switch(a){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;switch(l.rel){case"stylesheet":return a=l.disabled,typeof l.precedence=="string"&&a==null;default:return!0}case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function wy(a){return!(a.type==="stylesheet"&&(a.state.loading&3)===0)}function L2(a,l,o,u){if(o.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var g=gl(u.href),x=l.querySelector(Hi(g));if(x){l=x._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(a.count++,a=Zc.bind(a),l.then(a,a)),o.state.loading|=4,o.instance=x,Ot(x);return}x=l.ownerDocument||l,u=Ey(u),(g=Bn.get(g))&&Gh(u,g),x=x.createElement("link"),Ot(x);var E=x;E._p=new Promise(function(D,M){E.onload=D,E.onerror=M}),Bt(x,"link",u),o.instance=x}a.stylesheets===null&&(a.stylesheets=new Map),a.stylesheets.set(o,l),(l=o.state.preload)&&(o.state.loading&3)===0&&(a.count++,o=Zc.bind(a),l.addEventListener("load",o),l.addEventListener("error",o))}}var Fh=0;function z2(a,l){return a.stylesheets&&a.count===0&&Jc(a,a.stylesheets),0Fh?50:800)+l);return a.unsuspend=o,function(){a.unsuspend=null,clearTimeout(u),clearTimeout(g)}}:null}function Zc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Jc(this,this.stylesheets);else if(this.unsuspend){var a=this.unsuspend;this.unsuspend=null,a()}}}var Kc=null;function Jc(a,l){a.stylesheets=null,a.unsuspend!==null&&(a.count++,Kc=new Map,l.forEach(P2,a),Kc=null,Zc.call(a))}function P2(a,l){if(!(l.state.loading&4)){var o=Kc.get(a);if(o)var u=o.get(null);else{o=new Map,Kc.set(a,o);for(var g=a.querySelectorAll("link[data-precedence],style[data-precedence]"),x=0;x"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),ep.exports=J2(),ep.exports}var tC=eC();const Zy=t=>t?t.toUpperCase():"",Hn=t=>{const e={...t};for(const n in e)typeof e[n]=="string"&&n!=="id"&&n!=="email"&&n!=="start"&&n!=="end"&&!n.includes("data")&&!n.includes("cor")&&n!=="corAgenda"&&n!=="corCartao"&&(e[n]=e[n].toUpperCase());return e},me="/api",be=async(t,e={})=>{const n=localStorage.getItem("SCOREODONTO_AUTH_TOKEN"),r={...e.headers,...n?{Authorization:`Bearer ${n}`}:{}};return fetch(t,{...e,headers:r})},J={dbConfig:{database:"scoreodonto"},login:async(t,e)=>{const n=t.toLowerCase().trim(),r=e.trim();try{const i=await be(`${me}/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:n,password:r})});if(i.ok){const c=await i.json();return localStorage.setItem("SCOREODONTO_AUTH_TOKEN",c.token),localStorage.setItem("SCOREODONTO_USER_DATA",JSON.stringify(c.user)),localStorage.setItem("SCOREODONTO_WORKSPACES",JSON.stringify(c.workspaces)),c.workspaces&&c.workspaces.length>0&&localStorage.setItem("SCOREODONTO_ACTIVE_WORKSPACE",JSON.stringify(c.workspaces[0])),!0}return!1}catch(i){return console.error("Login error:",i),!1}},logout:()=>{localStorage.removeItem("SCOREODONTO_AUTH_TOKEN"),localStorage.removeItem("SCOREODONTO_USER_DATA"),localStorage.removeItem("SCOREODONTO_WORKSPACES"),localStorage.removeItem("SCOREODONTO_ACTIVE_WORKSPACE"),window.location.href="/",window.location.reload()},isAuthenticated:()=>!!localStorage.getItem("SCOREODONTO_AUTH_TOKEN"),getCurrentUser:()=>{const t=localStorage.getItem("SCOREODONTO_USER_DATA");if(!t)return null;try{return JSON.parse(t).email}catch{return null}},getCurrentUserName:()=>{const t=localStorage.getItem("SCOREODONTO_USER_DATA");if(!t)return"USUÁRIO";try{return JSON.parse(t).nome}catch{return"USUÁRIO"}},getWorkspaces:()=>{const t=localStorage.getItem("SCOREODONTO_WORKSPACES");return t?JSON.parse(t):[]},getActiveWorkspace:()=>{const t=localStorage.getItem("SCOREODONTO_ACTIVE_WORKSPACE");return t?JSON.parse(t):null},switchWorkspace:t=>{const n=J.getWorkspaces().find(r=>r.id===t);n&&(["SCOREODONTO_CACHE_PACIENTES","SCOREODONTO_CACHE_AGENDAMENTOS","SCOREODONTO_CACHE_FINANCEIRO","SCOREODONTO_CACHE_DENTISTAS","SCOREODONTO_CACHE_GUIAS","SCOREODONTO_CACHE_GTO","SCOREODONTO_CACHE_PROCEDIMENTOS","SCOREODONTO_CACHE_PLANOS","SCOREODONTO_CACHE_NOTIFICACOES"].forEach(i=>localStorage.removeItem(i)),console.log(`[SECURITY] Cache cleared for tenant switch to: ${t}`),localStorage.setItem("SCOREODONTO_ACTIVE_WORKSPACE",JSON.stringify(n)),window.location.reload())},getCurrentRole:()=>{const t=J.getActiveWorkspace();return(t==null?void 0:t.role)||"paciente"},getDashboardStats:async()=>await(await be(`${me}/dashboard/stats`)).json(),isDbConfigured:()=>localStorage.getItem("SCOREODONTO_DB_CONFIGURED")==="true",runInstallScript:async t=>{const e=["--------------------------------------------------"," SCOREODONTO - ATUALIZADOR DE BANCO DE DADOS ","--------------------------------------------------","[INFO] VERIFICANDO AMBIENTE...","[OK] AMBIENTE POSTGRESQL DETECTADO.",`[INFO] CONECTANDO DB: ${J.dbConfig.database}...`,"[INFO] INICIANDO BACKUP DE SEGURANCA...",`[OK] BACKUP SALVO EM: ./bkp_database/BKP_${new Date().toISOString().replace(/[:.]/g,"-")}.SQL`,"[INFO] CONECTANDO API GOOGLE SHEETS...","[INFO] LENDO PLANILHA: 'Dados Pacientes'..."," > 1.240 LINHAS ENCONTRADAS."," > VALIDANDO DADOS (CPF, TELEFONE)...","[INFO] SINCRONIZANDO COM POSTGRESQL (scoreodonto)..."," > FORCANDO PADRAO 'UPPERCASE' EM TODOS OS CAMPOS TEXTUAIS..."," > ATUALIZANDO TABELA: PACIENTES..."," > ATUALIZANDO TABELA: FINANCEIRO..."," > ATUALIZANDO TABELA: AGENDA...","[INFO] LIMPANDO CACHE DE SESSAO...","--------------------------------------------------"," ATUALIZACAO CONCLUIDA COM SUCESSO! ","--------------------------------------------------"];for(const n of e)await new Promise(r=>setTimeout(r,600)),t(n);return localStorage.setItem("SCOREODONTO_DB_CONFIGURED","true"),!0},syncGoogleSheetsToPg:async t=>(t("INICIANDO CONEXÃO COM GOOGLE SHEETS..."),await new Promise(e=>setTimeout(e,800)),t("LENDO ABA 'DADOS PACIENTES'..."),await new Promise(e=>setTimeout(e,800)),t(`CONECTANDO AO POSTGRESQL (${J.dbConfig.database})...`),await new Promise(e=>setTimeout(e,800)),t("COMPARANDO REGISTROS (HASH CHECK)..."),await new Promise(e=>setTimeout(e,1e3)),t("INSERINDO 2 NOVOS PACIENTES NO POSTGRESQL..."),t("ATUALIZANDO 4 AGENDAMENTOS..."),await new Promise(e=>setTimeout(e,500)),t("SINCRONIZAÇÃO CONCLUÍDA COM SUCESSO!"),!0),getPacientes:async(t="",e="recentes")=>{const n=new URLSearchParams;return t.trim()&&n.set("q",t.trim()),e&&n.set("sort",e),(await be(`${me}/pacientes?${n}`)).json()},checkCpfExists:async t=>{const e=t.replace(/\D/g,"");if(!e)return!1;const n=await be(`${me}/pacientes?q=${encodeURIComponent(t)}`),{data:r}=await n.json();return(r||[]).some(c=>c.cpf.replace(/\D/g,"")===e)},savePaciente:async t=>{const e=Hn(t),n={...e,id:e.id||`p_${Date.now()}`};return await(await be(`${me}/pacientes`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})).json()},updatePaciente:async t=>{const e=Hn(t);return await(await be(`${me}/pacientes/${t.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json()},getGruposFamiliares:async t=>{const e=t!=null&&t.trim()?`${me}/grupos-familiares?q=${encodeURIComponent(t)}`:`${me}/grupos-familiares`,r=await(await be(e)).json();return Array.isArray(r)?r:[]},criarGrupoFamiliar:async(t,e)=>(await be(`${me}/grupos-familiares`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({nome:t,responsavel_id:e})})).json(),getMembrosFamilia:async t=>(await be(`${me}/grupos-familiares/${t}/membros`)).json(),getModelosReceita:async t=>{const e=t?`${me}/modelos-receita?especialidadeId=${t}`:`${me}/modelos-receita`,r=await(await be(e)).json();return Array.isArray(r)?r:[]},saveModeloReceita:async t=>(await be(`${me}/modelos-receita`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json(),updateModeloReceita:async t=>(await be(`${me}/modelos-receita/${t.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json(),deleteModeloReceita:async t=>{await be(`${me}/modelos-receita/${t}`,{method:"DELETE"})},savePedidoExame:async t=>(await be(`${me}/pedidos-exame`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json(),getPedidosExame:async t=>{const e=t?`${me}/pedidos-exame?pacienteId=${t}`:`${me}/pedidos-exame`,r=await(await be(e)).json();return Array.isArray(r)?r:[]},getDentistas:async t=>{const e=t?`${me}/dentistas?clinicaId=${t}`:`${me}/dentistas`;return await(await be(e)).json()},getPlanos:async()=>await(await be(`${me}/planos`)).json(),updateDentista:async t=>{const e=Hn(t);return await(await be(`${me}/dentistas/${t.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json()},saveDentista:async t=>{const e=J.getActiveWorkspace(),r={...Hn(t),id:Math.random().toString(),clinica_id:e==null?void 0:e.id};return await(await be(`${me}/dentistas`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})).json()},reorderDentistas:async t=>await(await be(`${me}/dentistas/reorder`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({orders:t})})).json(),deleteDentista:async t=>{await be(`${me}/dentistas/${t}`,{method:"DELETE"})},getHorariosByDentista:async(t,e)=>await(await be(`${me}/dentistas/${t}/horarios?clinicaId=${e}`)).json(),saveHorario:async t=>await(await be(`${me}/dentistas/horarios`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json(),deleteHorario:async t=>{await be(`${me}/dentistas/horarios/${t}`,{method:"DELETE"})},getProductivityReport:async(t,e,n)=>await(await be(`${me}/reports/productivity?clinicaId=${t}&start=${e||""}&end=${n||""}`)).json(),updateEspecialidade:async t=>{const e=Hn(t);return await(await be(`${me}/especialidades/${t.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json()},saveEspecialidade:async t=>{const n={...Hn(t),id:Math.random().toString()};return await(await be(`${me}/especialidades`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})).json()},reorderEspecialidades:async t=>await(await be(`${me}/especialidades/reorder`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({orders:t})})).json(),deleteEspecialidade:async t=>{await be(`${me}/especialidades/${t}`,{method:"DELETE"})},updateProcedimento:async t=>{const e=Hn(t);return await(await be(`${me}/procedimentos/${t.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json()},saveProcedimento:async t=>{const n={...Hn(t),id:Math.random().toString()};return await(await be(`${me}/procedimentos`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})).json()},reorderProcedimentos:async t=>await(await be(`${me}/procedimentos/reorder`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({orders:t})})).json(),deleteProcedimento:async t=>{await be(`${me}/procedimentos/${t}`,{method:"DELETE"})},updatePlano:async t=>{const e=Hn(t);return await(await be(`${me}/planos/${t.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json()},savePlano:async t=>{const n={...Hn(t),id:Math.random().toString()};return await(await be(`${me}/planos`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})).json()},deletePlano:async t=>{await be(`${me}/planos/${t}`,{method:"DELETE"})},getEspecialidades:async()=>await(await be(`${me}/especialidades`)).json(),getProcedimentos:async()=>await(await be(`${me}/procedimentos`)).json(),getFinanceiro:async()=>await(await be(`${me}/financeiro`)).json(),saveFinanceiro:async t=>{const e=Hn(t);return await(await be(`${me}/financeiro`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json()},updateFinanceiro:async t=>{const e=Hn(t);return await(await be(`${me}/financeiro/${t.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json()},deleteFinanceiro:async t=>{await be(`${me}/financeiro/${t}`,{method:"DELETE"})},getAgendamentos:async()=>await(await be(`${me}/agendamentos`,{})).json(),salvarAgendamento:async t=>{const e=await be(`${me}/agendamentos`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!e.ok){const n=await e.json();throw new Error(n.message||"Erro ao salvar agendamento.")}return await e.json()},atualizarAgendamento:async(t,e)=>{const n=await be(`${me}/agendamentos/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){const r=await n.json();throw new Error(r.message||"Erro ao atualizar agendamento.")}return await n.json()},excluirAgendamento:async t=>{await be(`${me}/agendamentos/${t}`,{method:"DELETE"})},getOrtoTreatments:async()=>[{id:"t1",pacienteId:"1",pacienteNome:"ANA SILVA",dataNascimento:"2014-03-15",responsavel:"MARIA SILVA",tipoPaciente:"Adolescente",triagem:{queixaPrincipal:"DENTES TORTOS NA FRENTE",historicoMedico:"NENHUMA CONDIÇÃO RELEVANTE",medicacao:"NENHUMA",alergias:"NENHUMA",respiracaoBucal:!1,habitos:"BRUXISMO LEVE NOTURNO"},diagnostico:{classeAngle:"II",perfil:"Convexo",apinhamento:"Moderado",mordida:"Profunda",linhaMedia:"1MM PARA ESQUERDA"},dataInicio:"2024-08-10",tipoAparelho:"AUTOLIGADO METÁLICO",extracoes:"NÃO",sequenciaFios:"0.12 → 0.14 → 0.16 → 0.18 → 0.20x0.25",elasticos:"CLASSE II",iprPlanejado:"NÃO",tempoEstimado:"18–24 MESES",valor:4500,formaPagamento:"PARCELADO 24X",faseAtual:"NIVELAMENTO",fioAtual:"0.16",classificacao:"CLASSE II",cooperacao:"Média",percentualConcluido:35,ultimaConsulta:"2026-01-14",proximaConsulta:"2026-02-14",mesesRestantes:14,status:"Em Tratamento",evolucoes:[{id:"ev1",data:"2024-08-10",tipo:"Colagem",procedimento:"COLAGEM APARELHO SUPERIOR E INFERIOR",proximoRetorno:"2024-09-10",fio:"0.12",higiene:8,cooperacao:"Boa"},{id:"ev2",data:"2024-09-10",tipo:"Manutenção",procedimento:"TROCA DE FIO SUPERIOR 0.14",proximoRetorno:"2024-10-10",fio:"0.14",higiene:7,cooperacao:"Boa"},{id:"ev3",data:"2024-10-10",tipo:"Troca de fio",procedimento:"TROCA DE FIO SUPERIOR 0.16 + ELÁSTICO CLASSE II",proximoRetorno:"2024-11-10",fio:"0.16",elastico:"CLASSE II",higiene:6,cooperacao:"Média"},{id:"ev4",data:"2025-11-10",tipo:"Manutenção",procedimento:"MANUTENÇÃO + PROFILAXIA",proximoRetorno:"2025-12-10",fio:"0.16",elastico:"CLASSE II",procedimentos:["Profilaxia"],higiene:5,cooperacao:"Média",observacoes:"HIGIENE ABAIXO DO IDEAL. ORIENTAÇÕES REFORÇADAS."},{id:"ev5",data:"2026-01-14",tipo:"Manutenção",procedimento:"MANUTENÇÃO CORRENTE ELÁSTICA",proximoRetorno:"2026-02-14",fio:"0.16",elastico:"CLASSE II",higiene:6,cooperacao:"Média"}],flags:[{tipo:"warning",mensagem:"HIGIENE ABAIXO DO IDEAL"},{tipo:"info",mensagem:"COOPERAÇÃO MÉDIA NAS ÚLTIMAS 3 VISITAS"}],fotos:[{url:"",tipo:"inicio",data:"2024-08-10"},{url:"",tipo:"atual",data:"2026-01-14"}]},{id:"t2",pacienteId:"2",pacienteNome:"CARLOS EDUARDO MENDES",dataNascimento:"1990-07-22",tipoPaciente:"Adulto",triagem:{queixaPrincipal:"MORDIDA CRUZADA ANTERIOR",historicoMedico:"HIPERTENSÃO CONTROLADA",medicacao:"LOSARTANA 50MG",alergias:"DIPIRONA",respiracaoBucal:!1,habitos:"NENHUM",periodonto:"RECESSÃO GENGIVAL LEVE EM 31-41",implantes:"NENHUM",recessoes:"31 E 41 - CLASSE I MILLER",mobilidade:"NENHUMA"},diagnostico:{classeAngle:"III",perfil:"Côncavo",apinhamento:"Severo",mordida:"Cruzada",linhaMedia:"3MM PARA DIREITA"},dataInicio:"2024-03-05",tipoAparelho:"AUTOLIGADO CERÂMICO",extracoes:"1º PRÉ-MOLARES SUPERIORES (14 E 24)",sequenciaFios:"0.14 → 0.16 → 0.18 → 0.19x0.25 → 0.21x0.25",elasticos:"CLASSE III",iprPlanejado:"SIM - INFERIOR ANTERIOR",tempoEstimado:"24–30 MESES",valor:7200,formaPagamento:"PARCELADO 30X",faseAtual:"FECHAMENTO DE ESPAÇOS",fioAtual:"0.19x0.25",classificacao:"CLASSE III",cooperacao:"Boa",percentualConcluido:55,ultimaConsulta:"2026-02-05",proximaConsulta:"2026-03-05",mesesRestantes:10,status:"Em Tratamento",evolucoes:[{id:"ev6",data:"2024-03-05",tipo:"Colagem",procedimento:"COLAGEM APARELHO CERÂMICO SUP/INF + EXTRAÇÕES 14 E 24",proximoRetorno:"2024-04-05",fio:"0.14",higiene:9,cooperacao:"Boa"},{id:"ev7",data:"2025-06-05",tipo:"Manutenção",procedimento:"IPR INFERIOR ANTERIOR + MOLA FECHAMENTO",proximoRetorno:"2025-07-05",fio:"0.19x0.25",procedimentos:["IPR"],higiene:8,cooperacao:"Boa"},{id:"ev8",data:"2026-02-05",tipo:"Manutenção",procedimento:"ATIVAÇÃO MOLA + ELÁSTICO CLASSE III",proximoRetorno:"2026-03-05",fio:"0.19x0.25",elastico:"CLASSE III",higiene:9,cooperacao:"Boa"}],flags:[{tipo:"danger",mensagem:"COMPLEXIDADE ALTA - APINHAMENTO SEVERO"},{tipo:"warning",mensagem:"RISCO PERIODONTAL - RECESSÃO CLASSE I"}],fotos:[{url:"",tipo:"inicio",data:"2024-03-05"},{url:"",tipo:"atual",data:"2026-02-05"}]}],saveEvolucaoOrto:async(t,e)=>{const n={id:"ev_"+Math.random().toString(36).substring(2,8),data:new Date().toISOString().split("T")[0],tipo:e.tipo||"Manutenção",procedimento:e.procedimento||"",proximoRetorno:e.proximoRetorno||"",fio:e.fio,elastico:e.elastico,procedimentos:e.procedimentos,higiene:e.higiene,cooperacao:e.cooperacao,observacoes:e.observacoes};return console.log(`[Mock] Evolução salva no tratamento ${t}:`,n),n},updateTratamentoOrto:async t=>{console.log("[Mock] Tratamento atualizado:",t)},finalizarTratamentoOrto:async(t,e)=>{console.log(`[Mock] Tratamento ${t} finalizado com contenção:`,e)},saveLead:async t=>{const e={id:Math.random().toString(),nome:Zy(t.nome),sobrenome:Zy(t.sobrenome),cpf:t.cpf||"",whatsapp:t.whatsapp||"",tipoInteresse:t.tipoInteresse||"Particular",dataCadastro:new Date().toISOString(),status:"Novo"};return await be(`${me}/leads`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),e},getLeads:async()=>await(await be(`${me}/leads`)).json(),getNotifications:async()=>{try{return await(await be(`${me}/notificacoes`)).json()}catch{return[]}},markNotificationRead:async t=>{try{await be(`${me}/notificacoes/${t}/read`,{method:"PUT"})}catch(e){console.error("Erro ao marcar como lida:",e)}},markAllNotificationsRead:async()=>{try{await be(`${me}/notificacoes/read-all`,{method:"POST"})}catch(t){console.error("Erro ao marcar todas como lidas:",t)}},deleteNotification:async t=>{try{await be(`${me}/notificacoes/${t}`,{method:"DELETE"})}catch(e){console.error("Erro ao excluir notificação:",e)}},getSettings:async()=>await(await be(`${me}/settings`)).json(),saveSettings:async t=>await(await be(`${me}/settings`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json(),getGoogleEvents:async()=>{try{return await(await be(`${me}/google/events`)).json()}catch{return[]}},getContratos:async t=>{const e=t?`?paciente_id=${t}`:"";return(await be(`${me}/contratos${e}`)).json()},saveContrato:async t=>(await be(`${me}/contratos`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json(),updateContrato:async t=>{await be(`${me}/contratos/${t.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},deleteContrato:async t=>{await be(`${me}/contratos/${t}`,{method:"DELETE"})}};/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kN=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nC=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aC=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase());/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ky=t=>{const e=aC(t);return e.charAt(0).toUpperCase()+e.slice(1)};/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */var sC={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rC=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1};/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lC=w.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:c,iconNode:d,...f},h)=>w.createElement("svg",{ref:h,...sC,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:kN("lucide",i),...!c&&!rC(f)&&{"aria-hidden":"true"},...f},[...d.map(([p,b])=>w.createElement(p,b)),...Array.isArray(c)?c:[c]]));/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const le=(t,e)=>{const n=w.forwardRef(({className:r,...i},c)=>w.createElement(lC,{ref:c,iconNode:e,className:kN(`lucide-${nC(Ky(t))}`,`lucide-${t}`,r),...i}));return n.displayName=Ky(t),n};/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iC=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Vl=le("activity",iC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oC=[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]],_N=le("arrow-down-right",oC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cC=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],MN=le("arrow-left",cC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dC=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Ls=le("arrow-right",dC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uC=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],od=le("arrow-up-down",uC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fC=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],IN=le("arrow-up-right",fC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hC=[["path",{d:"m15.477 12.89 1.515 8.526a.5.5 0 0 1-.81.47l-3.58-2.687a1 1 0 0 0-1.197 0l-3.586 2.686a.5.5 0 0 1-.81-.469l1.514-8.526",key:"1yiouv"}],["circle",{cx:"12",cy:"8",r:"6",key:"1vp47v"}]],pC=le("award",hC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gC=[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],mC=le("badge-check",gC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xC=[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M6 12h.01M18 12h.01",key:"113zkx"}]],LN=le("banknote",xC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bC=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],uo=le("bell",bC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yC=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],vC=le("book-open",yC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NC=[["path",{d:"M10 12h4",key:"a56b0p"}],["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M14 21v-3a2 2 0 0 0-4 0v3",key:"1rgiei"}],["path",{d:"M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2",key:"secmi2"}],["path",{d:"M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16",key:"16ra0t"}]],Cg=le("building-2",NC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EC=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]],SC=le("calendar-days",EC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jC=[["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M17 14h-6",key:"bkmgh3"}],["path",{d:"M13 18H7",key:"bb0bb7"}],["path",{d:"M7 14h.01",key:"1qa3f1"}],["path",{d:"M17 18h.01",key:"1bdyru"}]],AC=le("calendar-range",jC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wC=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],Et=le("calendar",wC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CC=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],Ad=le("camera",CC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DC=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],ko=le("chart-column",DC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OC=[["path",{d:"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z",key:"pzmjnu"}],["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}]],RC=le("chart-pie",OC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TC=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],fo=le("check",TC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kC=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],_o=le("chevron-down",kC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _C=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Bs=le("chevron-left",_C);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MC=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ts=le("chevron-right",MC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IC=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Dg=le("chevron-up",IC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LC=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],gu=le("circle-alert",LC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zC=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Ua=le("circle-check-big",zC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PC=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],da=le("circle-check",PC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UC=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],zN=le("circle-plus",UC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BC=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],HC=le("circle-x",BC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GC=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]],PN=le("clipboard-check",GC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VC=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]],so=le("clipboard-list",VC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FC=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Fl=le("clock",FC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qC=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],$C=le("copy",qC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YC=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],QC=le("credit-card",YC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WC=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],Er=le("database",WC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XC=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],Ba=le("dollar-sign",XC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZC=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],Og=le("download",ZC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KC=[["path",{d:"M7 16.3c2.2 0 4-1.83 4-4.05 0-1.16-.57-2.26-1.71-3.19S7.29 6.75 7 5.3c-.29 1.45-1.14 2.84-2.29 3.76S3 11.1 3 12.25c0 2.22 1.8 4.05 4 4.05z",key:"1ptgy4"}],["path",{d:"M12.56 6.6A10.97 10.97 0 0 0 14 3.02c.5 2.5 2 4.9 4 6.5s3 3.5 3 5.5a6.98 6.98 0 0 1-11.91 4.97",key:"1sl1rz"}]],JC=le("droplets",KC);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eD=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],tD=le("ellipsis",eD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nD=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],aD=le("eye-off",nD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sD=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],rD=le("eye",sD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lD=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]],Jy=le("file-down",lD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iD=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],za=le("file-text",iD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oD=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m14.5 12.5-5 5",key:"b62r18"}],["path",{d:"m9.5 12.5 5 5",key:"1rk7el"}]],ev=le("file-x",oD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cD=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],tv=le("folder-open",cD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dD=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],mu=le("funnel",dD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uD=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],ql=le("grip-vertical",uD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fD=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}]],hD=le("heart",fD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pD=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],gD=le("history",pD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mD=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],xD=le("image",mD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bD=[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]],nv=le("inbox",bD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],UN=le("info",yD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vD=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],av=le("key-round",vD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ND=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],ED=le("layout-dashboard",ND);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SD=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ct=le("loader-circle",SD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jD=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],_d=le("lock",jD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AD=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],BN=le("log-out",AD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wD=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],Rg=le("mail",wD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CD=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]],HN=le("map-pin",CD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DD=[["path",{d:"M11 6a13 13 0 0 0 8.4-2.8A1 1 0 0 1 21 4v12a1 1 0 0 1-1.6.8A13 13 0 0 0 11 14H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z",key:"q8bfy3"}],["path",{d:"M6 14a12 12 0 0 0 2.4 7.2 2 2 0 0 0 3.2-2.4A8 8 0 0 1 10 14",key:"1853fq"}],["path",{d:"M8 6v8",key:"15ugcq"}]],GN=le("megaphone",DD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OD=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],VN=le("menu",OD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RD=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],TD=le("message-circle",RD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kD=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],Tg=le("message-square",kD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _D=[["path",{d:"M6 18h8",key:"1borvv"}],["path",{d:"M3 22h18",key:"8prr45"}],["path",{d:"M14 22a7 7 0 1 0 0-14h-1",key:"1jwaiy"}],["path",{d:"M9 14h2",key:"197e7h"}],["path",{d:"M9 12a2 2 0 0 1-2-2V6h6v4a2 2 0 0 1-2 2Z",key:"1bmzmy"}],["path",{d:"M12 6V3a1 1 0 0 0-1-1H9a1 1 0 0 0-1 1v3",key:"1drr47"}]],MD=le("microscope",_D);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ID=[["path",{d:"M5 12h14",key:"1ays0h"}]],FN=le("minus",ID);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LD=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],zD=le("palette",LD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PD=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Mo=le("pencil",PD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UD=[["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5",key:"4mh3h7"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5",key:"1mdrzq"}]],BD=le("percent",UD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HD=[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]],qN=le("phone",HD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GD=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],VD=le("play",GD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FD=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],ft=le("plus",FD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qD=[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]],Va=le("printer",qD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $D=[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]],YD=le("radio-tower",$D);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QD=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],xu=le("refresh-cw",QD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WD=[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]],XD=le("rocket",WD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZD=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],sv=le("rotate-ccw",ZD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KD=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],Io=le("save",KD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JD=[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]],eO=le("scissors",JD);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tO=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],ha=le("search",tO);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nO=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Md=le("settings",nO);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aO=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],$N=le("share-2",aO);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sO=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],Id=le("shield-alert",sO);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rO=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Sr=le("shield-check",rO);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lO=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],iO=le("shield",lO);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oO=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],cO=le("smartphone",oO);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dO=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],uO=le("sparkles",dO);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fO=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],Lo=le("square-pen",fO);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hO=[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]],ua=le("stethoscope",hO);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pO=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],gO=le("tag",pO);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mO=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],rv=le("terminal",mO);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xO=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],$t=le("trash-2",xO);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bO=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],yO=le("trending-down",bO);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vO=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],YN=le("trending-up",vO);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NO=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],kg=le("triangle-alert",NO);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EO=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],SO=le("upload",EO);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jO=[["path",{d:"m16 11 2 2 4-4",key:"9rsbq5"}],["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],$l=le("user-check",jO);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AO=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],Ld=le("user-plus",AO);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wO=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],zo=le("user",wO);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CO=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],$n=le("users",CO);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DO=[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]],OO=le("wallet",DO);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RO=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],TO=le("wrench",RO);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kO=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Qe=le("x",kO);/** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _O=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],MO=le("zap",_O),IO=({activeTab:t,setActiveTab:e})=>{const n=J.getCurrentRole(),r=J.getCurrentUserName(),i=J.getCurrentUser(),c=J.getActiveWorkspace(),d=(c==null?void 0:c.cor)||"#2563eb",f=[{id:"dashboard",label:"VISÃO GERAL",icon:ED},{id:"clinicas",label:"MINHAS CLÍNICAS",icon:Cg},{id:"leads",label:"GESTÃO DE LEADS",icon:GN},{id:"pacientes",label:"PACIENTES",icon:$n},{id:"tratamentos",label:"MEUS TRATAMENTOS",icon:so},{id:"lancar-gto",label:"LANÇAR GTO",icon:so},{id:"agenda",label:"AGENDA",icon:Et},{id:"ortodontia",label:"ORTODONTIA",icon:Vl},{id:"financeiro",label:"FINANCEIRO",icon:Ba},{id:"contratos",label:"CONTRATOS",icon:za},{id:"relatorios",label:"RELATÓRIOS",icon:ko},{id:"dentistas",label:"DENTISTAS",icon:ua},{id:"especialidades",label:"ESPECIALIDADES",icon:pC},{id:"procedimentos",label:"PROCEDIMENTOS",icon:so},{id:"planos",label:"PLANOS / CONVÊNIOS",icon:vC},{id:"notificacoes",label:"NOTIFICAÇÕES",icon:uo},{id:"sync",label:"SINCRONIZAÇÃO",icon:xu},{id:"configuracoes",label:"CONFIGURAÇÕES",icon:Md}].filter(p=>["admin","donoclinica"].includes(n)?!0:n==="paciente"?["tratamentos","notificacoes","configuracoes"].includes(p.id):n==="dentista"?["dashboard","pacientes","tratamentos","agenda","ortodontia","notificacoes","clinicas","configuracoes","contratos"].includes(p.id):n==="funcionario"?["dashboard","leads","pacientes","tratamentos","lancar-gto","agenda","financeiro","relatorios","notificacoes","clinicas","configuracoes","contratos"].includes(p.id):!1),h=()=>{window.confirm("TEM CERTEZA QUE DESEJA SAIR DO SISTEMA?")&&J.logout()};return s.jsxs("div",{className:"w-64 bg-white border-r border-gray-200 h-screen flex flex-col shadow-xl md:shadow-none",children:[s.jsxs("div",{className:"p-6 flex items-center gap-3",children:[s.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center text-white font-bold shadow-lg transition-colors duration-500",style:{backgroundColor:d},children:s.jsx(Er,{size:18})}),s.jsxs("div",{children:[s.jsx("span",{className:"font-bold text-lg text-gray-800 block leading-tight tracking-tight",children:"SCOREODONTO"}),s.jsx("span",{className:"text-[10px] text-gray-400 font-bold uppercase tracking-wider",children:"POSTGRESQL + GOOGLE"})]})]}),s.jsx("nav",{className:"flex-1 px-4 py-2 space-y-1 overflow-y-auto custom-scrollbar",children:f.map(p=>{const b=p.icon,y=t===p.id;return s.jsxs("button",{onClick:()=>e(p.id),className:`w-full flex items-center gap-3 px-4 py-3 rounded-xl text-[11px] font-bold uppercase transition-all duration-300 group ${y?"text-white":"text-gray-500 hover:bg-gray-50"}`,style:{backgroundColor:y?d:"transparent",boxShadow:y?`0 10px 15px -5px ${d}44`:"none"},children:[s.jsx(b,{size:18,className:`${y?"text-white":"text-gray-400 group-hover:text-gray-600"} transition-colors`,style:{color:y?"#fff":void 0}}),p.label]},p.id)})}),s.jsxs("div",{className:"p-4 border-t border-gray-100 bg-gray-50/50 space-y-2",children:[s.jsxs("button",{onClick:()=>e("configuracoes"),className:"w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-all group",style:{backgroundColor:t==="configuracoes"?d:"transparent"},children:[s.jsx("div",{className:"w-8 h-8 bg-gray-100 rounded-full flex items-center justify-center text-gray-500 border border-gray-200 flex-shrink-0",children:s.jsx(zo,{size:15})}),s.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[s.jsx("p",{className:`text-[10px] font-black uppercase truncate leading-none ${t==="configuracoes"?"text-white":"text-gray-700"}`,children:r}),s.jsx("p",{className:`text-[9px] font-medium truncate mt-0.5 ${t==="configuracoes"?"text-white/70":"text-gray-400"}`,children:i})]}),s.jsx(Md,{size:14,className:t==="configuracoes"?"text-white":"text-gray-400"})]}),s.jsxs("button",{onClick:h,className:"w-full flex items-center gap-3 px-4 py-2 text-red-500 hover:bg-red-50 rounded-xl text-[10px] font-black uppercase transition-all",children:[s.jsx(BN,{size:16}),"SAIR DO SISTEMA"]})]})]})};var wr=TN();const LO=RN(wr),QN=w.createContext(void 0),zO=({children:t})=>{const[e,n]=w.useState([]),r=w.useCallback((c,d)=>{const f=Date.now();n(h=>[...h,{id:f,message:c,type:d}]),setTimeout(()=>{n(h=>h.filter(p=>p.id!==f))},4e3)},[]),i={toasts:e,addToast:r};return s.jsx(QN.Provider,{value:i,children:t})},Fe=()=>{const t=w.useContext(QN);if(!t)throw new Error("useToast must be used within a ToastProvider");return{...t,success:e=>t.addToast(e,"success"),error:e=>t.addToast(e,"error"),info:e=>t.addToast(e,"info")}},PO={success:s.jsx(Ua,{className:"text-green-500",size:20}),error:s.jsx(kg,{className:"text-red-500",size:20}),info:s.jsx(UN,{className:"text-blue-500",size:20})},UO={success:"bg-green-50 border-green-200",error:"bg-red-50 border-red-200",info:"bg-blue-50 border-blue-200"},BO=()=>{const{toasts:t}=Fe(),e=document.getElementById("toast-container");return e?wr.createPortal(s.jsx("div",{className:"fixed top-6 right-6 z-[100] space-y-3",children:t.map(n=>s.jsxs("div",{className:`w-80 p-4 rounded-xl shadow-lg flex items-start gap-3 border animate-in slide-in-from-top-4 ${UO[n.type]}`,children:[s.jsx("div",{className:"flex-shrink-0 mt-0.5",children:PO[n.type]}),s.jsx("p",{className:"flex-1 text-sm text-gray-800 font-bold uppercase",children:n.message})]},n.id))}),e):null},cn=({title:t,description:e,children:n})=>s.jsxs("div",{className:"flex justify-between items-center mb-6",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-gray-900 uppercase",children:t}),e&&s.jsx("p",{className:"text-gray-500 text-xs uppercase font-bold mt-1",children:e})]}),s.jsx("div",{className:"flex items-center gap-3",children:n})]});function _e(t,e=[]){const[n,r]=w.useState(null),[i,c]=w.useState(!0),[d,f]=w.useState(null),[h,p]=w.useState(0),b=w.useCallback(async()=>{c(!0),f(null);try{const m=await t();r(m)}catch(m){f(m instanceof Error?m:new Error("An unknown error occurred"))}finally{c(!1)}},[...e,h]);return w.useEffect(()=>{b()},[b]),{data:n,isLoading:i,error:d,refresh:()=>{p(m=>m+1)}}}const HO=()=>{const[t,e]=w.useState(!1),[n,r]=w.useState([]),[i,c]=w.useState(0),d=async()=>{try{const y=await J.getNotifications();r(y),c(y.filter(m=>!m.lida).length)}catch{console.error("Erro ao carregar notificações")}};w.useEffect(()=>{d();const y=setInterval(d,3e4);return()=>clearInterval(y)},[]);const f=()=>e(!t),h=async y=>{await J.markNotificationRead(y),r(m=>m.map(v=>v.id===y?{...v,lida:!0}:v)),c(m=>Math.max(0,m-1))},p=y=>{switch(y){case"agenda":return s.jsx(Et,{size:18,className:"text-blue-500"});case"financeiro":return s.jsx(Ba,{size:18,className:"text-emerald-500"});case"lead":return s.jsx($l,{size:18,className:"text-amber-500"});case"sistema":return s.jsx(Id,{size:18,className:"text-red-500"});default:return s.jsx(Tg,{size:18,className:"text-gray-500"})}},b=y=>{switch(y){case"agenda":return"Agenda";case"financeiro":return"Financeiro";case"lead":return"Novo Lead";case"sistema":return"Sistema";default:return"Geral"}};return s.jsx("div",{className:"relative z-[1002]",children:s.jsxs("div",{className:"relative",children:[s.jsxs("button",{onClick:f,className:"group relative w-11 h-11 flex items-center justify-center rounded-xl bg-white/80 backdrop-blur-md border border-white/20 shadow-[0_8px_32px_rgba(0,0,0,0.06)] hover:shadow-[0_8px_32px_rgba(59,130,246,0.15)] hover:border-blue-400/50 transition-all duration-300",children:[s.jsx(uo,{size:22,className:"text-slate-600 group-hover:text-blue-600 transition-colors"}),i>0&&s.jsxs("span",{className:"absolute -top-1.5 -right-1.5 flex h-5 w-5",children:[s.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-red-400 opacity-75"}),s.jsx("span",{className:"relative inline-flex rounded-full h-5 w-5 bg-red-500 text-[10px] font-bold text-white items-center justify-center shadow-lg",children:i})]})]}),t&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0",onClick:f}),s.jsxs("div",{className:"absolute right-0 mt-4 w-[380px] bg-white/95 backdrop-blur-lg rounded-2xl shadow-[0_20px_50px_rgba(0,0,0,0.15)] border border-white/20 overflow-hidden animate-in fade-in zoom-in-95 slide-in-from-top-4 duration-300 transform origin-top-right",children:[s.jsxs("div",{className:"px-6 py-5 bg-gradient-to-r from-slate-50 to-white border-b border-slate-100 flex justify-between items-center",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"font-bold text-slate-800 text-lg tracking-tight",children:"Centro de Notificações"}),s.jsxs("p",{className:"text-[11px] text-slate-400 font-medium uppercase tracking-wider",children:["Você tem ",i," novas mensagens"]})]}),s.jsx("button",{onClick:f,className:"p-2 hover:bg-slate-100 rounded-full transition-colors",children:s.jsx(Qe,{size:18,className:"text-slate-400"})})]}),s.jsx("div",{className:"max-h-[450px] overflow-y-auto custom-scrollbar bg-slate-50/30",children:n.length===0?s.jsxs("div",{className:"py-20 flex flex-col items-center justify-center text-center px-8",children:[s.jsx("div",{className:"w-16 h-16 bg-slate-100 rounded-full flex items-center justify-center mb-4",children:s.jsx(uo,{size:32,className:"text-slate-300"})}),s.jsx("p",{className:"text-slate-500 font-medium",children:"Tudo limpo por aqui!"}),s.jsx("p",{className:"text-xs text-slate-400 mt-1",children:"Não há notificações para mostrar no momento."})]}):s.jsx("div",{className:"divide-y divide-slate-100",children:n.map(y=>s.jsxs("div",{className:`group p-5 hover:bg-white transition-all duration-200 cursor-default ${y.lida?"":"bg-blue-50/40 relative"}`,children:[!y.lida&&s.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 bg-blue-500 rounded-r-full"}),s.jsxs("div",{className:"flex gap-4",children:[s.jsx("div",{className:`mt-1 h-10 w-10 flex-shrink-0 flex items-center justify-center rounded-xl ${y.tipo==="agenda"?"bg-blue-100 text-blue-600":y.tipo==="financeiro"?"bg-emerald-100 text-emerald-600":y.tipo==="lead"?"bg-amber-100 text-amber-600":"bg-red-100 text-red-600"}`,children:p(y.tipo)}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex justify-between items-center mb-1",children:[s.jsx("span",{className:"text-[11px] font-bold text-slate-400 uppercase tracking-wide",children:b(y.tipo)}),s.jsx("span",{className:"text-[10px] text-slate-400",children:new Date(y.data).toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})})]}),s.jsx("h4",{className:`text-sm font-bold leading-tight ${y.lida?"text-slate-600":"text-slate-900"}`,children:y.titulo}),s.jsx("p",{className:"text-xs text-slate-500 mt-1 line-clamp-2 leading-relaxed",children:y.mensagem}),!y.lida&&s.jsx("button",{onClick:()=>h(y.id),className:"text-[11px] text-blue-600 font-bold mt-3 opacity-0 group-hover:opacity-100 transition-opacity hover:underline",children:"MARCAR COMO LIDA"})]})]})]},y.id))})}),s.jsx("div",{className:"p-4 bg-white border-t border-slate-100 text-center",children:s.jsx("button",{onClick:()=>{history.pushState({},"","/notificacoes"),e(!1)},className:"text-xs font-bold text-slate-500 hover:text-blue-600 transition-colors tracking-widest uppercase",children:"Histórico Completo"})})]})]})]})})},cd=({title:t,value:e,icon:n,trend:r,isPositive:i,color:c,onClick:d})=>{const f={blue:"bg-blue-50 text-blue-600",green:"bg-emerald-50 text-emerald-600",purple:"bg-indigo-50 text-indigo-600",amber:"bg-amber-50 text-amber-600"};return s.jsxs("div",{onClick:d,className:`bg-white rounded-[2rem] p-8 border border-gray-100 shadow-[0_10px_40px_-15px_rgba(0,0,0,0.05)] hover:shadow-[0_20px_50px_-20px_rgba(0,0,0,0.1)] transition-all duration-500 group relative overflow-hidden ${d?"cursor-pointer":""}`,children:[s.jsx("div",{className:"absolute top-0 right-0 w-32 h-32 opacity-[0.03] -mr-8 -mt-8 rounded-full bg-current transform group-hover:scale-110 transition-transform duration-700"}),s.jsx("div",{className:"flex justify-between items-start relative z-10",children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:`w-12 h-12 ${f[c]} rounded-2xl flex items-center justify-center mb-2 group-hover:scale-110 transition-transform`,children:n}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] font-black text-gray-400 uppercase tracking-[0.2em]",children:t}),s.jsx("h3",{className:"text-3xl font-black text-gray-900 tracking-tight mt-1",children:e})]}),r&&s.jsxs("div",{className:`flex items-center gap-1.5 text-xs font-bold ${i?"text-emerald-600":"text-rose-600"}`,children:[s.jsx("div",{className:`p-0.5 rounded-full ${i?"bg-emerald-100":"bg-rose-100"}`,children:i?s.jsx(IN,{size:12}):s.jsx(_N,{size:12})}),r]})]})})]})},GO=()=>{const{data:t,isLoading:e}=_e(J.getDashboardStats),n=w.useMemo(()=>{if(!(t!=null&&t.growth)||t.growth.length===0)return Array(6).fill(null).map((h,p)=>({label:`MÊS ${p+1}`,receita:0,despesa:0,heightP:"0%",heightR:"0%"}));const f=Math.max(...t.growth.map(h=>Math.max(parseFloat(h.receita),parseFloat(h.despesa))),1e3);return t.growth.map(h=>{const[p,b]=h.mes.split("-");return{label:new Date(parseInt(p),parseInt(b)-1).toLocaleString("pt-BR",{month:"short"}).toUpperCase(),receita:parseFloat(h.receita),despesa:parseFloat(h.despesa),heightR:`${parseFloat(h.receita)/f*100}%`,heightD:`${parseFloat(h.despesa)/f*100}%`}}).slice(-6)},[t]),r=J.getCurrentRole(),i=["admin","donoclinica","funcionario"].includes(r);if(e)return s.jsx("div",{className:"flex items-center justify-center h-96",children:s.jsx("div",{className:"w-12 h-12 border-4 border-blue-600 border-t-transparent rounded-full animate-spin"})});const c=(t==null?void 0:t.stats)||{totalPacientes:0,totalAgendamentos:0,totalLeads:0,faturamentoTotal:0},d=(t==null?void 0:t.recentAgendamentos)||[];return s.jsxs("div",{className:"space-y-10 pb-10",children:[s.jsxs("header",{className:"flex flex-col md:flex-row md:items-end justify-between gap-6",children:[s.jsx("div",{children:s.jsx(cn,{title:"DASHBOARD ANALÍTICO",description:"Informações consolidadas em tempo real da sua clínica."})}),s.jsxs("div",{className:"flex items-center gap-3",children:[(r==="admin"||r==="donoclinica"||r==="funcionario")&&s.jsxs("button",{onClick:()=>history.pushState({},"","/relatorios"),className:"bg-white text-gray-900 border border-gray-200 px-6 py-3 rounded-2xl text-xs font-black uppercase tracking-widest hover:bg-gray-50 transition-all flex items-center gap-2 shadow-sm",children:[s.jsx(Fl,{size:16})," Relatórios"]}),(r==="admin"||r==="donoclinica"||r==="funcionario")&&s.jsxs("button",{onClick:()=>history.pushState({},"","/pacientes"),className:"bg-blue-600 text-white px-6 py-3 rounded-2xl text-xs font-black uppercase tracking-widest hover:bg-blue-700 hover:shadow-xl hover:shadow-blue-200 transition-all flex items-center gap-2 shadow-lg shadow-blue-100",children:[s.jsx(ft,{size:16})," Novo Paciente"]}),s.jsx(HO,{})]})]}),s.jsxs("div",{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-${i?"4":"2"} gap-8`,children:[s.jsx(cd,{title:"Pacientes Ativos",value:c.totalPacientes,icon:s.jsx($n,{size:24}),trend:"+12% este mês",isPositive:!0,color:"blue",onClick:()=>history.pushState({},"","/pacientes")}),i&&s.jsx(cd,{title:"Faturamento Bruto",value:new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL"}).format(c.faturamentoTotal),icon:s.jsx(Ba,{size:24}),trend:"+5.4% vs mês ant.",isPositive:!0,color:"green",onClick:()=>history.pushState({},"","/financeiro")}),s.jsx(cd,{title:"Agendamentos",value:c.totalAgendamentos,icon:s.jsx(Et,{size:24}),trend:"82% de ocupação",isPositive:!0,color:"purple",onClick:()=>history.pushState({},"","/agenda")}),i&&s.jsx(cd,{title:"Novas Leads",value:c.totalLeads,icon:s.jsx(GN,{size:24}),trend:"-2% vs ontem",isPositive:!1,color:"amber",onClick:()=>history.pushState({},"","/leads")})]}),s.jsxs("div",{className:`grid lg:grid-cols-${i?"3":"1"} gap-8`,children:[i&&s.jsxs("div",{className:"lg:col-span-2 bg-white rounded-[2.5rem] p-10 border border-gray-100 shadow-[0_20px_50px_-15px_rgba(0,0,0,0.03)]",children:[s.jsxs("div",{className:"flex justify-between items-center mb-10",children:[s.jsxs("div",{children:[s.jsx("h4",{className:"text-xl font-black text-gray-900 uppercase tracking-tighter italic",children:"Crescimento Mensal"}),s.jsx("p",{className:"text-xs font-bold text-gray-400 mt-1 uppercase",children:"Receitas vs Despesas Reais"})]}),s.jsxs("select",{id:"chart-period-dashboard",name:"chart-period",className:"bg-gray-50 border-none text-[10px] font-black uppercase tracking-widest px-4 py-2 rounded-xl focus:ring-2 focus:ring-blue-100 cursor-pointer",children:[s.jsx("option",{value:"6m",children:"Últimos 6 meses"}),s.jsx("option",{value:"year",children:"Este Ano"})]})]}),s.jsx("div",{className:"h-64 flex items-end justify-between gap-4 px-4",children:n.map((f,h)=>s.jsxs("div",{className:"flex-1 flex flex-col items-center gap-3 group",children:[s.jsxs("div",{className:"w-full flex justify-center gap-1 items-end h-[200px] bg-slate-50/50 rounded-2xl p-1",children:[s.jsx("div",{title:`Despesa: R$ ${f.despesa}`,className:"w-1/3 bg-rose-200 rounded-lg group-hover:bg-rose-300 transition-all duration-500 origin-bottom",style:{height:f.heightD||"5%"}}),s.jsx("div",{title:`Receita: R$ ${f.receita}`,className:"w-1/3 bg-blue-500 rounded-lg group-hover:bg-blue-600 shadow-sm group-hover:shadow-blue-200 transition-all duration-500 origin-bottom",style:{height:f.heightR||"5%"}})]}),s.jsx("span",{className:"text-[10px] font-black text-gray-400 uppercase tracking-tighter",children:f.label})]},h))}),s.jsxs("div",{className:"flex justify-center gap-6 mt-6",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-3 h-3 bg-blue-500 rounded-sm"}),s.jsx("span",{className:"text-[10px] font-bold text-gray-500 uppercase",children:"Receitas"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-3 h-3 bg-rose-200 rounded-sm"}),s.jsx("span",{className:"text-[10px] font-bold text-gray-500 uppercase",children:"Despesas"})]})]})]}),s.jsxs("div",{className:"bg-gray-900 rounded-[2.5rem] p-10 shadow-2xl shadow-blue-200 overflow-hidden relative",children:[s.jsx("div",{className:"absolute top-0 right-0 w-32 h-32 bg-blue-600/20 blur-[80px] rounded-full"}),s.jsxs("div",{className:"relative z-10 h-full flex flex-col",children:[s.jsx("h4",{className:"text-xl font-black text-white uppercase tracking-tighter italic mb-8",children:"Últimos Agendamentos"}),s.jsx("div",{className:"space-y-6 flex-1 overflow-y-auto custom-scrollbar pr-2",children:d.length>0?d.map(f=>s.jsxs("div",{onClick:()=>history.pushState({},"","/agenda"),className:"flex items-center gap-4 group cursor-pointer",children:[s.jsx("div",{className:"w-12 h-12 rounded-2xl bg-white/10 flex items-center justify-center text-blue-400 group-hover:bg-blue-600 group-hover:text-white transition-all duration-300 flex-shrink-0",children:s.jsx(Et,{size:20})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm font-black text-white uppercase tracking-tight truncate",children:f.pacientenome||"Paciente"}),s.jsxs("div",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest mt-0.5 truncate",children:[f.dentistaNome||"Dr. Dentista"," • ",new Date(f.start_time).toLocaleDateString("pt-BR")," ",new Date(f.start_time).toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})]})]}),s.jsx(Ts,{size:16,className:"text-gray-600 group-hover:text-white group-hover:translate-x-1 transition-all"})]},f.id)):s.jsxs("div",{className:"flex flex-col items-center justify-center py-10 opacity-40",children:[s.jsx(Et,{size:40,className:"text-white mb-2"}),s.jsx("p",{className:"text-white text-[10px] font-bold uppercase tracking-widest",children:"Nenhum agendamento recente."})]})}),s.jsxs("button",{onClick:()=>history.pushState({},"","/agenda"),className:"w-full mt-8 bg-white/5 border border-white/10 text-white py-4 rounded-2xl text-[10px] font-black uppercase tracking-widest hover:bg-white/10 transition-all flex items-center justify-center gap-2 group",children:["Ver Agenda Completa ",s.jsx(Ls,{size:14,className:"group-hover:translate-x-1 transition-transform"})]})]})]})]})]})},VO=()=>s.jsx("div",{className:"col-span-3 flex justify-center items-center py-10",children:s.jsx(Ct,{className:"animate-spin text-blue-600",size:32})}),FO=({error:t})=>s.jsxs("div",{className:"col-span-3 text-center py-10 text-red-500 uppercase font-bold text-sm",children:["ERRO AO CARREGAR LEADS: ",t.message]}),qO=({onClose:t,onSaved:e})=>{const n=Fe(),[r,i]=w.useState({nome:"",sobrenome:"",whatsapp:"",tipoInteresse:"Particular"});w.useEffect(()=>{const d=f=>{f.key==="Escape"&&t()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[t]);const c=async d=>{if(d.preventDefault(),!r.nome||!r.whatsapp){n.error("PREENCHA NOME E WHATSAPP.");return}try{await J.saveLead({...r,status:"Novo",dataCadastro:new Date().toISOString()}),n.success("LEAD CADASTRADO!"),e(),t()}catch{n.error("ERRO AO CADASTRAR LEAD.")}};return s.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center backdrop-blur-sm p-0",children:s.jsxs("div",{className:"bg-white shadow-2xl w-full h-dvh md:w-[96vw] md:h-[98vh] rounded-none md:rounded-xl flex flex-col overflow-hidden animate-in fade-in zoom-in-50 duration-200",children:[s.jsxs("div",{className:"px-5 py-4 border-b border-gray-200 flex justify-between items-center flex-shrink-0 bg-gradient-to-r from-green-50 to-white",children:[s.jsxs("h2",{className:"text-base font-bold text-gray-800 uppercase flex items-center gap-2",children:[s.jsx(Ld,{size:18,className:"text-green-500"})," CADASTRAR NOVO LEAD"]}),s.jsx("button",{onClick:t,className:"text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-lg p-1.5 transition-colors",children:s.jsx(Qe,{size:22})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-5 lg:p-8",children:s.jsxs("form",{onSubmit:c,className:"space-y-4 max-w-2xl mx-auto",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-bold text-gray-500 uppercase",children:"NOME"}),s.jsx("input",{type:"text",value:r.nome,onChange:d=>i(f=>({...f,nome:d.target.value.toUpperCase()})),className:"w-full mt-1 border border-gray-300 rounded-lg p-2.5 text-sm font-semibold uppercase-input",placeholder:"NOME",required:!0})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-bold text-gray-500 uppercase",children:"SOBRENOME"}),s.jsx("input",{type:"text",value:r.sobrenome,onChange:d=>i(f=>({...f,sobrenome:d.target.value.toUpperCase()})),className:"w-full mt-1 border border-gray-300 rounded-lg p-2.5 text-sm font-semibold uppercase-input",placeholder:"SOBRENOME"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-bold text-gray-500 uppercase",children:"WHATSAPP"}),s.jsx("input",{type:"text",value:r.whatsapp,onChange:d=>i(f=>({...f,whatsapp:d.target.value})),className:"w-full mt-1 border border-gray-300 rounded-lg p-2.5 text-sm",placeholder:"(XX) XXXXX-XXXX",required:!0})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-bold text-gray-500 uppercase",children:"TIPO DE INTERESSE"}),s.jsxs("select",{value:r.tipoInteresse,onChange:d=>i(f=>({...f,tipoInteresse:d.target.value})),className:"w-full mt-1 border border-gray-300 rounded-lg p-2.5 text-sm bg-white uppercase-select",children:[s.jsx("option",{value:"Particular",children:"PARTICULAR"}),s.jsx("option",{value:"Plano",children:"PLANO"})]})]}),s.jsxs("div",{className:"flex justify-end gap-3 pt-6",children:[s.jsx("button",{type:"button",onClick:t,className:"px-6 py-2.5 bg-gray-100 hover:bg-gray-200 text-gray-700 font-bold rounded-lg text-sm uppercase",children:"CANCELAR"}),s.jsxs("button",{type:"submit",className:"px-6 py-2.5 bg-green-600 hover:bg-green-700 text-white font-bold rounded-lg text-sm uppercase flex items-center gap-2",children:[s.jsx(Ld,{size:16})," CADASTRAR"]})]})]})})]})})},$O=()=>{const{data:t,isLoading:e,error:n,refresh:r}=_e(J.getLeads),{data:i}=_e(J.getDentistas),[c,d]=w.useState(!1),[f,h]=w.useState(!1),[p,b]=w.useState(null),[y,m]=w.useState("TODOS"),[v,N]=w.useState(!1),S=Fe();w.useEffect(()=>{if(!c)return;const O=A=>{A.key==="Escape"&&d(!1)};return document.addEventListener("keydown",O),()=>{document.removeEventListener("keydown",O)}},[c]);const j=async O=>{if(O.preventDefault(),!!p)try{S.info(`FUNCIONALIDADE DE CONVERSÃO PARA ${p.nome} EM DESENVOLVIMENTO.`),d(!1)}catch{S.error("FALHA AO CONVERTER LEAD.")}},R=["TODOS","NOVO","CONVERTIDO"],C=t==null?void 0:t.filter(O=>{var A;return y==="TODOS"?!0:((A=O.status)==null?void 0:A.toUpperCase())===y});return s.jsxs("div",{className:"space-y-6",children:[s.jsx(cn,{title:"GESTÃO DE LEADS",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("div",{className:"relative",children:[s.jsxs("button",{onClick:()=>N(O=>!O),className:"bg-white border border-gray-300 text-gray-600 px-3 py-2 rounded-lg text-sm flex items-center gap-2 hover:bg-gray-50 uppercase font-bold",children:[s.jsx(mu,{size:16}),y,s.jsx(_o,{size:14,className:`transition-transform ${v?"rotate-180":""}`})]}),v&&s.jsx("div",{className:"absolute right-0 mt-1 bg-white border border-gray-200 rounded-lg shadow-lg z-10 min-w-[140px]",children:R.map(O=>s.jsx("button",{onClick:()=>{m(O),N(!1)},className:`w-full text-left px-4 py-2 text-sm font-bold uppercase hover:bg-gray-50 ${y===O?"text-blue-600 bg-blue-50":"text-gray-700"}`,children:O},O))})]}),s.jsxs("button",{onClick:()=>h(!0),className:"bg-green-600 text-white px-4 py-2 rounded-lg text-sm flex items-center gap-2 hover:bg-green-700 uppercase font-bold shadow-sm",children:[s.jsx(ft,{size:16})," NOVO LEAD"]})]})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[e&&s.jsx(VO,{}),n&&s.jsx(FO,{error:n}),C&&C.map(O=>s.jsxs("div",{className:`bg-white rounded-xl shadow-sm border ${O.status==="Novo"?"border-amber-200 bg-amber-50/30":"border-gray-200"} p-6 relative`,children:[O.status==="Novo"&&s.jsx("div",{className:"absolute top-4 right-4 w-2 h-2 bg-amber-500 rounded-full animate-pulse"}),s.jsxs("div",{className:"flex items-start justify-between mb-4",children:[s.jsxs("div",{children:[s.jsxs("h3",{className:"text-lg font-bold text-gray-900 uppercase",children:[O.nome," ",O.sobrenome]}),s.jsxs("p",{className:"text-sm text-gray-500 flex items-center gap-1 mt-1 font-medium",children:[s.jsx(Tg,{size:14})," ",O.whatsapp]})]}),s.jsx("span",{className:`px-2 py-1 text-xs font-bold rounded uppercase ${O.tipoInteresse==="Particular"?"bg-orange-100 text-orange-800":"bg-purple-100 text-purple-800"}`,children:O.tipoInteresse})]}),s.jsxs("div",{className:"text-xs text-gray-400 mb-6 font-bold uppercase",children:["CADASTRADO EM: ",new Date(O.dataCadastro).toLocaleDateString()]}),O.status!=="Convertido"?s.jsxs("button",{onClick:()=>{b(O),d(!0)},className:"w-full py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg flex items-center justify-center gap-2 font-bold transition-colors uppercase text-xs",children:[s.jsx(Ld,{size:18})," AGENDAR E CADASTRAR"]}):s.jsxs("div",{className:"w-full py-2 bg-gray-100 text-gray-500 rounded-lg flex items-center justify-center gap-2 font-bold uppercase text-xs",children:[s.jsx(Ua,{size:18})," CONVERTIDO"]})]},O.id)),(C==null?void 0:C.length)===0&&!e&&s.jsx("div",{className:"col-span-3 text-center py-10 text-gray-400 uppercase font-bold text-sm",children:"NENHUM LEAD ENCONTRADO."})]}),c&&p&&s.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center backdrop-blur-sm p-0",children:s.jsxs("div",{className:"bg-white shadow-2xl w-full h-dvh md:w-[96vw] md:h-[98vh] rounded-none md:rounded-xl flex flex-col overflow-hidden animate-in fade-in zoom-in-50 duration-200",children:[s.jsxs("div",{className:"px-5 py-4 border-b border-gray-200 flex justify-between items-center flex-shrink-0 bg-gradient-to-r from-blue-50 to-white",children:[s.jsxs("h3",{className:"text-lg font-bold text-gray-800 uppercase flex items-center gap-2",children:[s.jsx(Ld,{size:18,className:"text-blue-500"})," CONVERTER LEAD"]}),s.jsx("button",{onClick:()=>d(!1),className:"text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-lg p-1.5 transition-colors",children:s.jsx(Qe,{size:22})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-5 lg:p-8",children:s.jsxs("form",{onSubmit:j,className:"space-y-4 max-w-2xl mx-auto",children:[s.jsxs("div",{className:"bg-blue-50 p-4 rounded-lg mb-4 text-xs text-blue-800 border border-blue-100 font-bold uppercase",children:["AO SALVAR, O SISTEMA IRÁ AUTOMATICAMENTE ",s.jsx("strong",{children:"CADASTRAR O PACIENTE"})," E CRIAR O AGENDAMENTO."]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-bold text-gray-700 mb-1 uppercase",children:"PACIENTE"}),s.jsx("input",{disabled:!0,value:`${p.nome} ${p.sobrenome}`.toUpperCase(),className:"w-full bg-gray-100 border border-gray-300 rounded-lg p-2.5 text-gray-500 uppercase font-bold"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-bold text-gray-700 mb-1 uppercase",children:"DATA AGENDAMENTO"}),s.jsx("input",{type:"date",required:!0,className:"w-full border border-gray-300 rounded-lg p-2.5 font-semibold"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-bold text-gray-700 mb-1 uppercase",children:"HORA"}),s.jsx("input",{type:"time",required:!0,className:"w-full border border-gray-300 rounded-lg p-2.5 font-semibold"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-bold text-gray-700 mb-1 uppercase",children:"DENTISTA RESPONSÁVEL"}),s.jsx("select",{className:"w-full border border-gray-300 rounded-lg p-2.5 bg-white uppercase-select font-semibold",children:i&&i.map(O=>s.jsx("option",{value:O.id,children:O.nome},O.id))})]}),s.jsx("div",{className:"pt-6",children:s.jsx("button",{type:"submit",className:"w-full bg-green-600 text-white py-3 rounded-lg font-bold hover:bg-green-700 uppercase text-sm shadow-sm transition-all",children:"CONFIRMAR AGENDAMENTO"})})]})})]})}),f&&s.jsx(qO,{onClose:()=>h(!1),onSaved:r})]})},YO=()=>{const[t,e]=w.useState({nome:"",sobrenome:"",cpf:"",whatsapp:"",tipo:""}),[n,r]=w.useState(!1),[i,c]=w.useState(!1),d=Fe(),f=async p=>{if(p.preventDefault(),r(!0),!t.tipo){d.error("POR FAVOR, SELECIONE PARTICULAR OU PLANO."),r(!1);return}try{if(await J.checkCpfExists(t.cpf)){d.error("CPF JÁ CADASTRADO. ENTRE EM CONTATO PELO WHATSAPP."),r(!1);return}await J.saveLead({nome:t.nome,sobrenome:t.sobrenome,cpf:t.cpf,whatsapp:t.whatsapp,tipoInteresse:t.tipo}),c(!0)}catch{d.error("ERRO AO ENVIAR DADOS. TENTE NOVAMENTE.")}finally{r(!1)}},h=p=>{e({...t,[p.target.name]:p.target.value.toUpperCase()})};return i?s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-white p-4",children:s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"w-16 h-16 bg-green-100 text-green-600 rounded-full flex items-center justify-center mx-auto mb-4",children:s.jsx(Ua,{size:32})}),s.jsx("h2",{className:"text-xl font-bold text-amber-900 uppercase",children:"MENSAGEM ENVIADA!"}),s.jsx("p",{className:"text-amber-800 mt-2 uppercase font-bold text-sm",children:"NOSSA EQUIPE ENTRARÁ EM CONTATO EM BREVE."})]})}):s.jsx("div",{className:"min-h-screen bg-white flex flex-col items-center justify-center p-4",children:s.jsxs("div",{className:"w-full max-w-md",children:[s.jsx("h1",{className:"text-center font-bold text-xl mb-6 text-black uppercase",children:"DEIXE SEU CONTATO"}),s.jsxs("form",{onSubmit:f,className:"space-y-4",children:[s.jsx("input",{type:"text",name:"nome",placeholder:"NOME",className:"w-full border border-amber-700 rounded-lg p-3 text-gray-800 outline-none focus:ring-2 focus:ring-amber-500 placeholder-gray-500 uppercase-input",required:!0,value:t.nome,onChange:h}),s.jsx("input",{type:"text",name:"sobrenome",placeholder:"SOBRENOME",className:"w-full border border-amber-700 rounded-lg p-3 text-gray-800 outline-none focus:ring-2 focus:ring-amber-500 placeholder-gray-500 uppercase-input",required:!0,value:t.sobrenome,onChange:h}),s.jsx("input",{type:"text",name:"cpf",placeholder:"CPF",className:"w-full border border-amber-700 rounded-lg p-3 text-gray-800 outline-none focus:ring-2 focus:ring-amber-500 placeholder-gray-500 uppercase-input",required:!0,value:t.cpf,onChange:h}),s.jsx("input",{type:"text",name:"whatsapp",placeholder:"WHATSAPP",className:"w-full border border-amber-700 rounded-lg p-3 text-gray-800 outline-none focus:ring-2 focus:ring-amber-500 placeholder-gray-500 uppercase-input",required:!0,value:t.whatsapp,onChange:h}),s.jsxs("div",{className:"flex gap-4",children:[s.jsx("button",{type:"button",onClick:()=>e({...t,tipo:"Particular"}),className:`flex-1 py-3 rounded-lg font-bold uppercase text-sm transition-colors border ${t.tipo==="Particular"?"bg-amber-800 text-white border-amber-800":"bg-amber-600 text-white border-amber-600 hover:bg-amber-700"}`,children:"PARTICULAR"}),s.jsx("button",{type:"button",onClick:()=>e({...t,tipo:"Plano"}),className:`flex-1 py-3 rounded-lg font-bold uppercase text-sm transition-colors border ${t.tipo==="Plano"?"bg-purple-800 text-white border-purple-800":"bg-purple-600 text-white border-purple-600 hover:bg-purple-700"}`,children:"PLANO"})]}),s.jsx("button",{type:"submit",disabled:n,className:"w-full py-4 bg-gray-800 text-white font-bold rounded-lg mt-6 shadow-sm hover:opacity-90 transition-opacity uppercase disabled:bg-gray-400",children:n?"VERIFICANDO...":"ENVIAR"})]})]})})};function Wt(t){return`Minified Redux error #${t}; visit https://redux.js.org/Errors?code=${t} for the full message or use the non-minified dev environment for full errors. `}var QO=typeof Symbol=="function"&&Symbol.observable||"@@observable",lv=QO,iv=()=>Math.random().toString(36).substring(7).split("").join("."),WO={INIT:`@@redux/INIT${iv()}`,REPLACE:`@@redux/REPLACE${iv()}`},ov=WO;function XO(t){if(typeof t!="object"||t===null)return!1;let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e||Object.getPrototypeOf(t)===null}function WN(t,e,n){if(typeof t!="function")throw new Error(Wt(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(Wt(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(Wt(1));return n(WN)(t,e)}let r=t,i=e,c=new Map,d=c,f=0,h=!1;function p(){d===c&&(d=new Map,c.forEach((j,R)=>{d.set(R,j)}))}function b(){if(h)throw new Error(Wt(3));return i}function y(j){if(typeof j!="function")throw new Error(Wt(4));if(h)throw new Error(Wt(5));let R=!0;p();const C=f++;return d.set(C,j),function(){if(R){if(h)throw new Error(Wt(6));R=!1,p(),d.delete(C),c=null}}}function m(j){if(!XO(j))throw new Error(Wt(7));if(typeof j.type>"u")throw new Error(Wt(8));if(typeof j.type!="string")throw new Error(Wt(17));if(h)throw new Error(Wt(9));try{h=!0,i=r(i,j)}finally{h=!1}return(c=d).forEach(C=>{C()}),j}function v(j){if(typeof j!="function")throw new Error(Wt(10));r=j,m({type:ov.REPLACE})}function N(){const j=y;return{subscribe(R){if(typeof R!="object"||R===null)throw new Error(Wt(11));function C(){const A=R;A.next&&A.next(b())}return C(),{unsubscribe:j(C)}},[lv](){return this}}}return m({type:ov.INIT}),{dispatch:m,subscribe:y,getState:b,replaceReducer:v,[lv]:N}}function cv(t,e){return function(...n){return e(t.apply(this,n))}}function dv(t,e){if(typeof t=="function")return cv(t,e);if(typeof t!="object"||t===null)throw new Error(Wt(16));const n={};for(const r in t){const i=t[r];typeof i=="function"&&(n[r]=cv(i,e))}return n}function XN(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function ZO(...t){return e=>(n,r)=>{const i=e(n,r);let c=()=>{throw new Error(Wt(15))};const d={getState:i.getState,dispatch:(h,...p)=>c(h,...p)},f=t.map(h=>h(d));return c=XN(...f)(i.dispatch),{...i,dispatch:c}}}var sp={exports:{}},rp={};/** * @license React * use-sync-external-store-with-selector.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 uv;function KO(){if(uv)return rp;uv=1;var t=pu();function e(h,p){return h===p&&(h!==0||1/h===1/p)||h!==h&&p!==p}var n=typeof Object.is=="function"?Object.is:e,r=t.useSyncExternalStore,i=t.useRef,c=t.useEffect,d=t.useMemo,f=t.useDebugValue;return rp.useSyncExternalStoreWithSelector=function(h,p,b,y,m){var v=i(null);if(v.current===null){var N={hasValue:!1,value:null};v.current=N}else N=v.current;v=d(function(){function j(k){if(!R){if(R=!0,C=k,k=y(k),m!==void 0&&N.hasValue){var _=N.value;if(m(_,k))return O=_}return O=k}if(_=O,n(C,k))return _;var B=y(k);return m!==void 0&&m(_,B)?(C=k,_):(C=k,O=B)}var R=!1,C,O,A=b===void 0?null:b;return[function(){return j(p())},A===null?void 0:function(){return j(A())}]},[p,b,y,m]);var S=r(h,v[0],v[1]);return c(function(){N.hasValue=!0,N.value=S},[S]),f(S),S},rp}var fv;function JO(){return fv||(fv=1,sp.exports=KO()),sp.exports}JO();var eR=w.version.startsWith("19"),tR=Symbol.for(eR?"react.transitional.element":"react.element"),nR=Symbol.for("react.portal"),aR=Symbol.for("react.fragment"),sR=Symbol.for("react.strict_mode"),rR=Symbol.for("react.profiler"),lR=Symbol.for("react.consumer"),iR=Symbol.for("react.context"),ZN=Symbol.for("react.forward_ref"),oR=Symbol.for("react.suspense"),cR=Symbol.for("react.suspense_list"),_g=Symbol.for("react.memo"),dR=Symbol.for("react.lazy"),uR=ZN,fR=_g;function hR(t){if(typeof t=="object"&&t!==null){const{$$typeof:e}=t;switch(e){case tR:switch(t=t.type,t){case aR:case rR:case sR:case oR:case cR:return t;default:switch(t=t&&t.$$typeof,t){case iR:case ZN:case dR:case _g:return t;case lR:return t;default:return e}}case nR:return e}}}function pR(t){return hR(t)===_g}function gR(t,e,n,r,{areStatesEqual:i,areOwnPropsEqual:c,areStatePropsEqual:d}){let f=!1,h,p,b,y,m;function v(C,O){return h=C,p=O,b=t(h,p),y=e(r,p),m=n(b,y,p),f=!0,m}function N(){return b=t(h,p),e.dependsOnOwnProps&&(y=e(r,p)),m=n(b,y,p),m}function S(){return t.dependsOnOwnProps&&(b=t(h,p)),e.dependsOnOwnProps&&(y=e(r,p)),m=n(b,y,p),m}function j(){const C=t(h,p),O=!d(C,b);return b=C,O&&(m=n(b,y,p)),m}function R(C,O){const A=!c(O,p),k=!i(C,h,O,p);return h=C,p=O,A&&k?N():A?S():k?j():m}return function(O,A){return f?R(O,A):v(O,A)}}function mR(t,{initMapStateToProps:e,initMapDispatchToProps:n,initMergeProps:r,...i}){const c=e(t,i),d=n(t,i),f=r(t,i);return gR(c,d,f,t,i)}function xR(t,e){const n={};for(const r in t){const i=t[r];typeof i=="function"&&(n[r]=(...c)=>e(i(...c)))}return n}function Hp(t){return function(n){const r=t(n);function i(){return r}return i.dependsOnOwnProps=!1,i}}function hv(t){return t.dependsOnOwnProps?!!t.dependsOnOwnProps:t.length!==1}function KN(t,e){return function(r,{displayName:i}){const c=function(f,h){return c.dependsOnOwnProps?c.mapToProps(f,h):c.mapToProps(f,void 0)};return c.dependsOnOwnProps=!0,c.mapToProps=function(f,h){c.mapToProps=t,c.dependsOnOwnProps=hv(t);let p=c(f,h);return typeof p=="function"&&(c.mapToProps=p,c.dependsOnOwnProps=hv(p),p=c(f,h)),p},c}}function Mg(t,e){return(n,r)=>{throw new Error(`Invalid value of type ${typeof t} for ${e} argument when connecting component ${r.wrappedComponentName}.`)}}function bR(t){return t&&typeof t=="object"?Hp(e=>xR(t,e)):t?typeof t=="function"?KN(t):Mg(t,"mapDispatchToProps"):Hp(e=>({dispatch:e}))}function yR(t){return t?typeof t=="function"?KN(t):Mg(t,"mapStateToProps"):Hp(()=>({}))}function vR(t,e,n){return{...n,...t,...e}}function NR(t){return function(n,{displayName:r,areMergedPropsEqual:i}){let c=!1,d;return function(h,p,b){const y=t(h,p,b);return c?i(y,d)||(d=y):(c=!0,d=y),d}}}function ER(t){return t?typeof t=="function"?NR(t):Mg(t,"mergeProps"):()=>vR}function SR(t){t()}function jR(){let t=null,e=null;return{clear(){t=null,e=null},notify(){SR(()=>{let n=t;for(;n;)n.callback(),n=n.next})},get(){const n=[];let r=t;for(;r;)n.push(r),r=r.next;return n},subscribe(n){let r=!0;const i=e={callback:n,next:null,prev:e};return i.prev?i.prev.next=i:t=i,function(){!r||t===null||(r=!1,i.next?i.next.prev=i.prev:e=i.prev,i.prev?i.prev.next=i.next:t=i.next)}}}}var pv={notify(){},get:()=>[]};function JN(t,e){let n,r=pv,i=0,c=!1;function d(S){b();const j=r.subscribe(S);let R=!1;return()=>{R||(R=!0,j(),y())}}function f(){r.notify()}function h(){N.onStateChange&&N.onStateChange()}function p(){return c}function b(){i++,n||(n=e?e.addNestedSub(h):t.subscribe(h),r=jR())}function y(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=pv)}function m(){c||(c=!0,b())}function v(){c&&(c=!1,y())}const N={addNestedSub:d,notifyNestedSubs:f,handleChangeWrapper:h,isSubscribed:p,trySubscribe:m,tryUnsubscribe:v,getListeners:()=>r};return N}var AR=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",wR=AR(),CR=()=>typeof navigator<"u"&&navigator.product==="ReactNative",DR=CR(),OR=()=>wR||DR?w.useLayoutEffect:w.useEffect,zd=OR();function gv(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function lp(t,e){if(gv(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;const n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(let i=0;it(...e),n)}function HR(t,e,n,r,i,c){t.current=r,n.current=!1,i.current&&(i.current=null,c())}function GR(t,e,n,r,i,c,d,f,h,p,b){if(!t)return()=>{};let y=!1,m=null;const v=()=>{if(y||!f.current)return;const S=e.getState();let j,R;try{j=r(S,i.current)}catch(C){R=C,m=C}R||(m=null),j===c.current?d.current||p():(c.current=j,h.current=j,d.current=!0,b())};return n.onStateChange=v,n.trySubscribe(),v(),()=>{if(y=!0,n.tryUnsubscribe(),n.onStateChange=null,m)throw m}}function VR(t,e){return t===e}function FR(t,e,n,{pure:r,areStatesEqual:i=VR,areOwnPropsEqual:c=lp,areStatePropsEqual:d=lp,areMergedPropsEqual:f=lp,forwardRef:h=!1,context:p=tE}={}){const b=p,y=yR(t),m=bR(e),v=ER(n),N=!!t;return j=>{const R=j.displayName||j.name||"Component",C=`Connect(${R})`,O={shouldHandleStateChanges:N,displayName:C,wrappedComponentName:R,WrappedComponent:j,initMapStateToProps:y,initMapDispatchToProps:m,initMergeProps:v,areStatesEqual:i,areStatePropsEqual:d,areOwnPropsEqual:c,areMergedPropsEqual:f};function A(B){const[F,G,ee]=w.useMemo(()=>{const{reactReduxForwardedRef:ue,...Oe}=B;return[B.context,ue,Oe]},[B]),ne=w.useMemo(()=>{let ue=b;return F!=null&&F.Consumer,ue},[F,b]),oe=w.useContext(ne),Q=!!B.store&&!!B.store.getState&&!!B.store.dispatch,ce=!!oe&&!!oe.store,he=Q?B.store:oe.store,H=ce?oe.getServerState:he.getState,V=w.useMemo(()=>mR(he.dispatch,O),[he]),[P,W]=w.useMemo(()=>{if(!N)return UR;const ue=JN(he,Q?void 0:oe.subscription),Oe=ue.notifyNestedSubs.bind(ue);return[ue,Oe]},[he,Q,oe]),te=w.useMemo(()=>Q?oe:{...oe,subscription:P},[Q,oe,P]),T=w.useRef(void 0),X=w.useRef(ee),ie=w.useRef(void 0),de=w.useRef(!1),ve=w.useRef(!1),je=w.useRef(void 0);zd(()=>(ve.current=!0,()=>{ve.current=!1}),[]);const Te=w.useMemo(()=>()=>ie.current&&ee===X.current?ie.current:V(he.getState(),ee),[he,ee]),bt=w.useMemo(()=>Oe=>P?GR(N,he,P,V,X,T,de,ve,ie,W,Oe):()=>{},[P]);BR(HR,[X,T,de,ee,ie,W]);let Ue;try{Ue=w.useSyncExternalStore(bt,Te,H?()=>V(H(),ee):Te)}catch(ue){throw je.current&&(ue.message+=` The error may be correlated with this previous error: ${je.current.stack} `),ue}zd(()=>{je.current=void 0,ie.current=void 0,T.current=Ue});const It=w.useMemo(()=>w.createElement(j,{...Ue,ref:G}),[G,j,Ue]);return w.useMemo(()=>N?w.createElement(ne.Provider,{value:te},It):It,[ne,It,te])}const _=w.memo(A);if(_.WrappedComponent=j,_.displayName=A.displayName=C,h){const F=w.forwardRef(function(ee,ne){return w.createElement(_,{...ee,reactReduxForwardedRef:ne})});return F.displayName=C,F.WrappedComponent=j,Gp(F,j)}return Gp(_,j)}}var nE=FR;function qR(t){const{children:e,context:n,serverState:r,store:i}=t,c=w.useMemo(()=>{const h=JN(i);return{store:i,subscription:h,getServerState:r?()=>r:void 0}},[i,r]),d=w.useMemo(()=>i.getState(),[i]);zd(()=>{const{subscription:h}=c;return h.onStateChange=h.notifyNestedSubs,h.trySubscribe(),d!==i.getState()&&h.notifyNestedSubs(),()=>{h.tryUnsubscribe(),h.onStateChange=void 0}},[c,d]);const f=n||tE;return w.createElement(f.Provider,{value:c},e)}var $R=qR,YR="Invariant failed";function QR(t,e){throw new Error(YR)}var Jn=function(e){var n=e.top,r=e.right,i=e.bottom,c=e.left,d=r-c,f=i-n,h={top:n,right:r,bottom:i,left:c,width:d,height:f,x:c,y:n,center:{x:(r+c)/2,y:(i+n)/2}};return h},Ig=function(e,n){return{top:e.top-n.top,left:e.left-n.left,bottom:e.bottom+n.bottom,right:e.right+n.right}},yv=function(e,n){return{top:e.top+n.top,left:e.left+n.left,bottom:e.bottom-n.bottom,right:e.right-n.right}},WR=function(e,n){return{top:e.top+n.y,left:e.left+n.x,bottom:e.bottom+n.y,right:e.right+n.x}},cp={top:0,right:0,bottom:0,left:0},Lg=function(e){var n=e.borderBox,r=e.margin,i=r===void 0?cp:r,c=e.border,d=c===void 0?cp:c,f=e.padding,h=f===void 0?cp:f,p=Jn(Ig(n,i)),b=Jn(yv(n,d)),y=Jn(yv(b,h));return{marginBox:p,borderBox:Jn(n),paddingBox:b,contentBox:y,margin:i,border:d,padding:h}},Gn=function(e){var n=e.slice(0,-2),r=e.slice(-2);if(r!=="px")return 0;var i=Number(n);return isNaN(i)&&QR(),i},XR=function(){return{x:window.pageXOffset,y:window.pageYOffset}},Pd=function(e,n){var r=e.borderBox,i=e.border,c=e.margin,d=e.padding,f=WR(r,n);return Lg({borderBox:f,border:i,margin:c,padding:d})},Ud=function(e,n){return n===void 0&&(n=XR()),Pd(e,n)},aE=function(e,n){var r={top:Gn(n.marginTop),right:Gn(n.marginRight),bottom:Gn(n.marginBottom),left:Gn(n.marginLeft)},i={top:Gn(n.paddingTop),right:Gn(n.paddingRight),bottom:Gn(n.paddingBottom),left:Gn(n.paddingLeft)},c={top:Gn(n.borderTopWidth),right:Gn(n.borderRightWidth),bottom:Gn(n.borderBottomWidth),left:Gn(n.borderLeftWidth)};return Lg({borderBox:e,margin:r,padding:i,border:c})},sE=function(e){var n=e.getBoundingClientRect(),r=window.getComputedStyle(e);return aE(n,r)},ho=function(e){var n=[],r=null,i=function(){for(var d=arguments.length,f=new Array(d),h=0;h{const c=ZR(n,i.options);return t.addEventListener(i.eventName,i.fn,c),function(){t.removeEventListener(i.eventName,i.fn,c)}});return function(){r.forEach(c=>{c()})}}const KR="Invariant failed";class Hd extends Error{}Hd.prototype.toString=function(){return this.message};function fe(t,e){throw new Hd(KR)}let JR=class extends Ve.Component{constructor(...e){super(...e),this.callbacks=null,this.unbind=ks,this.onWindowError=n=>{const r=this.getCallbacks();r.isDragging()&&r.tryAbort(),n.error instanceof Hd&&n.preventDefault()},this.getCallbacks=()=>{if(!this.callbacks)throw new Error("Unable to find AppCallbacks in ");return this.callbacks},this.setCallbacks=n=>{this.callbacks=n}}componentDidMount(){this.unbind=Fn(window,[{eventName:"error",fn:this.onWindowError}])}componentDidCatch(e){if(e instanceof Hd){this.setState({});return}throw e}componentWillUnmount(){this.unbind()}render(){return this.props.children(this.setCallbacks)}};const eT=` Press space bar to start a drag. When dragging you can use the arrow keys to move the item around and escape to cancel. Some screen readers may require you to be in focus mode or to use your pass through key `,Gd=t=>t+1,tT=t=>` You have lifted an item in position ${Gd(t.source.index)} `,lE=(t,e)=>{const n=t.droppableId===e.droppableId,r=Gd(t.index),i=Gd(e.index);return n?` You have moved the item from position ${r} to position ${i} `:` You have moved the item from position ${r} in list ${t.droppableId} to list ${e.droppableId} in position ${i} `},iE=(t,e,n)=>e.droppableId===n.droppableId?` The item ${t} has been combined with ${n.draggableId}`:` The item ${t} in list ${e.droppableId} has been combined with ${n.draggableId} in list ${n.droppableId} `,nT=t=>{const e=t.destination;if(e)return lE(t.source,e);const n=t.combine;return n?iE(t.draggableId,t.source,n):"You are over an area that cannot be dropped on"},vv=t=>` The item has returned to its starting position of ${Gd(t.index)} `,aT=t=>{if(t.reason==="CANCEL")return` Movement cancelled. ${vv(t.source)} `;const e=t.destination,n=t.combine;return e?` You have dropped the item. ${lE(t.source,e)} `:n?` You have dropped the item. ${iE(t.draggableId,t.source,n)} `:` The item has been dropped while not over a drop area. ${vv(t.source)} `},wd={dragHandleUsageInstructions:eT,onDragStart:tT,onDragUpdate:nT,onDragEnd:aT};function sT(t,e){return!!(t===e||Number.isNaN(t)&&Number.isNaN(e))}function oE(t,e){if(t.length!==e.length)return!1;for(let n=0;n({inputs:e,result:t()}))[0],r=w.useRef(!0),i=w.useRef(n),d=r.current||!!(e&&i.current.inputs&&oE(e,i.current.inputs))?i.current:{inputs:e,result:t()};return w.useEffect(()=>{r.current=!1,i.current=d},[d]),d.result}function ye(t,e){return qe(()=>t,e)}const Mt={x:0,y:0},Gt=(t,e)=>({x:t.x+e.x,y:t.y+e.y}),Sn=(t,e)=>({x:t.x-e.x,y:t.y-e.y}),_s=(t,e)=>t.x===e.x&&t.y===e.y,Yl=t=>({x:t.x!==0?-t.x:0,y:t.y!==0?-t.y:0}),Cr=(t,e,n=0)=>t==="x"?{x:e,y:n}:{x:n,y:e},po=(t,e)=>Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2),Nv=(t,e)=>Math.min(...e.map(n=>po(t,n))),cE=t=>e=>({x:t(e.x),y:t(e.y)});var rT=(t,e)=>{const n=Jn({top:Math.max(e.top,t.top),right:Math.min(e.right,t.right),bottom:Math.min(e.bottom,t.bottom),left:Math.max(e.left,t.left)});return n.width<=0||n.height<=0?null:n};const Po=(t,e)=>({top:t.top+e.y,left:t.left+e.x,bottom:t.bottom+e.y,right:t.right+e.x}),Ev=t=>[{x:t.left,y:t.top},{x:t.right,y:t.top},{x:t.left,y:t.bottom},{x:t.right,y:t.bottom}],lT={top:0,right:0,bottom:0,left:0},iT=(t,e)=>e?Po(t,e.scroll.diff.displacement):t,oT=(t,e,n)=>n&&n.increasedBy?{...t,[e.end]:t[e.end]+n.increasedBy[e.line]}:t,cT=(t,e)=>e&&e.shouldClipSubject?rT(e.pageMarginBox,t):Jn(t);var zl=({page:t,withPlaceholder:e,axis:n,frame:r})=>{const i=iT(t.marginBox,r),c=oT(i,n,e),d=cT(c,r);return{page:t,withPlaceholder:e,active:d}},zg=(t,e)=>{t.frame||fe();const n=t.frame,r=Sn(e,n.scroll.initial),i=Yl(r),c={...n,scroll:{initial:n.scroll.initial,current:e,diff:{value:r,displacement:i},max:n.scroll.max}},d=zl({page:t.subject.page,withPlaceholder:t.subject.withPlaceholder,axis:t.axis,frame:c});return{...t,frame:c,subject:d}};function kt(t,e=oE){let n=null;function r(...i){if(n&&n.lastThis===this&&e(i,n.lastArgs))return n.lastResult;const c=t.apply(this,i);return n={lastResult:c,lastArgs:i,lastThis:this},c}return r.clear=function(){n=null},r}const dE=kt(t=>t.reduce((e,n)=>(e[n.descriptor.id]=n,e),{})),uE=kt(t=>t.reduce((e,n)=>(e[n.descriptor.id]=n,e),{})),bu=kt(t=>Object.values(t)),dT=kt(t=>Object.values(t));var Ql=kt((t,e)=>dT(e).filter(r=>t===r.descriptor.droppableId).sort((r,i)=>r.descriptor.index-i.descriptor.index));function Pg(t){return t.at&&t.at.type==="REORDER"?t.at.destination:null}function yu(t){return t.at&&t.at.type==="COMBINE"?t.at.combine:null}var vu=kt((t,e)=>e.filter(n=>n.descriptor.id!==t.descriptor.id)),uT=({isMovingForward:t,draggable:e,destination:n,insideDestination:r,previousImpact:i})=>{if(!n.isCombineEnabled||!Pg(i))return null;function d(v){const N={type:"COMBINE",combine:{draggableId:v,droppableId:n.descriptor.id}};return{...i,at:N}}const f=i.displaced.all,h=f.length?f[0]:null;if(t)return h?d(h):null;const p=vu(e,r);if(!h){if(!p.length)return null;const v=p[p.length-1];return d(v.descriptor.id)}const b=p.findIndex(v=>v.descriptor.id===h);b===-1&&fe();const y=b-1;if(y<0)return null;const m=p[y];return d(m.descriptor.id)},Wl=(t,e)=>t.descriptor.droppableId===e.descriptor.id;const fE={point:Mt,value:0},go={invisible:{},visible:{},all:[]},fT={displaced:go,displacedBy:fE,at:null};var qn=(t,e)=>n=>t<=n&&n<=e,hE=t=>{const e=qn(t.top,t.bottom),n=qn(t.left,t.right);return r=>{if(e(r.top)&&e(r.bottom)&&n(r.left)&&n(r.right))return!0;const c=e(r.top)||e(r.bottom),d=n(r.left)||n(r.right);if(c&&d)return!0;const h=r.topt.bottom,p=r.leftt.right;return h&&p?!0:h&&d||p&&c}},hT=t=>{const e=qn(t.top,t.bottom),n=qn(t.left,t.right);return r=>e(r.top)&&e(r.bottom)&&n(r.left)&&n(r.right)};const Ug={direction:"vertical",line:"y",crossAxisLine:"x",start:"top",end:"bottom",size:"height",crossAxisStart:"left",crossAxisEnd:"right",crossAxisSize:"width"},pE={direction:"horizontal",line:"x",crossAxisLine:"y",start:"left",end:"right",size:"width",crossAxisStart:"top",crossAxisEnd:"bottom",crossAxisSize:"height"};var pT=t=>e=>{const n=qn(e.top,e.bottom),r=qn(e.left,e.right);return i=>t===Ug?n(i.top)&&n(i.bottom):r(i.left)&&r(i.right)};const gT=(t,e)=>{const n=e.frame?e.frame.scroll.diff.displacement:Mt;return Po(t,n)},mT=(t,e,n)=>e.subject.active?n(e.subject.active)(t):!1,xT=(t,e,n)=>n(e)(t),Bg=({target:t,destination:e,viewport:n,withDroppableDisplacement:r,isVisibleThroughFrameFn:i})=>{const c=r?gT(t,e):t;return mT(c,e,i)&&xT(c,n,i)},bT=t=>Bg({...t,isVisibleThroughFrameFn:hE}),gE=t=>Bg({...t,isVisibleThroughFrameFn:hT}),yT=t=>Bg({...t,isVisibleThroughFrameFn:pT(t.destination.axis)}),vT=(t,e,n)=>{if(typeof n=="boolean")return n;if(!e)return!0;const{invisible:r,visible:i}=e;if(r[t])return!1;const c=i[t];return c?c.shouldAnimate:!0};function NT(t,e){const n=t.page.marginBox,r={top:e.point.y,right:0,bottom:0,left:e.point.x};return Jn(Ig(n,r))}function mo({afterDragging:t,destination:e,displacedBy:n,viewport:r,forceShouldAnimate:i,last:c}){return t.reduce(function(f,h){const p=NT(h,n),b=h.descriptor.id;if(f.all.push(b),!bT({target:p,destination:e,viewport:r,withDroppableDisplacement:!0}))return f.invisible[h.descriptor.id]=!0,f;const m=vT(b,c,i),v={draggableId:b,shouldAnimate:m};return f.visible[b]=v,f},{all:[],visible:{},invisible:{}})}function ET(t,e){if(!t.length)return 0;const n=t[t.length-1].descriptor.index;return e.inHomeList?n:n+1}function Sv({insideDestination:t,inHomeList:e,displacedBy:n,destination:r}){const i=ET(t,{inHomeList:e});return{displaced:go,displacedBy:n,at:{type:"REORDER",destination:{droppableId:r.descriptor.id,index:i}}}}function Vd({draggable:t,insideDestination:e,destination:n,viewport:r,displacedBy:i,last:c,index:d,forceShouldAnimate:f}){const h=Wl(t,n);if(d==null)return Sv({insideDestination:e,inHomeList:h,displacedBy:i,destination:n});const p=e.find(N=>N.descriptor.index===d);if(!p)return Sv({insideDestination:e,inHomeList:h,displacedBy:i,destination:n});const b=vu(t,e),y=e.indexOf(p),m=b.slice(y);return{displaced:mo({afterDragging:m,destination:n,displacedBy:i,last:c,viewport:r.frame,forceShouldAnimate:f}),displacedBy:i,at:{type:"REORDER",destination:{droppableId:n.descriptor.id,index:d}}}}function zs(t,e){return!!e.effected[t]}var ST=({isMovingForward:t,destination:e,draggables:n,combine:r,afterCritical:i})=>{if(!e.isCombineEnabled)return null;const c=r.draggableId,f=n[c].descriptor.index;return zs(c,i)?t?f:f-1:t?f+1:f},jT=({isMovingForward:t,isInHomeList:e,insideDestination:n,location:r})=>{if(!n.length)return null;const i=r.index,c=t?i+1:i-1,d=n[0].descriptor.index,f=n[n.length-1].descriptor.index,h=e?f:f+1;return ch?null:c},AT=({isMovingForward:t,isInHomeList:e,draggable:n,draggables:r,destination:i,insideDestination:c,previousImpact:d,viewport:f,afterCritical:h})=>{const p=d.at;if(p||fe(),p.type==="REORDER"){const y=jT({isMovingForward:t,isInHomeList:e,location:p.destination,insideDestination:c});return y==null?null:Vd({draggable:n,insideDestination:c,destination:i,viewport:f,last:d.displaced,displacedBy:d.displacedBy,index:y})}const b=ST({isMovingForward:t,destination:i,displaced:d.displaced,draggables:r,combine:p.combine,afterCritical:h});return b==null?null:Vd({draggable:n,insideDestination:c,destination:i,viewport:f,last:d.displaced,displacedBy:d.displacedBy,index:b})},wT=({displaced:t,afterCritical:e,combineWith:n,displacedBy:r})=>{const i=!!(t.visible[n]||t.invisible[n]);return zs(n,e)?i?Mt:Yl(r.point):i?r.point:Mt},CT=({afterCritical:t,impact:e,draggables:n})=>{const r=yu(e);r||fe();const i=r.draggableId,c=n[i].page.borderBox.center,d=wT({displaced:e.displaced,afterCritical:t,combineWith:i,displacedBy:e.displacedBy});return Gt(c,d)};const mE=(t,e)=>e.margin[t.start]+e.borderBox[t.size]/2,DT=(t,e)=>e.margin[t.end]+e.borderBox[t.size]/2,Hg=(t,e,n)=>e[t.crossAxisStart]+n.margin[t.crossAxisStart]+n.borderBox[t.crossAxisSize]/2,jv=({axis:t,moveRelativeTo:e,isMoving:n})=>Cr(t.line,e.marginBox[t.end]+mE(t,n),Hg(t,e.marginBox,n)),Av=({axis:t,moveRelativeTo:e,isMoving:n})=>Cr(t.line,e.marginBox[t.start]-DT(t,n),Hg(t,e.marginBox,n)),OT=({axis:t,moveInto:e,isMoving:n})=>Cr(t.line,e.contentBox[t.start]+mE(t,n),Hg(t,e.contentBox,n));var RT=({impact:t,draggable:e,draggables:n,droppable:r,afterCritical:i})=>{const c=Ql(r.descriptor.id,n),d=e.page,f=r.axis;if(!c.length)return OT({axis:f,moveInto:r.page,isMoving:d});const{displaced:h,displacedBy:p}=t,b=h.all[0];if(b){const m=n[b];if(zs(b,i))return Av({axis:f,moveRelativeTo:m.page,isMoving:d});const v=Pd(m.page,p.point);return Av({axis:f,moveRelativeTo:v,isMoving:d})}const y=c[c.length-1];if(y.descriptor.id===e.descriptor.id)return d.borderBox.center;if(zs(y.descriptor.id,i)){const m=Pd(y.page,Yl(i.displacedBy.point));return jv({axis:f,moveRelativeTo:m,isMoving:d})}return jv({axis:f,moveRelativeTo:y.page,isMoving:d})},Vp=(t,e)=>{const n=t.frame;return n?Gt(e,n.scroll.diff.displacement):e};const TT=({impact:t,draggable:e,droppable:n,draggables:r,afterCritical:i})=>{const c=e.page.borderBox.center,d=t.at;return!n||!d?c:d.type==="REORDER"?RT({impact:t,draggable:e,draggables:r,droppable:n,afterCritical:i}):CT({impact:t,draggables:r,afterCritical:i})};var Nu=t=>{const e=TT(t),n=t.droppable;return n?Vp(n,e):e},xE=(t,e)=>{const n=Sn(e,t.scroll.initial),r=Yl(n);return{frame:Jn({top:e.y,bottom:e.y+t.frame.height,left:e.x,right:e.x+t.frame.width}),scroll:{initial:t.scroll.initial,max:t.scroll.max,current:e,diff:{value:n,displacement:r}}}};function wv(t,e){return t.map(n=>e[n])}function kT(t,e){for(let n=0;n{const c=xE(e,Gt(e.scroll.current,i)),d=n.frame?zg(n,Gt(n.frame.scroll.current,i)):n,f=t.displaced,h=mo({afterDragging:wv(f.all,r),destination:n,displacedBy:t.displacedBy,viewport:c.frame,last:f,forceShouldAnimate:!1}),p=mo({afterDragging:wv(f.all,r),destination:d,displacedBy:t.displacedBy,viewport:e.frame,last:f,forceShouldAnimate:!1}),b={},y={},m=[f,h,p];return f.all.forEach(N=>{const S=kT(N,m);if(S){y[N]=S;return}b[N]=!0}),{...t,displaced:{all:f.all,invisible:b,visible:y}}},MT=(t,e)=>Gt(t.scroll.diff.displacement,e),Gg=({pageBorderBoxCenter:t,draggable:e,viewport:n})=>{const r=MT(n,t),i=Sn(r,e.page.borderBox.center);return Gt(e.client.borderBox.center,i)},bE=({draggable:t,destination:e,newPageBorderBoxCenter:n,viewport:r,withDroppableDisplacement:i,onlyOnMainAxis:c=!1})=>{const d=Sn(n,t.page.borderBox.center),h={target:Po(t.page.borderBox,d),destination:e,withDroppableDisplacement:i,viewport:r};return c?yT(h):gE(h)},IT=({isMovingForward:t,draggable:e,destination:n,draggables:r,previousImpact:i,viewport:c,previousPageBorderBoxCenter:d,previousClientSelection:f,afterCritical:h})=>{if(!n.isEnabled)return null;const p=Ql(n.descriptor.id,r),b=Wl(e,n),y=uT({isMovingForward:t,draggable:e,destination:n,insideDestination:p,previousImpact:i})||AT({isMovingForward:t,isInHomeList:b,draggable:e,draggables:r,destination:n,insideDestination:p,previousImpact:i,viewport:c,afterCritical:h});if(!y)return null;const m=Nu({impact:y,draggable:e,droppable:n,draggables:r,afterCritical:h});if(bE({draggable:e,destination:n,newPageBorderBoxCenter:m,viewport:c.frame,withDroppableDisplacement:!1,onlyOnMainAxis:!0}))return{clientSelection:Gg({pageBorderBoxCenter:m,draggable:e,viewport:c}),impact:y,scrollJumpRequest:null};const N=Sn(m,d),S=_T({impact:y,viewport:c,destination:n,draggables:r,maxScrollChange:N});return{clientSelection:f,impact:S,scrollJumpRequest:N}};const Qt=t=>{const e=t.subject.active;return e||fe(),e};var LT=({isMovingForward:t,pageBorderBoxCenter:e,source:n,droppables:r,viewport:i})=>{const c=n.subject.active;if(!c)return null;const d=n.axis,f=qn(c[d.start],c[d.end]),h=bu(r).filter(b=>b!==n).filter(b=>b.isEnabled).filter(b=>!!b.subject.active).filter(b=>hE(i.frame)(Qt(b))).filter(b=>{const y=Qt(b);return t?c[d.crossAxisEnd]{const y=Qt(b),m=qn(y[d.start],y[d.end]);return f(y[d.start])||f(y[d.end])||m(c[d.start])||m(c[d.end])}).sort((b,y)=>{const m=Qt(b)[d.crossAxisStart],v=Qt(y)[d.crossAxisStart];return t?m-v:v-m}).filter((b,y,m)=>Qt(b)[d.crossAxisStart]===Qt(m[0])[d.crossAxisStart]);if(!h.length)return null;if(h.length===1)return h[0];const p=h.filter(b=>qn(Qt(b)[d.start],Qt(b)[d.end])(e[d.line]));return p.length===1?p[0]:p.length>1?p.sort((b,y)=>Qt(b)[d.start]-Qt(y)[d.start])[0]:h.sort((b,y)=>{const m=Nv(e,Ev(Qt(b))),v=Nv(e,Ev(Qt(y)));return m!==v?m-v:Qt(b)[d.start]-Qt(y)[d.start]})[0]};const Cv=(t,e)=>{const n=t.page.borderBox.center;return zs(t.descriptor.id,e)?Sn(n,e.displacedBy.point):n},zT=(t,e)=>{const n=t.page.borderBox;return zs(t.descriptor.id,e)?Po(n,Yl(e.displacedBy.point)):n};var PT=({pageBorderBoxCenter:t,viewport:e,destination:n,insideDestination:r,afterCritical:i})=>r.filter(d=>gE({target:zT(d,i),destination:n,viewport:e.frame,withDroppableDisplacement:!0})).sort((d,f)=>{const h=po(t,Vp(n,Cv(d,i))),p=po(t,Vp(n,Cv(f,i)));return h{const r=t.axis;if(t.descriptor.mode==="virtual")return Cr(r.line,e[r.line]);const i=t.subject.page.contentBox[r.size],h=Ql(t.descriptor.id,n).reduce((p,b)=>p+b.client.marginBox[r.size],0)+e[r.line]-i;return h<=0?null:Cr(r.line,h)},yE=(t,e)=>({...t,scroll:{...t.scroll,max:e}}),vE=(t,e,n)=>{const r=t.frame;Wl(e,t)&&fe(),t.subject.withPlaceholder&&fe();const i=Uo(t.axis,e.displaceBy).point,c=UT(t,i,n),d={placeholderSize:i,increasedBy:c,oldFrameMaxScroll:t.frame?t.frame.scroll.max:null};if(!r){const b=zl({page:t.subject.page,withPlaceholder:d,axis:t.axis,frame:t.frame});return{...t,subject:b}}const f=c?Gt(r.scroll.max,c):r.scroll.max,h=yE(r,f),p=zl({page:t.subject.page,withPlaceholder:d,axis:t.axis,frame:h});return{...t,subject:p,frame:h}},BT=t=>{const e=t.subject.withPlaceholder;e||fe();const n=t.frame;if(!n){const d=zl({page:t.subject.page,axis:t.axis,frame:null,withPlaceholder:null});return{...t,subject:d}}const r=e.oldFrameMaxScroll;r||fe();const i=yE(n,r),c=zl({page:t.subject.page,axis:t.axis,frame:i,withPlaceholder:null});return{...t,subject:c,frame:i}};var HT=({previousPageBorderBoxCenter:t,moveRelativeTo:e,insideDestination:n,draggable:r,draggables:i,destination:c,viewport:d,afterCritical:f})=>{if(!e){if(n.length)return null;const y={displaced:go,displacedBy:fE,at:{type:"REORDER",destination:{droppableId:c.descriptor.id,index:0}}},m=Nu({impact:y,draggable:r,droppable:c,draggables:i,afterCritical:f}),v=Wl(r,c)?c:vE(c,r,i);return bE({draggable:r,destination:v,newPageBorderBoxCenter:m,viewport:d.frame,withDroppableDisplacement:!1,onlyOnMainAxis:!0})?y:null}const h=t[c.axis.line]<=e.page.borderBox.center[c.axis.line],p=(()=>{const y=e.descriptor.index;return e.descriptor.id===r.descriptor.id||h?y:y+1})(),b=Uo(c.axis,r.displaceBy);return Vd({draggable:r,insideDestination:n,destination:c,viewport:d,displacedBy:b,last:go,index:p})},GT=({isMovingForward:t,previousPageBorderBoxCenter:e,draggable:n,isOver:r,draggables:i,droppables:c,viewport:d,afterCritical:f})=>{const h=LT({isMovingForward:t,pageBorderBoxCenter:e,source:r,droppables:c,viewport:d});if(!h)return null;const p=Ql(h.descriptor.id,i),b=PT({pageBorderBoxCenter:e,viewport:d,destination:h,insideDestination:p,afterCritical:f}),y=HT({previousPageBorderBoxCenter:e,destination:h,draggable:n,draggables:i,moveRelativeTo:b,insideDestination:p,viewport:d,afterCritical:f});if(!y)return null;const m=Nu({impact:y,draggable:n,droppable:h,draggables:i,afterCritical:f});return{clientSelection:Gg({pageBorderBoxCenter:m,draggable:n,viewport:d}),impact:y,scrollJumpRequest:null}},jn=t=>{const e=t.at;return e?e.type==="REORDER"?e.destination.droppableId:e.combine.droppableId:null};const VT=(t,e)=>{const n=jn(t);return n?e[n]:null};var FT=({state:t,type:e})=>{const n=VT(t.impact,t.dimensions.droppables),r=!!n,i=t.dimensions.droppables[t.critical.droppable.id],c=n||i,d=c.axis.direction,f=d==="vertical"&&(e==="MOVE_UP"||e==="MOVE_DOWN")||d==="horizontal"&&(e==="MOVE_LEFT"||e==="MOVE_RIGHT");if(f&&!r)return null;const h=e==="MOVE_DOWN"||e==="MOVE_RIGHT",p=t.dimensions.draggables[t.critical.draggable.id],b=t.current.page.borderBoxCenter,{draggables:y,droppables:m}=t.dimensions;return f?IT({isMovingForward:h,previousPageBorderBoxCenter:b,draggable:p,destination:c,draggables:y,viewport:t.viewport,previousClientSelection:t.current.client.selection,previousImpact:t.impact,afterCritical:t.afterCritical}):GT({isMovingForward:h,previousPageBorderBoxCenter:b,draggable:p,isOver:c,draggables:y,droppables:m,viewport:t.viewport,afterCritical:t.afterCritical})};function ir(t){return t.phase==="DRAGGING"||t.phase==="COLLECTING"}function NE(t){const e=qn(t.top,t.bottom),n=qn(t.left,t.right);return function(i){return e(i.y)&&n(i.x)}}function qT(t,e){return t.lefte.left&&t.tope.top}function $T({pageBorderBox:t,draggable:e,candidates:n}){const r=e.page.borderBox.center,i=n.map(c=>{const d=c.axis,f=Cr(c.axis.line,t.center[d.line],c.page.borderBox.center[d.crossAxisLine]);return{id:c.descriptor.id,distance:po(r,f)}}).sort((c,d)=>d.distance-c.distance);return i[0]?i[0].id:null}function YT({pageBorderBox:t,draggable:e,droppables:n}){const r=bu(n).filter(i=>{if(!i.isEnabled)return!1;const c=i.subject.active;if(!c||!qT(t,c))return!1;if(NE(c)(t.center))return!0;const d=i.axis,f=c.center[d.crossAxisLine],h=t[d.crossAxisStart],p=t[d.crossAxisEnd],b=qn(c[d.crossAxisStart],c[d.crossAxisEnd]),y=b(h),m=b(p);return!y&&!m?!0:y?hf});return r.length?r.length===1?r[0].descriptor.id:$T({pageBorderBox:t,draggable:e,candidates:r}):null}const EE=(t,e)=>Jn(Po(t,e));var QT=(t,e)=>{const n=t.frame;return n?EE(e,n.scroll.diff.value):e};function SE({displaced:t,id:e}){return!!(t.visible[e]||t.invisible[e])}function WT({draggable:t,closest:e,inHomeList:n}){return e?n&&e.descriptor.index>t.descriptor.index?e.descriptor.index-1:e.descriptor.index:null}var XT=({pageBorderBoxWithDroppableScroll:t,draggable:e,destination:n,insideDestination:r,last:i,viewport:c,afterCritical:d})=>{const f=n.axis,h=Uo(n.axis,e.displaceBy),p=h.value,b=t[f.start],y=t[f.end],v=vu(e,r).find(S=>{const j=S.descriptor.id,R=S.page.borderBox.center[f.line],C=zs(j,d),O=SE({displaced:i,id:j});return C?O?y<=R:b{if(!r.isCombineEnabled)return null;const d=r.axis,f=Uo(r.axis,t.displaceBy),h=f.value,p=e[d.start],b=e[d.end],m=vu(t,i).find(N=>{const S=N.descriptor.id,j=N.page.borderBox,C=j[d.size]/ZT,O=zs(S,c),A=SE({displaced:n.displaced,id:S});return O?A?b>j[d.start]+C&&bj[d.start]-h+C&&pj[d.start]+h+C&&bj[d.start]+C&&p{const f=EE(e.page.borderBox,t),h=YT({pageBorderBox:f,draggable:e,droppables:r});if(!h)return fT;const p=r[h],b=Ql(p.descriptor.id,n),y=QT(p,f);return KT({pageBorderBoxWithDroppableScroll:y,draggable:e,previousImpact:i,destination:p,insideDestination:b,afterCritical:d})||XT({pageBorderBoxWithDroppableScroll:y,draggable:e,destination:p,insideDestination:b,last:i.displaced,viewport:c,afterCritical:d})},Vg=(t,e)=>({...t,[e.descriptor.id]:e});const JT=({previousImpact:t,impact:e,droppables:n})=>{const r=jn(t),i=jn(e);if(!r||r===i)return n;const c=n[r];if(!c.subject.withPlaceholder)return n;const d=BT(c);return Vg(n,d)};var ek=({draggable:t,draggables:e,droppables:n,previousImpact:r,impact:i})=>{const c=JT({previousImpact:r,impact:i,droppables:n}),d=jn(i);if(!d)return c;const f=n[d];if(Wl(t,f)||f.subject.withPlaceholder)return c;const h=vE(f,t,e);return Vg(c,h)},ro=({state:t,clientSelection:e,dimensions:n,viewport:r,impact:i,scrollJumpRequest:c})=>{const d=r||t.viewport,f=n||t.dimensions,h=e||t.current.client.selection,p=Sn(h,t.initial.client.selection),b={offset:p,selection:h,borderBoxCenter:Gt(t.initial.client.borderBoxCenter,p)},y={selection:Gt(b.selection,d.scroll.current),borderBoxCenter:Gt(b.borderBoxCenter,d.scroll.current),offset:Gt(b.offset,d.scroll.diff.value)},m={client:b,page:y};if(t.phase==="COLLECTING")return{...t,dimensions:f,viewport:d,current:m};const v=f.draggables[t.critical.draggable.id],N=i||jE({pageOffset:y.offset,draggable:v,draggables:f.draggables,droppables:f.droppables,previousImpact:t.impact,viewport:d,afterCritical:t.afterCritical}),S=ek({draggable:v,impact:N,previousImpact:t.impact,draggables:f.draggables,droppables:f.droppables});return{...t,current:m,dimensions:{draggables:f.draggables,droppables:S},impact:N,viewport:d,scrollJumpRequest:c||null,forceShouldAnimate:c?!1:null}};function tk(t,e){return t.map(n=>e[n])}var AE=({impact:t,viewport:e,draggables:n,destination:r,forceShouldAnimate:i})=>{const c=t.displaced,d=tk(c.all,n),f=mo({afterDragging:d,destination:r,displacedBy:t.displacedBy,viewport:e.frame,forceShouldAnimate:i,last:c});return{...t,displaced:f}},wE=({impact:t,draggable:e,droppable:n,draggables:r,viewport:i,afterCritical:c})=>{const d=Nu({impact:t,draggable:e,draggables:r,droppable:n,afterCritical:c});return Gg({pageBorderBoxCenter:d,draggable:e,viewport:i})},CE=({state:t,dimensions:e,viewport:n})=>{t.movementMode!=="SNAP"&&fe();const r=t.impact,i=n||t.viewport,c=e||t.dimensions,{draggables:d,droppables:f}=c,h=d[t.critical.draggable.id],p=jn(r);p||fe();const b=f[p],y=AE({impact:r,viewport:i,destination:b,draggables:d}),m=wE({impact:y,draggable:h,droppable:b,draggables:d,viewport:i,afterCritical:t.afterCritical});return ro({impact:y,clientSelection:m,state:t,dimensions:c,viewport:i})},nk=t=>({index:t.index,droppableId:t.droppableId}),DE=({draggable:t,home:e,draggables:n,viewport:r})=>{const i=Uo(e.axis,t.displaceBy),c=Ql(e.descriptor.id,n),d=c.indexOf(t);d===-1&&fe();const f=c.slice(d+1),h=f.reduce((m,v)=>(m[v.descriptor.id]=!0,m),{}),p={inVirtualList:e.descriptor.mode==="virtual",displacedBy:i,effected:h};return{impact:{displaced:mo({afterDragging:f,destination:e,displacedBy:i,last:null,viewport:r.frame,forceShouldAnimate:!1}),displacedBy:i,at:{type:"REORDER",destination:nk(t.descriptor)}},afterCritical:p}},ak=(t,e)=>({draggables:t.draggables,droppables:Vg(t.droppables,e)}),sk=({draggable:t,offset:e,initialWindowScroll:n})=>{const r=Pd(t.client,e),i=Ud(r,n);return{...t,placeholder:{...t.placeholder,client:r},client:r,page:i}},rk=t=>{const e=t.frame;return e||fe(),e},lk=({additions:t,updatedDroppables:e,viewport:n})=>{const r=n.scroll.diff.value;return t.map(i=>{const c=i.descriptor.droppableId,d=e[c],h=rk(d).scroll.diff.value,p=Gt(r,h);return sk({draggable:i,offset:p,initialWindowScroll:n.scroll.initial})})},ik=({state:t,published:e})=>{const n=e.modified.map(R=>{const C=t.dimensions.droppables[R.droppableId];return zg(C,R.scroll)}),r={...t.dimensions.droppables,...dE(n)},i=uE(lk({additions:e.additions,updatedDroppables:r,viewport:t.viewport})),c={...t.dimensions.draggables,...i};e.removals.forEach(R=>{delete c[R]});const d={droppables:r,draggables:c},f=jn(t.impact),h=f?d.droppables[f]:null,p=d.draggables[t.critical.draggable.id],b=d.droppables[t.critical.droppable.id],{impact:y,afterCritical:m}=DE({draggable:p,home:b,draggables:c,viewport:t.viewport}),v=h&&h.isCombineEnabled?t.impact:y,N=jE({pageOffset:t.current.page.offset,draggable:d.draggables[t.critical.draggable.id],draggables:d.draggables,droppables:d.droppables,previousImpact:v,viewport:t.viewport,afterCritical:m}),S={...t,phase:"DRAGGING",impact:N,onLiftImpact:y,dimensions:d,afterCritical:m,forceShouldAnimate:!1};return t.phase==="COLLECTING"?S:{...S,phase:"DROP_PENDING",reason:t.reason,isWaiting:!1}};const Fp=t=>t.movementMode==="SNAP",dp=(t,e,n)=>{const r=ak(t.dimensions,e);return!Fp(t)||n?ro({state:t,dimensions:r}):CE({state:t,dimensions:r})};function up(t){return t.isDragging&&t.movementMode==="SNAP"?{...t,scrollJumpRequest:null}:t}const Dv={phase:"IDLE",completed:null,shouldFlush:!1};var ok=(t=Dv,e)=>{if(e.type==="FLUSH")return{...Dv,shouldFlush:!0};if(e.type==="INITIAL_PUBLISH"){t.phase!=="IDLE"&&fe();const{critical:n,clientSelection:r,viewport:i,dimensions:c,movementMode:d}=e.payload,f=c.draggables[n.draggable.id],h=c.droppables[n.droppable.id],p={selection:r,borderBoxCenter:f.client.borderBox.center,offset:Mt},b={client:p,page:{selection:Gt(p.selection,i.scroll.initial),borderBoxCenter:Gt(p.selection,i.scroll.initial),offset:Gt(p.selection,i.scroll.diff.value)}},y=bu(c.droppables).every(S=>!S.isFixedOnPage),{impact:m,afterCritical:v}=DE({draggable:f,home:h,draggables:c.draggables,viewport:i});return{phase:"DRAGGING",isDragging:!0,critical:n,movementMode:d,dimensions:c,initial:b,current:b,isWindowScrollAllowed:y,impact:m,afterCritical:v,onLiftImpact:m,viewport:i,scrollJumpRequest:null,forceShouldAnimate:null}}if(e.type==="COLLECTION_STARTING")return t.phase==="COLLECTING"||t.phase==="DROP_PENDING"?t:(t.phase!=="DRAGGING"&&fe(),{...t,phase:"COLLECTING"});if(e.type==="PUBLISH_WHILE_DRAGGING")return t.phase==="COLLECTING"||t.phase==="DROP_PENDING"||fe(),ik({state:t,published:e.payload});if(e.type==="MOVE"){if(t.phase==="DROP_PENDING")return t;ir(t)||fe();const{client:n}=e.payload;return _s(n,t.current.client.selection)?t:ro({state:t,clientSelection:n,impact:Fp(t)?t.impact:null})}if(e.type==="UPDATE_DROPPABLE_SCROLL"){if(t.phase==="DROP_PENDING"||t.phase==="COLLECTING")return up(t);ir(t)||fe();const{id:n,newScroll:r}=e.payload,i=t.dimensions.droppables[n];if(!i)return t;const c=zg(i,r);return dp(t,c,!1)}if(e.type==="UPDATE_DROPPABLE_IS_ENABLED"){if(t.phase==="DROP_PENDING")return t;ir(t)||fe();const{id:n,isEnabled:r}=e.payload,i=t.dimensions.droppables[n];i||fe(),i.isEnabled===r&&fe();const c={...i,isEnabled:r};return dp(t,c,!0)}if(e.type==="UPDATE_DROPPABLE_IS_COMBINE_ENABLED"){if(t.phase==="DROP_PENDING")return t;ir(t)||fe();const{id:n,isCombineEnabled:r}=e.payload,i=t.dimensions.droppables[n];i||fe(),i.isCombineEnabled===r&&fe();const c={...i,isCombineEnabled:r};return dp(t,c,!0)}if(e.type==="MOVE_BY_WINDOW_SCROLL"){if(t.phase==="DROP_PENDING"||t.phase==="DROP_ANIMATING")return t;ir(t)||fe(),t.isWindowScrollAllowed||fe();const n=e.payload.newScroll;if(_s(t.viewport.scroll.current,n))return up(t);const r=xE(t.viewport,n);return Fp(t)?CE({state:t,viewport:r}):ro({state:t,viewport:r})}if(e.type==="UPDATE_VIEWPORT_MAX_SCROLL"){if(!ir(t))return t;const n=e.payload.maxScroll;if(_s(n,t.viewport.scroll.max))return t;const r={...t.viewport,scroll:{...t.viewport.scroll,max:n}};return{...t,viewport:r}}if(e.type==="MOVE_UP"||e.type==="MOVE_DOWN"||e.type==="MOVE_LEFT"||e.type==="MOVE_RIGHT"){if(t.phase==="COLLECTING"||t.phase==="DROP_PENDING")return t;t.phase!=="DRAGGING"&&fe();const n=FT({state:t,type:e.type});return n?ro({state:t,impact:n.impact,clientSelection:n.clientSelection,scrollJumpRequest:n.scrollJumpRequest}):t}if(e.type==="DROP_PENDING"){const n=e.payload.reason;return t.phase!=="COLLECTING"&&fe(),{...t,phase:"DROP_PENDING",isWaiting:!0,reason:n}}if(e.type==="DROP_ANIMATE"){const{completed:n,dropDuration:r,newHomeClientOffset:i}=e.payload;return t.phase==="DRAGGING"||t.phase==="DROP_PENDING"||fe(),{phase:"DROP_ANIMATING",completed:n,dropDuration:r,newHomeClientOffset:i,dimensions:t.dimensions}}if(e.type==="DROP_COMPLETE"){const{completed:n}=e.payload;return{phase:"IDLE",completed:n,shouldFlush:!1}}return t};function Xe(t,e){return t instanceof Object&&"type"in t&&t.type===e}const ck=t=>({type:"BEFORE_INITIAL_CAPTURE",payload:t}),dk=t=>({type:"LIFT",payload:t}),uk=t=>({type:"INITIAL_PUBLISH",payload:t}),fk=t=>({type:"PUBLISH_WHILE_DRAGGING",payload:t}),hk=()=>({type:"COLLECTION_STARTING",payload:null}),pk=t=>({type:"UPDATE_DROPPABLE_SCROLL",payload:t}),gk=t=>({type:"UPDATE_DROPPABLE_IS_ENABLED",payload:t}),mk=t=>({type:"UPDATE_DROPPABLE_IS_COMBINE_ENABLED",payload:t}),OE=t=>({type:"MOVE",payload:t}),xk=t=>({type:"MOVE_BY_WINDOW_SCROLL",payload:t}),bk=t=>({type:"UPDATE_VIEWPORT_MAX_SCROLL",payload:t}),yk=()=>({type:"MOVE_UP",payload:null}),vk=()=>({type:"MOVE_DOWN",payload:null}),Nk=()=>({type:"MOVE_RIGHT",payload:null}),Ek=()=>({type:"MOVE_LEFT",payload:null}),Fg=()=>({type:"FLUSH",payload:null}),Sk=t=>({type:"DROP_ANIMATE",payload:t}),qg=t=>({type:"DROP_COMPLETE",payload:t}),RE=t=>({type:"DROP",payload:t}),jk=t=>({type:"DROP_PENDING",payload:t}),TE=()=>({type:"DROP_ANIMATION_FINISHED",payload:null});var Ak=t=>({getState:e,dispatch:n})=>r=>i=>{if(!Xe(i,"LIFT")){r(i);return}const{id:c,clientSelection:d,movementMode:f}=i.payload,h=e();h.phase==="DROP_ANIMATING"&&n(qg({completed:h.completed})),e().phase!=="IDLE"&&fe(),n(Fg()),n(ck({draggableId:c,movementMode:f}));const b={draggableId:c,scrollOptions:{shouldPublishImmediately:f==="SNAP"}},{critical:y,dimensions:m,viewport:v}=t.startPublishing(b);n(uk({critical:y,dimensions:m,clientSelection:d,movementMode:f,viewport:v}))},wk=t=>()=>e=>n=>{Xe(n,"INITIAL_PUBLISH")&&t.dragging(),Xe(n,"DROP_ANIMATE")&&t.dropping(n.payload.completed.result.reason),(Xe(n,"FLUSH")||Xe(n,"DROP_COMPLETE"))&&t.resting(),e(n)};const $g={outOfTheWay:"cubic-bezier(0.2, 0, 0, 1)",drop:"cubic-bezier(.2,1,.1,1)"},xo={opacity:{drop:0,combining:.7},scale:{drop:.75}},kE={outOfTheWay:.2,minDropTime:.33,maxDropTime:.55},lr=`${kE.outOfTheWay}s ${$g.outOfTheWay}`,lo={fluid:`opacity ${lr}`,snap:`transform ${lr}, opacity ${lr}`,drop:t=>{const e=`${t}s ${$g.drop}`;return`transform ${e}, opacity ${e}`},outOfTheWay:`transform ${lr}`,placeholder:`height ${lr}, width ${lr}, margin ${lr}`},Ov=t=>_s(t,Mt)?void 0:`translate(${t.x}px, ${t.y}px)`,qp={moveTo:Ov,drop:(t,e)=>{const n=Ov(t);if(n)return e?`${n} scale(${xo.scale.drop})`:n}},{minDropTime:$p,maxDropTime:_E}=kE,Ck=_E-$p,Rv=1500,Dk=.6;var Ok=({current:t,destination:e,reason:n})=>{const r=po(t,e);if(r<=0)return $p;if(r>=Rv)return _E;const i=r/Rv,c=$p+Ck*i,d=n==="CANCEL"?c*Dk:c;return Number(d.toFixed(2))},Rk=({impact:t,draggable:e,dimensions:n,viewport:r,afterCritical:i})=>{const{draggables:c,droppables:d}=n,f=jn(t),h=f?d[f]:null,p=d[e.descriptor.droppableId],b=wE({impact:t,draggable:e,draggables:c,afterCritical:i,droppable:h||p,viewport:r});return Sn(b,e.client.borderBox.center)},Tk=({draggables:t,reason:e,lastImpact:n,home:r,viewport:i,onLiftImpact:c})=>!n.at||e!=="DROP"?{impact:AE({draggables:t,impact:c,destination:r,viewport:i,forceShouldAnimate:!0}),didDropInsideDroppable:!1}:n.at.type==="REORDER"?{impact:n,didDropInsideDroppable:!0}:{impact:{...n,displaced:go},didDropInsideDroppable:!0};const kk=({getState:t,dispatch:e})=>n=>r=>{if(!Xe(r,"DROP")){n(r);return}const i=t(),c=r.payload.reason;if(i.phase==="COLLECTING"){e(jk({reason:c}));return}if(i.phase==="IDLE")return;i.phase==="DROP_PENDING"&&i.isWaiting&&fe(),i.phase==="DRAGGING"||i.phase==="DROP_PENDING"||fe();const f=i.critical,h=i.dimensions,p=h.draggables[i.critical.draggable.id],{impact:b,didDropInsideDroppable:y}=Tk({reason:c,lastImpact:i.impact,afterCritical:i.afterCritical,onLiftImpact:i.onLiftImpact,home:i.dimensions.droppables[i.critical.droppable.id],viewport:i.viewport,draggables:i.dimensions.draggables}),m=y?Pg(b):null,v=y?yu(b):null,N={index:f.draggable.index,droppableId:f.droppable.id},S={draggableId:p.descriptor.id,type:p.descriptor.type,source:N,reason:c,mode:i.movementMode,destination:m,combine:v},j=Rk({impact:b,draggable:p,dimensions:h,viewport:i.viewport,afterCritical:i.afterCritical}),R={critical:i.critical,afterCritical:i.afterCritical,result:S,impact:b};if(!(!_s(i.current.client.offset,j)||!!S.combine)){e(qg({completed:R}));return}const O=Ok({current:i.current.client.offset,destination:j,reason:c});e(Sk({newHomeClientOffset:j,dropDuration:O,completed:R}))};var ME=()=>({x:window.pageXOffset,y:window.pageYOffset});function _k(t){return{eventName:"scroll",options:{passive:!0,capture:!1},fn:e=>{e.target!==window&&e.target!==window.document||t()}}}function Mk({onWindowScroll:t}){function e(){t(ME())}const n=ho(e),r=_k(n);let i=ks;function c(){return i!==ks}function d(){c()&&fe(),i=Fn(window,[r])}function f(){c()||fe(),n.cancel(),i(),i=ks}return{start:d,stop:f,isActive:c}}const Ik=t=>Xe(t,"DROP_COMPLETE")||Xe(t,"DROP_ANIMATE")||Xe(t,"FLUSH"),Lk=t=>{const e=Mk({onWindowScroll:n=>{t.dispatch(xk({newScroll:n}))}});return n=>r=>{!e.isActive()&&Xe(r,"INITIAL_PUBLISH")&&e.start(),e.isActive()&&Ik(r)&&e.stop(),n(r)}};var zk=t=>{let e=!1,n=!1;const r=setTimeout(()=>{n=!0}),i=c=>{e||n||(e=!0,t(c),clearTimeout(r))};return i.wasCalled=()=>e,i},Pk=()=>{const t=[],e=i=>{const c=t.findIndex(f=>f.timerId===i);c===-1&&fe();const[d]=t.splice(c,1);d.callback()};return{add:i=>{const c=setTimeout(()=>e(c)),d={timerId:c,callback:i};t.push(d)},flush:()=>{if(!t.length)return;const i=[...t];t.length=0,i.forEach(c=>{clearTimeout(c.timerId),c.callback()})}}};const Uk=(t,e)=>t==null&&e==null?!0:t==null||e==null?!1:t.droppableId===e.droppableId&&t.index===e.index,Bk=(t,e)=>t==null&&e==null?!0:t==null||e==null?!1:t.draggableId===e.draggableId&&t.droppableId===e.droppableId,Hk=(t,e)=>{if(t===e)return!0;const n=t.draggable.id===e.draggable.id&&t.draggable.droppableId===e.draggable.droppableId&&t.draggable.type===e.draggable.type&&t.draggable.index===e.draggable.index,r=t.droppable.id===e.droppable.id&&t.droppable.type===e.droppable.type;return n&&r},Wi=(t,e)=>{e()},dd=(t,e)=>({draggableId:t.draggable.id,type:t.droppable.type,source:{droppableId:t.droppable.id,index:t.draggable.index},mode:e});function fp(t,e,n,r){if(!t){n(r(e));return}const i=zk(n);t(e,{announce:i}),i.wasCalled()||n(r(e))}var Gk=(t,e)=>{const n=Pk();let r=null;const i=(y,m)=>{r&&fe(),Wi("onBeforeCapture",()=>{const v=t().onBeforeCapture;v&&v({draggableId:y,mode:m})})},c=(y,m)=>{r&&fe(),Wi("onBeforeDragStart",()=>{const v=t().onBeforeDragStart;v&&v(dd(y,m))})},d=(y,m)=>{r&&fe();const v=dd(y,m);r={mode:m,lastCritical:y,lastLocation:v.source,lastCombine:null},n.add(()=>{Wi("onDragStart",()=>fp(t().onDragStart,v,e,wd.onDragStart))})},f=(y,m)=>{const v=Pg(m),N=yu(m);r||fe();const S=!Hk(y,r.lastCritical);S&&(r.lastCritical=y);const j=!Uk(r.lastLocation,v);j&&(r.lastLocation=v);const R=!Bk(r.lastCombine,N);if(R&&(r.lastCombine=N),!S&&!j&&!R)return;const C={...dd(y,r.mode),combine:N,destination:v};n.add(()=>{Wi("onDragUpdate",()=>fp(t().onDragUpdate,C,e,wd.onDragUpdate))})},h=()=>{r||fe(),n.flush()},p=y=>{r||fe(),r=null,Wi("onDragEnd",()=>fp(t().onDragEnd,y,e,wd.onDragEnd))};return{beforeCapture:i,beforeStart:c,start:d,update:f,flush:h,drop:p,abort:()=>{if(!r)return;const y={...dd(r.lastCritical,r.mode),combine:null,destination:null,reason:"CANCEL"};p(y)}}},Vk=(t,e)=>{const n=Gk(t,e);return r=>i=>c=>{if(Xe(c,"BEFORE_INITIAL_CAPTURE")){n.beforeCapture(c.payload.draggableId,c.payload.movementMode);return}if(Xe(c,"INITIAL_PUBLISH")){const f=c.payload.critical;n.beforeStart(f,c.payload.movementMode),i(c),n.start(f,c.payload.movementMode);return}if(Xe(c,"DROP_COMPLETE")){const f=c.payload.completed.result;n.flush(),i(c),n.drop(f);return}if(i(c),Xe(c,"FLUSH")){n.abort();return}const d=r.getState();d.phase==="DRAGGING"&&n.update(d.critical,d.impact)}};const Fk=t=>e=>n=>{if(!Xe(n,"DROP_ANIMATION_FINISHED")){e(n);return}const r=t.getState();r.phase!=="DROP_ANIMATING"&&fe(),t.dispatch(qg({completed:r.completed}))},qk=t=>{let e=null,n=null;function r(){n&&(cancelAnimationFrame(n),n=null),e&&(e(),e=null)}return i=>c=>{if((Xe(c,"FLUSH")||Xe(c,"DROP_COMPLETE")||Xe(c,"DROP_ANIMATION_FINISHED"))&&r(),i(c),!Xe(c,"DROP_ANIMATE"))return;const d={eventName:"scroll",options:{capture:!0,passive:!1,once:!0},fn:function(){t.getState().phase==="DROP_ANIMATING"&&t.dispatch(TE())}};n=requestAnimationFrame(()=>{n=null,e=Fn(window,[d])})}};var $k=t=>()=>e=>n=>{(Xe(n,"DROP_COMPLETE")||Xe(n,"FLUSH")||Xe(n,"DROP_ANIMATE"))&&t.stopPublishing(),e(n)},Yk=t=>{let e=!1;return()=>n=>r=>{if(Xe(r,"INITIAL_PUBLISH")){e=!0,t.tryRecordFocus(r.payload.critical.draggable.id),n(r),t.tryRestoreFocusRecorded();return}if(n(r),!!e){if(Xe(r,"FLUSH")){e=!1,t.tryRestoreFocusRecorded();return}if(Xe(r,"DROP_COMPLETE")){e=!1;const i=r.payload.completed.result;i.combine&&t.tryShiftRecord(i.draggableId,i.combine.draggableId),t.tryRestoreFocusRecorded()}}}};const Qk=t=>Xe(t,"DROP_COMPLETE")||Xe(t,"DROP_ANIMATE")||Xe(t,"FLUSH");var Wk=t=>e=>n=>r=>{if(Qk(r)){t.stop(),n(r);return}if(Xe(r,"INITIAL_PUBLISH")){n(r);const i=e.getState();i.phase!=="DRAGGING"&&fe(),t.start(i);return}n(r),t.scroll(e.getState())};const Xk=t=>e=>n=>{if(e(n),!Xe(n,"PUBLISH_WHILE_DRAGGING"))return;const r=t.getState();r.phase==="DROP_PENDING"&&(r.isWaiting||t.dispatch(RE({reason:r.reason})))},Zk=XN;var Kk=({dimensionMarshal:t,focusMarshal:e,styleMarshal:n,getResponders:r,announce:i,autoScroller:c})=>WN(ok,Zk(ZO(wk(n),$k(t),Ak(t),kk,Fk,qk,Xk,Wk(c),Lk,Yk(e),Vk(r,i))));const hp=()=>({additions:{},removals:{},modified:{}});function Jk({registry:t,callbacks:e}){let n=hp(),r=null;const i=()=>{r||(e.collectionStarting(),r=requestAnimationFrame(()=>{r=null;const{additions:h,removals:p,modified:b}=n,y=Object.keys(h).map(N=>t.draggable.getById(N).getDimension(Mt)).sort((N,S)=>N.descriptor.index-S.descriptor.index),m=Object.keys(b).map(N=>{const j=t.droppable.getById(N).callbacks.getScrollWhileDragging();return{droppableId:N,scroll:j}}),v={additions:y,removals:Object.keys(p),modified:m};n=hp(),e.publish(v)}))};return{add:h=>{const p=h.descriptor.id;n.additions[p]=h,n.modified[h.descriptor.droppableId]=!0,n.removals[p]&&delete n.removals[p],i()},remove:h=>{const p=h.descriptor;n.removals[p.id]=!0,n.modified[p.droppableId]=!0,n.additions[p.id]&&delete n.additions[p.id],i()},stop:()=>{r&&(cancelAnimationFrame(r),r=null,n=hp())}}}var IE=({scrollHeight:t,scrollWidth:e,height:n,width:r})=>{const i=Sn({x:e,y:t},{x:r,y:n});return{x:Math.max(0,i.x),y:Math.max(0,i.y)}},LE=()=>{const t=document.documentElement;return t||fe(),t},zE=()=>{const t=LE();return IE({scrollHeight:t.scrollHeight,scrollWidth:t.scrollWidth,width:t.clientWidth,height:t.clientHeight})},e_=()=>{const t=ME(),e=zE(),n=t.y,r=t.x,i=LE(),c=i.clientWidth,d=i.clientHeight,f=r+c,h=n+d;return{frame:Jn({top:n,left:r,right:f,bottom:h}),scroll:{initial:t,current:t,max:e,diff:{value:Mt,displacement:Mt}}}},t_=({critical:t,scrollOptions:e,registry:n})=>{const r=e_(),i=r.scroll.current,c=t.droppable,d=n.droppable.getAllByType(c.type).map(b=>b.callbacks.getDimensionAndWatchScroll(i,e)),f=n.draggable.getAllByType(t.draggable.type).map(b=>b.getDimension(i));return{dimensions:{draggables:uE(f),droppables:dE(d)},critical:t,viewport:r}};function Tv(t,e,n){return!(n.descriptor.id===e.id||n.descriptor.type!==e.type||t.droppable.getById(n.descriptor.droppableId).descriptor.mode!=="virtual")}var n_=(t,e)=>{let n=null;const r=Jk({callbacks:{publish:e.publishWhileDragging,collectionStarting:e.collectionStarting},registry:t}),i=(m,v)=>{t.droppable.exists(m)||fe(),n&&e.updateDroppableIsEnabled({id:m,isEnabled:v})},c=(m,v)=>{n&&(t.droppable.exists(m)||fe(),e.updateDroppableIsCombineEnabled({id:m,isCombineEnabled:v}))},d=(m,v)=>{n&&(t.droppable.exists(m)||fe(),e.updateDroppableScroll({id:m,newScroll:v}))},f=(m,v)=>{n&&t.droppable.getById(m).callbacks.scroll(v)},h=()=>{if(!n)return;r.stop();const m=n.critical.droppable;t.droppable.getAllByType(m.type).forEach(v=>v.callbacks.dragStopped()),n.unsubscribe(),n=null},p=m=>{n||fe();const v=n.critical.draggable;m.type==="ADDITION"&&Tv(t,v,m.value)&&r.add(m.value),m.type==="REMOVAL"&&Tv(t,v,m.value)&&r.remove(m.value)};return{updateDroppableIsEnabled:i,updateDroppableIsCombineEnabled:c,scrollDroppable:f,updateDroppableScroll:d,startPublishing:m=>{n&&fe();const v=t.draggable.getById(m.draggableId),N=t.droppable.getById(v.descriptor.droppableId),S={draggable:v.descriptor,droppable:N.descriptor},j=t.subscribe(p);return n={critical:S,unsubscribe:j},t_({critical:S,registry:t,scrollOptions:m.scrollOptions})},stopPublishing:h}},PE=(t,e)=>t.phase==="IDLE"?!0:t.phase!=="DROP_ANIMATING"||t.completed.result.draggableId===e?!1:t.completed.result.reason==="DROP",a_=t=>{window.scrollBy(t.x,t.y)};const s_=kt(t=>bu(t).filter(e=>!(!e.isEnabled||!e.frame))),r_=(t,e)=>s_(e).find(r=>(r.frame||fe(),NE(r.frame.pageMarginBox)(t)))||null;var l_=({center:t,destination:e,droppables:n})=>{if(e){const i=n[e];return i.frame?i:null}return r_(t,n)};const bo={startFromPercentage:.25,maxScrollAtPercentage:.05,maxPixelScroll:28,ease:t=>t**2,durationDampening:{stopDampeningAt:1200,accelerateAt:360},disabled:!1};var i_=(t,e,n=()=>bo)=>{const r=n(),i=t[e.size]*r.startFromPercentage,c=t[e.size]*r.maxScrollAtPercentage;return{startScrollingFrom:i,maxScrollValueAt:c}},UE=({startOfRange:t,endOfRange:e,current:n})=>{const r=e-t;return r===0?0:(n-t)/r},Yg=1,o_=(t,e,n=()=>bo)=>{const r=n();if(t>e.startScrollingFrom)return 0;if(t<=e.maxScrollValueAt)return r.maxPixelScroll;if(t===e.startScrollingFrom)return Yg;const c=1-UE({startOfRange:e.maxScrollValueAt,endOfRange:e.startScrollingFrom,current:t}),d=r.maxPixelScroll*r.ease(c);return Math.ceil(d)},c_=(t,e,n)=>{const r=n(),i=r.durationDampening.accelerateAt,c=r.durationDampening.stopDampeningAt,d=e,f=c,p=Date.now()-d;if(p>=c)return t;if(p{const c=o_(t,e,i);return c===0?0:r?Math.max(c_(c,n,i),Yg):c},_v=({container:t,distanceToEdges:e,dragStartTime:n,axis:r,shouldUseTimeDampening:i,getAutoScrollerOptions:c})=>{const d=i_(t,r,c);return e[r.end]{const r=e.height>t.height,i=e.width>t.width;return!i&&!r?n:i&&r?null:{x:i?0:n.x,y:r?0:n.y}};const u_=cE(t=>t===0?0:t);var BE=({dragStartTime:t,container:e,subject:n,center:r,shouldUseTimeDampening:i,getAutoScrollerOptions:c})=>{const d={top:r.y-e.top,right:e.right-r.x,bottom:e.bottom-r.y,left:r.x-e.left},f=_v({container:e,distanceToEdges:d,dragStartTime:t,axis:Ug,shouldUseTimeDampening:i,getAutoScrollerOptions:c}),h=_v({container:e,distanceToEdges:d,dragStartTime:t,axis:pE,shouldUseTimeDampening:i,getAutoScrollerOptions:c}),p=u_({x:h,y:f});if(_s(p,Mt))return null;const b=d_({container:e,subject:n,proposedScroll:p});return b?_s(b,Mt)?null:b:null};const f_=cE(t=>t===0?0:t>0?1:-1),Qg=(()=>{const t=(e,n)=>e<0?e:e>n?e-n:0;return({current:e,max:n,change:r})=>{const i=Gt(e,r),c={x:t(i.x,n.x),y:t(i.y,n.y)};return _s(c,Mt)?null:c}})(),HE=({max:t,current:e,change:n})=>{const r={x:Math.max(e.x,t.x),y:Math.max(e.y,t.y)},i=f_(n),c=Qg({max:r,current:e,change:i});return!c||i.x!==0&&c.x===0||i.y!==0&&c.y===0},Wg=(t,e)=>HE({current:t.scroll.current,max:t.scroll.max,change:e}),h_=(t,e)=>{if(!Wg(t,e))return null;const n=t.scroll.max,r=t.scroll.current;return Qg({current:r,max:n,change:e})},Xg=(t,e)=>{const n=t.frame;return n?HE({current:n.scroll.current,max:n.scroll.max,change:e}):!1},p_=(t,e)=>{const n=t.frame;return!n||!Xg(t,e)?null:Qg({current:n.scroll.current,max:n.scroll.max,change:e})};var g_=({viewport:t,subject:e,center:n,dragStartTime:r,shouldUseTimeDampening:i,getAutoScrollerOptions:c})=>{const d=BE({dragStartTime:r,container:t.frame,subject:e,center:n,shouldUseTimeDampening:i,getAutoScrollerOptions:c});return d&&Wg(t,d)?d:null},m_=({droppable:t,subject:e,center:n,dragStartTime:r,shouldUseTimeDampening:i,getAutoScrollerOptions:c})=>{const d=t.frame;if(!d)return null;const f=BE({dragStartTime:r,container:d.pageMarginBox,subject:e,center:n,shouldUseTimeDampening:i,getAutoScrollerOptions:c});return f&&Xg(t,f)?f:null},Mv=({state:t,dragStartTime:e,shouldUseTimeDampening:n,scrollWindow:r,scrollDroppable:i,getAutoScrollerOptions:c})=>{const d=t.current.page.borderBoxCenter,h=t.dimensions.draggables[t.critical.draggable.id].page.marginBox;if(t.isWindowScrollAllowed){const y=t.viewport,m=g_({dragStartTime:e,viewport:y,subject:h,center:d,shouldUseTimeDampening:n,getAutoScrollerOptions:c});if(m){r(m);return}}const p=l_({center:d,destination:jn(t.impact),droppables:t.dimensions.droppables});if(!p)return;const b=m_({dragStartTime:e,droppable:p,subject:h,center:d,shouldUseTimeDampening:n,getAutoScrollerOptions:c});b&&i(p.descriptor.id,b)},x_=({scrollWindow:t,scrollDroppable:e,getAutoScrollerOptions:n=()=>bo})=>{const r=ho(t),i=ho(e);let c=null;const d=p=>{c||fe();const{shouldUseTimeDampening:b,dragStartTime:y}=c;Mv({state:p,scrollWindow:r,scrollDroppable:i,dragStartTime:y,shouldUseTimeDampening:b,getAutoScrollerOptions:n})};return{start:p=>{c&&fe();const b=Date.now();let y=!1;const m=()=>{y=!0};Mv({state:p,dragStartTime:0,shouldUseTimeDampening:!1,scrollWindow:m,scrollDroppable:m,getAutoScrollerOptions:n}),c={dragStartTime:b,shouldUseTimeDampening:y},y&&d(p)},stop:()=>{c&&(r.cancel(),i.cancel(),c=null)},scroll:d}},b_=({move:t,scrollDroppable:e,scrollWindow:n})=>{const r=(f,h)=>{const p=Gt(f.current.client.selection,h);t({client:p})},i=(f,h)=>{if(!Xg(f,h))return h;const p=p_(f,h);if(!p)return e(f.descriptor.id,h),null;const b=Sn(h,p);return e(f.descriptor.id,b),Sn(h,b)},c=(f,h,p)=>{if(!f||!Wg(h,p))return p;const b=h_(h,p);if(!b)return n(p),null;const y=Sn(p,b);return n(y),Sn(p,y)};return f=>{const h=f.scrollJumpRequest;if(!h)return;const p=jn(f.impact);p||fe();const b=i(f.dimensions.droppables[p],h);if(!b)return;const y=f.viewport,m=c(f.isWindowScrollAllowed,y,b);m&&r(f,m)}},y_=({scrollDroppable:t,scrollWindow:e,move:n,getAutoScrollerOptions:r})=>{const i=x_({scrollWindow:e,scrollDroppable:t,getAutoScrollerOptions:r}),c=b_({move:n,scrollWindow:e,scrollDroppable:t});return{scroll:h=>{if(!(r().disabled||h.phase!=="DRAGGING")){if(h.movementMode==="FLUID"){i.scroll(h);return}h.scrollJumpRequest&&c(h)}},start:i.start,stop:i.stop}};const Pl="data-rfd",Ul=(()=>{const t=`${Pl}-drag-handle`;return{base:t,draggableId:`${t}-draggable-id`,contextId:`${t}-context-id`}})(),Yp=(()=>{const t=`${Pl}-draggable`;return{base:t,contextId:`${t}-context-id`,id:`${t}-id`}})(),v_=(()=>{const t=`${Pl}-droppable`;return{base:t,contextId:`${t}-context-id`,id:`${t}-id`}})(),Iv={contextId:`${Pl}-scroll-container-context-id`},N_=t=>e=>`[${e}="${t}"]`,Xi=(t,e)=>t.map(n=>{const r=n.styles[e];return r?`${n.selector} { ${r} }`:""}).join(" "),E_="pointer-events: none;";var S_=t=>{const e=N_(t),n=(()=>{const f=` cursor: -webkit-grab; cursor: grab; `;return{selector:e(Ul.contextId),styles:{always:` -webkit-touch-callout: none; -webkit-tap-highlight-color: rgba(0,0,0,0); touch-action: manipulation; `,resting:f,dragging:E_,dropAnimating:f}}})(),r=(()=>{const f=` transition: ${lo.outOfTheWay}; `;return{selector:e(Yp.contextId),styles:{dragging:f,dropAnimating:f,userCancel:f}}})(),i={selector:e(v_.contextId),styles:{always:"overflow-anchor: none;"}},d=[r,n,i,{selector:"body",styles:{dragging:` cursor: grabbing; cursor: -webkit-grabbing; user-select: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; overflow-anchor: none; `}}];return{always:Xi(d,"always"),resting:Xi(d,"resting"),dragging:Xi(d,"dragging"),dropAnimating:Xi(d,"dropAnimating"),userCancel:Xi(d,"userCancel")}};const An=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?w.useLayoutEffect:w.useEffect,pp=()=>{const t=document.querySelector("head");return t||fe(),t},Lv=t=>{const e=document.createElement("style");return t&&e.setAttribute("nonce",t),e.type="text/css",e};function j_(t,e){const n=qe(()=>S_(t),[t]),r=w.useRef(null),i=w.useRef(null),c=ye(kt(y=>{const m=i.current;m||fe(),m.textContent=y}),[]),d=ye(y=>{const m=r.current;m||fe(),m.textContent=y},[]);An(()=>{!r.current&&!i.current||fe();const y=Lv(e),m=Lv(e);return r.current=y,i.current=m,y.setAttribute(`${Pl}-always`,t),m.setAttribute(`${Pl}-dynamic`,t),pp().appendChild(y),pp().appendChild(m),d(n.always),c(n.resting),()=>{const v=N=>{const S=N.current;S||fe(),pp().removeChild(S),N.current=null};v(r),v(i)}},[e,d,c,n.always,n.resting,t]);const f=ye(()=>c(n.dragging),[c,n.dragging]),h=ye(y=>{if(y==="DROP"){c(n.dropAnimating);return}c(n.userCancel)},[c,n.dropAnimating,n.userCancel]),p=ye(()=>{i.current&&c(n.resting)},[c,n.resting]);return qe(()=>({dragging:f,dropping:h,resting:p}),[f,h,p])}function GE(t,e){return Array.from(t.querySelectorAll(e))}var VE=t=>t&&t.ownerDocument&&t.ownerDocument.defaultView?t.ownerDocument.defaultView:window;function Eu(t){return t instanceof VE(t).HTMLElement}function A_(t,e){const n=`[${Ul.contextId}="${t}"]`,r=GE(document,n);if(!r.length)return null;const i=r.find(c=>c.getAttribute(Ul.draggableId)===e);return!i||!Eu(i)?null:i}function w_(t){const e=w.useRef({}),n=w.useRef(null),r=w.useRef(null),i=w.useRef(!1),c=ye(function(m,v){const N={id:m,focus:v};return e.current[m]=N,function(){const j=e.current;j[m]!==N&&delete j[m]}},[]),d=ye(function(m){const v=A_(t,m);v&&v!==document.activeElement&&v.focus()},[t]),f=ye(function(m,v){n.current===m&&(n.current=v)},[]),h=ye(function(){r.current||i.current&&(r.current=requestAnimationFrame(()=>{r.current=null;const m=n.current;m&&d(m)}))},[d]),p=ye(function(m){n.current=null;const v=document.activeElement;v&&v.getAttribute(Ul.draggableId)===m&&(n.current=m)},[]);return An(()=>(i.current=!0,function(){i.current=!1;const m=r.current;m&&cancelAnimationFrame(m)}),[]),qe(()=>({register:c,tryRecordFocus:p,tryRestoreFocusRecorded:h,tryShiftRecord:f}),[c,p,h,f])}function C_(){const t={draggables:{},droppables:{}},e=[];function n(y){return e.push(y),function(){const v=e.indexOf(y);v!==-1&&e.splice(v,1)}}function r(y){e.length&&e.forEach(m=>m(y))}function i(y){return t.draggables[y]||null}function c(y){const m=i(y);return m||fe(),m}const d={register:y=>{t.draggables[y.descriptor.id]=y,r({type:"ADDITION",value:y})},update:(y,m)=>{const v=t.draggables[m.descriptor.id];v&&v.uniqueId===y.uniqueId&&(delete t.draggables[m.descriptor.id],t.draggables[y.descriptor.id]=y)},unregister:y=>{const m=y.descriptor.id,v=i(m);v&&y.uniqueId===v.uniqueId&&(delete t.draggables[m],t.droppables[y.descriptor.droppableId]&&r({type:"REMOVAL",value:y}))},getById:c,findById:i,exists:y=>!!i(y),getAllByType:y=>Object.values(t.draggables).filter(m=>m.descriptor.type===y)};function f(y){return t.droppables[y]||null}function h(y){const m=f(y);return m||fe(),m}const p={register:y=>{t.droppables[y.descriptor.id]=y},unregister:y=>{const m=f(y.descriptor.id);m&&y.uniqueId===m.uniqueId&&delete t.droppables[y.descriptor.id]},getById:h,findById:f,exists:y=>!!f(y),getAllByType:y=>Object.values(t.droppables).filter(m=>m.descriptor.type===y)};function b(){t.draggables={},t.droppables={},e.length=0}return{draggable:d,droppable:p,subscribe:n,clean:b}}function D_(){const t=qe(C_,[]);return w.useEffect(()=>function(){t.clean()},[t]),t}var Zg=Ve.createContext(null),Fd=()=>{const t=document.body;return t||fe(),t};const O_={position:"absolute",width:"1px",height:"1px",margin:"-1px",border:"0",padding:"0",overflow:"hidden",clip:"rect(0 0 0 0)","clip-path":"inset(100%)"},R_=t=>`rfd-announcement-${t}`;function T_(t){const e=qe(()=>R_(t),[t]),n=w.useRef(null);return w.useEffect(function(){const c=document.createElement("div");return n.current=c,c.id=e,c.setAttribute("aria-live","assertive"),c.setAttribute("aria-atomic","true"),Bd(c.style,O_),Fd().appendChild(c),function(){setTimeout(function(){const h=Fd();h.contains(c)&&h.removeChild(c),c===n.current&&(n.current=null)})}},[e]),ye(i=>{const c=n.current;if(c){c.textContent=i;return}},[])}const k_={separator:"::"};function Kg(t,e=k_){const n=Ve.useId();return qe(()=>`${t}${e.separator}${n}`,[e.separator,t,n])}function __({contextId:t,uniqueId:e}){return`rfd-hidden-text-${t}-${e}`}function M_({contextId:t,text:e}){const n=Kg("hidden-text",{separator:"-"}),r=qe(()=>__({contextId:t,uniqueId:n}),[n,t]);return w.useEffect(function(){const c=document.createElement("div");return c.id=r,c.textContent=e,c.style.display="none",Fd().appendChild(c),function(){const f=Fd();f.contains(c)&&f.removeChild(c)}},[r,e]),r}var Su=Ve.createContext(null);function FE(t){const e=w.useRef(t);return w.useEffect(()=>{e.current=t}),e}function I_(){let t=null;function e(){return!!t}function n(d){return d===t}function r(d){t&&fe();const f={abandon:d};return t=f,f}function i(){t||fe(),t=null}function c(){t&&(t.abandon(),i())}return{isClaimed:e,isActive:n,claim:r,release:i,tryAbandon:c}}function yo(t){return t.phase==="IDLE"||t.phase==="DROP_ANIMATING"?!1:t.isDragging}const L_=9,z_=13,Jg=27,qE=32,P_=33,U_=34,B_=35,H_=36,G_=37,V_=38,F_=39,q_=40,$_={[z_]:!0,[L_]:!0};var $E=t=>{$_[t.keyCode]&&t.preventDefault()};const ju=(()=>{const t="visibilitychange";return typeof document>"u"?t:[t,`ms${t}`,`webkit${t}`,`moz${t}`,`o${t}`].find(r=>`on${r}`in document)||t})(),YE=0,zv=5;function Y_(t,e){return Math.abs(e.x-t.x)>=zv||Math.abs(e.y-t.y)>=zv}const Pv={type:"IDLE"};function Q_({cancel:t,completed:e,getPhase:n,setPhase:r}){return[{eventName:"mousemove",fn:i=>{const{button:c,clientX:d,clientY:f}=i;if(c!==YE)return;const h={x:d,y:f},p=n();if(p.type==="DRAGGING"){i.preventDefault(),p.actions.move(h);return}p.type!=="PENDING"&&fe();const b=p.point;if(!Y_(b,h))return;i.preventDefault();const y=p.actions.fluidLift(h);r({type:"DRAGGING",actions:y})}},{eventName:"mouseup",fn:i=>{const c=n();if(c.type!=="DRAGGING"){t();return}i.preventDefault(),c.actions.drop({shouldBlockNextClick:!0}),e()}},{eventName:"mousedown",fn:i=>{n().type==="DRAGGING"&&i.preventDefault(),t()}},{eventName:"keydown",fn:i=>{if(n().type==="PENDING"){t();return}if(i.keyCode===Jg){i.preventDefault(),t();return}$E(i)}},{eventName:"resize",fn:t},{eventName:"scroll",options:{passive:!0,capture:!1},fn:()=>{n().type==="PENDING"&&t()}},{eventName:"webkitmouseforcedown",fn:i=>{const c=n();if(c.type==="IDLE"&&fe(),c.actions.shouldRespectForcePress()){t();return}i.preventDefault()}},{eventName:ju,fn:t}]}function W_(t){const e=w.useRef(Pv),n=w.useRef(ks),r=qe(()=>({eventName:"mousedown",fn:function(y){if(y.defaultPrevented||y.button!==YE||y.ctrlKey||y.metaKey||y.shiftKey||y.altKey)return;const m=t.findClosestDraggableId(y);if(!m)return;const v=t.tryGetLock(m,d,{sourceEvent:y});if(!v)return;y.preventDefault();const N={x:y.clientX,y:y.clientY};n.current(),p(v,N)}}),[t]),i=qe(()=>({eventName:"webkitmouseforcewillbegin",fn:b=>{if(b.defaultPrevented)return;const y=t.findClosestDraggableId(b);if(!y)return;const m=t.findOptionsForDraggable(y);m&&(m.shouldRespectForcePress||t.canGetLock(y)&&b.preventDefault())}}),[t]),c=ye(function(){const y={passive:!1,capture:!0};n.current=Fn(window,[i,r],y)},[i,r]),d=ye(()=>{e.current.type!=="IDLE"&&(e.current=Pv,n.current(),c())},[c]),f=ye(()=>{const b=e.current;d(),b.type==="DRAGGING"&&b.actions.cancel({shouldBlockNextClick:!0}),b.type==="PENDING"&&b.actions.abort()},[d]),h=ye(function(){const y={capture:!0,passive:!1},m=Q_({cancel:f,completed:d,getPhase:()=>e.current,setPhase:v=>{e.current=v}});n.current=Fn(window,m,y)},[f,d]),p=ye(function(y,m){e.current.type!=="IDLE"&&fe(),e.current={type:"PENDING",point:m,actions:y},h()},[h]);An(function(){return c(),function(){n.current()}},[c])}function X_(){}const Z_={[U_]:!0,[P_]:!0,[H_]:!0,[B_]:!0};function K_(t,e){function n(){e(),t.cancel()}function r(){e(),t.drop()}return[{eventName:"keydown",fn:i=>{if(i.keyCode===Jg){i.preventDefault(),n();return}if(i.keyCode===qE){i.preventDefault(),r();return}if(i.keyCode===q_){i.preventDefault(),t.moveDown();return}if(i.keyCode===V_){i.preventDefault(),t.moveUp();return}if(i.keyCode===F_){i.preventDefault(),t.moveRight();return}if(i.keyCode===G_){i.preventDefault(),t.moveLeft();return}if(Z_[i.keyCode]){i.preventDefault();return}$E(i)}},{eventName:"mousedown",fn:n},{eventName:"mouseup",fn:n},{eventName:"click",fn:n},{eventName:"touchstart",fn:n},{eventName:"resize",fn:n},{eventName:"wheel",fn:n,options:{passive:!0}},{eventName:ju,fn:n}]}function J_(t){const e=w.useRef(X_),n=qe(()=>({eventName:"keydown",fn:function(c){if(c.defaultPrevented||c.keyCode!==qE)return;const d=t.findClosestDraggableId(c);if(!d)return;const f=t.tryGetLock(d,b,{sourceEvent:c});if(!f)return;c.preventDefault();let h=!0;const p=f.snapLift();e.current();function b(){h||fe(),h=!1,e.current(),r()}e.current=Fn(window,K_(p,b),{capture:!0,passive:!1})}}),[t]),r=ye(function(){const c={passive:!1,capture:!0};e.current=Fn(window,[n],c)},[n]);An(function(){return r(),function(){e.current()}},[r])}const gp={type:"IDLE"},e5=120,t5=.15;function n5({cancel:t,getPhase:e}){return[{eventName:"orientationchange",fn:t},{eventName:"resize",fn:t},{eventName:"contextmenu",fn:n=>{n.preventDefault()}},{eventName:"keydown",fn:n=>{if(e().type!=="DRAGGING"){t();return}n.keyCode===Jg&&n.preventDefault(),t()}},{eventName:ju,fn:t}]}function a5({cancel:t,completed:e,getPhase:n}){return[{eventName:"touchmove",options:{capture:!1},fn:r=>{const i=n();if(i.type!=="DRAGGING"){t();return}i.hasMoved=!0;const{clientX:c,clientY:d}=r.touches[0],f={x:c,y:d};r.preventDefault(),i.actions.move(f)}},{eventName:"touchend",fn:r=>{const i=n();if(i.type!=="DRAGGING"){t();return}r.preventDefault(),i.actions.drop({shouldBlockNextClick:!0}),e()}},{eventName:"touchcancel",fn:r=>{if(n().type!=="DRAGGING"){t();return}r.preventDefault(),t()}},{eventName:"touchforcechange",fn:r=>{const i=n();i.type==="IDLE"&&fe();const c=r.touches[0];if(!c||!(c.force>=t5))return;const f=i.actions.shouldRespectForcePress();if(i.type==="PENDING"){f&&t();return}if(f){if(i.hasMoved){r.preventDefault();return}t();return}r.preventDefault()}},{eventName:ju,fn:t}]}function s5(t){const e=w.useRef(gp),n=w.useRef(ks),r=ye(function(){return e.current},[]),i=ye(function(v){e.current=v},[]),c=qe(()=>({eventName:"touchstart",fn:function(v){if(v.defaultPrevented)return;const N=t.findClosestDraggableId(v);if(!N)return;const S=t.tryGetLock(N,f,{sourceEvent:v});if(!S)return;const j=v.touches[0],{clientX:R,clientY:C}=j,O={x:R,y:C};n.current(),y(S,O)}}),[t]),d=ye(function(){const v={capture:!0,passive:!1};n.current=Fn(window,[c],v)},[c]),f=ye(()=>{const m=e.current;m.type!=="IDLE"&&(m.type==="PENDING"&&clearTimeout(m.longPressTimerId),i(gp),n.current(),d())},[d,i]),h=ye(()=>{const m=e.current;f(),m.type==="DRAGGING"&&m.actions.cancel({shouldBlockNextClick:!0}),m.type==="PENDING"&&m.actions.abort()},[f]),p=ye(function(){const v={capture:!0,passive:!1},N={cancel:h,completed:f,getPhase:r},S=Fn(window,a5(N),v),j=Fn(window,n5(N),v);n.current=function(){S(),j()}},[h,r,f]),b=ye(function(){const v=r();v.type!=="PENDING"&&fe();const N=v.actions.fluidLift(v.point);i({type:"DRAGGING",actions:N,hasMoved:!1})},[r,i]),y=ye(function(v,N){r().type!=="IDLE"&&fe();const S=setTimeout(b,e5);i({type:"PENDING",point:N,actions:v,longPressTimerId:S}),p()},[p,r,i,b]);An(function(){return d(),function(){n.current();const N=r();N.type==="PENDING"&&(clearTimeout(N.longPressTimerId),i(gp))}},[r,d,i]),An(function(){return Fn(window,[{eventName:"touchmove",fn:()=>{},options:{capture:!1,passive:!1}}])},[])}const r5=["input","button","textarea","select","option","optgroup","video","audio"];function QE(t,e){if(e==null)return!1;if(r5.includes(e.tagName.toLowerCase()))return!0;const r=e.getAttribute("contenteditable");return r==="true"||r===""?!0:e===t?!1:QE(t,e.parentElement)}function l5(t,e){const n=e.target;return Eu(n)?QE(t,n):!1}var i5=t=>Jn(t.getBoundingClientRect()).center;function o5(t){return t instanceof VE(t).Element}const c5=(()=>{const t="matches";return typeof document>"u"?t:[t,"msMatchesSelector","webkitMatchesSelector"].find(r=>r in Element.prototype)||t})();function WE(t,e){return t==null?null:t[c5](e)?t:WE(t.parentElement,e)}function d5(t,e){return t.closest?t.closest(e):WE(t,e)}function u5(t){return`[${Ul.contextId}="${t}"]`}function f5(t,e){const n=e.target;if(!o5(n))return null;const r=u5(t),i=d5(n,r);return!i||!Eu(i)?null:i}function h5(t,e){const n=f5(t,e);return n?n.getAttribute(Ul.draggableId):null}function p5(t,e){const n=`[${Yp.contextId}="${t}"]`,i=GE(document,n).find(c=>c.getAttribute(Yp.id)===e);return!i||!Eu(i)?null:i}function g5(t){t.preventDefault()}function ud({expected:t,phase:e,isLockActive:n,shouldWarn:r}){return!(!n()||t!==e)}function XE({lockAPI:t,store:e,registry:n,draggableId:r}){if(t.isClaimed())return!1;const i=n.draggable.findById(r);return!(!i||!i.options.isEnabled||!PE(e.getState(),r))}function m5({lockAPI:t,contextId:e,store:n,registry:r,draggableId:i,forceSensorStop:c,sourceEvent:d}){if(!XE({lockAPI:t,store:n,registry:r,draggableId:i}))return null;const h=r.draggable.getById(i),p=p5(e,h.descriptor.id);if(!p||d&&!h.options.canDragInteractiveElements&&l5(p,d))return null;const b=t.claim(c||ks);let y="PRE_DRAG";function m(){return h.options.shouldRespectForcePress}function v(){return t.isActive(b)}function N(k,_){ud({expected:k,phase:y,isLockActive:v,shouldWarn:!0})&&n.dispatch(_())}const S=N.bind(null,"DRAGGING");function j(k){function _(){t.release(),y="COMPLETED"}y!=="PRE_DRAG"&&(_(),fe()),n.dispatch(dk(k.liftActionArgs)),y="DRAGGING";function B(F,G={shouldBlockNextClick:!1}){if(k.cleanup(),G.shouldBlockNextClick){const ee=Fn(window,[{eventName:"click",fn:g5,options:{once:!0,passive:!1,capture:!0}}]);setTimeout(ee)}_(),n.dispatch(RE({reason:F}))}return{isActive:()=>ud({expected:"DRAGGING",phase:y,isLockActive:v,shouldWarn:!1}),shouldRespectForcePress:m,drop:F=>B("DROP",F),cancel:F=>B("CANCEL",F),...k.actions}}function R(k){const _=ho(F=>{S(()=>OE({client:F}))});return{...j({liftActionArgs:{id:i,clientSelection:k,movementMode:"FLUID"},cleanup:()=>_.cancel(),actions:{move:_}}),move:_}}function C(){const k={moveUp:()=>S(yk),moveRight:()=>S(Nk),moveDown:()=>S(vk),moveLeft:()=>S(Ek)};return j({liftActionArgs:{id:i,clientSelection:i5(p),movementMode:"SNAP"},cleanup:ks,actions:k})}function O(){ud({expected:"PRE_DRAG",phase:y,isLockActive:v,shouldWarn:!0})&&t.release()}return{isActive:()=>ud({expected:"PRE_DRAG",phase:y,isLockActive:v,shouldWarn:!1}),shouldRespectForcePress:m,fluidLift:R,snapLift:C,abort:O}}const x5=[W_,J_,s5];function b5({contextId:t,store:e,registry:n,customSensors:r,enableDefaultSensors:i}){const c=[...i?x5:[],...r||[]],d=w.useState(()=>I_())[0],f=ye(function(j,R){yo(j)&&!yo(R)&&d.tryAbandon()},[d]);An(function(){let j=e.getState();return e.subscribe(()=>{const C=e.getState();f(j,C),j=C})},[d,e,f]),An(()=>d.tryAbandon,[d.tryAbandon]);const h=ye(S=>XE({lockAPI:d,registry:n,store:e,draggableId:S}),[d,n,e]),p=ye((S,j,R)=>m5({lockAPI:d,registry:n,contextId:t,store:e,draggableId:S,forceSensorStop:j||null,sourceEvent:R&&R.sourceEvent?R.sourceEvent:null}),[t,d,n,e]),b=ye(S=>h5(t,S),[t]),y=ye(S=>{const j=n.draggable.findById(S);return j?j.options:null},[n.draggable]),m=ye(function(){d.isClaimed()&&(d.tryAbandon(),e.getState().phase!=="IDLE"&&e.dispatch(Fg()))},[d,e]),v=ye(()=>d.isClaimed(),[d]),N=qe(()=>({canGetLock:h,tryGetLock:p,findClosestDraggableId:b,findOptionsForDraggable:y,tryReleaseLock:m,isLockClaimed:v}),[h,p,b,y,m,v]);for(let S=0;S({onBeforeCapture:e=>{const n=()=>{t.onBeforeCapture&&t.onBeforeCapture(e)};wr.flushSync(n)},onBeforeDragStart:t.onBeforeDragStart,onDragStart:t.onDragStart,onDragEnd:t.onDragEnd,onDragUpdate:t.onDragUpdate}),v5=t=>({...bo,...t.autoScrollerOptions,durationDampening:{...bo.durationDampening,...t.autoScrollerOptions}});function Zi(t){return t.current||fe(),t.current}function N5(t){const{contextId:e,setCallbacks:n,sensors:r,nonce:i,dragHandleUsageInstructions:c}=t,d=w.useRef(null),f=FE(t),h=ye(()=>y5(f.current),[f]),p=ye(()=>v5(f.current),[f]),b=T_(e),y=M_({contextId:e,text:c}),m=j_(e,i),v=ye(ee=>{Zi(d).dispatch(ee)},[]),N=qe(()=>dv({publishWhileDragging:fk,updateDroppableScroll:pk,updateDroppableIsEnabled:gk,updateDroppableIsCombineEnabled:mk,collectionStarting:hk},v),[v]),S=D_(),j=qe(()=>n_(S,N),[S,N]),R=qe(()=>y_({scrollWindow:a_,scrollDroppable:j.scrollDroppable,getAutoScrollerOptions:p,...dv({move:OE},v)}),[j.scrollDroppable,v,p]),C=w_(e),O=qe(()=>Kk({announce:b,autoScroller:R,dimensionMarshal:j,focusMarshal:C,getResponders:h,styleMarshal:m}),[b,R,j,C,h,m]);d.current=O;const A=ye(()=>{const ee=Zi(d);ee.getState().phase!=="IDLE"&&ee.dispatch(Fg())},[]),k=ye(()=>{const ee=Zi(d).getState();return ee.phase==="DROP_ANIMATING"?!0:ee.phase==="IDLE"?!1:ee.isDragging},[]),_=qe(()=>({isDragging:k,tryAbort:A}),[k,A]);n(_);const B=ye(ee=>PE(Zi(d).getState(),ee),[]),F=ye(()=>ir(Zi(d).getState()),[]),G=qe(()=>({marshal:j,focus:C,contextId:e,canLift:B,isMovementAllowed:F,dragHandleUsageInstructionsId:y,registry:S}),[e,j,y,C,B,F,S]);return b5({contextId:e,store:O,registry:S,customSensors:r||null,enableDefaultSensors:t.enableDefaultSensors!==!1}),w.useEffect(()=>A,[A]),Ve.createElement(Su.Provider,{value:G},Ve.createElement($R,{context:Zg,store:O},t.children))}function E5(){return Ve.useId()}function Xl(t){const e=E5(),n=t.dragHandleUsageInstructions||wd.dragHandleUsageInstructions;return Ve.createElement(JR,null,r=>Ve.createElement(N5,{nonce:t.nonce,contextId:e,setCallbacks:r,dragHandleUsageInstructions:n,enableDefaultSensors:t.enableDefaultSensors,sensors:t.sensors,onBeforeCapture:t.onBeforeCapture,onBeforeDragStart:t.onBeforeDragStart,onDragStart:t.onDragStart,onDragUpdate:t.onDragUpdate,onDragEnd:t.onDragEnd,autoScrollerOptions:t.autoScrollerOptions},t.children))}const Uv={dragging:5e3,dropAnimating:4500},S5=(t,e)=>e?lo.drop(e.duration):t?lo.snap:lo.fluid,j5=(t,e)=>{if(t)return e?xo.opacity.drop:xo.opacity.combining},A5=t=>t.forceShouldAnimate!=null?t.forceShouldAnimate:t.mode==="SNAP";function w5(t){const n=t.dimension.client,{offset:r,combineWith:i,dropping:c}=t,d=!!i,f=A5(t),h=!!c,p=h?qp.drop(r,d):qp.moveTo(r);return{position:"fixed",top:n.marginBox.top,left:n.marginBox.left,boxSizing:"border-box",width:n.borderBox.width,height:n.borderBox.height,transition:S5(f,c),transform:p,opacity:j5(d,h),zIndex:h?Uv.dropAnimating:Uv.dragging,pointerEvents:"none"}}function C5(t){return{transform:qp.moveTo(t.offset),transition:t.shouldAnimateDisplacement?void 0:"none"}}function D5(t){return t.type==="DRAGGING"?w5(t):C5(t)}function O5(t,e,n=Mt){const r=window.getComputedStyle(e),i=e.getBoundingClientRect(),c=aE(i,r),d=Ud(c,n),f={client:c,tagName:e.tagName.toLowerCase(),display:r.display},h={x:c.marginBox.width,y:c.marginBox.height};return{descriptor:t,placeholder:f,displaceBy:h,client:c,page:d}}function R5(t){const e=Kg("draggable"),{descriptor:n,registry:r,getDraggableRef:i,canDragInteractiveElements:c,shouldRespectForcePress:d,isEnabled:f}=t,h=qe(()=>({canDragInteractiveElements:c,shouldRespectForcePress:d,isEnabled:f}),[c,f,d]),p=ye(v=>{const N=i();return N||fe(),O5(n,N,v)},[n,i]),b=qe(()=>({uniqueId:e,descriptor:n,options:h,getDimension:p}),[n,p,h,e]),y=w.useRef(b),m=w.useRef(!0);An(()=>(r.draggable.register(y.current),()=>r.draggable.unregister(y.current)),[r.draggable]),An(()=>{if(m.current){m.current=!1;return}const v=y.current;y.current=b,r.draggable.update(b,v)},[b,r.draggable])}var em=Ve.createContext(null);function qd(t){const e=w.useContext(t);return e||fe(),e}function T5(t){t.preventDefault()}const k5=t=>{const e=w.useRef(null),n=ye((_=null)=>{e.current=_},[]),r=ye(()=>e.current,[]),{contextId:i,dragHandleUsageInstructionsId:c,registry:d}=qd(Su),{type:f,droppableId:h}=qd(em),p=qe(()=>({id:t.draggableId,index:t.index,type:f,droppableId:h}),[t.draggableId,t.index,f,h]),{children:b,draggableId:y,isEnabled:m,shouldRespectForcePress:v,canDragInteractiveElements:N,isClone:S,mapped:j,dropAnimationFinished:R}=t;if(!S){const _=qe(()=>({descriptor:p,registry:d,getDraggableRef:r,canDragInteractiveElements:N,shouldRespectForcePress:v,isEnabled:m}),[p,d,r,N,v,m]);R5(_)}const C=qe(()=>m?{tabIndex:0,role:"button","aria-describedby":c,"data-rfd-drag-handle-draggable-id":y,"data-rfd-drag-handle-context-id":i,draggable:!1,onDragStart:T5}:null,[i,c,y,m]),O=ye(_=>{j.type==="DRAGGING"&&j.dropping&&_.propertyName==="transform"&&wr.flushSync(R)},[R,j]),A=qe(()=>{const _=D5(j),B=j.type==="DRAGGING"&&j.dropping?O:void 0;return{innerRef:n,draggableProps:{"data-rfd-draggable-context-id":i,"data-rfd-draggable-id":y,style:_,onTransitionEnd:B},dragHandleProps:C}},[i,C,y,j,O,n]),k=qe(()=>({draggableId:p.id,type:p.type,source:{index:p.index,droppableId:p.droppableId}}),[p.droppableId,p.id,p.index,p.type]);return Ve.createElement(Ve.Fragment,null,b(A,j.snapshot,k))};var ZE=(t,e)=>t===e,KE=t=>{const{combine:e,destination:n}=t;return n?n.droppableId:e?e.droppableId:null};const _5=t=>t.combine?t.combine.draggableId:null,M5=t=>t.at&&t.at.type==="COMBINE"?t.at.combine.draggableId:null;function I5(){const t=kt((i,c)=>({x:i,y:c})),e=kt((i,c,d=null,f=null,h=null)=>({isDragging:!0,isClone:c,isDropAnimating:!!h,dropAnimation:h,mode:i,draggingOver:d,combineWith:f,combineTargetFor:null})),n=kt((i,c,d,f,h=null,p=null,b=null)=>({mapped:{type:"DRAGGING",dropping:null,draggingOver:h,combineWith:p,mode:c,offset:i,dimension:d,forceShouldAnimate:b,snapshot:e(c,f,h,p,null)}}));return(i,c)=>{if(yo(i)){if(i.critical.draggable.id!==c.draggableId)return null;const d=i.current.client.offset,f=i.dimensions.draggables[c.draggableId],h=jn(i.impact),p=M5(i.impact),b=i.forceShouldAnimate;return n(t(d.x,d.y),i.movementMode,f,c.isClone,h,p,b)}if(i.phase==="DROP_ANIMATING"){const d=i.completed;if(d.result.draggableId!==c.draggableId)return null;const f=c.isClone,h=i.dimensions.draggables[c.draggableId],p=d.result,b=p.mode,y=KE(p),m=_5(p),N={duration:i.dropDuration,curve:$g.drop,moveTo:i.newHomeClientOffset,opacity:m?xo.opacity.drop:null,scale:m?xo.scale.drop:null};return{mapped:{type:"DRAGGING",offset:i.newHomeClientOffset,dimension:h,dropping:N,draggingOver:y,combineWith:m,mode:b,forceShouldAnimate:null,snapshot:e(b,f,y,m,N)}}}return null}}function JE(t=null){return{isDragging:!1,isDropAnimating:!1,isClone:!1,dropAnimation:null,mode:null,draggingOver:null,combineTargetFor:t,combineWith:null}}const L5={mapped:{type:"SECONDARY",offset:Mt,combineTargetFor:null,shouldAnimateDisplacement:!0,snapshot:JE(null)}};function z5(){const t=kt((d,f)=>({x:d,y:f})),e=kt(JE),n=kt((d,f=null,h)=>({mapped:{type:"SECONDARY",offset:d,combineTargetFor:f,shouldAnimateDisplacement:h,snapshot:e(f)}})),r=d=>d?n(Mt,d,!0):null,i=(d,f,h,p)=>{const b=h.displaced.visible[d],y=!!(p.inVirtualList&&p.effected[d]),m=yu(h),v=m&&m.draggableId===d?f:null;if(!b){if(!y)return r(v);if(h.displaced.invisible[d])return null;const j=Yl(p.displacedBy.point),R=t(j.x,j.y);return n(R,v,!0)}if(y)return r(v);const N=h.displacedBy.point,S=t(N.x,N.y);return n(S,v,b.shouldAnimate)};return(d,f)=>{if(yo(d))return d.critical.draggable.id===f.draggableId?null:i(f.draggableId,d.critical.draggable.id,d.impact,d.afterCritical);if(d.phase==="DROP_ANIMATING"){const h=d.completed;return h.result.draggableId===f.draggableId?null:i(f.draggableId,h.result.draggableId,h.impact,h.afterCritical)}return null}}const P5=()=>{const t=I5(),e=z5();return(r,i)=>t(r,i)||e(r,i)||L5},U5={dropAnimationFinished:TE},B5=nE(P5,U5,null,{context:Zg,areStatePropsEqual:ZE})(k5);function eS(t){return qd(em).isUsingCloneFor===t.draggableId&&!t.isClone?null:Ve.createElement(B5,t)}function Zl(t){const e=typeof t.isDragDisabled=="boolean"?!t.isDragDisabled:!0,n=!!t.disableInteractiveElementBlocking,r=!!t.shouldRespectForcePress;return Ve.createElement(eS,Bd({},t,{isClone:!1,isEnabled:e,canDragInteractiveElements:n,shouldRespectForcePress:r}))}const tS=t=>e=>t===e,H5=tS("scroll"),G5=tS("auto"),Bv=(t,e)=>e(t.overflowX)||e(t.overflowY),V5=t=>{const e=window.getComputedStyle(t),n={overflowX:e.overflowX,overflowY:e.overflowY};return Bv(n,H5)||Bv(n,G5)},F5=()=>!1,nS=t=>t==null?null:t===document.body?F5()?t:null:t===document.documentElement?null:V5(t)?t:nS(t.parentElement);var Qp=t=>({x:t.scrollLeft,y:t.scrollTop});const aS=t=>t?window.getComputedStyle(t).position==="fixed"?!0:aS(t.parentElement):!1;var q5=t=>{const e=nS(t),n=aS(t);return{closestScrollable:e,isFixedOnPage:n}},$5=({descriptor:t,isEnabled:e,isCombineEnabled:n,isFixedOnPage:r,direction:i,client:c,page:d,closest:f})=>{const h=(()=>{if(!f)return null;const{scrollSize:m,client:v}=f,N=IE({scrollHeight:m.scrollHeight,scrollWidth:m.scrollWidth,height:v.paddingBox.height,width:v.paddingBox.width});return{pageMarginBox:f.page.marginBox,frameClient:v,scrollSize:m,shouldClipSubject:f.shouldClipSubject,scroll:{initial:f.scroll,current:f.scroll,max:N,diff:{value:Mt,displacement:Mt}}}})(),p=i==="vertical"?Ug:pE,b=zl({page:d,withPlaceholder:null,axis:p,frame:h});return{descriptor:t,isCombineEnabled:n,isFixedOnPage:r,axis:p,isEnabled:e,client:c,page:d,frame:h,subject:b}};const Y5=(t,e)=>{const n=sE(t);if(!e||t!==e)return n;const r=n.paddingBox.top-e.scrollTop,i=n.paddingBox.left-e.scrollLeft,c=r+e.scrollHeight,d=i+e.scrollWidth,h=Ig({top:r,right:d,bottom:c,left:i},n.border);return Lg({borderBox:h,margin:n.margin,border:n.border,padding:n.padding})};var Q5=({ref:t,descriptor:e,env:n,windowScroll:r,direction:i,isDropDisabled:c,isCombineEnabled:d,shouldClipSubject:f})=>{const h=n.closestScrollable,p=Y5(t,h),b=Ud(p,r),y=(()=>{if(!h)return null;const v=sE(h),N={scrollHeight:h.scrollHeight,scrollWidth:h.scrollWidth};return{client:v,page:Ud(v,r),scroll:Qp(h),scrollSize:N,shouldClipSubject:f}})();return $5({descriptor:e,isEnabled:!c,isCombineEnabled:d,isFixedOnPage:n.isFixedOnPage,direction:i,client:p,page:b,closest:y})};const W5={passive:!1},X5={passive:!0};var Hv=t=>t.shouldPublishImmediately?W5:X5;const fd=t=>t&&t.env.closestScrollable||null;function Z5(t){const e=w.useRef(null),n=qd(Su),r=Kg("droppable"),{registry:i,marshal:c}=n,d=FE(t),f=qe(()=>({id:t.droppableId,type:t.type,mode:t.mode}),[t.droppableId,t.mode,t.type]),h=w.useRef(f),p=qe(()=>kt((A,k)=>{e.current||fe();const _={x:A,y:k};c.updateDroppableScroll(f.id,_)}),[f.id,c]),b=ye(()=>{const A=e.current;return!A||!A.env.closestScrollable?Mt:Qp(A.env.closestScrollable)},[]),y=ye(()=>{const A=b();p(A.x,A.y)},[b,p]),m=qe(()=>ho(y),[y]),v=ye(()=>{const A=e.current,k=fd(A);if(A&&k||fe(),A.scrollOptions.shouldPublishImmediately){y();return}m()},[m,y]),N=ye((A,k)=>{e.current&&fe();const _=d.current,B=_.getDroppableRef();B||fe();const F=q5(B),G={ref:B,descriptor:f,env:F,scrollOptions:k};e.current=G;const ee=Q5({ref:B,descriptor:f,env:F,windowScroll:A,direction:_.direction,isDropDisabled:_.isDropDisabled,isCombineEnabled:_.isCombineEnabled,shouldClipSubject:!_.ignoreContainerClipping}),ne=F.closestScrollable;return ne&&(ne.setAttribute(Iv.contextId,n.contextId),ne.addEventListener("scroll",v,Hv(G.scrollOptions))),ee},[n.contextId,f,v,d]),S=ye(()=>{const A=e.current,k=fd(A);return A&&k||fe(),Qp(k)},[]),j=ye(()=>{const A=e.current;A||fe();const k=fd(A);e.current=null,k&&(m.cancel(),k.removeAttribute(Iv.contextId),k.removeEventListener("scroll",v,Hv(A.scrollOptions)))},[v,m]),R=ye(A=>{const k=e.current;k||fe();const _=fd(k);_||fe(),_.scrollTop+=A.y,_.scrollLeft+=A.x},[]),C=qe(()=>({getDimensionAndWatchScroll:N,getScrollWhileDragging:S,dragStopped:j,scroll:R}),[j,N,S,R]),O=qe(()=>({uniqueId:r,descriptor:f,callbacks:C}),[C,f,r]);An(()=>(h.current=O.descriptor,i.droppable.register(O),()=>{e.current&&j(),i.droppable.unregister(O)}),[C,f,j,O,c,i.droppable]),An(()=>{e.current&&c.updateDroppableIsEnabled(h.current.id,!t.isDropDisabled)},[t.isDropDisabled,c]),An(()=>{e.current&&c.updateDroppableIsCombineEnabled(h.current.id,t.isCombineEnabled)},[t.isCombineEnabled,c])}function mp(){}const Gv={width:0,height:0,margin:lT},K5=({isAnimatingOpenOnMount:t,placeholder:e,animate:n})=>t||n==="close"?Gv:{height:e.client.borderBox.height,width:e.client.borderBox.width,margin:e.client.margin},J5=({isAnimatingOpenOnMount:t,placeholder:e,animate:n})=>{const r=K5({isAnimatingOpenOnMount:t,placeholder:e,animate:n});return{display:e.display,boxSizing:"border-box",width:r.width,height:r.height,marginTop:r.margin.top,marginRight:r.margin.right,marginBottom:r.margin.bottom,marginLeft:r.margin.left,flexShrink:"0",flexGrow:"0",pointerEvents:"none",transition:n!=="none"?lo.placeholder:null}},eM=t=>{const e=w.useRef(null),n=ye(()=>{e.current&&(clearTimeout(e.current),e.current=null)},[]),{animate:r,onTransitionEnd:i,onClose:c,contextId:d}=t,[f,h]=w.useState(t.animate==="open");w.useEffect(()=>f?r!=="open"?(n(),h(!1),mp):e.current?mp:(e.current=setTimeout(()=>{e.current=null,h(!1)}),n):mp,[r,f,n]);const p=ye(y=>{y.propertyName==="height"&&(i(),r==="close"&&c())},[r,c,i]),b=J5({isAnimatingOpenOnMount:f,animate:t.animate,placeholder:t.placeholder});return Ve.createElement(t.placeholder.tagName,{style:b,"data-rfd-placeholder-context-id":d,onTransitionEnd:p,ref:t.innerRef})};var tM=Ve.memo(eM);class nM extends Ve.PureComponent{constructor(...e){super(...e),this.state={isVisible:!!this.props.on,data:this.props.on,animate:this.props.shouldAnimate&&this.props.on?"open":"none"},this.onClose=()=>{this.state.animate==="close"&&this.setState({isVisible:!1})}}static getDerivedStateFromProps(e,n){return e.shouldAnimate?e.on?{isVisible:!0,data:e.on,animate:"open"}:n.isVisible?{isVisible:!0,data:n.data,animate:"close"}:{isVisible:!1,animate:"close",data:null}:{isVisible:!!e.on,data:e.on,animate:"none"}}render(){if(!this.state.isVisible)return null;const e={onClose:this.onClose,data:this.state.data,animate:this.state.animate};return this.props.children(e)}}const aM=t=>{const e=w.useContext(Su);e||fe();const{contextId:n,isMovementAllowed:r}=e,i=w.useRef(null),c=w.useRef(null),{children:d,droppableId:f,type:h,mode:p,direction:b,ignoreContainerClipping:y,isDropDisabled:m,isCombineEnabled:v,snapshot:N,useClone:S,updateViewportMaxScroll:j,getContainerForClone:R}=t,C=ye(()=>i.current,[]),O=ye((ne=null)=>{i.current=ne},[]);ye(()=>c.current,[]);const A=ye((ne=null)=>{c.current=ne},[]),k=ye(()=>{r()&&j({maxScroll:zE()})},[r,j]);Z5({droppableId:f,type:h,mode:p,direction:b,isDropDisabled:m,isCombineEnabled:v,ignoreContainerClipping:y,getDroppableRef:C});const _=qe(()=>Ve.createElement(nM,{on:t.placeholder,shouldAnimate:t.shouldAnimatePlaceholder},({onClose:ne,data:oe,animate:Q})=>Ve.createElement(tM,{placeholder:oe,onClose:ne,innerRef:A,animate:Q,contextId:n,onTransitionEnd:k})),[n,k,t.placeholder,t.shouldAnimatePlaceholder,A]),B=qe(()=>({innerRef:O,placeholder:_,droppableProps:{"data-rfd-droppable-id":f,"data-rfd-droppable-context-id":n}}),[n,f,_,O]),F=S?S.dragging.draggableId:null,G=qe(()=>({droppableId:f,type:h,isUsingCloneFor:F}),[f,F,h]);function ee(){if(!S)return null;const{dragging:ne,render:oe}=S,Q=Ve.createElement(eS,{draggableId:ne.draggableId,index:ne.source.index,isClone:!0,isEnabled:!0,shouldRespectForcePress:!1,canDragInteractiveElements:!0},(ce,he)=>oe(ce,he,ne));return LO.createPortal(Q,R())}return Ve.createElement(em.Provider,{value:G},d(B,N),ee())};function sM(){return document.body||fe(),document.body}const Vv={mode:"standard",type:"DEFAULT",direction:"vertical",isDropDisabled:!1,isCombineEnabled:!1,ignoreContainerClipping:!1,renderClone:null,getContainerForClone:sM},sS=t=>{let e={...t},n;for(n in Vv)t[n]===void 0&&(e={...e,[n]:Vv[n]});return e},xp=(t,e)=>t===e.droppable.type,Fv=(t,e)=>e.draggables[t.draggable.id],rM=()=>{const t={placeholder:null,shouldAnimatePlaceholder:!0,snapshot:{isDraggingOver:!1,draggingOverWith:null,draggingFromThisWith:null,isUsingPlaceholder:!1},useClone:null},e={...t,shouldAnimatePlaceholder:!1},n=kt(c=>({draggableId:c.id,type:c.type,source:{index:c.index,droppableId:c.droppableId}})),r=kt((c,d,f,h,p,b)=>{const y=p.descriptor.id;if(p.descriptor.droppableId===c){const N=b?{render:b,dragging:n(p.descriptor)}:null,S={isDraggingOver:f,draggingOverWith:f?y:null,draggingFromThisWith:y,isUsingPlaceholder:!0};return{placeholder:p.placeholder,shouldAnimatePlaceholder:!1,snapshot:S,useClone:N}}if(!d)return e;if(!h)return t;const v={isDraggingOver:f,draggingOverWith:y,draggingFromThisWith:null,isUsingPlaceholder:!0};return{placeholder:p.placeholder,shouldAnimatePlaceholder:!0,snapshot:v,useClone:null}});return(c,d)=>{const f=sS(d),h=f.droppableId,p=f.type,b=!f.isDropDisabled,y=f.renderClone;if(yo(c)){const m=c.critical;if(!xp(p,m))return e;const v=Fv(m,c.dimensions),N=jn(c.impact)===h;return r(h,b,N,N,v,y)}if(c.phase==="DROP_ANIMATING"){const m=c.completed;if(!xp(p,m.critical))return e;const v=Fv(m.critical,c.dimensions);return r(h,b,KE(m.result)===h,jn(m.impact)===h,v,y)}if(c.phase==="IDLE"&&c.completed&&!c.shouldFlush){const m=c.completed;if(!xp(p,m.critical))return e;const v=jn(m.impact)===h,N=!!(m.impact.at&&m.impact.at.type==="COMBINE"),S=m.critical.droppable.id===h;return v?N?t:e:S?t:e}return e}},lM={updateViewportMaxScroll:bk},Kl=nE(rM,lM,(t,e,n)=>({...sS(n),...t,...e}),{context:Zg,areStatePropsEqual:ZE})(aM),iM=["VO","SL","IV","IM","SC","Tópico","Inalatória","Colírio","Nasal"],oM=["1x/dia","2x/dia","3x/dia","4x/dia","6/6h","8/8h","12/12h","24/24h","Dose única","Se necessário"],cM=["1 dia","2 dias","3 dias","5 dias","7 dias","10 dias","14 dias","21 dias","30 dias","Contínuo"],bp={medicamento:"",dose:"",via:"VO",frequencia:"8/8h",duracao:"7 dias",instrucoes:""},qv=({item:t,onChange:e,onSave:n,onCancel:r})=>{const i="w-full border border-gray-200 rounded-lg px-3 py-2 text-xs focus:ring-2 focus:ring-blue-100 focus:border-blue-300 outline-none bg-white",c=i+" appearance-none";return s.jsxs("div",{className:"bg-blue-50 border border-blue-100 rounded-xl p-3 space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-[9px] font-black text-gray-500 uppercase tracking-wider",children:"Medicamento"}),s.jsx("input",{autoFocus:!0,value:t.medicamento,onChange:d=>e({...t,medicamento:d.target.value.toUpperCase()}),placeholder:"EX: AMOXICILINA 500MG",className:i})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-[9px] font-black text-gray-500 uppercase tracking-wider",children:"Dose"}),s.jsx("input",{value:t.dose,onChange:d=>e({...t,dose:d.target.value}),placeholder:"EX: 500mg",className:i})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[9px] font-black text-gray-500 uppercase tracking-wider",children:"Via"}),s.jsx("select",{value:t.via,onChange:d=>e({...t,via:d.target.value}),className:c,children:iM.map(d=>s.jsx("option",{children:d},d))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-[9px] font-black text-gray-500 uppercase tracking-wider",children:"Frequência"}),s.jsx("select",{value:t.frequencia,onChange:d=>e({...t,frequencia:d.target.value}),className:c,children:oM.map(d=>s.jsx("option",{children:d},d))})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[9px] font-black text-gray-500 uppercase tracking-wider",children:"Duração"}),s.jsx("select",{value:t.duracao,onChange:d=>e({...t,duracao:d.target.value}),className:c,children:cM.map(d=>s.jsx("option",{children:d},d))})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[9px] font-black text-gray-500 uppercase tracking-wider",children:"Instruções extras (opcional)"}),s.jsx("input",{value:t.instrucoes||"",onChange:d=>e({...t,instrucoes:d.target.value}),placeholder:"EX: TOMAR APÓS AS REFEIÇÕES",className:i})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[s.jsx("button",{onClick:r,className:"px-3 py-1.5 bg-white border border-gray-200 text-gray-600 rounded-lg text-xs font-bold hover:bg-gray-50",children:"Cancelar"}),s.jsxs("button",{onClick:n,disabled:!t.medicamento.trim(),className:"px-3 py-1.5 bg-blue-600 text-white rounded-lg text-xs font-bold hover:bg-blue-700 disabled:opacity-40 flex items-center gap-1",children:[s.jsx(Io,{size:12})," Confirmar"]})]})]})},dM=({modelo:t,especialidades:e,onSave:n,onBack:r})=>{var oe;const i=Fe(),[c,d]=w.useState((t==null?void 0:t.nome)||""),[f,h]=w.useState((t==null?void 0:t.especialidadeId)||""),[p,b]=w.useState((t==null?void 0:t.instrucoes)||""),[y,m]=w.useState((t==null?void 0:t.items)||[]),[v,N]=w.useState(null),[S,j]=w.useState(bp),[R,C]=w.useState(!1),[O,A]=w.useState(!1),k=((oe=e.find(Q=>Q.id===f))==null?void 0:oe.nome)||"",_=Q=>{if(!Q.destination)return;const ce=[...y],[he]=ce.splice(Q.source.index,1);ce.splice(Q.destination.index,0,he),m(ce.map((H,V)=>({...H,ordem:V})))},B=()=>{S.medicamento.trim()&&(m(Q=>[...Q,{...S,id:`new_${Date.now()}`,ordem:Q.length}]),j(bp),C(!1))},F=(Q,ce)=>{m(he=>he.map((H,V)=>V===Q?{...H,...ce}:H))},G=Q=>m(ce=>ce.filter((he,H)=>H!==Q)),ee=async()=>{if(!c.trim()){i.error("NOME DO MODELO OBRIGATÓRIO");return}A(!0);try{const Q={nome:c.toUpperCase(),especialidadeId:f||void 0,especialidadeNome:k||void 0,instrucoes:p||void 0,items:y};if(t!=null&&t.id)await J.updateModeloReceita({...Q,id:t.id});else{const ce=await J.saveModeloReceita(Q);n({...Q,id:ce.id,items:y});return}n({...Q,id:t.id,items:y})}catch{i.error("ERRO AO SALVAR MODELO")}finally{A(!1)}},ne="w-full border border-gray-200 rounded-lg px-3 py-2.5 text-sm focus:ring-2 focus:ring-blue-100 focus:border-blue-300 outline-none bg-white";return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsxs("div",{className:"p-5 border-b border-gray-100 flex items-center gap-3",children:[s.jsx("button",{onClick:r,className:"text-gray-400 hover:text-gray-700 flex-shrink-0",children:s.jsx(Bs,{size:18})}),s.jsx("h3",{className:"text-sm font-black text-gray-800 uppercase",children:t?"Editar Modelo":"Novo Modelo"})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-5 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"Nome do Modelo *"}),s.jsx("input",{value:c,onChange:Q=>d(Q.target.value.toUpperCase()),className:ne,placeholder:"EX: ANTIBIÓTICO PÓS-CIRÚRGICO"})]}),s.jsx("div",{className:"grid grid-cols-2 gap-3",children:s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"Especialidade"}),s.jsxs("select",{value:f,onChange:Q=>h(Q.target.value),className:ne+" text-sm",children:[s.jsx("option",{value:"",children:"— Geral —"}),e.map(Q=>s.jsx("option",{value:Q.id,children:Q.nome},Q.id))]})]})}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"Instrução Geral (opcional)"}),s.jsx("input",{value:p,onChange:Q=>b(Q.target.value),className:ne,placeholder:"EX: USO EM CASO DE INFECÇÃO ODONTOGÊNICA"})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("label",{className:"text-[10px] font-black text-gray-500 uppercase tracking-wider",children:["Medicamentos (",y.length,")"]}),!R&&s.jsxs("button",{onClick:()=>C(!0),className:"flex items-center gap-1 text-xs font-bold text-blue-600 hover:text-blue-800",children:[s.jsx(ft,{size:13})," Adicionar"]})]}),R&&s.jsx("div",{className:"mb-2",children:s.jsx(qv,{item:S,onChange:j,onSave:B,onCancel:()=>{C(!1),j(bp)}})}),s.jsx(Xl,{onDragEnd:_,children:s.jsx(Kl,{droppableId:"items-receita",children:Q=>s.jsxs("div",{ref:Q.innerRef,...Q.droppableProps,className:"space-y-1.5",children:[y.map((ce,he)=>s.jsx(Zl,{draggableId:ce.id,index:he,children:(H,V)=>s.jsx("div",{ref:H.innerRef,...H.draggableProps,className:`rounded-xl border transition-shadow ${V.isDragging?"shadow-lg border-blue-300 bg-blue-50":"border-gray-200 bg-white"}`,children:v===he?s.jsx("div",{className:"p-2",children:s.jsx(qv,{item:{medicamento:ce.medicamento,dose:ce.dose,via:ce.via,frequencia:ce.frequencia,duracao:ce.duracao,instrucoes:ce.instrucoes},onChange:P=>F(he,P),onSave:()=>N(null),onCancel:()=>N(null)})}):s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[s.jsx("span",{...H.dragHandleProps,className:"text-gray-300 hover:text-gray-500 cursor-grab flex-shrink-0",children:s.jsx(ql,{size:15})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-xs font-bold text-gray-800 uppercase truncate",children:ce.medicamento}),s.jsx("p",{className:"text-[10px] text-gray-400",children:[ce.dose,ce.via,ce.frequencia,ce.duracao].filter(Boolean).join(" · ")}),ce.instrucoes&&s.jsx("p",{className:"text-[10px] text-blue-500 italic",children:ce.instrucoes})]}),s.jsx("button",{onClick:()=>N(he),className:"text-gray-300 hover:text-blue-500 flex-shrink-0",children:s.jsx(Mo,{size:13})}),s.jsx("button",{onClick:()=>G(he),className:"text-gray-300 hover:text-red-500 flex-shrink-0",children:s.jsx($t,{size:13})})]})})},ce.id)),Q.placeholder,y.length===0&&!R&&s.jsx("div",{className:"text-center py-6 text-xs text-gray-400 border-2 border-dashed border-gray-200 rounded-xl",children:"Nenhum medicamento adicionado ainda"})]})})})]})]}),s.jsxs("div",{className:"p-4 border-t border-gray-100 flex justify-end gap-2",children:[s.jsx("button",{onClick:r,className:"px-5 py-2 bg-gray-100 hover:bg-gray-200 text-gray-700 font-bold rounded-lg text-xs uppercase",children:"Cancelar"}),s.jsxs("button",{onClick:ee,disabled:O||!c.trim(),className:"px-5 py-2 bg-green-600 hover:bg-green-700 text-white font-bold rounded-lg text-xs uppercase flex items-center gap-1.5 disabled:opacity-40",children:[s.jsx(Io,{size:14})," ",O?"Salvando...":"Salvar Modelo"]})]})]})},uM=({modelo:t,paciente:e,dentista:n,onClose:r})=>{const i=new Date().toLocaleDateString("pt-BR",{day:"2-digit",month:"long",year:"numeric"});return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between print:hidden",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:r,className:"text-gray-400 hover:text-gray-700",children:s.jsx(Bs,{size:18})}),s.jsx("h3",{className:"text-sm font-black text-gray-800 uppercase",children:"Pré-visualização"})]}),s.jsxs("button",{onClick:()=>window.print(),className:"flex items-center gap-2 px-4 py-2 bg-gray-900 text-white rounded-lg text-xs font-bold hover:bg-black",children:[s.jsx(Va,{size:14})," Imprimir / Salvar PDF"]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-100 p-6 print:p-0 print:bg-white",children:s.jsxs("div",{id:"receita-print",className:"max-w-xl mx-auto bg-white rounded-2xl shadow-sm border border-gray-200 p-8 print:shadow-none print:rounded-none print:border-0 print:max-w-full",children:[s.jsxs("div",{className:"text-center border-b-2 border-gray-800 pb-4 mb-6",children:[s.jsx("h1",{className:"text-lg font-black text-gray-900 uppercase",children:"RECEITUÁRIO"}),n&&s.jsxs("p",{className:"text-sm font-bold text-gray-700 mt-1",children:[n.nome," — CRO: ",n.cro||"—","/",n.cro_uf||"—"]})]}),s.jsxs("div",{className:"mb-6 grid grid-cols-2 gap-3 text-sm",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500 text-xs uppercase font-bold",children:"Paciente"}),s.jsx("p",{className:"font-bold text-gray-900 uppercase",children:e.nome})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500 text-xs uppercase font-bold",children:"Data"}),s.jsx("p",{className:"font-bold text-gray-900",children:i})]})]}),t.instrucoes&&s.jsx("div",{className:"mb-5 p-3 bg-amber-50 border border-amber-200 rounded-lg text-xs text-amber-800 font-medium italic",children:t.instrucoes}),s.jsx("div",{className:"space-y-4",children:t.items.map((c,d)=>s.jsxs("div",{className:"border-b border-gray-100 pb-3 last:border-0 last:pb-0",children:[s.jsxs("p",{className:"font-black text-gray-900 text-sm",children:[d+1,". ",c.medicamento]}),s.jsx("p",{className:"text-gray-700 text-sm ml-4",children:[c.dose,c.via,c.frequencia,`por ${c.duracao}`].filter(Boolean).join(" — ")}),c.instrucoes&&s.jsx("p",{className:"text-gray-500 text-xs ml-4 italic mt-0.5",children:c.instrucoes})]},c.id))}),s.jsxs("div",{className:"mt-12 pt-6 border-t-2 border-gray-800 flex justify-between items-end",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-gray-500",children:"Assinatura e Carimbo"}),s.jsx("div",{className:"h-10"})]}),s.jsx("p",{className:"text-xs text-gray-400",children:i})]})]})})]})},fM=({paciente:t,onClose:e})=>{const n=Fe(),{data:r}=_e(J.getEspecialidades),i=r??[],{data:c}=_e(J.getDentistas),d=c??[],[f,h]=w.useState([]),[p,b]=w.useState(!0),[y,m]=w.useState(""),[v,N]=w.useState(""),[S,j]=w.useState("lista"),[R,C]=w.useState(null),[O,A]=w.useState(null),k=d[0],_=w.useCallback(async()=>{b(!0);try{h(await J.getModelosReceita())}catch{n.error("Erro ao carregar modelos")}finally{b(!1)}},[]);w.useEffect(()=>{_()},[_]),w.useEffect(()=>{const G=ee=>{ee.key==="Escape"&&(S!=="lista"?j("lista"):e())};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[S,e]);const B=async G=>{confirm("Excluir este modelo?")&&(await J.deleteModeloReceita(G),h(ee=>ee.filter(ne=>ne.id!==G)))},F=f.filter(G=>{const ee=!y||G.especialidadeId===y,ne=!v||G.nome.toLowerCase().includes(v.toLowerCase());return ee&&ne});return s.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center backdrop-blur-sm p-0",children:s.jsxs("div",{className:"bg-white shadow-2xl w-full h-dvh md:w-[96vw] md:h-[98vh] rounded-none md:rounded-2xl flex flex-col overflow-hidden animate-in fade-in zoom-in-95 duration-200",children:[S==="lista"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"p-5 border-b border-gray-100 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-8 h-8 bg-red-100 rounded-lg flex items-center justify-center",children:s.jsx(za,{size:15,className:"text-red-600"})}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-sm font-black text-gray-800 uppercase",children:"Modelos de Receita"}),s.jsx("p",{className:"text-[10px] text-gray-400 uppercase",children:t.nome})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:()=>{C(null),j("editor")},className:"flex items-center gap-1.5 px-3 py-2 bg-green-600 hover:bg-green-700 text-white text-xs font-bold rounded-lg",children:[s.jsx(ft,{size:13})," Novo Modelo"]}),s.jsx("button",{onClick:e,className:"text-gray-400 hover:text-gray-600",children:s.jsx(Qe,{size:18})})]})]}),s.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[s.jsxs("div",{className:"w-44 border-r border-gray-100 flex-shrink-0 overflow-y-auto bg-gray-50 p-2",children:[s.jsx("p",{className:"text-[9px] font-black text-gray-400 uppercase px-2 mb-2 tracking-wider",children:"Especialidade"}),s.jsx("button",{onClick:()=>m(""),className:`w-full text-left px-2.5 py-1.5 rounded-lg text-xs font-bold mb-0.5 transition-colors ${y?"text-gray-600 hover:bg-gray-100":"bg-blue-600 text-white"}`,children:"Todas"}),i.map(G=>s.jsx("button",{onClick:()=>m(G.id),className:`w-full text-left px-2.5 py-1.5 rounded-lg text-xs font-bold mb-0.5 transition-colors truncate ${y===G.id?"bg-blue-600 text-white":"text-gray-600 hover:bg-gray-100"}`,children:G.nome},G.id))]}),s.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[s.jsx("div",{className:"p-3 border-b border-gray-100",children:s.jsxs("div",{className:"relative",children:[s.jsx(ha,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-400"}),s.jsx("input",{value:v,onChange:G=>N(G.target.value),placeholder:"Buscar modelo...",className:"w-full pl-8 pr-3 py-2 border border-gray-200 rounded-lg text-xs focus:ring-2 focus:ring-blue-100 outline-none"})]})}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-3 space-y-2",children:[p&&s.jsx("div",{className:"text-center py-8 text-xs text-gray-400",children:"Carregando..."}),!p&&F.length===0&&s.jsxs("div",{className:"text-center py-10",children:[s.jsx(so,{size:28,className:"text-gray-200 mx-auto mb-2"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Nenhum modelo encontrado"}),s.jsx("button",{onClick:()=>{C(null),j("editor")},className:"mt-3 text-xs font-bold text-blue-600 hover:underline",children:"+ Criar primeiro modelo"})]}),F.map(G=>s.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl p-3 hover:border-blue-200 hover:shadow-sm transition-all group",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-xs font-black text-gray-800 uppercase truncate",children:G.nome}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[G.especialidadeNome&&s.jsx("span",{className:"text-[9px] bg-blue-50 text-blue-600 px-1.5 py-0.5 rounded-full font-bold uppercase",children:G.especialidadeNome}),s.jsxs("span",{className:"text-[9px] text-gray-400",children:[G.items.length," medicamento",G.items.length!==1?"s":""]})]}),G.instrucoes&&s.jsx("p",{className:"text-[10px] text-gray-400 italic mt-1 truncate",children:G.instrucoes})]}),s.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",children:[s.jsx("button",{onClick:()=>{A(G),j("print")},title:"Prescrever para este paciente",className:"p-1.5 text-gray-400 hover:text-green-600 hover:bg-green-50 rounded-lg",children:s.jsx(Va,{size:13})}),s.jsx("button",{onClick:()=>{C(G),j("editor")},className:"p-1.5 text-gray-400 hover:text-blue-600 hover:bg-blue-50 rounded-lg",children:s.jsx(Mo,{size:13})}),s.jsx("button",{onClick:()=>B(G.id),className:"p-1.5 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded-lg",children:s.jsx($t,{size:13})})]})]}),G.items.length>0&&s.jsxs("div",{className:"mt-2 pt-2 border-t border-gray-50 space-y-0.5",children:[G.items.slice(0,3).map(ee=>s.jsxs("p",{className:"text-[10px] text-gray-500 truncate",children:["• ",ee.medicamento," — ",ee.dose," ",ee.frequencia]},ee.id)),G.items.length>3&&s.jsxs("p",{className:"text-[10px] text-gray-400",children:["+",G.items.length-3," mais..."]})]})]},G.id))]})]})]})]}),S==="editor"&&s.jsx(dM,{modelo:R,especialidades:i,onSave:G=>{_(),j("lista"),n.success("MODELO SALVO!")},onBack:()=>j("lista")}),S==="print"&&O&&s.jsx(uM,{modelo:O,paciente:t,dentista:k,onClose:()=>j("lista")})]})})},$d=[{categoria:"RAIO-X",icon:s.jsx(xD,{size:14}),cor:"blue",items:[{nome:"Periapical"},{nome:"Interproximal (Bite-Wing)"},{nome:"Panorâmica"},{nome:"Oclusal Superior"},{nome:"Oclusal Inferior"},{nome:"Cefalométrica Lateral"},{nome:"P.A. de Face"}]},{categoria:"TOMOGRAFIA",icon:s.jsx(Vl,{size:14}),cor:"purple",items:[{nome:"Cone Beam — Dente Único",regiao:""},{nome:"Cone Beam — Terço Anterior"},{nome:"Cone Beam — Arcada Completa Superior"},{nome:"Cone Beam — Arcada Completa Inferior"},{nome:"Cone Beam — Ambas Arcadas"},{nome:"ATM (Articulação Temporomandibular)"}]},{categoria:"OUTROS",icon:s.jsx(MD,{size:14}),cor:"green",items:[{nome:"Cefalometria Analítica"},{nome:"Fotografia Clínica Extraoral"},{nome:"Fotografia Clínica Intraoral"},{nome:"Modelos de Gesso / Escaneamento"},{nome:"Biópsia"},{nome:"Exame Laboratorial"}]}],Wp={blue:{bg:"bg-blue-50",text:"text-blue-700",border:"border-blue-200",chip:"bg-blue-100 text-blue-700"},purple:{bg:"bg-purple-50",text:"text-purple-700",border:"border-purple-200",chip:"bg-purple-100 text-purple-700"},green:{bg:"bg-green-50",text:"text-green-700",border:"border-green-200",chip:"bg-green-100 text-green-700"}},hM=({pedido:t,dentista:e,onClose:n})=>{const r=new Date().toLocaleDateString("pt-BR",{day:"2-digit",month:"long",year:"numeric"}),i=$d.map(c=>({...c,selecionados:t.items.filter(d=>d.categoria===c.categoria)})).filter(c=>c.selecionados.length>0);return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between print:hidden",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:n,className:"text-gray-400 hover:text-gray-700",children:s.jsx(Bs,{size:18})}),s.jsx("h3",{className:"text-sm font-black text-gray-800 uppercase",children:"Pré-visualização"})]}),s.jsxs("button",{onClick:()=>window.print(),className:"flex items-center gap-2 px-4 py-2 bg-gray-900 text-white rounded-lg text-xs font-bold hover:bg-black",children:[s.jsx(Va,{size:14})," Imprimir / Salvar PDF"]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-100 p-6 print:p-0 print:bg-white",children:s.jsxs("div",{className:"max-w-xl mx-auto bg-white rounded-2xl shadow-sm border border-gray-200 p-8 print:shadow-none print:rounded-none print:border-0 print:max-w-full",children:[s.jsxs("div",{className:"text-center border-b-2 border-gray-800 pb-4 mb-6",children:[s.jsx("h1",{className:"text-lg font-black text-gray-900 uppercase",children:"PEDIDO DE EXAMES"}),e&&s.jsxs("p",{className:"text-sm font-bold text-gray-700 mt-1",children:[e.nome," — CRO: ",e.cro||"—","/",e.cro_uf||"—"]})]}),s.jsxs("div",{className:"mb-6 grid grid-cols-2 gap-3 text-sm",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500 text-xs uppercase font-bold",children:"Paciente"}),s.jsx("p",{className:"font-bold text-gray-900 uppercase",children:t.pacienteNome})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500 text-xs uppercase font-bold",children:"Data"}),s.jsx("p",{className:"font-bold text-gray-900",children:r})]})]}),s.jsx("div",{className:"space-y-5",children:i.map(c=>s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-black text-gray-500 uppercase tracking-widest mb-2 border-b border-gray-100 pb-1",children:c.categoria}),s.jsx("ul",{className:"space-y-1.5",children:c.selecionados.map((d,f)=>s.jsxs("li",{className:"flex items-start gap-2 text-sm text-gray-800",children:[s.jsxs("span",{className:"font-black text-gray-400 w-5 flex-shrink-0",children:[f+1,"."]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-bold",children:d.nome}),d.regiao&&s.jsxs("span",{className:"text-gray-500",children:[" — Região: ",d.regiao]}),d.observacao&&s.jsx("p",{className:"text-xs text-gray-500 italic mt-0.5",children:d.observacao})]})]},d.id))})]},c.categoria))}),t.observacoes&&s.jsxs("div",{className:"mt-5 p-3 bg-amber-50 border border-amber-200 rounded-lg text-xs text-amber-800 italic",children:[s.jsx("span",{className:"font-black not-italic uppercase",children:"Obs: "}),t.observacoes]}),s.jsxs("div",{className:"mt-12 pt-6 border-t-2 border-gray-800 flex justify-between items-end",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-gray-500",children:"Assinatura e Carimbo"}),s.jsx("div",{className:"h-10"})]}),s.jsx("p",{className:"text-xs text-gray-400",children:r})]})]})})]})},pM=({item:t,onChange:e,onRemove:n,dragHandle:r,isDragging:i})=>{const[c,d]=w.useState(!1),f=$d.find(p=>p.categoria===t.categoria),h=Wp[(f==null?void 0:f.cor)||"blue"];return s.jsxs("div",{className:`rounded-xl border transition-all ${i?"shadow-lg":""} ${h.border} bg-white`,children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[s.jsx("span",{className:"text-gray-300 hover:text-gray-500 cursor-grab flex-shrink-0",children:r}),s.jsx("span",{className:`text-[9px] font-black px-1.5 py-0.5 rounded-full flex-shrink-0 ${h.chip}`,children:t.categoria}),s.jsx("p",{className:"flex-1 text-xs font-bold text-gray-800 truncate",children:t.nome}),s.jsx("button",{onClick:()=>d(p=>!p),className:`text-[9px] font-bold px-2 py-0.5 rounded-full border flex-shrink-0 ${c?"bg-gray-100 text-gray-600 border-gray-200":"text-gray-400 border-gray-200 hover:bg-gray-50"}`,children:c?"fechar":"detalhe"}),s.jsx("button",{onClick:n,className:"text-gray-300 hover:text-red-500 flex-shrink-0",children:s.jsx($t,{size:13})})]}),c&&s.jsxs("div",{className:"px-3 pb-3 pt-0 grid grid-cols-2 gap-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-[9px] font-black text-gray-400 uppercase",children:"Região / Dente"}),s.jsx("input",{value:t.regiao||"",onChange:p=>e({regiao:p.target.value}),placeholder:"ex: dente 16, arcada inf.",className:"w-full border border-gray-200 rounded-lg px-2.5 py-1.5 text-xs focus:ring-2 focus:ring-blue-100 outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[9px] font-black text-gray-400 uppercase",children:"Observação"}),s.jsx("input",{value:t.observacao||"",onChange:p=>e({observacao:p.target.value}),placeholder:"ex: urgente, pós-cirúrgico",className:"w-full border border-gray-200 rounded-lg px-2.5 py-1.5 text-xs focus:ring-2 focus:ring-blue-100 outline-none"})]})]})]})},gM=({paciente:t,onClose:e})=>{const n=Fe(),{data:r}=_e(J.getDentistas),i=r??[],[c,d]=w.useState([]),[f,h]=w.useState(""),[p,b]=w.useState(""),[y,m]=w.useState(null),[v,N]=w.useState("editor"),[S,j]=w.useState(!1),R=i[0];w.useEffect(()=>{const G=ee=>{ee.key==="Escape"&&(v!=="editor"?N("editor"):e())};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[v,e]);const C=$d.map(G=>({...G,items:G.items.filter(ee=>!(y&&G.categoria!==y||p&&!ee.nome.toLowerCase().includes(p.toLowerCase())))})).filter(G=>G.items.length>0),O=(G,ee,ne)=>{if(c.some(oe=>oe.nome===ee&&oe.categoria===G)){n.error("EXAME JÁ ADICIONADO");return}d(oe=>[...oe,{id:`ex_${Date.now()}_${Math.random()}`,nome:ee,categoria:G,regiao:ne||"",observacao:"",ordem:oe.length}])},A=(G,ee)=>{d(ne=>ne.map(oe=>oe.id===G?{...oe,...ee}:oe))},k=G=>d(ee=>ee.filter(ne=>ne.id!==G)),_=G=>{if(!G.destination)return;const ee=[...c],[ne]=ee.splice(G.source.index,1);ee.splice(G.destination.index,0,ne),d(ee.map((oe,Q)=>({...oe,ordem:Q})))},B=async()=>{if(c.length===0){n.error("ADICIONE AO MENOS UM EXAME");return}j(!0);try{await J.savePedidoExame({pacienteId:t.id,pacienteNome:t.nome,profissionalId:R==null?void 0:R.id,profissionalNome:R==null?void 0:R.nome,data:new Date().toISOString().slice(0,10),observacoes:f||void 0,items:c}),N("print")}catch{n.error("ERRO AO SALVAR PEDIDO")}finally{j(!1)}},F={id:"preview",pacienteId:t.id,pacienteNome:t.nome,profissionalId:R==null?void 0:R.id,profissionalNome:R==null?void 0:R.nome,data:new Date().toISOString().slice(0,10),observacoes:f,items:c};return v==="print"?s.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center backdrop-blur-sm p-0",children:s.jsx("div",{className:"bg-white shadow-2xl w-full h-dvh md:w-[96vw] md:h-[98vh] rounded-none md:rounded-2xl flex flex-col overflow-hidden",children:s.jsx(hM,{pedido:F,dentista:R,onClose:()=>N("editor")})})}):s.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center backdrop-blur-sm p-0",children:s.jsxs("div",{className:"bg-white shadow-2xl w-full h-dvh md:w-[96vw] md:h-[98vh] rounded-none md:rounded-2xl flex flex-col overflow-hidden animate-in fade-in zoom-in-95 duration-200",children:[s.jsxs("div",{className:"p-5 border-b border-gray-100 flex items-center justify-between flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-8 h-8 bg-indigo-100 rounded-lg flex items-center justify-center",children:s.jsx(ev,{size:15,className:"text-indigo-600"})}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-sm font-black text-gray-800 uppercase",children:"Pedido de Exames"}),s.jsx("p",{className:"text-[10px] text-gray-400 uppercase",children:t.nome})]})]}),s.jsx("button",{onClick:e,className:"text-gray-400 hover:text-gray-600",children:s.jsx(Qe,{size:18})})]}),s.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[s.jsxs("div",{className:"w-80 flex-shrink-0 border-r border-gray-100 flex flex-col",children:[s.jsxs("div",{className:"p-3 border-b border-gray-100 space-y-2",children:[s.jsxs("div",{className:"relative",children:[s.jsx(ha,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-400"}),s.jsx("input",{value:p,onChange:G=>b(G.target.value),placeholder:"Buscar exame...",className:"w-full pl-8 pr-3 py-2 border border-gray-200 rounded-lg text-xs focus:ring-2 focus:ring-blue-100 outline-none"})]}),s.jsxs("div",{className:"flex gap-1 flex-wrap",children:[s.jsx("button",{onClick:()=>m(null),className:`text-[10px] font-bold px-2 py-0.5 rounded-full border transition-colors ${y?"text-gray-500 border-gray-200 hover:bg-gray-50":"bg-gray-800 text-white border-gray-800"}`,children:"Todos"}),$d.map(G=>{const ee=Wp[G.cor];return s.jsx("button",{onClick:()=>m(ne=>ne===G.categoria?null:G.categoria),className:`text-[10px] font-bold px-2 py-0.5 rounded-full border transition-colors ${y===G.categoria?ee.chip+" border-transparent":"text-gray-500 border-gray-200 hover:bg-gray-50"}`,children:G.categoria},G.categoria)})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-3 space-y-4",children:[C.map(G=>{const ee=Wp[G.cor];return s.jsxs("div",{children:[s.jsxs("div",{className:`flex items-center gap-1.5 mb-2 ${ee.text}`,children:[G.icon,s.jsx("span",{className:"text-[10px] font-black uppercase tracking-wider",children:G.categoria})]}),s.jsx("div",{className:"space-y-1",children:G.items.map(ne=>{const oe=c.some(Q=>Q.nome===ne.nome&&Q.categoria===G.categoria);return s.jsxs("button",{onClick:()=>O(G.categoria,ne.nome,ne.regiao),disabled:oe,className:`w-full text-left px-3 py-2 rounded-lg text-xs transition-all flex items-center justify-between group ${oe?`${ee.bg} ${ee.text} font-bold opacity-60 cursor-default`:`border border-gray-100 hover:${ee.bg} hover:${ee.border} hover:${ee.text} text-gray-600 font-medium`}`,children:[s.jsx("span",{children:ne.nome}),oe?s.jsx("span",{className:"text-[9px] font-black opacity-70",children:"✓"}):s.jsx(ft,{size:12,className:"opacity-0 group-hover:opacity-100 flex-shrink-0"})]},ne.nome)})})]},G.categoria)}),C.length===0&&s.jsx("p",{className:"text-xs text-gray-400 text-center py-6",children:"Nenhum exame encontrado"})]})]}),s.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[s.jsxs("div",{className:"p-3 border-b border-gray-100 flex items-center justify-between",children:[s.jsxs("p",{className:"text-[10px] font-black text-gray-500 uppercase tracking-wider",children:["Exames Selecionados ",c.length>0&&s.jsxs("span",{className:"text-blue-600 ml-1",children:["(",c.length,")"]})]}),c.length>0&&s.jsx("button",{onClick:()=>d([]),className:"text-[10px] text-red-500 hover:text-red-700 font-bold",children:"Limpar tudo"})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-3",children:c.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center",children:[s.jsx("div",{className:"w-16 h-16 bg-gray-100 rounded-2xl flex items-center justify-center mb-3",children:s.jsx(ev,{size:24,className:"text-gray-300"})}),s.jsx("p",{className:"text-sm font-bold text-gray-400",children:"Nenhum exame selecionado"}),s.jsx("p",{className:"text-xs text-gray-300 mt-1",children:"Clique nos exames ao lado para adicionar"})]}):s.jsx(Xl,{onDragEnd:_,children:s.jsx(Kl,{droppableId:"exames-selecionados",children:G=>s.jsxs("div",{ref:G.innerRef,...G.droppableProps,className:"space-y-2",children:[c.map((ee,ne)=>s.jsx(Zl,{draggableId:ee.id,index:ne,children:(oe,Q)=>s.jsx("div",{ref:oe.innerRef,...oe.draggableProps,children:s.jsx(pM,{item:ee,isDragging:Q.isDragging,dragHandle:s.jsx("span",{...oe.dragHandleProps,children:s.jsx(ql,{size:15})}),onChange:ce=>A(ee.id,ce),onRemove:()=>k(ee.id)})})},ee.id)),G.placeholder]})})})}),s.jsxs("div",{className:"p-3 border-t border-gray-100 space-y-3 flex-shrink-0",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[9px] font-black text-gray-400 uppercase tracking-wider mb-1",children:"Observações (opcional)"}),s.jsx("input",{value:f,onChange:G=>h(G.target.value),placeholder:"ex: urgente, pós-cirúrgico, encaminhar para...",className:"w-full border border-gray-200 rounded-lg px-3 py-2 text-xs focus:ring-2 focus:ring-blue-100 outline-none"})]}),s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsx("button",{onClick:e,className:"px-4 py-2 bg-gray-100 hover:bg-gray-200 text-gray-700 font-bold rounded-lg text-xs uppercase",children:"Cancelar"}),s.jsxs("button",{onClick:B,disabled:c.length===0||S,className:"flex items-center gap-2 px-5 py-2 bg-indigo-600 hover:bg-indigo-700 text-white font-bold rounded-lg text-xs uppercase disabled:opacity-40",children:[s.jsx(Va,{size:14})," ",S?"Salvando...":"Gerar Pedido"]})]})]})]})]})]})})},$v=t=>{let e;const n=new Set,r=(p,b)=>{const y=typeof p=="function"?p(e):p;if(!Object.is(y,e)){const m=e;e=b??(typeof y!="object"||y===null)?y:Object.assign({},e,y),n.forEach(v=>v(e,m))}},i=()=>e,f={setState:r,getState:i,getInitialState:()=>h,subscribe:p=>(n.add(p),()=>n.delete(p))},h=e=t(r,i,f);return f},mM=(t=>t?$v(t):$v),xM=t=>t;function bM(t,e=xM){const n=Ve.useSyncExternalStore(t.subscribe,Ve.useCallback(()=>e(t.getState()),[t,e]),Ve.useCallback(()=>e(t.getInitialState()),[t,e]));return Ve.useDebugValue(n),n}const Yv=t=>{const e=mM(t),n=r=>bM(e,r);return Object.assign(n,e),n},yM=(t=>t?Yv(t):Yv),rS=yM(t=>({paciente:null,dentista:null,credenciada:"CASSEMS - SEDE CENTRAL",items:[],setPaciente:e=>t({paciente:e}),setDentista:e=>t({dentista:e}),setCredenciada:e=>t({credenciada:e}),addItem:e=>t(n=>({items:[...n.items,e].slice(0,20)})),removeItem:e=>t(n=>({items:n.items.filter(r=>r.id!==e)})),clear:()=>t({paciente:null,dentista:null,items:[]})})),xs={q1:[14,13,12,11,18,17,16,15],q2:[21,22,23,24,25,26,27,28],q4:[44,43,42,41,48,47,46,45],q3:[31,32,33,34,35,36,37,38],extras:{q1:19,q2:29,q4:49,q3:39}},hd={q1:[null,53,52,51,null,null,55,54],q2:[61,62,63,null,64,65,null,null],q4:[null,43,42,41,null,null,46,45],q3:[71,72,73,null,74,75,null,null]},vM=()=>{var he,H;const t=rS(),e=Fe(),[n,r]=w.useState([]),[i,c]=w.useState([]),[d,f]=w.useState([]),[h,p]=w.useState([]),[b,y]=w.useState(""),[m,v]=w.useState(null),[N,S]=w.useState("ADULTO"),[j,R]=w.useState([]),[C,O]=w.useState(null),[A,k]=w.useState(""),[_,B]=w.useState("");w.useEffect(()=>{(async()=>{const P=await J.getPacientes(),W=await J.getDentistas(),te=await J.getEspecialidades(),T=await J.getProcedimentos();r(P),c(W),f(te),p(T)})()},[]);const F=w.useMemo(()=>b?h.filter(V=>V.especialidadeId===b):[],[b,h]),G=V=>{if((m==null?void 0:m.tipo_regiao)!=="DENTE"){e.error("ESTE PROCEDIMENTO NÃO PERMITE SELEÇÃO DE DENTE INDIVIDUAL.");return}O(null),R(P=>P.includes(V)?P.filter(W=>W!==V):[...P,V])},ee=V=>{if((m==null?void 0:m.tipo_regiao)!=="ARCO"){e.error("ESTE PROCEDIMENTO NÃO PERMITE SELEÇÃO DE ARCO.");return}R([]),O(V)},ne=()=>{if(!m){e.error("SELECIONE UM PROCEDIMENTO PRIMEIRO.");return}if(m.tipo_regiao==="DENTE"&&j.length===0){e.error("ESTE PROCEDIMENTO EXIGE A SELEÇÃO DE AO MENOS UM DENTE.");return}if(m.tipo_regiao==="ARCO"&&!C){e.error("ESTE PROCEDIMENTO EXIGE A SELEÇÃO DE UM ARCO (AI/AS).");return}if(m.exige_face&&(!A||A.trim()==="")){e.error("A FACE É OBRIGATÓRIA PARA ESTE PROCEDIMENTO.");return}const V={id:Math.random().toString(36).substring(7),procedimentoId:m.id,codigoTUSS:m.codigo||"000000",codigoInterno:m.codigoInterno||"",descricao:m.nome,dente:j.join(", "),arco:C||void 0,face:A,quantidade:1,valorUnitario:m.valorParticular||0,valorTotal:m.valorParticular||0,observacao:_};t.addItem(V),e.success("ADICIONADO AO RASCUNHO."),R([]),O(null),k(""),B("")},oe=async()=>{if(!t.paciente||!t.dentista||t.items.length===0){e.error("PACIENTE, DENTISTA E PELO MENOS 1 ITEM SÃO OBRIGATÓRIOS.");return}try{e.success("GTO GERADA COM SUCESSO!"),t.clear(),y(""),v(null)}catch{e.error("ERRO AO GERAR GTO.")}},Q=t.items.reduce((V,P)=>V+P.valorTotal,0),ce=(V,P)=>{if(V===null)return s.jsx("div",{className:"w-9 h-9"},`empty-${P}`);const W=V.toString(),te=j.includes(W),T=!!m&&m.tipo_regiao!=="DENTE";return s.jsx("button",{onClick:()=>G(W),disabled:T,className:`w-9 h-9 rounded-lg border-2 text-[11px] font-black transition-all shadow-sm flex items-center justify-center ${te?"bg-blue-600 border-blue-700 text-white scale-110 z-10":T?"bg-gray-50 border-gray-100 text-gray-300 cursor-not-allowed opacity-50":"bg-white border-gray-200 text-gray-700 hover:border-blue-400 hover:bg-blue-50"} `,children:W},W)};return s.jsxs("div",{className:"space-y-6",children:[s.jsx(cn,{title:"LANÇAR GTO",description:"MONTGEM DINÂMICA DE GUIA ODONTOLÓGICA (GTO)."}),s.jsxs("div",{className:"grid grid-cols-12 gap-6 items-start",children:[s.jsxs("div",{className:"col-span-12 lg:col-span-8 space-y-6",children:[s.jsxs("div",{className:"bg-white rounded-3xl border border-gray-100 shadow-xl p-8 space-y-6",children:[s.jsx("div",{className:"flex justify-center mb-4",children:s.jsxs("div",{className:"inline-flex bg-gray-100 p-1 rounded-xl shadow-inner",children:[s.jsx("button",{onClick:()=>{S("ADULTO"),R([])},className:`px-8 py-2 rounded-lg text-xs font-black transition-all uppercase ${N==="ADULTO"?"bg-blue-600 text-white shadow-md scale-105":"text-gray-500 hover:text-gray-800"}`,children:"Adulto"}),s.jsx("button",{onClick:()=>{S("CRIANCA"),R([])},className:`px-8 py-2 rounded-lg text-xs font-black transition-all uppercase ${N==="CRIANCA"?"bg-blue-600 text-white shadow-md scale-105":"text-gray-500 hover:text-gray-800"}`,children:"Criança"})]})}),s.jsxs("div",{className:"relative border-t border-b border-gray-50 py-10",children:[s.jsx("div",{className:"absolute left-1/2 top-4 bottom-4 w-[2px] bg-gray-200 -translate-x-1/2"}),s.jsx("div",{className:"absolute top-1/2 left-4 right-4 h-[2px] bg-gray-200 -translate-y-1/2"}),s.jsxs("div",{className:"grid grid-cols-2 gap-x-12 gap-y-16",children:[s.jsxs("div",{className:"flex justify-end items-center gap-2 pr-2",children:[N==="ADULTO"&&ce(xs.extras.q1),s.jsx("div",{className:"grid grid-cols-4 gap-2",children:(N==="ADULTO"?xs.q1:hd.q1).map((V,P)=>ce(V,P))})]}),s.jsxs("div",{className:"flex justify-start items-center gap-2 pl-2",children:[s.jsx("div",{className:"grid grid-cols-4 gap-2",children:(N==="ADULTO"?xs.q2:hd.q2).map((V,P)=>ce(V,P))}),N==="ADULTO"&&ce(xs.extras.q2)]}),s.jsxs("div",{className:"flex justify-end items-center gap-2 pr-2",children:[N==="ADULTO"&&ce(xs.extras.q4),s.jsx("div",{className:"grid grid-cols-4 gap-2",children:(N==="ADULTO"?xs.q4:hd.q4).map((V,P)=>ce(V,P))})]}),s.jsxs("div",{className:"flex justify-start items-center gap-2 pl-2",children:[s.jsx("div",{className:"grid grid-cols-4 gap-2",children:(N==="ADULTO"?xs.q3:hd.q3).map((V,P)=>ce(V,P))}),N==="ADULTO"&&ce(xs.extras.q3)]})]})]}),s.jsxs("div",{className:"flex justify-center gap-4 pt-4",children:[s.jsx("button",{onClick:()=>ee("AI"),disabled:!!m&&m.tipo_regiao!=="ARCO",className:`px-10 py-3 rounded-2xl border-2 font-black text-sm uppercase transition-all shadow-sm ${C==="AI"?"bg-amber-500 border-amber-600 text-white":m&&m.tipo_regiao!=="ARCO"?"bg-gray-50 border-gray-100 text-gray-300 cursor-not-allowed opacity-50":"bg-white border-gray-100 text-gray-500 hover:border-amber-400"}`,children:"AI - Inferior"}),s.jsx("button",{onClick:()=>ee("AS"),disabled:!!m&&m.tipo_regiao!=="ARCO",className:`px-10 py-3 rounded-2xl border-2 font-black text-sm uppercase transition-all shadow-sm ${C==="AS"?"bg-amber-500 border-amber-600 text-white":m&&m.tipo_regiao!=="ARCO"?"bg-gray-50 border-gray-100 text-gray-300 cursor-not-allowed opacity-50":"bg-white border-gray-100 text-gray-500 hover:border-amber-400"}`,children:"AS - Superior"})]})]}),s.jsxs("div",{className:"bg-white rounded-3xl border border-gray-100 overflow-hidden shadow-xl",children:[s.jsxs("div",{className:"bg-[#d49a4a] p-4 text-white font-black text-sm uppercase flex justify-between items-center tracking-widest",children:[s.jsx("span",{children:"PROCEDIMENTOS DO RASCUNHO"}),s.jsxs("div",{className:"bg-white/20 px-3 py-1 rounded-full text-[10px]",children:[t.items.length,"/20 ITENS"]})]}),s.jsxs("div",{className:"p-6 space-y-4",children:[t.items.length===0&&s.jsxs("div",{className:"py-16 text-center text-gray-300 font-bold uppercase flex flex-col items-center gap-4",children:[s.jsx("div",{className:"w-16 h-16 bg-gray-50 rounded-full flex items-center justify-center outline outline-gray-100 outline-offset-4",children:s.jsx(gu,{size:32})}),"NÃO HÁ ITENS ADICIONADOS"]}),t.items.map(V=>{var P;return s.jsxs("div",{className:"border border-gray-100 rounded-2xl p-5 bg-gray-50/30 hover:bg-white transition-all shadow-sm group",children:[s.jsxs("div",{className:"flex justify-between items-start mb-4",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("span",{className:"bg-blue-600 text-white text-[10px] font-black px-2 py-1 rounded-md uppercase shadow-sm",children:["COD ",V.codigoTUSS]}),s.jsx("h4",{className:"font-black text-gray-900 text-sm uppercase tracking-tight",children:V.descricao})]}),s.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-gray-400 font-bold uppercase",children:[s.jsx($n,{size:12})," ",(P=t.paciente)==null?void 0:P.nome]})]}),s.jsx("button",{onClick:()=>t.removeItem(V.id),className:"text-gray-300 hover:text-red-600 p-2 transition-colors",children:s.jsx($t,{size:20})})]}),s.jsxs("div",{className:"grid grid-cols-4 gap-6 text-[11px] font-black text-gray-500 uppercase tracking-wider mb-4 border-t border-gray-100 pt-4",children:[s.jsxs("div",{children:["DENTE: ",s.jsx("span",{className:"text-blue-600 ml-1",children:V.dente||"--"})]}),s.jsxs("div",{children:["ARCO: ",s.jsx("span",{className:"text-amber-600 ml-1",children:V.arco||"--"})]}),s.jsxs("div",{children:["FACE: ",s.jsx("span",{className:"text-gray-900 ml-1",children:V.face||"--"})]}),s.jsxs("div",{children:["VALOR: ",s.jsxs("span",{className:"text-green-600 ml-1 text-xs",children:["R$ ",V.valorTotal.toFixed(2)]})]})]}),V.observacao&&s.jsxs("div",{className:"text-[11px] text-gray-500 bg-white p-3 border border-gray-100 rounded-xl leading-relaxed",children:[s.jsx("span",{className:"font-black text-gray-400 uppercase mr-2 opacity-50",children:"OBS:"})," ",V.observacao]})]},V.id)}),s.jsxs("div",{className:"pt-6 border-t-2 border-dotted border-gray-200 flex justify-between items-center",children:[s.jsxs("button",{className:"flex items-center gap-2 text-blue-600 font-black text-[11px] uppercase hover:bg-blue-50 px-4 py-2 rounded-xl transition-all",children:[s.jsx(Ad,{size:16})," ANEXAR DOCUMENTOS"]}),s.jsxs("div",{className:"text-right",children:[s.jsx("p",{className:"text-[10px] font-black text-gray-400 uppercase tracking-[0.2em] mb-1",children:"TOTAL ACUMULADO"}),s.jsxs("h3",{className:"text-3xl font-black text-gray-900 p-2 bg-gray-50 rounded-2xl border border-gray-100 shadow-inner",children:["R$ ",Q.toFixed(2)]})]})]})]})]})]}),s.jsxs("div",{className:"col-span-12 lg:col-span-4 space-y-4 sticky top-6",children:[s.jsxs("div",{className:"bg-white p-6 rounded-3xl border border-gray-100 shadow-xl space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-3 text-blue-600 font-black text-base uppercase tracking-wider",children:[s.jsx($n,{size:20,strokeWidth:3})," 01. Paciente"]}),s.jsxs("select",{value:((he=t.paciente)==null?void 0:he.id)||"",onChange:V=>{const P=n.find(W=>W.id===V.target.value);t.setPaciente(P||null)},className:"w-full p-4 bg-gray-50 border-2 border-gray-100 rounded-2xl font-black text-gray-800 text-sm focus:border-blue-500 outline-none transition-all uppercase",children:[s.jsx("option",{value:"",children:"SELECIONE O BENEFICIÁRIO"}),n.map(V=>s.jsx("option",{value:V.id,children:V.nome},V.id))]})]}),s.jsxs("div",{className:"bg-white p-6 rounded-3xl border border-gray-100 shadow-xl space-y-5",children:[s.jsxs("div",{className:"flex items-center gap-3 text-orange-500 font-black text-base uppercase tracking-wider",children:[s.jsx(ua,{size:20,strokeWidth:3})," 02. Especialidade"]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("select",{value:b,onChange:V=>{y(V.target.value),v(null)},className:"w-full p-4 bg-gray-50 border-2 border-gray-100 rounded-2xl font-black text-gray-700 text-sm focus:border-orange-400 outline-none transition-all uppercase",children:[s.jsx("option",{value:"",children:"ESCOLHA A ÁREA..."}),d.map(V=>s.jsx("option",{value:V.id,children:V.nome},V.id))]}),b&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("select",{value:(m==null?void 0:m.id)||"",onChange:V=>{const P=h.find(W=>W.id===V.target.value);v(P||null),R([]),O(null)},className:"w-full p-4 bg-white border-2 border-orange-100 rounded-2xl font-black text-gray-800 text-sm shadow-inner uppercase",children:[s.jsx("option",{value:"",children:"BUSCAR PROCEDIMENTO"}),F.map(V=>s.jsx("option",{value:V.id,children:V.nome},V.id))]}),m&&s.jsxs("div",{className:"bg-orange-50 p-3 rounded-xl border border-orange-100 animate-in fade-in slide-in-from-top-1 duration-300",children:[s.jsx("p",{className:"text-[9px] font-black text-orange-600 uppercase mb-1",children:"REGRAS DE SELEÇÃO"}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsxs("span",{className:"text-[10px] font-bold text-orange-800 flex items-center gap-1",children:[s.jsx(Ts,{size:10}),m.tipo_regiao==="DENTE"?"EXIGE DENTE(S)":m.tipo_regiao==="ARCO"?"EXIGE ARCO (AI/AS)":"PROCEDIMENTO GERAL"]}),m.exige_face&&s.jsxs("span",{className:"text-[10px] font-bold text-red-600 flex items-center gap-1",children:[s.jsx(Ts,{size:10})," EXIGE FACE CLINICA"]})]})]})]})]})]}),s.jsxs("div",{className:"bg-white p-6 rounded-3xl border border-gray-100 shadow-xl space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-3 text-[#2d6a4f] font-black text-base uppercase tracking-wider",children:[s.jsx(fo,{size:20,strokeWidth:3,className:"bg-green-100 p-1 rounded-full text-green-700"})," 03. Dentista Executor"]}),s.jsxs("select",{value:((H=t.dentista)==null?void 0:H.id)||"",onChange:V=>{const P=i.find(W=>W.id===V.target.value);t.setDentista(P||null)},className:"w-full p-4 bg-gray-50 border-2 border-gray-100 rounded-2xl font-black text-gray-800 text-sm focus:border-green-500 outline-none transition-all uppercase",children:[s.jsx("option",{value:"",children:"SELECIONE O PROFISSIONAL"}),i.map(V=>s.jsx("option",{value:V.id,children:V.nome},V.id))]})]}),s.jsx("div",{className:"bg-white p-6 rounded-3xl border border-gray-100 shadow-xl space-y-4",children:s.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-[10px] font-black text-gray-400 uppercase tracking-widest mb-2 flex justify-between",children:[s.jsx("span",{children:"Face (O, M, D, V, L, P)"}),(m==null?void 0:m.exige_face)&&s.jsx("span",{className:"text-red-500 font-black animate-pulse",children:"* OBRIGATÓRIO"})]}),s.jsx("input",{type:"text",value:A,onChange:V=>k(V.target.value.toUpperCase()),disabled:(m==null?void 0:m.tipo_regiao)==="GERAL"&&!(m!=null&&m.exige_face),className:`w-full p-4 border-2 rounded-2xl text-sm font-black outline-none transition-all ${m!=null&&m.exige_face?"bg-red-50 border-red-100 focus:border-red-400":"bg-gray-50 border-gray-100 focus:border-amber-400"} `,placeholder:m!=null&&m.exige_face?"DIGITE AS FACES...":"OPCIONAL"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-400 uppercase tracking-widest mb-2 italic",children:"Observações Clínicas"}),s.jsxs("div",{className:"relative",children:[s.jsx("textarea",{value:_,onChange:V=>B(V.target.value),className:"w-full p-4 bg-gray-50 border-2 border-gray-100 rounded-2xl text-[11px] h-20 focus:border-amber-400 outline-none transition-all"}),s.jsx(zN,{size:24,className:"absolute bottom-4 right-4 text-green-500 opacity-50"})]})]})]})}),s.jsxs("div",{className:"grid grid-cols-4 gap-4 p-2",children:[s.jsxs("button",{onClick:ne,className:"col-span-3 bg-[#2d6a4f] text-white py-5 rounded-3xl font-black text-lg uppercase shadow-2xl shadow-green-200 hover:bg-[#1b4332] active:scale-95 transition-all flex items-center justify-center gap-3 group",children:["ADICIONAR ITEM ",s.jsx(Ts,{className:"group-hover:translate-x-1 transition-transform"})]}),s.jsx("button",{onClick:oe,className:"col-span-1 bg-gray-900 text-white py-5 rounded-3xl flex items-center justify-center shadow-xl hover:bg-black active:scale-95 transition-all",title:"FINALIZAR GTO",children:s.jsx(fo,{size:32,strokeWidth:4})})]})]})]})]})},NM=["V","L","M","D","O"],EM=["Superior","Inferior","Ambas"],SM=["Pix","Cartão","Dinheiro","Boleto"],jM=["Pendente","Pago","Atrasado"],Zn=t=>t.toLocaleString("pt-BR",{style:"currency",currency:"BRL"});function Qv(t,e){const n=new Date(t+"T12:00:00");return n.setMonth(n.getMonth()+e),n.toISOString().slice(0,10)}const AM=({item:t,onChange:e,onRemove:n})=>{const[r,i]=w.useState(t.proc.tipo_regiao!=="GERAL"),c="border border-gray-200 rounded-lg px-2 py-1.5 text-xs focus:ring-2 focus:ring-blue-100 outline-none w-full";return s.jsxs("div",{className:"border border-gray-200 rounded-xl bg-white overflow-hidden",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-xs font-black text-gray-800 uppercase truncate",children:t.proc.nome}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.proc.especialidadeNome&&s.jsx("span",{className:"text-[9px] bg-blue-50 text-blue-600 px-1.5 py-0.5 rounded-full font-bold uppercase",children:t.proc.especialidadeNome}),s.jsx("span",{className:"text-[10px] font-bold text-green-600",children:Zn(t.valorUnit*t.quantidade)}),t.quantidade>1&&s.jsxs("span",{className:"text-[9px] text-gray-400",children:[t.quantidade,"× ",Zn(t.valorUnit)]})]})]}),s.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[s.jsx("button",{onClick:()=>e({quantidade:Math.max(1,t.quantidade-1)}),className:"w-6 h-6 rounded-full border border-gray-200 flex items-center justify-center hover:bg-gray-100",children:s.jsx(FN,{size:10})}),s.jsx("span",{className:"w-5 text-center text-xs font-bold",children:t.quantidade}),s.jsx("button",{onClick:()=>e({quantidade:t.quantidade+1}),className:"w-6 h-6 rounded-full border border-gray-200 flex items-center justify-center hover:bg-gray-100",children:s.jsx(ft,{size:10})})]}),s.jsx("button",{onClick:()=>i(d=>!d),className:"text-gray-300 hover:text-gray-600 flex-shrink-0",children:s.jsx(_o,{size:14,className:`transition-transform ${r?"rotate-180":""}`})}),s.jsx("button",{onClick:n,className:"text-gray-300 hover:text-red-500 flex-shrink-0",children:s.jsx($t,{size:13})})]}),r&&s.jsxs("div",{className:"border-t border-gray-100 bg-gray-50/50 px-3 py-2.5 grid grid-cols-2 gap-2",children:[t.proc.tipo_regiao==="DENTE"&&s.jsxs("div",{children:[s.jsx("label",{className:"text-[9px] font-black text-gray-400 uppercase block mb-1",children:"Dente(s)"}),s.jsx("input",{value:t.dente,onChange:d=>e({dente:d.target.value}),className:c,placeholder:"ex: 16, 21-22"})]}),t.proc.tipo_regiao==="ARCO"&&s.jsxs("div",{children:[s.jsx("label",{className:"text-[9px] font-black text-gray-400 uppercase block mb-1",children:"Arcada"}),s.jsxs("select",{value:t.arco,onChange:d=>e({arco:d.target.value}),className:c,children:[s.jsx("option",{value:"",children:"— Selecione —"}),EM.map(d=>s.jsx("option",{children:d},d))]})]}),t.proc.exige_face&&s.jsxs("div",{children:[s.jsx("label",{className:"text-[9px] font-black text-gray-400 uppercase block mb-1",children:"Face(s)"}),s.jsx("div",{className:"flex gap-1 flex-wrap",children:NM.map(d=>s.jsx("button",{type:"button",onClick:()=>{const f=t.face.split("").filter(Boolean),h=f.includes(d)?f.filter(p=>p!==d):[...f,d];e({face:h.join("")})},className:`w-7 h-7 rounded-lg text-[10px] font-black border transition-colors ${t.face.includes(d)?"bg-blue-600 text-white border-blue-600":"bg-white text-gray-500 border-gray-200 hover:border-blue-400"}`,children:d},d))})]}),s.jsxs("div",{className:t.proc.tipo_regiao!=="GERAL"||t.proc.exige_face?"":"col-span-2",children:[s.jsx("label",{className:"text-[9px] font-black text-gray-400 uppercase block mb-1",children:"Obs"}),s.jsx("input",{value:t.observacao,onChange:d=>e({observacao:d.target.value}),className:c,placeholder:"observação opcional"})]})]})]})},wM=({patient:t,onClose:e,onSaved:n})=>{const r=Fe(),{data:i}=_e(J.getProcedimentos),{data:c}=_e(J.getEspecialidades),{data:d}=_e(J.getPlanos),f=i??[],h=c??[],p=d??[],[b,y]=w.useState(""),[m,v]=w.useState(""),[N,S]=w.useState([]),[j,R]=w.useState(!1),[C,O]=w.useState("R$"),[A,k]=w.useState(""),[_,B]=w.useState(""),[F,G]=w.useState(1),[ee,ne]=w.useState(new Date().toISOString().slice(0,10)),[oe,Q]=w.useState("Pix"),[ce,he]=w.useState("Pendente"),H=w.useMemo(()=>t.convenio?p.find(ue=>ue.nome===t.convenio)??null:null,[t.convenio,p]),V=ue=>{var Oe;if(H){const Ce=(Oe=ue.valoresPlanos)==null?void 0:Oe.find(yt=>yt.planoId===H.id);if(Ce)return Ce.valor}return ue.valorParticular??0},P=ue=>{if(N.some(Oe=>Oe.proc.id===ue.id)){S(Oe=>Oe.map(Ce=>Ce.proc.id===ue.id?{...Ce,quantidade:Ce.quantidade+1}:Ce));return}S(Oe=>[...Oe,{uid:`${ue.id}_${Date.now()}`,proc:ue,quantidade:1,dente:"",face:"",arco:"",observacao:"",valorUnit:V(ue)}])},W=(ue,Oe)=>S(Ce=>Ce.map(yt=>yt.uid===ue?{...yt,...Oe}:yt)),te=ue=>S(Oe=>Oe.filter(Ce=>Ce.uid!==ue)),T=N.reduce((ue,Oe)=>ue+Oe.valorUnit*Oe.quantidade,0),X=parseFloat(A)||0,ie=C==="%"?T*X/100:X,de=parseFloat(_)||0,ve=Math.max(0,T-ie-de),je=F>0?ve/F:0,Te=w.useMemo(()=>f.filter(ue=>!(m&&ue.especialidadeId!==m||b&&!ue.nome.toLowerCase().includes(b.toLowerCase()))),[f,m,b]),bt=w.useMemo(()=>{const ue={};return Te.forEach(Oe=>{const Ce=Oe.especialidadeId||"__geral";ue[Ce]||(ue[Ce]={esp:h.find(yt=>yt.id===Oe.especialidadeId)??null,procs:[]}),ue[Ce].procs.push(Oe)}),Object.values(ue).sort((Oe,Ce)=>{var yt,Yn;return(((yt=Oe.esp)==null?void 0:yt.ordem)??99)-(((Yn=Ce.esp)==null?void 0:Yn.ordem)??99)})},[Te,h]),Ue=async()=>{if(N.length===0){r.error("SELECIONE AO MENOS UM PROCEDIMENTO");return}R(!0);try{const ue=[],Oe=N.map(Ce=>{const yt=[Ce.dente,Ce.arco,Ce.face].filter(Boolean).join("/");return Ce.proc.nome+(yt?` (${yt})`:"")+(Ce.quantidade>1?` x${Ce.quantidade}`:"")}).join(", ");de>0&&ue.push({id:crypto.randomUUID(),pacienteNome:t.nome,descricao:`ENTRADA — ${Oe}`,valor:de,dataVencimento:ee,status:"Pago",formaPagamento:oe});for(let Ce=0;Ce1?` — ${Ce+1}/${F}`:"";ue.push({id:crypto.randomUUID(),pacienteNome:t.nome,descricao:Oe+yt,valor:parseFloat(je.toFixed(2)),dataVencimento:de>0?Qv(ee,Ce+1):Qv(ee,Ce),status:Ce===0&&F===1||Ce===0?ce:"Pendente",formaPagamento:oe})}for(const Ce of ue)await J.saveFinanceiro(Ce);r.success(`${ue.length} LANÇAMENTO(S) GERADO(S) COM SUCESSO!`),n(),e()}catch{r.error("ERRO AO SALVAR LANÇAMENTOS")}finally{R(!1)}},It="border border-gray-200 rounded-lg px-2.5 py-2 text-sm focus:ring-2 focus:ring-blue-100 outline-none w-full bg-white",Rn=ue=>N.some(Oe=>Oe.proc.id===ue);return s.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center backdrop-blur-sm p-0",children:s.jsxs("div",{className:"bg-white shadow-2xl w-full h-dvh md:w-[96vw] md:h-[98vh] rounded-none md:rounded-2xl flex flex-col overflow-hidden animate-in fade-in zoom-in-95 duration-200",children:[s.jsxs("div",{className:"flex-shrink-0 px-5 py-4 border-b border-gray-100 flex items-center justify-between bg-gradient-to-r from-emerald-50 to-white",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-9 h-9 bg-emerald-100 rounded-xl flex items-center justify-center",children:s.jsx(Ba,{size:18,className:"text-emerald-600"})}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-sm font-black text-gray-800 uppercase",children:"Lançar Procedimento"}),s.jsxs("p",{className:"text-[10px] text-gray-400 uppercase font-medium",children:[t.nome,H&&s.jsx("span",{className:"ml-2 bg-emerald-100 text-emerald-700 px-1.5 py-0.5 rounded-full font-bold",children:H.nome})]})]})]}),s.jsx("button",{onClick:e,className:"text-gray-400 hover:text-gray-600 p-1.5 hover:bg-gray-100 rounded-lg transition-colors",children:s.jsx(Qe,{size:18})})]}),s.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[s.jsxs("div",{className:"w-72 flex-shrink-0 border-r border-gray-100 flex flex-col bg-gray-50/30",children:[s.jsxs("div",{className:"p-3 space-y-2 border-b border-gray-100 flex-shrink-0",children:[s.jsxs("div",{className:"relative",children:[s.jsx(ha,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-400"}),s.jsx("input",{value:b,onChange:ue=>y(ue.target.value),placeholder:"Buscar procedimento...",className:"w-full pl-8 pr-3 py-2 border border-gray-200 rounded-lg text-xs focus:ring-2 focus:ring-blue-100 outline-none bg-white"})]}),s.jsxs("div",{className:"flex gap-1 flex-wrap",children:[s.jsx("button",{onClick:()=>v(""),className:`text-[10px] font-bold px-2 py-0.5 rounded-full border transition-colors ${m?"text-gray-500 border-gray-200 hover:bg-gray-100":"bg-gray-800 text-white border-gray-800"}`,children:"Todas"}),h.map(ue=>s.jsx("button",{onClick:()=>v(Oe=>Oe===ue.id?"":ue.id),className:`text-[10px] font-bold px-2 py-0.5 rounded-full border transition-colors ${m===ue.id?"bg-blue-600 text-white border-blue-600":"text-gray-500 border-gray-200 hover:bg-gray-100"}`,children:ue.nome},ue.id))]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-2 space-y-3",children:[!i&&s.jsx("div",{className:"flex justify-center pt-8",children:s.jsx(Ct,{size:18,className:"animate-spin text-gray-300"})}),bt.map((ue,Oe)=>s.jsxs("div",{children:[ue.esp&&s.jsx("p",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest px-2 mb-1",children:ue.esp.nome}),s.jsx("div",{className:"space-y-0.5",children:ue.procs.map(Ce=>{const yt=V(Ce),Yn=Rn(Ce.id);return s.jsxs("button",{onClick:()=>P(Ce),className:`w-full text-left px-2.5 py-2 rounded-lg transition-all flex items-center justify-between gap-2 group ${Yn?"bg-emerald-50 border border-emerald-200":"border border-transparent hover:bg-white hover:border-gray-200 hover:shadow-sm"}`,children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:`text-xs font-bold truncate ${Yn?"text-emerald-700":"text-gray-700"}`,children:Ce.nome}),Ce.codigo&&s.jsx("p",{className:"text-[9px] text-gray-400",children:Ce.codigo})]}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[s.jsx("span",{className:`text-[10px] font-black ${Yn?"text-emerald-600":"text-green-600"}`,children:Zn(yt)}),Yn?s.jsx(fo,{size:13,className:"text-emerald-500"}):s.jsx(ft,{size:13,className:"text-gray-300 group-hover:text-blue-500"})]})]},Ce.id)})})]},Oe)),i&&Te.length===0&&s.jsx("p",{className:"text-xs text-gray-400 text-center pt-6",children:"Nenhum procedimento encontrado"})]})]}),s.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[s.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-2",children:N.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center",children:[s.jsx("div",{className:"w-16 h-16 bg-gray-100 rounded-2xl flex items-center justify-center mb-3",children:s.jsx(gO,{size:24,className:"text-gray-300"})}),s.jsx("p",{className:"text-sm font-bold text-gray-400",children:"Nenhum procedimento selecionado"}),s.jsx("p",{className:"text-xs text-gray-300 mt-1",children:"Clique nos procedimentos ao lado para adicionar"})]}):N.map(ue=>s.jsx(AM,{item:ue,onChange:Oe=>W(ue.uid,Oe),onRemove:()=>te(ue.uid)},ue.uid))}),s.jsxs("div",{className:"flex-shrink-0 border-t border-gray-100 bg-gray-50/50 p-4 space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsx("span",{className:"font-bold text-gray-500 uppercase text-xs",children:"Subtotal"}),s.jsx("span",{className:"font-black text-gray-800 text-base",children:Zn(T)})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-[9px] font-black text-gray-400 uppercase block mb-1",children:"Desconto"}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx("button",{onClick:()=>O(ue=>ue==="R$"?"%":"R$"),className:"px-2 py-2 border border-gray-200 rounded-lg text-[10px] font-black text-gray-500 hover:bg-gray-100 flex-shrink-0 bg-white",children:C==="R$"?s.jsx(LN,{size:12}):s.jsx(BD,{size:12})}),s.jsx("input",{type:"number",step:"0.01",value:A,onChange:ue=>k(ue.target.value),placeholder:"0",className:It+" text-sm"})]}),ie>0&&s.jsxs("p",{className:"text-[10px] text-red-500 mt-0.5",children:["− ",Zn(ie)]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[9px] font-black text-gray-400 uppercase block mb-1",children:"Entrada (R$)"}),s.jsx("input",{type:"number",step:"0.01",value:_,onChange:ue=>B(ue.target.value),placeholder:"0",className:It}),de>0&&s.jsxs("p",{className:"text-[10px] text-blue-500 mt-0.5",children:["− ",Zn(de)," (marca como Pago)"]})]})]}),s.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-3 space-y-2.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-xs font-black text-gray-500 uppercase",children:"Restante a parcelar"}),s.jsx("span",{className:"text-lg font-black text-emerald-600",children:Zn(ve)})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-[9px] font-black text-gray-400 uppercase block mb-1",children:"Parcelas"}),s.jsx("select",{value:F,onChange:ue=>G(Number(ue.target.value)),className:It+" text-xs",children:Array.from({length:48},(ue,Oe)=>Oe+1).map(ue=>s.jsxs("option",{value:ue,children:[ue,"x — ",Zn(ve/ue)]},ue))})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[9px] font-black text-gray-400 uppercase block mb-1",children:"1ª Parcela"}),s.jsx("input",{type:"date",value:ee,onChange:ue=>ne(ue.target.value),className:It+" text-xs"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[9px] font-black text-gray-400 uppercase block mb-1",children:"Forma"}),s.jsx("select",{value:oe,onChange:ue=>Q(ue.target.value),className:It+" text-xs",children:SM.map(ue=>s.jsx("option",{children:ue},ue))})]})]}),F>1&&s.jsxs("div",{className:"flex items-center justify-between bg-emerald-50 rounded-lg px-3 py-2",children:[s.jsxs("span",{className:"text-xs font-bold text-emerald-700",children:[F,"x de"]}),s.jsx("span",{className:"text-sm font-black text-emerald-700",children:Zn(je)})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-[9px] font-black text-gray-400 uppercase block mb-1",children:"Status 1ª parcela"}),s.jsx("select",{value:ce,onChange:ue=>he(ue.target.value),className:It+" text-xs",children:jM.map(ue=>s.jsx("option",{children:ue},ue))})]}),s.jsx("div",{className:"flex items-end",children:s.jsxs("div",{className:"w-full bg-gray-50 border border-gray-100 rounded-lg p-2 text-center",children:[s.jsx("p",{className:"text-[9px] font-black text-gray-400 uppercase",children:"Total geral"}),s.jsx("p",{className:"text-sm font-black text-gray-800",children:Zn(de+ve)})]})})]})]}),s.jsxs("div",{className:"flex gap-2 pt-1",children:[s.jsx("button",{onClick:e,className:"px-5 py-2.5 bg-gray-100 hover:bg-gray-200 text-gray-700 font-bold rounded-lg text-xs uppercase flex-shrink-0",children:"Cancelar"}),s.jsxs("button",{onClick:Ue,disabled:N.length===0||j,className:"flex-1 py-2.5 bg-emerald-600 hover:bg-emerald-700 text-white font-black rounded-lg text-xs uppercase disabled:opacity-40 flex items-center justify-center gap-2 transition-colors",children:[j?s.jsx(Ct,{size:14,className:"animate-spin"}):s.jsx(fo,{size:14}),j?"Salvando...":`Confirmar ${N.length>0?`— ${Zn(de+ve)}`:""}`]})]})]})]})]})]})})};function CM(t,e){const[n,r]=w.useState(t);return w.useEffect(()=>{const i=setTimeout(()=>r(t),e);return()=>clearTimeout(i)},[t,e]),n}function DM({label:t,placeholder:e,value:n,onSelect:r,onClear:i,fetchFn:c}){const[d,f]=w.useState(""),[h,p]=w.useState([]),[b,y]=w.useState(!1),[m,v]=w.useState(!1),N=CM(d,300),S=w.useRef(null);return w.useEffect(()=>{if(!N.trim()||n){p([]),y(!1);return}v(!0),c(N).then(j=>{const R=Array.isArray(j)?j:[];p(R),y(R.length>0)}).finally(()=>v(!1))},[N]),w.useEffect(()=>{const j=R=>{S.current&&!S.current.contains(R.target)&&y(!1)};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[]),n?s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:t}),s.jsxs("div",{className:"flex items-center justify-between bg-blue-50 border border-blue-100 rounded-lg px-3 py-2",children:[s.jsx("span",{className:"text-xs font-bold text-blue-700 uppercase truncate",children:n.nome}),s.jsx("button",{type:"button",onClick:i,className:"ml-2 text-blue-300 hover:text-blue-600 flex-shrink-0",children:s.jsx(Qe,{size:13})})]})]}):s.jsxs("div",{ref:S,className:"relative",children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:t}),s.jsxs("div",{className:"relative",children:[s.jsx(ha,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),s.jsx("input",{value:d,onChange:j=>f(j.target.value),placeholder:e,className:"w-full pl-7 pr-3 py-2 border border-gray-200 rounded-lg text-xs focus:ring-2 focus:ring-blue-100 focus:border-blue-300 outline-none"}),m&&s.jsx(Ct,{size:12,className:"absolute right-2.5 top-1/2 -translate-y-1/2 animate-spin text-gray-400"})]}),b&&h.length>0&&s.jsx("div",{className:"absolute z-50 w-full mt-1 bg-white border border-gray-200 rounded-xl shadow-xl overflow-hidden",children:h.map(j=>s.jsxs("button",{type:"button",onClick:()=>{r(j),f(""),y(!1)},className:"w-full text-left px-3 py-2 hover:bg-blue-50 text-xs font-medium text-gray-700 flex items-center gap-2 border-b border-gray-50 last:border-0",children:[s.jsx($n,{size:12,className:"text-gray-400 flex-shrink-0"}),j.nome]},j.id))})]})}const Wv=`CLÁUSULA 1ª – DO OBJETO O presente contrato tem por objeto a prestação de serviços odontológicos conforme os procedimentos descritos neste instrumento, obrigando-se o profissional a realizá-los com toda a técnica e diligência necessárias. CLÁUSULA 2ª – DAS OBRIGAÇÕES DO CONTRATANTE O(A) paciente obriga-se a: comparecer às consultas agendadas; comunicar cancelamentos com antecedência mínima de 24 horas; seguir as orientações clínicas do profissional; e efetuar os pagamentos nos prazos acordados. CLÁUSULA 3ª – DO PAGAMENTO O valor total do tratamento, a forma de pagamento e o parcelamento estão descritos neste contrato. Em caso de atraso no pagamento, incidirão multa de 2% (dois por cento) e juros de 1% (um por cento) ao mês sobre o valor devido. CLÁUSULA 4ª – DA VIGÊNCIA O presente contrato vigorará pelo período necessário à conclusão do tratamento acordado, podendo ser prorrogado mediante aditivo escrito firmado por ambas as partes. CLÁUSULA 5ª – DO CANCELAMENTO E DESISTÊNCIA Em caso de desistência do tratamento pelo contratante, serão devidos os valores correspondentes aos procedimentos já realizados. Os valores pagos a maior serão restituídos no prazo de 30 dias. CLÁUSULA 6ª – DA PROTEÇÃO DE DADOS (LGPD) Os dados pessoais e de saúde do contratante serão tratados em conformidade com a Lei nº 13.709/2018 (LGPD), utilizados exclusivamente para fins relacionados ao tratamento odontológico. CLÁUSULA 7ª – DO FORO Fica eleito o foro da comarca do domicílio do contratado para dirimir quaisquer controvérsias oriundas do presente contrato, com renúncia expressa de qualquer outro.`,yp=["DADOS","ITENS","CLÁUSULAS"],Nn=t=>t.toLocaleString("pt-BR",{style:"currency",currency:"BRL"}),OM=({form:t,items:e,valorTotal:n,contratoId:r,onBack:i})=>{const c=new Date().toLocaleDateString("pt-BR",{day:"2-digit",month:"long",year:"numeric"}),d=n-t.entrada,f=t.parcelas>0&&d>0?d/t.parcelas:0;return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center gap-3 print:hidden flex-shrink-0",children:[s.jsxs("button",{type:"button",onClick:i,className:"flex items-center gap-1.5 px-3 py-2 bg-gray-100 hover:bg-gray-200 text-gray-700 rounded-lg text-xs font-bold",children:[s.jsx(Bs,{size:14})," Voltar"]}),s.jsxs("button",{type:"button",onClick:()=>window.print(),className:"flex items-center gap-1.5 px-4 py-2 bg-gray-900 hover:bg-black text-white rounded-lg text-xs font-bold",children:[s.jsx(Va,{size:14})," Imprimir / Salvar PDF"]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-6 print:p-0 print:bg-white",children:s.jsxs("div",{className:"max-w-3xl mx-auto bg-white rounded-2xl shadow-sm border border-gray-200 p-10 print:shadow-none print:rounded-none print:border-0 print:max-w-full",children:[s.jsxs("div",{className:"text-center border-b-2 border-gray-800 pb-6 mb-6",children:[s.jsx("h1",{className:"text-xl font-black text-gray-900 uppercase tracking-wide",children:"CONTRATO DE PRESTAÇÃO DE SERVIÇOS ODONTOLÓGICOS"}),s.jsx("p",{className:"text-sm text-gray-500 mt-1 font-bold uppercase",children:"Nome da Clínica"}),r&&s.jsxs("p",{className:"text-[10px] text-gray-400 mt-0.5",children:["Contrato Nº ",r]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-6 mb-6",children:[s.jsxs("div",{className:"border border-gray-200 rounded-xl p-4",children:[s.jsx("p",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest mb-2",children:"CONTRATANTE (PACIENTE)"}),s.jsx("p",{className:"font-bold text-gray-800 uppercase",children:t.pacienteNome||"—"}),s.jsxs("div",{className:"mt-2 space-y-1",children:[s.jsx("p",{className:"text-xs text-gray-500",children:"CPF: ___________________________________"}),s.jsx("p",{className:"text-xs text-gray-500",children:"RG: ____________________________________"}),s.jsx("p",{className:"text-xs text-gray-500",children:"Endereço: ______________________________"})]})]}),s.jsxs("div",{className:"border border-gray-200 rounded-xl p-4",children:[s.jsx("p",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest mb-2",children:"CONTRATADO (DENTISTA)"}),s.jsx("p",{className:"font-bold text-gray-800 uppercase",children:t.dentistaNome||"—"}),s.jsxs("div",{className:"mt-2 space-y-1",children:[s.jsx("p",{className:"text-xs text-gray-500",children:"CRO: ___________________________________"}),s.jsxs("p",{className:"text-xs text-gray-500",children:["Especialidade: ",t.especialidadeNome||"—"]}),s.jsxs("p",{className:"text-xs text-gray-500",children:["Data de início: ",t.dataInicio?new Date(t.dataInicio+"T12:00").toLocaleDateString("pt-BR"):"—"]})]})]})]}),s.jsxs("div",{className:"mb-6",children:[s.jsxs("h2",{className:"text-xs font-black text-gray-500 uppercase tracking-widest mb-3 border-b border-gray-100 pb-1",children:["OBJETO DO CONTRATO — ",t.titulo]}),e.length>0?s.jsxs("table",{className:"w-full text-sm border-collapse",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-gray-50",children:[s.jsx("th",{className:"text-left px-3 py-2 text-xs font-black text-gray-500 uppercase border border-gray-200",children:"Procedimento"}),s.jsx("th",{className:"text-center px-3 py-2 text-xs font-black text-gray-500 uppercase border border-gray-200 w-16",children:"Qtd"}),s.jsx("th",{className:"text-right px-3 py-2 text-xs font-black text-gray-500 uppercase border border-gray-200 w-28",children:"Unit."}),s.jsx("th",{className:"text-right px-3 py-2 text-xs font-black text-gray-500 uppercase border border-gray-200 w-28",children:"Total"})]})}),s.jsx("tbody",{children:e.map((h,p)=>s.jsxs("tr",{className:p%2===0?"bg-white":"bg-gray-50/50",children:[s.jsx("td",{className:"px-3 py-2 text-xs text-gray-700 border border-gray-200 font-medium uppercase",children:h.procedimentoNome}),s.jsx("td",{className:"px-3 py-2 text-xs text-gray-700 border border-gray-200 text-center",children:h.quantidade}),s.jsx("td",{className:"px-3 py-2 text-xs text-gray-700 border border-gray-200 text-right",children:Nn(h.valorUnitario)}),s.jsx("td",{className:"px-3 py-2 text-xs text-gray-700 border border-gray-200 text-right font-bold",children:Nn(h.valorTotal)})]},h.id))}),s.jsx("tfoot",{children:s.jsxs("tr",{className:"bg-gray-100",children:[s.jsx("td",{colSpan:3,className:"px-3 py-2 text-xs font-black text-gray-700 uppercase border border-gray-200 text-right",children:"VALOR TOTAL"}),s.jsx("td",{className:"px-3 py-2 text-sm font-black text-gray-900 border border-gray-200 text-right",children:Nn(n)})]})})]}):s.jsx("p",{className:"text-xs text-gray-500 italic",children:"Nenhum procedimento listado."})]}),s.jsxs("div",{className:"mb-6 border border-gray-200 rounded-xl p-4",children:[s.jsx("h2",{className:"text-xs font-black text-gray-500 uppercase tracking-widest mb-3",children:"RESUMO FINANCEIRO"}),s.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-400 text-xs font-bold uppercase block",children:"Valor Total"}),s.jsx("p",{className:"font-bold text-gray-800",children:Nn(n)})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-400 text-xs font-bold uppercase block",children:"Forma de Pagamento"}),s.jsx("p",{className:"font-bold text-gray-800",children:t.formaPagamento||"—"})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-400 text-xs font-bold uppercase block",children:"Entrada"}),s.jsx("p",{className:"font-bold text-gray-800",children:Nn(t.entrada)})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-400 text-xs font-bold uppercase block",children:"Restante"}),s.jsx("p",{className:"font-bold text-gray-800",children:Nn(d)})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-400 text-xs font-bold uppercase block",children:"Parcelas"}),s.jsxs("p",{className:"font-bold text-gray-800",children:[t.parcelas,"x"]})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-400 text-xs font-bold uppercase block",children:"Valor por Parcela"}),s.jsx("p",{className:"font-bold text-gray-800",children:Nn(f)})]})]})]}),t.clausulas&&s.jsxs("div",{className:"mb-6",children:[s.jsx("h2",{className:"text-xs font-black text-gray-500 uppercase tracking-widest mb-3 border-b border-gray-100 pb-1",children:"CLÁUSULAS CONTRATUAIS"}),s.jsx("div",{className:"text-xs text-gray-700 whitespace-pre-wrap leading-relaxed",children:t.clausulas})]}),s.jsxs("div",{className:"mt-10 pt-6 border-t-2 border-gray-800",children:[s.jsx("p",{className:"text-xs text-gray-500 text-center mb-8",children:"Estando de pleno acordo com as cláusulas e condições acima, as partes assinam o presente contrato."}),s.jsxs("p",{className:"text-xs text-gray-500 text-center mb-10",children:["___________________, ",c,"."]}),s.jsx("div",{className:"grid grid-cols-3 gap-8",children:[{title:"CONTRATANTE (PACIENTE)",name:t.pacienteNome},{title:"CONTRATADO (DENTISTA)",name:t.dentistaNome},{title:"TESTEMUNHA",name:""}].map((h,p)=>s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"h-16 border-b border-gray-400 mb-2"}),s.jsx("p",{className:"text-[10px] font-black text-gray-500 uppercase",children:h.title}),h.name&&s.jsx("p",{className:"text-[10px] text-gray-400 uppercase mt-0.5",children:h.name}),s.jsx("p",{className:"text-[10px] text-gray-400 mt-1",children:"CPF: __________________________"})]},p))})]}),r&&s.jsxs("div",{className:"mt-6 pt-3 border-t border-gray-100 flex justify-between items-center",children:[s.jsxs("p",{className:"text-[9px] text-gray-300",children:["ID: ",r]}),s.jsxs("p",{className:"text-[9px] text-gray-300",children:["Gerado em ",c]})]})]})})]})},lS=({contrato:t,paciente:e,onClose:n,onSaved:r})=>{var V;const i=Fe(),{data:c}=_e(J.getDentistas),{data:d}=_e(J.getEspecialidades),{data:f}=_e(J.getProcedimentos),[h,p]=w.useState(0),[b,y]=w.useState("editor"),[m,v]=w.useState(!1),[N,S]=w.useState({titulo:(t==null?void 0:t.titulo)||"CONTRATO DE SERVIÇOS ODONTOLÓGICOS",status:(t==null?void 0:t.status)||"Rascunho",pacienteId:(t==null?void 0:t.pacienteId)||(e==null?void 0:e.id)||"",pacienteNome:(t==null?void 0:t.pacienteNome)||(e==null?void 0:e.nome)||"",dentistaId:(t==null?void 0:t.dentistaId)||"",dentistaNome:(t==null?void 0:t.dentistaNome)||"",especialidadeId:(t==null?void 0:t.especialidadeId)||"",especialidadeNome:(t==null?void 0:t.especialidadeNome)||"",dataInicio:(t==null?void 0:t.dataInicio)||new Date().toISOString().split("T")[0],dataFim:(t==null?void 0:t.dataFim)||"",observacoes:(t==null?void 0:t.observacoes)||"",entrada:(t==null?void 0:t.entrada)||0,parcelas:(t==null?void 0:t.parcelas)||1,formaPagamento:(t==null?void 0:t.formaPagamento)||"Pix",clausulas:(t==null?void 0:t.clausulas)||Wv}),[j,R]=w.useState(((V=t==null?void 0:t.items)==null?void 0:V.map((P,W)=>({id:P.id,procedimentoNome:P.procedimentoNome,quantidade:P.quantidade,valorUnitario:P.valorUnitario,valorTotal:P.valorTotal,descricao:P.descricao,ordem:P.ordem??W})))??[]),[C,O]=w.useState(e?{id:e.id,nome:e.nome}:t!=null&&t.pacienteId?{id:t.pacienteId,nome:t.pacienteNome}:null),[A,k]=w.useState(""),_=j.length>0?j.reduce((P,W)=>P+W.valorTotal,0):0,B=_-N.entrada,F=N.parcelas>0&&B>0?B/N.parcelas:0;w.useEffect(()=>{const P=W=>{W.key==="Escape"&&n()};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[n]);const G=P=>{const W=d==null?void 0:d.find(te=>te.id===P);S(te=>({...te,especialidadeId:P,especialidadeNome:(W==null?void 0:W.nome)||"",titulo:W?`CONTRATO DE SERVIÇOS ODONTOLÓGICOS — ${W.nome.toUpperCase()}`:te.titulo}))},ee=P=>{const W=j.find(T=>T.procedimentoNome===P.nome);if(W){R(T=>T.map(X=>X.id===W.id?{...X,quantidade:X.quantidade+1,valorTotal:(X.quantidade+1)*X.valorUnitario}:X));return}const te={id:Math.random().toString(36).substring(2,10),procedimentoNome:P.nome,quantidade:1,valorUnitario:P.valorParticular,valorTotal:P.valorParticular,ordem:j.length};R(T=>[...T,te])},ne=()=>{const P={id:Math.random().toString(36).substring(2,10),procedimentoNome:"",quantidade:1,valorUnitario:0,valorTotal:0,ordem:j.length};R(W=>[...W,P])},oe=(P,W,te)=>{R(T=>T.map(X=>{if(X.id!==P)return X;const ie={...X,[W]:te};return(W==="quantidade"||W==="valorUnitario")&&(ie.valorTotal=ie.quantidade*ie.valorUnitario),ie}))},Q=P=>R(W=>W.filter(te=>te.id!==P)),ce=P=>{if(!P.destination)return;const W=[...j],[te]=W.splice(P.source.index,1);W.splice(P.destination.index,0,te),R(W.map((T,X)=>({...T,ordem:X})))},he=async()=>{if(!N.pacienteNome&&!C){i.error("SELECIONE UM PACIENTE.");return}v(!0);try{const P={id:t==null?void 0:t.id,titulo:N.titulo,status:N.status,paciente_id:(C==null?void 0:C.id)||N.pacienteId||void 0,paciente_nome:(C==null?void 0:C.nome)||N.pacienteNome,dentista_id:N.dentistaId||void 0,dentista_nome:N.dentistaNome||void 0,especialidade_id:N.especialidadeId||void 0,especialidade_nome:N.especialidadeNome||void 0,data_inicio:N.dataInicio||void 0,data_fim:N.dataFim||void 0,valor_total:_,entrada:N.entrada,parcelas:N.parcelas,forma_pagamento:N.formaPagamento,clausulas:N.clausulas,observacoes:N.observacoes||void 0,items:j.map((W,te)=>({id:W.id,procedimento_nome:W.procedimentoNome,quantidade:W.quantidade,valor_unitario:W.valorUnitario,valor_total:W.valorTotal,descricao:W.descricao||void 0,ordem:te}))};t!=null&&t.id?await J.updateContrato({...t,...P,items:t.items}):await J.saveContrato(P),i.success("CONTRATO SALVO COM SUCESSO!"),r(),n()}catch{i.error("ERRO AO SALVAR CONTRATO.")}finally{v(!1)}},H=Ve.useMemo(()=>{const P=f??[],W=A.trim()?P.filter(T=>T.nome.toLowerCase().includes(A.toLowerCase())||T.especialidadeNome.toLowerCase().includes(A.toLowerCase())):P,te={};return W.forEach(T=>{const X=T.especialidadeNome||"Outros";te[X]||(te[X]=[]),te[X].push(T)}),te},[f,A]);return b==="print"?s.jsx("div",{className:"fixed inset-0 bg-black/40 z-50 flex items-center justify-center backdrop-blur-sm p-0",children:s.jsxs("div",{className:"bg-white shadow-2xl w-full h-dvh md:w-[96vw] md:h-[98vh] rounded-none md:rounded-2xl flex flex-col animate-in fade-in zoom-in-50 duration-200 overflow-hidden",children:[s.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between flex-shrink-0 print:hidden",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(za,{size:16,className:"text-indigo-600"}),s.jsx("span",{className:"text-sm font-black text-gray-800 uppercase",children:"Visualização de Impressão"})]}),s.jsx("button",{type:"button",onClick:n,className:"text-gray-400 hover:text-gray-600",children:s.jsx(Qe,{size:18})})]}),s.jsx(OM,{form:N,items:j,valorTotal:_,contratoId:t==null?void 0:t.id,onBack:()=>y("editor")})]})}):s.jsx("div",{className:"fixed inset-0 bg-black/40 z-50 flex items-center justify-center backdrop-blur-sm p-0",children:s.jsxs("div",{className:"bg-white shadow-2xl w-full h-dvh md:w-[96vw] md:h-[98vh] rounded-none md:rounded-2xl flex flex-col animate-in fade-in zoom-in-50 duration-200 overflow-hidden",children:[s.jsxs("div",{className:"p-5 border-b border-gray-100 flex items-center justify-between flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-8 h-8 bg-indigo-100 rounded-lg flex items-center justify-center",children:s.jsx(za,{size:16,className:"text-indigo-600"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-black text-gray-800 uppercase",children:t?"Editar Contrato":"Novo Contrato"}),s.jsx("p",{className:"text-[10px] text-gray-400 font-medium uppercase",children:N.pacienteNome||"Paciente não selecionado"})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{type:"button",onClick:()=>y("print"),className:"flex items-center gap-1.5 px-3 py-1.5 bg-gray-100 hover:bg-gray-200 text-gray-700 rounded-lg text-xs font-bold transition-colors",children:[s.jsx(Va,{size:13})," Imprimir/Assinar"]}),s.jsx("button",{onClick:n,className:"text-gray-400 hover:text-gray-600",children:s.jsx(Qe,{size:18})})]})]}),s.jsx("div",{className:"px-6 pt-4 pb-2 flex-shrink-0",children:s.jsx("div",{className:"flex items-center",children:yp.map((P,W)=>s.jsxs(Ve.Fragment,{children:[s.jsxs("button",{type:"button",onClick:()=>p(W),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full text-[10px] font-black uppercase transition-all whitespace-nowrap ${h===W?"bg-indigo-600 text-white":W{O({id:P.id,nome:P.nome}),S(W=>({...W,pacienteId:P.id,pacienteNome:P.nome}))},onClear:()=>{O(null),S(P=>({...P,pacienteId:"",pacienteNome:""}))},fetchFn:P=>J.getPacientes(P).then(W=>W.data)}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"Dentista"}),s.jsxs("select",{value:N.dentistaId,onChange:P=>{const W=c==null?void 0:c.find(te=>te.id===P.target.value);S(te=>({...te,dentistaId:P.target.value,dentistaNome:(W==null?void 0:W.nome)||""}))},className:"w-full border border-gray-200 rounded-lg p-2.5 text-xs focus:ring-2 focus:ring-indigo-100 focus:border-indigo-300 outline-none",children:[s.jsx("option",{value:"",children:"— Selecionar —"}),c==null?void 0:c.map(P=>s.jsx("option",{value:P.id,children:P.nome},P.id))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"Especialidade"}),s.jsxs("select",{value:N.especialidadeId,onChange:P=>G(P.target.value),className:"w-full border border-gray-200 rounded-lg p-2.5 text-xs focus:ring-2 focus:ring-indigo-100 focus:border-indigo-300 outline-none",children:[s.jsx("option",{value:"",children:"— Selecionar —"}),d==null?void 0:d.map(P=>s.jsx("option",{value:P.id,children:P.nome},P.id))]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"Título do Contrato"}),s.jsx("input",{value:N.titulo,onChange:P=>S(W=>({...W,titulo:P.target.value.toUpperCase()})),className:"w-full border border-gray-200 rounded-lg p-2.5 text-xs focus:ring-2 focus:ring-indigo-100 focus:border-indigo-300 outline-none",placeholder:"CONTRATO DE SERVIÇOS ODONTOLÓGICOS"})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"Status"}),s.jsxs("select",{value:N.status,onChange:P=>S(W=>({...W,status:P.target.value})),className:"w-full border border-gray-200 rounded-lg p-2.5 text-xs focus:ring-2 focus:ring-indigo-100 focus:border-indigo-300 outline-none",children:[s.jsx("option",{value:"Rascunho",children:"Rascunho"}),s.jsx("option",{value:"Ativo",children:"Ativo"}),s.jsx("option",{value:"Assinado",children:"Assinado"}),s.jsx("option",{value:"Encerrado",children:"Encerrado"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"Data Início"}),s.jsx("input",{type:"date",value:N.dataInicio,onChange:P=>S(W=>({...W,dataInicio:P.target.value})),className:"w-full border border-gray-200 rounded-lg p-2.5 text-xs focus:ring-2 focus:ring-indigo-100 focus:border-indigo-300 outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"Data Fim (opcional)"}),s.jsx("input",{type:"date",value:N.dataFim,onChange:P=>S(W=>({...W,dataFim:P.target.value})),className:"w-full border border-gray-200 rounded-lg p-2.5 text-xs focus:ring-2 focus:ring-indigo-100 focus:border-indigo-300 outline-none"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"Observações"}),s.jsx("textarea",{value:N.observacoes,onChange:P=>S(W=>({...W,observacoes:P.target.value})),rows:3,className:"w-full border border-gray-200 rounded-lg p-2.5 text-xs focus:ring-2 focus:ring-indigo-100 focus:border-indigo-300 outline-none resize-none",placeholder:"Observações gerais do contrato..."})]})]}),h===1&&s.jsxs("div",{className:"flex-1 overflow-hidden flex gap-0 min-h-0",children:[s.jsxs("div",{className:"w-72 flex-shrink-0 border-r border-gray-100 flex flex-col min-h-0",children:[s.jsxs("div",{className:"p-3 border-b border-gray-100",children:[s.jsx("p",{className:"text-[10px] font-black text-gray-500 uppercase tracking-wider mb-2",children:"Catálogo de Procedimentos"}),s.jsxs("div",{className:"relative",children:[s.jsx(ha,{size:12,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),s.jsx("input",{value:A,onChange:P=>k(P.target.value),placeholder:"Buscar procedimento...",className:"w-full pl-7 pr-3 py-1.5 border border-gray-200 rounded-lg text-[11px] focus:ring-2 focus:ring-indigo-100 focus:border-indigo-300 outline-none"})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-2 space-y-3",children:[Object.entries(H).map(([P,W])=>s.jsxs("div",{children:[s.jsx("p",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest px-2 py-1",children:P}),W.map(te=>s.jsxs("button",{type:"button",onClick:()=>ee(te),className:"w-full flex items-center justify-between px-2 py-1.5 hover:bg-indigo-50 rounded-lg text-left transition-colors group",children:[s.jsx("span",{className:"text-[11px] text-gray-700 font-medium flex-1 truncate",children:te.nome}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0 ml-1",children:[s.jsx("span",{className:"text-[10px] text-green-600 font-bold",children:Nn(te.valorParticular)}),s.jsx("div",{className:"w-5 h-5 rounded-full bg-indigo-100 group-hover:bg-indigo-600 text-indigo-600 group-hover:text-white flex items-center justify-center transition-colors",children:s.jsx(ft,{size:11})})]})]},te.id))]},P)),Object.keys(H).length===0&&s.jsx("p",{className:"text-center text-xs text-gray-400 py-6",children:"Nenhum procedimento encontrado."})]})]}),s.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[s.jsxs("div",{className:"p-3 border-b border-gray-100 flex items-center justify-between",children:[s.jsxs("p",{className:"text-[10px] font-black text-gray-500 uppercase tracking-wider",children:["Itens do Contrato (",j.length,")"]}),s.jsxs("button",{type:"button",onClick:ne,className:"flex items-center gap-1 px-2.5 py-1.5 bg-indigo-50 hover:bg-indigo-100 text-indigo-700 rounded-lg text-[11px] font-bold transition-colors",children:[s.jsx(ft,{size:12})," Adicionar Item Manual"]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-3",children:j.length===0?s.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-gray-400 py-10",children:[s.jsx(za,{size:36,className:"mb-3 opacity-30"}),s.jsx("p",{className:"text-xs font-bold uppercase",children:"Nenhum item adicionado"}),s.jsx("p",{className:"text-[10px] mt-1",children:"Clique em procedimentos no catálogo ou adicione manualmente"})]}):s.jsx(Xl,{onDragEnd:ce,children:s.jsx(Kl,{droppableId:"items",children:P=>s.jsxs("div",{ref:P.innerRef,...P.droppableProps,className:"space-y-2",children:[j.map((W,te)=>s.jsx(Zl,{draggableId:W.id,index:te,children:(T,X)=>s.jsx("div",{ref:T.innerRef,...T.draggableProps,className:`bg-white border border-gray-200 rounded-xl p-3 ${X.isDragging?"shadow-lg border-indigo-300":""}`,children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("div",{...T.dragHandleProps,className:"mt-1 text-gray-300 hover:text-gray-500 cursor-grab flex-shrink-0",children:s.jsx(ql,{size:16})}),s.jsxs("div",{className:"flex-1 space-y-2",children:[s.jsx("input",{value:W.procedimentoNome,onChange:ie=>oe(W.id,"procedimentoNome",ie.target.value.toUpperCase()),className:"w-full border border-gray-200 rounded-lg px-2.5 py-1.5 text-xs font-bold text-gray-800 focus:ring-2 focus:ring-indigo-100 focus:border-indigo-300 outline-none",placeholder:"Nome do procedimento"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex items-center gap-1 border border-gray-200 rounded-lg overflow-hidden",children:[s.jsx("button",{type:"button",onClick:()=>oe(W.id,"quantidade",Math.max(1,W.quantidade-1)),className:"px-2 py-1.5 hover:bg-gray-100 text-gray-600 transition-colors",children:s.jsx(FN,{size:11})}),s.jsx("span",{className:"text-xs font-bold text-gray-800 w-6 text-center",children:W.quantidade}),s.jsx("button",{type:"button",onClick:()=>oe(W.id,"quantidade",W.quantidade+1),className:"px-2 py-1.5 hover:bg-gray-100 text-gray-600 transition-colors",children:s.jsx(ft,{size:11})})]}),s.jsx("div",{className:"flex-1",children:s.jsx("input",{type:"number",step:"0.01",min:"0",value:W.valorUnitario,onChange:ie=>oe(W.id,"valorUnitario",parseFloat(ie.target.value)||0),className:"w-full border border-gray-200 rounded-lg px-2.5 py-1.5 text-xs focus:ring-2 focus:ring-indigo-100 focus:border-indigo-300 outline-none",placeholder:"Valor unit."})}),s.jsx("div",{className:"text-sm font-black text-indigo-600 w-24 text-right flex-shrink-0",children:Nn(W.valorTotal)}),s.jsx("button",{type:"button",onClick:()=>Q(W.id),className:"text-red-300 hover:text-red-600 flex-shrink-0 transition-colors",children:s.jsx($t,{size:14})})]}),s.jsx("input",{value:W.descricao||"",onChange:ie=>oe(W.id,"descricao",ie.target.value),className:"w-full border border-gray-100 rounded-lg px-2.5 py-1 text-[11px] text-gray-500 focus:ring-1 focus:ring-indigo-100 outline-none bg-gray-50",placeholder:"Descrição opcional..."})]})]})})},W.id)),P.placeholder]})})})}),j.length>0&&s.jsxs("div",{className:"p-3 border-t border-gray-100 flex justify-between items-center bg-indigo-50/50",children:[s.jsx("span",{className:"text-xs font-black text-gray-500 uppercase",children:"Total"}),s.jsx("span",{className:"text-lg font-black text-indigo-700",children:Nn(_)})]})]})]}),h===2&&s.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-4 space-y-5",children:[s.jsxs("div",{className:"bg-indigo-50/60 border border-indigo-100 rounded-2xl p-4 space-y-3",children:[s.jsx("p",{className:"text-[10px] font-black text-indigo-600 uppercase tracking-widest",children:"Financeiro"}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"Valor Total"}),s.jsx("div",{className:"w-full border border-gray-200 rounded-lg p-2.5 text-sm font-black text-indigo-700 bg-white",children:Nn(_)})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"Entrada (R$)"}),s.jsx("input",{type:"number",step:"0.01",min:"0",value:N.entrada||"",onChange:P=>S(W=>({...W,entrada:parseFloat(P.target.value)||0})),className:"w-full border border-gray-200 rounded-lg p-2.5 text-xs focus:ring-2 focus:ring-indigo-100 focus:border-indigo-300 outline-none",placeholder:"0,00"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"Parcelas"}),s.jsx("select",{value:N.parcelas,onChange:P=>S(W=>({...W,parcelas:parseInt(P.target.value)})),className:"w-full border border-gray-200 rounded-lg p-2.5 text-xs focus:ring-2 focus:ring-indigo-100 focus:border-indigo-300 outline-none",children:Array.from({length:48},(P,W)=>W+1).map(P=>s.jsxs("option",{value:P,children:[P,"x"]},P))})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"Forma de Pagamento"}),s.jsx("select",{value:N.formaPagamento,onChange:P=>S(W=>({...W,formaPagamento:P.target.value})),className:"w-full border border-gray-200 rounded-lg p-2.5 text-xs focus:ring-2 focus:ring-indigo-100 focus:border-indigo-300 outline-none",children:["Pix","Dinheiro","Cartão de Crédito","Cartão de Débito","Boleto","Transferência"].map(P=>s.jsx("option",{value:P,children:P},P))})]})]}),s.jsxs("div",{className:"flex flex-wrap gap-4 pt-2 border-t border-indigo-100",children:[s.jsxs("div",{className:"text-center",children:[s.jsx("p",{className:"text-[10px] text-indigo-400 font-bold uppercase",children:"Restante"}),s.jsx("p",{className:"text-sm font-black text-indigo-700",children:Nn(B)})]}),s.jsxs("div",{className:"text-center",children:[s.jsx("p",{className:"text-[10px] text-indigo-400 font-bold uppercase",children:"Valor por Parcela"}),s.jsx("p",{className:"text-sm font-black text-indigo-700",children:Nn(F)})]})]})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider",children:"Cláusulas Contratuais"}),s.jsx("button",{type:"button",onClick:()=>S(P=>({...P,clausulas:Wv})),className:"text-[10px] text-indigo-500 hover:text-indigo-700 font-bold uppercase transition-colors",children:"Restaurar padrão"})]}),s.jsx("textarea",{value:N.clausulas,onChange:P=>S(W=>({...W,clausulas:P.target.value})),rows:18,className:"w-full border border-gray-200 rounded-xl p-3 text-xs font-mono focus:ring-2 focus:ring-indigo-100 focus:border-indigo-300 outline-none resize-none leading-relaxed"})]})]})]}),s.jsxs("div",{className:"p-4 border-t border-gray-100 flex justify-between items-center flex-shrink-0",children:[s.jsxs("button",{type:"button",onClick:()=>h>0?p(P=>P-1):n(),className:"px-5 py-2 bg-gray-100 hover:bg-gray-200 text-gray-700 font-bold rounded-lg text-xs uppercase flex items-center gap-1.5",children:[s.jsx(Bs,{size:14})," ",h===0?"Cancelar":"Voltar"]}),s.jsx("div",{className:"flex items-center gap-2",children:hp(P=>P+1),className:"px-5 py-2 bg-indigo-600 hover:bg-indigo-700 text-white font-bold rounded-lg text-xs uppercase flex items-center gap-1.5",children:["Próximo ",s.jsx(Ts,{size:14})]}):s.jsxs("button",{type:"button",onClick:he,disabled:m,className:"px-5 py-2 bg-green-600 hover:bg-green-700 disabled:opacity-60 text-white font-bold rounded-lg text-xs uppercase flex items-center gap-1.5",children:[m?s.jsx(Ct,{size:14,className:"animate-spin"}):s.jsx(Io,{size:14}),m?"Salvando...":"Salvar Contrato"]})})]})]})})},iS=["MÃE","PAI","FILHO","FILHA","IRMÃO","IRMÃ","CÔNJUGE","AVÔ","AVÓ","NETO","NETA","TIO","TIA","SOBRINHO","SOBRINHA","PRIMO","PRIMA","PADRASTO","MADRASTA","ENTEADO","ENTEADA"];function RM(t){if(!t)return"";if(/^\d{4}-\d{2}-\d{2}$/.test(t))return t;const e=t.match(/^(\d{2})\/(\d{2})\/(\d{4})$/);return e?`${e[3]}-${e[2]}-${e[1]}`:""}function oS(t,e){const[n,r]=w.useState(t);return w.useEffect(()=>{const i=setTimeout(()=>{r(t)},e);return()=>clearTimeout(i)},[t,e]),n}function Yd({label:t,placeholder:e,value:n,onSelect:r,onClear:i,fetchFn:c,renderOption:d,extraAction:f}){const[h,p]=w.useState(""),[b,y]=w.useState([]),[m,v]=w.useState(!1),[N,S]=w.useState(!1),j=oS(h,300),R=w.useRef(null);return w.useEffect(()=>{if(!j.trim()||n){y([]),v(!1);return}S(!0),c(j).then(C=>{const O=Array.isArray(C)?C:[];y(O),v(O.length>0)}).finally(()=>S(!1))},[j]),w.useEffect(()=>{const C=O=>{R.current&&!R.current.contains(O.target)&&v(!1)};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[]),n?s.jsxs("div",{className:"flex items-center justify-between bg-blue-50 border border-blue-100 rounded-lg px-3 py-2",children:[s.jsx("span",{className:"text-xs font-bold text-blue-700 uppercase truncate",children:n.nome}),s.jsx("button",{onClick:i,className:"ml-2 text-blue-300 hover:text-blue-600 flex-shrink-0",children:s.jsx(Qe,{size:13})})]}):s.jsxs("div",{ref:R,className:"relative",children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:t}),s.jsxs("div",{className:"flex gap-1",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(ha,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),s.jsx("input",{value:h,onChange:C=>p(C.target.value),placeholder:e,className:"w-full pl-7 pr-3 py-2 border border-gray-200 rounded-lg text-xs focus:ring-2 focus:ring-blue-100 focus:border-blue-300 outline-none"}),N&&s.jsx(Ct,{size:12,className:"absolute right-2.5 top-1/2 -translate-y-1/2 animate-spin text-gray-400"})]}),f]}),m&&b.length>0&&s.jsx("div",{className:"absolute z-50 w-full mt-1 bg-white border border-gray-200 rounded-xl shadow-xl overflow-hidden",children:b.map(C=>s.jsx("button",{onClick:()=>{r(C),p(""),v(!1)},className:"w-full text-left px-3 py-2 hover:bg-blue-50 text-xs font-medium text-gray-700 flex items-center gap-2 border-b border-gray-50 last:border-0",children:d?d(C):C.nome},C.id))})]})}const TM=({paciente:t,onClose:e})=>(w.useEffect(()=>{const n=r=>{r.key==="Escape"&&e()};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[e]),s.jsx("div",{className:"fixed inset-0 bg-black/40 z-50 flex items-center justify-center backdrop-blur-sm p-0",children:s.jsxs("div",{className:"bg-white shadow-2xl w-full h-dvh md:w-[96vw] md:h-[98vh] rounded-none md:rounded-2xl flex flex-col animate-in fade-in zoom-in-50 duration-200",children:[s.jsxs("div",{className:"p-5 border-b border-gray-100 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-8 h-8 bg-indigo-100 rounded-lg flex items-center justify-center",children:s.jsx($n,{size:16,className:"text-indigo-600"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-black text-gray-800 uppercase",children:"Vínculo Familiar"}),s.jsx("p",{className:"text-[10px] text-gray-400 font-medium uppercase",children:t.nome})]})]}),s.jsx("button",{onClick:e,className:"text-gray-400 hover:text-gray-600",children:s.jsx(Qe,{size:18})})]}),s.jsx("div",{className:"p-4",children:t.grupoFamiliarId?s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-indigo-50 rounded-xl border border-indigo-100",children:[s.jsx("div",{className:"w-9 h-9 rounded-full bg-indigo-200 flex items-center justify-center flex-shrink-0",children:s.jsx($l,{size:15,className:"text-indigo-700"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-bold text-gray-800 uppercase",children:t.grupoFamiliarNome}),s.jsx("p",{className:"text-[10px] text-indigo-500 font-bold uppercase",children:t.grupoFamiliarRelacao||"Familiar"})]})]}):s.jsx("p",{className:"text-center text-xs text-gray-400 py-4",children:"Nenhum familiar vinculado."})}),s.jsx("div",{className:"p-4 border-t border-gray-100 flex justify-end",children:s.jsx("button",{onClick:e,className:"px-5 py-2 bg-gray-100 hover:bg-gray-200 text-gray-700 text-xs font-bold rounded-lg uppercase",children:"Fechar"})})]})})),kM=({patient:t,onClose:e})=>{const{data:n}=_e(J.getDentistas),{data:r,refresh:i}=_e(J.getAgendamentos),c=Fe(),[d,f]=w.useState(30),[h,p]=w.useState(new Date().toISOString().split("T")[0]),[b,y]=w.useState(""),[m,v]=w.useState(void 0),[N,S]=w.useState("");w.useEffect(()=>{var A;n&&!m&&v((A=n[0])==null?void 0:A.id)},[n,m]),w.useEffect(()=>{const A=k=>{k.key==="Escape"&&e()};return document.addEventListener("keydown",A),()=>{document.removeEventListener("keydown",A)}},[e]);const j=n==null?void 0:n.find(A=>A.id===m),C=w.useCallback(()=>{const A=[];if(!m||!h)return A;const k=480,_=1080,B=720,F=840,G=(r??[]).filter(ee=>ee.dentistaId===m&&new Date(ee.start).toISOString().split("T")[0]===h).map(ee=>({start:new Date(ee.start).getHours()*60+new Date(ee.start).getMinutes(),end:new Date(ee.end).getHours()*60+new Date(ee.end).getMinutes()}));for(let ee=k;ee<_;ee+=d){const ne=ee,oe=ee+d;if(oe>_||ne>=B&&neB&&oe<=F||neF)continue;if(!G.some(he=>ne>=he.start&&nehe.start&&oe<=he.end||nehe.end)){const he=Math.floor(ne/60),H=ne%60;A.push({time:`${String(he).padStart(2,"0")}:${String(H).padStart(2,"0")}`,available:!0})}}return A},[m,h,r,d])(),O=async A=>{if(A.preventDefault(),!h||!b||!m||!N){c.error("PREENCHA TODOS OS CAMPOS PARA AGENDAR.");return}const k=new Date(`${h}T${b}:00`),_=new Date(k.getTime()+d*6e4);try{await J.salvarAgendamento({pacienteNome:t.nome,dentistaId:m,start:k.toISOString(),end:_.toISOString(),status:"Pendente",procedimento:N.toUpperCase()}),c.success(`AGENDAMENTO PARA ${t.nome} SALVO!`),i(),e()}catch{c.error("ERRO AO SALVAR AGENDAMENTO.")}};return s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-40 z-50 flex items-center justify-center backdrop-blur-sm p-0",children:s.jsxs("form",{onSubmit:O,className:"bg-white shadow-2xl w-full h-dvh md:w-[96vw] md:h-[98vh] rounded-none md:rounded-xl flex flex-col animate-in fade-in zoom-in-50 duration-200",children:[s.jsx("div",{className:"p-5 border-b border-gray-200",children:s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsxs("h2",{className:"text-lg font-bold text-gray-800 flex items-center gap-2",children:[s.jsx(Et,{size:20,className:"text-orange-500"})," AGENDAR CONSULTA"]}),s.jsx("button",{type:"button",onClick:e,className:"text-gray-400 hover:text-gray-600",children:s.jsx(Qe,{size:20})})]})}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-bold text-gray-500 uppercase",children:"PACIENTE"}),s.jsx("div",{className:"w-full bg-gray-100 p-3 rounded-lg mt-1 font-bold text-gray-800 uppercase",children:t.nome})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-bold text-gray-500 uppercase",children:"DENTISTA RESPONSÁVEL"}),s.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s.jsx("select",{value:m,onChange:A=>v(A.target.value),className:"w-full border border-gray-300 rounded-lg p-2.5 bg-white uppercase-select",children:n==null?void 0:n.map(A=>s.jsx("option",{value:A.id,children:A.nome},A.id))}),s.jsx("div",{className:"w-7 h-7 rounded-full border-2 border-white shadow flex-shrink-0",style:{backgroundColor:(j==null?void 0:j.corAgenda)||"#ccc"}})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-bold text-gray-500 uppercase",children:"DATA"}),s.jsx("input",{type:"date",value:h,onChange:A=>p(A.target.value),className:"w-full mt-1 border border-gray-300 rounded-lg p-2.5"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-bold text-gray-500 uppercase",children:"TEMPO"}),s.jsxs("select",{value:d,onChange:A=>f(Number(A.target.value)),className:"w-full mt-1 border border-gray-300 rounded-lg p-2.5 bg-white uppercase-select",children:[s.jsx("option",{value:15,children:"15 MIN"}),s.jsx("option",{value:30,children:"30 MIN"}),s.jsx("option",{value:45,children:"45 MIN"}),s.jsx("option",{value:60,children:"60 MIN"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-bold text-gray-500 uppercase",children:"HORÁRIOS"}),s.jsxs("div",{className:"grid grid-cols-6 gap-2 mt-2",children:[C.map(A=>s.jsx("button",{type:"button",onClick:()=>y(A.time),className:`py-2 rounded-lg text-sm font-bold border transition-colors ${b===A.time?"bg-blue-600 text-white border-blue-600":"bg-white border-gray-300 hover:border-blue-500"}`,children:A.time},A.time)),C.length===0&&s.jsx("p",{className:"col-span-6 text-center text-xs text-gray-500 p-4 bg-gray-50 rounded-lg",children:"NENHUM HORÁRIO DISPONÍVEL PARA ESTA DATA/DURAÇÃO."})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-bold text-gray-500 uppercase",children:"PROCEDIMENTO"}),s.jsx("input",{type:"text",value:N,onChange:A=>S(A.target.value.toUpperCase()),placeholder:"EX: AVALIAÇÃO...",className:"w-full mt-1 border border-gray-300 rounded-lg p-2.5 uppercase-input"})]})]}),s.jsxs("div",{className:"p-4 bg-gray-50 border-t border-gray-200 flex justify-end gap-3",children:[s.jsx("button",{type:"button",onClick:e,className:"px-6 py-2 bg-gray-200 hover:bg-gray-300 text-gray-700 font-bold rounded-lg transition-colors text-sm uppercase",children:"CANCELAR"}),s.jsx("button",{type:"submit",className:"px-6 py-2 bg-orange-500 hover:bg-orange-600 text-white font-bold rounded-lg shadow-sm transition-colors text-sm uppercase",children:"CONFIRMAR"})]})]})})},_M=({onClose:t,onSaved:e})=>{const n=Fe(),[r,i]=w.useState({nome:"",cpf:"",telefone:"",dataNascimento:"",convenio:"",email:""}),[c,d]=w.useState(null),[f,h]=w.useState(""),[p,b]=w.useState(null),{data:y}=_e(J.getPlanos);w.useEffect(()=>{const N=S=>{S.key==="Escape"&&t()};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[t]);const m=async N=>{if(N.preventDefault(),!r.nome||!r.cpf){n.error("PREENCHA NOME E CPF.");return}try{const S=Date.now().toString();await J.savePaciente({...r,id:S,grupoFamiliarId:c==null?void 0:c.id,grupoFamiliarRelacao:f||void 0,indicadoPorId:p==null?void 0:p.id}),n.success("PACIENTE CADASTRADO!"),e(),t()}catch{n.error("ERRO AO CADASTRAR PACIENTE.")}},v="w-full border border-gray-200 rounded-lg p-2.5 text-sm focus:ring-2 focus:ring-blue-100 focus:border-blue-300 outline-none";return s.jsx("div",{className:"fixed inset-0 bg-black/40 z-50 flex items-center justify-center backdrop-blur-sm p-0",children:s.jsxs("div",{className:"bg-white shadow-2xl w-full h-dvh md:w-[96vw] md:h-[98vh] rounded-none md:rounded-2xl flex flex-col animate-in fade-in zoom-in-50 duration-200",children:[s.jsxs("div",{className:"p-5 border-b border-gray-100 flex justify-between items-center",children:[s.jsxs("h2",{className:"text-sm font-black text-gray-800 uppercase flex items-center gap-2",children:[s.jsx(ft,{size:16,className:"text-green-500"})," Novo Paciente"]}),s.jsx("button",{onClick:t,className:"text-gray-400 hover:text-gray-600",children:s.jsx(Qe,{size:18})})]}),s.jsxs("form",{onSubmit:m,className:"flex-1 overflow-y-auto p-5 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"Nome Completo *"}),s.jsx("input",{required:!0,value:r.nome,onChange:N=>i(S=>({...S,nome:N.target.value.toUpperCase()})),className:v,placeholder:"NOME COMPLETO"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"CPF *"}),s.jsx("input",{required:!0,value:r.cpf,onChange:N=>i(S=>({...S,cpf:N.target.value})),className:v,placeholder:"000.000.000-00"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"Telefone"}),s.jsx("input",{value:r.telefone,onChange:N=>i(S=>({...S,telefone:N.target.value})),className:v,placeholder:"(67) 99999-9999"})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"Nascimento"}),s.jsx("input",{type:"date",value:r.dataNascimento,onChange:N=>i(S=>({...S,dataNascimento:N.target.value})),className:v})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"Convênio"}),s.jsxs("select",{value:r.convenio,onChange:N=>i(S=>({...S,convenio:N.target.value})),className:v,children:[s.jsx("option",{value:"",children:"— Particular —"}),y==null?void 0:y.map(N=>s.jsx("option",{value:N.nome,children:N.nome},N.id))]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"E-mail"}),s.jsx("input",{type:"email",value:r.email,onChange:N=>i(S=>({...S,email:N.target.value})),className:v,placeholder:"email@exemplo.com"})]}),s.jsxs("div",{className:"border-t border-gray-100 pt-3 space-y-3",children:[s.jsx(Yd,{label:"Familiar (vínculo)",placeholder:"Buscar paciente familiar...",value:c,onSelect:N=>{d({id:N.id,nome:N.nome})},onClear:()=>{d(null),h("")},fetchFn:N=>J.getPacientes(N).then(S=>S.data),renderOption:N=>s.jsxs("span",{className:"flex items-center gap-2 w-full",children:[s.jsx($n,{size:12,className:"text-indigo-400 flex-shrink-0"}),s.jsx("span",{className:"font-bold flex-1",children:N.nome}),s.jsx("span",{className:"text-[10px] text-gray-400",children:N.cpf})]})}),c&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"Parentesco"}),s.jsx("input",{list:"relacoes-list-novo",value:f,onChange:N=>h(N.target.value.toUpperCase()),placeholder:"EX: MÃE, PAI, IRMÃO...",className:v}),s.jsx("datalist",{id:"relacoes-list-novo",children:iS.map(N=>s.jsx("option",{value:N},N))})]}),s.jsx(Yd,{label:"Indicado por",placeholder:"Buscar paciente que indicou...",value:p,onSelect:N=>b({id:N.id,nome:N.nome}),onClear:()=>b(null),fetchFn:N=>J.getPacientes(N).then(S=>S.data),renderOption:N=>s.jsxs("span",{className:"flex items-center gap-2 w-full",children:[s.jsx($l,{size:12,className:"text-green-400 flex-shrink-0"}),s.jsx("span",{className:"font-bold flex-1",children:N.nome}),s.jsx("span",{className:"text-[10px] text-gray-400",children:N.cpf})]})})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx("button",{type:"button",onClick:t,className:"px-5 py-2 bg-gray-100 hover:bg-gray-200 text-gray-700 font-bold rounded-lg text-xs uppercase",children:"Cancelar"}),s.jsxs("button",{type:"submit",className:"px-5 py-2 bg-green-600 hover:bg-green-700 text-white font-bold rounded-lg text-xs uppercase flex items-center gap-1.5",children:[s.jsx(ft,{size:14})," Cadastrar"]})]})]})]})})},MM=({patient:t,onClose:e})=>{const{data:n,isLoading:r}=_e(J.getAgendamentos),i=(n==null?void 0:n.filter(c=>c.pacienteNome===t.nome))||[];return w.useEffect(()=>{const c=d=>{d.key==="Escape"&&e()};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[e]),s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-40 z-50 flex items-center justify-center backdrop-blur-sm p-0",children:s.jsxs("div",{className:"bg-white shadow-2xl w-full h-dvh md:w-[96vw] md:h-[98vh] rounded-none md:rounded-xl flex flex-col animate-in fade-in zoom-in-50 duration-200",children:[s.jsxs("div",{className:"p-5 border-b border-gray-200 flex justify-between items-center",children:[s.jsxs("h2",{className:"text-base font-bold text-gray-800 uppercase",children:["HISTÓRICO — ",t.nome]}),s.jsx("button",{onClick:e,className:"text-gray-400 hover:text-gray-600",children:s.jsx(Qe,{size:20})})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-2",children:[r&&s.jsx("p",{className:"text-center text-gray-400 text-sm",children:"CARREGANDO..."}),!r&&i.length===0&&s.jsx("p",{className:"text-center text-gray-400 text-sm py-6",children:"NENHUM AGENDAMENTO ENCONTRADO."}),i.map(c=>s.jsxs("div",{className:"flex items-center justify-between border border-gray-100 rounded-lg p-3 bg-gray-50",children:[s.jsxs("div",{children:[s.jsx("p",{className:"font-bold text-gray-800 text-sm uppercase",children:c.procedimento}),s.jsx("p",{className:"text-xs text-gray-500",children:new Date(c.start).toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})})]}),s.jsx("span",{className:`text-xs font-bold px-2 py-1 rounded-full uppercase ${c.status==="Confirmado"?"bg-green-100 text-green-700":c.status==="Pendente"?"bg-amber-100 text-amber-700":"bg-gray-100 text-gray-600"}`,children:c.status})]},c.id))]}),s.jsx("div",{className:"p-4 border-t border-gray-200 flex justify-end",children:s.jsx("button",{onClick:e,className:"px-6 py-2 bg-gray-100 hover:bg-gray-200 text-gray-700 font-bold rounded-lg text-sm uppercase",children:"FECHAR"})})]})})},IM=["AC","AL","AP","AM","BA","CE","DF","ES","GO","MA","MT","MS","MG","PA","PB","PR","PE","PI","RJ","RN","RS","RO","RR","SC","SP","SE","TO"],vp=["Dados","Família","Endereço","Histórico"],LM=({patient:t,onClose:e,onSaved:n})=>{const r=Fe(),{data:i}=_e(J.getPlanos),{data:c}=_e(J.getAgendamentos),[d,f]=w.useState(0),[h,p]=w.useState({...t,dataNascimento:RM(t.dataNascimento)}),[b,y]=w.useState(t.grupoFamiliarId?{id:t.grupoFamiliarId,nome:t.grupoFamiliarNome||""}:null),[m,v]=w.useState(t.grupoFamiliarRelacao||""),[N,S]=w.useState(t.indicadoPorId?{id:t.indicadoPorId,nome:t.indicadoPorNome||""}:null),j=(c??[]).filter(O=>O.pacienteNome===t.nome);w.useEffect(()=>{const O=A=>{A.key==="Escape"&&e()};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[e]);const R=async()=>{try{const{grupoFamiliarNome:O,indicadoPorNome:A,...k}=h;await J.updatePaciente({...k,grupoFamiliarId:b==null?void 0:b.id,grupoFamiliarRelacao:m||void 0,indicadoPorId:N==null?void 0:N.id}),r.success("PACIENTE ATUALIZADO!"),n(),e()}catch{r.error("ERRO AO SALVAR.")}},C="w-full border border-gray-200 rounded-lg p-2.5 text-sm focus:ring-2 focus:ring-blue-100 focus:border-blue-300 outline-none";return s.jsx("div",{className:"fixed inset-0 bg-black/40 z-50 flex items-center justify-center backdrop-blur-sm p-0",children:s.jsxs("div",{className:"bg-white shadow-2xl w-full h-dvh md:w-[96vw] md:h-[98vh] rounded-none md:rounded-2xl flex flex-col animate-in fade-in zoom-in-50 duration-200",children:[s.jsxs("div",{className:"p-5 border-b border-gray-100 flex justify-between items-center flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Mo,{size:15,className:"text-blue-500"}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-sm font-black text-gray-800 uppercase",children:"Editar Paciente"}),s.jsx("p",{className:"text-[10px] text-gray-400 font-medium uppercase",children:t.nome})]})]}),s.jsx("button",{onClick:e,className:"text-gray-400 hover:text-gray-600",children:s.jsx(Qe,{size:18})})]}),s.jsx("div",{className:"px-6 pt-4 pb-0 flex-shrink-0",children:s.jsx("div",{className:"flex items-center",children:vp.map((O,A)=>s.jsxs(Ve.Fragment,{children:[s.jsxs("button",{onClick:()=>f(A),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full text-[10px] font-black uppercase transition-all whitespace-nowrap ${d===A?"bg-blue-600 text-white":Ap(A=>({...A,nome:O.target.value.toUpperCase()})),className:C})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"CPF"}),s.jsx("input",{value:h.cpf,onChange:O=>p(A=>({...A,cpf:O.target.value})),className:C})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"Telefone"}),s.jsx("input",{value:h.telefone,onChange:O=>p(A=>({...A,telefone:O.target.value})),className:C})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"Nascimento"}),s.jsx("input",{type:"date",value:h.dataNascimento,onChange:O=>p(A=>({...A,dataNascimento:O.target.value})),className:C})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"Convênio"}),s.jsxs("select",{value:h.convenio||"",onChange:O=>p(A=>({...A,convenio:O.target.value})),className:C,children:[s.jsx("option",{value:"",children:"— Particular —"}),i==null?void 0:i.map(O=>s.jsx("option",{value:O.nome,children:O.nome},O.id))]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"E-mail"}),s.jsx("input",{type:"email",value:h.email||"",onChange:O=>p(A=>({...A,email:O.target.value})),className:C})]})]}),d===1&&s.jsxs("div",{className:"space-y-4",children:[s.jsx(Yd,{label:"Familiar (vínculo)",placeholder:"Buscar paciente familiar...",value:b,onSelect:O=>{y({id:O.id,nome:O.nome})},onClear:()=>{y(null),v("")},fetchFn:O=>J.getPacientes(O).then(A=>A.data),renderOption:O=>s.jsxs("span",{className:"flex items-center gap-2 w-full",children:[s.jsx($n,{size:12,className:"text-indigo-400 flex-shrink-0"}),s.jsx("span",{className:"font-bold flex-1",children:O.nome}),s.jsx("span",{className:"text-[10px] text-gray-400",children:O.cpf})]})}),b&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"Parentesco"}),s.jsx("input",{list:"relacoes-list-editar",value:m,onChange:O=>v(O.target.value.toUpperCase()),placeholder:"EX: MÃE, PAI, IRMÃO...",className:C}),s.jsx("datalist",{id:"relacoes-list-editar",children:iS.map(O=>s.jsx("option",{value:O},O))})]}),s.jsx(Yd,{label:"Indicado por",placeholder:"Buscar paciente que indicou...",value:N,onSelect:O=>S({id:O.id,nome:O.nome}),onClear:()=>S(null),fetchFn:O=>J.getPacientes(O).then(A=>A.data),renderOption:O=>s.jsxs("span",{className:"flex items-center gap-2 w-full",children:[s.jsx($l,{size:12,className:"text-green-400 flex-shrink-0"}),s.jsx("span",{className:"font-bold flex-1",children:O.nome}),s.jsx("span",{className:"text-[10px] text-gray-400",children:O.cpf})]})})]}),d===2&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"CEP"}),s.jsx("input",{value:h.cep||"",onChange:O=>p(A=>({...A,cep:O.target.value})),className:C,placeholder:"00000-000",maxLength:9})]}),s.jsxs("div",{className:"col-span-2",children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"Logradouro"}),s.jsx("input",{value:h.logradouro||"",onChange:O=>p(A=>({...A,logradouro:O.target.value.toUpperCase()})),className:C,placeholder:"RUA, AV, TRAVESSA..."})]})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"Número"}),s.jsx("input",{value:h.numero||"",onChange:O=>p(A=>({...A,numero:O.target.value})),className:C,placeholder:"123"})]}),s.jsxs("div",{className:"col-span-2",children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"Complemento"}),s.jsx("input",{value:h.complemento||"",onChange:O=>p(A=>({...A,complemento:O.target.value.toUpperCase()})),className:C,placeholder:"APTO, BLOCO..."})]})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("div",{className:"col-span-2",children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"Bairro"}),s.jsx("input",{value:h.bairro||"",onChange:O=>p(A=>({...A,bairro:O.target.value.toUpperCase()})),className:C,placeholder:"BAIRRO"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"UF"}),s.jsxs("select",{value:h.estado||"",onChange:O=>p(A=>({...A,estado:O.target.value})),className:C,children:[s.jsx("option",{value:"",children:"—"}),IM.map(O=>s.jsx("option",{children:O},O))]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"Cidade"}),s.jsx("input",{value:h.cidade||"",onChange:O=>p(A=>({...A,cidade:O.target.value.toUpperCase()})),className:C,placeholder:"CIDADE"})]})]}),d===3&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1",children:"Observações Clínicas"}),s.jsx("textarea",{rows:4,value:h.observacoes||"",onChange:O=>p(A=>({...A,observacoes:O.target.value})),className:C+" resize-none",placeholder:"ALERGIAS, HISTÓRICO MÉDICO, OBSERVAÇÕES..."})]}),s.jsxs("div",{children:[s.jsxs("p",{className:"text-[10px] font-black text-gray-500 uppercase tracking-wider mb-2",children:["Histórico de Atendimentos ",s.jsxs("span",{className:"text-blue-600",children:["(",j.length,")"]})]}),j.length===0&&s.jsx("p",{className:"text-xs text-gray-400 text-center py-4 border-2 border-dashed border-gray-100 rounded-xl",children:"Nenhum atendimento registrado."}),s.jsx("div",{className:"space-y-1.5 max-h-52 overflow-y-auto",children:j.map(O=>s.jsxs("div",{className:"flex items-center justify-between border border-gray-100 rounded-lg p-2.5 bg-gray-50/70",children:[s.jsxs("div",{children:[s.jsx("p",{className:"font-bold text-gray-800 text-xs uppercase",children:O.procedimento}),s.jsx("p",{className:"text-[10px] text-gray-400",children:new Date(O.start).toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),s.jsx("span",{className:`text-[9px] font-black px-2 py-0.5 rounded-full uppercase ${O.status==="Confirmado"?"bg-green-100 text-green-700":O.status==="Pendente"?"bg-amber-100 text-amber-700":O.status==="Faltou"?"bg-red-100 text-red-600":"bg-gray-100 text-gray-600"}`,children:O.status})]},O.id))})]})]})]}),s.jsxs("div",{className:"p-4 border-t border-gray-100 flex justify-between items-center flex-shrink-0",children:[s.jsxs("button",{type:"button",onClick:()=>d>0?f(O=>O-1):e(),className:"px-5 py-2 bg-gray-100 hover:bg-gray-200 text-gray-700 font-bold rounded-lg text-xs uppercase flex items-center gap-1.5",children:[s.jsx(Bs,{size:14})," ",d===0?"Cancelar":"Voltar"]}),df(O=>O+1),className:"px-5 py-2 bg-blue-600 hover:bg-blue-700 text-white font-bold rounded-lg text-xs uppercase flex items-center gap-1.5",children:["Próximo ",s.jsx(Ts,{size:14})]}):s.jsxs("button",{type:"button",onClick:R,className:"px-5 py-2 bg-green-600 hover:bg-green-700 text-white font-bold rounded-lg text-xs uppercase flex items-center gap-1.5",children:[s.jsx(Io,{size:14})," Salvar Tudo"]})]})]})})},zM=({patient:t,onClose:e})=>{const{data:n,isLoading:r}=_e(J.getAgendamentos),i=(n??[]).filter(h=>h.pacienteNome===t.nome),c=i.filter(h=>h.status==="Concluido"),d=i.filter(h=>h.status==="Faltou"),f=c.reduce((h,p)=>(h[p.procedimento]=(h[p.procedimento]||0)+1,h),{});return w.useEffect(()=>{const h=p=>{p.key==="Escape"&&e()};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[e]),s.jsx("div",{className:"fixed inset-0 bg-black/40 z-50 flex items-center justify-center backdrop-blur-sm p-0",children:s.jsxs("div",{className:"bg-white shadow-2xl w-full h-dvh md:w-[96vw] md:h-[98vh] rounded-none md:rounded-2xl flex flex-col animate-in fade-in zoom-in-50 duration-200",children:[s.jsxs("div",{className:"p-5 border-b border-gray-100 flex items-center justify-between flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-8 h-8 bg-teal-100 rounded-lg flex items-center justify-center",children:s.jsx(ua,{size:16,className:"text-teal-600"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-black text-gray-800 uppercase",children:"Tratamentos"}),s.jsx("p",{className:"text-[10px] text-gray-400 font-medium uppercase",children:t.nome})]})]}),s.jsx("button",{onClick:e,className:"text-gray-400 hover:text-gray-600",children:s.jsx(Qe,{size:18})})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-3 p-5 flex-shrink-0",children:[s.jsxs("div",{className:"bg-blue-50 rounded-xl p-3 text-center",children:[s.jsx("p",{className:"text-2xl font-black text-blue-600",children:i.length}),s.jsx("p",{className:"text-[10px] font-bold text-blue-400 uppercase",children:"Total Consultas"})]}),s.jsxs("div",{className:"bg-green-50 rounded-xl p-3 text-center",children:[s.jsx("p",{className:"text-2xl font-black text-green-600",children:c.length}),s.jsx("p",{className:"text-[10px] font-bold text-green-400 uppercase",children:"Concluídas"})]}),s.jsxs("div",{className:"bg-red-50 rounded-xl p-3 text-center",children:[s.jsx("p",{className:"text-2xl font-black text-red-600",children:d.length}),s.jsx("p",{className:"text-[10px] font-bold text-red-400 uppercase",children:"Faltas"})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto px-5 pb-5 space-y-5",children:[Object.keys(f).length>0&&s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] font-black text-gray-500 uppercase tracking-wider mb-2",children:"Procedimentos Realizados"}),s.jsx("div",{className:"space-y-1.5",children:Object.entries(f).sort(([,h],[,p])=>p-h).map(([h,p])=>s.jsxs("div",{className:"flex items-center justify-between bg-gray-50 rounded-lg px-3 py-2",children:[s.jsx("p",{className:"text-xs font-bold text-gray-700 uppercase",children:h}),s.jsxs("span",{className:"text-[10px] font-black bg-blue-100 text-blue-700 px-2 py-0.5 rounded-full",children:[p,"x"]})]},h))})]}),s.jsxs("div",{children:[s.jsxs("p",{className:"text-[10px] font-black text-gray-500 uppercase tracking-wider mb-2",children:["Histórico Cronológico (",i.length,")"]}),r&&s.jsx("p",{className:"text-xs text-gray-400 text-center py-4",children:"Carregando..."}),!r&&i.length===0&&s.jsx("p",{className:"text-xs text-gray-400 text-center py-4 border-2 border-dashed border-gray-100 rounded-xl",children:"Nenhum atendimento registrado."}),s.jsx("div",{className:"space-y-1.5",children:[...i].sort((h,p)=>new Date(p.start).getTime()-new Date(h.start).getTime()).map(h=>s.jsxs("div",{className:"flex items-center justify-between border border-gray-100 rounded-lg p-2.5",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"font-bold text-gray-800 text-xs uppercase truncate",children:h.procedimento}),s.jsx("p",{className:"text-[10px] text-gray-400",children:new Date(h.start).toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),s.jsx("span",{className:`text-[9px] font-black px-2 py-0.5 rounded-full uppercase flex-shrink-0 ml-2 ${h.status==="Concluido"?"bg-green-100 text-green-700":h.status==="Confirmado"?"bg-blue-100 text-blue-700":h.status==="Pendente"?"bg-amber-100 text-amber-700":"bg-red-100 text-red-600"}`,children:h.status})]},h.id))})]})]}),s.jsx("div",{className:"p-4 border-t border-gray-100 flex justify-end flex-shrink-0",children:s.jsx("button",{onClick:e,className:"px-5 py-2 bg-gray-100 hover:bg-gray-200 text-gray-700 text-xs font-bold rounded-lg uppercase",children:"Fechar"})})]})})},PM=({patient:t,onClose:e})=>{const{data:n}=_e(J.getAgendamentos),r=(n??[]).filter(f=>f.pacienteNome===t.nome),i=r.filter(f=>f.status==="Concluido").length,c=r.filter(f=>f.status==="Faltou").length,d=new Date().toLocaleDateString("pt-BR",{day:"2-digit",month:"long",year:"numeric"});return w.useEffect(()=>{const f=h=>{h.key==="Escape"&&e()};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[e]),s.jsx("div",{className:"fixed inset-0 bg-black/40 z-50 flex items-center justify-center backdrop-blur-sm p-0",children:s.jsxs("div",{className:"bg-white shadow-2xl w-full h-dvh md:w-[96vw] md:h-[98vh] rounded-none md:rounded-2xl flex flex-col animate-in fade-in zoom-in-50 duration-200",children:[s.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between flex-shrink-0 print:hidden",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-8 h-8 bg-violet-100 rounded-lg flex items-center justify-center",children:s.jsx(ko,{size:16,className:"text-violet-600"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-black text-gray-800 uppercase",children:"Relatório do Paciente"}),s.jsx("p",{className:"text-[10px] text-gray-400 font-medium uppercase",children:t.nome})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:()=>window.print(),className:"flex items-center gap-1.5 px-3 py-2 bg-gray-900 text-white rounded-lg text-xs font-bold hover:bg-black",children:[s.jsx(Va,{size:13})," Imprimir"]}),s.jsx("button",{onClick:e,className:"text-gray-400 hover:text-gray-600",children:s.jsx(Qe,{size:18})})]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-6 print:p-0 print:bg-white",children:s.jsxs("div",{className:"max-w-2xl mx-auto bg-white rounded-2xl shadow-sm border border-gray-200 p-8 print:shadow-none print:rounded-none print:border-0 print:max-w-full space-y-6",children:[s.jsxs("div",{className:"border-b-2 border-gray-800 pb-4",children:[s.jsx("h1",{className:"text-lg font-black text-gray-900 uppercase",children:"Relatório do Paciente"}),s.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Gerado em ",d]})]}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-xs font-black text-gray-500 uppercase tracking-widest mb-3 border-b border-gray-100 pb-1",children:"Dados Pessoais"}),s.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-400 text-xs font-bold uppercase block",children:"Nome"}),s.jsx("p",{className:"font-bold text-gray-800 uppercase",children:t.nome})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-400 text-xs font-bold uppercase block",children:"CPF"}),s.jsx("p",{className:"font-bold text-gray-800",children:t.cpf||"—"})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-400 text-xs font-bold uppercase block",children:"Telefone"}),s.jsx("p",{className:"font-bold text-gray-800",children:t.telefone||"—"})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-400 text-xs font-bold uppercase block",children:"E-mail"}),s.jsx("p",{className:"font-bold text-gray-800",children:t.email||"—"})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-400 text-xs font-bold uppercase block",children:"Nascimento"}),s.jsx("p",{className:"font-bold text-gray-800",children:t.dataNascimento||"—"})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-400 text-xs font-bold uppercase block",children:"Convênio"}),s.jsx("p",{className:"font-bold text-gray-800",children:t.convenio||"Particular"})]})]})]}),(t.logradouro||t.cidade)&&s.jsxs("div",{children:[s.jsxs("h2",{className:"text-xs font-black text-gray-500 uppercase tracking-widest mb-3 border-b border-gray-100 pb-1 flex items-center gap-1",children:[s.jsx(HN,{size:11})," Endereço"]}),s.jsxs("p",{className:"text-sm text-gray-700",children:[[t.logradouro,t.numero,t.complemento].filter(Boolean).join(", "),t.bairro&&s.jsxs("span",{className:"block",children:[t.bairro,t.cidade&&` — ${t.cidade}/${t.estado}`]}),t.cep&&s.jsxs("span",{className:"block text-gray-400 text-xs",children:["CEP ",t.cep]})]})]}),(t.grupoFamiliarNome||t.indicadoPorNome)&&s.jsxs("div",{children:[s.jsx("h2",{className:"text-xs font-black text-gray-500 uppercase tracking-widest mb-3 border-b border-gray-100 pb-1",children:"Vínculos"}),s.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[t.grupoFamiliarNome&&s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-400 text-xs font-bold uppercase block",children:"Familiar"}),s.jsxs("p",{className:"font-bold text-gray-800 uppercase",children:[t.grupoFamiliarNome," ",t.grupoFamiliarRelacao&&`(${t.grupoFamiliarRelacao})`]})]}),t.indicadoPorNome&&s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-400 text-xs font-bold uppercase block",children:"Indicado por"}),s.jsx("p",{className:"font-bold text-gray-800 uppercase",children:t.indicadoPorNome})]})]})]}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-xs font-black text-gray-500 uppercase tracking-widest mb-3 border-b border-gray-100 pb-1",children:"Resumo de Atendimentos"}),s.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[s.jsxs("div",{className:"bg-blue-50 rounded-xl p-3 text-center",children:[s.jsx("p",{className:"text-xl font-black text-blue-600",children:r.length}),s.jsx("p",{className:"text-[10px] font-bold text-blue-400 uppercase",children:"Total"})]}),s.jsxs("div",{className:"bg-green-50 rounded-xl p-3 text-center",children:[s.jsx("p",{className:"text-xl font-black text-green-600",children:i}),s.jsx("p",{className:"text-[10px] font-bold text-green-400 uppercase",children:"Concluídos"})]}),s.jsxs("div",{className:"bg-red-50 rounded-xl p-3 text-center",children:[s.jsx("p",{className:"text-xl font-black text-red-600",children:c}),s.jsx("p",{className:"text-[10px] font-bold text-red-400 uppercase",children:"Faltas"})]})]}),s.jsx("div",{className:"space-y-1.5 max-h-48 overflow-y-auto",children:[...r].sort((f,h)=>new Date(h.start).getTime()-new Date(f.start).getTime()).slice(0,20).map(f=>s.jsxs("div",{className:"flex items-center justify-between border border-gray-100 rounded-lg px-3 py-2",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-bold text-gray-800 uppercase",children:f.procedimento}),s.jsx("p",{className:"text-[10px] text-gray-400",children:new Date(f.start).toLocaleDateString("pt-BR")})]}),s.jsx("span",{className:`text-[9px] font-black px-2 py-0.5 rounded-full uppercase ${f.status==="Concluido"?"bg-green-100 text-green-700":f.status==="Faltou"?"bg-red-100 text-red-600":"bg-amber-100 text-amber-700"}`,children:f.status})]},f.id))})]}),t.observacoes&&s.jsxs("div",{children:[s.jsx("h2",{className:"text-xs font-black text-gray-500 uppercase tracking-widest mb-3 border-b border-gray-100 pb-1",children:"Observações Clínicas"}),s.jsx("p",{className:"text-sm text-gray-700 italic",children:t.observacoes})]}),s.jsxs("div",{className:"pt-6 border-t-2 border-gray-800 flex justify-between items-end",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-gray-500",children:"Assinatura / Responsável"}),s.jsx("div",{className:"h-8"})]}),s.jsx("p",{className:"text-xs text-gray-400",children:d})]})]})})]})})},pd=({label:t,value:e})=>{const[n,r]=w.useState(!1),i=()=>{e&&navigator.clipboard.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1500)})};return s.jsxs("div",{className:"flex items-center justify-between bg-gray-50/70 border border-gray-200/50 rounded-lg px-2 py-1.5 gap-1 min-w-0",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-gray-400 text-[9px] font-bold uppercase leading-none mb-0.5",children:t}),s.jsx("p",{className:"text-gray-800 font-semibold text-xs truncate leading-tight",children:e||"—"})]}),e&&s.jsx("button",{onClick:i,className:"flex-shrink-0 text-gray-300 hover:text-blue-500 transition-colors ml-1",title:`Copiar ${t}`,children:n?s.jsx(da,{size:13,className:"text-green-500"}):s.jsx($C,{size:13})})]})},UM=[{key:"recentes",label:"Recentes"},{key:"az",label:"A→Z"},{key:"za",label:"Z→A"},{key:"convenio",label:"Convênio"}],BM=()=>{const[t,e]=w.useState(""),[n,r]=w.useState("recentes"),i=oS(t,500),c=w.useCallback(()=>J.getPacientes(i,n),[i,n]),{data:d,isLoading:f,error:h,refresh:p}=_e(c,[i,n]),b=(d==null?void 0:d.data)??[];d==null||d.total;const y=Fe(),[m,v]=w.useState({type:null,patient:null}),[N,S]=w.useState(null),[j,R]=w.useState(!1),C=w.useCallback(()=>v({type:null,patient:null}),[]);w.useEffect(()=>{if(!(m.type!==null&&m.type!=="agendamento"&&m.type!=="historico"&&m.type!=="editar"))return;const ce=he=>{he.key==="Escape"&&C()};return document.addEventListener("keydown",ce),()=>{document.removeEventListener("keydown",ce)}},[m.type,C]);const[O,A]=w.useState({tratamento:"",valorTotal:"",desconto:"",entrada:"",parcelas:1,vencimento:new Date().toISOString().split("T")[0]});w.useEffect(()=>{m.type==="asaas"&&A({tratamento:"",valorTotal:"",desconto:"",entrada:"",parcelas:1,vencimento:new Date().toISOString().split("T")[0]})},[m.type,m.patient]);const k=Q=>{const{name:ce,value:he}=Q.target;A(H=>({...H,[ce]:he}))},_=parseFloat(O.valorTotal)||0,B=parseFloat(O.desconto)||0,F=parseFloat(O.entrada)||0,G=_-B-F,ee=G>0&&O.parcelas>0?G/Number(O.parcelas):0,ne=Q=>{var ce;Q.preventDefault(),y.success(`COBRANÇA GERADA NO ASAAS PARA ${(ce=m.patient)==null?void 0:ce.nome}!`),C()},oe=b;return s.jsxs("div",{className:"h-full flex flex-col relative",children:[s.jsx(cn,{title:"PACIENTES",children:s.jsxs("button",{onClick:()=>R(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 transition-colors uppercase font-bold text-sm shadow-sm",children:[s.jsx(ft,{size:18}),"NOVO PACIENTE"]})}),s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(ha,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none",size:16}),s.jsx("input",{type:"text",placeholder:"Nome ou CPF...",className:"w-full pl-9 pr-3 py-2 border border-gray-200 rounded-lg text-sm focus:ring-2 focus:ring-blue-100 focus:border-blue-300 outline-none bg-white",value:t,onChange:Q=>e(Q.target.value.toUpperCase())})]}),s.jsx("div",{className:"flex items-center gap-1 bg-gray-100 rounded-lg p-1",children:UM.map(Q=>s.jsx("button",{onClick:()=>r(Q.key),className:`px-2.5 py-1 rounded-md text-[11px] font-bold transition-all whitespace-nowrap ${n===Q.key?"bg-white text-gray-800 shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:Q.label},Q.key))})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-3 overflow-y-auto pb-6",children:[f&&s.jsxs("div",{className:"col-span-3 text-center p-10 text-gray-500 uppercase font-bold flex justify-center items-center gap-2",children:[s.jsx(Ct,{className:"animate-spin"})," CARREGANDO DADOS DO POSTGRESQL..."]}),h&&s.jsxs("div",{className:"col-span-3 text-center p-10 text-red-600 uppercase font-bold",children:["ERRO AO CARREGAR: ",h.message]}),oe&&oe.map(Q=>s.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 shadow-sm hover:shadow-md transition-all duration-200 flex flex-col",children:[s.jsxs("div",{className:"px-3 pt-3 pb-2 flex-grow flex flex-col gap-2",children:[s.jsxs("div",{className:"flex items-start justify-between gap-1.5",children:[s.jsx("h3",{className:"font-bold text-blue-700 text-[11px] leading-snug uppercase break-words flex-1",children:Q.nome}),Q.convenio&&s.jsx("span",{className:"bg-green-100 text-green-700 text-[9px] font-black px-1.5 py-0.5 rounded-full uppercase shrink-0",children:Q.convenio})]}),(Q.grupoFamiliarNome||Q.indicadoPorNome)&&s.jsxs("div",{className:"flex flex-wrap gap-1",children:[Q.grupoFamiliarNome&&s.jsxs("button",{onClick:()=>S(Q),className:"flex items-center gap-1 bg-indigo-50 hover:bg-indigo-100 text-indigo-600 px-1.5 py-0.5 rounded-full text-[9px] font-bold uppercase transition-colors",children:[s.jsx($n,{size:9}),Q.grupoFamiliarRelacao?`${Q.grupoFamiliarRelacao}: ${Q.grupoFamiliarNome}`:Q.grupoFamiliarNome]}),Q.indicadoPorNome&&s.jsxs("span",{className:"flex items-center gap-1 bg-emerald-50 text-emerald-600 px-1.5 py-0.5 rounded-full text-[9px] font-bold uppercase",children:[s.jsx($l,{size:9}),Q.indicadoPorNome]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[s.jsx(pd,{label:"CPF",value:Q.cpf}),s.jsx(pd,{label:"Telefone",value:Q.telefone}),s.jsx(pd,{label:"Nascimento",value:Q.dataNascimento}),s.jsx(pd,{label:"Convênio",value:Q.convenio})]})]}),s.jsxs("div",{className:"flex border-t border-gray-100",children:[s.jsxs("button",{onClick:()=>v({type:"clinical",patient:Q}),className:"w-1/2 flex items-center justify-center gap-1.5 py-2 text-blue-600 hover:bg-blue-50 rounded-bl-xl text-[10px] font-bold transition-colors uppercase",children:[s.jsx(tv,{size:12})," Clínico"]}),s.jsx("div",{className:"border-l border-gray-100"}),s.jsxs("button",{onClick:()=>v({type:"financial",patient:Q}),className:"w-1/2 flex items-center justify-center gap-1.5 py-2 text-green-700 hover:bg-green-50 rounded-br-xl text-[10px] font-bold transition-colors uppercase",children:[s.jsx(Ba,{size:12})," Financeiro"]})]})]},Q.id))]}),N&&s.jsx(TM,{paciente:N,onClose:()=>S(null)}),j&&s.jsx(_M,{onClose:()=>R(!1),onSaved:p}),m.type==="editar"&&m.patient&&s.jsx(LM,{patient:m.patient,onClose:C,onSaved:p}),m.type==="historico"&&m.patient&&s.jsx(MM,{patient:m.patient,onClose:C}),m.type==="clinical"&&m.patient&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-40 z-50 flex items-center justify-center backdrop-blur-sm p-0",children:s.jsxs("div",{className:"bg-white shadow-2xl w-full h-dvh md:w-[96vw] md:h-[98vh] rounded-none md:rounded-2xl flex flex-col p-6 animate-in fade-in zoom-in-50 duration-200",children:[s.jsxs("div",{className:"flex justify-between items-center mb-2",children:[s.jsxs("div",{className:"flex items-center gap-3 text-gray-700 font-bold text-xl",children:[s.jsx(tv,{size:28,className:"text-gray-400"}),"Menu Clínico"]}),s.jsx("button",{onClick:C,className:"text-gray-400 hover:text-gray-600",children:s.jsx(Qe,{size:20})})]}),s.jsx("p",{className:"text-gray-500 text-sm mb-6 font-bold uppercase",children:m.patient.nome}),s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4 flex-1 content-start",children:[s.jsxs("button",{onClick:()=>v({type:"agendamento",patient:m.patient}),className:"flex flex-col items-center justify-center p-5 bg-white border border-gray-200 rounded-xl hover:border-orange-400 hover:bg-orange-50/50 transition-all group shadow-sm",children:[s.jsx(SC,{size:32,className:"text-orange-500 mb-2 group-hover:scale-110 transition-transform"}),s.jsx("span",{className:"font-bold text-gray-700 text-sm text-center",children:"AGENDAR"})]}),s.jsxs("button",{onClick:()=>v({type:"historico",patient:m.patient}),className:"flex flex-col items-center justify-center p-5 bg-white border border-gray-200 rounded-xl hover:border-sky-400 hover:bg-sky-50/50 transition-all group shadow-sm",children:[s.jsx(Et,{size:32,className:"text-sky-500 mb-2 group-hover:scale-110 transition-transform"}),s.jsx("span",{className:"font-bold text-gray-700 text-sm text-center",children:"AGENDAMENTOS"})]}),s.jsxs("button",{onClick:()=>v({type:"tratamentos",patient:m.patient}),className:"flex flex-col items-center justify-center p-5 bg-white border border-gray-200 rounded-xl hover:border-teal-400 hover:bg-teal-50/50 transition-all group shadow-sm",children:[s.jsx(ua,{size:32,className:"text-teal-500 mb-2 group-hover:scale-110 transition-transform"}),s.jsx("span",{className:"font-bold text-gray-700 text-sm text-center",children:"TRATAMENTOS"})]}),s.jsxs("button",{onClick:()=>{rS.getState().setPaciente(m.patient),C(),window.location.hash="#/lancargto"},className:"flex flex-col items-center justify-center p-5 bg-white border border-gray-200 rounded-xl hover:border-yellow-400 hover:bg-yellow-50/50 transition-all group shadow-sm",children:[s.jsx(so,{size:32,className:"text-yellow-600 mb-2 group-hover:scale-110 transition-transform"}),s.jsx("span",{className:"font-bold text-gray-700 text-sm text-center",children:"GTOs"})]}),s.jsxs("button",{onClick:()=>v({type:"doc-receita",patient:m.patient}),className:"flex flex-col items-center justify-center p-5 bg-white border border-gray-200 rounded-xl hover:border-red-400 hover:bg-red-50/50 transition-all group shadow-sm",children:[s.jsx(za,{size:32,className:"text-red-500 mb-2 group-hover:scale-110 transition-transform"}),s.jsx("span",{className:"font-bold text-gray-700 text-sm text-center",children:"RECEITA"})]}),s.jsxs("button",{onClick:()=>v({type:"doc-raiox",patient:m.patient}),className:"flex flex-col items-center justify-center p-5 bg-white border border-gray-200 rounded-xl hover:border-purple-400 hover:bg-purple-50/50 transition-all group shadow-sm",children:[s.jsx(YD,{size:32,className:"text-purple-500 mb-2 group-hover:scale-110 transition-transform"}),s.jsx("span",{className:"font-bold text-gray-700 text-sm text-center",children:"RAIO-X"})]}),s.jsxs("button",{onClick:()=>v({type:"relatorio-paciente",patient:m.patient}),className:"flex flex-col items-center justify-center p-5 bg-white border border-gray-200 rounded-xl hover:border-violet-400 hover:bg-violet-50/50 transition-all group shadow-sm",children:[s.jsx(ko,{size:32,className:"text-violet-500 mb-2 group-hover:scale-110 transition-transform"}),s.jsx("span",{className:"font-bold text-gray-700 text-sm text-center",children:"RELATÓRIOS"})]}),s.jsxs("button",{onClick:()=>v({type:"editar",patient:m.patient}),className:"flex flex-col items-center justify-center p-5 bg-white border border-gray-200 rounded-xl hover:border-blue-400 hover:bg-blue-50/50 transition-all group shadow-sm",children:[s.jsx(Mo,{size:32,className:"text-blue-500 mb-2 group-hover:scale-110 transition-transform"}),s.jsx("span",{className:"font-bold text-gray-700 text-sm text-center",children:"EDITAR DADOS"})]})]})]})}),m.type==="agendamento"&&m.patient&&s.jsx(kM,{patient:m.patient,onClose:C}),m.type==="doc-receita"&&m.patient&&s.jsx(fM,{paciente:m.patient,onClose:C}),m.type==="doc-raiox"&&m.patient&&s.jsx(gM,{paciente:m.patient,onClose:C}),m.type==="tratamentos"&&m.patient&&s.jsx(zM,{patient:m.patient,onClose:C}),m.type==="relatorio-paciente"&&m.patient&&s.jsx(PM,{patient:m.patient,onClose:C}),m.type==="lancar"&&m.patient&&s.jsx(wM,{patient:m.patient,onClose:C,onSaved:p}),m.type==="contrato"&&m.patient&&s.jsx(lS,{paciente:m.patient,onClose:C,onSaved:p}),m.type==="financial"&&m.patient&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-40 z-50 flex items-center justify-center backdrop-blur-sm p-0",children:s.jsxs("div",{className:"bg-white shadow-2xl w-full h-dvh md:w-[96vw] md:h-[98vh] rounded-none md:rounded-2xl flex flex-col p-6 animate-in fade-in zoom-in-50 duration-200",children:[s.jsxs("div",{className:"flex justify-between items-center mb-2",children:[s.jsxs("div",{className:"flex items-center gap-3 text-gray-700 font-bold text-xl",children:[s.jsx(OO,{size:28,className:"text-gray-400"}),"Menu Financeiro"]}),s.jsx("button",{onClick:C,className:"text-gray-400 hover:text-gray-600",children:s.jsx(Qe,{size:20})})]}),s.jsx("p",{className:"text-gray-500 text-sm mb-8 font-bold uppercase",children:m.patient.nome}),s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[s.jsxs("button",{onClick:()=>v({type:"lancar",patient:m.patient}),className:"flex flex-col items-center justify-center p-6 bg-white border border-gray-200 rounded-xl hover:border-green-400 hover:bg-green-50/50 transition-all group shadow-sm",children:[s.jsx(zN,{size:32,className:"text-green-500 mb-2 group-hover:scale-110 transition-transform"}),s.jsx("span",{className:"font-bold text-gray-700 text-sm",children:"LANÇAR"})]}),s.jsxs("button",{onClick:()=>v({type:"asaas",patient:m.patient}),className:"flex flex-col items-center justify-center p-6 bg-white border border-gray-200 rounded-xl hover:border-blue-400 hover:bg-blue-50/50 transition-all group shadow-sm",children:[s.jsx(LN,{size:32,className:"text-blue-600 mb-2 group-hover:scale-110 transition-transform"}),s.jsx("span",{className:"font-bold text-gray-700 text-sm",children:"ASAAS"})]}),s.jsxs("button",{onClick:()=>v({type:"historico",patient:m.patient}),className:"flex flex-col items-center justify-center p-6 bg-white border border-gray-200 rounded-xl hover:border-gray-400 hover:bg-gray-50/50 transition-all group shadow-sm",children:[s.jsx(gD,{size:32,className:"text-gray-500 mb-2 group-hover:scale-110 transition-transform"}),s.jsx("span",{className:"font-bold text-gray-700 text-sm",children:"HISTÓRICO"})]}),s.jsxs("button",{onClick:()=>v({type:"contrato",patient:m.patient}),className:"flex flex-col items-center justify-center p-6 bg-white border border-gray-200 rounded-xl hover:border-indigo-400 hover:bg-indigo-50/50 transition-all group shadow-sm",children:[s.jsx(za,{size:32,className:"text-indigo-500 mb-2 group-hover:scale-110 transition-transform"}),s.jsx("span",{className:"font-bold text-gray-700 text-sm",children:"CONTRATOS"})]})]})]})}),m.type==="asaas"&&m.patient&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-40 z-50 flex items-center justify-center backdrop-blur-sm p-0",children:s.jsx("div",{className:"bg-white shadow-2xl w-full h-dvh md:w-[96vw] md:h-[98vh] rounded-none md:rounded-xl flex flex-col animate-in fade-in zoom-in-50 duration-200",children:s.jsxs("form",{onSubmit:ne,children:[s.jsx("div",{className:"p-6 border-b border-gray-200",children:s.jsxs("div",{className:"flex justify-between items-start",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-bold text-gray-800 flex items-center gap-2",children:[s.jsx("span",{className:"w-6 h-4 bg-yellow-400 rounded-sm flex items-center justify-center text-yellow-800",children:s.jsx(QC,{size:14})}),"PARCELAMENTO INTELIGENTE (ASAAS)"]}),s.jsxs("p",{className:"text-sm text-gray-500 mt-2",children:["Cliente: ",s.jsx("span",{className:"font-bold uppercase",children:m.patient.nome})]})]}),s.jsx("button",{type:"button",onClick:C,className:"text-gray-400 hover:text-gray-600",children:s.jsx(Qe,{size:20})})]})}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-bold text-gray-500 mb-1 uppercase",children:"TRATAMENTO"}),s.jsx("input",{type:"text",name:"tratamento",value:O.tratamento,onChange:k,placeholder:"EX: ORTODONTIA COMPLETA",className:"w-full border border-gray-300 rounded-md p-2 text-sm uppercase-input"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-bold text-gray-500 mb-1 uppercase",children:"VALOR TOTAL (R$)"}),s.jsx("input",{type:"number",step:"0.01",name:"valorTotal",value:O.valorTotal,onChange:k,placeholder:"0,00",className:"w-full border border-gray-300 rounded-md p-2 text-sm"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-bold text-gray-500 mb-1 uppercase",children:"DESCONTO (R$)"}),s.jsx("input",{type:"number",step:"0.01",name:"desconto",value:O.desconto,onChange:k,placeholder:"0,00",className:"w-full border border-gray-300 rounded-md p-2 text-sm"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-bold text-gray-500 mb-1 uppercase",children:"ENTRADA (R$)"}),s.jsx("input",{type:"number",step:"0.01",name:"entrada",value:O.entrada,onChange:k,placeholder:"0,00",className:"w-full border border-gray-300 rounded-md p-2 text-sm"})]}),s.jsxs("div",{className:"bg-blue-50/70 p-3 rounded-md flex justify-between items-center border border-blue-100/50",children:[s.jsx("span",{className:"font-semibold text-blue-700 text-sm",children:"SALDO A PARCELAR:"}),s.jsx("span",{className:"font-bold text-blue-700 text-lg",children:G.toLocaleString("pt-BR",{style:"currency",currency:"BRL"})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4 pt-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-bold text-gray-500 mb-1 uppercase",children:"PARCELAS (ATÉ 48X)"}),s.jsx("select",{name:"parcelas",value:O.parcelas,onChange:k,className:"w-full border border-gray-300 rounded-md p-2 text-sm bg-white",children:Array.from({length:48},(Q,ce)=>ce+1).map(Q=>s.jsxs("option",{value:Q,children:[Q,"x"]},Q))})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-bold text-gray-500 mb-1 uppercase",children:"VENCIMENTO 1ª PARCELA"}),s.jsx("input",{type:"date",name:"vencimento",value:O.vencimento,onChange:k,className:"w-full border border-gray-300 rounded-md p-2 text-sm"})]})]}),s.jsxs("div",{className:"text-center text-blue-600 font-bold text-lg py-2",children:[O.parcelas,"x DE ",ee.toLocaleString("pt-BR",{style:"currency",currency:"BRL"})]})]}),s.jsxs("div",{className:"p-6 bg-gray-50 border-t border-gray-200 flex justify-end gap-3",children:[s.jsx("button",{type:"button",onClick:C,className:"px-6 py-2 bg-gray-200 hover:bg-gray-300 text-gray-700 font-bold rounded-lg transition-colors text-sm uppercase",children:"CANCELAR"}),s.jsxs("button",{type:"submit",className:"px-6 py-2 bg-blue-600 hover:bg-blue-700 text-white font-bold rounded-lg shadow-sm flex items-center justify-center gap-2 transition-colors text-sm uppercase",children:[s.jsx(XD,{size:16}),"GERAR CARNÊ/PIX"]})]})]})})})]})};var Au,Se,cS,dS,Bl,ur,Xv,uS,fS,Qd={},hS=[],HM=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function Ds(t,e){for(var n in e)t[n]=e[n];return t}function pS(t){var e=t.parentNode;e&&e.removeChild(t)}function I(t,e,n){var r,i,c,d={};for(c in e)c=="key"?r=e[c]:c=="ref"?i=e[c]:d[c]=e[c];if(arguments.length>2&&(d.children=arguments.length>3?Au.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(c in t.defaultProps)d[c]===void 0&&(d[c]=t.defaultProps[c]);return Cd(t,d,r,i,null)}function Cd(t,e,n,r,i){var c={type:t,props:e,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:i??++cS};return i==null&&Se.vnode!=null&&Se.vnode(c),c}function Zt(){return{current:null}}function lt(t){return t.children}function GM(t,e,n,r,i){var c;for(c in n)c==="children"||c==="key"||c in e||Wd(t,c,null,n[c],r);for(c in e)i&&typeof e[c]!="function"||c==="children"||c==="key"||c==="value"||c==="checked"||n[c]===e[c]||Wd(t,c,e[c],n[c],r)}function Zv(t,e,n){e[0]==="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||HM.test(e)?n:n+"px"}function Wd(t,e,n,r,i){var c;e:if(e==="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof r=="string"&&(t.style.cssText=r=""),r)for(e in r)n&&e in n||Zv(t.style,e,"");if(n)for(e in n)r&&n[e]===r[e]||Zv(t.style,e,n[e])}else if(e[0]==="o"&&e[1]==="n")c=e!==(e=e.replace(/Capture$/,"")),e=e.toLowerCase()in t?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+c]=n,n?r||t.addEventListener(e,c?Jv:Kv,c):t.removeEventListener(e,c?Jv:Kv,c);else if(e!=="dangerouslySetInnerHTML"){if(i)e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!=="width"&&e!=="height"&&e!=="href"&&e!=="list"&&e!=="form"&&e!=="tabIndex"&&e!=="download"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e.indexOf("-")==-1?t.removeAttribute(e):t.setAttribute(e,n))}}function Kv(t){Bl=!0;try{return this.l[t.type+!1](Se.event?Se.event(t):t)}finally{Bl=!1}}function Jv(t){Bl=!0;try{return this.l[t.type+!0](Se.event?Se.event(t):t)}finally{Bl=!1}}function wn(t,e){this.props=t,this.context=e}function vo(t,e){if(e==null)return t.__?vo(t.__,t.__.__k.indexOf(t)+1):null;for(var n;ee&&ur.sort(function(h,p){return h.__v.__b-p.__v.__b}));Xd.__r=0}function mS(t,e,n,r,i,c,d,f,h,p){var b,y,m,v,N,S,j,R=r&&r.__k||hS,C=R.length;for(n.__k=[],b=0;b0?Cd(v.type,v.props,v.key,v.ref?v.ref:null,v.__v):v)!=null){if(v.__=n,v.__b=n.__b+1,(m=R[b])===null||m&&v.key==m.key&&v.type===m.type)R[b]=void 0;else for(y=0;y=0;e--)if((n=t.__k[e])&&(r=yS(n)))return r}return null}function tm(t,e,n,r,i,c,d,f,h){var p,b,y,m,v,N,S,j,R,C,O,A,k,_,B,F=e.type;if(e.constructor!==void 0)return null;n.__h!=null&&(h=n.__h,f=e.__e=n.__e,e.__h=null,c=[f]),(p=Se.__b)&&p(e);try{e:if(typeof F=="function"){if(j=e.props,R=(p=F.contextType)&&r[p.__c],C=p?R?R.props.value:p.__:r,n.__c?S=(b=e.__c=n.__c).__=b.__E:("prototype"in F&&F.prototype.render?e.__c=b=new F(j,C):(e.__c=b=new wn(j,C),b.constructor=F,b.render=qM),R&&R.sub(b),b.props=j,b.state||(b.state={}),b.context=C,b.__n=r,y=b.__d=!0,b.__h=[],b._sb=[]),b.__s==null&&(b.__s=b.state),F.getDerivedStateFromProps!=null&&(b.__s==b.state&&(b.__s=Ds({},b.__s)),Ds(b.__s,F.getDerivedStateFromProps(j,b.__s))),m=b.props,v=b.state,b.__v=e,y)F.getDerivedStateFromProps==null&&b.componentWillMount!=null&&b.componentWillMount(),b.componentDidMount!=null&&b.__h.push(b.componentDidMount);else{if(F.getDerivedStateFromProps==null&&j!==m&&b.componentWillReceiveProps!=null&&b.componentWillReceiveProps(j,C),!b.__e&&b.shouldComponentUpdate!=null&&b.shouldComponentUpdate(j,b.__s,C)===!1||e.__v===n.__v){for(e.__v!==n.__v&&(b.props=j,b.state=b.__s,b.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.forEach(function(G){G&&(G.__=e)}),O=0;O3;)n.pop()();if(n[1]>>1,1),e.i.removeChild(r)}}),No(I(ZM,{context:e.context},t.__v),e.l)):e.l&&e.componentWillUnmount()}function JM(t,e){var n=I(KM,{__v:t,i:e});return n.containerInfo=e,n}(gd.prototype=new wn).__a=function(t){var e=this,n=wS(e.__v),r=e.o.get(t);return r[0]++,function(i){var c=function(){e.props.revealOrder?(r.push(i),u1(e,t,r)):i()};n?n(c):c()}},gd.prototype.render=function(t){this.u=null,this.o=new Map;var e=Zd(t.children);t.revealOrder&&t.revealOrder[0]==="b"&&e.reverse();for(var n=e.length;n--;)this.o.set(e[n],this.u=[1,0,this.u]);return t.children},gd.prototype.componentDidUpdate=gd.prototype.componentDidMount=function(){var t=this;this.o.forEach(function(e,n){u1(t,n,e)})};var eI=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,tI=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,nI=typeof document<"u",aI=function(t){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/i:/fil|che|ra/i).test(t)};wn.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(t){Object.defineProperty(wn.prototype,t,{configurable:!0,get:function(){return this["UNSAFE_"+t]},set:function(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})});var f1=Se.event;function sI(){}function rI(){return this.cancelBubble}function lI(){return this.defaultPrevented}Se.event=function(t){return f1&&(t=f1(t)),t.persist=sI,t.isPropagationStopped=rI,t.isDefaultPrevented=lI,t.nativeEvent=t};var h1={configurable:!0,get:function(){return this.class}},p1=Se.vnode;Se.vnode=function(t){var e=t.type,n=t.props,r=n;if(typeof e=="string"){var i=e.indexOf("-")===-1;for(var c in r={},n){var d=n[c];nI&&c==="children"&&e==="noscript"||c==="value"&&"defaultValue"in n&&d==null||(c==="defaultValue"&&"value"in n&&n.value==null?c="value":c==="download"&&d===!0?d="":/ondoubleclick/i.test(c)?c="ondblclick":/^onchange(textarea|input)/i.test(c+e)&&!aI(n.type)?c="oninput":/^onfocus$/i.test(c)?c="onfocusin":/^onblur$/i.test(c)?c="onfocusout":/^on(Ani|Tra|Tou|BeforeInp|Compo)/.test(c)?c=c.toLowerCase():i&&tI.test(c)?c=c.replace(/[A-Z0-9]/g,"-$&").toLowerCase():d===null&&(d=void 0),/^oninput$/i.test(c)&&(c=c.toLowerCase(),r[c]&&(c="oninputCapture")),r[c]=d)}e=="select"&&r.multiple&&Array.isArray(r.value)&&(r.value=Zd(n.children).forEach(function(f){f.props.selected=r.value.indexOf(f.props.value)!=-1})),e=="select"&&r.defaultValue!=null&&(r.value=Zd(n.children).forEach(function(f){f.props.selected=r.multiple?r.defaultValue.indexOf(f.props.value)!=-1:r.defaultValue==f.props.value})),t.props=r,n.class!=n.className&&(h1.enumerable="className"in n,n.className!=null&&(r.class=n.className),Object.defineProperty(r,"className",h1))}t.$$typeof=eI,p1&&p1(t)};var g1=Se.__r;Se.__r=function(t){g1&&g1(t),t.__c};const CS=[],Kp=new Map;function nm(t){CS.push(t),Kp.forEach(e=>{OS(e,t)})}function iI(t){t.isConnected&&t.getRootNode&&DS(t.getRootNode())}function DS(t){let e=Kp.get(t);if(!e||!e.isConnected){if(e=t.querySelector("style[data-fullcalendar]"),!e){e=document.createElement("style"),e.setAttribute("data-fullcalendar","");const n=cI();n&&(e.nonce=n);const r=t===document?document.head:t,i=t===document?r.querySelector("script,link[rel=stylesheet],link[as=style],style"):r.firstChild;r.insertBefore(e,i)}Kp.set(t,e),oI(e)}}function oI(t){for(const e of CS)OS(t,e)}function OS(t,e){const{sheet:n}=t,r=n.cssRules.length;e.split("}").forEach((i,c)=>{i=i.trim(),i&&n.insertRule(i+"}",r+c)})}let jp;function cI(){return jp===void 0&&(jp=dI()),jp}function dI(){const t=document.querySelector('meta[name="csp-nonce"]');if(t&&t.hasAttribute("content"))return t.getAttribute("content");const e=document.querySelector("script[nonce]");return e&&e.nonce||""}typeof document<"u"&&DS(document);var uI=':root{--fc-small-font-size:.85em;--fc-page-bg-color:#fff;--fc-neutral-bg-color:hsla(0,0%,82%,.3);--fc-neutral-text-color:grey;--fc-border-color:#ddd;--fc-button-text-color:#fff;--fc-button-bg-color:#2c3e50;--fc-button-border-color:#2c3e50;--fc-button-hover-bg-color:#1e2b37;--fc-button-hover-border-color:#1a252f;--fc-button-active-bg-color:#1a252f;--fc-button-active-border-color:#151e27;--fc-event-bg-color:#3788d8;--fc-event-border-color:#3788d8;--fc-event-text-color:#fff;--fc-event-selected-overlay-color:rgba(0,0,0,.25);--fc-more-link-bg-color:#d0d0d0;--fc-more-link-text-color:inherit;--fc-event-resizer-thickness:8px;--fc-event-resizer-dot-total-width:8px;--fc-event-resizer-dot-border-width:1px;--fc-non-business-color:hsla(0,0%,84%,.3);--fc-bg-event-color:#8fdf82;--fc-bg-event-opacity:0.3;--fc-highlight-color:rgba(188,232,241,.3);--fc-today-bg-color:rgba(255,220,40,.15);--fc-now-indicator-color:red}.fc-not-allowed,.fc-not-allowed .fc-event{cursor:not-allowed}.fc{display:flex;flex-direction:column;font-size:1em}.fc,.fc *,.fc :after,.fc :before{box-sizing:border-box}.fc table{border-collapse:collapse;border-spacing:0;font-size:1em}.fc th{text-align:center}.fc td,.fc th{padding:0;vertical-align:top}.fc a[data-navlink]{cursor:pointer}.fc a[data-navlink]:hover{text-decoration:underline}.fc-direction-ltr{direction:ltr;text-align:left}.fc-direction-rtl{direction:rtl;text-align:right}.fc-theme-standard td,.fc-theme-standard th{border:1px solid var(--fc-border-color)}.fc-liquid-hack td,.fc-liquid-hack th{position:relative}@font-face{font-family:fcicons;font-style:normal;font-weight:400;src:url("data:application/x-font-ttf;charset=utf-8;base64,AAEAAAALAIAAAwAwT1MvMg8SBfAAAAC8AAAAYGNtYXAXVtKNAAABHAAAAFRnYXNwAAAAEAAAAXAAAAAIZ2x5ZgYydxIAAAF4AAAFNGhlYWQUJ7cIAAAGrAAAADZoaGVhB20DzAAABuQAAAAkaG10eCIABhQAAAcIAAAALGxvY2ED4AU6AAAHNAAAABhtYXhwAA8AjAAAB0wAAAAgbmFtZXsr690AAAdsAAABhnBvc3QAAwAAAAAI9AAAACAAAwPAAZAABQAAApkCzAAAAI8CmQLMAAAB6wAzAQkAAAAAAAAAAAAAAAAAAAABEAAAAAAAAAAAAAAAAAAAAABAAADpBgPA/8AAQAPAAEAAAAABAAAAAAAAAAAAAAAgAAAAAAADAAAAAwAAABwAAQADAAAAHAADAAEAAAAcAAQAOAAAAAoACAACAAIAAQAg6Qb//f//AAAAAAAg6QD//f//AAH/4xcEAAMAAQAAAAAAAAAAAAAAAQAB//8ADwABAAAAAAAAAAAAAgAANzkBAAAAAAEAAAAAAAAAAAACAAA3OQEAAAAAAQAAAAAAAAAAAAIAADc5AQAAAAABAWIAjQKeAskAEwAAJSc3NjQnJiIHAQYUFwEWMjc2NCcCnuLiDQ0MJAz/AA0NAQAMJAwNDcni4gwjDQwM/wANIwz/AA0NDCMNAAAAAQFiAI0CngLJABMAACUBNjQnASYiBwYUHwEHBhQXFjI3AZ4BAA0N/wAMJAwNDeLiDQ0MJAyNAQAMIw0BAAwMDSMM4uINIwwNDQAAAAIA4gC3Ax4CngATACcAACUnNzY0JyYiDwEGFB8BFjI3NjQnISc3NjQnJiIPAQYUHwEWMjc2NCcB87e3DQ0MIw3VDQ3VDSMMDQ0BK7e3DQ0MJAzVDQ3VDCQMDQ3zuLcMJAwNDdUNIwzWDAwNIwy4twwkDA0N1Q0jDNYMDA0jDAAAAgDiALcDHgKeABMAJwAAJTc2NC8BJiIHBhQfAQcGFBcWMjchNzY0LwEmIgcGFB8BBwYUFxYyNwJJ1Q0N1Q0jDA0Nt7cNDQwjDf7V1Q0N1QwkDA0Nt7cNDQwkDLfWDCMN1Q0NDCQMt7gMIw0MDNYMIw3VDQ0MJAy3uAwjDQwMAAADAFUAAAOrA1UAMwBoAHcAABMiBgcOAQcOAQcOARURFBYXHgEXHgEXHgEzITI2Nz4BNz4BNz4BNRE0JicuAScuAScuASMFITIWFx4BFx4BFx4BFREUBgcOAQcOAQcOASMhIiYnLgEnLgEnLgE1ETQ2Nz4BNz4BNz4BMxMhMjY1NCYjISIGFRQWM9UNGAwLFQkJDgUFBQUFBQ4JCRULDBgNAlYNGAwLFQkJDgUFBQUFBQ4JCRULDBgN/aoCVgQIBAQHAwMFAQIBAQIBBQMDBwQECAT9qgQIBAQHAwMFAQIBAQIBBQMDBwQECASAAVYRGRkR/qoRGRkRA1UFBAUOCQkVDAsZDf2rDRkLDBUJCA4FBQUFBQUOCQgVDAsZDQJVDRkLDBUJCQ4FBAVVAgECBQMCBwQECAX9qwQJAwQHAwMFAQICAgIBBQMDBwQDCQQCVQUIBAQHAgMFAgEC/oAZEhEZGRESGQAAAAADAFUAAAOrA1UAMwBoAIkAABMiBgcOAQcOAQcOARURFBYXHgEXHgEXHgEzITI2Nz4BNz4BNz4BNRE0JicuAScuAScuASMFITIWFx4BFx4BFx4BFREUBgcOAQcOAQcOASMhIiYnLgEnLgEnLgE1ETQ2Nz4BNz4BNz4BMxMzFRQWMzI2PQEzMjY1NCYrATU0JiMiBh0BIyIGFRQWM9UNGAwLFQkJDgUFBQUFBQ4JCRULDBgNAlYNGAwLFQkJDgUFBQUFBQ4JCRULDBgN/aoCVgQIBAQHAwMFAQIBAQIBBQMDBwQECAT9qgQIBAQHAwMFAQIBAQIBBQMDBwQECASAgBkSEhmAERkZEYAZEhIZgBEZGREDVQUEBQ4JCRUMCxkN/asNGQsMFQkIDgUFBQUFBQ4JCBUMCxkNAlUNGQsMFQkJDgUEBVUCAQIFAwIHBAQIBf2rBAkDBAcDAwUBAgICAgEFAwMHBAMJBAJVBQgEBAcCAwUCAQL+gIASGRkSgBkSERmAEhkZEoAZERIZAAABAOIAjQMeAskAIAAAExcHBhQXFjI/ARcWMjc2NC8BNzY0JyYiDwEnJiIHBhQX4uLiDQ0MJAzi4gwkDA0N4uINDQwkDOLiDCQMDQ0CjeLiDSMMDQ3h4Q0NDCMN4uIMIw0MDOLiDAwNIwwAAAABAAAAAQAAa5n0y18PPPUACwQAAAAAANivOVsAAAAA2K85WwAAAAADqwNVAAAACAACAAAAAAAAAAEAAAPA/8AAAAQAAAAAAAOrAAEAAAAAAAAAAAAAAAAAAAALBAAAAAAAAAAAAAAAAgAAAAQAAWIEAAFiBAAA4gQAAOIEAABVBAAAVQQAAOIAAAAAAAoAFAAeAEQAagCqAOoBngJkApoAAQAAAAsAigADAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAA4ArgABAAAAAAABAAcAAAABAAAAAAACAAcAYAABAAAAAAADAAcANgABAAAAAAAEAAcAdQABAAAAAAAFAAsAFQABAAAAAAAGAAcASwABAAAAAAAKABoAigADAAEECQABAA4ABwADAAEECQACAA4AZwADAAEECQADAA4APQADAAEECQAEAA4AfAADAAEECQAFABYAIAADAAEECQAGAA4AUgADAAEECQAKADQApGZjaWNvbnMAZgBjAGkAYwBvAG4Ac1ZlcnNpb24gMS4wAFYAZQByAHMAaQBvAG4AIAAxAC4AMGZjaWNvbnMAZgBjAGkAYwBvAG4Ac2ZjaWNvbnMAZgBjAGkAYwBvAG4Ac1JlZ3VsYXIAUgBlAGcAdQBsAGEAcmZjaWNvbnMAZgBjAGkAYwBvAG4Ac0ZvbnQgZ2VuZXJhdGVkIGJ5IEljb01vb24uAEYAbwBuAHQAIABnAGUAbgBlAHIAYQB0AGUAZAAgAGIAeQAgAEkAYwBvAE0AbwBvAG4ALgAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=") format("truetype")}.fc-icon{speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;display:inline-block;font-family:fcicons!important;font-style:normal;font-variant:normal;font-weight:400;height:1em;line-height:1;text-align:center;text-transform:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:1em}.fc-icon-chevron-left:before{content:"\\e900"}.fc-icon-chevron-right:before{content:"\\e901"}.fc-icon-chevrons-left:before{content:"\\e902"}.fc-icon-chevrons-right:before{content:"\\e903"}.fc-icon-minus-square:before{content:"\\e904"}.fc-icon-plus-square:before{content:"\\e905"}.fc-icon-x:before{content:"\\e906"}.fc .fc-button{border-radius:0;font-family:inherit;font-size:inherit;line-height:inherit;margin:0;overflow:visible;text-transform:none}.fc .fc-button:focus{outline:1px dotted;outline:5px auto -webkit-focus-ring-color}.fc .fc-button{-webkit-appearance:button}.fc .fc-button:not(:disabled){cursor:pointer}.fc .fc-button{background-color:transparent;border:1px solid transparent;border-radius:.25em;display:inline-block;font-size:1em;font-weight:400;line-height:1.5;padding:.4em .65em;text-align:center;-webkit-user-select:none;-moz-user-select:none;user-select:none;vertical-align:middle}.fc .fc-button:hover{text-decoration:none}.fc .fc-button:focus{box-shadow:0 0 0 .2rem rgba(44,62,80,.25);outline:0}.fc .fc-button:disabled{opacity:.65}.fc .fc-button-primary{background-color:var(--fc-button-bg-color);border-color:var(--fc-button-border-color);color:var(--fc-button-text-color)}.fc .fc-button-primary:hover{background-color:var(--fc-button-hover-bg-color);border-color:var(--fc-button-hover-border-color);color:var(--fc-button-text-color)}.fc .fc-button-primary:disabled{background-color:var(--fc-button-bg-color);border-color:var(--fc-button-border-color);color:var(--fc-button-text-color)}.fc .fc-button-primary:focus{box-shadow:0 0 0 .2rem rgba(76,91,106,.5)}.fc .fc-button-primary:not(:disabled).fc-button-active,.fc .fc-button-primary:not(:disabled):active{background-color:var(--fc-button-active-bg-color);border-color:var(--fc-button-active-border-color);color:var(--fc-button-text-color)}.fc .fc-button-primary:not(:disabled).fc-button-active:focus,.fc .fc-button-primary:not(:disabled):active:focus{box-shadow:0 0 0 .2rem rgba(76,91,106,.5)}.fc .fc-button .fc-icon{font-size:1.5em;vertical-align:middle}.fc .fc-button-group{display:inline-flex;position:relative;vertical-align:middle}.fc .fc-button-group>.fc-button{flex:1 1 auto;position:relative}.fc .fc-button-group>.fc-button.fc-button-active,.fc .fc-button-group>.fc-button:active,.fc .fc-button-group>.fc-button:focus,.fc .fc-button-group>.fc-button:hover{z-index:1}.fc-direction-ltr .fc-button-group>.fc-button:not(:first-child){border-bottom-left-radius:0;border-top-left-radius:0;margin-left:-1px}.fc-direction-ltr .fc-button-group>.fc-button:not(:last-child){border-bottom-right-radius:0;border-top-right-radius:0}.fc-direction-rtl .fc-button-group>.fc-button:not(:first-child){border-bottom-right-radius:0;border-top-right-radius:0;margin-right:-1px}.fc-direction-rtl .fc-button-group>.fc-button:not(:last-child){border-bottom-left-radius:0;border-top-left-radius:0}.fc .fc-toolbar{align-items:center;display:flex;justify-content:space-between}.fc .fc-toolbar.fc-header-toolbar{margin-bottom:1.5em}.fc .fc-toolbar.fc-footer-toolbar{margin-top:1.5em}.fc .fc-toolbar-title{font-size:1.75em;margin:0}.fc-direction-ltr .fc-toolbar>*>:not(:first-child){margin-left:.75em}.fc-direction-rtl .fc-toolbar>*>:not(:first-child){margin-right:.75em}.fc-direction-rtl .fc-toolbar-ltr{flex-direction:row-reverse}.fc .fc-scroller{-webkit-overflow-scrolling:touch;position:relative}.fc .fc-scroller-liquid{height:100%}.fc .fc-scroller-liquid-absolute{bottom:0;left:0;position:absolute;right:0;top:0}.fc .fc-scroller-harness{direction:ltr;overflow:hidden;position:relative}.fc .fc-scroller-harness-liquid{height:100%}.fc-direction-rtl .fc-scroller-harness>.fc-scroller{direction:rtl}.fc-theme-standard .fc-scrollgrid{border:1px solid var(--fc-border-color)}.fc .fc-scrollgrid,.fc .fc-scrollgrid table{table-layout:fixed;width:100%}.fc .fc-scrollgrid table{border-left-style:hidden;border-right-style:hidden;border-top-style:hidden}.fc .fc-scrollgrid{border-bottom-width:0;border-collapse:separate;border-right-width:0}.fc .fc-scrollgrid-liquid{height:100%}.fc .fc-scrollgrid-section,.fc .fc-scrollgrid-section table,.fc .fc-scrollgrid-section>td{height:1px}.fc .fc-scrollgrid-section-liquid>td{height:100%}.fc .fc-scrollgrid-section>*{border-left-width:0;border-top-width:0}.fc .fc-scrollgrid-section-footer>*,.fc .fc-scrollgrid-section-header>*{border-bottom-width:0}.fc .fc-scrollgrid-section-body table,.fc .fc-scrollgrid-section-footer table{border-bottom-style:hidden}.fc .fc-scrollgrid-section-sticky>*{background:var(--fc-page-bg-color);position:sticky;z-index:3}.fc .fc-scrollgrid-section-header.fc-scrollgrid-section-sticky>*{top:0}.fc .fc-scrollgrid-section-footer.fc-scrollgrid-section-sticky>*{bottom:0}.fc .fc-scrollgrid-sticky-shim{height:1px;margin-bottom:-1px}.fc-sticky{position:sticky}.fc .fc-view-harness{flex-grow:1;position:relative}.fc .fc-view-harness-active>.fc-view{bottom:0;left:0;position:absolute;right:0;top:0}.fc .fc-col-header-cell-cushion{display:inline-block;padding:2px 4px}.fc .fc-bg-event,.fc .fc-highlight,.fc .fc-non-business{bottom:0;left:0;position:absolute;right:0;top:0}.fc .fc-non-business{background:var(--fc-non-business-color)}.fc .fc-bg-event{background:var(--fc-bg-event-color);opacity:var(--fc-bg-event-opacity)}.fc .fc-bg-event .fc-event-title{font-size:var(--fc-small-font-size);font-style:italic;margin:.5em}.fc .fc-highlight{background:var(--fc-highlight-color)}.fc .fc-cell-shaded,.fc .fc-day-disabled{background:var(--fc-neutral-bg-color)}a.fc-event,a.fc-event:hover{text-decoration:none}.fc-event.fc-event-draggable,.fc-event[href]{cursor:pointer}.fc-event .fc-event-main{position:relative;z-index:2}.fc-event-dragging:not(.fc-event-selected){opacity:.75}.fc-event-dragging.fc-event-selected{box-shadow:0 2px 7px rgba(0,0,0,.3)}.fc-event .fc-event-resizer{display:none;position:absolute;z-index:4}.fc-event-selected .fc-event-resizer,.fc-event:hover .fc-event-resizer{display:block}.fc-event-selected .fc-event-resizer{background:var(--fc-page-bg-color);border-color:inherit;border-radius:calc(var(--fc-event-resizer-dot-total-width)/2);border-style:solid;border-width:var(--fc-event-resizer-dot-border-width);height:var(--fc-event-resizer-dot-total-width);width:var(--fc-event-resizer-dot-total-width)}.fc-event-selected .fc-event-resizer:before{bottom:-20px;content:"";left:-20px;position:absolute;right:-20px;top:-20px}.fc-event-selected,.fc-event:focus{box-shadow:0 2px 5px rgba(0,0,0,.2)}.fc-event-selected:before,.fc-event:focus:before{bottom:0;content:"";left:0;position:absolute;right:0;top:0;z-index:3}.fc-event-selected:after,.fc-event:focus:after{background:var(--fc-event-selected-overlay-color);bottom:-1px;content:"";left:-1px;position:absolute;right:-1px;top:-1px;z-index:1}.fc-h-event{background-color:var(--fc-event-bg-color);border:1px solid var(--fc-event-border-color);display:block}.fc-h-event .fc-event-main{color:var(--fc-event-text-color)}.fc-h-event .fc-event-main-frame{display:flex}.fc-h-event .fc-event-time{max-width:100%;overflow:hidden}.fc-h-event .fc-event-title-container{flex-grow:1;flex-shrink:1;min-width:0}.fc-h-event .fc-event-title{display:inline-block;left:0;max-width:100%;overflow:hidden;right:0;vertical-align:top}.fc-h-event.fc-event-selected:before{bottom:-10px;top:-10px}.fc-direction-ltr .fc-daygrid-block-event:not(.fc-event-start),.fc-direction-rtl .fc-daygrid-block-event:not(.fc-event-end){border-bottom-left-radius:0;border-left-width:0;border-top-left-radius:0}.fc-direction-ltr .fc-daygrid-block-event:not(.fc-event-end),.fc-direction-rtl .fc-daygrid-block-event:not(.fc-event-start){border-bottom-right-radius:0;border-right-width:0;border-top-right-radius:0}.fc-h-event:not(.fc-event-selected) .fc-event-resizer{bottom:0;top:0;width:var(--fc-event-resizer-thickness)}.fc-direction-ltr .fc-h-event:not(.fc-event-selected) .fc-event-resizer-start,.fc-direction-rtl .fc-h-event:not(.fc-event-selected) .fc-event-resizer-end{cursor:w-resize;left:calc(var(--fc-event-resizer-thickness)*-.5)}.fc-direction-ltr .fc-h-event:not(.fc-event-selected) .fc-event-resizer-end,.fc-direction-rtl .fc-h-event:not(.fc-event-selected) .fc-event-resizer-start{cursor:e-resize;right:calc(var(--fc-event-resizer-thickness)*-.5)}.fc-h-event.fc-event-selected .fc-event-resizer{margin-top:calc(var(--fc-event-resizer-dot-total-width)*-.5);top:50%}.fc-direction-ltr .fc-h-event.fc-event-selected .fc-event-resizer-start,.fc-direction-rtl .fc-h-event.fc-event-selected .fc-event-resizer-end{left:calc(var(--fc-event-resizer-dot-total-width)*-.5)}.fc-direction-ltr .fc-h-event.fc-event-selected .fc-event-resizer-end,.fc-direction-rtl .fc-h-event.fc-event-selected .fc-event-resizer-start{right:calc(var(--fc-event-resizer-dot-total-width)*-.5)}.fc .fc-popover{box-shadow:0 2px 6px rgba(0,0,0,.15);position:absolute;z-index:9999}.fc .fc-popover-header{align-items:center;display:flex;flex-direction:row;justify-content:space-between;padding:3px 4px}.fc .fc-popover-title{margin:0 2px}.fc .fc-popover-close{cursor:pointer;font-size:1.1em;opacity:.65}.fc-theme-standard .fc-popover{background:var(--fc-page-bg-color);border:1px solid var(--fc-border-color)}.fc-theme-standard .fc-popover-header{background:var(--fc-neutral-bg-color)}';nm(uI);class am{constructor(e){this.drainedOption=e,this.isRunning=!1,this.isDirty=!1,this.pauseDepths={},this.timeoutId=0}request(e){this.isDirty=!0,this.isPaused()||(this.clearTimeout(),e==null?this.tryDrain():this.timeoutId=setTimeout(this.tryDrain.bind(this),e))}pause(e=""){let{pauseDepths:n}=this;n[e]=(n[e]||0)+1,this.clearTimeout()}resume(e="",n){let{pauseDepths:r}=this;e in r&&(n?delete r[e]:(r[e]-=1,r[e]<=0&&delete r[e]),this.tryDrain())}isPaused(){return Object.keys(this.pauseDepths).length}tryDrain(){if(!this.isRunning&&!this.isPaused()){for(this.isRunning=!0;this.isDirty;)this.isDirty=!1,this.drained();this.isRunning=!1}}clear(){this.clearTimeout(),this.isDirty=!1,this.pauseDepths={}}clearTimeout(){this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=0)}drained(){this.drainedOption&&this.drainedOption()}}function sm(t){t.parentNode&&t.parentNode.removeChild(t)}function qt(t,e){if(t.closest)return t.closest(e);if(!document.documentElement.contains(t))return null;do{if(fI(t,e))return t;t=t.parentElement||t.parentNode}while(t!==null&&t.nodeType===1);return null}function fI(t,e){return(t.matches||t.matchesSelector||t.msMatchesSelector).call(t,e)}function hI(t,e){let n=t instanceof HTMLElement?[t]:t,r=[];for(let i=0;i{let r=qt(n.target,t);r&&e.call(r,n,r)}}function kS(t,e,n,r){let i=gI(n,r);return t.addEventListener(e,i),()=>{t.removeEventListener(e,i)}}function mI(t,e,n,r){let i;return kS(t,"mouseover",e,(c,d)=>{if(d!==i){i=d,n(c,d);let f=h=>{i=null,r(h,d),d.removeEventListener("mouseleave",f)};d.addEventListener("mouseleave",f)}})}const x1=["webkitTransitionEnd","otransitionend","oTransitionEnd","msTransitionEnd","transitionend"];function xI(t,e){let n=r=>{e(r),x1.forEach(i=>{t.removeEventListener(i,n)})};x1.forEach(r=>{t.addEventListener(r,n)})}function _S(t){return Object.assign({onClick:t},MS(t))}function MS(t){return{tabIndex:0,onKeyDown(e){(e.key==="Enter"||e.key===" ")&&(t(e),e.preventDefault())}}}let b1=0;function Tr(){return b1+=1,String(b1)}function rm(){document.body.classList.add("fc-not-allowed")}function lm(){document.body.classList.remove("fc-not-allowed")}function bI(t){t.style.userSelect="none",t.style.webkitUserSelect="none",t.addEventListener("selectstart",Cu)}function yI(t){t.style.userSelect="",t.style.webkitUserSelect="",t.removeEventListener("selectstart",Cu)}function vI(t){t.addEventListener("contextmenu",Cu)}function NI(t){t.removeEventListener("contextmenu",Cu)}function EI(t){let e=[],n=[],r,i;for(typeof t=="string"?n=t.split(/\s*,\s*/):typeof t=="function"?n=[t]:Array.isArray(t)&&(n=t),r=0;rr.replace("$"+c,i||""),t):n}function wI(t,e){return t-e}function Od(t){return t%1===0}function CI(t){let e=t.querySelector(".fc-scrollgrid-shrink-frame"),n=t.querySelector(".fc-scrollgrid-shrink-cushion");if(!e)throw new Error("needs fc-scrollgrid-shrink-frame className");if(!n)throw new Error("needs fc-scrollgrid-shrink-cushion className");return t.getBoundingClientRect().width-e.getBoundingClientRect().width+n.getBoundingClientRect().width}const y1=["years","months","days","milliseconds"],DI=/^(-?)(?:(\d+)\.)?(\d+):(\d\d)(?::(\d\d)(?:\.(\d\d\d))?)?/;function Ge(t,e){return typeof t=="string"?OI(t):typeof t=="object"&&t?v1(t):typeof t=="number"?v1({[e||"milliseconds"]:t}):null}function OI(t){let e=DI.exec(t);if(e){let n=e[1]?-1:1;return{years:0,months:0,days:n*(e[2]?parseInt(e[2],10):0),milliseconds:n*((e[3]?parseInt(e[3],10):0)*60*60*1e3+(e[4]?parseInt(e[4],10):0)*60*1e3+(e[5]?parseInt(e[5],10):0)*1e3+(e[6]?parseInt(e[6],10):0))}}return null}function v1(t){let e={years:t.years||t.year||0,months:t.months||t.month||0,days:t.days||t.day||0,milliseconds:(t.hours||t.hour||0)*60*60*1e3+(t.minutes||t.minute||0)*60*1e3+(t.seconds||t.second||0)*1e3+(t.milliseconds||t.millisecond||t.ms||0)},n=t.weeks||t.week;return n&&(e.days+=n*7,e.specifiedWeeks=!0),e}function RI(t,e){return t.years===e.years&&t.months===e.months&&t.days===e.days&&t.milliseconds===e.milliseconds}function Jp(t,e){return{years:t.years+e.years,months:t.months+e.months,days:t.days+e.days,milliseconds:t.milliseconds+e.milliseconds}}function TI(t,e){return{years:t.years-e.years,months:t.months-e.months,days:t.days-e.days,milliseconds:t.milliseconds-e.milliseconds}}function kI(t,e){return{years:t.years*e,months:t.months*e,days:t.days*e,milliseconds:t.milliseconds*e}}function _I(t){return El(t)/365}function MI(t){return El(t)/30}function El(t){return ea(t)/864e5}function ea(t){return t.years*(365*864e5)+t.months*(30*864e5)+t.days*864e5+t.milliseconds}function im(t,e){let n=null;for(let r=0;r=1?Math.min(i,c):i}function Ap(t,e,n,r){let i=on([e,0,1+$I(e,n,r)]),c=it(t),d=Math.round(kr(i,c));return Math.floor(d/7)+1}function $I(t,e,n){let r=7+e-n;return-((7+on([t,0,r]).getUTCDay()-e)%7)+r-1}function E1(t){return[t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()]}function S1(t){return new Date(t[0],t[1]||0,t[2]==null?1:t[2],t[3]||0,t[4]||0,t[5]||0)}function Os(t){return[t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds()]}function on(t){return t.length===1&&(t=t.concat([0])),new Date(Date.UTC(...t))}function IS(t){return!isNaN(t.valueOf())}function Rs(t){return t.getUTCHours()*1e3*60*60+t.getUTCMinutes()*1e3*60+t.getUTCSeconds()*1e3+t.getUTCMilliseconds()}function LS(t,e,n=!1){let r=t.toISOString();return r=r.replace(".000",""),n&&(r=r.replace("T00:00:00Z","")),r.length>10&&(e==null?r=r.replace("Z",""):e!==0&&(r=r.replace("Z",cm(e,!0)))),r}function om(t){return t.toISOString().replace(/T.*$/,"")}function YI(t){return t.toISOString().match(/^\d{4}-\d{2}/)[0]}function QI(t){return Nl(t.getUTCHours(),2)+":"+Nl(t.getUTCMinutes(),2)+":"+Nl(t.getUTCSeconds(),2)}function cm(t,e=!1){let n=t<0?"-":"+",r=Math.abs(t),i=Math.floor(r/60),c=Math.round(r%60);return e?`${n+Nl(i,2)}:${Nl(c,2)}`:`GMT${n}${i}${c?`:${Nl(c,2)}`:""}`}function we(t,e,n){let r,i;return function(...c){if(!r)i=t.apply(this,c);else if(!Ps(r,c)){let d=t.apply(this,c);(!e||!e(d,i))&&(i=d)}return r=c,i}}function Rd(t,e,n){let r,i;return c=>(r?ta(r,c)||(i=t.call(this,c)):i=t.call(this,c),r=c,i)}const wp={week:3,separator:9,omitZeroMinute:9,meridiem:9,omitCommas:9},Jd={timeZoneName:7,era:6,year:5,month:4,day:2,weekday:2,hour:1,minute:1,second:1},md=/\s*([ap])\.?m\.?/i,WI=/,/g,XI=/\s+/g,ZI=/\u200e/g,KI=/UTC|GMT/;class JI{constructor(e){let n={},r={},i=9;for(let c in e)c in wp?(r[c]=e[c],wp[c]<9&&(i=Math.min(wp[c],i))):(n[c]=e[c],c in Jd&&(i=Math.min(Jd[c],i)));this.standardDateProps=n,this.extendedSettings=r,this.smallestUnitNum=i,this.buildFormattingFunc=we(j1)}format(e,n){return this.buildFormattingFunc(this.standardDateProps,this.extendedSettings,n)(e)}formatRange(e,n,r,i){let{standardDateProps:c,extendedSettings:d}=this,f=r4(e.marker,n.marker,r.calendarSystem);if(!f)return this.format(e,r);let h=f;h>1&&(c.year==="numeric"||c.year==="2-digit")&&(c.month==="numeric"||c.month==="2-digit")&&(c.day==="numeric"||c.day==="2-digit")&&(h=1);let p=this.format(e,r),b=this.format(n,r);if(p===b)return p;let y=l4(c,h),m=j1(y,d,r),v=m(e),N=m(n),S=i4(p,v,b,N),j=d.separator||i||r.defaultSeparator||"";return S?S.before+v+j+N+S.after:p+j+b}getSmallestUnit(){switch(this.smallestUnitNum){case 7:case 6:case 5:return"year";case 4:return"month";case 3:return"week";case 2:return"day";default:return"time"}}}function j1(t,e,n){let r=Object.keys(t).length;return r===1&&t.timeZoneName==="short"?i=>cm(i.timeZoneOffset):r===0&&e.week?i=>s4(n.computeWeekNumber(i.marker),n.weekText,n.weekTextLong,n.locale,e.week):e4(t,e,n)}function e4(t,e,n){t=Object.assign({},t),e=Object.assign({},e),t4(t,e),t.timeZone="UTC";let r=new Intl.DateTimeFormat(n.locale.codes,t),i;if(e.omitZeroMinute){let c=Object.assign({},t);delete c.minute,i=new Intl.DateTimeFormat(n.locale.codes,c)}return c=>{let{marker:d}=c,f;i&&!d.getUTCMinutes()?f=i:f=r;let h=f.format(d);return n4(h,c,t,e,n)}}function t4(t,e){t.timeZoneName&&(t.hour||(t.hour="2-digit"),t.minute||(t.minute="2-digit")),t.timeZoneName==="long"&&(t.timeZoneName="short"),e.omitZeroMinute&&(t.second||t.millisecond)&&delete e.omitZeroMinute}function n4(t,e,n,r,i){return t=t.replace(ZI,""),n.timeZoneName==="short"&&(t=a4(t,i.timeZone==="UTC"||e.timeZoneOffset==null?"UTC":cm(e.timeZoneOffset))),r.omitCommas&&(t=t.replace(WI,"").trim()),r.omitZeroMinute&&(t=t.replace(":00","")),r.meridiem===!1?t=t.replace(md,"").trim():r.meridiem==="narrow"?t=t.replace(md,(c,d)=>d.toLocaleLowerCase()):r.meridiem==="short"?t=t.replace(md,(c,d)=>`${d.toLocaleLowerCase()}m`):r.meridiem==="lowercase"&&(t=t.replace(md,c=>c.toLocaleLowerCase())),t=t.replace(XI," "),t=t.trim(),t}function a4(t,e){let n=!1;return t=t.replace(KI,()=>(n=!0,e)),n||(t+=` ${e}`),t}function s4(t,e,n,r,i){let c=[];return i==="long"?c.push(n):(i==="short"||i==="narrow")&&c.push(e),(i==="long"||i==="short")&&c.push(" "),c.push(r.simpleNumberFormat.format(t)),r.options.direction==="rtl"&&c.reverse(),c.join("")}function r4(t,e,n){return n.getMarkerYear(t)!==n.getMarkerYear(e)?5:n.getMarkerMonth(t)!==n.getMarkerMonth(e)?4:n.getMarkerDay(t)!==n.getMarkerDay(e)?2:Rs(t)!==Rs(e)?1:0}function l4(t,e){let n={};for(let r in t)(!(r in Jd)||Jd[r]<=e)&&(n[r]=t[r]);return n}function i4(t,e,n,r){let i=0;for(;i=0;c-=1){let d=t[c][r];if(typeof d=="object"&&d)i.unshift(d);else if(d!==void 0){n[r]=d;break}}i.length&&(n[r]=um(i))}}for(let r=t.length-1;r>=0;r-=1){let i=t[r];for(let c in i)c in n||(n[c]=i[c])}return n}function Dr(t,e){let n={};for(let r in t)e(t[r],r)&&(n[r]=t[r]);return n}function Ha(t,e){let n={};for(let r in t)n[r]=e(t[r],r);return n}function zS(t){let e={};for(let n of t)e[n]=!0;return e}function fm(t){let e=[];for(let n in t)e.push(t[n]);return e}function ta(t,e){if(t===e)return!0;for(let n in t)if(tu.call(t,n)&&!(n in e))return!1;for(let n in e)if(tu.call(e,n)&&t[n]!==e[n])return!1;return!0}const u4=/^on[A-Z]/;function f4(t,e){const n=h4(t,e);for(let r of n)if(!u4.test(r))return!1;return!0}function h4(t,e){let n=[];for(let r in t)tu.call(t,r)&&(r in e||n.push(r));for(let r in e)tu.call(e,r)&&t[r]!==e[r]&&n.push(r);return n}function Dp(t,e,n={}){if(t===e)return!0;for(let r in e)if(!(r in t&&p4(t[r],e[r],n[r])))return!1;for(let r in t)if(!(r in e))return!1;return!0}function p4(t,e,n){return t===e||n===!0?!0:n?n(t,e):!1}function g4(t,e=0,n,r=1){let i=[];n==null&&(n=Object.keys(t).length);for(let c=e;c{this.props.value!==d.value&&c.forEach(f=>{f.context=d.value,f.forceUpdate()})},this.sub=d=>{c.push(d);let f=d.componentWillUnmount;d.componentWillUnmount=()=>{c.splice(c.indexOf(d),1),f&&f.call(d)}}}return i},e}class S4{constructor(e,n,r,i){this.execFunc=e,this.emitter=n,this.scrollTime=r,this.scrollTimeReset=i,this.handleScrollRequest=c=>{this.queuedRequest=Object.assign({},this.queuedRequest||{},c),this.drain()},n.on("_scrollRequest",this.handleScrollRequest),this.fireInitialScroll()}detach(){this.emitter.off("_scrollRequest",this.handleScrollRequest)}update(e){e&&this.scrollTimeReset?this.fireInitialScroll():this.drain()}fireInitialScroll(){this.handleScrollRequest({time:this.scrollTime})}drain(){this.queuedRequest&&this.execFunc(this.queuedRequest)&&(this.queuedRequest=null)}}const Fa=US({});function j4(t,e,n,r,i,c,d,f,h,p,b,y,m,v){return{dateEnv:i,nowManager:c,options:n,pluginHooks:f,emitter:b,dispatch:h,getCurrentData:p,calendarApi:y,viewSpec:t,viewApi:e,dateProfileGenerator:r,theme:d,isRtl:n.direction==="rtl",addResizeHandler(N){b.on("_resize",N)},removeResizeHandler(N){b.off("_resize",N)},createScrollResponder(N){return new S4(N,b,Ge(n.scrollTime),n.scrollTimeReset)},registerInteractiveComponent:m,unregisterInteractiveComponent:v}}class _r extends wn{shouldComponentUpdate(e,n){return!Dp(this.props,e,this.propEquality)||!Dp(this.state,n,this.stateEquality)}safeSetState(e){Dp(this.state,Object.assign(Object.assign({},this.state),e),this.stateEquality)||this.setState(e)}}_r.addPropsEquality=A4;_r.addStateEquality=w4;_r.contextType=Fa;_r.prototype.propEquality={};_r.prototype.stateEquality={};class Ke extends _r{}Ke.contextType=Fa;function A4(t){let e=Object.create(this.prototype.propEquality);Object.assign(e,t),this.prototype.propEquality=e}function w4(t){let e=Object.create(this.prototype.stateEquality);Object.assign(e,t),this.prototype.stateEquality=e}function fa(t,e){typeof t=="function"?t(e):t&&(t.current=e)}class hm extends Ke{constructor(){super(...arguments),this.id=Tr(),this.queuedDomNodes=[],this.currentDomNodes=[],this.handleEl=e=>{const{options:n}=this.context,{generatorName:r}=this.props;(!n.customRenderingReplaces||!tg(r,n))&&this.updateElRef(e)},this.updateElRef=e=>{this.props.elRef&&fa(this.props.elRef,e)}}render(){const{props:e,context:n}=this,{options:r}=n,{customGenerator:i,defaultGenerator:c,renderProps:d}=e,f=BS(e,[],this.handleEl);let h=!1,p,b=[],y;if(i!=null){const m=typeof i=="function"?i(d,I):i;if(m===!0)h=!0;else{const v=m&&typeof m=="object";v&&"html"in m?f.dangerouslySetInnerHTML={__html:m.html}:v&&"domNodes"in m?b=Array.prototype.slice.call(m.domNodes):(v?dS(m):typeof m!="function")?p=m:y=m}}else h=!tg(e.generatorName,r);return h&&c&&(p=c(d)),this.queuedDomNodes=b,this.currentGeneratorMeta=y,I(e.elTag,f,p)}componentDidMount(){this.applyQueueudDomNodes(),this.triggerCustomRendering(!0)}componentDidUpdate(){this.applyQueueudDomNodes(),this.triggerCustomRendering(!0)}componentWillUnmount(){this.triggerCustomRendering(!1)}triggerCustomRendering(e){var n;const{props:r,context:i}=this,{handleCustomRendering:c,customRenderingMetaMap:d}=i.options;if(c){const f=(n=this.currentGeneratorMeta)!==null&&n!==void 0?n:d==null?void 0:d[r.generatorName];f&&c(Object.assign(Object.assign({id:this.id,isActive:e,containerEl:this.base,reportNewContainerEl:this.updateElRef,generatorMeta:f},r),{elClasses:(r.elClasses||[]).filter(C4)}))}}applyQueueudDomNodes(){const{queuedDomNodes:e,currentDomNodes:n}=this,r=this.base;if(!Ps(e,n)){n.forEach(sm);for(let i of e)r.appendChild(i);this.currentDomNodes=e}}}hm.addPropsEquality({elClasses:Ps,elStyle:ta,elAttrs:f4,renderProps:ta});function tg(t,e){var n;return!!(e.handleCustomRendering&&t&&(!((n=e.customRenderingMetaMap)===null||n===void 0)&&n[t]))}function BS(t,e,n){const r=Object.assign(Object.assign({},t.elAttrs),{ref:n});return(t.elClasses||e)&&(r.className=(t.elClasses||[]).concat(e||[]).concat(r.className||[]).filter(Boolean).join(" ")),t.elStyle&&(r.style=t.elStyle),r}function C4(t){return!!t}const HS=US(0);class On extends wn{constructor(){super(...arguments),this.InnerContent=D4.bind(void 0,this),this.handleEl=e=>{this.el=e,this.props.elRef&&(fa(this.props.elRef,e),e&&this.didMountMisfire&&this.componentDidMount())}}render(){const{props:e}=this,n=O4(e.classNameGenerator,e.renderProps);if(e.children){const r=BS(e,n,this.handleEl),i=e.children(this.InnerContent,e.renderProps,r);return e.elTag?I(e.elTag,r,i):i}else return I(hm,Object.assign(Object.assign({},e),{elRef:this.handleEl,elTag:e.elTag||"div",elClasses:(e.elClasses||[]).concat(n),renderId:this.context}))}componentDidMount(){var e,n;this.el?(n=(e=this.props).didMount)===null||n===void 0||n.call(e,Object.assign(Object.assign({},this.props.renderProps),{el:this.el})):this.didMountMisfire=!0}componentWillUnmount(){var e,n;(n=(e=this.props).willUnmount)===null||n===void 0||n.call(e,Object.assign(Object.assign({},this.props.renderProps),{el:this.el}))}}On.contextType=HS;function D4(t,e){const n=t.props;return I(hm,Object.assign({renderProps:n.renderProps,generatorName:n.generatorName,customGenerator:n.customGenerator,defaultGenerator:n.defaultGenerator,renderId:t.context},e))}function O4(t,e){const n=typeof t=="function"?t(e):t||[];return typeof n=="string"?[n]:n}class au extends Ke{render(){let{props:e,context:n}=this,{options:r}=n,i={view:n.viewApi};return I(On,{elRef:e.elRef,elTag:e.elTag||"div",elAttrs:e.elAttrs,elClasses:[...GS(e.viewSpec),...e.elClasses||[]],elStyle:e.elStyle,renderProps:i,classNameGenerator:r.viewClassNames,generatorName:void 0,didMount:r.viewDidMount,willUnmount:r.viewWillUnmount},()=>e.children)}}function GS(t){return[`fc-${t.type}-view`,"fc-view"]}function R4(t,e){let n=null,r=null;return t.start&&(n=e.createMarker(t.start)),t.end&&(r=e.createMarker(t.end)),!n&&!r||n&&r&&rr&&n.push({start:r,end:c.start}),c.end>r&&(r=c.end);return re.start)&&(t.start===null||e.end===null||t.start=t.start)&&(t.end===null||e.end!==null&&e.end<=t.end)}function Pa(t,e){return(t.start===null||e>=t.start)&&(t.end===null||e=e.end?new Date(e.end.valueOf()-1):t}function VS(t){let e=Math.floor(kr(t.start,t.end))||1,n=it(t.start),r=_t(n,e);return{start:n,end:r}}function FS(t,e=Ge(0)){let n=null,r=null;if(t.end){r=it(t.end);let i=t.end.valueOf()-r.valueOf();i&&i>=ea(e)&&(r=_t(r,1))}return t.start&&(n=it(t.start),r&&r<=n&&(r=_t(n,1))),{start:n,end:r}}function vl(t,e,n,r){return r==="year"?Ge(n.diffWholeYears(t,e),"year"):r==="month"?Ge(n.diffWholeMonths(t,e),"month"):BI(t,e)}class qS{constructor(e){this.props=e,this.initHiddenDays()}buildPrev(e,n,r){let{dateEnv:i}=this.props,c=i.subtract(i.startOf(n,e.currentRangeUnit),e.dateIncrement);return this.build(c,-1,r)}buildNext(e,n,r){let{dateEnv:i}=this.props,c=i.add(i.startOf(n,e.currentRangeUnit),e.dateIncrement);return this.build(c,1,r)}build(e,n,r=!0){let{props:i}=this,c,d,f,h,p,b;return c=this.buildValidRange(),c=this.trimHiddenDays(c),r&&(e=_4(e,c)),d=this.buildCurrentRangeInfo(e,n),f=/^(year|month|week|day)$/.test(d.unit),h=this.buildRenderRange(this.trimHiddenDays(d.range),d.unit,f),h=this.trimHiddenDays(h),p=h,i.showNonCurrentDates||(p=Or(p,d.range)),p=this.adjustActiveRange(p),p=Or(p,c),b=pm(d.range,c),Pa(h,e)||(e=h.start),{currentDate:e,validRange:c,currentRange:d.range,currentRangeUnit:d.unit,isRangeAllDay:f,activeRange:p,renderRange:h,slotMinTime:i.slotMinTime,slotMaxTime:i.slotMaxTime,isValid:b,dateIncrement:this.buildDateIncrement(d.duration)}}buildValidRange(){let e=this.props.validRangeInput,n=typeof e=="function"?e.call(this.props.calendarApi,this.props.dateEnv.toDate(this.props.nowManager.getDateMarker())):e;return this.refineRange(n)||{start:null,end:null}}buildCurrentRangeInfo(e,n){let{props:r}=this,i=null,c=null,d=null,f;return r.duration?(i=r.duration,c=r.durationUnit,d=this.buildRangeFromDuration(e,n,i,c)):(f=this.props.dayCount)?(c="day",d=this.buildRangeFromDayCount(e,n,f)):(d=this.buildCustomVisibleRange(e))?c=r.dateEnv.greatestWholeUnit(d.start,d.end).unit:(i=this.getFallbackDuration(),c=eg(i).unit,d=this.buildRangeFromDuration(e,n,i,c)),{duration:i,unit:c,range:d}}getFallbackDuration(){return Ge({day:1})}adjustActiveRange(e){let{dateEnv:n,usesMinMaxTime:r,slotMinTime:i,slotMaxTime:c}=this.props,{start:d,end:f}=e;return r&&(El(i)<0&&(d=it(d),d=n.add(d,i)),El(c)>1&&(f=it(f),f=_t(f,-1),f=n.add(f,c))),{start:d,end:f}}buildRangeFromDuration(e,n,r,i){let{dateEnv:c,dateAlignment:d}=this.props,f,h,p;if(!d){let{dateIncrement:y}=this.props;y&&ea(y)!d[h.defId].recurringDef);for(let h in d){let p=d[h];if(p.recurringDef){let{duration:b}=p.recurringDef;b||(b=p.allDay?c.defaultAllDayEventDuration:c.defaultTimedEventDuration);let y=I4(p,b,e,r,i.recurringTypes);for(let m of y){let v=gm(h,{start:m,end:r.add(m,b)});f[v.instanceId]=v}}}return{defs:d,instances:f}}function I4(t,e,n,r,i){let d=i[t.recurringDef.typeId].expand(t.recurringDef.typeData,{start:r.subtract(n.start,e),end:n.end},r);return t.allDay&&(d=d.map(it)),d}const Td={id:String,groupId:String,title:String,url:String,interactive:Boolean},$S={start:Z,end:Z,date:Z,allDay:Boolean},L4=Object.assign(Object.assign(Object.assign({},Td),$S),{extendedProps:Z});function YS(t,e,n,r,i=mm(n),c,d){let{refined:f,extra:h}=QS(t,n,i),p=P4(e,n),b=M4(f,p,n.dateEnv,n.pluginHooks.recurringTypes);if(b){let m=ng(f,h,e?e.sourceId:"",b.allDay,!!b.duration,n,c);return m.recurringDef={typeId:b.typeId,typeData:b.typeData,duration:b.duration},{def:m,instance:null}}let y=z4(f,p,n,r);if(y){let m=ng(f,h,e?e.sourceId:"",y.allDay,y.hasEnd,n,c),v=gm(m.defId,y.range,y.forcedStartTzo,y.forcedEndTzo);return d&&m.publicId&&d[m.publicId]&&(v.instanceId=d[m.publicId]),{def:m,instance:v}}return null}function QS(t,e,n=mm(e)){return dm(t,n)}function mm(t){return Object.assign(Object.assign(Object.assign({},su),L4),t.pluginHooks.eventRefiners)}function ng(t,e,n,r,i,c,d){let f={title:t.title||"",groupId:t.groupId||"",publicId:t.id||"",url:t.url||"",recurringDef:null,defId:(d&&t.id?d[t.id]:"")||Tr(),sourceId:n,allDay:r,hasEnd:i,interactive:t.interactive,ui:ru(t,c),extendedProps:Object.assign(Object.assign({},t.extendedProps||{}),e)};for(let h of c.pluginHooks.eventDefMemberAdders)Object.assign(f,h(t));return Object.freeze(f.ui.classNames),Object.freeze(f.extendedProps),f}function z4(t,e,n,r){let{allDay:i}=t,c,d=null,f=!1,h,p=null,b=t.start!=null?t.start:t.date;if(c=n.dateEnv.createMarkerMeta(b),c)d=c.marker;else if(!r)return null;return t.end!=null&&(h=n.dateEnv.createMarkerMeta(t.end)),i==null&&(e!=null?i=e:i=(!c||c.isTimeUnspecified)&&(!h||h.isTimeUnspecified)),i&&d&&(d=it(d)),h&&(p=h.marker,i&&(p=it(p)),d&&p<=d&&(p=null)),p?f=!0:r||(f=n.options.forceEventDuration||!1,p=n.dateEnv.add(d,i?n.options.defaultAllDayEventDuration:n.options.defaultTimedEventDuration)),{allDay:i,hasEnd:f,range:{start:d,end:p},forcedStartTzo:c?c.forcedTzo:null,forcedEndTzo:h?h.forcedTzo:null}}function P4(t,e){let n=null;return t&&(n=t.defaultAllDay),n==null&&(n=e.options.defaultAllDay),n}function Eo(t,e,n,r,i,c){let d=Cn(),f=mm(n);for(let h of t){let p=YS(h,e,n,r,f,i,c);p&&ag(p,d)}return d}function ag(t,e=Cn()){return e.defs[t.def.defId]=t.def,t.instance&&(e.instances[t.instance.instanceId]=t.instance),e}function xm(t,e){let n=t.instances[e];if(n){let r=t.defs[n.defId],i=Ou(t,c=>U4(r,c));return i.defs[r.defId]=r,i.instances[n.instanceId]=n,i}return Cn()}function U4(t,e){return!!(t.groupId&&t.groupId===e.groupId)}function Cn(){return{defs:{},instances:{}}}function bm(t,e){return{defs:Object.assign(Object.assign({},t.defs),e.defs),instances:Object.assign(Object.assign({},t.instances),e.instances)}}function Ou(t,e){let n=Dr(t.defs,e),r=Dr(t.instances,i=>n[i.defId]);return{defs:n,instances:r}}function B4(t,e){let{defs:n,instances:r}=t,i={},c={};for(let d in n)e.defs[d]||(i[d]=n[d]);for(let d in r)!e.instances[d]&&i[r[d].defId]&&(c[d]=r[d]);return{defs:i,instances:c}}function H4(t,e){return Array.isArray(t)?Eo(t,null,e,!0):typeof t=="object"&&t?Eo([t],null,e,!0):t!=null?String(t):null}function R1(t){return Array.isArray(t)?t:typeof t=="string"?t.split(/\s+/):[]}const su={display:String,editable:Boolean,startEditable:Boolean,durationEditable:Boolean,constraint:Z,overlap:Z,allow:Z,className:R1,classNames:R1,color:String,backgroundColor:String,borderColor:String,textColor:String},G4={display:null,startEditable:null,durationEditable:null,constraints:[],overlap:null,allows:[],backgroundColor:"",borderColor:"",textColor:"",classNames:[]};function ru(t,e){let n=H4(t.constraint,e);return{display:t.display||null,startEditable:t.startEditable!=null?t.startEditable:t.editable,durationEditable:t.durationEditable!=null?t.durationEditable:t.editable,constraints:n!=null?[n]:[],overlap:t.overlap!=null?t.overlap:null,allows:t.allow!=null?[t.allow]:[],backgroundColor:t.backgroundColor||t.color||"",borderColor:t.borderColor||t.color||"",textColor:t.textColor||"",classNames:(t.className||[]).concat(t.classNames||[])}}function WS(t){return t.reduce(V4,G4)}function V4(t,e){return{display:e.display!=null?e.display:t.display,startEditable:e.startEditable!=null?e.startEditable:t.startEditable,durationEditable:e.durationEditable!=null?e.durationEditable:t.durationEditable,constraints:t.constraints.concat(e.constraints),overlap:typeof e.overlap=="boolean"?e.overlap:t.overlap,allows:t.allows.concat(e.allows),backgroundColor:e.backgroundColor||t.backgroundColor,borderColor:e.borderColor||t.borderColor,textColor:e.textColor||t.textColor,classNames:t.classNames.concat(e.classNames)}}const F4={id:String,defaultAllDay:Boolean,url:String,format:String,events:Z,eventDataTransform:Z,success:Z,failure:Z};function XS(t,e,n=ZS(e)){let r;if(typeof t=="string"?r={url:t}:typeof t=="function"||Array.isArray(t)?r={events:t}:typeof t=="object"&&t&&(r=t),r){let{refined:i,extra:c}=dm(r,n),d=q4(i,e);if(d)return{_raw:t,isFetching:!1,latestFetchId:"",fetchRange:null,defaultAllDay:i.defaultAllDay,eventDataTransform:i.eventDataTransform,success:i.success,failure:i.failure,publicId:i.id||"",sourceId:Tr(),sourceDefId:d.sourceDefId,meta:d.meta,ui:ru(i,e),extendedProps:c}}return null}function ZS(t){return Object.assign(Object.assign(Object.assign({},su),F4),t.pluginHooks.eventSourceRefiners)}function q4(t,e){let n=e.pluginHooks.eventSourceDefs;for(let r=n.length-1;r>=0;r-=1){let c=n[r].parseMeta(t);if(c)return{sourceDefId:r,meta:c}}return null}function $4(t,e,n,r,i){switch(e.type){case"RECEIVE_EVENTS":return Y4(t,n[e.sourceId],e.fetchId,e.fetchRange,e.rawEvents,i);case"RESET_RAW_EVENTS":return Q4(t,n[e.sourceId],e.rawEvents,r.activeRange,i);case"ADD_EVENTS":return W4(t,e.eventStore,r?r.activeRange:null,i);case"RESET_EVENTS":return e.eventStore;case"MERGE_EVENTS":return bm(t,e.eventStore);case"PREV":case"NEXT":case"CHANGE_DATE":case"CHANGE_VIEW_TYPE":return r?Rr(t,r.activeRange,i):t;case"REMOVE_EVENTS":return B4(t,e.eventStore);case"REMOVE_EVENT_SOURCE":return JS(t,e.sourceId);case"REMOVE_ALL_EVENT_SOURCES":return Ou(t,c=>!c.sourceId);case"REMOVE_ALL_EVENTS":return Cn();default:return t}}function Y4(t,e,n,r,i,c){if(e&&n===e.latestFetchId){let d=Eo(KS(i,e,c),e,c);return r&&(d=Rr(d,r,c)),bm(JS(t,e.sourceId),d)}return t}function Q4(t,e,n,r,i){const{defIdMap:c,instanceIdMap:d}=Z4(t);let f=Eo(KS(n,e,i),e,i,!1,c,d);return Rr(f,r,i)}function KS(t,e,n){let r=n.options.eventDataTransform,i=e?e.eventDataTransform:null;return i&&(t=T1(t,i)),r&&(t=T1(t,r)),t}function T1(t,e){let n;if(!e)n=t;else{n=[];for(let r of t){let i=e(r);i?n.push(i):i==null&&n.push(r)}}return n}function W4(t,e,n,r){return n&&(e=Rr(e,n,r)),bm(t,e)}function k1(t,e,n){let{defs:r}=t,i=Ha(t.instances,c=>r[c.defId].allDay?c:Object.assign(Object.assign({},c),{range:{start:n.createMarker(e.toDate(c.range.start,c.forcedStartTzo)),end:n.createMarker(e.toDate(c.range.end,c.forcedEndTzo))},forcedStartTzo:n.canComputeOffset?null:c.forcedStartTzo,forcedEndTzo:n.canComputeOffset?null:c.forcedEndTzo}));return{defs:r,instances:i}}function JS(t,e){return Ou(t,n=>n.sourceId!==e)}function X4(t,e){return{defs:t.defs,instances:Dr(t.instances,n=>!e[n.instanceId])}}function Z4(t){const{defs:e,instances:n}=t,r={},i={};for(let c in e){const d=e[c],{publicId:f}=d;f&&(r[f]=c)}for(let c in n){const d=n[c],f=e[d.defId],{publicId:h}=f;h&&(i[h]=c)}return{defIdMap:r,instanceIdMap:i}}class Ru{constructor(){this.handlers={},this.thisContext=null}setThisContext(e){this.thisContext=e}setOptions(e){this.options=e}on(e,n){K4(this.handlers,e,n)}off(e,n){J4(this.handlers,e,n)}trigger(e,...n){let r=this.handlers[e]||[],i=this.options&&this.options[e],c=[].concat(i||[],r);for(let d of c)d.apply(this.thisContext,n)}hasHandlers(e){return!!(this.handlers[e]&&this.handlers[e].length||this.options&&this.options[e])}}function K4(t,e,n){(t[e]||(t[e]=[])).push(n)}function J4(t,e,n){n?t[e]&&(t[e]=t[e].filter(r=>r!==n)):delete t[e]}const e3={startTime:"09:00",endTime:"17:00",daysOfWeek:[1,2,3,4,5],display:"inverse-background",classNames:"fc-non-business",groupId:"_businessHours"};function t3(t,e){return Eo(n3(t),null,e)}function n3(t){let e;return t===!0?e=[{}]:Array.isArray(t)?e=t.filter(n=>n.daysOfWeek):typeof t=="object"&&t?e=[t]:e=[],e=e.map(n=>Object.assign(Object.assign({},e3),n)),e}function ej(t,e,n){n.emitter.trigger("select",Object.assign(Object.assign({},ym(t,n)),{jsEvent:e?e.origEvent:null,view:n.viewApi||n.calendarApi.view}))}function a3(t,e){e.emitter.trigger("unselect",{jsEvent:t?t.origEvent:null,view:e.viewApi||e.calendarApi.view})}function ym(t,e){let n={};for(let r of e.pluginHooks.dateSpanTransforms)Object.assign(n,r(t,e));return Object.assign(n,x3(t,e.dateEnv)),n}function _1(t,e,n){let{dateEnv:r,options:i}=n,c=e;return t?(c=it(c),c=r.add(c,i.defaultAllDayEventDuration)):c=r.add(c,i.defaultTimedEventDuration),c}function vm(t,e,n,r){let i=lu(t.defs,e),c=Cn();for(let d in t.defs){let f=t.defs[d];c.defs[d]=s3(f,i[d],n,r)}for(let d in t.instances){let f=t.instances[d],h=c.defs[f.defId];c.instances[d]=r3(f,h,i[f.defId],n,r)}return c}function s3(t,e,n,r){let i=n.standardProps||{};i.hasEnd==null&&e.durationEditable&&(n.startDelta||n.endDelta)&&(i.hasEnd=!0);let c=Object.assign(Object.assign(Object.assign({},t),i),{ui:Object.assign(Object.assign({},t.ui),i.ui)});n.extendedProps&&(c.extendedProps=Object.assign(Object.assign({},c.extendedProps),n.extendedProps));for(let d of r.pluginHooks.eventDefMutationAppliers)d(c,n,r);return!c.hasEnd&&r.options.forceEventDuration&&(c.hasEnd=!0),c}function r3(t,e,n,r,i){let{dateEnv:c}=i,d=r.standardProps&&r.standardProps.allDay===!0,f=r.standardProps&&r.standardProps.hasEnd===!1,h=Object.assign({},t);return d&&(h.range=VS(h.range)),r.datesDelta&&n.startEditable&&(h.range={start:c.add(h.range.start,r.datesDelta),end:c.add(h.range.end,r.datesDelta)}),r.startDelta&&n.durationEditable&&(h.range={start:c.add(h.range.start,r.startDelta),end:h.range.end}),r.endDelta&&n.durationEditable&&(h.range={start:h.range.start,end:c.add(h.range.end,r.endDelta)}),f&&(h.range={start:h.range.start,end:_1(e.allDay,h.range.start,i)}),e.allDay&&(h.range={start:it(h.range.start),end:it(h.range.end)}),h.range.endnj(n,e))}function nj(t,e){let n=[];return e[""]&&n.push(e[""]),e[t.defId]&&n.push(e[t.defId]),n.push(t.ui),WS(n)}function aj(t,e){let n=t.map(i3);return n.sort((r,i)=>SI(r,i,e)),n.map(r=>r._seg)}function i3(t){let{eventRange:e}=t,n=e.def,r=e.instance?e.instance.range:e.range,i=r.start?r.start.valueOf():0,c=r.end?r.end.valueOf():0;return Object.assign(Object.assign(Object.assign({},n.extendedProps),n),{id:n.publicId,start:i,end:c,duration:c-i,allDay:Number(n.allDay),_seg:t})}function o3(t,e){let{pluginHooks:n}=e,r=n.isDraggableTransformers,{def:i,ui:c}=t.eventRange,d=c.startEditable;for(let f of r)d=f(d,i,c,e);return d}function c3(t,e){return t.isStart&&t.eventRange.ui.durationEditable&&e.options.eventResizableFromStart}function d3(t,e){return t.isEnd&&t.eventRange.ui.durationEditable}function sj(t,e,n,r,i,c,d){let{dateEnv:f,options:h}=n,{displayEventTime:p,displayEventEnd:b}=h,y=t.eventRange.def,m=t.eventRange.instance;p==null&&(p=r!==!1),b==null&&(b=i!==!1);let v=m.range.start,N=m.range.end,S=t.start||t.eventRange.range.start,j=t.end||t.eventRange.range.end,R=it(v).valueOf()===it(S).valueOf(),C=it(Us(N,-1)).valueOf()===it(Us(j,-1)).valueOf();return p&&!y.allDay&&(R||C)?(S=R?v:S,j=C?N:j,b&&y.hasEnd?f.formatRange(S,j,e,{forcedStartTzo:m.forcedStartTzo,forcedEndTzo:m.forcedEndTzo}):f.format(S,e,{forcedTzo:m.forcedStartTzo})):""}function Ms(t,e,n){let r=t.eventRange.range;return{isPast:r.end<=(n||e.start),isFuture:r.start>=(n||e.end),isToday:e&&Pa(e,r.start)}}function u3(t){let e=["fc-event"];return t.isMirror&&e.push("fc-event-mirror"),t.isDraggable&&e.push("fc-event-draggable"),(t.isStartResizable||t.isEndResizable)&&e.push("fc-event-resizable"),t.isDragging&&e.push("fc-event-dragging"),t.isResizing&&e.push("fc-event-resizing"),t.isSelected&&e.push("fc-event-selected"),t.isStart&&e.push("fc-event-start"),t.isEnd&&e.push("fc-event-end"),t.isPast&&e.push("fc-event-past"),t.isToday&&e.push("fc-event-today"),t.isFuture&&e.push("fc-event-future"),e}function rj(t){return t.instance?t.instance.instanceId:`${t.def.defId}:${t.range.start.toISOString()}`}function lj(t,e){let{def:n,instance:r}=t.eventRange,{url:i}=n;if(i)return{href:i};let{emitter:c,options:d}=e,{eventInteractive:f}=d;return f==null&&(f=n.interactive,f==null&&(f=!!c.hasHandlers("eventClick"))),f?MS(h=>{c.trigger("eventClick",{el:h.target,event:new ut(e,n,r),jsEvent:h,view:e.viewApi})}):{}}const f3={start:Z,end:Z,allDay:Boolean};function h3(t,e,n){let r=p3(t,e),{range:i}=r;if(!i.start)return null;if(!i.end){if(n==null)return null;i.end=e.add(i.start,n)}return r}function p3(t,e){let{refined:n,extra:r}=dm(t,f3),i=n.start?e.createMarkerMeta(n.start):null,c=n.end?e.createMarkerMeta(n.end):null,{allDay:d}=n;return d==null&&(d=i&&i.isTimeUnspecified&&(!c||c.isTimeUnspecified)),Object.assign({range:{start:i?i.marker:null,end:c?c.marker:null},allDay:d},r)}function g3(t,e){return k4(t.range,e.range)&&t.allDay===e.allDay&&m3(t,e)}function m3(t,e){for(let n in e)if(n!=="range"&&n!=="allDay"&&t[n]!==e[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}function x3(t,e){return Object.assign(Object.assign({},oj(t.range,e,t.allDay)),{allDay:t.allDay})}function ij(t,e,n){return Object.assign(Object.assign({},oj(t,e,n)),{timeZone:e.timeZone})}function oj(t,e,n){return{start:e.toDate(t.start),end:e.toDate(t.end),startStr:e.formatIso(t.start,{omitTime:n}),endStr:e.formatIso(t.end,{omitTime:n})}}function b3(t,e,n){let r=QS({editable:!1},n),i=ng(r.refined,r.extra,"",t.allDay,!0,n);return{def:i,ui:nj(i,e),instance:gm(i.defId,t.range),range:t.range,isStart:!0,isEnd:!0}}function y3(t,e,n){let r=!1,i=function(f){r||(r=!0,e(f))},c=function(f){r||(r=!0,n(f))},d=t(i,c);d&&typeof d.then=="function"&&d.then(i,c)}class L1 extends Error{constructor(e,n){super(e),this.response=n}}function v3(t,e,n){t=t.toUpperCase();const r={method:t};return t==="GET"?e+=(e.indexOf("?")===-1?"?":"&")+new URLSearchParams(n):(r.body=new URLSearchParams(n),r.headers={"Content-Type":"application/x-www-form-urlencoded"}),fetch(e,r).then(i=>{if(i.ok)return i.json().then(c=>[c,i],()=>{throw new L1("Failure parsing JSON",i)});throw new L1("Request failed",i)})}let Op;function cj(){return Op==null&&(Op=N3()),Op}function N3(){if(typeof document>"u")return!0;let t=document.createElement("div");t.style.position="absolute",t.style.top="0px",t.style.left="0px",t.innerHTML="
",t.querySelector("table").style.height="100px",t.querySelector("div").style.height="100%",document.body.appendChild(t);let n=t.querySelector("div").offsetHeight>0;return document.body.removeChild(t),n}class E3 extends Ke{constructor(){super(...arguments),this.state={forPrint:!1},this.handleBeforePrint=()=>{nu(()=>{this.setState({forPrint:!0})})},this.handleAfterPrint=()=>{nu(()=>{this.setState({forPrint:!1})})}}render(){let{props:e}=this,{options:n}=e,{forPrint:r}=this.state,i=r||n.height==="auto"||n.contentHeight==="auto",c=!i&&n.height!=null?n.height:"",d=["fc",r?"fc-media-print":"fc-media-screen",`fc-direction-${n.direction}`,e.theme.getClass("root")];return cj()||d.push("fc-liquid-hack"),e.children(d,c,i,r)}componentDidMount(){let{emitter:e}=this.props;e.on("_beforeprint",this.handleBeforePrint),e.on("_afterprint",this.handleAfterPrint)}componentWillUnmount(){let{emitter:e}=this.props;e.off("_beforeprint",this.handleBeforePrint),e.off("_afterprint",this.handleAfterPrint)}}class Jl{constructor(e){this.component=e.component,this.isHitComboAllowed=e.isHitComboAllowed||null}destroy(){}}function S3(t,e){return{component:t,el:e.el,useEventCenter:e.useEventCenter!=null?e.useEventCenter:!0,isHitComboAllowed:e.isHitComboAllowed||null}}function Nm(t){return{[t.component.uid]:t}}const sg={};class ei extends wn{constructor(e,n){super(e,n),this.handleRefresh=()=>{let r=this.computeTiming();r.state.nowDate.valueOf()!==this.state.nowDate.valueOf()&&this.setState(r.state),this.clearTimeout(),this.setTimeout(r.waitMs)},this.handleVisibilityChange=()=>{document.hidden||this.handleRefresh()},this.state=this.computeTiming().state}render(){let{props:e,state:n}=this;return e.children(n.nowDate,n.todayRange)}componentDidMount(){this.setTimeout(),this.context.nowManager.addResetListener(this.handleRefresh),document.addEventListener("visibilitychange",this.handleVisibilityChange)}componentDidUpdate(e){e.unit!==this.props.unit&&(this.clearTimeout(),this.setTimeout())}componentWillUnmount(){this.clearTimeout(),this.context.nowManager.removeResetListener(this.handleRefresh),document.removeEventListener("visibilitychange",this.handleVisibilityChange)}computeTiming(){let{props:e,context:n}=this,r=n.nowManager.getDateMarker(),{nowIndicatorSnap:i}=n.options;i==="auto"&&(i=/year|month|week|day/.test(e.unit)||(e.unitValue||1)===1);let c,d;return i?(c=n.dateEnv.startOf(r,e.unit),d=n.dateEnv.add(c,Ge(1,e.unit)).valueOf()-r.valueOf()):(c=r,d=1e3*60),d=Math.min(1e3*60*60*24,d),{state:{nowDate:c,todayRange:j3(c)},waitMs:d}}setTimeout(e=this.computeTiming().waitMs){this.timeoutId=setTimeout(()=>{const n=this.computeTiming();this.setState(n.state,()=>{this.setTimeout(n.waitMs)})},e)}clearTimeout(){this.timeoutId&&clearTimeout(this.timeoutId)}}ei.contextType=Fa;function j3(t){let e=it(t),n=_t(e,1);return{start:e,end:n}}class A3{getCurrentData(){return this.currentDataManager.getCurrentData()}dispatch(e){this.currentDataManager.dispatch(e)}get view(){return this.getCurrentData().viewApi}batchRendering(e){e()}updateSize(){this.trigger("_resize",!0)}setOption(e,n){this.dispatch({type:"SET_OPTION",optionName:e,rawOptionValue:n})}getOption(e){return this.currentDataManager.currentCalendarOptionsInput[e]}getAvailableLocaleCodes(){return Object.keys(this.getCurrentData().availableRawLocales)}on(e,n){let{currentDataManager:r}=this;r.currentCalendarOptionsRefiners[e]?r.emitter.on(e,n):console.warn(`Unknown listener name '${e}'`)}off(e,n){this.currentDataManager.emitter.off(e,n)}trigger(e,...n){this.currentDataManager.emitter.trigger(e,...n)}changeView(e,n){this.batchRendering(()=>{if(this.unselect(),n)if(n.start&&n.end)this.dispatch({type:"CHANGE_VIEW_TYPE",viewType:e}),this.dispatch({type:"SET_OPTION",optionName:"visibleRange",rawOptionValue:n});else{let{dateEnv:r}=this.getCurrentData();this.dispatch({type:"CHANGE_VIEW_TYPE",viewType:e,dateMarker:r.createMarker(n)})}else this.dispatch({type:"CHANGE_VIEW_TYPE",viewType:e})})}zoomTo(e,n){let r=this.getCurrentData(),i;n=n||"day",i=r.viewSpecs[n]||this.getUnitViewSpec(n),this.unselect(),i?this.dispatch({type:"CHANGE_VIEW_TYPE",viewType:i.type,dateMarker:e}):this.dispatch({type:"CHANGE_DATE",dateMarker:e})}getUnitViewSpec(e){let{viewSpecs:n,toolbarConfig:r}=this.getCurrentData(),i=[].concat(r.header?r.header.viewsWithButtons:[],r.footer?r.footer.viewsWithButtons:[]),c,d;for(let f in n)i.push(f);for(c=0;c{this.dispatch({type:"REMOVE_EVENTS",eventStore:tj(e)})}})}getEventById(e){let n=this.getCurrentData(),{defs:r,instances:i}=n.eventStore;e=String(e);for(let c in r){let d=r[c];if(d.publicId===e){if(d.recurringDef)return new ut(n,d,null);for(let f in i){let h=i[f];if(h.defId===d.defId)return new ut(n,d,h)}}}return null}getEvents(){let e=this.getCurrentData();return jr(e.eventStore,e)}removeAllEvents(){this.dispatch({type:"REMOVE_ALL_EVENTS"})}getEventSources(){let e=this.getCurrentData(),n=e.eventSources,r=[];for(let i in n)r.push(new yl(e,n[i]));return r}getEventSourceById(e){let n=this.getCurrentData(),r=n.eventSources;e=String(e);for(let i in r)if(r[i].publicId===e)return new yl(n,r[i]);return null}addEventSource(e){let n=this.getCurrentData();if(e instanceof yl)return n.eventSources[e.internalEventSource.sourceId]||this.dispatch({type:"ADD_EVENT_SOURCES",sources:[e.internalEventSource]}),e;let r=XS(e,n);return r?(this.dispatch({type:"ADD_EVENT_SOURCES",sources:[r]}),new yl(n,r)):null}removeAllEventSources(){this.dispatch({type:"REMOVE_ALL_EVENT_SOURCES"})}refetchEvents(){this.dispatch({type:"FETCH_EVENT_SOURCES",isRefetch:!0})}scrollToTime(e){let n=Ge(e);n&&this.trigger("_scrollRequest",{time:n})}}function w3(t,e){return t.left>=e.left&&t.left=e.top&&t.topthis.eventUiBuilders[y]||we(T3));for(let b in n){let y=n[b],m=d[b]||Rp,v=this.eventUiBuilders[b];p[b]={businessHours:y.businessHours||e.businessHours,dateSelection:i[b]||null,eventStore:m,eventUiBases:v(e.eventUiBases[""],y.ui,c[b]),eventSelection:m.instances[e.eventSelection]?e.eventSelection:"",eventDrag:f[b]||null,eventResize:h[b]||null}}return p}_splitDateSpan(e){let n={};if(e){let r=this.getKeysForDateSpan(e);for(let i of r)n[i]=e}return n}_getKeysForEventDefs(e){return Ha(e.defs,n=>this.getKeysForEventDef(n))}_splitEventStore(e,n){let{defs:r,instances:i}=e,c={};for(let d in r)for(let f of n[d])c[f]||(c[f]=Cn()),c[f].defs[d]=r[d];for(let d in i){let f=i[d];for(let h of n[f.defId])c[h]&&(c[h].instances[d]=f)}return c}_splitIndividualUi(e,n){let r={};for(let i in e)if(i)for(let c of n[i])r[c]||(r[c]={}),r[c][i]=e[i];return r}_splitInteraction(e){let n={};if(e){let r=this._splitEventStore(e.affectedEvents,this._getKeysForEventDefs(e.affectedEvents)),i=this._getKeysForEventDefs(e.mutatedEvents),c=this._splitEventStore(e.mutatedEvents,i),d=f=>{n[f]||(n[f]={affectedEvents:r[f]||Rp,mutatedEvents:c[f]||Rp,isEvent:e.isEvent})};for(let f in r)d(f);for(let f in c)d(f)}return n}}function T3(t,e,n){let r=[];t&&r.push(t),e&&r.push(e);let i={"":WS(r)};return n&&Object.assign(i,n),i}function uj(t,e,n,r){return{dow:t.getUTCDay(),isDisabled:!!(r&&(!r.activeRange||!Pa(r.activeRange,t))),isOther:!!(r&&!Pa(r.currentRange,t)),isToday:!!(e&&Pa(e,t)),isPast:!!(e&&t=e.end)}}function Em(t,e){let n=["fc-day",`fc-day-${II[t.dow]}`];return t.isDisabled?n.push("fc-day-disabled"):(t.isToday&&(n.push("fc-day-today"),n.push(e.getClass("today"))),t.isPast&&n.push("fc-day-past"),t.isFuture&&n.push("fc-day-future"),t.isOther&&n.push("fc-day-other")),n}const k3=ht({year:"numeric",month:"long",day:"numeric"}),_3=ht({week:"long"});function iu(t,e,n="day",r=!0){const{dateEnv:i,options:c,calendarApi:d}=t;let f=i.format(e,n==="week"?_3:k3);if(c.navLinks){let h=i.toDate(e);const p=b=>{let y=n==="day"?c.navLinkDayClick:n==="week"?c.navLinkWeekClick:null;typeof y=="function"?y.call(d,i.toDate(e),b):(typeof y=="string"&&(n=y),d.zoomTo(e,n))};return Object.assign({title:oo(c.navLinkHint,[f,h],f),"data-navlink":""},r?_S(p):{onClick:p})}return{"aria-label":f}}let Tp=null;function M3(){return Tp===null&&(Tp=I3()),Tp}function I3(){let t=document.createElement("div");io(t,{position:"absolute",top:-1e3,left:0,border:0,padding:0,overflow:"scroll",direction:"rtl"}),t.innerHTML="
",document.body.appendChild(t);let n=t.firstChild.getBoundingClientRect().left>t.getBoundingClientRect().left;return sm(t),n}let kp;function L3(){return kp||(kp=z3()),kp}function z3(){let t=document.createElement("div");t.style.overflow="scroll",t.style.position="absolute",t.style.top="-9999px",t.style.left="-9999px",document.body.appendChild(t);let e=fj(t);return document.body.removeChild(t),e}function fj(t){return{x:t.offsetHeight-t.clientHeight,y:t.offsetWidth-t.clientWidth}}function P3(t,e=!1){let n=window.getComputedStyle(t),r=parseInt(n.borderLeftWidth,10)||0,i=parseInt(n.borderRightWidth,10)||0,c=parseInt(n.borderTopWidth,10)||0,d=parseInt(n.borderBottomWidth,10)||0,f=fj(t),h=f.y-r-i,p=f.x-c-d,b={borderLeft:r,borderRight:i,borderTop:c,borderBottom:d,scrollbarBottom:p,scrollbarLeft:0,scrollbarRight:0};return M3()&&n.direction==="rtl"?b.scrollbarLeft=h:b.scrollbarRight=h,e&&(b.paddingLeft=parseInt(n.paddingLeft,10)||0,b.paddingRight=parseInt(n.paddingRight,10)||0,b.paddingTop=parseInt(n.paddingTop,10)||0,b.paddingBottom=parseInt(n.paddingBottom,10)||0),b}function U3(t,e=!1,n){let r=Sm(t),i=P3(t,e),c={left:r.left+i.borderLeft+i.scrollbarLeft,right:r.right-i.borderRight-i.scrollbarRight,top:r.top+i.borderTop,bottom:r.bottom-i.borderBottom-i.scrollbarBottom};return e&&(c.left+=i.paddingLeft,c.right-=i.paddingRight,c.top+=i.paddingTop,c.bottom-=i.paddingBottom),c}function Sm(t){let e=t.getBoundingClientRect();return{left:e.left+window.scrollX,top:e.top+window.scrollY,right:e.right+window.scrollX,bottom:e.bottom+window.scrollY}}function B3(t){let e=hj(t),n=t.getBoundingClientRect();for(let r of e){let i=dj(n,r.getBoundingClientRect());if(i)n=i;else return null}return n}function hj(t){let e=[];for(;t instanceof HTMLElement;){let n=window.getComputedStyle(t);if(n.position==="fixed")break;/(auto|scroll)/.test(n.overflow+n.overflowY+n.overflowX)&&e.push(t),t=t.parentNode}return e}class Gl{constructor(e,n,r,i){this.els=n;let c=this.originClientRect=e.getBoundingClientRect();r&&this.buildElHorizontals(c.left),i&&this.buildElVerticals(c.top)}buildElHorizontals(e){let n=[],r=[];for(let i of this.els){let c=i.getBoundingClientRect();n.push(c.left-e),r.push(c.right-e)}this.lefts=n,this.rights=r}buildElVerticals(e){let n=[],r=[];for(let i of this.els){let c=i.getBoundingClientRect();n.push(c.top-e),r.push(c.bottom-e)}this.tops=n,this.bottoms=r}leftToIndex(e){let{lefts:n,rights:r}=this,i=n.length,c;for(c=0;c=n[c]&&e=n[c]&&e0}canScrollHorizontally(){return this.getMaxScrollLeft()>0}canScrollUp(){return this.getScrollTop()>0}canScrollDown(){return this.getScrollTop()0}canScrollRight(){return this.getScrollLeft()n.thickness||1){this.getEntryThickness=e,this.strictOrder=!1,this.allowReslicing=!1,this.maxCoord=-1,this.maxStackCnt=-1,this.levelCoords=[],this.entriesByLevel=[],this.stackCnts={}}addSegs(e){let n=[];for(let r of e)this.insertEntry(r,n);return n}insertEntry(e,n){let r=this.findInsertion(e);this.isInsertionValid(r,e)?this.insertEntryAt(e,r):this.handleInvalidInsertion(r,e,n)}isInsertionValid(e,n){return(this.maxCoord===-1||e.levelCoord+this.getEntryThickness(n)<=this.maxCoord)&&(this.maxStackCnt===-1||e.stackCntc.end&&this.insertEntry({index:e.index,thickness:e.thickness,span:{start:c.end,end:i.end}},r)}insertEntryAt(e,n){let{entriesByLevel:r,levelCoords:i}=this;n.lateral===-1?(_p(i,n.level,n.levelCoord),_p(r,n.level,[e])):_p(r[n.level],n.lateral,e),this.stackCnts[Ar(e)]=n.stackCnt}findInsertion(e){let{levelCoords:n,entriesByLevel:r,strictOrder:i,stackCnts:c}=this,d=n.length,f=0,h=-1,p=-1,b=null,y=0;for(let N=0;N=f+this.getEntryThickness(e))break;let j=r[N],R,C=lg(j,e.span.start,rg),O=C[0]+C[1];for(;(R=j[O])&&R.span.startf&&(f=A,b=R,h=N,p=O),A===f&&(y=Math.max(y,c[Ar(R)]+1)),O+=1}}let m=0;if(b)for(m=h+1;mn(t[i-1]))return[i,0];for(;rd)r=c+1;else return[c,1]}return[r,0]}class q3{constructor(e,n){this.emitter=new Ru}destroy(){}setMirrorIsVisible(e){}setMirrorNeedsRevert(e){}setAutoScrollEnabled(e){}}const wm={};function $3(t,e){return!t||e>10?ht({weekday:"short"}):e>1?ht({weekday:"short",month:"numeric",day:"numeric",omitCommas:!0}):ht({weekday:"long"})}const gj="fc-col-header-cell";function mj(t){return t.text}class Y3 extends Ke{render(){let{dateEnv:e,options:n,theme:r,viewApi:i}=this.context,{props:c}=this,{date:d,dateProfile:f}=c,h=uj(d,c.todayRange,null,f),p=[gj].concat(Em(h,r)),b=e.format(d,c.dayHeaderFormat),y=!h.isDisabled&&c.colCnt>1?iu(this.context,d):{},m=e.toDate(d);e.namedTimeZoneImpl&&(m=Us(m,36e5));let v=Object.assign(Object.assign(Object.assign({date:m,view:i},c.extraRenderProps),{text:b}),h);return I(On,{elTag:"th",elClasses:p,elAttrs:Object.assign({role:"columnheader",colSpan:c.colSpan,"data-date":h.isDisabled?void 0:om(d)},c.extraDataAttrs),renderProps:v,generatorName:"dayHeaderContent",customGenerator:n.dayHeaderContent,defaultGenerator:mj,classNameGenerator:n.dayHeaderClassNames,didMount:n.dayHeaderDidMount,willUnmount:n.dayHeaderWillUnmount},N=>I("div",{className:"fc-scrollgrid-sync-inner"},!h.isDisabled&&I(N,{elTag:"a",elAttrs:y,elClasses:["fc-col-header-cell-cushion",c.isSticky&&"fc-sticky"]})))}}const Q3=ht({weekday:"long"});class W3 extends Ke{render(){let{props:e}=this,{dateEnv:n,theme:r,viewApi:i,options:c}=this.context,d=_t(new Date(2592e5),e.dow),f={dow:e.dow,isDisabled:!1,isFuture:!1,isPast:!1,isToday:!1,isOther:!1},h=n.format(d,e.dayHeaderFormat),p=Object.assign(Object.assign(Object.assign(Object.assign({date:d},f),{view:i}),e.extraRenderProps),{text:h});return I(On,{elTag:"th",elClasses:[gj,...Em(f,r),...e.extraClassNames||[]],elAttrs:Object.assign({role:"columnheader",colSpan:e.colSpan},e.extraDataAttrs),renderProps:p,generatorName:"dayHeaderContent",customGenerator:c.dayHeaderContent,defaultGenerator:mj,classNameGenerator:c.dayHeaderClassNames,didMount:c.dayHeaderDidMount,willUnmount:c.dayHeaderWillUnmount},b=>I("div",{className:"fc-scrollgrid-sync-inner"},I(b,{elTag:"a",elClasses:["fc-col-header-cell-cushion",e.isSticky&&"fc-sticky"],elAttrs:{"aria-label":n.format(d,Q3)}})))}}class xj extends Ke{constructor(){super(...arguments),this.createDayHeaderFormatter=we(X3)}render(){let{context:e}=this,{dates:n,dateProfile:r,datesRepDistinctDays:i,renderIntro:c}=this.props,d=this.createDayHeaderFormatter(e.options.dayHeaderFormat,i,n.length);return I(ei,{unit:"day"},(f,h)=>I("tr",{role:"row"},c&&c("day"),n.map(p=>i?I(Y3,{key:p.toISOString(),date:p,dateProfile:r,todayRange:h,colCnt:n.length,dayHeaderFormat:d}):I(W3,{key:p.getUTCDay(),dow:p.getUTCDay(),dayHeaderFormat:d}))))}}function X3(t,e,n){return t||$3(e,n)}class bj{constructor(e,n){let r=e.start,{end:i}=e,c=[],d=[],f=-1;for(;r=n.length?n[n.length-1]+1:n[r]}}class yj{constructor(e,n){let{dates:r}=e,i,c,d;if(n){for(c=r[0].getUTCDay(),i=1;ic.groupId===t)):typeof t=="object"&&t?Mp(Rr(t,e,i)):[]}function Mp(t){let{instances:e}=t,n=[];for(let r in e)n.push(e[r].range);return n}function n6(t,e){for(let n of t)if(Du(n,e))return!0;return!1}const vd=/^(visible|hidden)$/;class a6 extends Ke{constructor(){super(...arguments),this.handleEl=e=>{this.el=e,fa(this.props.elRef,e)}}render(){let{props:e}=this,{liquid:n,liquidIsAbsolute:r}=e,i=n&&r,c=["fc-scroller"];return n&&(r?c.push("fc-scroller-liquid-absolute"):c.push("fc-scroller-liquid")),I("div",{ref:this.handleEl,className:c.join(" "),style:{overflowX:e.overflowX,overflowY:e.overflowY,left:i&&-(e.overcomeLeft||0)||"",right:i&&-(e.overcomeRight||0)||"",bottom:i&&-(e.overcomeBottom||0)||"",marginLeft:!i&&-(e.overcomeLeft||0)||"",marginRight:!i&&-(e.overcomeRight||0)||"",marginBottom:!i&&-(e.overcomeBottom||0)||"",maxHeight:e.maxHeight||""}},e.children)}needsXScrolling(){if(vd.test(this.props.overflowX))return!1;let{el:e}=this,n=this.el.getBoundingClientRect().width-this.getYScrollbarWidth(),{children:r}=e;for(let i=0;in)return!0;return!1}needsYScrolling(){if(vd.test(this.props.overflowY))return!1;let{el:e}=this,n=this.el.getBoundingClientRect().height-this.getXScrollbarWidth(),{children:r}=e;for(let i=0;in)return!0;return!1}getXScrollbarWidth(){return vd.test(this.props.overflowX)?0:this.el.offsetHeight-this.el.clientHeight}getYScrollbarWidth(){return vd.test(this.props.overflowY)?0:this.el.offsetWidth-this.el.clientWidth}}class La{constructor(e){this.masterCallback=e,this.currentMap={},this.depths={},this.callbackMap={},this.handleValue=(n,r)=>{let{depths:i,currentMap:c}=this,d=!1,f=!1;n!==null?(d=r in c,c[r]=n,i[r]=(i[r]||0)+1,f=!0):(i[r]-=1,i[r]||(delete c[r],delete this.callbackMap[r],d=!0)),this.masterCallback&&(d&&this.masterCallback(null,String(r)),f&&this.masterCallback(n,String(r)))}}createRef(e){let n=this.callbackMap[e];return n||(n=this.callbackMap[e]=r=>{this.handleValue(r,String(e))}),n}collect(e,n,r){return g4(this.currentMap,e,n,r)}getAll(){return fm(this.currentMap)}}function s6(t){let e=hI(t,".fc-scrollgrid-shrink"),n=0;for(let r of e)n=Math.max(n,CI(r));return Math.ceil(n)}function jj(t,e){return t.liquid&&e.liquid}function r6(t,e){return e.maxHeight!=null||jj(t,e)}function l6(t,e,n,r){let{expandRows:i}=n;return typeof e.content=="function"?e.content(n):I("table",{role:"presentation",className:[e.tableClassName,t.syncRowHeights?"fc-scrollgrid-sync-table":""].join(" "),style:{minWidth:n.tableMinWidth,width:n.clientWidth,height:i?n.clientHeight:""}},n.tableColGroupNode,I(r?"thead":"tbody",{role:"presentation"},typeof e.rowContent=="function"?e.rowContent(n):e.rowContent))}function i6(t,e){return Ps(t,e,ta)}function o6(t,e){let n=[];for(let r of t){let i=r.span||1;for(let c=0;ce,i6),this.renderMicroColGroup=we(o6),this.scrollerRefs=new La,this.scrollerElRefs=new La(this._handleScrollerEl.bind(this)),this.state={shrinkWidth:null,forceYScrollbars:!1,scrollerClientWidths:{},scrollerClientHeights:{}},this.handleSizing=()=>{this.safeSetState(Object.assign({shrinkWidth:this.computeShrinkWidth()},this.computeScrollerDims()))}}render(){let{props:e,state:n,context:r}=this,i=e.sections||[],c=this.processCols(e.cols),d=this.renderMicroColGroup(c,n.shrinkWidth),f=u6(e.liquid,r);e.collapsibleWidth&&f.push("fc-scrollgrid-collapsible");let h=i.length,p=0,b,y=[],m=[],v=[];for(;p{}},i);return I(i?"th":"td",{ref:r.elRef,role:"presentation"},I("div",{className:`fc-scroller-harness${b?" fc-scroller-harness-liquid":""}`},I(a6,{ref:this.scrollerRefs.createRef(m),elRef:this.scrollerElRefs.createRef(m),overflowY:y,overflowX:c.liquid?"hidden":"visible",maxHeight:e.maxHeight,liquid:b,liquidIsAbsolute:!0},v)))}_handleScrollerEl(e,n){let r=h6(this.props.sections,n);r&&fa(r.chunk.scrollerElRef,e)}componentDidMount(){this.handleSizing(),this.context.addResizeHandler(this.handleSizing)}componentDidUpdate(){this.handleSizing()}componentWillUnmount(){this.context.removeResizeHandler(this.handleSizing)}computeShrinkWidth(){return d6(this.props.cols)?s6(this.scrollerElRefs.getAll()):0}computeScrollerDims(){let e=L3(),{scrollerRefs:n,scrollerElRefs:r}=this,i=!1,c={},d={};for(let f in n.currentMap){let h=n.currentMap[f];if(h&&h.needsYScrolling()){i=!0;break}}for(let f of this.props.sections){let h=f.key,p=r.currentMap[h];if(p){let b=p.parentNode;c[h]=Math.floor(b.getBoundingClientRect().width-(i?e.y:0)),d[h]=Math.floor(b.getBoundingClientRect().height)}}return{forceYScrollbars:i,scrollerClientWidths:c,scrollerClientHeights:d}}}Cm.addStateEquality({scrollerClientWidths:ta,scrollerClientHeights:ta});function h6(t,e){for(let n of t)if(n.key===e)return n;return null}class Dm extends Ke{constructor(){super(...arguments),this.buildPublicEvent=we((e,n,r)=>new ut(e,n,r)),this.handleEl=e=>{this.el=e,fa(this.props.elRef,e),e&&I1(e,this.props.seg)}}render(){const{props:e,context:n}=this,{options:r}=n,{seg:i}=e,{eventRange:c}=i,{ui:d}=c,f={event:this.buildPublicEvent(n,c.def,c.instance),view:n.viewApi,timeText:e.timeText,textColor:d.textColor,backgroundColor:d.backgroundColor,borderColor:d.borderColor,isDraggable:!e.disableDragging&&o3(i,n),isStartResizable:!e.disableResizing&&c3(i,n),isEndResizable:!e.disableResizing&&d3(i),isMirror:!!(e.isDragging||e.isResizing||e.isDateSelecting),isStart:!!i.isStart,isEnd:!!i.isEnd,isPast:!!e.isPast,isFuture:!!e.isFuture,isToday:!!e.isToday,isSelected:!!e.isSelected,isDragging:!!e.isDragging,isResizing:!!e.isResizing};return I(On,{elRef:this.handleEl,elTag:e.elTag,elAttrs:e.elAttrs,elClasses:[...u3(f),...i.eventRange.ui.classNames,...e.elClasses||[]],elStyle:e.elStyle,renderProps:f,generatorName:"eventContent",customGenerator:r.eventContent,defaultGenerator:e.defaultGenerator,classNameGenerator:r.eventClassNames,didMount:r.eventDidMount,willUnmount:r.eventWillUnmount},e.children)}componentDidUpdate(e){this.el&&this.props.seg!==e.seg&&I1(this.el,this.props.seg)}}class Om extends Ke{render(){let{props:e,context:n}=this,{options:r}=n,{seg:i}=e,{ui:c}=i.eventRange,d=r.eventTimeFormat||e.defaultTimeFormat,f=sj(i,d,n,e.defaultDisplayEventTime,e.defaultDisplayEventEnd);return I(Dm,Object.assign({},e,{elTag:"a",elStyle:{borderColor:c.borderColor,backgroundColor:c.backgroundColor},elAttrs:lj(i,n),defaultGenerator:p6,timeText:f}),(h,p)=>I(lt,null,I(h,{elTag:"div",elClasses:["fc-event-main"],elStyle:{color:p.textColor}}),!!p.isStartResizable&&I("div",{className:"fc-event-resizer fc-event-resizer-start"}),!!p.isEndResizable&&I("div",{className:"fc-event-resizer fc-event-resizer-end"})))}}Om.addPropsEquality({seg:ta});function p6(t){return I("div",{className:"fc-event-main-frame"},t.timeText&&I("div",{className:"fc-event-time"},t.timeText),I("div",{className:"fc-event-title-container"},I("div",{className:"fc-event-title fc-sticky"},t.event.title||I(lt,null," "))))}const Rm=t=>I(Fa.Consumer,null,e=>{let{options:n}=e,r={isAxis:t.isAxis,date:e.dateEnv.toDate(t.date),view:e.viewApi};return I(On,{elRef:t.elRef,elTag:t.elTag||"div",elAttrs:t.elAttrs,elClasses:t.elClasses,elStyle:t.elStyle,renderProps:r,generatorName:"nowIndicatorContent",customGenerator:n.nowIndicatorContent,classNameGenerator:n.nowIndicatorClassNames,didMount:n.nowIndicatorDidMount,willUnmount:n.nowIndicatorWillUnmount},t.children)}),g6=ht({day:"numeric"});class Tm extends Ke{constructor(){super(...arguments),this.refineRenderProps=Rd(m6)}render(){let{props:e,context:n}=this,{options:r}=n,i=this.refineRenderProps({date:e.date,dateProfile:e.dateProfile,todayRange:e.todayRange,isMonthStart:e.isMonthStart||!1,showDayNumber:e.showDayNumber,extraRenderProps:e.extraRenderProps,viewApi:n.viewApi,dateEnv:n.dateEnv,monthStartFormat:r.monthStartFormat});return I(On,{elRef:e.elRef,elTag:e.elTag,elAttrs:Object.assign(Object.assign({},e.elAttrs),i.isDisabled?{}:{"data-date":om(e.date)}),elClasses:[...Em(i,n.theme),...e.elClasses||[]],elStyle:e.elStyle,renderProps:i,generatorName:"dayCellContent",customGenerator:r.dayCellContent,defaultGenerator:e.defaultGenerator,classNameGenerator:i.isDisabled?void 0:r.dayCellClassNames,didMount:r.dayCellDidMount,willUnmount:r.dayCellWillUnmount},e.children)}}function km(t){return!!(t.dayCellContent||tg("dayCellContent",t))}function m6(t){let{date:e,dateEnv:n,dateProfile:r,isMonthStart:i}=t,c=uj(e,t.todayRange,null,r),d=t.showDayNumber?n.format(e,i?t.monthStartFormat:g6):"";return Object.assign(Object.assign(Object.assign({date:n.toDate(e),view:t.viewApi},c),{isMonthStart:i,dayNumberText:d}),t.extraRenderProps)}class wj extends Ke{render(){let{props:e}=this,{seg:n}=e;return I(Dm,{elTag:"div",elClasses:["fc-bg-event"],elStyle:{backgroundColor:n.eventRange.ui.backgroundColor},defaultGenerator:x6,seg:n,timeText:"",isDragging:!1,isResizing:!1,isDateSelecting:!1,isSelected:!1,isPast:e.isPast,isFuture:e.isFuture,isToday:e.isToday,disableDragging:!0,disableResizing:!0})}}function x6(t){let{title:e}=t.event;return e&&I("div",{className:"fc-event-title"},t.event.title)}function Cj(t){return I("div",{className:`fc-${t}`})}const Dj=t=>I(Fa.Consumer,null,e=>{let{dateEnv:n,options:r}=e,{date:i}=t,c=r.weekNumberFormat||t.defaultFormat,d=n.computeWeekNumber(i),f=n.format(i,c),h={num:d,text:f,date:i};return I(On,{elRef:t.elRef,elTag:t.elTag,elAttrs:t.elAttrs,elClasses:t.elClasses,elStyle:t.elStyle,renderProps:h,generatorName:"weekNumberContent",customGenerator:r.weekNumberContent,defaultGenerator:b6,classNameGenerator:r.weekNumberClassNames,didMount:r.weekNumberDidMount,willUnmount:r.weekNumberWillUnmount},t.children)});function b6(t){return t.text}const Ip=10;class y6 extends Ke{constructor(){super(...arguments),this.state={titleId:wu()},this.handleRootEl=e=>{this.rootEl=e,this.props.elRef&&fa(this.props.elRef,e)},this.handleDocumentMouseDown=e=>{const n=TS(e);this.rootEl.contains(n)||this.handleCloseClick()},this.handleDocumentKeyDown=e=>{e.key==="Escape"&&this.handleCloseClick()},this.handleCloseClick=()=>{let{onClose:e}=this.props;e&&e()}}render(){let{theme:e,options:n}=this.context,{props:r,state:i}=this,c=["fc-popover",e.getClass("popover")].concat(r.extraClassNames||[]);return JM(I("div",Object.assign({},r.extraAttrs,{id:r.id,className:c.join(" "),"aria-labelledby":i.titleId,ref:this.handleRootEl}),I("div",{className:"fc-popover-header "+e.getClass("popoverHeader")},I("span",{className:"fc-popover-title",id:i.titleId},r.title),I("span",{className:"fc-popover-close "+e.getIconClass("close"),title:n.closeHint,onClick:this.handleCloseClick})),I("div",{className:"fc-popover-body "+e.getClass("popoverContent")},r.children)),r.parentEl)}componentDidMount(){document.addEventListener("mousedown",this.handleDocumentMouseDown),document.addEventListener("keydown",this.handleDocumentKeyDown),this.updateSize()}componentWillUnmount(){document.removeEventListener("mousedown",this.handleDocumentMouseDown),document.removeEventListener("keydown",this.handleDocumentKeyDown)}updateSize(){let{isRtl:e}=this.context,{alignmentEl:n,alignGridTop:r}=this.props,{rootEl:i}=this,c=B3(n);if(c){let d=i.getBoundingClientRect(),f=r?qt(n,".fc-scrollgrid").getBoundingClientRect().top:c.top,h=e?c.right-d.width:c.left;f=Math.max(f,Ip),h=Math.min(h,document.documentElement.clientWidth-Ip-d.width),h=Math.max(h,Ip);let p=i.offsetParent.getBoundingClientRect();io(i,{top:f-p.top,left:h-p.left})}}}class v6 extends pa{constructor(){super(...arguments),this.handleRootEl=e=>{this.rootEl=e,e?this.context.registerInteractiveComponent(this,{el:e,useEventCenter:!1}):this.context.unregisterInteractiveComponent(this)}}render(){let{options:e,dateEnv:n}=this.context,{props:r}=this,{startDate:i,todayRange:c,dateProfile:d}=r,f=n.format(i,e.dayPopoverFormat);return I(Tm,{elRef:this.handleRootEl,date:i,dateProfile:d,todayRange:c},(h,p,b)=>I(y6,{elRef:b.ref,id:r.id,title:f,extraClassNames:["fc-more-popover"].concat(b.className||[]),extraAttrs:b,parentEl:r.parentEl,alignmentEl:r.alignmentEl,alignGridTop:r.alignGridTop,onClose:r.onClose},km(e)&&I(h,{elTag:"div",elClasses:["fc-more-popover-misc"]}),r.children))}queryHit(e,n,r,i){let{rootEl:c,props:d}=this;return e>=0&&e=0&&n{this.linkEl=e,this.props.elRef&&fa(this.props.elRef,e)},this.handleClick=e=>{let{props:n,context:r}=this,{moreLinkClick:i}=r.options,c=z1(n).start;function d(f){let{def:h,instance:p,range:b}=f.eventRange;return{event:new ut(r,h,p),start:r.dateEnv.toDate(b.start),end:r.dateEnv.toDate(b.end),isStart:f.isStart,isEnd:f.isEnd}}typeof i=="function"&&(i=i({date:c,allDay:!!n.allDayDate,allSegs:n.allSegs.map(d),hiddenSegs:n.hiddenSegs.map(d),jsEvent:e,view:r.viewApi})),!i||i==="popover"?this.setState({isPopoverOpen:!0}):typeof i=="string"&&r.calendarApi.zoomTo(c,i)},this.handlePopoverClose=()=>{this.setState({isPopoverOpen:!1})}}render(){let{props:e,state:n}=this;return I(Fa.Consumer,null,r=>{let{viewApi:i,options:c,calendarApi:d}=r,{moreLinkText:f}=c,{moreCnt:h}=e,p=z1(e),b=typeof f=="function"?f.call(d,h):`+${h} ${f}`,y=oo(c.moreLinkHint,[h],b),m={num:h,shortText:`+${h}`,text:b,view:i};return I(lt,null,!!e.moreCnt&&I(On,{elTag:e.elTag||"a",elRef:this.handleLinkEl,elClasses:[...e.elClasses||[],"fc-more-link"],elStyle:e.elStyle,elAttrs:Object.assign(Object.assign(Object.assign({},e.elAttrs),_S(this.handleClick)),{title:y,"aria-expanded":n.isPopoverOpen,"aria-controls":n.isPopoverOpen?n.popoverId:""}),renderProps:m,generatorName:"moreLinkContent",customGenerator:c.moreLinkContent,defaultGenerator:e.defaultGenerator||N6,classNameGenerator:c.moreLinkClassNames,didMount:c.moreLinkDidMount,willUnmount:c.moreLinkWillUnmount},e.children),n.isPopoverOpen&&I(v6,{id:n.popoverId,startDate:p.start,endDate:p.end,dateProfile:e.dateProfile,todayRange:e.todayRange,extraDateSpan:e.extraDateSpan,parentEl:this.parentEl,alignmentEl:e.alignmentElRef?e.alignmentElRef.current:this.linkEl,alignGridTop:e.alignGridTop,forceTimed:e.forceTimed,onClose:this.handlePopoverClose},e.popoverContent()))})}componentDidMount(){this.updateParentEl()}componentDidUpdate(){this.updateParentEl()}updateParentEl(){this.linkEl&&(this.parentEl=qt(this.linkEl,".fc-view-harness"))}}function N6(t){return t.text}function z1(t){if(t.allDayDate)return{start:t.allDayDate,end:_t(t.allDayDate,1)};let{hiddenSegs:e}=t;return{start:Rj(e),end:S6(e)}}function Rj(t){return t.reduce(E6).eventRange.range.start}function E6(t,e){return t.eventRange.range.starte.eventRange.range.end?t:e}class A6{constructor(){this.handlers=[]}set(e){this.currentValue=e;for(let n of this.handlers)n(e)}subscribe(e){this.handlers.push(e),this.currentValue!==void 0&&e(this.currentValue)}}class w6 extends A6{constructor(){super(...arguments),this.map=new Map}handle(e){const{map:n}=this;let r=!1;e.isActive?(n.set(e.id,e),r=!0):n.has(e.id)&&(n.delete(e.id),r=!0),r&&this.set(n)}}const C6=[],Tj={code:"en",week:{dow:0,doy:4},direction:"ltr",buttonText:{prev:"prev",next:"next",prevYear:"prev year",nextYear:"next year",year:"year",today:"today",month:"month",week:"week",day:"day",list:"list"},weekText:"W",weekTextLong:"Week",closeHint:"Close",timeHint:"Time",eventHint:"Event",allDayText:"all-day",moreLinkText:"more",noEventsText:"No events to display"},kj=Object.assign(Object.assign({},Tj),{buttonHints:{prev:"Previous $0",next:"Next $0",today(t,e){return e==="day"?"Today":`This ${t}`}},viewHint:"$0 view",navLinkHint:"Go to $0",moreLinkHint(t){return`Show ${t} more event${t===1?"":"s"}`}});function D6(t){let e=t.length>0?t[0].code:"en",n=C6.concat(t),r={en:kj};for(let i of n)r[i.code]=i;return{map:r,defaultCode:e}}function _j(t,e){return typeof t=="object"&&!Array.isArray(t)?Mj(t.code,[t.code],t):O6(t,e)}function O6(t,e){let n=[].concat(t||[]),r=R6(n,e)||kj;return Mj(t,n,r)}function R6(t,e){for(let n=0;n0;i-=1){let c=r.slice(0,i).join("-");if(e[c])return e[c]}}return null}function Mj(t,e,n){let r=um([Tj,n],["buttonText"]);delete r.code;let{week:i}=r;return delete r.week,{codeArg:t,codes:e,week:i,simpleNumberFormat:new Intl.NumberFormat(t),options:r}}function qa(t){return{id:Tr(),name:t.name,premiumReleaseDate:t.premiumReleaseDate?new Date(t.premiumReleaseDate):void 0,deps:t.deps||[],reducers:t.reducers||[],isLoadingFuncs:t.isLoadingFuncs||[],contextInit:[].concat(t.contextInit||[]),eventRefiners:t.eventRefiners||{},eventDefMemberAdders:t.eventDefMemberAdders||[],eventSourceRefiners:t.eventSourceRefiners||{},isDraggableTransformers:t.isDraggableTransformers||[],eventDragMutationMassagers:t.eventDragMutationMassagers||[],eventDefMutationAppliers:t.eventDefMutationAppliers||[],dateSelectionTransformers:t.dateSelectionTransformers||[],datePointTransforms:t.datePointTransforms||[],dateSpanTransforms:t.dateSpanTransforms||[],views:t.views||{},viewPropsTransformers:t.viewPropsTransformers||[],isPropsValid:t.isPropsValid||null,externalDefTransforms:t.externalDefTransforms||[],viewContainerAppends:t.viewContainerAppends||[],eventDropTransformers:t.eventDropTransformers||[],componentInteractions:t.componentInteractions||[],calendarInteractions:t.calendarInteractions||[],themeClasses:t.themeClasses||{},eventSourceDefs:t.eventSourceDefs||[],cmdFormatter:t.cmdFormatter,recurringTypes:t.recurringTypes||[],namedTimeZonedImpl:t.namedTimeZonedImpl,initialView:t.initialView||"",elementDraggingImpl:t.elementDraggingImpl,optionChangeHandlers:t.optionChangeHandlers||{},scrollGridImpl:t.scrollGridImpl||null,listenerRefiners:t.listenerRefiners||{},optionRefiners:t.optionRefiners||{},propSetHandlers:t.propSetHandlers||{}}}function T6(t,e){let n={},r={premiumReleaseDate:void 0,reducers:[],isLoadingFuncs:[],contextInit:[],eventRefiners:{},eventDefMemberAdders:[],eventSourceRefiners:{},isDraggableTransformers:[],eventDragMutationMassagers:[],eventDefMutationAppliers:[],dateSelectionTransformers:[],datePointTransforms:[],dateSpanTransforms:[],views:{},viewPropsTransformers:[],isPropsValid:null,externalDefTransforms:[],viewContainerAppends:[],eventDropTransformers:[],componentInteractions:[],calendarInteractions:[],themeClasses:{},eventSourceDefs:[],cmdFormatter:null,recurringTypes:[],namedTimeZonedImpl:null,initialView:"",elementDraggingImpl:null,optionChangeHandlers:{},scrollGridImpl:null,listenerRefiners:{},optionRefiners:{},propSetHandlers:{}};function i(c){for(let d of c){const f=d.name,h=n[f];h===void 0?(n[f]=d.id,i(d.deps),r=_6(r,d)):h!==d.id&&console.warn(`Duplicate plugin '${f}'`)}}return t&&i(t),i(e),r}function k6(){let t=[],e=[],n;return(r,i)=>((!n||!Ps(r,t)||!Ps(i,e))&&(n=T6(r,i)),t=r,e=i,n)}function _6(t,e){return{premiumReleaseDate:M6(t.premiumReleaseDate,e.premiumReleaseDate),reducers:t.reducers.concat(e.reducers),isLoadingFuncs:t.isLoadingFuncs.concat(e.isLoadingFuncs),contextInit:t.contextInit.concat(e.contextInit),eventRefiners:Object.assign(Object.assign({},t.eventRefiners),e.eventRefiners),eventDefMemberAdders:t.eventDefMemberAdders.concat(e.eventDefMemberAdders),eventSourceRefiners:Object.assign(Object.assign({},t.eventSourceRefiners),e.eventSourceRefiners),isDraggableTransformers:t.isDraggableTransformers.concat(e.isDraggableTransformers),eventDragMutationMassagers:t.eventDragMutationMassagers.concat(e.eventDragMutationMassagers),eventDefMutationAppliers:t.eventDefMutationAppliers.concat(e.eventDefMutationAppliers),dateSelectionTransformers:t.dateSelectionTransformers.concat(e.dateSelectionTransformers),datePointTransforms:t.datePointTransforms.concat(e.datePointTransforms),dateSpanTransforms:t.dateSpanTransforms.concat(e.dateSpanTransforms),views:Object.assign(Object.assign({},t.views),e.views),viewPropsTransformers:t.viewPropsTransformers.concat(e.viewPropsTransformers),isPropsValid:e.isPropsValid||t.isPropsValid,externalDefTransforms:t.externalDefTransforms.concat(e.externalDefTransforms),viewContainerAppends:t.viewContainerAppends.concat(e.viewContainerAppends),eventDropTransformers:t.eventDropTransformers.concat(e.eventDropTransformers),calendarInteractions:t.calendarInteractions.concat(e.calendarInteractions),componentInteractions:t.componentInteractions.concat(e.componentInteractions),themeClasses:Object.assign(Object.assign({},t.themeClasses),e.themeClasses),eventSourceDefs:t.eventSourceDefs.concat(e.eventSourceDefs),cmdFormatter:e.cmdFormatter||t.cmdFormatter,recurringTypes:t.recurringTypes.concat(e.recurringTypes),namedTimeZonedImpl:e.namedTimeZonedImpl||t.namedTimeZonedImpl,initialView:t.initialView||e.initialView,elementDraggingImpl:t.elementDraggingImpl||e.elementDraggingImpl,optionChangeHandlers:Object.assign(Object.assign({},t.optionChangeHandlers),e.optionChangeHandlers),scrollGridImpl:e.scrollGridImpl||t.scrollGridImpl,listenerRefiners:Object.assign(Object.assign({},t.listenerRefiners),e.listenerRefiners),optionRefiners:Object.assign(Object.assign({},t.optionRefiners),e.optionRefiners),propSetHandlers:Object.assign(Object.assign({},t.propSetHandlers),e.propSetHandlers)}}function M6(t,e){return t===void 0?e:e===void 0?t:new Date(Math.max(t.valueOf(),e.valueOf()))}class Hs extends Bo{}Hs.prototype.classes={root:"fc-theme-standard",tableCellShaded:"fc-cell-shaded",buttonGroup:"fc-button-group",button:"fc-button fc-button-primary",buttonActive:"fc-button-active"};Hs.prototype.baseIconClass="fc-icon";Hs.prototype.iconClasses={close:"fc-icon-x",prev:"fc-icon-chevron-left",next:"fc-icon-chevron-right",prevYear:"fc-icon-chevrons-left",nextYear:"fc-icon-chevrons-right"};Hs.prototype.rtlIconClasses={prev:"fc-icon-chevron-right",next:"fc-icon-chevron-left",prevYear:"fc-icon-chevrons-right",nextYear:"fc-icon-chevrons-left"};Hs.prototype.iconOverrideOption="buttonIcons";Hs.prototype.iconOverrideCustomButtonOption="icon";Hs.prototype.iconOverridePrefix="fc-icon-";function I6(t,e){let n={},r;for(r in t)og(r,n,t,e);for(r in e)og(r,n,t,e);return n}function og(t,e,n,r){if(e[t])return e[t];let i=L6(t,e,n,r);return i&&(e[t]=i),i}function L6(t,e,n,r){let i=n[t],c=r[t],d=b=>i&&i[b]!==null?i[b]:c&&c[b]!==null?c[b]:null,f=d("component"),h=d("superType"),p=null;if(h){if(h===t)throw new Error("Can't have a custom view type that references itself");p=og(h,e,n,r)}return!f&&p&&(f=p.component),f?{type:t,component:f,defaults:Object.assign(Object.assign({},p?p.defaults:{}),i?i.rawOptions:{}),overrides:Object.assign(Object.assign({},p?p.overrides:{}),c?c.rawOptions:{})}:null}function P1(t){return Ha(t,z6)}function z6(t){let e=typeof t=="function"?{component:t}:t,{component:n}=e;return e.content?n=U1(e):n&&!(n.prototype instanceof Ke)&&(n=U1(Object.assign(Object.assign({},e),{content:n}))),{superType:e.type,component:n,rawOptions:e}}function U1(t){return e=>I(Fa.Consumer,null,n=>I(On,{elTag:"div",elClasses:GS(n.viewSpec),renderProps:Object.assign(Object.assign({},e),{nextDayThreshold:n.options.nextDayThreshold}),generatorName:void 0,customGenerator:t.content,classNameGenerator:t.classNames,didMount:t.didMount,willUnmount:t.willUnmount}))}function P6(t,e,n,r){let i=P1(t),c=P1(e.views),d=I6(i,c);return Ha(d,f=>U6(f,c,e,n,r))}function U6(t,e,n,r,i){let c=t.overrides.duration||t.defaults.duration||r.duration||n.duration,d=null,f="",h="",p={};if(c&&(d=B6(c),d)){let m=eg(d);f=m.unit,m.value===1&&(h=f,p=e[f]?e[f].rawOptions:{})}let b=m=>{let v=m.buttonText||{},N=t.defaults.buttonTextKey;return N!=null&&v[N]!=null?v[N]:v[t.type]!=null?v[t.type]:v[h]!=null?v[h]:null},y=m=>{let v=m.buttonHints||{},N=t.defaults.buttonTextKey;return N!=null&&v[N]!=null?v[N]:v[t.type]!=null?v[t.type]:v[h]!=null?v[h]:null};return{type:t.type,component:t.component,duration:d,durationUnit:f,singleUnit:h,optionDefaults:t.defaults,optionOverrides:Object.assign(Object.assign({},p),t.overrides),buttonTextOverride:b(r)||b(n)||t.overrides.buttonText,buttonTextDefault:b(i)||t.defaults.buttonText||b(co)||t.type,buttonTitleOverride:y(r)||y(n)||t.overrides.buttonHint,buttonTitleDefault:y(i)||t.defaults.buttonHint||y(co)}}let B1={};function B6(t){let e=JSON.stringify(t),n=B1[e];return n===void 0&&(n=Ge(t),B1[e]=n),n}function H6(t,e){switch(e.type){case"CHANGE_VIEW_TYPE":t=e.viewType}return t}function G6(t,e){switch(e.type){case"CHANGE_DATE":return e.dateMarker;default:return t}}function V6(t,e,n){let r=t.initialDate;return r!=null?e.createMarker(r):n.getDateMarker()}function F6(t,e){switch(e.type){case"SET_OPTION":return Object.assign(Object.assign({},t),{[e.optionName]:e.rawOptionValue});default:return t}}function q6(t,e,n,r){let i;switch(e.type){case"CHANGE_VIEW_TYPE":return r.build(e.dateMarker||n);case"CHANGE_DATE":return r.build(e.dateMarker);case"PREV":if(i=r.buildPrev(t,n),i.isValid)return i;break;case"NEXT":if(i=r.buildNext(t,n),i.isValid)return i;break}return t}function $6(t,e,n){let r=e?e.activeRange:null;return Lj({},J6(t,n),r,n)}function Y6(t,e,n,r){let i=n?n.activeRange:null;switch(e.type){case"ADD_EVENT_SOURCES":return Lj(t,e.sources,i,r);case"REMOVE_EVENT_SOURCE":return W6(t,e.sourceId);case"PREV":case"NEXT":case"CHANGE_DATE":case"CHANGE_VIEW_TYPE":return n?zj(t,i,r):t;case"FETCH_EVENT_SOURCES":return _m(t,e.sourceIds?zS(e.sourceIds):Pj(t,r),i,e.isRefetch||!1,r);case"RECEIVE_EVENTS":case"RECEIVE_EVENT_ERROR":return K6(t,e.sourceId,e.fetchId,e.fetchRange);case"REMOVE_ALL_EVENT_SOURCES":return{};default:return t}}function Q6(t,e,n){let r=e?e.activeRange:null;return _m(t,Pj(t,n),r,!0,n)}function Ij(t){for(let e in t)if(t[e].isFetching)return!0;return!1}function Lj(t,e,n,r){let i={};for(let c of e)i[c.sourceId]=c;return n&&(i=zj(i,n,r)),Object.assign(Object.assign({},t),i)}function W6(t,e){return Dr(t,n=>n.sourceId!==e)}function zj(t,e,n){return _m(t,Dr(t,r=>X6(r,e,n)),e,!1,n)}function X6(t,e,n){return Uj(t,n)?!n.options.lazyFetching||!t.fetchRange||t.isFetching||e.startt.fetchRange.end:!t.latestFetchId}function _m(t,e,n,r,i){let c={};for(let d in t){let f=t[d];e[d]?c[d]=Z6(f,n,r,i):c[d]=f}return c}function Z6(t,e,n,r){let{options:i,calendarApi:c}=r,d=r.pluginHooks.eventSourceDefs[t.sourceDefId],f=Tr();return d.fetch({eventSource:t,range:e,isRefetch:n,context:r},h=>{let{rawEvents:p}=h;i.eventSourceSuccess&&(p=i.eventSourceSuccess.call(c,p,h.response)||p),t.success&&(p=t.success.call(c,p,h.response)||p),r.dispatch({type:"RECEIVE_EVENTS",sourceId:t.sourceId,fetchId:f,fetchRange:e,rawEvents:p})},h=>{let p=!1;i.eventSourceFailure&&(i.eventSourceFailure.call(c,h),p=!0),t.failure&&(t.failure(h),p=!0),p||console.warn(h.message,h),r.dispatch({type:"RECEIVE_EVENT_ERROR",sourceId:t.sourceId,fetchId:f,fetchRange:e,error:h})}),Object.assign(Object.assign({},t),{isFetching:!0,latestFetchId:f})}function K6(t,e,n,r){let i=t[e];return i&&n===i.latestFetchId?Object.assign(Object.assign({},t),{[e]:Object.assign(Object.assign({},i),{isFetching:!1,fetchRange:r})}):t}function Pj(t,e){return Dr(t,n=>Uj(n,e))}function J6(t,e){let n=ZS(e),r=[].concat(t.eventSources||[]),i=[];t.initialEvents&&r.unshift(t.initialEvents),t.events&&r.unshift(t.events);for(let c of r){let d=XS(c,e,n);d&&i.push(d)}return i}function Uj(t,e){return!e.pluginHooks.eventSourceDefs[t.sourceDefId].ignoreRange}function eL(t,e){switch(e.type){case"UNSELECT_DATES":return null;case"SELECT_DATES":return e.selection;default:return t}}function tL(t,e){switch(e.type){case"UNSELECT_EVENT":return"";case"SELECT_EVENT":return e.eventInstanceId;default:return t}}function nL(t,e){let n;switch(e.type){case"UNSET_EVENT_DRAG":return null;case"SET_EVENT_DRAG":return n=e.state,{affectedEvents:n.affectedEvents,mutatedEvents:n.mutatedEvents,isEvent:n.isEvent};default:return t}}function aL(t,e){let n;switch(e.type){case"UNSET_EVENT_RESIZE":return null;case"SET_EVENT_RESIZE":return n=e.state,{affectedEvents:n.affectedEvents,mutatedEvents:n.mutatedEvents,isEvent:n.isEvent};default:return t}}function sL(t,e,n,r,i){let c=t.headerToolbar?H1(t.headerToolbar,t,e,n,r,i):null,d=t.footerToolbar?H1(t.footerToolbar,t,e,n,r,i):null;return{header:c,footer:d}}function H1(t,e,n,r,i,c){let d={},f=[],h=!1;for(let p in t){let b=t[p],y=rL(b,e,n,r,i,c);d[p]=y.widgets,f.push(...y.viewsWithButtons),h=h||y.hasTitle}return{sectionWidgets:d,viewsWithButtons:f,hasTitle:h}}function rL(t,e,n,r,i,c){let d=e.direction==="rtl",f=e.customButtons||{},h=n.buttonText||{},p=e.buttonText||{},b=n.buttonHints||{},y=e.buttonHints||{},m=t?t.split(" "):[],v=[],N=!1;return{widgets:m.map(j=>j.split(",").map(R=>{if(R==="title")return N=!0,{buttonName:R};let C,O,A,k,_,B;if(C=f[R])A=F=>{C.click&&C.click.call(F.target,F,F.target)},(k=r.getCustomButtonIconClass(C))||(k=r.getIconClass(R,d))||(_=C.text),B=C.hint||C.text;else if(O=i[R]){v.push(R),A=()=>{c.changeView(R)},(_=O.buttonTextOverride)||(k=r.getIconClass(R,d))||(_=O.buttonTextDefault);let F=O.buttonTextOverride||O.buttonTextDefault;B=oo(O.buttonTitleOverride||O.buttonTitleDefault||e.viewHint,[F,R],F)}else if(c[R])if(A=()=>{c[R]()},(_=h[R])||(k=r.getIconClass(R,d))||(_=p[R]),R==="prevYear"||R==="nextYear"){let F=R==="prevYear"?"prev":"next";B=oo(b[F]||y[F],[p.year||"year","year"],p[R])}else B=F=>oo(b[R]||y[R],[p[F]||F,F],p[R]);return{buttonName:R,buttonClick:A,buttonIcon:k,buttonText:_,buttonHint:B}})),viewsWithButtons:v,hasTitle:N}}class lL{constructor(e,n,r){this.type=e,this.getCurrentData=n,this.dateEnv=r}get calendar(){return this.getCurrentData().calendarApi}get title(){return this.getCurrentData().viewTitle}get activeStart(){return this.dateEnv.toDate(this.getCurrentData().dateProfile.activeRange.start)}get activeEnd(){return this.dateEnv.toDate(this.getCurrentData().dateProfile.activeRange.end)}get currentStart(){return this.dateEnv.toDate(this.getCurrentData().dateProfile.currentRange.start)}get currentEnd(){return this.dateEnv.toDate(this.getCurrentData().dateProfile.currentRange.end)}getOption(e){return this.getCurrentData().options[e]}}let iL={ignoreRange:!0,parseMeta(t){return Array.isArray(t.events)?t.events:null},fetch(t,e){e({rawEvents:t.eventSource.meta})}};const oL=qa({name:"array-event-source",eventSourceDefs:[iL]});let cL={parseMeta(t){return typeof t.events=="function"?t.events:null},fetch(t,e,n){const{dateEnv:r}=t.context,i=t.eventSource.meta;y3(i.bind(null,ij(t.range,r)),c=>e({rawEvents:c}),n)}};const dL=qa({name:"func-event-source",eventSourceDefs:[cL]}),uL={method:String,extraParams:Z,startParam:String,endParam:String,timeZoneParam:String};let fL={parseMeta(t){return t.url&&(t.format==="json"||!t.format)?{url:t.url,format:"json",method:(t.method||"GET").toUpperCase(),extraParams:t.extraParams,startParam:t.startParam,endParam:t.endParam,timeZoneParam:t.timeZoneParam}:null},fetch(t,e,n){const{meta:r}=t.eventSource,i=pL(r,t.range,t.context);v3(r.method,r.url,i).then(([c,d])=>{e({rawEvents:c,response:d})},n)}};const hL=qa({name:"json-event-source",eventSourceRefiners:uL,eventSourceDefs:[fL]});function pL(t,e,n){let{dateEnv:r,options:i}=n,c,d,f,h,p={};return c=t.startParam,c==null&&(c=i.startParam),d=t.endParam,d==null&&(d=i.endParam),f=t.timeZoneParam,f==null&&(f=i.timeZoneParam),typeof t.extraParams=="function"?h=t.extraParams():h=t.extraParams||{},Object.assign(p,h),p[c]=r.formatIso(e.start),p[d]=r.formatIso(e.end),r.timeZone!=="local"&&(p[f]=r.timeZone),p}const gL={daysOfWeek:Z,startTime:Ge,endTime:Ge,duration:Ge,startRecur:Z,endRecur:Z};let mL={parse(t,e){if(t.daysOfWeek||t.startTime||t.endTime||t.startRecur||t.endRecur){let n={daysOfWeek:t.daysOfWeek||null,startTime:t.startTime||null,endTime:t.endTime||null,startRecur:t.startRecur?e.createMarker(t.startRecur):null,endRecur:t.endRecur?e.createMarker(t.endRecur):null,dateEnv:e},r;return t.duration&&(r=t.duration),!r&&t.startTime&&t.endTime&&(r=TI(t.endTime,t.startTime)),{allDayGuess:!t.startTime&&!t.endTime,duration:r,typeData:n}}return null},expand(t,e,n){let r=Or(e,{start:t.startRecur,end:t.endRecur});return r?bL(t.daysOfWeek,t.startTime,t.dateEnv,n,r):[]}};const xL=qa({name:"simple-recurring-event",recurringTypes:[mL],eventRefiners:gL});function bL(t,e,n,r,i){let c=t?zS(t):null,d=it(i.start),f=i.end,h=[];for(e&&(e.milliseconds<0?f=_t(f,1):e.milliseconds>=1e3*60*60*24&&(d=_t(d,-1)));dIj(t.eventSources)],propSetHandlers:{dateProfile:vL,eventStore:NL}})];class SL{constructor(e,n){this.runTaskOption=e,this.drainedOption=n,this.queue=[],this.delayedRunner=new am(this.drain.bind(this))}request(e,n){this.queue.push(e),this.delayedRunner.request(n)}pause(e){this.delayedRunner.pause(e)}resume(e,n){this.delayedRunner.resume(e,n)}drain(){let{queue:e}=this;for(;e.length;){let n=[],r;for(;r=e.shift();)this.runTask(r),n.push(r);this.drained(n)}}runTask(e){this.runTaskOption&&this.runTaskOption(e)}drained(e){this.drainedOption&&this.drainedOption(e)}}function jL(t,e,n){let r;return/^(year|month)$/.test(t.currentRangeUnit)?r=t.currentRange:r=t.activeRange,n.formatRange(r.start,r.end,ht(e.titleFormat||AL(t)),{isEndExclusive:t.isRangeAllDay,defaultSeparator:e.titleRangeSeparator})}function AL(t){let{currentRangeUnit:e}=t;if(e==="year")return{year:"numeric"};if(e==="month")return{year:"numeric",month:"long"};let n=Kd(t.currentRange.start,t.currentRange.end);return n!==null&&n>1?{year:"numeric",month:"short",day:"numeric"}:{year:"numeric",month:"long",day:"numeric"}}class V1{constructor(){this.resetListeners=new Set}handleInput(e,n){const r=this.dateEnv;if(e!==r&&(typeof n=="function"?this.nowFn=n:r||(this.nowAnchorDate=e.toDate(n?e.createMarker(n):e.createNowMarker()),this.nowAnchorQueried=Date.now()),this.dateEnv=e,r))for(const i of this.resetListeners.values())i()}getDateMarker(){return this.nowAnchorDate?this.dateEnv.timestampToMarker(this.nowAnchorDate.valueOf()+(Date.now()-this.nowAnchorQueried)):this.dateEnv.createMarker(this.nowFn())}addResetListener(e){this.resetListeners.add(e)}removeResetListener(e){this.resetListeners.delete(e)}}class wL{constructor(e){this.computeCurrentViewData=we(this._computeCurrentViewData),this.organizeRawLocales=we(D6),this.buildLocale=we(_j),this.buildPluginHooks=k6(),this.buildDateEnv=we(CL),this.buildTheme=we(DL),this.parseToolbars=we(sL),this.buildViewSpecs=we(P6),this.buildDateProfileGenerator=Rd(OL),this.buildViewApi=we(RL),this.buildViewUiProps=Rd(_L),this.buildEventUiBySource=we(TL,ta),this.buildEventUiBases=we(kL),this.parseContextBusinessHours=Rd(ML),this.buildTitle=we(jL),this.nowManager=new V1,this.emitter=new Ru,this.actionRunner=new SL(this._handleAction.bind(this),this.updateData.bind(this)),this.currentCalendarOptionsInput={},this.currentCalendarOptionsRefined={},this.currentViewOptionsInput={},this.currentViewOptionsRefined={},this.currentCalendarOptionsRefiners={},this.optionsForRefining=[],this.optionsForHandling=[],this.getCurrentData=()=>this.data,this.dispatch=m=>{this.actionRunner.request(m)},this.props=e,this.actionRunner.pause(),this.nowManager=new V1;let n={},r=this.computeOptionsData(e.optionOverrides,n,e.calendarApi),i=r.calendarOptions.initialView||r.pluginHooks.initialView,c=this.computeCurrentViewData(i,r,e.optionOverrides,n);e.calendarApi.currentDataManager=this,this.emitter.setThisContext(e.calendarApi),this.emitter.setOptions(c.options);let d={nowManager:this.nowManager,dateEnv:r.dateEnv,options:r.calendarOptions,pluginHooks:r.pluginHooks,calendarApi:e.calendarApi,dispatch:this.dispatch,emitter:this.emitter,getCurrentData:this.getCurrentData},f=V6(r.calendarOptions,r.dateEnv,this.nowManager),h=c.dateProfileGenerator.build(f);Pa(h.activeRange,f)||(f=h.currentRange.start);for(let m of r.pluginHooks.contextInit)m(d);let p=$6(r.calendarOptions,h,d),b={dynamicOptionOverrides:n,currentViewType:i,currentDate:f,dateProfile:h,businessHours:this.parseContextBusinessHours(d),eventSources:p,eventUiBases:{},eventStore:Cn(),renderableEventStore:Cn(),dateSelection:null,eventSelection:"",eventDrag:null,eventResize:null,selectionConfig:this.buildViewUiProps(d).selectionConfig},y=Object.assign(Object.assign({},d),b);for(let m of r.pluginHooks.reducers)Object.assign(b,m(null,null,y));Lp(b,d)&&this.emitter.trigger("loading",!0),this.state=b,this.updateData(),this.actionRunner.resume()}resetOptions(e,n){let{props:r}=this;n===void 0?r.optionOverrides=e:(r.optionOverrides=Object.assign(Object.assign({},r.optionOverrides||{}),e),this.optionsForRefining.push(...n)),(n===void 0||n.length)&&this.actionRunner.request({type:"NOTHING"})}_handleAction(e){let{props:n,state:r,emitter:i}=this,c=F6(r.dynamicOptionOverrides,e),d=this.computeOptionsData(n.optionOverrides,c,n.calendarApi),f=H6(r.currentViewType,e),h=this.computeCurrentViewData(f,d,n.optionOverrides,c);n.calendarApi.currentDataManager=this,i.setThisContext(n.calendarApi),i.setOptions(h.options);let p={nowManager:this.nowManager,dateEnv:d.dateEnv,options:d.calendarOptions,pluginHooks:d.pluginHooks,calendarApi:n.calendarApi,dispatch:this.dispatch,emitter:i,getCurrentData:this.getCurrentData},{currentDate:b,dateProfile:y}=r;this.data&&this.data.dateProfileGenerator!==h.dateProfileGenerator&&(y=h.dateProfileGenerator.build(b)),b=G6(b,e),y=q6(y,e,b,h.dateProfileGenerator),(e.type==="PREV"||e.type==="NEXT"||!Pa(y.currentRange,b))&&(b=y.currentRange.start);let m=Y6(r.eventSources,e,y,p),v=$4(r.eventStore,e,m,y,p),S=Ij(m)&&!h.options.progressiveEventRendering&&r.renderableEventStore||v,{eventUiSingleBase:j,selectionConfig:R}=this.buildViewUiProps(p),C=this.buildEventUiBySource(m),O=this.buildEventUiBases(S.defs,j,C),A={dynamicOptionOverrides:c,currentViewType:f,currentDate:b,dateProfile:y,eventSources:m,eventStore:v,renderableEventStore:S,selectionConfig:R,eventUiBases:O,businessHours:this.parseContextBusinessHours(p),dateSelection:eL(r.dateSelection,e),eventSelection:tL(r.eventSelection,e),eventDrag:nL(r.eventDrag,e),eventResize:aL(r.eventResize,e)},k=Object.assign(Object.assign({},p),A);for(let F of d.pluginHooks.reducers)Object.assign(A,F(r,e,k));let _=Lp(r,p),B=Lp(A,p);!_&&B?i.trigger("loading",!0):_&&!B&&i.trigger("loading",!1),this.state=A,n.onAction&&n.onAction(e)}updateData(){let{props:e,state:n}=this,r=this.data,i=this.computeOptionsData(e.optionOverrides,n.dynamicOptionOverrides,e.calendarApi),c=this.computeCurrentViewData(n.currentViewType,i,e.optionOverrides,n.dynamicOptionOverrides),d=this.data=Object.assign(Object.assign(Object.assign({nowManager:this.nowManager,viewTitle:this.buildTitle(n.dateProfile,c.options,i.dateEnv),calendarApi:e.calendarApi,dispatch:this.dispatch,emitter:this.emitter,getCurrentData:this.getCurrentData},i),c),n),f=i.pluginHooks.optionChangeHandlers,h=r&&r.calendarOptions,p=i.calendarOptions;if(h&&h!==p){h.timeZone!==p.timeZone&&(n.eventSources=d.eventSources=Q6(d.eventSources,n.dateProfile,d),n.eventStore=d.eventStore=k1(d.eventStore,r.dateEnv,d.dateEnv),n.renderableEventStore=d.renderableEventStore=k1(d.renderableEventStore,r.dateEnv,d.dateEnv));for(let b in f)(this.optionsForHandling.indexOf(b)!==-1||h[b]!==p[b])&&f[b](p[b],d)}this.optionsForHandling=[],e.onData&&e.onData(d)}computeOptionsData(e,n,r){if(!this.optionsForRefining.length&&e===this.stableOptionOverrides&&n===this.stableDynamicOptionOverrides)return this.stableCalendarOptionsData;let{refinedOptions:i,pluginHooks:c,localeDefaults:d,availableLocaleData:f,extra:h}=this.processRawCalendarOptions(e,n);F1(h);let p=this.buildDateEnv(i.timeZone,i.locale,i.weekNumberCalculation,i.firstDay,i.weekText,c,f,i.defaultRangeSeparator),b=this.buildViewSpecs(c.views,this.stableOptionOverrides,this.stableDynamicOptionOverrides,d),y=this.buildTheme(i,c),m=this.parseToolbars(i,this.stableOptionOverrides,y,b,r);return this.stableCalendarOptionsData={calendarOptions:i,pluginHooks:c,dateEnv:p,viewSpecs:b,theme:y,toolbarConfig:m,localeDefaults:d,availableRawLocales:f.map}}processRawCalendarOptions(e,n){let{locales:r,locale:i}=Cp([co,e,n]),c=this.organizeRawLocales(r),d=c.map,f=this.buildLocale(i||c.defaultCode,d).options,h=this.buildPluginHooks(e.plugins||[],EL),p=this.currentCalendarOptionsRefiners=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},w1),C1),D1),h.listenerRefiners),h.optionRefiners),b={},y=Cp([co,f,e,n]),m={},v=this.currentCalendarOptionsInput,N=this.currentCalendarOptionsRefined,S=!1;for(let j in y)this.optionsForRefining.indexOf(j)===-1&&(y[j]===v[j]||or[j]&&j in v&&or[j](v[j],y[j]))?m[j]=N[j]:p[j]?(m[j]=p[j](y[j]),S=!0):b[j]=v[j];return S&&(this.currentCalendarOptionsInput=y,this.currentCalendarOptionsRefined=m,this.stableOptionOverrides=e,this.stableDynamicOptionOverrides=n),this.optionsForHandling.push(...this.optionsForRefining),this.optionsForRefining=[],{rawOptions:this.currentCalendarOptionsInput,refinedOptions:this.currentCalendarOptionsRefined,pluginHooks:h,availableLocaleData:c,localeDefaults:f,extra:b}}_computeCurrentViewData(e,n,r,i){let c=n.viewSpecs[e];if(!c)throw new Error(`viewType "${e}" is not available. Please make sure you've loaded all neccessary plugins`);let{refinedOptions:d,extra:f}=this.processRawViewOptions(c,n.pluginHooks,n.localeDefaults,r,i);F1(f),this.nowManager.handleInput(n.dateEnv,d.now);let h=this.buildDateProfileGenerator({dateProfileGeneratorClass:c.optionDefaults.dateProfileGeneratorClass,nowManager:this.nowManager,duration:c.duration,durationUnit:c.durationUnit,usesMinMaxTime:c.optionDefaults.usesMinMaxTime,dateEnv:n.dateEnv,calendarApi:this.props.calendarApi,slotMinTime:d.slotMinTime,slotMaxTime:d.slotMaxTime,showNonCurrentDates:d.showNonCurrentDates,dayCount:d.dayCount,dateAlignment:d.dateAlignment,dateIncrement:d.dateIncrement,hiddenDays:d.hiddenDays,weekends:d.weekends,validRangeInput:d.validRange,visibleRangeInput:d.visibleRange,fixedWeekCount:d.fixedWeekCount}),p=this.buildViewApi(e,this.getCurrentData,n.dateEnv);return{viewSpec:c,options:d,dateProfileGenerator:h,viewApi:p}}processRawViewOptions(e,n,r,i,c){let d=Cp([co,e.optionDefaults,r,i,e.optionOverrides,c]),f=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},w1),C1),D1),d4),n.listenerRefiners),n.optionRefiners),h={},p=this.currentViewOptionsInput,b=this.currentViewOptionsRefined,y=!1,m={};for(let v in d)d[v]===p[v]||or[v]&&or[v](d[v],p[v])?h[v]=b[v]:(d[v]===this.currentCalendarOptionsInput[v]||or[v]&&or[v](d[v],this.currentCalendarOptionsInput[v])?v in this.currentCalendarOptionsRefined&&(h[v]=this.currentCalendarOptionsRefined[v]):f[v]?h[v]=f[v](d[v]):m[v]=d[v],y=!0);return y&&(this.currentViewOptionsInput=d,this.currentViewOptionsRefined=h),{rawOptions:this.currentViewOptionsInput,refinedOptions:this.currentViewOptionsRefined,extra:m}}}function CL(t,e,n,r,i,c,d,f){let h=_j(e||d.defaultCode,d.map);return new N4({calendarSystem:"gregory",timeZone:t,namedTimeZoneImpl:c.namedTimeZonedImpl,locale:h,weekNumberCalculation:n,firstDay:r,weekText:i,cmdFormatter:c.cmdFormatter,defaultSeparator:f})}function DL(t,e){let n=e.themeClasses[t.themeSystem]||Hs;return new n(t)}function OL(t){let e=t.dateProfileGeneratorClass||qS;return new e(t)}function RL(t,e,n){return new lL(t,e,n)}function TL(t){return Ha(t,e=>e.ui)}function kL(t,e,n){let r={"":e};for(let i in t){let c=t[i];c.sourceId&&n[c.sourceId]&&(r[i]=n[c.sourceId])}return r}function _L(t){let{options:e}=t;return{eventUiSingleBase:ru({display:e.eventDisplay,editable:e.editable,startEditable:e.eventStartEditable,durationEditable:e.eventDurationEditable,constraint:e.eventConstraint,overlap:typeof e.eventOverlap=="boolean"?e.eventOverlap:void 0,allow:e.eventAllow,backgroundColor:e.eventBackgroundColor,borderColor:e.eventBorderColor,textColor:e.eventTextColor,color:e.eventColor},t),selectionConfig:ru({constraint:e.selectConstraint,overlap:typeof e.selectOverlap=="boolean"?e.selectOverlap:void 0,allow:e.selectAllow},t)}}function Lp(t,e){for(let n of e.pluginHooks.isLoadingFuncs)if(n(t))return!0;return!1}function ML(t){return t3(t.options.businessHours,t)}function F1(t,e){for(let n in t)console.warn(`Unknown option '${n}'`)}class IL extends Ke{render(){let e=this.props.widgetGroups.map(n=>this.renderWidgetGroup(n));return I("div",{className:"fc-toolbar-chunk"},...e)}renderWidgetGroup(e){let{props:n}=this,{theme:r}=this.context,i=[],c=!0;for(let d of e){let{buttonName:f,buttonClick:h,buttonText:p,buttonIcon:b,buttonHint:y}=d;if(f==="title")c=!1,i.push(I("h2",{className:"fc-toolbar-title",id:n.titleId},n.title));else{let m=f===n.activeButton,v=!n.isTodayEnabled&&f==="today"||!n.isPrevEnabled&&f==="prev"||!n.isNextEnabled&&f==="next",N=[`fc-${f}-button`,r.getClass("button")];m&&N.push(r.getClass("buttonActive")),i.push(I("button",{type:"button",title:typeof y=="function"?y(n.navUnit):y,disabled:v,"aria-pressed":m,className:N.join(" "),onClick:h},p||(b?I("span",{className:b,role:"img"}):"")))}}if(i.length>1){let d=c&&r.getClass("buttonGroup")||"";return I("div",{className:d},...i)}return i[0]}}class q1 extends Ke{render(){let{model:e,extraClassName:n}=this.props,r=!1,i,c,d=e.sectionWidgets,f=d.center;return d.left?(r=!0,i=d.left):i=d.start,d.right?(r=!0,c=d.right):c=d.end,I("div",{className:[n||"","fc-toolbar",r?"fc-toolbar-ltr":""].join(" ")},this.renderSection("start",i||[]),this.renderSection("center",f||[]),this.renderSection("end",c||[]))}renderSection(e,n){let{props:r}=this;return I(IL,{key:e,widgetGroups:n,title:r.title,navUnit:r.navUnit,activeButton:r.activeButton,isTodayEnabled:r.isTodayEnabled,isPrevEnabled:r.isPrevEnabled,isNextEnabled:r.isNextEnabled,titleId:r.titleId})}}class LL extends Ke{constructor(){super(...arguments),this.state={availableWidth:null},this.handleEl=e=>{this.el=e,fa(this.props.elRef,e),this.updateAvailableWidth()},this.handleResize=()=>{this.updateAvailableWidth()}}render(){let{props:e,state:n}=this,{aspectRatio:r}=e,i=["fc-view-harness",r||e.liquid||e.height?"fc-view-harness-active":"fc-view-harness-passive"],c="",d="";return r?n.availableWidth!==null?c=n.availableWidth/r:d=`${1/r*100}%`:c=e.height||"",I("div",{"aria-labelledby":e.labeledById,ref:this.handleEl,className:i.join(" "),style:{height:c,paddingBottom:d}},e.children)}componentDidMount(){this.context.addResizeHandler(this.handleResize)}componentWillUnmount(){this.context.removeResizeHandler(this.handleResize)}updateAvailableWidth(){this.el&&this.props.aspectRatio&&this.setState({availableWidth:this.el.offsetWidth})}}class zL extends Jl{constructor(e){super(e),this.handleSegClick=(n,r)=>{let{component:i}=this,{context:c}=i,d=Hl(r);if(d&&i.isValidSegDownEl(n.target)){let f=qt(n.target,".fc-event-forced-url"),h=f?f.querySelector("a[href]").href:"";c.emitter.trigger("eventClick",{el:r,event:new ut(i.context,d.eventRange.def,d.eventRange.instance),jsEvent:n,view:c.viewApi}),h&&!n.defaultPrevented&&(window.location.href=h)}},this.destroy=kS(e.el,"click",".fc-event",this.handleSegClick)}}class PL extends Jl{constructor(e){super(e),this.handleEventElRemove=n=>{n===this.currentSegEl&&this.handleSegLeave(null,this.currentSegEl)},this.handleSegEnter=(n,r)=>{Hl(r)&&(this.currentSegEl=r,this.triggerEvent("eventMouseEnter",n,r))},this.handleSegLeave=(n,r)=>{this.currentSegEl&&(this.currentSegEl=null,this.triggerEvent("eventMouseLeave",n,r))},this.removeHoverListeners=mI(e.el,".fc-event",this.handleSegEnter,this.handleSegLeave)}destroy(){this.removeHoverListeners()}triggerEvent(e,n,r){let{component:i}=this,{context:c}=i,d=Hl(r);(!n||i.isValidSegDownEl(n.target))&&c.emitter.trigger(e,{el:r,event:new ut(c,d.eventRange.def,d.eventRange.instance),jsEvent:n,view:c.viewApi})}}class UL extends _r{constructor(){super(...arguments),this.buildViewContext=we(j4),this.buildViewPropTransformers=we(HL),this.buildToolbarProps=we(BL),this.headerRef=Zt(),this.footerRef=Zt(),this.interactionsStore={},this.state={viewLabelId:wu()},this.registerInteractiveComponent=(e,n)=>{let r=S3(e,n),d=[zL,PL].concat(this.props.pluginHooks.componentInteractions).map(f=>new f(r));this.interactionsStore[e.uid]=d,sg[e.uid]=r},this.unregisterInteractiveComponent=e=>{let n=this.interactionsStore[e.uid];if(n){for(let r of n)r.destroy();delete this.interactionsStore[e.uid]}delete sg[e.uid]},this.resizeRunner=new am(()=>{this.props.emitter.trigger("_resize",!0),this.props.emitter.trigger("windowResize",{view:this.props.viewApi})}),this.handleWindowResize=e=>{let{options:n}=this.props;n.handleWindowResize&&e.target===window&&this.resizeRunner.request(n.windowResizeDelay)}}render(){let{props:e}=this,{toolbarConfig:n,options:r}=e,i=!1,c="",d;e.isHeightAuto||e.forPrint?c="":r.height!=null?i=!0:r.contentHeight!=null?c=r.contentHeight:d=Math.max(r.aspectRatio,.5);let f=this.buildViewContext(e.viewSpec,e.viewApi,e.options,e.dateProfileGenerator,e.dateEnv,e.nowManager,e.theme,e.pluginHooks,e.dispatch,e.getCurrentData,e.emitter,e.calendarApi,this.registerInteractiveComponent,this.unregisterInteractiveComponent),h=n.header&&n.header.hasTitle?this.state.viewLabelId:void 0;return I(Fa.Provider,{value:f},I(ei,{unit:"day"},p=>{let b=this.buildToolbarProps(e.viewSpec,e.dateProfile,e.dateProfileGenerator,e.currentDate,p,e.viewTitle);return I(lt,null,n.header&&I(q1,Object.assign({ref:this.headerRef,extraClassName:"fc-header-toolbar",model:n.header,titleId:h},b)),I(LL,{liquid:i,height:c,aspectRatio:d,labeledById:h},this.renderView(e),this.buildAppendContent()),n.footer&&I(q1,Object.assign({ref:this.footerRef,extraClassName:"fc-footer-toolbar",model:n.footer,titleId:""},b)))}))}componentDidMount(){let{props:e}=this;this.calendarInteractions=e.pluginHooks.calendarInteractions.map(r=>new r(e)),window.addEventListener("resize",this.handleWindowResize);let{propSetHandlers:n}=e.pluginHooks;for(let r in n)n[r](e[r],e)}componentDidUpdate(e){let{props:n}=this,{propSetHandlers:r}=n.pluginHooks;for(let i in r)n[i]!==e[i]&&r[i](n[i],n)}componentWillUnmount(){window.removeEventListener("resize",this.handleWindowResize),this.resizeRunner.clear();for(let e of this.calendarInteractions)e.destroy();this.props.emitter.trigger("_unmount")}buildAppendContent(){let{props:e}=this,n=e.pluginHooks.viewContainerAppends.map(r=>r(e));return I(lt,{},...n)}renderView(e){let{pluginHooks:n}=e,{viewSpec:r}=e,i={dateProfile:e.dateProfile,businessHours:e.businessHours,eventStore:e.renderableEventStore,eventUiBases:e.eventUiBases,dateSelection:e.dateSelection,eventSelection:e.eventSelection,eventDrag:e.eventDrag,eventResize:e.eventResize,isHeightAuto:e.isHeightAuto,forPrint:e.forPrint},c=this.buildViewPropTransformers(n.viewPropsTransformers);for(let f of c)Object.assign(i,f.transform(i,e));let d=r.component;return I(d,Object.assign({},i))}}function BL(t,e,n,r,i,c){let d=n.build(i,void 0,!1),f=n.buildPrev(e,r,!1),h=n.buildNext(e,r,!1);return{title:c,activeButton:t.type,navUnit:t.singleUnit,isTodayEnabled:d.isValid&&!Pa(e.currentRange,i),isPrevEnabled:f.isValid,isNextEnabled:h.isValid}}function HL(t){return t.map(e=>new e)}class GL extends A3{constructor(e,n={}){super(),this.isRendering=!1,this.isRendered=!1,this.currentClassNames=[],this.customContentRenderId=0,this.handleAction=r=>{switch(r.type){case"SET_EVENT_DRAG":case"SET_EVENT_RESIZE":this.renderRunner.tryDrain()}},this.handleData=r=>{this.currentData=r,this.renderRunner.request(r.calendarOptions.rerenderDelay)},this.handleRenderRequest=()=>{if(this.isRendering){this.isRendered=!0;let{currentData:r}=this;nu(()=>{No(I(E3,{options:r.calendarOptions,theme:r.theme,emitter:r.emitter},(i,c,d,f)=>(this.setClassNames(i),this.setHeight(c),I(HS.Provider,{value:this.customContentRenderId},I(UL,Object.assign({isHeightAuto:d,forPrint:f},r))))),this.el)})}else this.isRendered&&(this.isRendered=!1,No(null,this.el),this.setClassNames([]),this.setHeight(""))},iI(e),this.el=e,this.renderRunner=new am(this.handleRenderRequest),new wL({optionOverrides:n,calendarApi:this,onAction:this.handleAction,onData:this.handleData})}render(){let e=this.isRendering;e?this.customContentRenderId+=1:this.isRendering=!0,this.renderRunner.request(),e&&this.updateSize()}destroy(){this.isRendering&&(this.isRendering=!1,this.renderRunner.request())}updateSize(){nu(()=>{super.updateSize()})}batchRendering(e){this.renderRunner.pause("batchRendering"),e(),this.renderRunner.resume("batchRendering")}pauseRendering(){this.renderRunner.pause("pauseRendering")}resumeRendering(){this.renderRunner.resume("pauseRendering",!0)}resetOptions(e,n){this.currentDataManager.resetOptions(e,n)}setClassNames(e){if(!Ps(e,this.currentClassNames)){let{classList:n}=this.el;for(let r of this.currentClassNames)n.remove(r);for(let r of e)n.add(r);this.currentClassNames=e}}setHeight(e){RS(this.el,"height",e)}}const VL=parseInt(String(Ve.version).split(".")[0]),FL=VL<18;class Bj extends w.Component{constructor(){super(...arguments),this.elRef=w.createRef(),this.isUpdating=!1,this.isUnmounting=!1,this.state={customRenderingMap:new Map},this.requestResize=()=>{this.isUnmounting||(this.cancelResize(),this.resizeId=requestAnimationFrame(()=>{this.doResize()}))}}render(){const e=[];for(const n of this.state.customRenderingMap.values())e.push(Ve.createElement(qL,{key:n.id,customRendering:n}));return Ve.createElement("div",{ref:this.elRef},e)}componentDidMount(){this.isUnmounting=!1;const e=new w6;this.handleCustomRendering=e.handle.bind(e),this.calendar=new GL(this.elRef.current,Object.assign(Object.assign({},this.props),{handleCustomRendering:this.handleCustomRendering})),this.calendar.render(),this.calendar.on("_beforeprint",()=>{wr.flushSync(()=>{})});let n;e.subscribe(r=>{const i=Date.now(),c=!n;(FL||c||this.isUpdating||this.isUnmounting||i-n<100?Hj:wr.flushSync)(()=>{this.setState({customRenderingMap:r},()=>{n=i,c?this.doResize():this.requestResize()})})})}componentDidUpdate(){this.isUpdating=!0,this.calendar.resetOptions(Object.assign(Object.assign({},this.props),{handleCustomRendering:this.handleCustomRendering})),this.isUpdating=!1}componentWillUnmount(){this.isUnmounting=!0,this.cancelResize(),this.calendar.destroy()}doResize(){this.calendar.updateSize()}cancelResize(){this.resizeId!==void 0&&(cancelAnimationFrame(this.resizeId),this.resizeId=void 0)}getApi(){return this.calendar}}Bj.act=Hj;class qL extends w.PureComponent{render(){const{customRendering:e}=this.props,{generatorMeta:n}=e,r=typeof n=="function"?n(e.renderProps):n;return wr.createPortal(r,e.containerEl)}}function Hj(t){t()}class $L extends pa{constructor(){super(...arguments),this.headerElRef=Zt()}renderSimpleLayout(e,n){let{props:r,context:i}=this,c=[],d=ou(i.options);return e&&c.push({type:"header",key:"header",isSticky:d,chunk:{elRef:this.headerElRef,tableClassName:"fc-col-header",rowContent:e}}),c.push({type:"body",key:"body",liquid:!0,chunk:{content:n}}),I(au,{elClasses:["fc-daygrid"],viewSpec:i.viewSpec},I(Cm,{liquid:!r.isHeightAuto&&!r.forPrint,collapsibleWidth:r.forPrint,cols:[],sections:c}))}renderHScrollLayout(e,n,r,i){let c=this.context.pluginHooks.scrollGridImpl;if(!c)throw new Error("No ScrollGrid implementation");let{props:d,context:f}=this,h=!d.forPrint&&ou(f.options),p=!d.forPrint&&Aj(f.options),b=[];return e&&b.push({type:"header",key:"header",isSticky:h,chunks:[{key:"main",elRef:this.headerElRef,tableClassName:"fc-col-header",rowContent:e}]}),b.push({type:"body",key:"body",liquid:!0,chunks:[{key:"main",content:n}]}),p&&b.push({type:"footer",key:"footer",isSticky:!0,chunks:[{key:"main",content:ig}]}),I(au,{elClasses:["fc-daygrid"],viewSpec:f.viewSpec},I(c,{liquid:!d.isHeightAuto&&!d.forPrint,forPrint:d.forPrint,collapsibleWidth:d.forPrint,colGroups:[{cols:[{span:r,minWidth:i}]}],sections:b}))}}function kd(t,e){let n=[];for(let r=0;r{let i=(e.eventDrag?e.eventDrag.affectedInstances:null)||(e.eventResize?e.eventResize.affectedInstances:null)||{};return I(lt,null,n.map(c=>{let d=c.eventRange.instance.instanceId;return I("div",{className:"fc-daygrid-event-harness",key:d,style:{visibility:i[d]?"hidden":""}},Vj(c)?I(qj,Object.assign({seg:c,isDragging:!1,isSelected:d===e.eventSelection,defaultDisplayEventEnd:!1},Ms(c,e.todayRange))):I(Fj,Object.assign({seg:c,isDragging:!1,isResizing:!1,isDateSelecting:!1,isSelected:d===e.eventSelection,defaultDisplayEventEnd:!1},Ms(c,e.todayRange))))}))}})}}function WL(t){let e=[],n=[];for(let r of t)e.push(r.seg),r.isVisible||n.push(r.seg);return{allSegs:e,invisibleSegs:n}}const XL=ht({week:"narrow"});class ZL extends pa{constructor(){super(...arguments),this.rootElRef=Zt(),this.state={dayNumberId:wu()},this.handleRootEl=e=>{fa(this.rootElRef,e),fa(this.props.elRef,e)}}render(){let{context:e,props:n,state:r,rootElRef:i}=this,{options:c,dateEnv:d}=e,{date:f,dateProfile:h}=n;const p=n.showDayNumber&&JL(f,h.currentRange,d);return I(Tm,{elTag:"td",elRef:this.handleRootEl,elClasses:["fc-daygrid-day",...n.extraClassNames||[]],elAttrs:Object.assign(Object.assign(Object.assign({},n.extraDataAttrs),n.showDayNumber?{"aria-labelledby":r.dayNumberId}:{}),{role:"gridcell"}),defaultGenerator:KL,date:f,dateProfile:h,todayRange:n.todayRange,showDayNumber:n.showDayNumber,isMonthStart:p,extraRenderProps:n.extraRenderProps},(b,y)=>I("div",{ref:n.innerElRef,className:"fc-daygrid-day-frame fc-scrollgrid-sync-inner",style:{minHeight:n.minHeight}},n.showWeekNumber&&I(Dj,{elTag:"a",elClasses:["fc-daygrid-week-number"],elAttrs:iu(e,f,"week"),date:f,defaultFormat:XL}),!y.isDisabled&&(n.showDayNumber||km(c)||n.forceDayTop)?I("div",{className:"fc-daygrid-day-top"},I(b,{elTag:"a",elClasses:["fc-daygrid-day-number",p&&"fc-daygrid-month-start"],elAttrs:Object.assign(Object.assign({},iu(e,f)),{id:r.dayNumberId})})):n.showDayNumber?I("div",{className:"fc-daygrid-day-top",style:{visibility:"hidden"}},I("a",{className:"fc-daygrid-day-number"}," ")):void 0,I("div",{className:"fc-daygrid-day-events",ref:n.fgContentElRef},n.fgContent,I("div",{className:"fc-daygrid-day-bottom",style:{marginTop:n.moreMarginTop}},I(QL,{allDayDate:f,singlePlacements:n.singlePlacements,moreCnt:n.moreCnt,alignmentElRef:i,alignGridTop:!n.showDayNumber,extraDateSpan:n.extraDateSpan,dateProfile:n.dateProfile,eventSelection:n.eventSelection,eventDrag:n.eventDrag,eventResize:n.eventResize,todayRange:n.todayRange}))),I("div",{className:"fc-daygrid-day-bg"},n.bgContent)))}}function KL(t){return t.dayNumberText||I(lt,null," ")}function JL(t,e,n){const{start:r,end:i}=e,c=Us(i,-1),d=n.getYear(r),f=n.getMonth(r),h=n.getYear(c),p=n.getMonth(c);return!(d===h&&f===p)&&(t.valueOf()===r.valueOf()||n.getDay(t)===1&&t.valueOf(){let C=t[R.index].eventRange.instance.instanceId+":"+R.span.start+":"+(R.span.end-1);return i[C]||1});f.allowReslicing=!0,f.strictOrder=r,e===!0||n===!0?(f.maxCoord=c,f.hiddenConsumes=!0):typeof e=="number"?f.maxStackCnt=e:typeof n=="number"&&(f.maxStackCnt=n,f.hiddenConsumes=!0);let h=[],p=[];for(let R=0;R1,j=v.span.start===f;y+=v.levelCoord-b,b=v.levelCoord+v.thickness,S?(y+=v.thickness,j&&m.push({seg:Sl(N,v.span.start,v.span.end,n),isVisible:!0,isAbsolute:!0,absoluteTop:v.levelCoord,marginTop:0})):j&&(m.push({seg:Sl(N,v.span.start,v.span.end,n),isVisible:!0,isAbsolute:!1,absoluteTop:v.levelCoord,marginTop:y}),y=0)}i.push(p),c.push(m),d.push(y)}return{singleColPlacements:i,multiColPlacements:c,leftoverMargins:d}}function nz(t,e){let n=[];for(let r=0;r!this.forceHidden[Ar(c)];for(let c=0;c{e&&this.updateSizing(!0)}}render(){let{props:e,state:n,context:r}=this,{options:i}=r,c=e.cells.length,d=Nd(e.businessHourSegs,c),f=Nd(e.bgEventSegs,c),h=Nd(this.getHighlightSegs(),c),p=Nd(this.getMirrorSegs(),c),{singleColPlacements:b,multiColPlacements:y,moreCnts:m,moreMarginTops:v}=ez(aj(e.fgEventSegs,i.eventOrder),e.dayMaxEvents,e.dayMaxEventRows,i.eventOrderStrict,n.segHeights,n.maxContentHeight,e.cells),N=e.eventDrag&&e.eventDrag.affectedInstances||e.eventResize&&e.eventResize.affectedInstances||{};return I("tr",{ref:this.rootElRef,role:"row"},e.renderIntro&&e.renderIntro(),e.cells.map((S,j)=>{let R=this.renderFgSegs(j,e.forPrint?b[j]:y[j],e.todayRange,N),C=this.renderFgSegs(j,sz(p[j],y),e.todayRange,{},!!e.eventDrag,!!e.eventResize,!1);return I(ZL,{key:S.key,elRef:this.cellElRefs.createRef(S.key),innerElRef:this.frameElRefs.createRef(S.key),dateProfile:e.dateProfile,date:S.date,showDayNumber:e.showDayNumbers,showWeekNumber:e.showWeekNumbers&&j===0,forceDayTop:e.showWeekNumbers,todayRange:e.todayRange,eventSelection:e.eventSelection,eventDrag:e.eventDrag,eventResize:e.eventResize,extraRenderProps:S.extraRenderProps,extraDataAttrs:S.extraDataAttrs,extraClassNames:S.extraClassNames,extraDateSpan:S.extraDateSpan,moreCnt:m[j],moreMarginTop:v[j],singlePlacements:b[j],fgContentElRef:this.fgElRefs.createRef(S.key),fgContent:I(lt,null,I(lt,null,R),I(lt,null,C)),bgContent:I(lt,null,this.renderFillSegs(h[j],"highlight"),this.renderFillSegs(d[j],"non-business"),this.renderFillSegs(f[j],"bg-event")),minHeight:e.cellMinHeight})}))}componentDidMount(){this.updateSizing(!0),this.context.addResizeHandler(this.handleResize)}componentDidUpdate(e,n){let r=this.props;this.updateSizing(!ta(e,r))}componentWillUnmount(){this.context.removeResizeHandler(this.handleResize)}getHighlightSegs(){let{props:e}=this;return e.eventDrag&&e.eventDrag.segs.length?e.eventDrag.segs:e.eventResize&&e.eventResize.segs.length?e.eventResize.segs:e.dateSelectionSegs}getMirrorSegs(){let{props:e}=this;return e.eventResize&&e.eventResize.segs.length?e.eventResize.segs:[]}renderFgSegs(e,n,r,i,c,d,f){let{context:h}=this,{eventSelection:p}=this.props,{framePositions:b}=this.state,y=this.props.cells.length===1,m=c||d||f,v=[];if(b)for(let N of n){let{seg:S}=N,{instanceId:j}=S.eventRange.instance,R=N.isVisible&&!i[j],C=N.isAbsolute,O="",A="";C&&(h.isRtl?(A=0,O=b.lefts[S.lastCol]-b.lefts[S.firstCol]):(O=0,A=b.rights[S.firstCol]-b.rights[S.lastCol])),v.push(I("div",{className:"fc-daygrid-event-harness"+(C?" fc-daygrid-event-harness-abs":""),key:$j(S),ref:m?null:this.segHarnessRefs.createRef(Yj(S)),style:{visibility:R?"":"hidden",marginTop:C?"":N.marginTop,top:C?N.absoluteTop:"",left:O,right:A}},Vj(S)?I(qj,Object.assign({seg:S,isDragging:c,isSelected:j===p,defaultDisplayEventEnd:y},Ms(S,r))):I(Fj,Object.assign({seg:S,isDragging:c,isResizing:d,isDateSelecting:f,isSelected:j===p,defaultDisplayEventEnd:y},Ms(S,r)))))}return v}renderFillSegs(e,n){let{isRtl:r}=this.context,{todayRange:i}=this.props,{framePositions:c}=this.state,d=[];if(c)for(let f of e){let h=r?{right:0,left:c.lefts[f.lastCol]-c.lefts[f.firstCol]}:{left:0,right:c.rights[f.firstCol]-c.rights[f.lastCol]};d.push(I("div",{key:rj(f.eventRange),className:"fc-daygrid-bg-harness",style:h},n==="bg-event"?I(wj,Object.assign({seg:f},Ms(f,i))):Cj(n)))}return I(lt,{},...d)}updateSizing(e){let{props:n,state:r,frameElRefs:i}=this;if(!n.forPrint&&n.clientWidth!==null){if(e){let h=n.cells.map(p=>i.currentMap[p.key]);if(h.length){let p=this.rootElRef.current,b=new Gl(p,h,!0,!1);(!r.framePositions||!r.framePositions.similarTo(b))&&this.setState({framePositions:new Gl(p,h,!0,!1)})}}const c=this.state.segHeights,d=this.querySegHeights(),f=n.dayMaxEvents===!0||n.dayMaxEventRows===!0;this.safeSetState({segHeights:Object.assign(Object.assign({},c),d),maxContentHeight:f?this.computeMaxContentHeight():null})}}querySegHeights(){let e=this.segHarnessRefs.currentMap,n={};for(let r in e){let i=Math.round(e[r].getBoundingClientRect().height);n[r]=Math.max(n[r]||0,i)}return n}computeMaxContentHeight(){let e=this.props.cells[0].key,n=this.cellElRefs.currentMap[e],r=this.fgElRefs.currentMap[e];return n.getBoundingClientRect().bottom-r.getBoundingClientRect().top}getCellEls(){let e=this.cellElRefs.currentMap;return this.props.cells.map(n=>e[n.key])}}Qj.addStateEquality({segHeights:ta});function sz(t,e){if(!t.length)return[];let n=rz(e);return t.map(r=>({seg:r,isVisible:!0,isAbsolute:!0,absoluteTop:n[r.eventRange.instance.instanceId],marginTop:0}))}function rz(t){let e={};for(let n of t)for(let r of n)e[r.seg.eventRange.instance.instanceId]=r.absoluteTop;return e}class lz extends pa{constructor(){super(...arguments),this.splitBusinessHourSegs=we(kd),this.splitBgEventSegs=we(iz),this.splitFgEventSegs=we(kd),this.splitDateSelectionSegs=we(kd),this.splitEventDrag=we($1),this.splitEventResize=we($1),this.rowRefs=new La}render(){let{props:e,context:n}=this,r=e.cells.length,i=this.splitBusinessHourSegs(e.businessHourSegs,r),c=this.splitBgEventSegs(e.bgEventSegs,r),d=this.splitFgEventSegs(e.fgEventSegs,r),f=this.splitDateSelectionSegs(e.dateSelectionSegs,r),h=this.splitEventDrag(e.eventDrag,r),p=this.splitEventResize(e.eventResize,r),b=r>=7&&e.clientWidth?e.clientWidth/n.options.aspectRatio/6:null;return I(ei,{unit:"day"},(y,m)=>I(lt,null,e.cells.map((v,N)=>I(Qj,{ref:this.rowRefs.createRef(N),key:v.length?v[0].date.toISOString():N,showDayNumbers:r>1,showWeekNumbers:e.showWeekNumbers,todayRange:m,dateProfile:e.dateProfile,cells:v,renderIntro:e.renderRowIntro,businessHourSegs:i[N],eventSelection:e.eventSelection,bgEventSegs:c[N],fgEventSegs:d[N],dateSelectionSegs:f[N],eventDrag:h[N],eventResize:p[N],dayMaxEvents:e.dayMaxEvents,dayMaxEventRows:e.dayMaxEventRows,clientWidth:e.clientWidth,clientHeight:e.clientHeight,cellMinHeight:b,forPrint:e.forPrint}))))}componentDidMount(){this.registerInteractiveComponent()}componentDidUpdate(){this.registerInteractiveComponent()}registerInteractiveComponent(){if(!this.rootEl){const e=this.rowRefs.currentMap[0].getCellEls()[0],n=e?e.closest(".fc-daygrid-body"):null;n&&(this.rootEl=n,this.context.registerInteractiveComponent(this,{el:n,isHitComboAllowed:this.props.isHitComboAllowed}))}}componentWillUnmount(){this.rootEl&&(this.context.unregisterInteractiveComponent(this),this.rootEl=null)}prepareHits(){this.rowPositions=new Gl(this.rootEl,this.rowRefs.collect().map(e=>e.getCellEls()[0]),!1,!0),this.colPositions=new Gl(this.rootEl,this.rowRefs.currentMap[0].getCellEls(),!0,!1)}queryHit(e,n){let{colPositions:r,rowPositions:i}=this,c=r.leftToIndex(e),d=i.topToIndex(n);if(d!=null&&c!=null){let f=this.props.cells[d][c];return{dateProfile:this.props.dateProfile,dateSpan:Object.assign({range:this.getCellRange(d,c),allDay:!0},f.extraDateSpan),dayEl:this.getCellEl(d,c),rect:{left:r.lefts[c],right:r.rights[c],top:i.tops[d],bottom:i.bottoms[d]},layer:0}}return null}getCellEl(e,n){return this.rowRefs.currentMap[e].getCellEls()[n]}getCellRange(e,n){let r=this.props.cells[e][n].date,i=_t(r,1);return{start:r,end:i}}}function iz(t,e){return kd(t.filter(oz),e)}function oz(t){return t.eventRange.def.allDay}class cz extends pa{constructor(){super(...arguments),this.elRef=Zt(),this.needsScrollReset=!1}render(){let{props:e}=this,{dayMaxEventRows:n,dayMaxEvents:r,expandRows:i}=e,c=r===!0||n===!0;c&&!i&&(c=!1,n=null,r=null);let d=["fc-daygrid-body",c?"fc-daygrid-body-balanced":"fc-daygrid-body-unbalanced",i?"":"fc-daygrid-body-natural"];return I("div",{ref:this.elRef,className:d.join(" "),style:{width:e.clientWidth,minWidth:e.tableMinWidth}},I("table",{role:"presentation",className:"fc-scrollgrid-sync-table",style:{width:e.clientWidth,minWidth:e.tableMinWidth,height:i?e.clientHeight:""}},e.colGroupNode,I("tbody",{role:"presentation"},I(lz,{dateProfile:e.dateProfile,cells:e.cells,renderRowIntro:e.renderRowIntro,showWeekNumbers:e.showWeekNumbers,clientWidth:e.clientWidth,clientHeight:e.clientHeight,businessHourSegs:e.businessHourSegs,bgEventSegs:e.bgEventSegs,fgEventSegs:e.fgEventSegs,dateSelectionSegs:e.dateSelectionSegs,eventSelection:e.eventSelection,eventDrag:e.eventDrag,eventResize:e.eventResize,dayMaxEvents:r,dayMaxEventRows:n,forPrint:e.forPrint,isHitComboAllowed:e.isHitComboAllowed}))))}componentDidMount(){this.requestScrollReset()}componentDidUpdate(e){e.dateProfile!==this.props.dateProfile?this.requestScrollReset():this.flushScrollReset()}requestScrollReset(){this.needsScrollReset=!0,this.flushScrollReset()}flushScrollReset(){if(this.needsScrollReset&&this.props.clientWidth){const e=dz(this.elRef.current,this.props.dateProfile);if(e){const n=e.closest(".fc-daygrid-body"),r=n.closest(".fc-scroller"),i=e.getBoundingClientRect().top-n.getBoundingClientRect().top;r.scrollTop=i?i+1:0}this.needsScrollReset=!1}}}function dz(t,e){let n;return e.currentRangeUnit.match(/year|month/)&&(n=t.querySelector(`[data-date="${YI(e.currentDate)}-01"]`)),n||(n=t.querySelector(`[data-date="${om(e.currentDate)}"]`)),n}class uz extends vj{constructor(){super(...arguments),this.forceDayIfListItem=!0}sliceRange(e,n){return n.sliceRange(e)}}class Wj extends pa{constructor(){super(...arguments),this.slicer=new uz,this.tableRef=Zt()}render(){let{props:e,context:n}=this;return I(cz,Object.assign({ref:this.tableRef},this.slicer.sliceProps(e,e.dateProfile,e.nextDayThreshold,n,e.dayTableModel),{dateProfile:e.dateProfile,cells:e.dayTableModel.cells,colGroupNode:e.colGroupNode,tableMinWidth:e.tableMinWidth,renderRowIntro:e.renderRowIntro,dayMaxEvents:e.dayMaxEvents,dayMaxEventRows:e.dayMaxEventRows,showWeekNumbers:e.showWeekNumbers,expandRows:e.expandRows,headerAlignElRef:e.headerAlignElRef,clientWidth:e.clientWidth,clientHeight:e.clientHeight,forPrint:e.forPrint}))}}class fz extends $L{constructor(){super(...arguments),this.buildDayTableModel=we(hz),this.headerRef=Zt(),this.tableRef=Zt()}render(){let{options:e,dateProfileGenerator:n}=this.context,{props:r}=this,i=this.buildDayTableModel(r.dateProfile,n),c=e.dayHeaders&&I(xj,{ref:this.headerRef,dateProfile:r.dateProfile,dates:i.headerDates,datesRepDistinctDays:i.rowCnt===1}),d=f=>I(Wj,{ref:this.tableRef,dateProfile:r.dateProfile,dayTableModel:i,businessHours:r.businessHours,dateSelection:r.dateSelection,eventStore:r.eventStore,eventUiBases:r.eventUiBases,eventSelection:r.eventSelection,eventDrag:r.eventDrag,eventResize:r.eventResize,nextDayThreshold:e.nextDayThreshold,colGroupNode:f.tableColGroupNode,tableMinWidth:f.tableMinWidth,dayMaxEvents:e.dayMaxEvents,dayMaxEventRows:e.dayMaxEventRows,showWeekNumbers:e.weekNumbers,expandRows:!r.isHeightAuto,headerAlignElRef:this.headerElRef,clientWidth:f.clientWidth,clientHeight:f.clientHeight,forPrint:r.forPrint});return e.dayMinWidth?this.renderHScrollLayout(c,d,i.colCnt,e.dayMinWidth):this.renderSimpleLayout(c,d)}}function hz(t,e){let n=new bj(t.renderRange,e);return new yj(n,/year|month|week/.test(t.currentRangeUnit))}class pz extends qS{buildRenderRange(e,n,r){let i=super.buildRenderRange(e,n,r),{props:c}=this;return gz({currentRange:i,snapToWeek:/^(year|month)$/.test(n),fixedWeekCount:c.fixedWeekCount,dateEnv:c.dateEnv})}}function gz(t){let{dateEnv:e,currentRange:n}=t,{start:r,end:i}=n,c;if(t.snapToWeek&&(r=e.startOfWeek(r),c=e.startOfWeek(i),c.valueOf()!==i.valueOf()&&(i=N1(c,1))),t.fixedWeekCount){let d=e.startOfWeek(e.startOfMonth(_t(n.end,-1))),f=Math.ceil(LI(d,i));i=N1(i,6-f)}return{start:r,end:i}}var mz=':root{--fc-daygrid-event-dot-width:8px}.fc-daygrid-day-events:after,.fc-daygrid-day-events:before,.fc-daygrid-day-frame:after,.fc-daygrid-day-frame:before,.fc-daygrid-event-harness:after,.fc-daygrid-event-harness:before{clear:both;content:"";display:table}.fc .fc-daygrid-body{position:relative;z-index:1}.fc .fc-daygrid-day.fc-day-today{background-color:var(--fc-today-bg-color)}.fc .fc-daygrid-day-frame{min-height:100%;position:relative}.fc .fc-daygrid-day-top{display:flex;flex-direction:row-reverse}.fc .fc-day-other .fc-daygrid-day-top{opacity:.3}.fc .fc-daygrid-day-number{padding:4px;position:relative;z-index:4}.fc .fc-daygrid-month-start{font-size:1.1em;font-weight:700}.fc .fc-daygrid-day-events{margin-top:1px}.fc .fc-daygrid-body-balanced .fc-daygrid-day-events{left:0;position:absolute;right:0}.fc .fc-daygrid-body-unbalanced .fc-daygrid-day-events{min-height:2em;position:relative}.fc .fc-daygrid-body-natural .fc-daygrid-day-events{margin-bottom:1em}.fc .fc-daygrid-event-harness{position:relative}.fc .fc-daygrid-event-harness-abs{left:0;position:absolute;right:0;top:0}.fc .fc-daygrid-bg-harness{bottom:0;position:absolute;top:0}.fc .fc-daygrid-day-bg .fc-non-business{z-index:1}.fc .fc-daygrid-day-bg .fc-bg-event{z-index:2}.fc .fc-daygrid-day-bg .fc-highlight{z-index:3}.fc .fc-daygrid-event{margin-top:1px;z-index:6}.fc .fc-daygrid-event.fc-event-mirror{z-index:7}.fc .fc-daygrid-day-bottom{font-size:.85em;margin:0 2px}.fc .fc-daygrid-day-bottom:after,.fc .fc-daygrid-day-bottom:before{clear:both;content:"";display:table}.fc .fc-daygrid-more-link{border-radius:3px;cursor:pointer;line-height:1;margin-top:1px;max-width:100%;overflow:hidden;padding:2px;position:relative;white-space:nowrap;z-index:4}.fc .fc-daygrid-more-link:hover{background-color:rgba(0,0,0,.1)}.fc .fc-daygrid-week-number{background-color:var(--fc-neutral-bg-color);color:var(--fc-neutral-text-color);min-width:1.5em;padding:2px;position:absolute;text-align:center;top:0;z-index:5}.fc .fc-more-popover .fc-popover-body{min-width:220px;padding:10px}.fc-direction-ltr .fc-daygrid-event.fc-event-start,.fc-direction-rtl .fc-daygrid-event.fc-event-end{margin-left:2px}.fc-direction-ltr .fc-daygrid-event.fc-event-end,.fc-direction-rtl .fc-daygrid-event.fc-event-start{margin-right:2px}.fc-direction-ltr .fc-daygrid-more-link{float:left}.fc-direction-ltr .fc-daygrid-week-number{border-radius:0 0 3px 0;left:0}.fc-direction-rtl .fc-daygrid-more-link{float:right}.fc-direction-rtl .fc-daygrid-week-number{border-radius:0 0 0 3px;right:0}.fc-liquid-hack .fc-daygrid-day-frame{position:static}.fc-daygrid-event{border-radius:3px;font-size:var(--fc-small-font-size);position:relative;white-space:nowrap}.fc-daygrid-block-event .fc-event-time{font-weight:700}.fc-daygrid-block-event .fc-event-time,.fc-daygrid-block-event .fc-event-title{padding:1px}.fc-daygrid-dot-event{align-items:center;display:flex;padding:2px 0}.fc-daygrid-dot-event .fc-event-title{flex-grow:1;flex-shrink:1;font-weight:700;min-width:0;overflow:hidden}.fc-daygrid-dot-event.fc-event-mirror,.fc-daygrid-dot-event:hover{background:rgba(0,0,0,.1)}.fc-daygrid-dot-event.fc-event-selected:before{bottom:-10px;top:-10px}.fc-daygrid-event-dot{border:calc(var(--fc-daygrid-event-dot-width)/2) solid var(--fc-event-border-color);border-radius:calc(var(--fc-daygrid-event-dot-width)/2);box-sizing:content-box;height:0;margin:0 4px;width:0}.fc-direction-ltr .fc-daygrid-event .fc-event-time{margin-right:3px}.fc-direction-rtl .fc-daygrid-event .fc-event-time{margin-left:3px}';nm(mz);var xz=qa({name:"@fullcalendar/daygrid",initialView:"dayGridMonth",views:{dayGrid:{component:fz,dateProfileGeneratorClass:pz},dayGridDay:{type:"dayGrid",duration:{days:1}},dayGridWeek:{type:"dayGrid",duration:{weeks:1}},dayGridMonth:{type:"dayGrid",duration:{months:1},fixedWeekCount:!0},dayGridYear:{type:"dayGrid",duration:{years:1}}}});class bz extends R3{getKeyInfo(){return{allDay:{},timed:{}}}getKeysForDateSpan(e){return e.allDay?["allDay"]:["timed"]}getKeysForEventDef(e){return e.allDay?l3(e)?["timed","allDay"]:["allDay"]:["timed"]}}const yz=ht({hour:"numeric",minute:"2-digit",omitZeroMinute:!0,meridiem:"short"});function Xj(t){let e=["fc-timegrid-slot","fc-timegrid-slot-label",t.isLabeled?"fc-scrollgrid-shrink":"fc-timegrid-slot-minor"];return I(Fa.Consumer,null,n=>{if(!t.isLabeled)return I("td",{className:e.join(" "),"data-time":t.isoTimeStr});let{dateEnv:r,options:i,viewApi:c}=n,d=i.slotLabelFormat==null?yz:Array.isArray(i.slotLabelFormat)?ht(i.slotLabelFormat[0]):ht(i.slotLabelFormat),f={level:0,time:t.time,date:r.toDate(t.date),view:c,text:r.format(t.date,d)};return I(On,{elTag:"td",elClasses:e,elAttrs:{"data-time":t.isoTimeStr},renderProps:f,generatorName:"slotLabelContent",customGenerator:i.slotLabelContent,defaultGenerator:vz,classNameGenerator:i.slotLabelClassNames,didMount:i.slotLabelDidMount,willUnmount:i.slotLabelWillUnmount},h=>I("div",{className:"fc-timegrid-slot-label-frame fc-scrollgrid-shrink-frame"},I(h,{elTag:"div",elClasses:["fc-timegrid-slot-label-cushion","fc-scrollgrid-shrink-cushion"]})))})}function vz(t){return t.text}class Nz extends Ke{render(){return this.props.slatMetas.map(e=>I("tr",{key:e.key},I(Xj,Object.assign({},e))))}}const Ez=ht({week:"short"}),Sz=5;class jz extends pa{constructor(){super(...arguments),this.allDaySplitter=new bz,this.headerElRef=Zt(),this.rootElRef=Zt(),this.scrollerElRef=Zt(),this.state={slatCoords:null},this.handleScrollTopRequest=e=>{let n=this.scrollerElRef.current;n&&(n.scrollTop=e)},this.renderHeadAxis=(e,n="")=>{let{options:r}=this.context,{dateProfile:i}=this.props,c=i.renderRange,f=kr(c.start,c.end)===1?iu(this.context,c.start,"week"):{};return r.weekNumbers&&e==="day"?I(Dj,{elTag:"th",elClasses:["fc-timegrid-axis","fc-scrollgrid-shrink"],elAttrs:{"aria-hidden":!0},date:c.start,defaultFormat:Ez},h=>I("div",{className:["fc-timegrid-axis-frame","fc-scrollgrid-shrink-frame","fc-timegrid-axis-frame-liquid"].join(" "),style:{height:n}},I(h,{elTag:"a",elClasses:["fc-timegrid-axis-cushion","fc-scrollgrid-shrink-cushion","fc-scrollgrid-sync-inner"],elAttrs:f}))):I("th",{"aria-hidden":!0,className:"fc-timegrid-axis"},I("div",{className:"fc-timegrid-axis-frame",style:{height:n}}))},this.renderTableRowAxis=e=>{let{options:n,viewApi:r}=this.context,i={text:n.allDayText,view:r};return I(On,{elTag:"td",elClasses:["fc-timegrid-axis","fc-scrollgrid-shrink"],elAttrs:{"aria-hidden":!0},renderProps:i,generatorName:"allDayContent",customGenerator:n.allDayContent,defaultGenerator:Az,classNameGenerator:n.allDayClassNames,didMount:n.allDayDidMount,willUnmount:n.allDayWillUnmount},c=>I("div",{className:["fc-timegrid-axis-frame","fc-scrollgrid-shrink-frame",e==null?" fc-timegrid-axis-frame-liquid":""].join(" "),style:{height:e}},I(c,{elTag:"span",elClasses:["fc-timegrid-axis-cushion","fc-scrollgrid-shrink-cushion","fc-scrollgrid-sync-inner"]})))},this.handleSlatCoords=e=>{this.setState({slatCoords:e})}}renderSimpleLayout(e,n,r){let{context:i,props:c}=this,d=[],f=ou(i.options);return e&&d.push({type:"header",key:"header",isSticky:f,chunk:{elRef:this.headerElRef,tableClassName:"fc-col-header",rowContent:e}}),n&&(d.push({type:"body",key:"all-day",chunk:{content:n}}),d.push({type:"body",key:"all-day-divider",outerContent:I("tr",{role:"presentation",className:"fc-scrollgrid-section"},I("td",{className:"fc-timegrid-divider "+i.theme.getClass("tableCellShaded")}))})),d.push({type:"body",key:"body",liquid:!0,expandRows:!!i.options.expandRows,chunk:{scrollerElRef:this.scrollerElRef,content:r}}),I(au,{elRef:this.rootElRef,elClasses:["fc-timegrid"],viewSpec:i.viewSpec},I(Cm,{liquid:!c.isHeightAuto&&!c.forPrint,collapsibleWidth:c.forPrint,cols:[{width:"shrink"}],sections:d}))}renderHScrollLayout(e,n,r,i,c,d,f){let h=this.context.pluginHooks.scrollGridImpl;if(!h)throw new Error("No ScrollGrid implementation");let{context:p,props:b}=this,y=!b.forPrint&&ou(p.options),m=!b.forPrint&&Aj(p.options),v=[];e&&v.push({type:"header",key:"header",isSticky:y,syncRowHeights:!0,chunks:[{key:"axis",rowContent:S=>I("tr",{role:"presentation"},this.renderHeadAxis("day",S.rowSyncHeights[0]))},{key:"cols",elRef:this.headerElRef,tableClassName:"fc-col-header",rowContent:e}]}),n&&(v.push({type:"body",key:"all-day",syncRowHeights:!0,chunks:[{key:"axis",rowContent:S=>I("tr",{role:"presentation"},this.renderTableRowAxis(S.rowSyncHeights[0]))},{key:"cols",content:n}]}),v.push({key:"all-day-divider",type:"body",outerContent:I("tr",{role:"presentation",className:"fc-scrollgrid-section"},I("td",{colSpan:2,className:"fc-timegrid-divider "+p.theme.getClass("tableCellShaded")}))}));let N=p.options.nowIndicator;return v.push({type:"body",key:"body",liquid:!0,expandRows:!!p.options.expandRows,chunks:[{key:"axis",content:S=>I("div",{className:"fc-timegrid-axis-chunk"},I("table",{"aria-hidden":!0,style:{height:S.expandRows?S.clientHeight:""}},S.tableColGroupNode,I("tbody",null,I(Nz,{slatMetas:d}))),I("div",{className:"fc-timegrid-now-indicator-container"},I(ei,{unit:N?"minute":"day"},j=>{let R=N&&f&&f.safeComputeTop(j);return typeof R=="number"?I(Rm,{elClasses:["fc-timegrid-now-indicator-arrow"],elStyle:{top:R},isAxis:!0,date:j}):null})))},{key:"cols",scrollerElRef:this.scrollerElRef,content:r}]}),m&&v.push({key:"footer",type:"footer",isSticky:!0,chunks:[{key:"axis",content:ig},{key:"cols",content:ig}]}),I(au,{elRef:this.rootElRef,elClasses:["fc-timegrid"],viewSpec:p.viewSpec},I(h,{liquid:!b.isHeightAuto&&!b.forPrint,forPrint:b.forPrint,collapsibleWidth:!1,colGroups:[{width:"shrink",cols:[{width:"shrink"}]},{cols:[{span:i,minWidth:c}]}],sections:v}))}getAllDayMaxEventProps(){let{dayMaxEvents:e,dayMaxEventRows:n}=this.context.options;return(e===!0||n===!0)&&(e=void 0,n=Sz),{dayMaxEvents:e,dayMaxEventRows:n}}}function Az(t){return t.text}class wz{constructor(e,n,r){this.positions=e,this.dateProfile=n,this.slotDuration=r}safeComputeTop(e){let{dateProfile:n}=this;if(Pa(n.currentRange,e)){let r=it(e),i=e.valueOf()-r.valueOf();if(i>=ea(n.slotMinTime)&&i{let f={time:c.time,date:n.dateEnv.toDate(c.date),view:n.viewApi};return I("tr",{key:c.key,ref:i.createRef(c.key)},e.axis&&I(Xj,Object.assign({},c)),I(On,{elTag:"td",elClasses:["fc-timegrid-slot","fc-timegrid-slot-lane",!c.isLabeled&&"fc-timegrid-slot-minor"],elAttrs:{"data-time":c.isoTimeStr},renderProps:f,generatorName:"slotLaneContent",customGenerator:r.slotLaneContent,classNameGenerator:r.slotLaneClassNames,didMount:r.slotLaneDidMount,willUnmount:r.slotLaneWillUnmount}))}))}}class Dz extends Ke{constructor(){super(...arguments),this.rootElRef=Zt(),this.slatElRefs=new La}render(){let{props:e,context:n}=this;return I("div",{ref:this.rootElRef,className:"fc-timegrid-slots"},I("table",{"aria-hidden":!0,className:n.theme.getClass("table"),style:{minWidth:e.tableMinWidth,width:e.clientWidth,height:e.minHeight}},e.tableColGroupNode,I(Cz,{slatElRefs:this.slatElRefs,axis:e.axis,slatMetas:e.slatMetas})))}componentDidMount(){this.updateSizing()}componentDidUpdate(){this.updateSizing()}componentWillUnmount(){this.props.onCoords&&this.props.onCoords(null)}updateSizing(){let{context:e,props:n}=this;n.onCoords&&n.clientWidth!==null&&this.rootElRef.current.offsetHeight&&n.onCoords(new wz(new Gl(this.rootElRef.current,Oz(this.slatElRefs.currentMap,n.slatMetas),!1,!0),this.props.dateProfile,e.options.slotDuration))}}function Oz(t,e){return e.map(n=>t[n.key])}function Ki(t,e){let n=[],r;for(r=0;rKj(e.hiddenSegs,e),defaultGenerator:Tz,forceTimed:!0},n=>I(n,{elTag:"div",elClasses:["fc-timegrid-more-link-inner","fc-sticky"]}))}}function Tz(t){return t.shortText}function kz(t,e,n){let r=new pj;e!=null&&(r.strictOrder=e),n!=null&&(r.maxStackCnt=n);let i=r.addSegs(t),c=V3(i),d=_z(r);return d=zz(d,1),{segRects:Pz(d),hiddenGroups:c}}function _z(t){const{entriesByLevel:e}=t,n=Mm((r,i)=>r+":"+i,(r,i)=>{let c=Lz(t,r,i),d=Q1(c,n),f=e[r][i];return[Object.assign(Object.assign({},f),{nextLevelNodes:d[0]}),f.thickness+d[1]]});return Q1(e.length?{level:0,lateralStart:0,lateralEnd:e[0].length}:null,n)[0]}function Q1(t,e){if(!t)return[[],0];let{level:n,lateralStart:r,lateralEnd:i}=t,c=r,d=[];for(;cAr(r),(r,i,c)=>{let{nextLevelNodes:d,thickness:f}=r,h=f+c,p=f/h,b,y=[];if(!d.length)b=e;else for(let v of d)if(b===void 0){let N=n(v,i,h);b=N[0],y.push(N[1])}else{let N=n(v,b,0);y.push(N[1])}let m=(b-i)*p;return[b-m,Object.assign(Object.assign({},r),{thickness:m,nextLevelNodes:y})]});return t.map(r=>n(r,0,0)[1])}function Pz(t){let e=[];const n=Mm((i,c,d)=>Ar(i),(i,c,d)=>{let f=Object.assign(Object.assign({},i),{levelCoord:c,stackDepth:d,stackForward:0});return e.push(f),f.stackForward=r(i.nextLevelNodes,c+i.thickness,d+1)+1});function r(i,c,d){let f=0;for(let h of i)f=Math.max(n(h,c,d),f);return f}return r(t,0,0),e}function Mm(t,e){const n={};return(...r)=>{let i=t(...r);return i in n?n[i]:n[i]=e(...r)}}function W1(t,e,n=null,r=0){let i=[];if(n)for(let c=0;cI("div",{className:"fc-timegrid-col-frame"},I("div",{className:"fc-timegrid-col-bg"},this.renderFillSegs(e.businessHourSegs,"non-business"),this.renderFillSegs(e.bgEventSegs,"bg-event"),this.renderFillSegs(e.dateSelectionSegs,"highlight")),I("div",{className:"fc-timegrid-col-events"},this.renderFgSegs(f,d,!1,!1,!1)),I("div",{className:"fc-timegrid-col-events"},this.renderFgSegs(c,{},!!e.eventDrag,!!e.eventResize,!!i,"mirror")),I("div",{className:"fc-timegrid-now-indicator-container"},this.renderNowIndicator(e.nowIndicatorSegs)),km(r)&&I(h,{elTag:"div",elClasses:["fc-timegrid-col-misc"]})))}renderFgSegs(e,n,r,i,c,d){let{props:f}=this;return f.forPrint?Kj(e,f):this.renderPositionedFgSegs(e,n,r,i,c,d)}renderPositionedFgSegs(e,n,r,i,c,d){let{eventMaxStack:f,eventShortHeight:h,eventOrderStrict:p,eventMinHeight:b}=this.context.options,{date:y,slatCoords:m,eventSelection:v,todayRange:N,nowDate:S}=this.props,j=r||i||c,R=W1(e,y,m,b),{segPlacements:C,hiddenGroups:O}=Uz(e,R,p,f);return I(lt,null,this.renderHiddenGroups(O,e),C.map(A=>{let{seg:k,rect:_}=A,B=k.eventRange.instance.instanceId,F=j||!!(!n[B]&&_),G=zp(_&&_.span),ee=!j&&_?this.computeSegHStyle(_):{left:0,right:0},ne=!!_&&_.stackForward>0,oe=!!_&&_.span.end-_.span.start{let y=zp(b.span),m=Gz(b.entries,n);return I(Rz,{key:LS(Rj(m)),hiddenSegs:m,top:y.top,bottom:y.bottom,extraDateSpan:r,dateProfile:i,todayRange:c,nowDate:d,eventSelection:f,eventDrag:h,eventResize:p})}))}renderFillSegs(e,n){let{props:r,context:i}=this,d=W1(e,r.date,r.slatCoords,i.options.eventMinHeight).map((f,h)=>{let p=e[h];return I("div",{key:rj(p.eventRange),className:"fc-timegrid-bg-harness",style:zp(f)},n==="bg-event"?I(wj,Object.assign({seg:p},Ms(p,r.todayRange,r.nowDate))):Cj(n))});return I(lt,null,d)}renderNowIndicator(e){let{slatCoords:n,date:r}=this.props;return n?e.map((i,c)=>I(Rm,{key:c,elClasses:["fc-timegrid-now-indicator-line"],elStyle:{top:n.computeDateTop(i.start,r)},isAxis:!1,date:r})):null}computeSegHStyle(e){let{isRtl:n,options:r}=this.context,i=r.slotEventOverlap,c=e.levelCoord,d=e.levelCoord+e.thickness,f,h;i&&(d=Math.min(1,c+(d-c)*2)),n?(f=1-d,h=c):(f=c,h=1-d);let p={zIndex:e.stackDepth+1,left:f*100+"%",right:h*100+"%"};return i&&!e.stackForward&&(p[n?"marginLeft":"marginRight"]=20),p}}function Kj(t,{todayRange:e,nowDate:n,eventSelection:r,eventDrag:i,eventResize:c}){let d=(i?i.affectedInstances:null)||(c?c.affectedInstances:null)||{};return I(lt,null,t.map(f=>{let h=f.eventRange.instance.instanceId;return I("div",{key:h,style:{visibility:d[h]?"hidden":""}},I(Zj,Object.assign({seg:f,isDragging:!1,isResizing:!1,isDateSelecting:!1,isSelected:h===r,isShort:!1},Ms(f,e,n))))}))}function zp(t){return t?{top:t.start,bottom:-t.end}:{top:"",bottom:""}}function Gz(t,e){return t.map(n=>e[n.index])}class Vz extends Ke{constructor(){super(...arguments),this.splitFgEventSegs=we(Ki),this.splitBgEventSegs=we(Ki),this.splitBusinessHourSegs=we(Ki),this.splitNowIndicatorSegs=we(Ki),this.splitDateSelectionSegs=we(Ki),this.splitEventDrag=we(Y1),this.splitEventResize=we(Y1),this.rootElRef=Zt(),this.cellElRefs=new La}render(){let{props:e,context:n}=this,r=n.options.nowIndicator&&e.slatCoords&&e.slatCoords.safeComputeTop(e.nowDate),i=e.cells.length,c=this.splitFgEventSegs(e.fgEventSegs,i),d=this.splitBgEventSegs(e.bgEventSegs,i),f=this.splitBusinessHourSegs(e.businessHourSegs,i),h=this.splitNowIndicatorSegs(e.nowIndicatorSegs,i),p=this.splitDateSelectionSegs(e.dateSelectionSegs,i),b=this.splitEventDrag(e.eventDrag,i),y=this.splitEventResize(e.eventResize,i);return I("div",{className:"fc-timegrid-cols",ref:this.rootElRef},I("table",{role:"presentation",style:{minWidth:e.tableMinWidth,width:e.clientWidth}},e.tableColGroupNode,I("tbody",{role:"presentation"},I("tr",{role:"row"},e.axis&&I("td",{"aria-hidden":!0,className:"fc-timegrid-col fc-timegrid-axis"},I("div",{className:"fc-timegrid-col-frame"},I("div",{className:"fc-timegrid-now-indicator-container"},typeof r=="number"&&I(Rm,{elClasses:["fc-timegrid-now-indicator-arrow"],elStyle:{top:r},isAxis:!0,date:e.nowDate})))),e.cells.map((m,v)=>I(Hz,{key:m.key,elRef:this.cellElRefs.createRef(m.key),dateProfile:e.dateProfile,date:m.date,nowDate:e.nowDate,todayRange:e.todayRange,extraRenderProps:m.extraRenderProps,extraDataAttrs:m.extraDataAttrs,extraClassNames:m.extraClassNames,extraDateSpan:m.extraDateSpan,fgEventSegs:c[v],bgEventSegs:d[v],businessHourSegs:f[v],nowIndicatorSegs:h[v],dateSelectionSegs:p[v],eventDrag:b[v],eventResize:y[v],slatCoords:e.slatCoords,eventSelection:e.eventSelection,forPrint:e.forPrint}))))))}componentDidMount(){this.updateCoords()}componentDidUpdate(){this.updateCoords()}updateCoords(){let{props:e}=this;e.onColCoords&&e.clientWidth!==null&&e.onColCoords(new Gl(this.rootElRef.current,Fz(this.cellElRefs.currentMap,e.cells),!0,!1))}}function Fz(t,e){return e.map(n=>t[n.key])}class qz extends pa{constructor(){super(...arguments),this.processSlotOptions=we($z),this.state={slatCoords:null},this.handleRootEl=e=>{e?this.context.registerInteractiveComponent(this,{el:e,isHitComboAllowed:this.props.isHitComboAllowed}):this.context.unregisterInteractiveComponent(this)},this.handleScrollRequest=e=>{let{onScrollTopRequest:n}=this.props,{slatCoords:r}=this.state;if(n&&r){if(e.time){let i=r.computeTimeTop(e.time);i=Math.ceil(i),i&&(i+=1),n(i)}return!0}return!1},this.handleColCoords=e=>{this.colCoords=e},this.handleSlatCoords=e=>{this.setState({slatCoords:e}),this.props.onSlatCoords&&this.props.onSlatCoords(e)}}render(){let{props:e,state:n}=this;return I("div",{className:"fc-timegrid-body",ref:this.handleRootEl,style:{width:e.clientWidth,minWidth:e.tableMinWidth}},I(Dz,{axis:e.axis,dateProfile:e.dateProfile,slatMetas:e.slatMetas,clientWidth:e.clientWidth,minHeight:e.expandRows?e.clientHeight:"",tableMinWidth:e.tableMinWidth,tableColGroupNode:e.axis?e.tableColGroupNode:null,onCoords:this.handleSlatCoords}),I(Vz,{cells:e.cells,axis:e.axis,dateProfile:e.dateProfile,businessHourSegs:e.businessHourSegs,bgEventSegs:e.bgEventSegs,fgEventSegs:e.fgEventSegs,dateSelectionSegs:e.dateSelectionSegs,eventSelection:e.eventSelection,eventDrag:e.eventDrag,eventResize:e.eventResize,todayRange:e.todayRange,nowDate:e.nowDate,nowIndicatorSegs:e.nowIndicatorSegs,clientWidth:e.clientWidth,tableMinWidth:e.tableMinWidth,tableColGroupNode:e.tableColGroupNode,slatCoords:n.slatCoords,onColCoords:this.handleColCoords,forPrint:e.forPrint}))}componentDidMount(){this.scrollResponder=this.context.createScrollResponder(this.handleScrollRequest)}componentDidUpdate(e){this.scrollResponder.update(e.dateProfile!==this.props.dateProfile)}componentWillUnmount(){this.scrollResponder.detach()}queryHit(e,n){let{dateEnv:r,options:i}=this.context,{colCoords:c}=this,{dateProfile:d}=this.props,{slatCoords:f}=this.state,{snapDuration:h,snapsPerSlot:p}=this.processSlotOptions(this.props.slotDuration,i.snapDuration),b=c.leftToIndex(e),y=f.positions.topToIndex(n);if(b!=null&&y!=null){let m=this.props.cells[b],v=f.positions.tops[y],N=f.positions.getHeight(y),S=(n-v)/N,j=Math.floor(S*p),R=y*p+j,C=this.props.cells[b].date,O=Jp(d.slotMinTime,kI(h,R)),A=r.add(C,O),k=r.add(A,h);return{dateProfile:d,dateSpan:Object.assign({range:{start:A,end:k},allDay:!1},m.extraDateSpan),dayEl:c.els[b],rect:{left:c.lefts[b],right:c.rights[b],top:v,bottom:v+N},layer:0}}return null}}function $z(t,e){let n=e||t,r=im(t,n);return r===null&&(n=t,r=1),{snapDuration:n,snapsPerSlot:r}}class Yz extends vj{sliceRange(e,n){let r=[];for(let i=0;iI(qz,Object.assign({ref:this.timeColsRef},this.slicer.sliceProps(e,r,null,n,f),{forPrint:e.forPrint,axis:e.axis,dateProfile:r,slatMetas:e.slatMetas,slotDuration:e.slotDuration,cells:i.cells[0],tableColGroupNode:e.tableColGroupNode,tableMinWidth:e.tableMinWidth,clientWidth:e.clientWidth,clientHeight:e.clientHeight,expandRows:e.expandRows,nowDate:h,nowIndicatorSegs:c&&this.slicer.sliceNowDate(h,r,d,n,f),todayRange:p,onScrollTopRequest:e.onScrollTopRequest,onSlatCoords:e.onSlatCoords})))}}function Wz(t,e,n){let r=[];for(let i of t.headerDates)r.push({start:n.add(i,e.slotMinTime),end:n.add(i,e.slotMaxTime)});return r}const X1=[{hours:1},{minutes:30},{minutes:15},{seconds:30},{seconds:15}];function Xz(t,e,n,r,i){let c=new Date(0),d=t,f=Ge(0),h=n||Zz(r),p=[];for(;ea(d)=0;e-=1)if(n=Ge(X1[e]),r=im(n,t),r!==null&&r>1)return n;return t}class Kz extends jz{constructor(){super(...arguments),this.buildTimeColsModel=we(Jz),this.buildSlatMetas=we(Xz)}render(){let{options:e,dateEnv:n,dateProfileGenerator:r}=this.context,{props:i}=this,{dateProfile:c}=i,d=this.buildTimeColsModel(c,r),f=this.allDaySplitter.splitProps(i),h=this.buildSlatMetas(c.slotMinTime,c.slotMaxTime,e.slotLabelInterval,e.slotDuration,n),{dayMinWidth:p}=e,b=!p,y=p,m=e.dayHeaders&&I(xj,{dates:d.headerDates,dateProfile:c,datesRepDistinctDays:!0,renderIntro:b?this.renderHeadAxis:null}),v=e.allDaySlot!==!1&&(S=>I(Wj,Object.assign({},f.allDay,{dateProfile:c,dayTableModel:d,nextDayThreshold:e.nextDayThreshold,tableMinWidth:S.tableMinWidth,colGroupNode:S.tableColGroupNode,renderRowIntro:b?this.renderTableRowAxis:null,showWeekNumbers:!1,expandRows:!1,headerAlignElRef:this.headerElRef,clientWidth:S.clientWidth,clientHeight:S.clientHeight,forPrint:i.forPrint},this.getAllDayMaxEventProps()))),N=S=>I(Qz,Object.assign({},f.timed,{dayTableModel:d,dateProfile:c,axis:b,slotDuration:e.slotDuration,slatMetas:h,forPrint:i.forPrint,tableColGroupNode:S.tableColGroupNode,tableMinWidth:S.tableMinWidth,clientWidth:S.clientWidth,clientHeight:S.clientHeight,onSlatCoords:this.handleSlatCoords,expandRows:S.expandRows,onScrollTopRequest:this.handleScrollTopRequest}));return y?this.renderHScrollLayout(m,v,N,d.colCnt,p,h,this.state.slatCoords):this.renderSimpleLayout(m,v,N)}}function Jz(t,e){let n=new bj(t.renderRange,e);return new yj(n,!1)}var eP='.fc-v-event{background-color:var(--fc-event-bg-color);border:1px solid var(--fc-event-border-color);display:block}.fc-v-event .fc-event-main{color:var(--fc-event-text-color);height:100%}.fc-v-event .fc-event-main-frame{display:flex;flex-direction:column;height:100%}.fc-v-event .fc-event-time{flex-grow:0;flex-shrink:0;max-height:100%;overflow:hidden}.fc-v-event .fc-event-title-container{flex-grow:1;flex-shrink:1;min-height:0}.fc-v-event .fc-event-title{bottom:0;max-height:100%;overflow:hidden;top:0}.fc-v-event:not(.fc-event-start){border-top-left-radius:0;border-top-right-radius:0;border-top-width:0}.fc-v-event:not(.fc-event-end){border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-width:0}.fc-v-event.fc-event-selected:before{left:-10px;right:-10px}.fc-v-event .fc-event-resizer-start{cursor:n-resize}.fc-v-event .fc-event-resizer-end{cursor:s-resize}.fc-v-event:not(.fc-event-selected) .fc-event-resizer{height:var(--fc-event-resizer-thickness);left:0;right:0}.fc-v-event:not(.fc-event-selected) .fc-event-resizer-start{top:calc(var(--fc-event-resizer-thickness)/-2)}.fc-v-event:not(.fc-event-selected) .fc-event-resizer-end{bottom:calc(var(--fc-event-resizer-thickness)/-2)}.fc-v-event.fc-event-selected .fc-event-resizer{left:50%;margin-left:calc(var(--fc-event-resizer-dot-total-width)/-2)}.fc-v-event.fc-event-selected .fc-event-resizer-start{top:calc(var(--fc-event-resizer-dot-total-width)/-2)}.fc-v-event.fc-event-selected .fc-event-resizer-end{bottom:calc(var(--fc-event-resizer-dot-total-width)/-2)}.fc .fc-timegrid .fc-daygrid-body{z-index:2}.fc .fc-timegrid-divider{padding:0 0 2px}.fc .fc-timegrid-body{min-height:100%;position:relative;z-index:1}.fc .fc-timegrid-axis-chunk{position:relative}.fc .fc-timegrid-axis-chunk>table,.fc .fc-timegrid-slots{position:relative;z-index:1}.fc .fc-timegrid-slot{border-bottom:0;height:1.5em}.fc .fc-timegrid-slot:empty:before{content:"\\00a0"}.fc .fc-timegrid-slot-minor{border-top-style:dotted}.fc .fc-timegrid-slot-label-cushion{display:inline-block;white-space:nowrap}.fc .fc-timegrid-slot-label{vertical-align:middle}.fc .fc-timegrid-axis-cushion,.fc .fc-timegrid-slot-label-cushion{padding:0 4px}.fc .fc-timegrid-axis-frame-liquid{height:100%}.fc .fc-timegrid-axis-frame{align-items:center;display:flex;justify-content:flex-end;overflow:hidden}.fc .fc-timegrid-axis-cushion{flex-shrink:0;max-width:60px}.fc-direction-ltr .fc-timegrid-slot-label-frame{text-align:right}.fc-direction-rtl .fc-timegrid-slot-label-frame{text-align:left}.fc-liquid-hack .fc-timegrid-axis-frame-liquid{bottom:0;height:auto;left:0;position:absolute;right:0;top:0}.fc .fc-timegrid-col.fc-day-today{background-color:var(--fc-today-bg-color)}.fc .fc-timegrid-col-frame{min-height:100%;position:relative}.fc-media-screen.fc-liquid-hack .fc-timegrid-col-frame{bottom:0;height:auto;left:0;position:absolute;right:0;top:0}.fc-media-screen .fc-timegrid-cols{bottom:0;left:0;position:absolute;right:0;top:0}.fc-media-screen .fc-timegrid-cols>table{height:100%}.fc-media-screen .fc-timegrid-col-bg,.fc-media-screen .fc-timegrid-col-events,.fc-media-screen .fc-timegrid-now-indicator-container{left:0;position:absolute;right:0;top:0}.fc .fc-timegrid-col-bg{z-index:2}.fc .fc-timegrid-col-bg .fc-non-business{z-index:1}.fc .fc-timegrid-col-bg .fc-bg-event{z-index:2}.fc .fc-timegrid-col-bg .fc-highlight{z-index:3}.fc .fc-timegrid-bg-harness{left:0;position:absolute;right:0}.fc .fc-timegrid-col-events{z-index:3}.fc .fc-timegrid-now-indicator-container{bottom:0;overflow:hidden}.fc-direction-ltr .fc-timegrid-col-events{margin:0 2.5% 0 2px}.fc-direction-rtl .fc-timegrid-col-events{margin:0 2px 0 2.5%}.fc-timegrid-event-harness{position:absolute}.fc-timegrid-event-harness>.fc-timegrid-event{bottom:0;left:0;position:absolute;right:0;top:0}.fc-timegrid-event-harness-inset .fc-timegrid-event,.fc-timegrid-event.fc-event-mirror,.fc-timegrid-more-link{box-shadow:0 0 0 1px var(--fc-page-bg-color)}.fc-timegrid-event,.fc-timegrid-more-link{border-radius:3px;font-size:var(--fc-small-font-size)}.fc-timegrid-event{margin-bottom:1px}.fc-timegrid-event .fc-event-main{padding:1px 1px 0}.fc-timegrid-event .fc-event-time{font-size:var(--fc-small-font-size);margin-bottom:1px;white-space:nowrap}.fc-timegrid-event-short .fc-event-main-frame{flex-direction:row;overflow:hidden}.fc-timegrid-event-short .fc-event-time:after{content:"\\00a0-\\00a0"}.fc-timegrid-event-short .fc-event-title{font-size:var(--fc-small-font-size)}.fc-timegrid-more-link{background:var(--fc-more-link-bg-color);color:var(--fc-more-link-text-color);cursor:pointer;margin-bottom:1px;position:absolute;z-index:9999}.fc-timegrid-more-link-inner{padding:3px 2px;top:0}.fc-direction-ltr .fc-timegrid-more-link{right:0}.fc-direction-rtl .fc-timegrid-more-link{left:0}.fc .fc-timegrid-now-indicator-arrow,.fc .fc-timegrid-now-indicator-line{pointer-events:none}.fc .fc-timegrid-now-indicator-line{border-color:var(--fc-now-indicator-color);border-style:solid;border-width:1px 0 0;left:0;position:absolute;right:0;z-index:4}.fc .fc-timegrid-now-indicator-arrow{border-color:var(--fc-now-indicator-color);border-style:solid;margin-top:-5px;position:absolute;z-index:4}.fc-direction-ltr .fc-timegrid-now-indicator-arrow{border-bottom-color:transparent;border-top-color:transparent;border-width:5px 0 5px 6px;left:0}.fc-direction-rtl .fc-timegrid-now-indicator-arrow{border-bottom-color:transparent;border-top-color:transparent;border-width:5px 6px 5px 0;right:0}';nm(eP);const tP={allDaySlot:Boolean};var nP=qa({name:"@fullcalendar/timegrid",initialView:"timeGridWeek",optionRefiners:tP,views:{timeGrid:{component:Kz,usesMinMaxTime:!0,allDaySlot:!0,slotDuration:"00:30:00",slotEventOverlap:!0},timeGridDay:{type:"timeGrid",duration:{days:1}},timeGridWeek:{type:"timeGrid",duration:{weeks:1}}}});wm.touchMouseIgnoreWait=500;let cg=0,cu=0,dg=!1;class Jj{constructor(e){this.subjectEl=null,this.selector="",this.handleSelector="",this.shouldIgnoreMove=!1,this.shouldWatchScroll=!0,this.isDragging=!1,this.isTouchDragging=!1,this.wasTouchScroll=!1,this.handleMouseDown=n=>{if(!this.shouldIgnoreMouse()&&aP(n)&&this.tryStart(n)){let r=this.createEventFromMouse(n,!0);this.emitter.trigger("pointerdown",r),this.initScrollWatch(r),this.shouldIgnoreMove||document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}},this.handleMouseMove=n=>{let r=this.createEventFromMouse(n);this.recordCoords(r),this.emitter.trigger("pointermove",r)},this.handleMouseUp=n=>{document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),this.emitter.trigger("pointerup",this.createEventFromMouse(n)),this.cleanup()},this.handleTouchStart=n=>{if(this.tryStart(n)){this.isTouchDragging=!0;let r=this.createEventFromTouch(n,!0);this.emitter.trigger("pointerdown",r),this.initScrollWatch(r);let i=n.target;this.shouldIgnoreMove||i.addEventListener("touchmove",this.handleTouchMove),i.addEventListener("touchend",this.handleTouchEnd),i.addEventListener("touchcancel",this.handleTouchEnd),window.addEventListener("scroll",this.handleTouchScroll,!0)}},this.handleTouchMove=n=>{let r=this.createEventFromTouch(n);this.recordCoords(r),this.emitter.trigger("pointermove",r)},this.handleTouchEnd=n=>{if(this.isDragging){let r=n.target;r.removeEventListener("touchmove",this.handleTouchMove),r.removeEventListener("touchend",this.handleTouchEnd),r.removeEventListener("touchcancel",this.handleTouchEnd),window.removeEventListener("scroll",this.handleTouchScroll,!0),this.emitter.trigger("pointerup",this.createEventFromTouch(n)),this.cleanup(),this.isTouchDragging=!1,sP()}},this.handleTouchScroll=()=>{this.wasTouchScroll=!0},this.handleScroll=n=>{if(!this.shouldIgnoreMove){let r=window.scrollX-this.prevScrollX+this.prevPageX,i=window.scrollY-this.prevScrollY+this.prevPageY;this.emitter.trigger("pointermove",{origEvent:n,isTouch:this.isTouchDragging,subjectEl:this.subjectEl,pageX:r,pageY:i,deltaX:r-this.origPageX,deltaY:i-this.origPageY})}},this.containerEl=e,this.emitter=new Ru,e.addEventListener("mousedown",this.handleMouseDown),e.addEventListener("touchstart",this.handleTouchStart,{passive:!0}),rP()}destroy(){this.containerEl.removeEventListener("mousedown",this.handleMouseDown),this.containerEl.removeEventListener("touchstart",this.handleTouchStart,{passive:!0}),lP()}tryStart(e){let n=this.querySubjectEl(e),r=e.target;return n&&(!this.handleSelector||qt(r,this.handleSelector))?(this.subjectEl=n,this.isDragging=!0,this.wasTouchScroll=!1,!0):!1}cleanup(){dg=!1,this.isDragging=!1,this.subjectEl=null,this.destroyScrollWatch()}querySubjectEl(e){return this.selector?qt(e.target,this.selector):this.containerEl}shouldIgnoreMouse(){return cg||this.isTouchDragging}cancelTouchScroll(){this.isDragging&&(dg=!0)}initScrollWatch(e){this.shouldWatchScroll&&(this.recordCoords(e),window.addEventListener("scroll",this.handleScroll,!0))}recordCoords(e){this.shouldWatchScroll&&(this.prevPageX=e.pageX,this.prevPageY=e.pageY,this.prevScrollX=window.scrollX,this.prevScrollY=window.scrollY)}destroyScrollWatch(){this.shouldWatchScroll&&window.removeEventListener("scroll",this.handleScroll,!0)}createEventFromMouse(e,n){let r=0,i=0;return n?(this.origPageX=e.pageX,this.origPageY=e.pageY):(r=e.pageX-this.origPageX,i=e.pageY-this.origPageY),{origEvent:e,isTouch:!1,subjectEl:this.subjectEl,pageX:e.pageX,pageY:e.pageY,deltaX:r,deltaY:i}}createEventFromTouch(e,n){let r=e.touches,i,c,d=0,f=0;return r&&r.length?(i=r[0].pageX,c=r[0].pageY):(i=e.pageX,c=e.pageY),n?(this.origPageX=i,this.origPageY=c):(d=i-this.origPageX,f=c-this.origPageY),{origEvent:e,isTouch:!0,subjectEl:this.subjectEl,pageX:i,pageY:c,deltaX:d,deltaY:f}}}function aP(t){return t.button===0&&!t.ctrlKey}function sP(){cg+=1,setTimeout(()=>{cg-=1},wm.touchMouseIgnoreWait)}function rP(){cu+=1,cu===1&&window.addEventListener("touchmove",eA,{passive:!1})}function lP(){cu-=1,cu||window.removeEventListener("touchmove",eA,{passive:!1})}function eA(t){dg&&t.preventDefault()}class iP{constructor(){this.isVisible=!1,this.sourceEl=null,this.mirrorEl=null,this.sourceElRect=null,this.parentNode=document.body,this.zIndex=9999,this.revertDuration=0}start(e,n,r){this.sourceEl=e,this.sourceElRect=this.sourceEl.getBoundingClientRect(),this.origScreenX=n-window.scrollX,this.origScreenY=r-window.scrollY,this.deltaX=0,this.deltaY=0,this.updateElPosition()}handleMove(e,n){this.deltaX=e-window.scrollX-this.origScreenX,this.deltaY=n-window.scrollY-this.origScreenY,this.updateElPosition()}setIsVisible(e){e?this.isVisible||(this.mirrorEl&&(this.mirrorEl.style.display=""),this.isVisible=e,this.updateElPosition()):this.isVisible&&(this.mirrorEl&&(this.mirrorEl.style.display="none"),this.isVisible=e)}stop(e,n){let r=()=>{this.cleanup(),n()};e&&this.mirrorEl&&this.isVisible&&this.revertDuration&&(this.deltaX||this.deltaY)?this.doRevertAnimation(r,this.revertDuration):setTimeout(r,0)}doRevertAnimation(e,n){let r=this.mirrorEl,i=this.sourceEl.getBoundingClientRect();r.style.transition="top "+n+"ms,left "+n+"ms",io(r,{left:i.left,top:i.top}),xI(r,()=>{r.style.transition="",e()})}cleanup(){this.mirrorEl&&(sm(this.mirrorEl),this.mirrorEl=null),this.sourceEl=null}updateElPosition(){this.sourceEl&&this.isVisible&&io(this.getMirrorEl(),{left:this.sourceElRect.left+this.deltaX,top:this.sourceElRect.top+this.deltaY})}getMirrorEl(){let e=this.sourceElRect,n=this.mirrorEl;return n||(n=this.mirrorEl=this.sourceEl.cloneNode(!0),n.style.userSelect="none",n.style.webkitUserSelect="none",n.style.pointerEvents="none",n.classList.add("fc-event-dragging"),io(n,{position:"fixed",zIndex:this.zIndex,visibility:"",boxSizing:"border-box",width:e.right-e.left,height:e.bottom-e.top,right:"auto",bottom:"auto",margin:0}),this.parentNode.appendChild(n)),n}}class tA extends jm{constructor(e,n){super(),this.handleScroll=()=>{this.scrollTop=this.scrollController.getScrollTop(),this.scrollLeft=this.scrollController.getScrollLeft(),this.handleScrollChange()},this.scrollController=e,this.doesListening=n,this.scrollTop=this.origScrollTop=e.getScrollTop(),this.scrollLeft=this.origScrollLeft=e.getScrollLeft(),this.scrollWidth=e.getScrollWidth(),this.scrollHeight=e.getScrollHeight(),this.clientWidth=e.getClientWidth(),this.clientHeight=e.getClientHeight(),this.clientRect=this.computeClientRect(),this.doesListening&&this.getEventTarget().addEventListener("scroll",this.handleScroll)}destroy(){this.doesListening&&this.getEventTarget().removeEventListener("scroll",this.handleScroll)}getScrollTop(){return this.scrollTop}getScrollLeft(){return this.scrollLeft}setScrollTop(e){this.scrollController.setScrollTop(e),this.doesListening||(this.scrollTop=Math.max(Math.min(e,this.getMaxScrollTop()),0),this.handleScrollChange())}setScrollLeft(e){this.scrollController.setScrollLeft(e),this.doesListening||(this.scrollLeft=Math.max(Math.min(e,this.getMaxScrollLeft()),0),this.handleScrollChange())}getClientWidth(){return this.clientWidth}getClientHeight(){return this.clientHeight}getScrollWidth(){return this.scrollWidth}getScrollHeight(){return this.scrollHeight}handleScrollChange(){}}class nA extends tA{constructor(e,n){super(new H3(e),n)}getEventTarget(){return this.scrollController.el}computeClientRect(){return U3(this.scrollController.el)}}class oP extends tA{constructor(e){super(new G3,e)}getEventTarget(){return window}computeClientRect(){return{left:this.scrollLeft,right:this.scrollLeft+this.clientWidth,top:this.scrollTop,bottom:this.scrollTop+this.clientHeight}}handleScrollChange(){this.clientRect=this.computeClientRect()}}const Z1=typeof performance=="function"?performance.now:Date.now;class cP{constructor(){this.isEnabled=!0,this.scrollQuery=[window,".fc-scroller"],this.edgeThreshold=50,this.maxVelocity=300,this.pointerScreenX=null,this.pointerScreenY=null,this.isAnimating=!1,this.scrollCaches=null,this.everMovedUp=!1,this.everMovedDown=!1,this.everMovedLeft=!1,this.everMovedRight=!1,this.animate=()=>{if(this.isAnimating){let e=this.computeBestEdge(this.pointerScreenX+window.scrollX,this.pointerScreenY+window.scrollY);if(e){let n=Z1();this.handleSide(e,(n-this.msSinceRequest)/1e3),this.requestAnimation(n)}else this.isAnimating=!1}}}start(e,n,r){this.isEnabled&&(this.scrollCaches=this.buildCaches(r),this.pointerScreenX=null,this.pointerScreenY=null,this.everMovedUp=!1,this.everMovedDown=!1,this.everMovedLeft=!1,this.everMovedRight=!1,this.handleMove(e,n))}handleMove(e,n){if(this.isEnabled){let r=e-window.scrollX,i=n-window.scrollY,c=this.pointerScreenY===null?0:i-this.pointerScreenY,d=this.pointerScreenX===null?0:r-this.pointerScreenX;c<0?this.everMovedUp=!0:c>0&&(this.everMovedDown=!0),d<0?this.everMovedLeft=!0:d>0&&(this.everMovedRight=!0),this.pointerScreenX=r,this.pointerScreenY=i,this.isAnimating||(this.isAnimating=!0,this.requestAnimation(Z1()))}}stop(){if(this.isEnabled){this.isAnimating=!1;for(let e of this.scrollCaches)e.destroy();this.scrollCaches=null}}requestAnimation(e){this.msSinceRequest=e,requestAnimationFrame(this.animate)}handleSide(e,n){let{scrollCache:r}=e,{edgeThreshold:i}=this,c=i-e.distance,d=c*c/(i*i)*this.maxVelocity*n,f=1;switch(e.name){case"left":f=-1;case"right":r.setScrollLeft(r.getScrollLeft()+d*f);break;case"top":f=-1;case"bottom":r.setScrollTop(r.getScrollTop()+d*f);break}}computeBestEdge(e,n){let{edgeThreshold:r}=this,i=null,c=this.scrollCaches||[];for(let d of c){let f=d.clientRect,h=e-f.left,p=f.right-e,b=n-f.top,y=f.bottom-n;h>=0&&p>=0&&b>=0&&y>=0&&(b<=r&&this.everMovedUp&&d.canScrollUp()&&(!i||i.distance>b)&&(i={scrollCache:d,name:"top",distance:b}),y<=r&&this.everMovedDown&&d.canScrollDown()&&(!i||i.distance>y)&&(i={scrollCache:d,name:"bottom",distance:y}),h<=r&&this.everMovedLeft&&d.canScrollLeft()&&(!i||i.distance>h)&&(i={scrollCache:d,name:"left",distance:h}),p<=r&&this.everMovedRight&&d.canScrollRight()&&(!i||i.distance>p)&&(i={scrollCache:d,name:"right",distance:p}))}return i}buildCaches(e){return this.queryScrollEls(e).map(n=>n===window?new oP(!1):new nA(n,!1))}queryScrollEls(e){let n=[];for(let r of this.scrollQuery)typeof r=="object"?n.push(r):n.push(...Array.prototype.slice.call(e.getRootNode().querySelectorAll(r)));return n}}class Ho extends q3{constructor(e,n){super(e),this.containerEl=e,this.delay=null,this.minDistance=0,this.touchScrollAllowed=!0,this.mirrorNeedsRevert=!1,this.isInteracting=!1,this.isDragging=!1,this.isDelayEnded=!1,this.isDistanceSurpassed=!1,this.delayTimeoutId=null,this.onPointerDown=i=>{this.isDragging||(this.isInteracting=!0,this.isDelayEnded=!1,this.isDistanceSurpassed=!1,bI(document.body),vI(document.body),i.isTouch||i.origEvent.preventDefault(),this.emitter.trigger("pointerdown",i),this.isInteracting&&!this.pointer.shouldIgnoreMove&&(this.mirror.setIsVisible(!1),this.mirror.start(i.subjectEl,i.pageX,i.pageY),this.startDelay(i),this.minDistance||this.handleDistanceSurpassed(i)))},this.onPointerMove=i=>{if(this.isInteracting){if(this.emitter.trigger("pointermove",i),!this.isDistanceSurpassed){let c=this.minDistance,d,{deltaX:f,deltaY:h}=i;d=f*f+h*h,d>=c*c&&this.handleDistanceSurpassed(i)}this.isDragging&&(i.origEvent.type!=="scroll"&&(this.mirror.handleMove(i.pageX,i.pageY),this.autoScroller.handleMove(i.pageX,i.pageY)),this.emitter.trigger("dragmove",i))}},this.onPointerUp=i=>{this.isInteracting&&(this.isInteracting=!1,yI(document.body),NI(document.body),this.emitter.trigger("pointerup",i),this.isDragging&&(this.autoScroller.stop(),this.tryStopDrag(i)),this.delayTimeoutId&&(clearTimeout(this.delayTimeoutId),this.delayTimeoutId=null))};let r=this.pointer=new Jj(e);r.emitter.on("pointerdown",this.onPointerDown),r.emitter.on("pointermove",this.onPointerMove),r.emitter.on("pointerup",this.onPointerUp),n&&(r.selector=n),this.mirror=new iP,this.autoScroller=new cP}destroy(){this.pointer.destroy(),this.onPointerUp({})}startDelay(e){typeof this.delay=="number"?this.delayTimeoutId=setTimeout(()=>{this.delayTimeoutId=null,this.handleDelayEnd(e)},this.delay):this.handleDelayEnd(e)}handleDelayEnd(e){this.isDelayEnded=!0,this.tryStartDrag(e)}handleDistanceSurpassed(e){this.isDistanceSurpassed=!0,this.tryStartDrag(e)}tryStartDrag(e){this.isDelayEnded&&this.isDistanceSurpassed&&(!this.pointer.wasTouchScroll||this.touchScrollAllowed)&&(this.isDragging=!0,this.mirrorNeedsRevert=!1,this.autoScroller.start(e.pageX,e.pageY,this.containerEl),this.emitter.trigger("dragstart",e),this.touchScrollAllowed===!1&&this.pointer.cancelTouchScroll())}tryStopDrag(e){this.mirror.stop(this.mirrorNeedsRevert,this.stopDrag.bind(this,e))}stopDrag(e){this.isDragging=!1,this.emitter.trigger("dragend",e)}setIgnoreMove(e){this.pointer.shouldIgnoreMove=e}setMirrorIsVisible(e){this.mirror.setIsVisible(e)}setMirrorNeedsRevert(e){this.mirrorNeedsRevert=e}setAutoScrollEnabled(e){this.autoScroller.isEnabled=e}}class dP{constructor(e){this.el=e,this.origRect=Sm(e),this.scrollCaches=hj(e).map(n=>new nA(n,!0))}destroy(){for(let e of this.scrollCaches)e.destroy()}computeLeft(){let e=this.origRect.left;for(let n of this.scrollCaches)e+=n.origScrollLeft-n.getScrollLeft();return e}computeTop(){let e=this.origRect.top;for(let n of this.scrollCaches)e+=n.origScrollTop-n.getScrollTop();return e}isWithinClipping(e,n){let r={left:e,top:n};for(let i of this.scrollCaches)if(!uP(i.getEventTarget())&&!w3(r,i.clientRect))return!1;return!0}}function uP(t){let e=t.tagName;return e==="HTML"||e==="BODY"}class Tu{constructor(e,n){this.useSubjectCenter=!1,this.requireInitial=!0,this.disablePointCheck=!1,this.initialHit=null,this.movingHit=null,this.finalHit=null,this.handlePointerDown=r=>{let{dragging:i}=this;this.initialHit=null,this.movingHit=null,this.finalHit=null,this.prepareHits(),this.processFirstCoord(r),this.initialHit||!this.requireInitial?(i.setIgnoreMove(!1),this.emitter.trigger("pointerdown",r)):i.setIgnoreMove(!0)},this.handleDragStart=r=>{this.emitter.trigger("dragstart",r),this.handleMove(r,!0)},this.handleDragMove=r=>{this.emitter.trigger("dragmove",r),this.handleMove(r)},this.handlePointerUp=r=>{this.releaseHits(),this.emitter.trigger("pointerup",r)},this.handleDragEnd=r=>{this.movingHit&&this.emitter.trigger("hitupdate",null,!0,r),this.finalHit=this.movingHit,this.movingHit=null,this.emitter.trigger("dragend",r)},this.droppableStore=n,e.emitter.on("pointerdown",this.handlePointerDown),e.emitter.on("dragstart",this.handleDragStart),e.emitter.on("dragmove",this.handleDragMove),e.emitter.on("pointerup",this.handlePointerUp),e.emitter.on("dragend",this.handleDragEnd),this.dragging=e,this.emitter=new Ru}processFirstCoord(e){let n={left:e.pageX,top:e.pageY},r=n,i=e.subjectEl,c;i instanceof HTMLElement&&(c=Sm(i),r=C3(r,c));let d=this.initialHit=this.queryHitForOffset(r.left,r.top);if(d){if(this.useSubjectCenter&&c){let f=dj(c,d.rect);f&&(r=D3(f))}this.coordAdjust=O3(r,n)}else this.coordAdjust={left:0,top:0}}handleMove(e,n){let r=this.queryHitForOffset(e.pageX+this.coordAdjust.left,e.pageY+this.coordAdjust.top);(n||!ku(this.movingHit,r))&&(this.movingHit=r,this.emitter.trigger("hitupdate",r,!1,e))}prepareHits(){this.offsetTrackers=Ha(this.droppableStore,e=>(e.component.prepareHits(),new dP(e.el)))}releaseHits(){let{offsetTrackers:e}=this;for(let n in e)e[n].destroy();this.offsetTrackers={}}queryHitForOffset(e,n){let{droppableStore:r,offsetTrackers:i}=this,c=null;for(let d in r){let f=r[d].component,h=i[d];if(h&&h.isWithinClipping(e,n)){let p=h.computeLeft(),b=h.computeTop(),y=e-p,m=n-b,{origRect:v}=h,N=v.right-v.left,S=v.bottom-v.top;if(y>=0&&y=0&&mc.layer)&&(j.componentId=d,j.context=f.context,j.rect.left+=p,j.rect.right+=p,j.rect.top+=b,j.rect.bottom+=b,c=j)}}}return c}}function ku(t,e){return!t&&!e?!0:!!t!=!!e?!1:g3(t.dateSpan,e.dateSpan)}function aA(t,e){let n={};for(let r of e.pluginHooks.datePointTransforms)Object.assign(n,r(t,e));return Object.assign(n,fP(t,e.dateEnv)),n}function fP(t,e){return{date:e.toDate(t.range.start),dateStr:e.formatIso(t.range.start,{omitTime:t.allDay}),allDay:t.allDay}}class hP extends Jl{constructor(e){super(e),this.handlePointerDown=r=>{let{dragging:i}=this,c=r.origEvent.target;i.setIgnoreMove(!this.component.isValidDateDownEl(c))},this.handleDragEnd=r=>{let{component:i}=this,{pointer:c}=this.dragging;if(!c.wasTouchScroll){let{initialHit:d,finalHit:f}=this.hitDragging;if(d&&f&&ku(d,f)){let{context:h}=i,p=Object.assign(Object.assign({},aA(d.dateSpan,h)),{dayEl:d.dayEl,jsEvent:r.origEvent,view:h.viewApi||h.calendarApi.view});h.emitter.trigger("dateClick",p)}}},this.dragging=new Ho(e.el),this.dragging.autoScroller.isEnabled=!1;let n=this.hitDragging=new Tu(this.dragging,Nm(e));n.emitter.on("pointerdown",this.handlePointerDown),n.emitter.on("dragend",this.handleDragEnd)}destroy(){this.dragging.destroy()}}class pP extends Jl{constructor(e){super(e),this.dragSelection=null,this.handlePointerDown=d=>{let{component:f,dragging:h}=this,{options:p}=f.context,b=p.selectable&&f.isValidDateDownEl(d.origEvent.target);h.setIgnoreMove(!b),h.delay=d.isTouch?gP(f):null},this.handleDragStart=d=>{this.component.context.calendarApi.unselect(d)},this.handleHitUpdate=(d,f)=>{let{context:h}=this.component,p=null,b=!1;if(d){let y=this.hitDragging.initialHit;d.componentId===y.componentId&&this.isHitComboAllowed&&!this.isHitComboAllowed(y,d)||(p=mP(y,d,h.pluginHooks.dateSelectionTransformers)),(!p||!Z3(p,d.dateProfile,h))&&(b=!0,p=null)}p?h.dispatch({type:"SELECT_DATES",selection:p}):f||h.dispatch({type:"UNSELECT_DATES"}),b?rm():lm(),f||(this.dragSelection=p)},this.handlePointerUp=d=>{this.dragSelection&&(ej(this.dragSelection,d,this.component.context),this.dragSelection=null)};let{component:n}=e,{options:r}=n.context,i=this.dragging=new Ho(e.el);i.touchScrollAllowed=!1,i.minDistance=r.selectMinDistance||0,i.autoScroller.isEnabled=r.dragScroll;let c=this.hitDragging=new Tu(this.dragging,Nm(e));c.emitter.on("pointerdown",this.handlePointerDown),c.emitter.on("dragstart",this.handleDragStart),c.emitter.on("hitupdate",this.handleHitUpdate),c.emitter.on("pointerup",this.handlePointerUp)}destroy(){this.dragging.destroy()}}function gP(t){let{options:e}=t.context,n=e.selectLongPressDelay;return n==null&&(n=e.longPressDelay),n}function mP(t,e,n){let r=t.dateSpan,i=e.dateSpan,c=[r.range.start,r.range.end,i.range.start,i.range.end];c.sort(wI);let d={};for(let f of n){let h=f(t,e);if(h===!1)return null;h&&Object.assign(d,h)}return d.range={start:c[0],end:c[3]},d.allDay=r.allDay,d}class Go extends Jl{constructor(e){super(e),this.subjectEl=null,this.subjectSeg=null,this.isDragging=!1,this.eventRange=null,this.relevantEvents=null,this.receivingContext=null,this.validMutation=null,this.mutatedRelevantEvents=null,this.handlePointerDown=d=>{let f=d.origEvent.target,{component:h,dragging:p}=this,{mirror:b}=p,{options:y}=h.context,m=h.context;this.subjectEl=d.subjectEl;let v=this.subjectSeg=Hl(d.subjectEl),S=(this.eventRange=v.eventRange).instance.instanceId;this.relevantEvents=xm(m.getCurrentData().eventStore,S),p.minDistance=d.isTouch?0:y.eventDragMinDistance,p.delay=d.isTouch&&S!==h.props.eventSelection?bP(h):null,y.fixedMirrorParent?b.parentNode=y.fixedMirrorParent:b.parentNode=qt(f,".fc"),b.revertDuration=y.dragRevertDuration;let j=h.isValidSegDownEl(f)&&!qt(f,".fc-event-resizer");p.setIgnoreMove(!j),this.isDragging=j&&d.subjectEl.classList.contains("fc-event-draggable")},this.handleDragStart=d=>{let f=this.component.context,h=this.eventRange,p=h.instance.instanceId;d.isTouch?p!==this.component.props.eventSelection&&f.dispatch({type:"SELECT_EVENT",eventInstanceId:p}):f.dispatch({type:"UNSELECT_EVENT"}),this.isDragging&&(f.calendarApi.unselect(d),f.emitter.trigger("eventDragStart",{el:this.subjectEl,event:new ut(f,h.def,h.instance),jsEvent:d.origEvent,view:f.viewApi}))},this.handleHitUpdate=(d,f)=>{if(!this.isDragging)return;let h=this.relevantEvents,p=this.hitDragging.initialHit,b=this.component.context,y=null,m=null,v=null,N=!1,S={affectedEvents:h,mutatedEvents:Cn(),isEvent:!0};if(d){y=d.context;let j=y.options;b===y||j.editable&&j.droppable?(m=xP(p,d,this.eventRange.instance.range.start,y.getCurrentData().pluginHooks.eventDragMutationMassagers),m&&(v=vm(h,y.getCurrentData().eventUiBases,m,y),S.mutatedEvents=v,Nj(S,d.dateProfile,y)||(N=!0,m=null,v=null,S.mutatedEvents=Cn()))):y=null}this.displayDrag(y,S),N?rm():lm(),f||(b===y&&ku(p,d)&&(m=null),this.dragging.setMirrorNeedsRevert(!m),this.dragging.setMirrorIsVisible(!d||!this.subjectEl.getRootNode().querySelector(".fc-event-mirror")),this.receivingContext=y,this.validMutation=m,this.mutatedRelevantEvents=v)},this.handlePointerUp=()=>{this.isDragging||this.cleanup()},this.handleDragEnd=d=>{if(this.isDragging){let f=this.component.context,h=f.viewApi,{receivingContext:p,validMutation:b}=this,y=this.eventRange.def,m=this.eventRange.instance,v=new ut(f,y,m),N=this.relevantEvents,S=this.mutatedRelevantEvents,{finalHit:j}=this.hitDragging;if(this.clearDrag(),f.emitter.trigger("eventDragStop",{el:this.subjectEl,event:v,jsEvent:d.origEvent,view:h}),b){if(p===f){let R=new ut(f,S.defs[y.defId],m?S.instances[m.instanceId]:null);f.dispatch({type:"MERGE_EVENTS",eventStore:S});let C={oldEvent:v,event:R,relatedEvents:jr(S,f,m),revert(){f.dispatch({type:"MERGE_EVENTS",eventStore:N})}},O={};for(let A of f.getCurrentData().pluginHooks.eventDropTransformers)Object.assign(O,A(b,f));f.emitter.trigger("eventDrop",Object.assign(Object.assign(Object.assign({},C),O),{el:d.subjectEl,delta:b.datesDelta,jsEvent:d.origEvent,view:h})),f.emitter.trigger("eventChange",C)}else if(p){let R={event:v,relatedEvents:jr(N,f,m),revert(){f.dispatch({type:"MERGE_EVENTS",eventStore:N})}};f.emitter.trigger("eventLeave",Object.assign(Object.assign({},R),{draggedEl:d.subjectEl,view:h})),f.dispatch({type:"REMOVE_EVENTS",eventStore:N}),f.emitter.trigger("eventRemove",R);let C=S.defs[y.defId],O=S.instances[m.instanceId],A=new ut(p,C,O);p.dispatch({type:"MERGE_EVENTS",eventStore:S});let k={event:A,relatedEvents:jr(S,p,O),revert(){p.dispatch({type:"REMOVE_EVENTS",eventStore:S})}};p.emitter.trigger("eventAdd",k),d.isTouch&&p.dispatch({type:"SELECT_EVENT",eventInstanceId:m.instanceId}),p.emitter.trigger("drop",Object.assign(Object.assign({},aA(j.dateSpan,p)),{draggedEl:d.subjectEl,jsEvent:d.origEvent,view:j.context.viewApi})),p.emitter.trigger("eventReceive",Object.assign(Object.assign({},k),{draggedEl:d.subjectEl,view:j.context.viewApi}))}}else f.emitter.trigger("_noEventDrop")}this.cleanup()};let{component:n}=this,{options:r}=n.context,i=this.dragging=new Ho(e.el);i.pointer.selector=Go.SELECTOR,i.touchScrollAllowed=!1,i.autoScroller.isEnabled=r.dragScroll;let c=this.hitDragging=new Tu(this.dragging,sg);c.useSubjectCenter=e.useEventCenter,c.emitter.on("pointerdown",this.handlePointerDown),c.emitter.on("dragstart",this.handleDragStart),c.emitter.on("hitupdate",this.handleHitUpdate),c.emitter.on("pointerup",this.handlePointerUp),c.emitter.on("dragend",this.handleDragEnd)}destroy(){this.dragging.destroy()}displayDrag(e,n){let r=this.component.context,i=this.receivingContext;i&&i!==e&&(i===r?i.dispatch({type:"SET_EVENT_DRAG",state:{affectedEvents:n.affectedEvents,mutatedEvents:Cn(),isEvent:!0}}):i.dispatch({type:"UNSET_EVENT_DRAG"})),e&&e.dispatch({type:"SET_EVENT_DRAG",state:n})}clearDrag(){let e=this.component.context,{receivingContext:n}=this;n&&n.dispatch({type:"UNSET_EVENT_DRAG"}),e!==n&&e.dispatch({type:"UNSET_EVENT_DRAG"})}cleanup(){this.subjectSeg=null,this.isDragging=!1,this.eventRange=null,this.relevantEvents=null,this.receivingContext=null,this.validMutation=null,this.mutatedRelevantEvents=null}}Go.SELECTOR=".fc-event-draggable, .fc-event-resizable";function xP(t,e,n,r){let i=t.dateSpan,c=e.dateSpan,d=i.range.start,f=c.range.start,h={};i.allDay!==c.allDay&&(h.allDay=c.allDay,h.hasEnd=e.context.options.allDayMaintainDuration,c.allDay?d=it(n):d=n);let p=vl(d,f,t.context.dateEnv,t.componentId===e.componentId?t.largeUnit:null);p.milliseconds&&(h.allDay=!1);let b={datesDelta:p,standardProps:h};for(let y of r)y(b,t,e);return b}function bP(t){let{options:e}=t.context,n=e.eventLongPressDelay;return n==null&&(n=e.longPressDelay),n}class yP extends Jl{constructor(e){super(e),this.draggingSegEl=null,this.draggingSeg=null,this.eventRange=null,this.relevantEvents=null,this.validMutation=null,this.mutatedRelevantEvents=null,this.handlePointerDown=c=>{let{component:d}=this,f=this.querySegEl(c),h=Hl(f),p=this.eventRange=h.eventRange;this.dragging.minDistance=d.context.options.eventDragMinDistance,this.dragging.setIgnoreMove(!this.component.isValidSegDownEl(c.origEvent.target)||c.isTouch&&this.component.props.eventSelection!==p.instance.instanceId)},this.handleDragStart=c=>{let{context:d}=this.component,f=this.eventRange;this.relevantEvents=xm(d.getCurrentData().eventStore,this.eventRange.instance.instanceId);let h=this.querySegEl(c);this.draggingSegEl=h,this.draggingSeg=Hl(h),d.calendarApi.unselect(),d.emitter.trigger("eventResizeStart",{el:h,event:new ut(d,f.def,f.instance),jsEvent:c.origEvent,view:d.viewApi})},this.handleHitUpdate=(c,d,f)=>{let{context:h}=this.component,p=this.relevantEvents,b=this.hitDragging.initialHit,y=this.eventRange.instance,m=null,v=null,N=!1,S={affectedEvents:p,mutatedEvents:Cn(),isEvent:!0};c&&(c.componentId===b.componentId&&this.isHitComboAllowed&&!this.isHitComboAllowed(b,c)||(m=vP(b,c,f.subjectEl.classList.contains("fc-event-resizer-start"),y.range))),m&&(v=vm(p,h.getCurrentData().eventUiBases,m,h),S.mutatedEvents=v,Nj(S,c.dateProfile,h)||(N=!0,m=null,v=null,S.mutatedEvents=null)),v?h.dispatch({type:"SET_EVENT_RESIZE",state:S}):h.dispatch({type:"UNSET_EVENT_RESIZE"}),N?rm():lm(),d||(m&&ku(b,c)&&(m=null),this.validMutation=m,this.mutatedRelevantEvents=v)},this.handleDragEnd=c=>{let{context:d}=this.component,f=this.eventRange.def,h=this.eventRange.instance,p=new ut(d,f,h),b=this.relevantEvents,y=this.mutatedRelevantEvents;if(d.emitter.trigger("eventResizeStop",{el:this.draggingSegEl,event:p,jsEvent:c.origEvent,view:d.viewApi}),this.validMutation){let m=new ut(d,y.defs[f.defId],h?y.instances[h.instanceId]:null);d.dispatch({type:"MERGE_EVENTS",eventStore:y});let v={oldEvent:p,event:m,relatedEvents:jr(y,d,h),revert(){d.dispatch({type:"MERGE_EVENTS",eventStore:b})}};d.emitter.trigger("eventResize",Object.assign(Object.assign({},v),{el:this.draggingSegEl,startDelta:this.validMutation.startDelta||Ge(0),endDelta:this.validMutation.endDelta||Ge(0),jsEvent:c.origEvent,view:d.viewApi})),d.emitter.trigger("eventChange",v)}else d.emitter.trigger("_noEventResize");this.draggingSeg=null,this.relevantEvents=null,this.validMutation=null};let{component:n}=e,r=this.dragging=new Ho(e.el);r.pointer.selector=".fc-event-resizer",r.touchScrollAllowed=!1,r.autoScroller.isEnabled=n.context.options.dragScroll;let i=this.hitDragging=new Tu(this.dragging,Nm(e));i.emitter.on("pointerdown",this.handlePointerDown),i.emitter.on("dragstart",this.handleDragStart),i.emitter.on("hitupdate",this.handleHitUpdate),i.emitter.on("dragend",this.handleDragEnd)}destroy(){this.dragging.destroy()}querySegEl(e){return qt(e.subjectEl,".fc-event")}}function vP(t,e,n,r){let i=t.context.dateEnv,c=t.dateSpan.range.start,d=e.dateSpan.range.start,f=vl(c,d,i,t.largeUnit);if(n){if(i.add(r.start,f)r.start)return{endDelta:f};return null}class NP{constructor(e){this.context=e,this.isRecentPointerDateSelect=!1,this.matchesCancel=!1,this.matchesEvent=!1,this.onSelect=r=>{r.jsEvent&&(this.isRecentPointerDateSelect=!0)},this.onDocumentPointerDown=r=>{let i=this.context.options.unselectCancel,c=TS(r.origEvent);this.matchesCancel=!!qt(c,i),this.matchesEvent=!!qt(c,Go.SELECTOR)},this.onDocumentPointerUp=r=>{let{context:i}=this,{documentPointer:c}=this,d=i.getCurrentData();if(!c.wasTouchScroll){if(d.dateSelection&&!this.isRecentPointerDateSelect){let f=i.options.unselectAuto;f&&(!f||!this.matchesCancel)&&i.calendarApi.unselect(r)}d.eventSelection&&!this.matchesEvent&&i.dispatch({type:"UNSELECT_EVENT"})}this.isRecentPointerDateSelect=!1};let n=this.documentPointer=new Jj(document);n.shouldIgnoreMove=!0,n.shouldWatchScroll=!1,n.emitter.on("pointerdown",this.onDocumentPointerDown),n.emitter.on("pointerup",this.onDocumentPointerUp),e.emitter.on("select",this.onSelect)}destroy(){this.context.emitter.off("select",this.onSelect),this.documentPointer.destroy()}}const EP={fixedMirrorParent:Z},SP={dateClick:Z,eventDragStart:Z,eventDragStop:Z,eventDrop:Z,eventResizeStart:Z,eventResizeStop:Z,eventResize:Z,drop:Z,eventReceive:Z,eventLeave:Z};wm.dataAttrPrefix="";var jP=qa({name:"@fullcalendar/interaction",componentInteractions:[hP,pP,Go,yP],calendarInteractions:[NP],elementDraggingImpl:Ho,optionRefiners:EP,listenerRefiners:SP});const du=({ownerId:t,isConnected:e,onStatusChange:n})=>{const[r,i]=w.useState(!1),c=async()=>{i(!0);try{const f=await fetch(`/api/auth/google/url?dentistId=${t}`),h=await f.json();if(!f.ok||h.error){alert(`Erro: ${h.error||"Falha ao obter URL de autenticação"}`),i(!1);return}const{url:p}=h,b=600,y=700,m=window.screen.width/2-b/2,v=window.screen.height/2-y/2,N=window.open(p,"google-auth",`width=${b},height=${y},left=${m},top=${v}`),S=setInterval(()=>{(!N||N.closed)&&(clearInterval(S),i(!1),n&&n())},1e3)}catch(f){console.error("Erro ao conectar Google Agenda:",f),i(!1)}},d=async()=>{if(confirm("Deseja realmente desconectar esta agenda?")){i(!0);try{await fetch(`/api/auth/google/${t}`,{method:"DELETE"}),n&&n()}catch(f){console.error("Erro ao desconectar:",f)}finally{i(!1)}}};return e?s.jsxs("div",{className:"flex items-center gap-3 bg-emerald-50 border border-emerald-100 p-4 rounded-2xl",children:[s.jsx("div",{className:"p-2 bg-emerald-500 rounded-xl",children:s.jsx(da,{size:18,className:"text-white"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-[10px] font-black text-emerald-800 uppercase tracking-tight",children:"Google Agenda Conectada"}),s.jsx("p",{className:"text-[9px] text-emerald-600 font-bold uppercase tracking-widest mt-0.5",children:"Sincronização Ativa"})]}),s.jsx("button",{onClick:d,disabled:r,className:"text-[9px] font-black text-red-500 hover:text-red-700 uppercase tracking-widest px-3 py-1 bg-white border border-red-100 rounded-lg shadow-sm transition-all",children:r?s.jsx(Ct,{size:12,className:"animate-spin"}):"Desconectar"})]}):s.jsxs("button",{onClick:c,disabled:r,className:"w-full group relative overflow-hidden flex items-center gap-4 bg-white border-2 border-gray-100 p-4 rounded-2xl hover:border-blue-500 hover:shadow-xl hover:shadow-blue-50/50 transition-all duration-300",children:[s.jsx("div",{className:"p-3 bg-gray-50 group-hover:bg-blue-600 rounded-xl transition-colors duration-300",children:s.jsx(Et,{size:20,className:"text-gray-400 group-hover:text-white transition-colors duration-300"})}),s.jsxs("div",{className:"text-left",children:[s.jsx("p",{className:"text-xs font-black text-gray-800 uppercase tracking-tight group-hover:text-blue-600",children:"Conectar Google Agenda"}),s.jsx("p",{className:"text-[10px] text-gray-400 font-bold uppercase tracking-widest",children:"Sincronize horários externos"})]}),r&&s.jsx("div",{className:"absolute right-4",children:s.jsx(Ct,{size:18,className:"text-blue-600 animate-spin"})})]})},AP=({isOpen:t,onClose:e,dentists:n})=>{const[r,i]=w.useState(1),[c,d]=w.useState({clinicEmail:"",clinicCalendarId:"",googleApiKey:"",googleCalendarIds:{}}),[f,h]=w.useState(!1),[p,b]=w.useState([]),y=Fe(),m=async()=>{try{const R=await(await fetch("/api/auth/google/status")).json();b(R)}catch(j){console.error("Erro ao buscar status do Google:",j)}};w.useEffect(()=>{t&&((async()=>{try{const R=await J.getSettings();d({clinicEmail:R.clinicEmail||"",clinicCalendarId:R.clinicCalendarId||"",googleApiKey:R.googleApiKey||"",googleCalendarIds:R.googleCalendarIds||{}})}catch(R){console.error("Erro ao carregar configurações:",R)}})(),m(),i(1))},[t]);const v=j=>{const R=`/api/auth/google/url?dentistId=${j}`;navigator.clipboard.writeText(R),y.success("LINK DE CONVITE COPIADO!")},N=async()=>{h(!0);try{await J.saveSettings(c),y.success("CONFIGURAÇÕES SALVAS COM SUCESSO!"),e()}catch{y.error("ERRO AO SALVAR CONFIGURAÇÕES.")}finally{h(!1)}};if(!t)return null;const S=3;return s.jsxs("div",{className:"fixed inset-0 bg-black/60 z-[60] flex items-center justify-center backdrop-blur-md p-0",children:[s.jsxs("div",{className:"bg-white shadow-2xl w-full h-dvh md:w-[96vw] md:h-[98vh] rounded-none md:rounded-[2.5rem] flex flex-col overflow-hidden border border-gray-100 animate-in fade-in zoom-in-95 duration-300",children:[s.jsxs("div",{className:"px-10 py-8 border-b border-gray-50 flex justify-between items-center bg-gradient-to-br from-gray-50 to-white",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"p-3 bg-blue-600 rounded-2xl shadow-lg shadow-blue-200",children:s.jsx(Md,{size:24,className:"text-white animate-spin-slow"})}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-xl font-black text-gray-900 uppercase tracking-tighter",children:"Configurações da Agenda"}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest mt-0.5",children:"Integrações e Comunicação"})]})]}),s.jsx("button",{onClick:e,className:"p-2 hover:bg-gray-100 rounded-xl transition-colors text-gray-400",children:s.jsx(Qe,{size:24})})]}),s.jsx("div",{className:"h-1.5 w-full bg-gray-100 flex",children:s.jsx("div",{className:"h-full bg-blue-600 transition-all duration-500 ease-out shadow-[0_0_10px_rgba(37,99,235,0.5)]",style:{width:`${r/S*100}%`}})}),s.jsx("div",{className:"flex-1 relative overflow-hidden bg-white",children:s.jsxs("div",{className:"absolute inset-0 flex transition-transform duration-500 ease-in-out transform-gpu",style:{transform:`translateX(-${(r-1)*100}%)`},children:[s.jsxs("div",{className:"w-full shrink-0 p-10 animate-in fade-in duration-700",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-8",children:[s.jsx(Rg,{className:"text-blue-600",size:24}),s.jsx("h3",{className:"text-sm font-black text-gray-800 uppercase tracking-tight",children:"E-mails da Clínica"})]}),s.jsx("div",{className:"space-y-6",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-[0.2em] ml-1",children:"E-mail para Notificações"}),s.jsx("input",{type:"email",placeholder:"EX: CONTATO@CLINICA.COM",className:"w-full bg-gray-50 border-2 border-transparent focus:border-blue-600 focus:bg-white rounded-2xl p-4 font-bold text-gray-800 outline-none transition-all shadow-sm",value:c.clinicEmail,onChange:j=>d({...c,clinicEmail:j.target.value.toUpperCase()})}),s.jsx("p",{className:"text-[10px] text-gray-400 italic ml-1",children:"* Este e-mail será usado para alertas de sistema e envio de comprovantes."})]})})]}),s.jsxs("div",{className:"w-full shrink-0 p-10 animate-in fade-in duration-700 overflow-y-auto custom-scrollbar",children:[s.jsxs("div",{className:"flex justify-between items-center mb-6",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{className:"text-emerald-600",size:24}),s.jsx("h3",{className:"text-sm font-black text-gray-800 uppercase tracking-tight",children:"Configuração Google Agenda"})]}),s.jsx("a",{href:"https://console.cloud.google.com/apis/library/calendar-json.googleapis.com",target:"_blank",rel:"noreferrer",className:"text-[9px] font-black text-white bg-black px-3 py-1.5 rounded-lg hover:opacity-80 transition-all uppercase tracking-widest",children:"1. Ativar API"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-6 mb-8",children:[s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{className:"bg-emerald-50 rounded-2xl p-4 border border-emerald-100",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx("div",{className:"w-5 h-5 bg-emerald-600 text-white text-[10px] font-black flex items-center justify-center rounded-full",children:"1"}),s.jsx("span",{className:"text-[10px] font-black text-emerald-800 uppercase",children:"Google API Key"})]}),s.jsx("input",{type:"password",placeholder:"COLE A CHAVE AQUI",className:"w-full bg-white border border-emerald-200 rounded-xl px-4 py-2 text-xs font-bold text-gray-700 outline-none focus:ring-2 focus:ring-emerald-100",value:c.googleApiKey,onChange:j=>d({...c,googleApiKey:j.target.value})}),s.jsx("a",{href:"https://console.cloud.google.com/apis/credentials",target:"_blank",rel:"noreferrer",className:"text-[8px] font-black text-emerald-600 hover:underline mt-2 inline-block uppercase",children:"Criar Credenciais ➔"})]})}),s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{className:"bg-blue-50 rounded-2xl p-4 border border-blue-100",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx("div",{className:"w-5 h-5 bg-blue-600 text-white text-[10px] font-black flex items-center justify-center rounded-full",children:"2"}),s.jsx("span",{className:"text-[10px] font-black text-blue-800 uppercase",children:"ID Agenda Clínica"})]}),s.jsx("input",{type:"text",placeholder:"ID DA AGENDA",className:"w-full bg-white border border-blue-200 rounded-xl px-4 py-2 text-xs font-bold text-gray-700 outline-none focus:ring-2 focus:ring-blue-100",value:c.clinicCalendarId,onChange:j=>d({...c,clinicCalendarId:j.target.value})}),s.jsx("a",{href:"https://calendar.google.com/calendar/r/settings",target:"_blank",rel:"noreferrer",className:"text-[8px] font-black text-blue-600 hover:underline mt-2 inline-block uppercase",children:"Pegar ID nas Configs ➔"})]})})]}),s.jsxs("div",{className:"bg-gray-900 rounded-3xl p-6 text-white",children:[s.jsx("h4",{className:"text-[10px] font-black text-blue-400 uppercase tracking-[0.2em] mb-4",children:"Guia de Integração"}),s.jsxs("ul",{className:"space-y-3",children:[s.jsxs("li",{className:"flex gap-3 text-xs",children:[s.jsx(da,{size:16,className:"text-emerald-500 shrink-0"}),s.jsxs("span",{className:"text-gray-300",children:["Crie um projeto no ",s.jsx("strong",{children:"Google Cloud Console"}),"."]})]}),s.jsxs("li",{className:"flex gap-3 text-xs",children:[s.jsx(da,{size:16,className:"text-emerald-500 shrink-0"}),s.jsxs("span",{className:"text-gray-300",children:["No menu 'Biblioteca', ative a ",s.jsx("strong",{children:"Google Calendar API"}),"."]})]}),s.jsxs("li",{className:"flex gap-3 text-xs",children:[s.jsx(da,{size:16,className:"text-emerald-500 shrink-0"}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsxs("span",{className:"text-gray-300",children:["Pegue o ",s.jsx("strong",{children:"ID da Agenda"})," nas configurações (Integrar agenda)."]}),s.jsx("a",{href:"https://calendar.google.com/calendar/r/settings",target:"_blank",rel:"noreferrer",className:"text-[9px] font-black text-blue-400 hover:underline flex items-center gap-1 uppercase",children:"Abrir Configurações de Agenda ➔"})]})]}),s.jsxs("li",{className:"flex gap-3 text-xs",children:[s.jsx(da,{size:16,className:"text-emerald-500 shrink-0"}),s.jsxs("span",{className:"text-gray-300",children:["No Google Agenda, torne a agenda ",s.jsx("strong",{children:"Pública"})," nas autorizações de acesso."]})]})]})]})]}),s.jsxs("div",{className:"w-full shrink-0 p-10 animate-in fade-in duration-700 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{className:"text-emerald-600",size:24}),s.jsx("h3",{className:"text-sm font-black text-gray-800 uppercase tracking-tight",children:"Agendas dos Dentistas"})]}),s.jsx("a",{href:"https://calendar.google.com/calendar/u/0/r/settings",target:"_blank",rel:"noreferrer",className:"text-[9px] font-black text-white bg-gray-900 px-3 py-1.5 rounded-lg hover:bg-black transition-colors uppercase tracking-widest",children:"Abrir Google Calendar"})]}),s.jsxs("div",{className:"space-y-4 flex-1 overflow-y-auto pr-4 custom-scrollbar",children:[s.jsxs("div",{className:"bg-blue-50/50 p-4 rounded-2xl border border-blue-100 mb-2",children:[s.jsx("p",{className:"text-[10px] text-blue-800 font-bold mb-1 uppercase tracking-wider",children:"Nova Integração Inteligente (OAuth2)"}),s.jsx("p",{className:"text-[10px] text-blue-600 italic",children:"Agora você pode conectar agendas sem precisar torná-las públicas ou usar API Keys."})]}),s.jsxs("div",{className:"space-y-3 mb-6",children:[s.jsx("h4",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-1",children:"Sua Conta (Administrador)"}),s.jsx(du,{ownerId:"admin",isConnected:p.some(j=>j.owner_id==="admin"||j.owner_id.includes("@")),onStatusChange:m})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("h4",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-1",children:"Contas dos Dentistas"}),n!=null&&n.length?n.map(j=>{var C;const R=p.some(O=>O.owner_id===j.id);return s.jsxs("div",{className:"bg-gray-50 rounded-2xl p-4 border border-transparent hover:border-gray-200 transition-all",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:j.corAgenda}}),s.jsx("span",{className:"text-xs font-black text-gray-800 uppercase",children:j.nome})]}),R?s.jsx("span",{className:"text-[9px] font-black text-emerald-600 bg-emerald-100 px-2 py-1 rounded-lg uppercase",children:"Conectado"}):s.jsx("span",{className:"text-[9px] font-black text-gray-400 uppercase",children:"Não Vinculado"})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("div",{className:"flex-1",children:s.jsx(du,{ownerId:j.id,isConnected:R,onStatusChange:m})}),!R&&s.jsx("button",{onClick:()=>v(j.id),className:"p-4 bg-gray-100 text-gray-600 rounded-2xl hover:bg-gray-200 transition-all flex items-center justify-center group",title:"Gerar Link para o Dentista",children:s.jsx($N,{size:18,className:"group-hover:scale-110 transition-transform"})})]}),s.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-200/50",children:[s.jsx("label",{className:"text-[9px] font-bold text-gray-400 uppercase ml-1",children:"ID Alternativo (API Key/Legado)"}),s.jsx("input",{type:"text",placeholder:"ID DA AGENDA GOOGLE (SE NÃO USAR OAUTH2)",className:"w-full bg-white/50 border border-gray-200 rounded-xl px-4 py-2 text-[10px] font-bold text-gray-500 outline-none focus:ring-1 focus:ring-blue-100 mt-1",value:((C=c.googleCalendarIds)==null?void 0:C[j.id])||"",onChange:O=>d({...c,googleCalendarIds:{...c.googleCalendarIds,[j.id]:O.target.value}})})]})]},j.id)}):s.jsx("p",{className:"text-center text-xs text-gray-400 py-10 uppercase font-bold",children:"Nenhum dentista cadastrado."})]})]})]})]})}),s.jsxs("div",{className:"px-10 py-8 bg-gray-50/50 border-t border-gray-100 flex justify-between items-center",children:[s.jsx("div",{className:"flex gap-2",children:r>1&&s.jsxs("button",{onClick:()=>i(r-1),className:"flex items-center gap-2 px-6 py-3 text-xs font-black text-gray-500 hover:text-gray-900 bg-white rounded-2xl border border-gray-200 hover:shadow-md transition-all uppercase tracking-widest",children:[s.jsx(Bs,{size:16})," Anterior"]})}),s.jsx("div",{className:"flex gap-4",children:ri(r+1),className:"flex items-center gap-2 px-8 py-4 bg-blue-600 text-white rounded-[1.5rem] text-xs font-black uppercase tracking-widest hover:bg-blue-700 hover:shadow-xl hover:shadow-blue-200 transition-all shadow-lg shadow-blue-100",children:["Próximo ",s.jsx(Ts,{size:16})]}):s.jsx("button",{onClick:N,disabled:f,className:"flex items-center gap-2 px-10 py-4 bg-emerald-600 text-white rounded-[1.5rem] text-xs font-black uppercase tracking-widest hover:bg-emerald-700 hover:shadow-xl hover:shadow-emerald-200 transition-all shadow-lg shadow-emerald-100 disabled:bg-gray-400",children:f?"Salvando...":s.jsxs(s.Fragment,{children:[s.jsx(Io,{size:16})," Salvar Tudo"]})})})]})]}),s.jsx("style",{children:` .animate-spin-slow { animation: spin 8s linear infinite; } @keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } .custom-scrollbar::-webkit-scrollbar { width: 4px; } .custom-scrollbar::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 10px; } .custom-scrollbar::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; } .custom-scrollbar::-webkit-scrollbar-thumb:hover { background: #94a3b8; } `})]})};function wP(t,e){const[n,r]=w.useState(t);return w.useEffect(()=>{const i=setTimeout(()=>{r(t)},e);return()=>clearTimeout(i)},[t,e]),n}const CP=({isOpen:t,onClose:e,onSave:n,dentists:r,initialDate:i,initialAppointment:c})=>{var W;const[d,f]=w.useState(null),[h,p]=w.useState(""),[b,y]=w.useState(15),[m,v]=w.useState(i?i.split("T")[0]:new Date().toISOString().split("T")[0]),[N,S]=w.useState(i?new Date(i).toTimeString().substring(0,5):""),[j,R]=w.useState((W=r==null?void 0:r[0])==null?void 0:W.id),[C,O]=w.useState(""),[A,k]=w.useState(!1),_=wP(h,400),B=w.useCallback(()=>J.getPacientes(_).then(te=>Array.isArray(te.data)?te.data:[]),[_]),{data:F,isLoading:G}=_e(B,[_]),{data:ee,refresh:ne}=_e(J.getAgendamentos),oe=J.getActiveWorkspace(),{data:Q}=_e(()=>j&&oe?J.getHorariosByDentista(j,oe.id):Promise.resolve([]),[j,oe==null?void 0:oe.id]),ce=Fe();w.useEffect(()=>{if(t)if(c){f({nome:c.pacienteNome,cpf:"",id:"temp"});const te=new Date(c.start),T=new Date(c.end);v(te.toISOString().split("T")[0]),S(te.toTimeString().substring(0,5)),y((T.getTime()-te.getTime())/6e4),R(c.dentistaId),O(c.procedimento)}else f(null),p(""),v(i?i.split("T")[0]:new Date().toISOString().split("T")[0]),S(i?new Date(i).toTimeString().substring(0,5):""),O(""),y(15),r&&r.length>0&&R(r[0].id)},[t,i,r,c]),w.useEffect(()=>{if(!t)return;const te=T=>{T.key==="Escape"&&e()};return document.addEventListener("keydown",te),()=>document.removeEventListener("keydown",te)},[t,e]);const he=r==null?void 0:r.find(te=>te.id===j),H=w.useCallback(()=>{const te=[];if(!j||!m)return te;const T=(ee??[]).filter(de=>de.dentistaId===j&&new Date(de.start).toISOString().split("T")[0]===m&&de.id!==(c==null?void 0:c.id)).map(de=>({start:new Date(de.start).getHours()*60+new Date(de.start).getMinutes(),end:new Date(de.end).getHours()*60+new Date(de.end).getMinutes()})),X=new Date(m).getUTCDay(),ie=(Q==null?void 0:Q.filter(de=>de.dia_semana===X&&de.ativo))||[];if(ie.length===0){for(let de=480;de<1080;de+=15)if(!T.some(je=>de>=je.start&&deUe>=Rn.start&&Ue{f(te),p(""),k(!1)},P=async te=>{if(te.preventDefault(),!d||!m||!N||!j||!C){ce.error("PREENCHA TODOS OS CAMPOS PARA AGENDAR.");return}const T=new Date(`${m}T${N}:00`),X=new Date(T.getTime()+b*6e4);try{const ie={pacienteNome:d.nome,dentistaId:j,start:T.toISOString(),end:X.toISOString(),status:(c==null?void 0:c.status)||"Pendente",procedimento:C.toUpperCase()};c!=null&&c.id?(await J.atualizarAgendamento(c.id,ie),ce.success(`AGENDAMENTO DE ${d.nome} ATUALIZADO!`)):(await J.salvarAgendamento(ie),ce.success(`AGENDAMENTO PARA ${d.nome} SALVO!`)),ne(),n()}catch{ce.error("ERRO AO SALVAR AGENDAMENTO.")}};return t?s.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center backdrop-blur-sm p-0",children:s.jsxs("form",{onSubmit:P,className:"bg-white shadow-2xl w-full h-dvh md:w-[96vw] md:h-[98vh] rounded-none md:rounded-xl flex flex-col overflow-hidden animate-in fade-in zoom-in-50 duration-200",children:[s.jsxs("div",{className:"px-5 py-4 border-b border-gray-200 flex justify-between items-center flex-shrink-0 bg-gradient-to-r from-orange-50 to-white",children:[s.jsxs("h2",{className:"text-lg font-bold text-gray-800 flex items-center gap-2 uppercase",children:[s.jsx(Et,{size:22,className:"text-orange-500"})," AGENDAR CONSULTA"]}),s.jsx("button",{type:"button",onClick:e,className:"text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-lg p-1.5 transition-colors",children:s.jsx(Qe,{size:22})})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-5 lg:p-8",children:[s.jsxs("div",{className:"mb-6",children:[s.jsx("label",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider",children:"PACIENTE"}),d?s.jsxs("div",{className:"w-full lg:w-1/2 bg-green-50 border border-green-200 p-3 lg:p-4 rounded-lg mt-2 flex justify-between items-center",children:[s.jsx("span",{className:"font-bold text-green-800 uppercase text-sm lg:text-base",children:d.nome}),s.jsx("button",{type:"button",onClick:()=>f(null),className:"text-xs font-bold bg-blue-100 text-blue-700 hover:bg-blue-200 px-3 py-1.5 rounded-md transition-colors",children:"ALTERAR"})]}):s.jsxs("div",{className:"relative mt-2",children:[s.jsx("input",{type:"text",value:h,onChange:te=>p(te.target.value.toUpperCase()),onFocus:()=>k(!0),onBlur:()=>setTimeout(()=>k(!1),200),placeholder:"DIGITE O NOME OU CPF...",className:"w-full lg:w-1/2 bg-gray-100 p-3 lg:p-4 rounded-lg font-bold text-gray-800 uppercase focus:border-blue-500 outline-none border-2 border-transparent focus:border-2 text-sm lg:text-base"}),A&&_&&s.jsxs("ul",{className:"absolute z-10 w-full lg:w-1/2 bg-white border border-gray-300 rounded-lg mt-1 max-h-48 overflow-y-auto shadow-lg",children:[G&&s.jsx("li",{className:"p-3 text-sm text-gray-500",children:"BUSCANDO..."}),F==null?void 0:F.map(te=>s.jsxs("li",{onMouseDown:()=>V(te),className:"p-3 hover:bg-gray-100 cursor-pointer uppercase font-semibold text-sm",children:[te.nome," (",te.cpf,")"]},te.id))]})]})]}),d&&s.jsx("div",{className:"animate-in fade-in space-y-6 lg:space-y-0",children:s.jsxs("div",{className:"lg:grid lg:grid-cols-3 lg:gap-x-8 lg:gap-y-6 space-y-5 lg:space-y-0",children:[s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider",children:"DENTISTA RESPONSÁVEL"}),s.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[s.jsx("select",{value:j,onChange:te=>R(te.target.value),className:"w-full border border-gray-300 rounded-lg p-2.5 lg:p-3 bg-white uppercase-select text-sm",children:r==null?void 0:r.map(te=>s.jsx("option",{value:te.id,children:te.nome},te.id))}),s.jsx("div",{className:"w-7 h-7 rounded-full flex-shrink-0 border-2 border-white shadow-md",style:{backgroundColor:(he==null?void 0:he.corAgenda)||"#ccc"}})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider",children:"DATA"}),s.jsx("input",{type:"date",value:m,onChange:te=>v(te.target.value),className:"w-full mt-2 border border-gray-300 bg-white text-gray-800 rounded-lg p-2.5 lg:p-3 text-sm"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider",children:"DURAÇÃO"}),s.jsxs("select",{value:b,onChange:te=>y(Number(te.target.value)),className:"w-full mt-2 border border-gray-300 rounded-lg p-2.5 lg:p-3 bg-white uppercase-select text-sm",children:[s.jsx("option",{value:15,children:"15 MIN"}),s.jsx("option",{value:30,children:"30 MIN"}),s.jsx("option",{value:45,children:"45 MIN"}),s.jsx("option",{value:60,children:"60 MIN"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider",children:"PROCEDIMENTO"}),s.jsx("input",{type:"text",value:C,onChange:te=>O(te.target.value.toUpperCase()),placeholder:"EX: AVALIAÇÃO, LIMPEZA...",className:"w-full mt-2 border border-gray-300 bg-white text-gray-800 rounded-lg p-2.5 lg:p-3 uppercase-input placeholder-gray-400 text-sm"})]})]}),s.jsxs("div",{className:"lg:col-span-2",children:[s.jsx("label",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider",children:"HORÁRIOS DISPONÍVEIS"}),s.jsxs("div",{className:"grid grid-cols-6 lg:grid-cols-8 xl:grid-cols-10 gap-2 mt-3",children:[H.map(te=>s.jsx("button",{type:"button",onClick:()=>S(te),className:`py-2.5 lg:py-3 rounded-lg text-sm font-bold border transition-all duration-150 ${N===te?"bg-blue-600 text-white border-blue-600 shadow-md scale-105":"bg-white text-gray-800 border-gray-300 hover:border-blue-400 hover:bg-blue-50"}`,children:te},te)),H.length===0&&s.jsx("p",{className:"col-span-6 lg:col-span-8 xl:col-span-10 text-center text-sm text-gray-400 p-8 bg-gray-50 rounded-lg border border-dashed border-gray-200 uppercase font-bold",children:"NENHUM HORÁRIO DISPONÍVEL."})]})]})]})})]}),s.jsxs("div",{className:"px-5 py-4 bg-gray-50 border-t border-gray-200 flex justify-end gap-3 flex-shrink-0",children:[s.jsx("button",{type:"button",onClick:e,className:"px-8 py-2.5 bg-gray-200 hover:bg-gray-300 text-gray-800 font-bold rounded-lg transition-colors text-sm uppercase",children:"CANCELAR"}),s.jsxs("button",{type:"submit",disabled:!d,className:"px-10 py-2.5 bg-orange-500 hover:bg-orange-600 text-white font-bold rounded-lg shadow-sm transition-colors text-sm uppercase disabled:bg-gray-400 disabled:cursor-not-allowed flex items-center gap-2",children:[s.jsx(Et,{size:16})," CONFIRMAR"]})]})]})}):null},DP=()=>{var oe;const{data:t,refresh:e}=_e(J.getAgendamentos),{data:n,refresh:r}=_e(J.getDentistas),{data:i,refresh:c}=_e(J.getGoogleEvents),[d,f]=w.useState([]),[h,p]=w.useState(!1),[b,y]=w.useState(!1),[m,v]=w.useState(null),[N,S]=w.useState(null),[j,R]=w.useState(!1),C=Fe();w.useEffect(()=>{var Q;if(t&&n){const ce=J.getCurrentRole(),he=J.getCurrentUser(),H=ce==="dentista",V=(Q=n.find(te=>te.email===he))==null?void 0:Q.id;let P=t;H&&(P=t.filter(te=>te.dentistaId===V));const W=P.map(te=>{const T=n.find(X=>X.id===te.dentistaId);return{id:te.id,title:`${te.pacienteNome} - ${te.procedimento}`,start:te.start,end:te.end,backgroundColor:te.status==="Faltou"?"#ef4444":T?T.corAgenda:"#94a3b8",borderColor:te.status==="Faltou"?"#ef4444":T?T.corAgenda:"#94a3b8",extendedProps:{...te,isGoogle:!1,dentistaNome:T==null?void 0:T.nome}}});if(i&&i.length>0){let te=i;H&&(te=i.filter(T=>T.extendedProps.owner_id===he)),W.push(...te)}f(W)}},[t,n,i]);const O=Q=>{v(Q),p(!0)},A=Q=>{if(Q.event.extendedProps.isGoogle){C.info(`EVENTO DO GOOGLE CALENDAR: ${Q.event.title}`);return}const ce=Q.event.extendedProps;S(ce),R(!0)},k=async(Q,ce)=>{try{await J.atualizarAgendamento(Q,{status:ce}),C.success(`STATUS ATUALIZADO PARA ${ce.toUpperCase()}`),e(),R(!1)}catch{C.error("ERRO AO ATUALIZAR STATUS.")}},_=async Q=>{if(confirm("DESEJA REALMENTE EXCLUIR ESTE AGENDAMENTO?"))try{await J.excluirAgendamento(Q),C.success("AGENDAMENTO EXCLUÍDO!"),e(),R(!1)}catch{C.error("ERRO AO EXCLUIR AGENDAMENTO.")}},B=()=>{e(),c(),p(!1),S(null)},F=async Q=>{if(!Q.destination||!n)return;const ce=Array.from(n),[he]=ce.splice(Q.source.index,1);ce.splice(Q.destination.index,0,he);const H=ce.map((V,P)=>({id:V.id,ordem:P}));try{await J.reorderDentistas(H),C.success("ORDEM DOS DENTISTAS ATUALIZADA!"),r()}catch{C.error("ERRO AO REORDENAR DENTISTAS.")}},G=J.getCurrentRole(),ee=J.getCurrentUser(),ne=n==null?void 0:n.filter(Q=>G==="admin"||G==="donoclinica"||G==="funcionario"?!0:G==="dentista"?Q.email===ee:!1);return s.jsxs("div",{className:"space-y-6",children:[s.jsx(cn,{title:"AGENDA CLÍNICA",children:s.jsxs("div",{className:"flex gap-4 items-center",children:[s.jsx(Xl,{onDragEnd:F,children:s.jsx(Kl,{droppableId:"dentists-legend",direction:"horizontal",children:Q=>s.jsxs("div",{...Q.droppableProps,ref:Q.innerRef,className:"hidden lg:flex gap-2 items-center",children:[ne==null?void 0:ne.map((ce,he)=>s.jsx(Zl,{draggableId:ce.id,index:he,isDragDisabled:G==="dentista",children:(H,V)=>s.jsxs("div",{ref:H.innerRef,...H.draggableProps,...H.dragHandleProps,className:`flex items-center gap-1.5 text-[10px] text-gray-700 bg-white border border-gray-200 px-3 py-1.5 rounded-full uppercase font-bold shadow-sm transition-all ${G!=="dentista"?"cursor-grab active:cursor-grabbing hover:border-gray-300":""} ${V.isDragging?"ring-2 ring-blue-500 scale-105 shadow-lg":""}`,children:[G!=="dentista"&&s.jsx(ql,{size:12,className:"text-gray-400"}),s.jsx("div",{className:"w-2.5 h-2.5 rounded-full shadow-inner",style:{backgroundColor:ce.corAgenda}}),ce.nome]})},ce.id)),Q.placeholder]})})}),(G==="admin"||G==="donoclinica")&&s.jsx("button",{onClick:()=>y(!0),className:"p-2.5 bg-white text-gray-400 hover:text-blue-600 border border-gray-200 rounded-xl transition-all hover:border-blue-200 hover:shadow-sm",children:s.jsx(Md,{size:20})}),G!=="paciente"&&s.jsxs("button",{onClick:()=>{v({dateStr:new Date().toISOString()}),p(!0)},className:"bg-blue-600 text-white px-4 py-2 rounded-lg text-sm font-bold uppercase flex items-center gap-2 hover:bg-blue-700 shadow-sm transition-colors",children:[s.jsx(ft,{size:16})," NOVO AGENDAMENTO"]})]})}),s.jsx("div",{className:"bg-white rounded-xl shadow-sm border border-gray-200 p-4 relative",style:{height:"750px"},children:s.jsx(Bj,{plugins:[xz,nP,jP],initialView:"timeGridWeek",headerToolbar:{left:"prev,next today",center:"title",right:"dayGridMonth,timeGridWeek,timeGridDay"},locale:"pt-br",buttonText:{today:"HOJE",month:"MÊS",week:"SEMANA",day:"DIA"},slotMinTime:"08:00:00",slotMaxTime:"19:00:00",allDaySlot:!1,events:d,dateClick:O,eventClick:A,height:"100%",slotLabelFormat:{hour:"2-digit",minute:"2-digit",hour12:!1},eventContent:Q=>{const ce=Q.event.extendedProps.isGoogle;return s.jsxs("div",{className:"p-0.5 overflow-hidden uppercase h-full",children:[s.jsx("div",{className:"text-[10px] font-bold",children:Q.timeText}),ce?s.jsx("div",{className:"text-[10px] font-black leading-tight break-words",children:Q.event.title}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"text-xs truncate font-bold",children:Q.event.extendedProps.pacienteNome}),s.jsx("div",{className:"text-[10px] truncate opacity-90",children:Q.event.extendedProps.procedimento})]})]})}})}),j&&N&&s.jsx("div",{className:"fixed inset-0 bg-black/40 z-[70] flex items-center justify-center backdrop-blur-sm p-0 animate-in fade-in duration-200",children:s.jsxs("div",{className:"bg-white shadow-2xl w-full h-dvh md:w-[96vw] md:h-[98vh] rounded-none md:rounded-[2rem] flex flex-col overflow-hidden border border-gray-100",children:[s.jsxs("div",{className:"px-8 py-6 border-b border-gray-50 flex justify-between items-center bg-gray-50/30",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{onClick:()=>{R(!1),p(!0)},className:"p-2.5 bg-white text-gray-400 hover:text-blue-600 rounded-xl border border-gray-100 hover:shadow-md transition-all group",title:"EDITAR",children:s.jsx(Lo,{size:18,className:"group-hover:scale-110 transition-transform"})}),s.jsx("button",{onClick:()=>_(N.id),className:"p-2.5 bg-white text-gray-400 hover:text-red-600 rounded-xl border border-gray-100 hover:shadow-md transition-all group",title:"EXCLUIR",children:s.jsx($t,{size:18,className:"group-hover:scale-110 transition-transform"})})]}),s.jsx("button",{onClick:()=>R(!1),className:"p-2 hover:bg-gray-100 rounded-full transition-colors text-gray-400",children:s.jsx(Qe,{size:24})})]}),s.jsxs("div",{className:"p-10 space-y-8",children:[s.jsxs("div",{className:"flex items-start gap-5",children:[s.jsx("div",{className:"p-4 bg-blue-50 rounded-2xl",children:s.jsx(zo,{size:28,className:"text-blue-600"})}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h3",{className:"text-xl font-black text-gray-900 leading-none uppercase tracking-tighter",children:N.pacienteNome}),s.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-bold text-gray-400 uppercase tracking-widest mt-2 bg-gray-100 px-3 py-1 rounded-full w-fit",children:[s.jsx(ua,{size:12,className:"text-blue-400"})," ",N.procedimento]})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-8 py-6 border-y border-gray-50",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Data e Hora"}),s.jsxs("div",{className:"flex items-center gap-2 text-sm font-bold text-gray-700",children:[s.jsx(AC,{size:16,className:"text-blue-500"}),new Date(N.start).toLocaleDateString("pt-BR",{weekday:"long",day:"numeric",month:"long"})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm font-bold text-gray-700",children:[s.jsx(Fl,{size:16,className:"text-blue-500"}),new Date(N.start).toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Profissional"}),s.jsxs("div",{className:"flex items-center gap-2 text-sm font-bold text-gray-700",children:[s.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-white shadow-sm",style:{backgroundColor:(oe=n==null?void 0:n.find(Q=>Q.id===N.dentistaId))==null?void 0:oe.corAgenda}}),N.dentistaNome]})]})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-1",children:"Status do Atendimento"}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("button",{onClick:()=>k(N.id,"Faltou"),className:`flex items-center justify-center gap-2 py-4 rounded-2xl text-xs font-black uppercase tracking-widest transition-all border-2 ${N.status==="Faltou"?"bg-red-50 text-red-600 border-red-200":"bg-white border-gray-100 text-gray-500 hover:border-red-200 hover:text-red-500"}`,children:[s.jsx(gu,{size:16})," Marcar Falta"]}),s.jsxs("button",{onClick:()=>k(N.id,"Confirmado"),className:`flex items-center justify-center gap-2 py-4 rounded-2xl text-xs font-black uppercase tracking-widest transition-all border-2 ${N.status==="Confirmado"?"bg-emerald-50 text-emerald-600 border-emerald-200":"bg-white border-gray-100 text-gray-500 hover:border-emerald-200 hover:text-emerald-500"}`,children:[s.jsx(da,{size:16})," Confirmar"]})]})]})]}),s.jsx("div",{className:"px-10 py-8 bg-gray-50/50 border-t border-gray-100 flex gap-4",children:s.jsx("button",{onClick:()=>{R(!1),p(!0)},className:"flex-1 py-4 bg-blue-600 text-white rounded-2xl text-xs font-black uppercase tracking-widest hover:bg-blue-700 hover:shadow-xl hover:shadow-blue-200 transition-all shadow-lg shadow-blue-100",children:"Reagendar Consulta"})})]})}),s.jsx("style",{children:` .animate-in { animation: animate-in 0.2s ease-out; } @keyframes animate-in { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } } .custom-scrollbar::-webkit-scrollbar { width: 4px; } .custom-scrollbar::-webkit-scrollbar-track { background: #f1f1f1; } .custom-scrollbar::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; } `}),s.jsx(CP,{isOpen:h,onClose:()=>{p(!1),S(null)},onSave:B,dentists:n,initialDate:m==null?void 0:m.dateStr,initialAppointment:N}),s.jsx(AP,{isOpen:b,onClose:()=>y(!1),dentists:n})]})};function sA(t){if(!t)return null;const e=new Date(t),n=new Date;let r=n.getFullYear()-e.getFullYear();const i=n.getMonth()-e.getMonth();return(i<0||i===0&&n.getDate(){var r;const e=sA(t.dataNascimento),n=OP(e);return s.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl p-5 shadow-sm",children:[s.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center lg:justify-between gap-4",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"w-14 h-14 bg-purple-100 text-purple-600 rounded-full flex items-center justify-center font-bold text-lg flex-shrink-0",children:t.pacienteNome.substring(0,2)}),s.jsxs("div",{children:[s.jsxs("h2",{className:"text-xl font-bold text-gray-900 uppercase",children:[t.pacienteNome," ",e!==null&&s.jsxs("span",{className:"text-gray-500 font-normal",children:["— ",e," ANOS"]})]}),s.jsxs("div",{className:"flex flex-wrap gap-2 mt-1",children:[n&&s.jsx("span",{className:"text-[10px] font-bold bg-purple-100 text-purple-700 px-2 py-0.5 rounded-full uppercase",children:n}),s.jsx("span",{className:"text-[10px] font-bold bg-gray-100 text-gray-600 px-2 py-0.5 rounded-full uppercase",children:t.classificacao||((r=t.diagnostico)==null?void 0:r.classeAngle)}),s.jsxs("span",{className:"text-[10px] font-bold bg-blue-100 text-blue-600 px-2 py-0.5 rounded-full uppercase",children:["FASE: ",t.faseAtual]}),s.jsxs("span",{className:"text-[10px] font-bold bg-gray-100 text-gray-600 px-2 py-0.5 rounded-full uppercase",children:["FIO ",t.fioAtual]}),t.cooperacao&&s.jsxs("span",{className:`text-[10px] font-bold px-2 py-0.5 rounded-full uppercase ${Im[t.cooperacao]||""}`,children:["COOPERAÇÃO ",t.cooperacao.toUpperCase()]})]})]})]}),s.jsxs("div",{className:"flex flex-wrap gap-4 text-xs uppercase font-bold text-gray-500",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(Et,{size:14})," ÚLTIMA: ",t.ultimaConsulta?new Date(t.ultimaConsulta).toLocaleDateString():"—"]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(Et,{size:14,className:"text-blue-500"})," PRÓX: ",t.proximaConsulta?new Date(t.proximaConsulta).toLocaleDateString():"—"]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(Fl,{size:14})," ",t.mesesRestantes??"?"," MESES RESTANTES"]})]})]}),t.percentualConcluido!=null&&s.jsxs("div",{className:"mt-4",children:[s.jsxs("div",{className:"flex justify-between text-[10px] font-bold text-gray-500 uppercase mb-1",children:[s.jsx("span",{children:"PROGRESSO DO TRATAMENTO"}),s.jsxs("span",{children:[t.percentualConcluido,"%"]})]}),s.jsx("div",{className:"w-full bg-gray-100 rounded-full h-2.5",children:s.jsx("div",{className:"bg-blue-500 h-2.5 rounded-full transition-all duration-500",style:{width:`${t.percentualConcluido}%`}})})]}),t.flags&&t.flags.length>0&&s.jsx("div",{className:"flex flex-wrap gap-2 mt-3",children:t.flags.map((i,c)=>{const d=uu[i.tipo]||uu.info;return s.jsxs("div",{className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg border text-xs font-bold uppercase ${d.bg} ${d.text}`,children:[d.icon," ",i.mensagem]},c)})}),t.responsavel&&s.jsxs("p",{className:"mt-2 text-[10px] text-gray-400 font-bold uppercase",children:["RESPONSÁVEL: ",t.responsavel]})]})},kP=({t})=>{const[e,n]=w.useState(!1),r=t.triagem;if(!r)return null;const i=sA(t.dataNascimento),c=i!==null&&i>=18;return s.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl shadow-sm overflow-hidden",children:[s.jsxs("button",{onClick:()=>n(!e),className:"w-full px-5 py-3 flex justify-between items-center bg-gray-50 hover:bg-gray-100 transition-colors",children:[s.jsxs("h3",{className:"font-bold text-gray-700 uppercase text-sm flex items-center gap-2",children:[s.jsx(ua,{size:16,className:"text-purple-500"})," TRIAGEM CLÍNICA"]}),e?s.jsx(Dg,{size:18,className:"text-gray-400"}):s.jsx(_o,{size:18,className:"text-gray-400"})]}),e&&s.jsxs("div",{className:"p-5 grid grid-cols-1 md:grid-cols-2 gap-4 text-sm animate-in fade-in",children:[s.jsx(xt,{label:"QUEIXA PRINCIPAL",value:r.queixaPrincipal}),s.jsx(xt,{label:"HISTÓRICO MÉDICO",value:r.historicoMedico}),s.jsx(xt,{label:"MEDICAÇÃO",value:r.medicacao}),s.jsx(xt,{label:"ALERGIAS",value:r.alergias}),s.jsx(xt,{label:"RESPIRAÇÃO BUCAL",value:r.respiracaoBucal?"SIM":"NÃO"}),s.jsx(xt,{label:"HÁBITOS",value:r.habitos}),c&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"col-span-full border-t pt-3 mt-1",children:s.jsx("span",{className:"text-[10px] font-bold text-purple-500 uppercase",children:"CAMPOS ADULTO"})}),s.jsx(xt,{label:"PERIODONTO",value:r.periodonto}),s.jsx(xt,{label:"IMPLANTES",value:r.implantes}),s.jsx(xt,{label:"RECESSÕES",value:r.recessoes}),s.jsx(xt,{label:"MOBILIDADE",value:r.mobilidade})]})]})]})},_P=({t})=>{const[e,n]=w.useState(!1),r=t.diagnostico;return r?s.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl shadow-sm overflow-hidden",children:[s.jsxs("button",{onClick:()=>n(!e),className:"w-full px-5 py-3 flex justify-between items-center bg-gray-50 hover:bg-gray-100 transition-colors",children:[s.jsxs("h3",{className:"font-bold text-gray-700 uppercase text-sm flex items-center gap-2",children:[s.jsx(za,{size:16,className:"text-blue-500"})," DIAGNÓSTICO ORTODÔNTICO"]}),e?s.jsx(Dg,{size:18,className:"text-gray-400"}):s.jsx(_o,{size:18,className:"text-gray-400"})]}),e&&s.jsxs("div",{className:"p-5 grid grid-cols-2 md:grid-cols-3 gap-4 text-sm animate-in fade-in",children:[s.jsx(xt,{label:"CLASSE ANGLE",value:r.classeAngle,highlight:!0}),s.jsx(xt,{label:"PERFIL",value:r.perfil}),s.jsx(xt,{label:"APINHAMENTO",value:r.apinhamento,highlight:r.apinhamento==="Severo"}),s.jsx(xt,{label:"MORDIDA",value:r.mordida}),s.jsx(xt,{label:"LINHA MÉDIA",value:r.linhaMedia})]})]}):null},MP=({t})=>{const[e,n]=w.useState(!0);return s.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl shadow-sm overflow-hidden",children:[s.jsxs("button",{onClick:()=>n(!e),className:"w-full px-5 py-3 flex justify-between items-center bg-gray-50 hover:bg-gray-100 transition-colors",children:[s.jsxs("h3",{className:"font-bold text-gray-700 uppercase text-sm flex items-center gap-2",children:[s.jsx(hD,{size:16,className:"text-pink-500"})," PLANO DE TRATAMENTO"]}),e?s.jsx(Dg,{size:18,className:"text-gray-400"}):s.jsx(_o,{size:18,className:"text-gray-400"})]}),e&&s.jsxs("div",{className:"p-5 space-y-3 text-sm animate-in fade-in",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[s.jsx(xt,{label:"APARELHO",value:t.tipoAparelho,highlight:!0}),s.jsx(xt,{label:"EXTRAÇÕES",value:t.extracoes}),s.jsx(xt,{label:"ELÁSTICOS",value:t.elasticos}),s.jsx(xt,{label:"IPR PLANEJADO",value:t.iprPlanejado}),s.jsx(xt,{label:"TEMPO ESTIMADO",value:t.tempoEstimado}),t.valor!=null&&s.jsx(xt,{label:"VALOR",value:`R$ ${t.valor.toLocaleString("pt-BR",{minimumFractionDigits:2})}`}),t.formaPagamento&&s.jsx(xt,{label:"PAGAMENTO",value:t.formaPagamento})]}),t.sequenciaFios&&s.jsxs("div",{className:"bg-gray-50 rounded-lg p-3 border border-gray-100 mt-2",children:[s.jsx("span",{className:"text-[10px] font-bold text-gray-400 uppercase",children:"SEQUÊNCIA DE FIOS"}),s.jsx("p",{className:"font-bold text-gray-800 mt-1 tracking-wide",children:t.sequenciaFios})]})]})]})},IP=({evolucoes:t})=>{const e=[...t].sort((n,r)=>new Date(r.data).getTime()-new Date(n.data).getTime());return s.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl shadow-sm p-5",children:[s.jsxs("h3",{className:"font-bold text-gray-700 uppercase text-sm flex items-center gap-2 mb-4",children:[s.jsx(Vl,{size:16,className:"text-blue-500"})," LINHA DO TEMPO — ",t.length," EVENTO",t.length!==1&&"S"]}),s.jsx("div",{className:"space-y-4 relative before:absolute before:left-[7px] before:top-2 before:bottom-2 before:w-0.5 before:bg-gray-200",children:e.map(n=>{var r;return s.jsxs("div",{className:"relative pl-7",children:[s.jsx("div",{className:`absolute left-0 top-1.5 w-3.5 h-3.5 rounded-full z-10 border-2 ${n.tipo==="Falta"?"bg-red-500 border-red-300":n.tipo==="Colagem"?"bg-green-500 border-green-300":"bg-white border-blue-500"}`}),s.jsxs("div",{className:"bg-gray-50 rounded-lg p-3 border border-gray-100",children:[s.jsxs("div",{className:"flex flex-wrap justify-between items-start gap-2 mb-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-bold text-gray-900 text-sm",children:new Date(n.data).toLocaleDateString()}),s.jsx("span",{className:"text-[9px] font-bold bg-gray-200 text-gray-600 px-2 py-0.5 rounded-full uppercase",children:n.tipo})]}),s.jsxs("span",{className:"text-[10px] text-blue-600 flex items-center gap-1 font-bold uppercase",children:["PRÓX: ",new Date(n.proximoRetorno).toLocaleDateString()," ",s.jsx(Ls,{size:10})]})]}),s.jsx("p",{className:"text-xs text-gray-700 uppercase font-medium",children:n.procedimento}),s.jsxs("div",{className:"flex flex-wrap gap-2 mt-2",children:[n.fio&&s.jsxs("span",{className:"text-[9px] font-bold bg-blue-50 text-blue-600 px-2 py-0.5 rounded-full uppercase",children:["FIO: ",n.fio]}),n.elastico&&s.jsxs("span",{className:"text-[9px] font-bold bg-purple-50 text-purple-600 px-2 py-0.5 rounded-full uppercase",children:["ELÁSTICO: ",n.elastico]}),(r=n.procedimentos)==null?void 0:r.map((i,c)=>s.jsx("span",{className:"text-[9px] font-bold bg-green-50 text-green-600 px-2 py-0.5 rounded-full uppercase",children:i},c)),n.higiene!=null&&s.jsxs("span",{className:`text-[9px] font-bold px-2 py-0.5 rounded-full uppercase ${n.higiene>=7?"bg-green-50 text-green-600":n.higiene>=5?"bg-amber-50 text-amber-600":"bg-red-50 text-red-600"}`,children:["HIGIENE: ",n.higiene,"/10"]}),n.cooperacao&&s.jsxs("span",{className:`text-[9px] font-bold px-2 py-0.5 rounded-full uppercase ${Im[n.cooperacao]||""}`,children:["COOP: ",n.cooperacao.toUpperCase()]})]}),n.observacoes&&s.jsx("p",{className:"text-[10px] text-gray-500 mt-2 italic uppercase",children:n.observacoes})]})]},n.id)})})]})},LP=({tratamentoId:t,currentFio:e,onSaved:n})=>{const r=Fe(),[i,c]=w.useState("Manutenção"),[d,f]=w.useState(e||""),[h,p]=w.useState(""),[b,y]=w.useState([]),[m,v]=w.useState(7),[N,S]=w.useState("Boa"),[j,R]=w.useState(""),[C,O]=w.useState(""),A=_=>{y(B=>B.includes(_)?B.filter(F=>F!==_):[...B,_])},k=async()=>{const _=[i,d&&`FIO ${d}`,h&&`ELÁSTICO ${h}`,...b].filter(Boolean).join(" + ");try{await J.saveEvolucaoOrto(t,{tipo:i,procedimento:_.toUpperCase(),proximoRetorno:C,fio:d||void 0,elastico:h||void 0,procedimentos:b.length>0?b:void 0,higiene:m,cooperacao:N,observacoes:j.toUpperCase()||void 0}),r.success("EVOLUÇÃO SALVA COM SUCESSO!"),c("Manutenção"),p(""),y([]),v(7),S("Boa"),R(""),O(""),n()}catch{r.error("ERRO AO SALVAR EVOLUÇÃO.")}};return s.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl shadow-sm p-5",children:[s.jsxs("h3",{className:"font-bold text-gray-700 uppercase text-sm flex items-center gap-2 mb-4",children:[s.jsx(ft,{size:16,className:"text-green-500"})," NOVA EVOLUÇÃO"]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] font-bold text-gray-400 uppercase",children:"TIPO EVENTO"}),s.jsxs("select",{value:i,onChange:_=>c(_.target.value),className:"w-full border border-gray-300 rounded-lg p-2.5 bg-white uppercase-select mt-1",children:[s.jsx("option",{children:"Manutenção"}),s.jsx("option",{children:"Troca de fio"}),s.jsx("option",{children:"Colagem"}),s.jsx("option",{children:"Emergência"}),s.jsx("option",{children:"Falta"}),s.jsx("option",{children:"Finalização"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] font-bold text-gray-400 uppercase",children:"FIO"}),s.jsxs("select",{value:d,onChange:_=>f(_.target.value),className:"w-full border border-gray-300 rounded-lg p-2.5 bg-white uppercase-select mt-1",children:[s.jsx("option",{value:"",children:"— MANTER ATUAL —"}),s.jsx("option",{children:"0.12"}),s.jsx("option",{children:"0.14"}),s.jsx("option",{children:"0.16"}),s.jsx("option",{children:"0.18"}),s.jsx("option",{children:"0.20x0.25"}),s.jsx("option",{children:"0.19x0.25"}),s.jsx("option",{children:"0.21x0.25"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] font-bold text-gray-400 uppercase",children:"ELÁSTICO"}),s.jsxs("select",{value:h,onChange:_=>p(_.target.value),className:"w-full border border-gray-300 rounded-lg p-2.5 bg-white uppercase-select mt-1",children:[s.jsx("option",{value:"",children:"— NENHUM —"}),s.jsx("option",{children:"CLASSE II"}),s.jsx("option",{children:"CLASSE III"}),s.jsx("option",{children:"VERTICAL"}),s.jsx("option",{children:"CRUZADO"})]})]})]}),s.jsxs("div",{className:"mt-4",children:[s.jsx("label",{className:"text-[10px] font-bold text-gray-400 uppercase",children:"PROCEDIMENTOS REALIZADOS"}),s.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:RP.map(_=>s.jsxs("button",{type:"button",onClick:()=>A(_.label),className:`flex items-center gap-1.5 px-3 py-2 rounded-lg text-xs font-bold uppercase border transition-all ${b.includes(_.label)?"bg-green-600 text-white border-green-600 shadow-sm":"bg-white text-gray-600 border-gray-300 hover:border-green-400 hover:bg-green-50"}`,children:[_.icon," ",_.label]},_.label))})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mt-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] font-bold text-gray-400 uppercase",children:"HIGIENE (1–10)"}),s.jsx("input",{type:"range",min:1,max:10,value:m,onChange:_=>v(Number(_.target.value)),className:"w-full mt-2"}),s.jsxs("div",{className:"text-center font-bold text-lg mt-1",children:[m,s.jsx("span",{className:"text-gray-400 text-xs",children:"/10"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] font-bold text-gray-400 uppercase",children:"COOPERAÇÃO"}),s.jsxs("select",{value:N,onChange:_=>S(_.target.value),className:"w-full border border-gray-300 rounded-lg p-2.5 bg-white uppercase-select mt-1",children:[s.jsx("option",{children:"Boa"}),s.jsx("option",{children:"Média"}),s.jsx("option",{children:"Ruim"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] font-bold text-gray-400 uppercase",children:"PRÓXIMO RETORNO"}),s.jsx("input",{type:"date",value:C,onChange:_=>O(_.target.value),className:"w-full border border-gray-300 rounded-lg p-2.5 bg-white mt-1"})]})]}),s.jsxs("div",{className:"mt-4",children:[s.jsx("label",{className:"text-[10px] font-bold text-gray-400 uppercase",children:"OBSERVAÇÕES CLÍNICAS"}),s.jsx("textarea",{value:j,onChange:_=>R(_.target.value.toUpperCase()),placeholder:"ANOTAÇÕES LIVRES...",className:"w-full border border-gray-300 rounded-lg p-3 mt-1 h-20 uppercase-textarea text-sm"})]}),s.jsxs("button",{onClick:k,className:"mt-4 w-full bg-green-600 hover:bg-green-700 text-white py-3 rounded-lg font-bold uppercase text-sm transition-colors shadow-sm flex items-center justify-center gap-2",children:[s.jsx(Ua,{size:16})," SALVAR EVOLUÇÃO"]})]})},zP=({t})=>{var e,n,r,i;return s.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl shadow-sm p-5",children:[s.jsxs("h3",{className:"font-bold text-gray-700 uppercase text-sm flex items-center gap-2 mb-4",children:[s.jsx(Ad,{size:16,className:"text-indigo-500"})," COMPARATIVO FOTOGRÁFICO"]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"border-2 border-dashed border-gray-200 rounded-xl p-8 flex flex-col items-center justify-center text-center bg-gray-50 min-h-[160px]",children:[s.jsx(Ad,{size:32,className:"text-gray-300 mb-2"}),s.jsx("span",{className:"text-xs font-bold text-gray-400 uppercase",children:"INÍCIO"}),((n=(e=t.fotos)==null?void 0:e.find(c=>c.tipo==="inicio"))==null?void 0:n.data)&&s.jsx("span",{className:"text-[10px] text-gray-400 mt-1",children:new Date(t.fotos.find(c=>c.tipo==="inicio").data).toLocaleDateString()})]}),s.jsxs("div",{className:"border-2 border-dashed border-gray-200 rounded-xl p-8 flex flex-col items-center justify-center text-center bg-gray-50 min-h-[160px]",children:[s.jsx(Ad,{size:32,className:"text-gray-300 mb-2"}),s.jsx("span",{className:"text-xs font-bold text-gray-400 uppercase",children:"ATUAL"}),((i=(r=t.fotos)==null?void 0:r.find(c=>c.tipo==="atual"))==null?void 0:i.data)&&s.jsx("span",{className:"text-[10px] text-gray-400 mt-1",children:new Date(t.fotos.find(c=>c.tipo==="atual").data).toLocaleDateString()})]})]}),s.jsxs("button",{className:"mt-4 w-full border-2 border-dashed border-gray-300 hover:border-blue-400 hover:bg-blue-50 py-3 rounded-lg text-xs font-bold text-gray-500 hover:text-blue-600 uppercase transition-colors flex items-center justify-center gap-2",children:[s.jsx(SO,{size:16})," UPLOAD FOTOS"]})]})},PP=({t,onFinalize:e})=>{const n=Fe(),[r,i]=w.useState({alinhamento:!1,oclusao:!1,raizes:!1,estetica:!1}),[c,d]=w.useState("CONTENÇÃO FIXA INFERIOR"),[f,h]=w.useState(!1),[p,b]=w.useState(!0),[y,m]=w.useState("PERMANENTE"),v=Object.values(r).every(Boolean),N=async()=>{if(!v){n.error("PREENCHA TODOS OS CRITÉRIOS DO CHECKLIST.");return}try{await J.finalizarTratamentoOrto(t.id,{tipo:c,superior:f,inferior:p,tempoUso:y}),n.success("TRATAMENTO FINALIZADO COM SUCESSO!"),e()}catch{n.error("ERRO AO FINALIZAR TRATAMENTO.")}};return t.status==="Finalizado"?s.jsxs("div",{className:"bg-green-50 border border-green-200 rounded-xl p-5 text-center",children:[s.jsx(Ua,{size:32,className:"text-green-500 mx-auto mb-2"}),s.jsx("h3",{className:"font-bold text-green-700 uppercase",children:"TRATAMENTO FINALIZADO"}),t.contencaoTipo&&s.jsxs("p",{className:"text-xs text-green-600 mt-1 uppercase",children:["CONTENÇÃO: ",t.contencaoTipo]})]}):s.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl shadow-sm p-5",children:[s.jsxs("h3",{className:"font-bold text-gray-700 uppercase text-sm flex items-center gap-2 mb-4",children:[s.jsx(Sr,{size:16,className:"text-green-500"})," FINALIZAÇÃO E CONTENÇÃO"]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-[10px] font-bold text-gray-400 uppercase",children:"CHECKLIST OBRIGATÓRIO"}),s.jsx("div",{className:"space-y-2 mt-2",children:Object.entries({alinhamento:"ALINHAMENTO OK",oclusao:"OCLUSÃO OK",raizes:"RAÍZES PARALELAS",estetica:"ESTÉTICA ACEITA"}).map(([S,j])=>s.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:r[S],onChange:()=>i(R=>({...R,[S]:!R[S]})),className:"w-4 h-4 rounded border-gray-300 text-green-600"}),s.jsx("span",{className:"font-bold uppercase text-gray-700",children:j})]},S))})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] font-bold text-gray-400 uppercase",children:"TIPO CONTENÇÃO"}),s.jsxs("select",{value:c,onChange:S=>d(S.target.value),className:"w-full border border-gray-300 rounded-lg p-2.5 bg-white uppercase-select mt-1 text-sm",children:[s.jsx("option",{children:"CONTENÇÃO FIXA INFERIOR"}),s.jsx("option",{children:"CONTENÇÃO FIXA SUPERIOR E INFERIOR"}),s.jsx("option",{children:"PLACA DE CONTENÇÃO REMOVÍVEL"}),s.jsx("option",{children:"ESSIX (ALINHADOR)"})]})]}),s.jsxs("div",{className:"flex gap-4",children:[s.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:f,onChange:()=>h(!f),className:"w-4 h-4 rounded"}),s.jsx("span",{className:"font-bold uppercase text-gray-700",children:"SUPERIOR"})]}),s.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:p,onChange:()=>b(!p),className:"w-4 h-4 rounded"}),s.jsx("span",{className:"font-bold uppercase text-gray-700",children:"INFERIOR"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] font-bold text-gray-400 uppercase",children:"TEMPO DE USO"}),s.jsxs("select",{value:y,onChange:S=>m(S.target.value),className:"w-full border border-gray-300 rounded-lg p-2.5 bg-white uppercase-select mt-1 text-sm",children:[s.jsx("option",{children:"PERMANENTE"}),s.jsx("option",{children:"6 MESES"}),s.jsx("option",{children:"12 MESES"}),s.jsx("option",{children:"24 MESES"})]})]})]})]}),s.jsxs("button",{onClick:N,disabled:!v,className:`mt-5 w-full py-3 rounded-lg font-bold uppercase text-sm transition-colors flex items-center justify-center gap-2 ${v?"bg-green-600 hover:bg-green-700 text-white shadow-sm":"bg-gray-200 text-gray-400 cursor-not-allowed"}`,children:[s.jsx(Ua,{size:16})," FINALIZAR TRATAMENTO"]})]})},UP=({t})=>{Fe();const[e,n]=w.useState(350),[r,i]=w.useState(!1);return s.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl shadow-sm p-5",children:[s.jsxs("h3",{className:"font-bold text-gray-700 uppercase text-sm flex items-center gap-2 mb-4",children:[s.jsx(PN,{size:16,className:"text-orange-500"})," CONTENÇÃO — TERMO E VALOR"]}),s.jsx("div",{className:"bg-amber-50 border border-amber-200 rounded-lg p-4 mb-4",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(gu,{size:18,className:"text-amber-600 flex-shrink-0 mt-0.5"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-bold text-amber-700 uppercase mb-1",children:"TERMO DE CIÊNCIA"}),s.jsxs("p",{className:"text-xs text-amber-800 leading-relaxed",children:["O PACIENTE DECLARA ESTAR CIENTE DE QUE A ",s.jsx("strong",{children:"CONTENÇÃO ORTODÔNTICA"})," (FIXA E/OU REMOVÍVEL) É UM PROCEDIMENTO ",s.jsx("strong",{children:"SEPARADO DO TRATAMENTO ORTODÔNTICO"})," E ",s.jsx("strong",{children:"NÃO ESTÁ INCLUÍDA NO VALOR DA MANUTENÇÃO MENSAL"}),". O CUSTO DA CONTENÇÃO SERÁ COBRADO À PARTE, CONFORME VALORES ABAIXO INFORMADOS."]})]})]})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] font-bold text-gray-400 uppercase",children:"VALOR DA CONTENÇÃO (R$)"}),s.jsx("input",{type:"number",value:e,onChange:c=>n(Number(c.target.value)),className:"w-full border border-gray-300 rounded-lg p-2.5 bg-white mt-1 text-sm font-bold",min:0,step:50}),s.jsx("p",{className:"text-[10px] text-gray-400 mt-1",children:"VALOR COBRADO SEPARADAMENTE DA MENSALIDADE"})]}),s.jsx("div",{className:"flex flex-col justify-end",children:s.jsxs("label",{className:"flex items-start gap-2 cursor-pointer bg-gray-50 border border-gray-200 rounded-lg p-3",children:[s.jsx("input",{type:"checkbox",checked:r,onChange:()=>i(!r),className:"w-4 h-4 rounded border-gray-300 text-orange-600 mt-0.5"}),s.jsx("span",{className:"text-xs font-bold uppercase text-gray-700 leading-relaxed",children:"PACIENTE CIENTE E DE ACORDO COM A COBRANÇA SEPARADA DA CONTENÇÃO"})]})})]}),r&&s.jsxs("div",{className:"mt-3 bg-green-50 border border-green-200 rounded-lg p-3 flex items-center gap-2",children:[s.jsx(Ua,{size:16,className:"text-green-500"}),s.jsxs("span",{className:"text-xs font-bold text-green-700 uppercase",children:["TERMO ACEITO — R$ ",e.toLocaleString("pt-BR",{minimumFractionDigits:2})]})]})]})},BP=({t})=>{const e=Fe(),[n,r]=w.useState([]),[i,c]=w.useState("LIMPEZA / PROFILAXIA"),[d,f]=w.useState(""),[h,p]=w.useState(""),b=["LIMPEZA / PROFILAXIA","DENTE COM CÁRIE","DENTE PARA EXTRAIR","RASPAGEM PERIODONTAL"],y=()=>{r(v=>[...v,{tipo:i,dente:d.toUpperCase()||void 0,obs:h.toUpperCase()||void 0}]),f(""),p(""),e.success("SOLICITAÇÃO ADICIONADA!")},m=v=>{r(N=>N.filter((S,j)=>j!==v))};return s.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl shadow-sm p-5",children:[s.jsxs("h3",{className:"font-bold text-gray-700 uppercase text-sm flex items-center gap-2 mb-4",children:[s.jsx(ua,{size:16,className:"text-red-500"})," SOLICITAÇÕES CLÍNICAS"]}),n.length>0&&s.jsx("div",{className:"space-y-2 mb-4",children:n.map((v,N)=>s.jsxs("div",{className:"flex items-center justify-between bg-gray-50 border border-gray-200 rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${v.tipo.includes("CÁRIE")?"bg-red-500":v.tipo.includes("EXTRAIR")?"bg-orange-500":v.tipo.includes("RASPAGEM")?"bg-purple-500":"bg-blue-500"}`}),s.jsxs("div",{children:[s.jsx("span",{className:"text-xs font-bold text-gray-800 uppercase",children:v.tipo}),v.dente&&s.jsxs("span",{className:"text-[10px] text-gray-500 ml-2",children:["DENTE: ",v.dente]}),v.obs&&s.jsx("p",{className:"text-[10px] text-gray-400 italic",children:v.obs})]})]}),s.jsx("button",{onClick:()=>m(N),className:"text-gray-400 hover:text-red-500 transition-colors",children:s.jsx(Qe,{size:16})})]},N))}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] font-bold text-gray-400 uppercase",children:"TIPO"}),s.jsx("select",{value:i,onChange:v=>c(v.target.value),className:"w-full border border-gray-300 rounded-lg p-2.5 bg-white mt-1 text-sm",children:b.map(v=>s.jsx("option",{children:v},v))})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] font-bold text-gray-400 uppercase",children:"DENTE (OPCIONAL)"}),s.jsx("input",{type:"text",value:d,onChange:v=>f(v.target.value),placeholder:"EX: 36, 14",className:"w-full border border-gray-300 rounded-lg p-2.5 bg-white mt-1 text-sm uppercase"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] font-bold text-gray-400 uppercase",children:"OBSERVAÇÃO"}),s.jsx("input",{type:"text",value:h,onChange:v=>p(v.target.value),placeholder:"DETALHES...",className:"w-full border border-gray-300 rounded-lg p-2.5 bg-white mt-1 text-sm uppercase"})]})]}),s.jsxs("button",{onClick:y,className:"mt-3 w-full border-2 border-dashed border-gray-300 hover:border-blue-400 hover:bg-blue-50 py-2.5 rounded-lg text-xs font-bold text-gray-500 hover:text-blue-600 uppercase transition-colors flex items-center justify-center gap-2",children:[s.jsx(ft,{size:14})," ADICIONAR SOLICITAÇÃO"]})]})},HP=({t})=>{const e=Fe(),n=()=>{const c=[...t.evolucoes].sort((f,h)=>new Date(f.data).getTime()-new Date(h.data).getTime()),d=["════════════════════════════════════════════════════════"," RELATÓRIO DE MANUTENÇÕES ORTODÔNTICAS","════════════════════════════════════════════════════════","",`PACIENTE: ${t.pacienteNome}`,`APARELHO: ${t.tipoAparelho}`,`INÍCIO: ${new Date(t.dataInicio).toLocaleDateString()}`,`STATUS: ${t.status}`,`FASE ATUAL: ${t.faseAtual||"—"}`,`FIO ATUAL: ${t.fioAtual||"—"}`,`PROGRESSO: ${t.percentualConcluido??"—"}%`,"","────────────────────────────────────────────────────────",` TOTAL DE ATENDIMENTOS: ${c.length}`,"────────────────────────────────────────────────────────",""];return c.forEach((f,h)=>{var p;d.push(` #${h+1} | ${new Date(f.data).toLocaleDateString()} | ${f.tipo}`),d.push(` ${f.procedimento}`),f.fio&&d.push(` FIO: ${f.fio}`),f.elastico&&d.push(` ELÁSTICO: ${f.elastico}`),(p=f.procedimentos)!=null&&p.length&&d.push(` PROC: ${f.procedimentos.join(", ")}`),f.higiene!=null&&d.push(` HIGIENE: ${f.higiene}/10`),f.cooperacao&&d.push(` COOPERAÇÃO: ${f.cooperacao}`),f.observacoes&&d.push(` OBS: ${f.observacoes}`),d.push(` PRÓXIMO RETORNO: ${new Date(f.proximoRetorno).toLocaleDateString()}`),d.push("")}),d.push("────────────────────────────────────────────────────────"),d.push(` GERADO EM: ${new Date().toLocaleString()}`),d.push(" SCOREODONTO — GESTÃO ORTODÔNTICA"),d.push("════════════════════════════════════════════════════════"),d.join(` `)},r=()=>{const c=n(),d=new Blob([c],{type:"text/plain;charset=utf-8"}),f=URL.createObjectURL(d),h=document.createElement("a");h.href=f,h.download=`RELATORIO_ORTO_${t.pacienteNome.replace(/\s+/g,"_")}_${new Date().toISOString().split("T")[0]}.txt`,document.body.appendChild(h),h.click(),document.body.removeChild(h),URL.revokeObjectURL(f),e.success("RELATÓRIO EXPORTADO COM SUCESSO!")},i=()=>{const c=n();navigator.clipboard.writeText(c).then(()=>{e.success("RELATÓRIO COPIADO PARA ÁREA DE TRANSFERÊNCIA!")})};return s.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl shadow-sm p-5",children:[s.jsxs("h3",{className:"font-bold text-gray-700 uppercase text-sm flex items-center gap-2 mb-4",children:[s.jsx(Jy,{size:16,className:"text-teal-500"})," RELATÓRIO DE MANUTENÇÕES"]}),s.jsx("div",{className:"bg-gray-50 border border-gray-200 rounded-lg p-4 mb-4",children:s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 text-center",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-gray-800",children:t.evolucoes.length}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase",children:"ATENDIMENTOS"})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-gray-800",children:new Date(t.dataInicio).toLocaleDateString()}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase",children:"INÍCIO"})]}),s.jsxs("div",{children:[s.jsxs("p",{className:"text-2xl font-bold text-gray-800",children:[t.percentualConcluido??"—","%"]}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase",children:"PROGRESSO"})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-gray-800",children:t.mesesRestantes??"—"}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase",children:"MESES REST."})]})]})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[s.jsxs("button",{onClick:r,className:"bg-teal-600 hover:bg-teal-700 text-white py-3 rounded-lg font-bold uppercase text-sm transition-colors shadow-sm flex items-center justify-center gap-2",children:[s.jsx(Jy,{size:16})," EXPORTAR RELATÓRIO (.TXT)"]}),s.jsxs("button",{onClick:i,className:"bg-gray-600 hover:bg-gray-700 text-white py-3 rounded-lg font-bold uppercase text-sm transition-colors shadow-sm flex items-center justify-center gap-2",children:[s.jsx(PN,{size:16})," COPIAR PARA ÁREA DE TRANSFERÊNCIA"]})]})]})},xt=({label:t,value:e,highlight:n})=>s.jsxs("div",{children:[s.jsx("span",{className:"text-[10px] font-bold text-gray-400 uppercase",children:t}),s.jsx("p",{className:`font-bold uppercase mt-0.5 ${n?"text-blue-600":"text-gray-800"}`,children:e||"—"})]}),GP=({treatment:t,onClose:e})=>{const[n,r]=w.useState(t),{refresh:i}=_e(J.getOrtoTreatments),c=w.useCallback(()=>{J.getOrtoTreatments().then(d=>{const f=d.find(h=>h.id===n.id);f&&r(f)})},[n.id]);return w.useEffect(()=>{const d=f=>{f.key==="Escape"&&e()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[e]),s.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center backdrop-blur-sm p-0",children:s.jsxs("div",{className:"bg-gray-50 shadow-2xl w-full h-dvh md:w-[96vw] md:h-[98vh] rounded-none md:rounded-xl flex flex-col overflow-hidden animate-in fade-in zoom-in-50 duration-200",children:[s.jsxs("div",{className:"px-5 py-3 border-b border-gray-200 flex justify-between items-center flex-shrink-0 bg-white",children:[s.jsxs("button",{onClick:e,className:"flex items-center gap-2 text-gray-500 hover:text-gray-800 text-xs font-bold uppercase transition-colors",children:[s.jsx(MN,{size:16})," VOLTAR À LISTA"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`px-3 py-1 rounded-full text-[10px] font-bold uppercase ${n.status==="Finalizado"?"bg-green-100 text-green-700":n.status==="Contenção"?"bg-blue-100 text-blue-700":"bg-amber-100 text-amber-700"}`,children:n.status}),s.jsx("button",{onClick:e,className:"text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-lg p-1.5 transition-colors",children:s.jsx(Qe,{size:20})})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-4 lg:p-6 space-y-5",children:[s.jsx(TP,{t:n}),s.jsx(kP,{t:n}),s.jsx(_P,{t:n}),s.jsx(MP,{t:n}),s.jsx(IP,{evolucoes:n.evolucoes}),s.jsx(LP,{tratamentoId:n.id,currentFio:n.fioAtual,onSaved:c}),s.jsx(zP,{t:n}),s.jsx(UP,{t:n}),s.jsx(BP,{t:n}),s.jsx(HP,{t:n}),s.jsx(PP,{t:n,onFinalize:()=>{i(),e()}})]})]})})},VP=()=>{const{data:t,refresh:e}=_e(J.getOrtoTreatments),[n,r]=w.useState(null);return s.jsxs("div",{className:"space-y-6",children:[s.jsx(cn,{title:"GESTÃO ORTODÔNTICA",children:s.jsxs("button",{className:"bg-blue-600 text-white px-4 py-2 rounded-lg flex items-center gap-2 hover:bg-blue-700 text-xs font-bold uppercase transition-colors shadow-sm",children:[s.jsx(ft,{size:18})," NOVO TRATAMENTO"]})}),s.jsx("div",{className:"grid grid-cols-1 gap-6",children:t==null?void 0:t.map(i=>s.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl overflow-hidden shadow-sm hover:shadow-md transition-shadow cursor-pointer",onClick:()=>r(i),children:[s.jsxs("div",{className:"p-4 border-b border-gray-100 bg-gray-50 flex justify-between items-center",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 bg-purple-100 text-purple-600 rounded-full flex items-center justify-center font-bold text-sm",children:i.pacienteNome.substring(0,2).toUpperCase()}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-bold text-gray-900 uppercase",children:i.pacienteNome}),s.jsxs("p",{className:"text-[10px] text-gray-500 uppercase font-bold",children:[i.tipoAparelho," • INÍCIO: ",new Date(i.dataInicio).toLocaleDateString(),i.faseAtual&&` • FASE: ${i.faseAtual}`]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[i.percentualConcluido!=null&&s.jsxs("div",{className:"hidden md:flex items-center gap-2",children:[s.jsx("div",{className:"w-24 bg-gray-200 rounded-full h-1.5",children:s.jsx("div",{className:"bg-blue-500 h-1.5 rounded-full",style:{width:`${i.percentualConcluido}%`}})}),s.jsxs("span",{className:"text-[10px] font-bold text-gray-500",children:[i.percentualConcluido,"%"]})]}),i.cooperacao&&s.jsx("span",{className:`text-[10px] font-bold px-2 py-0.5 rounded-full uppercase hidden lg:inline-block ${Im[i.cooperacao]||""}`,children:i.cooperacao}),s.jsx("span",{className:`px-3 py-1 rounded-full text-[10px] font-bold uppercase ${i.status==="Finalizado"?"bg-green-100 text-green-700":i.status==="Contenção"?"bg-blue-100 text-blue-700":"bg-green-100 text-green-700"}`,children:i.status})]})]}),s.jsxs("div",{className:"p-4",children:[s.jsxs("h4",{className:"text-xs font-bold text-gray-500 mb-3 flex items-center gap-2 uppercase",children:[s.jsx(Vl,{size:14})," ÚLTIMAS EVOLUÇÕES"]}),s.jsx("div",{className:"space-y-2",children:i.evolucoes.slice(-2).map(c=>s.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[s.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full flex-shrink-0"}),s.jsx("span",{className:"font-bold text-gray-700",children:new Date(c.data).toLocaleDateString()}),s.jsx("span",{className:"text-gray-500 truncate uppercase",children:c.procedimento})]},c.id))}),i.flags&&i.flags.length>0&&s.jsx("div",{className:"flex gap-2 mt-3 pt-3 border-t border-gray-100",children:i.flags.map((c,d)=>{const f=uu[c.tipo]||uu.info;return s.jsx("span",{className:`text-[9px] font-bold px-2 py-1 rounded-lg border uppercase ${f.bg} ${f.text}`,children:c.mensagem},d)})})]})]},i.id))}),n&&s.jsx(GP,{treatment:n,onClose:()=>{r(null),e()}})]})};function FP(t,e){const[n,r]=w.useState(t);return w.useEffect(()=>{const i=setTimeout(()=>r(t),e);return()=>clearTimeout(i)},[t,e]),n}const qP=({onClose:t,onSaved:e})=>{const n=Fe(),[r,i]=w.useState(null),[c,d]=w.useState(""),[f,h]=w.useState(!1),p=FP(c,400),[b,y]=w.useState([]),[m,v]=w.useState(!1);w.useEffect(()=>{if(!p){y([]);return}v(!0),J.getPacientes(p).then(C=>{y(C),v(!1)})},[p]);const N=C=>{i(C),d(""),h(!1)},[S,j]=w.useState({id:crypto.randomUUID(),descricao:"",valor:"",dataVencimento:new Date().toISOString().split("T")[0],status:"Pendente",formaPagamento:"Pix"});w.useEffect(()=>{const C=O=>{O.key==="Escape"&&t()};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[t]);const R=async C=>{if(C.preventDefault(),!r||!S.descricao||!S.valor){n.error("PREENCHA TODOS OS CAMPOS OBRIGATÓRIOS.");return}try{await J.saveFinanceiro({...S,pacienteNome:r.nome,valor:parseFloat(S.valor)}),n.success("LANÇAMENTO SALVO COM SUCESSO!"),e(),t()}catch{n.error("ERRO AO SALVAR LANÇAMENTO.")}};return s.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center backdrop-blur-sm p-0",children:s.jsxs("form",{onSubmit:R,className:"bg-white shadow-2xl w-full h-dvh md:w-[96vw] md:h-[98vh] rounded-none md:rounded-xl flex flex-col overflow-hidden animate-in fade-in zoom-in-50 duration-200",children:[s.jsxs("div",{className:"px-5 py-4 border-b border-gray-200 flex justify-between items-center flex-shrink-0 bg-gradient-to-r from-green-50 to-white",children:[s.jsxs("h2",{className:"text-lg font-bold text-gray-800 flex items-center gap-2",children:[s.jsx(Ba,{size:22,className:"text-green-600"})," NOVO LANÇAMENTO"]}),s.jsx("button",{type:"button",onClick:t,className:"text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-lg p-1.5 transition-colors",children:s.jsx(Qe,{size:22})})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-5 lg:p-8",children:[s.jsxs("div",{className:"mb-6",children:[s.jsx("label",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider",children:"PACIENTE *"}),r?s.jsxs("div",{className:"w-full lg:w-1/2 bg-green-50 border border-green-200 p-3 lg:p-4 rounded-lg mt-2 flex justify-between items-center",children:[s.jsx("span",{className:"font-bold text-green-800 uppercase text-sm lg:text-base",children:r.nome}),s.jsx("button",{type:"button",onClick:()=>i(null),className:"text-xs font-bold bg-blue-100 text-blue-700 hover:bg-blue-200 px-3 py-1.5 rounded-md transition-colors",children:"ALTERAR"})]}):s.jsxs("div",{className:"relative mt-2",children:[s.jsx("input",{type:"text",value:c,onChange:C=>d(C.target.value.toUpperCase()),onFocus:()=>h(!0),onBlur:()=>setTimeout(()=>h(!1),200),placeholder:"DIGITE O NOME OU CPF...",className:"w-full lg:w-1/2 bg-gray-100 p-3 lg:p-4 rounded-lg font-bold text-gray-800 uppercase focus:border-blue-500 outline-none border-2 border-transparent focus:border-2 text-sm lg:text-base"}),f&&p&&s.jsxs("ul",{className:"absolute z-10 w-full lg:w-1/2 bg-white border border-gray-300 rounded-lg mt-1 max-h-48 overflow-y-auto shadow-lg",children:[m&&s.jsx("li",{className:"p-3 text-sm text-gray-500",children:"BUSCANDO..."}),b.map(C=>s.jsxs("li",{onMouseDown:()=>N(C),className:"p-3 hover:bg-gray-100 cursor-pointer uppercase font-semibold text-sm",children:[C.nome," (",C.cpf,")"]},C.id)),!m&&b.length===0&&s.jsx("li",{className:"p-3 text-sm text-gray-500",children:"NENHUM PACIENTE ENCONTRADO."})]})]})]}),s.jsxs("div",{className:"lg:grid lg:grid-cols-2 lg:gap-x-8 lg:gap-y-5 space-y-5 lg:space-y-0",children:[s.jsxs("div",{className:"lg:col-span-2",children:[s.jsx("label",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider",children:"DESCRIÇÃO *"}),s.jsx("input",{type:"text",required:!0,value:S.descricao,onChange:C=>j(O=>({...O,descricao:C.target.value.toUpperCase()})),className:"w-full mt-2 border border-gray-300 rounded-lg p-2.5 lg:p-3 uppercase-input text-sm",placeholder:"EX: CONSULTA AVALIAÇÃO, LIMPEZA..."})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider",children:"VALOR (R$) *"}),s.jsx("input",{type:"number",step:"0.01",required:!0,value:S.valor,onChange:C=>j(O=>({...O,valor:C.target.value})),className:"w-full mt-2 border border-gray-300 rounded-lg p-2.5 lg:p-3 text-sm",placeholder:"0,00"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider",children:"DATA VENCIMENTO"}),s.jsx("input",{type:"date",value:S.dataVencimento,onChange:C=>j(O=>({...O,dataVencimento:C.target.value})),className:"w-full mt-2 border border-gray-300 rounded-lg p-2.5 lg:p-3 text-sm"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider",children:"STATUS"}),s.jsxs("select",{value:S.status,onChange:C=>j(O=>({...O,status:C.target.value})),className:"w-full mt-2 border border-gray-300 rounded-lg p-2.5 lg:p-3 bg-white text-sm uppercase-select",children:[s.jsx("option",{value:"Pendente",children:"PENDENTE"}),s.jsx("option",{value:"Pago",children:"PAGO"}),s.jsx("option",{value:"Atrasado",children:"ATRASADO"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider",children:"FORMA DE PAGAMENTO"}),s.jsxs("select",{value:S.formaPagamento,onChange:C=>j(O=>({...O,formaPagamento:C.target.value})),className:"w-full mt-2 border border-gray-300 rounded-lg p-2.5 lg:p-3 bg-white text-sm uppercase-select",children:[s.jsx("option",{value:"Pix",children:"PIX"}),s.jsx("option",{value:"Boleto",children:"BOLETO"}),s.jsx("option",{value:"Cartão",children:"CARTÃO"}),s.jsx("option",{value:"Dinheiro",children:"DINHEIRO"})]})]})]})]}),s.jsxs("div",{className:"px-5 py-4 bg-gray-50 border-t border-gray-200 flex justify-end gap-3 flex-shrink-0",children:[s.jsx("button",{type:"button",onClick:t,className:"px-6 py-2.5 bg-gray-200 hover:bg-gray-300 text-gray-700 font-bold rounded-lg text-sm uppercase transition-colors",children:"CANCELAR"}),s.jsxs("button",{type:"submit",className:"px-8 py-2.5 bg-green-600 hover:bg-green-700 text-white font-bold rounded-lg shadow-sm text-sm uppercase flex items-center gap-2 transition-colors",children:[s.jsx(ft,{size:16})," SALVAR"]})]})]})})},$P=()=>{const[t,e]=w.useState([]),[n,r]=w.useState(!0),[i,c]=w.useState("TODOS"),[d,f]=w.useState(!1),[h,p]=w.useState(!1),b=Fe(),y=w.useCallback(()=>{r(!0),J.getFinanceiro().then(A=>{e(A),r(!1)})},[]);w.useEffect(()=>{y()},[y]);const m=i==="TODOS"?t:t.filter(A=>A.status===i),v=t.filter(A=>A.status==="Pago").reduce((A,k)=>A+Number(k.valor),0),N=t.filter(A=>A.status==="Pendente").reduce((A,k)=>A+Number(k.valor),0),S=t.filter(A=>A.status==="Atrasado").reduce((A,k)=>A+Number(k.valor),0),j=async A=>{if(window.confirm(`CONFIRMAR PAGAMENTO DE R$ ${Number(A.valor).toFixed(2)} DE ${A.pacienteNome}?`))try{await J.updateFinanceiro({...A,status:"Pago"}),b.success(`PAGAMENTO DE ${A.pacienteNome} CONFIRMADO!`),y()}catch{b.error("ERRO AO CONFIRMAR PAGAMENTO.")}},R=async A=>{if(window.confirm(`TEM CERTEZA QUE DESEJA EXCLUIR O LANÇAMENTO DE ${A.pacienteNome}? ESTA AÇÃO NÃO PODE SER DESFEITA.`))try{await J.deleteFinanceiro(A.id),b.success("LANÇAMENTO EXCLUÍDO!"),y()}catch{b.error("ERRO AO EXCLUIR LANÇAMENTO.")}},C=A=>{b.success(`RECIBO DE ${A.pacienteNome} GERADO COM SUCESSO!`)},O=i==="TODOS"?"FILTRAR":i.toUpperCase();return s.jsxs("div",{className:"space-y-6",children:[s.jsx(cn,{title:"FINANCEIRO & FATURAMENTO",children:s.jsxs("div",{className:"flex gap-2 relative",children:[s.jsxs("div",{className:"relative",children:[s.jsxs("button",{onClick:()=>f(!d),className:`border px-3 py-2 rounded-lg flex items-center gap-2 font-bold text-xs uppercase transition-colors ${i!=="TODOS"?"bg-blue-50 border-blue-300 text-blue-700":"bg-white border-gray-300 text-gray-700 hover:bg-gray-50"}`,children:[s.jsx(mu,{size:18})," ",O]}),d&&s.jsx("div",{className:"absolute right-0 top-full mt-1 bg-white border border-gray-200 rounded-lg shadow-xl z-20 min-w-[160px] overflow-hidden",children:["TODOS","Pago","Pendente","Atrasado"].map(A=>s.jsxs("button",{onClick:()=>{c(A),f(!1)},className:`w-full text-left px-4 py-2.5 text-sm font-bold uppercase hover:bg-gray-50 transition-colors flex items-center justify-between ${i===A?"text-blue-700 bg-blue-50":"text-gray-700"}`,children:[A.toUpperCase(),i===A&&s.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-600"})]},A))})]}),s.jsxs("button",{onClick:()=>p(!0),className:"bg-green-600 text-white px-4 py-2 rounded-lg flex items-center gap-2 hover:bg-green-700 font-bold text-xs uppercase shadow-sm transition-colors",children:[s.jsx(ft,{size:18})," NOVO LANÇAMENTO"]})]})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[s.jsxs("div",{className:"bg-white p-6 rounded-xl border border-gray-200 shadow-sm flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-gray-500 font-bold mb-1 uppercase",children:"RECEBIDO (MÊS)"}),s.jsxs("h3",{className:"text-2xl font-bold text-green-600",children:["R$ ",v.toLocaleString("pt-BR",{minimumFractionDigits:2})]})]}),s.jsx("div",{className:"bg-green-100 p-3 rounded-full text-green-600",children:s.jsx(YN,{size:24})})]}),s.jsxs("div",{className:"bg-white p-6 rounded-xl border border-gray-200 shadow-sm flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-gray-500 font-bold mb-1 uppercase",children:"A RECEBER / PENDENTE"}),s.jsxs("h3",{className:"text-2xl font-bold text-yellow-600",children:["R$ ",N.toLocaleString("pt-BR",{minimumFractionDigits:2})]})]}),s.jsx("div",{className:"bg-yellow-100 p-3 rounded-full text-yellow-600",children:s.jsx(Fl,{size:24})})]}),s.jsxs("div",{className:"bg-white p-6 rounded-xl border border-gray-200 shadow-sm flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-gray-500 font-bold mb-1 uppercase",children:"EM ATRASO"}),s.jsxs("h3",{className:"text-2xl font-bold text-red-600",children:["R$ ",S.toLocaleString("pt-BR",{minimumFractionDigits:2})]})]}),s.jsx("div",{className:"bg-red-100 p-3 rounded-full text-red-600",children:s.jsx(yO,{size:24})})]})]}),s.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl shadow-sm overflow-hidden",children:[s.jsxs("div",{className:"p-4 border-b border-gray-200 bg-gray-50 flex justify-between items-center",children:[s.jsxs("h3",{className:"font-bold text-gray-800 uppercase",children:["LANÇAMENTOS ",i!=="TODOS"&&s.jsxs("span",{className:"text-blue-600 text-sm",children:["(",i.toUpperCase(),")"]})]}),s.jsxs("span",{className:"text-xs text-gray-400 font-bold uppercase",children:[m.length," REGISTRO(S)"]})]}),s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm text-left",children:[s.jsx("thead",{className:"bg-gray-50 text-gray-500 uppercase text-xs font-bold",children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-6 py-3",children:"PACIENTE"}),s.jsx("th",{className:"px-6 py-3",children:"DESCRIÇÃO"}),s.jsx("th",{className:"px-6 py-3",children:"VENCIMENTO"}),s.jsx("th",{className:"px-6 py-3",children:"VALOR"}),s.jsx("th",{className:"px-6 py-3",children:"STATUS"}),s.jsx("th",{className:"px-6 py-3 text-right",children:"AÇÕES"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-100",children:n?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"p-6 text-center text-gray-500 uppercase font-bold",children:s.jsxs("div",{className:"flex items-center justify-center gap-2",children:[s.jsx(Ct,{className:"animate-spin",size:18})," CARREGANDO..."]})})}):m.length===0?s.jsx("tr",{children:s.jsxs("td",{colSpan:6,className:"p-10 text-center text-gray-400 uppercase font-bold text-sm",children:["NENHUM LANÇAMENTO ENCONTRADO ",i!=="TODOS"&&`COM STATUS "${i.toUpperCase()}"`,"."]})}):m.map(A=>{var k;return s.jsxs("tr",{className:"hover:bg-gray-50 transition-colors",children:[s.jsx("td",{className:"px-6 py-4 font-bold text-gray-900 uppercase",children:A.pacienteNome}),s.jsxs("td",{className:"px-6 py-4 text-gray-600 font-medium uppercase",children:[A.descricao,s.jsx("span",{className:"text-[10px] text-gray-400 block font-bold",children:(k=A.formaPagamento)==null?void 0:k.toUpperCase()})]}),s.jsx("td",{className:"px-6 py-4 text-gray-600 font-medium",children:new Date(A.dataVencimento).toLocaleDateString("pt-BR")}),s.jsxs("td",{className:"px-6 py-4 font-bold text-gray-800",children:["R$ ",Number(A.valor).toLocaleString("pt-BR",{minimumFractionDigits:2})]}),s.jsx("td",{className:"px-6 py-4",children:s.jsx("span",{className:`px-2.5 py-1 rounded-full text-[10px] font-bold uppercase ${A.status==="Pago"?"bg-green-100 text-green-700":A.status==="Atrasado"?"bg-red-100 text-red-700":"bg-yellow-100 text-yellow-700"}`,children:A.status})}),s.jsx("td",{className:"px-6 py-4 text-right",children:s.jsxs("div",{className:"flex justify-end gap-1",children:[A.status!=="Pago"&&s.jsx("button",{onClick:()=>j(A),title:"CONFIRMAR PAGAMENTO",className:"p-1.5 text-green-600 hover:bg-green-50 rounded-lg transition-colors",children:s.jsx(Ua,{size:18})}),s.jsx("button",{onClick:()=>C(A),title:"GERAR RECIBO",className:"p-1.5 text-blue-600 hover:bg-blue-50 rounded-lg transition-colors",children:s.jsx(Og,{size:18})}),s.jsx("button",{onClick:()=>R(A),title:"EXCLUIR",className:"p-1.5 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded-lg transition-colors",children:s.jsx($t,{size:18})})]})})]},A.id)})})]})})]}),d&&s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>f(!1)}),h&&s.jsx(qP,{onClose:()=>p(!1),onSaved:y})]})};var Vo=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},hr,vs,jl,vN,YP=(vN=class extends Vo{constructor(){super();Ee(this,hr);Ee(this,vs);Ee(this,jl);pe(this,jl,e=>{if(typeof window<"u"&&window.addEventListener){const n=()=>e();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){z(this,vs)||this.setEventListener(z(this,jl))}onUnsubscribe(){var e;this.hasListeners()||((e=z(this,vs))==null||e.call(this),pe(this,vs,void 0))}setEventListener(e){var n;pe(this,jl,e),(n=z(this,vs))==null||n.call(this),pe(this,vs,e(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(e){z(this,hr)!==e&&(pe(this,hr,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(n=>{n(e)})}isFocused(){var e;return typeof z(this,hr)=="boolean"?z(this,hr):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},hr=new WeakMap,vs=new WeakMap,jl=new WeakMap,vN),Lm=new YP,QP={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Ns,wg,NN,WP=(NN=class{constructor(){Ee(this,Ns,QP);Ee(this,wg,!1)}setTimeoutProvider(t){pe(this,Ns,t)}setTimeout(t,e){return z(this,Ns).setTimeout(t,e)}clearTimeout(t){z(this,Ns).clearTimeout(t)}setInterval(t,e){return z(this,Ns).setInterval(t,e)}clearInterval(t){z(this,Ns).clearInterval(t)}},Ns=new WeakMap,wg=new WeakMap,NN),fr=new WP;function XP(t){setTimeout(t,0)}var ZP=typeof window>"u"||"Deno"in globalThis;function ln(){}function KP(t,e){return typeof t=="function"?t(e):t}function ug(t){return typeof t=="number"&&t>=0&&t!==1/0}function rA(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Is(t,e){return typeof t=="function"?t(e):t}function En(t,e){return typeof t=="function"?t(e):t}function K1(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:c,queryKey:d,stale:f}=t;if(d){if(r){if(e.queryHash!==zm(d,e.options))return!1}else if(!jo(e.queryKey,d))return!1}if(n!=="all"){const h=e.isActive();if(n==="active"&&!h||n==="inactive"&&h)return!1}return!(typeof f=="boolean"&&e.isStale()!==f||i&&i!==e.state.fetchStatus||c&&!c(e))}function J1(t,e){const{exact:n,status:r,predicate:i,mutationKey:c}=t;if(c){if(!e.options.mutationKey)return!1;if(n){if(So(e.options.mutationKey)!==So(c))return!1}else if(!jo(e.options.mutationKey,c))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function zm(t,e){return((e==null?void 0:e.queryKeyHashFn)||So)(t)}function So(t){return JSON.stringify(t,(e,n)=>hg(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function jo(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>jo(t[n],e[n])):!1}var JP=Object.prototype.hasOwnProperty;function lA(t,e,n=0){if(t===e)return t;if(n>500)return e;const r=eN(t)&&eN(e);if(!r&&!(hg(t)&&hg(e)))return e;const c=(r?t:Object.keys(t)).length,d=r?e:Object.keys(e),f=d.length,h=r?new Array(f):{};let p=0;for(let b=0;b{fr.setTimeout(e,t)})}function pg(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?lA(t,e):e}function tU(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function nU(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var Pm=Symbol();function iA(t,e){return!t.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!t.queryFn||t.queryFn===Pm?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function oA(t,e){return typeof t=="function"?t(...e):!!t}function aU(t,e,n){let r=!1,i;return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(i??(i=e()),r||(r=!0,i.aborted?n():i.addEventListener("abort",n,{once:!0})),i)}),t}var Ao=(()=>{let t=()=>ZP;return{isServer(){return t()},setIsServer(e){t=e}}})();function gg(){let t,e;const n=new Promise((i,c)=>{t=i,e=c});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),t(i)},n.reject=i=>{r({status:"rejected",reason:i}),e(i)},n}var sU=XP;function rU(){let t=[],e=0,n=f=>{f()},r=f=>{f()},i=sU;const c=f=>{e?t.push(f):i(()=>{n(f)})},d=()=>{const f=t;t=[],f.length&&i(()=>{r(()=>{f.forEach(h=>{n(h)})})})};return{batch:f=>{let h;e++;try{h=f()}finally{e--,e||d()}return h},batchCalls:f=>(...h)=>{c(()=>{f(...h)})},schedule:c,setNotifyFunction:f=>{n=f},setBatchNotifyFunction:f=>{r=f},setScheduler:f=>{i=f}}}var Ht=rU(),Al,Es,wl,EN,lU=(EN=class extends Vo{constructor(){super();Ee(this,Al,!0);Ee(this,Es);Ee(this,wl);pe(this,wl,e=>{if(typeof window<"u"&&window.addEventListener){const n=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){z(this,Es)||this.setEventListener(z(this,wl))}onUnsubscribe(){var e;this.hasListeners()||((e=z(this,Es))==null||e.call(this),pe(this,Es,void 0))}setEventListener(e){var n;pe(this,wl,e),(n=z(this,Es))==null||n.call(this),pe(this,Es,e(this.setOnline.bind(this)))}setOnline(e){z(this,Al)!==e&&(pe(this,Al,e),this.listeners.forEach(r=>{r(e)}))}isOnline(){return z(this,Al)}},Al=new WeakMap,Es=new WeakMap,wl=new WeakMap,EN),fu=new lU;function iU(t){return Math.min(1e3*2**t,3e4)}function cA(t){return(t??"online")==="online"?fu.isOnline():!0}var mg=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function dA(t){let e=!1,n=0,r;const i=gg(),c=()=>i.status!=="pending",d=S=>{var j;if(!c()){const R=new mg(S);m(R),(j=t.onCancel)==null||j.call(t,R)}},f=()=>{e=!0},h=()=>{e=!1},p=()=>Lm.isFocused()&&(t.networkMode==="always"||fu.isOnline())&&t.canRun(),b=()=>cA(t.networkMode)&&t.canRun(),y=S=>{c()||(r==null||r(),i.resolve(S))},m=S=>{c()||(r==null||r(),i.reject(S))},v=()=>new Promise(S=>{var j;r=R=>{(c()||p())&&S(R)},(j=t.onPause)==null||j.call(t)}).then(()=>{var S;r=void 0,c()||(S=t.onContinue)==null||S.call(t)}),N=()=>{if(c())return;let S;const j=n===0?t.initialPromise:void 0;try{S=j??t.fn()}catch(R){S=Promise.reject(R)}Promise.resolve(S).then(y).catch(R=>{var _;if(c())return;const C=t.retry??(Ao.isServer()?0:3),O=t.retryDelay??iU,A=typeof O=="function"?O(n,R):O,k=C===!0||typeof C=="number"&&np()?void 0:v()).then(()=>{e?m(R):N()})})};return{promise:i,status:()=>i.status,cancel:d,continue:()=>(r==null||r(),i),cancelRetry:f,continueRetry:h,canStart:b,start:()=>(b()?N():v().then(N),i)}}var pr,SN,uA=(SN=class{constructor(){Ee(this,pr)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ug(this.gcTime)&&pe(this,pr,fr.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Ao.isServer()?1/0:300*1e3))}clearGcTimeout(){z(this,pr)!==void 0&&(fr.clearTimeout(z(this,pr)),pe(this,pr,void 0))}},pr=new WeakMap,SN);function oU(t){return{onFetch:(e,n)=>{var b,y,m,v,N;const r=e.options,i=(m=(y=(b=e.fetchOptions)==null?void 0:b.meta)==null?void 0:y.fetchMore)==null?void 0:m.direction,c=((v=e.state.data)==null?void 0:v.pages)||[],d=((N=e.state.data)==null?void 0:N.pageParams)||[];let f={pages:[],pageParams:[]},h=0;const p=async()=>{let S=!1;const j=O=>{aU(O,()=>e.signal,()=>S=!0)},R=iA(e.options,e.fetchOptions),C=async(O,A,k)=>{if(S)return Promise.reject(e.signal.reason);if(A==null&&O.pages.length)return Promise.resolve(O);const B=(()=>{const ne={client:e.client,queryKey:e.queryKey,pageParam:A,direction:k?"backward":"forward",meta:e.options.meta};return j(ne),ne})(),F=await R(B),{maxPages:G}=e.options,ee=k?nU:tU;return{pages:ee(O.pages,F,G),pageParams:ee(O.pageParams,A,G)}};if(i&&c.length){const O=i==="backward",A=O?cU:nN,k={pages:c,pageParams:d},_=A(r,k);f=await C(k,_,O)}else{const O=t??c.length;do{const A=h===0?d[0]??r.initialPageParam:nN(r,f);if(h>0&&A==null)break;f=await C(f,A),h++}while(h{var S,j;return(j=(S=e.options).persister)==null?void 0:j.call(S,p,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},n)}:e.fetchFn=p}}}function nN(t,{pages:e,pageParams:n}){const r=e.length-1;return e.length>0?t.getNextPageParam(e[r],e,n[r],n):void 0}function cU(t,{pages:e,pageParams:n}){var r;return e.length>0?(r=t.getPreviousPageParam)==null?void 0:r.call(t,e[0],e,n[0],n):void 0}var Cl,gr,Dl,Vn,mr,Tt,Co,xr,vn,fA,_a,jN,dU=(jN=class extends uA{constructor(e){super();Ee(this,vn);Ee(this,Cl);Ee(this,gr);Ee(this,Dl);Ee(this,Vn);Ee(this,mr);Ee(this,Tt);Ee(this,Co);Ee(this,xr);pe(this,xr,!1),pe(this,Co,e.defaultOptions),this.setOptions(e.options),this.observers=[],pe(this,mr,e.client),pe(this,Vn,z(this,mr).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,pe(this,gr,sN(this.options)),this.state=e.state??z(this,gr),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return z(this,Cl)}get promise(){var e;return(e=z(this,Tt))==null?void 0:e.promise}setOptions(e){if(this.options={...z(this,Co),...e},e!=null&&e._type&&pe(this,Cl,e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=sN(this.options);n.data!==void 0&&(this.setState(aN(n.data,n.dataUpdatedAt)),pe(this,gr,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&z(this,Vn).remove(this)}setData(e,n){const r=pg(this.state.data,e,this.options);return Pe(this,vn,_a).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(e){Pe(this,vn,_a).call(this,{type:"setState",state:e})}cancel(e){var r,i;const n=(r=z(this,Tt))==null?void 0:r.promise;return(i=z(this,Tt))==null||i.cancel(e),n?n.then(ln).catch(ln):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return z(this,gr)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>En(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Pm||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>Is(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!rA(this.state.dataUpdatedAt,e)}onFocus(){var n;const e=this.observers.find(r=>r.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(n=z(this,Tt))==null||n.continue()}onOnline(){var n;const e=this.observers.find(r=>r.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(n=z(this,Tt))==null||n.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),z(this,Vn).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(n=>n!==e),this.observers.length||(z(this,Tt)&&(z(this,xr)||Pe(this,vn,fA).call(this)?z(this,Tt).cancel({revert:!0}):z(this,Tt).cancelRetry()),this.scheduleGc()),z(this,Vn).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Pe(this,vn,_a).call(this,{type:"invalidate"})}async fetch(e,n){var p,b,y,m,v,N,S,j,R,C,O;if(this.state.fetchStatus!=="idle"&&((p=z(this,Tt))==null?void 0:p.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(z(this,Tt))return z(this,Tt).continueRetry(),z(this,Tt).promise}if(e&&this.setOptions(e),!this.options.queryFn){const A=this.observers.find(k=>k.options.queryFn);A&&this.setOptions(A.options)}const r=new AbortController,i=A=>{Object.defineProperty(A,"signal",{enumerable:!0,get:()=>(pe(this,xr,!0),r.signal)})},c=()=>{const A=iA(this.options,n),_=(()=>{const B={client:z(this,mr),queryKey:this.queryKey,meta:this.meta};return i(B),B})();return pe(this,xr,!1),this.options.persister?this.options.persister(A,_,this):A(_)},f=(()=>{const A={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:z(this,mr),state:this.state,fetchFn:c};return i(A),A})(),h=z(this,Cl)==="infinite"?oU(this.options.pages):this.options.behavior;h==null||h.onFetch(f,this),pe(this,Dl,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((b=f.fetchOptions)==null?void 0:b.meta))&&Pe(this,vn,_a).call(this,{type:"fetch",meta:(y=f.fetchOptions)==null?void 0:y.meta}),pe(this,Tt,dA({initialPromise:n==null?void 0:n.initialPromise,fn:f.fetchFn,onCancel:A=>{A instanceof mg&&A.revert&&this.setState({...z(this,Dl),fetchStatus:"idle"}),r.abort()},onFail:(A,k)=>{Pe(this,vn,_a).call(this,{type:"failed",failureCount:A,error:k})},onPause:()=>{Pe(this,vn,_a).call(this,{type:"pause"})},onContinue:()=>{Pe(this,vn,_a).call(this,{type:"continue"})},retry:f.options.retry,retryDelay:f.options.retryDelay,networkMode:f.options.networkMode,canRun:()=>!0}));try{const A=await z(this,Tt).start();if(A===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(A),(v=(m=z(this,Vn).config).onSuccess)==null||v.call(m,A,this),(S=(N=z(this,Vn).config).onSettled)==null||S.call(N,A,this.state.error,this),A}catch(A){if(A instanceof mg){if(A.silent)return z(this,Tt).promise;if(A.revert){if(this.state.data===void 0)throw A;return this.state.data}}throw Pe(this,vn,_a).call(this,{type:"error",error:A}),(R=(j=z(this,Vn).config).onError)==null||R.call(j,A,this),(O=(C=z(this,Vn).config).onSettled)==null||O.call(C,this.state.data,A,this),A}finally{this.scheduleGc()}}},Cl=new WeakMap,gr=new WeakMap,Dl=new WeakMap,Vn=new WeakMap,mr=new WeakMap,Tt=new WeakMap,Co=new WeakMap,xr=new WeakMap,vn=new WeakSet,fA=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},_a=function(e){const n=r=>{switch(e.type){case"failed":return{...r,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...hA(r.data,this.options),fetchMeta:e.meta??null};case"success":const i={...r,...aN(e.data,e.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return pe(this,Dl,e.manual?i:void 0),i;case"error":const c=e.error;return{...r,error:c,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:c,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...e.state}}};this.state=n(this.state),Ht.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),z(this,Vn).notify({query:this,type:"updated",action:e})})},jN);function hA(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:cA(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function aN(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function sN(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,n=e!==void 0,r=n?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var rn,He,Do,Xt,br,Ol,Ma,Ss,Oo,Rl,Tl,yr,vr,js,kl,Ze,ao,xg,bg,yg,vg,Ng,Eg,Sg,pA,AN,uU=(AN=class extends Vo{constructor(e,n){super();Ee(this,Ze);Ee(this,rn);Ee(this,He);Ee(this,Do);Ee(this,Xt);Ee(this,br);Ee(this,Ol);Ee(this,Ma);Ee(this,Ss);Ee(this,Oo);Ee(this,Rl);Ee(this,Tl);Ee(this,yr);Ee(this,vr);Ee(this,js);Ee(this,kl,new Set);this.options=n,pe(this,rn,e),pe(this,Ss,null),pe(this,Ma,gg()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(z(this,He).addObserver(this),rN(z(this,He),this.options)?Pe(this,Ze,ao).call(this):this.updateResult(),Pe(this,Ze,vg).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return jg(z(this,He),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return jg(z(this,He),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Pe(this,Ze,Ng).call(this),Pe(this,Ze,Eg).call(this),z(this,He).removeObserver(this)}setOptions(e){const n=this.options,r=z(this,He);if(this.options=z(this,rn).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof En(this.options.enabled,z(this,He))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Pe(this,Ze,Sg).call(this),z(this,He).setOptions(this.options),n._defaulted&&!fg(this.options,n)&&z(this,rn).getQueryCache().notify({type:"observerOptionsUpdated",query:z(this,He),observer:this});const i=this.hasListeners();i&&lN(z(this,He),r,this.options,n)&&Pe(this,Ze,ao).call(this),this.updateResult(),i&&(z(this,He)!==r||En(this.options.enabled,z(this,He))!==En(n.enabled,z(this,He))||Is(this.options.staleTime,z(this,He))!==Is(n.staleTime,z(this,He)))&&Pe(this,Ze,xg).call(this);const c=Pe(this,Ze,bg).call(this);i&&(z(this,He)!==r||En(this.options.enabled,z(this,He))!==En(n.enabled,z(this,He))||c!==z(this,js))&&Pe(this,Ze,yg).call(this,c)}getOptimisticResult(e){const n=z(this,rn).getQueryCache().build(z(this,rn),e),r=this.createResult(n,e);return hU(this,r)&&(pe(this,Xt,r),pe(this,Ol,this.options),pe(this,br,z(this,He).state)),r}getCurrentResult(){return z(this,Xt)}trackResult(e,n){return new Proxy(e,{get:(r,i)=>(this.trackProp(i),n==null||n(i),i==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&z(this,Ma).status==="pending"&&z(this,Ma).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,i))})}trackProp(e){z(this,kl).add(e)}getCurrentQuery(){return z(this,He)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const n=z(this,rn).defaultQueryOptions(e),r=z(this,rn).getQueryCache().build(z(this,rn),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(e){return Pe(this,Ze,ao).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),z(this,Xt)))}createResult(e,n){var G;const r=z(this,He),i=this.options,c=z(this,Xt),d=z(this,br),f=z(this,Ol),p=e!==r?e.state:z(this,Do),{state:b}=e;let y={...b},m=!1,v;if(n._optimisticResults){const ee=this.hasListeners(),ne=!ee&&rN(e,n),oe=ee&&lN(e,r,n,i);(ne||oe)&&(y={...y,...hA(b.data,e.options)}),n._optimisticResults==="isRestoring"&&(y.fetchStatus="idle")}let{error:N,errorUpdatedAt:S,status:j}=y;v=y.data;let R=!1;if(n.placeholderData!==void 0&&v===void 0&&j==="pending"){let ee;c!=null&&c.isPlaceholderData&&n.placeholderData===(f==null?void 0:f.placeholderData)?(ee=c.data,R=!0):ee=typeof n.placeholderData=="function"?n.placeholderData((G=z(this,Tl))==null?void 0:G.state.data,z(this,Tl)):n.placeholderData,ee!==void 0&&(j="success",v=pg(c==null?void 0:c.data,ee,n),m=!0)}if(n.select&&v!==void 0&&!R)if(c&&v===(d==null?void 0:d.data)&&n.select===z(this,Oo))v=z(this,Rl);else try{pe(this,Oo,n.select),v=n.select(v),v=pg(c==null?void 0:c.data,v,n),pe(this,Rl,v),pe(this,Ss,null)}catch(ee){pe(this,Ss,ee)}z(this,Ss)&&(N=z(this,Ss),v=z(this,Rl),S=Date.now(),j="error");const C=y.fetchStatus==="fetching",O=j==="pending",A=j==="error",k=O&&C,_=v!==void 0,F={status:j,fetchStatus:y.fetchStatus,isPending:O,isSuccess:j==="success",isError:A,isInitialLoading:k,isLoading:k,data:v,dataUpdatedAt:y.dataUpdatedAt,error:N,errorUpdatedAt:S,failureCount:y.fetchFailureCount,failureReason:y.fetchFailureReason,errorUpdateCount:y.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:y.dataUpdateCount>p.dataUpdateCount||y.errorUpdateCount>p.errorUpdateCount,isFetching:C,isRefetching:C&&!O,isLoadingError:A&&!_,isPaused:y.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:A&&_,isStale:Um(e,n),refetch:this.refetch,promise:z(this,Ma),isEnabled:En(n.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const ee=F.data!==void 0,ne=F.status==="error"&&!ee,oe=he=>{ne?he.reject(F.error):ee&&he.resolve(F.data)},Q=()=>{const he=pe(this,Ma,F.promise=gg());oe(he)},ce=z(this,Ma);switch(ce.status){case"pending":e.queryHash===r.queryHash&&oe(ce);break;case"fulfilled":(ne||F.data!==ce.value)&&Q();break;case"rejected":(!ne||F.error!==ce.reason)&&Q();break}}return F}updateResult(){const e=z(this,Xt),n=this.createResult(z(this,He),this.options);if(pe(this,br,z(this,He).state),pe(this,Ol,this.options),z(this,br).data!==void 0&&pe(this,Tl,z(this,He)),fg(n,e))return;pe(this,Xt,n);const r=()=>{if(!e)return!0;const{notifyOnChangeProps:i}=this.options,c=typeof i=="function"?i():i;if(c==="all"||!c&&!z(this,kl).size)return!0;const d=new Set(c??z(this,kl));return this.options.throwOnError&&d.add("error"),Object.keys(z(this,Xt)).some(f=>{const h=f;return z(this,Xt)[h]!==e[h]&&d.has(h)})};Pe(this,Ze,pA).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Pe(this,Ze,vg).call(this)}},rn=new WeakMap,He=new WeakMap,Do=new WeakMap,Xt=new WeakMap,br=new WeakMap,Ol=new WeakMap,Ma=new WeakMap,Ss=new WeakMap,Oo=new WeakMap,Rl=new WeakMap,Tl=new WeakMap,yr=new WeakMap,vr=new WeakMap,js=new WeakMap,kl=new WeakMap,Ze=new WeakSet,ao=function(e){Pe(this,Ze,Sg).call(this);let n=z(this,He).fetch(this.options,e);return e!=null&&e.throwOnError||(n=n.catch(ln)),n},xg=function(){Pe(this,Ze,Ng).call(this);const e=Is(this.options.staleTime,z(this,He));if(Ao.isServer()||z(this,Xt).isStale||!ug(e))return;const r=rA(z(this,Xt).dataUpdatedAt,e)+1;pe(this,yr,fr.setTimeout(()=>{z(this,Xt).isStale||this.updateResult()},r))},bg=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(z(this,He)):this.options.refetchInterval)??!1},yg=function(e){Pe(this,Ze,Eg).call(this),pe(this,js,e),!(Ao.isServer()||En(this.options.enabled,z(this,He))===!1||!ug(z(this,js))||z(this,js)===0)&&pe(this,vr,fr.setInterval(()=>{(this.options.refetchIntervalInBackground||Lm.isFocused())&&Pe(this,Ze,ao).call(this)},z(this,js)))},vg=function(){Pe(this,Ze,xg).call(this),Pe(this,Ze,yg).call(this,Pe(this,Ze,bg).call(this))},Ng=function(){z(this,yr)!==void 0&&(fr.clearTimeout(z(this,yr)),pe(this,yr,void 0))},Eg=function(){z(this,vr)!==void 0&&(fr.clearInterval(z(this,vr)),pe(this,vr,void 0))},Sg=function(){const e=z(this,rn).getQueryCache().build(z(this,rn),this.options);if(e===z(this,He))return;const n=z(this,He);pe(this,He,e),pe(this,Do,e.state),this.hasListeners()&&(n==null||n.removeObserver(this),e.addObserver(this))},pA=function(e){Ht.batch(()=>{e.listeners&&this.listeners.forEach(n=>{n(z(this,Xt))}),z(this,rn).getQueryCache().notify({query:z(this,He),type:"observerResultsUpdated"})})},AN);function fU(t,e){return En(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&En(e.retryOnMount,t)===!1)}function rN(t,e){return fU(t,e)||t.state.data!==void 0&&jg(t,e,e.refetchOnMount)}function jg(t,e,n){if(En(e.enabled,t)!==!1&&Is(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&Um(t,e)}return!1}function lN(t,e,n,r){return(t!==e||En(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&Um(t,n)}function Um(t,e){return En(e.enabled,t)!==!1&&t.isStaleByTime(Is(e.staleTime,t))}function hU(t,e){return!fg(t.getCurrentResult(),e)}var Ro,la,Ft,Nr,ia,ys,wN,pU=(wN=class extends uA{constructor(e){super();Ee(this,ia);Ee(this,Ro);Ee(this,la);Ee(this,Ft);Ee(this,Nr);pe(this,Ro,e.client),this.mutationId=e.mutationId,pe(this,Ft,e.mutationCache),pe(this,la,[]),this.state=e.state||gU(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){z(this,la).includes(e)||(z(this,la).push(e),this.clearGcTimeout(),z(this,Ft).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){pe(this,la,z(this,la).filter(n=>n!==e)),this.scheduleGc(),z(this,Ft).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){z(this,la).length||(this.state.status==="pending"?this.scheduleGc():z(this,Ft).remove(this))}continue(){var e;return((e=z(this,Nr))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var d,f,h,p,b,y,m,v,N,S,j,R,C,O,A,k,_,B;const n=()=>{Pe(this,ia,ys).call(this,{type:"continue"})},r={client:z(this,Ro),meta:this.options.meta,mutationKey:this.options.mutationKey};pe(this,Nr,dA({fn:()=>this.options.mutationFn?this.options.mutationFn(e,r):Promise.reject(new Error("No mutationFn found")),onFail:(F,G)=>{Pe(this,ia,ys).call(this,{type:"failed",failureCount:F,error:G})},onPause:()=>{Pe(this,ia,ys).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>z(this,Ft).canRun(this)}));const i=this.state.status==="pending",c=!z(this,Nr).canStart();try{if(i)n();else{Pe(this,ia,ys).call(this,{type:"pending",variables:e,isPaused:c}),z(this,Ft).config.onMutate&&await z(this,Ft).config.onMutate(e,this,r);const G=await((f=(d=this.options).onMutate)==null?void 0:f.call(d,e,r));G!==this.state.context&&Pe(this,ia,ys).call(this,{type:"pending",context:G,variables:e,isPaused:c})}const F=await z(this,Nr).start();return await((p=(h=z(this,Ft).config).onSuccess)==null?void 0:p.call(h,F,e,this.state.context,this,r)),await((y=(b=this.options).onSuccess)==null?void 0:y.call(b,F,e,this.state.context,r)),await((v=(m=z(this,Ft).config).onSettled)==null?void 0:v.call(m,F,null,this.state.variables,this.state.context,this,r)),await((S=(N=this.options).onSettled)==null?void 0:S.call(N,F,null,e,this.state.context,r)),Pe(this,ia,ys).call(this,{type:"success",data:F}),F}catch(F){try{await((R=(j=z(this,Ft).config).onError)==null?void 0:R.call(j,F,e,this.state.context,this,r))}catch(G){Promise.reject(G)}try{await((O=(C=this.options).onError)==null?void 0:O.call(C,F,e,this.state.context,r))}catch(G){Promise.reject(G)}try{await((k=(A=z(this,Ft).config).onSettled)==null?void 0:k.call(A,void 0,F,this.state.variables,this.state.context,this,r))}catch(G){Promise.reject(G)}try{await((B=(_=this.options).onSettled)==null?void 0:B.call(_,void 0,F,e,this.state.context,r))}catch(G){Promise.reject(G)}throw Pe(this,ia,ys).call(this,{type:"error",error:F}),F}finally{z(this,Ft).runNext(this)}}},Ro=new WeakMap,la=new WeakMap,Ft=new WeakMap,Nr=new WeakMap,ia=new WeakSet,ys=function(e){const n=r=>{switch(e.type){case"failed":return{...r,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...r,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:e.error,failureCount:r.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Ht.batch(()=>{z(this,la).forEach(r=>{r.onMutationUpdate(e)}),z(this,Ft).notify({mutation:this,type:"updated",action:e})})},wN);function gU(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ia,Kn,To,CN,mU=(CN=class extends Vo{constructor(e={}){super();Ee(this,Ia);Ee(this,Kn);Ee(this,To);this.config=e,pe(this,Ia,new Set),pe(this,Kn,new Map),pe(this,To,0)}build(e,n,r){const i=new pU({client:e,mutationCache:this,mutationId:++id(this,To)._,options:e.defaultMutationOptions(n),state:r});return this.add(i),i}add(e){z(this,Ia).add(e);const n=Ed(e);if(typeof n=="string"){const r=z(this,Kn).get(n);r?r.push(e):z(this,Kn).set(n,[e])}this.notify({type:"added",mutation:e})}remove(e){if(z(this,Ia).delete(e)){const n=Ed(e);if(typeof n=="string"){const r=z(this,Kn).get(n);if(r)if(r.length>1){const i=r.indexOf(e);i!==-1&&r.splice(i,1)}else r[0]===e&&z(this,Kn).delete(n)}}this.notify({type:"removed",mutation:e})}canRun(e){const n=Ed(e);if(typeof n=="string"){const r=z(this,Kn).get(n),i=r==null?void 0:r.find(c=>c.state.status==="pending");return!i||i===e}else return!0}runNext(e){var r;const n=Ed(e);if(typeof n=="string"){const i=(r=z(this,Kn).get(n))==null?void 0:r.find(c=>c!==e&&c.state.isPaused);return(i==null?void 0:i.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Ht.batch(()=>{z(this,Ia).forEach(e=>{this.notify({type:"removed",mutation:e})}),z(this,Ia).clear(),z(this,Kn).clear()})}getAll(){return Array.from(z(this,Ia))}find(e){const n={exact:!0,...e};return this.getAll().find(r=>J1(n,r))}findAll(e={}){return this.getAll().filter(n=>J1(e,n))}notify(e){Ht.batch(()=>{this.listeners.forEach(n=>{n(e)})})}resumePausedMutations(){const e=this.getAll().filter(n=>n.state.isPaused);return Ht.batch(()=>Promise.all(e.map(n=>n.continue().catch(ln))))}},Ia=new WeakMap,Kn=new WeakMap,To=new WeakMap,CN);function Ed(t){var e;return(e=t.options.scope)==null?void 0:e.id}var oa,DN,xU=(DN=class extends Vo{constructor(e={}){super();Ee(this,oa);this.config=e,pe(this,oa,new Map)}build(e,n,r){const i=n.queryKey,c=n.queryHash??zm(i,n);let d=this.get(c);return d||(d=new dU({client:e,queryKey:i,queryHash:c,options:e.defaultQueryOptions(n),state:r,defaultOptions:e.getQueryDefaults(i)}),this.add(d)),d}add(e){z(this,oa).has(e.queryHash)||(z(this,oa).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const n=z(this,oa).get(e.queryHash);n&&(e.destroy(),n===e&&z(this,oa).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){Ht.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return z(this,oa).get(e)}getAll(){return[...z(this,oa).values()]}find(e){const n={exact:!0,...e};return this.getAll().find(r=>K1(n,r))}findAll(e={}){const n=this.getAll();return Object.keys(e).length>0?n.filter(r=>K1(e,r)):n}notify(e){Ht.batch(()=>{this.listeners.forEach(n=>{n(e)})})}onFocus(){Ht.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Ht.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},oa=new WeakMap,DN),mt,As,ws,_l,Ml,Cs,Il,Ll,ON,bU=(ON=class{constructor(t={}){Ee(this,mt);Ee(this,As);Ee(this,ws);Ee(this,_l);Ee(this,Ml);Ee(this,Cs);Ee(this,Il);Ee(this,Ll);pe(this,mt,t.queryCache||new xU),pe(this,As,t.mutationCache||new mU),pe(this,ws,t.defaultOptions||{}),pe(this,_l,new Map),pe(this,Ml,new Map),pe(this,Cs,0)}mount(){id(this,Cs)._++,z(this,Cs)===1&&(pe(this,Il,Lm.subscribe(async t=>{t&&(await this.resumePausedMutations(),z(this,mt).onFocus())})),pe(this,Ll,fu.subscribe(async t=>{t&&(await this.resumePausedMutations(),z(this,mt).onOnline())})))}unmount(){var t,e;id(this,Cs)._--,z(this,Cs)===0&&((t=z(this,Il))==null||t.call(this),pe(this,Il,void 0),(e=z(this,Ll))==null||e.call(this),pe(this,Ll,void 0))}isFetching(t){return z(this,mt).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return z(this,As).findAll({...t,status:"pending"}).length}getQueryData(t){var n;const e=this.defaultQueryOptions({queryKey:t});return(n=z(this,mt).get(e.queryHash))==null?void 0:n.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),n=z(this,mt).build(this,e),r=n.state.data;return r===void 0?this.fetchQuery(t):(t.revalidateIfStale&&n.isStaleByTime(Is(e.staleTime,n))&&this.prefetchQuery(e),Promise.resolve(r))}getQueriesData(t){return z(this,mt).findAll(t).map(({queryKey:e,state:n})=>{const r=n.data;return[e,r]})}setQueryData(t,e,n){const r=this.defaultQueryOptions({queryKey:t}),i=z(this,mt).get(r.queryHash),c=i==null?void 0:i.state.data,d=KP(e,c);if(d!==void 0)return z(this,mt).build(this,r).setData(d,{...n,manual:!0})}setQueriesData(t,e,n){return Ht.batch(()=>z(this,mt).findAll(t).map(({queryKey:r})=>[r,this.setQueryData(r,e,n)]))}getQueryState(t){var n;const e=this.defaultQueryOptions({queryKey:t});return(n=z(this,mt).get(e.queryHash))==null?void 0:n.state}removeQueries(t){const e=z(this,mt);Ht.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=z(this,mt);return Ht.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=Ht.batch(()=>z(this,mt).findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(ln).catch(ln)}invalidateQueries(t,e={}){return Ht.batch(()=>(z(this,mt).findAll(t).forEach(n=>{n.invalidate()}),(t==null?void 0:t.refetchType)==="none"?Promise.resolve():this.refetchQueries({...t,type:(t==null?void 0:t.refetchType)??(t==null?void 0:t.type)??"active"},e)))}refetchQueries(t,e={}){const n={...e,cancelRefetch:e.cancelRefetch??!0},r=Ht.batch(()=>z(this,mt).findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let c=i.fetch(void 0,n);return n.throwOnError||(c=c.catch(ln)),i.state.fetchStatus==="paused"?Promise.resolve():c}));return Promise.all(r).then(ln)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=z(this,mt).build(this,e);return n.isStaleByTime(Is(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(ln).catch(ln)}fetchInfiniteQuery(t){return t._type="infinite",this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(ln).catch(ln)}ensureInfiniteQueryData(t){return t._type="infinite",this.ensureQueryData(t)}resumePausedMutations(){return fu.isOnline()?z(this,As).resumePausedMutations():Promise.resolve()}getQueryCache(){return z(this,mt)}getMutationCache(){return z(this,As)}getDefaultOptions(){return z(this,ws)}setDefaultOptions(t){pe(this,ws,t)}setQueryDefaults(t,e){z(this,_l).set(So(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...z(this,_l).values()],n={};return e.forEach(r=>{jo(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){z(this,Ml).set(So(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...z(this,Ml).values()],n={};return e.forEach(r=>{jo(t,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(t){if(t._defaulted)return t;const e={...z(this,ws).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=zm(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===Pm&&(e.enabled=!1),e}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...z(this,ws).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){z(this,mt).clear(),z(this,As).clear()}},mt=new WeakMap,As=new WeakMap,ws=new WeakMap,_l=new WeakMap,Ml=new WeakMap,Cs=new WeakMap,Il=new WeakMap,Ll=new WeakMap,ON),gA=w.createContext(void 0),yU=t=>{const e=w.useContext(gA);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},vU=({client:t,children:e})=>(w.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),s.jsx(gA.Provider,{value:t,children:e})),mA=w.createContext(!1),NU=()=>w.useContext(mA);mA.Provider;function EU(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var SU=w.createContext(EU()),jU=()=>w.useContext(SU),AU=(t,e,n)=>{const r=n!=null&&n.state.error&&typeof t.throwOnError=="function"?oA(t.throwOnError,[n.state.error,n]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||r)&&(e.isReset()||(t.retryOnMount=!1))},wU=t=>{w.useEffect(()=>{t.clearReset()},[t])},CU=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||oA(n,[t.error,r])),DU=t=>{if(t.suspense){const n=i=>i==="static"?i:Math.max(i??1e3,1e3),r=t.staleTime;t.staleTime=typeof r=="function"?(...i)=>n(r(...i)):n(r),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},OU=(t,e)=>t.isLoading&&t.isFetching&&!e,RU=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,iN=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function TU(t,e,n){var m,v,N,S;const r=NU(),i=jU(),c=yU(),d=c.defaultQueryOptions(t);(v=(m=c.getDefaultOptions().queries)==null?void 0:m._experimental_beforeQuery)==null||v.call(m,d);const f=c.getQueryCache().get(d.queryHash);d._optimisticResults=r?"isRestoring":"optimistic",DU(d),AU(d,i,f),wU(i);const h=!c.getQueryCache().get(d.queryHash),[p]=w.useState(()=>new e(c,d)),b=p.getOptimisticResult(d),y=!r&&t.subscribed!==!1;if(w.useSyncExternalStore(w.useCallback(j=>{const R=y?p.subscribe(Ht.batchCalls(j)):ln;return p.updateResult(),R},[p,y]),()=>p.getCurrentResult(),()=>p.getCurrentResult()),w.useEffect(()=>{p.setOptions(d)},[d,p]),RU(d,b))throw iN(d,p,i);if(CU({result:b,errorResetBoundary:i,throwOnError:d.throwOnError,query:f,suspense:d.suspense}))throw b.error;if((S=(N=c.getDefaultOptions().queries)==null?void 0:N._experimental_afterQuery)==null||S.call(N,d,b),d.experimental_prefetchInRender&&!Ao.isServer()&&OU(b,r)){const j=h?iN(d,p,i):f==null?void 0:f.promise;j==null||j.catch(ln).finally(()=>{p.updateResult()})}return d.notifyOnChangeProps?b:p.trackResult(b)}function kU(t,e){return TU(t,uU)}const xA=6048e5,_U=864e5,bA=6e4,yA=36e5,oN=Symbol.for("constructDateFrom");function Ga(t,e){return typeof t=="function"?t(e):t&&typeof t=="object"&&oN in t?t[oN](e):t instanceof Date?new t.constructor(e):new Date(e)}function Dn(t,e){return Ga(e||t,t)}let MU={};function _u(){return MU}function wo(t,e){var f,h,p,b;const n=_u(),r=(e==null?void 0:e.weekStartsOn)??((h=(f=e==null?void 0:e.locale)==null?void 0:f.options)==null?void 0:h.weekStartsOn)??n.weekStartsOn??((b=(p=n.locale)==null?void 0:p.options)==null?void 0:b.weekStartsOn)??0,i=Dn(t,e==null?void 0:e.in),c=i.getDay(),d=(c=c.getTime()?r+1:n.getTime()>=f.getTime()?r:r-1}function cN(t){const e=Dn(t),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return n.setUTCFullYear(e.getFullYear()),+t-+n}function IU(t,...e){const n=Ga.bind(null,e.find(r=>typeof r=="object"));return e.map(n)}function dN(t,e){const n=Dn(t,e==null?void 0:e.in);return n.setHours(0,0,0,0),n}function LU(t,e,n){const[r,i]=IU(n==null?void 0:n.in,t,e),c=dN(r),d=dN(i),f=+c-cN(c),h=+d-cN(d);return Math.round((f-h)/_U)}function zU(t,e){const n=vA(t,e),r=Ga(t,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),hu(r)}function PU(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function UU(t){return!(!PU(t)&&typeof t!="number"||isNaN(+Dn(t)))}function BU(t,e){const n=Dn(t,e==null?void 0:e.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}const HU={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},GU=(t,e,n)=>{let r;const i=HU[t];return typeof i=="string"?r=i:e===1?r=i.one:r=i.other.replace("{{count}}",e.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function Pp(t){return(e={})=>{const n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const VU={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},FU={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},qU={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},$U={date:Pp({formats:VU,defaultWidth:"full"}),time:Pp({formats:FU,defaultWidth:"full"}),dateTime:Pp({formats:qU,defaultWidth:"full"})},YU={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},QU=(t,e,n,r)=>YU[t];function Ji(t){return(e,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let i;if(r==="formatting"&&t.formattingValues){const d=t.defaultFormattingWidth||t.defaultWidth,f=n!=null&&n.width?String(n.width):d;i=t.formattingValues[f]||t.formattingValues[d]}else{const d=t.defaultWidth,f=n!=null&&n.width?String(n.width):t.defaultWidth;i=t.values[f]||t.values[d]}const c=t.argumentCallback?t.argumentCallback(e):e;return i[c]}}const WU={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},XU={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},ZU={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},KU={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},JU={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},e8={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},t8=(t,e)=>{const n=Number(t),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},n8={ordinalNumber:t8,era:Ji({values:WU,defaultWidth:"wide"}),quarter:Ji({values:XU,defaultWidth:"wide",argumentCallback:t=>t-1}),month:Ji({values:ZU,defaultWidth:"wide"}),day:Ji({values:KU,defaultWidth:"wide"}),dayPeriod:Ji({values:JU,defaultWidth:"wide",formattingValues:e8,defaultFormattingWidth:"wide"})};function eo(t){return(e,n={})=>{const r=n.width,i=r&&t.matchPatterns[r]||t.matchPatterns[t.defaultMatchWidth],c=e.match(i);if(!c)return null;const d=c[0],f=r&&t.parsePatterns[r]||t.parsePatterns[t.defaultParseWidth],h=Array.isArray(f)?s8(f,y=>y.test(d)):a8(f,y=>y.test(d));let p;p=t.valueCallback?t.valueCallback(h):h,p=n.valueCallback?n.valueCallback(p):p;const b=e.slice(d.length);return{value:p,rest:b}}}function a8(t,e){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n}function s8(t,e){for(let n=0;n{const r=e.match(t.matchPattern);if(!r)return null;const i=r[0],c=e.match(t.parsePattern);if(!c)return null;let d=t.valueCallback?t.valueCallback(c[0]):c[0];d=n.valueCallback?n.valueCallback(d):d;const f=e.slice(i.length);return{value:d,rest:f}}}const l8=/^(\d+)(th|st|nd|rd)?/i,i8=/\d+/i,o8={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},c8={any:[/^b/i,/^(a|c)/i]},d8={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},u8={any:[/1/i,/2/i,/3/i,/4/i]},f8={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},h8={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},p8={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},g8={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},m8={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},x8={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},b8={ordinalNumber:r8({matchPattern:l8,parsePattern:i8,valueCallback:t=>parseInt(t,10)}),era:eo({matchPatterns:o8,defaultMatchWidth:"wide",parsePatterns:c8,defaultParseWidth:"any"}),quarter:eo({matchPatterns:d8,defaultMatchWidth:"wide",parsePatterns:u8,defaultParseWidth:"any",valueCallback:t=>t+1}),month:eo({matchPatterns:f8,defaultMatchWidth:"wide",parsePatterns:h8,defaultParseWidth:"any"}),day:eo({matchPatterns:p8,defaultMatchWidth:"wide",parsePatterns:g8,defaultParseWidth:"any"}),dayPeriod:eo({matchPatterns:m8,defaultMatchWidth:"any",parsePatterns:x8,defaultParseWidth:"any"})},y8={code:"en-US",formatDistance:GU,formatLong:$U,formatRelative:QU,localize:n8,match:b8,options:{weekStartsOn:0,firstWeekContainsDate:1}};function v8(t,e){const n=Dn(t,e==null?void 0:e.in);return LU(n,BU(n))+1}function N8(t,e){const n=Dn(t,e==null?void 0:e.in),r=+hu(n)-+zU(n);return Math.round(r/xA)+1}function NA(t,e){var b,y,m,v;const n=Dn(t,e==null?void 0:e.in),r=n.getFullYear(),i=_u(),c=(e==null?void 0:e.firstWeekContainsDate)??((y=(b=e==null?void 0:e.locale)==null?void 0:b.options)==null?void 0:y.firstWeekContainsDate)??i.firstWeekContainsDate??((v=(m=i.locale)==null?void 0:m.options)==null?void 0:v.firstWeekContainsDate)??1,d=Ga((e==null?void 0:e.in)||t,0);d.setFullYear(r+1,0,c),d.setHours(0,0,0,0);const f=wo(d,e),h=Ga((e==null?void 0:e.in)||t,0);h.setFullYear(r,0,c),h.setHours(0,0,0,0);const p=wo(h,e);return+n>=+f?r+1:+n>=+p?r:r-1}function E8(t,e){var f,h,p,b;const n=_u(),r=(e==null?void 0:e.firstWeekContainsDate)??((h=(f=e==null?void 0:e.locale)==null?void 0:f.options)==null?void 0:h.firstWeekContainsDate)??n.firstWeekContainsDate??((b=(p=n.locale)==null?void 0:p.options)==null?void 0:b.firstWeekContainsDate)??1,i=NA(t,e),c=Ga((e==null?void 0:e.in)||t,0);return c.setFullYear(i,0,r),c.setHours(0,0,0,0),wo(c,e)}function S8(t,e){const n=Dn(t,e==null?void 0:e.in),r=+wo(n,e)-+E8(n,e);return Math.round(r/xA)+1}function tt(t,e){const n=t<0?"-":"",r=Math.abs(t).toString().padStart(e,"0");return n+r}const bs={y(t,e){const n=t.getFullYear(),r=n>0?n:1-n;return tt(e==="yy"?r%100:r,e.length)},M(t,e){const n=t.getMonth();return e==="M"?String(n+1):tt(n+1,2)},d(t,e){return tt(t.getDate(),e.length)},a(t,e){const n=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(t,e){return tt(t.getHours()%12||12,e.length)},H(t,e){return tt(t.getHours(),e.length)},m(t,e){return tt(t.getMinutes(),e.length)},s(t,e){return tt(t.getSeconds(),e.length)},S(t,e){const n=e.length,r=t.getMilliseconds(),i=Math.trunc(r*Math.pow(10,n-3));return tt(i,e.length)}},bl={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},uN={G:function(t,e,n){const r=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(t,e,n){if(e==="yo"){const r=t.getFullYear(),i=r>0?r:1-r;return n.ordinalNumber(i,{unit:"year"})}return bs.y(t,e)},Y:function(t,e,n,r){const i=NA(t,r),c=i>0?i:1-i;if(e==="YY"){const d=c%100;return tt(d,2)}return e==="Yo"?n.ordinalNumber(c,{unit:"year"}):tt(c,e.length)},R:function(t,e){const n=vA(t);return tt(n,e.length)},u:function(t,e){const n=t.getFullYear();return tt(n,e.length)},Q:function(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(r);case"QQ":return tt(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(r);case"qq":return tt(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(t,e,n){const r=t.getMonth();switch(e){case"M":case"MM":return bs.M(t,e);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(t,e,n){const r=t.getMonth();switch(e){case"L":return String(r+1);case"LL":return tt(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(t,e,n,r){const i=S8(t,r);return e==="wo"?n.ordinalNumber(i,{unit:"week"}):tt(i,e.length)},I:function(t,e,n){const r=N8(t);return e==="Io"?n.ordinalNumber(r,{unit:"week"}):tt(r,e.length)},d:function(t,e,n){return e==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):bs.d(t,e)},D:function(t,e,n){const r=v8(t);return e==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):tt(r,e.length)},E:function(t,e,n){const r=t.getDay();switch(e){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(t,e,n,r){const i=t.getDay(),c=(i-r.weekStartsOn+8)%7||7;switch(e){case"e":return String(c);case"ee":return tt(c,2);case"eo":return n.ordinalNumber(c,{unit:"day"});case"eee":return n.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(i,{width:"short",context:"formatting"});case"eeee":default:return n.day(i,{width:"wide",context:"formatting"})}},c:function(t,e,n,r){const i=t.getDay(),c=(i-r.weekStartsOn+8)%7||7;switch(e){case"c":return String(c);case"cc":return tt(c,e.length);case"co":return n.ordinalNumber(c,{unit:"day"});case"ccc":return n.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(i,{width:"narrow",context:"standalone"});case"cccccc":return n.day(i,{width:"short",context:"standalone"});case"cccc":default:return n.day(i,{width:"wide",context:"standalone"})}},i:function(t,e,n){const r=t.getDay(),i=r===0?7:r;switch(e){case"i":return String(i);case"ii":return tt(i,e.length);case"io":return n.ordinalNumber(i,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(t,e,n){const i=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(t,e,n){const r=t.getHours();let i;switch(r===12?i=bl.noon:r===0?i=bl.midnight:i=r/12>=1?"pm":"am",e){case"b":case"bb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},B:function(t,e,n){const r=t.getHours();let i;switch(r>=17?i=bl.evening:r>=12?i=bl.afternoon:r>=4?i=bl.morning:i=bl.night,e){case"B":case"BB":case"BBB":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},h:function(t,e,n){if(e==="ho"){let r=t.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return bs.h(t,e)},H:function(t,e,n){return e==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):bs.H(t,e)},K:function(t,e,n){const r=t.getHours()%12;return e==="Ko"?n.ordinalNumber(r,{unit:"hour"}):tt(r,e.length)},k:function(t,e,n){let r=t.getHours();return r===0&&(r=24),e==="ko"?n.ordinalNumber(r,{unit:"hour"}):tt(r,e.length)},m:function(t,e,n){return e==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):bs.m(t,e)},s:function(t,e,n){return e==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):bs.s(t,e)},S:function(t,e){return bs.S(t,e)},X:function(t,e,n){const r=t.getTimezoneOffset();if(r===0)return"Z";switch(e){case"X":return hN(r);case"XXXX":case"XX":return dr(r);case"XXXXX":case"XXX":default:return dr(r,":")}},x:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"x":return hN(r);case"xxxx":case"xx":return dr(r);case"xxxxx":case"xxx":default:return dr(r,":")}},O:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+fN(r,":");case"OOOO":default:return"GMT"+dr(r,":")}},z:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+fN(r,":");case"zzzz":default:return"GMT"+dr(r,":")}},t:function(t,e,n){const r=Math.trunc(+t/1e3);return tt(r,e.length)},T:function(t,e,n){return tt(+t,e.length)}};function fN(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),i=Math.trunc(r/60),c=r%60;return c===0?n+String(i):n+String(i)+e+tt(c,2)}function hN(t,e){return t%60===0?(t>0?"-":"+")+tt(Math.abs(t)/60,2):dr(t,e)}function dr(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),i=tt(Math.trunc(r/60),2),c=tt(r%60,2);return n+i+e+c}const pN=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},EA=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},j8=(t,e)=>{const n=t.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return pN(t,e);let c;switch(r){case"P":c=e.dateTime({width:"short"});break;case"PP":c=e.dateTime({width:"medium"});break;case"PPP":c=e.dateTime({width:"long"});break;case"PPPP":default:c=e.dateTime({width:"full"});break}return c.replace("{{date}}",pN(r,e)).replace("{{time}}",EA(i,e))},A8={p:EA,P:j8},w8=/^D+$/,C8=/^Y+$/,D8=["D","DD","YY","YYYY"];function O8(t){return w8.test(t)}function R8(t){return C8.test(t)}function T8(t,e,n){const r=k8(t,e,n);if(console.warn(r),D8.includes(t))throw new RangeError(r)}function k8(t,e,n){const r=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const _8=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,M8=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,I8=/^'([^]*?)'?$/,L8=/''/g,z8=/[a-zA-Z]/;function Up(t,e,n){var b,y,m,v;const r=_u(),i=r.locale??y8,c=r.firstWeekContainsDate??((y=(b=r.locale)==null?void 0:b.options)==null?void 0:y.firstWeekContainsDate)??1,d=r.weekStartsOn??((v=(m=r.locale)==null?void 0:m.options)==null?void 0:v.weekStartsOn)??0,f=Dn(t,n==null?void 0:n.in);if(!UU(f))throw new RangeError("Invalid time value");let h=e.match(M8).map(N=>{const S=N[0];if(S==="p"||S==="P"){const j=A8[S];return j(N,i.formatLong)}return N}).join("").match(_8).map(N=>{if(N==="''")return{isToken:!1,value:"'"};const S=N[0];if(S==="'")return{isToken:!1,value:P8(N)};if(uN[S])return{isToken:!0,value:N};if(S.match(z8))throw new RangeError("Format string contains an unescaped latin alphabet character `"+S+"`");return{isToken:!1,value:N}});i.localize.preprocessor&&(h=i.localize.preprocessor(f,h));const p={firstWeekContainsDate:c,weekStartsOn:d,locale:i};return h.map(N=>{if(!N.isToken)return N.value;const S=N.value;(R8(S)||O8(S))&&T8(S,e,String(t));const j=uN[S[0]];return j(f,S,i.localize,p)}).join("")}function P8(t){const e=t.match(I8);return e?e[1].replace(L8,"'"):t}function gN(t,e){const n=()=>Ga(e==null?void 0:e.in,NaN),i=G8(t);let c;if(i.date){const p=V8(i.date,2);c=F8(p.restDateString,p.year)}if(!c||isNaN(+c))return n();const d=+c;let f=0,h;if(i.time&&(f=q8(i.time),isNaN(f)))return n();if(i.timezone){if(h=$8(i.timezone),isNaN(h))return n()}else{const p=new Date(d+f),b=Dn(0,e==null?void 0:e.in);return b.setFullYear(p.getUTCFullYear(),p.getUTCMonth(),p.getUTCDate()),b.setHours(p.getUTCHours(),p.getUTCMinutes(),p.getUTCSeconds(),p.getUTCMilliseconds()),b}return Dn(d+f+h,e==null?void 0:e.in)}const Sd={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},U8=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,B8=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,H8=/^([+-])(\d{2})(?::?(\d{2}))?$/;function G8(t){const e={},n=t.split(Sd.dateTimeDelimiter);let r;if(n.length>2)return e;if(/:/.test(n[0])?r=n[0]:(e.date=n[0],r=n[1],Sd.timeZoneDelimiter.test(e.date)&&(e.date=t.split(Sd.timeZoneDelimiter)[0],r=t.substr(e.date.length,t.length))),r){const i=Sd.timezone.exec(r);i?(e.time=r.replace(i[1],""),e.timezone=i[1]):e.time=r}return e}function V8(t,e){const n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+e)+"})|(\\d{2}|[+-]\\d{"+(2+e)+"})$)"),r=t.match(n);if(!r)return{year:NaN,restDateString:""};const i=r[1]?parseInt(r[1]):null,c=r[2]?parseInt(r[2]):null;return{year:c===null?i:c*100,restDateString:t.slice((r[1]||r[2]).length)}}function F8(t,e){if(e===null)return new Date(NaN);const n=t.match(U8);if(!n)return new Date(NaN);const r=!!n[4],i=to(n[1]),c=to(n[2])-1,d=to(n[3]),f=to(n[4]),h=to(n[5])-1;if(r)return Z8(e,f,h)?Y8(e,f,h):new Date(NaN);{const p=new Date(0);return!W8(e,c,d)||!X8(e,i)?new Date(NaN):(p.setUTCFullYear(e,c,Math.max(i,d)),p)}}function to(t){return t?parseInt(t):1}function q8(t){const e=t.match(B8);if(!e)return NaN;const n=Bp(e[1]),r=Bp(e[2]),i=Bp(e[3]);return K8(n,r,i)?n*yA+r*bA+i*1e3:NaN}function Bp(t){return t&&parseFloat(t.replace(",","."))||0}function $8(t){if(t==="Z")return 0;const e=t.match(H8);if(!e)return 0;const n=e[1]==="+"?-1:1,r=parseInt(e[2]),i=e[3]&&parseInt(e[3])||0;return J8(r,i)?n*(r*yA+i*bA):NaN}function Y8(t,e,n){const r=new Date(0);r.setUTCFullYear(t,0,4);const i=r.getUTCDay()||7,c=(e-1)*7+n+1-i;return r.setUTCDate(r.getUTCDate()+c),r}const Q8=[31,null,31,30,31,30,31,31,30,31,30,31];function SA(t){return t%400===0||t%4===0&&t%100!==0}function W8(t,e,n){return e>=0&&e<=11&&n>=1&&n<=(Q8[e]||(SA(t)?29:28))}function X8(t,e){return e>=1&&e<=(SA(t)?366:365)}function Z8(t,e,n){return e>=1&&e<=53&&n>=0&&n<=6}function K8(t,e,n){return t===24?e===0&&n===0:n>=0&&n<60&&e>=0&&e<60&&t>=0&&t<25}function J8(t,e){return e>=0&&e<=59}function mN(t,e){const[n,r]=Ve.useState(t);return Ve.useEffect(()=>{const i=setTimeout(()=>r(t),e);return()=>clearTimeout(i)},[t,e]),n}const eB=({status:t})=>{const e={AUTORIZADO:{label:"Autorizado",color:"bg-green-100 text-green-700 border-green-200"},AUTORIZADO_PARCIAL:{label:"Autorizado Parcialmente",color:"bg-yellow-100 text-yellow-700 border-yellow-200"},NEGADO:{label:"Negado",color:"bg-red-100 text-red-700 border-red-200"},EM_ANALISE:{label:"Em Análise",color:"bg-blue-100 text-blue-700 border-blue-200"},CANCELADO:{label:"Cancelado",color:"bg-gray-100 text-gray-700 border-gray-200"}},n=e[t]||e.EM_ANALISE;return s.jsx("span",{className:`px-2 py-1 rounded-full text-[10px] font-bold border uppercase ${n.color}`,children:n.label})},tB=()=>{const[t,e]=w.useState(1),[n]=w.useState(10),[r,i]=w.useState(""),[c,d]=w.useState(""),[f,h]=w.useState(""),[p,b]=w.useState(""),[y,m]=w.useState(""),[v,N]=w.useState("dataSolicitacao"),[S,j]=w.useState("DESC"),R=mN(r,500),C=mN(c,500),O=async()=>{const ne=new URLSearchParams({page:t.toString(),pageSize:n.toString(),search:R,gto:C,status:f,dataInicio:p,dataFim:y,sortField:v,sortOrder:S}),oe=localStorage.getItem("SCOREODONTO_AUTH_TOKEN"),Q=await fetch(`/api/guias?${ne}`,{headers:oe?{Authorization:`Bearer ${oe}`}:{}});if(!Q.ok)throw new Error("Falha ao carregar guias");return Q.json()},{data:A,isLoading:k,isError:_,refetch:B}=kU({queryKey:["guias",t,R,C,f,p,y,v,S],queryFn:O,placeholderData:ne=>ne}),F=ne=>{v===ne?j(S==="ASC"?"DESC":"ASC"):(N(ne),j("DESC"))},G=A?Math.ceil(A.total/n):0,ee=()=>{if(!(A!=null&&A.data))return;const ne=["Data Solicitação","Identificação","Beneficiário","Tipo Tratamento","GTO","Situação"],oe=A.data.map(H=>[Up(gN(H.dataSolicitacao),"dd/MM/yyyy"),H.beneficiarioIdentificacao,H.beneficiarioNome,H.tipoTratamento,H.numeroGuiaPrestador,H.status]),Q="data:text/csv;charset=utf-8,"+ne.join(",")+` `+oe.map(H=>H.join(",")).join(` `),ce=encodeURI(Q),he=document.createElement("a");he.setAttribute("href",ce),he.setAttribute("download",`tratamentos_${Up(new Date,"yyyyMMdd")}.csv`),document.body.appendChild(he),he.click(),document.body.removeChild(he)};return s.jsxs("div",{className:"flex flex-col h-full space-y-4",children:[s.jsx(cn,{title:"Meus Tratamentos",description:"LISTAGEM E GESTÃO DE GUIAS DE TRATAMENTO ODONTOLÓGICO (GTO).",children:s.jsxs("button",{onClick:ee,className:"flex items-center gap-2 px-4 py-2 bg-gray-800 text-white rounded-lg hover:bg-gray-700 transition-colors text-sm font-bold uppercase shadow-sm",children:[s.jsx(Og,{size:18})," Exportar CSV"]})}),s.jsxs("div",{className:"bg-white p-6 rounded-xl border border-gray-200 shadow-sm space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap items-end gap-4",children:[s.jsxs("div",{className:"flex-1 min-w-[200px]",children:[s.jsx("label",{className:"block text-[10px] font-bold text-gray-400 uppercase mb-1",children:"Status da Guia"}),s.jsxs("select",{value:f,onChange:ne=>{h(ne.target.value),e(1)},className:"w-full px-4 py-2 bg-gray-50 border border-gray-200 rounded-lg focus:ring-2 focus:ring-blue-500 outline-none text-sm font-semibold uppercase",children:[s.jsx("option",{value:"",children:"TODOS OS STATUS"}),s.jsx("option",{value:"AUTORIZADO",children:"AUTORIZADO"}),s.jsx("option",{value:"AUTORIZADO_PARCIAL",children:"AUTORIZADO PARCIALMENTE"}),s.jsx("option",{value:"NEGADO",children:"NEGADO"}),s.jsx("option",{value:"EM_ANALISE",children:"EM ANÁLISE"}),s.jsx("option",{value:"CANCELADO",children:"CANCELADO"})]})]}),s.jsxs("div",{className:"w-48",children:[s.jsx("label",{className:"block text-[10px] font-bold text-gray-400 uppercase mb-1",children:"GTO (Número)"}),s.jsxs("div",{className:"relative",children:[s.jsx(mu,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400",size:16}),s.jsx("input",{type:"text",placeholder:"EX: 177903",value:c,onChange:ne=>{d(ne.target.value),e(1)},className:"w-full pl-10 pr-4 py-2 bg-gray-50 border border-gray-200 rounded-lg focus:ring-2 focus:ring-blue-500 outline-none text-sm font-semibold uppercase"})]})]}),s.jsxs("div",{className:"flex-1 min-w-[300px]",children:[s.jsx("label",{className:"block text-[10px] font-bold text-gray-400 uppercase mb-1",children:"Pesquisar Beneficiário"}),s.jsxs("div",{className:"relative",children:[s.jsx(ha,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400",size:16}),s.jsx("input",{type:"text",placeholder:"DIGITE NOME OU IDENTIFICAÇÃO...",value:r,onChange:ne=>{i(ne.target.value.toUpperCase()),e(1)},className:"w-full pl-10 pr-4 py-2 bg-gray-50 border border-gray-200 rounded-lg focus:ring-2 focus:ring-blue-500 outline-none text-sm font-semibold uppercase"})]})]})]}),s.jsxs("div",{className:"flex items-center gap-4 pt-2 border-t border-gray-50",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Et,{size:16,className:"text-gray-400"}),s.jsx("input",{type:"date",value:p,onChange:ne=>{b(ne.target.value),e(1)},className:"px-3 py-1.5 bg-gray-50 border border-gray-200 rounded-lg text-xs font-semibold"}),s.jsx("span",{className:"text-gray-400 font-bold text-xs uppercase",children:"até"}),s.jsx("input",{type:"date",value:y,onChange:ne=>{m(ne.target.value),e(1)},className:"px-3 py-1.5 bg-gray-50 border border-gray-200 rounded-lg text-xs font-semibold"})]}),s.jsx("button",{onClick:()=>{i(""),d(""),h(""),b(""),m(""),e(1)},className:"text-[10px] font-bold text-blue-600 hover:text-blue-800 uppercase",children:"Limpar Filtros"})]})]}),s.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 shadow-sm overflow-hidden flex-1 flex flex-col min-h-[400px]",children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-left",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[s.jsx("th",{className:"px-6 py-4",children:s.jsxs("button",{onClick:()=>F("dataSolicitacao"),className:"flex items-center gap-2 text-[11px] font-extrabold text-gray-500 uppercase tracking-wider hover:text-blue-600 transition-colors",children:["Data Solicitação ",s.jsx(od,{size:14})]})}),s.jsx("th",{className:"px-6 py-4",children:s.jsx("span",{className:"text-[11px] font-extrabold text-gray-500 uppercase tracking-wider",children:"Identificação do Beneficiário"})}),s.jsx("th",{className:"px-6 py-4",children:s.jsxs("button",{onClick:()=>F("beneficiarioNome"),className:"flex items-center gap-2 text-[11px] font-extrabold text-gray-500 uppercase tracking-wider hover:text-blue-600 transition-colors",children:["Nome Beneficiário ",s.jsx(od,{size:14})]})}),s.jsx("th",{className:"px-6 py-4",children:s.jsx("span",{className:"text-[11px] font-extrabold text-gray-500 uppercase tracking-wider",children:"Tipo Tratamento"})}),s.jsx("th",{className:"px-6 py-4",children:s.jsxs("button",{onClick:()=>F("numeroGuiaPrestador"),className:"flex items-center gap-2 text-[11px] font-extrabold text-gray-500 uppercase tracking-wider hover:text-blue-600 transition-colors",children:["GTO ",s.jsx(od,{size:14})]})}),s.jsx("th",{className:"px-6 py-4",children:s.jsxs("button",{onClick:()=>F("status"),className:"flex items-center gap-2 text-[11px] font-extrabold text-gray-500 uppercase tracking-wider hover:text-blue-600 transition-colors",children:["Situação da GTO ",s.jsx(od,{size:14})]})})]})}),s.jsx("tbody",{className:"divide-y divide-gray-100",children:k?Array.from({length:5}).map((ne,oe)=>s.jsx("tr",{className:"animate-pulse",children:s.jsx("td",{colSpan:6,className:"px-6 py-4 h-16 bg-gray-50/30"})},oe)):_?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-6 py-12 text-center text-red-500 font-bold uppercase",children:"Erro ao carregar dados."})}):(A==null?void 0:A.data.length)===0?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-6 py-12 text-center text-gray-400 font-bold uppercase",children:"Nenhum tratamento encontrado."})}):A==null?void 0:A.data.map(ne=>s.jsxs("tr",{className:"hover:bg-blue-50/50 transition-colors cursor-pointer group",children:[s.jsx("td",{className:"px-6 py-4 text-sm font-semibold text-gray-700",children:Up(gN(ne.dataSolicitacao),"dd/MM/yyyy")}),s.jsx("td",{className:"px-6 py-4 text-sm font-bold text-blue-600 group-hover:underline",children:ne.beneficiarioIdentificacao}),s.jsx("td",{className:"px-6 py-4",children:s.jsx("p",{className:"text-sm font-bold text-gray-900 uppercase",children:ne.beneficiarioNome})}),s.jsx("td",{className:"px-6 py-4 text-sm text-gray-600",children:ne.tipoTratamento}),s.jsx("td",{className:"px-6 py-4 text-sm font-bold text-gray-800",children:ne.numeroGuiaPrestador}),s.jsx("td",{className:"px-6 py-4",children:s.jsx(eB,{status:ne.status})})]},ne.id))})]})}),s.jsxs("div",{className:"mt-auto bg-gray-50 px-6 py-4 border-t border-gray-200 flex items-center justify-between",children:[s.jsxs("div",{className:"text-xs font-bold text-gray-500 uppercase",children:["Mostrando ",s.jsx("span",{className:"text-gray-900",children:(A==null?void 0:A.data.length)||0})," de ",s.jsx("span",{className:"text-gray-900",children:(A==null?void 0:A.total)||0})," resultados"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{disabled:t===1,onClick:()=>e(ne=>Math.max(1,ne-1)),className:"p-2 border border-gray-300 rounded-lg hover:bg-white disabled:opacity-30 disabled:hover:bg-transparent transition-colors shadow-sm",children:s.jsx(Bs,{size:16})}),s.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:G},(ne,oe)=>oe+1).map(ne=>s.jsx("button",{onClick:()=>e(ne),className:`w-8 h-8 rounded-lg text-xs font-bold transition-all ${ne===t?"bg-blue-600 text-white shadow-md":"text-gray-600 hover:bg-white border border-transparent hover:border-gray-200"}`,children:ne},ne))}),s.jsx("button",{disabled:t===G,onClick:()=>e(ne=>Math.min(G,ne+1)),className:"p-2 border border-gray-300 rounded-lg hover:bg-white disabled:opacity-30 disabled:hover:bg-transparent transition-colors shadow-sm",children:s.jsx(Ts,{size:16})})]})]})]})]})},Ag="V1.0.6",nB=({onLoginSuccess:t})=>{const[e,n]=w.useState(""),[r,i]=w.useState(""),[c,d]=w.useState(!1),[f,h]=w.useState(""),[p,b]=w.useState(!0);if(w.useEffect(()=>{const m=setTimeout(()=>b(!1),3e3);return()=>clearTimeout(m)},[]),p)return s.jsxs("div",{className:"min-h-screen bg-gray-50 flex flex-col items-center justify-center p-4",children:[s.jsx(Ct,{className:"animate-spin text-blue-600 mb-4",size:48}),s.jsx("h2",{className:"text-gray-500 font-bold uppercase tracking-widest text-sm",children:"Inicializando Sistema..."}),s.jsx("span",{className:"text-gray-400 text-xs mt-2 font-mono font-bold bg-gray-200 px-2 py-1 rounded",children:Ag})]});const y=async m=>{m.preventDefault(),d(!0),h("");try{await J.login(e,r)?t():h("CREDENCIAIS INVÁLIDAS. VERIFIQUE EMAIL E SENHA.")}catch{h("ERRO DE CONEXÃO. TENTE NOVAMENTE.")}finally{d(!1)}};return s.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center p-4",children:s.jsxs("div",{className:"max-w-md w-full bg-white rounded-2xl shadow-xl overflow-hidden border border-gray-100",children:[s.jsxs("div",{className:"bg-blue-600 p-8 text-center",children:[s.jsx("div",{className:"w-16 h-16 bg-white/20 rounded-xl flex items-center justify-center text-white mx-auto backdrop-blur-sm mb-4",children:s.jsx(Er,{size:32})}),s.jsx("h1",{className:"text-2xl font-bold text-white uppercase tracking-wide",children:"SCOREODONTO"}),s.jsx("p",{className:"text-blue-100 text-xs font-bold uppercase mt-1",children:"SISTEMA INTEGRADO POSTGRESQL + GOOGLE"})]}),s.jsxs("div",{className:"p-8",children:[s.jsxs("h2",{className:"text-lg font-bold text-gray-800 uppercase mb-6 text-center flex items-center justify-center gap-2",children:[s.jsx(_d,{size:18,className:"text-blue-600"})," ACESSO RESTRITO"]}),s.jsxs("form",{onSubmit:y,className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-bold text-gray-500 mb-1 uppercase",children:"USUÁRIO / EMAIL"}),s.jsxs("div",{className:"relative",children:[s.jsx(zo,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400",size:18}),s.jsx("input",{type:"email",required:!0,value:e,onChange:m=>n(m.target.value),className:"w-full pl-10 pr-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 outline-none transition-all text-sm font-medium",placeholder:"ex: usuario@email.com"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-bold text-gray-500 mb-1 uppercase",children:"SENHA DE ACESSO"}),s.jsxs("div",{className:"relative",children:[s.jsx(_d,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400",size:18}),s.jsx("input",{type:"password",required:!0,value:r,onChange:m=>i(m.target.value),className:"w-full pl-10 pr-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 outline-none transition-all text-sm font-medium",placeholder:"••••••••"})]})]}),f&&s.jsx("div",{className:"p-3 bg-red-50 text-red-600 text-xs font-bold uppercase rounded-lg border border-red-100 text-center",children:f}),s.jsx("button",{type:"submit",disabled:c,className:"w-full bg-blue-600 hover:bg-blue-700 text-white py-3 rounded-lg font-bold uppercase flex items-center justify-center gap-2 transition-all shadow-lg hover:shadow-xl disabled:opacity-70 disabled:cursor-not-allowed mt-4",children:c?s.jsx("span",{children:"VERIFICANDO..."}):s.jsxs(s.Fragment,{children:["ENTRAR NO SISTEMA ",s.jsx(Ls,{size:18})]})})]}),s.jsxs("div",{className:"mt-8 flex flex-col items-center justify-center gap-2 text-gray-400 text-[10px] font-bold uppercase",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(Sr,{size:12})," AMBIENTE SEGURO E CRIPTOGRAFADO"]}),s.jsx("span",{className:"bg-gray-100 text-gray-500 px-2 py-1 rounded font-mono",children:Ag})]})]})]})})},jd=({icon:t,title:e,description:n})=>s.jsxs("div",{className:"bg-white/70 backdrop-blur-md p-8 rounded-3xl border border-white/50 shadow-[0_8px_30px_rgb(0,0,0,0.04)] hover:shadow-[0_20px_50px_rgba(8,112,184,0.1)] transition-all duration-500 group",children:[s.jsx("div",{className:"w-14 h-14 bg-blue-600/10 rounded-2xl flex items-center justify-center mb-6 group-hover:bg-blue-600 group-hover:text-white transition-all duration-500 text-blue-600",children:t}),s.jsx("h3",{className:"text-xl font-bold text-gray-900 mb-3 uppercase tracking-tight",children:e}),s.jsx("p",{className:"text-gray-600 leading-relaxed text-sm",children:n})]}),aB=({onGetStarted:t})=>{const[e,n]=w.useState(!1),[r,i]=w.useState(!1);return w.useEffect(()=>{const c=()=>n(window.scrollY>20);return window.addEventListener("scroll",c),()=>window.removeEventListener("scroll",c)},[]),s.jsxs("div",{className:"min-h-screen bg-[#F8FAFC] font-sans selection:bg-blue-100 selection:text-blue-900 overflow-x-hidden",children:[s.jsx("nav",{className:`fixed top-0 left-0 right-0 z-[100] transition-all duration-500 ${e?"bg-white/80 backdrop-blur-xl border-b border-gray-100 py-3 shadow-sm":"bg-transparent py-6"}`,children:s.jsxs("div",{className:"max-w-7xl mx-auto px-6 flex justify-between items-center",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-10 h-10 bg-gradient-to-tr from-blue-600 to-indigo-600 rounded-xl flex items-center justify-center shadow-lg shadow-blue-200",children:s.jsx(ua,{className:"text-white",size:24})}),s.jsxs("span",{className:"text-2xl font-black text-gray-900 tracking-tighter uppercase italic",children:["Score",s.jsx("span",{className:"text-blue-600",children:"Odonto"})]})]}),s.jsxs("div",{className:"hidden md:flex items-center gap-8",children:[s.jsx("a",{href:"#features",className:"text-sm font-bold text-gray-600 hover:text-blue-600 transition-colors uppercase tracking-widest",children:"Recursos"}),s.jsx("a",{href:"#solutions",className:"text-sm font-bold text-gray-600 hover:text-blue-600 transition-colors uppercase tracking-widest",children:"Soluções"}),s.jsx("a",{href:"#mobile",className:"text-sm font-bold text-gray-600 hover:text-blue-600 transition-colors uppercase tracking-widest",children:"Mobile"}),s.jsx("button",{onClick:t,className:"bg-gray-900 text-white px-6 py-3 rounded-full text-xs font-black uppercase tracking-widest hover:bg-blue-600 hover:shadow-xl hover:shadow-blue-200 transition-all active:scale-95",children:"Começar Agora"})]}),s.jsx("button",{className:"md:hidden p-2 text-gray-900",onClick:()=>i(!r),children:r?s.jsx(Qe,{size:28}):s.jsx(VN,{size:28})})]})}),s.jsxs("section",{className:"relative pt-32 pb-20 lg:pt-48 lg:pb-40 overflow-hidden",children:[s.jsx("div",{className:"absolute top-0 right-0 w-1/2 h-full bg-gradient-to-l from-blue-50/50 to-transparent -z-10 translate-x-20 skew-x-12"}),s.jsx("div",{className:"absolute top-40 left-10 w-72 h-72 bg-blue-400/10 rounded-full blur-3xl -z-10"}),s.jsx("div",{className:"max-w-7xl mx-auto px-6",children:s.jsxs("div",{className:"grid lg:grid-cols-2 gap-16 items-center",children:[s.jsxs("div",{className:"space-y-8",children:[s.jsxs("h1",{className:"text-6xl lg:text-7xl font-black text-gray-900 leading-[1.05] tracking-tighter",children:["O Futuro da Sua Clínica é ",s.jsx("span",{className:"text-transparent bg-clip-text bg-gradient-to-r from-blue-600 to-indigo-600 underline decoration-blue-200 underline-offset-8",children:"Inteligente"})]}),s.jsx("p",{className:"text-xl text-gray-600 leading-relaxed max-w-lg font-medium",children:"Maximize a produtividade com gestão financeira, agenda com arraste e solte, e controle absoluto de tratamentos em uma plataforma única e elegante."}),s.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[s.jsxs("button",{onClick:t,className:"bg-blue-600 text-white px-10 py-5 rounded-2xl text-sm font-black uppercase tracking-widest shadow-2xl shadow-blue-200 hover:bg-blue-700 hover:-translate-y-1 transition-all flex items-center justify-center gap-3 group",children:["Acessar Plataforma ",s.jsx(Ls,{size:18,className:"group-hover:translate-x-1 transition-transform"})]}),s.jsxs("div",{className:"flex items-center gap-4 py-2 px-4",children:[s.jsx("div",{className:"flex -space-x-3",children:[1,2,3,4].map(c=>s.jsx("div",{className:"w-10 h-10 rounded-full border-2 border-white bg-gray-200 flex items-center justify-center text-[10px] font-bold overflow-hidden shadow-sm",children:s.jsx("img",{src:`https://i.pravatar.cc/100?img=${c+10}`,alt:"User"})},c))}),s.jsxs("div",{className:"text-xs text-gray-500 font-bold uppercase tracking-tight",children:[s.jsx("span",{className:"text-gray-900",children:"+400 Clínicas"})," ",s.jsx("br",{})," que já otimizaram processos"]})]})]})]}),s.jsxs("div",{className:"relative",children:[s.jsxs("div",{className:"relative z-10 rounded-[3rem] overflow-hidden shadow-[0_50px_100px_-20px_rgba(0,0,0,0.2)] border-8 border-white group",children:[s.jsx("img",{src:"/dental_landing_hero.png",alt:"Interface ScoreOdonto",className:"w-full h-auto transform group-hover:scale-105 transition-all duration-700",onError:c=>{c.target.src="https://images.unsplash.com/photo-1594832284143-588b813ed334?q=80&w=2070&auto=format&fit=crop"}}),s.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/40 to-transparent flex items-bottom p-10 opacity-0 group-hover:opacity-100 transition-opacity duration-500",children:s.jsx("p",{className:"mt-auto text-white font-bold uppercase text-xs tracking-widest",children:"Interface Real: Dashboard Analítico"})})]}),s.jsx("div",{className:"absolute -top-10 -right-10 z-20 bg-white p-6 rounded-3xl shadow-2xl border border-blue-50 animate-bounce transition-all duration-1000 hidden md:block",style:{animationDelay:"0.2s"},children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"p-3 bg-blue-100 text-blue-600 rounded-2xl",children:s.jsx(Et,{size:24})}),s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Sincronização Total"}),s.jsx("div",{className:"text-lg font-black text-gray-900 tracking-tight",children:"Google Agenda"})]})]})}),s.jsx("div",{className:"absolute -bottom-10 -left-10 z-20 bg-white p-6 rounded-3xl shadow-2xl border border-green-50 animate-bounce transition-all duration-1000",children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"p-3 bg-green-100 text-green-600 rounded-2xl",children:s.jsx(TD,{size:24})}),s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Comunicação"}),s.jsx("div",{className:"text-lg font-black text-gray-900 tracking-tight",children:"CRM WhatsApp"})]})]})})]})]})})]}),s.jsx("div",{className:"bg-white border-y border-gray-100 py-10",children:s.jsxs("div",{className:"max-w-7xl mx-auto px-6 overflow-hidden",children:[s.jsx("p",{className:"text-center text-[10px] font-black text-gray-400 uppercase tracking-[0.3em] mb-10",children:"Conectado com os principais convênios"}),s.jsxs("div",{className:"flex justify-between items-center opacity-30 grayscale gap-10",children:[s.jsx("span",{className:"text-2xl font-black italic",children:"CASSEMS"}),s.jsx("span",{className:"text-2xl font-black italic",children:"UNIMED"}),s.jsx("span",{className:"text-2xl font-black italic",children:"BRADESCO"}),s.jsx("span",{className:"text-2xl font-black italic",children:"SULAMÉRICA"}),s.jsx("span",{className:"text-2xl font-black italic",children:"AMIL DENTAL"}),s.jsx("span",{className:"text-2xl font-black italic",children:"REDE DENTAL"})]})]})}),s.jsx("section",{id:"features",className:"py-32 px-6",children:s.jsxs("div",{className:"max-w-7xl mx-auto",children:[s.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-20 space-y-4",children:[s.jsx("h2",{className:"text-4xl lg:text-5xl font-black text-gray-900 leading-tight tracking-tighter uppercase",children:"Todo o Controle na Sua Mão"}),s.jsx("p",{className:"text-lg text-gray-600 font-medium",children:"Focamos na tecnologia para que você foque no que mais importa: o sorriso do seu paciente."})]}),s.jsxs("div",{className:"grid md:grid-cols-2 lg:grid-cols-4 gap-8",children:[s.jsx(jd,{icon:s.jsx(Et,{size:28}),title:"Agenda 4.0",description:"Controle total com arraste e solte, cores por profissional e sincronização em tempo real."}),s.jsx(jd,{icon:s.jsx(Sr,{size:28}),title:"GTO Segura",description:"Lançamento simplificado de guias de convênio com validação automática de erros."}),s.jsx(jd,{icon:s.jsx($n,{size:28}),title:"Gestão de Pacientes",description:"CRM odontológico completo com histórico clínico, anexos e ortodontia avançada."}),s.jsx(jd,{icon:s.jsx(ko,{size:28}),title:"BI Financeiro",description:"Gráficos de produtividade, fluxo de caixa e gestão de taxas de operadoras."})]})]})}),s.jsx("section",{className:"py-20 px-6",children:s.jsxs("div",{className:"max-w-7xl mx-auto bg-gradient-to-br from-blue-600 to-indigo-700 rounded-[3rem] p-12 lg:p-24 overflow-hidden relative shadow-2xl shadow-blue-300",children:[s.jsx("div",{className:"absolute top-0 right-0 w-96 h-96 bg-white/10 rounded-full -translate-y-1/2 translate-x-1/2 blur-3xl"}),s.jsx("div",{className:"absolute bottom-0 left-0 w-64 h-64 bg-black/10 rounded-full translate-y-1/2 -translate-x-1/2 blur-3xl"}),s.jsxs("div",{className:"relative z-10 text-center space-y-8 max-w-3xl mx-auto",children:[s.jsxs("h2",{className:"text-4xl lg:text-6xl font-black text-white leading-tight tracking-tighter uppercase italic",children:["Sua Clínica Elevada ao ",s.jsx("span",{className:"bg-white text-blue-600 px-4 py-1 rounded-2xl not-italic",children:"Próximo Nível"})]}),s.jsx("p",{className:"text-blue-100 text-xl font-medium",children:"Junte-se a centenas de profissionais que já transformaram a gestão de seus consultórios. Comece agora gratuitamente."}),s.jsx("div",{className:"pt-6",children:s.jsx("button",{onClick:t,className:"bg-white text-blue-600 px-12 py-6 rounded-3xl text-sm font-black uppercase tracking-widest shadow-xl hover:bg-gray-50 hover:-translate-y-1 transition-all active:scale-95",children:"Testar Demonstrativo"})})]})]})}),s.jsxs("footer",{className:"py-20 border-t border-gray-100 bg-white",children:[s.jsxs("div",{className:"max-w-7xl mx-auto px-6 grid md:grid-cols-4 gap-12",children:[s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-8 h-8 bg-blue-600 rounded-lg flex items-center justify-center",children:s.jsx(ua,{className:"text-white",size:18})}),s.jsxs("span",{className:"text-xl font-black text-gray-900 tracking-tighter uppercase italic",children:["Score",s.jsx("span",{className:"text-blue-600",children:"Odonto"})]})]}),s.jsx("p",{className:"text-gray-500 text-sm leading-relaxed",children:"A plataforma líder em gestão odontológica para clínicas que buscam excelência e eficiência."}),s.jsxs("div",{className:"flex gap-4",children:[s.jsx("div",{className:"w-8 h-8 bg-gray-100 rounded-full hover:bg-blue-600 hover:text-white transition-all flex items-center justify-center cursor-pointer",children:s.jsx(cO,{size:16})}),s.jsx("div",{className:"w-8 h-8 bg-gray-100 rounded-full hover:bg-blue-600 hover:text-white transition-all flex items-center justify-center cursor-pointer",children:s.jsx($n,{size:16})}),s.jsx("div",{className:"w-8 h-8 bg-gray-100 rounded-full hover:bg-blue-600 hover:text-white transition-all flex items-center justify-center cursor-pointer",children:s.jsx(MO,{size:16})})]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsx("h4",{className:"text-xs font-black text-gray-900 uppercase tracking-widest",children:"Produto"}),s.jsxs("ul",{className:"space-y-3 text-sm text-gray-500 font-bold uppercase tracking-tight",children:[s.jsx("li",{className:"hover:text-blue-600 cursor-pointer transition-colors",children:"Funcionalidades"}),s.jsx("li",{className:"hover:text-blue-600 cursor-pointer transition-colors",children:"Segurança"}),s.jsx("li",{className:"hover:text-blue-600 cursor-pointer transition-colors",children:"API"}),s.jsx("li",{className:"hover:text-blue-600 cursor-pointer transition-colors",children:"Mobile"})]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsx("h4",{className:"text-xs font-black text-gray-900 uppercase tracking-widest",children:"Empresa"}),s.jsxs("ul",{className:"space-y-3 text-sm text-gray-500 font-bold uppercase tracking-tight",children:[s.jsx("li",{className:"hover:text-blue-600 cursor-pointer transition-colors",children:"Sobre Nós"}),s.jsx("li",{className:"hover:text-blue-600 cursor-pointer transition-colors",children:"Blog"}),s.jsx("li",{className:"hover:text-blue-600 cursor-pointer transition-colors",children:"Carreiras"}),s.jsx("li",{className:"hover:text-blue-600 cursor-pointer transition-colors",children:"Contato"})]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsx("h4",{className:"text-xs font-black text-gray-900 uppercase tracking-widest",children:"Suporte"}),s.jsxs("div",{className:"p-4 bg-gray-50 rounded-2xl border border-gray-100",children:[s.jsx("p",{className:"text-xs text-gray-500 font-bold uppercase mb-2",children:"Central de Ajuda"}),s.jsx("a",{href:"mailto:suporte@scoreodonto.com",className:"text-sm font-black text-blue-600 hover:underline",children:"suporte@scoreodonto.com"})]})]})]}),s.jsxs("div",{className:"max-w-7xl mx-auto px-6 mt-20 pt-10 border-t border-gray-50 flex flex-col md:flex-row justify-between items-center gap-6",children:[s.jsx("p",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"© 2026 ScoreOdonto. Todos os direitos reservados."}),s.jsxs("div",{className:"flex gap-8 text-[10px] font-black text-gray-400 uppercase tracking-widest",children:[s.jsx("span",{className:"hover:text-gray-900 cursor-pointer",children:"Termos"}),s.jsx("span",{className:"hover:text-gray-900 cursor-pointer",children:"Privacidade"}),s.jsx("span",{className:"hover:text-gray-900 cursor-pointer",children:"Cookies"})]})]})]})]})},sB=()=>{const[t,e]=w.useState(!1),[n,r]=w.useState([]),[i,c]=w.useState(!1),d=async()=>{e(!0),r([]),c(!1),await J.runInstallScript(h=>{r(p=>[...p,h])}),c(!0),e(!1)},f=()=>{window.location.href="./"};return s.jsx("div",{className:"min-h-screen bg-gray-900 flex items-center justify-center p-4",children:s.jsxs("div",{className:"w-full max-w-2xl bg-white rounded-xl shadow-2xl overflow-hidden",children:[s.jsxs("div",{className:"bg-gray-100 p-6 border-b border-gray-200 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"w-12 h-12 bg-blue-600 rounded-lg flex items-center justify-center text-white",children:s.jsx(Er,{size:24})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-bold text-gray-900 uppercase",children:"SCOREODONTO ADMIN"}),s.jsx("p",{className:"text-gray-500 text-xs font-bold uppercase",children:"FERRAMENTA DE ATUALIZAÇÃO DE BANCO"})]})]}),s.jsxs("button",{onClick:f,className:"text-gray-500 hover:text-gray-800 flex items-center gap-1 text-xs font-bold uppercase",children:[s.jsx(MN,{size:16})," VOLTAR AO SISTEMA"]})]}),s.jsx("div",{className:"p-8",children:!t&&n.length===0?s.jsxs("div",{className:"text-center space-y-6",children:[s.jsx("div",{className:"w-20 h-20 bg-amber-100 text-amber-600 rounded-full flex items-center justify-center mx-auto",children:s.jsx(rv,{size:40})}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-bold text-gray-800 uppercase",children:"SCRIPT DE ATUALIZAÇÃO (SH/UPDATE_DB.SH)"}),s.jsx("p",{className:"text-gray-500 text-sm mt-2 max-w-md mx-auto uppercase",children:'ESTA AÇÃO IRÁ LER A PLANILHA "DADOS PACIENTES", GERAR UM BACKUP SQL E ATUALIZAR AS TABELAS DO POSTGRESQL.'})]}),s.jsx("div",{className:"bg-gray-800 text-green-400 p-4 rounded-lg font-mono text-sm text-left max-w-md mx-auto shadow-inner",children:"$ ./sh/update_db.sh --force-sync"}),s.jsxs("button",{onClick:d,className:"bg-blue-600 hover:bg-blue-700 text-white px-8 py-4 rounded-lg font-bold uppercase flex items-center gap-3 mx-auto transition-all hover:scale-105 shadow-lg",children:[s.jsx(VD,{size:20,fill:"currentColor"}),"EXECUTAR ATUALIZAÇÃO"]})]}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex justify-between items-center mb-2",children:[s.jsxs("h3",{className:"font-bold text-gray-800 uppercase flex items-center gap-2",children:[s.jsx(rv,{size:18})," TERMINAL DE SAÍDA"]}),i&&s.jsxs("span",{className:"text-green-600 text-xs font-bold uppercase flex items-center gap-1",children:[s.jsx(Ua,{size:14})," PROCESSO FINALIZADO"]})]}),s.jsxs("div",{className:"bg-gray-900 text-green-500 font-mono text-xs p-6 rounded-lg h-80 overflow-y-auto shadow-inner border-4 border-gray-800",children:[n.map((h,p)=>s.jsx("div",{className:"mb-1",children:h},p)),t&&s.jsx("div",{className:"animate-pulse mt-2",children:"_"})]}),i&&s.jsx("button",{onClick:f,className:"w-full py-3 bg-gray-200 hover:bg-gray-300 text-gray-800 font-bold rounded-lg uppercase transition-colors",children:"VOLTAR PARA O LOGIN"})]})})]})})},xN=[{name:"Azul Score",value:"#2563eb"},{name:"Verde Esmeralda",value:"#059669"},{name:"Indigo Premium",value:"#4f46e5"},{name:"Vinho Elegante",value:"#9f1239"},{name:"Slate Moderno",value:"#334155"},{name:"Laranja Vibrante",value:"#ea580c"},{name:"Teal Clínico",value:"#0d9488"},{name:"Roxo Nobre",value:"#7c3aed"}],rB=()=>{const t=J.getWorkspaces(),e=J.getActiveWorkspace(),n=Fe(),r=J.getCurrentRole(),i=r==="admin"||r==="donoclinica",[c,d]=w.useState(null),[f,h]=w.useState(!1),p=y=>{if((e==null?void 0:e.id)===y){n.info("VOCÊ JÁ ESTÁ NESTA UNIDADE.");return}J.switchWorkspace(y),n.success("TROCANDO DE UNIDADE...")},b=async(y,m)=>{h(!0);try{const v=localStorage.getItem("SCOREODONTO_AUTH_TOKEN");if((await fetch(`/api/clinicas/${y}/color`,{method:"PUT",headers:{"Content-Type":"application/json",...v?{Authorization:`Bearer ${v}`}:{}},body:JSON.stringify({cor:m})})).ok){n.success("COR DA UNIDADE ATUALIZADA!");const S=t.map(j=>j.id===y?{...j,cor:m}:j);localStorage.setItem("SCOREODONTO_WORKSPACES",JSON.stringify(S)),(e==null?void 0:e.id)===y&&localStorage.setItem("SCOREODONTO_ACTIVE_WORKSPACE",JSON.stringify({...e,cor:m})),d(null),setTimeout(()=>window.location.reload(),1e3)}else n.error("ERRO AO SALVAR COR.")}catch{n.error("ERRO DE CONEXÃO.")}finally{h(!1)}};return s.jsxs("div",{className:"space-y-10 animate-in fade-in duration-500",children:[s.jsx(cn,{title:"GESTÃO DE UNIDADES",description:"Configure a identidade visual e selecione a clínica para gerenciar atendimentos."}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8",children:t.map(y=>{const m=(e==null?void 0:e.id)===y.id,v=y.cor||"#2563eb";return s.jsx("div",{className:`group relative bg-white rounded-[2.5rem] p-1 border-2 transition-all duration-500 ${m?"shadow-[0_20px_50px_-15px_rgba(0,0,0,0.1)]":"border-transparent hover:border-gray-100 shadow-[0_10px_40px_-15px_rgba(0,0,0,0.05)]"}`,style:{borderColor:m?v:"transparent"},children:s.jsxs("div",{className:"px-8 py-10 rounded-[2.2rem] bg-white h-full flex flex-col",children:[s.jsxs("div",{className:"flex justify-between items-start mb-8",children:[s.jsx("div",{className:"w-16 h-16 rounded-2xl flex items-center justify-center transition-all duration-500 group-hover:scale-110 shadow-lg",style:{backgroundColor:v,color:"#fff",boxShadow:`0 10px 20px -5px ${v}44`},children:s.jsx(Cg,{size:32})}),s.jsxs("div",{className:"flex flex-col items-end gap-2",children:[m&&s.jsx("span",{className:"text-white text-[9px] font-black px-4 py-1.5 rounded-full uppercase tracking-widest shadow-sm",style:{backgroundColor:v},children:"ATIVA"}),i&&s.jsx("button",{onClick:()=>d(c===y.id?null:y.id),className:"p-2 text-gray-400 hover:text-gray-600 bg-gray-50 rounded-xl transition-colors",title:"Mudar Cor",children:s.jsx(zD,{size:16})})]})]}),s.jsxs("div",{className:"space-y-2 flex-grow",children:[s.jsx("h3",{className:"text-2xl font-black text-gray-900 uppercase tracking-tighter leading-tight",children:y.nome}),c===y.id?s.jsxs("div",{className:"mt-4 p-4 bg-gray-50 rounded-2xl border border-gray-100 animate-in slide-in-from-top-2 duration-300",children:[s.jsx("p",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest mb-3",children:"Escolha a cor da marca"}),s.jsx("div",{className:"grid grid-cols-4 gap-2",children:xN.map(N=>s.jsx("button",{onClick:()=>b(y.id,N.value),disabled:f,className:`w-full h-8 rounded-lg border-2 transition-all ${y.cor===N.value?"border-white ring-2 ring-gray-300":"border-transparent hover:scale-110"}`,style:{backgroundColor:N.value},title:N.name,children:f&&y.cor===N.value&&s.jsx(Ct,{size:12,className:"animate-spin text-white mx-auto"})},N.value))})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2 text-gray-400",children:[s.jsx(HN,{size:14}),s.jsx("span",{className:"text-[10px] font-bold uppercase tracking-widest",children:"Unidade Operacional"})]}),s.jsxs("div",{className:"mt-6 pt-6 border-t border-gray-50 flex items-center gap-3",children:[s.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center",style:{backgroundColor:`${v}11`,color:v},children:s.jsx(iO,{size:16})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest leading-none mb-1",children:"Seu Perfil"}),s.jsx("p",{className:"text-xs font-bold text-gray-700 uppercase",children:y.role})]})]})]})]}),s.jsx("button",{onClick:()=>p(y.id),disabled:m||c===y.id,className:"mt-10 w-full py-4 rounded-2xl text-xs font-black uppercase tracking-widest transition-all duration-300 flex items-center justify-center gap-3 group/btn shadow-lg",style:{backgroundColor:m?"#f3f4f6":v,color:m?"#9ca3af":"#fff",boxShadow:m?"none":`0 10px 20px -10px ${v}66`},children:m?s.jsxs(s.Fragment,{children:["UNIDADE ATUAL ",s.jsx(mC,{size:18})]}):s.jsxs(s.Fragment,{children:["ACESSAR UNIDADE ",s.jsx(Ls,{size:18,className:"group-hover/btn:translate-x-1 transition-transform"})]})})]})},y.id)})}),s.jsxs("div",{className:"bg-white rounded-[2rem] p-10 border border-gray-100 flex flex-col md:flex-row items-center justify-between gap-6 shadow-sm",children:[s.jsxs("div",{className:"text-center md:text-left",children:[s.jsx("h4",{className:"text-lg font-black text-gray-900 uppercase tracking-tight italic",children:"Identidade Visual Dinâmica"}),s.jsx("p",{className:"text-sm text-gray-500 font-medium",children:"A cor escolhida será aplicada automaticamente em toda a interface desta clínica."})]}),s.jsx("div",{className:"flex gap-2",children:xN.slice(0,4).map(y=>s.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:y.value}},y.value))})]})]})},lB=()=>{const[t,e]=w.useState(1),[n,r]=w.useState(!1),i=Fe(),c=new URLSearchParams(window.location.search),d=c.get("clinica"),f=c.get("nome"),h=c.get("token"),[p,b]=w.useState({nome:f||"",email:"",senha:"",cro:"",cro_uf:"MS",celular:"",especialidade:""});if(!h||!d)return s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 p-4",children:s.jsxs("div",{className:"text-center space-y-4",children:[s.jsx("div",{className:"w-20 h-20 bg-red-50 text-red-500 rounded-full flex items-center justify-center mx-auto shadow-sm",children:s.jsx(_d,{size:40})}),s.jsx("h2",{className:"text-2xl font-black text-gray-900 uppercase",children:"LINK INVÁLIDO OU EXPIRADO"}),s.jsx("p",{className:"text-gray-500 max-w-sm mx-auto font-medium",children:"Por favor, solicite um novo convite ao administrador da clínica."})]})});const y=async m=>{m.preventDefault(),r(!0);try{(await fetch("/api/dentistas/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...p,id:"d_"+Math.random().toString(36).substring(2,9),clinicaId:d})})).ok?(i.success("CADASTRO REALIZADO COM SUCESSO!"),e(3)):i.error("ERRO AO REALIZAR CADASTRO.")}catch{i.error("FALHA DE CONEXÃO.")}finally{r(!1)}};return s.jsx("div",{className:"min-h-screen bg-[#F8FAFC] flex items-center justify-center p-4",children:s.jsxs("div",{className:"max-w-xl w-full",children:[s.jsxs("div",{className:"mb-10 text-center space-y-2",children:[s.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-1.5 bg-blue-50 text-blue-600 rounded-full text-[10px] font-black uppercase tracking-widest border border-blue-100 mb-4",children:[s.jsx(Sr,{size:14})," Convite de Profissional"]}),s.jsx("h1",{className:"text-4xl font-black text-gray-900 tracking-tighter uppercase leading-none",children:"Complete seu Perfil"}),s.jsxs("p",{className:"text-gray-500 font-medium",children:["Bem-vindo ao SCOREODONTO. Você está sendo convidado para a unidade: ",s.jsx("span",{className:"text-blue-600 font-bold uppercase",children:d})]})]}),s.jsxs("div",{className:"bg-white rounded-[2.5rem] shadow-[0_50px_100px_-20px_rgba(0,0,0,0.08)] border border-gray-100 overflow-hidden relative",children:[s.jsx("div",{className:"h-2 bg-gray-100 w-full",children:s.jsx("div",{className:"h-full bg-blue-600 transition-all duration-700",style:{width:`${t/3*100}%`}})}),t===1&&s.jsx("div",{className:"p-10 animate-in fade-in slide-in-from-right-10 duration-500",children:s.jsxs("form",{className:"space-y-6",onSubmit:m=>{m.preventDefault(),e(2)},children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-1 mb-2 block",children:"Seu Nome Profissional"}),s.jsxs("div",{className:"relative group",children:[s.jsx(zo,{className:"absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 group-focus-within:text-blue-500 transition-colors",size:20}),s.jsx("input",{required:!0,value:p.nome,onChange:m=>b({...p,nome:m.target.value.toUpperCase()}),className:"w-full bg-gray-50 border border-transparent focus:border-blue-500 focus:bg-white px-12 py-4 rounded-2xl outline-none transition-all font-bold text-gray-800 uppercase",placeholder:"NOME COMPLETO"})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-1 mb-2 block",children:"Email de Acesso"}),s.jsxs("div",{className:"relative group",children:[s.jsx(Rg,{className:"absolute left-4 top-1/2 -translate-y-1/2 text-gray-400",size:20}),s.jsx("input",{type:"email",required:!0,value:p.email,onChange:m=>b({...p,email:m.target.value}),className:"w-full bg-gray-50 border border-transparent focus:border-blue-500 focus:bg-white px-12 py-4 rounded-2xl outline-none transition-all font-bold text-gray-800",placeholder:"seu@email.com"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-1 mb-2 block",children:"Senha de Acesso"}),s.jsxs("div",{className:"relative group",children:[s.jsx(_d,{className:"absolute left-4 top-1/2 -translate-y-1/2 text-gray-400",size:20}),s.jsx("input",{type:"password",required:!0,value:p.senha,onChange:m=>b({...p,senha:m.target.value}),className:"w-full bg-gray-50 border border-transparent focus:border-blue-500 focus:bg-white px-12 py-4 rounded-2xl outline-none transition-all font-bold text-gray-800",placeholder:"••••••••"})]})]})]})]}),s.jsxs("button",{type:"submit",className:"w-full bg-gray-900 text-white py-5 rounded-2xl font-black uppercase tracking-widest hover:bg-blue-600 hover:shadow-2xl hover:shadow-blue-200 transition-all flex items-center justify-center gap-3 active:scale-95",children:["Próximo Passo ",s.jsx(Ls,{size:20})]})]})}),t===2&&s.jsx("div",{className:"p-10 animate-in fade-in slide-in-from-right-10 duration-500",children:s.jsxs("form",{className:"space-y-6",onSubmit:y,children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-1 mb-2 block",children:"Inscrição CRO"}),s.jsxs("div",{className:"relative group",children:[s.jsx(Er,{className:"absolute left-4 top-1/2 -translate-y-1/2 text-gray-400",size:20}),s.jsx("input",{required:!0,value:p.cro,onChange:m=>b({...p,cro:m.target.value}),className:"w-full bg-gray-50 border border-transparent focus:border-blue-500 focus:bg-white px-12 py-4 rounded-2xl outline-none transition-all font-bold text-gray-800 uppercase",placeholder:"00000"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-1 mb-2 block",children:"Estado CRO"}),s.jsxs("select",{value:p.cro_uf,onChange:m=>b({...p,cro_uf:m.target.value}),className:"w-full bg-gray-50 border border-transparent focus:border-blue-500 focus:bg-white px-6 py-4 rounded-2xl outline-none transition-all font-bold text-gray-800",children:[s.jsx("option",{children:"MS"}),s.jsx("option",{children:"SP"}),s.jsx("option",{children:"RJ"}),s.jsx("option",{children:"MG"}),s.jsx("option",{children:"PR"}),s.jsx("option",{children:"SC"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-1 mb-2 block",children:"Especialidade Principal"}),s.jsxs("div",{className:"relative group",children:[s.jsx(ua,{className:"absolute left-4 top-1/2 -translate-y-1/2 text-gray-400",size:20}),s.jsx("input",{required:!0,value:p.especialidade,onChange:m=>b({...p,especialidade:m.target.value.toUpperCase()}),className:"w-full bg-gray-50 border border-transparent focus:border-blue-500 focus:bg-white px-12 py-4 rounded-2xl outline-none transition-all font-bold text-gray-800 uppercase",placeholder:"EX: ORTODONTIA"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-1 mb-2 block",children:"WhatsApp de Contato"}),s.jsxs("div",{className:"relative group",children:[s.jsx(qN,{className:"absolute left-4 top-1/2 -translate-y-1/2 text-gray-400",size:20}),s.jsx("input",{required:!0,value:p.celular,onChange:m=>b({...p,celular:m.target.value}),className:"w-full bg-gray-50 border border-transparent focus:border-blue-500 focus:bg-white px-12 py-4 rounded-2xl outline-none transition-all font-bold text-gray-800 uppercase",placeholder:"(00) 00000-0000"})]})]})]}),s.jsxs("div",{className:"flex gap-4 pt-4",children:[s.jsx("button",{type:"button",onClick:()=>e(1),className:"flex-1 bg-gray-100 text-gray-600 py-5 rounded-2xl font-black uppercase tracking-widest hover:bg-gray-200 transition-all font-bold",children:"Voltar"}),s.jsx("button",{type:"submit",disabled:n,className:"flex-[2] bg-blue-600 text-white py-5 rounded-2xl font-black uppercase tracking-widest hover:bg-blue-700 shadow-xl shadow-blue-200 transition-all flex items-center justify-center gap-3 disabled:opacity-50",children:n?s.jsx(Ct,{className:"animate-spin"}):s.jsxs(s.Fragment,{children:["Finalizar e Entrar ",s.jsx(Ls,{size:20})]})})]})]})}),t===3&&s.jsxs("div",{className:"p-16 text-center animate-in zoom-in duration-500",children:[s.jsx("div",{className:"w-24 h-24 bg-green-50 text-green-500 rounded-[2rem] flex items-center justify-center mx-auto mb-8 shadow-inner ring-1 ring-green-100",children:s.jsx(Sr,{size:48})}),s.jsx("h2",{className:"text-3xl font-black text-gray-900 uppercase tracking-tight mb-4",children:"Tudo Pronto!"}),s.jsxs("p",{className:"text-gray-500 font-medium mb-10",children:["Seu perfil foi criado e você já está vinculado à unidade ",s.jsx("br",{})," ",s.jsx("span",{className:"text-blue-600 font-bold",children:d}),"."]}),s.jsx("button",{onClick:()=>{history.pushState({},"","/login"),window.location.reload()},className:"w-full bg-gray-900 text-white py-5 rounded-2xl font-black uppercase tracking-widest hover:bg-blue-600 shadow-2xl transition-all",children:"Ir para o Login"})]})]}),s.jsxs("div",{className:"mt-8 flex items-center justify-center gap-2 text-gray-400 text-[10px] font-black uppercase tracking-widest",children:[s.jsx(Sr,{size:14})," Ambiente Seguro e Auditorado por Administradores"]})]})})},Mu=({title:t,buttonLabel:e,onButtonClick:n,children:r})=>s.jsxs("div",{className:"space-y-6",children:[s.jsx(cn,{title:t,children:s.jsxs("button",{onClick:n,className:"bg-blue-600 text-white px-4 py-2 rounded-lg flex items-center gap-2 hover:bg-blue-700 font-bold text-xs uppercase transition-colors shadow-sm",children:[s.jsx(ft,{size:18})," ",e]})}),r]}),iB=({dentist:t,clinicaId:e,onClose:n})=>{const{data:r,refresh:i}=_e(()=>J.getHorariosByDentista(t.id,e)),c=Fe(),d=["DOMINGO","SEGUNDA","TERÇA","QUARTA","QUINTA","SEXTA","SÁBADO"],f=async h=>{h.preventDefault();const p=new FormData(h.target);await J.saveHorario({dentista_id:t.id,clinica_id:e,dia_semana:parseInt(p.get("dia")),hora_inicio:p.get("inicio"),hora_fim:p.get("fim"),ativo:!0}),c.success("HORÁRIO ADICIONADO!"),i()};return s.jsx("div",{className:"fixed inset-0 bg-black/60 z-[60] flex items-center justify-center backdrop-blur-sm p-0",children:s.jsxs("div",{className:"bg-white shadow-2xl w-full h-dvh md:w-[96vw] md:h-[98vh] rounded-none md:rounded-2xl flex flex-col overflow-hidden animate-in zoom-in-95 duration-200",children:[s.jsxs("div",{className:"px-6 py-4 border-b border-gray-100 flex justify-between items-center bg-gray-50",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-black text-gray-900 uppercase leading-tight",children:"ESCALA DE ATENDIMENTO"}),s.jsx("p",{className:"text-[10px] text-blue-600 font-bold uppercase",children:t.nome})]}),s.jsx("button",{onClick:n,className:"p-2 hover:bg-gray-200 rounded-xl transition-colors",children:s.jsx(Qe,{size:20})})]}),s.jsxs("div",{className:"p-6 space-y-6",children:[s.jsxs("form",{onSubmit:f,className:"grid grid-cols-1 md:grid-cols-4 gap-3 bg-blue-50/50 p-4 rounded-xl border border-blue-100",children:[s.jsx("select",{name:"dia",className:"bg-white border-blue-200 border rounded-lg p-2 text-xs font-bold uppercase",required:!0,children:d.map((h,p)=>s.jsx("option",{value:p,children:h},p))}),s.jsx("input",{name:"inicio",type:"time",className:"bg-white border-blue-200 border rounded-lg p-2 text-xs font-bold",required:!0}),s.jsx("input",{name:"fim",type:"time",className:"bg-white border-blue-200 border rounded-lg p-2 text-xs font-bold",required:!0}),s.jsxs("button",{type:"submit",className:"bg-blue-600 text-white rounded-lg font-black text-[10px] uppercase hover:bg-blue-700 transition-all flex items-center justify-center gap-2",children:[s.jsx(ft,{size:14})," ADICIONAR"]})]}),s.jsx("div",{className:"space-y-2 flex-1 overflow-y-auto pr-2",children:r==null?void 0:r.map(h=>s.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 rounded-xl border border-gray-100 hover:border-blue-200 transition-all group",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"w-10 h-10 bg-white rounded-lg flex items-center justify-center shadow-sm text-blue-600 border border-gray-100 font-black text-[10px]",children:d[h.dia_semana].substring(0,3)}),s.jsxs("div",{className:"flex items-center gap-2 text-xs font-black text-gray-700",children:[s.jsx(Fl,{size:14,className:"text-gray-400"}),s.jsx("span",{children:h.hora_inicio.substring(0,5)}),s.jsx(Ls,{size:12,className:"text-gray-300"}),s.jsx("span",{children:h.hora_fim.substring(0,5)})]})]}),s.jsx("button",{onClick:async()=>{await J.deleteHorario(h.id),i(),c.success("REMOVIDO!")},className:"p-2 text-gray-300 hover:text-red-500 hover:bg-red-50 rounded-lg transition-all opacity-0 group-hover:opacity-100",children:s.jsx($t,{size:16})})]},h.id))})]})]})})},oB=()=>{const t=J.getActiveWorkspace(),{data:e,isLoading:n,error:r,refresh:i}=_e(()=>J.getDentistas(t==null?void 0:t.id)),[c,d]=w.useState(!1),[f,h]=w.useState(null),[p,b]=w.useState(!1),[y,m]=w.useState(null),[v,N]=w.useState([]),S=Fe(),j=async()=>{try{const B=await(await fetch("/api/auth/google/status")).json();N(B)}catch(_){console.error("Erro ao buscar status do Google:",_)}};w.useEffect(()=>{j()},[]),w.useEffect(()=>{if(!c)return;const _=B=>{B.key==="Escape"&&d(!1)};return document.addEventListener("keydown",_),()=>{document.removeEventListener("keydown",_)}},[c]);const R=async _=>{_.preventDefault();const B=new FormData(_.target),F=Object.fromEntries(B);try{f&&f.id?(await J.updateDentista({...f,...F}),S.success("DENTISTA ATUALIZADO!")):(await J.saveDentista({...F,ativo:!0}),S.success("DENTISTA CADASTRADO!")),d(!1),i()}catch{S.error("ERRO AO SALVAR DENTISTA.")}},C=async _=>{window.confirm("TEM CERTEZA QUE DESEJA EXCLUIR ESTE DENTISTA?")&&(await J.deleteDentista(_),S.success("Dentista excluído."),i())},[O,A]=w.useState(null),k=async _=>{try{const B=J.getActiveWorkspace(),F=await fetch("/api/dentistas/magic-link",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clinicaId:B.id,dentistName:_.nome})}),{link:G}=await F.json();await navigator.clipboard.writeText(G),A(_.id),S.success("LINK MÁGICO COPIADO!"),setTimeout(()=>A(null),2e3)}catch{S.error("ERRO AO GERAR LINK.")}};return s.jsxs(Mu,{title:"DENTISTAS & ESPECIALISTAS",buttonLabel:"NOVO DENTISTA",onButtonClick:()=>{h({}),d(!0)},children:[n&&s.jsx(Ct,{className:"animate-spin text-blue-500"}),r&&s.jsxs("p",{className:"text-red-500",children:["Erro: ",r.message]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:e==null?void 0:e.map(_=>s.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl shadow-sm hover:shadow-md transition-shadow flex flex-col",children:[s.jsxs("div",{className:"p-5 flex-grow",children:[s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"font-bold text-gray-900 uppercase",children:_.nome}),s.jsx("span",{className:"text-xs font-bold text-blue-600 bg-blue-50 px-2 py-0.5 rounded-full uppercase",children:_.especialidade})]}),s.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-white shadow",style:{backgroundColor:_.corAgenda}})]}),s.jsxs("div",{className:"mt-4 space-y-2 text-xs text-gray-500",children:[s.jsxs("p",{className:"flex items-center gap-2 font-medium",children:[s.jsx(Rg,{size:14})," ",_.email]}),s.jsxs("p",{className:"flex items-center gap-2 font-medium",children:[s.jsx(qN,{size:14})," ",_.telefone]})]}),s.jsxs("div",{className:"mt-5 border-t border-gray-50 pt-4 flex items-center gap-2",children:[s.jsx("div",{className:"flex-1",children:s.jsx(du,{ownerId:_.id,isConnected:v.some(B=>B.owner_id===_.id),onStatusChange:j})}),s.jsx("button",{onClick:()=>k(_),title:"COMPARTILHAR LINK DE CADASTRO",className:`p-2.5 rounded-xl border transition-all ${O===_.id?"bg-green-50 text-green-600 border-green-200":"bg-gray-50 text-gray-400 border-gray-100 hover:bg-blue-50 hover:text-blue-600 hover:border-blue-100"}`,children:O===_.id?s.jsx(fo,{size:18}):s.jsx($N,{size:18})})]})]}),s.jsxs("div",{className:"border-t border-gray-100 p-2 grid grid-cols-3 gap-1",children:[s.jsxs("button",{onClick:()=>{h(_),d(!0)},className:"text-[10px] uppercase font-bold text-gray-600 hover:bg-gray-100 py-2 rounded-md flex items-center justify-center gap-1",children:[s.jsx(Lo,{size:12})," EDITAR"]}),s.jsxs("button",{onClick:()=>{m(_),b(!0)},className:"text-[10px] uppercase font-bold text-blue-600 hover:bg-blue-50 py-2 rounded-md flex items-center justify-center gap-1",children:[s.jsx(Fl,{size:12})," ESCALA"]}),s.jsxs("button",{onClick:()=>C(_.id),className:"text-[10px] uppercase font-bold text-red-500 hover:bg-red-50 py-2 rounded-md flex items-center justify-center gap-1",children:[s.jsx($t,{size:12})," EXCLUIR"]})]})]},_.id))}),c&&s.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center backdrop-blur-sm p-0",children:s.jsxs("div",{className:"bg-white shadow-2xl w-full h-dvh md:w-[96vw] md:h-[98vh] rounded-none md:rounded-xl flex flex-col overflow-hidden animate-in fade-in zoom-in-50 duration-200",children:[s.jsxs("div",{className:"px-5 py-4 border-b border-gray-200 flex justify-between items-center flex-shrink-0 bg-gradient-to-r from-blue-50 to-white",children:[s.jsxs("h3",{className:"text-lg font-bold text-gray-800 uppercase",children:[f!=null&&f.id?"EDITAR":"NOVO"," DENTISTA"]}),s.jsx("button",{onClick:()=>d(!1),className:"text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-lg p-1.5 transition-colors",children:s.jsx(Qe,{size:22})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-5 lg:p-8",children:s.jsxs("form",{onSubmit:R,className:"space-y-4 max-w-2xl mx-auto",children:[s.jsx("input",{id:"dentista-nome",type:"text",name:"nome",placeholder:"NOME COMPLETO",defaultValue:f==null?void 0:f.nome,className:"w-full border border-gray-300 rounded-lg p-2 uppercase-input",required:!0}),s.jsx("input",{id:"dentista-email",type:"email",name:"email",placeholder:"EMAIL",defaultValue:f==null?void 0:f.email,className:"w-full border border-gray-300 rounded-lg p-2",required:!0}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx("input",{id:"dentista-telefone",type:"text",name:"telefone",placeholder:"TELEFONE",defaultValue:f==null?void 0:f.telefone,className:"w-full border border-gray-300 rounded-lg p-2 uppercase-input"}),s.jsx("input",{id:"dentista-celular",type:"text",name:"celular",placeholder:"WHATSAPP / CELULAR",defaultValue:f==null?void 0:f.celular,className:"w-full border border-gray-300 rounded-lg p-2 uppercase-input"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx("input",{id:"dentista-cro",type:"text",name:"cro",placeholder:"NÚMERO CRO",defaultValue:f==null?void 0:f.cro,className:"w-full border border-gray-300 rounded-lg p-2 uppercase-input"}),s.jsxs("select",{id:"dentista-cro-uf",name:"cro_uf",defaultValue:(f==null?void 0:f.cro_uf)||"MS",className:"w-full border border-gray-300 rounded-lg p-2",children:[s.jsx("option",{value:"MS",children:"MS"}),s.jsx("option",{value:"SP",children:"SP"}),s.jsx("option",{value:"RJ",children:"RJ"}),s.jsx("option",{value:"MG",children:"MG"}),s.jsx("option",{value:"PR",children:"PR"}),s.jsx("option",{value:"SC",children:"SC"})]})]}),s.jsx("input",{id:"dentista-especialidade",type:"text",name:"especialidade",placeholder:"ESPECIALIDADE PRINCIPAL",defaultValue:f==null?void 0:f.especialidade,className:"w-full border border-gray-300 rounded-lg p-2 uppercase-input",required:!0}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"dentista-cor",className:"text-xs font-bold text-gray-500 uppercase",children:"COR NA AGENDA"}),s.jsx("input",{id:"dentista-cor",type:"color",name:"corAgenda",defaultValue:(f==null?void 0:f.corAgenda)||"#3B82F6",className:"w-full h-10 border border-gray-300 rounded-lg p-1"})]}),s.jsx("button",{type:"submit",className:"w-full bg-green-600 text-white py-2 rounded-lg font-bold hover:bg-green-700 uppercase",children:"SALVAR"})]})})]})}),p&&y&&t&&s.jsx(iB,{dentist:y,clinicaId:t.id,onClose:()=>{b(!1),m(null)}})]})},cB=()=>{const{data:t,isLoading:e,error:n,refresh:r}=_e(J.getEspecialidades),[i,c]=w.useState(!1),[d,f]=w.useState(null),h=Fe();w.useEffect(()=>{if(!i)return;const m=v=>{v.key==="Escape"&&c(!1)};return document.addEventListener("keydown",m),()=>{document.removeEventListener("keydown",m)}},[i]);const p=async m=>{m.preventDefault();const v=new FormData(m.target),N=Object.fromEntries(v);try{d&&d.id?(await J.updateEspecialidade({...d,...N}),h.success("ESPECIALIDADE ATUALIZADA!")):(await J.saveEspecialidade(N),h.success("ESPECIALIDADE SALVA!")),c(!1),r()}catch{h.error("ERRO AO SALVAR ESPECIALIDADE.")}},b=async m=>{window.confirm("TEM CERTEZA QUE DESEJA EXCLUIR ESTA ESPECIALIDADE?")&&(await J.deleteEspecialidade(m),h.success("Especialidade excluída."),r())},y=async m=>{if(!m.destination||!t)return;const v=Array.from(t),[N]=v.splice(m.source.index,1);v.splice(m.destination.index,0,N);const S=v.map((j,R)=>({id:j.id,ordem:R}));try{await J.reorderEspecialidades(S),h.success("ORDEM ATUALIZADA!"),r()}catch{h.error("ERRO AO REORDENAR.")}};return s.jsxs(Mu,{title:"ESPECIALIDADES CLÍNICAS",buttonLabel:"NOVA ESPECIALIDADE",onButtonClick:()=>{f({}),c(!0)},children:[s.jsx("div",{className:"bg-white border border-gray-200 rounded-xl shadow-sm overflow-hidden",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{className:"bg-gray-50 text-gray-500 uppercase text-xs font-bold",children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-6 py-3 text-left w-10"}),s.jsx("th",{className:"px-6 py-3 text-left",children:"NOME"}),s.jsx("th",{className:"px-6 py-3 text-left",children:"DESCRIÇÃO"}),s.jsx("th",{className:"px-6 py-3 text-right",children:"AÇÕES"})]})}),s.jsx(Xl,{onDragEnd:y,children:s.jsx(Kl,{droppableId:"especialidades",children:m=>s.jsxs("tbody",{...m.droppableProps,ref:m.innerRef,className:"divide-y divide-gray-100",children:[e&&s.jsx("tr",{children:s.jsx("td",{colSpan:4,className:"p-6 text-center",children:s.jsx(Ct,{className:"animate-spin text-blue-500 mx-auto"})})}),n&&s.jsx("tr",{children:s.jsx("td",{colSpan:4,className:"p-6 text-center text-red-500",children:n.message})}),t==null?void 0:t.map((v,N)=>s.jsx(Zl,{draggableId:v.id,index:N,children:(S,j)=>s.jsxs("tr",{ref:S.innerRef,...S.draggableProps,className:`${j.isDragging?"bg-blue-50 shadow-md ring-1 ring-blue-200":"bg-white"} transition-shadow`,children:[s.jsx("td",{className:"px-6 py-4 text-gray-400 cursor-grab active:cursor-grabbing",...S.dragHandleProps,children:s.jsx(ql,{size:18})}),s.jsx("td",{className:"px-6 py-4 font-bold text-gray-800",children:v.nome}),s.jsx("td",{className:"px-6 py-4 text-gray-600",children:v.descricao}),s.jsx("td",{className:"px-6 py-4 text-right",children:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{onClick:()=>{f(v),c(!0)},className:"p-2 text-gray-500 hover:bg-gray-100 rounded-md",children:s.jsx(Lo,{size:16})}),s.jsx("button",{onClick:()=>b(v.id),className:"p-2 text-gray-500 hover:bg-red-50 hover:text-red-600 rounded-md",children:s.jsx($t,{size:16})})]})})]})},v.id)),m.placeholder]})})})]})}),i&&s.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center backdrop-blur-sm p-0",children:s.jsxs("div",{className:"bg-white shadow-2xl w-full h-dvh md:w-[96vw] md:h-[98vh] rounded-none md:rounded-xl flex flex-col overflow-hidden animate-in fade-in zoom-in-50 duration-200",children:[s.jsxs("div",{className:"px-5 py-4 border-b border-gray-200 flex justify-between items-center flex-shrink-0 bg-gradient-to-r from-blue-50 to-white",children:[s.jsxs("h3",{className:"text-lg font-bold text-gray-800 uppercase",children:[d!=null&&d.id?"EDITAR":"NOVA"," ESPECIALIDADE"]}),s.jsx("button",{onClick:()=>c(!1),className:"text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-lg p-1.5 transition-colors",children:s.jsx(Qe,{size:22})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-5 lg:p-8",children:s.jsxs("form",{onSubmit:p,className:"space-y-4 max-w-2xl mx-auto",children:[s.jsx("input",{id:"esp-nome",name:"nome",placeholder:"NOME DA ESPECIALIDADE",defaultValue:d==null?void 0:d.nome,className:"w-full border border-gray-300 rounded-lg p-2 uppercase-input",required:!0}),s.jsx("textarea",{id:"esp-desc",name:"descricao",placeholder:"BREVE DESCRIÇÃO",defaultValue:d==null?void 0:d.descricao,className:"w-full border border-gray-300 rounded-lg p-2 h-24 uppercase-textarea"}),s.jsx("button",{type:"submit",className:"w-full bg-green-600 text-white py-2 rounded-lg font-bold hover:bg-green-700 uppercase",children:"SALVAR"})]})})]})})]})},dB=()=>{const{data:t,isLoading:e,error:n,refresh:r}=_e(J.getProcedimentos),{data:i}=_e(J.getEspecialidades),{data:c}=_e(J.getPlanos),[d,f]=w.useState(!1),[h,p]=w.useState(null),[b,y]=w.useState([]),m=Fe();w.useEffect(()=>{if(!d)return;const A=k=>{k.key==="Escape"&&f(!1)};return document.addEventListener("keydown",A),()=>{document.removeEventListener("keydown",A)}},[d]),w.useEffect(()=>{h&&(y(h.valoresPlanos||[]),!h.id&&!h.categoria&&p(A=>({...A,categoria:"Particular"})))},[h]);const v=()=>{const A=((t==null?void 0:t.length)||0)+1;p(k=>({...k,codigoInterno:A.toString()}))},N=async A=>{A.preventDefault();const k=new FormData(A.target),_=Object.fromEntries(k.entries()),B=i==null?void 0:i.find(G=>G.id===_.especialidadeId),F={id:h==null?void 0:h.id,nome:_.nome,codigo:_.codigo,codigoInterno:_.codigoInterno,categoria:_.categoria,descricao:_.descricao,especialidadeId:_.especialidadeId,especialidadeNome:(B==null?void 0:B.nome)||"",valorParticular:parseFloat(_.valorParticular),tipo_regiao:(h==null?void 0:h.tipo_regiao)||"GERAL",exige_face:(h==null?void 0:h.tipo_regiao)==="DENTE"?!!(h!=null&&h.exige_face):!1,valoresPlanos:b.map(G=>{var ee;return{planoId:G.planoId,planoNome:((ee=c==null?void 0:c.find(ne=>ne.id===G.planoId))==null?void 0:ee.nome)||"",valor:parseFloat(G.valor),codigoPlano:G.codigoPlano||""}})};try{F.id?(await J.updateProcedimento(F),m.success("PROCEDIMENTO ATUALIZADO!")):(await J.saveProcedimento(F),m.success("PROCEDIMENTO SALVO!")),f(!1),r()}catch{m.error("ERRO AO SALVAR PROCEDIMENTO.")}},S=async A=>{window.confirm("TEM CERTEZA QUE DESEJA EXCLUIR ESTE PROCEDIMENTO?")&&(await J.deleteProcedimento(A),m.success("Procedimento excluído."),r())},j=()=>y(A=>[...A,{planoId:"",valor:0,codigoPlano:""}]),R=A=>y(k=>k.filter((_,B)=>B!==A)),C=(A,k,_)=>{const B=[...b];B[A]={...B[A],[k]:_},y(B)},O=async A=>{if(!A.destination||!t)return;const k=Array.from(t),[_]=k.splice(A.source.index,1);k.splice(A.destination.index,0,_);const B=k.map((F,G)=>({id:F.id,ordem:G}));try{await J.reorderProcedimentos(B),m.success("ORDEM DOS PROCEDIMENTOS ATUALIZADA!"),r()}catch{m.error("ERRO AO REORDENAR PROCEDIMENTOS.")}};return s.jsxs(Mu,{title:"PROCEDIMENTOS E VALORES",buttonLabel:"NOVO PROCEDIMENTO",onButtonClick:()=>{p({}),f(!0)},children:[s.jsx("div",{className:"bg-white border border-gray-200 rounded-xl shadow-sm overflow-hidden",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{className:"bg-gray-50 text-gray-500 uppercase text-xs font-bold",children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-6 py-3 text-left w-10"}),s.jsx("th",{className:"px-6 py-3 text-left",children:"NOME"}),s.jsx("th",{className:"px-6 py-3 text-left",children:"CÓDIGO (TUSS/INT)"}),s.jsx("th",{className:"px-6 py-3 text-left",children:"CATEGORIA"}),s.jsx("th",{className:"px-6 py-3 text-left",children:"ESPECIALIDADE"}),s.jsx("th",{className:"px-6 py-3 text-left",children:"VALOR PARTICULAR"}),s.jsx("th",{className:"px-6 py-3 text-right",children:"AÇÕES"})]})}),s.jsx(Xl,{onDragEnd:O,children:s.jsx(Kl,{droppableId:"procedimentos",children:A=>s.jsxs("tbody",{...A.droppableProps,ref:A.innerRef,className:"divide-y divide-gray-100",children:[e&&s.jsx("tr",{children:s.jsx("td",{colSpan:7,className:"p-6 text-center",children:s.jsx(Ct,{className:"animate-spin text-blue-500 mx-auto"})})}),n&&s.jsx("tr",{children:s.jsx("td",{colSpan:7,className:"p-6 text-center text-red-500",children:n.message})}),t==null?void 0:t.map((k,_)=>s.jsx(Zl,{draggableId:k.id,index:_,children:(B,F)=>s.jsxs("tr",{ref:B.innerRef,...B.draggableProps,className:`${F.isDragging?"bg-blue-50 shadow-md ring-1 ring-blue-200":"bg-white"} transition-shadow`,children:[s.jsx("td",{className:"px-6 py-4 text-gray-400 cursor-grab active:cursor-grabbing",...B.dragHandleProps,children:s.jsx(ql,{size:18})}),s.jsx("td",{className:"px-6 py-4 font-bold text-gray-800",children:k.nome}),s.jsx("td",{className:"px-6 py-4",children:s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsxs("span",{className:"text-[10px] font-bold text-gray-400 uppercase",children:["TUSS: ",k.codigo||"---"]}),s.jsxs("span",{className:"text-[10px] font-bold text-blue-600 uppercase bg-blue-50 px-1.5 py-0.5 rounded w-fit",children:["INT: ",k.codigoInterno||"---"]})]})}),s.jsx("td",{className:"px-6 py-4",children:s.jsx("span",{className:"text-xs font-bold px-2 py-1 rounded-full bg-gray-100 text-gray-600 uppercase",children:k.categoria})}),s.jsx("td",{className:"px-6 py-4 text-gray-600",children:k.especialidadeNome}),s.jsxs("td",{className:"px-6 py-4 font-semibold text-gray-700",children:["R$ ",Number(k.valorParticular).toFixed(2)]}),s.jsx("td",{className:"px-6 py-4 text-right",children:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{onClick:()=>{p(k),f(!0)},className:"p-2 text-gray-500 hover:bg-gray-100 rounded-md",children:s.jsx(Lo,{size:16})}),s.jsx("button",{onClick:()=>S(k.id),className:"p-2 text-gray-500 hover:bg-red-50 hover:text-red-600 rounded-md",children:s.jsx($t,{size:16})})]})})]})},k.id)),A.placeholder]})})})]})}),d&&s.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center backdrop-blur-sm p-0",children:s.jsxs("div",{className:"bg-white shadow-2xl w-full h-dvh md:w-[96vw] md:h-[98vh] rounded-none md:rounded-xl flex flex-col overflow-hidden animate-in fade-in zoom-in-50 duration-200",children:[s.jsxs("div",{className:"px-5 py-4 border-b border-gray-200 flex justify-between items-center flex-shrink-0 bg-gradient-to-r from-blue-50 to-white",children:[s.jsxs("h3",{className:"text-lg font-bold text-gray-800 uppercase",children:[h!=null&&h.id?"EDITAR":"NOVO"," PROCEDIMENTO"]}),s.jsx("button",{onClick:()=>f(!1),className:"text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-lg p-1.5 transition-colors",children:s.jsx(Qe,{size:22})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-5 lg:p-8",children:s.jsxs("form",{onSubmit:N,className:"space-y-4 max-w-2xl mx-auto pb-4",children:[s.jsx("input",{name:"nome",placeholder:"NOME DO PROCEDIMENTO",defaultValue:h==null?void 0:h.nome,className:"w-full border border-gray-300 rounded-lg p-2 uppercase-input",required:!0}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-bold text-gray-500 uppercase",children:"CATEGORIA"}),s.jsxs("select",{name:"categoria",value:(h==null?void 0:h.categoria)||"Particular",onChange:A=>{const k=A.target.value;p(_=>({..._,categoria:k})),k==="Particular"&&!(h!=null&&h.codigoInterno)&&v()},className:"w-full border border-gray-300 rounded-lg p-2 bg-white uppercase-select",required:!0,children:[s.jsx("option",{value:"Particular",children:"Particular"}),s.jsx("option",{value:"Plano",children:"Plano"}),s.jsx("option",{value:"Convênio",children:"Convênio"}),s.jsx("option",{value:"Outros",children:"Outros"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-bold text-gray-500 uppercase",children:"CÓDIGO TUSS"}),s.jsx("input",{name:"codigo",placeholder:(h==null?void 0:h.categoria)==="Plano"?"00000000":"OPCIONAL",defaultValue:h==null?void 0:h.codigo,className:`w-full border border-gray-300 rounded-lg p-2 uppercase-input ${(h==null?void 0:h.categoria)!=="Plano"?"bg-gray-50":""}`,required:(h==null?void 0:h.categoria)==="Plano"})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"text-xs font-bold text-gray-500 uppercase flex justify-between",children:["CÓDIGO INTERNO",(h==null?void 0:h.categoria)!=="Particular"&&s.jsx("button",{type:"button",onClick:v,className:"text-blue-600 hover:text-blue-800",children:s.jsx(xu,{size:12})})]}),s.jsx("input",{name:"codigoInterno",placeholder:(h==null?void 0:h.categoria)==="Particular"?"AUTO (CONTAGEM + 1)":"EX: 101",value:(h==null?void 0:h.codigoInterno)||"",onChange:A=>p(k=>({...k,codigoInterno:A.target.value})),className:`w-full border border-gray-300 rounded-lg p-2 uppercase-input ${(h==null?void 0:h.categoria)==="Particular"?"bg-gray-50 text-blue-600 font-bold":""}`,required:(h==null?void 0:h.categoria)!=="Particular"})]})]}),s.jsx("textarea",{name:"descricao",placeholder:"BREVE DESCRIÇÃO",defaultValue:h==null?void 0:h.descricao,className:"w-full border border-gray-300 rounded-lg p-2 h-20 uppercase-textarea"}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-bold text-gray-500 uppercase",children:"ESPECIALIDADE"}),s.jsxs("select",{name:"especialidadeId",defaultValue:h==null?void 0:h.especialidadeId,className:"w-full border border-gray-300 rounded-lg p-2 bg-white uppercase-select",required:!0,children:[s.jsx("option",{value:"",children:"SELECIONE UMA ESPECIALIDADE"}),i==null?void 0:i.map(A=>s.jsx("option",{value:A.id,children:A.nome},A.id))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-bold text-gray-500 uppercase",children:"VALOR PARTICULAR (R$)"}),s.jsx("input",{type:"number",step:"0.01",name:"valorParticular",placeholder:"0.00",defaultValue:h==null?void 0:h.valorParticular,className:"w-full border border-gray-300 rounded-lg p-2",required:!0})]})]}),s.jsxs("div",{className:"bg-blue-50/50 p-4 rounded-xl border border-blue-100 space-y-4",children:[s.jsxs("h4",{className:"text-[10px] font-black text-blue-600 uppercase tracking-widest flex items-center gap-2",children:[s.jsx(Vl,{size:12})," REGRA DO ODONTOGRAMA (GTO)"]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("label",{className:"text-xs font-bold text-gray-700 uppercase",children:"EXIGÊNCIA DE REGIÃO NO LANÇAMENTO"}),s.jsx("div",{className:"grid grid-cols-3 gap-2",children:[{id:"GERAL",label:"PROCED. GERAL",desc:"SEM ODONTOGRAMA"},{id:"DENTE",label:"DENTE ESPECÍFICO",desc:"LIBERA NÚMEROS"},{id:"ARCO",label:"ARCO COMPLETO",desc:"LIBERA AI / AS"}].map(A=>s.jsxs("label",{className:` relative flex flex-col p-3 rounded-lg border-2 cursor-pointer transition-all ${((h==null?void 0:h.tipo_regiao)||"GERAL")===A.id?"border-blue-600 bg-blue-50 ring-2 ring-blue-100":"border-gray-200 bg-white hover:border-gray-300"} `,children:[s.jsx("input",{type:"radio",name:"tipo_regiao",value:A.id,checked:((h==null?void 0:h.tipo_regiao)||"GERAL")===A.id,onChange:k=>p(_=>({..._,tipo_regiao:k.target.value})),className:"sr-only"}),s.jsx("span",{className:"text-[10px] font-black uppercase text-gray-900 leading-tight",children:A.label}),s.jsx("span",{className:"text-[9px] font-bold text-gray-400 mt-1 uppercase",children:A.desc})]},A.id))})]}),(h==null?void 0:h.tipo_regiao)==="DENTE"&&s.jsx("div",{className:"pt-2 animate-in slide-in-from-top-2 duration-200",children:s.jsxs("label",{className:"flex items-center gap-3 p-3 bg-white rounded-lg border border-blue-200 cursor-pointer hover:bg-blue-50/50 transition-colors",children:[s.jsx("div",{className:"relative flex items-center",children:s.jsx("input",{type:"checkbox",name:"exige_face",checked:!!(h!=null&&h.exige_face),onChange:A=>p(k=>({...k,exige_face:A.target.checked})),className:"w-5 h-5 rounded border-gray-300 text-blue-600 focus:ring-blue-500"})}),s.jsxs("div",{className:"flex flex-col",children:[s.jsx("span",{className:"text-[11px] font-black text-gray-800 uppercase",children:"Exigir preenchimento de Face?"}),s.jsx("span",{className:"text-[9px] font-bold text-gray-400 uppercase",children:"(O, M, D, V, L, P) será obrigatório na GTO"})]})]})})]}),s.jsxs("div",{className:"pt-4",children:[s.jsx("h4",{className:"font-bold text-gray-700 uppercase mb-2",children:"VALORES PARA PLANOS / CONVÊNIOS"}),s.jsx("div",{className:"space-y-2",children:b.map((A,k)=>s.jsxs("div",{className:"flex flex-col md:flex-row items-center gap-2 bg-gray-50 p-2 rounded-lg border",children:[s.jsxs("select",{value:A.planoId,onChange:_=>C(k,"planoId",_.target.value),className:"flex-1 border border-gray-300 rounded-lg p-2 bg-white uppercase-select",children:[s.jsx("option",{value:"",children:"SELECIONE UM PLANO"}),c==null?void 0:c.filter(_=>_.tipo!=="Particular").map(_=>s.jsx("option",{value:_.id,children:_.nome},_.id))]}),s.jsx("input",{type:"number",step:"0.01",placeholder:"VALOR (R$)",value:A.valor,onChange:_=>C(k,"valor",_.target.value),className:"w-32 border border-gray-300 rounded-lg p-2"}),s.jsx("input",{type:"text",placeholder:"CÓD. PLANO",value:A.codigoPlano,onChange:_=>C(k,"codigoPlano",_.target.value),className:"w-32 border border-gray-300 rounded-lg p-2 uppercase-input"}),s.jsx("button",{type:"button",onClick:()=>R(k),className:"p-2 text-red-500 hover:bg-red-100 rounded-md",children:s.jsx($t,{size:16})})]},k))}),s.jsxs("button",{type:"button",onClick:j,className:"mt-2 text-xs font-bold text-blue-600 hover:underline uppercase flex items-center gap-1",children:[s.jsx(ft,{size:14})," ADICIONAR VALOR DE PLANO"]})]}),s.jsx("div",{className:"pt-4 flex-shrink-0",children:s.jsx("button",{type:"submit",className:"w-full bg-green-600 text-white py-4 rounded-xl font-black hover:bg-green-700 uppercase text-xs shadow-lg shadow-green-100 transition-all active:scale-[0.98]",children:"SALVAR PROCEDIMENTO"})})]})})]})})]})},uB=()=>{const{data:t,isLoading:e,error:n,refresh:r}=_e(J.getPlanos),[i,c]=w.useState(!1),[d,f]=w.useState(null),h=Fe();w.useEffect(()=>{if(!i)return;const y=m=>{m.key==="Escape"&&c(!1)};return document.addEventListener("keydown",y),()=>{document.removeEventListener("keydown",y)}},[i]);const p=async y=>{y.preventDefault();const m=new FormData(y.target),v=Object.fromEntries(m);try{d&&d.id?(await J.updatePlano({...d,...v}),h.success("PLANO ATUALIZADO!")):(await J.savePlano(v),h.success("PLANO SALVO!")),c(!1),r()}catch{h.error("ERRO AO SALVAR PLANO.")}},b=async y=>{window.confirm("TEM CERTEZA QUE DESEJA EXCLUIR ESTE PLANO?")&&(await J.deletePlano(y),h.success("Plano excluído."),r())};return s.jsxs(Mu,{title:"PLANOS E CONVÊNIOS",buttonLabel:"NOVO PLANO",onButtonClick:()=>{f({}),c(!0)},children:[e&&s.jsx(Ct,{className:"animate-spin text-blue-500"}),n&&s.jsxs("p",{className:"text-red-500",children:["Erro: ",n.message]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:t==null?void 0:t.map(y=>s.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl shadow-sm hover:shadow-md transition-shadow flex flex-col overflow-hidden",style:{borderTop:`4px solid ${y.corCartao}`},children:[s.jsxs("div",{className:"p-5 flex-grow",children:[s.jsxs("div",{className:"flex justify-between items-start",children:[s.jsx("h3",{className:"font-bold text-gray-900 uppercase",children:y.nome}),s.jsx("span",{className:"text-xs font-bold text-gray-500 bg-gray-100 px-2 py-0.5 rounded-full uppercase",children:y.tipo})]}),s.jsxs("p",{className:"text-sm text-gray-600 mt-2",children:["DESCONTO PADRÃO: ",s.jsxs("span",{className:"font-bold",children:[y.descontoPadrao,"%"]})]})]}),s.jsxs("div",{className:"border-t border-gray-100 p-2 flex gap-2 bg-gray-50/50",children:[s.jsxs("button",{onClick:()=>{f(y),c(!0)},className:"flex-1 text-xs uppercase font-bold text-gray-600 hover:bg-gray-100 py-2 rounded-md flex items-center justify-center gap-2",children:[s.jsx(Lo,{size:14})," EDITAR"]}),s.jsxs("button",{onClick:()=>b(y.id),className:"flex-1 text-xs uppercase font-bold text-red-500 hover:bg-red-50 py-2 rounded-md flex items-center justify-center gap-2",children:[s.jsx($t,{size:14})," EXCLUIR"]})]})]},y.id))}),i&&s.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center backdrop-blur-sm p-0",children:s.jsxs("div",{className:"bg-white shadow-2xl w-full h-dvh md:w-[96vw] md:h-[98vh] rounded-none md:rounded-xl flex flex-col overflow-hidden animate-in fade-in zoom-in-50 duration-200",children:[s.jsxs("div",{className:"px-5 py-4 border-b border-gray-200 flex justify-between items-center flex-shrink-0 bg-gradient-to-r from-blue-50 to-white",children:[s.jsxs("h3",{className:"text-lg font-bold text-gray-800 uppercase",children:[d!=null&&d.id?"EDITAR":"NOVO"," PLANO"]}),s.jsx("button",{onClick:()=>c(!1),className:"text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-lg p-1.5 transition-colors",children:s.jsx(Qe,{size:22})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-5 lg:p-8",children:s.jsxs("form",{onSubmit:p,className:"space-y-4 max-w-2xl mx-auto",children:[s.jsx("input",{name:"nome",placeholder:"NOME DO PLANO/CONVÊNIO",defaultValue:d==null?void 0:d.nome,className:"w-full border border-gray-300 rounded-lg p-2 uppercase-input",required:!0}),s.jsxs("select",{name:"tipo",defaultValue:(d==null?void 0:d.tipo)||"Convenio",className:"w-full border border-gray-300 rounded-lg p-2 bg-white uppercase-select",required:!0,children:[s.jsx("option",{children:"Convenio"}),s.jsx("option",{children:"Particular"}),s.jsx("option",{children:"Parceria"})]}),s.jsx("input",{type:"number",name:"descontoPadrao",placeholder:"DESCONTO PADRÃO (%)",defaultValue:d==null?void 0:d.descontoPadrao,className:"w-full border border-gray-300 rounded-lg p-2"}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-bold text-gray-500 uppercase",children:"COR DO CARTÃO"}),s.jsx("input",{type:"color",name:"corCartao",defaultValue:(d==null?void 0:d.corCartao)||"#1f2937",className:"w-full h-10 border border-gray-300 rounded-lg p-1"})]}),s.jsx("button",{type:"submit",className:"w-full bg-green-600 text-white py-2 rounded-lg font-bold hover:bg-green-700 uppercase",children:"SALVAR"})]})})]})})]})},fB=["pacientes","agendamentos","financeiro","leads","guias"],hB=()=>{const[t,e]=w.useState([]),[n,r]=w.useState(null),[i,c]=w.useState(null),d=Fe(),f={Authorization:`Bearer ${localStorage.getItem("SCOREODONTO_AUTH_TOKEN")}`,"Content-Type":"application/json"},h=async()=>{try{const y=await fetch("/api/sync/status",{headers:f});y.ok&&c(await y.json())}catch{}};w.useEffect(()=>{h()},[]);const p=async y=>{r(y),e([`>>> ${{push:"BACKUP PostgreSQL → Google Sheets",pull:"RESTAURAR Google Sheets → PostgreSQL","import-legacy":"IMPORTAR PACIENTES (aba PACIENTES-CONSULTT-CLINIC)..."}[y]}...`]);try{const N=await(await fetch(`/api/sync/${y}`,{method:"POST",headers:f})).json();if(e(N.logs||[]),N.success){const S={push:"BACKUP REALIZADO!",pull:"DADOS RESTAURADOS!","import-legacy":`${N.imported??0} PACIENTES IMPORTADOS!`};d.success(S[y]),h()}else d.error("ERRO NA SINCRONIZAÇÃO. VERIFIQUE OS LOGS.")}catch(v){e(N=>[...N,`[ERRO] ${v.message}`]),d.error("FALHA NA CONEXÃO.")}finally{r(null)}},b=y=>y?new Date(y).toLocaleString("pt-BR",{day:"2-digit",month:"2-digit",hour:"2-digit",minute:"2-digit"}):"—";return s.jsxs("div",{className:"max-w-5xl mx-auto space-y-6",children:[s.jsx(cn,{title:"BACKUP & SINCRONIZAÇÃO",description:"POSTGRESQL ↔ GOOGLE SHEETS",children:s.jsxs("div",{className:"flex gap-3",children:[s.jsxs("button",{onClick:()=>p("push"),disabled:!!n,className:`px-4 py-2 rounded-xl flex items-center gap-2 text-xs font-black uppercase transition-all shadow-sm ${n?"bg-gray-200 text-gray-400 cursor-not-allowed":"bg-green-600 hover:bg-green-700 text-white shadow-green-100"}`,children:[s.jsx(xu,{size:15,className:n==="push"?"animate-spin":""}),n==="push"?"ENVIANDO...":"BACKUP AGORA"]}),s.jsxs("button",{onClick:()=>p("pull"),disabled:!!n,className:`px-4 py-2 rounded-xl flex items-center gap-2 text-xs font-black uppercase transition-all shadow-sm ${n?"bg-gray-200 text-gray-400 cursor-not-allowed":"bg-blue-600 hover:bg-blue-700 text-white shadow-blue-100"}`,children:[s.jsx(Er,{size:15,className:n==="pull"?"animate-spin":""}),n==="pull"?"IMPORTANDO...":"RESTAURAR DO BACKUP"]}),s.jsxs("button",{onClick:()=>p("import-legacy"),disabled:!!n,title:"Importa pacientes da aba PACIENTES-CONSULTT-CLINIC (Apps Script)",className:`px-4 py-2 rounded-xl flex items-center gap-2 text-xs font-black uppercase transition-all shadow-sm ${n?"bg-gray-200 text-gray-400 cursor-not-allowed":"bg-amber-500 hover:bg-amber-600 text-white shadow-amber-100"}`,children:[s.jsx(Er,{size:15,className:n==="import-legacy"?"animate-spin":""}),n==="import-legacy"?"IMPORTANDO...":"IMPORTAR PLANILHA LEGADA"]})]})}),s.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 shadow-sm overflow-hidden",children:[s.jsx("div",{className:"px-6 py-4 border-b border-gray-50",children:s.jsx("h3",{className:"text-xs font-black text-gray-500 uppercase tracking-widest",children:"ESTADO DAS TABELAS"})}),s.jsx("div",{className:"divide-y divide-gray-50",children:fB.map(y=>{var N,S;const m=(N=i==null?void 0:i.syncStatus)==null?void 0:N[y],v=(S=i==null?void 0:i.counts)==null?void 0:S[y];return s.jsxs("div",{className:"flex items-center justify-between px-6 py-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`w-2 h-2 rounded-full ${m!=null&&m.lastPush?"bg-green-400":"bg-gray-200"}`}),s.jsx("span",{className:"text-sm font-black uppercase text-gray-700",children:y})]}),s.jsxs("div",{className:"flex items-center gap-8 text-right",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[9px] font-bold text-gray-400 uppercase",children:"No banco"}),s.jsx("p",{className:"text-sm font-black text-gray-800",children:v??"—"})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[9px] font-bold text-gray-400 uppercase",children:"Último backup"}),s.jsx("p",{className:"text-xs font-bold text-gray-600",children:b(m==null?void 0:m.lastPush)})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[9px] font-bold text-gray-400 uppercase",children:"Registros no backup"}),s.jsx("p",{className:"text-xs font-bold text-gray-600",children:(m==null?void 0:m.count)??"—"})]})]})]},y)})}),(i==null?void 0:i.spreadsheetId)&&s.jsxs("div",{className:"px-6 py-3 bg-gray-50 border-t border-gray-100 flex items-center gap-2",children:[s.jsx("span",{className:"text-[10px] font-bold text-gray-400 uppercase",children:"PLANILHA:"}),s.jsx("span",{className:"text-[10px] font-mono text-blue-600 truncate",children:i.spreadsheetId})]})]}),s.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 shadow-sm overflow-hidden",children:[s.jsxs("div",{className:"px-6 py-4 border-b border-gray-50 flex items-center justify-between",children:[s.jsx("h3",{className:"text-xs font-black text-gray-500 uppercase tracking-widest",children:"LOG DE OPERAÇÃO"}),t.length>0&&s.jsx("button",{onClick:()=>e([]),className:"text-[10px] font-bold text-gray-400 hover:text-gray-600 uppercase",children:"LIMPAR"})]}),s.jsx("div",{className:"p-4",children:s.jsxs("div",{className:"bg-gray-950 rounded-xl p-4 font-mono text-xs text-green-400 min-h-[160px] max-h-80 overflow-y-auto",children:[t.length===0?s.jsx("span",{className:"text-gray-600",children:"AGUARDANDO OPERAÇÃO..."}):t.map((y,m)=>s.jsx("div",{className:`mb-1 pl-2 border-l-2 ${y.startsWith("[ERRO]")?"border-red-500 text-red-400":y.startsWith("[✓]")?"border-green-400 text-green-300":"border-gray-700"}`,children:y},m)),n&&s.jsx("div",{className:"animate-pulse text-green-500 mt-1",children:"▋"})]})}),s.jsxs("div",{className:"bg-amber-50 border-t border-amber-100 px-6 py-3 flex items-start gap-3",children:[s.jsx(Er,{size:14,className:"text-amber-600 mt-0.5 flex-shrink-0"}),s.jsx("p",{className:"text-[10px] text-amber-700 font-bold uppercase leading-relaxed",children:'BACKUP AUTOMÁTICO: cada alteração de paciente, agendamento, financeiro ou lead é enviada para a planilha automaticamente (com delay de 5s para agrupar alterações). Use "Restaurar" para recuperar dados da planilha caso o banco seja reiniciado.'})]})]})]})},pB=()=>{const[t,e]=w.useState([]),[n,r]=w.useState(!0),[i,c]=w.useState(""),[d,f]=w.useState("all"),[h,p]=w.useState("all"),b=Fe(),y=async()=>{r(!0);try{const C=await J.getNotifications();e(C.sort((O,A)=>new Date(A.data).getTime()-new Date(O.data).getTime()))}catch{b.error("Erro ao carregar notificações")}finally{r(!1)}};w.useEffect(()=>{y()},[]);const m=async C=>{try{await J.markNotificationRead(C),e(O=>O.map(A=>A.id===C?{...A,lida:!0}:A)),b.success("Notificação marcada como lida")}catch{b.error("Erro ao atualizar notificação")}},v=async()=>{if(t.filter(O=>!O.lida).length!==0)try{await J.markAllNotificationsRead(),e(O=>O.map(A=>({...A,lida:!0}))),b.success("Todas as notificações foram marcadas como lidas")}catch{b.error("Erro ao atualizar notificações")}},N=async C=>{try{await J.deleteNotification(C),e(O=>O.filter(A=>A.id!==C)),b.success("Notificação removida")}catch{b.error("Erro ao excluir notificação")}},S=C=>{switch(C){case"agenda":return s.jsx(Et,{size:20,className:"text-blue-500"});case"financeiro":return s.jsx(Ba,{size:20,className:"text-emerald-500"});case"lead":return s.jsx($l,{size:20,className:"text-amber-500"});case"sistema":return s.jsx(Id,{size:20,className:"text-red-500"});default:return s.jsx(Tg,{size:20,className:"text-gray-500"})}},j=t.filter(C=>{const O=C.titulo.toLowerCase().includes(i.toLowerCase())||C.mensagem.toLowerCase().includes(i.toLowerCase()),A=d==="all"||d==="unread"&&!C.lida||d==="important"&&C.tipo==="sistema",k=h==="all"||C.tipo===h;return O&&A&&k}),R=t.filter(C=>!C.lida).length;return s.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500",children:[s.jsx(cn,{title:"CENTRO DE NOTIFICAÇÕES",children:s.jsxs("div",{className:"flex gap-3",children:[s.jsxs("button",{onClick:v,className:"flex items-center gap-2 px-4 py-2 bg-white border border-slate-200 text-slate-600 hover:text-blue-600 hover:border-blue-200 rounded-xl font-bold text-xs uppercase tracking-wider transition-all shadow-sm",children:[s.jsx(da,{size:16})," Marcar todas como lidas"]}),s.jsxs("button",{onClick:y,className:"flex items-center gap-2 px-4 py-2 bg-blue-600 text-white hover:bg-blue-700 rounded-xl font-bold text-xs uppercase tracking-wider transition-all shadow-md active:scale-95",children:[s.jsx(uo,{size:16})," Atualizar"]})]})}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[{label:"Total",count:t.length,icon:nv,color:"text-slate-600",bg:"bg-slate-100"},{label:"Não Lidas",count:R,icon:uo,color:"text-blue-600",bg:"bg-blue-50"},{label:"Sistema",count:t.filter(C=>C.tipo==="sistema").length,icon:Id,color:"text-red-600",bg:"bg-red-50"},{label:"Financeiro",count:t.filter(C=>C.tipo==="financeiro").length,icon:Ba,color:"text-emerald-600",bg:"bg-emerald-50"}].map((C,O)=>s.jsxs("div",{className:"bg-white p-5 rounded-2xl border border-slate-100 shadow-sm flex items-center gap-4 group hover:shadow-md transition-all",children:[s.jsx("div",{className:`p-3 rounded-xl ${C.bg} ${C.color} group-hover:scale-110 transition-transform`,children:s.jsx(C.icon,{size:24})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest",children:C.label}),s.jsx("h4",{className:"text-2xl font-black text-slate-800 tracking-tighter",children:C.count})]})]},O))}),s.jsxs("div",{className:"bg-white rounded-[2.5rem] border border-slate-100 shadow-sm overflow-hidden min-h-[600px] flex flex-col",children:[s.jsxs("div",{className:"p-8 border-b border-slate-50 flex flex-col lg:flex-row lg:items-center justify-between gap-6 bg-slate-50/30",children:[s.jsx("div",{className:"flex p-1.5 bg-slate-100 rounded-2xl w-fit",children:[{id:"all",label:"Todas"},{id:"unread",label:"Não Lidas"},{id:"important",label:"Importantes"}].map(C=>s.jsxs("button",{onClick:()=>f(C.id),className:`px-6 py-2.5 rounded-xl text-xs font-black uppercase tracking-widest transition-all ${d===C.id?"bg-white text-blue-600 shadow-sm":"text-slate-500 hover:text-slate-700"}`,children:[C.label,C.id==="unread"&&R>0&&s.jsx("span",{className:"ml-2 bg-blue-600 text-white px-1.5 py-0.5 rounded-md text-[9px]",children:R})]},C.id))}),s.jsxs("div",{className:"flex flex-1 max-w-2xl gap-3",children:[s.jsxs("div",{className:"relative flex-1 group",children:[s.jsx(ha,{className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400 group-focus-within:text-blue-500 transition-colors",size:18}),s.jsx("input",{type:"text",placeholder:"Pesquisar notificações...",value:i,onChange:C=>c(C.target.value),className:"w-full pl-12 pr-4 py-3.5 bg-white border border-slate-200 rounded-2xl text-sm font-bold uppercase tracking-tight focus:ring-4 focus:ring-blue-50 focus:border-blue-500 outline-none transition-all placeholder:text-slate-300"})]}),s.jsxs("select",{value:h,onChange:C=>p(C.target.value),className:"px-4 py-3.5 bg-white border border-slate-200 rounded-2xl text-xs font-black uppercase tracking-widest focus:ring-4 focus:ring-blue-50 outline-none cursor-pointer",children:[s.jsx("option",{value:"all",children:"Filtro: Todos"}),s.jsx("option",{value:"lead",children:"Novos Leads"}),s.jsx("option",{value:"agenda",children:"Agendamentos"}),s.jsx("option",{value:"financeiro",children:"Financeiro"}),s.jsx("option",{value:"sistema",children:"Alertas de Sistema"})]})]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto custom-scrollbar",children:n?s.jsxs("div",{className:"flex flex-col items-center justify-center h-[400px]",children:[s.jsx("div",{className:"w-12 h-12 border-4 border-blue-100 border-t-blue-600 rounded-full animate-spin mb-4"}),s.jsx("p",{className:"text-slate-400 font-black uppercase tracking-widest text-xs",children:"Carregando Histórico..."})]}):j.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center p-20 text-center",children:[s.jsx("div",{className:"w-32 h-32 bg-slate-50 rounded-[3rem] flex items-center justify-center mb-6",children:s.jsx(nv,{size:48,className:"text-slate-200"})}),s.jsx("h3",{className:"text-xl font-black text-slate-800 uppercase tracking-tighter",children:"Nenhuma notificação encontrada"}),s.jsx("p",{className:"text-slate-400 text-sm mt-2 max-w-sm",children:"Não existem registros que correspondam aos seus filtros ou pesquisa no momento."})]}):s.jsx("div",{className:"divide-y divide-slate-50",children:j.map((C,O)=>s.jsxs("div",{className:`group p-8 transition-all hover:bg-slate-50/50 flex flex-col md:flex-row md:items-center gap-6 relative ${C.lida?"":"bg-blue-50/20"}`,style:{animationDelay:`${O*50}ms`},children:[!C.lida&&s.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1.5 bg-blue-600 rounded-r-full shadow-[2px_0_10px_rgba(37,99,235,0.3)]"}),s.jsx("div",{className:`p-4 rounded-[1.5rem] flex-shrink-0 shadow-sm border border-white transition-transform group-hover:scale-110 ${C.tipo==="agenda"?"bg-blue-100/50 text-blue-600":C.tipo==="financeiro"?"bg-emerald-100/50 text-emerald-600":C.tipo==="lead"?"bg-amber-100/50 text-amber-600":"bg-red-100/50 text-red-600"}`,children:S(C.tipo)}),s.jsxs("div",{className:"flex-1 space-y-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx("span",{className:`text-[10px] font-black uppercase tracking-[0.2em] px-3 py-1 rounded-full ${C.tipo==="agenda"?"bg-blue-100 text-blue-600":C.tipo==="financeiro"?"bg-emerald-100 text-emerald-600":C.tipo==="lead"?"bg-amber-100 text-amber-600":"bg-red-100 text-red-600"}`,children:C.tipo}),s.jsxs("span",{className:"text-[11px] font-bold text-slate-300 flex items-center gap-1.5 uppercase tracking-wider",children:[s.jsx(Et,{size:12}),new Date(C.data).toLocaleDateString("pt-BR",{day:"2-digit",month:"short",year:"numeric"})]}),s.jsxs("span",{className:"text-[11px] font-bold text-slate-300 flex items-center gap-1.5 uppercase tracking-wider",children:[s.jsx(gB,{size:12,className:"ml-2"}),new Date(C.data).toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})]})]}),s.jsx("h3",{className:`text-lg font-black tracking-tighter uppercase ${C.lida?"text-slate-600":"text-slate-900"}`,children:C.titulo}),s.jsx("p",{className:"text-slate-500 text-sm leading-relaxed max-w-4xl",children:C.mensagem})]}),s.jsxs("div",{className:"flex items-center gap-3 opacity-0 group-hover:opacity-100 transition-all transform translate-x-4 group-hover:translate-x-0",children:[!C.lida&&s.jsx("button",{onClick:()=>m(C.id),className:"p-3 bg-blue-600 text-white rounded-xl shadow-lg shadow-blue-100 hover:bg-blue-700 hover:-translate-y-1 transition-all",title:"Marcar como lida",children:s.jsx(da,{size:20})}),s.jsx("button",{onClick:()=>N(C.id),className:"p-3 bg-white text-slate-400 border border-slate-100 rounded-xl shadow-sm hover:text-red-600 hover:border-red-100 hover:-translate-y-1 transition-all",title:"Excluir",children:s.jsx($t,{size:20})}),s.jsx("button",{className:"p-3 bg-white text-slate-400 border border-slate-100 rounded-xl shadow-sm hover:text-slate-600 hover:-translate-y-1 transition-all",children:s.jsx(tD,{size:20})})]})]},C.id))})}),s.jsxs("div",{className:"p-6 bg-slate-50 border-t border-slate-100 flex items-center justify-between",children:[s.jsxs("p",{className:"text-[11px] font-bold text-slate-400 uppercase tracking-widest",children:["Mostrando ",j.length," de ",t.length," registros"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{className:"px-5 py-2 rounded-xl bg-white border border-slate-200 text-[11px] font-black uppercase tracking-wider text-slate-500 hover:bg-slate-50 transition-colors",children:"Voltar"}),s.jsx("button",{className:"px-5 py-2 rounded-xl bg-white border border-slate-200 text-[11px] font-black uppercase tracking-wider text-slate-500 hover:bg-slate-50 transition-colors",children:"Próximo"})]})]})]})]})},gB=({size:t,className:e})=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),mB=()=>{var m,v,N;const t=J.getActiveWorkspace(),[e,n]=w.useState(new Date(new Date().getFullYear(),new Date().getMonth(),1).toISOString().split("T")[0]),[r,i]=w.useState(new Date().toISOString().split("T")[0]),{data:c,isLoading:d,refresh:f}=_e(()=>t?J.getProductivityReport(t.id,e,r):Promise.resolve(null),[t==null?void 0:t.id,e,r]),h=((m=c==null?void 0:c.financeiro)==null?void 0:m.receita)||0,p=((v=c==null?void 0:c.financeiro)==null?void 0:v.despesa)||0,b=h-p,y=()=>{if(!c)return;let S=`Dentista,Total,Concluidos,Faltas,Taxa Ocupacao `;c.producao.forEach(O=>{const A=O.totalAgendamentos>0?(O.concluidos/O.totalAgendamentos*100).toFixed(1):0;S+=`${O.dentista},${O.totalAgendamentos},${O.concluidos},${O.faltas},${A}% `});const j=new Blob([S],{type:"text/csv"}),R=window.URL.createObjectURL(j),C=document.createElement("a");C.href=R,C.download=`relatorio_producao_${e}_${r}.csv`,C.click()};return s.jsxs("div",{className:"space-y-8 animate-in fade-in duration-500 pb-10",children:[s.jsx(cn,{title:"RELATÓRIOS & PERFORMANCE",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("button",{onClick:()=>window.print(),className:"bg-white border border-gray-200 text-gray-600 p-2 rounded-lg hover:bg-gray-50 flex items-center gap-2 text-xs font-bold transition-all shadow-sm",children:[s.jsx(Va,{size:16})," ",s.jsx("span",{className:"hidden sm:inline",children:"IMPRIMIR"})]}),s.jsxs("button",{onClick:y,className:"bg-white border border-gray-200 text-gray-600 p-2 rounded-lg hover:bg-gray-50 flex items-center gap-2 text-xs font-bold transition-all shadow-sm",children:[s.jsx(Og,{size:16})," ",s.jsx("span",{className:"hidden sm:inline",children:"EXPORTAR"})]})]})}),s.jsxs("div",{className:"bg-white p-6 rounded-2xl shadow-sm border border-gray-100 flex flex-wrap items-end gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest flex items-center gap-2",children:[s.jsx(Et,{size:12})," INÍCIO DO PERÍODO"]}),s.jsx("input",{type:"date",value:e,onChange:S=>n(S.target.value),className:"bg-gray-50 border border-gray-200 rounded-xl px-4 py-2.5 text-sm font-bold text-gray-700 focus:ring-2 focus:ring-blue-100 outline-none transition-all"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest flex items-center gap-2",children:[s.jsx(Et,{size:12})," FIM DO PERÍODO"]}),s.jsx("input",{type:"date",value:r,onChange:S=>i(S.target.value),className:"bg-gray-50 border border-gray-200 rounded-xl px-4 py-2.5 text-sm font-bold text-gray-700 focus:ring-2 focus:ring-blue-100 outline-none transition-all"})]}),s.jsxs("button",{onClick:f,className:"bg-blue-600 text-white px-6 py-3 rounded-xl font-black text-xs uppercase hover:bg-blue-700 transition-all shadow-lg shadow-blue-200 flex items-center gap-2",children:[s.jsx(mu,{size:16})," FILTRAR"]})]}),d?s.jsxs("div",{className:"flex flex-col items-center justify-center py-20 gap-4",children:[s.jsx(Ct,{className:"animate-spin text-blue-600",size:40}),s.jsx("p",{className:"text-xs font-black text-gray-400 uppercase tracking-widest",children:"Processando dados clínicos..."})]}):s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[s.jsxs("div",{className:"bg-white p-6 rounded-2xl border border-gray-100 shadow-sm overflow-hidden relative group",children:[s.jsx("div",{className:"absolute top-0 right-0 p-4 opacity-10 group-hover:scale-110 transition-transform",children:s.jsx(Ba,{size:80,className:"text-green-600"})}),s.jsx("h4",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"RECEITA NO PERÍODO"}),s.jsxs("div",{className:"mt-2 flex items-baseline gap-2",children:[s.jsxs("span",{className:"text-2xl font-black text-gray-900",children:["R$ ",h.toLocaleString("pt-BR",{minimumFractionDigits:2})]}),s.jsxs("span",{className:"text-green-500 text-[10px] font-black flex items-center",children:[s.jsx(IN,{size:12})," +2.4%"]})]}),s.jsx("div",{className:"mt-4 w-full bg-gray-50 h-1.5 rounded-full overflow-hidden",children:s.jsx("div",{className:"bg-green-500 h-full w-[70%]"})})]}),s.jsxs("div",{className:"bg-white p-6 rounded-2xl border border-gray-100 shadow-sm overflow-hidden relative group",children:[s.jsx("div",{className:"absolute top-0 right-0 p-4 opacity-10 group-hover:scale-110 transition-transform",children:s.jsx(YN,{size:80,className:"text-red-600"})}),s.jsx("h4",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"DESPESA NO PERÍODO"}),s.jsxs("div",{className:"mt-2 flex items-baseline gap-2",children:[s.jsxs("span",{className:"text-2xl font-black text-gray-900",children:["R$ ",p.toLocaleString("pt-BR",{minimumFractionDigits:2})]}),s.jsxs("span",{className:"text-red-500 text-[10px] font-black flex items-center",children:[s.jsx(_N,{size:12})," -1.2%"]})]}),s.jsx("div",{className:"mt-4 w-full bg-gray-50 h-1.5 rounded-full overflow-hidden",children:s.jsx("div",{className:"bg-red-500 h-full w-[30%]"})})]}),s.jsxs("div",{className:"bg-white p-6 rounded-2xl border border-gray-100 shadow-sm overflow-hidden relative group",children:[s.jsx("div",{className:"absolute top-0 right-0 p-4 opacity-10 group-hover:scale-110 transition-transform",children:s.jsx(Vl,{size:80,className:"text-blue-600"})}),s.jsx("h4",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"SALDO OPERACIONAL"}),s.jsx("div",{className:"mt-2",children:s.jsxs("span",{className:`text-2xl font-black ${b>=0?"text-blue-600":"text-red-600"}`,children:["R$ ",b.toLocaleString("pt-BR",{minimumFractionDigits:2})]})}),s.jsx("p",{className:"mt-4 text-[10px] font-bold text-gray-400",children:"LIQUIDEZ ATUAL DA UNIDADE"})]}),s.jsxs("div",{className:"bg-white p-6 rounded-2xl border border-gray-100 shadow-sm overflow-hidden relative group",children:[s.jsx("div",{className:"absolute top-0 right-0 p-4 opacity-10 group-hover:scale-110 transition-transform",children:s.jsx($n,{size:80,className:"text-purple-600"})}),s.jsx("h4",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"TRANSAÇÕES"}),s.jsx("div",{className:"mt-2",children:s.jsx("span",{className:"text-2xl font-black text-gray-900",children:((N=c==null?void 0:c.financeiro)==null?void 0:N.totalTransacoes)||0})}),s.jsx("p",{className:"mt-4 text-[10px] font-bold text-gray-400",children:"MOVIMENTAÇÕES FINANCEIRAS"})]})]}),s.jsxs("div",{className:"bg-white rounded-3xl border border-gray-100 shadow-xl overflow-hidden",children:[s.jsxs("div",{className:"px-8 py-6 bg-gradient-to-r from-gray-50 to-white border-b border-gray-100 flex justify-between items-center",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 bg-blue-600 rounded-xl flex items-center justify-center text-white shadow-lg shadow-blue-200",children:s.jsx(ko,{size:20})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-black text-gray-900 uppercase",children:"PRODUTIVIDADE POR DENTISTA"}),s.jsx("p",{className:"text-[10px] text-gray-400 font-bold uppercase tracking-widest",children:"DESEMPENHO CLÍNICO NO PERÍODO"})]})]}),s.jsxs("div",{className:"hidden sm:flex items-center gap-2 px-4 py-2 bg-blue-50 rounded-full",children:[s.jsx(RC,{size:16,className:"text-blue-600"}),s.jsx("span",{className:"text-[10px] font-black text-blue-600 uppercase",children:"Visão por Especialista"})]})]}),s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-left",children:[s.jsx("thead",{className:"bg-gray-50/50",children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-8 py-5 text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"ESPECIALISTA"}),s.jsx("th",{className:"px-8 py-5 text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"TOTAL APPTS"}),s.jsx("th",{className:"px-8 py-5 text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"EFETIVADOS"}),s.jsx("th",{className:"px-8 py-5 text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"FALTAS"}),s.jsx("th",{className:"px-8 py-5 text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"TAXA OCUPAÇÃO"}),s.jsx("th",{className:"px-8 py-5 text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"STATUS"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-100",children:((c==null?void 0:c.producao)||[]).map((S,j)=>{const R=S.totalAgendamentos>0?S.concluidos/S.totalAgendamentos*100:0;return s.jsxs("tr",{className:"hover:bg-blue-50/30 transition-colors group",children:[s.jsx("td",{className:"px-8 py-5",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-8 h-8 rounded-lg bg-gray-100 flex items-center justify-center text-gray-400 font-black text-xs group-hover:bg-blue-600 group-hover:text-white transition-all",children:S.dentista.substring(0,2).toUpperCase()}),s.jsx("span",{className:"font-bold text-gray-900 uppercase text-xs",children:S.dentista})]})}),s.jsx("td",{className:"px-8 py-5 font-bold text-gray-600 text-xs",children:S.totalAgendamentos}),s.jsx("td",{className:"px-8 py-5 font-bold text-green-600 text-xs",children:S.concluidos}),s.jsx("td",{className:"px-8 py-5 font-bold text-red-500 text-xs",children:S.faltas}),s.jsx("td",{className:"px-8 py-5",children:s.jsxs("div",{className:"flex items-center gap-3 min-w-[120px]",children:[s.jsx("div",{className:"flex-1 h-2 bg-gray-100 rounded-full overflow-hidden shadow-inner",children:s.jsx("div",{className:`h-full transition-all duration-1000 ${R>70?"bg-green-500":R>40?"bg-blue-500":"bg-orange-400"}`,style:{width:`${R}%`}})}),s.jsxs("span",{className:"text-[10px] font-black text-gray-400",children:[R.toFixed(0),"%"]})]})}),s.jsx("td",{className:"px-8 py-5",children:R>75?s.jsx("span",{className:"px-2 py-1 bg-green-50 text-green-600 text-[9px] font-black rounded-lg uppercase border border-green-100",children:"Alta Performance"}):R>30?s.jsx("span",{className:"px-2 py-1 bg-blue-50 text-blue-600 text-[9px] font-black rounded-lg uppercase border border-blue-100",children:"Estável"}):s.jsx("span",{className:"px-2 py-1 bg-gray-50 text-gray-400 text-[9px] font-black rounded-lg uppercase border border-gray-100",children:"Baixa Ocupação"})})]},j)})})]})})]})]})]})},xB=()=>{const[t,e]=w.useState([]),[n,r]=w.useState(null),[i,c]=w.useState(""),[d,f]=w.useState(""),[h,p]=w.useState(!1),[b,y]=w.useState(!1),m=J.getCurrentRole(),v=J.getCurrentUserName(),N=J.getCurrentUser(),S=J.getActiveWorkspace(),j=(S==null?void 0:S.cor)||"#2563eb",R=Fe(),C={Authorization:`Bearer ${localStorage.getItem("SCOREODONTO_AUTH_TOKEN")}`,"Content-Type":"application/json"},O=async()=>{try{const B=await fetch("/api/auth/google/status");e(await B.json())}catch{}},A=async()=>{try{const B=await fetch("/api/settings/google-credentials",{headers:C});B.ok&&r(await B.json())}catch{}};w.useEffect(()=>{O(),m==="admin"&&A()},[]);const k=async()=>{if(!i.trim()||!d.trim()){R.error("PREENCHA OS DOIS CAMPOS.");return}y(!0);try{const B=await fetch("/api/settings/google-credentials",{method:"POST",headers:C,body:JSON.stringify({clientId:i.trim(),clientSecret:d.trim()})});if(B.ok)R.success("CREDENCIAIS SALVAS!"),c(""),f(""),await A();else{const F=await B.json();R.error(F.error||"ERRO AO SALVAR.")}}catch{R.error("FALHA NA CONEXÃO.")}finally{y(!1)}},_=()=>{window.confirm("TEM CERTEZA QUE DESEJA SAIR DO SISTEMA?")&&J.logout()};return s.jsxs("div",{className:"space-y-8 max-w-2xl",children:[s.jsxs("div",{className:"flex items-end justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-black text-gray-900 uppercase tracking-tight",children:"Configurações"}),s.jsx("p",{className:"text-sm text-gray-400 font-medium mt-1",children:"Gerencie seu perfil e integrações"})]}),s.jsx("span",{className:"bg-gray-100 text-gray-400 text-[11px] font-mono font-bold px-3 py-1 rounded-full border border-gray-200 mb-1",children:Ag})]}),s.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 shadow-sm overflow-hidden",children:[s.jsx("div",{className:"px-6 py-4 border-b border-gray-50",children:s.jsx("h2",{className:"text-xs font-black text-gray-500 uppercase tracking-widest",children:"Perfil"})}),s.jsx("div",{className:"p-6",children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"w-14 h-14 bg-gray-100 rounded-full flex items-center justify-center text-gray-500 border border-gray-200 flex-shrink-0",children:s.jsx(zo,{size:24})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-base font-black text-gray-800 uppercase truncate leading-none mb-1",children:v||"—"}),s.jsx("p",{className:"text-sm font-medium text-gray-400 truncate",children:N||"—"}),s.jsx("span",{className:"inline-block mt-2 text-[10px] font-black uppercase tracking-widest px-2 py-0.5 rounded-full",style:{backgroundColor:`${j}18`,color:j},children:m})]})]})})]}),s.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 shadow-sm overflow-hidden",children:[s.jsx("div",{className:"px-6 py-4 border-b border-gray-50",children:s.jsx("h2",{className:"text-xs font-black text-gray-500 uppercase tracking-widest",children:"Unidade Ativa"})}),s.jsx("div",{className:"p-6",children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center text-white flex-shrink-0",style:{backgroundColor:j},children:s.jsx(Cg,{size:20})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-black text-gray-800 uppercase",children:(S==null?void 0:S.nome)||"Sem unidade vinculada"}),(S==null?void 0:S.id)&&s.jsxs("p",{className:"text-[11px] text-gray-400 font-mono mt-0.5",children:["ID: ",S.id]})]}),s.jsx("div",{className:"ml-auto w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:j}})]})})]}),m==="admin"&&s.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 shadow-sm overflow-hidden",children:[s.jsx("div",{className:"px-6 py-4 border-b border-gray-50",children:s.jsx("h2",{className:"text-xs font-black text-gray-500 uppercase tracking-widest",children:"Integrações Google"})}),s.jsxs("div",{className:"p-6 space-y-4 border-b border-gray-50",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(av,{size:15,className:"text-gray-400"}),s.jsx("span",{className:"text-xs font-black text-gray-700 uppercase tracking-wide",children:"Credenciais OAuth 2.0"})]}),n!=null&&n.configured?s.jsxs("div",{className:"flex items-center gap-1.5 text-green-600 bg-green-50 px-3 py-1 rounded-full border border-green-100",children:[s.jsx(da,{size:12}),s.jsx("span",{className:"text-[10px] font-black uppercase",children:n.fromEnv?"Via ENV":"Configurado"})]}):s.jsxs("div",{className:"flex items-center gap-1.5 text-amber-600 bg-amber-50 px-3 py-1 rounded-full border border-amber-100",children:[s.jsx(gu,{size:12}),s.jsx("span",{className:"text-[10px] font-black uppercase",children:"Não configurado"})]})]}),(n==null?void 0:n.configured)&&n.clientIdHint&&!n.fromEnv&&s.jsxs("div",{className:"bg-gray-50 rounded-xl px-4 py-3 border border-gray-100",children:[s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase mb-1",children:"Client ID atual"}),s.jsx("p",{className:"text-xs font-mono text-gray-600",children:n.clientIdHint})]}),(n==null?void 0:n.fromEnv)&&s.jsx("p",{className:"text-[11px] text-gray-400 font-medium",children:"Credenciais carregadas via variável de ambiente. Para substituir, preencha os campos abaixo."}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1.5",children:"Client ID"}),s.jsx("input",{type:"text",value:i,onChange:B=>c(B.target.value),placeholder:n!=null&&n.configured?"Deixe vazio para manter atual":"xxxxxxxxxxxx.apps.googleusercontent.com",className:"w-full border border-gray-200 rounded-xl px-4 py-2.5 text-sm font-mono focus:ring-2 focus:ring-blue-100 focus:border-blue-300 outline-none transition-all"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black text-gray-500 uppercase tracking-wider mb-1.5",children:"Client Secret"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:h?"text":"password",value:d,onChange:B=>f(B.target.value),placeholder:n!=null&&n.configured?"Deixe vazio para manter atual":"GOCSPX-...",className:"w-full border border-gray-200 rounded-xl px-4 py-2.5 pr-10 text-sm font-mono focus:ring-2 focus:ring-blue-100 focus:border-blue-300 outline-none transition-all"}),s.jsx("button",{type:"button",onClick:()=>p(B=>!B),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:h?s.jsx(aD,{size:15}):s.jsx(rD,{size:15})})]})]}),s.jsxs("button",{onClick:k,disabled:b||!i.trim()&&!d.trim(),className:"w-full flex items-center justify-center gap-2 py-2.5 rounded-xl text-xs font-black uppercase tracking-widest transition-all disabled:opacity-40 disabled:cursor-not-allowed bg-gray-900 text-white hover:bg-gray-700",children:[b?s.jsx(Ct,{size:14,className:"animate-spin"}):s.jsx(av,{size:14}),b?"Salvando...":"Salvar Credenciais"]})]}),s.jsxs("p",{className:"text-[10px] text-gray-400 leading-relaxed",children:["Obtenha as credenciais em"," ",s.jsx("span",{className:"font-mono text-blue-500",children:"console.cloud.google.com"})," ","→ APIs & Services → Credentials → OAuth 2.0 Client ID. Adicione"," ",s.jsx("span",{className:"font-mono text-gray-600",children:"https://scoreodonto.com/api/oauth2callback"})," ","como URI de redirecionamento autorizado."]})]}),s.jsxs("div",{className:"p-6",children:[s.jsx("p",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest mb-3",children:"Conta conectada"}),s.jsx(du,{ownerId:"admin",isConnected:t.some(B=>B.owner_id==="admin"||B.owner_id===N),onStatusChange:O})]})]}),s.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 shadow-sm overflow-hidden",children:[s.jsx("div",{className:"px-6 py-4 border-b border-gray-50",children:s.jsx("h2",{className:"text-xs font-black text-gray-500 uppercase tracking-widest",children:"Segurança"})}),s.jsxs("div",{className:"p-6 space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-3 text-green-600 bg-green-50 px-4 py-3 rounded-xl border border-green-100",children:[s.jsx(Sr,{size:16}),s.jsx("span",{className:"text-xs font-bold uppercase tracking-wide",children:"Sessão ativa e autenticada"})]}),s.jsxs("button",{onClick:_,className:"w-full flex items-center justify-center gap-2 px-4 py-3 bg-red-50 text-red-600 hover:bg-red-100 rounded-xl text-xs font-black uppercase tracking-widest transition-all border border-red-100",children:[s.jsx(BN,{size:16}),"Sair do Sistema"]})]})]})]})},bB=["TODOS","Ativo","Rascunho","Assinado","Encerrado"],yB={Ativo:"bg-green-100 text-green-700",Rascunho:"bg-amber-100 text-amber-700",Assinado:"bg-blue-100 text-blue-700",Encerrado:"bg-gray-100 text-gray-600"},vB=t=>t.toLocaleString("pt-BR",{style:"currency",currency:"BRL"}),NB=()=>{const t=Fe(),{data:e,isLoading:n,refresh:r}=_e(J.getContratos),i=e??[],[c,d]=w.useState(""),[f,h]=w.useState("TODOS"),[p,b]=w.useState(!1),[y,m]=w.useState(null),[v,N]=w.useState(null),S=i.filter(k=>{const _=!c.trim()||k.pacienteNome.toLowerCase().includes(c.toLowerCase())||k.titulo.toLowerCase().includes(c.toLowerCase()),B=f==="TODOS"||k.status===f;return _&&B}),j={total:i.length,ativos:i.filter(k=>k.status==="Ativo").length,rascunhos:i.filter(k=>k.status==="Rascunho").length,encerrados:i.filter(k=>k.status==="Encerrado"||k.status==="Assinado").length},R=async(k,_)=>{if(confirm(`EXCLUIR o contrato de ${_}?`))try{await J.deleteContrato(k),t.success("CONTRATO EXCLUÍDO."),r()}catch{t.error("ERRO AO EXCLUIR CONTRATO.")}},C=()=>{m(null),b(!0)},O=k=>{m(k),b(!0)},A=k=>{N(k),b(!0)};return s.jsxs("div",{className:"h-full flex flex-col",children:[s.jsx(cn,{title:"CONTRATOS",description:"Gestão de contratos de serviços odontológicos",children:s.jsxs("button",{onClick:C,className:"bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 transition-colors uppercase font-bold text-sm shadow-sm",children:[s.jsx(ft,{size:18})," NOVO CONTRATO"]})}),s.jsx("div",{className:"grid grid-cols-4 gap-3 mb-4",children:[{label:"Total",value:j.total,color:"bg-indigo-50 text-indigo-700"},{label:"Ativos",value:j.ativos,color:"bg-green-50 text-green-700"},{label:"Rascunhos",value:j.rascunhos,color:"bg-amber-50 text-amber-700"},{label:"Encerrados/Assinados",value:j.encerrados,color:"bg-gray-50 text-gray-600"}].map(k=>s.jsxs("div",{className:`${k.color} rounded-xl p-3 text-center`,children:[s.jsx("p",{className:"text-2xl font-black",children:k.value}),s.jsx("p",{className:"text-[10px] font-bold uppercase opacity-70",children:k.label})]},k.label))}),s.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mb-4",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(ha,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none",size:16}),s.jsx("input",{type:"text",placeholder:"Buscar por paciente ou título...",className:"w-full pl-9 pr-3 py-2 border border-gray-200 rounded-lg text-sm focus:ring-2 focus:ring-indigo-100 focus:border-indigo-300 outline-none bg-white",value:c,onChange:k=>d(k.target.value)})]}),s.jsx("div",{className:"flex items-center gap-1 bg-gray-100 rounded-lg p-1 overflow-x-auto",children:bB.map(k=>s.jsx("button",{onClick:()=>h(k),className:`px-2.5 py-1 rounded-md text-[11px] font-bold transition-all whitespace-nowrap ${f===k?"bg-white text-gray-800 shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:k},k))})]}),n&&s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx(Ct,{className:"animate-spin text-indigo-400",size:32})}),!n&&S.length===0&&s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-gray-400 py-20",children:[s.jsx(za,{size:48,className:"mb-4 opacity-30"}),s.jsx("p",{className:"text-sm font-bold uppercase",children:"Nenhum contrato encontrado"}),s.jsx("p",{className:"text-xs mt-1",children:c||f!=="TODOS"?"Tente limpar os filtros.":'Clique em "NOVO CONTRATO" para começar.'}),!c&&f==="TODOS"&&s.jsxs("button",{onClick:C,className:"mt-4 flex items-center gap-2 px-4 py-2 bg-indigo-600 hover:bg-indigo-700 text-white rounded-lg text-sm font-bold transition-colors",children:[s.jsx(ft,{size:16})," Criar Primeiro Contrato"]})]}),!n&&S.length>0&&s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4 overflow-y-auto pb-6",children:S.map(k=>{var _;return s.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 shadow-sm hover:shadow-md transition-all duration-200 flex flex-col",children:[s.jsxs("div",{className:"p-4 flex-1",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[s.jsx("h3",{className:"font-black text-gray-800 text-sm uppercase leading-tight flex-1",children:k.pacienteNome}),s.jsx("span",{className:`text-[9px] font-black px-2 py-0.5 rounded-full uppercase flex-shrink-0 ${yB[k.status]||"bg-gray-100 text-gray-600"}`,children:k.status})]}),s.jsx("p",{className:"text-[11px] text-gray-500 font-medium uppercase truncate mb-2",children:k.titulo}),s.jsxs("div",{className:"flex flex-wrap gap-1 mb-3",children:[k.especialidadeNome&&s.jsx("span",{className:"bg-indigo-50 text-indigo-600 text-[9px] font-bold px-2 py-0.5 rounded-full uppercase",children:k.especialidadeNome}),k.dentistaNome&&s.jsx("span",{className:"bg-gray-50 text-gray-500 text-[9px] font-bold px-2 py-0.5 rounded-full uppercase",children:k.dentistaNome})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[10px]",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-400 font-bold uppercase block",children:"Valor Total"}),s.jsx("span",{className:"font-black text-indigo-700 text-sm",children:vB(k.valorTotal)})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-400 font-bold uppercase block",children:"Itens"}),s.jsxs("span",{className:"font-bold text-gray-700",children:[((_=k.items)==null?void 0:_.length)??0," proc."]})]}),k.dataInicio&&s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-400 font-bold uppercase block",children:"Início"}),s.jsx("span",{className:"font-bold text-gray-700",children:new Date(k.dataInicio+"T12:00").toLocaleDateString("pt-BR")})]}),k.dataFim&&s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-400 font-bold uppercase block",children:"Fim"}),s.jsx("span",{className:"font-bold text-gray-700",children:new Date(k.dataFim+"T12:00").toLocaleDateString("pt-BR")})]})]})]}),s.jsxs("div",{className:"flex border-t border-gray-100",children:[s.jsxs("button",{onClick:()=>O(k),className:"flex-1 flex items-center justify-center gap-1.5 py-2 text-indigo-600 hover:bg-indigo-50 rounded-bl-xl text-[10px] font-bold transition-colors uppercase",children:[s.jsx(Mo,{size:12})," Editar"]}),s.jsx("div",{className:"border-l border-gray-100"}),s.jsxs("button",{onClick:()=>A(k),className:"flex-1 flex items-center justify-center gap-1.5 py-2 text-gray-600 hover:bg-gray-50 text-[10px] font-bold transition-colors uppercase",children:[s.jsx(Va,{size:12})," Imprimir"]}),s.jsx("div",{className:"border-l border-gray-100"}),s.jsxs("button",{onClick:()=>R(k.id,k.pacienteNome),className:"flex-1 flex items-center justify-center gap-1.5 py-2 text-red-500 hover:bg-red-50 rounded-br-xl text-[10px] font-bold transition-colors uppercase",children:[s.jsx($t,{size:12})," Excluir"]})]})]},k.id)})}),p&&s.jsx(lS,{contrato:y,onClose:()=>{b(!1),m(null),N(null)},onSaved:r})]})},EB={"/":"landing","/dashboard":"dashboard","/landing":"landing","/leads":"leads","/contato":"public","/pacientes":"pacientes","/agenda":"agenda","/ortodontia":"ortodontia","/financeiro":"financeiro","/login":"login","/update":"update","/clinicas":"clinicas","/admin/dentistas":"dentistas","/admin/especialidades":"especialidades","/admin/procedimentos":"procedimentos","/admin/planos":"planos","/admin/sync":"sync","/tratamentos":"tratamentos","/lancar-gto":"lancar-gto","/notificacoes":"notificacoes","/relatorios":"relatorios","/cadastro-dentista":"cadastro-dentista","/configuracoes":"configuracoes","/contratos":"contratos"},SB={landing:"/",dashboard:"/dashboard",leads:"/leads",public:"/contato",pacientes:"/pacientes",agenda:"/agenda",ortodontia:"/ortodontia",financeiro:"/financeiro",login:"/login",update:"/update",clinicas:"/clinicas",dentistas:"/admin/dentistas",especialidades:"/admin/especialidades",procedimentos:"/admin/procedimentos",planos:"/admin/planos",tratamentos:"/tratamentos","lancar-gto":"/lancar-gto",notificacoes:"/notificacoes",relatorios:"/relatorios",sync:"/admin/sync","cadastro-dentista":"/cadastro-dentista",configuracoes:"/configuracoes",contratos:"/contratos"};function bN(){const t=window.location.pathname||"/";return EB[t]??"dashboard"}function no(t){const e=SB[t];history.pushState({},"",e)}const jB=()=>{const[t,e]=w.useState(!1);J.getCurrentRole();const n=J.getActiveWorkspace(),r=(n==null?void 0:n.cor)||"#2563eb",i=(m,v)=>{var S;return["landing","login","public","update"].includes(m)||v==="admin"||v==="donoclinica"?!0:((S={paciente:["tratamentos","notificacoes","configuracoes"],dentista:["dashboard","pacientes","agenda","ortodontia","tratamentos","notificacoes","clinicas","configuracoes","contratos"],funcionario:["dashboard","leads","pacientes","agenda","financeiro","tratamentos","lancar-gto","relatorios","notificacoes","clinicas","configuracoes","contratos"]}[v])==null?void 0:S.includes(m))||!1},c=m=>m==="paciente"?"tratamentos":"dashboard",d=()=>{const m=bN(),v=J.getCurrentRole();return J.isAuthenticated()&&["landing","login"].includes(m)?c(v):!["landing","login","public"].includes(m)&&!J.isAuthenticated()?"landing":J.isAuthenticated()&&!i(m,v)?c(v):m},[f,h]=w.useState(d),p=m=>{const v=J.getCurrentRole();i(m,v)&&(h(m),no(m),e(!1))};w.useEffect(()=>{const m=()=>{const v=bN(),N=J.getCurrentRole();if(!["landing","login","public"].includes(v)&&!J.isAuthenticated()){h("landing"),no("landing");return}if(J.isAuthenticated()&&!i(v,N)){const j=c(N);h(j),no(j);return}h(v)};return window.addEventListener("popstate",m),()=>window.removeEventListener("popstate",m)},[]),w.useEffect(()=>{document.documentElement.style.setProperty("--brand-color",r),document.documentElement.style.setProperty("--brand-color-soft",`${r}11`)},[r]),w.useEffect(()=>{no(f)},[]);const b=()=>{switch(f){case"landing":return s.jsx(aB,{onGetStarted:()=>p("login")});case"dashboard":return s.jsx(GO,{});case"leads":return s.jsx($O,{});case"public":return s.jsx(YO,{});case"pacientes":return s.jsx(BM,{});case"agenda":return s.jsx(DP,{});case"ortodontia":return s.jsx(VP,{});case"financeiro":return s.jsx($P,{});case"dentistas":return s.jsx(oB,{});case"especialidades":return s.jsx(cB,{});case"procedimentos":return s.jsx(dB,{});case"planos":return s.jsx(uB,{});case"sync":return s.jsx(hB,{});case"tratamentos":return s.jsx(tB,{});case"lancar-gto":return s.jsx(vM,{});case"update":return s.jsx(sB,{});case"clinicas":return s.jsx(rB,{});case"notificacoes":return s.jsx(pB,{});case"relatorios":return s.jsx(mB,{});case"cadastro-dentista":return s.jsx(lB,{});case"configuracoes":return s.jsx(xB,{});case"contratos":return s.jsx(NB,{});case"login":default:return s.jsx(nB,{onLoginSuccess:()=>{const m=J.getCurrentRole(),v=c(m);h(v),no(v)}})}},y=["landing","login","public","update","cadastro-dentista"].includes(f);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex h-screen bg-gray-50 text-gray-800 overflow-hidden relative",children:[s.jsx("style",{children:` :root { --brand-color: ${r}; } .bg-brand { background-color: var(--brand-color); } .text-brand { color: var(--brand-color); } .border-brand { border-color: var(--brand-color); } .hover\\:bg-brand:hover { background-color: var(--brand-color); } .focus\\:ring-brand:focus { --tw-ring-color: var(--brand-color); } `}),!y&&s.jsxs(s.Fragment,{children:[t&&s.jsx("div",{className:"fixed inset-0 bg-black/50 z-20 md:hidden backdrop-blur-sm transition-opacity",onClick:()=>e(!1)}),s.jsx("div",{className:`fixed inset-y-0 left-0 z-30 transform transition-transform duration-300 md:relative md:translate-x-0 ${t?"translate-x-0":"-translate-x-full"}`,children:s.jsx(IO,{activeTab:f,setActiveTab:m=>p(m)})})]}),s.jsxs("main",{className:"flex-1 h-full relative flex flex-col min-w-0",children:[!y&&s.jsx(s.Fragment,{children:s.jsxs("div",{className:"md:hidden flex items-center justify-between px-4 py-3 bg-white border-b border-gray-200",children:[s.jsx("button",{onClick:()=>e(!0),className:"p-2 text-gray-600 hover:bg-gray-100 rounded-lg transition-colors",children:s.jsx(VN,{size:24})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-8 h-8 rounded flex items-center justify-center text-white font-bold text-sm shadow-sm",style:{backgroundColor:r},children:"S"}),s.jsx("span",{className:"font-bold text-gray-800 text-sm tracking-tight uppercase",children:"SCOREODONTO"})]}),s.jsx("div",{className:"w-8"})]})}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4 md:p-8 pb-20 scroll-smooth",children:s.jsx("div",{className:"max-w-7xl mx-auto h-full",children:b()})})]})]}),s.jsx(BO,{})]})};class AB extends Ve.Component{constructor(e){super(e),this.handleReload=()=>{window.location.reload()},this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e,errorInfo:null}}componentDidCatch(e,n){console.error("Uncaught error:",e,n),this.setState({errorInfo:n})}render(){var e;return this.state.hasError?s.jsx("div",{className:"min-h-screen bg-red-50 flex items-center justify-center p-6 font-sans",children:s.jsxs("div",{className:"max-w-3xl w-full bg-white rounded-2xl shadow-2xl overflow-hidden border border-red-100",children:[s.jsxs("div",{className:"bg-red-600 p-6 flex items-center gap-4",children:[s.jsx("div",{className:"bg-white/20 p-3 rounded-full text-white",children:s.jsx(HC,{size:32})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white uppercase",children:"ERRO CRÍTICO NO SISTEMA"}),s.jsx("p",{className:"text-red-100 text-xs font-bold uppercase mt-1",children:"O APLICATIVO ENCONTROU UM PROBLEMA INESPERADO"})]})]}),s.jsxs("div",{className:"p-8",children:[s.jsxs("div",{className:"mb-6",children:[s.jsx("p",{className:"text-gray-700 font-bold uppercase mb-2",children:"O QUE ACONTECEU?"}),s.jsx("p",{className:"text-gray-600 text-sm",children:"Ocorreu uma falha durante a renderização da interface. Tente recarregar a página. Se o problema persistir, envie o log abaixo para o suporte técnico."})]}),this.state.error&&s.jsxs("div",{className:"bg-gray-900 rounded-lg p-4 mb-6 overflow-x-auto border-l-4 border-red-500",children:[s.jsxs("div",{className:"flex items-center gap-2 text-red-400 font-bold text-xs uppercase mb-2",children:[s.jsx(kg,{size:14})," Stack Trace / Log Técnico"]}),s.jsxs("pre",{className:"text-green-400 font-mono text-xs leading-relaxed whitespace-pre-wrap break-words",children:[this.state.error.toString(),s.jsx("br",{}),(e=this.state.errorInfo)==null?void 0:e.componentStack]})]}),s.jsxs("div",{className:"flex gap-4",children:[s.jsxs("button",{onClick:this.handleReload,className:"bg-red-600 hover:bg-red-700 text-white px-6 py-3 rounded-lg font-bold uppercase flex items-center gap-2 transition-colors shadow-lg",children:[s.jsx(xu,{size:18})," RECARREGAR SISTEMA"]}),s.jsx("button",{onClick:()=>{localStorage.clear(),window.location.reload()},className:"bg-gray-200 hover:bg-gray-300 text-gray-700 px-6 py-3 rounded-lg font-bold uppercase flex items-center gap-2 transition-colors",children:"LIMPAR CACHE E REINICIAR"})]})]})]})}):this.props.children}}const wB=new bU,yN=document.getElementById("root");if(yN)tC.createRoot(yN).render(s.jsx(Ve.StrictMode,{children:s.jsx(vU,{client:wB,children:s.jsx(AB,{children:s.jsx(zO,{children:s.jsx(jB,{})})})})}));else{console.error("CRITICAL: Root element #root not found. App could not be mounted.");const t=document.getElementById("global-error-display");t&&(t.style.display="block",t.innerText="ERRO CRÍTICO: O ELEMENTO #ROOT NÃO FOI ENCONTRADO NO HTML.")}